Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Plasma demo plugin |
| 11 | * |
| 12 | * My crack at making a 80's style retro plasma effect for the fantastic |
| 13 | * rockbox! |
| 14 | * Okay, I could've hard-coded the sine wave values, I just wanted the |
| 15 | * challange of calculating them! silly: maybe, fun: yes! |
| 16 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 17 | * This program is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU General Public License |
| 19 | * as published by the Free Software Foundation; either version 2 |
| 20 | * of the License, or (at your option) any later version. |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 21 | * |
| 22 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 23 | * KIND, either express or implied. |
| 24 | * |
| 25 | ****************************************************************************/ |
| 26 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 27 | #include "plugin.h" |
Peter D'Hoye | cb53e3c | 2007-08-15 12:42:09 +0000 | [diff] [blame] | 28 | #include "helper.h" |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 29 | |
Jens Arnold | 6a972e0 | 2006-02-26 13:37:42 +0000 | [diff] [blame] | 30 | #ifdef HAVE_LCD_BITMAP |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 31 | |
| 32 | #ifndef HAVE_LCD_COLOR |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 33 | #include "grey.h" |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 34 | #endif |
Kevin Ferrare | df4f56b | 2007-07-31 04:59:03 +0000 | [diff] [blame] | 35 | #include "fixedpoint.h" |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 36 | |
Jens Arnold | a36b1d4 | 2006-01-15 18:20:18 +0000 | [diff] [blame] | 37 | PLUGIN_HEADER |
| 38 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 39 | /******************************* Globals ***********************************/ |
| 40 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 41 | static const struct plugin_api* rb; /* global api struct pointer */ |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 42 | static unsigned char wave_array[256]; /* Pre calculated wave array */ |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 43 | #ifdef HAVE_LCD_COLOR |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 44 | static fb_data colours[256]; /* Smooth transition of shades */ |
| 45 | static int redfactor = 1, greenfactor = 2, bluefactor = 3; |
| 46 | static int redphase = 0, greenphase = 50, bluephase = 100; |
| 47 | /* lower chance of gray at regular intervals */ |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 48 | #else |
Jens Arnold | a72499a | 2008-01-13 00:11:43 +0000 | [diff] [blame] | 49 | GREY_INFO_STRUCT |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 50 | static unsigned char colours[256]; /* Smooth transition of shades */ |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 51 | static unsigned char greybuffer[LCD_HEIGHT*LCD_WIDTH]; /* off screen buffer */ |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 52 | static unsigned char *gbuf; |
Michael Sevakis | 26d242a | 2007-04-21 18:38:25 +0000 | [diff] [blame] | 53 | static size_t gbuf_size = 0; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 54 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 55 | static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */ |
| 56 | static int plasma_frequency; |
| 57 | |
| 58 | /* Key assignement, all bitmapped models */ |
Jens Arnold | b701322 | 2007-07-27 09:57:27 +0000 | [diff] [blame] | 59 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
| 60 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) |
Dave Chapman | d350e80 | 2006-02-05 19:27:23 +0000 | [diff] [blame] | 61 | #define PLASMA_QUIT BUTTON_MENU |
| 62 | #define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_FWD |
| 63 | #define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_BACK |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 64 | |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 65 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
| 66 | #define PLASMA_QUIT BUTTON_A |
| 67 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
| 68 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 69 | |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 70 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ |
| 71 | (CONFIG_KEYPAD == SANSA_C200_PAD) |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 72 | #define PLASMA_QUIT BUTTON_POWER |
| 73 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
| 74 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
| 75 | |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 76 | #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) |
Christian Gmeiner | 7f9e1eb | 2006-03-27 17:34:23 +0000 | [diff] [blame] | 77 | #define PLASMA_QUIT BUTTON_POWER |
Linus Nielsen Feltzing | 568ac3e | 2006-02-24 15:06:25 +0000 | [diff] [blame] | 78 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
| 79 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 80 | |
Daniel Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 81 | #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) |
| 82 | #define PLASMA_QUIT BUTTON_POWER |
| 83 | #define PLASMA_INCREASE_FREQUENCY BUTTON_SCROLL_UP |
| 84 | #define PLASMA_DECREASE_FREQUENCY BUTTON_SCROLL_DOWN |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 85 | |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 86 | #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) |
| 87 | #define PLASMA_QUIT BUTTON_BACK |
| 88 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
| 89 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 90 | |
Robert Kukla | d6c8b57 | 2008-03-01 22:55:09 +0000 | [diff] [blame] | 91 | #elif (CONFIG_KEYPAD == MROBE100_PAD) |
| 92 | #define PLASMA_QUIT BUTTON_POWER |
| 93 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
| 94 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 95 | |
| 96 | #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD) |
| 97 | #define PLASMA_QUIT BUTTON_RC_REC |
| 98 | #define PLASMA_INCREASE_FREQUENCY BUTTON_RC_VOL_UP |
| 99 | #define PLASMA_DECREASE_FREQUENCY BUTTON_RC_VOL_DOWN |
| 100 | #define PLASMA_RC_QUIT BUTTON_REC |
| 101 | |
Rob Purchase | 554d7ed | 2008-03-22 22:03:34 +0000 | [diff] [blame] | 102 | #elif (CONFIG_KEYPAD == COWOND2_PAD) |
| 103 | #define PLASMA_QUIT BUTTON_POWER |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 104 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 105 | #endif |
| 106 | |
| 107 | #ifdef HAVE_TOUCHPAD |
| 108 | #ifndef PLASMA_QUIT |
| 109 | #define PLASMA_QUIT BUTTON_TOPLEFT |
| 110 | #endif |
| 111 | #ifndef PLASMA_INCREASE_FREQUENCY |
| 112 | #define PLASMA_INCREASE_FREQUENCY BUTTON_MIDRIGHT |
| 113 | #endif |
| 114 | #ifndef PLASMA_DECREASE_FREQUENCY |
| 115 | #define PLASMA_DECREASE_FREQUENCY BUTTON_MIDLEFT |
| 116 | #endif |
Rob Purchase | 3fa414d | 2008-04-27 16:13:18 +0000 | [diff] [blame] | 117 | #endif /* HAVE_TOUCHPAD */ |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 118 | |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 119 | #ifndef PLASMA_QUIT |
| 120 | #define PLASMA_QUIT BUTTON_OFF |
| 121 | #endif |
| 122 | #ifndef PLASMA_INCREASE_FREQUENCY |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 123 | #define PLASMA_INCREASE_FREQUENCY BUTTON_UP |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 124 | #endif |
| 125 | #ifndef PLASMA_DECREASE_FREQUENCY |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 126 | #define PLASMA_DECREASE_FREQUENCY BUTTON_DOWN |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 127 | #endif |
Jens Arnold | 40919d7 | 2008-03-25 23:21:36 +0000 | [diff] [blame] | 128 | |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 129 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) |
| 130 | #define PLASMA_RC_QUIT BUTTON_RC_STOP |
| 131 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 132 | |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 133 | #ifdef HAVE_LCD_COLOR |
Jens Arnold | 85a226d | 2007-03-16 23:02:39 +0000 | [diff] [blame] | 134 | #if CONFIG_KEYPAD == IAUDIO_X5M5_PAD |
Jens Arnold | a234ed8 | 2006-02-22 22:42:04 +0000 | [diff] [blame] | 135 | #define PLASMA_REGEN_COLORS BUTTON_PLAY |
Daniel Stenberg | 1e88be5 | 2006-08-03 20:17:25 +0000 | [diff] [blame] | 136 | #elif CONFIG_KEYPAD == IRIVER_H10_PAD |
| 137 | #define PLASMA_REGEN_COLORS BUTTON_PLAY |
Marianne Arnold | 12ddb8e | 2007-09-20 10:49:48 +0000 | [diff] [blame] | 138 | #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ |
| 139 | (CONFIG_KEYPAD == SANSA_C200_PAD) |
Barry Wardell | 24f4a2a | 2006-10-26 13:38:09 +0000 | [diff] [blame] | 140 | #define PLASMA_REGEN_COLORS BUTTON_SELECT |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 141 | #elif CONFIG_KEYPAD == IPOD_4G_PAD |
| 142 | #define PLASMA_REGEN_COLORS BUTTON_SELECT |
| 143 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD |
| 144 | #define PLASMA_REGEN_COLORS BUTTON_SELECT |
Marcoen Hirschberg | 338e2bb | 2006-02-24 15:42:52 +0000 | [diff] [blame] | 145 | #elif CONFIG_KEYPAD == GIGABEAT_PAD |
| 146 | #define PLASMA_REGEN_COLORS BUTTON_SELECT |
Will Robertson | 8215b34 | 2008-02-17 12:23:02 +0000 | [diff] [blame] | 147 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD |
| 148 | #define PLASMA_REGEN_COLORS BUTTON_SELECT |
Rob Purchase | 297e050 | 2008-04-27 15:30:19 +0000 | [diff] [blame] | 149 | #endif |
| 150 | #ifdef HAVE_TOUCHPAD |
| 151 | #ifndef PLASMA_REGEN_COLORS |
| 152 | #define PLASMA_REGEN_COLORS BUTTON_CENTER |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 153 | #endif |
Rob Purchase | 3fa414d | 2008-04-27 16:13:18 +0000 | [diff] [blame] | 154 | #endif /* HAVE_TOUCHPAD */ |
| 155 | #endif /* HAVE_LCD_COLOR */ |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 156 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 157 | #define WAV_AMP 90 |
| 158 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 159 | /* |
| 160 | * Main wave function so we don't have to re-calc the sine |
| 161 | * curve every time. Mess around WAV_AMP and FREQ to make slighlty |
| 162 | * weirder looking plasmas! |
| 163 | */ |
| 164 | |
| 165 | static void wave_table_generate(void) |
| 166 | { |
| 167 | int i; |
| 168 | for (i=0;i<256;++i) |
| 169 | { |
| 170 | wave_array[i] = (unsigned char)((WAV_AMP |
Kevin Ferrare | df4f56b | 2007-07-31 04:59:03 +0000 | [diff] [blame] | 171 | * (sin_int((i * 360 * plasma_frequency) / 256))) / 16384); |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 175 | #ifdef HAVE_LCD_COLOR |
| 176 | /* Make a smooth colour cycle. */ |
| 177 | void shades_generate(int time) |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 178 | { |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 179 | int i; |
| 180 | unsigned red, green, blue; |
| 181 | unsigned r = time * redfactor + redphase; |
| 182 | unsigned g = time * greenfactor + greenphase; |
| 183 | unsigned b = time * bluefactor + bluephase; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 184 | |
| 185 | for(i=0; i < 256; ++i) |
| 186 | { |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 187 | r &= 0xFF; g &= 0xFF; b &= 0xFF; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 188 | |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 189 | red = 2 * r; |
| 190 | if (red > 255) |
| 191 | red = 510 - red; |
| 192 | green = 2 * g; |
| 193 | if (green > 255) |
| 194 | green = 510 - green; |
| 195 | blue = 2 * b; |
| 196 | if (blue > 255) |
| 197 | blue= 510 - blue; |
| 198 | |
| 199 | colours[i] = LCD_RGBPACK(red, green, blue); |
| 200 | |
| 201 | r++; g++; b++; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 202 | } |
| 203 | } |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 204 | #else |
| 205 | /* Make a smooth shade from black into white and back into black again. */ |
| 206 | static void shades_generate(void) |
| 207 | { |
| 208 | int i, y; |
| 209 | |
| 210 | for(i=0; i < 256; ++i) |
| 211 | { |
| 212 | y = 2 * i; |
| 213 | if (y > 255) |
| 214 | y = 510 - y; |
| 215 | colours[i] = y; |
| 216 | } |
| 217 | } |
| 218 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 219 | |
| 220 | void cleanup(void *parameter) |
| 221 | { |
| 222 | (void)parameter; |
| 223 | |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 224 | #ifndef HAVE_LCD_COLOR |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 225 | grey_release(); |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 226 | #endif |
Peter D'Hoye | cb53e3c | 2007-08-15 12:42:09 +0000 | [diff] [blame] | 227 | /* Turn on backlight timeout (revert to settings) */ |
Peter D'Hoye | 767c0ec | 2007-08-16 23:01:18 +0000 | [diff] [blame] | 228 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /* |
| 232 | * Main function that also contain the main plasma |
| 233 | * algorithm. |
| 234 | */ |
| 235 | |
| 236 | int main(void) |
| 237 | { |
| 238 | plasma_frequency = 1; |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 239 | int button, x, y; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 240 | unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 241 | #ifdef HAVE_LCD_COLOR |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 242 | fb_data *ptr; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 243 | int time=0; |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 244 | #else |
| 245 | unsigned char *ptr; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 246 | #endif |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 247 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 248 | /*Generate the neccesary pre calced stuff*/ |
| 249 | wave_table_generate(); |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 250 | |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 251 | #ifndef HAVE_LCD_COLOR |
| 252 | shades_generate(); /* statically */ |
| 253 | |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 254 | /* get the remainder of the plugin buffer */ |
| 255 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
| 256 | |
Jens Arnold | df8749d | 2008-04-06 13:59:31 +0000 | [diff] [blame] | 257 | grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 258 | /* switch on greyscale overlay */ |
| 259 | grey_show(true); |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 260 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 261 | sp1 = 4; |
| 262 | sp2 = 2; |
| 263 | sp3 = 4; |
| 264 | sp4 = 2; |
| 265 | p1=p2=p3=p4=0; |
| 266 | while (true) |
| 267 | { |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 268 | #ifdef HAVE_LCD_COLOR |
| 269 | shades_generate(time++); /* dynamically */ |
| 270 | ptr = rb->lcd_framebuffer; |
| 271 | #else |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 272 | ptr = greybuffer; |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 273 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 274 | t1=p1; |
| 275 | t2=p2; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 276 | for(y = 0; y < LCD_HEIGHT; ++y) |
| 277 | { |
| 278 | t3=p3; |
| 279 | t4=p4; |
| 280 | for(x = 0; x < LCD_WIDTH; ++x) |
| 281 | { |
| 282 | z = wave_array[t1] + wave_array[t2] + wave_array[t3] |
Jens Arnold | 0045bd3 | 2006-02-22 21:41:48 +0000 | [diff] [blame] | 283 | + wave_array[t4]; |
| 284 | *ptr++ = colours[z]; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 285 | t3+=1; |
| 286 | t4+=2; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 287 | } |
| 288 | t1+=2; |
| 289 | t2+=1; |
| 290 | rb->yield(); |
| 291 | } |
| 292 | p1+=sp1; |
| 293 | p2-=sp2; |
| 294 | p3+=sp3; |
| 295 | p4-=sp4; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 296 | #ifdef HAVE_LCD_COLOR |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 297 | rb->lcd_update(); |
| 298 | #else |
Jens Arnold | feb5b15 | 2008-01-04 23:42:38 +0000 | [diff] [blame] | 299 | grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 300 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 301 | |
| 302 | button = rb->button_get(false); |
| 303 | |
| 304 | switch(button) |
| 305 | { |
Kevin Ferrare | 0e027bd | 2006-06-30 16:43:47 +0000 | [diff] [blame] | 306 | #ifdef PLASMA_RC_QUIT |
| 307 | case PLASMA_RC_QUIT: |
| 308 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 309 | case(PLASMA_QUIT): |
| 310 | cleanup(NULL); |
| 311 | return PLUGIN_OK; |
| 312 | break; |
| 313 | |
| 314 | case (PLASMA_INCREASE_FREQUENCY): |
| 315 | ++plasma_frequency; |
| 316 | wave_table_generate(); |
| 317 | break; |
| 318 | |
| 319 | case (PLASMA_DECREASE_FREQUENCY): |
| 320 | if(plasma_frequency>1) |
| 321 | { |
| 322 | --plasma_frequency; |
| 323 | wave_table_generate(); |
| 324 | } |
| 325 | break; |
Dave Chapman | b0f0580 | 2006-02-16 16:07:21 +0000 | [diff] [blame] | 326 | #ifdef HAVE_LCD_COLOR |
| 327 | case (PLASMA_REGEN_COLORS): |
| 328 | redfactor=rb->rand()%4; |
| 329 | greenfactor=rb->rand()%4; |
| 330 | bluefactor=rb->rand()%4; |
| 331 | redphase=rb->rand()%256; |
| 332 | greenphase=rb->rand()%256; |
| 333 | bluephase=rb->rand()%256; |
| 334 | break; |
| 335 | #endif |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 336 | |
| 337 | default: |
| 338 | if (rb->default_event_handler_ex(button, cleanup, NULL) |
| 339 | == SYS_USB_CONNECTED) |
| 340 | return PLUGIN_USB_CONNECTED; |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /*************************** Plugin entry point ****************************/ |
| 347 | |
Steve Bavin | 6526577 | 2008-05-13 09:57:56 +0000 | [diff] [blame] | 348 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 349 | { |
| 350 | int ret; |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 351 | |
Daniel Stenberg | 220fafd | 2006-03-03 08:14:44 +0000 | [diff] [blame] | 352 | rb = api; /* copy to global api pointer */ |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 353 | (void)parameter; |
Karl Kurbjun | 1a9442c | 2006-11-15 06:46:35 +0000 | [diff] [blame] | 354 | #if LCD_DEPTH > 1 |
Karl Kurbjun | d6b0c97 | 2006-11-15 06:14:27 +0000 | [diff] [blame] | 355 | rb->lcd_set_backdrop(NULL); |
Karl Kurbjun | 1a9442c | 2006-11-15 06:46:35 +0000 | [diff] [blame] | 356 | #endif |
Peter D'Hoye | cb53e3c | 2007-08-15 12:42:09 +0000 | [diff] [blame] | 357 | /* Turn off backlight timeout */ |
Peter D'Hoye | 767c0ec | 2007-08-16 23:01:18 +0000 | [diff] [blame] | 358 | backlight_force_on(rb); /* backlight control in lib/helper.c */ |
Jens Arnold | 74e4b25 | 2005-10-07 20:35:27 +0000 | [diff] [blame] | 359 | |
| 360 | ret = main(); |
| 361 | |
| 362 | return ret; |
| 363 | } |
| 364 | |
Jens Arnold | 6a972e0 | 2006-02-26 13:37:42 +0000 | [diff] [blame] | 365 | #endif /* HAVE_LCD_BITMAP */ |