summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2014-09-14 11:29:18 -0700
committerYamaArashi <shadow962@live.com>2014-09-14 11:29:18 -0700
commit2ed65d9c3e3ba60939ebe2928ffddc06a90b1876 (patch)
tree0efc4cb1b79494d119524b120d27c8c5b74a6a05
parent0c916aea3353ed1bf2750be403b0da9ea0b922d4 (diff)
Commented/labelled misc functions
-rw-r--r--constants/hardware_constants.asm20
-rwxr-xr-xengine/battle/14.asm2
-rwxr-xr-xengine/battle/core.asm8
-rwxr-xr-xengine/cable_club.asm2
-rwxr-xr-xengine/evolution.asm2
-rwxr-xr-xengine/evos_moves.asm4
-rwxr-xr-xengine/hall_of_fame.asm2
-rwxr-xr-xengine/hidden_object_functions18.asm2
-rwxr-xr-xengine/hidden_object_functions3.asm27
-rwxr-xr-xengine/hidden_object_functions7.asm6
-rwxr-xr-xengine/in_game_trades.asm2
-rw-r--r--engine/menu/bills_pc.asm2
-rwxr-xr-xengine/menu/league_pc.asm6
-rwxr-xr-xengine/menu/pokedex.asm6
-rwxr-xr-xengine/menu/start_sub_menus.asm6
-rwxr-xr-xengine/menu/status_screen.asm12
-rwxr-xr-xengine/oak_speech.asm2
-rwxr-xr-xengine/overworld/card_key.asm66
-rwxr-xr-xengine/overworld/cut.asm4
-rwxr-xr-xengine/overworld/elevator.asm2
-rwxr-xr-xengine/overworld/hidden_objects.asm110
-rwxr-xr-xengine/overworld/npc_movement.asm13
-rwxr-xr-xengine/play_time.asm26
-rwxr-xr-xengine/predefs.asm8
-rwxr-xr-xengine/save.asm192
-rwxr-xr-xengine/titlescreen.asm2
-rwxr-xr-xengine/town_map.asm41
-rwxr-xr-xengine/trade.asm2
-rw-r--r--home.asm217
-rw-r--r--home/init.asm4
-rw-r--r--home/overworld.asm112
-rw-r--r--home/vblank.asm8
-rw-r--r--home/vcopy.asm7
-rw-r--r--hram.asm9
-rw-r--r--macros.asm4
-rwxr-xr-xmain.asm94
-rwxr-xr-xscripts/agatha.asm4
-rwxr-xr-xscripts/bruno.asm4
-rwxr-xr-xscripts/celadongamecorner.asm6
-rwxr-xr-xscripts/celadongym.asm4
-rwxr-xr-xscripts/ceruleancity.asm4
-rwxr-xr-xscripts/ceruleangym.asm4
-rwxr-xr-xscripts/cinnabargym.asm16
-rwxr-xr-xscripts/fightingdojo.asm4
-rwxr-xr-xscripts/fuchsiagym.asm4
-rwxr-xr-xscripts/gary.asm2
-rwxr-xr-xscripts/lance.asm4
-rwxr-xr-xscripts/lorelei.asm4
-rwxr-xr-xscripts/mansion1.asm4
-rwxr-xr-xscripts/mansion2.asm4
-rwxr-xr-xscripts/mansion3.asm2
-rwxr-xr-xscripts/mansion4.asm2
-rwxr-xr-xscripts/mtmoon1.asm2
-rwxr-xr-xscripts/mtmoon3.asm4
-rwxr-xr-xscripts/oakslab.asm2
-rwxr-xr-xscripts/pewtergym.asm4
-rwxr-xr-xscripts/pokemontower2.asm2
-rwxr-xr-xscripts/pokemontower3.asm2
-rwxr-xr-xscripts/pokemontower4.asm2
-rwxr-xr-xscripts/pokemontower5.asm2
-rwxr-xr-xscripts/pokemontower6.asm2
-rwxr-xr-xscripts/pokemontower7.asm2
-rwxr-xr-xscripts/powerplant.asm2
-rwxr-xr-xscripts/rockethideout1.asm4
-rwxr-xr-xscripts/rockethideout2.asm4
-rwxr-xr-xscripts/rockethideout3.asm4
-rwxr-xr-xscripts/rockethideout4.asm6
-rwxr-xr-xscripts/rocktunnel1.asm2
-rwxr-xr-xscripts/rocktunnel2.asm2
-rwxr-xr-xscripts/route10.asm2
-rwxr-xr-xscripts/route11.asm2
-rwxr-xr-xscripts/route12.asm2
-rwxr-xr-xscripts/route13.asm2
-rwxr-xr-xscripts/route14.asm2
-rwxr-xr-xscripts/route15.asm2
-rwxr-xr-xscripts/route16.asm2
-rwxr-xr-xscripts/route17.asm2
-rwxr-xr-xscripts/route18.asm2
-rwxr-xr-xscripts/route19.asm2
-rwxr-xr-xscripts/route20.asm2
-rwxr-xr-xscripts/route21.asm2
-rwxr-xr-xscripts/route22.asm4
-rwxr-xr-xscripts/route24.asm4
-rwxr-xr-xscripts/route25.asm2
-rwxr-xr-xscripts/route3.asm2
-rwxr-xr-xscripts/route4.asm2
-rwxr-xr-xscripts/route6.asm2
-rwxr-xr-xscripts/route8.asm2
-rwxr-xr-xscripts/route9.asm2
-rwxr-xr-xscripts/saffrongym.asm4
-rwxr-xr-xscripts/silphco10.asm4
-rwxr-xr-xscripts/silphco11.asm10
-rwxr-xr-xscripts/silphco2.asm10
-rwxr-xr-xscripts/silphco3.asm6
-rwxr-xr-xscripts/silphco4.asm10
-rwxr-xr-xscripts/silphco5.asm8
-rwxr-xr-xscripts/silphco6.asm4
-rwxr-xr-xscripts/silphco7.asm14
-rwxr-xr-xscripts/silphco8.asm8
-rwxr-xr-xscripts/silphco9.asm14
-rwxr-xr-xscripts/ssanne10.asm2
-rwxr-xr-xscripts/ssanne2.asm2
-rwxr-xr-xscripts/ssanne5.asm2
-rwxr-xr-xscripts/ssanne8.asm2
-rwxr-xr-xscripts/ssanne9.asm2
-rwxr-xr-xscripts/unknowndungeon3.asm2
-rwxr-xr-xscripts/vermiliondock.asm6
-rwxr-xr-xscripts/vermiliongym.asm6
-rwxr-xr-xscripts/victoryroad1.asm4
-rwxr-xr-xscripts/victoryroad2.asm4
-rwxr-xr-xscripts/victoryroad3.asm4
-rwxr-xr-xscripts/viridianforest.asm2
-rwxr-xr-xscripts/viridiangym.asm6
-rwxr-xr-xwram.asm69
114 files changed, 733 insertions, 668 deletions
diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm
index 8e926a11..e875622d 100644
--- a/constants/hardware_constants.asm
+++ b/constants/hardware_constants.asm
@@ -2,27 +2,17 @@
GBC EQU $11
-; MBC3
-MBC3SRamEnable EQU $0000
-MBC3RomBank EQU $2000
-MBC3SRamBank EQU $4000
-MBC3LatchClock EQU $6000
-MBC3RTC EQU $a000
+; MBC1
+MBC1SRamEnable EQU $0000
+MBC1RomBank EQU $2000
+MBC1SRamBank EQU $4000
+MBC1SRamBankingMode EQU $6000
SRAM_DISABLE EQU $00
SRAM_ENABLE EQU $0a
NUM_SRAM_BANKS EQU 4
-RTC_S EQU $08 ; Seconds 0-59 (0-3Bh)
-RTC_M EQU $09 ; Minutes 0-59 (0-3Bh)
-RTC_H EQU $0a ; Hours 0-23 (0-17h)
-RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh)
-RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag
- ; Bit 0 Most significant bit of Day Counter (Bit 8)
- ; Bit 6 Halt (0=Active, 1=Stop Timer)
- ; Bit 7 Day Counter Carry Bit (1=Counter Overflow)
-
; interrupt flags
VBLANK EQU 0
LCD_STAT EQU 1
diff --git a/engine/battle/14.asm b/engine/battle/14.asm
index 530032a0..18aaa5e1 100755
--- a/engine/battle/14.asm
+++ b/engine/battle/14.asm
@@ -1,5 +1,5 @@
Func_525af: ; 525af (14:65af)
- ld a, [$ffd7]
+ ld a, [hTilesetType]
ld [wd0d4], a
xor a
ld [wcd6a], a
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 26465b8f..7b1c1d12 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -136,7 +136,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c)
ld [hVBlankWY], a
ld [rWY], a
xor a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [hVBlankSCY], a
dec a
ld [wUpdateSpritesEnabled], a
@@ -1015,7 +1015,7 @@ TrainerBattleVictory: ; 3c696 (f:4696)
call ScrollTrainerPicAfterBattle
ld c, $28
call DelayFrames
- call Func_3381
+ call PrintEndBattleText
ld hl, MoneyForWinningText
call PrintText
ld de, wPlayerMoney + 2
@@ -6263,7 +6263,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32)
ld [H_AUTOBGTRANSFERENABLED], a
ld [hVBlankWY], a
ld [rWY], a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld hl, wd060
ld [hli], a
ld [hli], a
@@ -6851,7 +6851,7 @@ InitBattle_Common: ; 3efeb (f:6feb)
pop af
ld [wMapPalOffset], a
ld a, [wd0d4]
- ld [$ffd7], a
+ ld [hTilesetType], a
scf
ret
.emptyString
diff --git a/engine/cable_club.asm b/engine/cable_club.asm
index 9b4017e2..34a9d0a1 100755
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -572,7 +572,7 @@ Func_577d: ; 577d (1:577d)
dec a
ld [wDestinationWarpID], a
call LoadMapData
- callba Func_c335
+ callba ClearVariablesAfterLoadingMapData
pop hl
pop af
ld [hl], a
diff --git a/engine/evolution.asm b/engine/evolution.asm
index 07ccdbda..106107d2 100755
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -19,7 +19,7 @@ Func_7bde9: ; 7bde9 (1e:7de9)
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld [$ffd7], a
+ ld [hTilesetType], a
ld a, [wHPBarMaxHP]
ld [wcf1d], a
ld c, $0
diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm
index 240fd9fa..bda4c9ff 100755
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -11,7 +11,7 @@ TryEvolvingMon: ; 3ad0e (e:6d0e)
; this is only called after battle
; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur
EvolutionAfterBattle: ; 3ad1c (e:6d1c)
- ld a, [$ffd7]
+ ld a, [hTilesetType]
push af
xor a
ld [wd121], a
@@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons
pop bc
pop hl
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
ld a, [W_ISLINKBATTLE]
cp $32
ret z
diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm
index 30ae6266..406fac01 100755
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -19,7 +19,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0)
call FillMemory
xor a
ld [wUpdateSpritesEnabled], a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wd358], a
ld [wTrainerScreenY], a
diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm
index 9dd7fac7..7696626f 100755
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -70,7 +70,7 @@ PrintBenchGuyText: ; 6245d (18:645d)
ld a, [hl]
jp PrintPredefTextID
-; format: db map id, 08, text id of PointerTable_3f22
+; format: db map id, 08, text id of PredefTextIDPointerTable
PokeCenterMapIDList: ; 6247e (18:647e)
db VIRIDIAN_POKECENTER,$08,$0F
db PEWTER_POKECENTER,$08,$10
diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm
index 09d9ebcc..d3d83f08 100755
--- a/engine/hidden_object_functions3.asm
+++ b/engine/hidden_object_functions3.asm
@@ -1,22 +1,23 @@
; prints text for bookshelves in buildings without sign events
PrintBookshelfText: ; fb50 (3:7b50)
- ld a, [wSpriteStateData1 + 9]
- cp $4
- jr nz, .asm_fb7f
- ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ cp SPRITE_FACING_UP
+ jr nz, .noMatch
+; facing up
+ ld a, [W_CURMAPTILESET]
ld b, a
aCoord 8, 7
ld c, a
- ld hl, BookshelfTileIDs ; $7b8b
-.asm_fb62
+ ld hl, BookshelfTileIDs
+.loop
ld a, [hli]
cp $ff
- jr z, .asm_fb7f
+ jr z, .noMatch
cp b
- jr nz, .asm_fb7b
+ jr nz, .nextBookshelfEntry1
ld a, [hli]
cp c
- jr nz, .asm_fb7c
+ jr nz, .nextBookshelfEntry2
ld a, [hl]
push af
call EnableAutoTextBoxDrawing
@@ -25,12 +26,12 @@ PrintBookshelfText: ; fb50 (3:7b50)
xor a
ld [$ffdb], a
ret
-.asm_fb7b
+.nextBookshelfEntry1
inc hl
-.asm_fb7c
+.nextBookshelfEntry2
inc hl
- jr .asm_fb62
-.asm_fb7f
+ jr .loop
+.noMatch
ld a, $ff
ld [$ffdb], a
ld b, BANK(PrintCardKeyText)
diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm
index c00749e4..012e941d 100755
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -60,7 +60,7 @@ SafariZoneCheckSteps: ; 1e997 (7:6997)
ld [wSafariSteps + 1], a ; wd70e
asm_1e9ab: ; 1e9ab (7:69ab)
xor a
- ld [wda46], a
+ ld [wSafariZoneGameOver], a
ret
asm_1e9b0: ; 1e9b0 (7:69b0)
call EnableAutoTextBoxDrawing
@@ -89,7 +89,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0)
ld hl, wd790
set 6, [hl]
ld a, $1
- ld [wda46], a
+ ld [wSafariZoneGameOver], a
ret
PrintSafariGameOverText: ; 1e9ed (7:69ed)
@@ -291,7 +291,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a)
.asm_1eb38
pop bc
ld [wd09f], a
- predef Func_ee9e
+ predef ReplaceTileBlock
ld hl, $ffdb
dec [hl]
jr nz, .asm_1eb0e
diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm
index 4f232eb4..7464edb3 100755
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -138,7 +138,7 @@ Func_71c07: ; 71c07 (1c:5c07)
callab EvolveTradeMon
call ClearScreen
call Func_71ca2
- callba Func_eedc
+ callba RedrawMapView
and a
ld a,$3
jr .asm_ee803 ; 0x71c9b $1
diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm
index b5ee9b94..65b70bb1 100644
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -332,7 +332,7 @@ Func_21673: ; 21673 (8:5673)
jp Func_214e8
Func_216b3: ; 216b3 (8:56b3)
- callba Func_738a1
+ callba ChangeBox
jp Func_214e8
Func_216be: ; 216be (8:56be)
diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm
index ffde236a..a6dd7021 100755
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -6,10 +6,10 @@ PKMNLeaguePC: ; 0x7657e
push hl
ld a, [wUpdateSpritesEnabled]
push af
- ld a, [$ffD7]
+ ld a, [hTilesetType]
push af
xor a
- ld [$ffD7], a
+ ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
@@ -38,7 +38,7 @@ PKMNLeaguePC: ; 0x7657e
jr nz, .first
.second
pop af
- ld [$ffD7], a
+ ld [hTilesetType], a
pop af
ld [wUpdateSpritesEnabled], a
pop hl
diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm
index 8f4bc508..152b8129 100755
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -404,10 +404,10 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
call GoPAL_SET
pop af
ld [wd11e],a
- ld a,[$ffd7]
+ ld a,[hTilesetType]
push af
xor a
- ld [$ffd7],a
+ ld [hTilesetType],a
hlCoord 0, 0
ld de,1
ld bc,$6414
@@ -554,7 +554,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
and a,%00000011 ; A button and B button
jr z,.waitForButtonPress
pop af
- ld [$ffd7],a
+ ld [hTilesetType],a
call GBPalWhiteOut
call ClearScreen
call GoPAL_SET_CF1C
diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm
index e91386b0..c6373e76 100755
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -500,10 +500,10 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
call GBPalWhiteOut
call ClearScreen
call UpdateSprites ; move sprites
- ld a,[$ffd7]
+ ld a,[hTilesetType]
push af
xor a
- ld [$ffd7],a
+ ld [hTilesetType],a
call DrawTrainerInfo
predef DrawBadges ; draw badges
ld b,$0d
@@ -517,7 +517,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460)
call ReloadMapData
call LoadGBPal
pop af
- ld [$ffd7],a
+ ld [hTilesetType],a
jp RedisplayStartMenu
; loads tile patterns and draws everything except for gym leader faces / badges
diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm
index 65b06e9d..f215fd0e 100755
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -36,10 +36,10 @@ StatusScreen: ; 12953 (4:6953)
ld hl, vChars2 + $720
ld bc,(BANK(PTile) << 8 | $01)
call CopyVideoDataDouble ; P (for PP), inline
- ld a, [$ffd7]
+ ld a, [hTilesetType]
push af
xor a
- ld [$ffd7], a
+ ld [hTilesetType], a
hlCoord 19, 1
ld bc, $060a
call DrawLineBox ; Draws the box around name, HP and status
@@ -109,7 +109,7 @@ StatusScreen: ; 12953 (4:6953)
call PlayCry ; play Pokémon cry
call WaitForTextScrollButtonPress ; wait for button
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
ret
.unk_12a7e ; 0x12a7e ; I don't know what this does, iterates over pointers?
ld a, [wcc49]
@@ -227,10 +227,10 @@ StatsText: ; 12b3a (4:6b3a)
next "SPECIAL@"
StatusScreen2: ; 12b57 (4:6b57)
- ld a, [$ffd7]
+ ld a, [hTilesetType]
push af
xor a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [$ffba], a
ld bc, $0005
ld hl, wd0dc
@@ -360,7 +360,7 @@ StatusScreen2: ; 12b57 (4:6b57)
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
ld hl, wd72c
res 1, [hl]
ld a, $77
diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm
index 518bea2a..0cbdaa3d 100755
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -52,7 +52,7 @@ OakSpeech: ; 6115 (1:6115)
ld [wDestinationMap],a
call SpecialWarpIn
xor a
- ld [$FFD7],a
+ ld [hTilesetType],a
ld a,[wd732]
bit 1,a ; XXX when is bit 1 set?
jp nz,Func_61bc ; easter egg: skip the intro
diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm
index 885932d5..c4df0d51 100755
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -2,18 +2,18 @@ PrintCardKeyText: ; 52673 (14:6673)
ld hl, SilphCoMapList
ld a, [W_CURMAP]
ld b, a
-.asm_5267a
+.silphCoMapListLoop
ld a, [hli]
cp $ff
ret z
cp b
- jr nz, .asm_5267a
+ jr nz, .silphCoMapListLoop
predef GetTileAndCoordsInFrontOfPlayer
ld a, [wTileInFrontOfPlayer]
cp $18
- jr z, .asm_5269c
+ jr z, .cardKeyDoorInFrontOfPlayer
cp $24
- jr z, .asm_5269c
+ jr z, .cardKeyDoorInFrontOfPlayer
ld b, a
ld a, [W_CURMAP]
cp SILPH_CO_11F
@@ -21,41 +21,41 @@ PrintCardKeyText: ; 52673 (14:6673)
ld a, b
cp $5e
ret nz
-.asm_5269c
+.cardKeyDoorInFrontOfPlayer
ld b, CARD_KEY
call IsItemInBag
- jr z, .asm_526dc
- call Func_526fd
+ jr z, .noCardKey
+ call GetCoordsInFrontOfPlayer
push de
ld a, $1
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [H_DOWNARROWBLINKCNT2], a
call PrintPredefTextID
pop de
srl d
ld a, d
ld b, a
- ld [wd73f], a
+ ld [wCardKeyDoorY], a
srl e
ld a, e
ld c, a
- ld [wd740], a
- ld a, [W_CURMAP] ; W_CURMAP
+ ld [wCardKeyDoorX], a
+ ld a, [W_CURMAP]
cp SILPH_CO_11F
- jr nz, .asm_526c8
+ jr nz, .notSilphCo11F
ld a, $3
- jr .asm_526ca
-.asm_526c8
+ jr .replaceCardKeyDoorTileBlock
+.notSilphCo11F
ld a, $e
-.asm_526ca
+.replaceCardKeyDoorTileBlock
ld [wd09f], a
- predef Func_ee9e
+ predef ReplaceTileBlock
ld hl, wd126
set 5, [hl]
ld a, (SFX_1f_57 - SFX_Headers_1f) / 3
jp PlaySound
-.asm_526dc
+.noCardKey
ld a, $2
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [H_DOWNARROWBLINKCNT2], a
jp PrintPredefTextID
SilphCoMapList: ; 526e3 (14:66e3)
@@ -81,26 +81,32 @@ CardKeyFailText: ; 526f8 (14:66f8)
TX_FAR _CardKeyFailText
db "@"
-Func_526fd: ; 526fd (14:66fd)
- ld a, [W_YCOORD] ; wd361
+; d = Y
+; e = X
+GetCoordsInFrontOfPlayer: ; 526fd (14:66fd)
+ 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_5270d
+ jr nz, .notFacingDown
+; facing down
inc d
ret
-.asm_5270d
- cp $4
- jr nz, .asm_52713
+.notFacingDown
+ cp SPRITE_FACING_UP
+ jr nz, .notFacingUp
+; facing up
dec d
ret
-.asm_52713
- cp $8
- jr nz, .asm_52719
+.notFacingUp
+ cp SPRITE_FACING_LEFT
+ jr nz, .notFacingLeft
+; facing left
dec e
ret
-.asm_52719
+.notFacingLeft
+; facing right
inc e
ret
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index 0cbc0214..f57b6465 100755
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -56,7 +56,7 @@ asm_ef82: ; ef82 (3:6f82)
call AnimateCutTree
ld de, CutTreeBlockSwaps ; $7100
call Func_f09f
- call Func_eedc
+ call RedrawMapView
callba Func_79e96
ld a, $1
ld [wUpdateSpritesEnabled], a
@@ -65,7 +65,7 @@ asm_ef82: ; ef82 (3:6f82)
ld a, $90
ld [hVBlankWY], a
call UpdateSprites
- jp Func_eedc
+ jp RedrawMapView
UsedCutText: ; eff2 (3:6ff2)
TX_FAR _UsedCutText
diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm
index d1d7d82a..c2191b91 100755
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -41,7 +41,7 @@ ShakeElevator: ; 7bf15 (1e:7f15)
jp PlayDefaultMusic
Func_7bf64: ; 7bf64 (1e:7f64)
- ld hl, wd527
+ ld hl, wMapViewVRAMPointer + 1
ld a, [hld]
push af
ld a, [hl]
diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm
index 1be5170c..ae67aeed 100755
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -6,7 +6,7 @@ Func_46981: ; 46981 (11:6981)
ret nz
call ArePlayerCoordsInArray
ret nc
- ld a, [wWhichTrade] ; wWhichTrade
+ ld a, [wWhichTrade]
ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
@@ -14,7 +14,8 @@ Func_46981: ; 46981 (11:6981)
set 4, [hl]
ret
-Func_469a0: ; 469a0 (11:69a0)
+; if a hidden object was found, stores $00 in [$ffee], else stores $ff
+CheckForHiddenObject: ; 469a0 (11:69a0)
ld hl, $ffeb
xor a
ld [hli], a
@@ -22,107 +23,110 @@ Func_469a0: ; 469a0 (11:69a0)
ld [hli], a
ld [hl], a
ld de, $0
- ld hl, HiddenObjectMaps ; $6a40
-.asm_469ae
+ ld hl, HiddenObjectMaps
+.hiddenMapLoop
ld a, [hli]
ld b, a
cp $ff
- jr z, .asm_469fc
- ld a, [W_CURMAP] ; W_CURMAP
+ jr z, .noMatch
+ ld a, [W_CURMAP]
cp b
- jr z, .asm_469be
+ jr z, .foundMatchingMap
inc de
inc de
- jr .asm_469ae
-.asm_469be
- ld hl, HiddenObjectPointers ; $6a96
+ jr .hiddenMapLoop
+.foundMatchingMap
+ ld hl, HiddenObjectPointers
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
push hl
- ld hl, wWhichTrade ; wWhichTrade
+ ld hl, wHiddenObjectFunctionArgument
xor a
ld [hli], a
ld [hli], a
ld [hl], a
pop hl
-.asm_469ce
+.hiddenObjectLoop
ld a, [hli]
cp $ff
- jr z, .asm_469fc
- ld [wTrainerScreenY], a
+ jr z, .noMatch
+ ld [wHiddenObjectY], a
ld b, a
ld a, [hli]
- ld [wTrainerScreenX], a
+ ld [wHiddenObjectX], a
ld c, a
- call Func_46a01
+ call CheckIfCoordsInFrontOfPlayerMatch
ld a, [$ffea]
and a
- jr z, .asm_469f0
+ jr z, .foundMatchingObject
inc hl
inc hl
inc hl
inc hl
push hl
- ld hl, wTrainerFacingDirection
+ ld hl, wHiddenObjectIndex
inc [hl]
pop hl
- jr .asm_469ce
-.asm_469f0
+ jr .hiddenObjectLoop
+.foundMatchingObject
ld a, [hli]
- ld [wWhichTrade], a ; wWhichTrade
+ ld [wHiddenObjectFunctionArgument], a
ld a, [hli]
- ld [wTrainerEngageDistance], a
+ ld [wHiddenObjectFunctionRomBank], a
ld a, [hli]
ld h, [hl]
ld l, a
ret
-.asm_469fc
+.noMatch
ld a, $ff
ld [$ffee], a
ret
-Func_46a01: ; 46a01 (11:6a01)
- ld a, [wSpriteStateData1 + 9]
- cp $4
- jr z, .asm_46a16
- cp $8
- jr z, .asm_46a25
- cp $c
- jr z, .asm_46a2b
- ld a, [W_YCOORD] ; wd361
+; checks if the coordinates in front of the player's sprite match Y in b and X in c
+; [$ffea] = $00 if they match, $ff if they don't match
+CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01)
+ ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
+ cp SPRITE_FACING_UP
+ jr z, .facingUp
+ cp SPRITE_FACING_LEFT
+ jr z, .facingLeft
+ cp SPRITE_FACING_RIGHT
+ jr z, .facingRight
+; facing down
+ ld a, [W_YCOORD]
inc a
- jr .asm_46a1a
-.asm_46a16
- ld a, [W_YCOORD] ; wd361
+ jr .upDownCommon
+.facingUp
+ ld a, [W_YCOORD]
dec a
-.asm_46a1a
+.upDownCommon
cp b
- jr nz, .asm_46a3b
- ld a, [W_XCOORD] ; wd362
+ jr nz, .didNotMatch
+ ld a, [W_XCOORD]
cp c
- jr nz, .asm_46a3b
- jr .asm_46a38
-.asm_46a25
- ld a, [W_XCOORD] ; wd362
+ jr nz, .didNotMatch
+ jr .matched
+.facingLeft
+ ld a, [W_XCOORD]
dec a
- jr .asm_46a2f
-.asm_46a2b
- ld a, [W_XCOORD] ; wd362
+ jr .leftRightCommon
+.facingRight
+ ld a, [W_XCOORD]
inc a
-.asm_46a2f
+.leftRightCommon
cp c
- jr nz, .asm_46a3b
- ld a, [W_YCOORD] ; wd361
+ jr nz, .didNotMatch
+ ld a, [W_YCOORD]
cp b
- jr nz, .asm_46a3b
-.asm_46a38
+ jr nz, .didNotMatch
+.matched
xor a
- jr .asm_46a3d
-.asm_46a3b
+ jr .done
+.didNotMatch
ld a, $ff
-.asm_46a3d
+.done
ld [$ffea], a
ret
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 07a73be6..84e39853 100755
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -260,12 +260,11 @@ RLEList_PewterGymGuy: ; 1a5da (6:65da)
db $C0, $03
db $FF
-; XXX why would this function want to return on POKEMONTOWER_7?
-Func_1a5e7: ; 1a5e7 (6:65e7)
- ld a, [W_CURMAP] ; W_CURMAP
+FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)
+ ld a, [W_CURMAP]
cp POKEMONTOWER_7
- ret z
- ld hl, RivalIDs ; $6605
+ ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them
+ ld hl, RivalIDs
ld a, [wEngagedTrainerClass]
ld b, a
.loop
@@ -273,11 +272,11 @@ Func_1a5e7: ; 1a5e7 (6:65e7)
cp $ff
jr z, .notRival
cp b
- ret z
+ ret z ; the rival leaves after battling, so don't freeze him
jr .loop
.notRival
ld a, [wSpriteIndex]
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [H_SPRITEINDEX], a
jp SetSpriteMovementBytesToFF
RivalIDs: ; 1a605 (6:6605)
diff --git a/engine/play_time.asm b/engine/play_time.asm
index db7d6f67..74da9c59 100755
--- a/engine/play_time.asm
+++ b/engine/play_time.asm
@@ -1,25 +1,25 @@
-Func_18dee: ; 18dee (6:4dee)
- call Func_18e36
+TrackPlayTime: ; 18dee (6:4dee)
+ call CountDownIgnoreInputBitReset
ld a, [wd732]
bit 0, a
ret z
- ld a, [W_PLAYTIMEMINUTES] ; wda42
+ ld a, [W_PLAYTIMEMINUTES]
and a
ret nz
- ld a, [W_PLAYTIMEFRAMES] ; wda45
+ ld a, [W_PLAYTIMEFRAMES]
inc a
- ld [W_PLAYTIMEFRAMES], a ; wda45
+ ld [W_PLAYTIMEFRAMES], a
cp 60
ret nz
xor a
- ld [W_PLAYTIMEFRAMES], a ; wda45
- ld a, [W_PLAYTIMESECONDS] ; wda44
+ ld [W_PLAYTIMEFRAMES], a
+ ld a, [W_PLAYTIMESECONDS]
inc a
- ld [W_PLAYTIMESECONDS], a ; wda44
+ ld [W_PLAYTIMESECONDS], a
cp 60
ret nz
xor a
- ld [W_PLAYTIMESECONDS], a ; wda44
+ ld [W_PLAYTIMESECONDS], a
ld a, [W_PLAYTIMEMINUTES + 1]
inc a
ld [W_PLAYTIMEMINUTES + 1], a
@@ -33,11 +33,11 @@ Func_18dee: ; 18dee (6:4dee)
cp $ff
ret nz
ld a, $ff
- ld [W_PLAYTIMEMINUTES], a ; wda42
+ ld [W_PLAYTIMEMINUTES], a
ret
-Func_18e36: ; 18e36 (6:4e36)
- ld a, [wd13a]
+CountDownIgnoreInputBitReset: ; 18e36 (6:4e36)
+ ld a, [wIgnoreInputCounter]
and a
jr nz, .asm_18e40
ld a, $ff
@@ -45,7 +45,7 @@ Func_18e36: ; 18e36 (6:4e36)
.asm_18e40
dec a
.asm_18e41
- ld [wd13a], a
+ ld [wIgnoreInputCounter], a
and a
ret nz
ld a, [wd730]
diff --git a/engine/predefs.asm b/engine/predefs.asm
index 0a5eff03..b73c485a 100755
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -58,7 +58,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef ScaleSpriteByTwo
add_predef LoadMonBackPic
add_predef Func_79aba
- add_predef Func_f132
+ add_predef LoadMissableObjects
add_predef HealParty
add_predef MoveAnimation; 08 play move animation
add_predef DivideBCDPredef
@@ -75,13 +75,13 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef AnyPartyAlive
add_predef ShowObject
add_predef ShowObject2
- add_predef Func_ee9e
+ add_predef ReplaceTileBlock
add_predef InitPlayerData2
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,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0
dbw $03,GiveItem
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
@@ -117,7 +117,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef WriteMonMoves
add_predef SaveSAV
add_predef LoadSGB
- add_predef Func_f113
+ add_predef MarkTownVisitedAndLoadMissableObjects
add_predef SetPartyMonTypes
add_predef CanLearnTM
add_predef TMToMove
diff --git a/engine/save.asm b/engine/save.asm
index fcfbd133..f4057577 100755
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -32,11 +32,11 @@ FileDataDestroyedText: ; 7361e (1c:761e)
db "@"
LoadSAVCheckSum: ; 73623 (1c:7623)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
ld hl, $a598 ; hero name located in SRAM
ld bc, $f8b ; but here checks the full SAV
call SAVCheckSum
@@ -58,30 +58,30 @@ LoadSAVCheckSum: ; 73623 (1c:7623)
ld bc, $b
call CopyData
ld hl, $a5a3
- ld de, wPokedexOwned ; wPokedexOwned
+ ld de, wPokedexOwned
ld bc, $789
call CopyData
- ld hl, W_CURMAPTILESET ; W_CURMAPTILESET
+ ld hl, W_CURMAPTILESET
set 7, [hl]
ld hl, $ad2c
ld de, wSpriteStateData1
ld bc, $200
call CopyData
ld a, [$b522]
- ld [$ffd7], a
+ ld [hTilesetType], a
ld hl, $b0c0
- ld de, W_NUMINBOX ; wda80
- ld bc, $462
+ ld de, W_NUMINBOX
+ ld bc, wBoxMonNicksEnd - W_NUMINBOX
call CopyData
and a
jp SAVGoodChecksum
LoadSAVCheckSum1: ; 73690 (1c:7690)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
ld hl, $a598 ; hero name located in SRAM
ld bc, $f8b ; but here checks the full SAV
call SAVCheckSum
@@ -90,18 +90,18 @@ LoadSAVCheckSum1: ; 73690 (1c:7690)
cp c
jr nz, SAVBadCheckSum
ld hl, $b0c0
- ld de, W_NUMINBOX ; wda80
- ld bc, $462
+ ld de, W_NUMINBOX
+ ld bc, wBoxMonNicksEnd - W_NUMINBOX
call CopyData
and a
jp SAVGoodChecksum
LoadSAVCheckSum2: ; 736bd (1c:76bd)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
ld hl, $a598 ; hero name located in SRAM
ld bc, $f8b ; but here checks the full SAV
call SAVCheckSum
@@ -125,8 +125,8 @@ SAVBadCheckSum: ; 736f7 (1c:76f7)
SAVGoodChecksum: ; 736f8 (1c:76f8)
ld a, $0
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
Func_73701: ; 0x73701
@@ -193,67 +193,67 @@ OlderFileWillBeErasedText: ; 73787 (1c:7787)
db "@"
SaveSAVtoSRAM0: ; 7378c (1c:778c)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
- ld hl, wPlayerName ; wd158
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
+ ld hl, wPlayerName
ld de, $a598
ld bc, $b
call CopyData
- ld hl, wPokedexOwned ; wPokedexOwned
+ ld hl, wPokedexOwned
ld de, $a5a3
- ld bc, $789
+ ld bc, W_NUMINBOX - wPokedexOwned
call CopyData
- ld hl, wSpriteStateData1 ; OAM?
+ ld hl, wSpriteStateData1
ld de, $ad2c
ld bc, $200
call CopyData
- ld hl, W_NUMINBOX ; wda80
+ ld hl, W_NUMINBOX
ld de, $b0c0
- ld bc, $462
+ ld bc, wBoxMonNicksEnd - W_NUMINBOX
call CopyData
- ld a, [$ffd7]
+ ld a, [hTilesetType]
ld [$b522], a
ld hl, $a598
ld bc, $f8b
call SAVCheckSum
ld [$b523], a
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
SaveSAVtoSRAM1: ; 737e2 (1c:77e2)
; stored pokémon
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
- ld hl, W_NUMINBOX ; wda80
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
+ ld hl, W_NUMINBOX
ld de, $b0c0
- ld bc, $462
+ ld bc, wBoxMonNicksEnd - W_NUMINBOX
call CopyData
ld hl, $a598
ld bc, $f8b
call SAVCheckSum
ld [$b523], a
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
SaveSAVtoSRAM2: ; 7380f (1c:780f)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
- ld [$4000], a
- ld hl, wPartyCount ; wPartyCount
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamBank], a
+ ld hl, wPartyCount
ld de, $af2c
- ld bc, $194
+ ld bc, wPokedexOwned - wPartyCount
call CopyData
ld hl, wPokedexOwned ; pokédex only
ld de, $a5a3
@@ -264,8 +264,8 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f)
call SAVCheckSum
ld [$b523], a
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
SaveSAVtoSRAM: ; 73848 (1c:7848)
@@ -334,13 +334,13 @@ PointerTable_73895: ; 73895 (1c:7895)
dw $B188
dw $B5EA
-Func_738a1:: ; 738a1 (1c:78a1)
+ChangeBox:: ; 738a1 (1c:78a1)
ld hl, WhenYouChangeBoxText
call PrintText
call YesNoChoice
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld a, [wCurrentMenuItem]
and a
- ret nz
+ ret nz ; return if No was chosen
ld hl, wd5a0
bit 7, [hl]
call z, Func_73a29
@@ -356,25 +356,25 @@ Func_738a1:: ; 738a1 (1c:78a1)
call Func_7387b
ld e, l
ld d, h
- ld hl, W_NUMINBOX ; wda80
+ ld hl, W_NUMINBOX
call Func_7390e
- ld a, [wCurrentMenuItem] ; wCurrentMenuItem
+ ld a, [wCurrentMenuItem]
set 7, a
ld [wd5a0], a
call Func_7387b
- ld de, W_NUMINBOX ; wda80
+ ld de, W_NUMINBOX
call Func_7390e
- ld hl, W_MAPTEXTPTR ; wd36c
- ld de, wWhichTrade ; wWhichTrade
+ ld hl, W_MAPTEXTPTR
+ ld de, wChangeBoxSavedMapTextPointer
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
- call Func_3f05
+ call RestoreMapTextPointer
call SaveSAVtoSRAM
- ld hl, wWhichTrade ; wWhichTrade
- call Func_3f0f
+ ld hl, wChangeBoxSavedMapTextPointer
+ call SetMapTextPointer
ld a, (SFX_02_5d - SFX_Headers_02) / 3
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
@@ -386,12 +386,12 @@ WhenYouChangeBoxText: ; 73909 (1c:7909)
Func_7390e: ; 7390e (1c:790e)
push hl
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
+ ld [MBC1SRamBankingMode], a
ld a, b
- ld [$4000], a
+ ld [MBC1SRamBank], a
ld bc, $462
call CopyData
pop hl
@@ -405,8 +405,8 @@ Func_7390e: ; 7390e (1c:790e)
ld [$ba4c], a
call Func_73863
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
Func_7393f: ; 7393f (1c:793f)
@@ -502,19 +502,19 @@ BoxNoText: ; 73a21 (1c:7a21)
db "BOX No.@"
Func_73a29: ; 73a29 (1c:7a29)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
+ ld [MBC1SRamBankingMode], a
ld a, $2
- ld [$4000], a
+ ld [MBC1SRamBank], a
call Func_73a4b
ld a, $3
- ld [$4000], a
+ ld [MBC1SRamBank], a
call Func_73a4b
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
Func_73a4b: ; 73a4b (1c:7a4b)
@@ -547,19 +547,19 @@ Func_73a7f: ; 73a7f (1c:7a7f)
Func_73a84: ; 73a84 (1c:7a84)
ld hl, wWhichTrade ; wWhichTrade
push hl
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
+ ld [MBC1SRamBankingMode], a
ld a, $2
- ld [$4000], a
+ ld [MBC1SRamBank], a
call Func_73ab8
ld a, $3
- ld [$4000], a
+ ld [MBC1SRamBank], a
call Func_73ab8
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
pop hl
ld a, [wd5a0]
and $7f
@@ -592,8 +592,8 @@ SAVCheckRandomID: ;$7ad1
ld a,$0a
ld [$0000],a
ld a,$01
- ld [$6000],a
- ld [$4000],a
+ ld [MBC1SRamBankingMode],a
+ ld [MBC1SRamBank],a
ld a,[$a598]
and a
jr z,.next
@@ -615,7 +615,7 @@ SAVCheckRandomID: ;$7ad1
cp h
.next
ld a,$00
- ld [$6000],a
+ ld [MBC1SRamBankingMode],a
ld [$0000],a
ret
@@ -653,23 +653,23 @@ LoadHallOfFameTeams: ; 73b3f (1c:7b3f)
; fallthrough
HallOfFame_Copy: ; 73b51 (1c:7b51)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
+ ld [MBC1SRamBankingMode], a
xor a
- ld [$4000], a
+ ld [MBC1SRamBank], a
call CopyData
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
Func_73b6a: ; 73b6a (1c:7b6a)
- ld a, $a
- ld [$0], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
ld a, $1
- ld [$6000], a
+ ld [MBC1SRamBankingMode], a
xor a
call PadSRAM_FF
ld a, $1
@@ -679,12 +679,12 @@ Func_73b6a: ; 73b6a (1c:7b6a)
ld a, $3
call PadSRAM_FF
xor a
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
PadSRAM_FF: ; 73b8f (1c:7b8f)
- ld [$4000], a
+ ld [MBC1SRamBank], a
ld hl, $a000
ld bc, $2000
ld a, $ff
diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm
index 3f9cc613..ca81eff8 100755
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -26,7 +26,7 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd)
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
xor a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [$ffae], a
ld a, $40
ld [$ffaf], a
diff --git a/engine/town_map.asm b/engine/town_map.asm
index 6d10c222..3b7506d5 100755
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -64,7 +64,7 @@ Func_70e92: ; 70e92 (1c:4e92)
ld bc, $10
call CopyData
.asm_70ec8
- call Func_716c6
+ call TownMapSpriteBlinkingAnimation
call JoypadLowSensitivity
ld a, [$ffb5]
ld b, a
@@ -77,9 +77,9 @@ Func_70e92: ; 70e92 (1c:4e92)
bit 7, b
jr nz, .asm_70f01
xor a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
ld [$ffb7], a
- ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM
+ ld [wTownMapSpriteBlinkingCounter], a
call Func_711ab
pop hl
pop af
@@ -213,7 +213,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
set 7, [hl]
.asm_71037
xor a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOutWithDelay3
pop hl
pop af
@@ -319,9 +319,9 @@ LoadTownMap: ; 7109b (1c:509b)
call Delay3
call GBPalNormal
xor a
- ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM
+ ld [wTownMapSpriteBlinkingCounter], a
inc a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
ret
CompressedMap: ; 71100 (1c:5100)
@@ -330,7 +330,7 @@ CompressedMap: ; 71100 (1c:5100)
Func_711ab: ; 711ab (1c:51ab)
xor a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOut
call ClearScreen
call ClearSprites
@@ -570,29 +570,30 @@ INCLUDE "text/map_names.asm"
MonNestIcon: ; 716be (1c:56be)
INCBIN "gfx/mon_nest_icon.1bpp"
-Func_716c6: ; 716c6 (1c:56c6)
- ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM
+TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
+ ld a, [wTownMapSpriteBlinkingCounter]
inc a
- cp $19
- jr z, .asm_716e1
- cp $32
- jr nz, .asm_716f1
+ cp 25
+ jr z, .hideSprites
+ cp 50
+ jr nz, .done
+; show sprites when the counter reaches 50
ld hl, wTileMapBackup
ld de, wOAMBuffer
ld bc, $90
call CopyData
xor a
- jr .asm_716f1
-.asm_716e1
+ jr .done
+.hideSprites
ld hl, wOAMBuffer
ld b, $24
ld de, $4
-.asm_716e9
+.hideSpritesLoop
ld [hl], $a0
add hl, de
dec b
- jr nz, .asm_716e9
- ld a, $19
-.asm_716f1
- ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM
+ jr nz, .hideSpritesLoop
+ ld a, 25
+.done
+ ld [wTownMapSpriteBlinkingCounter], a
jp DelayFrame
diff --git a/engine/trade.asm b/engine/trade.asm
index 5be77f3e..d134e15a 100755
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -475,7 +475,7 @@ Func_4149f: ; 4149f (10:549f)
Func_414ae: ; 414ae (10:54ae)
push hl
hlCoord 0, 4
- call ScheduleRowRedrawHelper
+ call CopyToScreenEdgeTiles
pop hl
ld a, h
ld [H_SCREENEDGEREDRAWADDR + 1], a
diff --git a/home.asm b/home.asm
index 87215991..19ab1715 100644
--- a/home.asm
+++ b/home.asm
@@ -86,11 +86,11 @@ FarCopyData::
push af
ld a, [wBuffer]
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
call CopyData
pop af
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ret
CopyData::
@@ -346,10 +346,10 @@ GetCryData:: ; 13d9 (0:13d9)
ret
DisplayPartyMenu:: ; 13fc (0:13fc)
- ld a,[$ffd7]
+ ld a,[hTilesetType]
push af
xor a
- ld [$ffd7],a
+ ld [hTilesetType],a
call GBPalWhiteOutWithDelay3
call ClearSprites
call PartyMenuInit
@@ -357,10 +357,10 @@ DisplayPartyMenu:: ; 13fc (0:13fc)
jp HandlePartyMenuInput
GoBackToPartyMenu:: ; 1411 (0:1411)
- ld a,[$ffd7]
+ ld a,[hTilesetType]
push af
xor a
- ld [$ffd7],a
+ ld [hTilesetType],a
call PartyMenuInit
call RedrawPartyMenu
jp HandlePartyMenuInput
@@ -422,7 +422,7 @@ HandlePartyMenuInput:: ; 145a (0:145a)
and a
jp nz,.swappingPokemon
pop af
- ld [$ffd7],a
+ ld [hTilesetType],a
bit 1,b
jr nz,.noPokemonChosen
ld a,[wPartyCount]
@@ -920,11 +920,11 @@ FarCopyData2::
push af
ld a,[$ff8b]
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
call CopyData
pop af
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
ret
FarCopyData3::
@@ -934,7 +934,7 @@ FarCopyData3::
push af
ld a,[$ff8b]
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
push hl
push de
push de
@@ -946,7 +946,7 @@ FarCopyData3::
pop hl
pop af
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
ret
FarCopyDataDouble::
@@ -957,7 +957,7 @@ FarCopyDataDouble::
push af
ld a,[$ff8b]
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
.loop
ld a,[hli]
ld [de],a
@@ -970,7 +970,7 @@ FarCopyDataDouble::
jr nz,.loop
pop af
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
ret
CopyVideoData::
@@ -988,7 +988,7 @@ CopyVideoData::
ld a, b
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ld a, e
ld [H_VBCOPYSRC], a
@@ -1010,7 +1010,7 @@ CopyVideoData::
call DelayFrame
ld a, [$ff8b]
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
pop af
ld [H_AUTOBGTRANSFERENABLED], a
ret
@@ -1037,7 +1037,7 @@ CopyVideoDataDouble::
ld a, b
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ld a, e
ld [H_VBCOPYDOUBLESRC], a
@@ -1059,7 +1059,7 @@ CopyVideoDataDouble::
call DelayFrame
ld a, [$ff8b]
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
pop af
ld [H_AUTOBGTRANSFERENABLED], a
ret
@@ -2687,12 +2687,14 @@ DisplayTextBoxID:: ; 30e8 (0:30e8)
ld [$2000],a
ret
-Func_30fd:: ; 30fd (0:30fd)
+; not zero if an NPC movement script is running, the player character is
+; automatically stepping down from a door, or joypad states are being simulated
+IsPlayerCharacterBeingControlledByGame:: ; 30fd (0:30fd)
ld a, [wNPCMovementScriptPointerTableNum]
and a
ret nz
ld a, [wd736]
- bit 1, a
+ bit 1, a ; currently stepping down from door bit
ret nz
ld a, [wd730]
and $80
@@ -2740,7 +2742,7 @@ EndNPCMovementScript:: ; 314e (0:314e)
ld hl, _EndNPCMovementScript
jp Bankswitch
-Func_3156:: ; 3156 (0:3156)
+EmptyFunc2:: ; 3156 (0:3156)
ret
; stores hl in [W_TRAINERHEADERPTR]
@@ -2831,7 +2833,6 @@ ReadTrainerHeaderInfo:: ; 3193 (0:3193)
TrainerFlagAction::
predef_jump FlagActionPredef
-; direct talking to a trainer (rather than getting seen by one)
TalkToTrainer:: ; 31cc (0:31cc)
call StoreTrainerHeaderPointer
xor a
@@ -2858,16 +2859,17 @@ TalkToTrainer:: ; 31cc (0:31cc)
ld a, $8
call ReadTrainerHeaderInfo ; read end battle text
pop de
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld hl, W_FLAGS_D733
set 4, [hl] ; activate map script index override (index is set below)
ld hl, wFlags_0xcd60
- bit 0, [hl] ; test if player is already being engaged by another trainer
+ bit 0, [hl] ; test if player is already engaging the trainer (because the trainer saw the player)
ret nz
+; if the player talked to the trainer of his own volition
call EngageMapTrainer
ld hl, W_CURMAPSCRIPT
- inc [hl] ; progress map script index (assuming it was 0 before) to start pre-battle routines
- jp Func_325d
+ inc [hl] ; increment map script index before StartTrainerBattle increments it again (next script function is usually EndTrainerBattle)
+ jp StartTrainerBattle
; checks if any trainers are seeing the player and wanting to fight
CheckFightingMapTrainers:: ; 3219 (0:3219)
@@ -2892,19 +2894,21 @@ CheckFightingMapTrainers:: ; 3219 (0:3219)
ldh [$b4], a
call TrainerWalkUpToPlayer_Bank0
ld hl, W_CURMAPSCRIPT
- inc [hl] ; progress to battle phase 1 (engaging)
+ inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle)
ret
-Func_324c:: ; 324c (0:324c)
+; display the before battle text after the enemy trainer has walked up to the player's sprite
+DisplayEnemyTrainerTextAndStartBattle:: ; 324c (0:324c)
ld a, [wd730]
and $1
- ret nz
+ ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite
ld [wJoyIgnore], a
ld a, [wSpriteIndex]
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [hSpriteIndexOrTextID], a
call DisplayTextID
+ ; fall through
-Func_325d:: ; 325d (0:325d)
+StartTrainerBattle:: ; 325d (0:325d)
xor a
ld [wJoyIgnore], a
call InitBattleEnemyParameters
@@ -2914,7 +2918,7 @@ Func_325d:: ; 325d (0:325d)
ld hl, wd72e
set 1, [hl]
ld hl, W_CURMAPSCRIPT
- inc [hl] ; progress to battle phase 2 (battling)
+ inc [hl] ; increment map script index (next script function is usually EndTrainerBattle)
ret
EndTrainerBattle:: ; 3275 (0:3275)
@@ -3044,18 +3048,19 @@ CheckForEngagingTrainers:: ; 3306 (0:3306)
ld e, l
jr .trainerLoop
-; saves loaded rom bank and hl as well as de registers
-PreBattleSaveRegisters:: ; 3354 (0:3354)
+; hl = text if the player wins
+; de = text if the player loses
+SaveEndBattleTextPointers:: ; 3354 (0:3354)
ld a, [H_LOADEDROMBANK]
- ld [W_PBSTOREDROMBANK], a
+ ld [wEndBattleTextRomBank], a
ld a, h
- ld [W_PBSTOREDREGISTERH], a
+ ld [wEndBattleWinTextPointer], a
ld a, l
- ld [W_PBSTOREDREGISTERL], a
+ ld [wEndBattleWinTextPointer + 1], a
ld a, d
- ld [W_PBSTOREDREGISTERD], a
+ ld [wEndBattleLoseTextPointer], a
ld a, e
- ld [W_PBSTOREDREGISTERE], a
+ ld [wEndBattleLoseTextPointer + 1], a
ret
; loads data of some trainer on the current map and plays pre-battle music
@@ -3074,7 +3079,7 @@ EngageMapTrainer:: ; 336a (0:336a)
ld [wEnemyMonAttackMod], a ; wcd2e
jp PlayTrainerMusic
-Func_3381:: ; 3381 (0:3381)
+PrintEndBattleText:: ; 3381 (0:3381)
push hl
ld hl, wd72d
bit 7, [hl]
@@ -3083,45 +3088,45 @@ Func_3381:: ; 3381 (0:3381)
ret z
ld a, [H_LOADEDROMBANK]
push af
- ld a, [W_PBSTOREDROMBANK]
+ ld a, [wEndBattleTextRomBank]
ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ ld [MBC1RomBank], a
push hl
callba SaveTrainerName
- ld hl, TrainerNameText
+ ld hl, TrainerEndBattleText
call PrintText
pop hl
pop af
ld [H_LOADEDROMBANK], a
- ld [$2000], a
- callba Func_1a5e7
+ ld [MBC1RomBank], a
+ callba FreezeEnemyTrainerSprite
jp WaitForSoundToFinish
-Func_33b7:: ; 33b7 (0:33b7)
+GetSavedEndBattleTextPointer:: ; 33b7 (0:33b7)
ld a, [wBattleResult]
and a
- jr nz, .asm_33c6
- ld a, [W_PBSTOREDREGISTERH]
+; won battle
+ jr nz, .lostBattle
+ ld a, [wEndBattleWinTextPointer]
ld h, a
- ld a, [W_PBSTOREDREGISTERL]
+ ld a, [wEndBattleWinTextPointer + 1]
ld l, a
ret
-.asm_33c6
- ld a, [W_PBSTOREDREGISTERD]
+.lostBattle
+ ld a, [wEndBattleLoseTextPointer]
ld h, a
- ld a, [W_PBSTOREDREGISTERE]
+ ld a, [wEndBattleLoseTextPointer + 1]
ld l, a
ret
-TrainerNameText:: ; 33cf (0:33cf)
+TrainerEndBattleText:: ; 33cf (0:33cf)
TX_FAR _TrainerNameText
db $08
-
-Func_33d4:: ; 33d4 (0:33d4)
- call Func_33b7
+ call GetSavedEndBattleTextPointer
call TextCommandProcessor
jp TextScriptEnd
+; XXX unused?
Func_33dd:: ; 33dd (0:33dd)
ld a, [wFlags_0xcd60]
bit 0, a
@@ -3177,15 +3182,19 @@ PlayTrainerMusic:: ; 33e8 (0:33e8)
INCLUDE "data/trainer_types.asm"
-Func_3442:: ; 3442 (0:3442)
+; checks if the player's coordinates match an arrow movement tile's coordinates
+; and if so, decodes the RLE movement data
+; b = player Y
+; c = player X
+DecodeArrowMovementRLE:: ; 3442 (0:3442)
ld a, [hli]
cp $ff
- ret z
+ ret z ; no match in the list
cp b
- jr nz, .asm_345b
+ jr nz, .nextArrowMovementTileEntry1
ld a, [hli]
cp c
- jr nz, .asm_345c
+ jr nz, .nextArrowMovementTileEntry2
ld a, [hli]
ld d, [hl]
ld e, a
@@ -3194,12 +3203,12 @@ Func_3442:: ; 3442 (0:3442)
dec a
ld [wSimulatedJoypadStatesIndex], a
ret
-.asm_345b
+.nextArrowMovementTileEntry1
inc hl
-.asm_345c
+.nextArrowMovementTileEntry2
inc hl
inc hl
- jr Func_3442
+ jr DecodeArrowMovementRLE
FuncTX_ItemStoragePC:: ; 3460 (0:3460)
call SaveScreenTilesToBuffer2
@@ -3313,14 +3322,14 @@ CheckCoords:: ; 34c7 (0:34c7)
; tests if a boulder's coordinates are in a specified array
; INPUT:
; hl = address of array
-; ff8c = which boulder to check? XXX
+; [H_SPRITEINDEX] = index of boulder sprite
; OUTPUT:
; [wWhichTrade] = if there is match, the matching array index
; sets carry if the coordinates are in the array, clears carry if not
CheckBoulderCoords:: ; 34e4 (0:34e4)
push hl
ld hl, wSpriteStateData2 + $04
- ld a, [$ff8c]
+ ld a, [H_SPRITEINDEX]
swap a
ld d, $0
ld e, a
@@ -3971,21 +3980,21 @@ JoypadLowSensitivity:: ; 3831 (0:3831)
ret
WaitForTextScrollButtonPress:: ; 3865 (0:3865)
- ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b
+ ld a, [H_DOWNARROWBLINKCNT1]
push af
- ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
+ ld a, [H_DOWNARROWBLINKCNT2]
push af
xor a
- ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
+ ld [H_DOWNARROWBLINKCNT1], a
ld a, $6
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
-.asm_3872
+ ld [H_DOWNARROWBLINKCNT2], a
+.loop
push hl
- ld a, [wd09b]
+ ld a, [wTownMapSpriteBlinkingEnabled]
and a
- jr z, .asm_387c
- call Func_716c6
-.asm_387c
+ jr z, .skipAnimation
+ call TownMapSpriteBlinkingAnimation
+.skipAnimation
hlCoord 18, 16
call HandleDownArrowBlinkTiming
pop hl
@@ -3993,16 +4002,16 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865)
predef Func_5a5f
ld a, [$ffb5]
and A_BUTTON | B_BUTTON
- jr z, .asm_3872
+ jr z, .loop
pop af
- ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
+ ld [H_DOWNARROWBLINKCNT2], a
pop af
- ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
+ ld [H_DOWNARROWBLINKCNT1], a
ret
-; (unlass in link battle) waits for A or B being pressed and outputs the scrolling sound effect
+; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect
ManualTextScroll:: ; 3898 (0:3898)
- ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE
+ ld a, [W_ISLINKBATTLE]
cp $4
jr z, .inLinkBattle
call WaitForTextScrollButtonPress
@@ -5145,70 +5154,72 @@ Func_3ead:: ; 3ead (0:3ead)
ld hl, CinnabarGymQuiz_1eb0a
jp Bankswitch
-Func_3eb5:: ; 3eb5 (0:3eb5)
+CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5)
ld a, [H_LOADEDROMBANK]
push af
ld a, [hJoyHeld]
- bit 0, a
- jr z, .asm_3eea
- ld a, Bank(Func_469a0)
- ld [$2000], a
+ bit 0, a ; A button
+ jr z, .nothingFound
+; A button is pressed
+ ld a, Bank(CheckForHiddenObject)
+ ld [MBC1RomBank], a
ld [H_LOADEDROMBANK], a
- call Func_469a0
+ call CheckForHiddenObject
ld a, [$ffee]
and a
- jr nz, .asm_3edd
- ld a, [wTrainerEngageDistance]
- ld [$2000], a
+ jr nz, .hiddenObjectNotFound
+ ld a, [wHiddenObjectFunctionRomBank]
+ ld [MBC1RomBank], a
ld [H_LOADEDROMBANK], a
- ld de, .asm_3eda
+ ld de, .returnAddress
push de
jp [hl]
-.asm_3eda
+.returnAddress
xor a
- jr .asm_3eec
-.asm_3edd
+ jr .done
+.hiddenObjectNotFound
callba PrintBookshelfText
ld a, [$ffdb]
and a
- jr z, .asm_3eec
-.asm_3eea
+ jr z, .done
+.nothingFound
ld a, $ff
-.asm_3eec
+.done
ld [$ffeb], a
pop af
- ld [$2000], a
+ ld [MBC1RomBank], a
ld [H_LOADEDROMBANK], a
ret
PrintPredefTextID:: ; 3ef5 (0:3ef5)
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
- ld hl, PointerTable_3f22
- call Func_3f0f
+ ld hl, PredefTextIDPointerTable
+ call SetMapTextPointer
ld hl, wcf11
set 0, [hl]
call DisplayTextID
+ ; fall through
-Func_3f05:: ; 3f05 (0:3f05)
- ld hl, W_MAPTEXTPTR ; wd36c
+RestoreMapTextPointer:: ; 3f05 (0:3f05)
+ ld hl, W_MAPTEXTPTR
ld a, [$ffec]
ld [hli], a
ld a, [$ffed]
ld [hl], a
ret
-Func_3f0f:: ; 3f0f (0:3f0f)
- ld a, [W_MAPTEXTPTR] ; wd36c
+SetMapTextPointer:: ; 3f0f (0:3f0f)
+ ld a, [W_MAPTEXTPTR]
ld [$ffec], a
ld a, [W_MAPTEXTPTR + 1]
ld [$ffed], a
ld a, l
- ld [W_MAPTEXTPTR], a ; wd36c
+ ld [W_MAPTEXTPTR], a
ld a, h
ld [W_MAPTEXTPTR + 1], a
ret
-PointerTable_3f22:: ; 3f22 (0:3f22)
+PredefTextIDPointerTable:: ; 3f22 (0:3f22)
dw CardKeySuccessText ; id = 01
dw CardKeyFailText ; id = 02
dw RedBedroomPC ; id = 03
diff --git a/home/init.asm b/home/init.asm
index 402a402e..e170fe78 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -61,11 +61,11 @@ rLCDC_DEFAULT EQU %11100011
ld a, Bank(WriteDMACodeToHRAM)
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
call WriteDMACodeToHRAM
xor a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [$ff41], a
ld [$ffae], a
ld [$ffaf], a
diff --git a/home/overworld.asm b/home/overworld.asm
index 9dbfdfb7..50791184 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -10,7 +10,7 @@ EnterMap::
ld a, $ff
ld [wJoyIgnore], a
call LoadMapData
- callba Func_c335 ; initialize map variables
+ callba ClearVariablesAfterLoadingMapData
ld hl, wd72c
bit 0, [hl] ; has the player already made 3 steps since the last battle?
jr z, .skipGivingThreeStepsOfNoRandomBattles
@@ -20,14 +20,14 @@ EnterMap::
ld hl, wd72e
bit 5, [hl] ; did a battle happen immediately before this?
res 5, [hl] ; unset the "battle just happened" flag
- call z, Func_12e7
+ call z, ResetUsingStrengthOutOfBattleBit
call nz, MapEntryAfterBattle
ld hl, wd732
ld a, [hl]
and 1 << 4 | 1 << 3 ; fly warp or dungeon warp
jr z, .didNotEnterUsingFlyWarpOrDungeonWarp
res 3, [hl]
- callba EnterMapAnim ; display fly/teleport in graphical effect
+ callba EnterMapAnim
call UpdateSprites
.didNotEnterUsingFlyWarpOrDungeonWarp
callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road
@@ -53,7 +53,7 @@ OverworldLoopLessDelay::
jp nz,.moveAhead ; if the player sprite has not yet completed the walking animation
call JoypadOverworld ; get joypad state (which is possibly simulated)
callba SafariZoneCheck
- ld a,[wda46]
+ ld a,[wSafariZoneGameOver]
and a
jp nz,WarpFound2
ld hl,wd72d
@@ -78,7 +78,7 @@ OverworldLoopLessDelay::
jr z,.startButtonNotPressed
; if START is pressed
xor a
- ld [$ff8c],a ; the $2920 ID for the start menu is 0
+ ld [hSpriteIndexOrTextID],a ; start menu text ID
jp .displayDialogue
.startButtonNotPressed
bit 0,a ; A button
@@ -87,14 +87,14 @@ OverworldLoopLessDelay::
ld a,[wd730]
bit 2,a
jp nz,.noDirectionButtonsPressed
- call Func_30fd
+ call IsPlayerCharacterBeingControlledByGame
jr nz,.checkForOpponent
- call Func_3eb5 ; check for hidden items, PC's, etc.
+ call CheckForHiddenObjectOrBookshelfOrCardKeyDoor
ld a,[$ffeb]
and a
- jp z,OverworldLoop
- call IsSpriteOrSignInFrontOfPlayer ; check for sign or sprite in front of the player
- ld a,[$ff8c] ; $2920 ID for NPC/sign text, if any
+ jp z,OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found
+ call IsSpriteOrSignInFrontOfPlayer
+ ld a,[hSpriteIndexOrTextID]
and a
jp z,OverworldLoop
.displayDialogue
@@ -293,7 +293,7 @@ OverworldLoopLessDelay::
bit 7,a ; in the safari zone?
jr z,.notSafariZone
callba SafariZoneCheckSteps
- ld a,[wda46]
+ ld a,[wSafariZoneGameOver]
and a
jp nz,WarpFound2
.notSafariZone
@@ -350,8 +350,8 @@ NewBattle:: ; 0683 (0:0683)
ld a,[wd72d]
bit 4,a
jr nz,.noBattle
- call Func_30fd
- jr nz,.noBattle
+ call IsPlayerCharacterBeingControlledByGame
+ jr nz,.noBattle ; no battle if the player character is under the game's control
ld a,[wd72e]
bit 4,a
jr nz,.noBattle
@@ -523,7 +523,7 @@ WarpFound2:: ; 073c (0:073c)
.done
ld hl,wd736
set 0,[hl] ; have the player's sprite step out from the door (if there is one)
- call Func_12da
+ call IgnoreInputForHalfSecond
jp EnterMap
ContinueCheckWarpsNoCollisionLoop:: ; 07b5 (0:07b5)
@@ -747,7 +747,7 @@ HandleBlackOut::
res 5, [hl]
ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap)
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
call ResetStatusAndHalveMoneyOnBlackout
call SpecialWarpIn
call Func_2312
@@ -798,7 +798,7 @@ LoadPlayerSpriteGraphics::
dec a
jr z, .ridingBike
- ld a, [$ffd7]
+ ld a, [hTilesetType]
and a
jr nz, .determineGraphics
jr .startWalking
@@ -1058,11 +1058,11 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02)
ret
; function to check if there is a sign or sprite in front of the player
-; if so, it is stored in [$FF8C]
-; if not, [$FF8C] is set to 0
+; if so, it is stored in [hSpriteIndexOrTextID]
+; if not, [hSpriteIndexOrTextID] is set to 0
IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
xor a
- ld [$ff8c],a
+ ld [hSpriteIndexOrTextID],a
ld a,[wd4b0] ; number of signs in the map
and a
jr z,.extendRangeOverCounter
@@ -1092,7 +1092,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
dec c
add hl,bc
ld a,[hl]
- ld [$ff8c],a ; store sign text ID
+ ld [hSpriteIndexOrTextID],a ; store sign text ID
pop bc
pop hl
ret
@@ -1113,7 +1113,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
jr nz,.counterTilesLoop
; part of the above function, but sometimes its called on its own, when signs are irrelevant
-; the caller must zero [$FF8C]
+; the caller must zero [hSpriteIndexOrTextID]
IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b)
ld d,$10 ; talking range in pixels (normal range)
IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
@@ -1195,7 +1195,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
ld l,a
set 7,[hl]
ld a,e
- ld [$ff8c],a ; store sprite ID
+ ld [hSpriteIndexOrTextID],a
ret
; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing)
@@ -1214,9 +1214,9 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1)
and d ; check if a sprite is in the direction the player is trying to go
jr nz,.collision
xor a
- ld [$ff8c],a
+ ld [hSpriteIndexOrTextID],a
call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision?
- ld a,[$ff8c]
+ ld a,[hSpriteIndexOrTextID]
and a ; was there a sprite collision?
jr nz,.collision
; if no sprite collision
@@ -1467,7 +1467,7 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
cp a,$01
jr nz,.checkIfMovingWest
; moving east
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
ld e,a
and a,$e0
ld d,a
@@ -1475,13 +1475,13 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
add a,$02
and a,$1f
or d
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
jr .adjustXCoordWithinBlock
.checkIfMovingWest
cp a,$ff
jr nz,.checkIfMovingSouth
; moving west
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
ld e,a
and a,$e0
ld d,a
@@ -1489,36 +1489,36 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27)
sub a,$02
and a,$1f
or d
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
jr .adjustXCoordWithinBlock
.checkIfMovingSouth
ld a,b
cp a,$01
jr nz,.checkIfMovingNorth
; moving south
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
add a,$40
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
jr nc,.adjustXCoordWithinBlock
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
inc a
and a,$03
or a,$98
- ld [wd527],a
+ ld [wMapViewVRAMPointer + 1],a
jr .adjustXCoordWithinBlock
.checkIfMovingNorth
cp a,$ff
jr nz,.adjustXCoordWithinBlock
; moving north
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
sub a,$40
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
jr nc,.adjustXCoordWithinBlock
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
dec a
and a,$03
or a,$98
- ld [wd527],a
+ ld [wMapViewVRAMPointer + 1],a
.adjustXCoordWithinBlock
ld a,c
and a
@@ -1694,18 +1694,18 @@ MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85)
ScheduleNorthRowRedraw:: ; 0e91 (0:0e91)
hlCoord 0, 0
- call ScheduleRowRedrawHelper
- ld a,[wd526]
+ call CopyToScreenEdgeTiles
+ ld a,[wMapViewVRAMPointer]
ld [H_SCREENEDGEREDRAWADDR],a
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
ld [H_SCREENEDGEREDRAWADDR + 1],a
ld a,REDRAWROW
ld [H_SCREENEDGEREDRAW],a
ret
-ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6)
+CopyToScreenEdgeTiles:: ; 0ea6 (0:0ea6)
ld de,wScreenEdgeTiles
- ld c,$28
+ ld c,2 * 20
.loop
ld a,[hli]
ld [de],a
@@ -1716,10 +1716,10 @@ ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6)
ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2)
hlCoord 0, 16
- call ScheduleRowRedrawHelper
- ld a,[wd526]
+ call CopyToScreenEdgeTiles
+ ld a,[wMapViewVRAMPointer]
ld l,a
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
ld h,a
ld bc,$0200
add hl,bc
@@ -1736,7 +1736,7 @@ ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2)
ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3)
hlCoord 18, 0
call ScheduleColumnRedrawHelper
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
ld c,a
and a,$e0
ld b,a
@@ -1745,7 +1745,7 @@ ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3)
and a,$1f
or b
ld [H_SCREENEDGEREDRAWADDR],a
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
ld [H_SCREENEDGEREDRAWADDR + 1],a
ld a,REDRAWCOL
ld [H_SCREENEDGEREDRAW],a
@@ -1774,9 +1774,9 @@ ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2)
ScheduleWestColumnRedraw:: ; 0f08 (0:0f08)
hlCoord 0, 0
call ScheduleColumnRedrawHelper
- ld a,[wd526]
+ ld a,[wMapViewVRAMPointer]
ld [H_SCREENEDGEREDRAWADDR],a
- ld a,[wd527]
+ ld a,[wMapViewVRAMPointer + 1]
ld [H_SCREENEDGEREDRAWADDR + 1],a
ld a,REDRAWCOL
ld [H_SCREENEDGEREDRAW],a
@@ -2013,7 +2013,7 @@ LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063)
; function to load data from the map header
LoadMapHeader:: ; 107c (0:107c)
- callba Func_f113
+ callba MarkTownVisitedAndLoadMissableObjects
ld a,[W_CURMAPTILESET]
ld [wd119],a
ld a,[W_CURMAP]
@@ -2307,9 +2307,9 @@ LoadMapData:: ; 1241 (0:1241)
push af
call DisableLCD
ld a,$98
- ld [wd527],a
+ ld [wMapViewVRAMPointer + 1],a
xor a
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
ld [$ffaf],a
ld [$ffae],a
ld [wWalkCounter],a
@@ -2383,16 +2383,16 @@ SwitchToMapRomBank:: ; 12bc (0:12bc)
pop hl
ret
-Func_12da:: ; 12da (0:12da)
- ld a, $1e
- ld [wd13a], a
+IgnoreInputForHalfSecond: ; 12da (0:12da)
+ ld a, 30
+ ld [wIgnoreInputCounter], a
ld hl, wd730
ld a, [hl]
or $26
- ld [hl], a
+ ld [hl], a ; set ignore input bit
ret
-Func_12e7:: ; 12e7 (0:12e7)
+ResetUsingStrengthOutOfBattleBit: ; 12e7 (0:12e7)
ld hl, wd728
res 0, [hl]
ret
diff --git a/home/vblank.asm b/home/vblank.asm
index b4daaa8b..d660f270 100644
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -29,7 +29,7 @@ VBlank::
call $ff80 ; hOAMDMA
ld a, Bank(PrepareOAMData)
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
call PrepareOAMData
; VBlank-sensitive operations end.
@@ -54,7 +54,7 @@ VBlank::
ld a, [wc0ef] ; music ROM bank
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
cp BANK(Music2_UpdateMusic)
jr nz, .notbank2
@@ -72,7 +72,7 @@ VBlank::
call Music1f_UpdateMusic
.afterMusic
- callba Func_18dee ; keep track of time played
+ callba TrackPlayTime ; keep track of time played
ld a, [$fff9]
and a
@@ -80,7 +80,7 @@ VBlank::
ld a, [wd122]
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
pop hl
pop de
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 81fcb991..d42293d9 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -376,9 +376,9 @@ UpdateMovingBgTiles::
; Animate water and flower
; tiles in the overworld.
- ld a, [$ffd7]
+ ld a, [hTilesetType]
and a
- ret z
+ ret z ; no animations if indoors (or if a menu set this to 0)
ld a, [$ffd8]
inc a
@@ -412,9 +412,10 @@ UpdateMovingBgTiles::
dec c
jr nz, .left
.done
- ld a, [$ffd7]
+ ld a, [hTilesetType]
rrca
ret nc
+; if in a cave, no flower animations
xor a
ld [$ffd8], a
ret
diff --git a/hram.asm b/hram.asm
index 551ec67d..013761d6 100644
--- a/hram.asm
+++ b/hram.asm
@@ -17,6 +17,9 @@ H_DOWNARROWBLINKCNT2 EQU $FF8C
H_SPRITEDATAOFFSET EQU $FF8B
H_SPRITEINDEX EQU $FF8C
+; DisplayTextID's argument
+hSpriteIndexOrTextID EQU $FF8C
+
; Note: the following multiplication and division addresses are used for multiple purposes
; and so they overlap with each other
@@ -120,6 +123,12 @@ H_FRAMECOUNTER EQU $FFD5 ; decremented every V-blank (used for delays)
; you can detect that the V-blank handler has run since then.
H_VBLANKOCCURRED EQU $FFD6
+; 00 = indoor
+; 01 = cave
+; 02 = outdoor
+; this is often set to 00 in order to turn off water and flower BG tile animations
+hTilesetType EQU $FFD7
+
H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10
H_WHOSETURN EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn
diff --git a/macros.asm b/macros.asm
index 8244c8c9..0aa76291 100644
--- a/macros.asm
+++ b/macros.asm
@@ -16,11 +16,11 @@ homecall: MACRO
push af
ld a, BANK(\1)
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
call \1
pop af
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ENDM
callba: MACRO
diff --git a/main.asm b/main.asm
index 22721cdb..72cef23b 100755
--- a/main.asm
+++ b/main.asm
@@ -2021,12 +2021,12 @@ INCLUDE "data/map_songs.asm"
INCLUDE "data/map_header_banks.asm"
-Func_c335: ; c335 (3:4335)
+ClearVariablesAfterLoadingMapData: ; c335 (3:4335)
ld a, $90
ld [hVBlankWY], a
- ld [rWY], a ; $ff4a
+ ld [rWY], a
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld [H_AUTOBGTRANSFERENABLED], a
ld [wStepCounter], a
ld [W_LONEATTACKNO], a ; W_GYMLEADERNO
ld [hJoyPressed], a
@@ -2034,10 +2034,10 @@ Func_c335: ; c335 (3:4335)
ld [hJoyHeld], a
ld [wcd6a], a
ld [wd5a3], a
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld [hli], a
ld [hl], a
- ld hl, wWhichTrade ; wWhichTrade
+ ld hl, wWhichTrade
ld bc, $1e
call FillMemory
ret
@@ -2509,7 +2509,7 @@ CheckForBoulderCollisionWithSprites: ; c636 (3:4636)
ApplyOutOfBattlePoisonDamage: ; c69c (3:469c)
ld a, [wd730]
add a
- jp c, .noBlackOut
+ jp c, .noBlackOut ; no black out if joypad states are being simulated
ld a, [wPartyCount]
and a
jp z, .noBlackOut
@@ -2644,7 +2644,7 @@ LoadTilesetHeader: ; c754 (3:4754)
dec c
jr nz, .copyTilesetHeaderLoop
ld a, [hl]
- ld [$ffd7], a
+ ld [hTilesetType], a
xor a
ld [$ffd8], a
pop hl
@@ -3068,10 +3068,14 @@ DrawBadges: ; ea03 (3:6a03)
GymLeaderFaceAndBadgeTileGraphics: ; ea9e (3:6a9e)
INCBIN "gfx/badges.2bpp"
-Func_ee9e: ; ee9e (3:6e9e)
+; replaces a tile block with the one specified in [wNewTileBlockID]
+; and redraws the map view if necessary
+; b = Y
+; c = X
+ReplaceTileBlock: ; ee9e (3:6e9e)
call GetPredefRegisters
ld hl, wOverworldMap
- ld a, [W_CURMAPWIDTH] ; wd369
+ ld a, [W_CURMAPWIDTH]
add $6
ld e, a
ld d, $0
@@ -3083,21 +3087,22 @@ Func_ee9e: ; ee9e (3:6e9e)
ld e, a
ld a, b
and a
- jr z, .asm_eebb
-.asm_eeb7
+ jr z, .addX
+; add width * Y
+.addWidthYTimesLoop
add hl, de
dec b
- jr nz, .asm_eeb7
-.asm_eebb
- add hl, bc
- ld a, [wd09f]
+ jr nz, .addWidthYTimesLoop
+.addX
+ add hl, bc ; add X
+ ld a, [wNewTileBlockID]
ld [hl], a
ld a, [wCurrentTileBlockMapViewPointer]
ld c, a
ld a, [wCurrentTileBlockMapViewPointer + 1]
ld b, a
- call Func_ef4e
- ret c
+ call CompareHLWithBC
+ ret c ; return if the replaced tile block is below the map view in memory
push hl
ld l, e
ld h, $0
@@ -3108,27 +3113,27 @@ Func_ee9e: ; ee9e (3:6e9e)
add hl, de
add hl, bc
pop bc
- call Func_ef4e
- ret c
+ call CompareHLWithBC
+ ret c ; return if the replaced tile block is above the map view in memory
-Func_eedc: ; eedc (3:6edc)
+RedrawMapView: ; eedc (3:6edc)
ld a, [W_ISINBATTLE] ; W_ISINBATTLE
inc a
ret z
- ld a, [H_AUTOBGTRANSFERENABLED] ; $ffba
+ ld a, [H_AUTOBGTRANSFERENABLED]
push af
- ld a, [$ffd7]
+ ld a, [hTilesetType]
push af
xor a
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld [$ffd7], a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld [hTilesetType], a ; no flower/water BG tile animations
call LoadCurrentMapView
call GoPAL_SET_CF1C
- ld hl, wd526
+ ld hl, wMapViewVRAMPointer
ld a, [hli]
ld h, [hl]
ld l, a
- ld de, $ffc0
+ ld de, -2 * 32
add hl, de
ld a, h
and $3
@@ -3137,21 +3142,21 @@ Func_eedc: ; eedc (3:6edc)
ld [wHPBarMaxHP], a
ld a, h
ld [wHPBarMaxHP + 1], a
- ld a, $2
+ ld a, 2
ld [$ffbe], a
- ld c, $9
-.asm_ef0f
+ ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen)
+.redrawRowLoop
push bc
push hl
push hl
- ld hl, wOAMBuffer + $78
- ld de, $14
+ ld hl, wTileMap - 2 * 20
+ ld de, 20
ld a, [$ffbe]
.asm_ef1a
add hl, de
dec a
jr nz, .asm_ef1a
- call ScheduleRowRedrawHelper
+ call CopyToScreenEdgeTiles
pop hl
ld de, $20
ld a, [$ffbe]
@@ -3163,11 +3168,11 @@ Func_eedc: ; eedc (3:6edc)
or $98
dec c
jr nz, .asm_ef28
- ld [$ffd2], a
+ ld [H_SCREENEDGEREDRAWADDR + 1], a
ld a, l
- ld [H_SCREENEDGEREDRAWADDR], a ; $ffd1
- ld a, $2
- ld [H_SCREENEDGEREDRAW], a ; $ffd0
+ ld [H_SCREENEDGEREDRAWADDR], a
+ ld a, REDRAWROW
+ ld [H_SCREENEDGEREDRAW], a
call DelayFrame
ld hl, $ffbe
inc [hl]
@@ -3175,14 +3180,14 @@ Func_eedc: ; eedc (3:6edc)
pop hl
pop bc
dec c
- jr nz, .asm_ef0f
+ jr nz, .redrawRowLoop
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
pop af
- ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
+ ld [H_AUTOBGTRANSFERENABLED], a
ret
-Func_ef4e: ; ef4e (3:6f4e)
+CompareHLWithBC: ; ef4e (3:6f4e)
ld a, h
sub b
ret nz
@@ -3192,8 +3197,8 @@ Func_ef4e: ; ef4e (3:6f4e)
INCLUDE "engine/overworld/cut.asm"
-Func_f113: ; f113 (3:7113)
- ld a, [W_CURMAP] ; W_CURMAP
+MarkTownVisitedAndLoadMissableObjects: ; f113 (3:7113)
+ ld a, [W_CURMAP]
cp ROUTE_1
jr nc, .notInTown
ld c, a
@@ -3202,15 +3207,16 @@ Func_f113: ; f113 (3:7113)
predef FlagActionPredef
.notInTown
ld hl, MapHSPointers
- ld a, [W_CURMAP] ; W_CURMAP
+ ld a, [W_CURMAP]
ld b, $0
ld c, a
add hl, bc
add hl, bc
ld a, [hli] ; load missable objects pointer in hl
ld h, [hl]
+ ; fall through
-Func_f132: ; f132 (3:7132)
+LoadMissableObjects: ; f132 (3:7132)
ld l, a
push hl
ld de, MapHS00 ; calculate difference between out pointer and the base pointer
diff --git a/scripts/agatha.asm b/scripts/agatha.asm
index ca7c0ed8..a8f9e137 100755
--- a/scripts/agatha.asm
+++ b/scripts/agatha.asm
@@ -24,7 +24,7 @@ AgathaScript_76443: ; 76443 (1d:6443)
AgathaScript_76459: ; 76459 (1d:6459)
ld [wd09f], a
ld bc, $2
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
AgathaScript_76464: ; 76464 (1d:6464)
xor a
@@ -33,7 +33,7 @@ AgathaScript_76464: ; 76464 (1d:6464)
AgathaScriptPointers: ; 76469 (1d:6469)
dw AgathaScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw AgathaScript2
dw AgathaScript3
dw AgathaScript4
diff --git a/scripts/bruno.asm b/scripts/bruno.asm
index 553469d0..ffe05bce 100755
--- a/scripts/bruno.asm
+++ b/scripts/bruno.asm
@@ -24,7 +24,7 @@ BrunoScript_762ec: ; 762ec (1d:62ec)
BrunoScript_76302: ; 76302 (1d:6302)
ld [wd09f], a
ld bc, $2
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
BrunoScript_7630d: ; 7630d (1d:630d)
xor a
@@ -33,7 +33,7 @@ BrunoScript_7630d: ; 7630d (1d:630d)
BrunoScriptPointers: ; 76312 (1d:6312)
dw BrunoScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw BrunoScript2
dw BrunoScript3
dw BrunoScript4
diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm
index 87239910..e8d90a5a 100755
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -34,7 +34,7 @@ CeladonGameCornerScript_48bec: ; 48bec (12:4bec)
ld a, $2a
ld [wd09f], a
ld bc, $0208
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
CeladonGameCornerScript_48c07: ; 48c07 (12:4c07)
xor a
@@ -409,7 +409,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d)
set 7, [hl]
ld hl, CeladonGameCornerText_48ed3
ld de, CeladonGameCornerText_48ed3
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
@@ -449,7 +449,7 @@ CeladonGameCornerText12: ; 48edd (12:4edd)
ld a, $43
ld [wd09f], a
ld bc, $0208
- predef Func_ee9e
+ predef ReplaceTileBlock
jp TextScriptEnd
CeladonGameCornerText_48f09: ; 48f09 (12:4f09)
diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm
index 092bff88..b1b1060c 100755
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -31,7 +31,7 @@ CeladonGymText_48943: ; 48943 (12:4943)
CeladonGymScriptPointers: ; 4894e (12:494e)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw CeladonGymScript3
@@ -177,7 +177,7 @@ CeladonGymText1: ; 48a11 (12:4a11)
set 7, [hl]
ld hl, CeladonGymText_48a63
ld de, CeladonGymText_48a63
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm
index d97f9723..97824662 100755
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -133,7 +133,7 @@ CeruleanCityScript1: ; 19567 (6:5567)
set 7, [hl]
ld hl, CeruleanCityText_1966d
ld de, CeruleanCityText_19672
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY1 + $c8
ld [W_CUROPPONENT], a
@@ -277,7 +277,7 @@ CeruleanCityText2: ; 1967c (6:567c)
set 7, [hl]
ld hl, CeruleanCityText_196ee
ld de, CeruleanCityText_196ee
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, [$ff8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm
index ae6a40a0..079844f3 100755
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -31,7 +31,7 @@ CeruleanGymScript_5c6ed: ; 5c6ed (17:46ed)
CeruleanGymScriptPointers: ; 5c6f8 (17:46f8)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw CeruleanGymScript3
@@ -126,7 +126,7 @@ CeruleanGymText1: ; 5c771 (17:4771)
set 7, [hl]
ld hl, CeruleanGymText_5c7d8
ld de, CeruleanGymText_5c7d8
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm
index 65fd1db9..48133c52 100755
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -224,7 +224,7 @@ CinnabarGymText1: ; 758df (1d:58df)
call PrintText
ld hl, BlaineEndBattleText
ld de, BlaineEndBattleText
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, $7
ld [W_GYMLEADERNO], a
jp CinnabarGymScript_758b7
@@ -267,7 +267,7 @@ CinnabarGymText2: ; 75939 (1d:5939)
call PrintText
ld hl, CinnabarGymText_75964
ld de, CinnabarGymText_75964 ; $5964 XXX
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_46bb4 ; 0x75956
ld hl, CinnabarGymText_75969
@@ -296,7 +296,7 @@ CinnabarGymText3: ; 7596e (1d:596e)
call PrintText
ld hl, CinnabarGymText_75999
ld de, CinnabarGymText_75999 ; $5999 XXX
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_4b406 ; 0x7598b
ld hl, CinnabarGymText_7599e
@@ -325,7 +325,7 @@ CinnabarGymText4: ; 759a3 (1d:59a3)
call PrintText
ld hl, CinnabarGymText_759ce
ld de, CinnabarGymText_759ce ; $59ce XXX
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_c0673 ; 0x759c0
ld hl, CinnabarGymText_759d3
@@ -354,7 +354,7 @@ CinnabarGymText5: ; 759d8 (1d:59d8)
call PrintText
ld hl, CinnabarGymText_75a03
ld de, CinnabarGymText_75a03 ; $5a03 XXX
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_5cfd7 ; 0x759f5
ld hl, CinnabarGymText_75a08
@@ -383,7 +383,7 @@ CinnabarGymText6: ; 75a0d (1d:5a0d)
call PrintText
ld hl, CinnabarGymText_75a38
ld de, CinnabarGymText_75a38
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_776b4 ; 0x75a2a
ld hl, CinnabarGymText_75a3d
@@ -412,7 +412,7 @@ CinnabarGymText7: ; 75a42 (1d:5a42)
call PrintText
ld hl, CinnabarGymText_75a6d
ld de, CinnabarGymText_75a6d
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_2f755 ; 0x75a5f
ld hl, CinnabarGymText_75a72
@@ -441,7 +441,7 @@ CinnabarGymText8: ; 75a77 (1d:5a77)
call PrintText
ld hl, CinnabarGymText_75aa2
ld de, CinnabarGymText_75aa2 ; $5aa2 XXX
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp CinnabarGymScript_758b7
.asm_d87be ; 0x75a94
ld hl, CinnabarGymText_75aa7
diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm
index fb8d7b19..4a55347e 100755
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -16,7 +16,7 @@ FightingDojoScript_5cd70: ; 5cd70 (17:4d70)
FightingDojoScriptPointers: ; 5cd7b (17:4d7b)
dw FightingDojoScript1
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw FightingDojoScript3
@@ -147,7 +147,7 @@ FightingDojoText1: ; 5ce44 (17:4e44)
set 7, [hl]
ld hl, FightingDojoText_5ce93
ld de, FightingDojoText_5ce93
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm
index 14ffdfa9..43d977d7 100755
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -32,7 +32,7 @@ FuchsiaGymScript_75477: ; 75477 (1d:5477)
FuchsiaGymScriptPointers: ; 75482 (1d:5482)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw FuchsiaGymScript3
@@ -166,7 +166,7 @@ FuchsiaGymText1: ; 75534 (1d:5534)
set 7, [hl]
ld hl, UnnamedText_75586
ld de, UnnamedText_75586
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/gary.asm b/scripts/gary.asm
index b32e3595..fa331152 100755
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -63,7 +63,7 @@ GaryScript2: ; 75f6a (1d:5f6a)
set 7, [hl]
ld hl, GaryText_760f9
ld de, GaryText_760fe
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY3 + $c8
ld [W_CUROPPONENT], a
diff --git a/scripts/lance.asm b/scripts/lance.asm
index d5ca4e5c..f2523098 100755
--- a/scripts/lance.asm
+++ b/scripts/lance.asm
@@ -34,7 +34,7 @@ LanceScript_5a2de: ; 5a2de (16:62de)
ld bc, $603
LanceScript_5a2f0: ; 5a2f0 (16:62f0)
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
LanceScript_5a2f5: ; 5a2f5 (16:62f5)
xor a
@@ -43,7 +43,7 @@ LanceScript_5a2f5: ; 5a2f5 (16:62f5)
LanceScriptPointers: ; 5a2fa (16:62fa)
dw LanceScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw LanceScript2
dw LanceScript3
dw LanceScript4
diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm
index 33f419a3..ab769d94 100755
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -25,7 +25,7 @@ LoreleiScript_76191: ; 76191 (1d:6191)
.asm_761ab
ld [wd09f], a
ld bc, $2
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
LoreleiScript_761b6: ; 761b6 (1d:61b6)
xor a
@@ -34,7 +34,7 @@ LoreleiScript_761b6: ; 761b6 (1d:61b6)
LoreleiScriptPointers: ; 761bb (1d:61bb)
dw LoreleiScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw LoreleiScript2
dw LoreleiScript3
dw LoreleiScript4
diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm
index 7621897f..3e067a98 100755
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -43,7 +43,7 @@ Mansion1Script_4430b: ; 4430b (11:430b)
ld a, $e
ld [wd09f], a
asm_44310: ; 44310 (11:4310)
- predef Func_ee9e
+ predef ReplaceTileBlock
ret
Mansion1Script_Switches: ; 44316 (11:4316)
@@ -58,7 +58,7 @@ Mansion1Script_Switches: ; 44316 (11:4316)
Mansion1ScriptPointers: ; 44326 (11:4326)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion1TextPointers: ; 4432c (11:432c)
diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm
index 1b7a28a3..c643d229 100755
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -40,7 +40,7 @@ Mansion2Script_51fee: ; 51fee (14:5fee)
Mansion2Script_5202f: ; 5202f (14:602f)
ld [wd09f], a
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
Mansion2Script_Switches: ; 52037 (14:6037)
ld a, [wSpriteStateData1 + 9]
@@ -54,7 +54,7 @@ Mansion2Script_Switches: ; 52037 (14:6037)
Mansion2ScriptPointers: ; 52047 (14:6047)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion2TextPointers: ; 5204d (14:604d)
diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm
index 494fba13..6ad02dd9 100755
--- a/scripts/mansion3.asm
+++ b/scripts/mansion3.asm
@@ -34,7 +34,7 @@ Mansion3Script_52204: ; 52204 (14:6204)
Mansion3ScriptPointers: ; 52235 (14:6235)
dw Mansion3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion3Script0: ; 5223b (14:623b)
diff --git a/scripts/mansion4.asm b/scripts/mansion4.asm
index cfd78c5f..b89af5f2 100755
--- a/scripts/mansion4.asm
+++ b/scripts/mansion4.asm
@@ -56,7 +56,7 @@ Mansion4Script_Switches: ; 52420 (14:6420)
Mansion4ScriptPointers: ; 52430 (14:6430)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion4TextPointers: ; 52436 (14:6436)
diff --git a/scripts/mtmoon1.asm b/scripts/mtmoon1.asm
index 42f98d98..def597ba 100755
--- a/scripts/mtmoon1.asm
+++ b/scripts/mtmoon1.asm
@@ -9,7 +9,7 @@ MtMoon1Script: ; 499c8 (12:59c8)
MtMoon1ScriptPointers: ; 499db (12:59db)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
MtMoon1TextPointers: ; 499e1 (12:59e1)
diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm
index 71638409..f0124be0 100755
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -47,7 +47,7 @@ MtMoon3Script_49d58: ; 49d58 (12:5d58)
MtMoon3ScriptPointers: ; 49d63 (12:5d63)
dw MtMoon3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw MtMoon3Script3
dw MtMoon3Script4
@@ -228,7 +228,7 @@ MtMoon3Text1: ; 49e79 (12:5e79)
set 7, [hl]
ld hl, MtMoon3Text_49f8a
ld de, MtMoon3Text_49f8a
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm
index 8666d18e..574c6814 100755
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -378,7 +378,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
call GetSpritePosition1
ld hl, OaksLabText_1d3be
ld de, OaksLabText_1d3c3
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld hl, wd72d
set 6, [hl]
set 7, [hl]
diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm
index 0ab4c3a4..21d3fe74 100755
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -31,7 +31,7 @@ PewterGymScript_5c3bf: ; 5c3bf (17:43bf)
PewterGymScriptPointers: ; 5c3ca (17:43ca)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw PewterGymScript3
@@ -126,7 +126,7 @@ PewterGymText1: ; 5c44e (17:444e)
set 7, [hl]
ld hl, PewterGymText_5c4bc
ld de, PewterGymText_5c4bc
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm
index 38dd1bc5..3c9ec72d 100755
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -130,7 +130,7 @@ PokemonTower2Text1: ; 605df (18:45df)
set 7, [hl]
ld hl, PokemonTower2Text_60632
ld de, PokemonTower2Text_60637 ; XXX $4637
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY2 + $c8
ld [W_CUROPPONENT], a
diff --git a/scripts/pokemontower3.asm b/scripts/pokemontower3.asm
index f05623fb..8df5bfc5 100755
--- a/scripts/pokemontower3.asm
+++ b/scripts/pokemontower3.asm
@@ -9,7 +9,7 @@ PokemonTower3Script: ; 606cc (18:46cc)
PokemonTower3ScriptPointers: ; 606df (18:46df)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower3TextPointers: ; 606e5 (18:46e5)
diff --git a/scripts/pokemontower4.asm b/scripts/pokemontower4.asm
index e48b9681..760bb604 100755
--- a/scripts/pokemontower4.asm
+++ b/scripts/pokemontower4.asm
@@ -9,7 +9,7 @@ PokemonTower4Script: ; 607f6 (18:47f6)
PokemonTower4ScriptPointers: ; 60809 (18:4809)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower4TextPointers: ; 6080f (18:480f)
diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm
index 6dd694ac..b70f9e28 100755
--- a/scripts/pokemontower5.asm
+++ b/scripts/pokemontower5.asm
@@ -9,7 +9,7 @@ PokemonTower5Script: ; 60932 (18:4932)
PokemonTower5ScriptPointers: ; 60945 (18:4945)
dw PokemonTower5Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower5Script0: ; 6094b (18:494b)
diff --git a/scripts/pokemontower6.asm b/scripts/pokemontower6.asm
index 6320e2af..58968d17 100755
--- a/scripts/pokemontower6.asm
+++ b/scripts/pokemontower6.asm
@@ -16,7 +16,7 @@ PokemonTower6Script_60b02: ; 60b02 (18:4b02)
PokemonTower6ScriptPointers: ; 60b0d (18:4b0d)
dw PokemonTower6Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw PokemonTower6Script3
dw PokemonTower6Script4
diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm
index 6ebf15d5..cc736a08 100755
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -16,7 +16,7 @@ PokemonTower7Script_60d18: ; 60d18 (18:4d18)
PokemonTower7ScriptPointers: ; 60d23 (18:4d23)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw PokemonTower7Script2
dw PokemonTower7Script3
dw PokemonTower7Script4
diff --git a/scripts/powerplant.asm b/scripts/powerplant.asm
index b90ba7a1..ec4f89b3 100755
--- a/scripts/powerplant.asm
+++ b/scripts/powerplant.asm
@@ -9,7 +9,7 @@ PowerPlantScript: ; 1e2c6 (7:62c6)
PowerPlantScriptPointers: ; 1e2d9 (7:62d9)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PowerPlantTextPointers: ; 1e2df (7:62df)
diff --git a/scripts/rockethideout1.asm b/scripts/rockethideout1.asm
index 43e4fd26..499f77ef 100755
--- a/scripts/rockethideout1.asm
+++ b/scripts/rockethideout1.asm
@@ -30,11 +30,11 @@ RocketHideout1Script_44be0: ; 44be0 (11:4be0)
.asm_44c03
ld [wd09f], a
ld bc, $080c
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
RocketHideout1ScriptPointers: ; 44c0e (11:4c0e)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RocketHideout1TextPointers: ; 44c14 (11:4c14)
diff --git a/scripts/rockethideout2.asm b/scripts/rockethideout2.asm
index 326c1605..99754658 100755
--- a/scripts/rockethideout2.asm
+++ b/scripts/rockethideout2.asm
@@ -9,7 +9,7 @@ RocketHideout2Script: ; 44e27 (11:4e27)
RocketHideout2ScriptPointers: ; 44e3a (11:4e3a)
dw RocketHideout2Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout2Script3
@@ -19,7 +19,7 @@ RocketHideout2Script0: ; 44e42 (11:4e42)
ld a, [W_XCOORD]
ld c, a
ld hl, RocketHideout2ArrowTilePlayerMovement
- call Func_3442
+ call DecodeArrowMovementRLE
cp $ff
jp z, CheckFightingMapTrainers
ld hl, wd736
diff --git a/scripts/rockethideout3.asm b/scripts/rockethideout3.asm
index 3870c6b6..6dc467ab 100755
--- a/scripts/rockethideout3.asm
+++ b/scripts/rockethideout3.asm
@@ -9,7 +9,7 @@ RocketHideout3Script: ; 45225 (11:5225)
RocketHideout3ScriptPointers: ; 45238 (11:5238)
dw RocketHideout3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout3Script3
@@ -19,7 +19,7 @@ RocketHideout3Script0: ; 45240 (11:5240)
ld a, [W_XCOORD]
ld c, a
ld hl, RocketHideout3ArrowTilePlayerMovement
- call Func_3442
+ call DecodeArrowMovementRLE
cp $ff
jp z, CheckFightingMapTrainers
ld hl, wd736
diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm
index ddac941a..097512c3 100755
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -31,7 +31,7 @@ RocketHideout4Script_45473: ; 45473 (11:5473)
.asm_45498
ld [wd09f], a
ld bc, $050c
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
RocketHideout4Script_454a3: ; 454a3 (11:54a3)
xor a
@@ -42,7 +42,7 @@ RocketHideout4Script_454a3: ; 454a3 (11:54a3)
RocketHideout4ScriptPointers: ; 454ae (11:54ae)c
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout4Script3
@@ -130,7 +130,7 @@ RocketHideout4Text1: ; 4553a (11:553a)
set 7, [hl]
ld hl, RocketHideout4Text_4557f
ld de, RocketHideout4Text_4557f
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/rocktunnel1.asm b/scripts/rocktunnel1.asm
index ad6e493f..1d514a05 100755
--- a/scripts/rocktunnel1.asm
+++ b/scripts/rocktunnel1.asm
@@ -9,7 +9,7 @@ RockTunnel1Script: ; 444dc (11:44dc)
RockTunnel1ScriptPointers: ; 444ef (11:44ef)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RockTunnel1TextPointers: ; 444f5 (11:44f5)
diff --git a/scripts/rocktunnel2.asm b/scripts/rocktunnel2.asm
index a35a7325..98b804a7 100755
--- a/scripts/rocktunnel2.asm
+++ b/scripts/rocktunnel2.asm
@@ -9,7 +9,7 @@ RockTunnel2Script: ; 45feb (11:5feb)
RockTunnel2ScriptPointers: ; 45ffe (11:5ffe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RockTunnel2TextPointers: ; 46004 (11:6004)
diff --git a/scripts/route10.asm b/scripts/route10.asm
index e5e0dec2..c587b1df 100755
--- a/scripts/route10.asm
+++ b/scripts/route10.asm
@@ -9,7 +9,7 @@ Route10Script: ; 59336 (16:5336)
Route10ScriptPointers: ; 59349 (16:5349)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route10TextPointers: ; 5934f (16:534f)
diff --git a/scripts/route11.asm b/scripts/route11.asm
index fb50937e..629a6efd 100755
--- a/scripts/route11.asm
+++ b/scripts/route11.asm
@@ -9,7 +9,7 @@ Route11Script: ; 5944c (16:544c)
Route11ScriptPointers: ; 5945f (16:545f)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route11TextPointers: ; 59465 (16:5465)
diff --git a/scripts/route12.asm b/scripts/route12.asm
index 04b86207..a38f6b83 100755
--- a/scripts/route12.asm
+++ b/scripts/route12.asm
@@ -16,7 +16,7 @@ Route12Script_59606: ; 59606 (16:5606)
Route12ScriptPointers: ; 59611 (16:5611)
dw Route12Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route12Script3
diff --git a/scripts/route13.asm b/scripts/route13.asm
index b78b7cb2..21862dfc 100755
--- a/scripts/route13.asm
+++ b/scripts/route13.asm
@@ -9,7 +9,7 @@ Route13Script: ; 5581e (15:581e)
Route13ScriptPointers: ; 55831 (15:5831)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route13TextPointers: ; 55837 (15:5837)
diff --git a/scripts/route14.asm b/scripts/route14.asm
index 9d8d8fcb..d430f858 100755
--- a/scripts/route14.asm
+++ b/scripts/route14.asm
@@ -9,7 +9,7 @@ Route14Script: ; 559d3 (15:59d3)
Route14ScriptPointers: ; 559e6 (15:59e6)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route14TextPointers: ; 559ec (15:59ec)
diff --git a/scripts/route15.asm b/scripts/route15.asm
index 789ace21..733d4a1c 100755
--- a/scripts/route15.asm
+++ b/scripts/route15.asm
@@ -9,7 +9,7 @@ Route15Script: ; 597ae (16:57ae)
Route15ScriptPointers: ; 597c1 (16:57c1)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route15TextPointers: ; 597c7 (16:57c7)
diff --git a/scripts/route16.asm b/scripts/route16.asm
index 2e60d77b..59f8cb24 100755
--- a/scripts/route16.asm
+++ b/scripts/route16.asm
@@ -16,7 +16,7 @@ Route16Script_59946: ; 59946 (16:5946)
Route16ScriptPointers: ; 59951 (16:5951)
dw Route16Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route16Script3
diff --git a/scripts/route17.asm b/scripts/route17.asm
index 78ceb2ae..ffd00634 100755
--- a/scripts/route17.asm
+++ b/scripts/route17.asm
@@ -9,7 +9,7 @@ Route17Script: ; 55b7a (15:5b7a)
Route17ScriptPointers: ; 55b8d (15:5b8d)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route17TextPointers: ; 55b93 (15:5b93)
diff --git a/scripts/route18.asm b/scripts/route18.asm
index a0e4487a..de2fe19a 100755
--- a/scripts/route18.asm
+++ b/scripts/route18.asm
@@ -9,7 +9,7 @@ Route18Script: ; 59ac7 (16:5ac7)
Route18ScriptPointers: ; 59ada (16:5ada)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route18TextPointers: ; 59ae0 (16:5ae0)
diff --git a/scripts/route19.asm b/scripts/route19.asm
index 6c749b03..40c7aeb3 100755
--- a/scripts/route19.asm
+++ b/scripts/route19.asm
@@ -9,7 +9,7 @@ Route19Script: ; 55d44 (15:5d44)
Route19ScriptPointers: ; 55d57 (15:5d57)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route19TextPointers: ; 55d5d (15:5d5d)
diff --git a/scripts/route20.asm b/scripts/route20.asm
index 7e8df3da..47edf376 100755
--- a/scripts/route20.asm
+++ b/scripts/route20.asm
@@ -58,7 +58,7 @@ Route20Script_50d14: ; 50d14 (14:4d14)
Route20ScriptPointers: ; 50d1c (14:4d1c)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route20TextPointers: ; 50d22 (14:4d22)
diff --git a/scripts/route21.asm b/scripts/route21.asm
index 034282f8..de2046dc 100755
--- a/scripts/route21.asm
+++ b/scripts/route21.asm
@@ -9,7 +9,7 @@ Route21Script: ; 55eeb (15:5eeb)
Route21ScriptPointers: ; 55efe (15:5efe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route21TextPointers: ; 55f04 (15:5f04)
diff --git a/scripts/route22.asm b/scripts/route22.asm
index 667edd65..233d42c3 100755
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -128,7 +128,7 @@ Route22Script1: ; 50f62 (14:4f62)
set 7, [hl]
ld hl, Route22RivalDefeatedText1
ld de, Route22Text_511bc
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY1 + $c8
ld [W_CUROPPONENT], a
ld hl, StarterMons_50faf ; $4faf
@@ -270,7 +270,7 @@ Route22Script4: ; 51087 (14:5087)
set 7, [hl]
ld hl, Route22RivalDefeatedText2 ; $51cb
ld de, Route22Text_511d0 ; $51d0
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY2 + $c8
ld [W_CUROPPONENT], a ; wd059
ld hl, StarterMons_510d9 ; $50d9
diff --git a/scripts/route24.asm b/scripts/route24.asm
index ea48053b..6916cbe7 100755
--- a/scripts/route24.asm
+++ b/scripts/route24.asm
@@ -16,7 +16,7 @@ Route24Script_513c0: ; 513c0 (14:53c0)
Route24ScriptPointers: ; 513cb (14:53cb)
dw Route24Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route24Script3
dw Route24Script4
@@ -169,7 +169,7 @@ Route24Text1: ; 514a4 (14:54a4)
set 7, [hl]
ld hl, Route24Text_5152b
ld de, Route24Text_5152b
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, [$ff8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/route25.asm b/scripts/route25.asm
index 088be3a2..720259ca 100755
--- a/scripts/route25.asm
+++ b/scripts/route25.asm
@@ -38,7 +38,7 @@ Route25Script_515e1: ; 515e1 (14:55e1)
Route25ScriptPointers: ; 51622 (14:5622)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route25TextPointers: ; 51628 (14:5628)
diff --git a/scripts/route3.asm b/scripts/route3.asm
index 5cd35fd9..acb2afce 100755
--- a/scripts/route3.asm
+++ b/scripts/route3.asm
@@ -9,7 +9,7 @@ Route3Script: ; 554f8 (15:54f8)
Route3ScriptPointers: ; 5550b (15:550b)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route3TextPointers: ; 55511 (15:5511)
diff --git a/scripts/route4.asm b/scripts/route4.asm
index fa234590..5eafb4f7 100755
--- a/scripts/route4.asm
+++ b/scripts/route4.asm
@@ -9,7 +9,7 @@ Route4Script: ; 55658 (15:5658)
Route4ScriptPointers: ; 5566b (15:566b)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route4TextPointers: ; 55671 (15:5671)
diff --git a/scripts/route6.asm b/scripts/route6.asm
index 018c1b80..ee6258cd 100755
--- a/scripts/route6.asm
+++ b/scripts/route6.asm
@@ -9,7 +9,7 @@ Route6Script: ; 590b0 (16:50b0)
Route6ScriptPointers: ; 590c3 (16:50c3)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route6TextPointers: ; 590c9 (16:50c9)
diff --git a/scripts/route8.asm b/scripts/route8.asm
index bf41b5ae..eed57c7b 100755
--- a/scripts/route8.asm
+++ b/scripts/route8.asm
@@ -9,7 +9,7 @@ Route8Script: ; 591b6 (16:51b6)
Route8ScriptPointers: ; 591c9 (16:51c9)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route8TextPointers: ; 591cf (16:51cf)
diff --git a/scripts/route9.asm b/scripts/route9.asm
index f14abef8..77b216c6 100755
--- a/scripts/route9.asm
+++ b/scripts/route9.asm
@@ -9,7 +9,7 @@ Route9Script: ; 556bc (15:56bc)
Route9ScriptPointers: ; 556cf (15:56cf)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route9TextPointers: ; 556d5 (15:56d5)
diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm
index 39f4df10..7c2eb559 100755
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -31,7 +31,7 @@ SaffronGymText_5d048: ; 5d048 (17:5048)
SaffronGymScriptPointers: ; 5d053 (17:5053)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SaffronGymScript3
@@ -178,7 +178,7 @@ SaffronGymText1: ; 5d118 (17:5118)
set 7, [hl]
ld hl, SaffronGymText_5d167
ld de, SaffronGymText_5d167
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/silphco10.asm b/scripts/silphco10.asm
index c831655f..7d044aca 100755
--- a/scripts/silphco10.asm
+++ b/scripts/silphco10.asm
@@ -22,7 +22,7 @@ SilphCo10Script_5a14f: ; 5a14f (16:614f)
ld a, $54
ld [wd09f], a
ld bc, $405
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_5a173: ; 5a173 (16:6173)
db $04,$05,$FF
@@ -37,7 +37,7 @@ SilphCo10Text_5a176: ; 5a176 (16:6176)
SilphCo10ScriptPointers: ; 5a180 (16:6180)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo10TextPointers: ; 5a186 (16:6186)
diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm
index 32a455ec..43ae72f6 100755
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -22,14 +22,14 @@ SilphCo11Script_62110: ; 62110 (18:6110)
ld a, $20
ld [wd09f], a
ld bc, $603
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_62134: ; 62134 (18:6134)
db $06,$03,$FF
SilphCo11Script_62137: ; 62137 (18:6137)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -53,7 +53,7 @@ SilphCo11Script_62137: ; 62137 (18:6137)
ld a, [hli]
cp c
jr nz, .asm_62143
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -116,7 +116,7 @@ SilphCo11Script_621c8: ; 621c8 (18:61c8)
SilphCo11ScriptPointers: ; 621cf (18:61cf)
dw SilphCo11Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SilphCo11Script3
dw SilphCo11Script4
@@ -221,7 +221,7 @@ SilphCo11Script4: ; 62293 (18:6293)
set 7, [hl]
ld hl, SilphCo10Text_62330 ; $6330
ld de, SilphCo10Text_62330 ; $6330
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/silphco2.asm b/scripts/silphco2.asm
index 20d689e6..63803acd 100755
--- a/scripts/silphco2.asm
+++ b/scripts/silphco2.asm
@@ -23,7 +23,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07)
ld a, $54
ld [wd09f], a
ld bc, $0202
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_59d2e
bit 6, a
@@ -31,14 +31,14 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07)
ld a, $54
ld [wd09f], a
ld bc, $0502
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_59d3e: ; 59d3e (16:5d3e)
db $02,$02,$05,$02,$FF
SilphCo2Script_59d43: ; 59d43 (16:5d43)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -62,7 +62,7 @@ SilphCo2Script_59d43: ; 59d43 (16:5d43)
ld a, [hli]
cp c
jr nz, .asm_59d4f
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -87,7 +87,7 @@ SilphCo2Script_59d6f: ; 59d6f (16:5d6f)
SilphCo2ScriptPointers: ; 59d80 (16:5d80)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo2TextPointers: ; 59d86 (16:5d86)
diff --git a/scripts/silphco3.asm b/scripts/silphco3.asm
index 5527d923..7b0c67c1 100755
--- a/scripts/silphco3.asm
+++ b/scripts/silphco3.asm
@@ -23,7 +23,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71)
ld a, $5f
ld [wd09f], a
ld bc, $404
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_59f98
bit 1, a
@@ -31,7 +31,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71)
ld a, $5f
ld [wd09f], a
ld bc, $408
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_59fa8: ; 59fa8 (16:5fa8)
db $04,$04,$04,$08,$FF
@@ -51,7 +51,7 @@ SilphCo3Script_59fad: ; 59fad (16:5fad)
SilphCo3ScriptPointers: ; 59fbe (16:5fbe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo3TextPointers: ; 59fc4 (16:5fc4)
diff --git a/scripts/silphco4.asm b/scripts/silphco4.asm
index 718077ce..15a46dd3 100755
--- a/scripts/silphco4.asm
+++ b/scripts/silphco4.asm
@@ -23,7 +23,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21)
ld a, $54
ld [wd09f], a
ld bc, $0602
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_19d48
bit 1, a
@@ -31,14 +31,14 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21)
ld a, $54
ld [wd09f], a
ld bc, $0406
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
SilphCo4Data19d58: ; 19d58 (6:5d58)
db $06, $02, $04, $06, $ff
SilphCo4Script_19d5d: ; 19d5d (6:5d5d)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -62,7 +62,7 @@ SilphCo4Script_19d5d: ; 19d5d (6:5d5d)
ld a, [hli]
cp c
jr nz, .asm_19d69 ; 0x19d7c $eb
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -87,7 +87,7 @@ SilphCo4Script_19d89: ; 19d89 (6:5d89)
SilphCo4ScriptPointers: ; 19d9a (6:5d9a)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo4TextPointers: ; 19da0 (6:5da0)
diff --git a/scripts/silphco5.asm b/scripts/silphco5.asm
index 709af20b..0b63708b 100755
--- a/scripts/silphco5.asm
+++ b/scripts/silphco5.asm
@@ -23,7 +23,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
ld a, $5f
ld [wd09f], a
ld bc, $0203
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_19f74
bit 1, a
@@ -32,7 +32,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
ld a, $5f
ld [wd09f], a
ld bc, $0603
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_19f87
bit 2, a
@@ -40,7 +40,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d)
ld a, $5f
ld [wd09f], a
ld bc, $0507
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
SilphCo5Coords: ; 19f97 (6:5f97) ; coords?
db $02, $03, $06, $03, $05, $07, $ff
@@ -65,7 +65,7 @@ SilphCo5Script_19f9e: ; 19f9e (6:5f9e)
SilphCo5ScriptPointers: ; 19fb6 (6:5fb6)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo5TextPointers: ; 19fbc (6:5fbc)
diff --git a/scripts/silphco6.asm b/scripts/silphco6.asm
index 4a9477c6..137e31be 100755
--- a/scripts/silphco6.asm
+++ b/scripts/silphco6.asm
@@ -22,7 +22,7 @@ SilphCo6Script_1a1bf: ; 1a1bf (6:61bf)
ld a, $5f
ld [wd09f], a
ld bc, $0602
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
SilphCo6Coords1: ; 1a1e3 (6:61e3)
db $06, $02
@@ -38,7 +38,7 @@ SilphCo6Script_1a1e6: ; 1a1e6 (6:61e6)
SilphCo6ScriptPointers: ; 1a1f0 (6:61f0)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo6TextPointers: ; 1a1f6 (6:61f6)
diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm
index fff1246e..2fc3c51a 100755
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -23,7 +23,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
ld a, $54
ld [wd09f], a
ld bc, $305
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_51b9e
bit 5, a
@@ -32,7 +32,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
ld a, $54
ld [wd09f], a
ld bc, $20a
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_51bb1
bit 6, a
@@ -40,14 +40,14 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77)
ld a, $54
ld [wd09f], a
ld bc, $60a
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_51bc1: ; 51bc1 (14:5bc1)
db $03,$05,$02,$0A,$06,$0A,$FF
SilphCo7Text_51bc8: ; 51bc8 (14:5bc8)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -71,7 +71,7 @@ SilphCo7Text_51bc8: ; 51bc8 (14:5bc8)
ld a, [hli]
cp c
jr nz, .asm_51bd4
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -110,7 +110,7 @@ SilphCo7Text_51c10: ; 51c10 (14:5c10)
SilphCo7ScriptPointers: ; 51c17 (14:5c17)
dw SilphCo7Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SilphCo7Script3
dw SilphCo7Script4
@@ -177,7 +177,7 @@ SilphCo7Script3: ; 51c82 (14:5c82)
set 7, [hl]
ld hl, SilphCo7Text14 ; $5ec8
ld de, SilphCo7Text_51ecd ; $5ecd
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY2 + $c8
ld [W_CUROPPONENT], a ; wd059
ld a, [W_RIVALSTARTER] ; wd715
diff --git a/scripts/silphco8.asm b/scripts/silphco8.asm
index cc508e61..ebca9b95 100755
--- a/scripts/silphco8.asm
+++ b/scripts/silphco8.asm
@@ -22,14 +22,14 @@ SilphCo8Script_5651a: ; 5651a (15:651a)
ld a, $5f
ld [wd09f], a
ld bc, $403
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_5653e: ; 5653e (15:653e)
db $04,$03,$FF
SilphCo8Script_56541: ; 56541 (15:6541)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -53,7 +53,7 @@ SilphCo8Script_56541: ; 56541 (15:6541)
ld a, [hli]
cp c
jr nz, .asm_5654d
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -73,7 +73,7 @@ SilphCo8Script_5656d: ; 5656d (15:656d)
SilphCo8ScriptPointers: ; 56577 (15:6577)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo8TextPointers: ; 5657d (15:657d)
diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm
index 44059b56..e8b16927 100755
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -23,7 +23,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
ld a, $5f
ld [wd09f], a
ld bc, $401
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_5d7f8
bit 1, a
@@ -32,7 +32,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
ld a, $54
ld [wd09f], a
ld bc, $209
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_5d80b
bit 2, a
@@ -41,7 +41,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
ld a, $54
ld [wd09f], a
ld bc, $509
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_5d81e
bit 3, a
@@ -49,14 +49,14 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1)
ld a, $5f
ld [wd09f], a
ld bc, $605
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
DataTable_5d82e: ; 5d82e (17:582e)
db $04,$01,$02,$09,$05,$09,$06,$05,$FF
SilphCo9Script_5d837: ; 5d837 (17:5837)
push hl
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
ld a, [hli]
ld b, a
ld a, [hl]
@@ -80,7 +80,7 @@ SilphCo9Script_5d837: ; 5d837 (17:5837)
ld a, [hli]
cp c
jr nz, .asm_5d843
- ld hl, wd73f
+ ld hl, wCardKeyDoorY
xor a
ld [hli], a
ld [hl], a
@@ -117,7 +117,7 @@ SilphCo9Script_5d863: ; 5d863 (17:5863)
SilphCo9ScriptPointers: ; 5d885 (17:5885)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo9TextPointers: ; 5d88b (17:588b)
diff --git a/scripts/ssanne10.asm b/scripts/ssanne10.asm
index 60eb28f2..8f3ff9a4 100755
--- a/scripts/ssanne10.asm
+++ b/scripts/ssanne10.asm
@@ -9,7 +9,7 @@ SSAnne10Script: ; 61d55 (18:5d55)
SSAnne10ScriptPointers: ; 61d68 (18:5d68)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne10TextPointers: ; 61d6e (18:5d6e)
diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm
index 50deba65..c5943a54 100755
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -186,7 +186,7 @@ SSAnne2Text2: ; 614e6 (18:54e6)
set 7, [hl]
ld hl, SSAnneRivalDefeatedText
ld de, SSAnneRivalWonText
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp TextScriptEnd
SSAnneRivalBeforeBattleText: ; 61500 (18:5500)
diff --git a/scripts/ssanne5.asm b/scripts/ssanne5.asm
index ea7ff282..96b94c52 100755
--- a/scripts/ssanne5.asm
+++ b/scripts/ssanne5.asm
@@ -9,7 +9,7 @@ SSAnne5Script: ; 616ae (18:56ae)
SSAnne5ScriptPointers: ; 616c1 (18:56c1)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne5TextPointers: ; 616c7 (18:56c7)
diff --git a/scripts/ssanne8.asm b/scripts/ssanne8.asm
index a2abb4bb..ff7fc57b 100755
--- a/scripts/ssanne8.asm
+++ b/scripts/ssanne8.asm
@@ -9,7 +9,7 @@ SSAnne8Script: ; 61976 (18:5976)
SSAnne8ScriptPointers: ; 61989 (18:5989)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne8TextPointers: ; 6198f (18:598f)
diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm
index f25d5532..db34fcf2 100755
--- a/scripts/ssanne9.asm
+++ b/scripts/ssanne9.asm
@@ -12,7 +12,7 @@ SSAnne9Script: ; 61b4b (18:5b4b)
SSAnne9ScriptPointers: ; 61b64 (18:5b64)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne9TextPointers: ; 61b6a (18:5b6a)
diff --git a/scripts/unknowndungeon3.asm b/scripts/unknowndungeon3.asm
index 2ca624a8..d2078916 100755
--- a/scripts/unknowndungeon3.asm
+++ b/scripts/unknowndungeon3.asm
@@ -9,7 +9,7 @@ UnknownDungeon3Script: ; 45ef0 (11:5ef0)
UnknownDungeon3ScriptPointers: ; 45f03 (11:5f03)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
UnknownDungeon3TextPointers: ; 45f09 (11:5f09)
diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm
index 6ed2d23d..dca1c66c 100755
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -66,7 +66,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b)
ld [$ff49], a
ld a, $58
ld [wTrainerEngageDistance], a
- ld hl, wd526
+ ld hl, wMapViewVRAMPointer
ld c, [hl]
inc hl
ld b, [hl]
@@ -82,9 +82,9 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b)
ld hl, $0002
add hl, bc
ld a, l
- ld [wd526], a
+ ld [wMapViewVRAMPointer], a
ld a, h
- ld [wd527], a
+ ld [wMapViewVRAMPointer + 1], a
push hl
push de
call ScheduleEastColumnRedraw
diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm
index 685bd2cb..6178dafb 100755
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -40,7 +40,7 @@ VermilionGymScript_5ca6d: ; 5ca6d (17:4a6d)
.asm_5ca7f
ld [wd09f], a
ld bc, $202
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a)
xor a
@@ -51,7 +51,7 @@ VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a)
VermilionGymScriptPointers: ; 5ca95 (17:4a95)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw VermilionGymScript3
@@ -156,7 +156,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d)
set 7, [hl]
ld hl, ReceivedThunderbadgeText
ld de, ReceivedThunderbadgeText
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/scripts/victoryroad1.asm b/scripts/victoryroad1.asm
index cebd8070..b6d2bf3e 100755
--- a/scripts/victoryroad1.asm
+++ b/scripts/victoryroad1.asm
@@ -17,11 +17,11 @@ VictoryRoad1Script: ; 5da0a (17:5a0a)
ld a, $1d
ld [wd09f], a
ld bc, $604
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
VictoryRoad1ScriptPointers: ; 5da3a (17:5a3a)
dw VictoryRoad1Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
VictoryRoad1Script0: ; 5da40 (17:5a40)
diff --git a/scripts/victoryroad2.asm b/scripts/victoryroad2.asm
index cf52e3a3..4aab61ca 100755
--- a/scripts/victoryroad2.asm
+++ b/scripts/victoryroad2.asm
@@ -36,12 +36,12 @@ VictoryRoad2Script_517c9: ; 517c9 (14:57c9)
VictoryRoad2Script_517e2: ; 517e2 (14:57e2)
ld [wd09f], a
- predef Func_ee9e
+ predef ReplaceTileBlock
ret
VictoryRoad2ScriptPointers: ; 517eb (14:57eb)
dw VictoryRoad2Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
VictoryRoad2Script0: ; 517f1 (14:57f1)
diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm
index e7d5ed12..99926498 100755
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -19,11 +19,11 @@ VictoryRoad3Script_44996: ; 44996 (11:4996)
ld a, $1d
ld [wd09f], a
ld bc, $503
- predef_jump Func_ee9e
+ predef_jump ReplaceTileBlock
VictoryRoad3ScriptPointers: ; 449b1 (11:49b1)
dw VictoryRoad3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
VictoryRoad3Script0: ; 449b7 (11:49b7)
diff --git a/scripts/viridianforest.asm b/scripts/viridianforest.asm
index 3744fc78..4ec1c0aa 100755
--- a/scripts/viridianforest.asm
+++ b/scripts/viridianforest.asm
@@ -9,7 +9,7 @@ ViridianForestScript: ; 6110d (18:510d)
ViridianForestScriptPointers: ; 61120 (18:5120)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
ViridianForestTextPointers: ; 61126 (18:5126)
diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm
index 6b0673d1..3aa23b43 100755
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -24,7 +24,7 @@ ViridianGymScript_748d6: ; 748d6 (1d:48d6)
ViridianGymScriptPointers: ; 748e1 (1d:48e1)
dw ViridianGymScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw ViridianGymScript3
dw ViridianGymScript4
@@ -35,7 +35,7 @@ ViridianGymScript0: ; 748eb (1d:48eb)
ld a, [W_XCOORD] ; wd362
ld c, a
ld hl, ViridianGymArrowTilePlayerMovement
- call Func_3442
+ call DecodeArrowMovementRLE
cp $ff
jp z, CheckFightingMapTrainers
call StartSimulatingJoypadStates
@@ -305,7 +305,7 @@ ViridianGymText1: ; 74a69 (1d:4a69)
set 7, [hl]
ld hl, ViridianGymText_74ad3
ld de, ViridianGymText_74ad3
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
diff --git a/wram.asm b/wram.asm
index a9bad081..15c339d1 100755
--- a/wram.asm
+++ b/wram.asm
@@ -500,15 +500,18 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
ds 1
+wChangeBoxSavedMapTextPointer:: ; cd3d
+
wFlyAnimUsingCoordList:: ; cd3d
wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d
wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d
+wHiddenObjectFunctionArgument:: ; cd3d
+
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
-; ds 1
wTrainerSpriteOffset:: ; cd3d
ds 1
@@ -519,6 +522,8 @@ wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e
wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e
+wHiddenObjectFunctionRomBank:: ; cd3e
+
wTrainerEngageDistance:: ; cd3e
ds 1
@@ -528,14 +533,21 @@ wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f
wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f
+wHiddenObjectIndex:: ; cd3f
+
wTrainerFacingDirection:: ; cd3f
wcd3f::
ds 1
wPlayerSpinInPlaceAnimSoundID:: ; cd40
+wHiddenObjectY:: ; cd40
+
wTrainerScreenY:: ; cd40
ds 1
+
+wHiddenObjectX:: ; cd40
+
wTrainerScreenX:: ; cd41
ds 1
@@ -992,6 +1004,8 @@ W_NUMFBTILES:: ; d089
wd08a:: ds 1
+wTownMapSpriteBlinkingCounter:: ; d08b
+
W_SUBANIMTRANSFORM:: ; d08b
; controls what transformations are applied to the subanimation
; 01: flip horizontally and vertically
@@ -1000,18 +1014,15 @@ W_SUBANIMTRANSFORM:: ; d08b
; 04: reverse the subanimation
ds 1
-W_PBSTOREDREGISTERH:: ; d08c
- ds 1
-W_PBSTOREDREGISTERL:: ; d08d
- ds 1
-W_PBSTOREDREGISTERD:: ; d08e
- ds 1
-W_PBSTOREDREGISTERE:: ; d08f
- ds 1
+wEndBattleWinTextPointer:: ; d08c
+ ds 2
+
+wEndBattleLoseTextPointer:: ; d08e
+ ds 2
ds 2
-W_PBSTOREDROMBANK:: ; d092
+wEndBattleTextRomBank:: ; d092
ds 1
ds 1
@@ -1026,6 +1037,11 @@ W_SUBANIMSUBENTRYADDR:: ; d096
ds 2
wd09a:: ds 1
+
+wTownMapSpriteBlinkingEnabled:: ; d09b
+; non-zero when enabled. causes nest locations to blink on and off.
+; the town selection cursor will blink regardless of what this value is
+
wd09b:: ds 1
W_FBDESTADDR:: ; d09c
@@ -1044,6 +1060,8 @@ W_FBMODE:: ; d09e
; contain the upper and lower bit of each of the 8 pixels, respectively
ds 1
+wNewTileBlockID:: ; d09f
+
wd09f:: ds 1
wd0a0:: ds 1
@@ -1200,7 +1218,11 @@ wd131:: ds 1
wd132:: ds 1
wd133:: ds 6
wd139:: ds 1
-wd13a:: ds 1
+
+wIgnoreInputCounter:: ; d13a
+; counts downward each frame
+; when it hits 0, bit 5 (ignore input bit) of wd730 is reset
+ ds 1
wStepCounter:: ; d13b
; counts down once every step
@@ -1458,8 +1480,11 @@ W_MAPSPRITEEXTRADATA:: ; d504
wd524:: ds 1
wd525:: ds 1
-wd526:: ds 1
-wd527:: ds 1
+
+wMapViewVRAMPointer:: ; d526
+; the address of the upper left corner of the visible portion of the BG tile map in VRAM
+ ds 2
+
wd528:: ds 1
wd529:: ds 1
wd52a:: ds 1
@@ -1816,6 +1841,9 @@ wd72d:: ds 1
wd72e:: ds 2
wd730::
+; bit 0: NPC sprite being moved by script
+; bit 5: ignore joypad input
+; bit 6: print text with no delay between each letter
; bit 7: set if joypad states are being simulated in the overworld
ds 1
@@ -1844,6 +1872,7 @@ 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 1: the player is currently stepping down from a door
; bit 2: standing on a warp
; bit 6: jumping down a ledge
ds 1
@@ -1851,8 +1880,15 @@ wd736:: ; d736
wd737:: ds 4
wd73b:: ds 1
wd73c:: ds 3
-wd73f:: ds 1
-wd740:: ds 3
+
+wCardKeyDoorY:: ; d73f
+ ds 1
+
+wCardKeyDoorX:: ; d740
+ ds 1
+
+ ds 2
+
wd743:: ds 1
wd744:: ds 3
wd747:: ds 3
@@ -2028,7 +2064,8 @@ W_PLAYTIMESECONDS:: ; da44
W_PLAYTIMEFRAMES:: ; da45
ds 1
-wda46:: ds 1
+wSafariZoneGameOver:: ; da46
+ ds 1
W_NUMSAFARIBALLS:: ; da47
ds 1