added skeleton files

This commit is contained in:
Steven Hugg 2017-04-19 14:26:46 -04:00
parent 89c3209f09
commit 1ca9d50801
10 changed files with 508 additions and 7 deletions

View File

@ -5,8 +5,11 @@ check:
lint:
gjslint -r src
# https://github.com/Kentzo/git-archive-all
archive:
mkdir -p release
git-archive-all --prefix 8bitworkshop-1.1/ release/8bitworkshop-1.1.tgz
#git archive --output release/8bitworkshop-1.1.tgz --prefix 8bitworkshop-1.1/ 1.1
git-archive-all --prefix 8bitworkshop-2.0/ release/8bitworkshop-2.0.zip # 2.0
#git-archive-all --prefix 8bitworkshop-1.1/ release/8bitworkshop-1.1.zip 1.1
git archive --prefix 8bitworkshop- -o release/8bitworkshop-tools.zip HEAD tools

View File

@ -0,0 +1,177 @@
#include <string.h>
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
volatile __sfr __at (0x0) input0;
volatile __sfr __at (0x1) input1;
volatile __sfr __at (0x2) input2;
__sfr __at (0x2) bitshift_offset;
volatile __sfr __at (0x3) bitshift_read;
__sfr __at (0x4) bitshift_value;
__sfr __at (0x6) watchdog_strobe;
byte __at (0x2400) vidmem[224][32]; // 256x224x1 video memory
#define FIRE1 (input1 & 0x10)
#define LEFT1 (input1 & 0x20)
#define RIGHT1 (input1 & 0x40)
#define COIN1 (input1 & 0x1)
#define START1 (input1 & 0x4)
#define START2 (input1 & 0x2)
void scanline96() __interrupt;
void scanline224() __interrupt;
void main();
// start routine @ 0x0
// set stack pointer, enable interrupts
void start() {
__asm
LD SP,#0x2400
EI
NOP
__endasm;
main();
}
// scanline 96 interrupt @ 0x8
// we don't have enough bytes to make this an interrupt
// because the next routine is at 0x10
void _RST_8() {
__asm
NOP
NOP
NOP
NOP
NOP
__endasm;
scanline96();
}
// scanline 224 interrupt @ 0x10
// this one, we make an interrupt so it saves regs.
void scanline224() __interrupt {
vidmem[2]++;
}
// scanline 96 function, saves regs
void scanline96() __interrupt {
vidmem[0]++;
}
/// GRAPHICS FUNCTIONS
void clrscr() {
memset(vidmem, 0, sizeof(vidmem));
}
inline void xor_pixel(byte x, byte y) {
byte* dest = &vidmem[x][y>>3];
*dest ^= 0x1 << (y&7);
}
void draw_vline(byte x, byte y1, byte y2) {
byte yb1 = y1/8;
byte yb2 = y2/8;
byte* dest = &vidmem[x][yb1];
signed char nbytes = yb2 - yb1;
*dest++ ^= 0xff << (y1&7);
if (nbytes > 0) {
while (--nbytes > 0) {
*dest++ ^= 0xff;
}
*dest ^= 0xff >> (~y2&7);
} else {
*--dest ^= 0xff << ((y2+1)&7);
}
}
#define LOCHAR 0x20
#define HICHAR 0x5e
const byte font8x8[HICHAR-LOCHAR+1][8] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x79,0x79,0x00,0x00,0x00 }, { 0x00,0x70,0x70,0x00,0x00,0x70,0x70,0x00 }, { 0x14,0x7f,0x7f,0x14,0x14,0x7f,0x7f,0x14 }, { 0x00,0x12,0x3a,0x6b,0x6b,0x2e,0x24,0x00 }, { 0x00,0x63,0x66,0x0c,0x18,0x33,0x63,0x00 }, { 0x00,0x26,0x7f,0x59,0x59,0x77,0x27,0x05 }, { 0x00,0x00,0x00,0x10,0x30,0x60,0x40,0x00 }, { 0x00,0x00,0x1c,0x3e,0x63,0x41,0x00,0x00 }, { 0x00,0x00,0x41,0x63,0x3e,0x1c,0x00,0x00 }, { 0x08,0x2a,0x3e,0x1c,0x1c,0x3e,0x2a,0x08 }, { 0x00,0x08,0x08,0x3e,0x3e,0x08,0x08,0x00 }, { 0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00 }, { 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00 }, { 0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00 }, { 0x00,0x01,0x03,0x06,0x0c,0x18,0x30,0x20 }, { 0x00,0x3e,0x7f,0x49,0x51,0x7f,0x3e,0x00 }, { 0x00,0x01,0x11,0x7f,0x7f,0x01,0x01,0x00 }, { 0x00,0x23,0x67,0x45,0x49,0x79,0x31,0x00 }, { 0x00,0x22,0x63,0x49,0x49,0x7f,0x36,0x00 }, { 0x00,0x0c,0x0c,0x14,0x34,0x7f,0x7f,0x04 }, { 0x00,0x72,0x73,0x51,0x51,0x5f,0x4e,0x00 }, { 0x00,0x3e,0x7f,0x49,0x49,0x6f,0x26,0x00 }, { 0x00,0x60,0x60,0x4f,0x5f,0x70,0x60,0x00 }, { 0x00,0x36,0x7f,0x49,0x49,0x7f,0x36,0x00 }, { 0x00,0x32,0x7b,0x49,0x49,0x7f,0x3e,0x00 }, { 0x00,0x00,0x00,0x12,0x12,0x00,0x00,0x00 }, { 0x00,0x00,0x00,0x13,0x13,0x00,0x00,0x00 }, { 0x00,0x08,0x1c,0x36,0x63,0x41,0x41,0x00 }, { 0x00,0x14,0x14,0x14,0x14,0x14,0x14,0x00 }, { 0x00,0x41,0x41,0x63,0x36,0x1c,0x08,0x00 }, { 0x00,0x20,0x60,0x45,0x4d,0x78,0x30,0x00 }, { 0x00,0x3e,0x7f,0x41,0x59,0x79,0x3a,0x00 }, { 0x00,0x1f,0x3f,0x68,0x68,0x3f,0x1f,0x00 }, { 0x00,0x7f,0x7f,0x49,0x49,0x7f,0x36,0x00 }, { 0x00,0x3e,0x7f,0x41,0x41,0x63,0x22,0x00 }, { 0x00,0x7f,0x7f,0x41,0x63,0x3e,0x1c,0x00 }, { 0x00,0x7f,0x7f,0x49,0x49,0x41,0x41,0x00 }, { 0x00,0x7f,0x7f,0x48,0x48,0x40,0x40,0x00 }, { 0x00,0x3e,0x7f,0x41,0x49,0x6f,0x2e,0x00 }, { 0x00,0x7f,0x7f,0x08,0x08,0x7f,0x7f,0x00 }, { 0x00,0x00,0x41,0x7f,0x7f,0x41,0x00,0x00 }, { 0x00,0x02,0x03,0x41,0x7f,0x7e,0x40,0x00 }, { 0x00,0x7f,0x7f,0x1c,0x36,0x63,0x41,0x00 }, { 0x00,0x7f,0x7f,0x01,0x01,0x01,0x01,0x00 }, { 0x00,0x7f,0x7f,0x30,0x18,0x30,0x7f,0x7f }, { 0x00,0x7f,0x7f,0x38,0x1c,0x7f,0x7f,0x00 }, { 0x00,0x3e,0x7f,0x41,0x41,0x7f,0x3e,0x00 }, { 0x00,0x7f,0x7f,0x48,0x48,0x78,0x30,0x00 }, { 0x00,0x3c,0x7e,0x42,0x43,0x7f,0x3d,0x00 }, { 0x00,0x7f,0x7f,0x4c,0x4e,0x7b,0x31,0x00 }, { 0x00,0x32,0x7b,0x49,0x49,0x6f,0x26,0x00 }, { 0x00,0x40,0x40,0x7f,0x7f,0x40,0x40,0x00 }, { 0x00,0x7e,0x7f,0x01,0x01,0x7f,0x7e,0x00 }, { 0x00,0x7c,0x7e,0x03,0x03,0x7e,0x7c,0x00 }, { 0x00,0x7f,0x7f,0x06,0x0c,0x06,0x7f,0x7f }, { 0x00,0x63,0x77,0x1c,0x1c,0x77,0x63,0x00 }, { 0x00,0x70,0x78,0x0f,0x0f,0x78,0x70,0x00 }, { 0x00,0x43,0x47,0x4d,0x59,0x71,0x61,0x00 }, { 0x00,0x00,0x7f,0x7f,0x41,0x41,0x00,0x00 }, { 0x00,0x20,0x30,0x18,0x0c,0x06,0x03,0x01 }, { 0x00,0x00,0x41,0x41,0x7f,0x7f,0x00,0x00 }, { 0x00,0x08,0x18,0x3f,0x3f,0x18,0x08,0x00 }
};
void draw_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
for (i=0; i<w; i++) {
*dest++ = *src++;
}
dest += 32-w;
}
}
byte xor_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte result = 0;
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
for (i=0; i<w; i++) {
result |= (*dest++ ^= *src++);
}
dest += 32-w;
}
return result;
}
void erase_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
for (i=0; i<w; i++) {
*dest++ &= ~(*src++);
}
dest += 32-w;
}
}
void clear_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
for (i=0; i<w; i++) {
*dest++ = 0;
}
dest += 32-w;
}
}
void draw_char(char ch, byte x, byte y) {
byte i;
const byte* src = &font8x8[(ch-LOCHAR)][0];
byte* dest = &vidmem[x*8][y];
for (i=0; i<8; i++) {
*dest = *src;
dest += 32;
src += 1;
}
}
void draw_string(const char* str, byte x, byte y) {
do {
byte ch = *str++;
if (!ch) break;
draw_char(ch, x, y);
x++;
} while (1);
}
void main() {
clrscr();
draw_string("HELLO WORLD", 1, 1);
while(1) ;
}

