summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-09-09 17:57:33 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-09-09 17:57:33 +0000
commitc97c5e5d17617475eaf4b81407dd5913ffa89528 (patch)
tree6bedd4b8a6614daed854ae99085bb776563d3fab /apps
parent544a52d9eb274c8989df2268324dcbf8f18795c6 (diff)
downloadrockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.tar.gz
rockbox-c97c5e5d17617475eaf4b81407dd5913ffa89528.zip
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')
-rw-r--r--apps/codecs/libgme/nes_apu.c19
-rw-r--r--apps/codecs/libgme/nes_apu.h4
-rw-r--r--apps/codecs/libgme/nes_cpu.h9
-rw-r--r--apps/codecs/libgme/nes_oscs.c2
-rw-r--r--apps/codecs/libgme/nes_vrc6_apu.c1
-rw-r--r--apps/codecs/libgme/nsf_emu.c8
-rw-r--r--apps/codecs/libgme/vgm_emu.c7
7 files changed, 30 insertions, 20 deletions
diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c
index 630e71f450..b6c88bc7e7 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 )
44 Apu_reset( this, false, 0 ); 44 Apu_reset( this, false, 0 );
45} 45}
46 46
47void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd ) 47#if 0
48// sq and tnd must use a fixed point frac where 1.0 = FP_ONE_VOLUME
49void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd )
48{ 50{
49 this->dmc.nonlinear = true; 51 this->dmc.nonlinear = true;
50 Synth_volume( &this->square_synth, (int)((long long)(sq * FP_ONE_VOLUME) / amp_range) ); 52 Synth_volume( &this->square_synth, sq );
51 53
52 Synth_volume( &this->triangle.synth, tnd * 2.752 ); 54 Synth_volume( &this->triangle.synth, (int)((long long)(FP_ONE_VOLUME * 2.752) * tnd / FP_ONE_VOLUME) );
53 Synth_volume( &this->noise.synth , tnd * 1.849 ); 55 Synth_volume( &this->noise.synth , (int)((long long)(FP_ONE_VOLUME * 1.849) * tnd / FP_ONE_VOLUME) );
54 Synth_volume( &this->dmc.synth , tnd ); 56 Synth_volume( &this->dmc.synth , tnd );
55 57
56 this->square1 .osc.last_amp = 0; 58 this->square1 .osc.last_amp = 0;
@@ -59,15 +61,16 @@ void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd )
59 this->noise .osc.last_amp = 0; 61 this->noise .osc.last_amp = 0;
60 this->dmc .osc.last_amp = 0; 62 this->dmc .osc.last_amp = 0;
61} 63}
64#endif
62 65
63void Apu_volume( struct Nes_Apu* this, int v ) 66void Apu_volume( struct Nes_Apu* this, int v )
64{ 67{
65 if ( !this->dmc.nonlinear ) 68 if ( !this->dmc.nonlinear )
66 { 69 {
67 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 70 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
68 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 71 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
69 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 72 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
70 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 73 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
71 } 74 }
72} 75}
73 76
diff --git a/apps/codecs/libgme/nes_apu.h b/apps/codecs/libgme/nes_apu.h
index 0a2b1f57cd..152ec94a17 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 )
130static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); } 130static inline nes_time_t Apu_next_dmc_read_time( struct Nes_Apu* this ) { return Dmc_next_read_time( &this->dmc ); }
131void Apu_irq_changed( struct Nes_Apu* this ); 131void Apu_irq_changed( struct Nes_Apu* this );
132 132
133#if 0
133// Experimental 134// Experimental
134void Apu_enable_nonlinear_( struct Nes_Apu* this, double sq, double tnd ); 135void Apu_enable_nonlinear_( struct Nes_Apu* this, int sq, int tnd );
136#endif
135#endif 137#endif
diff --git a/apps/codecs/libgme/nes_cpu.h b/apps/codecs/libgme/nes_cpu.h
index 7129ffd925..e4538cd00c 100644
--- a/apps/codecs/libgme/nes_cpu.h
+++ b/apps/codecs/libgme/nes_cpu.h
@@ -48,11 +48,14 @@ struct Nes_Cpu {
48 struct cpu_state_t cpu_state_; 48 struct cpu_state_t cpu_state_;
49}; 49};
50 50
51static inline void Cpu_init( struct Nes_Cpu* this ) { this->cpu_state = &this->cpu_state_; } 51static inline void Cpu_init( struct Nes_Cpu* this )
52{
53 this->cpu_state = &this->cpu_state_;
54}
52 55
53// Clears registers and maps all pages to unmapped_page 56// Clears registers and maps all pages to unmapped_page
54void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page ); 57void Cpu_reset( struct Nes_Cpu* this, void const* unmapped_page );
55 58
56// Maps code memory (memory accessed via the program counter). Start and size 59// Maps code memory (memory accessed via the program counter). Start and size
57// must be multiple of page_size. If mirror_size is non-zero, the first 60// must be multiple of page_size. If mirror_size is non-zero, the first
58// mirror_size bytes are repeated over the range. mirror_size must be a 61// 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 )
101{ 104{
102 this->end_time = t; 105 this->end_time = t;
103 Cpu_update_end_time( this, t, this->irq_time ); 106 Cpu_update_end_time( this, t, this->irq_time );
104} 107}
105 108
106#endif 109#endif
diff --git a/apps/codecs/libgme/nes_oscs.c b/apps/codecs/libgme/nes_oscs.c
index f97ce2176d..ac6e5759da 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 )
565 int noise = this->noise; 565 int noise = this->noise;
566 int delta = amp * 2 - volume; 566 int delta = amp * 2 - volume;
567 const int tap = (osc->regs [2] & mode_flag ? 8 : 13); 567 const int tap = (osc->regs [2] & mode_flag ? 8 : 13);
568 Blip_set_modified( osc->output ); 568 Blip_set_modified( output );
569 569
570 do { 570 do {
571 int feedback = (noise << tap) ^ (noise << 14); 571 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 55fccb7b0f..99a9ae3fed 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
107 if ( time < end_time ) 107 if ( time < end_time )
108 { 108 {
109 int phase = osc->phase; 109 int phase = osc->phase;
110 Blip_set_modified( output );
110 111
111 do 112 do
112 { 113 {
diff --git a/apps/codecs/libgme/nsf_emu.c b/apps/codecs/libgme/nsf_emu.c
index 705c345fa6..d9fc4e031d 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 )
299 blargg_err_t err = init_sound( this ); 299 blargg_err_t err = init_sound( this );
300 if ( err ) 300 if ( err )
301 return err; 301 return err;
302
303 // Post load
304 Sound_set_tempo( this, this->tempo );
305 Sound_mute_voices( this, this->mute_mask_ );
306 302
307 // Set track_count 303 // Set track_count
308 this->track_count = this->header.track_count; 304 this->track_count = this->header.track_count;
@@ -312,6 +308,10 @@ blargg_err_t Nsf_post_load( struct Nsf_Emu* this )
312 Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); 308 Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ );
313 RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) ); 309 RETURN_ERR( Buffer_set_channel_count( &this->stereo_buf, this->voice_count, this->voice_types ) );
314 this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); 310 this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf );
311
312 // Post load
313 Sound_set_tempo( this, this->tempo );
314 Sound_mute_voices( this, this->mute_mask_ );
315 return 0; 315 return 0;
316} 316}
317 317
diff --git a/apps/codecs/libgme/vgm_emu.c b/apps/codecs/libgme/vgm_emu.c
index 4f8a2adbc1..8b22aba06f 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 )
215static void set_voice( struct Vgm_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r ) 215static void set_voice( struct Vgm_Emu* this, int i, struct Blip_Buffer* c, struct Blip_Buffer* l, struct Blip_Buffer* r )
216{ 216{
217 if ( i < sms_osc_count ) { 217 if ( i < sms_osc_count ) {
218 int j; 218 Sms_apu_set_output( &this->psg, i, c, l, r );
219 for ( j = sms_osc_count; --j >= 0; )
220 Sms_apu_set_output( &this->psg, j, c, l, r );
221 } 219 }
222} 220}
223 221
@@ -294,6 +292,9 @@ blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_
294 // Post load 292 // Post load
295 Sound_set_tempo( this, this->tempo ); 293 Sound_set_tempo( this, this->tempo );
296 Sound_mute_voices( this, this->mute_mask_ ); 294 Sound_mute_voices( this, this->mute_mask_ );
295
296 // so we can start playback
297 this->current_track = 0;
297 return 0; 298 return 0;
298} 299}
299 300