Browse Source

add region bookmark funcitonality, resolves 21

SBird1337 6 years ago
parent
commit
f12c09733c

+ 1
- 1
g3headers

1
-Subproject commit ef2af052b8e5436da9efb035e06ee091b8d53e69
1
+Subproject commit ea54ef42e9c16dfa5ec7fca2fcdade01c8ebe47c

+ 4
- 12
src/pokedex/pokedex.c View File

9
 
9
 
10
 #include "pokedex_common.h"
10
 #include "pokedex_common.h"
11
 
11
 
12
-#define PDEX_LAST_SHOWN PKMN_AMIGENTO
12
+#define PDEX_LAST_SHOWN 813
13
 
13
 
14
 #define TB_TITLE 0
14
 #define TB_TITLE 0
15
 #define TB_PKMN 1
15
 #define TB_PKMN 1
85
 
85
 
86
 void pdex_update_page_full() {
86
 void pdex_update_page_full() {
87
     rboxid_clear_pixels(TB_MAIN, 0);
87
     rboxid_clear_pixels(TB_MAIN, 0);
88
-    for (s8 i = pokedex_context->cursor_position_top; i < pokedex_context->cursor_position_top + 8; ++i) {
88
+    for (u16 i = pokedex_context->cursor_position_top; i < pokedex_context->cursor_position_top + 8; ++i) {
89
         pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pokedex_context->lookup[i].species,
89
         pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pokedex_context->lookup[i].species,
90
                                    pokedex_context->lookup[i].seen, pokedex_context->lookup[i].caught);
90
                                    pokedex_context->lookup[i].seen, pokedex_context->lookup[i].caught);
91
     }
91
     }
117
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
117
     rboxid_update_tilemap_and_tileset(TB_CAUGHT);
118
 }
118
 }
119
 
119
 
120
-const struct OamData pdex_oam_pkmn = {
121
-    .affine_mode = 0,
122
-    .obj_mode = 0,
123
-    .mosaic = false,
124
-    .shape = 0,
125
-    .size = 3,
126
-};
127
-
128
 void pdex_pokemon_load(u16 species) {
120
 void pdex_pokemon_load(u16 species) {
129
     /* this is very temporary */
121
     /* this is very temporary */
130
     rboxid_clear_pixels(TB_PKMN, 0);
122
     rboxid_clear_pixels(TB_PKMN, 0);
328
             pokedex_context->lookup[i].caught = dex_flag_pokedex_index(i, DEX_FLAG_CHECK_CAUGHT);
320
             pokedex_context->lookup[i].caught = dex_flag_pokedex_index(i, DEX_FLAG_CHECK_CAUGHT);
329
             if (!first && (pokedex_context->lookup[i].seen)) {
321
             if (!first && (pokedex_context->lookup[i].seen)) {
330
                 pokedex_context->first_seen = 1; //i
322
                 pokedex_context->first_seen = 1; //i
331
-                pokedex_context->cursor_position_top = 1; //i
323
+                //pokedex_context->cursor_position_top = 1; //i is set in region dex
332
                 first = true;
324
                 first = true;
333
             }
325
             }
334
         }
326
         }
413
 
405
 
414
         pdex_pokeballs_init();
406
         pdex_pokeballs_init();
415
         pdex_load_scroll_ui();
407
         pdex_load_scroll_ui();
416
-        pdex_pokemon_load(pokedex_context->lookup[pokedex_context->first_seen].species);
408
+        pdex_pokemon_load(pokedex_context->lookup[pokedex_context->cursor_position_top].species);
417
         pdex_load_sc();
409
         pdex_load_sc();
418
         pdex_update_page_full();
410
         pdex_update_page_full();
419
 
411
 

+ 8
- 0
src/pokedex/pokedex_common.c View File

49
     },
49
     },
50
 };
50
 };
51
 
51
 
52
+const struct OamData pdex_oam_pkmn = {
53
+    .affine_mode = 0,
54
+    .obj_mode = 0,
55
+    .mosaic = false,
56
+    .shape = 0,
57
+    .size = 3,
58
+};
59
+
52
 struct TextColor pdex_text_color = {0, 1, 2};
