|
@@ -1,494 +0,0 @@
|
1
|
|
-#include <agb_debug.h>
|
2
|
|
-#include <constants/pkmns.h>
|
3
|
|
-#include <pokeagb/pokeagb.h>
|
4
|
|
-#include <pokedex/pdexArrow.h>
|
5
|
|
-#include <pokedex/pdexBall.h>
|
6
|
|
-#include <pokedex/pdexBg.h>
|
7
|
|
-#include <pokedex/pdexScrollBar.h>
|
8
|
|
-#include <pokedex/pdexSelectHalf.h>
|
9
|
|
-
|
10
|
|
-#include "pokedex_common.h"
|
11
|
|
-
|
12
|
|
-
|
13
|
|
-
|
14
|
|
-
|
15
|
|
-#define TB_TITLE 0
|
16
|
|
-#define TB_PKMN 1
|
17
|
|
-#define TB_SEEN 2
|
18
|
|
-#define TB_CAUGHT 3
|
19
|
|
-#define TB_MAIN 4
|
20
|
|
-
|
21
|
|
-#define TB_SEEN_Y (6)
|
22
|
|
-#define TB_CAUGHT_Y 3
|
23
|
|
-
|
24
|
|
-#define DEX_SCROLL_MIN 23
|
25
|
|
-#define DEX_SCROLL_MAX 146
|
26
|
|
-
|
27
|
|
-void pdex_load(void);
|
28
|
|
-void pdex_vblank_handler(void);
|
29
|
|
-void pdex_loop(u8 tid);
|
30
|
|
-void pdex_cb_handler(void);
|
31
|
|
-
|
32
|
|
-extern const pchar pdex_str_title[];
|
33
|
|
-extern const pchar pdex_str_seen[];
|
34
|
|
-extern const pchar pdex_str_caught[];
|
35
|
|
-extern const pchar pdex_str_empty[];
|
36
|
|
-
|
37
|
|
-static const u8 pdex_y_offset[] = {19, 35, 51, 67, 83, 99, 115, 131};
|
38
|
|
-
|
39
|
|
-struct TextboxTemplate pdex_boxes[] = {
|
40
|
|
- {.bg_id = 0, .x = 11, .y = 0, .width = 10, .height = 2, .pal_id = 15, .charbase = 1},
|
41
|
|
- {.bg_id = 0, .x = 2, .y = 2, .width = 10, .height = 2, .pal_id = 15, .charbase = 21},
|
42
|
|
- {.bg_id = 0, .x = 3, .y = 13, .width = 9, .height = 3, .pal_id = 15, .charbase = 41},
|
43
|
|
- {.bg_id = 0, .x = 3, .y = 16, .width = 9, .height = 2, .pal_id = 15, .charbase = 59},
|
44
|
|
-
|
45
|
|
- {.bg_id = 1, .x = 16, .y = 0, .width = 11, .height = 32, .pal_id = 15, .charbase = 77},
|
46
|
|
-
|
47
|
|
- {.bg_id = 0xFF},
|
48
|
|
-};
|
49
|
|
-
|
50
|
|
-
|
51
|
|
-
|
52
|
|
-s16 pdex_get_y_offset(s8 n) {
|
53
|
|
- s8 modOffset = n + pokedex_context->hardware_scroll_amount;
|
54
|
|
- dprintf("mod_offset: %d\n", modOffset);
|
55
|
|
- if (modOffset < -1) {
|
56
|
|
- modOffset += 16;
|
57
|
|
- }
|
58
|
|
-
|
59
|
|
- if (modOffset > 14) {
|
60
|
|
- modOffset -= 16;
|
61
|
|
- }
|
62
|
|
- return (19 + (16 * modOffset));
|
63
|
|
-}
|
64
|
|
-
|
65
|
|
-void pdex_main_box_species_fill(s8 n, u16 species, bool seen, bool caught) {
|
66
|
|
- seen = true;
|
67
|
|
- s16 y = pdex_get_y_offset(n);
|
68
|
|
- dprintf("trying to print box to y: %d\n", y);
|
69
|
|
- rboxid_fill_rectangle(TB_MAIN, 0, 0, y, 11 * 8, 16);
|
70
|
|
- const pchar *stringToPrint = (seen || caught) ? &pokemon_names[species][0] : &pdex_str_empty[0];
|
71
|
|
- const pchar stringWhitespace[] = {0x0, 0xFF};
|
72
|
|
- fmt_int_10(string_buffer, pokedex_context->cursor_position_top + n, 2, 3);
|
73
|
|
- pstrcat(string_buffer, &stringWhitespace[0]);
|
74
|
|
- pstrcat(string_buffer, stringToPrint);
|
75
|
|
- rboxid_print(TB_MAIN, FONT_DEX_STD, 4, y, &pdex_text_color, 0, string_buffer);
|
76
|
|
-}
|
77
|
|
-
|
78
|
|
-void pdex_update_balls(void) {
|
79
|
|
- for (u8 i = 0; i < 8; ++i) {
|
80
|
|
- if (pdex_lazy_lookup_entry(i + pokedex_context->cursor_position_top)->caught)
|
81
|
|
- OBJID_SHOW(pokedex_context->ball_oams[i]);
|
82
|
|
- else
|
83
|
|
- OBJID_HIDE(pokedex_context->ball_oams[i]);
|
84
|
|
- }
|
85
|
|
-}
|
86
|
|
-
|
87
|
|
-void pdex_update_page_full() {
|
88
|
|
- rboxid_clear_pixels(TB_MAIN, 0);
|
89
|
|
- for (u16 i = pokedex_context->cursor_position_top; i < pokedex_context->cursor_position_top + 8; ++i) {
|
90
|
|
- pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pdex_lazy_lookup_entry(i)->species,
|
91
|
|
- pdex_lazy_lookup_entry(i)->seen, pdex_lazy_lookup_entry(i)->caught);
|
92
|
|
- }
|
93
|
|
- pdex_update_balls();
|
94
|
|
- rboxid_update_tilemap_and_tileset(TB_MAIN);
|
95
|
|
-}
|
96
|
|
-
|
97
|
|
-void pdex_load_sc(void) {
|
98
|
|
- rboxid_clear_pixels(TB_SEEN, 0);
|
99
|
|
- rboxid_clear_pixels(TB_CAUGHT, 0);
|
100
|
|
- u32 seen = pokedex_count(false) + 10;
|
101
|
|
- u32 caught = pokedex_count(true);
|
102
|
|
- pchar seenBuffer[4];
|
103
|
|
- pchar caughtBuffer[4];
|
104
|
|
- fmt_int_10(seenBuffer, seen, 0, MAX3_COUNT_DIGITS(seen));
|
105
|
|
- fmt_int_10(caughtBuffer, caught, 0, MAX3_COUNT_DIGITS(caught));
|
106
|
|
-
|
107
|
|
- u32 twidthSeen = font_get_width_of_string(FONT_DEX_STD, seenBuffer, 0x0000);
|
108
|
|
- u32 twidthCaught = font_get_width_of_string(FONT_DEX_STD, caughtBuffer, 0x0000);
|
109
|
|
-
|
110
|
|
- rboxid_print(TB_SEEN, FONT_DEX_STD, 0, TB_SEEN_Y, &pdex_text_color, 0, &pdex_str_seen[0]);
|
111
|
|
- rboxid_print(TB_CAUGHT, FONT_DEX_STD, 0, TB_CAUGHT_Y, &pdex_text_color, 0, &pdex_str_caught[0]);
|
112
|
|
-
|
113
|
|
- rboxid_print(TB_SEEN, FONT_DEX_STD, TB_STD_RIGHT(twidthSeen,TB_BOT_LEN_PX), TB_SEEN_Y + 1, &pdex_text_color, 0, seenBuffer);
|
114
|
|
- rboxid_print(TB_CAUGHT, FONT_DEX_STD, TB_STD_RIGHT(twidthCaught,TB_BOT_LEN_PX), TB_CAUGHT_Y + 1, &pdex_text_color, 0,
|
115
|
|
- caughtBuffer);
|
116
|
|
-
|
117
|
|
- rboxid_update_tilemap_and_tileset(TB_SEEN);
|
118
|
|
- rboxid_update_tilemap_and_tileset(TB_CAUGHT);
|
119
|
|
-}
|
120
|
|
-
|
121
|
|
-void pdex_pokemon_load(u16 species) {
|
122
|
|
- /* this is very temporary */
|
123
|
|
- rboxid_clear_pixels(TB_PKMN, 0);
|
124
|
|
- u32 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
|
125
|
|
- rboxid_print(TB_PKMN, FONT_DEX_STD, TB_STD_CENTER(twidth,TB_STD_LEN_PX), 3, &pdex_text_color, 0, &pokemon_names[species][0]);
|
126
|
|
- if (pokedex_context->pokemon_oam != -1) {
|
127
|
|
- lz77UnCompVram(pokemon_graphics_front[species].data,
|
128
|
|
- ((void *)(objects[pokedex_context->pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
|
129
|
|
- gpu_pal_apply_compressed(pokemon_palette_normal[species].data,
|
130
|
|
- 16 * (objects[pokedex_context->pokemon_oam].final_oam.palette_num + 16), 32);
|
131
|
|
- } else {
|
132
|
|
- struct SpriteTiles pkmnTiles = {pokemon_graphics_front[species].data, 2048, DEX_PKMN_TAG};
|
133
|
|
- struct SpritePalette pkmnPal = {pokemon_palette_normal[species].data, DEX_PKMN_TAG};
|
134
|
|
- const struct Template pkmnTemplate = {
|
135
|
|
- .tiles_tag = DEX_PKMN_TAG,
|
136
|
|
- .pal_tag = DEX_PKMN_TAG,
|
137
|
|
- .oam = &pdex_oam_pkmn,
|
138
|
|
- .animation = &anim_image_empty,
|
139
|
|
- .graphics = &pkmnTiles,
|
140
|
|
- .rotscale = &rotscale_empty,
|
141
|
|
- .callback = oac_nullsub,
|
142
|
|
- };
|
143
|
|
- gpu_tile_obj_decompress_alloc_tag_and_upload(&pkmnTiles);
|
144
|
|
-
|
145
|
|
- gpu_pal_decompress_alloc_tag_and_upload(&pkmnPal);
|
146
|
|
- pokedex_context->pokemon_oam = (s8)template_instanciate_forward_search(&pkmnTemplate, 10, 10, 0);
|
147
|
|
-
|
148
|
|
- objects[pokedex_context->pokemon_oam].pos1.x = 55;
|
149
|
|
- objects[pokedex_context->pokemon_oam].pos1.y = 76;
|
150
|
|
- }
|
151
|
|
- rboxid_update_tilemap_and_tileset(TB_PKMN);
|
152
|
|
-}
|
153
|
|
-
|
154
|
|
-struct SpriteTiles pdex_ball_tiles = {pdexBallTiles, 128, DEX_BALL_TAG};
|
155
|
|
-struct SpritePalette pdex_ball_pal = {pdexBallPal, DEX_BALL_TAG};
|
156
|
|
-const struct OamData pdex_ball_oam = {
|
157
|
|
- .affine_mode = 0,
|
158
|
|
- .obj_mode = 0,
|
159
|
|
- .mosaic = false,
|
160
|
|
- .shape = 0,
|
161
|
|
- .size = 1,
|
162
|
|
-};
|
163
|
|
-
|
164
|
|
-const struct Template pdex_ball_template = {
|
165
|
|
- .tiles_tag = DEX_BALL_TAG,
|
166
|
|
- .pal_tag = DEX_BALL_TAG,
|
167
|
|
- .oam = &pdex_ball_oam,
|
168
|
|
- .animation = &anim_image_empty,
|
169
|
|
- .graphics = &pdex_ball_tiles,
|
170
|
|
- .rotscale = &rotscale_empty,
|
171
|
|
- .callback = oac_nullsub,
|
172
|
|
-};
|
173
|
|
-
|
174
|
|
-void pdex_pokeballs_init(void) {
|
175
|
|
- gpu_tile_obj_decompress_alloc_tag_and_upload(&pdex_ball_tiles);
|
176
|
|
- gpu_pal_obj_alloc_tag_and_apply(&pdex_ball_pal);
|
177
|
|
- for (u8 i = 0; i < 8; ++i) {
|
178
|
|
- pokedex_context->ball_oams[i] =
|
179
|
|
- template_instanciate_forward_search(&pdex_ball_template, 124, 8 + pdex_y_offset[i], 1);
|
180
|
|
- }
|
181
|
|
-}
|
182
|
|
-
|
183
|
|
-void pdex_oac_cursor_follow(struct Object *obj) { obj->pos1.y = objects[pokedex_context->cursor_main_oam].pos1.y; }
|
184
|
|
-
|
185
|
|
-void pdex_oac_cursor_main(struct Object *obj) {
|
186
|
|
- obj->pos1.y = 13 + pdex_y_offset[pokedex_context->cursor_position_internal];
|
187
|
|
-}
|
188
|
|
-
|
189
|
|
-struct SpriteTiles pdex_cursor_tiles = {pdexSelectHalfTiles, 1024, DEX_CURSOR_TAG};
|
190
|
|
-struct SpritePalette pdex_cursor_pal = {pdexSelectHalfPal, DEX_CURSOR_TAG};
|
191
|
|
-const struct OamData pdex_cursor_oam = {
|
192
|
|
- .affine_mode = 0,
|
193
|
|
- .obj_mode = 0,
|
194
|
|
- .mosaic = false,
|
195
|
|
- .shape = 1,
|
196
|
|
- .size = 3,
|
197
|
|
-};
|
198
|
|
-
|
199
|
|
-const struct Template pdex_ball_main_template = {
|
200
|
|
- .tiles_tag = DEX_CURSOR_TAG,
|
201
|
|
- .pal_tag = DEX_CURSOR_TAG,
|
202
|
|
- .oam = &pdex_cursor_oam,
|
203
|
|
- .animation = &anim_image_empty,
|
204
|
|
- .graphics = &pdex_cursor_tiles,
|
205
|
|
- .rotscale = &rotscale_empty,
|
206
|
|
- .callback = pdex_oac_cursor_main,
|
207
|
|
-};
|
208
|
|
-
|
209
|
|
-const struct Template pdex_ball_follow_template = {
|
210
|
|
- .tiles_tag = DEX_CURSOR_TAG,
|
211
|
|
- .pal_tag = DEX_CURSOR_TAG,
|
212
|
|
- .oam = &pdex_cursor_oam,
|
213
|
|
- .animation = &anim_image_empty,
|
214
|
|
- .graphics = &pdex_cursor_tiles,
|
215
|
|
- .rotscale = &rotscale_empty,
|
216
|
|
- .callback = pdex_oac_cursor_follow,
|
217
|
|
-};
|
218
|
|
-
|
219
|
|
-void pdex_cursor_init(void) {
|
220
|
|
- gpu_tile_obj_decompress_alloc_tag_and_upload(&pdex_cursor_tiles);
|
221
|
|
- gpu_pal_obj_alloc_tag_and_apply(&pdex_cursor_pal);
|
222
|
|
- pokedex_context->cursor_main_oam = template_instanciate_forward_search(&pdex_ball_main_template, 144, 32, 0);
|
223
|
|
- pokedex_context->cursor_follow_oam =
|
224
|
|
- template_instanciate_forward_search(&pdex_ball_follow_template, 144 + 48, 32, 0);
|
225
|
|
- objects[pokedex_context->cursor_follow_oam].final_oam.h_flip = true;
|
226
|
|
-}
|
227
|
|
-
|
228
|
|
-void pdex_oac_scroll_bar(struct Object *obj) {
|
229
|
|
- obj->pos1.y = 23 + (((pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal) * 123) /
|
230
|
|
- PDEX_LAST_SHOWN);
|
231
|
|
-}
|
232
|
|
-
|
233
|
|
-void pdex_oac_arrow(struct Object *obj) {
|
234
|
|
- if (obj->priv[0]) {
|
235
|
|
- // this is the down facing arrow
|
236
|
|
- if (pokedex_context->cursor_position_top + 8 > PDEX_LAST_SHOWN) {
|
237
|
|
- obj->final_oam.palette_num = obj->priv[2];
|
238
|
|
- } else {
|
239
|
|
- obj->final_oam.palette_num = obj->priv[1];
|
240
|
|
- }
|
241
|
|
- } else {
|
242
|
|
- // this is the up facing arrow
|
243
|
|
- if (pokedex_context->cursor_position_top == pokedex_context->first_seen) {
|
244
|
|
- obj->final_oam.palette_num = obj->priv[2];
|
245
|
|
- } else {
|
246
|
|
- obj->final_oam.palette_num = obj->priv[1];
|
247
|
|
- }
|
248
|
|
- }
|
249
|
|
-}
|
250
|
|
-
|
251
|
|
-struct SpriteTiles pdex_scroll_bar_tiles = {pdexScrollBarTiles, 32, DEX_SCROLL_TAG};
|
252
|
|
-struct SpritePalette pdex_scroll_bar_pal = {pdexScrollBarPal, DEX_SCROLL_TAG};
|
253
|
|
-struct SpriteTiles pdex_arrow_tiles = {pdexArrowTiles, 128, DEX_ARROW_TAG};
|
254
|
|
-struct SpritePalette pdex_arrow_pal = {pdexArrowPal, DEX_ARROW_TAG};
|
255
|
|
-struct SpritePalette pdex_arrow_pal_gray = {pdexArrowPal, DEX_ARROW_TAG_EPAL};
|
256
|
|
-
|
257
|
|
-const struct OamData pdex_scroll_bar_oam = {
|
258
|
|
- .affine_mode = 0,
|
259
|
|
- .obj_mode = 0,
|
260
|
|
- .mosaic = false,
|
261
|
|
- .shape = 0,
|
262
|
|
- .size = 0,
|
263
|
|
-};
|
264
|
|
-
|
265
|
|
-const struct OamData pdex_arrow_oam = {
|
266
|
|
- .affine_mode = 0,
|
267
|
|
- .obj_mode = 0,
|
268
|
|
- .mosaic = false,
|
269
|
|
- .shape = 0,
|
270
|
|
- .size = 1,
|
271
|
|
-};
|
272
|
|
-
|
273
|
|
-const struct Template pdex_scroll_bar_template = {
|
274
|
|
- .tiles_tag = DEX_SCROLL_TAG,
|
275
|
|
- .pal_tag = DEX_SCROLL_TAG,
|
276
|
|
- .oam = &pdex_scroll_bar_oam,
|
277
|
|
- .animation = &anim_image_empty,
|
278
|
|
- .graphics = &pdex_scroll_bar_tiles,
|
279
|
|
- .rotscale = &rotscale_empty,
|
280
|
|
- .callback = pdex_oac_scroll_bar,
|
281
|
|
-};
|
282
|
|
-
|
283
|
|
-const struct Template pdex_arrow_template = {
|
284
|
|
- .tiles_tag = DEX_ARROW_TAG,
|
285
|
|
- .pal_tag = DEX_ARROW_TAG,
|
286
|
|
- .oam = &pdex_arrow_oam,
|
287
|
|
- .animation = &anim_image_empty,
|
288
|
|
- .graphics = &pdex_arrow_tiles,
|
289
|
|
- .rotscale = &rotscale_empty,
|
290
|
|
- .callback = pdex_oac_arrow,
|
291
|
|
-};
|
292
|
|
-
|
293
|
|
-void pdex_load_scroll_ui(void) {
|
294
|
|
- gpu_tile_obj_decompress_alloc_tag_and_upload(&pdex_scroll_bar_tiles);
|
295
|
|
- gpu_tile_obj_decompress_alloc_tag_and_upload(&pdex_arrow_tiles);
|
296
|
|
- gpu_pal_obj_alloc_tag_and_apply(&pdex_scroll_bar_pal);
|
297
|
|
- u8 normalPal = gpu_pal_obj_alloc_tag_and_apply(&pdex_arrow_pal);
|
298
|
|
- u8 grayPal = gpu_pal_obj_alloc_tag_and_apply(&pdex_arrow_pal_gray);
|
299
|
|
- tint_palette_gray(&palette_bg_unfaded[16 * (16 + grayPal)], 16);
|
300
|
|
- (void)template_instanciate_forward_search(&pdex_scroll_bar_template, 233, 23, 0);
|
301
|
|
- u8 upArrow = template_instanciate_forward_search(&pdex_arrow_template, 232, 19, 0);
|
302
|
|
- u8 downArrow = template_instanciate_forward_search(&pdex_arrow_template, 232, 150, 0);
|
303
|
|
- objects[downArrow].priv[0] = true;
|
304
|
|
- objects[downArrow].final_oam.v_flip = true;
|
305
|
|
- objects[upArrow].priv[1] = normalPal;
|
306
|
|
- objects[downArrow].priv[1] = normalPal;
|
307
|
|
- objects[upArrow].priv[2] = grayPal;
|
308
|
|
- objects[downArrow].priv[2] = grayPal;
|
309
|
|
-}
|
310
|
|
-
|
311
|
|
-void pdex_data_setup(void) {
|
312
|
|
- pokedex_context->first_seen = 1;
|
313
|
|
-}
|
314
|
|
-
|
315
|
|
-void pdex_hardware_scroll(bool up) {
|
316
|
|
- if (up) {
|
317
|
|
- if (pokedex_context->hardware_scroll_amount > -15) {
|
318
|
|
- bgid_mod_y_offset(1, -(16 << 8), 1);
|
319
|
|
- pokedex_context->hardware_scroll_amount--;
|
320
|
|
- } else {
|
321
|
|
- pokedex_context->hardware_scroll_amount = 0;
|
322
|
|
- bgid_mod_y_offset(1, 0, 0);
|
323
|
|
- }
|
324
|
|
- } else {
|
325
|
|
-
|
326
|
|
- if (pokedex_context->hardware_scroll_amount < 15) {
|
327
|
|
- bgid_mod_y_offset(1, 16 << 8, 1);
|
328
|
|
- pokedex_context->hardware_scroll_amount++;
|
329
|
|
- } else {
|
330
|
|
- pokedex_context->hardware_scroll_amount = 0;
|
331
|
|
- bgid_mod_y_offset(1, 0, 0);
|
332
|
|
- }
|
333
|
|
- }
|
334
|
|
-}
|
335
|
|
-
|
336
|
|
-void pdex_fill_previous_slot(void) {
|
337
|
|
- u16 pIndex = pokedex_context->cursor_position_top - 1;
|
338
|
|
- pdex_main_box_species_fill(-1, pdex_lazy_lookup_entry(pIndex)->species, pdex_lazy_lookup_entry(pIndex)->seen,
|
339
|
|
- pdex_lazy_lookup_entry(pIndex)->caught);
|
340
|
|
-}
|
341
|
|
-
|
342
|
|
-void pdex_fill_next_slot(void) {
|
343
|
|
- u16 pIndex = pokedex_context->cursor_position_top + 8;
|
344
|
|
- pdex_main_box_species_fill(8, pdex_lazy_lookup_entry(pIndex)->species, pdex_lazy_lookup_entry(pIndex)->seen,
|
345
|
|
- pdex_lazy_lookup_entry(pIndex)->caught);
|
346
|
|
-}
|
347
|
|
-
|
348
|
|
-void pdex_try_advance(u8 reverse) {
|
349
|
|
- if (reverse) {
|
350
|
|
- if (pokedex_context->cursor_position_internal > 0) {
|
351
|
|
- pokedex_context->cursor_position_internal--;
|
352
|
|
- m4aSongNumStart(600);
|
353
|
|
- } else if ((pokedex_context->cursor_position_top) > (pokedex_context->first_seen)) {
|
354
|
|
- pdex_fill_previous_slot();
|
355
|
|
- pokedex_context->cursor_position_top--;
|
356
|
|
- pdex_hardware_scroll(true);
|
357
|
|
- m4aSongNumStart(600);
|
358
|
|
- }
|
359
|
|
- } else {
|
360
|
|
- if (pokedex_context->cursor_position_internal < 7) {
|
361
|
|
- pokedex_context->cursor_position_internal++;
|
362
|
|
- m4aSongNumStart(600);
|
363
|
|
- } else if (pokedex_context->cursor_position_top < (PDEX_LAST_SHOWN - 7)) {
|
364
|
|
- pdex_fill_next_slot();
|
365
|
|
- pokedex_context->cursor_position_top++;
|
366
|
|
- pdex_hardware_scroll(false);
|
367
|
|
- m4aSongNumStart(600);
|
368
|
|
- }
|
369
|
|
- }
|
370
|
|
-
|
371
|
|
- u16 pkIndexToLoad = pokedex_context->cursor_position_internal + pokedex_context->cursor_position_top;
|
372
|
|
- if (pdex_lazy_lookup_entry(pkIndexToLoad)->seen || pdex_lazy_lookup_entry(pkIndexToLoad)->caught)
|
373
|
|
- pdex_pokemon_load(pdex_lazy_lookup_entry(pkIndexToLoad)->species);
|
374
|
|
- else
|
375
|
|
- pdex_pokemon_load(pdex_lazy_lookup_entry(pkIndexToLoad)->species); /* debug, just display the mofo */
|
376
|
|
- pdex_update_balls();
|
377
|
|
-}
|
378
|
|
-
|
379
|
|
-void pdex_loop(u8 tid) {
|
380
|
|
- switch (pokedex_context->state) {
|
381
|
|
- case 0:
|
382
|
|
- pokedex_context->state++;
|
383
|
|
- break;
|
384
|
|
- case 1:
|
385
|
|
- for (u8 i = 0; i < 4; ++i)
|
386
|
|
- bgid_send_tilemap(i);
|
387
|
|
- rboxid_clear_pixels(TB_TITLE, 0);
|
388
|
|
- rboxid_print(TB_TITLE, FONT_DEX_STD, 0, 0, &pdex_text_color, 0, &pdex_str_title[0]);
|
389
|
|
- rboxid_update_tilemap_and_tileset(TB_TITLE);
|
390
|
|
-
|
391
|
|
- pdex_data_setup();
|
392
|
|
- pdex_cursor_init();
|
393
|
|
-
|
394
|
|
- pdex_pokeballs_init();
|
395
|
|
- pdex_load_scroll_ui();
|
396
|
|
- pdex_pokemon_load(pdex_lazy_lookup_entry(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal)->species);
|
397
|
|
- pdex_load_sc();
|
398
|
|
- pdex_update_page_full();
|
399
|
|
-
|
400
|
|
- palette_bg_faded_fill_black();
|
401
|
|
- pokedex_context->state++;
|
402
|
|
- break;
|
403
|
|
- case 2:
|
404
|
|
- gpu_sync_bg_show(0);
|
405
|
|
- gpu_sync_bg_show(1);
|
406
|
|
- gpu_sync_bg_hide(3);
|
407
|
|
-
|
408
|
|
- gpu_sync_bg_show(2);
|
409
|
|
- fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 16, 0, 0x0000);
|
410
|
|
- pokedex_context->state++;
|
411
|
|
-
|
412
|
|
- break;
|
413
|
|
- case 3:
|
414
|
|
- if (!pal_fade_control.active)
|
415
|
|
- pokedex_context->state++;
|
416
|
|
- break;
|
417
|
|
- case 4:
|
418
|
|
- /* main control */
|
419
|
|
- if(super.buttons_new & KEY_A)
|
420
|
|
- {
|
421
|
|
- pokedex_context->state = 15;
|
422
|
|
- m4aSongNumStart(5);
|
423
|
|
- }
|
424
|
|
- if (super.buttons_new & KEY_B) {
|
425
|
|
- pokedex_context->state = 10;
|
426
|
|
- m4aSongNumStart(601);
|
427
|
|
- }
|
428
|
|
- if ((super.buttons_new & KEY_DOWN) || (super.buttons_held & KEY_DOWN)) {
|
429
|
|
- pdex_try_advance(false);
|
430
|
|
- }
|
431
|
|
- if ((super.buttons_new & KEY_UP) || (super.buttons_held & KEY_UP)) {
|
432
|
|
- pdex_try_advance(true);
|
433
|
|
- }
|
434
|
|
- break;
|
435
|
|
- case 10:
|
436
|
|
- /* control flow exit */
|
437
|
|
- fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x000);
|
438
|
|
- pokedex_context->state++;
|
439
|
|
- break;
|
440
|
|
- case 11:
|
441
|
|
- if (!pal_fade_control.active) {
|
442
|
|
- task_del(tid);
|
443
|
|
- pdex_vram_free_bgmaps();
|
444
|
|
- pdex_free_memory();
|
445
|
|
- void region_select_load(void);
|
446
|
|
- set_callback2(region_select_load);
|
447
|
|
- }
|
448
|
|
- break;
|
449
|
|
- case 15:
|
450
|
|
- /* load the detail screen */
|
451
|
|
- fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
|
452
|
|
- pokedex_context->state++;
|
453
|
|
- break;
|
454
|
|
- case 16:
|
455
|
|
- if(!pal_fade_control.active)
|
456
|
|
- {
|
457
|
|
- pdex_vram_free_bgmaps();
|
458
|
|
- task_del(tid);
|
459
|
|
- void dexdetail_load(void);
|
460
|
|
- set_callback2(dexdetail_load);
|
461
|
|
- }
|
462
|
|
- default:
|
463
|
|
- break;
|
464
|
|
- }
|
465
|
|
-}
|
466
|
|
-
|
467
|
|
-void pdex_load_gfx(void) {
|
468
|
|
- /*TODO: setup text boxes here */
|
469
|
|
- rbox_init_from_templates(&pdex_boxes[0]);
|
470
|
|
-
|
471
|
|
- lz77UnCompVram(pdexBgTiles, (void *)0x0600C000);
|
472
|
|
- LZ77UnCompWram(pdexBgMap, bgid_get_tilemap(2));
|
473
|
|
- gpu_pal_apply_compressed(pdexBgPal, 0, 32);
|
474
|
|
- gpu_pal_apply(pdex_text_pal, 15 * 16, 32);
|
475
|
|
-
|
476
|
|
- /*setup window*/
|
477
|
|
- lcd_io_set(REG_ID_WIN0H, (128 << 8) | (216));
|
478
|
|
- lcd_io_set(REG_ID_WIN0V, ((20 << 8) | (148)));
|
479
|
|
- lcd_io_set(REG_ID_WININ, WIN_BG0 | WIN_BG1 | WIN_BG2 | WIN_BG3 | WIN_OBJ);
|
480
|
|
- lcd_io_set(REG_ID_WINOUT, WIN_BG0 | WIN_BG2 | WIN_BG3 | WIN_OBJ);
|
481
|
|
- bgid_mark_for_sync(0);
|
482
|
|
-}
|
483
|
|
-
|
484
|
|
-void pdex_load(void) {
|
485
|
|
-
|
486
|
|
- pdex_vram_setup();
|
487
|
|
- pdex_load_gfx();
|
488
|
|
-
|
489
|
|
- pokedex_context->pokemon_oam = -1;
|
490
|
|
- pokedex_context->state = 0;
|
491
|
|
- pokedex_context->hardware_scroll_amount = 0;
|
492
|
|
- task_add(pdex_loop, 0);
|
493
|
|
- set_callback2(pdex_cb_handler);
|
494
|
|
-}
|