dragonflysots před 6 roky
rodič
revize
0f193e727e

+ 2
- 2
data/trainer/ts_pal.s Zobrazit soubor

@@ -2,8 +2,8 @@
2 2
 .thumb
3 3
 .text
4 4
 
5
-.global ts_pal_maintable
6
-ts_pal_maintable:
5
+.global trainer_battle_palettes
6
+trainer_battle_palettes:
7 7
 
8 8
 .word ts_0000Pal
9 9
 .hword 0

+ 2
- 2
data/trainer/ts_tiles.s Zobrazit soubor

@@ -2,8 +2,8 @@
2 2
 .thumb
3 3
 .text
4 4
 
5
-.global ts_image_maintable
6
-ts_image_maintable:
5
+.global trainer_battle_sprites
6
+trainer_battle_sprites:
7 7
 
8 8
 .word ts_0000Tiles
9 9
 .hword 0x0800

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 07b29e81680ced24934c10161ff706c0949e4723
1
+Subproject commit c407f7e79467a4681f5327d549e4773751f13acb

+ 1
- 1
patches/game_engine/quick_hacks.asm Zobrazit soubor

@@ -96,6 +96,6 @@ bx r0
96 96
 .pool
97 97
 
98 98
 .org 0x0812EB2C
99
-ldr r0, =launch_tutorial|1
99
+ldr r0, =settings_launch|1
100 100
 bx r0
101 101
 .pool

+ 20
- 20
patches/trainer_sprites/images.asm Zobrazit soubor

@@ -1,60 +1,60 @@
1 1
 .org 0x0803473C 
2
-.word ts_image_maintable
2
+.word trainer_battle_sprites
3 3
  
4 4
 .org 0x080347A4 
5
-.word ts_image_maintable
5
+.word trainer_battle_sprites
6 6
  
7 7
 .org 0x08037E8C 
8
-.word ts_image_maintable
8
+.word trainer_battle_sprites
9 9
  
10 10
 .org 0x08038060 
11
-.word ts_image_maintable
11
+.word trainer_battle_sprites
12 12
  
13 13
 .org 0x0803CAE8 
14
-.word ts_image_maintable
14
+.word trainer_battle_sprites
15 15
  
16 16
 .org 0x080838E4 
17
-.word ts_image_maintable
17
+.word trainer_battle_sprites
18 18
  
19 19
 .org 0x08083928 
20
-.word ts_image_maintable
20
+.word trainer_battle_sprites
21 21
  
22 22
 .org 0x0810BC3C 
23
-.word ts_image_maintable
23
+.word trainer_battle_sprites
24 24
  
25 25
 .org 0x08158528 
26
-.word ts_image_maintable
26
+.word trainer_battle_sprites
27 27
 
28 28
 
29 29
 .org 0x0803474C 
30
-.word ts_pal_maintable
30
+.word trainer_battle_palettes
31 31
  
32 32
 .org 0x080347A0 
33
-.word ts_pal_maintable
33
+.word trainer_battle_palettes
34 34
  
35 35
 .org 0x08037E88 
36
-.word ts_pal_maintable
36
+.word trainer_battle_palettes
37 37
  
38 38
 .org 0x0803805C 
39
-.word ts_pal_maintable
39
+.word trainer_battle_palettes
40 40
  
41 41
 .org 0x0803CAE4 
42
-.word ts_pal_maintable
42
+.word trainer_battle_palettes
43 43
  
44 44
 .org 0x080838E0 
45
-.word ts_pal_maintable
45
+.word trainer_battle_palettes
46 46
  
47 47
 .org 0x0808392C 
48
-.word ts_pal_maintable
48
+.word trainer_battle_palettes
49 49
  
50 50
 .org 0x0810BD1C 
51
-.word ts_pal_maintable
51
+.word trainer_battle_palettes
52 52
  
53 53
 .org 0x0810BD3C 
54
-.word ts_pal_maintable
54
+.word trainer_battle_palettes
55 55
  
56 56
 .org 0x0810BD7C 
57
-.word ts_pal_maintable
57
+.word trainer_battle_palettes
58 58
  
59 59
 .org 0x08158524 
60
-.word ts_pal_maintable
60
+.word trainer_battle_palettes

+ 3
- 0
src/include/scene.h Zobrazit soubor

@@ -10,5 +10,8 @@ const struct BgConfig scene_default_config[4];
10 10
 void scene_default_cb_handler(void);
11 11
 const struct TextColor scene_default_text_color;
12 12
 void scene_free_bg_maps(void);
