From 9cfb4ffb52a8565f1bfbf8ec13db040cc108e68a Mon Sep 17 00:00:00 2001 From: Alieneer <37123222+BreavyTF2@users.noreply.github.com> Date: Fri, 3 Apr 2026 13:26:19 -0400 Subject: [PATCH] Document the animated tilesets (#130) --- data/tileset_anims.asm | 99 ++++++++++++++++++ data/tileset_headers.asm | 62 +++++------ engine/dumps/bank23.asm | 179 ++++++++++++++++++++++++++++++++ gfx/tilesets/flower/flower1.png | Bin 0 -> 113 bytes gfx/tilesets/flower/flower2.png | Bin 0 -> 113 bytes layout.link | 4 + ram/wram.asm | 5 + 7 files changed, 318 insertions(+), 31 deletions(-) create mode 100644 data/tileset_anims.asm create mode 100644 gfx/tilesets/flower/flower1.png create mode 100644 gfx/tilesets/flower/flower2.png diff --git a/data/tileset_anims.asm b/data/tileset_anims.asm new file mode 100644 index 00000000..86d45223 --- /dev/null +++ b/data/tileset_anims.asm @@ -0,0 +1,99 @@ +INCLUDE "constants.asm" + +SECTION "data/tileset_anims.asm", ROMX + +MACRO tileframe + if _NARG == 2 + dw \2 ; argument + else + dw 0 + endc + dw \1 ; function +ENDM + + +TilesetFlowerAnim: +; UnusedTilesetAnim1 in pokegold/pokecrystal. +; Scrolls tile $03 like cave water, but also has the standard $38 flower tile. + tileframe ReadTileToAnimBuffer, vTileset tile $03 + tileframe ScrollTileRightLeft, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $03 + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe AnimateFlowerTile + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe DoneTileAnimation + +TilesetWaterAnim: +; UnusedTilesetAnim2 in pokegold/pokecrystal. +; Scrolls tile $03 like cave water. + tileframe ReadTileToAnimBuffer, vTileset tile $03 + tileframe ScrollTileRightLeft, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $03 + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe DoneTileAnimation + +TilesetGenericAnim: +; UnusedTilesetAnim3 in pokegold/pokecrystal. +; Scrolls tile $53 like a waterfall; scrolls tile $03 like cave water. + tileframe ReadTileToAnimBuffer, vTileset tile $53 + tileframe ScrollTileDown, wTileAnimBuffer + tileframe ScrollTileDown, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $53 + tileframe ReadTileToAnimBuffer, vTileset tile $03 + tileframe ScrollTileRightLeft, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $03 + tileframe ReadTileToAnimBuffer, vTileset tile $53 + tileframe ScrollTileDown, wTileAnimBuffer + tileframe ScrollTileDown, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $53 + tileframe DoneTileAnimation + +TilesetFontAnim: +; UnusedTilesetAnim4 in pokegold/pokecrystal. +; Scrolls tile $54 like a waterfall; scrolls tile $03 like cave water. + tileframe ReadTileToAnimBuffer, vTileset tile $54 + tileframe ScrollTileDown, wTileAnimBuffer + tileframe ScrollTileDown, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $54 + tileframe WaitTileAnimation + tileframe ReadTileToAnimBuffer, vTileset tile $03 + tileframe ScrollTileRightLeft, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $03 + tileframe WaitTileAnimation + tileframe ReadTileToAnimBuffer, vTileset tile $54 + tileframe ScrollTileDown, wTileAnimBuffer + tileframe ScrollTileDown, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $54 + tileframe DoneTileAnimation + +TilesetRocketHouseAnim: +; UnusedTilesetAnim5 in pokegold/pokecrystal. +; Scrolls tile $4f like cave water. + tileframe ReadTileToAnimBuffer, vTileset tile $4f + tileframe ScrollTileRightLeft, wTileAnimBuffer + tileframe WriteTileFromAnimBuffer, vTileset tile $4f + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe DoneTileAnimation + +TilesetNoAnim: +; TilesetUndergroundAnim in pokegold/pokecrystal. + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe WaitTileAnimation + tileframe DoneTileAnimation \ No newline at end of file diff --git a/data/tileset_headers.asm b/data/tileset_headers.asm index 771286cc..35c46253 100644 --- a/data/tileset_headers.asm +++ b/data/tileset_headers.asm @@ -5,37 +5,37 @@ SECTION "data/tileset_headers.asm", ROMX MACRO tileset db BANK(\1_GFX) ; shared bank dw \1_Meta, \1_GFX, \1_Coll - db \2, \3, \4 ; counter tiles - db \5 ; unknown + dw \2, ; animation set + dw NULL ; unused ENDM Tilesets: - ; name, 3 counter tiles, unknown - tileset Tileset_00, $77, $40, $00, $00 - tileset Tileset_01, $4b, $40, $00, $00 - tileset Tileset_02, $1f, $40, $00, $00 - tileset Tileset_03, $1f, $40, $00, $00 - tileset Tileset_04, $4b, $40, $00, $00 - tileset Tileset_05, $a7, $40, $00, $00 - tileset Tileset_06, $4b, $40, $00, $00 - tileset Tileset_07, $1f, $40, $00, $00 - tileset Tileset_08, $4b, $40, $00, $00 - tileset Tileset_09, $07, $41, $00, $00 - tileset Tileset_0a, $07, $41, $00, $00 - tileset Tileset_0b, $07, $41, $00, $00 - tileset Tileset_0c, $07, $41, $00, $00 - tileset Tileset_0d, $07, $41, $00, $00 - tileset Tileset_0e, $07, $41, $00, $00 - tileset Tileset_0f, $07, $41, $00, $00 - tileset Tileset_10, $07, $41, $00, $00 - tileset Tileset_11, $07, $41, $00, $00 - tileset Tileset_12, $07, $41, $00, $00 - tileset Tileset_13, $df, $40, $00, $00 - tileset Tileset_14, $07, $41, $00, $00 - tileset Tileset_15, $07, $41, $00, $00 - tileset Tileset_16, $07, $41, $00, $00 - tileset Tileset_17, $07, $41, $00, $00 - tileset Tileset_18, $07, $41, $00, $00 - tileset Tileset_19, $07, $41, $00, $00 - tileset Tileset_1a, $07, $41, $00, $00 - tileset Tileset_1b, $77, $40, $00, $00 + ; name, animation set + tileset Tileset_00, TilesetGenericAnim + tileset Tileset_01, TilesetWaterAnim + tileset Tileset_02, TilesetFlowerAnim + tileset Tileset_03, TilesetFlowerAnim + tileset Tileset_04, TilesetWaterAnim + tileset Tileset_05, TilesetFontAnim + tileset Tileset_06, TilesetWaterAnim + tileset Tileset_07, TilesetFlowerAnim + tileset Tileset_08, TilesetWaterAnim + tileset Tileset_09, TilesetNoAnim + tileset Tileset_0a, TilesetNoAnim + tileset Tileset_0b, TilesetNoAnim + tileset Tileset_0c, TilesetNoAnim + tileset Tileset_0d, TilesetNoAnim + tileset Tileset_0e, TilesetNoAnim + tileset Tileset_0f, TilesetNoAnim + tileset Tileset_10, TilesetNoAnim + tileset Tileset_11, TilesetNoAnim + tileset Tileset_12, TilesetNoAnim + tileset Tileset_13, TilesetRocketHouseAnim + tileset Tileset_14, TilesetNoAnim + tileset Tileset_15, TilesetNoAnim + tileset Tileset_16, TilesetNoAnim + tileset Tileset_17, TilesetNoAnim + tileset Tileset_18, TilesetNoAnim + tileset Tileset_19, TilesetNoAnim + tileset Tileset_1a, TilesetNoAnim + tileset Tileset_1b, TilesetGenericAnim diff --git a/engine/dumps/bank23.asm b/engine/dumps/bank23.asm index c44bd3a7..83f99aa6 100644 --- a/engine/dumps/bank23.asm +++ b/engine/dumps/bank23.asm @@ -28,6 +28,185 @@ AnimateTilesetImpl: 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:: diff --git a/gfx/tilesets/flower/flower1.png b/gfx/tilesets/flower/flower1.png new file mode 100644 index 0000000000000000000000000000000000000000..fd97acac979ac95b8d87811ac82951b97f53fccc GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^93afZ3?z3ZhDiV^o&cW^*Z=?juU)$q$O{Szn$dje zDv+h%>Eakt5tp2hkeCp0;J}fC2R?Q-b~iiL%Q9c*W@}?(Q2EBfrS+iE9jKPU)78&q Iol`;+0EY)5+5i9m literal 0 HcmV?d00001 diff --git a/gfx/tilesets/flower/flower2.png b/gfx/tilesets/flower/flower2.png new file mode 100644 index 0000000000000000000000000000000000000000..2d30400ac071a9f94947009bb9503f6ad9693245 GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^93afZ3?z3ZhDiV^o&cW^*Z=?juU)$q$O{Szn$dje zDv+h%>Eakt5tp2hkeHB_@E{-|!0zCIg$EaG?{9p~%IwU{pxVcx@!MtjRG?Z0Pgg&e IbxsLQ0DO}oD*ylh literal 0 HcmV?d00001 diff --git a/layout.link b/layout.link index 523c33fc..45e9f360 100644 --- a/layout.link +++ b/layout.link @@ -381,6 +381,10 @@ 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/palettes.asm" org $446d diff --git a/ram/wram.asm b/ram/wram.asm index 7ad7d695..3f0005b4 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -716,6 +716,9 @@ wRedrawFlashlightWidthHeight:: db ; in units of two tiles (people event meta tile) ENDU +SECTION "CB3C", WRAM0[$CB3C] +wTileAnimBuffer:: ds 1 tiles + SECTION "CB56", WRAM0[$CB4C] UNION wOtherPlayerLinkMode:: db @@ -984,6 +987,8 @@ wPlaceBallsY:: db ; TODO: Investigate how it actually functions. wLowHealthAlarmBuffer:: db +wTileAnimationTimer:: db + SECTION "CCC7", WRAM0[$CCC7] wDisableVBlankOAMUpdate:: db