Bladeren bron

code cleanup and refractor, licence

SBird1337 8 jaren geleden
bovenliggende
commit
58ce676020

+ 49
- 0
.cproject Bestand weergeven

@@ -0,0 +1,49 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
3
+	<storageModule moduleId="org.eclipse.cdt.core.settings">
4
+		<cconfiguration id="0.611547157">
5
+			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.611547157" moduleId="org.eclipse.cdt.core.settings" name="Default">
6
+				<externalSettings/>
7
+				<extensions>
8
+					<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
9
+					<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
10
+					<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
11
+					<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12
+					<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
13
+					<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
14
+				</extensions>
15
+			</storageModule>
16
+			<storageModule moduleId="cdtBuildSystem" version="4.0.0">
17
+				<configuration buildProperties="" description="" id="0.611547157" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
18
+					<folderInfo id="0.611547157." name="/" resourcePath="">
19
+						<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2045814114" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
20
+							<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.2045814114.1252909595" name=""/>
21
+							<builder id="org.eclipse.cdt.build.core.settings.default.builder.1829609699" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
22
+							<tool id="org.eclipse.cdt.build.core.settings.holder.libs.907440362" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
23
+							<tool id="org.eclipse.cdt.build.core.settings.holder.1527973307" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
24
+								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.2026614964" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
25
+							</tool>
26
+							<tool id="org.eclipse.cdt.build.core.settings.holder.291840161" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
27
+								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1833279374" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
28
+							</tool>
29
+							<tool id="org.eclipse.cdt.build.core.settings.holder.1555053434" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
30
+								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.536157729" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
31
+							</tool>
32
+						</toolChain>
33
+					</folderInfo>
34
+				</configuration>
35
+			</storageModule>
36
+			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
37
+		</cconfiguration>
38
+	</storageModule>
39
+	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
40
+		<project id="source_of_the_sovereign.null.1685340467" name="source_of_the_sovereign"/>
41
+	</storageModule>
42
+	<storageModule moduleId="scannerConfiguration">
43
+		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
44
+		<scannerConfigBuildInfo instanceId="0.611547157">
45
+			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
46
+		</scannerConfigBuildInfo>
47
+	</storageModule>
48
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
49
+</cproject>

+ 27
- 0
.project Bestand weergeven

@@ -0,0 +1,27 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>source_of_the_sovereign</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10
+			<triggers>clean,full,incremental,</triggers>
11
+			<arguments>
12
+			</arguments>
13
+		</buildCommand>
14
+		<buildCommand>
15
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16
+			<triggers>full,incremental,</triggers>
17
+			<arguments>
18
+			</arguments>
19
+		</buildCommand>
20
+	</buildSpec>
21
+	<natures>
22
+		<nature>org.eclipse.cdt.core.cnature</nature>
23
+		<nature>org.eclipse.cdt.core.ccnature</nature>
24
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
25
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
26
+	</natures>
27
+</projectDescription>

+ 5
- 5
bpre.sym Bestand weergeven

@@ -8,7 +8,7 @@ free = 0x08002BC4|1;
8 8
 memmove = 0x081E8E60|1;
9 9
 memset = 0x081E5ED8|1;
10 10
 memcpy = 0x081E5E78|1;
11
-template_instanciate_forward_search = 0x08006F8D;
11
+obj_template_instanciate_forward_search = 0x08006F8D;
12 12
 gpu_copy_to_vram_by_bgid = 0x08001298|1;
13 13
 bg_set_tilemap = 0x08001FA0|1;
14 14
 bg_nullify_tilemap = 0x08001FD4|1;
@@ -21,7 +21,7 @@ gpu_bg_show = 0x08001320|1;
21 21
 gpu_bg_hide = 0x0800139C|1;
22 22
 gpu_sync_bg_visibility_and_mode = 0x080013D0|1;
23 23
 gpu_pal_upload = 0x08070474|1;
24
-gpu_sprites_upload = 0x08007320|1;
24
+obj_gpu_sprites_upload = 0x08007320|1;
25 25
 obj_delete_all = 0x8007770|1;
26 26
 camera_move_and_redraw = 0x0805ACB4|1;
27 27
 calc_circle = 0x0807EE2C|1;
@@ -55,9 +55,9 @@ lz77u_wram = 0x0800EBB4|1;
55 55
 
56 56
 vram_decompress = 0x081E3B6C|1;
57 57
 pal_decompress_slice_to_faded_and_unfaded = 0x080703A8|1;
