2005-10-07 20:35:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Plasma demo plugin
|
|
|
|
*
|
|
|
|
* My crack at making a 80's style retro plasma effect for the fantastic
|
|
|
|
* rockbox!
|
|
|
|
* Okay, I could've hard-coded the sine wave values, I just wanted the
|
|
|
|
* challange of calculating them! silly: maybe, fun: yes!
|
|
|
|
*
|
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-07 20:35:27 +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"
|
2005-10-07 20:35:27 +00:00
|
|
|
|
2006-02-26 13:37:42 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-02-22 21:41:48 +00:00
|
|
|
|
|
|
|
#ifndef HAVE_LCD_COLOR
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/grey.h"
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/fixedpoint.h"
|
2005-10-07 20:35:27 +00:00
|
|
|
|
2006-01-15 18:20:18 +00:00
|
|
|
PLUGIN_HEADER
|
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
/******************************* Globals ***********************************/
|
|
|
|
|
|
|
|
static unsigned char wave_array[256]; /* Pre calculated wave array */
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2006-02-22 21:41:48 +00:00
|
|
|
static fb_data colours[256]; /* Smooth transition of shades */
|
|
|
|
static int redfactor = 1, greenfactor = 2, bluefactor = 3;
|
|
|
|
static int redphase = 0, greenphase = 50, bluephase = 100;
|
|
|
|
/* lower chance of gray at regular intervals */
|
2006-02-16 16:07:21 +00:00
|
|
|
#else
|
2008-01-13 00:11:43 +00:00
|
|
|
GREY_INFO_STRUCT
|
2006-02-22 21:41:48 +00:00
|
|
|
static unsigned char colours[256]; /* Smooth transition of shades */
|
2008-01-04 23:42:38 +00:00
|
|
|
static unsigned char greybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */
|
2006-02-16 16:07:21 +00:00
|
|
|
static unsigned char *gbuf;
|
2007-04-21 18:38:25 +00:00
|
|
|
static size_t gbuf_size = 0;
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */
|
|
|
|
static int plasma_frequency;
|
2009-11-22 13:35:41 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
static bool boosted = false;
|
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
|
|
|
|
/* Key assignement, all bitmapped models */
|
2009-12-05 12:47:53 +00:00
|
|
|
#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == ONDIO_PAD)
|
|
|
|
#define PLASMA_QUIT BUTTON_OFF
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define PLASMA_QUIT BUTTON_OFF
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
|
|
|
#define PLASMA_RC_QUIT BUTTON_RC_STOP
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
|
|
|
#define PLASMA_QUIT BUTTON_MENU
|
2006-02-05 19:27:23 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_FWD
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_BACK
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2008-03-25 23:21:36 +00:00
|
|
|
|
2006-02-24 15:42:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2006-02-24 15:42:52 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
2009-01-04 23:33:15 +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)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2006-10-26 13:38:09 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT (BUTTON_HOME|BUTTON_REPEAT)
|
2009-04-10 17:28:26 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2009-04-10 17:28:26 +00:00
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2006-02-24 15:06:25 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
2008-03-25 23:21:36 +00:00
|
|
|
|
2006-08-03 20:17:25 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2006-08-03 20:17:25 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
2008-03-25 23:21:36 +00:00
|
|
|
|
2008-02-17 12:23:02 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_BACK
|
2008-02-17 12:23:02 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2008-03-25 23:21:36 +00:00
|
|
|
|
2008-03-01 22:55:09 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MROBE100_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2008-03-01 22:55:09 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2008-03-25 23:21:36 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_RC_REC
|
2008-03-25 23:21:36 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_RC_VOL_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_RC_VOL_DOWN
|
|
|
|
#define PLASMA_RC_QUIT BUTTON_REC
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif (CONFIG_KEYPAD == COWON_D2_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2008-03-25 23:21:36 +00:00
|
|
|
|
2008-10-07 16:38:28 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO67_PAD)
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2008-10-07 16:38:28 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_RIGHT
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_LEFT
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
2008-10-07 16:38:28 +00:00
|
|
|
#define PLASMA_RC_QUIT BUTTON_STOP
|
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_BACK
|
2008-12-04 21:28:56 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2008-12-04 21:28:56 +00:00
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2009-01-24 22:41:55 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_SELECT
|
2009-01-24 22:41:55 +00:00
|
|
|
|
2009-12-03 23:13:45 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
2009-12-03 23:13:45 +00:00
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
2009-12-03 23:13:45 +00:00
|
|
|
|
2009-12-08 12:29:25 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD) || (CONFIG_KEYPAD == ONDAVX777_PAD)
|
2009-04-07 23:41:44 +00:00
|
|
|
#define PLASMA_QUIT BUTTON_POWER
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define PLASMA_QUIT BUTTON_PLAY
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_LEFT
|
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define PLASMA_QUIT BUTTON_REC
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_UP
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN
|
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define PLASMA_QUIT (BUTTON_REC|BUTTON_PLAY)
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_VOL_DOWN
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_VOL_UP
|
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_PLAY
|
|
|
|
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef PLASMA_QUIT
|
|
|
|
#define PLASMA_QUIT BUTTON_TOPLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef PLASMA_INCREASE_FREQUENCY
|
|
|
|
#define PLASMA_INCREASE_FREQUENCY BUTTON_MIDRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef PLASMA_DECREASE_FREQUENCY
|
|
|
|
#define PLASMA_DECREASE_FREQUENCY BUTTON_MIDLEFT
|
|
|
|
#endif
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef PLASMA_REGEN_COLORS
|
2009-12-05 12:47:53 +00:00
|
|
|
#define PLASMA_REGEN_COLORS BUTTON_CENTER
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2008-04-27 16:13:18 +00:00
|
|
|
#endif /* HAVE_LCD_COLOR */
|
2009-12-05 12:47:53 +00:00
|
|
|
#endif /* HAVE_TOUCHSCREEN */
|
2006-02-16 16:07:21 +00:00
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
#define WAV_AMP 90
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* weirder looking plasmas!
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void wave_table_generate(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0;i<256;++i)
|
|
|
|
{
|
|
|
|
wave_array[i] = (unsigned char)((WAV_AMP
|
2009-07-05 18:06:07 +00:00
|
|
|
* (fp14_sin((i * 360 * plasma_frequency) / 256))) / 16384);
|
2005-10-07 20:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-22 21:41:48 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/* Make a smooth colour cycle. */
|
|
|
|
void shades_generate(int time)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned red, green, blue;
|
|
|
|
unsigned r = time * redfactor + redphase;
|
|
|
|
unsigned g = time * greenfactor + greenphase;
|
|
|
|
unsigned b = time * bluefactor + bluephase;
|
|
|
|
|
|
|
|
for(i=0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
r &= 0xFF; g &= 0xFF; b &= 0xFF;
|
|
|
|
|
|
|
|
red = 2 * r;
|
|
|
|
if (red > 255)
|
|
|
|
red = 510 - red;
|
|
|
|
green = 2 * g;
|
|
|
|
if (green > 255)
|
|
|
|
green = 510 - green;
|
|
|
|
blue = 2 * b;
|
|
|
|
if (blue > 255)
|
|
|
|
blue= 510 - blue;
|
2005-10-07 20:35:27 +00:00
|
|
|
|
2006-02-22 21:41:48 +00:00
|
|
|
colours[i] = LCD_RGBPACK(red, green, blue);
|
|
|
|
|
|
|
|
r++; g++; b++;
|
|
|
|
}
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
rb->lcd_pal256_update_pal(colours);
|
|
|
|
#endif
|
2006-02-22 21:41:48 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* Make a smooth shade from black into white and back into black again. */
|
2005-10-07 20:35:27 +00:00
|
|
|
static void shades_generate(void)
|
|
|
|
{
|
2006-02-22 21:41:48 +00:00
|
|
|
int i, y;
|
2005-10-07 20:35:27 +00:00
|
|
|
|
|
|
|
for(i=0; i < 256; ++i)
|
|
|
|
{
|
2006-02-22 21:41:48 +00:00
|
|
|
y = 2 * i;
|
|
|
|
if (y > 255)
|
|
|
|
y = 510 - y;
|
|
|
|
colours[i] = y;
|
2005-10-07 20:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-22 21:41:48 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
|
|
|
|
void cleanup(void *parameter)
|
|
|
|
{
|
|
|
|
(void)parameter;
|
2009-12-05 12:47:53 +00:00
|
|
|
|
2009-11-22 13:35:41 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
if (boosted)
|
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifndef HAVE_LCD_COLOR
|
2008-01-04 23:42:38 +00:00
|
|
|
grey_release();
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn on backlight timeout (revert to settings) */
|
2009-01-16 10:34:40 +00:00
|
|
|
backlight_use_settings(); /* backlight control in lib/helper.c */
|
2005-10-07 20:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Main function that also contain the main plasma
|
|
|
|
* algorithm.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
plasma_frequency = 1;
|
2009-11-22 13:35:41 +00:00
|
|
|
int button, delay, x, y;
|
|
|
|
unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z,z0;
|
|
|
|
long last_tick = *rb->current_tick;
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
int cumulated_lag = 0;
|
|
|
|
#endif
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
unsigned char *ptr;
|
|
|
|
#else
|
2006-02-22 21:41:48 +00:00
|
|
|
fb_data *ptr;
|
2009-09-07 14:00:38 +00:00
|
|
|
#endif
|
2006-02-16 16:07:21 +00:00
|
|
|
int time=0;
|
2006-02-22 21:41:48 +00:00
|
|
|
#else
|
|
|
|
unsigned char *ptr;
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2006-02-22 21:41:48 +00:00
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
/*Generate the neccesary pre calced stuff*/
|
|
|
|
wave_table_generate();
|
|
|
|
|
2006-02-22 21:41:48 +00:00
|
|
|
#ifndef HAVE_LCD_COLOR
|
|
|
|
shades_generate(); /* statically */
|
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
/* get the remainder of the plugin buffer */
|
|
|
|
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL);
|
2008-01-04 23:42:38 +00:00
|
|
|
/* switch on greyscale overlay */
|
|
|
|
grey_show(true);
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
sp1 = 4;
|
|
|
|
sp2 = 2;
|
|
|
|
sp3 = 4;
|
|
|
|
sp4 = 2;
|
|
|
|
p1=p2=p3=p4=0;
|
|
|
|
while (true)
|
|
|
|
{
|
2006-02-22 21:41:48 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
shades_generate(time++); /* dynamically */
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
ptr = (unsigned char*)rb->lcd_framebuffer;
|
|
|
|
#else
|
2006-02-22 21:41:48 +00:00
|
|
|
ptr = rb->lcd_framebuffer;
|
2009-09-07 14:00:38 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-22 21:41:48 +00:00
|
|
|
#else
|
2008-01-04 23:42:38 +00:00
|
|
|
ptr = greybuffer;
|
2006-02-22 21:41:48 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
t1=p1;
|
|
|
|
t2=p2;
|
|
|
|
for(y = 0; y < LCD_HEIGHT; ++y)
|
|
|
|
{
|
|
|
|
t3=p3;
|
|
|
|
t4=p4;
|
2009-11-22 13:35:41 +00:00
|
|
|
z0 = wave_array[t1] + wave_array[t2];
|
2005-10-07 20:35:27 +00:00
|
|
|
for(x = 0; x < LCD_WIDTH; ++x)
|
|
|
|
{
|
2009-12-05 12:47:53 +00:00
|
|
|
z = z0 + wave_array[t3] + wave_array[t4];
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
*ptr++ = z;
|
|
|
|
#else
|
2006-02-22 21:41:48 +00:00
|
|
|
*ptr++ = colours[z];
|
2009-09-07 14:00:38 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
t3+=1;
|
|
|
|
t4+=2;
|
|
|
|
}
|
|
|
|
t1+=2;
|
|
|
|
t2+=1;
|
|
|
|
rb->yield();
|
|
|
|
}
|
|
|
|
p1+=sp1;
|
|
|
|
p2-=sp2;
|
|
|
|
p3+=sp3;
|
|
|
|
p4-=sp4;
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
rb->lcd_blit_pal256( (unsigned char*)rb->lcd_framebuffer,
|
|
|
|
0,0,0,0,LCD_WIDTH,LCD_HEIGHT);
|
|
|
|
#else
|
2006-02-16 16:07:21 +00:00
|
|
|
rb->lcd_update();
|
2009-09-07 14:00:38 +00:00
|
|
|
#endif
|
2006-02-16 16:07:21 +00:00
|
|
|
#else
|
2008-01-04 23:42:38 +00:00
|
|
|
grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT);
|
2006-02-16 16:07:21 +00:00
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
|
2009-11-22 13:35:41 +00:00
|
|
|
delay = last_tick - *rb->current_tick + HZ/33;
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
|
|
|
if (!boosted && delay < 0)
|
|
|
|
{
|
|
|
|
cumulated_lag -= delay; /* proportional increase */
|
|
|
|
if (cumulated_lag >= HZ)
|
|
|
|
rb->cpu_boost(boosted = true);
|
|
|
|
}
|
|
|
|
else if (boosted && delay > 1) /* account for jitter */
|
|
|
|
{
|
|
|
|
if (--cumulated_lag <= 0) /* slow decrease */
|
|
|
|
rb->cpu_boost(boosted = false);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
button = rb->button_get_w_tmo(MAX(0, delay));
|
|
|
|
last_tick = *rb->current_tick;
|
2005-10-07 20:35:27 +00:00
|
|
|
|
|
|
|
switch(button)
|
|
|
|
{
|
2006-06-30 16:43:47 +00:00
|
|
|
#ifdef PLASMA_RC_QUIT
|
|
|
|
case PLASMA_RC_QUIT:
|
|
|
|
#endif
|
2005-10-07 20:35:27 +00:00
|
|
|
case(PLASMA_QUIT):
|
|
|
|
cleanup(NULL);
|
|
|
|
return PLUGIN_OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (PLASMA_INCREASE_FREQUENCY):
|
|
|
|
++plasma_frequency;
|
|
|
|
wave_table_generate();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (PLASMA_DECREASE_FREQUENCY):
|
|
|
|
if(plasma_frequency>1)
|
|
|
|
{
|
|
|
|
--plasma_frequency;
|
|
|
|
wave_table_generate();
|
|
|
|
}
|
|
|
|
break;
|
2006-02-16 16:07:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
case (PLASMA_REGEN_COLORS):
|
|
|
|
redfactor=rb->rand()%4;
|
|
|
|
greenfactor=rb->rand()%4;
|
|
|
|
bluefactor=rb->rand()%4;
|
|
|
|
redphase=rb->rand()%256;
|
|
|
|
greenphase=rb->rand()%256;
|
|
|
|
bluephase=rb->rand()%256;
|
|
|
|
break;
|
|
|
|
#endif
|
2009-12-05 12:47:53 +00:00
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
default:
|
|
|
|
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
|
|
|
== SYS_USB_CONNECTED)
|
|
|
|
return PLUGIN_USB_CONNECTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************** Plugin entry point ****************************/
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2005-10-07 20:35:27 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
(void)parameter;
|
2006-11-15 06:46:35 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-11-15 06:14:27 +00:00
|
|
|
rb->lcd_set_backdrop(NULL);
|
2006-11-15 06:46:35 +00:00
|
|
|
#endif
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn off backlight timeout */
|
2009-01-16 10:34:40 +00:00
|
|
|
backlight_force_on(); /* backlight control in lib/helper.c */
|
2005-10-07 20:35:27 +00:00
|
|
|
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_PAL256);
|
|
|
|
#endif
|
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
ret = main();
|
|
|
|
|
2009-09-07 14:00:38 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_RGB565);
|
|
|
|
#endif
|
|
|
|
|
2005-10-07 20:35:27 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-02-26 13:37:42 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|