Skip to content

Commit

Permalink
wip starting item support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mike8699 committed Nov 16, 2024
1 parent 2c37ba5 commit 3c60c0f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions base/code/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@
mov r1, 0x7d
ldr r0, [r0]
pop pc

.thumb
@set_starting_items:
push lr

push r1 ; save r1, as it's used later on in the original code
bl set_starting_items
pop r1 ; restore r1

; These three instructions are the original instructions that the `bl` to this current
; function replaced. They are needed to be able to return to the original code.
mov r0, 0x3C
mul r0, r1

pop pc
.pool
.endarea

Expand Down Expand Up @@ -129,6 +144,16 @@
.pool
.endarea

.thumb
.org 0x20ad20e
.area 0x6, 0x00
; hook into the function that sets the starting item flags
bl @set_starting_items
; original instruction, do not change
b 0x20ad216
.pool
.endarea

.thumb
.org 0x20ae1c2
.area 0x6, 0x00
Expand Down Expand Up @@ -472,5 +497,6 @@
.importobj "code/spawn_custom_freestanding_item.o"
.importobj "code/custom_salvage_item.o"
.importobj "code/extend_give_item_function.o"
.importobj "code/set_starting_items.o"
.endarea
.close
7 changes: 7 additions & 0 deletions base/code/set_starting_items.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "ph.h"
#include <stdbool.h>
#include <stdint.h>

__attribute__((target("thumb"))) void set_starting_items(void) {
gItemManager->mItemFlags[1] |= 0x2; // start player with SW sea chart
}

0 comments on commit 3c60c0f

Please sign in to comment.