summaryrefslogtreecommitdiff
path: root/apps/plugins/pacbox/wsg3.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pacbox/wsg3.c')
-rw-r--r--apps/plugins/pacbox/wsg3.c20
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)
65 return true; 65 return true;
66} 66}
67 67
68void wsg3_play_sound(int * buf, int len) 68void wsg3_play_sound(int16_t * buf, int len)
69{ 69{
70 struct wsg3_voice voice; 70 struct wsg3_voice voice;
71 71
@@ -73,7 +73,7 @@ void wsg3_play_sound(int * buf, int len)
73 { 73 {
74 unsigned offset = wsg3.wave_offset[0]; 74 unsigned offset = wsg3.wave_offset[0];
75 unsigned step = voice.frequency * wsg3.resample_step; 75 unsigned step = voice.frequency * wsg3.resample_step;
76 int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; 76 int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform;
77 int volume = voice.volume; 77 int volume = voice.volume;
78 int i; 78 int i;
79 79
@@ -81,7 +81,7 @@ void wsg3_play_sound(int * buf, int len)
81 { 81 {
82 /* Should be shifted right by 15, but we must also get rid 82 /* Should be shifted right by 15, but we must also get rid
83 * of the 10 bits used for decimals */ 83 * of the 10 bits used for decimals */
84 buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; 84 buf[i] = (int)wave_data[(offset >> 25) & 0x1F] * volume;
85 offset += step; 85 offset += step;
86 } 86 }
87 87
@@ -92,7 +92,7 @@ void wsg3_play_sound(int * buf, int len)
92 { 92 {
93 unsigned offset = wsg3.wave_offset[1]; 93 unsigned offset = wsg3.wave_offset[1];
94 unsigned step = voice.frequency * wsg3.resample_step; 94 unsigned step = voice.frequency * wsg3.resample_step;
95 int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; 95 int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform;
96 int volume = voice.volume; 96 int volume = voice.volume;
97 int i; 97 int i;
98 98
@@ -100,7 +100,7 @@ void wsg3_play_sound(int * buf, int len)
100 { 100 {
101 /* Should be shifted right by 15, but we must also get rid 101 /* Should be shifted right by 15, but we must also get rid
102 * of the 10 bits used for decimals */ 102 * of the 10 bits used for decimals */
103 buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; 103 buf[i] += (int)wave_data[(offset >> 25) & 0x1F] * volume;
104 offset += step; 104 offset += step;
105 } 105 }
106 106
@@ -111,7 +111,7 @@ void wsg3_play_sound(int * buf, int len)
111 { 111 {
112 unsigned offset = wsg3.wave_offset[2]; 112 unsigned offset = wsg3.wave_offset[2];
113 unsigned step = voice.frequency * wsg3.resample_step; 113 unsigned step = voice.frequency * wsg3.resample_step;
114 int * wave_data = wsg3.sound_wave_data + 32 * voice.waveform; 114 int16_t * wave_data = wsg3.sound_wave_data + 32 * voice.waveform;
115 int volume = voice.volume; 115 int volume = voice.volume;
116 int i; 116 int i;
117 117
@@ -119,7 +119,7 @@ void wsg3_play_sound(int * buf, int len)
119 { 119 {
120 /* Should be shifted right by 15, but we must also get rid 120 /* Should be shifted right by 15, but we must also get rid
121 * of the 10 bits used for decimals */ 121 * of the 10 bits used for decimals */
122 buf[i] += wave_data[(offset >> 25) & 0x1F] * volume; 122 buf[i] += (int)wave_data[(offset >> 25) & 0x1F] * volume;
123 offset += step; 123 offset += step;
124 } 124 }
125 125
@@ -137,8 +137,12 @@ void wsg3_set_sound_prom( const unsigned char * prom )
137{ 137{
138 int i; 138 int i;
139 139
140 memcpy(wsg3.sound_prom, prom, 32*8);
141
142 /* Copy wave data and convert 4-bit unsigned -> 16-bit signed,
143 * prenormalized */
140 for (i = 0; i < 32*8; i++) 144 for (i = 0; i < 32*8; i++)
141 wsg3.sound_wave_data[i] = (int)*prom++ - 8; 145 wsg3.sound_wave_data[i] = ((int16_t)wsg3.sound_prom[i] - 8) * 85;
142} 146}
143 147
144void wsg3_init(unsigned master_clock) 148void wsg3_init(unsigned master_clock)