generalized bitmap scroller and added an animated amphibian

This commit is contained in:
Christian Kroll 2010-08-22 03:12:56 +00:00
parent 2dadcb1d0b
commit e153ec68e1
10 changed files with 480 additions and 238 deletions

View File

@ -33,8 +33,16 @@ ifeq ($(ANIMATION_LTN_ANT),y)
SRC += ltn_ant.c SRC += ltn_ant.c
endif endif
ifeq ($(ANIMATION_BMSCROLLER),y)
SRC += bitmapscroller.c
endif
ifeq ($(ANIMATION_LABORLOGO),y) ifeq ($(ANIMATION_LABORLOGO),y)
SRC += laborlogo.c SRC += laborlogo.c
endif endif
ifeq ($(ANIMATION_AMPHIBIAN),y)
SRC += amphibian.c
endif
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk

167
animations/amphibian.c Normal file
View File

@ -0,0 +1,167 @@
#include <stdint.h>
#include <assert.h>
#include "../compat/pgmspace.h"
#include "bitmapscroller.h"
#include "amphibian.h"
static uint8_t amphibian_getChunk(unsigned int const nBitPlane,
unsigned int const nChunkX,
unsigned int const nChunkY,
unsigned int const nFrame)
{
assert(nChunkX < 6);
assert(nChunkY < 38);
static uint8_t aBitmap [2][38][6] PROGMEM =
{{{0x00, 0x00, 0x24, 0x00, 0x00, 0x00}, // bit plane 0
{0x00, 0x20, 0x3C, 0x00, 0x00, 0x00},
{0x07, 0x30, 0x47, 0x00, 0x00, 0x00},
{0x03, 0x00, 0xC3, 0x00, 0x00, 0x00},
{0x04, 0xD9, 0xA7, 0x00, 0x00, 0x00},
{0x02, 0xEB, 0x7C, 0x00, 0x00, 0x00},
{0x03, 0x3F, 0xBA, 0x00, 0x00, 0x00},
{0x00, 0xFF, 0xEF, 0x00, 0x00, 0x00},
{0x01, 0xFC, 0x3C, 0x80, 0x00, 0x00},
{0x02, 0xFC, 0x00, 0x00, 0x00, 0x00},
{0x01, 0xFC, 0x03, 0x00, 0x00, 0x00},
{0x05, 0xF8, 0x01, 0x40, 0x00, 0x00},
{0x00, 0x70, 0x01, 0x80, 0x00, 0x00},
{0x00, 0x00, 0x01, 0xE0, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x80, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x18, 0x00, 0x00},
{0x10, 0x7F, 0xC0, 0x18, 0x80, 0x00},
{0x03, 0xFF, 0xFC, 0x38, 0x00, 0x00},
{0x03, 0xFF, 0xFC, 0x3E, 0x00, 0x20},
{0x00, 0xFF, 0xFC, 0x7F, 0x00, 0xFC},
{0x00, 0xFF, 0xFC, 0xDE, 0x93, 0xFE},
{0x00, 0x7F, 0xFE, 0x8E, 0x57, 0xFF},
{0x22, 0xFF, 0xFD, 0x86, 0x0F, 0xFF},
{0x00, 0xFF, 0xFA, 0xC2, 0x7F, 0xFE},
{0x00, 0x5F, 0xF5, 0xC0, 0x7F, 0xFC},
{0x20, 0x78, 0x4B, 0xC8, 0x3F, 0xF8},
{0x00, 0xF0, 0x2F, 0xDC, 0x3F, 0xF0},
{0x10, 0xFF, 0xDF, 0x8E, 0x1F, 0xE0},
{0x08, 0xFF, 0xEF, 0x9E, 0x17, 0xC0},
{0x28, 0xFF, 0xFF, 0x83, 0x87, 0x00},
{0x80, 0xFF, 0xFF, 0x81, 0x87, 0xF0},
{0x70, 0x7F, 0xFF, 0x80, 0x1F, 0x8C},
{0x08, 0x1C, 0x1F, 0x01, 0xCF, 0x84},
{0x02, 0x54, 0x00, 0x02, 0x10, 0xC0},
{0x03, 0x40, 0x04, 0x08, 0x00, 0x30},
{0x00, 0x00, 0x1E, 0x40, 0x00, 0x08},
{0x02, 0x08, 0x16, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x4C, 0x00, 0x00, 0x00}},
{{0x00, 0x00, 0x18, 0x00, 0x00, 0x00}, // bit plane 1
{0x01, 0xC0, 0x7E, 0x00, 0x00, 0x00},
{0x03, 0xE0, 0xFE, 0x00, 0x00, 0x00},
{0x06, 0x30, 0x82, 0x00, 0x00, 0x00},
{0x06, 0x10, 0xDA, 0x00, 0x00, 0x00},
{0x07, 0xF0, 0xFE, 0x00, 0x00, 0x00},
{0x07, 0xC0, 0x7C, 0x00, 0x00, 0x00},
{0x03, 0x00, 0x10, 0x00, 0x00, 0x00},
{0x00, 0x03, 0xC3, 0x00, 0x00, 0x00},
{0x01, 0x03, 0xFF, 0x80, 0x00, 0x00},
{0x02, 0x03, 0xFC, 0x80, 0x00, 0x00},
{0x02, 0x07, 0xFE, 0x80, 0x00, 0x00},
{0x07, 0x8F, 0xFE, 0x40, 0x00, 0x00},
{0x0F, 0xFF, 0xFE, 0x00, 0x00, 0x00},
{0x1F, 0xFF, 0xFF, 0x60, 0x00, 0x00},
{0x3F, 0xFF, 0xFF, 0xE0, 0x00, 0x00},
{0x0F, 0xFF, 0xFF, 0xE7, 0x00, 0x00},
{0x03, 0xFF, 0xFF, 0xC7, 0x80, 0x00},
{0x01, 0xFF, 0xFF, 0xC1, 0xC0, 0x00},
{0x01, 0xFF, 0xFF, 0x80, 0xE0, 0x00},
{0x00, 0xFF, 0xFF, 0x21, 0x60, 0x00},
{0x00, 0xFF, 0xFF, 0x71, 0xA0, 0x00},
{0x1C, 0x7F, 0xFE, 0xF9, 0xF0, 0x00},
{0x3F, 0x7F, 0xFD, 0xFD, 0x80, 0x00},
{0x3F, 0xBF, 0xFA, 0xFF, 0x80, 0x00},
{0x1F, 0xC7, 0xB7, 0xF7, 0xC0, 0x00},
{0x1F, 0xFF, 0xFF, 0xE3, 0xC0, 0x00},
{0x0F, 0xFF, 0xEF, 0xF1, 0xE0, 0x00},
{0x07, 0xFF, 0xFF, 0xE1, 0xE8, 0x00},
{0x17, 0xFF, 0xFF, 0xFC, 0x78, 0x00},
{0x7F, 0xFF, 0xFF, 0xFE, 0x78, 0x00},
{0x0F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00},
{0x07, 0xFF, 0xFF, 0xFE, 0x00, 0x00},
{0x01, 0x88, 0x1F, 0xFC, 0x00, 0x00},
{0x00, 0x20, 0x03, 0xF0, 0x00, 0x00},
{0x02, 0x18, 0x01, 0x80, 0x00, 0x00},
{0x00, 0x00, 0x60, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x80, 0x00, 0x00, 0x00}}};
static uint8_t aEye[2][16][3] PROGMEM =
{{{0x07, 0xF0, 0x67}, // frame 1 (bit plane 0)
{0x03, 0xC0, 0xC3},
{0x04, 0x19, 0xA7},
{0x03, 0xEB, 0x7C},
{0x07, 0xF0, 0x5F}, // frame 2
{0x03, 0xE0, 0xC3},
{0x04, 0x19, 0xA7},
{0x03, 0xEB, 0x7C},
{0x07, 0xF0, 0x27}, // frame 3
{0x00, 0x00, 0xC3},
{0x07, 0xD9, 0xDF},
{0x03, 0xEB, 0x7C},
{0x07, 0xF0, 0x27}, // frame 4
{0x00, 0xC0, 0xC3},
{0x07, 0x19, 0xE7},
{0x03, 0x2B, 0x7C}},
{{0x03, 0xE0, 0xC6}, // frame 1 (bit plane 1)
{0x06, 0x30, 0x82},
{0x06, 0x10, 0xDA},
{0x07, 0xF0, 0xFE},
{0x03, 0xE0, 0xE6}, // frame 2
{0x07, 0xF0, 0x82},
{0x06, 0x10, 0xDA},
{0x07, 0xF0, 0xFE},
{0x03, 0xE0, 0xDA}, // frame 3
{0x06, 0x10, 0x82},
{0x06, 0x30, 0xE6},
{0x07, 0xF0, 0xFE},
{0x03, 0xE0, 0xDA}, // frame 4
{0x06, 0x10, 0x82},
{0x06, 0x30, 0xC6},
{0x07, 0xF0, 0xFE}}};
if ((nChunkX >= 0) && (nChunkX <= 2) && (nChunkY >= 2) && (nChunkY <= 5)
&& (((nFrame >> 1) % 8) != 0))
{
uint8_t nOffset;
switch ((nFrame >> 1) % 8)
{
case 1:
case 7:
nOffset = 0;
break;
case 2:
case 6:
nOffset = 4;
break;
case 3:
case 5:
nOffset = 8;
break;
case 4:
nOffset = 12;
break;
}
return pgm_read_byte(&aEye[nBitPlane][nChunkY-2+nOffset][nChunkX]);
}
else
{
return pgm_read_byte(&aBitmap[nBitPlane][nChunkY][nChunkX]);
}
}
void amphibian()
{
bitmap_scroll(48, 38, 2, 400, 75, amphibian_getChunk);
}

