pokecrystal-board/engine/events/buena.asm

301 lines
4.6 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
BuenasPassword:
2015-10-16 10:35:43 -07:00
xor a
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
ld hl, .MenuHeader
call CopyMenuHeader
2015-10-24 07:34:19 -07:00
ld a, [wBuenasPassword]
2015-10-16 10:35:43 -07:00
ld c, a
2017-12-24 09:47:30 -08:00
farcall GetBuenasPassword
2015-10-24 07:34:19 -07:00
ld a, [wMenuBorderLeftCoord]
2015-10-16 10:35:43 -07:00
add c
add $2
2015-10-24 07:34:19 -07:00
ld [wMenuBorderRightCoord], a
2015-12-22 19:19:33 -08:00
call PushWindow
2015-11-16 18:46:36 -08:00
call DoNthMenu ; menu
2017-12-24 09:47:30 -08:00
farcall Buena_ExitMenu
2015-10-16 10:35:43 -07:00
ld b, $0
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-10-16 10:35:43 -07:00
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wBuenasPassword]
2018-01-16 14:27:50 -08:00
maskbits NUM_PASSWORDS_PER_CATEGORY
2015-10-16 10:35:43 -07:00
cp c
2015-11-01 09:44:30 -08:00
jr nz, .wrong
2015-10-16 10:35:43 -07:00
ld b, $1
2015-11-01 09:44:30 -08:00
.wrong
2015-10-16 10:35:43 -07:00
ld a, b
2023-09-30 10:12:57 -07:00
ldh [hScriptVar], a
2015-10-16 10:35:43 -07:00
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 10, 7
dw .MenuData
2015-10-16 10:35:43 -07:00
db 1 ; default option
db 0
.MenuData:
db STATICMENU_CURSOR | STATICMENU_DISABLE_B ; flags
2015-10-16 10:35:43 -07:00
db 0 ; items
2015-11-01 09:44:30 -08:00
dw .PasswordIndices
dw .PlacePasswordChoices
2015-10-16 10:35:43 -07:00
2018-06-24 07:09:41 -07:00
.PasswordIndices:
2018-01-11 09:00:01 -08:00
db NUM_PASSWORDS_PER_CATEGORY
2021-04-19 13:31:37 -07:00
for x, NUM_PASSWORDS_PER_CATEGORY
db x
endr
2015-10-16 10:35:43 -07:00
db -1
2018-06-24 07:09:41 -07:00
.PlacePasswordChoices:
2015-10-16 10:35:43 -07:00
push de
2015-10-24 07:34:19 -07:00
ld a, [wBuenasPassword]
2015-10-16 10:35:43 -07:00
and $f0
ld c, a
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-10-16 10:35:43 -07:00
add c
ld c, a
2017-12-24 09:47:30 -08:00
farcall GetBuenasPassword
2015-10-16 10:35:43 -07:00
pop hl
call PlaceString
ret
2018-06-24 07:09:41 -07:00
BuenaPrize:
2015-10-16 10:35:43 -07:00
xor a
2015-11-23 13:04:53 -08:00
ld [wMenuScrollPosition], a
2015-10-16 10:35:43 -07:00
ld a, $1
2018-01-23 14:39:09 -08:00
ld [wMenuSelection], a
2015-12-18 17:07:09 -08:00
call Buena_PlacePrizeMenuBox
call Buena_DisplayBlueCardBalance
ld hl, .BuenaAskWhichPrizeText
call PrintText1bpp
2015-11-01 09:44:30 -08:00
jr .okay
2015-10-16 10:35:43 -07:00
2015-11-01 09:44:30 -08:00
.loop
ld hl, .BuenaAskWhichPrizeText
2015-10-31 18:05:02 -07:00
call BuenaPrintText
2015-10-16 10:35:43 -07:00
2015-11-01 09:44:30 -08:00
.okay
2015-10-16 10:35:43 -07:00
call DelayFrame
call UpdateSprites
2015-12-17 19:31:16 -08:00
call PrintBlueCardBalance
2015-12-18 17:07:09 -08:00
call Buena_PrizeMenu
2015-11-01 09:44:30 -08:00
jr z, .done
2018-01-23 14:39:09 -08:00
ld [wMenuSelectionQuantity], a
call Buena_GetPrize
2015-10-16 10:35:43 -07:00
ld a, [hl]
ld [wNamedObjectIndex], a
2015-10-16 10:35:43 -07:00
call GetItemName
ld hl, .BuenaIsThatRightText
2015-10-31 18:05:02 -07:00
call BuenaPrintText
2015-10-16 10:35:43 -07:00
call YesNoBox
2015-11-01 09:44:30 -08:00
jr c, .loop
2015-10-24 07:34:19 -07:00
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelectionQuantity]
call Buena_GetPrize
2015-10-16 10:35:43 -07:00
inc hl
ld a, [hld]
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wBlueCardBalance]
2015-10-16 10:35:43 -07:00
cp c
2015-10-24 07:34:19 -07:00
jr c, .InsufficientBalance
2015-10-16 10:35:43 -07:00
ld a, [hli]
push hl
2018-01-23 14:39:09 -08:00
ld [wCurItem], a
2015-10-16 10:35:43 -07:00
ld a, $1
ld [wItemQuantityChange], a
2018-01-23 14:39:09 -08:00
ld hl, wNumItems
2015-10-16 10:35:43 -07:00
call ReceiveItem
pop hl
2015-11-01 09:44:30 -08:00
jr nc, .BagFull
2015-10-16 10:35:43 -07:00
ld a, [hl]
ld c, a
2015-10-24 07:34:19 -07:00
ld a, [wBlueCardBalance]
2015-10-16 10:35:43 -07:00
sub c
2015-10-24 07:34:19 -07:00
ld [wBlueCardBalance], a
2015-12-17 19:31:16 -08:00
call PrintBlueCardBalance
2015-11-01 09:44:30 -08:00
jr .Purchase
2015-10-16 10:35:43 -07:00
.InsufficientBalance:
ld hl, .BuenaNotEnoughPointsText
2015-11-01 09:44:30 -08:00
jr .print
2015-10-16 10:35:43 -07:00
.BagFull:
ld hl, .BuenaNoRoomText
2015-11-01 09:44:30 -08:00
jr .print
2015-10-16 10:35:43 -07:00
.Purchase:
2015-10-16 10:35:43 -07:00
ld de, SFX_TRANSACTION
call PlaySFX
ld hl, .BuenaHereYouGoText
2015-10-16 10:35:43 -07:00
2015-11-01 09:44:30 -08:00
.print
2015-10-31 18:05:02 -07:00
call BuenaPrintText
2015-11-01 09:44:30 -08:00
jr .loop
2015-10-16 10:35:43 -07:00
2015-11-01 09:44:30 -08:00
.done
call CloseWindow
call CloseWindow
ld hl, .BuenaComeAgainText
call PrintText1bpp
call JoyWaitAorB
2015-10-16 10:35:43 -07:00
call PlayClickSFX
ret
.BuenaAskWhichPrizeText:
text_far _BuenaAskWhichPrizeText
text_end
2015-10-16 10:35:43 -07:00
.BuenaIsThatRightText:
text_far _BuenaIsThatRightText
text_end
2015-10-16 10:35:43 -07:00
.BuenaHereYouGoText:
text_far _BuenaHereYouGoText
text_end
2015-10-16 10:35:43 -07:00
.BuenaNotEnoughPointsText:
text_far _BuenaNotEnoughPointsText
text_end
2015-10-16 10:35:43 -07:00
.BuenaNoRoomText:
text_far _BuenaNoRoomText
text_end
2015-10-16 10:35:43 -07:00
.BuenaComeAgainText:
text_far _BuenaComeAgainText
text_end
2015-10-16 10:35:43 -07:00
2018-06-24 07:09:41 -07:00
Buena_DisplayBlueCardBalance:
ld hl, BlueCardBalanceMenuHeader
call LoadMenuHeader
2015-10-16 10:35:43 -07:00
ret
2018-06-24 07:09:41 -07:00
PrintBlueCardBalance:
2015-10-24 07:34:19 -07:00
ld de, wBlueCardBalance
2015-12-17 19:31:16 -08:00
call .DrawBox
2015-10-16 10:35:43 -07:00
ret
2018-06-24 07:09:41 -07:00
.DrawBox:
2015-10-16 10:35:43 -07:00
push de
xor a
ldh [hBGMapMode], a
ld hl, BlueCardBalanceMenuHeader
call CopyMenuHeader
2015-11-04 11:02:11 -08:00
call MenuBox
2015-10-16 10:35:43 -07:00
call UpdateSprites
call MenuBoxCoord2Tile
2015-12-17 19:31:16 -08:00
ld bc, SCREEN_WIDTH + 1
2015-10-16 10:35:43 -07:00
add hl, bc
2015-10-17 14:18:52 -07:00
ld de, .Points_string
2015-10-16 10:35:43 -07:00
call PlaceString
ld h, b
ld l, c
inc hl
2015-12-17 19:31:16 -08:00
ld a, " "
2015-10-16 10:35:43 -07:00
ld [hli], a
ld [hld], a
pop de
lb bc, 1, 2
call PrintNum
ret
2015-10-17 14:18:52 -07:00
.Points_string:
2015-10-16 10:35:43 -07:00
db "Points@"
BlueCardBalanceMenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 11, 11, 13
2015-10-16 10:35:43 -07:00
2018-06-24 07:09:41 -07:00
Buena_PlacePrizeMenuBox:
ld hl, .MenuHeader
call LoadMenuHeader
2015-10-16 10:35:43 -07:00
ret
.MenuHeader
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 17, TEXTBOX_Y - 1
2015-10-16 10:35:43 -07:00
2018-06-24 07:09:41 -07:00
Buena_PrizeMenu:
ld hl, .MenuHeader
call CopyMenuHeader
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
ld [wMenuCursorPosition], a
2015-10-16 10:35:43 -07:00
xor a
2015-12-18 17:07:09 -08:00
ld [wWhichIndexSet], a
ldh [hBGMapMode], a
2015-11-17 12:54:03 -08:00
call InitScrollingMenu
2015-10-16 10:35:43 -07:00
call UpdateSprites
2015-12-17 19:31:16 -08:00
call ScrollingMenu
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
2015-10-16 10:35:43 -07:00
ld c, a
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2018-01-23 14:39:09 -08:00
ld [wMenuSelection], a
2015-12-15 15:59:49 -08:00
ld a, [wMenuJoypad]
cp B_BUTTON
2015-12-17 19:31:16 -08:00
jr z, .cancel
2015-10-16 10:35:43 -07:00
ld a, c
and a
ret nz
2015-12-17 19:31:16 -08:00
.cancel
2015-10-16 10:35:43 -07:00
xor a
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 1, 1, 16, 9
dw .MenuData
2015-10-16 10:35:43 -07:00
db 1 ; default option
db 0
.MenuData:
db SCROLLINGMENU_DISPLAY_ARROWS ; flags
2015-12-17 19:31:16 -08:00
db 4, 13 ; rows, columns
db SCROLLINGMENU_ITEMS_NORMAL ; item format
dba .Prizes
dba .PrintPrizeItem
dba .PrintPrizePoints
2015-10-16 10:35:43 -07:00
.Prizes:
db NUM_BUENA_PRIZES
2021-04-19 13:31:37 -07:00
for x, NUM_BUENA_PRIZES
db x + 1
endr
2015-10-17 14:18:52 -07:00
db -1
2015-10-16 10:35:43 -07:00
.PrintPrizeItem:
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
call Buena_GetPrize
2015-10-16 10:35:43 -07:00
ld a, [hl]
push de
ld [wNamedObjectIndex], a
2015-10-16 10:35:43 -07:00
call GetItemName
pop hl
call PlaceString
ret
.PrintPrizePoints:
2018-01-23 14:39:09 -08:00
ld a, [wMenuSelection]
call Buena_GetPrize
2015-10-16 10:35:43 -07:00
inc hl
ld a, [hl]
ld c, "0"
add c
ld [de], a
ret
Buena_GetPrize:
2015-10-16 10:35:43 -07:00
dec a
ld hl, BuenaPrizeItems
2015-10-16 10:35:43 -07:00
ld b, 0
ld c, a
add hl, bc
add hl, bc
2015-10-16 10:35:43 -07:00
ret
INCLUDE "data/items/buena_prizes.asm"