13
+void scene_default_vblank(void);
14
+
15
+void scene_vram_default_init(void);
13 16
 
14 17
 #endif

+ 0
- 3
src/overworld/dns/dns.c Zobrazit soubor

@@ -7,9 +7,6 @@
7 7
 #define DNS_SEC_PAL_START 224
8 8
 #define DNS_SEC_PAL_START_C (DNS_SEC_PAL_START / 2)
9 9
 
10
-#define crgb5(r,g,b) (union Color)(((u16)(((b) << 10) | ((g)<<5) | ((r)))))
11
-#define rgb82rgb5(r,g,b) (crgb5(r/8, g/8, b/8))
12
-
13 10
 const union Color dns_color_times[5] = {
14 11
     rgb82rgb5(70, 70, 196),
15 12
     rgb82rgb5(70, 70, 196),

+ 1
- 7
src/specials/scenes/blackboard_intro.c Zobrazit soubor

@@ -16,12 +16,6 @@ const u16 blackboard_text_pal[] =
16 16
                              rgb5(255, 255, 255), rgb5(255, 255, 255), rgb5(255, 255, 255), rgb5(255, 255, 255),
17 17
                              rgb5(255, 255, 255), rgb5(255, 255, 255), rgb5(255, 255, 255), rgb5(255, 255, 255)};
18 18
 
