"use strict"; var EXIDY_PRESETS = [ ]; var ExidyPlatform = function(mainElement) { var self = this; var cpuFrequency = 705562; var cyclesPerFrame = Math.round(cpuFrequency/60); var vblankCyclesPerFrame = Math.round(cpuFrequency*3/(262.5*60)); var cpu, ram, bus, rom; var video, ap2disp, audio, timer; var port_dsw = 0; var PGM_BASE = 0x1000; // where to JMP after pr#6 this.getPresets = function() { return EXIDY_PRESETS; } this.start = function() { cpu = new jt.M6502(); ram = new RAM(0x200); // 64K + 16K LC RAM - 4K hardware rom = new RAM(0x1000); // bus bus = { read: function(address) { address &= 0xffff; if (address < ram.mem.length) { return ram.mem[address]; } else if (address >= 0x1000 && address <= 0x1fff) { return rom.mem[address - 0x1000]; } else if (address >= 0xf000) { return rom.mem[address - 0xf000]; } else if (address == 0xc000) { return port_dsw; } return 0; }, write: function(address, val) { address &= 0xffff; val &= 0xff; if (address < ram.mem.length) { ram.mem[address] = val; } } }; cpu.connectBus(bus); // create video/audio video = new RasterVideo(mainElement,256,256); video.start(); audio = new SampleAudio(cpuFrequency); // TODO audio.start(); var idata = video.getFrameData(); timer = new AnimationTimer(60, function() { var clock = 0; breakClock = -1; for (var i=0; i debugTargetClock) { var thisState = cpu.saveState(); if (previousPC < 0) { previousPC = thisState.PC; } else { if (thisState.PC != previousPC && thisState.T == 0) { //console.log(previousPC.toString(16), thisPC.toString(16)); debugTargetClock = debugClock-1; self.breakpointHit(); return true; } } } return false; }); } this.runEval = function(evalfunc) { var self = this; self.setDebugCondition(function() { if (debugClock++ > debugTargetClock) { var cpuState = cpu.saveState(); cpuState.PC = (cpuState.PC-1)&0xffff; if (evalfunc(cpuState)) { self.breakpointHit(); debugTargetClock = debugClock; return true; } else { return false; } } }); } this.loadState = function(state) { cpu.loadState(state.c); ram.mem.set(state.b); } this.saveState = function() { return { c:cpu.saveState(), b:ram.mem.slice(0), }; } this.getRAMForState = function(state) { return ram.mem; } };