DragonflySotS 6 년 전
부모
커밋
4d43d2d66d
4개의 변경된 파일82개의 추가작업 그리고 37개의 파일을 삭제
  1. 1
    1
      g3headers
  2. 76
    33
      src/pokedex/pokedex.c
  3. 3
    1
      src/pokedex/pokedex_common.h
  4. 2
    2
      src/pokedex/pokedex_detail.c

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 2f9b41afbceba16f5270691c2b7531529853efb5
1
+Subproject commit 9f790f1f0ac16ed8f80556e8f74e824836fc1950

+ 76
- 33
src/pokedex/pokedex.c 파일 보기

@@ -33,7 +33,7 @@ extern const pchar pdex_str_caught[];
33 33
 extern const pchar pdex_str_empty[];
34 34
 
35 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};
36
+static const u16 scroll_speed_delays[] = {20, 20, 20, 20, 10, 5, 0};
37 37
 
38 38
 struct TextboxTemplate pdex_boxes[] = {
39 39
     {.bg_id = 0, .x = 11, .y = 0, .width = 10, .height = 2, .pal_id = 15, .charbase = 1},
@@ -113,6 +113,35 @@ void pdex_load_sc(void) {
113 113
     rboxid_update_tilemap_and_tileset(TB_SEEN);
114 114
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
115 115
 }
116
+void pdex_pokemon_oam_update(u16 species, s8 objid) {
117
+    gpu_pal_apply_compressed(pokemon_palette_normal[species].data, 16 * (objects[objid].final_oam.palette_num + 16),
118
+                             32);
119
+    lz77UnCompVram(pokemon_graphics_front[species].data,
120
+                   ((void *)(objects[objid].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
121
+}
122
+
123
+s8 pdex_pokemon_oam_load(u16 species, u16 tag) {
124
+    struct SpriteTiles pkmnTiles = {pokemon_graphics_front[species].data, 2048, tag};
125
+    struct SpritePalette pkmnPal = {pokemon_palette_normal[species].data, tag};
126
+    const struct Template pkmnTemplate = {
127
+        .tiles_tag = tag,
128
+        .pal_tag = tag,
129
+        .oam = &pdex_oam_pkmn,
130
+        .animation = &anim_image_empty,
131
+        .graphics = &pkmnTiles,
132
+        .rotscale = &rotscale_empty,
133
+        .callback = oac_nullsub,
134
+    };
135
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&pkmnTiles);
136
+
137
+    gpu_pal_decompress_alloc_tag_and_upload(&pkmnPal);
138
+    s8 objid = (s8)template_instanciate_forward_search(&pkmnTemplate, 10, 10, 0);
139
+
140
+    objects[objid].pos1.x = 55;
141
+    objects[objid].pos1.y = 76;
142
+    OBJID_HIDE(objid);
143
+    return objid;
144
+}
116 145
 
117 146
 void pdex_pokemon_load(u16 species) {
118 147
     /* this is very temporary */
@@ -120,31 +149,9 @@ void pdex_pokemon_load(u16 species) {
120 149
     u32 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
121 150
     rboxid_print(TB_PKMN, FONT_DEX_STD, TB_STD_CENTER(twidth, TB_STD_LEN_PX), 3, &pdex_text_color, 0,
122 151
                  &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
-    }
152
+
153
+    // pokedex_context->pokemon_oam = pdex_pokemon_oam_load(species, pokedex_context->pokemon_oam);
154
+
148 155
     rboxid_update_tilemap_and_tileset(TB_PKMN);
149 156
 }
150 157
 
@@ -350,6 +357,8 @@ void pdex_try_advance(u8 reverse) {
350 357
             pokedex_context->cursor_position_top--;
351 358
             pdex_hardware_scroll(true);
352 359
             m4aSongNumStart(600);
360
+        } else {
361
+            return;
353 362
         }
354 363
     } else {
355 364
         if (pokedex_context->cursor_position_internal < 7) {
@@ -360,14 +369,35 @@ void pdex_try_advance(u8 reverse) {
360 369
             pokedex_context->cursor_position_top++;
361 370
             pdex_hardware_scroll(false);
362 371
             m4aSongNumStart(600);
372
+        } else {
373
+            return;
363 374
         }
364 375
     }
365 376
 
366 377
     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 */
378
+    u16 speciesToLoad = (pdex_lazy_lookup_entry(pkIndexToLoad)->seen || pdex_lazy_lookup_entry(pkIndexToLoad)->caught)
379
+                            ? pdex_lazy_lookup_entry(pkIndexToLoad)->species
380
+                            : pdex_lazy_lookup_entry(pkIndexToLoad)->species; /* debug, just display the mofo */
381
+
382
+    pdex_pokemon_load(speciesToLoad);
383
+    if (reverse) {
384
+        s8 oam = pokedex_context->pokemon_oam; // current oam id
385
+        OBJID_HIDE(oam);
386
+        pokedex_context->pokemon_oam = pokedex_context->prev_pokemon_oam;
387
+        OBJID_SHOW(pokedex_context->pokemon_oam);
388
+        pokedex_context->prev_pokemon_oam = pokedex_context->next_pokemon_oam;
389
+        pokedex_context->next_pokemon_oam = oam;
390
+
391
+        pdex_pokemon_oam_update(pdex_lazy_lookup_entry(pkIndexToLoad - 1)->species, pokedex_context->prev_pokemon_oam);
392
+    } else {
393
+        s8 oam = pokedex_context->pokemon_oam;
394
+        OBJID_HIDE(oam);
395
+        pokedex_context->pokemon_oam = pokedex_context->next_pokemon_oam;
396
+        OBJID_SHOW(pokedex_context->pokemon_oam);
397
+        pokedex_context->next_pokemon_oam = pokedex_context->prev_pokemon_oam;
398
+        pokedex_context->prev_pokemon_oam = oam;
399
+        pdex_pokemon_oam_update(pdex_lazy_lookup_entry(pkIndexToLoad + 1)->species, pokedex_context->next_pokemon_oam);
400
+    }
371 401
     pdex_update_balls();
372 402
 }
373 403
 
@@ -388,9 +418,22 @@ void pdex_loop(u8 tid) {
388 418
 
389 419
         pdex_pokeballs_init();
390 420
         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);
421
+        u16 currentIndex = pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal;
422
+        pdex_pokemon_load(pdex_lazy_lookup_entry(currentIndex)->species);
423
+
424
+        pokedex_context->pokemon_oam =
425
+            pdex_pokemon_oam_load(pdex_lazy_lookup_entry(currentIndex)->species, DEX_PKMN_TAG_ONE);
426
+        OBJID_SHOW(pokedex_context->pokemon_oam);
427
+
428
+        pokedex_context->next_pokemon_oam =
429
+            pdex_pokemon_oam_load(pdex_lazy_lookup_entry(currentIndex + 1)->species, DEX_PKMN_TAG_TWO);
430
+
431
+        if (currentIndex != pokedex_context->first_seen) {
432
+            pokedex_context->prev_pokemon_oam =
433
+                pdex_pokemon_oam_load(pdex_lazy_lookup_entry(currentIndex - 1)->species, DEX_PKMN_TAG_THREE);
434
+        } else {
435
+            pokedex_context->prev_pokemon_oam = pdex_pokemon_oam_load(0, DEX_PKMN_TAG_THREE);
436
+        }
394 437
         pdex_load_sc();
395 438
         pdex_update_page_full();
396 439
 

+ 3
- 1
src/pokedex/pokedex_common.h 파일 보기

@@ -27,7 +27,9 @@
27 27
 #define TB_STD_CENTER(t,w) (((w - t) >> 1) + 2)
28 28
 #define TB_STD_RIGHT(t,w) ((w - t))
29 29
 
30
-#define DEX_PKMN_TAG 0x1300
30
+#define DEX_PKMN_TAG_ONE 0x1300
31
+#define DEX_PKMN_TAG_TWO 0x1310
32
+#define DEX_PKMN_TAG_THREE 0x1311
31 33
 #define DEX_BALL_TAG 0x1301
32 34
 #define DEX_CURSOR_TAG 0x1302
33 35
 #define DEX_ARROW_TAG 0x1303

+ 2
- 2
src/pokedex/pokedex_detail.c 파일 보기

@@ -98,7 +98,7 @@ void dexdetail_load_pokemon(u16 dexindex, enum DexFormType formType) {
98 98
     pstrcat(string_buffer, pdex_str_weight_unit);
99 99
     u16 weightTwidth = font_get_width_of_string(FONT_DEX_STD, string_buffer, 0x0000);
100 100
 
101
-    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 1, &pdex_text_color, 0,
101
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 14, &pdex_text_color, 0,
102 102
                  string_buffer);
103 103
 
104 104
     u16 sizeNumber = pokedex_data[dexindex].height / 10;
@@ -109,7 +109,7 @@ void dexdetail_load_pokemon(u16 dexindex, enum DexFormType formType) {
109 109
     pstrcat(string_buffer, buffer);
110 110
     pstrcat(string_buffer, pdex_str_size_unit);
111 111
 
112
-    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 14, &pdex_text_color, 0,
112
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 1, &pdex_text_color, 0,
113 113
                  string_buffer);
114 114
 
115 115
     rboxid_print(TB_DESC, FONT_DEX_STD, 3, 2, &pdex_text_color, 0, pokedex_data[dexindex].description1);