summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-08-15 18:24:50 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-08-15 18:24:50 +0000
commit9477675f047aabf55490ea136d83c003bc330c84 (patch)
tree1b771cd110f809a10368913abac1bccfbb8ce038
parent4087875f1cf2677cc8542d7dd19cc3b4a8d26c2b (diff)
downloadrockbox-9477675f047aabf55490ea136d83c003bc330c84.tar.gz
rockbox-9477675f047aabf55490ea136d83c003bc330c84.zip
Save some RAM in a libgme emulator used for VGM codec. LFO_ENV_TAB[] and LFO_FREQ_TAB[] are obselete.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30319 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libgme/ym2612_emu.c24
-rw-r--r--apps/codecs/libgme/ym2612_emu.h7
2 files changed, 19 insertions, 12 deletions
diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c
index 970e4462e1..003be394dd 100644
--- a/apps/codecs/libgme/ym2612_emu.c
+++ b/apps/codecs/libgme/ym2612_emu.c
@@ -35,12 +35,18 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
35// Ported again to c by gama. 35// Ported again to c by gama.
36// Not sure if performance is better than the original c version. 36// Not sure if performance is better than the original c version.
37 37
38#if !defined(ROCKBOX) 38#if !defined(YM2612_CALCUL_TABLES)
39 #define YM2612_CALCUL_TABLES
40#else
41 #include "ymtables.h" 39 #include "ymtables.h"
42#endif 40#endif
43 41
42#ifdef YM2612_CALCUL_TABLES
43 #define FREQ_TAB_LOOKUP g->LFO_FREQ_TAB
44 #define ENV_TAB_LOOKUP g->LFO_ENV_TAB
45#else
46 #define FREQ_TAB_LOOKUP lfo_freq_coeff
47 #define ENV_TAB_LOOKUP lfo_env_coeff
48#endif
49
44const int output_bits = 14; 50const int output_bits = 14;
45 51
46static const unsigned char DT_DEF_TAB [4 * 32] = 52static const unsigned char DT_DEF_TAB [4 * 32] =
@@ -540,11 +546,10 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
540 impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j; 546 impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j;
541 } 547 }
542 548
549 #ifdef YM2612_CALCUL_TABLES
543 // Tableau LFO (LFO wav) : 550 // Tableau LFO (LFO wav) :
544
545 for ( i = 0; i < LFO_LENGHT; i++ ) 551 for ( i = 0; i < LFO_LENGHT; i++ )
546 { 552 {
547 #ifdef YM2612_CALCUL_TABLES
548 double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus 553 double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus
549 x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation 554 x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation
550 555
@@ -554,11 +559,8 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
554 x *= (1 << (LFO_HBITS - 1)) - 1; 559 x *= (1 << (LFO_HBITS - 1)) - 1;
555 560
556 impl->g.LFO_FREQ_TAB [i] = (int) x; 561 impl->g.LFO_FREQ_TAB [i] = (int) x;
557 #else
558 impl->g.LFO_ENV_TAB [i] = lfo_env_coeff [i];
559 impl->g.LFO_FREQ_TAB [i] = lfo_freq_coeff [i];
560 #endif
561 } 562 }
563 #endif
562 564
563 // Tableau Enveloppe : 565 // Tableau Enveloppe :
564 // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve 566 // impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve
@@ -901,7 +903,7 @@ int YM2612_LFOcnt = g->LFOcnt + YM2612_LFOinc;
901 ((temp##x - ch->SLOT [S##x].env_max) >> 31); 903 ((temp##x - ch->SLOT [S##x].env_max) >> 31);
902 904
903#define GET_ENV \ 905#define GET_ENV \
904int const env_LFO = g->LFO_ENV_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \ 906int const env_LFO = ENV_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \
905short const* const ENV_TAB = g->ENV_TAB; \ 907short const* const ENV_TAB = g->ENV_TAB; \
906CALC_EN( 0 ) \ 908CALC_EN( 0 ) \
907CALC_EN( 1 ) \ 909CALC_EN( 1 ) \
@@ -923,7 +925,7 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \
923CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ 925CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \
924 926
925#define UPDATE_PHASE_CYCLE \ 927#define UPDATE_PHASE_CYCLE \
926unsigned freq_LFO = ((g->LFO_FREQ_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \ 928unsigned freq_LFO = ((FREQ_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \
927 ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \ 929 ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \
928YM2612_LFOcnt += YM2612_LFOinc; \ 930YM2612_LFOcnt += YM2612_LFOinc; \
929in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ 931in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \
diff --git a/apps/codecs/libgme/ym2612_emu.h b/apps/codecs/libgme/ym2612_emu.h
index 4b8b5c0e94..96e3eae94b 100644
--- a/apps/codecs/libgme/ym2612_emu.h
+++ b/apps/codecs/libgme/ym2612_emu.h
@@ -6,6 +6,10 @@
6 6
7#include "blargg_common.h" 7#include "blargg_common.h"
8 8
9#if !defined(ROCKBOX)
10 #define YM2612_CALCUL_TABLES
11#endif
12
9enum { ym2612_out_chan_count = 2 }; // stereo 13enum { ym2612_out_chan_count = 2 }; // stereo
10enum { ym2612_channel_count = 6 }; 14enum { ym2612_channel_count = 6 };
11enum { ym2612_disabled_time = -1 }; 15enum { ym2612_disabled_time = -1 };
@@ -164,9 +168,10 @@ struct tables_t
164 int LFO_INC_TAB [8]; // LFO step table 168 int LFO_INC_TAB [8]; // LFO step table
165 169
166 short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay) 170 short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay)
167 171#ifdef YM2612_CALCUL_TABLES
168 short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB) 172 short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB)
169 short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE 173 short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE
174#endif
170 int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) 175 int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus)
171 unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase 176 unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase
172 unsigned int FINC_TAB [2048]; // Frequency step table 177 unsigned int FINC_TAB [2048]; // Frequency step table