Decompile __osContAddressCrc

This commit is contained in:
Ryan Dwyer 2021-03-17 19:45:08 +10:00
parent d13495c417
commit 79a824e0f3
5 changed files with 60 additions and 68 deletions

View File

@ -4,7 +4,7 @@
#include "data.h"
#include "types.h"
u32 func00051d50(void);
u32 __osContAddressCrc(void);
u32 func00051e20(void);
#endif

View File

@ -707,7 +707,7 @@ glabel func0004f748
/* 4f778: a3a80028 */ sb $t0,0x28($sp)
/* 4f77c: afa60050 */ sw $a2,0x50($sp)
/* 4f780: 24040600 */ addiu $a0,$zero,0x600
/* 4f784: 0c014754 */ jal func00051d50
/* 4f784: 0c014754 */ jal __osContAddressCrc
/* 4f788: afa5004c */ sw $a1,0x4c($sp)
/* 4f78c: 8fa60050 */ lw $a2,0x50($sp)
/* 4f790: 3449c000 */ ori $t1,$v0,0xc000

View File

@ -4,70 +4,62 @@
#include "data.h"
#include "types.h"
GLOBAL_ASM(
glabel func00051d50
/* 51d50: afa40000 */ sw $a0,0x0($sp)
/* 51d54: 308effff */ andi $t6,$a0,0xffff
/* 51d58: 01c02025 */ or $a0,$t6,$zero
/* 51d5c: 00001825 */ or $v1,$zero,$zero
/* 51d60: 24020400 */ addiu $v0,$zero,0x400
.L00051d64:
/* 51d64: 00037840 */ sll $t7,$v1,0x1
/* 51d68: 0082c024 */ and $t8,$a0,$v0
/* 51d6c: 13000008 */ beqz $t8,.L00051d90
/* 51d70: 01e01825 */ or $v1,$t7,$zero
/* 51d74: 31f90020 */ andi $t9,$t7,0x20
/* 51d78: 13200003 */ beqz $t9,.L00051d88
/* 51d7c: 00000000 */ nop
/* 51d80: 10000007 */ b .L00051da0
/* 51d84: 39e30014 */ xori $v1,$t7,0x14
.L00051d88:
/* 51d88: 10000005 */ b .L00051da0
/* 51d8c: 24630001 */ addiu $v1,$v1,0x1
.L00051d90:
/* 51d90: 30690020 */ andi $t1,$v1,0x20
/* 51d94: 11200002 */ beqz $t1,.L00051da0
/* 51d98: 386a0015 */ xori $t2,$v1,0x15
/* 51d9c: 01401825 */ or $v1,$t2,$zero
.L00051da0:
/* 51da0: 00025842 */ srl $t3,$v0,0x1
/* 51da4: 1560ffef */ bnez $t3,.L00051d64
/* 51da8: 01601025 */ or $v0,$t3,$zero
/* 51dac: 00036040 */ sll $t4,$v1,0x1
/* 51db0: 318d0020 */ andi $t5,$t4,0x20
/* 51db4: 11a00002 */ beqz $t5,.L00051dc0
/* 51db8: 01801825 */ or $v1,$t4,$zero
/* 51dbc: 39830015 */ xori $v1,$t4,0x15
.L00051dc0:
/* 51dc0: 00037840 */ sll $t7,$v1,0x1
/* 51dc4: 31f80020 */ andi $t8,$t7,0x20
/* 51dc8: 13000002 */ beqz $t8,.L00051dd4
/* 51dcc: 01e01825 */ or $v1,$t7,$zero
/* 51dd0: 39e30015 */ xori $v1,$t7,0x15
.L00051dd4:
/* 51dd4: 00034040 */ sll $t0,$v1,0x1
/* 51dd8: 31090020 */ andi $t1,$t0,0x20
/* 51ddc: 11200002 */ beqz $t1,.L00051de8
/* 51de0: 01001825 */ or $v1,$t0,$zero
/* 51de4: 39030015 */ xori $v1,$t0,0x15
.L00051de8:
/* 51de8: 00035840 */ sll $t3,$v1,0x1
/* 51dec: 316c0020 */ andi $t4,$t3,0x20
/* 51df0: 11800002 */ beqz $t4,.L00051dfc
/* 51df4: 01601825 */ or $v1,$t3,$zero
/* 51df8: 39630015 */ xori $v1,$t3,0x15
.L00051dfc:
/* 51dfc: 00037040 */ sll $t6,$v1,0x1
/* 51e00: 31cf0020 */ andi $t7,$t6,0x20
/* 51e04: 11e00002 */ beqz $t7,.L00051e10
/* 51e08: 01c01825 */ or $v1,$t6,$zero
/* 51e0c: 39c30015 */ xori $v1,$t6,0x15
.L00051e10:
/* 51e10: 00601025 */ or $v0,$v1,$zero
/* 51e14: 3059001f */ andi $t9,$v0,0x1f
/* 51e18: 03e00008 */ jr $ra
/* 51e1c: 03201025 */ or $v0,$t9,$zero
);
u8 __osContAddressCrc(u16 inaddr)
{
u32 crc;
u32 mask;
u32 addr = inaddr;
crc = 0;
for (mask = 0x400; mask != 0; mask >>= 1) {
crc *= 2;
if (addr & mask) {
if (crc & 0x20) {
crc ^= 20;
} else {
crc++;
}
} else {
if (crc & 0x20) {
crc ^= 21;
}
}
}
crc <<= 1;
if (crc & 0x20) {
crc ^= 21;
}
crc <<= 1;
if (crc & 0x20) {
crc ^= 21;
}
crc <<= 1;
if (crc & 0x20) {
crc ^= 21;
}
crc <<= 1;
if (crc & 0x20) {
crc ^= 21;
}
crc <<= 1;
if (crc & 0x20) {
crc ^= 21;
}
return crc & 0x1f;
}
GLOBAL_ASM(
glabel func00051e20

View File

@ -85,7 +85,7 @@ glabel __osContRamRead
.L0004b97c:
/* 4b97c: 8fb80044 */ lw $t8,0x44($sp)
/* 4b980: 30a4ffff */ andi $a0,$a1,0xffff
/* 4b984: 0c014754 */ jal func00051d50
/* 4b984: 0c014754 */ jal __osContAddressCrc
/* 4b988: a2180004 */ sb $t8,0x4($s0)
/* 4b98c: 8fb90040 */ lw $t9,0x40($sp)
/* 4b990: 24040001 */ addiu $a0,$zero,0x1

View File

@ -96,7 +96,7 @@ glabel __osContRamWrite
.L0004b75c:
/* 4b75c: 8fb80044 */ lw $t8,0x44($sp)
/* 4b760: a2180004 */ sb $t8,0x4($s0)
/* 4b764: 0c014754 */ jal func00051d50
/* 4b764: 0c014754 */ jal __osContAddressCrc
/* 4b768: 97a40072 */ lhu $a0,0x72($sp)
/* 4b76c: 8fb90040 */ lw $t9,0x40($sp)
/* 4b770: 26050006 */ addiu $a1,$s0,0x6