named wram variables

This commit is contained in:
YamaArashi 2015-07-12 23:00:48 -07:00
parent 99df5f0fd7
commit 4a8c9993ad
21 changed files with 253 additions and 173 deletions

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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]

View file

@ -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]

View file

@ -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

View file

@ -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

View file

@ -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