From a957bb154046427966d6e00de526adab13388938 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 12 Jul 2015 15:51:04 -0700 Subject: some battle animation stuff --- engine/battle/core.asm | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index ec67d094..db1ebd32 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -848,7 +848,7 @@ FaintEnemyPokemon: ; 0x3c567 ld [hl], a ld [W_ENEMYDISABLEDMOVE], a ld [wEnemyDisabledMoveNumber], a - ld [wccf3], a + ld [wEnemyMonMinimized], a ld hl, wPlayerUsedMove ld [hli], a ld [hl], a @@ -1376,7 +1376,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld [hl],a ld [W_ENEMYDISABLEDMOVE],a ld [wEnemyDisabledMoveNumber],a - ld [wccf3],a + ld [wEnemyMonMinimized],a ld hl,wPlayerUsedMove ld [hli],a ld [hl],a @@ -1826,7 +1826,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld [hl], a ld [W_PLAYERDISABLEDMOVE], a ld [wPlayerDisabledMoveNumber], a - ld [wccf7], a + ld [wPlayerMonMinimized], a ld b, $1 call GoPAL_SET ld hl, W_ENEMYBATTSTATUS1 @@ -2448,7 +2448,7 @@ PartyMenuOrRockOrRun: ld hl, AnimationSubstitute jr nz, .doEnemyMonAnimation ; enemy mon doesn't have substitute - ld a, [wccf3] + ld a, [wEnemyMonMinimized] and a ; has the enemy mon used Minimise? ld hl, AnimationMinimizeMon jr nz, .doEnemyMonAnimation @@ -3215,9 +3215,9 @@ getPlayerAnimationType playPlayerMoveAnimation push af ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79747 - ld b,BANK(Func_79747) + bit HasSubstituteUp,a + ld hl,HideSubstituteShowMonAnim + ld b,BANK(HideSubstituteShowMonAnim) call nz,Bankswitch pop af ld [wAnimationType],a @@ -3226,9 +3226,9 @@ playPlayerMoveAnimation call HandleExplodingAnimation call DrawPlayerHUDAndHPBar ld a,[W_PLAYERBATTSTATUS2] - bit 4,a - ld hl,Func_79771 - ld b,BANK(Func_79771) + bit HasSubstituteUp,a + ld hl,ReshowSubstituteAnim + ld b,BANK(ReshowSubstituteAnim) call nz,Bankswitch jr MirrorMoveCheck playerCheckIfFlyOrChargeEffect @@ -5089,7 +5089,7 @@ AttackSubstitute: ; 3e25e (f:625e) ld a,[H_WHOSETURN] xor a,$01 ld [H_WHOSETURN],a - callab Func_79747 ; animate the substitute breaking + callab HideSubstituteShowMonAnim ; animate the substitute breaking ; flip the turn back to the way it was ld a,[H_WHOSETURN] xor a,$01 @@ -5767,8 +5767,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4) push af ld a, [W_ENEMYBATTSTATUS2] bit HasSubstituteUp, a ; does mon have a substitute? - ld hl, Func_79747 - ld b, BANK(Func_79747) + ld hl, HideSubstituteShowMonAnim + ld b, BANK(HideSubstituteShowMonAnim) call nz, Bankswitch pop af ld [wAnimationType], a @@ -5778,8 +5778,8 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4) call DrawEnemyHUDAndHPBar ld a, [W_ENEMYBATTSTATUS2] bit HasSubstituteUp, a ; does mon have a substitute? - ld hl, Func_79771 - ld b, BANK(Func_79771) + ld hl, ReshowSubstituteAnim + ld b, BANK(ReshowSubstituteAnim) call nz, Bankswitch ; slide the substitute's sprite out jr EnemyCheckIfMirrorMoveEffect @@ -7657,24 +7657,26 @@ UpdateStatDone: ; 3f4ca (f:74ca) call PrintStatText ld hl, W_PLAYERBATTSTATUS2 ld de, W_PLAYERMOVENUM - ld bc, wccf7 + ld bc, wPlayerMonMinimized ld a, [H_WHOSETURN] and a jr z, .asm_3f4e6 ld hl, W_ENEMYBATTSTATUS2 ld de, W_ENEMYMOVENUM - ld bc, wccf3 + ld bc, wEnemyMonMinimized .asm_3f4e6 ld a, [de] cp MINIMIZE jr nz, .asm_3f4f9 - bit HasSubstituteUp, [hl] ; substitute + ; if a substitute is up, slide off the substitute and show the mon pic before + ; playing the minimize animation + bit HasSubstituteUp, [hl] push af push bc - ld hl, Func_79747 - ld b, BANK(Func_79747) + ld hl, HideSubstituteShowMonAnim + ld b, BANK(HideSubstituteShowMonAnim) push de - call nz, Bankswitch ; play Minimize animation unless there's Substitute involved + call nz, Bankswitch pop de .asm_3f4f9 call PlayCurrentMoveAnimation @@ -7684,8 +7686,8 @@ UpdateStatDone: ; 3f4ca (f:74ca) pop bc ld a, $1 ld [bc], a - ld hl, Func_79771 - ld b, BANK(Func_79771) + ld hl, ReshowSubstituteAnim + ld b, BANK(ReshowSubstituteAnim) pop af call nz, Bankswitch .applyBadgeBoostsAndStatusPenalties -- cgit v1.3.1-sl0p From 849b53623b2ace56ef40b7bbdefe29a86e10162e Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 12 Jul 2015 16:24:03 -0700 Subject: shake screen functions --- engine/battle/animations.asm | 8 +++---- engine/battle/core.asm | 2 +- engine/predefs.asm | 4 ++-- engine/predefs12.asm | 54 ++++++++++++++++++++++++-------------------- home/vblank.asm | 2 +- wram.asm | 2 +- 6 files changed, 39 insertions(+), 33 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 939c8db0..8b3b9147 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -835,9 +835,9 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9) ; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically .shakeScreen ld b,1 - predef Func_48125 ; shake horizontally + predef PredefShakeScreenHorizontally ; shake horizontally ld b,1 - predef_jump Func_480ff ; shake vertically + predef_jump PredefShakeScreenVertically ; shake vertically FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7) ld a,[W_SUBANIMCOUNTER] @@ -1225,14 +1225,14 @@ SetAnimationBGPalette: ; 791fc (1e:51fc) ld b, $5 AnimationShakeScreenVertically: ; 79209 (1e:5209) - predef_jump Func_480ff + predef_jump PredefShakeScreenVertically AnimationShakeScreen: ; 7920e (1e:520e) ; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations. ld b, $8 AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210) - predef_jump Func_48125 + predef_jump PredefShakeScreenHorizontally AnimationWaterDropletsEverywhere: ; 79215 (1e:5215) ; Draws water droplets all over the screen and makes them diff --git a/engine/battle/core.asm b/engine/battle/core.asm index db1ebd32..364b184b 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -3958,7 +3958,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld hl, KeptGoingAndCrashedText call PrintText ld b, $4 - predef Func_48125 + predef PredefShakeScreenHorizontally ld a, [H_WHOSETURN] and a jr nz, .enemyTurn diff --git a/engine/predefs.asm b/engine/predefs.asm index 90065d51..a8aba971 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -85,10 +85,10 @@ PredefPointers:: ; 4fe79 (13:7e79) dbw $03,GiveItem add_predef ChangeBGPalColor0_4Frames add_predef FindPathToPlayer - add_predef Func_480ff + add_predef PredefShakeScreenVertically add_predef CalcPositionOfPlayerRelativeToNPC add_predef ConvertNPCMovementDirectionsToJoypadMasks - add_predef Func_48125 + add_predef PredefShakeScreenHorizontally add_predef UpdateHPBar add_predef HPBarLength add_predef Diploma_TextBoxBorder diff --git a/engine/predefs12.asm b/engine/predefs12.asm index f318447e..9731134f 100755 --- a/engine/predefs12.asm +++ b/engine/predefs12.asm @@ -4,62 +4,68 @@ ChangeBGPalColor0_4Frames: ; 480eb (12:40eb) ld a, [rBGP] or b ld [rBGP], a - ld c, 4 + ld c, $4 call DelayFrames ld a, [rBGP] and %11111100 ld [rBGP], a ret -Func_480ff: ; 480ff (12:40ff) +PredefShakeScreenVertically: ; 480ff (12:40ff) +; Moves the window down and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. call GetPredefRegisters - ld a, $1 - ld [wd0a0], a + ld a, 1 + ld [wDisableVBlankWYUpdate], a xor a -.asm_48108 - ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND) - call Func_48119 - call Func_48119 +.loop + ld [$ff96], a + call .MutateWY + call .MutateWY dec b ld a, b - jr nz, .asm_48108 + jr nz, .loop xor a - ld [wd0a0], a + ld [wDisableVBlankWYUpdate], a ret -Func_48119: ; 48119 (12:4119) - ld a, [H_NUMTOPRINT] ; (aliases: H_MULTIPLICAND) +.MutateWY ; 48119 (12:4119) + ld a, [$ff96] xor b - ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND) + ld [$ff96], a ld [rWY], a ld c, 3 jp DelayFrames -Func_48125: ; 48125 (12:4125) +PredefShakeScreenHorizontally: ; 48125 (12:4125) +; Moves the window right and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. call GetPredefRegisters xor a -.asm_48129 +.loop ld [$ff97], a - call Func_4813f + call .MutateWX ld c, 1 call DelayFrames - call Func_4813f + call .MutateWX dec b ld a, b - jr nz, .asm_48129 - ld a, $7 + jr nz, .loop + +; restore normal WX + ld a, 7 ld [rWX], a ret -Func_4813f: ; 4813f (12:413f) +.MutateWX ; 4813f (12:413f) ld a, [$ff97] xor b ld [$ff97], a bit 7, a - jr z, .asm_48149 - xor a -.asm_48149 - add $7 + jr z, .skipZeroing + xor a ; zero a if it's negative +.skipZeroing + add 7 ld [rWX], a ld c, 4 jp DelayFrames diff --git a/home/vblank.asm b/home/vblank.asm index d8288187..9adf537c 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -13,7 +13,7 @@ VBlank:: ld a, [hSCY] ld [rSCY], a - ld a, [wd0a0] + ld a, [wDisableVBlankWYUpdate] and a jr nz, .ok ld a, [hWY] diff --git a/wram.asm b/wram.asm index 2fbbd7ec..83aa4e60 100755 --- a/wram.asm +++ b/wram.asm @@ -1223,7 +1223,7 @@ W_FBMODE:: ; d09e wNewTileBlockID:: ; d09f wd09f:: ds 1 ; used with predef ReplaceTileBlock -wd0a0:: ds 1 ; used in VBlank and ChangeBGPalColor0_4Frames +wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank W_SPRITECURPOSX:: ; d0a1 ds 1 -- cgit v1.3.1-sl0p From 99df5f0fd79f063ee4c7ec364eadd175a3d83c42 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 12 Jul 2015 16:37:06 -0700 Subject: use constant for bg transfer dest hram var --- engine/HoF_room_pc.asm | 2 +- engine/battle/animations.asm | 2 +- engine/battle/core.asm | 4 ++-- engine/titlescreen.asm | 2 +- home/init.asm | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index c33e9141..14382288 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -130,7 +130,7 @@ Func_74164: ; 74164 (1d:4164) ld a, l ld [H_AUTOBGTRANSFERDEST], a ld a, h - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a jp Delay3 diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 8b3b9147..a54233d0 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -2871,7 +2871,7 @@ Func_79de9: ; 79de9 (1e:5de9) Func_79e0d: ; 79e0d (1e:5e0d) ld a, h - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a ld a, l ld [H_AUTOBGTRANSFERDEST], a jp Delay3 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 364b184b..bb7c4990 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -6943,12 +6943,12 @@ InitBattle_Common: ; 3efeb (f:6feb) call SaveScreenTilesToBuffer1 call ClearScreen ld a, $98 - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a call Delay3 ld a, $9c - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a call LoadScreenTilesFromBuffer1 hlCoord 9, 7 ld bc, $50a diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index e582d1be..1d640909 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -348,7 +348,7 @@ Func_4524: ; 4524 (1:4524) jp LoadFrontSpriteByMonIndex Func_4533: ; 4533 (1:4533) - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a jp Delay3 LoadCopyrightAndTextBoxTiles: ; 4538 (1:4538) diff --git a/home/init.asm b/home/init.asm index 4ac2a4eb..5a74dca9 100644 --- a/home/init.asm +++ b/home/init.asm @@ -101,9 +101,9 @@ rLCDC_DEFAULT EQU %11100011 ld [wc0ef], a ld [wc0f0], a ld a, $9c - ld [$ffbd], a + ld [H_AUTOBGTRANSFERDEST + 1], a xor a - ld [$ffbc], a + ld [H_AUTOBGTRANSFERDEST], a dec a ld [wUpdateSpritesEnabled], a -- cgit v1.3.1-sl0p From 4a8c9993ad182296131ef87111e1b6d6e2af4201 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 12 Jul 2015 23:00:48 -0700 Subject: named wram variables --- constants/list_constants.asm | 6 +++ constants/misc_constants.asm | 8 +++ engine/battle/bank_e_misc.asm | 10 ++-- engine/battle/core.asm | 6 +-- engine/cable_club.asm | 18 +++---- engine/items/items.asm | 22 ++++---- engine/menu/bills_pc.asm | 6 +-- engine/menu/pc.asm | 2 +- engine/menu/players_pc.asm | 18 +++---- engine/menu/start_sub_menus.asm | 4 +- engine/oak_speech.asm | 2 +- engine/overworld/pokemart.asm | 112 +++++++++++++++++++++++----------------- engine/predefs7.asm | 2 +- home.asm | 69 +++++++++++++------------ home/overworld.asm | 2 +- hram.asm | 2 + main.asm | 63 +++++++++++----------- scripts/ceruleanhouse2.asm | 2 +- scripts/daycarem.asm | 6 +-- scripts/oakslab.asm | 2 +- wram.asm | 64 ++++++++++++++++++----- 21 files changed, 253 insertions(+), 173 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/constants/list_constants.asm b/constants/list_constants.asm index aab542ec..8027731d 100755 --- a/constants/list_constants.asm +++ b/constants/list_constants.asm @@ -12,3 +12,9 @@ ITEM_NAME EQU 4 PLAYEROT_NAME EQU 5 ENEMYOT_NAME EQU 6 TRAINER_NAME EQU 7 + +INIT_ENEMYOT_LIST EQU 1 +INIT_BAG_ITEM_LIST EQU 2 +INIT_OTHER_ITEM_LIST EQU 3 +INIT_PLAYEROT_LIST EQU 4 +INIT_MON_LIST EQU 5 \ No newline at end of file diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 3452a393..a96fc59f 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -58,6 +58,14 @@ TRADE_CANCEL_MENU EQU 5 HEAL_CANCEL_MENU EQU 6 NO_YES_MENU EQU 7 +; menu exit method constants for list menus and the buy/sell/quit menu +CHOSE_MENU_ITEM EQU 1 ; pressed A +CANCELLED_MENU EQU 2 ; pressed B + +; menu exit method constants for two-option menus +CHOSE_FIRST_ITEM EQU 1 +CHOSE_SECOND_ITEM EQU 2 + ; serial ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01 diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm index 80fa971a..2f3944e9 100755 --- a/engine/battle/bank_e_misc.asm +++ b/engine/battle/bank_e_misc.asm @@ -53,29 +53,29 @@ FormatMovesString: ; 39b87 (e:5b87) ; XXX this is called in a few places, but it doesn't appear to do anything useful InitList: ; 39bd5 (e:5bd5) - ld a, [wd11b] - cp $1 + ld a, [wInitListType] + cp INIT_ENEMYOT_LIST jr nz, .notEnemy ld hl, wEnemyPartyCount ld de, wEnemyMonOT ld a, ENEMYOT_NAME jr .done .notEnemy - cp $4 + cp INIT_PLAYEROT_LIST jr nz, .notPlayer ld hl, wPartyCount ld de, wPartyMonOT ld a, PLAYEROT_NAME jr .done .notPlayer - cp $5 + cp INIT_MON_LIST jr nz, .notMonster ld hl, wStringBuffer2 + 11 ld de, MonsterNames ld a, MONSTER_NAME jr .done .notMonster - cp $2 + cp INIT_BAG_ITEM_LIST jr nz, .notBag ld hl, wNumBagItems ld de, ItemNames diff --git a/engine/battle/core.asm b/engine/battle/core.asm index bb7c4990..95242f5d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1142,8 +1142,8 @@ DoUseNextMonDialogue: ; 3c79b (f:479b) ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID - ld a, [wd12e] - cp $2 ; did the player choose NO? + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM ; did the player choose NO? jr z, .tryRunning ; if the player chose NO, try running and a ; reset carry ret @@ -2296,7 +2296,7 @@ DisplayPlayerBag: DisplayBagMenu: xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, ITEMLISTMENU ld [wListMenuID], a ld a, [wcc2c] diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 3cbc0867..be403fa6 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -357,9 +357,9 @@ TradeCenter_SelectMon: dec a ld [wCurrentMenuItem], a .displayEnemyMonStats - ld a, $1 - ld [wd11b], a - callab InitList + ld a, INIT_ENEMYOT_LIST + ld [wInitListType], a + callab InitList ; the list isn't used ld hl, wEnemyMons call TradeCenter_DisplayStats jp .getNewInput @@ -416,9 +416,9 @@ TradeCenter_SelectMon: jr z, .playerMonMenu_ANotPressed jp .chosePlayerMon ; jump if A button pressed ; unreachable code - ld a, $4 - ld [wd11b], a - callab InitList + ld a, INIT_PLAYEROT_LIST + ld [wInitListType], a + callab InitList ; the list isn't used call TradeCenter_DisplayStats jp .getNewInput .playerMonMenu_ANotPressed @@ -511,9 +511,9 @@ TradeCenter_SelectMon: .displayPlayerMonStats pop af ld [wCurrentMenuItem], a - ld a, $4 - ld [wd11b], a - callab InitList + ld a, INIT_PLAYEROT_LIST + ld [wInitListType], a + callab InitList ; the list isn't used call TradeCenter_DisplayStats call LoadScreenTilesFromBuffer1 jp .playerMonMenu diff --git a/engine/items/items.asm b/engine/items/items.asm index ea4b7403..24ff544e 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -450,7 +450,7 @@ ItemUseBall: ; d687 (3:5687) ret nz ld hl,wNumBagItems inc a - ld [wcf96],a + ld [wItemQuantity],a jp RemoveItemFromInventory ItemUseBallText00: ; d937 (3:5937) ;"It dodged the thrown ball!" @@ -655,7 +655,7 @@ ItemUseEvoStone: ; da5b (3:5a5b) ld [wWhichPokemon],a ld hl,wNumBagItems ld a,1 ; remove 1 stone - ld [wcf96],a + ld [wItemQuantity],a jp RemoveItemFromInventory .noEffect call ItemUseNoEffect @@ -2193,7 +2193,7 @@ PrintItemUseTextAndRemoveItem: ; e563 (3:6563) RemoveUsedItem: ; e571 (3:6571) ld hl,wNumBagItems ld a,1 ; one item - ld [wcf96],a ; store quantity + ld [wItemQuantity],a jp RemoveItemFromInventory ItemUseNoEffect: ; e57c (3:657c) @@ -2464,7 +2464,7 @@ GetSelectedMoveOffset2: ; e6e9 (3:66e9) ; hl = address of inventory (either wNumBagItems or wNumBoxItems) ; [wcf91] = item ID ; [wWhichPokemon] = index of item within inventory -; [wcf96] = quantity to toss +; [wItemQuantity] = quantity to toss ; OUTPUT: ; clears carry flag if the item is tossed, sets carry flag if not TossItem_: ; e6f1 (3:66f1) @@ -2475,7 +2475,7 @@ TossItem_: ; e6f1 (3:66f1) jr c,.tooImportantToToss push hl call IsKeyItem_ - ld a,[wd124] + ld a,[wIsKeyItem] pop hl and a jr nz,.tooImportantToToss @@ -2491,11 +2491,11 @@ TossItem_: ; e6f1 (3:66f1) ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu - ld a,[wd12e] - cp a,2 + ld a,[wMenuExitMethod] + cp a,CHOSE_SECOND_ITEM pop hl scf - ret z + ret z ; return if the player chose No ; if the player chose Yes push hl ld a,[wWhichPokemon] @@ -2533,12 +2533,12 @@ TooImportantToTossText: ; e75f (3:675f) ; INPUT: ; [wcf91] = item ID ; OUTPUT: -; [wd124] = result +; [wIsKeyItem] = result ; 00: item is not key item ; 01: item is key item IsKeyItem_: ; e764 (3:6764) ld a,$01 - ld [wd124],a + ld [wIsKeyItem],a ld a,[wcf91] cp a,HM_01 ; is the item an HM or TM? jr nc,.checkIfItemIsHM @@ -2562,7 +2562,7 @@ IsKeyItem_: ; e764 (3:6764) call IsItemHM ret c xor a - ld [wd124],a + ld [wIsKeyItem],a ret INCLUDE "data/key_items.asm" diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index c9dd41b1..b4ac3680 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -231,7 +231,7 @@ BillsPCDeposit: call PlaySoundWaitForCurrent ld a, $1 ld [wcf95], a - call Func_3a68 + call MoveMon xor a ld [wcf95], a call RemovePokemon @@ -283,7 +283,7 @@ Func_21618: ; 21618 (8:5618) call PlaySoundWaitForCurrent xor a ld [wcf95], a - call Func_3a68 + call MoveMon ld a, $1 ld [wcf95], a call RemovePokemon @@ -329,7 +329,7 @@ Func_216be: ; 216be (8:56be) ld a, h ld [wList + 1], a xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld [wListMenuID], a inc a ; MONSTER_NAME ld [wNameListType], a diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm index edc8a751..2b8b9e92 100755 --- a/engine/menu/pc.asm +++ b/engine/menu/pc.asm @@ -135,7 +135,7 @@ RemoveItemByID: ; 17f37 (5:7f37) jr .asm_17f40 .asm_17f4f ld a, $1 - ld [wcf96], a + ld [wItemQuantity], a ld a, [$ffdc] ld [wWhichPokemon], a ld hl, wNumBagItems diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index 147a27a4..9512cc6b 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -101,15 +101,15 @@ Func_79ab: ; 79ab (1:79ab) ld a, h ld [wList + 1], a xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, $3 ld [wListMenuID], a call DisplayListMenuID jp c, Func_790c call IsKeyItem ld a, $1 - ld [wcf96], a - ld a, [wd124] + ld [wItemQuantity], a + ld a, [wIsKeyItem] and a jr nz, .asm_79e7 ld hl, DepositHowManyText @@ -155,15 +155,15 @@ Func_7a28: ; 7a28 (1:7a28) ld a, h ld [wList + 1], a xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, $3 ld [wListMenuID], a call DisplayListMenuID jp c, Func_790c call IsKeyItem ld a, $1 - ld [wcf96], a - ld a, [wd124] + ld [wItemQuantity], a + ld a, [wIsKeyItem] and a jr nz, .asm_7a64 ld hl, WithdrawHowManyText @@ -209,7 +209,7 @@ Func_7aa5: ; 7aa5 (1:7aa5) ld a, h ld [wList + 1], a xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, $3 ld [wListMenuID], a push hl @@ -220,8 +220,8 @@ Func_7aa5: ; 7aa5 (1:7aa5) call IsKeyItem pop hl ld a, $1 - ld [wcf96], a - ld a, [wd124] + ld [wItemQuantity], a + ld a, [wIsKeyItem] and a jr nz, .asm_7aef ld a, [wcf91] diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index b84657d5..0a940356 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -313,7 +313,7 @@ StartMenu_Item: ; 13302 (4:7302) ld [hli],a ld [hl],b ; store item bag pointer at wList (for DisplayListMenuID) xor a - ld [wcf93],a + ld [wPrintItemPrices],a ld a,ITEMLISTMENU ld [wListMenuID],a ld a,[wcc2c] @@ -423,7 +423,7 @@ StartMenu_Item: ; 13302 (4:7302) jp ItemMenuLoop .tossItem call IsKeyItem - ld a,[wd124] + ld a,[wIsKeyItem] and a jr nz,.skipAskingQuantity ld a,[wcf91] diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 72ccc389..f333586d 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -46,7 +46,7 @@ OakSpeech: ; 6115 (1:6115) ld a,POTION ld [wcf91],a ld a,1 - ld [wcf96],a + ld [wItemQuantity],a call AddItemToInventory ; give one potion ld a,[W_ANIMATIONID] ld [wDestinationMap],a diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index fa93e1db..de18a1ab 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -1,30 +1,34 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld a,[wListScrollOffset] - ld [wd07e],a + ld [wSavedListScrollOffset],a call UpdateSprites xor a - ld [wcf0a],a ; flag that is set if something is sold or bought + ld [wBoughtOrSoldItemInMart],a .loop xor a ld [wListScrollOffset],a ld [wCurrentMenuItem],a ld [wPlayerMonNumber],a inc a - ld [wcf93],a + ld [wPrintItemPrices],a ld a,MONEY_BOX ld [wTextBoxID],a - call DisplayTextBoxID ; draw money text box + call DisplayTextBoxID ld a,BUY_SELL_QUIT_MENU ld [wTextBoxID],a - call DisplayTextBoxID ; do buy/sell/quit menu - ld hl,wd128 ; pointer to this pokemart's inventory + call DisplayTextBoxID + +; This code is useless. It copies the address of the pokemart's inventory to hl, +; but the address is never used. + ld hl,wItemListPointer ld a,[hli] ld l,[hl] - ld h,a ; hl = address of inventory - ld a,[wd12e] - cp a,$02 + ld h,a + + ld a,[wMenuExitMethod] + cp a,CANCELLED_MENU jp z,.done - ld a,[wd12d] ; ID of the chosen menu item + ld a,[wChosenMenuItem] and a ; buying? jp z,.buyMenu dec a ; selling? @@ -32,11 +36,14 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) dec a ; quitting? jp z,.done .sellMenu + +; the same variables are set again below, so this code has no effect xor a - ld [wcf93],a - ld a,$02 - ld [wd11b],a + ld [wPrintItemPrices],a + ld a,INIT_BAG_ITEM_LIST + ld [wInitListType],a callab InitList + ld a,[wNumBagItems] and a jp z,.bagEmpty @@ -54,15 +61,15 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld a,h ld [wList + 1],a xor a - ld [wcf93],a + ld [wPrintItemPrices],a ld [wCurrentMenuItem],a ld a,ITEMLISTMENU ld [wListMenuID],a call DisplayListMenuID jp c,.returnToMainPokemartMenu ; if the player closed the menu .confirmItemSale ; if the player is trying to sell a specific item - call IsKeyItem ; check if item is unsellable - ld a,[wd124] + call IsKeyItem + ld a,[wIsKeyItem] and a jr nz,.unsellableItem ld a,[wcf91] @@ -70,7 +77,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) jr c,.unsellableItem ld a,PRICEDITEMLISTMENU ld [wListMenuID],a - ld [$ff8e],a ; halve prices when selling + ld [hHalveItemPrices],a ; halve prices when selling call DisplayChooseQuantityMenu inc a jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button @@ -82,18 +89,22 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu - ld a,[wd12e] - cp a,$02 - jr z,.sellMenuLoop ; if the player pressed the B button - ld a,[wd12d] ; ID of the chosen menu item + ld a,[wMenuExitMethod] + cp a,CHOSE_SECOND_ITEM + jr z,.sellMenuLoop ; if the player chose No or pressed the B button + +; The following code is supposed to check if the player chose No, but the above +; check already catches it. + ld a,[wChosenMenuItem] dec a - jr z,.sellMenuLoop ; if the player chose No + jr z,.sellMenuLoop + .sellItem - ld a,[wcf0a] ; flag that is set if something is sold or bought + ld a,[wBoughtOrSoldItemInMart] and a jr nz,.skipSettingFlag1 inc a - ld [wcf0a],a + ld [wBoughtOrSoldItemInMart],a .skipSettingFlag1 call AddAmountSoldToMoney ld hl,wNumBagItems @@ -106,22 +117,25 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) .bagEmpty ld hl,PokemartItemBagEmptyText call PrintText - call SaveScreenTilesToBuffer1 ; save screen + call SaveScreenTilesToBuffer1 jp .returnToMainPokemartMenu .buyMenu - ld a,$01 - ld [wcf93],a - ld a,$03 - ld [wd11b],a + +; the same variables are set again below, so this code has no effect + ld a,1 + ld [wPrintItemPrices],a + ld a,INIT_OTHER_ITEM_LIST + ld [wInitListType],a callab InitList + ld hl,PokemartBuyingGreetingText call PrintText - call SaveScreenTilesToBuffer1 ; save screen + call SaveScreenTilesToBuffer1 .buyMenuLoop - call LoadScreenTilesFromBuffer1 ; restore saved screen + call LoadScreenTilesFromBuffer1 ld a,MONEY_BOX ld [wTextBoxID],a - call DisplayTextBoxID ; draw money text box + call DisplayTextBoxID ld hl,wStringBuffer2 + 11 ld a,l ld [wList],a @@ -130,15 +144,15 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) xor a ld [wCurrentMenuItem],a inc a - ld [wcf93],a + ld [wPrintItemPrices],a inc a ; a = 2 (PRICEDITEMLISTMENU) ld [wListMenuID],a call DisplayListMenuID jr c,.returnToMainPokemartMenu ; if the player closed the menu - ld a,$63 - ld [wcf97],a + ld a,99 + ld [wMaxItemQuantity],a xor a - ld [$ff8e],a + ld [hHalveItemPrices],a ; don't halve item prices when buying call DisplayChooseQuantityMenu inc a jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button @@ -153,12 +167,16 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ; yes/no menu - ld a,[wd12e] - cp a,$02 - jp z,.buyMenuLoop ; if the player pressed the B button - ld a,[wd12d] ; ID of the chosen menu item + ld a,[wMenuExitMethod] + cp a,CHOSE_SECOND_ITEM + jp z,.buyMenuLoop ; if the player chose No or pressed the B button + +; The following code is supposed to check if the player chose No, but the above +; check already catches it. + ld a,[wChosenMenuItem] dec a - jr z,.buyMenuLoop ; if the player chose No + jr z,.buyMenuLoop + .buyItem call .isThereEnoughMoney jr c,.notEnoughMoney @@ -166,11 +184,11 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call AddItemToInventory jr nc,.bagFull call SubtractAmountPaidFromMoney - ld a,[wcf0a] ; flag that is set if something is sold or bought + ld a,[wBoughtOrSoldItemInMart] and a jr nz,.skipSettingFlag2 - ld a,$01 - ld [wcf0a],a + ld a,1 + ld [wBoughtOrSoldItemInMart],a .skipSettingFlag2 ld a,(SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent @@ -182,7 +200,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call LoadScreenTilesFromBuffer1 ld a,MONEY_BOX ld [wTextBoxID],a - call DisplayTextBoxID ; draw money text box + call DisplayTextBoxID ld hl,PokemartAnythingElseText call PrintText jp .loop @@ -202,10 +220,10 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) .done ld hl,PokemartThankYouText call PrintText - ld a,$01 + ld a,1 ld [wUpdateSpritesEnabled],a call UpdateSprites - ld a,[wd07e] + ld a,[wSavedListScrollOffset] ld [wListScrollOffset],a ret diff --git a/engine/predefs7.asm b/engine/predefs7.asm index 9786c097..82a073dc 100755 --- a/engine/predefs7.asm +++ b/engine/predefs7.asm @@ -11,7 +11,7 @@ Func_1c9c6: ; 1c9c6 (7:49c6) xor a ld [wCurrentMenuItem], a ld [wListScrollOffset], a - ld [wcf93], a + ld [wPrintItemPrices], a ld a, $4 ld [wListMenuID], a call DisplayListMenuID diff --git a/home.asm b/home.asm index 06a0aec3..b9041fef 100644 --- a/home.asm +++ b/home.asm @@ -1201,8 +1201,8 @@ DisplayPokemartDialogue:: ; 2a2e (0:2a2e) pop hl inc hl call LoadItemList - ld a,$02 - ld [wListMenuID],a ; selects between subtypes of menus + ld a,PRICEDITEMLISTMENU + ld [wListMenuID],a ld a,[H_LOADEDROMBANK] push af ld a,Bank(DisplayPokemartDialogue_) @@ -1219,12 +1219,12 @@ PokemartGreetingText:: ; 2a55 (0:2a55) db "@" LoadItemList:: ; 2a5a (0:2a5a) - ld a,$01 + ld a,1 ld [wUpdateSpritesEnabled],a ld a,h - ld [wd128],a + ld [wItemListPointer],a ld a,l - ld [wd129],a + ld [wItemListPointer + 1],a ld de,wStringBuffer2 + 11 .loop ld a,[hli] @@ -1336,7 +1336,7 @@ AddAmountSoldToMoney:: ; 2b9e (0:2b9e) ; INPUT: ; HL = address of inventory (either wNumBagItems or wNumBoxItems) ; [wWhichPokemon] = index (within the inventory) of the item to remove -; [wcf96] = quantity to remove +; [wItemQuantity] = quantity to remove RemoveItemFromInventory:: ; 2bbb (0:2bbb) ld a,[H_LOADEDROMBANK] push af @@ -1353,7 +1353,7 @@ RemoveItemFromInventory:: ; 2bbb (0:2bbb) ; INPUT: ; HL = address of inventory (either wNumBagItems or wNumBoxItems) ; [wcf91] = item ID -; [wcf96] = item quantity +; [wItemQuantity] = item quantity ; sets carry flag if successful, unsets carry flag if unsuccessful AddItemToInventory:: ; 2bcf (0:2bcf) push bc @@ -1461,9 +1461,12 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) .buttonAPressed ld a,[wCurrentMenuItem] call PlaceUnfilledArrowMenuCursor + +; pointless because both values are overwritten before they are read ld a,$01 - ld [wd12e],a - ld [wd12d],a + ld [wMenuExitMethod],a + ld [wChosenMenuItem],a + xor a ld [wcc37],a ld a,[wCurrentMenuItem] @@ -1506,7 +1509,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ; if it's an item menu inc hl ld a,[hl] ; a = item quantity - ld [wcf97],a + ld [wMaxItemQuantity],a .skipGettingQuantity ld a,[wcf91] ld [wd0b5],a @@ -1527,10 +1530,10 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) .storeChosenEntry ; store the menu entry that the player chose and return ld de,wcd6d call CopyStringToCF4B ; copy name to wcf4b - ld a,$01 - ld [wd12e],a + ld a,CHOSE_MENU_ITEM + ld [wMenuExitMethod],a ld a,[wCurrentMenuItem] - ld [wd12d],a + ld [wChosenMenuItem],a xor a ld [hJoy7],a ; joypad state update flag ld hl,wd730 @@ -1584,7 +1587,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld de,InitialQuantityText call PlaceString xor a - ld [wcf96],a ; initialize current quantity to 0 + ld [wItemQuantity],a ; initialize current quantity to 0 jp .incrementQuantity .waitForKeyPressLoop call JoypadLowSensitivity @@ -1599,10 +1602,10 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) jr nz,.decrementQuantity jr .waitForKeyPressLoop .incrementQuantity - ld a,[wcf97] ; max quantity + ld a,[wMaxItemQuantity] inc a ld b,a - ld hl,wcf96 ; current quantity + ld hl,wItemQuantity ; current quantity inc [hl] ld a,[hl] cp b @@ -1612,11 +1615,11 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld [hl],a jr .handleNewQuantity .decrementQuantity - ld hl,wcf96 ; current quantity + ld hl,wItemQuantity ; current quantity dec [hl] jr nz,.handleNewQuantity ; wrap to the max quantity if the player goes below 1 - ld a,[wcf97] ; max quantity + ld a,[wMaxItemQuantity] ld [hl],a .handleNewQuantity hlCoord 17, 10 @@ -1625,7 +1628,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) jr nz,.printQuantity .printPrice ld c,$03 - ld a,[wcf96] + ld a,[wItemQuantity] ld b,a ld hl,$ff9f ; total price ; initialize total price to 0 @@ -1641,7 +1644,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) pop bc dec b jr nz,.addLoop - ld a,[$ff8e] + ld a,[hHalveItemPrices] and a ; should the price be halved (for selling items)? jr z,.skipHalvingPrice xor a @@ -1666,7 +1669,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) call PrintBCDNumber hlCoord 9, 10 .printQuantity - ld de,wcf96 ; current quantity + ld de,wItemQuantity ; current quantity ld bc,$8102 ; print leading zeroes, 1 byte, 2 digits call PrintNumber jp .waitForKeyPressLoop @@ -1688,9 +1691,9 @@ SpacesBetweenQuantityAndPriceText:: ; 2e34 (0:2e34) ExitListMenu:: ; 2e3b (0:2e3b) ld a,[wCurrentMenuItem] - ld [wd12d],a - ld a,$02 - ld [wd12e],a + ld [wChosenMenuItem],a + ld a,CANCELLED_MENU + ld [wMenuExitMethod],a ld [wcc37],a xor a ld [hJoy7],a @@ -1775,7 +1778,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) call PlaceString pop de pop hl - ld a,[wcf93] + ld a,[wPrintItemPrices] and a ; should prices be printed? jr z,.skipPrintingItemPrice .printItemPrice @@ -1839,7 +1842,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) ld a,[wd11e] ld [wcf91],a call IsKeyItem ; check if item is unsellable - ld a,[wd124] + ld a,[wIsKeyItem] and a ; is the item unsellable? jr nz,.skipPrintingItemQuantity ; if so, don't print the quantity push hl @@ -1850,7 +1853,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) ld a,[wd11e] push af ld a,[de] - ld [wcf97],a + ld [wMaxItemQuantity],a push de ld de,wd11e ld [de],a @@ -2101,7 +2104,7 @@ UseItem:: ; 30bc (0:30bc) ; hl = address of inventory (either wNumBagItems or wNumBoxItems) ; [wcf91] = item ID ; [wWhichPokemon] = index of item within inventory -; [wcf96] = quantity to toss +; [wItemQuantity] = quantity to toss ; OUTPUT: ; clears carry flag if the item is tossed, sets carry flag if not TossItem:: ; 30c4 (0:30c4) @@ -2121,7 +2124,7 @@ TossItem:: ; 30c4 (0:30c4) ; INPUT: ; [wcf91] = item ID ; OUTPUT: -; [wd124] = result +; [wIsKeyItem] = result ; 00: item is not key item ; 01: item is key item IsKeyItem:: ; 30d9 (0:30d9) @@ -3826,13 +3829,13 @@ AddEnemyMonToPlayerParty:: ; 3a53 (0:3a53) ld [MBC1RomBank], a ret -Func_3a68:: ; 3a68 (0:3a68) +MoveMon:: ; 3a68 (0:3a68) ld a, [H_LOADEDROMBANK] push af - ld a, BANK(MoveMon) + ld a, BANK(_MoveMon) ld [H_LOADEDROMBANK], a ld [MBC1RomBank], a - call MoveMon + call _MoveMon pop bc ld a, b ld [H_LOADEDROMBANK], a @@ -4568,7 +4571,7 @@ GiveItem:: ld [wd11e], a ld [wcf91], a ld a, c - ld [wcf96], a + ld [wItemQuantity], a ld hl,wNumBagItems call AddItemToInventory ret nc diff --git a/home/overworld.asm b/home/overworld.asm index 0e62a932..37daa0d0 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -301,7 +301,7 @@ OverworldLoopLessDelay:: and a jp nz,CheckWarpsNoCollision predef ApplyOutOfBattlePoisonDamage ; also increment daycare mon exp - ld a,[wd12d] + ld a,[wOutOfBattleBlackout] and a jp nz,HandleBlackOut ; if all pokemon fainted .newBattle diff --git a/hram.asm b/hram.asm index a6035b59..edfb5c73 100644 --- a/hram.asm +++ b/hram.asm @@ -26,6 +26,8 @@ hSpriteIndexOrTextID EQU $FF8C hPartyMonIndex EQU $FF8C +hHalveItemPrices EQU $FF8E + ; Multiplcation and division variables are meant ; to overlap for back-to-back usage. Big endian. diff --git a/main.asm b/main.asm index 7372381a..3a79bdd6 100755 --- a/main.asm +++ b/main.asm @@ -1457,7 +1457,7 @@ DoBuySellQuitMenu: ; 74ea (1:74ea) set 6, a ; no printing delay ld [wd730], a xor a - ld [wd12d], a + ld [wChosenMenuItem], a ld a, BUY_SELL_QUIT_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID @@ -1482,24 +1482,24 @@ DoBuySellQuitMenu: ; 74ea (1:74ea) jr nz, .pressedA bit 1, a ; was B pressed? (always true since only A/B are watched) jr z, .pressedA - ld a, $2 - ld [wd12e], a + ld a, CANCELLED_MENU + ld [wMenuExitMethod], a jr .quit .pressedA - ld a, $1 - ld [wd12e], a + ld a, CHOSE_MENU_ITEM + ld [wMenuExitMethod], a ld a, [wCurrentMenuItem] - ld [wd12d], a + ld [wChosenMenuItem], a ld b, a ld a, [wMaxMenuItem] cp b jr z, .quit ret .quit - ld a, $2 - ld [wd12e], a + ld a, CANCELLED_MENU + ld [wMenuExitMethod], a ld a, [wCurrentMenuItem] - ld [wd12d], a + ld [wChosenMenuItem], a scf ret @@ -1512,9 +1512,12 @@ DisplayTwoOptionMenu: ; 7559 (1:7559) ld a, [wd730] set 6, a ; no printing delay ld [wd730], a + +; pointless because both values are overwritten before they are read xor a - ld [wd12d], a - ld [wd12e], a + ld [wChosenMenuItem], a + ld [wMenuExitMethod], a + ld a, A_BUTTON | B_BUTTON ld [wMenuWatchedKeys], a ld a, $1 @@ -1614,23 +1617,23 @@ DisplayTwoOptionMenu: ; 7559 (1:7559) jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed .pressedAButton ld a, [wCurrentMenuItem] - ld [wd12d], a + ld [wChosenMenuItem], a and a jr nz, .choseSecondMenuItem ; chose first menu item - ld a, $1 - ld [wd12e], a + ld a, CHOSE_FIRST_ITEM + ld [wMenuExitMethod], a ld c, 15 call DelayFrames call TwoOptionMenu_RestoreScreenTiles and a ret .choseSecondMenuItem - ld a, $1 + ld a, 1 ld [wCurrentMenuItem], a - ld [wd12d], a - ld a, $2 - ld [wd12e], a + ld [wChosenMenuItem], a + ld a, CHOSE_SECOND_ITEM + ld [wMenuExitMethod], a ld c, 15 call DelayFrames call TwoOptionMenu_RestoreScreenTiles @@ -2631,7 +2634,7 @@ ApplyOutOfBattlePoisonDamage: ; c69c (3:469c) .noBlackOut xor a .done - ld [wd12d], a + ld [wOutOfBattleBlackout], a ret LoadTilesetHeader: ; c754 (3:4754) @@ -2777,10 +2780,10 @@ CyclingIsFunText: ; cdff (3:4dff) ; INPUT: ; hl = address of inventory (either wNumBagItems or wNumBoxItems) ; [wcf91] = item ID -; [wcf96] = item quantity +; [wItemQuantity] = item quantity ; sets carry flag if successful, unsets carry flag if unsuccessful AddItemToInventory_: ; ce04 (3:4e04) - ld a,[wcf96] ; a = item quantity + ld a,[wItemQuantity] ; a = item quantity push af push bc push de @@ -2827,12 +2830,12 @@ AddItemToInventory_: ; ce04 (3:4e04) add hl,bc ; hl = address to store the item ld a,[wcf91] ld [hli],a ; store item ID - ld a,[wcf96] + ld a,[wItemQuantity] ld [hli],a ; store item quantity ld [hl],$ff ; store terminator jp .success .increaseItemQuantity ; increase the quantity of an item already in the inventory - ld a,[wcf96] + ld a,[wItemQuantity] ld b,a ; b = quantity to add ld a,[hl] ; a = existing item quantity add b ; a = new item quantity @@ -2841,7 +2844,7 @@ AddItemToInventory_: ; ce04 (3:4e04) ; if the new quantity is greater than or equal to 100, ; try to max out the current slot and add the rest in a new slot sub a,99 - ld [wcf96],a ; a = amount left over (to put in the new slot) + ld [wItemQuantity],a ; a = amount left over (to put in the new slot) ld a,d and a ; is there room for a new item slot? jr z,.increaseItemQuantityFailed @@ -2864,14 +2867,14 @@ AddItemToInventory_: ; ce04 (3:4e04) pop bc pop bc ld a,b - ld [wcf96],a ; restore the initial value from when the function was called + ld [wItemQuantity],a ; restore the initial value from when the function was called ret ; function to remove an item (in varying quantities) from the player's bag or PC box ; INPUT: ; hl = address of inventory (either wNumBagItems or wNumBoxItems) ; [wWhichPokemon] = index (within the inventory) of the item to remove -; [wcf96] = quantity to remove +; [wItemQuantity] = quantity to remove RemoveItemFromInventory_: ; ce74 (3:4e74) push hl inc hl @@ -2883,12 +2886,12 @@ RemoveItemFromInventory_: ; ce74 (3:4e74) inc h .noCarry inc hl - ld a,[wcf96] ; quantity being removed + ld a,[wItemQuantity] ; quantity being removed ld e,a ld a,[hl] ; a = current quantity sub e ld [hld],a ; store new quantity - ld [wcf97],a + ld [wMaxItemQuantity],a and a jr nz,.skipMovingUpSlots ; if the remaining quantity is 0, @@ -2909,7 +2912,7 @@ RemoveItemFromInventory_: ; ce74 (3:4e74) ld [wListScrollOffset],a ld [wCurrentMenuItem],a ld [wcc2c],a - ld [wd07e],a + ld [wSavedListScrollOffset],a pop hl ld a,[hl] ; a = number of items in inventory dec a ; decrement the number of items @@ -3863,7 +3866,7 @@ _AddEnemyMonToPlayerParty: ; f49d (3:749d) and a ret ; return success -MoveMon: ; f51e (3:751e) +_MoveMon: ; f51e (3:751e) ld a, [wcf95] and a jr z, .checkPartyMonSlots diff --git a/scripts/ceruleanhouse2.asm b/scripts/ceruleanhouse2.asm index 423c0209..2d012d70 100755 --- a/scripts/ceruleanhouse2.asm +++ b/scripts/ceruleanhouse2.asm @@ -26,7 +26,7 @@ CeruleanHouse2Text1: ; 74e15 (1d:4e15) ld a, h ld [wList + 1], a xor a - ld [wcf93], a + ld [wPrintItemPrices], a ld [wMenuItemToSwap], a ld a, SPECIALLISTMENU ld [wListMenuID], a diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index 3fa2d3b9..83b9b3a7 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -49,7 +49,7 @@ DayCareMText1: ; 56254 (15:6254) ld [W_DAYCARE_IN_USE], a ld a, $3 ld [wcf95], a - call Func_3a68 + call MoveMon xor a ld [wcf95], a call RemovePokemon @@ -158,14 +158,14 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) predef SubBCDPredef ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent - ld a, $13 + ld a, MONEY_BOX ld [wTextBoxID], a call DisplayTextBoxID ld hl, DayCareMText_5644f call PrintText ld a, $2 ld [wcf95], a - call Func_3a68 + call MoveMon ld a, [wDayCareMonSpecies] ld [wcf91], a ld a, [wPartyCount] diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 7c99d802..1c255103 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -641,7 +641,7 @@ OaksLabScript_1d00a: ; 1d00a (7:500a) ld a, c ld [wWhichPokemon], a ld a, $1 - ld [wcf96], a + ld [wItemQuantity], a jp RemoveItemFromInventory OaksLabScript_1d02b: ; 1d02b (7:502b) diff --git a/wram.asm b/wram.asm index 83aa4e60..65681990 100755 --- a/wram.asm +++ b/wram.asm @@ -746,7 +746,13 @@ wAnimSoundID:: ; cf07 wcf08:: ds 1 ; used as a storage value for the bank to return to after a BankswitchHome (bankswitch in homebank) wcf09:: ds 1 ; used as a temp storage value for the bank to switch to -wcf0a:: ds 1 ; used as flags for Poke Mart + +wBoughtOrSoldItemInMart:: ; cf0a +; 0 = nothing bought or sold in pokemart +; 1 = bought or sold something in pokemart +; this value is not used for anything + ds 1 + wBattleResult:: ; cf0b ; $00 - win ; $01 - lose @@ -831,7 +837,9 @@ wWhichPokemon:: ; cf92 ; which pokemon you selected ds 1 -wcf93:: ds 1 ; used with lists +wPrintItemPrices:: ; cf93 +; if non-zero, then print item prices when displaying lists + ds 1 wHPBarType:: ; cf94 ; type of HP bar @@ -844,8 +852,12 @@ wListMenuID:: ; cf94 ds 1 wcf95:: ds 1 ; used with RemovePokemon (BoxMons, Daycare, Trades, etc.) -wcf96:: ds 1 ; used with removing items -wcf97:: ds 1 ; used with printing item quantities? + +wItemQuantity:: ; cf96 + ds 1 + +wMaxItemQuantity:: ; cf97 + ds 1 ; LoadMonData copies mon data here wLoadedMon:: party_struct wLoadedMon ; cf98 @@ -1126,7 +1138,13 @@ W_ANIMATIONID:: ; d07c ds 1 wd07d:: ds 1 ; used with naming functions and party display type -wd07e:: ds 3 ; used with mart and inventory + +wSavedListScrollOffset:: ; d07e +; used by the pokemart code to save the existing value of wListScrollOffset +; so that it can be restored when the player is done with the pokemart NPC + ds 1 + + ds 2 ; base coordinates of frame block W_BASECOORDX:: ; d081 @@ -1353,7 +1371,10 @@ wWalkBikeSurfStateCopy:: ; d11a ; wWalkBikeSurfState is sometimes copied here, but it doesn't seem to be used for anything ds 1 -wd11b:: ds 1 ; used with mart text box and cable club +wInitListType:: ; d11b +; the type of list for InitList to init + ds 1 + wd11c:: ds 1 ; temp storage value for catching pokemon wd11d:: ds 1 ; used with battle switchout and testing if the enemy mon fainted wd11e:: ds 1 ; used as a Pokemon and Item storage value. Also used as an output value for CountSetBits @@ -1365,7 +1386,7 @@ wNumRunAttempts:: wd121:: ds 1 ; used with evolving pokemon wd122:: ds 2 ; saved ROM bank number for vblank -wd124:: ds 1 ; used as an output value when determining if an item is a key item +wIsKeyItem:: ds 1 ; d124 wTextBoxID:: ; d125 ds 1 @@ -1375,16 +1396,35 @@ wd126:: ds 1 ; not exactly sure what this is used for, but it seems to be used a W_CURENEMYLVL:: ; d127 ds 1 -wd128:: ds 1 ; used as a pointer to displaying Poke Mart inventory, also used to store the pointer of LoadItemList (pointer to item list initially in hl) -wd129:: ds 1 ; second half of above mentioned pointer +wItemListPointer:: ; d128 +; pointer to list of items terminated by $FF + ds 2 + wd12a:: ds 1 ; Number of list entries for displaying a list wLinkState:: ; d12b ds 1 -wTwoOptionMenuID:: ds 1 -wd12d:: ds 1 ; used with item menus and pokemart menu, also used with testing if all Pokemon Fainted? -wd12e:: ds 1 ; used as an output value to determine if A or B was pressed in a yes/no box +wTwoOptionMenuID:: ; d12c + ds 1 + +wChosenMenuItem:: ; d12d +; the id of the menu item the player ultimately chose + +wOutOfBattleBlackout:: ; d12d +; non-zero when the whole party has fainted due to out-of-battle poison damage + ds 1 + +wMenuExitMethod:: ; d12e +; the way the user exited a menu +; for list menus and the buy/sell/quit menu: +; $01 = the user pressed A to choose a menu item +; $02 = the user pressed B to cancel +; for two-option menus: +; $01 = the user pressed A with the first menu item selected +; $02 = the user pressed B or pressed A with the second menu item selected + ds 1 + wd12f:: ds 1 ; used in some coordinatestuff, npc pathstuff, and game corner prize stuff wd130:: ds 1 ; saved value of screen Y coord of trainer sprite wd131:: ds 1 ; saved value of screen X coord of trainer sprite -- cgit v1.3.1-sl0p From 95b1660e59283b6f76dca638985c76a7d81d026f Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 13 Jul 2015 00:32:03 -0700 Subject: menu wram variable names --- engine/battle/core.asm | 2 +- engine/cable_club.asm | 8 ++++---- engine/menu/pokedex.asm | 6 +++--- engine/save.asm | 2 +- engine/slot_machine.asm | 2 +- home.asm | 22 +++++++++++----------- main.asm | 10 +++++----- wram.asm | 11 +++++++++-- 8 files changed, 35 insertions(+), 28 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 95242f5d..f37da950 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2305,7 +2305,7 @@ DisplayBagMenu: ld a, [wCurrentMenuItem] ld [wcc2c], a ld a, $0 - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld [wMenuItemToSwap], a jp c, DisplayBattleMenu ; go back to battle menu if an item was not selected diff --git a/engine/cable_club.asm b/engine/cable_club.asm index c115ed4a..13a95ed5 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -317,7 +317,7 @@ TradeCenter_SelectMon: ld [hli], a ld [hli], a ld [hl], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld [wCurrentMenuItem], a ld [wLastMenuItem], a ld [wMenuJoypadPollCount], a @@ -326,7 +326,7 @@ TradeCenter_SelectMon: jp .playerMonMenu .enemyMonMenu xor a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a inc a ld [wWhichTradeMonSelectionMenu], a ld a, D_DOWN | D_LEFT | A_BUTTON @@ -390,7 +390,7 @@ TradeCenter_SelectMon: .playerMonMenu xor a ; player mon menu ld [wWhichTradeMonSelectionMenu], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld a, D_DOWN | D_RIGHT | A_BUTTON ld [wMenuWatchedKeys], a ld a, [wPartyCount] @@ -682,7 +682,7 @@ TradeCenter_Trade: xor a ld [wSerialExchangeNybbleSendData + 1], a ; unnecessary ld [wSerialExchangeNybbleReceiveData], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld [wMenuJoypadPollCount], a hlCoord 0, 12 ld b, 4 diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index e2e53d45..b8686a07 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -22,7 +22,7 @@ ShowPokedexMenu: ; 40000 (10:4000) xor a ld [hli],a ; top menu item X inc a - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a inc hl inc hl ld a,6 @@ -32,7 +32,7 @@ ShowPokedexMenu: ; 40000 (10:4000) jr c,.goToSideMenu ; if the player chose a pokemon from the list .exitPokedex xor a - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a ld [wCurrentMenuItem],a ld [wLastMenuItem],a ld [hJoy7],a @@ -91,7 +91,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d) ld [hli],a ; menu watched keys (A button and B button) xor a ld [hli],a ; old menu item ID - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a .handleMenuInput call HandleMenuInput bit 1,a ; was the B button pressed? diff --git a/engine/save.asm b/engine/save.asm index cc5e6c4a..2ef59263 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -421,7 +421,7 @@ Func_7393f: ; 7393f (1c:793f) ld a, $c ld [wTopMenuItemX], a xor a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld a, [wd5a0] and $7f ld [wCurrentMenuItem], a diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 0b9f8bc9..6dae7293 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -78,7 +78,7 @@ MainSlotMachineLoop: ; 37395 (d:7395) xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld hl, wTileMap + $ea ld b, $5 ld c, $4 diff --git a/home.asm b/home.asm index 51e10118..f6a1c914 100644 --- a/home.asm +++ b/home.asm @@ -378,7 +378,7 @@ PartyMenuInit:: ; 1420 (0:1420) set 6, [hl] ; turn off letter printing delay xor a ld [wcc49], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld hl, wTopMenuItemY inc a ld [hli], a ; top menu item Y @@ -1391,13 +1391,13 @@ DisplayListMenuID:: ; 2be6 (0:2be6) set 6,[hl] ; turn off letter printing delay xor a ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped - ld [wd12a],a + ld [wListCount],a ld a,[wList] ld l,a ld a,[wList + 1] ld h,a ; hl = address of the list - ld a,[hl] - ld [wd12a],a ; [wd12a] = number of list entries + ld a,[hl] ; the first byte is the number of entries in the list + ld [wListCount],a ld a,LIST_MENU_BOX ld [wTextBoxID],a call DisplayTextBoxID ; draw the menu text box @@ -1411,8 +1411,8 @@ DisplayListMenuID:: ; 2be6 (0:2be6) call UpdateSprites .skipMovingSprites ld a,1 ; max menu item ID is 1 if the list has less than 2 entries - ld [wcc37],a - ld a,[wd12a] + ld [wMenuWatchMovingOutOfBounds],a + ld a,[wListCount] cp a,2 ; does the list have less than 2 entries? jr c,.setMenuVariables ld a,2 ; max menu item ID is 2 if the list has at least 2 entries @@ -1468,13 +1468,13 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ld [wChosenMenuItem],a xor a - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a ld a,[wCurrentMenuItem] ld c,a ld a,[wListScrollOffset] add c ld c,a - ld a,[wd12a] ; number of list entries + ld a,[wListCount] and a ; is the list empty? jp z,ExitListMenu ; if so, exit the menu dec a @@ -1552,7 +1552,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ld a,[hl] add a,3 ld b,a - ld a,[wd12a] ; number of list entries + ld a,[wListCount] cp b ; will going down scroll past the Cancel button? jp c,DisplayListMenuIDLoop inc [hl] ; if not, go down @@ -1694,7 +1694,7 @@ ExitListMenu:: ; 2e3b (0:2e3b) ld [wChosenMenuItem],a ld a,CANCELLED_MENU ld [wMenuExitMethod],a - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a xor a ld [hJoy7],a ld hl,wd730 @@ -4026,7 +4026,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) ld a,[hJoy5] ret .noWrappingAround - ld a,[wcc37] + ld a,[wMenuWatchMovingOutOfBounds] and a ; should we return if the user tried to go past the top or bottom? jr z,.checkOtherKeys jr .checkIfAButtonOrBButtonPressed diff --git a/main.asm b/main.asm index 54440e60..3a1e0621 100755 --- a/main.asm +++ b/main.asm @@ -922,7 +922,7 @@ HandleItemListSwapping: ; 6b44 (1:6b44) ld l,a dec [hl] ; decrease the number of items ld a,[hl] - ld [wd12a],a ; update number of items variable + ld [wListCount],a ; update number of items variable cp a,1 jr nz,.skipSettingMaxMenuItemID ld [wMaxMenuItem],a ; if the number of items is only one now, update the max menu item ID @@ -1094,7 +1094,7 @@ DrawStartMenu: ; 710b (1:710b) ld [wCurrentMenuItem],a ld [wLastMenuItem],a xor a - ld [wcc37],a + ld [wMenuWatchMovingOutOfBounds],a ld hl,wd730 set 6,[hl] ; no pauses between printing each letter hlCoord 12, 2 @@ -1472,7 +1472,7 @@ DoBuySellQuitMenu: ; 74ea (1:74ea) xor a ld [wCurrentMenuItem], a ld [wLastMenuItem], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a ld a, [wd730] res 6, a ; turn on the printing delay ld [wd730], a @@ -1528,7 +1528,7 @@ DisplayTwoOptionMenu: ; 7559 (1:7559) ld [wTopMenuItemX], a xor a ld [wLastMenuItem], a - ld [wcc37], a + ld [wMenuWatchMovingOutOfBounds], a push hl ld hl, wTwoOptionMenuID bit 7, [hl] ; select second menu item by default? @@ -2917,7 +2917,7 @@ RemoveItemFromInventory_: ; ce74 (3:4e74) ld a,[hl] ; a = number of items in inventory dec a ; decrement the number of items ld [hl],a ; store new number of items - ld [wd12a],a + ld [wListCount],a cp a,2 jr c,.done ld [wMaxMenuItem],a diff --git a/wram.asm b/wram.asm index c5f06e53..a1b9f1d3 100755 --- a/wram.asm +++ b/wram.asm @@ -266,7 +266,12 @@ wListScrollOffset:: ; cc36 ; keeps track of what section of the list is on screen ds 1 -wcc37:: ds 1 ; menu related thing, used in pokedex and dialog boxes +wMenuWatchMovingOutOfBounds:: ; cc37 +; If non-zero, then when wrapping is disabled and the player tries to go past +; the top or bottom of the menu, return from HandleMenuInput. This is useful for +; menus that have too many items to display at once on the screen because it +; allows the caller to scroll the entire menu up or down when this happens. + ds 1 wTradeCenterPointerTableIndex:: ; cc38 ds 1 @@ -1409,7 +1414,9 @@ wItemListPointer:: ; d128 ; pointer to list of items terminated by $FF ds 2 -wd12a:: ds 1 ; Number of list entries for displaying a list +wListCount:: +; number of entries in a list + ds 1 wLinkState:: ; d12b ds 1 -- cgit v1.3.1-sl0p From 0066e09828265cc1cc83eca27e6be76911f187ec Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 13 Jul 2015 15:40:33 -0700 Subject: named party menu/naming screen wram variables --- constants/misc_constants.asm | 24 +++++++++++++++++++++ engine/battle/animations.asm | 4 ++-- engine/battle/core.asm | 16 +++++++------- engine/in_game_trades.asm | 4 ++-- engine/items/items.asm | 46 ++++++++++++++++++++--------------------- engine/menu/naming_screen.asm | 28 ++++++++++++------------- engine/menu/party_menu.asm | 16 +++++++------- engine/menu/start_sub_menus.asm | 14 ++++++------- engine/oak_speech2.asm | 8 +++---- home.asm | 2 +- main.asm | 4 ++-- scripts/daycarem.asm | 2 +- scripts/namerater.asm | 4 ++-- wram.asm | 8 ++++++- 14 files changed, 105 insertions(+), 75 deletions(-) (limited to 'engine/battle/core.asm') diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 323e2ab6..eca97408 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -85,6 +85,30 @@ SLOTSFISH EQU $0E0C SLOTSBIRD EQU $1210 SLOTSMOUSE EQU $1614 +; party menu types +NORMAL_PARTY_MENU EQU 0 +USE_ITEM_PARTY_MENU EQU 1 +BATTLE_PARTY_MENU EQU 2 +TMHM_PARTY_MENU EQU 3 +SWAP_MONS_PARTY_MENU EQU 4 +EVO_STONE_PARTY_MENU EQU 5 + +; party memu message IDs +ANTIDOTE_MSG EQU $F0 +BURN_HEAL_MSG EQU $F1 +ICE_HEAL_MSG EQU $F2 +AWAKENING_MSG EQU $F3 +PARALYZ_HEAL_MSG EQU $F4 +POTION_MSG EQU $F5 +FULL_HEAL_MSG EQU $F6 +REVIVE_MSG EQU $F7 +RARE_CANDY_MSG EQU $F8 + +; naming screen types +NAME_PLAYER_SCREEN EQU 0 +NAME_RIVAL_SCREEN EQU 1 +NAME_MON_SCREEN EQU 2 + ; serial ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01 diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index ea879e53..83590d4c 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -336,14 +336,14 @@ LoadAnimationTileset: ; 781d2 (1e:41d2) ld d,0 add hl,de ld a,[hli] - ld [wd07d],a ; number of tiles + ld [wTempTilesetNumTiles],a ; number of tiles ld a,[hli] ld e,a ld a,[hl] ld d,a ; de = address of tileset ld hl,vSprites + $310 ld b, BANK(AnimationTileset1) ; ROM bank - ld a,[wd07d] + ld a,[wTempTilesetNumTiles] ld c,a ; number of tiles jp CopyVideoData ; load tileset diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f37da950..a611864d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1162,8 +1162,8 @@ UseNextMonText: ; 3c7d3 (f:47d3) ; choose next player mon to send out ; stores whether enemy mon has no HP left in Z flag ChooseNextMon: ; 3c7d8 (f:47d8) - ld a, $2 - ld [wd07d], a + ld a, BATTLE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call DisplayPartyMenu .checkIfMonChosen jr nc, .monChosen @@ -1462,8 +1462,8 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) ld a,[wCurrentMenuItem] and a jr nz,.next4 - ld a,2 - ld [wd07d],a + ld a,BATTLE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a call DisplayPartyMenu .next9 ld a,1 @@ -2384,8 +2384,8 @@ PartyMenuOrRockOrRun: jp UseBagItem .partyMenuWasSelected call LoadScreenTilesFromBuffer1 - xor a - ld [wd07d], a + xor a ; NORMAL_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a ld [wMenuItemToSwap], a call DisplayPartyMenu .checkIfPartyMonWasSelected @@ -2403,8 +2403,8 @@ PartyMenuOrRockOrRun: ld bc, $81 ld a, $7f call FillMemory - xor a - ld [wd07d], a + xor a ; NORMAL_PARTY_MENU + ld [wPartyMenuTypeOrMessageID], a call GoBackToPartyMenu jr .checkIfPartyMonWasSelected .partyMonWasSelected diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 3594a26e..7366996c 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -87,8 +87,8 @@ InGameTrade_GetMonName: ; 71b6a (1c:5b6a) INCLUDE "data/trades.asm" InGameTrade_DoTrade: ; 71c07 (1c:5c07) - xor a - ld [wd07d],a + xor a ; NORMAL_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a dec a ld [wUpdateSpritesEnabled],a call DisplayPartyMenu diff --git a/engine/items/items.asm b/engine/items/items.asm index 24ff544e..fae2a871 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -633,8 +633,8 @@ ItemUseEvoStone: ; da5b (3:5a5b) ld a,[wcf91] ld [wd156],a push af - ld a,$05 ; evolution stone party menu - ld [wd07d],a + ld a,EVO_STONE_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a ld a,$ff ld [wUpdateSpritesEnabled],a call DisplayPartyMenu @@ -678,8 +678,8 @@ ItemUseMedicine: ; dabb (3:5abb) push af ld a,[wcf91] push af - ld a,$01 - ld [wd07d],a ; item use party menu + ld a,USE_ITEM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a ld a,$ff ld [wUpdateSpritesEnabled],a ld a,[wd152] @@ -737,22 +737,22 @@ ItemUseMedicine: ; dabb (3:5abb) ld bc,4 add hl,bc ; hl now points to status ld a,[wcf91] - ld bc,$f008 + ld bc, (ANTIDOTE_MSG << 8) | (1 << PSN) cp a,ANTIDOTE jr z,.checkMonStatus - ld bc,$f110 + ld bc, (BURN_HEAL_MSG << 8) | (1 << BRN) cp a,BURN_HEAL jr z,.checkMonStatus - ld bc,$f220 + ld bc, (ICE_HEAL_MSG << 8) | (1 << FRZ) cp a,ICE_HEAL jr z,.checkMonStatus - ld bc,$f307 + ld bc, (AWAKENING_MSG << 8) | SLP cp a,AWAKENING jr z,.checkMonStatus - ld bc,$f440 + ld bc, (PARALYZ_HEAL_MSG << 8) | (1 << PAR) cp a,PARLYZ_HEAL jr z,.checkMonStatus - ld bc,$f6ff ; Full Heal + ld bc, (FULL_HEAL_MSG << 8) | $ff ; Full Heal .checkMonStatus ld a,[hl] ; pokemon's status and c ; does the pokemon have a status ailment the item can cure? @@ -761,7 +761,7 @@ ItemUseMedicine: ; dabb (3:5abb) xor a ld [hl],a ; remove the status ailment in the party data ld a,b - ld [wd07d],a ; the message to display for the item used + ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used ld a,[wPlayerMonNumber] cp d ; is pokemon the item was used on active in battle? jp nz,.doneHealing @@ -1078,15 +1078,15 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[hFlags_0xFFF6] res 0,a ld [hFlags_0xFFF6],a - ld a,$f7 ; revived message - ld [wd07d],a + ld a,REVIVE_MSG + ld [wPartyMenuTypeOrMessageID],a ld a,[wcf91] cp a,REVIVE jr z,.showHealingItemMessage cp a,MAX_REVIVE jr z,.showHealingItemMessage - ld a,$f5 ; standard HP healed message - ld [wd07d],a + ld a,POTION_MSG + ld [wPartyMenuTypeOrMessageID],a jr .showHealingItemMessage .playStatusAilmentCuringSound ld a,(SFX_02_3e - SFX_Headers_02) / 3 ; status ailment curing sound @@ -1257,8 +1257,8 @@ ItemUseMedicine: ; dabb (3:5abb) ld a,[hl] adc b ld [hl],a - ld a,$f8 ; level up message - ld [wd07d],a + ld a,RARE_CANDY_MSG + ld [wPartyMenuTypeOrMessageID],a call RedrawPartyMenu pop de ld a,d @@ -1878,8 +1878,8 @@ ItemUsePPRestore: ; e31e (3:631e) .chooseMon xor a ld [wUpdateSpritesEnabled],a - ld a,$01 ; item use party menu - ld [wd07d],a + ld a,USE_ITEM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a call DisplayPartyMenu jr nc,.chooseMove jp .itemNotUsed @@ -2118,8 +2118,8 @@ ItemUseTMHM: ; e479 (3:6479) call CopyData ld a,$ff ld [wUpdateSpritesEnabled],a - ld a,$03 ; teach TM/HM party menu - ld [wd07d],a + ld a,TMHM_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a call DisplayPartyMenu push af ld hl,wd036 @@ -2650,8 +2650,8 @@ SendNewMonToBox: ; e7a4 (3:67a4) jr nz, .asm_e817 .asm_e82a ld hl, wBoxMonNicks - ld a, $2 - ld [wd07d], a + ld a, NAME_MON_SCREEN + ld [wNamingScreenType], a predef AskName ld a, [W_NUMINBOX] dec a diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index f77f7331..9bdfbee2 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -27,8 +27,8 @@ AskName: ; 64eb (1:64eb) xor a ld [wUpdateSpritesEnabled], a push hl - ld a, $2 - ld [wd07d], a + ld a, NAME_MON_SCREEN + ld [wNamingScreenType], a call DisplayNamingScreen ld a, [W_ISINBATTLE] and a @@ -53,12 +53,12 @@ DoYouWantToNicknameText: ; 0x6557 TX_FAR _DoYouWantToNicknameText db "@" -Func_655c: ; 655c (1:655c) +DisplayNameRaterScreen: ; 655c (1:655c) ld hl, wHPBarMaxHP xor a ld [wUpdateSpritesEnabled], a - ld a, $2 - ld [wd07d], a + ld a, NAME_MON_SCREEN + ld [wNamingScreenType], a call DisplayNamingScreen call GBPalWhiteOutWithDelay3 call RestoreScreenTilesAndReloadTilePatterns @@ -236,8 +236,8 @@ DisplayNamingScreen: ; 6596 (1:6596) cp $e4 ld de, Handakutens jr z, .asm_66e3 - ld a, [wd07d] - cp $2 + ld a, [wNamingScreenType] + cp NAME_MON_SCREEN jr nc, .checkMonNameLength ld a, [wHPBarMaxHP] cp $7 ; max length of player/rival names @@ -377,8 +377,8 @@ Func_680e: ; 680e (1:680e) ld de, wcf4b call PlaceString hlCoord 10, 3 - ld a, [wd07d] - cp $2 + ld a, [wNamingScreenType] + cp NAME_MON_SCREEN jr nc, .asm_6835 ld b, $7 jr .asm_6837 @@ -390,8 +390,8 @@ Func_680e: ; 680e (1:680e) ld [hli], a dec b jr nz, .asm_6839 - ld a, [wd07d] - cp $2 + ld a, [wNamingScreenType] + cp NAME_MON_SCREEN ld a, [wHPBarMaxHP] jr nc, .asm_684b cp $7 @@ -405,8 +405,8 @@ Func_680e: ; 680e (1:680e) ld [wTopMenuItemX], a ld a, $5 ld [wCurrentMenuItem], a - ld a, [wd07d] - cp $2 + ld a, [wNamingScreenType] + cp NAME_MON_SCREEN ld a, $9 jr nc, .asm_6867 ld a, $6 @@ -462,7 +462,7 @@ CalcStringLength: ; 68eb (1:68eb) PrintNamingText: ; 68f8 (1:68f8) hlCoord 0, 1 - ld a, [wd07d] + ld a, [wNamingScreenType] ld de, YourTextString and a jr z, .notNickname diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 6b365e2b..edd65a81 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -1,4 +1,4 @@ -; [wd07d] = menu type / message ID +; [wPartyMenuTypeOrMessageID] = menu type / message ID ; if less than $F0, it is a menu type ; menu types: ; 00: normal pokemon menu (e.g. Start menu) @@ -25,11 +25,11 @@ DrawPartyMenu_: ; 12cd2 (4:6cd2) callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics RedrawPartyMenu_: ; 12ce3 (4:6ce3) - ld a,[wd07d] - cp a,$04 + ld a,[wPartyMenuTypeOrMessageID] + cp a,SWAP_MONS_PARTY_MENU jp z,.printMessage call ErasePartyMenuCursors - callba SendBlkPacket_PartyMenu ; loads some data to wcf2e + callba SendBlkPacket_PartyMenu hlCoord 3, 0 ld de,wPartySpecies xor a @@ -75,10 +75,10 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) inc hl inc hl .skipUnfilledRightArrow - ld a,[wd07d] ; menu type - cp a,$03 + ld a,[wPartyMenuTypeOrMessageID] ; menu type + cp a,TMHM_PARTY_MENU jr z,.teachMoveMenu - cp a,$05 + cp a,EVO_STONE_PARTY_MENU jr z,.evolutionStoneMenu push hl ld bc,14 ; 14 columns to the right @@ -196,7 +196,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) push af push hl set 6,[hl] ; turn off letter printing delay - ld a,[wd07d] ; message ID + ld a,[wPartyMenuTypeOrMessageID] ; message ID cp a,$F0 jr nc,.printItemUseMessage add a diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 0a940356..d97c3d99 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -12,14 +12,14 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) jp z,RedisplayStartMenu xor a ld [wMenuItemToSwap],a - ld [wd07d],a + ld [wPartyMenuTypeOrMessageID],a ld [wUpdateSpritesEnabled],a call DisplayPartyMenu jr .checkIfPokemonChosen .loop xor a ld [wMenuItemToSwap],a - ld [wd07d],a + ld [wPartyMenuTypeOrMessageID],a call GoBackToPartyMenu .checkIfPokemonChosen jr nc,.chosePokemon @@ -89,8 +89,8 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) cp a,2 ; is there more than one pokemon in the party? jp c,StartMenu_Pokemon ; if not, no switching call SwitchPartyMon_Stats - ld a,$04 ; swap pokemon positions menu - ld [wd07d],a + ld a,SWAP_MONS_PARTY_MENU + ld [wPartyMenuTypeOrMessageID],a call GoBackToPartyMenu jp .checkIfPokemonChosen .choseStats @@ -747,7 +747,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ret .asm_13661 xor a - ld [wd07d], a + ld [wPartyMenuTypeOrMessageID], a ld a, [wMenuItemToSwap] dec a ld b, a @@ -757,7 +757,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) jr nz, .asm_1367b xor a ld [wMenuItemToSwap], a - ld [wd07d], a + ld [wPartyMenuTypeOrMessageID], a ret .asm_1367b ld a, b @@ -845,7 +845,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld [wWhichTrade], a xor a ld [wMenuItemToSwap], a - ld [wd07d], a + ld [wPartyMenuTypeOrMessageID], a pop de pop hl ret diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm index d8043484..49154d13 100755 --- a/engine/oak_speech2.asm +++ b/engine/oak_speech2.asm @@ -12,8 +12,8 @@ LoadDefaultNamesPlayer: ; 695d (1:695d) jr .asm_6999 .asm_697a ld hl, wPlayerName - xor a - ld [wd07d], a + xor a ; NAME_PLAYER_SCREEN + ld [wNamingScreenType], a call DisplayNamingScreen ld a, [wcf4b] cp $50 @@ -45,8 +45,8 @@ LoadDefaultNamesRival: ; 69a4 (1:69a4) jr .asm_69e1 .asm_69c1 ld hl, W_RIVALNAME - ld a, $1 - ld [wd07d], a + ld a, NAME_RIVAL_SCREEN + ld [wNamingScreenType], a call DisplayNamingScreen ld a, [wcf4b] cp $50 diff --git a/home.asm b/home.asm index f7da6e3a..b76713bf 100644 --- a/home.asm +++ b/home.asm @@ -456,7 +456,7 @@ HandlePartyMenuInput:: ; 145a (0:145a) callba ErasePartyMenuCursors xor a ld [wMenuItemToSwap],a - ld [wd07d],a + ld [wPartyMenuTypeOrMessageID],a call RedrawPartyMenu jr HandlePartyMenuInput .handleSwap diff --git a/main.asm b/main.asm index 3a1e0621..d3e2f404 100755 --- a/main.asm +++ b/main.asm @@ -3582,8 +3582,8 @@ _AddPartyMon: ; f2e5 (3:72e5) ld a, [$ffe4] dec a call SkipFixedLengthTextEntries - ld a, $2 - ld [wd07d], a + ld a, NAME_MON_SCREEN + ld [wNamingScreenType], a predef AskName .asm_f33f ld hl, wPartyMons diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index f48584dc..5e80a10f 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -25,7 +25,7 @@ DayCareMText1: ; 56254 (15:6254) call PrintText xor a ld [wUpdateSpritesEnabled], a - ld [wd07d], a + ld [wPartyMenuTypeOrMessageID], a ld [wMenuItemToSwap], a call DisplayPartyMenu push af diff --git a/scripts/namerater.asm b/scripts/namerater.asm index 010dc0cd..c2d028ef 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -49,7 +49,7 @@ NameRaterText1: ; 1da56 (7:5a56) ld hl, NameRaterText_1dab8 call PrintText xor a - ld [wd07d], a + ld [wPartyMenuTypeOrMessageID], a ld [wUpdateSpritesEnabled], a ld [wMenuItemToSwap], a call DisplayPartyMenu @@ -68,7 +68,7 @@ NameRaterText1: ; 1da56 (7:5a56) jr nz, .asm_1daae ld hl, NameRaterText_1dac2 call PrintText - callba Func_655c + callba DisplayNameRaterScreen jr c, .asm_1daae ld hl, NameRaterText_1dac7 .asm_1daa8 diff --git a/wram.asm b/wram.asm index c1002fcd..13853b55 100755 --- a/wram.asm +++ b/wram.asm @@ -1232,7 +1232,13 @@ W_ANIMATIONID:: ; d07c ; ID number of the current battle animation ds 1 -wd07d:: ds 1 ; used with naming functions and party display type +wNamingScreenType:: ; d07d + +wPartyMenuTypeOrMessageID:: ; d07d + +wTempTilesetNumTiles:: ; d07d +; temporary storage for the number of tiles in a tileset + ds 1 wSavedListScrollOffset:: ; d07e ; used by the pokemart code to save the existing value of wListScrollOffset -- cgit v1.3.1-sl0p