summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/bank3c/main.asm8
-rw-r--r--engine/bank3c/overworld.asm16
-rw-r--r--engine/bank3d/bank3d_battle.asm20
-rw-r--r--engine/bank3d/main.asm5
-rw-r--r--engine/bank3f/main.asm46
-rwxr-xr-xengine/battle/animations.asm6
-rw-r--r--engine/battle/battle_transitions.asm10
-rw-r--r--engine/battle/common_text.asm4
-rwxr-xr-xengine/battle/core.asm126
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm2
-rwxr-xr-xengine/battle/end_of_battle.asm4
-rw-r--r--engine/battle/experience.asm8
-rw-r--r--engine/battle/get_trainer_name.asm2
-rw-r--r--engine/battle/init_battle_variables.asm2
-rw-r--r--engine/battle/moveEffects/drain_hp_effect.asm6
-rw-r--r--engine/battle/moveEffects/one_hit_ko_effect.asm4
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm4
-rw-r--r--engine/battle/moveEffects/substitute_effect.asm2
-rw-r--r--engine/battle/moveEffects/transform_effect.asm2
-rw-r--r--engine/battle/print_type.asm6
-rwxr-xr-xengine/battle/read_trainer_party.asm18
-rwxr-xr-xengine/battle/safari_zone.asm2
-rw-r--r--engine/battle/trainer_ai.asm2
-rw-r--r--engine/battle/wild_encounters.asm18
-rwxr-xr-xengine/cable_club.asm135
-rwxr-xr-xengine/evos_moves.asm18
-rwxr-xr-xengine/experience.asm2
-rwxr-xr-xengine/hidden_object_functions18.asm4
-rwxr-xr-xengine/hidden_object_functions3.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm4
-rwxr-xr-xengine/in_game_trades.asm6
-rwxr-xr-xengine/intro.asm2
-rwxr-xr-xengine/items/itemfinder.asm10
-rwxr-xr-xengine/items/items.asm72
-rwxr-xr-xengine/items/tms.asm2
-rwxr-xr-xengine/learn_move.asm2
-rw-r--r--engine/menu/bills_pc.asm4
-rwxr-xr-xengine/menu/main_menu.asm8
-rwxr-xr-xengine/menu/naming_screen.asm6
-rwxr-xr-xengine/menu/prize_menu.asm2
-rwxr-xr-xengine/menu/status_screen.asm10
-rwxr-xr-xengine/oak_speech.asm4
-rwxr-xr-xengine/overworld/card_key.asm10
-rwxr-xr-xengine/overworld/cut.asm10
-rwxr-xr-xengine/overworld/hidden_items.asm2
-rwxr-xr-xengine/overworld/hidden_objects.asm14
-rw-r--r--engine/overworld/is_player_just_outside_map.asm8
-rw-r--r--engine/overworld/item.asm12
-rwxr-xr-xengine/overworld/map_sprites.asm20
-rw-r--r--engine/overworld/movement.asm479
-rwxr-xr-xengine/overworld/npc_movement.asm4
-rw-r--r--engine/overworld/oam.asm2
-rwxr-xr-xengine/overworld/pewter_guys.asm4
-rwxr-xr-xengine/overworld/trainers.asm2
-rwxr-xr-xengine/palettes.asm4
-rwxr-xr-xengine/predefs17_2.asm4
-rwxr-xr-xengine/town_map.asm10
-rwxr-xr-xengine/trade.asm6
58 files changed, 701 insertions, 506 deletions
diff --git a/engine/bank3c/main.asm b/engine/bank3c/main.asm
index 6253f971..468a6412 100644
--- a/engine/bank3c/main.asm
+++ b/engine/bank3c/main.asm
@@ -161,7 +161,7 @@ ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274)
xor a ; gamefreak copypasting functions (double xor a)
ld [wBattleResult], a
ld [wWalkBikeSurfState], a
- ld [W_ISINBATTLE], a
+ ld [wIsInBattle], a
ld [wMapPalOffset], a
ld [wNPCMovementScriptFunctionNum], a
ld [hJoyHeld], a
@@ -204,7 +204,7 @@ ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274)
predef_jump HealParty
Func_f02da:: ; f02da (3c:42da)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp VERMILION_GYM ; ??? new thing about verm gym?
jr z,.asm_f02ee
ld c,a
@@ -248,7 +248,7 @@ Func_f0a55:: ; f0a55 (3c:4a55)
cp a,$ff
ret z
ld b,a
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp b
jr z,.asm_f0a68
inc hl
@@ -263,7 +263,7 @@ Func_f0a55:: ; f0a55 (3c:4a55)
ld a,[hli]
ld h,[hl]
ld l,a
- ld de,W_MISSABLEOBJECTLIST
+ ld de,wMissableObjectList
call CopyData
ret
diff --git a/engine/bank3c/overworld.asm b/engine/bank3c/overworld.asm
index d7e6274f..e02fb129 100644
--- a/engine/bank3c/overworld.asm
+++ b/engine/bank3c/overworld.asm
@@ -9,12 +9,12 @@ _AdvancePlayerSprite:: ; f010c (3c:410c)
; if it's the end of the animation, update the player's map coordinates
ld hl, wd430
res 5, [hl]
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add b
- ld [W_YCOORD],a
- ld a,[W_XCOORD]
+ ld [wYCoord],a
+ ld a,[wXCoord]
add c
- ld [W_XCOORD],a
+ ld [wXCoord],a
.afterUpdateMapCoords
ld a,[wWalkCounter] ; walking animation counter
cp a,$07
@@ -81,7 +81,7 @@ _AdvancePlayerSprite:: ; f010c (3c:410c)
and a
jr z,.pointlessJump ; mistake?
.pointlessJump
- ld hl,W_XBLOCKCOORD
+ ld hl,wXBlockCoord
ld a,[hl]
add c
ld [hl],a
@@ -107,7 +107,7 @@ _AdvancePlayerSprite:: ; f010c (3c:410c)
call MoveTileBlockMapPointerWest
jr .updateMapView
.adjustYCoordWithinBlock
- ld hl,W_YBLOCKCOORD
+ ld hl,wYBlockCoord
ld a,[hl]
add b
ld [hl],a
@@ -119,7 +119,7 @@ _AdvancePlayerSprite:: ; f010c (3c:410c)
ld hl,wYOffsetSinceLastSpecialWarp
inc [hl]
ld de,wCurrentTileBlockMapViewPointer
- ld a,[W_CURMAPWIDTH]
+ ld a,[wCurMapWidth]
call MoveTileBlockMapPointerSouth
jr .updateMapView
.checkForMoveToNorthBlock
@@ -131,7 +131,7 @@ _AdvancePlayerSprite:: ; f010c (3c:410c)
ld hl,wYOffsetSinceLastSpecialWarp
dec [hl]
ld de,wCurrentTileBlockMapViewPointer
- ld a,[W_CURMAPWIDTH]
+ ld a,[wCurMapWidth]
call MoveTileBlockMapPointerNorth
.updateMapView
call LoadCurrentMapView
diff --git a/engine/bank3d/bank3d_battle.asm b/engine/bank3d/bank3d_battle.asm
index 5c5acd15..1f84d314 100644
--- a/engine/bank3d/bank3d_battle.asm
+++ b/engine/bank3d/bank3d_battle.asm
@@ -1,10 +1,10 @@
InitBattle: ; f5ff2 (3d:5ff2)
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
and a
jr z, asm_f6003
InitOpponent: ; f5ff8 (3d:5ff8)
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
ld [wcf91], a
ld [wEnemyMonSpecies2], a
jr asm_f601d
@@ -47,10 +47,10 @@ asm_f601d: ; f601d (f:601d)
ld a, $ff
ld [wEnemyMonPartyPos], a
ld a, $2
- ld [W_ISINBATTLE], a
+ ld [wIsInBattle], a
; Is this a major story battle?
- ld a,[W_LONEATTACKNO]
+ ld a,[wLoneAttackNo]
and a
jp z,InitBattle_Common
callabd_ModifyPikachuHappiness PIKAHAPPY_GYMLEADER ; useless since already in bank3d
@@ -58,16 +58,16 @@ asm_f601d: ; f601d (f:601d)
InitWildBattle: ; f607c (3d:607c)
ld a, $1
- ld [W_ISINBATTLE], a
+ ld [wIsInBattle], a
callab LoadEnemyMonData
callab DoBattleTransitionAndInitBattleVariables
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
cp MAROWAK
jr z, .isGhost
callab IsGhostBattle
jr nz, .isNoGhost
.isGhost
- ld hl, W_MONHSPRITEDIM
+ ld hl, wMonHSpriteDim
ld a, $66
ld [hli], a ; write sprite dimensions
ld bc, GhostPic
@@ -131,7 +131,7 @@ InitBattle_Common: ; f60eb (3d:60eb)
ld bc, $40a
call ClearScreenArea
call ClearSprites
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
dec a ; is it a wild battle?
ld hl, DrawEnemyHUDAndHPBar
ld b,BANK(DrawEnemyHUDAndHPBar)
@@ -175,7 +175,7 @@ LoadMonBackPic: ; f6178 (3d:6178)
coord hl, 1, 5
ld bc,$708
call ClearScreenArea
- ld hl, W_MONHBACKSPRITE - W_MONHEADER
+ ld hl, wMonHBackSprite - wMonHeader
call UncompressMonSprite
predef ScaleSpriteByTwo
ld de, vBackPic
@@ -195,7 +195,7 @@ Func_f61a6: ; f61a6 (3d:f61a6)
ld a, [$ffe1]
ld [H_DOWNARROWBLINKCNT1], a
ld b, $4c
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jr z, .asm_f61ef
add b
diff --git a/engine/bank3d/main.asm b/engine/bank3d/main.asm
index 131f4fca..c64dd26f 100644
--- a/engine/bank3d/main.asm
+++ b/engine/bank3d/main.asm
@@ -461,7 +461,7 @@ Func_f5b2d:: ; f5b2d (3d:5b2d)
ld a,[wd732]
bit 5,a
jr nz,.asm_f5b59
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp SEAFOAM_ISLANDS_5
ret nz
ld a,[wd881]
@@ -640,12 +640,13 @@ RemoveItemFromInventory_: ; f5be1 (3d:5be1)
ret
TrainerInfoTextBoxTileGraphics: INCBIN "gfx/trainer_info.2bpp"
+TrainerInfoTextBoxTileGraphicsEnd:
BlankLeaderNames: INCBIN "gfx/blank_leader_names.2bpp"
CircleTile: INCBIN "gfx/circle_tile.2bpp"
BadgeNumbersTileGraphics: INCBIN "gfx/badge_numbers.2bpp"
ReadSuperRodData:: ; f5ea4 (3d:5ea4)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld c,a
ld hl,FishingSlots
.loop
diff --git a/engine/bank3f/main.asm b/engine/bank3f/main.asm
index ae79a5ca..72942405 100644
--- a/engine/bank3f/main.asm
+++ b/engine/bank3f/main.asm
@@ -61,10 +61,10 @@ Func_fc534:: ; fc534 (3f:4534)
Func_fc53f:: ; fc53f (3f:453f)
ld bc,wSpriteStateData1 + $f0
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
ld e,a
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
ld d,a
ld a,[wd431]
@@ -178,7 +178,7 @@ Func_fc5bc:: ; fc5bc (3f:45bc)
ret
Func_fc5fa:: ; fc5fa (3f:45fa)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp OAKS_LAB
jr z,.asm_fc63d
cp ROUTE_22_GATE
@@ -187,11 +187,11 @@ Func_fc5fa:: ; fc5fa (3f:45fa)
jr z,.asm_fc635
cp ROCK_TUNNEL_1
jr z,.asm_fc645
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld hl,Pointer_fc64b
call Func_1568 ; similar to IsInArray, but not the same
jr c,.asm_fc639
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld hl,Pointer_fc653
call Func_1568
jr nc,.asm_fc641
@@ -231,12 +231,12 @@ Pointer_fc653:: ; fc653 (3f:4653)
db $2f,$e6,$3e,$5e,$80,$31,$a4,$ff
Func_fc65b:: ; fc65b (3f:465b)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp VIRIDIAN_FOREST_EXIT
jr z,.asm_fc673
cp VIRIDIAN_FOREST_ENTRANCE
jr z,.asm_fc67c
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld hl,Pointer_fc68e
call Func_1568
jr c,.asm_fc688
@@ -264,7 +264,7 @@ Pointer_fc68e:: ; fc68e (3f:468e)
db $33,$dd,$df,$e0,$e1,$de,$ec,$7f,$a8,$a9,$aa,$ff
Func_fc69a:: ; fc69a (3f:469a)
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp ROUTE_22_GATE
jr z,.asm_fc6a7
cp ROUTE_2_GATE
@@ -407,7 +407,7 @@ asm_fc76a: ; fc76a (3f:476a)
call Func_fc82e
jr c,.asm_fc783
push bc
- callab Func_5012
+ callab InitializeSpriteScreenPosition
pop bc
.asm_fc783
ld hl,$1
@@ -422,7 +422,7 @@ asm_fc76a: ; fc76a (3f:476a)
Func_fc793: ; fc793 (3f:4793)
call Func_fcba1
push bc
- callab Func_5012
+ callab InitializeSpriteScreenPosition
pop bc
ld hl,$2
add hl,bc
@@ -966,12 +966,12 @@ Func_fca99: ; fca99 (3f:4a99)
Func_fcae2: ; fcae2 (3f:4ae2)
ld hl,$104
add hl,bc
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
cp [hl]
jr nz,.asm_fcaff
inc hl
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
cp [hl]
jr nz,.asm_fcaff
@@ -989,10 +989,10 @@ Func_fcb01: ; fcb01 (3f:4b01)
push de
push hl
ld bc,wSpriteStateData1 + $f0
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
ld d,a
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
ld e,a
ld hl,$104
@@ -1045,10 +1045,10 @@ Func_fcb4d: ; fcb4d (3f:4b4d)
Func_fcb52: ; fcb52 (3f:4b52)
ld bc,wSpriteStateData1 + $f0
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
ld d,a
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
ld e,a
ld hl,$104
@@ -1111,7 +1111,7 @@ Func_fcbac: ; fcbac (3f:4bac)
ld bc,wSpriteStateData1 + $f0
ld hl,$104
add hl,bc
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
sub [hl]
jr z,.asm_fcbd7
@@ -1138,7 +1138,7 @@ Func_fcbac: ; fcbac (3f:4bac)
.asm_fcbd7
ld hl,$105
add hl,bc
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
sub [hl]
jr z,.asm_fcbff
@@ -1304,10 +1304,10 @@ Func_fccb2:: ; fccb2 (3f:4cb2)
add a
jr .asm_fccea
.asm_fccbf
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
add $4
ld d,a
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
add $4
ld e,a
ld a,[wSpriteStateData2 + $f4]
@@ -1381,7 +1381,7 @@ Func_fcd25: ; fcd25 (3f:4d25)
add $4
ld l,a
ld b,[hl]
- ld a,[W_YCOORD]
+ ld a,[wYCoord]
cp b
jr z,.asm_fcd3a
jr nc,.asm_fcd63
@@ -1391,7 +1391,7 @@ Func_fcd25: ; fcd25 (3f:4d25)
.asm_fcd3a
inc l
ld b,[hl]
- ld a,[W_XCOORD]
+ ld a,[wXCoord]
cp b
jr z,.asm_fcd49
jr nc,.asm_fcd63
@@ -1429,7 +1429,7 @@ Func_fcd25: ; fcd25 (3f:4d25)
ld a,[H_CURRENTSPRITEOFFSET]
add $7
ld l,a
- ld a,[W_GRASSTILE]
+ ld a,[wGrassTile]
cp e
ld a,$0
jr nz,.asm_fcd80
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 626eea9e..f0f5c6d3 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -389,7 +389,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
@@ -736,7 +736,7 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
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]
@@ -2945,7 +2945,7 @@ 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,[wPokeBallAnimData]
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index c5c4ffbe..e3527897 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -81,7 +81,7 @@ BattleTransitions: ; 70a3c (1c:4a3c)
dw BattleTransition_Split ; %111
GetBattleTransitionID_WildOrTrainer: ; 70a4c (1c:4a4c)
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
cp 200
jr nc, .trainer
res 0, c
@@ -105,7 +105,7 @@ GetBattleTransitionID_CompareLevels: ; 70a59 (1c:4a59)
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: ; 70a59 (1c:4a59)
; MANSION_1, SEAFOAM_ISLANDS_[2-5], POWER_PLANT, DIGLETTS_CAVE
; and SILPH_CO_[9-11]F as dungeon maps
GetBattleTransitionID_IsDungeonMap: ; 70a83 (1c:4a83)
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld e, a
ld hl, DungeonMaps1
.loop1
@@ -151,7 +151,7 @@ GetBattleTransitionID_IsDungeonMap: ; 70a83 (1c:4a83)
res 2, c
ret
-; GetBattleTransitionID_IsDungeonMap checks if W_CURMAP
+; GetBattleTransitionID_IsDungeonMap checks if wCurMap
; is equal to one of these maps
DungeonMaps1: ; 70aa9 (1c:4aa9)
db VIRIDIAN_FOREST
@@ -160,7 +160,7 @@ DungeonMaps1: ; 70aa9 (1c:4aa9)
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: ; 70aac (1c:4aac)
; all MT_MOON maps
diff --git a/engine/battle/common_text.asm b/engine/battle/common_text.asm
index 449fc1ab..0cbf70f0 100644
--- a/engine/battle/common_text.asm
+++ b/engine/battle/common_text.asm
@@ -1,8 +1,8 @@
PrintBeginningBattleText: ; f4000 (3d:4000)
- ld a, [W_ISINBATTLE] ; W_ISINBATTLE
+ ld a, [wIsInBattle] ; W_ISINBATTLE
dec a
jr nz, .trainerBattle
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp POKEMONTOWER_3
jr c, .notPokemonTower
cp LAVENDER_HOUSE_1
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index e5fd98f8..ac7ddcdc 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -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
@@ -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
@@ -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]
@@ -863,7 +863,7 @@ 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
@@ -1003,7 +1003,7 @@ 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
@@ -1068,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
@@ -1140,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
@@ -1221,7 +1221,7 @@ HandlePlayerBlackOut: ; 3c837 (f:4837)
ld a, [wLinkState]
cp LINK_STATE_BATTLING
jr z, .notSony1Battle
- ld a, [W_CUROPPONENT]
+ ld a, [wCurOpponent]
cp OPP_SONY1
jr nz, .notSony1Battle
coord hl, 0, 0 ; sony 1 battle
@@ -1232,7 +1232,7 @@ 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
@@ -1432,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
@@ -1459,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
@@ -1589,7 +1589,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9)
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]
@@ -1787,7 +1787,7 @@ LoadEnemyMonFromParty: ; 3cc13 (f:4c13)
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
@@ -2106,7 +2106,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3)
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 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
@@ -2156,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
@@ -2189,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
@@ -3039,7 +3039,7 @@ SelectEnemyMove: ; 3d564 (f:5564)
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
@@ -3364,10 +3364,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
@@ -3541,7 +3541,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
jr z,.ThrashingAboutCheck
xor a
ld [W_PLAYERMOVENUM],a
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
ld b,a
ld c,[hl]
@@ -3568,10 +3568,10 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854)
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
@@ -3943,7 +3943,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, W_DAMAGE 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]
@@ -4230,7 +4230,7 @@ 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
@@ -4342,7 +4342,7 @@ 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
@@ -4479,7 +4479,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
@@ -4585,7 +4585,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
@@ -4688,7 +4688,7 @@ 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]
@@ -4793,11 +4793,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]
@@ -4833,7 +4833,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df)
.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
@@ -4878,14 +4878,14 @@ 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]
@@ -4909,7 +4909,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
@@ -4952,7 +4952,7 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
.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
@@ -4997,14 +4997,14 @@ 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]
@@ -5029,7 +5029,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
@@ -5075,7 +5075,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld de,wPlayerSubstituteHP
ld bc,W_PLAYERBATTSTATUS2
.applyDamageToSubstitute
- ld hl,W_DAMAGE
+ ld hl,wDamage
ld a,[hli]
and a
jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes
@@ -5085,7 +5085,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
@@ -5315,7 +5315,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
@@ -5326,9 +5326,9 @@ 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
@@ -5361,7 +5361,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]
@@ -5536,7 +5536,7 @@ 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
@@ -5627,7 +5627,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
@@ -5656,7 +5656,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
@@ -6067,7 +6067,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
jr z, .checkIfThrashingAbout
xor a
ld [W_ENEMYMOVENUM], a
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld a, [hli]
ld b, a
ld c, [hl]
@@ -6094,10 +6094,10 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
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
@@ -6209,7 +6209,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
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
@@ -6224,7 +6224,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
@@ -6232,7 +6232,7 @@ 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]
@@ -6264,7 +6264,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
@@ -6275,7 +6275,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
@@ -6288,7 +6288,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
@@ -6310,7 +6310,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
@@ -6319,7 +6319,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
@@ -7751,10 +7751,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
@@ -7793,12 +7793,12 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
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
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index c1387b7b..cc0219eb 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
diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm
index f1de313c..2f84c6fe 100755
--- a/engine/battle/end_of_battle.asm
+++ b/engine/battle/end_of_battle.asm
@@ -47,10 +47,10 @@ EndOfBattle: ; 137aa (4:77aa)
xor a
ld [wLowHealthAlarm], a ;disable low health alarm
ld [wChannelSoundIDs + CH4], a
- ld [W_ISINBATTLE], a
+ ld [wIsInBattle], a
ld [W_BATTLETYPE], a
ld [W_MOVEMISSED], a
- ld [W_CUROPPONENT], 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 ab3e3c19..65e18999 100644
--- a/engine/battle/experience.asm
+++ b/engine/battle/experience.asm
@@ -83,7 +83,7 @@ GainExperience: ; 5524f (15:524f)
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
@@ -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
@@ -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 d393b800..cf09ac66 100644
--- a/engine/battle/get_trainer_name.asm
+++ b/engine/battle/get_trainer_name.asm
@@ -1,5 +1,5 @@
GetTrainerName_: ; f67a5 (3d:67a5)
- ld hl, W_GRASSRATE
+ ld hl, wGrassRate
ld a, [wLinkState]
and a
jr nz, .foundName
diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm
index 78f4ad22..5383a546 100644
--- a/engine/battle/init_battle_variables.asm
+++ b/engine/battle/init_battle_variables.asm
@@ -27,7 +27,7 @@ InitBattleVariables: ; f6236 (3d:6236)
jr nz, .loop
inc a ; POUND
ld [wTestBattlePlayerSelectedMove], a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
cp SAFARI_ZONE_EAST
jr c, .notSafariBattle
cp SAFARI_ZONE_REST_HOUSE_1
diff --git a/engine/battle/moveEffects/drain_hp_effect.asm b/engine/battle/moveEffects/drain_hp_effect.asm
index 1096794f..e977af32 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
diff --git a/engine/battle/moveEffects/one_hit_ko_effect.asm b/engine/battle/moveEffects/one_hit_ko_effect.asm
index c1dde6ff..12f70b90 100644
--- a/engine/battle/moveEffects/one_hit_ko_effect.asm
+++ b/engine/battle/moveEffects/one_hit_ko_effect.asm
@@ -1,5 +1,5 @@
OneHitKOEffect_: ; f64db (3d:64db)
- 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_: ; f64db (3d:64db)
ld a, [hl]
sbc b
jr c, .userIsSlower
- ld hl, W_DAMAGE
+ ld hl, wDamage
ld a, $ff
ld [hli], a
ld [hl], a
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 51232af6..9b165932 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -8,9 +8,9 @@ RecoilEffect_: ; 1392c (4:792c)
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/substitute_effect.asm b/engine/battle/moveEffects/substitute_effect.asm
index c72fffbe..54b752ef 100644
--- a/engine/battle/moveEffects/substitute_effect.asm
+++ b/engine/battle/moveEffects/substitute_effect.asm
@@ -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 fef6f7aa..bf252600 100644
--- a/engine/battle/moveEffects/transform_effect.asm
+++ b/engine/battle/moveEffects/transform_effect.asm
@@ -29,7 +29,7 @@ TransformEffect_: ; f637f (3d:637f)
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)
diff --git a/engine/battle/print_type.asm b/engine/battle/print_type.asm
index 38c701a8..0270f8b7 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
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 37a45476..9f94981e 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
@@ -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,7 +100,7 @@ ReadTrainer: ; 39c53 (e:5c53)
; check if our trainer's team has special moves
; get trainer class number
- ld a,[W_CUROPPONENT]
+ ld a,[wCurOpponent]
sub 200
ld b,a
ld hl,TeamMoves
@@ -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 00627d74..69439199 100755
--- a/engine/battle/safari_zone.asm
+++ b/engine/battle/safari_zone.asm
@@ -18,7 +18,7 @@ PrintSafariZoneBattleText: ; 4111 (1:4111)
ld a, [wEnemyMonSpecies]
ld [wd0b5], a
call GetMonHeader
- ld a, [W_MONHCATCHRATE]
+ ld a, [wMonHCatchRate]
ld [wEnemyMonCatchRate], a
pop hl
.asm_4138
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index afb04216..072d3c8a 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -338,7 +338,7 @@ 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]
diff --git a/engine/battle/wild_encounters.asm b/engine/battle/wild_encounters.asm
index 908bd493..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, [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 059b309a..2ec470df 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -1,7 +1,7 @@
; performs the appropriate action when the player uses the gameboy on the table in the Colosseum or Trade Center
; In the Colosseum, it starts a battle. In the Trade Center, it displays the trade selection screen.
; Before doing either action, it swaps random numbers, trainer names and party data with the other gameboy.
-CableClub_DoBattleOrTrade: ; 5317 (1:5317)
+CableClub_DoBattleOrTrade: ; 53a5 (1:53a5)
ld c, 80
call DelayFrames
call ClearScreen
@@ -10,8 +10,7 @@ CableClub_DoBattleOrTrade: ; 5317 (1:5317)
call LoadHpBarAndStatusTilePatterns
call LoadTrainerInfoTextBoxTiles
coord hl, 3, 8
- ld b, 2
- ld c, 12
+ lb bc, 2, 12
call CableClub_TextBoxBorder
coord hl, 4, 10
ld de, PleaseWaitString
@@ -23,14 +22,14 @@ CableClub_DoBattleOrTrade: ; 5317 (1:5317)
; fall through
; This is called after completing a trade.
-CableClub_DoBattleOrTradeAgain: ; 5345
+CableClub_DoBattleOrTradeAgain: ; 53d2 (1:53d2)
ld hl, wSerialPlayerDataBlock
ld a, SERIAL_PREAMBLE_BYTE
ld b, 6
-.writePlayeDataBlockPreambleLoop
+.writePlayerDataBlockPreambleLoop
ld [hli], a
dec b
- jr nz, .writePlayeDataBlockPreambleLoop
+ jr nz, .writePlayerDataBlockPreambleLoop
ld hl, wSerialRandomNumberListBlock
ld a, SERIAL_PREAMBLE_BYTE
ld b, 7
@@ -57,8 +56,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
@@ -119,6 +118,7 @@ CableClub_DoBattleOrTradeAgain: ; 5345
ld [rSC], a
.skipSendingTwoZeroBytes
call Delay3
+ call StopAllMusic
ld a, (1 << SERIAL)
ld [rIE], a
ld hl, wSerialRandomNumberListBlock
@@ -139,8 +139,6 @@ CableClub_DoBattleOrTradeAgain: ; 5345
call Serial_ExchangeBytes
ld a, (1 << SERIAL) | (1 << TIMER) | (1 << VBLANK)
ld [rIE], a
- ld a, $ff
- call PlaySound
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
jr z, .skipCopyingRandomNumberList ; the list generated by the gameboy clocking the connection is used by both gameboys
@@ -186,7 +184,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
@@ -255,14 +253,13 @@ CableClub_DoBattleOrTradeAgain: ; 5345
ld hl, wEnemyMons + (SERIAL_PREAMBLE_BYTE - 1)
dec c
jr nz, .unpatchEnemyMonsLoop
- ld a, wEnemyMonOT % $100
+ ld a, wEnemyMonOT & $ff
ld [wUnusedCF8D], a
ld a, wEnemyMonOT / $100
ld [wUnusedCF8D + 1], a
xor a
ld [wTradeCenterPointerTableIndex], a
- ld a, $ff
- call PlaySound
+ call StopAllMusic
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ld c, 66
@@ -271,28 +268,36 @@ CableClub_DoBattleOrTradeAgain: ; 5345
cp LINK_STATE_START_BATTLE
ld a, LINK_STATE_TRADING
ld [wLinkState], a
- jr nz, .asm_5506
+ jr nz, .asm_55a0
ld a, LINK_STATE_BATTLING
ld [wLinkState], a
ld a, OPP_SONY1
- ld [W_CUROPPONENT], a
+ ld [wCurOpponent], a
call ClearScreen
call Delay3
- ld hl, W_OPTIONS
+ ld b, $9
+ call RunPaletteCommand
+ ld hl, wOptions
res 7, [hl]
+ ld a, [wLetterPrintingDelayFlags]
+ push af
+ xor a
+ ld [wLetterPrintingDelayFlags], a
predef InitOpponent
+ pop af
+ ld [wLetterPrintingDelayFlags], a
predef HealParty
jp ReturnToCableClubRoom
-.asm_5506
+.asm_55a0
ld c, BANK(Music_GameCorner)
ld a, MUSIC_GAME_CORNER
call PlayMusic
jr CallCurrentTradeCenterFunction
-PleaseWaitString: ; 550f (1:550f)
+PleaseWaitString: ; 55a9 (1:55a9)
db "PLEASE WAIT!@"
-CallCurrentTradeCenterFunction:
+CallCurrentTradeCenterFunction: ; 55b6 (1:55b6)
ld hl, TradeCenterPointerTable
ld b, 0
ld a, [wTradeCenterPointerTableIndex]
@@ -306,8 +311,11 @@ CallCurrentTradeCenterFunction:
ld l, a
jp [hl]
-TradeCenter_SelectMon:
+TradeCenter_SelectMon: ; 55ca (1:55ca)
call ClearScreen
+ call Delay3
+ ld b, $9
+ call RunPaletteCommand
call LoadTrainerInfoTextBoxTiles
call TradeCenter_DrawPartyLists
call TradeCenter_DrawCancelBox
@@ -438,6 +446,7 @@ TradeCenter_SelectMon:
ld a, [wEnemyPartyCount]
dec a
cp b
+ ; continue
jr nc, .notPastLastEnemyMon
; when switching to the enemy mon menu, if the menu selection would be past the last enemy mon, select the last enemy mon
ld [wCurrentMenuItem], a
@@ -465,8 +474,7 @@ TradeCenter_SelectMon:
.displayStatsTradeMenu
push af
coord hl, 0, 14
- ld b, 2
- ld c, 18
+ lb bc, 2, 18
call CableClub_TextBoxBorder
coord hl, 2, 16
ld de, .statsTrade
@@ -576,7 +584,7 @@ TradeCenter_SelectMon:
jr nz, .cancelMenuItem_Loop
; fall through
-ReturnToCableClubRoom: ; 577d (1:577d)
+ReturnToCableClubRoom: ; 581e (1:581e)
call GBPalWhiteOutWithDelay3
ld hl, wFontLoaded
ld a, [hl]
@@ -595,23 +603,22 @@ ReturnToCableClubRoom: ; 577d (1:577d)
call GBFadeInFromWhite
ret
-TradeCenter_DrawCancelBox:
+TradeCenter_DrawCancelBox: ; 5843 (1:5843)
coord hl, 11, 15
ld a, $7e
ld bc, 2 * SCREEN_WIDTH + 9
call FillMemory
coord hl, 0, 15
- ld b, 1
- ld c, 9
+ lb bc, 1, 9
call CableClub_TextBoxBorder
coord hl, 2, 16
ld de, CancelTextString
jp PlaceString
-CancelTextString:
+CancelTextString: ; 5860 (1:5860)
db "CANCEL@"
-TradeCenter_PlaceSelectedEnemyMonMenuCursor:
+TradeCenter_PlaceSelectedEnemyMonMenuCursor: ; 5867 (1:5867)
ld a, [wSerialSyncAndExchangeNybbleReceiveData]
coord hl, 1, 9
ld bc, SCREEN_WIDTH
@@ -619,24 +626,25 @@ TradeCenter_PlaceSelectedEnemyMonMenuCursor:
ld [hl], $ec ; cursor
ret
-TradeCenter_DisplayStats:
+TradeCenter_DisplayStats: ; 5876 (1:5876)
ld a, [wCurrentMenuItem]
ld [wWhichPokemon], a
predef StatusScreen
predef StatusScreen2
+ call Delay3
+ ld b, $9
+ call RunPaletteCommand
call GBPalNormal
call LoadTrainerInfoTextBoxTiles
call TradeCenter_DrawPartyLists
jp TradeCenter_DrawCancelBox
-TradeCenter_DrawPartyLists:
+TradeCenter_DrawPartyLists: ; 589a (1:589a)
coord hl, 0, 0
- ld b, 6
- ld c, 18
+ lb bc, 6, 18
call CableClub_TextBoxBorder
coord hl, 0, 8
- ld b, 6
- ld c, 18
+ lb bc, 6, 18
call CableClub_TextBoxBorder
coord hl, 5, 0
ld de, wPlayerName
@@ -651,7 +659,7 @@ TradeCenter_DrawPartyLists:
ld de, wEnemyPartyMons
; fall through
-TradeCenter_PrintPartyListNames:
+TradeCenter_PrintPartyListNames: ; 58cd (1:58cd)
ld c, $0
.loop
ld a, [de]
@@ -676,7 +684,7 @@ TradeCenter_PrintPartyListNames:
inc c
jr .loop
-TradeCenter_Trade:
+TradeCenter_Trade: ; 58ef (1:58ef)
ld c, 100
call DelayFrames
xor a
@@ -685,8 +693,7 @@ TradeCenter_Trade:
ld [wMenuWatchMovingOutOfBounds], a
ld [wMenuJoypadPollCount], a
coord hl, 0, 12
- ld b, 4
- ld c, 18
+ lb bc, 4, 18
call CableClub_TextBoxBorder
ld a, [wTradingWhichPlayerMon]
ld hl, wPartySpecies
@@ -727,8 +734,7 @@ TradeCenter_Trade:
ld a, $1
ld [wSerialExchangeNybbleSendData], a
coord hl, 0, 12
- ld b, 4
- ld c, 18
+ lb bc, 4, 18
call CableClub_TextBoxBorder
coord hl, 1, 14
ld de, TradeCanceled
@@ -744,8 +750,7 @@ TradeCenter_Trade:
jr nz, .doTrade
; if the other person cancelled
coord hl, 0, 12
- ld b, 4
- ld c, 18
+ lb bc, 4, 18
call CableClub_TextBoxBorder
coord hl, 1, 14
ld de, TradeCanceled
@@ -792,6 +797,7 @@ TradeCenter_Trade:
add hl, bc
ld a, [hl]
ld [wTradedPlayerMonSpecies], a
+ callabd_ModifyPikachuHappiness PIKAHAPPY_TRADE
xor a
ld [wRemoveMonFromBox], a
call RemovePokemon
@@ -845,15 +851,18 @@ TradeCenter_Trade:
.usingExternalClock
predef ExternalClockTradeAnim
.tradeCompleted
+; continue
callab TryEvolvingMon
call ClearScreen
call LoadTrainerInfoTextBoxTiles
call Serial_PrintWaitingTextAndSyncAndExchangeNybble
ld c, 40
call DelayFrames
+ call Delay3
+ ld b, $9
+ call RunPaletteCommand
coord hl, 0, 12
- ld b, 4
- ld c, 18
+ lb bc, 4, 18
call CableClub_TextBoxBorder
coord hl, 1, 14
ld de, TradeCompleted
@@ -871,22 +880,22 @@ TradeCenter_Trade:
ld [wTradeCenterPointerTableIndex], a
jp CallCurrentTradeCenterFunction
-WillBeTradedText: ; 5a24 (1:5a24)
+WillBeTradedText: ; 5ad8 (1:5ad8)
TX_FAR _WillBeTradedText
db "@"
-TradeCompleted:
+TradeCompleted: ; 5add (1:5add)
db "Trade completed!@"
-TradeCanceled:
+TradeCanceled: ; 5aee (1:5aee)
db "Too bad! The trade"
next "was canceled!@"
-TradeCenterPointerTable: ; 5a5b (1:5a5b)
+TradeCenterPointerTable: ; 5b0f (1:5b0f)
dw TradeCenter_SelectMon
dw TradeCenter_Trade
-CableClub_Run: ; 5a5f (1:5a5f)
+CableClub_Run: ; 5b13 (1:5b13)
ld a, [wLinkState]
cp LINK_STATE_START_TRADE
jr z, .doBattleOrTrade
@@ -900,18 +909,18 @@ 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
@@ -923,15 +932,15 @@ CableClub_Run: ; 5a5f (1:5a5f)
ld [wNewSoundID], a
jp PlaySound
-EmptyFunc3: ; 5aaf (1:5aaf)
+EmptyFunc3: ; 5b63 (1:5b63)
ret
-Diploma_TextBoxBorder: ; 5ab0 (1:5ab0)
+Diploma_TextBoxBorder: ; 5b64 (1:5b64)
call GetPredefRegisters
; b = height
; c = width
-CableClub_TextBoxBorder: ; 5ab3 (1:5ab3)
+CableClub_TextBoxBorder: ; 5b67 (1:5b67)
push hl
ld a, $78 ; border upper left corner tile
ld [hli], a
@@ -962,10 +971,10 @@ CableClub_TextBoxBorder: ; 5ab3 (1:5ab3)
ret
; c = width
-CableClub_DrawHorizontalLine: ; 5ae0 (1:5ae0)
+CableClub_DrawHorizontalLine: ; 5b94 (1:5b94)
ld d, c
-.asm_5ae1
+.drawHorizontalLineLoop
ld [hli], a
dec d
- jr nz, .asm_5ae1
- ret
+ jr nz, .drawHorizontalLineLoop
+ ret \ No newline at end of file
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 056c125e..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_MONHINDEX], 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]
@@ -262,7 +262,7 @@ RenameEvolvedMon: ; 3aef7 (e:6ef7)
; nickname, in which case the nickname is kept.
ld a, [wd0b5]
push af
- ld a, [W_MONHINDEX]
+ ld a, [wMonHIndex]
ld [wd0b5], a
call GetName
pop af
@@ -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]
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/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 ba6d1fd3..e43ae451 100755
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -78,7 +78,7 @@ IndigoPlateauStatues: ; fa4d (3:7a4d)
TX_ASM
ld hl, IndigoPlateauStatuesText1
call PrintText
- ld a, [W_XCOORD]
+ ld a, [wXCoord]
bit 0, a
ld hl, IndigoPlateauStatuesText2
jr nz, .asm_fa61
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index 02d3928a..b61dc68a 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -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
@@ -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
diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm
index 553f550d..80cb27f3 100755
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -100,20 +100,20 @@ InGameTrade_DoTrade: ; 71ca9 (1c:5ca9)
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
ld a,[hl]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
ld b,FLAG_SET
call InGameTrade_FlagActionPredef
ld hl, ConnectCableText
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]
diff --git a/engine/intro.asm b/engine/intro.asm
index 6d2e350c..5a14dca7 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -312,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
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 2b3c1840..8671e34a 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -101,7 +101,7 @@ ItemUsePtrTable: ; d307 (3:5307)
dw ItemUsePPRestore ; MAX_ELIXER
ItemUseBall: ; d3ad (3:53ad)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime ; not in battle
dec a
@@ -126,7 +126,7 @@ ItemUseBall: ; d3ad (3:53ad)
jr nz,.skipSafariZoneCode
.safariZone
; remove a Safari Ball from inventory
- ld hl,W_NUMSAFARIBALLS
+ ld hl,wNumSafariBalls
dec [hl]
.skipSafariZoneCode
call RunDefaultPaletteCommand
@@ -145,7 +145,7 @@ ItemUseBall: ; d3ad (3:53ad)
jr z,.oldManBattle ; pikachu battle technically old man battle
jr .notOldManBattle
.oldManBattle
- ld hl,W_GRASSRATE
+ ld hl,wGrassRate
ld de,wPlayerName
ld bc,NAME_LENGTH
call CopyData ; save the player's name in the Wild Monster data
@@ -160,7 +160,7 @@ ItemUseBall: ; d3ad (3:53ad)
jp nz,.next12
jp .BallSuccess
.notOldManBattle
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
cp a,POKEMONTOWER_6
jr nz,.loop
ld a,[wEnemyMonSpecies2]
@@ -390,7 +390,7 @@ ItemUseBall: ; d3ad (3:53ad)
ld a,[wEnemyMonSpecies2]
ld [wcf91],a
ld a,[wEnemyMonLevel]
- ld [W_CURENEMYLVL],a
+ ld [wCurEnemyLVL],a
callab LoadEnemyMonData
pop af
ld [wcf91],a
@@ -522,13 +522,13 @@ ItemUseBallText06: ; d6c1 (3:56c1)
db "@"
ItemUseTownMap: ; d6c8 (3:56c8)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
jpba DisplayTownMap
ItemUseBicycle: ; d6d7 (3:56d7)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wWalkBikeSurfState]
@@ -652,7 +652,7 @@ ItemUsePokedex: ; d7cb (3:57cb)
predef_jump ShowPokedexMenu
ItemUseEvoStone: ; d7d0 (3:57d0)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wWhichPokemon]
@@ -757,7 +757,7 @@ RefusingText: ; d8a2 (3:58a2)
db "@"
ItemUseVitamin: ; d8a7 (3:58a7)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
@@ -903,7 +903,7 @@ ItemUseMedicine: ; d8ae (3:58ae)
pop af
ld [wWhichPokemon], a
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr z,.compareCurrentHPToMaxHP
push hl
@@ -1221,7 +1221,7 @@ ItemUseMedicine: ; d8ae (3:58ae)
ret nz ; if so, return
call GBPalWhiteOut
call z,RunDefaultPaletteCommand
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
ret nz
jp ReloadMapData
@@ -1233,7 +1233,7 @@ ItemUseMedicine: ; d8ae (3:58ae)
ld bc,33
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
@@ -1312,7 +1312,7 @@ ItemUseMedicine: ; d8ae (3:58ae)
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
@@ -1473,10 +1473,10 @@ ThrewRockText: ; ddca (3:5dca)
; also used for Dig out-of-battle effect
ItemUseEscapeRope: ; ddcf (3:5dcf)
- 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
cp a,BILLS_HOUSE
@@ -1501,7 +1501,7 @@ ItemUseEscapeRope: ; ddcf (3:5dcf)
ld hl,wd790
res 7,[hl]
xor a
- ld [W_NUMSAFARIBALLS],a
+ ld [wNumSafariBalls],a
ld [W_SAFARIZONEENTRANCECURSCRIPT],a
inc a
ld [wEscapedFromBattle],a
@@ -1524,7 +1524,7 @@ ItemUseRepel: ; de2e (3:5e2e)
ld b,100
ItemUseRepelCommon: ; e005 (3:6005)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,b
@@ -1533,7 +1533,7 @@ ItemUseRepelCommon: ; e005 (3:6005)
; handles X Accuracy item
ItemUseXAccuracy: ; de3e (3:5e3e)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
ld hl,W_PLAYERBATTSTATUS2
@@ -1562,7 +1562,7 @@ ItemUseCardKey: ; de57 (3:de57)
jp nz,ItemUseNotTime
ld hl,CardKeyTable3
.next1
- ld a,[W_CURMAP]
+ ld a,[wCurMap]
ld b,a
.loop
ld a,[hli]
@@ -1635,7 +1635,7 @@ CardKeyTable3: ; def9 (3:5ef9)
db $ff
ItemUsePokedoll: ; df02 (3:5f02)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
dec a
jp nz,ItemUseNotTime
ld a,$01
@@ -1643,7 +1643,7 @@ ItemUsePokedoll: ; df02 (3:5f02)
jp PrintItemUseTextAndRemoveItem
ItemUseGuardSpec: ; df11 (3:5f11)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
@@ -1668,7 +1668,7 @@ ItemUseMaxRepel: ; df3d (3:5f3d)
jp ItemUseRepelCommon
ItemUseDireHit: ; df42 (3:5f42)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp z,ItemUseNotTime
@@ -1685,7 +1685,7 @@ ItemUseDireHit: ; df42 (3:5f42)
jp PrintItemUseTextAndRemoveItem
ItemUseXStat: ; df69 (3:df69)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr nz,.inBattle
call ItemUseNotTime
@@ -1727,12 +1727,12 @@ ItemUseXStat: ; df69 (3:df69)
ret
ItemUsePokeflute: ; dfbd (3:5fbd)
- 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
ld a, [wd7d8]
@@ -1784,7 +1784,7 @@ ItemUsePokeflute: ; dfbd (3:5fbd)
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
@@ -1883,7 +1883,7 @@ PlayedFluteHadEffectText: ; e0c4 (3:60c4)
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
@@ -1900,7 +1900,7 @@ PlayedFluteHadEffectText: ; e0c4 (3:60c4)
jp TextScriptEnd ; end text
ItemUseCoinCase: ; e0e7 (3:60e7)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld hl,CoinCaseNumCoinsText
@@ -1974,9 +1974,9 @@ RodResponse: ; e15b (3:615b)
ld a, 1
ld [W_MOVEMISSED], a
ld a, b ; level
- ld [W_CURENEMYLVL], a
+ ld [wCurEnemyLVL], a
ld a, c ; species
- ld [W_CUROPPONENT], a
+ ld [wCurOpponent], a
DoNotGenerateFishingEncounter: ; e16e (3:616e)
ld hl, wWalkBikeSurfState
@@ -1993,7 +1993,7 @@ DoNotGenerateFishingEncounter: ; e16e (3:616e)
; 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: ; e182 (3:6182)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jr z,.notInBattle
scf ; can't fish during battle
@@ -2025,7 +2025,7 @@ ItemUseOaksParcel: ; e1b7 (3:61b7)
jp ItemUseNotYoursToUse
ItemUseItemfinder: ; e1ba (3:61ba)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
call ItemUseReloadOverworldData
@@ -2053,7 +2053,7 @@ ItemfinderFoundNothingText: ; e1eb (3:61eb)
db "@"
ItemUsePPUp: ; e1f0 (3:61f0)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
@@ -2071,7 +2071,7 @@ ItemUsePPRestore: ; e1f7 (3:61f7)
jr nc,.chooseMove
jp .itemNotUsed
.chooseMove
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jr z, .usePPItem
ld a, [wWhichPokemon]
@@ -2274,7 +2274,7 @@ UnusableItem: ; e371 (3:6371)
jp ItemUseNotTime
ItemUseTMHM: ; e374 (3:6374)
- ld a,[W_ISINBATTLE]
+ ld a,[wIsInBattle]
and a
jp nz,ItemUseNotTime
ld a,[wcf91]
@@ -2929,7 +2929,7 @@ SendNewMonToBox: ; e6e8 (3:66e8)
ld [de], a
inc de
push de
- ld a, [W_CURENEMYLVL]
+ ld a, [wCurEnemyLVL]
ld d, a
callab CalcExperience
pop de
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 ba96f29f..ec087d0c 100755
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -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]
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index 3ef1f95a..986bb339 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -559,7 +559,7 @@ CableClubLeftGameboy:: ; 21867 (8:5867)
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
@@ -576,7 +576,7 @@ CableClubRightGameboy:: ; 21887 (8:5887)
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/main_menu.asm b/engine/menu/main_menu.asm
index 98f1efdd..2e88dbcb 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -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)
@@ -626,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
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index 978216c8..167def51 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
@@ -169,7 +169,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld [W_SUBANIMTRANSFORM], a
ld hl, wd730
res 6, [hl]
- ld a, [W_ISINBATTLE]
+ ld a, [wIsInBattle]
and a
jp z, LoadTextBoxTilePatterns
jpab LoadHudTilePatterns
diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm
index 409f0bdb..626f670a 100755
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -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/status_screen.asm b/engine/menu/status_screen.asm
index 8775a8d9..807dce59 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
@@ -138,7 +138,7 @@ StatusScreen: ; 12953 (4:6953)
call PlaceString ; "STATUS/"
coord hl, 14, 2
call PrintLevel ; Pokémon level
- ld a, [W_MONHINDEX]
+ 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
@@ -417,7 +417,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call StatusScreen_ClearName
coord hl, 9, 1
call StatusScreen_ClearName
- ld a, [W_MONHINDEX]
+ ld a, [wMonHIndex]
ld [wd11e], a
call GetMonName
coord hl, 9, 1
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index 0de7ffad..2e28afc6 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]
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index cc9fe3a7..2ef7529c 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
@@ -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/cut.asm b/engine/overworld/cut.asm
index 8c863bf2..3a2b38cf 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -178,7 +178,7 @@ ReplaceTreeTileBlock: ; ef1f (3:6f1f)
; 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
@@ -196,22 +196,22 @@ ReplaceTreeTileBlock: ; ef1f (3:6f1f)
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/hidden_items.asm b/engine/overworld/hidden_items.asm
index 28528116..f7f81070 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -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..f4f46535 100644
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -1,9 +1,9 @@
-PickUpItem:
+PickUpItem: ; 4d55 (1:4d55)
call EnableAutoTextBoxDrawing
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
@@ -44,11 +44,11 @@ PickUpItem:
call PrintText
ret
-FoundItemText:
+FoundItemText: ; 4d9a (1:4d9a)
TX_FAR _FoundItemText
db $0B
db "@"
-NoMoreRoomForItemText:
+NoMoreRoomForItemText: ; 4da0 (1:4da0)
TX_FAR _NoMoreRoomForItemText
- db "@"
+ db "@" \ No newline at end of file
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm
index 84d67b36..eb4e2c03 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
@@ -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
@@ -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..dfd1c012 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -1,4 +1,4 @@
-UpdatePlayerSprite: ; 4e31 (1:4e31)
+UpdatePlayerSprite: ; 4da5 (1:4da5)
ld a, [wSpriteStateData2]
and a
jr z, .checkIfTextBoxInFrontOfSprite
@@ -20,7 +20,13 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
ld [wSpriteStateData1 + 2], a
ret
.lowerLeftTileIsMapTile
+ ld a, [wUpdateSpritesEnabled]
+ push af
+ ld a, $ff
+ ld [wUpdateSpritesEnabled], a
call DetectCollisionBetweenSprites
+ pop af
+ ld [wUpdateSpritesEnabled], a
ld h, wSpriteStateData1 / $100
ld a, [wWalkCounter]
and a
@@ -46,42 +52,24 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
jr z, .notMoving
ld a, SPRITE_FACING_RIGHT
jr .next
+.next
+ ld [wSpriteStateData1 + 9], a ; facing direction
+ ld a, [wFontLoaded]
+ bit 0, a
+ jr z, .moving
.notMoving
; zero the animation counters
xor a
ld [wSpriteStateData1 + 7], a
ld [wSpriteStateData1 + 8], a
- jr .calcImageIndex
-.next
- ld [wSpriteStateData1 + 9], a ; facing direction
- ld a, [wFontLoaded]
- bit 0, a
- jr nz, .notMoving
+ call Func_4e32
+ jr .skipSpriteAnim
.moving
ld a, [wd736]
bit 7, a ; is the player sprite spinning due to a spin tile?
jr nz, .skipSpriteAnim
- ld a, [H_CURRENTSPRITEOFFSET]
- add $7
- ld l, a
- ld a, [hl]
- inc a
- ld [hl], a
- cp 4
- jr nz, .calcImageIndex
- xor a
- ld [hl], a
- inc hl
- ld a, [hl]
- inc a
- and $3
- ld [hl], a
-.calcImageIndex
- ld a, [wSpriteStateData1 + 8]
- ld b, a
- ld a, [wSpriteStateData1 + 9]
- add b
- ld [wSpriteStateData1 + 2], a
+ call Func_5274
+ call Func_4e32
.skipSpriteAnim
; If the player is standing on a grass tile, make the player's sprite have
; lower priority than the background so that it's partially obscured by the
@@ -89,7 +77,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
@@ -98,28 +86,25 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
ld [wSpriteStateData2 + $07], a
ret
-UnusedReadSpriteDataFunction: ; 4ec7 (1:4ec7)
- push bc
- push af
- ld a, [H_CURRENTSPRITEOFFSET]
- ld c, a
- pop af
- add c
- ld l, a
- pop bc
+Func_4e32: ; 4e32 (1:4e32)
+ ld a, [wSpriteStateData1 + 8]
+ ld b, a
+ ld a, [wSpriteStateData1 + 9]
+ add b
+ ld [wSpriteStateData1 + 2], a
ret
-
-UpdateNPCSprite: ; 4ed1 (1:4ed1)
+
+UpdateNPCSprite: ; 4e3e (1:4e3e)
ld a, [H_CURRENTSPRITEOFFSET]
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
ld [wCurSpriteMovement2], a
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
ld l, a
inc l
@@ -128,7 +113,7 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
jp z, InitializeSpriteStatus
call CheckSpriteAvailability
ret c ; if sprite is invisible, on tile >=$60, in grass or player is currently walking
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
ld l, a
inc l
@@ -144,19 +129,21 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
jp z, UpdateSpriteMovementDelay ; c1x1 == 2
cp $3
jp z, UpdateSpriteInWalkingAnimation ; c1x1 == 3
+ cp $4
+ jp z, Func_5357
ld a, [wWalkCounter]
and a
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
ld a, [hl] ; c2x6: movement byte 1
inc a
- jr z, .randomMovement ; value $FF
+ jp z, .randomMovement ; value $FF
inc a
- jr z, .randomMovement ; value $FE
+ jp z, .randomMovement ; value $FE
; scripted movement
dec a
ld [hl], a ; increment movement byte 1 (movement data index)
@@ -181,12 +168,18 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
ret
.next
cp $fe
- jr nz, .determineDirection
+ jr nz, .asm_4ecb
; current NPC movement data is $fe. this seems buggy
ld [hl], $1 ; set movement byte 1 to $1
ld de, wNPCMovementDirections
call LoadDEPlusA ; a = [wNPCMovementDirections + $fe] (?)
- jr .determineDirection
+.asm_4ecb
+ push af
+ call Func_5288
+ pop bc
+ ld a, b
+ jr nc, .determineDirection
+ ret
.randomMovement
call GetTileSpriteStandsOn
call Random
@@ -249,7 +242,7 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
jr TryWalking
; changes facing direction by zeroing the movement delta and calling TryWalking
-ChangeFacingDirection: ; 4fc8 (1:4fc8)
+ChangeFacingDirection: ; 4f43 (1:4f43)
ld de, $0
; fall through
@@ -259,61 +252,27 @@ ChangeFacingDirection: ; 4fc8 (1:4fc8)
; e: X movement delta (-1, 0 or 1)
; hl: pointer to tile the sprite would walk onto
; set carry on failure, clears carry on success
-TryWalking: ; 4fcb (1:4fcb)
+TryWalking: ; 4f46 (1:4f46)
push hl
- ld h, $c1
- ld a, [H_CURRENTSPRITEOFFSET]
- add $9
- ld l, a
- ld [hl], c ; c1x9 (update facing direction)
- ld a, [H_CURRENTSPRITEOFFSET]
- add $3
- ld l, a
- ld [hl], d ; c1x3 (update Y movement delta)
- inc l
- inc l
- ld [hl], e ; c1x5 (update X movement delta)
+ call Func_5337
pop hl
push de
- ld c, [hl] ; read tile to walk onto
+ ld c, [hl]
call CanWalkOntoTile
pop de
- ret c ; cannot walk there (reinitialization of delay values already done)
- ld h, $c2
+ ret c
+ call Func_5349
ld a, [H_CURRENTSPRITEOFFSET]
- add $4
ld l, a
- ld a, [hl] ; c2x4: Y position
- add d
- ld [hli], a ; update Y position
- ld a, [hl] ; c2x5: X position
- add e
- ld [hl], a ; update X position
- ld a, [H_CURRENTSPRITEOFFSET]
- ld l, a
- ld [hl], $10 ; c2x0=16: walk animation counter
+ ld [hl], $10 ; c1x9 (update facing direction)
dec h
inc l
- ld [hl], $3 ; c1x1: set movement status to walking
+ ld [hl], $3
jp UpdateSpriteImage
; update the walking animation parameters for a sprite that is currently walking
-UpdateSpriteInWalkingAnimation: ; 4ffe (1:4ffe)
- ld a, [H_CURRENTSPRITEOFFSET]
- add $7
- ld l, a
- ld a, [hl] ; c1x7 (counter until next walk animation frame)
- inc a
- ld [hl], a ; c1x7 += 1
- cp $4
- jr nz, .noNextAnimationFrame
- xor a
- ld [hl], a ; c1x7 = 0
- inc l
- ld a, [hl] ; c1x8 (walk animation frame)
- inc a
- and $3
- ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step)
+UpdateSpriteInWalkingAnimation: ; 4f61 (1:4f61)
+ call Func_5274
.noNextAnimationFrame
ld a, [H_CURRENTSPRITEOFFSET]
add $3
@@ -371,7 +330,7 @@ UpdateSpriteInWalkingAnimation: ; 4ffe (1:4ffe)
ret
; update delay value (c2x8) for sprites in the delayed state (c1x1)
-UpdateSpriteMovementDelay: ; 5057 (1:5057)
+UpdateSpriteMovementDelay: ; 4fa9 (1:4fa9)
ld h, $c2
ld a, [H_CURRENTSPRITEOFFSET]
add $6
@@ -392,15 +351,15 @@ UpdateSpriteMovementDelay: ; 5057 (1:5057)
inc a
ld l, a
ld [hl], $1 ; c1x1 = 1 (mark as ready to move)
-notYetMoving: ; 5073 (1:5073)
- ld h, $c1
+notYetMoving: ; 4fc5 (1:4fc5)
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $8
ld l, a
ld [hl], $0 ; c1x8 = 0 (walk animation frame)
jp UpdateSpriteImage
-InitializeSpriteFacingDirection: ; 507f (1:507f)
+InitializeSpriteFacingDirection: ; 4fd1 (1:4fd1)
ld a, [wd72d]
bit 5, a
jr nz, notYetMoving
@@ -429,7 +388,7 @@ InitializeSpriteFacingDirection: ; 507f (1:507f)
ld [hl], c ; c1x9: set facing direction
jr notYetMoving
-InitializeSpriteStatus: ; 50ad (1:50ad)
+InitializeSpriteStatus: ; 4fff (1:4fff)
ld [hl], $1 ; $c1x1: set movement status to ready
inc l
ld [hl], $ff ; $c1x2: set sprite image to $ff (invisible/off screen)
@@ -440,39 +399,52 @@ InitializeSpriteStatus: ; 50ad (1:50ad)
ld a, $8
ld [hli], a ; $c2x2: set Y displacement to 8
ld [hl], a ; $c2x3: set X displacement to 8
+ call InitializeSpriteScreenPosition ; could have done fallthrough here
ret
; calculates the spprite's scrren position form its map position and the player position
-InitializeSpriteScreenPosition: ; 50bd (1:50bd)
- ld h, $c2
+InitializeSpriteScreenPosition: ; 5012 (1:5012)
+ ld h, wSpriteStateData2 / $100
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
- swap a ; * 16
+ call Func_5033
sub $4 ; - 4
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
- swap a ; * 16
+ call Func_5033
dec h
ld [hl], a ; c1x6 (screen X position)
ret
+Func_5033: ; 5033 (1:5033)
+ jr nc, .asm_503c
+ cpl
+ inc a
+ swap a
+ cpl
+ inc a
+ ret
+.asm_503c
+ swap a
+ ret
+
; tests if sprite is off screen or otherwise unable to do anything
-CheckSpriteAvailability: ; 50dc (1:50dc)
+CheckSpriteAvailability: ; 503f (1:503f)
predef IsObjectHidden
ld a, [$ffe5]
and a
jp nz, .spriteInvisible
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
@@ -483,7 +455,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 +465,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
@@ -520,7 +492,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
cp d
jr c, .spriteVisible ; standing on tile with ID >=$60 (top right tile)
.spriteInvisible
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $2
ld l, a
@@ -537,7 +509,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
@@ -548,7 +520,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
.done
ret
-UpdateSpriteImage: ; 5157 (1:5157)
+UpdateSpriteImage: ; 50ba (1:50ba)
ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET]
add $8
@@ -573,8 +545,8 @@ UpdateSpriteImage: ; 5157 (1:5157)
; d: Y movement delta (-1, 0 or 1)
; e: X movement delta (-1, 0 or 1)
; set carry on failure, clears carry on success
-CanWalkOntoTile: ; 516e (1:516e)
- ld h, $c2
+CanWalkOntoTile: ; 50d1 (1:50d1)
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
@@ -585,24 +557,16 @@ CanWalkOntoTile: ; 516e (1:516e)
and a
ret
.notScripted
- ld a, [W_TILESETCOLLISIONPTR]
- ld l, a
- ld a, [W_TILESETCOLLISIONPTR+1]
- ld h, a
-.tilePassableLoop
- ld a, [hli]
- cp $ff
- jr z, .impassable
- cp c
- jr nz, .tilePassableLoop
- ld h, $c2
+ call _IsTilePassable
+ jr c, .impassable
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $6
ld l, a
ld a, [hl] ; $c2x6 (movement byte 1)
inc a
jr z, .impassable ; if $ff, no movement allowed (however, changing direction is)
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
@@ -618,17 +582,23 @@ CanWalkOntoTile: ; 516e (1:516e)
jr nc, .impassable ; don't walk off screen
push de
push bc
+ ld a, [wUpdateSpritesEnabled]
+ push af
+ ld a, $ff
+ ld [wUpdateSpritesEnabled], a
call DetectCollisionBetweenSprites
+ pop af
+ ld [wUpdateSpritesEnabled], a
pop bc
pop de
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $c
ld l, a
ld a, [hl] ; c1xc (directions in which sprite collision would occur)
and b ; check against chosen direction (1,2,4 or 8)
jr nz, .impassable ; collision between sprites, don't go there
- ld h, $c2
+ ld h, wSpriteStateData2 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $2
ld l, a
@@ -637,7 +607,7 @@ CanWalkOntoTile: ; 516e (1:516e)
jr nz, .upwards
add d
cp $5
- jr c, .impassable ; if c2x2+d < 5, don't go ;bug: this tests probably were supposed to prevent sprites
+ ;jr c, .impassable (bugfix) ; if c2x2+d < 5, don't go ;bug: this tests probably were supposed to prevent sprites
jr .checkHorizontal ; from walking out too far, but this line makes sprites get stuck
.upwards ; whenever they walked upwards 5 steps
sub $1 ; on the other hand, the amount a sprite can walk out to the
@@ -659,7 +629,7 @@ CanWalkOntoTile: ; 516e (1:516e)
and a ; clear carry (marking success)
ret
.impassable
- ld h, $c1
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
inc a
ld l, a
@@ -684,14 +654,14 @@ CanWalkOntoTile: ; 516e (1:516e)
; calculates the tile pointer pointing to the tile the current sprite stancs on
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer
-GetTileSpriteStandsOn: ; 5207 (1:5207)
- ld h, $c1
+GetTileSpriteStandsOn: ; 516a (1:516a)
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
add $4
ld l, a
ld a, [hli] ; c1x4: screen Y position
add $4 ; align to 2*2 tile blocks (Y position is always off 4 pixels to the top)
- and $f0 ; in case object is currently moving
+ and $f8 ; in case object is currently moving (XXX why changed to $f8?)
srl a ; screen Y tile * 4
ld c, a
ld b, $0
@@ -713,7 +683,7 @@ GetTileSpriteStandsOn: ; 5207 (1:5207)
ret
; loads [de+a] into a
-LoadDEPlusA: ; 522f (1:522f)
+LoadDEPlusA: ; 5192 (1:5192)
add e
ld e, a
jr nc, .noCarry
@@ -722,7 +692,7 @@ LoadDEPlusA: ; 522f (1:522f)
ld a, [de]
ret
-DoScriptedNPCMovement: ; 5236 (1:5236)
+DoScriptedNPCMovement: ; 5199 (1:5199)
; This is an alternative method of scripting an NPC's movement and is only used
; a few times in the game. It is used when the NPC and player must walk together
; in sync, such as when the player is following the NPC somewhere. An NPC can't
@@ -793,23 +763,23 @@ DoScriptedNPCMovement: ; 5236 (1:5236)
inc [hl]
ret
-InitScriptedNPCMovement: ; 52a6 (1:52a6)
+InitScriptedNPCMovement: ; 5209 (1:5209)
xor a
ld [wNPCMovementDirections2Index], a
ld a, 8
ld [wScriptedNPCWalkCounter], a
jp AnimScriptedNPCMovement
-GetSpriteScreenYPointer: ; 52b2 (1:52b2)
+GetSpriteScreenYPointer: ; 5215 (1:5215)
ld a, $4
ld b, a
jr GetSpriteScreenXYPointerCommon
-GetSpriteScreenXPointer: ; 52b7 (1:52b7)
+GetSpriteScreenXPointer: ; 521a (1:521a)
ld a, $6
ld b, a
-GetSpriteScreenXYPointerCommon: ; 52ba (1:52ba)
+GetSpriteScreenXYPointerCommon: ; 521d (1:521d)
ld hl, wSpriteStateData1
ld a, [H_CURRENTSPRITEOFFSET]
add l
@@ -817,7 +787,7 @@ GetSpriteScreenXYPointerCommon: ; 52ba (1:52ba)
ld l, a
ret
-AnimScriptedNPCMovement: ; 52c3 (1:52c3)
+AnimScriptedNPCMovement: ; 5226 (1:5226)
ld hl, wSpriteStateData2
ld a, [H_CURRENTSPRITEOFFSET]
add $e
@@ -856,21 +826,236 @@ AnimScriptedNPCMovement: ; 52c3 (1:52c3)
ld [hl], a
ret
-AdvanceScriptedNPCAnimFrameCounter: ; 5301 (1:5301)
+AdvanceScriptedNPCAnimFrameCounter: ; 5264 (1:5264)
+ call Func_5274
+ ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET]
- add $7
+ add $8
ld l, a
ld a, [hl] ; intra-animation frame counter
+ and $3
+ ld [hSpriteAnimFrameCounter], a
+ ret
+
+Func_5274: ; 5274 (1:5274)
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $7
+ ld l, a
+ ld h, wSpriteStateData1 / $100
+ ld a, [hl] ; c1x7 (counter until next walk animation frame)
inc a
- ld [hl], a
- cp 4
- ret nz
- xor a
- ld [hl], a ; reset intra-animation frame counter
+ and $3
+ ld [hl], a ; c1x7 += 1
+ ret nz ; c1x7 = 0
inc l
- ld a, [hl] ; animation frame counter
+ ld a, [hl] ; c1x8 (walk animation frame)
inc a
and $3
+ ld [hl], a ; advance to next animation frame every 4 ticks (16 ticks total for one step)
+ ret
+
+Func_5288: ; 5288 (1:5288)
+; nice lookup table
+; a is supposedly [wNPCMovementDirections + $fe]
+ cp $5
+ jr z, .asm_52af
+ cp $4
+ jr z, .asm_52aa
+ cp $6
+ jr z, .asm_52b4
+ cp $7
+ jr z, .asm_52b9
+ cp $11
+ jr z, .asm_52c3
+ cp $12
+ jr z, .asm_52be
+ cp $13
+ jr z, .asm_52c8
+ cp $14
+ jr z, .asm_52cd
+ xor a
+ ret
+; set 1?
+.asm_52aa
+ call Func_531f
+ jr .asm_52e6
+.asm_52af
+ call Func_5325
+ jr .asm_52e6
+.asm_52b4
+ call Func_5331
+ jr .asm_52e6
+.asm_52b9
+ call Func_532b
+ jr .asm_52e6
+; set 2?
+.asm_52be
+ call Func_531f
+ jr .asm_52fa
+.asm_52c3
+ call Func_5325
+ jr .asm_52fa
+.asm_52c8
+ call Func_5331
+ jr .asm_52fa
+.asm_52cd
+ call Func_532b
+ jr .asm_52fa
+; set 3? (unused)
+.asm_52d2
+ call Func_531f
+ jr .asm_530b
+.asm_52d7
+ call Func_5325
+ jr .asm_530b
+.asm_52dc
+ call Func_5331
+ jr .asm_530b
+.asm_52e1
+ call Func_532b
+ jr .asm_530b
+
+.asm_52e6
+ call Func_5337
+ call Func_5349
+ ld a, [H_CURRENTSPRITEOFFSET]
+ ld l, a
+ ld [hl], $8
+ dec h
+ inc l
+ ld [hl], $4
+ call UpdateSpriteImage
+ scf
+ ret
+
+.asm_52fa
+ call Func_5337
+ ld a, [H_CURRENTSPRITEOFFSET]
+ ld l, a
+ ld [hl], $8
+ dec h
+ inc l
+ ld [hl], $3
+ call UpdateSpriteImage
+ scf
+ ret
+
+.asm_530b
+ call Func_5337
+ call Func_5349
+ ld a, [H_CURRENTSPRITEOFFSET]
+ ld l, a
+ ld [hl], $8
+ dec h
+ inc l
+ ld [hl], $3
+ call UpdateSpriteImage
+ scf
+ ret
+
+Func_531f: ; 531f (1:531f)
+ lb de, 1, 0
+ ld c, SPRITE_FACING_DOWN
+ ret
+
+Func_5325: ; 5325 (1:5325)
+ lb de, -1, 0
+ ld c, SPRITE_FACING_UP
+ ret
+
+Func_532b: ; 532b (1:532b)
+ lb de, 0, 1
+ ld c, SPRITE_FACING_RIGHT
+ ret
+
+Func_5331: ; 5331 (1:5331)
+ lb de, 0, -1
+ ld c, SPRITE_FACING_LEFT
+ ret
+
+Func_5337: ; 5337 (1:5337)
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $9
+ ld l, a
+ ld h, wSpriteStateData1 / $100
+ ld [hl], c ; c1x9 (update facing direction)
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $3
+ ld l, a
+ ld [hl], d ; c1x3 (update Y movement delta)
+ inc l
+ inc l
+ ld [hl], e ; c1x5 (update X movement delta)
+ ret
+
+Func_5349: ; 5349 (1:5349)
+ ld h, wSpriteStateData2 / $100
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $4
+ ld l, a
+ ld a, [hl] ; c2x4: Y position
+ add d
+ ld [hli], a ; update Y position
+ ld a, [hl] ; c2x5: X position
+ add e
+ ld [hl], a ; update X position
+ ret
+
+Func_5357: ; 5357 (1:5357)
+ call Func_5274
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $3
+ ld l, a
+ ld h, wSpriteStateData1 / $100
+ ld a, [hli]
+ add a
+ ld b, a
+ ld a, [hl]
+ add b
+ ld [hli], a
+ ld a, [hli]
+ add a
+ ld b, a
+ ld a, [hl]
+ add b
ld [hl], a
- ld [hSpriteAnimFrameCounter], a
+ ld a, [H_CURRENTSPRITEOFFSET]
+ ld l, a
+ ld h, wSpriteStateData2 / $100
+ dec [hl]
+ ret nz
+ ld a, $6
+ add l
+ ld l, a
+ ld a, [hl]
+ cp $fe
+ jr nc, .asm_5386
+ ld a, [H_CURRENTSPRITEOFFSET]
+ inc a
+ ld l, a
+ ld h, wSpriteStateData1 / $100
+ ld [hl], $1
ret
+.asm_5386
+ call Random
+ ld a, [H_CURRENTSPRITEOFFSET]
+ add $8
+ ld l, a
+ ld h, wSpriteStateData2 / $100
+ ld a, [hRandomAdd]
+ and $7f
+ ld [hl], a
+ dec h
+ ld a, [H_CURRENTSPRITEOFFSET]
+ inc a
+ ld l, a
+ ld [hl], $2
+ inc l
+ inc l
+ xor a
+ ld b, [hl]
+ ld [hli], a
+ inc l
+ ld c, [hl]
+ ld [hl], a
+ ret \ No newline at end of file
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 098be875..a609fb60 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
@@ -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
diff --git a/engine/overworld/oam.asm b/engine/overworld/oam.asm
index e81375a3..f51c839f 100644
--- a/engine/overworld/oam.asm
+++ b/engine/overworld/oam.asm
@@ -213,7 +213,7 @@ Func_4a7b: ; 4a7b (1:4a7b)
INCLUDE "engine/oam_dma.asm"
_IsTilePassable:: ; 4aaa (1:4aaa)
- 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
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/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 722b7804..94b20469 100755
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -152,7 +152,7 @@ SetPal_Overworld: ; 71fa5 (1c:5fa5)
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
@@ -396,7 +396,7 @@ Func_7213b:: ; 7213b (1c:613b)
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
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/town_map.asm b/engine/town_map.asm
index ea60e5a4..aff126ee 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -7,7 +7,7 @@ DisplayTownMap: ; 70eb7 (1c:4eb7)
push hl
ld a, $1
ld [hJoy7], a
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
push af
ld b, $0
call DrawPlayerOrBirdSprite ; player sprite
@@ -167,7 +167,7 @@ LoadTownMap_Fly: ; 71014 (1c:5014)
coord hl, 0, 0
ld de, ToText
call PlaceString
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, $0
call DrawPlayerOrBirdSprite
ld hl, wFlyLocationsList
@@ -262,9 +262,9 @@ BuildFlyLocationsList: ; 710fb (1c:50fb)
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
@@ -415,7 +415,7 @@ DisplayWildLocations: ; 71279 (1c:5279)
call PlaceString
jr .done
.drawPlayerSprite
- ld a, [W_CURMAP]
+ ld a, [wCurMap]
ld b, $0
call DrawPlayerOrBirdSprite
.done
diff --git a/engine/trade.asm b/engine/trade.asm
index 66afa47e..4bf90f8a 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