|
@@ -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:
|