6
animations/amphibian.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef AMPHIBIAN_H_
#define AMPHIBIAN_H_
void amphibian();
#endif /* AMPHIBIAN_H_ */

215
animations/bitmapscroller.c Normal file
View File

@ -0,0 +1,215 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include "../random/prng.h"
#include "../util.h"
#include "../autoconf.h"
#include "../pixel.h"
#include "bitmapscroller.h"
/**
* This structure merely contains the meta data of the bitmap. The actual
* bitmap data is delivered by a user provided function.
*/
typedef struct bitmap_t
{
unsigned int nWidth; /**< Width of the bitmap. */
unsigned int nHeight; /**< Height of the bitmap. */
unsigned char nBitPlanes; /**< Number of bit planes. */
bitmap_getChunk_t fpGetChunk; /**< Bitmap chunk retrieving function. */
unsigned int nFrame; /**< Current frame number. */
unsigned int nViewportWidth; /**< Width of the displayed content. */
unsigned int nViewportHeight; /**< Height of the displayed content. */
unsigned int nXDomain; /**< Last valid x-coordinate for viewport. */
unsigned int nYDomain; /**< Last valid y-coordinate for viewport. */
unsigned int nChunkDomain; /**< Last valid chunk for viewport. */
unsigned int nChunkCount; /**< Amount of horiz. chunks of the bitmap. */
}
bitmap_t;
/**
* This function generates an eight-by-one pixel chunk for a given pair of pixel
* coordinates and a borg plane number. The resulting chunk can be copied
* directly to the borg's frame buffer. It makes use of the user provided
* "getChunk" function which in contrast only accepts chunk based coordinates
* (resulting in chunks whose x-coordinates are always a multiple of eight) and
* uses bit planes which defer from the plane scheme used by the borg's frame
* buffer.
* @param pBitmap The bitmap of interest.
* @param nBorgPlane The nunmber of the borg plane of interest.
* @param x x-coordinate of the bitmap
* @param y y-coordinate of the bitmap
* @return The bitmap chunk packed into an unsigned char.
*/
static unsigned char bitmap_getAlignedChunk(bitmap_t const *const pBitmap,
unsigned char const nBorgPlane,
unsigned int const x,
unsigned int const y)
{
assert(x <= pBitmap->nChunkDomain);
assert(y < pBitmap->nHeight);
unsigned char nChunk = 0xFF;
unsigned char nMask = 1;
unsigned char nAlignment = x % 8;
// we have to go through every bit plane
for (int i = 0; i < pBitmap->nBitPlanes; ++i)
{
// generate chunk
unsigned char nPlaneChunk;
// if the given x-coordinate is aligned to a chunk coordinate we can
// reuse the result of the "getChunk" function directly.
if (nAlignment == 0)
{
nPlaneChunk = pBitmap->fpGetChunk(i, x/8, y, pBitmap->nFrame);
}
// in case of misalignment we combine two chunks with chunk based
// coordinates into one chunk which aligns to the given x-coordinate
else
{
nPlaneChunk = pBitmap->fpGetChunk(i, x/8, y, pBitmap->nFrame)
<< nAlignment;
nPlaneChunk |= pBitmap->fpGetChunk(i, x/8+1, y, pBitmap->nFrame)
>> (8 - nAlignment);
}
// convert the bit plane information into the borg plane format
nChunk &= ((nBorgPlane + 1) & nMask) == 0 ? ~nPlaneChunk : nPlaneChunk;
nMask <<= 1;
}
return nChunk;
}
/**
* This function actually draws the bitmap onto the screen. The viewport is
* @param pBitmap The bitmap which shall be shown.
* @param nX The x-coordinate of the bitmap which shall be displayed at the top
* left of the viewport.
* @param nY The y-coordinate of the bitmap which shall be displayed at the top
* left of the viewport.
*/
static void bitmap_drawViewport(bitmap_t const *const pBitmap,
unsigned int const nX,
unsigned int const nY)
{
assert(nX <= pBitmap->nXDomain);
assert(nY <= pBitmap->nYDomain);
unsigned char nBitmapHwPlanes = (1 << pBitmap->nBitPlanes) - 1;
unsigned char nPlanes = nBitmapHwPlanes > NUMPLANE ?
NUMPLANE : nBitmapHwPlanes;
for (int8_t y = 0; y < pBitmap->nViewportHeight; ++y)
{
for (int8_t x = pBitmap->nViewportWidth; x > 0; x -= 8)
{
for (int8_t p = NUMPLANE - nPlanes; p < NUMPLANE; ++p)
{
uint8_t nChunk;
if ((nX + x - 8) >= 0)
{
nChunk = bitmap_getAlignedChunk(pBitmap, p, nX+x-8, nY + y);
pixmap[p][y][pBitmap->nChunkCount - 1 - ((x-1)/8)] = nChunk;
}
else
{
nChunk = bitmap_getAlignedChunk(pBitmap, p, nX, nY + y)
>> (8-x);
pixmap[p][y][pBitmap->nChunkCount - 1] = nChunk;
}
}
}
}
}
/**
* This functions calculates randomly chosen offsets to move the viewport
* accross the bitmap.
* @param pBitmap The bitmap of interest.
* @param x The current x-coordinate of the viewport.
* @param y The current y-coordinate of the viewport.
* @param pdx Pointer to a variable which shall hold the horizontal offset.
* @param pdy Pointer to a variable which shall hold the vertical offset.
*/
static void bitmap_recalculateVector(bitmap_t const *const pBitmap,
unsigned int const x,
unsigned int const y,
char *const pdx,
char *const pdy)
{
if (((x + *pdx) > (pBitmap->nXDomain)) || ((x + *pdx) < 0))
{
*pdx = random8() % 2 * (x < (pBitmap->nXDomain / 2) ? 1 : -1);
}
if (((y + *pdy) > (pBitmap->nYDomain)) || ((y + *pdy) < 0))
{
*pdy = random8() % 2 * (y < (pBitmap->nYDomain / 2) ? 1 : -1);
}
if (*pdx == 0 && *pdy == 0)
{
*pdx = (x < (pBitmap->nXDomain / 2) ? 1 : -1);
*pdy = (y < (pBitmap->nYDomain / 2) ? 1 : -1);
}
}
/**
* This function scrolls through a bitmap.
* @param nWidth Width of the bitmap.
* @param nHeight Height of bitmap.
* @param nBitPlanes Amount of bit planes.
* @param nFrameCount How many frames shall be shown.
* @param nFrameTick Duration of a displayed frame in milliseconds.
* @param fpGetChunk Function that returns an eight-by-one chunk of a bitmap.
*/
void bitmap_scroll(unsigned int const nWidth,
unsigned int const nHeight,
unsigned char const nBitPlanes,
unsigned int const nFrameCount,
unsigned int const nFrameTick,
bitmap_getChunk_t fpGetChunk)
{
assert((nBitPlanes > 0) && (nBitPlanes <= 8));
bitmap_t bitmap;
// user provided values
bitmap.nWidth = nWidth;
bitmap.nHeight = nHeight;
bitmap.nBitPlanes = nBitPlanes;
bitmap.fpGetChunk = fpGetChunk;
// calculate domains for coordinates and chunk indices
bitmap.nViewportWidth = (NUM_COLS > nWidth) ? nWidth : NUM_COLS;
bitmap.nViewportHeight = (NUM_ROWS > nHeight) ? nHeight : NUM_ROWS;
bitmap.nXDomain = nWidth - bitmap.nViewportWidth;
bitmap.nYDomain = nHeight - bitmap.nViewportHeight;
bitmap.nChunkDomain = nWidth - 8;
bitmap.nChunkCount = (((bitmap.nViewportWidth - 1) / 8) + 1);
// initial starting point
int x = random8() % (bitmap.nXDomain + 1);
int y = random8() % (bitmap.nYDomain + 1);
char dx = 0;
char dy = 0;
// remove garbage from screen
clear_screen(0);
for (bitmap.nFrame = 0; bitmap.nFrame < nFrameCount; ++bitmap.nFrame)
{
bitmap_drawViewport(&bitmap, x, y);
bitmap_recalculateVector(&bitmap, x, y, &dx, &dy);
x += bitmap.nWidth > bitmap.nViewportWidth ? dx : 0;
y += bitmap.nHeight > bitmap.nViewportHeight ? dy : 0;
wait(nFrameTick);
}
}

