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