|
@@ -26,6 +26,42 @@ struct TextboxTemplate dexdetail_boxes[] = {
|
26
|
26
|
{.bg_id = 0xFF},
|
27
|
27
|
};
|
28
|
28
|
|
|
29
|
+u8 dexdetail_type_to_oam_type[18] = {0, 9, 8, 12, 6, 5, 11, 10, 14, 17, 1, 2, 3,4, 13, 7, 16, 15};
|
|
30
|
+
|
|
31
|
+#define O_TYPE(t) (dexdetail_type_to_oam_type[t])
|
|
32
|
+
|
|
33
|
+struct OamData dexdetail_type_oam = {
|
|
34
|
+ .affine_mode = 0,
|
|
35
|
+ .obj_mode = 0,
|
|
36
|
+ .mosaic = false,
|
|
37
|
+ .shape = 1,
|
|
38
|
+ .size = 2,
|
|
39
|
+};
|
|
40
|
+
|
|
41
|
+void dexdetail_update_type_oam(u8 type, struct Object *obj) {
|
|
42
|
+ memcpy((void *)((0x06010000) + (obj->final_oam.tile_num * 0x20)),
|
|
43
|
+ pokemon_type_chart_gfx + (128 * O_TYPE(type)) + (512 * (O_TYPE(type) >> 2)), 128);
|
|
44
|
+ memcpy((void *)((0x06010000) + 128 + (obj->final_oam.tile_num * 0x20)),
|
|
45
|
+ pokemon_type_chart_gfx + 512 + (128 * O_TYPE(type)) + (512 * (O_TYPE(type) >> 2)), 128);
|
|
46
|
+}
|
|
47
|
+
|
|
48
|
+s8 dexdetail_load_type_oam(u8 type, u16 tag) {
|
|
49
|
+ struct SpriteTiles typeTiles = {(&pokemon_type_chart_gfx[0]) + 256 * O_TYPE(type), 256, tag};
|
|
50
|
+ gpu_tile_obj_alloc_tag_and_upload(&typeTiles);
|
|
51
|
+ const struct Template typeTemplate = {
|
|
52
|
+ .tiles_tag = tag,
|
|
53
|
+ .pal_tag = DEX_DETAIL_TYPEPAL,
|
|
54
|
+ .oam = &dexdetail_type_oam,
|
|
55
|
+ .animation = &anim_image_empty,
|
|
56
|
+ .graphics = &typeTiles,
|
|
57
|
+ .rotscale = &rotscale_empty,
|
|
58
|
+ .callback = oac_nullsub,
|
|
59
|
+ };
|
|
60
|
+ s8 id = (s8)template_instanciate_forward_search(&typeTemplate, 100, 100, 0);
|
|
61
|
+ dexdetail_update_type_oam(type, &objects[id]);
|
|
62
|
+ return id;
|
|
63
|
+}
|
|
64
|
+
|
29
|
65
|
void dexdetail_load_pokemon(u16 dexindex) {
|
30
|
66
|
u16 species = pokedex_context->lookup[dexindex].species;
|
31
|
67
|
rboxid_clear_pixels(TB_PKNAME, 0);
|
|
@@ -91,6 +127,31 @@ void dexdetail_load_pokemon(u16 dexindex) {
|
91
|
127
|
objects[pokedex_context->detail_pokemon_oam].pos1.y = 55;
|
92
|
128
|
}
|
93
|
129
|
|
|
130
|
+ // draw the first type icon
|
|
131
|
+ if (pokedex_context->detail_type_oam[0] != -1) {
|
|
132
|
+ dexdetail_update_type_oam(pokemon_base_stats[species].type[0], &objects[pokedex_context->detail_type_oam[0]]);
|
|
133
|
+ } else {
|
|
134
|
+ pokedex_context->detail_type_oam[0] =
|
|
135
|
+ dexdetail_load_type_oam(pokemon_base_stats[species].type[0], DEX_DETAIL_TYPE1);
|
|
136
|
+ objects[pokedex_context->detail_type_oam[0]].pos1.x = 156;
|
|
137
|
+ objects[pokedex_context->detail_type_oam[0]].pos1.y = 80;
|
|
138
|
+ }
|
|
139
|
+ // draw the second type icon eventually
|
|
140
|
+ if (pokemon_base_stats[species].type[0] != pokemon_base_stats[species].type[1]) {
|
|
141
|
+ if (pokedex_context->detail_type_oam[1] != -1) {
|
|
142
|
+ dexdetail_update_type_oam(pokemon_base_stats[species].type[1],
|
|
143
|
+ &objects[pokedex_context->detail_type_oam[1]]);
|
|
144
|
+ } else {
|
|
145
|
+ pokedex_context->detail_type_oam[1] =
|
|
146
|
+ dexdetail_load_type_oam(pokemon_base_stats[species].type[1], DEX_DETAIL_TYPE2);
|
|
147
|
+ objects[pokedex_context->detail_type_oam[1]].pos1.x = 210;
|
|
148
|
+ objects[pokedex_context->detail_type_oam[1]].pos1.y = 80;
|
|
149
|
+ }
|
|
150
|
+ OBJID_SHOW(pokedex_context->detail_type_oam[1]);
|
|
151
|
+ } else {
|
|
152
|
+ OBJID_HIDE(pokedex_context->detail_type_oam[1]);
|
|
153
|
+ }
|
|
154
|
+
|
94
|
155
|
rboxid_update_tilemap_and_tileset(TB_DESC);
|
95
|
156
|
rboxid_update_tilemap_and_tileset(TB_PKNAME);
|
96
|
157
|
rboxid_update_tilemap_and_tileset(TB_PKSIZE);
|
|
@@ -102,7 +163,6 @@ void dexdetail_loop(u8 tid) {
|
102
|
163
|
case 0:
|
103
|
164
|
bgid_send_tilemap(2);
|
104
|
165
|
dexdetail_load_pokemon(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal);
|
105
|
|
-
|
106
|
166
|
palette_bg_faded_fill_black();
|
107
|
167
|
pokedex_context->state++;
|
108
|
168
|
break;
|
|
@@ -115,17 +175,38 @@ void dexdetail_loop(u8 tid) {
|
115
|
175
|
fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 16, 0, 0x0000);
|
116
|
176
|
pokedex_context->state++;
|
117
|
177
|
break;
|
|
178
|
+ case 2:
|
|
179
|
+ switch (super.buttons_new) {
|
|
180
|
+ case KEY_B:
|
|
181
|
+ pokedex_context->state = 12;
|
|
182
|
+ pokedex_context->cursor_position_top =
|
|
183
|
+ pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal;
|
|
184
|
+ pokedex_context->cursor_position_internal = 0;
|
|
185
|
+ fade_screen(0xFFFFFFFF, PDEX_FADEIN_SPD, 0, 16, 0x0000);
|
|
186
|
+ break;
|
|
187
|
+ }
|
|
188
|
+ break;
|
|
189
|
+ case 12:
|
|
190
|
+ if (!pal_fade_control.active) {
|
|
191
|
+ task_del(tid);
|
|
192
|
+ pdex_vram_free_bgmaps();
|
|
193
|
+ set_callback2(pdex_load);
|
|
194
|
+ }
|
|
195
|
+ break;
|
118
|
196
|
default:
|
119
|
197
|
break;
|
120
|
198
|
}
|
121
|
199
|
}
|
122
|
200
|
|
|
201
|
+struct SpritePalette dexdetail_type_pal = {&pokemon_type_chart_pal[0], DEX_DETAIL_TYPEPAL};
|
|
202
|
+
|
123
|
203
|
void dexdetail_load_gfx(void) {
|
124
|
204
|
rbox_init_from_templates(&dexdetail_boxes[0]);
|
125
|
205
|
lz77UnCompVram(pdexDetailBgTiles, (void *)0x0600C000);
|
126
|
206
|
LZ77UnCompWram(pdexDetailBgMap, bgid_get_tilemap(2));
|
127
|
207
|
gpu_pal_apply_compressed(pdexDetailBgPal, 0, 32);
|
128
|
208
|
gpu_pal_apply(pdex_text_pal, 15 * 16, 32);
|
|
209
|
+ gpu_pal_obj_alloc_tag_and_apply(&dexdetail_type_pal);
|
129
|
210
|
|
130
|
211
|
lcd_io_set(REG_ID_WIN0H, (8 << 8) | (232));
|
131
|
212
|
lcd_io_set(REG_ID_WIN0V, ((100 << 8) | (160)));
|
|
@@ -140,6 +221,8 @@ void dexdetail_load(void) {
|
140
|
221
|
dexdetail_load_gfx();
|
141
|
222
|
pokedex_context->state = 0;
|
142
|
223
|
pokedex_context->detail_pokemon_oam = -1;
|
|
224
|
+ pokedex_context->detail_type_oam[0] = -1;
|
|
225
|
+ pokedex_context->detail_type_oam[1] = -1;
|
143
|
226
|
task_add(dexdetail_loop, 0);
|
144
|
227
|
set_callback2(pdex_cb_handler);
|
145
|
228
|
}
|