summaryrefslogtreecommitdiff
path: root/src/engine/menus/glossary.asm
blob: 78f44dd95a5b02ed8cdd0f26f166a4f2ac4c7dbd (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
OpenGlossaryScreen:
	xor a
	ld [wGlossaryPageNo], a
	call .display_menu

	xor a
	ld [wInPlayAreaCurPosition], a
	ld de, OpenGlossaryScreen_TransitionTable ; this data is stored in bank 2.
	ld hl, wMenuInputTablePointer
	ld [hl], e
	inc hl
	ld [hl], d
	ld a, $ff
	ld [wDuelInitialPrizesUpperBitsSet], a
	xor a
	ld [wCheckMenuCursorBlinkCounter], a
.next
	ld a, $01
	ld [wVBlankOAMCopyToggle], a
	call DoFrame
	ldh a, [hKeysPressed]
	and SELECT
	jr nz, .on_select

	farcall YourOrOppPlayAreaScreen_HandleInput
	jr nc, .next

	cp -1 ; b button
	jr nz, .check_button

	farcall ZeroObjectPositionsWithCopyToggleOn
	ret

.check_button
	push af
	farcall ZeroObjectPositionsWithCopyToggleOn
	pop af

	cp $09 ; $09: next page or prev page
	jr z, .change_page

	call .print_description
	call .display_menu
	xor a
	ld [wCheckMenuCursorBlinkCounter], a
	jr .next

.on_select
	ld a, $01
	farcall PlaySFXConfirmOrCancel
.change_page
	ld a, [wGlossaryPageNo]
	xor $01 ; swap page
	ld [wGlossaryPageNo], a
	call .print_menu
	jr .next

; display glossary menu.
.display_menu ; 1852b (6:452b)
	xor a
	ld [wTileMapFill], a
	call ZeroObjectPositions
	ld a, $01
	ld [wVBlankOAMCopyToggle], a
	call DoFrame
	call EmptyScreen
	call Set_OBJ_8x8
	farcall LoadCursorTile

	lb de, 5, 0
	call InitTextPrinting
	ldtx hl, PokemonCardGlossaryText
	call ProcessTextFromID
	call .print_menu
	ldtx hl, ChooseWordAndPressAButtonText
	call DrawWideTextBox_PrintText
	ret

; print texts in glossary menu.
.print_menu ; 1855a (6:455a)
	ld hl, wDefaultText

	ld a, TX_SYMBOL
	ld [hli], a

	ld a, [wGlossaryPageNo]
	add SYM_1
	ld [hli], a

	ld a, TX_SYMBOL
	ld [hli], a

	ld a, SYM_SLASH
	ld [hli], a

	ld a, TX_SYMBOL
	ld [hli], a

	ld a, SYM_2
	ld [hli], a

	ld [hl], TX_END

	lb de, 16, 1
	call InitTextPrinting
	ld hl, wDefaultText
	call ProcessText

	lb de, 1, 3
	call InitTextPrinting
	ld a, [wGlossaryPageNo]
	or a
	jr nz, .page_two

	ldtx hl, GlossaryMenuPage1Text
	jr .page_one

.page_two
	ldtx hl, GlossaryMenuPage2Text
.page_one
	call ProcessTextFromID
	ret

; display glossary description.
.print_description ; 18598 (6:4598)
	push af
	xor a
	ld [wTileMapFill], a
	call EmptyScreen
	lb de, 5, 0
	call InitTextPrinting
	ldtx hl, PokemonCardGlossaryText
	call ProcessTextFromID
	lb de, 0, 4
	lb bc, 20, 14
	call DrawRegularTextBox

	ld a, [wGlossaryPageNo]
	or a
	jr nz, .back_page

	ld hl, GlossaryData1
	jr .front_page

.back_page
	ld hl, GlossaryData2
.front_page
	pop af
	; hl += (a + (a << 2)).
	; that is,
	; hl += (5 * a).
	ld c, a
	ld b, 0
	add hl, bc
	sla a
	sla a
	ld c, a
	add hl, bc
	ld a, [hli]
	push hl
	ld d, a
	ld e, $02
	call InitTextPrinting
	ld a, [hli]
	ld h, [hl]
	ld l, a
	call ProcessTextFromID
	pop hl
	lb de, 1, 5
	call InitTextPrinting
	inc hl
	inc hl
	ld a, [hli]
	ld h, [hl]
	ld l, a
	ld a, $01
	ld [wLineSeparation], a
	call ProcessTextFromID
	xor a
	ld [wLineSeparation], a
	call EnableLCD
.loop
	call DoFrame
	ldh a, [hKeysPressed]
	and B_BUTTON
	jr z, .loop

	ld a, -1
	farcall PlaySFXConfirmOrCancel
	ret

; unit: 5 bytes.
; [structure]
; horizontal align (1) / title text id (2) / desc. text id (2)
glossary_entry: MACRO
	db \1
	tx \2
	tx \3
ENDM

GlossaryData1:
	glossary_entry 7, AboutTheDeckText, DeckDescriptionText
	glossary_entry 5, AboutTheDiscardPileText, DiscardPileDescriptionText
	glossary_entry 7, AboutTheHandText, HandDescriptionText
	glossary_entry 6, AboutTheArenaText, ArenaDescriptionText
	glossary_entry 6, AboutTheBenchText, BenchDescriptionText
	glossary_entry 4, AboutTheActivePokemonText, ActivePokemonDescriptionText
	glossary_entry 5, AboutBenchPokemonText, BenchPokemonDescriptionText
	glossary_entry 7, AboutPrizesText, PrizesDescriptionText
	glossary_entry 5, AboutDamageCountersText, DamageCountersDescriptionText

GlossaryData2:
	glossary_entry 5, AboutEnergyCardsText, EnergyCardsDescriptionText
	glossary_entry 5, AboutTrainerCardsText, TrainerCardsDescriptionText
	glossary_entry 5, AboutBasicPokemonText, BasicPokemonDescriptionText
	glossary_entry 5, AboutEvolutionCardsText, EvolutionCardsDescriptionText
	glossary_entry 6, AboutAttackingText, AttackingDescriptionText
	glossary_entry 5, AboutPokemonPowerText, PokemonPowerDescriptionText
	glossary_entry 6, AboutWeaknessText, WeaknessDescriptionText
	glossary_entry 6, AboutResistanceText, ResistanceDescriptionText
	glossary_entry 6, AboutRetreatingText, RetreatingDescriptionText