Clean-up PixTone.cpp some more

This commit is contained in:
Clownacy 2019-11-21 19:50:20 +00:00
parent 4154b8c1bd
commit 16b9f1f0a4

View file

@ -15,8 +15,10 @@ void MakeWaveTables(void)
// Sine wave // Sine wave
for (i = 0; i < 0x100; ++i) for (i = 0; i < 0x100; ++i)
{ {
gWaveModelTable[0][i] = (signed char)(sin(i * 6.283184 / 256.0) * 64.0); int unknown;
a = gWaveModelTable[0][i];
gWaveModelTable[0][i] = (signed char)(sin((i * 6.283184) / 256.0) * 64.0);
unknown = gWaveModelTable[0][i]; // I have no idea what this line was meant to do
} }
// Triangle wave // Triangle wave
@ -29,23 +31,23 @@ void MakeWaveTables(void)
for (a = 0; i < 0xC0; ++i) for (a = 0; i < 0xC0; ++i)
{ {
// Downwards // Downwards
gWaveModelTable[1][i] = 0x40 - (a * 0x40) / 0x40; gWaveModelTable[1][i] = 0x40 - ((a * 0x40) / 0x40);
++a; ++a;
} }
for (a = 0; i < 0x100; ++i) for (a = 0; i < 0x100; ++i)
{ {
// Back up // Back up
gWaveModelTable[1][i] = (a * 0x40) / 0x40 - 0x40; gWaveModelTable[1][i] = ((a * 0x40) / 0x40) - 0x40;
++a; ++a;
} }
// Saw up wave // Saw up wave
for (i = 0; i < 0x100; ++i) for (i = 0; i < 0x100; ++i)
gWaveModelTable[2][i] = i / 2 - 0x40; gWaveModelTable[2][i] = (i / 2) - 0x40;
// Saw down wave // Saw down wave
for (i = 0; i < 0x100; ++i) for (i = 0; i < 0x100; ++i)
gWaveModelTable[3][i] = 0x40 - i / 2; gWaveModelTable[3][i] = 0x40 - (i / 2);
// Square wave // Square wave
for (i = 0; i < 0x80; ++i) for (i = 0; i < 0x80; ++i)
@ -86,7 +88,7 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
while (i < ptp->pointAx) while (i < ptp->pointAx)
{ {
envelopeTable[i] = (signed char)dEnvelope; envelopeTable[i] = (signed char)dEnvelope;
dEnvelope = ((double)ptp->pointAy - ptp->initial) / ptp->pointAx + dEnvelope; dEnvelope = (((double)ptp->pointAy - ptp->initial) / ptp->pointAx) + dEnvelope;
++i; ++i;
} }
@ -94,7 +96,7 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
while (i < ptp->pointBx) while (i < ptp->pointBx)
{ {
envelopeTable[i] = (signed char)dEnvelope; envelopeTable[i] = (signed char)dEnvelope;
dEnvelope = ((double)ptp->pointBy - ptp->pointAy) / (double)(ptp->pointBx - ptp->pointAx) + dEnvelope; dEnvelope = (((double)ptp->pointBy - ptp->pointAy) / (double)(ptp->pointBx - ptp->pointAx)) + dEnvelope;
++i; ++i;
} }
@ -110,7 +112,7 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
while (i < 0x100) while (i < 0x100)
{ {
envelopeTable[i] = (signed char)dEnvelope; envelopeTable[i] = (signed char)dEnvelope;
dEnvelope = (double)dEnvelope - ptp->pointCy / (double)(256 - ptp->pointCx); dEnvelope = dEnvelope - (ptp->pointCy / (double)(0x100 - ptp->pointCx));
++i; ++i;
} }
@ -142,7 +144,7 @@ BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
pData[i] = gWaveModelTable[ptp->oMain.model][a] pData[i] = gWaveModelTable[ptp->oMain.model][a]
* ptp->oMain.top * ptp->oMain.top
/ 64 / 64
* (gWaveModelTable[ptp->oVolume.model][c] * ptp->oVolume.top / 64 + 64) * (((gWaveModelTable[ptp->oVolume.model][c] * ptp->oVolume.top) / 64) + 64)
/ 64 / 64
* envelopeTable[d] * envelopeTable[d]
/ 64 / 64