diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-03 22:11:35 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-03 22:22:09 -0400 |
commit | 6ef36800b0dcb86100a7c716172015667e60dc99 (patch) | |
tree | 7e381171a7f42cadb6e619c839bfc4d3eb88e7d1 | |
parent | 35deb771130a9012ee4494b1db097761f2fe2919 (diff) |
Replace raw hex values with HRAM constants
To do: turn constants into labels and use ldh
65 files changed, 311 insertions, 248 deletions
diff --git a/audio/engine_1.asm b/audio/engine_1.asm index 0f76f576..20b992aa 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -925,7 +925,7 @@ Audio1_ApplyWavePatternAndFrequency: ld e, [hl] inc hl ld d, [hl] - ld hl, $ff30 ; wave pattern RAM + ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 ld [rNR30], a diff --git a/audio/engine_2.asm b/audio/engine_2.asm index 2e0aad0d..864a8c21 100644 --- a/audio/engine_2.asm +++ b/audio/engine_2.asm @@ -936,7 +936,7 @@ Audio2_ApplyWavePatternAndFrequency: ld e, [hl] inc hl ld d, [hl] - ld hl, $ff30 ; wave pattern RAM + ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 ld [rNR30], a diff --git a/audio/engine_3.asm b/audio/engine_3.asm index 771b44df..c0aaeaf8 100644 --- a/audio/engine_3.asm +++ b/audio/engine_3.asm @@ -925,7 +925,7 @@ Audio3_ApplyWavePatternAndFrequency: ld e, [hl] inc hl ld d, [hl] - ld hl, $ff30 ; wave pattern RAM + ld hl, rWave_0 ld b, $f ld a, $0 ; stop hardware channel 3 ld [rNR30], a diff --git a/audio/pokedex_rating_sfx.asm b/audio/pokedex_rating_sfx.asm index f3aace8a..1b5dc4f0 100644 --- a/audio/pokedex_rating_sfx.asm +++ b/audio/pokedex_rating_sfx.asm @@ -1,5 +1,5 @@ PlayPokedexRatingSfx:: - ld a, [$ffdc] + ld a, [hDexRatingNumMonsOwned] ld c, $0 ld hl, OwnedMonValues .getSfxPointer diff --git a/audio/wave_instruments.asm b/audio/wave_instruments.asm index c915f18a..4a830f4b 100644 --- a/audio/wave_instruments.asm +++ b/audio/wave_instruments.asm @@ -13,7 +13,7 @@ ; these are the definitions for the channel 3 instruments ; each instrument definition is made up of 32 points (nibbles) that form ; the graph of the wave -; the current instrument is copied to $FF30 +; the current instrument is copied to rWave_0--rWave_f .wave0 db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 9f2aa1b7..59ec6170 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -64,6 +64,22 @@ rNR44 EQU $ff23 ; Channel 4 Counter/consecutive; Initial (R/W) rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W) rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W) rNR52 EQU $ff26 ; Sound on/off +rWave_0 EQU $ff30 +rWave_1 EQU $ff31 +rWave_2 EQU $ff32 +rWave_3 EQU $ff33 +rWave_4 EQU $ff34 +rWave_5 EQU $ff35 +rWave_6 EQU $ff36 +rWave_7 EQU $ff37 +rWave_8 EQU $ff38 +rWave_9 EQU $ff39 +rWave_a EQU $ff3a +rWave_b EQU $ff3b +rWave_c EQU $ff3c +rWave_d EQU $ff3d +rWave_e EQU $ff3e +rWave_f EQU $ff3f rLCDC EQU $ff40 ; LCD Control (R/W) rLCDC_ENABLE EQU 7 rLCDC_ENABLE_MASK EQU 1 << rLCDC_ENABLE diff --git a/data/events/hidden_objects.asm b/data/events/hidden_objects.asm index 737947a7..8fc539ef 100755 --- a/data/events/hidden_objects.asm +++ b/data/events/hidden_objects.asm @@ -224,7 +224,7 @@ OaksLabHiddenObjects: db $FF ViridianPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -234,7 +234,7 @@ ViridianMartHiddenObjects: db $FF ViridianSchoolHiddenObjects: db $04,$03,(ViridianSchoolNotebook_id - TextPredefs) / 2 + 1 - db Bank(PrintNotebookText) + db BANK(PrintNotebookText) dw PrintNotebookText db $00,$03,(ViridianSchoolBlackboard_id - TextPredefs) / 2 + 1 db BANK(PrintBlackboardLinkCableText) @@ -262,7 +262,7 @@ PewterMartHiddenObjects: db $FF PewterPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -270,7 +270,7 @@ PewterPokecenterHiddenObjects: db $FF CeruleanPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -286,7 +286,7 @@ CeruleanMartHiddenObjects: db $FF LavenderPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -297,7 +297,7 @@ VermilionPokecenterHiddenObjects: db BANK(OpenPokemonCenterPC) dw OpenPokemonCenterPC db $04,$00,$04 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $FF VermilionGymHiddenObjects: @@ -345,7 +345,7 @@ CeladonMansion2HiddenObjects: db $FF CeladonPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -460,7 +460,7 @@ CeladonHotelHiddenObjects: db BANK(OpenPokemonCenterPC) dw OpenPokemonCenterPC db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $FF FuchsiaPokecenterHiddenObjects: @@ -468,7 +468,7 @@ FuchsiaPokecenterHiddenObjects: db BANK(OpenPokemonCenterPC) dw OpenPokemonCenterPC db $04,$00,$04 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $FF FuchsiaGymHiddenObjects: @@ -481,27 +481,27 @@ CinnabarGymHiddenObjects: db $0d,$11,$04 dbw BANK(GymStatues),GymStatues db $07,$0f,$01 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $01,$0a,$12 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $07,$09,$13 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $0d,$09,$14 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $0d,$01,$05 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $07,$01,$16 - db Bank(PrintCinnabarQuiz) + db BANK(PrintCinnabarQuiz) dw PrintCinnabarQuiz db $FF CinnabarPokecenterHiddenObjects: db $04,$00,$04 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -513,7 +513,7 @@ SaffronGymHiddenObjects: db $FF MtMoonPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -521,7 +521,7 @@ MtMoonPokecenterHiddenObjects: db $FF RockTunnelPokecenterHiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -589,7 +589,7 @@ RocketHideout4HiddenObjects: db $FF SaffronPokecenterHiddenObjects: db $04,$00,$04 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -704,7 +704,7 @@ ViridianCityHiddenObjects: db $FF SafariZoneRestHouse2HiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -712,7 +712,7 @@ SafariZoneRestHouse2HiddenObjects: db $FF SafariZoneRestHouse3HiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -720,7 +720,7 @@ SafariZoneRestHouse3HiddenObjects: db $FF SafariZoneRestHouse4HiddenObjects: db $04,$00,$08 - db Bank(PrintBenchGuyText) + db BANK(PrintBenchGuyText) dw PrintBenchGuyText db $03,$0d,$04 db BANK(OpenPokemonCenterPC) @@ -750,7 +750,7 @@ CeladonMansion5HiddenObjects: db BANK(PrintBlackboardLinkCableText) dw PrintBlackboardLinkCableText db $04,$03,(TMNotebook_id - TextPredefs) / 2 + 1 - db Bank(PrintNotebookText) + db BANK(PrintNotebookText) dw PrintNotebookText db $FF FightingDojoHiddenObjects: diff --git a/data/maps/hide_show_data.asm b/data/maps/hide_show_data.asm index 7f4593ca..bc89d600 100755 --- a/data/maps/hide_show_data.asm +++ b/data/maps/hide_show_data.asm @@ -2,7 +2,7 @@ ; objects for each map ($00-$F8) ; Table of 2-Byte pointers, one pointer per map, -; goes up to Map_F7, ends with $FFFF. +; goes up to Map_F7, ends with -1. ; points to table listing all missable object in the area MapHSPointers: dw MapHS00 @@ -253,7 +253,7 @@ MapHSPointers: dw MapHSXX dw MapHSXX dw MapHSXX - dw $FFFF + dw -1 ; end ; Structure: ; 3 bytes per object diff --git a/data/wild/grass_water.asm b/data/wild/grass_water.asm index f1dd461e..9dc41f82 100755 --- a/data/wild/grass_water.asm +++ b/data/wild/grass_water.asm @@ -247,7 +247,7 @@ WildDataPointers: dw NoMons dw NoMons dw NoMons - dw $FFFF + dw -1 ; end ; wild pokemon data is divided into two parts. ; first part: pokemon found in grass diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index c16fa3ec..d858e066 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -163,7 +163,7 @@ DrawFrameBlock: PlayAnimation: xor a - ld [$FF8B], a ; it looks like nothing reads this + ld [hROMBankTemp], a ; it looks like nothing reads this ld [wSubAnimTransform], a ld a, [wAnimationID] ; get animation number dec a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index e503243d..00852b2b 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -6870,9 +6870,9 @@ _LoadTrainerPic: ld d, a ; de contains pointer to trainer pic ld a, [wLinkState] and a - ld a, Bank(TrainerPics) ; this is where all the trainer pics are (not counting Red's) + ld a, BANK(TrainerPics) ; this is where all the trainer pics are (not counting Red's) jr z, .loadSprite - ld a, Bank(RedPicFront) + ld a, BANK(RedPicFront) .loadSprite call UncompressSpriteFromDE ld de, vFrontPic diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 1774f7c5..11967ba1 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -17,7 +17,7 @@ ScaleFirstThreeSpriteColumnsByTwo: .columnInnerLoop push bc ld a, [de] - ld bc, -(7*8)+1 ; $ffc9, scale lower nybble and seek to previous output column + ld bc, -(7*8)+1 ; -$37, scale lower nybble and seek to previous output column call ScalePixelsByTwo ld a, [de] dec de @@ -32,7 +32,7 @@ ScaleFirstThreeSpriteColumnsByTwo: dec de dec de ld a, b - ld bc, -7*8 ; $ffc8, skip one output column (which has already been written along with the current one) + ld bc, -7*8 ; -$38, skip one output column (which has already been written along with the current one) add hl, bc ld b, a dec b diff --git a/engine/events/cinnabar_lab.asm b/engine/events/cinnabar_lab.asm index e642840d..e1598f98 100755 --- a/engine/events/cinnabar_lab.asm +++ b/engine/events/cinnabar_lab.asm @@ -35,7 +35,7 @@ GiveFossilToCinnabarLab:: ld e, a add hl, de ld a, [hl] - ld [$ffdb], a + ld [hItemToRemoveID], a cp DOME_FOSSIL jr z, .choseDomeFossil cp HELIX_FOSSIL diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm index e53ef58f..24bd2f22 100755 --- a/engine/events/diploma.asm +++ b/engine/events/diploma.asm @@ -73,7 +73,7 @@ UnusedPlayerNameLengthFunc: ; Unused function that does a calculation involving the length of the player's ; name. ld hl, wPlayerName - ld bc, $ff00 + lb bc, $ff, $00 .loop ld a, [hli] cp "@" diff --git a/engine/events/hidden_objects/bookshelves.asm b/engine/events/hidden_objects/bookshelves.asm index 82cd8843..eaf744ff 100644 --- a/engine/events/hidden_objects/bookshelves.asm +++ b/engine/events/hidden_objects/bookshelves.asm @@ -24,7 +24,7 @@ PrintBookshelfText:: pop af call PrintPredefTextID xor a - ld [$ffdb], a + ld [hFFDB], a ret .nextBookshelfEntry1 inc hl @@ -33,7 +33,7 @@ PrintBookshelfText:: jr .loop .noMatch ld a, $ff - ld [$ffdb], a + ld [hFFDB], a jpba PrintCardKeyText INCLUDE "data/tilesets/bookshelf_tile_ids.asm" diff --git a/engine/events/hidden_objects/cinnabar_gym_quiz.asm b/engine/events/hidden_objects/cinnabar_gym_quiz.asm index 9f549eea..6404717e 100644 --- a/engine/events/hidden_objects/cinnabar_gym_quiz.asm +++ b/engine/events/hidden_objects/cinnabar_gym_quiz.asm @@ -16,7 +16,7 @@ CinnabarGymQuiz:: pop af and $f0 swap a - ld [$ffdc], a + ld [hGymGateAnswer], a ld hl, CinnabarGymQuizIntroText call PrintText ld a, [hGymGateIndex] @@ -77,7 +77,7 @@ CinnabarGymGateFlagAction: CinnabarGymQuiz_1ea92: call YesNoChoice - ld a, [$ffdc] + ld a, [hGymGateAnswer] ld c, a ld a, [wCurrentMenuItem] cp c @@ -85,10 +85,10 @@ CinnabarGymQuiz_1ea92: ld hl, wCurrentMapScriptFlags set 5, [hl] ld a, [hGymGateIndex] - ld [$ffe0], a + ld [hBackupGymGateIndex], a ld hl, CinnabarGymQuizCorrectText call PrintText - ld a, [$ffe0] + ld a, [hBackupGymGateIndex] AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_SET @@ -122,7 +122,7 @@ CinnabarGymQuizCorrectText: TX_BLINK TX_ASM - ld a, [$ffe0] + ld a, [hBackupGymGateIndex] AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_TEST @@ -162,7 +162,7 @@ UpdateCinnabarGymGateTileBlocks_:: ld [wGymGateTileBlock], a push bc ld a, [hGymGateIndex] - ld [$ffe0], a + ld [hBackupGymGateIndex], a AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0 ld c, a ld b, FLAG_TEST diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index 9f19100a..5a658f22 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -15,7 +15,7 @@ PickUpItem: .isMissable ld a, [hl] - ld [$ffdb], a + ld [hMissableObjectIndex], a ld hl, wMapSpriteExtraData ld a, [hSpriteIndexOrTextID] @@ -30,7 +30,7 @@ PickUpItem: call GiveItem jr nc, .BagFull - ld a, [$ffdb] + ld a, [hMissableObjectIndex] ld [wMissableObjectIndex], a predef HideObject ld a, 1 diff --git a/engine/events/saffron_guards.asm b/engine/events/saffron_guards.asm index 02ab92ea..59c2725c 100755 --- a/engine/events/saffron_guards.asm +++ b/engine/events/saffron_guards.asm @@ -2,7 +2,7 @@ RemoveGuardDrink:: ld hl, GuardDrinksList .drinkLoop ld a, [hli] - ld [$ffdb], a + ld [hItemToRemoveID], a and a ret z push hl diff --git a/engine/gfx/oam_dma.asm b/engine/gfx/oam_dma.asm index b0d64675..aeea4c01 100644 --- a/engine/gfx/oam_dma.asm +++ b/engine/gfx/oam_dma.asm @@ -1,12 +1,12 @@ WriteDMACodeToHRAM:: ; Since no other memory is available during OAM DMA, ; DMARoutine is copied to HRAM and executed there. - ld c, $ff80 % $100 + ld c, hDMARoutine % $100 ld b, DMARoutineEnd - DMARoutine ld hl, DMARoutine .copy ld a, [hli] - ld [$ff00+c], a + ldh [c], a inc c dec b jr nz, .copy diff --git a/engine/gfx/screen_effects.asm b/engine/gfx/screen_effects.asm index 95f0ea25..0d3806c1 100755 --- a/engine/gfx/screen_effects.asm +++ b/engine/gfx/screen_effects.asm @@ -19,7 +19,7 @@ PredefShakeScreenVertically: ld [wDisableVBlankWYUpdate], a xor a .loop - ld [$ff96], a + ld [hMutateWY], a call .MutateWY call .MutateWY dec b @@ -30,9 +30,9 @@ PredefShakeScreenVertically: ret .MutateWY - ld a, [$ff96] + ld a, [hMutateWY] xor b - ld [$ff96], a + ld [hMutateWY], a ld [rWY], a ld c, 3 jp DelayFrames @@ -43,7 +43,7 @@ PredefShakeScreenHorizontally: call GetPredefRegisters xor a .loop - ld [$ff97], a + ld [hMutateWX], a call .MutateWX ld c, 1 call DelayFrames @@ -58,9 +58,9 @@ PredefShakeScreenHorizontally: ret .MutateWX - ld a, [$ff97] + ld a, [hMutateWX] xor b - ld [$ff97], a + ld [hMutateWX], a bit 7, a jr z, .skipZeroing xor a ; zero a if it's negative diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index a793ae00..7e2aa227 100755 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -1341,7 +1341,7 @@ ItemUseMedicine: push hl push de ld d, a - callab CalcExperience ; calculate experience for next level and store it at $ff96 + callab CalcExperience ; calculate experience for next level and store it at hExperience pop de pop hl ld bc, wPartyMon1Exp - wPartyMon1Level diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm index 13b92e71..58008a94 100755 --- a/engine/link/cable_club.asm +++ b/engine/link/cable_club.asm @@ -663,7 +663,7 @@ TradeCenter_PrintPartyListNames: push de push hl ld a, c - ld [$ff95], a + ld [hPastLeadingZeros], a call GetMonName pop hl call PlaceString @@ -903,7 +903,7 @@ CableClub_Run: ld [wTilesetGfxPtr + 1], a ld a, l ld [wTilesetGfxPtr], a - ld a, Bank(Club_GFX) + ld a, BANK(Club_GFX) ld [wTilesetBank], a ld hl, Club_Coll ld a, h diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 0b7fb83c..baf656b6 100755 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -566,11 +566,11 @@ ShowPokedexDataInternal: pop hl inc hl ; hl = address of pokedex description text coord bc, 1, 11 - ld a, 2 - ld [$fff4], a + ld a, %10 + ld [hClearLetterPrintingDelayFlags], a call TextCommandProcessor ; print pokedex description text xor a - ld [$fff4], a + ld [hClearLetterPrintingDelayFlags], a .waitForButtonPress call JoypadLowSensitivity ld a, [hJoy5] diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 5aec7bd0..f2ecc3aa 100755 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -601,9 +601,9 @@ GetMonCountsForBoxesInBank: ret SAVCheckRandomID: -;checks if Sav file is the same by checking player's name 1st letter ($a598) +; 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 +; (which are stored at wPlayerID)s ld a, $0a ld [MBC1SRamEnable], a ld a, $01 @@ -702,7 +702,7 @@ ClearSAV: PadSRAM_FF: ld [MBC1SRamBank], a - ld hl, $a000 - ld bc, $2000 + ld hl, $a000 ; start of SRAM + ld bc, $2000 ; size of SRAM ld a, $ff jp FillMemory diff --git a/engine/menus/swap_items.asm b/engine/menus/swap_items.asm index 826fe60b..8b793ea1 100644 --- a/engine/menus/swap_items.asm +++ b/engine/menus/swap_items.asm @@ -77,18 +77,18 @@ HandleItemListSwapping:: cp b jr z, .swapSameItemType .swapDifferentItems - ld [$ff95], a ; [$ff95] = second item ID + ld [hSwapItemID], a ; save second item ID ld a, [hld] - ld [$ff96], a ; [$ff96] = second item quantity + ld [hSwapItemQuantity], a ; save second item quantity ld a, [de] ld [hli], a ; put first item ID in second item slot inc de ld a, [de] ld [hl], a ; put first item quantity in second item slot - ld a, [$ff96] + ld a, [hSwapItemQuantity] ld [de], a ; put second item quantity in first item slot dec de - ld a, [$ff95] + ld a, [hSwapItemID] ld [de], a ; put second item ID in first item slot xor a ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index ea7b84d8..578cf3b2 100755 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -57,7 +57,7 @@ OakSpeech: bit 1, a ; possibly a debug mode bit jp nz, .skipChoosingNames ld de, ProfOakPic - lb bc, Bank(ProfOakPic), $00 + lb bc, BANK(ProfOakPic), $00 call IntroDisplayPicCenteredOrUpperRight call FadeInIntroPic ld hl, OakSpeechText1 @@ -76,7 +76,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, RedPicFront - lb bc, Bank(RedPicFront), $00 + lb bc, BANK(RedPicFront), $00 call IntroDisplayPicCenteredOrUpperRight call MovePicLeft ld hl, IntroducePlayerText @@ -85,7 +85,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, Rival1Pic - lb bc, Bank(Rival1Pic), $00 + lb bc, BANK(Rival1Pic), $00 call IntroDisplayPicCenteredOrUpperRight call FadeInIntroPic ld hl, IntroduceRivalText @@ -95,7 +95,7 @@ OakSpeech: call GBFadeOutToWhite call ClearScreen ld de, RedPicFront - lb bc, Bank(RedPicFront), $00 + lb bc, BANK(RedPicFront), $00 call IntroDisplayPicCenteredOrUpperRight call GBFadeInFromWhite ld a, [wd72d] diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index 5887660e..a19694e0 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -14,14 +14,14 @@ IsPlayerOnDungeonWarp:: set 4, [hl] ret -; if a hidden object was found, stores $00 in [$ffee], else stores $ff +; if a hidden object was found, stores $00 in [hFoundHiddenObject], else stores $ff CheckForHiddenObject:: - ld hl, $ffeb + ld hl, hFoundHiddenObjectOrBookshelf xor a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a + ld [hli], a ; [hFoundHiddenObjectOrBookshelf] + ld [hli], a ; [hSavedMapTextPtr] + ld [hli], a ; [hSavedMapTextPtr + 1] + ld [hl], a ; [hFoundHiddenObject] ld de, $0 ld hl, HiddenObjectMaps .hiddenMapLoop @@ -81,7 +81,7 @@ CheckForHiddenObject:: ret .noMatch ld a, $ff - ld [$ffee], a + ld [hFoundHiddenObject], a ret ; checks if the coordinates in front of the player's sprite match Y in b and X in c diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/missable_objects.asm index 6d365715..a89fcb54 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/missable_objects.asm @@ -120,7 +120,7 @@ IsObjectHidden: .notHidden xor a .hidden - ld [$ffe5], a + ld [hIsHiddenMissableObject], a ret ; adds missable object (items, leg. pokemon, etc.) to the map diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 432ae5ca..6c354779 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -475,7 +475,7 @@ InitializeSpriteScreenPosition: ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ld a, [$ffe5] + ld a, [hIsHiddenMissableObject] and a jp nz, .spriteInvisible ld h, wSpriteStateData2 / $100 @@ -564,7 +564,7 @@ UpdateSpriteImage: ld a, [hl] ; c1x9: facing direction add b ld b, a - ld a, [$ff93] ; current sprite offset + ld a, [hTilePlayerStandingOn] add b ld b, a ld a, [hCurrentSpriteOffset] diff --git a/engine/overworld/player_state.asm b/engine/overworld/player_state.asm index 69b9201f..ea24fdc1 100644 --- a/engine/overworld/player_state.asm +++ b/engine/overworld/player_state.asm @@ -297,7 +297,7 @@ _GetTileAndCoordsInFrontOfPlayer: GetTileTwoStepsInFrontOfPlayer: xor a - ld [$ffdb], a + ld [hPlayerFacing], a ld hl, wYCoord ld a, [hli] ld d, a @@ -306,7 +306,7 @@ GetTileTwoStepsInFrontOfPlayer: and a ; cp SPRITE_FACING_DOWN jr nz, .notFacingDown ; facing down - ld hl, $ffdb + ld hl, hPlayerFacing set 0, [hl] aCoord 8, 13 inc d @@ -315,7 +315,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_UP jr nz, .notFacingUp ; facing up - ld hl, $ffdb + ld hl, hPlayerFacing set 1, [hl] aCoord 8, 5 dec d @@ -324,7 +324,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_LEFT jr nz, .notFacingLeft ; facing left - ld hl, $ffdb + ld hl, hPlayerFacing set 2, [hl] aCoord 4, 9 dec e @@ -333,7 +333,7 @@ GetTileTwoStepsInFrontOfPlayer: cp SPRITE_FACING_RIGHT jr nz, .storeTile ; facing right - ld hl, $ffdb + ld hl, hPlayerFacing set 3, [hl] aCoord 12, 9 inc e @@ -378,33 +378,33 @@ CheckForBoulderCollisionWithSprites: ld hl, wSpriteStateData2 + $14 add hl, de ld a, [hli] ; map Y position - ld [$ffdc], a + ld [hPlayerYCoord], a ld a, [hl] ; map X position - ld [$ffdd], a + ld [hPlayerXCoord], a ld a, [wNumSprites] ld c, a ld de, $f ld hl, wSpriteStateData2 + $14 - ld a, [$ffdb] + ld a, [hPlayerFacing] and $3 ; facing up or down? jr z, .pushingHorizontallyLoop .pushingVerticallyLoop inc hl - ld a, [$ffdd] + ld a, [hPlayerXCoord] cp [hl] jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a - ld a, [$ffdb] + ld a, [hPlayerFacing] rrca jr c, .pushingDown ; pushing up - ld a, [$ffdc] + ld a, [hPlayerYCoord] dec a jr .compareYCoords .pushingDown - ld a, [$ffdc] + ld a, [hPlayerYCoord] inc a .compareYCoords cp b @@ -417,19 +417,19 @@ CheckForBoulderCollisionWithSprites: .pushingHorizontallyLoop ld a, [hli] ld b, a - ld a, [$ffdc] + ld a, [hPlayerYCoord] cp b jr nz, .nextSprite2 ld b, [hl] - ld a, [$ffdb] + ld a, [hPlayerFacing] bit 2, a jr nz, .pushingLeft ; pushing right - ld a, [$ffdd] + ld a, [hPlayerXCoord] inc a jr .compareXCoords .pushingLeft - ld a, [$ffdd] + ld a, [hPlayerXCoord] dec a .compareXCoords cp b diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 43d1759c..c5ff8ebb 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -31,7 +31,7 @@ _UpdateSprites:: UpdateNonPlayerSprite: dec a swap a - ld [$ff93], a ; $10 * sprite# + ld [hTilePlayerStandingOn], a ; $10 * sprite# ld a, [wNPCMovementScriptSpriteOffset] ; some sprite offset? ld b, a ld a, [hCurrentSpriteOffset] @@ -79,7 +79,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff90], a ; store Y coordinate adjusted for direction of movement + ld [hFF90], a ; store Y coordinate adjusted for direction of movement ld a, [hli] ; a = [$c1i5] (delta X) (-1, 0, or 1) call SetSpriteCollisionValues @@ -92,7 +92,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ld [$ff91], a ; store X coordinate adjusted for direction of movement + ld [hFF91], a ; store X coordinate adjusted for direction of movement ld a, l add 7 @@ -102,15 +102,15 @@ DetectCollisionBetweenSprites: ld [hld], a ; zero [$c1id] XXX what's [$c1id] for? ld [hld], a ; zero [$c1ic] (directions in which collisions occurred) - ld a, [$ff91] + ld a, [hFF91] ld [hld], a ; [$c1ib] = adjusted X coordinate - ld a, [$ff90] + ld a, [hFF90] ld [hl], a ; [$c1ia] = adjusted Y coordinate xor a ; zero the loop counter .loop - ld [$ff8f], a ; store loop counter + ld [hFF8F], a ; store loop counter swap a ld e, a ld a, [hCurrentSpriteOffset] @@ -154,7 +154,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry1 - ld [$ff90], a ; store the distance between the two sprites' adjusted Y values + ld [hFF90], a ; store the distance between the two sprites' adjusted Y values ; Use the carry flag set by the above subtraction to determine which sprite's ; Y coordinate is larger. This information is used later to set [$c1ic], @@ -176,11 +176,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next1 - ld a, [$ff90] ; a = distance between adjusted Y coordinates + ld a, [hFF90] ; a = distance between adjusted Y coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff90], a ; store 7 or 9 depending on sprite i's delta Y + ld [hFF90], a ; store 7 or 9 depending on sprite i's delta Y jr c, .checkXDistance ; If sprite j's delta Y is 0, then b = 7, else b = 9. @@ -193,7 +193,7 @@ DetectCollisionBetweenSprites: ld b, 9 .next2 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .checkXDistance jr nc, .next ; go to next sprite if distance is still positive after both adjustments @@ -225,7 +225,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry2 - ld [$ff91], a ; store the distance between the two sprites' adjusted X values + ld [hFF91], a ; store the distance between the two sprites' adjusted X values ; Use the carry flag set by the above subtraction to determine which sprite's ; X coordinate is larger. This information is used later to set [$c1ic], @@ -247,11 +247,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next3 - ld a, [$ff91] ; a = distance between adjusted X coordinates + ld a, [hFF91] ; a = distance between adjusted X coordinates sub b - ld [$ff92], a ; store distance adjusted using sprite i's direction + ld [hFF92], a ; store distance adjusted using sprite i's direction ld a, b - ld [$ff91], a ; store 7 or 9 depending on sprite i's delta X + ld [hFF91], a ; store 7 or 9 depending on sprite i's delta X jr c, .collision ; If sprite j's delta X is 0, then b = 7, else b = 9. @@ -264,15 +264,15 @@ DetectCollisionBetweenSprites: ld b, 9 .next4 - ld a, [$ff92] ; a = distance adjusted using sprite i's direction + ld a, [hFF92] ; a = distance adjusted using sprite i's direction sub b ; adjust distance using sprite j's direction jr z, .collision jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision - ld a, [$ff91] ; a = 7 or 9 depending on sprite i's delta X + ld a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ld a, [$ff90] ; a = 7 or 9 depending on sprite i's delta Y + ld a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y inc l ; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. @@ -294,7 +294,7 @@ DetectCollisionBetweenSprites: ; set bit in [$c1ie] or [$c1if] to indicate which sprite the collision occurred with inc l inc l - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter ld de, SpriteCollisionBitTable add a add e @@ -311,7 +311,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ld a, [$ff8f] ; a = loop counter + ld a, [hFF8F] ; a = loop counter inc a cp $10 jp nz, .loop diff --git a/engine/overworld/tilesets.asm b/engine/overworld/tilesets.asm index d6b8221c..88147233 100644 --- a/engine/overworld/tilesets.asm +++ b/engine/overworld/tilesets.asm @@ -25,7 +25,7 @@ LoadTilesetHeader: ld a, [hl] ld [hTilesetType], a xor a - ld [$ffd8], a + ld [hMovingBGTilesCounter1], a pop hl ld a, [wCurMapTileset] push hl diff --git a/engine/overworld/trainer_sight.asm b/engine/overworld/trainer_sight.asm index f0ea7266..81978c35 100755 --- a/engine/overworld/trainer_sight.asm +++ b/engine/overworld/trainer_sight.asm @@ -5,16 +5,16 @@ _GetSpritePosition1:: ld [hSpriteIndex], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) - ld [$ffeb], a + ld [hSpriteScreenYCoord], a inc hl ld a, [hl] ; c1x6 (screen X pos) - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6) add hl, de ld a, [hli] ; c2x4 (map Y pos) - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, [hl] ; c2x5 (map X pos) - ld [$ffee], a + ld [hSpriteMapXCoord], a ret _GetSpritePosition2:: @@ -42,16 +42,16 @@ _SetSpritePosition1:: ld a, [wSpriteIndex] ld [hSpriteIndex], a call GetSpriteDataPointer - ld a, [$ffeb] ; c1x4 (screen Y pos) + ld a, [hSpriteScreenYCoord] ; c1x4 (screen Y pos) ld [hli], a inc hl - ld a, [$ffec] ; c1x6 (screen X pos) + ld a, [hSpriteScreenXCoord] ; c1x6 (screen X pos) ld [hl], a ld de, (wSpriteStateData2 + $4) - (wSpriteStateData1 + $6) add hl, de - ld a, [$ffed] ; c2x4 (map Y pos) + ld a, [hSpriteMapYCoord] ; c2x4 (map Y pos) ld [hli], a - ld a, [$ffee] ; c2x5 (map X pos) + ld a, [hSpriteMapXCoord] ; c2x5 (map X pos) ld [hl], a ret diff --git a/engine/overworld/update_map.asm b/engine/overworld/update_map.asm index c494065c..92ae2b10 100644 --- a/engine/overworld/update_map.asm +++ b/engine/overworld/update_map.asm @@ -63,7 +63,7 @@ RedrawMapView: ld a, [hli] ld h, [hl] ld l, a - ld de, -2 * 32 + ld de, -2 * BG_MAP_WIDTH add hl, de ld a, h and $3 @@ -73,23 +73,23 @@ RedrawMapView: ld a, h ld [wBuffer + 1], a ; this copy of the address is not used ld a, 2 - ld [$ffbe], a - ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen) + ld [hRedrawMapViewRowOffset], a + ld c, SCREEN_HEIGHT / 2 ; number of rows of 2x2 tiles (this covers the whole screen) .redrawRowLoop push bc push hl push hl ld hl, wTileMap - 2 * SCREEN_WIDTH ld de, SCREEN_WIDTH - ld a, [$ffbe] + ld a, [hRedrawMapViewRowOffset] .calcWRAMAddrLoop add hl, de dec a jr nz, .calcWRAMAddrLoop call CopyToRedrawRowOrColumnSrcTiles pop hl - ld de, $20 - ld a, [$ffbe] + ld de, BG_MAP_WIDTH + ld a, [hRedrawMapViewRowOffset] ld c, a .calcVRAMAddrLoop add hl, de @@ -104,7 +104,7 @@ RedrawMapView: ld a, REDRAW_ROW ld [hRedrawRowOrColumnMode], a call DelayFrame - ld hl, $ffbe + ld hl, hRedrawMapViewRowOffset inc [hl] inc [hl] pop hl @@ -199,7 +199,7 @@ LoadFrontSpriteByMonIndex:: pop hl ld a, [hLoadedROMBank] push af - ld a, Bank(CopyUncompressedPicToHL) + ld a, BANK(CopyUncompressedPicToHL) ld [hLoadedROMBank], a ld [MBC1RomBank], a xor a @@ -832,7 +832,7 @@ UpdateSprites:: ret nz ld a, [hLoadedROMBank] push af - ld a, Bank(_UpdateSprites) + ld a, BANK(_UpdateSprites) ld [hLoadedROMBank], a ld [MBC1RomBank], a call _UpdateSprites @@ -1104,7 +1104,7 @@ DisplayPokemartDialogue:: ld [wListMenuID], a ld a, [hLoadedROMBank] push af - ld a, Bank(DisplayPokemartDialogue_) + ld a, BANK(DisplayPokemartDialogue_) ld [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemartDialogue_ @@ -1136,14 +1136,14 @@ LoadItemList:: DisplayPokemonCenterDialogue:: ; zeroing these doesn't appear to serve any purpose xor a - ld [$ff8b], a - ld [$ff8c], a - ld [$ff8d], a + ld [hItemPrice], a + ld [hItemPrice + 1], a + ld [hItemPrice + 2], a inc hl ld a, [hLoadedROMBank] push af - ld a, Bank(DisplayPokemonCenterDialogue_) + ld a, BANK(DisplayPokemonCenterDialogue_) ld [hLoadedROMBank], a ld [MBC1RomBank], a call DisplayPokemonCenterDialogue_ @@ -2794,7 +2794,7 @@ GetTrainerInformation:: ld a, [wLinkState] and a jr nz, .linkBattle - ld a, Bank(TrainerPicAndMoneyPointers) + ld a, BANK(TrainerPicAndMoneyPointers) call BankswitchHome ld a, [wTrainerClass] dec a @@ -3185,12 +3185,12 @@ GetName:: ld hl, NamePointers add hl, de ld a, [hli] - ld [$ff96], a + ld [hSwapTemp + 1], a ld a, [hl] - ld [$ff95], a - ld a, [$ff95] + ld [hSwapTemp], a + ld a, [hSwapTemp] ld h, a - ld a, [$ff96] + ld a, [hSwapTemp + 1] ld l, a ld a, [wd0b5] ld b, a @@ -3258,7 +3258,7 @@ GetItemPrice:: ld [hItemPrice], a jr .done .getTMPrice - ld a, Bank(GetMachinePrice) + ld a, BANK(GetMachinePrice) ld [hLoadedROMBank], a ld [MBC1RomBank], a call GetMachinePrice @@ -3409,7 +3409,7 @@ Divide:: push bc ld a, [hLoadedROMBank] push af - ld a, Bank(_Divide) + ld a, BANK(_Divide) ld [hLoadedROMBank], a ld [MBC1RomBank], a call _Divide @@ -3552,11 +3552,11 @@ CalcStat:: call Multiply ld a, [hld] ld d, a - ld a, [$ff98] + ld a, [hProduct + 3] sub d ld a, [hli] ld d, a - ld a, [$ff97] + ld a, [hProduct + 2] sbc d ; test if (current stat exp bonus)^2 < stat exp jr c, .statExpLoop .statExpDone @@ -4497,11 +4497,11 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: bit 0, a ; A button jr z, .nothingFound ; A button is pressed - ld a, Bank(CheckForHiddenObject) + ld a, BANK(CheckForHiddenObject) ld [MBC1RomBank], a ld [hLoadedROMBank], a call CheckForHiddenObject - ld a, [$ffee] + ld a, [hFoundHiddenObject] and a jr nz, .hiddenObjectNotFound ld a, [wHiddenObjectFunctionRomBank] @@ -4515,13 +4515,13 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: jr .done .hiddenObjectNotFound callba PrintBookshelfText - ld a, [$ffdb] + ld a, [hFFDB] and a jr z, .done .nothingFound ld a, $ff .done - ld [$ffeb], a + ld [hFoundHiddenObjectOrBookshelf], a pop af ld [MBC1RomBank], a ld [hLoadedROMBank], a @@ -4537,17 +4537,17 @@ PrintPredefTextID:: RestoreMapTextPointer:: ld hl, wMapTextPtr - ld a, [$ffec] + ld a, [hSavedMapTextPtr] ld [hli], a - ld a, [$ffec + 1] + ld a, [hSavedMapTextPtr + 1] ld [hl], a ret SetMapTextPointer:: ld a, [wMapTextPtr] - ld [$ffec], a + ld [hSavedMapTextPtr], a ld a, [wMapTextPtr + 1] - ld [$ffec + 1], a + ld [hSavedMapTextPtr + 1], a ld a, l ld [wMapTextPtr], a ld a, h diff --git a/home/init.asm b/home/init.asm index efc886e0..48294fa6 100644 --- a/home/init.asm +++ b/home/init.asm @@ -53,13 +53,13 @@ rLCDC_DEFAULT EQU %11100011 call ClearVram - ld hl, $ff80 - ld bc, $ffff - $ff80 + ld hl, $ff80 ; start of HRAM + ld bc, $ffff - $ff80 ; size of HRAM call FillMemory call ClearSprites - ld a, Bank(WriteDMACodeToHRAM) + ld a, BANK(WriteDMACodeToHRAM) ld [hLoadedROMBank], a ld [MBC1RomBank], a call WriteDMACodeToHRAM diff --git a/home/overworld.asm b/home/overworld.asm index 9fb269dc..c959beb6 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -88,7 +88,7 @@ OverworldLoopLessDelay:: call IsPlayerCharacterBeingControlledByGame jr nz, .checkForOpponent call CheckForHiddenObjectOrBookshelfOrCardKeyDoor - ld a, [$ffeb] + ld a, [hFoundHiddenObjectOrBookshelf] and a jp z, OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found call IsSpriteOrSignInFrontOfPlayer @@ -762,7 +762,7 @@ HandleBlackOut:: call StopMusic ld hl, wd72e res 5, [hl] - ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) + ld a, BANK(ResetStatusAndHalveMoneyOnBlackout) ; also BANK(SpecialWarpIn) and BANK(SpecialEnterMap) ld [hLoadedROMBank], a ld [MBC1RomBank], a call ResetStatusAndHalveMoneyOnBlackout @@ -793,7 +793,7 @@ HandleFlyWarpOrDungeonWarp:: set 2, [hl] ; fly warp or dungeon warp res 5, [hl] ; forced to ride bike call LeaveMapAnim - ld a, Bank(SpecialWarpIn) + ld a, BANK(SpecialWarpIn) ld [hLoadedROMBank], a ld [MBC1RomBank], a call SpecialWarpIn @@ -2388,14 +2388,14 @@ SwitchToMapRomBank:: push bc ld c, a ld b, $00 - ld a, Bank(MapHeaderBanks) + ld a, BANK(MapHeaderBanks) call BankswitchHome ; switch to ROM bank 3 ld hl, MapHeaderBanks add hl, bc ld a, [hl] - ld [$ffe8], a ; save map ROM bank + ld [hMapROMBank], a ; save map ROM bank call BankswitchBack - ld a, [$ffe8] + ld a, [hMapROMBank] ld [hLoadedROMBank], a ld [MBC1RomBank], a ; switch to map ROM bank pop bc diff --git a/home/text.asm b/home/text.asm index 89c93dd0..0d2ed0a2 100644 --- a/home/text.asm +++ b/home/text.asm @@ -365,7 +365,7 @@ TextCommandProcessor:: push af set 1, a ld e, a - ld a, [$fff4] + ld a, [hClearLetterPrintingDelayFlags] xor e ld [wLetterPrintingDelayFlags], a ld a, c diff --git a/home/vblank.asm b/home/vblank.asm index e8232ea3..78f5f69d 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -26,7 +26,7 @@ VBlank:: call VBlankCopy call VBlankCopyDouble call UpdateMovingBgTiles - call $ff80 ; hOAMDMA + call hDMARoutine ld a, BANK(PrepareOAMData) ld [hLoadedROMBank], a ld [MBC1RomBank], a @@ -1,3 +1,5 @@ +hDMARoutine EQU $FF80 + hSoftReset EQU $FF8A ; Initialized to 16. ; Decremented each input iteration if the player @@ -81,6 +83,11 @@ hOAMBufferOffset EQU $FF90 hSpriteScreenX EQU $FF91 hSpriteScreenY EQU $FF92 +hFF8F EQU $FF8F +hFF90 EQU $FF90 +hFF91 EQU $FF91 +hFF92 EQU $FF92 + hTilePlayerStandingOn EQU $FF93 hSpritePriority EQU $FF94 @@ -90,14 +97,20 @@ hSignCoordPointer EQU $FF95 hNPCMovementDirections2Index EQU $FF95 +hSwapItemID EQU $FF95 +hSwapItemQuantity EQU $FF96 + ; CalcPositionOfPlayerRelativeToNPC hNPCSpriteOffset EQU $FF95 -; temp value used when swapping bytes +; temp value used when swapping bytes or words hSwapTemp EQU $FF95 hExperience EQU $FF96 ; 3 bytes, big endian +hMutateWY EQU $FF96 +hMutateWX EQU $FF97 + ; Multiplication and division variables are meant ; to overlap for back-to-back usage. Big endian. @@ -204,6 +217,8 @@ hAutoBGTransferPortion EQU $FFBB ; the destination address of the automatic background transfer hAutoBGTransferDest EQU $FFBC ; 2 bytes +hRedrawMapViewRowOffset EQU $FFBE + ; temporary storage for stack pointer during memory transfers that use pop ; to increase speed hSPTemp EQU $FFBF ; 2 bytes @@ -272,7 +287,8 @@ hCurrentSpriteOffset EQU $FFDA ; multiple of $10 hItemCounter EQU $FFDB -hGymGateIndex EQU $FFDB +hGymGateIndex EQU $FFDB +hGymGateAnswer EQU $FFDC hGymTrashCanRandNumMask EQU $FFDB @@ -285,33 +301,64 @@ hDexRatingNumMonsOwned EQU $FFDC ; $FF = player cancelled hOaksAideResult EQU $FFDB +hSavedCoordIndex EQU $FFDB + hOaksAideRequirement EQU $FFDB ; required number of owned mons hOaksAideRewardItem EQU $FFDC hOaksAideNumMonsOwned EQU $FFDD +hPlayerFacing EQU $FFDB +hPlayerYCoord EQU $FFDC +hPlayerXCoord EQU $FFDD + +hMissableObjectIndex EQU $FFDB + hItemToRemoveID EQU $FFDB hItemToRemoveIndex EQU $FFDC hVendingMachineItem EQU $FFDB hVendingMachinePrice EQU $FFDC ; 3-byte BCD number +hFFDB EQU $FFDB +hFFDC EQU $FFDC + +hBackupGymGateIndex EQU $FFE0 + +hUnlockedSilphCoDoors EQU $FFE0 + ; the first tile ID in a sequence of tile IDs that increase by 1 each step hStartTileID EQU $FFE1 hNewPartyLength EQU $FFE4 +hIsHiddenMissableObject EQU $FFE5 + hDividend2 EQU $FFE5 hDivisor2 EQU $FFE6 hQuotient2 EQU $FFE7 +hMapROMBank EQU $FFE8 + hSpriteVRAMSlotAndFacing EQU $FFE9 hCoordsInFrontOfPlayerMatch EQU $FFEA hSpriteAnimFrameCounter EQU $FFEA +hSpriteScreenYCoord EQU $FFEB +hSpriteScreenXCoord EQU $FFEC +hSpriteMapYCoord EQU $FFED +hSpriteMapXCoord EQU $FFEE + +hFoundHiddenObjectOrBookshelf EQU $FFEB +hFoundHiddenObject EQU $FFEE + +hSavedMapTextPtr EQU $FFEC + hWhoseTurn EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn +hClearLetterPrintingDelayFlags EQU $FFF4 + ; bit 0: draw HP fraction to the right of bar instead of below (for party menu) ; bit 1: menu is double spaced hFlagsFFF6 EQU $FFF6 diff --git a/scripts/BikeShop.asm b/scripts/BikeShop.asm index 71149759..2661ca70 100755 --- a/scripts/BikeShop.asm +++ b/scripts/BikeShop.asm @@ -23,7 +23,7 @@ BikeShopText1: call GiveItem jr nc, .BagFull ld a, BIKE_VOUCHER - ld [$ffdb], a + ld [hItemToRemoveID], a callba RemoveItemByID SetEvent EVENT_GOT_BICYCLE ld hl, BikeShopText_1d824 diff --git a/scripts/BillsHouse.asm b/scripts/BillsHouse.asm index 0c8ca4de..395694a3 100755 --- a/scripts/BillsHouse.asm +++ b/scripts/BillsHouse.asm @@ -66,13 +66,13 @@ BillsHouseScript3: ld a, $2 ld [wSpriteIndex], a ld a, $c - ld [$ffeb], a + ld [hSpriteScreenYCoord], a ld a, $40 - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld a, $6 - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, $5 - ld [$ffee], a + ld [hSpriteMapXCoord], a call SetSpritePosition1 ld a, HS_BILL_1 ld [wMissableObjectIndex], a diff --git a/scripts/CinnabarGym.asm b/scripts/CinnabarGym.asm index 1e92505a..08bbbe8b 100755 --- a/scripts/CinnabarGym.asm +++ b/scripts/CinnabarGym.asm @@ -96,7 +96,7 @@ CinnabarGymScript2: cp $ff jp z, CinnabarGymScript_75792 ld a, [wTrainerHeaderFlagBit] - ld [$ffdb], a + ld [hGymGateIndex], a AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 ld c, a ld b, FLAG_TEST @@ -111,7 +111,7 @@ CinnabarGymScript2: call WaitForSoundToFinish .asm_7581b ld a, [wTrainerHeaderFlagBit] - ld [$ffdb], a + ld [hGymGateIndex], a AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2 ld c, a ld b, FLAG_SET diff --git a/scripts/CopycatsHouse2F.asm b/scripts/CopycatsHouse2F.asm index b43234c3..64612535 100755 --- a/scripts/CopycatsHouse2F.asm +++ b/scripts/CopycatsHouse2F.asm @@ -29,7 +29,7 @@ CopycatsHouse2FText1: ld hl, ReceivedTM31Text call PrintText ld a, POKE_DOLL - ld [$ffdb], a + ld [hItemToRemoveID], a callba RemoveItemByID SetEvent EVENT_GOT_TM31 jr .asm_62ecd diff --git a/scripts/OaksLab.asm b/scripts/OaksLab.asm index a0383246..9bb84923 100755 --- a/scripts/OaksLab.asm +++ b/scripts/OaksLab.asm @@ -672,9 +672,9 @@ OaksLabScript_RemoveParcel: OaksLabScript_1d02b: ld a, $7c - ld [$ffeb], a + ld [hSpriteScreenYCoord], a ld a, $8 - ld [$ffee], a + ld [hSpriteMapXCoord], a ld a, [wYCoord] cp $3 jr nz, .asm_1d045 @@ -703,9 +703,9 @@ OaksLabScript_1d02b: .asm_1d066 ld a, $20 .asm_1d068 - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld a, b - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, $1 ld [wSpriteIndex], a call SetSpritePosition1 diff --git a/scripts/PewterCity.asm b/scripts/PewterCity.asm index 1b658242..86037c13 100755 --- a/scripts/PewterCity.asm +++ b/scripts/PewterCity.asm @@ -58,13 +58,13 @@ PewterCityScript1: ld [hSpriteIndexOrTextID], a call DisplayTextID ld a, $3c - ld [$ffeb], a + ld [hSpriteScreenYCoord], a ld a, $30 - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld a, $c - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, $11 - ld [$ffee], a + ld [hSpriteMapXCoord], a ld a, $3 ld [wSpriteIndex], a call SetSpritePosition1 @@ -126,13 +126,13 @@ PewterCityScript4: ld [hSpriteIndexOrTextID], a call DisplayTextID ld a, $3c - ld [$ffeb], a + ld [hSpriteScreenYCoord], a ld a, $40 - ld [$ffec], a + ld [hSpriteScreenXCoord], a ld a, $16 - ld [$ffed], a + ld [hSpriteMapYCoord], a ld a, $10 - ld [$ffee], a + ld [hSpriteMapXCoord], a ld a, $5 ld [wSpriteIndex], a call SetSpritePosition1 diff --git a/scripts/Route5Gate.asm b/scripts/Route5Gate.asm index bc763dfd..e5d86b97 100755 --- a/scripts/Route5Gate.asm +++ b/scripts/Route5Gate.asm @@ -27,7 +27,7 @@ Route5GateScript0: xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ffdb] + ld a, [hItemToRemoveID] and a jr nz, .asm_1df82 ld a, $2 @@ -74,7 +74,7 @@ Route5GateText1: bit 6, a jr nz, .asm_88856 callba RemoveGuardDrink - ld a, [$ffdb] + ld a, [hItemToRemoveID] and a jr nz, .asm_768a2 ld hl, Route5GateText2 diff --git a/scripts/Route6Gate.asm b/scripts/Route6Gate.asm index 348f61ac..6b00eddb 100755 --- a/scripts/Route6Gate.asm +++ b/scripts/Route6Gate.asm @@ -21,7 +21,7 @@ Route6GateScript0: xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ffdb] + ld a, [hItemToRemoveID] and a jr nz, .asm_1e080 ld a, $2 diff --git a/scripts/Route7Gate.asm b/scripts/Route7Gate.asm index 724172c5..06c5c91b 100755 --- a/scripts/Route7Gate.asm +++ b/scripts/Route7Gate.asm @@ -33,7 +33,7 @@ Route7GateScript0: xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ffdb] + ld a, [hItemToRemoveID] and a jr nz, .asm_1e15a ld a, $2 diff --git a/scripts/Route8Gate.asm b/scripts/Route8Gate.asm index 8ecea68e..80b8b9a4 100755 --- a/scripts/Route8Gate.asm +++ b/scripts/Route8Gate.asm @@ -32,7 +32,7 @@ Route8GateScript0: xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ffdb] + ld a, [hItemToRemoveID] and a jr nz, .asm_1e220 ld a, $2 diff --git a/scripts/SSAnne2F.asm b/scripts/SSAnne2F.asm index 203e9711..face08d8 100755 --- a/scripts/SSAnne2F.asm +++ b/scripts/SSAnne2F.asm @@ -31,7 +31,7 @@ SSAnne2Script0: ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, [wCoordIndex] - ld [$ffdb], a + ld [hSavedCoordIndex], a ld a, HS_SS_ANNE_2F_RIVAL ld [wMissableObjectIndex], a predef ShowObject @@ -43,7 +43,7 @@ SSAnne2Script0: ld [hJoyHeld], a ld a, $f0 ld [wJoyIgnore], a - ld a, [$ffdb] + ld a, [hSavedCoordIndex] cp $2 jr nz, .asm_61400 ld de, MovementData_6140c diff --git a/scripts/SSAnneCaptainsRoom.asm b/scripts/SSAnneCaptainsRoom.asm index 5723c32d..6078ccf0 100755 --- a/scripts/SSAnneCaptainsRoom.asm +++ b/scripts/SSAnneCaptainsRoom.asm @@ -51,7 +51,7 @@ SSAnne7RubText: ld a, SFX_STOP_ALL_MUSIC ld [wNewSoundID], a call PlaySound - ld a, Bank(Music_PkmnHealed) + ld a, BANK(Music_PkmnHealed) ld [wAudioROMBank], a .asm_61908 ld a, MUSIC_PKMN_HEALED diff --git a/scripts/SilphCo10F.asm b/scripts/SilphCo10F.asm index 40506682..92d95de1 100755 --- a/scripts/SilphCo10F.asm +++ b/scripts/SilphCo10F.asm @@ -28,7 +28,7 @@ SilphCo10GateCoords: db $FF SilphCo10Text_5a176: - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_10_UNLOCKED_DOOR diff --git a/scripts/SilphCo11F.asm b/scripts/SilphCo11F.asm index 2f9d7924..116b528f 100755 --- a/scripts/SilphCo11F.asm +++ b/scripts/SilphCo11F.asm @@ -35,14 +35,14 @@ SilphCo11Script_62137: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_62143 ld a, [hli] cp $ff jr z, .asm_6215f push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -60,11 +60,11 @@ SilphCo11Script_62137: ret .asm_6215f xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo11Script_62163: - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_11_UNLOCKED_DOOR diff --git a/scripts/SilphCo2F.asm b/scripts/SilphCo2F.asm index 5fd542cb..0ff7cee3 100755 --- a/scripts/SilphCo2F.asm +++ b/scripts/SilphCo2F.asm @@ -45,14 +45,14 @@ SilphCo2Script_59d43: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_59d4f ld a, [hli] cp $ff jr z, .asm_59d6b push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -70,12 +70,12 @@ SilphCo2Script_59d43: ret .asm_59d6b xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo2Script_59d6f: EventFlagAddress hl, EVENT_SILPH_CO_2_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo3F.asm b/scripts/SilphCo3F.asm index 42b5d611..3b6b1da8 100755 --- a/scripts/SilphCo3F.asm +++ b/scripts/SilphCo3F.asm @@ -39,7 +39,7 @@ SilphCo3GateCoords: SilphCo3Script_59fad: EventFlagAddress hl, EVENT_SILPH_CO_3_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo4F.asm b/scripts/SilphCo4F.asm index 7d5072f6..61288277 100755 --- a/scripts/SilphCo4F.asm +++ b/scripts/SilphCo4F.asm @@ -45,14 +45,14 @@ SilphCo4Script_19d5d: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_19d69 ld a, [hli] cp $ff jr z, .asm_19d85 push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -70,12 +70,12 @@ SilphCo4Script_19d5d: ret .asm_19d85 xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo4Script_19d89: EventFlagAddress hl, EVENT_SILPH_CO_4_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo5F.asm b/scripts/SilphCo5F.asm index d9deda5b..39d7235b 100755 --- a/scripts/SilphCo5F.asm +++ b/scripts/SilphCo5F.asm @@ -49,7 +49,7 @@ SilphCo5GateCoords: SilphCo5Script_19f9e: EventFlagAddress hl, EVENT_SILPH_CO_5_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo6F.asm b/scripts/SilphCo6F.asm index ddbcba79..9e6ffaf1 100755 --- a/scripts/SilphCo6F.asm +++ b/scripts/SilphCo6F.asm @@ -28,7 +28,7 @@ SilphCo6GateCoords: db $FF SilphCo6Script_1a1e6: - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_6_UNLOCKED_DOOR diff --git a/scripts/SilphCo7F.asm b/scripts/SilphCo7F.asm index 97dd09ea..4966bba6 100755 --- a/scripts/SilphCo7F.asm +++ b/scripts/SilphCo7F.asm @@ -55,14 +55,14 @@ SilphCo7Text_51bc8: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_51bd4 ld a, [hli] cp $ff jr z, .asm_51bf0 push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -80,12 +80,12 @@ SilphCo7Text_51bc8: ret .asm_51bf0 xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo7Text_51bf4: EventFlagAddress hl, EVENT_SILPH_CO_7_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/SilphCo8F.asm b/scripts/SilphCo8F.asm index ce6579f7..b1c32a34 100755 --- a/scripts/SilphCo8F.asm +++ b/scripts/SilphCo8F.asm @@ -35,14 +35,14 @@ SilphCo8Script_56541: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_5654d ld a, [hli] cp $ff jr z, .asm_56569 push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -60,11 +60,11 @@ SilphCo8Script_56541: ret .asm_56569 xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo8Script_5656d: - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z SetEvent EVENT_SILPH_CO_8_UNLOCKED_DOOR diff --git a/scripts/SilphCo9F.asm b/scripts/SilphCo9F.asm index 66291e98..d9fdc625 100755 --- a/scripts/SilphCo9F.asm +++ b/scripts/SilphCo9F.asm @@ -65,14 +65,14 @@ SilphCo9Script_5d837: ld a, [hl] ld c, a xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a pop hl .asm_5d843 ld a, [hli] cp $ff jr z, .asm_5d85f push hl - ld hl, $ffe0 + ld hl, hUnlockedSilphCoDoors inc [hl] pop hl cp b @@ -90,12 +90,12 @@ SilphCo9Script_5d837: ret .asm_5d85f xor a - ld [$ffe0], a + ld [hUnlockedSilphCoDoors], a ret SilphCo9Script_5d863: EventFlagAddress hl, EVENT_SILPH_CO_9_UNLOCKED_DOOR1 - ld a, [$ffe0] + ld a, [hUnlockedSilphCoDoors] and a ret z cp $1 diff --git a/scripts/ViridianCity.asm b/scripts/ViridianCity.asm index 643431a4..c3eb9a79 100755 --- a/scripts/ViridianCity.asm +++ b/scripts/ViridianCity.asm @@ -59,14 +59,14 @@ ViridianCityScript_1903d: ret ViridianCityScript1: - ld a, [wSpriteStateData1 + $34] - ld [$ffeb], a - ld a, [wSpriteStateData1 + $36] - ld [$ffec], a - ld a, [wSpriteStateData2 + $34] - ld [$ffed], a - ld a, [wSpriteStateData2 + $35] - ld [$ffee], a + ld a, [wSprite03StateData1YPixels] + ld [hSpriteScreenYCoord], a + ld a, [wSprite03StateData1XPixels] + ld [hSpriteScreenXCoord], a + ld a, [wSprite03StateData2MapY] + ld [hSpriteMapYCoord], a + ld a, [wSprite03StateData2MapX] + ld [hSpriteMapXCoord], a xor a ld [wListScrollOffset], a @@ -82,14 +82,14 @@ ViridianCityScript1: ret ViridianCityScript2: - ld a, [$ffeb] - ld [wSpriteStateData1 + $34], a - ld a, [$ffec] - ld [wSpriteStateData1 + $36], a - ld a, [$ffed] - ld [wSpriteStateData2 + $34], a - ld a, [$ffee] - ld [wSpriteStateData2 + $35], a + ld a, [hSpriteScreenYCoord] + ld [wSprite03StateData1YPixels], a + ld a, [hSpriteScreenXCoord] + ld [wSprite03StateData1XPixels], a + ld a, [hSpriteMapYCoord] + ld [wSprite03StateData2MapY], a + ld a, [hSpriteMapXCoord] + ld [wSprite03StateData2MapX], a call UpdateSprites call Delay3 xor a diff --git a/scripts/WardensHouse.asm b/scripts/WardensHouse.asm index e6ca47b2..015d137f 100755 --- a/scripts/WardensHouse.asm +++ b/scripts/WardensHouse.asm @@ -32,7 +32,7 @@ FuchsiaHouse2Text1: ld hl, WardenTeethText1 call PrintText ld a, GOLD_TEETH - ld [$ffdb], a + ld [hItemToRemoveID], a callba RemoveItemByID SetEvent EVENT_GAVE_GOLD_TEETH .asm_60cba @@ -1985,7 +1985,7 @@ wSpriteOutputBitOffset:: ; determines where in the output byte the two bits are ds 1 wSpriteLoadFlags:: -; bit 0 determines used buffer (0 -> $a188, 1 -> $a310) +; bit 0 determines used buffer (0 -> sSpriteBuffer1, 1 -> sSpriteBuffer2) ; bit 1 loading last sprite chunk? (there are at most 2 chunks per load operation) ds 1 wSpriteUnpackMode:: |