more platform tests
This commit is contained in:
parent
a071cd80db
commit
8bb67e5610
|
@ -1 +1 @@
|
||||||
Subproject commit 67d15ccb4940c0049fcd6444a72316148056e5b3
|
Subproject commit 8f5767e4ca9a759d759e9a09677d649d58f6aff7
|
|
@ -21,7 +21,7 @@ export interface CpuState {
|
||||||
};
|
};
|
||||||
export interface EmuState {
|
export interface EmuState {
|
||||||
c:CpuState, // CPU state
|
c:CpuState, // CPU state
|
||||||
b?:number[] // RAM
|
b?:number[] // RAM (TODO: not for vcs)
|
||||||
};
|
};
|
||||||
export interface EmuControlsState {
|
export interface EmuControlsState {
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ Javatari.AUDIO_BUFFER_SIZE = 256;
|
||||||
|
|
||||||
class VCSPlatform {
|
class VCSPlatform {
|
||||||
|
|
||||||
current_output;
|
|
||||||
recorder : EmuRecorder;
|
recorder : EmuRecorder;
|
||||||
paused : boolean = true;
|
paused : boolean = true;
|
||||||
|
|
||||||
|
@ -70,7 +69,6 @@ class VCSPlatform {
|
||||||
|
|
||||||
loadROM(title, data) {
|
loadROM(title, data) {
|
||||||
Javatari.loadROM(title, data);
|
Javatari.loadROM(title, data);
|
||||||
this.current_output = data; // TODO: use bus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpcodeMetadata(opcode, offset) {
|
getOpcodeMetadata(opcode, offset) {
|
||||||
|
@ -155,9 +153,11 @@ class VCSPlatform {
|
||||||
loadControlsState(state) {
|
loadControlsState(state) {
|
||||||
Javatari.room.console.loadControlsState(state);
|
Javatari.room.console.loadControlsState(state);
|
||||||
}
|
}
|
||||||
// TODO: load/save controls state
|
|
||||||
readAddress(addr) {
|
readAddress(addr) {
|
||||||
return this.current_output[addr & 0xfff]; // TODO: use bus to read
|
return Javatari.room.console.readAddress(addr);
|
||||||
|
}
|
||||||
|
writeAddress(addr,value) {
|
||||||
|
Javatari.room.console.writeAddress(addr,value);
|
||||||
}
|
}
|
||||||
runUntilReturn() {
|
runUntilReturn() {
|
||||||
var depth = 1;
|
var depth = 1;
|
||||||
|
|
|
@ -106,8 +106,12 @@ var AtariVectorPlatform = function(mainElement) {
|
||||||
dvg = new DVGBWStateMachine(bus, video, 0x4000);
|
dvg = new DVGBWStateMachine(bus, video, 0x4000);
|
||||||
audio = newPOKEYAudio();
|
audio = newPOKEYAudio();
|
||||||
video.create();
|
video.create();
|
||||||
timer = new AnimationTimer(60, function() {
|
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||||
video.clear();
|
setKeyboardFromMap(video, switches, ASTEROIDS_KEYCODE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.advance = function(novideo) {
|
||||||
|
if (!novideo) video.clear();
|
||||||
var debugCond = self.getDebugCallback();
|
var debugCond = self.getDebugCallback();
|
||||||
clock = 0;
|
clock = 0;
|
||||||
for (var i=0; i<cpuCyclesPerFrame; i++) {
|
for (var i=0; i<cpuCyclesPerFrame; i++) {
|
||||||
|
@ -123,9 +127,6 @@ var AtariVectorPlatform = function(mainElement) {
|
||||||
//cpu.executeInstruction();
|
//cpu.executeInstruction();
|
||||||
}
|
}
|
||||||
//if (++watchdog == 256) { watchdog = 0; cpu.reset(); }
|
//if (++watchdog == 256) { watchdog = 0; cpu.reset(); }
|
||||||
self.restartDebugState();
|
|
||||||
});
|
|
||||||
setKeyboardFromMap(video, switches, ASTEROIDS_KEYCODE_MAP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadROM = function(title, data) {
|
this.loadROM = function(title, data) {
|
||||||
|
@ -257,8 +258,12 @@ var AtariColorVectorPlatform = function(mainElement) {
|
||||||
dvg = new DVGColorStateMachine(bus, video, 0x2000);
|
dvg = new DVGColorStateMachine(bus, video, 0x2000);
|
||||||
audio = newPOKEYAudio();
|
audio = newPOKEYAudio();
|
||||||
video.create();
|
video.create();
|
||||||
timer = new AnimationTimer(60, function() {
|
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||||
video.clear();
|
setKeyboardFromMap(video, switches, GRAVITAR_KEYCODE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.advance = function(novideo) {
|
||||||
|
if (!novideo) video.clear();
|
||||||
var debugCond = self.getDebugCallback();
|
var debugCond = self.getDebugCallback();
|
||||||
clock = 0;
|
clock = 0;
|
||||||
for (var i=0; i<cpuCyclesPerFrame; i++) {
|
for (var i=0; i<cpuCyclesPerFrame; i++) {
|
||||||
|
@ -274,9 +279,6 @@ var AtariColorVectorPlatform = function(mainElement) {
|
||||||
cpu.clockPulse();
|
cpu.clockPulse();
|
||||||
//cpu.executeInstruction();
|
//cpu.executeInstruction();
|
||||||
}
|
}
|
||||||
self.restartDebugState();
|
|
||||||
});
|
|
||||||
setKeyboardFromMap(video, switches, GRAVITAR_KEYCODE_MAP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadROM = function(title, data) {
|
this.loadROM = function(title, data) {
|
||||||
|
@ -396,18 +398,19 @@ var Z80ColorVectorPlatform = function(mainElement, proto) {
|
||||||
dvg = new DVGColorStateMachine(bus, video, 0xa000);
|
dvg = new DVGColorStateMachine(bus, video, 0xa000);
|
||||||
audio = newPOKEYAudio();
|
audio = newPOKEYAudio();
|
||||||
video.create();
|
video.create();
|
||||||
timer = new AnimationTimer(60, function() {
|
timer = new AnimationTimer(60, this.nextFrame.bind(this));
|
||||||
video.clear();
|
setKeyboardFromMap(video, switches, GRAVITAR_KEYCODE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.advance = function(novideo) {
|
||||||
|
if (!novideo) video.clear();
|
||||||
self.runCPU(cpu, cpuCyclesPerFrame);
|
self.runCPU(cpu, cpuCyclesPerFrame);
|
||||||
cpu.requestInterrupt();
|
cpu.requestInterrupt();
|
||||||
self.restartDebugState();
|
|
||||||
switches[0xf] = (switches[0xf] + 1) & 0x3;
|
switches[0xf] = (switches[0xf] + 1) & 0x3;
|
||||||
if (--switches[0xe] <= 0) {
|
if (--switches[0xe] <= 0) {
|
||||||
console.log("WATCHDOG FIRED"); // TODO: alert on video
|
console.log("WATCHDOG FIRED"); // TODO: alert on video
|
||||||
self.reset(); // watchdog reset
|
self.reset(); // watchdog reset
|
||||||
}
|
}
|
||||||
});
|
|
||||||
setKeyboardFromMap(video, switches, GRAVITAR_KEYCODE_MAP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadROM = function(title, data) {
|
this.loadROM = function(title, data) {
|
||||||
|
|
|
@ -30,10 +30,15 @@ var emu = require('gen/emu.js');
|
||||||
var Keys = emu.Keys;
|
var Keys = emu.Keys;
|
||||||
var audio = require('gen/audio.js');
|
var audio = require('gen/audio.js');
|
||||||
var recorder = require('gen/recorder.js');
|
var recorder = require('gen/recorder.js');
|
||||||
var _vicdual = require('gen/platform/vicdual.js');
|
|
||||||
var _apple2 = require('gen/platform/apple2.js');
|
var _apple2 = require('gen/platform/apple2.js');
|
||||||
var _vcs = require('gen/platform/vcs.js');
|
var _vcs = require('gen/platform/vcs.js');
|
||||||
var _nes = require('gen/platform/nes.js');
|
var _nes = require('gen/platform/nes.js');
|
||||||
|
var _vicdual = require('gen/platform/vicdual.js');
|
||||||
|
var _mw8080bw = require('gen/platform/mw8080bw.js');
|
||||||
|
var _galaxian = require('gen/platform/galaxian.js');
|
||||||
|
var _vector = require('gen/platform/vector.js');
|
||||||
|
var _williams = require('gen/platform/williams.js');
|
||||||
|
var _sound_williams = require('gen/platform/sound_williams.js');
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -52,13 +57,29 @@ var keycallback;
|
||||||
emu.RasterVideo = function(mainElement, width, height, options) {
|
emu.RasterVideo = function(mainElement, width, height, options) {
|
||||||
var datau32;
|
var datau32;
|
||||||
this.create = function() {
|
this.create = function() {
|
||||||
datau32 = new Uint32Array(width*height);
|
datau32 = new Uint32Array(width*height);
|
||||||
}
|
}
|
||||||
this.setKeyboardEvents = function(callback) {
|
this.setKeyboardEvents = function(callback) {
|
||||||
keycallback = callback;
|
keycallback = callback;
|
||||||
}
|
}
|
||||||
this.getFrameData = function() { return datau32; }
|
this.getFrameData = function() { return datau32; }
|
||||||
this.updateFrame = function() { }
|
this.updateFrame = function() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
emu.VectorVideo = function(mainElement, width, height, options) {
|
||||||
|
this.create = function() {
|
||||||
|
this.drawops = 0;
|
||||||
|
}
|
||||||
|
this.setKeyboardEvents = function(callback) {
|
||||||
|
keycallback = callback;
|
||||||
|
}
|
||||||
|
this.clear = function() { }
|
||||||
|
this.drawLine = function() { this.drawops++; }
|
||||||
|
}
|
||||||
|
|
||||||
|
global.Worker = function() {
|
||||||
|
this.msgcount = 0;
|
||||||
|
this.postMessage = function() { this.msgcount++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -107,16 +128,68 @@ describe('Platform Replay', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.equal(platform.saveState().p.SA, 0xff ^ 0x40);
|
assert.equal(platform.saveState().p.SA, 0xff ^ 0x40);
|
||||||
|
assert.equal(60, platform.readAddress(0x80)); // player x pos
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should run nes', () => {
|
it('Should run nes', () => {
|
||||||
var platform = testPlatform('nes', 'shoot2.c.rom', 70, (platform, frameno) => {
|
var platform = testPlatform('nes', 'shoot2.c.rom', 70, (platform, frameno) => {
|
||||||
if (frameno == 60) {
|
if (frameno == 60) {
|
||||||
keycallback(Keys.VK_Z.c, Keys.VK_Z.c, 1);
|
keycallback(Keys.VK_LEFT.c, Keys.VK_LEFT.c, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert.equal(65, platform.saveControlsState().c1[0]);
|
assert.equal(120-10, platform.readAddress(0x41d)); // player x pos
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should run vicdual', () => {
|
||||||
|
var platform = testPlatform('vicdual', 'snake1.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_DOWN.c, Keys.VK_DOWN.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should run mw8080bw', () => {
|
||||||
|
var platform = testPlatform('mw8080bw', 'game2.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_LEFT.c, Keys.VK_LEFT.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert.equal(96-9*2, platform.readAddress(0x2006)); // player x pos
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should run galaxian', () => {
|
||||||
|
var platform = testPlatform('galaxian-scramble', 'shoot2.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_LEFT.c, Keys.VK_LEFT.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert.equal(112-10, platform.readAddress(0x4074)); // player x pos
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should run vector', () => {
|
||||||
|
var platform = testPlatform('vector-z80color', 'game.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_UP.c, Keys.VK_UP.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should run williams', () => {
|
||||||
|
var platform = testPlatform('williams-z80', 'game1.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_LEFT.c, Keys.VK_LEFT.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
/*
|
||||||
|
it('Should run sound_williams', () => {
|
||||||
|
var platform = testPlatform('sound_williams-z80', 'swave.c.rom', 70, (platform, frameno) => {
|
||||||
|
if (frameno == 60) {
|
||||||
|
keycallback(Keys.VK_2.c, Keys.VK_2.c, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue