mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-07 01:29:30 +00:00
coleco: update presets, stars.c; __MAIN__ define for main file
This commit is contained in:
parent
002e8e2447
commit
1d1512453d
|
@ -10,12 +10,14 @@
|
||||||
|
|
||||||
#define XOFS 12 // sprite horiz. offset
|
#define XOFS 12 // sprite horiz. offset
|
||||||
|
|
||||||
|
#define BGCOL CV_COLOR_BLUE
|
||||||
|
|
||||||
#define CH_BORDER 64
|
#define CH_BORDER 64
|
||||||
#define CH_FLOOR 65
|
#define CH_FLOOR 65
|
||||||
#define CH_LADDER 66
|
#define CH_LADDER 66
|
||||||
|
|
||||||
const byte char_table[8][8] = {
|
const byte char_table[8][8] = {
|
||||||
/*{w:8,h:8,count:8}*/
|
/*{w:8,h:8,brev:1,count:8}*/
|
||||||
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
|
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
|
||||||
{0xFF,0xBF,0xBF,0x00,0xFF,0xFB,0xFB,0x00},
|
{0xFF,0xBF,0xBF,0x00,0xFF,0xFB,0xFB,0x00},
|
||||||
{0x81,0xFF,0x81,0x81,0x81,0xFF,0x81,0x81},
|
{0x81,0xFF,0x81,0x81,0x81,0xFF,0x81,0x81},
|
||||||
|
@ -27,7 +29,7 @@ const byte char_table[8][8] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const byte static_sprite_table[2][16*2] = {
|
const byte static_sprite_table[2][16*2] = {
|
||||||
/*{w:16,h:16,remap:[-5,0,1,2,3,5,6,7,8,9],count:4}*/
|
/*{w:16,h:16,brev:1,remap:[4,0,1,2,3,5,6,7,8,9],count:4}*/
|
||||||
{
|
{
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x3F,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x3F,
|
||||||
0x35, 0x2A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3F,
|
0x35, 0x2A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3F,
|
||||||
|
@ -126,10 +128,6 @@ const byte sprite_table[NUM_SPRITE_PATTERNS*2][16*2] = {
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
#define BGCOL CV_COLOR_BLUE
|
|
||||||
|
|
||||||
///
|
|
||||||
|
|
||||||
typedef struct Level {
|
typedef struct Level {
|
||||||
byte ypos;
|
byte ypos;
|
||||||
byte height; // TODO: why does bitmask not work?
|
byte height; // TODO: why does bitmask not work?
|
||||||
|
|
|
@ -41,7 +41,6 @@ extern char font_bitmap_0[];
|
||||||
|
|
||||||
#define wait_vsync() __asm__("halt")
|
#define wait_vsync() __asm__("halt")
|
||||||
|
|
||||||
extern volatile bool vint;
|
|
||||||
extern volatile uint_fast8_t vint_counter;
|
extern volatile uint_fast8_t vint_counter;
|
||||||
|
|
||||||
extern void vint_handler(void);
|
extern void vint_handler(void);
|
||||||
|
|
|
@ -7,18 +7,25 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
//#link "common.c"
|
//#link "common.c"
|
||||||
|
|
||||||
|
#include "stars.h"
|
||||||
|
//#link "stars.c"
|
||||||
|
|
||||||
|
#ifdef CV_SMS
|
||||||
|
//#link "fonts.s"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NSPRITES 16
|
#define NSPRITES 16
|
||||||
#define NMISSILES 8
|
#define NMISSILES 8
|
||||||
#define YOFFSCREEN 239
|
#define YOFFSCREEN 239
|
||||||
|
|
||||||
static byte pattern_table[8*2] = {
|
static byte pattern_table[8*2] = {
|
||||||
/*{w:16,h:8,remap:[3,0,1,2]}*/
|
/*{w:16,h:8,brev:1,remap:[-4,0,1,2]}*/
|
||||||
0xCC, 0xF2, 0xD0, 0xFC, 0xF3, 0xE8, 0xC4, 0x03,
|
0xCC, 0xF2, 0xD0, 0xFC, 0xF3, 0xE8, 0xC4, 0x03,
|
||||||
0x0C, 0x13, 0x02, 0x0F, 0x33, 0x05, 0x08, 0x30,
|
0x0C, 0x13, 0x02, 0x0F, 0x33, 0x05, 0x08, 0x30,
|
||||||
};
|
};
|
||||||
|
|
||||||
static byte sprite_table[][16*2] = {
|
static byte sprite_table[][16*2] = {
|
||||||
/*{w:16,h:16,remap:[-5,0,1,2,3,5,6,7,8,9],count:15}*/
|
/*{w:16,h:16,brev:1,remap:[4,0,1,2,3,5,6,7,8,9],count:15}*/
|
||||||
{
|
{
|
||||||
0x01, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
|
0x01, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
0x03, 0x86, 0xCD, 0xBE, 0x9F, 0xB1, 0xC0, 0x80,
|
0x03, 0x86, 0xCD, 0xBE, 0x9F, 0xB1, 0xC0, 0x80,
|
||||||
|
@ -205,30 +212,28 @@ void setup_formation() {
|
||||||
#define BLANK 0
|
#define BLANK 0
|
||||||
|
|
||||||
void draw_row(byte row) {
|
void draw_row(byte row) {
|
||||||
byte i;
|
byte i,j;
|
||||||
byte x = formation_offset_x / 8;
|
byte x = formation_offset_x / 8;
|
||||||
byte xd = (formation_offset_x & 7) * 3;
|
byte xd = (formation_offset_x & 7) * 3;
|
||||||
byte y = 3 + row * 2;
|
byte y = 3 + row * 2;
|
||||||
//vcolumns[y].attrib = 0x2;
|
|
||||||
//vcolumns[y].scroll = formation_offset_x;
|
|
||||||
for (i=0; i<x; i++)
|
for (i=0; i<x; i++)
|
||||||
putchar(i, y, BLANK);
|
putchar(i, y, starfield_get_tile_xy(i,y));
|
||||||
for (i=0; i<ENEMIES_PER_ROW; i++) {
|
for (i=0; i<ENEMIES_PER_ROW; i++) {
|
||||||
byte shape = formation[i + row*ENEMIES_PER_ROW].shape;
|
byte shape = formation[i + row*ENEMIES_PER_ROW].shape;
|
||||||
if (shape) {
|
if (shape) {
|
||||||
shape += xd;
|
shape += xd;
|
||||||
putchar(x, y, shape);
|
for (j=0; j<3; j++) {
|
||||||
putchar(x+1, y, shape+1);
|
putchar(x++, y, shape++);
|
||||||
putchar(x+2, y, shape+2);
|
}
|
||||||
} else {
|
} else {
|
||||||
putchar(x, y, BLANK);
|
for (j=0; j<3; j++) {
|
||||||
putchar(x+1, y, BLANK);
|
putchar(x, y, starfield_get_tile_xy(x,y));
|
||||||
putchar(x+2, y, BLANK);
|
x++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x += 3;
|
|
||||||
}
|
}
|
||||||
for (; x<COLS; x++)
|
for (; x<COLS; x++)
|
||||||
putchar(x, y, BLANK);
|
putchar(x, y, starfield_get_tile_xy(x,y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_next_row() {
|
void draw_next_row() {
|
||||||
|
@ -620,6 +625,7 @@ void play_round() {
|
||||||
if (!enemies_left) end_timer--;
|
if (!enemies_left) end_timer--;
|
||||||
wait_for_frame();
|
wait_for_frame();
|
||||||
copy_sprites();
|
copy_sprites();
|
||||||
|
starfield_update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,6 +649,7 @@ void main() {
|
||||||
vdp_setup();
|
vdp_setup();
|
||||||
setup_graphics();
|
setup_graphics();
|
||||||
clrscr();
|
clrscr();
|
||||||
|
starfield_setup();
|
||||||
cv_set_vint_handler(&vint_handler);
|
cv_set_vint_handler(&vint_handler);
|
||||||
cv_set_screen_active(true);
|
cv_set_screen_active(true);
|
||||||
play_round();
|
play_round();
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
//#link "common.c"
|
//#link "common.c"
|
||||||
|
|
||||||
|
#ifdef CV_SMS
|
||||||
|
//#link "fonts.s"
|
||||||
|
#endif
|
||||||
|
|
||||||
////////// GAME DATA
|
////////// GAME DATA
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -1,81 +1,56 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <cv.h>
|
#include <cv.h>
|
||||||
#include <cvu.h>
|
#include <cvu.h>
|
||||||
|
|
||||||
#define PATTERN ((const cv_vmemp)0x0000)
|
#include "common.h"
|
||||||
#define COLOR ((const cv_vmemp)0x2000)
|
|
||||||
#define IMAGE ((const cv_vmemp)0x1c00)
|
|
||||||
|
|
||||||
volatile bool vint;
|
char starfield_base_char = 240;
|
||||||
volatile uint_fast8_t vint_counter;
|
|
||||||
uint_fast8_t oldcounter;
|
|
||||||
|
|
||||||
void vint_handler(void)
|
const char star_yoffsets[32] = {
|
||||||
{
|
31, 11, 25, 10, 21, 1, 9, 6,
|
||||||
vint = true;
|
22, 3, 7, 14, 15, 18, 0, 29,
|
||||||
vint_counter++;
|
30, 5, 16, 28, 20, 12, 24, 17,
|
||||||
|
13, 8, 26, 19, 23, 27, 2, 4
|
||||||
|
};
|
||||||
|
|
||||||
|
byte starfield_get_tile_xy(byte x, byte y) {
|
||||||
|
return ((star_yoffsets[x] + y) & 15) + starfield_base_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_stars(void)
|
void starfield_setup() {
|
||||||
{
|
for (byte x=0; x<32; x++) {
|
||||||
uint_fast8_t j;
|
for (byte y=0; y<28; y++) {
|
||||||
uint_fast8_t tmp = vint_counter;
|
putchar(x, y, starfield_get_tile_xy(x, y));
|
||||||
tmp %= (16 * 8);
|
}
|
||||||
|
cvu_voutb(COLOR_FG(CV_COLOR_WHITE),
|
||||||
for(j = 0; j < 3; j++)
|
COLOR+((starfield_base_char+x)>>3));
|
||||||
{
|
}
|
||||||
cvu_voutb(0x00, PATTERN + j * 256 * 8 + oldcounter);
|
|
||||||
cvu_voutb(0x10, PATTERN + j * 256 * 8 + tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
oldcounter = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_stars(void)
|
void starfield_update() {
|
||||||
{
|
static byte oldcounter;
|
||||||
uint_fast8_t i, j, r;
|
const byte mask = 0x7f; // 128 star bytes
|
||||||
|
byte counter = vint_counter;
|
||||||
for(j = 0; j < 32; j += rand() % 2)
|
word base = PATTERN + starfield_base_char * 8;
|
||||||
{
|
// erase old star, create new star in pattern table
|
||||||
r = rand() % 16;
|
cvu_voutb(0, base + (oldcounter & mask));
|
||||||
for(i = 0; i < 24; i++)
|
cvu_voutb(8, base + (counter & mask));
|
||||||
{
|
oldcounter = counter;
|
||||||
cvu_voutb(r++, IMAGE + j + i * 32);
|
|
||||||
r %= 16;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(j = 0; j < 3; j++)
|
|
||||||
cvu_vmemset(COLOR + j * 256 * 8, (CV_COLOR_WHITE << 4) | CV_COLOR_BLACK, 16 * 8);
|
|
||||||
|
|
||||||
cvu_voutb(0x10, PATTERN);
|
|
||||||
oldcounter = 0;
|
|
||||||
vint_counter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
#ifdef __MAIN__
|
||||||
{
|
|
||||||
cv_set_screen_active(false);
|
|
||||||
cv_set_image_table(IMAGE);
|
|
||||||
cv_set_color_table(0x3fff);
|
|
||||||
cv_set_character_pattern_t(0x1fff);
|
|
||||||
cv_set_screen_mode(CV_SCREENMODE_BITMAP);
|
|
||||||
cv_set_vint_handler(&vint_handler);
|
|
||||||
|
|
||||||
cvu_vmemset(PATTERN, 0, 8 * 256 * 3);
|
|
||||||
cvu_vmemset(COLOR, 0, 8 * 256 * 3);
|
|
||||||
cvu_vmemset(IMAGE, 0xff, 32 * 24);
|
|
||||||
|
|
||||||
init_stars();
|
//#link "common.c"
|
||||||
|
|
||||||
cv_set_screen_active(true);
|
void main() {
|
||||||
|
vdp_setup();
|
||||||
for(;;)
|
cv_set_vint_handler(&vint_handler);
|
||||||
{
|
starfield_setup();
|
||||||
while(!vint);
|
cv_set_screen_active(true);
|
||||||
update_stars();
|
while(1) {
|
||||||
vint = false;
|
wait_vsync();
|
||||||
}
|
starfield_update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
6
presets/coleco/stars.h
Normal file
6
presets/coleco/stars.h
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
extern unsigned char starfield_base_char;
|
||||||
|
extern unsigned char starfield_get_tile_xy(unsigned char x, unsigned char y);
|
||||||
|
extern void starfield_setup();
|
||||||
|
extern void starfield_update();
|
||||||
|
|
|
@ -1214,10 +1214,12 @@ function preprocessMCPP(step:BuildStep) {
|
||||||
"-D", "__8BITWORKSHOP__",
|
"-D", "__8BITWORKSHOP__",
|
||||||
"-D", "__SDCC_z80",
|
"-D", "__SDCC_z80",
|
||||||
"-D", makeCPPSafe(platform.toUpperCase()),
|
"-D", makeCPPSafe(platform.toUpperCase()),
|
||||||
"-D", "FILE__" + makeCPPSafe(step.path+""),
|
|
||||||
"-I", "/share/include",
|
"-I", "/share/include",
|
||||||
"-Q",
|
"-Q",
|
||||||
step.path, "main.i"];
|
step.path, "main.i"];
|
||||||
|
if (step.mainfile) {
|
||||||
|
args.unshift.apply(args, ["-D", "__MAIN__"]);
|
||||||
|
}
|
||||||
if (params.extra_preproc_args) {
|
if (params.extra_preproc_args) {
|
||||||
args.push.apply(args, params.extra_preproc_args);
|
args.push.apply(args, params.extra_preproc_args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user