Ver código fonte

laid foundation for adding new grass animations (and oe_script stuff)

Philipp Auer 7 anos atrás
pai
commit
bd1d7c232f

+ 6
- 0
.vscode/settings.json Ver arquivo

@@ -0,0 +1,6 @@
1
+{
2
+    "files.associations": {
3
+        "filesystem": "cpp",
4
+        "regex": "cpp"
5
+    }
6
+}

+ 20
- 0
.vscode/tasks.json Ver arquivo

@@ -0,0 +1,20 @@
1
+{
2
+    "version": "0.1.0",
3
+    "command": "make",
4
+    "isShellCommand": true,
5
+    "args": [],
6
+    "showOutput": "always",
7
+    "echoCommand": true,
8
+    "suppressTaskName": true,
9
+    "tasks": [
10
+        {
11
+            "isBuildCommand": true,
12
+            "taskName": "build",
13
+            "args": ["-j4", "all"]
14
+        },
15
+        {
16
+            "taskName": "clean",
17
+            "args": ["clean"]
18
+        }
19
+    ]
20
+}

+ 5
- 0
bpre.sym Ver arquivo

@@ -104,6 +104,7 @@ fade_controller = 0x02037AB8;
104 104
 npc_states = 0x02036E38;
105 105
 
106 106
 sav_one = 0x03005008;
107
+oe_exec = 0x08083444|1;
107 108
 
108 109
 weather_turns = 0x02023F48;
109 110
 
@@ -191,6 +192,10 @@ current_map_music_set = 0x08071A74|1;
191 192
 current_map_music_set_to_zero = 0x08071A44|1;
192 193
 current_map_music_fadeout = 0x08071AB4|1;
193 194
 
195
+current_map_block_role_get = 0x08058F78|1;
196
+
197
+current_oe_state = 0x020386E0;
198
+
194 199
 __aeabi_idiv = 0x081E4018|1;
195 200
 __aeabi_idivmod = 0x081E40F4|1;
196 201
 __aeabi_uidiv = 0x081E460C|1;

+ 4
- 0
data/raw_defines.s Ver arquivo

@@ -10,6 +10,10 @@ objects:
10 10
 evolutions:
11 11
     .word 0x08259754
12 12
 
13
+.global save_one
14
+save_one:
15
+    .word 0x03005008
16
+
13 17
 .global ts_pals
14 18
 ts_pals:
15 19
     .incbin "sots-private/assets/misc/title/pal.bin"

+ 4
- 0
makefile Ver arquivo

@@ -6,6 +6,7 @@ CC      := arm-none-eabi-gcc
6 6
 ARS     := armips
7 7
 MAKE    := make
8 8
 NM      := @arm-none-eabi-nm
9
+VBA		:= vba
9 10
 LAN	:= de
10 11
 STRAGB	:= string2agb
11 12
 
@@ -125,3 +126,6 @@ $(LIST_AR):
125 126
 .PHONY: $(CRY_AR)
126 127
 $(CRY_AR):
127 128
 	$(MAKE) -C $(dir $@) all
129
+
130
+run: rom
131
+	$(VBA) "build/pkmn_sots.gba"

+ 7
- 2
nbproject/configurations.xml Ver arquivo

@@ -1,5 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<configurationDescriptor version="100">
2
+<configurationDescriptor version="97">
3 3
   <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
4 4
     <df root="." name="0">
5 5
       <df name="sots-private">
@@ -69,6 +69,8 @@
69 69
             </df>
70 70
             <in>ascii.c</in>
71 71
           </df>
72
+          <in>npc.h</in>
73
+          <in>save_one.h</in>
72 74
         </df>
73 75
         <df name="interface">
74 76
           <in>textbox_mugshots.c</in>
@@ -174,7 +176,6 @@
174 176
         <compilerSet>Cygwin|Cygwin</compilerSet>
175 177
         <dependencyChecking>false</dependencyChecking>
176 178
         <rebuildPropChanged>false</rebuildPropChanged>
177
-        <prependToolCollectionPath>false</prependToolCollectionPath>
178 179
       </toolsSet>
179 180
       <flagsDictionary>
180 181
         <element flagsID="0" commonFlags="-g -march=armv4t -O3 -std=c99"/>
@@ -621,6 +622,10 @@
621 622
         <cTool flags="0">
622 623
         </cTool>
623 624
       </item>
625
+      <item path="src/include/npc.h" ex="false" tool="3" flavor2="0">
626
+      </item>
627
+      <item path="src/include/save_one.h" ex="false" tool="3" flavor2="0">
628
+      </item>
624 629
       <item path="src/interface/textbox_mugshots.c" ex="false" tool="0" flavor2="3">
625 630
         <cTool flags="0">
626 631
         </cTool>

+ 11
- 663
nbproject/private/configurations.xml
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 12
- 1
nbproject/private/private.xml Ver arquivo

@@ -18,6 +18,17 @@
18 18
         </file>
19 19
     </editor-bookmarks>
20 20
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
21
-        <group/>
21
+        <group>
22
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/grass_animation.c</file>
23
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/oe_animation.h</file>
24
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/overworld.c</file>
25
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/raw_defines.s</file>
26
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/game_engine.h</file>
27
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/save_one.h</file>
28
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/npc.h</file>
29
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/types.h</file>
30
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/specials/load_text_special.c</file>
31
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/overworlds/overworld.asm</file>
32
+        </group>
22 33
     </open-files>
