Decompiled a couple functions

This commit is contained in:
Ogre 2023-09-02 00:27:33 +02:00
parent 1d45805511
commit e579899bd0
8 changed files with 137 additions and 8 deletions

View File

@ -41,6 +41,8 @@ typedef struct {
/* 0xc */ s32 field_0xc;
} Stack__dma_load_loop; // size:0x10
extern void romCopy(const void* src, const void* dst, const s32 len);
extern void Stack__dma_load_loop_new(Stack__dma_load_loop* arg0, OSMesgQueue* arg1, s16 arg2);
extern void Stack__dma_load_loop_delete(Stack__dma_load_loop* arg0);

View File

@ -121,7 +121,7 @@ segments:
- [0x1B2E0, asm]
- [0x1B320, asm]
- [0x1B360, asm]
- [0x1B3A0, asm]
- [0x1B3A0, c]
- [0x1B3E0, c]
- [0x1B510, c]
- [0x1B530, asm]
@ -508,6 +508,7 @@ segments:
- [0x4F0FB0, bin] # Song
- [0x4F4070, bin]
# __calls_romCopy_8009DF48 starts reading here
- [0x594280, bin]
- [0x636784, bin, "last_battle_test.n64"]

14
src/1B3A0.c Normal file
View File

@ -0,0 +1,14 @@
#include "common.h"
extern void (*SWAP_BUFFER_FUNC_800A9E8C)(void*);
/* 1B3A0 8008AFA0 */
void set_swap_buffer_func_800A9E8C(void (*arg0)(void*)) {
s32 mask;
mask = osSetIntMask(OS_IM_NONE);
SWAP_BUFFER_FUNC_800A9E8C = arg0;
osSetIntMask(mask);
}

View File

@ -2,7 +2,40 @@
INCLUDE_ASM(const s32, "2DE10", func_8009DA10);
INCLUDE_ASM(const s32, "2DE10", __calls_romCopy_8009DA50);
// INCLUDE_ASM(const s32, "2DE10", __calls_romCopy_8009DA50);
/* 2DE50 8009DA50 */
void __calls_romCopy_8009DA50(u8* src, u8* dst, u32 len)
{
u8 sp1F[32];
u8* _dst;
u8* _src;
s32 i;
// align to 16
_src = (u8*) (((u32) &sp1F[15] >> 4) << 4);
if (len < 0x10)
{
_dst = dst;
// copy into stack, length aligned to 2 bytes
romCopy(src, _src, (len + 1) & ~1);
len--;
// then copy from stack into destination
while(len != -1)
{
*_dst++ = *_src++;
len--;
}
}
else
{
// too big to fit in our stack, so just do a regular copy
romCopy(src, dst, (len + 1) & ~1);
}
}
void func_8009DAEC(void) { }

View File

@ -22,7 +22,7 @@ INCLUDE_ASM(const s32, "A370", func_8007AB7C);
INCLUDE_ASM(const s32, "A370", func_8007ABAC);
extern void __some_logging(char*, u8);
extern void __some_logging(unsigned char*, ...);
extern char D_800AE038;
extern OSMesgQueue MQ_800AF320;
@ -72,7 +72,14 @@ INCLUDE_ASM(const s32, "A370", func_8007BA98);
INCLUDE_ASM(const s32, "A370", func_8007BB48);
INCLUDE_ASM(const s32, "A370", func_8007BB90);
// INCLUDE_ASM(const s32, "A370", func_8007BB90);
extern unsigned char STR_Error;
extern unsigned char STR_LHa___s_s__s;
/* BF90 8007BB90 */
void __log_lha_error(unsigned char* arg0, unsigned char* arg1) {
__some_logging(&STR_LHa___s_s__s, &STR_Error, arg0, arg1);
}
INCLUDE_ASM(const s32, "A370", func_8007BBC0);

View File

