mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-09-10 16:53:15 +02:00
fixed YM2612 reset on "soft reset"
small optimizations & fixes in FIR resampler code
This commit is contained in:
parent
f734e2fade
commit
f44d38b537
@ -146,6 +146,7 @@ void gen_reset(uint32 hard_reset)
|
||||
/* Reset CPUs */
|
||||
resetline = -1;
|
||||
gen_running = 1;
|
||||
fm_reset(0);
|
||||
m68k_pulse_reset();
|
||||
z80_reset();
|
||||
}
|
||||
@ -214,8 +215,8 @@ void gen_reset_w(uint32 state)
|
||||
}
|
||||
|
||||
/* Reset Z80 & YM2612 */
|
||||
fm_reset(mcycles_68k);
|
||||
z80_reset();
|
||||
fm_reset();
|
||||
|
||||
/* update Z80 bus status */
|
||||
zstate &= 2;
|
||||
|
@ -53,7 +53,7 @@ static void gen_sinc(double rolloff, int width, double offset, double spacing, d
|
||||
}
|
||||
}
|
||||
|
||||
static int available( long input_count )
|
||||
/*static int available( long input_count )
|
||||
{
|
||||
int cycle_count = input_count / input_per_cycle;
|
||||
int output_count = cycle_count * res * STEREO;
|
||||
@ -74,6 +74,36 @@ static int available( long input_count )
|
||||
}
|
||||
return output_count;
|
||||
}
|
||||
*/
|
||||
int Fir_Resampler_avail()
|
||||
{
|
||||
long count = 0;
|
||||
sample_t* in = buffer;
|
||||
sample_t* end_pos = write_pos;
|
||||
unsigned long skip = skip_bits >> imp_phase;
|
||||
int remain = res - imp_phase;
|
||||
if ( end_pos - in >= WIDTH * STEREO )
|
||||
{
|
||||
end_pos -= WIDTH * STEREO;
|
||||
do
|
||||
{
|
||||
count++;
|
||||
remain--;
|
||||
in += (skip * STEREO) & STEREO;
|
||||
skip >>= 1;
|
||||
in += step;
|
||||
|
||||
if ( !remain )
|
||||
{
|
||||
skip = skip_bits;
|
||||
remain = res;
|
||||
}
|
||||
}
|
||||
while ( in <= end_pos );
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
int Fir_Resampler_initialize( int new_size )
|
||||
{
|
||||
@ -191,10 +221,10 @@ int Fir_Resampler_written( void )
|
||||
}
|
||||
|
||||
/* Number of output samples available */
|
||||
int Fir_Resampler_avail( void )
|
||||
/*int Fir_Resampler_avail( void )
|
||||
{
|
||||
return available( write_pos - &buffer [WIDTH * STEREO] );
|
||||
}
|
||||
}*/
|
||||
|
||||
void Fir_Resampler_write( long count )
|
||||
{
|
||||
@ -274,13 +304,14 @@ int Fir_Resampler_read( sample_t* out, long count )
|
||||
return out - out_;
|
||||
}
|
||||
|
||||
/* fixed (Eke_Eke) */
|
||||
int Fir_Resampler_input_needed( long output_count )
|
||||
{
|
||||
long input_count = 0;
|
||||
|
||||
unsigned long skip = skip_bits >> imp_phase;
|
||||
int remain = res - imp_phase;
|
||||
while ( (output_count) > 0 ) /* fixed (Eke_Eke) */
|
||||
while ( (output_count) > 0 )
|
||||
{
|
||||
input_count += step + (skip & 1) * STEREO;
|
||||
skip >>= 1;
|
||||
@ -289,13 +320,13 @@ int Fir_Resampler_input_needed( long output_count )
|
||||
skip = skip_bits;
|
||||
remain = res;
|
||||
}
|
||||
output_count -= 2;
|
||||
output_count --;
|
||||
}
|
||||
|
||||
long input_extra = input_count - (write_pos - &buffer [WRITE_OFFSET]);
|
||||
if ( input_extra < 0 )
|
||||
input_extra = 0;
|
||||
return input_extra;
|
||||
return (input_extra >> 1);
|
||||
}
|
||||
|
||||
int Fir_Resampler_skip_input( long count )
|
||||
|
@ -148,7 +148,7 @@ void sound_init(void)
|
||||
Fir_Resampler_time_ratio(mclk / (double)snd.sample_rate / (144.0 * 7.0));
|
||||
}
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d mcycles per PSG samples\n", psg_cycles_ratio);
|
||||
error("%d mcycles per FM samples\n", fm_cycles_ratio);
|
||||
#endif
|
||||
@ -172,26 +172,26 @@ int sound_update(unsigned int cycles)
|
||||
/* number of available samples */
|
||||
int size = snd.psg.pos - snd.psg.buffer;
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
error("%d PSG samples available\n",snd.psg.pos - snd.psg.buffer);
|
||||
#ifdef LOGSOUND
|
||||
error("%d PSG samples available\n",size);
|
||||
#endif
|
||||
|
||||
/* FM resampling */
|
||||
if (config.hq_fm)
|
||||
{
|
||||
/* resynchronize FM & PSG chips */
|
||||
int remain = Fir_Resampler_input_needed(size << 1) >> 1;
|
||||
|
||||
/* get remaining FM samples */
|
||||
int remain = Fir_Resampler_input_needed(size);
|
||||
|
||||
if (remain > 0)
|
||||
{
|
||||
/* resynchronize FM & PSG chips */
|
||||
YM2612Update(Fir_Resampler_buffer(), remain);
|
||||
Fir_Resampler_write(remain << 1);
|
||||
}
|
||||
|
||||
fm_cycles_count = psg_cycles_count;
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d FM samples available\n",Fir_Resampler_written() >> 1);
|
||||
#endif
|
||||
}
|
||||
@ -200,21 +200,21 @@ int sound_update(unsigned int cycles)
|
||||
/* run FM chip until end of frame */
|
||||
fm_update(cycles);
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d FM samples available\n",(snd.fm.pos - snd.fm.buffer)>>1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%lu PSG cycles run\n",psg_cycles_count);
|
||||
error("%lu FM cycles run \n",fm_cycles_count);
|
||||
#endif
|
||||
|
||||
/* adjust PSG & FM cycle counts */
|
||||
psg_cycles_count -= (cycles << 11);
|
||||
fm_cycles_count -= (cycles << 11);
|
||||
psg_cycles_count -= (cycles << 11);
|
||||
fm_cycles_count -= (cycles << 11);
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%lu PSG cycles left\n",psg_cycles_count);
|
||||
error("%lu FM cycles left\n",fm_cycles_count);
|
||||
#endif
|
||||
@ -222,10 +222,10 @@ int sound_update(unsigned int cycles)
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Reset FM chip during 68k execution */
|
||||
void fm_reset(void)
|
||||
/* Reset FM chip */
|
||||
void fm_reset(unsigned int cycles)
|
||||
{
|
||||
fm_update(mcycles_68k);
|
||||
fm_update(cycles);
|
||||
YM2612ResetChip();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
extern void sound_init(void);
|
||||
extern void sound_reset(void);
|
||||
extern int sound_update(unsigned int cycles);
|
||||
extern void fm_reset(void);
|
||||
extern void fm_reset(unsigned int cycles);
|
||||
extern void fm_write(unsigned int cycles, unsigned int address, unsigned int data);
|
||||
extern unsigned int fm_read(unsigned int cycles, unsigned int address);
|
||||
extern void psg_write(unsigned int cycles, unsigned int data);
|
||||
|
@ -84,7 +84,7 @@ int audio_update (void)
|
||||
/* resample into FM output buffer */
|
||||
Fir_Resampler_read(fm,size);
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d FM samples remaining\n",Fir_Resampler_written() >> 1);
|
||||
#endif
|
||||
}
|
||||
@ -93,7 +93,7 @@ int audio_update (void)
|
||||
/* adjust remaining samples in FM output buffer*/
|
||||
snd.fm.pos -= (size << 1);
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d FM samples remaining\n",(snd.fm.pos - snd.fm.buffer)>>1);
|
||||
#endif
|
||||
}
|
||||
@ -101,7 +101,7 @@ int audio_update (void)
|
||||
/* adjust remaining samples in PSG output buffer*/
|
||||
snd.psg.pos -= size;
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d PSG samples remaining\n",snd.psg.pos - snd.psg.buffer);
|
||||
#endif
|
||||
|
||||
@ -155,7 +155,7 @@ int audio_update (void)
|
||||
memcpy(snd.fm.buffer, fm, (snd.fm.pos - snd.fm.buffer) << 1);
|
||||
memcpy(snd.psg.buffer, psg, (snd.psg.pos - snd.psg.buffer) << 1);
|
||||
|
||||
#ifdef LOG_SOUND
|
||||
#ifdef LOGSOUND
|
||||
error("%d samples returned\n\n",size);
|
||||
#endif
|
||||
|
||||
@ -398,7 +398,7 @@ int system_frame (int do_skip)
|
||||
if (line == vdp_height)
|
||||
{
|
||||
/* render overscan */
|
||||
if (line < end_line)
|
||||
if (!do_skip && (line < end_line))
|
||||
render_line(line, 1);
|
||||
|
||||
/* update inputs (doing this here fix Warriors of Eternal Sun) */
|
||||
@ -439,7 +439,7 @@ int system_frame (int do_skip)
|
||||
else
|
||||
{
|
||||
/* render overscan */
|
||||
if ((line < end_line) || (line >= start_line))
|
||||
if (!do_skip && ((line < end_line) || (line >= start_line)))
|
||||
render_line(line, 1);
|
||||
|
||||
/* clear any pending Z80 interrupt */
|
||||
|
Loading…
Reference in New Issue
Block a user