Browse Source

Merge branch 'master' of github.com:SBird1337/source_of_the_sovereign

Michael 7 years ago
parent
commit
e79f236407
2 changed files with 45 additions and 20 deletions
  1. 1
    1
      g3headers
  2. 44
    19
      src/pokedex/pokedex.c

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit e0402c99b51968537abb0f09ed017558e2055385
1
+Subproject commit 98ab5bcce4025410bc8ba8ffac90c12480dffeb2

+ 44
- 19
src/pokedex/pokedex.c View File

@@ -9,9 +9,6 @@
9 9
 
10 10
 #include "pokedex_common.h"
11 11
 
12
-
13
-
14
-
15 12
 #define TB_TITLE 0
16 13
 #define TB_PKMN 1
17 14
 #define TB_SEEN 2
@@ -23,6 +20,7 @@
23 20
 
24 21
 #define DEX_SCROLL_MIN 23
25 22
 #define DEX_SCROLL_MAX 146
23
+#define SCROLL_SPEED_MAX 6
26 24
 
27 25
 void pdex_load(void);
28 26
 void pdex_vblank_handler(void);
@@ -35,6 +33,7 @@ extern const pchar pdex_str_caught[];
35 33
 extern const pchar pdex_str_empty[];
36 34
 
37 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};
38 37
 
39 38
 struct TextboxTemplate pdex_boxes[] = {
40 39
     {.bg_id = 0, .x = 11, .y = 0, .width = 10, .height = 2, .pal_id = 15, .charbase = 1},
@@ -47,8 +46,6 @@ struct TextboxTemplate pdex_boxes[] = {
47 46
     {.bg_id = 0xFF},
48 47
 };
49 48
 
50
-
51
-
52 49
 s16 pdex_get_y_offset(s8 n) {
53 50
     s8 modOffset = n + pokedex_context->hardware_scroll_amount;
54 51
     dprintf("mod_offset: %d\n", modOffset);
@@ -110,9 +107,10 @@ void pdex_load_sc(void) {
110 107
     rboxid_print(TB_SEEN, FONT_DEX_STD, 0, TB_SEEN_Y, &pdex_text_color, 0, &pdex_str_seen[0]);
111 108
     rboxid_print(TB_CAUGHT, FONT_DEX_STD, 0, TB_CAUGHT_Y, &pdex_text_color, 0, &pdex_str_caught[0]);
112 109
 
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);
110
+    rboxid_print(TB_SEEN, FONT_DEX_STD, TB_STD_RIGHT(twidthSeen, TB_BOT_LEN_PX), TB_SEEN_Y + 1, &pdex_text_color, 0,
111
+                 seenBuffer);
112
+    rboxid_print(TB_CAUGHT, FONT_DEX_STD, TB_STD_RIGHT(twidthCaught, TB_BOT_LEN_PX), TB_CAUGHT_Y + 1, &pdex_text_color,
113
+                 0, caughtBuffer);
116 114
 
117 115
     rboxid_update_tilemap_and_tileset(TB_SEEN);
118 116
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
@@ -122,7 +120,8 @@ void pdex_pokemon_load(u16 species) {
122 120
     /* this is very temporary */
123 121
     rboxid_clear_pixels(TB_PKMN, 0);
124 122
     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]);
123
+    rboxid_print(TB_PKMN, FONT_DEX_STD, TB_STD_CENTER(twidth, TB_STD_LEN_PX), 3, &pdex_text_color, 0,
124
+                 &pokemon_names[species][0]);
126 125
     if (pokedex_context->pokemon_oam != -1) {
127 126
         lz77UnCompVram(pokemon_graphics_front[species].data,
128 127
                        ((void *)(objects[pokedex_context->pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
@@ -308,9 +307,7 @@ void pdex_load_scroll_ui(void) {
308 307
     objects[downArrow].priv[2] = grayPal;
309 308
 }
310 309
 
311
-void pdex_data_setup(void) {
312
-    pokedex_context->first_seen = 1;
313
-}
310
+void pdex_data_setup(void) { pokedex_context->first_seen = 1; }
314 311
 
315 312
 void pdex_hardware_scroll(bool up) {
316 313
     if (up) {
@@ -393,7 +390,9 @@ void pdex_loop(u8 tid) {
393 390
 
394 391
         pdex_pokeballs_init();
395 392
         pdex_load_scroll_ui();
396
-        pdex_pokemon_load(pdex_lazy_lookup_entry(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal)->species);
393
+        pdex_pokemon_load(
394
+            pdex_lazy_lookup_entry(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal)
395
+                ->species);
397 396
         pdex_load_sc();
398 397
         pdex_update_page_full();
399 398
 
@@ -416,8 +415,7 @@ void pdex_loop(u8 tid) {
416 415
         break;
417 416
     case 4:
418 417
         /* main control */
419
-        if(super.buttons_new & KEY_A)
420
-        {
418
+        if (super.buttons_new & KEY_A) {
421 419
             pokedex_context->state = 15;
422 420
             m4aSongNumStart(5);
423 421
         }
@@ -425,11 +423,39 @@ void pdex_loop(u8 tid) {
425 423
             pokedex_context->state = 10;
426 424
             m4aSongNumStart(601);
427 425
         }
428
-        if ((super.buttons_new & KEY_DOWN) || (super.buttons_held & KEY_DOWN)) {
426
+        if ((super.buttons_new & KEY_DOWN)) {
429 427
             pdex_try_advance(false);
428
+            pokedex_context->scroll_speed = 0;
429
+            pokedex_context->delay_count = 0;
430
+        } else if (super.buttons_held & KEY_DOWN) {
431
+            if (pokedex_context->scroll_speed < SCROLL_SPEED_MAX) {
432
+                if (pokedex_context->delay_count >= scroll_speed_delays[pokedex_context->scroll_speed]) {
433
+                    pdex_try_advance(false);
434
+                    pokedex_context->delay_count = 0;
435
+                    pokedex_context->scroll_speed++;
436
+                } else {
437
+                    pokedex_context->delay_count++;
438
+                }
439
+            } else {
440
+                pdex_try_advance(false);
441
+            }
430 442
         }
431
-        if ((super.buttons_new & KEY_UP) || (super.buttons_held & KEY_UP)) {
443
+        if ((super.buttons_new & KEY_UP)) {
432 444
             pdex_try_advance(true);
445
+            pokedex_context->scroll_speed = 0;
446
+            pokedex_context->delay_count = 0;
447
+        } else if (super.buttons_held & KEY_UP) {
448
+            if (pokedex_context->scroll_speed < SCROLL_SPEED_MAX) {
449
+                if (pokedex_context->delay_count >= scroll_speed_delays[pokedex_context->scroll_speed]) {
450
+                    pdex_try_advance(true);
451
+                    pokedex_context->delay_count = 0;
452
+                    pokedex_context->scroll_speed++;
453
+                } else {
454
+                    pokedex_context->delay_count++;
455
+                }
456
+            } else {
457
+                pdex_try_advance(true);
458
+            }
433 459
         }
434 460
         break;
435 461
     case 10:
@@ -452,8 +478,7 @@ void pdex_loop(u8 tid) {
452 478
         pokedex_context->state++;
453 479
         break;
454 480
     case 16:
455
-        if(!pal_fade_control.active)
456
-        {
481
+        if (!pal_fade_control.active) {
457 482
             pdex_vram_free_bgmaps();
458 483
             task_del(tid);
459 484
             void dexdetail_load(void);