103 lines
4.6 KiB
C
103 lines
4.6 KiB
C
// Space Taxi -- the cel bank definition + the shared cel expansion.
|
|
// See stCels.h. Ordered exactly as stRenderPrewarm built the cels: the
|
|
// cab set (flying, wreck and the intro decorations) and passenger set in
|
|
// multicolour at the constant level colours (cab/passenger 6, shared
|
|
// $D025/$D026 = 2/7), then the flame set in multicolour colour 7. No
|
|
// intro star: the level intro paints its starfield into the character
|
|
// screen (stTitle.c), so the star sprite is never drawn.
|
|
|
|
#include "stCels.h"
|
|
|
|
// mc0/mc1 are the level-wide multicolour registers, constant across all
|
|
// 24 screens and the title (verified from the level headers): 2 and 7.
|
|
#define MC0 0x02u
|
|
#define MC1 0x07u
|
|
#define CAB 0x06u // cab and passenger per-sprite colour
|
|
#define FLM 0x07u // flame colour
|
|
|
|
const StCelDefT kStCels[] = {
|
|
// Cab: flying (gear up/down x left/right), wreck cels, intro cabs.
|
|
{ 0xC0, CAB, 1u, MC0, MC1 }, { 0xC1, CAB, 1u, MC0, MC1 },
|
|
{ 0xDC, CAB, 1u, MC0, MC1 }, { 0xDD, CAB, 1u, MC0, MC1 },
|
|
{ 0xCC, CAB, 1u, MC0, MC1 }, { 0xCD, CAB, 1u, MC0, MC1 },
|
|
{ 0xCE, CAB, 1u, MC0, MC1 }, { 0xCF, CAB, 1u, MC0, MC1 },
|
|
{ 0xD0, CAB, 1u, MC0, MC1 }, { 0xD1, CAB, 1u, MC0, MC1 },
|
|
{ 0xE2, CAB, 1u, MC0, MC1 }, { 0xE3, CAB, 1u, MC0, MC1 },
|
|
{ 0xE4, CAB, 1u, MC0, MC1 }, { 0xE5, CAB, 1u, MC0, MC1 },
|
|
{ 0xE6, CAB, 1u, MC0, MC1 }, { 0xE7, CAB, 1u, MC0, MC1 },
|
|
{ 0xE8, CAB, 1u, MC0, MC1 },
|
|
// Passenger: walk cels and the boarding cel.
|
|
{ 0xC2, CAB, 1u, MC0, MC1 }, { 0xC3, CAB, 1u, MC0, MC1 },
|
|
{ 0xC4, CAB, 1u, MC0, MC1 }, { 0xC5, CAB, 1u, MC0, MC1 },
|
|
{ 0xC6, CAB, 1u, MC0, MC1 }, { 0xC7, CAB, 1u, MC0, MC1 },
|
|
{ 0xC8, CAB, 1u, MC0, MC1 }, { 0xC9, CAB, 1u, MC0, MC1 },
|
|
{ 0xCA, CAB, 1u, MC0, MC1 }, { 0xCB, CAB, 1u, MC0, MC1 },
|
|
{ 0xD9, CAB, 1u, MC0, MC1 },
|
|
// Flame (exhaust) cels, colour 7.
|
|
{ 0xD8, FLM, 1u, MC0, MC1 }, { 0xD4, FLM, 1u, MC0, MC1 },
|
|
{ 0xD5, FLM, 1u, MC0, MC1 }, { 0xD2, FLM, 1u, MC0, MC1 },
|
|
{ 0xD1, FLM, 1u, MC0, MC1 }, { 0xD7, FLM, 1u, MC0, MC1 },
|
|
{ 0xD3, FLM, 1u, MC0, MC1 }, { 0xD6, FLM, 1u, MC0, MC1 },
|
|
};
|
|
|
|
const uint16_t kStCelCount = (uint16_t)(sizeof(kStCels) / sizeof(kStCels[0]));
|
|
|
|
|
|
// Cels the title screen draws that are deliberately NOT pre-compiled.
|
|
//
|
|
// Its five decoration sprites are recoloured by logoColorCycle ($4861),
|
|
// which rewrites sprites 3..7 with the next logo colour every cycle
|
|
// step, so each is seen in all eight of kLogoColor's values -- forty
|
|
// combinations. The parked cab's jet is a forty-first, colour 6 rather
|
|
// than the flame list's 7. None of them are worth a bank slot: on the
|
|
// 65816 a compile costs about half a second, so baking the forty would
|
|
// add some twenty seconds to startup, and raising kStCelCount at all is
|
|
// risky -- 37 made the runtime reject the whole precompiled bank (see
|
|
// the note in the project memory). They draw interpreted, which
|
|
// a static title screen can well afford. stRender consults this list so
|
|
// the mid-ride warning stays about real misses.
|
|
// A zero colour means "in any colour": the decorations cycle through all
|
|
// eight. The jet is listed for the cab colour alone, because the flame
|
|
// list above already carries it in colour 7 for the ride itself.
|
|
const StCelDefT kStInterpretedCels[] = {
|
|
{ 0xDB, 0u, 1u, MC0, MC1 }, { 0xDE, 0u, 1u, MC0, MC1 },
|
|
{ 0xDF, 0u, 1u, MC0, MC1 }, { 0xE0, 0u, 1u, MC0, MC1 },
|
|
{ 0xE1, 0u, 1u, MC0, MC1 },
|
|
{ 0xD8, CAB, 1u, MC0, MC1 },
|
|
};
|
|
const uint16_t kStInterpretedCount = (uint16_t)(sizeof(kStInterpretedCels) / sizeof(kStInterpretedCels[0]));
|
|
|
|
|
|
void stCelBlob(const uint8_t *bm, uint8_t multi, uint8_t color, uint8_t mc0, uint8_t mc1, uint8_t *out) {
|
|
uint8_t pal[4];
|
|
uint8_t tx;
|
|
uint8_t ty;
|
|
uint8_t row;
|
|
uint8_t k;
|
|
|
|
pal[0] = 0u;
|
|
pal[1] = mc0;
|
|
pal[2] = color;
|
|
pal[3] = mc1;
|
|
for (ty = 0u; ty < ST_CEL_TILES; ty++) {
|
|
for (tx = 0u; tx < ST_CEL_TILES; tx++) {
|
|
uint8_t *tile = &out[(ty * ST_CEL_TILES + tx) * 32u];
|
|
for (row = 0u; row < 8u; row++) {
|
|
uint8_t y = (uint8_t)(ty * 8u + row);
|
|
uint8_t *p = &tile[row * 4u];
|
|
uint8_t b = 0u;
|
|
if (bm != 0 && y < ST_CEL_ROWS) {
|
|
b = bm[y * 3u + tx];
|
|
}
|
|
for (k = 0u; k < 4u; k++) {
|
|
uint8_t pair = (uint8_t)((b >> (6u - k * 2u)) & 3u);
|
|
if (multi != 0u) {
|
|
p[k] = (uint8_t)((pal[pair] << 4) | pal[pair]);
|
|
} else {
|
|
p[k] = (uint8_t)((((pair & 2u) != 0u) ? (uint8_t)(color << 4) : 0u) | (((pair & 1u) != 0u) ? color : 0u));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|