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
-Subproject commit e0402c99b51968537abb0f09ed017558e2055385
1
+Subproject commit 98ab5bcce4025410bc8ba8ffac90c12480dffeb2

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

9
 
9
 
10
 #include "pokedex_common.h"
10
 #include "pokedex_common.h"
11
 
11
 
12
-
13
-
14
-
15
 #define TB_TITLE 0
12
 #define TB_TITLE 0
16
 #define TB_PKMN 1
13
 #define TB_PKMN 1
17
 #define TB_SEEN 2
14
 #define TB_SEEN 2
23
 
20
 
24
 #define DEX_SCROLL_MIN 23
21
 #define DEX_SCROLL_MIN 23
25
 #define DEX_SCROLL_MAX 146
22
 #define DEX_SCROLL_MAX 146
23
+#define SCROLL_SPEED_MAX 6
26
 
24
 
27
 void pdex_load(void);
25
 void pdex_load(void);
28
 void pdex_vblank_handler(void);
26
 void pdex_vblank_handler(void);
35
 extern const pchar pdex_str_empty[];
33
 extern const pchar pdex_str_empty[];
36
 
34
 
37
 static const u8 pdex_y_offset[] = {19, 35, 51, 67, 83, 99, 115, 131};
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
 struct TextboxTemplate pdex_boxes[] = {
38
 struct TextboxTemplate pdex_boxes[] = {
40
     {.bg_id = 0, .x = 11, .y = 0, .width = 10, .height = 2, .pal_id = 15, .charbase = 1},
39
     {.bg_id = 0, .x = 11, .y = 0, .width = 10, .height = 2, .pal_id = 15, .charbase = 1},
47
     {.bg_id = 0xFF},
46
     {.bg_id = 0xFF},
48
 };
47
 };
49
 
48
 
50
-
51
-
52
 s16 pdex_get_y_offset(s8 n) {
49
 s16 pdex_get_y_offset(s8 n) {
53
     s8 modOffset = n + pokedex_context->hardware_scroll_amount;
50
     s8 modOffset = n + pokedex_context->hardware_scroll_amount;
54
     dprintf("mod_offset: %d\n", modOffset);
51
     dprintf("mod_offset: %d\n", modOffset);
110
     rboxid_print(TB_SEEN, FONT_DEX_STD, 0, TB_SEEN_Y, &pdex_text_color, 0, &pdex_str_seen[0]);
107
     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]);
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
     rboxid_update_tilemap_and_tileset(TB_SEEN);
115
     rboxid_update_tilemap_and_tileset(TB_SEEN);
118
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
116
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
122
     /* this is very temporary */
120
     /* this is very temporary */
123
     rboxid_clear_pixels(TB_PKMN, 0);
121
     rboxid_clear_pixels(TB_PKMN, 0);
124
     u32 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
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
     if (pokedex_context->pokemon_oam != -1) {
125
     if (pokedex_context->pokemon_oam != -1) {
127
         lz77UnCompVram(pokemon_graphics_front[species].data,
126
         lz77UnCompVram(pokemon_graphics_front[species].data,
128
                        ((void *)(objects[pokedex_context->pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
127
                        ((void *)(objects[pokedex_context->pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
308
     objects[downArrow].priv[2] = grayPal;
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
 void pdex_hardware_scroll(bool up) {
312
 void pdex_hardware_scroll(bool up) {
316
     if (up) {
313
     if (up) {
393
 
390
 
394
         pdex_pokeballs_init();
391
         pdex_pokeballs_init();
395
         pdex_load_scroll_ui();
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
         pdex_load_sc();
396
         pdex_load_sc();
398
         pdex_update_page_full();
397
         pdex_update_page_full();
399
 
398
 
416
         break;
415
         break;
417
     case 4:
416
     case 4:
418
         /* main control */
417
         /* main control */
419
-        if(super.buttons_new & KEY_A)
420
-        {
418
+        if (super.buttons_new & KEY_A) {
421
             pokedex_context->state = 15;
419
             pokedex_context->state = 15;
422
             m4aSongNumStart(5);
420
             m4aSongNumStart(5);
423
         }
421
         }
425
             pokedex_context->state = 10;
423
             pokedex_context->state = 10;
426
             m4aSongNumStart(601);
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
             pdex_try_advance(false);
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
             pdex_try_advance(true);
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
         break;
460
         break;
435
     case 10:
461
     case 10:
452
         pokedex_context->state++;
478
         pokedex_context->state++;
453
         break;
479
         break;
454
     case 16:
480
     case 16:
455
-        if(!pal_fade_control.active)
456
-        {
481
+        if (!pal_fade_control.active) {
457
             pdex_vram_free_bgmaps();
482
             pdex_vram_free_bgmaps();
458
             task_del(tid);
483
             task_del(tid);
459
             void dexdetail_load(void);
484
             void dexdetail_load(void);