Skip to content

Commit 5e0be2c

Browse files
committed
wip starting item support
We'll start with just the SW Sea chart, but this should be expanded in the future to eventually support any arbitrary item(s) the player chooses.
1 parent 55469fb commit 5e0be2c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

base/code/main.asm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@
8383
mov r1, 0x7d
8484
ldr r0, [r0]
8585
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
86101
.pool
87102
.endarea
88103

@@ -129,6 +144,16 @@
129144
.pool
130145
.endarea
131146

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+
132157
.thumb
133158
.org 0x20ae1c2
134159
.area 0x6, 0x00
@@ -440,5 +465,6 @@
440465
.importobj "code/spawn_custom_freestanding_item.o"
441466
.importobj "code/custom_salvage_item.o"
442467
.importobj "code/extend_give_item_function.o"
468+
.importobj "code/set_starting_items.o"
443469
.endarea
444470
.close

base/code/set_starting_items.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "ph.h"
2+
#include <stdbool.h>
3+
#include <stdint.h>
4+
5+
__attribute__((target("thumb"))) void set_starting_items(void) {
6+
gItemManager->mItemFlags[1] |= 0x2; // start player with SW sea chart
7+
}

0 commit comments

Comments
 (0)