updated presets; thinking about sprite editor

This commit is contained in:
Steven Hugg 2017-03-12 18:47:44 -04:00
parent 0828b3064e
commit ddc4550413
5 changed files with 73 additions and 26 deletions

View File

@ -173,6 +173,23 @@ canvas.pixelated {
image-rendering: pixelated; /* Awesome future-browsers */
-ms-interpolation-mode: nearest-neighbor; /* IE */
}
div.bitmap_editor {
position: fixed;
left: 2%;
width: 46%;
top: 10%;
bottom: 10%;
background-color: #333;
border-color: #fff;
border-style: ridge;
border-radius: 16px;
color: #66ff66;
white-space: pre;
padding: 20px;
z-index: 9;
font-family: "Andale Mono", "Menlo", "Lucida Console", monospace;
font-size: 12pt;
}
</style>
</head>
<body>
@ -194,7 +211,7 @@ canvas.pixelated {
<!--<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][</a></li>-->
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080 B&amp;W</a></li>
<li><a class="dropdown-item" href="?platform=vicdual" id="item_platform_vicdual">VIC Dual</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Scramble</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Galaxian/Scramble</a></li>
<li><a class="dropdown-item" href="?platform=vector-z80color" id="item_platform_vector_z80color">Atari Color Vector (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=williams" id="item_platform_williams">Williams (Z80)</a></li>
</ul>
@ -253,6 +270,14 @@ canvas.pixelated {
Making Games For The Atari 2600</a>
</div>
<div class="bitmap_editor" style="display:none">
PC: $<span id="bitmap_editor_pc">0000</span>
X: <span id="bitmap_editor_x">0</span>
Y: <span id="bitmap_editor_y">0</span>
Dest: $<span id="bitmap_editor_dest">0000/0</span>
<canvas width="32" height="32" id="bitmap_editor_canvas"/>
</div>
<script src="jquery/jquery-2.2.3.min.js"></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

View File

@ -11,16 +11,16 @@ __sfr __at (0x2) bitshift_offset;
__sfr __at (0x3) bitshift_read;
__sfr __at (0x4) bitshift_value;
__sfr __at (0x6) watchdog_strobe;
byte __at (0x2400) vidmem[0x1c00]; // 256x224x1 video memory
byte __at (0x2400) vidmem[224][32]; // 256x224x1 video memory
#define FIRE1 (input1 & 0x10)
#define LEFT1 (input1 & 0x20)
#define RIGHT1 (input1 & 0x40)
void main();
void scanline96() __interrupt;
void scanline224();
void scanline224() __interrupt;
void main();
// start routine @ 0x0
// set stack pointer, enable interrupts
void start() {
@ -48,24 +48,26 @@ __endasm;
// scanline 224 interrupt @ 0x10
// this one, we make an interrupt so it saves regs.
void RST_10() __interrupt {
scanline224();
void scanline224() __interrupt {
vidmem[2]++;
}
// scanline 96 function, saves regs
void scanline96() __interrupt {
}
// scanline 224 function, regs already saved
void scanline224() {
vidmem[0]++;
}
/// GRAPHICS FUNCTIONS
/*
void draw_hline(byte y, byte x1, byte x2) {
}
*/
void draw_vline(byte x, byte y1, byte y2) {
byte yb1 = y1/8;
byte yb2 = y2/8;
byte* dest = &vidmem[x*32+yb1];
byte* dest = &vidmem[x][yb1];
signed char nbytes = yb2 - yb1;
*dest++ ^= 0xff << (y1&7);
if (nbytes > 0) {
@ -103,7 +105,7 @@ const byte enemy1_bitmap[] =
void draw_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte* dest = &vidmem[y+x*32];
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
@ -117,7 +119,7 @@ void draw_sprite(const byte* src, byte x, byte y) {
byte xor_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte result = 0;
byte* dest = &vidmem[y+x*32];
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
@ -131,7 +133,7 @@ byte xor_sprite(const byte* src, byte x, byte y) {
void erase_sprite(const byte* src, byte x, byte y) {
byte i,j;
byte* dest = &vidmem[y+x*32];
byte* dest = &vidmem[x][y];
byte w = *src++;
byte h = *src++;
for (j=0; j<h; j++) {
@ -144,10 +146,9 @@ void erase_sprite(const byte* src, byte x, byte y) {
void draw_char(char ch, byte x, byte y) {
byte i;
byte* dest = &vidmem[y+x*32*8];
const byte* src = &font8x8[(ch-LOCHAR)][0];
byte* dest = &vidmem[x*8][y];
for (i=0; i<8; i++) {
//dest[i*32] ^= src[i];
*dest ^= *src;
dest += 32;
src += 1;
@ -254,17 +255,17 @@ void draw_bunker(byte x, byte y, byte y2, byte h, byte w) {
}
}
char in_rect(Entity* e, byte x, byte y) {
byte h = e->shape[0];
byte w = e->shape[1];
return (x >= e->x && x <= e->x+w && y >= e->y && y <= e->y+h);
char in_rect(Entity* e, byte x, byte y, byte w, byte h) {
byte eh = e->shape[0];
byte ew = e->shape[1];
return (x >= e->x-w && x <= e->x+ew && y >= e->y-h && y <= e->y+eh);
}
Entity* find_entity_at(byte x, byte y) {
byte i;
for (i=0; i<num_entities; i++) {
Entity* e = &entities[i];
if (in_rect(e, x, y)) {
if (in_rect(e, x, y, 2, 0)) {
return e;
}
}
@ -280,8 +281,6 @@ void check_bullet_hit(byte x, byte y) {
void gameloop() {
watchdog_strobe = 0b0111 / 14;
//draw_char('S',0,50);
//draw_string("HELLO WORLD", 6, 16);
draw_bunker(30, 40, 15, 15, 20);
draw_bunker(120, 40, 15, 15, 20);
draw_sprite(enemy1_bitmap, 10, 20);

View File

@ -1,6 +1,9 @@
"use strict";
var GALAXIAN_PRESETS = [
{id:'minimal.c', name:'Minimal Example'},
{id:'hello.c', name:'Hello World'},
{id:'gfxtest.c', name:'Graphics Test'},
];
var GALAXIAN_KEYCODE_MAP = makeKeycodeMap([

View File

@ -29,6 +29,7 @@ var VicDualPlatform = function(mainElement) {
var timerFrequency = 500; // TODO
var reset_disable = false;
var reset_disable_timer;
var framestats;
var palette = [
0xff000000, // black
@ -70,6 +71,9 @@ var VicDualPlatform = function(mainElement) {
for (var i=0; i<8; i++) {
var bm = 128>>i;
pixels[outi] = (data&bm) ? color2 : color1;
if (framestats) {
framestats.layers.tiles[outi] = (data&bm) ? colorprom[col+8] : colorprom[col];
}
outi++;
}
}
@ -203,7 +207,13 @@ var VicDualPlatform = function(mainElement) {
if (!this.getDebugCallback()) cpu.setTstates(0); // TODO?
}
this.readAddress = function(addr) {
return membus.read(addr); // TODO?
return membus.read(addr & 0xffff); // TODO?
}
this.setFrameStats = function(on) {
framestats = on ? {
palette: palette,
layers: {width:256, height:224, tiles:[]}
} : null;
}
}

View File

@ -192,7 +192,11 @@ function loadFile(fileid, filename, index) {
$.get( filename, function( text ) {
console.log("GET",text.length,'bytes');
loadCode(text, fileid);
}, 'text');
}, 'text')
.fail(function() {
alert("Could not load preset " + fileid);
loadCode("", fileid);
});
}
} else {
var ext = platform.getToolForFilename(fileid);
@ -201,7 +205,7 @@ function loadFile(fileid, filename, index) {
updatePreset(fileid, text);
}, 'text')
.fail(function() {
console.log("Could not load skeleton for " + platform_id + "/" + ext);
alert("Could not load skeleton for " + platform_id + "/" + ext);
loadCode("", fileid);
});
}
@ -925,6 +929,11 @@ function showWelcomeMessage() {
///////////////////////////////////////////////////
function setupBitmapEditor() {
}
///////////////////////////////////////////////////
var qs = (function (a) {
if (!a || a == "")
return {};
@ -957,6 +966,7 @@ function startPlatform() {
// start platform and load file
preloadWorker(qs['file']);
setupDebugControls();
setupBitmapEditor();
platform.start();
loadPreset(qs['file']);
updateSelector();