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 Jan 12, 2025
1 parent 2c4f1b8 commit ef5d3b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions base/code/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@
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 @@ -130,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 @@ -479,5 +503,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 ef5d3b1

Please sign in to comment.