diff --git a/src/include/PR/synthInternals.h b/src/include/PR/synthInternals.h index 6e73f4c1f..8b12c11a8 100755 --- a/src/include/PR/synthInternals.h +++ b/src/include/PR/synthInternals.h @@ -329,7 +329,7 @@ void __freeParam(ALParam *param); void _freePVoice(PVoice *pvoice); void _collectPVoices(void); -s32 _timeToSamples(ALSynth *ALSynth, s32 micros); +s32 _timeToSamples(s32 micros); ALMicroTime _samplesToTime(ALSynth *synth, s32 samples); #endif diff --git a/src/include/lib/lib_30ce0.h b/src/include/lib/lib_30ce0.h index b60af9f5f..9d4c32532 100644 --- a/src/include/lib/lib_30ce0.h +++ b/src/include/lib/lib_30ce0.h @@ -5,6 +5,5 @@ #include "types.h" u32 func00030ce0(void); -u32 func00031698(void); #endif diff --git a/src/lib/lib_30ce0.c b/src/lib/lib_30ce0.c index 1f83a4c50..8aac00377 100644 --- a/src/lib/lib_30ce0.c +++ b/src/lib/lib_30ce0.c @@ -529,7 +529,7 @@ s32 _timeToSamplesNoRound(s32 micros) } GLOBAL_ASM( -glabel func00031698 +glabel _timeToSamples /* 31698: 27bdffe8 */ addiu $sp,$sp,-24 /* 3169c: afbf0014 */ sw $ra,0x14($sp) /* 316a0: afa40018 */ sw $a0,0x18($sp) @@ -547,53 +547,22 @@ glabel func00031698 /* 316cc: 00000000 */ nop ); -GLOBAL_ASM( -glabel __nextSampleTime -/* 316d0: 27bdfff8 */ addiu $sp,$sp,-8 -/* 316d4: 3c0e7fff */ lui $t6,0x7fff -/* 316d8: 35ceffff */ ori $t6,$t6,0xffff -/* 316dc: afae0004 */ sw $t6,0x4($sp) -/* 316e0: ac800000 */ sw $zero,0x0($a0) -/* 316e4: 3c0f8006 */ lui $t7,%hi(alGlobals) -/* 316e8: 8deff114 */ lw $t7,%lo(alGlobals)($t7) -/* 316ec: 8df80000 */ lw $t8,0x0($t7) -/* 316f0: 13000018 */ beqz $t8,.L00031754 -/* 316f4: afb80000 */ sw $t8,0x0($sp) -.L000316f8: -/* 316f8: 3c098006 */ lui $t1,%hi(alGlobals) -/* 316fc: 8d29f114 */ lw $t1,%lo(alGlobals)($t1) -/* 31700: 8fb90000 */ lw $t9,0x0($sp) -/* 31704: 8fac0004 */ lw $t4,0x4($sp) -/* 31708: 8d2a0020 */ lw $t2,0x20($t1) -/* 3170c: 8f280010 */ lw $t0,0x10($t9) -/* 31710: 010a5823 */ subu $t3,$t0,$t2 -/* 31714: 016c082a */ slt $at,$t3,$t4 -/* 31718: 1020000a */ beqz $at,.L00031744 -/* 3171c: 00000000 */ nop -/* 31720: 8fad0000 */ lw $t5,0x0($sp) -/* 31724: ac8d0000 */ sw $t5,0x0($a0) -/* 31728: 3c188006 */ lui $t8,%hi(alGlobals) -/* 3172c: 8f18f114 */ lw $t8,%lo(alGlobals)($t8) -/* 31730: 8fae0000 */ lw $t6,0x0($sp) -/* 31734: 8f190020 */ lw $t9,0x20($t8) -/* 31738: 8dcf0010 */ lw $t7,0x10($t6) -/* 3173c: 01f94823 */ subu $t1,$t7,$t9 -/* 31740: afa90004 */ sw $t1,0x4($sp) -.L00031744: -/* 31744: 8fa80000 */ lw $t0,0x0($sp) -/* 31748: 8d0a0000 */ lw $t2,0x0($t0) -/* 3174c: 1540ffea */ bnez $t2,.L000316f8 -/* 31750: afaa0000 */ sw $t2,0x0($sp) -.L00031754: -/* 31754: 8c8b0000 */ lw $t3,0x0($a0) -/* 31758: 10000003 */ b .L00031768 -/* 3175c: 8d620010 */ lw $v0,0x10($t3) -/* 31760: 10000001 */ b .L00031768 -/* 31764: 00000000 */ nop -.L00031768: -/* 31768: 03e00008 */ jr $ra -/* 3176c: 27bd0008 */ addiu $sp,$sp,0x8 -); +s32 __nextSampleTime(ALPlayer **client) +{ + ALMicroTime delta = 0x7fffffff; /* max delta for s32 */ + ALPlayer *cl; + + *client = 0; + + for (cl = alGlobals->drvr.head; cl != 0; cl = cl->next) { + if ((cl->samplesLeft - alGlobals->drvr.curSamples) < delta) { + *client = cl; + delta = cl->samplesLeft - alGlobals->drvr.curSamples; + } + } + + return (*client)->samplesLeft; +} void alLink(ALLink *ln, ALLink *to) { diff --git a/src/lib/lib_3ccf0.c b/src/lib/lib_3ccf0.c index c26363070..cef2bec97 100644 --- a/src/lib/lib_3ccf0.c +++ b/src/lib/lib_3ccf0.c @@ -41,7 +41,7 @@ glabel alSynSetVol /* 3cd64: 87b80026 */ lh $t8,0x26($sp) /* 3cd68: 8fb9001c */ lw $t9,0x1c($sp) /* 3cd6c: af38000c */ sw $t8,0xc($t9) -/* 3cd70: 0c00c5a6 */ jal func00031698 +/* 3cd70: 0c00c5a6 */ jal _timeToSamples /* 3cd74: 8fa40028 */ lw $a0,0x28($sp) /* 3cd78: 8fa9001c */ lw $t1,0x1c($sp) /* 3cd7c: ad220010 */ sw $v0,0x10($t1) diff --git a/src/lib/lib_3cdc0.c b/src/lib/lib_3cdc0.c index b955e0e21..62be38ff4 100644 --- a/src/lib/lib_3cdc0.c +++ b/src/lib/lib_3cdc0.c @@ -66,7 +66,7 @@ glabel func0003cdc0 /* 3ce98: c7a6003c */ lwc1 $f6,0x3c($sp) /* 3ce9c: 8fab001c */ lw $t3,0x1c($sp) /* 3cea0: e5660018 */ swc1 $f6,0x18($t3) -/* 3cea4: 0c00c5a6 */ jal func00031698 +/* 3cea4: 0c00c5a6 */ jal _timeToSamples /* 3cea8: 8fa40044 */ lw $a0,0x44($sp) /* 3ceac: 8fac001c */ lw $t4,0x1c($sp) /* 3ceb0: ad82001c */ sw $v0,0x1c($t4)