Decompile dmaExecWithAutoAlign

This commit is contained in:
Ryan Dwyer 2021-02-13 11:57:59 +10:00
parent db073c46a9
commit a2eabf9e69
6 changed files with 38 additions and 50 deletions

View File

@ -739,7 +739,7 @@ glabel mpLoadConfig
/* f19b990: 01495021 */ addu $t2,$t2,$t1
/* f19b994: 000a50c0 */ sll $t2,$t2,0x3
/* f19b998: 014b2821 */ addu $a1,$t2,$t3
/* f19b99c: 0c003522 */ jal func0000d488
/* f19b99c: 0c003522 */ jal dmaExecWithAutoAlign
/* f19b9a0: 24060068 */ addiu $a2,$zero,0x68
/* f19b9a4: 8fac0050 */ lw $t4,0x50($sp)
/* f19b9a8: 8fb901c8 */ lw $t9,0x1c8($sp)
@ -752,7 +752,7 @@ glabel mpLoadConfig
/* f19b9c4: 0018c180 */ sll $t8,$t8,0x6
/* f19b9c8: afa201c4 */ sw $v0,0x1c4($sp)
/* f19b9cc: 24060140 */ addiu $a2,$zero,0x140
/* f19b9d0: 0c003522 */ jal func0000d488
/* f19b9d0: 0c003522 */ jal dmaExecWithAutoAlign
/* f19b9d4: 00782821 */ addu $a1,$v1,$t8
/* f19b9d8: 8fa701c4 */ lw $a3,0x1c4($sp)
/* f19b9dc: 00404825 */ or $t1,$v0,$zero
@ -825,11 +825,11 @@ glabel mpLoadConfig
// };
//
// // Load mpconfigs
// mpconfig = func0000d488(buffer, &_mpconfigsSegmentRomStart[confignum], sizeof(struct mpconfig));
// mpconfig = dmaExecWithAutoAlign(buffer, &_mpconfigsSegmentRomStart[confignum], sizeof(struct mpconfig));
//
// // Load mpstrings
// bank = banks[language_id][0];
// loadedstrings = func0000d488(buffer2, &bank[confignum], sizeof(struct mpstrings));
// loadedstrings = dmaExecWithAutoAlign(buffer2, &bank[confignum], sizeof(struct mpstrings));
//
// mpconfig->strings = *loadedstrings;
//

View File

@ -439,7 +439,7 @@ void *frLoadRomData(u32 len)
g_FrRomData = malloc(ALIGN16(len), MEMPOOL_STAGE);
if (g_FrRomData) {
return func0000d488(g_FrRomData, &_firingrangeSegmentRomStart, len);
return dmaExecWithAutoAlign(g_FrRomData, (u32)&_firingrangeSegmentRomStart, len);
}
return NULL;

View File

@ -14,6 +14,7 @@
#define U32_MAX 4294967295
#define ABS(val) ((val) > 0 ? (val) : -(val))
#define ALIGN2(val) (((val) | 1) ^ 0x1)
#define ALIGN8(val) (((val) + 0x7 | 0x7) ^ 0x7)
#define ALIGN16(val) (((val) + 0xf | 0xf) ^ 0xf)
#define ALIGN64(val) ((((u32)val) + 0x3f | 0x3f) ^ 0x3f)

View File

@ -11,6 +11,6 @@ void dmaCheckPiracy(void *memaddr, u32 len);
void dmaWait(void);
void dmaExec(void *memaddr, void *romaddr, u32 len);
void dmaExecHighPriority(void *memaddr, void *romaddr, u32 len);
void *func0000d488(void *memaddr, void *romaddr, u32 len);
void *dmaExecWithAutoAlign(void *memaddr, u32 romaddr, u32 len);
#endif

View File