60
 struct TextColor pdex_text_color = {0, 1, 2};
53
 
61
 
54
 void pdex_vblank_handler(void) {
62
 void pdex_vblank_handler(void) {

+ 2
- 0
src/pokedex/pokedex_common.h View File

44
 const u16 pdex_text_pal[16];
44
 const u16 pdex_text_pal[16];
45
 const struct BgConfig pdex_bg_config[4];
45
 const struct BgConfig pdex_bg_config[4];
46
 struct TextColor pdex_text_color;
46
 struct TextColor pdex_text_color;
47
+const struct OamData pdex_oam_pkmn;
48
+
47
 u8 pstr_lines(pchar* str);
49
 u8 pstr_lines(pchar* str);
48
 
50
 
49
 #endif
51
 #endif

+ 67
- 13
src/pokedex/pokedex_detail.c View File

5
 #include "pokedex_common.h"
5
 #include "pokedex_common.h"
6
 
6
 
7
 #define TB_PKNAME 0
7
 #define TB_PKNAME 0
8
-#define TB_PKSIZE 2
9
-#define TB_PKWEIGHT 3
8
+#define TB_PKSIZE 1
10
 #define TB_DESC 2
9
 #define TB_DESC 2
11
 
10
 
12
 #define TB_PKNAME_W 30
11
 #define TB_PKNAME_W 30
13
-#define TB_SW_W 20
12
+#define TB_SW_W 12
14
 
13
 
15
 extern pchar pdex_entry_debug[];
14
 extern pchar pdex_entry_debug[];
16
 extern pchar pdex_str_size[];
15
 extern pchar pdex_str_size[];
17
 extern pchar pdex_str_weight[];
16
 extern pchar pdex_str_weight[];
18
 extern pchar pdex_str_size_unit[];
17
 extern pchar pdex_str_size_unit[];
19
 extern pchar pdex_str_weight_unit[];
18
 extern pchar pdex_str_weight_unit[];
19
+extern pchar pdex_str_comma[];
20
 
20
 
21
 struct TextboxTemplate dexdetail_boxes[] = {
21
 struct TextboxTemplate dexdetail_boxes[] = {
22
     {.bg_id = 0, .x = 0, .y = 0, .width = TB_PKNAME_W, .height = 4, .pal_id = 15, .charbase = 1},
22
     {.bg_id = 0, .x = 0, .y = 0, .width = TB_PKNAME_W, .height = 4, .pal_id = 15, .charbase = 1},
23
-
24
-    {.bg_id = 1, .x = 1, .y = 0, .width = 28, .height = 20, .pal_id = 15, .charbase = 121},
23
+    {.bg_id = 0, .x = 17, .y = 5, .width = TB_SW_W, .height = 4, .pal_id = 15, .charbase = 121},
24
+    {.bg_id = 1, .x = 1, .y = 0, .width = 28, .height = 20, .pal_id = 15, .charbase = 161},
25
 
25
 
26
     {.bg_id = 0xFF},
26
     {.bg_id = 0xFF},
27
 };
27
 };
29
 void dexdetail_load_pokemon(u16 dexindex) {
29
 void dexdetail_load_pokemon(u16 dexindex) {
30
     u16 species = pokedex_context->lookup[dexindex].species;
30
     u16 species = pokedex_context->lookup[dexindex].species;
31
     rboxid_clear_pixels(TB_PKNAME, 0);
31
     rboxid_clear_pixels(TB_PKNAME, 0);
32
+    rboxid_clear_pixels(TB_PKSIZE, 0);
33
+    rboxid_clear_pixels(TB_DESC, 0);
32
     u16 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
34
     u16 twidth = font_get_width_of_string(FONT_DEX_STD, &pokemon_names[species][0], 0x0000);
33
-    //rboxid_print(TB_PKNAME, FONT_DEX_STD, TB_STD_CENTER(twidth,8*TB_PKNAME_W), 0, &pdex_text_color, 0, &pokemon_names[species][0]);
34
-    rboxid_print(TB_PKNAME, FONT_DEX_STD, 0, 0, &pdex_text_color, 0, pdex_entry_debug);
35
+    rboxid_print(TB_PKNAME, FONT_DEX_STD, TB_STD_CENTER(twidth, 8 * TB_PKNAME_W), 0, &pdex_text_color, 0,
36
+                 &pokemon_names[species][0]);
37
+
35
     pchar *strType = &pokedex_data[dexindex].category_name[0];
38
     pchar *strType = &pokedex_data[dexindex].category_name[0];
36
     u16 typeTwidth = font_get_width_of_string(FONT_DEX_STD, strType, 0x0000);
39
     u16 typeTwidth = font_get_width_of_string(FONT_DEX_STD, strType, 0x0000);
37
-    rboxid_print(TB_PKNAME, FONT_DEX_STD, 50, 16, &pdex_text_color, 0, strType);
38
-    rboxid_update_tilemap_and_tileset(TB_PKNAME);
40
+    rboxid_print(TB_PKNAME, FONT_DEX_STD, TB_STD_CENTER(typeTwidth, 88) + 110, 14, &pdex_text_color, 0, strType);
41
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, 4, 1, &pdex_text_color, 0, pdex_str_size);
42
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, 4, 14, &pdex_text_color, 0, pdex_str_weight);
43
+
44
+    u16 weightNumber = pokedex_data[dexindex].weight / 10;
45
+    u16 weightDecimal = pokedex_data[dexindex].weight % 10;
46
+    pchar buffer[20];
47
+    fmt_int_10(string_buffer, weightNumber, 0, 3);
48
+    fmt_int_10(&buffer[0], weightDecimal, 0, 1);
49
+    pstrcat(string_buffer, pdex_str_comma);
50
+    pstrcat(string_buffer, buffer);
51
+    pstrcat(string_buffer, pdex_str_weight_unit);
52
+    u16 weightTwidth = font_get_width_of_string(FONT_DEX_STD, string_buffer, 0x0000);
53
+
54
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 1, &pdex_text_color, 0,
55
+                 string_buffer);
56
+
57
+    u16 sizeNumber = pokedex_data[dexindex].height / 10;
58
+    u16 sizeDecimal = pokedex_data[dexindex].height % 10;
59
+    fmt_int_10(string_buffer, sizeNumber, 0, 3);
60
+    fmt_int_10(&buffer[0], sizeDecimal, 0, 1);
61
+    pstrcat(string_buffer, pdex_str_comma);
62
+    pstrcat(string_buffer, buffer);
63
+    pstrcat(string_buffer, pdex_str_size_unit);
64
+
65
+    rboxid_print(TB_PKSIZE, FONT_DEX_STD, TB_STD_RIGHT(weightTwidth, TB_SW_W * 8) - 6, 14, &pdex_text_color, 0,
66
+                 string_buffer);
39
 
67
 
68
+    rboxid_print(TB_DESC, FONT_DEX_STD, 3, 2, &pdex_text_color, 0, pokedex_data[dexindex].description1);
69
+
70
+    /* load the species sprite */
71
+    if (pokedex_context->detail_pokemon_oam != -1) {
72
+
73
+    } else {
74
+        struct SpriteTiles pkmnTiles = {pokemon_graphics_front[species].data, 2048, DEX_PKMN_TAG};
75
+        struct SpritePalette pkmnPal = {pokemon_palette_normal[species].data, DEX_PKMN_TAG};
76
+        const struct Template pkmnTemplate = {
77
+            .tiles_tag = DEX_PKMN_TAG,
78
+            .pal_tag = DEX_PKMN_TAG,
79
+            .oam = &pdex_oam_pkmn,
80
+            .animation = &anim_image_empty,
81
+            .graphics = &pkmnTiles,
82
+            .rotscale = &rotscale_empty,
83
+            .callback = oac_nullsub,
84
+        };
85
+        gpu_tile_obj_decompress_alloc_tag_and_upload(&pkmnTiles);
86
+
87
+        gpu_pal_decompress_alloc_tag_and_upload(&pkmnPal);
88
+        pokedex_context->detail_pokemon_oam = (s8)template_instanciate_forward_search(&pkmnTemplate, 10, 10, 0);
89
+
90
+        objects[pokedex_context->detail_pokemon_oam].pos1.x = 55;
91
+        objects[pokedex_context->detail_pokemon_oam].pos1.y = 55;
92
+    }
93
+
94
+    rboxid_update_tilemap_and_tileset(TB_DESC);
95
+    rboxid_update_tilemap_and_tileset(TB_PKNAME);
96
+    rboxid_update_tilemap_and_tileset(TB_PKSIZE);
40
 }
