SBird1337 6 lat temu
rodzic
commit
86ba5e9d0c

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 98ab5bcce4025410bc8ba8ffac90c12480dffeb2
1
+Subproject commit 49715f90bdcc302e550383737d5282cfde00dbe3

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit ce95fff5f8e8a38439ccafac1311e204fb65e01b
1
+Subproject commit 0d148aaf0367dab7082a16085b2ae596782aabd5

+ 10
- 2
src/pokedex/pokedex_common.c Wyświetl plik

@@ -1,4 +1,5 @@
1 1
 #include "pokedex_common.h"
2
+#include <constants/pkmns.h>
2 3
 #include <pokeagb/pokeagb.h>
3 4
 
4 5
 const u16 pdex_text_pal[] = {rgb5(255, 0, 255), rgb5(255, 255, 255), rgb5(0, 0, 0),     rgb5(255, 0, 255),
@@ -49,6 +50,13 @@ const struct BgConfig pdex_bg_config[4] = {
49 50
     },
50 51
 };
51 52
 
53
+struct DexForm pdex_forms[FORM_COUNT] = 
54
+{
55
+    {.index = 19, .forms = {{814, PKMN_ALOLA_RATTFRATZ, ALOLA}, {0xFFFF, 0xFFFF, FORM_END}}},
56
+    {.index = 20, .forms = {{815, PKMN_ALOLA_RATIKARL, ALOLA}, {0xFFFF, 0xFFFF, FORM_END}}},
57
+    {.index = 0xFFFF, .forms = {{0xFFFF, 0xFFFF, FORM_END}}},
58
+};
59
+
52 60
 const struct OamData pdex_oam_pkmn = {
53 61
     .affine_mode = 0,
54 62
     .obj_mode = 0,
@@ -121,8 +129,8 @@ void pdex_free_memory(void) {
121 129
 
122 130
 void pdex_alloc_memory(void) {
123 131
     pokedex_context = malloc_and_clear(sizeof(struct PdexCtx));
124
-    pokedex_context->lookup = malloc_and_clear((PDEX_LAST_SHOWN + 1) * sizeof(struct PdexLookup));
125
-    memset(pokedex_context->lookup, 0xFF, (PDEX_LAST_SHOWN + 1) * sizeof(struct PdexLookup));
132
+    pokedex_context->lookup = malloc_and_clear((PDEX_LAST_ENTRY + 1) * sizeof(struct PdexLookup));
133
+    memset(pokedex_context->lookup, 0xFF, (PDEX_LAST_ENTRY + 1) * sizeof(struct PdexLookup));
126 134
 }
127 135
 
128 136
 void pdex_vram_allocate_bgmaps(void) {

+ 12
- 2
src/pokedex/pokedex_common.h Wyświetl plik

@@ -3,7 +3,9 @@
3 3
 
4 4
 #include <pokeagb/pokeagb.h>
5 5
 
6
-#define PDEX_LAST_SHOWN 813
6
+#define PDEX_ALOLA_COUNT (18)
7
+#define PDEX_LAST_ENTRY (813 + PDEX_ALOLA_COUNT)
8
+#define PDEX_LAST_SHOWN (813)
7 9
 
8 10
 #define CPUFSCPY 0
9 11
 #define CPUFSSET 1
@@ -38,6 +40,14 @@
38 40
 
39 41
 #define DEX_REGION_PAL(i) (0x1307 + i)
40 42
 #define DEX_REGION_ICON(i) (0x1307 + i)
43
+#define MAX_FORMS 7
44
+#define FORM_COUNT 20
45
+
46
+struct DexForm
47
+{
48
+    u16 index;
49
+    struct DexFormEntry forms[MAX_FORMS];
50
+};
41 51
 
42 52
 void pdex_cb_handler(void);
43 53
 void pdex_vblank_handler(void);
@@ -46,13 +56,13 @@ void pdex_vram_free_bgmaps(void);
46 56
 void pdex_free_memory(void);
47 57
 void pdex_alloc_memory(void);
48 58
 struct PdexLookup *pdex_lazy_lookup_entry(u16 dexIndex);
49
-
50 59
 void pdex_load(void);
51 60
 
52 61
 const u16 pdex_text_pal[16];
53 62
 const struct BgConfig pdex_bg_config[4];
54 63
 struct TextColor pdex_text_color;
55 64
 const struct OamData pdex_oam_pkmn;
65
+struct DexForm pdex_forms[FORM_COUNT];
56 66
 
57 67
 u8 pstr_lines(pchar* str);
58 68
 

+ 139
- 6
src/pokedex/pokedex_detail.c Wyświetl plik

@@ -1,5 +1,6 @@
1 1
 #include <agb_debug.h>
2 2
 #include <pokeagb/pokeagb.h>
3
+#include <pokedex/pdexArrowRotated.h>
3 4
 #include <pokedex/pdexDetailBg.h>
4 5
 
5 6
 #include "pokedex_common.h"
@@ -62,14 +63,24 @@ s8 dexdetail_load_type_oam(u8 type, u16 tag) {
62 63
     return id;
63 64
 }
64 65
 
65
-void dexdetail_load_pokemon(u16 dexindex) {
66
+extern pchar pdex_str_form_alola[];
67
+
68
+void dexdetail_load_pokemon(u16 dexindex, enum DexFormType formType) {
66 69
     u16 species = pdex_lazy_lookup_entry(dexindex)->species;
67 70
     rboxid_clear_pixels(TB_PKNAME, 0);
68 71
     rboxid_clear_pixels(TB_PKSIZE, 0);
69 72
     rboxid_clear_pixels(TB_DESC, 0);
70
-    u16 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
73
+    pstrcpy(string_buffer, &pokemon_names[species][0]);
74
+    switch (formType) {
75
+    case ALOLA:
76
+        pstrcat(string_buffer, pdex_str_form_alola);
77
+        break;
78
+    default:
79
+        break;
80
+    }
81
+    u16 twidth = font_get_width_of_string(FONT_DEX_STD, string_buffer, 0x0000);
71 82
     rboxid_print(TB_PKNAME, FONT_DEX_STD, TB_STD_CENTER(twidth, 8 * TB_PKNAME_W), 0, &pdex_text_color, 0,
72
-                 &pokemon_names[species][0]);
83
+                 string_buffer);
73 84
 
74 85
     pchar *strType = &pokedex_data[dexindex].category_name[0];
75 86
     u16 typeTwidth = font_get_width_of_string(FONT_DEX_STD, strType, 0x0000);
@@ -105,7 +116,11 @@ void dexdetail_load_pokemon(u16 dexindex) {
105 116
 
106 117
     /* load the species sprite */
107 118
     if (pokedex_context->detail_pokemon_oam != -1) {
108
-
119
+        lz77UnCompVram(
120
+            pokemon_graphics_front[species].data,
121
+            ((void *)(objects[pokedex_context->detail_pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
122
+        gpu_pal_apply_compressed(pokemon_palette_normal[species].data,
123
+                                 16 * (objects[pokedex_context->detail_pokemon_oam].final_oam.palette_num + 16), 32);
109 124
     } else {
110 125
         struct SpriteTiles pkmnTiles = {pokemon_graphics_front[species].data, 2048, DEX_PKMN_TAG};
111 126
         struct SpritePalette pkmnPal = {pokemon_palette_normal[species].data, DEX_PKMN_TAG};
@@ -151,18 +166,124 @@ void dexdetail_load_pokemon(u16 dexindex) {
151 166
     } else {
152 167
         OBJID_HIDE(pokedex_context->detail_type_oam[1]);
153 168
     }
154
-
155 169
     rboxid_update_tilemap_and_tileset(TB_DESC);
156 170
     rboxid_update_tilemap_and_tileset(TB_PKNAME);
157 171
     rboxid_update_tilemap_and_tileset(TB_PKSIZE);
158 172
 }
159 173
 
174
+void dexdetail_update_form(u16 form) {
175
+    REG_DISPCNT &= ~((1 << 8) | (1 << 9));
176
+    if (form == 0) {
177
+        dexdetail_load_pokemon(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal,
178
+                               NORMAL);
179
+    } else {
180
+        form--;
181
+        if (pokedex_context->detail_forms[form].index > PDEX_LAST_SHOWN) {
182
+            dexdetail_load_pokemon(pokedex_context->detail_forms[form].index, pokedex_context->detail_forms[form].type);
183
+        } else {
184
+            // update the oam only
185
+            u16 species = pokedex_context->detail_forms[form].species;
186
+            lz77UnCompVram(
187
+                pokemon_graphics_front[species].data,
188
+                ((void *)(objects[pokedex_context->detail_pokemon_oam].final_oam.tile_num * 32) + ADDR_VRAM + 0x10000));
189
+            gpu_pal_apply_compressed(pokemon_palette_normal[species].data,
190
+                                     16 * (objects[pokedex_context->detail_pokemon_oam].final_oam.palette_num + 16),
191
+                                     32);
192
+        }
193
+    }
194
+    REG_DISPCNT |= ((1 << 8) | (1 << 9));
195
+}
196
+
197
+struct DexFormEntry *dexdetail_get_forms(u16 index) {
198
+    u16 current = 0;
199
+    while (pdex_forms[current].index != 0xFFFF) {
200
+        if (pdex_forms[current].index == index)
201
+            return &pdex_forms[current].forms[0];
202
+        current++;
203
+    }
204
+    return NULL;
205
+}
206
+
207
+void dexdetail_oac_arrow(struct Object *obj) {
208
+    if (pokedex_context->detail_forms != NULL) {
209
+        if (obj->priv[0]) {
210
+            // this is the left arrow
211
+            if (pokedex_context->detail_form_position != 0) {
212
+                obj->final_oam.palette_num = obj->priv[1];
213
+            } else {
214
+                obj->final_oam.palette_num = obj->priv[2];
215
+            }
216
+        } else {
217
+            // this is the right arrow
218
+            if (pokedex_context->detail_forms[pokedex_context->detail_form_position].type != FORM_END) {
219
+                obj->final_oam.palette_num = obj->priv[1];
220
+            } else {
221
+                obj->final_oam.palette_num = obj->priv[2];
222
+            }
223
+        }
224
+    }
225
+}
226
+
227
+struct SpriteTiles pdex_arrow_rot_tiles = {pdexArrowRotatedTiles, 256, DEX_ARROW_TAG};
228
+struct SpritePalette pdex_arrow_rot_pal = {pdexArrowRotatedPal, DEX_ARROW_TAG};
229
+struct SpritePalette pdex_arrow_rot_pal_gray = {pdexArrowRotatedPal, DEX_ARROW_TAG_EPAL};
230
+
231
+const struct OamData pdex_arrow_rot_oam = {
232
+    .affine_mode = 0,
233
+    .obj_mode = 0,
234
+    .mosaic = false,
235
+    .shape = 0,
236
+    .size = 1,
237
+};
238
+
239
+const struct Template pdex_arrow_rot_template = {
240
+    .tiles_tag = DEX_ARROW_TAG,
241
+    .pal_tag = DEX_ARROW_TAG,
242
+    .oam = &pdex_arrow_rot_oam,
243
+    .animation = &anim_image_empty,
244
+    .graphics = &pdex_arrow_rot_tiles,
245
+    .rotscale = &rotscale_empty,
246
+    .callback = dexdetail_oac_arrow,
247
+};
248
+
249
+void dexdetail_load_form_arrows(void) {
250
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&pdex_arrow_rot_tiles);
251
+    u8 normalPal = gpu_pal_obj_alloc_tag_and_apply(&pdex_arrow_rot_pal);
252
+    u8 grayPal = gpu_pal_obj_alloc_tag_and_apply(&pdex_arrow_rot_pal_gray);
253
+    tint_palette_gray(&palette_bg_unfaded[16 * (16 + grayPal)], 16);
254
+    u8 leftArrow = template_instanciate_forward_search(&pdex_arrow_rot_template, 20, 80, 0);
255
+    u8 rightArrow = template_instanciate_forward_search(&pdex_arrow_rot_template, 80, 80, 0);
256
+    objects[leftArrow].priv[0] = true;
257
+    objects[leftArrow].final_oam.h_flip = true;
258
+    objects[leftArrow].priv[1] = normalPal;
259
+    objects[leftArrow].priv[2] = grayPal;
260
+    objects[rightArrow].priv[0] = false;
261
+    objects[rightArrow].priv[1] = normalPal;
262
+    objects[rightArrow].priv[2] = grayPal;
263
+    pokedex_context->detail_arrows_oam[0] = leftArrow;
264
+    pokedex_context->detail_arrows_oam[1] = rightArrow;
265
+}
266
+
160 267
 void dexdetail_loop(u8 tid) {
161 268
     (void)tid;
162 269
     switch (pokedex_context->state) {
163 270
     case 0:
164 271
         bgid_send_tilemap(2);
165
-        dexdetail_load_pokemon(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal);
272
+        u16 currentIndex = pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal;
273
+        dexdetail_load_form_arrows();
274
+        dexdetail_load_pokemon(currentIndex, NORMAL);
275
+        pokedex_context->detail_form_position = 0;
276
+        struct DexFormEntry *forms = dexdetail_get_forms(currentIndex);
277
+        if (forms != NULL) {
278
+            OBJID_SHOW(pokedex_context->detail_arrows_oam[0]);
279
+            OBJID_SHOW(pokedex_context->detail_arrows_oam[1]);
280
+        } else {
281
+            OBJID_HIDE(pokedex_context->detail_arrows_oam[0]);
282
+            OBJID_HIDE(pokedex_context->detail_arrows_oam[1]);
283
+        }
284
+        dprintf("test: %d", pokedex_index_to_species(1000));
285
+        pokedex_context->detail_forms = forms;
286
+
166 287
         palette_bg_faded_fill_black();
167 288
         pokedex_context->state++;
168 289
         break;
@@ -190,6 +311,18 @@ void dexdetail_loop(u8 tid) {
190 311
 
191 312
             fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
192 313
             break;
314
+        case KEY_LEFT:
315
+            if (pokedex_context->detail_form_position != 0) {
316
+                pokedex_context->detail_form_position--;
317
+                dexdetail_update_form(pokedex_context->detail_form_position);
318
+            }
319
+            break;
320
+        case KEY_RIGHT:
321
+            if (pokedex_context->detail_forms[pokedex_context->detail_form_position].type != FORM_END) {
322
+                pokedex_context->detail_form_position++;
323
+                dexdetail_update_form(pokedex_context->detail_form_position);
324
+            }
325
+            break;
193 326
         }
194 327
         break;
195 328
     case 12:

+ 5
- 0
src/pokedex/pokedex_string.s Wyświetl plik

@@ -46,6 +46,11 @@ pdex_str_empty:
46 46
     .string LAN_DE "----------"
47 47
     .string LAN_EN "----------"
48 48
 
49
+.global pdex_str_form_alola
50
+pdex_str_form_alola:
51
+    .string LAN_DE " (Alola)"
52
+    .string LAN_DE " (Alola)"
53
+
49 54
 .align 2
50 55
 .global pdex_str_regions
51 56
 pdex_str_regions: