mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-23 18:31:08 +00:00
updated sms i/o mask, multicolor preset
This commit is contained in:
parent
b397406f45
commit
6e41dcd6c2
@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cv.h>
|
||||
#include <cvu.h>
|
||||
@ -35,7 +35,10 @@ typedef void SetPixelFunc(byte x, byte y, byte color);
|
||||
void set_pixel(byte x, byte y, byte color) {
|
||||
word pg = (x>>1)*8 + (y & 7) + (y & ~7)*32 + PATTERN;
|
||||
byte b = cvu_vinb(pg);
|
||||
b |= (x & 1) ? color : color<<4;
|
||||
if (x&1)
|
||||
b = color | (b & 0xf0);
|
||||
else
|
||||
b = (color<<4) | (b & 0xf);
|
||||
cvu_voutb(b, pg);
|
||||
}
|
||||
|
||||
@ -45,54 +48,27 @@ void set_two_pixels(byte x, byte y, byte leftcolor, byte rightcolor) {
|
||||
cvu_voutb(b, pg);
|
||||
}
|
||||
|
||||
void draw_line(sbyte x0, sbyte y0, sbyte x1, sbyte y1, byte color)
|
||||
{
|
||||
int dx, dy, p, x, y;
|
||||
dx=x1-x0;
|
||||
dy=y1-y0;
|
||||
x=x0;
|
||||
y=y0;
|
||||
p=2*dy-dx;
|
||||
while(x<x1)
|
||||
{
|
||||
if(p>=0)
|
||||
{
|
||||
set_pixel(x,y,color);
|
||||
y=y+1;
|
||||
p=p+2*dy-2*dx;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_pixel(x,y,color);
|
||||
p=p+2*dy;
|
||||
}
|
||||
x=x+1;
|
||||
}
|
||||
void draw_line(int x0, int y0, int x1, int y1, byte color) {
|
||||
int dx = abs(x1-x0);
|
||||
int sx = x0<x1 ? 1 : -1;
|
||||
int dy = abs(y1-y0);
|
||||
int sy = y0<y1 ? 1 : -1;
|
||||
int err = (dx>dy ? dx : -dy)>>1;
|
||||
int e2;
|
||||
for(;;) {
|
||||
set_pixel(x0, y0, color);
|
||||
if (x0==x1 && y0==y1) break;
|
||||
e2 = err;
|
||||
if (e2 > -dx) { err -= dy; x0 += sx; }
|
||||
if (e2 < dy) { err += dx; y0 += sy; }
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup_multicolor();
|
||||
set_pixel(0, 0, 4);
|
||||
set_pixel(1, 0, 4);
|
||||
set_pixel(COLS-1, 0, 4);
|
||||
set_pixel(0, 1, 6);
|
||||
set_pixel(0, 2, 6);
|
||||
set_pixel(0, 3, 6);
|
||||
set_pixel(1, 4, 4);
|
||||
set_pixel(2, 6, 5);
|
||||
set_pixel(4, 7, 5);
|
||||
set_pixel(7, 7, 5);
|
||||
set_pixel(8, 8, 5);
|
||||
draw_line(0, 0, COLS-1, ROWS-1, 2);
|
||||
draw_line(COLS-1, 0, 0, ROWS-1, 3);
|
||||
cv_set_screen_active(true);
|
||||
{
|
||||
for (int y=0; y<ROWS; y++) {
|
||||
for (int x=0; x<COLS; x+=2) {
|
||||
//set_pixel(x, y, rand());
|
||||
set_two_pixels(x, y, rand(), rand());
|
||||
}
|
||||
}
|
||||
while(1) {
|
||||
draw_line(rand()%64, rand()%48, rand()%64, rand()%48, rand()&15);
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ const _SG1000Platform = function(mainElement) {
|
||||
read: function(addr) {
|
||||
addr &= 0xff;
|
||||
//console.log('IO read', hex(addr,4));
|
||||
switch (addr) {
|
||||
case 0xbe: return vdp.readData();
|
||||
case 0xbf: return vdp.readStatus();
|
||||
case 0xc0: case 0xdc: return inputs[0] ^ 0xff;
|
||||
case 0xc1: case 0xdd: return inputs[1] ^ 0xff;
|
||||
switch (addr & 0xc1) {
|
||||
case 0x80: return vdp.readData();
|
||||
case 0x81: return vdp.readStatus();
|
||||
case 0xc0: return inputs[0] ^ 0xff;
|
||||
case 0xc1: return inputs[1] ^ 0xff;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
@ -96,10 +96,11 @@ const _SG1000Platform = function(mainElement) {
|
||||
addr &= 0xff;
|
||||
val &= 0xff;
|
||||
//console.log('IO write', hex(addr,4), hex(val,2));
|
||||
switch (addr) {
|
||||
case 0xbe: return vdp.writeData(val);
|
||||
case 0xbf: return vdp.writeAddress(val);
|
||||
case 0x7e: case 0x7f: return psg.setData(val);
|
||||
switch (addr & 0xc1) {
|
||||
case 0x80: return vdp.writeData(val);
|
||||
case 0x81: return vdp.writeAddress(val);
|
||||
case 0x40:
|
||||
case 0x41: return psg.setData(val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
37
src/store.ts
37
src/store.ts
@ -30,43 +30,6 @@ var OldFileStore = function(storage, prefix:string) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// localforage-compatible driver for old file store format
|
||||
var OldFileStoreDriver = {
|
||||
_driver: 'oldFileStoreDriver',
|
||||
_initStorage: function(options) {
|
||||
this._store = new OldFileStore(localStorage, options.name + '/');
|
||||
},
|
||||
clear: function(callback) {
|
||||
// Custom implementation here...
|
||||
},
|
||||
getItem: function(key, callback) {
|
||||
callback(null, this._store.loadFile(key));
|
||||
},
|
||||
iterate: function(iteratorCallback, successCallback) {
|
||||
// Custom implementation here...
|
||||
},
|
||||
key: function(n, callback) {
|
||||
// Custom implementation here...
|
||||
},
|
||||
keys: function(callback) {
|
||||
callback(this._store.getFiles(''));
|
||||
},
|
||||
length: function(callback) {
|
||||
callback(this._store.getFiles('').length);
|
||||
},
|
||||
removeItem: function(key, callback) {
|
||||
this._store.deleteFile(key);
|
||||
callback();
|
||||
},
|
||||
setItem: function(key, value, callback) {
|
||||
this._store.saveFile(key, value);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
localforage.defineDriver(OldFileStoreDriver);
|
||||
*/
|
||||
|
||||
// copy localStorage to new driver
|
||||
function copyFromOldStorageFormat(platformid:string, newstore, conversioncallback:()=>void) {
|
||||
var alreadyMigratedKey = "__migrated_" + platformid;
|
||||
|
Loading…
Reference in New Issue
Block a user