Bläddra i källkod

add region bookmark funcitonality, resolves 21

SBird1337 6 år sedan
förälder
incheckning
f12c09733c

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit ef2af052b8e5436da9efb035e06ee091b8d53e69
1
+Subproject commit ea54ef42e9c16dfa5ec7fca2fcdade01c8ebe47c

+ 4
- 12
src/pokedex/pokedex.c Visa fil

@@ -9,7 +9,7 @@
9 9
 
10 10
 #include "pokedex_common.h"
11 11
 
12
-#define PDEX_LAST_SHOWN PKMN_AMIGENTO
12
+#define PDEX_LAST_SHOWN 813
13 13
 
14 14
 #define TB_TITLE 0
15 15
 #define TB_PKMN 1
@@ -85,7 +85,7 @@ void pdex_update_balls(void) {
85 85
 
86 86
 void pdex_update_page_full() {
87 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 89
         pdex_main_box_species_fill(i - pokedex_context->cursor_position_top, pokedex_context->lookup[i].species,
90 90
                                    pokedex_context->lookup[i].seen, pokedex_context->lookup[i].caught);
91 91
     }
@@ -117,14 +117,6 @@ void pdex_load_sc(void) {
117 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 120
 void pdex_pokemon_load(u16 species) {
129 121
     /* this is very temporary */
130 122
     rboxid_clear_pixels(TB_PKMN, 0);
@@ -328,7 +320,7 @@ void pdex_data_setup(void) {
328 320
             pokedex_context->lookup[i].caught = dex_flag_pokedex_index(i, DEX_FLAG_CHECK_CAUGHT);
329 321
             if (!first && (pokedex_context->lookup[i].seen)) {
330 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 324
                 first = true;
333 325
             }
334 326
         }
@@ -413,7 +405,7 @@ void pdex_loop(u8 tid) {
413 405
 
414 406
         pdex_pokeballs_init();
415 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 409
         pdex_load_sc();
418 410
         pdex_update_page_full();
419 411
 

+ 8
- 0
src/pokedex/pokedex_common.c Visa fil

@@ -49,6 +49,14 @@ const struct BgConfig pdex_bg_config[4] = {
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 60
 struct TextColor pdex_text_color = {0, 1, 2};
53 61
 
54 62
 void pdex_vblank_handler(void) {

+ 2
- 0
src/pokedex/pokedex_common.h Visa fil

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

+ 67
- 13
src/pokedex/pokedex_detail.c Visa fil

@@ -5,23 +5,23 @@
5 5
 #include "pokedex_common.h"
6 6
 
7 7
 #define TB_PKNAME 0
8
-#define TB_PKSIZE 2
9
-#define TB_PKWEIGHT 3
8
+#define TB_PKSIZE 1
10 9
 #define TB_DESC 2
11 10
 
12 11
 #define TB_PKNAME_W 30
13
-#define TB_SW_W 20
12
+#define TB_SW_W 12
14 13
 
15 14
 extern pchar pdex_entry_debug[];
16 15
 extern pchar pdex_str_size[];
17 16
 extern pchar pdex_str_weight[];
18 17
 extern pchar pdex_str_size_unit[];
19 18
 extern pchar pdex_str_weight_unit[];
19
+extern pchar pdex_str_comma[];
20 20
 
21 21
 struct TextboxTemplate dexdetail_boxes[] = {
22 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 26
     {.bg_id = 0xFF},
27 27
 };
@@ -29,14 +29,71 @@ struct TextboxTemplate dexdetail_boxes[] = {
29 29
 void dexdetail_load_pokemon(u16 dexindex) {
30 30
     u16 species = pokedex_context->lookup[dexindex].species;
31 31
     rboxid_clear_pixels(TB_PKNAME, 0);
32
+    rboxid_clear_pixels(TB_PKSIZE, 0);
33
+    rboxid_clear_pixels(TB_DESC, 0);
32 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 38
     pchar *strType = &pokedex_data[dexindex].category_name[0];
36 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 99
 void dexdetail_loop(u8 tid) {
@@ -44,11 +101,7 @@ void dexdetail_loop(u8 tid) {
44 101
     switch (pokedex_context->state) {
45 102
     case 0:
46 103
         bgid_send_tilemap(2);
47
-        // rboxid_fill_rectangle(4, 1, 0, 0, 28 * 8, 20 * 8);
48 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 106
         palette_bg_faded_fill_black();
54 107
         pokedex_context->state++;
@@ -86,6 +139,7 @@ void dexdetail_load(void) {
86 139
     pdex_vram_setup();
87 140
     dexdetail_load_gfx();
88 141
     pokedex_context->state = 0;
142
+    pokedex_context->detail_pokemon_oam = -1;
89 143
     task_add(dexdetail_loop, 0);
90 144
     set_callback2(pdex_cb_handler);
91 145
 }

+ 3
- 0
src/pokedex/pokedex_region.c Visa fil

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

+ 5
- 0
src/pokedex/pokedex_string.s Visa fil

@@ -36,6 +36,11 @@ pdex_str_weight_unit:
36 36
     .string LAN_DE "kg"
37 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 44
 .global pdex_str_empty
40 45
 pdex_str_empty:
41 46
     .string LAN_DE "----------"