ref: 2ed65d9c3e3ba60939ebe2928ffddc06a90b1876
parent: 0c916aea3353ed1bf2750be403b0da9ea0b922d4
author: YamaArashi <shadow962@live.com>
date: Sun Sep 14 07:29:18 EDT 2014
Commented/labelled misc functions
--- a/constants/hardware_constants.asm
+++ b/constants/hardware_constants.asm
@@ -2,26 +2,16 @@
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
--- 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
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -136,7 +136,7 @@
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 @@
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 @@
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 @@
pop af
ld [wMapPalOffset], a
ld a, [wd0d4]
- ld [$ffd7], a
+ ld [hTilesetType], a
scf
ret
.emptyString
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -572,7 +572,7 @@
dec a
ld [wDestinationWarpID], a
call LoadMapData
- callba Func_c335
+ callba ClearVariablesAfterLoadingMapData
pop hl
pop af
ld [hl], a
--- a/engine/evolution.asm
+++ b/engine/evolution.asm
@@ -19,7 +19,7 @@
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a ; $ffba
- ld [$ffd7], a
+ ld [hTilesetType], a
ld a, [wHPBarMaxHP]
ld [wcf1d], a
ld c, $0
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -11,7 +11,7 @@
; 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 @@
pop bc
pop hl
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
ld a, [W_ISLINKBATTLE]
cp $32
ret z
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -19,7 +19,7 @@
call FillMemory
xor a
ld [wUpdateSpritesEnabled], a
- ld [$ffd7], a
+ ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wd358], a
ld [wTrainerScreenY], a
--- a/engine/hidden_object_functions18.asm
+++ b/engine/hidden_object_functions18.asm
@@ -70,7 +70,7 @@
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
--- 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 @@
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)
--- a/engine/hidden_object_functions7.asm
+++ b/engine/hidden_object_functions7.asm
@@ -60,7 +60,7 @@
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 @@
ld hl, wd790
set 6, [hl]
ld a, $1
- ld [wda46], a
+ ld [wSafariZoneGameOver], a
ret
PrintSafariGameOverText: ; 1e9ed (7:69ed)
@@ -291,7 +291,7 @@
.asm_1eb38
pop bc
ld [wd09f], a
- predef Func_ee9e
+ predef ReplaceTileBlock
ld hl, $ffdb
dec [hl]
jr nz, .asm_1eb0e
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -138,7 +138,7 @@
callab EvolveTradeMon
call ClearScreen
call Func_71ca2
- callba Func_eedc
+ callba RedrawMapView
and a
ld a,$3
jr .asm_ee803 ; 0x71c9b $1
--- a/engine/menu/bills_pc.asm
+++ b/engine/menu/bills_pc.asm
@@ -332,7 +332,7 @@
jp Func_214e8
Func_216b3: ; 216b3 (8:56b3)
- callba Func_738a1
+ callba ChangeBox
jp Func_214e8
Func_216be: ; 216be (8:56be)
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -6,10 +6,10 @@
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 @@
jr nz, .first
.second
pop af
- ld [$ffD7], a
+ ld [hTilesetType], a
pop af
ld [wUpdateSpritesEnabled], a
pop hl
--- a/engine/menu/pokedex.asm
+++ b/engine/menu/pokedex.asm
@@ -404,10 +404,10 @@
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 @@
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
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -500,10 +500,10 @@
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 @@
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
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -36,10 +36,10 @@
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 @@
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 @@
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 @@
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
- ld [$ffd7], a
+ ld [hTilesetType], a
ld hl, wd72c
res 1, [hl]
ld a, $77
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -52,7 +52,7 @@
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
--- a/engine/overworld/card_key.asm
+++ b/engine/overworld/card_key.asm
@@ -2,18 +2,18 @@
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 @@
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 @@
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
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -56,7 +56,7 @@
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 @@
ld a, $90
ld [hVBlankWY], a
call UpdateSprites
- jp Func_eedc
+ jp RedrawMapView
UsedCutText: ; eff2 (3:6ff2)
TX_FAR _UsedCutText
--- a/engine/overworld/elevator.asm
+++ b/engine/overworld/elevator.asm
@@ -41,7 +41,7 @@
jp PlayDefaultMusic
Func_7bf64: ; 7bf64 (1e:7f64)
- ld hl, wd527
+ ld hl, wMapViewVRAMPointer + 1
ld a, [hld]
push af
ld a, [hl]
--- a/engine/overworld/hidden_objects.asm
+++ b/engine/overworld/hidden_objects.asm
@@ -6,7 +6,7 @@
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 @@
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 @@
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
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -260,12 +260,11 @@
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 @@
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)
--- 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 @@
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 @@
.asm_18e40
dec a
.asm_18e41
- ld [wd13a], a
+ ld [wIgnoreInputCounter], a
and a
ret nz
ld a, [wd730]
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -58,7 +58,7 @@
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 @@
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 @@
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
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -32,11 +32,11 @@
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,10 +58,10 @@
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
@@ -68,20 +68,20 @@
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 @@
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 @@
SAVGoodChecksum: ; 736f8 (1c:76f8)
ld a, $0
- ld [$6000], a
- ld [$0], a
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
ret
Func_73701: ; 0x73701
@@ -193,28 +193,28 @@
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
@@ -221,20 +221,20 @@
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
@@ -241,19 +241,19 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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_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 @@
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 @@
cp h
.next
ld a,$00
- ld [$6000],a
+ ld [MBC1SRamBankingMode],a
ld [$0000],a
ret
@@ -653,23 +653,23 @@
; 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 @@
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
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -26,7 +26,7 @@
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
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -64,7 +64,7 @@
ld bc, $10
call CopyData
.asm_70ec8
- call Func_716c6
+ call TownMapSpriteBlinkingAnimation
call JoypadLowSensitivity
ld a, [$ffb5]
ld b, a
@@ -77,9 +77,9 @@
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 @@
set 7, [hl]
.asm_71037
xor a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOutWithDelay3
pop hl
pop af
@@ -319,9 +319,9 @@
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 @@
Func_711ab: ; 711ab (1c:51ab)
xor a
- ld [wd09b], a
+ ld [wTownMapSpriteBlinkingEnabled], a
call GBPalWhiteOut
call ClearScreen
call ClearSprites
@@ -570,29 +570,30 @@
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
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -475,7 +475,7 @@
Func_414ae: ; 414ae (10:54ae)
push hl
hlCoord 0, 4
- call ScheduleRowRedrawHelper
+ call CopyToScreenEdgeTiles
pop hl
ld a, h
ld [H_SCREENEDGEREDRAWADDR + 1], a
--- a/home.asm
+++ b/home.asm
@@ -86,11 +86,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
pop hl
pop af
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
ret
FarCopyDataDouble::
@@ -957,7 +957,7 @@
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 @@
jr nz,.loop
pop af
ld [H_LOADEDROMBANK],a
- ld [MBC3RomBank],a
+ ld [MBC1RomBank],a
ret
CopyVideoData::
@@ -988,7 +988,7 @@
ld a, b
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ld a, e
ld [H_VBCOPYSRC], a
@@ -1010,7 +1010,7 @@
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 @@
ld a, b
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
ld a, e
ld [H_VBCOPYDOUBLESRC], a
@@ -1059,7 +1059,7 @@
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 @@
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 @@
ld hl, _EndNPCMovementScript
jp Bankswitch
-Func_3156:: ; 3156 (0:3156)
+EmptyFunc2:: ; 3156 (0:3156)
ret
; stores hl in [W_TRAINERHEADERPTR]
@@ -2831,7 +2833,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,7 +3322,7 @@
; 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
@@ -3320,7 +3329,7 @@
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 @@
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 @@
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,52 +5154,54 @@
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]
@@ -5197,18 +5208,18 @@
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
--- a/home/init.asm
+++ b/home/init.asm
@@ -61,11 +61,11 @@
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
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -10,7 +10,7 @@
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,7 +20,7 @@
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]
@@ -27,7 +27,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
.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 @@
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 @@
dec a
jr z, .ridingBike
- ld a, [$ffd7]
+ ld a, [hTilesetType]
and a
jr nz, .determineGraphics
jr .startWalking
@@ -1058,11 +1058,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,7 +1489,7 @@
sub a,$02
and a,$1f
or d
- ld [wd526],a
+ ld [wMapViewVRAMPointer],a
jr .adjustXCoordWithinBlock
.checkIfMovingSouth
ld a,b
@@ -1496,29 +1496,29 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
; 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 @@
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 @@
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
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -29,7 +29,7 @@
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 @@
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 @@
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 @@
ld a, [wd122]
ld [H_LOADEDROMBANK], a
- ld [MBC3RomBank], a
+ ld [MBC1RomBank], a
pop hl
pop de
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -376,9 +376,9 @@
; 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 @@
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
--- a/hram.asm
+++ b/hram.asm
@@ -17,6 +17,9 @@
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
@@ -119,6 +122,12 @@
; So, by setting it to a nonzero value and waiting for it to become 0 again,
; 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
--- a/macros.asm
+++ b/macros.asm
@@ -16,11 +16,11 @@
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
--- a/main.asm
+++ b/main.asm
@@ -2021,12 +2021,12 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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,7 +3207,7 @@
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
@@ -3209,8 +3214,9 @@
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
--- a/scripts/agatha.asm
+++ b/scripts/agatha.asm
@@ -24,7 +24,7 @@
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 @@
AgathaScriptPointers: ; 76469 (1d:6469)
dw AgathaScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw AgathaScript2
dw AgathaScript3
dw AgathaScript4
--- a/scripts/bruno.asm
+++ b/scripts/bruno.asm
@@ -24,7 +24,7 @@
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 @@
BrunoScriptPointers: ; 76312 (1d:6312)
dw BrunoScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw BrunoScript2
dw BrunoScript3
dw BrunoScript4
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -34,7 +34,7 @@
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 @@
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 @@
ld a, $43
ld [wd09f], a
ld bc, $0208
- predef Func_ee9e
+ predef ReplaceTileBlock
jp TextScriptEnd
CeladonGameCornerText_48f09: ; 48f09 (12:4f09)
--- a/scripts/celadongym.asm
+++ b/scripts/celadongym.asm
@@ -31,7 +31,7 @@
CeladonGymScriptPointers: ; 4894e (12:494e)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw CeladonGymScript3
@@ -177,7 +177,7 @@
set 7, [hl]
ld hl, CeladonGymText_48a63
ld de, CeladonGymText_48a63
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/ceruleancity.asm
+++ b/scripts/ceruleancity.asm
@@ -133,7 +133,7 @@
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 @@
set 7, [hl]
ld hl, CeruleanCityText_196ee
ld de, CeruleanCityText_196ee
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, [$ff8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/ceruleangym.asm
+++ b/scripts/ceruleangym.asm
@@ -31,7 +31,7 @@
CeruleanGymScriptPointers: ; 5c6f8 (17:46f8)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw CeruleanGymScript3
@@ -126,7 +126,7 @@
set 7, [hl]
ld hl, CeruleanGymText_5c7d8
ld de, CeruleanGymText_5c7d8
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/cinnabargym.asm
+++ b/scripts/cinnabargym.asm
@@ -224,7 +224,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/scripts/fightingdojo.asm
+++ b/scripts/fightingdojo.asm
@@ -16,7 +16,7 @@
FightingDojoScriptPointers: ; 5cd7b (17:4d7b)
dw FightingDojoScript1
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw FightingDojoScript3
@@ -147,7 +147,7 @@
set 7, [hl]
ld hl, FightingDojoText_5ce93
ld de, FightingDojoText_5ce93
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/fuchsiagym.asm
+++ b/scripts/fuchsiagym.asm
@@ -32,7 +32,7 @@
FuchsiaGymScriptPointers: ; 75482 (1d:5482)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw FuchsiaGymScript3
@@ -166,7 +166,7 @@
set 7, [hl]
ld hl, UnnamedText_75586
ld de, UnnamedText_75586
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/gary.asm
+++ b/scripts/gary.asm
@@ -63,7 +63,7 @@
set 7, [hl]
ld hl, GaryText_760f9
ld de, GaryText_760fe
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, SONY3 + $c8
ld [W_CUROPPONENT], a
--- a/scripts/lance.asm
+++ b/scripts/lance.asm
@@ -34,7 +34,7 @@
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 @@
LanceScriptPointers: ; 5a2fa (16:62fa)
dw LanceScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw LanceScript2
dw LanceScript3
dw LanceScript4
--- a/scripts/lorelei.asm
+++ b/scripts/lorelei.asm
@@ -25,7 +25,7 @@
.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 @@
LoreleiScriptPointers: ; 761bb (1d:61bb)
dw LoreleiScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw LoreleiScript2
dw LoreleiScript3
dw LoreleiScript4
--- a/scripts/mansion1.asm
+++ b/scripts/mansion1.asm
@@ -43,7 +43,7 @@
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 @@
Mansion1ScriptPointers: ; 44326 (11:4326)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion1TextPointers: ; 4432c (11:432c)
--- a/scripts/mansion2.asm
+++ b/scripts/mansion2.asm
@@ -40,7 +40,7 @@
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 @@
Mansion2ScriptPointers: ; 52047 (14:6047)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion2TextPointers: ; 5204d (14:604d)
--- a/scripts/mansion3.asm
+++ b/scripts/mansion3.asm
@@ -34,7 +34,7 @@
Mansion3ScriptPointers: ; 52235 (14:6235)
dw Mansion3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion3Script0: ; 5223b (14:623b)
--- a/scripts/mansion4.asm
+++ b/scripts/mansion4.asm
@@ -56,7 +56,7 @@
Mansion4ScriptPointers: ; 52430 (14:6430)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Mansion4TextPointers: ; 52436 (14:6436)
--- a/scripts/mtmoon1.asm
+++ b/scripts/mtmoon1.asm
@@ -9,7 +9,7 @@
MtMoon1ScriptPointers: ; 499db (12:59db)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
MtMoon1TextPointers: ; 499e1 (12:59e1)
--- a/scripts/mtmoon3.asm
+++ b/scripts/mtmoon3.asm
@@ -47,7 +47,7 @@
MtMoon3ScriptPointers: ; 49d63 (12:5d63)
dw MtMoon3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw MtMoon3Script3
dw MtMoon3Script4
@@ -228,7 +228,7 @@
set 7, [hl]
ld hl, MtMoon3Text_49f8a
ld de, MtMoon3Text_49f8a
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/oakslab.asm
+++ b/scripts/oakslab.asm
@@ -378,7 +378,7 @@
call GetSpritePosition1
ld hl, OaksLabText_1d3be
ld de, OaksLabText_1d3c3
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld hl, wd72d
set 6, [hl]
set 7, [hl]
--- a/scripts/pewtergym.asm
+++ b/scripts/pewtergym.asm
@@ -31,7 +31,7 @@
PewterGymScriptPointers: ; 5c3ca (17:43ca)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw PewterGymScript3
@@ -126,7 +126,7 @@
set 7, [hl]
ld hl, PewterGymText_5c4bc
ld de, PewterGymText_5c4bc
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/pokemontower2.asm
+++ b/scripts/pokemontower2.asm
@@ -130,7 +130,7 @@
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
--- a/scripts/pokemontower3.asm
+++ b/scripts/pokemontower3.asm
@@ -9,7 +9,7 @@
PokemonTower3ScriptPointers: ; 606df (18:46df)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower3TextPointers: ; 606e5 (18:46e5)
--- a/scripts/pokemontower4.asm
+++ b/scripts/pokemontower4.asm
@@ -9,7 +9,7 @@
PokemonTower4ScriptPointers: ; 60809 (18:4809)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower4TextPointers: ; 6080f (18:480f)
--- a/scripts/pokemontower5.asm
+++ b/scripts/pokemontower5.asm
@@ -9,7 +9,7 @@
PokemonTower5ScriptPointers: ; 60945 (18:4945)
dw PokemonTower5Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PokemonTower5Script0: ; 6094b (18:494b)
--- a/scripts/pokemontower6.asm
+++ b/scripts/pokemontower6.asm
@@ -16,7 +16,7 @@
PokemonTower6ScriptPointers: ; 60b0d (18:4b0d)
dw PokemonTower6Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw PokemonTower6Script3
dw PokemonTower6Script4
--- a/scripts/pokemontower7.asm
+++ b/scripts/pokemontower7.asm
@@ -16,7 +16,7 @@
PokemonTower7ScriptPointers: ; 60d23 (18:4d23)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw PokemonTower7Script2
dw PokemonTower7Script3
dw PokemonTower7Script4
--- a/scripts/powerplant.asm
+++ b/scripts/powerplant.asm
@@ -9,7 +9,7 @@
PowerPlantScriptPointers: ; 1e2d9 (7:62d9)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
PowerPlantTextPointers: ; 1e2df (7:62df)
--- a/scripts/rockethideout1.asm
+++ b/scripts/rockethideout1.asm
@@ -30,11 +30,11 @@
.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)
--- a/scripts/rockethideout2.asm
+++ b/scripts/rockethideout2.asm
@@ -9,7 +9,7 @@
RocketHideout2ScriptPointers: ; 44e3a (11:4e3a)
dw RocketHideout2Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout2Script3
@@ -19,7 +19,7 @@
ld a, [W_XCOORD]
ld c, a
ld hl, RocketHideout2ArrowTilePlayerMovement
- call Func_3442
+ call DecodeArrowMovementRLE
cp $ff
jp z, CheckFightingMapTrainers
ld hl, wd736
--- a/scripts/rockethideout3.asm
+++ b/scripts/rockethideout3.asm
@@ -9,7 +9,7 @@
RocketHideout3ScriptPointers: ; 45238 (11:5238)
dw RocketHideout3Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout3Script3
@@ -19,7 +19,7 @@
ld a, [W_XCOORD]
ld c, a
ld hl, RocketHideout3ArrowTilePlayerMovement
- call Func_3442
+ call DecodeArrowMovementRLE
cp $ff
jp z, CheckFightingMapTrainers
ld hl, wd736
--- a/scripts/rockethideout4.asm
+++ b/scripts/rockethideout4.asm
@@ -31,7 +31,7 @@
.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 @@
RocketHideout4ScriptPointers: ; 454ae (11:54ae)c
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw RocketHideout4Script3
@@ -130,7 +130,7 @@
set 7, [hl]
ld hl, RocketHideout4Text_4557f
ld de, RocketHideout4Text_4557f
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/rocktunnel1.asm
+++ b/scripts/rocktunnel1.asm
@@ -9,7 +9,7 @@
RockTunnel1ScriptPointers: ; 444ef (11:44ef)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RockTunnel1TextPointers: ; 444f5 (11:44f5)
--- a/scripts/rocktunnel2.asm
+++ b/scripts/rocktunnel2.asm
@@ -9,7 +9,7 @@
RockTunnel2ScriptPointers: ; 45ffe (11:5ffe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
RockTunnel2TextPointers: ; 46004 (11:6004)
--- a/scripts/route10.asm
+++ b/scripts/route10.asm
@@ -9,7 +9,7 @@
Route10ScriptPointers: ; 59349 (16:5349)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route10TextPointers: ; 5934f (16:534f)
--- a/scripts/route11.asm
+++ b/scripts/route11.asm
@@ -9,7 +9,7 @@
Route11ScriptPointers: ; 5945f (16:545f)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route11TextPointers: ; 59465 (16:5465)
--- a/scripts/route12.asm
+++ b/scripts/route12.asm
@@ -16,7 +16,7 @@
Route12ScriptPointers: ; 59611 (16:5611)
dw Route12Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route12Script3
--- a/scripts/route13.asm
+++ b/scripts/route13.asm
@@ -9,7 +9,7 @@
Route13ScriptPointers: ; 55831 (15:5831)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route13TextPointers: ; 55837 (15:5837)
--- a/scripts/route14.asm
+++ b/scripts/route14.asm
@@ -9,7 +9,7 @@
Route14ScriptPointers: ; 559e6 (15:59e6)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route14TextPointers: ; 559ec (15:59ec)
--- a/scripts/route15.asm
+++ b/scripts/route15.asm
@@ -9,7 +9,7 @@
Route15ScriptPointers: ; 597c1 (16:57c1)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route15TextPointers: ; 597c7 (16:57c7)
--- a/scripts/route16.asm
+++ b/scripts/route16.asm
@@ -16,7 +16,7 @@
Route16ScriptPointers: ; 59951 (16:5951)
dw Route16Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route16Script3
--- a/scripts/route17.asm
+++ b/scripts/route17.asm
@@ -9,7 +9,7 @@
Route17ScriptPointers: ; 55b8d (15:5b8d)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route17TextPointers: ; 55b93 (15:5b93)
--- a/scripts/route18.asm
+++ b/scripts/route18.asm
@@ -9,7 +9,7 @@
Route18ScriptPointers: ; 59ada (16:5ada)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route18TextPointers: ; 59ae0 (16:5ae0)
--- a/scripts/route19.asm
+++ b/scripts/route19.asm
@@ -9,7 +9,7 @@
Route19ScriptPointers: ; 55d57 (15:5d57)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route19TextPointers: ; 55d5d (15:5d5d)
--- a/scripts/route20.asm
+++ b/scripts/route20.asm
@@ -58,7 +58,7 @@
Route20ScriptPointers: ; 50d1c (14:4d1c)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route20TextPointers: ; 50d22 (14:4d22)
--- a/scripts/route21.asm
+++ b/scripts/route21.asm
@@ -9,7 +9,7 @@
Route21ScriptPointers: ; 55efe (15:5efe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route21TextPointers: ; 55f04 (15:5f04)
--- a/scripts/route22.asm
+++ b/scripts/route22.asm
@@ -128,7 +128,7 @@
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 @@
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
--- a/scripts/route24.asm
+++ b/scripts/route24.asm
@@ -16,7 +16,7 @@
Route24ScriptPointers: ; 513cb (14:53cb)
dw Route24Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw Route24Script3
dw Route24Script4
@@ -169,7 +169,7 @@
set 7, [hl]
ld hl, Route24Text_5152b
ld de, Route24Text_5152b
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ld a, [$ff8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/route25.asm
+++ b/scripts/route25.asm
@@ -38,7 +38,7 @@
Route25ScriptPointers: ; 51622 (14:5622)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route25TextPointers: ; 51628 (14:5628)
--- a/scripts/route3.asm
+++ b/scripts/route3.asm
@@ -9,7 +9,7 @@
Route3ScriptPointers: ; 5550b (15:550b)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route3TextPointers: ; 55511 (15:5511)
--- a/scripts/route4.asm
+++ b/scripts/route4.asm
@@ -9,7 +9,7 @@
Route4ScriptPointers: ; 5566b (15:566b)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route4TextPointers: ; 55671 (15:5671)
--- a/scripts/route6.asm
+++ b/scripts/route6.asm
@@ -9,7 +9,7 @@
Route6ScriptPointers: ; 590c3 (16:50c3)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route6TextPointers: ; 590c9 (16:50c9)
--- a/scripts/route8.asm
+++ b/scripts/route8.asm
@@ -9,7 +9,7 @@
Route8ScriptPointers: ; 591c9 (16:51c9)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route8TextPointers: ; 591cf (16:51cf)
--- a/scripts/route9.asm
+++ b/scripts/route9.asm
@@ -9,7 +9,7 @@
Route9ScriptPointers: ; 556cf (15:56cf)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
Route9TextPointers: ; 556d5 (15:56d5)
--- a/scripts/saffrongym.asm
+++ b/scripts/saffrongym.asm
@@ -31,7 +31,7 @@
SaffronGymScriptPointers: ; 5d053 (17:5053)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SaffronGymScript3
@@ -178,7 +178,7 @@
set 7, [hl]
ld hl, SaffronGymText_5d167
ld de, SaffronGymText_5d167
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/silphco10.asm
+++ b/scripts/silphco10.asm
@@ -22,7 +22,7 @@
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 @@
SilphCo10ScriptPointers: ; 5a180 (16:6180)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo10TextPointers: ; 5a186 (16:6186)
--- a/scripts/silphco11.asm
+++ b/scripts/silphco11.asm
@@ -22,7 +22,7 @@
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
@@ -29,7 +29,7 @@
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 @@
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 @@
SilphCo11ScriptPointers: ; 621cf (18:61cf)
dw SilphCo11Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SilphCo11Script3
dw SilphCo11Script4
@@ -221,7 +221,7 @@
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
--- a/scripts/silphco2.asm
+++ b/scripts/silphco2.asm
@@ -23,7 +23,7 @@
ld a, $54
ld [wd09f], a
ld bc, $0202
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_59d2e
bit 6, a
@@ -31,7 +31,7 @@
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
@@ -38,7 +38,7 @@
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 @@
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 @@
SilphCo2ScriptPointers: ; 59d80 (16:5d80)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo2TextPointers: ; 59d86 (16:5d86)
--- a/scripts/silphco3.asm
+++ b/scripts/silphco3.asm
@@ -23,7 +23,7 @@
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 @@
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 @@
SilphCo3ScriptPointers: ; 59fbe (16:5fbe)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo3TextPointers: ; 59fc4 (16:5fc4)
--- a/scripts/silphco4.asm
+++ b/scripts/silphco4.asm
@@ -23,7 +23,7 @@
ld a, $54
ld [wd09f], a
ld bc, $0602
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_19d48
bit 1, a
@@ -31,7 +31,7 @@
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
@@ -38,7 +38,7 @@
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 @@
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 @@
SilphCo4ScriptPointers: ; 19d9a (6:5d9a)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo4TextPointers: ; 19da0 (6:5da0)
--- a/scripts/silphco5.asm
+++ b/scripts/silphco5.asm
@@ -23,7 +23,7 @@
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 @@
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 @@
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 @@
SilphCo5ScriptPointers: ; 19fb6 (6:5fb6)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo5TextPointers: ; 19fbc (6:5fbc)
--- a/scripts/silphco6.asm
+++ b/scripts/silphco6.asm
@@ -22,7 +22,7 @@
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 @@
SilphCo6ScriptPointers: ; 1a1f0 (6:61f0)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo6TextPointers: ; 1a1f6 (6:61f6)
--- a/scripts/silphco7.asm
+++ b/scripts/silphco7.asm
@@ -23,7 +23,7 @@
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 @@
ld a, $54
ld [wd09f], a
ld bc, $20a
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_51bb1
bit 6, a
@@ -40,7 +40,7 @@
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
@@ -47,7 +47,7 @@
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 @@
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 @@
SilphCo7ScriptPointers: ; 51c17 (14:5c17)
dw SilphCo7Script0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw SilphCo7Script3
dw SilphCo7Script4
@@ -177,7 +177,7 @@
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
--- a/scripts/silphco8.asm
+++ b/scripts/silphco8.asm
@@ -22,7 +22,7 @@
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
@@ -29,7 +29,7 @@
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 @@
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 @@
SilphCo8ScriptPointers: ; 56577 (15:6577)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo8TextPointers: ; 5657d (15:657d)
--- a/scripts/silphco9.asm
+++ b/scripts/silphco9.asm
@@ -23,7 +23,7 @@
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 @@
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 @@
ld a, $54
ld [wd09f], a
ld bc, $509
- predef Func_ee9e
+ predef ReplaceTileBlock
pop af
.asm_5d81e
bit 3, a
@@ -49,7 +49,7 @@
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
@@ -56,7 +56,7 @@
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 @@
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 @@
SilphCo9ScriptPointers: ; 5d885 (17:5885)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SilphCo9TextPointers: ; 5d88b (17:588b)
--- a/scripts/ssanne10.asm
+++ b/scripts/ssanne10.asm
@@ -9,7 +9,7 @@
SSAnne10ScriptPointers: ; 61d68 (18:5d68)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne10TextPointers: ; 61d6e (18:5d6e)
--- a/scripts/ssanne2.asm
+++ b/scripts/ssanne2.asm
@@ -186,7 +186,7 @@
set 7, [hl]
ld hl, SSAnneRivalDefeatedText
ld de, SSAnneRivalWonText
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
jp TextScriptEnd
SSAnneRivalBeforeBattleText: ; 61500 (18:5500)
--- a/scripts/ssanne5.asm
+++ b/scripts/ssanne5.asm
@@ -9,7 +9,7 @@
SSAnne5ScriptPointers: ; 616c1 (18:56c1)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne5TextPointers: ; 616c7 (18:56c7)
--- a/scripts/ssanne8.asm
+++ b/scripts/ssanne8.asm
@@ -9,7 +9,7 @@
SSAnne8ScriptPointers: ; 61989 (18:5989)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne8TextPointers: ; 6198f (18:598f)
--- a/scripts/ssanne9.asm
+++ b/scripts/ssanne9.asm
@@ -12,7 +12,7 @@
SSAnne9ScriptPointers: ; 61b64 (18:5b64)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
SSAnne9TextPointers: ; 61b6a (18:5b6a)
--- a/scripts/unknowndungeon3.asm
+++ b/scripts/unknowndungeon3.asm
@@ -9,7 +9,7 @@
UnknownDungeon3ScriptPointers: ; 45f03 (11:5f03)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
UnknownDungeon3TextPointers: ; 45f09 (11:5f09)
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -66,7 +66,7 @@
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 @@
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
--- a/scripts/vermiliongym.asm
+++ b/scripts/vermiliongym.asm
@@ -40,7 +40,7 @@
.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 @@
VermilionGymScriptPointers: ; 5ca95 (17:4a95)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw VermilionGymScript3
@@ -156,7 +156,7 @@
set 7, [hl]
ld hl, ReceivedThunderbadgeText
ld de, ReceivedThunderbadgeText
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/scripts/victoryroad1.asm
+++ b/scripts/victoryroad1.asm
@@ -17,11 +17,11 @@
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)
--- a/scripts/victoryroad2.asm
+++ b/scripts/victoryroad2.asm
@@ -36,12 +36,12 @@
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)
--- a/scripts/victoryroad3.asm
+++ b/scripts/victoryroad3.asm
@@ -19,11 +19,11 @@
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)
--- a/scripts/viridianforest.asm
+++ b/scripts/viridianforest.asm
@@ -9,7 +9,7 @@
ViridianForestScriptPointers: ; 61120 (18:5120)
dw CheckFightingMapTrainers
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
ViridianForestTextPointers: ; 61126 (18:5126)
--- a/scripts/viridiangym.asm
+++ b/scripts/viridiangym.asm
@@ -24,7 +24,7 @@
ViridianGymScriptPointers: ; 748e1 (1d:48e1)
dw ViridianGymScript0
- dw Func_324c
+ dw DisplayEnemyTrainerTextAndStartBattle
dw EndTrainerBattle
dw ViridianGymScript3
dw ViridianGymScript4
@@ -35,7 +35,7 @@
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 @@
set 7, [hl]
ld hl, ViridianGymText_74ad3
ld de, ViridianGymText_74ad3
- call PreBattleSaveRegisters
+ call SaveEndBattleTextPointers
ldh a, [$8c]
ld [wSpriteIndex], a
call EngageMapTrainer
--- a/wram.asm
+++ b/wram.asm
@@ -500,6 +500,8 @@
ds 1
+wChangeBoxSavedMapTextPointer:: ; cd3d
+
wFlyAnimUsingCoordList:: ; cd3d
wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d
@@ -506,9 +508,10 @@
wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d
+wHiddenObjectFunctionArgument:: ; cd3d
+
wWhichTrade:: ; cd3d
; which entry from TradeMons to select
-; ds 1
wTrainerSpriteOffset:: ; cd3d
ds 1
@@ -519,6 +522,8 @@
wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e
+wHiddenObjectFunctionRomBank:: ; cd3e
+
wTrainerEngageDistance:: ; cd3e
ds 1
@@ -528,6 +533,8 @@
wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f
+wHiddenObjectIndex:: ; cd3f
+
wTrainerFacingDirection:: ; cd3f
wcd3f::
ds 1
@@ -534,8 +541,13 @@
wPlayerSpinInPlaceAnimSoundID:: ; cd40
+wHiddenObjectY:: ; cd40
+
wTrainerScreenY:: ; cd40
ds 1
+
+wHiddenObjectX:: ; cd40
+
wTrainerScreenX:: ; cd41
ds 1
@@ -992,6 +1004,8 @@
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 @@
; 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
-W_PBSTOREDROMBANK:: ; d092
+ ds 2
+
+wEndBattleTextRomBank:: ; d092
ds 1
ds 1
@@ -1026,6 +1037,11 @@
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 @@
; contain the upper and lower bit of each of the 8 pixels, respectively
ds 1
+wNewTileBlockID:: ; d09f
+
wd09f:: ds 1
wd0a0:: ds 1
@@ -1200,8 +1218,12 @@
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
ds 1
@@ -1458,8 +1480,11 @@
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 @@
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 @@
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 @@
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_PLAYTIMEFRAMES:: ; da45
ds 1
-wda46:: ds 1
+wSafariZoneGameOver:: ; da46
+ ds 1
W_NUMSAFARIBALLS:: ; da47
ds 1