From eabf38452f236523040221231d4f5c831f03f4e1 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 20 Jul 2011 08:03:02 +0200 Subject: [PATCH] Use cbitset for game of life to reduce data size - making it run on r0ket --- firmware/applications/cbitset.h | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 firmware/applications/cbitset.h diff --git a/firmware/applications/cbitset.h b/firmware/applications/cbitset.h new file mode 100644 index 0000000..4e76b82 --- /dev/null +++ b/firmware/applications/cbitset.h @@ -0,0 +1,53 @@ +#ifndef CBITFIELD_H +#define CBITFIELD_H + +#define BITSETCHUNKSIZE 32 + +#define one ((uint32_t)1) + +struct bitset { + uint16_t size; + uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1]; +}; + +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<