pokered/engine/menu/bills_pc.asm

555 lines
9.8 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
DisplayPCMainMenu::
xor a
2015-02-08 06:18:42 +00:00
ld [H_AUTOBGTRANSFERENABLED], a
call SaveScreenTilesToBuffer2
2015-07-15 02:46:52 +00:00
ld a, [wNumHoFTeams]
and a
2015-07-16 03:04:58 +00:00
jr nz, .leaguePCAvailable
2015-07-21 01:32:02 +00:00
CheckEvent EVENT_GOT_POKEDEX
2015-07-16 03:04:58 +00:00
jr z, .noOaksPC
2015-07-15 02:46:52 +00:00
ld a, [wNumHoFTeams]
and a
2015-07-16 03:04:58 +00:00
jr nz, .leaguePCAvailable
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-07-16 03:04:58 +00:00
ld b, 8
ld c, 14
jr .next
.noOaksPC
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-07-16 03:04:58 +00:00
ld b, 6
ld c, 14
jr .next
.leaguePCAvailable
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-07-16 03:04:58 +00:00
ld b, 10
ld c, 14
.next
call TextBoxBorder
call UpdateSprites
2015-07-16 03:04:58 +00:00
ld a, 3
2015-02-08 06:18:42 +00:00
ld [wMaxMenuItem], a
2015-07-21 17:36:03 +00:00
CheckEvent EVENT_MET_BILL
2015-07-16 03:04:58 +00:00
jr nz, .metBill
2015-07-18 20:52:03 +00:00
coord hl, 2, 2
2015-02-08 06:18:42 +00:00
ld de, SomeonesPCText
2015-07-16 03:04:58 +00:00
jr .next2
.metBill
2015-07-18 20:52:03 +00:00
coord hl, 2, 2
2015-02-08 06:18:42 +00:00
ld de, BillsPCText
2015-07-16 03:04:58 +00:00
.next2
call PlaceString
2015-07-18 20:52:03 +00:00
coord hl, 2, 4
2015-02-08 06:18:42 +00:00
ld de, wPlayerName
call PlaceString
ld l, c
ld h, b
2015-02-08 06:18:42 +00:00
ld de, PlayersPCText
call PlaceString
2015-07-21 01:32:02 +00:00
CheckEvent EVENT_GOT_POKEDEX
2015-07-16 03:04:58 +00:00
jr z, .noOaksPC2
2015-07-18 20:52:03 +00:00
coord hl, 2, 6
2015-02-08 06:18:42 +00:00
ld de, OaksPCText
call PlaceString
2015-07-15 02:46:52 +00:00
ld a, [wNumHoFTeams]
and a
2015-07-16 03:04:58 +00:00
jr z, .noLeaguePC
ld a, 4
2015-02-08 06:18:42 +00:00
ld [wMaxMenuItem], a
2015-07-18 20:52:03 +00:00
coord hl, 2, 8
2015-02-08 06:18:42 +00:00
ld de, PKMNLeaguePCText
call PlaceString
2015-07-18 20:52:03 +00:00
coord hl, 2, 10
2015-02-08 06:18:42 +00:00
ld de, LogOffPCText
2015-07-16 03:04:58 +00:00
jr .next3
.noLeaguePC
2015-07-18 20:52:03 +00:00
coord hl, 2, 8
2015-02-08 06:18:42 +00:00
ld de, LogOffPCText
2015-07-16 03:04:58 +00:00
jr .next3
.noOaksPC2
ld a, $2
2015-02-08 06:18:42 +00:00
ld [wMaxMenuItem], a
2015-07-18 20:52:03 +00:00
coord hl, 2, 6
2015-02-08 06:18:42 +00:00
ld de, LogOffPCText
2015-07-16 03:04:58 +00:00
.next3
call PlaceString
2015-07-16 03:04:58 +00:00
ld a, A_BUTTON | B_BUTTON
2015-02-08 06:18:42 +00:00
ld [wMenuWatchedKeys], a
2015-07-16 03:04:58 +00:00
ld a, 2
2015-02-08 06:18:42 +00:00
ld [wTopMenuItemY], a
2015-07-16 03:04:58 +00:00
ld a, 1
2015-02-08 06:18:42 +00:00
ld [wTopMenuItemX], a
xor a
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
2015-07-16 03:04:58 +00:00
ld a, 1
2015-02-08 06:18:42 +00:00
ld [H_AUTOBGTRANSFERENABLED], a
ret
SomeonesPCText: db "SOMEONE's PC@"
BillsPCText: db "BILL's PC@"
PlayersPCText: db "'s PC@"
OaksPCText: db "PROF.OAK's PC@"
PKMNLeaguePCText: db $4a, "LEAGUE@"
LogOffPCText: db "LOG OFF@"
BillsPC_:: ; 0x214c2
ld hl, wd730
set 6, [hl]
xor a
2015-07-16 03:04:58 +00:00
ld [wParentMenuItem], a
inc a ; MONSTER_NAME
2015-02-08 09:44:41 +00:00
ld [wNameListType], a
call LoadHpBarAndStatusTilePatterns
2015-02-08 06:18:42 +00:00
ld a, [wListScrollOffset]
push af
ld a, [wFlags_0xcd60]
2015-07-16 03:04:58 +00:00
bit 3, a ; accessing Bill's PC through another PC?
jr nz, BillsPCMenu
2015-07-16 03:04:58 +00:00
; accessing it directly
ld a, $99
call PlaySound
ld hl, SwitchOnText
call PrintText
2016-06-12 00:24:04 +00:00
BillsPCMenu:
2015-07-16 03:04:58 +00:00
ld a, [wParentMenuItem]
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
2014-05-29 08:31:46 +00:00
ld hl, vChars2 + $780
2015-02-08 06:18:42 +00:00
ld de, PokeballTileGraphics
2015-08-05 21:20:29 +00:00
lb bc, BANK(PokeballTileGraphics), $01
call CopyVideoData
call LoadScreenTilesFromBuffer2DisableBGTransfer
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-07-16 03:04:58 +00:00
ld b, 10
ld c, 12
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 2, 2
2015-02-08 06:18:42 +00:00
ld de, BillsPCMenuText
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
dec a
2015-07-16 03:04:58 +00:00
ld [hli], a ; wTopMenuItemX
inc hl
inc hl
2015-07-16 03:04:58 +00:00
ld a, 4
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
xor a
2015-07-16 03:04:58 +00:00
ld [hli], a ; wLastMenuItem
ld [hli], a ; wPartyAndBillsPCSavedMenuItem
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
ld hl, WhatText
call PrintText
2015-07-18 20:52:03 +00:00
coord hl, 9, 14
2015-07-16 03:04:58 +00:00
ld b, 2
ld c, 9
call TextBoxBorder
2015-07-16 03:04:58 +00:00
ld a, [wCurrentBoxNum]
and $7f
cp 9
2015-07-16 03:04:58 +00:00
jr c, .singleDigitBoxNum
; two digit box num
sub 9
2015-07-18 20:52:03 +00:00
coord hl, 17, 16
ld [hl], "1"
add "0"
2015-07-16 03:04:58 +00:00
jr .next
.singleDigitBoxNum
add "1"
2015-07-16 03:04:58 +00:00
.next
Coorda 18, 16
2015-07-18 20:52:03 +00:00
coord hl, 10, 16
2015-02-08 06:18:42 +00:00
ld de, BoxNoPCText
call PlaceString
2015-07-16 03:04:58 +00:00
ld a, 1
2015-02-08 06:18:42 +00:00
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call HandleMenuInput
bit 1, a
2015-07-16 03:04:58 +00:00
jp nz, ExitBillsPC ; b button
call PlaceUnfilledArrowMenuCursor
2015-02-08 06:18:42 +00:00
ld a, [wCurrentMenuItem]
2015-07-16 03:04:58 +00:00
ld [wParentMenuItem], a
and a
2015-07-16 03:04:58 +00:00
jp z, BillsPCWithdraw ; withdraw
cp $1
2015-07-16 03:04:58 +00:00
jp z, BillsPCDeposit ; deposit
cp $2
2015-07-16 03:04:58 +00:00
jp z, BillsPCRelease ; release
cp $3
2015-07-16 03:04:58 +00:00
jp z, BillsPCChangeBox ; change box
2016-06-12 00:24:04 +00:00
ExitBillsPC:
ld a, [wFlags_0xcd60]
2015-07-16 03:04:58 +00:00
bit 3, a ; accessing Bill's PC through another PC?
jr nz, .next
; accessing it directly
call LoadTextBoxTilePatterns
ld a, $9a
call PlaySound
call WaitForSoundToFinish
2015-07-16 03:04:58 +00:00
.next
ld hl, wFlags_0xcd60
res 5, [hl]
call LoadScreenTilesFromBuffer2
pop af
2015-02-08 06:18:42 +00:00
ld [wListScrollOffset], a
ld hl, wd730
res 6, [hl]
ret
2016-06-12 00:24:04 +00:00
BillsPCDeposit:
2015-02-08 06:18:42 +00:00
ld a, [wPartyCount]
dec a
2015-07-16 03:04:58 +00:00
jr nz, .partyLargeEnough
ld hl, CantDepositLastMonText
call PrintText
jp BillsPCMenu
2015-07-16 03:04:58 +00:00
.partyLargeEnough
2015-08-31 02:38:41 +00:00
ld a, [wNumInBox]
cp MONS_PER_BOX
2015-07-16 03:04:58 +00:00
jr nz, .boxNotFull
2015-02-08 06:18:42 +00:00
ld hl, BoxFullText
call PrintText
jp BillsPCMenu
2015-07-16 03:04:58 +00:00
.boxNotFull
2015-02-08 06:18:42 +00:00
ld hl, wPartyCount
2015-07-16 03:04:58 +00:00
call DisplayMonListMenu
jp c, BillsPCMenu
2015-07-16 03:04:58 +00:00
call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
ld a, PARTY_TO_BOX
ld [wMoveMonType], a
2015-07-13 06:00:48 +00:00
call MoveMon
xor a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
2015-07-16 03:04:58 +00:00
ld hl, wBoxNumString
ld a, [wCurrentBoxNum]
and $7f
cp 9
2015-07-16 03:04:58 +00:00
jr c, .singleDigitBoxNum
sub 9
ld [hl], "1"
inc hl
add "0"
2015-07-16 03:04:58 +00:00
jr .next
.singleDigitBoxNum
add "1"
2015-07-16 03:04:58 +00:00
.next
ld [hli], a
ld [hl], $50
2015-02-08 06:18:42 +00:00
ld hl, MonWasStoredText
call PrintText
jp BillsPCMenu
2016-06-12 00:24:04 +00:00
BillsPCWithdraw:
2015-08-31 02:38:41 +00:00
ld a, [wNumInBox]
and a
2015-07-16 03:04:58 +00:00
jr nz, .boxNotEmpty
2015-02-08 06:18:42 +00:00
ld hl, NoMonText
call PrintText
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
.boxNotEmpty
2015-02-08 06:18:42 +00:00
ld a, [wPartyCount]
cp PARTY_LENGTH
2015-07-16 03:04:58 +00:00
jr nz, .partyNotFull
2015-02-08 06:18:42 +00:00
ld hl, CantTakeMonText
call PrintText
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
.partyNotFull
2015-08-31 02:38:41 +00:00
ld hl, wNumInBox
2015-07-16 03:04:58 +00:00
call DisplayMonListMenu
jp c, BillsPCMenu
call DisplayDepositWithdrawMenu
jp nc, BillsPCMenu
2015-02-08 06:18:42 +00:00
ld a, [wWhichPokemon]
ld hl, wBoxMonNicks
call GetPartyMonName
ld a, [wcf91]
call GetCryData
call PlaySoundWaitForCurrent
xor a ; BOX_TO_PARTY
ld [wMoveMonType], a
2015-07-13 06:00:48 +00:00
call MoveMon
ld a, 1
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
2015-02-08 06:18:42 +00:00
ld hl, MonIsTakenOutText
call PrintText
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
2016-06-12 00:24:04 +00:00
BillsPCRelease:
2015-08-31 02:38:41 +00:00
ld a, [wNumInBox]
and a
2015-07-16 03:04:58 +00:00
jr nz, .loop
2015-02-08 06:18:42 +00:00
ld hl, NoMonText
call PrintText
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
.loop
2015-08-31 02:38:41 +00:00
ld hl, wNumInBox
2015-07-16 03:04:58 +00:00
call DisplayMonListMenu
jp c, BillsPCMenu
2015-02-08 06:18:42 +00:00
ld hl, OnceReleasedText
call PrintText
call YesNoChoice
2015-02-08 06:18:42 +00:00
ld a, [wCurrentMenuItem]
and a
2015-07-16 03:04:58 +00:00
jr nz, .loop
inc a
ld [wRemoveMonFromBox], a
call RemovePokemon
call WaitForSoundToFinish
ld a, [wcf91]
call PlayCry
2015-02-08 06:18:42 +00:00
ld hl, MonWasReleasedText
call PrintText
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
2016-06-12 00:24:04 +00:00
BillsPCChangeBox:
2014-09-14 18:29:18 +00:00
callba ChangeBox
2015-07-16 03:04:58 +00:00
jp BillsPCMenu
2016-06-12 00:24:04 +00:00
DisplayMonListMenu:
ld a, l
2015-07-15 06:16:06 +00:00
ld [wListPointer], a
ld a, h
2015-07-15 06:16:06 +00:00
ld [wListPointer + 1], a
xor a
2015-07-13 06:00:48 +00:00
ld [wPrintItemPrices], a
2015-02-08 06:18:42 +00:00
ld [wListMenuID], a
inc a ; MONSTER_NAME
2015-02-08 09:44:41 +00:00
ld [wNameListType], a
2015-07-16 03:04:58 +00:00
ld a, [wPartyAndBillsPCSavedMenuItem]
2015-02-08 06:18:42 +00:00
ld [wCurrentMenuItem], a
call DisplayListMenuID
2015-02-08 06:18:42 +00:00
ld a, [wCurrentMenuItem]
2015-07-16 03:04:58 +00:00
ld [wPartyAndBillsPCSavedMenuItem], a
ret
2016-06-12 00:24:04 +00:00
BillsPCMenuText:
db "WITHDRAW ", $4a
next "DEPOSIT ", $4a
next "RELEASE ", $4a
next "CHANGE BOX"
next "SEE YA!"
db "@"
2016-06-12 00:24:04 +00:00
BoxNoPCText:
db "BOX No.@"
2016-06-12 00:24:04 +00:00
KnowsHMMove::
2015-07-16 03:04:58 +00:00
; returns whether mon with party index [wWhichPokemon] knows an HM move
ld hl, wPartyMon1Moves
ld bc, wPartyMon2 - wPartyMon1
2015-07-16 03:04:58 +00:00
jr .next
; unreachable
ld hl, wBoxMon1Moves
ld bc, wBoxMon2 - wBoxMon1
2015-07-16 03:04:58 +00:00
.next
ld a, [wWhichPokemon]
call AddNTimes
ld b, NUM_MOVES
2015-07-16 03:04:58 +00:00
.loop
ld a, [hli]
push hl
push bc
2015-02-08 06:18:42 +00:00
ld hl, HMMoveArray
ld de, 1
call IsInArray
pop bc
pop hl
ret c
dec b
2015-07-16 03:04:58 +00:00
jr nz, .loop
and a
ret
2016-06-12 00:24:04 +00:00
HMMoveArray:
db CUT
db FLY
db SURF
db STRENGTH
db FLASH
db -1
2016-06-12 00:24:04 +00:00
DisplayDepositWithdrawMenu:
2015-07-18 20:52:03 +00:00
coord hl, 9, 10
2015-07-16 03:04:58 +00:00
ld b, 6
ld c, 9
call TextBoxBorder
2015-07-16 03:04:58 +00:00
ld a, [wParentMenuItem]
and a ; was the Deposit or Withdraw item selected in the parent menu?
2015-02-08 06:18:42 +00:00
ld de, DepositPCText
2015-07-16 03:04:58 +00:00
jr nz, .next
2015-02-08 06:18:42 +00:00
ld de, WithdrawPCText
2015-07-16 03:04:58 +00:00
.next
2015-07-18 20:52:03 +00:00
coord hl, 11, 12
call PlaceString
2015-07-18 20:52:03 +00:00
coord hl, 11, 14
2015-02-08 06:18:42 +00:00
ld de, StatsCancelPCText
call PlaceString
2015-02-08 06:18:42 +00:00
ld hl, wTopMenuItemY
2015-07-16 03:04:58 +00:00
ld a, 12
ld [hli], a ; wTopMenuItemY
ld a, 10
ld [hli], a ; wTopMenuItemX
xor a
2015-07-16 03:04:58 +00:00
ld [hli], a ; wCurrentMenuItem
inc hl
2015-07-16 03:04:58 +00:00
ld a, 2
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
xor a
2015-07-16 03:04:58 +00:00
ld [hl], a ; wLastMenuItem
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
2015-07-16 03:04:58 +00:00
ld [wPartyAndBillsPCSavedMenuItem], a
.loop
call HandleMenuInput
2015-07-16 03:04:58 +00:00
bit 1, a ; pressed B?
jr nz, .exit
2015-02-08 06:18:42 +00:00
ld a, [wCurrentMenuItem]
and a
2015-07-16 03:04:58 +00:00
jr z, .choseDepositWithdraw
dec a
2015-07-16 03:04:58 +00:00
jr z, .viewStats
.exit
and a
ret
2015-07-16 03:04:58 +00:00
.choseDepositWithdraw
scf
ret
2015-07-16 03:04:58 +00:00
.viewStats
call SaveScreenTilesToBuffer1
2015-07-16 03:04:58 +00:00
ld a, [wParentMenuItem]
and a
2015-07-16 03:04:58 +00:00
ld a, PLAYER_PARTY_DATA
jr nz, .next2
ld a, BOX_DATA
.next2
ld [wMonDataLocation], a
predef StatusScreen
predef StatusScreen2
call LoadScreenTilesFromBuffer1
call ReloadTilesetTilePatterns
2015-08-12 09:16:56 +00:00
call RunDefaultPaletteCommand
call LoadGBPal
2015-07-16 03:04:58 +00:00
jr .loop
DepositPCText: db "DEPOSIT@"
WithdrawPCText: db "WITHDRAW@"
StatsCancelPCText:
db "STATS"
next "CANCEL@"
SwitchOnText: ; 0x217e9
TX_FAR _SwitchOnText
db "@"
WhatText: ; 0x217ee
TX_FAR _WhatText
db "@"
DepositWhichMonText: ; 0x217f3
TX_FAR _DepositWhichMonText
db "@"
MonWasStoredText: ; 0x217f8
TX_FAR _MonWasStoredText
db "@"
CantDepositLastMonText: ; 0x217fd
TX_FAR _CantDepositLastMonText
db "@"
BoxFullText: ; 0x21802
TX_FAR _BoxFullText
db "@"
MonIsTakenOutText: ; 0x21807
TX_FAR _MonIsTakenOutText
db "@"
NoMonText: ; 0x2180c
TX_FAR _NoMonText
db "@"
CantTakeMonText: ; 0x21811
TX_FAR _CantTakeMonText
db "@"
ReleaseWhichMonText: ; 0x21816
TX_FAR _ReleaseWhichMonText
db "@"
OnceReleasedText: ; 0x2181b
TX_FAR _OnceReleasedText
db "@"
MonWasReleasedText: ; 0x21820
TX_FAR _MonWasReleasedText
db "@"
2016-06-12 00:24:04 +00:00
CableClubLeftGameboy::
2015-02-07 10:43:08 +00:00
ld a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
ret z
2015-02-07 10:43:08 +00:00
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_RIGHT
ret nz
2015-08-31 02:38:41 +00:00
ld a, [wCurMap]
cp TRADE_CENTER
2015-02-07 10:43:08 +00:00
ld a, LINK_STATE_START_TRADE
2015-07-16 03:04:58 +00:00
jr z, .next
2015-02-07 10:43:08 +00:00
inc a ; LINK_STATE_START_BATTLE
2015-07-16 03:04:58 +00:00
.next
2015-02-07 10:43:08 +00:00
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
2016-06-12 00:24:04 +00:00
CableClubRightGameboy::
2015-02-07 10:43:08 +00:00
ld a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret z
2015-02-07 10:43:08 +00:00
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_LEFT
ret nz
2015-08-31 02:38:41 +00:00
ld a, [wCurMap]
cp TRADE_CENTER
2015-02-07 10:43:08 +00:00
ld a, LINK_STATE_START_TRADE
2015-07-16 03:04:58 +00:00
jr z, .next
2015-02-07 10:43:08 +00:00
inc a ; LINK_STATE_START_BATTLE
2015-07-16 03:04:58 +00:00
.next
2015-02-07 10:43:08 +00:00
ld [wLinkState], a
call EnableAutoTextBoxDrawing
tx_pre_jump JustAMomentText
2016-06-12 00:24:04 +00:00
JustAMomentText::
2014-05-15 23:58:24 +00:00
TX_FAR _JustAMomentText
db "@"
2015-02-07 10:43:08 +00:00
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_UP
ret nz
call EnableAutoTextBoxDrawing
tx_pre_jump OpenBillsPCText
2016-06-12 00:24:04 +00:00
OpenBillsPCText::
2014-05-21 23:08:32 +00:00
db $FD ; FuncTX_BillsPC