Decompile alBnkfNew

This commit is contained in:
Ryan Dwyer
2021-03-27 19:06:24 +10:00
parent d8d1ec2aa3
commit b8d094f282
3 changed files with 29 additions and 72 deletions
-1
View File
@@ -5,6 +5,5 @@
#include "types.h"
u32 func00037650(void);
void func00037704(void *arg0, void *arg1);
#endif
+6 -6
View File
@@ -37,7 +37,7 @@ u32 var80094ed4;
struct var80094ed8 var80094ed8[3];
ALHeap g_SndHeap;
u32 var80095200;
u32 var80095204;
ALBank *var80095204;
struct seqtable *g_SeqTable;
u32 var8009520c;
u8 var80095210[0x40f0];
@@ -2222,7 +2222,7 @@ void sndInit(void)
u32 seqromaddr = (u32) &_sequencesSegmentRomStart;
u8 *heapstart = ptr;
u8 *end = heapstart + heaplen;
u32 *tmp;
ALBankFile *bankfile;
while (ptr < end) {
*ptr = 0;
@@ -2241,16 +2241,16 @@ void sndInit(void)
// Load seq.ctl
var80095200 = 0xffffffff;
tmp = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len);
dmaExec(tmp, &_seqctlSegmentRomStart, len);
bankfile = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len);
dmaExec(bankfile, &_seqctlSegmentRomStart, len);
// Load seq.tbl
func00037704(tmp, &_seqtblSegmentRomStart);
alBnkfNew(bankfile, &_seqtblSegmentRomStart);
// Load the sequences table. To do this, load the header of the
// sequences segment and read the number of sequences, then allocate
// enough space for the table and load it.
var80095204 = tmp[1];
var80095204 = bankfile->bankArray[0];
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, 0x10);
dmaExec(g_SeqTable, (void *) seqromaddr, 0x10);
+23 -65
View File
@@ -24,71 +24,29 @@ void alSeqFileNew(ALSeqFile *file, u8 *base)
}
}
GLOBAL_ASM(
glabel func00037704
/* 37704: 27bdffd8 */ addiu $sp,$sp,-40
/* 37708: afbf0014 */ sw $ra,0x14($sp)
/* 3770c: afa40028 */ sw $a0,0x28($sp)
/* 37710: afa5002c */ sw $a1,0x2c($sp)
/* 37714: 8fae0028 */ lw $t6,0x28($sp)
/* 37718: afae0024 */ sw $t6,0x24($sp)
/* 3771c: 8faf002c */ lw $t7,0x2c($sp)
/* 37720: afaf0020 */ sw $t7,0x20($sp)
/* 37724: 8fb80028 */ lw $t8,0x28($sp)
/* 37728: 24014231 */ addiu $at,$zero,0x4231
/* 3772c: 87190000 */ lh $t9,0x0($t8)
/* 37730: 13210003 */ beq $t9,$at,.L00037740
/* 37734: 00000000 */ nop
/* 37738: 10000027 */ b .L000377d8
/* 3773c: 00000000 */ nop
.L00037740:
/* 37740: 8fa80028 */ lw $t0,0x28($sp)
/* 37744: afa0001c */ sw $zero,0x1c($sp)
/* 37748: 85090002 */ lh $t1,0x2($t0)
/* 3774c: 19200020 */ blez $t1,.L000377d0
/* 37750: 00000000 */ nop
.L00037754:
/* 37754: 8fab001c */ lw $t3,0x1c($sp)
/* 37758: 8faa0028 */ lw $t2,0x28($sp)
/* 3775c: 8faf0024 */ lw $t7,0x24($sp)
/* 37760: 000b6080 */ sll $t4,$t3,0x2
/* 37764: 014c6821 */ addu $t5,$t2,$t4
/* 37768: 8dae0004 */ lw $t6,0x4($t5)
/* 3776c: 01cfc021 */ addu $t8,$t6,$t7
/* 37770: adb80004 */ sw $t8,0x4($t5)
/* 37774: 8fa8001c */ lw $t0,0x1c($sp)
/* 37778: 8fb90028 */ lw $t9,0x28($sp)
/* 3777c: 00084880 */ sll $t1,$t0,0x2
/* 37780: 03295821 */ addu $t3,$t9,$t1
/* 37784: 8d6a0004 */ lw $t2,0x4($t3)
/* 37788: 11400009 */ beqz $t2,.L000377b0
/* 3778c: 00000000 */ nop
/* 37790: 8fae001c */ lw $t6,0x1c($sp)
/* 37794: 8fac0028 */ lw $t4,0x28($sp)
/* 37798: 8fa50024 */ lw $a1,0x24($sp)
/* 3779c: 000e7880 */ sll $t7,$t6,0x2
/* 377a0: 018fc021 */ addu $t8,$t4,$t7
/* 377a4: 8f040004 */ lw $a0,0x4($t8)
/* 377a8: 0c00ddfa */ jal _bnkfPatchBank
/* 377ac: 8fa60020 */ lw $a2,0x20($sp)
.L000377b0:
/* 377b0: 8fad001c */ lw $t5,0x1c($sp)
/* 377b4: 8fb90028 */ lw $t9,0x28($sp)
/* 377b8: 25a80001 */ addiu $t0,$t5,0x1
/* 377bc: afa8001c */ sw $t0,0x1c($sp)
/* 377c0: 87290002 */ lh $t1,0x2($t9)
/* 377c4: 0109082a */ slt $at,$t0,$t1
/* 377c8: 1420ffe2 */ bnez $at,.L00037754
/* 377cc: 00000000 */ nop
.L000377d0:
/* 377d0: 10000001 */ b .L000377d8
/* 377d4: 00000000 */ nop
.L000377d8:
/* 377d8: 8fbf0014 */ lw $ra,0x14($sp)
/* 377dc: 27bd0028 */ addiu $sp,$sp,0x28
/* 377e0: 03e00008 */ jr $ra
/* 377e4: 00000000 */ nop
);
void alBnkfNew(ALBankFile *file, u8 *table)
{
s32 offset = (s32) file;
s32 woffset = (s32) table;
s32 i;
/*
* check the file format revision in debug libraries
*/
ALFailIf(file->revision != AL_BANK_VERSION, ERR_ALBNKFNEW);
/*
* patch the file so that offsets are pointers
*/
for (i = 0; i < file->bankCount; i++) {
file->bankArray[i] = (ALBank *)((u8 *)file->bankArray[i] + offset);
if (file->bankArray[i]) {
_bnkfPatchBank(file->bankArray[i], offset, woffset);
}
}
}
void _bnkfPatchBank(ALBank *bank, s32 offset, s32 table)
{