Search
lxdream.org :: lxdream/src/aica/aica.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/aica.c
changeset 73:0bb57e51ac9e
prev66:2ec5b6eb75e5
next75:58ff379f11df
author nkeynes
date Thu Jan 12 11:30:19 2006 +0000 (16 years ago)
permissions -rw-r--r--
last change Render multiple samples per shot, should be mildly faster
Move timer logic down into armcore
Minor tweaks
file annotate diff log raw
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 11:30:19 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
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.7 *
1.8 * This is the core sound system (ie the bit which does the actual work)
1.9 *
1.10 @@ -39,8 +39,6 @@
1.11 int aica_load_state( FILE *f );
1.12 uint32_t aica_run_slice( uint32_t );
1.13
1.14 -#define IS_TIMER_ENABLED() (MMIO_READ( AICA2, AICA_TCR ) & 0x40)
1.15 -
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.19 @@ -82,23 +80,16 @@
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.23 - int i;
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.29 - val++;
1.30 - if( val == 0 )
1.31 - aica_event( AICA_EVENT_TIMER );
1.32 - MMIO_WRITE( AICA2, AICA_TIMER, val );
1.33 - }
1.34 - if( !dreamcast_is_running() )
1.35 - break;
1.36 - }
1.37 + num_samples = arm_run_slice( num_samples );
1.38 + audio_mix_samples( num_samples );
1.39 +
1.40 samples_done += num_samples;
1.41 nanosecs_done += nanosecs;
1.42 }
1.43 + if( nanosecs_done > 1000000000 ) {
1.44 + samples_done -= AICA_SAMPLE_RATE;
1.45 + nanosecs_done -= 1000000000;
1.46 + }
1.47 return nanosecs;
1.48 }
1.49
1.50 @@ -256,9 +247,9 @@
1.51 case 0x00: /* Config + high address bits*/
1.52 channel->start = (channel->start & 0xFFFF) | ((val&0x1F) << 16);
1.53 if( val & 0x200 )
1.54 - channel->loop_count = -1;
1.55 + channel->loop = TRUE;
1.56 else
1.57 - channel->loop_count = 0;
1.58 + channel->loop = FALSE;
1.59 switch( (val >> 7) & 0x03 ) {
1.60 case 0:
1.61 channel->sample_format = AUDIO_FMT_16BIT;
1.62 @@ -289,8 +280,8 @@
1.63 case 0x08: /* Loop start */
1.64 channel->loop_start = val;
1.65 break;
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.70 break;
1.71 case 0x10: /* Envelope register 1 */
1.72 break;
.