Skip to content
Merged
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
2 changes: 1 addition & 1 deletion base/src/set_initial_flags.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "flags.h"
#include <stdint.h>

void set_flag(int addr, uint8_t bit) {
__attribute__((always_inline)) static void set_flag(int addr, uint8_t bit) {
*((uint8_t *)addr) |= bit;
}

Expand Down
16 changes: 7 additions & 9 deletions base/src/spawn_custom_freestanding_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

#define RUPY 0x52555059

static uint16_t get_item_id() {
uint16_t *item_id_address;
// pull the base address of the NPCA entry's item_id off of the stack
asm volatile("ldr %0, [sp, #0x4]" : "=r"(item_id_address) :);
// return the item id
return item_id_address[0x10];
}

/**
* @param param_1 - original function arg, don't modify
* @param npc_type - 4 character string representing NPC type.
Expand All @@ -22,7 +14,13 @@ uint16_t spawn_custom_freestanding_item(void *param_1, uint32_t npc_type,
uint16_t (*spawn_npc)(void *, uint32_t, void *, uint16_t *) =
(void *)0x20C3FE8;

uint16_t item_id = get_item_id();
uint16_t *item_id_address;
// pull the base address of the NPCA entry's item_id off of the stack
asm volatile("ldr %0, [sp, #0x4]" : "=r"(item_id_address) :);

// get the item id
uint16_t item_id = item_id_address[0x10];

// if item_id is 0x1, continue as the vanilla game does.
if (item_id == 0x1) {
return (*spawn_npc)(param_1, npc_type, param_3, param_4);
Expand Down