58
-gpu_tile_obj_decompress_alloc_tag_and_upload = 0x0800F035;
59
-gpu_pal_obj_alloc_tag_and_apply = 0x08008929;
60
-gpu_tile_obj_free_by_tag = 0x0800874D;
58
+obj_gpu_tile_decompress_alloc_tag_and_upload = 0x0800F035;
59
+obj_gpu_pal_alloc_tag_and_apply = 0x08008929;
60
+obj_gpu_tile_free_by_tag = 0x0800874D;
61 61
 gpu_pal_free_by_tag = 0x08008A31;
62 62
 obj_delete_and_free_tiles = 0x08007281;
63 63
 box_zero_flag = 0x0203709C;

+ 3
- 2
makefile Bestand weergeven

@@ -2,7 +2,7 @@ AS      := arm-none-eabi-as
2 2
 LD      := arm-none-eabi-ld
3 3
 OBJCOPY := arm-none-eabi-objcopy
4 4
 GRIT    := grit
5
-CC      := arm-none-eabi-gcc
5
+CC      := @arm-none-eabi-gcc
6 6
 ARS     := armips
7 7
 MAKE    := make
8 8
 NM      := @arm-none-eabi-nm
@@ -13,7 +13,7 @@ export PATH := $(realpath ../tools):$(PATH)
13 13
 
14 14
 DEFINES   := -DBPRE -DSOFTWARE_VERSION=0
15 15
 ASFLAGS   := -mthumb
16
-CFLAGS    := -mthumb -mno-thumb-interwork -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=c99 -Wall -Isrc/include $(DEFINES)
16
+CFLAGS    := -mthumb -mno-thumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=c99 -Wall -Isrc/include $(DEFINES)
17 17
 GRITFLAGS := -ftc -fa
18 18
 LDFLAGS   := -z muldefs
19 19
 BLDPATH   := object
@@ -80,6 +80,7 @@ rom: main.asm $(MAIN_OBJ)
80 80
 $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(DYN_OVER) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR) $(STRING_OBJ)
81 81
 	$(MAKE) -f assets.makefile
82 82
 	$(LD) $(LDFLAGS) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
83
+	$(LD) $(LDFLAGS) -T linker.ld -T bpre.sym -o object/debug.o object/linked.o
83 84
 
84 85
 .PHONY: clean
85 86
 clean:

+ 1
- 1
nbproject/configurations.xml Bestand weergeven

@@ -4835,7 +4835,7 @@
4835 4835
           <buildCommandWorkingDir>.</buildCommandWorkingDir>
4836 4836
           <buildCommand>${MAKE} -f makefile LAN=DE -j4</buildCommand>
4837 4837
           <cleanCommand>${MAKE} -f makefile clean</cleanCommand>
4838
-          <executablePath></executablePath>
4838
+          <executablePath>object/debug.o</executablePath>
4839 4839
         </makeTool>
4840 4840
         <preBuild>
4841 4841
           <preBuildCommandWorkingDir>.</preBuildCommandWorkingDir>

+ 7
- 3
nbproject/private/configurations.xml Bestand weergeven

@@ -4363,7 +4363,7 @@
4363 4363
           </df>
4364 4364
         </df>
4365 4365
         <df name="string">
4366
-          <df name="DE">
4366
+          <df name="de">
4367 4367
           </df>
4368 4368
         </df>
4369 4369
       </df>
@@ -5587,6 +5587,7 @@
5587 5587
               <in>SEQ_BGM_E_CHAMPION.s</in>
5588 5588
               <in>SEQ_BGM_E_INISHIE.s</in>
5589 5589
               <in>SEQ_BGM_E_MENU.s</in>
5590
+              <in>SEQ_BGM_GYM.s</in>
5590 5591
               <in>SEQ_BGM_LABO.s</in>
5591 5592
               <in>SEQ_BGM_MART.s</in>
5592 5593
               <in>SEQ_BGM_OVERTURE.s</in>
@@ -5700,6 +5701,8 @@
5700 5701
               <in>snd_127_sticks.s</in>
5701 5702
               <in>snd_127_tambourine.s</in>
5702 5703
               <in>snd_127_tom.s</in>
5704
+              <in>snd_127_tom_45.s</in>
5705
+              <in>snd_127_tom_48.s</in>
5703 5706
               <in>snd_127_triangle.s</in>
5704 5707
               <in>snd_14_tubular_bell.s</in>
5705 5708
               <in>snd_17_organ.s</in>
@@ -6275,11 +6278,12 @@
6275 6278
             <option name="gdb_init_file"
6276 6279
                     value="C:\cygwin64\home\auerp\sots\emu\gdbinit.gdb"/>
6277 6280
             <option name="gdb_source_dirs" value="src"/>
6278
-            <option name="debug_command" value="&quot;../emu/mgba.exe&quot; -g &quot;build/pkmn_sots.gba&quot;"/>
6281
+            <option name="debug_command"
6282
+                    value="arm-none-eabi-gdb --args file &quot;build\debug.o&quot; target remote localhost:2345"/>
6279 6283
             <option name="debug_dir"