19
-void blackboard_vblank(void) {
20
-    gpu_sprites_upload();
21
-    copy_queue_process();
22
-    gpu_pal_upload();
23
-}
24
-
25 19
 void blackboard_loop(u8 id) {
26 20
     switch(tasks[id].priv[0]){
27 21
         case 0:
@@ -78,7 +72,7 @@ void blackboard_load_gfx(void){
78 72
 }
79 73
 
80 74
 void blackboard_start(void) {
81
-    scene_vram_init(blackboard_vblank, &scene_default_config[0]);
75
+    scene_vram_default_init();
82 76
     bgid_set_tilemap(0, malloc(0x800));
83 77
     bgid_set_tilemap(2, malloc(0x800));
84 78
     blackboard_load_gfx();

+ 14
- 0
src/specials/scenes/scene_common.c Zobrazit soubor

@@ -47,6 +47,12 @@ const struct BgConfig scene_default_config[4] = {
47 47
     },
48 48
 };
49 49
 
50
+void scene_default_vblank(void) {
51
+    gpu_sprites_upload();
52
+    copy_queue_process();
53
+    gpu_pal_upload();
54
+}
55
+
50 56
 const struct TextColor scene_default_text_color = {0, 1, 2};
51 57
 
52 58
 void scene_default_cb_handler(void) {
@@ -94,6 +100,14 @@ void scene_vram_init(SuperCallback vblank_handler, const struct BgConfig* config
94 100
     bgid_mod_x_offset(3, 0, 0);
95 101
     bgid_mod_y_offset(3, 0, 0);
96 102
 
103
+    //windows
104
+
105
+    lcd_io_set(REG_ID_WININ, WININ_BUILD(WIN_ENALL_NO_BLD,WIN_ENALL_NO_BLD));
106
+    lcd_io_set(REG_ID_WINOUT, WINOUT_BUILD(WIN_ENALL_NO_BLD,WIN_ENALL_BLD));
97 107
     vblank_handler_set(vblank_handler);
98 108
     interrupts_enable(INTERRUPT_VBLANK);
109
+}
110
+
111
+void scene_vram_default_init(void) {
112
+    scene_vram_init(scene_default_vblank, &scene_default_config[0]);
99 113
 }

+ 537
- 0
src/specials/scenes/settings_intro.c Zobrazit soubor

@@ -0,0 +1,537 @@
1
+#include <pokeagb/pokeagb.h>
2
+#include <scene_intro/genderChoose.h>
3
+#include <scene_intro/gameModeChoose.h>
4
+#include <scene.h>
5
+#include <agb_debug.h>
6
+#include <constants/pkmns.h>
7
+
8
+extern u8 settings_gender_script[];
9
+extern u8 settings_gender_script_sure[];
10
+extern u8 settings_name_sure[];
11
+extern u8 intro_choose_difficulty[];
12
+extern u8 intro_sure_difficulty[];
13
+
14
+const struct TextboxTemplate settings_gender_box[] = {
15
+    {.bg_id = 0, .x = 2, .y = 15, .width = 26, .height = 4, .pal_id = 15, .charbase = 0x198},
16
+};
17
+
18
+const struct Coords16 male_position = {.x=100, .y=80};
19
+const struct Coords16 female_position = {.x=205, .y=80};
20
+
21
+const struct Coords16 difficulty_positions[3] = {{.x=85,.y=95}, {.x=155,.y=90}, {.x=230,.y=84}};
22
+
23
+void launch_tutorial(void);
24
+
25
+#define SELECTED_IDX 7
26
+#define BINDEX_MALE 1
27
+#define BINDEX_FEMALE 2
28
+
29
+#define BINDEX_EASY 1
30
+#define BINDEX_MED 2
31
+#define BINDEX_HARD 3
32
+
33
+#define INNER_COLOR rgb82rgb5(0x80,0x80,0x80)
34
+#define OUTER_COLOR rgb82rgb5(0x60,0x60,0x60)
35
+
36
+#define INNER_COLOR_SEL rgb82rgb5(0xA6,0xA6,0xA6)
37
+#define OUTER_COLOR_SEL INNER_COLOR
38
+
39
+#define OUTER1_IDX 8
40
+#define OUTER2_IDX 10
41
+#define OUTER3_IDX 12
42
+#define INNER1_IDX 9
43
+#define INNER2_IDX 11
44
+#define INNER3_IDX 13
45
+
46
+#define EASY_MON PKMN_PICHU
47
+#define MED_MON PKMN_PIKACHU
48
+#define HARD_MON PKMN_RAICHU
49
+
50
+const union Color lighterPalette[] = {OUTER_COLOR_SEL, INNER_COLOR_SEL};
51
+const union Color darkerPalette[] = {OUTER_COLOR, INNER_COLOR};
52
+
53
+extern pchar name_rival_male[5];
54
+extern pchar name_rival_female[5];
55
+
56
+void settings_launch(void);
57
+void settings_mode_launch(void);
58
+
59
+void settings_switch_tinted(u8 baseIndex, u8 tid) {
60
+    u8 currentPal = objects[tasks[tid].priv[baseIndex]].final_oam.palette_num;
61
+    objects[tasks[tid].priv[baseIndex]].final_oam.palette_num = tasks[tid].priv[baseIndex+2];
62
+    tasks[tid].priv[baseIndex+2]=currentPal;
63
+}
64
+
65
+void settings_switch_mode_tinted(u8 baseIndex, u8 tid) {
66
+    u8 currentPal = objects[tasks[tid].priv[baseIndex]].final_oam.palette_num;
67
+    objects[tasks[tid].priv[baseIndex]].final_oam.palette_num = tasks[tid].priv[baseIndex+3];
68
+    tasks[tid].priv[baseIndex+3]=currentPal;
69
+}
70
+
71
+void settings_loop(u8 id) {
72
+    switch(tasks[id].priv[0]){
73
+        case 0:
74
+            bgid_send_tilemap(2);
75
+            bgid_send_tilemap(0);
76
+            rboxid_clear_pixels(0, 0);
77
+            palette_bg_faded_fill_black();
78
+            tasks[id].priv[0]++;
79
+        break;
80
+        case 1:
81
+            gpu_sync_bg_show(0);
82
+            gpu_sync_bg_hide(1);
83
+            gpu_sync_bg_hide(3);
84
+
85
+            gpu_sync_bg_show(2);
86
+            settings_switch_tinted(BINDEX_FEMALE, id);
87
+            gpu_pal_apply(&lighterPalette[0], OUTER1_IDX, 4);
88
+            gpu_pal_apply(&darkerPalette[0], OUTER2_IDX, 4);
89
+            objects[tasks[id].priv[1]].final_oam.affine_mode = 0;
90
+            objects[tasks[id].priv[2]].final_oam.affine_mode = 0;
91
+            objects[tasks[id].priv[1]].pos1 = male_position;
92
+            objects[tasks[id].priv[2]].pos1 = female_position;
93
+            fade_screen(0xFFFFFFFF, 1, 16, 0, 0x0000);
94
+            tasks[id].priv[0]++;
95
+        break;
96
+        case 2:
97
+            if (!pal_fade_control.active)
98
+                tasks[id].priv[0]++;
99
+        break;
100
+        case 3:
101
+            script_env_init_script(&settings_gender_script[0]);
102
+            tasks[id].priv[0]++; 
103
+        break;
104
+        case 4:
105
+            if(script_env_1.mode == SCRIPT_EXECUTE_MODE_PAUSED)
106
+                tasks[id].priv[0]++;
107
+        break;
108
+        case 5:
109
+            if(super.buttons_new & KEY_LEFT){
110
+                if(tasks[id].priv[SELECTED_IDX] == 1) {
111
+                    tasks[id].priv[SELECTED_IDX] = 0;
112
+                    m4aSongNumStart(5);
113
+                    settings_switch_tinted(BINDEX_FEMALE, id);
114
+                    settings_switch_tinted(BINDEX_MALE, id);
115
+                    gpu_pal_apply(&lighterPalette[0], OUTER1_IDX, 4);
116
+                    gpu_pal_apply(&darkerPalette[0], OUTER2_IDX, 4);
117
+                }
118
+            }
119
+            if(super.buttons_new & KEY_RIGHT){
120
+                if(tasks[id].priv[SELECTED_IDX] == 0) {
121
+                    tasks[id].priv[SELECTED_IDX] = 1;
122
+                    m4aSongNumStart(5);
123
+                    settings_switch_tinted(BINDEX_FEMALE, id);
124
+                    settings_switch_tinted(BINDEX_MALE, id);
125
+                    gpu_pal_apply(&lighterPalette[0], OUTER2_IDX, 4);
126
+                    gpu_pal_apply(&darkerPalette[0], OUTER1_IDX, 4);
127
+                }
128
+            }
129
+            if(super.buttons_new & KEY_A) {
130
+                tasks[id].priv[0]++;
131
+                m4aSongNumStart(5);
132
+            }
133
+
134
+        break;
135
+        case 6:
136
+            if(tasks[id].priv[SELECTED_IDX] == 1)
137
+                var_set(0x800D, 1);
138
+            else
139
+                var_set(0x800D, 0);
140
+            script_env_init_script(&settings_gender_script_sure[0]);
141
+            tasks[id].priv[0]++;
142
+        break;
143
+        case 7:
144
+            if(script_env_1.mode == SCRIPT_EXECUTE_MODE_PAUSED) {
145
+                if(var_load(0x800D) == 0)
146
+                    tasks[id].priv[0] = 3;
147
+                else
148
+                    tasks[id].priv[0]++;
149
+            }
150
+            break;
151
+        case 8:
152
+            if(tasks[id].priv[SELECTED_IDX] == 1) {
153
+                saveblock2->gender = GENDER_FEMALE;
154
+                pstrcpy(saveblock1->rival_name, &name_rival_male[0]);
155
+            }
156
+            else {
157
+                saveblock2->gender = GENDER_MALE;
158
+                pstrcpy(saveblock1->rival_name, &name_rival_female[0]);
159
+            }
160
+            tasks[id].priv[0]++;
161
+            break;
162
+        case 9:
163
+            var_set(0x8000, 1);
164
+            scene_free_bg_maps();
165
+            task_del(id);
166
+            name_chooser_enter(0, &saveblock2->name[0], saveblock2->gender, 0, 0, settings_launch);
167
+        default:
168
+        break;
169
+    }
170
+}
171
+
172
+void settings_loop_after_name(u8 id) {
173
+    switch(tasks[id].priv[0]){
174
+        case 0:
175
+            bgid_send_tilemap(2);
176
+            bgid_send_tilemap(0);
177
+            rboxid_clear_pixels(0, 0);
178
+            palette_bg_faded_fill_black();
179
+            tasks[id].priv[0]++;
180
+        break;
181
+        case 1:
182
+            gpu_sync_bg_show(0);
183
+            gpu_sync_bg_hide(1);
184
+            gpu_sync_bg_hide(3);
185
+
186
+            gpu_sync_bg_show(2);
187
+            if(saveblock2->gender == GENDER_MALE) {
188
+                settings_switch_tinted(BINDEX_FEMALE, id);
189
+                gpu_pal_apply(&lighterPalette[0], OUTER1_IDX, 4);
190
+                gpu_pal_apply(&darkerPalette[0], OUTER2_IDX, 4);
191
+                tasks[id].priv[SELECTED_IDX] = 0;
192
+            }
193
+            else {
194
+                settings_switch_tinted(BINDEX_MALE, id);
195
+                gpu_pal_apply(&lighterPalette[0], OUTER2_IDX, 4);
196
+                gpu_pal_apply(&darkerPalette[0], OUTER1_IDX, 4);
197
+                tasks[id].priv[SELECTED_IDX] = 1;
198
+            }
199
+
200
+            objects[tasks[id].priv[1]].final_oam.affine_mode = 0;
201
+            objects[tasks[id].priv[2]].final_oam.affine_mode = 0;
202
+            objects[tasks[id].priv[1]].pos1 = male_position;
203
+            objects[tasks[id].priv[2]].pos1 = female_position;
204
+            fade_screen(0xFFFFFFFF, 1, 16, 0, 0x0000);
205
+            tasks[id].priv[0]++;
206
+        break;
207
+        case 2:
208
+            if (!pal_fade_control.active)
209
+                tasks[id].priv[0]++;
210
+        break;
211
+        case 3:
212
+            if(saveblock2->name[0] == 0){
213
+                if(saveblock2->gender == GENDER_MALE){
214
+                    pstrcpy(saveblock2->name, name_rival_male);
215
+                } else {
216
+                    pstrcpy(saveblock2->name, name_rival_female);
217
+                }
218
+            }
219
+            script_env_init_script(&settings_name_sure[0]);
220
+            tasks[id].priv[0]++;
221
+        break;
222
+        case 4:
223
+            if(script_env_1.mode == SCRIPT_EXECUTE_MODE_PAUSED) {
224
+                if(var_load(0x800D) == 1) {
225
+                    tasks[id].priv[0]++;
226
+                    fade_screen(0xFFFFFFFF, 0, 0, 16, 0x0000);
227
+                } else {
228
+                    saveblock2->name[0] = 0;
229
+                    scene_free_bg_maps();
230
+                    task_del(id);
231
+                    name_chooser_enter(0, &saveblock2->name[0], saveblock2->gender, 0, 0, settings_launch);
232
+                }
233
+
234
+            }
235
+        break;
236
+        case 5:
237
+            if(!pal_fade_control.active) {
238
+                tasks[id].priv[0]++;
239
+                var_set(0x8001, 1);
240
+                scene_free_bg_maps();
241
+                task_del(id);
242
+                settings_mode_launch();
243
+            }
244
+        default:
245
+        break;
246
+    }
247
+}
248
+
249
+void settings_set_stuff_before_start(void) {
250
+    //set some stuff if needed
251
+}
252
+
253
+void settings_mode_loop(u8 id) {
254
+    switch(tasks[id].priv[0])
255
+    {
256
+        case 0:
257
+            bgid_send_tilemap(2);
258
+            bgid_send_tilemap(0);
259
+            rboxid_clear_pixels(0, 0);
260
+            palette_bg_faded_fill_black();
261
+            tasks[id].priv[0]++;
262
+        break;
263
+        case 1:
264
+            gpu_sync_bg_show(0);
265
+            gpu_sync_bg_hide(1);
266
+            gpu_sync_bg_hide(3);
267
+            gpu_sync_bg_show(2);
268
+            tasks[id].priv[SELECTED_IDX] = 1;
269
+            settings_switch_mode_tinted(BINDEX_EASY, id);
270
+            settings_switch_mode_tinted(BINDEX_HARD, id);
271
+            gpu_pal_apply(&darkerPalette[0], OUTER1_IDX, 4);
272
+            gpu_pal_apply(&lighterPalette[0], OUTER2_IDX, 4);
273
+            gpu_pal_apply(&darkerPalette[0], OUTER3_IDX, 4);
274
+            objects[tasks[id].priv[1]].final_oam.affine_mode = 0;
275
+            objects[tasks[id].priv[2]].final_oam.affine_mode = 0;
276
+            objects[tasks[id].priv[3]].final_oam.affine_mode = 0;
277
+            objects[tasks[id].priv[1]].pos1 = difficulty_positions[0];
278
+            objects[tasks[id].priv[2]].pos1 = difficulty_positions[1];
279
+            objects[tasks[id].priv[3]].pos1 = difficulty_positions[2];
280
+            fade_screen(0xFFFFFFFF, 1, 16,0, 0x0000);
281
+            tasks[id].priv[0]++;
282
+        break;
283
+        case 2:
284
+            script_env_init_script(&intro_choose_difficulty[0]);
285
+            tasks[id].priv[0]++;
286
+        break;
287
+        case 3:
288
+            if(script_env_1.mode == SCRIPT_EXECUTE_MODE_PAUSED)
289
+                tasks[id].priv[0]++;
290
+        break;
291
+        case 4:
292
+            if(super.buttons_new & KEY_LEFT) {
293
+                if(tasks[id].priv[SELECTED_IDX] > 0) {
294
+                    settings_switch_mode_tinted(BINDEX_EASY + tasks[id].priv[SELECTED_IDX], id);
295
+                    gpu_pal_apply(&darkerPalette[0], OUTER1_IDX + 2*tasks[id].priv[SELECTED_IDX], 4);
296
+                    tasks[id].priv[SELECTED_IDX]--;
297
+                    settings_switch_mode_tinted(BINDEX_EASY + tasks[id].priv[SELECTED_IDX], id);
298
+                    gpu_pal_apply(&lighterPalette[0], OUTER1_IDX + 2*tasks[id].priv[SELECTED_IDX], 4);
299
+                    m4aSongNumStart(5);
300
+                }
301
+            }
302
+            if(super.buttons_new & KEY_RIGHT) {
303
+                if(tasks[id].priv[SELECTED_IDX] < 2) {
304
+                    settings_switch_mode_tinted(BINDEX_EASY + tasks[id].priv[SELECTED_IDX], id);
305
+                    gpu_pal_apply(&darkerPalette[0], OUTER1_IDX + 2*tasks[id].priv[SELECTED_IDX], 4);
306
+                    tasks[id].priv[SELECTED_IDX]++;
307
+                    settings_switch_mode_tinted(BINDEX_EASY + tasks[id].priv[SELECTED_IDX], id);
308
+                    gpu_pal_apply(&lighterPalette[0], OUTER1_IDX + 2*tasks[id].priv[SELECTED_IDX], 4);
309
+                    m4aSongNumStart(5);
310
+                }
311
+            }
312
+            if(super.buttons_new & KEY_A) {
313
+                m4aSongNumStart(5);
314
+                var_set(0x8002, tasks[id].priv[SELECTED_IDX]);
315
+                switch(tasks[id].priv[SELECTED_IDX])
316
+                {
317
+                    case 0:
318
+                        var_set(0x8003, EASY_MON);
319
+                    break;
320
+                    case 1:
321
+                        var_set(0x8003, MED_MON);
322
+                    break;
323
+                    case 2:
324
+                        var_set(0x8003, HARD_MON);
325
+                    break;
326
+                    default:
327
+                    dprintf("assert 0 reached!\n");
328
+                }
329
+                script_env_init_script(&intro_sure_difficulty[0]);
330
+                tasks[id].priv[0]++;
331
+            }
332
+        break;
333
+        case 5:
334
+            if(script_env_1.mode == SCRIPT_EXECUTE_MODE_PAUSED)
335
+                tasks[id].priv[0]++;
336
+        break;
337
+        case 6:
338
+            if(var_load(0x800D) == 1) {
339
+                settings_set_stuff_before_start();
340
+                set_callback2(c2_new_game);
341
+            } else {
342
+                tasks[id].priv[0] = 2;
343
+            }
344
+        break;
345
+        default:
346
+        break;
347
+    }
348
+}
349
+
350
+void* settings_load_tinted_palette(struct SpritePalette *pal) {
351
+    union Color *tintedPal = malloc(32);
352
+    LZ77UnCompWram(pal->data, tintedPal);
353
+    for(u8 i = 0; i<16;++i){
354
+        tintedPal[i].components.r = tintedPal[i].components.r / 3;
355
+        tintedPal[i].components.g = tintedPal[i].components.g / 3;
356
+        tintedPal[i].components.b = tintedPal[i].components.b / 3;
357
+    }
358
+    return tintedPal;
359
+}
360
+
361
+const struct OamData trainer_pkmn_oam = {.size = 3, .affine_mode = 2, .priority=1};
362
+
363
+#define TRAINER_MALE 135
364
+#define TRAINER_FEMALE 136
365
+
366
+void settings_load_gfx(void) {
367
+    lz77UnCompVram(genderChooseTiles, (void *)0x0600C000);
368
+    LZ77UnCompWram(genderChooseMap, bgid_get_tilemap(2));
369
+
370
+    gpu_pal_apply_compressed(genderChoosePal, 0, 32);
371
+}
372
+
373
+void settings_mode_load_gfx(void) {
374
+    lz77UnCompVram(gameModeChooseTiles, (void *)0x0600C000);
375
+    LZ77UnCompWram(gameModeChooseMap, bgid_get_tilemap(2));
376
+    gpu_pal_apply_compressed(gameModeChoosePal,0,32);
377
+}
378
+
379
+void settings_mode_spawn_main_task(void) {
380
+
381
+    struct Template first_pkmn_sprite = {
382
+        .tiles_tag = 0x1337,
383
+        .pal_tag = 0x1337,
384
+        .oam = &trainer_pkmn_oam,
385
+        .animation = SPRITE_NO_ANIMATION,
386
+        .graphics = &pokemon_graphics_front[EASY_MON],
387
+        .rotscale = SPRITE_NO_ROTSCALE,
388
+        .callback = oac_nullsub
389
+    };
390
+    struct Template second_pkmn_sprite = {
391
+        .tiles_tag = 0x1338,
392
+        .pal_tag = 0x1338,
393
+        .oam = &trainer_pkmn_oam,
394
+        .animation = SPRITE_NO_ANIMATION,
395
+        .graphics = &pokemon_graphics_front[MED_MON],
396
+        .rotscale = SPRITE_NO_ROTSCALE,
397
+        .callback = oac_nullsub
398
+    };
399
+    struct Template third_pkmn_sprite = {
400
+        .tiles_tag = 0x1339,
401
+        .pal_tag = 0x1339,
402
+        .oam = &trainer_pkmn_oam,
403
+        .animation = SPRITE_NO_ANIMATION,
404
+        .graphics = &pokemon_graphics_front[HARD_MON],
405
+        .rotscale = SPRITE_NO_ROTSCALE,
406
+        .callback = oac_nullsub
407
+    };
408
+    struct SpritePalette firstPal = {.tag = 0x1337, .data = pokemon_palette_normal[EASY_MON].data};
409
+    struct SpritePalette secondPal = {.tag = 0x1338, .data = pokemon_palette_normal[MED_MON].data};
410
+    struct SpritePalette thirdPal = {.tag = 0x1339, .data = pokemon_palette_normal[HARD_MON].data};
411
+    struct SpriteTiles firstTiles = {.tag = 0x1337, .data = pokemon_graphics_front[EASY_MON].data, .size = 64*32};
412
+    struct SpriteTiles secondTiles = {.tag = 0x1338, .data = pokemon_graphics_front[MED_MON].data, .size = 64*32};
413
+    struct SpriteTiles thirdTiles = {.tag = 0x1339, .data = pokemon_graphics_front[HARD_MON].data, .size = 64*32};
414
+
415
+    gpu_pal_decompress_alloc_tag_and_upload(&firstPal);
416
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&firstTiles);
417
+    gpu_pal_decompress_alloc_tag_and_upload(&secondPal);
418
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&secondTiles);
419
+    gpu_pal_decompress_alloc_tag_and_upload(&thirdPal);
420
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&thirdTiles);
421
+
422
+    void* firstTintedPal = settings_load_tinted_palette(&firstPal);
423
+    void* secondTintedPal = settings_load_tinted_palette(&secondPal);
424
+    void* thirdTintedPal = settings_load_tinted_palette(&thirdPal);
425
+    struct SpritePalette firstTinted = {.tag = firstPal.tag + 3, .data = firstTintedPal};
426
+    struct SpritePalette secondTinted = {.tag = secondPal.tag + 3, .data = secondTintedPal};
427
+    struct SpritePalette thirdTinted = {.tag = thirdPal.tag + 3, .data = thirdTintedPal};
428
+
429
+    gpu_pal_obj_alloc_tag_and_apply(&firstTinted);
430
+    gpu_pal_obj_alloc_tag_and_apply(&secondTinted);
431
+    gpu_pal_obj_alloc_tag_and_apply(&thirdTinted);
432
+    free(firstTintedPal);
433
+    free(secondTintedPal);
434
+    free(thirdTintedPal);
435
+    u8 firstIdx = gpu_pal_tags_index_of(firstTiles.tag + 3);
436
+    u8 secondIdx = gpu_pal_tags_index_of(secondTiles.tag + 3);
437
+    u8 thirdIdx = gpu_pal_tags_index_of(thirdTiles.tag + 3);
438
+
439
+    u8 first = template_instanciate_forward_search(&first_pkmn_sprite, 50,50, 1);
440
+    u8 second = template_instanciate_forward_search(&second_pkmn_sprite, 100,50,1);
441
+    u8 third = template_instanciate_forward_search(&third_pkmn_sprite, 100,50,1);
442
+
443
+    u8 tid = task_add(settings_mode_loop, 0);
444
+    dprintf("task added\n");
445
+    tasks[tid].priv[0] = 0;
446
+    tasks[tid].priv[1] = first;
447
+    tasks[tid].priv[2] = second;
448
+    tasks[tid].priv[3] = third;
449
+    tasks[tid].priv[4] = firstIdx;
450
+    tasks[tid].priv[5] = secondIdx;
451
+    tasks[tid].priv[6] = thirdIdx;
452
+}
453
+
454
+void settings_spawn_main_task(void) {
455
+
456
+    struct Template trainer_sprite_male = {
457
+        .tiles_tag = trainer_battle_sprites[TRAINER_MALE].tag,
458
+        .pal_tag = trainer_battle_palettes[TRAINER_MALE].tag,
459
+        .oam = &trainer_pkmn_oam,
460
+        .animation = SPRITE_NO_ANIMATION,
461
+        .graphics = &trainer_battle_sprites[TRAINER_MALE],
462
+        .rotscale = SPRITE_NO_ROTSCALE,
463
+        .callback = oac_nullsub
464
+    };
465
+
466
+    struct Template trainer_sprite_female = {
467
+        .tiles_tag = trainer_battle_sprites[TRAINER_FEMALE].tag,
468
+        .pal_tag = trainer_battle_palettes[TRAINER_FEMALE].tag,
469
+        .oam = &trainer_pkmn_oam,
470
+        .animation = SPRITE_NO_ANIMATION,
471
+        .graphics = &trainer_battle_sprites[TRAINER_FEMALE],
472
+        .rotscale = SPRITE_NO_ROTSCALE,
473
+        .callback = oac_nullsub
474
+    };
475
+    gpu_pal_decompress_alloc_tag_and_upload(&trainer_battle_palettes[TRAINER_MALE]);
476
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&trainer_battle_sprites[TRAINER_MALE]);
477
+    gpu_pal_decompress_alloc_tag_and_upload(&trainer_battle_palettes[TRAINER_FEMALE]);
478
+    gpu_tile_obj_decompress_alloc_tag_and_upload(&trainer_battle_sprites[TRAINER_FEMALE]);
479
+
480
+    void* maleTintedPal = settings_load_tinted_palette(&trainer_battle_palettes[TRAINER_MALE]);
481
+    void* femaleTintedPal = settings_load_tinted_palette(&trainer_battle_palettes[TRAINER_FEMALE]);
482
+    struct SpritePalette maleTinted = {.tag = trainer_battle_sprites[TRAINER_MALE].tag + 2, .data = maleTintedPal};
483
+    struct SpritePalette femaleTinted = {.tag = trainer_battle_sprites[TRAINER_FEMALE].tag + 2, .data = femaleTintedPal};
484
+    gpu_pal_obj_alloc_tag_and_apply(&maleTinted);
485
+    gpu_pal_obj_alloc_tag_and_apply(&femaleTinted);
486
+    free(maleTintedPal);
487
+    free(femaleTintedPal);
488
+    u8 maleIdx = gpu_pal_tags_index_of(trainer_battle_sprites[TRAINER_MALE].tag + 2);
489
+    u8 femaleIdx = gpu_pal_tags_index_of(trainer_battle_sprites[TRAINER_FEMALE].tag + 2);
490
+
491
+    u8 male = template_instanciate_forward_search(&trainer_sprite_male, 50,50, 1);
492
+    u8 female = template_instanciate_forward_search(&trainer_sprite_female, 100,50,1);
493
+    u8 tid;
494
+    if(var_load(0x8000))
495
+        tid = task_add(settings_loop_after_name,0);
496
+    else
497
+        tid = task_add(settings_loop, 0);
498
+    
499
+    tasks[tid].priv[0] = 0;
500
+    tasks[tid].priv[1] = male;
501
+    tasks[tid].priv[2] = female;
502
+    tasks[tid].priv[3] = maleIdx;
503
+    tasks[tid].priv[4] = femaleIdx;
504
+}
505
+
506
+void settings_intro_c2(void) {
507
+    process_palfade();
508
+    task_exec();
509
+    objc_exec();
510
+    obj_sync_superstate();
511
+    tilemaps_sync();
512
+    script_execute_maybe();
513
+}
514
+
515
+void settings_launch(void) {
516
+    scene_vram_default_init();
517
+    lcd_io_set(REG_ID_DISPCNT, DISPCNT_OBJ | DISPCNT_OAM_1D);
518
+    rbox_init_from_templates(&settings_gender_box[0]);
519
+    remo_reset_acknowledgement_flags();
520
+    bgid_set_tilemap(0, malloc(0x800));
521
+    bgid_set_tilemap(2, malloc(0x800));
522
+    settings_load_gfx();
523
+    settings_spawn_main_task();
524
+    set_callback2(settings_intro_c2);
525
+}
526
+
527
+void settings_mode_launch(void) {
528
+    scene_vram_default_init();
529
+    lcd_io_set(REG_ID_DISPCNT, DISPCNT_OBJ | DISPCNT_OAM_1D);
530
+    rbox_init_from_templates(&settings_gender_box[0]);
531
+    remo_reset_acknowledgement_flags();
532
+    bgid_set_tilemap(0, malloc(0x800));
533
+    bgid_set_tilemap(2, malloc(0x800));
534
+    settings_mode_load_gfx();
535
+    settings_mode_spawn_main_task();
536
+    set_callback2(settings_intro_c2);
537
+}