1.1 --- a/src/aica/aica.c Tue Jan 10 13:56:54 2006 +0000
1.2 +++ b/src/aica/aica.c Thu Jan 12 12:38:59 2006 +0000
1.5 - * $Id: aica.c,v 1.11 2006-01-10 13:56:54 nkeynes Exp $
1.6 + * $Id: aica.c,v 1.12 2006-01-12 11:30:19 nkeynes Exp $
1.8 * This is the core sound system (ie the bit which does the actual work)
1.11 int aica_load_state( FILE *f );
1.12 uint32_t aica_run_slice( uint32_t );
1.14 -#define IS_TIMER_ENABLED() (MMIO_READ( AICA2, AICA_TCR ) & 0x40)
1.16 struct dreamcast_module aica_module = { "AICA", aica_init, aica_reset,
1.17 aica_start, aica_run_slice, aica_stop,
1.18 aica_save_state, aica_load_state };
1.20 int reset = MMIO_READ( AICA2, AICA_RESET );
1.21 if( (reset & 1) == 0 ) { /* Running */
1.22 int num_samples = (nanosecs_done + nanosecs) / AICA_SAMPLE_RATE - samples_done;
1.24 - for( i=0; i<num_samples; i++ ) {
1.25 - nanosecs = arm_run_slice( AICA_SAMPLE_PERIOD );
1.26 - audio_mix_sample();
1.27 - if( IS_TIMER_ENABLED() ) {
1.28 - uint8_t val = MMIO_READ( AICA2, AICA_TIMER );
1.31 - aica_event( AICA_EVENT_TIMER );
1.32 - MMIO_WRITE( AICA2, AICA_TIMER, val );
1.34 - if( !dreamcast_is_running() )
1.37 + num_samples = arm_run_slice( num_samples );
1.38 + audio_mix_samples( num_samples );
1.40 samples_done += num_samples;
1.41 nanosecs_done += nanosecs;
1.43 + if( nanosecs_done > 1000000000 ) {
1.44 + samples_done -= AICA_SAMPLE_RATE;
1.45 + nanosecs_done -= 1000000000;
1.51 case 0x00: /* Config + high address bits*/
1.52 channel->start = (channel->start & 0xFFFF) | ((val&0x1F) << 16);
1.54 - channel->loop_count = -1;
1.55 + channel->loop = TRUE;
1.57 - channel->loop_count = 0;
1.58 + channel->loop = FALSE;
1.59 switch( (val >> 7) & 0x03 ) {
1.61 channel->sample_format = AUDIO_FMT_16BIT;
1.63 case 0x08: /* Loop start */
1.64 channel->loop_start = val;
1.66 - case 0x0C: /* Loop end */
1.67 - channel->loop_end = channel->end = val;
1.68 + case 0x0C: /* End */
1.69 + channel->end = val;
1.71 case 0x10: /* Envelope register 1 */