Search
lxdream.org :: lxdream :: r463:0655796f9bb5
lxdream 0.9.1
released Jun 29
Download Now
changeset463:0655796f9bb5
parent462:9add12452876
child464:8e099fad42a6
authornkeynes
dateWed Oct 24 21:24:09 2007 +0000 (12 years ago)
Implement channel position readback
src/aica/aica.c
src/aica/aica.h
src/aica/audio.c
src/aica/audio.h
1.1 --- a/src/aica/aica.c Wed Oct 24 21:23:22 2007 +0000
1.2 +++ b/src/aica/aica.c Wed Oct 24 21:24:09 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: aica.c,v 1.23 2007-10-09 11:37:36 nkeynes Exp $
1.6 + * $Id: aica.c,v 1.24 2007-10-24 21:24:09 nkeynes Exp $
1.7 *
1.8 * This is the core sound system (ie the bit which does the actual work)
1.9 *
1.10 @@ -30,7 +30,6 @@
1.11
1.12 MMIO_REGION_READ_DEFFN( AICA0 )
1.13 MMIO_REGION_READ_DEFFN( AICA1 )
1.14 -MMIO_REGION_READ_DEFFN( AICA2 )
1.15
1.16 void aica_init( void );
1.17 void aica_reset( void );
1.18 @@ -226,6 +225,30 @@
1.19 }
1.20 }
1.21
1.22 +int32_t mmio_region_AICA2_read( uint32_t reg )
1.23 +{
1.24 + audio_channel_t channel;
1.25 + uint32_t channo;
1.26 + int32_t val;
1.27 + switch( reg ) {
1.28 + case AICA_CHANSTATE:
1.29 + channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;
1.30 + channel = audio_get_channel(channo);
1.31 + if( channel->loop == LOOP_LOOPED ) {
1.32 + val = 0x8000;
1.33 + channel->loop = LOOP_ON;
1.34 + } else {
1.35 + val = 0;
1.36 + }
1.37 + return val;
1.38 + case AICA_CHANPOSN:
1.39 + channo = (MMIO_READ( AICA2, AICA_CHANSEL ) >> 8) & 0x3F;
1.40 + channel = audio_get_channel(channo);
1.41 + return channel->posn;
1.42 + default:
1.43 + return MMIO_READ( AICA2, reg );
1.44 + }
1.45 +}
1.46
1.47 int32_t mmio_region_AICARTC_read( uint32_t reg )
1.48 {
1.49 @@ -332,9 +355,9 @@
1.50 case 0x00: /* Config + high address bits*/
1.51 channel->start = (channel->start & 0xFFFF) | ((val&0x1F) << 16);
1.52 if( val & 0x200 )
1.53 - channel->loop = TRUE;
1.54 + channel->loop = LOOP_ON;
1.55 else
1.56 - channel->loop = FALSE;
1.57 + channel->loop = LOOP_OFF;
1.58 switch( (val >> 7) & 0x03 ) {
1.59 case 0:
1.60 channel->sample_format = AUDIO_FMT_16BIT;
2.1 --- a/src/aica/aica.h Wed Oct 24 21:23:22 2007 +0000
2.2 +++ b/src/aica/aica.h Wed Oct 24 21:24:09 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: aica.h,v 1.10 2007-01-17 09:37:22 nkeynes Exp $
2.6 + * $Id: aica.h,v 1.11 2007-10-24 21:24:09 nkeynes Exp $
2.7 *
2.8 * MMIO definitions for the AICA sound chip. Note that the regions defined
2.9 * here are relative to the SH4 memory map (0x00700000 based), rather than
2.10 @@ -33,6 +33,9 @@
2.11 LONG_PORT( 0x044, CDDA_VOL_R, PORT_MRW, 0, "CDDA Volume right" )
2.12 LONG_PORT( 0x800, VOL_MASTER, PORT_MRW, UNDEFINED, "Master volume" )
2.13 LONG_PORT( 0x808, AICA_UNK7, PORT_MRW, 0, "AICA ??? 7" )
2.14 +LONG_PORT( 0x80C, AICA_CHANSEL, PORT_MRW, 0, "AICA channel select" )
2.15 +LONG_PORT( 0x810, AICA_CHANSTATE, PORT_MRW, 0, "AICA channel state" )
2.16 +LONG_PORT( 0x814, AICA_CHANPOSN, PORT_MRW, 0, "AICA channel position" )
2.17 LONG_PORT( 0x880, AICA_UNK6, PORT_MRW, 0, "AICA ??? 6" )
2.18 LONG_PORT( 0x890, AICA_TIMER, PORT_MRW, 0, "AICA Timer" )
2.19 LONG_PORT( 0x89C, AICA_UNK1, PORT_MRW, 0, "AICA ??? 1" )
3.1 --- a/src/aica/audio.c Wed Oct 24 21:23:22 2007 +0000
3.2 +++ b/src/aica/audio.c Wed Oct 24 21:24:09 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: audio.c,v 1.9 2007-10-09 11:37:36 nkeynes Exp $
3.6 + * $Id: audio.c,v 1.10 2007-10-24 21:24:09 nkeynes Exp $
3.7 *
3.8 * Audio mixer core. Combines all the active streams into a single sound
3.9 * buffer for output.
3.10 @@ -208,9 +208,10 @@
3.11 channel->posn++;
3.12
3.13 if( channel->posn == channel->end ) {
3.14 - if( channel->loop )
3.15 + if( channel->loop ) {
3.16 channel->posn = channel->loop_start;
3.17 - else {
3.18 + channel->loop = LOOP_LOOPED;
3.19 + } else {
3.20 audio_stop_channel(i);
3.21 j = num_samples;
3.22 break;
3.23 @@ -231,9 +232,10 @@
3.24 channel->posn++;
3.25
3.26 if( channel->posn == channel->end ) {
3.27 - if( channel->loop )
3.28 + if( channel->loop ) {
3.29 channel->posn = channel->loop_start;
3.30 - else {
3.31 + channel->loop = LOOP_LOOPED;
3.32 + } else {
3.33 audio_stop_channel(i);
3.34 j = num_samples;
3.35 break;
3.36 @@ -254,6 +256,7 @@
3.37 if( channel->posn == channel->end ) {
3.38 if( channel->loop ) {
3.39 channel->posn = channel->loop_start;
3.40 + channel->loop = LOOP_LOOPED;
3.41 channel->adpcm_predict = 0;
3.42 channel->adpcm_step = 0;
3.43 } else {
4.1 --- a/src/aica/audio.h Wed Oct 24 21:23:22 2007 +0000
4.2 +++ b/src/aica/audio.h Wed Oct 24 21:24:09 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: audio.h,v 1.8 2007-10-09 11:37:36 nkeynes Exp $
4.6 + * $Id: audio.h,v 1.9 2007-10-24 21:24:09 nkeynes Exp $
4.7 *
4.8 * Audio engine, ie the part that does the actual work.
4.9 *
4.10 @@ -35,13 +35,15 @@
4.11
4.12 #define AUDIO_FMT_16ST (AUDIO_FMT_16BIT|AUDIO_FMT_STEREO)
4.13
4.14 +typedef enum { LOOP_OFF = 0, LOOP_ON = 1, LOOP_LOOPED = 2 } loop_t;
4.15 +
4.16 typedef struct audio_channel {
4.17 gboolean active;
4.18 uint32_t posn; /* current sample #, 0 = first sample */
4.19 uint32_t posn_left;
4.20 uint32_t start;
4.21 uint32_t end;
4.22 - gboolean loop;
4.23 + loop_t loop;
4.24 uint32_t loop_start;
4.25 int vol; /* 0..255 */
4.26 int pan; /* 0 (left) .. 31 (right) */
.