diff options
Diffstat (limited to 'apps/codecs/libgme/emuadpcm.c')
-rw-r--r-- | apps/codecs/libgme/emuadpcm.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/apps/codecs/libgme/emuadpcm.c b/apps/codecs/libgme/emuadpcm.c index d85aba3488..b426a74de5 100644 --- a/apps/codecs/libgme/emuadpcm.c +++ b/apps/codecs/libgme/emuadpcm.c | |||
@@ -117,7 +117,7 @@ void restart(struct Y8950Adpcm* this_) | |||
117 | this_->diff = DDEF; | 117 | this_->diff = DDEF; |
118 | this_->nextLeveling = 0; | 118 | this_->nextLeveling = 0; |
119 | this_->sampleStep = 0; | 119 | this_->sampleStep = 0; |
120 | this_->volumeWStep = (int)((double)this_->volume * this_->step / MAX_STEP); | 120 | this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); |
121 | } | 121 | } |
122 | 122 | ||
123 | void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data) | 123 | void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data) |
@@ -176,23 +176,22 @@ void ADPCM_writeReg(struct Y8950Adpcm* this_, byte rg, byte data) | |||
176 | case 0x10: // DELTA-N (L) | 176 | case 0x10: // DELTA-N (L) |
177 | this_->delta = (this_->delta & 0xFF00) | data; | 177 | this_->delta = (this_->delta & 0xFF00) | data; |
178 | this_->step = rate_adjust(this_->delta<<GETA_BITS, this_->sampleRate, this_->clockRate); | 178 | this_->step = rate_adjust(this_->delta<<GETA_BITS, this_->sampleRate, this_->clockRate); |
179 | this_->volumeWStep = (int)((double)this_->volume * this_->step / MAX_STEP); | 179 | this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); |
180 | break; | 180 | break; |
181 | case 0x11: // DELTA-N (H) | 181 | case 0x11: // DELTA-N (H) |
182 | this_->delta = (this_->delta & 0x00FF) | (data << 8); | 182 | this_->delta = (this_->delta & 0x00FF) | (data << 8); |
183 | this_->step = rate_adjust(this_->delta<<GETA_BITS, this_->sampleRate, this_->clockRate); | 183 | this_->step = rate_adjust(this_->delta<<GETA_BITS, this_->sampleRate, this_->clockRate); |
184 | this_->volumeWStep = (int)((double)this_->volume * this_->step / MAX_STEP); | 184 | this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); |
185 | break; | 185 | break; |
186 | 186 | ||
187 | case 0x12: { // ENVELOP CONTROL | 187 | case 0x12: { // ENVELOP CONTROL |
188 | int oldVol = this_->volume; | 188 | int oldVol = this_->volume; |
189 | this_->volume = (data * ADPCM_VOLUME) >> 8; | 189 | this_->volume = (data * ADPCM_VOLUME) >> 8; |
190 | if (oldVol != 0) { | 190 | if (oldVol != 0) { |
191 | double factor = (double)this_->volume / (double)oldVol; | 191 | this_->output = (int)(((long long)this_->output * this_->volume) / oldVol); |
192 | this_->output = (int)((double)this_->output * factor); | 192 | this_->sampleStep = (int)(((long long)this_->sampleStep * this_->volume) / oldVol); |
193 | this_->sampleStep = (int)((double)this_->sampleStep * factor); | ||
194 | } | 193 | } |
195 | this_->volumeWStep = (int)((double)this_->volume * this_->step / MAX_STEP); | 194 | this_->volumeWStep = (int)((long long)this_->volume * this_->step / MAX_STEP); |
196 | break; | 195 | break; |
197 | } | 196 | } |
198 | case 0x0D: // PRESCALE (L) | 197 | case 0x0D: // PRESCALE (L) |
@@ -290,7 +289,7 @@ int ADPCM_calcSample(struct Y8950Adpcm* this_) | |||
290 | 289 | ||
291 | /* TODO: Used fixed point math here */ | 290 | /* TODO: Used fixed point math here */ |
292 | #if !defined(ROCKBOX) | 291 | #if !defined(ROCKBOX) |
293 | this_->output += (int)((double)this_->sampleStep * ((double)this_->nowStep/(double)this_->step)); | 292 | this_->output += (int)(((long long)this_->sampleStep * this_->nowStep) / this_->step); |
294 | #endif | 293 | #endif |
295 | } | 294 | } |
296 | this_->output += this_->sampleStep; | 295 | this_->output += this_->sampleStep; |