pokered/engine/menus/pc.asm

142 lines
3.3 KiB
NASM
Raw Normal View History

ActivatePC::
call SaveScreenTilesToBuffer2
2015-07-19 08:46:12 +00:00
ld a, SFX_TURN_ON_PC
call PlaySound
2014-05-22 22:13:20 +00:00
ld hl, TurnedOnPC1Text
call PrintText
call WaitForSoundToFinish
ld hl, wMiscFlags
set BIT_USING_GENERIC_PC, [hl]
call LoadScreenTilesFromBuffer2
2014-05-22 22:13:20 +00:00
call Delay3
2016-06-12 00:24:04 +00:00
PCMainMenu:
farcall DisplayPCMainMenu
ld hl, wMiscFlags
set BIT_NO_MENU_BUTTON_SOUND, [hl]
2014-05-22 22:13:20 +00:00
call HandleMenuInput
bit BIT_B_BUTTON, a
2014-05-22 22:13:20 +00:00
jp nz, LogOff
ld a, [wMaxMenuItem]
cp 2
2014-05-22 22:13:20 +00:00
jr nz, .next ;if not 2 menu items (not counting log off) (2 occurs before you get the pokedex)
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp 1
2014-05-22 22:13:20 +00:00
jr z, .playersPC ;if current menu item id is 1, it's players pc
jp LogOff ;otherwise, it's 2, and you're logging off
.next
cp 3
2014-05-22 22:13:20 +00:00
jr nz, .next2 ;if not 3 menu items (not counting log off) (3 occurs after you get the pokedex, before you beat the pokemon league)
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp 1
2014-05-22 22:13:20 +00:00
jr z, .playersPC ;if current menu item id is 1, it's players pc
cp 2
2014-05-22 22:13:20 +00:00
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
jp LogOff ;otherwise, it's 3, and you're logging off
.next2
ld a, [wCurrentMenuItem]
and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp 1
2014-05-22 22:13:20 +00:00
jr z, .playersPC ;if current menu item id is 1, it's players pc
cp 2
2014-05-22 22:13:20 +00:00
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
cp 3
2014-05-22 22:13:20 +00:00
jp z, PKMNLeague ;if current menu item id is 3, it's pkmnleague
jp LogOff ;otherwise, it's 4, and you're logging off
.playersPC
ld hl, wMiscFlags
res BIT_NO_MENU_BUTTON_SOUND, [hl]
set BIT_USING_GENERIC_PC, [hl]
2015-07-19 08:46:12 +00:00
ld a, SFX_ENTER_PC
call PlaySound
call WaitForSoundToFinish
2014-05-22 22:13:20 +00:00
ld hl, AccessedMyPCText
call PrintText
farcall PlayerPC
2014-05-22 22:13:20 +00:00
jr ReloadMainMenu
2016-06-12 00:24:04 +00:00
OaksPC:
2015-07-19 08:46:12 +00:00
ld a, SFX_ENTER_PC
call PlaySound
call WaitForSoundToFinish
farcall OpenOaksPC
2014-05-22 22:13:20 +00:00
jr ReloadMainMenu
2016-06-12 00:24:04 +00:00
PKMNLeague:
2015-07-19 08:46:12 +00:00
ld a, SFX_ENTER_PC
call PlaySound
call WaitForSoundToFinish
farcall PKMNLeaguePC
2014-05-22 22:13:20 +00:00
jr ReloadMainMenu
2016-06-12 00:24:04 +00:00
BillsPC:
2015-07-19 08:46:12 +00:00
ld a, SFX_ENTER_PC
call PlaySound
call WaitForSoundToFinish
2015-07-21 17:36:03 +00:00
CheckEvent EVENT_MET_BILL
2014-05-22 22:13:20 +00:00
jr nz, .billsPC ;if you've met bill, use that bill's instead of someone's
ld hl, AccessedSomeonesPCText
jr .printText
.billsPC
ld hl, AccessedBillsPCText
.printText
call PrintText
farcall BillsPC_
2016-06-12 00:24:04 +00:00
ReloadMainMenu:
2014-05-22 22:13:20 +00:00
xor a
2014-09-13 07:50:56 +00:00
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
2014-05-22 22:13:20 +00:00
call ReloadMapData
call UpdateSprites
2014-05-22 22:13:20 +00:00
jp PCMainMenu
2016-06-12 00:24:04 +00:00
LogOff:
2015-07-19 08:46:12 +00:00
ld a, SFX_TURN_OFF_PC
call PlaySound
call WaitForSoundToFinish
ld hl, wMiscFlags
res BIT_USING_GENERIC_PC, [hl]
res BIT_NO_MENU_BUTTON_SOUND, [hl]
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
TurnedOnPC1Text:
text_far _TurnedOnPC1Text
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
AccessedBillsPCText:
text_far _AccessedBillsPCText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
AccessedSomeonesPCText:
text_far _AccessedSomeonesPCText
text_end
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
AccessedMyPCText:
text_far _AccessedMyPCText
text_end
2014-05-22 22:13:20 +00:00
2015-07-24 21:57:49 +00:00
; removes one of the specified item ID [hItemToRemoveID] from bag (if existent)
RemoveItemByID::
ld hl, wBagItems
ldh a, [hItemToRemoveID]
2014-05-22 22:13:20 +00:00
ld b, a
xor a
ldh [hItemToRemoveIndex], a
2016-06-12 04:30:05 +00:00
.loop
2014-05-22 22:13:20 +00:00
ld a, [hli]
2016-06-12 04:30:05 +00:00
cp -1 ; reached terminator?
2014-05-22 22:13:20 +00:00
ret z
cp b
2016-06-12 04:30:05 +00:00
jr z, .foundItem
2014-05-22 22:13:20 +00:00
inc hl
ldh a, [hItemToRemoveIndex]
2014-05-22 22:13:20 +00:00
inc a
ldh [hItemToRemoveIndex], a
2016-06-12 04:30:05 +00:00
jr .loop
.foundItem
2014-05-22 22:13:20 +00:00
ld a, $1
2015-07-13 06:00:48 +00:00
ld [wItemQuantity], a
ldh a, [hItemToRemoveIndex]
ld [wWhichPokemon], a
ld hl, wNumBagItems
2014-05-22 22:13:20 +00:00
jp RemoveItemFromInventory