aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarishma-gb <194818981+Narishma-gb@users.noreply.github.com>2025-09-03 17:56:09 +0200
committerGitHub <noreply@github.com>2025-09-03 11:56:09 -0400
commit4d2594cb24b7e67cde4e1373c9a2b5e0ae7ff473 (patch)
tree5bd4fce0a314171b46b3962a5db5df6eb5154ee2
parentDocument where badge and elevator floor "items" are used (diff)
downloadpokeyellow-4d2594cb24b7e67cde4e1373c9a2b5e0ae7ff473.tar.gz
pokeyellow-4d2594cb24b7e67cde4e1373c9a2b5e0ae7ff473.tar.xz
pokeyellow-4d2594cb24b7e67cde4e1373c9a2b5e0ae7ff473.zip
Label and constant cleanup (#528)
* Label cleanup, add some constants instead of raw numbers * Rename load/save game functions to be more explicit
-rw-r--r--constants/ram_constants.asm4
-rw-r--r--data/maps/objects/Route2Gate.asm4
-rw-r--r--data/predef_pointers.asm12
-rw-r--r--engine/battle/core.asm48
-rw-r--r--engine/battle/effects.asm12
-rw-r--r--engine/events/give_pokemon.asm2
-rw-r--r--engine/events/prize_menu.asm12
-rw-r--r--engine/gfx/palettes.asm10
-rw-r--r--engine/link/cable_club.asm2
-rw-r--r--engine/link/cable_club_npc.asm2
-rw-r--r--engine/menus/display_text_id_init.asm2
-rw-r--r--engine/menus/main_menu.asm5
-rw-r--r--engine/menus/save.asm201
-rw-r--r--engine/menus/start_sub_menus.asm36
-rw-r--r--engine/movie/hall_of_fame.asm2
-rw-r--r--engine/movie/oak_speech/clear_save.asm2
-rw-r--r--engine/movie/title.asm2
-rw-r--r--engine/movie/trade.asm12
-rw-r--r--engine/overworld/missable_objects.asm3
-rw-r--r--engine/pokemon/bills_pc.asm5
-rw-r--r--engine/pokemon/status_screen.asm2
-rw-r--r--home/init.asm13
-rw-r--r--home/map_objects.asm10
-rw-r--r--home/overworld.asm2
-rw-r--r--home/text_script.asm4
-rw-r--r--home/vcopy.asm4
-rw-r--r--scripts/HallOfFame.asm2
-rw-r--r--scripts/PokemonMansionB1F.asm16
-rw-r--r--scripts/SeafoamIslandsB4F.asm2
-rw-r--r--scripts/VermilionDock.asm2
30 files changed, 221 insertions, 214 deletions
diff --git a/constants/ram_constants.asm b/constants/ram_constants.asm
index 756aaa68..cc794133 100644
--- a/constants/ram_constants.asm
+++ b/constants/ram_constants.asm
@@ -49,6 +49,7 @@ DEF BIT_NO_PREVIOUS_MAP EQU 7
; wCurrentBoxNum
DEF BIT_HAS_CHANGED_BOXES EQU 7
+DEF BOX_NUM_MASK EQU %01111111
; wObtainedBadges, wBeatGymFlags
const_def
@@ -153,3 +154,6 @@ DEF NUM_BADGES EQU const_value
const_def
const BIT_PLAYER_LOWER_Y ; 0
const BIT_PLAYER_LOWER_X ; 1
+
+; rLCDC
+DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9800 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
diff --git a/data/maps/objects/Route2Gate.asm b/data/maps/objects/Route2Gate.asm
index 6c46736d..44e4aa67 100644
--- a/data/maps/objects/Route2Gate.asm
+++ b/data/maps/objects/Route2Gate.asm
@@ -1,6 +1,6 @@
object_const_def
- const_export ROUTE2_OAKS_AIDE
- const_export ROUTE2_YOUNGSTER
+ const_export ROUTE2GATE_OAKS_AIDE
+ const_export ROUTE2GATE_YOUNGSTER
Route2Gate_Object:
db $a ; border block
diff --git a/data/predef_pointers.asm b/data/predef_pointers.asm
index ebf81847..e6968c46 100644
--- a/data/predef_pointers.asm
+++ b/data/predef_pointers.asm
@@ -53,7 +53,7 @@ PredefPointers::
add_predef DoubleOrHalveSelectedStats
add_predef ShowPokedexMenu
add_predef EvolutionAfterBattle
- add_predef SaveSAVtoSRAM0
+ add_predef SaveMainData
add_predef InitOpponent
add_predef CableClub_Run
add_predef DrawBadges
@@ -73,7 +73,7 @@ PredefPointers::
add_predef UsedCut
add_predef ShowPokedexData
add_predef WriteMonMoves
- add_predef SaveSAV
+ add_predef SaveMenu
add_predef LoadSGB
add_predef MarkTownVisitedAndLoadMissableObjects
add_predef SetPartyMonTypes
@@ -90,10 +90,10 @@ PredefPointers::
add_predef EmptyFunc ; return immediately
add_predef AskName
add_predef PewterGuys
- add_predef SaveSAVtoSRAM2
- add_predef LoadSAV2
- add_predef LoadSAV
- add_predef SaveSAVtoSRAM1
+ add_predef SavePartyAndDexData
+ add_predef LoadPartyAndDexData
+ add_predef TryLoadSaveFile
+ add_predef SaveCurrentBoxData
add_predef DoInGameTradeDialogue
add_predef HallOfFamePC
add_predef DisplayDexRating
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 28c164e5..296f9019 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -3137,30 +3137,30 @@ PlayerCalcMoveDamage:
jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
call CriticalHitTest
call HandleCounterMove
- jr z, handleIfPlayerMoveMissed
+ jr z, HandleIfPlayerMoveMissed
call GetDamageVarsForPlayerAttack
call CalculateDamage
- jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
+ jp z, PlayerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
; for these moves, accuracy tests will only occur if they are called as part of the effect itself
call AdjustDamageForMoveType
call RandomizeDamage
.moveHitTest
call MoveHitTest
-handleIfPlayerMoveMissed:
+HandleIfPlayerMoveMissed:
ld a, [wMoveMissed]
and a
- jr z, getPlayerAnimationType
+ jr z, GetPlayerAnimationType
ld a, [wPlayerMoveEffect]
sub EXPLODE_EFFECT
- jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
- jr playerCheckIfFlyOrChargeEffect
-getPlayerAnimationType:
+ jr z, PlayPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
+ jr PlayerCheckIfFlyOrChargeEffect
+GetPlayerAnimationType:
ld a, [wPlayerMoveEffect]
and a
ld a, ANIMATIONTYPE_BLINK_ENEMY_MON_SPRITE ; move has no effect other than dealing damage
- jr z, playPlayerMoveAnimation
+ jr z, PlayPlayerMoveAnimation
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT ; move has effect
-playPlayerMoveAnimation:
+PlayPlayerMoveAnimation:
push af
ld a, [wPlayerBattleStatus2]
bit HAS_SUBSTITUTE_UP, a
@@ -3179,7 +3179,7 @@ playPlayerMoveAnimation:
ld b, BANK(ReshowSubstituteAnim)
call nz, Bankswitch
jr MirrorMoveCheck
-playerCheckIfFlyOrChargeEffect:
+PlayerCheckIfFlyOrChargeEffect:
ld c, 30
call DelayFrames
ld a, [wPlayerMoveEffect]
@@ -3246,7 +3246,7 @@ MirrorMoveCheck:
ld a, [wPlayerNumAttacksLeft]
dec a
ld [wPlayerNumAttacksLeft], a
- jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
+ jp nz, GetPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
; damage calculation and accuracy tests only happen for the first hit
res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over
ld hl, MultiHitText
@@ -3523,7 +3523,7 @@ CheckPlayerStatusConditions:
ld [hl], a
ld a, BIDE
ld [wPlayerMoveNum], a
- ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
+ ld hl, HandleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .returnToHL
.ThrashingAboutCheck
@@ -3557,7 +3557,7 @@ CheckPlayerStatusConditions:
ld a, [wPlayerNumAttacksLeft]
dec a ; did multi-turn move end?
ld [wPlayerNumAttacksLeft], a
- ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
+ ld hl, GetPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
; DecrementPP and MoveHitTest
jp nz, .returnToHL
jp .returnToHL
@@ -5567,7 +5567,7 @@ RandomizeDamage:
.loop
call BattleRandom
rrca
- cp 217
+ cp 85 percent + 1
jr c, .loop
ldh [hMultiplier], a
call Multiply ; multiply damage by the random number, which is in the range [217, 255]
@@ -5660,7 +5660,7 @@ EnemyCalcMoveDamage:
jp c, EnemyMoveHitTest
call CriticalHitTest
call HandleCounterMove
- jr z, handleIfEnemyMoveMissed
+ jr z, HandleIfEnemyMoveMissed
call SwapPlayerAndEnemyLevels
call GetDamageVarsForEnemyAttack
call SwapPlayerAndEnemyLevels
@@ -5671,13 +5671,13 @@ EnemyCalcMoveDamage:
EnemyMoveHitTest:
call MoveHitTest
-handleIfEnemyMoveMissed:
+HandleIfEnemyMoveMissed:
ld a, [wMoveMissed]
and a
jr z, .moveDidNotMiss
ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
- jr z, handleExplosionMiss
+ jr z, HandleExplosionMiss
jr EnemyCheckIfFlyOrChargeEffect
.moveDidNotMiss
call SwapPlayerAndEnemyLevels
@@ -5686,13 +5686,13 @@ GetEnemyAnimationType:
ld a, [wEnemyMoveEffect]
and a
ld a, ANIMATIONTYPE_SHAKE_SCREEN_VERTICALLY
- jr z, playEnemyMoveAnimation
+ jr z, PlayEnemyMoveAnimation
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_HEAVY
- jr playEnemyMoveAnimation
-handleExplosionMiss:
+ jr PlayEnemyMoveAnimation
+HandleExplosionMiss:
call SwapPlayerAndEnemyLevels
xor a
-playEnemyMoveAnimation:
+PlayEnemyMoveAnimation:
push af
ld a, [wEnemyBattleStatus2]
bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
@@ -6031,7 +6031,7 @@ CheckEnemyStatusConditions:
ld a, BIDE
ld [wEnemyMoveNum], a
call SwapPlayerAndEnemyLevels
- ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
+ ld hl, HandleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
.checkIfThrashingAbout
bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?
@@ -6881,12 +6881,12 @@ _InitBattleCommon:
call PrintText
call SaveScreenTilesToBuffer1
call ClearScreen
- ld a, $98
+ ld a, HIGH(vBGMap0)
ldh [hAutoBGTransferDest + 1], a
ld a, $1
ldh [hAutoBGTransferEnabled], a
call Delay3
- ld a, $9c
+ ld a, HIGH(vBGMap1)
ldh [hAutoBGTransferDest + 1], a
call LoadScreenTilesFromBuffer1
hlcoord 9, 7
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index a3a552e7..e111f783 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -7,9 +7,9 @@ _JumpMoveEffect:
ldh a, [hWhoseTurn]
and a
ld a, [wPlayerMoveEffect]
- jr z, .next1
+ jr z, .next
ld a, [wEnemyMoveEffect]
-.next1
+.next
dec a ; subtract 1, there is no special effect for 00
add a ; x2, 16bit pointers
ld hl, MoveEffectPointerTable
@@ -680,14 +680,14 @@ UpdateLoweredStatDone:
call PrintStatText
pop de
ld a, [de]
- cp $44
+ cp ATTACK_DOWN_SIDE_EFFECT ; for all side effects, move animation has already played, skip it
jr nc, .ApplyBadgeBoostsAndStatusPenalties
call PlayCurrentMoveAnimation2
.ApplyBadgeBoostsAndStatusPenalties
ldh a, [hWhoseTurn]
and a
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
- ; even to those not affected by the stat-up move (will be boosted further)
+ ; even to those not affected by the stat-down move (will be boosted further)
ld hl, MonsStatsFellText
call PrintText
@@ -1438,9 +1438,9 @@ CheckTargetSubstitute:
ld hl, wEnemyBattleStatus2
ldh a, [hWhoseTurn]
and a
- jr z, .next1
+ jr z, .next
ld hl, wPlayerBattleStatus2
-.next1
+.next
bit HAS_SUBSTITUTE_UP, [hl]
pop hl
ret
diff --git a/engine/events/give_pokemon.asm b/engine/events/give_pokemon.asm
index 9e80bdfc..640a3dba 100644
--- a/engine/events/give_pokemon.asm
+++ b/engine/events/give_pokemon.asm
@@ -20,7 +20,7 @@ _GivePokemon::
callfar SendNewMonToBox
ld hl, wStringBuffer
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
cp 9
jr c, .singleDigitBoxNum
sub 9
diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm
index c73d7ab8..15b991ed 100644
--- a/engine/events/prize_menu.asm
+++ b/engine/events/prize_menu.asm
@@ -2,12 +2,12 @@ CeladonPrizeMenu::
ld b, COIN_CASE
call IsItemInBag
jr nz, .havingCoinCase
- ld hl, RequireCoinCaseTextPtr
+ ld hl, RequireCoinCaseText
jp PrintText
.havingCoinCase
ld hl, wStatusFlags5
set BIT_NO_TEXT_DELAY, [hl]
- ld hl, ExchangeCoinsForPrizesTextPtr
+ ld hl, ExchangeCoinsForPrizesText
call PrintText
; the following are the menu settings
xor a
@@ -28,7 +28,7 @@ CeladonPrizeMenu::
call TextBoxBorder
call GetPrizeMenuId
call UpdateSprites
- ld hl, WhichPrizeTextPtr
+ ld hl, WhichPrizeText
call PrintText
call HandleMenuInput ; menu choice handler
bit B_PAD_B, a
@@ -42,16 +42,16 @@ CeladonPrizeMenu::
res BIT_NO_TEXT_DELAY, [hl]
ret
-RequireCoinCaseTextPtr:
+RequireCoinCaseText:
text_far _RequireCoinCaseText
text_waitbutton
text_end
-ExchangeCoinsForPrizesTextPtr:
+ExchangeCoinsForPrizesText:
text_far _ExchangeCoinsForPrizesText
text_end
-WhichPrizeTextPtr:
+WhichPrizeText:
text_far _WhichPrizeText
text_end
diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm
index 429d8123..0497f74a 100644
--- a/engine/gfx/palettes.asm
+++ b/engine/gfx/palettes.asm
@@ -523,15 +523,15 @@ CopyGfxToSuperNintendoVRAM:
call CopySGBBorderTiles
jr .next
.notCopyingTileData
- ld bc, $1000
+ ld bc, 256 tiles
call CopyData
.next
ld hl, vBGMap0
- ld de, $c
+ ld de, TILEMAP_WIDTH - SCREEN_WIDTH
ld a, $80
- ld c, $d
+ ld c, (256 + SCREEN_WIDTH - 1) / SCREEN_WIDTH ; enough rows to fit 256 tiles
.loop
- ld b, $14
+ ld b, SCREEN_WIDTH
.innerLoop
ld [hli], a
inc a
@@ -540,7 +540,7 @@ CopyGfxToSuperNintendoVRAM:
add hl, de
dec c
jr nz, .loop
- ld a, $e3
+ ld a, LCDC_DEFAULT
ldh [rLCDC], a
pop hl
call SendSGBPacket
diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm
index 872e9b9c..a4307532 100644
--- a/engine/link/cable_club.asm
+++ b/engine/link/cable_club.asm
@@ -861,7 +861,7 @@ TradeCenter_Trade:
hlcoord 1, 14
ld de, TradeCompleted
call PlaceString
- predef SaveSAVtoSRAM2
+ predef SavePartyAndDexData ; this allows reset into Pokecenter
vc_hook Trade_save_game_end
ld c, 50
call DelayFrames
diff --git a/engine/link/cable_club_npc.asm b/engine/link/cable_club_npc.asm
index 19e59eca..2c458b59 100644
--- a/engine/link/cable_club_npc.asm
+++ b/engine/link/cable_club_npc.asm
@@ -64,7 +64,7 @@ CableClubNPC::
and a
jr nz, .choseNo
vc_hook Wireless_TryQuickSave_block_input
- callfar SaveSAVtoSRAM
+ callfar SaveGameData
call WaitForSoundToFinish
ld a, SFX_SAVE
call PlaySoundWaitForCurrent
diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm
index 2ef1cfb1..f8bd6512 100644
--- a/engine/menus/display_text_id_init.asm
+++ b/engine/menus/display_text_id_init.asm
@@ -69,7 +69,7 @@ DisplayTextIDInit::
add hl, de
dec c
jr nz, .spriteStandStillLoop
- ld b, $9c ; window background address
+ ld b, HIGH(vBGMap1)
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
xor a
ldh [hWY], a ; put the window on the screen
diff --git a/engine/menus/main_menu.asm b/engine/menus/main_menu.asm
index a3fe6587..c6f8547b 100644
--- a/engine/menus/main_menu.asm
+++ b/engine/menus/main_menu.asm
@@ -8,7 +8,7 @@ MainMenu:
call CheckForPlayerNameInSRAM
jr nc, .mainMenuLoop
- predef LoadSAV
+ predef TryLoadSaveFile
.mainMenuLoop
ld c, 20
@@ -701,8 +701,9 @@ CheckForPlayerNameInSRAM:
; in carry.
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK(sPlayerName) == BMODE_ADVANCED
ld [rRAMB], a
ld b, NAME_LENGTH
ld hl, sPlayerName
diff --git a/engine/menus/save.asm b/engine/menus/save.asm
index fba1dc53..7112207f 100644
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -1,16 +1,15 @@
-LoadSAV:
-; if carry, write "the file data is destroyed"
+TryLoadSaveFile:
call ClearScreen
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
- call LoadSAV0
+ call LoadMainData
jr c, .badsum
- call LoadSAV1
+ call LoadCurrentBoxData
jr c, .badsum
- call LoadSAV2
+ call LoadPartyAndDexData
jr c, .badsum
ld a, $2 ; good checksum
- jr .goodsum
+ jr .done
.badsum
ld hl, wStatusFlags5
push hl
@@ -22,7 +21,7 @@ LoadSAV:
pop hl
res BIT_NO_TEXT_DELAY, [hl]
ld a, $1 ; bad checksum
-.goodsum
+.done
ld [wSaveFileStatus], a
ret
@@ -30,33 +29,34 @@ FileDataDestroyedText:
text_far _FileDataDestroyedText
text_end
-LoadSAV0:
+LoadMainData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
; This vc_hook does not have to be in any particular location.
; It is defined here because it refers to the same labels as the two lines below.
vc_hook Unknown_save_limit
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld c, a
ld a, [sMainDataCheckSum]
cp c
- jp z, .checkSumsMatched
+ jp z, .checkSumMatched
; If the computed checksum didn't match the saved on, try again.
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld c, a
ld a, [sMainDataCheckSum]
cp c
- jp nz, SAVBadCheckSum
+ jp nz, CheckSumFailed
-.checkSumsMatched
+.checkSumMatched
ld hl, sPlayerName
ld de, wPlayerName
ld bc, NAME_LENGTH
@@ -73,46 +73,51 @@ LoadSAV0:
call CopyData
ld a, [sTileAnimations]
ldh [hTileAnimations], a
+
+; this part is redundant, LoadCurrentBoxData is always called next
ld hl, sCurBoxData
ld de, wBoxDataStart
ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
+
and a
- jp SAVGoodChecksum
+ jp GoodCheckSum
-LoadSAV1:
+LoadCurrentBoxData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld c, a
ld a, [sMainDataCheckSum]
cp c
- jr nz, SAVBadCheckSum
+ jr nz, CheckSumFailed
ld hl, sCurBoxData
ld de, wBoxDataStart
ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
and a
- jp SAVGoodChecksum
+ jp GoodCheckSum
-LoadSAV2:
+LoadPartyAndDexData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld c, a
ld a, [sMainDataCheckSum]
cp c
- jp nz, SAVBadCheckSum
+ jp nz, CheckSumFailed
ld hl, sPartyData
ld de, wPartyDataStart
ld bc, wPartyDataEnd - wPartyDataStart
@@ -122,40 +127,43 @@ LoadSAV2:
ld bc, wPokedexSeenEnd - wPokedexOwned
call CopyData
and a
- jp SAVGoodChecksum
+ jp GoodCheckSum
-SAVBadCheckSum:
+CheckSumFailed:
scf
+ ; fallthrough
-SAVGoodChecksum:
- ld a, $0
+GoodCheckSum:
+ ld a, BMODE_SIMPLE ; preserve flags
ld [rBMODE], a
+ ASSERT RAMG_SRAM_DISABLE == BMODE_SIMPLE
ld [rRAMG], a
ret
-LoadSAVIgnoreBadCheckSum:
-; unused function that loads save data and ignores bad checksums
- call LoadSAV0
- call LoadSAV1
- jp LoadSAV2
+TryLoadSaveFileIgnoreChecksum: ; unreferenced
+; don't update wSaveFileStatus upon success or failure
+; don't display warning in case of failed checksum
+ call LoadMainData
+ call LoadCurrentBoxData
+ jp LoadPartyAndDexData
-SaveSAV:
+SaveMenu:
farcall PrintSaveScreenText
ld hl, WouldYouLikeToSaveText
- call SaveSAVConfirm
+ call SaveTheGame_YesOrNo
and a ;|0 = Yes|1 = No|
ret nz
ld a, [wSaveFileStatus]
dec a
jr z, .save
- call SAVCheckRandomID
+ call CheckPreviousSaveFile
jr z, .save
ld hl, OlderFileWillBeErasedText
- call SaveSAVConfirm
+ call SaveTheGame_YesOrNo
and a
ret nz
.save
- call SaveSAVtoSRAM
+ call SaveGameData
hlcoord 1, 13
lb bc, 4, 18
call ClearScreenArea
@@ -175,13 +183,13 @@ SaveSAV:
NowSavingString:
db "Now saving...@"
-SaveSAVConfirm:
+SaveTheGame_YesOrNo:
call PrintText
hlcoord 0, 7
lb bc, 8, 1
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
- call DisplayTextBoxID ; yes/no menu
+ call DisplayTextBoxID
ld a, [wCurrentMenuItem]
ret
@@ -197,12 +205,14 @@ OlderFileWillBeErasedText:
text_far _OlderFileWillBeErasedText
text_end
-SaveSAVtoSRAM0:
+SaveMainData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
+
ld hl, wPlayerName
ld de, sPlayerName
ld bc, NAME_LENGTH
@@ -216,26 +226,29 @@ SaveSAVtoSRAM0:
ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
ld hl, wBoxDataStart
+
+; this part is redundant, SaveCurrentBoxData is always called next
ld de, sCurBoxData
ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
ldh a, [hTileAnimations]
ld [sTileAnimations], a
+
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld [sMainDataCheckSum], a
xor a
ld [rBMODE], a
ld [rRAMG], a
ret
-SaveSAVtoSRAM1:
-; stored pokémon
+SaveCurrentBoxData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
ld hl, wBoxDataStart
ld de, sCurBoxData
@@ -243,18 +256,19 @@ SaveSAVtoSRAM1:
call CopyData
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld [sMainDataCheckSum], a
xor a
ld [rBMODE], a
ld [rRAMG], a
ret
-SaveSAVtoSRAM2:
+SavePartyAndDexData:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
ld hl, wPartyDataStart
ld de, sPartyData
@@ -266,21 +280,21 @@ SaveSAVtoSRAM2:
call CopyData
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld [sMainDataCheckSum], a
xor a
ld [rBMODE], a
ld [rRAMG], a
ret
-SaveSAVtoSRAM::
+SaveGameData::
ld a, $2
ld [wSaveFileStatus], a
- call SaveSAVtoSRAM0
- call SaveSAVtoSRAM1
- jp SaveSAVtoSRAM2
+ call SaveMainData
+ call SaveCurrentBoxData
+ jp SavePartyAndDexData
-SAVCheckSum:
+CalcCheckSum:
;Check Sum (result[1 byte] is complemented)
ld d, 0
.loop
@@ -303,7 +317,7 @@ CalcIndividualBoxCheckSums:
push bc
push de
ld bc, wBoxDataEnd - wBoxDataStart
- call SAVCheckSum
+ call CalcCheckSum
pop de
ld [de], a
inc de
@@ -317,7 +331,7 @@ GetBoxSRAMLocation:
; out: b = box SRAM bank, hl = pointer to start of box
ld hl, BoxSRAMPointerTable
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
cp NUM_BOXES / 2
ld b, 2
jr c, .next
@@ -379,7 +393,7 @@ ChangeBox::
ld a, [hl]
ld [de], a
call RestoreMapTextPointer
- call SaveSAVtoSRAM
+ call SaveGameData
ld hl, wChangeBoxSavedMapTextPointer
call SetMapTextPointer
ld a, SFX_SAVE
@@ -396,7 +410,7 @@ CopyBoxToOrFromSRAM:
push hl
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
ld a, b
ld [rRAMB], a
@@ -404,7 +418,7 @@ CopyBoxToOrFromSRAM:
call CopyData
pop hl
-; mark the memory that the box was copied from as am empty box
+; mark the source box as an empty box
xor a
ld [hli], a
dec a
@@ -412,7 +426,7 @@ CopyBoxToOrFromSRAM:
ld hl, sBox1 ; sBox7
ld bc, sBank2AllBoxesChecksum - sBox1
- call SAVCheckSum
+ call CalcCheckSum
ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum
call CalcIndividualBoxCheckSums
xor a
@@ -434,7 +448,7 @@ DisplayChangeBoxMenu:
xor a
ld [wMenuWatchMovingOutOfBounds], a
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
hlcoord 0, 0
@@ -455,7 +469,7 @@ DisplayChangeBoxMenu:
ld hl, hUILayoutFlags
res BIT_SINGLE_SPACED_LINES, [hl]
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
cp 9
jr c, .singleDigitBoxNum
sub 9
@@ -474,7 +488,7 @@ DisplayChangeBoxMenu:
hlcoord 18, 1
ld de, wBoxMonCounts
ld bc, SCREEN_WIDTH
- ld a, $c
+ ld a, NUM_BOXES
.loop
push af
ld a, [de]
@@ -517,12 +531,12 @@ EmptyAllSRAMBoxes:
; player changes the box)
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
- ld a, 2
+ ld a, BANK("Saved Boxes 1")
ld [rRAMB], a
call EmptySRAMBoxesInBank
- ld a, 3
+ ld a, BANK("Saved Boxes 2")
ld [rRAMB], a
call EmptySRAMBoxesInBank
xor a
@@ -546,7 +560,7 @@ EmptySRAMBoxesInBank:
call EmptySRAMBox
ld hl, sBox1 ; sBox7
ld bc, sBank2AllBoxesChecksum - sBox1
- call SAVCheckSum
+ call CalcCheckSum
ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum
call CalcIndividualBoxCheckSums
ret
@@ -563,12 +577,12 @@ GetMonCountsForAllBoxes:
push hl
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
- ld a, $2
+ ld a, BANK("Saved Boxes 1")
ld [rRAMB], a
call GetMonCountsForBoxesInBank
- ld a, $3
+ ld a, BANK("Saved Boxes 2")
ld [rRAMB], a
call GetMonCountsForBoxesInBank
xor a
@@ -578,7 +592,7 @@ GetMonCountsForAllBoxes:
; copy the count for the current box from WRAM
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
ld c, a
ld b, 0
add hl, bc
@@ -602,25 +616,26 @@ GetMonCountsForBoxesInBank:
ld [hli], a
ret
-SAVCheckRandomID:
-; checks if Sav file is the same by checking player's name 1st letter
-; and the two random numbers generated at game beginning
-; (which are stored at wPlayerID)s
- ld a, $0a
+; check if we're trying to save over a different playthrough
+; return result in zero flag
+; z set: a valid save file was found, and saved PlayerID is different from wPlayerID
+CheckPreviousSaveFile:
+ ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $01
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
+ ASSERT BANK("Save Data") == BMODE_ADVANCED
ld [rRAMB], a
ld a, [sPlayerName]
and a
jr z, .next
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
- call SAVCheckSum
+ call CalcCheckSum
ld c, a
ld a, [sMainDataCheckSum]
cp c
- jr nz, .next
+ jr nz, .next ; return z set if save data is corrupted
ld hl, sMainData + (wPlayerID - wMainDataStart) ; player ID
ld a, [hli]
ld h, [hl]
@@ -631,8 +646,9 @@ SAVCheckRandomID:
ld a, [wPlayerID + 1]
cp h
.next
- ld a, $00
+ ld a, BMODE_SIMPLE
ld [rBMODE], a
+ ASSERT RAMG_SRAM_DISABLE == BMODE_SIMPLE
ld [rRAMG], a
ret
@@ -674,7 +690,7 @@ LoadHallOfFameTeams:
HallOfFame_Copy:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
xor a
ld [rRAMB], a
@@ -684,25 +700,26 @@ HallOfFame_Copy:
ld [rRAMG], a
ret
-ClearSAV:
+; Fill SRAM with $ff, erasing save data. Used by DoClearSaveDialogue
+ClearAllSRAMBanks:
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
- ld a, $1
+ ld a, BMODE_ADVANCED
ld [rBMODE], a
xor a
- call PadSRAM_FF
- ld a, $1
- call PadSRAM_FF
- ld a, $2
- call PadSRAM_FF
- ld a, $3
- call PadSRAM_FF
+ call .PadSRAM_FF
+ ld a, 1
+ call .PadSRAM_FF
+ ld a, 2
+ call .PadSRAM_FF
+ ld a, 3
+ call .PadSRAM_FF
xor a
ld [rBMODE], a
ld [rRAMG], a
ret
-PadSRAM_FF:
+.PadSRAM_FF
ld [rRAMB], a
ld hl, STARTOF(SRAM)
ld bc, SIZEOF(SRAM)
diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm
index 65f0b26e..e845941f 100644
--- a/engine/menus/start_sub_menus.asm
+++ b/engine/menus/start_sub_menus.asm
@@ -1,6 +1,6 @@
StartMenu_Pokedex::
predef ShowPokedexMenu
- call LoadScreenTilesFromBuffer2 ; restore saved screen
+ call LoadScreenTilesFromBuffer2
call Delay3
call LoadGBPal
call UpdateSprites
@@ -63,7 +63,7 @@ StartMenu_Pokemon::
ld [hl], a
call HandleMenuInput
push af
- call LoadScreenTilesFromBuffer1 ; restore saved screen
+ call LoadScreenTilesFromBuffer1
pop af
bit B_PAD_B, a
jp nz, .loop
@@ -117,7 +117,7 @@ StartMenu_Pokemon::
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [wObtainedBadges] ; badges obtained
+ ld a, [wObtainedBadges]
jp hl
.outOfBattleMovePointers
dw .cut
@@ -286,7 +286,7 @@ StartMenu_Pokemon::
; writes a blank tile to all possible menu cursor positions on the party menu
ErasePartyMenuCursors::
hlcoord 0, 1
- ld bc, 2 * 20 ; menu cursor positions are 2 rows apart
+ ld bc, 2 * SCREEN_WIDTH ; menu cursor positions are 2 rows apart
ld a, 6 ; 6 menu cursor positions
.loop
ld [hl], " "
@@ -296,7 +296,7 @@ ErasePartyMenuCursors::
ret
ItemMenuLoop:
- call LoadScreenTilesFromBuffer2DisableBGTransfer ; restore saved screen
+ call LoadScreenTilesFromBuffer2DisableBGTransfer
call RunDefaultPaletteCommand
StartMenu_Item::
@@ -323,7 +323,7 @@ StartMenu_Item::
ld [wBagSavedMenuItem], a
jr nc, .choseItem
.exitMenu
- call LoadScreenTilesFromBuffer2 ; restore saved screen
+ call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
call UpdateSprites
jp RedisplayStartMenu
@@ -363,7 +363,7 @@ StartMenu_Item::
bit B_PAD_B, a
jr z, .useOrTossItem
jp ItemMenuLoop
-.useOrTossItem ; if the player made the choice to use or toss the item
+.useOrTossItem
ld a, [wCurItem]
ld [wNamedObjectIndex], a
call GetItemName
@@ -459,14 +459,14 @@ StartMenu_TrainerInfo::
xor a
ldh [hTileAnimations], a
call DrawTrainerInfo
- predef DrawBadges ; draw badges
+ predef DrawBadges
ld b, SET_PAL_TRAINER_CARD
call RunPaletteCommand
call GBPalNormal
- call WaitForTextScrollButtonPress ; wait for button press
+ call WaitForTextScrollButtonPress
call GBPalWhiteOut
call LoadFontTilePatterns
- call LoadScreenTilesFromBuffer2 ; restore saved screen
+ call LoadScreenTilesFromBuffer2
call RunDefaultPaletteCommand
call ReloadMapData
call LoadGBPal
@@ -489,7 +489,7 @@ DrawTrainerInfo:
ld de, vChars2 tile $00
ld bc, $1c tiles
call CopyData
- ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns
+ ld hl, TrainerInfoTextBoxTileGraphics
ld de, vChars2 tile $77
ld bc, 8 tiles
push bc
@@ -499,10 +499,10 @@ DrawTrainerInfo:
ld bc, $17 tiles
call TrainerInfo_FarCopyData
pop bc
- ld hl, BadgeNumbersTileGraphics ; badge number tile patterns
+ ld hl, BadgeNumbersTileGraphics
ld de, vChars1 tile $58
call TrainerInfo_FarCopyData
- ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns
+ ld hl, GymLeaderFaceAndBadgeTileGraphics
ld de, vChars2 tile $20
ld bc, 8 * 8 tiles
ld a, BANK(GymLeaderFaceAndBadgeTileGraphics)
@@ -555,12 +555,12 @@ DrawTrainerInfo:
ld c, 3 | LEADING_ZEROES | LEFT_ALIGN | MONEY_SIGN
call PrintBCDNumber
hlcoord 9, 6
- ld de, wPlayTimeHours ; hours
+ ld de, wPlayTimeHours
lb bc, LEFT_ALIGN | 1, 3
call PrintNumber
ld [hl], $d6 ; colon tile ID
inc hl
- ld de, wPlayTimeMinutes ; minutes
+ ld de, wPlayTimeMinutes
lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber
@@ -642,8 +642,8 @@ StartMenu_SaveReset::
ld a, [wStatusFlags4]
bit BIT_LINK_CONNECTED, a
jp nz, Init
- predef SaveSAV ; save the game
- call LoadScreenTilesFromBuffer2 ; restore saved screen
+ predef SaveMenu
+ call LoadScreenTilesFromBuffer2
jp HoldTextDisplayOpen
StartMenu_Option::
@@ -652,7 +652,7 @@ StartMenu_Option::
call ClearScreen
call UpdateSprites
callfar DisplayOptionMenu
- call LoadScreenTilesFromBuffer2 ; restore saved screen
+ call LoadScreenTilesFromBuffer2
call LoadTextBoxTilePatterns
call UpdateSprites
jp RedisplayStartMenu
diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm
index 236cf516..7653b4bc 100644
--- a/engine/movie/hall_of_fame.asm
+++ b/engine/movie/hall_of_fame.asm
@@ -7,7 +7,7 @@ AnimateHallOfFame:
call LoadTextBoxTilePatterns
call DisableLCD
ld hl, vBGMap0
- ld bc, $800
+ ld bc, 2 * TILEMAP_AREA
ld a, " "
call FillMemory
call EnableLCD
diff --git a/engine/movie/oak_speech/clear_save.asm b/engine/movie/oak_speech/clear_save.asm
index d5c04e6e..f4a278b3 100644
--- a/engine/movie/oak_speech/clear_save.asm
+++ b/engine/movie/oak_speech/clear_save.asm
@@ -15,7 +15,7 @@ DoClearSaveDialogue:
ld a, [wCurrentMenuItem]
and a
jp z, Init
- farcall ClearSAV
+ farcall ClearAllSRAMBanks
jp Init
ClearSaveDataText:
diff --git a/engine/movie/title.asm b/engine/movie/title.asm
index 83fb32e8..bcd01f33 100644
--- a/engine/movie/title.asm
+++ b/engine/movie/title.asm
@@ -356,7 +356,7 @@ DrawPlayerCharacter:
ClearBothBGMaps:
ld hl, vBGMap0
- ld bc, $400 * 2
+ ld bc, 2 * TILEMAP_AREA
ld a, " "
jp FillMemory
diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm
index 4d7bd54a..4cb9d394 100644
--- a/engine/movie/trade.asm
+++ b/engine/movie/trade.asm
@@ -167,7 +167,7 @@ LoadTradingGFXAndMonNames:
ld a, BANK(TradingAnimationGraphics2)
call FarCopyData2
ld hl, vBGMap0
- ld bc, $800
+ ld bc, 2 * TILEMAP_AREA
ld a, " "
call FillMemory
call ClearSprites
@@ -223,7 +223,7 @@ Trade_Cleanup:
ret
Trade_ShowPlayerMon:
- ld a, %10101011
+ ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
ldh [rLCDC], a
ld a, $50
ldh [hWY], a
@@ -279,7 +279,7 @@ Trade_DrawOpenEndOfLinkCable:
ld a, $a0
ldh [hSCX], a
call DelayFrame
- ld a, %10001011
+ ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_OFF | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
ldh [rLCDC], a
hlcoord 6, 2
ld b, TILEMAP_LINK_CABLE
@@ -338,7 +338,7 @@ Trade_AnimateBallEnteringLinkCable:
ld a, $1
ldh [hAutoBGTransferEnabled], a
call ClearScreen
- ld b, $98
+ ld b, HIGH(vBGMap0)
call CopyScreenTileBufferToVRAM
call Delay3
xor a
@@ -452,7 +452,7 @@ Trade_InitGameboyTransferGfx:
ldh [hAutoBGTransferEnabled], a
call Trade_LoadMonPartySpriteGfx
call DelayFrame
- ld a, %10101011
+ ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
ldh [rLCDC], a
xor a
ldh [hSCX], a
@@ -757,7 +757,7 @@ Trade_ShowClearedWindow:
ld a, $1
ldh [hAutoBGTransferEnabled], a
call ClearScreen
- ld a, %11100011
+ ld a, LCDC_DEFAULT
ldh [rLCDC], a
ld a, $7
ldh [rWX], a
diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm
index 8f88b138..1660a894 100644
--- a/engine/overworld/missable_objects.asm
+++ b/engine/overworld/missable_objects.asm
@@ -15,9 +15,6 @@ MarkTownVisitedAndLoadMissableObjects::
add hl, bc
ld a, [hli] ; load missable objects pointer in hl
ld h, [hl]
- ; fall through
-
-LoadMissableObjects:
ld l, a
push hl
ld de, MissableObjects ; calculate difference between out pointer and the base pointer
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index ea21e8e2..6d522377 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -151,7 +151,7 @@ BillsPCMenu:
ld c, 9
call TextBoxBorder
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
cp 9
jr c, .singleDigitBoxNum
; two digit box num
@@ -236,7 +236,7 @@ BillsPCDeposit:
call WaitForSoundToFinish
ld hl, wBoxNumString
ld a, [wCurrentBoxNum]
- and $7f
+ and BOX_NUM_MASK
cp 9
jr c, .singleDigitBoxNum
sub 9
@@ -538,6 +538,7 @@ JustAMomentText::
text_far _JustAMomentText
text_end
+UnusedOpenBillsPC: ; unreferenced
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_UP
ret nz
diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm
index a68f9b38..344e7802 100644
--- a/engine/pokemon/status_screen.asm
+++ b/engine/pokemon/status_screen.asm
@@ -427,7 +427,7 @@ StatusScreen2:
ld a, $1
ldh [hAutoBGTransferEnabled], a
call Delay3
- call WaitForTextScrollButtonPress ; wait for button
+ call WaitForTextScrollButtonPress
pop af
ldh [hTileAnimations], a
ld hl, wStatusFlags2
diff --git a/home/init.asm b/home/init.asm
index 67fa3ab1..2ed200b4 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -7,17 +7,6 @@ SoftReset::
Init::
; Program init.
-
-; * LCD enabled
-; * Window tile map at $9C00
-; * Window display enabled
-; * BG and window tile data at $8800
-; * BG tile map at $9800
-; * 8x8 OBJ size
-; * OBJ display enabled
-; * BG display enabled
-DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9800 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
-
di
xor a
@@ -100,7 +89,7 @@ DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC
ld a, BANK(SFX_Shooting_Star)
ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a
- ld a, $9c
+ ld a, HIGH(vBGMap1)
ldh [hAutoBGTransferDest + 1], a
xor a
ldh [hAutoBGTransferDest], a
diff --git a/home/map_objects.asm b/home/map_objects.asm
index e0d9b6a5..44b012e6 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -30,27 +30,25 @@ TextScript_ItemStoragePC::
call SaveScreenTilesToBuffer2
ld b, BANK(PlayerPC)
ld hl, PlayerPC
- jr bankswitchAndContinue
+ jr BankswitchAndContinue
TextScript_BillsPC::
call SaveScreenTilesToBuffer2
ld b, BANK(BillsPC_)
ld hl, BillsPC_
- jr bankswitchAndContinue
+ jr BankswitchAndContinue
TextScript_GameCornerPrizeMenu::
-; XXX find a better name for this function
-; special_F7
ld b, BANK(CeladonPrizeMenu)
ld hl, CeladonPrizeMenu
-bankswitchAndContinue::
+BankswitchAndContinue::
call Bankswitch
jp HoldTextDisplayOpen ; continue to main text-engine function
TextScript_PokemonCenterPC::
ld b, BANK(ActivatePC)
ld hl, ActivatePC
- jr bankswitchAndContinue
+ jr BankswitchAndContinue
StartSimulatingJoypadStates::
xor a
diff --git a/home/overworld.asm b/home/overworld.asm
index 8c79d6e7..5af527c0 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -114,7 +114,7 @@ OverworldLoopLessDelay::
ld [wEnteringCableClub], a
jr z, .changeMap
; XXX can this code be reached?
- predef LoadSAV
+ predef TryLoadSaveFile
ld a, [wCurMap]
ld [wDestinationMap], a
call PrepareForSpecialWarp
diff --git a/home/text_script.asm b/home/text_script.asm
index 35dd955b..389f2499 100644
--- a/home/text_script.asm
+++ b/home/text_script.asm
@@ -84,7 +84,7 @@ ENDM
dict TX_SCRIPT_PRIZE_VENDOR, TextScript_GameCornerPrizeMenu
dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callfar CableClubNPC
- call PrintText_NoCreatingTextBox ; display the text
+ call PrintText_NoCreatingTextBox
ld a, [wDoNotWaitForButtonPressAfterDisplayingText]
and a
jr nz, HoldTextDisplayOpen
@@ -93,7 +93,7 @@ AfterDisplayingTextID::
ld a, [wEnteringCableClub]
and a
jr nz, HoldTextDisplayOpen
- call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text
+ call WaitForTextScrollButtonPress
; loop to hold the dialogue box open as long as the player keeps holding down the A button
HoldTextDisplayOpen::
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 92c78a88..e4ba2cdb 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -140,7 +140,7 @@ AutoBgMapTransfer::
ld h, a
ldh a, [hAutoBGTransferDest]
ld l, a
- ld de, 12 * 32
+ ld de, 12 * TILEMAP_WIDTH
add hl, de
xor a ; TRANSFERTOP
jr .doTransfer
@@ -160,7 +160,7 @@ AutoBgMapTransfer::
ld h, a
ldh a, [hAutoBGTransferDest]
ld l, a
- ld de, 6 * 32
+ ld de, 6 * TILEMAP_WIDTH
add hl, de
ld a, TRANSFERBOTTOM
.doTransfer
diff --git a/scripts/HallOfFame.asm b/scripts/HallOfFame.asm
index eb26afaf..31d56022 100644
--- a/scripts/HallOfFame.asm
+++ b/scripts/HallOfFame.asm
@@ -47,7 +47,7 @@ HallOfFameResetEventsAndSaveScript:
ld [wHallOfFameCurScript], a
ld a, PALLET_TOWN
ld [wLastBlackoutMap], a
- farcall SaveSAVtoSRAM
+ farcall SaveGameData
ld b, 5
.delayLoop
ld c, 600 / 5
diff --git a/scripts/PokemonMansionB1F.asm b/scripts/PokemonMansionB1F.asm
index e31bbd3e..176c243a 100644
--- a/scripts/PokemonMansionB1F.asm
+++ b/scripts/PokemonMansionB1F.asm
@@ -16,30 +16,30 @@ MansionB1FCheckReplaceSwitchDoorBlocks:
CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .switchTurnedOn
ld a, $e
- ld bc, $80d
+ lb bc, 8, 13
call Mansion2ReplaceBlock
ld a, $e
- ld bc, $b06
+ lb bc, 11, 6
call Mansion2ReplaceBlock
ld a, $5f
- ld bc, $304
+ lb bc, 3, 4
call Mansion2ReplaceBlock
ld a, $54
- ld bc, $808
+ lb bc, 8, 8
call Mansion2ReplaceBlock
ret
.switchTurnedOn
ld a, $2d
- ld bc, $80d
+ lb bc, 8, 13
call Mansion2ReplaceBlock
ld a, $5f
- ld bc, $b06
+ lb bc, 11, 6
call Mansion2ReplaceBlock
ld a, $e
- ld bc, $304
+ lb bc, 3, 4
call Mansion2ReplaceBlock
ld a, $e
- ld bc, $808
+ lb bc, 8, 8
call Mansion2ReplaceBlock
ret
diff --git a/scripts/SeafoamIslandsB4F.asm b/scripts/SeafoamIslandsB4F.asm
index 314a8d50..40ecee0a 100644
--- a/scripts/SeafoamIslandsB4F.asm
+++ b/scripts/SeafoamIslandsB4F.asm
@@ -37,7 +37,7 @@ SeafoamIslandsB4FDefaultScript:
ld a, [wCoordIndex]
cp $3
jr nc, .only1UpInputNeeded
- ld a, NPC_MOVEMENT_UP
+ ld a, PAD_UP
ld [wSimulatedJoypadStatesEnd + 1], a
ld a, 2
jr .forcePlayerUpFromSurfExit
diff --git a/scripts/VermilionDock.asm b/scripts/VermilionDock.asm
index 608d2b7e..237b4175 100644
--- a/scripts/VermilionDock.asm
+++ b/scripts/VermilionDock.asm
@@ -50,7 +50,7 @@ VermilionDockSSAnneLeavesScript:
ld [wSpritePlayerStateData1ImageIndex], a
ld c, 120
call DelayFrames
- ld b, $9c
+ ld b, HIGH(vBGMap1)
call CopyScreenTileBufferToVRAM
hlcoord 0, 10
ld bc, SCREEN_WIDTH * 6