int main(void) { plasma_frequency = 1; 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 #ifdef HAVE_LCD_COLOR #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) unsigned char *ptr; #else fb_data *ptr; #endif int time=0; #else unsigned char *ptr; #endif /*Generate the neccesary pre calced stuff*/ wave_table_generate(); #ifndef HAVE_LCD_COLOR shades_generate(); /* statically */ /* get the remainder of the plugin buffer */ gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); /* switch on greyscale overlay */ grey_show(true); #endif sp1 = 4; sp2 = 2; sp3 = 4; sp4 = 2; p1=p2=p3=p4=0; while (true) { #ifdef HAVE_LCD_COLOR shades_generate(time++); /* dynamically */ #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) ptr = (unsigned char*)rb->lcd_framebuffer; #else ptr = rb->lcd_framebuffer; #endif #else ptr = greybuffer; #endif t1=p1; t2=p2; for(y = 0; y < LCD_HEIGHT; ++y) { t3=p3; t4=p4; z0 = wave_array[t1] + wave_array[t2]; for(x = 0; x < LCD_WIDTH; ++x) { z = z0 + wave_array[t3] + wave_array[t4]; #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) *ptr++ = z; #else *ptr++ = colours[z]; #endif t3+=1; t4+=2; } t1+=2; t2+=1; rb->yield(); } p1+=sp1; p2-=sp2; p3+=sp3; p4-=sp4; #ifdef HAVE_LCD_COLOR #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 rb->lcd_update(); #endif #else grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); #endif 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; switch(button) { #ifdef PLASMA_RC_QUIT case PLASMA_RC_QUIT: #endif 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; #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 default: if (rb->default_event_handler_ex(button, cleanup, NULL) == SYS_USB_CONNECTED) return PLUGIN_USB_CONNECTED; break; } } }
int main(void) { plasma_frequency = 1; int action, x, y; unsigned char p1,p2,p3,p4,t1,t2,t3,t4, z,z0; #ifdef HAVE_ADJUSTABLE_CPU_FREQ long last_tick = *rb->current_tick; int delay; int cumulated_lag = 0; #endif #ifdef HAVE_LCD_COLOR #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) unsigned char *ptr; #else fb_data *ptr; #endif int time=0; #else unsigned char *ptr; #endif /*Generate the neccesary pre calced stuff*/ wave_table_generate(); #ifndef HAVE_LCD_COLOR shades_generate(); /* statically */ /* get the remainder of the plugin buffer */ gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL)) { rb->splash(HZ, "Couldn't init greyscale display"); return PLUGIN_ERROR; } /* switch on greyscale overlay */ grey_show(true); #endif atexit(cleanup); sp1 = 4; sp2 = 2; sp3 = 4; sp4 = 2; p1=p2=p3=p4=0; while (true) { #ifdef HAVE_LCD_COLOR shades_generate(time++); /* dynamically */ #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) ptr = (unsigned char*)rb->lcd_framebuffer; #else ptr = rb->lcd_framebuffer; #endif #else ptr = greybuffer; #endif t1=p1; t2=p2; for(y = 0; y < LCD_HEIGHT; ++y) { t3=p3; t4=p4; z0 = wave_array[t1] + wave_array[t2]; for(x = 0; x < LCD_WIDTH; ++x) { z = z0 + wave_array[t3] + wave_array[t4]; #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) *ptr++ = z; #else *ptr++ = colours[z]; #endif t3+=1; t4+=2; } t1+=2; t2+=1; rb->yield(); } p1+=sp1; p2-=sp2; p3+=sp3; p4-=sp4; #ifdef HAVE_LCD_COLOR #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 rb->lcd_update(); #endif #else grey_ub_gray_bitmap(greybuffer, 0, 0, LCD_WIDTH, LCD_HEIGHT); #endif #ifdef HAVE_ADJUSTABLE_CPU_FREQ delay = last_tick - *rb->current_tick + HZ/33; 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); } last_tick = *rb->current_tick; #endif action = pluginlib_getaction(0, plugin_contexts, ARRAYLEN(plugin_contexts)); switch(action) { case PLA_EXIT: case PLA_CANCEL: return PLUGIN_OK; break; #ifdef HAVE_SCROLLWHEEL case PLA_SCROLL_FWD: case PLA_SCROLL_FWD_REPEAT: #endif case PLA_UP: case PLA_UP_REPEAT: ++plasma_frequency; wave_table_generate(); break; #ifdef HAVE_SCROLLWHEEL case PLA_SCROLL_BACK: case PLA_SCROLL_BACK_REPEAT: #endif case PLA_DOWN: case PLA_DOWN_REPEAT: if(plasma_frequency>1) { --plasma_frequency; wave_table_generate(); } break; #ifdef HAVE_LCD_COLOR case PLA_SELECT: 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 default: exit_on_usb(action); break; } } }