pokecrystal-board/engine/items/mart.asm

898 lines
15 KiB
NASM
Raw Normal View History

2015-11-11 11:12:46 -08:00
const_def
const MARTTEXT_HOW_MANY
const MARTTEXT_COSTS_THIS_MUCH
const MARTTEXT_NOT_ENOUGH_MONEY
const MARTTEXT_BAG_FULL
const MARTTEXT_HERE_YOU_GO
const MARTTEXT_SOLD_OUT
2018-06-24 07:09:41 -07:00
OpenMartDialog::
2015-11-11 11:12:46 -08:00
call GetMart
ld a, c
ld [wMartType], a
2015-11-11 11:12:46 -08:00
call LoadMartPointer
ld a, [wMartType]
2015-11-11 11:12:46 -08:00
ld hl, .dialogs
rst JumpTable
ret
.dialogs
dw MartDialog
dw HerbShop
dw BargainShop
dw Pharmacist
dw RooftopSale
2018-06-24 07:09:41 -07:00
MartDialog:
ld a, MARTTYPE_STANDARD
ld [wMartType], a
xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wMartJumptableIndex], a
2015-11-11 11:12:46 -08:00
call StandardMart
ret
2018-06-24 07:09:41 -07:00
HerbShop:
2015-11-11 11:12:46 -08:00
call FarReadMart
call LoadStandardMenuHeader
2015-11-11 11:12:46 -08:00
ld hl, Text_HerbShop_Intro
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
call BuyMenu
ld hl, Text_HerbShop_ComeAgain
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
BargainShop:
2015-11-11 11:12:46 -08:00
ld b, BANK(BargainShopData)
ld de, BargainShopData
call LoadMartPointer
call ReadMart
call LoadStandardMenuHeader
2015-11-11 11:12:46 -08:00
ld hl, Text_BargainShop_Intro
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
call BuyMenu
ld hl, wBargainShopFlags
ld a, [hli]
or [hl]
jr z, .skip_set
ld hl, wDailyFlags1
set DAILYFLAGS1_GOLDENROD_UNDERGROUND_BARGAIN_F, [hl]
2015-11-11 11:12:46 -08:00
.skip_set
ld hl, Text_BargainShop_ComeAgain
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
Pharmacist:
2015-11-11 11:12:46 -08:00
call FarReadMart
call LoadStandardMenuHeader
2015-12-18 17:07:09 -08:00
ld hl, Text_Pharmacist_Intro
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
call BuyMenu
2015-12-18 17:07:09 -08:00
ld hl, Text_Pharmacist_ComeAgain
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
RooftopSale:
ld b, BANK(RooftopSaleMart1)
ld de, RooftopSaleMart1
ld hl, wStatusFlags
2018-01-22 12:40:43 -08:00
bit STATUSFLAGS_HALL_OF_FAME_F, [hl]
2015-11-11 11:12:46 -08:00
jr z, .ok
ld b, BANK(RooftopSaleMart2)
ld de, RooftopSaleMart2
2015-11-11 11:12:46 -08:00
.ok
call LoadMartPointer
call ReadMart
call LoadStandardMenuHeader
2015-11-11 11:12:46 -08:00
ld hl, Text_Mart_HowMayIHelpYou
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
call BuyMenu
ld hl, Text_Mart_ComeAgain
2019-04-08 05:15:10 -07:00
call MartTextbox
2015-11-11 11:12:46 -08:00
ret
INCLUDE "data/items/rooftop_sale.asm"
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
LoadMartPointer:
2015-11-11 11:12:46 -08:00
ld a, b
2018-01-23 14:39:09 -08:00
ld [wMartPointerBank], a
2015-11-11 11:12:46 -08:00
ld a, e
2018-01-23 14:39:09 -08:00
ld [wMartPointer], a
2015-11-11 11:12:46 -08:00
ld a, d
2018-01-23 14:39:09 -08:00
ld [wMartPointer + 1], a
ld hl, wCurMart
2015-11-11 11:12:46 -08:00
xor a
2018-06-23 20:15:13 -07:00
ld bc, wCurMartEnd - wCurMart
2015-11-11 11:12:46 -08:00
call ByteFill
xor a ; STANDARDMART_HOWMAYIHELPYOU
ld [wMartJumptableIndex], a
2015-11-11 11:12:46 -08:00
ld [wBargainShopFlags], a
2018-01-23 14:39:09 -08:00
ld [wFacingDirection], a
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
GetMart:
2015-11-11 11:12:46 -08:00
ld a, e
cp (Marts.End - Marts) / 2
2015-11-11 11:12:46 -08:00
jr c, .IsAMart
2016-01-27 09:25:12 -08:00
ld b, BANK(DefaultMart)
2015-11-11 11:12:46 -08:00
ld de, DefaultMart
ret
.IsAMart:
2015-11-11 11:12:46 -08:00
ld hl, Marts
add hl, de
add hl, de
2015-11-11 11:12:46 -08:00
ld e, [hl]
inc hl
ld d, [hl]
2016-01-27 09:25:12 -08:00
ld b, BANK(Marts)
2015-11-11 11:12:46 -08:00
ret
; 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_EXIT EQU -1
2018-06-24 07:09:41 -07:00
StandardMart:
2015-11-11 11:12:46 -08:00
.loop
ld a, [wMartJumptableIndex]
2015-11-11 11:12:46 -08:00
ld hl, .MartFunctions
rst JumpTable
ld [wMartJumptableIndex], a
cp STANDARDMART_EXIT
2015-11-11 11:12:46 -08:00
jr nz, .loop
ret
.MartFunctions:
; entries correspond to STANDARDMART_* constants
2015-11-11 11:12:46 -08:00
dw .HowMayIHelpYou
dw .TopMenu
dw .Buy
dw .Sell
dw .Quit
dw .AnythingElse
2018-06-24 07:09:41 -07:00
.HowMayIHelpYou:
call LoadStandardMenuHeader
2015-11-11 11:12:46 -08:00
ld hl, Text_Mart_HowMayIHelpYou
call PrintText
ld a, STANDARDMART_TOPMENU
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.TopMenu:
ld hl, MenuHeader_BuySell
call CopyMenuHeader
2015-12-15 15:59:49 -08:00
call VerticalMenu
2015-11-11 11:12:46 -08:00
jr c, .quit
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 11:12:46 -08:00
cp $1
jr z, .buy
cp $2
jr z, .sell
.quit
ld a, STANDARDMART_QUIT
2015-11-11 11:12:46 -08:00
ret
.buy
ld a, STANDARDMART_BUY
2015-11-11 11:12:46 -08:00
ret
.sell
ld a, STANDARDMART_SELL
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.Buy:
2015-11-11 11:12:46 -08:00
call ExitMenu
call FarReadMart
call BuyMenu
and a
ld a, STANDARDMART_ANYTHINGELSE
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.Sell:
2015-11-11 11:12:46 -08:00
call ExitMenu
call SellMenu
ld a, STANDARDMART_ANYTHINGELSE
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.Quit:
2015-11-11 11:12:46 -08:00
call ExitMenu
ld hl, Text_Mart_ComeAgain
2019-04-08 05:15:10 -07:00
call MartTextbox
ld a, STANDARDMART_EXIT
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.AnythingElse:
call LoadStandardMenuHeader
2015-11-11 11:12:46 -08:00
ld hl, Text_Mart_AnythingElse
call PrintText
ld a, STANDARDMART_TOPMENU
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
FarReadMart:
2018-01-23 14:39:09 -08:00
ld hl, wMartPointer
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2018-01-23 14:39:09 -08:00
ld de, wCurMart
.CopyMart:
2018-01-23 14:39:09 -08:00
ld a, [wMartPointerBank]
2015-11-11 11:12:46 -08:00
call GetFarByte
ld [de], a
inc hl
inc de
cp -1
jr nz, .CopyMart
ld hl, wMartItem1BCD
2018-01-23 14:39:09 -08:00
ld de, wCurMart + 1
.ReadMartItem:
2015-11-11 11:12:46 -08:00
ld a, [de]
inc de
cp -1
jr z, .done
push de
call GetMartItemPrice
pop de
jr .ReadMartItem
.done
ret
2018-06-24 07:09:41 -07:00
GetMartItemPrice:
2018-01-23 14:39:09 -08:00
; Return the price of item a in BCD at hl and in tiles at wStringBuffer1.
2015-11-11 11:12:46 -08:00
push hl
2018-01-23 14:39:09 -08:00
ld [wCurItem], a
2017-12-24 09:47:30 -08:00
farcall GetItemPrice
2015-11-11 11:12:46 -08:00
pop hl
2018-06-24 07:09:41 -07:00
GetMartPrice:
2018-01-23 14:39:09 -08:00
; Return price de in BCD at hl and in tiles at wStringBuffer1.
2015-11-11 11:12:46 -08:00
push hl
ld a, d
2018-01-23 14:39:09 -08:00
ld [wStringBuffer2], a
2015-11-11 11:12:46 -08:00
ld a, e
2018-01-23 14:39:09 -08:00
ld [wStringBuffer2 + 1], a
ld hl, wStringBuffer1
ld de, wStringBuffer2
2015-11-11 11:12:46 -08:00
lb bc, PRINTNUM_LEADINGZEROS | 2, 6 ; 6 digits
call PrintNum
pop hl
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-11 11:12:46 -08:00
ld c, 6 / 2 ; 6 digits
.loop
call .CharToNybble
swap a
ld b, a
call .CharToNybble
or b
ld [hli], a
dec c
jr nz, .loop
ret
2018-06-24 07:09:41 -07:00
.CharToNybble:
2015-11-11 11:12:46 -08:00
ld a, [de]
inc de
cp " "
jr nz, .not_space
ld a, "0"
.not_space
sub "0"
ret
2018-06-24 07:09:41 -07:00
ReadMart:
2015-11-11 11:12:46 -08:00
; Load the mart pointer. Mart data is local (no need for bank).
2018-01-23 14:39:09 -08:00
ld hl, wMartPointer
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
push hl
; set hl to the first item
inc hl
ld bc, wMartItem1BCD
2018-01-23 14:39:09 -08:00
ld de, wCurMart + 1
2015-11-11 11:12:46 -08:00
.loop
2018-01-23 14:39:09 -08:00
; copy the item to wCurMart + (ItemIndex)
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld [de], a
inc de
; -1 is the terminator
cp -1
jr z, .done
push de
; copy the price to de
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
; convert the price to 3-byte BCD at [bc]
push hl
ld h, b
ld l, c
call GetMartPrice
ld b, h
ld c, l
pop hl
pop de
jr .loop
.done
pop hl
ld a, [hl]
2018-01-23 14:39:09 -08:00
ld [wCurMart], a
2015-11-11 11:12:46 -08:00
ret
INCLUDE "data/items/bargain_shop.asm"
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
BuyMenu:
2015-11-11 11:12:46 -08:00
call FadeToMenu
2017-12-24 09:47:30 -08:00
farcall BlankScreen
2015-11-11 11:12:46 -08:00
xor a
2017-12-09 16:41:03 -08:00
ld [wMenuScrollPositionBackup], a
2015-11-11 11:12:46 -08:00
ld a, 1
2017-12-09 16:41:03 -08:00
ld [wMenuCursorBufferBackup], a
2015-11-11 11:12:46 -08:00
.loop
call BuyMenuLoop ; menu loop
jr nc, .loop
call CloseSubmenu
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
LoadBuyMenuText:
2015-11-11 11:12:46 -08:00
; load text from a nested table
; which table is in wMartType
2015-11-11 11:12:46 -08:00
; which entry is in register a
push af
call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers
ld a, [hli]
ld h, [hl]
ld l, a
pop af
ld e, a
ld d, 0
add hl, de
add hl, de
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
ret
2018-06-24 07:09:41 -07:00
MartAskPurchaseQuantity:
2015-11-11 11:12:46 -08:00
call GetMartDialogGroup ; gets a pointer from GetMartDialogGroup.MartTextFunctionPointers
inc hl
inc hl
2015-11-11 11:12:46 -08:00
ld a, [hl]
and a
jp z, StandardMartAskPurchaseQuantity
cp 1
jp z, BargainShopAskPurchaseQuantity
jp RooftopSaleAskPurchaseQuantity
2018-06-24 07:09:41 -07:00
GetMartDialogGroup:
ld a, [wMartType]
2015-11-11 11:12:46 -08:00
ld e, a
ld d, 0
ld hl, .MartTextFunctionPointers
add hl, de
add hl, de
add hl, de
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.MartTextFunctionPointers:
2015-11-11 11:12:46 -08:00
dwb .StandardMartPointers, 0
dwb .HerbShopPointers, 0
dwb .BargainShopPointers, 1
dwb .PharmacyPointers, 0
dwb .StandardMartPointers, 2
2018-06-24 07:09:41 -07:00
.StandardMartPointers:
2015-11-11 11:12:46 -08:00
dw Text_Mart_HowMany
dw Text_Mart_CostsThisMuch
dw Text_Mart_InsufficientFunds
dw Text_Mart_BagFull
dw Text_Mart_HereYouGo
dw BuyMenuLoop
2018-06-24 07:09:41 -07:00
.HerbShopPointers:
2015-11-11 11:12:46 -08:00
dw Text_HerbShop_HowMany
dw Text_HerbShop_CostsThisMuch
dw Text_HerbShop_InsufficientFunds
dw Text_HerbShop_BagFull
dw Text_HerbShop_HereYouGo
dw BuyMenuLoop
2018-06-24 07:09:41 -07:00
.BargainShopPointers:
2015-11-11 11:12:46 -08:00
dw BuyMenuLoop
dw Text_BargainShop_CostsThisMuch
dw Text_BargainShop_InsufficientFunds
dw Text_BargainShop_BagFull
dw Text_BargainShop_HereYouGo
dw Text_BargainShop_SoldOut
2018-06-24 07:09:41 -07:00
.PharmacyPointers:
2015-11-11 11:12:46 -08:00
dw Text_Pharmacy_HowMany
dw Text_Pharmacy_CostsThisMuch
dw Text_Pharmacy_InsufficientFunds
dw Text_Pharmacy_BagFull
dw Text_Pharmacy_HereYouGo
dw BuyMenuLoop
2018-06-24 07:09:41 -07:00
BuyMenuLoop:
farcall PlaceMoneyTopRight
2015-11-11 11:12:46 -08:00
call UpdateSprites
ld hl, MenuHeader_Buy
call CopyMenuHeader
2017-12-09 16:41:03 -08:00
ld a, [wMenuCursorBufferBackup]
2015-11-11 11:12:46 -08:00
ld [wMenuCursorBuffer], a
2017-12-09 16:41:03 -08:00
ld a, [wMenuScrollPositionBackup]
2015-11-23 13:04:53 -08:00
ld [wMenuScrollPosition], a
2015-12-17 19:31:16 -08:00
call ScrollingMenu
2015-11-23 13:04:53 -08:00
ld a, [wMenuScrollPosition]
2017-12-09 16:41:03 -08:00
ld [wMenuScrollPositionBackup], a
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2017-12-09 16:41:03 -08:00
ld [wMenuCursorBufferBackup], a
2019-04-08 05:15:10 -07:00
call SpeechTextbox
2015-12-15 15:59:49 -08:00
ld a, [wMenuJoypad]
2015-11-11 11:12:46 -08:00
cp B_BUTTON
jr z, .set_carry
cp A_BUTTON
jr z, .useless_pointer
.useless_pointer
call MartAskPurchaseQuantity
jr c, .cancel
2015-12-18 17:07:09 -08:00
call MartConfirmPurchase
2015-11-11 11:12:46 -08:00
jr c, .cancel
2018-01-23 14:39:09 -08:00
ld de, wMoney
2015-11-11 11:12:46 -08:00
ld bc, hMoneyTemp
ld a, 3 ; useless load
2015-11-11 11:12:46 -08:00
call CompareMoney
jr c, .insufficient_funds
2018-01-23 14:39:09 -08:00
ld hl, wNumItems
2015-11-11 11:12:46 -08:00
call ReceiveItem
jr nc, .insufficient_bag_space
ld a, [wMartItemID]
ld e, a
ld d, 0
2015-11-11 11:12:46 -08:00
ld b, SET_FLAG
ld hl, wBargainShopFlags
call FlagAction
call PlayTransactionSound
2018-01-23 14:39:09 -08:00
ld de, wMoney
2015-11-11 11:12:46 -08:00
ld bc, hMoneyTemp
call TakeMoney
ld a, MARTTEXT_HERE_YOU_GO
call LoadBuyMenuText
call JoyWaitAorB
.cancel
2019-04-08 05:15:10 -07:00
call SpeechTextbox
2015-11-11 11:12:46 -08:00
and a
ret
.set_carry
scf
ret
.insufficient_bag_space
ld a, MARTTEXT_BAG_FULL
call LoadBuyMenuText
call JoyWaitAorB
and a
ret
.insufficient_funds
ld a, MARTTEXT_NOT_ENOUGH_MONEY
call LoadBuyMenuText
call JoyWaitAorB
and a
ret
StandardMartAskPurchaseQuantity:
ld a, 99
ld [wItemQuantityBuffer], a
ld a, MARTTEXT_HOW_MANY
call LoadBuyMenuText
2017-12-24 09:47:30 -08:00
farcall SelectQuantityToBuy
2015-11-11 11:12:46 -08:00
call ExitMenu
ret
2018-06-24 07:09:41 -07:00
MartConfirmPurchase:
predef PartyMonItemName
2015-11-11 11:12:46 -08:00
ld a, MARTTEXT_COSTS_THIS_MUCH
call LoadBuyMenuText
call YesNoBox
ret
BargainShopAskPurchaseQuantity:
ld a, 1
ld [wItemQuantityChangeBuffer], a
ld a, [wMartItemID]
ld e, a
ld d, 0
2015-11-11 11:12:46 -08:00
ld b, CHECK_FLAG
ld hl, wBargainShopFlags
call FlagAction
ld a, c
and a
jr nz, .SoldOut
ld a, [wMartItemID]
ld e, a
ld d, 0
2018-01-23 14:39:09 -08:00
ld hl, wMartPointer
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
add hl, de
add hl, de
add hl, de
2015-11-11 11:12:46 -08:00
inc hl
ld a, [hli]
ldh [hMoneyTemp + 2], a
2015-11-11 11:12:46 -08:00
ld a, [hl]
ldh [hMoneyTemp + 1], a
2015-11-11 11:12:46 -08:00
xor a
ldh [hMoneyTemp], a
2015-11-11 11:12:46 -08:00
and a
ret
.SoldOut:
2015-11-11 11:12:46 -08:00
ld a, MARTTEXT_SOLD_OUT
call LoadBuyMenuText
call JoyWaitAorB
scf
ret
RooftopSaleAskPurchaseQuantity:
ld a, MARTTEXT_HOW_MANY
call LoadBuyMenuText
call .GetSalePrice
ld a, 99
ld [wItemQuantityBuffer], a
2017-12-24 09:47:30 -08:00
farcall RooftopSale_SelectQuantityToBuy
2015-11-11 11:12:46 -08:00
call ExitMenu
ret
2018-06-24 07:09:41 -07:00
.GetSalePrice:
2015-11-11 11:12:46 -08:00
ld a, [wMartItemID]
ld e, a
ld d, 0
2018-01-23 14:39:09 -08:00
ld hl, wMartPointer
2015-11-11 11:12:46 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
add hl, de
add hl, de
add hl, de
2015-11-11 11:12:46 -08:00
inc hl
ld e, [hl]
inc hl
ld d, [hl]
ret
Text_Mart_HowMany:
2015-11-11 11:12:46 -08:00
; How many?
text_far UnknownText_0x1c4bfd
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_CostsThisMuch:
2015-11-11 11:12:46 -08:00
; @ (S) will be ¥@ .
text_far UnknownText_0x1c4c08
text_end
2015-11-11 11:12:46 -08:00
MenuHeader_Buy:
db MENU_BACKUP_TILES ; flags
menu_coords 1, 3, SCREEN_WIDTH - 1, TEXTBOX_Y - 1
dw .MenuData
2015-11-11 11:12:46 -08:00
db 1 ; default option
.MenuData
db SCROLLINGMENU_DISPLAY_ARROWS | SCROLLINGMENU_ENABLE_FUNCTION3 ; flags
2015-11-11 11:12:46 -08:00
db 4, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
2018-01-23 14:39:09 -08:00
dbw 0, wCurMart
2015-11-11 11:12:46 -08:00
dba PlaceMenuItemName
dba .PrintBCDPrices
2015-11-23 13:04:53 -08:00
dba UpdateItemDescription
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
.PrintBCDPrices:
2015-12-17 14:51:32 -08:00
ld a, [wScrollingMenuCursorPosition]
2015-11-11 11:12:46 -08:00
ld c, a
ld b, 0
ld hl, wMartItem1BCD
add hl, bc
add hl, bc
add hl, bc
2015-11-11 11:12:46 -08:00
push de
ld d, h
ld e, l
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
ld c, PRINTNUM_LEADINGZEROS | PRINTNUM_MONEY | 3
call PrintBCDNumber
ret
Text_HerbShop_Intro:
2015-11-11 11:12:46 -08:00
; Hello, dear. I sell inexpensive herbal medicine. They're good, but a trifle bitter. Your #MON may not like them. Hehehehe…
text_far UnknownText_0x1c4c28
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_HowMany:
2015-11-11 11:12:46 -08:00
; How many?
text_far UnknownText_0x1c4ca3
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_CostsThisMuch:
2015-11-11 11:12:46 -08:00
; @ (S) will be ¥@ .
text_far UnknownText_0x1c4cae
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_HereYouGo:
2015-11-11 11:12:46 -08:00
; Thank you, dear. Hehehehe…
text_far UnknownText_0x1c4cce
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_BagFull:
2015-11-11 11:12:46 -08:00
; Oh? Your PACK is full, dear.
text_far UnknownText_0x1c4cea
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_InsufficientFunds:
2015-11-11 11:12:46 -08:00
; Hehehe… You don't have the money.
text_far UnknownText_0x1c4d08
text_end
2015-11-11 11:12:46 -08:00
Text_HerbShop_ComeAgain:
2015-11-11 11:12:46 -08:00
; Come again, dear. Hehehehe…
text_far UnknownText_0x1c4d2a
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_Intro:
2015-11-11 11:12:46 -08:00
; Hiya! Care to see some bargains? I sell rare items that nobody else carries--but only one of each item.
text_far UnknownText_0x1c4d47
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_CostsThisMuch:
2015-11-11 11:12:46 -08:00
; costs ¥@ . Want it?
text_far UnknownText_0x1c4db0
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_HereYouGo:
2015-11-11 11:12:46 -08:00
; Thanks.
text_far UnknownText_0x1c4dcd
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_BagFull:
2015-11-11 11:12:46 -08:00
; Uh-oh, your PACK is chock-full.
text_far UnknownText_0x1c4dd6
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_SoldOut:
2015-11-11 11:12:46 -08:00
; You bought that already. I'm all sold out of it.
text_far UnknownText_0x1c4df7
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_InsufficientFunds:
2015-11-11 11:12:46 -08:00
; Uh-oh, you're short on funds.
text_far UnknownText_0x1c4e28
text_end
2015-11-11 11:12:46 -08:00
Text_BargainShop_ComeAgain:
2015-11-11 11:12:46 -08:00
; Come by again sometime.
text_far UnknownText_0x1c4e46
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacist_Intro:
2015-11-11 11:12:46 -08:00
; What's up? Need some medicine?
text_far UnknownText_0x1c4e5f
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacy_HowMany:
2015-11-11 11:12:46 -08:00
; How many?
text_far UnknownText_0x1c4e7e
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacy_CostsThisMuch:
2015-11-11 11:12:46 -08:00
; @ (S) will cost ¥@ .
text_far UnknownText_0x1c4e89
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacy_HereYouGo:
2015-11-11 11:12:46 -08:00
; Thanks much!
text_far UnknownText_0x1c4eab
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacy_BagFull:
2015-11-11 11:12:46 -08:00
; You don't have any more space.
text_far UnknownText_0x1c4eb9
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacy_InsufficientFunds:
2015-11-11 11:12:46 -08:00
; Huh? That's not enough money.
text_far UnknownText_0x1c4ed8
text_end
2015-11-11 11:12:46 -08:00
Text_Pharmacist_ComeAgain:
2015-11-11 11:12:46 -08:00
; All right. See you around.
text_far UnknownText_0x1c4ef6
text_end
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
SellMenu:
2015-11-11 11:12:46 -08:00
call DisableSpriteUpdates
2017-12-24 09:47:30 -08:00
farcall DepositSellInitPackBuffers
2015-12-18 17:07:09 -08:00
.loop
2017-12-24 09:47:30 -08:00
farcall DepositSellPack
2018-01-11 12:36:11 -08:00
ld a, [wPackUsedItem]
2015-11-11 11:12:46 -08:00
and a
2015-12-18 17:07:09 -08:00
jp z, .quit
call .TryToSellItem
jr .loop
2015-11-11 11:12:46 -08:00
2015-12-18 17:07:09 -08:00
.quit
call ReturnToMapWithSpeechTextbox
2015-11-11 11:12:46 -08:00
and a
ret
2018-01-02 07:04:21 -08:00
.Unreferenced_NothingToSell:
2015-12-18 17:07:09 -08:00
ld hl, .NothingToSellText
2019-04-08 05:15:10 -07:00
call MenuTextboxBackup
2015-11-11 11:12:46 -08:00
and a
ret
.NothingToSellText:
2015-11-11 11:12:46 -08:00
; You don't have anything to sell.
text_far UnknownText_0x1c4f12
text_end
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
.TryToSellItem:
2017-12-24 09:47:30 -08:00
farcall CheckItemMenu
2015-11-11 11:12:46 -08:00
ld a, [wItemAttributeParamBuffer]
2015-12-26 18:59:03 -08:00
ld hl, .dw
2015-11-11 11:12:46 -08:00
rst JumpTable
ret
2018-06-24 07:09:41 -07:00
.dw
2015-11-11 11:12:46 -08:00
dw .try_sell
dw .cant_buy
dw .cant_buy
dw .cant_buy
dw .try_sell
dw .try_sell
dw .try_sell
2018-06-24 07:09:41 -07:00
.cant_buy
2015-11-11 11:12:46 -08:00
ret
2018-06-24 07:09:41 -07:00
.try_sell
2017-12-24 09:47:30 -08:00
farcall _CheckTossableItem
2015-11-11 11:12:46 -08:00
ld a, [wItemAttributeParamBuffer]
and a
jr z, .okay_to_sell
ld hl, TextMart_CantBuyFromYou
call PrintText
and a
ret
.okay_to_sell
ld hl, Text_Mart_SellHowMany
call PrintText
2017-12-24 09:47:30 -08:00
farcall PlaceMoneyAtTopLeftOfTextbox
farcall SelectQuantityToSell
2015-11-11 11:12:46 -08:00
call ExitMenu
jr c, .declined
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, Text_Mart_ICanPayThisMuch
2019-04-08 05:15:10 -07:00
call PrintTextboxText
2015-11-11 11:12:46 -08:00
call YesNoBox
jr c, .declined
2018-01-23 14:39:09 -08:00
ld de, wMoney
2015-11-11 11:12:46 -08:00
ld bc, hMoneyTemp
call GiveMoney
ld a, [wMartItemID]
2018-01-23 14:39:09 -08:00
ld hl, wNumItems
2015-11-11 11:12:46 -08:00
call TossItem
predef PartyMonItemName
2015-11-11 11:12:46 -08:00
hlcoord 1, 14
lb bc, 3, 18
call ClearBox
ld hl, Text_Mart_SoldForAmount
2019-04-08 05:15:10 -07:00
call PrintTextboxText
2015-11-11 11:12:46 -08:00
call PlayTransactionSound
2017-12-24 09:47:30 -08:00
farcall PlaceMoneyBottomLeft
2015-11-11 11:12:46 -08:00
call JoyWaitAorB
.declined
call ExitMenu
and a
ret
Text_Mart_SellHowMany:
2015-11-11 11:12:46 -08:00
; How many?
text_far UnknownText_0x1c4f33
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_ICanPayThisMuch:
2015-11-11 11:12:46 -08:00
; I can pay you ¥@ . Is that OK?
text_far UnknownText_0x1c4f3e
text_end
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
.UnusedString15f7d:
db "!ダミー!@"
2015-11-11 11:12:46 -08:00
Text_Mart_HowMayIHelpYou:
2015-11-11 11:12:46 -08:00
; Welcome! How may I help you?
text_far UnknownText_0x1c4f62
text_end
2015-11-11 11:12:46 -08:00
MenuHeader_BuySell:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 7, 8
dw .MenuData
2015-11-11 11:12:46 -08:00
db 1 ; default option
.MenuData
db STATICMENU_CURSOR ; strings
2015-11-11 11:12:46 -08:00
db 3 ; items
db "BUY@"
db "SELL@"
db "QUIT@"
Text_Mart_HereYouGo:
2015-11-11 11:12:46 -08:00
; Here you are. Thank you!
text_far UnknownText_0x1c4f80
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_InsufficientFunds:
2015-11-11 11:12:46 -08:00
; You don't have enough money.
text_far UnknownText_0x1c4f9a
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_BagFull:
2015-11-11 11:12:46 -08:00
; You can't carry any more items.
text_far UnknownText_0x1c4fb7
text_end
2015-11-11 11:12:46 -08:00
TextMart_CantBuyFromYou:
2015-11-11 11:12:46 -08:00
; Sorry, I can't buy that from you.
text_far UnknownText_0x1c4fd7
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_ComeAgain:
2015-11-11 11:12:46 -08:00
; Please come again!
text_far UnknownText_0x1c4ff9
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_AnythingElse:
text_far UnknownText_0x1c500d
text_end
2015-11-11 11:12:46 -08:00
Text_Mart_SoldForAmount:
text_far UnknownText_0x1c502e
text_end
2015-11-11 11:12:46 -08:00
2018-06-24 07:09:41 -07:00
PlayTransactionSound:
2015-11-11 11:12:46 -08:00
call WaitSFX
ld de, SFX_TRANSACTION
call PlaySFX
ret
2019-04-08 05:15:10 -07:00
MartTextbox:
call MenuTextbox
2015-11-11 11:12:46 -08:00
call JoyWaitAorB
call ExitMenu
ret