summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2014-09-13 00:50:56 -0700
committerYamaArashi <shadow962@live.com>2014-09-13 00:50:56 -0700
commit0c916aea3353ed1bf2750be403b0da9ea0b922d4 (patch)
tree4e50d805a37f06fabac6086a7ad6ed1d4f4526c4
parent91793015e53dbed09576f825d39e71bc59bf90a5 (diff)
Commented more sprite and map code
-rwxr-xr-xdata/special_warps.asm3
-rwxr-xr-xengine/battle/14.asm2
-rwxr-xr-xengine/battle/1c.asm2
-rwxr-xr-xengine/battle/4_2.asm4
-rwxr-xr-xengine/battle/animations.asm6
-rwxr-xr-xengine/battle/core.asm14
-rwxr-xr-xengine/battle/d.asm2
-rwxr-xr-xengine/cable_club.asm4
-rwxr-xr-xengine/evos_moves.asm2
-rwxr-xr-xengine/give_pokemon.asm2
-rwxr-xr-xengine/hall_of_fame.asm8
-rwxr-xr-xengine/hidden_object_functions14.asm2
-rwxr-xr-xengine/hidden_object_functions17.asm2
-rwxr-xr-xengine/hidden_object_functions18.asm2
-rwxr-xr-xengine/hidden_object_functions3.asm2
-rwxr-xr-xengine/hidden_object_functions7.asm8
-rwxr-xr-xengine/in_game_trades.asm2
-rwxr-xr-xengine/intro.asm2
-rwxr-xr-xengine/items/items.asm40
-rwxr-xr-xengine/menu/diploma.asm2
-rwxr-xr-xengine/menu/league_pc.asm6
-rwxr-xr-xengine/menu/main_menu.asm27
-rwxr-xr-xengine/menu/naming_screen.asm8
-rwxr-xr-xengine/menu/pc.asm2
-rwxr-xr-xengine/menu/players_pc.asm2
-rwxr-xr-xengine/menu/start_menu.asm4
-rwxr-xr-xengine/menu/start_sub_menus.asm10
-rwxr-xr-xengine/mon_party_sprites.asm2
-rwxr-xr-xengine/oak_speech.asm18
-rwxr-xr-xengine/overworld/card_key.asm4
-rwxr-xr-xengine/overworld/cut.asm10
-rwxr-xr-xengine/overworld/doors.asm4
-rwxr-xr-xengine/overworld/emotion_bubbles.asm6
-rwxr-xr-xengine/overworld/healing_machine.asm2
-rwxr-xr-xengine/overworld/hidden_items.asm4
-rwxr-xr-xengine/overworld/hidden_objects.asm4
-rw-r--r--engine/overworld/item.asm2
-rwxr-xr-xengine/overworld/ledges.asm50
-rwxr-xr-xengine/overworld/npc_movement.asm20
-rw-r--r--engine/overworld/oam.asm4
-rwxr-xr-xengine/overworld/player_animations.asm346
-rwxr-xr-xengine/overworld/pokemart.asm2
-rwxr-xr-xengine/overworld/ssanne.asm6
-rwxr-xr-xengine/overworld/trainers.asm12
-rwxr-xr-xengine/palettes.asm4
-rwxr-xr-xengine/predefs.asm14
-rwxr-xr-xengine/predefs12.asm13
-rwxr-xr-xengine/predefs7.asm2
-rwxr-xr-xengine/slot_machine.asm8
-rwxr-xr-xengine/town_map.asm8
-rwxr-xr-xengine/trade.asm4
-rw-r--r--home.asm52
-rw-r--r--home/audio.asm2
-rw-r--r--home/fade.asm22
-rw-r--r--home/init.asm2
-rw-r--r--home/overworld.asm236
-rw-r--r--home/predef.asm2
-rwxr-xr-xmain.asm621
-rwxr-xr-xscripts/billshouse.asm2
-rwxr-xr-xscripts/celadongamecorner.asm6
-rwxr-xr-xscripts/celadongym.asm2
-rwxr-xr-xscripts/celadonmansion3.asm2
-rwxr-xr-xscripts/celadonmartelevator.asm6
-rwxr-xr-xscripts/celadonmartroof.asm2
-rwxr-xr-xscripts/ceruleancity.asm6
-rwxr-xr-xscripts/ceruleancity2.asm4
-rwxr-xr-xscripts/ceruleangym.asm2
-rwxr-xr-xscripts/ceruleanhouse2.asm4
-rwxr-xr-xscripts/cinnabargym.asm4
-rwxr-xr-xscripts/copycatshouse2f.asm2
-rwxr-xr-xscripts/daycarem.asm2
-rwxr-xr-xscripts/fightingdojo.asm2
-rwxr-xr-xscripts/fuchsiagym.asm2
-rwxr-xr-xscripts/mansion1.asm2
-rwxr-xr-xscripts/mansion2.asm2
-rwxr-xr-xscripts/mansion3.asm8
-rwxr-xr-xscripts/mtmoon3.asm8
-rwxr-xr-xscripts/museum1f.asm4
-rwxr-xr-xscripts/namerater.asm2
-rwxr-xr-xscripts/oakslab.asm22
-rwxr-xr-xscripts/pallettown.asm4
-rwxr-xr-xscripts/pewtercity.asm12
-rwxr-xr-xscripts/pewtergym.asm2
-rwxr-xr-xscripts/pewtermart.asm2
-rwxr-xr-xscripts/pewterpokecenter.asm2
-rwxr-xr-xscripts/pokemontower5.asm4
-rwxr-xr-xscripts/pokemontower7.asm12
-rwxr-xr-xscripts/redshouse1f.asm4
-rwxr-xr-xscripts/rockethideout4.asm6
-rwxr-xr-xscripts/rockethideoutelevator.asm6
-rwxr-xr-xscripts/route12gateupstairs.asm2
-rwxr-xr-xscripts/route22.asm4
-rwxr-xr-xscripts/route24.asm2
-rwxr-xr-xscripts/saffrongym.asm2
-rwxr-xr-xscripts/seafoamislands1.asm2
-rwxr-xr-xscripts/seafoamislands2.asm2
-rwxr-xr-xscripts/seafoamislands3.asm2
-rwxr-xr-xscripts/seafoamislands4.asm2
-rwxr-xr-xscripts/seafoamislands5.asm4
-rwxr-xr-xscripts/silphco11.asm6
-rwxr-xr-xscripts/silphco9.asm4
-rwxr-xr-xscripts/silphcoelevator.asm6
-rwxr-xr-xscripts/ssanne9.asm4
-rwxr-xr-xscripts/vermiliondock.asm8
-rwxr-xr-xscripts/vermiliongym.asm2
-rwxr-xr-xscripts/victoryroad3.asm2
-rwxr-xr-xscripts/viridiangym.asm8
-rwxr-xr-xwram.asm169
108 files changed, 1091 insertions, 946 deletions
diff --git a/data/special_warps.asm b/data/special_warps.asm
index 418b57f2..480bac89 100755
--- a/data/special_warps.asm
+++ b/data/special_warps.asm
@@ -1,3 +1,6 @@
+; Format: (size 2 bytes)
+; 00: target map ID
+; 01: which dungeon warp in the source map was used
DungeonWarpList: ; 63bf (1:63bf)
db SEAFOAM_ISLANDS_2,$01
db SEAFOAM_ISLANDS_2,$02
diff --git a/engine/battle/14.asm b/engine/battle/14.asm
index 01a8f48a..530032a0 100755
--- a/engine/battle/14.asm
+++ b/engine/battle/14.asm
@@ -15,7 +15,7 @@ Func_525af: ; 525af (14:65af)
ld [wPartyGainExpFlags], a
ld [wPlayerMonNumber], a ; wPlayerMonNumber
ld [wEscapedFromBattle], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld hl, wcf1d
ld [hli], a
ld [hl], a
diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm
index 3f23a27c..1c69c00f 100755
--- a/engine/battle/1c.asm
+++ b/engine/battle/1c.asm
@@ -89,7 +89,7 @@ BattleTransition: ; 7096d (1c:496d)
xor a
ld [hVBlankWY], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call DelayFrame
ld hl, wSpriteStateData1 + 2
ld a, [H_DOWNARROWBLINKCNT2]
diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm
index 79594bdd..133acdcc 100755
--- a/engine/battle/4_2.asm
+++ b/engine/battle/4_2.asm
@@ -71,7 +71,7 @@ EndOfBattle: ; 137aa (4:77aa)
call WaitForSoundToFinish
call GBPalWhiteOut
ld a, $ff
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ret
YouWinText: ; 13853 (4:7853)
@@ -94,7 +94,7 @@ Func_13870: ; 13870 (4:7870)
ld a, [wd736]
and a
ret nz
- callab Func_c49d
+ callab IsPlayerStandingOnDoorTileOrWarpTile
jr nc, .asm_13888
.asm_13884
ld a, $1
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index a094b34c..15d94f05 100755
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -517,7 +517,7 @@ Func_78e01: ; 78e01 (1e:4e01)
ret
Func_78e23: ; 78e23 (1e:4e23)
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, $e4
jr z, .asm_78e47
@@ -1091,7 +1091,7 @@ CallWithTurnFlipped: ; 79155 (1e:5155)
AnimationFlashScreenLong: ; 79165 (1e:5165)
ld a,3 ; cycle through the palettes 3 times
ld [wd08a],a
- ld a,[wcf1b] ; running on SGB?
+ ld a,[wOnSGB] ; running on SGB?
and a
ld hl,FlashScreenLongMonochrome
jr z,.loop
@@ -1211,7 +1211,7 @@ Func_791f9: ; 791f9 (1e:51f9)
ld bc, $4040
Func_791fc: ; 791fc (1e:51fc)
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, b
jr z, .asm_79204
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 4b1ceedd..26465b8f 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -139,7 +139,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld [$ffd7], a
ld [hVBlankSCY], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
@@ -6247,7 +6247,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32)
ld [wMenuJoypadPollCount], a
callab DisplayLinkBattleVersusTextBox
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearScreen
.next
call DelayFrame
@@ -6256,7 +6256,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32)
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearSprites
call ClearScreen
xor a
@@ -6729,16 +6729,16 @@ asm_3ef23: ; 3ef23 (f:6f23)
bit 1, a
jr z, .asm_3ef2f
ld a, [hJoyHeld]
- bit 1, a
+ bit 1, a ; B button pressed?
ret nz
.asm_3ef2f
- ld a, [wd13c]
+ ld a, [wNumberOfNoRandomBattleStepsLeft]
and a
ret nz
callab Func_13870
ret nz
asm_3ef3d: ; 3ef3d (f:6f3d)
- ld a, [wd35d]
+ ld a, [wMapPalOffset]
push af
ld hl, wd358
ld a, [hl]
@@ -6849,7 +6849,7 @@ InitBattle_Common: ; 3efeb (f:6feb)
pop af
ld [wd358], a
pop af
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld a, [wd0d4]
ld [$ffd7], a
scf
diff --git a/engine/battle/d.asm b/engine/battle/d.asm
index dcd58ec4..94a07eb6 100755
--- a/engine/battle/d.asm
+++ b/engine/battle/d.asm
@@ -17,7 +17,7 @@ DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6)
ld [hli], a
ld [hl], $6a
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
callab SetupPlayerAndEnemyPokeballs
ld c, 150
jp DelayFrames
diff --git a/engine/cable_club.asm b/engine/cable_club.asm
index 8cb70cbf..9b4017e2 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -570,13 +570,13 @@ Func_577d: ; 577d (1:577d)
xor a
ld [wd72d], a
dec a
- ld [wd42f], a
+ ld [wDestinationWarpID], a
call LoadMapData
callba Func_c335
pop hl
pop af
ld [hl], a
- call GBFadeIn2
+ call GBFadeInFromWhite
ret
Func_57a2:
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 61ddb4e7..240fd9fa 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -127,7 +127,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ClearSprites
callab Func_7bde9
jp c, CancelledEvolution
diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm
index dd5e9264..d4d45bfb 100755
--- a/engine/give_pokemon.asm
+++ b/engine/give_pokemon.asm
@@ -43,7 +43,7 @@ _GivePokemon: ; 4fda5 (13:7da5)
call SetPokedexOwnedFlag
call AddPartyMon
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld [wccd3], a
scf
ret
diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm
index dd988cf1..30ae6266 100755
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -18,7 +18,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0)
ld bc, HOF_TEAM
call FillMemory
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [$ffd7], a
ld [W_SPRITEFLIPPED], a
ld [wd358], a
@@ -66,7 +66,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0)
call PlaceString
ld c, 180
call DelayFrames
- call GBFadeOut2
+ call GBFadeOutToWhite
pop bc
pop hl
jr .asm_701fb
@@ -125,7 +125,7 @@ Func_70278: ; 70278 (1c:4278)
call Func_7036d
ld d, $a0
ld e, $4
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
jr z, .asm_702c7
sla e
@@ -282,4 +282,4 @@ Func_70423: ; 70423 (1c:4423)
ld [wcfc9], a
ld a, $ff
ld [wMusicHeaderPointer], a
- jp GBFadeOut2
+ jp GBFadeOutToWhite
diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm
index 0d3598f2..a162c905 100755
--- a/engine/hidden_object_functions14.asm
+++ b/engine/hidden_object_functions14.asm
@@ -1,7 +1,7 @@
PrintNotebookText: ; 52996 (14:6996)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wTrainerSpriteOffset]
jp PrintPredefTextID
diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm
index fccd4267..f1a07542 100755
--- a/engine/hidden_object_functions17.asm
+++ b/engine/hidden_object_functions17.asm
@@ -89,7 +89,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9)
PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade]
call PrintPredefTextID
ret
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 5ccb43c2..9dd7fac7 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -181,7 +181,7 @@ OpenPokemonCenterPC: ; 62516 (18:6516)
ret nz
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ld a, $1f ; PredefText1f
jp PrintPredefTextID
diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm
index 11b91cd3..09d9ebcc 100755
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -114,7 +114,7 @@ TownMapText: ; fc12 (3:7c12)
db $06
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd730
set 6, [hl]
call GBPalWhiteOutWithDelay3
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index 07cf5651..c00749e4 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -83,7 +83,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0)
ld a, $9c
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
ld a, $3
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ld a, $5
ld [W_SAFARIZONEENTRANCECURSCRIPT], a
ld hl, wd790
@@ -152,7 +152,7 @@ CinnabarGymQuiz: ; 1ea25 (7:6a25)
ld l, a
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call CinnabarGymQuiz_1ea92
jp TextScriptEnd
@@ -334,7 +334,7 @@ BillsHousePC: ; 1eb6e (7:6b6e)
jp PrintPredefTextID
.asm_1eb8b
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $2e
call PrintPredefTextID
ld c, $20
@@ -363,7 +363,7 @@ BillsHousePC: ; 1eb6e (7:6b6e)
ret
.asm_1ebd2
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $2f
call PrintPredefTextID
ret
diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm
index ad9de8b1..4f232eb4 100755
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -88,7 +88,7 @@ Func_71c07: ; 71c07 (1c:5c07)
xor a
ld [wd07d],a
dec a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
push af
call Func_71ca2
diff --git a/engine/intro.asm b/engine/intro.asm
index 801324a5..68bf8b50 100755
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -5,7 +5,7 @@ PlayIntro: ; 41682 (10:5682)
ld [H_AUTOBGTRANSFERENABLED], a
call PlayShootingStar
call PlayIntroScene
- call GBFadeOut2
+ call GBFadeOutToWhite
xor a
ld [$ffae], a
ld [H_AUTOBGTRANSFERENABLED], a
diff --git a/engine/items/items.asm b/engine/items/items.asm
index 860479e7..b2bff822 100755
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -507,8 +507,8 @@ ItemUseBicycle: ; d977 (3:5977)
ld a,[W_ISINBATTLE]
and a
jp nz,ItemUseNotTime
- ld a,[wd700]
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState]
+ ld [wWalkBikeSurfStateCopy],a
cp a,2 ; is the player surfing?
jp z,ItemUseNotTime
dec a ; is player already bicycling?
@@ -516,7 +516,7 @@ ItemUseBicycle: ; d977 (3:5977)
.getOffBike
call ItemUseReloadOverworldData
xor a
- ld [wd700],a ; change player state to walking
+ ld [wWalkBikeSurfState],a ; change player state to walking
call PlayDefaultMusic ; play walking music
ld hl,GotOffBicycleText
jr .printText
@@ -527,7 +527,7 @@ ItemUseBicycle: ; d977 (3:5977)
xor a ; no keys pressed
ld [hJoyHeld],a ; current joypad state
inc a
- ld [wd700],a ; change player state to bicycling
+ ld [wWalkBikeSurfState],a ; change player state to bicycling
ld hl,GotOnBicycleText
call PlayDefaultMusic ; play bike riding music
.printText
@@ -535,8 +535,8 @@ ItemUseBicycle: ; d977 (3:5977)
; used for Surf out-of-battle effect
ItemUseSurfboard: ; d9b4 (3:59b4)
- ld a,[wd700]
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState]
+ ld [wWalkBikeSurfStateCopy],a
cp a,2 ; is the player already surfing?
jr z,.tryToStopSurfing
.tryToSurf
@@ -550,7 +550,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
ld hl,wd730
set 7,[hl]
ld a,2
- ld [wd700],a ; change player state to surfing
+ ld [wWalkBikeSurfState],a ; change player state to surfing
call PlayDefaultMusic ; play surfing music
ld hl,SurfingGotOnText
jp PrintText
@@ -570,7 +570,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
ld a,[hli]
ld h,[hl]
ld l,a ; hl now points to passable tiles
- ld a,[wcfc6] ; tile in front of the player
+ ld a,[wTileInFrontOfPlayer] ; tile in front of the player
ld b,a
.passableTileLoop
ld a,[hli]
@@ -586,7 +586,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
ld hl,wd730
set 7,[hl]
xor a
- ld [wd700],a ; change player state to walking
+ ld [wWalkBikeSurfState],a ; change player state to walking
dec a
ld [wJoyIgnore],a
call PlayDefaultMusic ; play walking music
@@ -636,7 +636,7 @@ ItemUseEvoStone: ; da5b (3:5a5b)
ld a,$05 ; evolution stone party menu
ld [wd07d],a
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
pop bc
jr c,.canceledItemUse
@@ -681,7 +681,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld a,$01
ld [wd07d],a ; item use party menu
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,[wd152]
and a ; using Softboiled?
jr z,.notUsingSoftboiled
@@ -1096,7 +1096,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [H_AUTOBGTRANSFERENABLED],a
call ClearScreen
dec a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call RedrawPartyMenu ; redraws the party menu and displays the message
ld a,1
ld [H_AUTOBGTRANSFERENABLED],a
@@ -1278,7 +1278,7 @@ ItemUseMedicine: ; dabb (3:5abb)
ld [wccd4],a
callab TryEvolvingMon ; evolve pokemon, if appropriate
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
pop af
ld [wcf91],a
pop af
@@ -1424,8 +1424,8 @@ ItemUseXAccuracy: ; e013 (3:6013)
ItemUseCardKey: ; e022 (3:6022)
xor a
ld [wd71f],a
- call Func_c586
- ld a,[Func_c586] ; $4586
+ call GetTileAndCoordsInFrontOfPlayer
+ ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586
cp a,$18
jr nz,.next0
ld hl,CardKeyTable1
@@ -1796,7 +1796,7 @@ RodResponse: ; e28d (3:628d)
ld [W_CUROPPONENT], a
.next
- ld hl, wd700
+ ld hl, wWalkBikeSurfState
ld a, [hl] ; store the value in a
push af
push hl
@@ -1818,7 +1818,7 @@ FishingInit: ; e2b4 (3:62b4)
.notInBattle
call IsNextTileShoreOrWater
ret c
- ld a,[wd700]
+ ld a,[wWalkBikeSurfState]
cp a,2 ; Surfing?
jr z,.surfing
call ItemUseReloadOverworldData
@@ -1877,7 +1877,7 @@ ItemUsePPRestore: ; e31e (3:631e)
ld [wWhichTrade],a
.chooseMon
xor a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,$01 ; item use party menu
ld [wd07d],a
call DisplayPartyMenu
@@ -2117,7 +2117,7 @@ ItemUseTMHM: ; e479 (3:6479)
ld bc,14
call CopyData
ld a,$ff
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,$03 ; teach TM/HM party menu
ld [wd07d],a
call DisplayPartyMenu
@@ -2744,7 +2744,7 @@ IsNextTileShoreOrWater: ; e8b8 (3:68b8)
jr nc, .notShoreOrWater
ld a, [W_CURMAPTILESET]
cp SHIP_PORT ; Vermilion Dock tileset
- ld a, [wcfc6] ; tile in front of player
+ ld a, [wTileInFrontOfPlayer] ; tile in front of player
jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset
cp $48 ; eastern shore tile in Safari Zone
jr z, .shoreOrWater
diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm
index adf4c396..95b2a87d 100755
--- a/engine/menu/diploma.asm
+++ b/engine/menu/diploma.asm
@@ -3,7 +3,7 @@ DisplayDiploma: ; 566e2 (15:66e2)
call GBPalWhiteOutWithDelay3
call ClearScreen
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wd730
set 6, [hl]
call DisableLCD
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index 4833e57d..ffde236a 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -4,14 +4,14 @@ PKMNLeaguePC: ; 0x7657e
ld hl, wd730
set 6, [hl]
push hl
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, [$ffD7]
push af
xor a
ld [$ffD7], a
ld [W_SPRITEFLIPPED], a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
ld [wcd42], a
ld a, [wd5a2]
@@ -40,7 +40,7 @@ PKMNLeaguePC: ; 0x7657e
pop af
ld [$ffD7], a
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
pop hl
res 6, [hl]
call GBPalWhiteOutWithDelay3
diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm
index 4044da43..6ffc6249 100755
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -111,16 +111,16 @@ MainMenu: ; 5af2 (1:5af2)
call DelayFrames
ld a,[wd5a2]
and a
- jp z,Func_5d5f
+ jp z,SpecialEnterMap
ld a,[W_CURMAP] ; map ID
cp a,HALL_OF_FAME
- jp nz,Func_5d5f
+ jp nz,SpecialEnterMap
xor a
- ld [wd71a],a
+ ld [wDestinationMap],a
ld hl,wd732
- set 2,[hl]
- call Func_62ce
- jp Func_5d5f
+ set 2,[hl] ; fly warp or dungeon warp
+ call SpecialWarpIn
+ jp SpecialEnterMap
Func_5bff: ; 5bff (1:5bff)
ld a,1
ld [wd358],a
@@ -247,7 +247,7 @@ LinkMenu: ; 5c0a (1:5c0a)
cp $2
jr z, .asm_5d2d
xor a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
and a
ld a, TRADE_CENTER
@@ -262,8 +262,8 @@ LinkMenu: ; 5c0a (1:5c0a)
ld hl, wd732
res 1, [hl]
ld a, [W_ANIMATIONID] ; W_ANIMATIONID
- ld [wd71a], a
- call Func_62ce
+ ld [wDestinationMap], a
+ call SpecialWarpIn
ld c, $14
call DelayFrames
xor a
@@ -272,7 +272,7 @@ LinkMenu: ; 5c0a (1:5c0a)
inc a
ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE
ld [wcc47], a
- jr Func_5d5f
+ jr SpecialEnterMap
.asm_5d2d
xor a
ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount
@@ -303,16 +303,17 @@ Func_5d52: ; 5d52 (1:5d52)
ld c, $14
call DelayFrames
-Func_5d5f: ; 5d5f (1:5d5f)
+; enter map after using a special warp or loading the game from the main menu
+SpecialEnterMap: ; 5d5f (1:5d5f)
xor a
ld [hJoyPressed], a
ld [hJoyHeld], a
ld [$ffb5], a
ld [wd72d], a
ld hl, wd732
- set 0, [hl]
+ set 0, [hl] ; count play time
call ResetPlayerSpriteData
- ld c, $14
+ ld c, 20
call DelayFrames
ld a, [wcc47]
and a
diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm
index f7fc883c..b7db452a 100755
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -22,10 +22,10 @@ AskName: ; 64eb (1:64eb)
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
and a
jr nz, .asm_654c
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
push hl
ld a, $2
ld [wd07d], a
@@ -38,7 +38,7 @@ AskName: ; 64eb (1:64eb)
call LoadScreenTilesFromBuffer1
pop hl
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, [wcf4b]
cp $50
ret nz
@@ -56,7 +56,7 @@ DoYouWantToNicknameText: ; 0x6557
Func_655c: ; 655c (1:655c)
ld hl, wHPBarMaxHP
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, $2
ld [wd07d], a
call DisplayNamingScreen
diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm
index 4df6c826..97895ca6 100755
--- a/engine/menu/pc.asm
+++ b/engine/menu/pc.asm
@@ -86,7 +86,7 @@ BillsPC: ; 17ee4 (5:7ee4)
callba BillsPC_
ReloadMainMenu: ; 17f06 (5:7f06)
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call ReloadMapData
call UpdateSprites ;XXX: moves sprites
jp PCMainMenu
diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm
index 4ff1b16f..5f1175eb 100755
--- a/engine/menu/players_pc.asm
+++ b/engine/menu/players_pc.asm
@@ -78,7 +78,7 @@ Func_796d: ; 796d (1:796d)
ld hl, wd730
res 6, [hl]
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
Func_7995: ; 7995 (1:7995)
diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm
index be172a67..da17822b 100755
--- a/engine/menu/start_menu.asm
+++ b/engine/menu/start_menu.asm
@@ -2,8 +2,8 @@ DisplayStartMenu:: ; 2acd (0:2acd)
ld a,$04 ; hardcoded Bank, not sure what's it refers to
ld [H_LOADEDROMBANK],a
ld [$2000],a ; ROM bank 4
- ld a,[wd700] ; walking/biking/surfing
- ld [wd11a],a
+ ld a,[wWalkBikeSurfState] ; walking/biking/surfing
+ ld [wWalkBikeSurfStateCopy],a
ld a, (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound
call PlaySound
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index e774565a..e91386b0 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -13,7 +13,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
xor a
ld [wMenuItemToSwap],a
ld [wd07d],a
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call DisplayPartyMenu
jr .checkIfPokemonChosen
.loop
@@ -184,7 +184,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9)
bit 0,a ; does the player have the Boulder Badge?
jp z,.newBadgeRequired
xor a
- ld [wd35d],a
+ ld [wMapPalOffset],a
ld hl,.flashLightsAreaText
call PrintText
call GBPalWhiteOutWithDelay3
@@ -406,7 +406,7 @@ StartMenu_Item: ; 13302 (4:7302)
jp z,ItemMenuLoop
jp CloseStartMenu
.useItem_partyMenu
- ld a,[wcfcb]
+ ld a,[wUpdateSpritesEnabled]
push af
call UseItem
ld a,[wcd6a]
@@ -415,11 +415,11 @@ StartMenu_Item: ; 13302 (4:7302)
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
pop af
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
jp StartMenu_Item
.partyMenuNotDisplayed
pop af
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
jp ItemMenuLoop
.tossItem
call IsKeyItem
diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm
index e05bdd55..5fa5c3bc 100755
--- a/engine/mon_party_sprites.asm
+++ b/engine/mon_party_sprites.asm
@@ -21,7 +21,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
ld c, a
ld hl, PartyMonSpeeds
add hl, bc
- ld a, [wcf1b]
+ ld a, [wOnSGB]
xor $1
add [hl]
ld c, a
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index e54741f2..518bea2a 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -49,8 +49,8 @@ OakSpeech: ; 6115 (1:6115)
ld [wcf96],a
call AddItemToInventory ; give one potion
ld a,[W_ANIMATIONID]
- ld [wd71a],a
- call Func_62ce
+ ld [wDestinationMap],a
+ call SpecialWarpIn
xor a
ld [$FFD7],a
ld a,[wd732]
@@ -62,7 +62,7 @@ OakSpeech: ; 6115 (1:6115)
call FadeInIntroPic
ld hl,OakSpeechText1
call PrintText ; prints text box
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld a,NIDORINO
ld [wd0b5],a ; pic displayed is stored at this location
@@ -73,7 +73,7 @@ OakSpeech: ; 6115 (1:6115)
call MovePicLeft
ld hl,OakSpeechText2
call PrintText ; Prints text box
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,RedPicFront
ld bc,(Bank(RedPicFront) << 8) | $00
@@ -82,7 +82,7 @@ OakSpeech: ; 6115 (1:6115)
ld hl,IntroducePlayerText
call PrintText
call LoadDefaultNamesPlayer ; brings up NewName/Red/etc menu
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,Rival1Pic
ld bc,(Bank(Rival1Pic) << 8) | $00
@@ -93,12 +93,12 @@ OakSpeech: ; 6115 (1:6115)
call LoadDefaultNamesRival
Func_61bc: ; 61bc (1:61bc)
- call GBFadeOut2
+ call GBFadeOutToWhite
call ClearScreen
ld de,RedPicFront
ld bc,(Bank(RedPicFront) << 8) | $00
call IntroPredef3B
- call GBFadeIn2
+ call GBFadeInFromWhite
ld a,[wd72d]
and a
jr nz,.next
@@ -148,10 +148,10 @@ Func_61bc: ; 61bc (1:61bc)
call ClearScreenArea
call LoadTextBoxTilePatterns
ld a,1
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld c,$32
call DelayFrames
- call GBFadeOut2
+ call GBFadeOutToWhite
jp ClearScreen
OakSpeechText1: ; 6253 (1:6253)
TX_FAR _OakSpeechText1
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index f48c26f4..885932d5 100755
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -8,8 +8,8 @@ PrintCardKeyText: ; 52673 (14:6673)
ret z
cp b
jr nz, .asm_5267a
- predef Func_c586
- ld a, [wcfc6]
+ predef GetTileAndCoordsInFrontOfPlayer
+ ld a, [wTileInFrontOfPlayer]
cp $18
jr z, .asm_5269c
cp $24
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index 59abe791..0cbc0214 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -6,13 +6,13 @@ UsedCut: ; ef54 (3:6f54)
jr z, .asm_ef6b
cp GYM
jr nz, .asm_ef77
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
jr nz, .asm_ef77
jr asm_ef82
.asm_ef6b
dec a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
jr z, asm_ef82
cp $52 ; grass
@@ -52,14 +52,14 @@ asm_ef82: ; ef82 (3:6f82)
ld hl, wd730
res 6, [hl]
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call AnimateCutTree
ld de, CutTreeBlockSwaps ; $7100
call Func_f09f
call Func_eedc
callba Func_79e96
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, (SFX_02_56 - SFX_Headers_02) / 3
call PlaySound
ld a, $90
@@ -178,7 +178,7 @@ Func_f09f: ; f09f (3:709f)
ld c, a
ld b, $0
ld d, $0
- ld hl, wd35f
+ ld hl, wCurrentTileBlockMapViewPointer
ld a, [hli]
ld h, [hl]
ld l, a
diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm
index 85ff58b2..ac345af9 100755
--- a/engine/overworld/doors.asm
+++ b/engine/overworld/doors.asm
@@ -1,5 +1,5 @@
-; returns whether the player is standing on a door in carry
-IsPlayerStandingOnDoor: ; 1a609 (6:6609)
+; returns whether the player is standing on a door tile in carry
+IsPlayerStandingOnDoorTile: ; 1a609 (6:6609)
push de
ld hl, DoorTileIDPointers ; $662c
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm
index ae7702b4..7106063b 100755
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -11,10 +11,10 @@ EmotionBubble: ; 17c47 (5:7c47)
ld hl, vChars1 + $780
ld bc, (BANK(EmotionBubblesPointerTable) << 8) + $04
call CopyVideoData
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, [wd736]
bit 6, a
ld hl, wOAMBuffer + $8f
@@ -51,7 +51,7 @@ EmotionBubble: ; 17c47 (5:7c47)
ld c, $3c
call DelayFrames
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call DelayFrame
jp UpdateSprites
diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm
index 9c93583d..53174630 100755
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -3,7 +3,7 @@ AnimateHealingMachine: ; 70433 (1c:4433)
ld hl, vChars0 + $7c0
ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03
call CopyVideoData
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm
index 77bd8fe6..befe2935 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -12,7 +12,7 @@ HiddenItems: ; 76688 (1d:6688)
ret nz
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade] ; item ID
ld [wd11e], a
call GetItemName
@@ -42,7 +42,7 @@ FoundHiddenItemText: ; 7675b (1d:675b)
.BagFull
call WaitForTextScrollButtonPress ; wait for button press
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, HiddenItemBagFullText
call PrintText
jp TextScriptEnd
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index d2114293..1be5170c 100755
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -1,13 +1,13 @@
Func_46981: ; 46981 (11:6981)
xor a
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld a, [wd72d]
bit 4, a
ret nz
call ArePlayerCoordsInArray
ret nc
ld a, [wWhichTrade] ; wWhichTrade
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
ld hl, wd732
diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm
index a69ec106..a49fc268 100644
--- a/engine/overworld/item.asm
+++ b/engine/overworld/item.asm
@@ -34,7 +34,7 @@ PickupItem:
ld [wcc4d], a
predef HideObject
ld a, 1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, FoundItemText
jr .print
diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm
index 21e1b567..b8c19181 100755
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -1,48 +1,48 @@
HandleLedges: ; 1a672 (6:6672)
ld a, [wd736]
- bit 6, a
+ bit 6, a ; already jumping down ledge
ret nz
ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
and a ; OVERWORLD
ret nz
- predef Func_c586
+ predef GetTileAndCoordsInFrontOfPlayer
ld a, [wSpriteStateData1 + 9]
ld b, a
aCoord 8, 9
ld c, a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
ld d, a
- ld hl, LedgeTiles ; $66cf
-.asm_1a691
+ ld hl, LedgeTiles
+.loop
ld a, [hli]
cp $ff
ret z
cp b
- jr nz, .asm_1a6a4
+ jr nz, .nextLedgeTile1
ld a, [hli]
cp c
- jr nz, .asm_1a6a5
+ jr nz, .nextLedgeTile2
ld a, [hli]
cp d
- jr nz, .asm_1a6a6
+ jr nz, .nextLedgeTile3
ld a, [hl]
ld e, a
- jr .asm_1a6a9
-.asm_1a6a4
+ jr .foundMatch
+.nextLedgeTile1
inc hl
-.asm_1a6a5
+.nextLedgeTile2
inc hl
-.asm_1a6a6
+.nextLedgeTile3
inc hl
- jr .asm_1a691
-.asm_1a6a9
+ jr .loop
+.foundMatch
ld a, [hJoyHeld]
and e
ret z
ld a, $ff
ld [wJoyIgnore], a
ld hl, wd736
- set 6, [hl]
+ set 6, [hl] ; jumping down ledge
call StartSimulatingJoypadStates
ld a, e
ld [wSimulatedJoypadStatesEnd], a
@@ -56,24 +56,24 @@ HandleLedges: ; 1a672 (6:6672)
; (player direction) (tile player standing on) (ledge tile) (input required)
LedgeTiles: ; 1a6cf (6:66cf)
- db $00,$2C,$37,$80
- db $00,$39,$36,$80
- db $00,$39,$37,$80
- db $08,$2C,$27,$20
- db $08,$39,$27,$20
- db $0C,$2C,$0D,$10
- db $0C,$2C,$1D,$10
- db $0C,$39,$0D,$10
+ db SPRITE_FACING_DOWN, $2C,$37,D_DOWN
+ db SPRITE_FACING_DOWN, $39,$36,D_DOWN
+ db SPRITE_FACING_DOWN, $39,$37,D_DOWN
+ db SPRITE_FACING_LEFT, $2C,$27,D_LEFT
+ db SPRITE_FACING_LEFT, $39,$27,D_LEFT
+ db SPRITE_FACING_RIGHT,$2C,$0D,D_RIGHT
+ db SPRITE_FACING_RIGHT,$2C,$1D,D_RIGHT
+ db SPRITE_FACING_RIGHT,$39,$0D,D_RIGHT
db $FF
LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
ld hl, vChars1 + $7f0
- ld de, LedgeHoppingShadow ; $6708
+ ld de, LedgeHoppingShadow
ld bc, (BANK(LedgeHoppingShadow) << 8) + $01
call CopyVideoDataDouble
ld a, $9
ld bc, $5448 ; b, c = y, x coordinates of shadow
- ld de, LedgeHoppingShadowOAM ; $6710
+ ld de, LedgeHoppingShadowOAM
call WriteOAMBlock
ret
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index e49c6af1..07a73be6 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,7 +1,7 @@
PlayerStepOutFromDoor: ; 1a3e0 (6:63e0)
ld hl, wd730
res 1, [hl]
- call IsPlayerStandingOnDoor
+ call IsPlayerStandingOnDoorTile
jr nc, .notStandingOnDoor
ld a, $fc
ld [wJoyIgnore], a
@@ -62,7 +62,7 @@ Func_1a44c: ; 1a44c (6:644c)
ld a, $80
call FillMemory
ld [hl], $ff
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
ld de, wNPCMovementDirections2
call MoveSprite
@@ -100,18 +100,18 @@ Func_1a4a1: ; 1a4a1 (6:64a1)
Func_1a4a6: ; 1a4a6 (6:64a6)
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
ld [wSpriteStateData2 + $06], a
ld hl, wSimulatedJoypadStatesEnd
- ld de, RLEList_1a4e9
+ ld de, RLEList_PlayerWalkToLab
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
ld hl, wNPCMovementDirections2
- ld de, RLEList_1a4dc
+ ld de, RLEList_ProfOakWalkToLab
call DecodeRLEList
ld hl, wd72e
res 7, [hl]
@@ -121,7 +121,7 @@ Func_1a4a6: ; 1a4a6 (6:64a6)
ld [wNPCMovementScriptFunctionNum], a
ret
-RLEList_1a4dc: ; 1a4dc (6:64dc)
+RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
db $00, $05
db $80, $01
db $00, $05
@@ -130,7 +130,7 @@ RLEList_1a4dc: ; 1a4dc (6:64dc)
db $E0, $01
db $FF
-RLEList_1a4e9: ; 1a4e9 (6:64e9)
+RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
db D_UP, $02
db D_RIGHT, $03
db D_DOWN, $05
@@ -162,7 +162,7 @@ Func_1a514: ; 1a514 (6:6514)
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
call PlaySound
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
call StartSimulatingJoypadStates
@@ -218,7 +218,7 @@ Func_1a581: ; 1a581 (6:6581)
ld a, MUSIC_MUSEUM_GUY
ld [wc0ee], a
call PlaySound
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wNPCMovementScriptSpriteOffset], a
xor a
@@ -276,7 +276,7 @@ Func_1a5e7: ; 1a5e7 (6:65e7)
ret z
jr .loop
.notRival
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
jp SetSpriteMovementBytesToFF
diff --git a/engine/overworld/oam.asm b/engine/overworld/oam.asm
index 63495d22..b4247257 100644
--- a/engine/overworld/oam.asm
+++ b/engine/overworld/oam.asm
@@ -2,13 +2,13 @@ PrepareOAMData:
; Determine OAM data for currently visible
; sprites and write it to wOAMBuffer.
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
dec a
jr z, .asm_4b1e
cp 0 - 1
ret nz
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
jp HideSprites
.asm_4b1e
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index f915a2b9..473b0d5a 100755
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -1,66 +1,67 @@
-Func_70510: ; 70510 (1c:4510)
- call Func_706ef
+EnterMapAnim: ; 70510 (1c:4510)
+ call InitFacingDirectionBuffer
ld a, $ec
- ld [wSpriteStateData1 + 4], a
+ ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position
call Delay3
push hl
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, W_FLAGS_D733
- bit 7, [hl]
+ bit 7, [hl] ; used fly out of battle?
res 7, [hl]
- jr nz, .asm_70568
+ jr nz, .flyAnimation
ld a, (SFX_02_4c - SFX_Headers_02) / 3
call PlaySound
ld hl, wd732
- bit 4, [hl]
+ bit 4, [hl] ; used dungeon warp?
res 4, [hl]
pop hl
- jr nz, .asm_7055e
- call Func_705aa
+ jr nz, .dungeonWarpAnimation
+ call PlayerSpinWhileMovingDown
ld a, (SFX_02_4f - SFX_Headers_02) / 3
call PlaySound
- call Func_70787
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
- jr nz, .asm_7055b
- ld hl, wWhichTrade ; wWhichTrade
+ jr nz, .done
+; if the player is not standing on a warp pad or hole
+ ld hl, wPlayerSpinInPlaceAnimFrameDelay
xor a
- ld [hli], a
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
inc a
- ld [hli], a
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
ld a, $8
- ld [hli], a
- ld [hl], $ff
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
+ ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
- call Func_70730
-.asm_70558
+ call PlayerSpinInPlace
+.restoreDefaultMusic
call PlayDefaultMusic
-.asm_7055b
- jp Func_70772
-.asm_7055e
- ld c, $32
+.done
+ jp RestoreFacingDirectionAndYScreenPos
+.dungeonWarpAnimation
+ ld c, 50
call DelayFrames
- call Func_705aa
- jr .asm_7055b
-.asm_70568
+ call PlayerSpinWhileMovingDown
+ jr .done
+.flyAnimation
pop hl
- ld de, BirdSprite ; $4d80
+ ld de, BirdSprite
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
call CopyVideoData
- call Func_706d7
+ call LoadBirdSpriteGraphics
ld a, (SFX_02_50 - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- xor a
- ld [hli], a
- ld a, $c
- ld [hli], a
- ld [hl], $8
+ ld hl, wFlyAnimUsingCoordList
+ xor a ; is using coord list
+ ld [hli], a ; wFlyAnimUsingCoordList
+ ld a, 12
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationEnterScreenCoords ; $4592
- call Func_706ae
+ call DoFlyAnimation
call LoadPlayerSpriteGraphics
- jr .asm_70558
+ jr .restoreDefaultMusic
FlyAnimationEnterScreenCoords: ; 70592 (1c:4592)
; y, x pairs
@@ -79,90 +80,92 @@ FlyAnimationEnterScreenCoords: ; 70592 (1c:4592)
db $3C, $48
db $3C, $40
-Func_705aa: ; 705aa (1c:45aa)
- ld hl, wWhichTrade ; wWhichTrade
+PlayerSpinWhileMovingDown: ; 705aa (1c:45aa)
+ ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $10
- ld [hli], a
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $3c
- ld [hli], a
- call Func_7077f
- ld [hl], a
- jp Func_70755
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
+ call GetPlayerTeleportAnimFrameDelay
+ ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
+ jp PlayerSpinWhileMovingUpOrDown
_LeaveMapAnim: ; 705ba (1c:45ba)
- call Func_706ef
- call Func_70787
+ call InitFacingDirectionBuffer
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
and a
- jr z, .asm_705ef
+ jr z, .playerNotStandingOnWarpPadOrHole
dec a
- jp nz, Func_7067d
-.asm_705c8
+ jp nz, LeaveMapThroughHoleAnim
+.spinWhileMovingUp
ld a, (SFX_02_4b - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $f0
- ld [hli], a
+ ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY
+ ld a, -$10
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY
ld a, $ec
- ld [hli], a
- call Func_7077f
- ld [hl], a
- call Func_70755
- call Func_70787
+ ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY
+ call GetPlayerTeleportAnimFrameDelay
+ ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay
+ call PlayerSpinWhileMovingUpOrDown
+ call IsPlayerStandingOnWarpPadOrHole
ld a, b
dec a
- jr z, .asm_705e9
- ld c, $a
+ jr z, .playerStandingOnWarpPad
+; if not standing on a warp pad, there is an extra delay
+ ld c, 10
call DelayFrames
-.asm_705e9
- call GBFadeOut2
- jp Func_70772
-.asm_705ef
+.playerStandingOnWarpPad
+ call GBFadeOutToWhite
+ jp RestoreFacingDirectionAndYScreenPos
+.playerNotStandingOnWarpPadOrHole
ld a, $4
call StopMusic
ld a, [wd732]
- bit 6, a
- jr z, .asm_70610
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $10
- ld [hli], a
- ld a, $ff
- ld [hli], a
+ bit 6, a ; is the last used pokemon center the destination?
+ jr z, .flyAnimation
+; if going to the last used pokemon center
+ ld hl, wPlayerSpinInPlaceAnimFrameDelay
+ ld a, 16
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay
+ ld a, -1
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta
xor a
- ld [hli], a
- ld [hl], $a1
+ ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue
+ ld [hl], $a1 ; wPlayerSpinInPlaceAnimSoundID
ld hl, wcd48
- call Func_70730
- jr .asm_705c8
-.asm_70610
- call Func_706d7
- ld hl, wWhichTrade ; wWhichTrade
- ld a, $ff
- ld [hli], a
- ld a, $8
- ld [hli], a
- ld [hl], $c
- call Func_706ae
+ call PlayerSpinInPlace
+ jr .spinWhileMovingUp
+.flyAnimation
+ call LoadBirdSpriteGraphics
+ ld hl, wFlyAnimUsingCoordList
+ ld a, $ff ; is not using coord list (flap in place)
+ ld [hli], a ; wFlyAnimUsingCoordList
+ ld a, 8
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $c ; wFlyAnimBirdSpriteImageIndex
+ call DoFlyAnimation
ld a, (SFX_02_50 - SFX_Headers_02) / 3
call PlaySound
- ld hl, wWhichTrade ; wWhichTrade
- xor a
- ld [hli], a
+ ld hl, wFlyAnimUsingCoordList
+ xor a ; is using coord list
+ ld [hli], a ; wFlyAnimUsingCoordList
ld a, $c
- ld [hli], a
- ld [hl], $c
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right)
ld de, FlyAnimationScreenCoords1 ; $464f
- call Func_706ae
- ld c, $28
+ call DoFlyAnimation
+ ld c, 40
call DelayFrames
- ld hl, wTrainerEngageDistance
- ld a, $b
- ld [hli], a
- ld [hl], $8
+ ld hl, wFlyAnimCounter
+ ld a, 11
+ ld [hli], a ; wFlyAnimCounter
+ ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left)
ld de, FlyAnimationScreenCoords2 ; $4667
- call Func_706ae
- call GBFadeOut2
- jp Func_70772
+ call DoFlyAnimation
+ call GBFadeOutToWhite
+ jp RestoreFacingDirectionAndYScreenPos
FlyAnimationScreenCoords1: ; 7064f (1c:464f)
; y, x pairs
@@ -198,33 +201,35 @@ FlyAnimationScreenCoords2: ; 70667 (1c:4667)
db $F0, $00
-Func_7067d: ; 7067d (1c:467d)
+LeaveMapThroughHoleAnim: ; 7067d (1c:467d)
ld a, $ff
- ld [wcfcb], a
- ld a, [wOAMBuffer + $02]
- ld [wOAMBuffer + $0a], a
- ld a, [wOAMBuffer + $06]
- ld [wOAMBuffer + $0e], a
+ ld [wUpdateSpritesEnabled], a ; disable UpdateSprites
+ ; shift upper half of player's sprite down 8 pixels and hide lower half
+ ld a, [wOAMBuffer + 0 * 4 + 2]
+ ld [wOAMBuffer + 2 * 4 + 2], a
+ ld a, [wOAMBuffer + 1 * 4 + 2]
+ ld [wOAMBuffer + 3 * 4 + 2], a
ld a, $a0
- ld [wOAMBuffer], a
- ld [wOAMBuffer + $04], a
- ld c, $2
+ ld [wOAMBuffer + 0 * 4], a
+ ld [wOAMBuffer + 1 * 4], a
+ ld c, 2
call DelayFrames
+ ; hide lower half of player's sprite
ld a, $a0
- ld [wOAMBuffer + $08], a
- ld [wOAMBuffer + $0c], a
- call GBFadeOut2
+ ld [wOAMBuffer + 2 * 4], a
+ ld [wOAMBuffer + 3 * 4], a
+ call GBFadeOutToWhite
ld a, $1
- ld [wcfcb], a
- jp Func_70772
+ ld [wUpdateSpritesEnabled], a ; enable UpdateSprites
+ jp RestoreFacingDirectionAndYScreenPos
-Func_706ae: ; 706ae (1c:46ae)
- ld a, [wTrainerFacingDirection]
- xor $1
- ld [wTrainerFacingDirection], a
+DoFlyAnimation: ; 706ae (1c:46ae)
+ ld a, [wFlyAnimBirdSpriteImageIndex]
+ xor $1 ; make the bird flap its wings
+ ld [wFlyAnimBirdSpriteImageIndex], a
ld [wSpriteStateData1 + 2], a
call Delay3
- ld a, [wWhichTrade] ; wWhichTrade
+ ld a, [wFlyAnimUsingCoordList]
cp $ff
jr z, .asm_706cd
ld hl, wSpriteStateData1 + 4
@@ -236,13 +241,13 @@ Func_706ae: ; 706ae (1c:46ae)
inc de
ld [hl], a
.asm_706cd
- ld a, [wTrainerEngageDistance]
+ ld a, [wFlyAnimCounter]
dec a
- ld [wTrainerEngageDistance], a
- jr nz, Func_706ae
+ ld [wFlyAnimCounter], a
+ jr nz, DoFlyAnimation
ret
-Func_706d7: ; 706d7 (1c:46d7)
+LoadBirdSpriteGraphics: ; 706d7 (1c:46d7)
ld de, BirdSprite ; $4d80
ld hl, vNPCSprites
ld bc, (BANK(BirdSprite) << 8) + $0c
@@ -252,32 +257,32 @@ Func_706d7: ; 706d7 (1c:46d7)
ld bc, (BANK(BirdSprite) << 8) + $0c
jp CopyVideoData
-Func_706ef: ; 706ef (1c:46ef)
- ld a, [wSpriteStateData1 + 2]
+InitFacingDirectionBuffer: ; 706ef (1c:46ef)
+ ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld [wcd50], a
- ld a, [wSpriteStateData1 + 4]
+ ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
ld [wcd4f], a
- ld hl, PlayerSpinningFacingOrder ; $4713
+ ld hl, PlayerSpinningFacingOrder
ld de, wcd48
ld bc, $4
call CopyData
- ld a, [wSpriteStateData1 + 2]
+ ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images)
ld hl, wcd48
-.asm_7070d
+.loop
cp [hl]
inc hl
- jr nz, .asm_7070d
+ jr nz, .loop
dec hl
ret
PlayerSpinningFacingOrder: ; 70713 (1c:4713)
; The order of the direction the player's sprite is facing when teleporting
; away. Creates a spinning effect.
- db $00, $08, $04, $0C ; down, left, up, right
+ db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT
-Func_70717: ; 70717 (1c:4717)
+SpinPlayerSprite: ; 70717 (1c:4717)
ld a, [hl]
- ld [wSpriteStateData1 + 2], a
+ ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images)
push hl
ld hl, wcd48
ld de, wcd47
@@ -288,84 +293,85 @@ Func_70717: ; 70717 (1c:4717)
pop hl
ret
-Func_70730: ; 70730 (1c:4730)
- call Func_70717
- ld a, [wWhichTrade] ; wWhichTrade
+PlayerSpinInPlace: ; 70730 (1c:4730)
+ call SpinPlayerSprite
+ ld a, [wPlayerSpinInPlaceAnimFrameDelay]
ld c, a
and $3
jr nz, .asm_70743
- ld a, [wTrainerScreenY]
+ ld a, [wPlayerSpinInPlaceAnimSoundID]
cp $ff
call nz, PlaySound
.asm_70743
- ld a, [wTrainerEngageDistance]
+ ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta]
add c
- ld [wWhichTrade], a ; wWhichTrade
+ ld [wPlayerSpinInPlaceAnimFrameDelay], a
ld c, a
- ld a, [wTrainerFacingDirection]
+ ld a, [wPlayerSpinInPlaceAnimFrameDelayEndValue]
cp c
ret z
call DelayFrames
- jr Func_70730
+ jr PlayerSpinInPlace
-Func_70755: ; 70755 (1c:4755)
- call Func_70717
- ld a, [wWhichTrade] ; wWhichTrade
+PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755)
+ call SpinPlayerSprite
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimDeltaY]
ld c, a
- ld a, [wSpriteStateData1 + 4]
+ ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position
add c
ld [wSpriteStateData1 + 4], a
ld c, a
- ld a, [wTrainerEngageDistance]
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimMaxY]
cp c
ret z
- ld a, [wTrainerFacingDirection]
+ ld a, [wPlayerSpinWhileMovingUpOrDownAnimFrameDelay]
ld c, a
call DelayFrames
- jr Func_70755
+ jr PlayerSpinWhileMovingUpOrDown
-Func_70772: ; 70772 (1c:4772)
+RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772)
ld a, [wcd4f]
ld [wSpriteStateData1 + 4], a
ld a, [wcd50]
ld [wSpriteStateData1 + 2], a
ret
-Func_7077f: ; 7077f (1c:477f)
- ld a, [wcf1b]
+; if SGB, 2 frames, else 3 frames
+GetPlayerTeleportAnimFrameDelay: ; 7077f (1c:477f)
+ ld a, [wOnSGB]
xor $1
inc a
inc a
ret
-Func_70787: ; 70787 (1c:4787)
+IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787)
ld b, 0
- ld hl, DataTable_707a9 ; $47a9
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld hl, .warpPadAndHoleData
+ ld a, [W_CURMAPTILESET]
ld c, a
-.asm_70790
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_707a4
+ jr z, .done
cp c
- jr nz, .asm_7079e
+ jr nz, .nextEntry
aCoord 8, 9
cp [hl]
- jr z, .asm_707a2
-.asm_7079e
+ jr z, .foundMatch
+.nextEntry
inc hl
inc hl
- jr .asm_70790
-.asm_707a2
+ jr .loop
+.foundMatch
inc hl
ld b, [hl]
-.asm_707a4
+.done
ld a, b
ld [wcd5b], a
ret
; format: db tileset id, tile id, value to be put in wcd5b
-DataTable_707a9: ; 707a9 (1c:47a9)
+.warpPadAndHoleData: ; 707a9 (1c:47a9)
db FACILITY, $20, 1 ; warp pad
db FACILITY, $11, 2 ; hole
db CAVERN, $22, 2 ; hole
@@ -454,7 +460,7 @@ ItsABiteText: ; 70851 (1c:4851)
db "@"
FishingRodGfxProperties: ; 70856 (1c:4856)
-; specicies how the fishing rod should be drawn on the screen
+; specifies how the fishing rod should be drawn on the screen
; first byte = screen y coordinate
; second byte = screen x coordinate
; third byte = tile number
@@ -482,21 +488,21 @@ RedFishingTiles: ; 70866 (1c:4866)
dw vNPCSprites2 + $7d0
_HandleMidJump: ; 7087e (1c:487e)
- ld a, [wd714]
+ ld a, [wPlayerJumpingYScreenCoordsIndex]
ld c, a
inc a
cp $10
- jr nc, .asm_70895
- ld [wd714], a
- ld b, $0
- ld hl, PlayerJumpingYScreenCoords ; $48ba
+ jr nc, .finishedJump
+ ld [wPlayerJumpingYScreenCoordsIndex], a
+ ld b, 0
+ ld hl, PlayerJumpingYScreenCoords
add hl, bc
ld a, [hl]
ld [wSpriteStateData1 + 4], a ; player's sprite y coordinate
ret
-.asm_70895
- ld a, [wWalkCounter] ; wcfc5
- cp $0
+.finishedJump
+ ld a, [wWalkCounter]
+ cp 0
ret nz
call UpdateSprites
call Delay3
@@ -504,11 +510,11 @@ _HandleMidJump: ; 7087e (1c:487e)
ld [hJoyHeld], a
ld [hJoyPressed], a
ld [hJoyReleased], a
- ld [wd714], a
+ ld [wPlayerJumpingYScreenCoordsIndex], a
ld hl, wd736
- res 6, [hl]
+ res 6, [hl] ; not jumping down a ledge any more
ld hl, wd730
- res 7, [hl]
+ res 7, [hl] ; not simulating joypad states any more
xor a
ld [wJoyIgnore], a
ret
diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm
index 1c2c23bf..a27f6b0a 100755
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -203,7 +203,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20)
ld hl,PokemartThankYouText
call PrintText
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call UpdateSprites ; move sprites
ld a,[wd07e]
ld [wListScrollOffset],a
diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm
index bdbbd17e..f1a8ecf9 100755
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -1,10 +1,10 @@
AnimateBoulderDust: ; 79f54 (1e:5f54)
ld a, $1
ld [wcd50], a ; select the boulder dust offsets
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
push af
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld a, %11100100
ld [rOBP1], a
call LoadSmokeTileFourTimes
@@ -26,7 +26,7 @@ AnimateBoulderDust: ; 79f54 (1e:5f54)
dec c
jr nz, .loop
pop af
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
jp LoadPlayerSpriteGraphics
GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92)
diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm
index 5237df0d..4aaab3ed 100755
--- a/engine/overworld/trainers.asm
+++ b/engine/overworld/trainers.asm
@@ -1,7 +1,7 @@
_GetSpritePosition1: ; 567f9 (15:67f9)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli]
@@ -20,7 +20,7 @@ _GetSpritePosition1: ; 567f9 (15:67f9)
_GetSpritePosition2: ; 56819 (15:6819)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [hli] ; c1x4 (screen Y pos)
@@ -39,7 +39,7 @@ _GetSpritePosition2: ; 56819 (15:6819)
_SetSpritePosition1: ; 5683d (15:683d)
ld hl, wSpriteStateData1
ld de, $4
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [$ffeb] ; c1x4 (screen Y pos)
@@ -58,7 +58,7 @@ _SetSpritePosition1: ; 5683d (15:683d)
_SetSpritePosition2: ; 5685d (15:685d)
ld hl, wSpriteStateData1
ld de, $0004
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
call GetSpriteDataPointer
ld a, [wd130]
@@ -75,7 +75,7 @@ _SetSpritePosition2: ; 5685d (15:685d)
ret
TrainerWalkUpToPlayer: ; 56881 (15:6881)
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a ; wWhichTrade
call ReadTrainerScreenPosition
@@ -143,7 +143,7 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881)
ld de, wNPCMovementDirections2
call FillMemory ; write the necessary steps to reach player
ld [hl], $ff ; write end of list sentinel
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_SPRITEINDEX], a
jp MoveSprite_
diff --git a/engine/palettes.asm b/engine/palettes.asm
index eafd8ef6..67afc12d 100755
--- a/engine/palettes.asm
+++ b/engine/palettes.asm
@@ -380,11 +380,11 @@ SendSGBPacket: ; 71feb (1c:5feb)
LoadSGB: ; 7202b (1c:602b)
xor a
- ld [wcf1b], a
+ ld [wOnSGB], a
call Func_7209b
ret nc
ld a, $1
- ld [wcf1b], a
+ ld [wOnSGB], a
ld a, [wGBC]
and a
jr z, .asm_7203f
diff --git a/engine/predefs.asm b/engine/predefs.asm
index c492a206..0a5eff03 100755
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -71,19 +71,19 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef FlagActionPredef
add_predef HideObject
add_predef IsObjectHidden
- add_predef Func_c69c
+ add_predef ApplyOutOfBattlePoisonDamage
add_predef AnyPartyAlive
add_predef ShowObject
add_predef ShowObject2
add_predef Func_ee9e
add_predef InitPlayerData2
- add_predef Func_c754
+ add_predef LoadTilesetHeader
add_predef LearnMoveFromLevelUp
add_predef LearnMove
add_predef IsItemInBag_ ; 1C, used in Pokémon Tower
dbw $03,Func_3eb5 ; for these two, the bank number is actually 0
dbw $03,GiveItem
- add_predef Func_480eb
+ add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
add_predef Func_480ff
add_predef CalcPositionOfPlayerRelativeToNPC
@@ -105,7 +105,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef PlayIntro
add_predef Func_79869
add_predef FlashScreen
- add_predef Func_c586
+ add_predef GetTileAndCoordsInFrontOfPlayer
add_predef StatusScreen
add_predef StatusScreen2
add_predef Func_410e2
@@ -140,9 +140,9 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef HallOfFamePC
add_predef DisplayDexRating
dbw $1E, _LeaveMapAnim ; wrong bank
- dbw $1E, Func_70510 ; wrong bank
- add_predef Func_c5be
- add_predef Func_c60b
+ dbw $1E, EnterMapAnim ; wrong bank
+ add_predef GetTileTwoStepsInFrontOfPlayer
+ add_predef CheckForCollisionWhenPushingBoulder
add_predef PrintStrengthTxt
add_predef PickupItem
add_predef Func_27d98
diff --git a/engine/predefs12.asm b/engine/predefs12.asm
index 380cfc1c..90032a14 100755
--- a/engine/predefs12.asm
+++ b/engine/predefs12.asm
@@ -1,13 +1,14 @@
-Func_480eb: ; 480eb (12:40eb)
+; b = new colour for BG colour 0 (usually white) for 4 frames
+ChangeBGPalColor0_4Frames: ; 480eb (12:40eb)
call GetPredefRegisters
- ld a, [rBGP] ; $ff47
+ ld a, [rBGP]
or b
- ld [rBGP], a ; $ff47
+ ld [rBGP], a
ld c, $4
call DelayFrames
- ld a, [rBGP] ; $ff47
- and $fc
- ld [rBGP], a ; $ff47
+ ld a, [rBGP]
+ and %11111100
+ ld [rBGP], a
ret
Func_480ff: ; 480ff (12:40ff)
diff --git a/engine/predefs7.asm b/engine/predefs7.asm
index 469fe0c4..b6c3bbbc 100755
--- a/engine/predefs7.asm
+++ b/engine/predefs7.asm
@@ -31,7 +31,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6)
ld b, a
ld a, [hl]
ld c, a
- ld hl, wd3af
+ ld hl, wWarpEntries
call Func_1ca0d
Func_1ca0d: ; 1ca0d (7:4a0d)
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index ed6f52fb..6964b94e 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -1,7 +1,7 @@
PromptUserToPlaySlots: ; 3730e (d:730e)
call SaveScreenTilesToBuffer2
ld a, BANK(DisplayTextIDInit)
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ld b, a
ld hl, DisplayTextIDInit
call Bankswitch
@@ -12,7 +12,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
and a
jr nz, .skip
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wcd4f
xor a
ld [hli], a
@@ -40,7 +40,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e)
ld [W_SUBANIMSUBENTRYADDR], a
call GBPalWhiteOutWithDelay3
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call GoPAL_SET_CF1C
call ReloadMapSpriteTilePatterns
call ReloadTilesetTilePatterns
@@ -221,7 +221,7 @@ SlotMachine_374ad: ; 374ad (d:74ad)
call SlotMachine_374fb
call SlotMachine_37517
ret c
- ld a, [wcf1b]
+ ld a, [wOnSGB]
xor $1
inc a
ld c, a
diff --git a/engine/town_map.asm b/engine/town_map.asm
index 2cd37284..6d10c222 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -1,6 +1,6 @@
DisplayTownMap: ; 70e3e (1c:4e3e)
call LoadTownMap
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -111,7 +111,7 @@ TownMapCursor: ; 70f40 (1c:4f40)
LoadTownMap_Nest: ; 70f60 (1c:4f60)
call LoadTownMap
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -148,7 +148,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
ld bc, (BANK(TownMapUpArrow) << 8) + $01
call CopyVideoDataDouble
call Func_71070
- ld hl, wcfcb
+ ld hl, wUpdateSpritesEnabled
ld a, [hl]
push af
ld [hl], $ff
@@ -206,7 +206,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
ld a, (SFX_02_3e - SFX_Headers_02) / 3
call PlaySound
ld a, [hl]
- ld [wd71a], a
+ ld [wDestinationMap], a
ld hl, wd732
set 3, [hl]
inc hl
diff --git a/engine/trade.asm b/engine/trade.asm
index 0f245fc5..5be77f3e 100755
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -119,10 +119,10 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1)
call FillMemory
call ClearSprites
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld hl, wd730
set 6, [hl]
- ld a, [wcf1b]
+ ld a, [wOnSGB]
and a
ld a, $e4
jr z, .asm_411e5
diff --git a/home.asm b/home.asm
index 735d087d..87215991 100644
--- a/home.asm
+++ b/home.asm
@@ -173,7 +173,7 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313)
ld b,0
add hl,bc
ld bc,4
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call CopyData
pop af
ld [H_LOADEDROMBANK],a
@@ -1464,7 +1464,7 @@ INCLUDE "home/audio.asm"
UpdateSprites:: ; 2429 (0:2429)
- ld a, [wcfcb]
+ ld a, [wUpdateSpritesEnabled]
dec a
ret nz
ld a, [H_LOADEDROMBANK]
@@ -1607,18 +1607,18 @@ DisplayTextID:: ; 2920 (0:2920)
ld l,a ; hl = map text pointer
ld d,$00
ld a,[$ff8c] ; text ID
- ld [wcf13],a
+ ld [wSpriteIndex],a
and a
jp z,DisplayStartMenu
- cp a,$d3 ; safari game over
+ cp a,$d3
jp z,DisplaySafariGameOverText
- cp a,$d0 ; fainted
+ cp a,$d0
jp z,DisplayPokemonFaintedText
- cp a,$d1 ; blacked out
+ cp a,$d1
jp z,DisplayPlayerBlackedOutText
- cp a,$d2 ; repel wore off
+ cp a,$d2
jp z,DisplayRepelWoreOffText
- ld a,[W_NUMSPRITES] ; number of sprites
+ ld a,[W_NUMSPRITES]
ld e,a
ld a,[$ff8c] ; sprite ID
cp e
@@ -1678,7 +1678,7 @@ DisplayTextID:: ; 2920 (0:2920)
jr AfterDisplayingTextID
.notSpecialCase
call Func_3c59 ; display the text
- ld a,[wcc3c]
+ ld a,[wDoNotWaitForButtonPressAfterDisplayingText]
and a
jr nz,HoldTextDisplayOpen
@@ -1723,13 +1723,13 @@ CloseTextDisplay:: ; 29e8 (0:29e8)
ld hl,wcfc4
res 0,[hl]
ld a,[wd732]
- bit 3,a
+ bit 3,a ; used fly warp
call z,LoadPlayerSpriteGraphics
call LoadCurrentMapView
pop af
ld [H_LOADEDROMBANK],a
ld [$2000],a
- jp UpdateSprites ; move sprites
+ jp UpdateSprites
DisplayPokemartDialogue:: ; 2a2e (0:2a2e)
push hl
@@ -1757,7 +1757,7 @@ PokemartGreetingText:: ; 2a55 (0:2a55)
LoadItemList:: ; 2a5a (0:2a5a)
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
ld a,h
ld [wd128],a
ld a,l
@@ -1805,7 +1805,7 @@ DisplayPlayerBlackedOutText:: ; 2aa9 (0:2aa9)
ld hl,PlayerBlackedOutText
call PrintText
ld a,[wd732]
- res 5,a
+ res 5,a ; reset forced to use bike bit
ld [wd732],a
jp HoldTextDisplayOpen
@@ -2616,7 +2616,7 @@ ChooseFlyDestination:: ; 30a9 (0:30a9)
; causes the text box to close without waiting for a button press after displaying text
DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6)
ld a,$01
- ld [wcc3c],a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a
ret
; uses an item
@@ -2872,11 +2872,11 @@ TalkToTrainer:: ; 31cc (0:31cc)
; checks if any trainers are seeing the player and wanting to fight
CheckFightingMapTrainers:: ; 3219 (0:3219)
call CheckForEngagingTrainers
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $ff
jr nz, .trainerEngaging
xor a
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld [wTrainerHeaderFlagBit], a
ret
.trainerEngaging
@@ -2900,7 +2900,7 @@ Func_324c:: ; 324c (0:324c)
and $1
ret nz
ld [wJoyIgnore], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
@@ -2939,7 +2939,7 @@ EndTrainerBattle:: ; 3275 (0:3275)
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld hl, W_MISSABLEOBJECTLIST
ld de, $2
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
call IsInArray ; search for sprite ID
inc hl
ld a, [hl]
@@ -3006,7 +3006,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
.trainerLoop
call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer
ld a, [de]
- ld [wcf13], a ; store trainer flag's bit
+ ld [wSpriteIndex], a ; store trainer flag's bit
ld [wTrainerHeaderFlagBit], a
cp $ff
ret z
@@ -3028,7 +3028,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
ld a, [hl] ; read trainer engage distance
pop hl
ld [wTrainerEngageDistance], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
swap a
ld [wTrainerSpriteOffset], a ; wWhichTrade
predef TrainerEngage
@@ -3059,11 +3059,11 @@ PreBattleSaveRegisters:: ; 3354 (0:3354)
ret
; loads data of some trainer on the current map and plays pre-battle music
-; [wcf13]: sprite ID of trainer who is engaged
+; [wSpriteIndex]: sprite ID of trainer who is engaged
EngageMapTrainer:: ; 336a (0:336a)
ld hl, W_MAPSPRITEEXTRADATA
ld d, $0
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
dec a
add a
ld e, a
@@ -4708,9 +4708,9 @@ DisableAutoTextBoxDrawing:: ; 3c3f (0:3c3f)
ld a,$01
AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41)
- ld [wcf0c],a ; control text box drawing
+ ld [wAutoTextBoxDrawingControl],a
xor a
- ld [wcc3c],a ; make DisplayTextID wait for button press
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press
ret
PrintText:: ; 3c49 (0:3c49)
@@ -5015,7 +5015,7 @@ IsInRestOfArray::
RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe)
call ClearSprites
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
call ReloadMapSpriteTilePatterns
call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
@@ -5052,7 +5052,7 @@ GBPalWhiteOut::
GoPAL_SET_CF1C:: ; 3ded (0:3ded)
ld b,$ff
GoPAL_SET:: ; 3def (0:3def)
- ld a,[wcf1b]
+ ld a,[wOnSGB]
and a
ret z
predef_jump Func_71ddf
diff --git a/home/audio.asm b/home/audio.asm
index 8dcc0d93..9210924c 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -17,7 +17,7 @@ Func_2312:: ; 2312 (0:2312)
ld c, $8
ld d, c
asm_2324:: ; 2324 (0:2324)
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_2343
cp $2
diff --git a/home/fade.asm b/home/fade.asm
index 9b55eaf2..08e087b4 100644
--- a/home/fade.asm
+++ b/home/fade.asm
@@ -1,7 +1,7 @@
; These routines manage gradual fading
; (e.g., entering a doorway)
LoadGBPal::
- ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?)
+ ld a, [wMapPalOffset] ;tells if cur.map is dark (requires HM5_FLASH?)
ld b, a
ld hl, FadePal4
ld a, l
@@ -18,16 +18,16 @@ LoadGBPal::
ld [rOBP1], a
ret
-GBFadeOut1::
+GBFadeInFromBlack::
ld hl, FadePal1
ld b, 4
- jr GBFadeOutCommon
+ jr GBFadeIncCommon
-GBFadeOut2::
+GBFadeOutToWhite::
ld hl, FadePal6
ld b, 3
-GBFadeOutCommon::
+GBFadeIncCommon:
ld a, [hli]
ld [rBGP], a
ld a, [hli]
@@ -37,19 +37,19 @@ GBFadeOutCommon::
ld c, 8
call DelayFrames
dec b
- jr nz, GBFadeOutCommon
+ jr nz, GBFadeIncCommon
ret
-GBFadeIn1::
+GBFadeOutToBlack::
ld hl, FadePal4 + 2
ld b, 4
- jr GBFadeInCommon
+ jr GBFadeDecCommon
-GBFadeIn2::
+GBFadeInFromWhite::
ld hl, FadePal7 + 2
ld b, 3
-GBFadeInCommon::
+GBFadeDecCommon:
ld a, [hld]
ld [rOBP1], a
ld a, [hld]
@@ -59,7 +59,7 @@ GBFadeInCommon::
ld c, 8
call DelayFrames
dec b
- jr nz, GBFadeInCommon
+ jr nz, GBFadeDecCommon
ret
FadePal1:: db %11111111, %11111111, %11111111
diff --git a/home/init.asm b/home/init.asm
index cf8f448e..402a402e 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -105,7 +105,7 @@ rLCDC_DEFAULT EQU %11100011
xor a
ld [$ffbc], a
dec a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
predef PlayIntro
diff --git a/home/overworld.asm b/home/overworld.asm
index a8747f2d..9dbfdfb7 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -12,11 +12,11 @@ EnterMap::
call LoadMapData
callba Func_c335 ; initialize map variables
ld hl, wd72c
- bit 0, [hl]
- jr z, .doNotCountSteps
- ld a, 3
- ld [wd13c], a ; some kind of step counter (counts up to 3 steps?)
-.doNotCountSteps
+ bit 0, [hl] ; has the player already made 3 steps since the last battle?
+ jr z, .skipGivingThreeStepsOfNoRandomBattles
+ ld a, 3 ; minimum number of steps between battles
+ ld [wNumberOfNoRandomBattleStepsLeft], a
+.skipGivingThreeStepsOfNoRandomBattles
ld hl, wd72e
bit 5, [hl] ; did a battle happen immediately before this?
res 5, [hl] ; unset the "battle just happened" flag
@@ -24,12 +24,12 @@ EnterMap::
call nz, MapEntryAfterBattle
ld hl, wd732
ld a, [hl]
- and 1 << 4 | 1 << 3
- jr z, .didNotFlyOrTeleportIn
+ and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ jr z, .didNotEnterUsingFlyWarpOrDungeonWarp
res 3, [hl]
- callba Func_70510 ; display fly/teleport in graphical effect
+ callba EnterMapAnim ; display fly/teleport in graphical effect
call UpdateSprites
-.didNotFlyOrTeleportIn
+.didNotEnterUsingFlyWarpOrDungeonWarp
callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road
ld hl, wd72d
res 5, [hl]
@@ -61,8 +61,8 @@ OverworldLoopLessDelay::
res 3,[hl]
jp nz,WarpFound2
ld a,[wd732]
- and a,$18
- jp nz,HandleFlyOrTeleportAway
+ and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
+ jp nz,HandleFlyWarpOrDungeonWarp
ld a,[W_CUROPPONENT]
and a
jp nz,.newBattle
@@ -98,8 +98,8 @@ OverworldLoopLessDelay::
and a
jp z,OverworldLoop
.displayDialogue
- predef Func_c586 ; check what is in front of the player
- call UpdateSprites ; move sprites
+ predef GetTileAndCoordsInFrontOfPlayer
+ call UpdateSprites
ld a,[wFlags_0xcd60]
bit 2,a
jr nz,.checkForOpponent
@@ -117,8 +117,8 @@ OverworldLoopLessDelay::
jr z,.changeMap
predef LoadSAV
ld a,[W_CURMAP]
- ld [wd71a],a
- call Func_62ce
+ ld [wDestinationMap],a
+ call SpecialWarpIn
ld a,[W_CURMAP]
call SwitchToMapRomBank ; switch to the ROM bank of the current map
ld hl,W_CURMAPTILESET
@@ -133,7 +133,7 @@ OverworldLoopLessDelay::
.noDirectionButtonsPressed
ld hl,wFlags_0xcd60
res 2,[hl]
- call UpdateSprites ; move sprites
+ call UpdateSprites
ld a,$01
ld [wcc4b],a
ld a,[wd528] ; the direction that was pressed last time
@@ -225,18 +225,20 @@ OverworldLoopLessDelay::
.noDirectionChange
ld a,[wd52a] ; current direction
ld [wd528],a ; save direction
- call UpdateSprites ; move sprites
- ld a,[wd700]
+ call UpdateSprites
+ ld a,[wWalkBikeSurfState]
cp a,$02 ; surfing
jr z,.surfing
; not surfing
call CollisionCheckOnLand
jr nc,.noCollision
+; collision occurred
push hl
ld hl,wd736
- bit 2,[hl]
+ bit 2,[hl] ; standing on warp flag
pop hl
jp z,OverworldLoop
+; collision occurred while standing on a warp
push hl
call ExtraWarpCheck ; sets carry if there is a potential to warp
pop hl
@@ -259,7 +261,7 @@ OverworldLoopLessDelay::
.moveAhead2
ld hl,wFlags_0xcd60
res 2,[hl]
- ld a,[wd700]
+ ld a,[wWalkBikeSurfState]
dec a ; riding a bike?
jr nz,.normalPlayerSpriteAdvancement
ld a,[wd736]
@@ -276,16 +278,16 @@ OverworldLoopLessDelay::
bit 7,a
jr nz,.doneStepCounting ; if button presses are being simulated, don't count steps
; step counting
- ld hl,wd13b ; step counter
+ ld hl,wStepCounter
dec [hl]
ld a,[wd72c]
bit 0,a
jr z,.doneStepCounting
- ld hl,wd13c
+ ld hl,wNumberOfNoRandomBattleStepsLeft
dec [hl]
jr nz,.doneStepCounting
ld hl,wd72c
- res 0,[hl]
+ res 0,[hl] ; indicate that the player has stepped thrice since the last battle
.doneStepCounting
ld a,[wd790]
bit 7,a ; in the safari zone?
@@ -298,14 +300,14 @@ OverworldLoopLessDelay::
ld a,[W_ISINBATTLE]
and a
jp nz,CheckWarpsNoCollision
- predef Func_c69c ; decrement HP of poisoned pokemon
+ predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp
ld a,[wd12d]
and a
jp nz,HandleBlackOut ; if all pokemon fainted
.newBattle
call NewBattle
ld hl,wd736
- res 2,[hl]
+ res 2,[hl] ; standing on warp flag
jp nc,CheckWarpsNoCollision ; check for warps if there was no battle
.battleOccurred
ld hl,wd72d
@@ -316,7 +318,7 @@ OverworldLoopLessDelay::
set 5,[hl]
set 6,[hl]
xor a
- ld [hJoyHeld],a ; clear joypad state
+ ld [hJoyHeld],a
ld a,[W_CURMAP]
cp a,CINNABAR_GYM
jr nz,.notCinnabarGym
@@ -327,8 +329,8 @@ OverworldLoopLessDelay::
set 5,[hl]
ld a,[W_CURMAP]
cp a,OAKS_LAB
- jp z,.noFaintCheck
- callab AnyPartyAlive ; check if all the player's pokemon fainted
+ jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab
+ callab AnyPartyAlive
ld a,d
and a
jr z,.allPokemonFainted
@@ -355,7 +357,7 @@ NewBattle:: ; 0683 (0:0683)
jr nz,.noBattle
ld b, BANK(InitBattle)
ld hl, InitBattle
- jp Bankswitch ; determines if a battle will occur and runs the battle if so
+ jp Bankswitch
.noBattle
and a
ret
@@ -368,25 +370,25 @@ BikeSpeedup:: ; 06a0 (0:06a0)
ld a,[W_CURMAP]
cp a,ROUTE_17 ; Cycling Road
jr nz,.goFaster
- ld a,[hJoyHeld] ; current joypad state
- and a,%01110000 ; bit mask for up, left, right buttons
+ ld a,[hJoyHeld]
+ and a,D_UP | D_LEFT | D_RIGHT
ret nz
.goFaster
jp AdvancePlayerSprite
; check if the player has stepped onto a warp after having not collided
CheckWarpsNoCollision:: ; 06b4 (0:06b4)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
and a
jp z,CheckMapConnections
- ld a,[wd3ae] ; number of warps
- ld b,$00
+ ld a,[wNumberOfWarps]
+ ld b,0
ld c,a
ld a,[W_YCOORD]
ld d,a
ld a,[W_XCOORD]
ld e,a
- ld hl,wd3af ; start of warp entries
+ ld hl,wWarpEntries
CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc)
ld a,[hli] ; check if the warp's Y position matches
cp d
@@ -398,14 +400,14 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc)
push hl
push bc
ld hl,wd736
- set 2,[hl]
- callba Func_c49d ; check if the player sprite is standing on a "door" tile
+ set 2,[hl] ; standing on warp flag
+ callba IsPlayerStandingOnDoorTileOrWarpTile
pop bc
pop hl
- jr c,WarpFound1 ; if it is, go to 0735
+ jr c,WarpFound1 ; jump if standing on door or warp
push hl
push bc
- call ExtraWarpCheck ; sets carry if the warp is confirmed
+ call ExtraWarpCheck
pop bc
pop hl
jr nc,CheckWarpsNoCollisionRetry2
@@ -418,16 +420,16 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc)
call Joypad
pop bc
pop de
- ld a,[hJoyHeld] ; current joypad state
- and a,%11110000 ; bit mask for directional buttons
+ ld a,[hJoyHeld]
+ and a,D_DOWN | D_UP | D_LEFT | D_RIGHT
jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp
jr WarpFound1
; check if the player has stepped onto a warp after having collided
CheckWarpsCollision:: ; 0706 (0:0706)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
ld c,a
- ld hl,wd3af ; start of warp entries
+ ld hl,wWarpEntries
.loop
ld a,[hli] ; Y coordinate of warp
ld b,a
@@ -440,7 +442,7 @@ CheckWarpsCollision:: ; 0706 (0:0706)
cp b
jr nz,.retry2
ld a,[hli]
- ld [wd42f],a ; save target warp ID
+ ld [wDestinationWarpID],a
ld a,[hl]
ld [$ff8b],a ; save target map
jr WarpFound2
@@ -462,12 +464,12 @@ CheckWarpsNoCollisionRetry2:: ; 0730 (0:0730)
WarpFound1:: ; 0735 (0:0735)
ld a,[hli]
- ld [wd42f],a ; save target warp ID
+ ld [wDestinationWarpID],a
ld a,[hli]
ld [$ff8b],a ; save target map
WarpFound2:: ; 073c (0:073c)
- ld a,[wd3ae] ; number of warps
+ ld a,[wNumberOfWarps]
sub c
ld [wd73b],a ; save ID of used warp
ld a,[W_CURMAP]
@@ -484,8 +486,8 @@ WarpFound2:: ; 073c (0:073c)
cp a,ROCK_TUNNEL_1
jr nz,.notRockTunnel
ld a,$06
- ld [wd35d],a
- call GBFadeIn1
+ ld [wMapPalOffset],a
+ call GBFadeOutToBlack
.notRockTunnel
call PlayMapChangeSound
jr .done
@@ -496,16 +498,16 @@ WarpFound2:: ; 073c (0:073c)
jr z,.goBackOutside
; if not going back to the previous map
ld [W_CURMAP],a ; current map number
- callba Func_70787 ; check if the warp was a Silph Co. teleporter
+ callba IsPlayerStandingOnWarpPadOrHole
ld a,[wcd5b]
- dec a
- jr nz,.notTeleporter
-; if it's a Silph Co. teleporter
+ dec a ; is the player on a warp pad?
+ jr nz,.notWarpPad
+; if the player is on a warp pad
ld hl,wd732
set 3,[hl]
call LeaveMapAnim
jr .skipMapChangeSound
-.notTeleporter
+.notWarpPad
call PlayMapChangeSound
.skipMapChangeSound
ld hl,wd736
@@ -517,7 +519,7 @@ WarpFound2:: ; 073c (0:073c)
ld [W_CURMAP],a
call PlayMapChangeSound
xor a
- ld [wd35d],a
+ ld [wMapPalOffset],a
.done
ld hl,wd736
set 0,[hl] ; have the player's sprite step out from the door (if there is one)
@@ -562,9 +564,9 @@ CheckMapConnections:: ; 07ba (0:07ba)
jr nz,.pointerAdjustmentLoop1
.savePointer1
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkEastMap
ld b,a
@@ -598,9 +600,9 @@ CheckMapConnections:: ; 07ba (0:07ba)
jr nz,.pointerAdjustmentLoop2
.savePointer2
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkNorthMap
ld a,[W_YCOORD]
@@ -624,9 +626,9 @@ CheckMapConnections:: ; 07ba (0:07ba)
srl c
add hl,bc
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
jp .loadNewMap
.checkSouthMap
ld b,a
@@ -651,9 +653,9 @@ CheckMapConnections:: ; 07ba (0:07ba)
srl c
add hl,bc
ld a,l
- ld [wd35f],a ; pointer to upper left corner of current tile block map section
+ ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section
ld a,h
- ld [wd360],a
+ ld [wCurrentTileBlockMapViewPointer + 1],a
.loadNewMap ; load the connected map that was entered
call LoadMapHeader
call Func_2312 ; music
@@ -678,10 +680,10 @@ PlayMapChangeSound:: ; 08c9 (0:08c9)
ld a,(SFX_02_5c - SFX_Headers_02) / 3
.playSound
call PlaySound
- ld a,[wd35d]
+ ld a,[wMapPalOffset]
and a
ret nz
- jp GBFadeIn1
+ jp GBFadeOutToBlack
CheckIfInOutsideMap:: ; 08e1 (0:08e1)
; If the player is in an outside map (a town or route), set the z flag
@@ -719,37 +721,37 @@ ExtraWarpCheck:: ; 08e9 (0:08e9)
cp PLATEAU ; Indigo Plateau tileset
jr z, .useFunction2
.useFunction1
- ld hl, Func_c3ff
+ ld hl, IsPlayerFacingEdgeOfMap
jr .doBankswitch
.useFunction2
- ld hl, Func_c44e
+ ld hl, IsWarpTileInFrontOfPlayer
.doBankswitch
- ld b, BANK(Func_c44e)
+ ld b, BANK(IsWarpTileInFrontOfPlayer)
jp Bankswitch
MapEntryAfterBattle:: ; 091f (0:091f)
- callba Func_c35f ; function that appears to disable warp testing after collisions if the player is standing on a warp
- ld a,[wd35d]
+ callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions
+ ld a,[wMapPalOffset]
and a
- jp z,GBFadeIn2
+ jp z,GBFadeInFromWhite
jp LoadGBPal
HandleBlackOut::
; For when all the player's pokemon faint.
; Does not print the "blacked out" message.
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $08
call StopMusic
ld hl, wd72e
res 5, [hl]
- ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f)
+ ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap)
ld [H_LOADEDROMBANK], a
ld [MBC3RomBank], a
- call Func_40b0
- call Func_62ce
+ call ResetStatusAndHalveMoneyOnBlackout
+ call SpecialWarpIn
call Func_2312
- jp Func_5d5f
+ jp SpecialEnterMap
StopMusic::
ld [wMusicHeaderPointer], a
@@ -762,23 +764,23 @@ StopMusic::
jr nz, .wait
jp StopAllSounds
-HandleFlyOrTeleportAway::
+HandleFlyWarpOrDungeonWarp::
call UpdateSprites
call Delay3
xor a
ld [wBattleResult], a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld [W_ISINBATTLE], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld hl, wd732
- set 2, [hl]
- res 5, [hl]
+ set 2, [hl] ; fly warp or dungeon warp
+ res 5, [hl] ; forced to ride bike
call LeaveMapAnim
- ld a, Bank(Func_62ce)
+ ld a, Bank(SpecialWarpIn)
ld [H_LOADEDROMBANK], a
ld [$2000], a
- call Func_62ce
- jp Func_5d5f
+ call SpecialWarpIn
+ jp SpecialEnterMap
LeaveMapAnim::
ld b, BANK(_LeaveMapAnim)
@@ -792,7 +794,7 @@ LoadPlayerSpriteGraphics::
; 1: biking
; 2: surfing
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
dec a
jr z, .ridingBike
@@ -809,12 +811,12 @@ LoadPlayerSpriteGraphics::
.startWalking
xor a
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp LoadWalkingPlayerSpriteGraphics
.determineGraphics
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jp z, LoadWalkingPlayerSpriteGraphics
dec a
@@ -1065,7 +1067,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
and a
jr z,.extendRangeOverCounter
; if there are signs
- predef Func_c586 ; get the coordinates in front of the player in de
+ predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de
ld hl,wd4b1 ; start of sign coordinates
ld a,[wd4b0] ; number of signs in the map
ld b,a
@@ -1099,7 +1101,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
jr nz,.signLoop
; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC
.extendRangeOverCounter
- predef Func_c586 ; get the tile in front of the player in c
+ predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c
ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles)
ld b,$03
ld d,$20 ; talking range in pixels (long range)
@@ -1239,8 +1241,8 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1)
; function that checks if the tile in front of the player is passable
; clears carry if it is, sets carry if not
CheckTilePassable:: ; 0c10 (0:0c10)
- predef Func_c586 ; get tile in front of player
- ld a,[wcfc6] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
+ ld a,[wTileInFrontOfPlayer] ; tile in front of player
ld c,a
ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles
ld a,[hli]
@@ -1263,7 +1265,7 @@ CheckTilePassable:: ; 0c10 (0:0c10)
; sets carry if there is a collision and unsets carry if not
CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a)
push hl
- predef Func_c586 ; get the tile in front of the player
+ predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player
push de
push bc
callba HandleLedges ; check if the player is trying to jump a ledge
@@ -1276,12 +1278,12 @@ CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a)
ret nz
; if not jumping
-Func_c44:: ; 0c44 (0:0c44)
+CheckForTilePairCollisions2:: ; 0c44 (0:0c44)
aCoord 8, 9 ; tile the player is on
ld [wcf0e],a
CheckForTilePairCollisions:: ; 0c4a (0:0c4a)
- ld a,[wcfc6] ; tile in front of the player
+ ld a,[wTileInFrontOfPlayer]
ld c,a
.tilePairCollisionLoop
ld a,[W_CURMAPTILESET] ; tileset number
@@ -1357,9 +1359,9 @@ LoadCurrentMapView:: ; 0caa (0:0caa)
ld a,[W_TILESETBANK] ; tile data ROM bank
ld [H_LOADEDROMBANK],a
ld [$2000],a ; switch to ROM bank that contains tile data
- ld a,[wd35f] ; address of upper left corner of current map view
+ ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
ld e,a
- ld a,[wd360]
+ ld a,[wCurrentTileBlockMapViewPointer + 1]
ld d,a
ld hl,wTileMapBackup
ld b,$05
@@ -1531,9 +1533,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
; moved into the tile block to the east
xor a
ld [hl],a
- ld hl,wd4e3
+ ld hl,wXOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerEast
jr .updateMapView
.checkForMoveToWestBlock
@@ -1542,9 +1544,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
; moved into the tile block to the west
ld a,$01
ld [hl],a
- ld hl,wd4e3
+ ld hl,wXOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
call MoveTileBlockMapPointerWest
jr .updateMapView
.adjustYCoordWithinBlock
@@ -1557,9 +1559,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
; moved into the tile block to the south
xor a
ld [hl],a
- ld hl,wd4e2
+ ld hl,wYOffsetSinceLastSpecialWarp
inc [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
ld a,[W_CURMAPWIDTH]
call MoveTileBlockMapPointerSouth
jr .updateMapView
@@ -1569,9 +1571,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
; moved into the tile block to the north
ld a,$01
ld [hl],a
- ld hl,wd4e2
+ ld hl,wYOffsetSinceLastSpecialWarp
dec [hl]
- ld de,wd35f
+ ld de,wCurrentTileBlockMapViewPointer
ld a,[W_CURMAPWIDTH]
call MoveTileBlockMapPointerNorth
.updateMapView
@@ -1905,8 +1907,8 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7)
ld hl,TilePairCollisionsWater
call CheckForJumpingAndTilePairCollisions
jr c,.collision
- predef Func_c586 ; get tile in front of player (puts it in c and [wcfc6])
- ld a,[wcfc6] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player (puts it in c and [wTileInFrontOfPlayer])
+ ld a,[wTileInFrontOfPlayer] ; tile in front of player
cp a,$14 ; water tile
jr z,.noCollision ; keep surfing if it's a water tile
cp a,$32 ; either the left tile of the S.S. Anne boarding platform or the tile on eastern coastlines (depending on the current tileset)
@@ -1941,7 +1943,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7)
ret
.stopSurfing
xor a
- ld [wd700],a
+ ld [wWalkBikeSurfState],a
call LoadPlayerSpriteGraphics
call PlayDefaultMusic
jr .noCollision
@@ -2089,12 +2091,12 @@ LoadMapHeader:: ; 107c (0:107c)
ld a,[hli]
ld [de],a ; save background tile ID
.loadWarpData
- ld a,[hli] ; number of warps
- ld [wd3ae],a ; save the number of warps
- and a ; are there any warps?
- jr z,.loadSignData ; if not, skip this
+ ld a,[hli]
+ ld [wNumberOfWarps],a
+ and a
+ jr z,.loadSignData
ld c,a
- ld de,wd3af ; base address of warps
+ ld de,wWarpEntries
.warpLoop ; one warp per loop iteration
ld b,$04
.warpInnerLoop
@@ -2258,8 +2260,8 @@ LoadMapHeader:: ; 107c (0:107c)
dec b
jp nz,.loadSpriteLoop
.finishUp
- predef Func_c754 ; load tileset data
- callab LoadWildData ; load wild pokemon data
+ predef LoadTilesetHeader
+ callab LoadWildData
pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose)
ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks
add a ; double it
@@ -2312,7 +2314,7 @@ LoadMapData:: ; 1241 (0:1241)
ld [$ffae],a
ld [wWalkCounter],a
ld [wd119],a
- ld [wd11a],a
+ ld [wWalkBikeSurfStateCopy],a
ld [W_SPRITESETID],a
call LoadTextBoxTilePatterns
call LoadMapHeader
@@ -2341,13 +2343,13 @@ LoadMapData:: ; 1241 (0:1241)
dec b
jr nz,.vramCopyLoop
ld a,$01
- ld [wcfcb],a
+ ld [wUpdateSpritesEnabled],a
call EnableLCD
ld b,$09
call GoPAL_SET
call LoadPlayerSpriteGraphics
ld a,[wd732]
- and a,$18 ; did the player fly or teleport in?
+ and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp
jr nz,.restoreRomBank
ld a,[W_FLAGS_D733]
bit 1,a
diff --git a/home/predef.asm b/home/predef.asm
index 1777d09f..8efe3000 100644
--- a/home/predef.asm
+++ b/home/predef.asm
@@ -7,7 +7,7 @@ Predef::
ld [wPredefID], a
; A hack for LoadDestinationWarpPosition.
- ; See Func_c754 (predef $19).
+ ; See LoadTilesetHeader (predef $19).
ld a, [H_LOADEDROMBANK]
ld [wPredefParentBank], a
diff --git a/main.asm b/main.asm
index a64d92b7..22721cdb 100755
--- a/main.asm
+++ b/main.asm
@@ -19,13 +19,13 @@ SECTION "bank1",ROMX,BANK[$1]
INCLUDE "data/facing.asm"
-Func_40b0::
+ResetStatusAndHalveMoneyOnBlackout::
; Reset player status on blackout.
xor a
ld [wBattleResult], a
- ld [wd700], a
+ ld [wWalkBikeSurfState], a
ld [W_ISINBATTLE], a
- ld [wd35d], a
+ ld [wMapPalOffset], a
ld [wNPCMovementScriptFunctionNum], a
ld [hJoyHeld], a
ld [wNPCMovementScriptPointerTableNum], a
@@ -578,7 +578,7 @@ TestBattle:
; When the battle ends,
; do it all again.
ld a, 1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [H_AUTOBGTRANSFERENABLED], a
jr .loop
@@ -597,19 +597,20 @@ INCLUDE "engine/menu/main_menu.asm"
INCLUDE "engine/oak_speech.asm"
-Func_62ce: ; 62ce (1:62ce)
- call Func_62ff
- predef Func_c754
+SpecialWarpIn: ; 62ce (1:62ce)
+ call LoadSpecialWarpData
+ predef LoadTilesetHeader
ld hl,wd732
- bit 2,[hl]
+ bit 2,[hl] ; dungeon warp or fly warp?
res 2,[hl]
jr z,.next
- ld a,[wd71a]
+; if dungeon warp or fly warp
+ ld a,[wDestinationMap]
jr .next2
.next
bit 1,[hl]
jr z,.next3
- call Func_64ea
+ call EmptyFunc
.next3
ld a,0
.next2
@@ -620,125 +621,128 @@ Func_62ce: ; 62ce (1:62ce)
ld a,b
.next4
ld hl,wd732
- bit 4,[hl]
+ bit 4,[hl] ; dungeon warp?
ret nz
+; if not dungeon warp
ld [wLastMap],a
ret
-Func_62ff: ; 62ff (1:62ff)
+; gets the map ID, tile block map view pointer, tileset, and coordinates
+LoadSpecialWarpData: ; 62ff (1:62ff)
ld a, [wd72d]
cp BATTLE_CENTER
- jr nz, .asm_6314
- ld hl, BattleCenterSpec1 ; $6428
+ jr nz, .notBattleCenter
+ ld hl, BattleCenterSpec1
ld a, [$ffaa]
cp $2
- jr z, .asm_6334
- ld hl, BattleCenterSpec2 ; $6430
- jr .asm_6334
-.asm_6314
+ jr z, .copyWarpData
+ ld hl, BattleCenterSpec2
+ jr .copyWarpData
+.notBattleCenter
cp TRADE_CENTER
- jr nz, .asm_6326
- ld hl, TradeCenterSpec1 ; $6438
+ jr nz, .notTradeCenter
+ ld hl, TradeCenterSpec1
ld a, [$ffaa]
cp $2
- jr z, .asm_6334
- ld hl, TradeCenterSpec2 ; $6440
- jr .asm_6334
-.asm_6326
+ jr z, .copyWarpData
+ ld hl, TradeCenterSpec2
+ jr .copyWarpData
+.notTradeCenter
ld a, [wd732]
bit 1, a
- jr nz, .asm_6346
+ jr nz, .notFirstMap
bit 2, a
- jr nz, .asm_6346
- ld hl, FirstMapSpec ; $6420
-.asm_6334
- ld de, W_CURMAP ; W_CURMAP
+ jr nz, .notFirstMap
+ ld hl, FirstMapSpec
+.copyWarpData
+ ld de, W_CURMAP
ld c, $7
-.asm_6339
+.copyWarpDataLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_6339
+ jr nz, .copyWarpDataLoop
ld a, [hli]
- ld [W_CURMAPTILESET], a ; W_CURMAPTILESET
+ ld [W_CURMAPTILESET], a
xor a
- jr .asm_63b3
-.asm_6346
+ jr .done
+.notFirstMap
ld a, [wLastMap]
ld hl, wd732
- bit 4, [hl]
- jr nz, .asm_635b
- bit 6, [hl]
+ bit 4, [hl] ; used dungeon warp (jumped down hole/waterfall)?
+ jr nz, .usedDunegonWarp
+ bit 6, [hl] ; return to last pokemon center (or player's house)?
res 6, [hl]
- jr z, .asm_638e
+ jr z, .otherDestination
+; return to last pokemon center or player's house
ld a, [wLastBlackoutMap]
- jr .asm_6391
-.asm_635b
+ jr .usedFlyWarp
+.usedDunegonWarp
ld hl, wd72d
res 4, [hl]
- ld a, [wd71d]
+ ld a, [wDungeonWarpDestinationMap]
ld b, a
- ld [W_CURMAP], a ; W_CURMAP
- ld a, [wd71e]
+ ld [W_CURMAP], a
+ ld a, [wWhichDungeonWarp]
ld c, a
- ld hl, DungeonWarpList ; $63bf
+ ld hl, DungeonWarpList
ld de, $0
ld a, $6
ld [wd12f], a
-.asm_6376
+.dungeonWarpListLoop
ld a, [hli]
cp b
- jr z, .asm_637d
+ jr z, .matchedDungeonWarpDestinationMap
inc hl
- jr .asm_6381
-.asm_637d
+ jr .nextDungeonWarp
+.matchedDungeonWarpDestinationMap
ld a, [hli]
cp c
- jr z, .asm_6388
-.asm_6381
+ jr z, .matchedDungeonWarpID
+.nextDungeonWarp
ld a, [wd12f]
add e
ld e, a
- jr .asm_6376
-.asm_6388
- ld hl, DungeonWarpData ; $63d8
+ jr .dungeonWarpListLoop
+.matchedDungeonWarpID
+ ld hl, DungeonWarpData
add hl, de
- jr .asm_63a4
-.asm_638e
- ld a, [wd71a]
-.asm_6391
+ jr .copyWarpData2
+.otherDestination
+ ld a, [wDestinationMap]
+.usedFlyWarp
ld b, a
- ld [W_CURMAP], a ; W_CURMAP
- ld hl, FlyWarpDataPtr ; $6448
-.asm_6398
+ ld [W_CURMAP], a
+ ld hl, FlyWarpDataPtr
+.flyWarpDataPtrLoop
ld a, [hli]
inc hl
cp b
- jr z, .asm_63a1
+ jr z, .foundFlyWarpMatch
inc hl
inc hl
- jr .asm_6398
-.asm_63a1
+ jr .flyWarpDataPtrLoop
+.foundFlyWarpMatch
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_63a4
- ld de, wd35f
+.copyWarpData2
+ ld de, wCurrentTileBlockMapViewPointer
ld c, $6
-.asm_63a9
+.copyWarpDataLoop2
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_63a9
- xor a
- ld [W_CURMAPTILESET], a ; W_CURMAPTILESET
-.asm_63b3
- ld [wd4e2], a
- ld [wd4e3], a
- ld a, $ff
- ld [wd42f], a
+ jr nz, .copyWarpDataLoop2
+ xor a ; OVERWORLD
+ ld [W_CURMAPTILESET], a
+.done
+ ld [wYOffsetSinceLastSpecialWarp], a
+ ld [wXOffsetSinceLastSpecialWarp], a
+ ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps
+ ld [wDestinationWarpID], a
ret
INCLUDE "data/special_warps.asm"
@@ -774,7 +778,7 @@ IshiharaTeam: ; 64df (1:64df)
db ARTICUNO,57
db $FF
-Func_64ea: ; 64ea (1:64ea)
+EmptyFunc: ; 64ea (1:64ea)
ret
INCLUDE "engine/menu/naming_screen.asm"
@@ -989,7 +993,7 @@ SafariZoneRestHouses:
DisplayTextIDInit: ; 7096 (1:7096)
xor a
ld [wListMenuID],a
- ld a,[wcf0c]
+ ld a,[wAutoTextBoxDrawingControl]
bit 0,a
jr nz,.skipDrawingTextBoxBorder
ld a,[$ff8c] ; text ID (or sprite ID)
@@ -2005,7 +2009,7 @@ Func_7c18: ; 7c18 (1:7c18)
ld hl, wPokedexSeen
predef FlagActionPredef
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
@@ -2023,7 +2027,7 @@ Func_c335: ; c335 (3:4335)
ld [rWY], a ; $ff4a
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld [wd13b], a
+ ld [wStepCounter], a
ld [W_LONEATTACKNO], a ; W_GYMLEADERNO
ld [hJoyPressed], a
ld [hJoyReleased], a
@@ -2038,36 +2042,37 @@ Func_c335: ; c335 (3:4335)
call FillMemory
ret
-Func_c35f: ; c35f (3:435f)
- ld a, [wd3ae]
+; only used for setting bit 2 of wd736 upon entering a new map
+IsPlayerStandingOnWarp: ; c35f (3:435f)
+ ld a, [wNumberOfWarps]
and a
ret z
ld c, a
- ld hl, wd3af
-.asm_c368
- ld a, [W_YCOORD] ; wd361
+ ld hl, wWarpEntries
+.loop
+ ld a, [W_YCOORD]
cp [hl]
- jr nz, .asm_c383
+ jr nz, .nextWarp1
inc hl
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
cp [hl]
- jr nz, .asm_c384
+ jr nz, .nextWarp2
inc hl
- ld a, [hli]
- ld [wd42f], a
- ld a, [hl]
- ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
+ ld a, [hli] ; target warp
+ ld [wDestinationWarpID], a
+ ld a, [hl] ; target map
+ ld [$ff8b], a
ld hl, wd736
- set 2, [hl]
+ set 2, [hl] ; standing on warp flag
ret
-.asm_c383
+.nextWarp1
inc hl
-.asm_c384
+.nextWarp2
inc hl
inc hl
inc hl
dec c
- jr nz, .asm_c368
+ jr nz, .loop
ret
CheckForceBikeOrSurf: ; c38b (3:438b)
@@ -2107,8 +2112,8 @@ CheckForceBikeOrSurf: ; c38b (3:438b)
ld hl, wd732
set 5, [hl]
ld a, $1
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
.incorrectMap
inc hl
@@ -2117,30 +2122,30 @@ CheckForceBikeOrSurf: ; c38b (3:438b)
jr .loop
.forceSurfing
ld a, $2
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
INCLUDE "data/force_bike_surf.asm"
-Func_c3ff: ; c3ff (3:43ff)
+IsPlayerFacingEdgeOfMap: ; c3ff (3:43ff)
push hl
push de
push bc
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
srl a
ld c, a
ld b, $0
- ld hl, PointerTable_c422 ; $4422
+ ld hl, .functionPointerTable
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [W_YCOORD] ; wd361
+ ld a, [W_YCOORD]
ld b, a
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
ld c, a
- ld de, .asm_c41e ; $441e
+ ld de, .asm_c41e
push de
jp [hl]
.asm_c41e
@@ -2149,34 +2154,34 @@ Func_c3ff: ; c3ff (3:43ff)
pop hl
ret
-PointerTable_c422: ; c422 (3:4422)
- dw .asm_c42a
- dw .asm_4434
- dw .asm_443A
- dw .asm_4440
+.functionPointerTable
+ dw .facingDown
+ dw .facingUp
+ dw .facingLeft
+ dw .facingRight
-.asm_c42a
- ld a, [W_CURMAPHEIGHT] ; wd368
+.facingDown
+ ld a, [W_CURMAPHEIGHT]
add a
dec a
cp b
jr z, .setCarry
jr .resetCarry
-.asm_4434
+.facingUp
ld a, b
and a
jr z, .setCarry
jr .resetCarry
-.asm_443A
+.facingLeft
ld a, c
and a
jr z, .setCarry
jr .resetCarry
-.asm_4440
- ld a, [W_CURMAPWIDTH] ; wd369
+.facingRight
+ ld a, [W_CURMAPWIDTH]
add a
dec a
cp c
@@ -2189,71 +2194,71 @@ PointerTable_c422: ; c422 (3:4422)
scf
ret
-Func_c44e: ; c44e (3:444e)
+IsWarpTileInFrontOfPlayer: ; c44e (3:444e)
push hl
push de
push bc
- call Func_c589
- ld a, [W_CURMAP] ; W_CURMAP
+ call _GetTileAndCoordsInFrontOfPlayer
+ ld a, [W_CURMAP]
cp SS_ANNE_5
jr z, .ssAnne5
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction
srl a
ld c, a
- ld b, $0
- ld hl, .pointerTable_c477 ; $4477
+ ld b, 0
+ ld hl, .warpTileListPointers
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
ld de, $1
call IsInArray
-.asm_c473
+.done
pop bc
pop de
pop hl
ret
-.pointerTable_c477: ; c477 (3:4477)
- dw .arrayData_c47f
- dw .arrayData_c487
- dw .arrayData_c48a
- dw .arrayData_c48d
+.warpTileListPointers: ; c477 (3:4477)
+ dw .facingDownWarpTiles
+ dw .facingUpWarpTiles
+ dw .facingLeftWarpTiles
+ dw .facingRightWarpTiles
-.arrayData_c47f
+.facingDownWarpTiles
db $01,$12,$17,$3D,$04,$18,$33,$FF
-.arrayData_c487
+.facingUpWarpTiles
db $01,$5C,$FF
-.arrayData_c48a
+.facingLeftWarpTiles
db $1A,$4B,$FF
-.arrayData_c48d
+.facingRightWarpTiles
db $0F,$4E,$FF
.ssAnne5
- ld a, [wcfc6]
+ ld a, [wTileInFrontOfPlayer]
cp $15
- jr nz, .asm_c49a
+ jr nz, .notSSAnne5Warp
scf
- jr .asm_c473
-.asm_c49a
+ jr .done
+.notSSAnne5Warp
and a
- jr .asm_c473
+ jr .done
-Func_c49d: ; c49d (3:449d)
+IsPlayerStandingOnDoorTileOrWarpTile: ; c49d (3:449d)
push hl
push de
push bc
- callba IsPlayerStandingOnDoor
- jr c, .asm_c4c8
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ callba IsPlayerStandingOnDoorTile
+ jr c, .done
+ ld a, [W_CURMAPTILESET]
add a
ld c, a
ld b, $0
- ld hl, WarpTileIDPointers ; $44cc
+ ld hl, WarpTileIDPointers
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -2261,10 +2266,10 @@ Func_c49d: ; c49d (3:449d)
ld de, $1
aCoord 8, 9
call IsInArray
- jr nc, .asm_c4c8
+ jr nc, .done
ld hl, wd736
res 2, [hl]
-.asm_c4c8
+.done
pop bc
pop de
pop hl
@@ -2310,223 +2315,237 @@ SafariSteps: ; c579 (3:4579)
SafariBallText: ; c57e (3:457e)
db "BALL×× @"
-Func_c586: ; c586 (3:4586)
+GetTileAndCoordsInFrontOfPlayer: ; c586 (3:4586)
call GetPredefRegisters
-Func_c589: ; c589 (3:4589)
- ld a, [W_YCOORD] ; wd361
+_GetTileAndCoordsInFrontOfPlayer: ; c589 (3:4589)
+ ld a, [W_YCOORD]
ld d, a
- ld a, [W_XCOORD] ; wd362
+ ld a, [W_XCOORD]
ld e, a
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
and a
- jr nz, .asm_c59d
+ jr nz, .notFacingDown
+; facing down
aCoord 8, 11
inc d
- jr .asm_c5b9
-.asm_c59d
- cp $4
- jr nz, .asm_c5a7
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
aCoord 8, 7
dec d
- jr .asm_c5b9
-.asm_c5a7
- cp $8
- jr nz, .asm_c5b1
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
aCoord 6, 9
dec e
- jr .asm_c5b9
-.asm_c5b1
- cp $c
- jr nz, .asm_c5b9
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
aCoord 10, 9
inc e
-.asm_c5b9
+.storeTile
ld c, a
- ld [wcfc6], a
+ ld [wTileInFrontOfPlayer], a
ret
-Func_c5be: ; c5be (3:45be)
+GetTileTwoStepsInFrontOfPlayer: ; c5be (3:45be)
xor a
ld [$ffdb], a
- ld hl, W_YCOORD ; wd361
+ ld hl, W_YCOORD
ld a, [hli]
ld d, a
ld e, [hl]
- ld a, [wSpriteStateData1 + 9]
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
and a
- jr nz, .asm_c5d8
+ jr nz, .notFacingDown
+; facing down
ld hl, $ffdb
set 0, [hl]
aCoord 8, 13
inc d
- jr .asm_c603
-.asm_c5d8
- cp $4
- jr nz, .asm_c5e7
+ jr .storeTile
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
ld hl, $ffdb
set 1, [hl]
aCoord 8, 5
dec d
- jr .asm_c603
-.asm_c5e7
- cp $8
- jr nz, .asm_c5f6
+ jr .storeTile
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
ld hl, $ffdb
set 2, [hl]
aCoord 4, 9
dec e
- jr .asm_c603
-.asm_c5f6
- cp $c
- jr nz, .asm_c603
+ jr .storeTile
+.notFacingLeft
+ cp SPRITE_FACING_RIGHT
+ jr nz, .storeTile
+; facing right
ld hl, $ffdb
set 3, [hl]
aCoord 12, 9
inc e
-.asm_c603
+.storeTile
ld c, a
- ld [wd71c], a
- ld [wcfc6], a
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
+ ld [wTileInFrontOfPlayer], a
ret
-Func_c60b: ; c60b (3:460b)
- call Func_c5be
+CheckForCollisionWhenPushingBoulder: ; c60b (3:460b)
+ call GetTileTwoStepsInFrontOfPlayer
ld hl, W_TILESETCOLLISIONPTR
ld a, [hli]
ld h, [hl]
ld l, a
-.asm_c614
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_c632
+ jr z, .done ; if the tile two steps ahead is not passable
cp c
- jr nz, .asm_c614
- ld hl, $c7e
- call Func_c44
+ jr nz, .loop
+ ld hl, TilePairCollisionsLand
+ call CheckForTilePairCollisions2
ld a, $ff
- jr c, .asm_c632
- ld a, [wd71c]
- cp $15
+ jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead
+ ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
+ cp $15 ; stairs tile
ld a, $ff
- jr z, .asm_c632
- call Func_c636
-.asm_c632
- ld [wd71c], a
+ jr z, .done ; if the tile two steps ahead is stairs
+ call CheckForBoulderCollisionWithSprites
+.done
+ ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a
ret
-Func_c636: ; c636 (3:4636)
- ld a, [wd718]
+; sets a to $ff if there is a collision and $00 if there is no collision
+CheckForBoulderCollisionWithSprites: ; c636 (3:4636)
+ ld a, [wBoulderSpriteIndex]
dec a
swap a
- ld d, $0
+ ld d, 0
ld e, a
ld hl, wSpriteStateData2 + $14
add hl, de
- ld a, [hli]
+ ld a, [hli] ; map Y position
ld [$ffdc], a
- ld a, [hl]
+ ld a, [hl] ; map X position
ld [$ffdd], a
- ld a, [W_NUMSPRITES] ; W_NUMSPRITES
+ ld a, [W_NUMSPRITES]
ld c, a
ld de, $f
ld hl, wSpriteStateData2 + $14
ld a, [$ffdb]
- and $3
- jr z, .asm_c678
-.asm_c659
+ and $3 ; facing up or down?
+ jr z, .pushingHorizontallyLoop
+.pushingVerticallyLoop
inc hl
ld a, [$ffdd]
cp [hl]
- jr nz, .asm_c672
+ jr nz, .nextSprite1 ; if X coordinates don't match
dec hl
ld a, [hli]
ld b, a
ld a, [$ffdb]
rrca
- jr c, .asm_c66c
+ jr c, .pushingDown
+; pushing up
ld a, [$ffdc]
dec a
- jr .asm_c66f
-.asm_c66c
+ jr .compareYCoords
+.pushingDown
ld a, [$ffdc]
inc a
-.asm_c66f
+.compareYCoords
cp b
- jr z, .asm_c697
-.asm_c672
+ jr z, .failure
+.nextSprite1
dec c
- jr z, .asm_c69a
+ jr z, .success
add hl, de
- jr .asm_c659
-.asm_c678
+ jr .pushingVerticallyLoop
+.pushingHorizontallyLoop
ld a, [hli]
ld b, a
ld a, [$ffdc]
cp b
- jr nz, .asm_c691
+ jr nz, .nextSprite2
ld b, [hl]
ld a, [$ffdb]
bit 2, a
- jr nz, .asm_c68b
+ jr nz, .pushingLeft
+; pushing right
ld a, [$ffdd]
inc a
- jr .asm_c68e
-.asm_c68b
+ jr .compareXCoords
+.pushingLeft
ld a, [$ffdd]
dec a
-.asm_c68e
+.compareXCoords
cp b
- jr z, .asm_c697
-.asm_c691
+ jr z, .failure
+.nextSprite2
dec c
- jr z, .asm_c69a
+ jr z, .success
add hl, de
- jr .asm_c678
-.asm_c697
+ jr .pushingHorizontallyLoop
+.failure
ld a, $ff
ret
-.asm_c69a
+.success
xor a
ret
-Func_c69c: ; c69c (3:469c)
+ApplyOutOfBattlePoisonDamage: ; c69c (3:469c)
ld a, [wd730]
add a
- jp c, .asm_c74f
- ld a, [wPartyCount] ; wPartyCount
+ jp c, .noBlackOut
+ ld a, [wPartyCount]
and a
- jp z, .asm_c74f
- call Func_c8de
- ld a, [wd13b]
- and $3
- jp nz, .asm_c74f
- ld [wWhichPokemon], a ; wWhichPokemon
- ld hl, wPartyMon1Status ; wPartyMon1Status
- ld de, wPartySpecies ; wPartySpecies
-.asm_c6be
+ jp z, .noBlackOut
+ call IncrementDayCareMonExp
+ ld a, [wStepCounter]
+ and $3 ; is the counter a multiple of 4?
+ jp nz, .noBlackOut ; only apply poison damage every fourth step
+ ld [wWhichPokemon], a
+ ld hl, wPartyMon1Status
+ ld de, wPartySpecies
+.applyDamageLoop
ld a, [hl]
- and $8
- jr z, .asm_c6fd
+ and (1 << PSN)
+ jr z, .nextMon2 ; not poisoned
dec hl
dec hl
ld a, [hld]
ld b, a
ld a, [hli]
or b
- jr z, .asm_c6fb
+ jr z, .nextMon ; already fainted
+; subtract 1 from HP
ld a, [hl]
dec a
ld [hld], a
inc a
- jr nz, .asm_c6d5
+ jr nz, .noBorrow
+; borrow 1 from upper byte of HP
dec [hl]
inc hl
- jr .asm_c6fb
-.asm_c6d5
+ jr .nextMon
+.noBorrow
ld a, [hli]
or [hl]
- jr nz, .asm_c6fb
+ jr nz, .nextMon ; didn't faint from damage
+; the mon fainted from the damage
push hl
inc hl
inc hl
@@ -2534,134 +2553,134 @@ Func_c69c: ; c69c (3:469c)
ld a, [de]
ld [wd11e], a
push de
- ld a, [wWhichPokemon] ; wWhichPokemon
- ld hl, wPartyMonNicks ; wPartyMonNicks
+ ld a, [wWhichPokemon]
+ ld hl, wPartyMonNicks
call GetPartyMonName
xor a
ld [wJoyIgnore], a
call EnableAutoTextBoxDrawing
ld a, $d0
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [$ff8c], a
call DisplayTextID
pop de
pop hl
-.asm_c6fb
+.nextMon
inc hl
inc hl
-.asm_c6fd
+.nextMon2
inc de
ld a, [de]
inc a
- jr z, .asm_c70e
- ld bc, $2c
+ jr z, .applyDamageLoopDone
+ ld bc, wPartyMon2 - wPartyMon1
add hl, bc
push hl
- ld hl, wWhichPokemon ; wWhichPokemon
+ ld hl, wWhichPokemon
inc [hl]
pop hl
- jr .asm_c6be
-.asm_c70e
- ld hl, wPartyMon1Status ; wPartyMon1Status
- ld a, [wPartyCount] ; wPartyCount
+ jr .applyDamageLoop
+.applyDamageLoopDone
+ ld hl, wPartyMon1Status
+ ld a, [wPartyCount]
ld d, a
- ld e, $0
-.asm_c717
+ ld e, 0
+.countPoisonedLoop
ld a, [hl]
- and $8
+ and (1 << PSN)
or e
ld e, a
- ld bc, $2c
+ ld bc, wPartyMon2 - wPartyMon1
add hl, bc
dec d
- jr nz, .asm_c717
+ jr nz, .countPoisonedLoop
ld a, e
- and a
- jr z, .asm_c733
+ and a ; are any party members poisoned?
+ jr z, .skipPoisonEffectAndSound
ld b, $2
- predef Func_480eb
+ predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames
ld a, (SFX_02_43 - SFX_Headers_02) / 3
call PlaySound
-.asm_c733
+.skipPoisonEffectAndSound
predef AnyPartyAlive
ld a, d
and a
- jr nz, .asm_c74f
+ jr nz, .noBlackOut
call EnableAutoTextBoxDrawing
ld a, $d1
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [$ff8c], a
call DisplayTextID
ld hl, wd72e
set 5, [hl]
ld a, $ff
- jr .asm_c750
-.asm_c74f
+ jr .done
+.noBlackOut
xor a
-.asm_c750
+.done
ld [wd12d], a
ret
-Func_c754: ; c754 (3:4754)
+LoadTilesetHeader: ; c754 (3:4754)
call GetPredefRegisters
push hl
- ld d, $0
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld d, 0
+ ld a, [W_CURMAPTILESET]
add a
add a
ld b, a
add a
- add b
- jr nc, .asm_c765
+ add b ; a = tileset * 12
+ jr nc, .noCarry
inc d
-.asm_c765
+.noCarry
ld e, a
ld hl, Tilesets
add hl, de
ld de, W_TILESETBANK
ld c, $b
-.asm_c76f
+.copyTilesetHeaderLoop
ld a, [hli]
ld [de], a
inc de
dec c
- jr nz, .asm_c76f
+ jr nz, .copyTilesetHeaderLoop
ld a, [hl]
ld [$ffd7], a
xor a
ld [$ffd8], a
pop hl
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld a, [W_CURMAPTILESET]
push hl
push de
- ld hl, DungeonTilesets ; $47b2
+ ld hl, DungeonTilesets
ld de, $1
call IsInArray
pop de
pop hl
jr c, .asm_c797
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld a, [W_CURMAPTILESET]
ld b, a
- ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b
+ ld a, [$ff8b]
cp b
- jr z, .asm_c7b1
+ jr z, .done
.asm_c797
- ld a, [wd42f]
+ ld a, [wDestinationWarpID]
cp $ff
- jr z, .asm_c7b1
+ jr z, .done
call LoadDestinationWarpPosition
- ld a, [W_YCOORD] ; wd361
+ ld a, [W_YCOORD]
and $1
- ld [W_YBLOCKCOORD], a ; wd363
- ld a, [W_XCOORD] ; wd362
+ ld [W_YBLOCKCOORD], a
+ ld a, [W_XCOORD]
and $1
- ld [W_XBLOCKCOORD], a ; wd364
-.asm_c7b1
+ ld [W_XBLOCKCOORD], a
+.done
ret
INCLUDE "data/dungeon_tilesets.asm"
INCLUDE "data/tileset_headers.asm"
-Func_c8de: ; c8de (3:48de)
+IncrementDayCareMonExp: ; c8de (3:48de)
ld a, [W_DAYCARE_IN_USE]
and a
ret z
@@ -3073,9 +3092,9 @@ Func_ee9e: ; ee9e (3:6e9e)
add hl, bc
ld a, [wd09f]
ld [hl], a
- ld a, [wd35f]
+ ld a, [wCurrentTileBlockMapViewPointer]
ld c, a
- ld a, [wd360]
+ ld a, [wCurrentTileBlockMapViewPointer + 1]
ld b, a
call Func_ef4e
ret c
@@ -3399,7 +3418,7 @@ TryPushingBoulder: ; f225 (3:7225)
ld [$ff8c], a
call IsSpriteInFrontOfPlayer
ld a, [$ff8c]
- ld [wd718], a
+ ld [wBoulderSpriteIndex], a
and a
jp z, ResetBoulderPushFlags
ld hl, wSpriteStateData1 + 1
@@ -3420,9 +3439,9 @@ TryPushingBoulder: ; f225 (3:7225)
ld a, [hJoyHeld]
and $f0
ret z
- predef Func_c60b
- ld a, [wd71c]
- and a
+ predef CheckForCollisionWhenPushingBoulder
+ ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult]
+ and a ; was there a collision?
jp nz, ResetBoulderPushFlags
ld a, [hJoyHeld]
ld b, a
@@ -3481,8 +3500,8 @@ DoBoulderDustAnimation: ; f2b5 (3:72b5)
ld [wJoyIgnore], a
call ResetBoulderPushFlags
set 7, [hl]
- ld a, [wd718]
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld a, [wBoulderSpriteIndex]
+ ld [H_SPRITEINDEX], a
call GetSpriteMovementByte2Pointer
ld [hl], $10
ld a, (SFX_02_56 - SFX_Headers_02) / 3
diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm
index b30a8602..14882d1a 100755
--- a/scripts/billshouse.asm
+++ b/scripts/billshouse.asm
@@ -57,7 +57,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5)
ld a, $f0
ld [wJoyIgnore], a
ld a, $2
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld a, $c
ld [$ffeb], a
ld a, $40
diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm
index 9746f54e..87239910 100755
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -236,7 +236,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a)
ld hl, wd77e
set 2, [hl]
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, Received10CoinsText
jr .asm_c7d1a ; 0x48d87
.asm_d0957 ; 0x48d89
@@ -411,7 +411,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d)
ld de, CeladonGameCornerText_48ed3
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
@@ -437,7 +437,7 @@ CeladonGameCornerText13: ; 48ed8 (12:4ed8)
CeladonGameCornerText12: ; 48edd (12:4edd)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CeladonGameCornerText_48f09
call PrintText
call WaitForSoundToFinish
diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm
index 6d44175e..092bff88 100755
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -179,7 +179,7 @@ CeladonGymText1: ; 48a11 (12:4a11)
ld de, CeladonGymText_48a63
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $4
diff --git a/scripts/celadonmansion3.asm b/scripts/celadonmansion3.asm
index 73cd45ed..47190c92 100755
--- a/scripts/celadonmansion3.asm
+++ b/scripts/celadonmansion3.asm
@@ -51,7 +51,7 @@ DirectorText: ; 487b2 (12:47b2)
db $8 ; asm
callab DisplayDiploma
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
jp TextScriptEnd
GameFreakPCText1: ; 487eb (12:47eb)
diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm
index 1e32647d..ff835765 100755
--- a/scripts/celadonmartelevator.asm
+++ b/scripts/celadonmartelevator.asm
@@ -9,13 +9,13 @@ CeladonMartElevatorScript: ; 48600 (12:4600)
res 7, [hl]
call nz, CeladonMartElevatorScript_48654
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
CeladonMartElevatorScript_4861c: ; 4861c (12:461c)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm
index 37025525..fa34b8cd 100755
--- a/scripts/celadonmartroof.asm
+++ b/scripts/celadonmartroof.asm
@@ -230,7 +230,7 @@ CeladonMartRoofText2: ; 4856c (12:456c)
and a
jr z, .asm_914b9 ; 0x48574
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CeladonMartRoofText4
call PrintText
call YesNoChoice
diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm
index 90ccab67..d97f9723 100755
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -64,7 +64,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8)
ld hl, CeruleanCityCoords2
call ArePlayerCoordsInArray
ret nc
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_19512 ; 0x19508 $8
ld a, $ff
@@ -279,7 +279,7 @@ CeruleanCityText2: ; 1967c (6:567c)
ld de, CeruleanCityText_196ee
call PreBattleSaveRegisters
ld a, [$ff8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $4
@@ -296,7 +296,7 @@ CeruleanCityText2: ; 1967c (6:567c)
jr .Done
.Success
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, ReceivedTM28Text
call PrintText
callba Func_74872
diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm
index 57c9ea4a..e65ef2c5 100755
--- a/scripts/ceruleancity2.asm
+++ b/scripts/ceruleancity2.asm
@@ -2,7 +2,7 @@ Func_74872: ; 74872 (1d:4872)
; code similar to this appears in a lot of banks; this particular
; one is called after you beat the Rocket that gives you TM28 DIG.
; the screen then fades out, he disappears, and fades back in
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $07
ld [wcc4d], a
predef ShowObject
@@ -12,5 +12,5 @@ Func_74872: ; 74872 (1d:4872)
ld a, $06
ld [wcc4d], a
predef HideObject
- call GBFadeOut1
+ call GBFadeInFromBlack
ret
diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm
index 19296fe2..ae6a40a0 100755
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -128,7 +128,7 @@ CeruleanGymText1: ; 5c771 (17:4771)
ld de, CeruleanGymText_5c7d8
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $2
diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm
index 7cc1aa74..3fa72183 100755
--- a/scripts/ceruleanhouse2.asm
+++ b/scripts/ceruleanhouse2.asm
@@ -1,8 +1,8 @@
CeruleanHouse2Script: ; 74e09 (1d:4e09)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
dec a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
CeruleanHouse2TextPointers: ; 74e13 (1d:4e13)
diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm
index 8ce02e81..65fd1db9 100755
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -187,13 +187,13 @@ CinnabarGymTextPointers: ; 7589f (1d:589f)
CinnabarGymScript_758b7: ; 758b7 (1d:58b7)
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld hl, wd72d
set 6, [hl]
set 7, [hl]
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $1
jr z, .asm_758d4
ld a, $2
diff --git a/scripts/copycatshouse2f.asm b/scripts/copycatshouse2f.asm
index ea1e91b3..b7a1255c 100755
--- a/scripts/copycatshouse2f.asm
+++ b/scripts/copycatshouse2f.asm
@@ -16,7 +16,7 @@ CopycatsHouse2FText1: ; 5cc82 (17:4c82)
bit 0, a
jr nz, .asm_7ccf3 ; 0x5cc88
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, CopycatsHouse2FText_5ccd4
call PrintText
ld b, POKE_DOLL
diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm
index 55a9f111..f2bf3188 100755
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -24,7 +24,7 @@ DayCareMText1: ; 56254 (15:6254)
ld hl, DayCareMText_56414
call PrintText
xor a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wd07d], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm
index 0fbff74a..fb8d7b19 100755
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -149,7 +149,7 @@ FightingDojoText1: ; 5ce44 (17:4e44)
ld de, FightingDojoText_5ce93
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm
index 09a767eb..14ffdfa9 100755
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -168,7 +168,7 @@ FuchsiaGymText1: ; 75534 (1d:5534)
ld de, UnnamedText_75586
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $5
diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm
index ee1b42b4..7621897f 100755
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -106,7 +106,7 @@ Mansion1Text4: ; 4435a (11:435a)
and a
jr nz, .asm_4438c ; 0x44368 $22
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd126
set 5, [hl]
ld hl, MansionSwitchPressedText
diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm
index 30261637..1b7a28a3 100755
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -112,7 +112,7 @@ Mansion2Text5: ; 52087 (14:6087)
and a
jr nz, .asm_520b9 ; 0x52095 $22
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, wd126
set 5, [hl]
ld hl, Mansion2Text_520c7
diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm
index 4e9c2271..494fba13 100755
--- a/scripts/mansion3.asm
+++ b/scripts/mansion3.asm
@@ -40,7 +40,7 @@ Mansion3ScriptPointers: ; 52235 (14:6235)
Mansion3Script0: ; 5223b (14:623b)
ld hl, CoordsData_52254
call Mansion3Script_5225b
- ld a, [wd71e]
+ ld a, [wWhichDungeonWarp]
and a
jp z, CheckFightingMapTrainers
cp $3
@@ -48,7 +48,7 @@ Mansion3Script0: ; 5223b (14:623b)
jr nz, .asm_52250
ld a, $d6
.asm_52250
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ret
CoordsData_52254: ; 52254 (14:6254)
@@ -59,14 +59,14 @@ CoordsData_52254: ; 52254 (14:6254)
Mansion3Script_5225b: ; 5225b (14:625b)
xor a
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld a, [wd72d]
bit 4, a
ret nz
call ArePlayerCoordsInArray
ret nc
ld a, [wWhichTrade] ; wWhichTrade
- ld [wd71e], a
+ ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
ld hl, wd732
diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm
index 8d6aaeed..71638409 100755
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -138,7 +138,7 @@ MtMoon3Script5: ; 49dfb (12:5dfb)
ld a, $f0
ld [wJoyIgnore], a
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, $a
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
@@ -230,7 +230,7 @@ MtMoon3Text1: ; 49e79 (12:5e79)
ld de, MtMoon3Text_49f8a
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
@@ -270,7 +270,7 @@ MtMoon3Text5: ; 49edf (12:5edf)
MtMoon3Text6: ; 49ee9 (12:5ee9)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, MtMoon3Text_49f24
call PrintText
call YesNoChoice
@@ -299,7 +299,7 @@ MtMoon3Text_49f24: ; 49f24 (12:5f24)
MtMoon3Text7: ; 49f29 (12:5f29)
db $08 ; asm
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, MtMoon3Text_49f64
call PrintText
call YesNoChoice
diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm
index 10dc9f42..a701e1a4 100755
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -1,8 +1,8 @@
Museum1FScript: ; 5c0f7 (17:40f7)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, Museum1FScriptPointers
ld a, [W_MUSEUM1FCURSCRIPT]
jp CallFunctionInTable
diff --git a/scripts/namerater.asm b/scripts/namerater.asm
index 2295944f..c9e3bfb4 100755
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -50,7 +50,7 @@ NameRaterText1: ; 1da56 (7:5a56)
call PrintText
xor a
ld [wd07d], a
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
push af
diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm
index faf86f1a..8666d18e 100755
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -3,9 +3,9 @@ OaksLabScript: ; 1cb0e (7:4b0e)
bit 6, a
call nz, OaksLabScript_1d076
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, OaksLabScriptPointers
ld a, [W_OAKSLABCURSCRIPT]
jp CallFunctionInTable
@@ -374,7 +374,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
.done
ld [W_TRAINERNO], a
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition1
ld hl, OaksLabText_1d3be
ld de, OaksLabText_1d3c3
@@ -397,7 +397,7 @@ OaksLabScript12: ; 1ce03 (7:4e03)
ld [wd528], a
call UpdateSprites
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $1
ld [H_SPRITEINDEX], a
@@ -680,7 +680,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b)
ld a, b
ld [$ffed], a
ld a, $1
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ret
@@ -801,7 +801,7 @@ OaksLabScript_1d133: ; 1d133 (7:5133)
ld [wcf91], a
ld [wd11e], a
ld a, b
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld a, [wd74b]
bit 2, a
jp nz, OaksLabScript_1d22d
@@ -837,7 +837,7 @@ OaksLabScript_1d157: ; 1d157 (7:5157)
call ReloadMapData
ld c, $a
call DelayFrames
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $2
jr z, OaksLabLookAtCharmander
cp $3
@@ -868,7 +868,7 @@ OaksLabBulbasaurText: ; 1d1ae (7:51ae)
OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3)
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
call YesNoChoice ; yes/no menu
ld a, [wCurrentMenuItem]
and a
@@ -877,7 +877,7 @@ OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3)
ld [W_PLAYERSTARTER], a
ld [wd11e], a
call GetMonName
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
cp $2
jr nz, asm_1d1db ; 0x1d1d5 $4
ld a, $2b
@@ -893,7 +893,7 @@ asm_1d1e5: ; 1d1e5 (7:51e5)
ld [wcc4d], a
predef HideObject
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, OaksLabMonEnergeticText
call PrintText
ld hl, OaksLabReceivedMonText
@@ -956,7 +956,7 @@ OaksLabText5: ; 1d248 (7:5248)
ld hl, OaksLabText_1d31d
call PrintText
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
predef DisplayDexRating
jp .asm_0f042
.asm_b28b0 ; 0x1d279
diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm
index 59660a90..e7bd2f57 100755
--- a/scripts/pallettown.asm
+++ b/scripts/pallettown.asm
@@ -109,7 +109,7 @@ PalletTownScript3: ; 18f12 (6:4f12)
ld a,$FF
ld [wJoyIgnore],a
ld a,1
- ld [wcf13],a
+ ld [wSpriteIndex],a
xor a
ld [wNPCMovementScriptFunctionNum],a
ld a,1
@@ -171,7 +171,7 @@ PalletTownText1: ; 18f96 (6:4f96)
and a
jr nz,.next
ld a,1
- ld [wcc3c],a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText],a
ld hl,OakAppearsText
jr .done
.next
diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm
index 2b8dfc3f..ba32454a 100755
--- a/scripts/pewtercity.asm
+++ b/scripts/pewtercity.asm
@@ -68,7 +68,7 @@ PewterCityScript1: ; 19280 (6:5280)
ld a, $11
ld [$ffee], a
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $3
ld [$ff8c], a
@@ -94,7 +94,7 @@ PewterCityScript2: ; 192d3 (6:52d3)
PewterCityScript3: ; 192e9 (6:52e9)
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition2
ld a, $3
ld [wcc4d], a
@@ -132,7 +132,7 @@ PewterCityScript4: ; 19305 (6:5305)
ld a, $10
ld [$ffee], a
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition1
ld a, $5
ld [$ff8c], a
@@ -158,7 +158,7 @@ PewterCityScript5: ; 19359 (6:5359)
PewterCityScript6: ; 1936f (6:536f)
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call SetSpritePosition2
ld a, $4
ld [wcc4d], a
@@ -216,7 +216,7 @@ PewterCityText3: ; 193b1 (6:53b1)
ldh a, [$b8]
ld [wNPCMovementScriptBank], a
ld a, $3
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition2
ld a, $1
ld [W_PEWTERCITYCURSCRIPT], a
@@ -280,7 +280,7 @@ PewterCityText5: ; 19436 (6:5436)
ldh a, [$b8]
ld [wNPCMovementScriptBank], a
ld a, $5
- ld [wcf13], a
+ ld [wSpriteIndex], a
call GetSpritePosition2
ld a, $4
ld [W_PEWTERCITYCURSCRIPT], a
diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm
index 2feb9817..0ab4c3a4 100755
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -128,7 +128,7 @@ PewterGymText1: ; 5c44e (17:444e)
ld de, PewterGymText_5c4bc
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $1
diff --git a/scripts/pewtermart.asm b/scripts/pewtermart.asm
index 4e867aee..8fe99d94 100755
--- a/scripts/pewtermart.asm
+++ b/scripts/pewtermart.asm
@@ -1,7 +1,7 @@
PewterMartScript: ; 74cad (1d:4cad)
call EnableAutoTextBoxDrawing
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
ret
PewterMartTextPointers: ; 74cb6 (1d:4cb6)
diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm
index 1871ad5f..2f4fd7af 100755
--- a/scripts/pewterpokecenter.asm
+++ b/scripts/pewterpokecenter.asm
@@ -18,7 +18,7 @@ PewterPokecenterText2: ; 5c596 (17:4596)
PewterPokecenterText3: ; 5c59b (17:459b)
db $8
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, PewterPokecenterText5
call PrintText
ld a, $ff
diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm
index 317690a2..6dd694ac 100755
--- a/scripts/pokemontower5.asm
+++ b/scripts/pokemontower5.asm
@@ -33,10 +33,10 @@ PokemonTower5Script0: ; 6094b (18:494b)
ld hl, wd72e
set 4, [hl]
predef HealParty
- call GBFadeOut2
+ call GBFadeOutToWhite
call Delay3
call Delay3
- call GBFadeIn2
+ call GBFadeInFromWhite
ld a, $7
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm
index 431855cb..6ebf15d5 100755
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -30,7 +30,7 @@ PokemonTower7Script2: ; 60d23 (18:4d23)
call EndTrainerBattle
ld a, $f0
ld [wJoyIgnore], a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
call PokemonTower7Script_60db6
@@ -44,7 +44,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56)
bit 0, a
ret nz
ld hl, W_MISSABLEOBJECTLIST
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld b, a
.missableObjectsListLoop
ld a, [hli]
@@ -55,7 +55,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56)
predef HideObject
xor a
ld [wJoyIgnore], a
- ld [wcf13], a
+ ld [wSpriteIndex], a
ld [wTrainerHeaderFlagBit], a
ld [wda38], a
ld a, $0
@@ -74,7 +74,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86)
ld a, $95
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
ld a, $1
- ld [wd42f], a
+ ld [wDestinationWarpID], a
ld a, LAVENDER_TOWN
ld [wLastMap], a
ld hl, wd72d
@@ -86,7 +86,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86)
PokemonTower7Script_60db6: ; 60db6 (18:4db6)
ld hl, CoordsData_60de3 ; $4de3
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
dec a
swap a
ld d, $0
@@ -106,7 +106,7 @@ PokemonTower7Script_60db6: ; 60db6 (18:4db6)
ld a, [hli]
ld d, [hl]
ld e, a
- ld a, [wcf13]
+ ld a, [wSpriteIndex]
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
jp MoveSprite
.asm_60dde
diff --git a/scripts/redshouse1f.asm b/scripts/redshouse1f.asm
index 0e3e331b..7b3f1f87 100755
--- a/scripts/redshouse1f.asm
+++ b/scripts/redshouse1f.asm
@@ -25,7 +25,7 @@ MomWakeUpText: ; 48185 (12:4185)
MomHealPokemon: ; 4818a (12:418a)
ld hl, MomHealText1
call PrintText
- call GBFadeOut2
+ call GBFadeOutToWhite
call ReloadMapData
predef HealParty
ld a, MUSIC_PKMN_HEALED
@@ -38,7 +38,7 @@ MomHealPokemon: ; 4818a (12:418a)
ld a, [wd35b]
ld [wc0ee], a
call PlaySound
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, MomHealText2
jp PrintText
diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm
index 5c99f3a1..ddac941a 100755
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -58,7 +58,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6)
ld a, $a
ld [H_SPRITEHEIGHT], a
call DisplayTextID
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $83
ld [wcc4d], a
predef HideObject
@@ -66,7 +66,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6)
ld [wcc4d], a
predef ShowObject
call UpdateSprites
- call GBFadeOut1
+ call GBFadeInFromBlack
xor a
ld [wJoyIgnore], a
ld hl, wd126
@@ -132,7 +132,7 @@ RocketHideout4Text1: ; 4553a (11:553a)
ld de, RocketHideout4Text_4557f
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm
index 73313dd7..e7bc24f3 100755
--- a/scripts/rockethideoutelevator.asm
+++ b/scripts/rockethideoutelevator.asm
@@ -9,13 +9,13 @@ RocketHideoutElevatorScript: ; 45710 (11:5710)
res 7, [hl]
call nz, RocketHideoutElevatorScript_4575f
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
RocketHideoutElevatorScript_4572c: ; 4572c (11:572c)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
diff --git a/scripts/route12gateupstairs.asm b/scripts/route12gateupstairs.asm
index 94a4f9a2..c4c05cd6 100755
--- a/scripts/route12gateupstairs.asm
+++ b/scripts/route12gateupstairs.asm
@@ -75,5 +75,5 @@ Route12GateUpstairsScript_495c9: ; 495c9 (12:55c9)
call PrintText
xor a
.asm_495d8
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
jp TextScriptEnd
diff --git a/scripts/route22.asm b/scripts/route22.asm
index cd47d1dc..667edd65 100755
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -83,7 +83,7 @@ Route22Script0: ; 50f00 (14:4f00)
xor a
ld [wcd50], a
predef EmotionBubble
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .asm_50f4e ; 0x50f44 $8
ld a, $ff
@@ -222,7 +222,7 @@ Route22Script_5104e: ; 5104e (14:504e)
xor a
ld [wcd50], a
predef EmotionBubble
- ld a, [wd700]
+ ld a, [wWalkBikeSurfState]
and a
jr z, .skipYVisibilityTesta
ld a, $ff
diff --git a/scripts/route24.asm b/scripts/route24.asm
index 89ddeded..ea48053b 100755
--- a/scripts/route24.asm
+++ b/scripts/route24.asm
@@ -171,7 +171,7 @@ Route24Text1: ; 514a4 (14:54a4)
ld de, Route24Text_5152b
call PreBattleSaveRegisters
ld a, [$ff8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm
index 336d40e9..39f4df10 100755
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -180,7 +180,7 @@ SaffronGymText1: ; 5d118 (17:5118)
ld de, SaffronGymText_5d167
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $6
diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm
index 55bbd43e..1fe0852b 100755
--- a/scripts/seafoamislands1.asm
+++ b/scripts/seafoamislands1.asm
@@ -34,7 +34,7 @@ SeafoamIslands1Script: ; 447e9 (11:47e9)
predef_jump ShowObject
.asm_4483b
ld a, $9f
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam1HolesCoords
jp Func_46981
diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm
index b14c16d8..e392620a 100755
--- a/scripts/seafoamislands2.asm
+++ b/scripts/seafoamislands2.asm
@@ -32,7 +32,7 @@ SeafoamIslands2Script: ; 46315 (11:6315)
predef_jump ShowObject
.asm_46362
ld a, $a0
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam2HolesCoords
jp Func_46981
diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm
index aa7b3615..ba34a2c3 100755
--- a/scripts/seafoamislands3.asm
+++ b/scripts/seafoamislands3.asm
@@ -32,7 +32,7 @@ SeafoamIslands3Script: ; 46451 (11:6451)
predef_jump ShowObject
.asm_4649e
ld a, $a1
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam3HolesCoords
jp Func_46981
diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm
index 909a8d9a..a56382dd 100755
--- a/scripts/seafoamislands4.asm
+++ b/scripts/seafoamislands4.asm
@@ -33,7 +33,7 @@ SeafoamIslands4Script: ; 4658d (11:658d)
jr .asm_465ed ; 0x465da $11
.asm_465dc
ld a, $a2
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam4HolesCoords
call Func_46981
ld a, [wd732]
diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm
index c4936ac1..b554034b 100755
--- a/scripts/seafoamislands5.asm
+++ b/scripts/seafoamislands5.asm
@@ -130,8 +130,8 @@ SeafoamIslands5Script3: ; 46860 (11:6860)
SeaFoamIslands5Script_46872: ; 46872 (11:6872)
xor a
- ld [wd700], a
- ld [wd11a], a
+ ld [wWalkBikeSurfState], a
+ ld [wWalkBikeSurfStateCopy], a
jp ForceBikeOrSurf
SeafoamIslands5TextPointers: ; 4687c (11:687c)
diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm
index dfdfbe1d..32a455ec 100755
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -182,11 +182,11 @@ SilphCo11Script5: ; 62227 (18:6227)
ld a, $6
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
call DisplayTextID
- call GBFadeIn1
+ call GBFadeOutToBlack
call SilphCo11Script_6216d
call UpdateSprites
call Delay3
- call GBFadeOut1
+ call GBFadeInFromBlack
ld hl, wd838
set 7, [hl]
xor a
@@ -223,7 +223,7 @@ SilphCo11Script4: ; 62293 (18:6293)
ld de, SilphCo10Text_62330 ; $6330
call PreBattleSaveRegisters
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
xor a
diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm
index c4f7a895..44059b56 100755
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -164,9 +164,9 @@ SilphCo9Text1: ; 5d8b8 (17:58b8)
ld hl, SilphCo9Text_5d8e5
call PrintText
predef HealParty
- call GBFadeOut2
+ call GBFadeOutToWhite
call Delay3
- call GBFadeIn2
+ call GBFadeInFromWhite
ld hl, SilphCo9Text_5d8ea
call PrintText
jr .asm_b6e28 ; 0x5d8da
diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm
index 853d7357..48d406cc 100755
--- a/scripts/silphcoelevator.asm
+++ b/scripts/silphcoelevator.asm
@@ -9,13 +9,13 @@ SilphCoElevatorScript: ; 457c0 (11:57c0)
res 7, [hl]
call nz, SilphCoElevatorScript_45827
xor a
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
inc a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ret
SilphCoElevatorScript_457dc: ; 457dc (11:57dc)
- ld hl, wd3af
+ ld hl, wWarpEntries
ld a, [wd73b]
ld b, a
ld a, [wd73c]
diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm
index 2ec0f28c..f25d5532 100755
--- a/scripts/ssanne9.asm
+++ b/scripts/ssanne9.asm
@@ -1,8 +1,8 @@
SSAnne9Script: ; 61b4b (18:5b4b)
ld a, $1
- ld [wcf0c], a
+ ld [wAutoTextBoxDrawingControl], a
xor a
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, SSAnne9TrainerHeaders
ld de, SSAnne9ScriptPointers
ld a, [W_SSANNE9CURSCRIPT]
diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm
index ca0ce66b..6ed2d23d 100755
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -5,7 +5,7 @@ VermilionDockScript: ; 1db52 (7:5b52)
jr nz, .asm_1db8d ; 0x1db5a $31
bit 0, [hl]
ret z
- ld a, [wd42f]
+ ld a, [wDestinationWarpID]
cp $1
ret nz
bit 2, [hl]
@@ -75,7 +75,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b)
ld a, (SFX_02_54 - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
ld a, $ff
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
ld d, $0
ld e, $8
.asm_1dbfa
@@ -111,14 +111,14 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b)
ld a, $90
ld [hVBlankWY], a
ld a, $1
- ld [wcfcb], a
+ ld [wUpdateSpritesEnabled], a
pop hl
pop bc
ld [hl], b
dec hl
ld [hl], c
call LoadPlayerSpriteGraphics
- ld hl, wd3ae
+ ld hl, wNumberOfWarps
dec [hl]
ret
diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm
index fa6b2fc2..685bd2cb 100755
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -158,7 +158,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d)
ld de, ReceivedThunderbadgeText
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $3
diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm
index e35e9131..e7d5ed12 100755
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -61,7 +61,7 @@ VictoryRoad3Script0: ; 449b7 (11:49b7)
.asm_449fe
ld a, $c2
- ld [wd71d], a
+ ld [wDungeonWarpDestinationMap], a
ld hl, .coordsData_449f9 ; $49f9
call Func_46981
ld a, [wWhichTrade] ; wWhichTrade
diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm
index 4c9e6821..6b0673d1 100755
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -286,16 +286,16 @@ ViridianGymText1: ; 74a69 (1d:4a69)
jr .asm_6dff7 ; 0x74a7b
.asm_9fc95 ; 0x74a7d
ld a, $1
- ld [wcc3c], a
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl, ViridianGymText_74ad9
call PrintText
- call GBFadeIn1
+ call GBFadeOutToBlack
ld a, $32
ld [wcc4d], a
predef HideObject
call UpdateSprites
call Delay3
- call GBFadeOut1
+ call GBFadeInFromBlack
jr .asm_6dff7 ; 0x74a9e
.asm_6de66 ; 0x74aa0
ld hl, ViridianGymText_74ace
@@ -307,7 +307,7 @@ ViridianGymText1: ; 74a69 (1d:4a69)
ld de, ViridianGymText_74ad3
call PreBattleSaveRegisters
ldh a, [$8c]
- ld [wcf13], a
+ ld [wSpriteIndex], a
call EngageMapTrainer
call InitBattleEnemyParameters
ld a, $8
diff --git a/wram.asm b/wram.asm
index b98372f0..a9bad081 100755
--- a/wram.asm
+++ b/wram.asm
@@ -260,7 +260,11 @@ wcc37:: ds 1
wcc38:: ds 2
wcc3a:: ds 1
wcc3b:: ds 1
-wcc3c:: ds 1
+
+wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c
+; if non-zero, skip waiting for a button press after displaying text in DisplayTextID
+ ds 1
+
wcc3d:: ds 1
wcc3e:: ds 4
wcc42:: ds 1
@@ -496,17 +500,40 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
ds 1
+wFlyAnimUsingCoordList:: ; cd3d
+
+wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d
+
+wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d
+
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
; ds 1
wTrainerSpriteOffset:: ; cd3d
ds 1
+
+wFlyAnimCounter:: ; cd3e
+
+wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e
+
+wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e
+
wTrainerEngageDistance:: ; cd3e
ds 1
+
+wFlyAnimBirdSpriteImageIndex:: ; cd3f
+
+wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f
+
+wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f
+
wTrainerFacingDirection:: ; cd3f
wcd3f::
ds 1
+
+wPlayerSpinInPlaceAnimSoundID:: ; cd40
+
wTrainerScreenY:: ; cd40
ds 1
wTrainerScreenX:: ; cd41
@@ -593,7 +620,11 @@ wBattleResult:: ; cf0b
; $01 - lose
; $02 - draw
ds 1
-wcf0c:: ds 1
+
+wAutoTextBoxDrawingControl:: ; cf0c
+; bit 0: if set, DisplayTextID automatically draws a text box
+ ds 1
+
wcf0d:: ds 1
wcf0e:: ds 1
wcf0f:: ds 1
@@ -608,7 +639,7 @@ wcf11:: ds 1
wPredefParentBank:: ; cf12
ds 1
-wcf13:: ds 1
+wSpriteIndex:: ds 1
wCurSpriteMovement2:: ; cf14
; movement byte 2 of current sprite
@@ -625,7 +656,10 @@ wcf18:: ds 2
wGBC:: ; cf1a
ds 1
-wcf1b:: ds 1
+wOnSGB:: ; cf1b
+; if running on SGB, it's 1, else it's 0
+ ds 1
+
wcf1c:: ds 1
wcf1d:: ds 1
wcf1e:: ds 1
@@ -692,7 +726,9 @@ wWalkCounter:: ; cfc5
; walk animation counter
ds 1
-wcfc6:: ds 1
+wTileInFrontOfPlayer:: ; cfc6
+; background tile number in front of the player (either 1 or 2 steps ahead)
+ ds 1
wMusicHeaderPointer:: ; cfc7
; (the current music channel address - $4000) / 3
@@ -701,7 +737,10 @@ wMusicHeaderPointer:: ; cfc7
wcfc8:: ds 1
wcfc9:: ds 1
wcfca:: ds 1
-wcfcb:: ds 1
+
+wUpdateSpritesEnabled:: ; cfcb
+; $01 enables UpdateSprites; anything else disables it
+ ds 1
W_ENEMYMOVENUM:: ; cfcc
ds 1
@@ -1121,7 +1160,11 @@ wd0dc:: ds 4
wd0e0:: ds 1
wd0e1:: ds 56
wd119:: ds 1
-wd11a:: ds 1
+
+wWalkBikeSurfStateCopy:: ; d11a
+; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything
+ ds 1
+
wd11b:: ds 1
wd11c:: ds 1
wd11d:: ds 1
@@ -1158,8 +1201,14 @@ wd132:: ds 1
wd133:: ds 6
wd139:: ds 1
wd13a:: ds 1
-wd13b:: ds 1
-wd13c:: ds 1
+
+wStepCounter:: ; d13b
+; counts down once every step
+ ds 1
+
+wNumberOfNoRandomBattleStepsLeft:: ; d13c
+; after a battle, you have at least 3 steps before a random battle can occur
+ ds 1
W_PRIZE1:: ; d13d
ds 1
@@ -1246,13 +1295,18 @@ wPlayerID:: ; d359
wd35b:: ds 1
wd35c:: ds 1
-wd35d:: ds 1
+
+wMapPalOffset:: ; d35d
+; offset subtracted from FadePal4 to get the background and object palettes for the current map
+; normally, it is 0. it is 6 when Flash is needed, causing FadePal2 to be used instead of FadePal4
+ ds 1
W_CURMAP:: ; d35e
ds 1
-wd35f:: ds 1
-wd360:: ds 1
+wCurrentTileBlockMapViewPointer:: ; d35f
+; pointer to the upper left corner of the current view in the tile block map
+ ds 2
W_YCOORD:: ; d361
; player’s position on the current map
@@ -1364,26 +1418,42 @@ W_SPRITESETID:: ; d3a8
wd3a9:: ds 1
wd3aa:: ds 3
wd3ad:: ds 1
-wd3ae:: ds 1
-wd3af:: ds 128
-wd42f:: ds 129
+
+wNumberOfWarps:: ; d3ae
+; number of warps in current map
+ ds 1
+
+wWarpEntries:: ; d3af
+; current map warp entries
+ ds 128
+
+wDestinationWarpID:: ; d42f
+; if $ff, the player's coordinates are not updated when entering the map
+ ds 1
+
+ ds 128
+
wd4b0:: ds 1
wd4b1:: ds 32
wd4d1:: ds 16
W_NUMSPRITES:: ; d4e1
; number of sprites on the current map
-; two bytes per sprite (movement byte 2 , text ID)
ds 1
-wd4e2:: ds 1
-wd4e3:: ds 1
+; these two variables track the X and Y offset in blocks from the last special warp used
+; they don't seem to be used for anything
+wYOffsetSinceLastSpecialWarp:: ; d4e2
+ ds 1
+wXOffsetSinceLastSpecialWarp:: ; d4e3
+ ds 1
W_MAPSPRITEDATA:: ; d4e4
-; two bytes per sprite (trainer class/item ID , trainer set ID)
+; two bytes per sprite (movement byte 2, text ID)
ds 32
W_MAPSPRITEEXTRADATA:: ; d504
+; two bytes per sprite (trainer class/item ID, trainer set ID)
ds 32
wd524:: ds 1
@@ -1661,7 +1731,14 @@ W_ROUTE18GATECURSCRIPT:: ; d669
wd6f0:: ds 14
wd6fe:: ds 2
-wd700:: ds 11
+
+wWalkBikeSurfState:: ; d700
+; $00 = walking
+; $01 = biking
+; $02 = surfing
+ ds 1
+
+ ds 10
W_TOWNVISITEDFLAG:: ; d70b
flag_array 13
@@ -1684,7 +1761,8 @@ W_ENEMYMONORTRAINERCLASS:: ; d713
; trainer classes start at $c8
ds 1
-wd714:: ds 1
+wPlayerJumpingYScreenCoordsIndex:: ; d714
+ ds 1
W_RIVALSTARTER:: ; d715
ds 1
@@ -1694,16 +1772,32 @@ W_RIVALSTARTER:: ; d715
W_PLAYERSTARTER:: ; d717
ds 1
-wd718:: ds 1
+wBoulderSpriteIndex:: ; d718
+; sprite index of the boulder the player is trying to push
+ ds 1
wLastBlackoutMap:: ; d719
ds 1
-wd71a:: ds 1
+wDestinationMap:: ; d71a
+; destination map (for certain types of special warps, not ordinary walking)
+ ds 1
+
wd71b:: ds 1
-wd71c:: ds 1
-wd71d:: ds 1
-wd71e:: ds 1
+
+wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c
+; used to store the tile in front of the boulder when trying to push a boulder
+; also used to store the result of the collision check ($ff for a collision and $00 for no collision)
+ ds 1
+
+wDungeonWarpDestinationMap:: ; d71d
+; destination map for dungeon warps
+ ds 1
+
+wWhichDungeonWarp:: ; d71e
+; which dungeon warp within the source map was used
+ ds 1
+
wd71f:: ds 9
wd728::
@@ -1713,7 +1807,11 @@ wd728::
ds 1
wd72a:: ds 2
-wd72c:: ds 1
+
+wd72c:: ; d72c
+; bit 0: if not set, the 3 minimum steps between random battles have passed
+ ds 1
+
wd72d:: ds 1
wd72e:: ds 2
@@ -1723,16 +1821,31 @@ wd730::
ds 1
-wd732:: ds 1
+wd732:: ; d732
+; bit 0: play time being counted
+; bit 1: remnant of debug mode? not set by the game code.
+; if it is set
+; 1. skips most of Prof. Oak's speech, and uses NINTEN as the player's name and SONY as the rival's name
+; 2. does not have the player start in floor two of the playyer's house (instead sending them to [wLastMap])
+; 3. allows wild battles to be avoided by holding down B
+; bit 2: the target warp is a fly warp (bit 3 set or blacked out) or a dungeon warp (bit 4 set)
+; bit 3: used warp pad, escape rope, dig, teleport, or fly, so the target warp is a "fly warp"
+; bit 4: jumped into hole (Pokemon Mansion, Seafoam Islands, Victory Road) or went down waterfall (Seafoam Islands), so the target warp is a "dungeon warp"
+; bit 5: currently being forced to ride bike (cycling road)
+; bit 6: map destination is [wLastBlackoutMap] (usually the last used pokemon center, but could be the player's house)
+ ds 1
W_FLAGS_D733:: ; d733
; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers)
+; bit 7: used fly out of battle
ds 1
wd734:: ds 2
wd736:: ; d736
; bit 0: check if the player is standing on a door and make him walk down a step if so
+; bit 2: standing on a warp
+; bit 6: jumping down a ledge
ds 1
wd737:: ds 4