File tree 2 files changed +51
-0
lines changed 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 83
83
mov r1 , 0x7d
84
84
ldr r0 , [ r0 ]
85
85
pop pc
86
+
87
+ .thumb
88
+ @set_starting_items:
89
+ push lr
90
+
91
+ push r1 ; save r1, as it's used later on in the original code
92
+ bl set_starting_items
93
+ pop r1 ; restore r1
94
+
95
+ ; These three instructions are the original instructions that the `bl` to this current
96
+ ; function replaced. They are needed to be able to return to the original code.
97
+ mov r0 , 0x3C
98
+ mul r0 , r1
99
+
100
+ pop pc
86
101
.pool
87
102
.endarea
88
103
129
144
.pool
130
145
.endarea
131
146
147
+ .thumb
148
+ .org 0x20ad20e
149
+ .area 0x6 , 0x00
150
+ ; hook into the function that sets the starting item flags
151
+ bl @set_starting_items
152
+ ; original instruction, do not change
153
+ b 0x20ad216
154
+ .pool
155
+ .endarea
156
+
132
157
.thumb
133
158
.org 0x20ae1c2
134
159
.area 0x6 , 0x00
439
464
.importobj "code/spawn_custom_freestanding_item.o"
440
465
.importobj "code/custom_salvage_item.o"
441
466
.importobj "code/extend_give_item_function.o"
467
+ .importobj "code/set_starting_items.o"
442
468
.close
Original file line number Diff line number Diff line change
1
+ #include <stdbool.h>
2
+ #include <stdint.h>
3
+
4
+ typedef struct {
5
+ uint8_t address ;
6
+ uint8_t bit ;
7
+ } ItemFlag ;
8
+
9
+ // define array of ints
10
+ ItemFlag starting_items [] = {
11
+ // Oshus sword
12
+ // {0x0, 0x1}, // TODO: enable this to support "Start with sword setting"
13
+
14
+ // SW Sea Chart
15
+ {0x8 , 0x2 }, // TODO: make this dynamic when the starting island is randomized
16
+ };
17
+
18
+ __attribute__((target ("thumb" ))) void set_starting_items (void ) {
19
+ uint8_t * base_address = (uint8_t * )(0x21BA604 );
20
+
21
+ for (int i = 0 ; i < sizeof (starting_items ) / sizeof (ItemFlag ); i ++ ) {
22
+ uint8_t * flag = (uint8_t * )(starting_items [i ].address + base_address );
23
+ * flag |= starting_items [i ].bit ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments