Remove residual float operations from sid codec.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29919 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2011-05-23 18:28:08 +00:00
parent 645ffa9beb
commit 8767ba9a85

View file

@ -67,6 +67,7 @@ CODEC_HEADER
#define CHUNK_SIZE (1024*2)
#define SID_BUFFER_SIZE 0x10000
#define SAMPLE_RATE 44100
/* This codec supports SID Files:
*
@ -157,8 +158,10 @@ struct sidflt {
int mixing_frequency IDATA_ATTR;
unsigned long freqmul IDATA_ATTR;
int filtmul IDATA_ATTR;
#ifndef ROCKBOX
unsigned long attacks [16] IDATA_ATTR;
unsigned long releases[16] IDATA_ATTR;
#endif
/* ------------------------------------------------------------ globals */
struct s6581 sid IDATA_ATTR;
@ -187,6 +190,7 @@ static int internal_period, internal_order, internal_start, internal_end,
internal_add, internal_repeat_times, internal_repeat_start IDATA_ATTR;
/* ---------------------------------------------------------- constants */
#ifndef ROCKBOX
static const float attackTimes[16] ICONST_ATTR =
{
0.0022528606, 0.0080099577, 0.0157696042, 0.0237795619,
@ -200,7 +204,23 @@ static const float decayReleaseTimes[16] ICONST_ATTR =
0.169078356, 0.205199432, 0.240551975, 0.301266125, 0.750858245,
1.50171551, 2.40243682, 3.00189298, 9.00721405, 15.010998, 24.0182111
};
#else
#define DIV(X) ((int)(0x1000000 / (X * SAMPLE_RATE)))
static const unsigned long attacks[16] ICONST_ATTR =
{
DIV(0.0022528606), DIV(0.0080099577), DIV(0.0157696042), DIV(0.0237795619),
DIV(0.0372963655), DIV(0.0550684591), DIV(0.0668330845), DIV(0.0783473987),
DIV(0.0981219818), DIV(0.2445540210), DIV(0.4891080420), DIV(0.7824727420),
DIV(0.9777154610), DIV(2.9336470100), DIV(4.8890779300), DIV(7.8227249300)
};
static const unsigned long releases[16] ICONST_ATTR =
{
DIV(0.00891777693), DIV(0.0245940510), DIV(0.0484185907), DIV(0.0730116639),
DIV(0.11451247500), DIV(0.1690783560), DIV(0.2051994320), DIV(0.2405519750),
DIV(0.30126612500), DIV(0.7508582450), DIV(1.5017155100), DIV(2.4024368200),
DIV(3.00189298000), DIV(9.0072140500), DIV(15.010998000), DIV(24.018211100)
};
#endif
static const int opcodes[256] ICONST_ATTR = {
_brk,ora,xxx,xxx,xxx,ora,asl,xxx,php,ora,asl,xxx,xxx,ora,asl,xxx,
bpl,ora,xxx,xxx,xxx,ora,asl,xxx,clc,ora,xxx,xxx,xxx,ora,asl,xxx,
@ -246,10 +266,14 @@ static inline int quickfloat_ConvertFromInt(int i)
{
return (i<<16);
}
#ifndef ROCKBOX
static inline int quickfloat_ConvertFromFloat(float f)
{
return (int)(f*(1<<16));
}
#else
#define quickfloat_ConvertFromFloat(X) (int)(X*(1<<16))
#endif
static inline int quickfloat_Multiply(int a, int b)
{
return (a>>8)*(b>>8);
@ -325,15 +349,19 @@ static inline int GenerateDigi(int sIn)
void synth_init(unsigned long mixfrq) ICODE_ATTR;
void synth_init(unsigned long mixfrq)
{
#ifndef ROCKBOX
int i;
#endif
mixing_frequency = mixfrq;
fracPos = 0;
freqmul = 15872000 / mixfrq;
filtmul = quickfloat_ConvertFromFloat(21.5332031f)/mixfrq;
#ifndef ROCKBOX
for (i=0;i<16;i++) {
attacks [i]=(int) (0x1000000 / (attackTimes[i]*mixfrq));
releases[i]=(int) (0x1000000 / (decayReleaseTimes[i]*mixfrq));
}
#endif
memset(&sid,0,sizeof(sid));
memset(osc,0,sizeof(osc));
memset(&filter,0,sizeof(filter));
@ -1207,7 +1235,7 @@ enum codec_status codec_main(enum codec_entry_call_reason reason)
{
if (reason == CODEC_LOAD) {
/* Make use of 44.1khz */
ci->configure(DSP_SWITCH_FREQUENCY, 44100);
ci->configure(DSP_SWITCH_FREQUENCY, SAMPLE_RATE);
/* Sample depth is 28 bit host endian */
ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
/* Mono output */
@ -1241,7 +1269,7 @@ enum codec_status codec_run(void)
return CODEC_ERROR;
}
c64Init(44100);
c64Init(SAMPLE_RATE);
LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr,
&subSongsMax, &subSong, &song_speed, (unsigned short)filesize);
sidPoke(24, 15); /* Turn on full volume */
@ -1262,7 +1290,7 @@ enum codec_status codec_run(void)
/* New time is ready in param */
/* Start playing from scratch */
c64Init(44100);
c64Init(SAMPLE_RATE);
LoadSIDFromMemory(sidfile, &load_addr, &init_addr, &play_addr,
&subSongsMax, &subSong, &song_speed, (unsigned short)filesize);
sidPoke(24, 15); /* Turn on full volume */