DragonflySotS 7 years ago
parent
commit
36c843b922

+ 1
- 1
battle_engine

1
-Subproject commit a201b518834f0208efdb82ac95b08675f5279950
1
+Subproject commit 4a4fb7ac2ac3def1d4270796bdd2c04e8231d382

+ 1
- 1
g3headers

1
-Subproject commit bcc741a7ec06fc8a1b7c0e0b93a7f94f318a658e
1
+Subproject commit 21b52cecff9250d0bdaf18660b4bea40606a675e

+ 3
- 0
main.asm View File

31
 .include "patches/pokemon_data/pokedex_entries.asm"
31
 .include "patches/pokemon_data/pokedex_entries.asm"
32
 .include "patches/pokemon_data/pokemon_names.asm"
32
 .include "patches/pokemon_data/pokemon_names.asm"
33
 .include "patches/pokemon_data/limits.asm"
33
 .include "patches/pokemon_data/limits.asm"
34
+
34
 .include "patches/pokemon_data/pokemon_stats.asm"
35
 .include "patches/pokemon_data/pokemon_stats.asm"
35
 .include "patches/pokemon_data/moveset_table.asm"
36
 .include "patches/pokemon_data/moveset_table.asm"
36
 .include "patches/pokemon_data/pokemon_back_sprites.asm"
37
 .include "patches/pokemon_data/pokemon_back_sprites.asm"
37
 .include "patches/pokemon_data/pokemon_front_sprites.asm"
38
 .include "patches/pokemon_data/pokemon_front_sprites.asm"
38
 .include "patches/pokemon_data/pokemon_normal_pal.asm"
39
 .include "patches/pokemon_data/pokemon_normal_pal.asm"
39
 .include "patches/pokemon_data/pokemon_shiny_pal.asm"
40
 .include "patches/pokemon_data/pokemon_shiny_pal.asm"
41
+
40
 .include "patches/pokemon_data/pokemon_icons.asm"
42
 .include "patches/pokemon_data/pokemon_icons.asm"
43
+
41
 .include "patches/pokemon_data/pokemon_habitats.asm"
44
 .include "patches/pokemon_data/pokemon_habitats.asm"
42
 .include "patches/pokemon_data/pokemon_evolution.asm"
45
 .include "patches/pokemon_data/pokemon_evolution.asm"
43
 
46
 

+ 19
- 0
patches/graphics/char.asm View File

1
 .org 0x08234718
1
 .org 0x08234718
2
 .word hero_backspriteTiles
2
 .word hero_backspriteTiles
3
+.word 0x800
4
+.word hero_backspriteTiles + 0x800
5
+.word 0x800
6
+.word hero_backspriteTiles + 0x800*2
7
+.word 0x800
8
+.word hero_backspriteTiles + 0x800*3
9
+.word 0x800
10
+.word hero_backspriteTiles + 0x800*4
11
+.word 0x800
3
 
12
 
4
 .org 0x08239FA4
13
 .org 0x08239FA4
5
 .word hero_backspriteTiles
14
 .word hero_backspriteTiles
15
+.word 0x800
6
 
16
 
7
 .org 0x08239FD4
17
 .org 0x08239FD4
8
 .word hero_backspritePal
18
 .word hero_backspritePal
9
 
19
 
10
 .org 0x08234740
20
 .org 0x08234740
11
 .word heroine_backspriteTiles
21
 .word heroine_backspriteTiles
22
+.word 0x800
23
+.word heroine_backspriteTiles + 0x800
24
+.word 0x800
25
+.word heroine_backspriteTiles + 0x800*2
26
+.word 0x800
27
+.word heroine_backspriteTiles + 0x800*3
28
+.word 0x800
29
+.word heroine_backspriteTiles + 0x800*4
30
+.word 0x800
12
 
31
 
13
 .org 0x08239FAC
32
 .org 0x08239FAC
14
 .word heroine_backspriteTiles
33
 .word heroine_backspriteTiles

+ 3
- 1
patches/pokemon_data/pokemon_icons.asm View File

11
 .word icon_palette_table
11
 .word icon_palette_table
12
 
12
 
13
 .org 0x08091390
13
 .org 0x08091390
14
-.word icon_palette_table
14
+//.word icon_palette_table
15
+/* NOTE: this is referencing the icon template, overriding this will break stuff, for now we do not need to modify the template */
16
+
15
 
17
 
16
 .org 0x08096EC0
18
 .org 0x08096EC0
