|
@@ -112,37 +112,50 @@ const struct BgConfig pdex_bg_config[4] = {
|
112
|
112
|
},
|
113
|
113
|
};
|
114
|
114
|
|
115
|
|
-u16 pdex_get_y_offset(s8 n) {
|
|
115
|
+s16 pdex_get_y_offset(s8 n) {
|
116
|
116
|
s8 modOffset = n + pokedex_context->hardware_scroll_amount;
|
117
|
|
- if (modOffset < -1)
|
118
|
|
- modOffset += 8;
|
119
|
|
- if (modOffset > 15)
|
120
|
|
- modOffset -= 8;
|
121
|
|
- return 19 + (15 * modOffset);
|
|
117
|
+ s8 wrapOffset = 0;
|
|
118
|
+ dprintf("mod_offset: %d\n", modOffset);
|
|
119
|
+ if (modOffset < -1) {
|
|
120
|
+ modOffset += 17;
|
|
121
|
+ wrapOffset = 1;
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ if (modOffset > 15) {
|
|
125
|
+ wrapOffset = -1;
|
|
126
|
+ modOffset -= 17;
|
|
127
|
+ }
|
|
128
|
+ return (19 + (15 * modOffset)) + wrapOffset + (pokedex_context->overdo_amount);
|
122
|
129
|
}
|
123
|
130
|
|
124
|
131
|
void pdex_main_box_species_fill(s8 n, u16 species, bool seen, bool caught) {
|
|
132
|
+ s16 y = pdex_get_y_offset(n);
|
|
133
|
+ dprintf("trying to print box to y: %d\n", y);
|
|
134
|
+ rboxid_fill_rectangle(TB_MAIN, 0, 0, y, 11 * 8, 15);
|
125
|
135
|
const pchar *stringToPrint = (seen || caught) ? &pokemon_names[species][0] : &pdex_str_empty[0];
|
126
|
136
|
const pchar stringWhitespace[] = {0x0, 0xFF};
|
127
|
137
|
fmt_int_10(string_buffer, pokedex_context->cursor_position_top + n, 2, 3);
|
128
|
138
|
pstrcat(string_buffer, &stringWhitespace[0]);
|
129
|
139
|
pstrcat(string_buffer, stringToPrint);
|
130
|
|
- rboxid_print(TB_MAIN, FONT_DEX_STD, 4, pdex_get_y_offset(n), &pdex_text_color, 0, string_buffer);
|
131
|
|
- // show the pokéball if necessary
|
|
140
|
+ rboxid_print(TB_MAIN, FONT_DEX_STD, 4, y, &pdex_text_color, 0, string_buffer);
|
132
|
141
|
}
|
133
|
142
|
|
134
|
|
-void pdex_update_page_full() {
|
135
|
|
- rboxid_clear_pixels(TB_MAIN, 0);
|
136
|
|
- for (s8 i = pokedex_context->cursor_position_top - 1; i < pokedex_context->cursor_position_top + 9 + 7; ++i) {
|
137
|
|
- pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pokedex_context->lookup[i].species,
|
138
|
|
- pokedex_context->lookup[i].seen, pokedex_context->lookup[i].caught);
|
139
|
|
- }
|
|
143
|
+void pdex_update_balls(void) {
|
140
|
144
|
for (u8 i = 0; i < 9; ++i) {
|
141
|
145
|
if (pokedex_context->lookup[i + pokedex_context->cursor_position_top].caught)
|
142
|
146
|
OBJID_SHOW(pokedex_context->ball_oams[i]);
|
143
|
147
|
else
|
144
|
148
|
OBJID_HIDE(pokedex_context->ball_oams[i]);
|
145
|
149
|
}
|
|
150
|
+}
|
|
151
|
+
|
|
152
|
+void pdex_update_page_full() {
|
|
153
|
+ rboxid_clear_pixels(TB_MAIN, 0);
|
|
154
|
+ for (s8 i = pokedex_context->cursor_position_top; i < pokedex_context->cursor_position_top + 9; ++i) {
|
|
155
|
+ pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pokedex_context->lookup[i].species,
|
|
156
|
+ pokedex_context->lookup[i].seen, pokedex_context->lookup[i].caught);
|
|
157
|
+ }
|
|
158
|
+ pdex_update_balls();
|
146
|
159
|
rboxid_update_tilemap_and_tileset(TB_MAIN);
|
147
|
160
|
}
|
148
|
161
|
|
|
@@ -306,59 +319,69 @@ void pdex_data_setup(void) {
|
306
|
319
|
|
307
|
320
|
void pdex_hardware_scroll(bool up) {
|
308
|
321
|
/* somewhat hacky wraparound scrolling, works though */
|
|
322
|
+ /* TODO: Fix the one pixel off */
|
309
|
323
|
if (up) {
|
310
|
324
|
if (pokedex_context->hardware_scroll_amount > -16) {
|
311
|
|
- if (pokedex_context->hardware_scroll_amount != -8) {
|
312
|
|
- bgid_mod_y_offset(1, -3840, 1);
|
313
|
|
-
|
314
|
|
- } else {
|
315
|
|
- bgid_mod_y_offset(1, -4096, 1);
|
316
|
|
- }
|
|
325
|
+ bgid_mod_y_offset(1, -(15 << 8), 1);
|
317
|
326
|
pokedex_context->hardware_scroll_amount--;
|
318
|
327
|
} else {
|
319
|
328
|
pokedex_context->hardware_scroll_amount = 0;
|
|
329
|
+ // pokedex_context->overdo_amount++;
|
320
|
330
|
bgid_mod_y_offset(1, 0, 0);
|
|
331
|
+ bgid_mod_y_offset(1, (256 * pokedex_context->overdo_amount), 1);
|
321
|
332
|
}
|
322
|
333
|
} else {
|
|
334
|
+
|
323
|
335
|
if (pokedex_context->hardware_scroll_amount < 16) {
|
324
|
|
- if (pokedex_context->hardware_scroll_amount != 8) {
|
325
|
|
- bgid_mod_y_offset(1, 3840, 1);
|
326
|
|
- } else {
|
327
|
|
- bgid_mod_y_offset(1, 4096, 1);
|
328
|
|
- }
|
|
336
|
+ bgid_mod_y_offset(1, 15 << 8, 1);
|
329
|
337
|
pokedex_context->hardware_scroll_amount++;
|
330
|
338
|
} else {
|
331
|
339
|
pokedex_context->hardware_scroll_amount = 0;
|
|
340
|
+ // pokedex_context->overdo_amount--;
|
332
|
341
|
bgid_mod_y_offset(1, 0, 0);
|
|
342
|
+ bgid_mod_y_offset(1, (256 * pokedex_context->overdo_amount), 1);
|
333
|
343
|
}
|
334
|
344
|
}
|
335
|
345
|
}
|
336
|
346
|
|
|
347
|
+void pdex_fill_previous_slot(void) {
|
|
348
|
+ u16 pIndex = pokedex_context->cursor_position_top - 1;
|
|
349
|
+ pdex_main_box_species_fill(-1, pokedex_context->lookup[pIndex].species, pokedex_context->lookup[pIndex].seen,
|
|
350
|
+ pokedex_context->lookup[pIndex].caught);
|
|
351
|
+}
|
|
352
|
+
|
|
353
|
+void pdex_fill_next_slot(void) {
|
|
354
|
+ u16 pIndex = pokedex_context->cursor_position_top + 9;
|
|
355
|
+ pdex_main_box_species_fill(9, pokedex_context->lookup[pIndex].species, pokedex_context->lookup[pIndex].seen,
|
|
356
|
+ pokedex_context->lookup[pIndex].caught);
|
|
357
|
+}
|
|
358
|
+
|
337
|
359
|
void pdex_try_advance(u8 reverse) {
|
338
|
|
- bool dirty = false;
|
339
|
360
|
if (reverse) {
|
340
|
361
|
if (pokedex_context->cursor_position_internal > 0) {
|
341
|
362
|
pokedex_context->cursor_position_internal--;
|
342
|
363
|
} else if ((pokedex_context->cursor_position_top) > (pokedex_context->first_seen)) {
|
|
364
|
+ pdex_fill_previous_slot();
|
343
|
365
|
pokedex_context->cursor_position_top--;
|
344
|
|
- dirty = true;
|
|
366
|
+
|
|
367
|
+ pdex_hardware_scroll(true);
|
345
|
368
|
}
|
346
|
369
|
} else {
|
347
|
370
|
if (pokedex_context->cursor_position_internal < 8) {
|
348
|
371
|
pokedex_context->cursor_position_internal++;
|
349
|
372
|
} else if (pokedex_context->cursor_position_top < (PDEX_LAST_SHOWN - 8)) {
|
|
373
|
+ pdex_fill_next_slot();
|
350
|
374
|
pokedex_context->cursor_position_top++;
|
351
|
|
- dirty = true;
|
|
375
|
+ pdex_hardware_scroll(false);
|
352
|
376
|
}
|
353
|
377
|
}
|
354
|
|
- if (dirty) {
|
355
|
|
- pdex_update_page_full();
|
356
|
|
- }
|
|
378
|
+
|
357
|
379
|
u16 pkIndexToLoad = pokedex_context->cursor_position_internal + pokedex_context->cursor_position_top;
|
358
|
380
|
if (pokedex_context->lookup[pkIndexToLoad].seen || pokedex_context->lookup[pkIndexToLoad].caught)
|
359
|
381
|
pdex_pokemon_load(pokedex_context->lookup[pkIndexToLoad].species);
|
360
|
382
|
else
|
361
|
383
|
pdex_pokemon_load(0);
|
|
384
|
+ pdex_update_balls();
|
362
|
385
|
}
|
363
|
386
|
|
364
|
387
|
void pdex_loop(u8 tid) {
|
|
@@ -396,15 +419,29 @@ void pdex_loop(u8 tid) {
|
396
|
419
|
|
397
|
420
|
break;
|
398
|
421
|
case 3:
|
399
|
|
- if ((super.buttons_new & KEY_DOWN)) {
|
|
422
|
+ if ((super.buttons_held & KEY_DOWN)) {
|
|
423
|
+ pokedex_context->held_frames++;
|
|
424
|
+ if (pokedex_context->held_frames == 10) {
|
400
|
425
|
pdex_try_advance(false);
|
401
|
|
- } else if ((super.buttons_new & KEY_UP)) {
|
|
426
|
+ pokedex_context->held_frames = 0;
|
|
427
|
+ }
|
|
428
|
+ } else if ((super.buttons_held & KEY_UP)) {
|
|
429
|
+ pokedex_context->held_frames++;
|
|
430
|
+ if (pokedex_context->held_frames == 10) {
|
402
|
431
|
pdex_try_advance(true);
|
|
432
|
+ pokedex_context->held_frames = 0;
|
403
|
433
|
}
|
404
|
|
- break;
|
405
|
|
- default:
|
406
|
|
- break;
|
|
434
|
+ } else if ((super.buttons_new & KEY_DOWN)) {
|
|
435
|
+ pokedex_context->held_frames = 0;
|
|
436
|
+ pdex_try_advance(false);
|
|
437
|
+ } else if ((super.buttons_new & KEY_UP)) {
|
|
438
|
+ pokedex_context->held_frames = 0;
|
|
439
|
+ pdex_try_advance(true);
|
407
|
440
|
}
|
|
441
|
+ break;
|
|
442
|
+default:
|
|
443
|
+ break;
|
|
444
|
+}
|
408
|
445
|
}
|
409
|
446
|
|
410
|
447
|
bool sm_pdex_init(void) {
|