diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-12 21:36:29 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-12 21:36:29 +0000 |
commit | 724a2d2514578297a7fe21dc4c17a7b51a25758d (patch) | |
tree | d89b1646a89241cd3bcc9d355acbdc5a1072c803 /apps/codecs/libgme/emu8950.c | |
parent | 5f6d8bfcc0071848454447ecfffa8c337a3cd2b4 (diff) | |
download | rockbox-724a2d2514578297a7fe21dc4c17a7b51a25758d.tar.gz rockbox-724a2d2514578297a7fe21dc4c17a7b51a25758d.zip |
6th part of FS#12176. Reduce memory consumption of libgme emulators to allow enabling of NSF and SGC codecs for low memory targets. The main lookup table only requires byte precision and can be used by 2413 and 8950 emulators. Update the manual accordingly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30283 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libgme/emu8950.c')
-rw-r--r-- | apps/codecs/libgme/emu8950.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/apps/codecs/libgme/emu8950.c b/apps/codecs/libgme/emu8950.c index 0e9c4864eb..e75bf66d64 100644 --- a/apps/codecs/libgme/emu8950.c +++ b/apps/codecs/libgme/emu8950.c | |||
@@ -36,7 +36,12 @@ static unsigned int dphaseARTable[16][16]; | |||
36 | /** Phase incr table for Decay and Release. */ | 36 | /** Phase incr table for Decay and Release. */ |
37 | static unsigned int dphaseDRTable[16][16]; | 37 | static unsigned int dphaseDRTable[16][16]; |
38 | /** KSL + TL Table. */ | 38 | /** KSL + TL Table. */ |
39 | static int tllTable[16][8][1<<TL_BITS][4]; | 39 | #if !defined(ROCKBOX) |
40 | static unsigned char tllTable[16][8][1<<TL_BITS][4]; | ||
41 | #else | ||
42 | /* Use the table calculated in emu2413 which is identical. */ | ||
43 | extern unsigned char tllTable[16][8][1<<TL_BITS][4]; | ||
44 | #endif | ||
40 | static int rksTable[2][8][2]; | 45 | static int rksTable[2][8][2]; |
41 | /** Since we wont change clock rate in rockbox we can | 46 | /** Since we wont change clock rate in rockbox we can |
42 | skip this table */ | 47 | skip this table */ |
@@ -193,6 +198,7 @@ static void makeDphaseTable(int sampleRate, int clockRate) | |||
193 | } | 198 | } |
194 | #endif | 199 | #endif |
195 | 200 | ||
201 | #if !defined(ROCKBOX) | ||
196 | static void makeTllTable(void) | 202 | static void makeTllTable(void) |
197 | { | 203 | { |
198 | #define dB2(x) (int)((x)*2) | 204 | #define dB2(x) (int)((x)*2) |
@@ -209,17 +215,17 @@ static void makeTllTable(void) | |||
209 | for (TL=0; TL<64; TL++) | 215 | for (TL=0; TL<64; TL++) |
210 | for (KL=0; KL<4; KL++) { | 216 | for (KL=0; KL<4; KL++) { |
211 | if (KL==0) { | 217 | if (KL==0) { |
212 | tllTable[fnum][block][TL][KL] = ALIGN(TL, TL_STEP, EG_STEP); | 218 | tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; |
213 | } else { | 219 | } else { |
214 | int tmp = kltable[fnum] - dB2(3.000) * (7 - block); | 220 | int tmp = kltable[fnum] - dB2(3.000) * (7 - block); |
215 | if (tmp <= 0) | 221 | if (tmp <= 0) |
216 | tllTable[fnum][block][TL][KL] = ALIGN(TL, TL_STEP, EG_STEP); | 222 | tllTable[fnum][block][TL][KL] = (ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; |
217 | else | 223 | else |
218 | tllTable[fnum][block][TL][KL] = (int)((tmp>>(3-KL))/EG_STEP) + ALIGN(TL, TL_STEP, EG_STEP); | 224 | tllTable[fnum][block][TL][KL] = ((int)((tmp>>(3-KL))/EG_STEP) + ALIGN(TL, TL_STEP, EG_STEP) ) >> 1; |
219 | } | 225 | } |
220 | } | 226 | } |
221 | } | 227 | } |
222 | 228 | #endif | |
223 | 229 | ||
224 | // Rate Table for Attack | 230 | // Rate Table for Attack |
225 | static void makeDphaseARTable(int sampleRate, int clockRate) | 231 | static void makeDphaseARTable(int sampleRate, int clockRate) |
@@ -313,7 +319,7 @@ static inline void slotUpdatePG(struct Slot* slot) | |||
313 | 319 | ||
314 | static inline void slotUpdateTLL(struct Slot* slot) | 320 | static inline void slotUpdateTLL(struct Slot* slot) |
315 | { | 321 | { |
316 | slot->tll = tllTable[slot->fnum>>6][slot->block][slot->patch.TL][slot->patch.KL]; | 322 | slot->tll = (int)(tllTable[slot->fnum>>6][slot->block][slot->patch.TL][slot->patch.KL]) << 1; |
317 | } | 323 | } |
318 | 324 | ||
319 | static inline void slotUpdateRKS(struct Slot* slot) | 325 | static inline void slotUpdateRKS(struct Slot* slot) |
@@ -457,7 +463,9 @@ void OPL_init(struct Y8950* this, byte* ramBank, int sampleRam) | |||
457 | 463 | ||
458 | makeAdjustTable(); | 464 | makeAdjustTable(); |
459 | makeDB2LinTable(); | 465 | makeDB2LinTable(); |
466 | #if !defined(ROCKBOX) | ||
460 | makeTllTable(); | 467 | makeTllTable(); |
468 | #endif | ||
461 | makeRksTable(); | 469 | makeRksTable(); |
462 | makeSinTable(); | 470 | makeSinTable(); |
463 | 471 | ||