From d3dd7a908e1df8e6ef69721d5c1c672e58ad0944 Mon Sep 17 00:00:00 2001 From: Ogre Date: Fri, 15 Sep 2023 02:16:33 +0200 Subject: [PATCH] Found `item` data Edited Makefile to handle the new splits Added `ctx_includes.h` Build: OK --- Makefile | 2 +- ctx_includes.h | 9 +++++++++ include/common.h | 18 ++++++++++++++++++ splat.yaml | 3 +++ src/ability.c | 26 +++++++++++++++++++++----- symbol_addrs.txt | 7 +++++++ tools/item_data.py | 0 7 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 ctx_includes.h create mode 100644 tools/item_data.py diff --git a/Makefile b/Makefile index b9e826e..8ef904d 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ split: @touch $(SPLAT_TIMESTAMP) context: - $(V)$(PYTHON) tools/m2ctx.py include/common.h + $(V)$(PYTHON) tools/m2ctx.py ctx_includes.h $(BUILD_DIR)/src/boot.c.o: OPTFLAGS = -O0 diff --git a/ctx_includes.h b/ctx_includes.h new file mode 100644 index 0000000..f77f1b2 --- /dev/null +++ b/ctx_includes.h @@ -0,0 +1,9 @@ +#include + +#include "common.h" +#include "ability.h" +#include "character.h" +#include "class.h" +#include "element.h" +#include "equipment.h" +#include "libmus.h" \ No newline at end of file diff --git a/include/common.h b/include/common.h index f7a8dce..586f3be 100644 --- a/include/common.h +++ b/include/common.h @@ -476,5 +476,23 @@ extern void __character_initialise(CharacterSlot *arg0, u8 level); extern u16 character_get_item(CharacterSlot* character, u8 slot); extern void __character_handle_levelup(CharacterSlot *slot); +typedef struct { + /* 0x0 */ char *name; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 field_0x5; + /* 0x6 */ u16 buy_price; + /* 0x8 */ u8 field_0x8; + /* 0x9 */ u8 field_0x9; + /* 0xa */ u8 field_0xa; + /* 0xb */ u8 field_0xb; +} ItemData; // size:0xc + +extern ItemData ITEM_DATA[45]; + +extern char *item_get_name(u16 arg0); +extern u8 item_get_field_0x4(u16 arg0); +extern u8 item_get_field_0x5(u16 arg0); +extern u8 item_get_field_0x8(u16 arg0); +extern u8 item_get_field_0x9(u16 arg0); #endif \ No newline at end of file diff --git a/splat.yaml b/splat.yaml index 1a40f6d..84f2446 100644 --- a/splat.yaml +++ b/splat.yaml @@ -2135,6 +2135,9 @@ segments: # Found in DMA log (N64 startup) - [0x238f7ba, bin] + # Calculated from `__calls_romCopy_8009DAF4` call in `func_8016FBE0` + - [0x238F96A, bin] + - [0x26FF9F0, bin, "viewdata"] - [0x26FFC28, bin, "viewdata1"] - [0x26FFD48, bin, "viewdata2"] diff --git a/src/ability.c b/src/ability.c index 92cef18..d4e4c39 100644 --- a/src/ability.c +++ b/src/ability.c @@ -72,12 +72,28 @@ INCLUDE_ASM(const s32, "ability", __character_handle_levelup); INCLUDE_ASM(const s32, "ability", __character_initialise); -INCLUDE_ASM(const s32, "ability", func_8016F4E0); +/* 453E0 8016F4E0 */ +char *item_get_name(u16 arg0) { + return ITEM_DATA[arg0].name; +} -INCLUDE_ASM(const s32, "ability", func_8016F500); +/* 45400 8016F500 */ +u8 item_get_field_0x4(u16 arg0) { + return ITEM_DATA[arg0].field_0x4; +} -INCLUDE_ASM(const s32, "ability", func_8016F520); +/* 45420 8016F520 */ +u8 item_get_field_0x5(u16 arg0) { + return ITEM_DATA[arg0].field_0x5; +} -INCLUDE_ASM(const s32, "ability", func_8016F540); +/* 45440 8016F540 */ +u8 item_get_field_0x8(u16 arg0) { + return ITEM_DATA[arg0].field_0x8; +} + +/* 45460 8016F560 */ +u8 item_get_field_0x9(u16 arg0) { + return ITEM_DATA[arg0].field_0x9; +} -INCLUDE_ASM(const s32, "ability", func_8016F560); diff --git a/symbol_addrs.txt b/symbol_addrs.txt index db219d1..085feb7 100644 --- a/symbol_addrs.txt +++ b/symbol_addrs.txt @@ -134,6 +134,13 @@ equipment_is_weapon = 0x8016F9F0; // rom:0x458F0 equipment_get_first_weapon = 0x8016FA34; // rom:0x45934 equipment_get_first_spellbook = 0x8016FB50; // rom:0x45A50 +ITEM_DATA = 0x8018E6CC; // rom:0x645CC size:0x21C +item_get_name = 0x8016F4E0; // rom:0x453E0 +item_get_field_0x4 = 0x8016F500; // rom:0x45400 +item_get_field_0x5 = 0x8016F520; // rom:0x45420 +item_get_field_0x8 = 0x8016F540; // rom:0x45440 +item_get_field_0x9 = 0x8016F560; // rom:0x45460 + CHARACTER_NAME_ARRAY_00 = 0x8018EB48; __setup_overlay_79730 = 0x8017B5EC; diff --git a/tools/item_data.py b/tools/item_data.py new file mode 100644 index 0000000..e69de29