2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
#include "../config.h"
|
2011-09-03 20:22:33 +00:00
|
|
|
#include "../compat/pgmspace.h"
|
2008-12-03 05:40:16 +00:00
|
|
|
#include "../random/prng.h"
|
|
|
|
#include "../pixel.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
#define RANDOM8() (random8())
|
|
|
|
|
|
|
|
|
2011-09-03 20:22:33 +00:00
|
|
|
#ifdef ANIMATION_TESTS
|
2011-02-25 22:57:49 +00:00
|
|
|
void test_level(unsigned char level){
|
|
|
|
for (unsigned char y=NUM_ROWS;y--;){
|
|
|
|
for (unsigned char x=NUM_COLS;x--;){
|
|
|
|
setpixel((pixel){x,y}, level);
|
2008-12-03 05:40:16 +00:00
|
|
|
wait(5);
|
|
|
|
}
|
|
|
|
}
|
2009-02-18 22:26:46 +00:00
|
|
|
wait(2000);
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_palette(){
|
2011-02-25 22:57:49 +00:00
|
|
|
for (unsigned char y=NUM_ROWS;y--;){
|
|
|
|
for (unsigned char x=NUM_COLS;x--;){
|
|
|
|
setpixel((pixel){x,y}, y%4);
|
2009-02-18 22:26:46 +00:00
|
|
|
// wait(1);
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-18 22:26:46 +00:00
|
|
|
wait(2000);
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
2009-02-18 22:26:46 +00:00
|
|
|
|
|
|
|
void test_palette2(){
|
2011-02-25 22:57:49 +00:00
|
|
|
for (unsigned char x=NUM_COLS;x--;){
|
|
|
|
for (unsigned char y=NUM_ROWS;y--;){
|
|
|
|
setpixel((pixel){x,y}, x%4);
|
2009-02-18 22:26:46 +00:00
|
|
|
// wait(1);
|
|
|
|
}
|
|
|
|
}
|
2011-02-25 22:57:49 +00:00
|
|
|
wait(1000);
|
|
|
|
for (unsigned char x=NUM_COLS;x--;){
|
|
|
|
// shift image right
|
|
|
|
shift_pixmap_l();
|
|
|
|
wait(30);
|
|
|
|
}
|
2009-02-18 22:26:46 +00:00
|
|
|
}
|
2009-06-19 21:09:08 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-05 02:53:09 +00:00
|
|
|
|
2011-11-07 22:35:57 +00:00
|
|
|
#ifdef ANIMATION_SPIRAL
|
2012-09-08 01:35:32 +00:00
|
|
|
static void walk(cursor_t* cur, unsigned char steps, int delay){
|
2011-09-04 22:31:24 +00:00
|
|
|
unsigned char x;
|
|
|
|
for(x=steps;x--;){
|
|
|
|
set_cursor(cur, next_pixel(cur->pos, cur->dir));
|
|
|
|
wait(delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-08 01:35:32 +00:00
|
|
|
void spiral(int delay){
|
2008-12-03 05:40:16 +00:00
|
|
|
clear_screen(0);
|
2011-09-04 22:31:24 +00:00
|
|
|
|
|
|
|
cursor_t cur;
|
|
|
|
cur.dir = right;
|
|
|
|
cur.mode = set;
|
|
|
|
set_cursor (&cur, (pixel){NUM_COLS-1,0});
|
|
|
|
|
|
|
|
unsigned char clearbit=0;
|
|
|
|
while(clearbit == 0){
|
|
|
|
|
|
|
|
clearbit = 1;
|
|
|
|
while (!get_next_pixel(cur.pos, cur.dir)){
|
|
|
|
clearbit = 0;
|
|
|
|
walk(&cur, 1, delay);
|
|
|
|
}
|
|
|
|
cur.dir = direction_r(cur.dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
cur.mode = clear;
|
|
|
|
set_cursor(&cur, (pixel){(NUM_COLS/2)-1,(NUM_ROWS/2)-1});
|
|
|
|
|
|
|
|
for(clearbit=0;clearbit==0;){
|
|
|
|
if( get_next_pixel(cur.pos, direction_r(cur.dir)) ){
|
|
|
|
cur.dir = direction_r(cur.dir);
|
|
|
|
}
|
|
|
|
if( get_next_pixel(cur.pos, cur.dir) == 1 ){
|
|
|
|
walk(&cur , 1, delay);
|
|
|
|
}else{
|
|
|
|
clearbit = 1;
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 22:57:49 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
#ifdef ANIMATION_JOERN1
|
|
|
|
void joern1(){
|
|
|
|
unsigned char i, j, x;
|
|
|
|
unsigned char rolr=0x01 , rol;
|
|
|
|
clear_screen(3);
|
|
|
|
for(i = 0; i< 80;i++){
|
|
|
|
rol = rolr;
|
|
|
|
for(j = 0 ;j < NUM_ROWS; j++){
|
|
|
|
for(x=0;x<LINEBYTES;x++)
|
|
|
|
pixmap[2][j][x] = rol;
|
|
|
|
if((rol<<=1)==0)rol = 0x01;
|
|
|
|
}
|
|
|
|
if((rolr<<=1) == 0) rolr = 1;
|
|
|
|
wait(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 22:57:49 +00:00
|
|
|
|
2011-11-08 02:46:56 +00:00
|
|
|
#ifdef ANIMATION_CHECKERBOARD
|
|
|
|
void checkerboard(unsigned char times){
|
2011-09-03 20:22:33 +00:00
|
|
|
while (times--) {
|
2010-12-22 23:18:11 +00:00
|
|
|
for (unsigned char row = 0; row < NUM_ROWS; ++row) {
|
2011-05-08 20:58:56 +00:00
|
|
|
for (unsigned char col = 0; col < NUM_COLS; ++col) {
|
2011-09-03 20:22:33 +00:00
|
|
|
setpixel((pixel){col, row}, (times ^ row ^ col) & 0x01 ? 0 : 3);
|
2010-12-22 23:18:11 +00:00
|
|
|
}
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
|
|
|
wait(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-11-07 22:35:57 +00:00
|
|
|
#ifdef ANIMATION_FIRE
|
2011-10-29 05:59:46 +00:00
|
|
|
#ifndef FIRE_CYCLES
|
|
|
|
#define FIRE_CYCLES 800
|
|
|
|
#endif
|
2011-11-07 22:35:57 +00:00
|
|
|
#define FIRE_Y (NUM_ROWS + 3)
|
|
|
|
void fire()
|
2008-12-03 05:40:16 +00:00
|
|
|
{
|
|
|
|
unsigned char y, x;
|
|
|
|
unsigned int t;
|
2011-11-07 22:35:57 +00:00
|
|
|
unsigned char world[NUM_COLS][FIRE_Y]; // double buffer
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2011-11-07 22:35:57 +00:00
|
|
|
for (t = 0; t < FIRE_CYCLES; t++) {
|
2008-12-03 05:40:16 +00:00
|
|
|
// diffuse
|
2011-11-07 22:35:57 +00:00
|
|
|
for (y = 1; y < FIRE_Y; y++) {
|
|
|
|
for (x = 1; x < NUM_COLS - 1; x++) {
|
|
|
|
world[x][y - 1] =
|
|
|
|
(FIRE_N * world[x - 1][y] +
|
|
|
|
FIRE_S * world[ x][y] +
|
|
|
|
FIRE_N * world[x + 1][y]) / FIRE_DIV;
|
2008-12-03 05:40:16 +00:00
|
|
|
};
|
|
|
|
|
2011-11-07 22:35:57 +00:00
|
|
|
world[0][y - 1] =
|
|
|
|
(FIRE_N * world[NUM_COLS - 1][y] +
|
|
|
|
FIRE_S * world[ 0][y] +
|
|
|
|
FIRE_N * world[ 1][y]) / FIRE_DIV;
|
|
|
|
|
|
|
|
world[NUM_COLS - 1][y - 1] =
|
|
|
|
(FIRE_N * world[0 ][y] +
|
|
|
|
FIRE_S * world[NUM_COLS - 1][y] +
|
|
|
|
FIRE_N * world[NUM_COLS - 2][y]) / FIRE_DIV;
|
|
|
|
}
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
// update lowest line
|
2011-11-07 22:35:57 +00:00
|
|
|
for (x = 0; x < NUM_COLS; x++) {
|
|
|
|
world[x][FIRE_Y - 1] = RANDOM8();
|
|
|
|
}
|
2011-10-29 05:59:46 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
// copy to screen
|
2011-11-07 22:35:57 +00:00
|
|
|
for (y = 0; y < NUM_ROWS; y++) {
|
|
|
|
for (x = 0; x < NUM_COLS; x++) {
|
|
|
|
setpixel((pixel) {x,y}, world[x][y] >> 5);
|
2011-10-29 05:59:46 +00:00
|
|
|
}
|
2011-11-07 22:35:57 +00:00
|
|
|
}
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2011-11-07 22:35:57 +00:00
|
|
|
wait(FIRE_DELAY);
|
2008-12-03 05:40:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-03 20:22:33 +00:00
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
#ifdef ANIMATION_RANDOM_BRIGHT
|
|
|
|
/**
|
|
|
|
* void random_bright(void)
|
|
|
|
* by Daniel Otte
|
|
|
|
*/
|
|
|
|
void random_bright(unsigned cycles){
|
|
|
|
uint8_t t,x,y;
|
|
|
|
while(cycles--){
|
|
|
|
for(y=0; y<NUM_ROWS; ++y)
|
|
|
|
for(x=0; x<NUM_COLS/4; ++x){
|
|
|
|
t=random8();
|
|
|
|
setpixel((pixel){x*4+0, y}, 0x3&(t>>0));
|
|
|
|
setpixel((pixel){x*4+1, y}, 0x3&(t>>2));
|
|
|
|
setpixel((pixel){x*4+2, y}, 0x3&(t>>4));
|
|
|
|
setpixel((pixel){x*4+3, y}, 0x3&(t>>6));
|
|
|
|
}
|
|
|
|
wait(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|