17
 .word icon_palette_table
19
 .word icon_palette_table

+ 66
- 57
src/battle_engine/battle_help.c View File

29
 
29
 
30
 /* === INCLUDE === */
30
 /* === INCLUDE === */
31
 
31
 
32
+#include <battle_common.h>
33
+#include <battle_custom_structs.h>
32
 #include <battle_help.h>
34
 #include <battle_help.h>
33
 #include <battle_locations.h>
35
 #include <battle_locations.h>
34
-#include <battle_custom_structs.h>
35
 #include <game_engine.h>
36
 #include <game_engine.h>
36
-#include <pkmn_types.h>
37
 #include <pkmn_abilities.h>
37
 #include <pkmn_abilities.h>
38
+#include <pkmn_attributes.h>
38
 #include <pkmn_item_effects.h>
39
 #include <pkmn_item_effects.h>
39
 #include <pkmn_items.h>
40
 #include <pkmn_items.h>
40
-#include <pkmn_attributes.h>
41
-#include <battle_common.h>
41
+#include <pkmn_types.h>
42
 
42
 
43
 /* === STATICS === */
43
 /* === STATICS === */
44
 
44
 
45
 /* from kds emerald battle engine upgrade */
45
 /* from kds emerald battle engine upgrade */
46
 u8 type_effectiveness_table[TYPE_FAIRY - 0x4][TYPE_FAIRY - 0x4] = {
46
 u8 type_effectiveness_table[TYPE_FAIRY - 0x4][TYPE_FAIRY - 0x4] = {
47
-    {10, 10, 10, 10, 10, 05, 10, 00, 05, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //normal
48
-    {20, 10, 05, 05, 10, 20, 05, 00, 20, 10, 10, 10, 10, 10, 05, 20, 10, 20, 05}, //fight
49
-    {10, 20, 10, 10, 10, 05, 20, 10, 05, 10, 10, 10, 20, 05, 10, 10, 10, 10, 10}, //flying
50
-    {10, 10, 10, 05, 05, 05, 10, 05, 00, 10, 10, 10, 20, 10, 10, 10, 10, 10, 20}, //poison
51
-    {10, 10, 00, 20, 10, 20, 05, 10, 20, 10, 20, 10, 05, 20, 10, 10, 10, 10, 10}, //ground
52
-    {10, 05, 20, 10, 05, 10, 20, 10, 05, 10, 20, 10, 10, 10, 10, 20, 10, 10, 10}, //rock
53
-    {10, 05, 05, 05, 10, 10, 10, 05, 05, 10, 05, 10, 20, 10, 20, 10, 10, 20, 05}, //bug
54
-    {00, 10, 10, 10, 10, 10, 10, 20, 10, 10, 10, 10, 10, 10, 20, 10, 10, 05, 10}, //ghost
55
-    {10, 10, 10, 10, 10, 20, 10, 10, 05, 10, 05, 05, 10, 05, 10, 20, 10, 10, 20}, //steel
56
-    {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, //egg
57
-    {10, 10, 10, 10, 10, 05, 20, 10, 20, 10, 05, 05, 20, 10, 10, 20, 05, 10, 10}, //fire
58
-    {10, 10, 10, 10, 20, 20, 10, 10, 10, 10, 20, 05, 05, 10, 10, 10, 05, 10, 10}, //water
59
-    {10, 10, 05, 05, 20, 20, 05, 10, 05, 10, 05, 20, 05, 10, 10, 10, 05, 10, 10}, //grass
60
-    {10, 10, 20, 10, 00, 10, 10, 10, 10, 10, 10, 20, 05, 05, 10, 10, 05, 10, 10}, //electric
61
-    {10, 20, 10, 20, 10, 10, 10, 10, 05, 10, 10, 10, 10, 10, 05, 10, 10, 00, 10}, //psychic
62
-    {10, 10, 20, 10, 20, 10, 10, 10, 05, 10, 05, 05, 20, 10, 10, 05, 20, 10, 10}, //ice
63
-    {10, 10, 10, 10, 10, 10, 10, 10, 05, 10, 10, 10, 10, 10, 10, 10, 20, 10, 00}, //dragon
64
-    {10, 05, 10, 10, 10, 10, 10, 20, 10, 10, 10, 10, 10, 10, 20, 10, 10, 05, 05}, //dark
65
-    {10, 20, 10, 05, 10, 10, 10, 10, 05, 10, 05, 10, 10, 10, 10, 10, 20, 20, 10} //fairy
47
+    {10, 10, 10, 10, 10, 05, 10, 00, 05, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, // normal
48
+    {20, 10, 05, 05, 10, 20, 05, 00, 20, 10, 10, 10, 10, 10, 05, 20, 10, 20, 05}, // fight
49
+    {10, 20, 10, 10, 10, 05, 20, 10, 05, 10, 10, 10, 20, 05, 10, 10, 10, 10, 10}, // flying
50
+    {10, 10, 10, 05, 05, 05, 10, 05, 00, 10, 10, 10, 20, 10, 10, 10, 10, 10, 20}, // poison
51
+    {10, 10, 00, 20, 10, 20, 05, 10, 20, 10, 20, 10, 05, 20, 10, 10, 10, 10, 10}, // ground
52
+    {10, 05, 20, 10, 05, 10, 20, 10, 05, 10, 20, 10, 10, 10, 10, 20, 10, 10, 10}, // rock
53
+    {10, 05, 05, 05, 10, 10, 10, 05, 05, 10, 05, 10, 20, 10, 20, 10, 10, 20, 05}, // bug
54
+    {00, 10, 10, 10, 10, 10, 10, 20, 10, 10, 10, 10, 10, 10, 20, 10, 10, 05, 10}, // ghost
55
+    {10, 10, 10, 10, 10, 20, 10, 10, 05, 10, 05, 05, 10, 05, 10, 20, 10, 10, 20}, // steel
56
+    {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, // egg
57
+    {10, 10, 10, 10, 10, 05, 20, 10, 20, 10, 05, 05, 20, 10, 10, 20, 05, 10, 10}, // fire
58
+    {10, 10, 10, 10, 20, 20, 10, 10, 10, 10, 20, 05, 05, 10, 10, 10, 05, 10, 10}, // water
59
+    {10, 10, 05, 05, 20, 20, 05, 10, 05, 10, 05, 20, 05, 10, 10, 10, 05, 10, 10}, // grass
60
+    {10, 10, 20, 10, 00, 10, 10, 10, 10, 10, 10, 20, 05, 05, 10, 10, 05, 10, 10}, // electric
61
+    {10, 20, 10, 20, 10, 10, 10, 10, 05, 10, 10, 10, 10, 10, 05, 10, 10, 00, 10}, // psychic
62
+    {10, 10, 20, 10, 20, 10, 10, 10, 05, 10, 05, 05, 20, 10, 10, 05, 20, 10, 10}, // ice
63
+    {10, 10, 10, 10, 10, 10, 10, 10, 05, 10, 10, 10, 10, 10, 10, 10, 20, 10, 00}, // dragon
64
+    {10, 05, 10, 10, 10, 10, 10, 20, 10, 10, 10, 10, 10, 10, 20, 10, 10, 05, 05}, // dark
65
+    {10, 20, 10, 05, 10, 10, 10, 10, 05, 10, 05, 10, 10, 10, 10, 10, 20, 20, 10}  // fairy
66
 };
66
 };
67
 
67
 
68
 /* === IMPLEMENTATIONS === */
68
 /* === IMPLEMENTATIONS === */
69
-u16 battle_damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank, u16 chained_effect, u8 airstatus) {
69
+u16 battle_damage_type_effectiveness_update(u8 attacking_type, u8 defending_type, u8 atk_bank, u8 def_bank,
70
+                                            u16 chained_effect, u8 airstatus) {
70
     u8 effect, atype = attacking_type, dtype = defending_type;
71
     u8 effect, atype = attacking_type, dtype = defending_type;
71
     if (!chained_effect || atype == TYPE_EGG || dtype == TYPE_EGG)
72
     if (!chained_effect || atype == TYPE_EGG || dtype == TYPE_EGG)
72
         return chained_effect;
73
         return chained_effect;
86
         }
87
         }
87
     }
88
     }
88
     /* handle normal / fighting on ghost */
89
     /* handle normal / fighting on ghost */
89
-    if ((((attacking_type == TYPE_NORMAL || attacking_type == TYPE_FIGHTING) && defending_type == TYPE_GHOST && ((battle_participants[def_bank].status2.foresight))) || battle_participants[atk_bank].ability_id == ABILITY_SCRAPPY) && effect == 0) {
90
+    if ((((attacking_type == TYPE_NORMAL || attacking_type == TYPE_FIGHTING) && defending_type == TYPE_GHOST &&
91
+          ((battle_participants[def_bank].status2.foresight))) ||
92
+         battle_participants[atk_bank].ability_id == ABILITY_SCRAPPY) &&
93
+        effect == 0) {
90
         effect = 10;
94
         effect = 10;
91
     }
95
     }
92
     /* handle other effectiveness changers here */
96
     /* handle other effectiveness changers here */
93
 
97
 
94
     switch (effect) {
98
     switch (effect) {
95
-        case 0:
96
-            chained_effect = 0;
97
-            break;
98
-        case 5:
99
-            chained_effect = chained_effect >> 1;
100
-            break;
101
-        case 20:
102
-            chained_effect = chained_effect << 1;
103
-            break;
99
+    case 0:
100
+        chained_effect = 0;
101
+        break;
102
+    case 5:
103
+        chained_effect = chained_effect >> 1;
104
+        break;
105
+    case 20:
106
+        chained_effect = chained_effect << 1;
107
+        break;
104
     }
108
     }
105
     return chained_effect;
109
     return chained_effect;
106
-
107
 }