6280 6284
                     value="C:\cygwin64\home\auerp\sots\source_of_the_sovereign\."/>
6281 6285
             <option name="symbol_file"
6282
-                    value="C:\cygwin64\home\auerp\sots\source_of_the_sovereign\object\linked.o"/>
6286
+                    value="C:\cygwin64\home\auerp\sots\source_of_the_sovereign\object\debug.o"/>
6283 6287
           </DebugOptions>
6284 6288
         </gdb_options>
6285 6289
         <gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>

+ 2
- 0
nbproject/private/private.xml Bestand weergeven

@@ -49,6 +49,7 @@
49 49
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle.h</file>
50 50
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/moves.asm</file>
51 51
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/pkmn_tables/pokemon_moveset_table.S</file>
52
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/types.h</file>
52 53
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/overworld/overworld_hooks.S</file>
53 54
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/battle_engine/battle_engine.asm</file>
54 55
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/moves/feint/feint.c</file>
@@ -91,6 +92,7 @@
91 92
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_script.h</file>
92 93
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/battle_engine/entry_hazards_hook.S</file>
93 94
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/data/moves/move_data.S</file>
95
+            <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/interface/textbox_mugshots.c</file>
94 96
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/string/de/move_strings.txt</file>
95 97
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/src/include/battle_abilities.h</file>
96 98
             <file>file:/C:/cygwin64/home/auerp/sots/source_of_the_sovereign/patches/items/items.asm</file>

+ 22
- 0
src/battle_engine/#battle_abilities.c# Bestand weergeven

@@ -0,0 +1,22 @@
1
+#include <battle_abilities.h>
2
+#include <custom_structs.h>
3
+
4
+#include "battle_structs.h"
5
+
6
+u8 has_ability_effect(u8 bank, u8 mold_breaker, u8 gastro)
7
+{
8
+  if(gastro && custom_battle_elements.ptr->bank_affecting[bank].gastro_acided)
9
+        return false;
10
+    return true;
11
+    //TODO: MOLD BREAKER
12
+}
13
+
14
+u8 weather_abilities_effect()
15
+{
16
+    //TODO: AIR LOCK AND CLOUD NINE
17
+    return true;
18
+}
19
+u8 has_ability(u8 bank, u8 ability)
20
+{
21
+    return (has_ability_effect(bank,0,1) && battle_participants[bank].ability_id == ability);
22
+}

+ 1
- 1
src/debug/debug.c Bestand weergeven

@@ -170,7 +170,7 @@ void debug_update() {
170 170
     objc_exec();
171 171
     obj_sync();
172 172
     gpu_pal_upload();
173
-    gpu_sprites_upload();
173
+    obj_gpu_sprites_upload();
174 174
 }
175 175
 
