mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-04-10 12:39:53 +00:00
working on williams sound, sprites
This commit is contained in:
parent
fdc40fc553
commit
a4c40948ea
18
index.html
18
index.html
@ -58,15 +58,11 @@ body {
|
||||
right:0;
|
||||
background-color: #666;
|
||||
}
|
||||
div.editor {
|
||||
position:absolute;
|
||||
left:0;
|
||||
top:0;
|
||||
bottom:0;
|
||||
right:0;
|
||||
width:50%;
|
||||
height:95vh;
|
||||
div.workspace {
|
||||
background-color:#999;
|
||||
}
|
||||
div.editor {
|
||||
width:50%;
|
||||
line-height:1.25;
|
||||
font-size:12pt;
|
||||
}
|
||||
@ -75,7 +71,6 @@ div.emulator {
|
||||
left:50%;
|
||||
top:0;
|
||||
width:50%;
|
||||
overflow-y: scroll;
|
||||
background-color: #666;
|
||||
margin-top: 20px auto 0;
|
||||
}
|
||||
@ -236,12 +231,11 @@ div.bitmap_editor {
|
||||
<button id="dbg_stepout" type="submit" title="Step Out of Subroutine"><span class="glyphicon glyphicon-hand-up" aria-hidden="true"></span></button>
|
||||
<button id="dbg_stepback" type="submit" title="Step Backwards"><span class="glyphicon glyphicon-step-backward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_timing" type="submit" title="See Timing" style="display:none"><span class="glyphicon glyphicon-time" aria-hidden="true"></span></button>
|
||||
<button id="dbg_disasm" type="submit" title="Toggle Disassembly" style="display:none"><span class="glyphicon glyphicon-list" aria-hidden="true"></span></button>
|
||||
<button id="dbg_disasm" type="submit" title="Show Disassembly" style="display:none"><span class="glyphicon glyphicon-list" aria-hidden="true"></span></button>
|
||||
</span>
|
||||
<span class="dbg_info" id="dbg_info"></span>
|
||||
</div>
|
||||
<div id="notebook">
|
||||
<div id="editor_window">
|
||||
<div id="workspace">
|
||||
<div id="disassembly" class="editor">
|
||||
</div>
|
||||
<div id="editor" class="editor">
|
||||
|
@ -188,6 +188,7 @@ void draw_string(const char* str, byte spacing) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
int r = 512;
|
||||
dvgwrofs = 0x800;
|
||||
draw_string("HELLO WORLD", 0);
|
||||
RTSL();
|
||||
@ -195,12 +196,12 @@ void main() {
|
||||
dvgreset();
|
||||
CNTR();
|
||||
SCAL(0x7f);
|
||||
//SCAL(frame & 0xff);
|
||||
STAT(RED, 0);
|
||||
VCTR(200, 200, 1);
|
||||
VCTR(-200, 200, 3);
|
||||
VCTR(-200, -200, 5);
|
||||
VCTR(200, -200, 7);
|
||||
VCTR(r, r, 1);
|
||||
VCTR(-r*2, 0, 3);
|
||||
VCTR(0, -r*2, 5);
|
||||
VCTR(r*2, 0, 7);
|
||||
VCTR(0, r*2, 7);
|
||||
CNTR();
|
||||
STAT(GREEN, 0);
|
||||
VCTR(100, -100, 0);
|
||||
|
@ -5,11 +5,11 @@ typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
byte __at (0xc000) palette[16];
|
||||
byte __at (0xc800) input0;
|
||||
byte __at (0xc802) input1;
|
||||
byte __at (0xc804) input2;
|
||||
volatile byte __at (0xc800) input0;
|
||||
volatile byte __at (0xc802) input1;
|
||||
volatile byte __at (0xc804) input2;
|
||||
byte __at (0xc900) rom_select;
|
||||
byte __at (0xcb00) video_counter;
|
||||
volatile byte __at (0xcb00) video_counter;
|
||||
byte __at (0xcbff) watchdog0x39;
|
||||
byte __at (0xcc00) nvram[0x400];
|
||||
|
||||
@ -359,7 +359,7 @@ typedef struct Actor {
|
||||
ActorDrawFn* draw;
|
||||
} Actor;
|
||||
|
||||
#define GBITS 4
|
||||
#define GBITS 3
|
||||
#define GDIM (1<<GBITS)
|
||||
#define MAX_ACTORS 256
|
||||
|
||||
@ -371,36 +371,43 @@ inline byte xy2grid(byte x, byte y) {
|
||||
}
|
||||
|
||||
void insert_into_grid(byte gi, byte actor_index) {
|
||||
actors[actor_index].grid_index = gi;
|
||||
actors[actor_index].next_actor = grid[gi];
|
||||
struct Actor* a = &actors[actor_index];
|
||||
a->grid_index = gi;
|
||||
a->next_actor = grid[gi];
|
||||
grid[gi] = actor_index;
|
||||
}
|
||||
|
||||
void delete_from_grid(byte gi, byte actor_index) {
|
||||
byte i = grid[gi];
|
||||
byte next = actors[actor_index].next_actor;
|
||||
// is actor to delete at head of list?
|
||||
if (i == actor_index) {
|
||||
grid[gi] = actors[actor_index].next_actor;
|
||||
grid[gi] = next;
|
||||
} else {
|
||||
// iterate through the list
|
||||
do {
|
||||
byte j = actors[i].next_actor;
|
||||
if (j == actor_index) {
|
||||
actors[i].next_actor = actors[actor_index].next_actor;
|
||||
actors[i].next_actor = next;
|
||||
break;
|
||||
}
|
||||
i = j;
|
||||
} while (1);
|
||||
// watchdog reset if actor not found to delete
|
||||
} while (1); // watchdog reset if actor not found to delete
|
||||
}
|
||||
actors[actor_index].next_actor = 0;
|
||||
actors[actor_index].grid_index = 0;
|
||||
}
|
||||
|
||||
void draw_actor_debug(struct Actor* a) {
|
||||
draw_sprite_solid(a->shape, a->x, a->y, a->next_actor?0xff:0x33);
|
||||
}
|
||||
|
||||
void update_actor(byte actor_index) {
|
||||
byte update_actor(byte actor_index) {
|
||||
struct Actor* a = &actors[actor_index];
|
||||
byte next_actor;
|
||||
byte gi0,gi1;
|
||||
if (!a->shape) return;
|
||||
if (!a->shape) return 0;
|
||||
next_actor = a->next_actor;
|
||||
gi0 = a->grid_index;
|
||||
draw_sprite_solid(a->shape, a->x, a->y, 0);
|
||||
if (a->update) a->update(a);
|
||||
@ -411,6 +418,7 @@ void update_actor(byte actor_index) {
|
||||
delete_from_grid(gi0, actor_index);
|
||||
insert_into_grid(gi1, actor_index);
|
||||
}
|
||||
return next_actor;
|
||||
}
|
||||
|
||||
//
|
||||
@ -436,8 +444,23 @@ void random_walk(Actor* a) {
|
||||
a->y += random_dir();
|
||||
}
|
||||
|
||||
void update_grid_cell(byte grid_index) {
|
||||
byte actor_index = grid[grid_index];
|
||||
while (actor_index) {
|
||||
actor_index = update_actor(actor_index);
|
||||
}
|
||||
}
|
||||
|
||||
void update_grid_rows(byte row_start, byte row_end) {
|
||||
byte i0 = row_start * GDIM;
|
||||
byte i1 = row_end * GDIM;
|
||||
byte i;
|
||||
for (i=i0; i!=i1; i++) {
|
||||
update_grid_cell(i);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
byte y = 0;
|
||||
byte i;
|
||||
byte num_actors = 32;
|
||||
blit_solid(0, 0, 255, 255, 0);
|
||||
@ -445,7 +468,7 @@ void main() {
|
||||
memset(actors, 0, sizeof(actors));
|
||||
memcpy(palette, palette_data, 16);
|
||||
fill_char_table();
|
||||
for (i=0; i<num_actors; i++) {
|
||||
for (i=1; i<num_actors; i++) {
|
||||
Actor* a = &actors[i];
|
||||
a->x = (i & 3) * 16 + 32;
|
||||
a->y = (i / 4) * 16 + 64;
|
||||
@ -456,10 +479,12 @@ void main() {
|
||||
watchdog0x39 = 0x39;
|
||||
}
|
||||
while (1) {
|
||||
for (i=0; i<num_actors; i++) {
|
||||
update_actor(i);
|
||||
watchdog0x39 = 0x39;
|
||||
}
|
||||
y++;
|
||||
// update top half while drawing bottom half
|
||||
while (video_counter < 0x80) ;
|
||||
update_grid_rows(0,GDIM/2);
|
||||
// update bottom half while drawing top half
|
||||
while (video_counter >= 0x80) ;
|
||||
update_grid_rows(GDIM/2,GDIM);
|
||||
watchdog0x39 = 0x39;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,9 @@ function fillBuffer() {
|
||||
|
||||
function start() {
|
||||
ram = new RAM(0x400);
|
||||
rom = [0xe,0x0,0x6,0x0,0x78,0xb9,0x30,0x06,0xa9,0xd3,0x00,0x04,0x18,0xf6,0x0c,0x79,0xd6,0xff,0x38,0xee,0x76,0x18,0xea]; // TODO
|
||||
rom = new RAM(0x4000).mem;
|
||||
// sample: [0xe,0x0,0x6,0x0,0x78,0xb9,0x30,0x06,0xa9,0xd3,0x00,0x04,0x18,0xf6,0x0c,0x79,0xd6,0xff,0x38,0xee,0x76,0x18,0xea];
|
||||
rom.fill(0x76); // HALT opcodes
|
||||
membus = {
|
||||
read: new AddressDecoder([
|
||||
[0x0000, 0x3fff, 0x3fff, function(a) { return rom ? rom[a] : null; }],
|
||||
@ -107,6 +109,7 @@ function timerCallback() {
|
||||
timer = setTimeout(timerCallback, dt);
|
||||
} else {
|
||||
timer = 0;
|
||||
//console.log("HALT @ " + cpu.getPC());
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +133,10 @@ onmessage = function(e) {
|
||||
bufferLength = numChannels*sampleRate*timerPeriod/1000;
|
||||
start();
|
||||
reset();
|
||||
} else if (e.data.rom) {
|
||||
rom = e.data.rom;
|
||||
command = 0x0;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ var WilliamsPlatform = function(mainElement, proto) {
|
||||
]);
|
||||
|
||||
var memread_williams = new AddressDecoder([
|
||||
[0x0000, 0x97ff, 0xffff, function(a) { return banksel ? rom[a] : ram.mem[a]; }],
|
||||
[0x9800, 0xbfff, 0xffff, function(a) { return ram.mem[a]; }],
|
||||
[0x0000, 0x8fff, 0xffff, function(a) { return banksel ? rom[a] : ram.mem[a]; }],
|
||||
[0x9000, 0xbfff, 0xffff, function(a) { return ram.mem[a]; }],
|
||||
[0xc000, 0xcfff, 0x0fff, ioread_williams],
|
||||
[0xd000, 0xffff, 0xffff, function(a) { return rom ? rom[a-0x4000] : 0; }],
|
||||
]);
|
||||
@ -324,11 +324,20 @@ var WilliamsPlatform = function(mainElement, proto) {
|
||||
});
|
||||
}
|
||||
|
||||
this.loadSoundROM = function(data) {
|
||||
var soundrom = padBytes(data, 0x4000);
|
||||
worker.postMessage({rom:soundrom});
|
||||
}
|
||||
|
||||
this.loadROM = function(title, data) {
|
||||
if (data.length > 2) {
|
||||
rom = padBytes(data, 0xc000);
|
||||
if (data.length > 0xc000) {
|
||||
self.loadSoundROM(data.slice(0xc000));
|
||||
rom = rom.slice(data, 0, 0xc000);
|
||||
} else {
|
||||
rom = padBytes(data, 0xc000);
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
self.reset();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user