From d69cf154a0c4a2d6c56a442c3c346fd3c0bb7222 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 16:38:50 +0200 Subject: [PATCH] Add life.c nickscroller. I hacked around quite a bit to get it small. --- firmware/l0dable/nick_life.c | 246 +++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 firmware/l0dable/nick_life.c diff --git a/firmware/l0dable/nick_life.c b/firmware/l0dable/nick_life.c new file mode 100644 index 0000000..9b042b3 --- /dev/null +++ b/firmware/l0dable/nick_life.c @@ -0,0 +1,246 @@ +#include + +#include "basic/basic.h" + +#include "lcd/render.h" +#include "lcd/display.h" + +#include "basic/config.h" + +#include "usetable.h" + +#define BITSET_X (RESX+2) +#define BITSET_Y (RESY+2) +#define BITSET_SIZE (BITSET_X*BITSET_Y) + +#define BITSETCHUNKSIZE 32 + +#define one ((uint32_t)1) + +struct bitset { + uint16_t size; + uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1]; +}; + + +typedef uint8_t uchar; + +int pattern=0; +#define PATTERNCOUNT 3 + +uchar stepmode=0; +uchar randdensity=0; +//uint8_t bl=0; + +struct bitset _buf1,*buf1=&_buf1; +struct bitset _buf2,*buf2=&_buf2; + +struct bitset *life =&_buf1; +struct bitset *new =&_buf2; + + +static void draw_area(); +static void calc_area(); +static void random_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value); +static void reset_area(); +static void nextledcycle(); + +void ram(void) { + getInputWaitRelease(); + reset_area(); + random_area(life,1,1,RESX,RESY,40); + + lcdClear(); + setExtFont(GLOBAL(nickfont)); + DoString(20,20,GLOBAL(nickname)); + +#if 0 + gpioSetValue (RB_LED0, CFG_LED_ON); + gpioSetValue (RB_LED1, CFG_LED_ON); + gpioSetValue (RB_LED2, CFG_LED_ON); + gpioSetValue (RB_LED3, CFG_LED_ON); +#endif + while (1) { + draw_area(); // xor life pattern over display content + lcdDisplay(); + draw_area(); // xor life pattern again to restore original display content + lcdShift(1,-2,1); + if(getInputRaw()) + return; + delayms_queue(10); + calc_area(); + } + return; +} + +static inline void bitset_set(struct bitset *bs,uint16_t index, uint8_t value) { + uint16_t base=index/BITSETCHUNKSIZE; + uint16_t offset=index%BITSETCHUNKSIZE; + if(value) { + bs->bits[base]|=(one<bits[base]&=~(one<bits[base]^=(one<bits[base]&(one<>24)