2014-05-22 22:13:20 +00:00
|
|
|
VendingMachineMenu: ; 74ee0 (1d:4ee0)
|
|
|
|
ld hl, VendingMachineText1
|
|
|
|
call PrintText
|
|
|
|
ld a, $13
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd125], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call DisplayTextBoxID
|
|
|
|
xor a
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wCurrentMenuItem], a ; wCurrentMenuItem
|
|
|
|
ld [wLastMenuItem], a ; wLastMenuItem
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $3
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMenuWatchedKeys], a ; wMenuWatchedKeys
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $3
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wMaxMenuItem], a ; wMaxMenuItem
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $5
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemY], a ; wTopMenuItemY
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $1
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wTopMenuItemX], a ; wTopMenuItemX
|
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
set 6, [hl]
|
2014-05-26 21:04:56 +00:00
|
|
|
FuncCoord 0, 3
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, Coord
|
|
|
|
ld b, $8
|
|
|
|
ld c, $c
|
|
|
|
call TextBoxBorder
|
|
|
|
call UpdateSprites
|
2014-05-26 21:04:56 +00:00
|
|
|
FuncCoord 2, 5
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, Coord
|
|
|
|
ld de, DrinkText
|
|
|
|
call PlaceString
|
2014-05-26 21:04:56 +00:00
|
|
|
FuncCoord 9, 6
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, Coord
|
|
|
|
ld de, DrinkPriceText
|
|
|
|
call PlaceString
|
2014-05-26 21:04:56 +00:00
|
|
|
ld hl, wd730
|
2014-05-22 22:13:20 +00:00
|
|
|
res 6, [hl]
|
|
|
|
call HandleMenuInput
|
|
|
|
bit 1, a
|
|
|
|
jr nz, .asm_74f93
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem] ; wCurrentMenuItem
|
2014-05-22 22:13:20 +00:00
|
|
|
cp $3
|
|
|
|
jr z, .asm_74f93
|
|
|
|
xor a
|
|
|
|
ld [$ff9f], a
|
|
|
|
ld [$ffa1], a
|
|
|
|
ld a, $2
|
|
|
|
ld [$ffa0], a
|
|
|
|
call HasEnoughMoney
|
|
|
|
jr nc, .enoughMoney
|
|
|
|
ld hl, VendingMachineText4
|
|
|
|
jp PrintText
|
|
|
|
.enoughMoney
|
|
|
|
call Func_74fe7
|
|
|
|
ld a, [$ffdb]
|
|
|
|
ld b, a
|
|
|
|
ld c, 1
|
|
|
|
call GiveItem
|
|
|
|
jr nc, .BagFull
|
|
|
|
ld b, $3c ; number of times to play the "brrrrr" sound
|
|
|
|
.playDeliverySound ; 0x74f63
|
|
|
|
ld c, $2
|
|
|
|
call DelayFrames
|
|
|
|
push bc
|
|
|
|
ld a, (SFX_02_53 - SFX_Headers_02) / 3
|
|
|
|
call PlaySound
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .playDeliverySound
|
|
|
|
.asm_74f72
|
|
|
|
ld hl, VendingMachineText5
|
|
|
|
call PrintText
|
|
|
|
ld hl, $ffde
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wPlayerMoney + 2 ; wd349
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, $3
|
2014-06-16 20:57:26 +00:00
|
|
|
predef SubBCDPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, $13
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd125], a
|
2014-05-22 22:13:20 +00:00
|
|
|
jp DisplayTextBoxID
|
|
|
|
.BagFull
|
|
|
|
ld hl, VendingMachineText6
|
|
|
|
jp PrintText
|
|
|
|
.asm_74f93
|
|
|
|
ld hl, VendingMachineText7
|
|
|
|
jp PrintText
|
|
|
|
|
|
|
|
VendingMachineText1: ; 74f99 (1d:4f99)
|
|
|
|
TX_FAR _VendingMachineText1
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
DrinkText: ; 74f9e (1d:4f9e)
|
|
|
|
db "FRESH WATER"
|
|
|
|
next "SODA POP"
|
|
|
|
next "LEMONADE"
|
|
|
|
next "CANCEL@"
|
|
|
|
|
|
|
|
DrinkPriceText: ; 74fc3 (1d:4fc3)
|
|
|
|
db "¥200"
|
|
|
|
next "¥300"
|
|
|
|
next "¥350",$4E,"@"
|
|
|
|
|
|
|
|
VendingMachineText4: ; 74fd3 (1d:4fd3)
|
|
|
|
TX_FAR _VendingMachineText4
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
VendingMachineText5: ; 74fd8 (1d:4fd8)
|
|
|
|
TX_FAR _VendingMachineText5
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
VendingMachineText6: ; 74fdd (1d:4fdd)
|
|
|
|
TX_FAR _VendingMachineText6
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
VendingMachineText7: ; 74fe2 (1d:4fe2)
|
|
|
|
TX_FAR _VendingMachineText7
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
Func_74fe7: ; 74fe7 (1d:4fe7)
|
|
|
|
ld hl, VendingPrices
|
2014-05-26 21:04:56 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2014-05-22 22:13:20 +00:00
|
|
|
add a
|
|
|
|
add a
|
|
|
|
ld d, $0
|
|
|
|
ld e, a
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [$ffdb], a
|
|
|
|
ld a, [hli]
|
|
|
|
ld [$ffdc], a
|
|
|
|
ld a, [hli]
|
|
|
|
ld [$ffdd], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [$ffde], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
VendingPrices: ; 75000 (1d:5000)
|
|
|
|
db FRESH_WATER,$00,$02,$00
|
|
|
|
db SODA_POP, $00,$03,$00
|
|
|
|
db LEMONADE, $00,$03,$50
|