Browse Source

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

Philipp Auer 7 years ago
parent
commit
bd1d7c232f

+ 6
- 0
.vscode/settings.json View File

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

+ 20
- 0
.vscode/tasks.json View File

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 View File

104
 npc_states = 0x02036E38;
104
 npc_states = 0x02036E38;
105
 
105
 
106
 sav_one = 0x03005008;
106
 sav_one = 0x03005008;
107
+oe_exec = 0x08083444|1;
107
 
108
 
108
 weather_turns = 0x02023F48;
109
 weather_turns = 0x02023F48;
109
 
110
 
191
 current_map_music_set_to_zero = 0x08071A44|1;
192
 current_map_music_set_to_zero = 0x08071A44|1;
192
 current_map_music_fadeout = 0x08071AB4|1;
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
 __aeabi_idiv = 0x081E4018|1;
199
 __aeabi_idiv = 0x081E4018|1;
195
 __aeabi_idivmod = 0x081E40F4|1;
200
 __aeabi_idivmod = 0x081E40F4|1;
196
 __aeabi_uidiv = 0x081E460C|1;
201
 __aeabi_uidiv = 0x081E460C|1;

+ 4
- 0
data/raw_defines.s View File

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

+ 4
- 0
makefile View File

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

+ 7
- 2
nbproject/configurations.xml View File

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

+ 11
- 663
nbproject/private/configurations.xml
File diff suppressed because it is too large
View File


+ 12
- 1
nbproject/private/private.xml View File

18
         </file>
18
         </file>
19
     </editor-bookmarks>
19
     </editor-bookmarks>
20
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
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
     </open-files>
33
     </open-files>
23
 </project-private>
34
 </project-private>

+ 11
- 1
patches/overworlds/overworld.asm View File

89
 
89
 
90
 .org 0x0805F4BA
90
 .org 0x0805F4BA
91
     lsl r0, #0x10
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 View File

36
 #include <pokemon.h>
36
 #include <pokemon.h>
37
 #include <pkmn_types.h>
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
 #define MAX_EVOLUTIONS 5
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
 #define HAPPY_BOUND 219
47
 #define HAPPY_BOUND 219
44
 #define BEAUTY_BOUND 170
48
 #define BEAUTY_BOUND 170
68
 #define EVO_LEVEL_VAR 21
72
 #define EVO_LEVEL_VAR 21
69
 #define EVO_LEVEL_MOVE 22
73
 #define EVO_LEVEL_MOVE 22
70
 #define EVO_LEVEL_POKEMON 23
74
 #define EVO_LEVEL_POKEMON 23
71
-#define EVO_LEVEL_TYPE  24
75
+#define EVO_LEVEL_TYPE 24
72
 #define EVO_LEVEL_MOVE_TYPE 25
76
 #define EVO_LEVEL_MOVE_TYPE 25
73
 #define EVO_MEGA_ONE 26
77
 #define EVO_MEGA_ONE 26
74
 #define EVO_MEGA_TWO 27
78
 #define EVO_MEGA_TWO 27
89
     u16 evolve_to;
93
     u16 evolve_to;
90
     struct
94
     struct
91
     {
95
     {
92
-        u16 gender: 2;
93
-        u16 versatile: 14;
96
+        u16 gender : 2;
97
+        u16 versatile : 14;
94
     } argument_2;
98
     } argument_2;
95
 };
99
 };
96
 
100
 
102
 };
106
 };
103
 
107
 
104
 struct evo_information evolutions[][MAX_EVOLUTIONS] = {
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
 struct evo_call_arguments
114
 struct evo_call_arguments
113
     u16 level;
117
     u16 level;
114
     enum evo_source source;
118
     enum evo_source source;
115
     u16 stoneId;
119
     u16 stoneId;
116
-    struct pokemon* poke;
120
+    struct pokemon *poke;
117
     struct evo_information evolution;
121
     struct evo_information evolution;
118
 };
122
 };
119
 
123
 
124
     u8 gender = pokemon_get_gender(arguments.poke);
128
     u8 gender = pokemon_get_gender(arguments.poke);
125
     u8 gender_arg = arguments.evolution.argument_2.gender;
129
     u8 gender_arg = arguments.evolution.argument_2.gender;
126
     dprintf("A pokemon with gender value %d\n", gender);
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
             return EVO_NO_EVO;
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
             return EVO_NO_EVO;
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
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
144
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
141
     }
145
     }
147
 
151
 
148
 struct evo_result evolve_by_trade_group(struct evo_call_arguments arguments)
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
         return EVO_NO_EVO;
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
             return (struct evo_result){false, false, 0};
161
             return (struct evo_result){false, false, 0};
158
         else
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
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
167
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
164
     }
168
     }
165
     else
169
     else
166
     {
170
     {
167
         dprintf("An invalid trade group method was reached in \"evolve_by_trade_group\"\nmethod: %d", arguments.evolution.method);
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
 struct evo_result evolve_random(struct evo_call_arguments arguments)
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
         return EVO_NO_EVO;
180
         return EVO_NO_EVO;
177
     }
181
     }
179
     pid = pid & 0xFFFF;
183
     pid = pid & 0xFFFF;
180
     u8 mod = __aeabi_uidivmod(pid, 10);
184
     u8 mod = __aeabi_uidivmod(pid, 10);
181
     dprintf("A pokemon tries to evolve at random: pid: %d, low: %d, mod: %d\n", pid, pid, mod);
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
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
189
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
186
         else
190
         else
187
             return EVO_NO_EVO;
191
             return EVO_NO_EVO;
188
     }
192
     }
189
     else
193
     else
190
     {
194
     {
191
-        if(arguments.evolution.method == EVO_PERSO_LOW)
195
+        if (arguments.evolution.method == EVO_PERSO_LOW)
192
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
196
             return (struct evo_result){true, false, arguments.evolution.evolve_to};
193
         else
197
         else
194
             return EVO_NO_EVO;
198
             return EVO_NO_EVO;
199
 {
203
 {
200
     u8 gender = pokemon_get_gender(arguments.poke);
204
     u8 gender = pokemon_get_gender(arguments.poke);
201
     u8 gender_arg = arguments.evolution.argument_2.gender;
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
             return EVO_NO_EVO;
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
             return EVO_NO_EVO;
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
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
224
         return (struct evo_result){true, false, arguments.evolution.evolve_to};
221
     }
225
     }
222
     else
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
     u8 has_required_pokemon = false;
234
     u8 has_required_pokemon = false;
231
     u16 species_required = arguments.evolution.argument_2.versatile;
235
     u16 species_required = arguments.evolution.argument_2.versatile;
232
     dprintf("Required: %d\n", species_required);
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
         u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
239
         u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
236
         dprintf("Found pkmn: %d\n", current_species);
240
         dprintf("Found pkmn: %d\n", current_species);
237
-        if(current_species == species_required)
241
+        if (current_species == species_required)
238
         {
242
         {
239
             has_required_pokemon = true;
243
             has_required_pokemon = true;
240
             break;
244
             break;
241
         }
245
         }
242
     }
246
     }
243
-    if(!has_required_pokemon)
247
+    if (!has_required_pokemon)
244
         return EVO_NO_EVO;
248
         return EVO_NO_EVO;
245
     return evolve_by_level(arguments);
249
     return evolve_by_level(arguments);
246
 }
250
 }