176 176
 void int_to_char(u32 i, char* ref) {

+ 2
- 2
src/dns/dns_core.c Bestand weergeven

@@ -108,8 +108,8 @@ void overworld_anim_load_pal(void** oe_script_pointer) {
108 108
     memcpy(temp_color, pal_to_apply->palette, 32);
109 109
     apply_shaders(0, 0, temp_color);
110 110
 
111
-    struct resource temp_resource = {temp_color, pal_to_apply->tag, pal_to_apply->fill};
112
-    gpu_pal_obj_alloc_tag_and_apply(&temp_resource);
111
+    struct obj_resource temp_resource = {temp_color, pal_to_apply->tag, pal_to_apply->fill};
112
+    obj_gpu_pal_alloc_tag_and_apply(&temp_resource);
113 113
     free(temp_color);
114 114
     if (current_idx != 0xFF) {
115 115
         current_idx = gpu_pal_tags_index_of(pal_to_apply->tag);

+ 9
- 9
src/include/callback.h Bestand weergeven

@@ -3,7 +3,8 @@
3 3
 
4 4
 #include <objects.h>
5 5
 typedef void (*callback)();
6
-typedef struct super {
6
+
7
+struct int_superstate {
7 8
 	callback callback1;
8 9
 	callback callback2;
9 10
 	callback callback2backup;
@@ -21,16 +22,15 @@ typedef struct super {
21 22
 	u16 buttons_new_and_key_repeat;
22 23
 	u32 keypad_countdown;
23 24
 	u32 unused_padding;
24
-	sprite sprites[128];
25
+	struct obj_entity sprites[128];
25 26
 	u8 multi_purpose_state_tracker;
26 27
 	u8 gpu_sprites_upload_skip;
27
- } super;
28
-extern super superstate;
29
-void set_callback2(callback address);
30
-void vblank_handler_set(callback address);
31
-
32
-
28
+ };
29
+ 
30
+extern struct int_superstate superstate;
31
+extern void set_callback2(callback address);
32
+extern void vblank_handler_set(callback address);
33 33
 
34
-void callback_overworld();
34
+extern void callback_overworld();
35 35
 
36 36
 #endif

+ 0
- 6
src/include/lcd.h Bestand weergeven

@@ -53,13 +53,7 @@ void gpu_bg_hide(u8 id);
53 53
 void gpu_sync_bg_visibility_and_mode();
54 54
 void lcd_io_set_func(u8 id, u16 value);
55 55
 void gpu_pal_upload();
56
-void gpu_sprites_upload();
57
-
58
-u8 gpu_pal_obj_alloc_tag_and_apply(resource *pal);
59 56
 void gpu_pal_free_by_tag(u16 tag);
60
-void gpu_tile_obj_free_by_tag(u16 tag);
61
-void obj_delete_and_free_tiles(object *obj);
62
-void obj_delete_all();
63 57
 
64 58
 u16 lcd_io_get(u8 id);
65 59
 

+ 106
- 29
src/include/objects.h Bestand weergeven

@@ -1,48 +1,68 @@
1
+/****************************************************************************
2
+ * Copyright (C) 2015-2016 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 Box.  If not, see <http://www.gnu.org/licenses/>.   *
20
+ ****************************************************************************/
21
+
22
+/**
23
+ * @file objects.h
24
+ * @author Sturmvogel
25
+ * @date 15 dec 2016
26
+ * @brief Helpful operations and structure on object entities.
27
+ * 
28
+ * This header provides a framework for working with the object engine.
29
+ * Methods are used to create, destroy, manipulate and update the object
30
+ * entities.
31
+ */
32
+
1 33
 #ifndef OBJECTS_H_
2 34
 #define OBJECTS_H_
3 35
 
4 36
 #include "types.h"
5 37
 
6
-struct object;
7
-typedef struct object object;
8
-typedef void (*object_callback)(object*);
38
+/* === STRUCTURES === */
9 39
 
10
-typedef struct frame {
40
+struct obj_frame {
11 41
   u16 data;
12 42
   u16 duration;
13
-} frame;
43
+};
14 44
 
15
-typedef struct rotscale_frame {
45
+struct obj_rotscale_frame {
16 46
   u16 scale_delta_x;
17 47
   u16 scale_delta_y;
18 48
   u8 rot_delta;
19 49
   u8 duration;
20 50
   u16 field_6;
21
-}  rotscale_frame;
51
+};
22 52
 
23
-typedef struct sprite {
53
+struct obj_oam_attributes {
24 54
   u16 attr0;
25 55
   u16 attr1;
26 56
   u16 attr2;
27 57
   u16 rotscale;
28
-} sprite;
58
+};
29 59
 
30
-typedef struct template {
31
-  u16 tiles_tag;
32
-  u16 pal_tag;
33
-  sprite *oam;
34
-  frame **animation;
35
-  u32 *graphics;
36
-  rotscale_frame **rotscale;
37
-  object_callback callback;
38
-} template;
39
-
40
-typedef struct object {
41
-  sprite final_oam;
42
-  frame **animation_table;
60
+struct obj_entity {
61
+  struct obj_oam_attributes final_oam;
62
+  struct obj_frame **animation_table;
43 63
   u32 *gfx_table;
44 64
   u32 *rotscale_table;
45
-  template *template;
65
+  struct obj_template *template;
46 66
   u32 field18;
47 67
   u32 *callback;
48 68
   u16 x;
@@ -61,16 +81,73 @@ typedef struct object {
61 81
   u16 anim_data_offset;
62 82
   u8 field42;
63 83
   u8 field43;
64
-} object;
84
+};
85
+
86
+typedef void (*object_callback)(struct obj_entity*);
65 87
 
66
-typedef struct resource {
88
+struct obj_template {
89
+  u16 tiles_tag;
90
+  u16 pal_tag;
91
+  struct obj_oam_attributes *oam;
92
+  struct obj_frame **animation;
93
+  u32 *graphics;
94
+  struct obj_rotscale_frame **rotscale;
95
+  object_callback callback;
96
+};
97
+
98
+struct obj_resource {
67 99
   void *data;
68 100
   u16 size;
69 101
   u16 tag;
70
-} resource;
102
+};
103
+
104
+/* === EXTERN METHODS === */
105
+
106
+/**
107
+ * 
108
+ * @param t pointer to obj_template structure which should be instancinated
109
+ * @param x x position
110
+ * @param y y position
111
+ * @param b index to start searching at ( ? )
112
+ * @return id of the newly generated obj_entity structure [in superstate.sprites array]
113
+ */
114
+extern u8 obj_template_instanciate_forward_search(struct obj_template *t, u16 x, u16 y, u8 b);
115
+
116
+/**
117
+ * 
118
+ * @param src obj_resource structure to allocate
119
+ * @return tag of the allocated resource
120
+ */
121
+extern u16 obj_gpu_tile_decompress_alloc_tag_and_upload(struct obj_resource *src);
122
+
123
+/**
124
+ * @brief parses and uploads the objects in memory to the object hardware
125
+ */
126
+extern void obj_gpu_sprites_upload();
127
+
128
+/**
129
+ * 
130
+ * @param pal palette resource to create
131
+ * @return success ( ? )
132
+ */
133
+extern u8 obj_gpu_pal_alloc_tag_and_apply(struct obj_resource *pal);
134
+
135
+/**
136
+ * 
137
+ * @param tag tag of tile resource to free
138
+ */
139
+extern void obj_gpu_tile_free_by_tag(u16 tag);
140
+
141
+/**
142
+ * 
143
+ * @param obj obj_entitiy structure to free and delete
144
+ */
145
+extern void obj_delete_and_free_tiles(struct obj_entity *obj);
146
+
147
+/**
148
+ * @brief delete all object entities in game
149
+ */
150
+extern void obj_delete_all();
71 151
 
72
-u8 template_instanciate_forward_search(struct template *t, u16 x, u16 y, u8 b);
73
-u16 gpu_tile_obj_decompress_alloc_tag_and_upload(resource *src);
74
-#define objects ((object*)0x0202063C)
75 152
 
76 153
 #endif

+ 2
- 0
src/include/types.h Bestand weergeven

@@ -16,6 +16,8 @@ typedef     double                  f64;
16 16
 
17 17
 typedef     unsigned int            size_t;
18 18
 
19
+typedef     unsigned char           bool;
20
+
19 21
 #define true 1
20 22
 #define false 0
21 23
 

+ 29
- 34
src/interface/textbox_mugshots.c Bestand weergeven

@@ -1,7 +1,7 @@
1
-#include <stdbool.h>
2 1
 #include <objects.h>
2
+#include <callback.h>
3 3
 #include <config.h>
4
-
4
+#include <lcd.h>
5 5
 typedef struct mugshot {
6 6
 	void *gfx;
7 7
 	void *pal;
@@ -11,21 +11,16 @@ typedef struct mugshot {
11 11
 mugshot *mugshots = (mugshot (*) ) 0x097007E0;
12 12
 u8 *temp_obj_id1 = (u8*) OBJ_1_TEMP;
13 13
 u8 *temp_obj_id2 = (u8*) OBJ_2_TEMP;
14
-
15
-void gpu_pal_obj_alloc_tag_and_apply(resource *pal);
16
-void gpu_pal_free_by_tag(u16 tag);
17
-void gpu_tile_obj_free_by_tag(u16 tag);
18
-void obj_delete_and_free_tiles(object *obj);
19 14
 void* memset(void* ptr, int value, u32 num);
20 15
 
21 16
 u16* var_access(u16 num);
22 17
 
23
-sprite mug_sprite = {0, 0x8000, 0, 0};
18
+struct obj_oam_attributes mug_sprite = {0, 0x8000, 0, 0};
24 19
 
25
-void null_callback(object *self);
20
+void null_callback(struct obj_entity *self);
26 21
 
27
-template mugshot_1_template = {MUGSHOT_1_TAG, MUGSHOT_1_TAG, &mug_sprite, (frame **)0x08231CF0, 0, (rotscale_frame **)0x08231CFC, null_callback};
28
-template mugshot_2_template = {MUGSHOT_2_TAG, MUGSHOT_2_TAG, &mug_sprite, (frame **)0x08231CF0, 0, (rotscale_frame **)0x08231CFC, null_callback};
22
+struct obj_template mugshot_1_template = {MUGSHOT_1_TAG, MUGSHOT_1_TAG, &mug_sprite, (struct obj_frame **)0x08231CF0, 0, (struct obj_rotscale_frame **)0x08231CFC, null_callback};
23
+struct obj_template mugshot_2_template = {MUGSHOT_2_TAG, MUGSHOT_2_TAG, &mug_sprite, (struct obj_frame **)0x08231CF0, 0, (struct obj_rotscale_frame **)0x08231CFC, null_callback};
29 24
 
30 25
 void create_mugshot_on_variable()
31 26
 {
@@ -40,22 +35,22 @@ void create_mugshot_on_variable()
40 35
 		u16 *mug1_y = var_access(MUGSHOT_1_Y);
41 36
 
42 37
 		mug_id_1--;
43
-		resource gfx_mugshot_1 = {(mugshots[mug_id_1].gfx), 0x1C00, MUGSHOT_1_TAG};
44
-		resource pal_mugshot_1 = {(mugshots[mug_id_1].pal), MUGSHOT_1_TAG};
38
+		struct obj_resource gfx_mugshot_1 = {(mugshots[mug_id_1].gfx), 0x1C00, MUGSHOT_1_TAG};
39
+		struct obj_resource pal_mugshot_1 = {(mugshots[mug_id_1].pal), MUGSHOT_1_TAG};
45 40
 
46 41
 
47
-		gpu_pal_obj_alloc_tag_and_apply(&pal_mugshot_1);
48
-		gpu_tile_obj_decompress_alloc_tag_and_upload(&gfx_mugshot_1);
42
+		obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_1);
43
+		obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_1);
49 44
 
50
-		*temp_obj_id1 = (u16)template_instanciate_forward_search(&mugshot_1_template, 0, 100, 1);
45
+		*temp_obj_id1 = (u16)obj_template_instanciate_forward_search(&mugshot_1_template, 0, 100, 1);
51 46
 
52 47
 		if(h_flip)
53
-			objects[*temp_obj_id1].final_oam.attr1 |= 0x1000;
48
+			superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x1000;
54 49
 		if(v_flip)
55
-			objects[*temp_obj_id1].final_oam.attr1 |= 0x2000;
50
+			superstate.sprites[*temp_obj_id1].final_oam.attr1 |= 0x2000;
56 51
 
57
-		objects[*temp_obj_id1].x = *mug1_x;
58
-		objects[*temp_obj_id1].y = *mug1_y;
52
+		superstate.sprites[*temp_obj_id1].x = *mug1_x;
53
+		superstate.sprites[*temp_obj_id1].y = *mug1_y;
59 54
 	}
60 55
 	//return;
61 56
 	u16 *mug2_var = var_access(MUGHSOT_2_TABLE);
@@ -69,23 +64,23 @@ void create_mugshot_on_variable()
69 64
 		u16 *mug2_y = var_access(MUGSHOT_2_Y);
70 65
 
71 66
 		mug_id_2--;
72
-		resource gfx_mugshot_2 = {(mugshots[mug_id_2].gfx), 0x1C00, MUGSHOT_2_TAG};
73
-		resource pal_mugshot_2 = {(mugshots[mug_id_2].pal), MUGSHOT_2_TAG};
67
+		struct obj_resource gfx_mugshot_2 = {(mugshots[mug_id_2].gfx), 0x1C00, MUGSHOT_2_TAG};
68
+		struct obj_resource pal_mugshot_2 = {(mugshots[mug_id_2].pal), MUGSHOT_2_TAG};
74 69
 
75 70
 
76
-		gpu_pal_obj_alloc_tag_and_apply(&pal_mugshot_2);
77
-		gpu_tile_obj_decompress_alloc_tag_and_upload(&gfx_mugshot_2);
71
+		obj_gpu_pal_alloc_tag_and_apply(&pal_mugshot_2);
72
+		obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_mugshot_2);
78 73
 
79 74
 		c_mug2_var = *mug2_var;
80
-		*temp_obj_id2 = (u16)template_instanciate_forward_search(&mugshot_2_template, 0, 100, 1);
75
+		*temp_obj_id2 = (u16)obj_template_instanciate_forward_search(&mugshot_2_template, 0, 100, 1);
81 76
 
82 77
 		if(h_flip)
83
-			objects[*temp_obj_id2].final_oam.attr1 |= 0x1000;
78
+			superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x1000;
84 79
 		if(v_flip)
85
-			objects[*temp_obj_id2].final_oam.attr1 |= 0x2000;
80
+			superstate.sprites[*temp_obj_id2].final_oam.attr1 |= 0x2000;
86 81
 
87
-		objects[*temp_obj_id2].x = *mug2_x;
88
-		objects[*temp_obj_id2].y = *mug2_y;
82
+		superstate.sprites[*temp_obj_id2].x = *mug2_x;
83
+		superstate.sprites[*temp_obj_id2].y = *mug2_y;
89 84
 	}
90 85
 }
91 86
 
@@ -97,14 +92,14 @@ void delete_mugshot()
97 92
 	if(*temp_obj_id1 != 0)
98 93
 	{
99 94
 		gpu_pal_free_by_tag(MUGSHOT_1_TAG);
100
-		gpu_tile_obj_free_by_tag(MUGSHOT_1_TAG);
95
+		obj_gpu_tile_free_by_tag(MUGSHOT_1_TAG);
101 96
 
102 97
 		//*mug1_var = 0;
103 98
 		//do reset mugshot var ; set it to old value instead
104 99
 
105 100
 		//*mug1_var = objects[object_id_1].private[0];
106 101
 
107
-		obj_delete_and_free_tiles(&objects[*temp_obj_id1]);
102
+		obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id1]));
108 103
 		*temp_obj_id1 = 0;
