diff options
Diffstat (limited to 'engine')
40 files changed, 1029 insertions, 947 deletions
diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 98c77903..77a07ea3 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -6,10 +6,10 @@ HallOfFamePC: ; 7405c (1d:405c) call DisableLCD ld hl, vFont ld bc, $800 / 2 - call Func_74171 + call ZeroMemory ld hl, vChars2 + $600 ld bc, $200 / 2 - call Func_74171 + call ZeroMemory ld hl, vChars2 + $7e0 ld bc, $10 ld a, $ff @@ -30,12 +30,12 @@ HallOfFamePC: ; 7405c (1d:405c) call DelayFrames xor a ld [wWhichTrade], a - ld [wTrainerEngageDistance], a + ld [wNumCreditsMonsDisplayed], a jp Credits -Func_740ba: ; 740ba (1d:40ba) +FadeInCreditsText: ; 740ba (1d:40ba) ld hl, HoFGBPalettes - ld b, $4 + ld b, 4 .asm_740bf ld a, [hli] ld [rBGP], a @@ -52,7 +52,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb) call FillMiddleOfScreenWithWhite ; display the next monster from CreditsMons - ld hl,wTrainerEngageDistance + ld hl,wNumCreditsMonsDisplayed ld c,[hl] ; how many monsters have we displayed so far? inc [hl] ld b,0 @@ -65,62 +65,69 @@ DisplayCreditsMon: ; 740cb (1d:40cb) call GetMonHeader call LoadFrontSpriteByMonIndex ld hl,vBGMap0 + $c - call Func_74164 + call CopyTileMapToVRAM xor a ld [H_AUTOBGTRANSFERENABLED],a call LoadScreenTilesFromBuffer1 ld hl,vBGMap0 - call Func_74164 + call CopyTileMapToVRAM ld a,$A7 - ld [$FF4B],a + ld [rWX],a ld hl,vBGMap1 - call Func_74164 + call CopyTileMapToVRAM call FillMiddleOfScreenWithWhite - ld a,$FC + ld a,%11111100 ; make the mon a black silhouette ld [rBGP],a + +; scroll the mon left by one tile 7 times ld bc,7 -.next - call Func_74140 +.scrollLoop1 + call ScrollCreditsMonLeft dec c - jr nz,.next - ld c,$14 -.next2 - call Func_74140 - ld a,[$FF4B] + jr nz,.scrollLoop1 + +; scroll the mon left by one tile 20 times +; This time, we have to move the window left too in order to hide the text that +; is wrapping around to the right side of the screen. + ld c,20 +.scrollLoop2 + call ScrollCreditsMonLeft + ld a,[rWX] sub 8 - ld [$FF4B],a + ld [rWX],a dec c - jr nz,.next2 + jr nz,.scrollLoop2 + xor a ld [hWY],a - ld a,$C0 + ld a,%11000000 ld [rBGP],a ret INCLUDE "data/credit_mons.asm" -Func_74140: ; 74140 (1d:4140) +ScrollCreditsMonLeft: ; 74140 (1d:4140) ld h, b ld l, $20 - call Func_74152 + call ScrollCreditsMonLeft_SetSCX ld h, $0 ld l, $70 - call Func_74152 + call ScrollCreditsMonLeft_SetSCX ld a, b add $8 ld b, a ret -Func_74152: ; 74152 (1d:4152) - ld a, [$ff44] +ScrollCreditsMonLeft_SetSCX: ; 74152 (1d:4152) + ld a, [rLY] cp l - jr nz, Func_74152 + jr nz, ScrollCreditsMonLeft_SetSCX ld a, h ld [rSCX], a -.asm_7415a - ld a, [$ff44] +.loop + ld a, [rLY] cp h - jr z, .asm_7415a + jr z, .loop ret HoFGBPalettes: ; 74160 (1d:4160) @@ -129,7 +136,7 @@ HoFGBPalettes: ; 74160 (1d:4160) db %11100000 db %11110000 -Func_74164: ; 74164 (1d:4164) +CopyTileMapToVRAM: ; 74164 (1d:4164) ld a, l ld [H_AUTOBGTRANSFERDEST], a ld a, h @@ -138,14 +145,15 @@ Func_74164: ; 74164 (1d:4164) ld [H_AUTOBGTRANSFERENABLED], a jp Delay3 -Func_74171: ; 74171 (1d:4171) - ld [hl], $0 +ZeroMemory: ; 74171 (1d:4171) +; zero bc bytes at hl + ld [hl], 0 inc hl inc hl dec bc ld a, b or c - jr nz, Func_74171 + jr nz, ZeroMemory ret FillFourRowsWithBlack: ; 7417b (1d:417b) @@ -162,26 +170,26 @@ FillMiddleOfScreenWithWhite: ; 74183 (1d:4183) Credits: ; 7418e (1d:418e) ld de, CreditsOrder push de -.asm_74192 +.nextCreditsScreen pop de hlCoord 9, 6 push hl call FillMiddleOfScreenWithWhite pop hl -.asm_7419b +.nextCreditsCommand ld a, [de] inc de push de cp $ff - jr z, .asm_741d5 + jr z, .fadeInTextAndShowMon cp $fe - jr z, .asm_741dc + jr z, .showTextAndShowMon cp $fd - jr z, .asm_741e6 + jr z, .fadeInText cp $fc - jr z, .asm_741ed + jr z, .showText cp $fb - jr z, .asm_741f4 + jr z, .showCopyrightText cp $fa jr z, .showTheEnd push hl @@ -189,7 +197,7 @@ Credits: ; 7418e (1d:418e) ld hl, CreditsTextPointers add a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld e, [hl] inc hl @@ -205,32 +213,32 @@ Credits: ; 7418e (1d:418e) ld bc, SCREEN_WIDTH * 2 add hl, bc pop de - jr .asm_7419b -.asm_741d5 - call Func_740ba + jr .nextCreditsCommand +.fadeInTextAndShowMon + call FadeInCreditsText ld c, 90 - jr .asm_741de -.asm_741dc + jr .next1 +.showTextAndShowMon ld c, 110 -.asm_741de +.next1 call DelayFrames call DisplayCreditsMon - jr .asm_74192 -.asm_741e6 - call Func_740ba + jr .nextCreditsScreen +.fadeInText + call FadeInCreditsText ld c, 120 - jr .asm_741ef -.asm_741ed + jr .next2 +.showText ld c, 140 -.asm_741ef +.next2 call DelayFrames - jr .asm_74192 -.asm_741f4 + jr .nextCreditsScreen +.showCopyrightText push de callba LoadCopyrightTiles pop de pop de - jr .asm_7419b + jr .nextCreditsCommand .showTheEnd ld c, 16 call DelayFrames @@ -246,7 +254,7 @@ Credits: ; 7418e (1d:418e) hlCoord 4, 9 inc de call PlaceString - jp Func_740ba + jp FadeInCreditsText TheEndTextString: ; 74229 (1d:4229) ; "T H E E N D" diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 32f98f19..63ea170d 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1973,7 +1973,7 @@ AnimationWavyScreen: ; 79666 (1e:5666) push hl .asm_79680 call Func_796ae - ld a, [$ff44] + ld a, [rLY] cp e jr nz, .asm_79680 pop hl @@ -2500,27 +2500,29 @@ CopyPicTiles: ; 79aae (1e:5aae) ld a, [H_WHOSETURN] and a ld a, $31 ; base tile ID of player mon sprite - jr z, .asm_79ab6 + jr z, .next ; enemy turn xor a ; base tile ID of enemy mon sprite -.asm_79ab6 +.next ld [hBaseTileID], a - jr asm_79acb + jr CopyTileIDs_NoBGTransfer -; copy the tiles used when a mon is being sent out -; and "growing" out of the pokeball -CopyGrowingMonTiles: ; 79aba (1e:5aba) +; copy the tiles used when a mon is being sent out of or into a pokeball +CopyDownscaledMonTiles: ; 79aba (1e:5aba) call GetPredefRegisters - ld a, [wcd6c] + ld a, [wDownscaledMonSize] and a - jr nz, .asm_79ac8 - ld de, Unknown_79b02 ; 5x5 - jr asm_79acb -.asm_79ac8 - ld de, Unknown_79b1b ; 3x3 -asm_79acb: ; 79acb (1e:5acb) + jr nz, .smallerSize + ld de, DownscaledMonTiles_5x5 + jr CopyTileIDs_NoBGTransfer +.smallerSize + ld de, DownscaledMonTiles_3x3 +; fall through + +CopyTileIDs_NoBGTransfer: ; 79acb (1e:5acb) xor a ld [H_AUTOBGTRANSFERENABLED], a +; fall through ; b = number of rows ; c = number of columns @@ -2567,14 +2569,14 @@ TileIDListPointerTable: ; 79aea (1e:5aea) dw Unknown_79c50 db $3C -Unknown_79b02: ; 79b02 (1e:5b02) +DownscaledMonTiles_5x5: ; 79b02 (1e:5b02) db $31,$38,$46,$54,$5B db $32,$39,$47,$55,$5C db $34,$3B,$49,$57,$5E db $36,$3D,$4B,$59,$60 db $37,$3E,$4C,$5A,$61 -Unknown_79b1b: ; 79b1b (1e:5b1b) +DownscaledMonTiles_3x3: ; 79b1b (1e:5b1b) db $31,$46,$5B db $34,$49,$5E db $37,$4C,$61 diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm index 2f3944e9..f47087d8 100755 --- a/engine/battle/bank_e_misc.asm +++ b/engine/battle/bank_e_misc.asm @@ -24,7 +24,7 @@ FormatMovesString: ; 39b87 (e:5b87) jr .copyNameLoop .doneCopyingName ld a, b - ld [wcd6c], a + ld [wNumMovesMinusOne], a inc b ld a, $4e ; line break ld [de], a @@ -70,7 +70,7 @@ InitList: ; 39bd5 (e:5bd5) .notPlayer cp INIT_MON_LIST jr nz, .notMonster - ld hl, wStringBuffer2 + 11 + ld hl, wItemList ld de, MonsterNames ld a, MONSTER_NAME jr .done @@ -82,15 +82,15 @@ InitList: ; 39bd5 (e:5bd5) ld a, ITEM_NAME jr .done .notBag - ld hl, wStringBuffer2 + 11 + ld hl, wItemList ld de, ItemNames ld a, ITEM_NAME .done ld [wNameListType], a ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a ld a, e ld [wcf8d], a ld a, d @@ -102,10 +102,10 @@ InitList: ; 39bd5 (e:5bd5) ld [wItemPrices + 1], a ret -; get species of mon e in list [wcc49] for LoadMonData +; get species of mon e in list [wMonDataLocation] for LoadMonData GetMonSpecies: ; 39c37 (e:5c37) ld hl, wPartySpecies - ld a, [wcc49] + ld a, [wMonDataLocation] and a jr z, .getSpecies dec a diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 8613560a..997f23ef 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -104,12 +104,12 @@ GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef) jr nc, .highLevelEnemy res 1, c ld a, $1 - ld [wcd47], a + ld [wBattleTransitionSpiralDirection], a ret .highLevelEnemy set 1, c xor a - ld [wcd47], a + ld [wBattleTransitionSpiralDirection], a ret ; fails to recognize VICTORY_ROAD_2, VICTORY_ROAD_3, all ROCKET_HIDEOUT maps, @@ -196,7 +196,7 @@ BattleTransition_BlackScreen: ; 70a69 (1c:4a69) ; outward spiral if enemy is at least 3 levels ; higher than player and does an inward spiral otherwise BattleTransition_Spiral: ; 70a72 (1c:4a72) - ld a, [wcd47] + ld a, [wBattleTransitionSpiralDirection] and a jr z, .outwardSpiral call BattleTransition_InwardSpiral diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 5ef94998..bdb20bb0 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -225,7 +225,7 @@ StartBattle: ; 3c11e (f:411e) xor a ld [wPartyGainExpFlags], a ld [wPartyFoughtCurrentEnemyFlags], a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a inc a ld [wd11d], a ld hl, wEnemyMon1HP @@ -260,7 +260,7 @@ StartBattle: ; 3c11e (f:411e) .displaySafariZoneBattleMenu call DisplayBattleMenu ret c ; return if the player ran from battle - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a ; was the item used successfully? jr z, .displaySafariZoneBattleMenu ; if not, display the menu again; XXX does this ever jump? ld a, [W_NUMSAFARIBALLS] @@ -415,8 +415,8 @@ MainInBattleLoop: ; 3c233 (f:4233) ld [wPlayerSelectedMove], a jr .selectEnemyMove .selectPlayerMove - ld a, [wcd6a] - and a + ld a, [wActionResultOrTookBattleTurn] + and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon) jr nz, .selectEnemyMove ld [wMoveMenuType], a inc a @@ -816,11 +816,11 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) call ChooseNextMon .skipReplacingBattleMon ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ReplaceFaintedEnemyMon jp z, EnemyRan xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a jp MainInBattleLoop FaintEnemyPokemon: ; 0x3c567 @@ -990,7 +990,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664) call EnemySendOut xor a ld [W_ENEMYMOVENUM], a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld [wAILayer2Encouragement], a inc a ; reset Z flag ret @@ -1075,11 +1075,11 @@ HandlePlayerMonFainted: ; 3c700 (f:4700) jp nz, MainInBattleLoop ; if the enemy mon has more than 0 HP, go back to battle loop ; the enemy mon has 0 HP ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ReplaceFaintedEnemyMon jp z, EnemyRan ; if enemy ran from battle rather than sending out another mon, jump xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a jp MainInBattleLoop ; resets flags, slides mon's pic down, plays cry, and prints fainted message @@ -1177,11 +1177,11 @@ ChooseNextMon: ; 3c7d8 (f:47d8) cp LINK_STATE_BATTLING jr nz, .notLinkBattle inc a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call LinkBattleExchangeData .notLinkBattle xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call ClearSprites ld a, [wWhichPokemon] ld [wPlayerMonNumber], a @@ -1646,7 +1646,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ; plus 30 times the number of attempts, the player can escape ; can't escape ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ; you lose your turn when you can't escape ld hl, CantEscapeText jr .printCantEscapeOrNoRunningText .trainerBattle @@ -1666,7 +1666,7 @@ TryRunningFromBattle: ; 3cab9 (f:4ab9) ; link battle call SaveScreenTilesToBuffer1 xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld a, $f ld [wPlayerMoveListIndex], a call LinkBattleExchangeData @@ -1809,7 +1809,7 @@ SendOutMon: ; 3cc91 (f:4c91) predef LoadMonBackPic xor a ld [$ffe1], a - ld hl, wcc2d + ld hl, wBattleAndStartSavedMenuItem ld [hli], a ld [hl], a ld [wBoostExpByExpAll], a @@ -1842,7 +1842,7 @@ SendOutMon: ; 3cc91 (f:4c91) call PrintEmptyString jp SaveScreenTilesToBuffer1 -; show 2 stages of the player getting smaller before disappearing +; show 2 stages of the player mon getting smaller before disappearing AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa) hlCoord 1, 5 ld bc, $707 @@ -1850,19 +1850,19 @@ AnimateRetreatingPlayerMon: ; 3ccfa (f:4cfa) hlCoord 3, 7 ld bc, $505 xor a - ld [wcd6c], a + ld [wDownscaledMonSize], a ld [H_DOWNARROWBLINKCNT1], a - predef CopyGrowingMonTiles + predef CopyDownscaledMonTiles ld c, 4 call DelayFrames call .clearScreenArea hlCoord 4, 9 ld bc, $303 ld a, $1 - ld [wcd6c], a + ld [wDownscaledMonSize], a xor a ld [H_DOWNARROWBLINKCNT1], a - predef CopyGrowingMonTiles + predef CopyDownscaledMonTiles call Delay3 call .clearScreenArea ld a, $4c @@ -2123,7 +2123,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .oldManName db "OLD MAN@" .handleBattleMenuInput - ld a, [wcc2d] + ld a, [wBattleAndStartSavedMenuItem] ld [wCurrentMenuItem], a ld [wLastMenuItem], a sub 2 ; check if the cursor is in the left column @@ -2206,7 +2206,7 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) ld a, [W_BATTLETYPE] cp $2 ; is it a Safari battle? ld a, [wCurrentMenuItem] - ld [wcc2d], a + ld [wBattleAndStartSavedMenuItem], a jr z, .handleMenuSelection ; not Safari battle ; swap the IDs of the item menu and party menu (this is probably because they swapped the positions @@ -2276,9 +2276,9 @@ BagWasSelected: jr nz, DisplayPlayerBag ; no, it is a normal battle ld hl, OldManItemList ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a jr DisplayBagMenu OldManItemList: @@ -2290,20 +2290,20 @@ DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle ld hl, wNumBagItems ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a DisplayBagMenu: xor a ld [wPrintItemPrices], a ld a, ITEMLISTMENU ld [wListMenuID], a - ld a, [wcc2c] + ld a, [wBagSavedMenuItem] ld [wCurrentMenuItem], a call DisplayListMenuID ld a, [wCurrentMenuItem] - ld [wcc2c], a + ld [wBagSavedMenuItem], a ld a, $0 ld [wMenuWatchMovingOutOfBounds], a ld [wMenuItemToSwap], a @@ -2326,7 +2326,7 @@ UseBagItem: cp $2 ; is it a safari battle? jr z, .checkIfMonCaptured - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a ; was the item used successfully? jp z, BagWasSelected ; if not, go back to the bag menu @@ -2435,8 +2435,8 @@ PartyMenuOrRockOrRun: and a ; was Switch selected? jr z, .switchMon ; if so, jump ; Stats was selected - xor a - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a ld hl, wPartyMon1 call ClearSprites ; display the two status screens @@ -2479,7 +2479,7 @@ PartyMenuOrRockOrRun: call HasMonFainted jp z, .partyMonDeselected ; can't switch to fainted mon ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a call GBPalWhiteOut call ClearSprites call LoadHudTilePatterns @@ -2525,9 +2525,9 @@ BattleMenu_RunWasSelected: ; 3d1fa (f:51fa) ld a, $0 ld [wd11f], a ret c - ld a, [wcd6a] + ld a, [wActionResultOrTookBattleTurn] and a - ret nz + ret nz ; return if the player couldn't escape jp DisplayBattleMenu MoveSelectionMenu: ; 3d219 (f:5219) @@ -2604,9 +2604,9 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld a, $7 .menuset ld hl, wTopMenuItemY - ld [hli], a + ld [hli], a ; wTopMenuItemY ld a, b - ld [hli], a + ld [hli], a ; wTopMenuItemX ld a, [wMoveMenuType] cp $1 jr z, .selectedmoveknown @@ -2615,30 +2615,30 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld a, [wPlayerMoveListIndex] inc a .selectedmoveknown - ld [hli], a + ld [hli], a ; wCurrentMenuItem inc hl ; wTileBehindCursor untouched - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a inc a - ld [hli], a + ld [hli], a ; wMaxMenuItem ld a, [wMoveMenuType] dec a - ld b, $c1 ; can't use B + ld b, D_UP | D_DOWN | A_BUTTON jr z, .matchedkeyspicked dec a - ld b, $c3 + ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON jr z, .matchedkeyspicked ld a, [wLinkState] cp LINK_STATE_BATTLING jr z, .matchedkeyspicked ld a, [W_FLAGS_D733] bit 0, a - ld b, $c7 + ld b, D_UP | D_DOWN | A_BUTTON | B_BUTTON | SELECT jr z, .matchedkeyspicked ld b, $ff .matchedkeyspicked ld a, b - ld [hli], a + ld [hli], a ; wMenuWatchedKeys ld a, [wMoveMenuType] cp $1 jr z, .movelistindex1 @@ -2759,7 +2759,7 @@ CursorUp: ; 3d3c9 (f:53c9) and a jp nz, SelectMenuItem call EraseMenuCursor - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a ld [wCurrentMenuItem], a jp SelectMenuItem @@ -2767,7 +2767,7 @@ CursorUp: ; 3d3c9 (f:53c9) CursorDown: ; 3d3dd (f:53dd) ld a, [wCurrentMenuItem] ld b, a - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a inc a cp b @@ -2935,8 +2935,8 @@ PrintMenuItem: ; 3d4b6 (f:54b6) ; isn't actually selected (just pointed to by the cursor) ld a, [wPlayerMonNumber] ld [wWhichPokemon], a - ld a, $4 - ld [wcc49], a + ld a, BATTLE_MON_DATA + ld [wMonDataLocation], a callab GetMaxPP ld hl, wCurrentMenuItem ld c, [hl] @@ -2983,7 +2983,7 @@ TypeText: ; 3d55f (f:555f) SelectEnemyMove: ; 3d564 (f:5564) ld a, [wLinkState] - sub $4 + sub LINK_STATE_BATTLING jr nz, .noLinkBattle ; link battle call SaveScreenTilesToBuffer1 @@ -3079,46 +3079,47 @@ LinkBattleExchangeData: ; 3d605 (f:5605) ld [wSerialExchangeNybbleReceiveData], a ld a, [wPlayerMoveListIndex] cp $f ; is the player running from battle? - jr z, .asm_3d630 - ld a, [wcd6a] - and a - jr nz, .asm_3d629 + jr z, .doExchange + ld a, [wActionResultOrTookBattleTurn] + and a ; is the player switching in another mon? + jr nz, .switching +; the player used a move ld a, [wPlayerSelectedMove] cp STRUGGLE ld b, $e - jr z, .asm_3d62f + jr z, .next dec b inc a - jr z, .asm_3d62f + jr z, .next ld a, [wPlayerMoveListIndex] - jr .asm_3d630 -.asm_3d629 + jr .doExchange +.switching ld a, [wWhichPokemon] - add $4 + add 4 ld b, a -.asm_3d62f +.next ld a, b -.asm_3d630 +.doExchange ld [wSerialExchangeNybbleSendData], a callab PrintWaitingText -.asm_3d63b +.syncLoop1 call Serial_ExchangeNybble call DelayFrame ld a, [wSerialExchangeNybbleReceiveData] inc a - jr z, .asm_3d63b - ld b, $a -.asm_3d649 + jr z, .syncLoop1 + ld b, 10 +.syncLoop2 call DelayFrame call Serial_ExchangeNybble dec b - jr nz, .asm_3d649 - ld b, $a -.asm_3d654 + jr nz, .syncLoop2 + ld b, 10 +.syncLoop3 call DelayFrame call Serial_SendZeroByte dec b - jr nz, .asm_3d654 + jr nz, .syncLoop3 ret ExecutePlayerMove: ; 3d65e (f:565e) @@ -3133,8 +3134,8 @@ ExecutePlayerMove: ; 3d65e (f:565e) ld [wMoveDidntMiss], a ld a, $a ld [wDamageMultipliers], a - ld a, [wcd6a] - and a + ld a, [wActionResultOrTookBattleTurn] + and a ; has the player already used the turn (e.g. by using an item, trying to run or switching pokemon) jp nz, ExecutePlayerMoveDone call PrintGhostText jp z, ExecutePlayerMoveDone @@ -3324,7 +3325,7 @@ MultiHitText: ; 3d805 (f:5805) ExecutePlayerMoveDone: ; 3d80a (f:580a) xor a - ld [wcd6a],a + ld [wActionResultOrTookBattleTurn],a ld b,1 ret @@ -6856,7 +6857,7 @@ DetermineWildOpponent: ; 3ef23 (f:6f23) InitBattleCommon: ; 3ef3d (f:6f3d) ld a, [wMapPalOffset] push af - ld hl, wd358 + ld hl, wLetterPrintingDelayFlags ld a, [hl] push af res 1, [hl] @@ -6963,7 +6964,7 @@ InitBattle_Common: ; 3efeb (f:6feb) call StartBattle callab EndOfBattle pop af - ld [wd358], a + ld [wLetterPrintingDelayFlags], a pop af ld [wMapPalOffset], a ld a, [wd0d4] @@ -6998,7 +6999,7 @@ ResetCryModifiers: ; 3f069 (f:7069) ld [wc0f2], a jp PlaySound -; animtes the mon "growing" out of the pokeball +; animates the mon "growing" out of the pokeball AnimateSendingOutMon: ; 3f073 (f:7073) ld a, [wPredefRegisters] ld h, a @@ -7016,17 +7017,17 @@ AnimateSendingOutMon: ; 3f073 (f:7073) ld bc, -41 add hl, bc ld a, $1 - ld [wcd6c], a + ld [wDownscaledMonSize], a ld bc, $303 - predef CopyGrowingMonTiles + predef CopyDownscaledMonTiles ld c, 4 call DelayFrames ld bc, -41 add hl, bc xor a - ld [wcd6c], a + ld [wDownscaledMonSize], a ld bc, $505 - predef CopyGrowingMonTiles + predef CopyDownscaledMonTiles ld c, 5 call DelayFrames ld bc, -41 @@ -8242,14 +8243,14 @@ ChargeEffect: ; 3f88c (f:788c) ld a, b call PlayBattleAnimation ld a, [de] - ld [wWhichTrade], a + ld [wChargeMoveNum], a ld hl, ChargeMoveEffectText jp PrintText ChargeMoveEffectText: ; 3f8c8 (f:78c8) TX_FAR _ChargeMoveEffectText TX_ASM - ld a, [wWhichTrade] + ld a, [wChargeMoveNum] cp RAZOR_WIND ld hl, MadeWhirlwindText jr z, .asm_3f8f8 diff --git a/engine/battle/end_of_battle.asm b/engine/battle/end_of_battle.asm index 0ca4b886..075cbeb1 100755 --- a/engine/battle/end_of_battle.asm +++ b/engine/battle/end_of_battle.asm @@ -54,7 +54,7 @@ EndOfBattle: ; 137aa (4:77aa) ld [wd11f], a ld [wNumRunAttempts], a ld [wEscapedFromBattle], a - ld hl, wcc2b + ld hl, wPartyAndBillsPCSavedMenuItem ld [hli], a ld [hli], a ld [hli], a diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 4e4d0f3c..11a1e87c 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -148,8 +148,8 @@ GainExperience: ; 5524f (15:524f) call GetPartyMonName ld hl, GainedText call PrintText - xor a ; party mon data - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a call LoadMonData pop hl ld bc, wPartyMon1Level - wPartyMon1Exp @@ -242,15 +242,15 @@ GainExperience: ; 5524f (15:524f) .printGrewLevelText ld hl, GrewLevelText call PrintText - xor a ; party mon data - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a call LoadMonData ld d, $1 callab PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 - xor a - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a ld a, [wd0b5] ld [wd11e], a predef LearnMoveFromLevelUp diff --git a/engine/battle/init_battle_variables.asm b/engine/battle/init_battle_variables.asm index edb1f13e..74df62aa 100644 --- a/engine/battle/init_battle_variables.asm +++ b/engine/battle/init_battle_variables.asm @@ -2,9 +2,9 @@ InitBattleVariables: ; 525af (14:65af) ld a, [hTilesetType] ld [wd0d4], a xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ld [wBattleResult], a - ld hl, wcc2b + ld hl, wPartyAndBillsPCSavedMenuItem ld [hli], a ld [hli], a ld [hli], a diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index e373ef93..4f72aea1 100755 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -55,8 +55,8 @@ ReadTrainer: ; 39c53 (e:5c53) and a ; have we reached the end of the trainer data? jr z,.FinishUp ld [wcf91],a ; write species somewhere (XXX why?) - ld a,1 - ld [wcc49],a + ld a,ENEMY_PARTY_DATA + ld [wMonDataLocation],a push hl call AddPartyMon pop hl @@ -72,8 +72,8 @@ ReadTrainer: ; 39c53 (e:5c53) ld [W_CURENEMYLVL],a ld a,[hli] ld [wcf91],a - ld a,1 - ld [wcc49],a + ld a,ENEMY_PARTY_DATA + ld [wMonDataLocation],a push hl call AddPartyMon pop hl diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 59611ef1..55314ea9 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -559,7 +559,7 @@ AIPlayRestoringSFX: ; 3a69b (e:669b) AIUseFullRestore: ; 3a6a0 (e:66a0) call AICureStatus ld a,FULL_RESTORE - ld [wcf05],a + ld [wAIItem],a ld de,wHPBarOldHP ld hl,wEnemyMonHP + 1 ld a,[hld] @@ -600,7 +600,7 @@ AIUseHyperPotion: ; 3a6d6 (e:66d6) AIRecoverHP: ; 3a6da (e:66da) ; heal b HP and print "trainer used $(a) on pokemon!" - ld [wcf05],a + ld [wAIItem],a ld hl,wEnemyMonHP + 1 ld a,[hl] ld [wHPBarOldHP],a @@ -797,7 +797,7 @@ AIUseXSpecial: ; 3a804 (e:6804) ; fallthrough AIIncreaseStat: ; 3a808 (e:6808) - ld [wcf05],a + ld [wAIItem],a push bc call AIPrintItemUse_ pop bc @@ -819,13 +819,13 @@ AIIncreaseStat: ; 3a808 (e:6808) jp DecrementAICount AIPrintItemUse: ; 3a82c (e:682c) - ld [wcf05],a + ld [wAIItem],a call AIPrintItemUse_ jp DecrementAICount AIPrintItemUse_: ; 3a835 (e:6835) -; print "x used [wcf05] on z!" - ld a,[wcf05] +; print "x used [wAIItem] on z!" + ld a,[wAIItem] ld [wd11e],a call GetItemName ld hl, AIBattleUseItemText diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index b43fdcae..2b54108d 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -55,8 +55,8 @@ Evolution_PartyMonLoop: ; loop over party mons push hl ld a, [wcf91] push af - xor a - ld [wcc49], a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation], a call LoadMonData pop af ld [wcf91], a @@ -206,7 +206,7 @@ Evolution_PartyMonLoop: ; loop over party mons ld a, [wd0b5] ld [wd11e], a xor a - ld [wcc49], a + ld [wMonDataLocation], a call LearnMoveFromLevelUp pop hl predef SetPartyMonTypes @@ -345,12 +345,13 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b) ld a, [hli] ; move ID jr nz, .learnSetLoop ld d, a ; ID of move to learn - ld a, [wcc49] + ld a, [wMonDataLocation] and a jr nz, .next -; if [wcc49] is 0, get the address of the mon's current moves -; there is no reason to make this conditional because the code wouldn't work properly without doing this -; every call to this function sets [wcc49] to 0 +; If [wMonDataLocation] is 0 (PLAYER_PARTY_DATA), get the address of the mon's +; current moves in party data. Every call to this function sets +; [wMonDataLocation] to 0 because other data locations are not supported. +; If it is not 0, this function will not work properly. ld hl, wPartyMon1Moves ld a, [wWhichPokemon] ld bc, wPartyMon2 - wPartyMon1 diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 0d451bf6..45e88b9c 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -16,7 +16,7 @@ _GivePokemon: ; 4fda5 (13:7da5) call SetPokedexOwnedFlag callab SendNewMonToBox ld hl, wcf4b - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f cp 9 jr c, .asm_4fdec diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 7882a226..81ccffdc 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -1,5 +1,5 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) - call Func_70423 + call HoFFadeOutScreenAndMusic call ClearScreen ld c, 100 call DelayFrames @@ -21,16 +21,16 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld [wUpdateSpritesEnabled], a ld [hTilesetType], a ld [W_SPRITEFLIPPED], a - ld [wd358], a - ld [wTrainerScreenY], a + ld [wLetterPrintingDelayFlags], a ; no delay + ld [wHoFMonOrPlayer], a ; mon inc a ld [H_AUTOBGTRANSFERENABLED], a - ld hl, wd5a2 + ld hl, wNumHoFTeams ld a, [hl] inc a - jr z, .asm_701eb + jr z, .skipInc ; don't wrap around to 0 inc [hl] -.asm_701eb +.skipInc ld a, $90 ld [hWY], a ld c, BANK(Music_HallOfFame) @@ -38,23 +38,23 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call PlayMusic ld hl, wPartySpecies ld c, $ff -.asm_701fb +.partyMonLoop ld a, [hli] cp $ff - jr z, .asm_70241 + jr z, .doneShowingParty inc c push hl push bc - ld [wWhichTrade], a + ld [wHoFMonSpecies], a ld a, c - ld [wTrainerEngageDistance], a + ld [wHoFPartyMonIndex], a ld hl, wPartyMon1Level ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld a, [hl] - ld [wTrainerFacingDirection], a - call Func_70278 - call Func_702e1 + ld [wHoFMonLevel], a + call HoFShowMonOrPlayer + call HoFDisplayAndRecordMonInfo ld c, 80 call DelayFrames hlCoord 2, 13 @@ -69,8 +69,8 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call GBFadeOutToWhite pop bc pop hl - jr .asm_701fb -.asm_70241 + jr .partyMonLoop +.doneShowingParty ld a, c inc a ld hl, wHallOfFame @@ -79,12 +79,12 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld [hl], $ff call SaveHallOfFameTeams xor a - ld [wWhichTrade], a + ld [wHoFMonSpecies], a inc a - ld [wTrainerScreenY], a - call Func_70278 + ld [wHoFMonOrPlayer], a ; player + call HoFShowMonOrPlayer call HoFDisplayPlayerStats - call Func_70423 + call HoFFadeOutScreenAndMusic xor a ld [hWY], a ld hl, rLCDC @@ -94,69 +94,72 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) HallOfFameText: ; 7026b (1c:426b) db "HALL OF FAME@" -Func_70278: ; 70278 (1c:4278) +HoFShowMonOrPlayer: ; 70278 (1c:4278) call ClearScreen ld a, $d0 ld [hSCY], a ld a, $c0 ld [hSCX], a - ld a, [wWhichTrade] + ld a, [wHoFMonSpecies] ld [wcf91], a ld [wd0b5], a ld [wBattleMonSpecies2], a ld [wcf1d], a - ld a, [wTrainerScreenY] + ld a, [wHoFMonOrPlayer] and a - jr z, .asm_7029d + jr z, .showMon +; show player call HoFLoadPlayerPics - jr .asm_702ab -.asm_7029d + jr .next1 +.showMon hlCoord 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex predef LoadMonBackPic -.asm_702ab +.next1 ld b, $b ld c, $0 call GoPAL_SET - ld a, $e4 + ld a, %11100100 ld [rBGP], a - ld c, $31 - call Func_7036d + ld c, $31 ; back pic + call HoFLoadMonPlayerPicTileIDs ld d, $a0 - ld e, $4 + ld e, 4 ld a, [wOnSGB] and a - jr z, .asm_702c7 - sla e -.asm_702c7 - call .asm_702d5 + jr z, .next2 + sla e ; scroll more slowly on SGB +.next2 + call .ScrollPic ; scroll back pic left xor a ld [hSCY], a - ld c, a - call Func_7036d - ld d, $0 - ld e, $fc -.asm_702d5 + ld c, a ; front pic + call HoFLoadMonPlayerPicTileIDs + ld d, 0 + ld e, -4 +; scroll front pic right + +.ScrollPic call DelayFrame ld a, [hSCX] add e ld [hSCX], a cp d - jr nz, .asm_702d5 + jr nz, .ScrollPic ret -Func_702e1: ; 702e1 (1c:42e1) - ld a, [wTrainerEngageDistance] +HoFDisplayAndRecordMonInfo: ; 702e1 (1c:42e1) + ld a, [wHoFPartyMonIndex] ld hl, wPartyMonNicks call GetPartyMonName - call Func_702f0 - jp Func_70404 + call HoFDisplayMonInfo + jp HoFRecordMonInfo -Func_702f0: ; 702f0 (1c:42f0) +HoFDisplayMonInfo: ; 702f0 (1c:42f0) hlCoord 0, 2 - ld b, $9 - ld c, $a + ld b, 9 + ld c, 10 call TextBoxBorder hlCoord 2, 6 ld de, HoFMonInfoText @@ -164,14 +167,14 @@ Func_702f0: ; 702f0 (1c:42f0) hlCoord 1, 4 ld de, wcd6d call PlaceString - ld a, [wTrainerFacingDirection] + ld a, [wHoFMonLevel] hlCoord 8, 7 call PrintLevelCommon - ld a, [wWhichTrade] + ld a, [wHoFMonSpecies] ld [wd0b5], a hlCoord 3, 9 predef PrintMonType - ld a, [wWhichTrade] + ld a, [wHoFMonSpecies] jp PlayCry HoFMonInfoText: ; 70329 (1c:4329) @@ -197,8 +200,9 @@ HoFLoadPlayerPics: ; 7033e (1c:433e) call InterlaceMergeSpriteBuffers ld c, $1 -Func_7036d: ; 7036d (1c:436d) - ld b, $0 +HoFLoadMonPlayerPicTileIDs: ; 7036d (1c:436d) +; c = base tile ID + ld b, 0 hlCoord 12, 5 predef_jump CopyTileIDsFromList @@ -261,14 +265,14 @@ DexRatingText: ; 703ff (1c:43ff) TX_FAR _DexRatingText db "@" -Func_70404: ; 70404 (1c:4404) +HoFRecordMonInfo: ; 70404 (1c:4404) ld hl, wHallOfFame ld bc, HOF_MON - ld a, [wTrainerEngageDistance] + ld a, [wHoFPartyMonIndex] call AddNTimes - ld a, [wWhichTrade] + ld a, [wHoFMonSpecies] ld [hli], a - ld a, [wTrainerFacingDirection] + ld a, [wHoFMonLevel] ld [hli], a ld e, l ld d, h @@ -276,7 +280,7 @@ Func_70404: ; 70404 (1c:4404) ld bc, $b jp CopyData -Func_70423: ; 70423 (1c:4423) +HoFFadeOutScreenAndMusic: ; 70423 (1c:4423) ld a, $a ld [wcfc8], a ld [wcfc9], a diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 7366996c..6f1167d0 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -130,11 +130,11 @@ InGameTrade_DoTrade: ; 71c07 (1c:5c07) ld a,[wInGameTradeReceiveMonSpecies] ld [wcf91],a xor a - ld [wcc49],a + ld [wMonDataLocation],a ; not used ld [wRemoveMonFromBox],a call RemovePokemon - ld a,$80 - ld [wcc49],a + ld a,$80 ; prevent the player from naming the mon + ld [wMonDataLocation],a call AddPartyMon call InGameTrade_CopyDataToReceivedMon callab EvolveTradeMon @@ -177,9 +177,9 @@ InGameTrade_PrepareTradeData: ; 71cc1 (1c:5cc1) ld bc, $b call InGameTrade_CopyData ld hl, InGameTrade_TrainerString - ld de, wcd4e + ld de, wTradedEnemyMonOT call InGameTrade_CopyData - ld de, W_GRASSRATE + ld de, wLinkEnemyTrainerName call InGameTrade_CopyData ld hl, wPartyMon1OTID ld bc, wPartyMon2 - wPartyMon1 diff --git a/engine/items/items.asm b/engine/items/items.asm index 8d6037eb..b65e8f1e 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1,6 +1,6 @@ UseItem_: ; d5c7 (3:55c7) ld a,1 - ld [wcd6a],a + ld [wActionResultOrTookBattleTurn],a ; initialise to success value ld a,[wcf91] ;contains item_ID cp a,HM_01 jp nc,ItemUseTMHM @@ -423,8 +423,8 @@ ItemUseBall: ; d687 (3:5687) ld a,[wPartyCount] cp a,PARTY_LENGTH ;is party full? jr z,.sendToBox - xor a - ld [wcc49],a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation],a call ClearSprites call AddPartyMon ;add mon to Party jr .End @@ -661,7 +661,7 @@ ItemUseEvoStone: ; da5b (3:5a5b) call ItemUseNoEffect .canceledItemUse xor a - ld [wcd6a],a + ld [wActionResultOrTookBattleTurn],a ; item not used pop af ret @@ -691,7 +691,7 @@ ItemUseMedicine: ; dabb (3:5abb) .emptyParty ld hl,.emptyPartyText xor a - ld [wcd6a],a ; item use failed + ld [wActionResultOrTookBattleTurn],a ; item use failed jp PrintText .emptyPartyText text "You don't have" @@ -706,7 +706,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[wWhichPokemon] call AddNTimes ld a,[wWhichPokemon] - ld [wcf06],a + ld [wUsedItemOnWhichPokemon],a ld d,a ld a,[wcf91] ld e,a @@ -803,7 +803,7 @@ ItemUseMedicine: ; dabb (3:5abb) push hl push de push bc - ld a,[wcf06] + ld a,[wUsedItemOnWhichPokemon] ld c,a ld hl,wPartyFoughtCurrentEnemyFlags ld b,$02 @@ -811,7 +811,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,c and a jr z,.next - ld a,[wcf06] + ld a,[wUsedItemOnWhichPokemon] ld c,a ld hl,wPartyGainExpFlags ld b,$01 @@ -1106,7 +1106,7 @@ ItemUseMedicine: ; dabb (3:5abb) jr .done .canceledItemUse xor a - ld [wcd6a],a ; item use failed + ld [wActionResultOrTookBattleTurn],a ; item use failed pop af pop af .done @@ -1265,14 +1265,14 @@ ItemUseMedicine: ; dabb (3:5abb) ld [wWhichPokemon],a ld a,e ld [wd11e],a - xor a - ld [wcc49],a ; load from player's party + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation],a call LoadMonData ld d,$01 callab PrintStatsBox ; display new stats text box call WaitForTextScrollButtonPress ; wait for button press - xor a - ld [wcc49],a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation],a predef LearnMoveFromLevelUp ; learn level up move, if any xor a ld [wForceEvolution],a @@ -1384,7 +1384,7 @@ ItemUseEscapeRope: ; dfaf (3:5faf) ld [W_SAFARIZONEENTRANCECURSCRIPT],a inc a ld [wEscapedFromBattle],a - ld [wcd6a],a ; item used + ld [wActionResultOrTookBattleTurn],a ; item used ld a,[wd152] and a ; using Dig? ret nz ; if so, return @@ -1550,7 +1550,7 @@ ItemUseXStat: ; e104 (3:6104) jr nz,.inBattle call ItemUseNotTime ld a,2 - ld [wcd6a],a ; item not used + ld [wActionResultOrTookBattleTurn],a ; item not used ret .inBattle ld hl,W_PLAYERMOVENUM @@ -1783,7 +1783,7 @@ SuperRodCode: ; e283 (3:6283) call ReadSuperRodData ld a, e RodResponse: ; e28d (3:628d) - ld [wWhichTrade], a + ld [wRodResponse], a dec a ; is there a bite? jr nz, .next @@ -1801,7 +1801,7 @@ RodResponse: ; e28d (3:628d) push af push hl ld [hl], 0 - callba Func_707b6 + callba FishingAnim pop hl pop af ld [hl], a @@ -1963,8 +1963,8 @@ ItemUsePPRestore: ; e31e (3:631e) ; unsets zero flag if PP was restored, sets zero flag if not ; however, this is bugged for Max Ethers and Max Elixirs (see below) .restorePP - xor a - ld [wcc49],a ; party pokemon + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation],a call GetMaxPP ld hl,wPartyMon1Moves ld bc,44 @@ -2043,7 +2043,7 @@ ItemUsePPRestore: ; e31e (3:631e) call GoPAL_SET_CF1C pop af xor a - ld [wcd6a],a ; item use failed + ld [wActionResultOrTookBattleTurn],a ; item use failed ret RaisePPWhichTechniqueText: ; e45d (3:645d) @@ -2104,7 +2104,7 @@ ItemUseTMHM: ; e479 (3:6479) and a jr z,.useMachine ld a,2 - ld [wcd6a],a ; item not used + ld [wActionResultOrTookBattleTurn],a ; item not used ret .useMachine ld a,[wWhichPokemon] @@ -2234,7 +2234,7 @@ SurfingAttemptFailed: ; e5b6 (3:65b6) ItemUseFailed: ; e5b9 (3:65b9) xor a - ld [wcd6a],a ; item use failed + ld [wActionResultOrTookBattleTurn],a ; item use failed jp PrintText ItemUseNotTimeText: ; e5c0 (3:65c0) @@ -2301,13 +2301,13 @@ RestoreBonusPP: ; e606 (3:6606) ld a,[wWhichPokemon] call AddNTimes push hl - ld de,wcd78 - 1 - predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wcd78 + ld de,wNormalMaxPPList - 1 + predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList pop hl ld c,21 ld b,0 add hl,bc ; hl now points to move 1 PP - ld de,wcd78 + ld de,wNormalMaxPPList ld b,0 ; initialize move counter to zero ; loop through the pokemon's moves .loop @@ -2379,7 +2379,7 @@ AddBonusPP: ; e642 (3:6642) ; gets max PP of a pokemon's move (including PP from PP Ups) ; INPUT: ; [wWhichPokemon] = index of pokemon within party/box -; [wcc49] = pokemon source +; [wMonDataLocation] = pokemon source ; 00: player's party ; 01: enemy's party ; 02: current box @@ -2389,7 +2389,7 @@ AddBonusPP: ; e642 (3:6642) ; OUTPUT: ; [wd11e] = max PP GetMaxPP: ; e677 (3:6677) - ld a,[wcc49] + ld a,[wMonDataLocation] and a ld hl,wPartyMon1Moves ld bc,wPartyMon2 - wPartyMon1 @@ -2420,13 +2420,13 @@ GetMaxPP: ; e677 (3:6677) ld de,wcd6d ld a,BANK(Moves) call FarCopyData - ld de,wcd72 + ld de,wcd6d + 5 ; PP is byte 5 of move data ld a,[de] ld b,a ; b = normal max PP pop hl push bc ld bc,21 ; PP offset if not player's in-battle pokemon data - ld a,[wcc49] + ld a,[wMonDataLocation] cp a,4 ; player's in-battle pokemon? jr nz,.addPPOffset ld bc,17 ; PP offset if player's in-battle pokemon data diff --git a/engine/learn_move.asm b/engine/learn_move.asm index 3c7663b2..cb5bdbd7 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -134,18 +134,18 @@ TryingToLearn: ; 6f07 (1:6f07) res 2, a ld [hFlags_0xFFF6], a ld hl, wTopMenuItemY - ld a, $8 - ld [hli], a - ld a, $5 - ld [hli], a + ld a, 8 + ld [hli], a ; wTopMenuItemY + ld a, 5 + ld [hli], a ; wTopMenuItemX xor a - ld [hli], a + ld [hli], a ; wCurrentMenuItem inc hl - ld a, [wcd6c] - ld [hli], a - ld a, $3 - ld [hli], a - ld [hl], $0 + ld a, [wNumMovesMinusOne] + ld [hli], a ; wMaxMenuItem + ld a, A_BUTTON | B_BUTTON + ld [hli], a ; wMenuWatchedKeys + ld [hl], 0 ; wLastMenuItem ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index fcc51af1..e0b405e8 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -1,44 +1,44 @@ -Func_213c8:: ; 213c8 (8:53c8) +DisplayPCMainMenu:: ; 213c8 (8:53c8) xor a ld [H_AUTOBGTRANSFERENABLED], a call SaveScreenTilesToBuffer2 - ld a, [wd5a2] + ld a, [wNumHoFTeams] and a - jr nz, .asm_213f3 + jr nz, .leaguePCAvailable ld a, [wd74b] - bit 5, a - jr z, .asm_213ea - ld a, [wd5a2] + bit 5, a ; received pokedex? + jr z, .noOaksPC + ld a, [wNumHoFTeams] and a - jr nz, .asm_213f3 + jr nz, .leaguePCAvailable hlCoord 0, 0 - ld b, $8 - ld c, $e - jr .asm_213fa -.asm_213ea + ld b, 8 + ld c, 14 + jr .next +.noOaksPC hlCoord 0, 0 - ld b, $6 - ld c, $e - jr .asm_213fa -.asm_213f3 + ld b, 6 + ld c, 14 + jr .next +.leaguePCAvailable hlCoord 0, 0 - ld b, $a - ld c, $e -.asm_213fa + ld b, 10 + ld c, 14 +.next call TextBoxBorder call UpdateSprites - ld a, $3 + ld a, 3 ld [wMaxMenuItem], a ld a, [wd7f1] bit 0, a - jr nz, .asm_21414 + jr nz, .metBill hlCoord 2, 2 ld de, SomeonesPCText - jr .asm_2141a -.asm_21414 + jr .next2 +.metBill hlCoord 2, 2 ld de, BillsPCText -.asm_2141a +.next2 call PlaceString hlCoord 2, 4 ld de, wPlayerName @@ -48,43 +48,43 @@ Func_213c8:: ; 213c8 (8:53c8) ld de, PlayersPCText call PlaceString ld a, [wd74b] - bit 5, a - jr z, .asm_21462 + bit 5, a ; received pokedex? + jr z, .noOaksPC2 hlCoord 2, 6 ld de, OaksPCText call PlaceString - ld a, [wd5a2] + ld a, [wNumHoFTeams] and a - jr z, .asm_2145a - ld a, $4 + jr z, .noLeaguePC + ld a, 4 ld [wMaxMenuItem], a hlCoord 2, 8 ld de, PKMNLeaguePCText call PlaceString hlCoord 2, 10 ld de, LogOffPCText - jr .asm_2146d -.asm_2145a + jr .next3 +.noLeaguePC hlCoord 2, 8 ld de, LogOffPCText - jr .asm_2146d -.asm_21462 + jr .next3 +.noOaksPC2 ld a, $2 ld [wMaxMenuItem], a hlCoord 2, 6 ld de, LogOffPCText -.asm_2146d +.next3 call PlaceString - ld a, $3 + ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a - ld a, $2 + ld a, 2 ld [wTopMenuItemY], a - ld a, $1 + ld a, 1 ld [wTopMenuItemX], a xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld a, $1 + ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a ret @@ -99,23 +99,23 @@ BillsPC_:: ; 0x214c2 ld hl, wd730 set 6, [hl] xor a - ld [wccd3], a + ld [wParentMenuItem], a inc a ; MONSTER_NAME ld [wNameListType], a call LoadHpBarAndStatusTilePatterns ld a, [wListScrollOffset] push af ld a, [wFlags_0xcd60] - bit 3, a + bit 3, a ; accessing Bill's PC through another PC? jr nz, BillsPCMenu +; accessing it directly ld a, $99 call PlaySound ld hl, SwitchOnText call PrintText -Func_214e8: ; 214e8 (8:54e8) -BillsPCMenu: - ld a, [wccd3] +BillsPCMenu: ; 214e8 (8:54e8) + ld a, [wParentMenuItem] ld [wCurrentMenuItem], a ld hl, vChars2 + $780 ld de, PokeballTileGraphics @@ -123,79 +123,81 @@ BillsPCMenu: call CopyVideoData call LoadScreenTilesFromBuffer2DisableBGTransfer hlCoord 0, 0 - ld b, $a - ld c, $c + ld b, 10 + ld c, 12 call TextBoxBorder hlCoord 2, 2 ld de, BillsPCMenuText call PlaceString ld hl, wTopMenuItemY - ld a, $2 - ld [hli], a + ld a, 2 + ld [hli], a ; wTopMenuItemY dec a - ld [hli], a + ld [hli], a ; wTopMenuItemX inc hl inc hl - ld a, $4 - ld [hli], a - ld a, $3 - ld [hli], a + ld a, 4 + ld [hli], a ; wMaxMenuItem + ld a, A_BUTTON | B_BUTTON + ld [hli], a ; wMenuWatchedKeys xor a - ld [hli], a - ld [hli], a + ld [hli], a ; wLastMenuItem + ld [hli], a ; wPartyAndBillsPCSavedMenuItem ld hl, wListScrollOffset - ld [hli], a - ld [hl], a + ld [hli], a ; wListScrollOffset + ld [hl], a ; wMenuWatchMovingOutOfBounds ld [wPlayerMonNumber], a ld hl, WhatText call PrintText hlCoord 9, 14 - ld b, $2 - ld c, $9 + ld b, 2 + ld c, 9 call TextBoxBorder - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f cp 9 - jr c, .asm_2154f + jr c, .singleDigitBoxNum +; two digit box num sub 9 hlCoord 17, 16 ld [hl], "1" add "0" - jr .asm_21551 -.asm_2154f + jr .next +.singleDigitBoxNum add "1" -.asm_21551 +.next Coorda 18, 16 hlCoord 10, 16 ld de, BoxNoPCText call PlaceString - ld a, $1 + ld a, 1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 call HandleMenuInput bit 1, a - jp nz, Func_21588 ; b button + jp nz, ExitBillsPC ; b button call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] - ld [wccd3], a + ld [wParentMenuItem], a and a - jp z, Func_21618 ; withdraw + jp z, BillsPCWithdraw ; withdraw cp $1 - jp z, Func_215ac ; deposit + jp z, BillsPCDeposit ; deposit cp $2 - jp z, Func_21673 ; release + jp z, BillsPCRelease ; release cp $3 - jp z, Func_216b3 ; change box + jp z, BillsPCChangeBox ; change box -Func_21588: ; 21588 (8:5588) +ExitBillsPC: ; 21588 (8:5588) ld a, [wFlags_0xcd60] - bit 3, a - jr nz, .asm_2159a + bit 3, a ; accessing Bill's PC through another PC? + jr nz, .next +; accessing it directly call LoadTextBoxTilePatterns ld a, $9a call PlaySound call WaitForSoundToFinish -.asm_2159a +.next ld hl, wFlags_0xcd60 res 5, [hl] call LoadScreenTilesFromBuffer2 @@ -205,26 +207,25 @@ Func_21588: ; 21588 (8:5588) res 6, [hl] ret -Func_215ac: ; 215ac (8:55ac) -BillsPCDeposit: +BillsPCDeposit: ; 215ac (8:55ac) ld a, [wPartyCount] dec a - jr nz, .asm_215bb + jr nz, .partyLargeEnough ld hl, CantDepositLastMonText call PrintText jp BillsPCMenu -.asm_215bb +.partyLargeEnough ld a, [W_NUMINBOX] cp MONS_PER_BOX - jr nz, .asm_215cb + jr nz, .boxNotFull ld hl, BoxFullText call PrintText jp BillsPCMenu -.asm_215cb +.boxNotFull ld hl, wPartyCount - call Func_216be + call DisplayMonListMenu jp c, BillsPCMenu - call Func_2174b + call DisplayDepositWithdrawMenu jp nc, BillsPCMenu ld a, [wcf91] call GetCryData @@ -236,45 +237,45 @@ BillsPCDeposit: ld [wRemoveMonFromBox], a call RemovePokemon call WaitForSoundToFinish - ld hl, wWhichTrade - ld a, [wd5a0] + ld hl, wBoxNumString + ld a, [wCurrentBoxNum] and $7f cp 9 - jr c, .asm_2160a + jr c, .singleDigitBoxNum sub 9 ld [hl], "1" inc hl add "0" - jr .asm_2160c -.asm_2160a + jr .next +.singleDigitBoxNum add "1" -.asm_2160c +.next ld [hli], a ld [hl], $50 ld hl, MonWasStoredText call PrintText jp BillsPCMenu -Func_21618: ; 21618 (8:5618) +BillsPCWithdraw: ; 21618 (8:5618) ld a, [W_NUMINBOX] and a - jr nz, .asm_21627 + jr nz, .boxNotEmpty ld hl, NoMonText call PrintText - jp Func_214e8 -.asm_21627 + jp BillsPCMenu +.boxNotEmpty ld a, [wPartyCount] cp PARTY_LENGTH - jr nz, .asm_21637 + jr nz, .partyNotFull ld hl, CantTakeMonText call PrintText - jp Func_214e8 -.asm_21637 + jp BillsPCMenu +.partyNotFull ld hl, W_NUMINBOX - call Func_216be - jp c, Func_214e8 - call Func_2174b - jp nc, Func_214e8 + call DisplayMonListMenu + jp c, BillsPCMenu + call DisplayDepositWithdrawMenu + jp nc, BillsPCMenu ld a, [wWhichPokemon] ld hl, wBoxMonNicks call GetPartyMonName @@ -290,25 +291,25 @@ Func_21618: ; 21618 (8:5618) call WaitForSoundToFinish ld hl, MonIsTakenOutText call PrintText - jp Func_214e8 + jp BillsPCMenu -Func_21673: ; 21673 (8:5673) +BillsPCRelease: ; 21673 (8:5673) ld a, [W_NUMINBOX] and a - jr nz, .asm_21682 + jr nz, .loop ld hl, NoMonText call PrintText - jp Func_214e8 -.asm_21682 + jp BillsPCMenu +.loop ld hl, W_NUMINBOX - call Func_216be - jp c, Func_214e8 + call DisplayMonListMenu + jp c, BillsPCMenu ld hl, OnceReleasedText call PrintText call YesNoChoice ld a, [wCurrentMenuItem] and a - jr nz, .asm_21682 + jr nz, .loop inc a ld [wRemoveMonFromBox], a call RemovePokemon @@ -317,27 +318,27 @@ Func_21673: ; 21673 (8:5673) call PlayCry ld hl, MonWasReleasedText call PrintText - jp Func_214e8 + jp BillsPCMenu -Func_216b3: ; 216b3 (8:56b3) +BillsPCChangeBox: ; 216b3 (8:56b3) callba ChangeBox - jp Func_214e8 + jp BillsPCMenu -Func_216be: ; 216be (8:56be) +DisplayMonListMenu: ; 216be (8:56be) ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a xor a ld [wPrintItemPrices], a ld [wListMenuID], a inc a ; MONSTER_NAME ld [wNameListType], a - ld a, [wcc2b] + ld a, [wPartyAndBillsPCSavedMenuItem] ld [wCurrentMenuItem], a call DisplayListMenuID ld a, [wCurrentMenuItem] - ld [wcc2b], a + ld [wPartyAndBillsPCSavedMenuItem], a ret BillsPCMenuText: ; 216e1 (8:56e1) @@ -354,17 +355,19 @@ ENDC BoxNoPCText: ; 21713 (8:5713) db "BOX No.@" -Func_2171b:: ; 2171b (8:571b) +KnowsHMMove:: ; 2171b (8:571b) +; returns whether mon with party index [wWhichPokemon] knows an HM move ld hl, wPartyMon1Moves ld bc, wPartyMon2 - wPartyMon1 - jr .asm_21729 + jr .next +; unreachable ld hl, wBoxMon1Moves ld bc, wBoxMon2 - wBoxMon1 -.asm_21729 +.next ld a, [wWhichPokemon] call AddNTimes ld b, NUM_MOVES -.asm_21731 +.loop ld a, [hli] push hl push bc @@ -375,7 +378,7 @@ Func_2171b:: ; 2171b (8:571b) pop hl ret c dec b - jr nz, .asm_21731 + jr nz, .loop and a ret @@ -387,72 +390,72 @@ HMMoveArray: ; 21745 (8:5745) db FLASH db -1 -Func_2174b: ; 2174b (8:574b) +DisplayDepositWithdrawMenu: ; 2174b (8:574b) hlCoord 9, 10 - ld b, $6 - ld c, $9 + ld b, 6 + ld c, 9 call TextBoxBorder - ld a, [wccd3] - and a + ld a, [wParentMenuItem] + and a ; was the Deposit or Withdraw item selected in the parent menu? ld de, DepositPCText - jr nz, .asm_21761 + jr nz, .next ld de, WithdrawPCText -.asm_21761 +.next hlCoord 11, 12 call PlaceString hlCoord 11, 14 ld de, StatsCancelPCText call PlaceString ld hl, wTopMenuItemY - ld a, $c - ld [hli], a - ld a, $a - ld [hli], a + ld a, 12 + ld [hli], a ; wTopMenuItemY + ld a, 10 + ld [hli], a ; wTopMenuItemX xor a - ld [hli], a + ld [hli], a ; wCurrentMenuItem inc hl - ld a, $2 - ld [hli], a - ld a, $3 - ld [hli], a + ld a, 2 + ld [hli], a ; wMaxMenuItem + ld a, A_BUTTON | B_BUTTON + ld [hli], a ; wMenuWatchedKeys xor a - ld [hl], a + ld [hl], a ; wLastMenuItem ld hl, wListScrollOffset - ld [hli], a - ld [hl], a + ld [hli], a ; wListScrollOffset + ld [hl], a ; wMenuWatchMovingOutOfBounds ld [wPlayerMonNumber], a - ld [wcc2b], a -.asm_2178f + ld [wPartyAndBillsPCSavedMenuItem], a +.loop call HandleMenuInput - bit 1, a - jr nz, .asm_2179f + bit 1, a ; pressed B? + jr nz, .exit ld a, [wCurrentMenuItem] and a - jr z, .asm_217a1 + jr z, .choseDepositWithdraw dec a - jr z, .asm_217a3 -.asm_2179f + jr z, .viewStats +.exit and a ret -.asm_217a1 +.choseDepositWithdraw scf ret -.asm_217a3 +.viewStats call SaveScreenTilesToBuffer1 - ld a, [wccd3] + ld a, [wParentMenuItem] and a - ld a, $0 - jr nz, .asm_217b0 - ld a, $2 -.asm_217b0 - ld [wcc49], a + ld a, PLAYER_PARTY_DATA + jr nz, .next2 + ld a, BOX_DATA +.next2 + ld [wMonDataLocation], a predef StatusScreen predef StatusScreen2 call LoadScreenTilesFromBuffer1 call ReloadTilesetTilePatterns call GoPAL_SET_CF1C call LoadGBPal - jr .asm_2178f + jr .loop DepositPCText: db "DEPOSIT@" WithdrawPCText: db "WITHDRAW@" @@ -518,9 +521,9 @@ CableClubLeftGameboy:: ; 5824 (8:5825) ld a, [W_CURMAP] cp BATTLE_CENTER ld a, LINK_STATE_START_TRADE - jr z, .asm_2183a + jr z, .next inc a ; LINK_STATE_START_BATTLE -.asm_2183a +.next ld [wLinkState], a call EnableAutoTextBoxDrawing tx_pre_jump JustAMomentText @@ -535,9 +538,9 @@ CableClubRightGameboy:: ; 5845 (8:5845) ld a, [W_CURMAP] cp BATTLE_CENTER ld a, LINK_STATE_START_TRADE - jr z, .asm_2185a + jr z, .next inc a ; LINK_STATE_START_BATTLE -.asm_2185a +.next ld [wLinkState], a call EnableAutoTextBoxDrawing tx_pre_jump JustAMomentText diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index a6dd7021..c38ab86b 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -13,30 +13,32 @@ PKMNLeaguePC: ; 0x7657e ld [W_SPRITEFLIPPED], a ld [wUpdateSpritesEnabled], a ld [wTrainerScreenX], a - ld [wcd42], a - ld a, [wd5a2] + ld [wHoFTeamNo], a + ld a, [wNumHoFTeams] ld b, a - cp NUM_HOF_TEAMS + 1 - jr c, .first - ld b, NUM_HOF_TEAMS + cp HOF_TEAM_CAPACITY + 1 + jr c, .loop +; If the total number of hall of fame teams is greater than the storage +; capacity, then calculate the number of the first team that is still recorded. + ld b, HOF_TEAM_CAPACITY sub b - ld [wcd42], a -.first - ld hl, wcd42 + ld [wHoFTeamNo], a +.loop + ld hl, wHoFTeamNo inc [hl] push bc ld a, [wTrainerScreenX] - ld [wWhichTrade], a + ld [wHoFMonSpecies], a callba LoadHallOfFameTeams - call Func_765e5 + call LeaguePCShowTeam pop bc - jr c, .second + jr c, .doneShowingTeams ld hl, wTrainerScreenX inc [hl] ld a, [hl] cp b - jr nz, .first -.second + jr nz, .loop +.doneShowingTeams pop af ld [hTilesetType], a pop af @@ -48,11 +50,11 @@ PKMNLeaguePC: ; 0x7657e call GoPAL_SET_CF1C jp GBPalNormal -Func_765e5: ; 765e5 (1d:65e5) +LeaguePCShowTeam: ; 765e5 (1d:65e5) ld c, PARTY_LENGTH .loop push bc - call Func_76610 + call LeaguePCShowMon call WaitForTextScrollButtonPress ld a, [hJoyHeld] bit 1, a @@ -75,18 +77,18 @@ Func_765e5: ; 765e5 (1d:65e5) scf ret -Func_76610: ; 76610 (1d:6610) +LeaguePCShowMon: ; 76610 (1d:6610) call GBPalWhiteOutWithDelay3 call ClearScreen ld hl, wHallOfFame ld a, [hli] - ld [wWhichTrade], a + ld [wHoFMonSpecies], a ld [wcf91], a ld [wd0b5], a ld [wBattleMonSpecies2], a ld [wcf1d], a ld a, [hli] - ld [wTrainerFacingDirection], a + ld [wHoFMonLevel], a ld de, wcd6d ld bc, $000B call CopyData @@ -105,11 +107,11 @@ Func_76610: ; 76610 (1d:6610) ld de, HallOfFameNoText call PlaceString hlCoord 16, 15 - ld de, wcd42 + ld de, wHoFTeamNo ld bc, $0103 call PrintNumber - ld b, BANK(Func_702f0) - ld hl, Func_702f0 + ld b, BANK(HoFDisplayMonInfo) + ld hl, HoFDisplayMonInfo jp Bankswitch HallOfFameNoText: ; 76670 (1d:6670) diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 0856352c..14480b0a 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -16,7 +16,7 @@ MainMenu: ; 5af2 (1:5af2) call DelayFrames xor a ; LINK_STATE_NONE ld [wLinkState],a - ld hl,wcc2b + ld hl,wPartyAndBillsPCSavedMenuItem ld [hli],a ld [hli],a ld [hli],a @@ -109,7 +109,7 @@ MainMenu: ; 5af2 (1:5af2) ld [wd52a],a ld c,10 call DelayFrames - ld a,[wd5a2] + ld a,[wNumHoFTeams] and a jp z,SpecialEnterMap ld a,[W_CURMAP] ; map ID @@ -124,14 +124,14 @@ MainMenu: ; 5af2 (1:5af2) Func_5bff: ; 5bff (1:5bff) ld a,1 - ld [wd358],a + ld [wLetterPrintingDelayFlags],a ld a,3 ld [W_OPTIONS],a ret LinkMenu: ; 5c0a (1:5c0a) xor a - ld [wd358], a + ld [wLetterPrintingDelayFlags], a ld hl, wd72e set 6, [hl] ld hl, TextTerminator_6b20 @@ -452,12 +452,12 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) ld [wCurrentMenuItem],a ld [wLastMenuItem],a inc a - ld [wd358],a + ld [wLetterPrintingDelayFlags],a ld [wTrainerScreenY],a ld a,3 ; text speed cursor Y coordinate ld [wTopMenuItemY],a call SetCursorPositionsFromOptions - ld a,[wWhichTrade] ; text speed cursor X coordinate + ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld [wTopMenuItemX],a ld a,$01 ld [H_AUTOBGTRANSFERENABLED],a ; enable auto background transfer @@ -507,7 +507,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) .downPressed cp a,16 ld b,-13 - ld hl,wWhichTrade + ld hl,wOptionsTextSpeedCursorX jr z,.updateMenuVariables ld b,5 cp a,3 @@ -522,7 +522,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) .upPressed cp a,8 ld b,-5 - ld hl,wWhichTrade + ld hl,wOptionsTextSpeedCursorX jr z,.updateMenuVariables cp a,13 inc hl @@ -541,17 +541,17 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) call PlaceUnfilledArrowMenuCursor jp .loop .cursorInBattleAnimation - ld a,[wTrainerEngageDistance] ; battle animation cursor X coordinate + ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate xor a,$0b ; toggle between 1 and 10 - ld [wTrainerEngageDistance],a + ld [wOptionsBattleAnimCursorX],a jp .eraseOldMenuCursor .cursorInBattleStyle - ld a,[wTrainerFacingDirection] ; battle style cursor X coordinate + ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate xor a,$0b ; toggle between 1 and 10 - ld [wTrainerFacingDirection],a + ld [wOptionsBattleStyleCursorX],a jp .eraseOldMenuCursor .pressedLeftInTextSpeed - ld a,[wWhichTrade] ; text speed cursor X coordinate + ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate cp a,1 jr z,.updateTextSpeedXCoord cp a,7 @@ -562,7 +562,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) sub a,7 jr .updateTextSpeedXCoord .pressedRightInTextSpeed - ld a,[wWhichTrade] ; text speed cursor X coordinate + ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate cp a,14 jr z,.updateTextSpeedXCoord cp a,7 @@ -572,7 +572,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) .fromFastToMedium add a,6 .updateTextSpeedXCoord - ld [wWhichTrade],a ; text speed cursor X coordinate + ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate jp .eraseOldMenuCursor TextSpeedOptionText: ; 5fc0 (1:5fc0) @@ -593,7 +593,7 @@ OptionMenuCancelText: ; 6018 (1:6018) ; sets the options variable according to the current placement of the menu cursors in the options menu SetOptionsFromCursorPositions: ; 601f (1:601f) ld hl,TextSpeedOptionData - ld a,[wWhichTrade] ; text speed cursor X coordinate + ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld c,a .loop ld a,[hli] @@ -604,7 +604,7 @@ SetOptionsFromCursorPositions: ; 601f (1:601f) .textSpeedMatchFound ld a,[hl] ld d,a - ld a,[wTrainerEngageDistance] ; battle animation cursor X coordinate + ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate dec a jr z,.battleAnimationOn .battleAnimationOff @@ -613,7 +613,7 @@ SetOptionsFromCursorPositions: ; 601f (1:601f) .battleAnimationOn res 7,d .checkBattleStyle - ld a,[wTrainerFacingDirection] ; battle style cursor X coordinate + ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate dec a jr z,.battleStyleShift .battleStyleSet @@ -638,7 +638,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) pop bc dec hl ld a,[hl] - ld [wWhichTrade],a ; text speed cursor X coordinate + ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate hlCoord 0, 3 call .placeUnfilledRightArrow sla c @@ -646,7 +646,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) jr nc,.storeBattleAnimationCursorX ld a,10 ; Off .storeBattleAnimationCursorX - ld [wTrainerEngageDistance],a ; battle animation cursor X coordinate + ld [wOptionsBattleAnimCursorX],a ; battle animation cursor X coordinate hlCoord 0, 8 call .placeUnfilledRightArrow sla c @@ -654,7 +654,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) jr nc,.storeBattleStyleCursorX ld a,10 .storeBattleStyleCursorX - ld [wTrainerFacingDirection],a ; battle style cursor X coordinate + ld [wOptionsBattleStyleCursorX],a ; battle style cursor X coordinate hlCoord 0, 13 call .placeUnfilledRightArrow ; cursor in front of Cancel diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index edd65a81..fcdd5c50 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -227,7 +227,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) ld h,[hl] ld l,a push hl - ld a,[wcf06] + ld a,[wUsedItemOnWhichPokemon] ld hl,wPartyMonNicks call GetPartyMonName pop hl diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm index 2b8b9e92..8ee40c7c 100755 --- a/engine/menu/pc.asm +++ b/engine/menu/pc.asm @@ -10,7 +10,7 @@ ActivatePC: ; 17e2c (5:7e2c) call LoadScreenTilesFromBuffer2 call Delay3 PCMainMenu: ; 17e48 (5:7e48) - callba Func_213c8 + callba DisplayPCMainMenu ld hl, wFlags_0xcd60 set 5, [hl] call HandleMenuInput diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 8b433027..f436ae24 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -5,18 +5,19 @@ PlayerPC: ; 78e6 (1:78e6) ld [wNameListType], a call SaveScreenTilesToBuffer1 xor a - ld [wcc2c], a - ld [wccd3], a + ld [wBagSavedMenuItem], a + ld [wParentMenuItem], a ld a, [wFlags_0xcd60] - bit 3, a - jr nz, Func_790c + bit 3, a ; accessing player's PC through another PC? + jr nz, PlayerPCMenu +; accessing it directly ld a, (SFX_02_45 - SFX_Headers_02) / 3 call PlaySound ld hl, TurnedOnPC2Text call PrintText -Func_790c: ; 790c (1:790c) - ld a, [wccd3] +PlayerPCMenu: ; 790c (1:790c) + ld a, [wParentMenuItem] ld [wCurrentMenuItem], a ld hl, wFlags_0xcd60 set 5, [hl] @@ -30,101 +31,102 @@ Func_790c: ; 790c (1:790c) ld de, PlayersPCMenuEntries call PlaceString ld hl, wTopMenuItemY - ld a, $2 - ld [hli], a + ld a, 2 + ld [hli], a ; wTopMenuItemY dec a - ld [hli], a + ld [hli], a ; wTopMenuItemX inc hl inc hl - ld a, $3 - ld [hli], a - ld a, $3 - ld [hli], a + ld a, 3 + ld [hli], a ; wMaxMenuItem + ld a, A_BUTTON | B_BUTTON + ld [hli], a ; wMenuWatchedKeys xor a ld [hl], a ld hl, wListScrollOffset - ld [hli], a - ld [hl], a + ld [hli], a ; wListScrollOffset + ld [hl], a ; wMenuWatchMovingOutOfBounds ld [wPlayerMonNumber], a ld hl, WhatDoYouWantText call PrintText call HandleMenuInput bit 1, a - jp nz, Func_796d + jp nz, ExitPlayerPC call PlaceUnfilledArrowMenuCursor ld a, [wCurrentMenuItem] - ld [wccd3], a + ld [wParentMenuItem], a and a - jp z, Func_7a12 + jp z, PlayerPCWithdraw dec a - jp z, Func_7995 + jp z, PlayerPCDeposit dec a - jp z, Func_7a8f + jp z, PlayerPCToss -Func_796d: ; 796d (1:796d) +ExitPlayerPC: ; 796d (1:796d) ld a, [wFlags_0xcd60] - bit 3, a - jr nz, .asm_797c + bit 3, a ; accessing player's PC through another PC? + jr nz, .next +; accessing it directly ld a, (SFX_02_46 - SFX_Headers_02) / 3 call PlaySound call WaitForSoundToFinish -.asm_797c +.next ld hl, wFlags_0xcd60 res 5, [hl] call LoadScreenTilesFromBuffer2 xor a ld [wListScrollOffset], a - ld [wcc2c], a + ld [wBagSavedMenuItem], a ld hl, wd730 res 6, [hl] xor a ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret -Func_7995: ; 7995 (1:7995) +PlayerPCDeposit: ; 7995 (1:7995) xor a ld [wCurrentMenuItem], a ld [wListScrollOffset], a ld a, [wNumBagItems] and a - jr nz, Func_79ab + jr nz, .loop ld hl, NothingToDepositText call PrintText - jp Func_790c - -Func_79ab: ; 79ab (1:79ab) + jp PlayerPCMenu +.loop ld hl, WhatToDepositText call PrintText ld hl, wNumBagItems ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a xor a ld [wPrintItemPrices], a - ld a, $3 + ld a, ITEMLISTMENU ld [wListMenuID], a call DisplayListMenuID - jp c, Func_790c + jp c, PlayerPCMenu call IsKeyItem - ld a, $1 + ld a, 1 ld [wItemQuantity], a ld a, [wIsKeyItem] and a - jr nz, .asm_79e7 + jr nz, .next +; if it's not a key item, there can be more than one of the item ld hl, DepositHowManyText call PrintText call DisplayChooseQuantityMenu cp $ff - jp z, Func_79ab -.asm_79e7 + jp z, .loop +.next ld hl, wNumBoxItems call AddItemToInventory - jr c, .asm_79f8 + jr c, .roomAvailable ld hl, NoRoomToStoreText call PrintText - jp Func_79ab -.asm_79f8 + jp .loop +.roomAvailable ld hl, wNumBagItems call RemoveItemFromInventory call WaitForSoundToFinish @@ -133,52 +135,52 @@ Func_79ab: ; 79ab (1:79ab) call WaitForSoundToFinish ld hl, ItemWasStoredText call PrintText - jp Func_79ab + jp .loop -Func_7a12: ; 7a12 (1:7a12) +PlayerPCWithdraw: ; 7a12 (1:7a12) xor a ld [wCurrentMenuItem], a ld [wListScrollOffset], a ld a, [wNumBoxItems] and a - jr nz, Func_7a28 + jr nz, .loop ld hl, NothingStoredText call PrintText - jp Func_790c - -Func_7a28: ; 7a28 (1:7a28) + jp PlayerPCMenu +.loop ld hl, WhatToWithdrawText call PrintText ld hl, wNumBoxItems ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a xor a ld [wPrintItemPrices], a - ld a, $3 + ld a, ITEMLISTMENU ld [wListMenuID], a call DisplayListMenuID - jp c, Func_790c + jp c, PlayerPCMenu call IsKeyItem - ld a, $1 + ld a, 1 ld [wItemQuantity], a ld a, [wIsKeyItem] and a - jr nz, .asm_7a64 + jr nz, .next +; if it's not a key item, there can be more than one of the item ld hl, WithdrawHowManyText call PrintText call DisplayChooseQuantityMenu cp $ff - jp z, Func_7a28 -.asm_7a64 + jp z, .loop +.next ld hl, wNumBagItems call AddItemToInventory - jr c, .asm_7a75 + jr c, .roomAvailable ld hl, CantCarryMoreText call PrintText - jp Func_7a28 -.asm_7a75 + jp .loop +.roomAvailable ld hl, wNumBoxItems call RemoveItemFromInventory call WaitForSoundToFinish @@ -187,56 +189,56 @@ Func_7a28: ; 7a28 (1:7a28) call WaitForSoundToFinish ld hl, WithdrewItemText call PrintText - jp Func_7a28 + jp .loop -Func_7a8f: ; 7a8f (1:7a8f) +PlayerPCToss: ; 7a8f (1:7a8f) xor a ld [wCurrentMenuItem], a ld [wListScrollOffset], a ld a, [wNumBoxItems] and a - jr nz, Func_7aa5 + jr nz, .loop ld hl, NothingStoredText call PrintText - jp Func_790c - -Func_7aa5: ; 7aa5 (1:7aa5) + jp PlayerPCMenu +.loop ld hl, WhatToTossText call PrintText ld hl, wNumBoxItems ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a xor a ld [wPrintItemPrices], a - ld a, $3 + ld a, ITEMLISTMENU ld [wListMenuID], a push hl call DisplayListMenuID pop hl - jp c, Func_790c + jp c, PlayerPCMenu push hl call IsKeyItem pop hl - ld a, $1 + ld a, 1 ld [wItemQuantity], a ld a, [wIsKeyItem] and a - jr nz, .asm_7aef + jr nz, .next ld a, [wcf91] call IsItemHM - jr c, .asm_7aef + jr c, .next +; if it's not a key item, there can be more than one of the item push hl ld hl, TossHowManyText call PrintText call DisplayChooseQuantityMenu pop hl cp $ff - jp z, Func_7aa5 -.asm_7aef - call TossItem - jp Func_7aa5 + jp z, .loop +.next + call TossItem ; disallows tossing key items + jp .loop PlayersPCMenuEntries: ; 7af5 (1:7af5) db "WITHDRAW ITEM" diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 0db0d052..7aa09df7 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -54,7 +54,7 @@ RedisplayStartMenu:: ; 2adf (0:2adf) .buttonPressed ; A, B, or Start button pressed call PlaceUnfilledArrowMenuCursor ld a,[wCurrentMenuItem] - ld [wcc2d],a ; save current menu item ID + ld [wBattleAndStartSavedMenuItem],a ; save current menu selection ld a,b and a,%00001010 ; was the Start button or B button pressed? jp nz,CloseStartMenu diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 825360a6..11b7fa90 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -33,14 +33,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld a,FIELD_MOVE_MON_MENU ld [wTextBoxID],a call DisplayTextBoxID ; display pokemon menu options - ld hl,wWhichTrade + ld hl,wFieldMoves ld bc,$020c ; max menu item ID, top menu item Y ld e,5 .adjustMenuVariablesLoop dec e jr z,.storeMenuVariables ld a,[hli] - and a + and a ; end of field moves? jr z,.storeMenuVariables inc b dec c @@ -50,7 +50,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld hl,wTopMenuItemY ld a,c ld [hli],a ; top menu item Y - ld a,[$fff7] + ld a,[hFieldMoveMonMenuTopMenuItemX] ld [hli],a ; top menu item X xor a ld [hli],a ; current menu item ID @@ -81,22 +81,22 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) jp z,.choseStats ld c,a ld b,0 - ld hl,wWhichTrade + ld hl,wFieldMoves add hl,bc jp .choseOutOfBattleMove .choseSwitch ld a,[wPartyCount] cp a,2 ; is there more than one pokemon in the party? jp c,StartMenu_Pokemon ; if not, no switching - call SwitchPartyMon_Stats + call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap] ld a,SWAP_MONS_PARTY_MENU ld [wPartyMenuTypeOrMessageID],a call GoBackToPartyMenu jp .checkIfPokemonChosen .choseStats call ClearSprites - xor a - ld [wcc49],a + xor a ; PLAYER_PARTY_DATA + ld [wMonDataLocation],a predef StatusScreen predef StatusScreen2 call ReloadMapData @@ -153,7 +153,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) bit 1,a ; does the player have the Cascade Badge? jp z,.newBadgeRequired predef UsedCut - ld a,[wcd6a] + ld a,[wActionResultOrTookBattleTurn] and a jp z,.loop jp CloseTextDisplay @@ -169,7 +169,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld [wcf91],a ld [wd152],a call UseItem - ld a,[wcd6a] + ld a,[wActionResultOrTookBattleTurn] and a jp z,.loop call GBPalWhiteOutWithDelay3 @@ -197,7 +197,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld [wcf91],a ld [wd152],a call UseItem - ld a,[wcd6a] + ld a,[wActionResultOrTookBattleTurn] and a jp z,.loop call GBPalWhiteOutWithDelay3 @@ -256,14 +256,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld a,[H_QUOTIENT + 2] sbc b jp nc,.notHealthyEnough - ld a,[wcc2b] + ld a,[wPartyAndBillsPCSavedMenuItem] push af ld a,POTION ld [wcf91],a ld [wd152],a call UseItem pop af - ld [wcc2b],a + ld [wPartyAndBillsPCSavedMenuItem],a jp .loop .notHealthyEnough ; if current HP is less than 1/5 of max HP ld hl,.notHealthyEnoughText @@ -308,19 +308,19 @@ StartMenu_Item: ; 13302 (4:7302) jr .exitMenu .notInCableClubRoom ld bc,wNumBagItems - ld hl,wList + ld hl,wListPointer ld a,c ld [hli],a - ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID) + ld [hl],b ; store item bag pointer in wListPointer (for DisplayListMenuID) xor a ld [wPrintItemPrices],a ld a,ITEMLISTMENU ld [wListMenuID],a - ld a,[wcc2c] + ld a,[wBagSavedMenuItem] ld [wCurrentMenuItem],a call DisplayListMenuID ld a,[wCurrentMenuItem] - ld [wcc2c],a + ld [wBagSavedMenuItem],a jr nc,.choseItem .exitMenu call LoadScreenTilesFromBuffer2 ; restore saved screen @@ -401,7 +401,7 @@ StartMenu_Item: ; 13302 (4:7302) xor a ld [wd152],a call UseItem - ld a,[wcd6a] + ld a,[wActionResultOrTookBattleTurn] and a jp z,ItemMenuLoop jp CloseStartMenu @@ -409,7 +409,7 @@ StartMenu_Item: ; 13302 (4:7302) ld a,[wUpdateSpritesEnabled] push af call UseItem - ld a,[wcd6a] + ld a,[wActionResultOrTookBattleTurn] cp a,$02 jp z,.partyMenuNotDisplayed call GBPalWhiteOutWithDelay3 @@ -566,7 +566,7 @@ DrawTrainerInfo: ; 1349a (4:749a) ld de,vChars1 + $570 call TrainerInfo_FarCopyData call EnableLCD - ld hl,wWhichTrade + ld hl,wTrainerInfoTextBoxWidthPlus1 ld a,18 + 1 ld [hli],a dec a @@ -574,7 +574,7 @@ DrawTrainerInfo: ; 1349a (4:749a) ld [hl],1 hlCoord 0, 0 call TrainerInfo_DrawTextBox - ld hl,wWhichTrade + ld hl,wTrainerInfoTextBoxWidthPlus1 ld a,16 + 1 ld [hli],a dec a @@ -627,15 +627,15 @@ TrainerInfo_BadgesText: ; 13597 (4:7597) ; height is always 6 ; INPUT: ; hl = destination address -; [wWhichTrade] = width + 1 -; [wTrainerEngageDistance] = width -; [wTrainerFacingDirection] = distance from the end of a text box row to the start of the next +; [wTrainerInfoTextBoxWidthPlus1] = width +; [wTrainerInfoTextBoxWidth] = width - 1 +; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next TrainerInfo_DrawTextBox: ; 135a0 (4:75a0) ld a,$79 ; upper left corner tile ID ld de,$7a7b ; top edge and upper right corner tile ID's call TrainerInfo_DrawHorizontalEdge ; draw top edge call TrainerInfo_NextTextBoxRow - ld a,[wWhichTrade] ; width of the text box plus one + ld a,[wTrainerInfoTextBoxWidthPlus1] ld e,a ld d,0 ld c,6 ; height of the text box @@ -651,7 +651,7 @@ TrainerInfo_DrawTextBox: ; 135a0 (4:75a0) TrainerInfo_DrawHorizontalEdge: ; 135c3 (4:75c3) ld [hli],a ; place left corner tile - ld a,[wTrainerEngageDistance] ; width of the text box + ld a,[wTrainerInfoTextBoxWidth] ld c,a ld a,d .loop @@ -663,7 +663,7 @@ TrainerInfo_DrawHorizontalEdge: ; 135c3 (4:75c3) ret TrainerInfo_NextTextBoxRow: ; 135d0 (4:75d0) - ld a,[wTrainerFacingDirection] ; distance to the start of the next row + ld a,[wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row .loop inc hl dec a @@ -704,62 +704,65 @@ StartMenu_Option: ; 135f6 (4:75f6) jp RedisplayStartMenu SwitchPartyMon: ; 13613 (4:7613) - call SwitchPartyMon_Stats - ld a, [wWhichTrade] - call SwitchPartyMon_OAM + call SwitchPartyMon_InitVarOrSwapData ; swap data + ld a, [wSwappedMenuItem] + call SwitchPartyMon_ClearGfx ld a, [wCurrentMenuItem] - call SwitchPartyMon_OAM + call SwitchPartyMon_ClearGfx jp RedrawPartyMenu_ -SwitchPartyMon_OAM: ; 13625 (4:7625) +SwitchPartyMon_ClearGfx: ; 13625 (4:7625) push af hlCoord 0, 0 ld bc, SCREEN_WIDTH * 2 call AddNTimes ld c, SCREEN_WIDTH * 2 ld a, " " -.asm_13633 +.clearMonBGLoop ; clear the mon's row in the party menu ld [hli], a dec c - jr nz, .asm_13633 + jr nz, .clearMonBGLoop pop af ld hl, wOAMBuffer ld bc, $10 call AddNTimes ld de, $4 ld c, e -.asm_13645 +.clearMonOAMLoop ld [hl], $a0 add hl, de dec c - jr nz, .asm_13645 + jr nz, .clearMonOAMLoop call WaitForSoundToFinish ld a, (SFX_02_58 - SFX_Headers_02) / 3 jp PlaySound -SwitchPartyMon_Stats: ; 13653 (4:7653) +SwitchPartyMon_InitVarOrSwapData: ; 13653 (4:7653) +; This is used to initialise [wMenuItemToSwap] and to actually swap the data. ld a, [wMenuItemToSwap] - and a - jr nz, .asm_13661 + and a ; has [wMenuItemToSwap] been initialised yet? + jr nz, .pickedMonsToSwap +; If not, initialise [wMenuItemToSwap] so that it matches the current mon. ld a, [wWhichPokemon] - inc a + inc a ; [wMenuItemToSwap] counts from 1 ld [wMenuItemToSwap], a ret -.asm_13661 +.pickedMonsToSwap xor a ld [wPartyMenuTypeOrMessageID], a ld a, [wMenuItemToSwap] dec a ld b, a ld a, [wCurrentMenuItem] - ld [wWhichTrade], a - cp b - jr nz, .asm_1367b + ld [wSwappedMenuItem], a + cp b ; swapping a mon with itself? + jr nz, .swappingDifferentMons +; can't swap a mon with itself xor a ld [wMenuItemToSwap], a ld [wPartyMenuTypeOrMessageID], a ret -.asm_1367b +.swappingDifferentMons ld a, b ld [wMenuItemToSwap], a push hl @@ -770,20 +773,20 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld a, [wCurrentMenuItem] add l ld l, a - jr nc, .asm_1368e + jr nc, .noCarry inc h -.asm_1368e +.noCarry ld a, [wMenuItemToSwap] add e ld e, a - jr nc, .asm_13696 + jr nc, .noCarry2 inc d -.asm_13696 +.noCarry2 ld a, [hl] - ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld [hSwapTemp], a ld a, [de] ld [hl], a - ld a, [H_DIVIDEND] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) + ld a, [hSwapTemp] ld [de], a ld hl, wPartyMons ld bc, wPartyMon2 - wPartyMon1 @@ -791,19 +794,19 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) call AddNTimes push hl ld de, wSwitchPartyMonTempBuffer - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call CopyData ld hl, wPartyMons - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 ld a, [wMenuItemToSwap] call AddNTimes pop de push hl - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call CopyData pop de ld hl, wSwitchPartyMonTempBuffer - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call CopyData ld hl, wPartyMonOT ld a, [wCurrentMenuItem] @@ -842,7 +845,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld bc, $b call CopyData ld a, [wMenuItemToSwap] - ld [wWhichTrade], a + ld [wSwappedMenuItem], a xor a ld [wMenuItemToSwap], a ld [wPartyMenuTypeOrMessageID], a diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 7b3674e6..3f73a84f 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -65,9 +65,10 @@ DrawHP_: ; 128fb (4:68fb) ; Predef 0x37 StatusScreen: ; 12953 (4:6953) call LoadMonData - ld a, [wcc49] - cp $2 ; 2 means we're in a PC box + ld a, [wMonDataLocation] + cp BOX_DATA jr c, .DontRecalculate +; mon is in a box or daycare ld a, [wLoadedMonBoxLevel] ld [wLoadedMonLevel], a ld [W_CURENEMYLVL], a @@ -148,13 +149,13 @@ StatusScreen: ; 12953 (4:6953) hlCoord 11, 10 predef PrintMonType ld hl, NamePointers2 - call .asm_12a7e + call .GetStringPointer ld d, h ld e, l hlCoord 9, 1 call PlaceString ; Pokémon name ld hl, OTPointers - call .asm_12a7e + call .GetStringPointer ld d, h ld e, l hlCoord 12, 16 @@ -175,17 +176,18 @@ StatusScreen: ; 12953 (4:6953) pop af ld [hTilesetType], a ret -.asm_12a7e ; I don't know what this does, iterates over pointers? - ld a, [wcc49] + +.GetStringPointer + ld a, [wMonDataLocation] add a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld a, [wcc49] - cp $3 + ld a, [wMonDataLocation] + cp DAYCARE_DATA ret z ld a, [wWhichPokemon] jp SkipFixedLengthTextEntries @@ -316,7 +318,7 @@ StatusScreen2: ; 12b57 (4:6b57) hlCoord 2, 9 ld de, wMovesString call PlaceString ; Print moves - ld a, [wcd6c] + ld a, [wNumMovesMinusOne] inc a ld c, a ld a, $4 @@ -335,7 +337,7 @@ StatusScreen2: ; 12b57 (4:6b57) .InitPP ; 12bbb ld hl, wLoadedMonMoves deCoord 14, 10 - ld b, $0 + ld b, 0 .PrintPP ; 12bc3 ld a, [hli] and a @@ -356,15 +358,15 @@ StatusScreen2: ; 12b57 (4:6b57) pop de pop hl push hl - ld bc, $0014 + ld bc, wPartyMon1PP - wPartyMon1Moves - 1 add hl, bc ld a, [hl] and $3f - ld [wcd71], a + ld [wStatusScreenCurrentPP], a ld h, d ld l, e push hl - ld de, wcd71 + ld de, wStatusScreenCurrentPP ld bc, $0102 call PrintNumber ld a, "/" diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index f333586d..df092d4c 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -1,5 +1,5 @@ SetDefaultNames: ; 60ca (1:60ca) - ld a, [wd358] + ld a, [wLetterPrintingDelayFlags] push af ld a, [W_OPTIONS] push af @@ -18,7 +18,7 @@ SetDefaultNames: ; 60ca (1:60ca) pop af ld [W_OPTIONS], a pop af - ld [wd358], a + ld [wLetterPrintingDelayFlags], a ld a, [wd08a] and a call z, Func_5bff @@ -193,18 +193,18 @@ IntroFadePalettes: ; 6282 (1:6282) MovePicLeft: ; 6288 (1:6288) ld a,119 - ld [$FF4B],a + ld [rWX],a call DelayFrame ld a,$E4 ld [rBGP],a .next call DelayFrame - ld a,[$FF4B] + ld a,[rWX] sub 8 cp $FF ret z - ld [$FF4B],a + ld [rWX],a jr .next Predef3B: ; 62a1 (1:62a1) diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 26a65b5b..f7be269c 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -1,6 +1,6 @@ UsedCut: ; ef54 (3:6f54) xor a - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ; initialise to failure value ld a, [W_CURMAPTILESET] and a ; OVERWORLD jr z, .asm_ef6b @@ -26,9 +26,9 @@ UsedCut: ; ef54 (3:6f54) db "@" .asm_ef82 - ld [wcd4d], a + ld [wCutTile], a ld a, $1 - ld [wcd6a], a + ld [wActionResultOrTookBattleTurn], a ; used cut ld a, [wWhichPokemon] ld hl, wPartyMonNicks call GetPartyMonName @@ -73,10 +73,10 @@ UsedCutText: ; eff2 (3:6ff2) AnimateCutTree: ; eff7 (3:6ff7) xor a - ld [wcd50], a + ld [wWhichAnimationOffsets], a ld a, $e4 ld [rOBP1], a - ld a, [wcd4d] + ld a, [wCutTile] cp $52 jr z, .asm_f020 ld de, Overworld_GFX + $2d0 ; cuttable tree sprite top row @@ -138,7 +138,7 @@ GetCutTreeBoulderDustAnimationOffsets: ; f068 (3:7068) srl a ld e, a ld d, $0 ; de holds direction (00: down, 02: up, 04: left, 06: right) - ld a, [wcd50] + ld a, [wWhichAnimationOffsets] and a ld hl, CutTreeAnimationOffsets jr z, .asm_f084 diff --git a/engine/overworld/cut2.asm b/engine/overworld/cut2.asm index 9cb011b4..3194b39b 100755 --- a/engine/overworld/cut2.asm +++ b/engine/overworld/cut2.asm @@ -1,5 +1,5 @@ Func_79e96: ; 79e96 (1e:5e96) - ld a, [wcd4d] + ld a, [wCutTile] cp $52 jr z, .asm_79ec8 ld c, $8 diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index 01b3ae85..22dfb24f 100755 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -1,7 +1,7 @@ EmotionBubble: ; 17c47 (5:7c47) - ld a, [wcd50] + ld a, [wWhichEmotionBubble] ld c, a - ld b, $0 + ld b, 0 ld hl, EmotionBubblesPointerTable add hl, bc add hl, bc @@ -16,15 +16,18 @@ EmotionBubble: ; 17c47 (5:7c47) ld a, $ff ld [wUpdateSpritesEnabled], a ld a, [wd736] - bit 6, a + bit 6, a ; are the last 4 OAM entries reserved for a shadow or fishing rod? ld hl, wOAMBuffer + $8f ld de, wOAMBuffer + $9f - jr z, .asm_17c7a + jr z, .next ld hl, wOAMBuffer + $7f ld de, wOAMBuffer + $8f -.asm_17c7a + +; Copy OAM data 16 bytes forward to make room for emotion bubble OAM data at the +; start of the OAM buffer. +.next ld bc, $90 -.asm_17c7d +.loop ld a, [hl] ld [de], a dec hl @@ -32,12 +35,14 @@ EmotionBubble: ; 17c47 (5:7c47) dec bc ld a, c or b - jr nz, .asm_17c7d + jr nz, .loop + +; get the screen coordinates of the sprite the bubble is to be displayed above ld hl, wSpriteStateData1 + 4 - ld a, [wcd4f] + ld a, [wEmotionBubbleSpriteIndex] swap a ld c, a - ld b, $0 + ld b, 0 add hl, bc ld a, [hli] ld b, a @@ -45,6 +50,7 @@ EmotionBubble: ; 17c47 (5:7c47) ld a, [hl] add $8 ld c, a + ld de, EmotionBubblesOAM xor a call WriteOAMBlock diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 0cbb7f1c..30793dec 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -12,7 +12,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ; the maximum number for map tiles .checkIfTextBoxInFrontOfSprite aCoord 8, 9 - ld [$ff93], a + ld [hTilePlayerStandingOn], a cp $60 jr c, .lowerLeftTileIsMapTile .disableSprite @@ -21,52 +21,54 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ret .lowerLeftTileIsMapTile call DetectCollisionBetweenSprites - ld h, $c1 + ld h, wSpriteStateData1 / $100 ld a, [wWalkCounter] and a - jr nz, .asm_4e90 + jr nz, .moving ld a, [wd528] +; check if down bit 2, a - jr z, .notDown + jr z, .checkIfUp xor a ; ld a, SPRITE_FACING_DOWN - jr .done -.notDown + jr .next +.checkIfUp bit 3, a - jr z, .notUp + jr z, .checkIfLeft ld a, SPRITE_FACING_UP - jr .done -.notUp + jr .next +.checkIfLeft bit 1, a - jr z, .notLeft + jr z, .checkIfRight ld a, SPRITE_FACING_LEFT - jr .done -.notLeft + jr .next +.checkIfRight bit 0, a - jr z, .notRight + jr z, .notMoving ld a, SPRITE_FACING_RIGHT - jr .done -.notRight + jr .next +.notMoving +; zero the animation counters xor a ld [wSpriteStateData1 + 7], a ld [wSpriteStateData1 + 8], a - jr .asm_4eab -.done - ld [wSpriteStateData1 + 9], a + jr .calcImageIndex +.next + ld [wSpriteStateData1 + 9], a ; facing direction ld a, [wFontLoaded] bit 0, a - jr nz, .notRight -.asm_4e90 + jr nz, .notMoving +.moving ld a, [wd736] - bit 7, a - jr nz, .asm_4eb6 + bit 7, a ; is the player sprite spinning due to a spin tile? + jr nz, .skipSpriteAnim ld a, [H_CURRENTSPRITEOFFSET] add $7 ld l, a ld a, [hl] inc a ld [hl], a - cp $4 - jr nz, .asm_4eab + cp 4 + jr nz, .calcImageIndex xor a ld [hl], a inc hl @@ -74,28 +76,32 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) inc a and $3 ld [hl], a -.asm_4eab +.calcImageIndex ld a, [wSpriteStateData1 + 8] ld b, a ld a, [wSpriteStateData1 + 9] add b ld [wSpriteStateData1 + 2], a -.asm_4eb6 - ld a, [$ff93] +.skipSpriteAnim +; If the player is standing on a grass tile, make the player's sprite have +; lower priority than the background so that it's partially obscured by the +; grass. Only the lower half of the sprite is permitted to have the priority +; bit set by later logic. + ld a, [hTilePlayerStandingOn] ld c, a ld a, [W_GRASSTILE] cp c ld a, $0 - jr nz, .asm_4ec3 + jr nz, .next2 ld a, $80 -.asm_4ec3 +.next2 ld [wSpriteStateData2 + $07], a ret -Func_4ec7: ; 4ec7 (1:4ec7) +UnusedReadSpriteDataFunction: ; 4ec7 (1:4ec7) push bc push af - ld a, [$ffda] + ld a, [H_CURRENTSPRITEOFFSET] ld c, a pop af add c @@ -103,7 +109,7 @@ Func_4ec7: ; 4ec7 (1:4ec7) pop bc ret -Func_4ed1: ; 4ed1 (1:4ed1) +UpdateNPCSprite: ; 4ed1 (1:4ed1) ld a, [H_CURRENTSPRITEOFFSET] swap a dec a @@ -148,40 +154,43 @@ Func_4ed1: ; 4ed1 (1:4ed1) ld l, a ld a, [hl] ; c2x6: movement byte 1 inc a - jr z, .asm_4f59 ; value $FF + jr z, .randomMovement ; value $FF inc a - jr z, .asm_4f59 ; value $FE + jr z, .randomMovement ; value $FE +; scripted movement dec a - ld [hl], a ; (temporarily) increment movement byte 1 + ld [hl], a ; increment movement byte 1 (movement data index) dec a push hl ld hl, wcf0f dec [hl] ; decrement wcf0f pop hl - ld de, wcc5b - call LoadDEPlusA ; a = [wcc5b + movement byte 1] + ld de, wNPCMovementDirections + call LoadDEPlusA ; a = [wNPCMovementDirections + movement byte 1] cp $e0 jp z, ChangeFacingDirection cp $ff - jr nz, .asm_4f4b - ld [hl], a ; reset movement byte 1 to initial value + jr nz, .next +; reached end of wNPCMovementDirections list + ld [hl], a ; store $ff in movement byte 1, disabling scripted movement ld hl, wd730 res 0, [hl] xor a ld [wSimulatedJoypadStatesIndex], a ld [wWastedByteCD3A], a ret -.asm_4f4b +.next cp $fe - jr nz, .asm_4f5f + jr nz, .determineDirection +; current NPC movement data is $fe. this seems buggy ld [hl], $1 ; set movement byte 1 to $1 - ld de, wcc5b - call LoadDEPlusA ; a = [wcc5b + $fe] (?) - jr .asm_4f5f -.asm_4f59 - call getTileSpriteStandsOn + ld de, wNPCMovementDirections + call LoadDEPlusA ; a = [wNPCMovementDirections + $fe] (?) + jr .determineDirection +.randomMovement + call GetTileSpriteStandsOn call Random -.asm_4f5f +.determineDirection ld b, a ld a, [wCurSpriteMovement2] cp $d0 @@ -199,7 +208,7 @@ Func_4ed1: ; 4ed1 (1:4ed1) cp $2 jr z, .moveLeft ; movement byte 2 = $2 only allows left or right .moveDown - ld de, 2*20 + ld de, 2*SCREEN_WIDTH add hl, de ; move tile pointer two rows down ld de, $100 @@ -212,7 +221,7 @@ Func_4ed1: ; 4ed1 (1:4ed1) cp $2 jr z, .moveRight ; movement byte 2 = $2 only allows left or right .moveUp - ld de, -2*20 + ld de, -2*SCREEN_WIDTH add hl, de ; move tile pointer two rows up ld de, $ff00 ld bc, $804 @@ -249,7 +258,7 @@ ChangeFacingDirection: ; 4fc8 (1:4fc8) ; c: new facing direction (0,4,8 or $c) ; d: Y movement delta (-1, 0 or 1) ; e: X movement delta (-1, 0 or 1) -; hl: pointer to tile the sprite would wlak onto +; hl: pointer to tile the sprite would walk onto ; set carry on failure, clears carry on success TryWalking: ; 4fcb (1:4fcb) push hl @@ -470,7 +479,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc) ld l, a ld a, [hl] ; c2x6: movement byte 1 cp $fe - jr c, .skipXVisibilityTest ; movement byte 1 < $fe + jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted) ld a, [H_CURRENTSPRITEOFFSET] add $4 ld l, a @@ -495,7 +504,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc) .skipXVisibilityTest ; make the sprite invisible if a text box is in front of it ; $5F is the maximum number for map tiles - call getTileSpriteStandsOn + call GetTileSpriteStandsOn ld d, $60 ld a, [hli] cp d @@ -572,10 +581,11 @@ CanWalkOntoTile: ; 516e (1:516e) ld l, a ld a, [hl] ; c2x6 (movement byte 1) cp $fe - jr nc, .canMove ; values $fe and $ff + jr nc, .notScripted ; values $fe and $ff +; always allow walking if the movement is scripted and a ret -.canMove +.notScripted ld a, [W_TILESETCOLLISIONPTR] ld l, a ld a, [W_TILESETCOLLISIONPTR+1] @@ -675,7 +685,7 @@ CanWalkOntoTile: ; 516e (1:516e) ; calculates the tile pointer pointing to the tile the current sprite stancs on ; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to ; hl: output pointer -getTileSpriteStandsOn: ; 5207 (1:5207) +GetTileSpriteStandsOn: ; 5207 (1:5207) ld h, $c1 ld a, [H_CURRENTSPRITEOFFSET] add $4 @@ -713,53 +723,58 @@ LoadDEPlusA: ; 522f (1:522f) ld a, [de] ret -Func_5236: ; 5236 (1:5236) +DoScriptedNPCMovement: ; 5236 (1:5236) +; This is an alternative method of scripting an NPC's movement and is only used +; a few times in the game. It is used when the NPC and player must walk together +; in sync, such as when the player is following the NPC somewhere. An NPC can't +; be moved in sync with the player using the other method. ld a, [wd730] bit 7, a ret z ld hl, wd72e bit 7, [hl] set 7, [hl] - jp z, Func_52a6 + jp z, InitScriptedNPCMovement ld hl, wNPCMovementDirections2 ld a, [wNPCMovementDirections2Index] add l ld l, a - jr nc, .asm_5251 + jr nc, .noCarry inc h -.asm_5251 +.noCarry ld a, [hl] - cp $40 - jr nz, .asm_525f - call Func_52b2 - ld c, $4 - ld a, $fe - jr .asm_5289 -.asm_525f - cp $0 - jr nz, .asm_526c - call Func_52b2 - ld c, $0 - ld a, $2 - jr .asm_5289 -.asm_526c - cp $80 - jr nz, .asm_5279 - call Func_52b7 - ld c, $8 - ld a, $fe - jr .asm_5289 -.asm_5279 - cp $c0 - jr nz, .asm_5286 - call Func_52b7 - ld c, $c - ld a, $2 - jr .asm_5289 -.asm_5286 +; check if moving up + cp NPC_MOVEMENT_UP + jr nz, .checkIfMovingDown + call GetSpriteScreenYPointer + ld c, SPRITE_FACING_UP + ld a, -2 + jr .move +.checkIfMovingDown + cp NPC_MOVEMENT_DOWN + jr nz, .checkIfMovingLeft + call GetSpriteScreenYPointer + ld c, SPRITE_FACING_DOWN + ld a, 2 + jr .move +.checkIfMovingLeft + cp NPC_MOVEMENT_LEFT + jr nz, .checkIfMovingRight + call GetSpriteScreenXPointer + ld c, SPRITE_FACING_LEFT + ld a, -2 + jr .move +.checkIfMovingRight + cp NPC_MOVEMENT_RIGHT + jr nz, .noMatch + call GetSpriteScreenXPointer + ld c, SPRITE_FACING_RIGHT + ld a, 2 + jr .move +.noMatch cp $ff ret -.asm_5289 +.move ld b, a ld a, [hl] add b @@ -768,33 +783,34 @@ Func_5236: ; 5236 (1:5236) add $9 ld l, a ld a, c - ld [hl], a - call Func_52c3 - ld hl, wcf18 + ld [hl], a ; facing direction + call AnimScriptedNPCMovement + ld hl, wScriptedNPCWalkCounter dec [hl] ret nz - ld a, $8 - ld [wcf18], a + ld a, 8 + ld [wScriptedNPCWalkCounter], a ld hl, wNPCMovementDirections2Index inc [hl] ret -Func_52a6: ; 52a6 (1:52a6) +InitScriptedNPCMovement: ; 52a6 (1:52a6) xor a ld [wNPCMovementDirections2Index], a - ld a, $8 - ld [wcf18], a - jp Func_52c3 + ld a, 8 + ld [wScriptedNPCWalkCounter], a + jp AnimScriptedNPCMovement -Func_52b2: ; 52b2 (1:52b2) +GetSpriteScreenYPointer: ; 52b2 (1:52b2) ld a, $4 ld b, a - jr asm_52ba + jr GetSpriteScreenXYPointerCommon -Func_52b7: ; 52b7 (1:52b7) +GetSpriteScreenXPointer: ; 52b7 (1:52b7) ld a, $6 ld b, a -asm_52ba: ; 52ba (1:52ba) + +GetSpriteScreenXYPointerCommon: ; 52ba (1:52ba) ld hl, wSpriteStateData1 ld a, [H_CURRENTSPRITEOFFSET] add l @@ -802,12 +818,12 @@ asm_52ba: ; 52ba (1:52ba) ld l, a ret -Func_52c3: ; 52c3 (1:52c3) +AnimScriptedNPCMovement: ; 52c3 (1:52c3) ld hl, wSpriteStateData2 ld a, [H_CURRENTSPRITEOFFSET] add $e ld l, a - ld a, [hl] + ld a, [hl] ; VRAM slot dec a swap a ld b, a @@ -815,47 +831,47 @@ Func_52c3: ; 52c3 (1:52c3) ld a, [H_CURRENTSPRITEOFFSET] add $9 ld l, a - ld a, [hl] - cp $0 - jr z, .asm_52ea - cp $4 - jr z, .asm_52ea - cp $8 - jr z, .asm_52ea - cp $c - jr z, .asm_52ea + ld a, [hl] ; facing direction + cp SPRITE_FACING_DOWN + jr z, .anim + cp SPRITE_FACING_UP + jr z, .anim + cp SPRITE_FACING_LEFT + jr z, .anim + cp SPRITE_FACING_RIGHT + jr z, .anim ret -.asm_52ea +.anim add b ld b, a - ld [$ffe9], a - call Func_5301 + ld [hSpriteVRAMSlotAndFacing], a + call AdvanceScriptedNPCAnimFrameCounter ld hl, wSpriteStateData1 ld a, [H_CURRENTSPRITEOFFSET] add $2 ld l, a - ld a, [$ffe9] + ld a, [hSpriteVRAMSlotAndFacing] ld b, a - ld a, [$ffea] + ld a, [hSpriteAnimFrameCounter] add b ld [hl], a ret -Func_5301: ; 5301 (1:5301) +AdvanceScriptedNPCAnimFrameCounter: ; 5301 (1:5301) ld a, [H_CURRENTSPRITEOFFSET] add $7 ld l, a - ld a, [hl] + ld a, [hl] ; intra-animation frame counter inc a ld [hl], a - cp $4 + cp 4 ret nz xor a - ld [hl], a + ld [hl], a ; reset intra-animation frame counter inc l - ld a, [hl] + ld a, [hl] ; animation frame counter inc a and $3 ld [hl], a - ld [$ffea], a + ld [hSpriteAnimFrameCounter], a ret diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 73a3fdfb..aabc2de8 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -44,60 +44,66 @@ _EndNPCMovementScript: ; 1a41d (6:641d) ld [wSimulatedJoypadStatesEnd], a ret -ProfOakMovementScriptPointerTable: ; 1a442 (6:6442) - dw Func_1a44c - dw Func_1a485 - dw Func_1a4a1 - dw Func_1a4a6 - dw Func_1a4f4 +PalletMovementScriptPointerTable: ; 1a442 (6:6442) + dw PalletMovementScript_OakMoveLeft + dw PalletMovementScript_PlayerMoveLeft + dw PalletMovementScript_WaitAndWalkToLab + dw PalletMovementScript_WalkToLab + dw PalletMovementScript_Done -Func_1a44c: ; 1a44c (6:644c) +PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c) ld a, [W_XCOORD] sub $a - ld [wcca1], a - jr z, .asm_1a475 - ld b, $0 + ld [wNumStepsToTake], a + jr z, .playerOnLeftTile +; The player is on the right tile of the northern path out of Pallet Town and +; Prof. Oak is below. +; Make Prof. Oak step to the left. + ld b, 0 ld c, a ld hl, wNPCMovementDirections2 - ld a, $80 + ld a, NPC_MOVEMENT_LEFT call FillMemory ld [hl], $ff ld a, [wSpriteIndex] - ld [H_DOWNARROWBLINKCNT2], a + ld [H_SPRITEINDEX], a ld de, wNPCMovementDirections2 call MoveSprite ld a, $1 ld [wNPCMovementScriptFunctionNum], a - jr .asm_1a47a -.asm_1a475 + jr .done +; The player is on the left tile of the northern path out of Pallet Town and +; Prof. Oak is below. +; Prof. Oak is already on the right tile. +.playerOnLeftTile ld a, $3 ld [wNPCMovementScriptFunctionNum], a -.asm_1a47a +.done ld hl, W_FLAGS_D733 set 1, [hl] ld a, $fc ld [wJoyIgnore], a ret -Func_1a485: ; 1a485 (6:6485) +PalletMovementScript_PlayerMoveLeft: ; 1a485 (6:6485) ld a, [wd730] - bit 0, a - ret nz - ld a, [wcca1] + bit 0, a ; is an NPC being moved by a script? + ret nz ; return if Oak is still moving + ld a, [wNumStepsToTake] ld [wSimulatedJoypadStatesIndex], a - ld [$ff95], a + ld [hNPCMovementDirections2Index], a predef ConvertNPCMovementDirectionsToJoypadMasks call StartSimulatingJoypadStates ld a, $2 ld [wNPCMovementScriptFunctionNum], a ret -Func_1a4a1: ; 1a4a1 (6:64a1) +PalletMovementScript_WaitAndWalkToLab: ; 1a4a1 (6:64a1) ld a, [wSimulatedJoypadStatesIndex] - and a + and a ; is the player done moving left yet? ret nz -Func_1a4a6: ; 1a4a6 (6:64a6) +PalletMovementScript_WalkToLab: ; 1a4a6 (6:64a6) xor a ld [wOverrideSimulatedJoypadStatesMask], a ld a, [wSpriteIndex] @@ -122,12 +128,12 @@ Func_1a4a6: ; 1a4a6 (6:64a6) ret RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc) - db $00, $05 - db $80, $01 - db $00, $05 - db $C0, $03 - db $40, $01 - db $E0, $01 + db NPC_MOVEMENT_DOWN, $05 + db NPC_MOVEMENT_LEFT, $01 + db NPC_MOVEMENT_DOWN, $05 + db NPC_MOVEMENT_RIGHT, $03 + db NPC_MOVEMENT_UP, $01 + db $E0, $01 ; stand still db $FF RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9) @@ -138,7 +144,7 @@ RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9) db D_DOWN, $06 db $FF -Func_1a4f4: ; 1a4f4 (6:64f4) +PalletMovementScript_Done: ; 1a4f4 (6:64f4) ld a, [wSimulatedJoypadStatesIndex] and a ret nz @@ -152,10 +158,10 @@ Func_1a4f4: ; 1a4f4 (6:64f4) jp EndNPCMovementScript PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510) - dw Func_1a514 - dw PewterMovementScriptDone + dw PewterMovementScript_WalkToMuseum + dw PewterMovementScript_Done -Func_1a514: ; 1a514 (6:6514) +PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514) ld a, BANK(Music_MuseumGuy) ld [wc0ef], a ld [wc0f0], a @@ -191,13 +197,13 @@ RLEList_PewterMuseumPlayer: ; 1a559 (6:6559) db $FF RLEList_PewterMuseumGuy: ; 1a562 (6:6562) - db $40, $06 - db $80, $0D - db $40, $03 - db $80, $01 + db NPC_MOVEMENT_UP, $06 + db NPC_MOVEMENT_LEFT, $0D + db NPC_MOVEMENT_UP, $03 + db NPC_MOVEMENT_LEFT, $01 db $FF -PewterMovementScriptDone: ; 1a56b (6:656b) +PewterMovementScript_Done: ; 1a56b (6:656b) ld a, [wSimulatedJoypadStatesIndex] and a ret nz @@ -208,10 +214,10 @@ PewterMovementScriptDone: ; 1a56b (6:656b) jp EndNPCMovementScript PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d) - dw Func_1a581 - dw PewterMovementScriptDone + dw PewterMovementScript_WalkToGym + dw PewterMovementScript_Done -Func_1a581: ; 1a581 (6:6581) +PewterMovementScript_WalkToGym: ; 1a581 (6:6581) ld a, BANK(Music_MuseumGuy) ld [wc0ef], a ld [wc0f0], a @@ -252,12 +258,12 @@ RLEList_PewterGymPlayer: ; 1a5cd (6:65cd) db $FF RLEList_PewterGymGuy: ; 1a5da (6:65da) - db $00, $02 - db $80, $0F - db $40, $05 - db $80, $0B - db $00, $05 - db $C0, $03 + db NPC_MOVEMENT_DOWN, $02 + db NPC_MOVEMENT_LEFT, $0F + db NPC_MOVEMENT_UP, $05 + db NPC_MOVEMENT_LEFT, $0B + db NPC_MOVEMENT_DOWN, $05 + db NPC_MOVEMENT_RIGHT, $03 db $FF FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7) diff --git a/engine/overworld/oam.asm b/engine/overworld/oam.asm index b4247257..41360965 100644 --- a/engine/overworld/oam.asm +++ b/engine/overworld/oam.asm @@ -4,25 +4,26 @@ PrepareOAMData: ld a, [wUpdateSpritesEnabled] dec a - jr z, .asm_4b1e + jr z, .updateEnabled cp 0 - 1 ret nz ld [wUpdateSpritesEnabled], a jp HideSprites -.asm_4b1e +.updateEnabled xor a - ld [$ff90], a -.asm_4b21 - ld [$ff8f], a + ld [hOAMBufferOffset], a + +.spriteLoop + ld [hSpriteOffset2], a ld d, wSpriteStateData1 / $100 - ld a, [$ff8f] + ld a, [hSpriteOffset2] ld e, a ld a, [de] ; c1x0 and a - jp z, .asm_4bad + jp z, .nextSprite inc e inc e @@ -31,21 +32,25 @@ PrepareOAMData: cp $ff ; off-screen (don't draw) jr nz, .visible - call Func_4bd1 - jr .asm_4bad + call GetSpriteScreenXY + jr .nextSprite .visible - cp $a0 + cp $a0 ; is the sprite unchanging like an item ball or boulder? jr c, .usefacing + +; unchanging and $f - add $10 - jr .asm_4b48 + add $10 ; skip to the second half of the table which doesn't account for facing direction + jr .next .usefacing and $f -.asm_4b48 + +.next ld l, a +; get sprite priority push de inc d ld a, e @@ -53,15 +58,15 @@ PrepareOAMData: ld e, a ld a, [de] ; c2x7 and $80 - ld [$ff94], a ; temp store sprite priority + ld [hSpritePriority], a ; temp store sprite priority pop de +; read the entry from the table ld h, 0 ld bc, SpriteFacingAndAnimationTable add hl, hl add hl, hl add hl, bc - ld a, [hli] ld c, a ld a, [hli] @@ -70,24 +75,25 @@ PrepareOAMData: ld h, [hl] ld l, a - call Func_4bd1 + call GetSpriteScreenXY - ld a, [$ff90] + ld a, [hOAMBufferOffset] ld e, a ld d, wOAMBuffer / $100 -.tile - ld a, [$ff92] ; temp for sprite Y position + +.tileLoop + ld a, [hSpriteScreenY] ; temp for sprite Y position add $10 ; Y=16 is top of screen (Y=0 is invisible) add [hl] ; add Y offset from table ld [de], a ; write new sprite OAM Y position inc hl - ld a, [$ff91] ; temp for sprite X position + ld a, [hSpriteScreenX] ; temp for sprite X position add $8 ; X=8 is left of screen (X=0 is invisible) add [hl] ; add X offset from table inc e ld [de], a ; write new sprite OAM X position inc e - ld a, [bc] ; read pattern number offset (accomodates orientation (offset 0,4 or 8) and animation (offset 0 or $80)) + ld a, [bc] ; read pattern number offset (accommodates orientation (offset 0,4 or 8) and animation (offset 0 or $80)) inc bc push bc ld b, a @@ -99,55 +105,60 @@ PrepareOAMData: ; Sprites $a and $b have one face (and therefore 4 tiles instead of 12). ; As a result, sprite $b's tile offset is less than normal. cp $b - jr nz, .offset + jr nz, .notFourTileSprite ld a, $a * 12 + 4 - jr .gotoffset + jr .next2 -.offset +.notFourTileSprite ; a *= 12 sla a sla a ld c, a sla a add c -.gotoffset - add b ; which frame + +.next2 + add b ; add the tile offset from the table (based on frame and facing direction) pop bc ld [de], a ; tile id inc hl inc e ld a, [hl] - bit 1, a ; sprite priority - jr z, .fg - ld a, [$ff94] ; facing priority + bit 1, a ; is the tile allowed to set the sprite priority bit? + jr z, .skipPriority + ld a, [hSpritePriority] or [hl] -.fg +.skipPriority inc hl ld [de], a inc e bit 0, a ; OAMFLAG_ENDOFDATA - jr z, .tile + jr z, .tileLoop ld a, e - ld [$ff90], a + ld [hOAMBufferOffset], a -.asm_4bad - ld a, [$ff8f] +.nextSprite + ld a, [hSpriteOffset2] add $10 cp $100 % $100 - jp nz, .asm_4b21 + jp nz, .spriteLoop ; Clear unused OAM. - ld a, [$ff90] + ld a, [hOAMBufferOffset] ld l, a ld h, wOAMBuffer / $100 ld de, $4 ld b, $a0 ld a, [wd736] - bit 6, a + bit 6, a ; jumping down ledge or fishing animation? ld a, $a0 jr z, .clear + +; Don't clear the last 4 entries because they are used for the shadow in the +; jumping down ledge animation and the rod in the fishing animation. ld a, $90 + .clear cp l ret z @@ -155,24 +166,24 @@ PrepareOAMData: add hl, de jr .clear -Func_4bd1: ; 4bd1 (1:4bd1) +GetSpriteScreenXY: ; 4bd1 (1:4bd1) inc e inc e ld a, [de] ; c1x4 - ld [$ff92], a + ld [hSpriteScreenY], a inc e inc e ld a, [de] ; c1x6 - ld [$ff91], a - ld a, $4 + ld [hSpriteScreenX], a + ld a, 4 add e ld e, a - ld a, [$ff92] - add $4 + ld a, [hSpriteScreenY] + add 4 and $f0 ld [de], a ; c1xa (y) inc e - ld a, [$ff91] + ld a, [hSpriteScreenX] and $f0 ld [de], a ; c1xb (x) ret diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index d68e4e57..98ea466d 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -1,5 +1,5 @@ EnterMapAnim: ; 70510 (1c:4510) - call InitFacingDirectionBuffer + call InitFacingDirectionList ld a, $ec ld [wSpriteStateData1 + 4], a ; player's sprite Y screen position call Delay3 @@ -32,7 +32,7 @@ EnterMapAnim: ; 70510 (1c:4510) ld a, $8 ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue ld [hl], $ff ; wPlayerSpinInPlaceAnimSoundID - ld hl, wcd48 + ld hl, wFacingDirectionList call PlayerSpinInPlace .restoreDefaultMusic call PlayDefaultMusic @@ -91,7 +91,7 @@ PlayerSpinWhileMovingDown: ; 705aa (1c:45aa) jp PlayerSpinWhileMovingUpOrDown _LeaveMapAnim: ; 705ba (1c:45ba) - call InitFacingDirectionBuffer + call InitFacingDirectionList call IsPlayerStandingOnWarpPadOrHole ld a, b and a @@ -134,7 +134,7 @@ _LeaveMapAnim: ; 705ba (1c:45ba) xor a ld [hli], a ; wPlayerSpinInPlaceAnimFrameDelayEndValue ld [hl], (SFX_02_4d - SFX_Headers_02) / 3 ; wPlayerSpinInPlaceAnimSoundID - ld hl, wcd48 + ld hl, wFacingDirectionList call PlayerSpinInPlace jr .spinWhileMovingUp .flyAnimation @@ -214,7 +214,7 @@ LeaveMapThroughHoleAnim: ; 7067d (1c:467d) ld [wOAMBuffer + 1 * 4], a ld c, 2 call DelayFrames - ; hide lower half of player's sprite + ; hide upper half of player's sprite ld a, $a0 ld [wOAMBuffer + 2 * 4], a ld [wOAMBuffer + 3 * 4], a @@ -231,7 +231,7 @@ DoFlyAnimation: ; 706ae (1c:46ae) call Delay3 ld a, [wFlyAnimUsingCoordList] cp $ff - jr z, .asm_706cd + jr z, .skipCopyingCoords ; if the bird is flapping its wings in place ld hl, wSpriteStateData1 + 4 ld a, [de] inc de @@ -240,7 +240,7 @@ DoFlyAnimation: ; 706ae (1c:46ae) ld a, [de] inc de ld [hl], a -.asm_706cd +.skipCopyingCoords ld a, [wFlyAnimCounter] dec a ld [wFlyAnimCounter], a @@ -252,22 +252,23 @@ LoadBirdSpriteGraphics: ; 706d7 (1c:46d7) ld hl, vNPCSprites ld bc, (BANK(BirdSprite) << 8) + $0c call CopyVideoData - ld de, BirdSprite + $c0 ; moving amination sprite + ld de, BirdSprite + $c0 ; moving animation sprite ld hl, vNPCSprites2 ld bc, (BANK(BirdSprite) << 8) + $0c jp CopyVideoData -InitFacingDirectionBuffer: ; 706ef (1c:46ef) +InitFacingDirectionList: ; 706ef (1c:46ef) ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) - ld [wcd50], a + ld [wSavedPlayerFacingDirection], a ld a, [wSpriteStateData1 + 4] ; player's sprite Y screen position - ld [wcd4f], a + ld [wSavedPlayerScreenY], a ld hl, PlayerSpinningFacingOrder - ld de, wcd48 - ld bc, $4 + ld de, wFacingDirectionList + ld bc, 4 call CopyData ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction (image index is locked to standing images) - ld hl, wcd48 + ld hl, wFacingDirectionList +; find the place in the list that matches the current facing direction .loop cp [hl] inc hl @@ -281,15 +282,16 @@ PlayerSpinningFacingOrder: ; 70713 (1c:4713) db SPRITE_FACING_DOWN, SPRITE_FACING_LEFT, SPRITE_FACING_UP, SPRITE_FACING_RIGHT SpinPlayerSprite: ; 70717 (1c:4717) +; copy the current value from the list into the sprite data and rotate the list ld a, [hl] ld [wSpriteStateData1 + 2], a ; player's sprite facing direction (image index is locked to standing images) push hl - ld hl, wcd48 - ld de, wcd47 - ld bc, $4 + ld hl, wFacingDirectionList + ld de, wFacingDirectionList - 1 + ld bc, 4 call CopyData - ld a, [wcd47] - ld [wcd4b], a + ld a, [wFacingDirectionList - 1] + ld [wFacingDirectionList + 3], a pop hl ret @@ -298,11 +300,12 @@ PlayerSpinInPlace: ; 70730 (1c:4730) ld a, [wPlayerSpinInPlaceAnimFrameDelay] ld c, a and $3 - jr nz, .asm_70743 + jr nz, .skipPlayingSound +; when the last delay was a multiple of 4, play a sound if there is one ld a, [wPlayerSpinInPlaceAnimSoundID] cp $ff call nz, PlaySound -.asm_70743 +.skipPlayingSound ld a, [wPlayerSpinInPlaceAnimFrameDelayDelta] add c ld [wPlayerSpinInPlaceAnimFrameDelay], a @@ -330,9 +333,9 @@ PlayerSpinWhileMovingUpOrDown: ; 70755 (1c:4755) jr PlayerSpinWhileMovingUpOrDown RestoreFacingDirectionAndYScreenPos: ; 70772 (1c:4772) - ld a, [wcd4f] + ld a, [wSavedPlayerScreenY] ld [wSpriteStateData1 + 4], a - ld a, [wcd50] + ld a, [wSavedPlayerFacingDirection] ld [wSpriteStateData1 + 2], a ret @@ -378,11 +381,11 @@ IsPlayerStandingOnWarpPadOrHole: ; 70787 (1c:4787) db INTERIOR, $55, 1 ; warp pad db $FF -Func_707b6: ; 707b6 (1c:47b6) +FishingAnim: ; 707b6 (1c:47b6) ld c, 10 call DelayFrames ld hl, wd736 - set 6, [hl] + set 6, [hl] ; reserve the last 4 OAM entries ld de, RedSprite ld hl, vNPCSprites ld bc, (BANK(RedSprite) << 8) + $0c @@ -393,55 +396,67 @@ Func_707b6: ; 707b6 (1c:47b6) ld a, [wSpriteStateData1 + 2] ld c, a ld b, $0 - ld hl, FishingRodGfxProperties + ld hl, FishingRodOAM add hl, bc ld de, wOAMBuffer + $9c ld bc, $4 call CopyData ld c, 100 call DelayFrames - ld a, [wWhichTrade] + ld a, [wRodResponse] and a ld hl, NoNibbleText - jr z, .asm_70836 + jr z, .done cp $2 ld hl, NothingHereText - jr z, .asm_70836 - ld b, $a -.asm_707fe - ld hl, wSpriteStateData1 + 4 - call Func_70842 + jr z, .done + +; there was a bite + +; shake the player's sprite vertically + ld b, 10 +.loop + ld hl, wSpriteStateData1 + 4 ; player's sprite Y screen position + call .ShakePlayerSprite ld hl, wOAMBuffer + $9c - call Func_70842 + call .ShakePlayerSprite call Delay3 dec b - jr nz, .asm_707fe - ld a, [wSpriteStateData1 + 2] - cp $4 - jr nz, .asm_7081c + jr nz, .loop + +; If the player is facing up, hide the fishing rod so it doesn't overlap with +; the exclamation bubble that will be shown next. + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr nz, .skipHidingFishingRod ld a, $a0 ld [wOAMBuffer + $9c], a -.asm_7081c - ld hl, wcd4f + +.skipHidingFishingRod + ld hl, wEmotionBubbleSpriteIndex xor a - ld [hli], a - ld [hl], a + ld [hli], a ; player's sprite + ld [hl], a ; EXCLAMATION_BUBBLE predef EmotionBubble - ld a, [wSpriteStateData1 + 2] - cp $4 - jr nz, .asm_70833 + +; If the player is facing up, unhide the fishing rod. + ld a, [wSpriteStateData1 + 2] ; player's sprite facing direction + cp SPRITE_FACING_UP + jr nz, .skipUnhidingFishingRod ld a, $44 ld [wOAMBuffer + $9c], a -.asm_70833 + +.skipUnhidingFishingRod ld hl, ItsABiteText -.asm_70836 + +.done call PrintText ld hl, wd736 - res 6, [hl] + res 6, [hl] ; unreserve the last 4 OAM entries call LoadFontTilePatterns ret -Func_70842: ; 70842 (1c:4842) +.ShakePlayerSprite ld a, [hl] xor $1 ld [hl], a @@ -459,7 +474,7 @@ ItsABiteText: ; 70851 (1c:4851) TX_FAR _ItsABiteText db "@" -FishingRodGfxProperties: ; 70856 (1c:4856) +FishingRodOAM: ; 70856 (1c:4856) ; specifies how the fishing rod should be drawn on the screen ; first byte = screen y coordinate ; second byte = screen x coordinate diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index de18a1ab..2caada1d 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -57,9 +57,9 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call DisplayTextBoxID ; draw money text box ld hl,wNumBagItems ld a,l - ld [wList],a + ld [wListPointer],a ld a,h - ld [wList + 1],a + ld [wListPointer + 1],a xor a ld [wPrintItemPrices],a ld [wCurrentMenuItem],a @@ -136,11 +136,11 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld a,MONEY_BOX ld [wTextBoxID],a call DisplayTextBoxID - ld hl,wStringBuffer2 + 11 + ld hl,wItemList ld a,l - ld [wList],a + ld [wListPointer],a ld a,h - ld [wList + 1],a + ld [wListPointer + 1],a xor a ld [wCurrentMenuItem],a inc a diff --git a/engine/overworld/ssanne.asm b/engine/overworld/ssanne.asm index 4cac4957..a59ae794 100755 --- a/engine/overworld/ssanne.asm +++ b/engine/overworld/ssanne.asm @@ -1,6 +1,6 @@ AnimateBoulderDust: ; 79f54 (1e:5f54) ld a, $1 - ld [wcd50], a ; select the boulder dust offsets + ld [wWhichAnimationOffsets], a ; select the boulder dust offsets ld a, [wUpdateSpritesEnabled] push af ld a, $ff diff --git a/engine/predefs.asm b/engine/predefs.asm index a8aba971..1af240ce 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -57,7 +57,7 @@ PredefPointers:: ; 4fe79 (13:7e79) add_predef AnimateSendingOutMon add_predef ScaleSpriteByTwo add_predef LoadMonBackPic - add_predef CopyGrowingMonTiles + add_predef CopyDownscaledMonTiles add_predef LoadMissableObjects add_predef HealParty add_predef MoveAnimation; 08 play move animation diff --git a/engine/predefs7.asm b/engine/predefs7.asm index 82a073dc..af013733 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -1,11 +1,11 @@ Func_1c9c6: ; 1c9c6 (7:49c6) ld hl, WhichFloorText call PrintText - ld hl, wStringBuffer2 + 11 + ld hl, wItemList ld a, l - ld [wList], a + ld [wListPointer], a ld a, h - ld [wList + 1], a + ld [wListPointer + 1], a ld a, [wListScrollOffset] push af xor a diff --git a/engine/save.asm b/engine/save.asm index 4849c53e..6dc1a46c 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -309,7 +309,7 @@ Func_73863: ; 73863 (1c:7863) Func_7387b: ; 7387b (1c:787b) ld hl, PointerTable_73895 - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f cp NUM_BOXES / 2 ld b, $2 @@ -341,7 +341,7 @@ ChangeBox:: ; 738a1 (1c:78a1) ld a, [wCurrentMenuItem] and a ret nz ; return if No was chosen - ld hl, wd5a0 + ld hl, wCurrentBoxNum bit 7, [hl] call z, Func_73a29 call Func_7393f @@ -360,7 +360,7 @@ ChangeBox:: ; 738a1 (1c:78a1) call Func_7390e ld a, [wCurrentMenuItem] set 7, a - ld [wd5a0], a + ld [wCurrentBoxNum], a call Func_7387b ld de, W_NUMINBOX call Func_7390e @@ -422,7 +422,7 @@ Func_7393f: ; 7393f (1c:793f) ld [wTopMenuItemX], a xor a ld [wMenuWatchMovingOutOfBounds], a - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f ld [wCurrentMenuItem], a ld [wLastMenuItem], a @@ -443,7 +443,7 @@ Func_7393f: ; 7393f (1c:793f) call PlaceString ld hl, hFlags_0xFFF6 res 2, [hl] - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f cp 9 jr c, .asm_739a6 @@ -561,7 +561,7 @@ Func_73a84: ; 73a84 (1c:7a84) ld [MBC1SRamBankingMode], a ld [MBC1SRamEnable], a pop hl - ld a, [wd5a0] + ld a, [wCurrentBoxNum] and $7f ld c, a ld b, $0 @@ -620,9 +620,9 @@ SAVCheckRandomID: ; 73ad1 (1c:7ad1) ret SaveHallOfFameTeams: ; 73b0d (1c:7b0d) - ld a, [wd5a2] + ld a, [wNumHoFTeams] dec a - cp NUM_HOF_TEAMS + cp HOF_TEAM_CAPACITY jr nc, .asm_73b28 ld hl, sHallOfFame ld bc, HOF_TEAM @@ -636,10 +636,10 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d) .asm_73b28 ld hl, sHallOfFame + HOF_TEAM ld de, sHallOfFame - ld bc, HOF_TEAM * (NUM_HOF_TEAMS - 1) + ld bc, HOF_TEAM * (HOF_TEAM_CAPACITY - 1) call HallOfFame_Copy ld hl, wcc5b - ld de, sHallOfFame + HOF_TEAM * (NUM_HOF_TEAMS - 1) + ld de, sHallOfFame + HOF_TEAM * (HOF_TEAM_CAPACITY - 1) ld bc, HOF_TEAM jr HallOfFame_Copy diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 69a3a20e..7230f08f 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -12,7 +12,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7) call CopyFixedLengthText xor a ld [hWY], a - ld [wd358], a + ld [wLetterPrintingDelayFlags], a ld hl, wd732 ld [hli], a ld [hli], a @@ -284,7 +284,7 @@ Func_44c1: ; 44c1 (1:44c1) Func_44cf: ; 44cf (1:44cf) .wait - ld a, [$ff44] ; rLY + ld a, [rLY] cp l jr nz, .wait @@ -292,7 +292,7 @@ Func_44cf: ; 44cf (1:44cf) ld [rSCX], a .wait2 - ld a, [$ff44] ; rLY + ld a, [rLY] cp h jr z, .wait2 ret diff --git a/engine/titlescreen2.asm b/engine/titlescreen2.asm index 57e5c3d5..61b97edc 100755 --- a/engine/titlescreen2.asm +++ b/engine/titlescreen2.asm @@ -69,7 +69,7 @@ _TitleScroll: ; 3726a (d:726a) .ScrollBetween ; 37292 (d:7292) .wait - ld a, [$ff44] ; rLY + ld a, [rLY] ; rLY cp l jr nz, .wait @@ -77,7 +77,7 @@ _TitleScroll: ; 3726a (d:726a) ld [rSCX], a .wait2 - ld a, [$ff44] ; rLY + ld a, [rLY] ; rLY cp h jr z, .wait2 ret |