110
 }
108
 
111
 
109
 u16 battle_apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus) {
112
 u16 battle_apply_type_effectiveness(u16 chained_effect, u8 move_type, u8 target_bank, u8 atk_bank, u8 airstatus) {
112
     /* set different types */
115
     /* set different types */
113
     if (defender_type2 == defender_type1)
116
     if (defender_type2 == defender_type1)
114
         defender_type2 = TYPE_EGG;
117
         defender_type2 = TYPE_EGG;
115
-    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type1, atk_bank, target_bank, chained_effect, airstatus);
116
-    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type2, atk_bank, target_bank, chained_effect, airstatus);
118
+    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type1, atk_bank, target_bank,
119
+                                                             chained_effect, airstatus);
120
+    chained_effect = battle_damage_type_effectiveness_update(move_type, defender_type2, atk_bank, target_bank,
121
+                                                             chained_effect, airstatus);
117
     return chained_effect;
122
     return chained_effect;
118
 }
123
 }
119
 
124
 
120
-u16 battle_type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank, u8 effects_handling_and_recording) {
125
+u16 battle_type_effectiveness_calc(u16 move, u8 move_type, u8 atk_bank, u8 def_bank,
126
+                                   u8 effects_handling_and_recording) {
121
     u16 chained_effect = 64;
127
     u16 chained_effect = 64;
122
-    //TODO: double_type moves
123
-    //TODO: get air status
128
+    // TODO: double_type moves
129
+    // TODO: get air status
124
     chained_effect = battle_apply_type_effectiveness(chained_effect, move_type, def_bank, atk_bank, 2);
130
     chained_effect = battle_apply_type_effectiveness(chained_effect, move_type, def_bank, atk_bank, 2);
125
-    //TODO: save into structs
126
-    //TODO: effect_handling_and_recording
131
+    // TODO: save into structs
132
+    // TODO: effect_handling_and_recording
127
     return chained_effect;
133
     return chained_effect;
128
 }
134
 }
