Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions data/tileset_anims.asm → data/tileset_anims.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
INCLUDE "constants.asm"

SECTION "data/tileset_anims.asm", ROMX

MACRO tileframe
if _NARG == 2
dw \2 ; argument
Expand All @@ -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.
Expand Down
108 changes: 108 additions & 0 deletions engine/overworld/healing_machine.asm
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading