#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 #define LCDSHIFT_EVERY_N 10 uchar stepmode=0; uchar randdensity=0; static unsigned long iter=0; struct bitset _life; #define life (&_life) 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(); void ram(void) { getInputWaitRelease(); reset_area(); random_area(life,1,1,RESX,RESY,40); lcdClear(); setExtFont(GLOBAL(nickfont)); DoString(20,20,GLOBAL(nickname)); char stepmode=0; while (1) { draw_area(); // xor life pattern over display content lcdDisplay(); draw_area(); // xor life pattern again to restore original display content if(iter%LCDSHIFT_EVERY_N==0) lcdShift(1,-2,1); char key=stepmode?getInputWait():getInputRaw(); stepmode=0; switch(key) { case BTN_LEFT: return; case BTN_DOWN: stepmode=1; getInputWaitRelease(); break; case BTN_ENTER: pattern=(pattern+1)%PATTERNCOUNT; case BTN_UP: stepmode=1; reset_area(); getInputWaitRelease(); break; } delayms_queue_plus(10,0); 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)