129
 
135
 
133
 
139
 
134
 u8 battle_item_get_effect(u8 bank, u8 check_negating_effects) {
140
 u8 battle_item_get_effect(u8 bank, u8 check_negating_effects) {
135
     if (check_negating_effects) {
141
     if (check_negating_effects) {
136
-        if (battle_participants[bank].ability_id == ABILITY_KLUTZ || custom_battle_elements.ptr->bank_affecting[bank].embargo)
142
+        if (battle_participants[bank].ability_id == ABILITY_KLUTZ ||
143
+            custom_battle_elements.ptr->bank_affecting[bank].embargo)
137
             return ITEM_EFFECT_NOEFFECT;
144
             return ITEM_EFFECT_NOEFFECT;
138
     }
145
     }
139
     if (battle_participants[bank].held_item == ITEM_ENIGMABERRY) {
146
     if (battle_participants[bank].held_item == ITEM_ENIGMABERRY) {
143
     }
150
     }
144
 }
151
 }
145
 
152
 
146
-u8 battle_bank_is_poison_resistant(u8 bank, u8 self_inflicted) { //0 == can poison
147
-    //1 == is already poisoned
148
-    //2 == has other major condition
149
-    //3 == type doesn't allow it
150
-    //4 == ability doesn't allow it
151
-    //5 == safeguard protection
152
-    //8 == misty terrain doesn't allow it !TODO!
153
+u8 battle_bank_is_poison_resistant(u8 bank, u8 self_inflicted) { // 0 == can poison
154
+    // 1 == is already poisoned
155
+    // 2 == has other major condition
156
+    // 3 == type doesn't allow it
157
+    // 4 == ability doesn't allow it
158
+    // 5 == safeguard protection
159
+    // 8 == misty terrain doesn't allow it !TODO!
153
     if (battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
160
     if (battle_participants[bank].status.flags.poison || battle_participants[bank].status.flags.toxic_poison)
154
         return 1;
161
         return 1;
155
     if (battle_participants[bank].status.int_status)
162
     if (battle_participants[bank].status.int_status)
156
         return 2;
163
         return 2;
157
     if (battle_bank_has_type(bank, TYPE_POISON) || battle_bank_has_type(bank, TYPE_STEEL))
164
     if (battle_bank_has_type(bank, TYPE_POISON) || battle_bank_has_type(bank, TYPE_STEEL))
158
         return 3;
165
         return 3;
159
-    if (((battle_participants[bank].ability_id == ABILITY_IMMUNITY || (battle_participants[bank].ability_id == ABILITY_LEAF_GUARD && (battle_weather.flags.sun || battle_weather.flags.permament_sun || battle_weather.flags.harsh_sun)))))
166
+    if (((battle_participants[bank].ability_id == ABILITY_IMMUNITY ||
167
+          (battle_participants[bank].ability_id == ABILITY_LEAF_GUARD &&
168
+           (battle_weather.flags.sun || battle_weather.flags.permament_sun || battle_weather.flags.harsh_sun)))))
160
         return 4;
169
         return 4;
161
     if (side_affecting_halfword[get_side_from_bank(bank)].safeguard_on && !self_inflicted)
170
     if (side_affecting_halfword[get_side_from_bank(bank)].safeguard_on && !self_inflicted)
162
         return 5;
171
         return 5;
163
     return 0;
172
     return 0;
164
 }
173
 }
165
 
174
 
166
-u8 battle_count_party_pokemon(u8 bank)
167
-{
168
-    struct pokemon* poke;
175
+u8 battle_count_party_pokemon(u8 bank) {
176
+    struct pokemon *poke;
169
     if (get_side_from_bank(bank))
177
     if (get_side_from_bank(bank))
170
         poke = &party_opponent[0];
178
         poke = &party_opponent[0];
171
     else
179
     else
172
         poke = &party_player[0];
180
         poke = &party_player[0];
173
     u8 usable_pokes = 0;
181
     u8 usable_pokes = 0;
174
-    for (u8 i = 0; i < 6; i ++)
175
-    {
176
-        if (pokemon_get_attribute(&poke[i], ATTR_CURRENT_HP, 0) != 0 && pokemon_get_attribute(&poke[i], ATTR_IS_EGG, 0) != 1 && pokemon_get_attribute(&poke[i], ATTR_SPECIES, 0) != 0)
182
+    for (u8 i = 0; i < 6; i++) {
183
+        if (pokemon_get_attribute(&poke[i], ATTR_CURRENT_HP, 0) != 0 &&
184
+            pokemon_get_attribute(&poke[i], ATTR_IS_EGG, 0) != 1 &&
185
+            pokemon_get_attribute(&poke[i], ATTR_SPECIES, 0) != 0)
177
             usable_pokes++;
186
             usable_pokes++;
178
     }
187
     }
179
     return usable_pokes;
188
     return usable_pokes;

+ 10
- 11
src/battle_engine/battle_load_elements/battle_load_elements.c View File

1
-#include <config.h>
2
-#include <pokeagb/pokeagb.h>
3
 #include <battlescreen/battlescreen_0.h>
1
 #include <battlescreen/battlescreen_0.h>
4
 #include <battlescreen/battlescreen_1.h>
2
 #include <battlescreen/battlescreen_1.h>
5
-#include <battlescreen/battlescreen_2.h>
6
-#include <battlescreen/battlescreen_3.h>
7
-#include <battlescreen/battlescreen_4.h>
8
-#include <battlescreen/battlescreen_5.h>
9
-#include <battlescreen/battlescreen_6.h>
10
-#include <battlescreen/battlescreen_7.h>
11
-#include <battlescreen/battlescreen_8.h>
12
-#include <battlescreen/battlescreen_9.h>
13
 #include <battlescreen/battlescreen_10.h>
3
 #include <battlescreen/battlescreen_10.h>
14
 #include <battlescreen/battlescreen_11.h>
4
 #include <battlescreen/battlescreen_11.h>
15
 #include <battlescreen/battlescreen_12.h>
5
 #include <battlescreen/battlescreen_12.h>
20
 #include <battlescreen/battlescreen_17.h>
10
 #include <battlescreen/battlescreen_17.h>
21
 #include <battlescreen/battlescreen_18.h>
11
 #include <battlescreen/battlescreen_18.h>
22
 #include <battlescreen/battlescreen_19.h>
12
 #include <battlescreen/battlescreen_19.h>
13
+#include <battlescreen/battlescreen_2.h>
23
 #include <battlescreen/battlescreen_20.h>
14
 #include <battlescreen/battlescreen_20.h>
24
 #include <battlescreen/battlescreen_21.h>
15
 #include <battlescreen/battlescreen_21.h>
25
 #include <battlescreen/battlescreen_22.h>
16
 #include <battlescreen/battlescreen_22.h>
26
 #include <battlescreen/battlescreen_23.h>
17
 #include <battlescreen/battlescreen_23.h>
27
 #include <battlescreen/battlescreen_24.h>
18
 #include <battlescreen/battlescreen_24.h>
28
-
19
+#include <battlescreen/battlescreen_3.h>
20
+#include <battlescreen/battlescreen_4.h>
21
+#include <battlescreen/battlescreen_5.h>
22
+#include <battlescreen/battlescreen_6.h>
23
+#include <battlescreen/battlescreen_7.h>
24
+#include <battlescreen/battlescreen_8.h>
25
+#include <battlescreen/battlescreen_9.h>
26
+#include <config.h>
27
+#include <pokeagb/pokeagb.h>
29
 
28
 
30
 #define SIZEOF_ARR(a) (sizeof(a) / sizeof(a[0]))
29
 #define SIZEOF_ARR(a) (sizeof(a) / sizeof(a[0]))
31
 #define BATTLE_ELEMENT(n)                                                                                              \
30
 #define BATTLE_ELEMENT(n)                                                                                              \

+ 39
- 49
src/debug/debug.c View File

29
 
29
 
30
 /* === INCLUDE === */
30
 /* === INCLUDE === */
31
 
31
 
32
-#include <types.h>
33
-#include <callback.h>
34
-#include <lcd.h>
35
-#include <debug.h>
36
-#include <memory.h>
37
 #include <assets/ascii.h>
32
 #include <assets/ascii.h>
38
 #include <battle_test.h>
33
 #include <battle_test.h>
39
-#include <math.h>
34
+#include <callback.h>
35
+#include <debug.h>
40
 #include <fade.h>
36
 #include <fade.h>
37
+#include <lcd.h>
38
+#include <math.h>
39
+#include <memory.h>
40
+#include <types.h>
41
 
41
 
42
 /* === STRUCTURES === */
42
 /* === STRUCTURES === */
43
 
43
 
44
-struct assert_memory
45
-{
46
-    char* file;
44
+struct assert_memory {
45
+    char *file;
47
     int line;
46
     int line;
48
-    char* expression;
47
+    char *expression;
49
 };
48
 };
50
 
49
 
51
 /* === STATICS === */
50
 /* === STATICS === */
52
-struct assert_memory* assert_global = (struct assert_memory*)0x0203FEC4;
53
-static struct print_engine* print_memory = (struct print_engine*)(0x0203FFF0);
51
+struct assert_memory *assert_global = (struct assert_memory *)0x0203FEC4;
52
+static struct print_engine *print_memory = (struct print_engine *)(0x0203FFF0);
54
 
53
 
55
 /* === PROTOTYPES === */
54
 /* === PROTOTYPES === */
56
 
55
 
59
  * @param i integer
58
  * @param i integer
60
  * @param ref buffer to output to
59
  * @param ref buffer to output to
61
  */
60
  */
62
-void debug_int_to_char(u32 i, char* ref);
61
+void debug_int_to_char(u32 i, char *ref);
63
 
62
 
64
 /**
63
 /**
65
  * @get length of integer
64
  * @get length of integer
111
  * @param color color to print in
110
  * @param color color to print in
112
  * @param pBuf string buffer to print (null terminated)
111
  * @param pBuf string buffer to print (null terminated)
113
  */
112
  */
114
-void debug_print_string(u16 line, u16 row, u8 color, char* pBuf);
113
+void debug_print_string(u16 line, u16 row, u8 color, char *pBuf);
115
 
114
 
116
 /**
115
 /**
117
  * @brief build power
116
  * @brief build power
129
  * @param color color to set to
128
  * @param color color to set to
130
  */
129
  */
131
 void debug_set_bg(u16 color) {
130
 void debug_set_bg(u16 color) {
132
-    u16* bgc = (u16*) 0x020375f8;
131
+    u16 *bgc = (u16 *)0x020375f8;
133
     *bgc = color;
132
     *bgc = color;
134
     return;
133
     return;
135
 }
134
 }
137
 /* === STATIC STRUCTURES === */
136
 /* === STATIC STRUCTURES === */
138
 
137
 
139
 static struct bg_config debug_bg_config[4] = {
138
 static struct bg_config debug_bg_config[4] = {
140
-    {0, 0, 0x19, 0, 0, 0},
141
-    {1, 1, 0x1A, 0, 0, 1},
142
-    {2, 2, 0x1B, 0, 0, 2},
143
-    {3, 3, 0x1C, 0, 0, 3}
144
-};
139
+    {0, 0, 0x19, 0, 0, 0}, {1, 1, 0x1A, 0, 0, 1}, {2, 2, 0x1B, 0, 0, 2}, {3, 3, 0x1C, 0, 0, 3}};
145
 
140
 
146
 /* === IMPLEMENTATIONS === */
141
 /* === IMPLEMENTATIONS === */
147
 
142
 
148
-void as_assert(char* expression, char* file, int line)
149
-{
143
+void as_assert(char *expression, char *file, int line) {
150
     assert_global->file = file;
144
     assert_global->file = file;
151
     assert_global->line = line;
145
     assert_global->line = line;
152
     assert_global->expression = expression;
146
     assert_global->expression = expression;
153
-    
147
+
154
     set_callback2(debug_assert_scene);
148
     set_callback2(debug_assert_scene);
155
     vblank_handler_set(debug_update);
149
     vblank_handler_set(debug_update);
156
     superstate.multi_purpose_state_tracker = 0;
150
     superstate.multi_purpose_state_tracker = 0;
174
     set_callback2(debug_scene);
168
     set_callback2(debug_scene);
175
     vblank_handler_set(debug_update);
169
     vblank_handler_set(debug_update);
176
     superstate.multi_purpose_state_tracker = 0;
170
     superstate.multi_purpose_state_tracker = 0;
177
-    
171
+
178
     return;
172
     return;
179
 }
173
 }
180
 
174
 
190
     return;
184
     return;
191
 }
185
 }
192
 
186
 
193
-void debug_init_unit_test() {
194
-    test_speed();
195
-}
187
+void debug_init_unit_test() { test_speed(); }
196
 
188
 
197
-void debug_print_string(u16 line, u16 row, u8 color, char* pBuf) {
189
+void debug_print_string(u16 line, u16 row, u8 color, char *pBuf) {
198
     while (*pBuf) {
190
     while (*pBuf) {
199
         debug_print_char(line, row++, *pBuf++, color);
191
         debug_print_char(line, row++, *pBuf++, color);
200
     }
192
     }
201
     return;
193
     return;
202
 }
194
 }
203
 
195
 
204
-void debug_print(char* str) {
196
+void debug_print(char *str) {
205
     while (*str) {
197
     while (*str) {
206
-        if(print_memory->row > 29)
207
-        {
198
+        if (print_memory->row > 29) {
208
             print_memory->line++;
199
             print_memory->line++;
209
             print_memory->row = 0;
200
             print_memory->row = 0;
210
         }
201
         }
211
         if (*str == '\n') {
202
         if (*str == '\n') {
212
             print_memory->line++;
203
             print_memory->line++;
213
             print_memory->row = 0;
204
             print_memory->row = 0;
214
-        } if (*str == '\xFE') {
205
+        }
206
+        if (*str == '\xFE') {
215
             str++;
207
             str++;
216
             u8 c = *str;
208
             u8 c = *str;
217
             if (c > 2)
209
             if (c > 2)
226
     return;
218
     return;
227
 }
219
 }
228
 
220
 
229
-void debug_printf(char* str, int arg) {
221
+void debug_printf(char *str, int arg) {
230
     while (*str) {
222
     while (*str) {
231
-        if(print_memory->row > 29)
232
-        {
223
+        if (print_memory->row > 29) {
233
             print_memory->line++;
224
             print_memory->line++;
234
             print_memory->row = 0;
225
             print_memory->row = 0;
235
         }
226
         }
236
         if (*str == '\n') {
227
         if (*str == '\n') {
237
             print_memory->line++;
228
             print_memory->line++;
238
             print_memory->row = 0;
229
             print_memory->row = 0;
239
-        } if (*str == '\xFE') {
230
+        }
231
+        if (*str == '\xFE') {
240
             str++;
232
             str++;
241
             u8 c = *str;
233
             u8 c = *str;
242
             if (c > 2)
234
             if (c > 2)
254
                 debug_int_to_char(arg, temp);
246
                 debug_int_to_char(arg, temp);
255
                 debug_print(temp);
247
                 debug_print(temp);
256
             } else if (*str == 'c') {
248
             } else if (*str == 'c') {
257
-                char print_char = (char) (arg);
249
+                char print_char = (char)(arg);
258
                 debug_print_char(print_memory->line, print_memory->row, print_char, print_memory->color);
250
                 debug_print_char(print_memory->line, print_memory->row, print_char, print_memory->color);
259
                 print_memory->row++;
251
                 print_memory->row++;
260
             }
252
             }
267
 }
259
 }
268
 
260
 
269
 void debug_clean() {
261
 void debug_clean() {
270
-    memset((void*) 0x0600C800, 0, 0x800);
262
+    memset((void *)0x0600C800, 0, 0x800);
271
     print_memory->row = 0;
263
     print_memory->row = 0;
272
     print_memory->line = 0;
264
     print_memory->line = 0;
273
     print_memory->color = 0;
265
     print_memory->color = 0;
275
 }
267
 }
276
 
268
 
277
 void debug_wait_for_btn(u16 field) {
269
 void debug_wait_for_btn(u16 field) {
278
-    volatile u16* control_io = (volatile u16*) (0x04000130);
270
+    volatile u16 *control_io = (volatile u16 *)(0x04000130);
279
     while (*control_io & field) {
271
     while (*control_io & field) {
280
     }
272
     }
281
     return;
273
     return;
282
 }
274
 }
283
 
275
 
284
-void debug_init_stage_one()
285
-{
276
+void debug_init_stage_one() {
286
     print_memory->row = 0;
277
     print_memory->row = 0;
287
     print_memory->line = 0;
278
     print_memory->line = 0;
288
     print_memory->color = 0;
279
     print_memory->color = 0;
301
     gpu_sync_bg_visibility_and_mode();
292
     gpu_sync_bg_visibility_and_mode();
302
     debug_reset_scrolling();
293
     debug_reset_scrolling();
303
     obj_delete_all();
294
     obj_delete_all();
304
-    memset((void*) 0x06000000, 0, 0x17fe0);
305
-    memset((void*) 0x020375F8, 0, 0x400);
295
+    memset((void *)0x06000000, 0, 0x17fe0);
296
+    memset((void *)0x020375F8, 0, 0x400);
306
 }
297
 }
307
 
298
 
308
-void debug_init_stage_two()
309
-{
310
-    vram_decompress((void*) asciiTiles, (void*) 0x06000000);
311
-    memcpy((void*) 0x020375F8, (void*) asciiPal, 0x60);
299
+void debug_init_stage_two() {
300
+    vram_decompress((void *)asciiTiles, (void *)0x06000000);
301
+    memcpy((void *)0x020375F8, (void *)asciiPal, 0x60);
312
     debug_set_bg(0x0000);
302
     debug_set_bg(0x0000);
313
 }
303
 }
314
 
304
 
338
     union t_map_entry map_entry;
328
     union t_map_entry map_entry;
339
     map_entry.entry.tile = char_to_byte(character);
329
     map_entry.entry.tile = char_to_byte(character);
340
     map_entry.entry.pal = color;
330
     map_entry.entry.pal = color;
341
-    u16* ptr = (u16*) (0x0600c800 + (position * 2));
331
+    u16 *ptr = (u16 *)(0x0600c800 + (position * 2));
342
     *ptr = map_entry.short_map;
332
     *ptr = map_entry.short_map;
343
     return;
333
     return;
344
 }
334
 }
359
     obj_gpu_sprites_upload();
349
     obj_gpu_sprites_upload();
360
 }
350
 }
361
 
351
 
362
-void debug_int_to_char(u32 i, char* ref) {
352
+void debug_int_to_char(u32 i, char *ref) {
363
     if (i == 0) {
353
     if (i == 0) {
364
         ref[0] = '0';
354
         ref[0] = '0';
365
         return;
355
         return;