pokered/engine/menu/vending_machine.asm

140 lines
2.2 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
VendingMachineMenu:
2014-05-22 22:13:20 +00:00
ld hl, VendingMachineText1
call PrintText
2015-02-07 20:27:36 +00:00
ld a, MONEY_BOX
2015-02-07 10:43:08 +00:00
ld [wTextBoxID], a
2014-05-22 22:13:20 +00:00
call DisplayTextBoxID
xor a
2015-02-07 20:27:36 +00:00
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
2015-07-17 07:16:27 +00:00
ld a, A_BUTTON | B_BUTTON
2015-02-07 20:27:36 +00:00
ld [wMenuWatchedKeys], a
2015-07-17 07:16:27 +00:00
ld a, 3
2015-02-07 20:27:36 +00:00
ld [wMaxMenuItem], a
2015-07-17 07:16:27 +00:00
ld a, 5
2015-02-07 20:27:36 +00:00
ld [wTopMenuItemY], a
2015-07-17 07:16:27 +00:00
ld a, 1
2015-02-07 20:27:36 +00:00
ld [wTopMenuItemX], a
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 6, [hl]
2015-07-18 20:52:03 +00:00
coord hl, 0, 3
2015-07-17 07:16:27 +00:00
ld b, 8
ld c, 12
2014-05-22 22:13:20 +00:00
call TextBoxBorder
call UpdateSprites
2015-07-18 20:52:03 +00:00
coord hl, 2, 5
2014-05-22 22:13:20 +00:00
ld de, DrinkText
call PlaceString
2015-07-18 20:52:03 +00:00
coord hl, 9, 6
2014-05-22 22:13:20 +00:00
ld de, DrinkPriceText
call PlaceString
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
call HandleMenuInput
2015-07-17 07:16:27 +00:00
bit 1, a ; pressed B?
jr nz, .notThirsty
2015-02-07 20:27:36 +00:00
ld a, [wCurrentMenuItem]
2015-07-17 07:16:27 +00:00
cp 3 ; chose Cancel?
jr z, .notThirsty
2014-05-22 22:13:20 +00:00
xor a
2015-07-17 08:21:40 +00:00
ld [hMoney], a
ld [hMoney + 2], a
2014-05-22 22:13:20 +00:00
ld a, $2
2015-07-17 08:21:40 +00:00
ld [hMoney + 1], a
2014-05-22 22:13:20 +00:00
call HasEnoughMoney
jr nc, .enoughMoney
ld hl, VendingMachineText4
jp PrintText
.enoughMoney
2015-07-17 07:16:27 +00:00
call LoadVendingMachineItem
ld a, [hVendingMachineItem]
2014-05-22 22:13:20 +00:00
ld b, a
ld c, 1
call GiveItem
jr nc, .BagFull
2015-07-17 07:16:27 +00:00
ld b, 60 ; number of times to play the "brrrrr" sound
.playDeliverySound
ld c, 2
2014-05-22 22:13:20 +00:00
call DelayFrames
push bc
2015-07-19 08:46:12 +00:00
ld a, SFX_PUSH_BOULDER
2014-05-22 22:13:20 +00:00
call PlaySound
pop bc
dec b
jr nz, .playDeliverySound
2015-07-17 07:16:27 +00:00
2014-05-22 22:13:20 +00:00
ld hl, VendingMachineText5
call PrintText
2015-07-17 07:16:27 +00:00
ld hl, hVendingMachinePrice + 2
2015-02-07 20:27:36 +00:00
ld de, wPlayerMoney + 2
2014-05-22 22:13:20 +00:00
ld c, $3
predef SubBCDPredef
2015-02-07 20:27:36 +00:00
ld a, MONEY_BOX
2015-02-07 10:43:08 +00:00
ld [wTextBoxID], a
2014-05-22 22:13:20 +00:00
jp DisplayTextBoxID
.BagFull
ld hl, VendingMachineText6
jp PrintText
2015-07-17 07:16:27 +00:00
.notThirsty
2014-05-22 22:13:20 +00:00
ld hl, VendingMachineText7
jp PrintText
2016-06-12 00:24:04 +00:00
VendingMachineText1:
2014-05-22 22:13:20 +00:00
TX_FAR _VendingMachineText1
db "@"
2016-06-12 00:24:04 +00:00
DrinkText:
2014-05-22 22:13:20 +00:00
db "FRESH WATER"
next "SODA POP"
next "LEMONADE"
next "CANCEL@"
2016-06-12 00:24:04 +00:00
DrinkPriceText:
2014-05-22 22:13:20 +00:00
db "¥200"
next "¥300"
2016-07-18 06:17:03 +00:00
next "¥350"
next "@"
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
VendingMachineText4:
2014-05-22 22:13:20 +00:00
TX_FAR _VendingMachineText4
db "@"
2016-06-12 00:24:04 +00:00
VendingMachineText5:
2014-05-22 22:13:20 +00:00
TX_FAR _VendingMachineText5
db "@"
2016-06-12 00:24:04 +00:00
VendingMachineText6:
2014-05-22 22:13:20 +00:00
TX_FAR _VendingMachineText6
db "@"
2016-06-12 00:24:04 +00:00
VendingMachineText7:
2014-05-22 22:13:20 +00:00
TX_FAR _VendingMachineText7
db "@"
2016-06-12 00:24:04 +00:00
LoadVendingMachineItem:
2014-05-22 22:13:20 +00:00
ld hl, VendingPrices
ld a, [wCurrentMenuItem]
2014-05-22 22:13:20 +00:00
add a
add a
2015-07-17 07:16:27 +00:00
ld d, 0
2014-05-22 22:13:20 +00:00
ld e, a
add hl, de
ld a, [hli]
2015-07-17 07:16:27 +00:00
ld [hVendingMachineItem], a
2014-05-22 22:13:20 +00:00
ld a, [hli]
2015-07-17 07:16:27 +00:00
ld [hVendingMachinePrice], a
2014-05-22 22:13:20 +00:00
ld a, [hli]
2015-07-17 07:16:27 +00:00
ld [hVendingMachinePrice + 1], a
2014-05-22 22:13:20 +00:00
ld a, [hl]
2015-07-17 07:16:27 +00:00
ld [hVendingMachinePrice + 2], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
VendingPrices:
2016-06-12 04:30:05 +00:00
db FRESH_WATER
money 200
db SODA_POP
money 300
db LEMONADE
money 350