109 104
 	}
110 105
 
@@ -112,20 +107,20 @@ void delete_mugshot()
112 107
 	if(*temp_obj_id2 != 0)
113 108
 	{
114 109
 		gpu_pal_free_by_tag(MUGSHOT_2_TAG);
115
-		gpu_tile_obj_free_by_tag(MUGSHOT_2_TAG);
110
+		obj_gpu_tile_free_by_tag(MUGSHOT_2_TAG);
116 111
 
117 112
 		//*mug2_var = 0;
118 113
 		//do reset mugshot var ; set it to old value instead
119 114
 
120 115
 		//*mug2_var = objects[object_id_2].private[0];
121 116
 
122
-		obj_delete_and_free_tiles(&objects[*temp_obj_id2]);
117
+		obj_delete_and_free_tiles(&(superstate.sprites[*temp_obj_id2]));
123 118
 		*temp_obj_id2 = 0;
124 119
 	}
125 120
 
126 121
 }
127 122
 
128
-void null_callback(object *self)
123
+void null_callback(struct obj_entity *self)
129 124
 {
130 125
 	//null_callback
131 126
 }

+ 2
- 2
src/overworld/grass_animation.c Bestand weergeven

@@ -1,4 +1,4 @@
1
-#include <bpre.h>
1
+/*#include <bpre.h>
2 2
 
3 3
 #include "oe_animation.h"
4 4
 
@@ -9,4 +9,4 @@ void grass_step_general(struct npc_state* npc)
9 9
     
10 10
 }
11 11
 
12
-void grass_step_normal()
12
+void grass_step_normal()*/

