diff options
| author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-09-09 17:57:33 +0000 |
|---|---|---|
| committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-09-09 17:57:33 +0000 |
| commit | c97c5e5d17617475eaf4b81407dd5913ffa89528 (patch) | |
| tree | 6bedd4b8a6614daed854ae99085bb776563d3fab /apps/codecs | |
| parent | 544a52d9eb274c8989df2268324dcbf8f18795c6 (diff) | |
| download | rockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.zip rockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.tar.gz rockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.tar.bz2 rockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.tar.xz | |
Bugfixes for libgme by Mauricio Garrido: added missing call of Blip_set_modified(), correctly set PSG voices in vgm_emu, correctly set current_track in vgm_emu, correct call of Sound_mute_voices() in nsf_emu. Additionally migrate few floating point code to fixed point -- even though this is unused and therefor commented out.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30490 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
| -rw-r--r-- | apps/codecs/libgme/nes_apu.c | 19 | ||||
| -rw-r--r-- | apps/codecs/libgme/nes_apu.h | 4 | ||||
| -rw-r--r-- | apps/codecs/libgme/nes_cpu.h | 9 | ||||
| -rw-r--r-- | apps/codecs/libgme/nes_oscs.c | 2 | ||||
| -rw-r--r-- | apps/codecs/libgme/nes_vrc6_apu.c | 1 | ||||
| -rw-r--r-- | apps/codecs/libgme/nsf_emu.c | 8 | ||||
| -rw-r--r-- | apps/codecs/libgme/vgm_emu.c | 7 |
7 files changed, 30 insertions, 20 deletions
diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c index 630e71f..b6c88bc 100644 --- a/apps/codecs/libgme/nes_apu.c +++ b/apps/codecs/libgme/nes_apu.c @@ -44,13 +44,15 @@ void Apu_init( struct Nes_Apu* this ) Apu_reset( this, false, 0 ); } -void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd ) +#if 0 +// sq and tnd must use a fixed point frac where 1.0 = FP_ONE_VOLUME +void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ) { this->dmc.nonlinear = true; - Synth_volume( &this->square_synth, (int)((long long)(sq * FP_ONE_VOLUME) / amp_range) ); + Synth_volume( &this->square_synth, sq ); - Synth_volume( &this->triangle.synth, tnd * 2.752 ); - Synth_volume( &this->noise.synth , tnd * 1.849 ); + Synth_volume( &this->triangle.synth, (int)((long long)(FP_ONE_VOLUME * 2.752) * tnd / FP_ONE_VOLUME) ); + Synth_volume( &this->noise.synth , (int)((long long)(FP_ONE_VOLUME * 1.849) * tnd / FP_ONE_VOLUME) ); Synth_volume( &this->dmc.synth , tnd ); this->square1 .osc.last_amp = 0; @@ -59,15 +61,16 @@ void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd ) this->noise .osc.last_amp = 0; this->dmc .osc.last_amp = 0; } +#endif void Apu_volume( struct Nes_Apu* this, int v ) { if ( !this->dmc.nonlinear ) { - Synth_volume( &this->square_synth, (int)((long long)((0.125 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.1128 1.108 - Synth_volume( &this->triangle.synth,(int)((long long)((0.150 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.12765 1.175 - Synth_volume( &this->noise.synth, (int)((long long)((0.095 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.0741 1.282 - Synth_volume( &this->dmc.synth, (int)((long long)((0.450 * (1.0 /1.11)) * FP_ONE_VOLUME) * v / 2048 / FP_ONE_VOLUME) ); // was 0.42545 1.058 + Synth_volume( &this->square_synth, (int)((long long)((0.125 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.1128 1.108 + Synth_volume( &this->triangle.synth,(int)((long long)((0.150 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.12765 1.175 + Synth_volume( &this->noise.synth, (int)((long long)((0.095 / 1.11) * FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); // was 0.0741 1.282 + Synth_volume( &this->dmc.synth, (int)((long long)((0.450 / 1.11) * FP_ONE_VOLUME) * v / 2048 / FP_ONE_VOLUME) ); // was 0.42545 1.058 } } diff --git a/apps/codecs/libgme/nes_apu.h b/apps/codecs/libgme/nes_apu.h index 0a2b1f5..152ec94 100644 --- a/apps/codecs/libgme/nes_apu.h +++ b/apps/codecs/libgme/nes_apu.h @@ -130,6 +130,8 @@ static inline nes_time_t Dmc_next_read_time( struct Nes_Dmc* this ) static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); } void Apu_irq_changed( struct Nes_Apu* this ); +#if 0 // Experimental -void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd ); +void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd ); +#endif #endif diff --git a/apps/codecs/libgme/nes_cpu.h b/apps/codecs/libgme/nes_cpu.h index 7129ffd..e4538cd 100644 --- a/apps/codecs/libgme/nes_cpu.h +++ b/apps/codecs/libgme/nes_cpu.h @@ -48,11 +48,14 @@ struct Nes_Cpu { struct cpu_state_t cpu_state_; }; -static inline void Cpu_init( struct Nes_Cpu* this ) { this->cpu_state = &this->cpu_state_; } +static inline void Cpu_init( struct Nes_Cpu* this ) +{ + this->cpu_state = &this->cpu_state_; +} // Clears registers and maps all pages to unmapped_page void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ); - + // Maps code memory (memory accessed via the program counter). Start and size // must be multiple of page_size. If mirror_size is non-zero, the first // mirror_size bytes are repeated over the range. mirror_size must be a @@ -101,6 +104,6 @@ static inline void Cpu_set_end_time( struct Nes_Cpu* this, nes_time_t t ) { this->end_time = t; Cpu_update_end_time( this, t, this->irq_time ); -} +} #endif diff --git a/apps/codecs/libgme/nes_oscs.c b/apps/codecs/libgme/nes_oscs.c index f97ce21..ac6e575 100644 --- a/apps/codecs/libgme/nes_oscs.c +++ b/apps/codecs/libgme/nes_oscs.c @@ -565,7 +565,7 @@ void Noise_run( struct Nes_Noise* this, nes_time_t time, nes_time_t end_time ) int noise = this->noise; int delta = amp * 2 - volume; const int tap = (osc->regs [2] & mode_flag ? 8 : 13); - Blip_set_modified( osc->output ); + Blip_set_modified( output ); do { int feedback = (noise << tap) ^ (noise << 14); diff --git a/apps/codecs/libgme/nes_vrc6_apu.c b/apps/codecs/libgme/nes_vrc6_apu.c index 55fccb7..99a9ae3 100644 --- a/apps/codecs/libgme/nes_vrc6_apu.c +++ b/apps/codecs/libgme/nes_vrc6_apu.c @@ -107,6 +107,7 @@ void run_square( struct Nes_Vrc6_Apu* this, struct Vrc6_Osc* osc, blip_time_t en if ( time < end_time ) { int phase = osc->phase; + Blip_set_modified( output ); do { diff --git a/apps/codecs/libgme/nsf_emu.c b/apps/codecs/libgme/nsf_emu.c index 705c345..d9fc4e0 100644 --- a/apps/codecs/libgme/nsf_emu.c +++ b/apps/codecs/libgme/nsf_emu.c @@ -299,10 +299,6 @@ blargg_err_t Nsf_post_load( struct Nsf_Emu* this ) blargg_err_t err = init_sound( this ); if ( err ) return err; - - // Post load - Sound_set_tempo( this, this->tempo ); - Sound_mute_voices( this, this->mute_mask_ ); // Set track_count this->track_count = this->header.track_count; @@ -312,6 +308,10 @@ blargg_err_t Nsf_post_load( struct Nsf_Emu* this ) Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); + + // Post load + Sound_set_tempo( this, this->tempo ); + Sound_mute_voices( this, this->mute_mask_ ); return 0; } diff --git a/apps/codecs/libgme/vgm_emu.c b/apps/codecs/libgme/vgm_emu.c index 4f8a2ad..8b22aba 100644 --- a/apps/codecs/libgme/vgm_emu.c +++ b/apps/codecs/libgme/vgm_emu.c @@ -215,9 +215,7 @@ static blargg_err_t check_vgm_header( struct header_t* h ) static void set_voice( struct Vgm_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) { if ( i < sms_osc_count ) { - int j; - for ( j = sms_osc_count; --j >= 0; ) - Sms_apu_set_output( &this->psg, j, c, l, r ); + Sms_apu_set_output( &this->psg, i, c, l, r ); } } @@ -294,6 +292,9 @@ blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_ // Post load Sound_set_tempo( this, this->tempo ); Sound_mute_voices( this, this->mute_mask_ ); + + // so we can start playback + this->current_track = 0; return 0; } |