summaryrefslogtreecommitdiff
path: root/apps/plugins/bubbles.c
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2007-07-31 04:59:03 +0000
committerKevin Ferrare <kevin@rockbox.org>2007-07-31 04:59:03 +0000
commitdf4f56b2b0a5343fb40cc749b24897f239c76be7 (patch)
treef324668f9b4c718649db29b6c7f9025bf115d309 /apps/plugins/bubbles.c
parent4e8b171fc4cc3b62a1656ae67e92944ff855dcd3 (diff)
downloadrockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.zip
rockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.tar.gz
rockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.tar.bz2
rockbox-df4f56b2b0a5343fb40cc749b24897f239c76be7.tar.xz
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
Diffstat (limited to 'apps/plugins/bubbles.c')
-rw-r--r--apps/plugins/bubbles.c91
1 files changed, 14 insertions, 77 deletions
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c
index dca3ede..25fd4f3 100644
--- a/apps/plugins/bubbles.c
+++ b/apps/plugins/bubbles.c
@@ -20,11 +20,13 @@
****************************************************************************/
#include "plugin.h"
-#include "xlcd.h"
-#include "pluginlib_actions.h"
#ifdef HAVE_LCD_BITMAP
+#include "xlcd.h"
+#include "pluginlib_actions.h"
+#include "fixedpoint.h"
+
PLUGIN_HEADER
/* files */
@@ -1278,71 +1280,6 @@ struct game_context {
struct tile playboard[BB_HEIGHT][BB_WIDTH];
};
-/*
- * Precalculated sine and cosine * 16384 (fixed point 18.14)
- * Borrowed from cube.c plugin
- */
-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 long sin(int val) {
- val = (val+360)%360;
-
- if(val < 181) {
- if(val < 91) {
- /* phase 0-90 degree */
- return (long)sin_table[val];
- } else {
- /* phase 91-180 degree */
- return (long)sin_table[180-val];
- }
- } else {
- if(val < 271) {
- /* phase 181-270 degree */
- return -(long)sin_table[val-180];
- } else {
- /* phase 270-359 degree */
- return -(long)sin_table[360-val];
- }
- }
- return 0;
-}
-
-static long cos(int val) {
- val = (val+360)%360;
-
- if(val < 181) {
- if(val < 91) {
- /* phase 0-90 degree */
- return (long)sin_table[90-val];
- } else {
- /* phase 91-180 degree */
- return -(long)sin_table[val-90];
- }
- } else {
- if(val < 271) {
- /* phase 181-270 degree */
- return -(long)sin_table[270-val];
- } else {
- /* phase 270-359 degree */
- return (long)sin_table[val-270];
- }
- }
- return 0;
-}
-
-
-
static void bubbles_init(struct game_context* bb);
static bool bubbles_nextlevel(struct game_context* bb);
static void bubbles_getonboard(struct game_context* bb);
@@ -1553,17 +1490,17 @@ static void bubbles_drawboard(struct game_context* bb) {
ROW_HEIGHT*(BB_HEIGHT-2)+BUBBLE_HEIGHT);
/* draw arrow */
- tipx = SHOTX+BUBBLE_WIDTH/2+(((sin(bb->angle)>>4)*BUBBLE_WIDTH*3/2)>>10);
- tipy = SHOTY+BUBBLE_HEIGHT/2-(((cos(bb->angle)>>4)*BUBBLE_HEIGHT*3/2)>>10);
+ tipx = SHOTX+BUBBLE_WIDTH/2+(((sin_int(bb->angle)>>4)*BUBBLE_WIDTH*3/2)>>10);
+ tipy = SHOTY+BUBBLE_HEIGHT/2-(((cos_int(bb->angle)>>4)*BUBBLE_HEIGHT*3/2)>>10);
- rb->lcd_drawline(SHOTX+BUBBLE_WIDTH/2+(((sin(bb->angle)>>4)*BUBBLE_WIDTH/2)>>10),
- SHOTY+BUBBLE_HEIGHT/2-(((cos(bb->angle)>>4)*BUBBLE_HEIGHT/2)>>10),
+ rb->lcd_drawline(SHOTX+BUBBLE_WIDTH/2+(((sin_int(bb->angle)>>4)*BUBBLE_WIDTH/2)>>10),
+ SHOTY+BUBBLE_HEIGHT/2-(((cos_int(bb->angle)>>4)*BUBBLE_HEIGHT/2)>>10),
tipx, tipy);
xlcd_filltriangle(tipx, tipy,
- tipx+(((sin(bb->angle-135)>>4)*BUBBLE_WIDTH/3)>>10),
- tipy-(((cos(bb->angle-135)>>4)*BUBBLE_HEIGHT/3)>>10),
- tipx+(((sin(bb->angle+135)>>4)*BUBBLE_WIDTH/3)>>10),
- tipy-(((cos(bb->angle+135)>>4)*BUBBLE_HEIGHT/3)>>10));
+ tipx+(((sin_int(bb->angle-135)>>4)*BUBBLE_WIDTH/3)>>10),
+ tipy-(((cos_int(bb->angle-135)>>4)*BUBBLE_HEIGHT/3)>>10),
+ tipx+(((sin_int(bb->angle+135)>>4)*BUBBLE_WIDTH/3)>>10),
+ tipy-(((cos_int(bb->angle+135)>>4)*BUBBLE_HEIGHT/3)>>10));
/* draw text */
rb->lcd_getstringsize(level, &w, &h);
@@ -1608,8 +1545,8 @@ static int bubbles_fire(struct game_context* bb) {
/* get current bubble */
bubblecur = bb->queue[bb->nextinq];
- shotxinc = ((sin(bb->angle)>>4)*BUBBLE_WIDTH)/3;
- shotyinc = ((-1*(cos(bb->angle)>>4))*BUBBLE_HEIGHT)/3;
+ shotxinc = ((sin_int(bb->angle)>>4)*BUBBLE_WIDTH)/3;
+ shotyinc = ((-1*(cos_int(bb->angle)>>4))*BUBBLE_HEIGHT)/3;
shotxofs = shotyofs = 0;
/* advance the queue */