249
 {
253
 {
250
     u32 atk = pokemon_get_attribute(arguments.poke, ATTR_ATTACK, NULL);
254
     u32 atk = pokemon_get_attribute(arguments.poke, ATTR_ATTACK, NULL);
251
 
255
 
252
-    
253
     u32 def = pokemon_get_attribute(arguments.poke, ATTR_DEFENCE, NULL);
256
     u32 def = pokemon_get_attribute(arguments.poke, ATTR_DEFENCE, NULL);
254
     dprintf("A pokemon wants to evolve by atk and def.\n");
257
     dprintf("A pokemon wants to evolve by atk and def.\n");
255
     dprintf("Level required: %d, pkmn level: %d, pkmn atk: %d, pkmn def: %d\n", arguments.evolution.argument, arguments.level, atk, def);
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
             return evolve_by_level(arguments);
262
             return evolve_by_level(arguments);
260
         else
263
         else
261
             return EVO_NO_EVO;
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
             return evolve_by_level(arguments);
269
             return evolve_by_level(arguments);
267
         else
270
         else
268
             return EVO_NO_EVO;
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
             return evolve_by_level(arguments);
276
             return evolve_by_level(arguments);
274
         else
277
         else
275
             return EVO_NO_EVO;
278
             return EVO_NO_EVO;
283
     u8 has_required_pokemon = false;
286
     u8 has_required_pokemon = false;
284
     u16 type_required = arguments.evolution.argument_2.versatile;
287
     u16 type_required = arguments.evolution.argument_2.versatile;
285
     dprintf("Required: %d\n", type_required);
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
         u16 current_species = pokemon_get_attribute(&(pokemon_party_player[i]), ATTR_SPECIES, NULL);
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
             continue;
293
             continue;
291
         u8 type_one = pokemon_stats[current_species].type_one;
294
         u8 type_one = pokemon_stats[current_species].type_one;
292
         u8 type_two = pokemon_stats[current_species].type_two;
295
         u8 type_two = pokemon_stats[current_species].type_two;
293
         dprintf("Found type: %d/%d\n", type_one, type_two);
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
             has_required_pokemon = true;
299
             has_required_pokemon = true;
297
             break;
300
             break;
298
         }
301
         }
299
     }
302
     }
300
-    if(!has_required_pokemon)
303
+    if (!has_required_pokemon)
301
         return EVO_NO_EVO;
304
         return EVO_NO_EVO;
302
     return evolve_by_level(arguments);
305
     return evolve_by_level(arguments);
303
 }
306
 }
307
     u32 happiness = pokemon_get_attribute(arguments.poke, ATTR_HAPPINESS, NULL);
310
     u32 happiness = pokemon_get_attribute(arguments.poke, ATTR_HAPPINESS, NULL);
308
     dprintf("A pokemon wants to evolve by happiness.\n");
311
     dprintf("A pokemon wants to evolve by happiness.\n");
309
     dprintf("Happiness value: %d; needed: %d\n", happiness, HAPPY_BOUND);
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
     else
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
 {
324
 {
322
     u16 value = var_get(EVO_VAR);
325
     u16 value = var_get(EVO_VAR);
323
     dprintf("A pokemon tried to evolve using the var evo method: value: %d needed: %d\n", value, arguments.evolution.argument_2.versatile);
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
         return EVO_NO_EVO;
329
         return EVO_NO_EVO;
327
     }
330
     }
332
 {
335
 {
333
     u32 beauty = pokemon_get_attribute(arguments.poke, ATTR_BEAUTY, NULL);
336
     u32 beauty = pokemon_get_attribute(arguments.poke, ATTR_BEAUTY, NULL);
334
     dprintf("A pokemon tires to evolve by beauty: value: %d; required: %d.\n", beauty, BEAUTY_BOUND);
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
         return evolve_by_level(arguments);
339
         return evolve_by_level(arguments);
337
     return EVO_NO_EVO;
340
     return EVO_NO_EVO;
338
 }
341
 }
339
 
342
 
340
 struct evo_result evolve_by_worn_item(struct evo_call_arguments arguments)
343
 struct evo_result evolve_by_worn_item(struct evo_call_arguments arguments)