@ -1,6 +1,6 @@
#include "PR/os.h"
#include "common.h"
INCLUDE_ASM(const s32, "main", func_80070C60);
INCLUDE_ASM(const s32, "main", AddHeap);
@ -103,7 +103,62 @@ s32 func_80072944(void) {
INCLUDE_ASM(const s32, "main", __calls_copy_controller_data);
INCLUDE_ASM(const s32, "main", __calls_osViSwapBuffer_8007307C);
extern u8 __reset_compared_osTvType(); /* extern */
extern void* D_800C4BB8;
extern OSViMode osViModeMpalHpf1;
extern OSViMode osViModeMpalLan1;
extern OSViMode osViModeNtscHpf1;
extern OSViMode osViModeNtscLan1;
#define OS_TV_TYPE_PAL 0
#define OS_TV_TYPE_NTSC 1
#define OS_TV_TYPE_MPAL 2
/* 347C 8007307C */
void __calls_osViSwapBuffer_8007307C(void** buffers)
{
u8 prev;
D_800C4BB8 = buffers[3];
prev = __reset_compared_osTvType();
if (prev == OS_TV_TYPE_MPAL)
{
switch(osTvType)
{
case OS_TV_TYPE_NTSC:
osViSetMode(&osViModeNtscHpf1);
break;
case OS_TV_TYPE_MPAL:
osViSetMode(&osViModeMpalHpf1);
break;
}
}
else if (prev == OS_TV_TYPE_NTSC)
{
if (osTvType == prev) goto ntsc;
if(osTvType == OS_TV_TYPE_MPAL) goto pal;
goto next;
ntsc:
osViSetMode(&osViModeNtscLan1);
goto next;
pal:
osViSetMode(&osViModeMpalLan1);
goto next;
}
next:
if (prev != OS_TV_TYPE_PAL)
osViSetSpecialFeatures(OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF);
osViSwapBuffer(buffers[3]);
}
INCLUDE_ASM(const s32, "main", func_80073164);

View File

@ -2,7 +2,6 @@
void __load_song(void*);
extern void romCopy(const void* src, const void* dst, const s32 len);
extern void Mus__unknown_80081DB4(const void* arg0, const void* arg1);
extern void func_80081F7C(const void* arg);
extern void MusFxBankSetPtrBank(const void*, const void*);

View File

@ -4,6 +4,8 @@ maybe_boot_01 = 0x800851C0;
__add_0x594284 = 0x8009DD28;
__log_lha_error = 0x8007BB90;
D_800A81C0 = 0x800A81C0; // size:0x30
D_800C4BBC = 0x800C4BBC; // size:0x8
D_800AEFE0 = 0x800AEFE0; // size:0x8
@ -13,6 +15,16 @@ D_800E7D90 = 0x800E7D90; // size:0x58
D_800E7DE8 = 0x800E7DE8; // size:0x58
D_800AEFE0 = 0x800AEFE0; // size:0x8
VALID_LHA_MAGIC = 0x800A8750;
STR_LHa___s_s__s = 0x800AE30C; // type:asciz
STR_Error = 0x800AE31C; // type:asciz
STR_Fatal_error = 0x800AE324; // type:asciz
STR_Invalid_header_LHarc_file_ = 0x800AE0E8; // type:asciz
STR_rb = 0x800AE0A8; // type:asciz
STR_wb = 0x800AE27C; // type:asciz
STR_Unknown_method_skiped = 0x800AE284; // type:asciz
__calls_osViSwapBuffer_8007307C = 0x8007307C;
__osViSwapBuffer_3 = 0x8008B110;
@ -292,9 +304,15 @@ __thread_80089200 = 0x80089200;
__thread_800893C0 = 0x800893C0;
__thread_80089540 = 0x80089540;
STR_INVALID_HEADER_LHA_FILE = 0x800AE108;
SWAP_BUFFER_FUNC = 0x800A9E84;
set_swap_buffer_func = 0x800899D0;
SWAP_BUFFER_FUNC_800A9E88 = 0x800A9E88;
SWAP_BUFFER_FUNC_800A9E8C = 0x800A9E8C;
set_swap_buffer_func_800A9E8C = 0x8008AFA0;
__reset_compared_osTvType = 0x8016CD3C;
__get_compared_osTvType = 0x8016CD30;
__inc_compared_osTvType = 0x8016CD5C;
@ -315,7 +333,7 @@ __calls_read_controller_0 = 0x8008A47C;
__calls_read_controller_1 = 0x8008A508;
__calls_read_controller_2 = 0x8008A528;
__CRC_ERROR = 0x800AE2A0;
STR_CRC_error = 0x800AE2A0;
__FILE_WRITE_ERROR = 0x800AE348;
__FILE_READ_ERROR = 0x800AE378;
__logs_read_error = 0x8007C590;