View File

@ -0,0 +1,33 @@
#ifndef BITMAP_SCROLLER_H_
#define BITMAP_SCROLLER_H_
#include <stdint.h>
/**
* This type definition describes a function which is supposed to provide an
* eight-by-one pixel chunk of a bitmap for a given bit plane. The x-coordinates
* are based on chunks, not on pixels (i.e. nChunkX=2 has to be interpreted as
* a pixel based x-coordinate of 16). This way it is easy to provide the bitmap
* via a simple lookup in an uint8_t typed array. (0,0) is considered as the top
* left coordinate.
* @param nBitPlane Number of the desired bit plane.
* @param nChunkX x-coordinate of the chunk.
* @param nChunkY y-coordinate of the chunk.
* @param nFrame The current frame number (in case you want to animate sth.).
* @return an eight-by-one chunk of the bitmap packed into an uint8_t typed
*/
typedef uint8_t (*bitmap_getChunk_t)(unsigned int const nBitPlane,
unsigned int const nChunkX,
unsigned int const nChunkY,
unsigned int const nFrame);
void bitmap_scroll(unsigned int const nWidth,
unsigned int const nHeight,
unsigned char const nBitPlanes,
unsigned int const nFrameCount,
unsigned int const nFrameTick,
bitmap_getChunk_t fpGetChunk);
#endif /* BITMAP_SCROLLER_H_ */

