2005-10-28 01:31:03 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
2005-10-30 01:24:35 +00:00
|
|
|
* Copyright (C) 2005 Kevin Ferrare
|
2005-10-28 01:31:03 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-10-28 01:31:03 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/helper.h"
|
2010-08-24 14:30:46 +00:00
|
|
|
#include "lib/pluginlib_exit.h"
|
2005-10-28 01:31:03 +00:00
|
|
|
|
|
|
|
/******************************* Globals ***********************************/
|
|
|
|
|
|
|
|
/* Key assignement */
|
2006-02-24 20:54:09 +00:00
|
|
|
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
2007-07-27 09:57:27 +00:00
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2005-12-14 01:31:37 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_MENU
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_SCROLL_FWD
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_SCROLL_BACK
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
|
2006-01-18 11:09:06 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2006-08-03 20:17:25 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_SCROLL_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_SCROLL_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2006-02-24 15:42:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
2007-05-19 23:38:09 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
2006-02-24 15:42:52 +00:00
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
2009-01-24 22:41:55 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_C200_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
|
2009-04-10 17:28:26 +00:00
|
|
|
(CONFIG_KEYPAD == SANSA_M200_PAD)
|
2006-10-26 13:38:09 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
|
|
|
#define STARFIELD_QUIT (BUTTON_HOME|BUTTON_REPEAT)
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
|
|
|
|
2008-02-17 12:23:02 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
|
|
|
|
#define STARFIELD_QUIT BUTTON_BACK
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2008-03-01 22:55:09 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MROBE100_PAD)
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2008-03-22 10:24:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_RC_REC
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_RC_VOL_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_RC_VOL_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RC_FF
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_RC_REW
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_RC_MODE
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2008-10-07 16:38:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO67_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_STOP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_PLAY
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_MENU
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif (CONFIG_KEYPAD == COWON_D2_PAD)
|
2008-03-22 22:03:34 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_BACK
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2009-04-07 23:41:44 +00:00
|
|
|
|
2010-11-02 20:09:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2009-12-05 14:34:47 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_NEXT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_PREV
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2009-12-08 12:29:25 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD) || (CONFIG_KEYPAD == ONDAVX777_PAD) || (CONFIG_KEYPAD == MROBE500_PAD)
|
2009-04-07 23:41:44 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_POWER
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_FFWD
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define STARFIELD_QUIT BUTTON_REC
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_NEXT
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_PREV
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define STARFIELD_QUIT (BUTTON_REC|BUTTON_PLAY)
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_VOL_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_VOL_DOWN
|
2010-11-02 10:44:34 +00:00
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_FF
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_REW
|
2010-04-26 21:40:00 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
#define STARFIELD_QUIT (BUTTON_REC|BUTTON_REPEAT)
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_FF
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_REW
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef STARFIELD_QUIT
|
|
|
|
#define STARFIELD_QUIT BUTTON_TOPLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_INCREASE_ZMOVE
|
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_TOPMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_DECREASE_ZMOVE
|
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_BOTTOMMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_INCREASE_NB_STARS
|
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_MIDRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_DECREASE_NB_STARS
|
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_MIDLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_TOGGLE_COLOR
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_CENTER
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STARFIELD_QUIT
|
2005-10-28 01:31:03 +00:00
|
|
|
#define STARFIELD_QUIT BUTTON_OFF
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_INCREASE_ZMOVE
|
2005-10-28 01:31:03 +00:00
|
|
|
#define STARFIELD_INCREASE_ZMOVE BUTTON_UP
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_DECREASE_ZMOVE
|
2005-10-28 01:31:03 +00:00
|
|
|
#define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_INCREASE_NB_STARS
|
2005-10-28 01:31:03 +00:00
|
|
|
#define STARFIELD_INCREASE_NB_STARS BUTTON_RIGHT
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef STARFIELD_DECREASE_NB_STARS
|
2005-10-28 01:31:03 +00:00
|
|
|
#define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STARFIELD_TOGGLE_COLOR
|
2007-06-30 22:28:01 +00:00
|
|
|
#ifdef BUTTON_SELECT
|
2007-06-30 22:12:22 +00:00
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
|
2007-06-30 22:28:01 +00:00
|
|
|
#else
|
|
|
|
#define STARFIELD_TOGGLE_COLOR BUTTON_PLAY
|
|
|
|
#endif
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
2006-06-30 16:43:47 +00:00
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define STARFIELD_RC_QUIT BUTTON_RC_STOP
|
|
|
|
#endif
|
|
|
|
|
2005-10-28 01:31:03 +00:00
|
|
|
|
|
|
|
#define LCD_CENTER_X (LCD_WIDTH/2)
|
|
|
|
#define LCD_CENTER_Y (LCD_HEIGHT/2)
|
|
|
|
#define Z_MAX_DIST 100
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_STARS (LCD_WIDTH*LCD_HEIGHT*20)/100
|
2007-04-08 15:10:51 +00:00
|
|
|
#define INIT_STARS 200
|
|
|
|
#define STARFIELD_INCREASE_STEP 50
|
2005-10-28 01:31:03 +00:00
|
|
|
#define INIT_SPACE_SPEED 1
|
|
|
|
#define STAR_MAX_VELOCITY 2
|
|
|
|
/*
|
|
|
|
* max 3d coord in the 2d screen :
|
|
|
|
* example with x
|
|
|
|
* x2d=x3d/z+LCD_CENTER_X (+LCD_CENTER_X to center ...)
|
|
|
|
* so
|
|
|
|
* max_x2d=max_x3d/max_z+LCD_CENTER_X
|
|
|
|
* max_x3d=(max_x2d-LCD_CENTER_X)*max_z
|
|
|
|
* with
|
|
|
|
* max_x2d = LCD_WIDTH
|
|
|
|
* max_z = Z_MAX_DIST
|
|
|
|
* we have now
|
|
|
|
* max_x3d=(LCD_WIDTH-LCD_CENTER_X)*Z_MAX_DIST
|
|
|
|
* max_x3d=LCD_CENTER_X*Z_MAX_DIST
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_INIT_STAR_X LCD_CENTER_X*Z_MAX_DIST
|
|
|
|
#define MAX_INIT_STAR_Y LCD_CENTER_Y*Z_MAX_DIST
|
|
|
|
|
|
|
|
#define MSG_DISP_TIME 30
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each star's stuffs
|
|
|
|
*/
|
|
|
|
struct star
|
|
|
|
{
|
|
|
|
int x,y,z;
|
|
|
|
int velocity;
|
2007-06-30 22:28:01 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-30 22:12:22 +00:00
|
|
|
int color;
|
|
|
|
#endif
|
2005-10-28 01:31:03 +00:00
|
|
|
};
|
|
|
|
|
2007-06-30 22:12:22 +00:00
|
|
|
static inline void star_init(struct star * star, int z_move, bool color)
|
2005-10-28 01:31:03 +00:00
|
|
|
{
|
|
|
|
star->velocity=rb->rand() % STAR_MAX_VELOCITY+1;
|
|
|
|
/* choose x between -MAX_INIT_STAR_X and MAX_INIT_STAR_X */
|
|
|
|
star->x=rb->rand() % (2*MAX_INIT_STAR_X)-MAX_INIT_STAR_X;
|
|
|
|
star->y=rb->rand() % (2*MAX_INIT_STAR_Y)-MAX_INIT_STAR_Y;
|
2007-06-30 22:28:01 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-30 22:12:22 +00:00
|
|
|
if(color)
|
|
|
|
star->color=LCD_RGBPACK(rb->rand()%128+128,rb->rand()%128+128,
|
|
|
|
rb->rand()%128+128);
|
|
|
|
else
|
|
|
|
star->color=LCD_WHITE;
|
|
|
|
#else
|
|
|
|
(void)color;
|
|
|
|
#endif
|
2005-10-28 01:31:03 +00:00
|
|
|
if(z_move>=0)
|
|
|
|
star->z=Z_MAX_DIST;
|
|
|
|
else
|
|
|
|
star->z=rb->rand() %Z_MAX_DIST/2+1;
|
|
|
|
}
|
|
|
|
|
2007-06-30 22:12:22 +00:00
|
|
|
static inline void star_move(struct star * star, int z_move, bool color)
|
2005-10-28 01:31:03 +00:00
|
|
|
{
|
|
|
|
star->z -= z_move*star->velocity;
|
|
|
|
if (star->z <= 0 || star->z > Z_MAX_DIST)
|
2007-06-30 22:12:22 +00:00
|
|
|
star_init(star, z_move, color);
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
|
2007-06-30 22:12:22 +00:00
|
|
|
static inline void star_draw(struct star * star, int z_move, bool color)
|
2005-10-28 01:31:03 +00:00
|
|
|
{
|
|
|
|
int x_draw, y_draw;
|
|
|
|
/*
|
|
|
|
* 3d -> 2d : projection on the screen : x2d=x3d/z (thales theorem)
|
|
|
|
* we put the star in the center of the screen
|
|
|
|
*/
|
|
|
|
x_draw = star->x / star->z + LCD_CENTER_X;
|
|
|
|
if (x_draw < 1 || x_draw >= LCD_WIDTH)
|
|
|
|
{
|
2007-06-30 22:12:22 +00:00
|
|
|
star_init(star, z_move, color);
|
2005-10-28 01:31:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
y_draw = star->y / star->z + LCD_CENTER_Y;
|
|
|
|
if (y_draw < 1 || y_draw >= LCD_HEIGHT)
|
|
|
|
{
|
2007-06-30 22:12:22 +00:00
|
|
|
star_init(star, z_move, color);
|
2005-10-28 01:31:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-04-08 15:10:51 +00:00
|
|
|
|
2007-06-30 22:28:01 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-30 22:12:22 +00:00
|
|
|
rb->lcd_set_foreground(star->color);
|
|
|
|
#endif
|
|
|
|
|
2005-10-28 01:31:03 +00:00
|
|
|
rb->lcd_drawpixel(x_draw, y_draw);
|
|
|
|
if(star->z<5*Z_MAX_DIST/6)
|
|
|
|
{
|
|
|
|
rb->lcd_drawpixel(x_draw, y_draw - 1);
|
|
|
|
rb->lcd_drawpixel(x_draw - 1, y_draw);
|
|
|
|
if(star->z<Z_MAX_DIST/2)
|
|
|
|
{
|
|
|
|
rb->lcd_drawpixel(x_draw + 1, y_draw);
|
|
|
|
rb->lcd_drawpixel(x_draw, y_draw + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Whole starfield operations
|
|
|
|
*/
|
|
|
|
struct starfield
|
|
|
|
{
|
|
|
|
struct star tab[MAX_STARS];
|
|
|
|
int nb_stars;
|
|
|
|
int z_move;
|
2007-06-30 22:12:22 +00:00
|
|
|
bool color;
|
2005-10-28 01:31:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void starfield_init(struct starfield * starfield)
|
|
|
|
{
|
|
|
|
starfield->nb_stars=0;
|
|
|
|
starfield->z_move=INIT_SPACE_SPEED;
|
2007-06-30 22:12:22 +00:00
|
|
|
starfield->color=false;
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void starfield_add_stars(struct starfield * starfield,
|
|
|
|
int nb_to_add)
|
|
|
|
{
|
|
|
|
int i, old_nb_stars;
|
|
|
|
old_nb_stars=starfield->nb_stars;
|
|
|
|
starfield->nb_stars+=nb_to_add;
|
|
|
|
|
|
|
|
if(starfield->nb_stars > MAX_STARS)
|
|
|
|
starfield->nb_stars=MAX_STARS;
|
|
|
|
|
|
|
|
for( i=old_nb_stars ; i < starfield->nb_stars ; ++i )
|
|
|
|
{
|
2007-06-30 22:12:22 +00:00
|
|
|
star_init( &(starfield->tab[i]), starfield->z_move, starfield->color );
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void starfield_del_stars(struct starfield * starfield,
|
|
|
|
int nb_to_add)
|
|
|
|
{
|
|
|
|
starfield->nb_stars-=nb_to_add;
|
|
|
|
if(starfield->nb_stars<0)
|
|
|
|
starfield->nb_stars=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void starfield_move_and_draw(struct starfield * starfield)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0;i<starfield->nb_stars;++i)
|
|
|
|
{
|
2007-06-30 22:12:22 +00:00
|
|
|
star_move(&(starfield->tab[i]), starfield->z_move, starfield->color);
|
|
|
|
star_draw(&(starfield->tab[i]), starfield->z_move, starfield->color);
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct starfield starfield;
|
|
|
|
|
2005-11-17 18:54:00 +00:00
|
|
|
int plugin_main(void)
|
2005-10-28 01:31:03 +00:00
|
|
|
{
|
2007-04-08 15:10:51 +00:00
|
|
|
int button, avg_peak, t_disp=0;
|
2005-10-28 01:31:03 +00:00
|
|
|
int font_h, font_w;
|
2011-05-23 19:09:04 +00:00
|
|
|
bool pulse __attribute__ ((unused)) = true; /* 'unused' resolves warnings */
|
2005-10-28 01:31:03 +00:00
|
|
|
rb->lcd_getstringsize("A", &font_w, &font_h);
|
|
|
|
starfield_init(&starfield);
|
|
|
|
starfield_add_stars(&starfield, INIT_STARS);
|
2007-04-08 15:10:51 +00:00
|
|
|
|
2007-06-30 22:41:20 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
|
|
|
#endif
|
2006-11-26 18:26:31 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
#endif
|
2005-10-28 01:31:03 +00:00
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
rb->sleep(1);
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
2007-04-08 16:19:28 +00:00
|
|
|
#if ((CONFIG_CODEC == SWCODEC) || !defined(SIMULATOR) && \
|
|
|
|
((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)))
|
|
|
|
|
2007-04-08 15:10:51 +00:00
|
|
|
/* This will make the stars pulse to the music */
|
2010-01-02 16:03:30 +00:00
|
|
|
if(pulse){
|
2007-04-08 15:10:51 +00:00
|
|
|
|
|
|
|
/* Get the peaks. ( Borrowed from vu_meter ) */
|
2007-04-08 16:19:28 +00:00
|
|
|
#if (CONFIG_CODEC == SWCODEC)
|
2007-04-08 15:10:51 +00:00
|
|
|
int left_peak, right_peak;
|
|
|
|
rb->pcm_calculate_peaks(&left_peak, &right_peak);
|
2007-04-08 16:19:28 +00:00
|
|
|
#else
|
|
|
|
int left_peak = rb->mas_codec_readreg(0xC);
|
|
|
|
int right_peak = rb->mas_codec_readreg(0xD);
|
2007-04-08 15:10:51 +00:00
|
|
|
#endif
|
2007-04-08 16:19:28 +00:00
|
|
|
/* Devide peak data by 4098 to bring the max
|
|
|
|
value down from ~32k to 8 */
|
|
|
|
left_peak = left_peak/0x1000;
|
|
|
|
right_peak = right_peak/0x1000;
|
|
|
|
|
|
|
|
/* Make sure they dont stop */
|
|
|
|
if(left_peak<0x1)
|
|
|
|
left_peak = 0x1;
|
|
|
|
if(right_peak<0x1)
|
|
|
|
right_peak = 0x1;
|
|
|
|
|
|
|
|
/* And make sure they dont go over 8 */
|
|
|
|
if(left_peak>0x8)
|
|
|
|
left_peak = 0x8;
|
|
|
|
if(right_peak>0x8)
|
|
|
|
right_peak = 0x8;
|
|
|
|
|
|
|
|
/* We need the average of both chanels */
|
|
|
|
avg_peak = ( left_peak + right_peak )/2;
|
2007-04-08 15:10:51 +00:00
|
|
|
|
|
|
|
/* Set the speed to the peak meter */
|
|
|
|
starfield.z_move = avg_peak;
|
|
|
|
|
|
|
|
} /* if pulse */
|
2007-04-08 16:19:28 +00:00
|
|
|
#else
|
2007-06-30 22:12:22 +00:00
|
|
|
(void) avg_peak;
|
2007-04-08 16:19:28 +00:00
|
|
|
#endif
|
2005-10-28 01:31:03 +00:00
|
|
|
starfield_move_and_draw(&starfield);
|
|
|
|
|
2007-04-08 15:10:51 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-10-26 16:01:52 +00:00
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
2007-04-08 15:10:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* if a parameter is updated (by the user), we must print it */
|
2005-10-28 01:31:03 +00:00
|
|
|
if (t_disp > 0)
|
2007-04-08 15:10:51 +00:00
|
|
|
{
|
2005-10-28 01:31:03 +00:00
|
|
|
--t_disp;
|
2007-10-26 16:01:52 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-30 22:12:22 +00:00
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
#endif
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(0, LCD_HEIGHT-font_h, "star:%d speed:%d",
|
|
|
|
starfield.nb_stars, starfield.z_move);
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
rb->lcd_update();
|
|
|
|
|
|
|
|
button = rb->button_get(false);
|
|
|
|
switch(button)
|
|
|
|
{
|
|
|
|
case (STARFIELD_INCREASE_ZMOVE):
|
|
|
|
case (STARFIELD_INCREASE_ZMOVE | BUTTON_REPEAT):
|
|
|
|
++(starfield.z_move);
|
2007-04-08 15:10:51 +00:00
|
|
|
pulse=false;
|
2005-10-28 01:31:03 +00:00
|
|
|
t_disp=MSG_DISP_TIME;
|
|
|
|
break;
|
|
|
|
case (STARFIELD_DECREASE_ZMOVE):
|
|
|
|
case (STARFIELD_DECREASE_ZMOVE | BUTTON_REPEAT):
|
|
|
|
--(starfield.z_move);
|
2007-04-08 15:10:51 +00:00
|
|
|
pulse=false;
|
2005-10-28 01:31:03 +00:00
|
|
|
t_disp=MSG_DISP_TIME;
|
|
|
|
break;
|
|
|
|
case(STARFIELD_INCREASE_NB_STARS):
|
|
|
|
case(STARFIELD_INCREASE_NB_STARS | BUTTON_REPEAT):
|
|
|
|
starfield_add_stars(&starfield, STARFIELD_INCREASE_STEP);
|
|
|
|
t_disp=MSG_DISP_TIME;
|
|
|
|
break;
|
|
|
|
case(STARFIELD_DECREASE_NB_STARS):
|
|
|
|
case(STARFIELD_DECREASE_NB_STARS | BUTTON_REPEAT):
|
|
|
|
starfield_del_stars(&starfield, STARFIELD_INCREASE_STEP);
|
|
|
|
t_disp=MSG_DISP_TIME;
|
|
|
|
break;
|
2007-06-30 22:28:01 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-06-30 22:12:22 +00:00
|
|
|
case(STARFIELD_TOGGLE_COLOR):
|
|
|
|
starfield.color=!starfield.color;
|
|
|
|
break;
|
2007-06-30 22:28:01 +00:00
|
|
|
#endif
|
2006-06-30 16:43:47 +00:00
|
|
|
#ifdef STARFIELD_RC_QUIT
|
|
|
|
case STARFIELD_RC_QUIT:
|
|
|
|
#endif
|
2005-10-28 01:31:03 +00:00
|
|
|
case(STARFIELD_QUIT):
|
|
|
|
return PLUGIN_OK;
|
|
|
|
break;
|
2010-08-24 14:30:46 +00:00
|
|
|
default:
|
|
|
|
exit_on_usb(button);
|
|
|
|
break;
|
2005-10-28 01:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** Plugin entry point ****************************/
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2005-10-28 01:31:03 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
(void)parameter;
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn off backlight timeout */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_ignore_timeout();
|
2005-10-28 01:31:03 +00:00
|
|
|
|
2005-11-17 18:54:00 +00:00
|
|
|
ret = plugin_main();
|
2005-10-28 01:31:03 +00:00
|
|
|
|
2009-12-18 14:17:28 +00:00
|
|
|
/* Turn on backlight timeout (revert to settings) */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_use_settings();
|
2009-12-18 14:17:28 +00:00
|
|
|
|
2005-10-28 01:31:03 +00:00
|
|
|
return ret;
|
|
|
|
}
|