Skip to content

Commit

Permalink
Merge pull request #49 from RevoSucks/decompile_C030
Browse files Browse the repository at this point in the history
decompile C030.c
  • Loading branch information
RevoSucks authored Jul 29, 2023
2 parents 2e23eeb + 1337960 commit 857c200
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ build/src/libultra/io/gbpakpower.c.o: OPTFLAGS += -Wo,-loopunroll,0
build/src/libultra/io/gbpakinit.c.o: OPTFLAGS += -Wo,-loopunroll,0
build/src/libultra/io/gbpakselectbank.c.o: OPTFLAGS += -Wo,-loopunroll,0

build/src/C030.c.o: OPTFLAGS += -Wo,-loopunroll,0

# Libultra misc
build/src/libultra/gu/scale.c.o: CC := $(CC_OLD)
build/src/libultra/gu/scale.c.o: OPTFLAGS := -O3
Expand Down
2 changes: 1 addition & 1 deletion splat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ segments:
- [0xAF00, asm] # camera code
- [0xB130, c, hal_libc]
- [0xB230, c, gb_tower]
- [0xC030, asm] # extra sprites loader
- [0xC030, c] # extra sprites loader
- [0xC3D0, asm, exception_set] # exception functions
- [0xC3F0, asm] # yay0 decoder
- [0xC4B0, bin, libleo_bootdisk] # These are libleo's bootdisk and bootstrap files, but
Expand Down
92 changes: 92 additions & 0 deletions src/C030.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "ultra64.h"
#include "ultra64/controller.h"

extern s32 D_800697E0;
extern u8 D_800A82B0[32];

extern OSMesgQueue gSIEventMesgQueue;

s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force);
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer);

extern s32 osPfsIsPlug(OSMesgQueue *, u8 *);

extern u8 D_800A82CF;

// some kind of cycle count sleep function. just like the one in crash_screen.c
void func_8000B430(long ms) {
unsigned long start = (osGetCount());
unsigned long target = (s32)((ms * 1000LL) * 3000 / 64ULL + start);

while (osGetCount() < target) {
;
}
}

s32 func_8000B4C4(void) {
s32 i;
s32 ret;
u8 sp2F; // sp2F

if (D_800697E0 == 0) {
u8 *buffer;
osPfsIsPlug(&gSIEventMesgQueue, &sp2F);
if(sp2F & 8) {
Cont_BlockEepromQueue();
for(buffer = D_800A82B0, i = 0; i < 32; i++) {
buffer[i] = 0xFE;
}
if((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2)
&& (__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
Cont_NoBlockEepromQueue();
return 0;
}
if((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0) && (D_800A82CF == 0xFE)) {
Cont_NoBlockEepromQueue();
return 0;
}
for(buffer = D_800A82B0, i = 0; i < 32; i+=4) {
buffer[i+0] = 0x85;
buffer[i+1] = 0x85;
buffer[i+2] = 0x85;
buffer[i+3] = 0x85;
}
if((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2)
&& (__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
Cont_NoBlockEepromQueue();
return 0;
}
if((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0)
&& (D_800A82CF == 0x85)) {
Cont_NoBlockEepromQueue();
D_800697E0 = 1;
return 1;
}
Cont_NoBlockEepromQueue();
}
return 0;
}
return 1;
}

u8 func_8000B6B4(void) {
Cont_BlockEepromQueue();
__osContRamRead(&gSIEventMesgQueue, 3, 0x600, D_800A82B0);
Cont_NoBlockEepromQueue();
return D_800A82CF;
}

void func_8000B6FC(u8 arg0) {
u8 *buffer = D_800A82B0;
Cont_BlockEepromQueue();
__osContRamRead(&gSIEventMesgQueue, 3, 0x600, buffer);
if (D_800A82CF == 8) {
do {
func_8000B430(0x14);
__osContRamRead(&gSIEventMesgQueue, 3, 0x600, buffer);
} while (buffer[0x1F] == 8);
}
D_800A82CF = arg0;
__osContRamWrite(&gSIEventMesgQueue, 3, 0x600, buffer, 1);
Cont_NoBlockEepromQueue();
}

0 comments on commit 857c200

Please sign in to comment.