View File

@ -1,25 +1,26 @@
mainmenu_option next_comment mainmenu_option next_comment
comment "Animations" comment "Animations"
comment "selects which animations are displayed in main loop" dep_bool "Scrolltext" ANIMATION_SCROLLTEXT $SCROLLTEXT_SUPPORT
bool "Spirale" ANIMATION_SPIRALE
bool "Joern1" ANIMATION_JOERN1
dep_bool "Snake" ANIMATION_SNAKE $RANDOM_SUPPORT
bool "Schachbrett" ANIMATION_SCHACHBRETT
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 "Flying Dots" ANIMATION_FLYINGDOTS $RANDOM_SUPPORT
dep_bool "Game of Life" ANIMATION_GAMEOFLIFE $RANDOM_SUPPORT
dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT
bool "Martin Herweg" ANIMATION_MHERWEG
dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT
dep_bool "Scrolltext" ANIMATION_SCROLLTEXT $SCROLLTEXT_SUPPORT dep_bool_menu "Bitmap Scroller" ANIMATION_BMSCROLLER y $RANDOM_SUPPORT
bool "Spirale" ANIMATION_SPIRALE dep_bool "LABOR Logo" ANIMATION_LABORLOGO $ANIMATION_BMSCROLLER
bool "Joern1" ANIMATION_JOERN1 dep_bool "Amphibian" ANIMATION_AMPHIBIAN $ANIMATION_BMSCROLLER
dep_bool "Snake" ANIMATION_SNAKE $RANDOM_SUPPORT endmenu
bool "Schachbrett" ANIMATION_SCHACHBRETT
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 "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
bool "Display off mode" ANIMATION_OFF
comment "Special Animations"
bool "Test Animations" ANIMATION_TESTS
bool "Display off mode" ANIMATION_OFF
endmenu endmenu

