forked from len0rd/rockbox
plugins code cleanup : moved the duplicated fixed point table loockup based sinus/cosinus functions to fixedpoint.c, removed the bmp size definition in the clock.c|-(useless as the size is already defined in a .h generated with every bitmaps ...)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14087 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4e8b171fc4
commit
df4f56b2b0
6 changed files with 118 additions and 378 deletions
|
@ -29,6 +29,7 @@
|
|||
#ifndef HAVE_LCD_COLOR
|
||||
#include "gray.h"
|
||||
#endif
|
||||
#include "fixedpoint.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
@ -101,60 +102,6 @@ static int plasma_frequency;
|
|||
|
||||
#define WAV_AMP 90
|
||||
|
||||
|
||||
/* Precalculated sine * 16384 (fixed point 18.14) */
|
||||
static const short sin_table[91] =
|
||||
{
|
||||
0, 285, 571, 857, 1142, 1427, 1712, 1996, 2280, 2563,
|
||||
2845, 3126, 3406, 3685, 3963, 4240, 4516, 4790, 5062, 5334,
|
||||
5603, 5871, 6137, 6401, 6663, 6924, 7182, 7438, 7691, 7943,
|
||||
8191, 8438, 8682, 8923, 9161, 9397, 9630, 9860, 10086, 10310,
|
||||
10531, 10748, 10963, 11173, 11381, 11585, 11785, 11982, 12175, 12365,
|
||||
12550, 12732, 12910, 13084, 13254, 13420, 13582, 13740, 13894, 14043,
|
||||
14188, 14329, 14466, 14598, 14725, 14848, 14967, 15081, 15190, 15295,
|
||||
15395, 15491, 15582, 15668, 15749, 15825, 15897, 15964, 16025, 16082,
|
||||
16135, 16182, 16224, 16261, 16294, 16321, 16344, 16361, 16374, 16381,
|
||||
16384
|
||||
};
|
||||
|
||||
static short sin(int val)
|
||||
{
|
||||
/* value should be between 0 and 360 degree for correct lookup*/
|
||||
val%=360;
|
||||
if(val<0)
|
||||
val+=360;
|
||||
|
||||
/* Speed improvement through successive lookup */
|
||||
if (val < 181)
|
||||
{
|
||||
if (val < 91)
|
||||
{
|
||||
/* phase 0-90 degree */
|
||||
return (short)sin_table[val];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* phase 91-180 degree */
|
||||
return (short)sin_table[180-val];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val < 271)
|
||||
{
|
||||
/* phase 181-270 degree */
|
||||
return -(short)sin_table[val-180];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* phase 270-359 degree */
|
||||
return -(short)sin_table[360-val];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main wave function so we don't have to re-calc the sine
|
||||
* curve every time. Mess around WAV_AMP and FREQ to make slighlty
|
||||
|
@ -167,7 +114,7 @@ static void wave_table_generate(void)
|
|||
for (i=0;i<256;++i)
|
||||
{
|
||||
wave_array[i] = (unsigned char)((WAV_AMP
|
||||
* (sin((i * 360 * plasma_frequency) / 256))) / 16384);
|
||||
* (sin_int((i * 360 * plasma_frequency) / 256))) / 16384);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue