mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 19:20:38 +00:00
xa.cpp: Tabs to spaces.
git-svn-id: https://svn.eduke32.com/eduke32@6764 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6acbb77ac5
commit
607ddc45e0
1 changed files with 144 additions and 146 deletions
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#define kNumOfSamples 224
|
#define kNumOfSamples 224
|
||||||
#define kNumOfSGs 18
|
#define kNumOfSGs 18
|
||||||
#define TTYWidth 80
|
#define TTYWidth 80
|
||||||
|
|
||||||
/* ADPCM */
|
/* ADPCM */
|
||||||
#define XA_DATA_START (0x44-48)
|
#define XA_DATA_START (0x44-48)
|
||||||
|
@ -50,35 +50,35 @@ typedef struct {
|
||||||
typedef int8_t SoundGroup[128];
|
typedef int8_t SoundGroup[128];
|
||||||
|
|
||||||
typedef struct XASector {
|
typedef struct XASector {
|
||||||
int8_t sectorFiller[48];
|
int8_t sectorFiller[48];
|
||||||
SoundGroup SoundGroups[18];
|
SoundGroup SoundGroups[18];
|
||||||
} XASector;
|
} XASector;
|
||||||
|
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
static int32_t K0[4] = {
|
static int32_t K0[4] = {
|
||||||
0x00000000,
|
0x00000000,
|
||||||
0x0000F000,
|
0x0000F000,
|
||||||
0x0001CC00,
|
0x0001CC00,
|
||||||
0x00018800,
|
0x00018800,
|
||||||
};
|
};
|
||||||
static int32_t K1[4] = {
|
static int32_t K1[4] = {
|
||||||
0x00000000,
|
0x00000000,
|
||||||
0x00000000,
|
0x00000000,
|
||||||
(int32_t)0xFFFF3000u,
|
(int32_t)0xFFFF3000u,
|
||||||
(int32_t)0xFFFF2400u,
|
(int32_t)0xFFFF2400u,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
static double K0[4] = {
|
static double K0[4] = {
|
||||||
0.0,
|
0.0,
|
||||||
0.9375,
|
0.9375,
|
||||||
1.796875,
|
1.796875,
|
||||||
1.53125
|
1.53125
|
||||||
};
|
};
|
||||||
static double K1[4] = {
|
static double K1[4] = {
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
-0.8125,
|
-0.8125,
|
||||||
-0.859375
|
-0.859375
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -86,24 +86,24 @@ static double K1[4] = {
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
static int32_t FXD_FixMul(int32_t a, int32_t b)
|
static int32_t FXD_FixMul(int32_t a, int32_t b)
|
||||||
{
|
{
|
||||||
int32_t high_a, low_a, high_b, low_b;
|
int32_t high_a, low_a, high_b, low_b;
|
||||||
int32_t hahb, halb, lahb;
|
int32_t hahb, halb, lahb;
|
||||||
uint32_t lalb;
|
uint32_t lalb;
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
high_a = a >> 16;
|
high_a = a >> 16;
|
||||||
low_a = a & 0x0000FFFF;
|
low_a = a & 0x0000FFFF;
|
||||||
high_b = b >> 16;
|
high_b = b >> 16;
|
||||||
low_b = b & 0x0000FFFF;
|
low_b = b & 0x0000FFFF;
|
||||||
|
|
||||||
hahb = (high_a * high_b) << 16;
|
hahb = (high_a * high_b) << 16;
|
||||||
halb = high_a * low_b;
|
halb = high_a * low_b;
|
||||||
lahb = low_a * high_b;
|
lahb = low_a * high_b;
|
||||||
lalb = (uint32_t)(low_a * low_b) >> 16;
|
lalb = (uint32_t)(low_a * low_b) >> 16;
|
||||||
|
|
||||||
ret = hahb + halb + lahb + lalb;
|
ret = hahb + halb + lahb + lalb;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -111,81 +111,81 @@ static int32_t FXD_FixMul(int32_t a, int32_t b)
|
||||||
|
|
||||||
static int8_t getSoundData(int8_t *buf, int32_t unit, int32_t sample)
|
static int8_t getSoundData(int8_t *buf, int32_t unit, int32_t sample)
|
||||||
{
|
{
|
||||||
int8_t ret;
|
int8_t ret;
|
||||||
int8_t *p;
|
int8_t *p;
|
||||||
int32_t offset, shift;
|
int32_t offset, shift;
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
shift = (unit%2) * 4;
|
shift = (unit%2) * 4;
|
||||||
|
|
||||||
offset = 16 + (unit / 2) + (sample * 4);
|
offset = 16 + (unit / 2) + (sample * 4);
|
||||||
p += offset;
|
p += offset;
|
||||||
|
|
||||||
ret = (*p >> shift) & 0x0F;
|
ret = (*p >> shift) & 0x0F;
|
||||||
|
|
||||||
if (ret > 7) {
|
if (ret > 7) {
|
||||||
ret -= 16;
|
ret -= 16;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int8_t getFilter(int8_t *buf, int32_t unit)
|
static int8_t getFilter(int8_t *buf, int32_t unit)
|
||||||
{
|
{
|
||||||
return (*(buf + 4 + unit) >> 4) & 0x03;
|
return (*(buf + 4 + unit) >> 4) & 0x03;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int8_t getRange(int8_t *buf, int32_t unit)
|
static int8_t getRange(int8_t *buf, int32_t unit)
|
||||||
{
|
{
|
||||||
return *(buf + 4 + unit) & 0x0F;
|
return *(buf + 4 + unit) & 0x0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void decodeSoundSectMono(XASector *ssct, xa_data * xad)
|
static void decodeSoundSectMono(XASector *ssct, xa_data * xad)
|
||||||
{
|
{
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
int8_t snddat, filt, range;
|
int8_t snddat, filt, range;
|
||||||
int16_t decoded;
|
int16_t decoded;
|
||||||
int32_t unit, sample;
|
int32_t unit, sample;
|
||||||
int32_t sndgrp;
|
int32_t sndgrp;
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
int32_t tmp2, tmp3, tmp4, tmp5;
|
int32_t tmp2, tmp3, tmp4, tmp5;
|
||||||
#else
|
#else
|
||||||
double tmp2, tmp3, tmp4, tmp5;
|
double tmp2, tmp3, tmp4, tmp5;
|
||||||
#endif
|
#endif
|
||||||
int8_t decodeBuf[kNumOfSGs*kNumOfSamples*2];
|
int8_t decodeBuf[kNumOfSGs*kNumOfSamples*2];
|
||||||
|
|
||||||
for (sndgrp = 0; sndgrp < kNumOfSGs; sndgrp++)
|
for (sndgrp = 0; sndgrp < kNumOfSGs; sndgrp++)
|
||||||
{
|
{
|
||||||
for (unit = 0; unit < 8; unit++)
|
for (unit = 0; unit < 8; unit++)
|
||||||
{
|
{
|
||||||
range = getRange(ssct->SoundGroups[sndgrp], unit);
|
range = getRange(ssct->SoundGroups[sndgrp], unit);
|
||||||
filt = getFilter(ssct->SoundGroups[sndgrp], unit);
|
filt = getFilter(ssct->SoundGroups[sndgrp], unit);
|
||||||
for (sample = 0; sample < 28; sample++)
|
for (sample = 0; sample < 28; sample++)
|
||||||
{
|
{
|
||||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
tmp2 = (int32_t)(snddat) << (12 - range);
|
tmp2 = (int32_t)(snddat) << (12 - range);
|
||||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||||
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
||||||
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
||||||
xad->t2 = xad->t1;
|
xad->t2 = xad->t1;
|
||||||
xad->t1 = tmp3 + tmp4 + tmp5;
|
xad->t1 = tmp3 + tmp4 + tmp5;
|
||||||
decoded = FXD_FxdToPcm16(xad->t1);
|
decoded = FXD_FxdToPcm16(xad->t1);
|
||||||
#else
|
#else
|
||||||
tmp2 = (double)(1 << (12 - range));
|
tmp2 = (double)(1 << (12 - range));
|
||||||
tmp3 = (double)snddat * tmp2;
|
tmp3 = (double)snddat * tmp2;
|
||||||
tmp4 = xad->t1 * K0[filt];
|
tmp4 = xad->t1 * K0[filt];
|
||||||
tmp5 = xad->t2 * K1[filt];
|
tmp5 = xad->t2 * K1[filt];
|
||||||
xad->t2 = xad->t1;
|
xad->t2 = xad->t1;
|
||||||
xad->t1 = tmp3 + tmp4 + tmp5;
|
xad->t1 = tmp3 + tmp4 + tmp5;
|
||||||
decoded = DblToPCM(xad->t1);
|
decoded = DblToPCM(xad->t1);
|
||||||
#endif
|
#endif
|
||||||
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
||||||
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > xad->blocksize)
|
if (count > xad->blocksize)
|
||||||
xad->block = (int8_t *)realloc(xad->block, count);
|
xad->block = (int8_t *)realloc(xad->block, count);
|
||||||
|
@ -196,76 +196,76 @@ static void decodeSoundSectMono(XASector *ssct, xa_data * xad)
|
||||||
|
|
||||||
static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
||||||
{
|
{
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
int8_t snddat, filt, range;
|
int8_t snddat, filt, range;
|
||||||
int8_t filt1, range1;
|
int8_t filt1, range1;
|
||||||
int16_t decoded;
|
int16_t decoded;
|
||||||
int32_t unit, sample;
|
int32_t unit, sample;
|
||||||
int32_t sndgrp;
|
int32_t sndgrp;
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
int32_t tmp2, tmp3, tmp4, tmp5;
|
int32_t tmp2, tmp3, tmp4, tmp5;
|
||||||
#else
|
#else
|
||||||
double tmp2, tmp3, tmp4, tmp5;
|
double tmp2, tmp3, tmp4, tmp5;
|
||||||
#endif
|
#endif
|
||||||
int8_t decodeBuf[kNumOfSGs*kNumOfSamples*2];
|
int8_t decodeBuf[kNumOfSGs*kNumOfSamples*2];
|
||||||
|
|
||||||
for (sndgrp = 0; sndgrp < kNumOfSGs; sndgrp++)
|
for (sndgrp = 0; sndgrp < kNumOfSGs; sndgrp++)
|
||||||
{
|
{
|
||||||
for (unit = 0; unit < 8; unit+= 2)
|
for (unit = 0; unit < 8; unit+= 2)
|
||||||
{
|
{
|
||||||
range = getRange(ssct->SoundGroups[sndgrp], unit);
|
range = getRange(ssct->SoundGroups[sndgrp], unit);
|
||||||
filt = getFilter(ssct->SoundGroups[sndgrp], unit);
|
filt = getFilter(ssct->SoundGroups[sndgrp], unit);
|
||||||
range1 = getRange(ssct->SoundGroups[sndgrp], unit+1);
|
range1 = getRange(ssct->SoundGroups[sndgrp], unit+1);
|
||||||
filt1 = getFilter(ssct->SoundGroups[sndgrp], unit+1);
|
filt1 = getFilter(ssct->SoundGroups[sndgrp], unit+1);
|
||||||
|
|
||||||
for (sample = 0; sample < 28; sample++)
|
for (sample = 0; sample < 28; sample++)
|
||||||
{
|
{
|
||||||
// Channel 1
|
// Channel 1
|
||||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
tmp2 = (int32_t)(snddat) << (12 - range);
|
tmp2 = (int32_t)(snddat) << (12 - range);
|
||||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||||
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
||||||
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
||||||
xad->t2 = xad->t1;
|
xad->t2 = xad->t1;
|
||||||
xad->t1 = tmp3 + tmp4 + tmp5;
|
xad->t1 = tmp3 + tmp4 + tmp5;
|
||||||
decoded = FXD_FxdToPcm16(xad->t1);
|
decoded = FXD_FxdToPcm16(xad->t1);
|
||||||
#else
|
#else
|
||||||
tmp2 = (double)(1 << (12 - range));
|
tmp2 = (double)(1 << (12 - range));
|
||||||
tmp3 = (double)snddat * tmp2;
|
tmp3 = (double)snddat * tmp2;
|
||||||
tmp4 = xad->t1 * K0[filt];
|
tmp4 = xad->t1 * K0[filt];
|
||||||
tmp5 = xad->t2 * K1[filt];
|
tmp5 = xad->t2 * K1[filt];
|
||||||
xad->t2 = xad->t1;
|
xad->t2 = xad->t1;
|
||||||
xad->t1 = tmp3 + tmp4 + tmp5;
|
xad->t1 = tmp3 + tmp4 + tmp5;
|
||||||
decoded = DblToPCM(xad->t1);
|
decoded = DblToPCM(xad->t1);
|
||||||
#endif
|
#endif
|
||||||
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
||||||
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
||||||
|
|
||||||
// Channel 2
|
// Channel 2
|
||||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit+1, sample);
|
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit+1, sample);
|
||||||
#if USE_FXD
|
#if USE_FXD
|
||||||
tmp2 = (int32_t)(snddat) << (12 - range1);
|
tmp2 = (int32_t)(snddat) << (12 - range1);
|
||||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||||
tmp4 = FXD_FixMul(K0[filt1], xad->t1_x);
|
tmp4 = FXD_FixMul(K0[filt1], xad->t1_x);
|
||||||
tmp5 = FXD_FixMul(K1[filt1], xad->t2_x);
|
tmp5 = FXD_FixMul(K1[filt1], xad->t2_x);
|
||||||
xad->t2_x = xad->t1_x;
|
xad->t2_x = xad->t1_x;
|
||||||
xad->t1_x = tmp3 + tmp4 + tmp5;
|
xad->t1_x = tmp3 + tmp4 + tmp5;
|
||||||
decoded = FXD_FxdToPcm16(xad->t1_x);
|
decoded = FXD_FxdToPcm16(xad->t1_x);
|
||||||
#else
|
#else
|
||||||
tmp2 = (double)(1 << (12 - range1));
|
tmp2 = (double)(1 << (12 - range1));
|
||||||
tmp3 = (double)snddat * tmp2;
|
tmp3 = (double)snddat * tmp2;
|
||||||
tmp4 = xad->t1_x * K0[filt1];
|
tmp4 = xad->t1_x * K0[filt1];
|
||||||
tmp5 = xad->t2_x * K1[filt1];
|
tmp5 = xad->t2_x * K1[filt1];
|
||||||
xad->t2_x = xad->t1_x;
|
xad->t2_x = xad->t1_x;
|
||||||
xad->t1_x = tmp3 + tmp4 + tmp5;
|
xad->t1_x = tmp3 + tmp4 + tmp5;
|
||||||
decoded = DblToPCM(xad->t1_x);
|
decoded = DblToPCM(xad->t1_x);
|
||||||
#endif
|
#endif
|
||||||
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
decodeBuf[count++] = (int8_t) ((uint16_t)decoded & 0x00FF);
|
||||||
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
decodeBuf[count++] = (int8_t)(((uint16_t)decoded & 0xFF00) >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > xad->blocksize)
|
if (count > xad->blocksize)
|
||||||
xad->block = (int8_t *)realloc(xad->block, count);
|
xad->block = (int8_t *)realloc(xad->block, count);
|
||||||
|
@ -303,7 +303,6 @@ static playbackstatus MV_GetNextXABlock
|
||||||
(
|
(
|
||||||
VoiceNode *voice
|
VoiceNode *voice
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
xa_data * xad = (xa_data *) voice->rawdataptr;
|
xa_data * xad = (xa_data *) voice->rawdataptr;
|
||||||
XASector ssct;
|
XASector ssct;
|
||||||
|
@ -382,7 +381,6 @@ int32_t MV_PlayXA3D
|
||||||
int32_t priority,
|
int32_t priority,
|
||||||
uint32_t callbackval
|
uint32_t callbackval
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t left;
|
int32_t left;
|
||||||
int32_t right;
|
int32_t right;
|
||||||
|
@ -477,7 +475,7 @@ int32_t MV_PlayXA
|
||||||
xad->owner = voice;
|
xad->owner = voice;
|
||||||
|
|
||||||
voice->wavetype = FMT_XA;
|
voice->wavetype = FMT_XA;
|
||||||
voice->rawdataptr = (void*)xad;
|
voice->rawdataptr = (void*)xad;
|
||||||
voice->GetSound = MV_GetNextXABlock;
|
voice->GetSound = MV_GetNextXABlock;
|
||||||
voice->NextBlock = (char *)xad->block;
|
voice->NextBlock = (char *)xad->block;
|
||||||
voice->LoopCount = 0;
|
voice->LoopCount = 0;
|
||||||
|
|
Loading…
Reference in a new issue