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.zip
rockbox-9477675f047aabf55490ea136d83c003bc330c84.tar.gz
rockbox-9477675f047aabf55490ea136d83c003bc330c84.tar.bz2
rockbox-9477675f047aabf55490ea136d83c003bc330c84.tar.xz
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 970e446..003be39 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 */
// Ported again to c by gama.
// Not sure if performance is better than the original c version.
-#if !defined(ROCKBOX)
- #define YM2612_CALCUL_TABLES
-#else
+#if !defined(YM2612_CALCUL_TABLES)
#include "ymtables.h"
#endif
+#ifdef YM2612_CALCUL_TABLES
+ #define FREQ_TAB_LOOKUP g->LFO_FREQ_TAB
+ #define ENV_TAB_LOOKUP g->LFO_ENV_TAB
+#else
+ #define FREQ_TAB_LOOKUP lfo_freq_coeff
+ #define ENV_TAB_LOOKUP lfo_env_coeff
+#endif
+
const int output_bits = 14;
static 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
impl->g.SIN_TAB [(SIN_LENGHT / 2) + i] = impl->g.SIN_TAB [SIN_LENGHT - i] = TL_LENGHT + j;
}
+ #ifdef YM2612_CALCUL_TABLES
// Tableau LFO (LFO wav) :
-
for ( i = 0; i < LFO_LENGHT; i++ )
{
- #ifdef YM2612_CALCUL_TABLES
double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus
x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation
@@ -554,11 +559,8 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double
x *= (1 << (LFO_HBITS - 1)) - 1;
impl->g.LFO_FREQ_TAB [i] = (int) x;
- #else
- impl->g.LFO_ENV_TAB [i] = lfo_env_coeff [i];
- impl->g.LFO_FREQ_TAB [i] = lfo_freq_coeff [i];
- #endif
}
+ #endif
// Tableau Enveloppe :
// 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;
((temp##x - ch->SLOT [S##x].env_max) >> 31);
#define GET_ENV \
-int const env_LFO = g->LFO_ENV_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \
+int const env_LFO = ENV_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK]; \
short const* const ENV_TAB = g->ENV_TAB; \
CALC_EN( 0 ) \
CALC_EN( 1 ) \
@@ -923,7 +925,7 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \
CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \
#define UPDATE_PHASE_CYCLE \
-unsigned freq_LFO = ((g->LFO_FREQ_TAB [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \
+unsigned freq_LFO = ((FREQ_TAB_LOOKUP [YM2612_LFOcnt >> LFO_LBITS & LFO_MASK] * \
ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \
YM2612_LFOcnt += YM2612_LFOinc; \
in0 += (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 4b8b5c0..96e3eae 100644
--- a/apps/codecs/libgme/ym2612_emu.h
+++ b/apps/codecs/libgme/ym2612_emu.h
@@ -6,6 +6,10 @@
#include "blargg_common.h"
+#if !defined(ROCKBOX)
+ #define YM2612_CALCUL_TABLES
+#endif
+
enum { ym2612_out_chan_count = 2 }; // stereo
enum { ym2612_channel_count = 6 };
enum { ym2612_disabled_time = -1 };
@@ -164,9 +168,10 @@ struct tables_t
int LFO_INC_TAB [8]; // LFO step table
short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay)
-
+#ifdef YM2612_CALCUL_TABLES
short LFO_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB)
short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE
+#endif
int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus)
unsigned int DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase
unsigned int FINC_TAB [2048]; // Frequency step table