From 1a74745b8c01c35c887968184c6a55edc157b744 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Thu, 15 Apr 2010 21:49:43 +0000 Subject: [PATCH] added LABOR logo animation --- animations/Makefile | 4 ++ animations/laborlogo.c | 145 +++++++++++++++++++++++++++++++++++++++++ animations/laborlogo.h | 13 ++++ config.in | 3 +- display_loop.c | 7 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 animations/laborlogo.c create mode 100644 animations/laborlogo.h diff --git a/animations/Makefile b/animations/Makefile index 1d8640c..aa4d050 100644 --- a/animations/Makefile +++ b/animations/Makefile @@ -33,4 +33,8 @@ ifeq ($(ANIMATION_LTN_ANT),y) SRC += ltn_ant.c endif +ifeq ($(ANIMATION_LABORLOGO),y) + SRC += laborlogo.c +endif + include $(TOPDIR)/rules.mk diff --git a/animations/laborlogo.c b/animations/laborlogo.c new file mode 100644 index 0000000..66add8e --- /dev/null +++ b/animations/laborlogo.c @@ -0,0 +1,145 @@ +#include +#include +#include "../compat/pgmspace.h" +#include "../random/prng.h" +#include "../util.h" +#include "../autoconf.h" +#include "../pixel.h" + +#define BITMAP_WIDTH 48 +#define BITMAP_HEIGHT 48 +#define VIEWPORT_WIDTH 16 +#define VIEWPORT_HEIGHT 16 +#define XDOMAIN (BITMAP_WIDTH - VIEWPORT_WIDTH) +#define YDOMAIN (BITMAP_HEIGHT - VIEWPORT_HEIGHT) + +static uint16_t laborlogo_getLine(uint8_t x, uint8_t y) +{ + assert(x <= BITMAP_WIDTH - VIEWPORT_WIDTH); + assert(y < BITMAP_HEIGHT); + + static const uint8_t nBitmap[48][6] PROGMEM = + {{0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF}, + {0xFF, 0xFF, 0x00, 0xF8, 0xFF, 0xFF}, + {0xFF, 0xF8, 0x00, 0xFF, 0x1F, 0xFF}, + {0xFF, 0xF0, 0x00, 0xFF, 0xEF, 0xFF}, + {0xFF, 0xC0, 0x00, 0xFF, 0xF3, 0xFF}, + {0xFF, 0x80, 0x00, 0xFF, 0xFD, 0xFF}, + {0xFF, 0x00, 0x00, 0xFF, 0xFE, 0xFF}, + {0xFE, 0x00, 0x03, 0x3F, 0xFF, 0x7F}, + {0xFC, 0x00, 0x04, 0xDF, 0xFF, 0xBF}, + {0xF8, 0x00, 0x08, 0xEF, 0xFF, 0xDF}, + {0xF0, 0x00, 0x10, 0xF7, 0xFF, 0xEF}, + {0xF0, 0x00, 0x10, 0xF7, 0xFF, 0xEF}, + {0xE0, 0xC0, 0x10, 0xF7, 0xFF, 0xF7}, + {0xC0, 0xC0, 0x10, 0xF7, 0xFF, 0xFB}, + {0xC0, 0x40, 0x08, 0xEF, 0xFF, 0xFB}, + {0xC0, 0x40, 0x04, 0xDF, 0xFF, 0xFB}, + {0x80, 0x40, 0x03, 0x3F, 0xFF, 0xFD}, + {0x87, 0xFC, 0x00, 0xFF, 0xFF, 0xFD}, + {0x84, 0x0C, 0x00, 0xFF, 0xFF, 0xFD}, + {0x04, 0x00, 0x1F, 0x07, 0xFF, 0xFE}, + {0x04, 0x00, 0x10, 0xF7, 0xFF, 0xFE}, + {0x04, 0x00, 0x10, 0xF7, 0xFF, 0xFE}, + {0xFF, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0x00, 0x80, 0x10, 0xF7, 0xFF, 0xFE}, + {0xBF, 0xFC, 0x10, 0xF7, 0xFF, 0xFD}, + {0xB0, 0x0C, 0x10, 0xF7, 0xFF, 0xFD}, + {0x80, 0x00, 0x10, 0xF7, 0xFF, 0xFD}, + {0xC0, 0x00, 0x10, 0xF7, 0xFF, 0xFB}, + {0xC0, 0x00, 0x10, 0xF7, 0xFF, 0xFB}, + {0xC0, 0x00, 0x10, 0xF7, 0xFF, 0xFB}, + {0xE0, 0x00, 0x10, 0xF7, 0xFF, 0xF7}, + {0xF0, 0x00, 0x10, 0xF7, 0xFF, 0xEF}, + {0xF0, 0x00, 0x10, 0xF7, 0xFF, 0xEF}, + {0xF8, 0x00, 0x10, 0xF7, 0xFF, 0xDF}, + {0xFC, 0x00, 0x10, 0xF7, 0xFF, 0xBF}, + {0xFE, 0x00, 0x1F, 0x07, 0xFF, 0x7F}, + {0xFF, 0x00, 0x00, 0xFF, 0xFE, 0xFF}, + {0xFF, 0x80, 0x00, 0xFF, 0xFD, 0xFF}, + {0xFF, 0xC0, 0x00, 0xFF, 0xF3, 0xFF}, + {0xFF, 0xF0, 0x00, 0xFF, 0xEF, 0xFF}, + {0xFF, 0xF8, 0x00, 0xFF, 0x1F, 0xFF}, + {0xFF, 0xFF, 0x00, 0xF8, 0xFF, 0xFF}, + {0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF}}; + + uint16_t nLine; + uint8_t nAlignment = x % 8; + + if (nAlignment == 0) + { + nLine = nBitmap[y][x / 8] << 8 | (nBitmap[y][x / 8 + 1]); + } + else + { + nLine = pgm_read_byte(&nBitmap[y][x / 8]) << (8 + nAlignment); + nLine |= pgm_read_byte(&nBitmap[y][x / 8 + 1]) << nAlignment; + nLine |= pgm_read_byte(&nBitmap[y][x / 8 + 2]) >> (8 - nAlignment); + } + + return nLine; +} + + +void laborlogo_drawViewport(uint8_t nBitmapX, uint8_t nBitmapY) +{ + assert(nBitmapX <= 32); + assert(nBitmapY <= 32); + + for (uint8_t nVPortY = 0; nVPortY < 16; ++nVPortY) + { + uint16_t nLineBuffer = laborlogo_getLine(nBitmapX, nVPortY + nBitmapY); + for (int8_t nVPortX = 0; nVPortX < 16; ++nVPortX) + { + if ((0x0001 << nVPortX) & nLineBuffer) + { + setpixel((pixel){nVPortX, nVPortY}, 3); + } + else + { + setpixel((pixel){nVPortX, nVPortY}, 0); + } + } + } +} + +void laborlogo_recalcVectors(int8_t *px, int8_t *py, int8_t *pdx, int8_t *pdy) +{ + if (((*px + *pdx) > (XDOMAIN)) || ((*px + *pdx) < 0)) + { + *pdx = random8() % 2 * (*px < (XDOMAIN / 2) ? 1 : -1); + } + if (((*py + *pdy) > (YDOMAIN)) || ((*py + *pdy) < 0)) + { + *pdy = random8() % 2 * (*py < (YDOMAIN / 2) ? 1 : -1); + } + if (*pdx == 0 && *pdy == 0) + { + *pdx = (*px < (XDOMAIN / 2) ? 1 : -1); + *pdy = (*py < (YDOMAIN / 2) ? 1 : -1); + } + *px += *pdx; + *py += *pdy; +// printf("%d, %d\n", *px , *py); +} + +void laborlogo() +{ + uint16_t nCycles = 500; + int8_t x = random8() % (XDOMAIN + 1); + int8_t y = random8() % (YDOMAIN + 1); + int8_t dx = 0; + int8_t dy = 0; + + while (nCycles-- != 0) + { + laborlogo_drawViewport(x ,y); + wait(75); + laborlogo_recalcVectors(&x, &y, &dx, &dy); + } +} diff --git a/animations/laborlogo.h b/animations/laborlogo.h new file mode 100644 index 0000000..9a31758 --- /dev/null +++ b/animations/laborlogo.h @@ -0,0 +1,13 @@ +/* + * laborlogo.h + * + * Created on: 13.04.2010 + * Author: chris + */ + +#ifndef LABORLOGO_H_ +#define LABORLOGO_H_ + +void laborlogo(); + +#endif /* LABORLOGO_H_ */ diff --git a/config.in b/config.in index 27f5d8d..02c9b5f 100644 --- a/config.in +++ b/config.in @@ -71,12 +71,13 @@ comment "Animations" dep_bool "Feuer" ANIMATION_FEUER $RANDOM_SUPPORT dep_bool "Matrix" ANIMATION_MATRIX $RANDOM_SUPPORT dep_bool "Random Bright" ANIMATION_RANDOM_BRIGHT $RANDOM_SUPPORT - dep_bool "Stonefly" ANIMATION_STONEFLY $RANDOM_SUPPORT $GAME_TETRIS_CORE + dep_bool "Stonefly" ANIMATION_STONEFLY $RANDOM_SUPPORT $GAME_TETRIS_CORE dep_bool "Flying Dots" ANIMATION_FLYINGDOTS $RANDOM_SUPPORT dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT bool "M Herweg" ANIMATION_MHERWEG dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT + dep_bool "LABOR Logo" ANIMATION_LABORLOGO $RANDOM_SUPPORT comment "Special Animations" bool "Test Animations" ANIMATION_TESTS diff --git a/display_loop.c b/display_loop.c index b6bd9e9..30fae72 100644 --- a/display_loop.c +++ b/display_loop.c @@ -11,6 +11,7 @@ #include "animations/flyingdots.h" #include "animations/breakout_demo.h" #include "animations/ltn_ant.h" +#include "animations/laborlogo.h" #include "borg_hw/borg_hw.h" #include "can/borg_can.h" #include "random/prng.h" @@ -142,6 +143,12 @@ void display_loop(){ break; #endif +#ifdef ANIMATION_LABORLOGO + case 15: + laborlogo();; + break; +#endif + #ifdef ANIMATION_TESTS case 31: test_level1();