341
 {
344
 {
342
-    
345
+
343
     struct evo_result level_result = evolve_by_level(arguments);
346
     struct evo_result level_result = evolve_by_level(arguments);
344
-    if(!level_result.can_evolve)
347
+    if (!level_result.can_evolve)
345
         return EVO_NO_EVO;
348
         return EVO_NO_EVO;
346
     u16 item_to_wear = arguments.evolution.argument_2.versatile;
349
     u16 item_to_wear = arguments.evolution.argument_2.versatile;
347
     dprintf("A pokemon tried to evolve by item. pkmn_item: %d; argument item: %d", arguments.item, item_to_wear);
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
         return EVO_NO_EVO;
352
         return EVO_NO_EVO;
350
-    
353
+
351
     return (struct evo_result){true, false, arguments.evolution.evolve_to};
354
     return (struct evo_result){true, false, arguments.evolution.evolve_to};
352
 }
355
 }
353
 
356
 
371
     u16 move_four = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_4, NULL);
374
     u16 move_four = pokemon_get_attribute(arguments.poke, ATTR_ATTACK_4, NULL);
372
     u16 move_needed = arguments.evolution.argument_2.versatile;
375
     u16 move_needed = arguments.evolution.argument_2.versatile;
373
     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);
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
         return evolve_by_level(arguments);
378
         return evolve_by_level(arguments);
376
     else
379
     else
377
         return EVO_NO_EVO;
380
         return EVO_NO_EVO;
381
 {
384
 {
382
     u16 needed_type = arguments.evolution.argument_2.versatile;
385
     u16 needed_type = arguments.evolution.argument_2.versatile;
383
     u8 knows_required_move = false;
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
         u16 current_move = pokemon_get_attribute(arguments.poke, i, NULL);
389
         u16 current_move = pokemon_get_attribute(arguments.poke, i, NULL);
387
-        if(current_move == 0)
390
+        if (current_move == 0)
388
             continue;
391
             continue;
389
         u8 current_type = move_table[current_move].type;
392
         u8 current_type = move_table[current_move].type;
390
         dprintf("found move type: %d on move %d\n", current_type, current_move);
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
             knows_required_move = true;
396
             knows_required_move = true;
394
             break;
397
             break;
395
         }
398
         }
396
     }
399
     }
397
-    if(knows_required_move)
400
+    if (knows_required_move)
398
         return evolve_by_level(arguments);
401
         return evolve_by_level(arguments);
399
     else
402
     else
400
         return EVO_NO_EVO;
403
         return EVO_NO_EVO;
413
 }
416
 }
414
 
417
 
415
 static evolution_callback evolution_methods[] =
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
     u16 held_item = pokemon_get_attribute(pokemon, ATTR_HELD_ITEM, NULL);
454
     u16 held_item = pokemon_get_attribute(pokemon, ATTR_HELD_ITEM, NULL);
452
     u16 species = pokemon_get_attribute(pokemon, ATTR_SPECIES, NULL);
455
     u16 species = pokemon_get_attribute(pokemon, ATTR_SPECIES, NULL);
453
     u16 level = pokemon_get_attribute(pokemon, ATTR_LEVEL, NULL);
456
     u16 level = pokemon_get_attribute(pokemon, ATTR_LEVEL, NULL);
454
     dprintf("Species %d tried to evolve.\n", species);
457
     dprintf("Species %d tried to evolve.\n", species);
455
     dprintf("Cause: %d\n", source);
458
     dprintf("Cause: %d\n", source);
456
-    if(species > 2)
459
+    if (species > 2)
457
     {
460
     {
458
         dprintf("Currently no evolution possible due to short table!\n");
461
         dprintf("Currently no evolution possible due to short table!\n");
459
         return 0;
462
         return 0;
460
     }
463
     }
461
-    struct evo_information* current_evolution_structure = evolutions[species];
464
+    struct evo_information *current_evolution_structure = evolutions[species];
462
     struct evo_result result;
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
             dprintf("found valid evolution with method %d for species %d\n", current_evolution_structure[i].method, species);
470
             dprintf("found valid evolution with method %d for species %d\n", current_evolution_structure[i].method, species);