23 34
 </project-private>

+ 11
- 1
patches/overworlds/overworld.asm Ver arquivo

@@ -89,4 +89,14 @@ strb r0, [r4, #0x1A]
89 89
 
90 90
 .org 0x0805F4BA
91 91
     lsl r0, #0x10
92
-    lsr r1, r0, #0x10
92
+    lsr r1, r0, #0x10
93
+
94
+.org 0x0806837C
95
+    ldr r3, =grass_step_general+1
96
+    bx r3
97
+    .pool
98
+
99
+.org 0x080683C8
100
+    ldr r3, =grass_step_elastic+1
101
+    bx r3
102
+    .pool

+ 105
- 102
src/evolution/evolution_methods.c Ver arquivo

@@ -36,9 +36,13 @@
36 36
 #include <pokemon.h>
37 37
 #include <pkmn_types.h>
38 38
 
39
-#define EVO_NULL {0,0,0, {false, 0}}
39
+#define EVO_NULL              \
40
+    {                         \
41
+        0, 0, 0, { false, 0 } \
42
+    }
40 43
 #define MAX_EVOLUTIONS 5
41
-#define EVO_NO_EVO (struct evo_result){false,false,0}
44
+#define EVO_NO_EVO \
45
+    (struct evo_result) { false, false, 0 }
42 46
 
43 47
 #define HAPPY_BOUND 219
44 48
 #define BEAUTY_BOUND 170
@@ -68,7 +72,7 @@
68 72
 #define EVO_LEVEL_VAR 21
69 73
 #define EVO_LEVEL_MOVE 22
70 74
 #define EVO_LEVEL_POKEMON 23
71
-#define EVO_LEVEL_TYPE  24
75
+#define EVO_LEVEL_TYPE 24
72 76
 #define EVO_LEVEL_MOVE_TYPE 25
73 77
 #define EVO_MEGA_ONE 26
74 78
 #define EVO_MEGA_TWO 27
@@ -89,8 +93,8 @@ struct evo_information
89 93
     u16 evolve_to;
90 94
     struct
91 95
     {
92
-        u16 gender: 2;
93
-        u16 versatile: 14;
96
+        u16 gender : 2;
97
+        u16 versatile : 14;
94 98
     } argument_2;
95 99
 };
96 100
 
@@ -102,9 +106,9 @@ struct evo_result
102 106
 };
103 107
 
104 108
 struct evo_information evolutions[][MAX_EVOLUTIONS] = {
105
-    {EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},               //Nothing
106
-    {{EVO_LEVEL_MOVE_TYPE,7,20,{GENDER_DC, TYPE_GRASS}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},   //BISASAM
107
-    {{EVO_LEVEL_UP,32,3,{GENDER_DC, 0}},EVO_NULL,EVO_NULL,EVO_NULL,EVO_NULL},//BISAKNOSP
109
+    {EVO_NULL, EVO_NULL, EVO_NULL, EVO_NULL, EVO_NULL},                                              //Nothing
110
+    {{EVO_LEVEL_MOVE_TYPE, 7, 20, {GENDER_DC, TYPE_GRASS}}, EVO_NULL, EVO_NULL, EVO_NULL, EVO_NULL}, //BISASAM
111
+    {{EVO_LEVEL_UP, 32, 3, {GENDER_DC, 0}}, EVO_NULL, EVO_NULL, EVO_NULL, EVO_NULL},                 //BISAKNOSP
108 112
 };
109 113
 
110 114
 struct evo_call_arguments
@@ -113,7 +117,7 @@ struct evo_call_arguments
113 117
     u16 level;
114 118
     enum evo_source source;
115 119
     u16 stoneId;
116
-    struct pokemon* poke;
120
+    struct pokemon *poke;
117 121
     struct evo_information evolution;
118 122
 };
119 123
 
@@ -124,18 +128,18 @@ struct evo_result evolve_by_level(struct evo_call_arguments arguments)
124 128
     u8 gender = pokemon_get_gender(arguments.poke);
125 129
     u8 gender_arg = arguments.evolution.argument_2.gender;
126 130
     dprintf("A pokemon with gender value %d\n", gender);
127
-    if(gender_arg == 1)
131
+    if (gender_arg == 1)
128 132
     {
129
-        if(gender)
133
+        if (gender)
130 134
             return EVO_NO_EVO;
131 135
     }
132
-    if(gender_arg == 2)
136
+    if (gender_arg == 2)
133 137
     {
134
-        if(!gender)
138
+        if (!gender)
135 139
             return EVO_NO_EVO;
136 140
     }
137
-    
138
-    if(arguments.evolution.argument <= arguments.level && arguments.source == LEVEL_UP)
141
+
142
+    if (arguments.evolution.argument <= arguments.level && arguments.source == LEVEL_UP)
139 143
     {
140 144
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
141 145
     }
@@ -147,31 +151,31 @@ struct evo_result evolve_by_level(struct evo_call_arguments arguments)
147 151
 
148 152
 struct evo_result evolve_by_trade_group(struct evo_call_arguments arguments)
