From a10f6e5db260d7577112513d6ccf4d6d9b23fd28 Mon Sep 17 00:00:00 2001 From: Ogre Date: Fri, 15 Sep 2023 15:43:35 +0200 Subject: [PATCH] Figured out first display list thingy! Added `ASSERT_SIZE` macro to make sure sizes match Added compile_flags for mips --- compile_flags.txt | 3 ++- include/ability.h | 3 +++ include/assert.h | 7 +++++++ include/character.h | 3 +++ include/class.h | 3 +++ include/common.h | 4 ++-- include/element.h | 4 ++++ include/equipment.h | 5 +++++ splat.yaml | 2 +- src/19050.c | 2 +- src/1A5B0.c | 29 +++++++++++------------------ src/42C90.c | 18 ++++++++++++++++++ src/ability.c | 17 ++++++++++++++++- symbol_addrs.txt | 11 +++++++++++ 14 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 include/assert.h create mode 100644 src/42C90.c diff --git a/compile_flags.txt b/compile_flags.txt index 669cc98..2375763 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -2,4 +2,5 @@ -Ilib/libreultra/include/2.0I -D_LANGUAGE_C -D_FINALROM --DF3DEX_GBI_2 \ No newline at end of file +-DF3DEX_GBI_2 +--target=mips-linux-gnu \ No newline at end of file diff --git a/include/ability.h b/include/ability.h index 5ab50f1..675ea89 100644 --- a/include/ability.h +++ b/include/ability.h @@ -3,6 +3,7 @@ #include +#include "assert.h" #include "element.h" typedef struct { @@ -21,6 +22,8 @@ typedef struct { /* 0x0f */ u8 field_0xf; } AbilityData; // size:0x10 +ASSERT_SIZE(AbilityData, 0x10); + extern AbilityData ABILITY_DATA[]; extern char *ability_get_name(u8 index); diff --git a/include/assert.h b/include/assert.h new file mode 100644 index 0000000..68e803f --- /dev/null +++ b/include/assert.h @@ -0,0 +1,7 @@ +#ifndef __ASSERT_H__ +#define __ASSERT_H__ + +#define STATIC_ASSERT(COND,MSG) typedef char MSG[(COND) ? 1 : -1] +#define ASSERT_SIZE(_struct, _size) STATIC_ASSERT(sizeof(_struct) == _size, _struct ## _is_not_size_ ## _size) + +#endif // __ASSERT_H__ \ No newline at end of file diff --git a/include/character.h b/include/character.h index 22836c7..ea0578d 100644 --- a/include/character.h +++ b/include/character.h @@ -3,6 +3,7 @@ #include +#include "assert.h" #include "element.h" typedef struct { @@ -44,4 +45,6 @@ typedef struct { /* 0x37 */ u8 field_0x37; } CharacterSlot; // size:0x38 +ASSERT_SIZE(CharacterSlot, 0x38); + #endif // __CHARACTER_H__ \ No newline at end of file diff --git a/include/class.h b/include/class.h index c939803..eb1b663 100644 --- a/include/class.h +++ b/include/class.h @@ -3,6 +3,7 @@ #include +#include "assert.h" #include "equipment.h" typedef struct { @@ -79,6 +80,8 @@ typedef struct { /* 0x47 */ u8 max_items; } ClassData; // size:0x48 +ASSERT_SIZE(ClassData, 0x48); + extern ClassData CLASS_DATA[]; extern EquipmentId (*FP_CLASS_GET_ITEM[4])(u8, u8); diff --git a/include/common.h b/include/common.h index 586f3be..39bee20 100644 --- a/include/common.h +++ b/include/common.h @@ -84,7 +84,7 @@ extern s32 D_800E8B14; extern Unk0 MQ_800E8B4C; extern s32 __SCREEN_IS_NOT_BLACK; extern s32 D_800A9EB0; -extern s32 D_800A9EE0; +extern s32 __SOMETHING_FRAMEBUFFERS; extern s32 D_800C4B20; extern void* D_800C4CE0; extern s32 D_A9EF0; @@ -151,7 +151,7 @@ extern void __calls_osViBlack(bool black); extern void __start_thread_800B9C88(); extern void __start_thread_800BE1C0(); -extern void func_80089804(s32*, s32, s32, s32); +extern void __something_display_list(Gfx*, s32, s32, s32); extern void func_80089A10(); extern void func_80089AB0(s32*, s32); diff --git a/include/element.h b/include/element.h index f90a63a..eb740e6 100644 --- a/include/element.h +++ b/include/element.h @@ -3,6 +3,8 @@ #include +#include "assert.h" + typedef u8 Element; #define ELEMENT_PHYSICAL 0 @@ -25,4 +27,6 @@ typedef u8 Element; #define ELEMENT_INVALID 0xFF +ASSERT_SIZE(Element, 1); + #endif // __ELEMENT_H__ diff --git a/include/equipment.h b/include/equipment.h index 1a0808c..0d8b67c 100644 --- a/include/equipment.h +++ b/include/equipment.h @@ -3,6 +3,7 @@ #include +#include "assert.h" #include "element.h" typedef u8 EquipmentType; @@ -36,6 +37,8 @@ typedef u8 EquipmentType; typedef u16 EquipmentId; +ASSERT_SIZE(EquipmentId, 2); + #define EQUIPMENT_ID_GALLANT_DOLL 132 typedef struct { @@ -69,6 +72,8 @@ typedef struct { /* 0x1f */ u8 field_0x1f; } EquipmentData; // size:0x20 +ASSERT_SIZE(EquipmentData, 0x20); + extern char *EQUIPMENT_TYPE_NAMES[]; extern EquipmentData EQUIPMENT_DATA[]; extern s8 (*FP_EQUIPMENT_GET_RESISTANCE[])(EquipmentId index); diff --git a/splat.yaml b/splat.yaml index 84f2446..3846047 100644 --- a/splat.yaml +++ b/splat.yaml @@ -438,7 +438,7 @@ segments: - [0x40E80, asm] - [0x420D0, asm] - [0x42C30, c] - - [0x42C90, asm] + - [0x42C90, c] - [0x43100, c, "class"] - [0x44340, c, "ability"] - [0x45480, c, "equipment"] diff --git a/src/19050.c b/src/19050.c index 76aa311..b608bf2 100644 --- a/src/19050.c +++ b/src/19050.c @@ -111,7 +111,7 @@ INCLUDE_ASM(const s32, "19050", __thread_80089540); INCLUDE_ASM(const s32, "19050", __start_thread_800B9C88); -INCLUDE_ASM(const s32, "19050", func_80089804); +INCLUDE_ASM(const s32, "19050", __something_display_list); /* 19D90 80089990 */ void func_80089990(void (*arg0)(s32)) { diff --git a/src/1A5B0.c b/src/1A5B0.c index 5569894..4148cae 100644 --- a/src/1A5B0.c +++ b/src/1A5B0.c @@ -1,30 +1,23 @@ +#include "PR/gbi.h" #include "common.h" /* 1A5B0 8008A1B0 */ void func_8008A1B0(void) { - struct { - /* 0x00 */ s32 field_0x0; - /* 0x04 */ void* field_0x4; - /* 0x08 */ s32 field_0x8; - /* 0x0c */ s32 field_0xc; - /* 0x10 */ s32 field_0x10; - /* 0x14 */ s32 field_0x14; - } sp10; - u8 pad[0x7F0]; + Gfx list[257]; + Gfx* ptr = list; __start_thread_800BE1C0(); - func_80089AB0(&D_800A9EE0, 3); - D_800C4B20 = 0x80000400; + func_80089AB0(&__SOMETHING_FRAMEBUFFERS, 3); + D_800C4B20 = BOOT_ADDRESS_ULTRA; set_swap_buffer_func(&__osViSwapBuffer_3); D_800C4CE0 = &D_800A9EB0; __start_thread_800B9C88(); - sp10.field_0x0 = 0xDE000000; - sp10.field_0x4 = &D_A9EF0; - sp10.field_0x8 = 0xE9000000; - sp10.field_0xc = 0; - sp10.field_0x10 = 0xDF000000; - sp10.field_0x14 = 0; - func_80089804(&sp10, 0x18, 0, 0); + + gSPDisplayList(ptr++, &D_A9EF0); + gDPFullSync(ptr++); + gSPEndDisplayList(ptr++); + + __something_display_list(list, sizeof(Gfx) * 3, 0, 0); func_80089A10(); } diff --git a/src/42C90.c b/src/42C90.c new file mode 100644 index 0000000..c48b4f6 --- /dev/null +++ b/src/42C90.c @@ -0,0 +1,18 @@ +#include "PR/gbi.h" +#include "common.h" + +INCLUDE_ASM(const s32, "42C90", func_8016CD90); + +INCLUDE_ASM(const s32, "42C90", func_8016CDCC); + +INCLUDE_ASM(const s32, "42C90", func_8016CDF4); + +INCLUDE_ASM(const s32, "42C90", func_8016CE40); + +INCLUDE_ASM(const s32, "42C90", func_8016CEC4); + +INCLUDE_ASM(const s32, "42C90", func_8016CF64); + +INCLUDE_ASM(const s32, "42C90", func_8016D068); + +INCLUDE_ASM(const s32, "42C90", func_8016D100); diff --git a/src/ability.c b/src/ability.c index d4e4c39..c71ee64 100644 --- a/src/ability.c +++ b/src/ability.c @@ -36,7 +36,22 @@ Element ability_get_element(u8 index, u16 arg1, u16 arg2, s32 arg3, u16 arg4) { INCLUDE_ASM(const s32, "ability", func_8016E50C); -INCLUDE_ASM(const s32, "ability", func_8016EA34); +// INCLUDE_ASM(const s32, "ability", func_8016EA34); + +/* 44934 8016EA34 */ +u8 func_8016EA34(u8 portrait, u8 class, u8 arg2) +{ + if (CLASS_DATA[portrait].field_0x45 != class) + portrait = class; + + portrait = (CLASS_DATA[portrait].field_0x42 != 0xFF && arg2 < CLASS_DATA[portrait].field_0x42) ? + CLASS_DATA[portrait].field_0x41 : + (CLASS_DATA[portrait].field_0x44 != 0xFF && arg2 < CLASS_DATA[portrait].field_0x44) ? + CLASS_DATA[portrait].field_0x43 : portrait; + + return portrait; +} + /* 449EC 8016EAEC */ u16 character_get_item(CharacterSlot* character, u8 slot) { diff --git a/symbol_addrs.txt b/symbol_addrs.txt index 085feb7..116b515 100644 --- a/symbol_addrs.txt +++ b/symbol_addrs.txt @@ -1,3 +1,10 @@ +__SOMETHING_FRAMEBUFFERS = 0x800A9EE0; // rom:0x3A2E0 size:0xC + +__something_display_list = 0x80089804; // rom:0x19C04 +__SOMETHING_WITH_GFX = 0x800E9BE0; // size:0x18 + +__MAYBE_DISPLAY_LIST = 0x801B8430; // rom:0x1EE930 + FP_CLASS_GET_ITEM = 0x8018B494; // rom:0x61394 size:0x10 __restore_zombie_hp_to_max = 0x80219EEC; // rom:0x1B75DC @@ -27,6 +34,10 @@ __CONTAINS_BATTALION_NAME = 0x80196A58; // size:0x94 DEFAULT_BATTALION_NAME = 0x80190EFC; // rom:0x66DFC type:asciz +STR_COMMAND_MOBILE_WALL = 0x80212FF0; // rom:0x164160 type:asciz + +STR_LEGION_LED_BY_COMMANDER_OF_BATTALION_MAY = 0x801EEBA4; // rom:0x1432E4 type:asciz + STR_UNPACK_ERROR_UNSUPPORTED_FORMAT = 0x800AE038; // rom:0x3E438 STR_SERIFU_POSITION_X_ERROR = 0x8019E20C; // rom:0xEAF8C type:asciz