@ -142,46 +142,33 @@ void dmaExecHighPriority(void *memaddr, void *romaddr, u32 len)
dmaCheckPiracy(memaddr, len);
}
GLOBAL_ASM(
glabel func0000d488
/* d488: 27bdffd0 */ addiu $sp,$sp,-48
/* d48c: afbf0014 */ sw $ra,0x14($sp)
/* d490: afa40030 */ sw $a0,0x30($sp)
/* d494: afa60038 */ sw $a2,0x38($sp)
/* d498: 14c00009 */ bnez $a2,.L0000d4c0
/* d49c: 00a03825 */ or $a3,$a1,$zero
/* d4a0: 2498000f */ addiu $t8,$a0,0xf
/* d4a4: 34a90001 */ ori $t1,$a1,0x1
/* d4a8: 392a0001 */ xori $t2,$t1,0x1
/* d4ac: 3719000f */ ori $t9,$t8,0xf
/* d4b0: 3b28000f */ xori $t0,$t9,0xf
/* d4b4: 00aa5823 */ subu $t3,$a1,$t2
/* d4b8: 10000014 */ b .L0000d50c
/* d4bc: 010b1021 */ addu $v0,$t0,$t3
.L0000d4c0:
/* d4c0: 8fa40030 */ lw $a0,0x30($sp)
/* d4c4: 8faf0038 */ lw $t7,0x38($sp)
/* d4c8: 34e50001 */ ori $a1,$a3,0x1
/* d4cc: 38ae0001 */ xori $t6,$a1,0x1
/* d4d0: 00ee1823 */ subu $v1,$a3,$t6
/* d4d4: 2484000f */ addiu $a0,$a0,0xf
/* d4d8: 006f3021 */ addu $a2,$v1,$t7
/* d4dc: 24c6000f */ addiu $a2,$a2,0xf
/* d4e0: 348c000f */ ori $t4,$a0,0xf
/* d4e4: 3984000f */ xori $a0,$t4,0xf
/* d4e8: 34d8000f */ ori $t8,$a2,0xf
/* d4ec: 3b06000f */ xori $a2,$t8,0xf
/* d4f0: afa4001c */ sw $a0,0x1c($sp)
/* d4f4: afa30018 */ sw $v1,0x18($sp)
/* d4f8: 0c003504 */ jal dmaExec
/* d4fc: 01c02825 */ or $a1,$t6,$zero
/* d500: 8fa30018 */ lw $v1,0x18($sp)
/* d504: 8fa4001c */ lw $a0,0x1c($sp)
/* d508: 00831021 */ addu $v0,$a0,$v1
.L0000d50c:
/* d50c: 8fbf0014 */ lw $ra,0x14($sp)
/* d510: 27bd0030 */ addiu $sp,$sp,0x30
/* d514: 03e00008 */ jr $ra
/* d518: 00000000 */ nop
/* d51c: 00000000 */ nop
);
/**
* DMA data from ROM to RAM with automatic alignment.
*
* The destination memory address is aligned to 0x10.
*
* The ROM address is aligned to 2 bytes (ie. subtract 1 if ROM address is odd).
* If this is done then the returned memory pointer is bumped forwards by one
* to compensate. The length of data to be transferred is also increased by one
* to make it 2-byte aligned.
*
* It is assumed that the passed len is 2-byte aligned (ie. an even number).
*
* If a length of zero is passed, no DMA is done. This can be used to retrieve
* the memory address that would have been returned.
*/
void *dmaExecWithAutoAlign(void *memaddr, u32 romaddr, u32 len)
{
u32 alignedrom = ALIGN2(romaddr);
u32 alignedmem = ALIGN16((u32)memaddr);
u32 offset = romaddr - alignedrom; // 0 or 1
u32 alignedlen = ALIGN16(offset + len);
if (len == 0) {
return (void *)(alignedmem + offset);
}
dmaExec((void *)alignedmem, (void *)alignedrom, alignedlen);
return (void *)(alignedmem + offset);
}

View File

@ -332,7 +332,7 @@ glabel func000237e8
/* 23828: 3c08001a */ lui $t0,0x1a
/* 2382c: 250815c0 */ addiu $t0,$t0,0x15c0
/* 23830: 00e02025 */ or $a0,$a3,$zero
/* 23834: 0c003522 */ jal func0000d488
/* 23834: 0c003522 */ jal dmaExecWithAutoAlign
/* 23838: 03282821 */ addu $a1,$t9,$t0
.L0002383c:
/* 2383c: 8fbf0014 */ lw $ra,0x14($sp)