diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/plasma.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index 450b09fb8c..aadeb18deb 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c | |||
@@ -53,6 +53,9 @@ static size_t gbuf_size = 0; | |||
53 | #endif | 53 | #endif |
54 | static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */ | 54 | static unsigned char sp1, sp2, sp3, sp4; /* Speed of plasma */ |
55 | static int plasma_frequency; | 55 | static int plasma_frequency; |
56 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
57 | static bool boosted = false; | ||
58 | #endif | ||
56 | 59 | ||
57 | /* Key assignement, all bitmapped models */ | 60 | /* Key assignement, all bitmapped models */ |
58 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | 61 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
@@ -260,6 +263,10 @@ void cleanup(void *parameter) | |||
260 | { | 263 | { |
261 | (void)parameter; | 264 | (void)parameter; |
262 | 265 | ||
266 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
267 | if (boosted) | ||
268 | rb->cpu_boost(false); | ||
269 | #endif | ||
263 | #ifndef HAVE_LCD_COLOR | 270 | #ifndef HAVE_LCD_COLOR |
264 | grey_release(); | 271 | grey_release(); |
265 | #endif | 272 | #endif |
@@ -275,8 +282,12 @@ void cleanup(void *parameter) | |||
275 | int main(void) | 282 | int main(void) |
276 | { | 283 | { |
277 | plasma_frequency = 1; | 284 | plasma_frequency = 1; |
278 | int button, x, y; | 285 | int button, delay, x, y; |
279 | unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z; | 286 | unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z,z0; |
287 | long last_tick = *rb->current_tick; | ||
288 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
289 | int cumulated_lag = 0; | ||
290 | #endif | ||
280 | #ifdef HAVE_LCD_COLOR | 291 | #ifdef HAVE_LCD_COLOR |
281 | #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) | 292 | #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) |
282 | unsigned char *ptr; | 293 | unsigned char *ptr; |
@@ -325,10 +336,10 @@ int main(void) | |||
325 | { | 336 | { |
326 | t3=p3; | 337 | t3=p3; |
327 | t4=p4; | 338 | t4=p4; |
339 | z0 = wave_array[t1] + wave_array[t2]; | ||
328 | for(x = 0; x < LCD_WIDTH; ++x) | 340 | for(x = 0; x < LCD_WIDTH; ++x) |
329 | { | 341 | { |
330 | z = wave_array[t1] + wave_array[t2] + wave_array[t3] | 342 | z = z0 + wave_array[t3] + wave_array[t4]; |
331 | + wave_array[t4]; | ||
332 | #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) | 343 | #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) |
333 | *ptr++ = z; | 344 | *ptr++ = z; |
334 | #else | 345 | #else |
@@ -356,7 +367,22 @@ int main(void) | |||
356 | grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); | 367 | grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
357 | #endif | 368 | #endif |
358 | 369 | ||
359 | button = rb->button_get(false); | 370 | delay = last_tick - *rb->current_tick + HZ/33; |
371 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
372 | if (!boosted && delay < 0) | ||
373 | { | ||
374 | cumulated_lag -= delay; /* proportional increase */ | ||
375 | if (cumulated_lag >= HZ) | ||
376 | rb->cpu_boost(boosted = true); | ||
377 | } | ||
378 | else if (boosted && delay > 1) /* account for jitter */ | ||
379 | { | ||
380 | if (--cumulated_lag <= 0) /* slow decrease */ | ||
381 | rb->cpu_boost(boosted = false); | ||
382 | } | ||
383 | #endif | ||
384 | button = rb->button_get_w_tmo(MAX(0, delay)); | ||
385 | last_tick = *rb->current_tick; | ||
360 | 386 | ||
361 | switch(button) | 387 | switch(button) |
362 | { | 388 | { |