diff options
| author | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
|---|---|---|
| committer | dannye <33dannye@gmail.com> | 2020-11-04 00:06:44 -0600 |
| commit | 5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch) | |
| tree | dde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/events/vending_machine.asm | |
| parent | Merge pull request #55 from Deokishisu/patch-1 (diff) | |
| download | pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip | |
Sync with pokered
Diffstat (limited to 'engine/events/vending_machine.asm')
| -rwxr-xr-x | engine/events/vending_machine.asm | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/engine/events/vending_machine.asm b/engine/events/vending_machine.asm new file mode 100755 index 00000000..6ff6a5e4 --- /dev/null +++ b/engine/events/vending_machine.asm @@ -0,0 +1,132 @@ +VendingMachineMenu:: + ld hl, VendingMachineText1 + call PrintText + ld a, MONEY_BOX + ld [wTextBoxID], a + call DisplayTextBoxID + xor a + ld [wCurrentMenuItem], a + ld [wLastMenuItem], a + ld a, A_BUTTON | B_BUTTON + ld [wMenuWatchedKeys], a + ld a, 3 + ld [wMaxMenuItem], a + ld a, 5 + ld [wTopMenuItemY], a + ld a, 1 + ld [wTopMenuItemX], a + ld hl, wd730 + set 6, [hl] + hlcoord 0, 3 + lb bc, 8, 12 + call TextBoxBorder + call UpdateSprites + hlcoord 2, 5 + ld de, DrinkText + call PlaceString + hlcoord 9, 6 + ld de, DrinkPriceText + call PlaceString + ld hl, wd730 + res 6, [hl] + call HandleMenuInput + bit 1, a ; pressed B? + jr nz, .notThirsty + ld a, [wCurrentMenuItem] + cp 3 ; chose Cancel? + jr z, .notThirsty + xor a + ldh [hMoney], a + ldh [hMoney + 2], a + ld a, $2 + ldh [hMoney + 1], a + call HasEnoughMoney + jr nc, .enoughMoney + ld hl, VendingMachineText4 + jp PrintText +.enoughMoney + call LoadVendingMachineItem + ldh a, [hVendingMachineItem] + ld b, a + ld c, 1 + call GiveItem + jr nc, .BagFull + + ld b, 60 ; number of times to play the "brrrrr" sound +.playDeliverySound + ld c, 2 + call DelayFrames + push bc + ld a, SFX_PUSH_BOULDER + call PlaySound + pop bc + dec b + jr nz, .playDeliverySound + + ld hl, VendingMachineText5 + call PrintText + ld hl, hVendingMachinePrice + 2 + ld de, wPlayerMoney + 2 + ld c, $3 + predef SubBCDPredef + ld a, MONEY_BOX + ld [wTextBoxID], a + jp DisplayTextBoxID +.BagFull + ld hl, VendingMachineText6 + jp PrintText +.notThirsty + ld hl, VendingMachineText7 + jp PrintText + +VendingMachineText1: + text_far _VendingMachineText1 + text_end + +DrinkText: + db "FRESH WATER" + next "SODA POP" + next "LEMONADE" + next "CANCEL@" + +DrinkPriceText: + db "¥200" + next "¥300" + next "¥350" + next "@" + +VendingMachineText4: + text_far _VendingMachineText4 + text_end + +VendingMachineText5: + text_far _VendingMachineText5 + text_end + +VendingMachineText6: + text_far _VendingMachineText6 + text_end + +VendingMachineText7: + text_far _VendingMachineText7 + text_end + +LoadVendingMachineItem: + ld hl, VendingPrices + ld a, [wCurrentMenuItem] + add a + add a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ldh [hVendingMachineItem], a + ld a, [hli] + ldh [hVendingMachinePrice], a + ld a, [hli] + ldh [hVendingMachinePrice + 1], a + ld a, [hl] + ldh [hVendingMachinePrice + 2], a + ret + +INCLUDE "data/items/vending_prices.asm" |