468
             struct evo_call_arguments args = {held_item, level, source, stoneId, pokemon, current_evolution_structure[i]};
471
             struct evo_call_arguments args = {held_item, level, source, stoneId, pokemon, current_evolution_structure[i]};
469
             result = evolution_methods[current_evolution_structure[i].method](args);
472
             result = evolution_methods[current_evolution_structure[i].method](args);
470
-            if(result.can_evolve)
473
+            if (result.can_evolve)
471
                 break;
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
             u16 zero = 0;
481
             u16 zero = 0;
479
             pokemon_set_attribute(pokemon, ATTR_HELD_ITEM, &zero);
482
             pokemon_set_attribute(pokemon, ATTR_HELD_ITEM, &zero);

+ 93
- 0
src/include/npc.h View File

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 View File

1
 #ifndef OE_ANIMATION_H
1
 #ifndef OE_ANIMATION_H
2
 #define OE_ANIMATION_H
2
 #define OE_ANIMATION_H
3
 
3
 
4
-#include <bpre.h>
4
+#include <types.h>
5
 
5
 
6
 struct oe_state
6
 struct oe_state
7
 {
7
 {
11
     u32 field_C;
11
     u32 field_C;
12
     u32 local_id_and_mapnumber;
12
     u32 local_id_and_mapnumber;
13
     u32 local_mapbank;
13
     u32 local_mapbank;
14
-    void* sav1_location;
14
+    u32 sav1_location;
15
     u32 field_1C;
15
     u32 field_1C;
16
 };
16
 };
17
 extern struct oe_state current_oe_state;
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
 #endif /* OE_ANIMATION_H */
22
 #endif /* OE_ANIMATION_H */
51
 
23
 

+ 63
- 0
src/include/save_one.h View File

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 View File

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 View File

29
 
29
 
30
 /* === INCLUDES === */
30
 /* === INCLUDES === */
31
 #include <game_engine.h>
31
 #include <game_engine.h>
32
+#include <npc.h>
32
 
33
 
33
 /* === DEFINES === */
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
 /* === PROTOTYPES === */
38
 /* === PROTOTYPES === */
60
 /**
39
 /**
62
  * @param npc_id short npc id
41
  * @param npc_id short npc id
63
  * @return pointer to corresponding npc_type structure
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
 /* === EXTERN STATICS ===*/
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
 /* === IMPLEMENTATIONS === */
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
     /* Not possible in a global scope because of gcc cow magic */
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
     //struct npc_type** npc_tables[] = {ow_main_table, ow_second_table, ow_third_table};
57
     //struct npc_type** npc_tables[] = {ow_main_table, ow_second_table, ow_third_table};
78
     u8 table_id = npc_id >> 8;
58
     u8 table_id = npc_id >> 8;
79
     if (table_id > 2)
59
     if (table_id > 2)
80
-        npc_id = (u8) npc_id;
60
+        npc_id = (u8)npc_id;
81
 
61
 
82
     u16 replace_ow = var_get(OW_REPLACE_VAR);
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
         npc_id = var_get(OW_REPLACE_TO_VAR);
65
         npc_id = var_get(OW_REPLACE_TO_VAR);
85
     }
66
     }
86
     u8 table = (npc_id >> 8);
67
     u8 table = (npc_id >> 8);

+ 1
- 24
src/specials/load_text_special.c View File

34
 #include <types.h>
34
 #include <types.h>
35
 #include <game_engine.h>
35
 #include <game_engine.h>
36
 #include <config.h>
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
 /* === PROTOTYPES === */
39
 /* === PROTOTYPES === */
62
 
40
 
71
 void sp_load_text_person();
49
 void sp_load_text_person();
72
 
50
 
73
 /* === GLOBALS === */
51
 /* === GLOBALS === */
74
-extern struct sav_struct* sav_one;
75
 
52
 
76
 char* str_invalid_text_ref;
53
 char* str_invalid_text_ref;
77
 char***** text_lookup_table;   
54
 char***** text_lookup_table;