2020-06-27 19:32:24 +00:00
|
|
|
CeladonPrizeMenu::
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, COIN_CASE
|
2014-05-22 22:13:20 +00:00
|
|
|
call IsItemInBag
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .havingCoinCase
|
|
|
|
ld hl, RequireCoinCaseTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
|
|
|
.havingCoinCase
|
2024-07-16 17:02:54 +00:00
|
|
|
ld hl, wStatusFlags5
|
|
|
|
set BIT_NO_TEXT_DELAY, [hl]
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, ExchangeCoinsForPrizesTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintText
|
|
|
|
; the following are the menu settings
|
|
|
|
xor a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld [wCurrentMenuItem], a
|
|
|
|
ld [wLastMenuItem], a
|
|
|
|
ld a, A_BUTTON | B_BUTTON
|
|
|
|
ld [wMenuWatchedKeys], a
|
|
|
|
ld a, $03
|
|
|
|
ld [wMaxMenuItem], a
|
|
|
|
ld a, $04
|
|
|
|
ld [wTopMenuItemY], a
|
|
|
|
ld a, $01
|
|
|
|
ld [wTopMenuItemX], a
|
2015-07-14 05:21:03 +00:00
|
|
|
call PrintPrizePrice
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 0, 2
|
2016-06-12 04:30:05 +00:00
|
|
|
ld b, 8
|
|
|
|
ld c, 16
|
2014-05-22 22:13:20 +00:00
|
|
|
call TextBoxBorder
|
2015-07-14 05:21:03 +00:00
|
|
|
call GetPrizeMenuId
|
2014-05-22 22:13:20 +00:00
|
|
|
call UpdateSprites
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, WhichPrizeTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintText
|
|
|
|
call HandleMenuInput ; menu choice handler
|
2021-11-05 19:40:15 +00:00
|
|
|
bit BIT_B_BUTTON, a
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nz, .noChoice
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
2016-06-12 04:30:05 +00:00
|
|
|
cp 3 ; "NO,THANKS" choice
|
|
|
|
jr z, .noChoice
|
2015-07-14 05:21:03 +00:00
|
|
|
call HandlePrizeChoice
|
2016-06-12 04:30:05 +00:00
|
|
|
.noChoice
|
2024-07-16 17:02:54 +00:00
|
|
|
ld hl, wStatusFlags5
|
|
|
|
res BIT_NO_TEXT_DELAY, [hl]
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RequireCoinCaseTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _RequireCoinCaseText
|
2020-07-06 16:39:29 +00:00
|
|
|
text_waitbutton
|
2020-07-04 21:09:35 +00:00
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
ExchangeCoinsForPrizesTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _ExchangeCoinsForPrizesText
|
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
WhichPrizeTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _WhichPrizeText
|
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GetPrizeMenuId:
|
2024-09-19 01:01:18 +00:00
|
|
|
; determine which one among the three prize texts has been selected using the text ID (stored in [hTextID])
|
|
|
|
; prize texts' IDs are TEXT_GAMECORNERPRIZEROOM_PRIZE_VENDOR_1-TEXT_GAMECORNERPRIZEROOM_PRIZE_VENDOR_3
|
|
|
|
; load the three prizes at wPrize1-wPrice3
|
|
|
|
; load the three prices at wPrize1Price-wPrize3Price
|
|
|
|
; display the three prizes' names, distinguishing between Pokemon names and item names (specifically TMs)
|
|
|
|
ldh a, [hTextID]
|
|
|
|
sub TEXT_GAMECORNERPRIZEROOM_PRIZE_VENDOR_1
|
|
|
|
ld [wWhichPrizeWindow], a ; prize texts' relative ID (i.e. 0-2)
|
2014-05-22 22:13:20 +00:00
|
|
|
add a
|
|
|
|
add a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld d, 0
|
|
|
|
ld e, a
|
|
|
|
ld hl, PrizeDifferentMenuPtrs
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, [hl]
|
|
|
|
ld e, a
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, wPrize1
|
2015-07-03 19:37:53 +00:00
|
|
|
call CopyString
|
2014-05-22 22:13:20 +00:00
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld de, wPrize1Price
|
|
|
|
ld bc, 6
|
2014-05-22 22:13:20 +00:00
|
|
|
call CopyData
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wWhichPrizeWindow]
|
2024-09-19 01:01:18 +00:00
|
|
|
cp 2 ; is TM_menu?
|
2017-12-30 00:54:27 +00:00
|
|
|
jr nz, .putMonName
|
|
|
|
ld a, [wPrize1]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 4
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wPrize2]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 6
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wPrize3]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
|
|
|
jr .putNoThanksText
|
2015-07-14 05:21:03 +00:00
|
|
|
.putMonName
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wPrize1]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 4
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wPrize2]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 6
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wPrize3]
|
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 8
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2015-07-14 05:21:03 +00:00
|
|
|
.putNoThanksText
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 10
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, NoThanksText
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
|
|
|
; put prices on the right side of the textbox
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wPrize1Price
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 13, 5
|
2014-05-22 22:13:20 +00:00
|
|
|
; reg. c:
|
|
|
|
; [low nybble] number of bytes
|
2020-07-04 05:00:45 +00:00
|
|
|
; [bits 765 = %100] space-padding (not zero-padding)
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, (1 << 7 | 2)
|
2015-07-14 05:21:03 +00:00
|
|
|
call PrintBCDNumber
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wPrize2Price
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 13, 7
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, (1 << 7 | 2)
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintBCDNumber
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wPrize3Price
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 13, 9
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, (1 << 7 | 2)
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintBCDNumber
|
|
|
|
|
2020-07-03 15:51:00 +00:00
|
|
|
INCLUDE "data/events/prizes.asm"
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PrintPrizePrice:
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 11, 0
|
2016-06-12 04:30:05 +00:00
|
|
|
ld b, 1
|
|
|
|
ld c, 7
|
2014-05-22 22:13:20 +00:00
|
|
|
call TextBoxBorder
|
2015-07-03 19:37:53 +00:00
|
|
|
call UpdateSprites
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 12, 0
|
2016-06-12 04:30:05 +00:00
|
|
|
ld de, .CoinString
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 13, 1
|
2016-06-12 04:30:05 +00:00
|
|
|
ld de, .SixSpacesString
|
2014-05-22 22:13:20 +00:00
|
|
|
call PlaceString
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 13, 1
|
2017-12-30 00:54:27 +00:00
|
|
|
ld de, wPlayerCoins
|
|
|
|
ld c, %10000010
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintBCDNumber
|
|
|
|
ret
|
|
|
|
|
2016-06-12 04:30:05 +00:00
|
|
|
.CoinString:
|
2014-05-22 22:13:20 +00:00
|
|
|
db "COIN@"
|
|
|
|
|
2016-06-12 04:30:05 +00:00
|
|
|
.SixSpacesString:
|
2014-05-22 22:13:20 +00:00
|
|
|
db " @"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
LoadCoinsToSubtract:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wWhichPrize]
|
2014-05-22 22:13:20 +00:00
|
|
|
add a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld d, 0
|
|
|
|
ld e, a
|
|
|
|
ld hl, wPrize1Price
|
|
|
|
add hl, de ; get selected prize's price
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hUnusedCoinsByte], a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hCoins], a
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hl]
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hCoins + 1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
HandlePrizeChoice:
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurrentMenuItem]
|
|
|
|
ld [wWhichPrize], a
|
|
|
|
ld d, 0
|
|
|
|
ld e, a
|
|
|
|
ld hl, wPrize1
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wd11e], a
|
|
|
|
ld a, [wWhichPrizeWindow]
|
2016-06-12 04:30:05 +00:00
|
|
|
cp 2 ; is prize a TM?
|
|
|
|
jr nz, .getMonName
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2016-06-12 04:30:05 +00:00
|
|
|
jr .givePrize
|
|
|
|
.getMonName
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetMonName
|
2016-06-12 04:30:05 +00:00
|
|
|
.givePrize
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, SoYouWantPrizeTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
call PrintText
|
2015-07-26 02:26:54 +00:00
|
|
|
call YesNoChoice
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nz, .printOhFineThen
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadCoinsToSubtract
|
|
|
|
call HasEnoughCoins
|
2016-06-12 04:30:05 +00:00
|
|
|
jr c, .notEnoughCoins
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wWhichPrizeWindow]
|
2016-06-12 04:30:05 +00:00
|
|
|
cp $02
|
|
|
|
jr nz, .giveMon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
|
|
|
ld b, a
|
|
|
|
ld a, 1
|
|
|
|
ld c, a
|
2015-07-14 05:21:03 +00:00
|
|
|
call GiveItem
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nc, .bagFull
|
|
|
|
jr .subtractCoins
|
|
|
|
.giveMon
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wd11e]
|
2024-08-04 14:05:33 +00:00
|
|
|
ld [wCurPartySpecies], a
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2015-07-14 05:21:03 +00:00
|
|
|
call GetPrizeMonLevel
|
2017-12-30 00:54:27 +00:00
|
|
|
ld c, a
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GivePokemon
|
2015-07-19 03:49:52 +00:00
|
|
|
|
|
|
|
; If either the party or box was full, wait after displaying message.
|
2014-05-22 22:13:20 +00:00
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [wAddedToParty]
|
2014-05-22 22:13:20 +00:00
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
call z, WaitForTextScrollButtonPress
|
2014-05-22 22:13:20 +00:00
|
|
|
pop af
|
2015-07-19 03:49:52 +00:00
|
|
|
|
|
|
|
; If the mon couldn't be given to the player (because both the party and box
|
|
|
|
; were full), return without subtracting coins.
|
2014-05-22 22:13:20 +00:00
|
|
|
ret nc
|
2015-07-19 03:49:52 +00:00
|
|
|
|
2016-06-12 04:30:05 +00:00
|
|
|
.subtractCoins
|
2014-05-22 22:13:20 +00:00
|
|
|
call LoadCoinsToSubtract
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, hCoins + 1
|
|
|
|
ld de, wPlayerCoins + 1
|
|
|
|
ld c, $02 ; how many bytes
|
2015-07-19 03:49:52 +00:00
|
|
|
predef SubBCDPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintPrizePrice
|
2016-06-12 04:30:05 +00:00
|
|
|
.bagFull
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, PrizeRoomBagIsFullTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
2016-06-12 04:30:05 +00:00
|
|
|
.notEnoughCoins
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, SorryNeedMoreCoinsText
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
2016-06-12 04:30:05 +00:00
|
|
|
.printOhFineThen
|
2017-12-30 00:54:27 +00:00
|
|
|
ld hl, OhFineThenTextPtr
|
2014-05-22 22:13:20 +00:00
|
|
|
jp PrintText
|
|
|
|
|
2016-06-12 04:30:05 +00:00
|
|
|
UnknownPrizeData:
|
2014-05-22 22:13:20 +00:00
|
|
|
; XXX what's this?
|
|
|
|
db $00,$01,$00,$01,$00,$01,$00,$00,$01
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
HereYouGoTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _HereYouGoText
|
2020-07-06 16:39:29 +00:00
|
|
|
text_waitbutton
|
2020-07-04 21:09:35 +00:00
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SoYouWantPrizeTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _SoYouWantPrizeText
|
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
SorryNeedMoreCoinsText:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _SorryNeedMoreCoinsText
|
2020-07-06 16:39:29 +00:00
|
|
|
text_waitbutton
|
2020-07-04 21:09:35 +00:00
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
PrizeRoomBagIsFullTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _OopsYouDontHaveEnoughRoomText
|
2020-07-06 16:39:29 +00:00
|
|
|
text_waitbutton
|
2020-07-04 21:09:35 +00:00
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
OhFineThenTextPtr:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _OhFineThenText
|
2020-07-06 16:39:29 +00:00
|
|
|
text_waitbutton
|
2020-07-04 21:09:35 +00:00
|
|
|
text_end
|
2014-05-22 22:13:20 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
GetPrizeMonLevel:
|
2024-08-04 14:05:33 +00:00
|
|
|
ld a, [wCurPartySpecies]
|
2017-12-30 00:54:27 +00:00
|
|
|
ld b, a
|
|
|
|
ld hl, PrizeMonLevelDictionary
|
2015-07-14 05:21:03 +00:00
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hli]
|
2014-05-22 22:13:20 +00:00
|
|
|
cp b
|
2017-12-30 00:54:27 +00:00
|
|
|
jr z, .matchFound
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
jr .loop
|
2015-07-14 05:21:03 +00:00
|
|
|
.matchFound
|
2017-12-30 00:54:27 +00:00
|
|
|
ld a, [hl]
|
2024-07-16 17:02:54 +00:00
|
|
|
ld [wCurEnemyLevel], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
2020-07-03 15:51:00 +00:00
|
|
|
INCLUDE "data/events/prize_mon_levels.asm"
|