diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2010-07-01 03:57:37 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2010-07-01 03:57:37 +0000 |
commit | ceab0b04ebb52da8fd632ed051cf833d35bbdd22 (patch) | |
tree | 810b17e7b1931ce0ac13a8105196bf958e8a94e8 /apps/plugins/pacbox/wsg3.c | |
parent | f09370058ff170bcf99481dd8115871ba20ee816 (diff) |
PacBox: Premultiply sound prom data on load rather than during emulation. Use 16-bit data for 'raw' output instead of int.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27208 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pacbox/wsg3.c')
-rw-r--r-- | apps/plugins/pacbox/wsg3.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/apps/plugins/pacbox/wsg3.c b/apps/plugins/pacbox/wsg3.c index 3c861312b9..c848b68b6b 100644 --- a/apps/plugins/pacbox/wsg3.c +++ b/apps/plugins/pacbox/wsg3.c @@ -65,7 +65,7 @@ static bool wsg3_get_voice(struct wsg3_voice *voice, int index) return true; } -void wsg3_play_sound(int * buf, int len) +void wsg3_play_sound(int16_t * buf, int len) { struct wsg3_voice voice; @@ -73,7 +73,7 @@ void wsg3_play_sound(int * buf, int len) { unsigned offset = wsg3.wave_offset[0]; unsigned step = voice.frequency * wsg3.resample_step; - int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; + int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; int volume = voice.volume; int i; @@ -81,7 +81,7 @@ void wsg3_play_sound(int * buf, int len) { /* Should be shifted right by 15, but we must also get rid * of the 10 bits used for decimals */ - buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; + buf[i] = (int)wave_data[(offset >> 25) & 0x1F] * volume; offset += step; } @@ -92,7 +92,7 @@ void wsg3_play_sound(int * buf, int len) { unsigned offset = wsg3.wave_offset[1]; unsigned step = voice.frequency * wsg3.resample_step; - int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; + int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; int volume = voice.volume; int i; @@ -100,7 +100,7 @@ void wsg3_play_sound(int * buf, int len) { /* Should be shifted right by 15, but we must also get rid * of the 10 bits used for decimals */ - buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; + buf[i] += (int)wave_data[(offset >> 25) & 0x1F] * volume; offset += step; } @@ -111,7 +111,7 @@ void wsg3_play_sound(int * buf, int len) { unsigned offset = wsg3.wave_offset[2]; unsigned step = voice.frequency * wsg3.resample_step; - int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; + int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; int volume = voice.volume; int i; @@ -119,7 +119,7 @@ void wsg3_play_sound(int * buf, int len) { /* Should be shifted right by 15, but we must also get rid * of the 10 bits used for decimals */ - buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; + buf[i] += (int)wave_data[(offset >> 25) & 0x1F] * volume; offset += step; } @@ -137,8 +137,12 @@ void wsg3_set_sound_prom( const unsigned char * prom ) { int i; + memcpy(wsg3.sound_prom, prom, 32*8); + + /* Copy wave data and convert 4-bit unsigned -> 16-bit signed, + * prenormalized */ for (i = 0; i < 32*8; i++) - wsg3.sound_wave_data[i] = (int)*prom++ - 8; + wsg3.sound_wave_data[i] = ((int16_t)wsg3.sound_prom[i] - 8) * 85; } void wsg3_init(unsigned master_clock) |