saved another 270 bytes
This commit is contained in:
parent
ccc549db61
commit
4920272878
|
@ -6,9 +6,9 @@
|
||||||
#include "27c3.h"
|
#include "27c3.h"
|
||||||
|
|
||||||
|
|
||||||
static uint8_t logo_27c3_getChunk(unsigned int const nBitPlane,
|
static uint8_t logo_27c3_getChunk(unsigned char const nBitPlane,
|
||||||
unsigned int const nChunkX,
|
unsigned char const nChunkX,
|
||||||
unsigned int const nChunkY,
|
unsigned char const nChunkY,
|
||||||
unsigned int const nFrame)
|
unsigned int const nFrame)
|
||||||
{
|
{
|
||||||
assert(nBitPlane < 2);
|
assert(nBitPlane < 2);
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#include "amphibian.h"
|
#include "amphibian.h"
|
||||||
|
|
||||||
|
|
||||||
static uint8_t amphibian_getChunk(unsigned int const nBitPlane,
|
static uint8_t amphibian_getChunk(unsigned char const nBitPlane,
|
||||||
unsigned int const nChunkX,
|
unsigned char const nChunkX,
|
||||||
unsigned int const nChunkY,
|
unsigned char const nChunkY,
|
||||||
unsigned int const nFrame)
|
unsigned int const nFrame)
|
||||||
{
|
{
|
||||||
assert(nChunkX < 6);
|
assert(nChunkX < 6);
|
||||||
|
@ -129,7 +129,7 @@ static uint8_t amphibian_getChunk(unsigned int const nBitPlane,
|
||||||
{0x07, 0xF0, 0xFE}}};
|
{0x07, 0xF0, 0xFE}}};
|
||||||
|
|
||||||
|
|
||||||
if ((nChunkX >= 0) && (nChunkX <= 2) && (nChunkY >= 2) && (nChunkY <= 5)
|
if ((nChunkX <= 2) && (nChunkY >= 2) && (nChunkY <= 5)
|
||||||
&& (((nFrame >> 1) % 8) != 0))
|
&& (((nFrame >> 1) % 8) != 0))
|
||||||
{
|
{
|
||||||
uint8_t nOffset;
|
uint8_t nOffset;
|
||||||
|
@ -148,6 +148,7 @@ static uint8_t amphibian_getChunk(unsigned int const nBitPlane,
|
||||||
nOffset = 8;
|
nOffset = 8;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
default:
|
||||||
nOffset = 12;
|
nOffset = 12;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
#include "../autoconf.h"
|
#include "../autoconf.h"
|
||||||
#include "../pixel.h"
|
#include "../pixel.h"
|
||||||
|
#include "../joystick/joystick.h"
|
||||||
#include "bitmapscroller.h"
|
#include "bitmapscroller.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,17 +16,17 @@
|
||||||
*/
|
*/
|
||||||
typedef struct bitmap_t
|
typedef struct bitmap_t
|
||||||
{
|
{
|
||||||
unsigned int nWidth; /**< Width of the bitmap. */
|
unsigned char nWidth; /**< Width of the bitmap. */
|
||||||
unsigned int nHeight; /**< Height of the bitmap. */
|
unsigned char nHeight; /**< Height of the bitmap. */
|
||||||
unsigned char nBitPlanes; /**< Number of bit planes. */
|
unsigned char nBitPlanes; /**< Number of bit planes. */
|
||||||
bitmap_getChunk_t fpGetChunk; /**< Bitmap chunk retrieving function. */
|
bitmap_getChunk_t fpGetChunk; /**< Bitmap chunk retrieving function. */
|
||||||
unsigned int nFrame; /**< Current frame number. */
|
unsigned int nFrame; /**< Current frame number. */
|
||||||
unsigned int nViewportWidth; /**< Width of the displayed content. */
|
unsigned char nViewportWidth; /**< Width of the displayed content. */
|
||||||
unsigned int nViewportHeight; /**< Height of the displayed content. */
|
unsigned char nViewportHeight; /**< Height of the displayed content. */
|
||||||
unsigned int nXDomain; /**< Last valid x-coordinate for viewport. */
|
unsigned char nXDomain; /**< Last valid x-coordinate for viewport. */
|
||||||
unsigned int nYDomain; /**< Last valid y-coordinate for viewport. */
|
unsigned char nYDomain; /**< Last valid y-coordinate for viewport. */
|
||||||
unsigned int nChunkDomain; /**< Last valid chunk for viewport. */
|
unsigned char nChunkDomain; /**< Last valid chunk for viewport. */
|
||||||
unsigned int nChunkCount; /**< Amount of horiz. chunks of the bitmap. */
|
unsigned char nChunkCount; /**< Amount of horiz. chunks of the bitmap. */
|
||||||
}
|
}
|
||||||
bitmap_t;
|
bitmap_t;
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ static unsigned char bitmap_getAlignedChunk(bitmap_t const *const pBitmap,
|
||||||
unsigned char nAlignment = x % 8;
|
unsigned char nAlignment = x % 8;
|
||||||
|
|
||||||
// we have to go through every bit plane
|
// we have to go through every bit plane
|
||||||
for (int i = 0; i < pBitmap->nBitPlanes; ++i)
|
for (unsigned char i = 0; i < pBitmap->nBitPlanes; ++i)
|
||||||
{
|
{
|
||||||
// generate chunk
|
// generate chunk
|
||||||
unsigned char nPlaneChunk;
|
unsigned char nPlaneChunk;
|
||||||
|
@ -104,24 +105,28 @@ static void bitmap_drawViewport(bitmap_t const *const pBitmap,
|
||||||
unsigned char nPlanes = nBitmapHwPlanes > NUMPLANE ?
|
unsigned char nPlanes = nBitmapHwPlanes > NUMPLANE ?
|
||||||
NUMPLANE : nBitmapHwPlanes;
|
NUMPLANE : nBitmapHwPlanes;
|
||||||
|
|
||||||
for (int8_t y = 0; y < pBitmap->nViewportHeight; ++y)
|
for (unsigned char y = 0; y < pBitmap->nViewportHeight; ++y)
|
||||||
{
|
{
|
||||||
for (int8_t x = pBitmap->nViewportWidth; x > 0; x -= 8)
|
for (unsigned char x = 0; x < pBitmap->nViewportWidth; x += 8)
|
||||||
{
|
{
|
||||||
for (int8_t p = NUMPLANE - nPlanes; p < NUMPLANE; ++p)
|
for (unsigned char p = NUMPLANE - nPlanes; p < NUMPLANE; ++p)
|
||||||
{
|
{
|
||||||
uint8_t nChunk;
|
unsigned char nChunk;
|
||||||
if ((nX + x - 8) >= 0)
|
#if ((NUM_COLS % 8) != 0)
|
||||||
|
if ((x + nX) > (8 - NUM_COLS % 8))
|
||||||
{
|
{
|
||||||
nChunk = bitmap_getAlignedChunk(pBitmap, p, nX+x-8, nY + y);
|
nChunk = bitmap_getAlignedChunk(pBitmap, p,
|
||||||
pixmap[p][y][pBitmap->nChunkCount - 1 - ((x-1)/8)] = nChunk;
|
nX + x - (8 - NUM_COLS % 8), nY + y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nChunk = bitmap_getAlignedChunk(pBitmap, p, nX, nY + y)
|
nChunk = bitmap_getAlignedChunk(pBitmap, p,
|
||||||
>> (8-x);
|
nX, nY + y) >> (8 - NUM_COLS % 8);
|
||||||
pixmap[p][y][pBitmap->nChunkCount - 1] = nChunk;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
nChunk = bitmap_getAlignedChunk(pBitmap, p, nX + x, nY + y);
|
||||||
|
#endif
|
||||||
|
pixmap[p][y][pBitmap->nChunkCount - 1 - (x / 8)] = nChunk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +143,8 @@ static void bitmap_drawViewport(bitmap_t const *const pBitmap,
|
||||||
* @param pdy Pointer to a variable which shall hold the vertical offset.
|
* @param pdy Pointer to a variable which shall hold the vertical offset.
|
||||||
*/
|
*/
|
||||||
static void bitmap_recalculateVector(bitmap_t const *const pBitmap,
|
static void bitmap_recalculateVector(bitmap_t const *const pBitmap,
|
||||||
unsigned int const x,
|
unsigned char const x,
|
||||||
unsigned int const y,
|
unsigned char const y,
|
||||||
char *const pdx,
|
char *const pdx,
|
||||||
char *const pdy)
|
char *const pdy)
|
||||||
{
|
{
|
||||||
|
@ -168,8 +173,8 @@ static void bitmap_recalculateVector(bitmap_t const *const pBitmap,
|
||||||
* @param nFrameTick Duration of a displayed frame in milliseconds.
|
* @param nFrameTick Duration of a displayed frame in milliseconds.
|
||||||
* @param fpGetChunk Function that returns an eight-by-one chunk of a bitmap.
|
* @param fpGetChunk Function that returns an eight-by-one chunk of a bitmap.
|
||||||
*/
|
*/
|
||||||
void bitmap_scroll(unsigned int const nWidth,
|
void bitmap_scroll(unsigned char const nWidth,
|
||||||
unsigned int const nHeight,
|
unsigned char const nHeight,
|
||||||
unsigned char const nBitPlanes,
|
unsigned char const nBitPlanes,
|
||||||
unsigned int const nFrameCount,
|
unsigned int const nFrameCount,
|
||||||
unsigned int const nFrameTick,
|
unsigned int const nFrameTick,
|
||||||
|
@ -205,7 +210,6 @@ void bitmap_scroll(unsigned int const nWidth,
|
||||||
for (bitmap.nFrame = 0; bitmap.nFrame < nFrameCount; ++bitmap.nFrame)
|
for (bitmap.nFrame = 0; bitmap.nFrame < nFrameCount; ++bitmap.nFrame)
|
||||||
{
|
{
|
||||||
bitmap_drawViewport(&bitmap, x, y);
|
bitmap_drawViewport(&bitmap, x, y);
|
||||||
|
|
||||||
bitmap_recalculateVector(&bitmap, x, y, &dx, &dy);
|
bitmap_recalculateVector(&bitmap, x, y, &dx, &dy);
|
||||||
x += bitmap.nWidth > bitmap.nViewportWidth ? dx : 0;
|
x += bitmap.nWidth > bitmap.nViewportWidth ? dx : 0;
|
||||||
y += bitmap.nHeight > bitmap.nViewportHeight ? dy : 0;
|
y += bitmap.nHeight > bitmap.nViewportHeight ? dy : 0;
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
* @param nFrame The current frame number (in case you want to animate sth.).
|
* @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
|
* @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,
|
typedef uint8_t (*bitmap_getChunk_t)(unsigned char const nBitPlane,
|
||||||
unsigned int const nChunkX,
|
unsigned char const nChunkX,
|
||||||
unsigned int const nChunkY,
|
unsigned char const nChunkY,
|
||||||
unsigned int const nFrame);
|
unsigned int const nFrame);
|
||||||
|
|
||||||
|
|
||||||
void bitmap_scroll(unsigned int const nWidth,
|
void bitmap_scroll(unsigned char const nWidth,
|
||||||
unsigned int const nHeight,
|
unsigned char const nHeight,
|
||||||
unsigned char const nBitPlanes,
|
unsigned char const nBitPlanes,
|
||||||
unsigned int const nFrameCount,
|
unsigned int const nFrameCount,
|
||||||
unsigned int const nFrameTick,
|
unsigned int const nFrameTick,
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#include "laborlogo.h"
|
#include "laborlogo.h"
|
||||||
|
|
||||||
|
|
||||||
static uint8_t laborlogo_getChunk(unsigned int const nBitPlane,
|
static uint8_t laborlogo_getChunk(unsigned char const nBitPlane,
|
||||||
unsigned int const nChunkX,
|
unsigned char const nChunkX,
|
||||||
unsigned int const nChunkY,
|
unsigned char const nChunkY,
|
||||||
unsigned int const nFrame)
|
unsigned int const nFrame)
|
||||||
{
|
{
|
||||||
assert(nChunkX < 6);
|
assert(nChunkX < 6);
|
||||||
|
|
Loading…
Reference in New Issue