Skip to content

Commit 46f22e9

Browse files
author
Niko
committed
audio reduced logic optimization
1 parent ba6c63d commit 46f22e9

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

decompile/General/CDSYS/CDSYS_07_SpuCallbackIRQ.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ half.
1717
// from TOMB5
1818
// https://github.com/TOMB5/TOMB5/blob/master/EMULATOR/LIBSPU.H
1919
#define SPU_CDONLY 5
20-
SpuReadDecodedData(&sdata->SpuDecodedData[0], SPU_CDONLY);
20+
SpuReadDecodedData(&sdata->SpuReadbackDst[0], SPU_CDONLY);
2121

2222
if(
2323
(sdata->XA_boolFinished == 0) &&

decompile/General/CDSYS/CDSYS_08_SpuCallbackTransfer.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
void DECOMP_CDSYS_SpuCallbackTransfer()
44
{
5-
if (sdata->irqAddr == 0)
6-
sdata->irqAddr = 0x200;
5+
// 0->1, and 1->0
6+
sdata->irqAddr = sdata->irqAddr + 1;
7+
sdata->irqAddr = sdata->irqAddr & 2;
78

8-
else
9-
sdata->irqAddr = 0;
10-
11-
SpuSetIRQAddr(sdata->irqAddr);
9+
SpuSetIRQAddr(sdata->irqAddr << 9);
1210
SpuSetIRQ(1);
1311

1412
#if 0 // unused

decompile/General/CDSYS/CDSYS_09_SpuEnableIRQ.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ void DECOMP_CDSYS_SpuEnableIRQ()
44
{
55
for(int i = 0; i < 0x100; i++)
66
{
7-
sdata->SpuDecodedData[i] = 0;
7+
sdata->SpuReadbackDst[i] = 0;
88
}
99

1010
SpuSetTransferMode(SPU_TRANSFER_BY_DMA);
1111
SpuSetTransferCallback(DECOMP_CDSYS_SpuCallbackTransfer);
1212
SpuSetIRQCallback(DECOMP_CDSYS_SpuCallbackIRQ);
1313

14-
sdata->irqAddr = 0x200;
15-
SpuSetIRQAddr(0x200);
14+
sdata->irqAddr = 1;
15+
SpuSetIRQAddr(sdata->irqAddr << 9);
1616
SpuSetIRQ(1);
1717
}

decompile/General/CDSYS/CDSYS_11_SpuGetMaxSample.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,19 @@ void DECOMP_CDSYS_SpuGetMaxSample(void)
1212
// if you are not using CD, quit
1313
if (sdata->boolUseDisc == false) return;
1414

15-
// irqAddr = 0, index = {0x000 - 0x100}, byteRange = {0x000 - 0x200},
16-
// irqAddr = 1, index = {0x100 - 0x200}, byteRange = {0x200 - 0x400},
17-
1815
// this irqAddr value changes in CDSYS_SpuCallbackTransfer,
1916
// meaning this might always be 1 frame behind, even in retail CTR
2017

21-
if (sdata->irqAddr == 0)
22-
{
23-
currIndex = 0;
24-
endIndex = 0x100;
25-
}
26-
27-
else
28-
{
29-
currIndex = 0x100;
30-
endIndex = 0x200;
31-
}
18+
// loop through 0x100 short's is 0x200 bytes
19+
short* arrSpuReadbackDst =
20+
&sdata->SpuReadbackDst[sdata->irqAddr << 9];
3221

3322
// loop through region
34-
for (max = 0; currIndex < endIndex; currIndex++)
23+
max = 0;
24+
for (int i = 0; i < 0x100; i++)
3525
{
3626
// absolute value
37-
sample = sdata->SpuDecodedData[currIndex];
27+
sample = arrSpuReadbackDst[i];
3828
if (sample < 0) sample = -sample;
3929

4030
// find max

include/regionsEXE.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4508,9 +4508,9 @@ struct sData
45084508
// 80091198 -- JpnRetail
45094509
// see FUN_8001c8e4
45104510
#if BUILD == SepReview
4511-
short SpuDecodedData[0x800];
4511+
char SpuReadbackDst[0x1000];
45124512
#elif BUILD >= UsaRetail
4513-
short SpuDecodedData[0x400];
4513+
char SpuReadbackDst[0x800];
45144514
#endif
45154515

45164516
// 8008E528

0 commit comments

Comments
 (0)