Search
lxdream.org :: lxdream :: r1089:a3984d242909
lxdream 0.9.1
released Jun 29
Download Now
changeset1089:a3984d242909
parent1088:cf3900ae8acc
child1090:71e28626b358
authornkeynes
dateMon Dec 07 08:59:50 2009 +1000 (11 years ago)
Mask audio RAM accesses from the mixer to ensure they're in bounds. Uncertain if
this is correct (vs eg zero-fill), but it's at least consistent with the masking
of the channel start position.
src/aica/audio.c
src/aica/audio.h
1.1 --- a/src/aica/audio.c Fri Dec 04 18:06:12 2009 +1000
1.2 +++ b/src/aica/audio.c Mon Dec 07 08:59:50 2009 +1000
1.3 @@ -328,7 +328,7 @@
1.4 switch( channel->sample_format ) {
1.5 case AUDIO_FMT_16BIT:
1.6 for( j=0; j<num_samples; j++ ) {
1.7 - sample = ((int16_t *)(aica_main_ram + channel->start))[channel->posn];
1.8 + sample = *(int16_t *)(aica_main_ram + ((channel->start + channel->posn*2)&AUDIO_MEM_MASK));
1.9 result_buf[j][0] += sample * vol_left;
1.10 result_buf[j][1] += sample * vol_right;
1.11
1.12 @@ -352,7 +352,7 @@
1.13 break;
1.14 case AUDIO_FMT_8BIT:
1.15 for( j=0; j<num_samples; j++ ) {
1.16 - sample = ((int8_t *)(aica_main_ram + channel->start))[channel->posn] << 8;
1.17 + sample = (*(int8_t *)(aica_main_ram + ((channel->start + channel->posn)&AUDIO_MEM_MASK))) << 8;
1.18 result_buf[j][0] += sample * vol_left;
1.19 result_buf[j][1] += sample * vol_right;
1.20
1.21 @@ -395,7 +395,7 @@
1.22 break;
1.23 }
1.24 }
1.25 - uint8_t data = ((uint8_t *)(aica_main_ram + channel->start))[channel->posn>>1];
1.26 + uint8_t data = *(uint8_t *)(aica_main_ram + ((channel->start + (channel->posn>>1))&AUDIO_MEM_MASK));
1.27 if( channel->posn&1 ) {
1.28 adpcm_yamaha_decode_nibble( channel, (data >> 4) & 0x0F );
1.29 } else {
2.1 --- a/src/aica/audio.h Fri Dec 04 18:06:12 2009 +1000
2.2 +++ b/src/aica/audio.h Mon Dec 07 08:59:50 2009 +1000
2.3 @@ -43,6 +43,7 @@
2.4
2.5 #define AUDIO_FMT_16ST (AUDIO_FMT_16BIT|AUDIO_FMT_STEREO)
2.6 #define AUDIO_FMT_FLOATST (AUDIO_FMT_FLOAT|AUDIO_FMT_STEREO)
2.7 +#define AUDIO_MEM_MASK 0x1FFFFF
2.8
2.9 #define DEFAULT_SAMPLE_RATE 44100
2.10 #define DEFAULT_SAMPLE_FORMAT AUDIO_FMT_16ST
.