From 4672fe01cbfd5237c56c0e01cdec6f88061bdfe7 Mon Sep 17 00:00:00 2001 From: Ogre Date: Sun, 3 Sep 2023 17:30:01 +0200 Subject: [PATCH] Added a lot of symbols Decompiled more code --- include/common.h | 74 +++++++++++++++++++++++++++++++++++ splat.yaml | 60 ++++++++++++++++++++++++++-- src/19050.c | 8 +++- src/5FC0.c | 29 ++++++++++++++ src/main.c | 57 ++++++++++++++++++++++++++- src/overlays/overlay1/5C060.c | 62 +++++++++++++++++++++++++++++ symbol_addrs.txt | 28 ++++++++++++- 7 files changed, 311 insertions(+), 7 deletions(-) create mode 100644 src/5FC0.c create mode 100644 src/overlays/overlay1/5C060.c diff --git a/include/common.h b/include/common.h index edfe604..027f795 100644 --- a/include/common.h +++ b/include/common.h @@ -12,6 +12,8 @@ typedef u8 bool; #define MAX_BYTES_TO_READ 512 +#define ARRAY_LENGTH(x) ((sizeof(x)) / (sizeof(x[0]))) + typedef struct { /* 0x00 */ s32 field_0x0; /* 0x04 */ s32 field_0x4; @@ -155,4 +157,76 @@ extern void func_8008949C(void** buffers); extern void func_8008350C(); extern void func_8008B1D0(u8*); +typedef struct { + /* 0x00 */ u8* dst; + /* 0x04 */ u8* field_0x4; + /* 0x08 */ u8* src_start; + /* 0x0c */ u8* src_end; + /* 0x10 */ u8* bss_start; + /* 0x14 */ u8* bss_end; + /* 0x18 */ u8* text_start; + /* 0x1c */ u8* text_end; + /* 0x20 */ u8* data_start; + /* 0x24 */ u8* data_end; +} OverlayEntry; // size:0x28 + +extern u8* __SOME_OVERLAY_ID_ARRAY[11]; +extern OverlayEntry __SOME_OVERLAY_TABLE[11]; + +extern u8* func_80076188(void); +extern void func_80076194(void); +extern void func_800761A4(void); +extern void __loads_overlay_array(s32 arg0); +extern u8 __get_overlay_index(s32 arg0); +extern void func_80076324(s32 arg0); + +extern void func_800E9C20(void); + +extern s8 D_800AEE72; +extern s16 D_800C4A18; +extern s16 D_800C4AD8; +extern s16 D_800C4BCA; +extern s16 D_800C4C08; +extern s16 D_800E7A1C; +extern s16 D_800E7D68; +extern void func_80073164(u8 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6); + +extern s8 D_800A81F0; + +typedef struct { + /* 0x00 */ void* field_0x0; + /* 0x04 */ void* field_0x4; + /* 0x08 */ u32 field_0x8; + /* 0x0c */ u32 field_0xc; + /* 0x10 */ u32 field_0x10; + /* 0x14 */ u32 field_0x14; + /* 0x18 */ u32 field_0x18; + /* 0x1c */ u32 field_0x1c; + /* 0x20 */ u32 field_0x20; +} Arg_800712C4; + +typedef struct { + /* 0x00 */ Arg_800712C4* field_0x0; + /* 0x04 */ Arg_800712C4* field_0x4; + /* 0x08 */ Arg_800712C4* field_0x8; + /* 0x0c */ Arg_800712C4* field_0xc; + /* 0x10 */ Arg_800712C4* field_0x10; + /* 0x14 */ Arg_800712C4* field_0x14; +} Unk_800A81C0; // size:0x18 + +extern Unk_800A81C0 D_800A81C0[2]; + +extern void func_800712C4(Arg_800712C4*); + +extern u8 D_80197168[0x10]; +extern s32 D_80196F58; +extern u8 D_801951A1; +extern u8 D_80197AE7[8]; + +extern void func_80186160(void); +extern s32 func_80186240(s32 arg0); +extern void func_80186284(s32 arg0); +extern void func_80186290(void); +extern void func_801862A8(void); + #endif \ No newline at end of file diff --git a/splat.yaml b/splat.yaml index 5b070ac..63f760a 100644 --- a/splat.yaml +++ b/splat.yaml @@ -48,7 +48,7 @@ segments: subsegments: - [0x1060, c, "main"] - [0x4AC0, asm] - - [0x5FC0, asm] + - [0x5FC0, c] - [0x68E0, asm] - [0x8700, asm] - [0xA370, c] @@ -385,7 +385,7 @@ segments: - [0x514B0, asm] - [0x5AC70, asm] - [0x5AFF0, asm] - - [0x5C060, asm] + - [0x5C060, c] - [0x5C1D0, asm] - [0x5C210, rodata] @@ -419,7 +419,61 @@ segments: - { start: 0x66E10, type: bss, vram: 0x80190F10 } - - [0x66E10, bin] + # - [0x66E10, bin] + + - type: code + dir: overlays/overlay_table_0 + start: 0x66E10 + vram: 0x80197B70 + bss_size: 0x10 + subsegments: + - [0x66E10, asm] + - [0x67570, asm] + - [0x680F0, asm] + + - [0x694B0, rodata] + - [0x69560, rodata] + - [0x69610, rodata] + - [0x69790, rodata] + + - { start: 0x69900, type: bss, vram: 0x8019A660 } + + - [0x69900, bin] + + # - type: code + # dir: overlays/overlay_table_1 + # start: 0x6E660 + # vram: 0x80197B70 + # bss_size: 0x10 + # exclusive_overlay_id: overlay_table_1 + # subsegments: + # - [0x6E660, asm] + + # - [0x70E70, rodata] + # - [0x71060, rodata] + # - [0x71080, rodata] + + # - { start: 0x71280, type: bss, vram: 0x8019A790 } + + # - [0x71280, bin] + + + # - type: code + # dir: overlays/overlay_table_2 + # start: 0xE48F0 + # vram: 0x80197B70 + # bss_size: 0x20 + # exclusive_overlay_id: overlay_table_2 + # symbol_name_format: overlay_table_2_$ROM + # subsegments: + # - [0xE48F0, asm] + # - [0xE4BE0, asm] + # - [0xE5960, asm] + + # - [0xEAF00, rodata] + # - [0xEAF10, rodata] + + # - { start: 0xEBBB0, type: bss, vram: 0x8019EE30 } # - type: code # dir: overlays/unknown diff --git a/src/19050.c b/src/19050.c index 99029a0..76aa311 100644 --- a/src/19050.c +++ b/src/19050.c @@ -99,7 +99,13 @@ void func_80089528(s8 arg0) { } -INCLUDE_ASM(const s32, "19050", func_80089534); +// INCLUDE_ASM(const s32, "19050", func_80089534); +extern u8 D_800E918C; + +/* 19934 80089534 */ +u8 func_80089534(void) { + return D_800E918C; +} INCLUDE_ASM(const s32, "19050", __thread_80089540); diff --git a/src/5FC0.c b/src/5FC0.c new file mode 100644 index 0000000..d941f53 --- /dev/null +++ b/src/5FC0.c @@ -0,0 +1,29 @@ +#include "common.h" + +INCLUDE_ASM(const s32, "5FC0", __calls_loads_overlay_array); + +INCLUDE_ASM(const s32, "5FC0", func_80076150); + +extern u8 D_800A872C; +/* 6588 80076188 */ +u8* func_80076188(void) { + return &D_800A872C; +} + +extern u16 D_800C4C26; +/* 6594 80076194 */ +void func_80076194(void) { + D_800C4C26 = 0xFFFE; +} + +/* 65A4 800761A4 */ +void func_800761A4(void) { + func_80073164(0, 1, 1, 0x80, 1, 0x100, 0x2000); +} + + +INCLUDE_ASM(const s32, "5FC0", __loads_overlay_array); + +INCLUDE_ASM(const s32, "5FC0", func_80076324); + +INCLUDE_ASM(const s32, "5FC0", __get_overlay_index); diff --git a/src/main.c b/src/main.c index 02b2566..b5e2ef4 100644 --- a/src/main.c +++ b/src/main.c @@ -156,9 +156,62 @@ void __calls_osViSwapBuffer_8007307C(void** buffers) } -INCLUDE_ASM(const s32, "main", func_80073164); +/* 3564 80073164 */ +void func_80073164(u8 arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6) { + if (arg0 == 0) { + if ((arg1 << 0x10) >= 0) { + D_800C4C08 = arg1; + } + if ((arg2 << 0x10) >= 0) { + D_800E7D68 = arg2; + } + if ((arg3 << 0x10) >= 0) { + D_800C4A18 = arg3; + } + if ((arg4 << 0x10) >= 0) { + D_800E7A1C = arg4; + } + if ((arg5 << 0x10) >= 0) { + D_800C4BCA = arg5; + } + if ((arg6 << 0x10) >= 0) { + D_800C4AD8 = arg6; + } + } else { + D_800C4C08 += arg1; + D_800E7D68 += arg2; + D_800C4A18 += arg3; + D_800E7A1C += arg4; + D_800C4BCA += arg5; + D_800C4AD8 += arg6; + } + D_800AEE72 = 2; +} + +/* 368C 8007328C */ +void func_8007328C(void) { + s32 index; + for(index = 0; index < 2; index++) { + func_800712C4(D_800A81C0[index].field_0x0); + func_800712C4(D_800A81C0[index].field_0x4); + func_800712C4(D_800A81C0[index].field_0x8); + func_800712C4(D_800A81C0[index].field_0xc); + func_800712C4(D_800A81C0[index].field_0x10); + func_800712C4(D_800A81C0[index].field_0x14); + } + + D_800C4C08 = 0; + D_800E7D68 = 0; + D_800C4A18 = 0; + D_800E7A1C = 0; + D_800C4BCA = 0; + D_800C4AD8 = 0; + D_800AEE72 = 2; + + bzero(&D_800A81C0, 0x30); + D_800A81F0 = 0; +} -INCLUDE_ASM(const s32, "main", func_8007328C); INCLUDE_ASM(const s32, "main", func_8007337C); diff --git a/src/overlays/overlay1/5C060.c b/src/overlays/overlay1/5C060.c new file mode 100644 index 0000000..096eeb4 --- /dev/null +++ b/src/overlays/overlay1/5C060.c @@ -0,0 +1,62 @@ +#include "common.h" + +/* 5C060 80186160 */ +void func_80186160(void) { + D_80197168[0] |= 1; +} + +/* 5C078 80186178 */ +void func_80186178(void) { + D_80197168[0] &= 0xFE; +} + +INCLUDE_ASM(const s32, "overlays/overlay1/5C060", func_80186190); + +/* 5C110 80186210 */ +s32 func_80186210(s32 arg0) { + s32 temp_v1; + s32 var_v1; + + var_v1 = arg0; + if (arg0 < 0) { + var_v1 = arg0 + 7; + } + temp_v1 = var_v1 >> 3; + return (D_80197168[temp_v1] >> (arg0 - (temp_v1 * 8))) & 1; +} + + +/* 5C140 80186240 */ +s32 func_80186240(s32 arg0) { + s32 temp_v1; + s32 var_v0; + s32 var_v1; + + if(arg0 == -1) + return 1; + + var_v1 = arg0; + if (arg0 < 0) { + var_v1 = arg0 + 7; + } + temp_v1 = var_v1 >> 3; + return ((D_80197AE7[temp_v1] >> (arg0 - (temp_v1 * 8))) & 1) ^ 1; +} + + +/* 5C184 80186284 */ +void func_80186284(s32 arg0) { + D_80196F58 = arg0; +} + + +/* 5C190 80186290 */ +void func_80186290(void) { + D_801951A1 |= 1; +} + +/* 5C1A8 801862A8 */ +void func_801862A8(void) { + bzero(&D_80197AE7, 8); +} + diff --git a/symbol_addrs.txt b/symbol_addrs.txt index 3ec0929..3a523eb 100644 --- a/symbol_addrs.txt +++ b/symbol_addrs.txt @@ -1,4 +1,31 @@ +__SOME_OVERLAY_TABLE = 0x800A83C0; // size:0x28 +__SOME_OVERLAY_TABLE_1 = 0x800A83E8; // size:0x28 +__SOME_OVERLAY_TABLE_2 = 0x800A8410; // size:0x28 +__SOME_OVERLAY_TABLE_3 = 0x800A8438; // size:0x28 +__SOME_OVERLAY_TABLE_4 = 0x800A8460; // size:0x28 +__SOME_OVERLAY_TABLE_5 = 0x800A8488; // size:0x28 +__SOME_OVERLAY_TABLE_6 = 0x800A84B0; // size:0x28 + +__SOME_OVERLAY_ID_ARRAY = 0x800A86FC; // size:0x2c + +D_800A86B8 = 0x800A86B8; // size:0x3 type:u8 +D_800A86BC = 0x800A86BC; // size:0x6 type:u8 +D_800A86C4 = 0x800A86C4; // size:0x8 type:u8 +D_800A86CC = 0x800A86CC; // size:0x3 type:u8 +D_800A86D0 = 0x800A86D0; // size:0x4 type:u8 +D_800A86D4 = 0x800A86D4; // size:0x2 type:u8 +D_800A86D8 = 0x800A86D8; // size:0xc type:u8 +D_800A86E4 = 0x800A86E4; // size:0x8 type:u8 +D_800A86EC = 0x800A86EC; // size:0x3 type:u8 +D_800A86F0 = 0x800A86F0; // size:0x7 type:u8 +D_800A86F8 = 0x800A86F8; // size:0x4 type:u8 + +__loads_overlay_array = 0x800761E4; +__get_overlay_index = 0x80076430; +__calls_loads_overlay_array = 0x80075BC0; + +D_800A81C0 = 0x800A81C0; // size:0x30 maybe_boot_01 = 0x800851C0; @@ -70,7 +97,6 @@ __MAIN_START_BUT_STATE = 0x800E8214; __thread_80089358 = 0x80089358; __idle_start_4_threads = 0x80088C50; - __CONTROLLER_0_BUTTON = 0x800E8700; __menu_handle_input = 0x8019B8AC; // type:func