pokered/engine/menu/players_pc.asm

304 lines
5.3 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
PlayerPC:
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 6, [hl]
ld a, ITEM_NAME
2015-02-08 09:44:41 +00:00
ld [wNameListType], a
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
xor a
2015-07-16 03:04:58 +00:00
ld [wBagSavedMenuItem], a
ld [wParentMenuItem], a
2014-05-22 22:13:20 +00:00
ld a, [wFlags_0xcd60]
2015-07-16 03:04:58 +00:00
bit 3, a ; accessing player's PC through another PC?
jr nz, PlayerPCMenu
; accessing it directly
2015-07-19 08:46:12 +00:00
ld a, SFX_TURN_ON_PC
2014-05-22 22:13:20 +00:00
call PlaySound
ld hl, TurnedOnPC2Text
call PrintText
2016-06-12 00:24:04 +00:00
PlayerPCMenu:
2015-07-16 03:04:58 +00:00
ld a, [wParentMenuItem]
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
2014-05-22 22:13:20 +00:00
ld hl, wFlags_0xcd60
set 5, [hl]
call LoadScreenTilesFromBuffer2
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2014-05-22 22:13:20 +00:00
ld b, $8
ld c, $e
call TextBoxBorder
call UpdateSprites
2015-07-18 20:52:03 +00:00
coord hl, 2, 2
2015-02-08 06:18:42 +00:00
ld de, PlayersPCMenuEntries
2014-05-22 22:13:20 +00:00
call PlaceString
2015-02-08 06:18:42 +00:00
ld hl, wTopMenuItemY
2015-07-16 03:04:58 +00:00
ld a, 2
ld [hli], a ; wTopMenuItemY
2014-05-22 22:13:20 +00:00
dec a
2015-07-16 03:04:58 +00:00
ld [hli], a ; wTopMenuItemX
2014-05-22 22:13:20 +00:00
inc hl
inc hl
2015-07-16 03:04:58 +00:00
ld a, 3
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
2014-05-22 22:13:20 +00:00
xor a
ld [hl], a
2015-02-08 06:18:42 +00:00
ld hl, wListScrollOffset
2015-07-16 03:04:58 +00:00
ld [hli], a ; wListScrollOffset
ld [hl], a ; wMenuWatchMovingOutOfBounds
2015-02-08 06:18:42 +00:00
ld [wPlayerMonNumber], a
2014-05-22 22:13:20 +00:00
ld hl, WhatDoYouWantText
call PrintText
call HandleMenuInput
bit 1, a
2015-07-16 03:04:58 +00:00
jp nz, ExitPlayerPC
2014-05-22 22:13:20 +00:00
call PlaceUnfilledArrowMenuCursor
2015-02-08 06:18:42 +00:00
ld a, [wCurrentMenuItem]
2015-07-16 03:04:58 +00:00
ld [wParentMenuItem], a
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jp z, PlayerPCWithdraw
2014-05-22 22:13:20 +00:00
dec a
2015-07-16 03:04:58 +00:00
jp z, PlayerPCDeposit
2014-05-22 22:13:20 +00:00
dec a
2015-07-16 03:04:58 +00:00
jp z, PlayerPCToss
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
ExitPlayerPC:
2014-05-22 22:13:20 +00:00
ld a, [wFlags_0xcd60]
2015-07-16 03:04:58 +00:00
bit 3, a ; accessing player's PC through another PC?
jr nz, .next
; accessing it directly
2015-07-19 08:46:12 +00:00
ld a, SFX_TURN_OFF_PC
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
2015-07-16 03:04:58 +00:00
.next
2014-05-22 22:13:20 +00:00
ld hl, wFlags_0xcd60
res 5, [hl]
call LoadScreenTilesFromBuffer2
xor a
2015-02-08 06:18:42 +00:00
ld [wListScrollOffset], a
2015-07-16 03:04:58 +00:00
ld [wBagSavedMenuItem], a
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
xor a
2014-09-13 07:50:56 +00:00
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
PlayerPCDeposit:
2014-05-22 22:13:20 +00:00
xor a
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBagItems]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ld hl, NothingToDepositText
call PrintText
2015-07-16 03:04:58 +00:00
jp PlayerPCMenu
.loop
2014-05-22 22:13:20 +00:00
ld hl, WhatToDepositText
call PrintText
2015-02-08 06:18:42 +00:00
ld hl, wNumBagItems
2014-05-22 22:13:20 +00:00
ld a, l
2015-07-15 06:16:06 +00:00
ld [wListPointer], a
2014-05-22 22:13:20 +00:00
ld a, h
2015-07-15 06:16:06 +00:00
ld [wListPointer + 1], a
2014-05-22 22:13:20 +00:00
xor a
2015-07-13 06:00:48 +00:00
ld [wPrintItemPrices], a
2015-07-16 03:04:58 +00:00
ld a, ITEMLISTMENU
2015-02-08 06:18:42 +00:00
ld [wListMenuID], a
2014-05-22 22:13:20 +00:00
call DisplayListMenuID
2015-07-16 03:04:58 +00:00
jp c, PlayerPCMenu
2014-05-22 22:13:20 +00:00
call IsKeyItem
2015-07-16 03:04:58 +00:00
ld a, 1
2015-07-13 06:00:48 +00:00
ld [wItemQuantity], a
ld a, [wIsKeyItem]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .next
; if it's not a key item, there can be more than one of the item
2014-05-22 22:13:20 +00:00
ld hl, DepositHowManyText
call PrintText
call DisplayChooseQuantityMenu
cp $ff
2015-07-16 03:04:58 +00:00
jp z, .loop
.next
2015-02-08 06:18:42 +00:00
ld hl, wNumBoxItems
2014-05-22 22:13:20 +00:00
call AddItemToInventory
2015-07-16 03:04:58 +00:00
jr c, .roomAvailable
2014-05-22 22:13:20 +00:00
ld hl, NoRoomToStoreText
call PrintText
2015-07-16 03:04:58 +00:00
jp .loop
.roomAvailable
2015-02-08 06:18:42 +00:00
ld hl, wNumBagItems
2014-05-22 22:13:20 +00:00
call RemoveItemFromInventory
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_WITHDRAW_DEPOSIT
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
ld hl, ItemWasStoredText
call PrintText
2015-07-16 03:04:58 +00:00
jp .loop
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PlayerPCWithdraw:
2014-05-22 22:13:20 +00:00
xor a
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBoxItems]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ld hl, NothingStoredText
call PrintText
2015-07-16 03:04:58 +00:00
jp PlayerPCMenu
.loop
2014-05-22 22:13:20 +00:00
ld hl, WhatToWithdrawText
call PrintText
2015-02-08 06:18:42 +00:00
ld hl, wNumBoxItems
2014-05-22 22:13:20 +00:00
ld a, l
2015-07-15 06:16:06 +00:00
ld [wListPointer], a
2014-05-22 22:13:20 +00:00
ld a, h
2015-07-15 06:16:06 +00:00
ld [wListPointer + 1], a
2014-05-22 22:13:20 +00:00
xor a
2015-07-13 06:00:48 +00:00
ld [wPrintItemPrices], a
2015-07-16 03:04:58 +00:00
ld a, ITEMLISTMENU
2015-02-08 06:18:42 +00:00
ld [wListMenuID], a
2014-05-22 22:13:20 +00:00
call DisplayListMenuID
2015-07-16 03:04:58 +00:00
jp c, PlayerPCMenu
2014-05-22 22:13:20 +00:00
call IsKeyItem
2015-07-16 03:04:58 +00:00
ld a, 1
2015-07-13 06:00:48 +00:00
ld [wItemQuantity], a
ld a, [wIsKeyItem]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .next
; if it's not a key item, there can be more than one of the item
2014-05-22 22:13:20 +00:00
ld hl, WithdrawHowManyText
call PrintText
call DisplayChooseQuantityMenu
cp $ff
2015-07-16 03:04:58 +00:00
jp z, .loop
.next
2015-02-08 06:18:42 +00:00
ld hl, wNumBagItems
2014-05-22 22:13:20 +00:00
call AddItemToInventory
2015-07-16 03:04:58 +00:00
jr c, .roomAvailable
2014-05-22 22:13:20 +00:00
ld hl, CantCarryMoreText
call PrintText
2015-07-16 03:04:58 +00:00
jp .loop
.roomAvailable
2015-02-08 06:18:42 +00:00
ld hl, wNumBoxItems
2014-05-22 22:13:20 +00:00
call RemoveItemFromInventory
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_WITHDRAW_DEPOSIT
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
ld hl, WithdrewItemText
call PrintText
2015-07-16 03:04:58 +00:00
jp .loop
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PlayerPCToss:
2014-05-22 22:13:20 +00:00
xor a
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
ld [wListScrollOffset], a
ld a, [wNumBoxItems]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ld hl, NothingStoredText
call PrintText
2015-07-16 03:04:58 +00:00
jp PlayerPCMenu
.loop
2014-05-22 22:13:20 +00:00
ld hl, WhatToTossText
call PrintText
2015-02-08 06:18:42 +00:00
ld hl, wNumBoxItems
2014-05-22 22:13:20 +00:00
ld a, l
2015-07-15 06:16:06 +00:00
ld [wListPointer], a
2014-05-22 22:13:20 +00:00
ld a, h
2015-07-15 06:16:06 +00:00
ld [wListPointer + 1], a
2014-05-22 22:13:20 +00:00
xor a
2015-07-13 06:00:48 +00:00
ld [wPrintItemPrices], a
2015-07-16 03:04:58 +00:00
ld a, ITEMLISTMENU
2015-02-08 06:18:42 +00:00
ld [wListMenuID], a
2014-05-22 22:13:20 +00:00
push hl
call DisplayListMenuID
pop hl
2015-07-16 03:04:58 +00:00
jp c, PlayerPCMenu
2014-05-22 22:13:20 +00:00
push hl
call IsKeyItem
pop hl
2015-07-16 03:04:58 +00:00
ld a, 1
2015-07-13 06:00:48 +00:00
ld [wItemQuantity], a
ld a, [wIsKeyItem]
2014-05-22 22:13:20 +00:00
and a
2015-07-16 03:04:58 +00:00
jr nz, .next
ld a, [wcf91]
2014-05-22 22:13:20 +00:00
call IsItemHM
2015-07-16 03:04:58 +00:00
jr c, .next
; if it's not a key item, there can be more than one of the item
2014-05-22 22:13:20 +00:00
push hl
ld hl, TossHowManyText
call PrintText
call DisplayChooseQuantityMenu
pop hl
cp $ff
2015-07-16 03:04:58 +00:00
jp z, .loop
.next
call TossItem ; disallows tossing key items
jp .loop
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
PlayersPCMenuEntries:
2014-05-22 22:13:20 +00:00
db "WITHDRAW ITEM"
next "DEPOSIT ITEM"
next "TOSS ITEM"
next "LOG OFF@"
2016-06-12 00:24:04 +00:00
TurnedOnPC2Text:
2014-05-22 22:13:20 +00:00
TX_FAR _TurnedOnPC2Text
db "@"
2016-06-12 00:24:04 +00:00
WhatDoYouWantText:
2014-05-22 22:13:20 +00:00
TX_FAR _WhatDoYouWantText
db "@"
2016-06-12 00:24:04 +00:00
WhatToDepositText:
2014-05-22 22:13:20 +00:00
TX_FAR _WhatToDepositText
db "@"
2016-06-12 00:24:04 +00:00
DepositHowManyText:
2014-05-22 22:13:20 +00:00
TX_FAR _DepositHowManyText
db "@"
2016-06-12 00:24:04 +00:00
ItemWasStoredText:
2014-05-22 22:13:20 +00:00
TX_FAR _ItemWasStoredText
db "@"
2016-06-12 00:24:04 +00:00
NothingToDepositText:
2014-05-22 22:13:20 +00:00
TX_FAR _NothingToDepositText
db "@"
2016-06-12 00:24:04 +00:00
NoRoomToStoreText:
2014-05-22 22:13:20 +00:00
TX_FAR _NoRoomToStoreText
db "@"
2016-06-12 00:24:04 +00:00
WhatToWithdrawText:
2014-05-22 22:13:20 +00:00
TX_FAR _WhatToWithdrawText
db "@"
2016-06-12 00:24:04 +00:00
WithdrawHowManyText:
2014-05-22 22:13:20 +00:00
TX_FAR _WithdrawHowManyText
db "@"
2016-06-12 00:24:04 +00:00
WithdrewItemText:
2014-05-22 22:13:20 +00:00
TX_FAR _WithdrewItemText
db "@"
2016-06-12 00:24:04 +00:00
NothingStoredText:
2014-05-22 22:13:20 +00:00
TX_FAR _NothingStoredText
db "@"
2016-06-12 00:24:04 +00:00
CantCarryMoreText:
2014-05-22 22:13:20 +00:00
TX_FAR _CantCarryMoreText
db "@"
2016-06-12 00:24:04 +00:00
WhatToTossText:
2014-05-22 22:13:20 +00:00
TX_FAR _WhatToTossText
db "@"
2016-06-12 00:24:04 +00:00
TossHowManyText:
2014-05-22 22:13:20 +00:00
TX_FAR _TossHowManyText
db "@"