1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-08 08:33:32 +00:00

use Z80 emulation from https://github.com/DrGoldfire/Z80.js for better performance

This commit is contained in:
Steven Hugg 2019-08-25 15:09:21 -04:00
parent ecd7f364a6
commit 5323862172
9 changed files with 3372 additions and 1702 deletions

View File

@ -480,7 +480,7 @@ export function cpuStateToLongString_Z80(c) {
function decodeFlags(flags) {
return printFlags(flags, ["S","Z",,"H",,"V","N","C"], true);
}
return "PC " + hex(c.PC,4) + " " + decodeFlags(c.AF) + "\n"
return "PC " + hex(c.PC,4) + " " + decodeFlags(c.AF) + " " + (c.iff1?"I":"-") + (c.iff2?"I":"-") + "\n"
+ "SP " + hex(c.SP,4) + " IR " + hex(c.IR,4) + "\n"
+ "IX " + hex(c.IX,4) + " IY " + hex(c.IY,4) + "\n"
+ "AF " + hex(c.AF,4) + " BC " + hex(c.BC,4) + "\n"
@ -1193,7 +1193,7 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
this.audio && this.audio.stop();
}
// TODO
// TODO: reset target clock counter
breakpointHit(targetClock : number) {
console.log(this.debugTargetClock, targetClock, this.debugClock, this.machine.cpu.isStable());
this.debugTargetClock = targetClock;
@ -1305,6 +1305,7 @@ export abstract class BaseZ80MachinePlatform<T extends Machine> extends BaseMach
console.log(sp,start,end);
return dumpStackToString(<Platform><any>this, [], start, end, sp, 0xcd);
}
default: return isDebuggable(this.machine) && this.machine.getDebugInfo(category, state);
}
}
disassemble(pc:number, read:(addr:number)=>number) : DisasmLine {

File diff suppressed because one or more lines are too long

View File

@ -181,7 +181,7 @@ export class MSX1 extends BaseZ80VDPBasedMachine {
}
vdpInterrupt() {
this.cpu.interrupt(0x38);
this.cpu.interrupt(0xff); // RST 0x38
}
loadState(state) {

View File

@ -118,9 +118,9 @@ export class Midway8080 extends BasicScanlineMachine {
drawScanline() {
// at end of scanline
if (this.scanline == 95)
this.cpu.interrupt(0x8); // RST $8
this.cpu.interrupt(0xcf); // RST $8
else if (this.scanline == 223)
this.cpu.interrupt(0x10); // RST $10
this.cpu.interrupt(0xd7); // RST $10
}
advanceFrame(maxCycles, trap) : number {

View File

@ -43,7 +43,11 @@ export class SG1000 extends BaseZ80VDPBasedMachine {
}
getKeyboardMap() { return SG1000_KEYCODE_MAP; }
vdpInterrupt() { return this.cpu.NMI(); }
vdpInterrupt() {
return this.cpu.interrupt(0xff); // RST 0x38
//return this.cpu.NMI();
}
read = newAddressDecoder([
[0xc000, 0xffff, 0x3ff, (a) => { return this.ram[a]; }],
@ -216,7 +220,7 @@ export class SMS extends SG1000 {
}
getDebugInfo(category, state) {
switch (category) {
case 'CPU':
case 'SMS': // TODO
return super.getDebugInfo(category, state) +
"\nBank Regs: " + this.pagingRegisters + "\n";
default: return super.getDebugInfo(category, state);

View File

@ -26,6 +26,7 @@ class ColecoVisionPlatform extends BaseZ80MachinePlatform<ColecoVision> implemen
getPresets() { return ColecoVision_PRESETS; }
getDefaultExtension() { return ".c"; };
readAddress(a) { return this.machine.read(a); }
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
}

View File

@ -42,6 +42,7 @@ class MSXPlatform extends BaseZ80MachinePlatform<MSX1> implements Platform {
getPresets() { return MSX_BIOS_PRESETS; }
getDefaultExtension() { return ".c"; };
readAddress(a) { return this.machine.read(a); }
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
}

View File

@ -34,6 +34,7 @@ class SG1000Platform extends BaseZ80MachinePlatform<SG1000> implements Platform
getPresets() { return SG1000_PRESETS; }
getDefaultExtension() { return ".c"; };
readAddress(a) { return this.machine.read(a); }
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
}
class SMSPlatform extends BaseZ80MachinePlatform<SMS> implements Platform {
@ -42,6 +43,7 @@ class SMSPlatform extends BaseZ80MachinePlatform<SMS> implements Platform {
getPresets() { return SMS_PRESETS; }
getDefaultExtension() { return ".c"; };
readAddress(a) { return this.machine.read(a); }
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
}
///

View File

@ -30,7 +30,7 @@ describe('ZilogZ80', function() {
cpu.reset();
let cycles = 0;
let finish = false;
var maxcyc = runall ? 10000000000 : 1000000;
var maxcyc = runall ? 10000000000 : 10000000;
for (var i=0; i<maxcyc; i++) {
cycles += cpu.advanceInsn(1);
var pc = cpu.getPC();