mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-23 03:29:39 +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 BGCOL CV_COLOR_BLUE
|
||||
|
||||
#define CH_BORDER 64
|
||||
#define CH_FLOOR 65
|
||||
#define CH_LADDER 66
|
||||
|
||||
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,0xBF,0xBF,0x00,0xFF,0xFB,0xFB,0x00},
|
||||
{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] = {
|
||||
/*{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,
|
||||
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 {
|
||||
byte ypos;
|
||||
byte height; // TODO: why does bitmask not work?
|
||||
|
@ -41,7 +41,6 @@ extern char font_bitmap_0[];
|
||||
|
||||
#define wait_vsync() __asm__("halt")
|
||||
|
||||
extern volatile bool vint;
|
||||
extern volatile uint_fast8_t vint_counter;
|
||||
|
||||
extern void vint_handler(void);
|
||||
|
@ -7,18 +7,25 @@
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
#include "stars.h"
|
||||
//#link "stars.c"
|
||||
|
||||
#ifdef CV_SMS
|
||||
//#link "fonts.s"
|
||||
#endif
|
||||
|
||||
#define NSPRITES 16
|
||||
#define NMISSILES 8
|
||||
#define YOFFSCREEN 239
|
||||
|
||||
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,
|
||||
0x0C, 0x13, 0x02, 0x0F, 0x33, 0x05, 0x08, 0x30,
|
||||
};
|
||||
|
||||
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,
|
||||
0x03, 0x86, 0xCD, 0xBE, 0x9F, 0xB1, 0xC0, 0x80,
|
||||
@ -205,30 +212,28 @@ void setup_formation() {
|
||||
#define BLANK 0
|
||||
|
||||
void draw_row(byte row) {
|
||||
byte i;
|
||||
byte i,j;
|
||||
byte x = formation_offset_x / 8;
|
||||
byte xd = (formation_offset_x & 7) * 3;
|
||||
byte y = 3 + row * 2;
|
||||
//vcolumns[y].attrib = 0x2;
|
||||
//vcolumns[y].scroll = formation_offset_x;
|
||||
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++) {
|
||||
byte shape = formation[i + row*ENEMIES_PER_ROW].shape;
|
||||
if (shape) {
|
||||
shape += xd;
|
||||
putchar(x, y, shape);
|
||||
putchar(x+1, y, shape+1);
|
||||
putchar(x+2, y, shape+2);
|
||||
for (j=0; j<3; j++) {
|
||||
putchar(x++, y, shape++);
|
||||
}
|
||||
} else {
|
||||
putchar(x, y, BLANK);
|
||||
putchar(x+1, y, BLANK);
|
||||
putchar(x+2, y, BLANK);
|
||||
for (j=0; j<3; j++) {
|
||||
putchar(x, y, starfield_get_tile_xy(x,y));
|
||||
x++;
|
||||
}
|
||||
}
|
||||
x += 3;
|
||||
}
|
||||
for (; x<COLS; x++)
|
||||
putchar(x, y, BLANK);
|
||||
putchar(x, y, starfield_get_tile_xy(x,y));
|
||||
}
|
||||
|
||||
void draw_next_row() {
|
||||
@ -620,6 +625,7 @@ void play_round() {
|
||||
if (!enemies_left) end_timer--;
|
||||
wait_for_frame();
|
||||
copy_sprites();
|
||||
starfield_update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,6 +649,7 @@ void main() {
|
||||
vdp_setup();
|
||||
setup_graphics();
|
||||
clrscr();
|
||||
starfield_setup();
|
||||
cv_set_vint_handler(&vint_handler);
|
||||
cv_set_screen_active(true);
|
||||
play_round();
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include "common.h"
|
||||
//#link "common.c"
|
||||
|
||||
#ifdef CV_SMS
|
||||
//#link "fonts.s"
|
||||
#endif
|
||||
|
||||
////////// GAME DATA
|
||||
|
||||
typedef struct {
|
||||
|
@ -1,81 +1,56 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cv.h>
|
||||
#include <cvu.h>
|
||||
|
||||
#define PATTERN ((const cv_vmemp)0x0000)
|
||||
#define COLOR ((const cv_vmemp)0x2000)
|
||||
#define IMAGE ((const cv_vmemp)0x1c00)
|
||||
#include "common.h"
|
||||
|
||||
volatile bool vint;
|
||||
volatile uint_fast8_t vint_counter;
|
||||
uint_fast8_t oldcounter;
|
||||
char starfield_base_char = 240;
|
||||
|
||||
void vint_handler(void)
|
||||
{
|
||||
vint = true;
|
||||
vint_counter++;
|
||||
const char star_yoffsets[32] = {
|
||||
31, 11, 25, 10, 21, 1, 9, 6,
|
||||
22, 3, 7, 14, 15, 18, 0, 29,
|
||||
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)
|
||||
{
|
||||
uint_fast8_t j;
|
||||
uint_fast8_t tmp = vint_counter;
|
||||
tmp %= (16 * 8);
|
||||
|
||||
for(j = 0; j < 3; j++)
|
||||
{
|
||||
cvu_voutb(0x00, PATTERN + j * 256 * 8 + oldcounter);
|
||||
cvu_voutb(0x10, PATTERN + j * 256 * 8 + tmp);
|
||||
}
|
||||
|
||||
oldcounter = tmp;
|
||||
void starfield_setup() {
|
||||
for (byte x=0; x<32; x++) {
|
||||
for (byte y=0; y<28; y++) {
|
||||
putchar(x, y, starfield_get_tile_xy(x, y));
|
||||
}
|
||||
cvu_voutb(COLOR_FG(CV_COLOR_WHITE),
|
||||
COLOR+((starfield_base_char+x)>>3));
|
||||
}
|
||||
}
|
||||
|
||||
void init_stars(void)
|
||||
{
|
||||
uint_fast8_t i, j, r;
|
||||
|
||||
for(j = 0; j < 32; j += rand() % 2)
|
||||
{
|
||||
r = rand() % 16;
|
||||
for(i = 0; i < 24; i++)
|
||||
{
|
||||
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 starfield_update() {
|
||||
static byte oldcounter;
|
||||
const byte mask = 0x7f; // 128 star bytes
|
||||
byte counter = vint_counter;
|
||||
word base = PATTERN + starfield_base_char * 8;
|
||||
// erase old star, create new star in pattern table
|
||||
cvu_voutb(0, base + (oldcounter & mask));
|
||||
cvu_voutb(8, base + (counter & mask));
|
||||
oldcounter = counter;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
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);
|
||||
#ifdef __MAIN__
|
||||
|
||||
cvu_vmemset(PATTERN, 0, 8 * 256 * 3);
|
||||
cvu_vmemset(COLOR, 0, 8 * 256 * 3);
|
||||
cvu_vmemset(IMAGE, 0xff, 32 * 24);
|
||||
//#link "common.c"
|
||||
|
||||
init_stars();
|
||||
|
||||
cv_set_screen_active(true);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
while(!vint);
|
||||
update_stars();
|
||||
vint = false;
|
||||
}
|
||||
void main() {
|
||||
vdp_setup();
|
||||
cv_set_vint_handler(&vint_handler);
|
||||
starfield_setup();
|
||||
cv_set_screen_active(true);
|
||||
while(1) {
|
||||
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", "__SDCC_z80",
|
||||
"-D", makeCPPSafe(platform.toUpperCase()),
|
||||
"-D", "FILE__" + makeCPPSafe(step.path+""),
|
||||
"-I", "/share/include",
|
||||
"-Q",
|
||||
step.path, "main.i"];
|
||||
if (step.mainfile) {
|
||||
args.unshift.apply(args, ["-D", "__MAIN__"]);
|
||||
}
|
||||
if (params.extra_preproc_args) {
|
||||
args.push.apply(args, params.extra_preproc_args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user