1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Andree Buschmann 2011-08-15 18:24:50 +00:00
parent 4087875f1c
commit 9477675f04
2 changed files with 19 additions and 12 deletions

View file

@ -35,12 +35,18 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
// Ported again to c by gama. // Ported again to c by gama.
// Not sure if performance is better than the original c version. // Not sure if performance is better than the original c version.
#if !defined(ROCKBOX) #if !defined(YM2612_CALCUL_TABLES)
#define YM2612_CALCUL_TABLES
#else
#include "ymtables.h" #include "ymtables.h"
#endif #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; const int output_bits = 14;
static const unsigned char DT_DEF_TAB [4 * 32] = 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; 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) : // Tableau LFO (LFO wav) :
for ( i = 0; i < LFO_LENGHT; i++ ) for ( i = 0; i < LFO_LENGHT; i++ )
{ {
#ifdef YM2612_CALCUL_TABLES
double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus double x = 1 + sin( 2.0 * PI * i * (1.0 / LFO_LENGHT) ); // Sinus
x *= 11.8 / ENV_STEP / 2; // ajusted to MAX enveloppe modulation 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; x *= (1 << (LFO_HBITS - 1)) - 1;
impl->g.LFO_FREQ_TAB [i] = (int) x; 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 : // Tableau Enveloppe :
// impl->g.ENV_TAB [0] -> impl->g.ENV_TAB [ENV_LENGHT - 1] = attack curve // 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); ((temp##x - ch->SLOT [S##x].env_max) >> 31);
#define GET_ENV \ #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; \ short const* const ENV_TAB = g->ENV_TAB; \
CALC_EN( 0 ) \ CALC_EN( 0 ) \
CALC_EN( 1 ) \ CALC_EN( 1 ) \
@ -923,7 +925,7 @@ int CH_S0_OUT_0 = ch->S0_OUT [0]; \
CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \ CH_OUTd >>= MAX_OUT_BITS - output_bits + 2; \
#define UPDATE_PHASE_CYCLE \ #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)); \ ch->FMS) >> (LFO_HBITS - 1 + 1)) + (1 << (LFO_FMS_LBITS - 1)); \
YM2612_LFOcnt += YM2612_LFOinc; \ YM2612_LFOcnt += YM2612_LFOinc; \
in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \ in0 += (ch->SLOT [S0].Finc * freq_LFO) >> (LFO_FMS_LBITS - 1); \

View file

@ -6,6 +6,10 @@
#include "blargg_common.h" #include "blargg_common.h"
#if !defined(ROCKBOX)
#define YM2612_CALCUL_TABLES
#endif
enum { ym2612_out_chan_count = 2 }; // stereo enum { ym2612_out_chan_count = 2 }; // stereo
enum { ym2612_channel_count = 6 }; enum { ym2612_channel_count = 6 };
enum { ym2612_disabled_time = -1 }; enum { ym2612_disabled_time = -1 };
@ -164,9 +168,10 @@ struct tables_t
int LFO_INC_TAB [8]; // LFO step table int LFO_INC_TAB [8]; // LFO step table
short ENV_TAB [2 * ENV_LENGHT + 8]; // ENV CURVE TABLE (attack & decay) 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_ENV_TAB [LFO_LENGHT]; // LFO AMS TABLE (adjusted for 11.8 dB)
short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE short LFO_FREQ_TAB [LFO_LENGHT]; // LFO FMS TABLE
#endif
int TL_TAB [TL_LENGHT * 2]; // TOTAL LEVEL TABLE (positif and minus) 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 DECAY_TO_ATTACK [ENV_LENGHT]; // Conversion from decay to attack phase
unsigned int FINC_TAB [2048]; // Frequency step table unsigned int FINC_TAB [2048]; // Frequency step table