149 153
 {
150
-    if(arguments.source != TRADE)
154
+    if (arguments.source != TRADE)
151 155
     {
152 156
         return EVO_NO_EVO;
153 157
     }
154
-    if(arguments.evolution.method == EVO_TRADE_ITEM)
158
+    if (arguments.evolution.method == EVO_TRADE_ITEM)
155 159
     {
156
-        if(arguments.item != arguments.evolution.argument)
160
+        if (arguments.item != arguments.evolution.argument)
157 161
             return (struct evo_result){false, false, 0};
158 162
         else
159
-            return (struct evo_result){true,true, arguments.evolution.evolve_to};
163
+            return (struct evo_result){true, true, arguments.evolution.evolve_to};
160 164
     }
161
-    else if(arguments.evolution.method == EVO_TRADE)
165
+    else if (arguments.evolution.method == EVO_TRADE)
162 166
     {
163 167
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
164 168
     }
165 169
     else
166 170
     {
167 171
         dprintf("An invalid trade group method was reached in \"evolve_by_trade_group\"\nmethod: %d", arguments.evolution.method);
168
-        return (struct evo_result){false,false,0};
172
+        return (struct evo_result){false, false, 0};
169 173
     }
170 174
 }
171 175
 
172 176
 struct evo_result evolve_random(struct evo_call_arguments arguments)
