mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Wire up tests.
This commit is contained in:
parent
58dbac1a78
commit
9bffd347cc
51
js/test.js
Normal file
51
js/test.js
Normal file
@ -0,0 +1,51 @@
|
||||
import CPU6502 from './cpu6502';
|
||||
import Test6502 from './6502test';
|
||||
import Test65C02 from './65C02test';
|
||||
import { toHex } from './util';
|
||||
|
||||
var SYMBOLS = {};
|
||||
var cpu;
|
||||
var trace = [];
|
||||
var lastPC = 0;
|
||||
var done = false;
|
||||
function traceCB() {
|
||||
var pc = cpu.getPC();
|
||||
done = lastPC == pc;
|
||||
lastPC = pc;
|
||||
var line = cpu.dumpRegisters() + ' ' + cpu.dumpPC(undefined, SYMBOLS);
|
||||
trace.push(line);
|
||||
if (trace.length > 1000) {
|
||||
trace.shift();
|
||||
}
|
||||
}
|
||||
|
||||
window.test6502 = function test6502() {
|
||||
cpu = new CPU6502();
|
||||
var test = new Test6502();
|
||||
cpu.addPageHandler(test);
|
||||
cpu.setPC(0x400);
|
||||
do {
|
||||
cpu.stepCyclesDebug(1000, traceCB);
|
||||
} while (!done);
|
||||
|
||||
if (lastPC == 0x3469) {
|
||||
window.alert('6502 Success!');
|
||||
} else {
|
||||
window.alert('Failed! ' + toHex(lastPC));
|
||||
}
|
||||
};
|
||||
|
||||
window.test65C02 = function test65C02() {
|
||||
cpu = new CPU6502({'65C02': true});
|
||||
var test = new Test65C02();
|
||||
cpu.addPageHandler(test);
|
||||
cpu.setPC(0x400);
|
||||
do {
|
||||
cpu.stepCyclesDebug(1000, traceCB);
|
||||
} while (!done);
|
||||
if (lastPC == 0x24f1) {
|
||||
window.alert('65C02 Success!');
|
||||
} else {
|
||||
window.alert('Failed! ' + toHex(lastPC));
|
||||
}
|
||||
};
|
53
test.html
53
test.html
@ -4,58 +4,7 @@
|
||||
<title>Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="js/util.js"></script>
|
||||
<script src="js/cpu6502.js"></script>
|
||||
<script src="js/6502test.js"></script>
|
||||
<script src="js/65C02test.js"></script>
|
||||
<script>
|
||||
var SYMBOLS = {};
|
||||
var cpu;
|
||||
var trace = [];
|
||||
var lastPC = 0;
|
||||
var done = false;
|
||||
function traceCB() {
|
||||
var pc = cpu.getPC()
|
||||
done = lastPC == pc
|
||||
lastPC = pc
|
||||
var line = cpu.dumpRegisters() + ' ' + cpu.dumpPC(undefined, SYMBOLS);
|
||||
trace.push(line);
|
||||
if (trace.length > 1000) {
|
||||
trace.shift();
|
||||
}
|
||||
}
|
||||
|
||||
function test6502() {
|
||||
cpu = new CPU6502();
|
||||
var test = new Test6502();
|
||||
cpu.addPageHandler(test);
|
||||
cpu.setPC(0x400);
|
||||
do {
|
||||
cpu.stepCyclesDebug(1000, traceCB);
|
||||
} while (!done)
|
||||
|
||||
if (lastPC == 0x3469) {
|
||||
window.alert("6502 Success!")
|
||||
} else {
|
||||
window.alert("Failed! " + toHex(lastPC))
|
||||
}
|
||||
}
|
||||
|
||||
function test65C02() {
|
||||
cpu = new CPU6502({'65C02': true});
|
||||
var test = new Test65C02();
|
||||
cpu.addPageHandler(test);
|
||||
cpu.setPC(0x400);
|
||||
do {
|
||||
cpu.stepCyclesDebug(1000, traceCB);
|
||||
} while (!done)
|
||||
if (lastPC == 0x24f1) {
|
||||
window.alert("65C02 Success!")
|
||||
} else {
|
||||
window.alert("Failed! " + toHex(lastPC))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="dist/test.js"></script>
|
||||
<button onclick="test6502()">Test 6502</button>
|
||||
<button onclick="test65C02()">Test 65C02</button>
|
||||
</body>
|
||||
|
@ -7,9 +7,10 @@ module.exports =
|
||||
entry: {
|
||||
main2: path.resolve('js/main2.js'),
|
||||
main2e: path.resolve('js/main2e.js'),
|
||||
test: path.resolve('js/test.js')
|
||||
},
|
||||
output: {
|
||||
path: path.resolve('dist/'),
|
||||
path: path.resolve('dist/')
|
||||
},
|
||||
devServer: {
|
||||
compress: true,
|
||||
|
Loading…
Reference in New Issue
Block a user