From 035bfbaa5a7b27126a0d840f5cd77cd670761543 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 7 Nov 2021 22:14:30 +1000 Subject: [PATCH] Decompile func00045ed0 --- Makefile | 1 + src/include/lib/lib_45ed0.h | 2 +- src/include/lib/lib_47d20.h | 4 +- src/lib/lib_45ed0.c | 244 ++++++------------------------------ 4 files changed, 43 insertions(+), 208 deletions(-) diff --git a/Makefile b/Makefile index 5c2eccfe7..1db9cb8f3 100644 --- a/Makefile +++ b/Makefile @@ -114,6 +114,7 @@ G_C_FILES := \ src/lib/lib_39c80.c \ src/lib/lib_3a100.c \ src/lib/lib_3e3e0.c \ + src/lib/lib_45ed0.c \ src/lib/mp3.c \ src/lib/speaker.c diff --git a/src/include/lib/lib_45ed0.h b/src/include/lib/lib_45ed0.h index b64f019bd..5981af429 100644 --- a/src/include/lib/lib_45ed0.h +++ b/src/include/lib/lib_45ed0.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -u32 func00045ed0(void); +f32 func00045ed0(f32 arg0, f32 arg1); #endif diff --git a/src/include/lib/lib_47d20.h b/src/include/lib/lib_47d20.h index 9f8e5d106..9a0adc825 100644 --- a/src/include/lib/lib_47d20.h +++ b/src/include/lib/lib_47d20.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -u32 func00047d20(void); -u32 func00047ef0(void); +f32 func00047d20(f32 arg0); +f32 func00047ef0(f32 arg0); #endif diff --git a/src/lib/lib_45ed0.c b/src/lib/lib_45ed0.c index 88a816273..a1043ce1e 100644 --- a/src/lib/lib_45ed0.c +++ b/src/lib/lib_45ed0.c @@ -5,208 +5,42 @@ #include "data.h" #include "types.h" -GLOBAL_ASM( -glabel func00045ed0 -/* 45ed0: 27bdffc8 */ addiu $sp,$sp,-56 -/* 45ed4: afbf0024 */ sw $ra,0x24($sp) -/* 45ed8: e7ac0038 */ swc1 $f12,0x38($sp) -/* 45edc: e7ae003c */ swc1 $f14,0x3c($sp) -/* 45ee0: afb00020 */ sw $s0,0x20($sp) -/* 45ee4: f7b40018 */ sdc1 $f20,0x18($sp) -/* 45ee8: c7a4003c */ lwc1 $f4,0x3c($sp) -/* 45eec: 4600218d */ trunc.w.s $f6,$f4 -/* 45ef0: 440f3000 */ mfc1 $t7,$f6 -/* 45ef4: 00000000 */ nop -/* 45ef8: afaf0034 */ sw $t7,0x34($sp) -/* 45efc: c7a80038 */ lwc1 $f8,0x38($sp) -/* 45f00: 44805000 */ mtc1 $zero,$f10 -/* 45f04: 00000000 */ nop -/* 45f08: 460a4032 */ c.eq.s $f8,$f10 -/* 45f0c: 00000000 */ nop -/* 45f10: 4501000c */ bc1t .L00045f44 -/* 45f14: 00000000 */ nop -/* 45f18: c7b0003c */ lwc1 $f16,0x3c($sp) -/* 45f1c: 44809000 */ mtc1 $zero,$f18 -/* 45f20: 00000000 */ nop -/* 45f24: 46128032 */ c.eq.s $f16,$f18 -/* 45f28: 00000000 */ nop -/* 45f2c: 45000005 */ bc1f .L00045f44 -/* 45f30: 00000000 */ nop -/* 45f34: 3c013f80 */ lui $at,0x3f80 -/* 45f38: 44810000 */ mtc1 $at,$f0 -/* 45f3c: 10000098 */ b .L000461a0 -/* 45f40: 00000000 */ nop -.L00045f44: -/* 45f44: c7a40038 */ lwc1 $f4,0x38($sp) -/* 45f48: 44803000 */ mtc1 $zero,$f6 -/* 45f4c: 00000000 */ nop -/* 45f50: 46062032 */ c.eq.s $f4,$f6 -/* 45f54: 00000000 */ nop -/* 45f58: 45000004 */ bc1f .L00045f6c -/* 45f5c: 00000000 */ nop -/* 45f60: 44800000 */ mtc1 $zero,$f0 -/* 45f64: 1000008e */ b .L000461a0 -/* 45f68: 00000000 */ nop -.L00045f6c: -/* 45f6c: c7a80038 */ lwc1 $f8,0x38($sp) -/* 45f70: 44805000 */ mtc1 $zero,$f10 -/* 45f74: 00000000 */ nop -/* 45f78: 460a4032 */ c.eq.s $f8,$f10 -/* 45f7c: 00000000 */ nop -/* 45f80: 45000008 */ bc1f .L00045fa4 -/* 45f84: 00000000 */ nop -/* 45f88: c7b0003c */ lwc1 $f16,0x3c($sp) -/* 45f8c: 44809000 */ mtc1 $zero,$f18 -/* 45f90: 00000000 */ nop -/* 45f94: 46128032 */ c.eq.s $f16,$f18 -/* 45f98: 00000000 */ nop -/* 45f9c: 45010011 */ bc1t .L00045fe4 -/* 45fa0: 00000000 */ nop -.L00045fa4: -/* 45fa4: c7a40038 */ lwc1 $f4,0x38($sp) -/* 45fa8: 44803000 */ mtc1 $zero,$f6 -/* 45fac: 00000000 */ nop -/* 45fb0: 4606203c */ c.lt.s $f4,$f6 -/* 45fb4: 00000000 */ nop -/* 45fb8: 4500000d */ bc1f .L00045ff0 -/* 45fbc: 00000000 */ nop -/* 45fc0: 8fb80034 */ lw $t8,0x34($sp) -/* 45fc4: c7b0003c */ lwc1 $f16,0x3c($sp) -/* 45fc8: 44984000 */ mtc1 $t8,$f8 -/* 45fcc: 00000000 */ nop -/* 45fd0: 468042a0 */ cvt.s.w $f10,$f8 -/* 45fd4: 46105032 */ c.eq.s $f10,$f16 -/* 45fd8: 00000000 */ nop -/* 45fdc: 45010004 */ bc1t .L00045ff0 -/* 45fe0: 00000000 */ nop -.L00045fe4: -/* 45fe4: 44800000 */ mtc1 $zero,$f0 -/* 45fe8: 1000006d */ b .L000461a0 -/* 45fec: 00000000 */ nop -.L00045ff0: -/* 45ff0: 8fb90034 */ lw $t9,0x34($sp) -/* 45ff4: c7a6003c */ lwc1 $f6,0x3c($sp) -/* 45ff8: 44999000 */ mtc1 $t9,$f18 -/* 45ffc: 00000000 */ nop -/* 46000: 46809120 */ cvt.s.w $f4,$f18 -/* 46004: 46062032 */ c.eq.s $f4,$f6 -/* 46008: 00000000 */ nop -/* 4600c: 4501000a */ bc1t .L00046038 -/* 46010: 00000000 */ nop -/* 46014: 0c011fbc */ jal func00047ef0 -/* 46018: c7ac0038 */ lwc1 $f12,0x38($sp) -/* 4601c: c7a8003c */ lwc1 $f8,0x3c($sp) -/* 46020: 46000506 */ mov.s $f20,$f0 -/* 46024: 4608a302 */ mul.s $f12,$f20,$f8 -/* 46028: 0c011f48 */ jal func00047d20 -/* 4602c: 00000000 */ nop -/* 46030: 10000057 */ b .L00046190 -/* 46034: e7a00038 */ swc1 $f0,0x38($sp) -.L00046038: -/* 46038: c7aa003c */ lwc1 $f10,0x3c($sp) -/* 4603c: 44808000 */ mtc1 $zero,$f16 -/* 46040: 00000000 */ nop -/* 46044: 460a803c */ c.lt.s $f16,$f10 -/* 46048: 00000000 */ nop -/* 4604c: 4500002a */ bc1f .L000460f8 -/* 46050: 00000000 */ nop -/* 46054: 3c013f80 */ lui $at,0x3f80 -/* 46058: 44812000 */ mtc1 $at,$f4 -/* 4605c: c7b2003c */ lwc1 $f18,0x3c($sp) -/* 46060: 46049181 */ sub.s $f6,$f18,$f4 -/* 46064: e7a6003c */ swc1 $f6,0x3c($sp) -/* 46068: c7a80038 */ lwc1 $f8,0x38($sp) -/* 4606c: e7a80030 */ swc1 $f8,0x30($sp) -/* 46070: c7aa003c */ lwc1 $f10,0x3c($sp) -/* 46074: 44808000 */ mtc1 $zero,$f16 -/* 46078: 00008025 */ or $s0,$zero,$zero -/* 4607c: 46105032 */ c.eq.s $f10,$f16 -/* 46080: 00000000 */ nop -/* 46084: 45010002 */ bc1t .L00046090 -/* 46088: 00000000 */ nop -/* 4608c: 24100001 */ addiu $s0,$zero,0x1 -.L00046090: -/* 46090: 3c013f80 */ lui $at,0x3f80 -/* 46094: 44819000 */ mtc1 $at,$f18 -/* 46098: 00000000 */ nop -/* 4609c: 46125101 */ sub.s $f4,$f10,$f18 -/* 460a0: 12000013 */ beqz $s0,.L000460f0 -/* 460a4: e7a4003c */ swc1 $f4,0x3c($sp) -.L000460a8: -/* 460a8: c7a60038 */ lwc1 $f6,0x38($sp) -/* 460ac: c7a80030 */ lwc1 $f8,0x30($sp) -/* 460b0: 46083402 */ mul.s $f16,$f6,$f8 -/* 460b4: e7b00038 */ swc1 $f16,0x38($sp) -/* 460b8: c7aa003c */ lwc1 $f10,0x3c($sp) -/* 460bc: 44809000 */ mtc1 $zero,$f18 -/* 460c0: 00008025 */ or $s0,$zero,$zero -/* 460c4: 46125032 */ c.eq.s $f10,$f18 -/* 460c8: 00000000 */ nop -/* 460cc: 45010002 */ bc1t .L000460d8 -/* 460d0: 00000000 */ nop -/* 460d4: 24100001 */ addiu $s0,$zero,0x1 -.L000460d8: -/* 460d8: 3c013f80 */ lui $at,0x3f80 -/* 460dc: 44812000 */ mtc1 $at,$f4 -/* 460e0: 00000000 */ nop -/* 460e4: 46045181 */ sub.s $f6,$f10,$f4 -/* 460e8: 1600ffef */ bnez $s0,.L000460a8 -/* 460ec: e7a6003c */ swc1 $f6,0x3c($sp) -.L000460f0: -/* 460f0: 10000027 */ b .L00046190 -/* 460f4: 00000000 */ nop -.L000460f8: -/* 460f8: 3c013f80 */ lui $at,0x3f80 -/* 460fc: 44814000 */ mtc1 $at,$f8 -/* 46100: 00000000 */ nop -/* 46104: e7a80030 */ swc1 $f8,0x30($sp) -/* 46108: c7b0003c */ lwc1 $f16,0x3c($sp) -/* 4610c: 44809000 */ mtc1 $zero,$f18 -/* 46110: 00008025 */ or $s0,$zero,$zero -/* 46114: 46128032 */ c.eq.s $f16,$f18 -/* 46118: 00000000 */ nop -/* 4611c: 45010002 */ bc1t .L00046128 -/* 46120: 00000000 */ nop -/* 46124: 24100001 */ addiu $s0,$zero,0x1 -.L00046128: -/* 46128: 3c013f80 */ lui $at,0x3f80 -/* 4612c: 44815000 */ mtc1 $at,$f10 -/* 46130: 00000000 */ nop -/* 46134: 460a8100 */ add.s $f4,$f16,$f10 -/* 46138: 12000013 */ beqz $s0,.L00046188 -/* 4613c: e7a4003c */ swc1 $f4,0x3c($sp) -.L00046140: -/* 46140: c7a60030 */ lwc1 $f6,0x30($sp) -/* 46144: c7a80038 */ lwc1 $f8,0x38($sp) -/* 46148: 46083483 */ div.s $f18,$f6,$f8 -/* 4614c: e7b20030 */ swc1 $f18,0x30($sp) -/* 46150: c7b0003c */ lwc1 $f16,0x3c($sp) -/* 46154: 44805000 */ mtc1 $zero,$f10 -/* 46158: 00008025 */ or $s0,$zero,$zero -/* 4615c: 460a8032 */ c.eq.s $f16,$f10 -/* 46160: 00000000 */ nop -/* 46164: 45010002 */ bc1t .L00046170 -/* 46168: 00000000 */ nop -/* 4616c: 24100001 */ addiu $s0,$zero,0x1 -.L00046170: -/* 46170: 3c013f80 */ lui $at,0x3f80 -/* 46174: 44812000 */ mtc1 $at,$f4 -/* 46178: 00000000 */ nop -/* 4617c: 46048180 */ add.s $f6,$f16,$f4 -/* 46180: 1600ffef */ bnez $s0,.L00046140 -/* 46184: e7a6003c */ swc1 $f6,0x3c($sp) -.L00046188: -/* 46188: c7a80030 */ lwc1 $f8,0x30($sp) -/* 4618c: e7a80038 */ swc1 $f8,0x38($sp) -.L00046190: -/* 46190: 10000003 */ b .L000461a0 -/* 46194: c7a00038 */ lwc1 $f0,0x38($sp) -/* 46198: 10000001 */ b .L000461a0 -/* 4619c: 00000000 */ nop -.L000461a0: -/* 461a0: 8fbf0024 */ lw $ra,0x24($sp) -/* 461a4: d7b40018 */ ldc1 $f20,0x18($sp) -/* 461a8: 8fb00020 */ lw $s0,0x20($sp) -/* 461ac: 03e00008 */ jr $ra -/* 461b0: 27bd0038 */ addiu $sp,$sp,0x38 -); +f32 func00045ed0(f32 arg0, f32 arg1) +{ + s32 arg1int = arg1; + f32 sp30; + register bool s0; + + if (arg0 != 0 && arg1 == 0) { + return 1; + } + + if (arg0 == 0) { + return 0; + } + + if ((arg0 == 0 && arg1 == 0) || (arg0 < 0 && arg1int != arg1)) { + return 0; + } + + if (arg1int != arg1) { + arg0 = func00047d20(func00047ef0(arg0) * arg1); + } else if (arg1 > 0) { + arg1--; + sp30 = arg0; + + for (s0 = (arg1-- != 0); s0; s0 = (arg1-- != 0)) { + arg0 *= sp30; + } + } else { + sp30 = 1; + + for (s0 = (arg1++ != 0); s0; s0 = (arg1++ != 0)) { + sp30 /= arg0; + } + + arg0 = sp30; + } + + return arg0; +}