From 909d5df047f087e2fdc998f1d930f0d65eca44db Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Sun, 3 Apr 2011 00:56:48 +0000 Subject: [PATCH] small optimization --- animations/gameoflife.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/animations/gameoflife.c b/animations/gameoflife.c index 4693081..2b5e874 100644 --- a/animations/gameoflife.c +++ b/animations/gameoflife.c @@ -228,15 +228,21 @@ uint8_t pfempty(field_t src) { /******************************************************************************/ -void insertglider(field_t pf) { +static void insertglider(field_t pf) { +#ifndef BITSTUFFED /* * # - * # + * # * ### */ setcell(pf, 1, 0, alive); - setcell(pf, 2, 1, alive); + setcell(pf, 2, 1, alive); setcell(pf, 0, 2, alive);setcell(pf, 1, 2, alive);setcell(pf, 2, 2, alive); +#else + pf[0][0] |= 0x02; // # + pf[1][0] |= 0x04; // # + pf[2][0] |= 0x07; // ### +#endif } /******************************************************************************/ @@ -269,17 +275,18 @@ void gameoflife() { uint8_t ldbuf_idx = 0; uint16_t cycle; - /* initialize the field with random */ - pfinit(pf1); - #ifdef GLIDER_TEST /* initialize with glider */ - for(y=YSIZE; y--;) { - for(x=XSIZE; x--;) { + coord_t x,y; + for(y = YSIZE; y--;) { + for(x = XSIZE; x--;) { setcell(pf1, x, y, dead); } } insertglider(pf1); +#else + /* initialize the field with random */ + pfinit(pf1); #endif /* the main part */