ref: 82512e449115aa9d004e24a3d1526dd32570c56d
parent: e6d02b4b7b69701f223fe9100ccc21ad2089afc4
author: YamaArashi <shadow962@live.com>
date: Fri Jul 24 10:39:45 EDT 2015
named animation functions/variables
--- a/constants/move_animation_constants.asm
+++ b/constants/move_animation_constants.asm
@@ -6,7 +6,7 @@
const SE_WAVY_SCREEN ; $D8 used in Psywave/Night Shade/Psychic etc.
const SE_SUBSTITUTE_MON ; $D9 used in Substitute (turns the pokemon into a mini sprite)
const SE_SHAKE_BACK_AND_FORTH ; $DA used in Double Team
- const SE_SLIDE_ENEMY_MON_OUT ; $DB used in Whirlwind
+ const SE_SLIDE_ENEMY_MON_OFF ; $DB used in Whirlwind
const SE_SHOW_ENEMY_MON_PIC ; $DC used in Seismic Toss
const SE_SHOW_MON_PIC ; $DD used in Low Kick/Quick Attack/Seismic Toss etc.
const SE_BLINK_ENEMY_MON ; $DE used in Seismic Toss
@@ -16,7 +16,7 @@
const SE_SPIRAL_BALLS_INWARD ; $E2 used in Growth/Focus Energy/Hyper Beam etc.
const SE_SHAKE_ENEMY_HUD_2 ; $E3 unused
const SE_SHAKE_ENEMY_HUD ; $E4
- const SE_SLIDE_MON_HALF_LEFT ; $E5 used in Softboiled
+ const SE_SLIDE_MON_HALF_OFF ; $E5 used in Softboiled
const SE_PETALS_FALLING ; $E6 used in Petal Dance
const SE_LEAVES_FALLING ; $E7 used in Razor Leaf
const SE_TRANSFORM_MON ; $E8 used in Transform
@@ -31,7 +31,7 @@
const SE_RESET_MON_POSITION ; $F1 used in Tackle/Body Slam/etc.
const SE_MOVE_MON_HORIZONTALLY ; $F2 used in Tackle/Body Slam/etc.
const SE_BLINK_MON ; $F3 used in Recover
- const SE_SLIDE_MON_OUT ; $F4 used in Seismic Toss/Low Kick/etc.
+ const SE_SLIDE_MON_OFF ; $F4 used in Seismic Toss/Low Kick/etc.
const SE_FLASH_MON_PIC ; $F5
const SE_SLIDE_MON_DOWN ; $F6 used in Withdraw/Waterfall/fainting
const SE_SLIDE_MON_UP ; $F7 used in Dig/Waterfall/etc.
--- a/data/animations.asm
+++ b/data/animations.asm
@@ -296,7 +296,7 @@
WhirlwindAnim: ; 7a27b (1e:627b)
db $46,$11,$10
- db SE_SLIDE_ENEMY_MON_OUT, $FF
+ db SE_SLIDE_ENEMY_MON_OFF, $FF
db $FF
FlyAnim: ; 7a281 (1e:6281)
@@ -550,19 +550,19 @@
db $FF
SubmissionAnim: ; 7a3cc (1e:63cc)
- db SE_SLIDE_MON_OUT, $41
+ db SE_SLIDE_MON_OFF, $41
db $06,$FF,$01
db SE_SHOW_MON_PIC, $FF
db $FF
LowKickAnim: ; 7a3d4 (1e:63d4)
- db SE_SLIDE_MON_OUT, $42
+ db SE_SLIDE_MON_OFF, $42
db $46,$FF,$04
db SE_SHOW_MON_PIC, $FF
db $FF
CounterAnim: ; 7a3dc (1e:63dc)
- db SE_SLIDE_MON_OUT, $43
+ db SE_SLIDE_MON_OFF, $43
db $46,$FF,$04
db SE_SHOW_MON_PIC, $FF
db $FF
@@ -571,7 +571,7 @@
db SE_BLINK_ENEMY_MON, $FF
db $41,$8B,$4E
db SE_HIDE_ENEMY_MON_PIC, $FF
- db SE_SLIDE_MON_OUT, $FF
+ db SE_SLIDE_MON_OFF, $FF
db $42,$44,$4F
db SE_DELAY_ANIMATION_10, $FF
db SE_DELAY_ANIMATION_10, $FF
@@ -736,7 +736,7 @@
db $FF
QuickAttackAnim: ; 7a4c8 (1e:64c8)
- db SE_SLIDE_MON_OUT, $61
+ db SE_SLIDE_MON_OFF, $61
db $46,$FF,$04
db SE_SHOW_MON_PIC, $FF
db $FF
@@ -960,7 +960,7 @@
db $FF
SoftboiledAnim: ; 7a5fe (1e:65fe)
- db SE_SLIDE_MON_HALF_LEFT, $48
+ db SE_SLIDE_MON_HALF_OFF, $48
db $08,$86,$4C
db SE_LIGHT_SCREEN_PALETTE, $FF
db SE_SPIRAL_BALLS_INWARD, $FF
@@ -1119,7 +1119,7 @@
db $FF
SubstituteAnim: ; 7a6d1 (1e:66d1)
- db SE_SLIDE_MON_OUT, $A3
+ db SE_SLIDE_MON_OFF, $A3
db $08,$FF,$47
db SE_SUBSTITUTE_MON, $FF
db $FF
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -65,16 +65,16 @@
call GetMonHeader
call LoadFrontSpriteByMonIndex
ld hl,vBGMap0 + $c
- call CopyTileMapToVRAM
+ call CreditsCopyTileMapToVRAM
xor a
ld [H_AUTOBGTRANSFERENABLED],a
call LoadScreenTilesFromBuffer1
ld hl,vBGMap0
- call CopyTileMapToVRAM
+ call CreditsCopyTileMapToVRAM
ld a,$A7
ld [rWX],a
ld hl,vBGMap1
- call CopyTileMapToVRAM
+ call CreditsCopyTileMapToVRAM
call FillMiddleOfScreenWithWhite
ld a,%11111100 ; make the mon a black silhouette
ld [rBGP],a
@@ -136,12 +136,12 @@
db %11100000
db %11110000
-CopyTileMapToVRAM: ; 74164 (1d:4164)
+CreditsCopyTileMapToVRAM: ; 74164 (1d:4164)
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
ld a, h
ld [H_AUTOBGTRANSFERDEST + 1], a
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -223,7 +223,7 @@
rla
sla c
rla
- ld [wd09f],a ; tile select
+ ld [wWhichBattleAnimTileset],a
ld a,[hli] ; sound
ld [wAnimSoundID],a ; store sound
ld a,[hli] ; subanimation ID
@@ -243,7 +243,7 @@
push hl
ld a,[rOBP0]
push af
- ld a,[wcc79]
+ ld a,[wAnimPalette]
ld [rOBP0],a
call LoadAnimationTileset
call LoadSubanimation
@@ -328,7 +328,7 @@
; loads tile patterns for battle animations
LoadAnimationTileset: ; 781d2 (1e:41d2)
- ld a,[wd09f] ; tileset select
+ ld a,[wWhichBattleAnimTileset]
add a
add a
ld hl,AnimationTilesetPointers
@@ -412,7 +412,7 @@
call WaitForSoundToFinish
xor a
ld [W_SUBANIMSUBENTRYADDR],a
- ld [wd09b],a
+ ld [wUnusedD09B],a
ld [W_SUBANIMTRANSFORM],a
dec a
ld [wAnimSoundID],a
@@ -472,16 +472,16 @@
ShakeScreenVertically: ; 78ddb (1e:4ddb)
call PlayApplyingAttackSound
- ld b, $8
+ ld b, 8
jp AnimationShakeScreenVertically
ShakeScreenHorizontallyHeavy: ; 78de3 (1e:4de3)
call PlayApplyingAttackSound
- ld b, $8
+ ld b, 8
jp AnimationShakeScreenHorizontallyFast
ShakeScreenHorizontallySlow: ; 78deb (1e:4deb)
- ld bc, $602
+ lb bc, 6, 2
jr AnimationShakeScreenHorizontallySlow
BlinkEnemyMonSprite: ; 78df0 (1e:4df0)
@@ -490,16 +490,16 @@
ShakeScreenHorizontallyLight: ; 78df6 (1e:4df6)
call PlayApplyingAttackSound
- ld b, $2
+ ld b, 2
jp AnimationShakeScreenHorizontallyFast
ShakeScreenHorizontallySlow2: ; 78dfe (1e:4dfe)
- ld bc, $302
+ lb bc, 3, 2
AnimationShakeScreenHorizontallySlow: ; 78e01 (1e:4e01)
push bc
push bc
-.asm_78e03
+.loop1
ld a, [rWX]
inc a
ld [rWX], a
@@ -506,9 +506,9 @@
ld c, 2
call DelayFrames
dec b
- jr nz, .asm_78e03
+ jr nz, .loop1
pop bc
-.asm_78e11
+.loop2
ld a, [rWX]
dec a
ld [rWX], a
@@ -515,7 +515,7 @@
ld c, 2
call DelayFrames
dec b
- jr nz, .asm_78e11
+ jr nz, .loop2
pop bc
dec c
jr nz, AnimationShakeScreenHorizontallySlow
@@ -525,25 +525,25 @@
ld a, [wOnSGB]
and a
ld a, $e4
- jr z, .asm_78e47
+ jr z, .notSGB
ld a, $f0
- ld [wcc79], a
+ ld [wAnimPalette], a
ld b, $e4
ld a, [W_ANIMATIONID]
cp TRADE_BALL_DROP_ANIM
- jr c, .asm_78e3f
+ jr c, .next
cp TRADE_BALL_POOF_ANIM + 1
- jr nc, .asm_78e3f
+ jr nc, .next
ld b, $f0
-.asm_78e3f
+.next
ld a, b
ld [rOBP0], a
ld a, $6c
ld [rOBP1], a
ret
-.asm_78e47
+.notSGB
ld a, $e4
- ld [wcc79], a
+ ld [wAnimPalette], a
ld [rOBP0], a
ld a, $6c
ld [rOBP1], a
@@ -761,11 +761,11 @@
.moveGhostMarowakLeft
coord hl, 17, 0
ld de,20
- ld bc,$0707 ; 7 rows and 7 columns
+ lb bc, 7, 7
.loop
push hl
push bc
- call Func_79862 ; move row of tiles left
+ call AnimCopyRowRight ; move row of tiles left
pop bc
pop hl
add hl,de
@@ -891,8 +891,8 @@
ld a,[W_SUBANIMCOUNTER]
cp a,6
ret nz
- ld a,$2F
- jp Func_7980c ; make pokemon disappear
+ ld a,2 * SCREEN_WIDTH + 7
+ jp ClearMonPicFromTileMap ; make pokemon disappear
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball: ; 7904c (1e:504c)
@@ -1010,8 +1010,8 @@
dw AnimationSlideMonDown
db SE_FLASH_MON_PIC ; $F5
dw AnimationFlashMonPic
- db SE_SLIDE_MON_OUT ; $F4
- dw AnimationSlideMonOut
+ db SE_SLIDE_MON_OFF ; $F4
+ dw AnimationSlideMonOff
db SE_BLINK_MON ; $F3
dw AnimationBlinkMon
db SE_MOVE_MON_HORIZONTALLY ; $F2
@@ -1040,8 +1040,8 @@
dw AnimationLeavesFalling
db SE_PETALS_FALLING ; $E6
dw AnimationPetalsFalling
- db SE_SLIDE_MON_HALF_LEFT ; $E5
- dw AnimationSlideMonHalfLeft
+ db SE_SLIDE_MON_HALF_OFF ; $E5
+ dw AnimationSlideMonHalfOff
db SE_SHAKE_ENEMY_HUD ; $E4
dw AnimationShakeEnemyHUD
db SE_SHAKE_ENEMY_HUD_2 ; unused--same pointer as SE_SHAKE_ENEMY_HUD ($E4)
@@ -1060,8 +1060,8 @@
dw AnimationShowMonPic
db SE_SHOW_ENEMY_MON_PIC ; $DC
dw AnimationShowEnemyMonPic
- db SE_SLIDE_ENEMY_MON_OUT ; $DB
- dw AnimationSlideEnemyMonOut
+ db SE_SLIDE_ENEMY_MON_OFF ; $DB
+ dw AnimationSlideEnemyMonOff
db SE_SHAKE_BACK_AND_FORTH ; $DA
dw AnimationShakeBackAndForth
db SE_SUBSTITUTE_MON ; $D9
@@ -1092,7 +1092,7 @@
; flashes the screen for an extended period (48 frames)
AnimationFlashScreenLong: ; 79165 (1e:5165)
ld a,3 ; cycle through the palettes 3 times
- ld [wd08a],a
+ ld [wFlashScreenLongCounter],a
ld a,[wOnSGB] ; running on SGB?
and a
ld hl,FlashScreenLongMonochrome
@@ -1108,9 +1108,9 @@
call FlashScreenLongDelay
jr .innerLoop
.endOfPalettes
- ld a,[wd08a]
+ ld a,[wFlashScreenLongCounter]
dec a
- ld [wd08a],a
+ ld [wFlashScreenLongCounter],a
pop hl
jr nz,.loop
ret
@@ -1150,8 +1150,8 @@
; causes a delay of 2 frames for the first cycle
; causes a delay of 1 frame for the second and third cycles
FlashScreenLongDelay: ; 791a8 (1e:51a8)
- ld a,[wd08a]
- cp a,4 ; never true since [wd08a] starts at 3
+ ld a,[wFlashScreenLongCounter]
+ cp a,4 ; never true since [wFlashScreenLongCounter] starts at 3
ld c,4
jr z,.delayFrames
cp a,3
@@ -1179,46 +1179,46 @@
AnimationDarkScreenPalette: ; 791d6 (1e:51d6)
; Changes the screen's palette to a dark palette.
- ld bc, $6f6f
+ lb bc, $6f, $6f
jr SetAnimationBGPalette
AnimationDarkenMonPalette: ; 791db (1e:51db)
; Darkens the mon sprite's palette.
- ld bc, $f9f4
+ lb bc, $f9, $f4
jr SetAnimationBGPalette
AnimationUnusedPalette1: ; 791e0 (1e:51e0)
- ld bc, $fef8
+ lb bc, $fe, $f8
jr SetAnimationBGPalette
AnimationUnusedPalette2: ; 791e5 (1e:51e5)
- ld bc, $ffff
+ lb bc, $ff, $ff
jr SetAnimationBGPalette
AnimationResetScreenPalette: ; 791ea (1e:51ea)
; Restores the screen's palette to the normal palette.
- ld bc, $e4e4
+ lb bc, $e4, $e4
jr SetAnimationBGPalette
AnimationUnusedPalette3: ; 791ef (1e:51ef)
- ld bc, $0000
+ lb bc, $00, $00
jr SetAnimationBGPalette
AnimationLightScreenPalette: ; 791f4 (1e:51f4)
; Changes the screen to use a palette with light colors.
- ld bc, $9090
+ lb bc, $90, $90
jr SetAnimationBGPalette
AnimationUnusedPalette4: ; 791f9 (1e:51f9)
- ld bc, $4040
+ lb bc, $40, $40
SetAnimationBGPalette: ; 791fc (1e:51fc)
ld a, [wOnSGB]
and a
ld a, b
- jr z, .asm_79204
+ jr z, .next
ld a, c
-.asm_79204
+.next
ld [rBGP], a
ret
@@ -1239,68 +1239,68 @@
; scroll. It's hard to describe, but it's the main animation
; in Surf/Mist/Toxic.
xor a
- ld [wd09f], a
+ ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
- ld d, $20
- ld a, $f0
+ ld d, 32
+ ld a, -16
ld [W_BASECOORDX], a
ld a, $71
- ld [wd09f], a
-.asm_79228
- ld a, $10
+ ld [wDropletTile], a
+.loop
+ ld a, 16
ld [W_BASECOORDY], a
- ld a, $0
- ld [wd08a], a
+ ld a, 0
+ ld [wUnusedD08A], a
call _AnimationWaterDroplets
- ld a, $18
+ ld a, 24
ld [W_BASECOORDY], a
- ld a, $20
- ld [wd08a], a
+ ld a, 32
+ ld [wUnusedD08A], a
call _AnimationWaterDroplets
dec d
- jr nz, .asm_79228
+ jr nz, .loop
ret
_AnimationWaterDroplets: ; 79246 (1e:5246)
ld hl, wOAMBuffer
-.asm_79249
+.loop
ld a, [W_BASECOORDY]
- ld [hli], a
+ ld [hli], a ; Y
ld a, [W_BASECOORDX]
- add $1b
+ add 27
ld [W_BASECOORDX], a
- ld [hli], a
- ld a, [wd09f]
- ld [hli], a
+ ld [hli], a ; X
+ ld a, [wDropletTile]
+ ld [hli], a ; tile
xor a
- ld [hli], a
+ ld [hli], a ; attribute
ld a, [W_BASECOORDX]
- cp $90
- jr c, .asm_79249
- sub $a8
+ cp 144
+ jr c, .loop
+ sub 168
ld [W_BASECOORDX], a
ld a, [W_BASECOORDY]
- add $10
+ add 16
ld [W_BASECOORDY], a
- cp $70
- jr c, .asm_79249
+ cp 112
+ jr c, .loop
call AnimationCleanOAM
jp DelayFrame
AnimationSlideMonUp: ; 7927a (1e:527a)
; Slides the mon's sprite upwards.
- ld c, $7
+ ld c, 7
ld a, [H_WHOSETURN]
and a
coord hl, 1, 6
coord de, 1, 5
ld a, $30
- jr z, .asm_79291
+ jr z, .next
coord hl, 12, 1
coord de, 12, 0
ld a, $ff
-.asm_79291
- ld [wd09f], a
+.next
+ ld [wSlideMonUpBottomRowLeftTile], a
jp _AnimationSlideMonUp
AnimationSlideMonDown: ; 79297 (1e:5297)
@@ -1307,7 +1307,7 @@
; Slides the mon's sprite down out of the screen.
xor a
call GetTileIDList
-.asm_7929b
+.loop
call GetMonSpriteTileMapPointerFromRowCount
push bc
push de
@@ -1317,19 +1317,19 @@
pop de
pop bc
dec b
- jr nz, .asm_7929b
+ jr nz, .loop
ret
-AnimationSlideMonOut: ; 792af (1e:52af)
-; Slides the mon's sprite out of the screen horizontally.
- ld e, $8
- ld a, $3
- ld [W_SUBANIMTRANSFORM], a
- jp AnimationSlideMonLeft
+AnimationSlideMonOff: ; 792af (1e:52af)
+; Slides the mon's sprite off the screen horizontally.
+ ld e, 8
+ ld a, 3
+ ld [wSlideMonDelay], a
+ jp _AnimationSlideMonOff
-AnimationSlideEnemyMonOut: ; 792b9 (1e:52b9)
-; Slides the enemy mon out of the screen horizontally.
- ld hl, AnimationSlideMonOut
+AnimationSlideEnemyMonOff: ; 792b9 (1e:52b9)
+; Slides the enemy mon off the screen horizontally.
+ ld hl, AnimationSlideMonOff
jp CallWithTurnFlipped
_AnimationSlideMonUp: ; 792bf (1e:52bf)
@@ -1336,13 +1336,19 @@
push de
push hl
push bc
- ld b, $6
-.asm_792c4
+
+; In each iteration, slide up all rows but the top one (which is overwritten).
+ ld b, 6
+.slideLoop
push bc
push de
push hl
- ld bc, $0007
+ ld bc, 7
call CopyData
+; Note that de and hl are popped in the same order they are pushed, swapping
+; their values. When CopyData is called, hl points to a tile 1 row below
+; the one de points to. To maintain this relationship, after swapping, we add 2
+; rows to hl so that it is 1 row below again.
pop de
pop hl
ld bc, SCREEN_WIDTH * 2
@@ -1349,22 +1355,25 @@
add hl, bc
pop bc
dec b
- jr nz, .asm_792c4
+ jr nz, .slideLoop
+
+; Fill in the bottom row of the mon pic with the next row's tile IDs.
ld a, [H_WHOSETURN]
and a
coord hl, 1, 11
- jr z, .asm_792e2
+ jr z, .next
coord hl, 12, 6
-.asm_792e2
- ld a, [wd09f]
+.next
+ ld a, [wSlideMonUpBottomRowLeftTile]
inc a
- ld [wd09f], a
- ld c, $7
-.asm_792eb
+ ld [wSlideMonUpBottomRowLeftTile], a
+ ld c, 7
+.fillBottomRowLoop
ld [hli], a
- add $7
+ add 7
dec c
- jr nz, .asm_792eb
+ jr nz, .fillBottomRowLoop
+
ld c, 2
call DelayFrames
pop bc
@@ -1374,35 +1383,41 @@
jr nz, _AnimationSlideMonUp
ret
-_AnimationShakeEnemyHUD: ; 792fd (1e:52fd)
+ShakeEnemyHUD_WritePlayerMonPicOAM: ; 792fd (1e:52fd)
+; Writes the OAM entries for a copy of the player mon's pic in OAM.
+; The top 5 rows are reproduced in OAM, although only 2 are actually needed.
ld a, $10
ld [W_BASECOORDX], a
ld a, $30
ld [W_BASECOORDY], a
ld hl, wOAMBuffer
- ld d, $0
- ld c, $7
-.asm_7930e
+ ld d, 0
+ ld c, 7
+.loop
ld a, [W_BASECOORDY]
ld e, a
- ld b, $5
-.asm_79314
- call Animations_79329
+ ld b, 5
+.innerLoop
+ call BattleAnimWriteOAMEntry
inc d
dec b
- jr nz, .asm_79314
+ jr nz, .innerLoop
dec c
ret z
inc d
inc d
ld a, [W_BASECOORDX]
- add $8
+ add 8
ld [W_BASECOORDX], a
- jr .asm_7930e
+ jr .loop
-Animations_79329: ; 79329 (1e:5329)
+BattleAnimWriteOAMEntry: ; 79329 (1e:5329)
+; Y coordinate = e (increased by 8 each call, before the write to OAM)
+; X coordinate = [W_BASECOORDX]
+; tile = d
+; attributes = 0
ld a, e
- add $8
+ add 8
ld e, a
ld [hli], a
ld a, [W_BASECOORDX]
@@ -1418,16 +1433,17 @@
ld h, d
AdjustOAMBlockXPos2: ; 79339 (1e:5339)
- ld de, $4
+ ld de, 4
.loop
- ld a, [wd08a]
+ ld a, [wCoordAdjustmentAmount]
ld b, a
ld a, [hl]
add b
- cp $a8
+ cp 168
jr c, .skipPuttingEntryOffScreen
+; put off-screen if X >= 168
dec hl
- ld a, $a0
+ ld a, 160
ld [hli], a
.skipPuttingEntryOffScreen
ld [hl], a
@@ -1441,16 +1457,16 @@
ld h, d
AdjustOAMBlockYPos2: ; 79352 (1e:5352)
- ld de, $4
+ ld de, 4
.loop
- ld a, [wd08a]
+ ld a, [wCoordAdjustmentAmount]
ld b, a
ld a, [hl]
add b
- cp $70
+ cp 112
jr c, .skipSettingPreviousEntrysAttribute
dec hl
- ld a, $a0 ; bug, sets previous OAM entry's attribute
+ ld a, 160 ; bug, sets previous OAM entry's attribute
ld [hli], a
.skipSettingPreviousEntrysAttribute
ld [hl], a
@@ -1467,8 +1483,8 @@
AnimationBlinkMon: ; 7936f (1e:536f)
; Make the mon's sprite blink on and off for a second or two.
push af
- ld c, $6
-.asm_79372
+ ld c, 6
+.loop
push bc
call AnimationHideMonPic
ld c, 5
@@ -1478,7 +1494,7 @@
call DelayFrames
pop bc
dec c
- jr nz, .asm_79372
+ jr nz, .loop
pop af
ret
@@ -1485,10 +1501,10 @@
AnimationFlashMonPic: ; 79389 (1e:5389)
; Flashes the mon's sprite on and off
ld a, [wBattleMonSpecies]
- ld [wHPBarMaxHP + 1], a
+ ld [wChangeMonPicPlayerTurnSpecies], a
ld a, [wEnemyMonSpecies]
- ld [wHPBarMaxHP], a
- jp Func_79793
+ ld [wChangeMonPicEnemyTurnSpecies], a
+ jp ChangeMonPic
AnimationFlashEnemyMonPic: ; 79398 (1e:5398)
; Flashes the enemy mon's sprite on and off
@@ -1515,14 +1531,14 @@
and a
coord hl, 0, 5
coord de, 2, 5
- jr z, .asm_793c2
+ jr z, .next
coord hl, 11, 0
coord de, 13, 0
-.asm_793c2
+.next
xor a
ld c, $10
-.asm_793c5
+.loop
push af
push bc
push de
@@ -1537,7 +1553,7 @@
call CopyPicTiles
call Delay3
pop hl
- ld bc, $0709
+ lb bc, 7, 9
call ClearScreenArea
pop af
call GetTileIDList
@@ -1545,7 +1561,7 @@
call CopyPicTiles
call Delay3
pop hl
- ld bc, $0709
+ lb bc, 7, 9
call ClearScreenArea
pop hl
pop de
@@ -1552,7 +1568,7 @@
pop bc
pop af
dec c
- jr nz, .asm_793c5
+ jr nz, .loop
ret
AnimationMoveMonHorizontally: ; 793f9 (1e:53f9)
@@ -1562,9 +1578,9 @@
ld a, [H_WHOSETURN]
and a
coord hl, 2, 5
- jr z, .asm_79407
+ jr z, .next
coord hl, 11, 0
-.asm_79407
+.next
xor a
push hl
call GetTileIDList
@@ -1577,63 +1593,63 @@
; Resets the mon's sprites to be located at the normal coordinates.
ld a, [H_WHOSETURN]
and a
- ld a, $66
- jr z, .asm_7941e
- ld a, $b
-.asm_7941e
- call Func_7980c
+ ld a, 5 * SCREEN_WIDTH + 2
+ jr z, .next
+ ld a, 11
+.next
+ call ClearMonPicFromTileMap
jp AnimationShowMonPic
AnimationSpiralBallsInward: ; 79424 (1e:5424)
-; Creates an effect that looks like energy balls sprialing into the
+; Creates an effect that looks like energy balls spiralling into the
; player mon's sprite. Used in Focus Energy, for example.
ld a, [H_WHOSETURN]
and a
- jr z, .asm_79435
- ld a, $d8
- ld [wd08a], a
- ld a, $50
- ld [W_SUBANIMTRANSFORM], a
- jr .asm_7943c
-.asm_79435
+ jr z, .playerTurn
+ ld a, -40
+ ld [wSpiralBallsBaseY], a
+ ld a, 80
+ ld [wSpiralBallsBaseX], a
+ jr .next
+.playerTurn
xor a
- ld [wd08a], a
- ld [W_SUBANIMTRANSFORM], a
-.asm_7943c
- ld d, $7a
- ld c, $3
+ ld [wSpiralBallsBaseY], a
+ ld [wSpiralBallsBaseX], a
+.next
+ ld d, $7a ; ball tile
+ ld c, 3 ; number of balls
xor a
- call Func_797e8
+ call InitMultipleObjectsOAM
ld hl, SpiralBallAnimationCoordinates
-.asm_79447
+.loop
push hl
- ld c, $3
+ ld c, 3
ld de, wOAMBuffer
-.asm_7944d
+.innerLoop
ld a, [hl]
cp $ff
- jr z, .asm_7946f
- ld a, [wd08a]
+ jr z, .done
+ ld a, [wSpiralBallsBaseY]
add [hl]
- ld [de], a
+ ld [de], a ; Y
inc de
inc hl
- ld a, [W_SUBANIMTRANSFORM]
+ ld a, [wSpiralBallsBaseX]
add [hl]
- ld [de], a
+ ld [de], a ; X
inc hl
inc de
inc de
inc de
dec c
- jr nz, .asm_7944d
+ jr nz, .innerLoop
ld c, 5
call DelayFrames
pop hl
inc hl
inc hl
- jr .asm_79447
-.asm_7946f
+ jr .loop
+.done
pop hl
call AnimationCleanOAM
jp AnimationFlashScreen
@@ -1640,7 +1656,7 @@
SpiralBallAnimationCoordinates: ; 79476 (1e:5476)
; y, x pairs
-; This is the sequence of screen coordinates that the spiraling
+; This is the sequence of screen coordinates that the spiralling
; balls are positioned at.
db $38, $28
db $40, $18
@@ -1668,50 +1684,50 @@
AnimationSquishMonPic: ; 794a1 (1e:54a1)
; Squishes the mon's sprite horizontally making it
; disappear. Used by Teleport/Sky Attack animations.
- ld c, $4
-.asm_794a3
+ ld c, 4
+.loop
push bc
ld a, [H_WHOSETURN]
and a
- jr z, .asm_794b1
+ jr z, .playerTurn
coord hl, 16, 0
coord de, 14, 0
- jr .asm_794b7
-.asm_794b1
+ jr .next
+.playerTurn
coord hl, 5, 5
coord de, 3, 5
-.asm_794b7
+.next
push de
- xor a
- ld [wd09f], a
+ xor a ; left
+ ld [wSquishMonCurrentDirection], a
call _AnimationSquishMonPic
pop hl
- ld a, $1
- ld [wd09f], a
+ ld a, 1 ; right
+ ld [wSquishMonCurrentDirection], a
call _AnimationSquishMonPic
pop bc
dec c
- jr nz, .asm_794a3
+ jr nz, .loop
call AnimationHideMonPic
- ld c, $2
+ ld c, 2
jp DelayFrame
_AnimationSquishMonPic: ; 794d4 (1e:54d4)
- ld c, $7
-.asm_794d6
+ ld c, 7
+.loop
push bc
push hl
- ld c, $3
- ld a, [wd09f]
- cp $0
- jr nz, .asm_794e7
- call Func_7985b
+ ld c, 3
+ ld a, [wSquishMonCurrentDirection]
+ cp 0
+ jr nz, .right
+ call AnimCopyRowLeft
dec hl
- jr .asm_794eb
-.asm_794e7
- call Func_79862
+ jr .next
+.right
+ call AnimCopyRowRight
inc hl
-.asm_794eb
+.next
ld [hl], " "
pop hl
ld de, SCREEN_WIDTH
@@ -1718,7 +1734,7 @@
add hl, de
pop bc
dec c
- jr nz, .asm_794d6
+ jr nz, .loop
jp Delay3
AnimationShootBallsUpward: ; 794f9 (1e:54f9)
@@ -1726,17 +1742,17 @@
; animations.
ld a, [H_WHOSETURN]
and a
- jr z, .asm_79503
- ld bc, $80
- jr .asm_79506
-.asm_79503
- ld bc, $3028
-.asm_79506
+ jr z, .playerTurn
+ lb bc, 0, 16 * 8
+ jr .next
+.playerTurn
+ lb bc, 6 * 8, 5 * 8
+.next
ld a, b
ld [W_BASECOORDY], a
ld a, c
ld [W_BASECOORDX], a
- ld bc, $501
+ lb bc, 5, 1
call _AnimationShootBallsUpward
jp AnimationCleanOAM
@@ -1743,50 +1759,51 @@
_AnimationShootBallsUpward: ; 79517 (1e:5517)
push bc
xor a
- ld [wd09f], a
+ ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
pop bc
- ld d, $7a
+ ld d, $7a ; ball tile
ld hl, wOAMBuffer
push bc
ld a, [W_BASECOORDY]
ld e, a
-.asm_7952a
- call Animations_79329
+.initOAMLoop
+ call BattleAnimWriteOAMEntry
dec b
- jr nz, .asm_7952a
+ jr nz, .initOAMLoop
call DelayFrame
pop bc
ld a, b
- ld [wd08a], a
-.asm_79538
+ ld [wNumShootingBalls], a
+.loop
push bc
ld hl, wOAMBuffer
-.asm_7953c
+.innerLoop
ld a, [W_BASECOORDY]
- add $8
+ add 8
ld e, a
ld a, [hl]
- cp e
- jr z, .asm_7954b
- add $fc
+ cp e ; has the ball reached the top?
+ jr z, .reachedTop
+ add -4 ; ball hasn't reached the top. move it up 4 pixels
ld [hl], a
- jr .asm_79554
-.asm_7954b
- ld [hl], $0
- ld a, [wd08a]
+ jr .next
+.reachedTop
+; remove the ball once it has reached the top
+ ld [hl], 0 ; put it off-screen
+ ld a, [wNumShootingBalls]
dec a
- ld [wd08a], a
-.asm_79554
- ld de, $4
- add hl, de
+ ld [wNumShootingBalls], a
+.next
+ ld de, 4
+ add hl, de ; next OAM entry
dec b
- jr nz, .asm_7953c
+ jr nz, .innerLoop
call DelayFrames
pop bc
- ld a, [wd08a]
+ ld a, [wNumShootingBalls]
and a
- jr nz, .asm_79538
+ jr nz, .loop
ret
AnimationShootManyBallsUpward: ; 79566 (1e:5566)
@@ -1799,15 +1816,15 @@
ld hl, UpwardBallsAnimXCoordinatesEnemyTurn
ld a, $28 ; y coordinate for "energy" ball pillar
.player
- ld [wTrainerSpriteOffset], a
+ ld [wSavedY], a
.loop
- ld a, [wTrainerSpriteOffset]
+ ld a, [wSavedY]
ld [W_BASECOORDY], a
ld a, [hli]
cp $ff
jp z, AnimationCleanOAM
ld [W_BASECOORDX], a
- ld bc, $0401
+ lb bc, 4, 1
push hl
call _AnimationShootBallsUpward
pop hl
@@ -1838,14 +1855,14 @@
add hl, de
ld de, MinimizedMonSprite
ld c, $5
-.asm_795b4
+.loop
ld a, [de]
ld [hli], a
ld [hli], a
inc de
dec c
- jr nz, .asm_795b4
- call Func_79652
+ jr nz, .loop
+ call CopyTempPicToMonPic
call Delay3
jp AnimationShowMonPic
@@ -1856,7 +1873,7 @@
; Slides the mon's sprite down and disappears. Used in Acid Armor.
ld a, $1
ld c, $2
-.asm_795cd
+.loop
push bc
push af
call AnimationHideMonPic
@@ -1871,87 +1888,101 @@
inc a
pop bc
dec c
- jr nz, .asm_795cd
+ jr nz, .loop
call AnimationHideMonPic
ld hl, wTempPic
ld bc, $0310
xor a
call FillMemory
- jp Func_79652
+ jp CopyTempPicToMonPic
-AnimationSlideMonLeft: ; 795f8 (1e:55f8)
+_AnimationSlideMonOff: ; 795f8 (1e:55f8)
+; Slides the mon's sprite off the screen horizontally by e tiles and waits
+; [wSlideMonDelay] V-blanks each time the pic is slid by one tile.
ld a, [H_WHOSETURN]
and a
- jr z, .asm_79602
+ jr z, .playerTurn
coord hl, 12, 0
- jr .asm_79605
-.asm_79602
+ jr .next
+.playerTurn
coord hl, 0, 5
-.asm_79605
- ld d, $8
-.asm_79607
+.next
+ ld d, 8 ; d's value is unused
+.slideLoop ; iterates once for each time the pic slides by one tile
push hl
- ld b, $7
-.asm_7960a
- ld c, $8
-.asm_7960c
+ ld b, 7
+.rowLoop ; iterates once for each row
+ ld c, 8
+.tileLoop ; iterates once for each tile in the row
ld a, [H_WHOSETURN]
and a
- jr z, .asm_79616
- call Func_7963c
- jr .asm_79619
-.asm_79616
- call Func_79633
-.asm_79619
+ jr z, .playerTurn2
+ call .EnemyNextTile
+ jr .next2
+.playerTurn2
+ call .PlayerNextTile
+.next2
ld [hli], a
dec c
- jr nz, .asm_7960c
+ jr nz, .tileLoop
push de
- ld de, $c
+ ld de, SCREEN_WIDTH - 8
add hl, de
pop de
dec b
- jr nz, .asm_7960a
- ld a, [W_SUBANIMTRANSFORM]
+ jr nz, .rowLoop
+ ld a, [wSlideMonDelay]
ld c, a
call DelayFrames
pop hl
dec d
dec e
- jr nz, .asm_79607
+ jr nz, .slideLoop
ret
-Func_79633: ; 79633 (1e:5633)
+; Since mon pic tile numbers go from top to bottom, left to right in order,
+; adding the height of the mon pic in tiles to a tile number gives the tile
+; number of the tile one column to the right (and thus subtracting the height
+; gives the reverse). If the next tile would be past the edge of the pic, the 2
+; functions below catch it by checking if the tile number is within the valid
+; range and if not, replacing it with a blank tile.
+
+.PlayerNextTile ; 79633 (1e:5633)
ld a, [hl]
- add $7
+ add 7
+; This is a bug. The lower right corner tile of the mon back pic is blanked
+; while the mon is sliding off the screen. It should compare with the max tile
+; plus one instead.
cp $61
ret c
- ld a, $7f
+ ld a, " "
ret
-Func_7963c: ; 7963c (1e:563c)
+.EnemyNextTile ; 7963c (1e:563c)
ld a, [hl]
- sub $7
+ sub 7
+; This has the same problem as above, but it has no visible effect because
+; the lower right tile is in the first column to slide off the screen.
cp $30
ret c
- ld a, $7f
+ ld a, " "
ret
-AnimationSlideMonHalfLeft: ; 79645 (1e:5645)
-; Slides the mon's sprite halfway out of the screen. It's used in Softboiled.
- ld e, $4
- ld a, $4
- ld [W_SUBANIMTRANSFORM], a
- call AnimationSlideMonLeft
+AnimationSlideMonHalfOff: ; 79645 (1e:5645)
+; Slides the mon's sprite halfway off the screen. It's used in Softboiled.
+ ld e, 4
+ ld a, 4
+ ld [wSlideMonDelay], a
+ call _AnimationSlideMonOff
jp Delay3
-Func_79652: ; 79652 (1e:5652)
+CopyTempPicToMonPic: ; 79652 (1e:5652)
ld a, [H_WHOSETURN]
and a
- ld hl, vBackPic
- jr z, .asm_7965d
- ld hl, vFrontPic
-.asm_7965d
+ ld hl, vBackPic ; player turn
+ jr z, .next
+ ld hl, vFrontPic ; enemy turn
+.next
ld de, wTempPic
ld bc, 7 * 7
jp CopyVideoData
@@ -1959,55 +1990,55 @@
AnimationWavyScreen: ; 79666 (1e:5666)
; used in Psywave/Psychic etc.
ld hl, vBGMap0
- call Func_79e0d
+ call BattleAnimCopyTileMapToVRAM
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- ld a, $90
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
- ld d, $80
- ld e, $8f
+ ld d, $80 ; terminator
+ ld e, SCREEN_HEIGHT_PIXELS - 1
ld c, $ff
ld hl, WavyScreenLineOffsets
-.asm_7967f
+.loop
push hl
-.asm_79680
- call Func_796ae
+.innerLoop
+ call WavyScreen_SetSCX
ld a, [rLY]
- cp e
- jr nz, .asm_79680
+ cp e ; is it the last visible line in the frame?
+ jr nz, .innerLoop ; keep going if not
pop hl
inc hl
ld a, [hl]
- cp d
- jr nz, .asm_79691
- ld hl, WavyScreenLineOffsets
-.asm_79691
+ cp d ; have we reached the end?
+ jr nz, .next
+ ld hl, WavyScreenLineOffsets ; go back to the beginning if so
+.next
dec c
- jr nz, .asm_7967f
+ jr nz, .loop
xor a
ld [hWY], a
call SaveScreenTilesToBuffer2
call ClearScreen
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call LoadScreenTilesFromBuffer2
ld hl, vBGMap1
- call Func_79e0d
+ call BattleAnimCopyTileMapToVRAM
ret
-Func_796ae: ; 796ae (1e:56ae)
+WavyScreen_SetSCX: ; 796ae (1e:56ae)
ld a, [rSTAT]
- and $3
- jr nz, Func_796ae
+ and $3 ; is it H-blank?
+ jr nz, WavyScreen_SetSCX ; wait until it's H-blank
ld a, [hl]
ld [rSCX], a
inc hl
ld a, [hl]
- cp d
+ cp d ; have we reached the end?
ret nz
- ld hl, WavyScreenLineOffsets
+ ld hl, WavyScreenLineOffsets ; go back to the beginning if so
ret
WavyScreenLineOffsets: ; 796bf (1e:56bf)
@@ -2023,9 +2054,9 @@
xor a
ld bc, $0310
call FillMemory
- ld a, [$fff3]
+ ld a, [H_WHOSETURN]
and a
- jr z, .asm_79715
+ jr z, .playerTurn
ld hl, SlowbroSprite ; facing down sprite
ld de, wTempPic + $120
call CopySlowbroSpriteData
@@ -2038,8 +2069,8 @@
ld hl, SlowbroSprite + $30
ld de, wTempPic + $120 + $10 + $70
call CopySlowbroSpriteData
- jr .asm_79739
-.asm_79715
+ jr .next
+.playerTurn
ld hl, SlowbroSprite + $40 ; facing up sprite
ld de, wTempPic + $120 + $70
call CopySlowbroSpriteData
@@ -2052,8 +2083,8 @@
ld hl, SlowbroSprite + $70
ld de, wTempPic + $120 + $f0
call CopySlowbroSpriteData
-.asm_79739
- call Func_79652
+.next
+ call CopyTempPicToMonPic
jp AnimationShowMonPic
CopySlowbroSpriteData: ; 7973f (1e:573f)
@@ -2077,7 +2108,7 @@
call AnimationSlideMonDown
jr .next2
.substituteStillUp
- call AnimationSlideMonOut
+ call AnimationSlideMonOff
.next2
pop hl
ld a, [hl]
@@ -2087,7 +2118,7 @@
jp AnimationShowMonPic
ReshowSubstituteAnim: ; 79771 (1e:5771)
- call AnimationSlideMonOut
+ call AnimationSlideMonOff
call AnimationSubstitute
jp AnimationShowMonPic
@@ -2094,13 +2125,13 @@
AnimationBoundUpAndDown: ; 7977a (1e:577a)
; Bounces the mon's sprite up and down several times. It is used
; by Splash's animation.
- ld c, $5
-.asm_7977c
+ ld c, 5
+.loop
push bc
call AnimationSlideMonDown
pop bc
dec c
- jr nz, .asm_7977c
+ jr nz, .loop
jp AnimationShowMonPic
AnimationTransformMon: ; 79787 (1e:5787)
@@ -2107,15 +2138,15 @@
; Redraws this mon's sprite as the back/front sprite of the opposing mon.
; Used in Transform.
ld a, [wEnemyMonSpecies]
- ld [wHPBarMaxHP + 1], a
+ ld [wChangeMonPicPlayerTurnSpecies], a
ld a, [wBattleMonSpecies]
- ld [wHPBarMaxHP], a
+ ld [wChangeMonPicEnemyTurnSpecies], a
-Func_79793: ; 79793 (1e:5793)
+ChangeMonPic: ; 79793 (1e:5793)
ld a, [H_WHOSETURN]
and a
- jr z, .asm_797b0
- ld a, [wHPBarMaxHP]
+ jr z, .playerTurn
+ ld a, [wChangeMonPicEnemyTurnSpecies]
ld [wcf91], a
ld [wd0b5], a
xor a
@@ -2123,11 +2154,11 @@
call GetMonHeader
coord hl, 12, 0
call LoadFrontSpriteByMonIndex
- jr .asm_797d3
-.asm_797b0
+ jr .done
+.playerTurn
ld a, [wBattleMonSpecies2]
push af
- ld a, [wHPBarMaxHP + 1]
+ ld a, [wChangeMonPicPlayerTurnSpecies]
ld [wBattleMonSpecies2], a
ld [wd0b5], a
call GetMonHeader
@@ -2138,7 +2169,7 @@
call CopyPicTiles
pop af
ld [wBattleMonSpecies2], a
-.asm_797d3
+.done
ld b, $1
jp GoPAL_SET
@@ -2152,10 +2183,14 @@
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
-Func_797e8: ; 797e8 (1e:57e8)
+InitMultipleObjectsOAM: ; 797e8 (1e:57e8)
+; Writes c OAM entries with tile d.
+; Sets their Y coordinates to sequential multiples of 8, starting from 0.
+; Sets their X coordinates to 0.
+; Loads animation tileset a.
push bc
push de
- ld [wd09f], a
+ ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
pop de
pop bc
@@ -2163,10 +2198,10 @@
ld e, a
ld [W_BASECOORDX], a
ld hl, wOAMBuffer
-.asm_797fa
- call Animations_79329
+.loop
+ call BattleAnimWriteOAMEntry
dec c
- jr nz, .asm_797fa
+ jr nz, .loop
ret
AnimationHideMonPic: ; 79801 (1e:5801)
@@ -2173,21 +2208,21 @@
; Hides the mon's sprite.
ld a, [H_WHOSETURN]
and a
- jr z, .asm_7980a
- ld a, $c
- jr Func_7980c
-.asm_7980a
- ld a, $65
+ jr z, .playerTurn
+ ld a, 12
+ jr ClearMonPicFromTileMap
+.playerTurn
+ ld a, 5 * SCREEN_WIDTH + 1
-Func_7980c: ; 7980c (1e:580c)
+ClearMonPicFromTileMap: ; 7980c (1e:580c)
push hl
push de
push bc
ld e, a
- ld d, $0
+ ld d, 0
coord hl, 0, 0
add hl, de
- ld bc, $707
+ lb bc, 7, 7
call ClearScreenArea
pop bc
pop de
@@ -2251,20 +2286,22 @@
ld b, a
ret
-Func_7985b: ; 7985b (1e:585b)
+AnimCopyRowLeft: ; 7985b (1e:585b)
+; copy a row of c tiles 1 tile left
ld a, [hld]
ld [hli], a
inc hl
dec c
- jr nz, Func_7985b
+ jr nz, AnimCopyRowLeft
ret
-Func_79862: ; 79862 (1e:5862)
+AnimCopyRowRight: ; 79862 (1e:5862)
+; copy a row of c tiles 1 tile right
ld a, [hli]
ld [hld], a
dec hl
dec c
- jr nz, Func_79862
+ jr nz, AnimCopyRowRight
ret
; get the sound of the move id in b
@@ -2649,12 +2686,12 @@
; in Razor Leaf's animation.
ld a, [rOBP0]
push af
- ld a, [wcc79]
+ ld a, [wAnimPalette]
ld [rOBP0], a
- ld d, $37
- ld a, $3
- ld [W_SUBANIMTRANSFORM], a
- call Func_79c97
+ ld d, $37 ; leaf tile
+ ld a, 3 ; number of leaves
+ ld [wNumFallingObjects], a
+ call AnimationFallingObjects
pop af
ld [rOBP0], a
ret
@@ -2662,115 +2699,120 @@
AnimationPetalsFalling: ; 79c8a (1e:5c8a)
; Makes lots of petals fall down from the top of the screen. It's used in
; the animation for Petal Dance.
- ld d, $71
- ld a, $14
- ld [W_SUBANIMTRANSFORM], a
- call Func_79c97
+ ld d, $71 ; petal tile
+ ld a, 20 ; number of petals
+ ld [wNumFallingObjects], a
+ call AnimationFallingObjects
jp ClearSprites
-Func_79c97: ; 79c97 (1e:5c97)
+AnimationFallingObjects: ; 79c97 (1e:5c97)
ld c, a
- ld a, $1
- call Func_797e8
- call Func_79d2a
- call Func_79d52
+ ld a, 1
+ call InitMultipleObjectsOAM
+ call FallingObjects_InitXCoords
+ call FallingObjects_InitMovementData
ld hl, wOAMBuffer
- ld [hl], $0
-.asm_79ca8
- ld hl, wTrainerSpriteOffset
- ld de, $0000
- ld a, [W_SUBANIMTRANSFORM]
+ ld [hl], 0
+.loop
+ ld hl, wFallingObjectsMovementData
+ ld de, 0
+ ld a, [wNumFallingObjects]
ld c, a
-.asm_79cb2
+.innerLoop
push bc
push hl
push de
ld a, [hl]
- ld [wd08a], a
- call Func_79d16
- call Func_79cdb
+ ld [wFallingObjectMovementByte], a
+ call FallingObjects_UpdateMovementByte
+ call FallingObjects_UpdateOAMEntry
pop de
- ld hl, $0004
+ ld hl, 4
add hl, de
ld e, l
ld d, h
pop hl
- ld a, [wd08a]
+ ld a, [wFallingObjectMovementByte]
ld [hli], a
pop bc
dec c
- jr nz, .asm_79cb2
+ jr nz, .innerLoop
call Delay3
ld hl, wOAMBuffer
- ld a, [hl]
- cp $68
- jr nz, .asm_79ca8
+ ld a, [hl] ; Y
+ cp 104 ; has the top falling object reached 104 yet?
+ jr nz, .loop ; keep moving the falling objects down until it does
ret
-Func_79cdb: ; 79cdb (1e:5cdb)
+FallingObjects_UpdateOAMEntry: ; 79cdb (1e:5cdb)
+; Increases Y by 2 pixels and adjusts X and X flip based on the falling object's
+; movement byte.
ld hl, wOAMBuffer
add hl, de
ld a, [hl]
inc a
inc a
- cp $70
- jr c, .asm_79ce8
- ld a, $a0
-.asm_79ce8
- ld [hli], a
- ld a, [wd08a]
+ cp 112
+ jr c, .next
+ ld a, 160 ; if Y >= 112, put it off-screen
+.next
+ ld [hli], a ; Y
+ ld a, [wFallingObjectMovementByte]
ld b, a
- ld de, Unknown_79d0d
+ ld de, FallingObjects_DeltaXs
and $7f
add e
- jr nc, .asm_79cf6
+ jr nc, .noCarry
inc d
-.asm_79cf6
+.noCarry
ld e, a
ld a, b
and $80
- jr nz, .asm_79d03
+ jr nz, .movingLeft
+; moving right
ld a, [de]
add [hl]
- ld [hli], a
+ ld [hli], a ; X
inc hl
- xor a
- jr .asm_79d0b
-.asm_79d03
+ xor a ; no horizontal flip
+ jr .next2
+.movingLeft
ld a, [de]
ld b, a
ld a, [hl]
sub b
- ld [hli], a
+ ld [hli], a ; X
inc hl
- ld a, $20
-.asm_79d0b
- ld [hl], a
+ ld a, (1 << OAM_X_FLIP)
+.next2
+ ld [hl], a ; attribute
ret
-Unknown_79d0d: ; 79d0d (1e:5d0d)
- db $00,$01,$03,$05,$07,$09,$0B,$0D,$0F
+FallingObjects_DeltaXs: ; 79d0d (1e:5d0d)
+ db 0, 1, 3, 5, 7, 9, 11, 13, 15
-Func_79d16: ; 79d16 (1e:5d16)
- ld a, [wd08a]
+FallingObjects_UpdateMovementByte: ; 79d16 (1e:5d16)
+ ld a, [wFallingObjectMovementByte]
inc a
ld b, a
and $7f
- cp $9
+ cp 9 ; have we reached the end of the delta-Xs?
ld a, b
- jr nz, .asm_79d26
+ jr nz, .next
+; We've reached the end of the delta-Xs, so wrap to the start and change
+; direction from right to left or vice versa.
and $80
xor $80
-.asm_79d26
- ld [wd08a], a
+.next
+ ld [wFallingObjectMovementByte], a
ret
-Func_79d2a: ; 79d2a (1e:5d2a)
+FallingObjects_InitXCoords: ; 79d2a (1e:5d2a)
ld hl, wOAMBuffer + $01
- ld de, Unknown_79d3e
- ld a, [W_SUBANIMTRANSFORM]
+ ld de, FallingObjects_InitialXCoords
+ ld a, [wNumFallingObjects]
ld c, a
-.asm_79d34
+.loop
ld a, [de]
ld [hli], a
inc hl
@@ -2778,66 +2820,98 @@
inc hl
inc de
dec c
- jr nz, .asm_79d34
+ jr nz, .loop
ret
-Unknown_79d3e: ; 79d3e (1e:5d3e)
+FallingObjects_InitialXCoords: ; 79d3e (1e:5d3e)
db $38,$40,$50,$60,$70,$88,$90,$56,$67,$4A,$77,$84,$98,$32,$22,$5C,$6C,$7D,$8E,$99
-Func_79d52: ; 79d52 (1e:5d52)
- ld hl, wTrainerSpriteOffset
- ld de, Unknown_79d63
- ld a, [W_SUBANIMTRANSFORM]
+FallingObjects_InitMovementData: ; 79d52 (1e:5d52)
+ ld hl, wFallingObjectsMovementData
+ ld de, FallingObjects_InitialMovementData
+ ld a, [wNumFallingObjects]
ld c, a
-.asm_79d5c
+.loop
ld a, [de]
ld [hli], a
inc de
dec c
- jr nz, .asm_79d5c
+ jr nz, .loop
ret
-Unknown_79d63: ; 79d63 (1e:5d63)
+FallingObjects_InitialMovementData: ; 79d63 (1e:5d63)
db $00,$84,$06,$81,$02,$88,$01,$83,$05,$89,$09,$80,$07,$87,$03,$82,$04,$85,$08,$86
AnimationShakeEnemyHUD: ; 79d77 (1e:5d77)
+; Shakes the enemy HUD.
+
+; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM.
ld de, vBackPic
ld hl, vSprites
ld bc, 7 * 7
call CopyVideoData
+
xor a
ld [hSCX], a
+
+; Copy wTileMap to BG map 0. The regular BG (not the window) is set to use
+; map 0 and can be scrolled with SCX, which allows a shaking effect.
ld hl, vBGMap0
- call Func_79e0d
- ld a, $90
+ call BattleAnimCopyTileMapToVRAM
+
+; Now that the regular BG is showing the same thing the window was, move the
+; window off the screen so that we can modify its contents below.
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
- ld hl, vBGMap0 + $320
- call Func_79e0d
- ld a, $38
+
+; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is
+; lined up with row 0 of the window.
+ ld hl, vBGMap1 - $20 * 7
+ call BattleAnimCopyTileMapToVRAM
+
+; Move the window so that the row below the enemy HUD (in BG map 0) lines up
+; with the top row of the window on the screen. This makes it so that the window
+; covers everything below the enemy HD with a copy that looks just like what
+; was there before.
+ ld a, 7 * 8
ld [hWY], a
- call _AnimationShakeEnemyHUD
+
+; Write OAM entries so that the copy of the back pic from the top of this
+; function shows up on screen. We need this because the back pic's Y coordinates
+; range overlaps with that of the enemy HUD and we don't want to shake the top
+; of the back pic when we shake the enemy HUD. The OAM copy won't be affected
+; by SCX.
+ call ShakeEnemyHUD_WritePlayerMonPicOAM
+
ld hl, vBGMap0
- call Func_79e0d
+ call BattleAnimCopyTileMapToVRAM
+
+; Remove the back pic from the BG map.
call AnimationHideMonPic
call Delay3
- ld de, $0208
- call Func_79de9
+
+; Use SCX to shake the regular BG. The window and the back pic OAM copy are
+; not affected.
+ lb de, 2, 8
+ call ShakeEnemyHUD_ShakeBG
+
+; Restore the original graphics.
call AnimationShowMonPic
call ClearSprites
- ld a, $90
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld hl, vBGMap1
- call Func_79e0d
+ call BattleAnimCopyTileMapToVRAM
xor a
ld [hWY], a
call SaveScreenTilesToBuffer1
ld hl, vBGMap0
- call Func_79e0d
+ call BattleAnimCopyTileMapToVRAM
call ClearScreen
call Delay3
call LoadScreenTilesFromBuffer1
ld hl, vBGMap1
- jp Func_79e0d
+ jp BattleAnimCopyTileMapToVRAM
; b = tile ID list index
; c = base tile ID
@@ -2851,27 +2925,27 @@
pop hl
jp CopyTileIDs
-Func_79de9: ; 79de9 (1e:5de9)
+ShakeEnemyHUD_ShakeBG: ; 79de9 (1e:5de9)
ld a, [hSCX]
- ld [wTrainerSpriteOffset], a
-.asm_79dee
- ld a, [wTrainerSpriteOffset]
+ ld [wTempSCX], a
+.loop
+ ld a, [wTempSCX]
add d
ld [hSCX], a
ld c, 2
call DelayFrames
- ld a, [wTrainerSpriteOffset]
+ ld a, [wTempSCX]
sub d
ld [hSCX], a
ld c, 2
call DelayFrames
dec e
- jr nz, .asm_79dee
- ld a, [wTrainerSpriteOffset]
+ jr nz, .loop
+ ld a, [wTempSCX]
ld [hSCX], a
ret
-Func_79e0d: ; 79e0d (1e:5e0d)
+BattleAnimCopyTileMapToVRAM: ; 79e0d (1e:5e0d)
ld a, h
ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, l
@@ -2942,19 +3016,19 @@
ld a, [wDamageMultipliers]
and $7f
ret z
- cp $a
+ cp 10
ld a, $20
ld b, $30
ld c, SFX_DAMAGE
- jr z, .asm_79e8b
+ jr z, .playSound
ld a, $e0
ld b, $ff
ld c, SFX_SUPER_EFFECTIVE
- jr nc, .asm_79e8b
+ jr nc, .playSound
ld a, $50
ld b, $1
ld c, SFX_NOT_VERY_EFFECTIVE
-.asm_79e8b
+.playSound
ld [wc0f1], a
ld a, b
ld [wc0f2], a
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -210,28 +210,28 @@
.outwardSpiral
coord hl, 10, 10
ld a, $3
- ld [wd09f], a
+ ld [wOutwardSpiralCurrentDirection], a
ld a, l
- ld [wd09b], a
+ ld [wOutwardSpiralTileMapPointer + 1], a
ld a, h
- ld [wd09a], a
- ld b, $78
-.loop1
- ld c, $3
-.loop2
+ ld [wOutwardSpiralTileMapPointer], a
+ ld b, 120
+.loop
+ ld c, 3
+.innerLoop
push bc
call BattleTransition_OutwardSpiral_
pop bc
dec c
- jr nz, .loop2
+ jr nz, .innerLoop
call DelayFrame
dec b
- jr nz, .loop1
+ jr nz, .loop
.done
call BattleTransition_BlackScreen
xor a
- ld [wd09b], a
- ld [wd09a], a
+ ld [wOutwardSpiralTileMapPointer + 1], a
+ ld [wOutwardSpiralTileMapPointer], a
ret
BattleTransition_InwardSpiral: ; 70aaa (1c:4aaa)
@@ -286,69 +286,69 @@
BattleTransition_OutwardSpiral_: ; 70af9 (1c:4af9)
ld bc, -SCREEN_WIDTH
ld de, SCREEN_WIDTH
- ld a, [wd09b]
+ ld a, [wOutwardSpiralTileMapPointer + 1]
ld l, a
- ld a, [wd09a]
+ ld a, [wOutwardSpiralTileMapPointer]
ld h, a
- ld a, [wd09f]
+ ld a, [wOutwardSpiralCurrentDirection]
cp $0
- jr z, .zero
+ jr z, .up
cp $1
- jr z, .one
+ jr z, .left
cp $2
- jr z, .two
+ jr z, .down
cp $3
- jr z, .three
-.done1
+ jr z, .right
+.keepSameDirection
ld [hl], $ff
-.done2_
+.done
ld a, l
- ld [wd09b], a
+ ld [wOutwardSpiralTileMapPointer + 1], a
ld a, h
- ld [wd09a], a
+ ld [wOutwardSpiralTileMapPointer], a
ret
-.zero
+.up
dec hl
ld a, [hl]
cp $ff
- jr nz, .done2
+ jr nz, .changeDirection
inc hl
add hl, bc
- jr .done1
-.one
+ jr .keepSameDirection
+.left
add hl, de
ld a, [hl]
cp $ff
- jr nz, .done2
+ jr nz, .changeDirection
add hl, bc
dec hl
- jr .done1
-.two
+ jr .keepSameDirection
+.down
inc hl
ld a, [hl]
cp $ff
- jr nz, .done2
+ jr nz, .changeDirection
dec hl
add hl, de
- jr .done1
-.three
+ jr .keepSameDirection
+.right
add hl, bc
ld a, [hl]
cp $ff
- jr nz, .done2
+ jr nz, .changeDirection
add hl, de
inc hl
- jr .done1
-.done2
+ jr .keepSameDirection
+.changeDirection
ld [hl], $ff
- ld a, [wd09f]
+ ld a, [wOutwardSpiralCurrentDirection]
inc a
cp $4
jr nz, .skip
xor a
.skip
- ld [wd09f], a
- jr .done2_
+ ld [wOutwardSpiralCurrentDirection], a
+ jr .done
FlashScreen:
BattleTransition_FlashScreen_: ; 70b5d (1c:4b5d)
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -357,7 +357,7 @@
call PlaySoundWaitForCurrent
xor a
ld [H_WHOSETURN], a
- jpab AnimationSlideEnemyMonOut
+ jpab AnimationSlideEnemyMonOff
WildRanText: ; 3c229 (f:4229)
TX_FAR _WildRanText
--- a/engine/battle/ghost_marowak_anim.asm
+++ b/engine/battle/ghost_marowak_anim.asm
@@ -12,10 +12,10 @@
ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon
; replace ghost pic with Marowak in BG
ld a, MAROWAK
- ld [wHPBarMaxHP], a
+ ld [wChangeMonPicEnemyTurnSpecies], a
ld a, $1
ld [H_WHOSETURN], a
- callab Func_79793
+ callab ChangeMonPic
; alternate between black and light grey 8 times.
; this makes the ghost's body appear to flash
ld d, $80
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -293,7 +293,7 @@
ld a, $e
.next
pop bc
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
ld hl, $ffdb
dec [hl]
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -38,7 +38,7 @@
ld a, SFX_INTRO_HIP
call PlaySound
xor a
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation1
call AnimateIntroNidorino
; hop
@@ -86,7 +86,7 @@
ld a, SFX_INTRO_HIP
call PlaySound
ld a, $24
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation3
call AnimateIntroNidorino
ld c, $1e
@@ -105,7 +105,7 @@
ld a, SFX_INTRO_HIP
call PlaySound
xor a
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation4
call AnimateIntroNidorino
; hop
@@ -118,7 +118,7 @@
ret c
ld a, $24
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation6
call AnimateIntroNidorino
ld c, $1e
@@ -129,7 +129,7 @@
ld a, SFX_INTRO_LUNGE
call PlaySound
ld a, $48
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation7
jp AnimateIntroNidorino
@@ -152,17 +152,17 @@
UpdateIntroNidorinoOAM: ; 417ae (10:57ae)
ld hl, wOAMBuffer
- ld a, [wd09f]
+ ld a, [wIntroNidorinoBaseTile]
ld d, a
.loop
ld a, [W_BASECOORDY]
add [hl]
- ld [hli], a
+ ld [hli], a ; Y
ld a, [W_BASECOORDX]
add [hl]
- ld [hli], a
+ ld [hli], a ; X
ld a, d
- ld [hli], a
+ ld [hli], a ; tile
inc hl
inc d
dec c
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -319,7 +319,7 @@
ld a,TOSS_ANIM
ld [W_ANIMATIONID],a
xor a
- ld [$fff3],a
+ ld [H_WHOSETURN],a
ld [wAnimationType],a
ld [wDamageMultipliers],a
ld a,[wWhichPokemon]
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -47,7 +47,7 @@
.notSilphCo11F
ld a, $e
.replaceCardKeyDoorTileBlock
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
ld hl, wd126
set 5, [hl]
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -3,21 +3,21 @@
ld [wActionResultOrTookBattleTurn], a ; initialise to failure value
ld a, [W_CURMAPTILESET]
and a ; OVERWORLD
- jr z, .asm_ef6b
+ jr z, .overworld
cp GYM
- jr nz, .asm_ef77
+ jr nz, .nothingToCut
ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
- jr nz, .asm_ef77
- jr .asm_ef82
-.asm_ef6b
+ jr nz, .nothingToCut
+ jr .canCut
+.overworld
dec a
ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
- jr z, .asm_ef82
+ jr z, .canCut
cp $52 ; grass
- jr z, .asm_ef82
-.asm_ef77
+ jr z, .canCut
+.nothingToCut
ld hl, .NothingToCutText
jp PrintText
@@ -25,9 +25,9 @@
TX_FAR _NothingToCutText
db "@"
-.asm_ef82
+.canCut
ld [wCutTile], a
- ld a, $1
+ ld a, 1
ld [wActionResultOrTookBattleTurn], a ; used cut
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
@@ -37,7 +37,7 @@
call GBPalWhiteOutWithDelay3
call ClearSprites
call RestoreScreenTilesAndReloadTilePatterns
- ld a, $90
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
call Delay3
call LoadGBPal
@@ -53,11 +53,11 @@
res 6, [hl]
ld a, $ff
ld [wUpdateSpritesEnabled], a
- call AnimateCutTree
+ call InitCutAnimOAM
ld de, CutTreeBlockSwaps
- call Func_f09f
+ call ReplaceTreeTileBlock
call RedrawMapView
- callba Func_79e96
+ callba AnimCut
ld a, $1
ld [wUpdateSpritesEnabled], a
ld a, SFX_CUT
@@ -71,7 +71,7 @@
TX_FAR _UsedCutText
db "@"
-AnimateCutTree: ; eff7 (3:6ff7)
+InitCutAnimOAM: ; eff7 (3:6ff7)
xor a
ld [wWhichAnimationOffsets], a
ld a, $e4
@@ -78,7 +78,8 @@
ld [rOBP1], a
ld a, [wCutTile]
cp $52
- jr z, .asm_f020
+ jr z, .grass
+; tree
ld de, Overworld_GFX + $2d0 ; cuttable tree sprite top row
ld hl, vChars1 + $7c0
ld bc, (BANK(Overworld_GFX) << 8) + $02
@@ -87,45 +88,45 @@
ld hl, vChars1 + $7e0
ld bc, (BANK(Overworld_GFX) << 8) + $02
call CopyVideoData
- jr WriteCutTreeBoulderDustAnimationOAMBlock
-.asm_f020
+ jr WriteCutOrBoulderDustAnimationOAMBlock
+.grass
ld hl, vChars1 + $7c0
- call LoadCutTreeAnimationTilePattern
+ call LoadCutGrassAnimationTilePattern
ld hl, vChars1 + $7d0
- call LoadCutTreeAnimationTilePattern
+ call LoadCutGrassAnimationTilePattern
ld hl, vChars1 + $7e0
- call LoadCutTreeAnimationTilePattern
+ call LoadCutGrassAnimationTilePattern
ld hl, vChars1 + $7f0
- call LoadCutTreeAnimationTilePattern
- call WriteCutTreeBoulderDustAnimationOAMBlock
+ call LoadCutGrassAnimationTilePattern
+ call WriteCutOrBoulderDustAnimationOAMBlock
ld hl, wOAMBuffer + $93
- ld de, $4
+ ld de, 4
ld a, $30
ld c, e
-.asm_f044
+.loop
ld [hl], a
add hl, de
xor $60
dec c
- jr nz, .asm_f044
+ jr nz, .loop
ret
-LoadCutTreeAnimationTilePattern: ; f04c (3:704c)
+LoadCutGrassAnimationTilePattern: ; f04c (3:704c)
ld de, AnimationTileset2 + $60 ; tile depicting a leaf
ld bc, (BANK(AnimationTileset2) << 8) + $01
jp CopyVideoData
-WriteCutTreeBoulderDustAnimationOAMBlock: ; f055 (3:7055)
- call GetCutTreeBoulderDustAnimationOffsets
+WriteCutOrBoulderDustAnimationOAMBlock: ; f055 (3:7055)
+ call GetCutOrBoulderDustAnimationOffsets
ld a, $9
- ld de, CutTreeBoulderDustAnimationTilesAndAttributes
+ ld de, CutOrBoulderDustAnimationTilesAndAttributes
jp WriteOAMBlock
-CutTreeBoulderDustAnimationTilesAndAttributes: ; f060 (3:7060)
+CutOrBoulderDustAnimationTilesAndAttributes: ; f060 (3:7060)
db $FC,$10,$FD,$10
db $FE,$10,$FF,$10
-GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068)
+GetCutOrBoulderDustAnimationOffsets: ; f068 (3:7068)
ld hl, wSpriteStateData1 + 4
ld a, [hli] ; player's sprite screen Y position
ld b, a
@@ -140,10 +141,10 @@
ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right)
ld a, [wWhichAnimationOffsets]
and a
- ld hl, CutTreeAnimationOffsets
- jr z, .asm_f084
+ ld hl, CutAnimationOffsets
+ jr z, .next
ld hl, BoulderDustAnimationOffsets
-.asm_f084
+.next
add hl, de
ld e, [hl]
inc hl
@@ -156,7 +157,7 @@
ld c, a
ret
-CutTreeAnimationOffsets: ; f08f (3:708f)
+CutAnimationOffsets: ; f08f (3:708f)
; Each pair represents the x and y pixels offsets from the player of where the cut tree animation should be drawn
db 8, 36 ; player is facing down
db 8, 4 ; player is facing up
@@ -171,19 +172,22 @@
db -24, 20 ; player is facing left
db 40, 20 ; player is facing right
-Func_f09f: ; f09f (3:709f)
+ReplaceTreeTileBlock: ; f09f (3:709f)
+; Determine the address of the tile block that contains the tile in front of the
+; player (i.e. where the tree is) and replace it with the corresponding tile
+; block that doesn't have the tree.
push de
ld a, [W_CURMAPWIDTH]
- add $6
+ add 6
ld c, a
- ld b, $0
- ld d, $0
+ ld b, 0
+ ld d, 0
ld hl, wCurrentTileBlockMapViewPointer
ld a, [hli]
ld h, [hl]
ld l, a
add hl, bc
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
and a
jr z, .down
cp SPRITE_FACING_UP
@@ -190,47 +194,48 @@
jr z, .up
cp SPRITE_FACING_LEFT
jr z, .left
+; right
ld a, [W_XBLOCKCOORD]
and a
- jr z, .asm_f0e0
- jr .asm_f0ec
+ jr z, .centerTileBlock
+ jr .rightOfCenter
.down
ld a, [W_YBLOCKCOORD]
and a
- jr z, .asm_f0e0
- jr .asm_f0df
+ jr z, .centerTileBlock
+ jr .belowCenter
.up
ld a, [W_YBLOCKCOORD]
and a
- jr z, .asm_f0e1
- jr .asm_f0e0
+ jr z, .aboveCenter
+ jr .centerTileBlock
.left
ld a, [W_XBLOCKCOORD]
and a
- jr z, .asm_f0e6
- jr .asm_f0e0
-.asm_f0df
+ jr z, .leftOfCenter
+ jr .centerTileBlock
+.belowCenter
add hl, bc
-.asm_f0e0
+.centerTileBlock
add hl, bc
-.asm_f0e1
+.aboveCenter
ld e, $2
add hl, de
- jr .asm_f0f0
-.asm_f0e6
+ jr .next
+.leftOfCenter
ld e, $1
add hl, bc
add hl, de
- jr .asm_f0f0
-.asm_f0ec
+ jr .next
+.rightOfCenter
ld e, $3
add hl, bc
add hl, de
-.asm_f0f0
+.next
pop de
ld a, [hl]
ld c, a
-.asm_f0f3
+.loop ; find the matching tile block in the array
ld a, [de]
inc de
inc de
@@ -237,9 +242,9 @@
cp $ff
ret z
cp c
- jr nz, .asm_f0f3
+ jr nz, .loop
dec de
- ld a, [de]
+ ld a, [de] ; replacement tile block from matching array entry
ld [hl], a
ret
--- a/engine/overworld/cut2.asm
+++ b/engine/overworld/cut2.asm
@@ -1,19 +1,19 @@
-Func_79e96: ; 79e96 (1e:5e96)
+AnimCut: ; 79e96 (1e:5e96)
ld a, [wCutTile]
cp $52
- jr z, .asm_79ec8
+ jr z, .grass
ld c, $8
-.asm_79e9f
+.cutTreeLoop
push bc
ld hl, wOAMBuffer + $91
- ld a, $1
- ld [wd08a], a
- ld c, $2
+ ld a, 1
+ ld [wCoordAdjustmentAmount], a
+ ld c, 2
call AdjustOAMBlockXPos2
ld hl, wOAMBuffer + $99
- ld a, $ff
- ld [wd08a], a
- ld c, $2
+ ld a, -1
+ ld [wCoordAdjustmentAmount], a
+ ld c, 2
call AdjustOAMBlockXPos2
ld a, [rOBP1]
xor $64
@@ -21,49 +21,49 @@
call DelayFrame
pop bc
dec c
- jr nz, .asm_79e9f
+ jr nz, .cutTreeLoop
ret
-.asm_79ec8
- ld c, $2
-.asm_79eca
+.grass
+ ld c, 2
+.cutGrassLoop
push bc
ld c, $8
- call Func_79eed
- call Func_79f30
+ call AnimCutGrass_UpdateOAMEntries
+ call AnimCutGrass_SwapOAMEntries
ld c, $8
- call Func_79eed
- call Func_79f30
+ call AnimCutGrass_UpdateOAMEntries
+ call AnimCutGrass_SwapOAMEntries
ld hl, wOAMBuffer + $90
- ld a, $2
- ld [wd08a], a
- ld c, $4
+ ld a, 2
+ ld [wCoordAdjustmentAmount], a
+ ld c, 4
call AdjustOAMBlockYPos2
pop bc
dec c
- jr nz, .asm_79eca
+ jr nz, .cutGrassLoop
ret
-Func_79eed: ; 79eed (1e:5eed)
+AnimCutGrass_UpdateOAMEntries: ; 79eed (1e:5eed)
push bc
ld hl, wOAMBuffer + $91
- ld a, $1
- ld [wd08a], a
- ld c, $1
+ ld a, 1
+ ld [wCoordAdjustmentAmount], a
+ ld c, 1
call AdjustOAMBlockXPos2
ld hl, wOAMBuffer + $95
- ld a, $2
- ld [wd08a], a
- ld c, $1
+ ld a, 2
+ ld [wCoordAdjustmentAmount], a
+ ld c, 1
call AdjustOAMBlockXPos2
ld hl, wOAMBuffer + $99
- ld a, $fe
- ld [wd08a], a
- ld c, $1
+ ld a, -2
+ ld [wCoordAdjustmentAmount], a
+ ld c, 1
call AdjustOAMBlockXPos2
ld hl, wOAMBuffer + $9d
- ld a, $ff
- ld [wd08a], a
- ld c, $1
+ ld a, -1
+ ld [wCoordAdjustmentAmount], a
+ ld c, 1
call AdjustOAMBlockXPos2
ld a, [rOBP1]
xor $64
@@ -71,12 +71,12 @@
call DelayFrame
pop bc
dec c
- jr nz, Func_79eed
+ jr nz, AnimCutGrass_UpdateOAMEntries
ret
-Func_79f30: ; 79f30 (1e:5f30)
+AnimCutGrass_SwapOAMEntries: ; 79f30 (1e:5f30)
ld hl, wOAMBuffer + $90
- ld de, wHPBarMaxHP
+ ld de, wBuffer
ld bc, $8
call CopyData
ld hl, wOAMBuffer + $98
@@ -83,7 +83,7 @@
ld de, wOAMBuffer + $90
ld bc, $8
call CopyData
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
ld de, wOAMBuffer + $98
ld bc, $8
jp CopyData
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -8,7 +8,7 @@
ld a, %11100100
ld [rOBP1], a
call LoadSmokeTileFourTimes
- callba WriteCutTreeBoulderDustAnimationOAMBlock
+ callba WriteCutOrBoulderDustAnimationOAMBlock
ld c, 8 ; number of steps in animation
.loop
push bc
@@ -15,7 +15,7 @@
call GetMoveBoulderDustFunctionPointer
ld bc, .returnAddress
push bc
- ld c, $4
+ ld c, 4
jp [hl]
.returnAddress
ld a, [rOBP1]
@@ -36,7 +36,7 @@
ld b, $0
add hl, bc
ld a, [hli]
- ld [wd08a], a
+ ld [wCoordAdjustmentAmount], a
ld a, [hli]
ld e, a
ld a, [hli]
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -711,12 +711,12 @@
SlotMachine_PutOutLitBalls: ; 377ce (d:77ce)
ld a, $23
- ld [wd08a], a
+ ld [wNewSlotMachineBallTile], a
jr SlotMachine_UpdateThreeCoinBallTiles
SlotMachine_LightBalls: ; 377d5 (d:77d5)
ld a, $14
- ld [wd08a], a
+ ld [wNewSlotMachineBallTile], a
ld a, [wSlotMachineBet]
dec a
jr z, SlotMachine_UpdateOneCoinBallTiles
@@ -739,7 +739,7 @@
coord hl, 3, 6
SlotMachine_UpdateBallTiles: ; 377fe (d:77fe)
- ld a, [wd08a]
+ ld a, [wNewSlotMachineBallTile]
ld [hl], a
ld bc, 13
add hl, bc
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -304,7 +304,7 @@
ld a, %11100100
ld [rOBP0], a
xor a
- ld [wd09f], a
+ ld [wLinkCableAnimBulgeToggle], a
ld bc, $2060
.moveBallInsideLinkCableLoop
push bc
@@ -311,18 +311,18 @@
xor a
ld de, Trade_BallInsideLinkCableOAM
call WriteOAMBlock
- ld a, [wd09f]
+ ld a, [wLinkCableAnimBulgeToggle]
xor $1
- ld [wd09f], a
+ ld [wLinkCableAnimBulgeToggle], a
add $7e
ld hl, wOAMBuffer + $02
- ld de, $4
+ ld de, 4
ld c, e
-.cycleSpriteFramesLoop
+.cycleLinkCableBulgeTile
ld [hl], a
add hl, de
dec c
- jr nz, .cycleSpriteFramesLoop
+ jr nz, .cycleLinkCableBulgeTile
call Delay3
pop bc
ld a, c
--- a/home.asm
+++ b/home.asm
@@ -411,12 +411,12 @@
ld a,1
ld [wMenuWrappingEnabled],a
ld a,$40
- ld [wd09b],a
- call HandleMenuInputPokemonSelection
+ ld [wPartyMenuAnimMonEnabled],a
+ call HandleMenuInput_
call PlaceUnfilledArrowMenuCursor
ld b,a
xor a
- ld [wd09b],a
+ ld [wPartyMenuAnimMonEnabled],a
ld a,[wCurrentMenuItem]
ld [wPartyAndBillsPCSavedMenuItem],a
ld hl,wd730
@@ -3897,9 +3897,9 @@
HandleMenuInput:: ; 3abe (0:3abe)
xor a
- ld [wd09b],a
+ ld [wPartyMenuAnimMonEnabled],a
-HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
+HandleMenuInput_:: ; 3ac2 (0:3ac2)
ld a,[H_DOWNARROWBLINKCNT1]
push af
ld a,[H_DOWNARROWBLINKCNT2]
@@ -3915,7 +3915,7 @@
call Delay3
.loop2
push hl
- ld a,[wd09b]
+ ld a,[wPartyMenuAnimMonEnabled]
and a ; is it a pokemon selection menu?
jr z,.getJoypadState
callba AnimatePartyMon ; shake mini sprite of selected pokemon
--- a/scripts/agatha.asm
+++ b/scripts/agatha.asm
@@ -21,7 +21,7 @@
ld a, $3b
AgathaScript_76459: ; 76459 (1d:6459)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
--- a/scripts/bruno.asm
+++ b/scripts/bruno.asm
@@ -21,7 +21,7 @@
ld a, $24
BrunoScript_76302: ; 76302 (1d:6302)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -31,7 +31,7 @@
CheckEvent EVENT_FOUND_ROCKET_HIDEOUT
ret nz
ld a, $2a
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0208
predef_jump ReplaceTileBlock
@@ -451,7 +451,7 @@
call WaitForSoundToFinish
SetEvent EVENT_FOUND_ROCKET_HIDEOUT
ld a, $43
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0208
predef ReplaceTileBlock
jp TextScriptEnd
--- a/scripts/lance.asm
+++ b/scripts/lance.asm
@@ -24,12 +24,12 @@
LanceScript_5a2de: ; 5a2de (16:62de)
push bc
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $602
call LanceScript_5a2f0
pop bc
ld a, b
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $603
LanceScript_5a2f0: ; 5a2f0 (16:62f0)
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -22,7 +22,7 @@
.asm_761a9
ld a, $24
.asm_761ab
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -35,12 +35,12 @@
Mansion1Script_44304: ; 44304 (11:4304)
ld a, $2d
- ld [wd09f], a
+ ld [wNewTileBlockID], a
jr Mansion1ReplaceBlock
Mansion1Script_4430b: ; 4430b (11:430b)
ld a, $e
- ld [wd09f], a
+ ld [wNewTileBlockID], a
Mansion1ReplaceBlock: ; 44310 (11:4310)
predef ReplaceTileBlock
ret
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -38,7 +38,7 @@
ret
Mansion2Script_5202f: ; 5202f (14:602f)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef_jump ReplaceTileBlock
Mansion2Script_Switches: ; 52037 (14:6037)
--- a/scripts/rockethideout1.asm
+++ b/scripts/rockethideout1.asm
@@ -26,7 +26,7 @@
.asm_44c01
ld a, $e
.asm_44c03
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $080c
predef_jump ReplaceTileBlock
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -26,7 +26,7 @@
.asm_45496
ld a, $e
.asm_45498
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $050c
predef_jump ReplaceTileBlock
--- a/scripts/silphco10.asm
+++ b/scripts/silphco10.asm
@@ -19,7 +19,7 @@
CheckEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR
ret nz
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $405
predef_jump ReplaceTileBlock
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -19,7 +19,7 @@
CheckEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR
ret nz
ld a, $20
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $603
predef_jump ReplaceTileBlock
--- a/scripts/silphco2.asm
+++ b/scripts/silphco2.asm
@@ -20,7 +20,7 @@
jr nz, .asm_59d2e
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0202
predef ReplaceTileBlock
pop af
@@ -28,7 +28,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_2_UNLOCKED_DOOR2, EVENT_SILPH_CO_2_UNLOCKED_DOOR1
ret nz
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0502
predef_jump ReplaceTileBlock
--- a/scripts/silphco3.asm
+++ b/scripts/silphco3.asm
@@ -20,7 +20,7 @@
jr nz, .asm_59f98
push af
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $404
predef ReplaceTileBlock
pop af
@@ -28,7 +28,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_3_UNLOCKED_DOOR2, EVENT_SILPH_CO_3_UNLOCKED_DOOR1
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $408
predef_jump ReplaceTileBlock
--- a/scripts/silphco4.asm
+++ b/scripts/silphco4.asm
@@ -20,7 +20,7 @@
jr nz, .asm_19d48
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0602
predef ReplaceTileBlock
pop af
@@ -28,7 +28,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_4_UNLOCKED_DOOR2, EVENT_SILPH_CO_4_UNLOCKED_DOOR1
ret nz
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0406
predef_jump ReplaceTileBlock
--- a/scripts/silphco5.asm
+++ b/scripts/silphco5.asm
@@ -20,7 +20,7 @@
jr nz, .asm_19f74
push af
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0203
predef ReplaceTileBlock
pop af
@@ -29,7 +29,7 @@
jr nz, .asm_19f87
push af
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0603
predef ReplaceTileBlock
pop af
@@ -37,7 +37,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_5_UNLOCKED_DOOR3, EVENT_SILPH_CO_5_UNLOCKED_DOOR2
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0507
predef_jump ReplaceTileBlock
--- a/scripts/silphco6.asm
+++ b/scripts/silphco6.asm
@@ -19,7 +19,7 @@
CheckEvent EVENT_SILPH_CO_6_UNLOCKED_DOOR
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0602
predef_jump ReplaceTileBlock
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -20,7 +20,7 @@
jr nz, .asm_51b9e
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $305
predef ReplaceTileBlock
pop af
@@ -29,7 +29,7 @@
jr nz, .asm_51bb1
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $20a
predef ReplaceTileBlock
pop af
@@ -37,7 +37,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_7_UNLOCKED_DOOR3, EVENT_SILPH_CO_7_UNLOCKED_DOOR2
ret nz
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $60a
predef_jump ReplaceTileBlock
--- a/scripts/silphco8.asm
+++ b/scripts/silphco8.asm
@@ -19,7 +19,7 @@
CheckEvent EVENT_SILPH_CO_8_UNLOCKED_DOOR
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $403
predef_jump ReplaceTileBlock
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -20,7 +20,7 @@
jr nz, .asm_5d7f8
push af
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $401
predef ReplaceTileBlock
pop af
@@ -29,7 +29,7 @@
jr nz, .asm_5d80b
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $209
predef ReplaceTileBlock
pop af
@@ -38,7 +38,7 @@
jr nz, .asm_5d81e
push af
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $509
predef ReplaceTileBlock
pop af
@@ -46,7 +46,7 @@
CheckEventAfterBranchReuseA EVENT_SILPH_CO_9_UNLOCKED_DOOR4, EVENT_SILPH_CO_9_UNLOCKED_DOOR3
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $605
predef_jump ReplaceTileBlock
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -37,7 +37,7 @@
call PlaySound
ld a, $5
.asm_5ca7f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $202
predef_jump ReplaceTileBlock
--- a/scripts/victoryroad1.asm
+++ b/scripts/victoryroad1.asm
@@ -14,7 +14,7 @@
CheckEvent EVENT_VICTORY_ROAD_1_BOULDER_ON_SWITCH
ret z
ld a, $1d
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $604
predef_jump ReplaceTileBlock
--- a/scripts/victoryroad2.asm
+++ b/scripts/victoryroad2.asm
@@ -33,7 +33,7 @@
ld bc, $70b
VictoryRoad2Script_517e2: ; 517e2 (14:57e2)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
ret
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -16,7 +16,7 @@
CheckEventHL EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1
ret z
ld a, $1d
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $503
predef_jump ReplaceTileBlock
--- a/wram.asm
+++ b/wram.asm
@@ -409,8 +409,12 @@
ds 12
wcc6b:: ds 14 ; doesn't seem to be used for anything, probably just more storage
-wcc79:: ds 30 ; used in battle animations
+wAnimPalette:: ; cc79
+ ds 1
+
+ ds 29
+
wNPCMovementDirections2:: ; cc97
wSwitchPartyMonTempBuffer:: ; cc97
@@ -647,6 +651,13 @@
ds 1
+wFallingObjectsMovementData:: ; cd3d
+; up to 20 bytes (one byte for each falling object)
+
+wSavedY:: ; cd3d
+
+wTempSCX:: ; cd3d
+
wBattleTransitionCircleScreenQuadrantY:: ; cd3d
; 0 = upper half (Y < 9)
; 1 = lower half (Y >= 9)
@@ -1050,9 +1061,13 @@
; whether WriteMonMoves is being used to make a mon learn moves from day care
; non-zero if so
+wChangeMonPicEnemyTurnSpecies:: ; cee9
+
wHPBarMaxHP:: ; cee9
ds 1
+wChangeMonPicPlayerTurnSpecies:: ; ceea
+
wEvoNewSpecies:: ; ceea
ds 1
@@ -1554,13 +1569,35 @@
; number of tiles in current battle animation frame block
ds 1
+wFlashScreenLongCounter:: ; d08a
+
+wSpiralBallsBaseY:: ; d08a
+
+wFallingObjectMovementByte:: ; d08a
+; bits 0-6: index into FallingObjects_DeltaXs array (0 - 8)
+; bit 7: direction; 0 = right, 1 = left
+
+wNumShootingBalls:: ; d08a
+
wTradedMonMovingRight:: ; d08a
; $01 if mon is moving from left gameboy to right gameboy; $00 if vice versa
wOptionsInitialized:: ; d08a
-wd08a:: ds 1 ; used with sprites and displaying the option menu on the main menu screen?
+wNewSlotMachineBallTile:: ; d08a
+wCoordAdjustmentAmount:: ; d08a
+; how much to add to the X/Y coord
+
+wUnusedD08A:: ; d08a
+ ds 1
+
+wSpiralBallsBaseX:: ; d08b
+
+wNumFallingObjects:: ; d08b
+
+wSlideMonDelay:: ; d08b
+
wAnimCounter:: ; d08b
; generic counter variable for various animations
@@ -1601,13 +1638,17 @@
ds 2
-wd09a:: ds 1 ; used with the battle transition screen when entering a battle (screen slowly draws into black)
+wOutwardSpiralTileMapPointer:: ; d09a
+ ds 1
+wPartyMenuAnimMonEnabled:: ; d09b
+
wTownMapSpriteBlinkingEnabled:: ; d09b
; non-zero when enabled. causes nest locations to blink on and off.
; the town selection cursor will blink regardless of what this value is
-wd09b:: ds 1 ; also used with battle transition screen and move animations
+wUnusedD09B:: ; d09b
+ ds 1
W_FBDESTADDR:: ; d09c
; current destination address in OAM for frame blocks (big endian)
@@ -1625,9 +1666,28 @@
; contain the upper and lower bit of each of the 8 pixels, respectively
ds 1
+wLinkCableAnimBulgeToggle:: ; d09f
+; 0 = small
+; 1 = big
+
+wIntroNidorinoBaseTile:: ; d09f
+
+wOutwardSpiralCurrentDirection:: ; d09f
+
+wDropletTile:: ; d09f
+
wNewTileBlockID:: ; d09f
-wd09f:: ds 1 ; used with predef ReplaceTileBlock
+wWhichBattleAnimTileset:: ; d09f
+
+wSquishMonCurrentDirection:: ; d09f
+; 0 = left
+; 1 = right
+
+wSlideMonUpBottomRowLeftTile:: ; d09f
+; the tile ID of the leftmost tile in the bottom row in AnimationSlideMonUp_
+ ds 1
+
wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank
W_SPRITECURPOSX:: ; d0a1