From f2b3efc96b2b263a1591cc73612732ec5ddf4533 Mon Sep 17 00:00:00 2001 From: Ogre Date: Fri, 15 Sep 2023 00:43:41 +0200 Subject: [PATCH] Refactored `item` to `equipment` Build: OK --- include/class.h | 12 +- include/common.h | 2 +- include/equipment.h | 121 +++++ include/item.h | 116 ----- splat.yaml | 3 +- src/43100.c | 342 +++++++++++++ src/equipment.c | 231 +++++++++ src/item.c | 570 ---------------------- symbol_addrs.txt | 75 ++- tools/{item_data.py => equipment_data.py} | 0 10 files changed, 740 insertions(+), 732 deletions(-) create mode 100644 include/equipment.h delete mode 100644 include/item.h create mode 100644 src/43100.c create mode 100644 src/equipment.c delete mode 100644 src/item.c rename tools/{item_data.py => equipment_data.py} (100%) diff --git a/include/class.h b/include/class.h index 11cd33d..c939803 100644 --- a/include/class.h +++ b/include/class.h @@ -3,7 +3,7 @@ #include -#include "item.h" +#include "equipment.h" typedef struct { /* 0x00 */ char* name; @@ -80,7 +80,7 @@ typedef struct { } ClassData; // size:0x48 extern ClassData CLASS_DATA[]; -extern ItemId (*FP_CLASS_GET_ITEM[4])(u8, u8); +extern EquipmentId (*FP_CLASS_GET_ITEM[4])(u8, u8); extern u8 class_get_field_0x2c(u8 portrait, u8 class); extern u8 class_get_ability_front(u8 portrait, u8 class); @@ -94,10 +94,10 @@ extern u8 class_get_gender(u8 portrait, u8 class); extern u8 class_get_leadership_rank(u8 portrait, u8 class); extern u8 class_get_global_flag(u8 portrait, u8 class); -extern ItemId class_get_item_upper_left(u8 portrait, u8 class); -extern ItemId class_get_item_upper_right(u8 portrait, u8 class); -extern ItemId class_get_item_lower_left(u8 portrait, u8 class); -extern ItemId class_get_item_lower_right(u8 portrait, u8 class); +extern EquipmentId class_get_item_upper_left(u8 portrait, u8 class); +extern EquipmentId class_get_item_upper_right(u8 portrait, u8 class); +extern EquipmentId class_get_item_lower_left(u8 portrait, u8 class); +extern EquipmentId class_get_item_lower_right(u8 portrait, u8 class); extern char* class_get_ability_front_name(u8 portrait, u8 class); extern char* class_get_ability_middle_name(u8 portrait, u8 class); diff --git a/include/common.h b/include/common.h index bd3dac3..9007721 100644 --- a/include/common.h +++ b/include/common.h @@ -35,7 +35,7 @@ typedef u8 bool; #define ARRAY_LENGTH(x) ((sizeof(x)) / (sizeof(x[0]))) #include "character.h" -#include "item.h" +#include "equipment.h" #include "ability.h" #include "class.h" diff --git a/include/equipment.h b/include/equipment.h new file mode 100644 index 0000000..1a0808c --- /dev/null +++ b/include/equipment.h @@ -0,0 +1,121 @@ +#ifndef __ITEM_H__ +#define __ITEM_H__ + +#include + +#include "element.h" + +typedef u8 EquipmentType; + +#define EQUIPMENT_TYPE_SWORD 0x01 +#define EQUIPMENT_TYPE_GREATSWORD 0x02 +#define EQUIPMENT_TYPE_THRUSTING_SWORD 0x03 +#define EQUIPMENT_TYPE_1_HANDED_HAMMER 0x04 +#define EQUIPMENT_TYPE_2_HANDED_HAMMER 0x05 +#define EQUIPMENT_TYPE_SHORT_SPEAR 0x06 +#define EQUIPMENT_TYPE_SPEAR 0x07 +#define EQUIPMENT_TYPE_WHIP 0x08 +#define EQUIPMENT_TYPE_CLAW 0x09 +#define EQUIPMENT_TYPE_BOW 0x0a +#define EQUIPMENT_TYPE_MACE 0x0b +#define EQUIPMENT_TYPE_STAFF 0x0c +#define EQUIPMENT_TYPE_DOLL 0x0d +#define EQUIPMENT_TYPE_SMALL_SHIELD 0x0e +#define EQUIPMENT_TYPE_SHIELD 0x0f +#define EQUIPMENT_TYPE_LIGHT_ARMOR 0x10 +#define EQUIPMENT_TYPE_ARMOR 0x11 +#define EQUIPMENT_TYPE_FULL_BODY_ARMOR 0x12 +#define EQUIPMENT_TYPE_ROBE 0x13 +#define EQUIPMENT_TYPE_GARMENT 0x14 +#define EQUIPMENT_TYPE_HELM 0x15 +#define EQUIPMENT_TYPE_HEAD_GEAR 0x16 +#define EQUIPMENT_TYPE_SPELLBOOK 0x17 +#define EQUIPMENT_TYPE_FAN 0x18 +#define EQUIPMENT_TYPE_ACCESSORY 0x19 +#define EQUIPMENT_TYPE_INVALID 0xFF + +typedef u16 EquipmentId; + +#define EQUIPMENT_ID_GALLANT_DOLL 132 + +typedef struct { + /* 0x00 */ char *name; + /* 0x04 */ EquipmentType type; + /* 0x05 */ Element element; + /* 0x06 */ u8 field_0x6; + /* 0x07 */ u8 field_0x7; + /* 0x08 */ u16 buy_price; + /* 0x0a */ s8 strength; + /* 0x0b */ s8 intelligence; + /* 0x0c */ s8 agility; + /* 0x0d */ s8 dexterity; + /* 0x0e */ s8 vitality; + /* 0x0f */ s8 mentality; + /* 0x10 */ s8 field_0x10; + /* 0x11 */ s8 res_strike; + /* 0x12 */ s8 res_wind; + /* 0x13 */ s8 res_fire; + /* 0x14 */ s8 res_earth; + /* 0x15 */ s8 res_water; + /* 0x16 */ s8 res_holy; + /* 0x17 */ u8 res_dark; + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1a */ u8 field_0x1a; + /* 0x1b */ u8 field_0x1b; + /* 0x1c */ u8 field_0x1c; + /* 0x1d */ u8 field_0x1d; + /* 0x1e */ u8 field_0x1e; + /* 0x1f */ u8 field_0x1f; +} EquipmentData; // size:0x20 + +extern char *EQUIPMENT_TYPE_NAMES[]; +extern EquipmentData EQUIPMENT_DATA[]; +extern s8 (*FP_EQUIPMENT_GET_RESISTANCE[])(EquipmentId index); + +extern char *equipment_get_name(EquipmentId index); +extern EquipmentType equipment_get_type(EquipmentId index); +extern Element equipment_get_element(EquipmentId index); + +extern u8 equipment_get_field_0x6(EquipmentId index); +extern u16 equipment_get_buy_price(EquipmentId index); +extern s8 equipment_get_field_0x10(EquipmentId index); + +extern s8 equipment_get_strength(EquipmentId index); +extern s8 equipment_get_vitality(EquipmentId index); +extern s8 equipment_get_intelligence(EquipmentId index); +extern s8 equipment_get_mentality(EquipmentId index); +extern s8 equipment_get_agility(EquipmentId index); +extern s8 equipment_get_dexterity(EquipmentId index); + +extern s8 equipment_get_resistance_strike(EquipmentId index); +extern s8 equipment_get_resistance_wind(EquipmentId index); +extern s8 equipment_get_resistance_fire(EquipmentId index); +extern s8 equipment_get_resistance_earth(EquipmentId index); +extern s8 equipment_get_resistance_water(EquipmentId index); +extern s8 equipment_get_resistance_holy(EquipmentId index); +extern s8 equipment_get_resistance_dark(EquipmentId index); + +extern u8 equipment_get_field_0x18_b68(EquipmentId index); +extern u8 equipment_get_field_0x18_b46(EquipmentId index); +extern u8 equipment_get_field_0x18_b24(EquipmentId index); +extern u8 equipment_get_field_0x18_b12(EquipmentId index); + +extern u8 equipment_get_field_0x19_b68(EquipmentId index); +extern u8 equipment_get_field_0x19_b46(EquipmentId index); +extern u8 equipment_get_field_0x19_b24(EquipmentId index); +extern u8 equipment_get_field_0x19_b12(EquipmentId index); + +extern u8 equipment_get_field_0x1a_b7(EquipmentId index); + +extern u8 equipment_is_weapon(EquipmentId index); +extern EquipmentId equipment_get_first_weapon(EquipmentId arg0, + EquipmentId arg1, + EquipmentId arg2, + EquipmentId arg3); +extern EquipmentId equipment_get_first_spellbook(EquipmentId arg0, + EquipmentId arg1, + EquipmentId arg2, + EquipmentId arg3); + +#endif \ No newline at end of file diff --git a/include/item.h b/include/item.h deleted file mode 100644 index f5d22a3..0000000 --- a/include/item.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef __ITEM_H__ -#define __ITEM_H__ - -#include - -#include "element.h" - -typedef u8 ItemType; - -#define ITEM_TYPE_SWORD 0x01 -#define ITEM_TYPE_GREATSWORD 0x02 -#define ITEM_TYPE_THRUSTING_SWORD 0x03 -#define ITEM_TYPE_1_HANDED_HAMMER 0x04 -#define ITEM_TYPE_2_HANDED_HAMMER 0x05 -#define ITEM_TYPE_SHORT_SPEAR 0x06 -#define ITEM_TYPE_SPEAR 0x07 -#define ITEM_TYPE_WHIP 0x08 -#define ITEM_TYPE_CLAW 0x09 -#define ITEM_TYPE_BOW 0x0a -#define ITEM_TYPE_MACE 0x0b -#define ITEM_TYPE_STAFF 0x0c -#define ITEM_TYPE_DOLL 0x0d -#define ITEM_TYPE_SMALL_SHIELD 0x0e -#define ITEM_TYPE_SHIELD 0x0f -#define ITEM_TYPE_LIGHT_ARMOR 0x10 -#define ITEM_TYPE_ARMOR 0x11 -#define ITEM_TYPE_FULL_BODY_ARMOR 0x12 -#define ITEM_TYPE_ROBE 0x13 -#define ITEM_TYPE_GARMENT 0x14 -#define ITEM_TYPE_HELM 0x15 -#define ITEM_TYPE_HEAD_GEAR 0x16 -#define ITEM_TYPE_SPELLBOOK 0x17 -#define ITEM_TYPE_FAN 0x18 -#define ITEM_TYPE_ACCESSORY 0x19 -#define ITEM_TYPE_INVALID 0xFF - - -typedef u16 ItemId; - -#define ITEM_ID_GALLANT_DOLL 132 - -typedef struct { - /* 0x00 */ char* name; - /* 0x04 */ ItemType type; - /* 0x05 */ Element element; - /* 0x06 */ u8 field_0x6; - /* 0x07 */ u8 field_0x7; - /* 0x08 */ u16 buy_price; - /* 0x0a */ s8 strength; - /* 0x0b */ s8 intelligence; - /* 0x0c */ s8 agility; - /* 0x0d */ s8 dexterity; - /* 0x0e */ s8 vitality; - /* 0x0f */ s8 mentality; - /* 0x10 */ s8 field_0x10; - /* 0x11 */ s8 res_strike; - /* 0x12 */ s8 res_wind; - /* 0x13 */ s8 res_fire; - /* 0x14 */ s8 res_earth; - /* 0x15 */ s8 res_water; - /* 0x16 */ s8 res_holy; - /* 0x17 */ u8 res_dark; - /* 0x18 */ u8 field_0x18; - /* 0x19 */ u8 field_0x19; - /* 0x1a */ u8 field_0x1a; - /* 0x1b */ u8 field_0x1b; - /* 0x1c */ u8 field_0x1c; - /* 0x1d */ u8 field_0x1d; - /* 0x1e */ u8 field_0x1e; - /* 0x1f */ u8 field_0x1f; -} ItemData; // size:0x20 - -extern char* ITEM_TYPE_NAMES[]; -extern ItemData ITEM_DATA[]; -extern s8 (*FP_ITEM_GET_RESISTANCE[])(ItemId index); - -extern char* item_get_name(ItemId index); -extern ItemType item_get_type(ItemId index); -extern Element item_get_element(ItemId index); - -extern u8 item_get_field_0x6(ItemId index); -extern u16 item_get_buy_price(ItemId index); -extern s8 item_get_field_0x10(ItemId index); - -extern s8 item_get_strength(ItemId index); -extern s8 item_get_vitality(ItemId index); -extern s8 item_get_intelligence(ItemId index); -extern s8 item_get_mentality(ItemId index); -extern s8 item_get_agility(ItemId index); -extern s8 item_get_dexterity(ItemId index); - -extern s8 item_get_resistance_strike(ItemId index); -extern s8 item_get_resistance_wind(ItemId index); -extern s8 item_get_resistance_fire(ItemId index); -extern s8 item_get_resistance_earth(ItemId index); -extern s8 item_get_resistance_water(ItemId index); -extern s8 item_get_resistance_holy(ItemId index); -extern s8 item_get_resistance_dark(ItemId index); - -extern u8 item_get_field_0x18_b68(ItemId index); -extern u8 item_get_field_0x18_b46(ItemId index); -extern u8 item_get_field_0x18_b24(ItemId index); -extern u8 item_get_field_0x18_b12(ItemId index); - -extern u8 item_get_field_0x19_b68(ItemId index); -extern u8 item_get_field_0x19_b46(ItemId index); -extern u8 item_get_field_0x19_b24(ItemId index); -extern u8 item_get_field_0x19_b12(ItemId index); - -extern u8 item_get_field_0x1a_b7(ItemId index); - -extern u8 item_is_weapon(ItemId index); -extern ItemId item_get_first_weapon(ItemId arg0, ItemId arg1, ItemId arg2, ItemId arg3); -extern ItemId item_get_first_spellbook(ItemId arg0, ItemId arg1, ItemId arg2, ItemId arg3); - -#endif \ No newline at end of file diff --git a/splat.yaml b/splat.yaml index 67c0893..bd19aa7 100644 --- a/splat.yaml +++ b/splat.yaml @@ -439,7 +439,8 @@ segments: - [0x420D0, asm] - [0x42C30, c] - [0x42C90, asm] - - [0x43100, c, "item"] + - [0x43100, c] + - [0x45480, c, "equipment"] - [0x45AE0, c] - [0x45CB0, asm] - [0x46090, asm] diff --git a/src/43100.c b/src/43100.c new file mode 100644 index 0000000..c6da492 --- /dev/null +++ b/src/43100.c @@ -0,0 +1,342 @@ +#include "common.h" +#include "element.h" +#include "equipment.h" + +INCLUDE_ASM(const s32, "43100", func_8016D200); + +INCLUDE_ASM(const s32, "43100", func_8016D254); + +INCLUDE_ASM(const s32, "43100", func_8016D2A8); + +INCLUDE_ASM(const s32, "43100", func_8016D2FC); + +INCLUDE_ASM(const s32, "43100", func_8016D350); + +INCLUDE_ASM(const s32, "43100", func_8016D3A4); + +INCLUDE_ASM(const s32, "43100", func_8016D3F8); + +INCLUDE_ASM(const s32, "43100", func_8016D44C); + +INCLUDE_ASM(const s32, "43100", func_8016D4A0); + +INCLUDE_ASM(const s32, "43100", func_8016D4F4); + +INCLUDE_ASM(const s32, "43100", func_8016D548); + +INCLUDE_ASM(const s32, "43100", func_8016D59C); + +INCLUDE_ASM(const s32, "43100", func_8016D5F0); + +INCLUDE_ASM(const s32, "43100", func_8016D644); + +INCLUDE_ASM(const s32, "43100", func_8016D698); + +INCLUDE_ASM(const s32, "43100", func_8016D6EC); + +INCLUDE_ASM(const s32, "43100", func_8016D740); + +INCLUDE_ASM(const s32, "43100", func_8016D794); + +INCLUDE_ASM(const s32, "43100", func_8016D7E8); + +INCLUDE_ASM(const s32, "43100", func_8016D83C); + +INCLUDE_ASM(const s32, "43100", func_8016D890); + +INCLUDE_ASM(const s32, "43100", func_8016D8E4); + +INCLUDE_ASM(const s32, "43100", func_8016D938); + +INCLUDE_ASM(const s32, "43100", func_8016D98C); + +INCLUDE_ASM(const s32, "43100", func_8016D9E0); + +INCLUDE_ASM(const s32, "43100", func_8016DA34); + +INCLUDE_ASM(const s32, "43100", func_8016DA88); + +INCLUDE_ASM(const s32, "43100", func_8016DADC); + +INCLUDE_ASM(const s32, "43100", func_8016DB30); + +INCLUDE_ASM(const s32, "43100", func_8016DB84); + +/* 43AD8 8016DBD8 */ +u8 class_get_field_0x2c(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].field_0x2c; + + return CLASS_DATA[class].field_0x2c; +} + +/* 43B2C 8016DC2C */ +u8 class_get_ability_front(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].ability_front; + + return CLASS_DATA[class].ability_front; +} + +/* 43B80 8016DC80 */ +u8 class_get_ability_front_hitcount(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].ability_front_hitcount; + + return CLASS_DATA[class].ability_front_hitcount; +} + +/* 43BD4 8016DCD4 */ +u8 class_get_ability_middle(u8 portrait, u8 class) { + s32 var_v0; + + if (CLASS_DATA[portrait].field_0x45 != class) { + var_v0 = class * 9; + } else { + var_v0 = CLASS_DATA[portrait].field_0x45 * 9; + } + return *(&CLASS_DATA->ability_middle + (var_v0 * 8)); +} + +/* 43C20 8016DD20 */ +u8 class_get_ability_middle_hitcount(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].ability_middle_hitcount; + + return CLASS_DATA[class].ability_middle_hitcount; +} + +/* 43C74 8016DD74 */ +u8 class_get_ability_back(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].ability_back; + + return CLASS_DATA[class].ability_back; +} + +/* 43CC8 8016DDC8 */ +u8 class_get_ability_back_hitcount(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].ability_back_hitcount; + + return CLASS_DATA[class].ability_back_hitcount; +} + +/* 43D1C 8016DE1C */ +u8 class_get_field_0x4(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].field_0x4; + + return CLASS_DATA[class].field_0x4; +} + +/* 43D70 8016DE70 */ +u8 class_get_gender(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].gender; + + return CLASS_DATA[class].gender; +} + +/* 43DC4 8016DEC4 */ +u8 class_get_leadership_rank(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].leadership_rank; + + return CLASS_DATA[class].leadership_rank; +} + +/* 43E18 8016DF18 */ +u8 class_get_global_flag(u8 portrait, u8 class) { + u8 var_a1; + + var_a1 = class; + if (D_8018ECE4[portrait].field_0x0 & 0x80) { + if (CLASS_DATA[portrait].field_0x45 == var_a1) { + var_a1 = portrait; + } + } + return D_8018ECE4[var_a1].field_0x0 & 0x3F; +} + +/* 43E88 8016DF88 */ +EquipmentId class_get_item_upper_left(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].item_upper_left; + + return CLASS_DATA[class].item_upper_left; +} + +/* 43EDC 8016DFDC */ +EquipmentId class_get_item_upper_right(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].item_upper_right; + + return CLASS_DATA[class].item_upper_right; +} + +/* 43F30 8016E030 */ +EquipmentId class_get_item_lower_left(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].item_lower_left; + + return CLASS_DATA[class].item_lower_left; +} + +/* 43F84 8016E084 */ +EquipmentId class_get_item_lower_right(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].item_lower_right; + + return CLASS_DATA[class].item_lower_right; +} + +/* 43FD8 8016E0D8 */ +char* class_get_ability_front_name(u8 portrait, u8 class) { + u8 var_v0; + + if (CLASS_DATA[portrait].field_0x45 == class) { + var_v0 = CLASS_DATA[portrait].ability_front; + } else { + var_v0 = CLASS_DATA[class].ability_front; + } + + return ability_get_name(var_v0); +} + +/* 44040 8016E140 */ +char* class_get_ability_middle_name(u8 portrait, u8 class) { + // Possible a C macro wrapping? + do { + char* ret = ability_get_name(CLASS_DATA[class].ability_middle); + return ret; + } while(0); +} + +/* 44074 8016E174 */ +char* class_get_ability_back_name(u8 portrait, u8 class) { + u8 var_v0; + + if (CLASS_DATA[portrait].field_0x45 == class) { + var_v0 = CLASS_DATA[portrait].ability_back; + } else { + var_v0 = CLASS_DATA[class].ability_back; + } + + return ability_get_name(var_v0); +} + +/* 440DC 8016E1DC */ +char* class_get_name(u8 portrait, u8 class) { + if (CLASS_DATA[portrait].field_0x45 == class) + return CLASS_DATA[portrait].name; + + return CLASS_DATA[class].name; +} + +/* 44130 8016E230 */ +u8 class_get_ability(u8 portrait, u8 class, u8 row) +{ + if (CLASS_DATA[portrait].field_0x45 != class) + portrait = class; + + if (row == 0) { + return CLASS_DATA[portrait].ability_front != 0xFF ? CLASS_DATA[portrait].ability_front : CLASS_DATA[class].ability_front; + } else if (row == 1) { + return CLASS_DATA[portrait].ability_middle != 0xFF ? CLASS_DATA[portrait].ability_middle : CLASS_DATA[class].ability_middle; + } else { + return CLASS_DATA[portrait].ability_back != 0xFF ? CLASS_DATA[portrait].ability_back : CLASS_DATA[class].ability_back; + } +} + +/* 44238 8016E338 */ +u8 class_get_ability_hitcount(u8 portrait, u8 class, u8 row) { + if (CLASS_DATA[portrait].field_0x45 != class) + portrait = class; + + if (row == 0) { + return CLASS_DATA[portrait].ability_front_hitcount != 0xFF ? CLASS_DATA[portrait].ability_front_hitcount : CLASS_DATA[class].ability_front_hitcount; + } else if (row == 1) { + return CLASS_DATA[portrait].ability_middle_hitcount != 0xFF ? CLASS_DATA[portrait].ability_middle_hitcount : CLASS_DATA[class].ability_middle_hitcount; + } else { + return CLASS_DATA[portrait].ability_back_hitcount != 0xFF ? CLASS_DATA[portrait].ability_back_hitcount : CLASS_DATA[class].ability_back_hitcount; + } +} + +/* 44340 8016E440 */ +char* ability_get_name(u8 index) { + return ABILITY_DATA[index].name; +} + +/* 44358 8016E458 */ +u8 func_8016E458(u8 index) { + return ABILITY_DATA[index].field_0x4; +} + +/* 44370 8016E470 */ +Element ability_get_element(u8 index, u16 arg1, u16 arg2, s32 arg3, u16 arg4) { + u16 item_index; + + if (ABILITY_DATA[index].element != ELEMENT_INVALID && ABILITY_DATA[index].element != 0xF) + return ABILITY_DATA[index].element; + + if (ABILITY_DATA[index].field_0x4 == 3) { + item_index = equipment_get_first_spellbook(arg1, arg2, arg3, arg4); + } else { + item_index = equipment_get_first_weapon(arg1, arg2, arg3, arg4); + } + + if (item_index == 0) + return ELEMENT_PHYSICAL; + + return equipment_get_element(item_index); +} + + +INCLUDE_ASM(const s32, "43100", func_8016E50C); + +INCLUDE_ASM(const s32, "43100", func_8016EA34); + +/* 449EC 8016EAEC */ +u16 character_get_item(CharacterSlot* character, u8 slot) { + u16 item_id; + + item_id = 0; + switch(slot) { + case 0: + item_id = character->item_upper_left; + break; + + case 1: + item_id = character->item_upper_right; + break; + + case 2: + item_id = character->item_lower_left; + break; + + case 3: + item_id = character->item_lower_right; + break; + } + + if (item_id == 0) { + item_id = FP_CLASS_GET_ITEM[slot](character->portrait, character->class); + } + return item_id; +} + + +INCLUDE_ASM(const s32, "43100", __character_handle_levelup); + +INCLUDE_ASM(const s32, "43100", __character_initialise); + +INCLUDE_ASM(const s32, "43100", func_8016F4E0); + +INCLUDE_ASM(const s32, "43100", func_8016F500); + +INCLUDE_ASM(const s32, "43100", func_8016F520); + +INCLUDE_ASM(const s32, "43100", func_8016F540); + +INCLUDE_ASM(const s32, "43100", func_8016F560); diff --git a/src/equipment.c b/src/equipment.c new file mode 100644 index 0000000..b31d719 --- /dev/null +++ b/src/equipment.c @@ -0,0 +1,231 @@ +#include "common.h" +#include "element.h" +#include "equipment.h" + +/* 45480 8016F580 */ +u8 equipment_get_field_0x1b(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x1b; +} + +/* 45498 8016F598 */ +u8 equipment_get_field_0x1c(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x1c; +} + +/* 454B0 8016F5B0 */ +char* equipment_get_name(EquipmentId index) { + return EQUIPMENT_DATA[index].name; +} + +/* 454C8 8016F5C8 */ +EquipmentType equipment_get_type(EquipmentId index) { + return EQUIPMENT_DATA[index].type; +} + +/* 454E0 8016F5E0 */ +Element equipment_get_element(EquipmentId index) { + Element element; + + element = EQUIPMENT_DATA[index].element; + if (element == ELEMENT_UNKNOWN_0x10) { + element = CHARACTER_SLOT[0].element; + } + return element; +} + +/* 45514 8016F614 */ +u8 equipment_get_field_0x6(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x6; +} + +/* 4552C 8016F62C */ +u16 equipment_get_buy_price(EquipmentId index) { + return EQUIPMENT_DATA[index].buy_price; +} + +/* 45544 8016F644 */ +s8 equipment_get_field_0x10(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x10; +} + +/* 4555C 8016F65C */ +s8 equipment_get_strength(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].strength / 20; + } else { + ret = EQUIPMENT_DATA[index].strength; + } + return ret; +} + +/* 455AC 8016F6AC */ +s8 equipment_get_vitality(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].vitality / 20; + } else { + ret = EQUIPMENT_DATA[index].vitality; + } + return ret; +} + +/* 455FC 8016F6FC */ +s8 equipment_get_intelligence(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].intelligence / 20; + } else { + ret = EQUIPMENT_DATA[index].intelligence; + } + return ret; +} + +/* 4564C 8016F74C */ +s8 equipment_get_mentality(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].mentality / 20; + } else { + ret = EQUIPMENT_DATA[index].mentality; + } + return ret; +} + +/* 4569C 8016F79C */ +s8 equipment_get_agility(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].agility / 20; + } else { + ret = EQUIPMENT_DATA[index].agility; + } + return ret; +} + +/* 456EC 8016F7EC */ +s8 equipment_get_dexterity(EquipmentId index) { + s8 ret; + if (index == EQUIPMENT_ID_GALLANT_DOLL) { + ret = CHARACTER_SLOT[0].dexterity / 20; + } else { + ret = EQUIPMENT_DATA[index].dexterity; + } + return ret; +} + +/* 4573C 8016F83C */ +s8 equipment_get_resistance_strike(EquipmentId index) { + return EQUIPMENT_DATA[index].res_strike; +} + +/* 45754 8016F854 */ +s8 equipment_get_resistance_wind(EquipmentId index) { + return EQUIPMENT_DATA[index].res_wind; +} + +/* 4576C 8016F86C */ +s8 equipment_get_resistance_fire(EquipmentId index) { + return EQUIPMENT_DATA[index].res_fire; +} + +/* 45784 8016F884 */ +s8 equipment_get_resistance_earth(EquipmentId index) { + return EQUIPMENT_DATA[index].res_earth; +} + +/* 4579C 8016F89C */ +s8 equipment_get_resistance_water(EquipmentId index) { + return EQUIPMENT_DATA[index].res_water; +} + +/* 457B4 8016F8B4 */ +s8 equipment_get_resistance_holy(EquipmentId index) { + return EQUIPMENT_DATA[index].res_holy; +} + +/* 457CC 8016F8CC */ +s8 equipment_get_resistance_dark(EquipmentId index) { + return EQUIPMENT_DATA[index].res_dark; +} + +/* 457E4 8016F8E4 */ +u8 equipment_get_field_0x18_b68(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x18 >> 6; +} + +/* 45800 8016F900 */ +u8 equipment_get_field_0x18_b46(EquipmentId index) { + return (EQUIPMENT_DATA[index].field_0x18 >> 4) & 3; +} + +/* 45820 8016F920 */ +u8 equipment_get_field_0x18_b24(EquipmentId index) { + return (EQUIPMENT_DATA[index].field_0x18 >> 2) & 3; +} + +/* 45840 8016F940 */ +u8 equipment_get_field_0x18_b12(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x18 & 3; +} + +/* 4585C 8016F95C */ +u8 equipment_get_field_0x19_b68(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x19 >> 6; +} + +/* 45878 8016F978 */ +u8 equipment_get_field_0x19_b46(EquipmentId index) { + return (EQUIPMENT_DATA[index].field_0x19 >> 4) & 3; +} + +/* 45898 8016F998 */ +u8 equipment_get_field_0x19_b24(EquipmentId index) { + return (EQUIPMENT_DATA[index].field_0x19 >> 2) & 3; +} + +/* 458B8 8016F9B8 */ +u8 equipment_get_field_0x19_b12(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x19 & 3; +} + +/* 458D4 8016F9D4 */ +u8 equipment_get_field_0x1a_b7(EquipmentId index) { + return EQUIPMENT_DATA[index].field_0x1a >> 7; +} + +/* 458F0 8016F9F0 */ +bool equipment_is_weapon(EquipmentId index) { + s32 type = EQUIPMENT_DATA[index].type; + + if (type != 0) { + if (type < EQUIPMENT_TYPE_SMALL_SHIELD) { + return true; + } + if (type == EQUIPMENT_TYPE_FAN) { + return true; + } + } + + return false; +} + +INCLUDE_ASM(const s32, "equipment", equipment_get_first_weapon); + +/* 45A50 8016FB50 */ +EquipmentId equipment_get_first_spellbook(EquipmentId arg0, EquipmentId arg1, EquipmentId arg2, EquipmentId arg3) { + if (EQUIPMENT_DATA[arg0].type == EQUIPMENT_TYPE_SPELLBOOK) + return arg0; + + if (EQUIPMENT_DATA[arg1].type == EQUIPMENT_TYPE_SPELLBOOK) + return arg1; + + if (EQUIPMENT_DATA[arg2].type == EQUIPMENT_TYPE_SPELLBOOK) + return arg2; + + if (EQUIPMENT_DATA[arg3].type == EQUIPMENT_TYPE_SPELLBOOK) + return arg3; + + return 0; +} + diff --git a/src/item.c b/src/item.c deleted file mode 100644 index 29ff59c..0000000 --- a/src/item.c +++ /dev/null @@ -1,570 +0,0 @@ -#include "common.h" -#include "element.h" -#include "item.h" - -INCLUDE_ASM(const s32, "item", func_8016D200); - -INCLUDE_ASM(const s32, "item", func_8016D254); - -INCLUDE_ASM(const s32, "item", func_8016D2A8); - -INCLUDE_ASM(const s32, "item", func_8016D2FC); - -INCLUDE_ASM(const s32, "item", func_8016D350); - -INCLUDE_ASM(const s32, "item", func_8016D3A4); - -INCLUDE_ASM(const s32, "item", func_8016D3F8); - -INCLUDE_ASM(const s32, "item", func_8016D44C); - -INCLUDE_ASM(const s32, "item", func_8016D4A0); - -INCLUDE_ASM(const s32, "item", func_8016D4F4); - -INCLUDE_ASM(const s32, "item", func_8016D548); - -INCLUDE_ASM(const s32, "item", func_8016D59C); - -INCLUDE_ASM(const s32, "item", func_8016D5F0); - -INCLUDE_ASM(const s32, "item", func_8016D644); - -INCLUDE_ASM(const s32, "item", func_8016D698); - -INCLUDE_ASM(const s32, "item", func_8016D6EC); - -INCLUDE_ASM(const s32, "item", func_8016D740); - -INCLUDE_ASM(const s32, "item", func_8016D794); - -INCLUDE_ASM(const s32, "item", func_8016D7E8); - -INCLUDE_ASM(const s32, "item", func_8016D83C); - -INCLUDE_ASM(const s32, "item", func_8016D890); - -INCLUDE_ASM(const s32, "item", func_8016D8E4); - -INCLUDE_ASM(const s32, "item", func_8016D938); - -INCLUDE_ASM(const s32, "item", func_8016D98C); - -INCLUDE_ASM(const s32, "item", func_8016D9E0); - -INCLUDE_ASM(const s32, "item", func_8016DA34); - -INCLUDE_ASM(const s32, "item", func_8016DA88); - -INCLUDE_ASM(const s32, "item", func_8016DADC); - -INCLUDE_ASM(const s32, "item", func_8016DB30); - -INCLUDE_ASM(const s32, "item", func_8016DB84); - -/* 43AD8 8016DBD8 */ -u8 class_get_field_0x2c(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].field_0x2c; - - return CLASS_DATA[class].field_0x2c; -} - -/* 43B2C 8016DC2C */ -u8 class_get_ability_front(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].ability_front; - - return CLASS_DATA[class].ability_front; -} - -/* 43B80 8016DC80 */ -u8 class_get_ability_front_hitcount(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].ability_front_hitcount; - - return CLASS_DATA[class].ability_front_hitcount; -} - -/* 43BD4 8016DCD4 */ -u8 class_get_ability_middle(u8 portrait, u8 class) { - s32 var_v0; - - if (CLASS_DATA[portrait].field_0x45 != class) { - var_v0 = class * 9; - } else { - var_v0 = CLASS_DATA[portrait].field_0x45 * 9; - } - return *(&CLASS_DATA->ability_middle + (var_v0 * 8)); -} - -/* 43C20 8016DD20 */ -u8 class_get_ability_middle_hitcount(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].ability_middle_hitcount; - - return CLASS_DATA[class].ability_middle_hitcount; -} - -/* 43C74 8016DD74 */ -u8 class_get_ability_back(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].ability_back; - - return CLASS_DATA[class].ability_back; -} - -/* 43CC8 8016DDC8 */ -u8 class_get_ability_back_hitcount(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].ability_back_hitcount; - - return CLASS_DATA[class].ability_back_hitcount; -} - -/* 43D1C 8016DE1C */ -u8 class_get_field_0x4(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].field_0x4; - - return CLASS_DATA[class].field_0x4; -} - -/* 43D70 8016DE70 */ -u8 class_get_gender(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].gender; - - return CLASS_DATA[class].gender; -} - -/* 43DC4 8016DEC4 */ -u8 class_get_leadership_rank(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].leadership_rank; - - return CLASS_DATA[class].leadership_rank; -} - -/* 43E18 8016DF18 */ -u8 class_get_global_flag(u8 portrait, u8 class) { - u8 var_a1; - - var_a1 = class; - if (D_8018ECE4[portrait].field_0x0 & 0x80) { - if (CLASS_DATA[portrait].field_0x45 == var_a1) { - var_a1 = portrait; - } - } - return D_8018ECE4[var_a1].field_0x0 & 0x3F; -} - -/* 43E88 8016DF88 */ -ItemId class_get_item_upper_left(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].item_upper_left; - - return CLASS_DATA[class].item_upper_left; -} - -/* 43EDC 8016DFDC */ -ItemId class_get_item_upper_right(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].item_upper_right; - - return CLASS_DATA[class].item_upper_right; -} - -/* 43F30 8016E030 */ -ItemId class_get_item_lower_left(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].item_lower_left; - - return CLASS_DATA[class].item_lower_left; -} - -/* 43F84 8016E084 */ -ItemId class_get_item_lower_right(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].item_lower_right; - - return CLASS_DATA[class].item_lower_right; -} - -/* 43FD8 8016E0D8 */ -char* class_get_ability_front_name(u8 portrait, u8 class) { - u8 var_v0; - - if (CLASS_DATA[portrait].field_0x45 == class) { - var_v0 = CLASS_DATA[portrait].ability_front; - } else { - var_v0 = CLASS_DATA[class].ability_front; - } - - return ability_get_name(var_v0); -} - -/* 44040 8016E140 */ -char* class_get_ability_middle_name(u8 portrait, u8 class) { - // Possible a C macro wrapping? - do { - char* ret = ability_get_name(CLASS_DATA[class].ability_middle); - return ret; - } while(0); -} - -/* 44074 8016E174 */ -char* class_get_ability_back_name(u8 portrait, u8 class) { - u8 var_v0; - - if (CLASS_DATA[portrait].field_0x45 == class) { - var_v0 = CLASS_DATA[portrait].ability_back; - } else { - var_v0 = CLASS_DATA[class].ability_back; - } - - return ability_get_name(var_v0); -} - -/* 440DC 8016E1DC */ -char* class_get_name(u8 portrait, u8 class) { - if (CLASS_DATA[portrait].field_0x45 == class) - return CLASS_DATA[portrait].name; - - return CLASS_DATA[class].name; -} - -/* 44130 8016E230 */ -u8 class_get_ability(u8 portrait, u8 class, u8 row) -{ - if (CLASS_DATA[portrait].field_0x45 != class) - portrait = class; - - if (row == 0) { - return CLASS_DATA[portrait].ability_front != 0xFF ? CLASS_DATA[portrait].ability_front : CLASS_DATA[class].ability_front; - } else if (row == 1) { - return CLASS_DATA[portrait].ability_middle != 0xFF ? CLASS_DATA[portrait].ability_middle : CLASS_DATA[class].ability_middle; - } else { - return CLASS_DATA[portrait].ability_back != 0xFF ? CLASS_DATA[portrait].ability_back : CLASS_DATA[class].ability_back; - } -} - -/* 44238 8016E338 */ -u8 class_get_ability_hitcount(u8 portrait, u8 class, u8 row) { - if (CLASS_DATA[portrait].field_0x45 != class) - portrait = class; - - if (row == 0) { - return CLASS_DATA[portrait].ability_front_hitcount != 0xFF ? CLASS_DATA[portrait].ability_front_hitcount : CLASS_DATA[class].ability_front_hitcount; - } else if (row == 1) { - return CLASS_DATA[portrait].ability_middle_hitcount != 0xFF ? CLASS_DATA[portrait].ability_middle_hitcount : CLASS_DATA[class].ability_middle_hitcount; - } else { - return CLASS_DATA[portrait].ability_back_hitcount != 0xFF ? CLASS_DATA[portrait].ability_back_hitcount : CLASS_DATA[class].ability_back_hitcount; - } -} - -/* 44340 8016E440 */ -char* ability_get_name(u8 index) { - return ABILITY_DATA[index].name; -} - -/* 44358 8016E458 */ -u8 func_8016E458(u8 index) { - return ABILITY_DATA[index].field_0x4; -} - -/* 44370 8016E470 */ -Element ability_get_element(u8 index, u16 arg1, u16 arg2, s32 arg3, u16 arg4) { - u16 item_index; - - if (ABILITY_DATA[index].element != ELEMENT_INVALID && ABILITY_DATA[index].element != 0xF) - return ABILITY_DATA[index].element; - - if (ABILITY_DATA[index].field_0x4 == 3) { - item_index = item_get_first_spellbook(arg1, arg2, arg3, arg4); - } else { - item_index = item_get_first_weapon(arg1, arg2, arg3, arg4); - } - - if (item_index == 0) - return ELEMENT_PHYSICAL; - - return item_get_element(item_index); -} - - -INCLUDE_ASM(const s32, "item", func_8016E50C); - -INCLUDE_ASM(const s32, "item", func_8016EA34); - -/* 449EC 8016EAEC */ -u16 character_get_item(CharacterSlot* character, u8 slot) { - u16 item_id; - - item_id = 0; - switch(slot) { - case 0: - item_id = character->item_upper_left; - break; - - case 1: - item_id = character->item_upper_right; - break; - - case 2: - item_id = character->item_lower_left; - break; - - case 3: - item_id = character->item_lower_right; - break; - } - - if (item_id == 0) { - item_id = FP_CLASS_GET_ITEM[slot](character->portrait, character->class); - } - return item_id; -} - - -INCLUDE_ASM(const s32, "item", __character_handle_levelup); - -INCLUDE_ASM(const s32, "item", __character_initialise); - -INCLUDE_ASM(const s32, "item", func_8016F4E0); - -INCLUDE_ASM(const s32, "item", func_8016F500); - -INCLUDE_ASM(const s32, "item", func_8016F520); - -INCLUDE_ASM(const s32, "item", func_8016F540); - -INCLUDE_ASM(const s32, "item", func_8016F560); - -/* 45480 8016F580 */ -u8 item_get_field_0x1b(ItemId index) { - return ITEM_DATA[index].field_0x1b; -} - -/* 45498 8016F598 */ -u8 item_get_field_0x1c(ItemId index) { - return ITEM_DATA[index].field_0x1c; -} - -/* 454B0 8016F5B0 */ -char* item_get_name(ItemId index) { - return ITEM_DATA[index].name; -} - -/* 454C8 8016F5C8 */ -ItemType item_get_type(ItemId index) { - return ITEM_DATA[index].type; -} - -/* 454E0 8016F5E0 */ -Element item_get_element(ItemId index) { - Element element; - - element = ITEM_DATA[index].element; - if (element == ELEMENT_UNKNOWN_0x10) { - element = CHARACTER_SLOT[0].element; - } - return element; -} - -/* 45514 8016F614 */ -u8 item_get_field_0x6(ItemId index) { - return ITEM_DATA[index].field_0x6; -} - -/* 4552C 8016F62C */ -u16 item_get_buy_price(ItemId index) { - return ITEM_DATA[index].buy_price; -} - -/* 45544 8016F644 */ -s8 item_get_field_0x10(ItemId index) { - return ITEM_DATA[index].field_0x10; -} - -/* 4555C 8016F65C */ -s8 item_get_strength(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].strength / 20; - } else { - ret = ITEM_DATA[index].strength; - } - return ret; -} - -/* 455AC 8016F6AC */ -s8 item_get_vitality(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].vitality / 20; - } else { - ret = ITEM_DATA[index].vitality; - } - return ret; -} - -/* 455FC 8016F6FC */ -s8 item_get_intelligence(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].intelligence / 20; - } else { - ret = ITEM_DATA[index].intelligence; - } - return ret; -} - -/* 4564C 8016F74C */ -s8 item_get_mentality(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].mentality / 20; - } else { - ret = ITEM_DATA[index].mentality; - } - return ret; -} - -/* 4569C 8016F79C */ -s8 item_get_agility(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].agility / 20; - } else { - ret = ITEM_DATA[index].agility; - } - return ret; -} - -/* 456EC 8016F7EC */ -s8 item_get_dexterity(ItemId index) { - s8 ret; - if (index == ITEM_ID_GALLANT_DOLL) { - ret = CHARACTER_SLOT[0].dexterity / 20; - } else { - ret = ITEM_DATA[index].dexterity; - } - return ret; -} - -/* 4573C 8016F83C */ -s8 item_get_resistance_strike(ItemId index) { - return ITEM_DATA[index].res_strike; -} - -/* 45754 8016F854 */ -s8 item_get_resistance_wind(ItemId index) { - return ITEM_DATA[index].res_wind; -} - -/* 4576C 8016F86C */ -s8 item_get_resistance_fire(ItemId index) { - return ITEM_DATA[index].res_fire; -} - -/* 45784 8016F884 */ -s8 item_get_resistance_earth(ItemId index) { - return ITEM_DATA[index].res_earth; -} - -/* 4579C 8016F89C */ -s8 item_get_resistance_water(ItemId index) { - return ITEM_DATA[index].res_water; -} - -/* 457B4 8016F8B4 */ -s8 item_get_resistance_holy(ItemId index) { - return ITEM_DATA[index].res_holy; -} - -/* 457CC 8016F8CC */ -s8 item_get_resistance_dark(ItemId index) { - return ITEM_DATA[index].res_dark; -} - -/* 457E4 8016F8E4 */ -u8 item_get_field_0x18_b68(ItemId index) { - return ITEM_DATA[index].field_0x18 >> 6; -} - -/* 45800 8016F900 */ -u8 item_get_field_0x18_b46(ItemId index) { - return (ITEM_DATA[index].field_0x18 >> 4) & 3; -} - -/* 45820 8016F920 */ -u8 item_get_field_0x18_b24(ItemId index) { - return (ITEM_DATA[index].field_0x18 >> 2) & 3; -} - -/* 45840 8016F940 */ -u8 item_get_field_0x18_b12(ItemId index) { - return ITEM_DATA[index].field_0x18 & 3; -} - -/* 4585C 8016F95C */ -u8 item_get_field_0x19_b68(ItemId index) { - return ITEM_DATA[index].field_0x19 >> 6; -} - -/* 45878 8016F978 */ -u8 item_get_field_0x19_b46(ItemId index) { - return (ITEM_DATA[index].field_0x19 >> 4) & 3; -} - -/* 45898 8016F998 */ -u8 item_get_field_0x19_b24(ItemId index) { - return (ITEM_DATA[index].field_0x19 >> 2) & 3; -} - -/* 458B8 8016F9B8 */ -u8 item_get_field_0x19_b12(ItemId index) { - return ITEM_DATA[index].field_0x19 & 3; -} - -/* 458D4 8016F9D4 */ -u8 item_get_field_0x1a_b7(ItemId index) { - return ITEM_DATA[index].field_0x1a >> 7; -} - -/* 458F0 8016F9F0 */ -bool item_is_weapon(ItemId index) { - s32 type = ITEM_DATA[index].type; - - if (type != 0) { - if (type < ITEM_TYPE_SMALL_SHIELD) { - return true; - } - if (type == ITEM_TYPE_FAN) { - return true; - } - } - - return false; -} - -INCLUDE_ASM(const s32, "item", item_get_first_weapon); - -/* 45A50 8016FB50 */ -ItemId item_get_first_spellbook(ItemId arg0, ItemId arg1, ItemId arg2, ItemId arg3) { - if (ITEM_DATA[arg0].type == ITEM_TYPE_SPELLBOOK) - return arg0; - - if (ITEM_DATA[arg1].type == ITEM_TYPE_SPELLBOOK) - return arg1; - - if (ITEM_DATA[arg2].type == ITEM_TYPE_SPELLBOOK) - return arg2; - - if (ITEM_DATA[arg3].type == ITEM_TYPE_SPELLBOOK) - return arg3; - - return 0; -} - diff --git a/symbol_addrs.txt b/symbol_addrs.txt index 99f2143..6621868 100644 --- a/symbol_addrs.txt +++ b/symbol_addrs.txt @@ -95,44 +95,43 @@ ABILITY_DATA = 0x8018AA7C; // rom:0x6097C size:0x10 ability_get_name = 0x8016E440; ability_get_element = 0x8016E470; -ITEM_TYPE_NAMES = 0x802130A4; // rom:0x164214 type:char* -ITEM_DATA = 0x8018C40C; // size:0x20 -item_get_field_0x1b = 0x8016F580; // rom:0x45480 -item_get_field_0x1c = 0x8016F598; // rom:0x45498 -item_get_name = 0x8016F5B0; -item_get_type = 0x8016F5C8; -item_get_element = 0x8016F5E0; -item_get_field_0x6 = 0x8016F614; -item_get_buy_price = 0x8016F62C; -item_get_field_0x10 = 0x8016F644; -item_get_strength = 0x8016F65C; -item_get_vitality = 0x8016F6AC; -item_get_intelligence = 0x8016F6FC; -item_get_mentality = 0x8016F74C; -item_get_agility = 0x8016F79C; -item_get_dexterity = 0x8016F7EC; -item_get_resistance_strike = 0x8016F83C; -item_get_resistance_wind = 0x8016F854; -item_get_resistance_fire = 0x8016F86C; -item_get_resistance_earth = 0x8016F884; -item_get_resistance_water = 0x8016F89C; -item_get_resistance_holy = 0x8016F8B4; -item_get_resistance_dark = 0x8016F8CC; -item_get_field_0x18_b68 = 0x8016F8E4; -item_get_field_0x18_b46 = 0x8016F900; -item_get_field_0x18_b24 = 0x8016F920; -item_get_field_0x18_b12 = 0x8016F940; -item_get_field_0x19_b68 = 0x8016F95C; -item_get_field_0x19_b46 = 0x8016F978; -item_get_field_0x19_b24 = 0x8016F998; -item_get_field_0x19_b12 = 0x8016F9B8; -item_get_field_0x1a_b7 = 0x8016F9D4; // rom:0x458D4 -item_is_weapon = 0x8016F9F0; // rom:0x458F0 -item_get_first_weapon = 0x8016FA34; // rom:0x45934 -item_get_first_spellbook = 0x8016FB50; // rom:0x45A50 - -FP_ITEM_GET_RESISTANCE = 0x801EF2B0; // rom:0xDBD10 -FP_ITEM_GET_ALL_STATS = 0x801EF298; // rom:0xDBCF8 +FP_EQUIPMENT_GET_RESISTANCE = 0x801EF2B0; // rom:0xDBD10 +FP_EQUIPMENT_GET_ALL_STATS = 0x801EF298; // rom:0xDBCF8 +EQUIPMENT_TYPE_NAMES = 0x802130A4; // rom:0x164214 type:char* +EQUIPMENT_DATA = 0x8018C40C; // size:0x20 +equipment_get_field_0x1b = 0x8016F580; // rom:0x45480 +equipment_get_field_0x1c = 0x8016F598; // rom:0x45498 +equipment_get_name = 0x8016F5B0; +equipment_get_type = 0x8016F5C8; +equipment_get_element = 0x8016F5E0; +equipment_get_field_0x6 = 0x8016F614; +equipment_get_buy_price = 0x8016F62C; +equipment_get_field_0x10 = 0x8016F644; +equipment_get_strength = 0x8016F65C; +equipment_get_vitality = 0x8016F6AC; +equipment_get_intelligence = 0x8016F6FC; +equipment_get_mentality = 0x8016F74C; +equipment_get_agility = 0x8016F79C; +equipment_get_dexterity = 0x8016F7EC; +equipment_get_resistance_strike = 0x8016F83C; +equipment_get_resistance_wind = 0x8016F854; +equipment_get_resistance_fire = 0x8016F86C; +equipment_get_resistance_earth = 0x8016F884; +equipment_get_resistance_water = 0x8016F89C; +equipment_get_resistance_holy = 0x8016F8B4; +equipment_get_resistance_dark = 0x8016F8CC; +equipment_get_field_0x18_b68 = 0x8016F8E4; +equipment_get_field_0x18_b46 = 0x8016F900; +equipment_get_field_0x18_b24 = 0x8016F920; +equipment_get_field_0x18_b12 = 0x8016F940; +equipment_get_field_0x19_b68 = 0x8016F95C; +equipment_get_field_0x19_b46 = 0x8016F978; +equipment_get_field_0x19_b24 = 0x8016F998; +equipment_get_field_0x19_b12 = 0x8016F9B8; +equipment_get_field_0x1a_b7 = 0x8016F9D4; // rom:0x458D4 +equipment_is_weapon = 0x8016F9F0; // rom:0x458F0 +equipment_get_first_weapon = 0x8016FA34; // rom:0x45934 +equipment_get_first_spellbook = 0x8016FB50; // rom:0x45A50 CHARACTER_NAME_ARRAY_00 = 0x8018EB48; diff --git a/tools/item_data.py b/tools/equipment_data.py similarity index 100% rename from tools/item_data.py rename to tools/equipment_data.py