diff options
Diffstat (limited to 'engine/items/mart.asm')
-rw-r--r-- | engine/items/mart.asm | 283 |
1 files changed, 104 insertions, 179 deletions
diff --git a/engine/items/mart.asm b/engine/items/mart.asm index 911251f65..7e185662b 100644 --- a/engine/items/mart.asm +++ b/engine/items/mart.asm @@ -6,7 +6,7 @@ const MARTTEXT_HERE_YOU_GO const MARTTEXT_SOLD_OUT -OpenMartDialog:: ; 15a45 +OpenMartDialog:: call GetMart ld a, c ld [wEngineBuffer1], a @@ -15,7 +15,6 @@ OpenMartDialog:: ; 15a45 ld hl, .dialogs rst JumpTable ret -; 15a57 .dialogs dw MartDialog @@ -23,18 +22,16 @@ OpenMartDialog:: ; 15a45 dw BargainShop dw Pharmacist dw RooftopSale -; 15a61 -MartDialog: ; 15a61 +MartDialog: ld a, 0 ld [wEngineBuffer1], a - xor a + xor a ; STANDARDMART_HOWMAYIHELPYOU ld [wEngineBuffer5], a call StandardMart ret -; 15a6e -HerbShop: ; 15a6e +HerbShop: call FarReadMart call LoadStandardMenuHeader ld hl, Text_HerbShop_Intro @@ -43,9 +40,8 @@ HerbShop: ; 15a6e ld hl, Text_HerbShop_ComeAgain call MartTextBox ret -; 15a84 -BargainShop: ; 15a84 +BargainShop: ld b, BANK(BargainShopData) ld de, BargainShopData call LoadMartPointer @@ -65,9 +61,8 @@ BargainShop: ; 15a84 ld hl, Text_BargainShop_ComeAgain call MartTextBox ret -; 15aae -Pharmacist: ; 15aae +Pharmacist: call FarReadMart call LoadStandardMenuHeader ld hl, Text_Pharmacist_Intro @@ -76,9 +71,8 @@ Pharmacist: ; 15aae ld hl, Text_Pharmacist_ComeAgain call MartTextBox ret -; 15ac4 -RooftopSale: ; 15ac4 +RooftopSale: ld b, BANK(RooftopSaleMart1) ld de, RooftopSaleMart1 ld hl, wStatusFlags @@ -97,11 +91,10 @@ RooftopSale: ; 15ac4 ld hl, Text_Mart_ComeAgain call MartTextBox ret -; 15aee INCLUDE "data/items/rooftop_sale.asm" -LoadMartPointer: ; 15b10 +LoadMartPointer: ld a, b ld [wMartPointerBank], a ld a, e @@ -110,16 +103,15 @@ LoadMartPointer: ; 15b10 ld [wMartPointer + 1], a ld hl, wCurMart xor a - ld bc, 16 + ld bc, wCurMartEnd - wCurMart call ByteFill xor a ld [wEngineBuffer5], a ld [wBargainShopFlags], a ld [wFacingDirection], a ret -; 15b31 -GetMart: ; 15b31 +GetMart: ld a, e cp (Marts.End - Marts) / 2 jr c, .IsAMart @@ -136,36 +128,43 @@ GetMart: ; 15b31 ld d, [hl] ld b, BANK(Marts) ret -; 15b47 -StandardMart: ; 15b47 +; StandardMart.MartFunctions indexes + const_def + const STANDARDMART_HOWMAYIHELPYOU ; 0 + const STANDARDMART_TOPMENU ; 1 + const STANDARDMART_BUY ; 2 + const STANDARDMART_SELL ; 3 + const STANDARDMART_QUIT ; 4 + const STANDARDMART_ANYTHINGELSE ; 5 + +StandardMart: .loop ld a, [wEngineBuffer5] ld hl, .MartFunctions rst JumpTable ld [wEngineBuffer5], a - cp $ff + cp -1 jr nz, .loop ret .MartFunctions: +; entries correspond to STANDARDMART_* constants dw .HowMayIHelpYou dw .TopMenu dw .Buy dw .Sell dw .Quit dw .AnythingElse -; 15b62 -.HowMayIHelpYou: ; 15b62 +.HowMayIHelpYou: call LoadStandardMenuHeader ld hl, Text_Mart_HowMayIHelpYou call PrintText - ld a, $1 ; top menu + ld a, STANDARDMART_TOPMENU ret -; 15b6e -.TopMenu: ; 15b6e +.TopMenu: ld hl, MenuHeader_BuySell call CopyMenuHeader call VerticalMenu @@ -176,49 +175,44 @@ StandardMart: ; 15b47 cp $2 jr z, .sell .quit - ld a, $4 ; Come again! + ld a, STANDARDMART_QUIT ret .buy - ld a, $2 ; buy + ld a, STANDARDMART_BUY ret .sell - ld a, $3 ; sell + ld a, STANDARDMART_SELL ret -; 15b8d -.Buy: ; 15b8d +.Buy: call ExitMenu call FarReadMart call BuyMenu and a - ld a, $5 ; Anything else? + ld a, STANDARDMART_ANYTHINGELSE ret -; 15b9a -.Sell: ; 15b9a +.Sell: call ExitMenu call SellMenu - ld a, $5 ; Anything else? + ld a, STANDARDMART_ANYTHINGELSE ret -; 15ba3 -.Quit: ; 15ba3 +.Quit: call ExitMenu ld hl, Text_Mart_ComeAgain call MartTextBox - ld a, $ff ; exit + ld a, -1 ret -; 15baf -.AnythingElse: ; 15baf +.AnythingElse: call LoadStandardMenuHeader ld hl, Text_Mart_AnythingElse call PrintText - ld a, $1 ; top menu + ld a, STANDARDMART_TOPMENU ret -; 15bbb -FarReadMart: ; 15bbb +FarReadMart: ld hl, wMartPointer ld a, [hli] ld h, [hl] @@ -246,16 +240,15 @@ FarReadMart: ; 15bbb .done ret -; 15be5 -GetMartItemPrice: ; 15be5 +GetMartItemPrice: ; Return the price of item a in BCD at hl and in tiles at wStringBuffer1. push hl ld [wCurItem], a farcall GetItemPrice pop hl -GetMartPrice: ; 15bf0 +GetMartPrice: ; Return price de in BCD at hl and in tiles at wStringBuffer1. push hl ld a, d @@ -280,9 +273,8 @@ GetMartPrice: ; 15bf0 dec c jr nz, .loop ret -; 15c1a -.CharToNybble: ; 15c1a +.CharToNybble: ld a, [de] inc de cp " " @@ -292,9 +284,8 @@ GetMartPrice: ; 15bf0 .not_space sub "0" ret -; 15c25 -ReadMart: ; 15c25 +ReadMart: ; Load the mart pointer. Mart data is local (no need for bank). ld hl, wMartPointer ld a, [hli] @@ -337,12 +328,10 @@ ReadMart: ; 15c25 ld a, [hl] ld [wCurMart], a ret -; 15c51 INCLUDE "data/items/bargain_shop.asm" - -BuyMenu: ; 15c62 +BuyMenu: call FadeToMenu farcall BlankScreen xor a @@ -354,9 +343,8 @@ BuyMenu: ; 15c62 jr nc, .loop call CloseSubmenu ret -; 15c7d -LoadBuyMenuText: ; 15c7d +LoadBuyMenuText: ; load text from a nested table ; which table is in wEngineBuffer1 ; which entry is in register a @@ -375,9 +363,8 @@ LoadBuyMenuText: ; 15c7d ld l, a call PrintText ret -; 15c91 -MartAskPurchaseQuantity: ; 15c91 +MartAskPurchaseQuantity: call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers inc hl inc hl @@ -387,9 +374,8 @@ MartAskPurchaseQuantity: ; 15c91 cp 1 jp z, BargainShopAskPurchaseQuantity jp RooftopSaleAskPurchaseQuantity -; 15ca3 -GetMartDialogGroup: ; 15ca3 +GetMartDialogGroup: ld a, [wEngineBuffer1] ld e, a ld d, 0 @@ -398,17 +384,15 @@ GetMartDialogGroup: ; 15ca3 add hl, de add hl, de ret -; 15cb0 -.MartTextFunctionPointers: ; 15cb0 +.MartTextFunctionPointers: dwb .StandardMartPointers, 0 dwb .HerbShopPointers, 0 dwb .BargainShopPointers, 1 dwb .PharmacyPointers, 0 dwb .StandardMartPointers, 2 -; 15cbf -.StandardMartPointers: ; 15cbf +.StandardMartPointers: dw Text_Mart_HowMany dw Text_Mart_CostsThisMuch dw Text_Mart_InsufficientFunds @@ -416,7 +400,7 @@ GetMartDialogGroup: ; 15ca3 dw Text_Mart_HereYouGo dw BuyMenuLoop -.HerbShopPointers: ; 15ccb +.HerbShopPointers: dw Text_HerbShop_HowMany dw Text_HerbShop_CostsThisMuch dw Text_HerbShop_InsufficientFunds @@ -424,7 +408,7 @@ GetMartDialogGroup: ; 15ca3 dw Text_HerbShop_HereYouGo dw BuyMenuLoop -.BargainShopPointers: ; 15cd7 +.BargainShopPointers: dw BuyMenuLoop dw Text_BargainShop_CostsThisMuch dw Text_BargainShop_InsufficientFunds @@ -432,17 +416,15 @@ GetMartDialogGroup: ; 15ca3 dw Text_BargainShop_HereYouGo dw Text_BargainShop_SoldOut -.PharmacyPointers: ; 15ce3 +.PharmacyPointers: dw Text_Pharmacy_HowMany dw Text_Pharmacy_CostsThisMuch dw Text_Pharmacy_InsufficientFunds dw Text_Pharmacy_BagFull dw Text_Pharmacy_HereYouGo dw BuyMenuLoop -; 15cef - -BuyMenuLoop: ; 15cef +BuyMenuLoop: farcall PlaceMoneyTopRight call UpdateSprites ld hl, MenuHeader_Buy @@ -470,7 +452,7 @@ BuyMenuLoop: ; 15cef jr c, .cancel ld de, wMoney ld bc, hMoneyTemp - ld a, $3 ; useless load + ld a, 3 ; useless load call CompareMoney jr c, .insufficient_funds ld hl, wNumItems @@ -478,7 +460,7 @@ BuyMenuLoop: ; 15cef jr nc, .insufficient_bag_space ld a, [wMartItemID] ld e, a - ld d, $0 + ld d, 0 ld b, SET_FLAG ld hl, wBargainShopFlags call FlagAction @@ -512,7 +494,6 @@ BuyMenuLoop: ; 15cef call JoyWaitAorB and a ret -; 15d83 StandardMartAskPurchaseQuantity: ld a, 99 @@ -522,22 +503,20 @@ StandardMartAskPurchaseQuantity: farcall SelectQuantityToBuy call ExitMenu ret -; 15d97 -MartConfirmPurchase: ; 15d97 +MartConfirmPurchase: predef PartyMonItemName ld a, MARTTEXT_COSTS_THIS_MUCH call LoadBuyMenuText call YesNoBox ret -; 15da5 BargainShopAskPurchaseQuantity: ld a, 1 ld [wItemQuantityChangeBuffer], a ld a, [wMartItemID] ld e, a - ld d, $0 + ld d, 0 ld b, CHECK_FLAG ld hl, wBargainShopFlags call FlagAction @@ -546,7 +525,7 @@ BargainShopAskPurchaseQuantity: jr nz, .SoldOut ld a, [wMartItemID] ld e, a - ld d, $0 + ld d, 0 ld hl, wMartPointer ld a, [hli] ld h, [hl] @@ -571,7 +550,6 @@ BargainShopAskPurchaseQuantity: call JoyWaitAorB scf ret -; 15de2 RooftopSaleAskPurchaseQuantity: ld a, MARTTEXT_HOW_MANY @@ -582,9 +560,8 @@ RooftopSaleAskPurchaseQuantity: farcall RooftopSale_SelectQuantityToBuy call ExitMenu ret -; 15df9 -.GetSalePrice: ; 15df9 +.GetSalePrice: ld a, [wMartItemID] ld e, a ld d, 0 @@ -601,29 +578,24 @@ RooftopSaleAskPurchaseQuantity: inc hl ld d, [hl] ret -; 15e0e - -Text_Mart_HowMany: ; 0x15e0e +Text_Mart_HowMany: ; How many? text_jump UnknownText_0x1c4bfd db "@" -; 0x15e13 -Text_Mart_CostsThisMuch: ; 0x15e13 +Text_Mart_CostsThisMuch: ; @ (S) will be ¥@ . text_jump UnknownText_0x1c4c08 db "@" -; 0x15e18 -MenuHeader_Buy: ; 0x15e18 +MenuHeader_Buy: db MENU_BACKUP_TILES ; flags menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw .MenuData db 1 ; default option -; 0x15e20 -.MenuData ; 0x15e20 +.MenuData db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags db 4, 8 ; rows, columns db 1 ; horizontal spacing @@ -631,9 +603,8 @@ MenuHeader_Buy: ; 0x15e18 dba PlaceMenuItemName dba .PrintBCDPrices dba UpdateItemDescription -; 15e30 -.PrintBCDPrices: ; 15e30 +.PrintBCDPrices: ld a, [wScrollingMenuCursorPosition] ld c, a ld b, 0 @@ -650,136 +621,113 @@ MenuHeader_Buy: ; 0x15e18 ld c, PRINTNUM_LEADINGZEROS | PRINTNUM_MONEY | 3 call PrintBCDNumber ret -; 15e4a (5:5e4a) -Text_HerbShop_Intro: ; 0x15e4a +Text_HerbShop_Intro: ; Hello, dear. I sell inexpensive herbal medicine. They're good, but a trifle bitter. Your #MON may not like them. Hehehehe… text_jump UnknownText_0x1c4c28 db "@" -; 0x15e4f -Text_HerbShop_HowMany: ; 0x15e4f +Text_HerbShop_HowMany: ; How many? text_jump UnknownText_0x1c4ca3 db "@" -; 0x15e54 -Text_HerbShop_CostsThisMuch: ; 0x15e54 +Text_HerbShop_CostsThisMuch: ; @ (S) will be ¥@ . text_jump UnknownText_0x1c4cae db "@" -; 0x15e59 -Text_HerbShop_HereYouGo: ; 0x15e59 +Text_HerbShop_HereYouGo: ; Thank you, dear. Hehehehe… text_jump UnknownText_0x1c4cce db "@" -; 0x15e5e -Text_HerbShop_BagFull: ; 0x15e5e +Text_HerbShop_BagFull: ; Oh? Your PACK is full, dear. text_jump UnknownText_0x1c4cea db "@" -; 0x15e63 -Text_HerbShop_InsufficientFunds: ; 0x15e63 +Text_HerbShop_InsufficientFunds: ; Hehehe… You don't have the money. text_jump UnknownText_0x1c4d08 db "@" -; 0x15e68 -Text_HerbShop_ComeAgain: ; 0x15e68 +Text_HerbShop_ComeAgain: ; Come again, dear. Hehehehe… text_jump UnknownText_0x1c4d2a db "@" -; 0x15e6d -Text_BargainShop_Intro: ; 0x15e6d +Text_BargainShop_Intro: ; Hiya! Care to see some bargains? I sell rare items that nobody else carries--but only one of each item. text_jump UnknownText_0x1c4d47 db "@" -; 0x15e72 -Text_BargainShop_CostsThisMuch: ; 0x15e72 +Text_BargainShop_CostsThisMuch: ; costs ¥@ . Want it? text_jump UnknownText_0x1c4db0 db "@" -; 0x15e77 -Text_BargainShop_HereYouGo: ; 0x15e77 +Text_BargainShop_HereYouGo: ; Thanks. text_jump UnknownText_0x1c4dcd db "@" -; 0x15e7c -Text_BargainShop_BagFull: ; 0x15e7c +Text_BargainShop_BagFull: ; Uh-oh, your PACK is chock-full. text_jump UnknownText_0x1c4dd6 db "@" -; 0x15e81 -Text_BargainShop_SoldOut: ; 0x15e81 +Text_BargainShop_SoldOut: ; You bought that already. I'm all sold out of it. text_jump UnknownText_0x1c4df7 db "@" -; 0x15e86 -Text_BargainShop_InsufficientFunds: ; 0x15e86 +Text_BargainShop_InsufficientFunds: ; Uh-oh, you're short on funds. text_jump UnknownText_0x1c4e28 db "@" -; 0x15e8b -Text_BargainShop_ComeAgain: ; 0x15e8b +Text_BargainShop_ComeAgain: ; Come by again sometime. text_jump UnknownText_0x1c4e46 db "@" -; 0x15e90 -Text_Pharmacist_Intro: ; 0x15e90 +Text_Pharmacist_Intro: ; What's up? Need some medicine? text_jump UnknownText_0x1c4e5f db "@" -; 0x15e95 -Text_Pharmacy_HowMany: ; 0x15e95 +Text_Pharmacy_HowMany: ; How many? text_jump UnknownText_0x1c4e7e db "@" -; 0x15e9a -Text_Pharmacy_CostsThisMuch: ; 0x15e9a +Text_Pharmacy_CostsThisMuch: ; @ (S) will cost ¥@ . text_jump UnknownText_0x1c4e89 db "@" -; 0x15e9f -Text_Pharmacy_HereYouGo: ; 0x15e9f +Text_Pharmacy_HereYouGo: ; Thanks much! text_jump UnknownText_0x1c4eab db "@" -; 0x15ea4 -Text_Pharmacy_BagFull: ; 0x15ea4 +Text_Pharmacy_BagFull: ; You don't have any more space. text_jump UnknownText_0x1c4eb9 db "@" -; 0x15ea9 -Text_Pharmacy_InsufficientFunds: ; 0x15ea9 +Text_Pharmacy_InsufficientFunds: ; Huh? That's not enough money. text_jump UnknownText_0x1c4ed8 db "@" -; 0x15eae -Text_Pharmacist_ComeAgain: ; 0x15eae +Text_Pharmacist_ComeAgain: ; All right. See you around. text_jump UnknownText_0x1c4ef6 db "@" -; 0x15eb3 - -SellMenu: ; 15eb3 +SellMenu: call DisableSpriteUpdates farcall DepositSellInitPackBuffers .loop @@ -794,31 +742,26 @@ SellMenu: ; 15eb3 call ReturnToMapWithSpeechTextbox and a ret -; 15ed3 .Unreferenced_NothingToSell: ld hl, .NothingToSellText call MenuTextBoxBackup and a ret -; 15edb -.NothingToSellText: ; 0x15edb +.NothingToSellText: ; You don't have anything to sell. text_jump UnknownText_0x1c4f12 db "@" -; 0x15ee0 - -.TryToSellItem: ; 15ee0 +.TryToSellItem: farcall CheckItemMenu ld a, [wItemAttributeParamBuffer] ld hl, .dw rst JumpTable ret -; 15eee -.dw ; 15eee +.dw dw .try_sell dw .cant_buy dw .cant_buy @@ -826,14 +769,11 @@ SellMenu: ; 15eb3 dw .try_sell dw .try_sell dw .try_sell -; 15efc -.cant_buy ; 15efc +.cant_buy ret -; 15efd - -.try_sell ; 15efd +.try_sell farcall _CheckTossableItem ld a, [wItemAttributeParamBuffer] and a @@ -877,94 +817,79 @@ SellMenu: ; 15eb3 call ExitMenu and a ret -; 15f73 -Text_Mart_SellHowMany: ; 0x15f73 +Text_Mart_SellHowMany: ; How many? text_jump UnknownText_0x1c4f33 db "@" -; 0x15f78 -Text_Mart_ICanPayThisMuch: ; 0x15f78 +Text_Mart_ICanPayThisMuch: ; I can pay you ¥@ . Is that OK? text_jump UnknownText_0x1c4f3e db "@" -; 0x15f7d -.UnusedString15f7d: ; 15f7d +.UnusedString15f7d: db "!ダミー!@" -Text_Mart_HowMayIHelpYou: ; 0x15f83 +Text_Mart_HowMayIHelpYou: ; Welcome! How may I help you? text_jump UnknownText_0x1c4f62 db "@" -; 0x15f88 -MenuHeader_BuySell: ; 0x15f88 +MenuHeader_BuySell: db MENU_BACKUP_TILES ; flags menu_coords 0, 0, 7, 8 dw .MenuData db 1 ; default option -; 0x15f90 -.MenuData ; 0x15f90 +.MenuData db STATICMENU_CURSOR ; strings db 3 ; items db "BUY@" db "SELL@" db "QUIT@" -; 0x15f96 -Text_Mart_HereYouGo: ; 0x15fa0 +Text_Mart_HereYouGo: ; Here you are. Thank you! text_jump UnknownText_0x1c4f80 db "@" -; 0x15fa5 -Text_Mart_InsufficientFunds: ; 0x15fa5 +Text_Mart_InsufficientFunds: ; You don't have enough money. text_jump UnknownText_0x1c4f9a db "@" -; 0x15faa -Text_Mart_BagFull: ; 0x15faa +Text_Mart_BagFull: ; You can't carry any more items. text_jump UnknownText_0x1c4fb7 db "@" -; 0x15faf -TextMart_CantBuyFromYou: ; 0x15faf +TextMart_CantBuyFromYou: ; Sorry, I can't buy that from you. text_jump UnknownText_0x1c4fd7 db "@" -; 0x15fb4 -Text_Mart_ComeAgain: ; 0x15fb4 +Text_Mart_ComeAgain: ; Please come again! text_jump UnknownText_0x1c4ff9 db "@" -; 0x15fb9 -Text_Mart_AnythingElse: ; 0x15fb9 +Text_Mart_AnythingElse: text_jump UnknownText_0x1c500d db "@" -; 0x15fbe -Text_Mart_SoldForAmount: ; 0x15fbe +Text_Mart_SoldForAmount: text_jump UnknownText_0x1c502e db "@" -; 0x15fc3 -PlayTransactionSound: ; 15fc3 +PlayTransactionSound: call WaitSFX ld de, SFX_TRANSACTION call PlaySFX ret -; 15fcd -MartTextBox: ; 15fcd +MartTextBox: call MenuTextBox call JoyWaitAorB call ExitMenu ret -; 15fd7 |