decompile 3A80.c

This commit is contained in:
RevoSucks 2023-08-20 18:08:52 -04:00
parent 08c1c16bda
commit 4eab260c88
5 changed files with 132 additions and 3 deletions

View File

@ -9,6 +9,9 @@ extern s32 func_8005A990(OSPiHandle *);
// bcopy.s
extern void _bcopy(void *, void *, u32);
// 3640.s
extern void* func_80002AF8(s32, void*);
// 3A80.s
extern void func_80002F58(void);
extern void *func_80002FDC(s32);
@ -31,6 +34,9 @@ extern void func_800057C0(void);
// 6BC0.s
extern u32 func_80006314(s32, s32, s32, s32, s32); // types unknown
// 75F0.s
extern void func_80008154(s32, s32, char*, ...);
// 9D20.s
extern void func_80009120(s32);

View File

@ -38,7 +38,7 @@ segments:
- [0x28E0, c, memmap]
- [0x2EC0, c, intro_loader] # intro loader
- [0x3640, asm] #
- [0x3A80, asm] # transition loader
- [0x3A80, c]
- [0x3FB0, asm] # PRES-JPEG decoder
- [0x5580, asm] # there's a split here according to PAL
- [0x60A0, asm] #
@ -352,7 +352,7 @@ segments:
# Start of .rodata
- [0x7BAC0, .rodata, rsp]
- [0x7BB10, rodata, rom_rodata_7BB10]
- [0x7BB20, rodata, rom_rodata_7BB20]
- [0x7BB20, .rodata, 3A80]
- [0x7BB50, rodata, rom_rodata_7BB50]
- [0x7BBE0, .rodata, crash_screen]
- [0x7BFA0, rodata, rom_rodata_7BFA0]

119
src/3A80.c Normal file
View File

@ -0,0 +1,119 @@
#include <ultra64.h>
#include "memmap.h"
#include "intro_loader.h"
extern s32 D_80068B90;
extern u8 D_80104BB0[];
extern s32 D_800A60B0;
uintptr_t func_80002E80(uintptr_t addr) {
uintptr_t retaddr = 0x00000000;
if (addr < (size_t) osMemSize) {
retaddr = addr | 0x80000000;
} else if (addr < 0x10000000U) {
retaddr = Memmap_GetSegmentVaddr(addr);
} else if ((addr >= 0x81000000U) && (addr < 0x90000000U)) { // is the address in fragment space? convert it to its post-relocated address.
retaddr = Memmap_GetFragmentVaddr(addr);
} else if ((addr >= 0x80000000U) && (addr < (uintptr_t) (osMemSize + 0x80000000U))) {
retaddr = addr;
}
return retaddr;
}
// HAL memcpy?
void func_80002F28(u32* dest, u32* src, int size) {
while (size --> 0) {
*(dest++) = *(src++);
}
}
void func_80002F58(void) {
// wat? mem sizes are only ever 0x400000 or 0x800000. This check makes no sense.
if ((D_80068B90 != 0) && ((u32) osMemSize > 0x600000U)) {
func_800022C0(&D_80104BB0, 0x80600000);
} else {
func_800022C0(&D_80104BB0, 0x80400000);
D_80068B90 = 0;
}
func_80003860();
D_800A60B0 = func_80002A40(0x10000, 0);
}
void *func_80002FDC(s32 arg0) {
return func_80002AF8(D_800A60B0, arg0);
}
void func_80003004(void *arg0) {
func_80002BD0(D_800A60B0, arg0);
}
// HAL_DrawRect
void func_8000302C(Gfx** dlist, s32 ulx, s32 lrx, u16 color) {
s32 uly = 0xF;
s32 lry = 0x11;
Gfx *gfx = *dlist;
if (func_80007A58() != 0) {
ulx <<= 1;
lrx <<= 1;
uly <<= 1;
lry <<= 1;
}
gDPPipeSync(gfx++);
gDPSetFillColor(gfx++, color << 16 | color);
gDPFillRectangle(gfx++, ulx, uly, lrx, lry);
*dlist = gfx;
}
void func_8000310C(Gfx** dlist)
{
struct Unk800A6070 * sp54 = func_80002A30();
s32 temp_s1 = func_80002764() - D_80068B90;
if (temp_s1 >= 0)
{
u32 coord = 0x1E;
s32 sp48 = ((u32) ( K0_TO_PHYS(sp54->unk20)) >> 0xF) + coord;
s32 sp44 = ((u32) ( K0_TO_PHYS(sp54->unk28)) >> 0xF) + coord;
s32 sp40 = ((u32) ( K0_TO_PHYS(sp54->unk2C) - D_80068B90) >> 0xF) + coord;
s32 sp3C = ((u32) ( K0_TO_PHYS(sp54->unk24) - D_80068B90) >> 0xF) + coord;
func_8000302C(dlist, coord, sp48, 0xFBCB);
func_8000302C(dlist, sp48, sp44, 0xFFCB);
func_8000302C(dlist, sp44, sp40, 0x2ABF);
func_8000302C(dlist, sp40, sp3C, 0xFFCB);
func_80008154(coord, 0x14, "MEM: +%XH (+%dK)", temp_s1, temp_s1 / 1024);
}
else
{
u32 coord = 0x1E;
s32 sp34 = ((u32) ( K0_TO_PHYS(sp54->unk20)) >> 0xF) + coord;
s32 sp30 = ((u32) ( K0_TO_PHYS(sp54->unk28)) >> 0xF) + coord;
s32 sp2C = ((u32) ( K0_TO_PHYS(sp54->unk2C) - D_80068B90) >> 0xF) + coord;
s32 sp28 = ((u32) ( K0_TO_PHYS(sp54->unk24) - D_80068B90) >> 0xF) + coord;
func_8000302C(dlist, coord, sp34, 0xFBCB);
func_8000302C(dlist, sp34, sp2C, 0xFFCB);
func_8000302C(dlist, sp2C, sp30, 0xF94B);
func_8000302C(dlist, sp30, sp28, 0xFFCB);
func_80008154(coord, 0x14, "MEM: -%XH (-%dK)", -temp_s1, -temp_s1 / 1024);
}
}
void func_8000330C(u64 * dest, u32 arg1) {
while( arg1 --> 0 ) {
*(dest++) = -1;
}
}
s32 func_80003348(u64* arg0)
{
s32 ret = 0;
while (*(arg0++) == 0x8040000080400000)
{
ret++;
}
return ret * sizeof(*arg0);
}

View File

@ -549,4 +549,6 @@ D_87906094 = 0x87906094;
D_87906098 = 0x87906098;
D_879060A4 = 0x879060A4;
D_879060C4 = 0x879060C4;
D_879060C8 = 0x879060C8;
D_879060C8 = 0x879060C8;
gShowCPUProfiler = 0x80068BC0;
gShowMEMProfiler = 0x80068BC4;

View File

@ -12,3 +12,5 @@ piThreadStack = 0x801026D0;
LEOZONE_OUTERCYL_TBL = 0x8007DD08;
LEOinterruptThreadStack = 0x80100638;
.L8120A860 = 0x8120A860;
gShowCPUProfiler = 0x80068BC0;
gShowMEMProfiler = 0x80068BC4;