diff --git a/data/tileset_anims.asm b/data/tileset_anims.inc similarity index 98% rename from data/tileset_anims.asm rename to data/tileset_anims.inc index 86d45223..8771a459 100644 --- a/data/tileset_anims.asm +++ b/data/tileset_anims.inc @@ -1,7 +1,3 @@ -INCLUDE "constants.asm" - -SECTION "data/tileset_anims.asm", ROMX - MACRO tileframe if _NARG == 2 dw \2 ; argument @@ -11,7 +7,6 @@ MACRO tileframe dw \1 ; function ENDM - TilesetFlowerAnim: ; UnusedTilesetAnim1 in pokegold/pokecrystal. ; Scrolls tile $03 like cave water, but also has the standard $38 flower tile. diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm new file mode 100644 index 00000000..0f70c77b --- /dev/null +++ b/engine/overworld/healing_machine.asm @@ -0,0 +1,108 @@ +INCLUDE "constants.asm" + +SECTION "engine/overworld/healing_machine.asm", ROMX + +AnimateHealingMachine:: + ld a, [wPartyCount] + and a + ret z + call GroupHealingMachineSprites + ld de, PokeCenterFlashingMonitorAndHealBall + ld hl, vChars0 tile $7c + lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), 2 + call Request2bpp + ld d, 2 + call LoadHealingMachineSprites + ldh a, [rOBP1] + push af + ld a, $e0 + ldh [rOBP1], a + ld hl, wShadowOAMSprite32 + ld de, PokeCenterOAMData + call CopyHealingMachineOAM + call CopyHealingMachineOAM ; duplicate, removed code? +.waitLoop ; never called? + ld a, [wPartyCount] + ld b, a +.partyLoop + call CopyHealingMachineOAM + ld c, 30 + call DelayFrames + dec b + jr nz, .partyLoop +.next ; never called? + ld d, $28 + call FlashSprite8Times +.waitLoop2 ; never called? + ld c, 32 + call DelayFrames + ld d, 0 + call LoadHealingMachineSprites + pop af + ldh [rOBP1], a + call UngroupHealingMachineSprites + call UpdateSprites + ret + +PokeCenterFlashingMonitorAndHealBall: + INCBIN "gfx/overworld/heal_machine.2bpp" + +PokeCenterOAMData: + ; heal machine monitor + dbsprite 4, 4, 2, 0, $7c, OBP_NUM + dbsprite 4, 4, 6, 0, $7c, OBP_NUM + ; poke balls 1-6 + dbsprite 4, 4, 0, 6, $7d, OBP_NUM + dbsprite 5, 4, 0, 6, $7d, OBP_NUM | X_FLIP + dbsprite 4, 5, 0, 3, $7d, OBP_NUM + dbsprite 5, 5, 0, 3, $7d, OBP_NUM | X_FLIP + dbsprite 4, 6, 0, 0, $7d, OBP_NUM + dbsprite 5, 6, 0, 0, $7d, OBP_NUM | X_FLIP + +LoadHealingMachineSprites: + ld a, 2 + call SetObjectFacing + call UpdateSprites + ret +FlashSprite8Times: + ld b, 8 +.loop + ldh a, [rOBP1] + xor d + ldh [rOBP1], a + ld c, 10 + call DelayFrames + dec b + jr nz, .loop + ret + +CopyHealingMachineOAM: +; copy one OAM entry and advance the pointers +REPT 4 + ld a, [de] + inc de + ld [hli], a +ENDR + ret + +GroupHealingMachineSprites:: + ld hl, .group + call HealingMachineLoop + ret + +.group: + nop + sub a, h + add hl, de + +UngroupHealingMachineSprites: + ld hl, .ungroup + call HealingMachineLoop + ld a, 0 + call ObjectUseOBP0 + ret + +.ungroup: + nop + sbc a + add hl, de diff --git a/engine/dumps/bank23.asm b/engine/overworld/player_animations_old.asm similarity index 77% rename from engine/dumps/bank23.asm rename to engine/overworld/player_animations_old.asm index 83f99aa6..bab954d1 100644 --- a/engine/dumps/bank23.asm +++ b/engine/overworld/player_animations_old.asm @@ -1,257 +1,6 @@ INCLUDE "constants.asm" -SECTION "engine/dumps/bank23.asm@AnimateTilesetImpl", ROMX - -AnimateTilesetImpl: - ldh a, [hMapAnims] - and a - ret z - - ld a, [wTilesetAnim] - ld e, a - ld a, [wTilesetAnim+1] - ld d, a - ldh a, [hTileAnimFrame] - ld l, a - inc a - ldh [hTileAnimFrame], a - ld h, 0 - add hl, hl - add hl, hl - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - inc hl - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -SECTION "engine/dumps/bank23.asm@WaitTileAnimation", ROMX - -WaitTileAnimation: -; Do nothing this frame. - ret - -DoneTileAnimation: -; Reset the animation command loop. - xor a - ldh [hTileAnimFrame], a - jp TransferToolgearRow - -ScrollTileRightLeft: - ld a, [wTileAnimationTimer] - inc a - and %111 - ld [wTileAnimationTimer], a - and %100 - jr nz, ScrollTileLeft - jr ScrollTileRight - -ScrollTileLeft: - ld h, d - ld l, e - ld c, 16 / 4 -.loop -rept 4 - ld a, [hl] - rlca - ld [hli], a -endr - dec c - jr nz, .loop - ret - -ScrollTileRight: - ld h, d - ld l, e - ld c, 16 / 4 -.loop -rept 4 - ld a, [hl] - rrca - ld [hli], a -endr - dec c - jr nz, .loop - ret - -ScrollTileUp: - ld h, d - ld l, e - ld d, [hl] - inc hl - ld e, [hl] - ld bc, 16 - 2 - add hl, bc - ld a, 16 / 4 -.loop - ld c, [hl] - ld [hl], e - dec hl - ld b, [hl] - ld [hl], d - dec hl - ld e, [hl] - ld [hl], c - dec hl - ld d, [hl] - ld [hl], b - dec hl - dec a - jr nz, .loop - ret - -ScrollTileDown: - ld h, d - ld l, e - ld de, 16 - 2 - push hl - add hl, de - ld d, [hl] - inc hl - ld e, [hl] - pop hl - ld a, 16 / 4 -.loop - ld b, [hl] - ld [hl], d - inc hl - ld c, [hl] - ld [hl], e - inc hl - ld d, [hl] - ld [hl], b - inc hl - ld e, [hl] - ld [hl], c - inc hl - dec a - jr nz, .loop - ret - -AnimateFlowerTile: -; Save the stack pointer in bc for WriteTile to restore - ld hl, sp+0 - ld b, h - ld c, l - -; A cycle of 2 frames, updating every other tick - ld a, [wTileAnimationTimer] - and %10 - ld hl, FlowerTileFrame1 - jr nz, .end - ld hl, FlowerTileFrame2 - -.end -; Write the tile graphic from hl (now sp) to tile $38 (now hl) - ld sp, hl - ld hl, vTileset tile $38 - jr WriteTile - -FlowerTileFrame1: - INCBIN "gfx/tilesets/flower/flower1.2bpp" -FlowerTileFrame2: - INCBIN "gfx/tilesets/flower/flower2.2bpp" - -WriteTileFromAnimBuffer: -; Save the stack pointer in bc for WriteTile to restore - ld hl, sp+0 - ld b, h - ld c, l - -; Write the tile graphic from wTileAnimBuffer (now sp) to de (now hl) - ld hl, wTileAnimBuffer - ld sp, hl - ld h, d - ld l, e - jr WriteTile - -ReadTileToAnimBuffer: -; Save the stack pointer in bc for WriteTile to restore - ld hl, sp+0 - ld b, h - ld c, l - -; Write the tile graphic from de (now sp) to wTileAnimBuffer (now hl) - ld h, d - ld l, e - ld sp, hl - ld hl, wTileAnimBuffer - ; fallthrough - -WriteTile: -; Write one tile from sp to hl. -; The stack pointer has been saved in bc. - -; This function cannot be called, only jumped to, -; because it relocates the stack pointer to quickly -; copy data with a "pop slide". - - pop de - ld [hl], e - inc hl - ld [hl], d -rept (16 - 2) / 2 - pop de - inc hl - ld [hl], e - inc hl - ld [hl], d -endr - -; Restore the stack pointer from bc - ld h, b - ld l, c - ld sp, hl - ret - -SECTION "engine/dumps/bank23.asm@RestoreOverworldMapTiles", ROMX - -RestoreOverworldMapTiles:: - xor a - call OpenSRAM - ld hl, wTileMap - ld de, sScratch - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT - call CopyBytes - call CloseSRAM - farcall ReanchorBGMap_NoOAMUpdate - - xor a - call OpenSRAM - ld hl, sScratch - ld de, wTileMap - ld bc, SCREEN_WIDTH * SCREEN_HEIGHT -.loop - ld a, [hl] - cp $61 - jr c, .next - ld [de], a -.next - inc hl - inc de - dec bc - ld a, c - or b - jr nz, .loop - - call CloseSRAM - call UpdateSprites - call WaitBGMap - ld a, SCREEN_HEIGHT_PX - ldh [hWY], a - call DelayFrame - - xor a - ldh [hBGMapMode], a - call InitToolgearBuffer - ld b, SGB_MAP_PALS - call GetSGBLayout - ret - -SECTION "engine/dumps/bank23.asm@EnterMapAnim_Old", ROMX +SECTION "engine/overworld/player_animations_old.asm", ROMX ; A bunch of old animation functions from Generation I. ; Basically non-functional because RAM has moved around so much since then. diff --git a/engine/palettes.asm b/engine/palettes.asm index de15ecad..f3060e62 100644 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -247,3 +247,45 @@ GetFadeStep:: db $90, $80, $80 db $40, $40, $40 db $00, $00, $00 + +RestoreOverworldMapTiles:: + xor a + call OpenSRAM + ld hl, wTileMap + ld de, sScratch + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call CopyBytes + call CloseSRAM + farcall ReanchorBGMap_NoOAMUpdate + + xor a + call OpenSRAM + ld hl, sScratch + ld de, wTileMap + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT +.loop + ld a, [hl] + cp $61 + jr c, .next + ld [de], a +.next + inc hl + inc de + dec bc + ld a, c + or b + jr nz, .loop + + call CloseSRAM + call UpdateSprites + call WaitBGMap + ld a, SCREEN_HEIGHT_PX + ldh [hWY], a + call DelayFrame + + xor a + ldh [hBGMapMode], a + call InitToolgearBuffer + ld b, SGB_MAP_PALS + call GetSGBLayout + ret diff --git a/engine/sprite_anims/core.asm b/engine/sprite_anims/core.asm index a8ecaf50..d6003054 100644 --- a/engine/sprite_anims/core.asm +++ b/engine/sprite_anims/core.asm @@ -1,6 +1,6 @@ INCLUDE "constants.asm" -SECTION "engine/dumps/bank23.asm@ClearSpriteAnims", ROMX +SECTION "engine/sprite_anims/core.asm", ROMX ClearSpriteAnims:: ld hl, wSpriteAnimData diff --git a/engine/tileset_anims.asm b/engine/tileset_anims.asm new file mode 100644 index 00000000..eb13aa5f --- /dev/null +++ b/engine/tileset_anims.asm @@ -0,0 +1,209 @@ +INCLUDE "constants.asm" + +SECTION "engine/tileset_anims.asm", ROMX + +_AnimateTileset: + ldh a, [hMapAnims] + and a + ret z + + ld a, [wTilesetAnim] + ld e, a + ld a, [wTilesetAnim+1] + ld d, a + ldh a, [hTileAnimFrame] + ld l, a + inc a + ldh [hTileAnimFrame], a + ld h, 0 + add hl, hl + add hl, hl + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +INCLUDE "data/tileset_anims.inc" + +WaitTileAnimation: +; Do nothing this frame. + ret + +DoneTileAnimation: +; Reset the animation command loop. + xor a + ldh [hTileAnimFrame], a + jp TransferToolgearRow + +ScrollTileRightLeft: + ld a, [wTileAnimationTimer] + inc a + and %111 + ld [wTileAnimationTimer], a + and %100 + jr nz, ScrollTileLeft + jr ScrollTileRight + +ScrollTileLeft: + ld h, d + ld l, e + ld c, 16 / 4 +.loop +rept 4 + ld a, [hl] + rlca + ld [hli], a +endr + dec c + jr nz, .loop + ret + +ScrollTileRight: + ld h, d + ld l, e + ld c, 16 / 4 +.loop +rept 4 + ld a, [hl] + rrca + ld [hli], a +endr + dec c + jr nz, .loop + ret + +ScrollTileUp: + ld h, d + ld l, e + ld d, [hl] + inc hl + ld e, [hl] + ld bc, 16 - 2 + add hl, bc + ld a, 16 / 4 +.loop + ld c, [hl] + ld [hl], e + dec hl + ld b, [hl] + ld [hl], d + dec hl + ld e, [hl] + ld [hl], c + dec hl + ld d, [hl] + ld [hl], b + dec hl + dec a + jr nz, .loop + ret + +ScrollTileDown: + ld h, d + ld l, e + ld de, 16 - 2 + push hl + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + pop hl + ld a, 16 / 4 +.loop + ld b, [hl] + ld [hl], d + inc hl + ld c, [hl] + ld [hl], e + inc hl + ld d, [hl] + ld [hl], b + inc hl + ld e, [hl] + ld [hl], c + inc hl + dec a + jr nz, .loop + ret + +AnimateFlowerTile: +; Save the stack pointer in bc for WriteTile to restore + ld hl, sp+0 + ld b, h + ld c, l + +; A cycle of 2 frames, updating every other tick + ld a, [wTileAnimationTimer] + and %10 + ld hl, FlowerTileFrame1 + jr nz, .end + ld hl, FlowerTileFrame2 + +.end +; Write the tile graphic from hl (now sp) to tile $38 (now hl) + ld sp, hl + ld hl, vTileset tile $38 + jr WriteTile + +FlowerTileFrame1: + INCBIN "gfx/tilesets/flower/flower1.2bpp" +FlowerTileFrame2: + INCBIN "gfx/tilesets/flower/flower2.2bpp" + +WriteTileFromAnimBuffer: +; Save the stack pointer in bc for WriteTile to restore + ld hl, sp+0 + ld b, h + ld c, l + +; Write the tile graphic from wTileAnimBuffer (now sp) to de (now hl) + ld hl, wTileAnimBuffer + ld sp, hl + ld h, d + ld l, e + jr WriteTile + +ReadTileToAnimBuffer: +; Save the stack pointer in bc for WriteTile to restore + ld hl, sp+0 + ld b, h + ld c, l + +; Write the tile graphic from de (now sp) to wTileAnimBuffer (now hl) + ld h, d + ld l, e + ld sp, hl + ld hl, wTileAnimBuffer + ; fallthrough + +WriteTile: +; Write one tile from sp to hl. +; The stack pointer has been saved in bc. + +; This function cannot be called, only jumped to, +; because it relocates the stack pointer to quickly +; copy data with a "pop slide". + + pop de + ld [hl], e + inc hl + ld [hl], d +rept (16 - 2) / 2 + pop de + inc hl + ld [hl], e + inc hl + ld [hl], d +endr + +; Restore the stack pointer from bc + ld h, b + ld l, c + ld sp, hl + ret + diff --git a/gfx/overworld/heal_machine.png b/gfx/overworld/heal_machine.png new file mode 100644 index 00000000..73d457a5 Binary files /dev/null and b/gfx/overworld/heal_machine.png differ diff --git a/home/map_objects.asm b/home/map_objects.asm index 8ad12266..5ab42127 100644 --- a/home/map_objects.asm +++ b/home/map_objects.asm @@ -463,7 +463,7 @@ UnfreezeObject:: ret ; Iterates through a dba function table at 'hl' that is 16 entries long. -Unreferenced_FarCallLoop:: +HealingMachineLoop:: xor a .loop push af diff --git a/home/vcopy.asm b/home/vcopy.asm index a26fafb0..327eefcc 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -528,9 +528,9 @@ endr AnimateTileset:: ldh a, [hROMBank] push af - ld a, BANK(AnimateTilesetImpl) + ld a, BANK(_AnimateTileset) call Bankswitch - call AnimateTilesetImpl + call _AnimateTileset pop af jp Bankswitch diff --git a/layout.link b/layout.link index 858eb85a..b2d58c67 100644 --- a/layout.link +++ b/layout.link @@ -184,7 +184,6 @@ ROMX $04 ROMX $05 org $4000 "engine/overworld/player_movement.asm@_RedrawPlayerSprite" - org $4036 "engine/sprites/sprites.asm@RefreshSprites" "data/maps/sprite_sets.asm" "data/overworld_sprites.asm" @@ -195,37 +194,25 @@ ROMX $05 ROMX $06 org $4000 "gfx.asm@Bank 6 Tilesets Silent Hill" - org $4e00 "gfx.asm@Bank 6 Tilesets Forest" - org $5800 "gfx.asm@Bank 6 Tilesets Old City" - org $6600 "gfx.asm@Bank 6 Tilesets West" - org $7400 "gfx.asm@Bank 6 Tilesets House" ROMX $07 org $4000 "gfx.asm@Bank 7 Tilesets Rocket House" - org $4b00 "gfx.asm@Bank 7 Tilesets Aquarium" - org $5600 "gfx.asm@Bank 7 Tilesets North" - org $6400 "gfx.asm@Bank 7 Tilesets Font" - org $7200 "gfx.asm@Bank 7 Tilesets HighTech" ROMX $08 org $4000 "gfx.asm@Bank 8 Tilesets Birdon" - org $4e00 "gfx.asm@Bank 8 Tilesets Kanto" - org $5c00 "gfx.asm@Bank 8 Tilesets South" - org $6a00 "gfx.asm@Bank 8 Tilesets Tower" - org $7500 "gfx.asm@Bank 8 Tilesets Gate" ROMX $09 @@ -254,15 +241,10 @@ ROMX $0b ROMX $0c org $4000 "gfx.asm@Bank C Tilesets Radio Tower" - org $4b00 "gfx.asm@Bank C Tilesets Traditional House" - org $5600 "gfx.asm@Bank C Tilesets Mart" - org $6100 "gfx.asm@Bank C Tilesets Gym" - org $7100 "gfx.asm@Bank C Tilesets Pokecenter" - org $7c00 "gfx.asm@Bank C Tilesets Common" ROMX $0d @@ -272,10 +254,8 @@ ROMX $0d ROMX $0e org $4000 "engine/dumps/bank0e.asm" - org $4d90 "data/trainers/class_names.asm" "engine/dumps/bank0e.asm@ReadTrainerParty" - org $5110 "data/trainers/parties.asm@Trainer Parties" ROMX $0f @@ -307,23 +287,16 @@ ROMX $12 ROMX $13 org $4000 "gfx.asm@Bank 13 Tilesets Lab" - org $4b00 "gfx.asm@Bank 13 Tilesets Ruins Of Alph" - org $5b00 "gfx.asm@Bank 13 Tilesets Ship" - org $6900 "gfx.asm@Bank 13 Tilesets Ship Port" ROMX $14 org $4000 "engine/dumps/bank14.asm@CopyMonToTempMon" - org $40dd "data/types/names.asm" - org $4162 "engine/dumps/bank14.asm@GetTrainerClassName_Old" - org $4756 "engine/dumps/bank14.asm@Party Menu Routines" - org $4f10 "data/pokemon/base_stats.asm" "data/pokemon/names.asm" "gfx.asm@PKMN Sprite Bank List" @@ -380,24 +353,13 @@ ROMX $21 ROMX $23 org $4000 - "engine/dumps/bank23.asm@AnimateTilesetImpl" - org $401f - "data/tileset_anims.asm" - org $411b - "engine/dumps/bank23.asm@WaitTileAnimation" - org $42dc + "engine/tileset_anims.asm" + "engine/overworld/healing_machine.asm" "engine/palettes.asm" - org $446d - "engine/dumps/bank23.asm@RestoreOverworldMapTiles" - org $44be "engine/battle/battle_transitions.asm" - org $4940 - "engine/dumps/bank23.asm@EnterMapAnim_Old" - org $4cfd - "engine/dumps/bank23.asm@ClearSpriteAnims" - org $60cc + "engine/overworld/player_animations_old.asm" + "engine/sprite_anims/core.asm" "gfx.asm@Pokemon Party Sprites" - org $70cc "engine/gfx/mon_icons.asm" ROMX $24 @@ -908,11 +870,8 @@ ROMX $36 ROMX $37 org $4000 "gfx.asm@Bank 37 Tilesets Dept Store" - org $4b00 "gfx.asm@Bank 37 Tilesets Office" - org $5b00 "gfx.asm@Bank 37 Tilesets Cave" - org $6b00 "gfx.asm@Bank 37 Tilesets Power Plant" ROMX $38 @@ -925,7 +884,6 @@ ROMX $38 org $622b "engine/games/memory_minigame.asm" "gfx.asm@Matches GFX" - org $6886 "engine/games/picross_minigame.asm" "gfx.asm@Picross GFX" diff --git a/shim.sym b/shim.sym index a7f01b3c..5aad4454 100644 --- a/shim.sym +++ b/shim.sym @@ -33,4 +33,4 @@ 0B:786F Bank0b_FillerStart 0e:59bc Bank0e_FillerStart 14:7274 Bank14_FillerStart - +23:7325 Bank23_FillerStart