From 91793015e53dbed09576f825d39e71bc59bf90a5 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Tue, 9 Sep 2014 20:55:19 -0700 Subject: Labelled and commented mostly sprite-related things --- scripts/oakslab.asm | 130 ++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) (limited to 'scripts/oakslab.asm') diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index fb56aade..faf86f1a 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -35,7 +35,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) ld a, [wd74b] bit 7, a ret z - ld a, [wcf10] + ld a, [wNPCMovementScriptFunctionNum] and a ret nz ld a, $31 @@ -50,7 +50,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) OaksLabScript1: ; 1cb6e (7:4b6e) ld a, $8 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld de, OakEntryMovement call MoveSprite @@ -78,22 +78,22 @@ OaksLabScript2: ; 1cb82 (7:4b82) OaksLabScript3: ; 1cba2 (7:4ba2) call Delay3 - ld hl, wccd3 + ld hl, wSimulatedJoypadStatesEnd ld de, PlayerEntryMovementRLE call DecodeRLEList dec a - ld [wcd38], a - call Func_3486 + ld [wSimulatedJoypadStatesIndex], a + call StartSimulatingJoypadStates ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $4 ld [W_OAKSLABCURSCRIPT], a @@ -103,7 +103,7 @@ PlayerEntryMovementRLE: ; 1cbcf (7:4bcf) db $40, $8, $ff OaksLabScript4: ; 1cbd2 (7:4bd2) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz ld hl, wd747 @@ -111,14 +111,14 @@ OaksLabScript4: ; 1cbd2 (7:4bd2) ld hl, wd74b set 0, [hl] ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call UpdateSprites ld hl, W_FLAGS_D733 res 1, [hl] - call Func_2307 + call PlayDefaultMusic ld a, $5 ld [W_OAKSLABCURSCRIPT], a @@ -156,24 +156,24 @@ OaksLabScript6: ; 1cc36 (7:4c36) cp $6 ret nz ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call UpdateSprites ld a, $c ld [$ff8c], a call DisplayTextID ld a, $1 - ld [wcd38], a + ld [wSimulatedJoypadStatesIndex], a ld a, $40 - ld [wccd3], a - call Func_3486 + ld [wSimulatedJoypadStatesEnd], a + call StartSimulatingJoypadStates ld a, $8 ld [wd528], a @@ -182,7 +182,7 @@ OaksLabScript6: ; 1cc36 (7:4c36) ret OaksLabScript7: ; 1cc72 (7:4c72) - ld a, [wcd38] + ld a, [wSimulatedJoypadStatesIndex] and a ret nz call Delay3 @@ -231,10 +231,10 @@ OaksLabScript8: ; 1cc80 (7:4c80) jr nz, .asm_1ccf3 ; 0x1cccd $24 push hl ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 push hl ld [hl], $4c inc hl @@ -256,7 +256,7 @@ OaksLabScript8: ; 1cc80 (7:4c80) .asm_1ccf3 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a call MoveSprite ld a, $9 @@ -270,10 +270,10 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld a, $fc ld [wJoyIgnore], a ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $d ld [$ff8c], a call DisplayTextID @@ -299,10 +299,10 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld [wd11e], a call GetMonName ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $e ld [$ff8c], a call DisplayTextID @@ -320,10 +320,10 @@ OaksLabScript10: ; 1cd6d (7:4d6d) cp $6 ret nz ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $8 ld [wd528], a ld c, BANK(Music_MeetRival) @@ -337,14 +337,14 @@ OaksLabScript10: ; 1cd6d (7:4d6d) ld a, $1 swap a ld [$ff95], a - predef Func_f929 + predef CalcPositionOfPlayerRelativeToNPC ld a, [$ff95] dec a ld [$ff95], a - predef Func_f8ba - ld de, wcc97 + predef FindPathToPlayer + ld de, wNPCMovementDirections2 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a call MoveSprite ld a, $b @@ -375,7 +375,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) ld [W_TRAINERNO], a ld a, $1 ld [wcf13], a - call Func_32ef + call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 call PreBattleSaveRegisters @@ -398,12 +398,12 @@ OaksLabScript12: ; 1ce03 (7:4e03) call UpdateSprites ld a, $1 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay predef HealParty ld hl, wd74b set 3, [hl] @@ -420,7 +420,7 @@ OaksLabScript13: ; 1ce32 (7:4e32) call DisplayTextID callba Music_RivalAlternateStart ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld de, .RivalExitMovement call MoveSprite ld a, [W_XCOORD] @@ -450,7 +450,7 @@ OaksLabScript14: ; 1ce6d (7:4e6d) predef HideObject xor a ld [wJoyIgnore], a - call Func_2307 ; reset to map music + call PlayDefaultMusic ; reset to map music ld a, $12 ld [W_OAKSLABCURSCRIPT], a jr .done ; 0x1ce8a $23 @@ -491,17 +491,17 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) ld a, $2a ld [wcc4d], a predef ShowObject - ld a, [wcd37] + ld a, [wNPCMovementDirections2Index] ld [wd157], a ld b, $0 ld c, a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 ld a, $40 call FillMemory ld [hl], $ff ld a, $1 - ld [$ff8c], a - ld de, wcc97 + ld [H_SPRITEINDEX], a + ld de, wNPCMovementDirections2 call MoveSprite ld a, $10 @@ -510,22 +510,22 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) OaksLabScript_1cefd ; 1cefd (7:4efd) ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $4 ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay ld a, $8 - ld [$ff8c], a + ld [H_SPRITEINDEX], a xor a ld [$ff8d], a - jp Func_34a6 ; face object + jp SetSpriteFacingDirectionAndDelay OaksLabScript16: ; 1cf12 (7:4f12) ld a, [wd730] bit 0, a ret nz call EnableAutoTextBoxDrawing - call Func_2307 + call PlayDefaultMusic ld a, $fc ld [wJoyIgnore], a call OaksLabScript_1cefd @@ -558,10 +558,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) ld [$ff8c], a call DisplayTextID ld a, $1 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $c ld [$ff8d], a - call Func_34a6 ; face object + call SetSpriteFacingDirectionAndDelay call Delay3 ld a, $1b ld [$ff8c], a @@ -579,7 +579,7 @@ OaksLabScript16: ; 1cf12 (7:4f12) ld a, [wd157] ld b, $0 ld c, a - ld hl, wcc97 + ld hl, wNPCMovementDirections2 xor a call FillMemory ld [hl], $ff @@ -588,8 +588,8 @@ OaksLabScript16: ; 1cf12 (7:4f12) call PlaySound callba Music_RivalAlternateStart ld a, $1 - ld [$ff8c], a - ld de, wcc97 + ld [H_SPRITEINDEX], a + ld de, wNPCMovementDirections2 call MoveSprite ld a, $11 @@ -600,7 +600,7 @@ OaksLabScript17: ; 1cfd4 (7:4fd4) ld a, [wd730] bit 0, a ret nz - call Func_2307 + call PlayDefaultMusic ld a, $2a ld [wcc4d], a predef HideObject @@ -652,7 +652,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) cp $3 jr nz, .asm_1d045 ; 0x1d038 $b ld a, $4 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld a, $30 ld b, $b jr .asm_1d068 ; 0x1d043 $23 @@ -660,13 +660,13 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) cp $1 jr nz, .asm_1d054 ; 0x1d047 $b ld a, $2 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld a, $30 ld b, $9 jr .asm_1d068 ; 0x1d052 $14 .asm_1d054 ld a, $3 - ld [wcd37], a + ld [wNPCMovementDirections2Index], a ld b, $a ld a, [W_XCOORD] cp $4 @@ -681,7 +681,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) ld [$ffed], a ld a, $1 ld [wcf13], a - call Func_32f9 + call SetSpritePosition1 ret OaksLabScript_1d076: ; 1d076 (7:5076) @@ -817,17 +817,17 @@ OaksLabText39: ; 1d152 (7:5152) OaksLabScript_1d157: ; 1d157 (7:5157) ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $0 ; manually fixed some disassembler issues around here ld a, $1 - ld [$FF8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $c ld hl, wd730 set 6, [hl] @@ -924,10 +924,10 @@ OaksLabReceivedMonText: ; 1d227 (7:5227) OaksLabScript_1d22d: ; 1d22d (7:522d) ld a, $5 - ld [$ff8c], a + ld [H_SPRITEINDEX], a ld a, $9 ld [$ff8b], a - call Func_34fc + call GetPointerWithinSpriteStateData1 ld [hl], $0 ld hl, OaksLabLastMonText call PrintText -- cgit v1.3.1-sl0p From 0c916aea3353ed1bf2750be403b0da9ea0b922d4 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 13 Sep 2014 00:50:56 -0700 Subject: Commented more sprite and map code --- data/special_warps.asm | 3 + engine/battle/14.asm | 2 +- engine/battle/1c.asm | 2 +- engine/battle/4_2.asm | 4 +- engine/battle/animations.asm | 6 +- engine/battle/core.asm | 14 +- engine/battle/d.asm | 2 +- engine/cable_club.asm | 4 +- engine/evos_moves.asm | 2 +- engine/give_pokemon.asm | 2 +- engine/hall_of_fame.asm | 8 +- engine/hidden_object_functions14.asm | 2 +- engine/hidden_object_functions17.asm | 2 +- engine/hidden_object_functions18.asm | 2 +- engine/hidden_object_functions3.asm | 2 +- engine/hidden_object_functions7.asm | 8 +- engine/in_game_trades.asm | 2 +- engine/intro.asm | 2 +- engine/items/items.asm | 40 +-- engine/menu/diploma.asm | 2 +- engine/menu/league_pc.asm | 6 +- engine/menu/main_menu.asm | 27 +- engine/menu/naming_screen.asm | 8 +- engine/menu/pc.asm | 2 +- engine/menu/players_pc.asm | 2 +- engine/menu/start_menu.asm | 4 +- engine/menu/start_sub_menus.asm | 10 +- engine/mon_party_sprites.asm | 2 +- engine/oak_speech.asm | 18 +- engine/overworld/card_key.asm | 4 +- engine/overworld/cut.asm | 10 +- engine/overworld/doors.asm | 4 +- engine/overworld/emotion_bubbles.asm | 6 +- engine/overworld/healing_machine.asm | 2 +- engine/overworld/hidden_items.asm | 4 +- engine/overworld/hidden_objects.asm | 4 +- engine/overworld/item.asm | 2 +- engine/overworld/ledges.asm | 50 +-- engine/overworld/npc_movement.asm | 20 +- engine/overworld/oam.asm | 4 +- engine/overworld/player_animations.asm | 346 +++++++++--------- engine/overworld/pokemart.asm | 2 +- engine/overworld/ssanne.asm | 6 +- engine/overworld/trainers.asm | 12 +- engine/palettes.asm | 4 +- engine/predefs.asm | 14 +- engine/predefs12.asm | 13 +- engine/predefs7.asm | 2 +- engine/slot_machine.asm | 8 +- engine/town_map.asm | 8 +- engine/trade.asm | 4 +- home.asm | 52 +-- home/audio.asm | 2 +- home/fade.asm | 22 +- home/init.asm | 2 +- home/overworld.asm | 236 ++++++------- home/predef.asm | 2 +- main.asm | 621 +++++++++++++++++---------------- scripts/billshouse.asm | 2 +- scripts/celadongamecorner.asm | 6 +- scripts/celadongym.asm | 2 +- scripts/celadonmansion3.asm | 2 +- scripts/celadonmartelevator.asm | 6 +- scripts/celadonmartroof.asm | 2 +- scripts/ceruleancity.asm | 6 +- scripts/ceruleancity2.asm | 4 +- scripts/ceruleangym.asm | 2 +- scripts/ceruleanhouse2.asm | 4 +- scripts/cinnabargym.asm | 4 +- scripts/copycatshouse2f.asm | 2 +- scripts/daycarem.asm | 2 +- scripts/fightingdojo.asm | 2 +- scripts/fuchsiagym.asm | 2 +- scripts/mansion1.asm | 2 +- scripts/mansion2.asm | 2 +- scripts/mansion3.asm | 8 +- scripts/mtmoon3.asm | 8 +- scripts/museum1f.asm | 4 +- scripts/namerater.asm | 2 +- scripts/oakslab.asm | 22 +- scripts/pallettown.asm | 4 +- scripts/pewtercity.asm | 12 +- scripts/pewtergym.asm | 2 +- scripts/pewtermart.asm | 2 +- scripts/pewterpokecenter.asm | 2 +- scripts/pokemontower5.asm | 4 +- scripts/pokemontower7.asm | 12 +- scripts/redshouse1f.asm | 4 +- scripts/rockethideout4.asm | 6 +- scripts/rockethideoutelevator.asm | 6 +- scripts/route12gateupstairs.asm | 2 +- scripts/route22.asm | 4 +- scripts/route24.asm | 2 +- scripts/saffrongym.asm | 2 +- scripts/seafoamislands1.asm | 2 +- scripts/seafoamislands2.asm | 2 +- scripts/seafoamislands3.asm | 2 +- scripts/seafoamislands4.asm | 2 +- scripts/seafoamislands5.asm | 4 +- scripts/silphco11.asm | 6 +- scripts/silphco9.asm | 4 +- scripts/silphcoelevator.asm | 6 +- scripts/ssanne9.asm | 4 +- scripts/vermiliondock.asm | 8 +- scripts/vermiliongym.asm | 2 +- scripts/victoryroad3.asm | 2 +- scripts/viridiangym.asm | 8 +- wram.asm | 169 +++++++-- 108 files changed, 1091 insertions(+), 946 deletions(-) (limited to 'scripts/oakslab.asm') diff --git a/data/special_warps.asm b/data/special_warps.asm index 418b57f2..480bac89 100755 --- a/data/special_warps.asm +++ b/data/special_warps.asm @@ -1,3 +1,6 @@ +; Format: (size 2 bytes) +; 00: target map ID +; 01: which dungeon warp in the source map was used DungeonWarpList: ; 63bf (1:63bf) db SEAFOAM_ISLANDS_2,$01 db SEAFOAM_ISLANDS_2,$02 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 01a8f48a..530032a0 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -15,7 +15,7 @@ Func_525af: ; 525af (14:65af) ld [wPartyGainExpFlags], a ld [wPlayerMonNumber], a ; wPlayerMonNumber ld [wEscapedFromBattle], a - ld [wd35d], a + ld [wMapPalOffset], a ld hl, wcf1d ld [hli], a ld [hl], a diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 3f23a27c..1c69c00f 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -89,7 +89,7 @@ BattleTransition: ; 7096d (1c:496d) xor a ld [hVBlankWY], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call DelayFrame ld hl, wSpriteStateData1 + 2 ld a, [H_DOWNARROWBLINKCNT2] diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 79594bdd..133acdcc 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -71,7 +71,7 @@ EndOfBattle: ; 137aa (4:77aa) call WaitForSoundToFinish call GBPalWhiteOut ld a, $ff - ld [wd42f], a + ld [wDestinationWarpID], a ret YouWinText: ; 13853 (4:7853) @@ -94,7 +94,7 @@ Func_13870: ; 13870 (4:7870) ld a, [wd736] and a ret nz - callab Func_c49d + callab IsPlayerStandingOnDoorTileOrWarpTile jr nc, .asm_13888 .asm_13884 ld a, $1 diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index a094b34c..15d94f05 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -517,7 +517,7 @@ Func_78e01: ; 78e01 (1e:4e01) ret Func_78e23: ; 78e23 (1e:4e23) - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, $e4 jr z, .asm_78e47 @@ -1091,7 +1091,7 @@ CallWithTurnFlipped: ; 79155 (1e:5155) AnimationFlashScreenLong: ; 79165 (1e:5165) ld a,3 ; cycle through the palettes 3 times ld [wd08a],a - ld a,[wcf1b] ; running on SGB? + ld a,[wOnSGB] ; running on SGB? and a ld hl,FlashScreenLongMonochrome jr z,.loop @@ -1211,7 +1211,7 @@ Func_791f9: ; 791f9 (1e:51f9) ld bc, $4040 Func_791fc: ; 791fc (1e:51fc) - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, b jr z, .asm_79204 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 4b1ceedd..26465b8f 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -139,7 +139,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld [$ffd7], a ld [hVBlankSCY], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a @@ -6247,7 +6247,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [wMenuJoypadPollCount], a callab DisplayLinkBattleVersusTextBox ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearScreen .next call DelayFrame @@ -6256,7 +6256,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearSprites call ClearScreen xor a @@ -6729,16 +6729,16 @@ asm_3ef23: ; 3ef23 (f:6f23) bit 1, a jr z, .asm_3ef2f ld a, [hJoyHeld] - bit 1, a + bit 1, a ; B button pressed? ret nz .asm_3ef2f - ld a, [wd13c] + ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz callab Func_13870 ret nz asm_3ef3d: ; 3ef3d (f:6f3d) - ld a, [wd35d] + ld a, [wMapPalOffset] push af ld hl, wd358 ld a, [hl] @@ -6849,7 +6849,7 @@ InitBattle_Common: ; 3efeb (f:6feb) pop af ld [wd358], a pop af - ld [wd35d], a + ld [wMapPalOffset], a ld a, [wd0d4] ld [$ffd7], a scf diff --git a/engine/battle/d.asm b/engine/battle/d.asm index dcd58ec4..94a07eb6 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -17,7 +17,7 @@ DisplayLinkBattleVersusTextBox: ; 372d6 (d:72d6) ld [hli], a ld [hl], $6a xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a callab SetupPlayerAndEnemyPokeballs ld c, 150 jp DelayFrames diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 8cb70cbf..9b4017e2 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -570,13 +570,13 @@ Func_577d: ; 577d (1:577d) xor a ld [wd72d], a dec a - ld [wd42f], a + ld [wDestinationWarpID], a call LoadMapData callba Func_c335 pop hl pop af ld [hl], a - call GBFadeIn2 + call GBFadeInFromWhite ret Func_57a2: diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 61ddb4e7..240fd9fa 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -127,7 +127,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ClearSprites callab Func_7bde9 jp c, CancelledEvolution diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index dd5e9264..d4d45bfb 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -43,7 +43,7 @@ _GivePokemon: ; 4fda5 (13:7da5) call SetPokedexOwnedFlag call AddPartyMon ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld [wccd3], a scf ret diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index dd988cf1..30ae6266 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -18,7 +18,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld bc, HOF_TEAM call FillMemory xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [$ffd7], a ld [W_SPRITEFLIPPED], a ld [wd358], a @@ -66,7 +66,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call PlaceString ld c, 180 call DelayFrames - call GBFadeOut2 + call GBFadeOutToWhite pop bc pop hl jr .asm_701fb @@ -125,7 +125,7 @@ Func_70278: ; 70278 (1c:4278) call Func_7036d ld d, $a0 ld e, $4 - ld a, [wcf1b] + ld a, [wOnSGB] and a jr z, .asm_702c7 sla e @@ -282,4 +282,4 @@ Func_70423: ; 70423 (1c:4423) ld [wcfc9], a ld a, $ff ld [wMusicHeaderPointer], a - jp GBFadeOut2 + jp GBFadeOutToWhite diff --git a/engine/hidden_object_functions14.asm b/engine/hidden_object_functions14.asm index 0d3598f2..a162c905 100755 --- a/engine/hidden_object_functions14.asm +++ b/engine/hidden_object_functions14.asm @@ -1,7 +1,7 @@ PrintNotebookText: ; 52996 (14:6996) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wTrainerSpriteOffset] jp PrintPredefTextID diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index fccd4267..f1a07542 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -89,7 +89,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wWhichTrade] call PrintPredefTextID ret diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 5ccb43c2..9dd7fac7 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -181,7 +181,7 @@ OpenPokemonCenterPC: ; 62516 (18:6516) ret nz call EnableAutoTextBoxDrawing ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ld a, $1f ; PredefText1f jp PrintPredefTextID diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index 11b91cd3..09d9ebcc 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -114,7 +114,7 @@ TownMapText: ; fc12 (3:7c12) db $06 db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd730 set 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 07cf5651..c00749e4 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -83,7 +83,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0) ld a, $9c ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $3 - ld [wd42f], a + ld [wDestinationWarpID], a ld a, $5 ld [W_SAFARIZONEENTRANCECURSCRIPT], a ld hl, wd790 @@ -152,7 +152,7 @@ CinnabarGymQuiz: ; 1ea25 (7:6a25) ld l, a call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call CinnabarGymQuiz_1ea92 jp TextScriptEnd @@ -334,7 +334,7 @@ BillsHousePC: ; 1eb6e (7:6b6e) jp PrintPredefTextID .asm_1eb8b ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $2e call PrintPredefTextID ld c, $20 @@ -363,7 +363,7 @@ BillsHousePC: ; 1eb6e (7:6b6e) ret .asm_1ebd2 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $2f call PrintPredefTextID ret diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index ad9de8b1..4f232eb4 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -88,7 +88,7 @@ Func_71c07: ; 71c07 (1c:5c07) xor a ld [wd07d],a dec a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu push af call Func_71ca2 diff --git a/engine/intro.asm b/engine/intro.asm index 801324a5..68bf8b50 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -5,7 +5,7 @@ PlayIntro: ; 41682 (10:5682) ld [H_AUTOBGTRANSFERENABLED], a call PlayShootingStar call PlayIntroScene - call GBFadeOut2 + call GBFadeOutToWhite xor a ld [$ffae], a ld [H_AUTOBGTRANSFERENABLED], a diff --git a/engine/items/items.asm b/engine/items/items.asm index 860479e7..b2bff822 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -507,8 +507,8 @@ ItemUseBicycle: ; d977 (3:5977) ld a,[W_ISINBATTLE] and a jp nz,ItemUseNotTime - ld a,[wd700] - ld [wd11a],a + ld a,[wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy],a cp a,2 ; is the player surfing? jp z,ItemUseNotTime dec a ; is player already bicycling? @@ -516,7 +516,7 @@ ItemUseBicycle: ; d977 (3:5977) .getOffBike call ItemUseReloadOverworldData xor a - ld [wd700],a ; change player state to walking + ld [wWalkBikeSurfState],a ; change player state to walking call PlayDefaultMusic ; play walking music ld hl,GotOffBicycleText jr .printText @@ -527,7 +527,7 @@ ItemUseBicycle: ; d977 (3:5977) xor a ; no keys pressed ld [hJoyHeld],a ; current joypad state inc a - ld [wd700],a ; change player state to bicycling + ld [wWalkBikeSurfState],a ; change player state to bicycling ld hl,GotOnBicycleText call PlayDefaultMusic ; play bike riding music .printText @@ -535,8 +535,8 @@ ItemUseBicycle: ; d977 (3:5977) ; used for Surf out-of-battle effect ItemUseSurfboard: ; d9b4 (3:59b4) - ld a,[wd700] - ld [wd11a],a + ld a,[wWalkBikeSurfState] + ld [wWalkBikeSurfStateCopy],a cp a,2 ; is the player already surfing? jr z,.tryToStopSurfing .tryToSurf @@ -550,7 +550,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld hl,wd730 set 7,[hl] ld a,2 - ld [wd700],a ; change player state to surfing + ld [wWalkBikeSurfState],a ; change player state to surfing call PlayDefaultMusic ; play surfing music ld hl,SurfingGotOnText jp PrintText @@ -570,7 +570,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld a,[hli] ld h,[hl] ld l,a ; hl now points to passable tiles - ld a,[wcfc6] ; tile in front of the player + ld a,[wTileInFrontOfPlayer] ; tile in front of the player ld b,a .passableTileLoop ld a,[hli] @@ -586,7 +586,7 @@ ItemUseSurfboard: ; d9b4 (3:59b4) ld hl,wd730 set 7,[hl] xor a - ld [wd700],a ; change player state to walking + ld [wWalkBikeSurfState],a ; change player state to walking dec a ld [wJoyIgnore],a call PlayDefaultMusic ; play walking music @@ -636,7 +636,7 @@ ItemUseEvoStone: ; da5b (3:5a5b) ld a,$05 ; evolution stone party menu ld [wd07d],a ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu pop bc jr c,.canceledItemUse @@ -681,7 +681,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,$01 ld [wd07d],a ; item use party menu ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,[wd152] and a ; using Softboiled? jr z,.notUsingSoftboiled @@ -1096,7 +1096,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [H_AUTOBGTRANSFERENABLED],a call ClearScreen dec a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call RedrawPartyMenu ; redraws the party menu and displays the message ld a,1 ld [H_AUTOBGTRANSFERENABLED],a @@ -1278,7 +1278,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [wccd4],a callab TryEvolvingMon ; evolve pokemon, if appropriate ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a pop af ld [wcf91],a pop af @@ -1424,8 +1424,8 @@ ItemUseXAccuracy: ; e013 (3:6013) ItemUseCardKey: ; e022 (3:6022) xor a ld [wd71f],a - call Func_c586 - ld a,[Func_c586] ; $4586 + call GetTileAndCoordsInFrontOfPlayer + ld a,[GetTileAndCoordsInFrontOfPlayer] ; $4586 cp a,$18 jr nz,.next0 ld hl,CardKeyTable1 @@ -1796,7 +1796,7 @@ RodResponse: ; e28d (3:628d) ld [W_CUROPPONENT], a .next - ld hl, wd700 + ld hl, wWalkBikeSurfState ld a, [hl] ; store the value in a push af push hl @@ -1818,7 +1818,7 @@ FishingInit: ; e2b4 (3:62b4) .notInBattle call IsNextTileShoreOrWater ret c - ld a,[wd700] + ld a,[wWalkBikeSurfState] cp a,2 ; Surfing? jr z,.surfing call ItemUseReloadOverworldData @@ -1877,7 +1877,7 @@ ItemUsePPRestore: ; e31e (3:631e) ld [wWhichTrade],a .chooseMon xor a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,$01 ; item use party menu ld [wd07d],a call DisplayPartyMenu @@ -2117,7 +2117,7 @@ ItemUseTMHM: ; e479 (3:6479) ld bc,14 call CopyData ld a,$ff - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,$03 ; teach TM/HM party menu ld [wd07d],a call DisplayPartyMenu @@ -2744,7 +2744,7 @@ IsNextTileShoreOrWater: ; e8b8 (3:68b8) jr nc, .notShoreOrWater ld a, [W_CURMAPTILESET] cp SHIP_PORT ; Vermilion Dock tileset - ld a, [wcfc6] ; tile in front of player + ld a, [wTileInFrontOfPlayer] ; tile in front of player jr z, .skipShoreTiles ; if it's the Vermilion Dock tileset cp $48 ; eastern shore tile in Safari Zone jr z, .shoreOrWater diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index adf4c396..95b2a87d 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -3,7 +3,7 @@ DisplayDiploma: ; 566e2 (15:66e2) call GBPalWhiteOutWithDelay3 call ClearScreen xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] call DisableLCD diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index 4833e57d..ffde236a 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -4,14 +4,14 @@ PKMNLeaguePC: ; 0x7657e ld hl, wd730 set 6, [hl] push hl - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, [$ffD7] push af xor a ld [$ffD7], a ld [W_SPRITEFLIPPED], a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wTrainerScreenX], a ld [wcd42], a ld a, [wd5a2] @@ -40,7 +40,7 @@ PKMNLeaguePC: ; 0x7657e pop af ld [$ffD7], a pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a pop hl res 6, [hl] call GBPalWhiteOutWithDelay3 diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 4044da43..6ffc6249 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -111,16 +111,16 @@ MainMenu: ; 5af2 (1:5af2) call DelayFrames ld a,[wd5a2] and a - jp z,Func_5d5f + jp z,SpecialEnterMap ld a,[W_CURMAP] ; map ID cp a,HALL_OF_FAME - jp nz,Func_5d5f + jp nz,SpecialEnterMap xor a - ld [wd71a],a + ld [wDestinationMap],a ld hl,wd732 - set 2,[hl] - call Func_62ce - jp Func_5d5f + set 2,[hl] ; fly warp or dungeon warp + call SpecialWarpIn + jp SpecialEnterMap Func_5bff: ; 5bff (1:5bff) ld a,1 ld [wd358],a @@ -247,7 +247,7 @@ LinkMenu: ; 5c0a (1:5c0a) cp $2 jr z, .asm_5d2d xor a - ld [wd700], a + ld [wWalkBikeSurfState], a ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a ld a, TRADE_CENTER @@ -262,8 +262,8 @@ LinkMenu: ; 5c0a (1:5c0a) ld hl, wd732 res 1, [hl] ld a, [W_ANIMATIONID] ; W_ANIMATIONID - ld [wd71a], a - call Func_62ce + ld [wDestinationMap], a + call SpecialWarpIn ld c, $14 call DelayFrames xor a @@ -272,7 +272,7 @@ LinkMenu: ; 5c0a (1:5c0a) inc a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE ld [wcc47], a - jr Func_5d5f + jr SpecialEnterMap .asm_5d2d xor a ld [wMenuJoypadPollCount], a ; wMenuJoypadPollCount @@ -303,16 +303,17 @@ Func_5d52: ; 5d52 (1:5d52) ld c, $14 call DelayFrames -Func_5d5f: ; 5d5f (1:5d5f) +; enter map after using a special warp or loading the game from the main menu +SpecialEnterMap: ; 5d5f (1:5d5f) xor a ld [hJoyPressed], a ld [hJoyHeld], a ld [$ffb5], a ld [wd72d], a ld hl, wd732 - set 0, [hl] + set 0, [hl] ; count play time call ResetPlayerSpriteData - ld c, $14 + ld c, 20 call DelayFrames ld a, [wcc47] and a diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index f7fc883c..b7db452a 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -22,10 +22,10 @@ AskName: ; 64eb (1:64eb) ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a jr nz, .asm_654c - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a push hl ld a, $2 ld [wd07d], a @@ -38,7 +38,7 @@ AskName: ; 64eb (1:64eb) call LoadScreenTilesFromBuffer1 pop hl pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, [wcf4b] cp $50 ret nz @@ -56,7 +56,7 @@ DoYouWantToNicknameText: ; 0x6557 Func_655c: ; 655c (1:655c) ld hl, wHPBarMaxHP xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, $2 ld [wd07d], a call DisplayNamingScreen diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm index 4df6c826..97895ca6 100755 --- a/engine/menu/pc.asm +++ b/engine/menu/pc.asm @@ -86,7 +86,7 @@ BillsPC: ; 17ee4 (5:7ee4) callba BillsPC_ ReloadMainMenu: ; 17f06 (5:7f06) xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call ReloadMapData call UpdateSprites ;XXX: moves sprites jp PCMainMenu diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 4ff1b16f..5f1175eb 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -78,7 +78,7 @@ Func_796d: ; 796d (1:796d) ld hl, wd730 res 6, [hl] xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret Func_7995: ; 7995 (1:7995) diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index be172a67..da17822b 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -2,8 +2,8 @@ DisplayStartMenu:: ; 2acd (0:2acd) ld a,$04 ; hardcoded Bank, not sure what's it refers to ld [H_LOADEDROMBANK],a ld [$2000],a ; ROM bank 4 - ld a,[wd700] ; walking/biking/surfing - ld [wd11a],a + ld a,[wWalkBikeSurfState] ; walking/biking/surfing + ld [wWalkBikeSurfStateCopy],a ld a, (SFX_02_3f - SFX_Headers_02) / 3 ; Start menu sound call PlaySound diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index e774565a..e91386b0 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -13,7 +13,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) xor a ld [wMenuItemToSwap],a ld [wd07d],a - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call DisplayPartyMenu jr .checkIfPokemonChosen .loop @@ -184,7 +184,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) bit 0,a ; does the player have the Boulder Badge? jp z,.newBadgeRequired xor a - ld [wd35d],a + ld [wMapPalOffset],a ld hl,.flashLightsAreaText call PrintText call GBPalWhiteOutWithDelay3 @@ -406,7 +406,7 @@ StartMenu_Item: ; 13302 (4:7302) jp z,ItemMenuLoop jp CloseStartMenu .useItem_partyMenu - ld a,[wcfcb] + ld a,[wUpdateSpritesEnabled] push af call UseItem ld a,[wcd6a] @@ -415,11 +415,11 @@ StartMenu_Item: ; 13302 (4:7302) call GBPalWhiteOutWithDelay3 call RestoreScreenTilesAndReloadTilePatterns pop af - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a jp StartMenu_Item .partyMenuNotDisplayed pop af - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a jp ItemMenuLoop .tossItem call IsKeyItem diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index e05bdd55..5fa5c3bc 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -21,7 +21,7 @@ GetAnimationSpeed: ; 7170a (1c:570a) ld c, a ld hl, PartyMonSpeeds add hl, bc - ld a, [wcf1b] + ld a, [wOnSGB] xor $1 add [hl] ld c, a diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index e54741f2..518bea2a 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -49,8 +49,8 @@ OakSpeech: ; 6115 (1:6115) ld [wcf96],a call AddItemToInventory ; give one potion ld a,[W_ANIMATIONID] - ld [wd71a],a - call Func_62ce + ld [wDestinationMap],a + call SpecialWarpIn xor a ld [$FFD7],a ld a,[wd732] @@ -62,7 +62,7 @@ OakSpeech: ; 6115 (1:6115) call FadeInIntroPic ld hl,OakSpeechText1 call PrintText ; prints text box - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld a,NIDORINO ld [wd0b5],a ; pic displayed is stored at this location @@ -73,7 +73,7 @@ OakSpeech: ; 6115 (1:6115) call MovePicLeft ld hl,OakSpeechText2 call PrintText ; Prints text box - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,RedPicFront ld bc,(Bank(RedPicFront) << 8) | $00 @@ -82,7 +82,7 @@ OakSpeech: ; 6115 (1:6115) ld hl,IntroducePlayerText call PrintText call LoadDefaultNamesPlayer ; brings up NewName/Red/etc menu - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,Rival1Pic ld bc,(Bank(Rival1Pic) << 8) | $00 @@ -93,12 +93,12 @@ OakSpeech: ; 6115 (1:6115) call LoadDefaultNamesRival Func_61bc: ; 61bc (1:61bc) - call GBFadeOut2 + call GBFadeOutToWhite call ClearScreen ld de,RedPicFront ld bc,(Bank(RedPicFront) << 8) | $00 call IntroPredef3B - call GBFadeIn2 + call GBFadeInFromWhite ld a,[wd72d] and a jr nz,.next @@ -148,10 +148,10 @@ Func_61bc: ; 61bc (1:61bc) call ClearScreenArea call LoadTextBoxTilePatterns ld a,1 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld c,$32 call DelayFrames - call GBFadeOut2 + call GBFadeOutToWhite jp ClearScreen OakSpeechText1: ; 6253 (1:6253) TX_FAR _OakSpeechText1 diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index f48c26f4..885932d5 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -8,8 +8,8 @@ PrintCardKeyText: ; 52673 (14:6673) ret z cp b jr nz, .asm_5267a - predef Func_c586 - ld a, [wcfc6] + predef GetTileAndCoordsInFrontOfPlayer + ld a, [wTileInFrontOfPlayer] cp $18 jr z, .asm_5269c cp $24 diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 59abe791..0cbc0214 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -6,13 +6,13 @@ UsedCut: ; ef54 (3:6f54) jr z, .asm_ef6b cp GYM jr nz, .asm_ef77 - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $50 ; gym cut tree jr nz, .asm_ef77 jr asm_ef82 .asm_ef6b dec a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $3d ; cut tree jr z, asm_ef82 cp $52 ; grass @@ -52,14 +52,14 @@ asm_ef82: ; ef82 (3:6f82) ld hl, wd730 res 6, [hl] ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call AnimateCutTree ld de, CutTreeBlockSwaps ; $7100 call Func_f09f call Func_eedc callba Func_79e96 ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, (SFX_02_56 - SFX_Headers_02) / 3 call PlaySound ld a, $90 @@ -178,7 +178,7 @@ Func_f09f: ; f09f (3:709f) ld c, a ld b, $0 ld d, $0 - ld hl, wd35f + ld hl, wCurrentTileBlockMapViewPointer ld a, [hli] ld h, [hl] ld l, a diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index 85ff58b2..ac345af9 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -1,5 +1,5 @@ -; returns whether the player is standing on a door in carry -IsPlayerStandingOnDoor: ; 1a609 (6:6609) +; returns whether the player is standing on a door tile in carry +IsPlayerStandingOnDoorTile: ; 1a609 (6:6609) push de ld hl, DoorTileIDPointers ; $662c ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index ae7702b4..7106063b 100755 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -11,10 +11,10 @@ EmotionBubble: ; 17c47 (5:7c47) ld hl, vChars1 + $780 ld bc, (BANK(EmotionBubblesPointerTable) << 8) + $04 call CopyVideoData - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, [wd736] bit 6, a ld hl, wOAMBuffer + $8f @@ -51,7 +51,7 @@ EmotionBubble: ; 17c47 (5:7c47) ld c, $3c call DelayFrames pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call DelayFrame jp UpdateSprites diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index 9c93583d..53174630 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -3,7 +3,7 @@ AnimateHealingMachine: ; 70433 (1c:4433) ld hl, vChars0 + $7c0 ld bc, (BANK(PokeCenterFlashingMonitorAndHealBall) << 8) + $03 call CopyVideoData - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index 77bd8fe6..befe2935 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -12,7 +12,7 @@ HiddenItems: ; 76688 (1d:6688) ret nz call EnableAutoTextBoxDrawing ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, [wWhichTrade] ; item ID ld [wd11e], a call GetItemName @@ -42,7 +42,7 @@ FoundHiddenItemText: ; 7675b (1d:675b) .BagFull call WaitForTextScrollButtonPress ; wait for button press xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, HiddenItemBagFullText call PrintText jp TextScriptEnd diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index d2114293..1be5170c 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -1,13 +1,13 @@ Func_46981: ; 46981 (11:6981) xor a - ld [wd71e], a + ld [wWhichDungeonWarp], a ld a, [wd72d] bit 4, a ret nz call ArePlayerCoordsInArray ret nc ld a, [wWhichTrade] ; wWhichTrade - ld [wd71e], a + ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] ld hl, wd732 diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm index a69ec106..a49fc268 100644 --- a/engine/overworld/item.asm +++ b/engine/overworld/item.asm @@ -34,7 +34,7 @@ PickupItem: ld [wcc4d], a predef HideObject ld a, 1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, FoundItemText jr .print diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index 21e1b567..b8c19181 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -1,48 +1,48 @@ HandleLedges: ; 1a672 (6:6672) ld a, [wd736] - bit 6, a + bit 6, a ; already jumping down ledge ret nz ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET and a ; OVERWORLD ret nz - predef Func_c586 + predef GetTileAndCoordsInFrontOfPlayer ld a, [wSpriteStateData1 + 9] ld b, a aCoord 8, 9 ld c, a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] ld d, a - ld hl, LedgeTiles ; $66cf -.asm_1a691 + ld hl, LedgeTiles +.loop ld a, [hli] cp $ff ret z cp b - jr nz, .asm_1a6a4 + jr nz, .nextLedgeTile1 ld a, [hli] cp c - jr nz, .asm_1a6a5 + jr nz, .nextLedgeTile2 ld a, [hli] cp d - jr nz, .asm_1a6a6 + jr nz, .nextLedgeTile3 ld a, [hl] ld e, a - jr .asm_1a6a9 -.asm_1a6a4 + jr .foundMatch +.nextLedgeTile1 inc hl -.asm_1a6a5 +.nextLedgeTile2 inc hl -.asm_1a6a6 +.nextLedgeTile3 inc hl - jr .asm_1a691 -.asm_1a6a9 + jr .loop +.foundMatch ld a, [hJoyHeld] and e ret z ld a, $ff ld [wJoyIgnore], a ld hl, wd736 - set 6, [hl] + set 6, [hl] ; jumping down ledge call StartSimulatingJoypadStates ld a, e ld [wSimulatedJoypadStatesEnd], a @@ -56,24 +56,24 @@ HandleLedges: ; 1a672 (6:6672) ; (player direction) (tile player standing on) (ledge tile) (input required) LedgeTiles: ; 1a6cf (6:66cf) - db $00,$2C,$37,$80 - db $00,$39,$36,$80 - db $00,$39,$37,$80 - db $08,$2C,$27,$20 - db $08,$39,$27,$20 - db $0C,$2C,$0D,$10 - db $0C,$2C,$1D,$10 - db $0C,$39,$0D,$10 + db SPRITE_FACING_DOWN, $2C,$37,D_DOWN + db SPRITE_FACING_DOWN, $39,$36,D_DOWN + db SPRITE_FACING_DOWN, $39,$37,D_DOWN + db SPRITE_FACING_LEFT, $2C,$27,D_LEFT + db SPRITE_FACING_LEFT, $39,$27,D_LEFT + db SPRITE_FACING_RIGHT,$2C,$0D,D_RIGHT + db SPRITE_FACING_RIGHT,$2C,$1D,D_RIGHT + db SPRITE_FACING_RIGHT,$39,$0D,D_RIGHT db $FF LoadHoppingShadowOAM: ; 1a6f0 (6:66f0) ld hl, vChars1 + $7f0 - ld de, LedgeHoppingShadow ; $6708 + ld de, LedgeHoppingShadow ld bc, (BANK(LedgeHoppingShadow) << 8) + $01 call CopyVideoDataDouble ld a, $9 ld bc, $5448 ; b, c = y, x coordinates of shadow - ld de, LedgeHoppingShadowOAM ; $6710 + ld de, LedgeHoppingShadowOAM call WriteOAMBlock ret diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index e49c6af1..07a73be6 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,7 +1,7 @@ PlayerStepOutFromDoor: ; 1a3e0 (6:63e0) ld hl, wd730 res 1, [hl] - call IsPlayerStandingOnDoor + call IsPlayerStandingOnDoorTile jr nc, .notStandingOnDoor ld a, $fc ld [wJoyIgnore], a @@ -62,7 +62,7 @@ Func_1a44c: ; 1a44c (6:644c) ld a, $80 call FillMemory ld [hl], $ff - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld de, wNPCMovementDirections2 call MoveSprite @@ -100,18 +100,18 @@ Func_1a4a1: ; 1a4a1 (6:64a1) Func_1a4a6: ; 1a4a6 (6:64a6) xor a ld [wOverrideSimulatedJoypadStatesMask], a - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a xor a ld [wSpriteStateData2 + $06], a ld hl, wSimulatedJoypadStatesEnd - ld de, RLEList_1a4e9 + ld de, RLEList_PlayerWalkToLab call DecodeRLEList dec a ld [wSimulatedJoypadStatesIndex], a ld hl, wNPCMovementDirections2 - ld de, RLEList_1a4dc + ld de, RLEList_ProfOakWalkToLab call DecodeRLEList ld hl, wd72e res 7, [hl] @@ -121,7 +121,7 @@ Func_1a4a6: ; 1a4a6 (6:64a6) ld [wNPCMovementScriptFunctionNum], a ret -RLEList_1a4dc: ; 1a4dc (6:64dc) +RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc) db $00, $05 db $80, $01 db $00, $05 @@ -130,7 +130,7 @@ RLEList_1a4dc: ; 1a4dc (6:64dc) db $E0, $01 db $FF -RLEList_1a4e9: ; 1a4e9 (6:64e9) +RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9) db D_UP, $02 db D_RIGHT, $03 db D_DOWN, $05 @@ -162,7 +162,7 @@ Func_1a514: ; 1a514 (6:6514) ld a, MUSIC_MUSEUM_GUY ld [wc0ee], a call PlaySound - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a call StartSimulatingJoypadStates @@ -218,7 +218,7 @@ Func_1a581: ; 1a581 (6:6581) ld a, MUSIC_MUSEUM_GUY ld [wc0ee], a call PlaySound - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wNPCMovementScriptSpriteOffset], a xor a @@ -276,7 +276,7 @@ Func_1a5e7: ; 1a5e7 (6:65e7) ret z jr .loop .notRival - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c jp SetSpriteMovementBytesToFF diff --git a/engine/overworld/oam.asm b/engine/overworld/oam.asm index 63495d22..b4247257 100644 --- a/engine/overworld/oam.asm +++ b/engine/overworld/oam.asm @@ -2,13 +2,13 @@ PrepareOAMData: ; Determine OAM data for currently visible ; sprites and write it to wOAMBuffer. - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] dec a jr z, .asm_4b1e cp 0 - 1 ret nz - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a jp HideSprites .asm_4b1e diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index f915a2b9..473b0d5a 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -1,66 +1,67 @@ -Func_70510: ; 70510 (1c:4510) - call Func_706ef +EnterMapAnim: ; 70510 (1c:4510) + call InitFacingDirectionBuffer ld a, $ec - ld [wSpriteStateData1 + 4], a + ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position call Delay3 push hl - call GBFadeIn2 + call GBFadeInFromWhite ld hl, W_FLAGS_D733 - bit 7, [hl] + bit 7, [hl] ; used fly out of battle? res 7, [hl] - jr nz, .asm_70568 + jr nz, .flyAnimation ld a, (SFX_02_4c - SFX_Headers_02) / 3 call PlaySound ld hl, wd732 - bit 4, [hl] + bit 4, [hl] ; used dungeon warp? res 4, [hl] pop hl - jr nz, .asm_7055e - call Func_705aa + jr nz, .dungeonWarpAnimation + call PlayerSpinWhileMovingDown ld a, (SFX_02_4f - SFX_Headers_02) / 3 call PlaySound - call Func_70787 + call IsPlayerStandingOnWarpPadOrHole ld a, b and a - jr nz, .asm_7055b - ld hl, wWhichTrade ; wWhichTrade + jr nz, .done +; if the player is not standing on a warp pad or hole + ld hl, wPlayerSpinInPlaceAnimFrameDelay xor a - ld [hli], a + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay inc a - ld [hli], a + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta ld a, $8 - ld [hli], a - ld [hl], $ff + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue + ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID ld hl, wcd48 - call Func_70730 -.asm_70558 + call PlayerSpinInPlace +.restoreDefaultMusic call PlayDefaultMusic -.asm_7055b - jp Func_70772 -.asm_7055e - ld c, $32 +.done + jp RestoreFacingDirectionAndYScreenPos +.dungeonWarpAnimation + ld c, 50 call DelayFrames - call Func_705aa - jr .asm_7055b -.asm_70568 + call PlayerSpinWhileMovingDown + jr .done +.flyAnimation pop hl - ld de, BirdSprite ; $4d80 + ld de, BirdSprite ld hl, vNPCSprites ld bc, (BANK(BirdSprite) << 8) + $0c call CopyVideoData - call Func_706d7 + call LoadBirdSpriteGraphics ld a, (SFX_02_50 - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - xor a - ld [hli], a - ld a, $c - ld [hli], a - ld [hl], $8 + ld hl, wFlyAnimUsingCoordList + xor a ; is using coord list + ld [hli], a ; wFlyAnimUsingCoordList + ld a, 12 + ld [hli], a ; wFlyAnimCounter + ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing right) ld de, FlyAnimationEnterScreenCoords ; $4592 - call Func_706ae + call DoFlyAnimation call LoadPlayerSpriteGraphics - jr .asm_70558 + jr .restoreDefaultMusic FlyAnimationEnterScreenCoords: ; 70592 (1c:4592) ; y, x pairs @@ -79,90 +80,92 @@ FlyAnimationEnterScreenCoords: ; 70592 (1c:4592) db $3C, $48 db $3C, $40 -Func_705aa: ; 705aa (1c:45aa) - ld hl, wWhichTrade ; wWhichTrade +PlayerSpinWhileMovingDown: ; 705aa (1c:45aa) + ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $10 - ld [hli], a + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $3c - ld [hli], a - call Func_7077f - ld [hl], a - jp Func_70755 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY + call GetPlayerTeleportAnimFrameDelay + ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay + jp PlayerSpinWhileMovingUpOrDown _LeaveMapAnim: ; 705ba (1c:45ba) - call Func_706ef - call Func_70787 + call InitFacingDirectionBuffer + call IsPlayerStandingOnWarpPadOrHole ld a, b and a - jr z, .asm_705ef + jr z, .playerNotStandingOnWarpPadOrHole dec a - jp nz, Func_7067d -.asm_705c8 + jp nz, LeaveMapThroughHoleAnim +.spinWhileMovingUp ld a, (SFX_02_4b - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - ld a, $f0 - ld [hli], a + ld hl, wPlayerSpinWhileMovingUpOrDownAnimDeltaY + ld a, -$10 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimDeltaY ld a, $ec - ld [hli], a - call Func_7077f - ld [hl], a - call Func_70755 - call Func_70787 + ld [hli], a ; wPlayerSpinWhileMovingUpOrDownAnimMaxY + call GetPlayerTeleportAnimFrameDelay + ld [hl], a ; wPlayerSpinWhileMovingUpOrDownAnimFrameDelay + call PlayerSpinWhileMovingUpOrDown + call IsPlayerStandingOnWarpPadOrHole ld a, b dec a - jr z, .asm_705e9 - ld c, $a + jr z, .playerStandingOnWarpPad +; if not standing on a warp pad, there is an extra delay + ld c, 10 call DelayFrames -.asm_705e9 - call GBFadeOut2 - jp Func_70772 -.asm_705ef +.playerStandingOnWarpPad + call GBFadeOutToWhite + jp RestoreFacingDirectionAndYScreenPos +.playerNotStandingOnWarpPadOrHole ld a, $4 call StopMusic ld a, [wd732] - bit 6, a - jr z, .asm_70610 - ld hl, wWhichTrade ; wWhichTrade - ld a, $10 - ld [hli], a - ld a, $ff - ld [hli], a + bit 6, a ; is the last used pokemon center the destination? + jr z, .flyAnimation +; if going to the last used pokemon center + ld hl, wPlayerSpinInPlaceAnimFrameDelay + ld a, 16 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelay + ld a, -1 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayDelta xor a - ld [hli], a - ld [hl], $a1 + ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue + ld [hl], $a1 ; wPlayerSpinInPlaceAnimSoundID ld hl, wcd48 - call Func_70730 - jr .asm_705c8 -.asm_70610 - call Func_706d7 - ld hl, wWhichTrade ; wWhichTrade - ld a, $ff - ld [hli], a - ld a, $8 - ld [hli], a - ld [hl], $c - call Func_706ae + call PlayerSpinInPlace + jr .spinWhileMovingUp +.flyAnimation + call LoadBirdSpriteGraphics + ld hl, wFlyAnimUsingCoordList + ld a, $ff ; is not using coord list (flap in place) + ld [hli], a ; wFlyAnimUsingCoordList + ld a, 8 + ld [hli], a ; wFlyAnimCounter + ld [hl], $c ; wFlyAnimBirdSpriteImageIndex + call DoFlyAnimation ld a, (SFX_02_50 - SFX_Headers_02) / 3 call PlaySound - ld hl, wWhichTrade ; wWhichTrade - xor a - ld [hli], a + ld hl, wFlyAnimUsingCoordList + xor a ; is using coord list + ld [hli], a ; wFlyAnimUsingCoordList ld a, $c - ld [hli], a - ld [hl], $c + ld [hli], a ; wFlyAnimCounter + ld [hl], $c ; wFlyAnimBirdSpriteImageIndex (facing right) ld de, FlyAnimationScreenCoords1 ; $464f - call Func_706ae - ld c, $28 + call DoFlyAnimation + ld c, 40 call DelayFrames - ld hl, wTrainerEngageDistance - ld a, $b - ld [hli], a - ld [hl], $8 + ld hl, wFlyAnimCounter + ld a, 11 + ld [hli], a ; wFlyAnimCounter + ld [hl], $8 ; wFlyAnimBirdSpriteImageIndex (facing left) ld de, FlyAnimationScreenCoords2 ; $4667 - call Func_706ae - call GBFadeOut2 - jp Func_70772 + call DoFlyAnimation + call GBFadeOutToWhite + jp RestoreFacingDirectionAndYScreenPos FlyAnimationScreenCoords1: ; 7064f (1c:464f) ; y, x pairs @@ -198,33 +201,35 @@ FlyAnimationScreenCoords2: ; 70667 (1c:4667) db $F0, $00 -Func_7067d: ; 7067d (1c:467d) +LeaveMapThroughHoleAnim: ; 7067d (1c:467d) ld a, $ff - ld [wcfcb], a - ld a, [wOAMBuffer + $02] - ld [wOAMBuffer + $0a], a - ld a, [wOAMBuffer + $06] - ld [wOAMBuffer + $0e], a + ld [wUpdateSpritesEnabled], a ; disable UpdateSprites + ; shift upper half of player's sprite down 8 pixels and hide lower half + ld a, [wOAMBuffer + 0 * 4 + 2] + ld [wOAMBuffer + 2 * 4 + 2], a + ld a, [wOAMBuffer + 1 * 4 + 2] + ld [wOAMBuffer + 3 * 4 + 2], a ld a, $a0 - ld [wOAMBuffer], a - ld [wOAMBuffer + $04], a - ld c, $2 + ld [wOAMBuffer + 0 * 4], a + ld [wOAMBuffer + 1 * 4], a + ld c, 2 call DelayFrames + ; hide lower half of player's sprite ld a, $a0 - ld [wOAMBuffer + $08], a - ld [wOAMBuffer + $0c], a - call GBFadeOut2 + ld [wOAMBuffer + 2 * 4], a + ld [wOAMBuffer + 3 * 4], a + call GBFadeOutToWhite ld a, $1 - ld [wcfcb], a - jp Func_70772 + ld [wUpdateSpritesEnabled], a ; enable UpdateSprites + jp RestoreFacingDirectionAndYScreenPos -Func_706ae: ; 706ae (1c:46ae) - ld a, [wTrainerFacingDirection] - xor $1 - ld [wTrainerFacingDirection], a +DoFlyAnimation: ; 706ae (1c:46ae) + ld a, [wFlyAnimBirdSpriteImageIndex] + xor $1 ; make the bird flap its wings + ld [wFlyAnimBirdSpriteImageIndex], a ld [wSpriteStateData1 + 2], a call Delay3 - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wFlyAnimUsingCoordList] cp $ff jr z, .asm_706cd ld hl, wSpriteStateData1 + 4 @@ -236,13 +241,13 @@ Func_706ae: ; 706ae (1c:46ae) inc de ld [hl], a .asm_706cd - ld a, [wTrainerEngageDistance] + ld a, [wFlyAnimCounter] dec a - ld [wTrainerEngageDistance], a - jr nz, Func_706ae + ld [wFlyAnimCounter], a + jr nz, DoFlyAnimation ret -Func_706d7: ; 706d7 (1c:46d7) +LoadBirdSpriteGraphics: ; 706d7 (1c:46d7) ld de, BirdSprite ; $4d80 ld hl, vNPCSprites ld bc, (BANK(BirdSprite) << 8) + $0c @@ -252,32 +257,32 @@ Func_706d7: ; 706d7 (1c:46d7) ld bc, (BANK(BirdSprite) << 8) + $0c jp CopyVideoData -Func_706ef: ; 706ef (1c:46ef) - ld a, [wSpriteStateData1 + 2] +InitFacingDirectionBuffer: ; 706ef (1c:46ef) + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) ld [wcd50], a - ld a, [wSpriteStateData1 + 4] + ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position ld [wcd4f], a - ld hl, PlayerSpinningFacingOrder ; $4713 + ld hl, PlayerSpinningFacingOrder ld de, wcd48 ld bc, $4 call CopyData - ld a, [wSpriteStateData1 + 2] + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) ld hl, wcd48 -.asm_7070d +.loop cp [hl] inc hl - jr nz, .asm_7070d + jr nz, .loop dec hl ret PlayerSpinningFacingOrder: ; 70713 (1c:4713) ; The order of the direction the player's sprite is facing when teleporting ; away. Creates a spinning effect. - db $00, $08, $04, $0C ; down, left, up, right + db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT -Func_70717: ; 70717 (1c:4717) +SpinPlayerSprite: ; 70717 (1c:4717) ld a, [hl] - ld [wSpriteStateData1 + 2], a + ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images) push hl ld hl, wcd48 ld de, wcd47 @@ -288,84 +293,85 @@ Func_70717: ; 70717 (1c:4717) pop hl ret -Func_70730: ; 70730 (1c:4730) - call Func_70717 - ld a, [wWhichTrade] ; wWhichTrade +PlayerSpinInPlace: ; 70730 (1c:4730) + call SpinPlayerSprite + ld a, [wPlayerSpinInPlaceAnimFrameDelay] ld c, a and $3 jr nz, .asm_70743 - ld a, [wTrainerScreenY] + ld a, [wPlayerSpinInPlaceAnimSoundID] cp $ff call nz, PlaySound .asm_70743 - ld a, [wTrainerEngageDistance] + ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta] add c - ld [wWhichTrade], a ; wWhichTrade + ld [wPlayerSpinInPlaceAnimFrameDelay], a ld c, a - ld a, [wTrainerFacingDirection] + ld a, [wPlayerSpinInPlaceAnimFrameDelayEndValue] cp c ret z call DelayFrames - jr Func_70730 + jr PlayerSpinInPlace -Func_70755: ; 70755 (1c:4755) - call Func_70717 - ld a, [wWhichTrade] ; wWhichTrade +PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755) + call SpinPlayerSprite + ld a, [wPlayerSpinWhileMovingUpOrDownAnimDeltaY] ld c, a - ld a, [wSpriteStateData1 + 4] + ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position add c ld [wSpriteStateData1 + 4], a ld c, a - ld a, [wTrainerEngageDistance] + ld a, [wPlayerSpinWhileMovingUpOrDownAnimMaxY] cp c ret z - ld a, [wTrainerFacingDirection] + ld a, [wPlayerSpinWhileMovingUpOrDownAnimFrameDelay] ld c, a call DelayFrames - jr Func_70755 + jr PlayerSpinWhileMovingUpOrDown -Func_70772: ; 70772 (1c:4772) +RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772) ld a, [wcd4f] ld [wSpriteStateData1 + 4], a ld a, [wcd50] ld [wSpriteStateData1 + 2], a ret -Func_7077f: ; 7077f (1c:477f) - ld a, [wcf1b] +; if SGB, 2 frames, else 3 frames +GetPlayerTeleportAnimFrameDelay: ; 7077f (1c:477f) + ld a, [wOnSGB] xor $1 inc a inc a ret -Func_70787: ; 70787 (1c:4787) +IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787) ld b, 0 - ld hl, DataTable_707a9 ; $47a9 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld hl, .warpPadAndHoleData + ld a, [W_CURMAPTILESET] ld c, a -.asm_70790 +.loop ld a, [hli] cp $ff - jr z, .asm_707a4 + jr z, .done cp c - jr nz, .asm_7079e + jr nz, .nextEntry aCoord 8, 9 cp [hl] - jr z, .asm_707a2 -.asm_7079e + jr z, .foundMatch +.nextEntry inc hl inc hl - jr .asm_70790 -.asm_707a2 + jr .loop +.foundMatch inc hl ld b, [hl] -.asm_707a4 +.done ld a, b ld [wcd5b], a ret ; format: db tileset id, tile id, value to be put in wcd5b -DataTable_707a9: ; 707a9 (1c:47a9) +.warpPadAndHoleData: ; 707a9 (1c:47a9) db FACILITY, $20, 1 ; warp pad db FACILITY, $11, 2 ; hole db CAVERN, $22, 2 ; hole @@ -454,7 +460,7 @@ ItsABiteText: ; 70851 (1c:4851) db "@" FishingRodGfxProperties: ; 70856 (1c:4856) -; specicies how the fishing rod should be drawn on the screen +; specifies how the fishing rod should be drawn on the screen ; first byte = screen y coordinate ; second byte = screen x coordinate ; third byte = tile number @@ -482,21 +488,21 @@ RedFishingTiles: ; 70866 (1c:4866) dw vNPCSprites2 + $7d0 _HandleMidJump: ; 7087e (1c:487e) - ld a, [wd714] + ld a, [wPlayerJumpingYScreenCoordsIndex] ld c, a inc a cp $10 - jr nc, .asm_70895 - ld [wd714], a - ld b, $0 - ld hl, PlayerJumpingYScreenCoords ; $48ba + jr nc, .finishedJump + ld [wPlayerJumpingYScreenCoordsIndex], a + ld b, 0 + ld hl, PlayerJumpingYScreenCoords add hl, bc ld a, [hl] ld [wSpriteStateData1 + 4], a ; player's sprite y coordinate ret -.asm_70895 - ld a, [wWalkCounter] ; wcfc5 - cp $0 +.finishedJump + ld a, [wWalkCounter] + cp 0 ret nz call UpdateSprites call Delay3 @@ -504,11 +510,11 @@ _HandleMidJump: ; 7087e (1c:487e) ld [hJoyHeld], a ld [hJoyPressed], a ld [hJoyReleased], a - ld [wd714], a + ld [wPlayerJumpingYScreenCoordsIndex], a ld hl, wd736 - res 6, [hl] + res 6, [hl] ; not jumping down a ledge any more ld hl, wd730 - res 7, [hl] + res 7, [hl] ; not simulating joypad states any more xor a ld [wJoyIgnore], a ret diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 1c2c23bf..a27f6b0a 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -203,7 +203,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld hl,PokemartThankYouText call PrintText ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call UpdateSprites ; move sprites ld a,[wd07e] ld [wListScrollOffset],a diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm index bdbbd17e..f1a8ecf9 100755 --- a/engine/overworld/ssanne.asm +++ b/engine/overworld/ssanne.asm @@ -1,10 +1,10 @@ AnimateBoulderDust: ; 79f54 (1e:5f54) ld a, $1 ld [wcd50], a ; select the boulder dust offsets - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] push af ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld a, %11100100 ld [rOBP1], a call LoadSmokeTileFourTimes @@ -26,7 +26,7 @@ AnimateBoulderDust: ; 79f54 (1e:5f54) dec c jr nz, .loop pop af - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a jp LoadPlayerSpriteGraphics GetMoveBoulderDustFunctionPointer: ; 79f92 (1e:5f92) diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm index 5237df0d..4aaab3ed 100755 --- a/engine/overworld/trainers.asm +++ b/engine/overworld/trainers.asm @@ -1,7 +1,7 @@ _GetSpritePosition1: ; 567f9 (15:67f9) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [hli] @@ -20,7 +20,7 @@ _GetSpritePosition1: ; 567f9 (15:67f9) _GetSpritePosition2: ; 56819 (15:6819) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [hli] ; c1x4 (screen Y pos) @@ -39,7 +39,7 @@ _GetSpritePosition2: ; 56819 (15:6819) _SetSpritePosition1: ; 5683d (15:683d) ld hl, wSpriteStateData1 ld de, $4 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [$ffeb] ; c1x4 (screen Y pos) @@ -58,7 +58,7 @@ _SetSpritePosition1: ; 5683d (15:683d) _SetSpritePosition2: ; 5685d (15:685d) ld hl, wSpriteStateData1 ld de, $0004 - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a call GetSpriteDataPointer ld a, [wd130] @@ -75,7 +75,7 @@ _SetSpritePosition2: ; 5685d (15:685d) ret TrainerWalkUpToPlayer: ; 56881 (15:6881) - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wTrainerSpriteOffset], a ; wWhichTrade call ReadTrainerScreenPosition @@ -143,7 +143,7 @@ TrainerWalkUpToPlayer: ; 56881 (15:6881) ld de, wNPCMovementDirections2 call FillMemory ; write the necessary steps to reach player ld [hl], $ff ; write end of list sentinel - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_SPRITEINDEX], a jp MoveSprite_ diff --git a/engine/palettes.asm b/engine/palettes.asm index eafd8ef6..67afc12d 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -380,11 +380,11 @@ SendSGBPacket: ; 71feb (1c:5feb) LoadSGB: ; 7202b (1c:602b) xor a - ld [wcf1b], a + ld [wOnSGB], a call Func_7209b ret nc ld a, $1 - ld [wcf1b], a + ld [wOnSGB], a ld a, [wGBC] and a jr z, .asm_7203f diff --git a/engine/predefs.asm b/engine/predefs.asm index c492a206..0a5eff03 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -71,19 +71,19 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef FlagActionPredef add_predef HideObject add_predef IsObjectHidden - add_predef Func_c69c + add_predef ApplyOutOfBattlePoisonDamage add_predef AnyPartyAlive add_predef ShowObject add_predef ShowObject2 add_predef Func_ee9e add_predef InitPlayerData2 - add_predef Func_c754 + add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove add_predef IsItemInBag_ ; 1C, used in Pokémon Tower dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 dbw $03,GiveItem - add_predef Func_480eb + add_predef ChangeBGPalColor0_4Frames add_predef FindPathToPlayer add_predef Func_480ff add_predef CalcPositionOfPlayerRelativeToNPC @@ -105,7 +105,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef PlayIntro add_predef Func_79869 add_predef FlashScreen - add_predef Func_c586 + add_predef GetTileAndCoordsInFrontOfPlayer add_predef StatusScreen add_predef StatusScreen2 add_predef Func_410e2 @@ -140,9 +140,9 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef HallOfFamePC add_predef DisplayDexRating dbw $1E, _LeaveMapAnim ; wrong bank - dbw $1E, Func_70510 ; wrong bank - add_predef Func_c5be - add_predef Func_c60b + dbw $1E, EnterMapAnim ; wrong bank + add_predef GetTileTwoStepsInFrontOfPlayer + add_predef CheckForCollisionWhenPushingBoulder add_predef PrintStrengthTxt add_predef PickupItem add_predef Func_27d98 diff --git a/engine/predefs12.asm b/engine/predefs12.asm index 380cfc1c..90032a14 100755 --- a/engine/predefs12.asm +++ b/engine/predefs12.asm @@ -1,13 +1,14 @@ -Func_480eb: ; 480eb (12:40eb) +; b = new colour for BG colour 0 (usually white) for 4 frames +ChangeBGPalColor0_4Frames: ; 480eb (12:40eb) call GetPredefRegisters - ld a, [rBGP] ; $ff47 + ld a, [rBGP] or b - ld [rBGP], a ; $ff47 + ld [rBGP], a ld c, $4 call DelayFrames - ld a, [rBGP] ; $ff47 - and $fc - ld [rBGP], a ; $ff47 + ld a, [rBGP] + and %11111100 + ld [rBGP], a ret Func_480ff: ; 480ff (12:40ff) diff --git a/engine/predefs7.asm b/engine/predefs7.asm index 469fe0c4..b6c3bbbc 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -31,7 +31,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6) ld b, a ld a, [hl] ld c, a - ld hl, wd3af + ld hl, wWarpEntries call Func_1ca0d Func_1ca0d: ; 1ca0d (7:4a0d) diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index ed6f52fb..6964b94e 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -1,7 +1,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) call SaveScreenTilesToBuffer2 ld a, BANK(DisplayTextIDInit) - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ld b, a ld hl, DisplayTextIDInit call Bankswitch @@ -12,7 +12,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) and a jr nz, .skip dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wcd4f xor a ld [hli], a @@ -40,7 +40,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) ld [W_SUBANIMSUBENTRYADDR], a call GBPalWhiteOutWithDelay3 ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call GoPAL_SET_CF1C call ReloadMapSpriteTilePatterns call ReloadTilesetTilePatterns @@ -221,7 +221,7 @@ SlotMachine_374ad: ; 374ad (d:74ad) call SlotMachine_374fb call SlotMachine_37517 ret c - ld a, [wcf1b] + ld a, [wOnSGB] xor $1 inc a ld c, a diff --git a/engine/town_map.asm b/engine/town_map.asm index 2cd37284..6d10c222 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -1,6 +1,6 @@ DisplayTownMap: ; 70e3e (1c:4e3e) call LoadTownMap - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -111,7 +111,7 @@ TownMapCursor: ; 70f40 (1c:4f40) LoadTownMap_Nest: ; 70f60 (1c:4f60) call LoadTownMap - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -148,7 +148,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld bc, (BANK(TownMapUpArrow) << 8) + $01 call CopyVideoDataDouble call Func_71070 - ld hl, wcfcb + ld hl, wUpdateSpritesEnabled ld a, [hl] push af ld [hl], $ff @@ -206,7 +206,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld a, (SFX_02_3e - SFX_Headers_02) / 3 call PlaySound ld a, [hl] - ld [wd71a], a + ld [wDestinationMap], a ld hl, wd732 set 3, [hl] inc hl diff --git a/engine/trade.asm b/engine/trade.asm index 0f245fc5..5be77f3e 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -119,10 +119,10 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1) call FillMemory call ClearSprites ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] - ld a, [wcf1b] + ld a, [wOnSGB] and a ld a, $e4 jr z, .asm_411e5 diff --git a/home.asm b/home.asm index 735d087d..87215991 100644 --- a/home.asm +++ b/home.asm @@ -173,7 +173,7 @@ LoadDestinationWarpPosition:: ; 1313 (0:1313) ld b,0 add hl,bc ld bc,4 - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call CopyData pop af ld [H_LOADEDROMBANK],a @@ -1464,7 +1464,7 @@ INCLUDE "home/audio.asm" UpdateSprites:: ; 2429 (0:2429) - ld a, [wcfcb] + ld a, [wUpdateSpritesEnabled] dec a ret nz ld a, [H_LOADEDROMBANK] @@ -1607,18 +1607,18 @@ DisplayTextID:: ; 2920 (0:2920) ld l,a ; hl = map text pointer ld d,$00 ld a,[$ff8c] ; text ID - ld [wcf13],a + ld [wSpriteIndex],a and a jp z,DisplayStartMenu - cp a,$d3 ; safari game over + cp a,$d3 jp z,DisplaySafariGameOverText - cp a,$d0 ; fainted + cp a,$d0 jp z,DisplayPokemonFaintedText - cp a,$d1 ; blacked out + cp a,$d1 jp z,DisplayPlayerBlackedOutText - cp a,$d2 ; repel wore off + cp a,$d2 jp z,DisplayRepelWoreOffText - ld a,[W_NUMSPRITES] ; number of sprites + ld a,[W_NUMSPRITES] ld e,a ld a,[$ff8c] ; sprite ID cp e @@ -1678,7 +1678,7 @@ DisplayTextID:: ; 2920 (0:2920) jr AfterDisplayingTextID .notSpecialCase call Func_3c59 ; display the text - ld a,[wcc3c] + ld a,[wDoNotWaitForButtonPressAfterDisplayingText] and a jr nz,HoldTextDisplayOpen @@ -1723,13 +1723,13 @@ CloseTextDisplay:: ; 29e8 (0:29e8) ld hl,wcfc4 res 0,[hl] ld a,[wd732] - bit 3,a + bit 3,a ; used fly warp call z,LoadPlayerSpriteGraphics call LoadCurrentMapView pop af ld [H_LOADEDROMBANK],a ld [$2000],a - jp UpdateSprites ; move sprites + jp UpdateSprites DisplayPokemartDialogue:: ; 2a2e (0:2a2e) push hl @@ -1757,7 +1757,7 @@ PokemartGreetingText:: ; 2a55 (0:2a55) LoadItemList:: ; 2a5a (0:2a5a) ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a ld a,h ld [wd128],a ld a,l @@ -1805,7 +1805,7 @@ DisplayPlayerBlackedOutText:: ; 2aa9 (0:2aa9) ld hl,PlayerBlackedOutText call PrintText ld a,[wd732] - res 5,a + res 5,a ; reset forced to use bike bit ld [wd732],a jp HoldTextDisplayOpen @@ -2616,7 +2616,7 @@ ChooseFlyDestination:: ; 30a9 (0:30a9) ; causes the text box to close without waiting for a button press after displaying text DisableWaitingAfterTextDisplay:: ; 30b6 (0:30b6) ld a,$01 - ld [wcc3c],a + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ret ; uses an item @@ -2872,11 +2872,11 @@ TalkToTrainer:: ; 31cc (0:31cc) ; checks if any trainers are seeing the player and wanting to fight CheckFightingMapTrainers:: ; 3219 (0:3219) call CheckForEngagingTrainers - ld a, [wcf13] + ld a, [wSpriteIndex] cp $ff jr nz, .trainerEngaging xor a - ld [wcf13], a + ld [wSpriteIndex], a ld [wTrainerHeaderFlagBit], a ret .trainerEngaging @@ -2900,7 +2900,7 @@ Func_324c:: ; 324c (0:324c) and $1 ret nz ld [wJoyIgnore], a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID @@ -2939,7 +2939,7 @@ EndTrainerBattle:: ; 3275 (0:3275) jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite) ld hl, W_MISSABLEOBJECTLIST ld de, $2 - ld a, [wcf13] + ld a, [wSpriteIndex] call IsInArray ; search for sprite ID inc hl ld a, [hl] @@ -3006,7 +3006,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) .trainerLoop call StoreTrainerHeaderPointer ; set trainer header pointer to current trainer ld a, [de] - ld [wcf13], a ; store trainer flag's bit + ld [wSpriteIndex], a ; store trainer flag's bit ld [wTrainerHeaderFlagBit], a cp $ff ret z @@ -3028,7 +3028,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ld a, [hl] ; read trainer engage distance pop hl ld [wTrainerEngageDistance], a - ld a, [wcf13] + ld a, [wSpriteIndex] swap a ld [wTrainerSpriteOffset], a ; wWhichTrade predef TrainerEngage @@ -3059,11 +3059,11 @@ PreBattleSaveRegisters:: ; 3354 (0:3354) ret ; loads data of some trainer on the current map and plays pre-battle music -; [wcf13]: sprite ID of trainer who is engaged +; [wSpriteIndex]: sprite ID of trainer who is engaged EngageMapTrainer:: ; 336a (0:336a) ld hl, W_MAPSPRITEEXTRADATA ld d, $0 - ld a, [wcf13] + ld a, [wSpriteIndex] dec a add a ld e, a @@ -4708,9 +4708,9 @@ DisableAutoTextBoxDrawing:: ; 3c3f (0:3c3f) ld a,$01 AutoTextBoxDrawingCommon:: ; 3c41 (0:3c41) - ld [wcf0c],a ; control text box drawing + ld [wAutoTextBoxDrawingControl],a xor a - ld [wcc3c],a ; make DisplayTextID wait for button press + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press ret PrintText:: ; 3c49 (0:3c49) @@ -5015,7 +5015,7 @@ IsInRestOfArray:: RestoreScreenTilesAndReloadTilePatterns:: ; 3dbe (0:3dbe) call ClearSprites ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a call ReloadMapSpriteTilePatterns call LoadScreenTilesFromBuffer2 call LoadTextBoxTilePatterns @@ -5052,7 +5052,7 @@ GBPalWhiteOut:: GoPAL_SET_CF1C:: ; 3ded (0:3ded) ld b,$ff GoPAL_SET:: ; 3def (0:3def) - ld a,[wcf1b] + ld a,[wOnSGB] and a ret z predef_jump Func_71ddf diff --git a/home/audio.asm b/home/audio.asm index 8dcc0d93..9210924c 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -17,7 +17,7 @@ Func_2312:: ; 2312 (0:2312) ld c, $8 ld d, c asm_2324:: ; 2324 (0:2324) - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_2343 cp $2 diff --git a/home/fade.asm b/home/fade.asm index 9b55eaf2..08e087b4 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -1,7 +1,7 @@ ; These routines manage gradual fading ; (e.g., entering a doorway) LoadGBPal:: - ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?) + ld a, [wMapPalOffset] ;tells if cur.map is dark (requires HM5_FLASH?) ld b, a ld hl, FadePal4 ld a, l @@ -18,16 +18,16 @@ LoadGBPal:: ld [rOBP1], a ret -GBFadeOut1:: +GBFadeInFromBlack:: ld hl, FadePal1 ld b, 4 - jr GBFadeOutCommon + jr GBFadeIncCommon -GBFadeOut2:: +GBFadeOutToWhite:: ld hl, FadePal6 ld b, 3 -GBFadeOutCommon:: +GBFadeIncCommon: ld a, [hli] ld [rBGP], a ld a, [hli] @@ -37,19 +37,19 @@ GBFadeOutCommon:: ld c, 8 call DelayFrames dec b - jr nz, GBFadeOutCommon + jr nz, GBFadeIncCommon ret -GBFadeIn1:: +GBFadeOutToBlack:: ld hl, FadePal4 + 2 ld b, 4 - jr GBFadeInCommon + jr GBFadeDecCommon -GBFadeIn2:: +GBFadeInFromWhite:: ld hl, FadePal7 + 2 ld b, 3 -GBFadeInCommon:: +GBFadeDecCommon: ld a, [hld] ld [rOBP1], a ld a, [hld] @@ -59,7 +59,7 @@ GBFadeInCommon:: ld c, 8 call DelayFrames dec b - jr nz, GBFadeInCommon + jr nz, GBFadeDecCommon ret FadePal1:: db %11111111, %11111111, %11111111 diff --git a/home/init.asm b/home/init.asm index cf8f448e..402a402e 100644 --- a/home/init.asm +++ b/home/init.asm @@ -105,7 +105,7 @@ rLCDC_DEFAULT EQU %11100011 xor a ld [$ffbc], a dec a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a predef PlayIntro diff --git a/home/overworld.asm b/home/overworld.asm index a8747f2d..9dbfdfb7 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -12,11 +12,11 @@ EnterMap:: call LoadMapData callba Func_c335 ; initialize map variables ld hl, wd72c - bit 0, [hl] - jr z, .doNotCountSteps - ld a, 3 - ld [wd13c], a ; some kind of step counter (counts up to 3 steps?) -.doNotCountSteps + bit 0, [hl] ; has the player already made 3 steps since the last battle? + jr z, .skipGivingThreeStepsOfNoRandomBattles + ld a, 3 ; minimum number of steps between battles + ld [wNumberOfNoRandomBattleStepsLeft], a +.skipGivingThreeStepsOfNoRandomBattles ld hl, wd72e bit 5, [hl] ; did a battle happen immediately before this? res 5, [hl] ; unset the "battle just happened" flag @@ -24,12 +24,12 @@ EnterMap:: call nz, MapEntryAfterBattle ld hl, wd732 ld a, [hl] - and 1 << 4 | 1 << 3 - jr z, .didNotFlyOrTeleportIn + and 1 << 4 | 1 << 3 ; fly warp or dungeon warp + jr z, .didNotEnterUsingFlyWarpOrDungeonWarp res 3, [hl] - callba Func_70510 ; display fly/teleport in graphical effect + callba EnterMapAnim ; display fly/teleport in graphical effect call UpdateSprites -.didNotFlyOrTeleportIn +.didNotEnterUsingFlyWarpOrDungeonWarp callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road ld hl, wd72d res 5, [hl] @@ -61,8 +61,8 @@ OverworldLoopLessDelay:: res 3,[hl] jp nz,WarpFound2 ld a,[wd732] - and a,$18 - jp nz,HandleFlyOrTeleportAway + and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp + jp nz,HandleFlyWarpOrDungeonWarp ld a,[W_CUROPPONENT] and a jp nz,.newBattle @@ -98,8 +98,8 @@ OverworldLoopLessDelay:: and a jp z,OverworldLoop .displayDialogue - predef Func_c586 ; check what is in front of the player - call UpdateSprites ; move sprites + predef GetTileAndCoordsInFrontOfPlayer + call UpdateSprites ld a,[wFlags_0xcd60] bit 2,a jr nz,.checkForOpponent @@ -117,8 +117,8 @@ OverworldLoopLessDelay:: jr z,.changeMap predef LoadSAV ld a,[W_CURMAP] - ld [wd71a],a - call Func_62ce + ld [wDestinationMap],a + call SpecialWarpIn ld a,[W_CURMAP] call SwitchToMapRomBank ; switch to the ROM bank of the current map ld hl,W_CURMAPTILESET @@ -133,7 +133,7 @@ OverworldLoopLessDelay:: .noDirectionButtonsPressed ld hl,wFlags_0xcd60 res 2,[hl] - call UpdateSprites ; move sprites + call UpdateSprites ld a,$01 ld [wcc4b],a ld a,[wd528] ; the direction that was pressed last time @@ -225,18 +225,20 @@ OverworldLoopLessDelay:: .noDirectionChange ld a,[wd52a] ; current direction ld [wd528],a ; save direction - call UpdateSprites ; move sprites - ld a,[wd700] + call UpdateSprites + ld a,[wWalkBikeSurfState] cp a,$02 ; surfing jr z,.surfing ; not surfing call CollisionCheckOnLand jr nc,.noCollision +; collision occurred push hl ld hl,wd736 - bit 2,[hl] + bit 2,[hl] ; standing on warp flag pop hl jp z,OverworldLoop +; collision occurred while standing on a warp push hl call ExtraWarpCheck ; sets carry if there is a potential to warp pop hl @@ -259,7 +261,7 @@ OverworldLoopLessDelay:: .moveAhead2 ld hl,wFlags_0xcd60 res 2,[hl] - ld a,[wd700] + ld a,[wWalkBikeSurfState] dec a ; riding a bike? jr nz,.normalPlayerSpriteAdvancement ld a,[wd736] @@ -276,16 +278,16 @@ OverworldLoopLessDelay:: bit 7,a jr nz,.doneStepCounting ; if button presses are being simulated, don't count steps ; step counting - ld hl,wd13b ; step counter + ld hl,wStepCounter dec [hl] ld a,[wd72c] bit 0,a jr z,.doneStepCounting - ld hl,wd13c + ld hl,wNumberOfNoRandomBattleStepsLeft dec [hl] jr nz,.doneStepCounting ld hl,wd72c - res 0,[hl] + res 0,[hl] ; indicate that the player has stepped thrice since the last battle .doneStepCounting ld a,[wd790] bit 7,a ; in the safari zone? @@ -298,14 +300,14 @@ OverworldLoopLessDelay:: ld a,[W_ISINBATTLE] and a jp nz,CheckWarpsNoCollision - predef Func_c69c ; decrement HP of poisoned pokemon + predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp ld a,[wd12d] and a jp nz,HandleBlackOut ; if all pokemon fainted .newBattle call NewBattle ld hl,wd736 - res 2,[hl] + res 2,[hl] ; standing on warp flag jp nc,CheckWarpsNoCollision ; check for warps if there was no battle .battleOccurred ld hl,wd72d @@ -316,7 +318,7 @@ OverworldLoopLessDelay:: set 5,[hl] set 6,[hl] xor a - ld [hJoyHeld],a ; clear joypad state + ld [hJoyHeld],a ld a,[W_CURMAP] cp a,CINNABAR_GYM jr nz,.notCinnabarGym @@ -327,8 +329,8 @@ OverworldLoopLessDelay:: set 5,[hl] ld a,[W_CURMAP] cp a,OAKS_LAB - jp z,.noFaintCheck - callab AnyPartyAlive ; check if all the player's pokemon fainted + jp z,.noFaintCheck ; no blacking out if the player lost to the rival in Oak's lab + callab AnyPartyAlive ld a,d and a jr z,.allPokemonFainted @@ -355,7 +357,7 @@ NewBattle:: ; 0683 (0:0683) jr nz,.noBattle ld b, BANK(InitBattle) ld hl, InitBattle - jp Bankswitch ; determines if a battle will occur and runs the battle if so + jp Bankswitch .noBattle and a ret @@ -368,25 +370,25 @@ BikeSpeedup:: ; 06a0 (0:06a0) ld a,[W_CURMAP] cp a,ROUTE_17 ; Cycling Road jr nz,.goFaster - ld a,[hJoyHeld] ; current joypad state - and a,%01110000 ; bit mask for up, left, right buttons + ld a,[hJoyHeld] + and a,D_UP | D_LEFT | D_RIGHT ret nz .goFaster jp AdvancePlayerSprite ; check if the player has stepped onto a warp after having not collided CheckWarpsNoCollision:: ; 06b4 (0:06b4) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] and a jp z,CheckMapConnections - ld a,[wd3ae] ; number of warps - ld b,$00 + ld a,[wNumberOfWarps] + ld b,0 ld c,a ld a,[W_YCOORD] ld d,a ld a,[W_XCOORD] ld e,a - ld hl,wd3af ; start of warp entries + ld hl,wWarpEntries CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) ld a,[hli] ; check if the warp's Y position matches cp d @@ -398,14 +400,14 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) push hl push bc ld hl,wd736 - set 2,[hl] - callba Func_c49d ; check if the player sprite is standing on a "door" tile + set 2,[hl] ; standing on warp flag + callba IsPlayerStandingOnDoorTileOrWarpTile pop bc pop hl - jr c,WarpFound1 ; if it is, go to 0735 + jr c,WarpFound1 ; jump if standing on door or warp push hl push bc - call ExtraWarpCheck ; sets carry if the warp is confirmed + call ExtraWarpCheck pop bc pop hl jr nc,CheckWarpsNoCollisionRetry2 @@ -418,16 +420,16 @@ CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) call Joypad pop bc pop de - ld a,[hJoyHeld] ; current joypad state - and a,%11110000 ; bit mask for directional buttons + ld a,[hJoyHeld] + and a,D_DOWN | D_UP | D_LEFT | D_RIGHT jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp jr WarpFound1 ; check if the player has stepped onto a warp after having collided CheckWarpsCollision:: ; 0706 (0:0706) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] ld c,a - ld hl,wd3af ; start of warp entries + ld hl,wWarpEntries .loop ld a,[hli] ; Y coordinate of warp ld b,a @@ -440,7 +442,7 @@ CheckWarpsCollision:: ; 0706 (0:0706) cp b jr nz,.retry2 ld a,[hli] - ld [wd42f],a ; save target warp ID + ld [wDestinationWarpID],a ld a,[hl] ld [$ff8b],a ; save target map jr WarpFound2 @@ -462,12 +464,12 @@ CheckWarpsNoCollisionRetry2:: ; 0730 (0:0730) WarpFound1:: ; 0735 (0:0735) ld a,[hli] - ld [wd42f],a ; save target warp ID + ld [wDestinationWarpID],a ld a,[hli] ld [$ff8b],a ; save target map WarpFound2:: ; 073c (0:073c) - ld a,[wd3ae] ; number of warps + ld a,[wNumberOfWarps] sub c ld [wd73b],a ; save ID of used warp ld a,[W_CURMAP] @@ -484,8 +486,8 @@ WarpFound2:: ; 073c (0:073c) cp a,ROCK_TUNNEL_1 jr nz,.notRockTunnel ld a,$06 - ld [wd35d],a - call GBFadeIn1 + ld [wMapPalOffset],a + call GBFadeOutToBlack .notRockTunnel call PlayMapChangeSound jr .done @@ -496,16 +498,16 @@ WarpFound2:: ; 073c (0:073c) jr z,.goBackOutside ; if not going back to the previous map ld [W_CURMAP],a ; current map number - callba Func_70787 ; check if the warp was a Silph Co. teleporter + callba IsPlayerStandingOnWarpPadOrHole ld a,[wcd5b] - dec a - jr nz,.notTeleporter -; if it's a Silph Co. teleporter + dec a ; is the player on a warp pad? + jr nz,.notWarpPad +; if the player is on a warp pad ld hl,wd732 set 3,[hl] call LeaveMapAnim jr .skipMapChangeSound -.notTeleporter +.notWarpPad call PlayMapChangeSound .skipMapChangeSound ld hl,wd736 @@ -517,7 +519,7 @@ WarpFound2:: ; 073c (0:073c) ld [W_CURMAP],a call PlayMapChangeSound xor a - ld [wd35d],a + ld [wMapPalOffset],a .done ld hl,wd736 set 0,[hl] ; have the player's sprite step out from the door (if there is one) @@ -562,9 +564,9 @@ CheckMapConnections:: ; 07ba (0:07ba) jr nz,.pointerAdjustmentLoop1 .savePointer1 ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkEastMap ld b,a @@ -598,9 +600,9 @@ CheckMapConnections:: ; 07ba (0:07ba) jr nz,.pointerAdjustmentLoop2 .savePointer2 ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkNorthMap ld a,[W_YCOORD] @@ -624,9 +626,9 @@ CheckMapConnections:: ; 07ba (0:07ba) srl c add hl,bc ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a jp .loadNewMap .checkSouthMap ld b,a @@ -651,9 +653,9 @@ CheckMapConnections:: ; 07ba (0:07ba) srl c add hl,bc ld a,l - ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld [wCurrentTileBlockMapViewPointer],a ; pointer to upper left corner of current tile block map section ld a,h - ld [wd360],a + ld [wCurrentTileBlockMapViewPointer + 1],a .loadNewMap ; load the connected map that was entered call LoadMapHeader call Func_2312 ; music @@ -678,10 +680,10 @@ PlayMapChangeSound:: ; 08c9 (0:08c9) ld a,(SFX_02_5c - SFX_Headers_02) / 3 .playSound call PlaySound - ld a,[wd35d] + ld a,[wMapPalOffset] and a ret nz - jp GBFadeIn1 + jp GBFadeOutToBlack CheckIfInOutsideMap:: ; 08e1 (0:08e1) ; If the player is in an outside map (a town or route), set the z flag @@ -719,37 +721,37 @@ ExtraWarpCheck:: ; 08e9 (0:08e9) cp PLATEAU ; Indigo Plateau tileset jr z, .useFunction2 .useFunction1 - ld hl, Func_c3ff + ld hl, IsPlayerFacingEdgeOfMap jr .doBankswitch .useFunction2 - ld hl, Func_c44e + ld hl, IsWarpTileInFrontOfPlayer .doBankswitch - ld b, BANK(Func_c44e) + ld b, BANK(IsWarpTileInFrontOfPlayer) jp Bankswitch MapEntryAfterBattle:: ; 091f (0:091f) - callba Func_c35f ; function that appears to disable warp testing after collisions if the player is standing on a warp - ld a,[wd35d] + callba IsPlayerStandingOnWarp ; for enabling warp testing after collisions + ld a,[wMapPalOffset] and a - jp z,GBFadeIn2 + jp z,GBFadeInFromWhite jp LoadGBPal HandleBlackOut:: ; For when all the player's pokemon faint. ; Does not print the "blacked out" message. - call GBFadeIn1 + call GBFadeOutToBlack ld a, $08 call StopMusic ld hl, wd72e res 5, [hl] - ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f) + ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) ld [H_LOADEDROMBANK], a ld [MBC3RomBank], a - call Func_40b0 - call Func_62ce + call ResetStatusAndHalveMoneyOnBlackout + call SpecialWarpIn call Func_2312 - jp Func_5d5f + jp SpecialEnterMap StopMusic:: ld [wMusicHeaderPointer], a @@ -762,23 +764,23 @@ StopMusic:: jr nz, .wait jp StopAllSounds -HandleFlyOrTeleportAway:: +HandleFlyWarpOrDungeonWarp:: call UpdateSprites call Delay3 xor a ld [wBattleResult], a - ld [wd700], a + ld [wWalkBikeSurfState], a ld [W_ISINBATTLE], a - ld [wd35d], a + ld [wMapPalOffset], a ld hl, wd732 - set 2, [hl] - res 5, [hl] + set 2, [hl] ; fly warp or dungeon warp + res 5, [hl] ; forced to ride bike call LeaveMapAnim - ld a, Bank(Func_62ce) + ld a, Bank(SpecialWarpIn) ld [H_LOADEDROMBANK], a ld [$2000], a - call Func_62ce - jp Func_5d5f + call SpecialWarpIn + jp SpecialEnterMap LeaveMapAnim:: ld b, BANK(_LeaveMapAnim) @@ -792,7 +794,7 @@ LoadPlayerSpriteGraphics:: ; 1: biking ; 2: surfing - ld a, [wd700] + ld a, [wWalkBikeSurfState] dec a jr z, .ridingBike @@ -809,12 +811,12 @@ LoadPlayerSpriteGraphics:: .startWalking xor a - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp LoadWalkingPlayerSpriteGraphics .determineGraphics - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jp z, LoadWalkingPlayerSpriteGraphics dec a @@ -1065,7 +1067,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) and a jr z,.extendRangeOverCounter ; if there are signs - predef Func_c586 ; get the coordinates in front of the player in de + predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de ld hl,wd4b1 ; start of sign coordinates ld a,[wd4b0] ; number of signs in the map ld b,a @@ -1099,7 +1101,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) jr nz,.signLoop ; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC .extendRangeOverCounter - predef Func_c586 ; get the tile in front of the player in c + predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) ld b,$03 ld d,$20 ; talking range in pixels (long range) @@ -1239,8 +1241,8 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) ; function that checks if the tile in front of the player is passable ; clears carry if it is, sets carry if not CheckTilePassable:: ; 0c10 (0:0c10) - predef Func_c586 ; get tile in front of player - ld a,[wcfc6] ; tile in front of player + predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player + ld a,[wTileInFrontOfPlayer] ; tile in front of player ld c,a ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles ld a,[hli] @@ -1263,7 +1265,7 @@ CheckTilePassable:: ; 0c10 (0:0c10) ; sets carry if there is a collision and unsets carry if not CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) push hl - predef Func_c586 ; get the tile in front of the player + predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player push de push bc callba HandleLedges ; check if the player is trying to jump a ledge @@ -1276,12 +1278,12 @@ CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) ret nz ; if not jumping -Func_c44:: ; 0c44 (0:0c44) +CheckForTilePairCollisions2:: ; 0c44 (0:0c44) aCoord 8, 9 ; tile the player is on ld [wcf0e],a CheckForTilePairCollisions:: ; 0c4a (0:0c4a) - ld a,[wcfc6] ; tile in front of the player + ld a,[wTileInFrontOfPlayer] ld c,a .tilePairCollisionLoop ld a,[W_CURMAPTILESET] ; tileset number @@ -1357,9 +1359,9 @@ LoadCurrentMapView:: ; 0caa (0:0caa) ld a,[W_TILESETBANK] ; tile data ROM bank ld [H_LOADEDROMBANK],a ld [$2000],a ; switch to ROM bank that contains tile data - ld a,[wd35f] ; address of upper left corner of current map view + ld a,[wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view ld e,a - ld a,[wd360] + ld a,[wCurrentTileBlockMapViewPointer + 1] ld d,a ld hl,wTileMapBackup ld b,$05 @@ -1531,9 +1533,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the east xor a ld [hl],a - ld hl,wd4e3 + ld hl,wXOffsetSinceLastSpecialWarp inc [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call MoveTileBlockMapPointerEast jr .updateMapView .checkForMoveToWestBlock @@ -1542,9 +1544,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the west ld a,$01 ld [hl],a - ld hl,wd4e3 + ld hl,wXOffsetSinceLastSpecialWarp dec [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer call MoveTileBlockMapPointerWest jr .updateMapView .adjustYCoordWithinBlock @@ -1557,9 +1559,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the south xor a ld [hl],a - ld hl,wd4e2 + ld hl,wYOffsetSinceLastSpecialWarp inc [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer ld a,[W_CURMAPWIDTH] call MoveTileBlockMapPointerSouth jr .updateMapView @@ -1569,9 +1571,9 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) ; moved into the tile block to the north ld a,$01 ld [hl],a - ld hl,wd4e2 + ld hl,wYOffsetSinceLastSpecialWarp dec [hl] - ld de,wd35f + ld de,wCurrentTileBlockMapViewPointer ld a,[W_CURMAPWIDTH] call MoveTileBlockMapPointerNorth .updateMapView @@ -1905,8 +1907,8 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ld hl,TilePairCollisionsWater call CheckForJumpingAndTilePairCollisions jr c,.collision - predef Func_c586 ; get tile in front of player (puts it in c and [wcfc6]) - ld a,[wcfc6] ; tile in front of player + predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player (puts it in c and [wTileInFrontOfPlayer]) + ld a,[wTileInFrontOfPlayer] ; tile in front of player cp a,$14 ; water tile jr z,.noCollision ; keep surfing if it's a water tile cp a,$32 ; either the left tile of the S.S. Anne boarding platform or the tile on eastern coastlines (depending on the current tileset) @@ -1941,7 +1943,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ret .stopSurfing xor a - ld [wd700],a + ld [wWalkBikeSurfState],a call LoadPlayerSpriteGraphics call PlayDefaultMusic jr .noCollision @@ -2089,12 +2091,12 @@ LoadMapHeader:: ; 107c (0:107c) ld a,[hli] ld [de],a ; save background tile ID .loadWarpData - ld a,[hli] ; number of warps - ld [wd3ae],a ; save the number of warps - and a ; are there any warps? - jr z,.loadSignData ; if not, skip this + ld a,[hli] + ld [wNumberOfWarps],a + and a + jr z,.loadSignData ld c,a - ld de,wd3af ; base address of warps + ld de,wWarpEntries .warpLoop ; one warp per loop iteration ld b,$04 .warpInnerLoop @@ -2258,8 +2260,8 @@ LoadMapHeader:: ; 107c (0:107c) dec b jp nz,.loadSpriteLoop .finishUp - predef Func_c754 ; load tileset data - callab LoadWildData ; load wild pokemon data + predef LoadTilesetHeader + callab LoadWildData pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks add a ; double it @@ -2312,7 +2314,7 @@ LoadMapData:: ; 1241 (0:1241) ld [$ffae],a ld [wWalkCounter],a ld [wd119],a - ld [wd11a],a + ld [wWalkBikeSurfStateCopy],a ld [W_SPRITESETID],a call LoadTextBoxTilePatterns call LoadMapHeader @@ -2341,13 +2343,13 @@ LoadMapData:: ; 1241 (0:1241) dec b jr nz,.vramCopyLoop ld a,$01 - ld [wcfcb],a + ld [wUpdateSpritesEnabled],a call EnableLCD ld b,$09 call GoPAL_SET call LoadPlayerSpriteGraphics ld a,[wd732] - and a,$18 ; did the player fly or teleport in? + and a,1 << 4 | 1 << 3 ; fly warp or dungeon warp jr nz,.restoreRomBank ld a,[W_FLAGS_D733] bit 1,a diff --git a/home/predef.asm b/home/predef.asm index 1777d09f..8efe3000 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -7,7 +7,7 @@ Predef:: ld [wPredefID], a ; A hack for LoadDestinationWarpPosition. - ; See Func_c754 (predef $19). + ; See LoadTilesetHeader (predef $19). ld a, [H_LOADEDROMBANK] ld [wPredefParentBank], a diff --git a/main.asm b/main.asm index a64d92b7..22721cdb 100755 --- a/main.asm +++ b/main.asm @@ -19,13 +19,13 @@ SECTION "bank1",ROMX,BANK[$1] INCLUDE "data/facing.asm" -Func_40b0:: +ResetStatusAndHalveMoneyOnBlackout:: ; Reset player status on blackout. xor a ld [wBattleResult], a - ld [wd700], a + ld [wWalkBikeSurfState], a ld [W_ISINBATTLE], a - ld [wd35d], a + ld [wMapPalOffset], a ld [wNPCMovementScriptFunctionNum], a ld [hJoyHeld], a ld [wNPCMovementScriptPointerTableNum], a @@ -578,7 +578,7 @@ TestBattle: ; When the battle ends, ; do it all again. ld a, 1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [H_AUTOBGTRANSFERENABLED], a jr .loop @@ -597,19 +597,20 @@ INCLUDE "engine/menu/main_menu.asm" INCLUDE "engine/oak_speech.asm" -Func_62ce: ; 62ce (1:62ce) - call Func_62ff - predef Func_c754 +SpecialWarpIn: ; 62ce (1:62ce) + call LoadSpecialWarpData + predef LoadTilesetHeader ld hl,wd732 - bit 2,[hl] + bit 2,[hl] ; dungeon warp or fly warp? res 2,[hl] jr z,.next - ld a,[wd71a] +; if dungeon warp or fly warp + ld a,[wDestinationMap] jr .next2 .next bit 1,[hl] jr z,.next3 - call Func_64ea + call EmptyFunc .next3 ld a,0 .next2 @@ -620,125 +621,128 @@ Func_62ce: ; 62ce (1:62ce) ld a,b .next4 ld hl,wd732 - bit 4,[hl] + bit 4,[hl] ; dungeon warp? ret nz +; if not dungeon warp ld [wLastMap],a ret -Func_62ff: ; 62ff (1:62ff) +; gets the map ID, tile block map view pointer, tileset, and coordinates +LoadSpecialWarpData: ; 62ff (1:62ff) ld a, [wd72d] cp BATTLE_CENTER - jr nz, .asm_6314 - ld hl, BattleCenterSpec1 ; $6428 + jr nz, .notBattleCenter + ld hl, BattleCenterSpec1 ld a, [$ffaa] cp $2 - jr z, .asm_6334 - ld hl, BattleCenterSpec2 ; $6430 - jr .asm_6334 -.asm_6314 + jr z, .copyWarpData + ld hl, BattleCenterSpec2 + jr .copyWarpData +.notBattleCenter cp TRADE_CENTER - jr nz, .asm_6326 - ld hl, TradeCenterSpec1 ; $6438 + jr nz, .notTradeCenter + ld hl, TradeCenterSpec1 ld a, [$ffaa] cp $2 - jr z, .asm_6334 - ld hl, TradeCenterSpec2 ; $6440 - jr .asm_6334 -.asm_6326 + jr z, .copyWarpData + ld hl, TradeCenterSpec2 + jr .copyWarpData +.notTradeCenter ld a, [wd732] bit 1, a - jr nz, .asm_6346 + jr nz, .notFirstMap bit 2, a - jr nz, .asm_6346 - ld hl, FirstMapSpec ; $6420 -.asm_6334 - ld de, W_CURMAP ; W_CURMAP + jr nz, .notFirstMap + ld hl, FirstMapSpec +.copyWarpData + ld de, W_CURMAP ld c, $7 -.asm_6339 +.copyWarpDataLoop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_6339 + jr nz, .copyWarpDataLoop ld a, [hli] - ld [W_CURMAPTILESET], a ; W_CURMAPTILESET + ld [W_CURMAPTILESET], a xor a - jr .asm_63b3 -.asm_6346 + jr .done +.notFirstMap ld a, [wLastMap] ld hl, wd732 - bit 4, [hl] - jr nz, .asm_635b - bit 6, [hl] + bit 4, [hl] ; used dungeon warp (jumped down hole/waterfall)? + jr nz, .usedDunegonWarp + bit 6, [hl] ; return to last pokemon center (or player's house)? res 6, [hl] - jr z, .asm_638e + jr z, .otherDestination +; return to last pokemon center or player's house ld a, [wLastBlackoutMap] - jr .asm_6391 -.asm_635b + jr .usedFlyWarp +.usedDunegonWarp ld hl, wd72d res 4, [hl] - ld a, [wd71d] + ld a, [wDungeonWarpDestinationMap] ld b, a - ld [W_CURMAP], a ; W_CURMAP - ld a, [wd71e] + ld [W_CURMAP], a + ld a, [wWhichDungeonWarp] ld c, a - ld hl, DungeonWarpList ; $63bf + ld hl, DungeonWarpList ld de, $0 ld a, $6 ld [wd12f], a -.asm_6376 +.dungeonWarpListLoop ld a, [hli] cp b - jr z, .asm_637d + jr z, .matchedDungeonWarpDestinationMap inc hl - jr .asm_6381 -.asm_637d + jr .nextDungeonWarp +.matchedDungeonWarpDestinationMap ld a, [hli] cp c - jr z, .asm_6388 -.asm_6381 + jr z, .matchedDungeonWarpID +.nextDungeonWarp ld a, [wd12f] add e ld e, a - jr .asm_6376 -.asm_6388 - ld hl, DungeonWarpData ; $63d8 + jr .dungeonWarpListLoop +.matchedDungeonWarpID + ld hl, DungeonWarpData add hl, de - jr .asm_63a4 -.asm_638e - ld a, [wd71a] -.asm_6391 + jr .copyWarpData2 +.otherDestination + ld a, [wDestinationMap] +.usedFlyWarp ld b, a - ld [W_CURMAP], a ; W_CURMAP - ld hl, FlyWarpDataPtr ; $6448 -.asm_6398 + ld [W_CURMAP], a + ld hl, FlyWarpDataPtr +.flyWarpDataPtrLoop ld a, [hli] inc hl cp b - jr z, .asm_63a1 + jr z, .foundFlyWarpMatch inc hl inc hl - jr .asm_6398 -.asm_63a1 + jr .flyWarpDataPtrLoop +.foundFlyWarpMatch ld a, [hli] ld h, [hl] ld l, a -.asm_63a4 - ld de, wd35f +.copyWarpData2 + ld de, wCurrentTileBlockMapViewPointer ld c, $6 -.asm_63a9 +.copyWarpDataLoop2 ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_63a9 - xor a - ld [W_CURMAPTILESET], a ; W_CURMAPTILESET -.asm_63b3 - ld [wd4e2], a - ld [wd4e3], a - ld a, $ff - ld [wd42f], a + jr nz, .copyWarpDataLoop2 + xor a ; OVERWORLD + ld [W_CURMAPTILESET], a +.done + ld [wYOffsetSinceLastSpecialWarp], a + ld [wXOffsetSinceLastSpecialWarp], a + ld a, $ff ; the player's coordinates have already been updated using a special warp, so don't use any of the normal warps + ld [wDestinationWarpID], a ret INCLUDE "data/special_warps.asm" @@ -774,7 +778,7 @@ IshiharaTeam: ; 64df (1:64df) db ARTICUNO,57 db $FF -Func_64ea: ; 64ea (1:64ea) +EmptyFunc: ; 64ea (1:64ea) ret INCLUDE "engine/menu/naming_screen.asm" @@ -989,7 +993,7 @@ SafariZoneRestHouses: DisplayTextIDInit: ; 7096 (1:7096) xor a ld [wListMenuID],a - ld a,[wcf0c] + ld a,[wAutoTextBoxDrawingControl] bit 0,a jr nz,.skipDrawingTextBoxBorder ld a,[$ff8c] ; text ID (or sprite ID) @@ -2005,7 +2009,7 @@ Func_7c18: ; 7c18 (1:7c18) ld hl, wPokedexSeen predef FlagActionPredef ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret @@ -2023,7 +2027,7 @@ Func_c335: ; c335 (3:4335) ld [rWY], a ; $ff4a xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [wd13b], a + ld [wStepCounter], a ld [W_LONEATTACKNO], a ; W_GYMLEADERNO ld [hJoyPressed], a ld [hJoyReleased], a @@ -2038,36 +2042,37 @@ Func_c335: ; c335 (3:4335) call FillMemory ret -Func_c35f: ; c35f (3:435f) - ld a, [wd3ae] +; only used for setting bit 2 of wd736 upon entering a new map +IsPlayerStandingOnWarp: ; c35f (3:435f) + ld a, [wNumberOfWarps] and a ret z ld c, a - ld hl, wd3af -.asm_c368 - ld a, [W_YCOORD] ; wd361 + ld hl, wWarpEntries +.loop + ld a, [W_YCOORD] cp [hl] - jr nz, .asm_c383 + jr nz, .nextWarp1 inc hl - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] cp [hl] - jr nz, .asm_c384 + jr nz, .nextWarp2 inc hl - ld a, [hli] - ld [wd42f], a - ld a, [hl] - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld a, [hli] ; target warp + ld [wDestinationWarpID], a + ld a, [hl] ; target map + ld [$ff8b], a ld hl, wd736 - set 2, [hl] + set 2, [hl] ; standing on warp flag ret -.asm_c383 +.nextWarp1 inc hl -.asm_c384 +.nextWarp2 inc hl inc hl inc hl dec c - jr nz, .asm_c368 + jr nz, .loop ret CheckForceBikeOrSurf: ; c38b (3:438b) @@ -2107,8 +2112,8 @@ CheckForceBikeOrSurf: ; c38b (3:438b) ld hl, wd732 set 5, [hl] ld a, $1 - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf .incorrectMap inc hl @@ -2117,30 +2122,30 @@ CheckForceBikeOrSurf: ; c38b (3:438b) jr .loop .forceSurfing ld a, $2 - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf INCLUDE "data/force_bike_surf.asm" -Func_c3ff: ; c3ff (3:43ff) +IsPlayerFacingEdgeOfMap: ; c3ff (3:43ff) push hl push de push bc - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction srl a ld c, a ld b, $0 - ld hl, PointerTable_c422 ; $4422 + ld hl, .functionPointerTable add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld a, [W_YCOORD] ; wd361 + ld a, [W_YCOORD] ld b, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld c, a - ld de, .asm_c41e ; $441e + ld de, .asm_c41e push de jp [hl] .asm_c41e @@ -2149,34 +2154,34 @@ Func_c3ff: ; c3ff (3:43ff) pop hl ret -PointerTable_c422: ; c422 (3:4422) - dw .asm_c42a - dw .asm_4434 - dw .asm_443A - dw .asm_4440 +.functionPointerTable + dw .facingDown + dw .facingUp + dw .facingLeft + dw .facingRight -.asm_c42a - ld a, [W_CURMAPHEIGHT] ; wd368 +.facingDown + ld a, [W_CURMAPHEIGHT] add a dec a cp b jr z, .setCarry jr .resetCarry -.asm_4434 +.facingUp ld a, b and a jr z, .setCarry jr .resetCarry -.asm_443A +.facingLeft ld a, c and a jr z, .setCarry jr .resetCarry -.asm_4440 - ld a, [W_CURMAPWIDTH] ; wd369 +.facingRight + ld a, [W_CURMAPWIDTH] add a dec a cp c @@ -2189,71 +2194,71 @@ PointerTable_c422: ; c422 (3:4422) scf ret -Func_c44e: ; c44e (3:444e) +IsWarpTileInFrontOfPlayer: ; c44e (3:444e) push hl push de push bc - call Func_c589 - ld a, [W_CURMAP] ; W_CURMAP + call _GetTileAndCoordsInFrontOfPlayer + ld a, [W_CURMAP] cp SS_ANNE_5 jr z, .ssAnne5 - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player sprite's facing direction srl a ld c, a - ld b, $0 - ld hl, .pointerTable_c477 ; $4477 + ld b, 0 + ld hl, .warpTileListPointers add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] ld de, $1 call IsInArray -.asm_c473 +.done pop bc pop de pop hl ret -.pointerTable_c477: ; c477 (3:4477) - dw .arrayData_c47f - dw .arrayData_c487 - dw .arrayData_c48a - dw .arrayData_c48d +.warpTileListPointers: ; c477 (3:4477) + dw .facingDownWarpTiles + dw .facingUpWarpTiles + dw .facingLeftWarpTiles + dw .facingRightWarpTiles -.arrayData_c47f +.facingDownWarpTiles db $01,$12,$17,$3D,$04,$18,$33,$FF -.arrayData_c487 +.facingUpWarpTiles db $01,$5C,$FF -.arrayData_c48a +.facingLeftWarpTiles db $1A,$4B,$FF -.arrayData_c48d +.facingRightWarpTiles db $0F,$4E,$FF .ssAnne5 - ld a, [wcfc6] + ld a, [wTileInFrontOfPlayer] cp $15 - jr nz, .asm_c49a + jr nz, .notSSAnne5Warp scf - jr .asm_c473 -.asm_c49a + jr .done +.notSSAnne5Warp and a - jr .asm_c473 + jr .done -Func_c49d: ; c49d (3:449d) +IsPlayerStandingOnDoorTileOrWarpTile: ; c49d (3:449d) push hl push de push bc - callba IsPlayerStandingOnDoor - jr c, .asm_c4c8 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + callba IsPlayerStandingOnDoorTile + jr c, .done + ld a, [W_CURMAPTILESET] add a ld c, a ld b, $0 - ld hl, WarpTileIDPointers ; $44cc + ld hl, WarpTileIDPointers add hl, bc ld a, [hli] ld h, [hl] @@ -2261,10 +2266,10 @@ Func_c49d: ; c49d (3:449d) ld de, $1 aCoord 8, 9 call IsInArray - jr nc, .asm_c4c8 + jr nc, .done ld hl, wd736 res 2, [hl] -.asm_c4c8 +.done pop bc pop de pop hl @@ -2310,223 +2315,237 @@ SafariSteps: ; c579 (3:4579) SafariBallText: ; c57e (3:457e) db "BALL×× @" -Func_c586: ; c586 (3:4586) +GetTileAndCoordsInFrontOfPlayer: ; c586 (3:4586) call GetPredefRegisters -Func_c589: ; c589 (3:4589) - ld a, [W_YCOORD] ; wd361 +_GetTileAndCoordsInFrontOfPlayer: ; c589 (3:4589) + ld a, [W_YCOORD] ld d, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld e, a - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_c59d + jr nz, .notFacingDown +; facing down aCoord 8, 11 inc d - jr .asm_c5b9 -.asm_c59d - cp $4 - jr nz, .asm_c5a7 + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up aCoord 8, 7 dec d - jr .asm_c5b9 -.asm_c5a7 - cp $8 - jr nz, .asm_c5b1 + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left aCoord 6, 9 dec e - jr .asm_c5b9 -.asm_c5b1 - cp $c - jr nz, .asm_c5b9 + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right aCoord 10, 9 inc e -.asm_c5b9 +.storeTile ld c, a - ld [wcfc6], a + ld [wTileInFrontOfPlayer], a ret -Func_c5be: ; c5be (3:45be) +GetTileTwoStepsInFrontOfPlayer: ; c5be (3:45be) xor a ld [$ffdb], a - ld hl, W_YCOORD ; wd361 + ld hl, W_YCOORD ld a, [hli] ld d, a ld e, [hl] - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_c5d8 + jr nz, .notFacingDown +; facing down ld hl, $ffdb set 0, [hl] aCoord 8, 13 inc d - jr .asm_c603 -.asm_c5d8 - cp $4 - jr nz, .asm_c5e7 + jr .storeTile +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up ld hl, $ffdb set 1, [hl] aCoord 8, 5 dec d - jr .asm_c603 -.asm_c5e7 - cp $8 - jr nz, .asm_c5f6 + jr .storeTile +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left ld hl, $ffdb set 2, [hl] aCoord 4, 9 dec e - jr .asm_c603 -.asm_c5f6 - cp $c - jr nz, .asm_c603 + jr .storeTile +.notFacingLeft + cp SPRITE_FACING_RIGHT + jr nz, .storeTile +; facing right ld hl, $ffdb set 3, [hl] aCoord 12, 9 inc e -.asm_c603 +.storeTile ld c, a - ld [wd71c], a - ld [wcfc6], a + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a + ld [wTileInFrontOfPlayer], a ret -Func_c60b: ; c60b (3:460b) - call Func_c5be +CheckForCollisionWhenPushingBoulder: ; c60b (3:460b) + call GetTileTwoStepsInFrontOfPlayer ld hl, W_TILESETCOLLISIONPTR ld a, [hli] ld h, [hl] ld l, a -.asm_c614 +.loop ld a, [hli] cp $ff - jr z, .asm_c632 + jr z, .done ; if the tile two steps ahead is not passable cp c - jr nz, .asm_c614 - ld hl, $c7e - call Func_c44 + jr nz, .loop + ld hl, TilePairCollisionsLand + call CheckForTilePairCollisions2 ld a, $ff - jr c, .asm_c632 - ld a, [wd71c] - cp $15 + jr c, .done ; if there is an elevation difference between the current tile and the one two steps ahead + ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] + cp $15 ; stairs tile ld a, $ff - jr z, .asm_c632 - call Func_c636 -.asm_c632 - ld [wd71c], a + jr z, .done ; if the tile two steps ahead is stairs + call CheckForBoulderCollisionWithSprites +.done + ld [wTileInFrontOfBoulderAndBoulderCollisionResult], a ret -Func_c636: ; c636 (3:4636) - ld a, [wd718] +; sets a to $ff if there is a collision and $00 if there is no collision +CheckForBoulderCollisionWithSprites: ; c636 (3:4636) + ld a, [wBoulderSpriteIndex] dec a swap a - ld d, $0 + ld d, 0 ld e, a ld hl, wSpriteStateData2 + $14 add hl, de - ld a, [hli] + ld a, [hli] ; map Y position ld [$ffdc], a - ld a, [hl] + ld a, [hl] ; map X position ld [$ffdd], a - ld a, [W_NUMSPRITES] ; W_NUMSPRITES + ld a, [W_NUMSPRITES] ld c, a ld de, $f ld hl, wSpriteStateData2 + $14 ld a, [$ffdb] - and $3 - jr z, .asm_c678 -.asm_c659 + and $3 ; facing up or down? + jr z, .pushingHorizontallyLoop +.pushingVerticallyLoop inc hl ld a, [$ffdd] cp [hl] - jr nz, .asm_c672 + jr nz, .nextSprite1 ; if X coordinates don't match dec hl ld a, [hli] ld b, a ld a, [$ffdb] rrca - jr c, .asm_c66c + jr c, .pushingDown +; pushing up ld a, [$ffdc] dec a - jr .asm_c66f -.asm_c66c + jr .compareYCoords +.pushingDown ld a, [$ffdc] inc a -.asm_c66f +.compareYCoords cp b - jr z, .asm_c697 -.asm_c672 + jr z, .failure +.nextSprite1 dec c - jr z, .asm_c69a + jr z, .success add hl, de - jr .asm_c659 -.asm_c678 + jr .pushingVerticallyLoop +.pushingHorizontallyLoop ld a, [hli] ld b, a ld a, [$ffdc] cp b - jr nz, .asm_c691 + jr nz, .nextSprite2 ld b, [hl] ld a, [$ffdb] bit 2, a - jr nz, .asm_c68b + jr nz, .pushingLeft +; pushing right ld a, [$ffdd] inc a - jr .asm_c68e -.asm_c68b + jr .compareXCoords +.pushingLeft ld a, [$ffdd] dec a -.asm_c68e +.compareXCoords cp b - jr z, .asm_c697 -.asm_c691 + jr z, .failure +.nextSprite2 dec c - jr z, .asm_c69a + jr z, .success add hl, de - jr .asm_c678 -.asm_c697 + jr .pushingHorizontallyLoop +.failure ld a, $ff ret -.asm_c69a +.success xor a ret -Func_c69c: ; c69c (3:469c) +ApplyOutOfBattlePoisonDamage: ; c69c (3:469c) ld a, [wd730] add a - jp c, .asm_c74f - ld a, [wPartyCount] ; wPartyCount + jp c, .noBlackOut + ld a, [wPartyCount] and a - jp z, .asm_c74f - call Func_c8de - ld a, [wd13b] - and $3 - jp nz, .asm_c74f - ld [wWhichPokemon], a ; wWhichPokemon - ld hl, wPartyMon1Status ; wPartyMon1Status - ld de, wPartySpecies ; wPartySpecies -.asm_c6be + jp z, .noBlackOut + call IncrementDayCareMonExp + ld a, [wStepCounter] + and $3 ; is the counter a multiple of 4? + jp nz, .noBlackOut ; only apply poison damage every fourth step + ld [wWhichPokemon], a + ld hl, wPartyMon1Status + ld de, wPartySpecies +.applyDamageLoop ld a, [hl] - and $8 - jr z, .asm_c6fd + and (1 << PSN) + jr z, .nextMon2 ; not poisoned dec hl dec hl ld a, [hld] ld b, a ld a, [hli] or b - jr z, .asm_c6fb + jr z, .nextMon ; already fainted +; subtract 1 from HP ld a, [hl] dec a ld [hld], a inc a - jr nz, .asm_c6d5 + jr nz, .noBorrow +; borrow 1 from upper byte of HP dec [hl] inc hl - jr .asm_c6fb -.asm_c6d5 + jr .nextMon +.noBorrow ld a, [hli] or [hl] - jr nz, .asm_c6fb + jr nz, .nextMon ; didn't faint from damage +; the mon fainted from the damage push hl inc hl inc hl @@ -2534,134 +2553,134 @@ Func_c69c: ; c69c (3:469c) ld a, [de] ld [wd11e], a push de - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, wPartyMonNicks ; wPartyMonNicks + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName xor a ld [wJoyIgnore], a call EnableAutoTextBoxDrawing ld a, $d0 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [$ff8c], a call DisplayTextID pop de pop hl -.asm_c6fb +.nextMon inc hl inc hl -.asm_c6fd +.nextMon2 inc de ld a, [de] inc a - jr z, .asm_c70e - ld bc, $2c + jr z, .applyDamageLoopDone + ld bc, wPartyMon2 - wPartyMon1 add hl, bc push hl - ld hl, wWhichPokemon ; wWhichPokemon + ld hl, wWhichPokemon inc [hl] pop hl - jr .asm_c6be -.asm_c70e - ld hl, wPartyMon1Status ; wPartyMon1Status - ld a, [wPartyCount] ; wPartyCount + jr .applyDamageLoop +.applyDamageLoopDone + ld hl, wPartyMon1Status + ld a, [wPartyCount] ld d, a - ld e, $0 -.asm_c717 + ld e, 0 +.countPoisonedLoop ld a, [hl] - and $8 + and (1 << PSN) or e ld e, a - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 add hl, bc dec d - jr nz, .asm_c717 + jr nz, .countPoisonedLoop ld a, e - and a - jr z, .asm_c733 + and a ; are any party members poisoned? + jr z, .skipPoisonEffectAndSound ld b, $2 - predef Func_480eb + predef ChangeBGPalColor0_4Frames ; change BG white to dark grey for 4 frames ld a, (SFX_02_43 - SFX_Headers_02) / 3 call PlaySound -.asm_c733 +.skipPoisonEffectAndSound predef AnyPartyAlive ld a, d and a - jr nz, .asm_c74f + jr nz, .noBlackOut call EnableAutoTextBoxDrawing ld a, $d1 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [$ff8c], a call DisplayTextID ld hl, wd72e set 5, [hl] ld a, $ff - jr .asm_c750 -.asm_c74f + jr .done +.noBlackOut xor a -.asm_c750 +.done ld [wd12d], a ret -Func_c754: ; c754 (3:4754) +LoadTilesetHeader: ; c754 (3:4754) call GetPredefRegisters push hl - ld d, $0 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld d, 0 + ld a, [W_CURMAPTILESET] add a add a ld b, a add a - add b - jr nc, .asm_c765 + add b ; a = tileset * 12 + jr nc, .noCarry inc d -.asm_c765 +.noCarry ld e, a ld hl, Tilesets add hl, de ld de, W_TILESETBANK ld c, $b -.asm_c76f +.copyTilesetHeaderLoop ld a, [hli] ld [de], a inc de dec c - jr nz, .asm_c76f + jr nz, .copyTilesetHeaderLoop ld a, [hl] ld [$ffd7], a xor a ld [$ffd8], a pop hl - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [W_CURMAPTILESET] push hl push de - ld hl, DungeonTilesets ; $47b2 + ld hl, DungeonTilesets ld de, $1 call IsInArray pop de pop hl jr c, .asm_c797 - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [W_CURMAPTILESET] ld b, a - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [$ff8b] cp b - jr z, .asm_c7b1 + jr z, .done .asm_c797 - ld a, [wd42f] + ld a, [wDestinationWarpID] cp $ff - jr z, .asm_c7b1 + jr z, .done call LoadDestinationWarpPosition - ld a, [W_YCOORD] ; wd361 + ld a, [W_YCOORD] and $1 - ld [W_YBLOCKCOORD], a ; wd363 - ld a, [W_XCOORD] ; wd362 + ld [W_YBLOCKCOORD], a + ld a, [W_XCOORD] and $1 - ld [W_XBLOCKCOORD], a ; wd364 -.asm_c7b1 + ld [W_XBLOCKCOORD], a +.done ret INCLUDE "data/dungeon_tilesets.asm" INCLUDE "data/tileset_headers.asm" -Func_c8de: ; c8de (3:48de) +IncrementDayCareMonExp: ; c8de (3:48de) ld a, [W_DAYCARE_IN_USE] and a ret z @@ -3073,9 +3092,9 @@ Func_ee9e: ; ee9e (3:6e9e) add hl, bc ld a, [wd09f] ld [hl], a - ld a, [wd35f] + ld a, [wCurrentTileBlockMapViewPointer] ld c, a - ld a, [wd360] + ld a, [wCurrentTileBlockMapViewPointer + 1] ld b, a call Func_ef4e ret c @@ -3399,7 +3418,7 @@ TryPushingBoulder: ; f225 (3:7225) ld [$ff8c], a call IsSpriteInFrontOfPlayer ld a, [$ff8c] - ld [wd718], a + ld [wBoulderSpriteIndex], a and a jp z, ResetBoulderPushFlags ld hl, wSpriteStateData1 + 1 @@ -3420,9 +3439,9 @@ TryPushingBoulder: ; f225 (3:7225) ld a, [hJoyHeld] and $f0 ret z - predef Func_c60b - ld a, [wd71c] - and a + predef CheckForCollisionWhenPushingBoulder + ld a, [wTileInFrontOfBoulderAndBoulderCollisionResult] + and a ; was there a collision? jp nz, ResetBoulderPushFlags ld a, [hJoyHeld] ld b, a @@ -3481,8 +3500,8 @@ DoBoulderDustAnimation: ; f2b5 (3:72b5) ld [wJoyIgnore], a call ResetBoulderPushFlags set 7, [hl] - ld a, [wd718] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld a, [wBoulderSpriteIndex] + ld [H_SPRITEINDEX], a call GetSpriteMovementByte2Pointer ld [hl], $10 ld a, (SFX_02_56 - SFX_Headers_02) / 3 diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index b30a8602..14882d1a 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -57,7 +57,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5) ld a, $f0 ld [wJoyIgnore], a ld a, $2 - ld [wcf13], a + ld [wSpriteIndex], a ld a, $c ld [$ffeb], a ld a, $40 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 9746f54e..87239910 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -236,7 +236,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a) ld hl, wd77e set 2, [hl] ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, Received10CoinsText jr .asm_c7d1a ; 0x48d87 .asm_d0957 ; 0x48d89 @@ -411,7 +411,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d) ld de, CeladonGameCornerText_48ed3 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a @@ -437,7 +437,7 @@ CeladonGameCornerText13: ; 48ed8 (12:4ed8) CeladonGameCornerText12: ; 48edd (12:4edd) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CeladonGameCornerText_48f09 call PrintText call WaitForSoundToFinish diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm index 6d44175e..092bff88 100755 --- a/scripts/celadongym.asm +++ b/scripts/celadongym.asm @@ -179,7 +179,7 @@ CeladonGymText1: ; 48a11 (12:4a11) ld de, CeladonGymText_48a63 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $4 diff --git a/scripts/celadonmansion3.asm b/scripts/celadonmansion3.asm index 73cd45ed..47190c92 100755 --- a/scripts/celadonmansion3.asm +++ b/scripts/celadonmansion3.asm @@ -51,7 +51,7 @@ DirectorText: ; 487b2 (12:47b2) db $8 ; asm callab DisplayDiploma ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a jp TextScriptEnd GameFreakPCText1: ; 487eb (12:47eb) diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm index 1e32647d..ff835765 100755 --- a/scripts/celadonmartelevator.asm +++ b/scripts/celadonmartelevator.asm @@ -9,13 +9,13 @@ CeladonMartElevatorScript: ; 48600 (12:4600) res 7, [hl] call nz, CeladonMartElevatorScript_48654 xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret CeladonMartElevatorScript_4861c: ; 4861c (12:461c) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index 37025525..fa34b8cd 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -230,7 +230,7 @@ CeladonMartRoofText2: ; 4856c (12:456c) and a jr z, .asm_914b9 ; 0x48574 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CeladonMartRoofText4 call PrintText call YesNoChoice diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index 90ccab67..d97f9723 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -64,7 +64,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) ld hl, CeruleanCityCoords2 call ArePlayerCoordsInArray ret nc - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_19512 ; 0x19508 $8 ld a, $ff @@ -279,7 +279,7 @@ CeruleanCityText2: ; 1967c (6:567c) ld de, CeruleanCityText_196ee call PreBattleSaveRegisters ld a, [$ff8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $4 @@ -296,7 +296,7 @@ CeruleanCityText2: ; 1967c (6:567c) jr .Done .Success ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, ReceivedTM28Text call PrintText callba Func_74872 diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm index 57c9ea4a..e65ef2c5 100755 --- a/scripts/ceruleancity2.asm +++ b/scripts/ceruleancity2.asm @@ -2,7 +2,7 @@ Func_74872: ; 74872 (1d:4872) ; code similar to this appears in a lot of banks; this particular ; one is called after you beat the Rocket that gives you TM28 DIG. ; the screen then fades out, he disappears, and fades back in - call GBFadeIn1 + call GBFadeOutToBlack ld a, $07 ld [wcc4d], a predef ShowObject @@ -12,5 +12,5 @@ Func_74872: ; 74872 (1d:4872) ld a, $06 ld [wcc4d], a predef HideObject - call GBFadeOut1 + call GBFadeInFromBlack ret diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm index 19296fe2..ae6a40a0 100755 --- a/scripts/ceruleangym.asm +++ b/scripts/ceruleangym.asm @@ -128,7 +128,7 @@ CeruleanGymText1: ; 5c771 (17:4771) ld de, CeruleanGymText_5c7d8 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $2 diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm index 7cc1aa74..3fa72183 100755 --- a/scripts/ceruleanhouse2.asm +++ b/scripts/ceruleanhouse2.asm @@ -1,8 +1,8 @@ CeruleanHouse2Script: ; 74e09 (1d:4e09) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a dec a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret CeruleanHouse2TextPointers: ; 74e13 (1d:4e13) diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 8ce02e81..65fd1db9 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -187,13 +187,13 @@ CinnabarGymTextPointers: ; 7589f (1d:589f) CinnabarGymScript_758b7: ; 758b7 (1d:58b7) ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld hl, wd72d set 6, [hl] set 7, [hl] - ld a, [wcf13] + ld a, [wSpriteIndex] cp $1 jr z, .asm_758d4 ld a, $2 diff --git a/scripts/copycatshouse2f.asm b/scripts/copycatshouse2f.asm index ea1e91b3..b7a1255c 100755 --- a/scripts/copycatshouse2f.asm +++ b/scripts/copycatshouse2f.asm @@ -16,7 +16,7 @@ CopycatsHouse2FText1: ; 5cc82 (17:4c82) bit 0, a jr nz, .asm_7ccf3 ; 0x5cc88 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, CopycatsHouse2FText_5ccd4 call PrintText ld b, POKE_DOLL diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index 55a9f111..f2bf3188 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -24,7 +24,7 @@ DayCareMText1: ; 56254 (15:6254) ld hl, DayCareMText_56414 call PrintText xor a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wd07d], a ld [wMenuItemToSwap], a call DisplayPartyMenu diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 0fbff74a..fb8d7b19 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -149,7 +149,7 @@ FightingDojoText1: ; 5ce44 (17:4e44) ld de, FightingDojoText_5ce93 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm index 09a767eb..14ffdfa9 100755 --- a/scripts/fuchsiagym.asm +++ b/scripts/fuchsiagym.asm @@ -168,7 +168,7 @@ FuchsiaGymText1: ; 75534 (1d:5534) ld de, UnnamedText_75586 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $5 diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index ee1b42b4..7621897f 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -106,7 +106,7 @@ Mansion1Text4: ; 4435a (11:435a) and a jr nz, .asm_4438c ; 0x44368 $22 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd126 set 5, [hl] ld hl, MansionSwitchPressedText diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 30261637..1b7a28a3 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -112,7 +112,7 @@ Mansion2Text5: ; 52087 (14:6087) and a jr nz, .asm_520b9 ; 0x52095 $22 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, wd126 set 5, [hl] ld hl, Mansion2Text_520c7 diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm index 4e9c2271..494fba13 100755 --- a/scripts/mansion3.asm +++ b/scripts/mansion3.asm @@ -40,7 +40,7 @@ Mansion3ScriptPointers: ; 52235 (14:6235) Mansion3Script0: ; 5223b (14:623b) ld hl, CoordsData_52254 call Mansion3Script_5225b - ld a, [wd71e] + ld a, [wWhichDungeonWarp] and a jp z, CheckFightingMapTrainers cp $3 @@ -48,7 +48,7 @@ Mansion3Script0: ; 5223b (14:623b) jr nz, .asm_52250 ld a, $d6 .asm_52250 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ret CoordsData_52254: ; 52254 (14:6254) @@ -59,14 +59,14 @@ CoordsData_52254: ; 52254 (14:6254) Mansion3Script_5225b: ; 5225b (14:625b) xor a - ld [wd71e], a + ld [wWhichDungeonWarp], a ld a, [wd72d] bit 4, a ret nz call ArePlayerCoordsInArray ret nc ld a, [wWhichTrade] ; wWhichTrade - ld [wd71e], a + ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] ld hl, wd732 diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index 8d6aaeed..71638409 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -138,7 +138,7 @@ MtMoon3Script5: ; 49dfb (12:5dfb) ld a, $f0 ld [wJoyIgnore], a ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld a, $a ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID @@ -230,7 +230,7 @@ MtMoon3Text1: ; 49e79 (12:5e79) ld de, MtMoon3Text_49f8a call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 @@ -270,7 +270,7 @@ MtMoon3Text5: ; 49edf (12:5edf) MtMoon3Text6: ; 49ee9 (12:5ee9) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, MtMoon3Text_49f24 call PrintText call YesNoChoice @@ -299,7 +299,7 @@ MtMoon3Text_49f24: ; 49f24 (12:5f24) MtMoon3Text7: ; 49f29 (12:5f29) db $08 ; asm ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, MtMoon3Text_49f64 call PrintText call YesNoChoice diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index 10dc9f42..a701e1a4 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -1,8 +1,8 @@ Museum1FScript: ; 5c0f7 (17:40f7) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, Museum1FScriptPointers ld a, [W_MUSEUM1FCURSCRIPT] jp CallFunctionInTable diff --git a/scripts/namerater.asm b/scripts/namerater.asm index 2295944f..c9e3bfb4 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -50,7 +50,7 @@ NameRaterText1: ; 1da56 (7:5a56) call PrintText xor a ld [wd07d], a - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld [wMenuItemToSwap], a call DisplayPartyMenu push af diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index faf86f1a..8666d18e 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -3,9 +3,9 @@ OaksLabScript: ; 1cb0e (7:4b0e) bit 6, a call nz, OaksLabScript_1d076 ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, OaksLabScriptPointers ld a, [W_OAKSLABCURSCRIPT] jp CallFunctionInTable @@ -374,7 +374,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) .done ld [W_TRAINERNO], a ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 @@ -397,7 +397,7 @@ OaksLabScript12: ; 1ce03 (7:4e03) ld [wd528], a call UpdateSprites ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $1 ld [H_SPRITEINDEX], a @@ -680,7 +680,7 @@ OaksLabScript_1d02b: ; 1d02b (7:502b) ld a, b ld [$ffed], a ld a, $1 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ret @@ -801,7 +801,7 @@ OaksLabScript_1d133: ; 1d133 (7:5133) ld [wcf91], a ld [wd11e], a ld a, b - ld [wcf13], a + ld [wSpriteIndex], a ld a, [wd74b] bit 2, a jp nz, OaksLabScript_1d22d @@ -837,7 +837,7 @@ OaksLabScript_1d157: ; 1d157 (7:5157) call ReloadMapData ld c, $a call DelayFrames - ld a, [wcf13] + ld a, [wSpriteIndex] cp $2 jr z, OaksLabLookAtCharmander cp $3 @@ -868,7 +868,7 @@ OaksLabBulbasaurText: ; 1d1ae (7:51ae) OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3) call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a call YesNoChoice ; yes/no menu ld a, [wCurrentMenuItem] and a @@ -877,7 +877,7 @@ OaksLabMonChoiceMenu: ; 1d1b3 (7:51b3) ld [W_PLAYERSTARTER], a ld [wd11e], a call GetMonName - ld a, [wcf13] + ld a, [wSpriteIndex] cp $2 jr nz, asm_1d1db ; 0x1d1d5 $4 ld a, $2b @@ -893,7 +893,7 @@ asm_1d1e5: ; 1d1e5 (7:51e5) ld [wcc4d], a predef HideObject ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, OaksLabMonEnergeticText call PrintText ld hl, OaksLabReceivedMonText @@ -956,7 +956,7 @@ OaksLabText5: ; 1d248 (7:5248) ld hl, OaksLabText_1d31d call PrintText ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a predef DisplayDexRating jp .asm_0f042 .asm_b28b0 ; 0x1d279 diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index 59660a90..e7bd2f57 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -109,7 +109,7 @@ PalletTownScript3: ; 18f12 (6:4f12) ld a,$FF ld [wJoyIgnore],a ld a,1 - ld [wcf13],a + ld [wSpriteIndex],a xor a ld [wNPCMovementScriptFunctionNum],a ld a,1 @@ -171,7 +171,7 @@ PalletTownText1: ; 18f96 (6:4f96) and a jr nz,.next ld a,1 - ld [wcc3c],a + ld [wDoNotWaitForButtonPressAfterDisplayingText],a ld hl,OakAppearsText jr .done .next diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index 2b8dfc3f..ba32454a 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -68,7 +68,7 @@ PewterCityScript1: ; 19280 (6:5280) ld a, $11 ld [$ffee], a ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $3 ld [$ff8c], a @@ -94,7 +94,7 @@ PewterCityScript2: ; 192d3 (6:52d3) PewterCityScript3: ; 192e9 (6:52e9) ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition2 ld a, $3 ld [wcc4d], a @@ -132,7 +132,7 @@ PewterCityScript4: ; 19305 (6:5305) ld a, $10 ld [$ffee], a ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition1 ld a, $5 ld [$ff8c], a @@ -158,7 +158,7 @@ PewterCityScript5: ; 19359 (6:5359) PewterCityScript6: ; 1936f (6:536f) ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call SetSpritePosition2 ld a, $4 ld [wcc4d], a @@ -216,7 +216,7 @@ PewterCityText3: ; 193b1 (6:53b1) ldh a, [$b8] ld [wNPCMovementScriptBank], a ld a, $3 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition2 ld a, $1 ld [W_PEWTERCITYCURSCRIPT], a @@ -280,7 +280,7 @@ PewterCityText5: ; 19436 (6:5436) ldh a, [$b8] ld [wNPCMovementScriptBank], a ld a, $5 - ld [wcf13], a + ld [wSpriteIndex], a call GetSpritePosition2 ld a, $4 ld [W_PEWTERCITYCURSCRIPT], a diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 2feb9817..0ab4c3a4 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -128,7 +128,7 @@ PewterGymText1: ; 5c44e (17:444e) ld de, PewterGymText_5c4bc call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $1 diff --git a/scripts/pewtermart.asm b/scripts/pewtermart.asm index 4e867aee..8fe99d94 100755 --- a/scripts/pewtermart.asm +++ b/scripts/pewtermart.asm @@ -1,7 +1,7 @@ PewterMartScript: ; 74cad (1d:4cad) call EnableAutoTextBoxDrawing ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a ret PewterMartTextPointers: ; 74cb6 (1d:4cb6) diff --git a/scripts/pewterpokecenter.asm b/scripts/pewterpokecenter.asm index 1871ad5f..2f4fd7af 100755 --- a/scripts/pewterpokecenter.asm +++ b/scripts/pewterpokecenter.asm @@ -18,7 +18,7 @@ PewterPokecenterText2: ; 5c596 (17:4596) PewterPokecenterText3: ; 5c59b (17:459b) db $8 ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, PewterPokecenterText5 call PrintText ld a, $ff diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm index 317690a2..6dd694ac 100755 --- a/scripts/pokemontower5.asm +++ b/scripts/pokemontower5.asm @@ -33,10 +33,10 @@ PokemonTower5Script0: ; 6094b (18:494b) ld hl, wd72e set 4, [hl] predef HealParty - call GBFadeOut2 + call GBFadeOutToWhite call Delay3 call Delay3 - call GBFadeIn2 + call GBFadeInFromWhite ld a, $7 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 431855cb..6ebf15d5 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -30,7 +30,7 @@ PokemonTower7Script2: ; 60d23 (18:4d23) call EndTrainerBattle ld a, $f0 ld [wJoyIgnore], a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID call PokemonTower7Script_60db6 @@ -44,7 +44,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) bit 0, a ret nz ld hl, W_MISSABLEOBJECTLIST - ld a, [wcf13] + ld a, [wSpriteIndex] ld b, a .missableObjectsListLoop ld a, [hli] @@ -55,7 +55,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) predef HideObject xor a ld [wJoyIgnore], a - ld [wcf13], a + ld [wSpriteIndex], a ld [wTrainerHeaderFlagBit], a ld [wda38], a ld a, $0 @@ -74,7 +74,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) ld a, $95 ld [H_DOWNARROWBLINKCNT1], a ; $ff8b ld a, $1 - ld [wd42f], a + ld [wDestinationWarpID], a ld a, LAVENDER_TOWN ld [wLastMap], a ld hl, wd72d @@ -86,7 +86,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) PokemonTower7Script_60db6: ; 60db6 (18:4db6) ld hl, CoordsData_60de3 ; $4de3 - ld a, [wcf13] + ld a, [wSpriteIndex] dec a swap a ld d, $0 @@ -106,7 +106,7 @@ PokemonTower7Script_60db6: ; 60db6 (18:4db6) ld a, [hli] ld d, [hl] ld e, a - ld a, [wcf13] + ld a, [wSpriteIndex] ld [H_DOWNARROWBLINKCNT2], a ; $ff8c jp MoveSprite .asm_60dde diff --git a/scripts/redshouse1f.asm b/scripts/redshouse1f.asm index 0e3e331b..7b3f1f87 100755 --- a/scripts/redshouse1f.asm +++ b/scripts/redshouse1f.asm @@ -25,7 +25,7 @@ MomWakeUpText: ; 48185 (12:4185) MomHealPokemon: ; 4818a (12:418a) ld hl, MomHealText1 call PrintText - call GBFadeOut2 + call GBFadeOutToWhite call ReloadMapData predef HealParty ld a, MUSIC_PKMN_HEALED @@ -38,7 +38,7 @@ MomHealPokemon: ; 4818a (12:418a) ld a, [wd35b] ld [wc0ee], a call PlaySound - call GBFadeIn2 + call GBFadeInFromWhite ld hl, MomHealText2 jp PrintText diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 5c99f3a1..ddac941a 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -58,7 +58,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6) ld a, $a ld [H_SPRITEHEIGHT], a call DisplayTextID - call GBFadeIn1 + call GBFadeOutToBlack ld a, $83 ld [wcc4d], a predef HideObject @@ -66,7 +66,7 @@ RocketHideout4Script3: ; 454b6 (11:54b6) ld [wcc4d], a predef ShowObject call UpdateSprites - call GBFadeOut1 + call GBFadeInFromBlack xor a ld [wJoyIgnore], a ld hl, wd126 @@ -132,7 +132,7 @@ RocketHideout4Text1: ; 4553a (11:553a) ld de, RocketHideout4Text_4557f call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm index 73313dd7..e7bc24f3 100755 --- a/scripts/rockethideoutelevator.asm +++ b/scripts/rockethideoutelevator.asm @@ -9,13 +9,13 @@ RocketHideoutElevatorScript: ; 45710 (11:5710) res 7, [hl] call nz, RocketHideoutElevatorScript_4575f xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret RocketHideoutElevatorScript_4572c: ; 4572c (11:572c) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/route12gateupstairs.asm b/scripts/route12gateupstairs.asm index 94a4f9a2..c4c05cd6 100755 --- a/scripts/route12gateupstairs.asm +++ b/scripts/route12gateupstairs.asm @@ -75,5 +75,5 @@ Route12GateUpstairsScript_495c9: ; 495c9 (12:55c9) call PrintText xor a .asm_495d8 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a jp TextScriptEnd diff --git a/scripts/route22.asm b/scripts/route22.asm index cd47d1dc..667edd65 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -83,7 +83,7 @@ Route22Script0: ; 50f00 (14:4f00) xor a ld [wcd50], a predef EmotionBubble - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .asm_50f4e ; 0x50f44 $8 ld a, $ff @@ -222,7 +222,7 @@ Route22Script_5104e: ; 5104e (14:504e) xor a ld [wcd50], a predef EmotionBubble - ld a, [wd700] + ld a, [wWalkBikeSurfState] and a jr z, .skipYVisibilityTesta ld a, $ff diff --git a/scripts/route24.asm b/scripts/route24.asm index 89ddeded..ea48053b 100755 --- a/scripts/route24.asm +++ b/scripts/route24.asm @@ -171,7 +171,7 @@ Route24Text1: ; 514a4 (14:54a4) ld de, Route24Text_5152b call PreBattleSaveRegisters ld a, [$ff8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm index 336d40e9..39f4df10 100755 --- a/scripts/saffrongym.asm +++ b/scripts/saffrongym.asm @@ -180,7 +180,7 @@ SaffronGymText1: ; 5d118 (17:5118) ld de, SaffronGymText_5d167 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $6 diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm index 55bbd43e..1fe0852b 100755 --- a/scripts/seafoamislands1.asm +++ b/scripts/seafoamislands1.asm @@ -34,7 +34,7 @@ SeafoamIslands1Script: ; 447e9 (11:47e9) predef_jump ShowObject .asm_4483b ld a, $9f - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam1HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm index b14c16d8..e392620a 100755 --- a/scripts/seafoamislands2.asm +++ b/scripts/seafoamislands2.asm @@ -32,7 +32,7 @@ SeafoamIslands2Script: ; 46315 (11:6315) predef_jump ShowObject .asm_46362 ld a, $a0 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam2HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm index aa7b3615..ba34a2c3 100755 --- a/scripts/seafoamislands3.asm +++ b/scripts/seafoamislands3.asm @@ -32,7 +32,7 @@ SeafoamIslands3Script: ; 46451 (11:6451) predef_jump ShowObject .asm_4649e ld a, $a1 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam3HolesCoords jp Func_46981 diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm index 909a8d9a..a56382dd 100755 --- a/scripts/seafoamislands4.asm +++ b/scripts/seafoamislands4.asm @@ -33,7 +33,7 @@ SeafoamIslands4Script: ; 4658d (11:658d) jr .asm_465ed ; 0x465da $11 .asm_465dc ld a, $a2 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, Seafoam4HolesCoords call Func_46981 ld a, [wd732] diff --git a/scripts/seafoamislands5.asm b/scripts/seafoamislands5.asm index c4936ac1..b554034b 100755 --- a/scripts/seafoamislands5.asm +++ b/scripts/seafoamislands5.asm @@ -130,8 +130,8 @@ SeafoamIslands5Script3: ; 46860 (11:6860) SeaFoamIslands5Script_46872: ; 46872 (11:6872) xor a - ld [wd700], a - ld [wd11a], a + ld [wWalkBikeSurfState], a + ld [wWalkBikeSurfStateCopy], a jp ForceBikeOrSurf SeafoamIslands5TextPointers: ; 4687c (11:687c) diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index dfdfbe1d..32a455ec 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -182,11 +182,11 @@ SilphCo11Script5: ; 62227 (18:6227) ld a, $6 ld [H_DOWNARROWBLINKCNT2], a ; $ff8c call DisplayTextID - call GBFadeIn1 + call GBFadeOutToBlack call SilphCo11Script_6216d call UpdateSprites call Delay3 - call GBFadeOut1 + call GBFadeInFromBlack ld hl, wd838 set 7, [hl] xor a @@ -223,7 +223,7 @@ SilphCo11Script4: ; 62293 (18:6293) ld de, SilphCo10Text_62330 ; $6330 call PreBattleSaveRegisters ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters xor a diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm index c4f7a895..44059b56 100755 --- a/scripts/silphco9.asm +++ b/scripts/silphco9.asm @@ -164,9 +164,9 @@ SilphCo9Text1: ; 5d8b8 (17:58b8) ld hl, SilphCo9Text_5d8e5 call PrintText predef HealParty - call GBFadeOut2 + call GBFadeOutToWhite call Delay3 - call GBFadeIn2 + call GBFadeInFromWhite ld hl, SilphCo9Text_5d8ea call PrintText jr .asm_b6e28 ; 0x5d8da diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm index 853d7357..48d406cc 100755 --- a/scripts/silphcoelevator.asm +++ b/scripts/silphcoelevator.asm @@ -9,13 +9,13 @@ SilphCoElevatorScript: ; 457c0 (11:57c0) res 7, [hl] call nz, SilphCoElevatorScript_45827 xor a - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a inc a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret SilphCoElevatorScript_457dc: ; 457dc (11:57dc) - ld hl, wd3af + ld hl, wWarpEntries ld a, [wd73b] ld b, a ld a, [wd73c] diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm index 2ec0f28c..f25d5532 100755 --- a/scripts/ssanne9.asm +++ b/scripts/ssanne9.asm @@ -1,8 +1,8 @@ SSAnne9Script: ; 61b4b (18:5b4b) ld a, $1 - ld [wcf0c], a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, SSAnne9TrainerHeaders ld de, SSAnne9ScriptPointers ld a, [W_SSANNE9CURSCRIPT] diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index ca0ce66b..6ed2d23d 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -5,7 +5,7 @@ VermilionDockScript: ; 1db52 (7:5b52) jr nz, .asm_1db8d ; 0x1db5a $31 bit 0, [hl] ret z - ld a, [wd42f] + ld a, [wDestinationWarpID] cp $1 ret nz bit 2, [hl] @@ -75,7 +75,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld a, (SFX_02_54 - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ld a, $ff - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a ld d, $0 ld e, $8 .asm_1dbfa @@ -111,14 +111,14 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld a, $90 ld [hVBlankWY], a ld a, $1 - ld [wcfcb], a + ld [wUpdateSpritesEnabled], a pop hl pop bc ld [hl], b dec hl ld [hl], c call LoadPlayerSpriteGraphics - ld hl, wd3ae + ld hl, wNumberOfWarps dec [hl] ret diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index fa6b2fc2..685bd2cb 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -158,7 +158,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d) ld de, ReceivedThunderbadgeText call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $3 diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index e35e9131..e7d5ed12 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -61,7 +61,7 @@ VictoryRoad3Script0: ; 449b7 (11:49b7) .asm_449fe ld a, $c2 - ld [wd71d], a + ld [wDungeonWarpDestinationMap], a ld hl, .coordsData_449f9 ; $49f9 call Func_46981 ld a, [wWhichTrade] ; wWhichTrade diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 4c9e6821..6b0673d1 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -286,16 +286,16 @@ ViridianGymText1: ; 74a69 (1d:4a69) jr .asm_6dff7 ; 0x74a7b .asm_9fc95 ; 0x74a7d ld a, $1 - ld [wcc3c], a + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ld hl, ViridianGymText_74ad9 call PrintText - call GBFadeIn1 + call GBFadeOutToBlack ld a, $32 ld [wcc4d], a predef HideObject call UpdateSprites call Delay3 - call GBFadeOut1 + call GBFadeInFromBlack jr .asm_6dff7 ; 0x74a9e .asm_6de66 ; 0x74aa0 ld hl, ViridianGymText_74ace @@ -307,7 +307,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) ld de, ViridianGymText_74ad3 call PreBattleSaveRegisters ldh a, [$8c] - ld [wcf13], a + ld [wSpriteIndex], a call EngageMapTrainer call InitBattleEnemyParameters ld a, $8 diff --git a/wram.asm b/wram.asm index b98372f0..a9bad081 100755 --- a/wram.asm +++ b/wram.asm @@ -260,7 +260,11 @@ wcc37:: ds 1 wcc38:: ds 2 wcc3a:: ds 1 wcc3b:: ds 1 -wcc3c:: ds 1 + +wDoNotWaitForButtonPressAfterDisplayingText:: ; cc3c +; if non-zero, skip waiting for a button press after displaying text in DisplayTextID + ds 1 + wcc3d:: ds 1 wcc3e:: ds 4 wcc42:: ds 1 @@ -496,17 +500,40 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b ds 1 +wFlyAnimUsingCoordList:: ; cd3d + +wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d + +wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d + wWhichTrade:: ; cd3d ; which entry from TradeMons to select ; ds 1 wTrainerSpriteOffset:: ; cd3d ds 1 + +wFlyAnimCounter:: ; cd3e + +wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e + +wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e + wTrainerEngageDistance:: ; cd3e ds 1 + +wFlyAnimBirdSpriteImageIndex:: ; cd3f + +wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f + +wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f + wTrainerFacingDirection:: ; cd3f wcd3f:: ds 1 + +wPlayerSpinInPlaceAnimSoundID:: ; cd40 + wTrainerScreenY:: ; cd40 ds 1 wTrainerScreenX:: ; cd41 @@ -593,7 +620,11 @@ wBattleResult:: ; cf0b ; $01 - lose ; $02 - draw ds 1 -wcf0c:: ds 1 + +wAutoTextBoxDrawingControl:: ; cf0c +; bit 0: if set, DisplayTextID automatically draws a text box + ds 1 + wcf0d:: ds 1 wcf0e:: ds 1 wcf0f:: ds 1 @@ -608,7 +639,7 @@ wcf11:: ds 1 wPredefParentBank:: ; cf12 ds 1 -wcf13:: ds 1 +wSpriteIndex:: ds 1 wCurSpriteMovement2:: ; cf14 ; movement byte 2 of current sprite @@ -625,7 +656,10 @@ wcf18:: ds 2 wGBC:: ; cf1a ds 1 -wcf1b:: ds 1 +wOnSGB:: ; cf1b +; if running on SGB, it's 1, else it's 0 + ds 1 + wcf1c:: ds 1 wcf1d:: ds 1 wcf1e:: ds 1 @@ -692,7 +726,9 @@ wWalkCounter:: ; cfc5 ; walk animation counter ds 1 -wcfc6:: ds 1 +wTileInFrontOfPlayer:: ; cfc6 +; background tile number in front of the player (either 1 or 2 steps ahead) + ds 1 wMusicHeaderPointer:: ; cfc7 ; (the current music channel address - $4000) / 3 @@ -701,7 +737,10 @@ wMusicHeaderPointer:: ; cfc7 wcfc8:: ds 1 wcfc9:: ds 1 wcfca:: ds 1 -wcfcb:: ds 1 + +wUpdateSpritesEnabled:: ; cfcb +; $01 enables UpdateSprites; anything else disables it + ds 1 W_ENEMYMOVENUM:: ; cfcc ds 1 @@ -1121,7 +1160,11 @@ wd0dc:: ds 4 wd0e0:: ds 1 wd0e1:: ds 56 wd119:: ds 1 -wd11a:: ds 1 + +wWalkBikeSurfStateCopy:: ; d11a +; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything + ds 1 + wd11b:: ds 1 wd11c:: ds 1 wd11d:: ds 1 @@ -1158,8 +1201,14 @@ wd132:: ds 1 wd133:: ds 6 wd139:: ds 1 wd13a:: ds 1 -wd13b:: ds 1 -wd13c:: ds 1 + +wStepCounter:: ; d13b +; counts down once every step + ds 1 + +wNumberOfNoRandomBattleStepsLeft:: ; d13c +; after a battle, you have at least 3 steps before a random battle can occur + ds 1 W_PRIZE1:: ; d13d ds 1 @@ -1246,13 +1295,18 @@ wPlayerID:: ; d359 wd35b:: ds 1 wd35c:: ds 1 -wd35d:: ds 1 + +wMapPalOffset:: ; d35d +; offset subtracted from FadePal4 to get the background and object palettes for the current map +; normally, it is 0. it is 6 when Flash is needed, causing FadePal2 to be used instead of FadePal4 + ds 1 W_CURMAP:: ; d35e ds 1 -wd35f:: ds 1 -wd360:: ds 1 +wCurrentTileBlockMapViewPointer:: ; d35f +; pointer to the upper left corner of the current view in the tile block map + ds 2 W_YCOORD:: ; d361 ; player’s position on the current map @@ -1364,26 +1418,42 @@ W_SPRITESETID:: ; d3a8 wd3a9:: ds 1 wd3aa:: ds 3 wd3ad:: ds 1 -wd3ae:: ds 1 -wd3af:: ds 128 -wd42f:: ds 129 + +wNumberOfWarps:: ; d3ae +; number of warps in current map + ds 1 + +wWarpEntries:: ; d3af +; current map warp entries + ds 128 + +wDestinationWarpID:: ; d42f +; if $ff, the player's coordinates are not updated when entering the map + ds 1 + + ds 128 + wd4b0:: ds 1 wd4b1:: ds 32 wd4d1:: ds 16 W_NUMSPRITES:: ; d4e1 ; number of sprites on the current map -; two bytes per sprite (movement byte 2 , text ID) ds 1 -wd4e2:: ds 1 -wd4e3:: ds 1 +; these two variables track the X and Y offset in blocks from the last special warp used +; they don't seem to be used for anything +wYOffsetSinceLastSpecialWarp:: ; d4e2 + ds 1 +wXOffsetSinceLastSpecialWarp:: ; d4e3 + ds 1 W_MAPSPRITEDATA:: ; d4e4 -; two bytes per sprite (trainer class/item ID , trainer set ID) +; two bytes per sprite (movement byte 2, text ID) ds 32 W_MAPSPRITEEXTRADATA:: ; d504 +; two bytes per sprite (trainer class/item ID, trainer set ID) ds 32 wd524:: ds 1 @@ -1661,7 +1731,14 @@ W_ROUTE18GATECURSCRIPT:: ; d669 wd6f0:: ds 14 wd6fe:: ds 2 -wd700:: ds 11 + +wWalkBikeSurfState:: ; d700 +; $00 = walking +; $01 = biking +; $02 = surfing + ds 1 + + ds 10 W_TOWNVISITEDFLAG:: ; d70b flag_array 13 @@ -1684,7 +1761,8 @@ W_ENEMYMONORTRAINERCLASS:: ; d713 ; trainer classes start at $c8 ds 1 -wd714:: ds 1 +wPlayerJumpingYScreenCoordsIndex:: ; d714 + ds 1 W_RIVALSTARTER:: ; d715 ds 1 @@ -1694,16 +1772,32 @@ W_RIVALSTARTER:: ; d715 W_PLAYERSTARTER:: ; d717 ds 1 -wd718:: ds 1 +wBoulderSpriteIndex:: ; d718 +; sprite index of the boulder the player is trying to push + ds 1 wLastBlackoutMap:: ; d719 ds 1 -wd71a:: ds 1 +wDestinationMap:: ; d71a +; destination map (for certain types of special warps, not ordinary walking) + ds 1 + wd71b:: ds 1 -wd71c:: ds 1 -wd71d:: ds 1 -wd71e:: ds 1 + +wTileInFrontOfBoulderAndBoulderCollisionResult:: ; d71c +; used to store the tile in front of the boulder when trying to push a boulder +; also used to store the result of the collision check ($ff for a collision and $00 for no collision) + ds 1 + +wDungeonWarpDestinationMap:: ; d71d +; destination map for dungeon warps + ds 1 + +wWhichDungeonWarp:: ; d71e +; which dungeon warp within the source map was used + ds 1 + wd71f:: ds 9 wd728:: @@ -1713,7 +1807,11 @@ wd728:: ds 1 wd72a:: ds 2 -wd72c:: ds 1 + +wd72c:: ; d72c +; bit 0: if not set, the 3 minimum steps between random battles have passed + ds 1 + wd72d:: ds 1 wd72e:: ds 2 @@ -1723,16 +1821,31 @@ wd730:: ds 1 -wd732:: ds 1 +wd732:: ; d732 +; bit 0: play time being counted +; bit 1: remnant of debug mode? not set by the game code. +; if it is set +; 1. skips most of Prof. Oak's speech, and uses NINTEN as the player's name and SONY as the rival's name +; 2. does not have the player start in floor two of the playyer's house (instead sending them to [wLastMap]) +; 3. allows wild battles to be avoided by holding down B +; bit 2: the target warp is a fly warp (bit 3 set or blacked out) or a dungeon warp (bit 4 set) +; bit 3: used warp pad, escape rope, dig, teleport, or fly, so the target warp is a "fly warp" +; bit 4: jumped into hole (Pokemon Mansion, Seafoam Islands, Victory Road) or went down waterfall (Seafoam Islands), so the target warp is a "dungeon warp" +; bit 5: currently being forced to ride bike (cycling road) +; bit 6: map destination is [wLastBlackoutMap] (usually the last used pokemon center, but could be the player's house) + ds 1 W_FLAGS_D733:: ; d733 ; bit 4: use variable [W_CURMAPSCRIPT] instead of the provided index for next frame's map script (used to start battle when talking to trainers) +; bit 7: used fly out of battle ds 1 wd734:: ds 2 wd736:: ; d736 ; bit 0: check if the player is standing on a door and make him walk down a step if so +; bit 2: standing on a warp +; bit 6: jumping down a ledge ds 1 wd737:: ds 4 -- cgit v1.3.1-sl0p From 2ed65d9c3e3ba60939ebe2928ffddc06a90b1876 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 14 Sep 2014 11:29:18 -0700 Subject: Commented/labelled misc functions --- constants/hardware_constants.asm | 20 +--- engine/battle/14.asm | 2 +- engine/battle/core.asm | 8 +- engine/cable_club.asm | 2 +- engine/evolution.asm | 2 +- engine/evos_moves.asm | 4 +- engine/hall_of_fame.asm | 2 +- engine/hidden_object_functions18.asm | 2 +- engine/hidden_object_functions3.asm | 27 ++--- engine/hidden_object_functions7.asm | 6 +- engine/in_game_trades.asm | 2 +- engine/menu/bills_pc.asm | 2 +- engine/menu/league_pc.asm | 6 +- engine/menu/pokedex.asm | 6 +- engine/menu/start_sub_menus.asm | 6 +- engine/menu/status_screen.asm | 12 +- engine/oak_speech.asm | 2 +- engine/overworld/card_key.asm | 66 ++++++----- engine/overworld/cut.asm | 4 +- engine/overworld/elevator.asm | 2 +- engine/overworld/hidden_objects.asm | 110 +++++++++--------- engine/overworld/npc_movement.asm | 13 +-- engine/play_time.asm | 26 ++--- engine/predefs.asm | 8 +- engine/save.asm | 192 +++++++++++++++---------------- engine/titlescreen.asm | 2 +- engine/town_map.asm | 41 +++---- engine/trade.asm | 2 +- home.asm | 217 ++++++++++++++++++----------------- home/init.asm | 4 +- home/overworld.asm | 112 +++++++++--------- home/vblank.asm | 8 +- home/vcopy.asm | 7 +- hram.asm | 9 ++ macros.asm | 4 +- main.asm | 94 ++++++++------- scripts/agatha.asm | 4 +- scripts/bruno.asm | 4 +- scripts/celadongamecorner.asm | 6 +- scripts/celadongym.asm | 4 +- scripts/ceruleancity.asm | 4 +- scripts/ceruleangym.asm | 4 +- scripts/cinnabargym.asm | 16 +-- scripts/fightingdojo.asm | 4 +- scripts/fuchsiagym.asm | 4 +- scripts/gary.asm | 2 +- scripts/lance.asm | 4 +- scripts/lorelei.asm | 4 +- scripts/mansion1.asm | 4 +- scripts/mansion2.asm | 4 +- scripts/mansion3.asm | 2 +- scripts/mansion4.asm | 2 +- scripts/mtmoon1.asm | 2 +- scripts/mtmoon3.asm | 4 +- scripts/oakslab.asm | 2 +- scripts/pewtergym.asm | 4 +- scripts/pokemontower2.asm | 2 +- scripts/pokemontower3.asm | 2 +- scripts/pokemontower4.asm | 2 +- scripts/pokemontower5.asm | 2 +- scripts/pokemontower6.asm | 2 +- scripts/pokemontower7.asm | 2 +- scripts/powerplant.asm | 2 +- scripts/rockethideout1.asm | 4 +- scripts/rockethideout2.asm | 4 +- scripts/rockethideout3.asm | 4 +- scripts/rockethideout4.asm | 6 +- scripts/rocktunnel1.asm | 2 +- scripts/rocktunnel2.asm | 2 +- scripts/route10.asm | 2 +- scripts/route11.asm | 2 +- scripts/route12.asm | 2 +- scripts/route13.asm | 2 +- scripts/route14.asm | 2 +- scripts/route15.asm | 2 +- scripts/route16.asm | 2 +- scripts/route17.asm | 2 +- scripts/route18.asm | 2 +- scripts/route19.asm | 2 +- scripts/route20.asm | 2 +- scripts/route21.asm | 2 +- scripts/route22.asm | 4 +- scripts/route24.asm | 4 +- scripts/route25.asm | 2 +- scripts/route3.asm | 2 +- scripts/route4.asm | 2 +- scripts/route6.asm | 2 +- scripts/route8.asm | 2 +- scripts/route9.asm | 2 +- scripts/saffrongym.asm | 4 +- scripts/silphco10.asm | 4 +- scripts/silphco11.asm | 10 +- scripts/silphco2.asm | 10 +- scripts/silphco3.asm | 6 +- scripts/silphco4.asm | 10 +- scripts/silphco5.asm | 8 +- scripts/silphco6.asm | 4 +- scripts/silphco7.asm | 14 +-- scripts/silphco8.asm | 8 +- scripts/silphco9.asm | 14 +-- scripts/ssanne10.asm | 2 +- scripts/ssanne2.asm | 2 +- scripts/ssanne5.asm | 2 +- scripts/ssanne8.asm | 2 +- scripts/ssanne9.asm | 2 +- scripts/unknowndungeon3.asm | 2 +- scripts/vermiliondock.asm | 6 +- scripts/vermiliongym.asm | 6 +- scripts/victoryroad1.asm | 4 +- scripts/victoryroad2.asm | 4 +- scripts/victoryroad3.asm | 4 +- scripts/viridianforest.asm | 2 +- scripts/viridiangym.asm | 6 +- wram.asm | 69 ++++++++--- 114 files changed, 733 insertions(+), 668 deletions(-) (limited to 'scripts/oakslab.asm') diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index 8e926a11..e875622d 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -2,27 +2,17 @@ GBC EQU $11 -; MBC3 -MBC3SRamEnable EQU $0000 -MBC3RomBank EQU $2000 -MBC3SRamBank EQU $4000 -MBC3LatchClock EQU $6000 -MBC3RTC EQU $a000 +; MBC1 +MBC1SRamEnable EQU $0000 +MBC1RomBank EQU $2000 +MBC1SRamBank EQU $4000 +MBC1SRamBankingMode EQU $6000 SRAM_DISABLE EQU $00 SRAM_ENABLE EQU $0a NUM_SRAM_BANKS EQU 4 -RTC_S EQU $08 ; Seconds 0-59 (0-3Bh) -RTC_M EQU $09 ; Minutes 0-59 (0-3Bh) -RTC_H EQU $0a ; Hours 0-23 (0-17h) -RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh) -RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag - ; Bit 0 Most significant bit of Day Counter (Bit 8) - ; Bit 6 Halt (0=Active, 1=Stop Timer) - ; Bit 7 Day Counter Carry Bit (1=Counter Overflow) - ; interrupt flags VBLANK EQU 0 LCD_STAT EQU 1 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 530032a0..18aaa5e1 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -1,5 +1,5 @@ Func_525af: ; 525af (14:65af) - ld a, [$ffd7] + ld a, [hTilesetType] ld [wd0d4], a xor a ld [wcd6a], a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 26465b8f..7b1c1d12 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -136,7 +136,7 @@ SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) ld [hVBlankWY], a ld [rWY], a xor a - ld [$ffd7], a + ld [hTilesetType], a ld [hVBlankSCY], a dec a ld [wUpdateSpritesEnabled], a @@ -1015,7 +1015,7 @@ TrainerBattleVictory: ; 3c696 (f:4696) call ScrollTrainerPicAfterBattle ld c, $28 call DelayFrames - call Func_3381 + call PrintEndBattleText ld hl, MoneyForWinningText call PrintText ld de, wPlayerMoney + 2 @@ -6263,7 +6263,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [H_AUTOBGTRANSFERENABLED], a ld [hVBlankWY], a ld [rWY], a - ld [$ffd7], a + ld [hTilesetType], a ld hl, wd060 ld [hli], a ld [hli], a @@ -6851,7 +6851,7 @@ InitBattle_Common: ; 3efeb (f:6feb) pop af ld [wMapPalOffset], a ld a, [wd0d4] - ld [$ffd7], a + ld [hTilesetType], a scf ret .emptyString diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 9b4017e2..34a9d0a1 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -572,7 +572,7 @@ Func_577d: ; 577d (1:577d) dec a ld [wDestinationWarpID], a call LoadMapData - callba Func_c335 + callba ClearVariablesAfterLoadingMapData pop hl pop af ld [hl], a diff --git a/engine/evolution.asm b/engine/evolution.asm index 07ccdbda..106107d2 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -19,7 +19,7 @@ Func_7bde9: ; 7bde9 (1e:7de9) call Delay3 xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [$ffd7], a + ld [hTilesetType], a ld a, [wHPBarMaxHP] ld [wcf1d], a ld c, $0 diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 240fd9fa..bda4c9ff 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -11,7 +11,7 @@ TryEvolvingMon: ; 3ad0e (e:6d0e) ; this is only called after battle ; it is supposed to do level up evolutions, though there is a bug that allows item evolutions to occur EvolutionAfterBattle: ; 3ad1c (e:6d1c) - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a ld [wd121], a @@ -245,7 +245,7 @@ Evolution_PartyMonLoop: ; loop over party mons pop bc pop hl pop af - ld [$ffd7], a + ld [hTilesetType], a ld a, [W_ISLINKBATTLE] cp $32 ret z diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 30ae6266..406fac01 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -19,7 +19,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call FillMemory xor a ld [wUpdateSpritesEnabled], a - ld [$ffd7], a + ld [hTilesetType], a ld [W_SPRITEFLIPPED], a ld [wd358], a ld [wTrainerScreenY], a diff --git a/engine/hidden_object_functions18.asm b/engine/hidden_object_functions18.asm index 9dd7fac7..7696626f 100755 --- a/engine/hidden_object_functions18.asm +++ b/engine/hidden_object_functions18.asm @@ -70,7 +70,7 @@ PrintBenchGuyText: ; 6245d (18:645d) ld a, [hl] jp PrintPredefTextID -; format: db map id, 08, text id of PointerTable_3f22 +; format: db map id, 08, text id of PredefTextIDPointerTable PokeCenterMapIDList: ; 6247e (18:647e) db VIRIDIAN_POKECENTER,$08,$0F db PEWTER_POKECENTER,$08,$10 diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index 09d9ebcc..d3d83f08 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -1,22 +1,23 @@ ; prints text for bookshelves in buildings without sign events PrintBookshelfText: ; fb50 (3:7b50) - ld a, [wSpriteStateData1 + 9] - cp $4 - jr nz, .asm_fb7f - ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr nz, .noMatch +; facing up + ld a, [W_CURMAPTILESET] ld b, a aCoord 8, 7 ld c, a - ld hl, BookshelfTileIDs ; $7b8b -.asm_fb62 + ld hl, BookshelfTileIDs +.loop ld a, [hli] cp $ff - jr z, .asm_fb7f + jr z, .noMatch cp b - jr nz, .asm_fb7b + jr nz, .nextBookshelfEntry1 ld a, [hli] cp c - jr nz, .asm_fb7c + jr nz, .nextBookshelfEntry2 ld a, [hl] push af call EnableAutoTextBoxDrawing @@ -25,12 +26,12 @@ PrintBookshelfText: ; fb50 (3:7b50) xor a ld [$ffdb], a ret -.asm_fb7b +.nextBookshelfEntry1 inc hl -.asm_fb7c +.nextBookshelfEntry2 inc hl - jr .asm_fb62 -.asm_fb7f + jr .loop +.noMatch ld a, $ff ld [$ffdb], a ld b, BANK(PrintCardKeyText) diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index c00749e4..012e941d 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -60,7 +60,7 @@ SafariZoneCheckSteps: ; 1e997 (7:6997) ld [wSafariSteps + 1], a ; wd70e asm_1e9ab: ; 1e9ab (7:69ab) xor a - ld [wda46], a + ld [wSafariZoneGameOver], a ret asm_1e9b0: ; 1e9b0 (7:69b0) call EnableAutoTextBoxDrawing @@ -89,7 +89,7 @@ asm_1e9b0: ; 1e9b0 (7:69b0) ld hl, wd790 set 6, [hl] ld a, $1 - ld [wda46], a + ld [wSafariZoneGameOver], a ret PrintSafariGameOverText: ; 1e9ed (7:69ed) @@ -291,7 +291,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a) .asm_1eb38 pop bc ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ld hl, $ffdb dec [hl] jr nz, .asm_1eb0e diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 4f232eb4..7464edb3 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -138,7 +138,7 @@ Func_71c07: ; 71c07 (1c:5c07) callab EvolveTradeMon call ClearScreen call Func_71ca2 - callba Func_eedc + callba RedrawMapView and a ld a,$3 jr .asm_ee803 ; 0x71c9b $1 diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index b5ee9b94..65b70bb1 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -332,7 +332,7 @@ Func_21673: ; 21673 (8:5673) jp Func_214e8 Func_216b3: ; 216b3 (8:56b3) - callba Func_738a1 + callba ChangeBox jp Func_214e8 Func_216be: ; 216be (8:56be) diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index ffde236a..a6dd7021 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -6,10 +6,10 @@ PKMNLeaguePC: ; 0x7657e push hl ld a, [wUpdateSpritesEnabled] push af - ld a, [$ffD7] + ld a, [hTilesetType] push af xor a - ld [$ffD7], a + ld [hTilesetType], a ld [W_SPRITEFLIPPED], a ld [wUpdateSpritesEnabled], a ld [wTrainerScreenX], a @@ -38,7 +38,7 @@ PKMNLeaguePC: ; 0x7657e jr nz, .first .second pop af - ld [$ffD7], a + ld [hTilesetType], a pop af ld [wUpdateSpritesEnabled], a pop hl diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 8f4bc508..152b8129 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -404,10 +404,10 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) call GoPAL_SET pop af ld [wd11e],a - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a hlCoord 0, 0 ld de,1 ld bc,$6414 @@ -554,7 +554,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) and a,%00000011 ; A button and B button jr z,.waitForButtonPress pop af - ld [$ffd7],a + ld [hTilesetType],a call GBPalWhiteOut call ClearScreen call GoPAL_SET_CF1C diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index e91386b0..c6373e76 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -500,10 +500,10 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) call GBPalWhiteOut call ClearScreen call UpdateSprites ; move sprites - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call DrawTrainerInfo predef DrawBadges ; draw badges ld b,$0d @@ -517,7 +517,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) call ReloadMapData call LoadGBPal pop af - ld [$ffd7],a + ld [hTilesetType],a jp RedisplayStartMenu ; loads tile patterns and draws everything except for gym leader faces / badges diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 65b06e9d..f215fd0e 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -36,10 +36,10 @@ StatusScreen: ; 12953 (4:6953) ld hl, vChars2 + $720 ld bc,(BANK(PTile) << 8 | $01) call CopyVideoDataDouble ; P (for PP), inline - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [$ffd7], a + ld [hTilesetType], a hlCoord 19, 1 ld bc, $060a call DrawLineBox ; Draws the box around name, HP and status @@ -109,7 +109,7 @@ StatusScreen: ; 12953 (4:6953) call PlayCry ; play Pokémon cry call WaitForTextScrollButtonPress ; wait for button pop af - ld [$ffd7], a + ld [hTilesetType], a ret .unk_12a7e ; 0x12a7e ; I don't know what this does, iterates over pointers? ld a, [wcc49] @@ -227,10 +227,10 @@ StatsText: ; 12b3a (4:6b3a) next "SPECIAL@" StatusScreen2: ; 12b57 (4:6b57) - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ffba], a ld bc, $0005 ld hl, wd0dc @@ -360,7 +360,7 @@ StatusScreen2: ; 12b57 (4:6b57) call Delay3 call WaitForTextScrollButtonPress ; wait for button pop af - ld [$ffd7], a + ld [hTilesetType], a ld hl, wd72c res 1, [hl] ld a, $77 diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 518bea2a..0cbdaa3d 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -52,7 +52,7 @@ OakSpeech: ; 6115 (1:6115) ld [wDestinationMap],a call SpecialWarpIn xor a - ld [$FFD7],a + ld [hTilesetType],a ld a,[wd732] bit 1,a ; XXX when is bit 1 set? jp nz,Func_61bc ; easter egg: skip the intro diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index 885932d5..c4df0d51 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -2,18 +2,18 @@ PrintCardKeyText: ; 52673 (14:6673) ld hl, SilphCoMapList ld a, [W_CURMAP] ld b, a -.asm_5267a +.silphCoMapListLoop ld a, [hli] cp $ff ret z cp b - jr nz, .asm_5267a + jr nz, .silphCoMapListLoop predef GetTileAndCoordsInFrontOfPlayer ld a, [wTileInFrontOfPlayer] cp $18 - jr z, .asm_5269c + jr z, .cardKeyDoorInFrontOfPlayer cp $24 - jr z, .asm_5269c + jr z, .cardKeyDoorInFrontOfPlayer ld b, a ld a, [W_CURMAP] cp SILPH_CO_11F @@ -21,41 +21,41 @@ PrintCardKeyText: ; 52673 (14:6673) ld a, b cp $5e ret nz -.asm_5269c +.cardKeyDoorInFrontOfPlayer ld b, CARD_KEY call IsItemInBag - jr z, .asm_526dc - call Func_526fd + jr z, .noCardKey + call GetCoordsInFrontOfPlayer push de ld a, $1 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a call PrintPredefTextID pop de srl d ld a, d ld b, a - ld [wd73f], a + ld [wCardKeyDoorY], a srl e ld a, e ld c, a - ld [wd740], a - ld a, [W_CURMAP] ; W_CURMAP + ld [wCardKeyDoorX], a + ld a, [W_CURMAP] cp SILPH_CO_11F - jr nz, .asm_526c8 + jr nz, .notSilphCo11F ld a, $3 - jr .asm_526ca -.asm_526c8 + jr .replaceCardKeyDoorTileBlock +.notSilphCo11F ld a, $e -.asm_526ca +.replaceCardKeyDoorTileBlock ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ld hl, wd126 set 5, [hl] ld a, (SFX_1f_57 - SFX_Headers_1f) / 3 jp PlaySound -.asm_526dc +.noCardKey ld a, $2 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a jp PrintPredefTextID SilphCoMapList: ; 526e3 (14:66e3) @@ -81,26 +81,32 @@ CardKeyFailText: ; 526f8 (14:66f8) TX_FAR _CardKeyFailText db "@" -Func_526fd: ; 526fd (14:66fd) - ld a, [W_YCOORD] ; wd361 +; d = Y +; e = X +GetCoordsInFrontOfPlayer: ; 526fd (14:66fd) + ld a, [W_YCOORD] ld d, a - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld e, a - ld a, [wSpriteStateData1 + 9] + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction and a - jr nz, .asm_5270d + jr nz, .notFacingDown +; facing down inc d ret -.asm_5270d - cp $4 - jr nz, .asm_52713 +.notFacingDown + cp SPRITE_FACING_UP + jr nz, .notFacingUp +; facing up dec d ret -.asm_52713 - cp $8 - jr nz, .asm_52719 +.notFacingUp + cp SPRITE_FACING_LEFT + jr nz, .notFacingLeft +; facing left dec e ret -.asm_52719 +.notFacingLeft +; facing right inc e ret diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 0cbc0214..f57b6465 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -56,7 +56,7 @@ asm_ef82: ; ef82 (3:6f82) call AnimateCutTree ld de, CutTreeBlockSwaps ; $7100 call Func_f09f - call Func_eedc + call RedrawMapView callba Func_79e96 ld a, $1 ld [wUpdateSpritesEnabled], a @@ -65,7 +65,7 @@ asm_ef82: ; ef82 (3:6f82) ld a, $90 ld [hVBlankWY], a call UpdateSprites - jp Func_eedc + jp RedrawMapView UsedCutText: ; eff2 (3:6ff2) TX_FAR _UsedCutText diff --git a/engine/overworld/elevator.asm b/engine/overworld/elevator.asm index d1d7d82a..c2191b91 100755 --- a/engine/overworld/elevator.asm +++ b/engine/overworld/elevator.asm @@ -41,7 +41,7 @@ ShakeElevator: ; 7bf15 (1e:7f15) jp PlayDefaultMusic Func_7bf64: ; 7bf64 (1e:7f64) - ld hl, wd527 + ld hl, wMapViewVRAMPointer + 1 ld a, [hld] push af ld a, [hl] diff --git a/engine/overworld/hidden_objects.asm b/engine/overworld/hidden_objects.asm index 1be5170c..ae67aeed 100755 --- a/engine/overworld/hidden_objects.asm +++ b/engine/overworld/hidden_objects.asm @@ -6,7 +6,7 @@ Func_46981: ; 46981 (11:6981) ret nz call ArePlayerCoordsInArray ret nc - ld a, [wWhichTrade] ; wWhichTrade + ld a, [wWhichTrade] ld [wWhichDungeonWarp], a ld hl, wd72d set 4, [hl] @@ -14,7 +14,8 @@ Func_46981: ; 46981 (11:6981) set 4, [hl] ret -Func_469a0: ; 469a0 (11:69a0) +; if a hidden object was found, stores $00 in [$ffee], else stores $ff +CheckForHiddenObject: ; 469a0 (11:69a0) ld hl, $ffeb xor a ld [hli], a @@ -22,107 +23,110 @@ Func_469a0: ; 469a0 (11:69a0) ld [hli], a ld [hl], a ld de, $0 - ld hl, HiddenObjectMaps ; $6a40 -.asm_469ae + ld hl, HiddenObjectMaps +.hiddenMapLoop ld a, [hli] ld b, a cp $ff - jr z, .asm_469fc - ld a, [W_CURMAP] ; W_CURMAP + jr z, .noMatch + ld a, [W_CURMAP] cp b - jr z, .asm_469be + jr z, .foundMatchingMap inc de inc de - jr .asm_469ae -.asm_469be - ld hl, HiddenObjectPointers ; $6a96 + jr .hiddenMapLoop +.foundMatchingMap + ld hl, HiddenObjectPointers add hl, de ld a, [hli] ld h, [hl] ld l, a push hl - ld hl, wWhichTrade ; wWhichTrade + ld hl, wHiddenObjectFunctionArgument xor a ld [hli], a ld [hli], a ld [hl], a pop hl -.asm_469ce +.hiddenObjectLoop ld a, [hli] cp $ff - jr z, .asm_469fc - ld [wTrainerScreenY], a + jr z, .noMatch + ld [wHiddenObjectY], a ld b, a ld a, [hli] - ld [wTrainerScreenX], a + ld [wHiddenObjectX], a ld c, a - call Func_46a01 + call CheckIfCoordsInFrontOfPlayerMatch ld a, [$ffea] and a - jr z, .asm_469f0 + jr z, .foundMatchingObject inc hl inc hl inc hl inc hl push hl - ld hl, wTrainerFacingDirection + ld hl, wHiddenObjectIndex inc [hl] pop hl - jr .asm_469ce -.asm_469f0 + jr .hiddenObjectLoop +.foundMatchingObject ld a, [hli] - ld [wWhichTrade], a ; wWhichTrade + ld [wHiddenObjectFunctionArgument], a ld a, [hli] - ld [wTrainerEngageDistance], a + ld [wHiddenObjectFunctionRomBank], a ld a, [hli] ld h, [hl] ld l, a ret -.asm_469fc +.noMatch ld a, $ff ld [$ffee], a ret -Func_46a01: ; 46a01 (11:6a01) - ld a, [wSpriteStateData1 + 9] - cp $4 - jr z, .asm_46a16 - cp $8 - jr z, .asm_46a25 - cp $c - jr z, .asm_46a2b - ld a, [W_YCOORD] ; wd361 +; checks if the coordinates in front of the player's sprite match Y in b and X in c +; [$ffea] = $00 if they match, $ff if they don't match +CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01) + ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr z, .facingUp + cp SPRITE_FACING_LEFT + jr z, .facingLeft + cp SPRITE_FACING_RIGHT + jr z, .facingRight +; facing down + ld a, [W_YCOORD] inc a - jr .asm_46a1a -.asm_46a16 - ld a, [W_YCOORD] ; wd361 + jr .upDownCommon +.facingUp + ld a, [W_YCOORD] dec a -.asm_46a1a +.upDownCommon cp b - jr nz, .asm_46a3b - ld a, [W_XCOORD] ; wd362 + jr nz, .didNotMatch + ld a, [W_XCOORD] cp c - jr nz, .asm_46a3b - jr .asm_46a38 -.asm_46a25 - ld a, [W_XCOORD] ; wd362 + jr nz, .didNotMatch + jr .matched +.facingLeft + ld a, [W_XCOORD] dec a - jr .asm_46a2f -.asm_46a2b - ld a, [W_XCOORD] ; wd362 + jr .leftRightCommon +.facingRight + ld a, [W_XCOORD] inc a -.asm_46a2f +.leftRightCommon cp c - jr nz, .asm_46a3b - ld a, [W_YCOORD] ; wd361 + jr nz, .didNotMatch + ld a, [W_YCOORD] cp b - jr nz, .asm_46a3b -.asm_46a38 + jr nz, .didNotMatch +.matched xor a - jr .asm_46a3d -.asm_46a3b + jr .done +.didNotMatch ld a, $ff -.asm_46a3d +.done ld [$ffea], a ret diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 07a73be6..84e39853 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -260,12 +260,11 @@ RLEList_PewterGymGuy: ; 1a5da (6:65da) db $C0, $03 db $FF -; XXX why would this function want to return on POKEMONTOWER_7? -Func_1a5e7: ; 1a5e7 (6:65e7) - ld a, [W_CURMAP] ; W_CURMAP +FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7) + ld a, [W_CURMAP] cp POKEMONTOWER_7 - ret z - ld hl, RivalIDs ; $6605 + ret z ; the Rockets on Pokemon Tower 7F leave after battling, so don't freeze them + ld hl, RivalIDs ld a, [wEngagedTrainerClass] ld b, a .loop @@ -273,11 +272,11 @@ Func_1a5e7: ; 1a5e7 (6:65e7) cp $ff jr z, .notRival cp b - ret z + ret z ; the rival leaves after battling, so don't freeze him jr .loop .notRival ld a, [wSpriteIndex] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_SPRITEINDEX], a jp SetSpriteMovementBytesToFF RivalIDs: ; 1a605 (6:6605) diff --git a/engine/play_time.asm b/engine/play_time.asm index db7d6f67..74da9c59 100755 --- a/engine/play_time.asm +++ b/engine/play_time.asm @@ -1,25 +1,25 @@ -Func_18dee: ; 18dee (6:4dee) - call Func_18e36 +TrackPlayTime: ; 18dee (6:4dee) + call CountDownIgnoreInputBitReset ld a, [wd732] bit 0, a ret z - ld a, [W_PLAYTIMEMINUTES] ; wda42 + ld a, [W_PLAYTIMEMINUTES] and a ret nz - ld a, [W_PLAYTIMEFRAMES] ; wda45 + ld a, [W_PLAYTIMEFRAMES] inc a - ld [W_PLAYTIMEFRAMES], a ; wda45 + ld [W_PLAYTIMEFRAMES], a cp 60 ret nz xor a - ld [W_PLAYTIMEFRAMES], a ; wda45 - ld a, [W_PLAYTIMESECONDS] ; wda44 + ld [W_PLAYTIMEFRAMES], a + ld a, [W_PLAYTIMESECONDS] inc a - ld [W_PLAYTIMESECONDS], a ; wda44 + ld [W_PLAYTIMESECONDS], a cp 60 ret nz xor a - ld [W_PLAYTIMESECONDS], a ; wda44 + ld [W_PLAYTIMESECONDS], a ld a, [W_PLAYTIMEMINUTES + 1] inc a ld [W_PLAYTIMEMINUTES + 1], a @@ -33,11 +33,11 @@ Func_18dee: ; 18dee (6:4dee) cp $ff ret nz ld a, $ff - ld [W_PLAYTIMEMINUTES], a ; wda42 + ld [W_PLAYTIMEMINUTES], a ret -Func_18e36: ; 18e36 (6:4e36) - ld a, [wd13a] +CountDownIgnoreInputBitReset: ; 18e36 (6:4e36) + ld a, [wIgnoreInputCounter] and a jr nz, .asm_18e40 ld a, $ff @@ -45,7 +45,7 @@ Func_18e36: ; 18e36 (6:4e36) .asm_18e40 dec a .asm_18e41 - ld [wd13a], a + ld [wIgnoreInputCounter], a and a ret nz ld a, [wd730] diff --git a/engine/predefs.asm b/engine/predefs.asm index 0a5eff03..b73c485a 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -58,7 +58,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef ScaleSpriteByTwo add_predef LoadMonBackPic add_predef Func_79aba - add_predef Func_f132 + add_predef LoadMissableObjects add_predef HealParty add_predef MoveAnimation; 08 play move animation add_predef DivideBCDPredef @@ -75,13 +75,13 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef AnyPartyAlive add_predef ShowObject add_predef ShowObject2 - add_predef Func_ee9e + add_predef ReplaceTileBlock add_predef InitPlayerData2 add_predef LoadTilesetHeader add_predef LearnMoveFromLevelUp add_predef LearnMove add_predef IsItemInBag_ ; 1C, used in Pokémon Tower - dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 + dbw $03,CheckForHiddenObjectOrBookshelfOrCardKeyDoor ; for these two, the bank number is actually 0 dbw $03,GiveItem add_predef ChangeBGPalColor0_4Frames add_predef FindPathToPlayer @@ -117,7 +117,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef WriteMonMoves add_predef SaveSAV add_predef LoadSGB - add_predef Func_f113 + add_predef MarkTownVisitedAndLoadMissableObjects add_predef SetPartyMonTypes add_predef CanLearnTM add_predef TMToMove diff --git a/engine/save.asm b/engine/save.asm index fcfbd133..f4057577 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -32,11 +32,11 @@ FileDataDestroyedText: ; 7361e (1c:761e) db "@" LoadSAVCheckSum: ; 73623 (1c:7623) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -58,30 +58,30 @@ LoadSAVCheckSum: ; 73623 (1c:7623) ld bc, $b call CopyData ld hl, $a5a3 - ld de, wPokedexOwned ; wPokedexOwned + ld de, wPokedexOwned ld bc, $789 call CopyData - ld hl, W_CURMAPTILESET ; W_CURMAPTILESET + ld hl, W_CURMAPTILESET set 7, [hl] ld hl, $ad2c ld de, wSpriteStateData1 ld bc, $200 call CopyData ld a, [$b522] - ld [$ffd7], a + ld [hTilesetType], a ld hl, $b0c0 - ld de, W_NUMINBOX ; wda80 - ld bc, $462 + ld de, W_NUMINBOX + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData and a jp SAVGoodChecksum LoadSAVCheckSum1: ; 73690 (1c:7690) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -90,18 +90,18 @@ LoadSAVCheckSum1: ; 73690 (1c:7690) cp c jr nz, SAVBadCheckSum ld hl, $b0c0 - ld de, W_NUMINBOX ; wda80 - ld bc, $462 + ld de, W_NUMINBOX + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData and a jp SAVGoodChecksum LoadSAVCheckSum2: ; 736bd (1c:76bd) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a ld hl, $a598 ; hero name located in SRAM ld bc, $f8b ; but here checks the full SAV call SAVCheckSum @@ -125,8 +125,8 @@ SAVBadCheckSum: ; 736f7 (1c:76f7) SAVGoodChecksum: ; 736f8 (1c:76f8) ld a, $0 - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73701: ; 0x73701 @@ -193,67 +193,67 @@ OlderFileWillBeErasedText: ; 73787 (1c:7787) db "@" SaveSAVtoSRAM0: ; 7378c (1c:778c) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, wPlayerName ; wd158 + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, wPlayerName ld de, $a598 ld bc, $b call CopyData - ld hl, wPokedexOwned ; wPokedexOwned + ld hl, wPokedexOwned ld de, $a5a3 - ld bc, $789 + ld bc, W_NUMINBOX - wPokedexOwned call CopyData - ld hl, wSpriteStateData1 ; OAM? + ld hl, wSpriteStateData1 ld de, $ad2c ld bc, $200 call CopyData - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX ld de, $b0c0 - ld bc, $462 + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData - ld a, [$ffd7] + ld a, [hTilesetType] ld [$b522], a ld hl, $a598 ld bc, $f8b call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM1: ; 737e2 (1c:77e2) ; stored pokémon - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, W_NUMINBOX ; wda80 + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, W_NUMINBOX ld de, $b0c0 - ld bc, $462 + ld bc, wBoxMonNicksEnd - W_NUMINBOX call CopyData ld hl, $a598 ld bc, $f8b call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM2: ; 7380f (1c:780f) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a - ld [$4000], a - ld hl, wPartyCount ; wPartyCount + ld [MBC1SRamBankingMode], a + ld [MBC1SRamBank], a + ld hl, wPartyCount ld de, $af2c - ld bc, $194 + ld bc, wPokedexOwned - wPartyCount call CopyData ld hl, wPokedexOwned ; pokédex only ld de, $a5a3 @@ -264,8 +264,8 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f) call SAVCheckSum ld [$b523], a xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret SaveSAVtoSRAM: ; 73848 (1c:7848) @@ -334,13 +334,13 @@ PointerTable_73895: ; 73895 (1c:7895) dw $B188 dw $B5EA -Func_738a1:: ; 738a1 (1c:78a1) +ChangeBox:: ; 738a1 (1c:78a1) ld hl, WhenYouChangeBoxText call PrintText call YesNoChoice - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] and a - ret nz + ret nz ; return if No was chosen ld hl, wd5a0 bit 7, [hl] call z, Func_73a29 @@ -356,25 +356,25 @@ Func_738a1:: ; 738a1 (1c:78a1) call Func_7387b ld e, l ld d, h - ld hl, W_NUMINBOX ; wda80 + ld hl, W_NUMINBOX call Func_7390e - ld a, [wCurrentMenuItem] ; wCurrentMenuItem + ld a, [wCurrentMenuItem] set 7, a ld [wd5a0], a call Func_7387b - ld de, W_NUMINBOX ; wda80 + ld de, W_NUMINBOX call Func_7390e - ld hl, W_MAPTEXTPTR ; wd36c - ld de, wWhichTrade ; wWhichTrade + ld hl, W_MAPTEXTPTR + ld de, wChangeBoxSavedMapTextPointer ld a, [hli] ld [de], a inc de ld a, [hl] ld [de], a - call Func_3f05 + call RestoreMapTextPointer call SaveSAVtoSRAM - ld hl, wWhichTrade ; wWhichTrade - call Func_3f0f + ld hl, wChangeBoxSavedMapTextPointer + call SetMapTextPointer ld a, (SFX_02_5d - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent call WaitForSoundToFinish @@ -386,12 +386,12 @@ WhenYouChangeBoxText: ; 73909 (1c:7909) Func_7390e: ; 7390e (1c:790e) push hl - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, b - ld [$4000], a + ld [MBC1SRamBank], a ld bc, $462 call CopyData pop hl @@ -405,8 +405,8 @@ Func_7390e: ; 7390e (1c:790e) ld [$ba4c], a call Func_73863 xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_7393f: ; 7393f (1c:793f) @@ -502,19 +502,19 @@ BoxNoText: ; 73a21 (1c:7a21) db "BOX No.@" Func_73a29: ; 73a29 (1c:7a29) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, $2 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73a4b ld a, $3 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73a4b xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73a4b: ; 73a4b (1c:7a4b) @@ -547,19 +547,19 @@ Func_73a7f: ; 73a7f (1c:7a7f) Func_73a84: ; 73a84 (1c:7a84) ld hl, wWhichTrade ; wWhichTrade push hl - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a ld a, $2 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73ab8 ld a, $3 - ld [$4000], a + ld [MBC1SRamBank], a call Func_73ab8 xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a pop hl ld a, [wd5a0] and $7f @@ -592,8 +592,8 @@ SAVCheckRandomID: ;$7ad1 ld a,$0a ld [$0000],a ld a,$01 - ld [$6000],a - ld [$4000],a + ld [MBC1SRamBankingMode],a + ld [MBC1SRamBank],a ld a,[$a598] and a jr z,.next @@ -615,7 +615,7 @@ SAVCheckRandomID: ;$7ad1 cp h .next ld a,$00 - ld [$6000],a + ld [MBC1SRamBankingMode],a ld [$0000],a ret @@ -653,23 +653,23 @@ LoadHallOfFameTeams: ; 73b3f (1c:7b3f) ; fallthrough HallOfFame_Copy: ; 73b51 (1c:7b51) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a xor a - ld [$4000], a + ld [MBC1SRamBank], a call CopyData xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret Func_73b6a: ; 73b6a (1c:7b6a) - ld a, $a - ld [$0], a + ld a, SRAM_ENABLE + ld [MBC1SRamEnable], a ld a, $1 - ld [$6000], a + ld [MBC1SRamBankingMode], a xor a call PadSRAM_FF ld a, $1 @@ -679,12 +679,12 @@ Func_73b6a: ; 73b6a (1c:7b6a) ld a, $3 call PadSRAM_FF xor a - ld [$6000], a - ld [$0], a + ld [MBC1SRamBankingMode], a + ld [MBC1SRamEnable], a ret PadSRAM_FF: ; 73b8f (1c:7b8f) - ld [$4000], a + ld [MBC1SRamBank], a ld hl, $a000 ld bc, $2000 ld a, $ff diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 3f9cc613..ca81eff8 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -26,7 +26,7 @@ LoadTitlescreenGraphics: ; 42dd (1:42dd) ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ffae], a ld a, $40 ld [$ffaf], a diff --git a/engine/town_map.asm b/engine/town_map.asm index 6d10c222..3b7506d5 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -64,7 +64,7 @@ Func_70e92: ; 70e92 (1c:4e92) ld bc, $10 call CopyData .asm_70ec8 - call Func_716c6 + call TownMapSpriteBlinkingAnimation call JoypadLowSensitivity ld a, [$ffb5] ld b, a @@ -77,9 +77,9 @@ Func_70e92: ; 70e92 (1c:4e92) bit 7, b jr nz, .asm_70f01 xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a ld [$ffb7], a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [wTownMapSpriteBlinkingCounter], a call Func_711ab pop hl pop af @@ -213,7 +213,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) set 7, [hl] .asm_71037 xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a call GBPalWhiteOutWithDelay3 pop hl pop af @@ -319,9 +319,9 @@ LoadTownMap: ; 7109b (1c:509b) call Delay3 call GBPalNormal xor a - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + ld [wTownMapSpriteBlinkingCounter], a inc a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a ret CompressedMap: ; 71100 (1c:5100) @@ -330,7 +330,7 @@ CompressedMap: ; 71100 (1c:5100) Func_711ab: ; 711ab (1c:51ab) xor a - ld [wd09b], a + ld [wTownMapSpriteBlinkingEnabled], a call GBPalWhiteOut call ClearScreen call ClearSprites @@ -570,29 +570,30 @@ INCLUDE "text/map_names.asm" MonNestIcon: ; 716be (1c:56be) INCBIN "gfx/mon_nest_icon.1bpp" -Func_716c6: ; 716c6 (1c:56c6) - ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM +TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6) + ld a, [wTownMapSpriteBlinkingCounter] inc a - cp $19 - jr z, .asm_716e1 - cp $32 - jr nz, .asm_716f1 + cp 25 + jr z, .hideSprites + cp 50 + jr nz, .done +; show sprites when the counter reaches 50 ld hl, wTileMapBackup ld de, wOAMBuffer ld bc, $90 call CopyData xor a - jr .asm_716f1 -.asm_716e1 + jr .done +.hideSprites ld hl, wOAMBuffer ld b, $24 ld de, $4 -.asm_716e9 +.hideSpritesLoop ld [hl], $a0 add hl, de dec b - jr nz, .asm_716e9 - ld a, $19 -.asm_716f1 - ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM + jr nz, .hideSpritesLoop + ld a, 25 +.done + ld [wTownMapSpriteBlinkingCounter], a jp DelayFrame diff --git a/engine/trade.asm b/engine/trade.asm index 5be77f3e..d134e15a 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -475,7 +475,7 @@ Func_4149f: ; 4149f (10:549f) Func_414ae: ; 414ae (10:54ae) push hl hlCoord 0, 4 - call ScheduleRowRedrawHelper + call CopyToScreenEdgeTiles pop hl ld a, h ld [H_SCREENEDGEREDRAWADDR + 1], a diff --git a/home.asm b/home.asm index 87215991..19ab1715 100644 --- a/home.asm +++ b/home.asm @@ -86,11 +86,11 @@ FarCopyData:: push af ld a, [wBuffer] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call CopyData pop af ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ret CopyData:: @@ -346,10 +346,10 @@ GetCryData:: ; 13d9 (0:13d9) ret DisplayPartyMenu:: ; 13fc (0:13fc) - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call GBPalWhiteOutWithDelay3 call ClearSprites call PartyMenuInit @@ -357,10 +357,10 @@ DisplayPartyMenu:: ; 13fc (0:13fc) jp HandlePartyMenuInput GoBackToPartyMenu:: ; 1411 (0:1411) - ld a,[$ffd7] + ld a,[hTilesetType] push af xor a - ld [$ffd7],a + ld [hTilesetType],a call PartyMenuInit call RedrawPartyMenu jp HandlePartyMenuInput @@ -422,7 +422,7 @@ HandlePartyMenuInput:: ; 145a (0:145a) and a jp nz,.swappingPokemon pop af - ld [$ffd7],a + ld [hTilesetType],a bit 1,b jr nz,.noPokemonChosen ld a,[wPartyCount] @@ -920,11 +920,11 @@ FarCopyData2:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a call CopyData pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret FarCopyData3:: @@ -934,7 +934,7 @@ FarCopyData3:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a push hl push de push de @@ -946,7 +946,7 @@ FarCopyData3:: pop hl pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret FarCopyDataDouble:: @@ -957,7 +957,7 @@ FarCopyDataDouble:: push af ld a,[$ff8b] ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a .loop ld a,[hli] ld [de],a @@ -970,7 +970,7 @@ FarCopyDataDouble:: jr nz,.loop pop af ld [H_LOADEDROMBANK],a - ld [MBC3RomBank],a + ld [MBC1RomBank],a ret CopyVideoData:: @@ -988,7 +988,7 @@ CopyVideoData:: ld a, b ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ld a, e ld [H_VBCOPYSRC], a @@ -1010,7 +1010,7 @@ CopyVideoData:: call DelayFrame ld a, [$ff8b] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop af ld [H_AUTOBGTRANSFERENABLED], a ret @@ -1037,7 +1037,7 @@ CopyVideoDataDouble:: ld a, b ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ld a, e ld [H_VBCOPYDOUBLESRC], a @@ -1059,7 +1059,7 @@ CopyVideoDataDouble:: call DelayFrame ld a, [$ff8b] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop af ld [H_AUTOBGTRANSFERENABLED], a ret @@ -2687,12 +2687,14 @@ DisplayTextBoxID:: ; 30e8 (0:30e8) ld [$2000],a ret -Func_30fd:: ; 30fd (0:30fd) +; not zero if an NPC movement script is running, the player character is +; automatically stepping down from a door, or joypad states are being simulated +IsPlayerCharacterBeingControlledByGame:: ; 30fd (0:30fd) ld a, [wNPCMovementScriptPointerTableNum] and a ret nz ld a, [wd736] - bit 1, a + bit 1, a ; currently stepping down from door bit ret nz ld a, [wd730] and $80 @@ -2740,7 +2742,7 @@ EndNPCMovementScript:: ; 314e (0:314e) ld hl, _EndNPCMovementScript jp Bankswitch -Func_3156:: ; 3156 (0:3156) +EmptyFunc2:: ; 3156 (0:3156) ret ; stores hl in [W_TRAINERHEADERPTR] @@ -2831,7 +2833,6 @@ ReadTrainerHeaderInfo:: ; 3193 (0:3193) TrainerFlagAction:: predef_jump FlagActionPredef -; direct talking to a trainer (rather than getting seen by one) TalkToTrainer:: ; 31cc (0:31cc) call StoreTrainerHeaderPointer xor a @@ -2858,16 +2859,17 @@ TalkToTrainer:: ; 31cc (0:31cc) ld a, $8 call ReadTrainerHeaderInfo ; read end battle text pop de - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld hl, W_FLAGS_D733 set 4, [hl] ; activate map script index override (index is set below) ld hl, wFlags_0xcd60 - bit 0, [hl] ; test if player is already being engaged by another trainer + bit 0, [hl] ; test if player is already engaging the trainer (because the trainer saw the player) ret nz +; if the player talked to the trainer of his own volition call EngageMapTrainer ld hl, W_CURMAPSCRIPT - inc [hl] ; progress map script index (assuming it was 0 before) to start pre-battle routines - jp Func_325d + inc [hl] ; increment map script index before StartTrainerBattle increments it again (next script function is usually EndTrainerBattle) + jp StartTrainerBattle ; checks if any trainers are seeing the player and wanting to fight CheckFightingMapTrainers:: ; 3219 (0:3219) @@ -2892,19 +2894,21 @@ CheckFightingMapTrainers:: ; 3219 (0:3219) ldh [$b4], a call TrainerWalkUpToPlayer_Bank0 ld hl, W_CURMAPSCRIPT - inc [hl] ; progress to battle phase 1 (engaging) + inc [hl] ; increment map script index (next script function is usually DisplayEnemyTrainerTextAndStartBattle) ret -Func_324c:: ; 324c (0:324c) +; display the before battle text after the enemy trainer has walked up to the player's sprite +DisplayEnemyTrainerTextAndStartBattle:: ; 324c (0:324c) ld a, [wd730] and $1 - ret nz + ret nz ; return if the enemy trainer hasn't finished walking to the player's sprite ld [wJoyIgnore], a ld a, [wSpriteIndex] - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [hSpriteIndexOrTextID], a call DisplayTextID + ; fall through -Func_325d:: ; 325d (0:325d) +StartTrainerBattle:: ; 325d (0:325d) xor a ld [wJoyIgnore], a call InitBattleEnemyParameters @@ -2914,7 +2918,7 @@ Func_325d:: ; 325d (0:325d) ld hl, wd72e set 1, [hl] ld hl, W_CURMAPSCRIPT - inc [hl] ; progress to battle phase 2 (battling) + inc [hl] ; increment map script index (next script function is usually EndTrainerBattle) ret EndTrainerBattle:: ; 3275 (0:3275) @@ -3044,18 +3048,19 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ld e, l jr .trainerLoop -; saves loaded rom bank and hl as well as de registers -PreBattleSaveRegisters:: ; 3354 (0:3354) +; hl = text if the player wins +; de = text if the player loses +SaveEndBattleTextPointers:: ; 3354 (0:3354) ld a, [H_LOADEDROMBANK] - ld [W_PBSTOREDROMBANK], a + ld [wEndBattleTextRomBank], a ld a, h - ld [W_PBSTOREDREGISTERH], a + ld [wEndBattleWinTextPointer], a ld a, l - ld [W_PBSTOREDREGISTERL], a + ld [wEndBattleWinTextPointer + 1], a ld a, d - ld [W_PBSTOREDREGISTERD], a + ld [wEndBattleLoseTextPointer], a ld a, e - ld [W_PBSTOREDREGISTERE], a + ld [wEndBattleLoseTextPointer + 1], a ret ; loads data of some trainer on the current map and plays pre-battle music @@ -3074,7 +3079,7 @@ EngageMapTrainer:: ; 336a (0:336a) ld [wEnemyMonAttackMod], a ; wcd2e jp PlayTrainerMusic -Func_3381:: ; 3381 (0:3381) +PrintEndBattleText:: ; 3381 (0:3381) push hl ld hl, wd72d bit 7, [hl] @@ -3083,45 +3088,45 @@ Func_3381:: ; 3381 (0:3381) ret z ld a, [H_LOADEDROMBANK] push af - ld a, [W_PBSTOREDROMBANK] + ld a, [wEndBattleTextRomBank] ld [H_LOADEDROMBANK], a - ld [$2000], a + ld [MBC1RomBank], a push hl callba SaveTrainerName - ld hl, TrainerNameText + ld hl, TrainerEndBattleText call PrintText pop hl pop af ld [H_LOADEDROMBANK], a - ld [$2000], a - callba Func_1a5e7 + ld [MBC1RomBank], a + callba FreezeEnemyTrainerSprite jp WaitForSoundToFinish -Func_33b7:: ; 33b7 (0:33b7) +GetSavedEndBattleTextPointer:: ; 33b7 (0:33b7) ld a, [wBattleResult] and a - jr nz, .asm_33c6 - ld a, [W_PBSTOREDREGISTERH] +; won battle + jr nz, .lostBattle + ld a, [wEndBattleWinTextPointer] ld h, a - ld a, [W_PBSTOREDREGISTERL] + ld a, [wEndBattleWinTextPointer + 1] ld l, a ret -.asm_33c6 - ld a, [W_PBSTOREDREGISTERD] +.lostBattle + ld a, [wEndBattleLoseTextPointer] ld h, a - ld a, [W_PBSTOREDREGISTERE] + ld a, [wEndBattleLoseTextPointer + 1] ld l, a ret -TrainerNameText:: ; 33cf (0:33cf) +TrainerEndBattleText:: ; 33cf (0:33cf) TX_FAR _TrainerNameText db $08 - -Func_33d4:: ; 33d4 (0:33d4) - call Func_33b7 + call GetSavedEndBattleTextPointer call TextCommandProcessor jp TextScriptEnd +; XXX unused? Func_33dd:: ; 33dd (0:33dd) ld a, [wFlags_0xcd60] bit 0, a @@ -3177,15 +3182,19 @@ PlayTrainerMusic:: ; 33e8 (0:33e8) INCLUDE "data/trainer_types.asm" -Func_3442:: ; 3442 (0:3442) +; checks if the player's coordinates match an arrow movement tile's coordinates +; and if so, decodes the RLE movement data +; b = player Y +; c = player X +DecodeArrowMovementRLE:: ; 3442 (0:3442) ld a, [hli] cp $ff - ret z + ret z ; no match in the list cp b - jr nz, .asm_345b + jr nz, .nextArrowMovementTileEntry1 ld a, [hli] cp c - jr nz, .asm_345c + jr nz, .nextArrowMovementTileEntry2 ld a, [hli] ld d, [hl] ld e, a @@ -3194,12 +3203,12 @@ Func_3442:: ; 3442 (0:3442) dec a ld [wSimulatedJoypadStatesIndex], a ret -.asm_345b +.nextArrowMovementTileEntry1 inc hl -.asm_345c +.nextArrowMovementTileEntry2 inc hl inc hl - jr Func_3442 + jr DecodeArrowMovementRLE FuncTX_ItemStoragePC:: ; 3460 (0:3460) call SaveScreenTilesToBuffer2 @@ -3313,14 +3322,14 @@ CheckCoords:: ; 34c7 (0:34c7) ; tests if a boulder's coordinates are in a specified array ; INPUT: ; hl = address of array -; ff8c = which boulder to check? XXX +; [H_SPRITEINDEX] = index of boulder sprite ; OUTPUT: ; [wWhichTrade] = if there is match, the matching array index ; sets carry if the coordinates are in the array, clears carry if not CheckBoulderCoords:: ; 34e4 (0:34e4) push hl ld hl, wSpriteStateData2 + $04 - ld a, [$ff8c] + ld a, [H_SPRITEINDEX] swap a ld d, $0 ld e, a @@ -3971,21 +3980,21 @@ JoypadLowSensitivity:: ; 3831 (0:3831) ret WaitForTextScrollButtonPress:: ; 3865 (0:3865) - ld a, [H_DOWNARROWBLINKCNT1] ; $ff8b + ld a, [H_DOWNARROWBLINKCNT1] push af - ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c + ld a, [H_DOWNARROWBLINKCNT2] push af xor a - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a ld a, $6 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c -.asm_3872 + ld [H_DOWNARROWBLINKCNT2], a +.loop push hl - ld a, [wd09b] + ld a, [wTownMapSpriteBlinkingEnabled] and a - jr z, .asm_387c - call Func_716c6 -.asm_387c + jr z, .skipAnimation + call TownMapSpriteBlinkingAnimation +.skipAnimation hlCoord 18, 16 call HandleDownArrowBlinkTiming pop hl @@ -3993,16 +4002,16 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) predef Func_5a5f ld a, [$ffb5] and A_BUTTON | B_BUTTON - jr z, .asm_3872 + jr z, .loop pop af - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a pop af - ld [H_DOWNARROWBLINKCNT1], a ; $ff8b + ld [H_DOWNARROWBLINKCNT1], a ret -; (unlass in link battle) waits for A or B being pressed and outputs the scrolling sound effect +; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect ManualTextScroll:: ; 3898 (0:3898) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 jr z, .inLinkBattle call WaitForTextScrollButtonPress @@ -5145,70 +5154,72 @@ Func_3ead:: ; 3ead (0:3ead) ld hl, CinnabarGymQuiz_1eb0a jp Bankswitch -Func_3eb5:: ; 3eb5 (0:3eb5) +CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: ; 3eb5 (0:3eb5) ld a, [H_LOADEDROMBANK] push af ld a, [hJoyHeld] - bit 0, a - jr z, .asm_3eea - ld a, Bank(Func_469a0) - ld [$2000], a + bit 0, a ; A button + jr z, .nothingFound +; A button is pressed + ld a, Bank(CheckForHiddenObject) + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a - call Func_469a0 + call CheckForHiddenObject ld a, [$ffee] and a - jr nz, .asm_3edd - ld a, [wTrainerEngageDistance] - ld [$2000], a + jr nz, .hiddenObjectNotFound + ld a, [wHiddenObjectFunctionRomBank] + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a - ld de, .asm_3eda + ld de, .returnAddress push de jp [hl] -.asm_3eda +.returnAddress xor a - jr .asm_3eec -.asm_3edd + jr .done +.hiddenObjectNotFound callba PrintBookshelfText ld a, [$ffdb] and a - jr z, .asm_3eec -.asm_3eea + jr z, .done +.nothingFound ld a, $ff -.asm_3eec +.done ld [$ffeb], a pop af - ld [$2000], a + ld [MBC1RomBank], a ld [H_LOADEDROMBANK], a ret PrintPredefTextID:: ; 3ef5 (0:3ef5) ld [H_DOWNARROWBLINKCNT2], a ; $ff8c - ld hl, PointerTable_3f22 - call Func_3f0f + ld hl, PredefTextIDPointerTable + call SetMapTextPointer ld hl, wcf11 set 0, [hl] call DisplayTextID + ; fall through -Func_3f05:: ; 3f05 (0:3f05) - ld hl, W_MAPTEXTPTR ; wd36c +RestoreMapTextPointer:: ; 3f05 (0:3f05) + ld hl, W_MAPTEXTPTR ld a, [$ffec] ld [hli], a ld a, [$ffed] ld [hl], a ret -Func_3f0f:: ; 3f0f (0:3f0f) - ld a, [W_MAPTEXTPTR] ; wd36c +SetMapTextPointer:: ; 3f0f (0:3f0f) + ld a, [W_MAPTEXTPTR] ld [$ffec], a ld a, [W_MAPTEXTPTR + 1] ld [$ffed], a ld a, l - ld [W_MAPTEXTPTR], a ; wd36c + ld [W_MAPTEXTPTR], a ld a, h ld [W_MAPTEXTPTR + 1], a ret -PointerTable_3f22:: ; 3f22 (0:3f22) +PredefTextIDPointerTable:: ; 3f22 (0:3f22) dw CardKeySuccessText ; id = 01 dw CardKeyFailText ; id = 02 dw RedBedroomPC ; id = 03 diff --git a/home/init.asm b/home/init.asm index 402a402e..e170fe78 100644 --- a/home/init.asm +++ b/home/init.asm @@ -61,11 +61,11 @@ rLCDC_DEFAULT EQU %11100011 ld a, Bank(WriteDMACodeToHRAM) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call WriteDMACodeToHRAM xor a - ld [$ffd7], a + ld [hTilesetType], a ld [$ff41], a ld [$ffae], a ld [$ffaf], a diff --git a/home/overworld.asm b/home/overworld.asm index 9dbfdfb7..50791184 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -10,7 +10,7 @@ EnterMap:: ld a, $ff ld [wJoyIgnore], a call LoadMapData - callba Func_c335 ; initialize map variables + callba ClearVariablesAfterLoadingMapData ld hl, wd72c bit 0, [hl] ; has the player already made 3 steps since the last battle? jr z, .skipGivingThreeStepsOfNoRandomBattles @@ -20,14 +20,14 @@ EnterMap:: ld hl, wd72e bit 5, [hl] ; did a battle happen immediately before this? res 5, [hl] ; unset the "battle just happened" flag - call z, Func_12e7 + call z, ResetUsingStrengthOutOfBattleBit call nz, MapEntryAfterBattle ld hl, wd732 ld a, [hl] and 1 << 4 | 1 << 3 ; fly warp or dungeon warp jr z, .didNotEnterUsingFlyWarpOrDungeonWarp res 3, [hl] - callba EnterMapAnim ; display fly/teleport in graphical effect + callba EnterMapAnim call UpdateSprites .didNotEnterUsingFlyWarpOrDungeonWarp callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road @@ -53,7 +53,7 @@ OverworldLoopLessDelay:: jp nz,.moveAhead ; if the player sprite has not yet completed the walking animation call JoypadOverworld ; get joypad state (which is possibly simulated) callba SafariZoneCheck - ld a,[wda46] + ld a,[wSafariZoneGameOver] and a jp nz,WarpFound2 ld hl,wd72d @@ -78,7 +78,7 @@ OverworldLoopLessDelay:: jr z,.startButtonNotPressed ; if START is pressed xor a - ld [$ff8c],a ; the $2920 ID for the start menu is 0 + ld [hSpriteIndexOrTextID],a ; start menu text ID jp .displayDialogue .startButtonNotPressed bit 0,a ; A button @@ -87,14 +87,14 @@ OverworldLoopLessDelay:: ld a,[wd730] bit 2,a jp nz,.noDirectionButtonsPressed - call Func_30fd + call IsPlayerCharacterBeingControlledByGame jr nz,.checkForOpponent - call Func_3eb5 ; check for hidden items, PC's, etc. + call CheckForHiddenObjectOrBookshelfOrCardKeyDoor ld a,[$ffeb] and a - jp z,OverworldLoop - call IsSpriteOrSignInFrontOfPlayer ; check for sign or sprite in front of the player - ld a,[$ff8c] ; $2920 ID for NPC/sign text, if any + jp z,OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found + call IsSpriteOrSignInFrontOfPlayer + ld a,[hSpriteIndexOrTextID] and a jp z,OverworldLoop .displayDialogue @@ -293,7 +293,7 @@ OverworldLoopLessDelay:: bit 7,a ; in the safari zone? jr z,.notSafariZone callba SafariZoneCheckSteps - ld a,[wda46] + ld a,[wSafariZoneGameOver] and a jp nz,WarpFound2 .notSafariZone @@ -350,8 +350,8 @@ NewBattle:: ; 0683 (0:0683) ld a,[wd72d] bit 4,a jr nz,.noBattle - call Func_30fd - jr nz,.noBattle + call IsPlayerCharacterBeingControlledByGame + jr nz,.noBattle ; no battle if the player character is under the game's control ld a,[wd72e] bit 4,a jr nz,.noBattle @@ -523,7 +523,7 @@ WarpFound2:: ; 073c (0:073c) .done ld hl,wd736 set 0,[hl] ; have the player's sprite step out from the door (if there is one) - call Func_12da + call IgnoreInputForHalfSecond jp EnterMap ContinueCheckWarpsNoCollisionLoop:: ; 07b5 (0:07b5) @@ -747,7 +747,7 @@ HandleBlackOut:: res 5, [hl] ld a, Bank(ResetStatusAndHalveMoneyOnBlackout) ; also Bank(SpecialWarpIn) and Bank(SpecialEnterMap) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call ResetStatusAndHalveMoneyOnBlackout call SpecialWarpIn call Func_2312 @@ -798,7 +798,7 @@ LoadPlayerSpriteGraphics:: dec a jr z, .ridingBike - ld a, [$ffd7] + ld a, [hTilesetType] and a jr nz, .determineGraphics jr .startWalking @@ -1058,11 +1058,11 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02) ret ; function to check if there is a sign or sprite in front of the player -; if so, it is stored in [$FF8C] -; if not, [$FF8C] is set to 0 +; if so, it is stored in [hSpriteIndexOrTextID] +; if not, [hSpriteIndexOrTextID] is set to 0 IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) xor a - ld [$ff8c],a + ld [hSpriteIndexOrTextID],a ld a,[wd4b0] ; number of signs in the map and a jr z,.extendRangeOverCounter @@ -1092,7 +1092,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) dec c add hl,bc ld a,[hl] - ld [$ff8c],a ; store sign text ID + ld [hSpriteIndexOrTextID],a ; store sign text ID pop bc pop hl ret @@ -1113,7 +1113,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) jr nz,.counterTilesLoop ; part of the above function, but sometimes its called on its own, when signs are irrelevant -; the caller must zero [$FF8C] +; the caller must zero [hSpriteIndexOrTextID] IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b) ld d,$10 ; talking range in pixels (normal range) IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) @@ -1195,7 +1195,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) ld l,a set 7,[hl] ld a,e - ld [$ff8c],a ; store sprite ID + ld [hSpriteIndexOrTextID],a ret ; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing) @@ -1214,9 +1214,9 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) and d ; check if a sprite is in the direction the player is trying to go jr nz,.collision xor a - ld [$ff8c],a + ld [hSpriteIndexOrTextID],a call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision? - ld a,[$ff8c] + ld a,[hSpriteIndexOrTextID] and a ; was there a sprite collision? jr nz,.collision ; if no sprite collision @@ -1467,7 +1467,7 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) cp a,$01 jr nz,.checkIfMovingWest ; moving east - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld e,a and a,$e0 ld d,a @@ -1475,13 +1475,13 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) add a,$02 and a,$1f or d - ld [wd526],a + ld [wMapViewVRAMPointer],a jr .adjustXCoordWithinBlock .checkIfMovingWest cp a,$ff jr nz,.checkIfMovingSouth ; moving west - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld e,a and a,$e0 ld d,a @@ -1489,36 +1489,36 @@ AdvancePlayerSprite:: ; 0d27 (0:0d27) sub a,$02 and a,$1f or d - ld [wd526],a + ld [wMapViewVRAMPointer],a jr .adjustXCoordWithinBlock .checkIfMovingSouth ld a,b cp a,$01 jr nz,.checkIfMovingNorth ; moving south - ld a,[wd526] + ld a,[wMapViewVRAMPointer] add a,$40 - ld [wd526],a + ld [wMapViewVRAMPointer],a jr nc,.adjustXCoordWithinBlock - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] inc a and a,$03 or a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a jr .adjustXCoordWithinBlock .checkIfMovingNorth cp a,$ff jr nz,.adjustXCoordWithinBlock ; moving north - ld a,[wd526] + ld a,[wMapViewVRAMPointer] sub a,$40 - ld [wd526],a + ld [wMapViewVRAMPointer],a jr nc,.adjustXCoordWithinBlock - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] dec a and a,$03 or a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a .adjustXCoordWithinBlock ld a,c and a @@ -1694,18 +1694,18 @@ MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85) ScheduleNorthRowRedraw:: ; 0e91 (0:0e91) hlCoord 0, 0 - call ScheduleRowRedrawHelper - ld a,[wd526] + call CopyToScreenEdgeTiles + ld a,[wMapViewVRAMPointer] ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWROW ld [H_SCREENEDGEREDRAW],a ret -ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) +CopyToScreenEdgeTiles:: ; 0ea6 (0:0ea6) ld de,wScreenEdgeTiles - ld c,$28 + ld c,2 * 20 .loop ld a,[hli] ld [de],a @@ -1716,10 +1716,10 @@ ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) hlCoord 0, 16 - call ScheduleRowRedrawHelper - ld a,[wd526] + call CopyToScreenEdgeTiles + ld a,[wMapViewVRAMPointer] ld l,a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld h,a ld bc,$0200 add hl,bc @@ -1736,7 +1736,7 @@ ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) hlCoord 18, 0 call ScheduleColumnRedrawHelper - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld c,a and a,$e0 ld b,a @@ -1745,7 +1745,7 @@ ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) and a,$1f or b ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWCOL ld [H_SCREENEDGEREDRAW],a @@ -1774,9 +1774,9 @@ ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2) ScheduleWestColumnRedraw:: ; 0f08 (0:0f08) hlCoord 0, 0 call ScheduleColumnRedrawHelper - ld a,[wd526] + ld a,[wMapViewVRAMPointer] ld [H_SCREENEDGEREDRAWADDR],a - ld a,[wd527] + ld a,[wMapViewVRAMPointer + 1] ld [H_SCREENEDGEREDRAWADDR + 1],a ld a,REDRAWCOL ld [H_SCREENEDGEREDRAW],a @@ -2013,7 +2013,7 @@ LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063) ; function to load data from the map header LoadMapHeader:: ; 107c (0:107c) - callba Func_f113 + callba MarkTownVisitedAndLoadMissableObjects ld a,[W_CURMAPTILESET] ld [wd119],a ld a,[W_CURMAP] @@ -2307,9 +2307,9 @@ LoadMapData:: ; 1241 (0:1241) push af call DisableLCD ld a,$98 - ld [wd527],a + ld [wMapViewVRAMPointer + 1],a xor a - ld [wd526],a + ld [wMapViewVRAMPointer],a ld [$ffaf],a ld [$ffae],a ld [wWalkCounter],a @@ -2383,16 +2383,16 @@ SwitchToMapRomBank:: ; 12bc (0:12bc) pop hl ret -Func_12da:: ; 12da (0:12da) - ld a, $1e - ld [wd13a], a +IgnoreInputForHalfSecond: ; 12da (0:12da) + ld a, 30 + ld [wIgnoreInputCounter], a ld hl, wd730 ld a, [hl] or $26 - ld [hl], a + ld [hl], a ; set ignore input bit ret -Func_12e7:: ; 12e7 (0:12e7) +ResetUsingStrengthOutOfBattleBit: ; 12e7 (0:12e7) ld hl, wd728 res 0, [hl] ret diff --git a/home/vblank.asm b/home/vblank.asm index b4daaa8b..d660f270 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -29,7 +29,7 @@ VBlank:: call $ff80 ; hOAMDMA ld a, Bank(PrepareOAMData) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call PrepareOAMData ; VBlank-sensitive operations end. @@ -54,7 +54,7 @@ VBlank:: ld a, [wc0ef] ; music ROM bank ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a cp BANK(Music2_UpdateMusic) jr nz, .notbank2 @@ -72,7 +72,7 @@ VBlank:: call Music1f_UpdateMusic .afterMusic - callba Func_18dee ; keep track of time played + callba TrackPlayTime ; keep track of time played ld a, [$fff9] and a @@ -80,7 +80,7 @@ VBlank:: ld a, [wd122] ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a pop hl pop de diff --git a/home/vcopy.asm b/home/vcopy.asm index 81fcb991..d42293d9 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -376,9 +376,9 @@ UpdateMovingBgTiles:: ; Animate water and flower ; tiles in the overworld. - ld a, [$ffd7] + ld a, [hTilesetType] and a - ret z + ret z ; no animations if indoors (or if a menu set this to 0) ld a, [$ffd8] inc a @@ -412,9 +412,10 @@ UpdateMovingBgTiles:: dec c jr nz, .left .done - ld a, [$ffd7] + ld a, [hTilesetType] rrca ret nc +; if in a cave, no flower animations xor a ld [$ffd8], a ret diff --git a/hram.asm b/hram.asm index 551ec67d..013761d6 100644 --- a/hram.asm +++ b/hram.asm @@ -17,6 +17,9 @@ H_DOWNARROWBLINKCNT2 EQU $FF8C H_SPRITEDATAOFFSET EQU $FF8B H_SPRITEINDEX EQU $FF8C +; DisplayTextID's argument +hSpriteIndexOrTextID EQU $FF8C + ; Note: the following multiplication and division addresses are used for multiple purposes ; and so they overlap with each other @@ -120,6 +123,12 @@ H_FRAMECOUNTER EQU $FFD5 ; decremented every V-blank (used for delays) ; you can detect that the V-blank handler has run since then. H_VBLANKOCCURRED EQU $FFD6 +; 00 = indoor +; 01 = cave +; 02 = outdoor +; this is often set to 00 in order to turn off water and flower BG tile animations +hTilesetType EQU $FFD7 + H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 H_WHOSETURN EQU $FFF3 ; 0 on player’s turn, 1 on enemy’s turn diff --git a/macros.asm b/macros.asm index 8244c8c9..0aa76291 100644 --- a/macros.asm +++ b/macros.asm @@ -16,11 +16,11 @@ homecall: MACRO push af ld a, BANK(\1) ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a call \1 pop af ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a + ld [MBC1RomBank], a ENDM callba: MACRO diff --git a/main.asm b/main.asm index 22721cdb..72cef23b 100755 --- a/main.asm +++ b/main.asm @@ -2021,12 +2021,12 @@ INCLUDE "data/map_songs.asm" INCLUDE "data/map_header_banks.asm" -Func_c335: ; c335 (3:4335) +ClearVariablesAfterLoadingMapData: ; c335 (3:4335) ld a, $90 ld [hVBlankWY], a - ld [rWY], a ; $ff4a + ld [rWY], a xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ld [wStepCounter], a ld [W_LONEATTACKNO], a ; W_GYMLEADERNO ld [hJoyPressed], a @@ -2034,10 +2034,10 @@ Func_c335: ; c335 (3:4335) ld [hJoyHeld], a ld [wcd6a], a ld [wd5a3], a - ld hl, wd73f + ld hl, wCardKeyDoorY ld [hli], a ld [hl], a - ld hl, wWhichTrade ; wWhichTrade + ld hl, wWhichTrade ld bc, $1e call FillMemory ret @@ -2509,7 +2509,7 @@ CheckForBoulderCollisionWithSprites: ; c636 (3:4636) ApplyOutOfBattlePoisonDamage: ; c69c (3:469c) ld a, [wd730] add a - jp c, .noBlackOut + jp c, .noBlackOut ; no black out if joypad states are being simulated ld a, [wPartyCount] and a jp z, .noBlackOut @@ -2644,7 +2644,7 @@ LoadTilesetHeader: ; c754 (3:4754) dec c jr nz, .copyTilesetHeaderLoop ld a, [hl] - ld [$ffd7], a + ld [hTilesetType], a xor a ld [$ffd8], a pop hl @@ -3068,10 +3068,14 @@ DrawBadges: ; ea03 (3:6a03) GymLeaderFaceAndBadgeTileGraphics: ; ea9e (3:6a9e) INCBIN "gfx/badges.2bpp" -Func_ee9e: ; ee9e (3:6e9e) +; replaces a tile block with the one specified in [wNewTileBlockID] +; and redraws the map view if necessary +; b = Y +; c = X +ReplaceTileBlock: ; ee9e (3:6e9e) call GetPredefRegisters ld hl, wOverworldMap - ld a, [W_CURMAPWIDTH] ; wd369 + ld a, [W_CURMAPWIDTH] add $6 ld e, a ld d, $0 @@ -3083,21 +3087,22 @@ Func_ee9e: ; ee9e (3:6e9e) ld e, a ld a, b and a - jr z, .asm_eebb -.asm_eeb7 + jr z, .addX +; add width * Y +.addWidthYTimesLoop add hl, de dec b - jr nz, .asm_eeb7 -.asm_eebb - add hl, bc - ld a, [wd09f] + jr nz, .addWidthYTimesLoop +.addX + add hl, bc ; add X + ld a, [wNewTileBlockID] ld [hl], a ld a, [wCurrentTileBlockMapViewPointer] ld c, a ld a, [wCurrentTileBlockMapViewPointer + 1] ld b, a - call Func_ef4e - ret c + call CompareHLWithBC + ret c ; return if the replaced tile block is below the map view in memory push hl ld l, e ld h, $0 @@ -3108,27 +3113,27 @@ Func_ee9e: ; ee9e (3:6e9e) add hl, de add hl, bc pop bc - call Func_ef4e - ret c + call CompareHLWithBC + ret c ; return if the replaced tile block is above the map view in memory -Func_eedc: ; eedc (3:6edc) +RedrawMapView: ; eedc (3:6edc) ld a, [W_ISINBATTLE] ; W_ISINBATTLE inc a ret z - ld a, [H_AUTOBGTRANSFERENABLED] ; $ffba + ld a, [H_AUTOBGTRANSFERENABLED] push af - ld a, [$ffd7] + ld a, [hTilesetType] push af xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld [$ffd7], a + ld [H_AUTOBGTRANSFERENABLED], a + ld [hTilesetType], a ; no flower/water BG tile animations call LoadCurrentMapView call GoPAL_SET_CF1C - ld hl, wd526 + ld hl, wMapViewVRAMPointer ld a, [hli] ld h, [hl] ld l, a - ld de, $ffc0 + ld de, -2 * 32 add hl, de ld a, h and $3 @@ -3137,21 +3142,21 @@ Func_eedc: ; eedc (3:6edc) ld [wHPBarMaxHP], a ld a, h ld [wHPBarMaxHP + 1], a - ld a, $2 + ld a, 2 ld [$ffbe], a - ld c, $9 -.asm_ef0f + ld c, 9 ; number of rows of 2x2 tiles (this covers the whole screen) +.redrawRowLoop push bc push hl push hl - ld hl, wOAMBuffer + $78 - ld de, $14 + ld hl, wTileMap - 2 * 20 + ld de, 20 ld a, [$ffbe] .asm_ef1a add hl, de dec a jr nz, .asm_ef1a - call ScheduleRowRedrawHelper + call CopyToScreenEdgeTiles pop hl ld de, $20 ld a, [$ffbe] @@ -3163,11 +3168,11 @@ Func_eedc: ; eedc (3:6edc) or $98 dec c jr nz, .asm_ef28 - ld [$ffd2], a + ld [H_SCREENEDGEREDRAWADDR + 1], a ld a, l - ld [H_SCREENEDGEREDRAWADDR], a ; $ffd1 - ld a, $2 - ld [H_SCREENEDGEREDRAW], a ; $ffd0 + ld [H_SCREENEDGEREDRAWADDR], a + ld a, REDRAWROW + ld [H_SCREENEDGEREDRAW], a call DelayFrame ld hl, $ffbe inc [hl] @@ -3175,14 +3180,14 @@ Func_eedc: ; eedc (3:6edc) pop hl pop bc dec c - jr nz, .asm_ef0f + jr nz, .redrawRowLoop pop af - ld [$ffd7], a + ld [hTilesetType], a pop af - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ret -Func_ef4e: ; ef4e (3:6f4e) +CompareHLWithBC: ; ef4e (3:6f4e) ld a, h sub b ret nz @@ -3192,8 +3197,8 @@ Func_ef4e: ; ef4e (3:6f4e) INCLUDE "engine/overworld/cut.asm" -Func_f113: ; f113 (3:7113) - ld a, [W_CURMAP] ; W_CURMAP +MarkTownVisitedAndLoadMissableObjects: ; f113 (3:7113) + ld a, [W_CURMAP] cp ROUTE_1 jr nc, .notInTown ld c, a @@ -3202,15 +3207,16 @@ Func_f113: ; f113 (3:7113) predef FlagActionPredef .notInTown ld hl, MapHSPointers - ld a, [W_CURMAP] ; W_CURMAP + ld a, [W_CURMAP] ld b, $0 ld c, a add hl, bc add hl, bc ld a, [hli] ; load missable objects pointer in hl ld h, [hl] + ; fall through -Func_f132: ; f132 (3:7132) +LoadMissableObjects: ; f132 (3:7132) ld l, a push hl ld de, MapHS00 ; calculate difference between out pointer and the base pointer diff --git a/scripts/agatha.asm b/scripts/agatha.asm index ca7c0ed8..a8f9e137 100755 --- a/scripts/agatha.asm +++ b/scripts/agatha.asm @@ -24,7 +24,7 @@ AgathaScript_76443: ; 76443 (1d:6443) AgathaScript_76459: ; 76459 (1d:6459) ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock AgathaScript_76464: ; 76464 (1d:6464) xor a @@ -33,7 +33,7 @@ AgathaScript_76464: ; 76464 (1d:6464) AgathaScriptPointers: ; 76469 (1d:6469) dw AgathaScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw AgathaScript2 dw AgathaScript3 dw AgathaScript4 diff --git a/scripts/bruno.asm b/scripts/bruno.asm index 553469d0..ffe05bce 100755 --- a/scripts/bruno.asm +++ b/scripts/bruno.asm @@ -24,7 +24,7 @@ BrunoScript_762ec: ; 762ec (1d:62ec) BrunoScript_76302: ; 76302 (1d:6302) ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock BrunoScript_7630d: ; 7630d (1d:630d) xor a @@ -33,7 +33,7 @@ BrunoScript_7630d: ; 7630d (1d:630d) BrunoScriptPointers: ; 76312 (1d:6312) dw BrunoScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw BrunoScript2 dw BrunoScript3 dw BrunoScript4 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 87239910..e8d90a5a 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -34,7 +34,7 @@ CeladonGameCornerScript_48bec: ; 48bec (12:4bec) ld a, $2a ld [wd09f], a ld bc, $0208 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock CeladonGameCornerScript_48c07: ; 48c07 (12:4c07) xor a @@ -409,7 +409,7 @@ CeladonGameCornerText11: ; 48e9d (12:4e9d) set 7, [hl] ld hl, CeladonGameCornerText_48ed3 ld de, CeladonGameCornerText_48ed3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer @@ -449,7 +449,7 @@ CeladonGameCornerText12: ; 48edd (12:4edd) ld a, $43 ld [wd09f], a ld bc, $0208 - predef Func_ee9e + predef ReplaceTileBlock jp TextScriptEnd CeladonGameCornerText_48f09: ; 48f09 (12:4f09) diff --git a/scripts/celadongym.asm b/scripts/celadongym.asm index 092bff88..b1b1060c 100755 --- a/scripts/celadongym.asm +++ b/scripts/celadongym.asm @@ -31,7 +31,7 @@ CeladonGymText_48943: ; 48943 (12:4943) CeladonGymScriptPointers: ; 4894e (12:494e) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw CeladonGymScript3 @@ -177,7 +177,7 @@ CeladonGymText1: ; 48a11 (12:4a11) set 7, [hl] ld hl, CeladonGymText_48a63 ld de, CeladonGymText_48a63 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index d97f9723..97824662 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -133,7 +133,7 @@ CeruleanCityScript1: ; 19567 (6:5567) set 7, [hl] ld hl, CeruleanCityText_1966d ld de, CeruleanCityText_19672 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY1 + $c8 ld [W_CUROPPONENT], a @@ -277,7 +277,7 @@ CeruleanCityText2: ; 1967c (6:567c) set 7, [hl] ld hl, CeruleanCityText_196ee ld de, CeruleanCityText_196ee - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [$ff8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/ceruleangym.asm b/scripts/ceruleangym.asm index ae6a40a0..079844f3 100755 --- a/scripts/ceruleangym.asm +++ b/scripts/ceruleangym.asm @@ -31,7 +31,7 @@ CeruleanGymScript_5c6ed: ; 5c6ed (17:46ed) CeruleanGymScriptPointers: ; 5c6f8 (17:46f8) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw CeruleanGymScript3 @@ -126,7 +126,7 @@ CeruleanGymText1: ; 5c771 (17:4771) set 7, [hl] ld hl, CeruleanGymText_5c7d8 ld de, CeruleanGymText_5c7d8 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 65fd1db9..48133c52 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -224,7 +224,7 @@ CinnabarGymText1: ; 758df (1d:58df) call PrintText ld hl, BlaineEndBattleText ld de, BlaineEndBattleText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, $7 ld [W_GYMLEADERNO], a jp CinnabarGymScript_758b7 @@ -267,7 +267,7 @@ CinnabarGymText2: ; 75939 (1d:5939) call PrintText ld hl, CinnabarGymText_75964 ld de, CinnabarGymText_75964 ; $5964 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_46bb4 ; 0x75956 ld hl, CinnabarGymText_75969 @@ -296,7 +296,7 @@ CinnabarGymText3: ; 7596e (1d:596e) call PrintText ld hl, CinnabarGymText_75999 ld de, CinnabarGymText_75999 ; $5999 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_4b406 ; 0x7598b ld hl, CinnabarGymText_7599e @@ -325,7 +325,7 @@ CinnabarGymText4: ; 759a3 (1d:59a3) call PrintText ld hl, CinnabarGymText_759ce ld de, CinnabarGymText_759ce ; $59ce XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_c0673 ; 0x759c0 ld hl, CinnabarGymText_759d3 @@ -354,7 +354,7 @@ CinnabarGymText5: ; 759d8 (1d:59d8) call PrintText ld hl, CinnabarGymText_75a03 ld de, CinnabarGymText_75a03 ; $5a03 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_5cfd7 ; 0x759f5 ld hl, CinnabarGymText_75a08 @@ -383,7 +383,7 @@ CinnabarGymText6: ; 75a0d (1d:5a0d) call PrintText ld hl, CinnabarGymText_75a38 ld de, CinnabarGymText_75a38 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_776b4 ; 0x75a2a ld hl, CinnabarGymText_75a3d @@ -412,7 +412,7 @@ CinnabarGymText7: ; 75a42 (1d:5a42) call PrintText ld hl, CinnabarGymText_75a6d ld de, CinnabarGymText_75a6d - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_2f755 ; 0x75a5f ld hl, CinnabarGymText_75a72 @@ -441,7 +441,7 @@ CinnabarGymText8: ; 75a77 (1d:5a77) call PrintText ld hl, CinnabarGymText_75aa2 ld de, CinnabarGymText_75aa2 ; $5aa2 XXX - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp CinnabarGymScript_758b7 .asm_d87be ; 0x75a94 ld hl, CinnabarGymText_75aa7 diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index fb8d7b19..4a55347e 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -16,7 +16,7 @@ FightingDojoScript_5cd70: ; 5cd70 (17:4d70) FightingDojoScriptPointers: ; 5cd7b (17:4d7b) dw FightingDojoScript1 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw FightingDojoScript3 @@ -147,7 +147,7 @@ FightingDojoText1: ; 5ce44 (17:4e44) set 7, [hl] ld hl, FightingDojoText_5ce93 ld de, FightingDojoText_5ce93 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/fuchsiagym.asm b/scripts/fuchsiagym.asm index 14ffdfa9..43d977d7 100755 --- a/scripts/fuchsiagym.asm +++ b/scripts/fuchsiagym.asm @@ -32,7 +32,7 @@ FuchsiaGymScript_75477: ; 75477 (1d:5477) FuchsiaGymScriptPointers: ; 75482 (1d:5482) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw FuchsiaGymScript3 @@ -166,7 +166,7 @@ FuchsiaGymText1: ; 75534 (1d:5534) set 7, [hl] ld hl, UnnamedText_75586 ld de, UnnamedText_75586 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/gary.asm b/scripts/gary.asm index b32e3595..fa331152 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -63,7 +63,7 @@ GaryScript2: ; 75f6a (1d:5f6a) set 7, [hl] ld hl, GaryText_760f9 ld de, GaryText_760fe - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY3 + $c8 ld [W_CUROPPONENT], a diff --git a/scripts/lance.asm b/scripts/lance.asm index d5ca4e5c..f2523098 100755 --- a/scripts/lance.asm +++ b/scripts/lance.asm @@ -34,7 +34,7 @@ LanceScript_5a2de: ; 5a2de (16:62de) ld bc, $603 LanceScript_5a2f0: ; 5a2f0 (16:62f0) - predef_jump Func_ee9e + predef_jump ReplaceTileBlock LanceScript_5a2f5: ; 5a2f5 (16:62f5) xor a @@ -43,7 +43,7 @@ LanceScript_5a2f5: ; 5a2f5 (16:62f5) LanceScriptPointers: ; 5a2fa (16:62fa) dw LanceScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw LanceScript2 dw LanceScript3 dw LanceScript4 diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm index 33f419a3..ab769d94 100755 --- a/scripts/lorelei.asm +++ b/scripts/lorelei.asm @@ -25,7 +25,7 @@ LoreleiScript_76191: ; 76191 (1d:6191) .asm_761ab ld [wd09f], a ld bc, $2 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock LoreleiScript_761b6: ; 761b6 (1d:61b6) xor a @@ -34,7 +34,7 @@ LoreleiScript_761b6: ; 761b6 (1d:61b6) LoreleiScriptPointers: ; 761bb (1d:61bb) dw LoreleiScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw LoreleiScript2 dw LoreleiScript3 dw LoreleiScript4 diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index 7621897f..3e067a98 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -43,7 +43,7 @@ Mansion1Script_4430b: ; 4430b (11:430b) ld a, $e ld [wd09f], a asm_44310: ; 44310 (11:4310) - predef Func_ee9e + predef ReplaceTileBlock ret Mansion1Script_Switches: ; 44316 (11:4316) @@ -58,7 +58,7 @@ Mansion1Script_Switches: ; 44316 (11:4316) Mansion1ScriptPointers: ; 44326 (11:4326) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion1TextPointers: ; 4432c (11:432c) diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 1b7a28a3..c643d229 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -40,7 +40,7 @@ Mansion2Script_51fee: ; 51fee (14:5fee) Mansion2Script_5202f: ; 5202f (14:602f) ld [wd09f], a - predef_jump Func_ee9e + predef_jump ReplaceTileBlock Mansion2Script_Switches: ; 52037 (14:6037) ld a, [wSpriteStateData1 + 9] @@ -54,7 +54,7 @@ Mansion2Script_Switches: ; 52037 (14:6037) Mansion2ScriptPointers: ; 52047 (14:6047) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion2TextPointers: ; 5204d (14:604d) diff --git a/scripts/mansion3.asm b/scripts/mansion3.asm index 494fba13..6ad02dd9 100755 --- a/scripts/mansion3.asm +++ b/scripts/mansion3.asm @@ -34,7 +34,7 @@ Mansion3Script_52204: ; 52204 (14:6204) Mansion3ScriptPointers: ; 52235 (14:6235) dw Mansion3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion3Script0: ; 5223b (14:623b) diff --git a/scripts/mansion4.asm b/scripts/mansion4.asm index cfd78c5f..b89af5f2 100755 --- a/scripts/mansion4.asm +++ b/scripts/mansion4.asm @@ -56,7 +56,7 @@ Mansion4Script_Switches: ; 52420 (14:6420) Mansion4ScriptPointers: ; 52430 (14:6430) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Mansion4TextPointers: ; 52436 (14:6436) diff --git a/scripts/mtmoon1.asm b/scripts/mtmoon1.asm index 42f98d98..def597ba 100755 --- a/scripts/mtmoon1.asm +++ b/scripts/mtmoon1.asm @@ -9,7 +9,7 @@ MtMoon1Script: ; 499c8 (12:59c8) MtMoon1ScriptPointers: ; 499db (12:59db) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle MtMoon1TextPointers: ; 499e1 (12:59e1) diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index 71638409..f0124be0 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -47,7 +47,7 @@ MtMoon3Script_49d58: ; 49d58 (12:5d58) MtMoon3ScriptPointers: ; 49d63 (12:5d63) dw MtMoon3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw MtMoon3Script3 dw MtMoon3Script4 @@ -228,7 +228,7 @@ MtMoon3Text1: ; 49e79 (12:5e79) set 7, [hl] ld hl, MtMoon3Text_49f8a ld de, MtMoon3Text_49f8a - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 8666d18e..574c6814 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -378,7 +378,7 @@ OaksLabScript11: ; 1cdb9 (7:4db9) call GetSpritePosition1 ld hl, OaksLabText_1d3be ld de, OaksLabText_1d3c3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld hl, wd72d set 6, [hl] set 7, [hl] diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 0ab4c3a4..21d3fe74 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -31,7 +31,7 @@ PewterGymScript_5c3bf: ; 5c3bf (17:43bf) PewterGymScriptPointers: ; 5c3ca (17:43ca) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw PewterGymScript3 @@ -126,7 +126,7 @@ PewterGymText1: ; 5c44e (17:444e) set 7, [hl] ld hl, PewterGymText_5c4bc ld de, PewterGymText_5c4bc - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index 38dd1bc5..3c9ec72d 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -130,7 +130,7 @@ PokemonTower2Text1: ; 605df (18:45df) set 7, [hl] ld hl, PokemonTower2Text_60632 ld de, PokemonTower2Text_60637 ; XXX $4637 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a diff --git a/scripts/pokemontower3.asm b/scripts/pokemontower3.asm index f05623fb..8df5bfc5 100755 --- a/scripts/pokemontower3.asm +++ b/scripts/pokemontower3.asm @@ -9,7 +9,7 @@ PokemonTower3Script: ; 606cc (18:46cc) PokemonTower3ScriptPointers: ; 606df (18:46df) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower3TextPointers: ; 606e5 (18:46e5) diff --git a/scripts/pokemontower4.asm b/scripts/pokemontower4.asm index e48b9681..760bb604 100755 --- a/scripts/pokemontower4.asm +++ b/scripts/pokemontower4.asm @@ -9,7 +9,7 @@ PokemonTower4Script: ; 607f6 (18:47f6) PokemonTower4ScriptPointers: ; 60809 (18:4809) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower4TextPointers: ; 6080f (18:480f) diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm index 6dd694ac..b70f9e28 100755 --- a/scripts/pokemontower5.asm +++ b/scripts/pokemontower5.asm @@ -9,7 +9,7 @@ PokemonTower5Script: ; 60932 (18:4932) PokemonTower5ScriptPointers: ; 60945 (18:4945) dw PokemonTower5Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PokemonTower5Script0: ; 6094b (18:494b) diff --git a/scripts/pokemontower6.asm b/scripts/pokemontower6.asm index 6320e2af..58968d17 100755 --- a/scripts/pokemontower6.asm +++ b/scripts/pokemontower6.asm @@ -16,7 +16,7 @@ PokemonTower6Script_60b02: ; 60b02 (18:4b02) PokemonTower6ScriptPointers: ; 60b0d (18:4b0d) dw PokemonTower6Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw PokemonTower6Script3 dw PokemonTower6Script4 diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 6ebf15d5..cc736a08 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -16,7 +16,7 @@ PokemonTower7Script_60d18: ; 60d18 (18:4d18) PokemonTower7ScriptPointers: ; 60d23 (18:4d23) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw PokemonTower7Script2 dw PokemonTower7Script3 dw PokemonTower7Script4 diff --git a/scripts/powerplant.asm b/scripts/powerplant.asm index b90ba7a1..ec4f89b3 100755 --- a/scripts/powerplant.asm +++ b/scripts/powerplant.asm @@ -9,7 +9,7 @@ PowerPlantScript: ; 1e2c6 (7:62c6) PowerPlantScriptPointers: ; 1e2d9 (7:62d9) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle PowerPlantTextPointers: ; 1e2df (7:62df) diff --git a/scripts/rockethideout1.asm b/scripts/rockethideout1.asm index 43e4fd26..499f77ef 100755 --- a/scripts/rockethideout1.asm +++ b/scripts/rockethideout1.asm @@ -30,11 +30,11 @@ RocketHideout1Script_44be0: ; 44be0 (11:4be0) .asm_44c03 ld [wd09f], a ld bc, $080c - predef_jump Func_ee9e + predef_jump ReplaceTileBlock RocketHideout1ScriptPointers: ; 44c0e (11:4c0e) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RocketHideout1TextPointers: ; 44c14 (11:4c14) diff --git a/scripts/rockethideout2.asm b/scripts/rockethideout2.asm index 326c1605..99754658 100755 --- a/scripts/rockethideout2.asm +++ b/scripts/rockethideout2.asm @@ -9,7 +9,7 @@ RocketHideout2Script: ; 44e27 (11:4e27) RocketHideout2ScriptPointers: ; 44e3a (11:4e3a) dw RocketHideout2Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout2Script3 @@ -19,7 +19,7 @@ RocketHideout2Script0: ; 44e42 (11:4e42) ld a, [W_XCOORD] ld c, a ld hl, RocketHideout2ArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers ld hl, wd736 diff --git a/scripts/rockethideout3.asm b/scripts/rockethideout3.asm index 3870c6b6..6dc467ab 100755 --- a/scripts/rockethideout3.asm +++ b/scripts/rockethideout3.asm @@ -9,7 +9,7 @@ RocketHideout3Script: ; 45225 (11:5225) RocketHideout3ScriptPointers: ; 45238 (11:5238) dw RocketHideout3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout3Script3 @@ -19,7 +19,7 @@ RocketHideout3Script0: ; 45240 (11:5240) ld a, [W_XCOORD] ld c, a ld hl, RocketHideout3ArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers ld hl, wd736 diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index ddac941a..097512c3 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -31,7 +31,7 @@ RocketHideout4Script_45473: ; 45473 (11:5473) .asm_45498 ld [wd09f], a ld bc, $050c - predef_jump Func_ee9e + predef_jump ReplaceTileBlock RocketHideout4Script_454a3: ; 454a3 (11:54a3) xor a @@ -42,7 +42,7 @@ RocketHideout4Script_454a3: ; 454a3 (11:54a3) RocketHideout4ScriptPointers: ; 454ae (11:54ae)c dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw RocketHideout4Script3 @@ -130,7 +130,7 @@ RocketHideout4Text1: ; 4553a (11:553a) set 7, [hl] ld hl, RocketHideout4Text_4557f ld de, RocketHideout4Text_4557f - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/rocktunnel1.asm b/scripts/rocktunnel1.asm index ad6e493f..1d514a05 100755 --- a/scripts/rocktunnel1.asm +++ b/scripts/rocktunnel1.asm @@ -9,7 +9,7 @@ RockTunnel1Script: ; 444dc (11:44dc) RockTunnel1ScriptPointers: ; 444ef (11:44ef) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RockTunnel1TextPointers: ; 444f5 (11:44f5) diff --git a/scripts/rocktunnel2.asm b/scripts/rocktunnel2.asm index a35a7325..98b804a7 100755 --- a/scripts/rocktunnel2.asm +++ b/scripts/rocktunnel2.asm @@ -9,7 +9,7 @@ RockTunnel2Script: ; 45feb (11:5feb) RockTunnel2ScriptPointers: ; 45ffe (11:5ffe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle RockTunnel2TextPointers: ; 46004 (11:6004) diff --git a/scripts/route10.asm b/scripts/route10.asm index e5e0dec2..c587b1df 100755 --- a/scripts/route10.asm +++ b/scripts/route10.asm @@ -9,7 +9,7 @@ Route10Script: ; 59336 (16:5336) Route10ScriptPointers: ; 59349 (16:5349) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route10TextPointers: ; 5934f (16:534f) diff --git a/scripts/route11.asm b/scripts/route11.asm index fb50937e..629a6efd 100755 --- a/scripts/route11.asm +++ b/scripts/route11.asm @@ -9,7 +9,7 @@ Route11Script: ; 5944c (16:544c) Route11ScriptPointers: ; 5945f (16:545f) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route11TextPointers: ; 59465 (16:5465) diff --git a/scripts/route12.asm b/scripts/route12.asm index 04b86207..a38f6b83 100755 --- a/scripts/route12.asm +++ b/scripts/route12.asm @@ -16,7 +16,7 @@ Route12Script_59606: ; 59606 (16:5606) Route12ScriptPointers: ; 59611 (16:5611) dw Route12Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route12Script3 diff --git a/scripts/route13.asm b/scripts/route13.asm index b78b7cb2..21862dfc 100755 --- a/scripts/route13.asm +++ b/scripts/route13.asm @@ -9,7 +9,7 @@ Route13Script: ; 5581e (15:581e) Route13ScriptPointers: ; 55831 (15:5831) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route13TextPointers: ; 55837 (15:5837) diff --git a/scripts/route14.asm b/scripts/route14.asm index 9d8d8fcb..d430f858 100755 --- a/scripts/route14.asm +++ b/scripts/route14.asm @@ -9,7 +9,7 @@ Route14Script: ; 559d3 (15:59d3) Route14ScriptPointers: ; 559e6 (15:59e6) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route14TextPointers: ; 559ec (15:59ec) diff --git a/scripts/route15.asm b/scripts/route15.asm index 789ace21..733d4a1c 100755 --- a/scripts/route15.asm +++ b/scripts/route15.asm @@ -9,7 +9,7 @@ Route15Script: ; 597ae (16:57ae) Route15ScriptPointers: ; 597c1 (16:57c1) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route15TextPointers: ; 597c7 (16:57c7) diff --git a/scripts/route16.asm b/scripts/route16.asm index 2e60d77b..59f8cb24 100755 --- a/scripts/route16.asm +++ b/scripts/route16.asm @@ -16,7 +16,7 @@ Route16Script_59946: ; 59946 (16:5946) Route16ScriptPointers: ; 59951 (16:5951) dw Route16Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route16Script3 diff --git a/scripts/route17.asm b/scripts/route17.asm index 78ceb2ae..ffd00634 100755 --- a/scripts/route17.asm +++ b/scripts/route17.asm @@ -9,7 +9,7 @@ Route17Script: ; 55b7a (15:5b7a) Route17ScriptPointers: ; 55b8d (15:5b8d) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route17TextPointers: ; 55b93 (15:5b93) diff --git a/scripts/route18.asm b/scripts/route18.asm index a0e4487a..de2fe19a 100755 --- a/scripts/route18.asm +++ b/scripts/route18.asm @@ -9,7 +9,7 @@ Route18Script: ; 59ac7 (16:5ac7) Route18ScriptPointers: ; 59ada (16:5ada) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route18TextPointers: ; 59ae0 (16:5ae0) diff --git a/scripts/route19.asm b/scripts/route19.asm index 6c749b03..40c7aeb3 100755 --- a/scripts/route19.asm +++ b/scripts/route19.asm @@ -9,7 +9,7 @@ Route19Script: ; 55d44 (15:5d44) Route19ScriptPointers: ; 55d57 (15:5d57) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route19TextPointers: ; 55d5d (15:5d5d) diff --git a/scripts/route20.asm b/scripts/route20.asm index 7e8df3da..47edf376 100755 --- a/scripts/route20.asm +++ b/scripts/route20.asm @@ -58,7 +58,7 @@ Route20Script_50d14: ; 50d14 (14:4d14) Route20ScriptPointers: ; 50d1c (14:4d1c) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route20TextPointers: ; 50d22 (14:4d22) diff --git a/scripts/route21.asm b/scripts/route21.asm index 034282f8..de2046dc 100755 --- a/scripts/route21.asm +++ b/scripts/route21.asm @@ -9,7 +9,7 @@ Route21Script: ; 55eeb (15:5eeb) Route21ScriptPointers: ; 55efe (15:5efe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route21TextPointers: ; 55f04 (15:5f04) diff --git a/scripts/route22.asm b/scripts/route22.asm index 667edd65..233d42c3 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -128,7 +128,7 @@ Route22Script1: ; 50f62 (14:4f62) set 7, [hl] ld hl, Route22RivalDefeatedText1 ld de, Route22Text_511bc - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY1 + $c8 ld [W_CUROPPONENT], a ld hl, StarterMons_50faf ; $4faf @@ -270,7 +270,7 @@ Route22Script4: ; 51087 (14:5087) set 7, [hl] ld hl, Route22RivalDefeatedText2 ; $51cb ld de, Route22Text_511d0 ; $51d0 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a ; wd059 ld hl, StarterMons_510d9 ; $50d9 diff --git a/scripts/route24.asm b/scripts/route24.asm index ea48053b..6916cbe7 100755 --- a/scripts/route24.asm +++ b/scripts/route24.asm @@ -16,7 +16,7 @@ Route24Script_513c0: ; 513c0 (14:53c0) Route24ScriptPointers: ; 513cb (14:53cb) dw Route24Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw Route24Script3 dw Route24Script4 @@ -169,7 +169,7 @@ Route24Text1: ; 514a4 (14:54a4) set 7, [hl] ld hl, Route24Text_5152b ld de, Route24Text_5152b - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [$ff8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/route25.asm b/scripts/route25.asm index 088be3a2..720259ca 100755 --- a/scripts/route25.asm +++ b/scripts/route25.asm @@ -38,7 +38,7 @@ Route25Script_515e1: ; 515e1 (14:55e1) Route25ScriptPointers: ; 51622 (14:5622) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route25TextPointers: ; 51628 (14:5628) diff --git a/scripts/route3.asm b/scripts/route3.asm index 5cd35fd9..acb2afce 100755 --- a/scripts/route3.asm +++ b/scripts/route3.asm @@ -9,7 +9,7 @@ Route3Script: ; 554f8 (15:54f8) Route3ScriptPointers: ; 5550b (15:550b) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route3TextPointers: ; 55511 (15:5511) diff --git a/scripts/route4.asm b/scripts/route4.asm index fa234590..5eafb4f7 100755 --- a/scripts/route4.asm +++ b/scripts/route4.asm @@ -9,7 +9,7 @@ Route4Script: ; 55658 (15:5658) Route4ScriptPointers: ; 5566b (15:566b) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route4TextPointers: ; 55671 (15:5671) diff --git a/scripts/route6.asm b/scripts/route6.asm index 018c1b80..ee6258cd 100755 --- a/scripts/route6.asm +++ b/scripts/route6.asm @@ -9,7 +9,7 @@ Route6Script: ; 590b0 (16:50b0) Route6ScriptPointers: ; 590c3 (16:50c3) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route6TextPointers: ; 590c9 (16:50c9) diff --git a/scripts/route8.asm b/scripts/route8.asm index bf41b5ae..eed57c7b 100755 --- a/scripts/route8.asm +++ b/scripts/route8.asm @@ -9,7 +9,7 @@ Route8Script: ; 591b6 (16:51b6) Route8ScriptPointers: ; 591c9 (16:51c9) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route8TextPointers: ; 591cf (16:51cf) diff --git a/scripts/route9.asm b/scripts/route9.asm index f14abef8..77b216c6 100755 --- a/scripts/route9.asm +++ b/scripts/route9.asm @@ -9,7 +9,7 @@ Route9Script: ; 556bc (15:56bc) Route9ScriptPointers: ; 556cf (15:56cf) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route9TextPointers: ; 556d5 (15:56d5) diff --git a/scripts/saffrongym.asm b/scripts/saffrongym.asm index 39f4df10..7c2eb559 100755 --- a/scripts/saffrongym.asm +++ b/scripts/saffrongym.asm @@ -31,7 +31,7 @@ SaffronGymText_5d048: ; 5d048 (17:5048) SaffronGymScriptPointers: ; 5d053 (17:5053) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SaffronGymScript3 @@ -178,7 +178,7 @@ SaffronGymText1: ; 5d118 (17:5118) set 7, [hl] ld hl, SaffronGymText_5d167 ld de, SaffronGymText_5d167 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/silphco10.asm b/scripts/silphco10.asm index c831655f..7d044aca 100755 --- a/scripts/silphco10.asm +++ b/scripts/silphco10.asm @@ -22,7 +22,7 @@ SilphCo10Script_5a14f: ; 5a14f (16:614f) ld a, $54 ld [wd09f], a ld bc, $405 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5a173: ; 5a173 (16:6173) db $04,$05,$FF @@ -37,7 +37,7 @@ SilphCo10Text_5a176: ; 5a176 (16:6176) SilphCo10ScriptPointers: ; 5a180 (16:6180) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo10TextPointers: ; 5a186 (16:6186) diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index 32a455ec..43ae72f6 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -22,14 +22,14 @@ SilphCo11Script_62110: ; 62110 (18:6110) ld a, $20 ld [wd09f], a ld bc, $603 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_62134: ; 62134 (18:6134) db $06,$03,$FF SilphCo11Script_62137: ; 62137 (18:6137) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -53,7 +53,7 @@ SilphCo11Script_62137: ; 62137 (18:6137) ld a, [hli] cp c jr nz, .asm_62143 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -116,7 +116,7 @@ SilphCo11Script_621c8: ; 621c8 (18:61c8) SilphCo11ScriptPointers: ; 621cf (18:61cf) dw SilphCo11Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SilphCo11Script3 dw SilphCo11Script4 @@ -221,7 +221,7 @@ SilphCo11Script4: ; 62293 (18:6293) set 7, [hl] ld hl, SilphCo10Text_62330 ; $6330 ld de, SilphCo10Text_62330 ; $6330 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/silphco2.asm b/scripts/silphco2.asm index 20d689e6..63803acd 100755 --- a/scripts/silphco2.asm +++ b/scripts/silphco2.asm @@ -23,7 +23,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0202 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_59d2e bit 6, a @@ -31,14 +31,14 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0502 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_59d3e: ; 59d3e (16:5d3e) db $02,$02,$05,$02,$FF SilphCo2Script_59d43: ; 59d43 (16:5d43) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -62,7 +62,7 @@ SilphCo2Script_59d43: ; 59d43 (16:5d43) ld a, [hli] cp c jr nz, .asm_59d4f - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -87,7 +87,7 @@ SilphCo2Script_59d6f: ; 59d6f (16:5d6f) SilphCo2ScriptPointers: ; 59d80 (16:5d80) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo2TextPointers: ; 59d86 (16:5d86) diff --git a/scripts/silphco3.asm b/scripts/silphco3.asm index 5527d923..7b0c67c1 100755 --- a/scripts/silphco3.asm +++ b/scripts/silphco3.asm @@ -23,7 +23,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $404 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_59f98 bit 1, a @@ -31,7 +31,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $408 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_59fa8: ; 59fa8 (16:5fa8) db $04,$04,$04,$08,$FF @@ -51,7 +51,7 @@ SilphCo3Script_59fad: ; 59fad (16:5fad) SilphCo3ScriptPointers: ; 59fbe (16:5fbe) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo3TextPointers: ; 59fc4 (16:5fc4) diff --git a/scripts/silphco4.asm b/scripts/silphco4.asm index 718077ce..15a46dd3 100755 --- a/scripts/silphco4.asm +++ b/scripts/silphco4.asm @@ -23,7 +23,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0602 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19d48 bit 1, a @@ -31,14 +31,14 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0406 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo4Data19d58: ; 19d58 (6:5d58) db $06, $02, $04, $06, $ff SilphCo4Script_19d5d: ; 19d5d (6:5d5d) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -62,7 +62,7 @@ SilphCo4Script_19d5d: ; 19d5d (6:5d5d) ld a, [hli] cp c jr nz, .asm_19d69 ; 0x19d7c $eb - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -87,7 +87,7 @@ SilphCo4Script_19d89: ; 19d89 (6:5d89) SilphCo4ScriptPointers: ; 19d9a (6:5d9a) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo4TextPointers: ; 19da0 (6:5da0) diff --git a/scripts/silphco5.asm b/scripts/silphco5.asm index 709af20b..0b63708b 100755 --- a/scripts/silphco5.asm +++ b/scripts/silphco5.asm @@ -23,7 +23,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0203 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19f74 bit 1, a @@ -32,7 +32,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0603 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_19f87 bit 2, a @@ -40,7 +40,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0507 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo5Coords: ; 19f97 (6:5f97) ; coords? db $02, $03, $06, $03, $05, $07, $ff @@ -65,7 +65,7 @@ SilphCo5Script_19f9e: ; 19f9e (6:5f9e) SilphCo5ScriptPointers: ; 19fb6 (6:5fb6) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo5TextPointers: ; 19fbc (6:5fbc) diff --git a/scripts/silphco6.asm b/scripts/silphco6.asm index 4a9477c6..137e31be 100755 --- a/scripts/silphco6.asm +++ b/scripts/silphco6.asm @@ -22,7 +22,7 @@ SilphCo6Script_1a1bf: ; 1a1bf (6:61bf) ld a, $5f ld [wd09f], a ld bc, $0602 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock SilphCo6Coords1: ; 1a1e3 (6:61e3) db $06, $02 @@ -38,7 +38,7 @@ SilphCo6Script_1a1e6: ; 1a1e6 (6:61e6) SilphCo6ScriptPointers: ; 1a1f0 (6:61f0) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo6TextPointers: ; 1a1f6 (6:61f6) diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index fff1246e..2fc3c51a 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -23,7 +23,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $305 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_51b9e bit 5, a @@ -32,7 +32,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $20a - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_51bb1 bit 6, a @@ -40,14 +40,14 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $60a - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_51bc1: ; 51bc1 (14:5bc1) db $03,$05,$02,$0A,$06,$0A,$FF SilphCo7Text_51bc8: ; 51bc8 (14:5bc8) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -71,7 +71,7 @@ SilphCo7Text_51bc8: ; 51bc8 (14:5bc8) ld a, [hli] cp c jr nz, .asm_51bd4 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -110,7 +110,7 @@ SilphCo7Text_51c10: ; 51c10 (14:5c10) SilphCo7ScriptPointers: ; 51c17 (14:5c17) dw SilphCo7Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw SilphCo7Script3 dw SilphCo7Script4 @@ -177,7 +177,7 @@ SilphCo7Script3: ; 51c82 (14:5c82) set 7, [hl] ld hl, SilphCo7Text14 ; $5ec8 ld de, SilphCo7Text_51ecd ; $5ecd - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ld a, SONY2 + $c8 ld [W_CUROPPONENT], a ; wd059 ld a, [W_RIVALSTARTER] ; wd715 diff --git a/scripts/silphco8.asm b/scripts/silphco8.asm index cc508e61..ebca9b95 100755 --- a/scripts/silphco8.asm +++ b/scripts/silphco8.asm @@ -22,14 +22,14 @@ SilphCo8Script_5651a: ; 5651a (15:651a) ld a, $5f ld [wd09f], a ld bc, $403 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5653e: ; 5653e (15:653e) db $04,$03,$FF SilphCo8Script_56541: ; 56541 (15:6541) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -53,7 +53,7 @@ SilphCo8Script_56541: ; 56541 (15:6541) ld a, [hli] cp c jr nz, .asm_5654d - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -73,7 +73,7 @@ SilphCo8Script_5656d: ; 5656d (15:656d) SilphCo8ScriptPointers: ; 56577 (15:6577) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo8TextPointers: ; 5657d (15:657d) diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm index 44059b56..e8b16927 100755 --- a/scripts/silphco9.asm +++ b/scripts/silphco9.asm @@ -23,7 +23,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $401 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d7f8 bit 1, a @@ -32,7 +32,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $209 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d80b bit 2, a @@ -41,7 +41,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $509 - predef Func_ee9e + predef ReplaceTileBlock pop af .asm_5d81e bit 3, a @@ -49,14 +49,14 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $605 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock DataTable_5d82e: ; 5d82e (17:582e) db $04,$01,$02,$09,$05,$09,$06,$05,$FF SilphCo9Script_5d837: ; 5d837 (17:5837) push hl - ld hl, wd73f + ld hl, wCardKeyDoorY ld a, [hli] ld b, a ld a, [hl] @@ -80,7 +80,7 @@ SilphCo9Script_5d837: ; 5d837 (17:5837) ld a, [hli] cp c jr nz, .asm_5d843 - ld hl, wd73f + ld hl, wCardKeyDoorY xor a ld [hli], a ld [hl], a @@ -117,7 +117,7 @@ SilphCo9Script_5d863: ; 5d863 (17:5863) SilphCo9ScriptPointers: ; 5d885 (17:5885) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SilphCo9TextPointers: ; 5d88b (17:588b) diff --git a/scripts/ssanne10.asm b/scripts/ssanne10.asm index 60eb28f2..8f3ff9a4 100755 --- a/scripts/ssanne10.asm +++ b/scripts/ssanne10.asm @@ -9,7 +9,7 @@ SSAnne10Script: ; 61d55 (18:5d55) SSAnne10ScriptPointers: ; 61d68 (18:5d68) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne10TextPointers: ; 61d6e (18:5d6e) diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index 50deba65..c5943a54 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -186,7 +186,7 @@ SSAnne2Text2: ; 614e6 (18:54e6) set 7, [hl] ld hl, SSAnneRivalDefeatedText ld de, SSAnneRivalWonText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers jp TextScriptEnd SSAnneRivalBeforeBattleText: ; 61500 (18:5500) diff --git a/scripts/ssanne5.asm b/scripts/ssanne5.asm index ea7ff282..96b94c52 100755 --- a/scripts/ssanne5.asm +++ b/scripts/ssanne5.asm @@ -9,7 +9,7 @@ SSAnne5Script: ; 616ae (18:56ae) SSAnne5ScriptPointers: ; 616c1 (18:56c1) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne5TextPointers: ; 616c7 (18:56c7) diff --git a/scripts/ssanne8.asm b/scripts/ssanne8.asm index a2abb4bb..ff7fc57b 100755 --- a/scripts/ssanne8.asm +++ b/scripts/ssanne8.asm @@ -9,7 +9,7 @@ SSAnne8Script: ; 61976 (18:5976) SSAnne8ScriptPointers: ; 61989 (18:5989) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne8TextPointers: ; 6198f (18:598f) diff --git a/scripts/ssanne9.asm b/scripts/ssanne9.asm index f25d5532..db34fcf2 100755 --- a/scripts/ssanne9.asm +++ b/scripts/ssanne9.asm @@ -12,7 +12,7 @@ SSAnne9Script: ; 61b4b (18:5b4b) SSAnne9ScriptPointers: ; 61b64 (18:5b64) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle SSAnne9TextPointers: ; 61b6a (18:5b6a) diff --git a/scripts/unknowndungeon3.asm b/scripts/unknowndungeon3.asm index 2ca624a8..d2078916 100755 --- a/scripts/unknowndungeon3.asm +++ b/scripts/unknowndungeon3.asm @@ -9,7 +9,7 @@ UnknownDungeon3Script: ; 45ef0 (11:5ef0) UnknownDungeon3ScriptPointers: ; 45f03 (11:5f03) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle UnknownDungeon3TextPointers: ; 45f09 (11:5f09) diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index 6ed2d23d..dca1c66c 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -66,7 +66,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld [$ff49], a ld a, $58 ld [wTrainerEngageDistance], a - ld hl, wd526 + ld hl, wMapViewVRAMPointer ld c, [hl] inc hl ld b, [hl] @@ -82,9 +82,9 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld hl, $0002 add hl, bc ld a, l - ld [wd526], a + ld [wMapViewVRAMPointer], a ld a, h - ld [wd527], a + ld [wMapViewVRAMPointer + 1], a push hl push de call ScheduleEastColumnRedraw diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index 685bd2cb..6178dafb 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -40,7 +40,7 @@ VermilionGymScript_5ca6d: ; 5ca6d (17:4a6d) .asm_5ca7f ld [wd09f], a ld bc, $202 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a) xor a @@ -51,7 +51,7 @@ VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a) VermilionGymScriptPointers: ; 5ca95 (17:4a95) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw VermilionGymScript3 @@ -156,7 +156,7 @@ VermilionGymText1: ; 5cb1d (17:4b1d) set 7, [hl] ld hl, ReceivedThunderbadgeText ld de, ReceivedThunderbadgeText - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/scripts/victoryroad1.asm b/scripts/victoryroad1.asm index cebd8070..b6d2bf3e 100755 --- a/scripts/victoryroad1.asm +++ b/scripts/victoryroad1.asm @@ -17,11 +17,11 @@ VictoryRoad1Script: ; 5da0a (17:5a0a) ld a, $1d ld [wd09f], a ld bc, $604 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VictoryRoad1ScriptPointers: ; 5da3a (17:5a3a) dw VictoryRoad1Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad1Script0: ; 5da40 (17:5a40) diff --git a/scripts/victoryroad2.asm b/scripts/victoryroad2.asm index cf52e3a3..4aab61ca 100755 --- a/scripts/victoryroad2.asm +++ b/scripts/victoryroad2.asm @@ -36,12 +36,12 @@ VictoryRoad2Script_517c9: ; 517c9 (14:57c9) VictoryRoad2Script_517e2: ; 517e2 (14:57e2) ld [wd09f], a - predef Func_ee9e + predef ReplaceTileBlock ret VictoryRoad2ScriptPointers: ; 517eb (14:57eb) dw VictoryRoad2Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad2Script0: ; 517f1 (14:57f1) diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index e7d5ed12..99926498 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -19,11 +19,11 @@ VictoryRoad3Script_44996: ; 44996 (11:4996) ld a, $1d ld [wd09f], a ld bc, $503 - predef_jump Func_ee9e + predef_jump ReplaceTileBlock VictoryRoad3ScriptPointers: ; 449b1 (11:49b1) dw VictoryRoad3Script0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle VictoryRoad3Script0: ; 449b7 (11:49b7) diff --git a/scripts/viridianforest.asm b/scripts/viridianforest.asm index 3744fc78..4ec1c0aa 100755 --- a/scripts/viridianforest.asm +++ b/scripts/viridianforest.asm @@ -9,7 +9,7 @@ ViridianForestScript: ; 6110d (18:510d) ViridianForestScriptPointers: ; 61120 (18:5120) dw CheckFightingMapTrainers - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle ViridianForestTextPointers: ; 61126 (18:5126) diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index 6b0673d1..3aa23b43 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -24,7 +24,7 @@ ViridianGymScript_748d6: ; 748d6 (1d:48d6) ViridianGymScriptPointers: ; 748e1 (1d:48e1) dw ViridianGymScript0 - dw Func_324c + dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle dw ViridianGymScript3 dw ViridianGymScript4 @@ -35,7 +35,7 @@ ViridianGymScript0: ; 748eb (1d:48eb) ld a, [W_XCOORD] ; wd362 ld c, a ld hl, ViridianGymArrowTilePlayerMovement - call Func_3442 + call DecodeArrowMovementRLE cp $ff jp z, CheckFightingMapTrainers call StartSimulatingJoypadStates @@ -305,7 +305,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) set 7, [hl] ld hl, ViridianGymText_74ad3 ld de, ViridianGymText_74ad3 - call PreBattleSaveRegisters + call SaveEndBattleTextPointers ldh a, [$8c] ld [wSpriteIndex], a call EngageMapTrainer diff --git a/wram.asm b/wram.asm index a9bad081..15c339d1 100755 --- a/wram.asm +++ b/wram.asm @@ -500,15 +500,18 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b ds 1 +wChangeBoxSavedMapTextPointer:: ; cd3d + wFlyAnimUsingCoordList:: ; cd3d wPlayerSpinInPlaceAnimFrameDelay:: ; cd3d wPlayerSpinWhileMovingUpOrDownAnimDeltaY:: ; cd3d +wHiddenObjectFunctionArgument:: ; cd3d + wWhichTrade:: ; cd3d ; which entry from TradeMons to select -; ds 1 wTrainerSpriteOffset:: ; cd3d ds 1 @@ -519,6 +522,8 @@ wPlayerSpinInPlaceAnimFrameDelayDelta:: ; cd3e wPlayerSpinWhileMovingUpOrDownAnimMaxY:: ; cd3e +wHiddenObjectFunctionRomBank:: ; cd3e + wTrainerEngageDistance:: ; cd3e ds 1 @@ -528,14 +533,21 @@ wPlayerSpinInPlaceAnimFrameDelayEndValue:: ; cd3f wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: ; cd3f +wHiddenObjectIndex:: ; cd3f + wTrainerFacingDirection:: ; cd3f wcd3f:: ds 1 wPlayerSpinInPlaceAnimSoundID:: ; cd40 +wHiddenObjectY:: ; cd40 + wTrainerScreenY:: ; cd40 ds 1 + +wHiddenObjectX:: ; cd40 + wTrainerScreenX:: ; cd41 ds 1 @@ -992,6 +1004,8 @@ W_NUMFBTILES:: ; d089 wd08a:: ds 1 +wTownMapSpriteBlinkingCounter:: ; d08b + W_SUBANIMTRANSFORM:: ; d08b ; controls what transformations are applied to the subanimation ; 01: flip horizontally and vertically @@ -1000,18 +1014,15 @@ W_SUBANIMTRANSFORM:: ; d08b ; 04: reverse the subanimation ds 1 -W_PBSTOREDREGISTERH:: ; d08c - ds 1 -W_PBSTOREDREGISTERL:: ; d08d - ds 1 -W_PBSTOREDREGISTERD:: ; d08e - ds 1 -W_PBSTOREDREGISTERE:: ; d08f - ds 1 +wEndBattleWinTextPointer:: ; d08c + ds 2 + +wEndBattleLoseTextPointer:: ; d08e + ds 2 ds 2 -W_PBSTOREDROMBANK:: ; d092 +wEndBattleTextRomBank:: ; d092 ds 1 ds 1 @@ -1026,6 +1037,11 @@ W_SUBANIMSUBENTRYADDR:: ; d096 ds 2 wd09a:: ds 1 + +wTownMapSpriteBlinkingEnabled:: ; d09b +; non-zero when enabled. causes nest locations to blink on and off. +; the town selection cursor will blink regardless of what this value is + wd09b:: ds 1 W_FBDESTADDR:: ; d09c @@ -1044,6 +1060,8 @@ W_FBMODE:: ; d09e ; contain the upper and lower bit of each of the 8 pixels, respectively ds 1 +wNewTileBlockID:: ; d09f + wd09f:: ds 1 wd0a0:: ds 1 @@ -1200,7 +1218,11 @@ wd131:: ds 1 wd132:: ds 1 wd133:: ds 6 wd139:: ds 1 -wd13a:: ds 1 + +wIgnoreInputCounter:: ; d13a +; counts downward each frame +; when it hits 0, bit 5 (ignore input bit) of wd730 is reset + ds 1 wStepCounter:: ; d13b ; counts down once every step @@ -1458,8 +1480,11 @@ W_MAPSPRITEEXTRADATA:: ; d504 wd524:: ds 1 wd525:: ds 1 -wd526:: ds 1 -wd527:: ds 1 + +wMapViewVRAMPointer:: ; d526 +; the address of the upper left corner of the visible portion of the BG tile map in VRAM + ds 2 + wd528:: ds 1 wd529:: ds 1 wd52a:: ds 1 @@ -1816,6 +1841,9 @@ wd72d:: ds 1 wd72e:: ds 2 wd730:: +; bit 0: NPC sprite being moved by script +; bit 5: ignore joypad input +; bit 6: print text with no delay between each letter ; bit 7: set if joypad states are being simulated in the overworld ds 1 @@ -1844,6 +1872,7 @@ wd734:: ds 2 wd736:: ; d736 ; bit 0: check if the player is standing on a door and make him walk down a step if so +; bit 1: the player is currently stepping down from a door ; bit 2: standing on a warp ; bit 6: jumping down a ledge ds 1 @@ -1851,8 +1880,15 @@ wd736:: ; d736 wd737:: ds 4 wd73b:: ds 1 wd73c:: ds 3 -wd73f:: ds 1 -wd740:: ds 3 + +wCardKeyDoorY:: ; d73f + ds 1 + +wCardKeyDoorX:: ; d740 + ds 1 + + ds 2 + wd743:: ds 1 wd744:: ds 3 wd747:: ds 3 @@ -2028,7 +2064,8 @@ W_PLAYTIMESECONDS:: ; da44 W_PLAYTIMEFRAMES:: ; da45 ds 1 -wda46:: ds 1 +wSafariZoneGameOver:: ; da46 + ds 1 W_NUMSAFARIBALLS:: ; da47 ds 1 -- cgit v1.3.1-sl0p