View File

@ -1,179 +0,0 @@
#include <stdint.h>
#include <assert.h>
#include "../compat/pgmspace.h"
#include "../random/prng.h"
#include "../util.h"
#include "../autoconf.h"
#include "../pixel.h"
#define PB(a) pgm_read_byte(&(a))
#define BITMAP_WIDTH 48
#define BITMAP_HEIGHT 48
#if NUM_COLS > BITMAP_WIDTH
#define VIEWPORT_WIDTH BITMAP_WIDTH
#else
#define VIEWPORT_WIDTH NUM_COLS
#endif
#if NUM_ROWS > BITMAP_HEIGHT
#define VIEWPORT_HEIGHT BITMAP_HEIGHT
#else
#define VIEWPORT_HEIGHT NUM_ROWS
#endif
#define XDOMAIN (BITMAP_WIDTH - VIEWPORT_WIDTH)
#define YDOMAIN (BITMAP_HEIGHT - VIEWPORT_HEIGHT)
#define CHUNKDOMAIN (BITMAP_WIDTH - 8)
#define CHUNKCOUNT (((VIEWPORT_WIDTH - 1) / 8) + 1)
#define FRAME_TICK 75
#define FRAMECOUNT 400
static uint8_t laborlogo_getChunk(const uint8_t x, const uint8_t y)
{
assert(x <= CHUNKDOMAIN);
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}};
uint8_t nChunk;
uint8_t nAlignment = x % 8;
if (nAlignment == 0)
{
nChunk = PB(nBitmap[y][x / 8]);
}
else
{
nChunk = PB(nBitmap[y][x / 8]) << nAlignment;
nChunk |= PB(nBitmap[y][x / 8 + 1]) >> (8 - nAlignment);
}
return nChunk;
}
static void laborlogo_drawViewport(const uint8_t nBitmapX,
const uint8_t nBitmapY)
{
assert(nBitmapX <= XDOMAIN);
assert(nBitmapY <= YDOMAIN);
for (int8_t y = 0; y < VIEWPORT_HEIGHT; ++y)
{
for (int8_t x = VIEWPORT_WIDTH; x > 0; x -= 8)
{
uint8_t nChunk;
if ((nBitmapX + x - 8) >= 0)
{
nChunk = laborlogo_getChunk(nBitmapX + x - 8, nBitmapY + y);
pixmap[2][y][CHUNKCOUNT - 1 - ((x - 1) / 8)] = nChunk;
}
else
{
nChunk = laborlogo_getChunk(nBitmapX, nBitmapY + y) >> (8 - x);
pixmap[2][y][CHUNKCOUNT - 1] = nChunk;
}
}
}
}
static void laborlogo_recalcVector(const int8_t x,
const int8_t y,
int8_t *const pdx,
int8_t *const pdy)
{
if (((x + *pdx) > (XDOMAIN)) || ((x + *pdx) < 0))
{
*pdx = random8() % 2 * (x < (XDOMAIN / 2) ? 1 : -1);
}
if (((y + *pdy) > (YDOMAIN)) || ((y + *pdy) < 0))
{
*pdy = random8() % 2 * (y < (YDOMAIN / 2) ? 1 : -1);
}
if (*pdx == 0 && *pdy == 0)
{
*pdx = (x < (XDOMAIN / 2) ? 1 : -1);
*pdy = (y < (YDOMAIN / 2) ? 1 : -1);
}
}
void laborlogo()
{
int8_t x = random8() % (XDOMAIN + 1);
int8_t y = random8() % (YDOMAIN + 1);
int8_t dx = 0;
int8_t dy = 0;
clear_screen(0);
for (uint16_t nCycles = FRAMECOUNT; nCycles > 0; --nCycles)
{
laborlogo_drawViewport(x, y);
laborlogo_recalcVector(x, y, &dx, &dy);
#if BITMAP_WIDTH > VIEWPORT_WIDTH
x += dx;
#endif
#if BITMAP_HEIGHT > VIEWPORT_HEIGHT
y += dy;
#endif
wait(FRAME_TICK);
}
}