+ 111
- 0
src/player_interaction/#on_step.S# Bestand weergeven

@@ -0,0 +1,111 @@
1
+#include <config.h>
2
+
3
+.text
4
+.align 2
5
+.thumb
6
+.global on_step
7
+on_step:
8
+	push {r5}
9
+	bl safari_step
10
+	lsl r0, #0x18
11
+	lsr r0, #0x18
12
+	cmp r0, #1
13
+	beq return_true
14
+	
15
+	ldrh r0, =FLAG_WALK_SCRIPT
16
+	bl read_flag
17
+	cmp r0, #0
18
+	beq check_walking_script
19
+	sub SP, #4
20
+	mov r0, sp
21
+	mov r1, sp
22
+	add r1, #2
23
+	bl get_player_to
24
+	mov r0, sp
25
+	mov r1, sp
26
+	add r1, #2
27
+	ldrh r0, [r0]
28
+	ldrh r1, [r1]
29
+	add sp, #4
30
+	lsl r0, #0x10
31
+	asr r4, r0, #0x10
32
+	lsl r1, #0x10
33
+	asr r5, r1, #0x10
34
+	mov r0, r4
35
+	mov r1, r5
36
+	bl check_block_role
37
+	lsl r0, #0x18
38
+	lsr r0, #0x18
39
+	ldr r1, behavior_walk_table
40
+	lsl r0, #2
41
+	add r0, r1
42
+	ldr r0, [r0]
43
+	mov r2, #0
44
+	sub r2, #1
45
+	cmp r0, r2
46
+	beq check_walking_script
47
+	
48
+	bl execute_script
49
+	b return_false
50
+
51
+check_walking_script:
52
+	
53
+	ldrh r0, =WALK_SCRIPT_VAR
54
+	bl read_var
55
+	ldrh r0, [r0]
56
+	cmp r0, #0
57
+	beq return_false
58
+	sub r0, #1
59
+	ldr r1, script_walk_table
60
+	lsl r0, #2
61
+	add r0, r1
62
+	ldr r0, [r0]
63
+	mov r2, #0
64
+	sub r2, #1
65
+	cmp r0, r2
66
+	beq return_false
67
+	@@@EXECUTE WALKING SCRIPT HERE
68
+	bl execute_script
69
+
70
+return_false:
71
+	mov r0, #0
72
+	b end
73
+
74
+return_true:
75
+	mov r0, #1
76
+end:
77
+	pop {r5}
78
+	pop {r4}
79
+	pop {r1}
80
+	bx r1
81
+
82
+safari_step:
83
+	ldr r3, =0x080A0F0C|1
84
+	bx r3
85
+
86
+get_player_to:
87
+	ldr r3, =0x0805C538|1
88
+	bx r3
89
+
90
+check_block_role:
91
+	ldr r3, =0x08058F78|1
92
+	bx r3
93
+
94
+read_var:
95
+	ldr r3, =var_access
96
+	bx r3
97
+
98
+read_flag:
99
+	ldr r3, =flag_decrypt_func
100
+	bx r3
101
+	
102
+execute_script:
103
+	ldr r3, =0x08069AE4|1
104
+	bx r3
105
+
106
+.align 2
107
+behavior_walk_table:
108
+	.word 0x09700B20
109
+
110
+script_walk_table:
111
+	.word 0x09700F20

