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

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