Browse Source

decoupled frame rate from movement rate

feature/2015
Christian Kroll 13 years ago
parent
commit
24ef3480ff
  1. 2
      animations/amphibian.c
  2. 33
      animations/bitmapscroller.c
  3. 6
      animations/bitmapscroller.h
  4. 4
      animations/fairydust.c
  5. 2
      animations/laborlogo.c
  6. 3
      animations/outofspec.c

2
animations/amphibian.c

@ -146,5 +146,5 @@ static uint8_t amphibian_getChunk(unsigned char const nBitPlane,
void amphibian()
{
bitmap_scroll(48, 38, 2, 400, 75, amphibian_getChunk);
bitmap_scroll(48, 38, 2, 400, 75, 1, 1, amphibian_getChunk);
}

33
animations/bitmapscroller.c

@ -176,18 +176,24 @@ static void bitmap_recalculateVector(bitmap_t const *const pBitmap,
* @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 nTickCount How many ticks the animation will last.
* @param nTick Time quantum in milliseconds.
* @param nFrameTickDivider Amount of ticks between frame changes.
* @param nMovementTickDiver Amount of ticks between movement changes.
* @param fpGetChunk Function that returns an eight-by-one chunk of a bitmap.
*/
void bitmap_scroll(unsigned char const nWidth,
unsigned char const nHeight,
unsigned char const nBitPlanes,
unsigned int const nFrameCount,
unsigned int const nFrameTick,
unsigned int const nTickCount,
unsigned int const nTick,
unsigned char const nFrameTickDivider,
unsigned char const nMovementTickDivider,
bitmap_getChunk_t fpGetChunk)
{
assert((nBitPlanes > 0) && (nBitPlanes <= 8));
assert(nFrameTickDivider > 0);
assert(nFrameTickDivider > 0);
bitmap_t bitmap;
@ -206,18 +212,25 @@ void bitmap_scroll(unsigned char const nWidth,
bitmap.nChunkCount = (((bitmap.nViewportWidth - 1) / 8) + 1);
// initial starting point
bitmap.nFrame = 0;
unsigned char x = bitmap.nXDomain > 0 ? random8() % bitmap.nXDomain : 0;
unsigned char y = bitmap.nYDomain > 0 ? random8() % bitmap.nYDomain : 0;
signed char dx = 0;
signed char dy = 0;
for (bitmap.nFrame = 0; bitmap.nFrame < nFrameCount; ++bitmap.nFrame)
for (unsigned int i = 0; i < nTickCount; ++i)
{
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);
if ((i % nFrameTickDivider) == 0)
{
++bitmap.nFrame;
}
if ((i % nMovementTickDivider) == 0)
{
bitmap_recalculateVector(&bitmap, x, y, &dx, &dy);
x += bitmap.nWidth > bitmap.nViewportWidth ? dx : 0;
y += bitmap.nHeight > bitmap.nViewportHeight ? dy : 0;
}
wait(nTick);
}
}

6
animations/bitmapscroller.h

@ -26,8 +26,10 @@ typedef uint8_t (*bitmap_getChunk_t)(unsigned char const nBitPlane,
void bitmap_scroll(unsigned char const nWidth,
unsigned char const nHeight,
unsigned char const nBitPlanes,
unsigned int const nFrameCount,
unsigned int const nFrameTick,
unsigned int const nTickCount,
unsigned int const nTick,
unsigned char const nFrameTickDivider,
unsigned char const nMovementTickDivider,
bitmap_getChunk_t fpGetChunk);
#endif /* BITMAP_SCROLLER_H_ */

4
animations/fairydust.c

@ -204,6 +204,6 @@ static uint8_t fairydust_getChunk(unsigned char const nBitPlane,
void fairydust()
{
// width 72, height 30+x, 2 bitplanes (4 colors), 600 frames à 50ms (20 fps)
bitmap_scroll(72, nMargin + 30 + nMargin, 2, 600, 50, fairydust_getChunk);
bitmap_scroll(72, nMargin + 30 + nMargin, 2, 2400, 12, 1, 4,
fairydust_getChunk);
}

2
animations/laborlogo.c

@ -70,5 +70,5 @@ static uint8_t laborlogo_getChunk(unsigned char const nBitPlane,
void laborlogo()
{
bitmap_scroll(48, 48, 2, 400, 75, laborlogo_getChunk);
bitmap_scroll(48, 48, 2, 400, 75, 1, 1, laborlogo_getChunk);
}

3
animations/outofspec.c

@ -125,6 +125,5 @@ static uint8_t logo_OutOfSpec_getChunk(unsigned char const nBitPlane,
void logo_OutOfSpec()
{
// width 64, height 50, 2 bitplanes (4 colors), 600 frames à 50ms (20 fps)
bitmap_scroll(64, 50, 2, 600, 50, logo_OutOfSpec_getChunk);
bitmap_scroll(64, 50, 2, 600, 50, 1, 1, logo_OutOfSpec_getChunk);
}

Loading…
Cancel
Save