+ 1
- 1
src/specials/camera_move.c Bestand weergeven

@@ -15,7 +15,7 @@ void update_screen_cam()
15 15
 	objc_exec();
16 16
 	obj_sync();
17 17
 	gpu_pal_upload();
18
-	gpu_sprites_upload();
18
+	obj_gpu_sprites_upload();
19 19
 }
20 20
 
21 21
 void sp_move_camera()

+ 14
- 14
src/specials/cutscene_meteor.c Bestand weergeven

@@ -29,30 +29,30 @@ struct meteor_memory{
29 29
 
30 30
 static struct meteor_memory* memory = (struct meteor_memory*)(0x0203FFC0);
31 31
 
32
-static struct sprite sprite_meteor = {0, 0x8000, 0x800, 0x0};
32
+static struct obj_oam_attributes sprite_meteor = {0, 0x8000, 0x800, 0x0};
33 33
 
34
-static struct frame meteor_frames [4] = {
34
+static struct obj_frame meteor_frames [4] = {
35 35
 	{0, 10},
36 36
 	{16, 10},
37 37
 	{32, 10},
38 38
 	{0xFFFE, 0}
39 39
 };
40 40
 
41
-static struct frame* meteor_frames_a [1] = {
41
+static struct obj_frame* meteor_frames_a [1] = {
42 42
 	meteor_frames
43 43
 };
44 44
 
45
-static struct template template_meteor = {
45
+static struct obj_template template_meteor = {
46 46
 	TAG_METEOR,
47 47
 	TAG_METEOR,
48 48
 	&sprite_meteor,
49 49
 	meteor_frames_a,
50 50
 	0,
51
-	(rotscale_frame **) 0x08231CFC,
51
+	(struct obj_rotscale_frame **) 0x08231CFC,
52 52
 	meteor_callback
53 53
 };
54 54
 
55
-void meteor_callback(object* self)
55
+void meteor_callback(struct obj_entity* self)
56 56
 {
57 57
 	if(memory->meteor_moving > 0)
58 58
 	{
@@ -239,14 +239,14 @@ void setup_vram()
239 239
 
240 240
 	//setup oam
241 241
 	obj_delete_all();
242
-	resource gfx_meteor = {(void*)met_meteorTiles, 0x1C00, TAG_METEOR};
243
-	resource pal_meteor = {(void*)met_meteorPal, TAG_METEOR};
244
-	gpu_pal_obj_alloc_tag_and_apply(&pal_meteor);
245
-	gpu_tile_obj_decompress_alloc_tag_and_upload(&gfx_meteor);
242
+	struct obj_resource gfx_meteor = {(void*)met_meteorTiles, 0x1C00, TAG_METEOR};
243
+	struct obj_resource pal_meteor = {(void*)met_meteorPal, TAG_METEOR};
244
+	obj_gpu_pal_alloc_tag_and_apply(&pal_meteor);
245
+	obj_gpu_tile_decompress_alloc_tag_and_upload(&gfx_meteor);
246 246
 
247
-	u8 meteor_id = template_instanciate_forward_search(&template_meteor, 0, 100, 1);
248
-	objects[meteor_id].x = 200;
249
-	objects[meteor_id].y = 0;
247
+	u8 meteor_id = obj_template_instanciate_forward_search(&template_meteor, 0, 100, 1);
248
+	superstate.sprites[meteor_id].x = 200;
249
+	superstate.sprites[meteor_id].y = 0;
250 250
 
251 251
 	memory->animate_clouds = 1;
252 252
 }
@@ -258,7 +258,7 @@ void update_screen()
258 258
 	objc_exec();
259 259
 	obj_sync();
260 260
 	gpu_pal_upload();
261
-	gpu_sprites_upload();
261
+	obj_gpu_sprites_upload();
262 262
 	if(memory->cloud_animation_state == 0 && memory->animate_clouds != 0)
263 263
 	{
264 264
 		u16 sky_h = lcd_io_get(0x18);

+ 1
- 1
src/specials/cutscene_meteor.h Bestand weergeven

@@ -12,7 +12,7 @@ void play_meteor();
12 12
 void setup_vram();
13 13
 void cutscene();
14 14
 void update_screen();
15
-void meteor_callback(object* self);
15
+void meteor_callback(struct obj_entity* self);
16 16
 void end_playback();
17 17
 
18 18
 #endif