Decompile bbufUpdateIndex2Buffer

This commit is contained in:
Ryan Dwyer 2021-01-27 12:21:38 +10:00
parent 8937776679
commit 34a077c41f
9 changed files with 84 additions and 101 deletions

View File

@ -186,7 +186,7 @@ void __scMain(void *arg)
OSSched *sc = (OSSched *)arg;
int done = 0;
func00002400();
bbufResetBuffers();
while (!done) {
osRecvMesg(&sc->interruptQ, (OSMesg *)&msg, OS_MESG_BLOCK);
@ -349,106 +349,88 @@ u32 *func000023f4(void)
return &var8008de38;
}
void func00002400(void)
void bbufResetBuffers(void)
{
s32 i;
s32 j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 120; j++) {
var8008de48[i].unk00[j].unk00 = 0;
g_BootBuffers[i].unk00[j].unk00 = 0;
}
var8008fa68[i] = 0;
g_BootBufferDirtyIndexes[i] = 0;
}
}
struct bootbufferthing *func0000244c(void)
struct bootbufferthing *bbufGetIndex0Buffer(void)
{
return &var8008de48[var8008fa6c];
return &g_BootBuffers[g_BootBufferIndex0];
}
struct bootbufferthing *func00002480(void)
struct bootbufferthing *bbufGetIndex1Buffer(void)
{
return &var8008de48[var8008fa70];
return &g_BootBuffers[g_BootBufferIndex1];
}
struct bootbufferthing *func000024b4(void)
struct bootbufferthing *bbufGetIndex2Buffer(void)
{
return &var8008de48[var8008fa74];
return &g_BootBuffers[g_BootBufferIndex2];
}
void func000024e8(void)
void bbufIncIndex0(void)
{
var8008fa6c = (var8008fa6c + 1) % 3;
g_BootBufferIndex0 = (g_BootBufferIndex0 + 1) % 3;
}
void func00002510(void)
void bbufIncIndex1(void)
{
var8008fa70 = (var8008fa70 + 1) % 3;
g_BootBufferIndex1 = (g_BootBufferIndex1 + 1) % 3;
}
void func00002538(void)
void bbufIncIndex2(void)
{
var8008fa74 = (var8008fa74 + 1) % 3;
g_BootBufferIndex2 = (g_BootBufferIndex2 + 1) % 3;
}
void func00002560(void)
void bbufResetIndexes(void)
{
var8008fa6c = 0;
var8008fa70 = 1;
var8008fa74 = 0;
g_BootBufferIndex0 = 0;
g_BootBufferIndex1 = 1;
g_BootBufferIndex2 = 0;
}
GLOBAL_ASM(
glabel func00002580
/* 2580: 27bdffe8 */ addiu $sp,$sp,-24
/* 2584: afbf0014 */ sw $ra,0x14($sp)
/* 2588: 0c00092d */ jal func000024b4
/* 258c: 00000000 */ nop
/* 2590: 3c0b8009 */ lui $t3,%hi(var8008fa74)
/* 2594: 3c0a8009 */ lui $t2,%hi(var8008fa68)
/* 2598: 254afa68 */ addiu $t2,$t2,%lo(var8008fa68)
/* 259c: 256bfa74 */ addiu $t3,$t3,%lo(var8008fa74)
/* 25a0: 00003825 */ or $a3,$zero,$zero
/* 25a4: 00401825 */ or $v1,$v0,$zero
/* 25a8: 24090960 */ addiu $t1,$zero,0x960
/* 25ac: 24080001 */ addiu $t0,$zero,0x1
.L000025b0:
/* 25b0: 946e0000 */ lhu $t6,0x0($v1)
/* 25b4: 24e70014 */ addiu $a3,$a3,0x14
/* 25b8: 11c00012 */ beqz $t6,.L00002604
/* 25bc: 00000000 */ nop
/* 25c0: 8d6f0000 */ lw $t7,0x0($t3)
/* 25c4: 8c640008 */ lw $a0,0x8($v1)
/* 25c8: 014fc021 */ addu $t8,$t2,$t7
/* 25cc: 93190000 */ lbu $t9,0x0($t8)
/* 25d0: 94850000 */ lhu $a1,0x0($a0)
/* 25d4: 5519000b */ bnel $t0,$t9,.L00002604
/* 25d8: a4650002 */ sh $a1,0x2($v1)
/* 25dc: 8c64000c */ lw $a0,0xc($v1)
/* 25e0: 94860000 */ lhu $a2,0x0($a0)
/* 25e4: 00a6082a */ slt $at,$a1,$a2
/* 25e8: 10200003 */ beqz $at,.L000025f8
/* 25ec: 00000000 */ nop
/* 25f0: 10000004 */ b .L00002604
/* 25f4: a4650002 */ sh $a1,0x2($v1)
.L000025f8:
/* 25f8: 10000002 */ b .L00002604
/* 25fc: a4660002 */ sh $a2,0x2($v1)
/* 2600: a4650002 */ sh $a1,0x2($v1)
.L00002604:
/* 2604: 14e9ffea */ bne $a3,$t1,.L000025b0
/* 2608: 24630014 */ addiu $v1,$v1,0x14
/* 260c: 8d6c0000 */ lw $t4,0x0($t3)
/* 2610: 014c6821 */ addu $t5,$t2,$t4
/* 2614: 0c00094e */ jal func00002538
/* 2618: a1a00000 */ sb $zero,0x0($t5)
/* 261c: 8fbf0014 */ lw $ra,0x14($sp)
/* 2620: 27bd0018 */ addiu $sp,$sp,0x18
/* 2624: 03e00008 */ jr $ra
/* 2628: 00000000 */ nop
);
void bbufUpdateIndex2Buffer(void)
{
struct bootbufferthing *thing = bbufGetIndex2Buffer();
s32 i;
for (i = 0; i < 120; i++) {
struct bootbufferthingdeep *deep = &thing->unk00[i];
if (deep->unk00) {
u16 *unk08 = deep->unk08;
u16 value08 = unk08[0];
if (g_BootBufferDirtyIndexes[g_BootBufferIndex2] == 1) {
u16 *unk0c = deep->unk0c;
u16 value0c = unk0c[0];
if (value0c > value08) {
deep->unk02 = value08;
} else {
deep->unk02 = value0c;
}
} else {
deep->unk02 = value08;
}
}
}
g_BootBufferDirtyIndexes[g_BootBufferIndex2] = 0;
bbufIncIndex2();
}
void __scHandleRDP(OSSched *sc)
{
@ -456,7 +438,7 @@ void __scHandleRDP(OSSched *sc)
s32 state;
if (sc->curRDPTask != NULL) {
func00002580();
bbufUpdateIndex2Buffer();
if (var8005dd18 == 0) {
func00002d90();

View File

@ -454,7 +454,7 @@ void coreLoadStage(s32 stagenum)
func0f011124(false);
var80084018 = 1;
func00002560();
bbufResetIndexes();
coreSetPaused(0);
#if PIRACYCHECKS

View File

@ -7455,7 +7455,7 @@ glabel var7f1b5108
/* f125d98: 0048b821 */ addu $s7,$v0,$t0
/* f125d9c: 26e9fff0 */ addiu $t1,$s7,-16
/* f125da0: afa900a0 */ sw $t1,0xa0($sp)
/* f125da4: 0c000913 */ jal func0000244c
/* f125da4: 0c000913 */ jal bbufGetIndex0Buffer
/* f125da8: 2455000f */ addiu $s5,$v0,0xf
/* f125dac: c62c0000 */ lwc1 $f12,0x0($s1)
/* f125db0: 3c01447a */ lui $at,0x447a
@ -7791,7 +7791,7 @@ glabel var7f1b5108
/* f1262ac: afb90170 */ sw $t9,0x170($sp)
/* f1262b0: 3c090001 */ lui $t1,0x1
/* f1262b4: ad490004 */ sw $t1,0x4($t2)
/* f1262b8: 0c000920 */ jal func00002480
/* f1262b8: 0c000920 */ jal bbufGetIndex1Buffer
/* f1262bc: ad4b0000 */ sw $t3,0x0($t2)
/* f1262c0: 8fac0098 */ lw $t4,0x98($sp)
/* f1262c4: 0fc49687 */ jal func0f125a1c
@ -8875,7 +8875,7 @@ glabel func0f12715c
/* f127268: 00000000 */ nop
/* f12726c: 4502001c */ bc1fl .L0f1272e0
/* f127270: 8fb90064 */ lw $t9,0x64($sp)
/* f127274: 0c000920 */ jal func00002480
/* f127274: 0c000920 */ jal bbufGetIndex1Buffer
/* f127278: 00129140 */ sll $s2,$s2,0x5
/* f12727c: 0fc49687 */ jal func0f125a1c
/* f127280: 00522021 */ addu $a0,$v0,$s2

View File

@ -59,7 +59,7 @@ const u32 var7f1b5a0c[] = {0x3ecccccd};
void func0f13c510(void)
{
struct bootbufferthing *thing = func0000244c();
struct bootbufferthing *thing = bbufGetIndex0Buffer();
s32 i;
for (i = 0; i < ARRAYCOUNT(thing->unk00); i++) {
@ -69,8 +69,8 @@ void func0f13c510(void)
void func0f13c54c(void)
{
func000024e8();
func00002510();
bbufIncIndex0();
bbufIncIndex1();
}
GLOBAL_ASM(
@ -280,7 +280,7 @@ glabel func0f13c780
/* f13c7b8: f7b80028 */ sdc1 $f24,0x28($sp)
/* f13c7bc: f7b60020 */ sdc1 $f22,0x20($sp)
/* f13c7c0: f7b40018 */ sdc1 $f20,0x18($sp)
/* f13c7c4: 0c000913 */ jal func0000244c
/* f13c7c4: 0c000913 */ jal bbufGetIndex0Buffer
/* f13c7c8: afa401d8 */ sw $a0,0x1d8($sp)
/* f13c7cc: 8fa501d8 */ lw $a1,0x1d8($sp)
/* f13c7d0: 3c0e800a */ lui $t6,%hi(g_Vars+0x284)
@ -1151,7 +1151,7 @@ glabel func0f13d568
/* f13d5a4: f7b60038 */ sdc1 $f22,0x38($sp)
/* f13d5a8: f7b40030 */ sdc1 $f20,0x30($sp)
/* f13d5ac: afa40160 */ sw $a0,0x160($sp)
/* f13d5b0: 0c000920 */ jal func00002480
/* f13d5b0: 0c000920 */ jal bbufGetIndex1Buffer
/* f13d5b4: afa50164 */ sw $a1,0x164($sp)
/* f13d5b8: 0040a025 */ or $s4,$v0,$zero
/* f13d5bc: 0fc00331 */ jal roomGetUnk5c

View File

@ -476,7 +476,7 @@ glabel func0f1766b4
/* f1766d4: afb40028 */ sw $s4,0x28($sp)
/* f1766d8: afb30024 */ sw $s3,0x24($sp)
/* f1766dc: afb20020 */ sw $s2,0x20($sp)
/* f1766e0: 0c000913 */ jal func0000244c
/* f1766e0: 0c000913 */ jal bbufGetIndex0Buffer
/* f1766e4: afb1001c */ sw $s1,0x1c($sp)
/* f1766e8: 3c0e8008 */ lui $t6,%hi(var800844f0)
/* f1766ec: 8dce44f0 */ lw $t6,%lo(var800844f0)($t6)
@ -484,19 +484,19 @@ glabel func0f1766b4
/* f1766f4: 0000a025 */ or $s4,$zero,$zero
/* f1766f8: 0c002ac7 */ jal viGetUnk28
/* f1766fc: afae004c */ sw $t6,0x4c($sp)
/* f176700: 3c138009 */ lui $s3,%hi(var8008fa6c)
/* f176704: 2673fa6c */ addiu $s3,$s3,%lo(var8008fa6c)
/* f176700: 3c138009 */ lui $s3,%hi(g_BootBufferIndex0)
/* f176704: 2673fa6c */ addiu $s3,$s3,%lo(g_BootBufferIndex0)
/* f176708: 0fc5d99a */ jal func0f176668
/* f17670c: 8e640000 */ lw $a0,0x0($s3)
/* f176710: 8e780000 */ lw $t8,0x0($s3)
/* f176714: 3c018009 */ lui $at,%hi(var8008fa68)
/* f176714: 3c018009 */ lui $at,%hi(g_BootBufferDirtyIndexes)
/* f176718: 02001825 */ or $v1,$s0,$zero
/* f17671c: 240f0001 */ addiu $t7,$zero,0x1
/* f176720: 26100008 */ addiu $s0,$s0,0x8
/* f176724: 00380821 */ addu $at,$at,$t8
/* f176728: 3c16e700 */ lui $s6,0xe700
/* f17672c: afa20044 */ sw $v0,0x44($sp)
/* f176730: a02ffa68 */ sb $t7,%lo(var8008fa68)($at)
/* f176730: a02ffa68 */ sb $t7,%lo(g_BootBufferDirtyIndexes)($at)
/* f176734: 02008825 */ or $s1,$s0,$zero
/* f176738: ac600004 */ sw $zero,0x4($v1)
/* f17673c: ac760000 */ sw $s6,0x0($v1)

View File

@ -2658,11 +2658,11 @@ u32 var8008de38 = 0;
u32 var8008de3c = 0;
u32 var8008de40 = 0;
u32 var8008de44 = 0;
struct bootbufferthing var8008de48[3] = {0, 0, 0};
u8 var8008fa68[3] = {0, 0, 0};
s32 var8008fa6c = 0;
s32 var8008fa70 = 0;
s32 var8008fa74 = 0;
struct bootbufferthing g_BootBuffers[3] = {0, 0, 0};
u8 g_BootBufferDirtyIndexes[3] = {0, 0, 0};
s32 g_BootBufferIndex0 = 0;
s32 g_BootBufferIndex1 = 0;
s32 g_BootBufferIndex2 = 0;
u32 var8008fa78 = 0;
u32 var8008fa7c = 0;
OSMesg g_ResetMesg = NULL;

View File

@ -12,11 +12,11 @@ void __scAppendList(OSSched *sc, OSScTask *t);
void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp);
void __scMain(void *arg);
void __scYield(OSSched *sc);
struct bootbufferthing *func0000244c(void);
void func00002400(void);
void func000024e8(void);
void func00002510(void);
void func00002580(void);
struct bootbufferthing *bbufGetIndex0Buffer(void);
void bbufResetBuffers(void);
void bbufIncIndex0(void);
void bbufIncIndex1(void);
void bbufUpdateIndex2Buffer(void);
void func00002d90(void);
#endif

View File

@ -308,10 +308,10 @@ extern s32 g_NumTags;
extern struct tag **g_TagPtrs;
extern u32 var8008de38;
extern struct bootbufferthing var8008de48[3];
extern s32 var8008fa6c;
extern s32 var8008fa70;
extern s32 var8008fa74;
extern struct bootbufferthing g_BootBuffers[3];
extern s32 g_BootBufferIndex0;
extern s32 g_BootBufferIndex1;
extern s32 g_BootBufferIndex2;
extern u8 g_Is4Mb;
extern u32 var80090af4;
extern u32 var80090af8;
@ -342,7 +342,7 @@ extern u32 var8008de08;
extern u32 var8008de0c;
extern u32 var8008de10;
extern OSTimer var8008de18;
extern u8 var8008fa68[3];
extern u8 g_BootBufferDirtyIndexes[3];
extern OSMesg g_ResetMesg;
extern OSMesgQueue g_ResetMesgQueue;
extern OSThread g_ResetThread;

View File

@ -3426,9 +3426,10 @@ struct audioconfig {
struct bootbufferthingdeep {
u16 unk00;
u16 unk02;
u32 unk04;
u32 unk08;
u32 unk0c;
u16 *unk08;
u16 *unk0c;
u32 unk10;
};