vic dual snake.c, gfxtest.c

This commit is contained in:
Steven Hugg 2017-02-20 18:50:29 -05:00
parent ad36052afb
commit f04afc3810
10 changed files with 718 additions and 38 deletions

View File

@ -383,6 +383,8 @@ span.CodeMirror-selectedtext { background: none; }
.cm-s-mbo span.cm-error { border-bottom: #636363; color: #ffffec; }
.cm-s-mbo span.cm-qualifier { color: #ffffec; }
.cm-s-mbo span.cm-meta { color: #aaddaa; }
.cm-s-mbo .CodeMirror-activeline-background { background: #494b41; }
.cm-s-mbo .CodeMirror-matchingbracket { color: #33ff33 !important; }
.cm-s-mbo .CodeMirror-matchingtag { background: rgba(255, 255, 255, .37); }

104
presets/vicdual/gfxtest.c Normal file

File diff suppressed because one or more lines are too long

81
presets/vicdual/hello.c Normal file

File diff suppressed because one or more lines are too long

35
presets/vicdual/minimal.c Normal file
View File

@ -0,0 +1,35 @@
#include <string.h>
typedef unsigned char byte;
typedef unsigned short word;
__sfr __at (0x40) palette;
byte __at (0xe000) cellram[32][32];
byte __at (0xe800) tileram[256][8];
void main();
void start() {
__asm
LD SP,#0xE800 ; set up stack pointer
DI ; disable interrupts
__endasm;
main();
}
#if start != 0x0
#error start() function must be at address 0x0!
#endif
void main() {
byte x,y;
palette = 1;
memset(tileram, 0xfe, sizeof(tileram));
for (y=0; y<32; y++) {
for (x=0; x<32; x++) {
cellram[x][y] = y*8;
}
}
while (1) ;
}

428
presets/vicdual/snake.c Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -51,7 +51,7 @@ var RasterVideo = function(mainElement, width, height, options) {
datau32 = new Uint32Array(buf);
}
// TODO: make common
// TODO: common function (canvas)
this.setKeyboardEvents = function(callback) {
canvas.onkeydown = function(e) {
callback(e.which, 0, 1|_metakeyflags(e));
@ -62,7 +62,7 @@ var RasterVideo = function(mainElement, width, height, options) {
canvas.onkeypress = function(e) {
callback(e.which, e.charCode, 1|_metakeyflags(e));
};
}
};
this.getFrameData = function() {
return datau32;
@ -136,6 +136,7 @@ var VectorVideo = function(mainElement, width, height) {
ctx = canvas.getContext('2d');
}
// TODO: common function (canvas)
this.setKeyboardEvents = function(callback) {
canvas.onkeydown = function(e) {
callback(e.which, 0, 1|_metakeyflags(e));
@ -146,7 +147,7 @@ var VectorVideo = function(mainElement, width, height) {
canvas.onkeypress = function(e) {
callback(e.which, e.charCode, 1|_metakeyflags(e));
};
}
};
this.clear = function() {
ctx.globalCompositeOperation = 'source-over';

View File

@ -1,7 +1,11 @@
"use strict";
var VICDUAL_PRESETS = [
{id:'soundtest.c', name:'Sound Tester'},
{id:'minimal.c', name:'Minimal Example'},
{id:'hello.c', name:'Hello World'},
{id:'gfxtest.c', name:'Graphics Test'},
{id:'soundtest.c', name:'Sound Test'},
{id:'snake.c', name:'Snake Game'},
];
var VicDualPlatform = function(mainElement) {
@ -10,7 +14,7 @@ var VicDualPlatform = function(mainElement) {
var cpu, ram, membus, iobus, rom;
var video, audio, psg, timer, pixels;
var inputs = [0xff, 0xff, 0xff, 0xff]; // most things active low
var inputs = [0xff, 0xff, 0xff, 0xff^0x8]; // most things active low
var palbank = 0;
var XTAL = 15468000.0;
@ -22,6 +26,8 @@ var VicDualPlatform = function(mainElement) {
var vsyncFrequency = hsyncFrequency/0x148;
var cpuCyclesPerLine = cpuFrequency/hsyncFrequency;
var timerFrequency = 500; // TODO
var reset_disable = false;
var reset_disable_timer;
var palette = [
0xff000000, // black
@ -119,7 +125,11 @@ var VicDualPlatform = function(mainElement) {
var idata = video.getFrameData();
setKeyboardFromMap(video, inputs, CARNIVAL_KEYCODE_MAP, function(o) {
// reset when coin inserted
if (o.index==3 && o.mask==0x8) cpu.reset();
if (o.index==3 && o.mask==0x8 && !reset_disable) cpu.reset();
// don't allow repeated resets in short period of time
reset_disable = true;
clearTimeout(reset_disable_timer);
reset_disable_timer = setTimeout(function() { reset_disable = false; }, 1100);
});
pixels = video.getFrameData();
timer = new AnimationTimer(60, function() {

View File

@ -134,12 +134,17 @@ function newEditor(mode) {
lineNumbers: true,
matchBrackets: true,
tabSize: 8,
indentAuto: true,
gutters: isAsm ? ["CodeMirror-linenumbers", "gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"]
: ["CodeMirror-linenumbers", "gutter-offset", "gutter-info"],
});
var timer;
editor.on('changes', function(ed, changeobj) {
var text = editor.getValue() || "";
setCode(text);
clearTimeout(timer);
timer = setTimeout(function() {
var text = editor.getValue() || "";
setCode(text);
}, 200);
});
editor.setOption("mode", mode);
}
@ -376,8 +381,11 @@ worker.onmessage = function(e) {
if (e.data.errors.length > 0) {
toolbar.addClass("has-errors");
editor.clearGutter("gutter-info");
var numLines = editor.lineCount();
for (info of e.data.errors) {
addErrorMarker(info.line-1, info.msg);
var line = info.line-1;
if (line < 0 || line >= numLines) line = numLines-1;
addErrorMarker(line, info.msg);
}
current_output = null;
} else {

View File

@ -108,6 +108,7 @@ function match_msvc(s) {
var errline = parseInt(matches[2]);
msvc_errors.push({
line:errline,
file:matches[1],
type:matches[3],
msg:matches[4]
});
@ -655,7 +656,8 @@ function compileSDCC(code, platform) {
//'-S', 'main.c',
//'--asm=z80asm',
'--less-pedantic',
'--fomit-frame-pointer', '--opt-code-speed',
//'--fomit-frame-pointer',
'--opt-code-speed',
'-o', 'main.asm']);
/*
// ignore if all are warnings (TODO?)
@ -665,6 +667,7 @@ function compileSDCC(code, platform) {
nwarnings++;
}
*/
// TODO: preprocessor errors w/ correct file
if (msvc_errors.length /* && nwarnings < msvc_errors.length*/) {
return {errors:msvc_errors};
}
@ -753,6 +756,7 @@ function preprocessMCPP(code, platform) {
MCPP.callMain([
"-D", "__8BITWORKSHOP__",
"-D", platform.toUpperCase().replace('-','_'),
"-D", "__SDCC_z80",
"-I", "/share/include",
"-Q",
"main.c", "main.i"]);