mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-04-20 15:16:38 +00:00
generate z80 cpu on demand like we used to, fix test b/c global.z80 is global
This commit is contained in:
@@ -6,7 +6,7 @@ var PNG = require('pngjs').PNG;
|
||||
|
||||
const jsdom = require('jsdom');
|
||||
const { JSDOM } = jsdom;
|
||||
const { window } = new JSDOM();
|
||||
//const { window } = new JSDOM();
|
||||
|
||||
const dom = new JSDOM(`<!DOCTYPE html><div id="emulator"><div id="javatari-screen"></div></div>`);
|
||||
global.window = dom.window;
|
||||
@@ -14,10 +14,10 @@ global.document = dom.window.document;
|
||||
dom.window.Audio = null;
|
||||
global.Image = function() { }
|
||||
global['$'] = require("jquery/jquery-2.2.3.min.js");
|
||||
global.includeInThisContext('src/cpu/z80fast.js');
|
||||
includeInThisContext('src/cpu/z80.js');
|
||||
global['buildZ80'] = global.window.buildZ80;
|
||||
includeInThisContext("javatari.js/release/javatari/javatari.js");
|
||||
Javatari.AUTO_START = false;
|
||||
includeInThisContext('src/cpu/z80fast.js');
|
||||
includeInThisContext('tss/js/Log.js');
|
||||
//global.Log = require('tss/js/Log.js').Log;
|
||||
includeInThisContext('tss/js/tss/PsgDeviceChannel.js');
|
||||
|
||||
+11
-16
@@ -1,17 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
if (true) {
|
||||
global.window = global;
|
||||
require('../../../src/cpu/z80.js');
|
||||
var _global = window;
|
||||
_global.buildZ80({
|
||||
applyContention: true
|
||||
});
|
||||
} else {
|
||||
var wtu = require('../workertestutils.js');
|
||||
global.includeInThisContext('src/cpu/z80fast.js');
|
||||
var _global = {Z80:Z80_fast};
|
||||
}
|
||||
var wtu = require('../workertestutils.js');
|
||||
includeInThisContext('src/cpu/z80.js');
|
||||
if (!global.buildZ80) global.buildZ80 = global.window.buildZ80;
|
||||
|
||||
var Memory = function(dump) {
|
||||
var self = {};
|
||||
@@ -99,7 +90,7 @@ function runTest(input, expected) {
|
||||
|
||||
var memory = Memory(dump);
|
||||
var ioBus = IOBus();
|
||||
var z80 = _global.Z80({
|
||||
var z80 = global.Z80({
|
||||
display: {},
|
||||
memory: memory,
|
||||
ioBus: ioBus
|
||||
@@ -208,7 +199,7 @@ assert(testsIn.length == testsExpected.length);
|
||||
function benchmark(cycles) {
|
||||
var memory = Memory(function() { });
|
||||
var ioBus = IOBus();
|
||||
var z80 = _global.Z80({
|
||||
var z80 = global.Z80({
|
||||
display: {},
|
||||
memory: memory,
|
||||
ioBus: ioBus
|
||||
@@ -223,7 +214,11 @@ function benchmark(cycles) {
|
||||
|
||||
if (global.describe) {
|
||||
describe('Z80 CPU', function() {
|
||||
it('should execute test cases', function() {
|
||||
global.buildZ80({
|
||||
applyContention: true
|
||||
});
|
||||
global.Z80 = global.window.Z80;
|
||||
it('should execute Z80 test cases', function() {
|
||||
for (var iter=0; iter<testsIn.length; iter++) {
|
||||
var fn = function(index, input, expected) {
|
||||
var output = runTest(input);
|
||||
@@ -231,7 +226,7 @@ if (global.describe) {
|
||||
}.call(this, iter, testsIn[iter], testsExpected[iter]);
|
||||
}
|
||||
});
|
||||
it('should run 1M cycles', function() {
|
||||
it('should run Z80 1M cycles', function() {
|
||||
benchmark(1164770);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user