Updated modplay
parent
ce2303ef24
commit
b8763c6cad
|
@ -2167,7 +2167,8 @@ static void MainPlayer(PLAYER *p) /* periodically called from mixer */
|
||||||
|
|
||||||
if (oldSongPos != p->Song.SongPos)
|
if (oldSongPos != p->Song.SongPos)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < playedRowsCount; ++i)
|
size_t i;
|
||||||
|
for (i = 0; i < playedRowsCount; ++i)
|
||||||
bit_array_set(p->playedRows, oldSongPos * 1024 + p->playedRowsPatLoop[i]);
|
bit_array_set(p->playedRows, oldSongPos * 1024 + p->playedRowsPatLoop[i]);
|
||||||
memset(p->playedRowsPatLoop, 0xFF, playedRowsCount * 2);
|
memset(p->playedRowsPatLoop, 0xFF, playedRowsCount * 2);
|
||||||
playedRowsCount = 0;
|
playedRowsCount = 0;
|
||||||
|
@ -3032,7 +3033,7 @@ static inline void mix8b(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler) ||
|
||||||
!resampler_get_sample_count(resampler)))
|
!resampler_get_sample_count(resampler)))
|
||||||
{
|
{
|
||||||
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 8);
|
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 8);
|
||||||
|
@ -3071,11 +3072,18 @@ static inline void mix8b(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
}
|
}
|
||||||
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
||||||
{
|
{
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler) ||
|
||||||
|
!resampler_get_sample_count(resampler)))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler, 0, 8);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->loopingForward = loopingForward;
|
v->loopingForward = loopingForward;
|
||||||
v->interpolating = (int8_t)interpolating;
|
v->interpolating = (int8_t)interpolating;
|
||||||
|
@ -3196,7 +3204,7 @@ static inline void mix8bstereo(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler[0]) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
(!resampler_get_sample_count(resampler[0]) &&
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
!resampler_get_sample_count(resampler[1]))))
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
{
|
{
|
||||||
|
@ -3237,11 +3245,20 @@ static inline void mix8bstereo(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
}
|
}
|
||||||
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
||||||
{
|
{
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler[0], 0, 8);
|
||||||
|
resampler_write_sample_fixed(resampler[1], 0, 8);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->loopingForward = loopingForward;
|
v->loopingForward = loopingForward;
|
||||||
v->interpolating = (int8_t)interpolating;
|
v->interpolating = (int8_t)interpolating;
|
||||||
|
@ -3366,7 +3383,7 @@ static inline void mix16b(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler) ||
|
||||||
!resampler_get_sample_count(resampler)))
|
!resampler_get_sample_count(resampler)))
|
||||||
{
|
{
|
||||||
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 16);
|
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 16);
|
||||||
|
@ -3405,11 +3422,18 @@ static inline void mix16b(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
}
|
}
|
||||||
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
||||||
{
|
{
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler) ||
|
||||||
|
!resampler_get_sample_count(resampler)))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler, 0, 16);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->loopingForward = loopingForward;
|
v->loopingForward = loopingForward;
|
||||||
v->interpolating = (int8_t)interpolating;
|
v->interpolating = (int8_t)interpolating;
|
||||||
|
@ -3530,7 +3554,7 @@ static inline void mix16bstereo(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler[0]) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
(!resampler_get_sample_count(resampler[0]) &&
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
!resampler_get_sample_count(resampler[1]))))
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
{
|
{
|
||||||
|
@ -3571,11 +3595,20 @@ static inline void mix16bstereo(PLAYER *p, uint32_t ch, uint32_t samples)
|
||||||
}
|
}
|
||||||
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
else if ((samplePosition < 0) || (samplePosition >= sampleLength))
|
||||||
{
|
{
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler[0], 0, 16);
|
||||||
|
resampler_write_sample_fixed(resampler[1], 0, 16);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->loopingForward = loopingForward;
|
v->loopingForward = loopingForward;
|
||||||
v->interpolating = (int8_t)interpolating;
|
v->interpolating = (int8_t)interpolating;
|
||||||
|
|
|
@ -303,6 +303,11 @@ static int resampler_output_delay(resampler *r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int resampler_get_padding_size()
|
||||||
|
{
|
||||||
|
return SINC_WIDTH - 1;
|
||||||
|
}
|
||||||
|
|
||||||
int resampler_ready(void *_r)
|
int resampler_ready(void *_r)
|
||||||
{
|
{
|
||||||
resampler * r = ( resampler * ) _r;
|
resampler * r = ( resampler * ) _r;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#define RESAMPLER_DECORATE modplay
|
#define RESAMPLER_DECORATE modplay
|
||||||
|
|
||||||
// Ugglay
|
|
||||||
#ifdef RESAMPLER_DECORATE
|
#ifdef RESAMPLER_DECORATE
|
||||||
#define PASTE(a,b) a ## b
|
#define PASTE(a,b) a ## b
|
||||||
#define EVALUATE(a,b) PASTE(a,b)
|
#define EVALUATE(a,b) PASTE(a,b)
|
||||||
|
@ -14,6 +13,7 @@
|
||||||
#define resampler_dup_inplace EVALUATE(RESAMPLER_DECORATE,_resampler_dup_inplace)
|
#define resampler_dup_inplace EVALUATE(RESAMPLER_DECORATE,_resampler_dup_inplace)
|
||||||
#define resampler_set_quality EVALUATE(RESAMPLER_DECORATE,_resampler_set_quality)
|
#define resampler_set_quality EVALUATE(RESAMPLER_DECORATE,_resampler_set_quality)
|
||||||
#define resampler_get_free_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_free_count)
|
#define resampler_get_free_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_free_count)
|
||||||
|
#define resampler_get_padding_size EVALUATE(RESAMPLER_DECORATE,_resampler_get_padding_size)
|
||||||
#define resampler_write_sample EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample)
|
#define resampler_write_sample EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample)
|
||||||
#define resampler_write_sample_fixed EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample_fixed)
|
#define resampler_write_sample_fixed EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample_fixed)
|
||||||
#define resampler_set_rate EVALUATE(RESAMPLER_DECORATE,_resampler_set_rate)
|
#define resampler_set_rate EVALUATE(RESAMPLER_DECORATE,_resampler_set_rate)
|
||||||
|
@ -47,6 +47,7 @@ enum
|
||||||
void resampler_set_quality(void *, int quality);
|
void resampler_set_quality(void *, int quality);
|
||||||
|
|
||||||
int resampler_get_free_count(void *);
|
int resampler_get_free_count(void *);
|
||||||
|
int resampler_get_padding_size();
|
||||||
void resampler_write_sample(void *, short sample);
|
void resampler_write_sample(void *, short sample);
|
||||||
void resampler_write_sample_fixed(void *, int sample, unsigned char depth);
|
void resampler_write_sample_fixed(void *, int sample, unsigned char depth);
|
||||||
void resampler_set_rate( void *, double new_factor );
|
void resampler_set_rate( void *, double new_factor );
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
** - Added S9E/S9F (non-ST3, play sample backwards/forwards)
|
** - Added S9E/S9F (non-ST3, play sample backwards/forwards)
|
||||||
** - Fixed a bug in setspd() in Amiga limit mode
|
** - Fixed a bug in setspd() in Amiga limit mode
|
||||||
** - Proper tracker handling for non-ST3 effects
|
** - Proper tracker handling for non-ST3 effects
|
||||||
** - Panbrello (Yxy) didn't set the panning at all (heh)
|
** - Panbrello (Yxy) didn't set the panning at all
|
||||||
** - Decodes ADPCM samples at load time instead of play time
|
** - Decodes ADPCM samples at load time instead of play time
|
||||||
** - Mxx (set cannel volume) didn't work correctly
|
** - Mxx (set cannel volume) didn't work correctly
|
||||||
**
|
**
|
||||||
|
@ -199,11 +199,9 @@ typedef struct
|
||||||
|
|
||||||
#ifdef USE_VOL_RAMP
|
#ifdef USE_VOL_RAMP
|
||||||
VOICE voice[32 * 2];
|
VOICE voice[32 * 2];
|
||||||
|
|
||||||
void *resampler[64 * 2];
|
void *resampler[64 * 2];
|
||||||
#else
|
#else
|
||||||
VOICE voice[32];
|
VOICE voice[32];
|
||||||
|
|
||||||
void *resampler[64];
|
void *resampler[64];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -213,7 +211,7 @@ typedef struct
|
||||||
const uint8_t *fmPatchTable[9];
|
const uint8_t *fmPatchTable[9];
|
||||||
uint8_t fmLastB0[9];
|
uint8_t fmLastB0[9];
|
||||||
|
|
||||||
int8_t ** adpcmSamples;
|
int8_t **adpcmSamples;
|
||||||
|
|
||||||
float f_outputFreq;
|
float f_outputFreq;
|
||||||
float f_masterVolume;
|
float f_masterVolume;
|
||||||
|
@ -546,7 +544,7 @@ void * st3play_Alloc(uint32_t outputFreq, int8_t interpolation, int8_t ramp_styl
|
||||||
#ifdef USE_VOL_RAMP
|
#ifdef USE_VOL_RAMP
|
||||||
setRampStyle(p, ramp_style);
|
setRampStyle(p, ramp_style);
|
||||||
#endif
|
#endif
|
||||||
setSamplesPerFrame(p, ((outputFreq * 5UL) / 2 / 125));
|
setSamplesPerFrame(p, ((outputFreq * 5) / 2 / 125));
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
@ -645,7 +643,7 @@ static void settempo(PLAYER *p, uint16_t val)
|
||||||
if (val > 32)
|
if (val > 32)
|
||||||
{
|
{
|
||||||
p->tempo = val;
|
p->tempo = val;
|
||||||
setSamplesPerFrame(p, ((p->outputFreq * 5UL) / 2) / p->tempo);
|
setSamplesPerFrame(p, ((p->outputFreq * 5) / 2) / p->tempo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,8 +651,8 @@ static void st3play_AdlibHertzTouch(PLAYER *p, uint8_t ch, int32_t Hertz, uint8_
|
||||||
{
|
{
|
||||||
int32_t Oct;
|
int32_t Oct;
|
||||||
|
|
||||||
for (Oct = 0; Hertz > 0x1FF; Oct++)
|
for (Oct = 0; Hertz >= 512; Oct++)
|
||||||
Hertz >>= 1;
|
Hertz /= 2;
|
||||||
|
|
||||||
Chip_WriteReg(p->fmChip, 0xA0 + ch, Hertz & 0xFF);
|
Chip_WriteReg(p->fmChip, 0xA0 + ch, Hertz & 0xFF);
|
||||||
|
|
||||||
|
@ -764,7 +762,7 @@ static inline int16_t stnote2herz(PLAYER *p, uint8_t note)
|
||||||
if (note == 254) return (0);
|
if (note == 254) return (0);
|
||||||
|
|
||||||
tmpnote = note & 0x0F;
|
tmpnote = note & 0x0F;
|
||||||
tmpocta = note >> 0x04;
|
tmpocta = note >> 4;
|
||||||
|
|
||||||
// ST3 doesn't do this, but do it for safety
|
// ST3 doesn't do this, but do it for safety
|
||||||
if (tmpnote > 11) tmpnote = 11;
|
if (tmpnote > 11) tmpnote = 11;
|
||||||
|
@ -778,11 +776,11 @@ static inline int16_t stnote2herz(PLAYER *p, uint8_t note)
|
||||||
|
|
||||||
static inline int32_t scalec2spd(PLAYER *p, uint8_t ch, int32_t spd)
|
static inline int32_t scalec2spd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
{
|
{
|
||||||
spd *= 8363UL;
|
spd *= 8363;
|
||||||
|
|
||||||
if (p->tracker == SCREAM_TRACKER)
|
if (p->tracker == SCREAM_TRACKER)
|
||||||
{
|
{
|
||||||
if ((spd >> 16) > p->chn[ch].ac2spd)
|
if ((spd / 65536) > p->chn[ch].ac2spd)
|
||||||
return (32767);
|
return (32767);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +810,7 @@ static inline int32_t roundspd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
|
|
||||||
if (p->tracker == SCREAM_TRACKER)
|
if (p->tracker == SCREAM_TRACKER)
|
||||||
{
|
{
|
||||||
if ((newspd >> 16) >= 8363)
|
if ((newspd / 65536) >= 8363)
|
||||||
return (spd);
|
return (spd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,11 +818,11 @@ static inline int32_t roundspd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
|
|
||||||
// find octave
|
// find octave
|
||||||
octa = 0;
|
octa = 0;
|
||||||
lastspd = ((1712 * 8) + notespd[11]) >> 1;
|
lastspd = ((1712 * 8) + (907 * 16)) / 2;;
|
||||||
while (newspd < lastspd)
|
while (newspd < lastspd)
|
||||||
{
|
{
|
||||||
octa++;
|
octa++;
|
||||||
lastspd >>= 1;
|
lastspd /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find note
|
// find note
|
||||||
|
@ -834,7 +832,7 @@ static inline int32_t roundspd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
if (p->tracker == SCREAM_TRACKER)
|
if (p->tracker == SCREAM_TRACKER)
|
||||||
lastspd = 32767;
|
lastspd = 32767;
|
||||||
else
|
else
|
||||||
lastspd = 32767 * 2; // Might be wrong? Probably not
|
lastspd = 32767 * 2;
|
||||||
|
|
||||||
while (newnote < 11)
|
while (newnote < 11)
|
||||||
{
|
{
|
||||||
|
@ -851,11 +849,11 @@ static inline int32_t roundspd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new speed from new note
|
// get new speed from new note
|
||||||
newspd = (uint32_t)(stnote2herz(p, (octa << 4) | (lastnote & 0x0F))) * 8363;
|
newspd = (stnote2herz(p, (octa << 4) | (lastnote & 0x0F))) * 8363;
|
||||||
|
|
||||||
if (p->tracker == SCREAM_TRACKER)
|
if (p->tracker == SCREAM_TRACKER)
|
||||||
{
|
{
|
||||||
if ((newspd >> 16) >= p->chn[ch].ac2spd)
|
if ((newspd / 65536) >= p->chn[ch].ac2spd)
|
||||||
return (spd);
|
return (spd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,14 +865,14 @@ static inline int32_t roundspd(PLAYER *p, uint8_t ch, int32_t spd)
|
||||||
|
|
||||||
static int16_t neworder(PLAYER *p)
|
static int16_t neworder(PLAYER *p)
|
||||||
{
|
{
|
||||||
skip:
|
newOrderSkip:
|
||||||
p->np_ord++;
|
p->np_ord++;
|
||||||
|
|
||||||
if ((p->mseg[0x60+(p->np_ord-1)]==255)||(p->np_ord>get_le16(&p->mseg[0x20]))) // end
|
if ((p->mseg[0x60 + (p->np_ord - 1)] == 255) || (p->np_ord > get_le16(&p->mseg[0x20]))) // end
|
||||||
p->np_ord = 1;
|
p->np_ord = 1;
|
||||||
|
|
||||||
if (p->mseg[0x60 + (p->np_ord - 1)] == 254) // skip
|
if (p->mseg[0x60 + (p->np_ord - 1)] == 254) // skip
|
||||||
goto skip; // avoid recursive calling
|
goto newOrderSkip; // avoid recursive calling
|
||||||
|
|
||||||
p->np_pat = (int16_t)(p->mseg[0x60 + (p->np_ord - 1)]);
|
p->np_pat = (int16_t)(p->mseg[0x60 + (p->np_ord - 1)]);
|
||||||
p->np_patoff = -1; // force reseek
|
p->np_patoff = -1; // force reseek
|
||||||
|
@ -896,7 +894,7 @@ static inline void seekpat(PLAYER *p)
|
||||||
|
|
||||||
if (p->np_patoff == -1) // seek must be done
|
if (p->np_patoff == -1) // seek must be done
|
||||||
{
|
{
|
||||||
p->np_patseg = (uint32_t)(get_le16(&p->mseg[p->patternadd + (p->np_pat << 1)])) << 4;
|
p->np_patseg = get_le16(&p->mseg[p->patternadd + (p->np_pat * 2)]) * 16;
|
||||||
if (p->np_patseg)
|
if (p->np_patseg)
|
||||||
{
|
{
|
||||||
j = 2; // skip packed pat len flag
|
j = 2; // skip packed pat len flag
|
||||||
|
@ -1031,10 +1029,10 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
|
|
||||||
if (p->chn[ch].ins <= get_le16(&p->mseg[0x22])) // added for safety reasons
|
if (p->chn[ch].ins <= get_le16(&p->mseg[0x22])) // added for safety reasons
|
||||||
{
|
{
|
||||||
insdat = &p->mseg[(uint32_t)(get_le16(&p->mseg[p->instrumentadd + ((p->chn[ch].ins - 1) << 1)])) << 4];
|
insdat = &p->mseg[get_le16(&p->mseg[p->instrumentadd + ((p->chn[ch].ins - 1) * 2)]) * 16];
|
||||||
if (insdat[0])
|
if (insdat[0])
|
||||||
{
|
{
|
||||||
if (insdat[0] == 1 && adlibChannel >= 9)
|
if ((insdat[0] == 1) && (adlibChannel >= 9))
|
||||||
{
|
{
|
||||||
p->chn[ch].ac2spd = get_le32(&insdat[0x20]);
|
p->chn[ch].ac2spd = get_le32(&insdat[0x20]);
|
||||||
|
|
||||||
|
@ -1045,12 +1043,13 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
p->chn[ch].avol = (int8_t)(insdat[0x1C]);
|
p->chn[ch].avol = (int8_t)(insdat[0x1C]);
|
||||||
|
|
||||||
if (p->chn[ch].avol < 0) p->chn[ch].avol = 0;
|
if (p->chn[ch].avol < 0) p->chn[ch].avol = 0;
|
||||||
if (p->chn[ch].avol > 63) p->chn[ch].avol = 63;
|
else if (p->chn[ch].avol > 63) p->chn[ch].avol = 63;
|
||||||
|
|
||||||
p->chn[ch].aorgvol = p->chn[ch].avol;
|
p->chn[ch].aorgvol = p->chn[ch].avol;
|
||||||
|
|
||||||
insoffs = (uint32_t)(((uint32_t)(insdat[0x0D])<<16)|((uint16_t)(insdat[0x0F])<<8)|insdat[0x0E])<<4;
|
insoffs = ((insdat[0x0D] << 16) | (insdat[0x0F] << 8) | insdat[0x0E]) * 16;
|
||||||
|
|
||||||
if (insoffs > p->mseg_len)
|
if (insoffs > p->mseg_len)
|
||||||
insoffs = p->mseg_len;
|
insoffs = p->mseg_len;
|
||||||
|
@ -1100,7 +1099,7 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
p->chn[ch].surround = 0;
|
p->chn[ch].surround = 0;
|
||||||
voiceSetSurround(p, ch, 0);
|
voiceSetSurround(p, ch, 0);
|
||||||
|
|
||||||
p->chn[ch].apanpos = (p->chn[ch].vol - 128) << 2;
|
p->chn[ch].apanpos = (p->chn[ch].vol - 128) * 4;
|
||||||
setpan(p, ch);
|
setpan(p, ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1136,7 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
}
|
}
|
||||||
else if (insdat[0] == 2 && adlibChannel < 9)
|
else if (insdat[0] == 2 && adlibChannel < 9)
|
||||||
{
|
{
|
||||||
p->chn[ch].ac2spd = 8363 * 164 / 249;
|
p->chn[ch].ac2spd = (8363 * 164) / 249;
|
||||||
p->chn[ch].avol = (int8_t)(insdat[0x1C]);
|
p->chn[ch].avol = (int8_t)(insdat[0x1C]);
|
||||||
p->chn[ch].aorgvol = p->chn[ch].avol;
|
p->chn[ch].aorgvol = p->chn[ch].avol;
|
||||||
|
|
||||||
|
@ -1164,7 +1163,7 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p->chn[ch].astartoffset = (uint16_t)(p->chn[ch].info) << 8;
|
p->chn[ch].astartoffset = 256 * p->chn[ch].info;
|
||||||
p->chn[ch].astartoffset00 = p->chn[ch].astartoffset;
|
p->chn[ch].astartoffset00 = p->chn[ch].astartoffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1250,7 +1249,7 @@ static inline void doamiga(PLAYER *p, uint8_t ch)
|
||||||
p->chn[ch].surround = 0;
|
p->chn[ch].surround = 0;
|
||||||
voiceSetSurround(p, ch, 0);
|
voiceSetSurround(p, ch, 0);
|
||||||
|
|
||||||
p->chn[ch].apanpos = (p->chn[ch].vol - 128) << 2;
|
p->chn[ch].apanpos = (p->chn[ch].vol - 128) * 4;
|
||||||
setpan(p, ch);
|
setpan(p, ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1267,7 @@ static inline void donewnote(PLAYER *p, uint8_t ch, int8_t notedelayflag)
|
||||||
{
|
{
|
||||||
p->lastachannelused = ch + 1;
|
p->lastachannelused = ch + 1;
|
||||||
|
|
||||||
// hackish fix, fixes call_me_an_angel.s3m crash
|
// sanity fix
|
||||||
if (p->lastachannelused > 31) p->lastachannelused = 31;
|
if (p->lastachannelused > 31) p->lastachannelused = 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,7 +1304,7 @@ static inline void donotes(PLAYER *p)
|
||||||
ch = getnote(p);
|
ch = getnote(p);
|
||||||
if (ch == 255) break; // end of row/channels
|
if (ch == 255) break; // end of row/channels
|
||||||
|
|
||||||
if ((p->mseg[0x40 + ch] & 0x7F) <= 15 + 9)
|
if ((p->mseg[0x40 + ch] & 0x7F) <= (15 + 9))
|
||||||
donewnote(p, ch, 0);
|
donewnote(p, ch, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1328,9 +1327,6 @@ static inline void docmd1(PLAYER *p)
|
||||||
|
|
||||||
if (p->chn[i].cmd == ('D' - 64))
|
if (p->chn[i].cmd == ('D' - 64))
|
||||||
{
|
{
|
||||||
// THEORY: I think this fix is related to
|
|
||||||
// AdLib channels...
|
|
||||||
|
|
||||||
// fix retrig if Dxy
|
// fix retrig if Dxy
|
||||||
p->chn[i].atrigcnt = 0;
|
p->chn[i].atrigcnt = 0;
|
||||||
|
|
||||||
|
@ -1420,9 +1416,10 @@ static inline void docmd2(PLAYER *p)
|
||||||
|
|
||||||
void dorow(PLAYER *p) // periodically called from mixer
|
void dorow(PLAYER *p) // periodically called from mixer
|
||||||
{
|
{
|
||||||
int32_t offset, bit;
|
int8_t offset;
|
||||||
|
int8_t bit;
|
||||||
|
|
||||||
p->patmusicrand = (uint16_t)(((uint32_t)(p->patmusicrand) * 0xCDEF) >> 16) + 0x1727;
|
p->patmusicrand = (((p->patmusicrand * 0xCDEF) >> 16) + 0x1727) & 0x0000FFFF;
|
||||||
|
|
||||||
if (!p->musiccount)
|
if (!p->musiccount)
|
||||||
{
|
{
|
||||||
|
@ -1497,22 +1494,23 @@ static inline int8_t get_adpcm_sample(const int8_t *sampleDictionary, const uint
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
|
||||||
byte = sampleData[samplePosition >> 1];
|
byte = sampleData[samplePosition / 2];
|
||||||
byte = (samplePosition & 1) ? byte >> 4 : byte & 15;
|
byte = (samplePosition & 1) ? (byte >> 4) : (byte & 0x0F);
|
||||||
return *lastDelta += sampleDictionary[byte];
|
|
||||||
|
return (*(lastDelta) += sampleDictionary[byte]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void decode_adpcm(const uint8_t * sampleData, int8_t * decodedSampleData, int32_t sampleLength)
|
static inline void decode_adpcm(const uint8_t *sampleData, int8_t *decodedSampleData, int32_t sampleLength)
|
||||||
{
|
{
|
||||||
int i;
|
int32_t i;
|
||||||
int8_t lastDelta, sample;
|
int8_t lastDelta;
|
||||||
const int8_t * sampleDictionary;
|
int8_t sample;
|
||||||
|
const int8_t *sampleDictionary;
|
||||||
|
|
||||||
sampleDictionary = (const int8_t *)(sampleData);
|
sampleDictionary = (const int8_t *)(sampleData);
|
||||||
sampleData += 16;
|
sampleData += 16;
|
||||||
|
|
||||||
lastDelta = 0;
|
lastDelta = 0;
|
||||||
|
|
||||||
for (i = 0; i < sampleLength; ++i)
|
for (i = 0; i < sampleLength; ++i)
|
||||||
{
|
{
|
||||||
sample = get_adpcm_sample(sampleDictionary, sampleData, i, &lastDelta);
|
sample = get_adpcm_sample(sampleDictionary, sampleData, i, &lastDelta);
|
||||||
|
@ -1596,8 +1594,8 @@ static void loadheaderparms(PLAYER *p)
|
||||||
insnum = get_le16(&p->mseg[0x22]);
|
insnum = get_le16(&p->mseg[0x22]);
|
||||||
for (i = 0; i < insnum; ++i)
|
for (i = 0; i < insnum; ++i)
|
||||||
{
|
{
|
||||||
insdat = &p->mseg[get_le16(&p->mseg[p->instrumentadd + (i << 1)]) << 4];
|
insdat = &p->mseg[get_le16(&p->mseg[p->instrumentadd + (i * 2)]) * 16];
|
||||||
insoff = (uint32_t)(((uint32_t)(insdat[0x0D])<<16)|((uint16_t)(insdat[0x0F])<<8)|insdat[0x0E])<<4;
|
insoff = ((insdat[0x0D] << 16) | (insdat[0x0F] << 8) | insdat[0x0E]) * 16;
|
||||||
|
|
||||||
if (insoff && (insdat[0] == 1)) // PCM
|
if (insoff && (insdat[0] == 1)) // PCM
|
||||||
{
|
{
|
||||||
|
@ -1610,6 +1608,7 @@ static void loadheaderparms(PLAYER *p)
|
||||||
{
|
{
|
||||||
if (p->adpcmSamples == NULL)
|
if (p->adpcmSamples == NULL)
|
||||||
p->adpcmSamples = (int8_t **)(calloc(sizeof(int8_t *), insnum));
|
p->adpcmSamples = (int8_t **)(calloc(sizeof(int8_t *), insnum));
|
||||||
|
|
||||||
if (p->adpcmSamples)
|
if (p->adpcmSamples)
|
||||||
{
|
{
|
||||||
p->adpcmSamples[i] = (int8_t *)(calloc(1, inslen));
|
p->adpcmSamples[i] = (int8_t *)(calloc(1, inslen));
|
||||||
|
@ -1617,28 +1616,32 @@ static void loadheaderparms(PLAYER *p)
|
||||||
{
|
{
|
||||||
if ((insoff + (16 + (inslen + 1) / 2)) > p->mseg_len)
|
if ((insoff + (16 + (inslen + 1) / 2)) > p->mseg_len)
|
||||||
inslen = ((p->mseg_len - insoff) - 16) * 2;
|
inslen = ((p->mseg_len - insoff) - 16) * 2;
|
||||||
|
|
||||||
if (inslen >= 1)
|
if (inslen >= 1)
|
||||||
decode_adpcm(&p->mseg[insoff], p->adpcmSamples[i], inslen);
|
decode_adpcm(&p->mseg[insoff], p->adpcmSamples[i], inslen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insdat[0x1F] & 2) inslen <<= 1; // stereo
|
if (insdat[0x1F] & 2) inslen *= 2; // stereo
|
||||||
|
|
||||||
if (insdat[0x1F] & 4)
|
if (insdat[0x1F] & 4)
|
||||||
{
|
{
|
||||||
// 16-bit
|
// 16-bit
|
||||||
if (insoff + inslen * 2 > p->mseg_len)
|
if ((insoff + (inslen * 2)) > p->mseg_len)
|
||||||
inslen = (p->mseg_len - insoff) / 2;
|
inslen = (p->mseg_len - insoff) / 2;
|
||||||
|
|
||||||
for (j = 0; j < inslen; ++j)
|
for (j = 0; j < inslen; ++j)
|
||||||
set_le16(&p->mseg[insoff + (j << 1)], get_le16(&p->mseg[insoff + (j << 1)]) - 0x8000);
|
set_le16(&p->mseg[insoff + (j * 2)], get_le16(&p->mseg[insoff + (j * 2)]) - 0x8000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 8-bit
|
// 8-bit
|
||||||
if (insoff + inslen > p->mseg_len)
|
if ((insoff + inslen) > p->mseg_len)
|
||||||
inslen = p->mseg_len - insoff;
|
inslen = p->mseg_len - insoff;
|
||||||
|
|
||||||
for (j = 0; j < inslen; ++j)
|
for (j = 0; j < inslen; ++j)
|
||||||
p->mseg[insoff + j] = p->mseg[insoff + j] - 0x80;
|
p->mseg[insoff + j] = p->mseg[insoff + j] - 0x80;
|
||||||
}
|
}
|
||||||
|
@ -1655,6 +1658,8 @@ static void loadheaderparms(PLAYER *p)
|
||||||
void st3play_PlaySong(void *_p, int16_t startOrder)
|
void st3play_PlaySong(void *_p, int16_t startOrder)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
int8_t offset;
|
||||||
|
int8_t bit;
|
||||||
uint8_t dat;
|
uint8_t dat;
|
||||||
int16_t pan;
|
int16_t pan;
|
||||||
PLAYER *p;
|
PLAYER *p;
|
||||||
|
@ -1674,28 +1679,29 @@ void st3play_PlaySong(void *_p, int16_t startOrder)
|
||||||
for (i = 0; i < 32; ++i)
|
for (i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
pan = (p->mseg[0x33] & 0x80) ? ((p->mseg[0x40 + i] & 0x08) ? 192 : 64) : 128;
|
pan = (p->mseg[0x33] & 0x80) ? ((p->mseg[0x40 + i] & 0x08) ? 192 : 64) : 128;
|
||||||
|
|
||||||
if (p->mseg[0x35] == 0xFC) // non-default pannings follow
|
if (p->mseg[0x35] == 0xFC) // non-default pannings follow
|
||||||
{
|
{
|
||||||
dat = p->mseg[(p->patternadd + (get_le16(&p->mseg[0x24]) << 1)) + i];
|
dat = p->mseg[(p->patternadd + (get_le16(&p->mseg[0x24]) * 2)) + i];
|
||||||
if (dat & 0x20)
|
if (dat & 0x20)
|
||||||
pan = (dat & 0x0F) << 4;
|
pan = (dat & 0x0F) * 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->stereomode)
|
p->chn[i].apanpos = p->stereomode ? pan : 128;
|
||||||
p->chn[i].apanpos = pan;
|
|
||||||
else
|
|
||||||
p->chn[i].apanpos = 128;
|
|
||||||
|
|
||||||
voiceSetPanning(p, i, pan);
|
voiceSetPanning(p, i, pan);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->Playing = 1;
|
p->Playing = 1;
|
||||||
setSamplesPerFrame(p, ((p->outputFreq * 5UL) / 2 / p->tempo));
|
setSamplesPerFrame(p, ((p->outputFreq * 5) / 2 / p->tempo));
|
||||||
p->isMixing = 1;
|
p->isMixing = 1;
|
||||||
|
|
||||||
p->loopCount = 0;
|
p->loopCount = 0;
|
||||||
memset(p->playedOrder, 0, sizeof (p->playedOrder));
|
memset(p->playedOrder, 0, sizeof (p->playedOrder));
|
||||||
p->playedOrder[startOrder / 8] = 1 << (startOrder % 8);
|
|
||||||
|
offset = startOrder / 8;
|
||||||
|
bit = 1 << (startOrder % 8);
|
||||||
|
|
||||||
|
p->playedOrder[offset] = bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t st3play_LoadModule(void *_p, const uint8_t *module, size_t size)
|
int8_t st3play_LoadModule(void *_p, const uint8_t *module, size_t size)
|
||||||
|
@ -1738,7 +1744,7 @@ int8_t st3play_LoadModule(void *_p, const uint8_t *module, size_t size)
|
||||||
p->mseg_len = (uint32_t)(size);
|
p->mseg_len = (uint32_t)(size);
|
||||||
|
|
||||||
p->instrumentadd = 0x60 + p->mseg[0x20];
|
p->instrumentadd = 0x60 + p->mseg[0x20];
|
||||||
p->patternadd = p->instrumentadd + (p->mseg[0x22] << 1);
|
p->patternadd = p->instrumentadd + (p->mseg[0x22] * 2);
|
||||||
p->tickdelay = 0;
|
p->tickdelay = 0;
|
||||||
p->musiccount = 0;
|
p->musiccount = 0;
|
||||||
p->patterndelay = 0;
|
p->patterndelay = 0;
|
||||||
|
@ -1832,7 +1838,8 @@ static void s_tickdelay(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
if ( (p->tracker == OPENMPT)
|
if ( (p->tracker == OPENMPT)
|
||||||
|| (p->tracker == BEROTRACKER)
|
|| (p->tracker == BEROTRACKER)
|
||||||
|| (p->tracker == IMPULSE_TRACKER)
|
|| (p->tracker == IMPULSE_TRACKER)
|
||||||
|| (p->tracker == SCHISM_TRACKER))
|
|| (p->tracker == SCHISM_TRACKER)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
p->tickdelay += (ch->info & 0x0F);
|
p->tickdelay += (ch->info & 0x0F);
|
||||||
}
|
}
|
||||||
|
@ -1843,7 +1850,7 @@ static void s_setpanpos(PLAYER *p, chn_t *ch)
|
||||||
ch->surround = 0;
|
ch->surround = 0;
|
||||||
voiceSetSurround(p, ch->channelnum, 0);
|
voiceSetSurround(p, ch->channelnum, 0);
|
||||||
|
|
||||||
ch->apanpos = (ch->info & 0x0F) << 4;
|
ch->apanpos = (ch->info & 0x0F) * 16;
|
||||||
setpan(p, ch->channelnum);
|
setpan(p, ch->channelnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1879,6 +1886,9 @@ static void s_sndcntrl(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
|
|
||||||
static void s_patloop(PLAYER *p, chn_t *ch)
|
static void s_patloop(PLAYER *p, chn_t *ch)
|
||||||
{
|
{
|
||||||
|
int8_t offset;
|
||||||
|
int8_t bit;
|
||||||
|
|
||||||
if (!(ch->info & 0x0F))
|
if (!(ch->info & 0x0F))
|
||||||
{
|
{
|
||||||
p->patloopstart = p->np_row;
|
p->patloopstart = p->np_row;
|
||||||
|
@ -1900,7 +1910,12 @@ static void s_patloop(PLAYER *p, chn_t *ch)
|
||||||
p->np_patoff = -1; // force reseek
|
p->np_patoff = -1; // force reseek
|
||||||
|
|
||||||
if (p->patloopstart == 0)
|
if (p->patloopstart == 0)
|
||||||
p->playedOrder[(p->np_ord - 1) / 8] &= ~(1 << ((p->np_ord - 1) % 8));
|
{
|
||||||
|
offset = (p->np_ord - 1) / 8;
|
||||||
|
bit = 1 << ((p->np_ord - 1) % 8);
|
||||||
|
|
||||||
|
p->playedOrder[offset] &= ~bit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1963,7 +1978,7 @@ static void s_setspeed(PLAYER *p, chn_t *ch)
|
||||||
|
|
||||||
static void s_jmpto(PLAYER *p, chn_t *ch)
|
static void s_jmpto(PLAYER *p, chn_t *ch)
|
||||||
{
|
{
|
||||||
if (ch->info != 255)
|
if (ch->info != 0xFF)
|
||||||
{
|
{
|
||||||
p->breakpat = 1;
|
p->breakpat = 1;
|
||||||
p->np_ord = ch->info;
|
p->np_ord = ch->info;
|
||||||
|
@ -1987,7 +2002,7 @@ static void s_volslide(PLAYER *p, chn_t *ch)
|
||||||
|
|
||||||
getlastnfo(p, ch);
|
getlastnfo(p, ch);
|
||||||
|
|
||||||
infohi = ch->info >> 0x04;
|
infohi = ch->info >> 4;
|
||||||
infolo = ch->info & 0x0F;
|
infolo = ch->info & 0x0F;
|
||||||
|
|
||||||
if (infolo == 0x0F)
|
if (infolo == 0x0F)
|
||||||
|
@ -2017,14 +2032,12 @@ static void s_volslide(PLAYER *p, chn_t *ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch->avol < 0) ch->avol = 0;
|
if (ch->avol < 0) ch->avol = 0;
|
||||||
if (ch->avol > 63) ch->avol = 63;
|
else if (ch->avol > 63) ch->avol = 63;
|
||||||
|
|
||||||
setvol(p, ch->channelnum, 0, 0);
|
setvol(p, ch->channelnum, 0, 0);
|
||||||
|
|
||||||
if (p->volslidetype == 1)
|
if (p->volslidetype == 1) s_vibrato(p, ch);
|
||||||
s_vibrato(p, ch);
|
else if (p->volslidetype == 2) s_toneslide(p, ch);
|
||||||
else if (p->volslidetype == 2)
|
|
||||||
s_toneslide(p, ch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_slidedown(PLAYER *p, chn_t *ch)
|
static void s_slidedown(PLAYER *p, chn_t *ch)
|
||||||
|
@ -2037,7 +2050,7 @@ static void s_slidedown(PLAYER *p, chn_t *ch)
|
||||||
{
|
{
|
||||||
if (ch->info >= 0xE0) return; // no fine slides here
|
if (ch->info >= 0xE0) return; // no fine slides here
|
||||||
|
|
||||||
ch->aspd += ((uint16_t)(ch->info) << 2);
|
ch->aspd += (ch->info * 4);
|
||||||
if (ch->aspd > 32767) ch->aspd = 32767;
|
if (ch->aspd > 32767) ch->aspd = 32767;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2051,7 +2064,7 @@ static void s_slidedown(PLAYER *p, chn_t *ch)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch->aspd += ((ch->info & 0x0F) << 2);
|
ch->aspd += ((ch->info & 0x0F) * 4);
|
||||||
if (ch->aspd > 32767) ch->aspd = 32767;
|
if (ch->aspd > 32767) ch->aspd = 32767;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2071,7 +2084,7 @@ static void s_slideup(PLAYER *p, chn_t *ch)
|
||||||
{
|
{
|
||||||
if (ch->info >= 0xE0) return; // no fine slides here
|
if (ch->info >= 0xE0) return; // no fine slides here
|
||||||
|
|
||||||
ch->aspd -= ((uint16_t)(ch->info) << 2);
|
ch->aspd -= (ch->info * 4);
|
||||||
if (ch->aspd < 0) ch->aspd = 0;
|
if (ch->aspd < 0) ch->aspd = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2085,7 +2098,7 @@ static void s_slideup(PLAYER *p, chn_t *ch)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch->aspd -= ((ch->info & 0x0F) << 2);
|
ch->aspd -= ((ch->info & 0x0F) * 4);
|
||||||
if (ch->aspd < 0) ch->aspd = 0;
|
if (ch->aspd < 0) ch->aspd = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2122,13 +2135,13 @@ static void s_toneslide(PLAYER *p, chn_t *ch)
|
||||||
{
|
{
|
||||||
if (ch->aorgspd < ch->asldspd)
|
if (ch->aorgspd < ch->asldspd)
|
||||||
{
|
{
|
||||||
ch->aorgspd += ((uint16_t)(ch->info) << 2);
|
ch->aorgspd += (ch->info * 4);
|
||||||
if (ch->aorgspd > ch->asldspd)
|
if (ch->aorgspd > ch->asldspd)
|
||||||
ch->aorgspd = ch->asldspd;
|
ch->aorgspd = ch->asldspd;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch->aorgspd -= ((uint16_t)(ch->info) << 2);
|
ch->aorgspd -= (ch->info * 4);
|
||||||
if (ch->aorgspd < ch->asldspd)
|
if (ch->aorgspd < ch->asldspd)
|
||||||
ch->aorgspd = ch->asldspd;
|
ch->aorgspd = ch->asldspd;
|
||||||
}
|
}
|
||||||
|
@ -2180,7 +2193,7 @@ static void s_vibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ramp
|
// ramp
|
||||||
|
@ -2195,7 +2208,7 @@ static void s_vibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibramp[cnt >> 1];
|
dat = vibramp[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// square
|
// square
|
||||||
|
@ -2210,7 +2223,7 @@ static void s_vibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsqu[cnt >> 1];
|
dat = vibsqu[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// random
|
// random
|
||||||
|
@ -2225,7 +2238,7 @@ static void s_vibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = (int32_t)(vibsin[cnt >> 1]);
|
dat = vibsin[cnt / 2];
|
||||||
cnt += (p->patmusicrand & 0x1E);
|
cnt += (p->patmusicrand & 0x1E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2243,7 +2256,7 @@ static void s_vibrato(PLAYER *p, chn_t *ch)
|
||||||
ch->aspd = dat;
|
ch->aspd = dat;
|
||||||
setspd(p, ch->channelnum);
|
setspd(p, ch->channelnum);
|
||||||
|
|
||||||
ch->avibcnt = (cnt + ((ch->info >> 4) << 1)) & 0x7E;
|
ch->avibcnt = (cnt + ((ch->info >> 4) * 2)) & 0x7E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2287,16 +2300,15 @@ static void s_arp(PLAYER *p, chn_t *ch)
|
||||||
getlastnfo(p, ch);
|
getlastnfo(p, ch);
|
||||||
|
|
||||||
tick = p->musiccount % 3;
|
tick = p->musiccount % 3;
|
||||||
noteadd = 0;
|
|
||||||
|
|
||||||
if (tick == 1)
|
if (tick == 1) noteadd = ch->info >> 4;
|
||||||
noteadd = ch->info >> 4;
|
else if (tick == 2) noteadd = ch->info & 0x0F;
|
||||||
else if (tick == 2)
|
else noteadd = 0;
|
||||||
noteadd = ch->info & 0x0F;
|
|
||||||
|
|
||||||
// check for octave overflow
|
// check for octave overflow
|
||||||
octa = ch->lastnote & 0xF0;
|
octa = ch->lastnote & 0xF0;
|
||||||
note = (ch->lastnote & 0x0F) + noteadd;
|
note = (ch->lastnote & 0x0F) + noteadd;
|
||||||
|
|
||||||
while (note >= 12)
|
while (note >= 12)
|
||||||
{
|
{
|
||||||
note -= 12;
|
note -= 12;
|
||||||
|
@ -2330,7 +2342,7 @@ static void s_chanvolslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
else
|
else
|
||||||
ch->info = ch->nxymem;
|
ch->info = ch->nxymem;
|
||||||
|
|
||||||
infohi = ch->nxymem >> 0x04;
|
infohi = ch->nxymem >> 4;
|
||||||
infolo = ch->nxymem & 0x0F;
|
infolo = ch->nxymem & 0x0F;
|
||||||
|
|
||||||
if (infolo == 0x0F)
|
if (infolo == 0x0F)
|
||||||
|
@ -2360,7 +2372,7 @@ static void s_chanvolslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch->chanvol < 0) ch->chanvol = 0;
|
if (ch->chanvol < 0) ch->chanvol = 0;
|
||||||
if (ch->chanvol > 64) ch->chanvol = 64;
|
else if (ch->chanvol > 64) ch->chanvol = 64;
|
||||||
|
|
||||||
setvol(p, ch->channelnum, 0, 0);
|
setvol(p, ch->channelnum, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -2390,29 +2402,29 @@ static void s_panslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
else
|
else
|
||||||
ch->info = ch->pxymem;
|
ch->info = ch->pxymem;
|
||||||
|
|
||||||
infohi = ch->pxymem >> 0x04;
|
infohi = ch->pxymem >> 4;
|
||||||
infolo = ch->pxymem & 0x0F;
|
infolo = ch->pxymem & 0x0F;
|
||||||
|
|
||||||
if (infolo == 0x0F)
|
if (infolo == 0x0F)
|
||||||
{
|
{
|
||||||
if (!infohi)
|
if (!infohi)
|
||||||
ch->apanpos += (infolo << 2);
|
ch->apanpos += (infolo * 4);
|
||||||
else if (!p->musiccount)
|
else if (!p->musiccount)
|
||||||
ch->apanpos -= (infohi << 2);
|
ch->apanpos -= (infohi * 4);
|
||||||
}
|
}
|
||||||
else if (infohi == 0x0F)
|
else if (infohi == 0x0F)
|
||||||
{
|
{
|
||||||
if (!infolo)
|
if (!infolo)
|
||||||
ch->apanpos -= (infohi << 2);
|
ch->apanpos -= (infohi * 4);
|
||||||
else if (!p->musiccount)
|
else if (!p->musiccount)
|
||||||
ch->apanpos += (infolo << 2);
|
ch->apanpos += (infolo * 4);
|
||||||
}
|
}
|
||||||
else if (p->musiccount) // don't rely on fastvolslide flag here
|
else if (p->musiccount) // don't rely on fastvolslide flag here
|
||||||
{
|
{
|
||||||
if (!infolo)
|
if (!infolo)
|
||||||
ch->apanpos -= (infohi << 2);
|
ch->apanpos -= (infohi * 4);
|
||||||
else
|
else
|
||||||
ch->apanpos += (infolo << 2);
|
ch->apanpos += (infolo * 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2420,7 +2432,7 @@ static void s_panslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch->apanpos < 0) ch->apanpos = 0;
|
if (ch->apanpos < 0) ch->apanpos = 0;
|
||||||
if (ch->apanpos > 256) ch->apanpos = 256;
|
else if (ch->apanpos > 256) ch->apanpos = 256;
|
||||||
|
|
||||||
setpan(p, ch->channelnum);
|
setpan(p, ch->channelnum);
|
||||||
}
|
}
|
||||||
|
@ -2431,7 +2443,7 @@ static void s_retrig(PLAYER *p, chn_t *ch)
|
||||||
uint8_t infohi;
|
uint8_t infohi;
|
||||||
|
|
||||||
getlastnfo(p, ch);
|
getlastnfo(p, ch);
|
||||||
infohi = ch->info >> 0x04;
|
infohi = ch->info >> 4;
|
||||||
|
|
||||||
if (!(ch->info & 0x0F) || (ch->atrigcnt < (ch->info & 0x0F)))
|
if (!(ch->info & 0x0F) || (ch->atrigcnt < (ch->info & 0x0F)))
|
||||||
{
|
{
|
||||||
|
@ -2447,10 +2459,10 @@ static void s_retrig(PLAYER *p, chn_t *ch)
|
||||||
if (!retrigvoladd[16 + infohi])
|
if (!retrigvoladd[16 + infohi])
|
||||||
ch->avol += retrigvoladd[infohi];
|
ch->avol += retrigvoladd[infohi];
|
||||||
else
|
else
|
||||||
ch->avol = (int8_t)(((int16_t)(ch->avol) * retrigvoladd[16 + infohi]) >> 4);
|
ch->avol = (int8_t)((ch->avol * retrigvoladd[16 + infohi]) / 16);
|
||||||
|
|
||||||
if (ch->avol > 63) ch->avol = 63;
|
if (ch->avol > 63) ch->avol = 63;
|
||||||
if (ch->avol < 0) ch->avol = 0;
|
else if (ch->avol < 0) ch->avol = 0;
|
||||||
|
|
||||||
setvol(p, ch->channelnum, 0, 0);
|
setvol(p, ch->channelnum, 0, 0);
|
||||||
|
|
||||||
|
@ -2487,7 +2499,7 @@ static void s_tremolo(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ramp
|
// ramp
|
||||||
|
@ -2502,7 +2514,7 @@ static void s_tremolo(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibramp[cnt >> 1];
|
dat = vibramp[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// square
|
// square
|
||||||
|
@ -2517,7 +2529,7 @@ static void s_tremolo(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsqu[cnt >> 1];
|
dat = vibsqu[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// random
|
// random
|
||||||
|
@ -2532,7 +2544,7 @@ static void s_tremolo(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
cnt += (p->patmusicrand & 0x1E);
|
cnt += (p->patmusicrand & 0x1E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2543,13 +2555,14 @@ static void s_tremolo(PLAYER *p, chn_t *ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = ((dat * (ch->info & 0x0F)) >> 7) + ch->aorgvol;
|
dat = ((dat * (ch->info & 0x0F)) >> 7) + ch->aorgvol;
|
||||||
|
|
||||||
if (dat > 63) dat = 63;
|
if (dat > 63) dat = 63;
|
||||||
if (dat < 0) dat = 0;
|
else if (dat < 0) dat = 0;
|
||||||
|
|
||||||
ch->avol = (int8_t)(dat);
|
ch->avol = (int8_t)(dat);
|
||||||
setvol(p, ch->channelnum, 0, 0);
|
setvol(p, ch->channelnum, 0, 0);
|
||||||
|
|
||||||
ch->avibcnt = (cnt + ((ch->info >> 4) << 1)) & 0x7E;
|
ch->avibcnt = (cnt + ((ch->info >> 4) * 2)) & 0x7E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2632,7 +2645,7 @@ static void s_finevibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ramp
|
// ramp
|
||||||
|
@ -2647,7 +2660,7 @@ static void s_finevibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibramp[cnt >> 1];
|
dat = vibramp[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// square
|
// square
|
||||||
|
@ -2662,7 +2675,7 @@ static void s_finevibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsqu[cnt >> 1];
|
dat = vibsqu[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// random
|
// random
|
||||||
|
@ -2677,7 +2690,7 @@ static void s_finevibrato(PLAYER *p, chn_t *ch)
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
cnt += (p->patmusicrand & 0x1E);
|
cnt += (p->patmusicrand & 0x1E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2695,7 +2708,7 @@ static void s_finevibrato(PLAYER *p, chn_t *ch)
|
||||||
ch->aspd = dat;
|
ch->aspd = dat;
|
||||||
setspd(p, ch->channelnum);
|
setspd(p, ch->channelnum);
|
||||||
|
|
||||||
ch->avibcnt = (cnt + ((ch->info >> 4) << 1)) & 0x7E;
|
ch->avibcnt = (cnt + ((ch->info >> 4) * 2)) & 0x7E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2718,7 +2731,7 @@ static void s_globvolslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
else
|
else
|
||||||
ch->info = ch->wxymem;
|
ch->info = ch->wxymem;
|
||||||
|
|
||||||
infohi = ch->wxymem >> 0x04;
|
infohi = ch->wxymem >> 4;
|
||||||
infolo = ch->wxymem & 0x0F;
|
infolo = ch->wxymem & 0x0F;
|
||||||
|
|
||||||
if (infolo == 0x0F)
|
if (infolo == 0x0F)
|
||||||
|
@ -2748,10 +2761,11 @@ static void s_globvolslide(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->globalvol < 0) p->globalvol = 0;
|
if (p->globalvol < 0) p->globalvol = 0;
|
||||||
if (p->globalvol > 64) p->globalvol = 64;
|
else if (p->globalvol > 64) p->globalvol = 64;
|
||||||
|
|
||||||
// update all channels now
|
// update all channels now
|
||||||
for (i = 0; i < (p->lastachannelused + 1); ++i) setvol(p, i, 0, 0);
|
for (i = 0; i < (p->lastachannelused + 1); ++i)
|
||||||
|
setvol(p, i, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2765,7 +2779,7 @@ static void s_setpan(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
ch->surround = 0;
|
ch->surround = 0;
|
||||||
voiceSetSurround(p, ch->channelnum, 0);
|
voiceSetSurround(p, ch->channelnum, 0);
|
||||||
|
|
||||||
ch->apanpos = (int16_t)(ch->info) << 1;
|
ch->apanpos = ch->info * 2;
|
||||||
setpan(p, ch->channelnum);
|
setpan(p, ch->channelnum);
|
||||||
}
|
}
|
||||||
else if (ch->info == 0xA4) // surround
|
else if (ch->info == 0xA4) // surround
|
||||||
|
@ -2815,7 +2829,7 @@ static void s_panbrello(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ramp
|
// ramp
|
||||||
|
@ -2830,7 +2844,7 @@ static void s_panbrello(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibramp[cnt >> 1];
|
dat = vibramp[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// square
|
// square
|
||||||
|
@ -2845,7 +2859,7 @@ static void s_panbrello(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsqu[cnt >> 1];
|
dat = vibsqu[cnt / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
// random
|
// random
|
||||||
|
@ -2860,7 +2874,7 @@ static void s_panbrello(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
if (cnt & 0x80) cnt = 0;
|
if (cnt & 0x80) cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = vibsin[cnt >> 1];
|
dat = vibsin[cnt / 2];
|
||||||
cnt += (p->patmusicrand & 0x1E);
|
cnt += (p->patmusicrand & 0x1E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2873,11 +2887,11 @@ static void s_panbrello(PLAYER *p, chn_t *ch) // NON-ST3
|
||||||
dat = ((dat * (ch->info & 0x0F)) >> 4) + ch->apanpos;
|
dat = ((dat * (ch->info & 0x0F)) >> 4) + ch->apanpos;
|
||||||
|
|
||||||
if (dat < 0) dat = 0;
|
if (dat < 0) dat = 0;
|
||||||
if (dat > 256) dat = 256;
|
else if (dat > 256) dat = 256;
|
||||||
|
|
||||||
voiceSetPanning(p, ch->channelnum, dat);
|
voiceSetPanning(p, ch->channelnum, dat);
|
||||||
|
|
||||||
ch->apancnt = (cnt + ((ch->info >> 6) << 1)) & 0x7E;
|
ch->apancnt = (cnt + ((ch->info >> 6) * 2)) & 0x7E;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3106,7 +3120,7 @@ static inline void mix8b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
while (interpolating > 0 && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
||||||
{
|
{
|
||||||
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 8);
|
resampler_write_sample_fixed(resampler, sampleData[samplePosition], 8);
|
||||||
|
|
||||||
|
@ -3124,7 +3138,7 @@ static inline void mix8b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
if (samplePosition < 0)
|
if (samplePosition < 0)
|
||||||
{
|
{
|
||||||
samplePosition = 0;
|
samplePosition = 0;
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3140,11 +3154,17 @@ static inline void mix8b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (samplePosition >= sampleLength)
|
if (samplePosition >= sampleLength)
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler, 0, 8);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->interpolating = (int8_t)(interpolating);
|
v->interpolating = (int8_t)(interpolating);
|
||||||
|
|
||||||
|
@ -3269,7 +3289,7 @@ static inline void mix8bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler[0]) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
(!resampler_get_sample_count(resampler[0]) &&
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
!resampler_get_sample_count(resampler[1]))))
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
{
|
{
|
||||||
|
@ -3290,7 +3310,7 @@ static inline void mix8bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
if (samplePosition < 0)
|
if (samplePosition < 0)
|
||||||
{
|
{
|
||||||
samplePosition = 0;
|
samplePosition = 0;
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3306,11 +3326,20 @@ static inline void mix8bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (samplePosition >= sampleLength)
|
if (samplePosition >= sampleLength)
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler[0], 0, 8);
|
||||||
|
resampler_write_sample_fixed(resampler[1], 0, 8);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->interpolating = (int8_t)(interpolating);
|
v->interpolating = (int8_t)(interpolating);
|
||||||
|
|
||||||
|
@ -3432,7 +3461,7 @@ static inline void mix16b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
while (interpolating > 0 && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
||||||
{
|
{
|
||||||
resampler_write_sample_fixed(resampler, (int16_t)(get_le16(&sampleData[samplePosition])), 16);
|
resampler_write_sample_fixed(resampler, (int16_t)(get_le16(&sampleData[samplePosition])), 16);
|
||||||
|
|
||||||
|
@ -3450,7 +3479,7 @@ static inline void mix16b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
if (samplePosition < 0)
|
if (samplePosition < 0)
|
||||||
{
|
{
|
||||||
samplePosition = 0;
|
samplePosition = 0;
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3466,11 +3495,17 @@ static inline void mix16b(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (samplePosition >= sampleLength)
|
if (samplePosition >= sampleLength)
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler) || !resampler_get_sample_count(resampler)))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler, 0, 16);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->interpolating = (int8_t)(interpolating);
|
v->interpolating = (int8_t)(interpolating);
|
||||||
|
|
||||||
|
@ -3595,7 +3630,7 @@ static inline void mix16bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
{
|
{
|
||||||
samplePosition = v->samplePosition;
|
samplePosition = v->samplePosition;
|
||||||
|
|
||||||
while (interpolating && (resampler_get_free_count(resampler[0]) ||
|
while (interpolating > 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
(!resampler_get_sample_count(resampler[0]) &&
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
!resampler_get_sample_count(resampler[1]))))
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
{
|
{
|
||||||
|
@ -3616,7 +3651,7 @@ static inline void mix16bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
if (samplePosition < 0)
|
if (samplePosition < 0)
|
||||||
{
|
{
|
||||||
samplePosition = 0;
|
samplePosition = 0;
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3632,11 +3667,20 @@ static inline void mix16bstereo(PLAYER *p, uint8_t ch, uint32_t samples)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (samplePosition >= sampleLength)
|
if (samplePosition >= sampleLength)
|
||||||
interpolating = 0;
|
interpolating = -resampler_get_padding_size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (interpolating < 0 && (resampler_get_free_count(resampler[0]) ||
|
||||||
|
(!resampler_get_sample_count(resampler[0]) &&
|
||||||
|
!resampler_get_sample_count(resampler[1]))))
|
||||||
|
{
|
||||||
|
resampler_write_sample_fixed(resampler[0], 0, 16);
|
||||||
|
resampler_write_sample_fixed(resampler[1], 0, 16);
|
||||||
|
++interpolating;
|
||||||
|
}
|
||||||
|
|
||||||
v->samplePosition = samplePosition;
|
v->samplePosition = samplePosition;
|
||||||
v->interpolating = (int8_t)(interpolating);
|
v->interpolating = (int8_t)(interpolating);
|
||||||
|
|
||||||
|
@ -3840,7 +3884,7 @@ void st3play_RenderFloat(void *_p, float *buffer, int32_t count)
|
||||||
if (p->fmChip && p->fmResampler)
|
if (p->fmChip && p->fmResampler)
|
||||||
st3play_AdlibMix(p, outputStream, samplesTodo);
|
st3play_AdlibMix(p, outputStream, samplesTodo);
|
||||||
|
|
||||||
outputStream += (samplesTodo << 1);
|
outputStream += (samplesTodo * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->samplesLeft -= samplesTodo;
|
p->samplesLeft -= samplesTodo;
|
||||||
|
@ -3923,16 +3967,18 @@ void st3play_RenderFixed16(void *_p, int16_t *buffer, int32_t count, int8_t dept
|
||||||
|
|
||||||
void FreeSong(PLAYER *p)
|
void FreeSong(PLAYER *p)
|
||||||
{
|
{
|
||||||
|
uint16_t i;
|
||||||
|
|
||||||
p->Playing = 0;
|
p->Playing = 0;
|
||||||
|
|
||||||
if (p->adpcmSamples)
|
if (p->adpcmSamples != NULL)
|
||||||
{
|
{
|
||||||
int i, j;
|
for (i = 0; i < get_le16(&p->mseg[0x22]); ++i)
|
||||||
for (i = 0, j = get_le16(&p->mseg[0x22]); i < j; i++)
|
|
||||||
{
|
{
|
||||||
if (p->adpcmSamples[i])
|
if (p->adpcmSamples[i] != NULL)
|
||||||
free(p->adpcmSamples[i]);
|
free(p->adpcmSamples[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(p->adpcmSamples);
|
free(p->adpcmSamples);
|
||||||
p->adpcmSamples = NULL;
|
p->adpcmSamples = NULL;
|
||||||
}
|
}
|
||||||
|
@ -3951,7 +3997,8 @@ void FreeSong(PLAYER *p)
|
||||||
void st3play_Mute(void *_p, int8_t channel, int8_t mute)
|
void st3play_Mute(void *_p, int8_t channel, int8_t mute)
|
||||||
{
|
{
|
||||||
PLAYER *p;
|
PLAYER *p;
|
||||||
int8_t mask;
|
int8_t offset;
|
||||||
|
int8_t bit;
|
||||||
uint8_t adlibChannel;
|
uint8_t adlibChannel;
|
||||||
|
|
||||||
if (channel > 31)
|
if (channel > 31)
|
||||||
|
@ -3960,12 +4007,14 @@ void st3play_Mute(void *_p, int8_t channel, int8_t mute)
|
||||||
p = (PLAYER *)(_p);
|
p = (PLAYER *)(_p);
|
||||||
|
|
||||||
adlibChannel = (p->mseg[0x40 + channel] & 0x7F) - 16;
|
adlibChannel = (p->mseg[0x40 + channel] & 0x7F) - 16;
|
||||||
mask = 1 << (channel % 8);
|
|
||||||
|
offset = channel / 8;
|
||||||
|
bit = 1 << (channel % 8);
|
||||||
|
|
||||||
if (mute)
|
if (mute)
|
||||||
p->muted[channel / 8] |= mask;
|
p->muted[offset] |= bit;
|
||||||
else
|
else
|
||||||
p->muted[channel / 8] &= ~mask;
|
p->muted[offset] &= ~bit;
|
||||||
|
|
||||||
if (adlibChannel < 9)
|
if (adlibChannel < 9)
|
||||||
Chip_Mute(p->fmChip, adlibChannel, mute);
|
Chip_Mute(p->fmChip, adlibChannel, mute);
|
||||||
|
|
Loading…
Reference in New Issue