mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-21 21:29:17 +00:00
vic20: added cart support, fixed bugs
This commit is contained in:
parent
30342d2618
commit
3853f9a86a
16
presets/vic20/hellocart.dasm
Normal file
16
presets/vic20/hellocart.dasm
Normal file
@ -0,0 +1,16 @@
|
||||
processor 6502
|
||||
|
||||
org $a000-2 ; so we can write the ...
|
||||
.word $a000 ; cartridge 2-byte header
|
||||
.word Start ; start vector
|
||||
.word Start ; RESTORE vector
|
||||
.byte $41, $30, $c3, $c2, $cd ; "A0CBM"
|
||||
|
||||
Start:
|
||||
lda $9004
|
||||
WaitLine;
|
||||
cmp $9004
|
||||
beq WaitLine
|
||||
sta $900f
|
||||
jmp Start
|
||||
|
@ -205,6 +205,7 @@ void declare_winner(byte winner) {
|
||||
void play_round() {
|
||||
reset_players();
|
||||
clrscr();
|
||||
bgcolor(COLOR_BLUE);
|
||||
textcolor(COLOR_WHITE);
|
||||
draw_playfield();
|
||||
while (1) {
|
||||
|
BIN
res/c64.wasm
BIN
res/c64.wasm
Binary file not shown.
BIN
res/vic20.wasm
BIN
res/vic20.wasm
Binary file not shown.
@ -1,6 +1,10 @@
|
||||
|
||||
//// WASM Machine
|
||||
|
||||
// http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/VIC-I.txt
|
||||
// http://www.zimmers.net/anonftp/pub/cbm/maps/Vic20.MemoryMap.txt
|
||||
// http://sleepingelephant.com/denial/wiki/index.php/Autostart
|
||||
|
||||
import { Machine } from "../common/baseplatform";
|
||||
import { Probeable, TrapCondition } from "../common/devices";
|
||||
import { KeyFlags } from "../common/emu";
|
||||
@ -10,7 +14,7 @@ import { BaseWASMMachine } from "../common/wasmplatform";
|
||||
export class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probeable {
|
||||
|
||||
numTotalScanlines = 312;
|
||||
cpuCyclesPerLine = 63;
|
||||
cpuCyclesPerLine = 71;
|
||||
videoOffsetBytes = -24 * 4;
|
||||
|
||||
prgstart : number;
|
||||
@ -30,42 +34,47 @@ export class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probe
|
||||
}
|
||||
// load rom
|
||||
if (this.romptr && this.romlen) {
|
||||
let rom = this.romarr;
|
||||
this.exports.machine_load_rom(this.sys, this.romptr, this.romlen);
|
||||
this.prgstart = this.romarr[0] + (this.romarr[1]<<8); // get load address
|
||||
// look for BASIC program start
|
||||
if (this.prgstart == 0x1001) {
|
||||
this.prgstart = this.romarr[2] + (this.romarr[3]<<8) + 2; // point to after BASIC program
|
||||
console.log("prgstart", hex(this.prgstart));
|
||||
}
|
||||
// is program loaded into RAM?
|
||||
if (this.prgstart < 0x8000) {
|
||||
// advance BIOS a few frames
|
||||
this.exports.machine_exec(this.sys, 400000);
|
||||
// type in command (SYS 2061)
|
||||
var cmd = "SYS "+this.prgstart+"\r";
|
||||
console.log(cmd);
|
||||
for (var i=0; i<cmd.length; i++) {
|
||||
var key = cmd.charCodeAt(i);
|
||||
this.exports.machine_exec(this.sys, 20000);
|
||||
this.exports.machine_exec(this.sys, 20000);
|
||||
this.exports.machine_key_down(this.sys, key);
|
||||
this.exports.machine_exec(this.sys, 20000);
|
||||
this.exports.machine_exec(this.sys, 20000);
|
||||
this.exports.machine_key_up(this.sys, key);
|
||||
let iscart = rom[4+2]==0x41 && rom[5+2]==0x30 && rom[6+2]==0xC3 && rom[7+2]==0xC2 && rom[8+2]==0xCD;
|
||||
if (!iscart) {
|
||||
this.prgstart = rom[0] + (rom[1]<<8); // get load address
|
||||
// look for BASIC program start
|
||||
if (this.prgstart == 0x1001) {
|
||||
this.prgstart = rom[2] + (rom[3]<<8) + 2; // point to after BASIC program
|
||||
console.log("prgstart", hex(this.prgstart));
|
||||
}
|
||||
// advance clock until program starts
|
||||
for (var i=0; i<10000 && this.getPC() != this.prgstart; i++) {
|
||||
//this.exports.machine_tick(this.sys);
|
||||
// is program loaded into RAM?
|
||||
if (this.prgstart < 0x8000) {
|
||||
// advance BIOS a few frames
|
||||
this.exports.machine_exec(this.sys, 500000);
|
||||
// type in command (SYS 2061)
|
||||
var cmd = "SYS "+this.prgstart+"\r";
|
||||
console.log(cmd);
|
||||
for (var i=0; i<cmd.length; i++) {
|
||||
var key = cmd.charCodeAt(i);
|
||||
this.exports.machine_exec(this.sys, 10000);
|
||||
this.exports.machine_exec(this.sys, 10000);
|
||||
this.exports.machine_key_down(this.sys, key);
|
||||
this.exports.machine_exec(this.sys, 10000);
|
||||
this.exports.machine_exec(this.sys, 10000);
|
||||
this.exports.machine_key_up(this.sys, key);
|
||||
}
|
||||
// advance clock until program starts
|
||||
for (var i=0; i<10000 && this.getPC() != this.prgstart; i++) {
|
||||
this.exports.machine_tick(this.sys);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// get out of reset
|
||||
this.exports.machine_exec(this.sys, 100);
|
||||
//this.exports.machine_exec(this.sys, 100);
|
||||
// wait until cartridge start
|
||||
// TODO: detect ROM cartridge
|
||||
var warmstart = this.romarr[0x4] + this.romarr[0x5]*256;
|
||||
for (var i=0; i<150000 && this.getPC() != warmstart; i++) {
|
||||
var warmstart = this.romarr[0x2+2] + this.romarr[0x3+2]*256;
|
||||
for (var i=0; i<10000 && this.getPC() != warmstart; i++) {
|
||||
this.exports.machine_tick(this.sys);
|
||||
}
|
||||
console.log('cart', i, hex(warmstart));
|
||||
}
|
||||
// TODO: shouldn't we return here @ start of frame?
|
||||
// and stop probing
|
||||
@ -74,7 +83,7 @@ export class VIC20_WASMMachine extends BaseWASMMachine implements Machine, Probe
|
||||
advanceFrame(trap: TrapCondition) : number {
|
||||
// TODO: does this sync with VSYNC?
|
||||
var scanline = this.getRasterY();
|
||||
var clocks = Math.floor((this.numTotalScanlines - scanline) * 19656 / this.numTotalScanlines);
|
||||
var clocks = Math.floor((this.numTotalScanlines - scanline) * 22152 / this.numTotalScanlines);
|
||||
var probing = this.probe != null;
|
||||
if (probing) this.exports.machine_reset_probe_buffer();
|
||||
clocks = super.advanceFrameClock(trap, clocks);
|
||||
|
@ -6,18 +6,23 @@ import { BaseMAME6502Platform } from "../common/mameplatform";
|
||||
|
||||
const VIC20_PRESETS = [
|
||||
{id:'hello.dasm', name:'Hello World (ASM)'},
|
||||
{id:'hellocart.dasm', name:'Hello Cartridge (ASM)'},
|
||||
{id:'siegegame.c', name:'Siege Game (C)'},
|
||||
];
|
||||
|
||||
const VIC20_MEMORY_MAP = { main:[
|
||||
{name:'RAM', start:0x0000,size:0x0400,type:'ram'},
|
||||
{name:'RAM', start:0x1000,size:0x1000,type:'ram'},
|
||||
{name:'Cartridge ROM',start:0x8000,size:0x2000,type:'rom'},
|
||||
{name:'BASIC ROM', start:0xc000,size:0x2000,type:'rom'},
|
||||
{name:'BLK1 Cart ROM',start:0x2000,size:0x2000,type:'rom'},
|
||||
{name:'BLK2 Cart ROM',start:0x4000,size:0x2000,type:'rom'},
|
||||
{name:'BLK3 Cart ROM',start:0x6000,size:0x2000,type:'rom'},
|
||||
{name:'Character ROM',start:0x8000,size:0x1000,type:'rom'},
|
||||
{name:'I/O 1', start:0x9000,size:0x0400,type:'io'},
|
||||
{name:'Color RAM', start:0x9400,size:0x0400,type:'io'},
|
||||
{name:'I/O 2', start:0x9800,size:0x0400,type:'io'},
|
||||
{name:'I/O 3', start:0x9c00,size:0x0400,type:'io'},
|
||||
{name:'BLK5 Autostart',start:0xa000,size:0x2000,type:'rom'},
|
||||
{name:'BASIC ROM', start:0xc000,size:0x2000,type:'rom'},
|
||||
{name:'KERNAL ROM', start:0xe000,size:0x2000,type:'rom'},
|
||||
] }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user