Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/pc.asm
1271 views
1
ActivatePC::
2
call SaveScreenTilesToBuffer2
3
ld a, SFX_TURN_ON_PC
4
call PlaySound
5
ld hl, TurnedOnPC1Text
6
call PrintText
7
call WaitForSoundToFinish
8
ld hl, wMiscFlags
9
set BIT_USING_GENERIC_PC, [hl]
10
call LoadScreenTilesFromBuffer2
11
call Delay3
12
PCMainMenu:
13
farcall DisplayPCMainMenu
14
ld hl, wMiscFlags
15
set BIT_NO_MENU_BUTTON_SOUND, [hl]
16
call HandleMenuInput
17
bit B_PAD_B, a
18
jp nz, LogOff
19
ld a, [wMaxMenuItem]
20
cp 2
21
jr nz, .next ;if not 2 menu items (not counting log off) (2 occurs before you get the pokedex)
22
ld a, [wCurrentMenuItem]
23
and a
24
jp z, BillsPC ;if current menu item id is 0, it's bills pc
25
cp 1
26
jr z, .playersPC ;if current menu item id is 1, it's players pc
27
jp LogOff ;otherwise, it's 2, and you're logging off
28
.next
29
cp 3
30
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)
31
ld a, [wCurrentMenuItem]
32
and a
33
jp z, BillsPC ;if current menu item id is 0, it's bills pc
34
cp 1
35
jr z, .playersPC ;if current menu item id is 1, it's players pc
36
cp 2
37
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
38
jp LogOff ;otherwise, it's 3, and you're logging off
39
.next2
40
ld a, [wCurrentMenuItem]
41
and a
42
jp z, BillsPC ;if current menu item id is 0, it's bills pc
43
cp 1
44
jr z, .playersPC ;if current menu item id is 1, it's players pc
45
cp 2
46
jp z, OaksPC ;if current menu item id is 2, it's oaks pc
47
cp 3
48
jp z, PKMNLeague ;if current menu item id is 3, it's pkmnleague
49
jp LogOff ;otherwise, it's 4, and you're logging off
50
.playersPC
51
ld hl, wMiscFlags
52
res BIT_NO_MENU_BUTTON_SOUND, [hl]
53
set BIT_USING_GENERIC_PC, [hl]
54
ld a, SFX_ENTER_PC
55
call PlaySound
56
call WaitForSoundToFinish
57
ld hl, AccessedMyPCText
58
call PrintText
59
farcall PlayerPC
60
jr ReloadMainMenu
61
OaksPC:
62
ld a, SFX_ENTER_PC
63
call PlaySound
64
call WaitForSoundToFinish
65
farcall OpenOaksPC
66
jr ReloadMainMenu
67
PKMNLeague:
68
ld a, SFX_ENTER_PC
69
call PlaySound
70
call WaitForSoundToFinish
71
farcall PKMNLeaguePC
72
jr ReloadMainMenu
73
BillsPC:
74
ld a, SFX_ENTER_PC
75
call PlaySound
76
call WaitForSoundToFinish
77
CheckEvent EVENT_MET_BILL
78
jr nz, .billsPC ;if you've met bill, use that bill's instead of someone's
79
ld hl, AccessedSomeonesPCText
80
jr .printText
81
.billsPC
82
ld hl, AccessedBillsPCText
83
.printText
84
call PrintText
85
farcall BillsPC_
86
ReloadMainMenu:
87
xor a
88
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
89
call ReloadMapData
90
call UpdateSprites
91
jp PCMainMenu
92
LogOff:
93
ld a, SFX_TURN_OFF_PC
94
call PlaySound
95
call WaitForSoundToFinish
96
ld hl, wMiscFlags
97
res BIT_USING_GENERIC_PC, [hl]
98
res BIT_NO_MENU_BUTTON_SOUND, [hl]
99
ret
100
101
TurnedOnPC1Text:
102
text_far _TurnedOnPC1Text
103
text_end
104
105
AccessedBillsPCText:
106
text_far _AccessedBillsPCText
107
text_end
108
109
AccessedSomeonesPCText:
110
text_far _AccessedSomeonesPCText
111
text_end
112
113
AccessedMyPCText:
114
text_far _AccessedMyPCText
115
text_end
116
117
; removes one of the specified item ID [hItemToRemoveID] from bag (if existent)
118
RemoveItemByID::
119
ld hl, wBagItems
120
ldh a, [hItemToRemoveID]
121
ld b, a
122
xor a
123
ldh [hItemToRemoveIndex], a
124
.loop
125
ld a, [hli]
126
cp -1 ; reached terminator?
127
ret z
128
cp b
129
jr z, .foundItem
130
inc hl
131
ldh a, [hItemToRemoveIndex]
132
inc a
133
ldh [hItemToRemoveIndex], a
134
jr .loop
135
.foundItem
136
ld a, $1
137
ld [wItemQuantity], a
138
ldh a, [hItemToRemoveIndex]
139
ld [wWhichPokemon], a
140
ld hl, wNumBagItems
141
jp RemoveItemFromInventory
142
143