From 955ba2f301eb5efa10ef8a72f0af1fa9ce8a6fe7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 31 Mar 2021 12:14:35 +1000 Subject: [PATCH] Decompile sndIsMp3 --- src/game/game_092610.c | 8 ++++---- src/include/lib/snd.h | 2 +- src/include/types.h | 2 +- src/lib/snd.c | 27 +++++++++++---------------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/game/game_092610.c b/src/game/game_092610.c index ebe4f18ff..235e44f44 100644 --- a/src/game/game_092610.c +++ b/src/game/game_092610.c @@ -3395,7 +3395,7 @@ glabel var7f1ab748 .L0f093f60: /* f093f60: 358d1000 */ ori $t5,$t4,0x1000 /* f093f64: a60d0030 */ sh $t5,0x30($s0) -/* f093f68: 0c003ee8 */ jal snd0000fba0 +/* f093f68: 0c003ee8 */ jal sndIsMp3 /* f093f6c: 87a400ba */ lh $a0,0xba($sp) /* f093f70: 10400014 */ beqz $v0,.L0f093fc4 /* f093f74: 00000000 */ nop @@ -3830,7 +3830,7 @@ glabel var7f1a5a9cnb /* f092290: 96180030 */ lhu $t8,0x30($s0) /* f092294: 37191000 */ ori $t9,$t8,0x1000 /* f092298: a6190030 */ sh $t9,0x30($s0) -/* f09229c: 0c00400e */ jal snd0000fba0 +/* f09229c: 0c00400e */ jal sndIsMp3 /* f0922a0: 87a400c2 */ lh $a0,0xc2($sp) /* f0922a4: 10400008 */ beqz $v0,.NB0f0922c8 /* f0922a8: 00000000 */ sll $zero,$zero,0x0 @@ -4072,7 +4072,7 @@ glabel var7f1a5a9cnb // // channel->flags |= AUDIOCHANNELFLAG_1000; // -// if (snd0000fba0(soundnum)) { +// if (sndIsMp3(soundnum)) { // channel->flags |= AUDIOCHANNELFLAG_0010; // // prevpri = osGetThreadPri(0); @@ -5473,7 +5473,7 @@ glabel var7f1ab788 /* f095198: 0fc2535e */ jal func0f094d78 /* f09519c: e7a80010 */ swc1 $f8,0x10($sp) /* f0951a0: 00408025 */ or $s0,$v0,$zero -/* f0951a4: 0c003ee8 */ jal snd0000fba0 +/* f0951a4: 0c003ee8 */ jal sndIsMp3 /* f0951a8: 87a4007a */ lh $a0,0x7a($sp) /* f0951ac: 3c013f80 */ lui $at,0x3f80 /* f0951b0: 44815000 */ mtc1 $at,$f10 diff --git a/src/include/lib/snd.h b/src/include/lib/snd.h index ea1c3460e..6bbf2ead9 100644 --- a/src/include/lib/snd.h +++ b/src/include/lib/snd.h @@ -21,7 +21,7 @@ void sndSetSoundMode(s32 mode); u32 snd0000f49c(void); void snd0000f67c(struct var80094ed8 *arg0); void sndInit(void); -bool snd0000fba0(s32 soundnum); +bool sndIsMp3(u16 soundnum); void snd0000fbc4(s16 arg0); u32 snd0000fc48(void); u32 snd0000fd74(void); diff --git a/src/include/types.h b/src/include/types.h index 5641f2f3d..f1681242f 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3630,7 +3630,7 @@ struct something { }; union soundnumhack { - s16 packed; + u16 packed; struct { u16 isruss : 1; diff --git a/src/lib/snd.c b/src/lib/snd.c index 6b576c055..2a5c2054d 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -1799,7 +1799,7 @@ glabel snd0000f49c /* f4b8: 00047c03 */ sra $t7,$a0,0x10 /* f4bc: 01c08025 */ or $s0,$t6,$zero /* f4c0: afb10018 */ sw $s1,0x18($sp) -/* f4c4: 0c003ee8 */ jal snd0000fba0 +/* f4c4: 0c003ee8 */ jal sndIsMp3 /* f4c8: 01e02025 */ or $a0,$t7,$zero /* f4cc: 10400003 */ beqz $v0,.L0000f4dc /* f4d0: 3c088009 */ lui $t0,%hi(var80095210) @@ -1931,7 +1931,7 @@ glabel snd0000f49c /* f934: 00047c03 */ sra $t7,$a0,0x10 /* f938: 01c08025 */ or $s0,$t6,$zero /* f93c: afb10018 */ sw $s1,0x18($sp) -/* f940: 0c00400e */ jal snd0000fba0 +/* f940: 0c00400e */ jal sndIsMp3 /* f944: 01e02025 */ or $a0,$t7,$zero /* f948: 10400003 */ beqz $v0,.NB0000f958 /* f94c: 3c08800a */ lui $t0,0x800a @@ -2338,18 +2338,13 @@ const char var70053c10[] = "Snd_Play_Mpeg : SYSTEM IS DISABLED\n"; const char var70053c34[] = "Snd_Play_Mpeg : Lib called -> Adr=%x\n"; const char var70053c5c[] = "Snd_Play_Mpeg : Chunk size -> Adr=%x\n"; -GLOBAL_ASM( -glabel snd0000fba0 -/* fba0: 27bdfff8 */ addiu $sp,$sp,-8 -/* fba4: a7a40004 */ sh $a0,0x4($sp) -/* fba8: 8fa20004 */ lw $v0,0x4($sp) -/* fbac: afa40008 */ sw $a0,0x8($sp) -/* fbb0: 27bd0008 */ addiu $sp,$sp,0x8 -/* fbb4: 0002c0c0 */ sll $t8,$v0,0x3 -/* fbb8: 0018cf82 */ srl $t9,$t8,0x1e -/* fbbc: 03e00008 */ jr $ra -/* fbc0: 0019102b */ sltu $v0,$zero,$t9 -); +bool sndIsMp3(u16 soundnum) +{ + union soundnumhack tmp; + tmp.packed = soundnum & 0xffff; + + return tmp.bits3.unk04 != 0; +} GLOBAL_ASM( glabel snd0000fbc4 @@ -4522,7 +4517,7 @@ glabel sndStart /* 10a0c: a3a5003e */ sb $a1,0x3e($sp) /* 10a10: a3a8003d */ sb $t0,0x3d($sp) /* 10a14: a3a9003f */ sb $t1,0x3f($sp) -/* 10a18: 0c003ee8 */ jal snd0000fba0 +/* 10a18: 0c003ee8 */ jal sndIsMp3 /* 10a1c: e7a00034 */ swc1 $f0,0x34($sp) /* 10a20: 8fa3002c */ lw $v1,0x2c($sp) /* 10a24: 87a40040 */ lh $a0,0x40($sp) @@ -4663,7 +4658,7 @@ glabel sndStart /* 10de8: a3a5003e */ sb $a1,0x3e($sp) /* 10dec: a3a8003d */ sb $t0,0x3d($sp) /* 10df0: a3a9003f */ sb $t1,0x3f($sp) -/* 10df4: 0c00400e */ jal snd0000fba0 +/* 10df4: 0c00400e */ jal sndIsMp3 /* 10df8: e7a00034 */ swc1 $f0,0x34($sp) /* 10dfc: 8fa3002c */ lw $v1,0x2c($sp) /* 10e00: 87a40040 */ lh $a0,0x40($sp)