173
-{  
174
-    if(arguments.source != LEVEL_UP)
177
+{
178
+    if (arguments.source != LEVEL_UP)
175 179
     {
176 180
         return EVO_NO_EVO;
177 181
     }
@@ -179,16 +183,16 @@ struct evo_result evolve_random(struct evo_call_arguments arguments)
179 183
     pid = pid & 0xFFFF;
180 184
     u8 mod = __aeabi_uidivmod(pid, 10);
181 185
     dprintf("A pokemon tries to evolve at random: pid: %d, low: %d, mod: %d\n", pid, pid, mod);
182
-    if(mod >= 5)
186
+    if (mod >= 5)
183 187
     {
184
-        if(arguments.evolution.method == EVO_PERSO_HIGH)
188
+        if (arguments.evolution.method == EVO_PERSO_HIGH)
185 189
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
186 190
         else
187 191
             return EVO_NO_EVO;
188 192
     }
189 193
     else
190 194
     {
191
-        if(arguments.evolution.method == EVO_PERSO_LOW)
195
+        if (arguments.evolution.method == EVO_PERSO_LOW)
192 196
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
193 197
         else
194 198
             return EVO_NO_EVO;
@@ -199,29 +203,29 @@ struct evo_result evolve_by_stone(struct evo_call_arguments arguments)
199 203
 {
200 204
     u8 gender = pokemon_get_gender(arguments.poke);
201 205
     u8 gender_arg = arguments.evolution.argument_2.gender;
202
-    
203
-    if(gender_arg == 1)
206
+
207
+    if (gender_arg == 1)
204 208
     {
205
-        if(gender)
209
+        if (gender)
206 210
             return EVO_NO_EVO;
207 211
     }
208
-    if(gender_arg == 2)
212
+    if (gender_arg == 2)
209 213
     {
210
-        if(!gender)
214
+        if (!gender)
211 215
             return EVO_NO_EVO;
212 216
     }
213 217
 
214
-    if(arguments.source != STONE_EVOLUTION && arguments.source != STONE_REQUEST)
218
+    if (arguments.source != STONE_EVOLUTION && arguments.source != STONE_REQUEST)
215 219
     {
216
-        return (struct evo_result){false,false, 0};
220
+        return (struct evo_result){false, false, 0};
217 221
     }
218
-    if(arguments.stoneId == arguments.evolution.argument)
222
+    if (arguments.stoneId == arguments.evolution.argument)
219 223
     {
220 224
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
221 225
     }
222 226
     else
223 227
     {
224
-        return (struct evo_result){false,false,0};
228
+        return (struct evo_result){false, false, 0};
225 229
     }
226 230
 }
227 231
 
@@ -230,17 +234,17 @@ struct evo_result evolve_by_pokemon(struct evo_call_arguments arguments)
230 234
     u8 has_required_pokemon = false;
231 235
     u16 species_required = arguments.evolution.argument_2.versatile;
232 236
     dprintf("Required: %d\n", species_required);
233
-    for(int i = 0; i < 6; ++i)
237
+    for (int i = 0; i < 6; ++i)
234 238
     {
235 239
         u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
236 240
         dprintf("Found pkmn: %d\n", current_species);
237
-        if(current_species == species_required)
241
+        if (current_species == species_required)
238 242
         {
239 243
             has_required_pokemon = true;
240 244
             break;
241 245
         }
242 246
     }
243
-    if(!has_required_pokemon)
247
+    if (!has_required_pokemon)
244 248
         return EVO_NO_EVO;
245 249
     return evolve_by_level(arguments);
246 250
 }
@@ -249,27 +253,26 @@ struct evo_result evolve_by_atk_def(struct evo_call_arguments arguments)
249 253
 {
250 254
     u32 atk = pokemon_get_attribute(arguments.poke, ATTR_ATTACK, NULL);
251 255
 
252
-    
253 256
     u32 def = pokemon_get_attribute(arguments.poke, ATTR_DEFENCE, NULL);
254 257
     dprintf("A pokemon wants to evolve by atk and def.\n");
255 258
     dprintf("Level required: %d, pkmn level: %d, pkmn atk: %d, pkmn def: %d\n", arguments.evolution.argument, arguments.level, atk, def);
256
-    if(arguments.evolution.method == EVO_ATK)
259
+    if (arguments.evolution.method == EVO_ATK)
257 260
     {
258
-        if(atk > def)
261
+        if (atk > def)
259 262
             return evolve_by_level(arguments);
260 263
         else
261 264
             return EVO_NO_EVO;
262 265
     }
263
-    if(arguments.evolution.method == EVO_DEF)
266
+    if (arguments.evolution.method == EVO_DEF)
264 267
     {
265
-        if(def > atk)
268
+        if (def > atk)
266 269
             return evolve_by_level(arguments);
267 270
         else
268 271
             return EVO_NO_EVO;
269 272
     }
270
-    if(arguments.evolution.method == EVO_ADEQU)
273
+    if (arguments.evolution.method == EVO_ADEQU)
271 274
     {
272
-        if(atk == def)
275
+        if (atk == def)
273 276
             return evolve_by_level(arguments);
274 277
         else
275 278
             return EVO_NO_EVO;
@@ -283,21 +286,21 @@ struct evo_result evolve_by_type(struct evo_call_arguments arguments)
283 286
     u8 has_required_pokemon = false;
284 287
     u16 type_required = arguments.evolution.argument_2.versatile;
285 288
     dprintf("Required: %d\n", type_required);
286
-    for(int i = 0; i < 6; ++i)
289
+    for (int i = 0; i < 6; ++i)
287 290
     {
288 291
         u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
289
-        if(current_species == 0)
292
+        if (current_species == 0)
290 293
             continue;
291 294
         u8 type_one = pokemon_stats[current_species].type_one;
292 295
         u8 type_two = pokemon_stats[current_species].type_two;
293 296
         dprintf("Found type: %d/%d\n", type_one, type_two);
294
-        if(type_one == type_required || type_two == type_required)
297
+        if (type_one == type_required || type_two == type_required)
295 298
         {
296 299
             has_required_pokemon = true;
297 300
             break;
298 301
         }
299 302
     }
300
-    if(!has_required_pokemon)
303
+    if (!has_required_pokemon)
301 304
         return EVO_NO_EVO;
302 305
     return evolve_by_level(arguments);
303 306
 }
@@ -307,13 +310,13 @@ struct evo_result evolve_by_happiness(struct evo_call_arguments arguments)
307 310
     u32 happiness = pokemon_get_attribute(arguments.poke, ATTR_HAPPINESS, NULL);
308 311
     dprintf("A pokemon wants to evolve by happiness.\n");
309 312
     dprintf("Happiness value: %d; needed: %d\n", happiness, HAPPY_BOUND);
310
-    if((happiness > HAPPY_BOUND) && (arguments.source == LEVEL_UP))
313
+    if ((happiness > HAPPY_BOUND) && (arguments.source == LEVEL_UP))
311 314
     {
312
-        return (struct evo_result){true,false,arguments.evolution.evolve_to};
315
+        return (struct evo_result){true, false, arguments.evolution.evolve_to};
313 316
     }
314 317
     else
315 318
     {
316
-        return (struct evo_result){false,false,0};
319
+        return (struct evo_result){false, false, 0};
317 320
     }
318 321
 }
319 322
 
@@ -321,7 +324,7 @@ struct evo_result evolve_by_special_place(struct evo_call_arguments arguments)
321 324
 {
322 325
     u16 value = var_get(EVO_VAR);
323 326
     dprintf("A pokemon tried to evolve using the var evo method: value: %d needed: %d\n", value, arguments.evolution.argument_2.versatile);
324
-    if(arguments.evolution.argument_2.versatile != value)
327
+    if (arguments.evolution.argument_2.versatile != value)
325 328
     {
326 329
         return EVO_NO_EVO;
327 330
     }
@@ -332,22 +335,22 @@ struct evo_result evolve_by_beauty(struct evo_call_arguments arguments)
332 335
 {
333 336
     u32 beauty = pokemon_get_attribute(arguments.poke, ATTR_BEAUTY, NULL);
334 337
     dprintf("A pokemon tires to evolve by beauty: value: %d; required: %d.\n", beauty, BEAUTY_BOUND);
335
-    if(beauty > BEAUTY_BOUND && arguments.source == LEVEL_UP)
338
+    if (beauty > BEAUTY_BOUND && arguments.source == LEVEL_UP)
336 339
         return evolve_by_level(arguments);
337 340
     return EVO_NO_EVO;
338 341
 }
339 342
 
340 343
 struct evo_result evolve_by_worn_item(struct evo_call_arguments arguments)
341 344
 {
342
-    
345
+
343 346
     struct evo_result level_result = evolve_by_level(arguments);
344
-    if(!level_result.can_evolve)
347
+    if (!level_result.can_evolve)
345 348
         return EVO_NO_EVO;
346 349
     u16 item_to_wear = arguments.evolution.argument_2.versatile;
347 350
     dprintf("A pokemon tried to evolve by item. pkmn_item: %d; argument item: %d", arguments.item, item_to_wear);
348
-    if(arguments.item != item_to_wear)
351
+    if (arguments.item != item_to_wear)
349 352
         return EVO_NO_EVO;
350
-    
353
+
351 354
     return (struct evo_result){true, false, arguments.evolution.evolve_to};
352 355
 }
353 356
 
@@ -371,7 +374,7 @@ struct evo_result evolve_by_move(struct evo_call_arguments arguments)
371 374
     u16 move_four = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_4, NULL);
372 375
     u16 move_needed = arguments.evolution.argument_2.versatile;
373 376
     dprintf("A pokemon tried to evolve using evolve_by_move: needed: %d, one: %d, two: %d, three: %d, four: %d\n", move_needed, move_one, move_two, move_three, move_four);
374
-    if((move_one == move_needed) || (move_two == move_needed) || (move_three == move_needed) || (move_four == move_needed))
377
+    if ((move_one == move_needed) || (move_two == move_needed) || (move_three == move_needed) || (move_four == move_needed))
375 378
         return evolve_by_level(arguments);
376 379
     else
377 380
         return EVO_NO_EVO;
@@ -381,20 +384,20 @@ struct evo_result evolve_by_move_type(struct evo_call_arguments arguments)
381 384
 {
382 385
     u16 needed_type = arguments.evolution.argument_2.versatile;
383 386
     u8 knows_required_move = false;
384
-    for(int i = ATTR_ATTACK_1; i <= ATTR_ATTACK_4; ++i)
387
+    for (int i = ATTR_ATTACK_1; i <= ATTR_ATTACK_4; ++i)
385 388
     {
386 389
         u16 current_move = pokemon_get_attribute(arguments.poke, i, NULL);
387
-        if(current_move == 0)
390
+        if (current_move == 0)
388 391
             continue;
389 392
         u8 current_type = move_table[current_move].type;
390 393
         dprintf("found move type: %d on move %d\n", current_type, current_move);
391
-        if(current_type == needed_type)
394
+        if (current_type == needed_type)
392 395
         {
393 396
             knows_required_move = true;
394 397
             break;
395 398
         }
396 399
     }
397
-    if(knows_required_move)
400
+    if (knows_required_move)
398 401
         return evolve_by_level(arguments);
399 402
     else
400 403
         return EVO_NO_EVO;
@@ -413,67 +416,67 @@ struct evo_result evolve_invalid_method(struct evo_call_arguments arguments)
413 416
 }
414 417
 
415 418
 static evolution_callback evolution_methods[] =
416
-{
417
-    evolve_invalid_method,                            //Method 0 INVALID
418
-    evolve_by_happiness,                              //Method 1
419
-    evolve_invalid_method, //TODO: Happiness DAY        Method 2
420
-    evolve_invalid_method, //TODO: Happiness NIGHT      Method 3
421
-    evolve_by_level,                                  //Method 4
422
-    evolve_by_trade_group,                            //Method 5
423
-    evolve_by_trade_group,                            //Method 6
424
-    evolve_by_stone,                                  //Method 7
425
-    evolve_by_atk_def,                                //Method 8
426
-    evolve_by_atk_def,                                //Method 9
427
-    evolve_by_atk_def,                                //Method 10
428
-    evolve_random,                                    //Method 11
429
-    evolve_random,                                    //Method 12
430
-    evolve_by_level,   //Shedninja SPAWN                Method 13
431
-    evolve_no_method, //Shedninja SPAWNED             //Method 14
432
-    evolve_by_beauty,                                 //Method 15
433
-    evolve_by_worn_item,                              //Method 16
434
-    evolve_by_worn_item_day, //TODO implement day       Method 17
435
-    evolve_by_worn_item_night, //TODO implement night   Method 18
436
-    evolve_invalid_method, //TODO implement level night Method 19
437
-    evolve_invalid_method, //TODO implement level day   Method 20
438
-    evolve_by_special_place,                          //Method 21
439
-    evolve_by_move,                                   //Method 22
440
-    evolve_by_pokemon,                                //Method 23
441
-    evolve_by_type,                                   //Method 24
442
-    evolve_by_move_type,                              //Method 25
443
-    evolve_no_method,                                 //Method 26
444
-    evolve_no_method,                                 //Method 26
445
-    evolve_no_method,                                 //Method 26
446
-    evolve_no_method,                                 //Method 26
419
+    {
420
+        evolve_invalid_method,     //Method 0 INVALID
421
+        evolve_by_happiness,       //Method 1
422
+        evolve_invalid_method,     //TODO: Happiness DAY        Method 2
423
+        evolve_invalid_method,     //TODO: Happiness NIGHT      Method 3
424
+        evolve_by_level,           //Method 4
425
+        evolve_by_trade_group,     //Method 5
426
+        evolve_by_trade_group,     //Method 6
427
+        evolve_by_stone,           //Method 7
428
+        evolve_by_atk_def,         //Method 8
429
+        evolve_by_atk_def,         //Method 9
430
+        evolve_by_atk_def,         //Method 10
431
+        evolve_random,             //Method 11
432
+        evolve_random,             //Method 12
433
+        evolve_by_level,           //Shedninja SPAWN                Method 13
434
+        evolve_no_method,          //Shedninja SPAWNED             //Method 14
435
+        evolve_by_beauty,          //Method 15
436
+        evolve_by_worn_item,       //Method 16
437
+        evolve_by_worn_item_day,   //TODO implement day       Method 17
438
+        evolve_by_worn_item_night, //TODO implement night   Method 18
439
+        evolve_invalid_method,     //TODO implement level night Method 19
440
+        evolve_invalid_method,     //TODO implement level day   Method 20
441
+        evolve_by_special_place,   //Method 21
442
+        evolve_by_move,            //Method 22
443
+        evolve_by_pokemon,         //Method 23
444
+        evolve_by_type,            //Method 24
445
+        evolve_by_move_type,       //Method 25
446
+        evolve_no_method,          //Method 26
447
+        evolve_no_method,          //Method 26
448
+        evolve_no_method,          //Method 26
449
+        evolve_no_method,          //Method 26
447 450
 };
448 451
 
449
-u16 evolution_try_evolve(struct pokemon* pokemon, enum evo_source source, u16 stoneId)
452
+u16 evolution_try_evolve(struct pokemon *pokemon, enum evo_source source, u16 stoneId)
450 453
 {
451 454
     u16 held_item = pokemon_get_attribute(pokemon, ATTR_HELD_ITEM, NULL);
452 455
     u16 species = pokemon_get_attribute(pokemon, ATTR_SPECIES, NULL);
453 456
     u16 level = pokemon_get_attribute(pokemon, ATTR_LEVEL, NULL);
454 457
     dprintf("Species %d tried to evolve.\n", species);
455 458
     dprintf("Cause: %d\n", source);
456
-    if(species > 2)
459
+    if (species > 2)
457 460
     {
458 461
         dprintf("Currently no evolution possible due to short table!\n");
459 462
         return 0;
460 463
     }
461
-    struct evo_information* current_evolution_structure = evolutions[species];
464
+    struct evo_information *current_evolution_structure = evolutions[species];
462 465
     struct evo_result result;
463
-    for(int i = 0; i < MAX_EVOLUTIONS; ++i)
466
+    for (int i = 0; i < MAX_EVOLUTIONS; ++i)
464 467
     {
465
-        if(current_evolution_structure[i].method != 0)
468
+        if (current_evolution_structure[i].method != 0)
466 469
         {
467 470
             dprintf("found valid evolution with method %d for species %d\n", current_evolution_structure[i].method, species);
468 471
             struct evo_call_arguments args = {held_item, level, source, stoneId, pokemon, current_evolution_structure[i]};
469 472
             result = evolution_methods[current_evolution_structure[i].method](args);
470
-            if(result.can_evolve)
473
+            if (result.can_evolve)
471 474
                 break;
472 475
         }
473 476
     }
474
-    if(result.can_evolve)
477
+    if (result.can_evolve)
475 478
     {
476
-        if(result.consume_item)
479
+        if (result.consume_item)
477 480
         {
478 481
             u16 zero = 0;
479 482
             pokemon_set_attribute(pokemon, ATTR_HELD_ITEM, &zero);

+ 93
- 0
src/include/npc.h Ver arquivo

@@ -0,0 +1,93 @@
1
+/****************************************************************************
2
+ * Copyright (C) 2015-2017 by the SotS Team                                 *
3
+ *                                                                          *
4
+ * This file is part of Sovereign of the Skies.                             *
5
+ *                                                                          *
6
+ *   Sovereign of the Skies is free software: you can redistribute it       *
7
+ *   and/or modify it                                                       *
8
+ *   under the terms of the GNU Lesser General Public License as published  *
9
+ *   by the Free Software Foundation, either version 3 of the License, or   *
10
+ *   (at your option) any later version provided you include a copy of the  *
11
+ *   licence and this header.                                               *
12
+ *                                                                          *
13
+ *   Sovereign of the Skies is distributed in the hope that it will be      *
14
+ *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU Lesser General Public License for more details.                    *
17
+ *                                                                          *
18
+ *   You should have received a copy of the GNU Lesser General Public       *
19
+ *   License along with Sovereign of the Skies.                             *
20
+ *   If not, see <http://www.gnu.org/licenses/>.                            *
21
+ ****************************************************************************/
22
+
23
+/* 
24
+ * File:   npc.h
25
+ * Author: Sturmvogel
26
+ *
27
+ * Created on May 2, 2017
28
+ * @brief Provides structures for NPC access
29
+*/
30
+
31
+#ifndef NPC_H
32
+#define NPC_H
33
+
34
+#include <types.h>
35
+        
36
+/* === STRUCTURES === */
37
+
38
+
39
+struct coords_16 {
40
+    u16 x;
41
+    u16 y;
42
+};
43
+
44
+struct npc_state
45
+{
46
+    u8 bitfield;
47
+    u8 field_1;
48
+    u8 field_2;
49
+    u8 field_3;
50
+    u8 oam_id;
51
+    u8 type_id;
52
+    u8 running_behavior;
53
+    u8 is_trainer;
54
+    u8 local_id;
55
+    u8 local_mapnumber;
56
+    u8 local_mapbank;
57
+    u8 height;
58
+    struct coords_16 stay_around;
59
+    struct coords_16 to;
60
+    struct coords_16 from;
61
+    u8 direction;
62
+    u8 movement_area;
63
+    u8 field_1A;
64
+    u8 oamid2;
65
+    u8 an_index;
66
+    u8 sight_distance;
67
+    u8 tile_to;
68
+    u8 tile_from;
69
+    u8 unknown_1;
70
+    u8 unknown_2;
71
+    u8 field_22;
72
+    u8 field_23;
73
+};
74
+
75
+
76
+struct npc_type {
77
+    u16 tiles_tag;
78
+    u16 pal_num;
79
+    u16 pal_tag_2;
80
+    u16 field_6;
81
+    struct coords_16 pos_neg_center;
82
+    u8 pal_slot_unk;
83
+    u8 field_D;
84
+    u16 pal_table;
85
+    u32 oam;
86
+    u32 field_14;
87
+    u32 image_anims;
88
+    u32 gfx_table;
89
+    u32 rot_scale_anims;
90
+};
91
+
92
+#endif /* NPC_H */
93
+

+ 4
- 32
src/include/oe_animation.h Ver arquivo

@@ -1,7 +1,7 @@
1 1
 #ifndef OE_ANIMATION_H
2 2
 #define OE_ANIMATION_H
3 3
 
4
-#include <bpre.h>
4
+#include <types.h>
5 5
 
6 6
 struct oe_state
7 7
 {
@@ -11,41 +11,13 @@ struct oe_state
11 11
     u32 field_C;
12 12
     u32 local_id_and_mapnumber;
13 13
     u32 local_mapbank;
14
-    void* sav1_location;
14
+    u32 sav1_location;
15 15
     u32 field_1C;
16 16
 };
17 17
 extern struct oe_state current_oe_state;
18 18
 
19
-struct npc_state
20
-{
21
-    u8 bitfield;
22
-    u8 field_1;
23
-    u8 field_2;
24
-    u8 field_3;
25
-    u8 oam_id;
26
-    u8 type_id;
27
-    u8 running_behavior;
28
-    u8 is_trainer;
29
-    u8 local_id;
30
-    u8 local_mapnumber;
31
-    u8 local_mapbank;
32
-    u8 height;
33
-    struct coords16 stay_around;
34
-    struct coords16 to;
35
-    struct coords16 from;
36
-    u8 direction;
37
-    u8 movement_area;
38
-    u8 field_1A;
39
-    u8 oamid2;
40
-    u8 an_index;
41
-    u8 sight_distance;
42
-    u8 tile_to;
43
-    u8 tile_from;
44
-    u8 unknown_1;
45
-    u8 unknown_2;
46
-    u8 field_22;
47
-    u8 field_23;
48
-};
19
+//TODO: find correct return type
20
+u32 oe_exec(u8 animation_number);
49 21
 
50 22
 #endif /* OE_ANIMATION_H */
51 23
 

+ 63
- 0
src/include/save_one.h Ver arquivo

@@ -0,0 +1,63 @@
1
+/****************************************************************************
2
+ * Copyright (C) 2015-2017 by the SotS Team                                 *
3
+ *                                                                          *
4
+ * This file is part of Sovereign of the Skies.                             *
5
+ *                                                                          *
6
+ *   Sovereign of the Skies is free software: you can redistribute it       *
7
+ *   and/or modify it                                                       *
8
+ *   under the terms of the GNU Lesser General Public License as published  *
9
+ *   by the Free Software Foundation, either version 3 of the License, or   *
10
+ *   (at your option) any later version provided you include a copy of the  *
11
+ *   licence and this header.                                               *
12
+ *                                                                          *
13
+ *   Sovereign of the Skies is distributed in the hope that it will be      *
14
+ *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU Lesser General Public License for more details.                    *
17
+ *                                                                          *
18
+ *   You should have received a copy of the GNU Lesser General Public       *
19
+ *   License along with Sovereign of the Skies.                             *
20
+ *   If not, see <http://www.gnu.org/licenses/>.                            *
21
+ ****************************************************************************/
22
+
23
+/* 
24
+ * File:   save_one.h
25
+ * Author: Sturmvogel
26
+ *
27
+ * Created on May 2, 2017
28
+ * @brief Provides structures for save file access
29
+*/
30
+
31
+#ifndef SAVE_ONE_H
32
+#define SAVE_ONE_H
33
+
34
+#include <types.h>
35
+
36
+/* === STRUCTURES === */
37
+
38
+/* === STRUCTURES === */
39
+struct lt_point
40
+{
41
+    u16 x;
42
+    u16 y;
43
+};
44
+
45
+struct lt_warpdata
46
+{
47
+    u8 bank;
48
+    u8 map;
49
+    u8 warpid;
50
+    u8 unknown;
51
+    u16 enter_x;
52
+    u16 enter_y;
53
+};
54
+
55
+struct sav_struct
56
+{
57
+    struct lt_point position;
58
+    struct lt_warpdata location;
59
+};
60
+
61
+extern struct sav_struct *sav_one;
62
+
63
+#endif /* SAVE_ONE_H */

+ 30
- 7
src/overworld/grass_animation.c Ver arquivo

@@ -1,12 +1,35 @@
1
-/*#include <bpre.h>
1
+#include <oe_animation.h>
2
+#include <npc.h>
3
+#include <save_one.h>
4
+#include <agb_debug.h>
2 5
 
3
-#include "oe_animation.h"
6
+extern u16 current_map_block_role_get(u16 x, u16 y);
4 7
 
5
-void grass_step_general(struct npc_state* npc)
8
+void grass_step_general(struct npc_state *npc)
6 9
 {
7
-    current_oe_state->to_x___local_id = npc_state->to.x;
8
-    current_oe_state->to_y___local_mapnumber = npc_state->to.y;
9
-    
10
+    current_oe_state.to_x___local_id = npc->to.x;
11
+    current_oe_state.to_y___local_mapnumber = npc->to.y;
12
+    current_oe_state.height_lsr_4___local_mapbank = (npc->height) >> 4;
13
+    current_oe_state.field_C = 2;
14
+    current_oe_state.local_id_and_mapnumber = (npc->local_id << 8) | (npc->local_mapnumber);
15
+    current_oe_state.local_mapbank = npc->local_mapbank;
16
+    current_oe_state.sav1_location = (((sav_one->location.map) << 8) | sav_one->location.bank);
17
+    current_oe_state.field_1C = 1;
18
+    (void)oe_exec(4);
10 19
 }
11 20
 
12
-void grass_step_normal()*/
21
+void grass_step_elastic(struct npc_state *npc)
22
+{
23
+    current_oe_state.to_x___local_id = npc->to.x;
24
+    current_oe_state.to_y___local_mapnumber = npc->to.y;
25
+    current_oe_state.height_lsr_4___local_mapbank = (npc->height) >> 4;
26
+    current_oe_state.field_C = 2;
27
+    current_oe_state.local_id_and_mapnumber = (npc->local_id << 8) | (npc->local_mapnumber);
28
+    current_oe_state.local_mapbank = npc->local_mapbank;
29
+    current_oe_state.sav1_location = (((sav_one->location.map) << 8) | sav_one->location.bank);
30
+    current_oe_state.field_1C = 0;
31
+
32
+    /* use variable to determine the oe animation to play */
33
+
34
+    (void)oe_exec(4);
35
+}

+ 13
- 32
src/overworld/overworld.c Ver arquivo

@@ -29,32 +29,11 @@
29 29
 
30 30
 /* === INCLUDES === */
31 31
 #include <game_engine.h>
32
+#include <npc.h>
32 33
 
33 34
 /* === DEFINES === */
34
-#define OW_REPLACE_VAR  0x500A
35
-#define OW_REPLACE_TO_VAR   0x500B
36
-
37
-/* === STRUCTURES === */
38
-struct ow_point {
39
-    u16 x;
40
-    u16 y;
41
-};
42
-
43
-struct npc_type {
44
-    u16 tiles_tag;
45
-    u16 pal_num;
46
-    u16 pal_tag_2;
47
-    u16 field_6;
48
-    struct ow_point pos_neg_center;
49
-    u8 pal_slot_unk;
50
-    u8 field_D;
51
-    u16 pal_table;
52
-    u32 oam;
53
-    u32 field_14;
54
-    u32 image_anims;
55
-    u32 gfx_table;
56
-    u32 rot_scale_anims;
57
-};
35
+#define OW_REPLACE_VAR 0x500A
36
+#define OW_REPLACE_TO_VAR 0x500B
58 37
 
59 38
 /* === PROTOTYPES === */
60 39
 /**
@@ -62,25 +41,27 @@ struct npc_type {
62 41
  * @param npc_id short npc id
63 42
  * @return pointer to corresponding npc_type structure
64 43
  */
65
-struct npc_type* npc_get_type(u16 npc_id);
44
+struct npc_type *npc_get_type(u16 npc_id);
66 45
 
67 46
 /* === EXTERN STATICS ===*/
68
-struct npc_type** ow_main_table;
69
-struct npc_type** ow_second_table;
70
-struct npc_type** ow_third_table;
47
+struct npc_type **ow_main_table;
48
+struct npc_type **ow_second_table;
49
+struct npc_type **ow_third_table;
71 50
 
72 51
 /* === IMPLEMENTATIONS === */
73
-struct npc_type* npc_get_type(u16 npc_id) {
52
+struct npc_type *npc_get_type(u16 npc_id)
53
+{
74 54
 
75 55
     /* Not possible in a global scope because of gcc cow magic */
76
-    struct npc_type** npc_tables[3] = {ow_main_table, ow_second_table, ow_third_table};
56
+    struct npc_type **npc_tables[3] = {ow_main_table, ow_second_table, ow_third_table};
77 57
     //struct npc_type** npc_tables[] = {ow_main_table, ow_second_table, ow_third_table};
78 58
     u8 table_id = npc_id >> 8;
79 59
     if (table_id > 2)
80
-        npc_id = (u8) npc_id;
60
+        npc_id = (u8)npc_id;
81 61
 
82 62
     u16 replace_ow = var_get(OW_REPLACE_VAR);
83
-    if (replace_ow > 0 && replace_ow - 1 == npc_id) {
63
+    if (replace_ow > 0 && replace_ow - 1 == npc_id)
64
+    {
84 65
         npc_id = var_get(OW_REPLACE_TO_VAR);
85 66
     }
86 67
     u8 table = (npc_id >> 8);

+ 1
- 24
src/specials/load_text_special.c Ver arquivo

@@ -34,29 +34,7 @@
34 34
 #include <types.h>
35 35
 #include <game_engine.h>
36 36
 #include <config.h>
37
-
38
-/* === STRUCTURES === */
39
-struct lt_point
40
-{
41
-    u16 x;
42
-    u16 y;
43
-};
44
-
45
-struct lt_warpdata
46
-{
47
-    u8 bank;
48
-    u8 map;
49
-    u8 warpid;
50
-    u8 unknown;
51
-    u16 enter_x;
52
-    u16 enter_y;
53
-};
54
-
55
-struct sav_struct
56
-{
57
-    struct lt_point position;
58
-    struct lt_warpdata location;
59
-};
37
+#include <save_one.h>
60 38
 
61 39
 /* === PROTOTYPES === */
62 40
 
@@ -71,7 +49,6 @@ void sp_load_text_map();
71 49
 void sp_load_text_person();
72 50
 
73 51
 /* === GLOBALS === */
74
-extern struct sav_struct* sav_one;
75 52
 
76 53
 char* str_invalid_text_ref;
77 54
 char***** text_lookup_table;