Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions base/src/execute_npc_spawner.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "ph.h"
#include <stdint.h>

uint32_t execute_npc_spawner(void *param_1, uint32_t npc_id) {
NPC *npc = get_npc_address(npc_id);
if (npc != 0x0) {
return npc->spawn_function();
}
return 0;
}
8 changes: 8 additions & 0 deletions base/src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.relativeinclude on
.erroronwarning on

.include "ph.asm"

.open "../arm9_original.bin","../arm9_compressed.bin",0x02004000
.arm
.org 0x54894 + 0x2004000
Expand All @@ -10,6 +12,7 @@
.importobj "src/set_initial_flags.o"
// .importobj "src/faster_boat.o"
.importobj "src/spawn_custom_freestanding_item.o"
.importobj "src/execute_npc_spawner.o"

@init_flags:
sub r0, lr, 0x30 ; set_initial_flags() function parameter
Expand Down Expand Up @@ -51,6 +54,11 @@
.area 0x4
b @init_flags
.endarea

.org 0x20c402c
.area 0x4
bl execute_npc_spawner
.endarea
.close


Expand Down
1 change: 1 addition & 0 deletions base/src/ph.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.definelabel get_npc_address, 0x203e824
13 changes: 13 additions & 0 deletions base/src/ph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdint.h>

typedef struct {
uint32_t npc_id;
uint32_t (*spawn_function)(void);
uint32_t unknown1;
uint32_t unknown2;
struct NPC *next;
} NPC;

// searches the list of NPC structs in memory for the given NPC and returns its
// address.
extern NPC *get_npc_address(uint32_t npc_id); // 203e824