summaryrefslogtreecommitdiff
path: root/engine/menu/pc.asm
blob: 97895ca6e6b197658491cf3f0541b7aa027a9e80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
ActivatePC: ; 17e2c (5:7e2c)
	call SaveScreenTilesToBuffer2  ;XXX: copy background from wTileMap to wTileMapBackup2
	ld a, (SFX_02_45 - SFX_Headers_02) / 3
	call PlaySound  ;XXX: play sound or stop music
	ld hl, TurnedOnPC1Text
	call PrintText
	call WaitForSoundToFinish  ;XXX: wait for sound to be done
	ld hl, wFlags_0xcd60
	set 3, [hl]
	call LoadScreenTilesFromBuffer2  ;XXX: restore saved screen
	call Delay3
PCMainMenu: ; 17e48 (5:7e48)
	callba Func_213c8
	ld hl, wFlags_0xcd60
	set 5, [hl]
	call HandleMenuInput
	bit 1, a              ;if player pressed B
	jp nz, LogOff
	ld a, [wMaxMenuItem]
	cp a, 2
	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 a, 1
	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 a, 3
	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 a, 1
	jr z, .playersPC ;if current menu item id is 1, it's players pc
	cp a, 2
	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 a, 1
	jr z, .playersPC ;if current menu item id is 1, it's players pc
	cp a, 2
	jp z, OaksPC     ;if current menu item id is 2, it's oaks pc
	cp a, 3
	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, wFlags_0xcd60
	res 5, [hl]
	set 3, [hl]
	ld a, (SFX_02_47 - SFX_Headers_02) / 3
	call PlaySound  ;XXX: play sound or stop music
	call WaitForSoundToFinish  ;XXX: wait for sound to be done
	ld hl, AccessedMyPCText
	call PrintText
	callba PlayerPC
	jr ReloadMainMenu
OaksPC: ; 17ec0 (5:7ec0)
	ld a, (SFX_02_47 - SFX_Headers_02) / 3
	call PlaySound  ;XXX: play sound or stop music
	call WaitForSoundToFinish  ;XXX: wait for sound to be done
	callba OpenOaksPC
	jr ReloadMainMenu
PKMNLeague: ; 17ed2 (5:7ed2)
	ld a, (SFX_02_47 - SFX_Headers_02) / 3
	call PlaySound  ;XXX: play sound or stop music
	call WaitForSoundToFinish  ;XXX: wait for sound to be done
	callba PKMNLeaguePC
	jr ReloadMainMenu
BillsPC: ; 17ee4 (5:7ee4)
	ld a, (SFX_02_47 - SFX_Headers_02) / 3
	call PlaySound    ;XXX: play sound or stop music
	call WaitForSoundToFinish    ;XXX: wait for sound to be done
	ld a, [wd7f1] ;has to do with having met Bill
	bit 0, a
	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
	callba BillsPC_
ReloadMainMenu: ; 17f06 (5:7f06)
	xor a
	ld [wDoNotWaitForButtonPressAfterDisplayingText], a
	call ReloadMapData
	call UpdateSprites  ;XXX: moves sprites
	jp PCMainMenu
LogOff: ; 17f13 (5:7f13)
	ld a, (SFX_02_46 - SFX_Headers_02) / 3
	call PlaySound  ;XXX: play sound or stop music
	call WaitForSoundToFinish  ;XXX: wait for sound to be done
	ld hl, wFlags_0xcd60
	res 3, [hl]
	res 5, [hl]
	ret

TurnedOnPC1Text: ; 17f23 (5:7f23)
	TX_FAR _TurnedOnPC1Text
	db "@"

AccessedBillsPCText: ; 17f28 (5:7f28)
	TX_FAR _AccessedBillsPCText
	db "@"

AccessedSomeonesPCText: ; 17f2d (5:7f2d)
	TX_FAR _AccessedSomeonesPCText
	db "@"

AccessedMyPCText: ; 17f32 (5:7f32)
	TX_FAR _AccessedMyPCText
	db "@"

; removes one of the specified item ID [$FFdb] from bag (if existent)
RemoveItemByID: ; 17f37 (5:7f37)
	ld hl, wBagItems ; wd31e
	ld a, [$ffdb]
	ld b, a
	xor a
	ld [$ffdc], a
.asm_17f40
	ld a, [hli]
	cp $ff
	ret z
	cp b
	jr z, .asm_17f4f
	inc hl
	ld a, [$ffdc]
	inc a
	ld [$ffdc], a
	jr .asm_17f40
.asm_17f4f
	ld a, $1
	ld [wcf96], a
	ld a, [$ffdc]
	ld [wWhichPokemon], a ; wWhichPokemon
	ld hl, wNumBagItems ; wNumBagItems
	jp RemoveItemFromInventory