mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-27 15:03:01 +00:00
more mzpokeysnd changes
This commit is contained in:
parent
a8071a3c9f
commit
139ac97144
1 changed files with 80 additions and 196 deletions
|
@ -394,47 +394,6 @@ static void ResetPokeyState(PokeyState* ps)
|
|||
ps->speaker = 0;
|
||||
}
|
||||
|
||||
|
||||
static double read_resam_all(PokeyState* ps)
|
||||
{
|
||||
int i = ps->qebeg;
|
||||
qev_t avol,bvol;
|
||||
double sum;
|
||||
|
||||
if(ps->qebeg == ps->qeend)
|
||||
{
|
||||
return ps->ovola * filter_data[0]; /* if no events in the queue */
|
||||
}
|
||||
|
||||
avol = ps->ovola;
|
||||
sum = 0;
|
||||
|
||||
/* Separate two loop cases, for wrap-around and without */
|
||||
if(ps->qeend < ps->qebeg) /* With wrap */
|
||||
{
|
||||
while(i<filter_size)
|
||||
{
|
||||
bvol = ps->qev[i];
|
||||
sum += (avol-bvol)*filter_data[ps->curtick - ps->qet[i]];
|
||||
avol = bvol;
|
||||
++i;
|
||||
}
|
||||
i=0;
|
||||
}
|
||||
|
||||
/* without wrap */
|
||||
while(i<ps->qeend)
|
||||
{
|
||||
bvol = ps->qev[i];
|
||||
sum += (avol-bvol)*filter_data[ps->curtick - ps->qet[i]];
|
||||
avol = bvol;
|
||||
++i;
|
||||
}
|
||||
|
||||
sum += avol*filter_data[0];
|
||||
return sum;
|
||||
}
|
||||
|
||||
#ifdef SYNCHRONIZED_SOUND
|
||||
/* linear interpolation of filter data */
|
||||
static double interp_filter_data(int pos, double frac)
|
||||
|
@ -490,15 +449,6 @@ static double interp_read_resam_all(PokeyState* ps, double frac)
|
|||
}
|
||||
#endif /* SYNCHRONIZED_SOUND */
|
||||
|
||||
static void add_change(PokeyState* ps, qev_t a)
|
||||
{
|
||||
ps->qev[ps->qeend] = a;
|
||||
ps->qet[ps->qeend] = ps->curtick; /*0;*/
|
||||
++ps->qeend;
|
||||
if(ps->qeend >= filter_size)
|
||||
ps->qeend = 0;
|
||||
}
|
||||
|
||||
static void bump_qe_subticks(PokeyState* ps, int subticks)
|
||||
{
|
||||
/* Remove too old events from the queue while bumping */
|
||||
|
@ -939,7 +889,6 @@ static void advance_ticks(PokeyState* ps, int ticks)
|
|||
if(outvol_new != ps->outvol_all)
|
||||
{
|
||||
ps->outvol_all = outvol_new;
|
||||
add_change(ps, outvol_new);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1060,6 @@ static void advance_ticks(PokeyState* ps, int ticks)
|
|||
if(outvol_new != ps->outvol_all)
|
||||
{
|
||||
ps->outvol_all = outvol_new;
|
||||
add_change(ps, outvol_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1123,7 +1071,7 @@ static double generate_sample(PokeyState* ps)
|
|||
subticks = (subticks+pokey_frq)%POKEYSND_playback_freq;*/
|
||||
|
||||
advance_ticks(ps, pokey_frq/POKEYSND_playback_freq);
|
||||
return read_resam_all(ps);
|
||||
return ps->outvol_all;
|
||||
}
|
||||
|
||||
/******************************************
|
||||
|
@ -1217,9 +1165,6 @@ found:
|
|||
void mzpokeysnd_process_8(void* sndbuffer, int sndn);
|
||||
void mzpokeysnd_process_16(void* sndbuffer, int sndn);
|
||||
void Update_pokey_sound_mz(UWORD addr, UBYTE val, UBYTE gain);
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
static void Update_vol_only_sound_mz( void );
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module: MZPOKEYSND_Init() */
|
||||
|
@ -1258,14 +1203,6 @@ int MZPOKEYSND_Init(size_t freq17, int playback_freq,
|
|||
snd_quality = quality;
|
||||
|
||||
POKEYSND_Update_ptr = Update_pokey_sound_mz;
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
POKEYSND_UpdateVolOnly = Update_vol_only_sound_mz;
|
||||
#endif
|
||||
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
POKEYSND_samp_freq=playback_freq;
|
||||
#endif /* VOL_ONLY_SOUND */
|
||||
|
||||
POKEYSND_Process_ptr = (flags & POKEYSND_BIT16) ? mzpokeysnd_process_16 : mzpokeysnd_process_8;
|
||||
|
||||
pokey_frq = (int)(((double)pokey_frq_ideal/POKEYSND_playback_freq) + 0.5)
|
||||
|
@ -2165,32 +2102,8 @@ void mzpokeysnd_process_8(void* sndbuffer, int sndn)
|
|||
we assume even sndn */
|
||||
while(nsam >= 1)
|
||||
{
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
if( POKEYSND_sampbuf_rptr!=POKEYSND_sampbuf_ptr )
|
||||
{ int l;
|
||||
if( POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]>0 )
|
||||
POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]-=1280;
|
||||
while( (l=POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr])<=0 )
|
||||
{ POKEYSND_sampout=POKEYSND_sampbuf_val[POKEYSND_sampbuf_rptr];
|
||||
POKEYSND_sampbuf_rptr++;
|
||||
if( POKEYSND_sampbuf_rptr>=POKEYSND_SAMPBUF_MAX )
|
||||
POKEYSND_sampbuf_rptr=0;
|
||||
if( POKEYSND_sampbuf_rptr!=POKEYSND_sampbuf_ptr )
|
||||
{
|
||||
POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]+=l;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
buffer[0] = (UBYTE)floor((generate_sample(pokey_states) + POKEYSND_sampout)
|
||||
* (255.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 128 + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
#else
|
||||
buffer[0] = (UBYTE)floor(generate_sample(pokey_states)
|
||||
* (255.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 128 + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
#endif
|
||||
buffer += 1;
|
||||
nsam -= 1;
|
||||
}
|
||||
|
@ -2206,31 +2119,8 @@ void mzpokeysnd_process_16(void* sndbuffer, int sndn)
|
|||
we assume even sndn */
|
||||
while(nsam >= (int) 1)
|
||||
{
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
if( POKEYSND_sampbuf_rptr!=POKEYSND_sampbuf_ptr )
|
||||
{ int l;
|
||||
if( POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]>0 )
|
||||
POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]-=1280;
|
||||
while( (l=POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr])<=0 )
|
||||
{ POKEYSND_sampout=POKEYSND_sampbuf_val[POKEYSND_sampbuf_rptr];
|
||||
POKEYSND_sampbuf_rptr++;
|
||||
if( POKEYSND_sampbuf_rptr>=POKEYSND_SAMPBUF_MAX )
|
||||
POKEYSND_sampbuf_rptr=0;
|
||||
if( POKEYSND_sampbuf_rptr!=POKEYSND_sampbuf_ptr )
|
||||
{
|
||||
POKEYSND_sampbuf_cnt[POKEYSND_sampbuf_rptr]+=l;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
buffer[0] = (SWORD)floor((generate_sample(pokey_states) + POKEYSND_sampout)
|
||||
* (65535.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
#else
|
||||
buffer[0] = (SWORD)floor(generate_sample(pokey_states)
|
||||
* (65535.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
#endif
|
||||
buffer += 1;
|
||||
nsam -= 1;
|
||||
}
|
||||
|
@ -2286,9 +2176,3 @@ static void generate_sync(unsigned int num_ticks)
|
|||
}
|
||||
#endif /* SYNCHRONIZED_SOUND */
|
||||
|
||||
|
||||
#ifdef VOL_ONLY_SOUND
|
||||
static void Update_vol_only_sound_mz( void )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue