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

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

View file

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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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