View File

@ -0,0 +1,135 @@
#include <string.h>
#include <malloc.h>
typedef unsigned char byte;
typedef unsigned short word;
typedef signed char sbyte;
word __at(0xa000) dvgram[0x1000];
byte __at(0x8840) _dvgstart;
volatile int __at(0x8100) mathbox_sum;
sbyte __at(0x8102) mathbox_arg1;
sbyte __at(0x8103) mathbox_arg2;
byte __at(0x810f) mathbox_go_mul;
volatile byte __at (0x8000) input0;
volatile byte __at (0x8001) input1;
volatile byte __at (0x8002) input2;
volatile byte __at (0x800f) vidframe;
byte __at (0x8980) watchdog;
#define LEFT1 !(input1 & 0x8)
#define RIGHT1 !(input1 & 0x4)
#define UP1 !(input1 & 0x10)
#define DOWN1 !(input1 & 0x20)
#define FIRE1 !(input1 & 0x2)
#define BOMB1 !(input1 & 0x1)
#define COIN1 (input0 & 0x2)
#define COIN2 (input0 & 0x1)
#define START1 (input2 & 0x20)
#define START2 (input2 & 0x40)
//
void main();
void _sdcc_heap_init(void); // for malloc()
void start() {
__asm
LD SP,#0x0
DI
; copy initialized data
LD BC, #l__INITIALIZER
LD A, B
LD DE, #s__INITIALIZED
LD HL, #s__INITIALIZER
LDIR
__endasm;
// init heap for malloc() and run main pgm.
_sdcc_heap_init();
main();
}
// VECTOR ROUTINES
int dvgwrofs; // write offset for DVG buffer
inline word ___swapw(word j) {
return ((j << 8) | (j >> 8));
}
inline void dvgreset() {
dvgwrofs = 0;
}
inline void dvgstart() {
_dvgstart = 0;
}
void dvgwrite(word w) {
dvgram[dvgwrofs++] = w;
}
inline void VCTR(int dx, int dy, byte bright) {
dvgwrite((dy & 0x1fff));
dvgwrite(((bright & 7) << 13) | (dx & 0x1fff));
}
inline void SVEC(signed char dx, signed char dy, byte bright) {
dvgwrite(0x4000 | (dx & 0x1f) | ((bright&7)<<5) | ((dy & 0x1f)<<8));
}
inline void JSRL(word offset) {
dvgwrite(0xa000 | offset);
}
inline void JMPL(word offset) {
dvgwrite(0xe000 | offset);
}
inline void RTSL() {
dvgwrite(0xc000);
}
inline void CNTR() {
dvgwrite(0x8000);
}
inline void HALT() {
dvgwrite(0x2000);
}
inline void STAT(byte rgb, byte intens) {
dvgwrite(0x6000 | ((intens & 0xf)<<4) | (rgb & 7));
}
inline void STAT_sparkle(byte intens) {
dvgwrite(0x6800 | ((intens & 0xf)<<4));
}
inline void SCAL(word scale) {
dvgwrite(0x7000 | scale);
}
enum {
BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE
} Color;
void main() {
memset(dvgram, 0x20, sizeof(dvgram)); // HALTs
while (1) {
dvgreset();
CNTR();
VCTR(100,0,1);
VCTR(0,100,2);
VCTR(-100,0,3);
VCTR(0,-100,4);
CNTR();
HALT();
dvgstart();
watchdog=0;
}
main();
}

