summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authordannye <corrnondacqb@yahoo.com>2016-01-12 18:45:02 -0600
committerdannye <corrnondacqb@yahoo.com>2016-01-12 18:45:02 -0600
commit5914540ba780d7936fd6624d6fde2d67a9f7a773 (patch)
treea1ce27018f39d98f49d89468df426d0291e18560 /engine
parentccf4fe54a8e444aaf966fac7b38bc9452c494222 (diff)
parent8a5a7d8e68538b727e0c166488265f395603366e (diff)
Merge branch 'master' of https://github.com/pret/pokered into rgbgfxrgbgfx
Diffstat (limited to 'engine')
-rwxr-xr-xengine/HoF_room_pc.asm3
-rwxr-xr-xengine/battle/animations.asm254
-rwxr-xr-xengine/battle/bank_e_misc.asm4
-rw-r--r--engine/battle/battle_transitions.asm15
-rw-r--r--engine/battle/common_text.asm10
-rwxr-xr-xengine/battle/core.asm994
-rw-r--r--engine/battle/decrement_pp.asm8
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm21
-rwxr-xr-xengine/battle/end_of_battle.asm10
-rw-r--r--engine/battle/experience.asm22
-rw-r--r--engine/battle/get_trainer_name.asm8
-rw-r--r--engine/battle/ghost_marowak_anim.asm12
-rw-r--r--engine/battle/init_battle_variables.asm16
-rw-r--r--engine/battle/moveEffects/conversion_effect.asm4
-rw-r--r--engine/battle/moveEffects/drain_hp_effect.asm10
-rw-r--r--engine/battle/moveEffects/focus_energy_effect.asm4
-rw-r--r--engine/battle/moveEffects/haze_effect.asm8
-rw-r--r--engine/battle/moveEffects/heal_effect.asm4
-rw-r--r--engine/battle/moveEffects/leech_seed_effect.asm6
-rw-r--r--engine/battle/moveEffects/mist_effect.asm4
-rw-r--r--engine/battle/moveEffects/one_hit_ko_effect.asm6
-rw-r--r--engine/battle/moveEffects/paralyze_effect.asm6
-rw-r--r--engine/battle/moveEffects/pay_day_effect.asm2
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm8
-rw-r--r--engine/battle/moveEffects/reflect_light_screen_effect.asm8
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm6
-rw-r--r--engine/battle/moveEffects/transform_effect.asm20
-rw-r--r--engine/battle/print_type.asm8
-rwxr-xr-xengine/battle/read_trainer_party.asm24
-rwxr-xr-xengine/battle/safari_zone.asm2
-rw-r--r--engine/battle/save_trainer_name.asm54
-rw-r--r--engine/battle/scale_sprites.asm8
-rw-r--r--engine/battle/scroll_draw_trainer_pic.asm4
-rw-r--r--engine/battle/trainer_ai.asm48
-rw-r--r--engine/battle/wild_encounters.asm20
-rwxr-xr-xengine/cable_club.asm58
-rwxr-xr-xengine/clear_save.asm2
-rwxr-xr-xengine/evolution.asm22
-rwxr-xr-xengine/evos_moves.asm28
-rwxr-xr-xengine/experience.asm2
-rwxr-xr-xengine/game_corner_slots2.asm2
-rwxr-xr-xengine/gamefreak.asm12
-rwxr-xr-xengine/give_pokemon.asm4
-rwxr-xr-xengine/hall_of_fame.asm30
-rwxr-xr-xengine/hidden_object_functions14.asm2
-rwxr-xr-xengine/hidden_object_functions17.asm118
-rwxr-xr-xengine/hidden_object_functions18.asm4
-rwxr-xr-xengine/hidden_object_functions3.asm6
-rwxr-xr-xengine/hidden_object_functions7.asm56
-rwxr-xr-xengine/in_game_trades.asm22
-rwxr-xr-xengine/intro.asm68
-rwxr-xr-xengine/items/itemfinder.asm10
-rwxr-xr-xengine/items/items.asm635
-rwxr-xr-xengine/items/tms.asm2
-rwxr-xr-xengine/learn_move.asm42
-rwxr-xr-xengine/load_pokedex_tiles.asm2
-rw-r--r--engine/menu/bills_pc.asm16
-rwxr-xr-xengine/menu/diploma.asm4
-rwxr-xr-xengine/menu/league_pc.asm12
-rwxr-xr-xengine/menu/main_menu.asm35
-rwxr-xr-xengine/menu/naming_screen.asm27
-rwxr-xr-xengine/menu/party_menu.asm26
-rwxr-xr-xengine/menu/pokedex.asm23
-rwxr-xr-xengine/menu/prize_menu.asm20
-rwxr-xr-xengine/menu/start_sub_menus.asm34
-rwxr-xr-xengine/menu/status_screen.asm25
-rwxr-xr-xengine/mon_party_sprites.asm14
-rwxr-xr-xengine/oak_speech.asm26
-rwxr-xr-xengine/oak_speech2.asm8
-rwxr-xr-xengine/overworld/card_key.asm12
-rwxr-xr-xengine/overworld/cinnabar_lab.asm26
-rwxr-xr-xengine/overworld/cut.asm12
-rwxr-xr-xengine/overworld/doors.asm2
-rwxr-xr-xengine/overworld/elevator.asm2
-rwxr-xr-xengine/overworld/emotion_bubbles.asm2
-rwxr-xr-xengine/overworld/healing_machine.asm42
-rwxr-xr-xengine/overworld/hidden_items.asm4
-rwxr-xr-xengine/overworld/hidden_objects.asm14
-rw-r--r--engine/overworld/is_player_just_outside_map.asm8
-rw-r--r--engine/overworld/item.asm4
-rwxr-xr-xengine/overworld/ledges.asm5
-rwxr-xr-xengine/overworld/map_sprites.asm28
-rw-r--r--engine/overworld/movement.asm29
-rwxr-xr-xengine/overworld/npc_movement.asm24
-rwxr-xr-xengine/overworld/oaks_aide.asm34
-rwxr-xr-xengine/overworld/pewter_guys.asm4
-rwxr-xr-xengine/overworld/player_animations.asm4
-rwxr-xr-xengine/overworld/pokecenter.asm12
-rwxr-xr-xengine/overworld/ssanne.asm3
-rwxr-xr-xengine/overworld/trainers.asm2
-rwxr-xr-xengine/palettes.asm383
-rwxr-xr-xengine/play_time.asm26
-rwxr-xr-xengine/pokedex_rating.asm32
-rwxr-xr-xengine/predefs.asm4
-rwxr-xr-xengine/predefs17_2.asm4
-rwxr-xr-xengine/predefs7.asm4
-rwxr-xr-xengine/save.asm66
-rwxr-xr-xengine/slot_machine.asm30
-rwxr-xr-xengine/titlescreen.asm33
-rwxr-xr-xengine/town_map.asm37
-rwxr-xr-xengine/trade.asm62
101 files changed, 2095 insertions, 1897 deletions
diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm
index 90b9450b..847ff3d1 100755
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -246,7 +246,7 @@ Credits: ; 7418e (1d:418e)
pop de
ld de, TheEndGfx
ld hl, vChars2 + $600
- lb bc, BANK(TheEndGfx), $0a
+ lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10
call CopyVideoData
coord hl, 4, 8
ld de, TheEndTextString
@@ -267,3 +267,4 @@ INCLUDE "text/credits_text.asm"
TheEndGfx: ; 7473e (1d:473e) (7473f on blue)
INCBIN "gfx/theend.2bpp"
+TheEndGfxEnd:
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 424190d3..31b490f3 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -4,18 +4,18 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld l,c
ld h,b
ld a,[hli]
- ld [W_NUMFBTILES],a
- ld a,[W_FBDESTADDR + 1]
+ ld [wNumFBTiles],a
+ ld a,[wFBDestAddr + 1]
ld e,a
- ld a,[W_FBDESTADDR]
+ ld a,[wFBDestAddr]
ld d,a
xor a
- ld [W_FBTILECOUNTER],a ; loop counter
+ ld [wFBTileCounter],a ; loop counter
.loop
- ld a,[W_FBTILECOUNTER]
+ ld a,[wFBTileCounter]
inc a
- ld [W_FBTILECOUNTER],a
- ld a,[W_SUBANIMTRANSFORM]
+ ld [wFBTileCounter],a
+ ld a,[wSubAnimTransform]
dec a
jr z,.flipHorizontalAndVertical ; 1
dec a
@@ -23,15 +23,15 @@ DrawFrameBlock: ; 78000 (1e:4000)
dec a
jr z,.flipBaseCoords ; 3
.noTransformation
- ld a,[W_BASECOORDY]
+ ld a,[wBaseCoordY]
add [hl]
ld [de],a ; store Y
inc hl
inc de
- ld a,[W_BASECOORDX]
+ ld a,[wBaseCoordX]
jr .finishCopying
.flipBaseCoords
- ld a,[W_BASECOORDY]
+ ld a,[wBaseCoordY]
ld b,a
ld a,136
sub b ; flip Y base coordinate
@@ -39,11 +39,11 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld [de],a ; store Y
inc hl
inc de
- ld a,[W_BASECOORDX]
+ ld a,[wBaseCoordX]
ld b,a
ld a,168
sub b ; flip X base coordinate
-.finishCopying ; finish copying values to OAM (when [W_SUBANIMTRANSFORM] not 1 or 2)
+.finishCopying ; finish copying values to OAM (when [wSubAnimTransform] not 1 or 2)
add [hl] ; X offset
ld [de],a ; store X
inc hl
@@ -57,7 +57,7 @@ DrawFrameBlock: ; 78000 (1e:4000)
inc de
jp .nextTile
.flipHorizontalAndVertical
- ld a,[W_BASECOORDY]
+ ld a,[wBaseCoordY]
add [hl] ; Y offset
ld b,a
ld a,136
@@ -65,7 +65,7 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld [de],a ; store Y
inc hl
inc de
- ld a,[W_BASECOORDX]
+ ld a,[wBaseCoordX]
add [hl] ; X offset
ld b,a
ld a,168
@@ -95,13 +95,13 @@ DrawFrameBlock: ; 78000 (1e:4000)
inc de
jp .nextTile
.flipHorizontalTranslateDown
- ld a,[W_BASECOORDY]
+ ld a,[wBaseCoordY]
add [hl]
add a,40 ; translate Y coordinate downwards
ld [de],a ; store Y
inc hl
inc de
- ld a,[W_BASECOORDX]
+ ld a,[wBaseCoordX]
add [hl]
ld b,a
ld a,168
@@ -125,47 +125,47 @@ DrawFrameBlock: ; 78000 (1e:4000)
ld [de],a
inc de
.nextTile
- ld a,[W_FBTILECOUNTER]
+ ld a,[wFBTileCounter]
ld c,a
- ld a,[W_NUMFBTILES]
+ ld a,[wNumFBTiles]
cp c
jp nz,.loop ; go back up if there are more tiles to draw
.afterDrawingTiles
- ld a,[W_FBMODE]
+ ld a,[wFBMode]
cp a,2
jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
- ld a,[W_SUBANIMFRAMEDELAY]
+ ld a,[wSubAnimFrameDelay]
ld c,a
call DelayFrames
- ld a,[W_FBMODE]
+ ld a,[wFBMode]
cp a,3
jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer
cp a,4
jr z,.done ; skip cleaning OAM buffer and don't advance the frame block destination address
- ld a,[W_ANIMATIONID]
+ ld a,[wAnimationID]
cp a,GROWL
jr z,.resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
ld hl,wOAMBuffer ; OAM buffer
ld a,l
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,h
- ld [W_FBDESTADDR],a ; set destination address to beginning of OAM buffer
+ ld [wFBDestAddr],a ; set destination address to beginning of OAM buffer
ret
.advanceFrameBlockDestAddr
ld a,e
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,d
- ld [W_FBDESTADDR],a
+ ld [wFBDestAddr],a
.done
ret
PlayAnimation: ; 780f1 (1e:40f1)
xor a
ld [$FF8B],a ; it looks like nothing reads this
- ld [W_SUBANIMTRANSFORM],a
- ld a,[W_ANIMATIONID] ; get animation number
+ ld [wSubAnimTransform],a
+ ld a,[wAnimationID] ; get animation number
dec a
ld l,a
ld h,0
@@ -217,7 +217,7 @@ PlayAnimation: ; 780f1 (1e:40f1)
.playSubanimation
ld c,a
and a,%00111111
- ld [W_SUBANIMFRAMEDELAY],a
+ ld [wSubAnimFrameDelay],a
xor a
sla c
rla
@@ -235,9 +235,9 @@ PlayAnimation: ; 780f1 (1e:40f1)
ld de,SubanimationPointers
add hl,de
ld a,l
- ld [W_SUBANIMADDRPTR],a
+ ld [wSubAnimAddrPtr],a
ld a,h
- ld [W_SUBANIMADDRPTR + 1],a
+ ld [wSubAnimAddrPtr + 1],a
ld l,c
ld h,b
push hl
@@ -257,9 +257,9 @@ PlayAnimation: ; 780f1 (1e:40f1)
ret
LoadSubanimation: ; 7817c (1e:417c)
- ld a,[W_SUBANIMADDRPTR + 1]
+ ld a,[wSubAnimAddrPtr + 1]
ld h,a
- ld a,[W_SUBANIMADDRPTR]
+ ld a,[wSubAnimAddrPtr]
ld l,a
ld a,[hli]
ld e,a
@@ -268,7 +268,7 @@ LoadSubanimation: ; 7817c (1e:417c)
ld a,[de]
ld b,a
and a,31
- ld [W_SUBANIMCOUNTER],a ; number of frame blocks
+ ld [wSubAnimCounter],a ; number of frame blocks
ld a,b
and a,%11100000
cp a,5 << 5 ; is subanimation type 5?
@@ -282,12 +282,12 @@ LoadSubanimation: ; 7817c (1e:417c)
; place the upper 3 bits of a into bits 0-2 of a before storing
srl a
swap a
- ld [W_SUBANIMTRANSFORM],a
+ ld [wSubAnimTransform],a
cp a,4 ; is the animation reversed?
ld hl,0
jr nz,.storeSubentryAddr
; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
ld bc,3
.loop
@@ -298,9 +298,9 @@ LoadSubanimation: ; 7817c (1e:417c)
inc de
add hl,de
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ret
; called if the subanimation type is not 5
@@ -384,7 +384,7 @@ MoveAnimation: ; 78d5e (1e:4d5e)
push af
call WaitForSoundToFinish
call SetAnimationPalette
- ld a,[W_ANIMATIONID]
+ ld a,[wAnimationID]
and a
jr z,.AnimationFinished
@@ -397,7 +397,7 @@ MoveAnimation: ; 78d5e (1e:4d5e)
.MoveAnimation
; check if battle animations are disabled in the options
- ld a,[W_OPTIONS]
+ ld a,[wOptions]
bit 7,a
jr nz,.AnimationsDisabled
call ShareMoveAnimations
@@ -411,9 +411,9 @@ MoveAnimation: ; 78d5e (1e:4d5e)
.AnimationFinished
call WaitForSoundToFinish
xor a
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld [wUnusedD09B],a
- ld [W_SUBANIMTRANSFORM],a
+ ld [wSubAnimTransform],a
dec a
ld [wAnimSoundID],a
pop af
@@ -430,7 +430,7 @@ ShareMoveAnimations: ; 78da6 (1e:4da6)
; opponent’s turn
- ld a,[W_ANIMATIONID]
+ ld a,[wAnimationID]
cp a,AMNESIA
ld b,CONF_ANIM
@@ -442,7 +442,7 @@ ShareMoveAnimations: ; 78da6 (1e:4da6)
.Replace
ld a,b
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
ret
PlayApplyingAttackAnimation: ; 78dbd (1e:4dbd)
@@ -529,7 +529,7 @@ SetAnimationPalette: ; 78e23 (1e:4e23)
ld a, $f0
ld [wAnimPalette], a
ld b, $e4
- ld a, [W_ANIMATIONID]
+ ld a, [wAnimationID]
cp TRADE_BALL_DROP_ANIM
jr c, .next
cp TRADE_BALL_POOF_ANIM + 1
@@ -558,12 +558,12 @@ PlaySubanimation: ; 78e53 (1e:4e53)
.skipPlayingSound
ld hl,wOAMBuffer ; base address of OAM buffer
ld a,l
- ld [W_FBDESTADDR + 1],a
+ ld [wFBDestAddr + 1],a
ld a,h
- ld [W_FBDESTADDR],a
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld [wFBDestAddr],a
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
.loop
push hl
@@ -585,24 +585,24 @@ PlaySubanimation: ; 78e53 (1e:4e53)
add hl,de
add hl,de
ld a,[hli]
- ld [W_BASECOORDY],a
+ ld [wBaseCoordY],a
ld a,[hl]
- ld [W_BASECOORDX],a
+ ld [wBaseCoordX],a
pop hl
inc hl
ld a,[hl] ; frame block mode
- ld [W_FBMODE],a
+ ld [wFBMode],a
call DrawFrameBlock
call DoSpecialEffectByAnimationId ; run animation-specific function (if there is one)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret z
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
- ld a,[W_SUBANIMTRANSFORM]
+ ld a,[wSubAnimTransform]
cp a,4 ; is the animation reversed?
ld bc,3
jr nz,.nextSubanimationSubentry
@@ -610,9 +610,9 @@ PlaySubanimation: ; 78e53 (1e:4e53)
.nextSubanimationSubentry
add hl,bc
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
jp .loop
AnimationCleanOAM: ; 78ec8 (1e:4ec8)
@@ -634,7 +634,7 @@ DoSpecialEffectByAnimationId: ; 78ed7 (1e:4ed7)
push hl
push de
push bc
- ld a,[W_ANIMATIONID]
+ ld a,[wAnimationID]
ld hl,AnimationIdSpecialEffects
ld de,3
call IsInArray
@@ -737,21 +737,21 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
xor a,%00111100 ; complement colors 1 and 2
ld [rOBP0],a
.skipFlashingEffect
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,11 ; is it the beginning of the subanimation?
jr nz,.skipPlayingSound
; if it is the beginning of the subanimation, play a sound
ld a,SFX_BALL_TOSS
call PlaySound
.skipPlayingSound
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
cp a,02 ; is it a trainer battle?
jr z,.isTrainerBattle
ld a,[wd11e]
cp a,$10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,3
jr z,.moveGhostMarowakLeft
cp a,2
@@ -772,18 +772,18 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
dec b
jr nz,.loop
ld a,%00001000
- ld [$ff10],a ; Channel 1 sweep register
+ ld [rNR10],a ; Channel 1 sweep register
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,3
ret nz
dec a
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret
DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,4 ; is it the beginning of a shake?
jr nz,.skipPlayingSound
; if it is the beginning of a shake, play a sound and wait 2/3 of a second
@@ -792,7 +792,7 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
ld c,40
call DelayFrames
.skipPlayingSound
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
ret nz
; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation
@@ -801,30 +801,30 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
ld [wNumShakes],a
ret z
; if there are shakes left, restart the subanimation
- ld a,[W_SUBANIMSUBENTRYADDR]
+ ld a,[wSubAnimSubEntryAddr]
ld l,a
- ld a,[W_SUBANIMSUBENTRYADDR + 1]
+ ld a,[wSubAnimSubEntryAddr + 1]
ld h,a
ld de,-(4 * 3) ; 4 subentries and 3 bytes per subentry
add hl,de
ld a,l
- ld [W_SUBANIMSUBENTRYADDR],a
+ ld [wSubAnimSubEntryAddr],a
ld a,h
- ld [W_SUBANIMSUBENTRYADDR + 1],a
+ ld [wSubAnimSubEntryAddr + 1],a
ld a,5 ; number of subentries in the ball shaking subanimation plus one
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ret
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects: ; 78fce (1e:4fce)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,5
ret nz
ld a,SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,12
ret nc
cp a,8
@@ -840,21 +840,21 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
and a,7 ; is the subanimation counter exactly 8?
call z,AnimationFlashScreen ; if so, flash the screen
ret
; flashes the screen if the subanimation counter is divisible by 4
FlashScreenEveryFourFrameBlocks: ; 79000 (1e:5000)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
and a,3
call z,AnimationFlashScreen
ret
; used for Explosion and Selfdestruct
DoExplodeSpecialEffects: ; 79009 (1e:5009)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,1 ; is it the end of the subanimation?
jr nz,FlashScreenEveryFourFrameBlocks
; if it's the end of the subanimation, make the attacking pokemon disappear
@@ -863,7 +863,7 @@ DoExplodeSpecialEffects: ; 79009 (1e:5009)
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects: ; 79016 (1e:5016)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,13
jp z,AnimationFlashScreen
cp a,9
@@ -877,7 +877,7 @@ DoBlizzardSpecialEffects: ; 79016 (1e:5016)
; flashes the screen at 3 points in the subanimation
; unused
FlashScreenUnused: ; 7902e (1e:502e)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,14
jp z,AnimationFlashScreen
cp a,9
@@ -888,7 +888,7 @@ FlashScreenUnused: ; 7902e (1e:502e)
; function to make the pokemon disappear at the beginning of the animation
TradeHidePokemon: ; 79041 (1e:5041)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,6
ret nz
ld a,2 * SCREEN_WIDTH + 7
@@ -896,7 +896,7 @@ TradeHidePokemon: ; 79041 (1e:5041)
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball: ; 7904c (1e:504c)
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
cp a,1
ret nz
; if it's the end of the animation, make the ball jump up
@@ -976,7 +976,7 @@ DoGrowlSpecialEffects: ; 790bc (1e:50bc)
ld de,wOAMBuffer + $10
ld bc,$10
call CopyData ; copy the musical note graphic
- ld a,[W_SUBANIMCOUNTER]
+ ld a,[wSubAnimCounter]
dec a
call z,AnimationCleanOAM ; clean up at the end of the subanimation
ret
@@ -984,7 +984,7 @@ DoGrowlSpecialEffects: ; 790bc (1e:50bc)
; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations
TailWhipAnimationUnused: ; 790d0 (1e:50d0)
ld a,1
- ld [W_SUBANIMCOUNTER],a
+ ld [wSubAnimCounter],a
ld c,20
jp DelayFrames
@@ -1243,17 +1243,17 @@ AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
call LoadAnimationTileset
ld d, 32
ld a, -16
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld a, $71
ld [wDropletTile], a
.loop
ld a, 16
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, 0
ld [wUnusedD08A], a
call _AnimationWaterDroplets
ld a, 24
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, 32
ld [wUnusedD08A], a
call _AnimationWaterDroplets
@@ -1264,24 +1264,24 @@ AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
_AnimationWaterDroplets: ; 79246 (1e:5246)
ld hl, wOAMBuffer
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld [hli], a ; Y
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add 27
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld [hli], a ; X
ld a, [wDropletTile]
ld [hli], a ; tile
xor a
ld [hli], a ; attribute
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
cp 144
jr c, .loop
sub 168
- ld [W_BASECOORDX], a
- ld a, [W_BASECOORDY]
+ ld [wBaseCoordX], a
+ ld a, [wBaseCoordY]
add 16
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
cp 112
jr c, .loop
call AnimationCleanOAM
@@ -1387,14 +1387,14 @@ 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 [wBaseCoordX], a
ld a, $30
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld hl, wOAMBuffer
ld d, 0
ld c, 7
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld e, a
ld b, 5
.innerLoop
@@ -1406,21 +1406,21 @@ ShakeEnemyHUD_WritePlayerMonPicOAM: ; 792fd (1e:52fd)
ret z
inc d
inc d
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add 8
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
jr .loop
BattleAnimWriteOAMEntry: ; 79329 (1e:5329)
; Y coordinate = e (increased by 8 each call, before the write to OAM)
-; X coordinate = [W_BASECOORDX]
+; X coordinate = [wBaseCoordX]
; tile = d
; attributes = 0
ld a, e
add 8
ld e, a
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld [hli], a
ld a, d
ld [hli], a
@@ -1749,9 +1749,9 @@ AnimationShootBallsUpward: ; 794f9 (1e:54f9)
lb bc, 6 * 8, 5 * 8
.next
ld a, b
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, c
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
lb bc, 5, 1
call _AnimationShootBallsUpward
jp AnimationCleanOAM
@@ -1765,7 +1765,7 @@ _AnimationShootBallsUpward: ; 79517 (1e:5517)
ld d, $7a ; ball tile
ld hl, wOAMBuffer
push bc
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld e, a
.initOAMLoop
call BattleAnimWriteOAMEntry
@@ -1779,7 +1779,7 @@ _AnimationShootBallsUpward: ; 79517 (1e:5517)
push bc
ld hl, wOAMBuffer
.innerLoop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
add 8
ld e, a
ld a, [hl]
@@ -1819,11 +1819,11 @@ AnimationShootManyBallsUpward: ; 79566 (1e:5566)
ld [wSavedY], a
.loop
ld a, [wSavedY]
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, [hli]
cp $ff
jp z, AnimationCleanOAM
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
lb bc, 4, 1
push hl
call _AnimationShootBallsUpward
@@ -2096,10 +2096,10 @@ HideSubstituteShowMonAnim: ; 79747 (1e:5747)
ld a, [H_WHOSETURN]
and a
ld hl, wPlayerMonMinimized
- ld a, [W_PLAYERBATTSTATUS2]
+ ld a, [wPlayerBattleStatus2]
jr z, .next1
ld hl, wEnemyMonMinimized
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
.next1
push hl
; if the substitute broke, slide it down, else slide it offscreen horizontally
@@ -2150,7 +2150,7 @@ ChangeMonPic: ; 79793 (1e:5793)
ld [wcf91], a
ld [wd0b5], a
xor a
- ld [W_SPRITEFLIPPED], a
+ ld [wSpriteFlipped], a
call GetMonHeader
coord hl, 12, 0
call LoadFrontSpriteByMonIndex
@@ -2170,8 +2170,8 @@ ChangeMonPic: ; 79793 (1e:5793)
pop af
ld [wBattleMonSpecies2], a
.done
- ld b, $1
- jp GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ jp RunPaletteCommand
AnimationHideEnemyMonPic: ; 797d8 (1e:57d8)
; Hides the enemy mon's sprite
@@ -2196,7 +2196,7 @@ InitMultipleObjectsOAM: ; 797e8 (1e:57e8)
pop bc
xor a
ld e, a
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld hl, wOAMBuffer
.loop
call BattleAnimWriteOAMEntry
@@ -2335,26 +2335,26 @@ GetMoveSound: ; 7986f (1e:586f)
call GetCryData
ld b,a
pop hl
- ld a,[wc0f1]
+ ld a,[wFrequencyModifier]
add [hl]
- ld [wc0f1],a
+ ld [wFrequencyModifier],a
inc hl
- ld a,[wc0f2]
+ ld a,[wTempoModifier]
add [hl]
- ld [wc0f2],a
+ ld [wTempoModifier],a
jr .done
.NotCryMove
ld a,[hli]
- ld [wc0f1],a
+ ld [wFrequencyModifier],a
ld a,[hli]
- ld [wc0f2],a
+ ld [wTempoModifier],a
.done
ld a,b
ret
IsCryMove: ; 798ad (1e:58ad)
; set carry if the move animation involves playing a monster cry
- ld a,[W_ANIMATIONID]
+ ld a,[wAnimationID]
cp a,GROWL
jr z,.CryMove
cp a,ROAR
@@ -2953,10 +2953,10 @@ BattleAnimCopyTileMapToVRAM: ; 79e0d (1e:5e0d)
jp Delay3
TossBallAnimation: ; 79e16 (1e:5e16)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
cp a,2
jr z,.BlockBall ; if in trainer battle, play different animation
- ld a,[wd11e]
+ ld a,[wPokeBallAnimData]
ld b,a
; upper nybble: how many animations (from PokeBallAnimations) to play
@@ -2984,7 +2984,7 @@ TossBallAnimation: ; 79e16 (1e:5e16)
.done
ld a,b
.PlayNextAnimation
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
push bc
push hl
call PlayAnimation
@@ -3001,12 +3001,12 @@ TossBallAnimation: ; 79e16 (1e:5e16)
.BlockBall ; 5E55
ld a,TOSS_ANIM
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
call PlayAnimation
ld a,SFX_FAINT_THUD
call PlaySound
ld a,BLOCKBALL_ANIM
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
jp PlayAnimation
PlayApplyingAttackSound: ; 79e6a (1e:5e6a)
@@ -3029,8 +3029,8 @@ PlayApplyingAttackSound: ; 79e6a (1e:5e6a)
ld b, $1
ld c, SFX_NOT_VERY_EFFECTIVE
.playSound
- ld [wc0f1], a
+ ld [wFrequencyModifier], a
ld a, b
- ld [wc0f2], a
+ ld [wTempoModifier], a
ld a, c
jp PlaySound
diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm
index f47087d8..dc766f23 100755
--- a/engine/battle/bank_e_misc.asm
+++ b/engine/battle/bank_e_misc.asm
@@ -92,9 +92,9 @@ InitList: ; 39bd5 (e:5bd5)
ld a, h
ld [wListPointer + 1], a
ld a, e
- ld [wcf8d], a
+ ld [wUnusedCF8D], a
ld a, d
- ld [wcf8e], a
+ ld [wUnusedCF8D + 1], a
ld bc, ItemPrices
ld a, c
ld [wItemPrices], a
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index e9e247f9..545273ee 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -81,8 +81,8 @@ BattleTransitions: ; 709d2 (1c:49d2)
dw BattleTransition_Split ; %111
GetBattleTransitionID_WildOrTrainer: ; 709e2 (1c:49e2)
- ld a, [W_CUROPPONENT]
- cp $c8
+ ld a, [wCurOpponent]
+ cp 200
jr nc, .trainer
res 0, c
ret
@@ -105,7 +105,7 @@ GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef)
ld a, [hl]
add $3
ld e, a
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
sub e
jr nc, .highLevelEnemy
res 1, c
@@ -122,7 +122,7 @@ GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef)
; MANSION_1, SEAFOAM_ISLANDS_[2-5], POWER_PLANT, DIGLETTS_CAVE
; and SILPH_CO_[9-11]F as dungeon maps
GetBattleTransitionID_IsDungeonMap: ; 70a19 (1c:4a19)
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld e, a
ld hl, DungeonMaps1
.loop1
@@ -151,7 +151,7 @@ GetBattleTransitionID_IsDungeonMap: ; 70a19 (1c:4a19)
res 2, c
ret
-; GetBattleTransitionID_IsDungeonMap checks if W_CURMAP
+; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is equal to one of these maps
DungeonMaps1: ; 70a3f (1c:4a3f)
db VIRIDIAN_FOREST
@@ -160,7 +160,7 @@ DungeonMaps1: ; 70a3f (1c:4a3f)
db ROCK_TUNNEL_2
db $FF
-; GetBattleTransitionID_IsDungeonMap checks if W_CURMAP
+; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is in between or equal to each pair of maps
DungeonMaps2: ; 70a44 (1c:4a44)
; all MT_MOON maps
@@ -184,11 +184,12 @@ DungeonMaps2: ; 70a44 (1c:4a44)
LoadBattleTransitionTile: ; 70a4d (1c:4a4d)
ld hl, vChars1 + $7f0
ld de, BattleTransitionTile
- lb bc, BANK(BattleTransitionTile), $01
+ lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10
jp CopyVideoData
BattleTransitionTile: ; 70a59 (1c:4a59)
INCBIN "gfx/battle_transition.2bpp"
+BattleTransitionTileEnd:
BattleTransition_BlackScreen: ; 70a69 (1c:4a69)
ld a, $ff
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index a00e9d59..476284f0 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -1,8 +1,8 @@
PrintBeginningBattleText: ; 58d99 (16:4d99)
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr nz, .trainerBattle
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp POKEMONTOWER_3
jr c, .notPokemonTower
cp LAVENDER_HOUSE_1
@@ -11,7 +11,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99)
ld a, [wEnemyMonSpecies2]
call PlayCry
ld hl, WildMonAppearedText
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr z, .notFishing
ld hl, HookedMonAttackedText
@@ -61,9 +61,9 @@ PrintBeginningBattleText: ; 58d99 (16:4d99)
.playSFX
xor a
- ld [wc0f1], a
+ ld [wFrequencyModifier], a
ld a, $80
- ld [wc0f2], a
+ ld [wTempoModifier], a
ld a, SFX_SILPH_SCOPE
call PlaySound
jp WaitForSoundToFinish
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 65549f7b..c5c3774f 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -184,8 +184,8 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
inc a
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call HideSprites
jpab PrintBeginningBattleText
@@ -239,7 +239,7 @@ StartBattle: ; 3c11e (f:411e)
.foundFirstAliveEnemyMon
ld a, d
ld [wSerialExchangeNybbleReceiveData], a
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a ; is it a trainer battle?
call nz, EnemySendOutFirstMon ; if it is a trainer battle, send out enemy mon
ld c, 40
@@ -251,7 +251,7 @@ StartBattle: ; 3c11e (f:411e)
and a
jp z, HandlePlayerBlackOut ; jump if no mon is alive
call LoadScreenTilesFromBuffer1
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
and a ; is it a normal battle?
jp z, .playerSendOutFirstMon ; if so, send out player mon
; safari zone battle
@@ -261,7 +261,7 @@ StartBattle: ; 3c11e (f:411e)
ld a, [wActionResultOrTookBattleTurn]
and a ; was the item used successfully?
jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump?
- ld a, [W_NUMSAFARIBALLS]
+ ld a, [wNumSafariBalls]
and a
jr nz, .notOutOfSafariBalls
call LoadScreenTilesFromBuffer1
@@ -380,13 +380,13 @@ MainInBattleLoop: ; 3c233 (f:4233)
call SaveScreenTilesToBuffer1
xor a
ld [wFirstMonsNotOutYet], a
- ld a, [W_PLAYERBATTSTATUS2]
+ ld a, [wPlayerBattleStatus2]
and (1 << NeedsToRecharge) | (1 << UsingRage) ; check if the player is using Rage or needs to recharge
jr nz, .selectEnemyMove
; the player is not using Rage and doesn't need to recharge
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res Flinched, [hl] ; reset flinch bit
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
res Flinched, [hl] ; reset flinch bit
ld a, [hl]
and (1 << ThrashingAbout) | (1 << ChargingUp) ; check if the player is thrashing about or charging for an attack
@@ -400,10 +400,10 @@ MainInBattleLoop: ; 3c233 (f:4233)
ld a, [wBattleMonStatus]
and (1 << FRZ) | SLP ; is mon frozen or asleep?
jr nz, .selectEnemyMove ; if so, jump
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
and (1 << StoringEnergy) | (1 << UsingTrappingMove) ; check player is using Bide or using a multi-turn attack like wrap
jr nz, .selectEnemyMove ; if so, jump
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
bit UsingTrappingMove, a ; check if enemy is using a multi-turn attack like wrap
jr z, .selectPlayerMove ; if not, jump
; enemy is using a mult-turn attack like wrap, so player is trapped and cannot execute a move
@@ -416,7 +416,7 @@ MainInBattleLoop: ; 3c233 (f:4233)
jr nz, .selectEnemyMove
ld [wMoveMenuType], a
inc a
- ld [W_ANIMATIONID], a
+ ld [wAnimationID], a
xor a
ld [wMenuItemToSwap], a
call MoveSelectionMenu
@@ -441,7 +441,7 @@ MainInBattleLoop: ; 3c233 (f:4233)
sub $4
jr c, .noLinkBattle
; the link battle enemy has switched mons
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
bit UsingTrappingMove, a ; check if using multi-turn move like Wrap
jr z, .asm_3c2dd
ld a, [wPlayerMoveListIndex]
@@ -584,11 +584,11 @@ HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd)
pop hl
call HandlePoisonBurnLeechSeed_DecreaseOwnHP
.notBurnedOrPoisoned
- ld de, W_PLAYERBATTSTATUS2
+ ld de, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .playersTurn2
- ld de, W_ENEMYBATTSTATUS2
+ ld de, wEnemyBattleStatus2
.playersTurn2
ld a, [de]
add a
@@ -659,13 +659,13 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d)
jr nz, .nonZeroDamage
inc c ; damage is at least 1
.nonZeroDamage
- ld hl, W_PLAYERBATTSTATUS3
- ld de, W_PLAYERTOXICCOUNTER
+ ld hl, wPlayerBattleStatus3
+ ld de, wPlayerToxicCounter
ld a, [H_WHOSETURN]
and a
jr z, .playersTurn
- ld hl, W_ENEMYBATTSTATUS3
- ld de, W_ENEMYTOXICCOUNTER
+ ld hl, wEnemyBattleStatus3
+ ld de, wEnemyToxcCounter
.playersTurn
bit BadlyPoisoned, [hl]
jr z, .noToxic
@@ -775,20 +775,20 @@ CheckNumAttacksLeft: ; 3c50f (f:450f)
and a
jr nz, .checkEnemy
; player has 0 attacks left
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
res UsingTrappingMove, [hl] ; player not using multi-turn attack like wrap any more
.checkEnemy
ld a, [wEnemyNumAttacksLeft]
and a
ret nz
; enemy has 0 attacks left
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res UsingTrappingMove, [hl] ; enemy not using multi-turn attack like wrap any more
ret
HandleEnemyMonFainted: ; 3c525 (f:4525)
xor a
- ld [wccf0], a
+ ld [wInHandlePlayerMonFainted], a
call FaintEnemyPokemon
call AnyPartyAlive
ld a, d
@@ -798,7 +798,7 @@ HandleEnemyMonFainted: ; 3c525 (f:4525)
ld a, [hli]
or [hl] ; is battle mon HP zero?
call nz, DrawPlayerHUDAndHPBar ; if battle mon HP is not zero, draw player HD and HP bar
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
ret z ; return if it's a wild battle
call AnyEnemyPokemonAliveCheck
@@ -821,7 +821,7 @@ HandleEnemyMonFainted: ; 3c525 (f:4525)
FaintEnemyPokemon: ; 0x3c567
call ReadPlayerMonCurHPAndStatus
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr z, .wild
ld a, [wEnemyMonPartyPos]
@@ -832,17 +832,26 @@ FaintEnemyPokemon: ; 0x3c567
ld [hli], a
ld [hl], a
.wild
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
res AttackingMultipleTimes, [hl]
- xor a
- ld [wPlayerNumHits], a
+; Bug. This only zeroes the high byte of the player's accumulated damage,
+; setting the accumulated damage to itself mod 256 instead of 0 as was probably
+; intended. That alone is problematic, but this mistake has another more severe
+; effect. This function's counterpart for when the player mon faints,
+; RemoveFaintedPlayerMon, zeroes both the high byte and the low byte. In a link
+; battle, the other player's Game Boy will call that function in response to
+; the enemy mon (the player mon from the other side's perspective) fainting,
+; and the states of the two Game Boys will go out of sync unless the damage
+; was congruent to 0 modulo 256.
+ xor a
+ ld [wPlayerBideAccumulatedDamage], a
ld hl, wEnemyStatsToDouble ; clear enemy statuses
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
- ld [W_ENEMYDISABLEDMOVE], a
+ ld [wEnemyDisabledMove], a
ld [wEnemyDisabledMoveNumber], a
ld [wEnemyMonMinimized], a
ld hl, wPlayerUsedMove
@@ -854,16 +863,16 @@ FaintEnemyPokemon: ; 0x3c567
coord hl, 0, 0
lb bc, 4, 11
call ClearScreenArea
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr z, .wild_win
xor a
- ld [wc0f1], a
- ld [wc0f2], a
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent
.sfxwait
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp SFX_FAINT_FALL
jr z, .sfxwait
ld a, SFX_FAINT_THUD
@@ -879,9 +888,9 @@ FaintEnemyPokemon: ; 0x3c567
ld a, [hli]
or [hl]
jr nz, .playermonnotfaint
- ld a, [wccf0]
- and a
- jr nz, .playermonnotfaint
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandlePlayerMonFainted?
+ jr nz, .playermonnotfaint ; if so, don't call RemoveFaintedPlayerMon twice
call RemoveFaintedPlayerMon
.playermonnotfaint
call AnyPartyAlive
@@ -894,7 +903,7 @@ FaintEnemyPokemon: ; 0x3c567
call SaveScreenTilesToBuffer1
xor a
ld [wBattleResult], a
- ld b, EXP__ALL
+ ld b, EXP_ALL
call IsItemInBag
push af
jr z, .giveExpToMonsThatFought ; if no exp all, then jump
@@ -941,11 +950,13 @@ EnemyMonFaintedText: ; 0x3c63e
db "@"
EndLowHealthAlarm: ; 3c643 (f:4643)
+; This function is called when the player has the won the battle. It turns off
+; the low health alarm and prevents it from reactivating until the next battle.
xor a
- ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wc02a], a
+ ld [wLowHealthAlarm], a ; turn off low health alarm
+ ld [wChannelSoundIDs + CH4], a
inc a
- ld [wccf6], a
+ ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret
AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f)
@@ -967,7 +978,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f)
; stores whether enemy ran in Z flag
ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
ld e, $30
call GetBattleHealthBarColor
callab DrawEnemyPokeballs
@@ -983,7 +994,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
.notLinkBattle
call EnemySendOut
xor a
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
ld [wActionResultOrTookBattleTurn], a
ld [wAILayer2Encouragement], a
inc a ; reset Z flag
@@ -992,16 +1003,16 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
TrainerBattleVictory: ; 3c696 (f:4696)
call EndLowHealthAlarm
ld b, MUSIC_DEFEATED_GYM_LEADER
- ld a, [W_GYMLEADERNO]
+ ld a, [wGymLeaderNo]
and a
jr nz, .gymleader
ld b, MUSIC_DEFEATED_TRAINER
.gymleader
- ld a, [W_TRAINERCLASS]
+ ld a, [wTrainerClass]
cp SONY3 ; final battle against rival
jr nz, .notrival
ld b, MUSIC_DEFEATED_GYM_LEADER
- ld hl, W_FLAGS_D733
+ ld hl, wFlags_D733
set 1, [hl]
.notrival
ld a, [wLinkState]
@@ -1036,7 +1047,7 @@ TrainerDefeatedText: ; 3c6e9 (f:46e9)
PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
push af
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySoundWaitForCurrent
ld c, BANK(Music_DefeatedTrainer)
pop af
@@ -1044,8 +1055,8 @@ PlayBattleVictoryMusic: ; 3c6ee (f:46ee)
jp Delay3
HandlePlayerMonFainted: ; 3c700 (f:4700)
- ld a, $1
- ld [wccf0], a
+ ld a, 1
+ ld [wInHandlePlayerMonFainted], a
call RemoveFaintedPlayerMon
call AnyPartyAlive ; test if any more mons are alive
ld a, d
@@ -1057,7 +1068,7 @@ HandlePlayerMonFainted: ; 3c700 (f:4700)
jr nz, .doUseNextMonDialogue ; if not, jump
; the enemy mon has 0 HP
call FaintEnemyPokemon
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
ret z ; if wild encounter, battle is over
call AnyEnemyPokemonAliveCheck
@@ -1083,7 +1094,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
ld hl, wPartyGainExpFlags
ld b, FLAG_RESET
predef FlagActionPredef ; clear gain exp flag for fainted mon
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res 2, [hl] ; reset "attacking multiple times" flag
ld a, [wLowHealthAlarm]
bit 7, a ; skip sound flag (red bar (?))
@@ -1092,8 +1103,7 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
ld [wLowHealthAlarm], a ;disable low health alarm
call WaitForSoundToFinish
.skipWaitForSound
-; bug? if the player mon faints while the enemy mon is using bide,
-; the accumulated damage is overwritten. xxx what values can [wLowHealthAlarm] have here?
+; a is 0, so this zeroes the enemy's accumulated damage.
ld hl, wEnemyBideAccumulatedDamage
ld [hli], a
ld [hl], a
@@ -1107,9 +1117,15 @@ RemoveFaintedPlayerMon: ; 3c741 (f:4741)
call SlideDownFaintedMonPic
ld a, $1
ld [wBattleResult], a
- ld a, [wccf0]
- and a
- ret z
+
+; When the player mon and enemy mon faint at the same time and the fact that the
+; enemy mon has fainted is detected first (e.g. when the player mon knocks out
+; the enemy mon using a move with recoil and faints due to the recoil), don't
+; play the player mon's cry or show the "[player mon] fainted!" message.
+ ld a, [wInHandlePlayerMonFainted]
+ and a ; was this called by HandleEnemyMonFainted?
+ ret z ; if so, return
+
ld a, [wBattleMonSpecies]
call PlayCry
ld hl, PlayerMonFaintedText
@@ -1124,7 +1140,7 @@ PlayerMonFaintedText: ; 3c796 (f:4796)
DoUseNextMonDialogue: ; 3c79b (f:479b)
call PrintEmptyString
call SaveScreenTilesToBuffer1
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
dec a
ret nz ; return if it's a trainer battle
@@ -1191,7 +1207,7 @@ ChooseNextMon: ; 3c7d8 (f:47d8)
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
call SendOutMon
ld hl, wEnemyMonHP
@@ -1205,8 +1221,8 @@ HandlePlayerBlackOut: ; 3c837 (f:4837)
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .notSony1Battle
- ld a, [W_CUROPPONENT]
- cp $c8 + SONY1
+ ld a, [wCurOpponent]
+ cp OPP_SONY1
jr nz, .notSony1Battle
coord hl, 0, 0 ; sony 1 battle
lb bc, 8, 21
@@ -1216,12 +1232,12 @@ HandlePlayerBlackOut: ; 3c837 (f:4837)
call DelayFrames
ld hl, Sony1WinText
call PrintText
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp OAKS_LAB
ret z ; starter battle in oak's lab: don't black out
.notSony1Battle
- ld b, $0
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE_BLACK
+ call RunPaletteCommand
ld hl, PlayerBlackedOutText2
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -1368,7 +1384,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hli],a
ld [hli],a
ld [hl],a
- ld [W_ENEMYDISABLEDMOVE],a
+ ld [wEnemyDisabledMove],a
ld [wEnemyDisabledMoveNumber],a
ld [wEnemyMonMinimized],a
ld hl,wPlayerUsedMove
@@ -1376,7 +1392,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hl],a
dec a
ld [wAICount],a
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res 5,[hl]
coord hl, 18, 0
ld a,8
@@ -1416,7 +1432,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld bc,wEnemyMon2 - wEnemyMon1
call AddNTimes
ld a,[hl]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
ld a,[wWhichPokemon]
inc a
ld hl,wEnemyPartyCount
@@ -1443,7 +1459,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld a,[wLinkState]
cp LINK_STATE_BATTLING
jr z,.next4
- ld a,[W_OPTIONS]
+ ld a,[wOptions]
bit 6,a
jr nz,.next4
ld hl, TrainerAboutToUseText
@@ -1486,8 +1502,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
coord hl, 0, 0
lb bc, 4, 11
call ClearScreenArea
- ld b,1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
call GBPalNormal
ld hl,TrainerSentOutText
call PrintText
@@ -1567,13 +1583,13 @@ NoWillText: ; 3cab4 (f:4ab4)
TryRunningFromBattle: ; 3cab9 (f:4ab9)
call IsGhostBattle
jp z, .canEscape ; jump if it's a ghost battle
- ld a, [W_BATTLETYPE]
- cp $2
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jp z, .canEscape ; jump if it's a safari battle
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jp z, .canEscape
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr nz, .trainerBattle ; jump if it's a trainer battle
ld a, [wNumRunAttempts]
@@ -1720,7 +1736,7 @@ LoadBattleMonFromParty: ; 3cba6 (f:4ba6)
ld a, [wPlayerMonNumber]
call SkipFixedLengthTextEntries
ld de, wBattleMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wBattleMonLevel
ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats
@@ -1764,14 +1780,14 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13)
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
ld de, wEnemyMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wEnemyMonLevel
ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats
ld bc, 1 + NUM_STATS * 2
call CopyData
call ApplyBurnAndParalysisPenaltiesToEnemy
- ld hl, W_MONHBASESTATS
+ ld hl, wMonHBaseStats
ld de, wEnemyMonBaseStats
ld b, NUM_STATS
.copyBaseStatsLoop
@@ -1808,7 +1824,7 @@ SendOutMon: ; 3cc91 (f:4c91)
ld [hl], a
ld [wBoostExpByExpAll], a
ld [wDamageMultipliers], a
- ld [W_PLAYERMOVENUM], a
+ ld [wPlayerMoveNum], a
ld hl, wPlayerUsedMove
ld [hli], a
ld [hl], a
@@ -1818,12 +1834,12 @@ SendOutMon: ; 3cc91 (f:4c91)
ld [hli], a
ld [hli], a
ld [hl], a
- ld [W_PLAYERDISABLEDMOVE], a
+ ld [wPlayerDisabledMove], a
ld [wPlayerDisabledMoveNumber], a
ld [wPlayerMonMinimized], a
- ld b, $1
- call GoPAL_SET
- ld hl, W_ENEMYBATTSTATUS1
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
+ ld hl, wEnemyBattleStatus1
res UsingTrappingMove, [hl]
ld a, $1
ld [H_WHOSETURN], a
@@ -1918,17 +1934,17 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
predef DrawHP
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1d
+ ld hl, wPlayerHPBarColor
call GetBattleHealthBarColor
ld hl, wBattleMonHP
ld a, [hli]
or [hl]
jr z, .asm_3cdd9
- ld a, [wccf6]
- and a
- ret nz
- ld a, [wcf1d]
- cp $2
+ ld a, [wLowHealthAlarmDisabled]
+ and a ; has the alarm been disabled because the player has already won?
+ ret nz ; if so, return
+ ld a, [wPlayerHPBarColor]
+ cp HP_BAR_RED
jr z, .asm_3cde6
.asm_3cdd9
ld hl, wLowHealthAlarm
@@ -1936,7 +1952,7 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60)
ld [hl], $0
ret z
xor a
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
ret
.asm_3cde6
ld hl, wLowHealthAlarm
@@ -2031,7 +2047,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec)
call DrawHPBar
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
- ld hl, wcf1e
+ ld hl, wEnemyHPBarColor
GetBattleHealthBarColor: ; 3ce90 (f:4e90)
ld b, [hl]
@@ -2039,8 +2055,8 @@ GetBattleHealthBarColor: ; 3ce90 (f:4e90)
ld a, [hl]
cp b
ret z
- ld b, $1
- jp GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ jp RunPaletteCommand
; center's mon's name on the battle screen
; if the name is 1 or 2 letters long, it is printed 2 spaces more to the right than usual
@@ -2070,28 +2086,28 @@ CenterMonName: ; 3ce9c (f:4e9c)
DisplayBattleMenu: ; 3ceb3 (f:4eb3)
call LoadScreenTilesFromBuffer1 ; restore saved screen
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
and a
jr nz, .nonstandardbattle
call DrawHUDsAndHPBars
call PrintEmptyString
call SaveScreenTilesToBuffer1
.nonstandardbattle
- ld a, [W_BATTLETYPE]
- cp $2 ; safari
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
ld a, BATTLE_MENU_TEMPLATE
jr nz, .menuselected
ld a, SAFARI_BATTLE_MENU_TEMPLATE
.menuselected
ld [wTextBoxID], a
call DisplayTextBoxID
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
dec a
jp nz, .handleBattleMenuInput ; handle menu input if it's not the old man tutorial
; the following happens for the old man tutorial
ld hl, wPlayerName
- ld de, W_GRASSRATE
- ld bc, 11
+ ld de, wGrassRate
+ ld bc, NAME_LENGTH
call CopyData ; temporarily save the player name in unused space,
; which is supposed to get overwritten when entering a
; map with wild Pokémon. Due to an oversight, the data
@@ -2099,7 +2115,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
; Missingno. glitch can show up.
ld hl, .oldManName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
; the following simulates the keystrokes by drawing menus on screen
coord hl, 9, 14
@@ -2127,8 +2143,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
ld [wLastMenuItem], a
jr .rightColumn
.leftColumn ; put cursor in left column of menu
- ld a, [W_BATTLETYPE]
- cp $2
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
ld a, " "
jr z, .safariLeftColumn
; put cursor in left column for normal battle menu (i.e. when it's not a Safari battle)
@@ -2140,7 +2156,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
Coorda 13, 14
Coorda 13, 16
coord hl, 7, 14
- ld de, W_NUMSAFARIBALLS
+ ld de, wNumSafariBalls
lb bc, 1, 2
call PrintNumber
ld b, $1 ; top menu item X
@@ -2160,8 +2176,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
jr nz, .rightColumn
jr .AButtonPressed ; the A button was pressed
.rightColumn ; put cursor in right column of menu
- ld a, [W_BATTLETYPE]
- cp $2
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
ld a, " "
jr z, .safariRightColumn
; put cursor in right column for normal battle menu (i.e. when it's not a Safari battle)
@@ -2173,7 +2189,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
Coorda 1, 14 ; clear upper cursor position in left column
Coorda 1, 16 ; clear lower cursor position in left column
coord hl, 7, 14
- ld de, W_NUMSAFARIBALLS
+ ld de, wNumSafariBalls
lb bc, 1, 2
call PrintNumber
ld b, $d ; top menu item X
@@ -2197,8 +2213,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
ld [wCurrentMenuItem], a
.AButtonPressed
call PlaceUnfilledArrowMenuCursor
- ld a, [W_BATTLETYPE]
- cp $2 ; is it a Safari battle?
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
ld a, [wCurrentMenuItem]
ld [wBattleAndStartSavedMenuItem], a
jr z, .handleMenuSelection
@@ -2219,8 +2235,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
and a
jr nz, .upperLeftMenuItemWasNotSelected
; the upper left menu item was selected
- ld a, [W_BATTLETYPE]
- cp $2
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jr z, .throwSafariBallWasSelected
; the "FIGHT" menu was selected
xor a
@@ -2247,8 +2263,8 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
.notLinkBattle
call SaveScreenTilesToBuffer2
- ld a, [W_BATTLETYPE]
- cp $2 ; is it a safari battle?
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jr nz, BagWasSelected
; bait was selected
@@ -2258,14 +2274,14 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
BagWasSelected:
call LoadScreenTilesFromBuffer1
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
and a ; is it a normal battle?
jr nz, .next
; normal battle
call DrawHUDsAndHPBars
.next
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
dec a ; is it the old man tutorial?
jr nz, DisplayPlayerBag ; no, it is a normal battle
ld hl, OldManItemList
@@ -2316,21 +2332,21 @@ UseBagItem:
call ClearSprites
xor a
ld [wCurrentMenuItem], a
- ld a, [W_BATTLETYPE]
- cp $2 ; is it a safari battle?
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jr z, .checkIfMonCaptured
ld a, [wActionResultOrTookBattleTurn]
and a ; was the item used successfully?
jp z, BagWasSelected ; if not, go back to the bag menu
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
bit UsingTrappingMove, a ; is the player using a multi-turn move like wrap?
jr z, .checkIfMonCaptured
ld hl, wPlayerNumAttacksLeft
dec [hl]
jr nz, .checkIfMonCaptured
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
res UsingTrappingMove, [hl] ; not using multi-turn move any more
.checkIfMonCaptured
@@ -2338,8 +2354,8 @@ UseBagItem:
and a ; was the enemy mon captured with a ball?
jr nz, .returnAfterCapturingMon
- ld a, [W_BATTLETYPE]
- cp $2 ; is it a safari battle?
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jr z, .returnAfterUsingItem_NoCapture
; not a safari battle
call LoadScreenTilesFromBuffer1
@@ -2369,8 +2385,8 @@ PartyMenuOrRockOrRun:
jp nz, BattleMenu_RunWasSelected
; party menu or rock was selected
call SaveScreenTilesToBuffer2
- ld a, [W_BATTLETYPE]
- cp $2 ; is it a safari battle?
+ ld a, [wBattleType]
+ cp BATTLE_TYPE_SAFARI
jr nz, .partyMenuWasSelected
; safari battle
ld a, SAFARI_ROCK
@@ -2389,12 +2405,12 @@ PartyMenuOrRockOrRun:
call GBPalWhiteOut
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer2
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
jp DisplayBattleMenu
.partyMonDeselected
coord hl, 11, 11
- ld bc, $81
+ ld bc, 6 * SCREEN_WIDTH + 9
ld a, " "
call FillMemory
xor a ; NORMAL_PARTY_MENU
@@ -2437,7 +2453,7 @@ PartyMenuOrRockOrRun:
predef StatusScreen
predef StatusScreen2
; now we need to reload the enemy mon pic
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
bit HasSubstituteUp, a ; does the enemy mon have a substitute?
ld hl, AnimationSubstitute
jr nz, .doEnemyMonAnimation
@@ -2478,7 +2494,7 @@ PartyMenuOrRockOrRun:
call ClearSprites
call LoadHudTilePatterns
call LoadScreenTilesFromBuffer1
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
; fall through to SwitchPlayerMon
@@ -2625,8 +2641,8 @@ MoveSelectionMenu: ; 3d219 (f:5219)
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .matchedkeyspicked
- ld a, [W_FLAGS_D733]
- bit 0, a
+ ld a, [wFlags_D733]
+ bit BIT_TEST_BATTLE, a
ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT
jr z, .matchedkeyspicked
ld b, $ff
@@ -2653,8 +2669,8 @@ SelectMenuItem: ; 3d2fe (f:52fe)
call PlaceString
jr .select
.battleselect
- ld a, [W_FLAGS_D733]
- bit 0, a
+ ld a, [wFlags_D733]
+ bit BIT_TEST_BATTLE, a
jr nz, .select
call PrintMenuItem
ld a, [wMenuItemToSwap]
@@ -2708,13 +2724,13 @@ SelectMenuItem: ; 3d2fe (f:52fe)
ld a, [hl]
and $3f
jr z, .nopp
- ld a, [W_PLAYERDISABLEDMOVE]
+ ld a, [wPlayerDisabledMove]
swap a
and $f
dec a
cp c
jr z, .disabled
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
bit 3, a ; transformed
jr nz, .dummy ; game freak derp
.dummy
@@ -2775,7 +2791,7 @@ AnyMoveToSelect: ; 3d3f5 (f:53f5)
; return z and Struggle as the selected move if all moves have 0 PP and/or are disabled
ld a, STRUGGLE
ld [wPlayerSelectedMove], a
- ld a, [W_PLAYERDISABLEDMOVE]
+ ld a, [wPlayerDisabledMove]
and a
ld hl, wBattleMonPP
jr nz, .asm_3d40e
@@ -2827,7 +2843,7 @@ SwapMovesInMenu: ; 3d435 (f:5435)
ld hl, wBattleMonPP
call .swapBytes ; swap move PP
; update the index of the disabled move if necessary
- ld hl, W_PLAYERDISABLEDMOVE
+ ld hl, wPlayerDisabledMove
ld a, [hl]
swap a
and $f
@@ -2901,7 +2917,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
ld b, $3
ld c, $9
call TextBoxBorder
- ld a, [W_PLAYERDISABLEDMOVE]
+ ld a, [wPlayerDisabledMove]
and a
jr z, .notDisabled
swap a
@@ -2954,7 +2970,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6)
lb bc, 1, 2
call PrintNumber
coord hl, 8, 11
- ld de, wd11e
+ ld de, wMaxPP
lb bc, 1, 2
call PrintNumber
call GetCurrentMove
@@ -2998,20 +3014,20 @@ SelectEnemyMove: ; 3d564 (f:5564)
ld a, [hl]
jr .done
.noLinkBattle
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
and (1 << NeedsToRecharge) | (1 << UsingRage) ; need to recharge or using rage
ret nz
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld a, [hl]
and (1 << ChargingUp) | (1 << ThrashingAbout) ; using a charging move or thrash/petal dance
ret nz
ld a, [wEnemyMonStatus]
and SLP | 1 << FRZ ; sleeping or frozen
ret nz
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
and (1 << UsingTrappingMove) | (1 << StoringEnergy) ; using a trapping move like wrap or bide
ret nz
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
bit UsingTrappingMove, a ; caught in player's trapping move (e.g. wrap)
jr z, .canSelectMove
.unableToSelectMove
@@ -3022,12 +3038,12 @@ SelectEnemyMove: ; 3d564 (f:5564)
ld a, [hld]
and a
jr nz, .atLeastTwoMovesAvailable
- ld a, [W_ENEMYDISABLEDMOVE]
+ ld a, [wEnemyDisabledMove]
and a
ld a, STRUGGLE ; struggle if the only move is disabled
jr nz, .done
.atLeastTwoMovesAvailable
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr z, .chooseRandomMove ; wild encounter
callab AIEnemyTrainerChooseMoves
@@ -3051,7 +3067,7 @@ SelectEnemyMove: ; 3d564 (f:5564)
ld a, b
dec a
ld [wEnemyMoveListIndex], a
- ld a, [W_ENEMYDISABLEDMOVE]
+ ld a, [wEnemyDisabledMove]
swap a
and $f
cp b
@@ -3123,7 +3139,7 @@ ExecutePlayerMove: ; 3d65e (f:565e)
inc a
jp z, ExecutePlayerMoveDone ; for selected move = FF, skip most of player's turn
xor a
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
ld [wMonIsDisobedient], a
ld [wMoveDidntMiss], a
ld a, $a
@@ -3138,14 +3154,14 @@ ExecutePlayerMove: ; 3d65e (f:565e)
jp [hl]
.playerHasNoSpecialCondition
call GetCurrentMove
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
bit ChargingUp, [hl] ; charging up for attack
jr nz, PlayerCanExecuteChargingMove
call CheckForDisobedience
jp z, ExecutePlayerMoveDone
CheckIfPlayerNeedsToChargeUp: ; 3d69a (f:569a)
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
cp CHARGE_EFFECT
jp z, JumpMoveEffect
cp FLY_EFFECT
@@ -3154,7 +3170,7 @@ CheckIfPlayerNeedsToChargeUp: ; 3d69a (f:569a)
; in-battle stuff
PlayerCanExecuteChargingMove: ; 3d6a9 (f:56a9)
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res ChargingUp,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack
; being fully paralyzed or hurting oneself in confusion removes charging up status
; resulting in the Pokemon being invulnerable for the whole battle
@@ -3165,19 +3181,19 @@ PlayerCanExecuteMove: ; 3d6b0 (f:56b0)
ld de,wPlayerSelectedMove ; pointer to the move just used
ld b,BANK(DecrementPP)
call Bankswitch
- ld a,[W_PLAYERMOVEEFFECT] ; effect of the move just used
+ ld a,[wPlayerMoveEffect] ; effect of the move just used
ld hl,ResidualEffects1
ld de,1
call IsInArray
jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests
; unless executed as part of their exclusive effect functions
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
ld hl,SpecialEffectsCont
ld de,1
call IsInArray
call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything
PlayerCalcMoveDamage: ; 3d6dc (f:56dc)
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
ld hl,SetDamageEffects
ld de,1
call IsInArray
@@ -3194,33 +3210,33 @@ PlayerCalcMoveDamage: ; 3d6dc (f:56dc)
.moveHitTest
call MoveHitTest
handleIfPlayerMoveMissed
- ld a,[W_MOVEMISSED]
+ ld a,[wMoveMissed]
and a
jr z,getPlayerAnimationType
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
sub a,EXPLODE_EFFECT
jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
jr playerCheckIfFlyOrChargeEffect
getPlayerAnimationType
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
and a
ld a,4 ; move has no effect other than dealing damage
jr z,playPlayerMoveAnimation
ld a,5 ; move has effect
playPlayerMoveAnimation
push af
- ld a,[W_PLAYERBATTSTATUS2]
+ ld a,[wPlayerBattleStatus2]
bit HasSubstituteUp,a
ld hl,HideSubstituteShowMonAnim
ld b,BANK(HideSubstituteShowMonAnim)
call nz,Bankswitch
pop af
ld [wAnimationType],a
- ld a,[W_PLAYERMOVENUM]
+ ld a,[wPlayerMoveNum]
call PlayMoveAnimation
call HandleExplodingAnimation
call DrawPlayerHUDAndHPBar
- ld a,[W_PLAYERBATTSTATUS2]
+ ld a,[wPlayerBattleStatus2]
bit HasSubstituteUp,a
ld hl,ReshowSubstituteAnim
ld b,BANK(ReshowSubstituteAnim)
@@ -3229,7 +3245,7 @@ playPlayerMoveAnimation
playerCheckIfFlyOrChargeEffect
ld c,30
call DelayFrames
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,FLY_EFFECT
jr z,.playAnim
cp a,CHARGE_EFFECT
@@ -3241,7 +3257,7 @@ playerCheckIfFlyOrChargeEffect
ld a,STATUS_AFFECTED_ANIM
call PlayMoveAnimation
MirrorMoveCheck
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,MIRROR_MOVE_EFFECT
jr nz,.metronomeCheck
call MirrorMoveCopyMove
@@ -3255,16 +3271,16 @@ MirrorMoveCheck
call MetronomePickMove
jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome
.next
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
ld hl,ResidualEffects2
ld de,1
call IsInArray
jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2
- ld a,[W_MOVEMISSED]
+ ld a,[wMoveMissed]
and a
jr z,.moveDidNotMiss
call PrintMoveFailureText
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated
jr z,.notDone
jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed
@@ -3275,7 +3291,7 @@ MirrorMoveCheck
ld a,1
ld [wMoveDidntMiss],a
.notDone
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
ld hl,AlwaysHappenSideEffects
ld de,1
call IsInArray
@@ -3287,7 +3303,7 @@ MirrorMoveCheck
ret z ; don't do anything else if the enemy fainted
call HandleBuildingRage
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
bit AttackingMultipleTimes,[hl]
jr z,.executeOtherEffects
ld a,[wPlayerNumAttacksLeft]
@@ -3301,7 +3317,7 @@ MirrorMoveCheck
xor a
ld [wPlayerNumHits],a
.executeOtherEffects
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
and a
jp z,ExecutePlayerMoveDone
ld hl,SpecialEffects
@@ -3352,10 +3368,10 @@ GetOutText: ; 3d835 (f:5835)
db "@"
IsGhostBattle: ; 3d83a (f:583a)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
dec a
ret nz
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp a,POKEMONTOWER_1
jr c,.next
cp a,LAVENDER_HOUSE_1
@@ -3408,7 +3424,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL
.HeldInPlaceCheck
- ld a,[W_ENEMYBATTSTATUS1]
+ ld a,[wEnemyBattleStatus1]
bit UsingTrappingMove,a ; is enemy using a mult-turn move like wrap?
jp z,.FlinchedCheck
ld hl,CantMoveText
@@ -3417,7 +3433,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL
.FlinchedCheck
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
bit Flinched,[hl]
jp z,.HyperBeamCheck
res Flinched,[hl] ; reset player's flinch status
@@ -3427,7 +3443,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL
.HyperBeamCheck
- ld hl,W_PLAYERBATTSTATUS2
+ ld hl,wPlayerBattleStatus2
bit NeedsToRecharge,[hl]
jr z,.AnyMoveDisabledCheck
res NeedsToRecharge,[hl] ; reset player's recharge status
@@ -3437,7 +3453,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL
.AnyMoveDisabledCheck
- ld hl,W_PLAYERDISABLEDMOVE
+ ld hl,wPlayerDisabledMove
ld a,[hl]
and a
jr z,.ConfusedCheck
@@ -3451,13 +3467,13 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
call PrintText
.ConfusedCheck
- ld a,[W_PLAYERBATTSTATUS1]
+ ld a,[wPlayerBattleStatus1]
add a ; is player confused?
jr nc,.TriedToUseDisabledMoveCheck
- ld hl,W_PLAYERCONFUSEDCOUNTER
+ ld hl,wPlayerConfusedCounter
dec [hl]
jr nz,.IsConfused
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res Confused,[hl] ; if confused counter hit 0, reset confusion status
ld hl,ConfusedNoMoreText
call PrintText
@@ -3472,9 +3488,9 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
call BattleRandom
cp a,$80 ; 50% chance to hurt itself
jr c,.TriedToUseDisabledMoveCheck
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
ld a,[hl]
- and a, 1 << Confused ; if mon hurts itself, clear every other status from W_PLAYERBATTSTATUS1
+ and a, 1 << Confused ; if mon hurts itself, clear every other status from wPlayerBattleStatus1
ld [hl],a
call HandleSelfConfusionDamage
jr .MonHurtItselfOrFullyParalysed
@@ -3502,12 +3518,12 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
call PrintText
.MonHurtItselfOrFullyParalysed
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
ld a,[hl]
; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)
and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
ld [hl],a
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,FLY_EFFECT
jr z,.FlyOrChargeEffect
cp a,CHARGE_EFFECT
@@ -3524,12 +3540,12 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL ; if using a two-turn move, we need to recharge the first turn
.BideCheck
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
bit StoringEnergy,[hl] ; is mon using bide?
jr z,.ThrashingAboutCheck
xor a
- ld [W_PLAYERMOVENUM],a
- ld hl,W_DAMAGE
+ ld [wPlayerMoveNum],a
+ ld hl,wDamage
ld a,[hli]
ld b,a
ld c,[hl]
@@ -3546,30 +3562,30 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld hl,ExecutePlayerMoveDone
jp .returnToHL ; unless mon unleashes energy, can't move this turn
.UnleashEnergy
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res StoringEnergy,[hl] ; not using bide any more
ld hl,UnleashedEnergyText
call PrintText
ld a,1
- ld [W_PLAYERMOVEPOWER],a
+ ld [wPlayerMovePower],a
ld hl,wPlayerBideAccumulatedDamage + 1
ld a,[hld]
add a
ld b,a
- ld [W_DAMAGE + 1],a
+ ld [wDamage + 1],a
ld a,[hl]
rl a ; double the damage
- ld [W_DAMAGE],a
+ ld [wDamage],a
or b
jr nz,.next
ld a,1
- ld [W_MOVEMISSED],a
+ ld [wMoveMissed],a
.next
xor a
ld [hli],a
ld [hl],a
ld a,BIDE
- ld [W_PLAYERMOVENUM],a
+ ld [wPlayerMoveNum],a
ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL
@@ -3577,7 +3593,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
bit ThrashingAbout,[hl] ; is mon using thrash or petal dance?
jr z,.MultiturnMoveCheck
ld a,THRASH
- ld [W_PLAYERMOVENUM],a
+ ld [wPlayerMoveNum],a
ld hl,ThrashingAboutText
call PrintText
ld hl,wPlayerNumAttacksLeft
@@ -3585,14 +3601,14 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
ld hl,PlayerCalcMoveDamage ; skip DecrementPP
jp nz,.returnToHL
push hl
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res ThrashingAbout,[hl] ; no longer thrashing about
set Confused,[hl] ; confused
call BattleRandom
and a,3
inc a
inc a ; confused for 2-5 turns
- ld [W_PLAYERCONFUSEDCOUNTER],a
+ ld [wPlayerConfusedCounter],a
pop hl ; skip DecrementPP
jp .returnToHL
@@ -3610,7 +3626,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jp .returnToHL
.RageCheck
- ld a, [W_PLAYERBATTSTATUS2]
+ ld a, [wPlayerBattleStatus2]
bit UsingRage, a ; is mon using rage?
jp z, .checkPlayerStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
@@ -3618,7 +3634,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
call GetMoveName
call CopyStringToCF4B
xor a
- ld [W_PLAYERMOVEEFFECT], a
+ ld [wPlayerMoveEffect], a
ld hl, PlayerCanExecuteMove
jp .returnToHL
@@ -3693,12 +3709,12 @@ CantMoveText: ; 3da83 (f:5a83)
PrintMoveIsDisabledText: ; 3da88 (f:5a88)
ld hl, wPlayerSelectedMove
- ld de, W_PLAYERBATTSTATUS1
+ ld de, wPlayerBattleStatus1
ld a, [H_WHOSETURN]
and a
jr z, .removeChargingUp
inc hl
- ld de, W_ENEMYBATTSTATUS1
+ ld de, wEnemyBattleStatus1
.removeChargingUp
ld a, [de]
res ChargingUp, a ; end the pokemon's
@@ -3725,7 +3741,7 @@ HandleSelfConfusionDamage: ; 3daad (f:5aad)
ld [hli], a
ld a, [wBattleMonDefense + 1]
ld [hl], a
- ld hl, W_PLAYERMOVEEFFECT
+ ld hl, wPlayerMoveEffect
push hl
ld a, [hl]
push af
@@ -3771,10 +3787,10 @@ MonName1Text: ; 3dafb (f:5afb)
TX_ASM
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
ld hl, wPlayerUsedMove
jr z, .asm_3db11
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld hl, wEnemyUsedMove
.asm_3db11
ld [hl], a
@@ -3905,11 +3921,11 @@ ExclamationPointMoveSets: ; 3dba3 (f:5ba3)
db $FF ; terminator
PrintMoveFailureText: ; 3dbe2 (f:5be2)
- ld de, W_PLAYERMOVEEFFECT
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .playersTurn
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.playersTurn
ld hl, DoesntAffectMonText
ld a, [wDamageMultipliers]
@@ -3931,7 +3947,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2)
ret nz
; if you get here, the mon used jump kick or hi jump kick and missed
- ld hl, W_DAMAGE ; since the move missed, W_DAMAGE will always contain 0 at this point.
+ ld hl, wDamage ; since the move missed, wDamage will always contain 0 at this point.
; Thus, recoil damage will always be equal to 1
; even if it was intended to be potential damage/8.
ld a, [hli]
@@ -4041,7 +4057,7 @@ CheckForDisobedience: ; 3dc88 (f:5c88)
; it was traded
.monIsTraded
; what level might disobey?
- ld hl, W_OBTAINEDBADGES
+ ld hl, wObtainedBadges
bit 7, [hl]
ld a, 101
jr nz, .next
@@ -4218,15 +4234,15 @@ IgnoredOrdersText: ; 3ddca (f:5dca)
; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the player mon
GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf)
xor a
- ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero
+ ld hl, wDamage ; damage to eventually inflict, initialise to zero
ldi [hl], a
ld [hl], a
- ld hl, W_PLAYERMOVEPOWER
+ ld hl, wPlayerMovePower
ld a, [hli]
and a
ld d, a ; d = move power
ret z ; return if move power is zero
- ld a, [hl] ; a = [W_PLAYERMOVETYPE]
+ ld a, [hl] ; a = [wPlayerMoveType]
cp FIRE ; types >= FIRE are all special
jr nc, .specialAttack
.physicalAttack
@@ -4234,7 +4250,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf)
ld a, [hli]
ld b, a
ld c, [hl] ; bc = enemy defense
- ld a, [W_ENEMYBATTSTATUS3]
+ ld a, [wEnemyBattleStatus3]
bit HasReflectUp, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the enemy has used Reflect, double the enemy's defense
@@ -4264,7 +4280,7 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf)
ld a, [hli]
ld b, a
ld c, [hl] ; bc = enemy special
- ld a, [W_ENEMYBATTSTATUS3]
+ ld a, [wEnemyBattleStatus3]
bit HasLightScreenUp, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the enemy has used Light Screen, double the enemy's special
@@ -4330,16 +4346,16 @@ GetDamageVarsForPlayerAttack: ; 3ddcf (f:5dcf)
; sets b, c, d, and e for the CalculateDamage routine in the case of an attack by the enemy mon
GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75)
- ld hl, W_DAMAGE ; damage to eventually inflict, initialise to zero
+ ld hl, wDamage ; damage to eventually inflict, initialise to zero
xor a
ld [hli], a
ld [hl], a
- ld hl, W_ENEMYMOVEPOWER
+ ld hl, wEnemyMovePower
ld a, [hli]
ld d, a ; d = move power
and a
ret z ; return if move power is zero
- ld a, [hl] ; a = [W_ENEMYMOVETYPE]
+ ld a, [hl] ; a = [wEnemyMoveType]
cp FIRE ; types >= FIRE are all special
jr nc, .specialAttack
.physicalAttack
@@ -4347,7 +4363,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75)
ld a, [hli]
ld b, a
ld c, [hl] ; bc = player defense
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
bit HasReflectUp, a ; check for Reflect
jr z, .physicalAttackCritCheck
; if the player has used Reflect, double the player's defense
@@ -4377,7 +4393,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75)
ld a, [hli]
ld b, a
ld c, [hl]
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
bit HasLightScreenUp, a ; check for Light Screen
jr z, .specialAttackCritCheck
; if the player has used Light Screen, double the player's special
@@ -4467,7 +4483,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c)
ret
.notLinkBattle
ld a, [wEnemyMonLevel]
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
call GetMonHeader
@@ -4494,9 +4510,9 @@ CalculateDamage: ; 3df65 (f:5f65)
ld a, [H_WHOSETURN] ; whose turn?
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .effect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.effect
; EXPLODE_EFFECT halves defense.
@@ -4573,7 +4589,7 @@ CalculateDamage: ; 3df65 (f:5f65)
ld b, 4
call Divide
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld b, [hl]
ld a, [H_QUOTIENT + 3]
add b
@@ -4649,7 +4665,7 @@ CalculateDamage: ; 3df65 (f:5f65)
JumpToOHKOMoveEffect: ; 3e016 (f:6016)
call JumpMoveEffect
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
dec a
ret
@@ -4676,16 +4692,16 @@ CriticalHitTest: ; 3e023 (f:6023)
.asm_3e032
ld [wd0b5], a
call GetMonHeader
- ld a, [W_MONHBASESPEED]
+ ld a, [wMonHBaseSpeed]
ld b, a
srl b ; (effective (base speed/2))
ld a, [H_WHOSETURN]
and a
- ld hl, W_PLAYERMOVEPOWER
- ld de, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerMovePower
+ ld de, wPlayerBattleStatus2
jr z, .calcCriticalHitProbability
- ld hl, W_ENEMYMOVEPOWER
- ld de, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyMovePower
+ ld de, wEnemyBattleStatus2
.calcCriticalHitProbability
ld a, [hld] ; read base power from RAM
and a
@@ -4752,18 +4768,18 @@ HandleCounterMove: ; 3e093 (f:6093)
and a
; player's turn
ld hl,wEnemySelectedMove
- ld de,W_ENEMYMOVEPOWER
+ ld de,wEnemyMovePower
ld a,[wPlayerSelectedMove]
jr z,.next
; enemy's turn
ld hl,wPlayerSelectedMove
- ld de,W_PLAYERMOVEPOWER
+ ld de,wPlayerMovePower
ld a,[wEnemySelectedMove]
.next
cp a,COUNTER
ret nz ; return if not using Counter
ld a,$01
- ld [W_MOVEMISSED],a ; initialize the move missed variable to true (it is set to false below if the move hits)
+ ld [wMoveMissed],a ; initialize the move missed variable to true (it is set to false below if the move hits)
ld a,[hl]
cp a,COUNTER
ret z ; miss if the opponent's last selected move is Counter.
@@ -4781,11 +4797,11 @@ HandleCounterMove: ; 3e093 (f:6093)
xor a
ret
.counterableType
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
or [hl]
ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target.
- ; W_DAMAGE is shared by both players, so Counter may strike back damage dealt by the Counter user itself
+ ; wDamage is shared by both players, so Counter may strike back damage dealt by the Counter user itself
; if the conditions meet, even though 99% of the times damage will come from the target.
; if it did damage, double it
ld a,[hl]
@@ -4801,27 +4817,27 @@ HandleCounterMove: ; 3e093 (f:6093)
ld [hl],a
.noCarry
xor a
- ld [W_MOVEMISSED],a
+ ld [wMoveMissed],a
call MoveHitTest ; do the normal move hit test in addition to Counter's special rules
xor a
ret
ApplyAttackToEnemyPokemon: ; 3e0df (f:60df)
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,OHKO_EFFECT
jr z,ApplyDamageToEnemyPokemon
cp a,SUPER_FANG_EFFECT
jr z,.superFangEffect
cp a,SPECIAL_DAMAGE_EFFECT
jr z,.specialDamage
- ld a,[W_PLAYERMOVEPOWER]
+ ld a,[wPlayerMovePower]
and a
jp z,ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0
jr ApplyDamageToEnemyPokemon
.superFangEffect
; set the damage to half the target's HP
ld hl,wEnemyMonHP
- ld de,W_DAMAGE
+ ld de,wDamage
ld a,[hli]
srl a
ld [de],a
@@ -4840,7 +4856,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df)
ld hl,wBattleMonLevel
ld a,[hl]
ld b,a ; Seismic Toss deals damage equal to the user's level
- ld a,[W_PLAYERMOVENUM]
+ ld a,[wPlayerMoveNum]
cp a,SEISMIC_TOSS
jr z,.storeDamage
cp a,NIGHT_SHADE
@@ -4866,20 +4882,20 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df)
jr nc,.loop
ld b,a
.storeDamage ; store damage value at b
- ld hl,W_DAMAGE
+ ld hl,wDamage
xor a
ld [hli],a
ld a,b
ld [hl],a
ApplyDamageToEnemyPokemon: ; 3e142 (f:6142)
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
ld b,a
ld a,[hl]
or b
jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0
- ld a,[W_ENEMYBATTSTATUS2]
+ ld a,[wEnemyBattleStatus2]
bit HasSubstituteUp,a ; does the enemy have a substitute?
jp nz,AttackSubstitute
; subtract the damage from the pokemon's current HP
@@ -4897,7 +4913,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142)
sbc b
ld [wEnemyMonHP],a
jr nc,.animateHpBar
-; if more damage was done than the current HP, zero the HP and set the damage (W_DAMAGE)
+; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
ld a,[wHPBarOldHP+1]
ld [hli],a
@@ -4926,21 +4942,21 @@ ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d)
jp DrawHUDsAndHPBars
ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
- ld a,[W_ENEMYMOVEEFFECT]
+ ld a,[wEnemyMoveEffect]
cp a,OHKO_EFFECT
jr z,ApplyDamageToPlayerPokemon
cp a,SUPER_FANG_EFFECT
jr z,.superFangEffect
cp a,SPECIAL_DAMAGE_EFFECT
jr z,.specialDamage
- ld a,[W_ENEMYMOVEPOWER]
+ ld a,[wEnemyMovePower]
and a
jp z,ApplyAttackToPlayerPokemonDone
jr ApplyDamageToPlayerPokemon
.superFangEffect
; set the damage to half the target's HP
ld hl,wBattleMonHP
- ld de,W_DAMAGE
+ ld de,wDamage
ld a,[hli]
srl a
ld [de],a
@@ -4959,7 +4975,7 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
ld hl,wEnemyMonLevel
ld a,[hl]
ld b,a
- ld a,[W_ENEMYMOVENUM]
+ ld a,[wEnemyMoveNum]
cp a,SEISMIC_TOSS
jr z,.storeDamage
cp a,NIGHT_SHADE
@@ -4985,20 +5001,20 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
jr nc,.loop
ld b,a
.storeDamage
- ld hl,W_DAMAGE
+ ld hl,wDamage
xor a
ld [hli],a
ld a,b
ld [hl],a
ApplyDamageToPlayerPokemon: ; 3e200 (f:6200)
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
ld b,a
ld a,[hl]
or b
jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0
- ld a,[W_PLAYERBATTSTATUS2]
+ ld a,[wPlayerBattleStatus2]
bit HasSubstituteUp,a ; does the player have a substitute?
jp nz,AttackSubstitute
; subtract the damage from the pokemon's current HP
@@ -5017,7 +5033,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200)
ld [wBattleMonHP],a
ld [wHPBarNewHP+1],a
jr nc,.animateHpBar
-; if more damage was done than the current HP, zero the HP and set the damage (W_DAMAGE)
+; if more damage was done than the current HP, zero the HP and set the damage (wDamage)
; equal to how much HP the pokemon had before the attack
ld a,[wHPBarOldHP+1]
ld [hli],a
@@ -5055,15 +5071,15 @@ AttackSubstitute: ; 3e25e (f:625e)
call PrintText
; values for player turn
ld de,wEnemySubstituteHP
- ld bc,W_ENEMYBATTSTATUS2
+ ld bc,wEnemyBattleStatus2
ld a,[H_WHOSETURN]
and a
jr z,.applyDamageToSubstitute
; values for enemy turn
ld de,wPlayerSubstituteHP
- ld bc,W_PLAYERBATTSTATUS2
+ ld bc,wPlayerBattleStatus2
.applyDamageToSubstitute
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
and a
jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes
@@ -5073,7 +5089,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld [de],a
ret nc
.substituteBroke
-; If the target's Substitute breaks, W_DAMAGE isn't updated with the amount of HP
+; If the target's Substitute breaks, wDamage isn't updated with the amount of HP
; the Substitute had before being attacked.
ld h,b
ld l,c
@@ -5089,10 +5105,10 @@ AttackSubstitute: ; 3e25e (f:625e)
ld a,[H_WHOSETURN]
xor a,$01
ld [H_WHOSETURN],a
- ld hl,W_PLAYERMOVEEFFECT ; value for player's turn
+ ld hl,wPlayerMoveEffect ; value for player's turn
and a
jr z,.nullifyEffect
- ld hl,W_ENEMYMOVEEFFECT ; value for enemy's turn
+ ld hl,wEnemyMoveEffect ; value for enemy's turn
.nullifyEffect
xor a
ld [hl],a ; zero the effect of the attacker's move
@@ -5109,16 +5125,16 @@ SubstituteBrokeText: ; 3e2b1 (f:62b1)
; this function raises the attack modifier of a pokemon using Rage when that pokemon is attacked
HandleBuildingRage: ; 3e2b6 (f:62b6)
; values for the player turn
- ld hl,W_ENEMYBATTSTATUS2
+ ld hl,wEnemyBattleStatus2
ld de,wEnemyMonStatMods
- ld bc,W_ENEMYMOVENUM
+ ld bc,wEnemyMoveNum
ld a,[H_WHOSETURN]
and a
jr z,.next
; values for the enemy turn
- ld hl,W_PLAYERBATTSTATUS2
+ ld hl,wPlayerBattleStatus2
ld de,wPlayerMonStatMods
- ld bc,W_PLAYERMOVENUM
+ ld bc,wPlayerMoveNum
.next
bit UsingRage,[hl] ; is the pokemon being attacked under the effect of Rage?
ret z ; return if not
@@ -5167,11 +5183,11 @@ MirrorMoveCopyMove: ; 3e2fd (f:62fd)
; values for player turn
ld a,[wEnemyUsedMove]
ld hl,wPlayerSelectedMove
- ld de,W_PLAYERMOVENUM
+ ld de,wPlayerMoveNum
jr z,.next
; values for enemy turn
ld a,[wPlayerUsedMove]
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
ld hl,wEnemySelectedMove
.next
ld [hl],a
@@ -5194,7 +5210,7 @@ ReloadMoveData: ; 3e329 (f:6329)
ld [wd11e],a
dec a
ld hl,Moves
- ld bc,$0006
+ ld bc,MoveEnd - Moves
call AddNTimes
ld a,BANK(Moves)
call FarCopyData ; copy the move's stats
@@ -5213,13 +5229,13 @@ MetronomePickMove: ; 3e348 (f:6348)
ld a,METRONOME
call PlayMoveAnimation ; play Metronome's animation
; values for player turn
- ld de,W_PLAYERMOVENUM
+ ld de,wPlayerMoveNum
ld hl,wPlayerSelectedMove
ld a,[H_WHOSETURN]
and a
jr z,.pickMoveLoop
; values for enemy turn
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
ld hl,wEnemySelectedMove
; loop to pick a random number in the range [1, $a5) to be the move used by Metronome
.pickMoveLoop
@@ -5278,8 +5294,8 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld a,[hli]
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
- ld a,[W_PLAYERMOVETYPE]
- ld [wd11e],a
+ ld a,[wPlayerMoveType]
+ ld [wMoveType],a
ld a,[H_WHOSETURN]
and a
jr z,.next
@@ -5292,10 +5308,10 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld a,[hli]
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
- ld a,[W_ENEMYMOVETYPE]
- ld [wd11e],a
+ ld a,[wEnemyMoveType]
+ ld [wMoveType],a
.next
- ld a,[wd11e] ; move type
+ ld a,[wMoveType]
cp b ; does the move type match type 1 of the attacker?
jr z,.sameTypeAttackBonus
cp c ; does the move type match type 2 of the attacker?
@@ -5303,7 +5319,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
jr .skipSameTypeAttackBonus
.sameTypeAttackBonus
; if the move type matches one of the attacker's types
- ld hl,W_DAMAGE + 1
+ ld hl,wDamage + 1
ld a,[hld]
ld h,[hl]
ld l,a ; hl = damage
@@ -5314,14 +5330,14 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
add hl,bc ; hl = floor(1.5 * damage)
; store damage
ld a,h
- ld [W_DAMAGE],a
+ ld [wDamage],a
ld a,l
- ld [W_DAMAGE + 1],a
+ ld [wDamage + 1],a
ld hl,wDamageMultipliers
set 7,[hl]
.skipSameTypeAttackBonus
- ld a,[wd11e]
- ld b,a ; b = move type
+ ld a,[wMoveType]
+ ld b,a
ld hl,TypeEffects
.loop
ld a,[hli] ; a = "attacking type" of the current type pair
@@ -5349,7 +5365,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld [wDamageMultipliers],a
xor a
ld [H_MULTIPLICAND],a
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
ld [H_MULTIPLICAND + 1],a
ld a,[hld]
@@ -5370,7 +5386,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
; if damage is 0, make the move miss
; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target
inc a
- ld [W_MOVEMISSED],a
+ ld [wMoveMissed],a
.skipTypeImmunity
pop bc
pop hl
@@ -5384,29 +5400,29 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
; function to tell how effective the type of an enemy attack is on the player's current pokemon
; this doesn't take into account the effects that dual types can have
; (e.g. 4x weakness / resistance, weaknesses and resistances canceling)
-; the result is stored in [wd11e]
+; the result is stored in [wTypeEffectiveness]
; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness: ; 3e449 (f:6449)
- ld a,[W_ENEMYMOVETYPE]
- ld d,a ; d = type of enemy move
+ ld a,[wEnemyMoveType]
+ ld d,a ; d = type of enemy move
ld hl,wBattleMonType
- ld b,[hl] ; b = type 1 of player's pokemon
+ ld b,[hl] ; b = type 1 of player's pokemon
inc hl
- ld c,[hl] ; c = type 2 of player's pokemon
+ ld c,[hl] ; c = type 2 of player's pokemon
ld a,$10
- ld [wd11e],a ; initialize [wd11e] to neutral effectiveness
+ ld [wTypeEffectiveness],a ; initialize to neutral effectiveness
ld hl,TypeEffects
.loop
ld a,[hli]
cp a,$ff
ret z
- cp d ; match the type of the move
+ cp d ; match the type of the move
jr nz,.nextTypePair1
ld a,[hli]
- cp b ; match with type 1 of pokemon
+ cp b ; match with type 1 of pokemon
jr z,.done
- cp c ; or match with type 2 of pokemon
+ cp c ; or match with type 2 of pokemon
jr z,.done
jr .nextTypePair2
.nextTypePair1
@@ -5416,7 +5432,7 @@ AIGetTypeEffectiveness: ; 3e449 (f:6449)
jr .loop
.done
ld a,[hl]
- ld [wd11e],a ; store damage multiplier
+ ld [wTypeEffectiveness],a ; store damage multiplier
ret
INCLUDE "data/type_effects.asm"
@@ -5424,15 +5440,15 @@ INCLUDE "data/type_effects.asm"
; some tests that need to pass for a move to hit
MoveHitTest: ; 3e56b (f:656b)
; player's turn
- ld hl,W_ENEMYBATTSTATUS1
- ld de,W_PLAYERMOVEEFFECT
+ ld hl,wEnemyBattleStatus1
+ ld de,wPlayerMoveEffect
ld bc,wEnemyMonStatus
ld a,[H_WHOSETURN]
and a
jr z,.dreamEaterCheck
; enemy's turn
- ld hl,W_PLAYERBATTSTATUS1
- ld de,W_ENEMYMOVEEFFECT
+ ld hl,wPlayerBattleStatus1
+ ld de,wEnemyMoveEffect
ld bc,wBattleMonStatus
.dreamEaterCheck
ld a,[de]
@@ -5461,7 +5477,7 @@ MoveHitTest: ; 3e56b (f:656b)
jr nz,.enemyTurn
.playerTurn
; this checks if the move effect is disallowed by mist
- ld a,[W_PLAYERMOVEEFFECT]
+ ld a,[wPlayerMoveEffect]
cp a,ATTACK_DOWN1_EFFECT
jr c,.skipEnemyMistCheck
cp a,HAZE_EFFECT + 1
@@ -5478,16 +5494,16 @@ MoveHitTest: ; 3e56b (f:656b)
; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT*
; the moves that are marked with an asterisk are not affected since this
; function is not called when those moves are used
- ld a,[W_ENEMYBATTSTATUS2]
+ ld a,[wEnemyBattleStatus2]
bit ProtectedByMist,a ; is mon protected by mist?
jp nz,.moveMissed
.skipEnemyMistCheck
- ld a,[W_PLAYERBATTSTATUS2]
+ ld a,[wPlayerBattleStatus2]
bit UsingXAccuracy,a ; is the player using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
jr .calcHitChance
.enemyTurn
- ld a,[W_ENEMYMOVEEFFECT]
+ ld a,[wEnemyMoveEffect]
cp a,ATTACK_DOWN1_EFFECT
jr c,.skipPlayerMistCheck
cp a,HAZE_EFFECT + 1
@@ -5499,21 +5515,21 @@ MoveHitTest: ; 3e56b (f:656b)
jr .skipPlayerMistCheck
.playerMistCheck
; similar to enemy mist check
- ld a,[W_PLAYERBATTSTATUS2]
+ ld a,[wPlayerBattleStatus2]
bit ProtectedByMist,a ; is mon protected by mist?
jp nz,.moveMissed
.skipPlayerMistCheck
- ld a,[W_ENEMYBATTSTATUS2]
+ ld a,[wEnemyBattleStatus2]
bit UsingXAccuracy,a ; is the enemy using X Accuracy?
ret nz ; if so, always hit regardless of accuracy/evasion
.calcHitChance
call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion
- ld a,[W_PLAYERMOVEACCURACY]
+ ld a,[wPlayerMoveAccuracy]
ld b,a
ld a,[H_WHOSETURN]
and a
jr z,.doAccuracyCheck
- ld a,[W_ENEMYMOVEACCURACY]
+ ld a,[wEnemyMoveAccuracy]
ld b,a
.doAccuracyCheck
; if the random number generated is greater than or equal to the scaled accuracy, the move misses
@@ -5524,26 +5540,26 @@ MoveHitTest: ; 3e56b (f:656b)
ret
.moveMissed
xor a
- ld hl,W_DAMAGE ; zero the damage
+ ld hl,wDamage ; zero the damage
ld [hli],a
ld [hl],a
inc a
- ld [W_MOVEMISSED],a
+ ld [wMoveMissed],a
ld a,[H_WHOSETURN]
and a
jr z,.playerTurn2
.enemyTurn2
- ld hl,W_ENEMYBATTSTATUS1
+ ld hl,wEnemyBattleStatus1
res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
ret
.playerTurn2
- ld hl,W_PLAYERBATTSTATUS1
+ ld hl,wPlayerBattleStatus1
res UsingTrappingMove,[hl] ; end multi-turn attack e.g. wrap
ret
; values for player turn
CalcHitChance: ; 3e624 (f:6624)
- ld hl,W_PLAYERMOVEACCURACY
+ ld hl,wPlayerMoveAccuracy
ld a,[H_WHOSETURN]
and a
ld a,[wPlayerMonAccuracyMod]
@@ -5552,7 +5568,7 @@ CalcHitChance: ; 3e624 (f:6624)
ld c,a
jr z,.next
; values for enemy turn
- ld hl,W_ENEMYMOVEACCURACY
+ ld hl,wEnemyMoveAccuracy
ld a,[wEnemyMonAccuracyMod]
ld b,a
ld a,[wPlayerMonEvasionMod]
@@ -5615,7 +5631,7 @@ CalcHitChance: ; 3e624 (f:6624)
; multiplies damage by a random percentage from ~85% to 100%
RandomizeDamage: ; 3e687 (f:6687)
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld a, [hli]
and a
jr nz, .DamageGreaterThanOne
@@ -5644,7 +5660,7 @@ RandomizeDamage: ; 3e687 (f:6687)
call Divide ; divide the result by 255
; store the modified damage
ld a, [H_QUOTIENT + 2]
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld [hli], a
ld a, [H_QUOTIENT + 3]
ld [hl], a
@@ -5670,7 +5686,7 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc)
ld hl, wAILayer2Encouragement
inc [hl]
xor a
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
ld [wMoveDidntMiss], a
ld a, $a
ld [wDamageMultipliers], a
@@ -5678,23 +5694,23 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc)
jr nz, .enemyHasNoSpecialConditions
jp [hl]
.enemyHasNoSpecialConditions
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
bit ChargingUp, [hl] ; is the enemy charging up for attack?
jr nz, EnemyCanExecuteChargingMove ; if so, jump
call GetCurrentMove
CheckIfEnemyNeedsToChargeUp: ; 3e6fc (f:66fc)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp CHARGE_EFFECT
jp z, JumpMoveEffect
cp FLY_EFFECT
jp z, JumpMoveEffect
jr EnemyCanExecuteMove
EnemyCanExecuteChargingMove: ; 3e70b (f:670b)
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res ChargingUp, [hl] ; no longer charging up for attack
res Invulnerable, [hl] ; no longer invulnerable to typical attacks
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld [wd0b5], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
@@ -5707,19 +5723,19 @@ EnemyCanExecuteMove: ; 3e72b (f:672b)
xor a
ld [wMonIsDisobedient], a
call PrintMonName1Text
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, ResidualEffects1
ld de, $1
call IsInArray
jp c, JumpMoveEffect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, SpecialEffectsCont
ld de, $1
call IsInArray
call c, JumpMoveEffect
EnemyCalcMoveDamage: ; 3e750 (f:6750)
call SwapPlayerAndEnemyLevels
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, SetDamageEffects
ld de, $1
call IsInArray
@@ -5738,10 +5754,10 @@ EnemyCalcMoveDamage: ; 3e750 (f:6750)
EnemyMoveHitTest: ; 3e77f (f:677f)
call MoveHitTest
handleIfEnemyMoveMissed: ; 3e782 (f:6782)
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr z, .asm_3e791
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
jr z, asm_3e7a0
jr EnemyCheckIfFlyOrChargeEffect
@@ -5749,7 +5765,7 @@ handleIfEnemyMoveMissed: ; 3e782 (f:6782)
call SwapPlayerAndEnemyLevels
GetEnemyAnimationType: ; 3e794 (f:6794)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
and a
ld a, $1
jr z, playEnemyMoveAnimation
@@ -5760,18 +5776,18 @@ asm_3e7a0: ; 3e7a0 (f:67a0)
xor a
playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
push af
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
bit HasSubstituteUp, a ; does mon have a substitute?
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
pop af
ld [wAnimationType], a
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
call PlayMoveAnimation
call HandleExplodingAnimation
call DrawEnemyHUDAndHPBar
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
bit HasSubstituteUp, a ; does mon have a substitute?
ld hl, ReshowSubstituteAnim
ld b, BANK(ReshowSubstituteAnim)
@@ -5782,7 +5798,7 @@ EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
call SwapPlayerAndEnemyLevels
ld c, 30
call DelayFrames
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
jr z, .playAnim
cp CHARGE_EFFECT
@@ -5794,7 +5810,7 @@ EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
ld a,STATUS_AFFECTED_ANIM
call PlayMoveAnimation
EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp MIRROR_MOVE_EFFECT
jr nz, .notMirrorMoveEffect
call MirrorMoveCopyMove
@@ -5806,16 +5822,16 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
call MetronomePickMove
jp CheckIfEnemyNeedsToChargeUp
.notMetronomeEffect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, ResidualEffects2
ld de, $1
call IsInArray
jp c, JumpMoveEffect
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr z, .asm_3e82b
call PrintMoveFailureText
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
jr z, .asm_3e83e
jp ExecuteEnemyMoveDone
@@ -5826,7 +5842,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
ld a, 1
ld [wMoveDidntMiss], a
.asm_3e83e
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, AlwaysHappenSideEffects
ld de, $1
call IsInArray
@@ -5837,7 +5853,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
or b
ret z
call HandleBuildingRage
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
bit AttackingMultipleTimes, [hl] ; is mon hitting multiple times? (example: double kick)
jr z, .asm_3e873
push hl
@@ -5851,7 +5867,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
xor a
ld [wEnemyNumHits], a
.asm_3e873
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
and a
jr z, ExecuteEnemyMoveDone
ld hl, SpecialEffects
@@ -5904,7 +5920,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfTrapped
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
bit UsingTrappingMove, a ; is the player using a multi-turn attack like warp
jp z, .checkIfFlinched
ld hl, CantMoveText
@@ -5912,7 +5928,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfFlinched
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
bit Flinched, [hl] ; check if enemy mon flinched
jp z, .checkIfMustRecharge
res Flinched, [hl]
@@ -5921,7 +5937,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfMustRecharge
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
bit NeedsToRecharge, [hl] ; check if enemy mon has to recharge after using a move
jr z, .checkIfAnyMoveDisabled
res NeedsToRecharge, [hl]
@@ -5930,7 +5946,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfAnyMoveDisabled
- ld hl, W_ENEMYDISABLEDMOVE
+ ld hl, wEnemyDisabledMove
ld a, [hl]
and a
jr z, .checkIfConfused
@@ -5943,13 +5959,13 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, DisabledNoMoreText
call PrintText
.checkIfConfused
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
add a ; check if enemy mon is confused
jp nc, .checkIfTriedToUseDisabledMove
- ld hl, W_ENEMYCONFUSEDCOUNTER
+ ld hl, wEnemyConfusedCounter
dec [hl]
jr nz, .isConfused
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res Confused, [hl] ; if confused counter hit 0, reset confusion status
ld hl, ConfusedNoMoreText
call PrintText
@@ -5964,9 +5980,9 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call BattleRandom
cp $80
jr c, .checkIfTriedToUseDisabledMove
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld a, [hl]
- and 1 << Confused ; if mon hurts itself, clear every other status from W_ENEMYBATTSTATUS1
+ and 1 << Confused ; if mon hurts itself, clear every other status from wEnemyBattleStatus1
ld [hl], a
ld hl, HurtItselfText
call PrintText
@@ -5979,7 +5995,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld [hli], a
ld a, [wEnemyMonDefense + 1]
ld [hl], a
- ld hl, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyMoveEffect
push hl
ld a, [hl]
push af
@@ -6030,12 +6046,12 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, FullyParalyzedText
call PrintText
.monHurtItselfOrFullyParalysed
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld a, [hl]
; clear bide, thrashing about, charging up, and multi-turn moves such as warp
and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
ld [hl], a
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
jr z, .flyOrChargeEffect
cp CHARGE_EFFECT
@@ -6050,12 +6066,12 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone
jp .enemyReturnToHL ; if using a two-turn move, enemy needs to recharge the first turn
.checkIfUsingBide
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
bit StoringEnergy, [hl] ; is mon using bide?
jr z, .checkIfThrashingAbout
xor a
- ld [W_ENEMYMOVENUM], a
- ld hl, W_DAMAGE
+ ld [wEnemyMoveNum], a
+ ld hl, wDamage
ld a, [hli]
ld b, a
ld c, [hl]
@@ -6072,30 +6088,30 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone
jp .enemyReturnToHL ; unless mon unleashes energy, can't move this turn
.unleashEnergy
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res StoringEnergy, [hl] ; not using bide any more
ld hl, UnleashedEnergyText
call PrintText
ld a, $1
- ld [W_ENEMYMOVEPOWER], a
+ ld [wEnemyMovePower], a
ld hl, wEnemyBideAccumulatedDamage + 1
ld a, [hld]
add a
ld b, a
- ld [W_DAMAGE + 1], a
+ ld [wDamage + 1], a
ld a, [hl]
rl a ; double the damage
- ld [W_DAMAGE], a
+ ld [wDamage], a
or b
jr nz, .next
ld a, $1
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
.next
xor a
ld [hli], a
ld [hl], a
ld a, BIDE
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
call SwapPlayerAndEnemyLevels
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
@@ -6103,7 +6119,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
jr z, .checkIfUsingMultiturnMove
ld a, THRASH
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
ld hl, ThrashingAboutText
call PrintText
ld hl, wEnemyNumAttacksLeft
@@ -6111,14 +6127,14 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, EnemyCalcMoveDamage ; skip DecrementPP
jp nz, .enemyReturnToHL
push hl
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
res ThrashingAbout, [hl] ; mon is no longer using thrash or petal dance
set Confused, [hl] ; mon is now confused
call BattleRandom
and $3
inc a
inc a ; confused for 2-5 turns
- ld [W_ENEMYCONFUSEDCOUNTER], a
+ ld [wEnemyConfusedCounter], a
pop hl ; skip DecrementPP
jp .enemyReturnToHL
.checkIfUsingMultiturnMove
@@ -6133,7 +6149,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
jp nz, .enemyReturnToHL
jp .enemyReturnToHL
.checkIfUsingRage
- ld a, [W_ENEMYBATTSTATUS2]
+ ld a, [wEnemyBattleStatus2]
bit UsingRage, a ; is mon using rage?
jp z, .checkEnemyStatusConditionsDone ; if we made it this far, mon can move normally this turn
ld a, RAGE
@@ -6141,7 +6157,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call GetMoveName
call CopyStringToCF4B
xor a
- ld [W_ENEMYMOVEEFFECT], a
+ ld [wEnemyMoveEffect], a
ld hl, EnemyCanExecuteMove
jp .enemyReturnToHL
.enemyReturnToHL
@@ -6156,21 +6172,21 @@ GetCurrentMove: ; 3eabe (f:6abe)
ld a, [H_WHOSETURN]
and a
jp z, .player
- ld de, W_ENEMYMOVENUM
+ ld de, wEnemyMoveNum
ld a, [wEnemySelectedMove]
jr .selected
.player
- ld de, W_PLAYERMOVENUM
- ld a, [W_FLAGS_D733]
- bit 0, a
- ld a, [wccd9]
+ ld de, wPlayerMoveNum
+ ld a, [wFlags_D733]
+ bit BIT_TEST_BATTLE, a
+ ld a, [wTestBattlePlayerSelectedMove]
jr nz, .selected
ld a, [wPlayerSelectedMove]
.selected
ld [wd0b5], a
dec a
ld hl, Moves
- ld bc, $6
+ ld bc, MoveEnd - Moves
call AddNTimes
ld a, BANK(Moves)
call FarCopyData
@@ -6191,13 +6207,13 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld [wEnemyMonSpecies], a
ld [wd0b5], a
call GetMonHeader
- ld a, [W_ENEMYBATTSTATUS3]
+ ld a, [wEnemyBattleStatus3]
bit Transformed, a ; is enemy mon transformed?
- ld hl, wcceb ; copied DVs from when it used Transform
+ ld hl, wTransformedEnemyMonOriginalDVs ; original DVs before transforming
ld a, [hli]
ld b, [hl]
jr nz, .storeDVs
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
cp $2 ; is it a trainer battle?
; fixed DVs for trainer mon
ld a, $98
@@ -6212,7 +6228,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld [hli], a
ld [hl], b
ld de, wEnemyMonLevel
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
ld [de], a
inc de
ld b, $0
@@ -6220,10 +6236,10 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
push hl
call CalcStats
pop hl
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
cp $2 ; is it a trainer battle?
jr z, .copyHPAndStatusFromPartyData
- ld a, [W_ENEMYBATTSTATUS3]
+ ld a, [wEnemyBattleStatus3]
bit Transformed, a ; is enemy mon transformed?
jr nz, .copyTypes ; if transformed, jump
; if it's a wild mon and not transformed, init the current HP to max HP and the status to 0
@@ -6252,7 +6268,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld [wEnemyMonStatus], a
jr .copyTypes
.copyTypes
- ld hl, W_MONHTYPES
+ ld hl, wMonHTypes
ld de, wEnemyMonType
ld a, [hli] ; copy type 1
ld [de], a
@@ -6263,7 +6279,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld a, [hli] ; copy catch rate
ld [de], a
inc de
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
cp $2 ; is it a trainer battle?
jr nz, .copyStandardMoves
; if it's a trainer battle, copy moves from enemy party data
@@ -6276,7 +6292,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
jr .loadMovePPs
.copyStandardMoves
; for a wild mon, first copy default moves from the mon header
- ld hl, W_MONHMOVES
+ ld hl, wMonHMoves
ld a, [hli]
ld [de], a
inc de
@@ -6298,7 +6314,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
ld hl, wEnemyMonMoves
ld de, wEnemyMonPP - 1
predef LoadMovePPs
- ld hl, W_MONHBASESTATS
+ ld hl, wMonHBaseStats
ld de, wEnemyMonBaseStats
ld b, NUM_STATS
.copyBaseStatsLoop
@@ -6307,7 +6323,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
inc de
dec b
jr nz, .copyBaseStatsLoop
- ld hl, W_MONHCATCHRATE
+ ld hl, wMonHCatchRate
ld a, [hli]
ld [de], a
inc de
@@ -6318,7 +6334,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
call GetMonName
ld hl, wcd6d
ld de, wEnemyMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wEnemyMonSpecies2]
ld [wd11e], a
@@ -6375,7 +6391,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32)
ld [hli], a
ld [hli], a
ld [hl], a
- ld [W_PLAYERDISABLEDMOVE], a
+ ld [wPlayerDisabledMove], a
ret
; swaps the level values of the BattleMon and EnemyMon structs
@@ -6394,7 +6410,7 @@ SwapPlayerAndEnemyLevels: ; 3ec81 (f:6c81)
; also writes OAM data and loads tile patterns for the Red or Old Man back sprite's head
; (for use when scrolling the player sprite and enemy's silhouettes on screen)
LoadPlayerBackPic: ; 3ec92 (f:6c92)
- ld a, [W_BATTLETYPE]
+ ld a, [wBattleType]
dec a ; is it the old man tutorial?
ld de, RedPicBack
jr nz, .next
@@ -6441,7 +6457,7 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92)
xor a
ld [$4000], a
ld hl, vSprites
- ld de, S_SPRITEBUFFER1
+ ld de, sSpriteBuffer1
ld a, [H_LOADEDROMBANK]
ld b, a
ld c, 7 * 7
@@ -6569,12 +6585,12 @@ CalculateModifiedStats: ; 3ed99 (f:6d99)
CalculateModifiedStat: ; 3eda5 (f:6da5)
push bc
push bc
- ld a, [wd11e]
+ ld a, [wCalculateWhoseStats]
and a
ld a, c
ld hl, wBattleMonAttack
ld de, wPlayerMonUnmodifiedAttack
- ld bc, wPlayerMonAttackMod
+ ld bc, wPlayerMonStatMods
jr z, .next
ld hl, wEnemyMonAttack
ld de, wEnemyMonUnmodifiedAttack
@@ -6648,7 +6664,7 @@ ApplyBadgeStatBoosts: ; 3ee19 (f:6e19)
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z ; return if link battle
- ld a, [W_OBTAINEDBADGES]
+ ld a, [wObtainedBadges]
ld b, a
ld hl, wBattleMonAttack
ld c, $4
@@ -6707,22 +6723,22 @@ LoadHudTilePatterns: ; 3ee5b (f:6e5b)
.lcdDisabled
ld hl, BattleHudTiles1
ld de, vChars2 + $6d0
- ld bc, $18
+ ld bc, BattleHudTiles1End - BattleHudTiles1
ld a, BANK(BattleHudTiles1)
call FarCopyDataDouble
ld hl, BattleHudTiles2
ld de, vChars2 + $730
- ld bc, $30
+ ld bc, BattleHudTiles3End - BattleHudTiles2
ld a, BANK(BattleHudTiles2)
jp FarCopyDataDouble
.lcdEnabled
ld de, BattleHudTiles1
ld hl, vChars2 + $6d0
- lb bc, BANK(BattleHudTiles1), $03
+ lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8
call CopyVideoDataDouble
ld de, BattleHudTiles2
ld hl, vChars2 + $730
- lb bc, BANK(BattleHudTiles2), $06
+ lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8
jp CopyVideoDataDouble
PrintEmptyString: ; 3ee94 (f:6e94)
@@ -6788,12 +6804,12 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3)
ld a, [H_WHOSETURN]
and a
ld hl, wEnemyMonType1
- ld de, W_ENEMYBATTSTATUS1
- ld a, [W_PLAYERMOVENUM]
+ ld de, wEnemyBattleStatus1
+ ld a, [wPlayerMoveNum]
jr z, .asm_3eeea
ld hl, wBattleMonType1
- ld de, W_ENEMYBATTSTATUS1
- ld a, [W_ENEMYMOVENUM]
+ ld de, wEnemyBattleStatus1
+ ld a, [wEnemyMoveNum]
.asm_3eeea
cp SELFDESTRUCT
jr z, .asm_3eef1
@@ -6809,24 +6825,24 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3)
ld a, [hl]
cp GHOST
ret z
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
ret nz
ld a, 5
ld [wAnimationType], a
PlayMoveAnimation: ; 3ef07 (f:6f07)
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
call Delay3
predef_jump MoveAnimation
InitBattle: ; 3ef12 (f:6f12)
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
and a
jr z, DetermineWildOpponent
InitOpponent: ; 3ef18 (f:6f18)
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
jr InitBattleCommon
@@ -6853,9 +6869,9 @@ InitBattleCommon: ; 3ef3d (f:6f3d)
res 1, [hl]
callab InitBattleVariables
ld a, [wEnemyMonSpecies2]
- sub $c8
+ sub 200
jp c, InitWildBattle
- ld [W_TRAINERCLASS], a
+ ld [wTrainerClass], a
call GetTrainerInformation
callab ReadTrainer
call DoBattleTransitionAndInitBattleVariables
@@ -6870,21 +6886,21 @@ InitBattleCommon: ; 3ef3d (f:6f3d)
ld a, $ff
ld [wEnemyMonPartyPos], a
ld a, $2
- ld [W_ISINBATTLE], a
- jp InitBattle_Common
+ ld [wIsInBattle], a
+ jp _InitBattleCommon
InitWildBattle: ; 3ef8b (f:6f8b)
ld a, $1
- ld [W_ISINBATTLE], a
+ ld [wIsInBattle], a
call LoadEnemyMonData
call DoBattleTransitionAndInitBattleVariables
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
cp MAROWAK
jr z, .isGhost
call IsGhostBattle
jr nz, .isNoGhost
.isGhost
- ld hl, W_MONHSPRITEDIM
+ ld hl, wMonHSpriteDim
ld a, $66
ld [hli], a ; write sprite dimensions
ld bc, GhostPic
@@ -6917,15 +6933,15 @@ InitWildBattle: ; 3ef8b (f:6f8b)
call LoadMonFrontSprite ; load mon sprite
.spriteLoaded
xor a
- ld [W_TRAINERCLASS], a
+ ld [wTrainerClass], a
ld [hStartTileID], a
coord hl, 12, 0
predef CopyUncompressedPicToTilemap
; common code that executes after init battle code specific to trainer or wild battles
-InitBattle_Common: ; 3efeb (f:6feb)
- ld b, $0
- call GoPAL_SET
+_InitBattleCommon: ; 3efeb (f:6feb)
+ ld b, SET_PAL_BATTLE_BLACK
+ call RunPaletteCommand
call SlidePlayerAndEnemySilhouettesOnScreen
xor a
ld [H_AUTOBGTRANSFERENABLED], a
@@ -6948,7 +6964,7 @@ InitBattle_Common: ; 3efeb (f:6feb)
lb bc, 4, 10
call ClearScreenArea
call ClearSprites
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a ; is it a wild battle?
call z, DrawEnemyHUDAndHPBar ; draw enemy HUD and HP bar if it's a wild battle
call StartBattle
@@ -6985,8 +7001,8 @@ _LoadTrainerPic: ; 3f04b (f:704b)
; unreferenced
ResetCryModifiers: ; 3f069 (f:7069)
xor a
- ld [wc0f1], a
- ld [wc0f2], a
+ ld [wFrequencyModifier], a
+ ld [wTempoModifier], a
jp PlaySound
; animates the mon "growing" out of the pokeball
@@ -6998,7 +7014,7 @@ AnimateSendingOutMon: ; 3f073 (f:7073)
ld a, [hStartTileID]
ld [hBaseTileID], a
ld b, $4c
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jr z, .notInBattle
add b
@@ -7040,7 +7056,7 @@ CopyUncompressedPicToHL: ; 3f0d0 (f:70d0)
lb bc, 7, 7
ld de, SCREEN_WIDTH
push af
- ld a, [W_SPRITEFLIPPED]
+ ld a, [wSpriteFlipped]
and a
jr nz, .flipped
pop af
@@ -7092,7 +7108,7 @@ LoadMonBackPic: ; 3f103 (f:7103)
ld b, 7
ld c, 8
call ClearScreenArea
- ld hl, W_MONHBACKSPRITE - W_MONHEADER
+ ld hl, wMonHBackSprite - wMonHeader
call UncompressMonSprite
predef ScaleSpriteByTwo
ld de, vBackPic
@@ -7112,9 +7128,9 @@ JumpMoveEffect: ; 3f132 (f:7132)
_JumpMoveEffect: ; 3f138 (f:7138)
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .next1
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.next1
dec a ; subtract 1, there is no special effect for 00
add a ; x2, 16bit pointers
@@ -7217,12 +7233,12 @@ MoveEffectPointerTable: ; 3f150 (f:7150)
SleepEffect: ; 3f1fc (f:71fc)
ld de, wEnemyMonStatus
- ld bc, W_ENEMYBATTSTATUS2
+ ld bc, wEnemyBattleStatus2
ld a, [H_WHOSETURN]
and a
jp z, .sleepEffect
ld de, wBattleMonStatus
- ld bc, W_PLAYERBATTSTATUS2
+ ld bc, wPlayerBattleStatus2
.sleepEffect
ld a, [bc]
@@ -7244,7 +7260,7 @@ SleepEffect: ; 3f1fc (f:71fc)
push de
call MoveHitTest ; apply accuracy tests
pop de
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .didntAffect
.setSleepCounter
@@ -7269,12 +7285,12 @@ AlreadyAsleepText: ; 3f24a (f:724a)
PoisonEffect: ; 3f24f (f:724f)
ld hl, wEnemyMonStatus
- ld de, W_PLAYERMOVEEFFECT
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .poisonEffect
ld hl, wBattleMonStatus
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.poisonEffect
call CheckTargetSubstitute
jr nz, .noEffect ; can't posion a substitute target
@@ -7300,7 +7316,7 @@ PoisonEffect: ; 3f24f (f:724f)
call MoveHitTest ; apply accuracy tests
pop de
pop hl
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .didntAffect
jr .inflictPoison
@@ -7316,13 +7332,13 @@ PoisonEffect: ; 3f24f (f:724f)
ld a, [H_WHOSETURN]
and a
ld b, ANIM_C7
- ld hl, W_PLAYERBATTSTATUS3
+ ld hl, wPlayerBattleStatus3
ld a, [de]
- ld de, W_PLAYERTOXICCOUNTER
+ ld de, wPlayerToxicCounter
jr nz, .ok
ld b, ANIM_A9
- ld hl, W_ENEMYBATTSTATUS3
- ld de, W_ENEMYTOXICCOUNTER
+ ld hl, wEnemyBattleStatus3
+ ld de, wEnemyToxcCounter
.ok
cp TOXIC
jr nz, .normalPoison ; done if move is not Toxic
@@ -7366,12 +7382,12 @@ DrainHPEffect: ; 3f2e9 (f:72e9)
ExplodeEffect: ; 3f2f1 (f:72f1)
ld hl, wBattleMonHP
- ld de, W_PLAYERBATTSTATUS2
+ ld de, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .faintUser
ld hl, wEnemyMonHP
- ld de, W_ENEMYBATTSTATUS2
+ ld de, wEnemyBattleStatus2
.faintUser
xor a
ld [hli], a ; set the mon's HP to 0
@@ -7394,7 +7410,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c)
ld a, [wEnemyMonStatus]
and a
jp nz, CheckDefrost ; can't inflict status if opponent is already statused
- ld a, [W_PLAYERMOVETYPE]
+ ld a, [wPlayerMoveType]
ld b, a
ld a, [wEnemyMonType1]
cp b ; do target type 1 and move type match?
@@ -7402,7 +7418,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c)
ld a, [wEnemyMonType2]
cp b ; do target type 2 and move type match?
ret z ; return if they match
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
cp a, PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those
ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance
jr c, .next1 ; branch ahead if this is a 10% chance effect..
@@ -7446,7 +7462,7 @@ opponentAttacker: ; 3f382 (f:7382)
ld a, [wBattleMonStatus] ; mostly same as above with addresses swapped for opponent
and a
jp nz, CheckDefrost
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
ld b, a
ld a, [wBattleMonType1]
cp b
@@ -7454,7 +7470,7 @@ opponentAttacker: ; 3f382 (f:7382)
ld a, [wBattleMonType2]
cp b
ret z
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp a, PARALYZE_SIDE_EFFECT1 + 1
ld b, $1a
jr c, .next1
@@ -7504,7 +7520,7 @@ CheckDefrost: ; 3f3e2 (f:73e2)
and a
jr nz, .opponent
;player [attacker]
- ld a, [W_PLAYERMOVETYPE]
+ ld a, [wPlayerMoveType]
sub a, FIRE
ret nz ; return if type of move used isn't fire
ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
@@ -7517,7 +7533,7 @@ CheckDefrost: ; 3f3e2 (f:73e2)
ld hl, FireDefrostedText
jr .common
.opponent
- ld a, [W_ENEMYMOVETYPE] ; same as above with addresses swapped
+ ld a, [wEnemyMoveType] ; same as above with addresses swapped
sub a, FIRE
ret nz
ld [wBattleMonStatus], a
@@ -7537,12 +7553,12 @@ FireDefrostedText: ; 3f423 (f:7423)
StatModifierUpEffect: ; 3f428 (f:7428)
ld hl, wPlayerMonStatMods
- ld de, W_PLAYERMOVEEFFECT
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .statModifierUpEffect
ld hl, wEnemyMonStatMods
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.statModifierUpEffect
ld a, [de]
sub ATTACK_UP1_EFFECT
@@ -7644,14 +7660,14 @@ UpdateStatDone: ; 3f4ca (f:74ca)
ld b, c
inc b
call PrintStatText
- ld hl, W_PLAYERBATTSTATUS2
- ld de, W_PLAYERMOVENUM
+ ld hl, wPlayerBattleStatus2
+ ld de, wPlayerMoveNum
ld bc, wPlayerMonMinimized
ld a, [H_WHOSETURN]
and a
jr z, .asm_3f4e6
- ld hl, W_ENEMYBATTSTATUS2
- ld de, W_ENEMYMOVENUM
+ ld hl, wEnemyBattleStatus2
+ ld de, wEnemyMoveNum
ld bc, wEnemyMonMinimized
.asm_3f4e6
ld a, [de]
@@ -7705,9 +7721,9 @@ MonsStatsRoseText: ; 3f528 (f:7528)
ld hl, GreatlyRoseText
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .asm_3f53b
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.asm_3f53b
cp ATTACK_DOWN1_EFFECT
ret nc
@@ -7724,14 +7740,14 @@ RoseText: ; 3f547 (f:7547)
StatModifierDownEffect: ; 3f54c (f:754c)
ld hl, wEnemyMonStatMods
- ld de, W_PLAYERMOVEEFFECT
- ld bc, W_ENEMYBATTSTATUS1
+ ld de, wPlayerMoveEffect
+ ld bc, wEnemyBattleStatus1
ld a, [H_WHOSETURN]
and a
jr z, .statModifierDownEffect
ld hl, wPlayerMonStatMods
- ld de, W_ENEMYMOVEEFFECT
- ld bc, W_PLAYERBATTSTATUS1
+ ld de, wEnemyMoveEffect
+ ld bc, wPlayerBattleStatus1
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .statModifierDownEffect
@@ -7758,7 +7774,7 @@ StatModifierDownEffect: ; 3f54c (f:754c)
pop bc
pop de
pop hl
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jp nz, MoveMissed
ld a, [bc]
@@ -7907,9 +7923,9 @@ MonsStatsFellText: ; 3f661 (f:7661)
ld hl, FellText
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .asm_3f674
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.asm_3f674
cp $1a
ret c
@@ -7967,13 +7983,13 @@ StatModifierRatios: ; 3f6cb (f:76cb)
db 4, 1 ; 4.00
BideEffect: ; 3f6e5 (f:76e5)
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
ld de, wPlayerBideAccumulatedDamage
ld bc, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN]
and a
jr z, .bideEffect
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld de, wEnemyBideAccumulatedDamage
ld bc, wEnemyNumAttacksLeft
.bideEffect
@@ -7982,8 +7998,8 @@ BideEffect: ; 3f6e5 (f:76e5)
ld [de], a
inc de
ld [de], a
- ld [W_PLAYERMOVEEFFECT], a
- ld [W_ENEMYMOVEEFFECT], a
+ ld [wPlayerMoveEffect], a
+ ld [wEnemyMoveEffect], a
call BattleRandom
and $1
inc a
@@ -7994,12 +8010,12 @@ BideEffect: ; 3f6e5 (f:76e5)
jp PlayBattleAnimation2
ThrashPetalDanceEffect: ; 3f717 (f:7717)
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN]
and a
jr z, .thrashPetalDanceEffect
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.thrashPetalDanceEffect
set ThrashingAbout, [hl] ; mon is now using thrash/petal dance
@@ -8016,10 +8032,10 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld a, [H_WHOSETURN]
and a
jr nz, .asm_3f791
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr nz, .asm_3f77e
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
ld b, a
ld a, [wBattleMonLevel]
cp b
@@ -8037,7 +8053,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
jr nc, .asm_3f76e
ld c, 50
call DelayFrames
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
cp TELEPORT
jp nz, PrintDidntAffectText
jp PrintButItFailedText_
@@ -8047,23 +8063,23 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld [wAnimationType], a
inc a
ld [wEscapedFromBattle], a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
jr .asm_3f7e4
.asm_3f77e
ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
cp TELEPORT
jp nz, PrintText
jp PrintButItFailedText_
.asm_3f791
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
jr nz, .asm_3f7d1
ld a, [wBattleMonLevel]
ld b, a
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
cp b
jr nc, .asm_3f7c1
add b
@@ -8079,7 +8095,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
jr nc, .asm_3f7c1
ld c, 50
call DelayFrames
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
cp TELEPORT
jp nz, PrintDidntAffectText
jp PrintButItFailedText_
@@ -8089,13 +8105,13 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld [wAnimationType], a
inc a
ld [wEscapedFromBattle], a
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
jr .asm_3f7e4
.asm_3f7d1
ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
cp TELEPORT
jp nz, PrintText
jp ConditionalPrintButItFailed
@@ -8128,24 +8144,24 @@ WasBlownAwayText: ; 3f80c (f:780c)
db "@"
TwoToFiveAttacksEffect: ; 3f811 (f:7811)
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft
ld bc, wPlayerNumHits
ld a, [H_WHOSETURN]
and a
jr z, .twoToFiveAttacksEffect
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
ld bc, wEnemyNumHits
.twoToFiveAttacksEffect
bit AttackingMultipleTimes, [hl] ; is mon attacking multiple times?
ret nz
set AttackingMultipleTimes, [hl] ; mon is now attacking multiple times
- ld hl, W_PLAYERMOVEEFFECT
+ ld hl, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .setNumberOfHits
- ld hl, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyMoveEffect
.setNumberOfHits
ld a, [hl]
cp TWINEEDLE_EFFECT
@@ -8175,13 +8191,13 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811)
FlinchSideEffect: ; 3f85b (f:785b)
call CheckTargetSubstitute
ret nz
- ld hl, W_ENEMYBATTSTATUS1
- ld de, W_PLAYERMOVEEFFECT
+ ld hl, wEnemyBattleStatus1
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .flinchSideEffect
- ld hl, W_PLAYERBATTSTATUS1
- ld de, W_ENEMYMOVEEFFECT
+ ld hl, wPlayerBattleStatus1
+ ld de, wEnemyMoveEffect
.flinchSideEffect
ld a, [de]
cp FLINCH_SIDE_EFFECT1
@@ -8200,14 +8216,14 @@ OneHitKOEffect: ; 3f884 (f:7884)
jpab OneHitKOEffect_
ChargeEffect: ; 3f88c (f:788c)
- ld hl, W_PLAYERBATTSTATUS1
- ld de, W_PLAYERMOVEEFFECT
+ ld hl, wPlayerBattleStatus1
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
ld b, XSTATITEM_ANIM
jr z, .chargeEffect
- ld hl, W_ENEMYBATTSTATUS1
- ld de, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyBattleStatus1
+ ld de, wEnemyMoveEffect
ld b, ANIM_AF
.chargeEffect
set ChargingUp, [hl]
@@ -8282,12 +8298,12 @@ DugAHoleText: ; 3f912 (f:7912)
db "@"
TrappingEffect: ; 3f917 (f:7917)
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
ld de, wPlayerNumAttacksLeft
ld a, [H_WHOSETURN]
and a
jr z, .trappingEffect
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
ld de, wEnemyNumAttacksLeft
.trappingEffect
bit UsingTrappingMove, [hl]
@@ -8325,20 +8341,20 @@ ConfusionEffect: ; 3f961 (f:7961)
call CheckTargetSubstitute
jr nz, ConfusionEffectFailed
call MoveHitTest
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, ConfusionEffectFailed
ConfusionSideEffectSuccess: ; 3f96f (f:796f)
ld a, [H_WHOSETURN]
and a
- ld hl, W_ENEMYBATTSTATUS1
- ld bc, W_ENEMYCONFUSEDCOUNTER
- ld a, [W_PLAYERMOVEEFFECT]
+ ld hl, wEnemyBattleStatus1
+ ld bc, wEnemyConfusedCounter
+ ld a, [wPlayerMoveEffect]
jr z, .confuseTarget
- ld hl, W_PLAYERBATTSTATUS1
- ld bc, W_PLAYERCONFUSEDCOUNTER
- ld a, [W_ENEMYMOVEEFFECT]
+ ld hl, wPlayerBattleStatus1
+ ld bc, wPlayerConfusedCounter
+ ld a, [wEnemyMoveEffect]
.confuseTarget
bit Confused, [hl] ; is mon confused?
jr nz, ConfusionEffectFailed
@@ -8373,33 +8389,33 @@ SubstituteEffect: ; 3f9b9 (f:79b9)
jpab SubstituteEffect_
HyperBeamEffect: ; 3f9c1 (f:79c1)
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .hyperBeamEffect
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.hyperBeamEffect
set NeedsToRecharge, [hl] ; mon now needs to recharge
ret
ClearHyperBeam: ; 3f9cf (f:79cf)
push hl
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .asm_3f9db
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
.asm_3f9db
res NeedsToRecharge, [hl] ; mon no longer needs to recharge
pop hl
ret
RageEffect: ; 3f9df (f:79df)
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .player
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.player
set UsingRage, [hl] ; mon is now in "rage" mode
ret
@@ -8408,19 +8424,19 @@ MimicEffect: ; 3f9ed (f:79ed)
ld c, 50
call DelayFrames
call MoveHitTest
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .asm_3fa74
ld a, [H_WHOSETURN]
and a
ld hl, wBattleMonMoves
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
jr nz, .asm_3fa13
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr nz, .asm_3fa3a
ld hl, wEnemyMonMoves
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
.asm_3fa13
bit Invulnerable, a
jr nz, .asm_3fa74
@@ -8445,7 +8461,7 @@ MimicEffect: ; 3f9ed (f:79ed)
ld a, [wEnemyMoveListIndex]
jr .asm_3fa5f
.asm_3fa3a
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
bit Invulnerable, a
jr nz, .asm_3fa74
ld a, [wCurrentMenuItem]
@@ -8489,15 +8505,15 @@ SplashEffect: ; 3fa84 (f:7a84)
DisableEffect: ; 3fa8a (f:7a8a)
call MoveHitTest
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .moveMissed
- ld de, W_ENEMYDISABLEDMOVE
+ ld de, wEnemyDisabledMove
ld hl, wEnemyMonMoves
ld a, [H_WHOSETURN]
and a
jr z, .disableEffect
- ld de, W_PLAYERDISABLEDMOVE
+ ld de, wPlayerDisabledMove
ld hl, wBattleMonMoves
.disableEffect
; no effect if target already has a move disabled
@@ -8551,7 +8567,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
inc a ; 1-8 turns disabled
inc c ; move 1-4 will be disabled
swap c
- add c ; map disabled move to high nibble of W_ENEMYDISABLEDMOVE / W_PLAYERDISABLEDMOVE
+ add c ; map disabled move to high nibble of wEnemyDisabledMove / wPlayerDisabledMove
ld [de], a
call PlayCurrentMoveAnimation2
ld hl, wPlayerDisabledMoveNumber
@@ -8639,11 +8655,11 @@ ParalyzedMayNotAttackText: ; 3fb74 (f:7b74)
CheckTargetSubstitute: ; 3fb79 (f:7b79)
push hl
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .next1
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
.next1
bit HasSubstituteUp, [hl]
pop hl
@@ -8654,16 +8670,16 @@ PlayCurrentMoveAnimation2: ; 3fb89 (f:7b89)
; plays wAnimationType 3 or 6
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.notEnemyTurn
and a
ret z
PlayBattleAnimation2: ; 3fb96 (f:7b96)
; play animation ID at a and animation type 6 or 3
- ld [W_ANIMATIONID], a
+ ld [wAnimationID], a
ld a, [H_WHOSETURN]
and a
ld a, $6
@@ -8680,19 +8696,19 @@ PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8)
ld [wAnimationType], a
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
jr z, .notEnemyTurn
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.notEnemyTurn
and a
ret z
PlayBattleAnimation: ; 3fbb9 (f:7bb9)
; play animation ID at a and predefined animation type
- ld [W_ANIMATIONID], a
+ ld [wAnimationID], a
PlayBattleAnimationGotID: ; 3fbbc (f:7bbc)
-; play animation at W_ANIMATIONID
+; play animation at wAnimationID
push hl
push de
push bc
diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm
index 7345c5c1..f1a0dd58 100644
--- a/engine/battle/decrement_pp.asm
+++ b/engine/battle/decrement_pp.asm
@@ -4,9 +4,9 @@ DecrementPP: ; 68000 (1a:4000)
cp a, STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
- ld hl, W_PLAYERBATTSTATUS1
- ld a, [hli] ; load the W_PLAYERBATTSTATUS1 pokemon status flags and increment hl to load the
- ; W_PLAYERBATTSTATUS2 status flags later
+ ld hl, wPlayerBattleStatus1
+ ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
+ ; wPlayerBattleStatus2 status flags later
and a, (1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << AttackingMultipleTimes)
ret nz ; if any of these statuses are true, don't decrement PP
bit UsingRage, [hl]
@@ -17,7 +17,7 @@ DecrementPP: ; 68000 (1a:4000)
call .DecrementPP
; decrement PP in the party struct
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
bit Transformed, a
ret nz ; Return if transformed. Pokemon Red stores the "current pokemon's" PP
; separately from the "Pokemon in your party's" PP. This is
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 7198d984..8cfd30af 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -1,7 +1,7 @@
DrawAllPokeballs: ; 3a849 (e:6849)
call LoadPartyPokeballGfx
call SetupOwnPartyPokeballs
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
ret z ; return if wild pokémon
jp SetupEnemyPartyPokeballs
@@ -13,7 +13,7 @@ DrawEnemyPokeballs: ; 3a857 (e:6857)
LoadPartyPokeballGfx: ; 3a85d (e:685d)
ld de, PokeballTileGraphics
ld hl, vSprites + $310
- lb bc, BANK(PokeballTileGraphics), $04
+ lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
jp CopyVideoData
SetupOwnPartyPokeballs: ; 3a869 (e:6869)
@@ -22,7 +22,7 @@ SetupOwnPartyPokeballs: ; 3a869 (e:6869)
ld de, wPartyCount
call SetupPokeballs
ld a, $60
- ld hl, W_BASECOORDX
+ ld hl, wBaseCoordX
ld [hli], a
ld [hl], a
ld a, 8
@@ -35,7 +35,7 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887)
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
- ld hl, W_BASECOORDX
+ ld hl, wBaseCoordX
ld a, $48
ld [hli], a
ld [hl], $20
@@ -98,19 +98,19 @@ WritePokeballOAMData: ; 3a8e1 (e:68e1)
ld de, wBuffer
ld c, PARTY_LENGTH
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld [hli], a
ld a, [de]
ld [hli], a
xor a
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld b, a
ld a, [wHUDPokeballGfxOffsetX]
add b
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
inc de
dec c
jr nz, .loop
@@ -168,7 +168,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948)
ld hl, wPartyMons
ld de, wPartyCount
call SetupPokeballs
- ld hl, W_BASECOORDX
+ ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $40
@@ -179,7 +179,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948)
ld hl, wEnemyMons
ld de, wEnemyPartyCount
call SetupPokeballs
- ld hl, W_BASECOORDX
+ ld hl, wBaseCoordX
ld a, $50
ld [hli], a
ld [hl], $68
@@ -189,3 +189,4 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948)
; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
PokeballTileGraphics:: ; 3a97e (e:697e)
INCBIN "gfx/pokeball.2bpp"
+PokeballTileGraphicsEnd:
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index c642d206..34bc3119 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -46,11 +46,11 @@ EndOfBattle: ; 137aa (4:77aa)
.resetVariables
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
- ld [wc02a], a
- ld [W_ISINBATTLE], a
- ld [W_BATTLETYPE], a
- ld [W_MOVEMISSED], a
- ld [W_CUROPPONENT], a
+ ld [wChannelSoundIDs + CH4], a
+ ld [wIsInBattle], a
+ ld [wBattleType], a
+ ld [wMoveMissed], a
+ ld [wCurOpponent], a
ld [wForcePlayerToChooseMon], a
ld [wNumRunAttempts], a
ld [wEscapedFromBattle], a
diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm
index edee81b1..0480bfcb 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -76,14 +76,14 @@ GainExperience: ; 5524f (15:524f)
ld b, [hl]
ld a, [wPlayerID + 1]
cp b
- ld a, $0
+ ld a, 0
jr z, .next
.tradedMon
call BoostExp ; traded mon exp boost
- ld a, $1
+ ld a, 1
.next
ld [wGainBoostedExp], a
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a ; is it a trainer battle?
call nz, BoostExp ; if so, boost exp
inc hl
@@ -92,12 +92,12 @@ GainExperience: ; 5524f (15:524f)
; add the gained exp to the party mon's exp
ld b, [hl]
ld a, [H_QUOTIENT + 3]
- ld [wcf4c], a
+ ld [wExpAmountGained + 1], a
add b
ld [hld], a
ld b, [hl]
ld a, [H_QUOTIENT + 2]
- ld [wcf4b], a
+ ld [wExpAmountGained], a
adc b
ld [hl], a
jr nc, .noCarry
@@ -160,11 +160,11 @@ GainExperience: ; 5524f (15:524f)
ld a, [hl] ; current level
cp d
jp z, .nextMon ; if level didn't change, go to next mon
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
push af
push hl
ld a, d
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld [hl], a
ld bc, wPartyMon1Species - wPartyMon1Level
add hl, bc
@@ -223,7 +223,7 @@ GainExperience: ; 5524f (15:524f)
ld bc, 1 + NUM_STATS * 2 ; size of stats
call CopyData
pop hl
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
bit 3, a ; is the mon transformed?
jr nz, .recalcStatChanges
; the mon is not transformed, so update the unmodified stats
@@ -231,8 +231,8 @@ GainExperience: ; 5524f (15:524f)
ld bc, 1 + NUM_STATS * 2
call CopyData
.recalcStatChanges
- xor a
- ld [wd11e], a
+ xor a ; battle mon
+ ld [wCalculateWhoseStats], a
callab CalculateModifiedStats
callab ApplyBurnAndParalysisPenaltiesToPlayer
callab ApplyBadgeStatBoosts
@@ -261,7 +261,7 @@ GainExperience: ; 5524f (15:524f)
predef FlagActionPredef
pop hl
pop af
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
.nextMon
ld a, [wPartyCount]
diff --git a/engine/battle/get_trainer_name.asm b/engine/battle/get_trainer_name.asm
index 961f25cf..36492292 100644
--- a/engine/battle/get_trainer_name.asm
+++ b/engine/battle/get_trainer_name.asm
@@ -1,10 +1,10 @@
GetTrainerName_: ; 13a58 (4:7a58)
- ld hl, W_GRASSRATE
+ ld hl, wGrassRate
ld a, [wLinkState]
and a
jr nz, .rival
- ld hl, W_RIVALNAME
- ld a, [W_TRAINERCLASS]
+ ld hl, wRivalName
+ ld a, [wTrainerClass]
cp SONY1
jr z, .rival
cp SONY2
@@ -19,6 +19,6 @@ GetTrainerName_: ; 13a58 (4:7a58)
call GetName
ld hl, wcd6d
.rival
- ld de, W_TRAINERNAME
+ ld de, wTrainerName
ld bc, $d
jp CopyData
diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm
index d76f3f41..6702589d 100644
--- a/engine/battle/ghost_marowak_anim.asm
+++ b/engine/battle/ghost_marowak_anim.asm
@@ -55,22 +55,22 @@ CopyMonPicFromBGToSpriteVRAM: ; 7092a (1c:492a)
ld bc, 7 * 7
call CopyVideoData
ld a, $10
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, $70
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld hl, wOAMBuffer
lb bc, 6, 6
ld d, $8
.oamLoop
push bc
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld e, a
.oamInnerLoop
ld a, e
add $8
ld e, a
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld [hli], a
ld a, d
ld [hli], a
@@ -80,9 +80,9 @@ CopyMonPicFromBGToSpriteVRAM: ; 7092a (1c:492a)
dec c
jr nz, .oamInnerLoop
inc d
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add $8
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
pop bc
dec b
jr nz, .oamLoop
diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm
index 3c926858..9372a786 100644
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -16,23 +16,23 @@ InitBattleVariables: ; 525af (14:65af)
ld [wPlayerMonNumber], a
ld [wEscapedFromBattle], a
ld [wMapPalOffset], a
- ld hl, wcf1d
- ld [hli], a
- ld [hl], a
+ ld hl, wPlayerHPBarColor
+ ld [hli], a ; wPlayerHPBarColor
+ ld [hl], a ; wEnemyHPBarColor
ld hl, wCanEvolveFlags
ld b, $3c
.loop
ld [hli], a
dec b
jr nz, .loop
- inc a
- ld [wccd9], a
- ld a, [W_CURMAP]
+ inc a ; POUND
+ ld [wTestBattlePlayerSelectedMove], a
+ ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr c, .notSafariBattle
cp SAFARI_ZONE_REST_HOUSE_1
jr nc, .notSafariBattle
- ld a, $2 ; safari battle
- ld [W_BATTLETYPE], a
+ ld a, BATTLE_TYPE_SAFARI
+ ld [wBattleType], a
.notSafariBattle
jpab PlayBattleMusic
diff --git a/engine/battle/moveEffects/conversion_effect.asm b/engine/battle/moveEffects/conversion_effect.asm
index e4c5b4bd..8e895361 100644
--- a/engine/battle/moveEffects/conversion_effect.asm
+++ b/engine/battle/moveEffects/conversion_effect.asm
@@ -3,13 +3,13 @@ ConversionEffect_: ; 139a3 (4:79a3)
ld de, wBattleMonType1
ld a, [H_WHOSETURN]
and a
- ld a, [W_ENEMYBATTSTATUS1]
+ ld a, [wEnemyBattleStatus1]
jr z, .conversionEffect
push hl
ld h, d
ld l, e
pop de
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
.conversionEffect
bit Invulnerable, a ; is mon immune to typical attacks (dig/fly)
jr nz, PrintButItFailedText
diff --git a/engine/battle/moveEffects/drain_hp_effect.asm b/engine/battle/moveEffects/drain_hp_effect.asm
index 1096794f..ffa75c13 100644
--- a/engine/battle/moveEffects/drain_hp_effect.asm
+++ b/engine/battle/moveEffects/drain_hp_effect.asm
@@ -1,5 +1,5 @@
DrainHPEffect_: ; 783f (1:783f)
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld a, [hl]
srl a ; divide damage by 2
ld [hli], a
@@ -36,12 +36,12 @@ DrainHPEffect_: ; 783f (1:783f)
dec bc
ld [bc], a
; add damage to attacker's HP and copy new HP to wHPBarNewHP
- ld a, [W_DAMAGE + 1]
+ ld a, [wDamage + 1]
ld b, [hl]
add b
ld [hld], a
ld [wHPBarNewHP], a
- ld a, [W_DAMAGE]
+ ld a, [wDamage]
ld b, [hl]
adc b
ld [hli], a
@@ -85,9 +85,9 @@ DrainHPEffect_: ; 783f (1:783f)
ld hl, SuckedHealthText
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVEEFFECT]
+ ld a, [wPlayerMoveEffect]
jr z, .next3
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.next3
cp DREAM_EATER_EFFECT
jr nz, .printText
diff --git a/engine/battle/moveEffects/focus_energy_effect.asm b/engine/battle/moveEffects/focus_energy_effect.asm
index b8a783e4..b1cd03f3 100644
--- a/engine/battle/moveEffects/focus_energy_effect.asm
+++ b/engine/battle/moveEffects/focus_energy_effect.asm
@@ -1,9 +1,9 @@
FocusEnergyEffect_: ; 27f86 (9:7f86)
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .notEnemy
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.notEnemy
bit GettingPumped, [hl] ; is mon already using focus energy?
jr nz, .alreadyUsing
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index 5c5443c0..8c759cce 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -31,14 +31,14 @@ HazeEffect_: ; 139da (4:79da)
.cureVolatileStatuses
xor a
- ld [W_PLAYERDISABLEDMOVE], a
- ld [W_ENEMYDISABLEDMOVE], a
+ ld [wPlayerDisabledMove], a
+ ld [wEnemyDisabledMove], a
ld hl, wPlayerDisabledMoveNumber
ld [hli], a
ld [hl], a
- ld hl, W_PLAYERBATTSTATUS1
+ ld hl, wPlayerBattleStatus1
call CureVolatileStatuses
- ld hl, W_ENEMYBATTSTATUS1
+ ld hl, wEnemyBattleStatus1
call CureVolatileStatuses
ld hl, PlayCurrentMoveAnimation
call CallBankF
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index cea63a1f..4b8f83bd 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -3,11 +3,11 @@ HealEffect_: ; 3b9ec (e:79ec)
and a
ld de, wBattleMonHP
ld hl, wBattleMonMaxHP
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
jr z, .healEffect
ld de, wEnemyMonHP
ld hl, wEnemyMonMaxHP
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.healEffect
ld b, a
ld a, [de]
diff --git a/engine/battle/moveEffects/leech_seed_effect.asm b/engine/battle/moveEffects/leech_seed_effect.asm
index 1b0afe4b..ea7ceb30 100644
--- a/engine/battle/moveEffects/leech_seed_effect.asm
+++ b/engine/battle/moveEffects/leech_seed_effect.asm
@@ -1,14 +1,14 @@
LeechSeedEffect_: ; 2bea9 (a:7ea9)
callab MoveHitTest
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .moveMissed
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
ld de, wEnemyMonType1
ld a, [H_WHOSETURN]
and a
jr z, .leechSeedEffect
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld de, wBattleMonType1
.leechSeedEffect
; miss if the target is grass-type or already seeded
diff --git a/engine/battle/moveEffects/mist_effect.asm b/engine/battle/moveEffects/mist_effect.asm
index 1f8e40b0..fcdb4b28 100644
--- a/engine/battle/moveEffects/mist_effect.asm
+++ b/engine/battle/moveEffects/mist_effect.asm
@@ -1,9 +1,9 @@
MistEffect_: ; 33f2b (c:7f2b)
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .mistEffect
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.mistEffect
bit ProtectedByMist, [hl] ; is mon protected by mist?
jr nz, .mistAlreadyInUse
diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm
index 907db80c..efba0b79 100644
--- a/engine/battle/moveEffects/one_hit_ko_effect.asm
+++ b/engine/battle/moveEffects/one_hit_ko_effect.asm
@@ -1,5 +1,5 @@
OneHitKOEffect_: ; 33f57 (c:7f57)
- ld hl, W_DAMAGE
+ ld hl, wDamage
xor a
ld [hli], a
ld [hl], a ; set the damage output to zero
@@ -24,7 +24,7 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
ld a, [hl]
sbc b
jr c, .userIsSlower
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld a, $ff
ld [hli], a
ld [hl], a
@@ -34,5 +34,5 @@ OneHitKOEffect_: ; 33f57 (c:7f57)
.userIsSlower
; keep damage at 0 and set move missed flag if target's current speed is higher instead
ld a, $1
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
ret
diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm
index 658b0c50..eac42a90 100644
--- a/engine/battle/moveEffects/paralyze_effect.asm
+++ b/engine/battle/moveEffects/paralyze_effect.asm
@@ -1,11 +1,11 @@
ParalyzeEffect_: ; 52601 (14:6601)
ld hl, wEnemyMonStatus
- ld de, W_PLAYERMOVETYPE
+ ld de, wPlayerMoveType
ld a, [H_WHOSETURN]
and a
jp z, .next
ld hl, wBattleMonStatus
- ld de, W_ENEMYMOVETYPE
+ ld de, wEnemyMoveType
.next
ld a, [hl]
and a ; does the target already have a status ailment?
@@ -28,7 +28,7 @@ ParalyzeEffect_: ; 52601 (14:6601)
push hl
callab MoveHitTest
pop hl
- ld a, [W_MOVEMISSED]
+ ld a, [wMoveMissed]
and a
jr nz, .didntAffect
set PAR, [hl]
diff --git a/engine/battle/moveEffects/pay_day_effect.asm b/engine/battle/moveEffects/pay_day_effect.asm
index 26e69ef5..eb228615 100644
--- a/engine/battle/moveEffects/pay_day_effect.asm
+++ b/engine/battle/moveEffects/pay_day_effect.asm
@@ -1,4 +1,4 @@
-PayDayEffect_ ; 2feb8 (b:7eb8)
+PayDayEffect_: ; 2feb8 (b:7eb8)
xor a
ld hl, wcd6d
ld [hli], a
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 51232af6..43bf8d5f 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -1,16 +1,16 @@
RecoilEffect_: ; 1392c (4:792c)
ld a, [H_WHOSETURN]
and a
- ld a, [W_PLAYERMOVENUM]
+ ld a, [wPlayerMoveNum]
ld hl, wBattleMonMaxHP
jr z, .recoilEffect
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld hl, wEnemyMonMaxHP
.recoilEffect
ld d, a
- ld a, [W_DAMAGE]
+ ld a, [wDamage]
ld b, a
- ld a, [W_DAMAGE + 1]
+ ld a, [wDamage + 1]
ld c, a
srl b
rr c
diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index df34827f..45f785a4 100644
--- a/engine/battle/moveEffects/reflect_light_screen_effect.asm
+++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm
@@ -1,11 +1,11 @@
ReflectLightScreenEffect_: ; 3bb97 (e:7b97)
- ld hl, W_PLAYERBATTSTATUS3
- ld de, W_PLAYERMOVEEFFECT
+ ld hl, wPlayerBattleStatus3
+ ld de, wPlayerMoveEffect
ld a, [H_WHOSETURN]
and a
jr z, .reflectLightScreenEffect
- ld hl, W_ENEMYBATTSTATUS3
- ld de, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyBattleStatus3
+ ld de, wEnemyMoveEffect
.reflectLightScreenEffect
ld a, [de]
cp LIGHT_SCREEN_EFFECT
diff --git a/engine/battle/moveEffects/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
index c72fffbe..7cac9f62 100644
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -3,13 +3,13 @@ SubstituteEffect_: ; 17dad (5:7dad)
call DelayFrames
ld hl, wBattleMonMaxHP
ld de, wPlayerSubstituteHP
- ld bc, W_PLAYERBATTSTATUS2
+ ld bc, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .notEnemy
ld hl, wEnemyMonMaxHP
ld de, wEnemySubstituteHP
- ld bc, W_ENEMYBATTSTATUS2
+ ld bc, wEnemyBattleStatus2
.notEnemy
ld a, [bc]
bit HasSubstituteUp, a ; user already has substitute?
@@ -44,7 +44,7 @@ SubstituteEffect_: ; 17dad (5:7dad)
ld h, b
ld l, c
set HasSubstituteUp, [hl]
- ld a, [W_OPTIONS]
+ ld a, [wOptions]
bit 7, a ; battle animation is enabled?
ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
diff --git a/engine/battle/moveEffects/transform_effect.asm b/engine/battle/moveEffects/transform_effect.asm
index 185d47af..097a0d3a 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -1,27 +1,27 @@
TransformEffect_: ; 3bab1 (e:7ab1)
ld hl, wBattleMonSpecies
ld de, wEnemyMonSpecies
- ld bc, W_ENEMYBATTSTATUS3
- ld a, [W_ENEMYBATTSTATUS1]
+ ld bc, wEnemyBattleStatus3
+ ld a, [wEnemyBattleStatus1]
ld a, [H_WHOSETURN]
and a
jr nz, .hitTest
ld hl, wEnemyMonSpecies
ld de, wBattleMonSpecies
- ld bc, W_PLAYERBATTSTATUS3
+ ld bc, wPlayerBattleStatus3
ld [wPlayerMoveListIndex], a
- ld a, [W_PLAYERBATTSTATUS1]
+ ld a, [wPlayerBattleStatus1]
.hitTest
bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig)
jp nz, .failed
push hl
push de
push bc
- ld hl, W_PLAYERBATTSTATUS2
+ ld hl, wPlayerBattleStatus2
ld a, [H_WHOSETURN]
and a
jr z, .transformEffect
- ld hl, W_ENEMYBATTSTATUS2
+ ld hl, wEnemyBattleStatus2
.transformEffect
; animation(s) played are different if target has Substitute up
bit HasSubstituteUp, [hl]
@@ -29,7 +29,7 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld hl, HideSubstituteShowMonAnim
ld b, BANK(HideSubstituteShowMonAnim)
call nz, Bankswitch
- ld a, [W_OPTIONS]
+ ld a, [wOptions]
add a
ld hl, PlayCurrentMoveAnimation
ld b, BANK(PlayCurrentMoveAnimation)
@@ -67,12 +67,12 @@ TransformEffect_: ; 3bab1 (e:7ab1)
ld a, [H_WHOSETURN]
and a
jr z, .next
-; save enemy mon DVs in wcceb/wccec (enemy turn only)
+; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
ld a, [de]
- ld [wcceb], a
+ ld [wTransformedEnemyMonOriginalDVs], a
inc de
ld a, [de]
- ld [wccec], a
+ ld [wTransformedEnemyMonOriginalDVs + 1], a
dec de
.next
; DVs
diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm
index 38c701a8..deca2426 100644
--- a/engine/battle/print_type.asm
+++ b/engine/battle/print_type.asm
@@ -6,11 +6,11 @@ PrintMonType: ; 27d6b (9:7d6b)
call GetMonHeader
pop hl
push hl
- ld a, [W_MONHTYPE1]
+ ld a, [wMonHType1]
call PrintType
- ld a, [W_MONHTYPE1]
+ ld a, [wMonHType1]
ld b, a
- ld a, [W_MONHTYPE2]
+ ld a, [wMonHType2]
cp b
pop hl
jr z, EraseType2Text
@@ -34,7 +34,7 @@ EraseType2Text: ; 27d8c (9:7d8c)
PrintMoveType: ; 27d98 (9:7d98)
call GetPredefRegisters
push hl
- ld a, [W_PLAYERMOVETYPE]
+ ld a, [wPlayerMoveType]
; fall through
PrintType_: ; 27d9f (9:7d9f)
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 0976c7c7..4a5657b2 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -15,7 +15,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld [hl],a
; get the pointer to trainer data for this class
- ld a,[W_CUROPPONENT]
+ ld a,[wCurOpponent]
sub $C9 ; convert value from pokemon to trainer
add a,a
ld hl,TrainerDataPointers
@@ -25,7 +25,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld a,[hli]
ld h,[hl]
ld l,a
- ld a,[W_TRAINERNO]
+ ld a,[wTrainerNo]
ld b,a
; At this point b contains the trainer number,
; and hl points to the trainer class.
@@ -43,13 +43,13 @@ ReadTrainer: ; 39c53 (e:5c53)
; if the first byte of trainer data is FF,
; - each pokemon has a specific level
; (as opposed to the whole team being of the same level)
-; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move
+; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team
.IterateTrainer
ld a,[hli]
cp $FF ; is the trainer special?
jr z,.SpecialTrainer ; if so, check for special moves
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
.LoopTrainerData
ld a,[hli]
and a ; have we reached the end of the trainer data?
@@ -65,11 +65,11 @@ ReadTrainer: ; 39c53 (e:5c53)
; if this code is being run:
; - each pokemon has a specific level
; (as opposed to the whole team being of the same level)
-; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move
+; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
ld a,[hli]
and a ; have we reached the end of the trainer data?
jr z,.AddLoneMove
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
ld a,[hli]
ld [wcf91],a
ld a,ENEMY_PARTY_DATA
@@ -80,7 +80,7 @@ ReadTrainer: ; 39c53 (e:5c53)
jr .SpecialTrainer
.AddLoneMove
; does the trainer have a single monster with a different move
- ld a,[W_LONEATTACKNO] ; Brock is 01, Misty is 02, Erika is 04, etc
+ ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a
jr z,.AddTeamMove
dec a
@@ -100,8 +100,8 @@ ReadTrainer: ; 39c53 (e:5c53)
; check if our trainer's team has special moves
; get trainer class number
- ld a,[W_CUROPPONENT]
- sub $C8
+ ld a,[wCurOpponent]
+ sub 200
ld b,a
ld hl,TeamMoves
@@ -130,7 +130,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld [wEnemyMon1Moves + 2],a
; starter
- ld a,[W_RIVALSTARTER]
+ ld a,[wRivalStarter]
cp STARTER3
ld b,MEGA_DRAIN
jr z,.GiveStarterMove
@@ -150,7 +150,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld [de],a
inc de
ld [de],a
- ld a,[W_CURENEMYLVL]
+ ld a,[wCurEnemyLVL]
ld b,a
.LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level
@@ -162,5 +162,5 @@ ReadTrainer: ; 39c53 (e:5c53)
inc de
inc de
dec b
- jr nz,.LastLoop ; repeat W_CURENEMYLVL times
+ jr nz,.LastLoop ; repeat wCurEnemyLVL times
ret
diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm
index 6b0e2220..344e2309 100755
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -18,7 +18,7 @@ PrintSafariZoneBattleText: ; 4277 (1:4277)
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
call GetMonHeader
- ld a, [W_MONHCATCHRATE]
+ ld a, [wMonHCatchRate]
ld [wEnemyMonCatchRate], a
pop hl
.asm_429f
diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm
index 84ef1f69..ceba63bd 100644
--- a/engine/battle/save_trainer_name.asm
+++ b/engine/battle/save_trainer_name.asm
@@ -1,6 +1,6 @@
SaveTrainerName: ; 27e4a (9:7e4a)
ld hl,TrainerNamePointers
- ld a,[W_TRAINERCLASS]
+ ld a,[wTrainerClass]
dec a
ld c,a
ld b,0
@@ -23,50 +23,50 @@ TrainerNamePointers: ; 27e64 (9:7e64)
dw YoungsterName
dw BugCatcherName
dw LassName
- dw W_TRAINERNAME
+ dw wTrainerName
dw JrTrainerMName
dw JrTrainerFName
dw PokemaniacName
dw SuperNerdName
- dw W_TRAINERNAME
- dw W_TRAINERNAME
+ dw wTrainerName
+ dw wTrainerName
dw BurglarName
dw EngineerName
dw JugglerXName
- dw W_TRAINERNAME
+ dw wTrainerName
dw SwimmerName
- dw W_TRAINERNAME
- dw W_TRAINERNAME
+ dw wTrainerName
+ dw wTrainerName
dw BeautyName
- dw W_TRAINERNAME
+ dw wTrainerName
dw RockerName
dw JugglerName
- dw W_TRAINERNAME
- dw W_TRAINERNAME
+ dw wTrainerName
+ dw wTrainerName
dw BlackbeltName
- dw W_TRAINERNAME
+ dw wTrainerName
dw ProfOakName
dw ChiefName
dw ScientistName
- dw W_TRAINERNAME
+ dw wTrainerName
dw RocketName
dw CooltrainerMName
dw CooltrainerFName
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
- dw W_TRAINERNAME
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
+ dw wTrainerName
YoungsterName: ; 27ec2 (9:7ec2)
db "YOUNGSTER@"
diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm
index ed227984..6a8d43a9 100644
--- a/engine/battle/scale_sprites.asm
+++ b/engine/battle/scale_sprites.asm
@@ -2,12 +2,12 @@
; assumes that input sprite chunks are 4x4 tiles, and the rightmost and bottommost 4 pixels will be ignored
; resulting in a 7*7 tile output sprite chunk
ScaleSpriteByTwo: ; 2fe40 (b:7e40)
- ld de, S_SPRITEBUFFER1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
- ld hl, S_SPRITEBUFFER0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
+ ld de, sSpriteBuffer1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
+ ld hl, sSpriteBuffer0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
call ScaleLastSpriteColumnByTwo ; last tile column is special case
call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns
- ld de, S_SPRITEBUFFER2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
- ld hl, S_SPRITEBUFFER1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
+ ld de, sSpriteBuffer2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped
+ ld hl, sSpriteBuffer1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer
call ScaleLastSpriteColumnByTwo ; last tile column is special case
ScaleFirstThreeSpriteColumnsByTwo: ; 2fe55 (b:7e55)
diff --git a/engine/battle/scroll_draw_trainer_pic.asm b/engine/battle/scroll_draw_trainer_pic.asm
index b32650e3..5949208c 100644
--- a/engine/battle/scroll_draw_trainer_pic.asm
+++ b/engine/battle/scroll_draw_trainer_pic.asm
@@ -3,8 +3,8 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3)
; the screen from the right.
xor a
ld [wEnemyMonSpecies2], a
- ld b, $1
- call GoPAL_SET
+ ld b, SET_PAL_BATTLE
+ call RunPaletteCommand
callab _LoadTrainerPic
coord hl, 19, 0
ld c, $0
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 9102b2d8..bab4c253 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -7,7 +7,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld [hli], a ; move 2
ld [hli], a ; move 3
ld [hl], a ; move 4
- ld a, [W_ENEMYDISABLEDMOVE] ; forbid disabled move (if any)
+ ld a, [wEnemyDisabledMove] ; forbid disabled move (if any)
swap a
and $f
jr z, .noMoveDisabled
@@ -19,7 +19,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld [hl], $50 ; forbid (highly discourage) disabled move
.noMoveDisabled
ld hl, TrainerClassMoveChoiceModifications
- ld a, [W_TRAINERCLASS]
+ ld a, [wTrainerClass]
ld b, a
.loopTrainerClasses
dec b
@@ -126,10 +126,10 @@ AIMoveChoiceModification1: ; 397ab (e:57ab)
ret z ; no more moves in move set
inc de
call ReadMove
- ld a, [W_ENEMYMOVEPOWER]
+ ld a, [wEnemyMovePower]
and a
jr nz, .nextMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
push hl
push de
push bc
@@ -171,7 +171,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
ret z ; no more moves in move set
inc de
call ReadMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp ATTACK_UP1_EFFECT
jr c, .nextMove
cp BIDE_EFFECT
@@ -191,7 +191,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
AIMoveChoiceModification3: ; 39817 (e:5817)
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves
- ld b, $5
+ ld b, NUM_MOVES + 1
.nextMove
dec b
ret z ; processed all 4 moves
@@ -208,7 +208,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
pop de
pop bc
pop hl
- ld a, [wd11e]
+ ld a, [wTypeEffectiveness]
cp $10
jr z, .nextMove
jr c, .notEffectiveMove
@@ -218,7 +218,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
push hl
push de
push bc
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
ld d, a
ld hl, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1
@@ -230,17 +230,17 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
and a
jr z, .done
call ReadMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp SUPER_FANG_EFFECT
jr z, .betterMoveFound ; Super Fang is considered to be a better move
cp SPECIAL_DAMAGE_EFFECT
jr z, .betterMoveFound ; any special damage moves are considered to be better moves
cp FLY_EFFECT
jr z, .betterMoveFound ; Fly is considered to be a better move
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
cp d
jr z, .loopMoves
- ld a, [W_ENEMYMOVEPOWER]
+ ld a, [wEnemyMovePower]
and a
jr nz, .betterMoveFound ; damaging moves of a different type are considered to be better moves
jr .loopMoves
@@ -264,9 +264,9 @@ ReadMove: ; 39884 (e:5884)
push bc
dec a
ld hl,Moves
- ld bc,6
+ ld bc,MoveEnd - Moves
call AddNTimes
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
call CopyData
pop bc
pop de
@@ -280,8 +280,8 @@ TrainerClassMoveChoiceModifications: ; 3989b (e:589b)
db 1,0 ; BUG CATCHER
db 1,0 ; LASS
db 1,3,0 ; SAILOR
- db 1,0 ; JR__TRAINER_M
- db 1,0 ; JR__TRAINER_F
+ db 1,0 ; JR_TRAINER_M
+ db 1,0 ; JR_TRAINER_F
db 1,2,3,0; POKEMANIAC
db 1,2,0 ; SUPER_NERD
db 1,0 ; HIKER
@@ -311,7 +311,7 @@ TrainerClassMoveChoiceModifications: ; 3989b (e:589b)
db 1,0 ; BRUNO
db 1,0 ; BROCK
db 1,3,0 ; MISTY
- db 1,3,0 ; LT__SURGE
+ db 1,3,0 ; LT_SURGE
db 1,3,0 ; ERIKA
db 1,3,0 ; KOGA
db 1,3,0 ; BLAINE
@@ -338,13 +338,13 @@ INCLUDE "data/trainer_parties.asm"
TrainerAI: ; 3a52e (e:652e)
and a
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
dec a
ret z ; if not a trainer, we're done here
ld a,[wLinkState]
cp LINK_STATE_BATTLING
ret z
- ld a,[W_TRAINERCLASS] ; what trainer class is this?
+ ld a,[wTrainerClass] ; what trainer class is this?
dec a
ld c,a
ld b,0
@@ -727,27 +727,27 @@ AICureStatus: ; 3a791 (e:6791)
xor a
ld [hl],a ; clear status in enemy team roster
ld [wEnemyMonStatus],a ; clear status of active enemy
- ld hl,W_ENEMYBATTSTATUS3
+ ld hl,wEnemyBattleStatus3
res 0,[hl]
ret
AIUseXAccuracy: ; 0x3a7a8 unused
call AIPlayRestoringSFX
- ld hl,W_ENEMYBATTSTATUS2
+ ld hl,wEnemyBattleStatus2
set 0,[hl]
ld a,X_ACCURACY
jp AIPrintItemUse
AIUseGuardSpec: ; 3a7b5 (e:67b5)
call AIPlayRestoringSFX
- ld hl,W_ENEMYBATTSTATUS2
+ ld hl,wEnemyBattleStatus2
set 1,[hl]
- ld a,GUARD_SPEC_
+ ld a,GUARD_SPEC
jp AIPrintItemUse
AIUseDireHit: ; 0x3a7c2 unused
call AIPlayRestoringSFX
- ld hl,W_ENEMYBATTSTATUS2
+ ld hl,wEnemyBattleStatus2
set 2,[hl]
ld a,DIRE_HIT
jp AIPrintItemUse
@@ -803,7 +803,7 @@ AIIncreaseStat: ; 3a808 (e:6808)
push bc
call AIPrintItemUse_
pop bc
- ld hl,W_ENEMYMOVEEFFECT
+ ld hl,wEnemyMoveEffect
ld a,[hld]
push af
ld a,[hl]
diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm
index 144234bb..044f7ea5 100644
--- a/engine/battle/wild_encounters.asm
+++ b/engine/battle/wild_encounters.asm
@@ -27,24 +27,24 @@ TryDoWildEncounter: ; 13870 (4:7870)
; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile?
coord hl, 9, 9
ld c, [hl]
- ld a, [W_GRASSTILE]
+ ld a, [wGrassTile]
cp c
- ld a, [W_GRASSRATE]
+ ld a, [wGrassRate]
jr z, .CanEncounter
ld a, $14 ; in all tilesets with a water tile, this is its id
cp c
- ld a, [W_WATERRATE]
+ ld a, [wWaterRate]
jr z, .CanEncounter
; even if not in grass/water, standing anywhere we can encounter pokemon
; so long as the map is "indoor" and has wild pokemon defined.
; ...as long as it's not Viridian Forest or Safari Zone.
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp REDS_HOUSE_1F ; is this an indoor map?
jr c, .CantEncounter2
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
cp FOREST ; Viridian Forest/Safari Zone
jr z, .CantEncounter2
- ld a, [W_GRASSRATE]
+ ld a, [wGrassRate]
.CanEncounter
; compare encounter chance with a random number to determine if there will be an encounter
ld b, a
@@ -63,18 +63,18 @@ TryDoWildEncounter: ; 13870 (4:7870)
.gotEncounterSlot
; determine which wild pokemon (grass or water) can appear in the half-block we're standing in
ld c, [hl]
- ld hl, W_GRASSMONS
+ ld hl, wGrassMons
aCoord 8, 9
cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile?
jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default
- ld hl, W_WATERMONS
+ ld hl, wWaterMons
; 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
add hl, bc
ld a, [hli]
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld a, [hl]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
@@ -83,7 +83,7 @@ TryDoWildEncounter: ; 13870 (4:7870)
jr z, .willEncounter
ld a, [wPartyMon1Level]
ld b, a
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
cp b
jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon
jr .willEncounter
diff --git a/engine/cable_club.asm b/engine/cable_club.asm
index 07284d13..f2f881d8 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -57,8 +57,8 @@ CableClub_DoBattleOrTradeAgain: ; 5345
ld [hli], a
dec b
jr nz, .zeroPlayerDataPatchListLoop
- ld hl, W_GRASSRATE
- ld bc, W_TRAINERHEADERPTR - W_GRASSRATE
+ ld hl, wGrassRate
+ ld bc, wTrainerHeaderPtr - wGrassRate
.zeroEnemyPartyLoop
xor a
ld [hli], a
@@ -176,7 +176,7 @@ CableClub_DoBattleOrTradeAgain: ; 5345
jr z, .findStartOfEnemyNameLoop
dec hl
ld de, wLinkEnemyTrainerName
- ld c, 11
+ ld c, NAME_LENGTH
.copyEnemyNameLoop
ld a, [hli]
cp SERIAL_NO_DATA_BYTE
@@ -186,7 +186,7 @@ CableClub_DoBattleOrTradeAgain: ; 5345
dec c
jr nz, .copyEnemyNameLoop
ld de, wEnemyPartyCount
- ld bc, W_TRAINERHEADERPTR - wEnemyPartyCount
+ ld bc, wTrainerHeaderPtr - wEnemyPartyCount
.copyEnemyPartyLoop
ld a, [hli]
cp SERIAL_NO_DATA_BYTE
@@ -256,9 +256,9 @@ CableClub_DoBattleOrTradeAgain: ; 5345
dec c
jr nz, .unpatchEnemyMonsLoop
ld a, wEnemyMonOT % $100
- ld [wcf8d], a
+ ld [wUnusedCF8D], a
ld a, wEnemyMonOT / $100
- ld [wcf8e], a
+ ld [wUnusedCF8D + 1], a
xor a
ld [wTradeCenterPointerTableIndex], a
ld a, $ff
@@ -274,11 +274,11 @@ CableClub_DoBattleOrTradeAgain: ; 5345
jr nz, .asm_5506
ld a, LINK_STATE_BATTLING
ld [wLinkState], a
- ld a, SONY1 + $c8
- ld [W_CUROPPONENT], a
+ ld a, OPP_SONY1
+ ld [wCurOpponent], a
call ClearScreen
call Delay3
- ld hl, W_OPTIONS
+ ld hl, wOptions
res 7, [hl]
predef InitOpponent
predef HealParty
@@ -598,7 +598,7 @@ ReturnToCableClubRoom: ; 577d (1:577d)
TradeCenter_DrawCancelBox:
coord hl, 11, 15
ld a, $7e
- ld bc, 2 * 20 + 9
+ ld bc, 2 * SCREEN_WIDTH + 9
call FillMemory
coord hl, 0, 15
ld b, 1
@@ -614,7 +614,7 @@ CancelTextString:
TradeCenter_PlaceSelectedEnemyMonMenuCursor:
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
coord hl, 1, 9
- ld bc, 20
+ ld bc, SCREEN_WIDTH
call AddNTimes
ld [hl], $ec ; cursor
ret
@@ -698,7 +698,7 @@ TradeCenter_Trade:
call GetMonName
ld hl, wcd6d
ld de, wNameOfPlayerMonToBeTraded
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wTradingWhichEnemyMon]
ld hl, wEnemyPartyMons
@@ -756,7 +756,7 @@ TradeCenter_Trade:
ld hl, wPartyMonOT
call SkipFixedLengthTextEntries
ld de, wTradedPlayerMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMon1Species
ld a, [wTradingWhichPlayerMon]
@@ -772,7 +772,7 @@ TradeCenter_Trade:
ld hl, wEnemyMonOT
call SkipFixedLengthTextEntries
ld de, wTradedEnemyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wEnemyMons
ld a, [wTradingWhichEnemyMon]
@@ -824,19 +824,19 @@ TradeCenter_Trade:
add hl, bc
ld a, [hl]
ld [wTradedEnemyMonSpecies], a
- ld a, $a
- ld [wMusicHeaderPointer], a
+ ld a, 10
+ ld [wAudioFadeOutControl], a
ld a, $2
- ld [wc0f0], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_SAFARI_ZONE
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld c, 100
call DelayFrames
call ClearScreen
call LoadHpBarAndStatusTilePatterns
xor a
- ld [wcc5b], a
+ ld [wUnusedCC5B], a
ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
jr z, .usingExternalClock
@@ -900,27 +900,27 @@ CableClub_Run: ; 5a5f (1:5a5f)
call CableClub_DoBattleOrTrade
ld hl, Club_GFX
ld a, h
- ld [W_TILESETGFXPTR + 1], a
+ ld [wTileSetGFXPtr + 1], a
ld a, l
- ld [W_TILESETGFXPTR], a
+ ld [wTileSetGFXPtr], a
ld a, Bank(Club_GFX)
- ld [W_TILESETBANK], a
+ ld [wTileSetBank], a
ld hl, Club_Coll
ld a, h
- ld [W_TILESETCOLLISIONPTR + 1], a
+ ld [wTileSetCollisionPtr + 1], a
ld a, l
- ld [W_TILESETCOLLISIONPTR], a
+ ld [wTileSetCollisionPtr], a
xor a
- ld [W_GRASSRATE], a
+ ld [wGrassRate], a
inc a ; LINK_STATE_IN_CABLE_CLUB
ld [wLinkState], a
ld [$ffb5], a
- ld a, $a
- ld [wMusicHeaderPointer], a
+ ld a, 10
+ ld [wAudioFadeOutControl], a
ld a, BANK(Music_Celadon)
- ld [wc0f0], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_CELADON
- ld [wc0ee], a
+ ld [wNewSoundID], a
jp PlaySound
EmptyFunc3: ; 5aaf (1:5aaf)
diff --git a/engine/clear_save.asm b/engine/clear_save.asm
index d4f05071..adbef1a4 100755
--- a/engine/clear_save.asm
+++ b/engine/clear_save.asm
@@ -1,6 +1,6 @@
DoClearSaveDialogue: ; 1c98a (7:498a)
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
ld hl, ClearSaveDataText
diff --git a/engine/evolution.asm b/engine/evolution.asm
index 720e77cd..c65cc293 100755
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -8,9 +8,9 @@ EvolveMon: ; 7bde9 (1e:7de9)
push af
xor a
ld [wLowHealthAlarm], a
- ld [wc02a], a
+ ld [wChannelSoundIDs + CH4], a
dec a
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
@@ -21,8 +21,8 @@ EvolveMon: ; 7bde9 (1e:7de9)
ld [H_AUTOBGTRANSFERENABLED], a
ld [hTilesetType], a
ld a, [wEvoOldSpecies]
- ld [wcf1d], a
- ld c, $0
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld c, 0
call EvolutionSetWholeScreenPalette
ld a, [wEvoNewSpecies]
ld [wcf91], a
@@ -46,7 +46,7 @@ EvolveMon: ; 7bde9 (1e:7de9)
call PlayMusic
ld c, 80
call DelayFrames
- ld c, $1
+ ld c, 1 ; set PAL_BLACK instead of mon palette
call EvolutionSetWholeScreenPalette
lb bc, $1, $10
.animLoop
@@ -66,13 +66,13 @@ EvolveMon: ; 7bde9 (1e:7de9)
call Evolution_ChangeMonPic ; show the new species pic
ld a, [wEvoNewSpecies]
.done
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
- ld a, [wcf1d]
+ ld a, [wWholeScreenPaletteMonSpecies]
call PlayCry
- ld c, $0
+ ld c, 0
call EvolutionSetWholeScreenPalette
pop af
ld [wd0b5], a
@@ -94,8 +94,8 @@ EvolveMon: ; 7bde9 (1e:7de9)
jr .done
EvolutionSetWholeScreenPalette: ; 7beb4 (1e:7eb4)
- ld b, $b
- jp GoPAL_SET
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ jp RunPaletteCommand
Evolution_LoadPic: ; 7beb9 (1e:7eb9)
call GetMonHeader
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 16e893e5..2113e50a 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -105,7 +105,7 @@ Evolution_PartyMonLoop: ; loop over party mons
cp b ; is the mon's level greater than the evolution requirement?
jp c, .nextEvoEntry2 ; if so, go the next evolution entry
.doEvolution
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld a, 1
ld [wEvolutionOccurred], a
push hl
@@ -163,10 +163,10 @@ Evolution_PartyMonLoop: ; loop over party mons
ld hl, BaseStats
ld bc, MonBaseStatsEnd - MonBaseStats
call AddNTimes
- ld de, W_MONHEADER
+ ld de, wMonHeader
call CopyData
ld a, [wd0b5]
- ld [W_MONHDEXNUM], a
+ ld [wMonHIndex], a
pop af
ld [wd11e], a
ld hl, wLoadedMonHPExp - 1
@@ -210,7 +210,7 @@ Evolution_PartyMonLoop: ; loop over party mons
call LearnMoveFromLevelUp
pop hl
predef SetPartyMonTypes
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
call z, Evolution_ReloadTilesetTilePatterns
predef IndexToPokedex
@@ -249,7 +249,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [wLinkState]
cp LINK_STATE_TRADING
ret z
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
ret nz
ld a, [wEvolutionOccurred]
@@ -257,12 +257,12 @@ Evolution_PartyMonLoop: ; loop over party mons
call nz, PlayDefaultMusic
ret
-; checks if the evolved mon's name is different from the standard name (i.e. it has a nickname)
-; if so, rename it to is evolved form's standard name
RenameEvolvedMon: ; 3aef7 (e:6ef7)
+; Renames the mon to its new, evolved form's standard name unless it had a
+; nickname, in which case the nickname is kept.
ld a, [wd0b5]
push af
- ld a, [W_MONHDEXNUM]
+ ld a, [wMonHIndex]
ld [wd0b5], a
call GetName
pop af
@@ -275,10 +275,10 @@ RenameEvolvedMon: ; 3aef7 (e:6ef7)
cp [hl]
inc hl
ret nz
- cp $50
+ cp "@"
jr nz, .compareNamesLoop
ld a, [wWhichPokemon]
- ld bc, 11
+ ld bc, NAME_LENGTH
ld hl, wPartyMonNicks
call AddNTimes
push hl
@@ -340,7 +340,7 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b)
and a ; have we reached the end of the learn set?
jr z, .done ; if we've reached the end of the learn set, jump
ld b, a ; level the move is learnt at
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
cp b ; is the move learnt at the mon's current level?
ld a, [hli] ; move ID
jr nz, .learnSetLoop
@@ -375,7 +375,7 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b)
ld [wd11e], a
ret
-; writes the moves a mon has at level [W_CURENEMYLVL] to [de]
+; writes the moves a mon has at level [wCurEnemyLVL] to [de]
; move slots are being filled up sequentially and shifted if all slots are full
WriteMonMoves: ; 3afb8 (e:6fb8)
call GetPredefRegisters
@@ -407,7 +407,7 @@ WriteMonMoves: ; 3afb8 (e:6fb8)
and a
jp z, .done ; end of list
ld b, a
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
cp b
jp c, .done ; mon level < move level (assumption: learnset is sorted by level)
ld a, [wLearningMovesFromDayCare]
@@ -479,7 +479,7 @@ WriteMonMoves: ; 3afb8 (e:6fb8)
push hl
dec a
ld hl, Moves
- ld bc, 6
+ ld bc, MoveEnd - Moves
call AddNTimes
ld de, wBuffer
ld a, BANK(Moves)
diff --git a/engine/experience.asm b/engine/experience.asm
index b43fbcf9..e1037950 100755
--- a/engine/experience.asm
+++ b/engine/experience.asm
@@ -29,7 +29,7 @@ CalcLevelFromExperience: ; 58f43 (16:4f43)
; calculates the amount of experience needed for level d
CalcExperience: ; 58f6a (16:4f6a)
- ld a, [W_MONHGROWTHRATE]
+ ld a, [wMonHGrowthRate]
add a
add a
ld c, a
diff --git a/engine/game_corner_slots2.asm b/engine/game_corner_slots2.asm
index 643536ea..58386ba1 100755
--- a/engine/game_corner_slots2.asm
+++ b/engine/game_corner_slots2.asm
@@ -3,7 +3,7 @@ AbleToPlaySlotsCheck: ; 2ff09 (b:7f09)
and $8
jr z, .done ; not able
ld b, COIN_CASE
- predef IsItemInBag_ ; IsItemInBag_
+ predef GetQuantityOfItemInBag
ld a, b
and a
ld b, (GameCornerCoinCaseText_id - TextPredefs) / 2 + 1
diff --git a/engine/gamefreak.asm b/engine/gamefreak.asm
index 73e4f074..fa8faebc 100755
--- a/engine/gamefreak.asm
+++ b/engine/gamefreak.asm
@@ -13,15 +13,15 @@ LoadShootingStarGraphics: ; 70000 (1c:4000)
call CopyVideoData
ld de, FallingStar
ld hl, vChars1 + $220
- lb bc, BANK(FallingStar), $01
+ lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
call CopyVideoData
ld hl, GameFreakLogoOAMData
ld de, wOAMBuffer + $60
- ld bc, $40
+ ld bc, GameFreakLogoOAMDataEnd - GameFreakLogoOAMData
call CopyData
ld hl, GameFreakShootingStarOAMData
ld de, wOAMBuffer
- ld bc, $10
+ ld bc, GameFreakShootingStarOAMDataEnd - GameFreakShootingStarOAMData
jp CopyData
AnimateShootingStar: ; 70044 (1c:4044)
@@ -88,7 +88,7 @@ AnimateShootingStar: ; 70044 (1c:4044)
.initSmallStarsOAMLoop
push af
ld hl, SmallStarsOAM
- ld bc, 4
+ ld bc, SmallStarsOAMEnd - SmallStarsOAM
call CopyData
pop af
dec a
@@ -147,6 +147,7 @@ AnimateShootingStar: ; 70044 (1c:4044)
SmallStarsOAM: ; 700ee (1c:40ee)
db $00,$00,$A2,$90
+SmallStarsOAMEnd:
SmallStarsWaveCoordsPointerTable: ; 700f2 (1c:40f2)
dw SmallStarsWave1Coords
@@ -229,12 +230,15 @@ GameFreakLogoOAMData: ; 70140 (1c:4140)
db $60,$68,$83,$00
db $60,$70,$81,$00
db $60,$78,$86,$00
+GameFreakLogoOAMDataEnd:
GameFreakShootingStarOAMData: ; 70180 (1c:4180)
db $00,$A0,$A0,$10
db $00,$A8,$A0,$30
db $08,$A0,$A1,$10
db $08,$A8,$A1,$30
+GameFreakShootingStarOAMDataEnd:
FallingStar: ; 70190 (1c:4190)
INCBIN "gfx/falling_star.2bpp"
+FallingStarEnd:
diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm
index 02e2b743..33e7b426 100755
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -7,12 +7,12 @@ _GivePokemon: ; 4fda5 (13:7da5)
ld a, [wPartyCount]
cp PARTY_LENGTH
jr c, .addToParty
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
cp MONS_PER_BOX
jr nc, .boxFull
; add to box
xor a
- ld [W_ENEMYBATTSTATUS3], a
+ ld [wEnemyBattleStatus3], a
ld a, [wcf91]
ld [wEnemyMonSpecies2], a
callab LoadEnemyMonData
diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm
index ce1430e3..4225c5a1 100755
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -20,7 +20,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0)
xor a
ld [wUpdateSpritesEnabled], a
ld [hTilesetType], a
- ld [W_SPRITEFLIPPED], a
+ ld [wSpriteFlipped], a
ld [wLetterPrintingDelayFlags], a ; no delay
ld [wHoFMonOrPlayer], a ; mon
inc a
@@ -104,7 +104,7 @@ HoFShowMonOrPlayer: ; 70278 (1c:4278)
ld [wcf91], a
ld [wd0b5], a
ld [wBattleMonSpecies2], a
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, [wHoFMonOrPlayer]
and a
jr z, .showMon
@@ -117,9 +117,9 @@ HoFShowMonOrPlayer: ; 70278 (1c:4278)
call LoadFrontSpriteByMonIndex
predef LoadMonBackPic
.next1
- ld b, $b
- ld c, $0
- call GoPAL_SET
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
ld a, %11100100
ld [rBGP], a
ld c, $31 ; back pic
@@ -186,8 +186,8 @@ HoFLoadPlayerPics: ; 7033e (1c:433e)
ld de, RedPicFront
ld a, BANK(RedPicFront)
call UncompressSpriteFromDE
- ld hl, S_SPRITEBUFFER1
- ld de, S_SPRITEBUFFER0
+ ld hl, sSpriteBuffer1
+ ld de, sSpriteBuffer0
ld bc, $310
call CopyData
ld de, vFrontPic
@@ -224,12 +224,12 @@ HoFDisplayPlayerStats: ; 70377 (1c:4377)
ld de, HoFPlayTimeText
call PlaceString
coord hl, 5, 7
- ld de, W_PLAYTIMEHOURS + 1
+ ld de, wPlayTimeHours
lb bc, 1, 3
call PrintNumber
ld [hl], $6d
inc hl
- ld de, W_PLAYTIMEMINUTES + 1
+ ld de, wPlayTimeMinutes
lb bc, LEADING_ZEROES | 1, 2
call PrintNumber
coord hl, 1, 9
@@ -243,7 +243,7 @@ HoFDisplayPlayerStats: ; 70377 (1c:4377)
call HoFPrintTextAndDelay
ld hl, DexRatingText
call HoFPrintTextAndDelay
- ld hl, wcc5d
+ ld hl, wDexRatingText
HoFPrintTextAndDelay: ; 703e2 (1c:43e2)
call PrintText
@@ -276,13 +276,13 @@ HoFRecordMonInfo: ; 70404 (1c:4404)
ld e, l
ld d, h
ld hl, wcd6d
- ld bc, $b
+ ld bc, NAME_LENGTH
jp CopyData
HoFFadeOutScreenAndMusic: ; 70423 (1c:4423)
- ld a, $a
- ld [wcfc8], a
- ld [wcfc9], a
+ ld a, 10
+ ld [wAudioFadeOutCounterReloadValue], a
+ ld [wAudioFadeOutCounter], a
ld a, $ff
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
jp GBFadeOutToWhite
diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm
index e0ed973d..97187638 100755
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -2,7 +2,7 @@ PrintNotebookText: ; 52996 (14:6996)
call EnableAutoTextBoxDrawing
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
- ld a, [wTrainerSpriteOffset]
+ ld a, [wHiddenObjectFunctionArgument]
jp PrintPredefTextID
TMNotebook: ; 529a4 (14:69a4)
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index a2167b54..ffcc33c3 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -1,4 +1,4 @@
-PrintRedsNESText: ; 5db79 (17:5b79)
+PrintRedSNESText: ; 5db79 (17:5b79)
call EnableAutoTextBoxDrawing
tx_pre_jump RedBedroomSNESText
@@ -95,23 +95,23 @@ LinkCableHelp: ; 5dc29 (17:5c29)
ld hl, LinkCableHelpText1
call PrintText
xor a
- ld [W_ANIMATIONID], a
+ ld [wMenuItemOffset], a ; not used
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $3
+ ld a, 3
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
-.asm_5c51
+.linkHelpLoop
ld hl, wd730
set 6, [hl]
coord hl, 0, 0
- ld b, $8
- ld c, $d
+ ld b, 8
+ ld c, 13
call TextBoxBorder
coord hl, 2, 2
ld de, HowToLinkText
@@ -119,24 +119,24 @@ LinkCableHelp: ; 5dc29 (17:5c29)
ld hl, LinkCableHelpText2
call PrintText
call HandleMenuInput
- bit 1, a
- jr nz, .asm_5dc93
+ bit 1, a ; pressed b
+ jr nz, .exit
ld a, [wCurrentMenuItem]
- cp $3
- jr z, .asm_5dc93
+ cp 3 ; pressed a on "STOP READING"
+ jr z, .exit
ld hl, wd730
res 6, [hl]
ld hl, LinkCableInfoTexts
add a
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
- jp .asm_5c51
-.asm_5dc93
+ jp .linkHelpLoop
+.exit
ld hl, wd730
res 6, [hl]
call LoadScreenTilesFromBuffer1
@@ -179,18 +179,18 @@ ViridianSchoolBlackboard: ; 5dced (17:5ced)
ld hl, ViridianSchoolBlackboardText1
call PrintText
xor a
- ld [W_ANIMATIONID], a
+ ld [wMenuItemOffset], a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld a, $33
+ ld a, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $2
+ ld a, 2
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
-.asm_5dd15
+.blackboardLoop
ld hl, wd730
set 6, [hl]
coord hl, 0, 0
@@ -204,51 +204,55 @@ ViridianSchoolBlackboard: ; 5dced (17:5ced)
call PlaceString
ld hl, ViridianSchoolBlackboardText2
call PrintText
- call HandleMenuInput
- bit 1, a
+ call HandleMenuInput ; pressing up and down is handled in here
+ bit 1, a ; pressed b
jr nz, .exitBlackboard
- bit 4, a
- jr z, .asm_5dd5c
- ld a, $2
+ bit 4, a ; pressed right
+ jr z, .didNotPressRight
+ ; move cursor to right column
+ ld a, 2
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $6
+ ld a, 6
ld [wTopMenuItemX], a
- ld a, $3
- ld [W_ANIMATIONID], a
- jr .asm_5dd15
-.asm_5dd5c
- bit 5, a
- jr z, .asm_5dd75
- ld a, $2
+ ld a, 3 ; in the the right column, use an offset to prevent overlap
+ ld [wMenuItemOffset], a
+ jr .blackboardLoop
+.didNotPressRight
+ bit 5, a ; pressed left
+ jr z, .didNotPressLeftOrRight
+ ; move cursor to left column
+ ld a, 2
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
xor a
- ld [W_ANIMATIONID], a
- jr .asm_5dd15
-.asm_5dd75
+ ld [wMenuItemOffset], a
+ jr .blackboardLoop
+.didNotPressLeftOrRight
ld a, [wCurrentMenuItem]
ld b, a
- ld a, [W_ANIMATIONID]
+ ld a, [wMenuItemOffset]
add b
- cp $5
+ cp 5 ; cursor is pointing to "QUIT"
jr z, .exitBlackboard
+ ; we must have pressed a on a status condition
+ ; so print the text
ld hl, wd730
res 6, [hl]
ld hl, ViridianBlackboardStatusPointers
add a
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
- jp .asm_5dd15
+ jp .blackboardLoop
.exitBlackboard
ld hl, wd730
res 6, [hl]
@@ -276,7 +280,7 @@ StatusAilmentText2: ; 5ddbb (17:5dbb)
ViridianBlackboardStatusPointers: ; 5ddcc (17:5ddc)
dw ViridianBlackboardSleepText
dw ViridianBlackboardPoisonText
- dw ViridianBlackbaordPrlzText
+ dw ViridianBlackboardPrlzText
dw ViridianBlackboardBurnText
dw ViridianBlackboardFrozenText
@@ -288,8 +292,8 @@ ViridianBlackboardPoisonText: ; 5dddb (17:5ddb)
TX_FAR _ViridianBlackboardPoisonText
db "@"
-ViridianBlackbaordPrlzText: ; 5dde0 (17:5de0)
- TX_FAR _ViridianBlackbaordPrlzText
+ViridianBlackboardPrlzText: ; 5dde0 (17:5de0)
+ TX_FAR _ViridianBlackboardPrlzText
db "@"
ViridianBlackboardBurnText: ; 5dde5 (17:5de5)
@@ -375,7 +379,7 @@ GymTrashScript: ; 5ddfc (17:5dfc)
and $f
ld [wSecondLockTrashCanIndex], a
- tx_pre_id VermilionGymTrashSuccesText1
+ tx_pre_id VermilionGymTrashSuccessText1
jr .done
.trySecondLock
@@ -398,10 +402,10 @@ GymTrashScript: ; 5ddfc (17:5dfc)
.openSecondLock
; Completed the trash can puzzle.
SetEvent EVENT_2ND_LOCK_OPENED
- ld hl, wd126
+ ld hl, wCurrentMapScriptFlags
set 6, [hl]
- tx_pre_id VermilionGymTrashSuccesText3
+ tx_pre_id VermilionGymTrashSuccessText3
.done
jp PrintPredefTextID
@@ -430,8 +434,8 @@ GymTrashCans: ; 5de7d (17:5e7d)
db 2, 11, 13, 0, 0 ; 14
; 5dec8
-VermilionGymTrashSuccesText1: ; 5dec8 (17:5ec8)
- TX_FAR _VermilionGymTrashSuccesText1
+VermilionGymTrashSuccessText1: ; 5dec8 (17:5ec8)
+ TX_FAR _VermilionGymTrashSuccessText1
TX_ASM
call WaitForSoundToFinish
ld a, SFX_SWITCH
@@ -440,8 +444,8 @@ VermilionGymTrashSuccesText1: ; 5dec8 (17:5ec8)
jp TextScriptEnd
; unused
-VermilionGymTrashSuccesText2: ; 5dedb (17:5edb)
- TX_FAR _VermilionGymTrashSuccesText2
+VermilionGymTrashSuccessText2: ; 5dedb (17:5edb)
+ TX_FAR _VermilionGymTrashSuccessText2
db "@"
; unused
@@ -453,8 +457,8 @@ VermilionGymTrashSuccesPlaySfx: ; 5dee0 (17:5ee0)
call WaitForSoundToFinish
jp TextScriptEnd
-VermilionGymTrashSuccesText3: ; 5deef (17:5eef)
- TX_FAR _VermilionGymTrashSuccesText3
+VermilionGymTrashSuccessText3: ; 5deef (17:5eef)
+ TX_FAR _VermilionGymTrashSuccessText3
TX_ASM
call WaitForSoundToFinish
ld a, SFX_GO_INSIDE
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 0a93fd44..ab66a818 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -7,7 +7,7 @@ GymStatues: ; 62419 (18:6419)
cp SPRITE_FACING_UP
ret nz
ld hl, .BadgeFlags
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, a
.loop
ld a, [hli]
@@ -50,7 +50,7 @@ GymStatueText2: ; 62458 (18:6458)
PrintBenchGuyText: ; 6245d (18:645d)
call EnableAutoTextBoxDrawing
ld hl, BenchGuyTextPointers
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, a
.loop
ld a, [hli]
diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm
index 80251b94..d6e25cec 100755
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -4,7 +4,7 @@ PrintBookshelfText: ; fb50 (3:7b50)
cp SPRITE_FACING_UP
jr nz, .noMatch
; facing up
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
ld b, a
aCoord 8, 7
ld c, a
@@ -78,7 +78,7 @@ IndigoPlateauStatues: ; fbbf (3:7bbf)
TX_ASM
ld hl, IndigoPlateauStatuesText1
call PrintText
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
bit 0, a
ld hl, IndigoPlateauStatuesText2
jr nz, .asm_fbd3
@@ -102,7 +102,7 @@ IndigoPlateauStatuesText3: ; fbe3 (3:7be3)
BookOrSculptureText: ; fbe8 (3:7be8)
TX_ASM
ld hl, PokemonBooksText
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
cp MANSION ; Celadon Mansion tileset
jr nz, .asm_fbfd
aCoord 8, 6
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index e3c296ca..87305472 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -19,8 +19,8 @@ DisplayOakLabRightPoster: ; 1e965 (7:6965)
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- cp $2
+ ld a, [wNumSetBits]
+ cp 2
tx_pre_id SaveOptionText
jr c, .ownThreeOrMoreMon
tx_pre_id StrengthsAndWeaknessesText
@@ -38,7 +38,7 @@ StrengthsAndWeaknessesText: ; 1e983 (7:6983)
SafariZoneCheck: ; 1e988 (7:6988)
CheckEventHL EVENT_IN_SAFARI_ZONE ; if we are not in the Safari Zone,
jr z, SafariZoneGameStillGoing ; don't bother printing game over text
- ld a, [W_NUMSAFARIBALLS]
+ ld a, [wNumSafariBalls]
and a
jr z, SafariZoneGameOver
jr SafariZoneGameStillGoing
@@ -63,14 +63,14 @@ SafariZoneGameStillGoing: ; 1e9ab (7:69ab)
SafariZoneGameOver: ; 1e9b0 (7:69b0)
call EnableAutoTextBoxDrawing
xor a
- ld [wMusicHeaderPointer], a
+ ld [wAudioFadeOutControl], a
dec a
call PlaySound
ld c, BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.asm_1e9c2
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp $b9
jr nz, .asm_1e9c2
ld a, TEXT_SAFARI_GAME_OVER
@@ -83,7 +83,7 @@ SafariZoneGameOver: ; 1e9b0 (7:69b0)
ld a, $3
ld [wDestinationWarpID], a
ld a, $5
- ld [W_SAFARIZONEENTRANCECURSCRIPT], a
+ ld [wSafariZoneEntranceCurScript], a
SetEvent EVENT_SAFARI_GAME_OVER
ld a, 1
ld [wSafariZoneGameOver], a
@@ -97,7 +97,7 @@ PrintSafariGameOverText: ; 1e9ed (7:69ed)
SafariGameOverText: ; 1e9f7 (7:69f7)
TX_ASM
- ld a, [W_NUMSAFARIBALLS]
+ ld a, [wNumSafariBalls]
and a
jr z, .asm_1ea04
ld hl, TimesUpText
@@ -147,7 +147,7 @@ CinnabarGymQuiz: ; 1ea25 (7:6a25)
ld h, [hl]
ld l, a
call PrintText
- ld a, $1
+ ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call CinnabarGymQuiz_1ea92
jp TextScriptEnd
@@ -199,7 +199,7 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92)
ld a, [wCurrentMenuItem]
cp c
jr nz, .wrongAnswer
- ld hl, wd126
+ ld hl, wCurrentMapScriptFlags
set 5, [hl]
ld a, [hGymGateIndex]
ld [$ffe0], a
@@ -374,7 +374,7 @@ BillsHouseInitiatedText: ; 1ebe2 (7:6be2)
db $06
TX_ASM
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld c, 16
call DelayFrames
@@ -391,23 +391,23 @@ BillsHousePokemonList: ; 1ec05 (7:6c05)
ld hl, BillsHousePokemonListText1
call PrintText
xor a
- ld [W_ANIMATIONID], a
+ ld [wMenuItemOffset], a ; not used
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
- ld a, $3
+ ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, $4
+ ld a, 4
ld [wMaxMenuItem], a
- ld a, $2
+ ld a, 2
ld [wTopMenuItemY], a
- ld a, $1
+ ld a, 1
ld [wTopMenuItemX], a
-.asm_1ec2d
+.billsPokemonLoop
ld hl, wd730
set 6, [hl]
coord hl, 0, 0
- ld b, $a
- ld c, $9
+ ld b, 10
+ ld c, 9
call TextBoxBorder
coord hl, 2, 2
ld de, BillsMonListText
@@ -416,24 +416,24 @@ BillsHousePokemonList: ; 1ec05 (7:6c05)
call PrintText
call SaveScreenTilesToBuffer2
call HandleMenuInput
- bit 1, a
- jr nz, .asm_1ec74
+ bit 1, a ; pressed b
+ jr nz, .cancel
ld a, [wCurrentMenuItem]
add EEVEE
cp EEVEE
- jr z, .asm_1ec6c
+ jr z, .displayPokedex
cp FLAREON
- jr z, .asm_1ec6c
+ jr z, .displayPokedex
cp JOLTEON
- jr z, .asm_1ec6c
+ jr z, .displayPokedex
cp VAPOREON
- jr z, .asm_1ec6c
- jr .asm_1ec74
-.asm_1ec6c
+ jr z, .displayPokedex
+ jr .cancel
+.displayPokedex
call DisplayPokedex
call LoadScreenTilesFromBuffer2
- jr .asm_1ec2d
-.asm_1ec74
+ jr .billsPokemonLoop
+.cancel
ld hl, wd730
res 6, [hl]
call LoadScreenTilesFromBuffer2
diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm
index b4a73e59..176d6af7 100755
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -17,7 +17,7 @@ DoInGameTradeDialogue: ; 71ad9 (1c:5ad9)
ld a,[hli]
push af
ld de,wInGameTradeMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop af
ld l,a
@@ -81,7 +81,7 @@ InGameTrade_GetMonName: ; 71b6a (1c:5b6a)
call GetMonName
ld hl,wcd6d
pop de
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
INCLUDE "data/trades.asm"
@@ -108,7 +108,7 @@ InGameTrade_DoTrade: ; 71c07 (1c:5c07)
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld a,[hl]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
ld hl,wCompletedInGameTradeFlags
ld a,[wWhichTrade]
ld c,a
@@ -118,13 +118,13 @@ InGameTrade_DoTrade: ; 71c07 (1c:5c07)
call PrintText
ld a,[wWhichPokemon]
push af
- ld a,[W_CURENEMYLVL]
+ ld a,[wCurEnemyLVL]
push af
call LoadHpBarAndStatusTilePatterns
call InGameTrade_PrepareTradeData
predef InternalClockTradeAnim
pop af
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
pop af
ld [wWhichPokemon],a
ld a,[wInGameTradeReceiveMonSpecies]
@@ -168,11 +168,11 @@ InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1)
ld a, [wInGameTradeReceiveMonSpecies]
ld [hl], a ; wTradedEnemyMonSpecies
ld hl, wPartyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld de, wTradedPlayerMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_CopyData
ld hl, InGameTrade_TrainerString
ld de, wTradedEnemyMonOT
@@ -201,16 +201,16 @@ InGameTrade_CopyData: ; 71d11 (1c:5d11)
InGameTrade_CopyDataToReceivedMon: ; 71d19 (1c:5d19)
ld hl, wPartyMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_GetReceivedMonPointer
ld hl, wInGameTradeMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_GetReceivedMonPointer
ld hl, InGameTrade_TrainerString
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMon1OTID
ld bc, wPartyMon2 - wPartyMon1
diff --git a/engine/intro.asm b/engine/intro.asm
index 9f17e05c..7ddbe240 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -1,3 +1,7 @@
+MOVE_GENGAR_RIGHT EQU $00
+MOVE_GENGAR_LEFT EQU $01
+MOVE_NIDORINO_RIGHT EQU $ff
+
PlayIntro: ; 41682 (10:5682)
xor a
ld [hJoyHeld], a
@@ -14,8 +18,8 @@ PlayIntro: ; 41682 (10:5682)
ret
PlayIntroScene: ; 4169d (10:569d)
- ld b, $7
- call GoPAL_SET
+ ld b, SET_PAL_NIDORINO_INTRO
+ call RunPaletteCommand
ld a, %11100100
ld [rBGP], a
ld [rOBP0], a
@@ -25,12 +29,12 @@ PlayIntroScene: ; 4169d (10:569d)
ld b, $3 ; Gengar tiles
call IntroCopyTiles
ld a, 0
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld a, 80
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
lb bc, 6, 6
call InitIntroNidorinoOAM
- ld de, $28ff ; move Nidorino right by 80 pixels
+ lb de, 80 / 2, MOVE_NIDORINO_RIGHT
call IntroMoveMon
ret c
@@ -69,7 +73,7 @@ PlayIntroScene: ; 4169d (10:569d)
call IntroCopyTiles
ld a, SFX_INTRO_RAISE
call PlaySound
- ld de, $401 ; move Gengar left by 8 pixels
+ lb de, 8 / 2, MOVE_GENGAR_LEFT
call IntroMoveMon
ld c, $1e
call CheckForUserInterruption
@@ -80,7 +84,7 @@ PlayIntroScene: ; 4169d (10:569d)
call IntroCopyTiles
ld a, SFX_INTRO_CRASH
call PlaySound
- ld de, $800 ; move Gengar right by 16 pixels
+ lb de, 16 / 2, MOVE_GENGAR_RIGHT
call IntroMoveMon
; hip
ld a, SFX_INTRO_HIP
@@ -93,7 +97,7 @@ PlayIntroScene: ; 4169d (10:569d)
call CheckForUserInterruption
ret c
- ld de, $401 ; move Gengar left by 8 pixels
+ lb de, 8 / 2, MOVE_GENGAR_LEFT
call IntroMoveMon
ld b, $3
call IntroCopyTiles
@@ -137,10 +141,10 @@ AnimateIntroNidorino: ; 41793 (10:5793)
ld a, [de]
cp $50
ret z
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
inc de
ld a, [de]
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
push de
ld c, 6 * 6
call UpdateIntroNidorinoOAM
@@ -155,10 +159,10 @@ UpdateIntroNidorinoOAM: ; 417ae (10:57ae)
ld a, [wIntroNidorinoBaseTile]
ld d, a
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
add [hl]
ld [hli], a ; Y
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add [hl]
ld [hli], a ; X
ld a, d
@@ -174,14 +178,14 @@ InitIntroNidorinoOAM: ; 417c7 (10:57c7)
ld d, 0
.loop
push bc
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld e, a
.innerLoop
ld a, e
add 8
ld e, a
ld [hli], a ; Y
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld [hli], a ; X
ld a, d
ld [hli], a ; tile
@@ -190,9 +194,9 @@ InitIntroNidorinoOAM: ; 417c7 (10:57c7)
inc d
dec c
jr nz, .innerLoop
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add 8
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
pop bc
dec b
jr nz, .loop
@@ -241,9 +245,9 @@ IntroMoveMon: ; 4180e (10:580e)
.moveNidorinoRight
push de
ld a, 2
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
xor a
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld c, 6 * 6
call UpdateIntroNidorinoOAM
pop de
@@ -278,28 +282,28 @@ PlayMoveSoundB: ; 41849 (10:5849)
LoadIntroGraphics: ; 41852 (10:5852)
ld hl, FightIntroBackMon
ld de, vChars2
- ld bc, $600
+ ld bc, FightIntroBackMonEnd - FightIntroBackMon
ld a, BANK(FightIntroBackMon)
call FarCopyData2
ld hl, GameFreakIntro
ld de, vChars2 + $600
- ld bc, $140
+ ld bc, GameFreakIntroEnd - GameFreakIntro
ld a, BANK(GameFreakIntro)
call FarCopyData2
ld hl, GameFreakIntro
ld de, vChars1
- ld bc, $140
+ ld bc, GameFreakIntroEnd - GameFreakIntro
ld a, BANK(GameFreakIntro)
call FarCopyData2
ld hl, FightIntroFrontMon
ld de, vChars0
- ld bc, $6c0
+ ld bc, FightIntroFrontMonEnd - FightIntroFrontMon
ld a, BANK(FightIntroFrontMon)
jp FarCopyData2
PlayShootingStar: ; 4188a (10:588a)
- ld b, $c
- call GoPAL_SET
+ ld b, SET_PAL_GAME_FREAK_INTRO
+ call RunPaletteCommand
callba LoadCopyrightAndTextBoxTiles
ld a, $e4
ld [rBGP], a
@@ -308,7 +312,7 @@ PlayShootingStar: ; 4188a (10:588a)
call ClearScreen
call DisableLCD
xor a
- ld [W_CUROPPONENT], a
+ ld [wCurOpponent], a
call IntroDrawBlackBars
call LoadIntroGraphics
call EnableLCD
@@ -325,10 +329,10 @@ PlayShootingStar: ; 4188a (10:588a)
call DelayFrames
.next
ld a, BANK(Music_IntroBattle)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_INTRO_BATTLE
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
call IntroClearMiddleOfScreen
call ClearSprites
@@ -430,9 +434,11 @@ GameFreakIntro: ; 41959 (10:5959)
INCBIN "gfx/gamefreak_intro.2bpp"
INCBIN "gfx/gamefreak_logo.2bpp"
ds $10 ; blank tile
+GameFreakIntroEnd:
FightIntroBackMon: ; 41a99 (10:5a99)
INCBIN "gfx/intro_fight.2bpp"
+FightIntroBackMonEnd:
FightIntroFrontMon: ; 42099 (10:6099)
@@ -440,11 +446,13 @@ IF DEF(_RED)
INCBIN "gfx/red/intro_nido_1.2bpp"
INCBIN "gfx/red/intro_nido_2.2bpp"
INCBIN "gfx/red/intro_nido_3.2bpp"
- ds $10 ; blank tile
ENDC
IF DEF(_BLUE)
INCBIN "gfx/blue/intro_purin_1.2bpp"
INCBIN "gfx/blue/intro_purin_2.2bpp"
INCBIN "gfx/blue/intro_purin_3.2bpp"
- ds $10 ; blank tile
ENDC
+
+FightIntroFrontMonEnd:
+
+ ds $10 ; blank tile
diff --git a/engine/items/itemfinder.asm b/engine/items/itemfinder.asm
index 5da72388..d638b0b8 100755
--- a/engine/items/itemfinder.asm
+++ b/engine/items/itemfinder.asm
@@ -3,7 +3,7 @@ HiddenItemNear: ; 7481f (1d:481f)
ld b, 0
.loop
ld de, 3
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
call IsInRestOfArray
ret nc ; return if current map has no hidden items
push bc
@@ -24,19 +24,19 @@ HiddenItemNear: ; 7481f (1d:481f)
inc hl
jr nz, .loop ; if the item has already been obtained
; check if the item is within 4-5 tiles (depending on the direction of item)
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
call Sub5ClampTo0
cp d
jr nc, .loop
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
add 4
cp d
jr c, .loop
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
call Sub5ClampTo0
cp e
jr nc, .loop
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
add 5
cp e
jr c, .loop
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 364570da..55dcb53e 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -70,7 +70,7 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw ItemUseMedicine ; FULL_HEAL
dw ItemUseMedicine ; REVIVE
dw ItemUseMedicine ; MAX_REVIVE
- dw ItemUseGuardSpec ; GUARD_SPEC_
+ dw ItemUseGuardSpec ; GUARD_SPEC
dw ItemUseSuperRepel ; SUPER_REPL
dw ItemUseMaxRepel ; MAX_REPEL
dw ItemUseDireHit ; DIRE_HIT
@@ -78,7 +78,7 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw ItemUseMedicine ; FRESH_WATER
dw ItemUseMedicine ; SODA_POP
dw ItemUseMedicine ; LEMONADE
- dw UnusableItem ; S_S__TICKET
+ dw UnusableItem ; S_S_TICKET
dw UnusableItem ; GOLD_TEETH
dw ItemUseXStat ; X_ATTACK
dw ItemUseXStat ; X_DEFEND
@@ -90,7 +90,7 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw UnusableItem ; SILPH_SCOPE
dw ItemUsePokeflute ; POKE_FLUTE
dw UnusableItem ; LIFT_KEY
- dw UnusableItem ; EXP__ALL
+ dw UnusableItem ; EXP_ALL
dw ItemUseOldRod ; OLD_ROD
dw ItemUseGoodRod ; GOOD_ROD
dw ItemUseSuperRod ; SUPER_ROD
@@ -101,97 +101,143 @@ ItemUsePtrTable: ; d5e1 (3:55e1)
dw ItemUsePPRestore ; MAX_ELIXER
ItemUseBall: ; d687 (3:5687)
- ld a,[W_ISINBATTLE]
+
+; Balls can't be used out of battle.
+ ld a,[wIsInBattle]
and a
- jp z,ItemUseNotTime ; not in battle
+ jp z,ItemUseNotTime
+
+; Balls can't catch trainers' Pokémon.
dec a
jp nz,ThrowBallAtTrainerMon
- ld a,[W_BATTLETYPE]
+
+; If this is for the old man battle, skip checking if the party & box are full.
+ ld a,[wBattleType]
dec a
- jr z,.UseBall
- ld a,[wPartyCount] ;is Party full?
+ jr z,.canUseBall
+
+ ld a,[wPartyCount] ; is party full?
cp a,PARTY_LENGTH
- jr nz,.UseBall
- ld a,[W_NUMINBOX] ;is Box full?
+ jr nz,.canUseBall
+ ld a,[wNumInBox] ; is box full?
cp a,MONS_PER_BOX
jp z,BoxFullCannotThrowBall
-.UseBall
-;ok, you can use a ball
+
+.canUseBall
xor a
ld [wCapturedMonSpecies],a
- ld a,[W_BATTLETYPE]
- cp a,2 ;SafariBattle
+
+ ld a,[wBattleType]
+ cp a,BATTLE_TYPE_SAFARI
jr nz,.skipSafariZoneCode
+
.safariZone
- ; remove a Safari Ball from inventory
- ld hl,W_NUMSAFARIBALLS
- dec [hl]
+ ld hl,wNumSafariBalls
+ dec [hl] ; remove a Safari Ball
+
.skipSafariZoneCode
- call GoPAL_SET_CF1C
- ld a,$43
- ld [wd11e],a
- call LoadScreenTilesFromBuffer1 ;restore screenBuffer from Backup
+ call RunDefaultPaletteCommand
+
+ ld a,$43 ; successful capture value
+ ld [wPokeBallAnimData],a
+
+ call LoadScreenTilesFromBuffer1
ld hl,ItemUseText00
call PrintText
+
+; If the player is fighting an unidentified ghost, set the value that indicates
+; the Pokémon can't be caught and skip the capture calculations.
callab IsGhostBattle
- ld b,$10
- jp z,.next12
- ld a,[W_BATTLETYPE]
+ ld b,$10 ; can't be caught value
+ jp z,.setAnimData
+
+ ld a,[wBattleType]
dec a
jr nz,.notOldManBattle
+
.oldManBattle
- ld hl,W_GRASSRATE
+ ld hl,wGrassRate
ld de,wPlayerName
- ld bc,11
- call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno glitch)
- jp .BallSuccess
+ ld bc,NAME_LENGTH
+ call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno. glitch)
+ jp .captured
+
.notOldManBattle
- ld a,[W_CURMAP]
+; If the player is fighting the ghost Marowak, set the value that indicates the
+; Pokémon can't be caught and skip the capture calculations.
+ ld a,[wCurMap]
cp a,POKEMONTOWER_6
jr nz,.loop
ld a,[wEnemyMonSpecies2]
cp a,MAROWAK
- ld b,$10
- jp z,.next12
-; if not fighting ghost Marowak, loop until a random number in the current
-; pokeball's allowed range is found
+ ld b,$10 ; can't be caught value
+ jp z,.setAnimData
+
+; Get the first random number. Let it be called Rand1.
+; Rand1 must be within a certain range according the kind of ball being thrown.
+; The ranges are as follows.
+; Poké Ball: [0, 255]
+; Great Ball: [0, 200]
+; Ultra/Safari Ball: [0, 150]
+; Loop until an acceptable number is found.
+
.loop
call Random
ld b,a
+
+; Get the item ID.
ld hl,wcf91
ld a,[hl]
+
+; The Master Ball always succeeds.
cp a,MASTER_BALL
- jp z,.BallSuccess
+ jp z,.captured
+
+; Anything will do for the basic Poké Ball.
cp a,POKE_BALL
jr z,.checkForAilments
+
+; If it's a Great/Ultra/Safari Ball and Rand1 is greater than 200, try again.
ld a,200
cp b
- jr c,.loop ;get only numbers <= 200 for Great Ball
+ jr c,.loop
+
+; Less than or equal to 200 is good enough for a Great Ball.
ld a,[hl]
cp a,GREAT_BALL
jr z,.checkForAilments
- ld a,150 ;get only numbers <= 150 for Ultra Ball
+
+; If it's an Ultra/Safari Ball and Rand1 is greater than 150, try again.
+ ld a,150
cp b
jr c,.loop
+
.checkForAilments
-; pokemon can be caught more easily with any (primary) status ailment
-; Frozen/Asleep pokemon are relatively even easier to catch
-; for Frozen/Asleep pokemon, any random number from 0-24 ensures a catch.
-; for the others, a random number from 0-11 ensures a catch.
- ld a,[wEnemyMonStatus] ;status ailments
+; Pokémon can be caught more easily with a status ailment.
+; Depending on the status ailment, a certain value will be subtracted from
+; Rand1. Let this value be called Status.
+; The larger Status is, the more easily the Pokémon can be caught.
+; no status ailment: Status = 0
+; Burn/Paralysis/Poison: Status = 12
+; Freeze/Sleep: Status = 25
+; If Status is greater than Rand1, the Pokémon will be caught for sure.
+ ld a,[wEnemyMonStatus]
and a
- jr z,.noAilments
- and a, 1 << FRZ | SLP ;is frozen and/or asleep?
+ jr z,.skipAilmentValueSubtraction ; no ailments
+ and a, 1 << FRZ | SLP
ld c,12
jr z,.notFrozenOrAsleep
ld c,25
.notFrozenOrAsleep
ld a,b
sub c
- jp c,.BallSuccess
+ jp c,.captured
ld b,a
-.noAilments
- push bc ;save RANDOM number
+
+.skipAilmentValueSubtraction
+ push bc ; save (Rand1 - Status)
+
+; Calculate MaxHP * 255.
xor a
ld [H_MULTIPLICAND],a
ld hl,wEnemyMonMaxHP
@@ -201,123 +247,180 @@ ItemUseBall: ; d687 (3:5687)
ld [H_MULTIPLICAND + 2],a
ld a,255
ld [H_MULTIPLIER],a
- call Multiply ; MaxHP * 255
+ call Multiply
+
+; Determine BallFactor. It's 8 for Great Balls and 12 for the others.
ld a,[wcf91]
cp a,GREAT_BALL
- ld a,12 ;any other BallFactor
- jr nz,.next7
+ ld a,12
+ jr nz,.skip1
ld a,8
-.next7
+
+.skip1
+; Note that the results of all division operations are floored.
+
+; Calculate (MaxHP * 255) / BallFactor.
ld [H_DIVISOR],a
- ld b,4 ; number of bytes in dividend
+ ld b,4 ; number of bytes in dividend
call Divide
+
+; Divide the enemy's current HP by 4. HP is not supposed to exceed 999 so
+; the result should fit in a. If the division results in a quotient of 0,
+; change it to 1.
ld hl,wEnemyMonHP
ld a,[hli]
ld b,a
ld a,[hl]
-
-; explanation: we have a 16-bit value equal to [b << 8 | a].
-; This number is divided by 4. The result is 8 bit (reg. a).
-; Always bigger than zero.
srl b
rr a
srl b
- rr a ; a = current HP / 4
+ rr a
and a
- jr nz,.next8
+ jr nz,.skip2
inc a
-.next8
+
+.skip2
+; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W.
ld [H_DIVISOR],a
ld b,4
- call Divide ; ((MaxHP * 255) / BallFactor) / (CurHP / 4)
+ call Divide
+
+; If W > 255, store 255 in [H_QUOTIENT + 3].
+; Let X = min(W, 255) = [H_QUOTIENT + 3].
ld a,[H_QUOTIENT + 2]
and a
- jr z,.next9
+ jr z,.skip3
ld a,255
ld [H_QUOTIENT + 3],a
-.next9
- pop bc
- ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate
+
+.skip3
+ pop bc ; b = Rand1 - Status
+
+; If Rand1 - Status > CatchRate, the ball fails to capture the Pokémon.
+ ld a,[wEnemyMonCatchRate]
cp b
- jr c,.next10
+ jr c,.failedToCapture
+
+; If W > 255, the ball captures the Pokémon.
ld a,[H_QUOTIENT + 2]
and a
- jr nz,.BallSuccess ; if ((MaxHP * 255) / BallFactor) / (CurHP / 4) > 0x255, automatic success
- call Random
+ jr nz,.captured
+
+ call Random ; Let this random number be called Rand2.
+
+; If Rand2 > X, the ball fails to capture the Pokémon.
ld b,a
ld a,[H_QUOTIENT + 3]
cp b
- jr c,.next10
-.BallSuccess
- jr .BallSuccess2
-.next10
+ jr c,.failedToCapture
+
+.captured
+ jr .skipShakeCalculations
+
+.failedToCapture
ld a,[H_QUOTIENT + 3]
- ld [wd11e],a
+ ld [wPokeBallCaptureCalcTemp],a ; Save X.
+
+; Calculate CatchRate * 100.
xor a
ld [H_MULTIPLICAND],a
ld [H_MULTIPLICAND + 1],a
- ld a,[wEnemyMonCatchRate] ;enemy: Catch Rate
+ ld a,[wEnemyMonCatchRate]
ld [H_MULTIPLICAND + 2],a
ld a,100
ld [H_MULTIPLIER],a
- call Multiply ; CatchRate * 100
+ call Multiply
+
+; Determine BallFactor2.
+; Poké Ball: BallFactor2 = 255
+; Great Ball: BallFactor2 = 200
+; Ultra/Safari Ball: BallFactor2 = 150
ld a,[wcf91]
ld b,255
cp a,POKE_BALL
- jr z,.next11
+ jr z,.skip4
ld b,200
cp a,GREAT_BALL
- jr z,.next11
+ jr z,.skip4
ld b,150
cp a,ULTRA_BALL
- jr z,.next11
-.next11
+ jr z,.skip4
+
+.skip4
+; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y.
ld a,b
ld [H_DIVISOR],a
ld b,4
call Divide
+
+; If Y > 255, there are 3 shakes.
+; Note that this shouldn't be possible.
+; The maximum value of Y is (255 * 100) / 150 = 170.
ld a,[H_QUOTIENT + 2]
and a
- ld b,$63
- jr nz,.next12
- ld a,[wd11e]
+ ld b,$63 ; 3 shakes
+ jr nz,.setAnimData
+
+; Calculate X * Y.
+ ld a,[wPokeBallCaptureCalcTemp]
ld [H_MULTIPLIER],a
call Multiply
+
+; Calculate (X * Y) / 255.
ld a,255
ld [H_DIVISOR],a
ld b,4
call Divide
- ld a,[wEnemyMonStatus] ;status ailments
+
+; Determine Status2.
+; no status ailment: Status2 = 0
+; Burn/Paralysis/Poison: Status2 = 5
+; Freeze/Sleep: Status2 = 10
+ ld a,[wEnemyMonStatus]
and a
- jr z,.next13
+ jr z,.skip5
and a, 1 << FRZ | SLP
ld b,5
- jr z,.next14
+ jr z,.addAilmentValue
ld b,10
-.next14
+
+.addAilmentValue
+; If the Pokémon has a status ailment, add Status2.
ld a,[H_QUOTIENT + 3]
add b
ld [H_QUOTIENT + 3],a
-.next13
+
+.skip5
+; Finally determine the number of shakes.
+; Let Z = ((X * Y) / 255) + Status2 = [H_QUOTIENT + 3].
+; The number of shakes depend on the range Z is in.
+; 0 ≤ Z < 10: 0 shakes (the ball misses)
+; 10 ≤ Z < 30: 1 shake
+; 30 ≤ Z < 70: 2 shakes
+; 70 ≤ Z: 3 shakes
ld a,[H_QUOTIENT + 3]
cp a,10
ld b,$20
- jr c,.next12
+ jr c,.setAnimData
cp a,30
ld b,$61
- jr c,.next12
+ jr c,.setAnimData
cp a,70
ld b,$62
- jr c,.next12
+ jr c,.setAnimData
ld b,$63
-.next12
+
+.setAnimData
ld a,b
- ld [wd11e],a
-.BallSuccess2
+ ld [wPokeBallAnimData],a
+
+.skipShakeCalculations
ld c,20
call DelayFrames
+
+; Do the animation.
ld a,TOSS_ANIM
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
xor a
ld [H_WHOSETURN],a
ld [wAnimationType],a
@@ -331,51 +434,67 @@ ItemUseBall: ; d687 (3:5687)
ld [wcf91],a
pop af
ld [wWhichPokemon],a
- ld a,[wd11e]
+
+; Determine the message to display from the animation.
+ ld a,[wPokeBallAnimData]
cp a,$10
ld hl,ItemUseBallText00
- jp z,.printText0
+ jp z,.printMessage
cp a,$20
ld hl,ItemUseBallText01
- jp z,.printText0
+ jp z,.printMessage
cp a,$61
ld hl,ItemUseBallText02
- jp z,.printText0
+ jp z,.printMessage
cp a,$62
ld hl,ItemUseBallText03
- jp z,.printText0
+ jp z,.printMessage
cp a,$63
ld hl,ItemUseBallText04
- jp z,.printText0
- ld hl,wEnemyMonHP ;current HP
+ jp z,.printMessage
+
+; Save current HP.
+ ld hl,wEnemyMonHP
ld a,[hli]
push af
ld a,[hli]
- push af ;backup currentHP...
+ push af
+
+; Save status ailment.
inc hl
ld a,[hl]
- push af ;...and status ailments
+ push af
+
push hl
- ld hl,W_ENEMYBATTSTATUS3
+
+; If the Pokémon is transformed, the Pokémon is assumed to be a Ditto.
+; This is a bug because a wild Pokémon could have used Transform via
+; Mirror Move even though the only wild Pokémon that knows Transform is Ditto.
+ ld hl,wEnemyBattleStatus3
bit Transformed,[hl]
- jr z,.next15
- ld a,$4c
+ jr z,.notTransformed
+ ld a,DITTO
ld [wEnemyMonSpecies2],a
- jr .next16
-.next15
+ jr .skip6
+
+.notTransformed
+; If the Pokémon is not transformed, set the transformed bit and copy the
+; DVs to wTransformedEnemyMonOriginalDVs so that LoadEnemyMonData won't generate
+; new DVs.
set Transformed,[hl]
- ld hl,wcceb
+ ld hl,wTransformedEnemyMonOriginalDVs
ld a,[wEnemyMonDVs]
ld [hli],a
ld a,[wEnemyMonDVs + 1]
ld [hl],a
-.next16
+
+.skip6
ld a,[wcf91]
push af
ld a,[wEnemyMonSpecies2]
ld [wcf91],a
ld a,[wEnemyMonLevel]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
callab LoadEnemyMonData
pop af
ld [wcf91],a
@@ -387,15 +506,18 @@ ItemUseBall: ; d687 (3:5687)
ld [hld],a
pop af
ld [hl],a
- ld a,[wEnemyMonSpecies] ;enemy
+ ld a,[wEnemyMonSpecies]
ld [wCapturedMonSpecies],a
ld [wcf91],a
ld [wd11e],a
- ld a,[W_BATTLETYPE]
- dec a
- jr z,.printText1
+ ld a,[wBattleType]
+ dec a ; is this the old man battle?
+ jr z,.oldManCaughtMon ; if so, don't give the player the caught Pokémon
+
ld hl,ItemUseBallText05
call PrintText
+
+; Add the caught Pokémon to the Pokédex.
predef IndexToPokedex
ld a,[wd11e]
dec a
@@ -411,46 +533,56 @@ ItemUseBall: ; d687 (3:5687)
ld b,FLAG_SET
predef FlagActionPredef
pop af
- and a
- jr nz,.checkParty
+
+ and a ; was the Pokémon already in the Pokédex?
+ jr nz,.skipShowingPokedexData ; if so, don't show the Pokédex data
+
ld hl,ItemUseBallText06
call PrintText
call ClearSprites
- ld a,[wEnemyMonSpecies] ;caught mon_ID
+ ld a,[wEnemyMonSpecies]
ld [wd11e],a
predef ShowPokedexData
-.checkParty
+
+.skipShowingPokedexData
ld a,[wPartyCount]
- cp a,PARTY_LENGTH ;is party full?
+ cp a,PARTY_LENGTH ; is party full?
jr z,.sendToBox
xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation],a
call ClearSprites
- call AddPartyMon ;add mon to Party
- jr .End
+ call AddPartyMon
+ jr .done
+
.sendToBox
call ClearSprites
call SendNewMonToBox
ld hl,ItemUseBallText07
CheckEvent EVENT_MET_BILL
- jr nz,.sendToBox2
+ jr nz,.printTransferredToPCText
ld hl,ItemUseBallText08
-.sendToBox2
+.printTransferredToPCText
call PrintText
- jr .End
-.printText1
+ jr .done
+
+.oldManCaughtMon
ld hl,ItemUseBallText05
-.printText0
+
+.printMessage
call PrintText
call ClearSprites
-.End
- ld a,[W_BATTLETYPE]
- and a
- ret nz
+
+.done
+ ld a,[wBattleType]
+ and a ; is this the old man battle?
+ ret nz ; if so, don't remove a ball from the bag
+
+; Remove a ball from the bag.
ld hl,wNumBagItems
inc a
ld [wItemQuantity],a
jp RemoveItemFromInventory
+
ItemUseBallText00: ; d937 (3:5937)
;"It dodged the thrown ball!"
;"This pokemon can't be caught"
@@ -495,13 +627,13 @@ ItemUseBallText06: ; d961 (3:5961)
db "@"
ItemUseTownMap: ; d968 (3:5968)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
jpba DisplayTownMap
ItemUseBicycle: ; d977 (3:5977)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wWalkBikeSurfState]
@@ -563,7 +695,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
ld hl,TilePairCollisionsWater
call CheckForTilePairCollisions
jr c,.cannotStopSurfing
- ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles
+ ld hl,wTileSetCollisionPtr ; pointer to list of passable tiles
ld a,[hli]
ld h,[hl]
ld l,a ; hl now points to passable tiles
@@ -622,7 +754,7 @@ ItemUsePokedex: ; da56 (3:5a56)
predef_jump ShowPokedexMenu
ItemUseEvoStone: ; da5b (3:5a5b)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wWhichPokemon]
@@ -663,7 +795,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ret
ItemUseVitamin: ; dab4 (3:5ab4)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
@@ -766,13 +898,13 @@ ItemUseMedicine: ; dabb (3:5abb)
xor a
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
push hl
- ld hl,W_PLAYERBATTSTATUS3
+ ld hl,wPlayerBattleStatus3
res BadlyPoisoned,[hl] ; heal Toxic status
pop hl
- ld bc,30
+ ld bc,wPartyMon1Stats - wPartyMon1Status
add hl,bc ; hl now points to party stats
- ld de,wBattleMonMaxHP
- ld bc,10
+ ld de,wBattleMonStats
+ ld bc,NUM_STATS * 2
call CopyData ; copy party stats to in-battle stat data
predef DoubleOrHalveSelectedStats
jp .doneHealing
@@ -794,7 +926,7 @@ ItemUseMedicine: ; dabb (3:5abb)
jr z,.updateInBattleFaintedData
jp .healingItemNoEffect
.updateInBattleFaintedData
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr z,.compareCurrentHPToMaxHP
push hl
@@ -827,7 +959,7 @@ ItemUseMedicine: ; dabb (3:5abb)
.compareCurrentHPToMaxHP
push hl
push bc
- ld bc,32
+ ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
add hl,bc ; hl now points to max HP
pop bc
ld a,[hli]
@@ -856,10 +988,10 @@ ItemUseMedicine: ; dabb (3:5abb)
.notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a
ld [wLowHealthAlarm],a ;disable low health alarm
- ld [wc02a],a
+ ld [wChannelSoundIDs + CH4],a
push hl
push de
- ld bc,32
+ ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1)
add hl,bc ; hl now points to max HP
ld a,[hli]
ld [wHPBarMaxHP+1],a
@@ -892,7 +1024,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [H_DIVISOR],a
ld b,2 ; number of bytes
call Divide ; get 1/5 of max HP of pokemon that used Softboiled
- ld bc,wPartyMon1HP - wPartyMon1MaxHP
+ ld bc,(wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1)
add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled
; subtract 1/5 of max HP from current HP of pokemon that used Softboiled
ld a,[H_QUOTIENT + 3]
@@ -912,7 +1044,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wHPBarNewHP+1],a
coord hl, 4, 1
ld a,[wWhichPokemon]
- ld bc,2 * 20
+ ld bc,2 * SCREEN_WIDTH
call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
ld a,SFX_HEAL_HP
call PlaySoundWaitForCurrent
@@ -971,7 +1103,7 @@ ItemUseMedicine: ; dabb (3:5abb)
inc hl
ld d,h
ld e,l ; de now points to current HP
- ld hl,33
+ ld hl,(wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1)
add hl,de ; hl now points to max HP
ld a,[wcf91]
cp a,REVIVE
@@ -1018,7 +1150,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[wcf91]
cp a,FULL_RESTORE
jr nz,.updateInBattleData
- ld bc,-31
+ ld bc,wPartyMon1Status - (wPartyMon1MaxHP + 1)
add hl,bc
xor a
ld [hl],a ; remove the status ailment in the party data
@@ -1041,7 +1173,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data
.calculateHPBarCoords
ld hl,wOAMBuffer + $90
- ld bc,2 * 20
+ ld bc,2 * SCREEN_WIDTH
inc d
.calculateHPBarCoordsLoop
add hl,bc
@@ -1111,8 +1243,8 @@ ItemUseMedicine: ; dabb (3:5abb)
and a ; using Softboiled?
ret nz ; if so, return
call GBPalWhiteOut
- call z,GoPAL_SET_CF1C
- ld a,[W_ISINBATTLE]
+ call z,RunDefaultPaletteCommand
+ ld a,[wIsInBattle]
and a
ret nz
jp ReloadMapData
@@ -1121,10 +1253,10 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,[hl]
ld [wd0b5],a
ld [wd11e],a
- ld bc,33
+ ld bc,wPartyMon1Level - wPartyMon1
add hl,bc ; hl now points to level
ld a,[hl] ; a = level
- ld [W_CURENEMYLVL],a ; store level
+ ld [wCurEnemyLVL],a ; store level
call GetMonHeader
push de
ld a,d
@@ -1138,7 +1270,7 @@ ItemUseMedicine: ; dabb (3:5abb)
push hl
sub a,HP_UP
add a
- ld bc,17
+ ld bc,wPartyMon1HPExp - wPartyMon1
add hl,bc
add l
ld l,a
@@ -1186,32 +1318,32 @@ ItemUseMedicine: ; dabb (3:5abb)
call PrintText
jp GBPalWhiteOut
.recalculateStats
- ld bc,34
+ ld bc,wPartyMon1Stats - wPartyMon1
add hl,bc
ld d,h
ld e,l ; de now points to stats
- ld bc,-18
- add hl,bc ; hl now points to byte 3 of experience
+ ld bc,(wPartyMon1Exp + 2) - wPartyMon1Stats
+ add hl,bc ; hl now points to LSB of experience
ld b,1
jp CalcStats ; recalculate stats
.useRareCandy
push hl
- ld bc,33
+ ld bc,wPartyMon1Level - wPartyMon1
add hl,bc ; hl now points to level
ld a,[hl] ; a = level
cp a, MAX_LEVEL
jr z,.vitaminNoEffect ; can't raise level above 100
inc a
ld [hl],a ; store incremented level
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
push hl
push de
ld d,a
callab CalcExperience ; calculate experience for next level and store it at $ff96
pop de
pop hl
- ld bc,-19
- add hl,bc ; hl now points to experience
+ ld bc,wPartyMon1Exp - wPartyMon1Level
+ add hl,bc ; hl now points to MSB of experience
; update experience to minimum for new level
ld a,[hExperience]
ld [hli],a
@@ -1226,7 +1358,7 @@ ItemUseMedicine: ; dabb (3:5abb)
push af
push de
push hl
- ld bc,34
+ ld bc,wPartyMon1MaxHP - wPartyMon1
add hl,bc ; hl now points to MSB of max HP
ld a,[hli]
ld b,a
@@ -1236,8 +1368,8 @@ ItemUseMedicine: ; dabb (3:5abb)
push hl
call .recalculateStats
pop hl
- ld bc,35 ; hl now points to LSB of max HP
- add hl,bc
+ ld bc,(wPartyMon1MaxHP + 1) - wPartyMon1
+ add hl,bc ; hl now points to LSB of max HP
pop bc
ld a,[hld]
sub c
@@ -1246,8 +1378,8 @@ ItemUseMedicine: ; dabb (3:5abb)
sbc b
ld b,a ; bc = the amount of max HP gained from leveling up
; add the amount gained to the current HP
- ld de,-32
- add hl,de ; hl now points to MSB of current HP
+ ld de,(wPartyMon1HP + 1) - wPartyMon1MaxHP
+ add hl,de ; hl now points to LSB of current HP
ld a,[hl]
add c
ld [hld],a
@@ -1322,9 +1454,9 @@ ItemUseRock: ; df67 (3:5f67)
ld de,wSafariBaitFactor ; bait factor
BaitRockCommon: ; df7f (3:5f7f)
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
xor a
- ld [wcc5b],a
+ ld [wAnimationType],a
ld [H_WHOSETURN],a
ld [de],a ; zero escape factor (for bait), zero bait factor (for rock)
.randomLoop ; loop until a random number less than 5 is generated
@@ -1354,13 +1486,13 @@ ThrewRockText: ; dfaa (3:5faa)
; also used for Dig out-of-battle effect
ItemUseEscapeRope: ; dfaf (3:5faf)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr nz,.notUsable
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp a,AGATHAS_ROOM
jr z,.notUsable
- ld a,[W_CURMAPTILESET]
+ ld a,[wCurMapTileset]
ld b,a
ld hl,EscapeRopeTilesets
.loop
@@ -1376,8 +1508,8 @@ ItemUseEscapeRope: ; dfaf (3:5faf)
res 4,[hl]
ResetEvent EVENT_IN_SAFARI_ZONE
xor a
- ld [W_NUMSAFARIBALLS],a
- ld [W_SAFARIZONEENTRANCECURSCRIPT],a
+ ld [wNumSafariBalls],a
+ ld [wSafariZoneEntranceCurScript],a
inc a
ld [wEscapedFromBattle],a
ld [wActionResultOrTookBattleTurn],a ; item used
@@ -1399,7 +1531,7 @@ ItemUseRepel: ; e003 (3:6003)
ld b,100
ItemUseRepelCommon: ; e005 (3:6005)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,b
@@ -1408,10 +1540,10 @@ ItemUseRepelCommon: ; e005 (3:6005)
; handles X Accuracy item
ItemUseXAccuracy: ; e013 (3:6013)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
- ld hl,W_PLAYERBATTSTATUS2
+ ld hl,wPlayerBattleStatus2
set UsingXAccuracy,[hl] ; X Accuracy bit
jp PrintItemUseTextAndRemoveItem
@@ -1421,7 +1553,7 @@ ItemUseCardKey: ; e022 (3:6022)
xor a
ld [wUnusedD71F],a
call GetTileAndCoordsInFrontOfPlayer
- ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
+ ld a,[GetTileAndCoordsInFrontOfPlayer]
cp a,$18
jr nz,.next0
ld hl,CardKeyTable1
@@ -1436,7 +1568,7 @@ ItemUseCardKey: ; e022 (3:6022)
jp nz,ItemUseNotTime
ld hl,CardKeyTable3
.next1
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld b,a
.loop
ld a,[hli]
@@ -1509,7 +1641,7 @@ CardKeyTable3: ; e0c4 (3:60c4)
db $ff
ItemUsePokedoll: ; e0cd (3:60cd)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
dec a
jp nz,ItemUseNotTime
ld a,$01
@@ -1517,10 +1649,10 @@ ItemUsePokedoll: ; e0cd (3:60cd)
jp PrintItemUseTextAndRemoveItem
ItemUseGuardSpec: ; e0dc (3:60dc)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
- ld hl,W_PLAYERBATTSTATUS2
+ ld hl,wPlayerBattleStatus2
set ProtectedByMist,[hl] ; Mist bit
jp PrintItemUseTextAndRemoveItem
@@ -1533,15 +1665,15 @@ ItemUseMaxRepel: ; e0f0 (3:60f0)
jp ItemUseRepelCommon
ItemUseDireHit: ; e0f5 (3:60f5)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
- ld hl,W_PLAYERBATTSTATUS2
+ ld hl,wPlayerBattleStatus2
set GettingPumped,[hl] ; Focus Energy bit
jp PrintItemUseTextAndRemoveItem
ItemUseXStat: ; e104 (3:6104)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr nz,.inBattle
call ItemUseNotTime
@@ -1549,18 +1681,18 @@ ItemUseXStat: ; e104 (3:6104)
ld [wActionResultOrTookBattleTurn],a ; item not used
ret
.inBattle
- ld hl,W_PLAYERMOVENUM
+ ld hl,wPlayerMoveNum
ld a,[hli]
- push af ; save [W_PLAYERMOVENUM]
+ push af ; save [wPlayerMoveNum]
ld a,[hl]
- push af ; save [W_PLAYERMOVEEFFECT]
+ push af ; save [wPlayerMoveEffect]
push hl
ld a,[wcf91]
sub a,X_ATTACK - ATTACK_UP1_EFFECT
ld [hl],a ; store player move effect
call PrintItemUseTextAndRemoveItem
ld a,XSTATITEM_ANIM ; X stat item animation ID
- ld [W_PLAYERMOVENUM],a
+ ld [wPlayerMoveNum],a
call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3
xor a
@@ -1568,18 +1700,18 @@ ItemUseXStat: ; e104 (3:6104)
callba StatModifierUpEffect ; do stat increase move
pop hl
pop af
- ld [hld],a ; restore [W_PLAYERMOVEEFFECT]
+ ld [hld],a ; restore [wPlayerMoveEffect]
pop af
- ld [hl],a ; restore [W_PLAYERMOVENUM]
+ ld [hl],a ; restore [wPlayerMoveNum]
ret
ItemUsePokeflute: ; e140 (3:6140)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr nz,.inBattle
; if not in battle
call ItemUseReloadOverworldData
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp a,ROUTE_12
jr nz,.notRoute12
CheckEvent EVENT_BEAT_ROUTE12_SNORLAX
@@ -1614,7 +1746,7 @@ ItemUsePokeflute: ; e140 (3:6140)
ld b,~SLP & $ff
ld hl,wPartyMon1Status
call WakeUpEntireParty
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
dec a ; is it a trainer battle?
jr z,.skipWakingUpEnemyParty
; if it's a trainer battle
@@ -1643,7 +1775,7 @@ ItemUsePokeflute: ; e140 (3:6140)
call WaitForSoundToFinish ; wait for sound to end
callba Music_PokeFluteInBattle ; play in-battle pokeflute music
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc02c]
+ ld a,[wChannelSoundIDs + CH6]
and a ; music off?
jr nz,.musicWaitLoop
.skipMusic
@@ -1706,7 +1838,7 @@ PlayedFluteHadEffectText: ; e215 (3:6215)
TX_FAR _PlayedFluteHadEffectText
db $06
TX_ASM
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr nz,.done
; play out-of-battle pokeflute music
@@ -1716,15 +1848,15 @@ PlayedFluteHadEffectText: ; e215 (3:6215)
ld c, BANK(SFX_Pokeflute)
call PlayMusic
.musicWaitLoop ; wait for music to finish playing
- ld a,[wc028]
- cp a,$b8
+ ld a,[wChannelSoundIDs + CH2]
+ cp a, SFX_POKEFLUE
jr z,.musicWaitLoop
call PlayDefaultMusic ; start playing normal music again
.done
jp TextScriptEnd ; end text
ItemUseCoinCase: ; e23a (3:623a)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld hl,CoinCaseNumCoinsText
@@ -1781,11 +1913,11 @@ RodResponse: ; e28d (3:628d)
jr nz, .next
; if yes, store level and species data
ld a, 1
- ld [W_MOVEMISSED], a
+ ld [wMoveMissed], a
ld a, b ; level
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld a, c ; species
- ld [W_CUROPPONENT], a
+ ld [wCurOpponent], a
.next
ld hl, wWalkBikeSurfState
@@ -1802,7 +1934,7 @@ RodResponse: ; e28d (3:628d)
; checks if fishing is possible and if so, runs initialization code common to all rods
; unsets carry if fishing is possible, sets carry if not
FishingInit: ; e2b4 (3:62b4)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr z,.notInBattle
scf ; can't fish during battle
@@ -1830,7 +1962,7 @@ ItemUseOaksParcel: ; e2de (3:62de)
jp ItemUseNotYoursToUse
ItemUseItemfinder: ; e2e1 (3:62e1)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
call ItemUseReloadOverworldData
@@ -1858,7 +1990,7 @@ ItemfinderFoundNothingText: ; e312 (3:6312)
db "@"
ItemUsePPUp: ; e317 (3:6317)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
@@ -1895,7 +2027,7 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wPlayerMoveListIndex],a
jr nz,.chooseMon
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
push hl
ld a,[hl]
@@ -1928,7 +2060,7 @@ ItemUsePPRestore: ; e31e (3:631e)
pop af
ld [wWhichPokemon],a
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp RemoveUsedItem
.afterRestoringPP ; after using a (Max) Ether/Elixir
ld a,[wWhichPokemon]
@@ -1937,7 +2069,7 @@ ItemUsePPRestore: ; e31e (3:631e)
cp b ; is the pokemon whose PP was restored active in battle?
jr nz,.skipUpdatingInBattleData
ld hl,wPartyMon1PP
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld de,wBattleMonPP
ld bc,4
@@ -1959,12 +2091,12 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wMonDataLocation],a
call GetMaxPP
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
- ld bc,21
+ ld bc, wPartyMon1PP - wPartyMon1Moves
add hl,bc ; hl now points to move's PP
- ld a,[wd11e]
- ld b,a ; b = max PP
+ ld a,[wMaxPP]
+ ld b,a
ld a,[wPPRestoreItem]
cp a,MAX_ETHER
jr z,.fullyRestorePP
@@ -2009,7 +2141,7 @@ ItemUsePPRestore: ; e31e (3:631e)
.elixirLoop
push bc
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
call GetSelectedMoveOffset
ld a,[hl]
and a ; does the current slot have a move?
@@ -2032,7 +2164,7 @@ ItemUsePPRestore: ; e31e (3:631e)
call ItemUseNoEffect
.itemNotUsed
call GBPalWhiteOut
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
pop af
xor a
ld [wActionResultOrTookBattleTurn],a ; item use failed
@@ -2063,7 +2195,7 @@ UnusableItem: ; e476 (3:6476)
jp ItemUseNotTime
ItemUseTMHM: ; e479 (3:6479)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wcf91]
@@ -2105,16 +2237,16 @@ ItemUseTMHM: ; e479 (3:6479)
push af
.chooseMon
ld hl,wcf4b
- ld de,wd036
+ ld de,wTempMoveNameBuffer
ld bc,14
- call CopyData
+ call CopyData ; save the move name because DisplayPartyMenu will overwrite it
ld a,$ff
ld [wUpdateSpritesEnabled],a
ld a,TMHM_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a
call DisplayPartyMenu
push af
- ld hl,wd036
+ ld hl,wTempMoveNameBuffer
ld de,wcf4b
ld bc,14
call CopyData
@@ -2125,7 +2257,7 @@ ItemUseTMHM: ; e479 (3:6479)
pop af
call GBPalWhiteOutWithDelay3
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp LoadScreenTilesFromBuffer1 ; restore saved screen
.checkIfAbleToLearnMove
predef CanLearnTM ; check if the pokemon can learn the move
@@ -2201,11 +2333,11 @@ ItemUseNotYoursToUse: ; e586 (3:6586)
jr ItemUseFailed
ThrowBallAtTrainerMon: ; e58b (3:658b)
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadScreenTilesFromBuffer1 ; restore saved screen
call Delay3
ld a,TOSS_ANIM
- ld [W_ANIMATIONID],a
+ ld [wAnimationID],a
predef MoveAnimation ; do animation
ld hl,ThrowBallAtTrainerMonText1
call PrintText
@@ -2283,20 +2415,17 @@ GotOffBicycleText: ; e5fc (3:65fc)
; also, when a PP Up is used, it increases the current PP by one PP Up bonus
; INPUT:
; [wWhichPokemon] = index of pokemon in party
-; [wd11e] = mode
-; 0: Pokemon Center healing
-; 1: using a PP Up
; [wCurrentMenuItem] = index of move (when using a PP Up)
RestoreBonusPP: ; e606 (3:6606)
ld hl,wPartyMon1Moves
- ld bc,44
+ ld bc, wPartyMon2 - wPartyMon1
ld a,[wWhichPokemon]
call AddNTimes
push hl
ld de,wNormalMaxPPList - 1
predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList
pop hl
- ld c,21
+ ld c, wPartyMon1PP - wPartyMon1Moves
ld b,0
add hl,bc ; hl now points to move 1 PP
ld de,wNormalMaxPPList
@@ -2307,7 +2436,7 @@ RestoreBonusPP: ; e606 (3:6606)
ld a,b
cp a,5 ; reached the end of the pokemon's moves?
ret z ; if so, return
- ld a,[wd11e]
+ ld a,[wUsingPPUp]
dec a ; using a PP Up?
jr nz,.skipMenuItemIDCheck
; if using a PP Up, check if this is the move it's being used on
@@ -2329,8 +2458,6 @@ RestoreBonusPP: ; e606 (3:6606)
; INPUT:
; [de] = normal max PP
; [hl] = move PP
-; [wd11e] = max number of times to add bonus
-; set to 1 when using a PP Up, set to 255 otherwise
AddBonusPP: ; e642 (3:6642)
push bc
ld a,[de] ; normal max PP of move
@@ -2358,9 +2485,9 @@ AddBonusPP: ; e642 (3:6642)
.addAmount
add b
ld b,a
- ld a,[wd11e]
- dec a
- jr z,.done
+ ld a,[wUsingPPUp]
+ dec a ; is the player using a PP Up right now?
+ jr z,.done ; if so, only add the bonus once
dec c
jr nz,.loop
.done
@@ -2379,7 +2506,7 @@ AddBonusPP: ; e642 (3:6642)
; 04: player's in-battle pokemon
; [wCurrentMenuItem] = move index
; OUTPUT:
-; [wd11e] = max PP
+; [wMaxPP] = max PP
GetMaxPP: ; e677 (3:6677)
ld a,[wMonDataLocation]
and a
@@ -2407,7 +2534,7 @@ GetMaxPP: ; e677 (3:6677)
dec a
push hl
ld hl,Moves
- ld bc,6
+ ld bc,MoveEnd - Moves
call AddNTimes
ld de,wcd6d
ld a,BANK(Moves)
@@ -2432,12 +2559,12 @@ GetMaxPP: ; e677 (3:6677)
ld l,e
inc hl ; hl = wcd73
ld [hl],a
- xor a
- ld [wd11e],a ; no limit on PP Up amount
+ xor a ; add the bonus for the existing PP Up count
+ ld [wUsingPPUp],a
call AddBonusPP ; add bonus PP from PP Ups
ld a,[hl]
and a,%00111111 ; mask out the PP Up count
- ld [wd11e],a ; store max PP
+ ld [wMaxPP],a ; store max PP
ret
GetSelectedMoveOffset: ; e6e3 (3:66e3)
@@ -2560,7 +2687,7 @@ IsKeyItem_: ; e764 (3:6764)
INCLUDE "data/key_items.asm"
SendNewMonToBox: ; e7a4 (3:67a4)
- ld de, W_NUMINBOX
+ ld de, wNumInBox
ld a, [de]
inc a
ld [de], a
@@ -2578,30 +2705,30 @@ SendNewMonToBox: ; e7a4 (3:67a4)
jr nz, .asm_e7b1
call GetMonHeader
ld hl, wBoxMonOT
- ld bc, 11
- ld a, [W_NUMINBOX]
+ ld bc, NAME_LENGTH
+ ld a, [wNumInBox]
dec a
jr z, .asm_e7ee
dec a
call AddNTimes
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
dec a
ld b, a
.asm_e7db
push bc
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, -$b
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
@@ -2609,33 +2736,33 @@ SendNewMonToBox: ; e7a4 (3:67a4)
.asm_e7ee
ld hl, wPlayerName
ld de, wBoxMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
dec a
jr z, .asm_e82a
ld hl, wBoxMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
dec a
call AddNTimes
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
dec a
ld b, a
.asm_e817
push bc
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, -$b
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
@@ -2645,7 +2772,7 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
predef AskName
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
dec a
jr z, .asm_e867
ld hl, wBoxMons
@@ -2658,7 +2785,7 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld d, h
ld e, l
pop hl
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
dec a
ld b, a
.asm_e854
@@ -2689,7 +2816,7 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld [de], a
inc de
push de
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
ld d, a
callab CalcExperience
pop de
@@ -2729,12 +2856,12 @@ SendNewMonToBox: ; e7a4 (3:67a4)
; used for surfing and fishing
; unsets carry if it is, sets carry if not
IsNextTileShoreOrWater: ; e8b8 (3:68b8)
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
ld hl, WaterTilesets
ld de,1
call IsInArray
jr nc, .notShoreOrWater
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
cp SHIP_PORT ; Vermilion Dock tileset
ld a, [wTileInFrontOfPlayer] ; tile in front of player
jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset
@@ -2761,7 +2888,7 @@ ReadSuperRodData: ; e8ea (3:68ea)
; return e = 2 if no fish on this map
; return e = 1 if a bite, bc = level,species
; return e = 0 if no bite
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld de, 3 ; each fishing group is three bytes wide
ld hl, SuperRodData
call IsInArray
diff --git a/engine/items/tms.asm b/engine/items/tms.asm
index 23912b34..7d00f7f3 100755
--- a/engine/items/tms.asm
+++ b/engine/items/tms.asm
@@ -3,7 +3,7 @@ CanLearnTM: ; 1373e (4:773e)
ld a, [wcf91]
ld [wd0b5], a
call GetMonHeader
- ld hl, W_MONHLEARNSET
+ ld hl, wMonHLearnset
push hl
ld a, [wMoveNum]
ld b, a
diff --git a/engine/learn_move.asm b/engine/learn_move.asm
index 88dedd3d..ede8a542 100755
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -4,8 +4,8 @@ LearnMove: ; 6e43 (1:6e43)
ld hl, wPartyMonNicks
call GetPartyMonName
ld hl, wcd6d
- ld de, wd036
- ld bc, 11
+ ld de, wLearnMoveMonName
+ ld bc, NAME_LENGTH
call CopyData
DontAbandonLearning: ; 6e5b (1:6e5b)
@@ -16,13 +16,13 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
ld d, h
ld e, l
ld b, NUM_MOVES
-.asm_6e6b
+.findEmptyMoveSlotLoop
ld a, [hl]
and a
- jr z, .asm_6e8b
+ jr z, .next
inc hl
dec b
- jr nz, .asm_6e6b
+ jr nz, .findEmptyMoveSlotLoop
push de
call TryingToLearn
pop de
@@ -35,7 +35,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
call PrintText
pop de
pop hl
-.asm_6e8b
+.next
ld a, [wMoveNum]
ld [hl], a
ld bc, wPartyMon1PP - wPartyMon1Moves
@@ -44,7 +44,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
push de
dec a
ld hl, Moves
- ld bc, $6
+ ld bc, MoveEnd - Moves
call AddNTimes
ld de, wBuffer
ld a, BANK(Moves)
@@ -53,7 +53,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b)
pop de
pop hl
ld [hl], a
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jp z, PrintLearnedMove
ld a, [wWhichPokemon]
@@ -86,13 +86,13 @@ AbandonLearning: ; 6eda (1:6eda)
jp nz, DontAbandonLearning
ld hl, DidNotLearnText
call PrintText
- ld b, $0
+ ld b, 0
ret
PrintLearnedMove: ; 6efe (1:6efe)
ld hl, LearnedMove1Text
call PrintText
- ld b, $1
+ ld b, 1
ret
TryingToLearn: ; 6f07 (1:6f07)
@@ -108,7 +108,7 @@ TryingToLearn: ; 6f07 (1:6f07)
ld a, [wCurrentMenuItem]
rra
ret c
- ld bc, - NUM_MOVES
+ ld bc, -NUM_MOVES
add hl, bc
push hl
ld de, wMoves
@@ -116,13 +116,13 @@ TryingToLearn: ; 6f07 (1:6f07)
call CopyData
callab FormatMovesString
pop hl
-.asm_6f39
+.loop
push hl
ld hl, WhichMoveToForgetText
call PrintText
coord hl, 4, 7
- ld b, $4
- ld c, $e
+ ld b, 4
+ ld c, 14
call TextBoxBorder
coord hl, 6, 8
ld de, wMovesString
@@ -155,12 +155,12 @@ TryingToLearn: ; 6f07 (1:6f07)
call LoadScreenTilesFromBuffer1
pop af
pop hl
- bit 1, a
- jr nz, .asm_6fab
+ bit 1, a ; pressed b
+ jr nz, .cancel
push hl
ld a, [wCurrentMenuItem]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
push af
@@ -169,17 +169,17 @@ TryingToLearn: ; 6f07 (1:6f07)
pop bc
pop de
ld a, d
- jr c, .asm_6fa2
+ jr c, .hm
pop hl
add hl, bc
and a
ret
-.asm_6fa2
+.hm
ld hl, HMCantDeleteText
call PrintText
pop hl
- jr .asm_6f39
-.asm_6fab
+ jr .loop
+.cancel
scf
ret
diff --git a/engine/load_pokedex_tiles.asm b/engine/load_pokedex_tiles.asm
index f4e45247..1189d2f0 100755
--- a/engine/load_pokedex_tiles.asm
+++ b/engine/load_pokedex_tiles.asm
@@ -3,7 +3,7 @@ LoadPokedexTilePatterns: ; 17840 (5:7840)
call LoadHpBarAndStatusTilePatterns
ld de,PokedexTileGraphics
ld hl,vChars2 + $600
- lb bc, BANK(PokedexTileGraphics), $12
+ lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
call CopyVideoData
ld de,PokeballTileGraphics
ld hl,vChars2 + $720
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 072a19d3..d367bdb5 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -212,7 +212,7 @@ BillsPCDeposit: ; 215ac (8:55ac)
call PrintText
jp BillsPCMenu
.partyLargeEnough
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
cp MONS_PER_BOX
jr nz, .boxNotFull
ld hl, BoxFullText
@@ -254,7 +254,7 @@ BillsPCDeposit: ; 215ac (8:55ac)
jp BillsPCMenu
BillsPCWithdraw: ; 21618 (8:5618)
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
and a
jr nz, .boxNotEmpty
ld hl, NoMonText
@@ -268,7 +268,7 @@ BillsPCWithdraw: ; 21618 (8:5618)
call PrintText
jp BillsPCMenu
.partyNotFull
- ld hl, W_NUMINBOX
+ ld hl, wNumInBox
call DisplayMonListMenu
jp c, BillsPCMenu
call DisplayDepositWithdrawMenu
@@ -291,14 +291,14 @@ BillsPCWithdraw: ; 21618 (8:5618)
jp BillsPCMenu
BillsPCRelease: ; 21673 (8:5673)
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
and a
jr nz, .loop
ld hl, NoMonText
call PrintText
jp BillsPCMenu
.loop
- ld hl, W_NUMINBOX
+ ld hl, wNumInBox
call DisplayMonListMenu
jp c, BillsPCMenu
ld hl, OnceReleasedText
@@ -450,7 +450,7 @@ DisplayDepositWithdrawMenu: ; 2174b (8:574b)
predef StatusScreen2
call LoadScreenTilesFromBuffer1
call ReloadTilesetTilePatterns
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadGBPal
jr .loop
@@ -515,7 +515,7 @@ CableClubLeftGameboy:: ; 5824 (8:5825)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_RIGHT
ret nz
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp TRADE_CENTER
ld a, LINK_STATE_START_TRADE
jr z, .next
@@ -532,7 +532,7 @@ CableClubRightGameboy:: ; 5845 (8:5845)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_LEFT
ret nz
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp TRADE_CENTER
ld a, LINK_STATE_START_TRADE
jr z, .next
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
index 3e28bc93..630c6c23 100755
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -55,8 +55,8 @@ DisplayDiploma: ; 566e2 (15:66e2)
call EnableLCD
callba LoadTrainerInfoTextBoxTiles
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call Delay3
call GBPalNormal
ld a, $90
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index 21c3f9e7..7c31d346 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -10,7 +10,7 @@ PKMNLeaguePC: ; 0x7657e
push af
xor a
ld [hTilesetType], a
- ld [W_SPRITEFLIPPED], a
+ ld [wSpriteFlipped], a
ld [wUpdateSpritesEnabled], a
ld [wHoFTeamIndex2], a
ld [wHoFTeamNo], a
@@ -47,7 +47,7 @@ PKMNLeaguePC: ; 0x7657e
res 6, [hl]
call GBPalWhiteOutWithDelay3
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp GBPalNormal
LeaguePCShowTeam: ; 765e5 (1d:65e5)
@@ -86,15 +86,15 @@ LeaguePCShowMon: ; 76610 (1d:6610)
ld [wcf91], a
ld [wd0b5], a
ld [wBattleMonSpecies2], a
- ld [wcf1d], a
+ ld [wWholeScreenPaletteMonSpecies], a
ld a, [hli]
ld [wHoFMonLevel], a
ld de, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
- ld b, $0B
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
ld c, 0
- call GoPAL_SET
+ call RunPaletteCommand
coord hl, 12, 5
call GetMonHeader
call LoadFrontSpriteByMonIndex
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index f99e5b80..75458c5e 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -20,11 +20,11 @@ MainMenu: ; 5af2 (1:5af2)
ld [hli],a
ld [hli],a
ld [hl],a
- ld [W_ANIMATIONID],a
+ ld [wDefaultMap],a
ld hl,wd72e
res 6,[hl]
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call LoadFontTilePatterns
ld hl,wd730
@@ -61,7 +61,7 @@ MainMenu: ; 5af2 (1:5af2)
ld [wTopMenuItemX],a
inc a
ld [wTopMenuItemY],a
- ld a,$B
+ ld a,A_BUTTON | B_BUTTON | START
ld [wMenuWatchedKeys],a
ld a,[wSaveFileStatus]
ld [wMaxMenuItem],a
@@ -90,7 +90,7 @@ MainMenu: ; 5af2 (1:5af2)
jp .mainMenuLoop
.choseContinue
call DisplayContinueGameInfo
- ld hl,wd126
+ ld hl,wCurrentMapScriptFlags
set 5,[hl]
.inputLoop
xor a
@@ -114,7 +114,7 @@ MainMenu: ; 5af2 (1:5af2)
ld a,[wNumHoFTeams]
and a
jp z,SpecialEnterMap
- ld a,[W_CURMAP] ; map ID
+ ld a,[wCurMap] ; map ID
cp a,HALL_OF_FAME
jp nz,SpecialEnterMap
xor a
@@ -128,7 +128,7 @@ InitOptions: ; 5bff (1:5bff)
ld a,1 ; no delay
ld [wLetterPrintingDelayFlags],a
ld a,3 ; medium speed
- ld [W_OPTIONS],a
+ ld [wOptions],a
ret
LinkMenu: ; 5c0a (1:5c0a)
@@ -150,7 +150,7 @@ LinkMenu: ; 5c0a (1:5c0a)
ld de, CableClubOptionsText
call PlaceString
xor a
- ld [wcd37], a
+ ld [wUnusedCD37], a
ld [wd72d], a
ld hl, wTopMenuItemY
ld a, $7
@@ -163,7 +163,8 @@ LinkMenu: ; 5c0a (1:5c0a)
ld a, $2
ld [hli], a
inc a
- ld [hli], a
+ ; ld a, A_BUTTON | B_BUTTON
+ ld [hli], a ; wMenuWatchedKeys
xor a
ld [hl], a
.waitForInputLoop
@@ -268,7 +269,7 @@ LinkMenu: ; 5c0a (1:5c0a)
call DelayFrames
ld hl, wd732
res 1, [hl]
- ld a, [W_ANIMATIONID]
+ ld a, [wDefaultMap]
ld [wDestinationMap], a
call SpecialWarpIn
ld c, 20
@@ -391,11 +392,11 @@ PrintSaveScreenText: ; 5def (1:5def)
PrintNumBadges: ; 5e2f (1:5e2f)
push hl
- ld hl, W_OBTAINEDBADGES
+ ld hl, wObtainedBadges
ld b, $1
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 2
jp PrintNumber
@@ -405,17 +406,17 @@ PrintNumOwnedMons: ; 5e42 (1:5e42)
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
pop hl
- ld de, wd11e
+ ld de, wNumSetBits
lb bc, 1, 3
jp PrintNumber
PrintPlayTime: ; 5e55 (1:5e55)
- ld de, W_PLAYTIMEHOURS + 1
+ ld de, wPlayTimeHours
lb bc, 1, 3
call PrintNumber
ld [hl], $6d
inc hl
- ld de, W_PLAYTIMEMINUTES + 1
+ ld de, wPlayTimeMinutes
lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
@@ -625,13 +626,13 @@ SetOptionsFromCursorPositions: ; 601f (1:601f)
res 6,d
.storeOptions
ld a,d
- ld [W_OPTIONS],a
+ ld [wOptions],a
ret
; reads the options variable and places menu cursors in the correct positions within the options menu
SetCursorPositionsFromOptions: ; 604c (1:604c)
ld hl,TextSpeedOptionData + 1
- ld a,[W_OPTIONS]
+ ld a,[wOptions]
ld c,a
and a,$3f
push bc
@@ -689,7 +690,7 @@ CheckForPlayerNameInSRAM: ; 609e (1:609e)
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld b, $b
+ ld b, NAME_LENGTH
ld hl, sPlayerName
.loop
ld a, [hli]
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index 967f11e8..41f63095 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -2,7 +2,7 @@ AskName: ; 64eb (1:64eb)
call SaveScreenTilesToBuffer1
call GetPredefRegisters
push hl
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a
coord hl, 0, 0
ld b, 4
@@ -30,7 +30,7 @@ AskName: ; 64eb (1:64eb)
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jr nz, .inBattle
call ReloadMapSpriteTilePatterns
@@ -46,7 +46,7 @@ AskName: ; 64eb (1:64eb)
ld d, h
ld e, l
ld hl, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
DoYouWantToNicknameText: ; 0x6557
@@ -67,13 +67,13 @@ DisplayNameRaterScreen: ; 655c (1:655c)
cp "@"
jr z, .playerCancelled
ld hl, wPartyMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld e, l
ld d, h
ld hl, wBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
and a
ret
@@ -88,8 +88,8 @@ DisplayNamingScreen: ; 6596 (1:6596)
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
call LoadHpBarAndStatusTilePatterns
call LoadEDTile
callba LoadMonPartySpriteGfx
@@ -158,18 +158,18 @@ DisplayNamingScreen: ; 6596 (1:6596)
.submitNickname
pop de
ld hl, wcf4b
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
call GBPalWhiteOutWithDelay3
call ClearScreen
call ClearSprites
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call GBPalNormal
xor a
- ld [W_SUBANIMTRANSFORM], a
+ ld [wAnimCounter], a
ld hl, wd730
res 6, [hl]
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jp z, LoadTextBoxTilePatterns
jpab LoadHudTilePatterns
@@ -326,11 +326,14 @@ DisplayNamingScreen: ; 6596 (1:6596)
LoadEDTile: ; 675b (1:675b)
ld de, ED_Tile
ld hl, vFont + $700
- ld bc, $1
+ ld bc, (ED_TileEnd - ED_Tile) / $8
+ ; to fix the graphical bug on poor emulators
+ ;lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8
jp CopyVideoDataDouble
ED_Tile: ; 6767 (1:6767)
INCBIN "gfx/ED_tile.1bpp"
+ED_TileEnd:
PrintAlphabet: ; 676f (1:676f)
xor a
diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm
index 42ab553a..f3e1a138 100755
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -29,13 +29,13 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
cp a,SWAP_MONS_PARTY_MENU
jp z,.printMessage
call ErasePartyMenuCursors
- callba SendBlkPacket_PartyMenu
+ callba InitPartyMenuBlkPacket
coord hl, 3, 0
ld de,wPartySpecies
xor a
ld c,a
ld [hPartyMonIndex],a
- ld [wcf2d],a
+ ld [wWhichPartyMenuHPBar],a
.loop
ld a,[de]
cp a,$FF ; reached the terminator?
@@ -96,7 +96,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld a,[hFlags_0xFFF6]
res 0,a
ld [hFlags_0xFFF6],a
- call SetPartyMenuHealthBarColor ; color the HP bar (on SGB)
+ call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
.teachMoveMenu
@@ -150,7 +150,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld l,a
ld de,wcd6d
ld a,BANK(EvosMovesPointerTable)
- ld bc,13
+ ld bc,Mon133_EvosEnd - Mon133_EvosMoves
call FarCopyData
ld hl,wcd6d
ld de,.notAbleToEvolveText
@@ -188,8 +188,8 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
.notAbleToEvolveText
db "NOT ABLE@"
.afterDrawingMonEntries
- ld b,$0A
- call GoPAL_SET
+ ld b, SET_PAL_PARTY_MENU
+ call RunPaletteCommand
.printMessage
ld hl,wd730
ld a,[hl]
@@ -311,15 +311,15 @@ RareCandyText: ; 12ec0 (4:6ec0)
db $06
db "@"
-SetPartyMenuHealthBarColor: ; 12ec7 (4:6ec7)
- ld hl, wcf1f
- ld a, [wcf2d]
+SetPartyMenuHPBarColor: ; 12ec7 (4:6ec7)
+ ld hl, wPartyMenuHPBarColors
+ ld a, [wWhichPartyMenuHPBar]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
call GetHealthBarColor
- ld b, $fc
- call GoPAL_SET
- ld hl, wcf2d
+ ld b, UPDATE_PARTY_MENU_BLK_PACKET
+ call RunPaletteCommand
+ ld hl, wWhichPartyMenuHPBar
inc [hl]
ret
diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm
index ead2c359..a58523e8 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -12,8 +12,8 @@ ShowPokedexMenu: ; 40000 (10:4000)
ld [wd11e],a
ld [hJoy7],a
.setUpGraphics
- ld b,$08
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
callab LoadPokedexTilePatterns
.doPokemonListMenu
ld hl,wTopMenuItemY
@@ -27,7 +27,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
inc hl
ld a,6
ld [hli],a ; max menu item ID
- ld [hl],%00110011 ; menu watched keys (Left, Right, B button, A button)
+ ld [hl],D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
call HandlePokedexListMenu
jr c,.goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex
@@ -41,7 +41,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
pop af
ld [wListScrollOffset],a
call GBPalWhiteOutWithDelay3
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
jp ReloadMapData
.goToSideMenu
call HandlePokedexSideMenu
@@ -88,6 +88,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
inc hl
ld a,3
ld [hli],a ; max menu item ID
+ ;ld a, A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys (A button and B button)
xor a
ld [hli],a ; old menu item ID
@@ -169,14 +170,14 @@ HandlePokedexListMenu: ; 40111 (10:4111)
ld hl,wPokedexSeen
ld b,wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 3
lb bc, 1, 3
call PrintNumber ; print number of seen pokemon
ld hl,wPokedexOwned
ld b,wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld de,wd11e
+ ld de, wNumSetBits
coord hl, 16, 6
lb bc, 1, 3
call PrintNumber ; print number of owned pokemon
@@ -397,14 +398,14 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld hl,wd72c
set 1,[hl]
ld a,$33 ; 3/7 volume
- ld [$ff24],a
+ ld [rNR50],a
call GBPalWhiteOut ; zero all palettes
call ClearScreen
ld a,[wd11e] ; pokemon ID
ld [wcf91],a
push af
- ld b,04
- call GoPAL_SET
+ ld b, SET_PAL_POKEDEX
+ call RunPaletteCommand
pop af
ld [wd11e],a
ld a,[hTilesetType]
@@ -560,13 +561,13 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld [hTilesetType],a
call GBPalWhiteOut
call ClearScreen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns
call GBPalNormal
ld hl,wd72c
res 1,[hl]
ld a,$77 ; max volume
- ld [$ff24],a
+ ld [rNR50],a
ret
HeightWeightText: ; 40448 (10:4448)
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index 2bf932ba..434a1943 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -13,7 +13,7 @@ CeladonPrizeMenu: ; 5271b (14:671b)
xor a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
- ld a,$03
+ ld a,A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys],a
ld a,$03
ld [wMaxMenuItem],a
@@ -78,7 +78,7 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld e,a
inc hl
push hl
- ld hl,W_PRIZE1
+ ld hl,wPrize1
call CopyString
pop hl
ld a,[hli]
@@ -90,34 +90,34 @@ GetPrizeMenuId: ; 5278e (14:678e)
ld a,[wWhichPrizeWindow]
cp a,$02 ;is TM_menu?
jr nz,.putMonName
- ld a,[W_PRIZE1]
+ ld a,[wPrize1]
ld [wd11e],a
call GetItemName
coord hl, 2, 4
call PlaceString
- ld a,[W_PRIZE2]
+ ld a,[wPrize2]
ld [wd11e],a
call GetItemName
coord hl, 2, 6
call PlaceString
- ld a,[W_PRIZE3]
+ ld a,[wPrize3]
ld [wd11e],a
call GetItemName
coord hl, 2, 8
call PlaceString
jr .putNoThanksText
.putMonName
- ld a,[W_PRIZE1]
+ ld a,[wPrize1]
ld [wd11e],a
call GetMonName
coord hl, 2, 4
call PlaceString
- ld a,[W_PRIZE2]
+ ld a,[wPrize2]
ld [wd11e],a
call GetMonName
coord hl, 2, 6
call PlaceString
- ld a,[W_PRIZE3]
+ ld a,[wPrize3]
ld [wd11e],a
call GetMonName
coord hl, 2, 8
@@ -191,7 +191,7 @@ HandlePrizeChoice: ; 528c6 (14:68c6)
ld [wWhichPrize],a
ld d,0
ld e,a
- ld hl,W_PRIZE1
+ ld hl,wPrize1
add hl,de
ld a,[hl]
ld [wd11e],a
@@ -300,7 +300,7 @@ GetPrizeMonLevel: ; 52977 (14:6977)
jr .loop
.matchFound
ld a,[hl]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
ret
INCLUDE "data/prize_mon_levels.asm"
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index f061fbf6..34c21da0 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -57,7 +57,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
inc hl
ld a,b
ld [hli],a ; max menu item ID
- ld a,%00000011 ; A button, B button
+ ld a,A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys
xor a
ld [hl],a
@@ -117,7 +117,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
ld a,[hli]
ld h,[hl]
ld l,a
- ld a,[W_OBTAINEDBADGES] ; badges obtained
+ ld a,[wObtainedBadges] ; badges obtained
jp [hl]
.outOfBattleMovePointers
dw .cut
@@ -160,7 +160,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
.surf
bit 4,a ; does the player have the Soul Badge?
jp z,.newBadgeRequired
- callba CheckForForcedBikeSurf
+ callba IsSurfingAllowed
ld hl,wd728
bit 1,[hl]
res 1,[hl]
@@ -297,7 +297,7 @@ ErasePartyMenuCursors: ; 132ed (4:72ed)
ItemMenuLoop: ; 132fc (4:72fc)
call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
StartMenu_Item: ; 13302 (4:7302)
ld a,[wLinkState]
@@ -354,7 +354,7 @@ StartMenu_Item: ; 13302 (4:7302)
inc hl
inc a ; a = 1
ld [hli],a ; max menu item ID
- ld a,%00000011 ; A button, B button
+ ld a,A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys
xor a
ld [hl],a ; old menu item id
@@ -506,14 +506,14 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
ld [hTilesetType],a
call DrawTrainerInfo
predef DrawBadges ; draw badges
- ld b,$0d
- call GoPAL_SET
+ ld b, SET_PAL_TRAINER_CARD
+ call RunPaletteCommand
call GBPalNormal
call WaitForTextScrollButtonPress ; wait for button press
call GBPalWhiteOut
call LoadFontTilePatterns
call LoadScreenTilesFromBuffer2 ; restore saved screen
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call ReloadMapData
call LoadGBPal
pop af
@@ -601,17 +601,17 @@ DrawTrainerInfo: ; 1349a (4:749a)
ld c,$e3
call PrintBCDNumber
coord hl, 9, 6
- ld de,W_PLAYTIMEHOURS + 1 ; hours
+ ld de,wPlayTimeHours ; hours
lb bc, LEFT_ALIGN | 1, 3
call PrintNumber
ld [hl],$d6 ; colon tile ID
inc hl
- ld de,W_PLAYTIMEMINUTES + 1 ; minutes
+ ld de,wPlayTimeMinutes ; minutes
lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
TrainerInfo_FarCopyData: ; 1357f (4:757f)
- ld a,$0b
+ ld a,BANK(TrainerInfoTextBoxTileGraphics)
jp FarCopyData2
TrainerInfo_NameMoneyTimeText: ; 13584 (4:7584)
@@ -813,36 +813,36 @@ SwitchPartyMon_InitVarOrSwapData: ; 13653 (4:7653)
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonOT
ld a, [wMenuItemToSwap]
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonNicks
ld a, [wCurrentMenuItem]
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonNicks
ld a, [wMenuItemToSwap]
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wMenuItemToSwap]
ld [wSwappedMenuItem], a
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index d8a504bb..d07cc026 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -71,7 +71,7 @@ StatusScreen: ; 12953 (4:6953)
; mon is in a box or daycare
ld a, [wLoadedMonBoxLevel]
ld [wLoadedMonLevel], a
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld hl, wLoadedMonHPExp - 1
ld de, wLoadedMonStats
ld b, $1
@@ -80,7 +80,7 @@ StatusScreen: ; 12953 (4:6953)
ld hl, wd72c
set 1, [hl]
ld a, $33
- ld [$ff24], a ; Reduce the volume
+ ld [rNR50], a ; Reduce the volume
call GBPalWhiteOutWithDelay3
call ClearScreen
call UpdateSprites
@@ -99,7 +99,7 @@ StatusScreen: ; 12953 (4:6953)
call CopyVideoDataDouble ; ─┘
ld de, PTile
ld hl, vChars2 + $720
- lb bc, BANK(PTile), $01
+ lb bc, BANK(PTile), (PTileEnd - PTile) / $8
call CopyVideoDataDouble ; P (for PP), inline
ld a, [hTilesetType]
push af
@@ -121,10 +121,10 @@ StatusScreen: ; 12953 (4:6953)
call PlaceString ; "TYPE1/"
coord hl, 11, 3
predef DrawHP
- ld hl, wcf25
+ ld hl, wStatusScreenHPBarColor
call GetHealthBarColor
- ld b, $3
- call GoPAL_SET ; SGB palette
+ ld b, SET_PAL_STATUS_SCREEN
+ call RunPaletteCommand
coord hl, 16, 6
ld de, wLoadedMonStatus
call PrintStatusCondition
@@ -138,7 +138,7 @@ StatusScreen: ; 12953 (4:6953)
call PlaceString ; "STATUS/"
coord hl, 14, 2
call PrintLevel ; Pokémon level
- ld a, [W_MONHDEXNUM]
+ ld a, [wMonHIndex]
ld [wd11e], a
ld [wd0b5], a
predef IndexToPokedex
@@ -196,13 +196,13 @@ OTPointers: ; 12a95 (4:6a95)
dw wPartyMonOT
dw wEnemyMonOT
dw wBoxMonOT
- dw W_DAYCAREMONOT
+ dw wDayCareMonOT
NamePointers2: ; 12a9d (4:6a9d)
dw wPartyMonNicks
dw wEnemyMonNicks
dw wBoxMonNicks
- dw W_DAYCAREMONNAME
+ dw wDayCareMonName
Type1Text: ; 12aa5 (4:6aa5)
db "TYPE1/", $4e
@@ -242,6 +242,7 @@ DrawLineBox: ; 0x12ac7
PTile: ; 12adc (4:6adc) ; This is a single 1bpp "P" tile
INCBIN "gfx/p_tile.1bpp"
+PTileEnd:
PrintStatsBox: ; 12ae4 (4:6ae4)
ld a, d
@@ -371,7 +372,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call PrintNumber
ld a, "/"
ld [hli], a
- ld de, wd11e
+ ld de, wMaxPP
lb bc, 1, 2
call PrintNumber
pop hl
@@ -416,7 +417,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call StatusScreen_ClearName
coord hl, 9, 1
call StatusScreen_ClearName
- ld a, [W_MONHDEXNUM]
+ ld a, [wMonHIndex]
ld [wd11e], a
call GetMonName
coord hl, 9, 1
@@ -430,7 +431,7 @@ StatusScreen2: ; 12b57 (4:6b57)
ld hl, wd72c
res 1, [hl]
ld a, $77
- ld [$ff24], a
+ ld [rNR50], a
call GBPalWhiteOut
jp ClearScreen
diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm
index e7f9d2df..185151cb 100755
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -5,15 +5,15 @@ AnimatePartyMon_ForceSpeed1: ; 716f7 (1c:56f7)
inc a
jr GetAnimationSpeed
-; wcf1f contains the party mon's health bar colors
+; wPartyMenuHPBarColors contains the party mon's health bar colors
; 0: green
; 1: yellow
; 2: red
AnimatePartyMon: ; 716ff (1c:56ff)
- ld hl, wcf1f
+ ld hl, wPartyMenuHPBarColors
ld a, [wCurrentMenuItem]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
ld a, [hl]
@@ -42,7 +42,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
jp DelayFrame
.resetSprites
push bc
- ld hl, wcc5b
+ ld hl, wMonPartySpritesSavedOAM
ld de, wOAMBuffer
ld bc, $60
call CopyData
@@ -86,7 +86,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
; that each frame lasts for green HP, yellow HP, and red HP in order.
; On the naming screen, the yellow HP speed is always used.
PartyMonSpeeds: ; 71769 (1c:5769)
- db $05,$10,$20
+ db 5, 16, 32
LoadMonPartySpriteGfx: ; 7176c (1c:576c)
; Load mon party sprite tile patterns into VRAM during V-blank.
@@ -372,7 +372,7 @@ UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)
WriteMonPartySpriteOAM: ; 718c3 (1c:58c3)
; Write the OAM blocks for the first animation frame into the OAM buffer and
-; make a copy at wcc5b.
+; make a copy at wMonPartySpritesSavedOAM.
push af
ld c, $10
ld h, wOAMBuffer / $100
@@ -392,7 +392,7 @@ WriteMonPartySpriteOAM: ; 718c3 (1c:58c3)
; we can flip back to it from the second frame by copying it back.
.makeCopy
ld hl, wOAMBuffer
- ld de, wcc5b
+ ld de, wMonPartySpritesSavedOAM
ld bc, $60
jp CopyData
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index 98499d7f..c4d35639 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -1,7 +1,7 @@
SetDefaultNames: ; 60ca (1:60ca)
ld a, [wLetterPrintingDelayFlags]
push af
- ld a, [W_OPTIONS]
+ ld a, [wOptions]
push af
ld a, [wd732]
push af
@@ -16,7 +16,7 @@ SetDefaultNames: ; 60ca (1:60ca)
pop af
ld [wd732], a
pop af
- ld [W_OPTIONS], a
+ ld [wOptions], a
pop af
ld [wLetterPrintingDelayFlags], a
ld a, [wOptionsInitialized]
@@ -24,11 +24,11 @@ SetDefaultNames: ; 60ca (1:60ca)
call z, InitOptions
ld hl, NintenText
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, SonyText
- ld de, W_RIVALNAME
- ld bc, 11
+ ld de, wRivalName
+ ld bc, NAME_LENGTH
jp CopyData
OakSpeech: ; 6115 (1:6115)
@@ -48,7 +48,7 @@ OakSpeech: ; 6115 (1:6115)
ld a,1
ld [wItemQuantity],a
call AddItemToInventory ; give one potion
- ld a,[W_ANIMATIONID]
+ ld a,[wDefaultMap]
ld [wDestinationMap],a
call SpecialWarpIn
xor a
@@ -129,12 +129,12 @@ OakSpeech: ; 6115 (1:6115)
ld a,[H_LOADEDROMBANK]
push af
ld a, BANK(Music_PalletTown)
- ld [wc0ef],a
- ld [wc0f0],a
- ld a,$A
- ld [wMusicHeaderPointer],a
+ ld [wAudioROMBank],a
+ ld [wAudioSavedROMBank],a
+ ld a, 10
+ ld [wAudioFadeOutControl],a
ld a,$FF
- ld [wc0ee],a
+ ld [wNewSoundID],a
call PlaySound ; stop music
pop af
ld [H_LOADEDROMBANK],a
@@ -215,8 +215,8 @@ IntroDisplayPicCenteredOrUpperRight: ; 62a4 (1:62a4)
push bc
ld a,b
call UncompressSpriteFromDE
- ld hl,S_SPRITEBUFFER1
- ld de,S_SPRITEBUFFER0
+ ld hl,sSpriteBuffer1
+ ld de,sSpriteBuffer0
ld bc,$310
call CopyData
ld de,vFrontPic
diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm
index 50e3708c..9b5622b8 100755
--- a/engine/oak_speech2.asm
+++ b/engine/oak_speech2.asm
@@ -40,11 +40,11 @@ ChooseRivalName: ; 69a4 (1:69a4)
jr z, .customName
ld hl, DefaultNamesRivalList
call GetDefaultName
- ld de, W_RIVALNAME
+ ld de, wRivalName
call OakSpeechSlidePicLeft
jr .done
.customName
- ld hl, W_RIVALNAME
+ ld hl, wRivalName
ld a, NAME_RIVAL_SCREEN
ld [wNamingScreenType], a
call DisplayNamingScreen
@@ -73,7 +73,7 @@ OakSpeechSlidePicLeft: ; 69ec (1:69ec)
call DelayFrames
pop de
ld hl, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
call Delay3
coord hl, 12, 4
@@ -177,7 +177,7 @@ DisplayIntroNameTextBox: ; 6a6c (1:6a6c)
ld [wLastMenuItem], a
inc a
ld [wTopMenuItemX], a
- ld [wMenuWatchedKeys], a
+ ld [wMenuWatchedKeys], a ; A_BUTTON
inc a
ld [wTopMenuItemY], a
inc a
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index cc9fe3a7..49d99575 100755
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -1,6 +1,6 @@
PrintCardKeyText: ; 52673 (14:6673)
ld hl, SilphCoMapList
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, a
.silphCoMapListLoop
ld a, [hli]
@@ -15,7 +15,7 @@ PrintCardKeyText: ; 52673 (14:6673)
cp $24
jr z, .cardKeyDoorInFrontOfPlayer
ld b, a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp SILPH_CO_11F
ret nz
ld a, b
@@ -39,7 +39,7 @@ PrintCardKeyText: ; 52673 (14:6673)
ld a, e
ld c, a
ld [wCardKeyDoorX], a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp SILPH_CO_11F
jr nz, .notSilphCo11F
ld a, $3
@@ -49,7 +49,7 @@ PrintCardKeyText: ; 52673 (14:6673)
.replaceCardKeyDoorTileBlock
ld [wNewTileBlockID], a
predef ReplaceTileBlock
- ld hl, wd126
+ ld hl, wCurrentMapScriptFlags
set 5, [hl]
ld a, SFX_GO_INSIDE
jp PlaySound
@@ -84,9 +84,9 @@ CardKeyFailText: ; 526f8 (14:66f8)
; d = Y
; e = X
GetCoordsInFrontOfPlayer: ; 526fd (14:66fd)
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
ld d, a
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
ld e, a
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
and a
diff --git a/engine/overworld/cinnabar_lab.asm b/engine/overworld/cinnabar_lab.asm
index 5337255c..f7c5e326 100755
--- a/engine/overworld/cinnabar_lab.asm
+++ b/engine/overworld/cinnabar_lab.asm
@@ -5,14 +5,14 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
ld [wCurrentMenuItem], a
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
- ld a, [wcd37]
+ ld a, [wFilteredBagItemsCount]
dec a
ld [wMaxMenuItem], a
ld a, 2
ld [wTopMenuItemY], a
ld a, 1
ld [wTopMenuItemX], a
- ld a, [wcd37]
+ ld a, [wFilteredBagItemsCount]
dec a
ld bc, 2
ld hl, 3
@@ -29,9 +29,9 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
call HandleMenuInput
bit 1, a ; pressed B?
jr nz, .cancelledGivingFossil
- ld hl, wcc5b
+ ld hl, wFilteredBagItems
ld a, [wCurrentMenuItem]
- ld d, $0
+ ld d, 0
ld e, a
add hl, de
ld a, [hl]
@@ -48,9 +48,9 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
.choseDomeFossil
ld b, KABUTO
.fossilSelected
- ld [W_FOSSILITEM], a
+ ld [wFossilItem], a
ld a, b
- ld [W_FOSSILMON], a
+ ld [wFossilMon], a
call LoadFossilItemAndMonName
ld hl, LabFossil_610ae
call PrintText
@@ -60,7 +60,7 @@ GiveFossilToCinnabarLab: ; 61006 (18:5006)
jr nz, .cancelledGivingFossil
ld hl, LabFossil_610b3
call PrintText
- ld a, [W_FOSSILITEM]
+ ld a, [wFossilItem]
ld [hItemToRemoveID], a
callba RemoveItemByID
ld hl, LabFossil_610b8
@@ -90,9 +90,9 @@ LabFossil_610bd: ; 610bd (18:50bd)
PrintFossilsInBag: ; 610c2 (18:50c2)
; Prints each fossil in the player's bag on a separate line in the menu.
- ld hl, wcc5b
+ ld hl, wFilteredBagItems
xor a
- ld [hFossilCounter], a
+ ld [hItemCounter], a
.loop
ld a, [hli]
cp $ff
@@ -101,23 +101,23 @@ PrintFossilsInBag: ; 610c2 (18:50c2)
ld [wd11e], a
call GetItemName
coord hl, 2, 2
- ld a, [hFossilCounter]
+ ld a, [hItemCounter]
ld bc, SCREEN_WIDTH * 2
call AddNTimes
ld de, wcd6d
call PlaceString
- ld hl, hFossilCounter
+ ld hl, hItemCounter
inc [hl]
pop hl
jr .loop
; loads the names of the fossil item and the resulting mon
LoadFossilItemAndMonName: ; 610eb (18:50eb)
- ld a, [W_FOSSILMON]
+ ld a, [wFossilMon]
ld [wd11e], a
call GetMonName
call CopyStringToCF4B
- ld a, [W_FOSSILITEM]
+ ld a, [wFossilItem]
ld [wd11e], a
call GetItemName
ret
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index 30aedbc1..8a0513b2 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -1,7 +1,7 @@
UsedCut: ; ef54 (3:6f54)
xor a
ld [wActionResultOrTookBattleTurn], a ; initialise to failure value
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
and a ; OVERWORLD
jr z, .overworld
cp GYM
@@ -177,7 +177,7 @@ ReplaceTreeTileBlock: ; f09f (3:709f)
; 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]
+ ld a, [wCurMapWidth]
add 6
ld c, a
ld b, 0
@@ -195,22 +195,22 @@ ReplaceTreeTileBlock: ; f09f (3:709f)
cp SPRITE_FACING_LEFT
jr z, .left
; right
- ld a, [W_XBLOCKCOORD]
+ ld a, [wXBlockCoord]
and a
jr z, .centerTileBlock
jr .rightOfCenter
.down
- ld a, [W_YBLOCKCOORD]
+ ld a, [wYBlockCoord]
and a
jr z, .centerTileBlock
jr .belowCenter
.up
- ld a, [W_YBLOCKCOORD]
+ ld a, [wYBlockCoord]
and a
jr z, .aboveCenter
jr .centerTileBlock
.left
- ld a, [W_XBLOCKCOORD]
+ ld a, [wXBlockCoord]
and a
jr z, .leftOfCenter
jr .centerTileBlock
diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm
index 641c021f..6b0c0464 100755
--- a/engine/overworld/doors.asm
+++ b/engine/overworld/doors.asm
@@ -2,7 +2,7 @@
IsPlayerStandingOnDoorTile: ; 1a609 (6:6609)
push de
ld hl, DoorTileIDPointers
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
ld de, $3
call IsInArray
pop de
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index eb62fee7..05a9cc4e 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -33,7 +33,7 @@ ShakeElevator: ; 7bf15 (1e:7f15)
ld a, SFX_SAFARI_ZONE_PA
call PlayMusic
.musicLoop
- ld a, [wc02a]
+ ld a, [wChannelSoundIDs + CH4]
cp $b9
jr z, .musicLoop
call UpdateSprites
diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm
index ebd441aa..f8665dd6 100755
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -9,7 +9,7 @@ EmotionBubble: ; 17c47 (5:7c47)
inc hl
ld d, [hl]
ld hl, vChars1 + $780
- lb bc, BANK(EmotionBubblesPointerTable), $04
+ lb bc, BANK(EmotionBubbles), $04
call CopyVideoData
ld a, [wUpdateSpritesEnabled]
push af
diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm
index d3513b0d..bf7130cb 100755
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -1,7 +1,7 @@
AnimateHealingMachine: ; 70433 (1c:4433)
ld de, PokeCenterFlashingMonitorAndHealBall
ld hl, vChars0 + $7c0
- lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), $03
+ lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), $03 ; loads one too many tiles
call CopyVideoData
ld hl, wUpdateSpritesEnabled
ld a, [hl]
@@ -15,44 +15,44 @@ AnimateHealingMachine: ; 70433 (1c:4433)
ld hl, wOAMBuffer + $84
ld de, PokeCenterOAMData
call CopyHealingMachineOAM
- ld a, $4
- ld [wMusicHeaderPointer], a
+ ld a, 4
+ ld [wAudioFadeOutControl], a
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
-.asm_70464
- ld a, [wMusicHeaderPointer]
- and a
- jr nz, .asm_70464
+.waitLoop
+ ld a, [wAudioFadeOutControl]
+ and a ; is fade-out finished?
+ jr nz, .waitLoop ; if not, check again
ld a, [wPartyCount]
ld b, a
-.asm_7046e
+.partyLoop
call CopyHealingMachineOAM
ld a, SFX_HEALING_MACHINE
call PlaySound
ld c, 30
call DelayFrames
dec b
- jr nz, .asm_7046e
- ld a, [wc0ef]
+ jr nz, .partyLoop
+ ld a, [wAudioROMBank]
cp BANK(Audio3_UpdateMusic)
- ld [wc0f0], a
- jr nz, .asm_70495
+ ld [wAudioSavedROMBank], a
+ jr nz, .next
ld a, $ff
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, BANK(Music_PkmnHealed)
- ld [wc0ef], a
-.asm_70495
+ ld [wAudioROMBank], a
+.next
ld a, MUSIC_PKMN_HEALED
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld d, $28
call FlashSprite8Times
-.asm_704a2
- ld a, [wc026]
- cp MUSIC_PKMN_HEALED
- jr z, .asm_704a2
+.waitLoop2
+ ld a, [wChannelSoundIDs]
+ cp MUSIC_PKMN_HEALED ; is the healed music still playing?
+ jr z, .waitLoop2 ; if so, check gain
ld c, 32
call DelayFrames
pop af
diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm
index 1203dd2a..f7f81070 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -51,7 +51,7 @@ HiddenItemBagFullText: ; 76794 (1d:6794)
HiddenCoins: ; 76799 (1d:6799)
ld b, COIN_CASE
- predef IsItemInBag_
+ predef GetQuantityOfItemInBag
ld a, b
and a
ret z
@@ -135,7 +135,7 @@ FindHiddenItemOrCoinsIndex: ; 76857 (1d:6857)
ld d, a
ld a, [wHiddenObjectX]
ld e, a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, a
ld c, -1
.loop
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index cabfc093..1fc20e5c 100755
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -29,7 +29,7 @@ CheckForHiddenObject: ; 469a0 (11:69a0)
ld b, a
cp $ff
jr z, .noMatch
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp b
jr z, .foundMatchingMap
inc de
@@ -95,30 +95,30 @@ CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01)
cp SPRITE_FACING_RIGHT
jr z, .facingRight
; facing down
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
inc a
jr .upDownCommon
.facingUp
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
dec a
.upDownCommon
cp b
jr nz, .didNotMatch
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
cp c
jr nz, .didNotMatch
jr .matched
.facingLeft
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
dec a
jr .leftRightCommon
.facingRight
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
inc a
.leftRightCommon
cp c
jr nz, .didNotMatch
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
cp b
jr nz, .didNotMatch
.matched
diff --git a/engine/overworld/is_player_just_outside_map.asm b/engine/overworld/is_player_just_outside_map.asm
index 24e434b3..e9ba204a 100644
--- a/engine/overworld/is_player_just_outside_map.asm
+++ b/engine/overworld/is_player_just_outside_map.asm
@@ -1,13 +1,13 @@
; returns whether the player is one tile outside the map in Z
IsPlayerJustOutsideMap: ; 128d8 (4:68d8)
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
ld b, a
- ld a, [W_CURMAPHEIGHT]
+ ld a, [wCurMapHeight]
call .compareCoordWithMapDimension
ret z
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
ld b, a
- ld a, [W_CURMAPWIDTH]
+ ld a, [wCurMapWidth]
.compareCoordWithMapDimension
add a
cp b
diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm
index 6fbe823d..63eecef9 100644
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -3,7 +3,7 @@ PickUpItem:
ld a, [hSpriteIndexOrTextID]
ld b, a
- ld hl, W_MISSABLEOBJECTLIST
+ ld hl, wMissableObjectList
.missableObjectsListLoop
ld a, [hli]
cp $ff
@@ -17,7 +17,7 @@ PickUpItem:
ld a, [hl]
ld [$ffdb], a
- ld hl, W_MAPSPRITEEXTRADATA
+ ld hl, wMapSpriteExtraData
ld a, [hSpriteIndexOrTextID]
dec a
add a
diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm
index 5a3bfbe0..b04f6332 100755
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -2,7 +2,7 @@ HandleLedges: ; 1a672 (6:6672)
ld a, [wd736]
bit 6, a ; already jumping down ledge
ret nz
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
and a ; OVERWORLD
ret nz
predef GetTileAndCoordsInFrontOfPlayer
@@ -69,7 +69,7 @@ LedgeTiles: ; 1a6cf (6:66cf)
LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
ld hl, vChars1 + $7f0
ld de, LedgeHoppingShadow
- lb bc, BANK(LedgeHoppingShadow), $01
+ lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
call CopyVideoDataDouble
ld a, $9
lb bc, $54, $48 ; b, c = y, x coordinates of shadow
@@ -79,6 +79,7 @@ LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
LedgeHoppingShadow: ; 1a708 (6:6708)
INCBIN "gfx/ledge_hopping_shadow.1bpp"
+LedgeHoppingShadowEnd:
LedgeHoppingShadowOAM: ; 1a710 (6:6710)
db $FF,$10,$FF,$20
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm
index 33411dfc..bdd3320b 100755
--- a/engine/overworld/map_sprites.asm
+++ b/engine/overworld/map_sprites.asm
@@ -30,12 +30,12 @@ InitMapSprites: ; 1785b (5:785b)
; InitOutsideMapSprites.
; Loads tile pattern data for sprites into VRAM.
LoadMapSpriteTilePatterns: ; 17871 (5:7871)
- ld a,[W_NUMSPRITES]
+ ld a,[wNumSprites]
and a ; are there any sprites?
jr nz,.spritesExist
ret
.spritesExist
- ld c,a ; c = [W_NUMSPRITES]
+ ld c,a ; c = [wNumSprites]
ld b,$10 ; number of sprite slots
ld hl,wSpriteStateData2 + $0d
xor a
@@ -251,7 +251,7 @@ ReadSpriteSheetData: ; 17971 (5:7971)
; Loads sprite set for outside maps (cities and routes) and sets VRAM slots.
; sets carry if the map is a city or route, unsets carry if not
InitOutsideMapSprites: ; 1797b (5:797b)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp a,REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)?
ret nc ; if not, return
ld hl,MapSpriteSets
@@ -267,12 +267,12 @@ InitOutsideMapSprites: ; 1797b (5:797b)
ld a,[wFontLoaded]
bit 0,a ; reloading upper half of tile patterns after displaying text?
jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set
- ld a,[W_SPRITESETID]
+ ld a,[wSpriteSetID]
cp b ; has the sprite set ID changed?
jr z,.skipLoadingSpriteSet ; if not, don't load it again
.loadSpriteSet
ld a,b
- ld [W_SPRITESETID],a
+ ld [wSpriteSetID],a
dec a
ld b,a
sla a
@@ -291,7 +291,7 @@ InitOutsideMapSprites: ; 1797b (5:797b)
ld hl,wSpriteStateData2 + $0d
ld a,SPRITE_RED
ld [hl],a
- ld bc,W_SPRITESET
+ ld bc,wSpriteSet
; Load the sprite set into RAM.
; This loop also fills $C2XD (sprite picture ID) where X is from $0 to $A
; with picture ID's. This is done so that LoadMapSpriteTilePatterns will
@@ -317,13 +317,13 @@ InitOutsideMapSprites: ; 1797b (5:797b)
ld [hl],a ; $C2XD (sprite picture ID)
dec b
jr nz,.zeroRemainingSlotsLoop
- ld a,[W_NUMSPRITES]
+ ld a,[wNumSprites]
push af ; save number of sprites
ld a,11 ; 11 sprites in sprite set
- ld [W_NUMSPRITES],a
+ ld [wNumSprites],a
call LoadMapSpriteTilePatterns
pop af
- ld [W_NUMSPRITES],a ; restore number of sprites
+ ld [wNumSprites],a ; restore number of sprites
ld hl,wSpriteStateData2 + $1e
ld b,$0f
; The VRAM tile pattern slots that LoadMapSpriteTilePatterns set are in the
@@ -352,7 +352,7 @@ InitOutsideMapSprites: ; 1797b (5:797b)
and a ; is the sprite slot used?
jr z,.skipGettingPictureIndex ; if the sprite slot is not used
ld b,a ; b = picture ID
- ld de,W_SPRITESET
+ ld de,wSpriteSet
; Loop to find the index of the sprite's picture ID within the sprite set.
.getPictureIndexLoop
inc c
@@ -399,10 +399,10 @@ GetSplitMapSpriteSetID: ; 17a1a (5:7a1a)
ld b,a
jr z,.eastWestDivide
.northSouthDivide
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
jr .compareCoord
.eastWestDivide
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
.compareCoord
cp b
jr c,.loadSpriteSetID
@@ -415,7 +415,7 @@ GetSplitMapSpriteSetID: ; 17a1a (5:7a1a)
; Route 20 is a special case because the two map sections have a more complex
; shape instead of the map simply being split horizontally or vertically.
.route20
- ld hl,W_XCOORD
+ ld hl,wXCoord
ld a,[hl]
cp a,$2b
ld a,$01
@@ -430,7 +430,7 @@ GetSplitMapSpriteSetID: ; 17a1a (5:7a1a)
jr nc,.next
ld b,$0d
.next
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
cp b
ld a,$0a
ret c
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index be10fd69..c89406d1 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -89,7 +89,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
; bit set by later logic.
ld a, [hTilePlayerStandingOn]
ld c, a
- ld a, [W_GRASSTILE]
+ ld a, [wGrassTile]
cp c
ld a, $0
jr nz, .next2
@@ -114,7 +114,7 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
swap a
dec a
add a
- ld hl, W_MAPSPRITEDATA
+ ld hl, wMapSpriteData
add l
ld l, a
ld a, [hl] ; read movement byte 2
@@ -133,8 +133,8 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
ld l, a
inc l
ld a, [hl] ; c1x1
- bit 7, a
- jp nz, InitializeSpriteFacingDirection ; c1x1 >= $80
+ bit 7, a ; is the face player flag set?
+ jp nz, MakeNPCFacePlayer
ld b, a
ld a, [wFontLoaded]
bit 0, a
@@ -400,10 +400,15 @@ notYetMoving: ; 5073 (1:5073)
ld [hl], $0 ; c1x8 = 0 (walk animation frame)
jp UpdateSpriteImage
-InitializeSpriteFacingDirection: ; 507f (1:507f)
+MakeNPCFacePlayer: ; 507f (1:507f)
+; Make an NPC face the player if the player has spoken to him or her.
+
+; Check if the behaviour of the NPC facing the player when spoken to is
+; disabled. This is only done when rubbing the S.S. Anne captain's back.
ld a, [wd72d]
bit 5, a
jr nz, notYetMoving
+
res 7, [hl]
ld a, [wPlayerDirection]
bit PLAYER_DIR_BIT_UP, a
@@ -448,7 +453,7 @@ InitializeSpriteScreenPosition: ; 50bd (1:50bd)
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
ld b, a
ld a, [hl] ; c2x4 (Y position + 4)
sub b ; relative to player position
@@ -457,7 +462,7 @@ InitializeSpriteScreenPosition: ; 50bd (1:50bd)
dec h
ld [hli], a ; c1x4 (screen Y position)
inc h
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
ld b, a
ld a, [hli] ; c2x6 (X position + 4)
sub b ; relative to player position
@@ -483,7 +488,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
add $4
ld l, a
ld b, [hl] ; c2x4: Y pos (+4)
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
cp b
jr z, .skipYVisibilityTest
jr nc, .spriteInvisible ; above screen region
@@ -493,7 +498,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
.skipYVisibilityTest
inc l
ld b, [hl] ; c2x5: X pos (+4)
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
cp b
jr z, .skipXVisibilityTest
jr nc, .spriteInvisible ; left of screen region
@@ -537,7 +542,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
ld a, [H_CURRENTSPRITEOFFSET]
add $7
ld l, a
- ld a, [W_GRASSTILE]
+ ld a, [wGrassTile]
cp c
ld a, $0
jr nz, .notInGrass
@@ -585,9 +590,9 @@ CanWalkOntoTile: ; 516e (1:516e)
and a
ret
.notScripted
- ld a, [W_TILESETCOLLISIONPTR]
+ ld a, [wTileSetCollisionPtr]
ld l, a
- ld a, [W_TILESETCOLLISIONPTR+1]
+ ld a, [wTileSetCollisionPtr+1]
ld h, a
.tilePassableLoop
ld a, [hli]
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 0c01e38c..719c8835 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -52,7 +52,7 @@ PalletMovementScriptPointerTable: ; 1a442 (6:6442)
dw PalletMovementScript_Done
PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
sub $a
ld [wNumStepsToTake], a
jr z, .playerOnLeftTile
@@ -79,7 +79,7 @@ PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
.done
- ld hl, W_FLAGS_D733
+ ld hl, wFlags_D733
set 1, [hl]
ld a, $fc
ld [wJoyIgnore], a
@@ -163,10 +163,10 @@ PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
@@ -219,10 +219,10 @@ PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
ld a, BANK(Music_MuseumGuy)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
ld a, MUSIC_MUSEUM_GUY
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
ld a, [wSpriteIndex]
swap a
@@ -267,7 +267,7 @@ RLEList_PewterGymGuy: ; 1a5da (6:65da)
db $FF
FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp POKEMONTOWER_7
ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
ld hl, RivalIDs
@@ -286,7 +286,7 @@ FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
jp SetSpriteMovementBytesToFF
RivalIDs: ; 1a605 (6:6605)
- db SONY1 + $c8
- db SONY2 + $c8
- db SONY3 + $c8
+ db OPP_SONY1
+ db OPP_SONY2
+ db OPP_SONY3
db $ff
diff --git a/engine/overworld/oaks_aide.asm b/engine/overworld/oaks_aide.asm
index 00f6ea82..8ac456d2 100755
--- a/engine/overworld/oaks_aide.asm
+++ b/engine/overworld/oaks_aide.asm
@@ -4,45 +4,45 @@ OaksAideScript: ; 0x59035
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
- jr nz, .asm_59086
+ jr nz, .choseNo
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e]
- ld [$ffdd], a
+ ld a, [wNumSetBits]
+ ld [hOaksAideNumMonsOwned], a
ld b, a
- ld a, [$ffdb]
+ ld a, [hOaksAideRequirement]
cp b
- jr z, .asm_59059
- jr nc, .asm_5907c
-.asm_59059
+ jr z, .giveItem
+ jr nc, .notEnoughOwnedMons
+.giveItem
ld hl, OaksAideHereYouGoText
call PrintText
- ld a, [$ffdc]
+ ld a, [hOaksAideRewardItem]
ld b, a
ld c, 1
call GiveItem
- jr nc, .BagFull
+ jr nc, .bagFull
ld hl, OaksAideGotItemText
call PrintText
ld a, $1
- jr .asm_5908e
-.BagFull
+ jr .done
+.bagFull
ld hl, OaksAideNoRoomText
call PrintText
xor a
- jr .asm_5908e
-.asm_5907c
+ jr .done
+.notEnoughOwnedMons
ld hl, OaksAideUhOhText
call PrintText
ld a, $80
- jr .asm_5908e
-.asm_59086
+ jr .done
+.choseNo
ld hl, OaksAideComeBackText
call PrintText
ld a, $ff
-.asm_5908e
- ld [$ffdb], a
+.done
+ ld [hOaksAideResult], a
ret
OaksAideHiText: ; 59091 (16:5091)
diff --git a/engine/overworld/pewter_guys.asm b/engine/overworld/pewter_guys.asm
index 4ac60e00..543dac91 100755
--- a/engine/overworld/pewter_guys.asm
+++ b/engine/overworld/pewter_guys.asm
@@ -17,9 +17,9 @@ PewterGuys: ; 37ca1 (d:7ca1)
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [W_YCOORD]
+ ld a, [wYCoord]
ld b, a
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
ld c, a
.findMatchingCoordsLoop
ld a, [hli]
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index 74762b00..de36eeaf 100755
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -5,7 +5,7 @@ EnterMapAnim: ; 70510 (1c:4510)
call Delay3
push hl
call GBFadeInFromWhite
- ld hl, W_FLAGS_D733
+ ld hl, wFlags_D733
bit 7, [hl] ; used fly out of battle?
res 7, [hl]
jr nz, .flyAnimation
@@ -350,7 +350,7 @@ GetPlayerTeleportAnimFrameDelay: ; 7077f (1c:477f)
IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
ld b, 0
ld hl, .warpPadAndHoleData
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
ld c, a
.loop
ld a, [hli]
diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm
index 5b2e4cbb..f302d994 100755
--- a/engine/overworld/pokecenter.asm
+++ b/engine/overworld/pokecenter.asm
@@ -24,12 +24,12 @@ DisplayPokemonCenterDialogue_: ; 6fe6 (1:6fe6)
predef HealParty
callba AnimateHealingMachine ; do the healing machine animation
xor a
- ld [wMusicHeaderPointer], a
- ld a, [wc0f0]
- ld [wc0ef], a
- ld a, [wd35b]
- ld [wcfca], a
- ld [wc0ee], a
+ ld [wAudioFadeOutControl], a
+ ld a, [wAudioSavedROMBank]
+ ld [wAudioROMBank], a
+ ld a, [wMapMusicSoundID]
+ ld [wLastMusicSoundID], a
+ ld [wNewSoundID], a
call PlaySound
ld hl, PokemonFightingFitText
call PrintText
diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm
index 1dccd026..e631bbfa 100755
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -85,8 +85,9 @@ LoadSmokeTileFourTimes: ; 79fc0 (1e:5fc0)
LoadSmokeTile: ; 79fd4 (1e:5fd4)
ld de, SSAnneSmokePuffTile
- lb bc, BANK(SSAnneSmokePuffTile), $01
+ lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / $10
jp CopyVideoData
SSAnneSmokePuffTile: ; 79fdd (1e:5fdd)
INCBIN "gfx/ss_anne_smoke_puff.2bpp"
+SSAnneSmokePuffTileEnd:
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index 7d2ec0dd..66ae20ce 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -291,7 +291,7 @@ CheckSpriteCanSeePlayer: ; 569af (15:69af)
; tests if the player is in front of the sprite (rather than behind it)
CheckPlayerIsInFrontOfSprite: ; 569e3 (15:69e3)
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp POWER_PLANT
jp z, .engage ; bypass this for power plant to get voltorb fake items to work
ld a, [wTrainerSpriteOffset]
diff --git a/engine/palettes.asm b/engine/palettes.asm
index a325e0a3..94466533 100755
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -1,49 +1,49 @@
-Func_71ddf: ; 71ddf (1c:5ddf)
+_RunPaletteCommand: ; 71ddf (1c:5ddf)
call GetPredefRegisters
ld a, b
cp $ff
- jr nz, .asm_71dea
- ld a, [wcf1c]
-.asm_71dea
- cp $fc
- jp z, Func_71fc2
+ jr nz, .next
+ ld a, [wDefaultPaletteCommand] ; use default command if command ID is $ff
+.next
+ cp UPDATE_PARTY_MENU_BLK_PACKET
+ jp z, UpdatePartyMenuBlkPacket
ld l, a
- ld h, $0
+ ld h, 0
add hl, hl
- ld de, PointerTable_71f73
+ ld de, SetPalFunctions
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, Func_72156
+ ld de, SendSGBPackets
push de
jp [hl]
-SendPalPacket_Black: ; 71dff (1c:5dff)
+SetPal_BattleBlack: ; 71dff (1c:5dff)
ld hl, PalPacket_Black
ld de, BlkPacket_Battle
ret
; uses PalPacket_Empty to build a packet based on mon IDs and health color
-BuildBattlePalPacket: ; 71e06 (1c:5e06)
+SetPal_Battle: ; 71e06 (1c:5e06)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
- ld a, [W_PLAYERBATTSTATUS3]
+ ld a, [wPlayerBattleStatus3]
ld hl, wBattleMonSpecies
call DeterminePaletteID
ld b, a
- ld a, [W_ENEMYBATTSTATUS3]
+ ld a, [wEnemyBattleStatus3]
ld hl, wEnemyMonSpecies2
call DeterminePaletteID
ld c, a
- ld hl, wcf2e
- ld a, [wcf1d]
+ ld hl, wPalPacket + 1
+ ld a, [wPlayerHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
- ld a, [wcf1e]
+ ld a, [wEnemyHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
@@ -52,21 +52,21 @@ BuildBattlePalPacket: ; 71e06 (1c:5e06)
inc hl
ld a, c
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_Battle
- ld a, $1
- ld [wcf1c], a
+ ld a, SET_PAL_BATTLE
+ ld [wDefaultPaletteCommand], a
ret
-SendPalPacket_TownMap: ; 71e48 (1c:5e48)
+SetPal_TownMap: ; 71e48 (1c:5e48)
ld hl, PalPacket_TownMap
ld de, BlkPacket_WholeScreen
ret
; uses PalPacket_Empty to build a packet based the mon ID
-BuildStatusScreenPalPacket: ; 71e4f (1c:5e4f)
+SetPal_StatusScreen: ; 71e4f (1c:5e4f)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
@@ -76,75 +76,75 @@ BuildStatusScreenPalPacket: ; 71e4f (1c:5e4f)
.pokemon
call DeterminePaletteIDOutOfBattle
push af
- ld hl, wcf2e
- ld a, [wcf25]
+ ld hl, wPalPacket + 1
+ ld a, [wStatusScreenHPBarColor]
add PAL_GREENBAR
ld [hli], a
inc hl
pop af
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_StatusScreen
ret
-SendPalPacket_PartyMenu: ; 71e7b (1c:5e7b)
+SetPal_PartyMenu: ; 71e7b (1c:5e7b)
ld hl, PalPacket_PartyMenu
- ld de, wcf2e
+ ld de, wPartyMenuBlkPacket
ret
-SendPalPacket_Pokedex: ; 71e82 (1c:5e82)
+SetPal_Pokedex: ; 71e82 (1c:5e82)
ld hl, PalPacket_Pokedex
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
ld a, [wcf91]
call DeterminePaletteIDOutOfBattle
- ld hl, wcf30
+ ld hl, wPalPacket + 3
ld [hl], a
- ld hl, wcf2d
+ ld hl, wPalPacket
ld de, BlkPacket_Pokedex
ret
-SendPalPacket_Slots: ; 71e9f (1c:5e9f)
+SetPal_Slots: ; 71e9f (1c:5e9f)
ld hl, PalPacket_Slots
ld de, BlkPacket_Slots
ret
-SendPalPacket_Titlescreen: ; 71ea6 (1c:5ea6)
+SetPal_TitleScreen: ; 71ea6 (1c:5ea6)
ld hl, PalPacket_Titlescreen
ld de, BlkPacket_Titlescreen
ret
; used mostly for menus and the Oak intro
-SendPalPacket_Generic: ; 71ead (1c:5ead)
+SetPal_Generic: ; 71ead (1c:5ead)
ld hl, PalPacket_Generic
ld de, BlkPacket_WholeScreen
ret
-SendPalPacket_NidorinoIntro: ; 71eb4 (1c:5eb4)
+SetPal_NidorinoIntro: ; 71eb4 (1c:5eb4)
ld hl, PalPacket_NidorinoIntro
ld de, BlkPacket_NidorinoIntro
ret
-SendPalPacket_GameFreakIntro: ; 71ebb (1c:5ebb)
+SetPal_GameFreakIntro: ; 71ebb (1c:5ebb)
ld hl, PalPacket_GameFreakIntro
ld de, BlkPacket_GameFreakIntro
- ld a, $8
- ld [wcf1c], a
+ ld a, SET_PAL_GENERIC
+ ld [wDefaultPaletteCommand], a
ret
; uses PalPacket_Empty to build a packet based on the current map
-BuildOverworldPalPacket: ; 71ec7 (1c:5ec7)
+SetPal_Overworld: ; 71ec7 (1c:5ec7)
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
- ld a, [W_CURMAPTILESET]
+ ld a, [wCurMapTileset]
cp CEMETERY
jr z, .PokemonTowerOrAgatha
cp CAVERN
jr z, .caveOrBruno
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp REDS_HOUSE_1F
jr c, .townOrRoute
cp UNKNOWN_DUNGEON_2
@@ -162,12 +162,12 @@ BuildOverworldPalPacket: ; 71ec7 (1c:5ec7)
jr c, .town
ld a, PAL_ROUTE - 1
.town
- inc a ; a town's pallete ID is its map ID + 1
- ld hl, wcf2e
+ inc a ; a town's palette ID is its map ID + 1
+ ld hl, wPalPacket + 1
ld [hld], a
ld de, BlkPacket_WholeScreen
- ld a, $9
- ld [wcf1c], a
+ ld a, SET_PAL_OVERWORLD
+ ld [wDefaultPaletteCommand], a
ret
.PokemonTowerOrAgatha
ld a, PAL_GREYMON - 1
@@ -181,131 +181,143 @@ BuildOverworldPalPacket: ; 71ec7 (1c:5ec7)
; used when a Pokemon is the only thing on the screen
; such as evolution, trading and the Hall of Fame
-SendPokemonPalette_WholeScreen: ; 71f17 (1c:5f17)
+SetPal_PokemonWholeScreen: ; 71f17 (1c:5f17)
push bc
ld hl, PalPacket_Empty
- ld de, wcf2d
+ ld de, wPalPacket
ld bc, $10
call CopyData
pop bc
ld a, c
and a
- ld a, $1e
- jr nz, .asm_71f31
- ld a, [wcf1d]
+ ld a, PAL_BLACK
+ jr nz, .next
+ ld a, [wWholeScreenPaletteMonSpecies]
call DeterminePaletteIDOutOfBattle
-.asm_71f31
- ld [wcf2e], a
- ld hl, wcf2d
+.next
+ ld [wPalPacket + 1], a
+ ld hl, wPalPacket
ld de, BlkPacket_WholeScreen
ret
-BuildTrainerCardPalPacket: ; 71f3b (1c:5f3b)
+SetPal_TrainerCard: ; 71f3b (1c:5f3b)
ld hl, BlkPacket_TrainerCard
- ld de, wcc5b
+ ld de, wTrainerCardBlkPacket
ld bc, $40
call CopyData
- ld de, LoopCounts_71f8f
- ld hl, wcc5d
- ld a, [W_OBTAINEDBADGES]
- ld c, $8
-.asm_71f52
+ ld de, BadgeBlkDataLengths
+ ld hl, wTrainerCardBlkPacket + 2
+ ld a, [wObtainedBadges]
+ ld c, 8
+.badgeLoop
srl a
push af
- jr c, .asm_71f62
+ jr c, .haveBadge
+; The player doens't have the badge, so zero the badge's blk data.
push bc
ld a, [de]
ld c, a
xor a
-.asm_71f5b
+.zeroBadgeDataLoop
ld [hli], a
dec c
- jr nz, .asm_71f5b
+ jr nz, .zeroBadgeDataLoop
pop bc
- jr .asm_71f67
-.asm_71f62
+ jr .nextBadge
+.haveBadge
+; The player does have the badge, so skip past the badge's blk data.
ld a, [de]
-.asm_71f63
+.skipBadgeDataLoop
inc hl
dec a
- jr nz, .asm_71f63
-.asm_71f67
+ jr nz, .skipBadgeDataLoop
+.nextBadge
pop af
inc de
dec c
- jr nz, .asm_71f52
+ jr nz, .badgeLoop
ld hl, PalPacket_TrainerCard
- ld de, wcc5b
+ ld de, wTrainerCardBlkPacket
ret
-PointerTable_71f73: ; 71f73 (1c:5f73)
- dw SendPalPacket_Black
- dw BuildBattlePalPacket
- dw SendPalPacket_TownMap
- dw BuildStatusScreenPalPacket
- dw SendPalPacket_Pokedex
- dw SendPalPacket_Slots
- dw SendPalPacket_Titlescreen
- dw SendPalPacket_NidorinoIntro
- dw SendPalPacket_Generic
- dw BuildOverworldPalPacket
- dw SendPalPacket_PartyMenu
- dw SendPokemonPalette_WholeScreen
- dw SendPalPacket_GameFreakIntro
- dw BuildTrainerCardPalPacket
-
-; each byte is the number of loops to make in .asm_71f5b for each badge
-LoopCounts_71f8f: ; 71f8f (1c:5f8f)
- db $06,$06,$06,$12,$06,$06,$06,$06
+SetPalFunctions: ; 71f73 (1c:5f73)
+ dw SetPal_BattleBlack
+ dw SetPal_Battle
+ dw SetPal_TownMap
+ dw SetPal_StatusScreen
+ dw SetPal_Pokedex
+ dw SetPal_Slots
+ dw SetPal_TitleScreen
+ dw SetPal_NidorinoIntro
+ dw SetPal_Generic
+ dw SetPal_Overworld
+ dw SetPal_PartyMenu
+ dw SetPal_PokemonWholeScreen
+ dw SetPal_GameFreakIntro
+ dw SetPal_TrainerCard
+
+; The length of the blk data of each badge on the Trainer Card.
+; The Rainbow Badge has 3 entries because of its many colors.
+BadgeBlkDataLengths: ; 71f8f (1c:5f8f)
+ db 6 ; Boulder Badge
+ db 6 ; Cascade Badge
+ db 6 ; Thunder Badge
+ db 6 * 3 ; Rainbow Badge
+ db 6 ; Soul Badge
+ db 6 ; Marsh Badge
+ db 6 ; Volcano Badge
+ db 6 ; Earth Badge
DeterminePaletteID: ; 71f97 (1c:5f97)
- bit 3, a ; bit 3 of battle status 3, set if current Pokemon is transformed
- ld a, PAL_GREYMON ; if yes, use Ditto's palette
+ bit Transformed, a ; a is battle status 3
+ ld a, PAL_GREYMON ; if the mon has used Transform, use Ditto's palette
ret nz
ld a, [hl]
DeterminePaletteIDOutOfBattle: ; 71f9d (1c:5f9d)
ld [wd11e], a
- and a
- jr z, .idZero
+ and a ; is the mon index 0?
+ jr z, .skipDexNumConversion
push bc
- predef IndexToPokedex ; turn Pokemon ID number into Pokedex number
+ predef IndexToPokedex
pop bc
ld a, [wd11e]
-.idZero
+.skipDexNumConversion
ld e, a
- ld d, $00
- ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too
+ ld d, 0
+ ld hl, MonsterPalettes ; not just for Pokemon, Trainers use it too
add hl, de
ld a, [hl]
ret
-SendBlkPacket_PartyMenu: ; 71fb6 (1c:5fb6)
+InitPartyMenuBlkPacket: ; 71fb6 (1c:5fb6)
ld hl, BlkPacket_PartyMenu
- ld de, wcf2e
+ ld de, wPartyMenuBlkPacket
ld bc, $30
jp CopyData
-Func_71fc2: ; 71fc2 (1c:5fc2)
- ld hl, wcf1f
- ld a, [wcf2d]
+UpdatePartyMenuBlkPacket: ; 71fc2 (1c:5fc2)
+; Update the blk packet with the palette of the HP bar that is
+; specified in [wWhichPartyMenuHPBar].
+ ld hl, wPartyMenuHPBarColors
+ ld a, [wWhichPartyMenuHPBar]
ld e, a
- ld d, $0
+ ld d, 0
add hl, de
ld e, l
ld d, h
ld a, [de]
and a
- ld e, $5
- jr z, .asm_71fdb
+ ld e, (1 << 2) | 1 ; green
+ jr z, .next
dec a
- ld e, $a
- jr z, .asm_71fdb
- ld e, $f
-.asm_71fdb
+ ld e, (2 << 2) | 2 ; yellow
+ jr z, .next
+ ld e, (3 << 2) | 3 ; red
+.next
push de
- ld hl, wcf37
- ld bc, $6
- ld a, [wcf2d]
+ ld hl, wPartyMenuBlkPacket + 8 + 1
+ ld bc, 6
+ ld a, [wWhichPartyMenuHPBar]
call AddNTimes
pop de
ld [hl], e
@@ -321,11 +333,9 @@ SendSGBPacket: ; 71feb (1c:5feb)
.loop2
; save B for later use
push bc
-; load a non-zero value in $fff9 to disable the routine that checks actual
-; joypad input (said routine, located at $15f, does nothing if $fff9 is not
-; zero)
- ld a,$01
- ld [$fff9],a
+; disable ReadJoypad to prevent it from interfering with sending the packet
+ ld a, 1
+ ld [hDisableJoypadPolling], a
; send RESET signal (P14=LOW, P15=LOW)
xor a
ld [rJOYP],a
@@ -367,7 +377,7 @@ SendSGBPacket: ; 71feb (1c:5feb)
ld a,$30
ld [rJOYP],a
xor a
- ld [$fff9],a
+ ld [hDisableJoypadPolling],a
; wait for about 70000 cycles
call Wait7000
; restore (previously pushed) number of packets
@@ -383,39 +393,39 @@ LoadSGB: ; 7202b (1c:602b)
ld [wOnSGB], a
call CheckSGB
ret nc
- ld a, $1
+ ld a, 1
ld [wOnSGB], a
ld a, [wGBC]
and a
- jr z, .asm_7203f
+ jr z, .notGBC
ret
-.asm_7203f
+.notGBC
di
- call Func_72075
+ call PrepareSuperNintendoVRAMTransfer
ei
- ld a, $1
- ld [wcf2d], a
+ ld a, 1
+ ld [wCopyingSGBTileData], a
ld de, ChrTrnPacket
ld hl, SGBBorderGraphics
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
xor a
- ld [wcf2d], a
+ ld [wCopyingSGBTileData], a
ld de, PctTrnPacket
ld hl, BorderPalettes
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
xor a
- ld [wcf2d], a
+ ld [wCopyingSGBTileData], a
ld de, PalTrnPacket
ld hl, SuperPalettes
- call Func_7210b
+ call CopyGfxToSuperNintendoVRAM
call ClearVram
ld hl, MaskEnCancelPacket
jp SendSGBPacket
-Func_72075: ; 72075 (1c:6075)
- ld hl, PointerTable_72089
- ld c, $9
-.asm_7207a
+PrepareSuperNintendoVRAMTransfer: ; 72075 (1c:6075)
+ ld hl, .packetPointers
+ ld c, 9
+.loop
push bc
ld a, [hli]
push hl
@@ -426,10 +436,11 @@ Func_72075: ; 72075 (1c:6075)
inc hl
pop bc
dec c
- jr nz, .asm_7207a
+ jr nz, .loop
ret
-PointerTable_72089: ; 72089 (1c:6089)
+.packetPointers
+; Only the first packet is needed.
dw MaskEnFreezePacket
dw DataSnd_72548
dw DataSnd_72558
@@ -441,17 +452,18 @@ PointerTable_72089: ; 72089 (1c:6089)
dw DataSnd_725b8
CheckSGB: ; 7209b (1c:609b)
+; Returns whether the game is running on an SGB in carry.
ld hl, MltReq2Packet
di
call SendSGBPacket
- ld a, $1
- ld [$fff9], a
+ ld a, 1
+ ld [hDisableJoypadPolling], a
ei
call Wait7000
ld a, [rJOYP]
and $3
cp $3
- jr nz, .asm_720fd
+ jr nz, .isSGB
ld a, $20
ld [rJOYP], a
ld a, [rJOYP]
@@ -482,50 +494,50 @@ CheckSGB: ; 7209b (1c:609b)
ld a, [rJOYP]
and $3
cp $3
- jr nz, .asm_720fd
- call Func_72102
+ jr nz, .isSGB
+ call SendMltReq1Packet
and a
ret
-.asm_720fd
- call Func_72102
+.isSGB
+ call SendMltReq1Packet
scf
ret
-Func_72102: ; 72102 (1c:6102)
+SendMltReq1Packet: ; 72102 (1c:6102)
ld hl, MltReq1Packet
call SendSGBPacket
jp Wait7000
-Func_7210b: ; 7210b (1c:610b)
+CopyGfxToSuperNintendoVRAM: ; 7210b (1c:610b)
di
push de
call DisableLCD
ld a, $e4
ld [rBGP], a
ld de, vChars1
- ld a, [wcf2d]
+ ld a, [wCopyingSGBTileData]
and a
- jr z, .asm_72122
- call Func_72188
- jr .asm_72128
-.asm_72122
+ jr z, .notCopyingTileData
+ call CopySGBBorderTiles
+ jr .next
+.notCopyingTileData
ld bc, $1000
call CopyData
-.asm_72128
+.next
ld hl, vBGMap0
ld de, $c
ld a, $80
ld c, $d
-.asm_72132
+.loop
ld b, $14
-.asm_72134
+.innerLoop
ld [hli], a
inc a
dec b
- jr nz, .asm_72134
+ jr nz, .innerLoop
add hl, de
dec c
- jr nz, .asm_72132
+ jr nz, .loop
ld a, $e3
ld [rLCDC], a
pop hl
@@ -548,27 +560,27 @@ Wait7000: ; 7214a (1c:614a)
jr nz, .loop
ret
-Func_72156: ; 72156 (1c:6156)
+SendSGBPackets: ; 72156 (1c:6156)
ld a, [wGBC]
and a
- jr z, .asm_72165
+ jr z, .notGBC
push de
- call Func_7216d
+ call InitGBCPalettes
pop hl
- call Func_72187
+ call EmptyFunc5
ret
-.asm_72165
+.notGBC
push de
call SendSGBPacket
pop hl
jp SendSGBPacket
-Func_7216d: ; 7216d (1c:616d)
- ld a, $80
- ld [$ff68], a
+InitGBCPalettes: ; 7216d (1c:616d)
+ ld a, $80 ; index 0 with auto-increment
+ ld [rBGPI], a
inc hl
ld c, $20
-.asm_72174
+.loop
ld a, [hli]
inc hl
add a
@@ -576,37 +588,48 @@ Func_7216d: ; 7216d (1c:616d)
add a
ld de, SuperPalettes
add e
- jr nc, .asm_72180
+ jr nc, .noCarry
inc d
-.asm_72180
+.noCarry
ld a, [de]
- ld [$ff69], a
+ ld [rBGPD], a
dec c
- jr nz, .asm_72174
+ jr nz, .loop
ret
-Func_72187: ; 72187 (1c:6187)
+EmptyFunc5: ; 72187 (1c:6187)
ret
-Func_72188: ; 72188 (1c:6188)
- ld b, $80
-.asm_7218a
- ld c, $10
-.asm_7218c
+CopySGBBorderTiles: ; 72188 (1c:6188)
+; SGB tile data is stored in a 4BPP planar format.
+; Each tile is 32 bytes. The first 16 bytes contain bit planes 1 and 2, while
+; the second 16 bytes contain bit planes 3 and 4.
+; This function converts 2BPP planar data into this format by mapping
+; 2BPP colors 0-3 to 4BPP colors 0-3. 4BPP colors 4-15 are not used.
+ ld b, 128
+
+.tileLoop
+
+; Copy bit planes 1 and 2 of the tile data.
+ ld c, 16
+.copyLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_7218c
- ld c, $10
+ jr nz, .copyLoop
+
+; Zero bit planes 3 and 4.
+ ld c, 16
xor a
-.asm_72195
+.zeroLoop
ld [de], a
inc de
dec c
- jr nz, .asm_72195
+ jr nz, .zeroLoop
+
dec b
- jr nz, .asm_7218a
+ jr nz, .tileLoop
ret
INCLUDE "data/sgb_packets.asm"
diff --git a/engine/play_time.asm b/engine/play_time.asm
index 74da9c59..79deaf5e 100755
--- a/engine/play_time.asm
+++ b/engine/play_time.asm
@@ -3,37 +3,37 @@ TrackPlayTime: ; 18dee (6:4dee)
ld a, [wd732]
bit 0, a
ret z
- ld a, [W_PLAYTIMEMINUTES]
+ ld a, [wPlayTimeMaxed]
and a
ret nz
- ld a, [W_PLAYTIMEFRAMES]
+ ld a, [wPlayTimeFrames]
inc a
- ld [W_PLAYTIMEFRAMES], a
+ ld [wPlayTimeFrames], a
cp 60
ret nz
xor a
- ld [W_PLAYTIMEFRAMES], a
- ld a, [W_PLAYTIMESECONDS]
+ ld [wPlayTimeFrames], a
+ ld a, [wPlayTimeSeconds]
inc a
- ld [W_PLAYTIMESECONDS], a
+ ld [wPlayTimeSeconds], a
cp 60
ret nz
xor a
- ld [W_PLAYTIMESECONDS], a
- ld a, [W_PLAYTIMEMINUTES + 1]
+ ld [wPlayTimeSeconds], a
+ ld a, [wPlayTimeMinutes]
inc a
- ld [W_PLAYTIMEMINUTES + 1], a
+ ld [wPlayTimeMinutes], a
cp 60
ret nz
xor a
- ld [W_PLAYTIMEMINUTES + 1], a
- ld a, [W_PLAYTIMEHOURS + 1]
+ ld [wPlayTimeMinutes], a
+ ld a, [wPlayTimeHours]
inc a
- ld [W_PLAYTIMEHOURS + 1], a
+ ld [wPlayTimeHours], a
cp $ff
ret nz
ld a, $ff
- ld [W_PLAYTIMEMINUTES], a
+ ld [wPlayTimeMaxed], a
ret
CountDownIgnoreInputBitReset: ; 18e36 (6:4e36)
diff --git a/engine/pokedex_rating.asm b/engine/pokedex_rating.asm
index ca88673f..73025f0a 100755
--- a/engine/pokedex_rating.asm
+++ b/engine/pokedex_rating.asm
@@ -2,18 +2,18 @@ DisplayDexRating: ; 44169 (11:4169)
ld hl, wPokedexSeen
ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (seen count)
- ld [$FFDB], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsSeen], a
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
- ld a, [wd11e] ; result of CountSetBits (own count)
- ld [$FFDC], a
+ ld a, [wNumSetBits]
+ ld [hDexRatingNumMonsOwned], a
ld hl, DexRatingsTable
.findRating
ld a, [hli]
ld b, a
- ld a, [$FFDC] ; number of pokemon owned
+ ld a, [hDexRatingNumMonsOwned]
cp b
jr c, .foundRating
inc hl
@@ -24,30 +24,30 @@ DisplayDexRating: ; 44169 (11:4169)
ld h, [hl]
ld l, a ; load text pointer into hl
CheckAndResetEventA EVENT_HALL_OF_FAME_DEX_RATING
- jr nz, .label3
+ jr nz, .hallOfFame
push hl
ld hl, PokedexRatingText_441cc
call PrintText
pop hl
call PrintText
callba PlayPokedexRatingSfx
- jp WaitForTextScrollButtonPress ; wait for button press
-.label3
- ld de, wcc5b
- ld a, [$FFDB]
+ jp WaitForTextScrollButtonPress
+.hallOfFame
+ ld de, wDexRatingNumMonsSeen
+ ld a, [hDexRatingNumMonsSeen]
ld [de], a
inc de
- ld a, [$FFDC]
+ ld a, [hDexRatingNumMonsOwned]
ld [de], a
inc de
-.label4
+.copyRatingTextLoop
ld a, [hli]
- cp a, $50
- jr z, .label5
+ cp a, "@"
+ jr z, .doneCopying
ld [de], a
inc de
- jr .label4
-.label5
+ jr .copyRatingTextLoop
+.doneCopying
ld [de], a
ret
diff --git a/engine/predefs.asm b/engine/predefs.asm
index d8cf030c..16533751 100755
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -80,7 +80,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef LoadTilesetHeader
add_predef LearnMoveFromLevelUp
add_predef LearnMove
- add_predef IsItemInBag_
+ add_predef GetQuantityOfItemInBag
dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0
dbw $03,GiveItem
add_predef ChangeBGPalColor0_4Frames
@@ -121,7 +121,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef SetPartyMonTypes
add_predef CanLearnTM
add_predef TMToMove
- add_predef Func_71ddf
+ add_predef _RunPaletteCommand
add_predef StarterDex ; 46
add_predef _AddPartyMon
add_predef UpdateHPBar2
diff --git a/engine/predefs17_2.asm b/engine/predefs17_2.asm
index a2dac120..c0df7d0a 100755
--- a/engine/predefs17_2.asm
+++ b/engine/predefs17_2.asm
@@ -8,8 +8,8 @@ SetPartyMonTypes: ; 5db5e (17:5b5e)
push hl
call GetMonHeader
pop hl
- ld a, [W_MONHTYPE1]
+ ld a, [wMonHType1]
ld [hli], a
- ld a, [W_MONHTYPE2]
+ ld a, [wMonHType2]
ld [hl], a
ret
diff --git a/engine/predefs7.asm b/engine/predefs7.asm
index bf31772c..c336eaa9 100755
--- a/engine/predefs7.asm
+++ b/engine/predefs7.asm
@@ -19,9 +19,9 @@ DisplayElevatorFloorMenu: ; 1c9c6 (7:49c6)
ld a, b
ld [wListScrollOffset], a
ret c
- ld hl, wd126
+ ld hl, wCurrentMapScriptFlags
set 7, [hl]
- ld hl, wcc5b
+ ld hl, wElevatorWarpMaps
ld a, [wWhichPokemon]
add a
ld d, 0
diff --git a/engine/save.asm b/engine/save.asm
index dfc50616..e47be58a 100755
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -57,23 +57,23 @@ LoadSAV0: ; 73623 (1c:7623)
.checkSumsMatched
ld hl, sPlayerName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, sMainData
- ld de, wPokedexOwned
- ld bc, sSpriteData - sMainData
+ ld de, wMainDataStart
+ ld bc, wMainDataEnd - wMainDataStart
call CopyData
- ld hl, W_CURMAPTILESET
+ ld hl, wCurMapTileset
set 7, [hl]
ld hl, sSpriteData
- ld de, wSpriteStateData1
- ld bc, sPartyData - sSpriteData
+ ld de, wSpriteDataStart
+ ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
ld a, [sTilesetType]
ld [hTilesetType], a
ld hl, sCurBoxData
- ld de, W_NUMINBOX
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld de, wBoxDataStart
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
and a
jp SAVGoodChecksum
@@ -92,8 +92,8 @@ LoadSAV1: ; 73690 (1c:7690)
cp c
jr nz, SAVBadCheckSum
ld hl, sCurBoxData
- ld de, W_NUMINBOX
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld de, wBoxDataStart
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
and a
jp SAVGoodChecksum
@@ -112,8 +112,8 @@ LoadSAV2: ; 736bd (1c:76bd)
cp c
jp nz, SAVBadCheckSum
ld hl, sPartyData
- ld de, wPartyCount
- ld bc, wPokedexOwned - wPartyCount
+ ld de, wPartyDataStart
+ ld bc, wPartyDataEnd - wPartyDataStart
call CopyData
ld hl, sMainData
ld de, wPokedexOwned
@@ -203,19 +203,19 @@ SaveSAVtoSRAM0: ; 7378c (1c:778c)
ld [MBC1SRamBank], a
ld hl, wPlayerName
ld de, sPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
- ld hl, wPokedexOwned
+ ld hl, wMainDataStart
ld de, sMainData
- ld bc, W_NUMINBOX - wPokedexOwned
+ ld bc, wMainDataEnd - wMainDataStart
call CopyData
- ld hl, wSpriteStateData1
+ ld hl, wSpriteDataStart
ld de, sSpriteData
- ld bc, sPartyData - sSpriteData
+ ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
ld de, sCurBoxData
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
ld a, [hTilesetType]
ld [sTilesetType], a
@@ -235,9 +235,9 @@ SaveSAVtoSRAM1: ; 737e2 (1c:77e2)
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
ld de, sCurBoxData
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName
@@ -254,9 +254,9 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f)
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld hl, wPartyCount
+ ld hl, wPartyDataStart
ld de, sPartyData
- ld bc, wPokedexOwned - wPartyCount
+ ld bc, wPartyDataEnd - wPartyDataStart
call CopyData
ld hl, wPokedexOwned ; pokédex only
ld de, sMainData
@@ -300,7 +300,7 @@ CalcIndividualBoxCheckSums: ; 73863 (1c:7863)
.loop
push bc
push de
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call SAVCheckSum
pop de
ld [de], a
@@ -356,20 +356,20 @@ ChangeBox:: ; 738a1 (1c:78a1)
call HandleMenuInput
ld hl, hFlags_0xFFF6
res 1, [hl]
- bit 1, a
+ bit 1, a ; pressed b
ret nz
call GetBoxSRAMLocation
ld e, l
ld d, h
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
call CopyBoxToOrFromSRAM ; copy old box from WRAM to SRAM
ld a, [wCurrentMenuItem]
set 7, a
ld [wCurrentBoxNum], a
call GetBoxSRAMLocation
- ld de, W_NUMINBOX
+ ld de, wBoxDataStart
call CopyBoxToOrFromSRAM ; copy new box from SRAM to WRAM
- ld hl, W_MAPTEXTPTR
+ ld hl, wMapTextPtr
ld de, wChangeBoxSavedMapTextPointer
ld a, [hli]
ld [de], a
@@ -398,7 +398,7 @@ CopyBoxToOrFromSRAM: ; 7390e (1c:790e)
ld [MBC1SRamBankingMode], a
ld a, b
ld [MBC1SRamBank], a
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
pop hl
@@ -580,7 +580,7 @@ GetMonCountsForAllBoxes: ; 73a84 (1c:7a84)
ld c, a
ld b, 0
add hl, bc
- ld a, [W_NUMINBOX]
+ ld a, [wNumInBox]
ld [hl], a
ret
@@ -644,7 +644,7 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d)
call AddNTimes
ld e, l
ld d, h
- ld hl, wcc5b
+ ld hl, wHallOfFame
ld bc, HOF_TEAM
jr HallOfFame_Copy
@@ -653,7 +653,7 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d)
ld de, sHallOfFame
ld bc, HOF_TEAM * (HOF_TEAM_CAPACITY - 1)
call HallOfFame_Copy
- ld hl, wcc5b
+ ld hl, wHallOfFame
ld de, sHallOfFame + HOF_TEAM * (HOF_TEAM_CAPACITY - 1)
ld bc, HOF_TEAM
jr HallOfFame_Copy
@@ -663,7 +663,7 @@ LoadHallOfFameTeams: ; 73b3f (1c:7b3f)
ld bc, HOF_TEAM
ld a, [wHoFTeamIndex]
call AddNTimes
- ld de, wcc5b
+ ld de, wHallOfFame
ld bc, HOF_TEAM
; fallthrough
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index 3b392dde..b2917459 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -21,8 +21,8 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
call GBPalWhiteOutWithDelay3
call LoadSlotMachineTiles
call LoadFontTilePatterns
- ld b, $5
- call GoPAL_SET
+ ld b, SET_PAL_SLOTS
+ call RunPaletteCommand
call GBPalNormal
ld a, $e4
ld [rOBP0], a
@@ -41,7 +41,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
call GBPalWhiteOutWithDelay3
ld a, $1
ld [wUpdateSpritesEnabled], a
- call GoPAL_SET_CF1C
+ call RunDefaultPaletteCommand
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
.done
@@ -411,7 +411,7 @@ SlotMachine_CheckForMatches: ; 37588 (d:7588)
call PrintText
.done
xor a
- ld [wc002], a
+ ld [wMuteAudioAndPauseMusic], a
ret
.rollWheel3DownByOneSymbol
call SlotMachine_AnimWheel3
@@ -654,7 +654,7 @@ SlotMachine_PrintPayoutCoins: ; 3775f (d:775f)
SlotMachine_PayCoinsToPlayer: ; 3776b (d:776b)
ld a, $1
- ld [wc002], a
+ ld [wMuteAudioAndPauseMusic], a
call WaitForSoundToFinish
; Put 1 in the temp coins variable. This value is added to the player's coins
@@ -758,7 +758,7 @@ SlotMachine_AnimWheel1: ; 37813 (d:7813)
ld de, wSlotMachineWheel1Offset
ld hl, wOAMBuffer
ld a, $30
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
jr SlotMachine_AnimWheel
SlotMachine_AnimWheel2: ; 37823 (d:7823)
@@ -766,7 +766,7 @@ SlotMachine_AnimWheel2: ; 37823 (d:7823)
ld de, wSlotMachineWheel2Offset
ld hl, wOAMBuffer + $30
ld a, $50
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
jr SlotMachine_AnimWheel
SlotMachine_AnimWheel3: ; 37833 (d:7833)
@@ -774,11 +774,11 @@ SlotMachine_AnimWheel3: ; 37833 (d:7833)
ld de, wSlotMachineWheel3Offset
ld hl, wOAMBuffer + $60
ld a, $70
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
SlotMachine_AnimWheel: ; 37841 (d:7841)
ld a, $58
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
push de
ld a, [de]
ld d, b
@@ -787,17 +787,17 @@ SlotMachine_AnimWheel: ; 37841 (d:7841)
jr nc, .loop
inc d
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
ld [hli], a
ld a, [de]
ld [hli], a
ld a, $80
ld [hli], a
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add $8
ld [hli], a
ld a, [de]
@@ -806,9 +806,9 @@ SlotMachine_AnimWheel: ; 37841 (d:7841)
ld a, $80
ld [hli], a
inc de
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
sub $8
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
cp $28
jr nz, .loop
pop de
diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm
index df47275b..cbe19d6d 100755
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -1,6 +1,6 @@
-; copy text of fixed length $b (like player name, rival name, mon names, ...)
+; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
CopyFixedLengthText: ; 42b1 (1:42b1)
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
@@ -8,7 +8,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
ld de, wPlayerName
call CopyFixedLengthText
ld hl, SonyText
- ld de, W_RIVALNAME
+ ld de, wRivalName
call CopyFixedLengthText
xor a
ld [hWY], a
@@ -18,8 +18,8 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
ld [hli], a
ld [hl], a
ld a, BANK(Music_TitleScreen)
- ld [wc0ef], a
- ld [wc0f0], a
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
DisplayTitleScreen: ; 42dd (1:42dd)
call GBPalWhiteOut
@@ -56,15 +56,8 @@ DisplayTitleScreen: ; 42dd (1:42dd)
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk
ld hl, Version_GFX
-IF DEF(_RED)
- ld de,vChars2 + $600
- ld bc,$50
-ENDC
-IF DEF(_BLUE)
- ld de,vChars2 + $600 + $10
- ld bc,$50 - $10
-ENDC
-
+ ld de,vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
+ ld bc, Version_GFXEnd - Version_GFX
ld a, BANK(Version_GFX)
call FarCopyDataDouble
call ClearBothBGMaps
@@ -141,8 +134,8 @@ ENDC
call LoadScreenTilesFromBuffer2
ld a, vBGMap0 / $100
call TitleScreenCopyTileMapToVRAM
- ld b, $6
- call GoPAL_SET
+ ld b, SET_PAL_TITLE_SCREEN
+ call RunPaletteCommand
call GBPalNormal
ld a, %11100100
ld [rOBP0], a
@@ -219,10 +212,10 @@ ENDC
call Delay3
call WaitForSoundToFinish
ld a, MUSIC_TITLE_SCREEN
- ld [wc0ee], a
+ ld [wNewSoundID], a
call PlaySound
xor a
- ld [wcc5b], a
+ ld [wUnusedCC5B], a
; Keep scrolling in new mons indefinitely until the user performs input.
.awaitUserInterruptionLoop
@@ -317,7 +310,7 @@ ScrollTitleScreenGameVersion: ; 44cf (1:44cf)
DrawPlayerCharacter: ; 44dd (1:44dd)
ld hl, PlayerCharacterTitleGraphics
ld de, vSprites
- ld bc, $230
+ ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
ld a, BANK(PlayerCharacterTitleGraphics)
call FarCopyData2
call ClearSprites
@@ -377,7 +370,7 @@ LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538)
LoadCopyrightTiles: ; 4541 (1:4541)
ld de, NintendoCopyrightLogoGraphics
ld hl, vChars2 + $600
- lb bc, BANK(NintendoCopyrightLogoGraphics), $1c
+ lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
call CopyVideoData
coord hl, 2, 7
ld de, CopyrightTextString
diff --git a/engine/town_map.asm b/engine/town_map.asm
index 037a59fa..727197de 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -7,7 +7,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
push hl
ld a, $1
ld [hJoy7], a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
push af
ld b, $0
call DrawPlayerOrBirdSprite ; player sprite
@@ -20,7 +20,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
call CopyData
ld hl, vSprites + $40
ld de, TownMapCursor
- lb bc, BANK(TownMapCursor), $04
+ lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
call CopyVideoDataDouble
xor a
ld [wWhichTownMapLocation], a
@@ -107,6 +107,7 @@ INCLUDE "data/town_map_order.asm"
TownMapCursor: ; 70f40 (1c:4f40)
INCBIN "gfx/town_map_cursor.1bpp"
+TownMapCursorEnd:
LoadTownMap_Nest: ; 70f60 (1c:4f60)
call LoadTownMap
@@ -144,7 +145,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
call CopyVideoData
ld de, TownMapUpArrow
ld hl, vChars1 + $6d0
- lb bc, BANK(TownMapUpArrow), $01
+ lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
call CopyVideoDataDouble
call BuildFlyLocationsList
ld hl, wUpdateSpritesEnabled
@@ -155,7 +156,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
coord hl, 0, 0
ld de, ToText
call PlaceString
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, $0
call DrawPlayerOrBirdSprite
ld hl, wFlyLocationsList
@@ -249,9 +250,9 @@ BuildFlyLocationsList: ; 71070 (1c:5070)
ld hl, wFlyLocationsList - 1
ld [hl], $ff
inc hl
- ld a, [W_TOWNVISITEDFLAG]
+ ld a, [wTownVisitedFlag]
ld e, a
- ld a, [W_TOWNVISITEDFLAG + 1]
+ ld a, [wTownVisitedFlag + 1]
ld d, a
ld bc, SAFFRON_CITY + 1
.loop
@@ -271,6 +272,7 @@ BuildFlyLocationsList: ; 71070 (1c:5070)
TownMapUpArrow: ; 71093 (1c:5093)
INCBIN "gfx/up_arrow.1bpp"
+TownMapUpArrowEnd:
LoadTownMap: ; 7109b (1c:509b)
call GBPalWhiteOutWithDelay3
@@ -283,12 +285,12 @@ LoadTownMap: ; 7109b (1c:509b)
call DisableLCD
ld hl, WorldMapTileGraphics
ld de, vChars2 + $600
- ld bc, $100
+ ld bc, WorldMapTileGraphicsEnd - WorldMapTileGraphics
ld a, BANK(WorldMapTileGraphics)
call FarCopyData2
ld hl, MonNestIcon
ld de, vSprites + $40
- ld bc, $8
+ ld bc, MonNestIconEnd - MonNestIcon
ld a, BANK(MonNestIcon)
call FarCopyDataDouble
coord hl, 0, 0
@@ -312,8 +314,8 @@ LoadTownMap: ; 7109b (1c:509b)
jr .nextTile
.done
call EnableLCD
- ld b, $2
- call GoPAL_SET
+ ld b, SET_PAL_TOWN_MAP
+ call RunPaletteCommand
call Delay3
call GBPalNormal
xor a
@@ -336,7 +338,7 @@ ExitTownMap: ; 711ab (1c:51ab)
call LoadPlayerSpriteGraphics
call LoadFontTilePatterns
call UpdateSprites
- jp GoPAL_SET_CF1C
+ jp RunDefaultPaletteCommand
DrawPlayerOrBirdSprite: ; 711c4 (1c:51c4)
; a = map number
@@ -403,7 +405,7 @@ DisplayWildLocations: ; 711ef (1c:51ef)
call PlaceString
jr .done
.drawPlayerSprite
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, $0
call DrawPlayerOrBirdSprite
.done
@@ -442,8 +444,12 @@ WritePlayerOrBirdSpriteOAM: ; 7126d (1c:526d)
WriteTownMapSpriteOAM: ; 71279 (1c:5279)
push hl
+
+; Subtract 4 from c (X coord) and 4 from b (Y coord). However, the carry from c
+; is added to b, so the net result is that only 3 is subtracted from b.
lb hl, -4, -4
- add hl, bc ; subtract 4 from c (X coord) and 4 from b (Y coord)
+ add hl, bc
+
ld b, h
ld c, l
pop hl
@@ -467,14 +473,14 @@ WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
xor a
ld [hli], a
inc d
- ld a, $8
+ ld a, 8
add c
ld c, a
dec e
jr nz, .innerLoop
pop bc
pop de
- ld a, $8
+ ld a, 8
add b
ld b, a
dec d
@@ -582,6 +588,7 @@ INCLUDE "text/map_names.asm"
MonNestIcon: ; 716be (1c:56be)
INCBIN "gfx/mon_nest_icon.1bpp"
+MonNestIconEnd:
TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
ld a, [wAnimCounter]
diff --git a/engine/trade.asm b/engine/trade.asm
index 1a0e5f61..1642e729 100755
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -18,14 +18,14 @@ ExternalClockTradeAnim: ; 410f3 (10:50f3)
ld de, ExternalClockTradeFuncSequence
TradeAnimCommon: ; 41102 (10:5102)
- ld a, [W_OPTIONS]
+ ld a, [wOptions]
push af
ld a, [hSCY]
push af
ld a, [hSCX]
push af
xor a
- ld [W_OPTIONS], a
+ ld [wOptions], a
ld [hSCY], a
ld [hSCX], a
push de
@@ -53,7 +53,7 @@ TradeAnimCommon: ; 41102 (10:5102)
pop af
ld [hSCY], a
pop af
- ld [W_OPTIONS], a
+ ld [wOptions], a
ret
addtradefunc: MACRO
@@ -149,7 +149,7 @@ Trade_Delay80: ; 41191 (10:5191)
Trade_ClearTileMap: ; 41196 (10:5196)
coord hl, 0, 0
- ld bc, 20 * 18
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, " "
jp FillMemory
@@ -158,12 +158,12 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1)
call DisableLCD
ld hl, TradingAnimationGraphics
ld de, vChars2 + $310
- ld bc, $310
+ ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics
ld a, BANK(TradingAnimationGraphics)
call FarCopyData2
ld hl, TradingAnimationGraphics2
ld de, vSprites + $7c0
- ld bc, $40
+ ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2
ld a, BANK(TradingAnimationGraphics2)
call FarCopyData2
ld hl, vBGMap0
@@ -190,7 +190,7 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1)
call GetMonName
ld hl, wcd6d
ld de, wcf4b
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wTradedEnemyMonSpecies]
ld [wd11e], a
@@ -204,15 +204,15 @@ Trade_LoadMonPartySpriteGfx: ; 4120b (10:520b)
Trade_SwapNames: ; 41217 (10:5217)
ld hl, wPlayerName
ld de, wBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wLinkEnemyTrainerName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wBuffer
ld de, wLinkEnemyTrainerName
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
Trade_Cleanup: ; 4123b (10:523b)
@@ -268,8 +268,8 @@ Trade_DrawOpenEndOfLinkCable: ; 41298 (10:5298)
call Trade_ClearTileMap
ld b, vBGMap0 / $100
call CopyScreenTileBufferToVRAM
- ld b, $8
- call GoPAL_SET
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
; This function call is pointless. It just copies blank tiles to VRAM that was
; already filled with blank tiles.
@@ -383,9 +383,9 @@ Trade_AnimLeftToRight: ; 41376 (10:5376)
ld a, $e4
ld [rOBP0], a
ld a, $54
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld a, $1c
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, [wLeftGBMonSpecies]
ld [wMonPartySpriteSpecies], a
call Trade_WriteCircledMonOAM
@@ -415,9 +415,9 @@ Trade_AnimRightToLeft: ; 413c6 (10:53c6)
xor a
ld [wTradedMonMovingRight], a
ld a, $64
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld a, $44
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld a, [wRightGBMonSpecies]
ld [wMonPartySpriteSpecies], a
call Trade_WriteCircledMonOAM
@@ -552,14 +552,14 @@ Trade_CopyCableTilesOffScreen: ; 414ae (10:54ae)
; continues when the screen is scrolled.
push hl
coord hl, 0, 4
- call CopyToScreenEdgeTiles
+ call CopyToRedrawRowOrColumnSrcTiles
pop hl
ld a, h
- ld [H_SCREENEDGEREDRAWADDR + 1], a
+ ld [hRedrawRowOrColumnDest + 1], a
ld a, l
- ld [H_SCREENEDGEREDRAWADDR], a
- ld a, REDRAWROW
- ld [H_SCREENEDGEREDRAW], a
+ ld [hRedrawRowOrColumnDest], a
+ ld a, REDRAW_ROW
+ ld [hRedrawRowOrColumnMode], a
ld c, 10
jp DelayFrames
@@ -622,10 +622,10 @@ Trade_AddOffsetsToOAMCoords: ; 41510 (10:5510)
ld hl, wOAMBuffer
ld c, $14
.loop
- ld a, [W_BASECOORDY]
+ ld a, [wBaseCoordY]
add [hl]
ld [hli], a
- ld a, [W_BASECOORDX]
+ ld a, [wBaseCoordX]
add [hl]
ld [hli], a
inc hl
@@ -657,9 +657,9 @@ Trade_AnimMonMoveVertical: ; 41525 (10:5525)
lb bc, -4, 0 ; move left
.doAnim
ld a, b
- ld [W_BASECOORDX], a
+ ld [wBaseCoordX], a
ld a, c
- ld [W_BASECOORDY], a
+ ld [wBaseCoordY], a
ld d, $4
.loop
call Trade_AddOffsetsToOAMCoords
@@ -727,10 +727,10 @@ Trade_CircleOAM3: ; 4159c (10:559c)
Trade_LoadMonSprite: ; 415a4 (10:55a4)
ld [wcf91], a
ld [wd0b5], a
- ld [wcf1d], a
- ld b, $b
- ld c, $0
- call GoPAL_SET
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
ld a, [H_AUTOBGTRANSFERENABLED]
xor $1
ld [H_AUTOBGTRANSFERENABLED], a
@@ -847,7 +847,7 @@ TradeforText: ; 41671 (10:5671)
db "@"
Trade_ShowAnimation: ; 41676 (10:5676)
- ld [W_ANIMATIONID], a
+ ld [wAnimationID], a
xor a
- ld [wcc5b], a
+ ld [wAnimationType], a
predef_jump MoveAnimation