mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-21 21:29:11 +00:00
started atari8 emulation; fixed memory view; show speed bar only when CRT
This commit is contained in:
parent
50ac618e86
commit
7b6af7ef04
@ -42,7 +42,7 @@ TODO:
|
||||
- online tools for music etc
|
||||
- text log debugging script
|
||||
- NES crt should mark raster pos when debugging
|
||||
- intro/help text for each platform
|
||||
- intro/help text for each platform (+ memory map)
|
||||
- vscode/atom extension?
|
||||
- navigator.getGamepads
|
||||
- VCS library
|
||||
@ -64,9 +64,8 @@ TODO:
|
||||
- 'undefined' for bitmap replacer
|
||||
- astrocade: run to cursor in hello world messes up emulation
|
||||
- requestInterrupt needs to be disabled after breakpoint?
|
||||
- verilog resets randomly (lfsr enable bit)
|
||||
- verilog: when paused scope doesn't work
|
||||
- verilog: don't need fps controls when no video
|
||||
- resize memory dump window
|
||||
|
||||
|
||||
WEB WORKER FORMAT
|
||||
|
14
index.html
14
index.html
@ -134,13 +134,6 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
<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>
|
||||
</span>
|
||||
<span class="btn_group view_group" id="speed_bar" style="display:none">
|
||||
<button id="dbg_slowest" type="submit" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_slower" type="submit" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
||||
<span class="label"><span id="fps_label">60.00</span> fps</span>
|
||||
<button id="dbg_faster" type="submit" title="Faster"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_fastest" type="submit" title="Faster"><span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span></button>
|
||||
</span>
|
||||
<span class="btn_group view_group" id="extra_bar">
|
||||
<button id="dbg_timing" type="submit" title="Analyze CPU Timing" style="display:none"><span class="glyphicon glyphicon-time" 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>
|
||||
@ -149,6 +142,13 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
||||
<button id="dbg_bitmap" type="submit" title="Edit Bitmap"><span class="glyphicon glyphicon-camera" aria-hidden="true"></span></button>
|
||||
<button id="dbg_record" type="submit" title="Start/Stop Replay Recording" style="display:none"><span class="glyphicon glyphicon-record" aria-hidden="true"></span></button>
|
||||
</span>
|
||||
<span class="btn_group view_group" id="speed_bar" style="display:none">
|
||||
<button id="dbg_slowest" type="submit" title="Slowest"><span class="glyphicon glyphicon-fast-backward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_slower" type="submit" title="Slower"><span class="glyphicon glyphicon-backward" aria-hidden="true"></span></button>
|
||||
<span class="label"><span id="fps_label">60.00</span> fps</span>
|
||||
<button id="dbg_faster" type="submit" title="Faster"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
|
||||
<button id="dbg_fastest" type="submit" title="Faster"><span class="glyphicon glyphicon-fast-forward" aria-hidden="true"></span></button>
|
||||
</span>
|
||||
<span id="verilog_bar" style="display:none">
|
||||
<span class="label"><span id="settle_label"></span> evals/clk</span>
|
||||
</span>
|
||||
|
@ -26,7 +26,7 @@ export interface CpuState {
|
||||
};
|
||||
export interface EmuState {
|
||||
c?:CpuState, // CPU state
|
||||
b?:number[], // RAM (TODO: not for vcs)
|
||||
b?:Uint8Array|number[], // RAM (TODO: not for vcs, support Uint8Array)
|
||||
o?:{}, // verilog
|
||||
T?:number, // verilog
|
||||
};
|
||||
@ -904,7 +904,7 @@ export abstract class BaseMAMEPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
export function dumpStackToString(platform:Platform, mem:number[], start:number, end:number, sp:number, jsrop:number) : string {
|
||||
export function dumpStackToString(platform:Platform, mem:Uint8Array|number[], start:number, end:number, sp:number, jsrop:number) : string {
|
||||
var s = "";
|
||||
var nraw = 0;
|
||||
//s = dumpRAM(mem.slice(start,start+end+1), start, end-start+1);
|
||||
|
@ -232,7 +232,7 @@ export var AnimationTimer = function(frequencyHz:number, callback:() => void) {
|
||||
|
||||
// TODO: move to util?
|
||||
|
||||
export function dumpRAM(ram:number[], ramofs:number, ramlen:number) : string {
|
||||
export function dumpRAM(ram:Uint8Array|number[], ramofs:number, ramlen:number) : string {
|
||||
var s = "";
|
||||
// TODO: show scrollable RAM for other platforms
|
||||
for (var ofs=0; ofs<ramlen; ofs+=0x10) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import { Platform, BaseZ80Platform } from "../baseplatform";
|
||||
import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap } from "../emu";
|
||||
import { hex, lzgmini, stringToByteArray } from "../util";
|
||||
import { hex, lzgmini, stringToByteArray, rgb2bgr } from "../util";
|
||||
import { MasterAudio, AY38910_Audio } from "../audio";
|
||||
|
||||
const ASTROCADE_PRESETS = [
|
||||
@ -453,8 +453,7 @@ var ASTROCADE_PALETTE = [0x000000,0x242424,0x484848,0x6D6D6D,0x919191,0xB6B6B6,0
|
||||
// swap palette RGB to BGR
|
||||
for (var i=0; i<256; i++) {
|
||||
var x = ASTROCADE_PALETTE[i];
|
||||
x = ((x&0xff)<<16) | ((x>>16)&0xff) | (x&0x00ff00);
|
||||
ASTROCADE_PALETTE[i] = x | 0xff000000;
|
||||
ASTROCADE_PALETTE[i] = rgb2bgr(x) | 0xff000000;
|
||||
}
|
||||
|
||||
//var ASTROCADE_BIOS_LZG = decodeURIComponent();
|
||||
|
@ -1,13 +1,554 @@
|
||||
"use strict";
|
||||
|
||||
import { Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, getToolForFilename_6502 } from "../baseplatform";
|
||||
import { PLATFORMS } from "../emu";
|
||||
import { Platform, Base6502Platform, BaseMAMEPlatform, getOpcodeMetadata_6502, getToolForFilename_6502 } from "../baseplatform";
|
||||
import { PLATFORMS, RAM, newAddressDecoder, padBytes, noise, setKeyboardFromMap, AnimationTimer, RasterVideo, Keys, makeKeycodeMap, dumpRAM } from "../emu";
|
||||
import { hex, lzgmini, stringToByteArray, lpad, rpad, rgb2bgr } from "../util";
|
||||
import { MasterAudio, POKEYDeviceChannel } from "../audio";
|
||||
|
||||
declare var jt; // for 6502
|
||||
|
||||
var Atari8_PRESETS = [
|
||||
{id:'hello.a', name:'Hello World (ASM)'},
|
||||
{id:'hellopm.a', name:'Hello Sprites (ASM)'},
|
||||
];
|
||||
|
||||
function newPOKEYAudio() {
|
||||
var pokey1 = new POKEYDeviceChannel();
|
||||
var audio = new MasterAudio();
|
||||
audio['pokey1'] = pokey1; // TODO: cheezy
|
||||
audio.master.addChannel(pokey1);
|
||||
return audio;
|
||||
}
|
||||
|
||||
// ANTIC
|
||||
|
||||
// https://www.atarimax.com/jindroush.atari.org/atanttim.html
|
||||
// http://www.virtualdub.org/blog/pivot/entry.php?id=243
|
||||
// http://www.beipmu.com/Antic_Timings.txt
|
||||
|
||||
const PF_LEFT = [999,64,48,32];
|
||||
const PF_RIGHT = [999,192,208,224];
|
||||
|
||||
const DMACTL = 0;
|
||||
const CHACTL = 1;
|
||||
const DLISTL = 2;
|
||||
const DLISTH = 3;
|
||||
const HSCROL = 4;
|
||||
const VSCROL = 5;
|
||||
const PMBASE = 7;
|
||||
const CHBASE = 9;
|
||||
const WSYNC = 10;
|
||||
const VCOUNT = 11;
|
||||
const PENH = 12;
|
||||
const PENV = 13;
|
||||
const NMIEN = 14;
|
||||
const NMIRES = 15;
|
||||
const NMIST = 15;
|
||||
|
||||
const PFNONE = 0;
|
||||
const PFNARROW = 1;
|
||||
const PFNORMAL = 2;
|
||||
const PFWIDE = 3;
|
||||
|
||||
const NMIST_CYCLE = 12;
|
||||
const NMI_CYCLE = 24;
|
||||
const WSYNC_CYCLE = 212;
|
||||
|
||||
const MODE_LINES = [ 0, 0, 7, 9, 7, 15, 7, 15, 7, 3, 3, 1, 0, 1, 0, 0 ];
|
||||
const MODE_PERIOD = [ 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 0, 0, 0 ];
|
||||
const MODE_YPERIOD = [ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 1, 0, 0, 0, 0 ];
|
||||
|
||||
class ANTIC {
|
||||
regs = new Uint8Array(0x10); // registers
|
||||
gtia : GTIA; // GTIA link
|
||||
read : (address:number) => number; // bus read function
|
||||
nmiPending : boolean = false;
|
||||
|
||||
// derived by registers
|
||||
pfwidth : number; // playfield width
|
||||
left : number;
|
||||
right : number; // left/right clocks for mode
|
||||
|
||||
// a la minute
|
||||
mode : number = 0; // current mode
|
||||
period : number = 0; // current mode period bitmask
|
||||
scanaddr : number = 0; // Scan Address (via LMS)
|
||||
startaddr: number = 0; // Start of line Address
|
||||
pfbyte : number = 0; // playfield byte fetched
|
||||
linesleft : number = 0; // # of lines left in mode
|
||||
yofs : number = 0; // yofs fine
|
||||
v : number = 0; // vertical scanline #
|
||||
h : number = 0; // horizontal color clock
|
||||
|
||||
constructor(readfn) {
|
||||
this.read = readfn; // bus read function
|
||||
}
|
||||
reset() {
|
||||
this.regs[NMIEN] = 0x00;
|
||||
this.regs[NMIST] = 0x1f;
|
||||
this.setReg(DMACTL, 0x0);
|
||||
}
|
||||
saveState() {
|
||||
return {
|
||||
regs: this.regs.slice(0),
|
||||
mode: this.mode,
|
||||
period: this.period,
|
||||
scanaddr: this.scanaddr,
|
||||
startaddr: this.startaddr,
|
||||
pfbyte: this.pfbyte,
|
||||
linesleft: this.linesleft,
|
||||
yofs: this.yofs,
|
||||
v: this.v,
|
||||
h: this.h,
|
||||
};
|
||||
}
|
||||
loadState(s) {
|
||||
for (let i=0; i<16; i++)
|
||||
if (i != NMIRES)
|
||||
this.setReg(i, s.regs[i]);
|
||||
this.mode = s.mode;
|
||||
this.period = s.period;
|
||||
this.scanaddr = s.scanaddr;
|
||||
this.startaddr = s.startaddr;
|
||||
this.pfbyte = s.pfbyte;
|
||||
this.linesleft = s.linesleft;
|
||||
this.yofs = s.yofs;
|
||||
this.v = s.v;
|
||||
this.h = s.h;
|
||||
}
|
||||
static stateToLongString(state) : string {
|
||||
let s = "";
|
||||
s += "H: " + lpad(state.h,3) + " V: " + lpad(state.v,3) + " Linesleft: " + state.linesleft + "\n";
|
||||
s += "Mode: " + hex(state.mode,2) + " Period: " + (state.period+1) + "\n";
|
||||
s += "Addr: " + hex(state.scanaddr,4) + "\n";
|
||||
s += dumpRAM(state.regs, 0, 16).replace('$00', 'Regs');
|
||||
return s;
|
||||
}
|
||||
setReg(a:number, v:number) {
|
||||
this.regs[a] = v;
|
||||
switch (a) {
|
||||
case DMACTL:
|
||||
this.pfwidth = this.regs[DMACTL] & 3;
|
||||
this.left = PF_LEFT[this.pfwidth]-4; // TODO
|
||||
this.right = PF_RIGHT[this.pfwidth]-4; // TODO
|
||||
break;
|
||||
case NMIRES:
|
||||
this.regs[NMIST] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
readReg(a:number) {
|
||||
switch (a) {
|
||||
case NMIST: return this.regs[NMIST];
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
startline1() {
|
||||
let stolen = 0;
|
||||
if (this.linesleft) {
|
||||
this.linesleft--;
|
||||
if ((this.linesleft & MODE_YPERIOD[this.mode&0xf]) == 0) // use Y period
|
||||
this.yofs++;
|
||||
}
|
||||
if (!this.linesleft) {
|
||||
if (this.mode & 0x80)
|
||||
this.triggerInterrupt(0x80); // Display List Interrupt (DLI)
|
||||
this.mode = this.nextInsn();
|
||||
stolen++;
|
||||
if ((this.mode & 0xf) == 0) { // N Blank Lines
|
||||
this.linesleft = (this.mode >> 4) + 1;
|
||||
} else {
|
||||
this.linesleft = MODE_LINES[this.mode & 0xf];
|
||||
this.period = (1<<MODE_PERIOD[this.mode & 0xf])-1;
|
||||
// TODO: this is actually at cclock 9-10
|
||||
if ((this.mode & ~0x40) == 0x01) { // JMP insn
|
||||
let lo = this.nextInsn();
|
||||
let hi = this.nextInsn();
|
||||
this.regs[DLISTL] = lo;
|
||||
this.regs[DLISTH] = hi;
|
||||
// JVB (Jump and wait for Vertical Blank)
|
||||
if (this.mode & 0x40) {
|
||||
this.mode = 0;
|
||||
this.linesleft = 240 - this.v;
|
||||
}
|
||||
stolen += 2;
|
||||
} else if ((this.mode & 0x40) && (this.mode & 0xf)) { // Load Memory Scan bit
|
||||
let lo = this.nextInsn();
|
||||
let hi = this.nextInsn();
|
||||
this.scanaddr = lo + (hi<<8);
|
||||
//console.log('scanaddr', hex(this.scanaddr));
|
||||
stolen += 2;
|
||||
}
|
||||
this.startaddr = this.scanaddr;
|
||||
this.yofs = 0;
|
||||
}
|
||||
} else {
|
||||
if ((this.mode & 0xf) < 8) // character mode?
|
||||
this.scanaddr = this.startaddr; // reset line addr
|
||||
}
|
||||
return stolen;
|
||||
}
|
||||
|
||||
startline2() {
|
||||
return 0; // TODO
|
||||
}
|
||||
|
||||
startline3() {
|
||||
return 0; // TODO
|
||||
}
|
||||
|
||||
startline4() {
|
||||
let stolen = 0;
|
||||
return stolen;
|
||||
}
|
||||
|
||||
triggerInterrupt(mask : number) {
|
||||
if (this.regs[NMIEN] & mask) {
|
||||
this.nmiPending = true;
|
||||
//this.regs[NMIST] = mask | 0x1f;
|
||||
}
|
||||
}
|
||||
|
||||
nextInsn() : number {
|
||||
let pc = this.regs[DLISTL] + (this.regs[DLISTH]<<8);
|
||||
let b = this.read(pc);
|
||||
//console.log('nextInsn', hex(pc), hex(b), this.v);
|
||||
pc = ((pc+1) & 0x3ff) | (pc & ~0x3ff);
|
||||
this.regs[DLISTL] = pc & 0xff;
|
||||
this.regs[DLISTH] = pc >> 8;
|
||||
return b;
|
||||
}
|
||||
|
||||
nextScreen() : number {
|
||||
let b = this.read(this.scanaddr);
|
||||
this.scanaddr = ((this.scanaddr+1) & 0xfff) | (this.scanaddr & ~0xfff);
|
||||
return b;
|
||||
}
|
||||
|
||||
clockPulse4() : number {
|
||||
let nc = 4; // number of cycles not stolen by DMA
|
||||
let h = this.h;
|
||||
// in overscan region?
|
||||
if (this.v >= 240) {
|
||||
// interrupts on last scanline of frame
|
||||
if (this.v == 240) {
|
||||
if (h == NMIST_CYCLE)
|
||||
this.regs[NMIST] = 0x5f;
|
||||
else if (h == NMI_CYCLE)
|
||||
this.triggerInterrupt(0x40);
|
||||
}
|
||||
}
|
||||
// DMA enabled?
|
||||
else if (this.regs[DMACTL] & 0x20) {
|
||||
// read line data?
|
||||
switch (h) {
|
||||
case 0: nc -= this.startline1(); break;
|
||||
case 4: nc -= this.startline2(); break;
|
||||
case 8: nc -= this.startline3(); break;
|
||||
case 12: nc -= this.startline4(); break;
|
||||
default:
|
||||
if (h >= 48 && h < 120) nc--; // steal 1 clock for memory refresh
|
||||
if (h >= this.left && h < this.right) { // fetch screen byte?
|
||||
if (((h>>2) & this.period) == 0) { // use period interval
|
||||
if ((this.mode & 0xf) < 8) { // character mode
|
||||
let ch = this.nextScreen();
|
||||
let addr = (ch<<3) + (this.regs[CHBASE]<<8);
|
||||
this.pfbyte = this.read(addr + this.yofs);
|
||||
//console.log(hex(addr), this.yofs, hex(this.scanaddr), this.h, this.v, ch);
|
||||
nc -= 2;
|
||||
} else { // map mode
|
||||
this.pfbyte = this.nextScreen();
|
||||
nc -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// next scanline?
|
||||
this.h += 4;
|
||||
if (this.h >= 228) {
|
||||
this.h = 0;
|
||||
this.v++;
|
||||
if (this.v >= 262) {
|
||||
this.v = 0;
|
||||
}
|
||||
}
|
||||
return nc;
|
||||
}
|
||||
}
|
||||
|
||||
// GTIA
|
||||
// write regs
|
||||
const HPOSP0 = 0x0;
|
||||
const HPOSM0 = 0x4;
|
||||
const SIZEP0 = 0x8;
|
||||
const SIZEM = 0x0c;
|
||||
const GRAFP0 = 0x0d;
|
||||
const GRAFM = 0x11;
|
||||
const COLPM0 = 0x12;
|
||||
const COLPF0 = 0x16;
|
||||
const COLBK = 0x1a;
|
||||
const PRIOR = 0x1b;
|
||||
const VDELAY = 0x1c;
|
||||
const GRACTL = 0x1d;
|
||||
const HITCLR = 0x1e;
|
||||
const CONSPK = 0x1f;
|
||||
// read regs
|
||||
const M0PF = 0x0;
|
||||
const P0PF = 0x4;
|
||||
const M0PL = 0x8;
|
||||
const P0PL = 0xc;
|
||||
const TRIG0 = 0x10;
|
||||
const CONSOL = 0x1f;
|
||||
|
||||
class GTIA {
|
||||
regs = new Uint8Array(0x20);
|
||||
count : number = 0;
|
||||
antic : ANTIC;
|
||||
|
||||
constructor(antic : ANTIC) {
|
||||
this.antic = antic;
|
||||
}
|
||||
saveState() {
|
||||
return {
|
||||
regs: this.regs.slice(0),
|
||||
count: this.count,
|
||||
};
|
||||
}
|
||||
loadState(s) {
|
||||
for (let i=0; i<32; i++)
|
||||
this.setReg(i, s.regs[i]);
|
||||
this.count = s.count;
|
||||
}
|
||||
setReg(a:number, v:number) {
|
||||
this.regs[a] = v;
|
||||
switch (a) {
|
||||
}
|
||||
}
|
||||
clockPulse() : number {
|
||||
let colreg = (this.antic.pfbyte & 128) ? COLPF0 : COLBK;
|
||||
if ((this.count & this.antic.period) == 0)
|
||||
this.antic.pfbyte <<= 1;
|
||||
let colidx = this.regs[colreg];
|
||||
this.count = (this.count + 1) & 0xff;
|
||||
// TODO
|
||||
return COLORS_RGBA[colidx];
|
||||
}
|
||||
static stateToLongString(state) : string {
|
||||
let s = "";
|
||||
s += dumpRAM(state.regs, 0, 32);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
const _Atari8Platform = function(mainElement) {
|
||||
// http://www.ataripreservation.org/websites/freddy.offenga/megazine/ISSUE5-PALNTSC.html
|
||||
const cpuFrequency = 1789773;
|
||||
const linesPerFrame = 262;
|
||||
const colorClocksPerLine = 228;
|
||||
// TODO: for 400/800/5200
|
||||
const romLength = 0x8000;
|
||||
|
||||
var cpu;
|
||||
var ram : RAM;
|
||||
var rom : Uint8Array;
|
||||
var bios : Uint8Array;
|
||||
var bus;
|
||||
var video, audio;
|
||||
var timer; // TODO : AnimationTimer;
|
||||
var antic : ANTIC;
|
||||
var gtia : GTIA;
|
||||
var kbdlatch = 0;
|
||||
|
||||
class Atari8Platform extends Base6502Platform implements Platform {
|
||||
|
||||
getPresets() {
|
||||
return Atari8_PRESETS;
|
||||
}
|
||||
start() {
|
||||
cpu = new jt.M6502();
|
||||
ram = new RAM(0x4000); // TODO
|
||||
var lzgrom = window['ATARI5200_LZGROM'];
|
||||
if (lzgrom) {
|
||||
bios = new lzgmini().decode(stringToByteArray(atob(lzgrom)));
|
||||
} else {
|
||||
bios = padBytes([0], 0x800); // TODO
|
||||
}
|
||||
bus = {
|
||||
// TODO: https://github.com/dmlloyd/atari800/blob/master/DOC/cart.txt
|
||||
// TODO: http://atariage.com/forums/topic/169971-5200-memory-map/
|
||||
read: newAddressDecoder([
|
||||
[0x0000, 0x3fff, 0x3fff, function(a) { return ram.mem[a]; }],
|
||||
[0x4000, 0xbfff, 0xffff, function(a) { return rom ? rom[a-0x4000] : 0; }],
|
||||
[0xf000, 0xffff, 0x7ff, function(a) { return bios[a]; }],
|
||||
[0xd400, 0xd4ff, 0xf, function(a) { return antic.readReg(a); }],
|
||||
]),
|
||||
write: newAddressDecoder([
|
||||
[0x0000, 0x3fff, 0xffff, function(a,v) { ram.mem[a] = v; }],
|
||||
[0xc000, 0xcfff, 0x1f, function(a,v) { gtia.regs[a] = v; }],
|
||||
[0xd400, 0xd4ff, 0xf, function(a,v) { antic.setReg(a,v); }],
|
||||
[0xe800, 0xefff, 0xf, function(a,v) { audio.pokey1.setRegister(a, v); }],
|
||||
]),
|
||||
};
|
||||
cpu.connectBus(bus);
|
||||
// create support chips
|
||||
antic = new ANTIC(bus.read);
|
||||
gtia = new GTIA(antic);
|
||||
// create video/audio
|
||||
video = new RasterVideo(mainElement, 384, 192);
|
||||
audio = newPOKEYAudio();
|
||||
video.create();
|
||||
video.setKeyboardEvents((key,code,flags) => {
|
||||
if (flags & 1) {
|
||||
if (code) {
|
||||
// convert to uppercase for Apple ][
|
||||
if (code >= 0x61 && code <= 0x7a)
|
||||
code -= 0x20;
|
||||
kbdlatch = (code | 0x80) & 0xff;
|
||||
} else if (key) {
|
||||
switch (key) {
|
||||
case 16: return; // shift
|
||||
case 17: return; // ctrl
|
||||
case 18: return; // alt
|
||||
case 37: key=8; break; // left
|
||||
case 39: key=21; break; // right
|
||||
case 38: key=11; break; // up
|
||||
case 40: key=10; break; // down
|
||||
}
|
||||
if (key >= 65 && key < 65+26) {
|
||||
if (flags & 5) key -= 64; // ctrl
|
||||
}
|
||||
kbdlatch = (key | 0x80) & 0xff;
|
||||
}
|
||||
}
|
||||
});
|
||||
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||
}
|
||||
|
||||
advance(novideo : boolean) {
|
||||
var idata = video.getFrameData();
|
||||
var iofs = 0;
|
||||
var debugCond = this.getDebugCallback();
|
||||
var rgb;
|
||||
var freeClocks = 0;
|
||||
// visible lines
|
||||
for (var sl=0; sl<linesPerFrame; sl++) {
|
||||
for (var i=0; i<colorClocksPerLine; i+=4) {
|
||||
// 2 color clocks per CPU cycle = 4 color clocks
|
||||
freeClocks += antic.clockPulse4();
|
||||
// interrupt?
|
||||
if (antic.nmiPending) {
|
||||
freeClocks -= cpu.setNMIAndWait(); // steal clocks b/c of interrupt (could be negative)
|
||||
antic.nmiPending = false;
|
||||
}
|
||||
// iterate CPU with free clocks
|
||||
while (freeClocks > 0) {
|
||||
freeClocks--;
|
||||
if (debugCond && debugCond()) {
|
||||
debugCond = null;
|
||||
i = 999;
|
||||
sl = 999;
|
||||
break;
|
||||
}
|
||||
cpu.clockPulse();
|
||||
}
|
||||
// 4 ANTIC pulses = 8 pixels
|
||||
if (antic.h >= 32 && antic.h < 32+192) { // TODO
|
||||
for (var j=0; j<8; j++) {
|
||||
rgb = gtia.clockPulse();
|
||||
idata[iofs++] = rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// update video frame
|
||||
if (!novideo) {
|
||||
video.updateFrame();
|
||||
// set background/border color
|
||||
let bkcol = gtia.regs[COLBK];
|
||||
$(video.canvas).css('background-color', COLORS_WEB[bkcol]);
|
||||
}
|
||||
}
|
||||
|
||||
loadROM(title, data) {
|
||||
rom = padBytes(data, romLength);
|
||||
this.reset();
|
||||
}
|
||||
|
||||
isRunning() {
|
||||
return timer.isRunning();
|
||||
}
|
||||
pause() {
|
||||
timer.stop();
|
||||
audio.stop();
|
||||
}
|
||||
resume() {
|
||||
timer.start();
|
||||
audio.start();
|
||||
}
|
||||
reset() {
|
||||
cpu.reset();
|
||||
// execute until out of BIOS
|
||||
for (var i=0; i<20000; i++) {
|
||||
cpu.clockPulse();
|
||||
if (this.getCPUState().PC < 0xf000)
|
||||
break;
|
||||
}
|
||||
}
|
||||
readAddress(addr : number) {
|
||||
return ((addr & 0xf000) != 0xd000) ? bus.read(addr) : null; // ignore I/O space
|
||||
}
|
||||
|
||||
loadState(state) {
|
||||
cpu.loadState(state.c);
|
||||
ram.mem.set(state.b);
|
||||
antic.loadState(state.antic);
|
||||
gtia.loadState(state.gtia);
|
||||
kbdlatch = state.kbd;
|
||||
}
|
||||
saveState() {
|
||||
return {
|
||||
c:cpu.saveState(),
|
||||
b:ram.mem.slice(0),
|
||||
antic:antic.saveState(),
|
||||
gtia:gtia.saveState(),
|
||||
kbd:kbdlatch,
|
||||
};
|
||||
}
|
||||
loadControlsState(state) {
|
||||
kbdlatch = state.kbd;
|
||||
}
|
||||
saveControlsState() {
|
||||
return {
|
||||
kbd:kbdlatch
|
||||
};
|
||||
}
|
||||
getCPUState() {
|
||||
return cpu.saveState();
|
||||
}
|
||||
|
||||
getDebugCategories() {
|
||||
return super.getDebugCategories().concat(['ANTIC','GTIA']);
|
||||
}
|
||||
getDebugInfo(category, state) {
|
||||
switch (category) {
|
||||
case 'ANTIC': return ANTIC.stateToLongString(state.antic);
|
||||
case 'GTIA': return GTIA.stateToLongString(state.gtia);
|
||||
default: return super.getDebugInfo(category, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Atari8Platform(); // return inner class from constructor
|
||||
};
|
||||
|
||||
// Atari 5200
|
||||
const _Atari5200Platform = function(mainElement) {
|
||||
this.__proto__ = new (_Atari8Platform as any)(mainElement);
|
||||
}
|
||||
|
||||
|
||||
/// MAME support
|
||||
|
||||
var Atari8MAMEPlatform = function(mainElement) {
|
||||
@ -25,7 +566,7 @@ var Atari8MAMEPlatform = function(mainElement) {
|
||||
this.getDefaultExtension = function() { return ".c"; };
|
||||
}
|
||||
|
||||
var Atari800Platform = function(mainElement) {
|
||||
var Atari800MAMEPlatform = function(mainElement) {
|
||||
var self = this;
|
||||
this.__proto__ = new Atari8MAMEPlatform(mainElement);
|
||||
|
||||
@ -45,7 +586,7 @@ var Atari800Platform = function(mainElement) {
|
||||
}
|
||||
}
|
||||
|
||||
var Atari5200Platform = function(mainElement) {
|
||||
var Atari5200MAMEPlatform = function(mainElement) {
|
||||
var self = this;
|
||||
this.__proto__ = new (Atari8MAMEPlatform as any)(mainElement);
|
||||
|
||||
@ -65,8 +606,148 @@ var Atari5200Platform = function(mainElement) {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
const ATARI_NTSC_RGB = [
|
||||
0x000000, // 00
|
||||
0x404040, // 02
|
||||
0x6c6c6c, // 04
|
||||
0x909090, // 06
|
||||
0xb0b0b0, // 08
|
||||
0xc8c8c8, // 0A
|
||||
0xdcdcdc, // 0C
|
||||
0xf4f4f4, // 0E
|
||||
0x004444, // 10
|
||||
0x106464, // 12
|
||||
0x248484, // 14
|
||||
0x34a0a0, // 16
|
||||
0x40b8b8, // 18
|
||||
0x50d0d0, // 1A
|
||||
0x5ce8e8, // 1C
|
||||
0x68fcfc, // 1E
|
||||
0x002870, // 20
|
||||
0x144484, // 22
|
||||
0x285c98, // 24
|
||||
0x3c78ac, // 26
|
||||
0x4c8cbc, // 28
|
||||
0x5ca0cc, // 2A
|
||||
0x68b4dc, // 2C
|
||||
0x78c8ec, // 2E
|
||||
0x001884, // 30
|
||||
0x183498, // 32
|
||||
0x3050ac, // 34
|
||||
0x4868c0, // 36
|
||||
0x5c80d0, // 38
|
||||
0x7094e0, // 3A
|
||||
0x80a8ec, // 3C
|
||||
0x94bcfc, // 3E
|
||||
0x000088, // 40
|
||||
0x20209c, // 42
|
||||
0x3c3cb0, // 44
|
||||
0x5858c0, // 46
|
||||
0x7070d0, // 48
|
||||
0x8888e0, // 4A
|
||||
0xa0a0ec, // 4C
|
||||
0xb4b4fc, // 4E
|
||||
0x5c0078, // 50
|
||||
0x74208c, // 52
|
||||
0x883ca0, // 54
|
||||
0x9c58b0, // 56
|
||||
0xb070c0, // 58
|
||||
0xc084d0, // 5A
|
||||
0xd09cdc, // 5C
|
||||
0xe0b0ec, // 5E
|
||||
0x780048, // 60
|
||||
0x902060, // 62
|
||||
0xa43c78, // 64
|
||||
0xb8588c, // 66
|
||||
0xcc70a0, // 68
|
||||
0xdc84b4, // 6A
|
||||
0xec9cc4, // 6C
|
||||
0xfcb0d4, // 6E
|
||||
0x840014, // 70
|
||||
0x982030, // 72
|
||||
0xac3c4c, // 74
|
||||
0xc05868, // 76
|
||||
0xd0707c, // 78
|
||||
0xe08894, // 7A
|
||||
0xeca0a8, // 7C
|
||||
0xfcb4bc, // 7E
|
||||
0x880000, // 80
|
||||
0x9c201c, // 82
|
||||
0xb04038, // 84
|
||||
0xc05c50, // 86
|
||||
0xd07468, // 88
|
||||
0xe08c7c, // 8A
|
||||
0xeca490, // 8C
|
||||
0xfcb8a4, // 8E
|
||||
0x7c1800, // 90
|
||||
0x90381c, // 92
|
||||
0xa85438, // 94
|
||||
0xbc7050, // 96
|
||||
0xcc8868, // 98
|
||||
0xdc9c7c, // 9A
|
||||
0xecb490, // 9C
|
||||
0xfcc8a4, // 9E
|
||||
0x5c2c00, // A0
|
||||
0x784c1c, // A2
|
||||
0x906838, // A4
|
||||
0xac8450, // A6
|
||||
0xc09c68, // A8
|
||||
0xd4b47c, // AA
|
||||
0xe8cc90, // AC
|
||||
0xfce0a4, // AE
|
||||
0x2c3c00, // B0
|
||||
0x485c1c, // B2
|
||||
0x647c38, // B4
|
||||
0x809c50, // B6
|
||||
0x94b468, // B8
|
||||
0xacd07c, // BA
|
||||
0xc0e490, // BC
|
||||
0xd4fca4, // BE
|
||||
0x003c00, // C0
|
||||
0x205c20, // C2
|
||||
0x407c40, // C4
|
||||
0x5c9c5c, // C6
|
||||
0x74b474, // C8
|
||||
0x8cd08c, // CA
|
||||
0xa4e4a4, // CC
|
||||
0xb8fcb8, // CE
|
||||
0x003814, // D0
|
||||
0x1c5c34, // D2
|
||||
0x387c50, // D4
|
||||
0x50986c, // D6
|
||||
0x68b484, // D8
|
||||
0x7ccc9c, // DA
|
||||
0x90e4b4, // DC
|
||||
0xa4fcc8, // DE
|
||||
0x00302c, // E0
|
||||
0x1c504c, // E2
|
||||
0x347068, // E4
|
||||
0x4c8c84, // E6
|
||||
0x64a89c, // E8
|
||||
0x78c0b4, // EA
|
||||
0x88d4cc, // EC
|
||||
0x9cece0, // EE
|
||||
0x002844, // F0
|
||||
0x184864, // F2
|
||||
0x306884, // F4
|
||||
0x4484a0, // F6
|
||||
0x589cb8, // F8
|
||||
0x6cb4d0, // FA
|
||||
0x7ccce8, // FC
|
||||
0x8ce0fc // FE
|
||||
];
|
||||
|
||||
var COLORS_RGBA = new Uint32Array(256);
|
||||
var COLORS_WEB = [];
|
||||
for (var i=0; i<256; i++) {
|
||||
COLORS_RGBA[i] = ATARI_NTSC_RGB[i>>1] | 0xff000000;
|
||||
COLORS_WEB[i] = "#"+hex(rgb2bgr(ATARI_NTSC_RGB[i>>1]),6);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
PLATFORMS['atari8-800'] = Atari800Platform;
|
||||
PLATFORMS['atari8-5200'] = Atari5200Platform;
|
||||
PLATFORMS['atari8-5200'] = _Atari5200Platform;
|
||||
PLATFORMS['atari8-800.mame'] = Atari800MAMEPlatform;
|
||||
PLATFORMS['atari8-5200.mame'] = Atari5200MAMEPlatform;
|
||||
|
@ -127,6 +127,7 @@ abstract class VerilatorBase {
|
||||
maxVclockLoop = 0;
|
||||
clk = 0;
|
||||
reset = 0;
|
||||
enable?;
|
||||
|
||||
vl_fatal(msg:string) {
|
||||
console.log(msg);
|
||||
@ -136,6 +137,9 @@ abstract class VerilatorBase {
|
||||
setTicks(T:number) { this.totalTicks = T|0; }
|
||||
|
||||
__reset() {
|
||||
if (this.enable !== undefined) {
|
||||
this.enable = 1; // enable enable if defined
|
||||
}
|
||||
if (this.reset !== undefined) {
|
||||
this.totalTicks = 0;
|
||||
this.reset = 0;
|
||||
@ -595,6 +599,9 @@ var VerilogPlatform = function(mainElement, options) {
|
||||
if (this.hasvideo) {
|
||||
const IGNORE_SIGNALS = ['clk','reset'];
|
||||
trace_signals = trace_signals.filter((v) => { return IGNORE_SIGNALS.indexOf(v.name)<0; }); // remove clk, reset
|
||||
$("#speed_bar").show();
|
||||
} else {
|
||||
$("#speed_bar").hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -891,7 +891,6 @@ function setupDebugControls(){
|
||||
$("#item_download_allzip").click(_downloadAllFilesZipFile);
|
||||
$("#item_record_video").click(_recordVideo);
|
||||
if (platform.setFrameRate && platform.getFrameRate) {
|
||||
$("#speed_bar").show();
|
||||
$("#dbg_slower").click(_slowerFrameRate);
|
||||
$("#dbg_faster").click(_fasterFrameRate);
|
||||
$("#dbg_slowest").click(_slowestFrameRate);
|
||||
|
@ -372,3 +372,7 @@ export function printFlags(val:number, names:string[], r2l:boolean) {
|
||||
return s;
|
||||
}
|
||||
|
||||
export function rgb2bgr(x) {
|
||||
return ((x&0xff)<<16) | ((x>>16)&0xff) | (x&0x00ff00);
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ export class MemoryView implements ProjectView {
|
||||
w: $(workspace).width(),
|
||||
h: $(workspace).height(),
|
||||
itemHeight: getVisibleEditorLineHeight(),
|
||||
totalRows: 0x1000,
|
||||
totalRows: 0x2000,
|
||||
generatorFn: (row : number) => {
|
||||
var s = this.getMemoryLineAt(row);
|
||||
var linediv = document.createElement("div");
|
||||
@ -598,8 +598,7 @@ export class MemoryView implements ProjectView {
|
||||
|
||||
refresh() {
|
||||
this.dumplines = null;
|
||||
this.memorylist.clear();
|
||||
//this.tick();
|
||||
this.tick();
|
||||
}
|
||||
|
||||
tick() {
|
||||
@ -631,7 +630,7 @@ export class MemoryView implements ProjectView {
|
||||
return '.';
|
||||
}
|
||||
}
|
||||
var s = hex(offset,4) + ' ';
|
||||
var s = hex(offset+n1,4) + ' ';
|
||||
for (var i=0; i<n1; i++) s += ' ';
|
||||
if (n1 > 8) s += ' ';
|
||||
for (var i=n1; i<n2; i++) {
|
||||
|
11
src/vlist.js
11
src/vlist.js
@ -161,14 +161,3 @@ VirtualList.prototype.scrollToItem = function(index) {
|
||||
this.container.scrollTop = this.itemHeight * index;
|
||||
};
|
||||
|
||||
VirtualList.prototype.clear = function() {
|
||||
var badNodes = document.querySelectorAll('[data-index]');
|
||||
for (var i = 0, l = badNodes.length; i < l; i++) {
|
||||
try {
|
||||
this.container.removeChild(badNodes[i]);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
this._renderChunk(this.container, 0);
|
||||
};
|
||||
|
@ -175,7 +175,6 @@ export class WaveformView {
|
||||
// clear to black
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
// draw waveform
|
||||
ctx.strokeStyle = ctx.fillStyle = "#66ff66";
|
||||
var fh = 12;
|
||||
var b1 = fh+4;
|
||||
var b2 = 4;
|
||||
@ -185,6 +184,9 @@ export class WaveformView {
|
||||
this.clockMax = Math.max(this.clockMax, this.t0 + data.length);
|
||||
var printvals = meta.len > 1 && this.zoom >= 32;
|
||||
var ycen = b1+h2-1;
|
||||
ctx.fillStyle = "#336633";
|
||||
ctx.fillRect(0, fh/2, 3, b1+h2-fh/2); // draw left tag
|
||||
ctx.strokeStyle = ctx.fillStyle = "#66ff66";
|
||||
// draw waveform
|
||||
ctx.beginPath();
|
||||
var x = 0;
|
||||
|
@ -40,6 +40,7 @@ var _vector = require('gen/platform/vector.js');
|
||||
var _williams = require('gen/platform/williams.js');
|
||||
var _sound_williams = require('gen/platform/sound_williams.js');
|
||||
var _astrocade = require('gen/platform/astrocade.js');
|
||||
var _atari8 = require('gen/platform/atari8.js');
|
||||
|
||||
//
|
||||
|
||||
@ -220,6 +221,13 @@ describe('Platform Replay', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
it('Should run atari8-5200', () => {
|
||||
var platform = testPlatform('atari8-5200', 'hello.a.rom', 92, (platform, frameno) => {
|
||||
if (frameno == 62) {
|
||||
keycallback(Keys.VK_SPACE.c, Keys.VK_SPACE.c, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user