summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconstants/event_constants.asm6
-rw-r--r--constants/misc_constants.asm6
-rw-r--r--constants/move_animation_constants.asm6
-rwxr-xr-xdata/animations.asm16
-rwxr-xr-xdata/baseStats/rhydon.asm2
-rwxr-xr-xengine/HoF_room_pc.asm10
-rwxr-xr-xengine/battle/animations.asm906
-rw-r--r--engine/battle/battle_transitions.asm152
-rw-r--r--engine/battle/common_text.asm39
-rwxr-xr-xengine/battle/core.asm118
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm36
-rwxr-xr-xengine/battle/end_of_battle.asm2
-rw-r--r--engine/battle/ghost_marowak_anim.asm4
-rwxr-xr-xengine/battle/read_trainer_party.asm2
-rw-r--r--engine/battle/trainer_ai.asm26
-rw-r--r--engine/battle/wild_encounters.asm10
-rwxr-xr-xengine/evos_moves.asm12
-rwxr-xr-xengine/hidden_object_functions17.asm39
-rwxr-xr-xengine/hidden_object_functions18.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm42
-rwxr-xr-xengine/hp_bar.asm17
-rwxr-xr-xengine/intro.asm18
-rwxr-xr-xengine/items/items.asm30
-rwxr-xr-xengine/learn_move.asm4
-rwxr-xr-xengine/menu/main_menu.asm6
-rwxr-xr-xengine/menu/naming_screen.asm48
-rwxr-xr-xengine/menu/party_menu.asm2
-rwxr-xr-xengine/menu/pc.asm12
-rwxr-xr-xengine/menu/prize_menu.asm36
-rwxr-xr-xengine/menu/start_sub_menus.asm12
-rwxr-xr-xengine/oak_speech.asm2
-rwxr-xr-xengine/overworld/cable_club_npc.asm23
-rwxr-xr-xengine/overworld/card_key.asm6
-rwxr-xr-xengine/overworld/cinnabar_lab.asm35
-rwxr-xr-xengine/overworld/cut.asm125
-rwxr-xr-xengine/overworld/cut2.asm76
-rwxr-xr-xengine/overworld/hidden_items.asm4
-rw-r--r--engine/overworld/item.asm2
-rwxr-xr-xengine/overworld/npc_movement.asm8
-rwxr-xr-xengine/overworld/pewter_guys.asm18
-rwxr-xr-xengine/overworld/player_animations.asm4
-rwxr-xr-xengine/overworld/ssanne.asm6
-rwxr-xr-xengine/overworld/trainers.asm18
-rwxr-xr-xengine/predefs.asm2
-rwxr-xr-xengine/predefs7.asm14
-rwxr-xr-xengine/slot_machine.asm6
-rwxr-xr-xengine/town_map.asm22
-rwxr-xr-xengine/trade.asm12
-rw-r--r--home.asm48
-rw-r--r--home/overworld.asm50
-rw-r--r--home/text.asm8
-rw-r--r--home/vblank.asm4
-rw-r--r--home/vcopy.asm20
-rw-r--r--hram.asm17
-rwxr-xr-xmain.asm80
-rwxr-xr-xscripts/agatha.asm2
-rwxr-xr-xscripts/billshouse.asm8
-rwxr-xr-xscripts/blueshouse.asm2
-rwxr-xr-xscripts/bruno.asm2
-rwxr-xr-xscripts/celadongamecorner.asm6
-rwxr-xr-xscripts/celadongym.asm2
-rwxr-xr-xscripts/celadonmansion5.asm2
-rwxr-xr-xscripts/celadonmartelevator.asm6
-rwxr-xr-xscripts/ceruleancity.asm6
-rwxr-xr-xscripts/ceruleancity2.asm6
-rwxr-xr-xscripts/ceruleangym.asm2
-rwxr-xr-xscripts/cinnabargym.asm10
-rwxr-xr-xscripts/daycarem.asm26
-rwxr-xr-xscripts/fightingdojo.asm4
-rwxr-xr-xscripts/fuchsiagym.asm2
-rwxr-xr-xscripts/gary.asm4
-rwxr-xr-xscripts/halloffameroom.asm2
-rwxr-xr-xscripts/lance.asm4
-rwxr-xr-xscripts/lorelei.asm2
-rwxr-xr-xscripts/mansion1.asm4
-rwxr-xr-xscripts/mansion2.asm2
-rwxr-xr-xscripts/mtmoon3.asm6
-rwxr-xr-xscripts/museum1f.asm2
-rwxr-xr-xscripts/oakslab.asm42
-rwxr-xr-xscripts/pallettown.asm6
-rwxr-xr-xscripts/pewtercity.asm8
-rwxr-xr-xscripts/pewtergym.asm10
-rwxr-xr-xscripts/pokemontower2.asm2
-rwxr-xr-xscripts/pokemontower7.asm12
-rwxr-xr-xscripts/rockethideout1.asm2
-rwxr-xr-xscripts/rockethideout4.asm8
-rwxr-xr-xscripts/rockethideoutelevator.asm6
-rwxr-xr-xscripts/route12.asm2
-rwxr-xr-xscripts/route16.asm2
-rwxr-xr-xscripts/route20.asm4
-rwxr-xr-xscripts/route22.asm18
-rwxr-xr-xscripts/route23.asm4
-rwxr-xr-xscripts/route25.asm8
-rw-r--r--scripts/safarizoneentrance-yellow.asm18
-rwxr-xr-xscripts/safarizoneentrance.asm12
-rwxr-xr-xscripts/saffrongym.asm2
-rwxr-xr-xscripts/seafoamislands1.asm16
-rwxr-xr-xscripts/seafoamislands2.asm16
-rwxr-xr-xscripts/seafoamislands3.asm16
-rwxr-xr-xscripts/seafoamislands4.asm16
-rwxr-xr-xscripts/seafoamislands5.asm8
-rwxr-xr-xscripts/silphco1.asm2
-rwxr-xr-xscripts/silphco10.asm2
-rwxr-xr-xscripts/silphco11.asm6
-rwxr-xr-xscripts/silphco2.asm4
-rwxr-xr-xscripts/silphco3.asm4
-rwxr-xr-xscripts/silphco4.asm4
-rwxr-xr-xscripts/silphco5.asm6
-rwxr-xr-xscripts/silphco6.asm2
-rwxr-xr-xscripts/silphco7.asm8
-rwxr-xr-xscripts/silphco8.asm2
-rwxr-xr-xscripts/silphco9.asm8
-rwxr-xr-xscripts/silphcoelevator.asm6
-rwxr-xr-xscripts/ssanne2.asm4
-rwxr-xr-xscripts/vermilioncity.asm6
-rwxr-xr-xscripts/vermiliongym.asm6
-rwxr-xr-xscripts/victoryroad1.asm2
-rwxr-xr-xscripts/victoryroad2.asm2
-rwxr-xr-xscripts/victoryroad3.asm6
-rwxr-xr-xscripts/viridiangym.asm8
-rw-r--r--text/maps/daycare_1.asm2
-rw-r--r--text/maps/name_rater.asm2
-rwxr-xr-xwram.asm357
123 files changed, 1694 insertions, 1336 deletions
diff --git a/constants/event_constants.asm b/constants/event_constants.asm
index 4e3a2849..f284c967 100755
--- a/constants/event_constants.asm
+++ b/constants/event_constants.asm
@@ -1317,9 +1317,9 @@ const_value = 0
const EVENT_522 ; 522, (D7EB, bit 2)
const EVENT_523 ; 523, (D7EB, bit 3)
const EVENT_524 ; 524, (D7EB, bit 4)
- const EVENT_BEAT_ROUTE22_RIVAL_1ST_FIGHT ; 525, (D7EB, bit 5)
- const EVENT_BEAT_ROUTE22_RIVAL_2ND_FIGHT ; 526, (D7EB, bit 6)
- const EVENT_ROUTE22_RIVAL_WANTS_FIGHT ; 527, (D7EB, bit 7)
+ const EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE ; 525, (D7EB, bit 5)
+ const EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE ; 526, (D7EB, bit 6)
+ const EVENT_ROUTE22_RIVAL_WANTS_BATTLE ; 527, (D7EB, bit 7)
const EVENT_528 ; 528, (D7EC, bit 0)
const EVENT_529 ; 529, (D7EC, bit 1)
const EVENT_52A ; 52A, (D7EC, bit 2)
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index ad2e8dea..b5d889d4 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -143,6 +143,12 @@ FLAG_RESET EQU 0
FLAG_SET EQU 1
FLAG_TEST EQU 2
+; special text IDs
+TEXT_MON_FAINTED EQU $d0
+TEXT_BLACKED_OUT EQU $d1
+TEXT_REPEL_WORE_OFF EQU $d2
+TEXT_SAFARI_GAME_OVER EQU $d3
+
; serial
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
diff --git a/constants/move_animation_constants.asm b/constants/move_animation_constants.asm
index 61e25212..27658c83 100644
--- a/constants/move_animation_constants.asm
+++ b/constants/move_animation_constants.asm
@@ -6,7 +6,7 @@ const_value = $D8
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_value = $D8
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_value = $D8
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.
diff --git a/data/animations.asm b/data/animations.asm
index a9d22e54..cf6dc150 100755
--- a/data/animations.asm
+++ b/data/animations.asm
@@ -296,7 +296,7 @@ WingAttackAnim: ; 7a277 (1e:6277)
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 @@ DrillPeckAnim: ; 7a3c8 (1e:63c8)
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 @@ SeismicTossAnim: ; 7a3e4 (1e:63e4)
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 @@ AgilityAnim: ; 7a4c3 (1e:64c3)
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 @@ KinesisAnim: ; 7a5fa (1e:65fa)
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 @@ SlashAnim: ; 7a6cd (1e:66cd)
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
diff --git a/data/baseStats/rhydon.asm b/data/baseStats/rhydon.asm
index a480f2b1..2d844a3d 100755
--- a/data/baseStats/rhydon.asm
+++ b/data/baseStats/rhydon.asm
@@ -28,4 +28,4 @@ db %10100010
db %10001000
db %00110010
db 0 ; padding
-MonBaseStatsEnd: \ No newline at end of file
+MonBaseStatsEnd:
diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm
index 104d32ff..15ea1524 100755
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -65,16 +65,16 @@ DisplayCreditsMon: ; 740cb (1d:40cb)
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 @@ HoFGBPalettes: ; 74160 (1d:4160)
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
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 73d152b8..424190d3 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -223,7 +223,7 @@ PlayAnimation: ; 780f1 (1e:40f1)
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 @@ PlayAnimation: ; 780f1 (1e:40f1)
push hl
ld a,[rOBP0]
push af
- ld a,[wcc79]
+ ld a,[wAnimPalette]
ld [rOBP0],a
call LoadAnimationTileset
call LoadSubanimation
@@ -328,7 +328,7 @@ GetSubanimationTransform2: ; 781ca (1e:41ca)
; 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 @@ MoveAnimation: ; 78d5e (1e:4d5e)
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 @@ AnimationTypePointerTable: ; 78dcf (1e:4dcf)
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,32 +490,32 @@ BlinkEnemyMonSprite: ; 78df0 (1e:4df0)
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
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
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 @@ SetAnimationPalette: ; 78e23 (1e:4e23)
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 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
.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 @@ TradeHidePokemon: ; 79041 (1e:5041)
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 @@ SpecialEffectPointers: ; 790da (1e:50da)
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 @@ SpecialEffectPointers: ; 790da (1e:50da)
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 @@ SpecialEffectPointers: ; 790da (1e:50da)
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 @@ CallWithTurnFlipped: ; 79155 (1e:5155)
; 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 @@ AnimationFlashScreenLong: ; 79165 (1e:5165)
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 @@ FlashScreenLongSGB: ; 7919b (1e:519b)
; 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 @@ AnimationFlashScreen: ; 791be (1e:51be)
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,75 +1239,75 @@ AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
; 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)
; Slides the mon's sprite down out of the screen.
xor a
call GetTileIDList
-.asm_7929b
+.loop
call GetMonSpriteTileMapPointerFromRowCount
push bc
push de
@@ -1317,54 +1317,63 @@ AnimationSlideMonDown: ; 79297 (1e:5297)
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)
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
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 @@ _AnimationSlideMonUp: ; 792bf (1e:52bf)
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 @@ AdjustOAMBlockXPos: ; 79337 (1e:5337)
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 @@ AdjustOAMBlockYPos: ; 79350 (1e:5350)
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 @@ AnimationBlinkEnemyMon: ; 79369 (1e:5369)
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,17 +1494,17 @@ AnimationBlinkMon: ; 7936f (1e:536f)
call DelayFrames
pop bc
dec c
- jr nz, .asm_79372
+ jr nz, .loop
pop af
ret
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 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1)
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 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1)
call CopyPicTiles
call Delay3
pop hl
- ld bc, $0709
+ lb bc, 7, 9
call ClearScreenArea
pop af
call GetTileIDList
@@ -1545,14 +1561,14 @@ AnimationShakeBackAndForth: ; 793b1 (1e:53b1)
call CopyPicTiles
call Delay3
pop hl
- ld bc, $0709
+ lb bc, 7, 9
call ClearScreenArea
pop hl
pop de
pop bc
pop af
dec c
- jr nz, .asm_793c5
+ jr nz, .loop
ret
AnimationMoveMonHorizontally: ; 793f9 (1e:53f9)
@@ -1562,9 +1578,9 @@ AnimationMoveMonHorizontally: ; 793f9 (1e:53f9)
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,70 +1593,70 @@ AnimationResetMonPosition: ; 79415 (1e:5415)
; 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
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,57 +1684,57 @@ SpiralBallAnimationCoordinates: ; 79476 (1e:5476)
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
add hl, de
pop bc
dec c
- jr nz, .asm_794d6
+ jr nz, .loop
jp Delay3
AnimationShootBallsUpward: ; 794f9 (1e:54f9)
@@ -1726,67 +1742,68 @@ AnimationShootBallsUpward: ; 794f9 (1e:54f9)
; 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
_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 @@ AnimationShootManyBallsUpward: ; 79566 (1e:5566)
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 @@ AnimationMinimizeMon: ; 7959f (1e:559f)
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 @@ AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9)
; 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 @@ AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9)
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 @@ Func_79652: ; 79652 (1e:5652)
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 @@ AnimationSubstitute: ; 796e0 (1e:56e0)
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 @@ AnimationSubstitute: ; 796e0 (1e:56e0)
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 @@ AnimationSubstitute: ; 796e0 (1e:56e0)
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 @@ HideSubstituteShowMonAnim: ; 79747 (1e:5747)
call AnimationSlideMonDown
jr .next2
.substituteStillUp
- call AnimationSlideMonOut
+ call AnimationSlideMonOff
.next2
pop hl
ld a, [hl]
@@ -2087,35 +2118,35 @@ HideSubstituteShowMonAnim: ; 79747 (1e:5747)
jp AnimationShowMonPic
ReshowSubstituteAnim: ; 79771 (1e:5771)
- call AnimationSlideMonOut
+ call AnimationSlideMonOff
call AnimationSubstitute
jp AnimationShowMonPic
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)
; 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 @@ Func_79793: ; 79793 (1e:5793)
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 @@ Func_79793: ; 79793 (1e:5793)
call CopyPicTiles
pop af
ld [wBattleMonSpecies2], a
-.asm_797d3
+.done
ld b, $1
jp GoPAL_SET
@@ -2152,10 +2183,14 @@ AnimationHideEnemyMonPic: ; 797d8 (1e:57d8)
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,31 +2198,31 @@ Func_797e8: ; 797e8 (1e:57e8)
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)
; 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 @@ GetTileIDList: ; 79842 (1e:5842)
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 @@ AnimationLeavesFalling: ; 79c74 (1e:5c74)
; 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 @@ AnimationLeavesFalling: ; 79c74 (1e:5c74)
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 @@ Func_79d2a: ; 79d2a (1e:5d2a)
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 @@ CopyTileIDsFromList: ; 79dda (1e:5dda)
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 @@ PlayApplyingAttackSound: ; 79e6a (1e:5e6a)
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
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index 4f605b52..e64cbabb 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -1,5 +1,5 @@
BattleTransition: ; 7096d (1c:496d)
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
xor a
@@ -7,10 +7,13 @@ BattleTransition: ; 7096d (1c:496d)
dec a
ld [wUpdateSpritesEnabled], a
call DelayFrame
+
+; Determine which OAM block is being used by the enemy trainer sprite (if there
+; is one).
ld hl, wSpriteStateData1 + 2
- ld a, [H_DOWNARROWBLINKCNT2]
+ ld a, [hSpriteIndexOrTextID] ; enemy trainer sprite index (0 if wild battle)
ld c, a
- ld b, $0
+ ld b, 0
ld de, $10
.loop1
ld a, [hl]
@@ -21,13 +24,15 @@ BattleTransition: ; 7096d (1c:496d)
add hl, de
dec c
jr nz, .loop1
+
+; Clear OAM except for the blocks used by the player and enemy trainer sprites.
ld hl, wOAMBuffer + $10
- ld c, $9
+ ld c, 9
.loop2
ld a, b
swap a
cp l
- jr z, .skip2
+ jr z, .skip2 ; skip clearing the block if the enemy trainer is using it
push hl
push bc
ld bc, $10
@@ -40,9 +45,10 @@ BattleTransition: ; 7096d (1c:496d)
add hl, de
dec c
jr nz, .loop2
+
call Delay3
call LoadBattleTransitionTile
- ld bc, $0
+ ld bc, 0
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .linkBattle
@@ -103,7 +109,7 @@ GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef)
sub e
jr nc, .highLevelEnemy
res 1, c
- ld a, $1
+ ld a, 1
ld [wBattleTransitionSpiralDirection], a
ret
.highLevelEnemy
@@ -204,35 +210,35 @@ BattleTransition_Spiral: ; 70a72 (1c:4a72)
.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)
- ld a, $7
- ld [wWhichTrade], a
+ ld a, 7
+ ld [wInwardSpiralUpdateScreenCounter], a
coord hl, 0, 0
- ld c, $11
+ ld c, SCREEN_HEIGHT - 1
ld de, SCREEN_WIDTH
call BattleTransition_InwardSpiral_
inc c
@@ -242,7 +248,7 @@ BattleTransition_InwardSpiral: ; 70aaa (1c:4aaa)
call BattleTransition_InwardSpiral_
.skip
inc c
- ld de, $1
+ ld de, 1
call BattleTransition_InwardSpiral_
dec c
dec c
@@ -264,13 +270,13 @@ BattleTransition_InwardSpiral_: ; 70ae0 (1c:4ae0)
ld [hl], $ff
add hl, de
push bc
- ld a, [wWhichTrade]
+ ld a, [wInwardSpiralUpdateScreenCounter]
dec a
jr nz, .skip
call BattleTransition_TransferDelay3
- ld a, $7
+ ld a, 7
.skip
- ld [wWhichTrade], a
+ ld [wInwardSpiralUpdateScreenCounter], a
pop bc
dec c
jr nz, .loop
@@ -280,69 +286,69 @@ BattleTransition_InwardSpiral_: ; 70ae0 (1c:4ae0)
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)
@@ -385,7 +391,7 @@ BattleTransition_Shrink: ; 70b7f (1c:4b7f)
call BattleTransition_CopyTiles2
coord hl, 11, 0
coord de, 10, 0
- ld bc, $2
+ ld bc, 2
call BattleTransition_CopyTiles2
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
@@ -419,7 +425,7 @@ BattleTransition_Split: ; 70bca (1c:4bca)
call BattleTransition_CopyTiles2
coord hl, 1, 0
coord de, 0, 0
- ld bc, $2
+ ld bc, 2
call BattleTransition_CopyTiles2
call BattleTransition_TransferDelay3
call Delay3
@@ -432,10 +438,10 @@ BattleTransition_Split: ; 70bca (1c:4bca)
BattleTransition_CopyTiles1: ; 70c12 (1c:4c12)
ld a, c
- ld [wWhichTrade], a
+ ld [wBattleTransitionCopyTilesOffset], a
ld a, b
- ld [wTrainerEngageDistance], a
- ld c, $8
+ ld [wBattleTransitionCopyTilesOffset + 1], a
+ ld c, 8
.loop1
push bc
push hl
@@ -444,9 +450,9 @@ BattleTransition_CopyTiles1: ; 70c12 (1c:4c12)
call CopyData
pop hl
pop de
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCopyTilesOffset]
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCopyTilesOffset + 1]
ld b, a
add hl, bc
pop bc
@@ -464,9 +470,9 @@ BattleTransition_CopyTiles1: ; 70c12 (1c:4c12)
BattleTransition_CopyTiles2: ; 70c3f (1c:4c3f)
ld a, c
- ld [wWhichTrade], a
+ ld [wBattleTransitionCopyTilesOffset], a
ld a, b
- ld [wTrainerEngageDistance], a
+ ld [wBattleTransitionCopyTilesOffset + 1], a
ld c, SCREEN_HEIGHT / 2
.loop1
push bc
@@ -492,9 +498,9 @@ BattleTransition_CopyTiles2: ; 70c3f (1c:4c3f)
jr nz, .loop2
pop hl
pop de
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCopyTilesOffset]
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCopyTilesOffset + 1]
ld b, a
add hl, bc
pop bc
@@ -590,11 +596,11 @@ BattleTransition_HorizontalStripes_: ; 70cd8 (1c:4cd8)
; by animating each half circle one at a time
BattleTransition_Circle: ; 70ce4 (1c:4ce4)
call BattleTransition_FlashScreen
- ld bc, SCREEN_WIDTH / 2
+ lb bc, 0, SCREEN_WIDTH / 2
ld hl, BattleTransition_HalfCircle1
call BattleTransition_Circle_Sub1
ld c, SCREEN_WIDTH / 2
- ld b, $1
+ ld b, 1
ld hl, BattleTransition_HalfCircle2
call BattleTransition_Circle_Sub1
jp BattleTransition_BlackScreen
@@ -612,7 +618,7 @@ BattleTransition_Circle_Sub1: ; 70d06 (1c:4d06)
ld a, b
call BattleTransition_Circle_Sub2
pop hl
- ld bc, $0005
+ ld bc, 5
add hl, bc
call BattleTransition_TransferDelay3
pop bc
@@ -621,7 +627,7 @@ BattleTransition_Circle_Sub1: ; 70d06 (1c:4d06)
ret
BattleTransition_TransferDelay3: ; 70d19 (1c:4d19)
- ld a, $1
+ ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
xor a
@@ -647,7 +653,7 @@ BattleTransition_DoubleCircle: ; 70d24 (1c:4d24)
ld a, $1
call BattleTransition_Circle_Sub2
pop hl
- ld bc, $5
+ ld bc, 5
add hl, bc
ld e, l
ld d, h
@@ -660,9 +666,9 @@ BattleTransition_DoubleCircle: ; 70d24 (1c:4d24)
jp BattleTransition_BlackScreen
BattleTransition_Circle_Sub2: ; 70d50 (1c:4d50)
- ld [wWhichTrade], a
+ ld [wBattleTransitionCircleScreenQuadrantY], a
ld a, [hli]
- ld [wTrainerEngageDistance], a
+ ld [wBattleTransitionCircleScreenQuadrantX], a
ld a, [hli]
ld e, a
ld a, [hli]
@@ -761,7 +767,7 @@ BattleTransition_Circle_Sub3: ; 70dc5 (1c:4dc5)
inc de
.loop1
ld [hl], $ff
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCircleScreenQuadrantX]
and a
jr z, .skip1
inc hl
@@ -772,7 +778,7 @@ BattleTransition_Circle_Sub3: ; 70dc5 (1c:4dc5)
dec c
jr nz, .loop1
pop hl
- ld a, [wWhichTrade]
+ ld a, [wBattleTransitionCircleScreenQuadrantY]
and a
ld bc, SCREEN_WIDTH
jr z, .skip3
@@ -787,7 +793,7 @@ BattleTransition_Circle_Sub3: ; 70dc5 (1c:4dc5)
jr z, BattleTransition_Circle_Sub3
ld c, a
.loop2
- ld a, [wTrainerEngageDistance]
+ ld a, [wBattleTransitionCircleScreenQuadrantX]
and a
jr z, .skip4
dec hl
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index 1acef280..a00e9d59 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -104,10 +104,10 @@ PrintSendOutMonMessage: ; 58e59 (16:4e59)
ld [H_MULTIPLICAND], a
ld hl, wEnemyMonHP
ld a, [hli]
- ld [wcce3], a
+ ld [wLastSwitchInEnemyMonHP], a
ld [H_MULTIPLICAND + 1], a
ld a, [hl]
- ld [wcce4], a
+ ld [wLastSwitchInEnemyMonHP + 1], a
ld [H_MULTIPLICAND + 2], a
ld a, 25
ld [H_MULTIPLIER], a
@@ -120,7 +120,7 @@ PrintSendOutMonMessage: ; 58e59 (16:4e59)
srl a
rr b
ld a, b
- ld b, $4
+ ld b, 4
ld [H_DIVISOR], a ; enemy mon max HP divided by 4
call Divide
ld a, [H_QUOTIENT + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
@@ -174,19 +174,19 @@ PlayerMon2Text: ; 58ed7 (16:4ed7)
push de
push bc
ld hl, wEnemyMonHP + 1
- ld de, wcce4
+ ld de, wLastSwitchInEnemyMonHP + 1
ld b, [hl]
dec hl
ld a, [de]
sub b
- ld [$ff98], a
+ ld [H_MULTIPLICAND + 2], a
dec de
ld b, [hl]
ld a, [de]
sbc b
- ld [$ff97], a
- ld a, $19
- ld [H_POWEROFTEN], a
+ ld [H_MULTIPLICAND + 1], a
+ ld a, 25
+ ld [H_MULTIPLIER], a
call Multiply
ld hl, wEnemyMonMaxHP
ld a, [hli]
@@ -196,22 +196,27 @@ PlayerMon2Text: ; 58ed7 (16:4ed7)
srl a
rr b
ld a, b
- ld b, $4
- ld [H_POWEROFTEN], a
+ ld b, 4
+ ld [H_DIVISOR], a
call Divide
pop bc
pop de
- ld a, [$ff98]
- ld hl, EnoughText
+ ld a, [H_QUOTIENT + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
+; Assuming that the enemy mon hasn't gained HP since the last switch in,
+; a approximates the percentage that the enemy mon's total HP has decreased
+; since the last switch in.
+; If the enemy mon has gained HP, then a is garbage due to wrap-around and
+; can fall in any of the ranges below.
+ ld hl, EnoughText ; HP stayed the same
and a
ret z
- ld hl, ComeBackText
- cp $1e
+ ld hl, ComeBackText ; HP went down 1% - 29%
+ cp 30
ret c
- ld hl, OKExclamationText
- cp $46
+ ld hl, OKExclamationText ; HP went down 30% - 69%
+ cp 70
ret c
- ld hl, GoodText
+ ld hl, GoodText ; HP went down 70% or more
ret
EnoughText: ; 58f25 (16:4f25)
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index cd9be561..335108f7 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -175,7 +175,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $31
- ld [$ffe1], a
+ ld [hStartTileID], a
coord hl, 1, 5
predef CopyUncompressedPicToTilemap
xor a
@@ -225,7 +225,7 @@ StartBattle: ; 3c11e (f:411e)
ld [wPartyFoughtCurrentEnemyFlags], a
ld [wActionResultOrTookBattleTurn], a
inc a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld hl, wEnemyMon1HP
ld bc, wEnemyMon2 - wEnemyMon1 - 1
ld d, $3
@@ -357,7 +357,7 @@ EnemyRan: ; 3c202 (f:4202)
call PlaySoundWaitForCurrent
xor a
ld [H_WHOSETURN], a
- jpab AnimationSlideEnemyMonOut
+ jpab AnimationSlideEnemyMonOff
WildRanText: ; 3c229 (f:4229)
TX_FAR _WildRanText
@@ -379,7 +379,7 @@ MainInBattleLoop: ; 3c233 (f:4233)
jp z, HandleEnemyMonFainted ; if enemy mon HP is 0, jump
call SaveScreenTilesToBuffer1
xor a
- ld [wd11d], a
+ ld [wFirstMonsNotOutYet], a
ld a, [W_PLAYERBATTSTATUS2]
and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
@@ -1429,12 +1429,12 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
call LoadEnemyMonData
ld hl,wEnemyMonHP
ld a,[hli]
- ld [wcce3],a
+ ld [wLastSwitchInEnemyMonHP],a
ld a,[hl]
- ld [wcce4],a
+ ld [wLastSwitchInEnemyMonHP + 1],a
ld a,1
ld [wCurrentMenuItem],a
- ld a,[wd11d]
+ ld a,[wFirstMonsNotOutYet]
dec a
jr z,.next4
ld a,[wPartyCount]
@@ -1497,8 +1497,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
call GetMonHeader
ld de,vFrontPic
call LoadMonFrontSprite
- ld a,$CF
- ld [$FFE1],a
+ ld a,-$31
+ ld [hStartTileID],a
coord hl, 15, 6
predef AnimateSendingOutMon
ld a,[wEnemyMonSpecies2]
@@ -1549,7 +1549,7 @@ HasMonFainted: ; 3ca97 (f:4a97)
ld a, [hli]
or [hl]
ret nz
- ld a, [wd11d]
+ ld a, [wFirstMonsNotOutYet]
and a
jr nz, .done
ld hl, NoWillText
@@ -1647,8 +1647,8 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
ld hl, NoRunningText
.printCantEscapeOrNoRunningText
call PrintText
- ld a, $1
- ld [wd11f], a
+ ld a, 1
+ ld [wForcePlayerToChooseMon], a
call SaveScreenTilesToBuffer1
and a ; reset carry
ret
@@ -1802,7 +1802,7 @@ SendOutMon: ; 3cc91 (f:4c91)
call DrawPlayerHUDAndHPBar
predef LoadMonBackPic
xor a
- ld [$ffe1], a
+ ld [hStartTileID], a
ld hl, wBattleAndStartSavedMenuItem
ld [hli], a
ld [hl], a
@@ -1839,23 +1839,23 @@ SendOutMon: ; 3cc91 (f:4c91)
; show 2 stages of the player mon getting smaller before disappearing
AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa)
coord hl, 1, 5
- ld bc, $707
+ lb bc, 7, 7
call ClearScreenArea
coord hl, 3, 7
- ld bc, $505
+ lb bc, 5, 5
xor a
ld [wDownscaledMonSize], a
- ld [H_DOWNARROWBLINKCNT1], a
+ ld [hBaseTileID], a
predef CopyDownscaledMonTiles
ld c, 4
call DelayFrames
call .clearScreenArea
coord hl, 4, 9
- ld bc, $303
- ld a, $1
+ lb bc, 3, 3
+ ld a, 1
ld [wDownscaledMonSize], a
xor a
- ld [H_DOWNARROWBLINKCNT1], a
+ ld [hBaseTileID], a
predef CopyDownscaledMonTiles
call Delay3
call .clearScreenArea
@@ -1863,7 +1863,7 @@ AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa)
Coorda 5, 11
.clearScreenArea
coord hl, 1, 5
- ld bc, $707
+ lb bc, 7, 7
jp ClearScreenArea
; reads player's current mon's HP into wBattleMonHP
@@ -2310,7 +2310,7 @@ UseBagItem:
call GetItemName
call CopyStringToCF4B ; copy name
xor a
- ld [wd152], a
+ ld [wPseudoItemID], a
call UseItem
call LoadHudTilePatterns
call ClearSprites
@@ -2334,7 +2334,7 @@ UseBagItem:
res UsingTrappingMove, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
- ld a, [wd11c]
+ ld a, [wCapturedMonSpecies]
and a ; was the enemy mon captured with a ball?
jr nz, .returnAfterCapturingMon
@@ -2354,7 +2354,7 @@ UseBagItem:
.returnAfterCapturingMon
call GBPalNormal
xor a
- ld [wd11c], a
+ ld [wCapturedMonSpecies], a
ld a, $2
ld [wBattleResult], a
scf ; set carry
@@ -2516,8 +2516,8 @@ BattleMenu_RunWasSelected: ; 3d1fa (f:51fa)
ld hl, wBattleMonSpeed
ld de, wEnemyMonSpeed
call TryRunningFromBattle
- ld a, $0
- ld [wd11f], a
+ ld a, 0
+ ld [wForcePlayerToChooseMon], a
ret c
ld a, [wActionResultOrTookBattleTurn]
and a
@@ -3035,18 +3035,18 @@ SelectEnemyMove: ; 3d564 (f:5564)
push hl
call BattleRandom
ld b, $1
- cp $3f ; select move 1 in [0,3e] (63/256 chance)
+ cp $3f ; select move 1, [0,3e] (63/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $7f ; select move 1 in [3f,7e] (64/256 chance)
+ cp $7f ; select move 2, [3f,7e] (64/256 chance)
jr c, .moveChosen
inc hl
inc b
- cp $be ; select move 1 in [7f,bd] (63/256 chance)
+ cp $be ; select move 3, [7f,bd] (63/256 chance)
jr c, .moveChosen
inc hl
- inc b ; select move 4 in [be,ff] (66/256 chance)
+ inc b ; select move 4, [be,ff] (66/256 chance)
.moveChosen
ld a, b
dec a
@@ -6449,7 +6449,7 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92)
xor a
ld [$0], a
ld a, $31
- ld [$ffe1], a
+ ld [hStartTileID], a
coord hl, 1, 5
predef_jump CopyUncompressedPicToTilemap
@@ -6862,7 +6862,7 @@ InitBattleCommon: ; 3ef3d (f:6f3d)
call _LoadTrainerPic
xor a
ld [wEnemyMonSpecies2], a
- ld [$ffe1], a
+ ld [hStartTileID], a
dec a
ld [wAICount], a
coord hl, 12, 0
@@ -6918,7 +6918,7 @@ InitWildBattle: ; 3ef8b (f:6f8b)
.spriteLoaded
xor a
ld [W_TRAINERCLASS], a
- ld [$ffe1], a
+ ld [hStartTileID], a
coord hl, 12, 0
predef CopyUncompressedPicToTilemap
@@ -6995,38 +6995,38 @@ AnimateSendingOutMon: ; 3f073 (f:7073)
ld h, a
ld a, [wPredefRegisters + 1]
ld l, a
- ld a, [$ffe1]
- ld [H_DOWNARROWBLINKCNT1], a
+ ld a, [hStartTileID]
+ ld [hBaseTileID], a
ld b, $4c
ld a, [W_ISINBATTLE]
and a
- jr z, .asm_3f0bc
+ jr z, .notInBattle
add b
ld [hl], a
call Delay3
- ld bc, -41
+ ld bc, -(SCREEN_WIDTH * 2 + 1)
add hl, bc
- ld a, $1
+ ld a, 1
ld [wDownscaledMonSize], a
- ld bc, $303
+ lb bc, 3, 3
predef CopyDownscaledMonTiles
ld c, 4
call DelayFrames
- ld bc, -41
+ ld bc, -(SCREEN_WIDTH * 2 + 1)
add hl, bc
xor a
ld [wDownscaledMonSize], a
- ld bc, $505
+ lb bc, 5, 5
predef CopyDownscaledMonTiles
ld c, 5
call DelayFrames
- ld bc, -41
- jr .asm_3f0bf
-.asm_3f0bc
- ld bc, -123
-.asm_3f0bf
+ ld bc, -(SCREEN_WIDTH * 2 + 1)
+ jr .next
+.notInBattle
+ ld bc, -(SCREEN_WIDTH * 6 + 3)
+.next
add hl, bc
- ld a, [H_DOWNARROWBLINKCNT1]
+ ld a, [hBaseTileID]
add $31
jr CopyUncompressedPicToHL
@@ -7035,52 +7035,52 @@ CopyUncompressedPicToTilemap: ; 3f0c6 (f:70c6)
ld h, a
ld a, [wPredefRegisters + 1]
ld l, a
- ld a, [$ffe1]
+ ld a, [hStartTileID]
CopyUncompressedPicToHL: ; 3f0d0 (f:70d0)
- ld bc, $707
+ lb bc, 7, 7
ld de, SCREEN_WIDTH
push af
ld a, [W_SPRITEFLIPPED]
and a
- jr nz, .asm_3f0ed
+ jr nz, .flipped
pop af
-.asm_3f0de
+.loop
push bc
push hl
-.asm_3f0e0
+.innerLoop
ld [hl], a
add hl, de
inc a
dec c
- jr nz, .asm_3f0e0
+ jr nz, .innerLoop
pop hl
inc hl
pop bc
dec b
- jr nz, .asm_3f0de
+ jr nz, .loop
ret
-.asm_3f0ed
+.flipped
push bc
- ld b, $0
+ ld b, 0
dec c
add hl, bc
pop bc
pop af
-.asm_3f0f4
+.flippedLoop
push bc
push hl
-.asm_3f0f6
+.flippedInnerLoop
ld [hl], a
add hl, de
inc a
dec c
- jr nz, .asm_3f0f6
+ jr nz, .flippedInnerLoop
pop hl
dec hl
pop bc
dec b
- jr nz, .asm_3f0f4
+ jr nz, .flippedLoop
ret
LoadMonBackPic: ; 3f103 (f:7103)
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 021ff1b1..1e229b1c 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -6,7 +6,7 @@ DrawAllPokeballs: ; 3a849 (e:6849)
ret z ; return if wild pokémon
jp SetupEnemyPartyPokeballs
-DrawEnemyPokeballs: ; 0x3a857
+DrawEnemyPokeballs: ; 3a857 (e:6857)
call LoadPartyPokeballGfx
jp SetupEnemyPartyPokeballs
@@ -25,8 +25,8 @@ SetupOwnPartyPokeballs: ; 3a869 (e:6869)
ld hl, W_BASECOORDX
ld [hli], a
ld [hl], a
- ld a, $8
- ld [wTrainerEngageDistance], a
+ ld a, 8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
jp WritePokeballOAMData
@@ -39,8 +39,8 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887)
ld a, $48
ld [hli], a
ld [hl], $20
- ld a, $f8
- ld [wTrainerEngageDistance], a
+ ld a, -8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer + PARTY_LENGTH * 4
jp WritePokeballOAMData
@@ -90,8 +90,8 @@ PickPokeball: ; 3a8c2 (e:68c2)
.done
ld a, b
ld [de], a
- ld bc, wPartyMon2 - wPartyMon1 - 4 ; rest of mon struct
- add hl, bc
+ ld bc, wPartyMon2 - wPartyMon1Status
+ add hl, bc ; next mon struct
ret
WritePokeballOAMData: ; 3a8e1 (e:68e1)
@@ -108,7 +108,7 @@ WritePokeballOAMData: ; 3a8e1 (e:68e1)
ld [hli], a
ld a, [W_BASECOORDX]
ld b, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wHUDPokeballGfxOffsetX]
add b
ld [W_BASECOORDX], a
inc de
@@ -118,11 +118,11 @@ WritePokeballOAMData: ; 3a8e1 (e:68e1)
PlacePlayerHUDTiles: ; 3a902 (e:6902)
ld hl, PlayerBattleHUDGraphicsTiles
- ld de, wTrainerFacingDirection
+ ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 18, 10
- ld de, rIE
+ ld de, -1
jr PlaceHUDTiles
PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916)
@@ -133,7 +133,7 @@ PlayerBattleHUDGraphicsTiles: ; 3a916 (e:6916)
PlaceEnemyHUDTiles: ; 3a919 (e:6919)
ld hl, EnemyBattleHUDGraphicsTiles
- ld de, wTrainerFacingDirection
+ ld de, wHUDGraphicsTiles
ld bc, $3
call CopyData
coord hl, 1, 2
@@ -150,16 +150,16 @@ PlaceHUDTiles: ; 3a930 (e:6930)
ld [hl], $73
ld bc, SCREEN_WIDTH
add hl, bc
- ld a, [wTrainerScreenY]
+ ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
ld [hl], a
- ld a, $8
-.asm_3a93c
+ ld a, 8
+.loop
add hl, de
ld [hl], $76
dec a
- jr nz, .asm_3a93c
+ jr nz, .loop
add hl, de
- ld a, [wTrainerScreenX]
+ ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
ld [hl], a
ret
@@ -172,8 +172,8 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948)
ld a, $50
ld [hli], a
ld [hl], $40
- ld a, $8
- ld [wTrainerEngageDistance], a
+ ld a, 8
+ ld [wHUDPokeballGfxOffsetX], a
ld hl, wOAMBuffer
call WritePokeballOAMData
ld hl, wEnemyMons
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index 8264e49c..c642d206 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -51,7 +51,7 @@ EndOfBattle: ; 137aa (4:77aa)
ld [W_BATTLETYPE], a
ld [W_MOVEMISSED], a
ld [W_CUROPPONENT], a
- ld [wd11f], a
+ ld [wForcePlayerToChooseMon], a
ld [wNumRunAttempts], a
ld [wEscapedFromBattle], a
ld hl, wPartyAndBillsPCSavedMenuItem
diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm
index e3b3f42c..96e65f70 100644
--- a/engine/battle/ghost_marowak_anim.asm
+++ b/engine/battle/ghost_marowak_anim.asm
@@ -12,10 +12,10 @@ MarowakAnim: ; 708ca (1c:48ca)
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
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 4f72aea1..0976c7c7 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -154,7 +154,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld b,a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
- ld hl,wd047
+ ld hl,wTrainerBaseMoney + 1
ld c,2 ; wAmountMoneyWon is a 3-byte number
push bc
predef AddBCDPredef
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index c803a870..fb932035 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -2,7 +2,7 @@
; unused slots are filled with 0, all used slots may be chosen with equal probability
AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld a, $a
- ld hl, wHPBarMaxHP ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
+ ld hl, wBuffer ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
ld [hli], a ; move 1
ld [hli], a ; move 2
ld [hli], a ; move 3
@@ -11,14 +11,14 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
swap a
and $f
jr z, .noMoveDisabled
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
dec a
ld c, a
ld b, $0
add hl, bc ; advance pointer to forbidden move
ld [hl], $50 ; forbid (highly discourage) disabled move
.noMoveDisabled
- ld hl, TrainerClassMoveChoiceModifications ; 589B
+ ld hl, TrainerClassMoveChoiceModifications
ld a, [W_TRAINERCLASS]
ld b, a
.loopTrainerClasses
@@ -44,7 +44,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
dec a
add a
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc ; skip to pointer
ld a, [hli] ; read pointer into hl
ld h, [hl]
@@ -53,9 +53,9 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
push de
jp [hl] ; execute modification function
.loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero
- ld hl, wHPBarMaxHP ; temp move selection array
+ ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
- ld c, $4
+ ld c, NUM_MOVES
.loopDecrementEntries
ld a, [de]
inc de
@@ -73,11 +73,11 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
inc [hl]
dec hl
inc a
- cp $5
+ cp NUM_MOVES + 1
jr nz, .loopUndoPartialIteration
- ld hl, wHPBarMaxHP ; temp move selection array
+ ld hl, wBuffer ; temp move selection array
ld de, wEnemyMonMoves ; enemy moves
- ld c, $4
+ ld c, NUM_MOVES
.filterMinimalEntries ; all minimal entries now have value 1. All other slots will be disabled (move set to 0)
ld a, [de]
and a
@@ -97,7 +97,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
inc de
dec c
jr nz, .filterMinimalEntries
- ld hl, wHPBarMaxHP ; use created temporary array as move set
+ ld hl, wBuffer ; use created temporary array as move set
ret
.useOriginalMoveSet
ld hl, wEnemyMonMoves ; use original move set
@@ -694,11 +694,13 @@ SwitchEnemyMon: ; 3a74b (e:674b)
ld hl, AIBattleWithdrawText
call PrintText
+ ; This wFirstMonsNotOutYet variable is abused to prevent the player from
+ ; switching in a new mon in response to this switch.
ld a,1
- ld [wd11d],a
+ ld [wFirstMonsNotOutYet],a
callab EnemySendOut
xor a
- ld [wd11d],a
+ ld [wFirstMonsNotOutYet],a
ld a,[wLinkState]
cp LINK_STATE_BATTLING
diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm
index 5964f996..144234bb 100644
--- a/engine/battle/wild_encounters.asm
+++ b/engine/battle/wild_encounters.asm
@@ -18,11 +18,11 @@ TryDoWildEncounter: ; 13870 (4:7870)
jr z, .CantEncounter
ld a, [wRepelRemainingSteps]
and a
- jr z, .asm_1389e
+ jr z, .next
dec a
jr z, .lastRepelStep
ld [wRepelRemainingSteps], a
-.asm_1389e
+.next
; determine if wild pokemon can appear in the half-block we're standing in
; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile?
coord hl, 9, 9
@@ -71,7 +71,7 @@ TryDoWildEncounter: ; 13870 (4:7870)
; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not,
; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters.
.gotWildEncounterType
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hli]
ld [W_CURENEMYLVL], a
@@ -89,8 +89,8 @@ TryDoWildEncounter: ; 13870 (4:7870)
jr .willEncounter
.lastRepelStep
ld [wRepelRemainingSteps], a
- ld a, 210
- ld [H_DOWNARROWBLINKCNT2], a
+ ld a, TEXT_REPEL_WORE_OFF
+ ld [hSpriteIndexOrTextID], a
call EnableAutoTextBoxDrawing
call DisplayTextID
.CantEncounter2
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 585ee6ac..137b75e0 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -14,7 +14,7 @@ EvolutionAfterBattle: ; 3ad1c (e:6d1c)
ld a, [hTilesetType]
push af
xor a
- ld [wd121], a
+ ld [wEvolutionOccurred], a
dec a
ld [wWhichPokemon], a
push hl
@@ -91,7 +91,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [wLoadedMonLevel]
cp b ; is the mon's level greater than the evolution requirement?
jp c, Evolution_PartyMonLoop ; if so, go the next mon
- jr .asm_3adb6
+ jr .doEvolution
.checkItemEvo
ld a, [hli]
ld b, a ; evolution item
@@ -104,10 +104,10 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [wLoadedMonLevel]
cp b ; is the mon's level greater than the evolution requirement?
jp c, .nextEvoEntry2 ; if so, go the next evolution entry
-.asm_3adb6
+.doEvolution
ld [W_CURENEMYLVL], a
- ld a, $1
- ld [wd121], a
+ ld a, 1
+ ld [wEvolutionOccurred], a
push hl
ld a, [hl]
ld [wEvoNewSpecies], a
@@ -252,7 +252,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [W_ISINBATTLE]
and a
ret nz
- ld a, [wd121]
+ ld a, [wEvolutionOccurred]
and a
call nz, PlayDefaultMusic
ret
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index 01787e3e..aad8c468 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -71,7 +71,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9)
ld de, vChars1 + $310
call LoadMonFrontSprite
ld a, $80
- ld [$ffe1], a
+ ld [hStartTileID], a
coord hl, 10, 11
predef AnimateSendingOutMon
call WaitForTextScrollButtonPress
@@ -311,7 +311,7 @@ VermilionGymTrashText: ; 5ddf7 (17:5df7)
GymTrashScript: ; 5ddfc (17:5dfc)
call EnableAutoTextBoxDrawing
ld a, [wHiddenObjectFunctionArgument]
- ld [wcd5b], a
+ ld [wGymTrashCanIndex], a
; Don't do the trash can puzzle if it's already been done.
CheckEvent EVENT_2ND_LOCK_OPENED
@@ -320,12 +320,12 @@ GymTrashScript: ; 5ddfc (17:5dfc)
tx_pre_jump VermilionGymTrashText
.ok
- bit 1, a
+ CheckEventReuseA EVENT_1ST_LOCK_OPENED
jr nz, .trySecondLock
- ld a, [wd743]
+ ld a, [wFirstLockTrashCanIndex]
ld b, a
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
cp b
jr z, .openFirstLock
@@ -337,7 +337,7 @@ GymTrashScript: ; 5ddfc (17:5dfc)
SetEvent EVENT_1ST_LOCK_OPENED
ld hl, GymTrashCans
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
; * 5
ld b, a
add a
@@ -349,12 +349,21 @@ GymTrashScript: ; 5ddfc (17:5dfc)
add hl, de
ld a, [hli]
- ld [$ffdb], a
+; There is a bug in this code. It should calculate a value in the range [0, 3]
+; but if the mask and random number don't have any 1 bits in common, then
+; the result of the AND will be 0. When 1 is subtracted from that, the value
+; will become $ff. This will result in 255 being added to hl, which will cause
+; hl to point to one of the zero bytes that pad the end of the ROM bank.
+; Trash can 0 was intended to be able to have the second lock only when the
+; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can
+; have the second lock regardless of which trash can had the first lock.
+
+ ld [hGymTrashCanRandNumMask], a
push hl
call Random
swap a
ld b, a
- ld a, [$ffdb]
+ ld a, [hGymTrashCanRandNumMask]
and b
dec a
pop hl
@@ -364,15 +373,15 @@ GymTrashScript: ; 5ddfc (17:5dfc)
add hl, de
ld a, [hl]
and $f
- ld [wd744], a
+ ld [wSecondLockTrashCanIndex], a
tx_pre_id VermilionGymTrashSuccesText1
jr .done
.trySecondLock
- ld a, [wd744]
+ ld a, [wSecondLockTrashCanIndex]
ld b, a
- ld a, [wcd5b]
+ ld a, [wGymTrashCanIndex]
cp b
jr z, .openSecondLock
@@ -381,7 +390,7 @@ GymTrashScript: ; 5ddfc (17:5dfc)
call Random
and $e
- ld [wd743], a
+ ld [wFirstLockTrashCanIndex], a
tx_pre_id VermilionGymTrashFailText
jr .done
@@ -398,6 +407,12 @@ GymTrashScript: ; 5ddfc (17:5dfc)
jp PrintPredefTextID
GymTrashCans: ; 5de7d (17:5e7d)
+; byte 0: mask for random number
+; bytes 1-4: indices of the trash cans that can have the second lock
+; (but see the comment above explaining a bug regarding this)
+; Note that the mask is simply the number of valid trash can indices that
+; follow. The remaining bytes are filled with 0 to pad the length of each entry
+; to 5 bytes.
db 2, 1, 3, 0, 0 ; 0
db 3, 0, 2, 4, 0 ; 1
db 2, 1, 5, 0, 0 ; 2
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 00744c5d..0a93fd44 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -19,7 +19,7 @@ GymStatues: ; 62419 (18:6419)
jr .loop
.match
ld b, [hl]
- ld a, [wd72a]
+ ld a, [wBeatGymFlags]
and b
cp b
tx_pre_id GymStatueText2
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index 6f1eef61..e3c296ca 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -73,19 +73,19 @@ SafariZoneGameOver: ; 1e9b0 (7:69b0)
ld a, [wc02a]
cp $b9
jr nz, .asm_1e9c2
- ld a, $d3
- ld [H_DOWNARROWBLINKCNT2], a
+ ld a, TEXT_SAFARI_GAME_OVER
+ ld [hSpriteIndexOrTextID], a
call DisplayTextID
xor a
ld [wPlayerMovingDirection], a
ld a, SAFARI_ZONE_ENTRANCE
- ld [H_DOWNARROWBLINKCNT1], a
+ ld [hWarpDestinationMap], a
ld a, $3
ld [wDestinationWarpID], a
ld a, $5
ld [W_SAFARIZONEENTRANCECURSCRIPT], a
SetEvent EVENT_SAFARI_GAME_OVER
- ld a, $1
+ ld a, 1
ld [wSafariZoneGameOver], a
ret
@@ -125,21 +125,21 @@ PrintCinnabarQuiz: ; 1ea17 (7:6a17)
CinnabarGymQuiz: ; 1ea25 (7:6a25)
TX_ASM
xor a
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ld a, [wHiddenObjectFunctionArgument]
push af
and $f
- ld [$ffdb], a
+ ld [hGymGateIndex], a
pop af
and $f0
swap a
ld [$ffdc], a
ld hl, CinnabarGymQuizIntroText
call PrintText
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
dec a
add a
- ld d, $0
+ ld d, 0
ld e, a
ld hl, CinnabarQuizQuestions
add hl, de
@@ -198,10 +198,10 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld c, a
ld a, [wCurrentMenuItem]
cp c
- jr nz, .asm_1eab8
+ jr nz, .wrongAnswer
ld hl, wd126
set 5, [hl]
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
ld [$ffe0], a
ld hl, CinnabarGymQuizCorrectText
call PrintText
@@ -211,14 +211,14 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld b, FLAG_SET
call CinnabarGymGateFlagAction
jp UpdateCinnabarGymGateTileBlocks_
-.asm_1eab8
+.wrongAnswer
call WaitForSoundToFinish
ld a, SFX_DENIED
call PlaySound
call WaitForSoundToFinish
ld hl, CinnabarGymQuizIncorrectText
call PrintText
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
add $2
AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2
ld c, a
@@ -228,9 +228,9 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld a, c
and a
ret nz
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
add $2
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ret
CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3)
@@ -261,9 +261,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
; Update the overworld map with open floor blocks or locked gate blocks
; depending on event flags.
ld a, 6
- ld [$ffdb], a
+ ld [hGymGateIndex], a
.loop
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
dec a
add a
add a
@@ -276,9 +276,9 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
ld c, a
inc hl
ld a, [hl]
- ld [wd12f], a
+ ld [wGymGateTileBlock], a
push bc
- ld a, [$ffdb]
+ ld a, [hGymGateIndex]
ld [$ffe0], a
AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0
ld c, a
@@ -287,15 +287,15 @@ UpdateCinnabarGymGateTileBlocks_: ; 1eb0a (7:6b0a)
ld a, c
and a
jr nz, .unlocked
- ld a, [wd12f]
+ ld a, [wGymGateTileBlock]
jr .next
.unlocked
ld a, $e
.next
pop bc
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
- ld hl, $ffdb
+ ld hl, hGymGateIndex
dec [hl]
jr nz, .loop
ret
diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm
index 61209778..d1367b4e 100755
--- a/engine/hp_bar.asm
+++ b/engine/hp_bar.asm
@@ -205,20 +205,21 @@ UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5)
push de
ld a, [wHPBarType]
and a
- jr z, .asm_fb2d
+ jr z, .done ; don't print number in enemy HUD
+; convert from little-endian to big-endian for PrintNumber
ld a, [wHPBarOldHP]
- ld [wcef1], a
- ld a, [wHPBarOldHP+1]
- ld [wcef0], a
+ ld [wHPBarTempHP + 1], a
+ ld a, [wHPBarOldHP + 1]
+ ld [wHPBarTempHP], a
push hl
ld a, [hFlags_0xFFF6]
bit 0, a
jr z, .asm_fb15
ld de, $9
- jr .asm_fb18
+ jr .next
.asm_fb15
ld de, $15
-.asm_fb18
+.next
add hl, de
push hl
ld a, $7f
@@ -226,12 +227,12 @@ UpdateHPBar_PrintHPNumber: ; faf5 (3:7af5)
ld [hli], a
ld [hli], a
pop hl
- ld de, wcef0
+ ld de, wHPBarTempHP
ld bc, $203
call PrintNumber
call DelayFrame
pop hl
-.asm_fb2d
+.done
pop de
pop af
ret
diff --git a/engine/intro.asm b/engine/intro.asm
index 6b5c46c9..c7c4a04d 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -38,7 +38,7 @@ PlayIntroScene: ; 4169d (10:569d)
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 @@ PlayIntroScene: ; 4169d (10:569d)
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 @@ PlayIntroScene: ; 4169d (10:569d)
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 @@ PlayIntroScene: ; 4169d (10:569d)
ret c
ld a, $24
- ld [wd09f], a
+ ld [wIntroNidorinoBaseTile], a
ld de, IntroNidorinoAnimation6
call AnimateIntroNidorino
ld c, $1e
@@ -129,7 +129,7 @@ PlayIntroScene: ; 4169d (10:569d)
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 @@ AnimateIntroNidorino: ; 41793 (10:5793)
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
diff --git a/engine/items/items.asm b/engine/items/items.asm
index bda922e8..953f953a 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -118,7 +118,7 @@ ItemUseBall: ; d687 (3:5687)
.UseBall
;ok, you can use a ball
xor a
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld a,[W_BATTLETYPE]
cp a,2 ;SafariBattle
jr nz,.skipSafariZoneCode
@@ -319,7 +319,7 @@ ItemUseBall: ; d687 (3:5687)
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]
@@ -388,7 +388,7 @@ ItemUseBall: ; d687 (3:5687)
pop af
ld [hl],a
ld a,[wEnemyMonSpecies] ;enemy
- ld [wd11c],a
+ ld [wCapturedMonSpecies],a
ld [wcf91],a
ld [wd11e],a
ld a,[W_BATTLETYPE]
@@ -628,7 +628,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
- ld [wd156],a
+ ld [wEvoStoneItemID],a
push af
ld a,EVO_STONE_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
@@ -645,7 +645,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
callab TryEvolvingMon ; try to evolve pokemon
- ld a,[wd121]
+ ld a,[wEvolutionOccurred]
and a
jr z,.noEffect
pop af
@@ -679,7 +679,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wPartyMenuTypeOrMessageID],a
ld a,$ff
ld [wUpdateSpritesEnabled],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
; if using softboiled
@@ -712,7 +712,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr z,.checkItemType
; if using softboiled
@@ -865,7 +865,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wHPBarMaxHP+1],a
ld a,[hl]
ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian)
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jp z,.notUsingSoftboiled2
; if using softboiled
@@ -1052,7 +1052,7 @@ ItemUseMedicine: ; dabb (3:5abb)
call ItemUseNoEffect
jp .done
.doneHealing
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
jr nz,.skipRemovingItem ; no item to remove if using Softboiled
push hl
@@ -1107,7 +1107,7 @@ ItemUseMedicine: ; dabb (3:5abb)
pop af
pop af
.done
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
@@ -1381,7 +1381,7 @@ ItemUseEscapeRope: ; dfaf (3:5faf)
inc a
ld [wEscapedFromBattle],a
ld [wActionResultOrTookBattleTurn],a ; item used
- ld a,[wd152]
+ ld a,[wPseudoItemID]
and a ; using Dig?
ret nz ; if so, return
call ItemUseReloadOverworldData
@@ -1419,7 +1419,7 @@ ItemUseXAccuracy: ; e013 (3:6013)
; The Card Key is handled in a different way.
ItemUseCardKey: ; e022 (3:6022)
xor a
- ld [wd71f],a
+ ld [wUnusedD71F],a
call GetTileAndCoordsInFrontOfPlayer
ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
cp a,$18
@@ -1451,7 +1451,7 @@ ItemUseCardKey: ; e022 (3:6022)
cp e
jr nz,.nextEntry3
ld a,[hl]
- ld [wd71f],a
+ ld [wUnusedD71F],a
jr .done
.nextEntry1
inc hl
@@ -2537,13 +2537,13 @@ IsKeyItem_: ; e764 (3:6764)
; if the item is not an HM or TM
push af
ld hl,KeyItemBitfield
- ld de,wHPBarMaxHP
+ ld de,wBuffer
ld bc,15 ; only 11 bytes are actually used
call CopyData
pop af
dec a
ld c,a
- ld hl,wHPBarMaxHP
+ ld hl,wBuffer
ld b,FLAG_TEST
predef FlagActionPredef
ld a,c
diff --git a/engine/learn_move.asm b/engine/learn_move.asm
index 95a7984e..66d27a40 100755
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -46,10 +46,10 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
ld hl, Moves
ld bc, $6
call AddNTimes
- ld de, wHPBarMaxHP
+ ld de, wBuffer
ld a, BANK(Moves)
call FarCopyData
- ld a, [wHPBarNewHP + 1]
+ ld a, [wBuffer + 5] ; a = move's max PP
pop de
pop hl
ld [hl], a
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 3ed2f443..994841d3 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -278,7 +278,7 @@ LinkMenu: ; 5c0a (1:5c0a)
ld [wSerialExchangeNybbleSendData], a
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
- ld [wcc47], a
+ ld [wEnteringCableClub], a
jr SpecialEnterMap
.choseCancel
xor a
@@ -322,7 +322,7 @@ SpecialEnterMap: ; 5d5f (1:5d5f)
call ResetPlayerSpriteData
ld c, 20
call DelayFrames
- ld a, [wcc47]
+ ld a, [wEnteringCableClub]
and a
ret nz
jp EnterMap
@@ -455,7 +455,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
ld [wLastMenuItem],a
inc a
ld [wLetterPrintingDelayFlags],a
- ld [wTrainerScreenY],a
+ ld [wUnusedCD40],a
ld a,3 ; text speed cursor Y coordinate
ld [wTopMenuItemY],a
call SetCursorPositionsFromOptions
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index 6037329e..20745c58 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -54,7 +54,7 @@ DoYouWantToNicknameText: ; 0x6557
db "@"
DisplayNameRaterScreen: ; 655c (1:655c)
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
xor a
ld [wUpdateSpritesEnabled], a
ld a, NAME_MON_SCREEN
@@ -72,7 +72,7 @@ DisplayNameRaterScreen: ; 655c (1:655c)
call AddNTimes
ld e, l
ld d, h
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
ld bc, 11
call CopyData
and a
@@ -94,24 +94,24 @@ DisplayNamingScreen: ; 6596 (1:6596)
call LoadEDTile
callba LoadMonPartySpriteGfx
coord hl, 0, 4
- ld b, $9
- ld c, $12
+ ld b, 9
+ ld c, 18
call TextBoxBorder
call PrintNamingText
- ld a, $3
+ ld a, 3
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
ld [wLastMenuItem], a
ld [wCurrentMenuItem], a
ld a, $ff
ld [wMenuWatchedKeys], a
- ld a, $7
+ ld a, 7
ld [wMaxMenuItem], a
ld a, $50
ld [wcf4b], a
xor a
- ld hl, wHPBarMaxHP + 1
+ ld hl, wNamingScreenSubmitName
ld [hli], a
ld [hli], a
ld [wAnimCounter], a
@@ -119,7 +119,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
call PrintAlphabet
call GBPalNormal
.ABStartReturnPoint
- ld a, [wHPBarMaxHP + 1]
+ ld a, [wNamingScreenSubmitName]
and a
jr nz, .submitNickname
call PrintNicknameAndUnderscores
@@ -197,14 +197,14 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld de, .selectReturnPoint
push de
.pressedSelect
- ld a, [wHPBarOldHP]
+ ld a, [wAlphabetCase]
xor $1
- ld [wHPBarOldHP], a
+ ld [wAlphabetCase], a
ret
.pressedStart
- ld a, $1
- ld [wHPBarMaxHP + 1], a
+ ld a, 1
+ ld [wNamingScreenSubmitName], a
ret
.pressedA
@@ -216,7 +216,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
jr z, .pressedStart
.didNotPressED
ld a, [wCurrentMenuItem]
- cp $6 ; case swtich row
+ cp $6 ; case switch row
jr nz, .didNotPressCaseSwtich
ld a, [wTopMenuItemX]
cp $1 ; case switch column
@@ -228,9 +228,9 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld l, a
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
call CalcStringLength
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
cp $e5
ld de, Dakutens
jr z, .dakutensAndHandakutens
@@ -240,11 +240,11 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
jr nc, .checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $7 ; max length of player/rival names
jr .checkNameLength
.checkMonNameLength
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
cp $a ; max length of pokemon nicknames
.checkNameLength
jr c, .addLetter
@@ -257,14 +257,14 @@ DisplayNamingScreen: ; 6596 (1:6596)
ret nc
dec hl
.addLetter
- ld a, [wHPBarNewHP]
+ ld a, [wNamingScreenLetter]
ld [hli], a
ld [hl], $50
ld a, SFX_PRESS_AB
call PlaySound
ret
.pressedB
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
and a
ret z
call CalcStringLength
@@ -335,7 +335,7 @@ ED_Tile: ; 6767 (1:6767)
PrintAlphabet: ; 676f (1:676f)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
- ld a, [wHPBarOldHP]
+ ld a, [wAlphabetCase]
and a
ld de, LowerCaseAlphabet
jr nz, .lowercase
@@ -371,7 +371,7 @@ UpperCaseAlphabet: ; 67d6 (1:67d6)
PrintNicknameAndUnderscores: ; 680e (1:680e)
call CalcStringLength
ld a, c
- ld [wHPBarMaxHP], a
+ ld [wNamingScreenNameLength], a
coord hl, 10, 2
ld bc, $10a
call ClearScreenArea
@@ -394,7 +394,7 @@ PrintNicknameAndUnderscores: ; 680e (1:680e)
jr nz, .placeUnderscoreLoop
ld a, [wNamingScreenType]
cp NAME_MON_SCREEN
- ld a, [wHPBarMaxHP]
+ ld a, [wNamingScreenNameLength]
jr nc, .pokemon2
cp 7 ; player or rival max name length
jr .playerOrRival2
@@ -433,7 +433,7 @@ DakutensAndHandakutens: ; 6871 (1:6871)
ret nc
inc hl
ld a, [hl]
- ld [wHPBarNewHP], a
+ ld [wNamingScreenLetter], a
ret
Dakutens: ; 6885 (1:6885)
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 00ae3912..42ab553a 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -167,7 +167,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
dec hl
dec hl
ld b,[hl]
- ld a,[wd156] ; evolution stone item ID
+ ld a,[wEvoStoneItemID] ; the stone the player used
inc hl
inc hl
inc hl
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index a804abb2..78b35b95 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -114,13 +114,13 @@ AccessedMyPCText: ; 17f32 (5:7f32)
TX_FAR _AccessedMyPCText
db "@"
-; removes one of the specified item ID [$FFdb] from bag (if existent)
+; removes one of the specified item ID [hItemToRemoveID] from bag (if existent)
RemoveItemByID: ; 17f37 (5:7f37)
ld hl, wBagItems
- ld a, [$ffdb]
+ ld a, [hItemToRemoveID]
ld b, a
xor a
- ld [$ffdc], a
+ ld [hItemToRemoveIndex], a
.asm_17f40
ld a, [hli]
cp $ff
@@ -128,14 +128,14 @@ RemoveItemByID: ; 17f37 (5:7f37)
cp b
jr z, .asm_17f4f
inc hl
- ld a, [$ffdc]
+ ld a, [hItemToRemoveIndex]
inc a
- ld [$ffdc], a
+ ld [hItemToRemoveIndex], a
jr .asm_17f40
.asm_17f4f
ld a, $1
ld [wItemQuantity], a
- ld a, [$ffdc]
+ ld a, [hItemToRemoveIndex]
ld [wWhichPokemon], a
ld hl, wNumBagItems
jp RemoveItemFromInventory
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index f2f2a794..2bf932ba 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -65,11 +65,11 @@ GetPrizeMenuId: ; 5278e (14:678e)
; (distinguishing between Pokemon names
; and Items (specifically TMs) names)
ld a,[hSpriteIndexOrTextID]
- sub a,$03 ; prize-texts' id are 3, 4 and 5
- ld [wd12f],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
+ sub a,3 ; prize-texts' id are 3, 4 and 5
+ ld [wWhichPrizeWindow],a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a
add a
- ld d,$00
+ ld d,0
ld e,a
ld hl,PrizeDifferentMenuPtrs
add hl,de
@@ -84,10 +84,10 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld a,[hli]
ld h,[hl]
ld l,a
- ld de,wd141
- ld bc,$0006
+ ld de,wPrize1Price
+ ld bc,6
call CopyData
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ;is TM_menu?
jr nz,.putMonName
ld a,[W_PRIZE1]
@@ -127,7 +127,7 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld de,NoThanksText
call PlaceString
; put prices on the right side of the textbox
- ld de,wd141
+ ld de,wPrize1Price
coord hl, 13, 5
; reg. c:
; [low nybble] number of bytes
@@ -136,11 +136,11 @@ GetPrizeMenuId: ; 5278e (14:678e)
; Function $15CD displays BCD value (same routine
; used by text-command $02)
call PrintBCDNumber
- ld de,wd143
+ ld de,wPrize2Price
coord hl, 13, 7
ld c,(%1 << 7 | 2)
call PrintBCDNumber
- ld de,wd145
+ ld de,wPrize3Price
coord hl, 13, 9
ld c,(1 << 7 | 2)
jp PrintBCDNumber
@@ -172,11 +172,11 @@ PrintPrizePrice: ; 5287a (14:687a)
db " @"
LoadCoinsToSubtract: ; 528b1 (14:68b1)
- ld a,[wd139] ; backup of selected menu_entry
+ ld a,[wWhichPrize]
add a
- ld d,$00
+ ld d,0
ld e,a
- ld hl,wd141 ; first prize's price
+ ld hl,wPrize1Price
add hl,de ; get selected prize's price
xor a
ld [hUnusedCoinsByte],a
@@ -187,15 +187,15 @@ LoadCoinsToSubtract: ; 528b1 (14:68b1)
ret
HandlePrizeChoice: ; 528c6 (14:68c6)
- ld a,[wCurrentMenuItem] ; selected menu_entry
- ld [wd139],a
- ld d,$00
+ ld a,[wCurrentMenuItem]
+ ld [wWhichPrize],a
+ ld d,0
ld e,a
ld hl,W_PRIZE1
add hl,de
ld a,[hl]
ld [wd11e],a
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02 ; is prize a TM?
jr nz,.GetMonName
call GetItemName
@@ -205,14 +205,14 @@ HandlePrizeChoice: ; 528c6 (14:68c6)
.GivePrize
ld hl,SoYouWantPrizeTextPtr
call PrintText
- call YesNoChoice ; yes/no textbox
+ call YesNoChoice
ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a
jr nz,.PrintOhFineThen
call LoadCoinsToSubtract
call HasEnoughCoins
jr c,.NotEnoughCoins
- ld a,[wd12f]
+ ld a,[wWhichPrizeWindow]
cp a,$02
jr nz,.GiveMon
ld a,[wd11e]
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index 481c0fbe..0895258c 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -167,7 +167,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
jp z,.loop
ld a,SURFBOARD
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
@@ -195,7 +195,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
.dig
ld a,ESCAPE_ROPE
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
@@ -260,7 +260,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
push af
ld a,POTION
ld [wcf91],a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
pop af
ld [wPartyAndBillsPCSavedMenuItem],a
@@ -381,8 +381,8 @@ StartMenu_Item: ; 13302 (4:7302)
ld a,[wCurrentMenuItem]
and a
jr nz,.tossItem
-.useItem
- ld [wd152],a
+; use item
+ ld [wPseudoItemID],a ; a must be 0 due to above conditional jump
ld a,[wcf91]
cp a,HM_01
jr nc,.useItem_partyMenu
@@ -399,7 +399,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp ItemMenuLoop
.useItem_closeMenu
xor a
- ld [wd152],a
+ ld [wPseudoItemID],a
call UseItem
ld a,[wActionResultOrTookBattleTurn]
and a
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index be84b99d..5b6c29e1 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -229,5 +229,5 @@ IntroDisplayPicCenteredOrUpperRight: ; 62a4 (1:62a4)
coord hl, 6, 4
.next
xor a
- ld [$FFE1],a
+ ld [hStartTileID],a
predef_jump CopyUncompressedPicToTilemap
diff --git a/engine/overworld/cable_club_npc.asm b/engine/overworld/cable_club_npc.asm
index 65837150..a2feba06 100755
--- a/engine/overworld/cable_club_npc.asm
+++ b/engine/overworld/cable_club_npc.asm
@@ -8,7 +8,7 @@ CableClubNPC: ; 71c5 (1:71c5)
call DelayFrames
ld hl, CableClubNPCMakingPreparationsText
call PrintText
- jp Func_7298
+ jp .didNotConnect
.receivedPokedex
ld a, $1
ld [wMenuJoypadPollCount], a
@@ -71,31 +71,29 @@ CableClubNPC: ; 71c5 (1:71c5)
ld hl, wUnknownSerialCounter
ld a, [hli]
inc a
- jr nz, Func_72a8
+ jr nz, .connected
ld a, [hl]
inc a
- jr nz, Func_72a8
- ld b, $a
-.asm_7273
+ jr nz, .connected
+ ld b, 10
+.syncLoop
call DelayFrame
call Serial_SendZeroByte
dec b
- jr nz, .asm_7273
+ jr nz, .syncLoop
call CloseLinkConnection
ld hl, CableClubNPCLinkClosedBecauseOfInactivityText
call PrintText
- jr Func_7298
+ jr .didNotConnect
.failedToEstablishConnection
ld hl, CableClubNPCAreaReservedFor2FriendsLinkedByCableText
call PrintText
- jr Func_7298
+ jr .didNotConnect
.choseNo
call CloseLinkConnection
ld hl, CableClubNPCPleaseComeAgainText
call PrintText
- ; fall through
-
-Func_7298: ; 7298 (1:7298)
+.didNotConnect
xor a
ld hl, wUnknownSerialCounter
ld [hli], a
@@ -105,8 +103,7 @@ Func_7298: ; 7298 (1:7298)
xor a
ld [wMenuJoypadPollCount], a
ret
-
-Func_72a8: ; 72a8 (1:72a8)
+.connected
xor a
ld [hld], a
ld [hl], a
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index 746ea326..cc9fe3a7 100755
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -28,7 +28,7 @@ PrintCardKeyText: ; 52673 (14:6673)
call GetCoordsInFrontOfPlayer
push de
tx_pre_id CardKeySuccessText
- ld [H_DOWNARROWBLINKCNT2], a
+ ld [hSpriteIndexOrTextID], a
call PrintPredefTextID
pop de
srl d
@@ -47,7 +47,7 @@ PrintCardKeyText: ; 52673 (14:6673)
.notSilphCo11F
ld a, $e
.replaceCardKeyDoorTileBlock
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
ld hl, wd126
set 5, [hl]
@@ -55,7 +55,7 @@ PrintCardKeyText: ; 52673 (14:6673)
jp PlaySound
.noCardKey
tx_pre_id CardKeyFailText
- ld [H_DOWNARROWBLINKCNT2], a
+ ld [hSpriteIndexOrTextID], a
jp PrintPredefTextID
SilphCoMapList: ; 526e3 (14:66e3)
diff --git a/engine/overworld/cinnabar_lab.asm b/engine/overworld/cinnabar_lab.asm
index 1b96b4c6..5337255c 100755
--- a/engine/overworld/cinnabar_lab.asm
+++ b/engine/overworld/cinnabar_lab.asm
@@ -3,19 +3,19 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
set 6, [hl]
xor a
ld [wCurrentMenuItem], a
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, [wcd37]
dec a
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
ld a, [wcd37]
dec a
- ld bc, $2
- ld hl, $3
+ ld bc, 2
+ ld hl, 3
call AddNTimes
dec l
ld b, l
@@ -23,12 +23,12 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
coord hl, 0, 0
call TextBoxBorder
call UpdateSprites
- call Func_610c2
+ call PrintFossilsInBag
ld hl, wd730
res 6, [hl]
call HandleMenuInput
- bit 1, a
- jr nz, .asm_610a7
+ bit 1, a ; pressed B?
+ jr nz, .cancelledGivingFossil
ld hl, wcc5b
ld a, [wCurrentMenuItem]
ld d, $0
@@ -57,17 +57,17 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_610a7
+ jr nz, .cancelledGivingFossil
ld hl, LabFossil_610b3
call PrintText
ld a, [W_FOSSILITEM]
- ld [$ffdb], a
+ ld [hItemToRemoveID], a
callba RemoveItemByID
ld hl, LabFossil_610b8
call PrintText
SetEvents EVENT_GAVE_FOSSIL_TO_LAB, EVENT_LAB_STILL_REVIVING_FOSSIL
ret
-.asm_610a7
+.cancelledGivingFossil
ld hl, LabFossil_610bd
call PrintText
ret
@@ -88,11 +88,12 @@ LabFossil_610bd: ; 610bd (18:50bd)
TX_FAR _Lab4Text_610bd
db "@"
-Func_610c2: ; 610c2 (18:50c2)
+PrintFossilsInBag: ; 610c2 (18:50c2)
+; Prints each fossil in the player's bag on a separate line in the menu.
ld hl, wcc5b
xor a
- ld [$ffdb], a
-.asm_610c8
+ ld [hFossilCounter], a
+.loop
ld a, [hli]
cp $ff
ret z
@@ -100,15 +101,15 @@ Func_610c2: ; 610c2 (18:50c2)
ld [wd11e], a
call GetItemName
coord hl, 2, 2
- ld a, [$ffdb]
+ ld a, [hFossilCounter]
ld bc, SCREEN_WIDTH * 2
call AddNTimes
ld de, wcd6d
call PlaceString
- ld hl, $ffdb
+ ld hl, hFossilCounter
inc [hl]
pop hl
- jr .asm_610c8
+ jr .loop
; loads the names of the fossil item and the resulting mon
LoadFossilItemAndMonName: ; 610eb (18:50eb)
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index 293daee7..2056bbb0 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -3,21 +3,21 @@ UsedCut: ; ef54 (3:6f54)
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 @@ UsedCut: ; ef54 (3:6f54)
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 @@ UsedCut: ; ef54 (3:6f54)
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 @@ UsedCut: ; ef54 (3:6f54)
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,14 +71,15 @@ UsedCutText: ; eff2 (3:6ff2)
TX_FAR _UsedCutText
db "@"
-AnimateCutTree: ; eff7 (3:6ff7)
+InitCutAnimOAM: ; eff7 (3:6ff7)
xor a
ld [wWhichAnimationOffsets], a
ld a, $e4
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 @@ AnimateCutTree: ; eff7 (3:6ff7)
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 @@ GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068)
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 @@ GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068)
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,75 +172,79 @@ BoulderDustAnimationOffsets: ; f097 (3:7097)
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
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
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
diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm
index 3194b39b..1cf832b5 100755
--- 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 @@ Func_79e96: ; 79e96 (1e:5e96)
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,19 +71,19 @@ Func_79eed: ; 79eed (1e:5eed)
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
ld de, wOAMBuffer + $90
ld bc, $8
call CopyData
- ld hl, wHPBarMaxHP
+ ld hl, wBuffer
ld de, wOAMBuffer + $98
ld bc, $8
jp CopyData
diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm
index fc69afc1..1203dd2a 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -29,7 +29,7 @@ FoundHiddenItemText: ; 7675b (1d:675b)
call GiveItem
jr nc, .BagFull
ld hl, wObtainedHiddenItemsFlags
- ld a, [wTrainerScreenX]
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, FLAG_SET
predef FlagActionPredef
@@ -100,7 +100,7 @@ HiddenCoins: ; 76799 (1d:6799)
ld c, $2
predef AddBCDPredef
ld hl, wObtainedHiddenCoinsFlags
- ld a, [wTrainerScreenX]
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, FLAG_SET
predef FlagActionPredef
diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm
index eb6d743a..6fbe823d 100644
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -31,7 +31,7 @@ PickUpItem:
jr nc, .BagFull
ld a, [$ffdb]
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index fcef55e0..0c01e38c 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -149,7 +149,7 @@ PalletMovementScript_Done: ; 1a4f4 (6:64f4)
and a
ret nz
ld a, $0
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd730
res 7, [hl]
@@ -178,7 +178,7 @@ PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
dec a
ld [wSimulatedJoypadStatesIndex], a
xor a
- ld [wd12f], a
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterMuseumGuy
@@ -234,8 +234,8 @@ PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
- ld a, $1
- ld [wd12f], a
+ ld a, 1
+ ld [wWhichPewterGuy], a
predef PewterGuys
ld hl, wNPCMovementDirections2
ld de, RLEList_PewterGymGuy
diff --git a/engine/overworld/pewter_guys.asm b/engine/overworld/pewter_guys.asm
index fa0dd4a7..4ac60e00 100755
--- a/engine/overworld/pewter_guys.asm
+++ b/engine/overworld/pewter_guys.asm
@@ -9,7 +9,7 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld d, h
ld e, l
ld hl, PointerTable_37ce6
- ld a, [wd12f]
+ ld a, [wWhichPewterGuy]
add a
ld b, 0
ld c, a
@@ -21,17 +21,17 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld b, a
ld a, [W_XCOORD]
ld c, a
-.asm_37cc7
+.findMatchingCoordsLoop
ld a, [hli]
cp b
- jr nz, .asm_37ce1
+ jr nz, .nextEntry1
ld a, [hli]
cp c
- jr nz, .asm_37ce2
+ jr nz, .nextEntry2
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_37cd2
+.copyMovementDataLoop
ld a, [hli]
cp $ff
ret z
@@ -40,13 +40,13 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld a, [wSimulatedJoypadStatesIndex]
inc a
ld [wSimulatedJoypadStatesIndex], a
- jr .asm_37cd2
-.asm_37ce1
+ jr .copyMovementDataLoop
+.nextEntry1
inc hl
-.asm_37ce2
+.nextEntry2
inc hl
inc hl
- jr .asm_37cc7
+ jr .findMatchingCoordsLoop
PointerTable_37ce6: ; 37ce6 (d:7ce6)
dw PewterMuseumGuyCoords
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index a9aa2cf2..1a3d374f 100755
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -370,10 +370,10 @@ IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
ld b, [hl]
.done
ld a, b
- ld [wcd5b], a
+ ld [wStandingOnWarpPadOrHole], a
ret
-; format: db tileset id, tile id, value to be put in wcd5b
+; format: db tileset id, tile id, value to be put in [wStandingOnWarpPadOrHole]
.warpPadAndHoleData: ; 707a9 (1c:47a9)
db FACILITY, $20, 1 ; warp pad
db FACILITY, $11, 2 ; hole
diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm
index a59ae794..8c5485e2 100755
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -8,14 +8,14 @@ AnimateBoulderDust: ; 79f54 (1e:5f54)
ld a, %11100100
ld [rOBP1], a
call LoadSmokeTileFourTimes
- callba WriteCutTreeBoulderDustAnimationOAMBlock
+ callba WriteCutOrBoulderDustAnimationOAMBlock
ld c, 8 ; number of steps in animation
.loop
push bc
call GetMoveBoulderDustFunctionPointer
ld bc, .returnAddress
push bc
- ld c, $4
+ ld c, 4
jp [hl]
.returnAddress
ld a, [rOBP1]
@@ -36,7 +36,7 @@ GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92)
ld b, $0
add hl, bc
ld a, [hli]
- ld [wd08a], a
+ ld [wCoordAdjustmentAmount], a
ld a, [hli]
ld e, a
ld a, [hli]
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index 2b08997b..7d2ec0dd 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -24,16 +24,16 @@ _GetSpritePosition2: ; 56819 (15:6819)
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
- ld [wd130], a
+ ld [wSavedSpriteScreenY], a
inc hl
ld a, [hl] ; c1x6 (screen X pos)
- ld [wd131], a
+ ld [wSavedSpriteScreenX], a
ld de, $104 - $6
add hl, de
ld a, [hli] ; c2x4 (map Y pos)
- ld [wd132], a
+ ld [wSavedSpriteMapY], a
ld a, [hl] ; c2x5 (map X pos)
- ld [wd133], a
+ ld [wSavedSpriteMapX], a
ret
_SetSpritePosition1: ; 5683d (15:683d)
@@ -61,16 +61,16 @@ _SetSpritePosition2: ; 5685d (15:685d)
ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
- ld a, [wd130]
+ ld a, [wSavedSpriteScreenY]
ld [hli], a
inc hl
- ld a, [wd131]
+ ld a, [wSavedSpriteScreenX]
ld [hl], a
ld de, $00fe
add hl, de
- ld a, [wd132]
+ ld a, [wSavedSpriteMapY]
ld [hli], a
- ld a, [wd133]
+ ld a, [wSavedSpriteMapX]
ld [hl], a
ret
@@ -256,7 +256,7 @@ ReadTrainerScreenPosition: ; 5698e (15:698e)
; a: distance player to sprite
CheckSpriteCanSeePlayer: ; 569af (15:69af)
ld b, a
- ld a, [wTrainerEngageDistance] ; sprite line of sight (engage distance)
+ ld a, [wTrainerEngageDistance] ; how far the trainer can see
cp b
jr nc, .checkIfLinedUp
jr .notInLine ; player too far away
diff --git a/engine/predefs.asm b/engine/predefs.asm
index 73a22ad9..d8cf030c 100755
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -149,5 +149,5 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef LoadMovePPs
add_predef DrawHP ; 5F
add_predef DrawHP2
- add_predef Func_1c9c6
+ add_predef DisplayElevatorFloorMenu
add_predef OaksAideScript
diff --git a/engine/predefs7.asm b/engine/predefs7.asm
index af013733..bf31772c 100755
--- a/engine/predefs7.asm
+++ b/engine/predefs7.asm
@@ -1,4 +1,4 @@
-Func_1c9c6: ; 1c9c6 (7:49c6)
+DisplayElevatorFloorMenu: ; 1c9c6 (7:49c6)
ld hl, WhichFloorText
call PrintText
ld hl, wItemList
@@ -12,7 +12,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6)
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld [wPrintItemPrices], a
- ld a, $4
+ ld a, SPECIALLISTMENU
ld [wListMenuID], a
call DisplayListMenuID
pop bc
@@ -24,7 +24,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6)
ld hl, wcc5b
ld a, [wWhichPokemon]
add a
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hli]
@@ -32,15 +32,15 @@ Func_1c9c6: ; 1c9c6 (7:49c6)
ld a, [hl]
ld c, a
ld hl, wWarpEntries
- call Func_1ca0d
+ call .UpdateWarp
-Func_1ca0d: ; 1ca0d (7:4a0d)
+.UpdateWarp
inc hl
inc hl
ld a, b
- ld [hli], a
+ ld [hli], a ; destination warp ID
ld a, c
- ld [hli], a
+ ld [hli], a ; destination map ID
ret
WhichFloorText: ; 1ca14 (7:4a14)
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index 990687ff..8e98f662 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -711,12 +711,12 @@ SlotMachine_PayCoinsToPlayer: ; 3776b (d:776b)
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 @@ SlotMachine_UpdateOneCoinBallTiles: ; 377fb (d:77fb)
coord hl, 3, 6
SlotMachine_UpdateBallTiles: ; 377fe (d:77fe)
- ld a, [wd08a]
+ ld a, [wNewSlotMachineBallTile]
ld [hl], a
ld bc, 13
add hl, bc
diff --git a/engine/town_map.asm b/engine/town_map.asm
index a90aa331..f5a047c3 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -487,24 +487,24 @@ WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
; the X-flip OAM bit to be used so that only 2 rather than 4 tile patterns are
; needed.
xor a
- ld [wcd5c], a
- ld de, $202
+ ld [wSymmetricSpriteOAMAttributes], a
+ lb de, 2, 2
.loop
push de
push bc
.innerLoop
ld a, b
- ld [hli], a
+ ld [hli], a ; Y
ld a, c
- ld [hli], a
+ ld [hli], a ; X
ld a, [wOAMBaseTile]
- ld [hli], a
- ld a, [wcd5c]
- ld [hli], a
- xor $20
- ld [wcd5c], a
+ ld [hli], a ; tile
+ ld a, [wSymmetricSpriteOAMAttributes]
+ ld [hli], a ; attributes
+ xor (1 << OAM_X_FLIP)
+ ld [wSymmetricSpriteOAMAttributes], a
inc d
- ld a, $8
+ ld a, 8
add c
ld c, a
dec e
@@ -516,7 +516,7 @@ WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
inc [hl]
inc [hl]
pop hl
- ld a, $8
+ ld a, 8
add b
ld b, a
dec d
diff --git a/engine/trade.asm b/engine/trade.asm
index ba8de4ff..74fd3434 100755
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -304,25 +304,25 @@ Trade_AnimateBallEnteringLinkCable: ; 412d2 (10:52d2)
ld a, %11100100
ld [rOBP0], a
xor a
- ld [wd09f], a
+ ld [wLinkCableAnimBulgeToggle], a
ld bc, $2060
.moveBallInsideLinkCableLoop
push bc
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
diff --git a/home.asm b/home.asm
index 2024f0de..6f52f914 100644
--- a/home.asm
+++ b/home.asm
@@ -301,7 +301,7 @@ LoadFrontSpriteByMonIndex:: ; 1389 (0:1389)
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
xor a
- ld [$ffe1], a
+ ld [hStartTileID], a
call CopyUncompressedPicToHL
xor a
ld [W_SPRITEFLIPPED], a
@@ -394,13 +394,13 @@ PartyMenuInit:: ; 1420 (0:1420)
; otherwise, it is 0
.storeMaxMenuItemID
ld [hli], a ; max menu item ID
- ld a, [wd11f]
+ ld a, [wForcePlayerToChooseMon]
and a
- ld a, A_BUTTON + B_BUTTON
+ ld a, A_BUTTON | B_BUTTON
jr z, .next
xor a
- ld [wd11f], a
- inc a
+ ld [wForcePlayerToChooseMon], a
+ inc a ; a = A_BUTTON
.next
ld [hli], a ; menu watched keys
pop af
@@ -411,12 +411,12 @@ HandlePartyMenuInput:: ; 145a (0:145a)
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
@@ -1071,13 +1071,13 @@ DisplayTextID:: ; 2920 (0:2920)
ld [wSpriteIndex],a
and a
jp z,DisplayStartMenu
- cp a,$d3
+ cp a,TEXT_SAFARI_GAME_OVER
jp z,DisplaySafariGameOverText
- cp a,$d0
+ cp a,TEXT_MON_FAINTED
jp z,DisplayPokemonFaintedText
- cp a,$d1
+ cp a,TEXT_BLACKED_OUT
jp z,DisplayPlayerBlackedOutText
- cp a,$d2
+ cp a,TEXT_REPEL_WORE_OFF
jp z,DisplayRepelWoreOffText
ld a,[W_NUMSPRITES]
ld e,a
@@ -1144,7 +1144,7 @@ DisplayTextID:: ; 2920 (0:2920)
jr nz,HoldTextDisplayOpen
AfterDisplayingTextID:: ; 29d6 (0:29d6)
- ld a,[wcc47]
+ ld a,[wEnteringCableClub]
and a
jr nz,HoldTextDisplayOpen
call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text
@@ -2403,7 +2403,7 @@ EndTrainerBattle:: ; 3275 (0:3275)
call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
- ld [wcc4d], a ; load corresponding missable object index and remove it
+ ld [wMissableObjectIndex], a ; load corresponding missable object index and remove it
predef HideObject
.skipRemoveSprite
ld hl, wd730
@@ -2825,7 +2825,7 @@ DecodeRLEList:: ; 350c (0:350c)
ld a, [de]
cp $ff
jr z, .endOfList
- ld [H_DOWNARROWBLINKCNT1], a ; store byte value to be written
+ ld [hRLEByteValue], a ; store byte value to be written
inc de
ld a, [de]
ld b, $0
@@ -2833,7 +2833,7 @@ DecodeRLEList:: ; 350c (0:350c)
ld a, [wRLEByteCount]
add c
ld [wRLEByteCount], a ; update total number of written bytes
- ld a, [H_DOWNARROWBLINKCNT1]
+ ld a, [hRLEByteValue]
call FillMemory ; write a c-times to output
inc de
jr .listLoop
@@ -2905,7 +2905,7 @@ GetTrainerInformation:: ; 3566 (0:3566)
inc de
ld a, [hli]
ld [de], a
- ld de, wd046
+ ld de, wTrainerBaseMoney
ld a, [hli]
ld [de], a
inc de
@@ -3897,16 +3897,16 @@ WriteOAMBlock:: ; 3a97 (0:3a97)
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]
push af ; save existing values on stack
xor a
ld [H_DOWNARROWBLINKCNT1],a ; blinking down arrow timing value 1
- ld a,$06
+ ld a,6
ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2
.loop1
xor a
@@ -3915,7 +3915,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
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
@@ -3944,7 +3944,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
ret
.keyPressed
xor a
- ld [wcc4b],a
+ ld [wCheckFor180DegreeTurn],a
ld a,[hJoy5]
ld b,a
bit 6,a ; pressed Up key?
@@ -4162,7 +4162,7 @@ HandleDownArrowBlinkTiming:: ; 3c04 (0:3c04)
; The following code either enables or disables the automatic drawing of
; text boxes by DisplayTextID. Both functions cause DisplayTextID to wait
-; for a button press after displaying text (unless [wcc47] is set).
+; for a button press after displaying text (unless [wEnteringCableClub] is set).
EnableAutoTextBoxDrawing:: ; 3c3c (0:3c3c)
xor a
@@ -4631,7 +4631,7 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
ret
PrintPredefTextID:: ; 3ef5 (0:3ef5)
- ld [H_DOWNARROWBLINKCNT2], a
+ ld [hSpriteIndexOrTextID], a
ld hl, TextPredefs
call SetMapTextPointer
ld hl, wTextPredefFlag
diff --git a/home/overworld.asm b/home/overworld.asm
index 9b60d7e9..3675eca8 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -106,13 +106,14 @@ OverworldLoopLessDelay::
aCoord 8, 9
ld [wTilePlayerStandingOn],a ; unused?
call DisplayTextID ; display either the start menu or the NPC/sign text
- ld a,[wcc47]
+ ld a,[wEnteringCableClub]
and a
jr z,.checkForOpponent
dec a
- ld a,$00
- ld [wcc47],a
+ ld a,0
+ ld [wEnteringCableClub],a
jr z,.changeMap
+; XXX can this code be reached?
predef LoadSAV
ld a,[W_CURMAP]
ld [wDestinationMap],a
@@ -132,8 +133,8 @@ OverworldLoopLessDelay::
ld hl,wFlags_0xcd60
res 2,[hl]
call UpdateSprites
- ld a,$01
- ld [wcc4b],a
+ ld a,1
+ ld [wCheckFor180DegreeTurn],a
ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
and a
jp z,OverworldLoop
@@ -174,7 +175,7 @@ OverworldLoopLessDelay::
ld a,[wd730]
bit 7,a ; are we simulating button presses?
jr nz,.noDirectionChange ; ignore direction changes if we are
- ld a,[wcc4b]
+ ld a,[wCheckFor180DegreeTurn]
and a
jr z,.noDirectionChange
ld a,[wPlayerDirection] ; new direction
@@ -182,39 +183,44 @@ OverworldLoopLessDelay::
ld a,[wPlayerLastStopDirection] ; old direction
cp b
jr z,.noDirectionChange
-; the code below is strange
-; it computes whether or not the player did a 180 degree turn, but then overwrites the result
-; also, it does a seemingly pointless loop afterwards
+; Check whether the player did a 180-degree turn.
+; It appears that this code was supposed to show the player rotate by having
+; the player's sprite face an intermediate direction before facing the opposite
+; direction (instead of doing an instantaneous about-face), but the intermediate
+; direction is only set for a short period of time. It is unlikely for it to
+; ever be visible because DelayFrame is called at the start of OverworldLoop and
+; normally not enough cycles would be executed between then and the time the
+; direction is set for V-blank to occur while the direction is still set.
swap a ; put old direction in upper half
or b ; put new direction in lower half
cp a,(PLAYER_DIR_DOWN << 4) | PLAYER_DIR_UP ; change dir from down to up
jr nz,.notDownToUp
ld a,PLAYER_DIR_LEFT
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notDownToUp
cp a,(PLAYER_DIR_UP << 4) | PLAYER_DIR_DOWN ; change dir from up to down
jr nz,.notUpToDown
ld a,PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notUpToDown
cp a,(PLAYER_DIR_RIGHT << 4) | PLAYER_DIR_LEFT ; change dir from right to left
jr nz,.notRightToLeft
ld a,PLAYER_DIR_DOWN
ld [wPlayerMovingDirection],a
- jr .oddLoop
+ jr .holdIntermediateDirectionLoop
.notRightToLeft
cp a,(PLAYER_DIR_LEFT << 4) | PLAYER_DIR_RIGHT ; change dir from left to right
- jr nz,.oddLoop
+ jr nz,.holdIntermediateDirectionLoop
ld a,PLAYER_DIR_UP
ld [wPlayerMovingDirection],a
-.oddLoop
+.holdIntermediateDirectionLoop
ld hl,wFlags_0xcd60
set 2,[hl]
- ld hl,wcc4b
+ ld hl,wCheckFor180DegreeTurn
dec [hl]
- jr nz,.oddLoop
+ jr nz,.holdIntermediateDirectionLoop
ld a,[wPlayerDirection]
ld [wPlayerMovingDirection],a
call NewBattle
@@ -465,16 +471,16 @@ WarpFound1:: ; 0735 (0:0735)
WarpFound2:: ; 073c (0:073c)
ld a,[wNumberOfWarps]
sub c
- ld [wd73b],a ; save ID of used warp
+ ld [wWarpedFromWhichWarp],a ; save ID of used warp
ld a,[W_CURMAP]
- ld [wd73c],a
+ ld [wWarpedFromWhichMap],a
call CheckIfInOutsideMap
jr nz,.indoorMaps
; this is for handling "outside" maps that can't have the 0xFF destination map
ld a,[W_CURMAP]
ld [wLastMap],a
ld a,[W_CURMAPWIDTH]
- ld [wd366],a
+ ld [wUnusedD366],a ; not read
ld a,[hWarpDestinationMap]
ld [W_CURMAP],a
cp a,ROCK_TUNNEL_1
@@ -493,7 +499,7 @@ WarpFound2:: ; 073c (0:073c)
; if not going back to the previous map
ld [W_CURMAP],a
callba IsPlayerStandingOnWarpPadOrHole
- ld a,[wcd5b]
+ ld a,[wStandingOnWarpPadOrHole]
dec a ; is the player on a warp pad?
jr nz,.notWarpPad
; if the player is on a warp pad
@@ -2007,7 +2013,7 @@ LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063)
LoadMapHeader:: ; 107c (0:107c)
callba MarkTownVisitedAndLoadMissableObjects
ld a,[W_CURMAPTILESET]
- ld [wd119],a
+ ld [wUnusedD119],a
ld a,[W_CURMAP]
call SwitchToMapRomBank
ld a,[W_CURMAPTILESET]
@@ -2305,7 +2311,7 @@ LoadMapData:: ; 1241 (0:1241)
ld [hSCY],a
ld [hSCX],a
ld [wWalkCounter],a
- ld [wd119],a
+ ld [wUnusedD119],a
ld [wWalkBikeSurfStateCopy],a
ld [W_SPRITESETID],a
call LoadTextBoxTilePatterns
diff --git a/home/text.asm b/home/text.asm
index d57fc03f..366dfd73 100644
--- a/home/text.asm
+++ b/home/text.asm
@@ -376,9 +376,9 @@ TextCommandProcessor:: ; 1b40 (0:1b40)
xor e
ld [wLetterPrintingDelayFlags],a
ld a,c
- ld [wcc3a],a
+ ld [wUnusedCC3A],a
ld a,b
- ld [wcc3b],a
+ ld [wUnusedCC3B],a
NextTextCommand:: ; 1b55 (0:1b55)
ld a,[hli]
@@ -487,10 +487,10 @@ TextCommand02:: ; 1ba5 (0:1ba5)
TextCommand03:: ; 1bb7 (0:1bb7)
pop hl
ld a,[hli]
- ld [wcc3a],a
+ ld [wUnusedCC3A],a
ld c,a
ld a,[hli]
- ld [wcc3b],a
+ ld [wUnusedCC3B],a
ld b,a
jp NextTextCommand
diff --git a/home/vblank.asm b/home/vblank.asm
index 05b01a3d..6abc3756 100644
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -6,7 +6,7 @@ VBlank::
push hl
ld a, [H_LOADEDROMBANK]
- ld [wd122], a
+ ld [wVBlankSavedROMBank], a
ld a, [hSCX]
ld [rSCX], a
@@ -78,7 +78,7 @@ VBlank::
and a
call z, ReadJoypad
- ld a, [wd122]
+ ld a, [wVBlankSavedROMBank]
ld [H_LOADEDROMBANK], a
ld [MBC1RomBank], a
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 8de00e38..02caef29 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -380,21 +380,23 @@ UpdateMovingBgTiles::
and a
ret z ; no animations if indoors (or if a menu set this to 0)
- ld a, [$ffd8]
+ ld a, [hMovingBGTilesCounter1]
inc a
- ld [$ffd8], a
- cp $14
+ ld [hMovingBGTilesCounter1], a
+ cp 20
ret c
- cp $15
+ cp 21
jr z, .flower
+; water
+
ld hl, vTileset + $14 * $10
ld c, $10
- ld a, [wd085]
+ ld a, [wMovingBGTilesCounter2]
inc a
and 7
- ld [wd085], a
+ ld [wMovingBGTilesCounter2], a
and 4
jr nz, .left
@@ -417,14 +419,14 @@ UpdateMovingBgTiles::
ret nc
; if in a cave, no flower animations
xor a
- ld [$ffd8], a
+ ld [hMovingBGTilesCounter1], a
ret
.flower
xor a
- ld [$ffd8], a
+ ld [hMovingBGTilesCounter1], a
- ld a, [wd085]
+ ld a, [wMovingBGTilesCounter2]
and 3
cp 2
ld hl, FlowerTile1
diff --git a/hram.asm b/hram.asm
index 0b7274ad..2b83df76 100644
--- a/hram.asm
+++ b/hram.asm
@@ -4,6 +4,7 @@ hSoftReset EQU $FF8A
; presses the reset sequence (A+B+SEL+START).
; Soft reset when 0 is reached.
+; base tile ID to which offsets are added
hBaseTileID EQU $FF8B
; 3-byte BCD number
@@ -23,6 +24,8 @@ hEastWestConnectedMapWidth EQU $FF8B
hSlideAmount EQU $FF8B
+hRLEByteValue EQU $FF8B
+
H_SPRITEWIDTH EQU $FF8B ; in tiles
H_SPRITEINTERLACECOUNTER EQU $FF8B
H_SPRITEHEIGHT EQU $FF8C ; in tiles
@@ -256,11 +259,25 @@ H_VBLANKOCCURRED EQU $FFD6
; this is often set to 00 in order to turn off water and flower BG tile animations
hTilesetType EQU $FFD7
+hMovingBGTilesCounter1 EQU $FFD8
+
H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10
+hFossilCounter EQU $FFDB
+
+hGymGateIndex EQU $FFDB
+
+hGymTrashCanRandNumMask EQU $FFDB
+
+hItemToRemoveID EQU $FFDB
+hItemToRemoveIndex EQU $FFDC
+
hVendingMachineItem EQU $FFDB
hVendingMachinePrice EQU $FFDC ; 3-byte BCD number
+; the first tile ID in a sequence of tile IDs that increase by 1 each step
+hStartTileID EQU $FFE1
+
hNewPartyLength EQU $FFE4
hDividend2 EQU $FFE5
diff --git a/main.asm b/main.asm
index 64c0a59d..c8cb3b63 100755
--- a/main.asm
+++ b/main.asm
@@ -687,9 +687,9 @@ LoadSpecialWarpData: ; 62ff (1:62ff)
ld a, [wWhichDungeonWarp]
ld c, a
ld hl, DungeonWarpList
- ld de, $0
- ld a, $6
- ld [wd12f], a
+ ld de, 0
+ ld a, 6
+ ld [wDungeonWarpDataEntrySize], a
.dungeonWarpListLoop
ld a, [hli]
cp b
@@ -701,7 +701,7 @@ LoadSpecialWarpData: ; 62ff (1:62ff)
cp c
jr z, .matchedDungeonWarpID
.nextDungeonWarp
- ld a, [wd12f]
+ ld a, [wDungeonWarpDataEntrySize]
add e
ld e, a
jr .dungeonWarpListLoop
@@ -1642,39 +1642,39 @@ DisplayTwoOptionMenu: ; 7559 (1:7559)
; The bottom and right edges of the menu may remain after the function returns.
TwoOptionMenu_SaveScreenTiles: ; 763e (1:763e)
- ld de, wHPBarMaxHP
- ld bc, $506
-.asm_7644
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_7644
+ jr nz, .loop
push bc
- ld bc, 14
+ ld bc, SCREEN_WIDTH - 6
add hl, bc
pop bc
ld c, $6
dec b
- jr nz, .asm_7644
+ jr nz, .loop
ret
TwoOptionMenu_RestoreScreenTiles: ; 7656 (1:7656)
- ld de, wHPBarMaxHP
- ld bc, $506
-.asm_765c
+ ld de, wBuffer
+ lb bc, 5, 6
+.loop
ld a, [de]
inc de
ld [hli], a
dec c
- jr nz, .asm_765c
+ jr nz, .loop
push bc
- ld bc, $e
+ ld bc, SCREEN_WIDTH - 6
add hl, bc
pop bc
- ld c, $6
+ ld c, 6
dec b
- jr nz, .asm_765c
+ jr nz, .loop
call UpdateSprites
ret
@@ -2052,7 +2052,7 @@ INCLUDE "data/map_songs.asm"
INCLUDE "data/map_header_banks.asm"
ClearVariablesAfterLoadingMapData: ; c335 (3:4335)
- ld a, $90
+ ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld [rWY], a
xor a
@@ -2063,7 +2063,7 @@ ClearVariablesAfterLoadingMapData: ; c335 (3:4335)
ld [hJoyReleased], a
ld [hJoyHeld], a
ld [wActionResultOrTookBattleTurn], a
- ld [wd5a3], a
+ ld [wUnusedD5A3], a
ld hl, wCardKeyDoorY
ld [hli], a
ld [hl], a
@@ -3167,9 +3167,9 @@ RedrawMapView: ; eedc (3:6edc)
and $3
or $98
ld a, l
- ld [wHPBarMaxHP], a
+ ld [wBuffer], a
ld a, h
- ld [wHPBarMaxHP + 1], a
+ ld [wBuffer + 1], a ; this copy of the address is not used
ld a, 2
ld [$ffbe], a
ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen)
@@ -3177,25 +3177,25 @@ RedrawMapView: ; eedc (3:6edc)
push bc
push hl
push hl
- ld hl, wTileMap - 2 * 20
- ld de, 20
+ ld hl, wTileMap - 2 * SCREEN_WIDTH
+ ld de, SCREEN_WIDTH
ld a, [$ffbe]
-.asm_ef1a
+.calcWRAMAddrLoop
add hl, de
dec a
- jr nz, .asm_ef1a
+ jr nz, .calcWRAMAddrLoop
call CopyToScreenEdgeTiles
pop hl
ld de, $20
ld a, [$ffbe]
ld c, a
-.asm_ef28
+.calcVRAMAddrLoop
add hl, de
ld a, h
and $3
or $98
dec c
- jr nz, .asm_ef28
+ jr nz, .calcVRAMAddrLoop
ld [H_SCREENEDGEREDRAWADDR + 1], a
ld a, l
ld [H_SCREENEDGEREDRAWADDR], a
@@ -3301,7 +3301,7 @@ InitializeMissableObjectsFlags: ; f175 (3:7175)
call FillMemory ; clear missable objects flags
ld hl, MapHS00
xor a
- ld [wd048], a
+ ld [wMissableObjectCounter], a
.missableObjectsLoop
ld a, [hli]
cp $ff ; end of list
@@ -3310,14 +3310,14 @@ InitializeMissableObjectsFlags: ; f175 (3:7175)
inc hl
ld a, [hl]
cp Hide
- jr nz, .asm_f19d
+ jr nz, .skip
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wd048]
+ ld a, [wMissableObjectCounter]
ld c, a
ld b, FLAG_SET
- call MissableObjectFlagAction ; set flag iff Item is hidden
-.asm_f19d
- ld hl, wd048
+ call MissableObjectFlagAction ; set flag if Item is hidden
+.skip
+ ld hl, wMissableObjectCounter
inc [hl]
pop hl
inc hl
@@ -3351,21 +3351,21 @@ IsObjectHidden: ; f1a6 (3:71a6)
ret
; adds missable object (items, leg. pokemon, etc.) to the map
-; [wcc4d]: index of the missable object to be added (global index)
+; [wMissableObjectIndex]: index of the missable object to be added (global index)
ShowObject: ; f1c8 (3:71c8)
ShowObject2:
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wcc4d]
+ ld a, [wMissableObjectIndex]
ld c, a
ld b, FLAG_RESET
call MissableObjectFlagAction ; reset "removed" flag
jp UpdateSprites
; removes missable object (items, leg. pokemon, etc.) from the map
-; [wcc4d]: index of the missable object to be removed (global index)
+; [wMissableObjectIndex]: index of the missable object to be removed (global index)
HideObject: ; f1d7 (3:71d7)
ld hl, W_MISSABLEOBJECTFLAGS
- ld a, [wcc4d]
+ ld a, [wMissableObjectIndex]
ld c, a
ld b, FLAG_SET
call MissableObjectFlagAction ; set "removed" flag
@@ -3640,8 +3640,8 @@ _AddPartyMon: ; f2e5 (3:72e5)
ld b, FLAG_TEST
ld hl, wPokedexOwned
call FlagAction
- ld a, c
- ld [wd153], a
+ ld a, c ; whether the mon was already flagged as owned
+ ld [wUnusedD153], a ; not read
ld a, [wd11e]
dec a
ld c, a
@@ -4463,7 +4463,7 @@ InitPlayerData2:
ld [wPlayerID + 1], a
ld a, $ff
- ld [wd71b], a ; XXX what's this?
+ ld [wUnusedD71B], a
ld hl, wPartyCount
call InitializeEmptyList
diff --git a/scripts/agatha.asm b/scripts/agatha.asm
index f0607785..60ddf606 100755
--- a/scripts/agatha.asm
+++ b/scripts/agatha.asm
@@ -21,7 +21,7 @@ AgathaScript_76443: ; 76443 (1d:6443)
ld a, $3b
AgathaScript_76459: ; 76459 (1d:6459)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm
index 71e61603..e4cfc031 100755
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -49,7 +49,7 @@ BillsHouseScript2: ; 1e7a6 (7:67a6)
bit 0, a
ret nz
ld a, HS_BILL_POKEMON
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_BILL_SAID_USE_CELL_SEPARATOR
xor a
@@ -75,7 +75,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5)
ld [$ffee], a
call SetSpritePosition1
ld a, HS_BILL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld c, 8
call DelayFrames
@@ -170,10 +170,10 @@ BillsHouseText2: ; 1e874 (7:6874)
call PrintText
SetEvent EVENT_GOT_SS_TICKET
ld a, HS_CERULEAN_GUARD_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_CERULEAN_GUARD_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.asm_1e8a9
ld hl, BillsHouseText_1e8cb
diff --git a/scripts/blueshouse.asm b/scripts/blueshouse.asm
index 12ca9106..0e29d64c 100755
--- a/scripts/blueshouse.asm
+++ b/scripts/blueshouse.asm
@@ -40,7 +40,7 @@ BluesHouseText1: ; 19b5d (6:5b5d)
call GiveItem
jr nc, .BagFull
ld a,HS_TOWN_MAP
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef HideObject ; hide table map object
ld hl,GotMapText
call PrintText
diff --git a/scripts/bruno.asm b/scripts/bruno.asm
index 1aae7d19..c39656b9 100755
--- a/scripts/bruno.asm
+++ b/scripts/bruno.asm
@@ -21,7 +21,7 @@ BrunoScript_762ec: ; 762ec (1d:62ec)
ld a, $24
BrunoScript_76302: ; 76302 (1d:6302)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm
index 48264603..e8917434 100755
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -31,7 +31,7 @@ CeladonGameCornerScript_48bec: ; 48bec (12:4bec)
CheckEvent EVENT_FOUND_ROCKET_HIDEOUT
ret nz
ld a, $2a
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0208
predef_jump ReplaceTileBlock
@@ -107,7 +107,7 @@ CeladonGameCornerScript2: ; 48c69 (12:4c69)
xor a
ld [wJoyIgnore], a
ld a, HS_GAME_CORNER_ROCKET
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, wd126
set 5, [hl]
@@ -451,7 +451,7 @@ CeladonGameCornerText12: ; 48edd (12:4edd)
call WaitForSoundToFinish
SetEvent EVENT_FOUND_ROCKET_HIDEOUT
ld a, $43
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0208
predef ReplaceTileBlock
jp TextScriptEnd
diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm
index 9d761a31..5dc328c7 100755
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -62,7 +62,7 @@ CeladonGymText_48963: ; 48963 (12:4963)
.asm_4898c
ld hl, W_OBTAINEDBADGES
set 3, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 3, [hl]
; deactivate gym trainers
diff --git a/scripts/celadonmansion5.asm b/scripts/celadonmansion5.asm
index f847759b..60d2cc92 100755
--- a/scripts/celadonmansion5.asm
+++ b/scripts/celadonmansion5.asm
@@ -15,7 +15,7 @@ CeladonMansion5Text2: ; 1dd46 (7:5d46)
call GivePokemon
jr nc, .asm_24365
ld a, HS_CELADON_MANSION_5_GIFT
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.asm_24365
jp TextScriptEnd
diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm
index c8ff1a6d..53f1f434 100755
--- a/scripts/celadonmartelevator.asm
+++ b/scripts/celadonmartelevator.asm
@@ -16,9 +16,9 @@ CeladonMartElevatorScript: ; 48600 (12:4600)
CeladonMartElevatorScript_4861c: ; 4861c (12:461c)
ld hl, wWarpEntries
- ld a, [wd73b]
+ ld a, [wWarpedFromWhichWarp]
ld b, a
- ld a, [wd73c]
+ ld a, [wWarpedFromWhichMap]
ld c, a
call CeladonMartElevatorScript_4862a
@@ -64,5 +64,5 @@ CeladonMartElevatorText1: ; 4865e (12:465e)
TX_ASM
call CeladonMartElevatorScript_48631
ld hl, CeldaonMartElevatorWarpMaps
- predef Func_1c9c6
+ predef DisplayElevatorFloorMenu
jp TextScriptEnd
diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm
index 5da549f3..c13e66e2 100755
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -9,7 +9,7 @@ CeruleanCityScript_1948c: ; 1948c (6:548c)
ld [wJoyIgnore], a
ld [W_CERULEANCITYCURSCRIPT], a
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
CeruleanCityScriptPointers: ; 1949d (6:549d)
@@ -86,7 +86,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8)
ld [hl], $19
.asm_19535
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld de, CeruleanCityMovement1
ld a, $1
@@ -218,7 +218,7 @@ CeruleanCityScript3: ; 19610 (6:5610)
bit 0, a
ret nz
ld a, HS_CERULEAN_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm
index 2232b0f4..3dafb3f8 100755
--- a/scripts/ceruleancity2.asm
+++ b/scripts/ceruleancity2.asm
@@ -4,13 +4,13 @@ CeruleanHideRocket: ; 74872 (1d:4872)
; the screen then fades out, he disappears, and fades back in
call GBFadeOutToBlack
ld a, HS_CERULEAN_GUARD_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_CERULEAN_GUARD_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_CERULEAN_ROCKET
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call GBFadeInFromBlack
ret
diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm
index c8ce12b9..a7845c68 100755
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -62,7 +62,7 @@ CeruleanGymScript_5c70d: ; 5c70d (17:470d)
.asm_5c736
ld hl, W_OBTAINEDBADGES
set 1, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 1, [hl]
; deactivate gym trainers
diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm
index 18737d2b..60df9338 100755
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -32,7 +32,7 @@ CinnabarGymScript_75792: ; 75792 (1d:5792)
ld [wJoyIgnore], a
ld [W_CINNABARGYMCURSCRIPT], a
ld [W_CURMAPSCRIPT], a
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ret
CinnabarGymScript_757a0: ; 757a0 (1d:57a0)
@@ -47,7 +47,7 @@ CinnabarGymScriptPointers: ; 757a6 (1d:57a6)
dw CinnabarGymScript3
CinnabarGymScript0: ; 757ae (1d:57ae)
- ld a, [wda38]
+ ld a, [wOpponentAfterWrongAnswer]
and a
ret z
ld [H_SPRITEINDEX], a
@@ -83,7 +83,7 @@ CinnabarGymScript1: ; 757dc (1d:57dc)
ret nz
xor a
ld [wJoyIgnore], a
- ld a, [wda38]
+ ld a, [wOpponentAfterWrongAnswer]
ld [wTrainerHeaderFlagBit], a
ld [hSpriteIndexOrTextID], a
jp DisplayTextID
@@ -127,7 +127,7 @@ CinnabarGymScript2: ; 757f6 (1d:57f6)
call UpdateCinnabarGymGateTileBlocks
xor a
ld [wJoyIgnore], a
- ld [wda38], a
+ ld [wOpponentAfterWrongAnswer], a
ld a, $0
ld [W_CINNABARGYMCURSCRIPT], a
ld [W_CURMAPSCRIPT], a
@@ -159,7 +159,7 @@ CinnabarGymScript3_75857: ; 75857 (1d:5857)
.asm_75880
ld hl, W_OBTAINEDBADGES
set 6, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 6, [hl]
; deactivate gym trainers
diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm
index 917a4c79..3eabb0bc 100755
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -103,21 +103,21 @@ DayCareMText1: ; 56254 (15:6254)
ld a, [wPartyCount]
cp PARTY_LENGTH
ld hl, DayCareNoRoomForMonText
- jp z, .asm_56403
- ld de, wTrainerFacingDirection
+ jp z, .leaveMonInDayCare
+ ld de, wDayCareTotalCost
xor a
ld [de], a
inc de
ld [de], a
- ld hl, wTrainerScreenX
+ ld hl, wDayCarePerLevelCost
ld a, $1
ld [hli], a
ld [hl], $0
ld a, [wDayCareNumLevelsGrown]
inc a
ld b, a
- ld c, $2
-.asm_56357
+ ld c, 2
+.calcPriceLoop
push hl
push de
push bc
@@ -126,29 +126,29 @@ DayCareMText1: ; 56254 (15:6254)
pop de
pop hl
dec b
- jr nz, .asm_56357
+ jr nz, .calcPriceLoop
ld hl, DayCareOweMoneyText
call PrintText
- ld a, $13
+ ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
call YesNoChoice
ld hl, DayCareAllRightThenText
ld a, [wCurrentMenuItem]
and a
- jp nz, .asm_56403
- ld hl, wTrainerFacingDirection
+ jp nz, .leaveMonInDayCare
+ ld hl, wDayCareTotalCost
ld [hMoney], a
ld a, [hli]
ld [hMoney + 1], a
ld a, [hl]
ld [hMoney + 2], a
call HasEnoughMoney
- jr nc, .asm_56396
+ jr nc, .enoughMoney
ld hl, DayCareNotEnoughMoneyText
- jp .asm_56403
+ jp .leaveMonInDayCare
-.asm_56396
+.enoughMoney
xor a
ld [W_DAYCARE_IN_USE], a
ld hl, wDayCareNumLevelsGrown
@@ -202,7 +202,7 @@ DayCareMText1: ; 56254 (15:6254)
ld hl, DayCareGotMonBackText
jr .done
-.asm_56403
+.leaveMonInDayCare
ld a, [wDayCareStartLevel]
ld [wDayCareMonBoxLevel], a
diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm
index 91d8a484..fa05d486 100755
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -274,7 +274,7 @@ FightingDojoText6: ; 5cf06 (17:4f06)
; once Poké Ball is taken, hide sprite
ld a, HS_FIGHTING_DOJO_GIFT_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvents EVENT_GOT_HITMONLEE, EVENT_DEFEATED_FIGHTING_DOJO
.done
@@ -310,7 +310,7 @@ FightingDojoText7: ; 5cf4e (17:4f4e)
; once Poké Ball is taken, hide sprite
ld a, HS_FIGHTING_DOJO_GIFT_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
.done
jp TextScriptEnd
diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm
index 0855d506..9bbc38a8 100755
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -62,7 +62,7 @@ FuchsiaGymScript3_75497: ; 75497 (1d:5497)
.asm_754c0
ld hl, W_OBTAINEDBADGES
set 4, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 4, [hl]
; deactivate gym trainers
diff --git a/scripts/gary.asm b/scripts/gary.asm
index 24a2d2de..9a3b1582 100755
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -120,7 +120,7 @@ GaryScript4: ; 75fe4 (1d:5fe4)
ld [H_SPRITEINDEX], a
call MoveSprite
ld a, HS_CHAMPIONS_ROOM_OAK
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $5
ld [W_GARYCURSCRIPT], a
@@ -197,7 +197,7 @@ GaryScript8: ; 76083 (1d:6083)
bit 0, a
ret nz
ld a, HS_CHAMPIONS_ROOM_OAK
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $9
ld [W_GARYCURSCRIPT], a
diff --git a/scripts/halloffameroom.asm b/scripts/halloffameroom.asm
index 9a5b595a..1da6d3f5 100755
--- a/scripts/halloffameroom.asm
+++ b/scripts/halloffameroom.asm
@@ -95,7 +95,7 @@ HallofFameRoomScript1: ; 5a52b (16:652b)
ld a, $ff
ld [wJoyIgnore], a
ld a, HS_UNKNOWN_DUNGEON_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $2
ld [W_HALLOFFAMEROOMCURSCRIPT], a
diff --git a/scripts/lance.asm b/scripts/lance.asm
index 4d0072be..9fa621da 100755
--- a/scripts/lance.asm
+++ b/scripts/lance.asm
@@ -24,12 +24,12 @@ LanceScript_5a2c4: ; 5a2c4 (16:62c4)
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)
diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm
index 4a245d93..3c639d1e 100755
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -22,7 +22,7 @@ LoreleiScript_76191: ; 76191 (1d:6191)
.asm_761a9
ld a, $24
.asm_761ab
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $2
predef_jump ReplaceTileBlock
diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm
index 7d349276..88bdd3ed 100755
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -35,12 +35,12 @@ Mansion1Subscript1: ; 442c5 (11:42c5)
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
diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm
index 4f5aac9f..cb697b94 100755
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -38,7 +38,7 @@ Mansion2Script_51fee: ; 51fee (14:5fee)
ret
Mansion2Script_5202f: ; 5202f (14:602f)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef_jump ReplaceTileBlock
Mansion2Script_Switches: ; 52037 (14:6037)
diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm
index 4542cc53..21c959aa 100755
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -145,7 +145,7 @@ MtMoon3Script5: ; 49dfb (12:5dfb)
.asm_49e1d
ld a, HS_MT_MOON_3_FOSSIL_1
.asm_49e1f
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
@@ -276,7 +276,7 @@ MtMoon3Text6: ; 49ee9 (12:5ee9)
jp nc, MtMoon3Script_49f76
call MtMoon3Script_49f69
ld a, HS_MT_MOON_3_FOSSIL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_GOT_DOME_FOSSIL
ld a, $4
@@ -304,7 +304,7 @@ MtMoon3Text7: ; 49f29 (12:5f29)
jp nc, MtMoon3Script_49f76
call MtMoon3Script_49f69
ld a, HS_MT_MOON_3_FOSSIL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_GOT_HELIX_FOSSIL
ld a, $4
diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm
index 77c7f270..4c209eb8 100755
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -196,7 +196,7 @@ Museum1FText3: ; 5c256 (17:4256)
jr nc, .BagFull
SetEvent EVENT_GOT_OLD_AMBER
ld a, HS_OLD_AMBER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld hl, ReceivedOldAmberText
jr .asm_5c288
diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm
index 620923ad..93f87657 100755
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -37,7 +37,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e)
and a
ret nz
ld a, HS_OAKS_LAB_OAK_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld hl, wd72e
res 4, [hl]
@@ -67,10 +67,10 @@ OaksLabScript2: ; 1cb82 (7:4b82)
bit 0, a
ret nz
ld a, HS_OAKS_LAB_OAK_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_OAKS_LAB_OAK_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $3
@@ -315,7 +315,7 @@ OaksLabScript9: ; 1cd00 (7:4d00)
.asm_1cd30
ld a, HS_STARTER_BALL_3
.asm_1cd32
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call Delay3
ld a, [wRivalStarterTemp]
@@ -475,7 +475,7 @@ OaksLabScript14: ; 1ce6d (7:4e6d)
bit 0, a
jr nz, .asm_1ce8c
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
@@ -519,14 +519,14 @@ OaksLabScript15: ; 1ceb0 (7:4eb0)
call DisplayTextID
call OaksLabScript_1d02b
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, [wNPCMovementDirections2Index]
- ld [wd157], a
- ld b, $0
+ ld [wSavedNPCMovementDirections2Index], a
+ ld b, 0
ld c, a
ld hl, wNPCMovementDirections2
- ld a, $40
+ ld a, NPC_MOVEMENT_UP
call FillMemory
ld [hl], $ff
ld a, $1
@@ -578,10 +578,10 @@ OaksLabScript16: ; 1cf12 (7:4f12)
call DisplayTextID
call Delay3
ld a, HS_POKEDEX_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_POKEDEX_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call OaksLabScript_1cefd
ld a, $1a
@@ -599,16 +599,16 @@ OaksLabScript16: ; 1cf12 (7:4f12)
SetEvent EVENT_GOT_POKEDEX
SetEvent EVENT_OAK_GOT_PARCEL
ld a, HS_LYING_OLD_MAN
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_OLD_MAN
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
- ld a, [wd157]
- ld b, $0
+ ld a, [wSavedNPCMovementDirections2Index]
+ ld b, 0
ld c, a
ld hl, wNPCMovementDirections2
- xor a
+ xor a ; NPC_MOVEMENT_DOWN
call FillMemory
ld [hl], $ff
ld a, $ff
@@ -630,13 +630,13 @@ OaksLabScript17: ; 1cfd4 (7:4fd4)
ret nz
call PlayDefaultMusic
ld a, HS_OAKS_LAB_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
SetEvent EVENT_1ST_ROUTE22_RIVAL_BATTLE
ResetEventReuseHL EVENT_2ND_ROUTE22_RIVAL_BATTLE
- SetEventReuseHL EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ SetEventReuseHL EVENT_ROUTE22_RIVAL_WANTS_BATTLE
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $5
ld [W_PALLETTOWNCURSCRIPT], a
@@ -914,7 +914,7 @@ OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3)
.asm_1d1e3
ld a, HS_STARTER_BALL_3
.asm_1d1e5
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
@@ -985,7 +985,7 @@ OaksLabText5: ; 1d248 (7:5248)
ld b,POKE_BALL
call IsItemInBag
jr nz, .asm_1d2e7
- CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_FIGHT
+ CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE
jr nz, .asm_1d2d0
CheckEvent EVENT_GOT_POKEDEX
jr nz, .asm_1d2c8
diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm
index 0fd7300e..e4c3f135 100755
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -51,7 +51,7 @@ PalletTownScript1: ; 18eb2 (6:4eb2)
ld a,$FF
ld [wJoyIgnore],a
ld a,HS_PALLET_TOWN_OAK
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef ShowObject
; trigger the next script
@@ -136,10 +136,10 @@ PalletTownScript5: ; 18f56 (6:4f56)
jr nz,.next
SetEvent EVENT_DAISY_WALKING
ld a,HS_DAISY_SITTING
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef HideObject
ld a,HS_DAISY_WALKING
- ld [wcc4d],a
+ ld [wMissableObjectIndex],a
predef_jump ShowObject
.next
CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm
index 77da14f8..66589d52 100755
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -88,7 +88,7 @@ PewterCityScript2: ; 192d3 (6:52d3)
bit 0, a
ret nz
ld a, HS_MUSEUM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $3
ld [W_PEWTERCITYCURSCRIPT], a
@@ -99,7 +99,7 @@ PewterCityScript3: ; 192e9 (6:52e9)
ld [wSpriteIndex], a
call SetSpritePosition2
ld a, HS_MUSEUM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
xor a
ld [wJoyIgnore], a
@@ -157,7 +157,7 @@ PewterCityScript5: ; 19359 (6:5359)
bit 0, a
ret nz
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $6
ld [W_PEWTERCITYCURSCRIPT], a
@@ -168,7 +168,7 @@ PewterCityScript6: ; 1936f (6:536f)
ld [wSpriteIndex], a
call SetSpritePosition2
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
xor a
ld [wJoyIgnore], a
diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm
index 186d0176..81fcb600 100755
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -62,17 +62,17 @@ PewterGymScript_5c3df: ; 5c3df (17:43df)
.asm_5c408
ld hl, W_OBTAINEDBADGES
set 0, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 0, [hl]
ld a, HS_GYM_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
- ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
; deactivate gym trainers
SetEvent EVENT_BEAT_PEWTER_GYM_TRAINER_0
@@ -183,7 +183,7 @@ PewterGymAfterBattleText1: ; 5c4da (17:44da)
PewterGymText3: ; 5c4df (17:44df)
TX_ASM
- ld a, [wd72a]
+ ld a, [wBeatGymFlags]
bit 0, a
jr nz, .asm_5c50c
ld hl, PewterGymText_5c515
diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm
index c7b94c4f..a569b60b 100755
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -112,7 +112,7 @@ PokemonTower2Script2: ; 605bb (18:45bb)
bit 0, a
ret nz
ld a, HS_POKEMONTOWER_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
xor a
ld [wJoyIgnore], a
diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm
index 3698f4ee..a4635aa3 100755
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -51,13 +51,13 @@ PokemonTower7Script3: ; 60d56 (18:4d56)
cp b ; search for sprite ID in missing objects list
ld a, [hli]
jr nz, .missableObjectsListLoop
- ld [wcc4d], a ; remove missable object
+ ld [wMissableObjectIndex], a ; remove missable object
predef HideObject
xor a
ld [wJoyIgnore], a
ld [wSpriteIndex], a
ld [wTrainerHeaderFlagBit], a
- ld [wda38], a
+ ld [wUnusedDA38], a
ld a, $0
ld [W_POKEMONTOWER7CURSCRIPT], a
ld [W_CURMAPSCRIPT], a
@@ -67,7 +67,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86)
ld a, $ff
ld [wJoyIgnore], a
ld a, HS_POKEMONTOWER_7_MR_FUJI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, SPRITE_FACING_UP
ld [wSpriteStateData1 + 9], a
@@ -259,13 +259,13 @@ PokemonTower7FujiText:
SetEvent EVENT_RESCUED_MR_FUJI
SetEvent EVENT_RESCUED_MR_FUJI_2
ld a, HS_LAVENDER_HOUSE_1_MR_FUJI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_SAFFRON_CITY_E
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_SAFFRON_CITY_F
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, $4
ld [W_POKEMONTOWER7CURSCRIPT], a
diff --git a/scripts/rockethideout1.asm b/scripts/rockethideout1.asm
index ccf40cb4..c658596e 100755
--- a/scripts/rockethideout1.asm
+++ b/scripts/rockethideout1.asm
@@ -26,7 +26,7 @@ RocketHideout1Script_44be0: ; 44be0 (11:4be0)
.asm_44c01
ld a, $e
.asm_44c03
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $080c
predef_jump ReplaceTileBlock
diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm
index 3c312d4c..62d6f6bb 100755
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -26,7 +26,7 @@ RocketHideout4Script_45473: ; 45473 (11:5473)
.asm_45496
ld a, $e
.asm_45498
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $050c
predef_jump ReplaceTileBlock
@@ -56,10 +56,10 @@ RocketHideout4Script3: ; 454b6 (11:54b6)
call DisplayTextID
call GBFadeOutToBlack
ld a, HS_ROCKET_HIDEOUT_4_GIOVANNI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_ROCKET_HIDEOUT_4_ITEM_4
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
call UpdateSprites
call GBFadeInFromBlack
@@ -211,7 +211,7 @@ RocketHideout4AfterBattleText4: ; 455cf (11:55cf)
CheckAndSetEvent EVENT_ROCKET_DROPPED_LIFT_KEY
jr nz, .asm_455e9
ld a, HS_ROCKET_HIDEOUT_4_ITEM_5
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
.asm_455e9
jp TextScriptEnd
diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm
index 169b536b..52c7fad3 100755
--- a/scripts/rockethideoutelevator.asm
+++ b/scripts/rockethideoutelevator.asm
@@ -16,9 +16,9 @@ RocketHideoutElevatorScript: ; 45710 (11:5710)
RocketHideoutElevatorScript_4572c: ; 4572c (11:572c)
ld hl, wWarpEntries
- ld a, [wd73b]
+ ld a, [wWarpedFromWhichWarp]
ld b, a
- ld a, [wd73c]
+ ld a, [wWarpedFromWhichMap]
ld c, a
call RocketHideoutElevatorScript_4573a
@@ -68,7 +68,7 @@ RocketHideoutElevatorText1: ; 4576d (11:576d)
jr z, .asm_45782
call RocketHideoutElevatorScript_45741
ld hl, RocketHideoutElevatorWarpMaps
- predef Func_1c9c6
+ predef DisplayElevatorFloorMenu
jr .asm_45788
.asm_45782
ld hl, RocketHideoutElevatorText_4578b
diff --git a/scripts/route12.asm b/scripts/route12.asm
index be20958e..4057ce03 100755
--- a/scripts/route12.asm
+++ b/scripts/route12.asm
@@ -34,7 +34,7 @@ Route12Script0: ; 59619 (16:5619)
ld a, 30
ld [W_CURENEMYLVL], a
ld a, HS_ROUTE_12_SNORLAX
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, $3
ld [W_ROUTE12CURSCRIPT], a
diff --git a/scripts/route16.asm b/scripts/route16.asm
index 286b5289..c762c999 100755
--- a/scripts/route16.asm
+++ b/scripts/route16.asm
@@ -34,7 +34,7 @@ Route16Script0: ; 59959 (16:5959)
ld a, 30
ld [W_CURENEMYLVL], a
ld a, HS_ROUTE_16_SNORLAX
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call UpdateSprites
ld a, $3
diff --git a/scripts/route20.asm b/scripts/route20.asm
index 2ef51da9..ce9e6f23 100755
--- a/scripts/route20.asm
+++ b/scripts/route20.asm
@@ -49,11 +49,11 @@ Route20Script_50cc6: ; 50cc6 (14:4cc6)
ret
Route20Script_50d0c: ; 50d0c (14:4d0c)
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
Route20Script_50d14: ; 50d14 (14:4d14)
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
Route20ScriptPointers: ; 50d1c (14:4d1c)
diff --git a/scripts/route22.asm b/scripts/route22.asm
index 73fe2f55..041f75e6 100755
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -55,7 +55,7 @@ Route22RivalMovementData: ; 50efb (14:4efb)
db $FF
Route22Script0: ; 50f00 (14:4f00)
- CheckEvent EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ CheckEvent EVENT_ROUTE22_RIVAL_WANTS_BATTLE
ret z
ld hl, .Route22RivalBattleCoords
call ArePlayerCoordsInArray
@@ -163,7 +163,7 @@ Route22Script2: ; 50fb5 (14:4fb5)
call SetSpriteFacingDirectionAndDelay
ld a, $f0
ld [wJoyIgnore], a
- SetEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_FIGHT
+ SetEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE
ld a, $1
ld [hSpriteIndexOrTextID], a
call DisplayTextID
@@ -224,10 +224,10 @@ Route22Script3: ; 5102a (14:502a)
xor a
ld [wJoyIgnore], a
ld a, HS_ROUTE_22_RIVAL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
- ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ ResetEvents EVENT_1ST_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
ld a, $0
ld [W_ROUTE22CURSCRIPT], a
ret
@@ -322,7 +322,7 @@ Route22Script5: ; 510df (14:50df)
call SetSpriteFacingDirectionAndDelay
ld a, $f0
ld [wJoyIgnore], a
- SetEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_FIGHT
+ SetEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE
ld a, $2
ld [hSpriteIndexOrTextID], a
call DisplayTextID
@@ -369,10 +369,10 @@ Route22Script6: ; 51151 (14:5151)
xor a
ld [wJoyIgnore], a
ld a, HS_ROUTE_22_RIVAL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
- ResetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ ResetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
ld a, $7
ld [W_ROUTE22CURSCRIPT], a
ret
@@ -384,7 +384,7 @@ Route22TextPointers: ; 51175 (14:5175)
Route22Text1: ; 5117b (14:517b)
TX_ASM
- CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_FIGHT
+ CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE
jr z, .asm_5118b
ld hl, Route22RivalAfterBattleText1
call PrintText
@@ -397,7 +397,7 @@ Route22Text1: ; 5117b (14:517b)
Route22Text2: ; 51194 (14:5194)
TX_ASM
- CheckEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_FIGHT
+ CheckEvent EVENT_BEAT_ROUTE22_RIVAL_2ND_BATTLE
jr z, .asm_511a4
ld hl, Route22RivalAfterBattleText2
call PrintText
diff --git a/scripts/route23.asm b/scripts/route23.asm
index adc631d8..35f1b9cb 100755
--- a/scripts/route23.asm
+++ b/scripts/route23.asm
@@ -13,10 +13,10 @@ Route23Script_511e9: ; 511e9 (14:51e9)
ResetEvents EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_2_BOULDER_ON_SWITCH2
ResetEvents EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH1, EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH2
ld a, HS_VICTORY_ROAD_3_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
ld a, HS_VICTORY_ROAD_2_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump HideObject
Route23ScriptPointers: ; 51213 (14:5213)
diff --git a/scripts/route25.asm b/scripts/route25.asm
index a123d74a..49580ba6 100755
--- a/scripts/route25.asm
+++ b/scripts/route25.asm
@@ -19,20 +19,20 @@ Route25Script_515e1: ; 515e1 (14:55e1)
jr nz, .asm_515ff
ResetEventReuseHL EVENT_BILL_SAID_USE_CELL_SEPARATOR
ld a, HS_BILL_POKEMON
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_515ff
CheckEventAfterBranchReuseHL EVENT_GOT_SS_TICKET, EVENT_MET_BILL_2
ret z
SetEventReuseHL EVENT_LEFT_BILLS_HOUSE_AFTER_HELPING
ld a, HS_NUGGET_BRIDGE_GUY
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_BILL_1
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_BILL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
Route25ScriptPointers: ; 51622 (14:5622)
diff --git a/scripts/safarizoneentrance-yellow.asm b/scripts/safarizoneentrance-yellow.asm
index 6ff0e298..9d354cff 100644
--- a/scripts/safarizoneentrance-yellow.asm
+++ b/scripts/safarizoneentrance-yellow.asm
@@ -1,7 +1,7 @@
.xf1f77
ld hl,.ForJust500Text
call PrintText
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
call YesNoChoice
@@ -21,11 +21,11 @@
.xf1f9f
xor a
- ld [$ff9f],a
+ ld [hMoney],a
ld a,$05
- ld [$ffa0],a
+ ld [hMoney + 1],a
ld a,$00
- ld [$ffa1],a
+ ld [hMoney + 2],a
call HasEnoughMoney
jr nc,.success
ld hl,.NotEnoughMoneyText
@@ -36,19 +36,19 @@
.success
xor a
- ld [wSubtrahend],a
+ ld [wPriceTemp],a
ld a,$05
- ld [wSubtrahend+1],a
+ ld [wPriceTemp + 1],a
ld a,$00
- ld [wSubtrahend+2],a
- ld hl,wTrainerFacingDirection
+ ld [wPriceTemp + 2],a
+ ld hl,wPriceTemp + 2
ld de,wPlayerMoney + 2
ld c,3
predef SubBCDPredef
ld a,$b2
call $3736
call $373e
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
ld hl,.MakePaymentText
diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm
index 6ed62fd1..e4e2e2a8 100755
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -145,7 +145,7 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9)
.SafariZoneEntranceText4
TX_FAR SafariZoneEntranceText_9e6e4
TX_ASM
- ld a, $13
+ ld a, MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
call YesNoChoice
@@ -166,16 +166,16 @@ SafariZoneEntranceTextPointers: ; 752b9 (1d:52b9)
.success
xor a
- ld [wSubtrahend],a
+ ld [wPriceTemp],a
ld a,$05
- ld [wSubtrahend+1],a
+ ld [wPriceTemp + 1],a
ld a,$00
- ld [wSubtrahend+2],a
- ld hl,wTrainerFacingDirection
+ ld [wPriceTemp + 2],a
+ ld hl,wPriceTemp + 2
ld de,wPlayerMoney + 2
ld c,3
predef SubBCDPredef
- ld a,$13
+ ld a,MONEY_BOX
ld [wTextBoxID],a
call DisplayTextBoxID
ld hl,.MakePaymentText
diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm
index e712689f..9ee632f7 100755
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -62,7 +62,7 @@ SaffronGymText_5d068: ; 5d068 (17:5068)
.asm_5d091
ld hl, W_OBTAINEDBADGES
set 5, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 5, [hl]
; deactivate gym trainers
diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm
index 542afe18..f9a2e7fc 100755
--- a/scripts/seafoamislands1.asm
+++ b/scripts/seafoamislands1.asm
@@ -14,22 +14,22 @@ SeafoamIslands1Script: ; 447e9 (11:47e9)
jr nz, .asm_44819
SetEventReuseHL EVENT_SEAFOAM1_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_44825
.asm_44819
SetEventAfterBranchReuseHL EVENT_SEAFOAM1_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM1_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_1_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_44825
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_4483b
ld a, $9f
diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm
index bf81a467..2c2962f8 100755
--- a/scripts/seafoamislands2.asm
+++ b/scripts/seafoamislands2.asm
@@ -13,22 +13,22 @@ SeafoamIslands2Script: ; 46315 (11:6315)
jr nz, .asm_46340
SetEventReuseHL EVENT_SEAFOAM2_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_4634c
.asm_46340
SetEventAfterBranchReuseHL EVENT_SEAFOAM2_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM2_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_2_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_4634c
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_46362
ld a, $a0
diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm
index 8f66a0ca..6dda7f37 100755
--- a/scripts/seafoamislands3.asm
+++ b/scripts/seafoamislands3.asm
@@ -13,22 +13,22 @@ SeafoamIslands3Script: ; 46451 (11:6451)
jr nz, .asm_4647c
SetEventReuseHL EVENT_SEAFOAM3_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_3
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_46488
.asm_4647c
SetEventAfterBranchReuseHL EVENT_SEAFOAM3_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM3_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_3_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_4
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_46488
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.asm_4649e
ld a, $a1
diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm
index dc198123..f7407e48 100755
--- a/scripts/seafoamislands4.asm
+++ b/scripts/seafoamislands4.asm
@@ -13,22 +13,22 @@ SeafoamIslands4Script: ; 4658d (11:658d)
jr nz, .asm_465b8
SetEventReuseHL EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_1
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_1
- ld [wd07a], a
+ ld [wObjectToShow], a
jr .asm_465c4
.asm_465b8
SetEventAfterBranchReuseHL EVENT_SEAFOAM4_BOULDER2_DOWN_HOLE, EVENT_SEAFOAM4_BOULDER1_DOWN_HOLE
ld a, HS_SEAFOAM_ISLANDS_4_BOULDER_2
- ld [wd079], a
+ ld [wObjectToHide], a
ld a, HS_SEAFOAM_ISLANDS_5_BOULDER_2
- ld [wd07a], a
+ ld [wObjectToShow], a
.asm_465c4
- ld a, [wd079]
- ld [wcc4d], a
+ ld a, [wObjectToHide]
+ ld [wMissableObjectIndex], a
predef HideObject
- ld a, [wd07a]
- ld [wcc4d], a
+ ld a, [wObjectToShow]
+ ld [wMissableObjectIndex], a
predef ShowObject
jr .asm_465ed
.asm_465dc
diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm
index eca361f3..87942ca0 100755
--- a/scripts/seafoamislands5.asm
+++ b/scripts/seafoamislands5.asm
@@ -35,12 +35,12 @@ SeafoamIslands5Script0: ; 467c7 (11:67c7)
ld a, [wCoordIndex]
cp $3
jr nc, .asm_467e6
- ld a, $40
- ld [wccd4], a
- ld a, $2
+ ld a, NPC_MOVEMENT_UP
+ ld [wSimulatedJoypadStatesEnd + 1], a
+ ld a, 2
jr .asm_467e8
.asm_467e6
- ld a, $1
+ ld a, 1
.asm_467e8
ld [wSimulatedJoypadStatesIndex], a
ld a, D_UP
diff --git a/scripts/silphco1.asm b/scripts/silphco1.asm
index 71b59d72..cfd51dc1 100755
--- a/scripts/silphco1.asm
+++ b/scripts/silphco1.asm
@@ -5,7 +5,7 @@ SilphCo1Script: ; 5d44e (17:544e)
CheckAndSetEvent EVENT_SILPH_CO_RECEPTIONIST_AT_DESK
ret nz
ld a, HS_SILPH_CO_1F_RECEPTIONIST
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
SilphCo1TextPointers: ; 5d469 (17:5469)
diff --git a/scripts/silphco10.asm b/scripts/silphco10.asm
index 326b0aeb..fb419a22 100755
--- a/scripts/silphco10.asm
+++ b/scripts/silphco10.asm
@@ -19,7 +19,7 @@ SilphCo10Script_5a14f: ; 5a14f (16:614f)
CheckEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR
ret nz
ld a, $54
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $405
predef_jump ReplaceTileBlock
diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm
index 8f37b57f..9cdf2891 100755
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -19,7 +19,7 @@ SilphCo11Script_62110: ; 62110 (18:6110)
CheckEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR
ret nz
ld a, $20
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $603
predef_jump ReplaceTileBlock
@@ -76,7 +76,7 @@ SilphCo11Script_6216d: ; 6216d (18:616d)
cp $ff
jr z, .asm_62181
push hl
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
pop hl
jr .asm_62170
@@ -87,7 +87,7 @@ SilphCo11Script_6216d: ; 6216d (18:616d)
cp $ff
ret z
push hl
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
pop hl
jr .asm_62184
diff --git a/scripts/silphco2.asm b/scripts/silphco2.asm
index a8d0fa56..b758455e 100755
--- a/scripts/silphco2.asm
+++ b/scripts/silphco2.asm
@@ -20,7 +20,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07)
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 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07)
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
diff --git a/scripts/silphco3.asm b/scripts/silphco3.asm
index b55cc5eb..f693ea33 100755
--- a/scripts/silphco3.asm
+++ b/scripts/silphco3.asm
@@ -20,7 +20,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71)
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 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71)
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
diff --git a/scripts/silphco4.asm b/scripts/silphco4.asm
index 815170ff..0ea2c8c8 100755
--- a/scripts/silphco4.asm
+++ b/scripts/silphco4.asm
@@ -20,7 +20,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21)
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 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21)
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
diff --git a/scripts/silphco5.asm b/scripts/silphco5.asm
index ecc57537..d6f35993 100755
--- a/scripts/silphco5.asm
+++ b/scripts/silphco5.asm
@@ -20,7 +20,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
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 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
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 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
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
diff --git a/scripts/silphco6.asm b/scripts/silphco6.asm
index a84f0dc4..25fbcef9 100755
--- a/scripts/silphco6.asm
+++ b/scripts/silphco6.asm
@@ -19,7 +19,7 @@ SilphCo6Script_1a1bf: ; 1a1bf (6:61bf)
CheckEvent EVENT_SILPH_CO_6_UNLOCKED_DOOR
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $0602
predef_jump ReplaceTileBlock
diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm
index 26d9e62f..44e92475 100755
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -20,7 +20,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
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 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
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 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
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
@@ -252,7 +252,7 @@ SilphCo7Script5: ; 51d25 (14:5d25)
bit 0, a
ret nz
ld a, HS_SILPH_CO_7F_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
xor a
diff --git a/scripts/silphco8.asm b/scripts/silphco8.asm
index 26a89355..7545f359 100755
--- a/scripts/silphco8.asm
+++ b/scripts/silphco8.asm
@@ -19,7 +19,7 @@ SilphCo8Script_5651a: ; 5651a (15:651a)
CheckEvent EVENT_SILPH_CO_8_UNLOCKED_DOOR
ret nz
ld a, $5f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $403
predef_jump ReplaceTileBlock
diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm
index 8960c290..557ce1f1 100755
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -20,7 +20,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
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 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
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 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
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 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
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
diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm
index 161b5ece..36dbb6d2 100755
--- a/scripts/silphcoelevator.asm
+++ b/scripts/silphcoelevator.asm
@@ -16,9 +16,9 @@ SilphCoElevatorScript: ; 457c0 (11:57c0)
SilphCoElevatorScript_457dc: ; 457dc (11:57dc)
ld hl, wWarpEntries
- ld a, [wd73b]
+ ld a, [wWarpedFromWhichWarp]
ld b, a
- ld a, [wd73c]
+ ld a, [wWarpedFromWhichMap]
ld c, a
call SilphCoElevatorScript_457ea
@@ -73,5 +73,5 @@ SilphCoElevatorText1: ; 45835 (11:5835)
TX_ASM
call SilphCoElevatorScript_457f1
ld hl, SilphCoElevatorWarpMaps
- predef Func_1c9c6
+ predef DisplayElevatorFloorMenu
jp TextScriptEnd
diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm
index bc13d4b6..b95c5723 100755
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -33,7 +33,7 @@ SSAnne2Script0: ; 613be (18:53be)
ld a, [wCoordIndex]
ld [$ffdb], a
ld a, HS_SS_ANNE_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
call Delay3
ld a, $2
@@ -171,7 +171,7 @@ SSAnne2Script3: ; 614be (18:54be)
xor a
ld [wJoyIgnore], a
ld a, HS_SS_ANNE_2_RIVAL
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call PlayDefaultMusic
ld a, $4
diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm
index 7448e8f9..de721a2f 100755
--- a/scripts/vermilioncity.asm
+++ b/scripts/vermilioncity.asm
@@ -17,7 +17,7 @@ VermilionCityScript_197c0: ; 197c0 (6:57c0)
call Random
ld a, [$ffd4]
and $e
- ld [wd743], a
+ ld [wFirstLockTrashCanIndex], a
ret
VermilionCityScript_197cb: ; 197cb (6:57cb)
@@ -84,8 +84,8 @@ VermilionCityScript2: ; 19833 (6:5833)
ld [wJoyIgnore], a
ld a, D_UP
ld [wSimulatedJoypadStatesEnd], a
- ld [wccd4], a
- ld a, $2
+ ld [wSimulatedJoypadStatesEnd + 1], a
+ ld a, 2
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $3
diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm
index 8c400b5f..5c504335 100755
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -37,7 +37,7 @@ VermilionGymScript_5ca6d: ; 5ca6d (17:4a6d)
call PlaySound
ld a, $5
.asm_5ca7f
- ld [wd09f], a
+ ld [wNewTileBlockID], a
ld bc, $202
predef_jump ReplaceTileBlock
@@ -81,7 +81,7 @@ VermilionGymScript_5caaa: ; 5caaa (17:4aaa)
.asm_5cad3
ld hl, W_OBTAINEDBADGES
set 2, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 2, [hl]
; deactivate gym trainers
@@ -247,7 +247,7 @@ VermilionGymAfterBattleText3: ; 5cbd6 (17:4bd6)
VermilionGymText5: ; 5cbdb (17:4bdb)
TX_ASM
- ld a, [wd72a]
+ ld a, [wBeatGymFlags]
bit 2, a
jr nz, .asm_5cbeb
ld hl, VermilionGymText_5cbf4
diff --git a/scripts/victoryroad1.asm b/scripts/victoryroad1.asm
index 91e20ad3..dbb69a64 100755
--- a/scripts/victoryroad1.asm
+++ b/scripts/victoryroad1.asm
@@ -14,7 +14,7 @@ VictoryRoad1Script: ; 5da0a (17:5a0a)
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
diff --git a/scripts/victoryroad2.asm b/scripts/victoryroad2.asm
index b7aa40b5..41fe0212 100755
--- a/scripts/victoryroad2.asm
+++ b/scripts/victoryroad2.asm
@@ -33,7 +33,7 @@ VictoryRoad2Script_517c9: ; 517c9 (14:57c9)
ld bc, $70b
VictoryRoad2Script_517e2: ; 517e2 (14:57e2)
- ld [wd09f], a
+ ld [wNewTileBlockID], a
predef ReplaceTileBlock
ret
diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm
index 2984e4ae..c5aaef50 100755
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -16,7 +16,7 @@ VictoryRoad3Script_44996: ; 44996 (11:4996)
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
@@ -44,10 +44,10 @@ VictoryRoad3Script0: ; 449b7 (11:49b7)
CheckAndSetEvent EVENT_VICTORY_ROAD_3_BOULDER_ON_SWITCH2
jr nz, .asm_449fe
ld a, HS_VICTORY_ROAD_3_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
ld a, HS_VICTORY_ROAD_2_BOULDER
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef_jump ShowObject
.coordsData_449f9: ; 449f9 (11:49f9)
diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm
index 2124d965..8e012040 100755
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -156,16 +156,16 @@ ViridianGymScript3_74995: ; 74995 (1d:4995)
.asm_749be
ld hl, W_OBTAINEDBADGES
set 7, [hl]
- ld hl, wd72a
+ ld hl, wBeatGymFlags
set 7, [hl]
; deactivate gym trainers
SetEventRange EVENT_BEAT_VIRIDIAN_GYM_TRAINER_0, EVENT_BEAT_VIRIDIAN_GYM_TRAINER_7
ld a, HS_ROUTE_22_RIVAL_2
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef ShowObject
- SetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_FIGHT
+ SetEvents EVENT_2ND_ROUTE22_RIVAL_BATTLE, EVENT_ROUTE22_RIVAL_WANTS_BATTLE
jp ViridianGymScript_748d6
ViridianGymTextPointers: ; 749ec (1d:49ec)
@@ -275,7 +275,7 @@ ViridianGymText1: ; 74a69 (1d:4a69)
call PrintText
call GBFadeOutToBlack
ld a, HS_VIRIDIAN_GYM_GIOVANNI
- ld [wcc4d], a
+ ld [wMissableObjectIndex], a
predef HideObject
call UpdateSprites
call Delay3
diff --git a/text/maps/daycare_1.asm b/text/maps/daycare_1.asm
index a42e3cf2..02e35344 100644
--- a/text/maps/daycare_1.asm
+++ b/text/maps/daycare_1.asm
@@ -39,7 +39,7 @@ _DayCareMonHasGrownText:: ; 8ac32 (22:6c32)
_DayCareOweMoneyText:: ; 8ac7d (22:6c7d)
text "You owe me ¥@"
- TX_BCD wcd3f, $c2
+ TX_BCD wDayCareTotalCost, $c2
db $0
line "for the return"
cont "of this #MON."
diff --git a/text/maps/name_rater.asm b/text/maps/name_rater.asm
index 2baec727..052a9588 100644
--- a/text/maps/name_rater.asm
+++ b/text/maps/name_rater.asm
@@ -35,7 +35,7 @@ _NameRaterText_1dac7:: ; 9a404 (26:6404)
text "OK! This #MON"
line "has been renamed"
cont "@"
- TX_RAM wHPBarMaxHP
+ TX_RAM wBuffer
text "!"
para "That's a better"
diff --git a/wram.asm b/wram.asm
index 275ccc40..bcd932d7 100755
--- a/wram.asm
+++ b/wram.asm
@@ -295,9 +295,11 @@ wTradeCenterPointerTableIndex:: ; cc38
ds 1
-; group these two together
-wcc3a:: ds 1 ; both used in home/text.asm
-wcc3b:: ds 1
+wUnusedCC3A:: ; cc3a
+ ds 1
+
+wUnusedCC3B:: ; cc3b
+ ds 1
wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c
; if non-zero, skip waiting for a button press after displaying text in DisplayTextID
@@ -312,8 +314,7 @@ wSerialExchangeNybbleTempReceiveData:: ; cc3d
wLinkMenuSelectionReceiveBuffer:: ; cc3d
; two byte buffer
; the received menu selection is stored twice
-
-wcc3d:: ds 1 ; not used for anything other than mentioned above (haha link function)
+ ds 1
wSerialExchangeNybbleReceiveData:: ; cc3e
; the final received nybble is stored here by Serial_ExchangeNybble
@@ -336,8 +337,10 @@ wLinkTimeoutCounter:: ; cc47
wUnknownSerialCounter:: ; cc47
; 2 bytes
-wcc47:: ds 1 ; used in text id stuff
-wcc48:: ds 1 ; part of wUnknownSerialCounter
+wEnteringCableClub:: ; cc47
+ ds 1
+
+ ds 1
wWhichTradeMonSelectionMenu:: ; cc49
; $00 = player mons
@@ -360,8 +363,14 @@ wMenuWrappingEnabled:: ; cc4a
; set to 0 if you can't go past the top or bottom of the menu
ds 1
-wcc4b:: ds 2 ; used as a joypad storage value
-wcc4d:: ds 1 ; used in sprite hiding/showing related operations
+wCheckFor180DegreeTurn:: ; cc4b
+; whether to check for 180-degree turn (0 = don't, 1 = do)
+ ds 1
+
+ ds 1
+
+wMissableObjectIndex:: ; cc4d
+ ds 1
wPredefID:: ; cc4e
ds 1
@@ -406,10 +415,12 @@ wSlotMachineSavedROMBank:: ; cc5e
; ROM back to return to when the player is done with the slot machine
ds 1
- ds 12
+ ds 26
-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
@@ -442,8 +453,8 @@ wCanEvolveFlags:: ; ccd3
; Other methods of evolution simply set it by calling TryEvolvingMon.
ds 1
-wForceEvolution::
-wccd4:: ds 1 ; has a direct reference for simulated joypad stuff in vermillion and seafoam
+wForceEvolution:: ; ccd4
+ ds 1
; if [ccd5] != 1, the second AI layer is not applied
wAILayer2Encouragement:: ; ccd5
@@ -479,8 +490,11 @@ wAICount:: ; ccdf
wEnemyMoveListIndex:: ; cce2
ds 1
-wcce3:: ds 1 ; used in battle-related text functions
-wcce4:: ds 1 ; used in battle-related text functions
+wLastSwitchInEnemyMonHP:: ; cce3
+; The enemy mon's HP when it was switched in or when the current player mon
+; was switched in, which was more recent.
+; It's used to determine the message to print when switching out the player mon.
+ ds 2
wTotalPayDayMoney:: ; cce5
; total amount of money made using Pay Day during the current battle
@@ -644,6 +658,25 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
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)
+
+wBattleTransitionCopyTilesOffset:: ; cd3d
+; 2 bytes
+; after 1 row/column has been copied, the offset to the next one to copy from
+
+wInwardSpiralUpdateScreenCounter:: ; cd3d
+; counts down from 7 so that every time 7 more tiles of the spiral have been
+; placed, the tile map buffer is copied to VRAM so that progress is visible
+
wHoFTeamIndex:: ; cd3d
wSSAnneSmokeDriftAmount:: ; cd3d
@@ -726,9 +759,6 @@ wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d
wHiddenObjectFunctionArgument:: ; cd3d
-wSubtrahend:: ; cd3d
-; subtract (BCD) wSubtrahend, wSubtrahend+1, wSubtrahend+2
-
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
@@ -737,6 +767,13 @@ wTrainerSpriteOffset:: ; cd3d
wUnusedCD3D:: ; cd3d
ds 1
+wHUDPokeballGfxOffsetX:: ; cd3e
+; difference in X between the next ball and the current one
+
+wBattleTransitionCircleScreenQuadrantX:: ; cd3e
+; 0 = left half (X < 10)
+; 1 = right half (X >= 10)
+
wSSAnneSmokeX:: ; cd3e
wRivalStarterBallSpriteIndex:: ; cd3e
@@ -775,6 +812,12 @@ wHiddenObjectFunctionRomBank:: ; cd3e
wTrainerEngageDistance:: ; cd3e
ds 1
+wHUDGraphicsTiles:: ; cd3f
+; 3 bytes
+
+wDayCareTotalCost:: ; cd3f
+; 2-byte BCD number
+
wJigglypuffFacingDirections:: ; cd3f
wOptionsBattleStyleCursorX:: ; cd3f
@@ -801,7 +844,6 @@ wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f
wHiddenObjectIndex:: ; cd3f
wTrainerFacingDirection:: ; cd3f
-wcd3f:: ; used with daycare text for money amount
ds 1
wHoFMonOrPlayer:: ; cd40
@@ -816,8 +858,13 @@ wPlayerSpinInPlaceAnimSoundID:: ; cd40
wHiddenObjectY:: ; cd40
wTrainerScreenY:: ; cd40
+
+wUnusedCD40:: ; cd40
ds 1
+wDayCarePerLevelCost:: ; cd41
+; 2-byte BCD number (always set to $0100)
+
wHoFTeamIndex2:: ; cd41
wHiddenItemOrCoinsIndex:: ; cd41
@@ -842,8 +889,7 @@ wHoFTeamNo:: ; cd42
wSlotMachineWheel1MiddleTile:: ; cd42
wFieldMovesLeftmostXCoord:: ; cd42
-
-wcd42:: ds 1 ; used in pewter center script, printing field mon moves, slot machines and HoF PC
+ ds 1
wLastFieldMoveID:: ; cd43
; unused
@@ -940,10 +986,18 @@ wWhichAnimationOffsets:: ; cd50
wTradedEnemyMonOTID:: ; cd59
ds 2
+wStandingOnWarpPadOrHole:: ; cd5b
+; 0 = neither
+; 1 = warp pad
+; 2 = hole
+
wOAMBaseTile:: ; cd5b
-wcd5b:: ds 1 ; used in some sprite stuff, town map and surge gym trash cans
-wcd5c:: ds 1 ; used in town map
+wGymTrashCanIndex:: ; cd5b
+ ds 1
+
+wSymmetricSpriteOAMAttributes:: ; cd5c
+ ds 1
wMonPartySpriteSpecies:: ; cd5d
ds 1
@@ -1010,6 +1064,8 @@ wTileMapBackup2:: ; cd81
; second buffer for temporarily saving and restoring current screen's tiles (e.g. if menus are drawn on top)
ds 20 * 18
+wNamingScreenNameLength:: ; cee9
+
wEvoOldSpecies:: ; cee9
wBuffer:: ; cee9
@@ -1022,12 +1078,23 @@ wLearningMovesFromDayCare:: ; cee9
; whether WriteMonMoves is being used to make a mon learn moves from day care
; non-zero if so
+wChangeMonPicEnemyTurnSpecies:: ; cee9
+
wHPBarMaxHP:: ; cee9
ds 1
+wNamingScreenSubmitName:: ; ceea
+; non-zero when the player has chosen to submit the name
+
+wChangeMonPicPlayerTurnSpecies:: ; ceea
+
wEvoNewSpecies:: ; ceea
ds 1
+wAlphabetCase:: ; ceeb
+; 0 = upper case
+; 1 = lower case
+
wEvoMonTileOffset:: ; ceeb
wHPBarOldHP:: ; ceeb
@@ -1036,13 +1103,17 @@ wHPBarOldHP:: ; ceeb
wEvoCancelled:: ; ceec
ds 1
+wNamingScreenLetter:: ; ceed
+
wHPBarNewHP:: ; ceed
ds 2
wHPBarDelta:: ; ceef
ds 1
-wcef0:: ds 1 ; used with HP bar stuff, probably used with wBuffer too.
-wcef1:: ds 12 ; same case as above
+wHPBarTempHP:: ; cef0
+ ds 2
+
+ ds 11
wHPBarHPDifference:: ; cefd
ds 1
@@ -1313,9 +1384,16 @@ wTrainerPicPointer:: ; d033
ds 2
ds 1
wd036:: ds 16 ; used as a temporary buffer to print "XXX learned YYY"
-wd046:: ds 1 ; used with trainer pointer stuff (not exactly sure, but the label is incremented and loaded with a value, so wd047 is accessed)
-wd047:: ds 1 ; used with unloading trainer data?
-wd048:: ds 2 ; used as a pointer for missable object loop
+
+wTrainerBaseMoney:: ; d046
+; 2-byte BCD number
+; money received after battle = base money × level of highest-level enemy mon
+ ds 2
+
+wMissableObjectCounter:: ; d048
+ ds 1
+
+ ds 1
W_TRAINERNAME:: ; d04a
; 13 bytes for the letters of the opposing trainer
@@ -1324,6 +1402,7 @@ W_TRAINERNAME:: ; d04a
ds 13
W_ISINBATTLE:: ; d057
+; lost battle, this is -1
; no battle, this is 0
; wild battle, this is 1
; trainer battle, this is 2
@@ -1470,10 +1549,16 @@ wEscapedFromBattle::
; non-zero when an item or move that allows escape from battle was used
ds 1
-wAmountMoneyWon:: ; wd079 - wd07b
-wd079:: ds 1 ; used as a value to print the money won from a battle, as well as a misc. value in seafoam
-wd07a:: ds 1 ; same case as above
-wd07b:: ds 1 ; used as a buffer to convert the money won from a battle into BCD
+wAmountMoneyWon:: ; d079
+; 3-byte BCD number
+
+wObjectToHide:: ; d079
+ ds 1
+
+wObjectToShow:: ; d07a
+ ds 1
+
+ ds 1
W_ANIMATIONID:: ; d07c
; ID number of the current battle animation
@@ -1508,7 +1593,8 @@ W_FBTILECOUNTER:: ; d084
; counts how many tiles of the current frame block have been drawn
ds 1
-wd085:: ds 1 ; used with animating water/flowers
+wMovingBGTilesCounter2:: ; d085
+ ds 1
W_SUBANIMFRAMEDELAY:: ; d086
; duration of each frame of the current subanimation in terms of screen refreshes
@@ -1526,12 +1612,34 @@ W_NUMFBTILES:: ; d089
; 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
@@ -1573,13 +1681,17 @@ W_SUBANIMSUBENTRYADDR:: ; d096
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)
@@ -1597,9 +1709,28 @@ W_FBMODE:: ; d09e
; 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
@@ -1728,7 +1859,8 @@ wMoveNum:: ; d0e0
wMovesString:: ; d0e1
ds 56
-wd119:: ds 1 ; written to from W_CURMAPTILESET but never read
+wUnusedD119:: ; d119
+ ds 1
wWalkBikeSurfStateCopy:: ; d11a
; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything
@@ -1738,18 +1870,39 @@ wInitListType:: ; d11b
; the type of list for InitList to init
ds 1
-wd11c:: ds 1 ; temp storage value for catching pokemon
-wd11d:: ds 1 ; used with battle switchout and testing if the enemy mon fainted
+wCapturedMonSpecies:: ; d11c
+; 0 if no mon was captured
+ ds 1
+
+wFirstMonsNotOutYet:: ; d11d
+; Non-zero when the first player mon and enemy mon haven't been sent out yet.
+; It prevents the game from asking if the player wants to choose another mon
+; when the enemy sends out their first mon and suppresses the "no will to fight"
+; message when the game searches for the first non-fainted mon in the party,
+; which will be the first mon sent out.
+ ds 1
+
wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits
-wd11f:: ds 1 ; used when running from battle and PartyMenuInit
+
+wForcePlayerToChooseMon:: ; d11f
+; When this value is non-zero, the player isn't allowed to exit the party menu
+; by pressing B and not choosing a mon.
+ ds 1
wNumRunAttempts::
; number of times the player has tried to run from battle
ds 1
-wd121:: ds 1 ; used with evolving pokemon
-wd122:: ds 2 ; saved ROM bank number for vblank
-wIsKeyItem:: ds 1 ; d124
+wEvolutionOccurred:: ; d121
+ ds 1
+
+wVBlankSavedROMBank:: ; d122
+ ds 1
+
+ ds 1
+
+wIsKeyItem:: ; d124
+ ds 1
wTextBoxID:: ; d125
ds 1
@@ -1790,12 +1943,36 @@ wMenuExitMethod:: ; d12e
; $02 = the user pressed B or pressed A with the second menu item selected
ds 1
-wd12f:: ds 1 ; used in some coordinatestuff, npc pathstuff, and game corner prize stuff
-wd130:: ds 1 ; saved value of screen Y coord of trainer sprite
-wd131:: ds 1 ; saved value of screen X coord of trainer sprite
-wd132:: ds 1 ; saved value of map Y coordinate of trainer sprite (not sure for purpose)
-wd133:: ds 6 ; saved value of map X coordinate of trainer sprite
-wd139:: ds 1 ; backup of selected menu entry for game corner prizes
+wDungeonWarpDataEntrySize:: ; d12f
+; the size is always 6, so they didn't need a variable in RAM for this
+
+wWhichPewterGuy:: ; d12f
+; 0 = museum guy
+; 1 = gym guy
+
+wWhichPrizeWindow:: ; d12f
+; there are 3 windows, from 0 to 2
+
+wGymGateTileBlock:: ; d12f
+; a horizontal or vertical gate block
+ ds 1
+
+wSavedSpriteScreenY:: ; d130
+ ds 1
+
+wSavedSpriteScreenX:: ; d131
+ ds 1
+
+wSavedSpriteMapY:: ; d132
+ ds 1
+
+wSavedSpriteMapX:: ; d133
+ ds 1
+
+ ds 5
+
+wWhichPrize:: ; d139
+ ds 1
wIgnoreInputCounter:: ; d13a
; counts downward each frame
@@ -1822,9 +1999,16 @@ W_PRIZE3:: ; d13f
wSerialRandomNumberListBlock:: ; d141
; the first 7 bytes are the preamble
-wd141:: ds 2 ; prices for prizes
-wd143:: ds 2 ; prices for prizes
-wd145:: ds 3 ; prices for prizes
+wPrize1Price:: ; d141
+ ds 2
+
+wPrize2Price:: ; d143
+ ds 2
+
+wPrize3Price:: ; d145
+ ds 2
+
+ ds 1
wLinkBattleRandomNumberList:: ; d148
; shared list of 9 random numbers, indexed by wLinkBattleRandomNumberListIndex
@@ -1833,11 +2017,23 @@ wLinkBattleRandomNumberList:: ; d148
wSerialPlayerDataBlock:: ; d152
; the first 6 bytes are the preamble
-wd152:: ds 1 ; used as a temporary storage for the item used
-wd153:: ds 3 ; written to during pokedex flag action but doesn't seem to be read from
-wd156:: ds 1 ; evolution stone ID used
-wd157:: ds 1 ; used with oak's lab script (related to npc movement directions), possibly indirectly accessed with values below
+wPseudoItemID:: ; d152
+; When a real item is being used, this is 0.
+; When a move is acting as an item, this is the ID of the item it's acting as.
+; For example, out-of-battle Dig is executed using a fake Escape Rope item. In
+; that case, this would be ESCAPE_ROPE.
+ ds 1
+wUnusedD153:: ; d153
+ ds 1
+
+ ds 2
+
+wEvoStoneItemID:: ; d156
+ ds 1
+
+wSavedNPCMovementDirections2Index:: ; d157
+ ds 1
wPlayerName:: ; d158
ds 11
@@ -1940,7 +2136,8 @@ W_XBLOCKCOORD:: ; d364
wLastMap:: ; d365
ds 1
-wd366:: ds 1 ; W_CURMAPWIDTH of the last outdoor map visited when entering an inside map
+wUnusedD366:: ; d366
+ ds 1
W_CURMAPTILESET:: ; d367
ds 1
@@ -2192,7 +2389,8 @@ wNumHoFTeams:: ; d5a2
; number of HOF teams
ds 1
-wd5a3:: ds 1 ; unused? (written to when loading map data)
+wUnusedD5A3:: ; d5a3
+ ds 1
wPlayerCoins:: ; d5a4
ds 2 ; BCD
@@ -2483,7 +2681,8 @@ wDestinationMap:: ; d71a
; destination map (for certain types of special warps, not ordinary walking)
ds 1
-wd71b:: ds 1 ; written to but doesn't seem to be read
+wUnusedD71B:: ; d71b
+ ds 1
wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c
; used to store the tile in front of the boulder when trying to push a boulder
@@ -2498,7 +2697,10 @@ wWhichDungeonWarp:: ; d71e
; which dungeon warp within the source map was used
ds 1
-wd71f:: ds 9 ; used with card key
+wUnusedD71F:: ; d71f
+ ds 1
+
+ ds 8
wd728::
; bit 0: using Strength outside of battle
@@ -2506,7 +2708,12 @@ wd728::
ds 1
-wd72a:: ds 2 ; flags for if a gym is beaten, also used to determine whether to display your name on the gym statues
+wBeatGymFlags:: ; d72a
+; redundant because it matches W_OBTAINEDBADGES
+; used to determine whether to show name on statue and in two NPC text scripts
+ ds 1
+
+ ds 1
wd72c:: ; d72c
; bit 0: if not set, the 3 minimum steps between random battles have passed
@@ -2565,8 +2772,13 @@ wCompletedInGameTradeFlags:: ; d737
ds 2
-wd73b:: ds 1 ; used with elevator warps
-wd73c:: ds 3 ; also used with elevator warps
+wWarpedFromWhichWarp:: ; d73b
+ ds 1
+
+wWarpedFromWhichMap:: ; d73c
+ ds 1
+
+ ds 2
wCardKeyDoorY:: ; d73f
ds 1
@@ -2576,9 +2788,13 @@ wCardKeyDoorX:: ; d740
ds 2
-wd743:: ds 1 ; used with surge gym trash cans
-wd744:: ds 3 ; also used with surge gym trash cans
+wFirstLockTrashCanIndex:: ; d743
+ ds 1
+wSecondLockTrashCanIndex:: ; d743
+ ds 1
+
+ ds 2
wEventFlags:: ; d747
ds 320
@@ -2611,7 +2827,12 @@ W_TRAINERHEADERPTR:: ; da30
ds 6
-wda38:: ds 1 ; used with cinnabar gym questions and pokemon tower 7F?
+wOpponentAfterWrongAnswer:: ; da38
+; the trainer the player must face after getting a wrong answer in the Cinnabar
+; gym quiz
+
+wUnusedDA38:: ; da38
+ ds 1
W_CURMAPSCRIPT:: ; da39
; index of current map script, mostly used as index for function pointer array