View File

@ -25,7 +25,7 @@ byte __at (0xe800) tileram[256][8];
#define COIN1 (input3 & 0x8)
#define START1 !(input2 & 0x10)
#define START2 !(input3 & 0x20)
#define VSYNC (input1 & 0x8)
#define TIMER500HZ (input2 & 0x8)
inline void set8910(byte reg, byte data) {
ay8910_reg = reg;

View File

@ -0,0 +1,162 @@
#include <string.h>
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
typedef enum { false, true } bool;
byte __at (0x0) vidmem[152][256]; // 304x256x4bpp video memory
byte __at (0xc000) palette[16];
volatile byte __at (0xc804) input0;
volatile byte __at (0xc806) input1;
volatile byte __at (0xc80c) input2;
byte __at (0xc80c) sound_pia;
byte __at (0xc900) rom_select;
volatile byte __at (0xcb00) video_counter;
byte __at (0xcbff) watchdog0x39;
byte __at (0xcc00) nvram[0x400];
__sfr __at (0) debug;
// blitter flags
#define SRCSCREEN 0x1
#define DSTSCREEN 0x2
#define ESYNC 0x4
#define FGONLY 0x8
#define SOLID 0x10
#define RSHIFT 0x20
#define EVENONLY 0x40
#define ODDONLY 0x80
struct {
byte flags;
byte solid;
word sstart;
word dstart;
byte width;
byte height;
} __at (0xca00) blitter;
// switch flags
#define UP1 (input0 & 0x1)
#define DOWN1 (input0 & 0x2)
#define LEFT1 (input0 & 0x4)
#define RIGHT1 (input0 & 0x8)
#define START1 (input0 & 0x10)
#define START2 (input0 & 0x20)
#define UP2 (input0 & 0x40)
#define DOWN2 (input0 & 0x80)
#define LEFT2 (input1 & 0x1)
#define RIGHT2 (input1 & 0x2)
#define AUTOUP (input2 & 0x1)
#define ADVANCE (input2 & 0x2)
#define COIN2 (input2 & 0x4)
#define HIGHSCORERESET (input2 & 0x8)
#define COIN1 (input2 & 0x10)
#define COIN3 (input2 & 0x20)
#define TILTSWITCH (input2 & 0x40)
#define SOUNDACK (input2 & 0x80)
#define WATCHDOG watchdog0x39=0x39;
//
void main();
void _sdcc_heap_init(void); // for malloc()
// start routine @ 0x0
// set stack pointer, enable interrupts
void start() {
__asm
LD SP,#0xc000
DI
; copy initialized data
LD BC, #l__INITIALIZER
LD A, B
LD DE, #s__INITIALIZED
LD HL, #s__INITIALIZER
LDIR
__endasm;
_sdcc_heap_init();
main();
}
inline word swapw(word j) {
return ((j << 8) | (j >> 8));
}
// x1: 0-151
// y1: 0-255
inline void blit_solid(byte x1, byte y1, byte w, byte h, byte color) {
blitter.width = w^4;
blitter.height = h^4;
blitter.dstart = x1+y1*256; // swapped
blitter.solid = color;
blitter.flags = DSTSCREEN|SOLID;
}
inline void draw_solid(word x1, byte y1, byte w, byte h, byte color) {
blitter.width = w^4;
blitter.height = h^4;
blitter.dstart = (x1>>1)+y1*256; // swapped
blitter.solid = color;
blitter.flags = (x1&1) ? DSTSCREEN|SOLID|RSHIFT : DSTSCREEN|SOLID;
}
inline void draw_vline(word x1, byte y1, byte h, byte color) {
blitter.width = 1^4;
blitter.height = h^4;
blitter.dstart = (x1>>1)+y1*256; // swapped
blitter.solid = color;
blitter.flags = (x1&1) ? DSTSCREEN|SOLID|ODDONLY : DSTSCREEN|SOLID|EVENONLY;
}
inline void blit_copy_solid(word x, byte y, byte w, byte h, const byte* data, byte solid) {
blitter.width = w^4;
blitter.height = h^4;
blitter.solid = solid;
blitter.sstart = swapw((word)data);
blitter.dstart = (x>>1)+y*256; // swapped
if (solid)
blitter.flags = (x&1) ? DSTSCREEN|FGONLY|SOLID|RSHIFT : DSTSCREEN|FGONLY|SOLID;
else
blitter.flags = (x&1) ? DSTSCREEN|RSHIFT : DSTSCREEN;
}
// bias sprites by +4 pixels
#define XBIAS 2
inline void draw_sprite(const byte* data, byte x, byte y) {
blitter.width = data[0]^4;
blitter.height = data[1]^4;
blitter.sstart = swapw((word)(data+2));
blitter.dstart = (x>>1)+y*256+XBIAS; // swapped
blitter.flags = (x&1) ? DSTSCREEN|FGONLY|RSHIFT : DSTSCREEN|FGONLY;
}
inline void draw_sprite_solid(const byte* data, byte x, byte y, byte color) {
blitter.width = data[0]^4;
blitter.height = data[1]^4;
blitter.sstart = swapw((word)(data+2));
blitter.dstart = (x>>1)+y*256+XBIAS; // swapped
blitter.solid = color;
blitter.flags = (x&1) ? DSTSCREEN|FGONLY|RSHIFT|SOLID : DSTSCREEN|FGONLY|SOLID;
}
void draw_box(word x1, byte y1, word x2, byte y2, byte color) {
draw_solid(x1, y1, (x2-x1)>>1, 1, color);
draw_solid(x1, y2, (x2-x1)>>1, 1, color);
draw_vline(x1, y1, y2-y1, color);
draw_vline(x2, y1, y2-y1, color);
}
static byte frame = 0;
void main() {
palette[0] = 0x11;
palette[1] = 0xff+frame++;
blit_solid(0,0,25,25,0x11);
main();
}

View File

@ -348,6 +348,9 @@ var Z80ColorVectorPlatform = function(mainElement, proto) {
this.start = function() {
cpuram = new RAM(0x2000);
dvgram = new RAM(0x4000);
switches[0] = 0x0;
switches[1] = 0xff;
switches[2] = 0x0;
// bus
bus = {

View File

@ -131,9 +131,29 @@ describe('Worker', function() {
it('should compile SDCC w/ include', function(done) {
compile('sdcc', '#include <string.h>\nvoid main() {\nstrlen(0);\n}\n', 'mw8080bw', done, 8192, 2, 0);
});
it('should compile big SDCC file', function(done) {
var csource = ab2str(fs.readFileSync('test/cli/test1.c'));
compile('sdcc', csource, 'vector-z80color', done, 32768, 298, 0);
it('should compile vicdual skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/vicdual/skeleton.sdcc'));
compile('sdcc', csource, 'vicdual', done, 16416, 45, 0);
});
it('should compile mw8080 skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/mw8080bw/skeleton.sdcc'));
compile('sdcc', csource, 'mw8080bw', done, 8192, 84, 0);
});
it('should compile galaxian skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/galaxian-scramble/skeleton.sdcc'));
compile('sdcc', csource, 'galaxian-scramble', done, 20512, 29, 0);
});
it('should compile vector skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/vector-z80color/skeleton.sdcc'));
compile('sdcc', csource, 'vector-z80color', done, 32768, 24, 0);
});
it('should compile williams skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/williams-z80/skeleton.sdcc'));
compile('sdcc', csource, 'williams-z80', done, 38912, 39, 0);
});
it('should compile williams_sound skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/sound_williams-z80/skeleton.sdcc'));
compile('sdcc', csource, 'sound_williams-z80', done, 16384, 6, 0);
});
it('should NOT compile SDCC', function(done) {
compile('sdcc', 'foobar', 'mw8080bw', done, 0, 0, 1);

View File

@ -6,6 +6,7 @@ parser = argparse.ArgumentParser()
parser.add_argument('-l', '--length', type=int, default=64, help="length of note table")
parser.add_argument('-u', '--upper', type=int, default=49, help="upper note # to test")
parser.add_argument('-f', '--freq', type=float, default=3579545/32.0, help="base frequency (Hz)")
parser.add_argument('-b', '--bias', type=float, default=0, help="divisor bias")
args = parser.parse_args()
test_notes = args.upper

View File

@ -1,5 +1,5 @@
all: baddies.c badspacerobots.tga tom-thumb.c
all: baddies.c badspacerobots.tga tom-thumb.c swave.c.rom.h
%.h: %
cat $* | hexdump -v -e '"\n" 128/1 "0x%02x,"' > $@

BIN
tools/williams/swave.c.rom Normal file

Binary file not shown.