97
 }
41
 
98
 
42
 void dexdetail_loop(u8 tid) {
99
 void dexdetail_loop(u8 tid) {
44
     switch (pokedex_context->state) {
101
     switch (pokedex_context->state) {
45
     case 0:
102
     case 0:
46
         bgid_send_tilemap(2);
103
         bgid_send_tilemap(2);
47
-        // rboxid_fill_rectangle(4, 1, 0, 0, 28 * 8, 20 * 8);
48
         dexdetail_load_pokemon(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal);
104
         dexdetail_load_pokemon(pokedex_context->cursor_position_top + pokedex_context->cursor_position_internal);
49
-        //rboxid_clear_pixels(TB_DESC, 0);
50
-        //rboxid_print(TB_DESC, FONT_DEX_STD, 3, 2, &pdex_text_color, 0, pdex_entry_debug);
51
-        //rboxid_update_tilemap_and_tileset(TB_DESC);
52
 
105
 
53
         palette_bg_faded_fill_black();
106
         palette_bg_faded_fill_black();
54
         pokedex_context->state++;
107
         pokedex_context->state++;
86
     pdex_vram_setup();
139
     pdex_vram_setup();
87
     dexdetail_load_gfx();
140
     dexdetail_load_gfx();
88
     pokedex_context->state = 0;
141
     pokedex_context->state = 0;
142
+    pokedex_context->detail_pokemon_oam = -1;
89
     task_add(dexdetail_loop, 0);
143
     task_add(dexdetail_loop, 0);
90
     set_callback2(pdex_cb_handler);
144
     set_callback2(pdex_cb_handler);
91
 }
145
 }

+ 3
- 0
src/pokedex/pokedex_region.c View File

10
 extern const pchar *pdex_str_regions[];
10
 extern const pchar *pdex_str_regions[];
11
 extern const pchar *pdex_str_empty;
11
 extern const pchar *pdex_str_empty;
12
 
12
 
13
+const u16 region_to_dex[] = {1, 152, 252, 393, 501, 656, 728};
14
+
13
 struct TextboxTemplate region_select_boxes[] = {
15
 struct TextboxTemplate region_select_boxes[] = {
14
     {.bg_id = 0, .x = 4, .y = 7, .width = 6, .height = 3, .pal_id = 15, .charbase = 1},
16
     {.bg_id = 0, .x = 4, .y = 7, .width = 6, .height = 3, .pal_id = 15, .charbase = 1},
15
     {.bg_id = 0, .x = 13, .y = 7, .width = 6, .height = 3, .pal_id = 15, .charbase = 19},
17
     {.bg_id = 0, .x = 13, .y = 7, .width = 6, .height = 3, .pal_id = 15, .charbase = 19},
190
         if (!pal_fade_control.active) {
192
         if (!pal_fade_control.active) {
191
             task_del(tid);
193
             task_del(tid);
192
             pdex_vram_free_bgmaps();
194
             pdex_vram_free_bgmaps();
195
+            pokedex_context->cursor_position_top = region_to_dex[pokedex_context->region_selected];
193
             set_callback2(pdex_load);
196
             set_callback2(pdex_load);
194
         }
197
         }
195
         break;
198
         break;

+ 5
- 0
src/pokedex/pokedex_string.s View File

36
     .string LAN_DE "kg"
36
     .string LAN_DE "kg"
37
     .string LAN_EN "kg"
37
     .string LAN_EN "kg"
38
 
38
 
39
+.global pdex_str_comma
40
+pdex_str_comma:
41
+    .string LAN_DE ","
42
+    .string LAN_EN ","
43
+
39
 .global pdex_str_empty
44
 .global pdex_str_empty
40
 pdex_str_empty:
45
 pdex_str_empty:
41
     .string LAN_DE "----------"
46
     .string LAN_DE "----------"