View File

@ -1,13 +0,0 @@
/*
* laborlogo.h
*
* Created on: 13.04.2010
* Author: chris
*/
#ifndef LABORLOGO_H_
#define LABORLOGO_H_
void laborlogo();
#endif /* LABORLOGO_H_ */

View File

@ -1,63 +1,60 @@
mainmenu_name "Borg Configuration" mainmenu_name "Borg Configuration"
###################### General Setup Menu ##################################### ### General Setup Menu ########################################################
mainmenu_option next_comment mainmenu_option next_comment
comment "General Setup" comment "General Setup"
#bool 'Prompt for experimental code' CONFIG_EXPERIMENTAL #bool 'Prompt for experimental code' CONFIG_EXPERIMENTAL
choice 'Target MCU' \ choice 'Target MCU' \
"ATmega8 atmega8 \ "ATmega8 atmega8 \
ATmega32 atmega32 \ ATmega32 atmega32 \
ATmega644 atmega644 \ ATmega644 atmega644 \
ATmega644p atmega644p" \ ATmega644p atmega644p" \
'ATmega32' MCU 'ATmega32' MCU
int "MCU frequency" FREQ 16000000 int "MCU frequency" FREQ 16000000
endmenu endmenu
############################################################################### ###############################################################################
###################### Borg Hardware Menu ##################################### ### Borg Hardware Menu ########################################################
source borg_hw/config.in source borg_hw/config.in
############################################################################### ###############################################################################
########################### Features Menu ##################################### ### Features Menu #############################################################
mainmenu_option next_comment mainmenu_option next_comment
comment "Features" comment "Features"
bool "prng random number generator" RANDOM_SUPPORT y
bool "prng random number generator" RANDOM_SUPPORT y
endmenu endmenu
############################################################################### ###############################################################################
########################## Scrolltext Menu #################################### ### Scrolltext Menu ###########################################################
source scrolltext/config.in source scrolltext/config.in
############################################################################### ###############################################################################
############################ Joystick Menu #################################### ### Joystick Menu #############################################################
source joystick/config.in source joystick/config.in
############################################################################### ###############################################################################
############################ CAN Menu #########################################
### CAN Menu ##################################################################
source can/config.in source can/config.in
############################################################################### ###############################################################################
### Borg Menu #################################################################
dep_bool "menu support" MENU_SUPPORT $JOYSTICK_SUPPORT dep_bool "menu support" MENU_SUPPORT $JOYSTICK_SUPPORT
###############################################################################
### Game Menu #################################################################
############################ Game Menu ########################################
source games/config.in source games/config.in
############################################################################### ###############################################################################
######################### Animations Menu ##################################### ### Animations Menu ###########################################################
source animations/config.in source animations/config.in
############################################################################### ###############################################################################

View File

@ -11,6 +11,7 @@
#include "animations/flyingdots.h" #include "animations/flyingdots.h"
#include "animations/breakout_demo.h" #include "animations/breakout_demo.h"
#include "animations/ltn_ant.h" #include "animations/ltn_ant.h"
#include "animations/amphibian.h"
#include "animations/laborlogo.h" #include "animations/laborlogo.h"
#include "borg_hw/borg_hw.h" #include "borg_hw/borg_hw.h"
#include "can/borg_can.h" #include "can/borg_can.h"
@ -145,7 +146,13 @@ void display_loop(){
#ifdef ANIMATION_LABORLOGO #ifdef ANIMATION_LABORLOGO
case 15: case 15:
laborlogo();; laborlogo();
break;
#endif
#ifdef ANIMATION_AMPHIBIAN
case 16:
amphibian();
break; break;
#endif #endif