mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-23 03:29:05 +00:00
use Z80 emulation from https://github.com/DrGoldfire/Z80.js for better performance
This commit is contained in:
parent
ecd7f364a6
commit
5323862172
@ -480,7 +480,7 @@ export function cpuStateToLongString_Z80(c) {
|
|||||||
function decodeFlags(flags) {
|
function decodeFlags(flags) {
|
||||||
return printFlags(flags, ["S","Z",,"H",,"V","N","C"], true);
|
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"
|
+ "SP " + hex(c.SP,4) + " IR " + hex(c.IR,4) + "\n"
|
||||||
+ "IX " + hex(c.IX,4) + " IY " + hex(c.IY,4) + "\n"
|
+ "IX " + hex(c.IX,4) + " IY " + hex(c.IY,4) + "\n"
|
||||||
+ "AF " + hex(c.AF,4) + " BC " + hex(c.BC,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();
|
this.audio && this.audio.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO: reset target clock counter
|
||||||
breakpointHit(targetClock : number) {
|
breakpointHit(targetClock : number) {
|
||||||
console.log(this.debugTargetClock, targetClock, this.debugClock, this.machine.cpu.isStable());
|
console.log(this.debugTargetClock, targetClock, this.debugClock, this.machine.cpu.isStable());
|
||||||
this.debugTargetClock = targetClock;
|
this.debugTargetClock = targetClock;
|
||||||
@ -1305,6 +1305,7 @@ export abstract class BaseZ80MachinePlatform<T extends Machine> extends BaseMach
|
|||||||
console.log(sp,start,end);
|
console.log(sp,start,end);
|
||||||
return dumpStackToString(<Platform><any>this, [], start, end, sp, 0xcd);
|
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 {
|
disassemble(pc:number, read:(addr:number)=>number) : DisasmLine {
|
||||||
|
5039
src/cpu/ZilogZ80.ts
5039
src/cpu/ZilogZ80.ts
File diff suppressed because one or more lines are too long
@ -181,7 +181,7 @@ export class MSX1 extends BaseZ80VDPBasedMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vdpInterrupt() {
|
vdpInterrupt() {
|
||||||
this.cpu.interrupt(0x38);
|
this.cpu.interrupt(0xff); // RST 0x38
|
||||||
}
|
}
|
||||||
|
|
||||||
loadState(state) {
|
loadState(state) {
|
||||||
|
@ -118,9 +118,9 @@ export class Midway8080 extends BasicScanlineMachine {
|
|||||||
drawScanline() {
|
drawScanline() {
|
||||||
// at end of scanline
|
// at end of scanline
|
||||||
if (this.scanline == 95)
|
if (this.scanline == 95)
|
||||||
this.cpu.interrupt(0x8); // RST $8
|
this.cpu.interrupt(0xcf); // RST $8
|
||||||
else if (this.scanline == 223)
|
else if (this.scanline == 223)
|
||||||
this.cpu.interrupt(0x10); // RST $10
|
this.cpu.interrupt(0xd7); // RST $10
|
||||||
}
|
}
|
||||||
|
|
||||||
advanceFrame(maxCycles, trap) : number {
|
advanceFrame(maxCycles, trap) : number {
|
||||||
|
@ -43,7 +43,11 @@ export class SG1000 extends BaseZ80VDPBasedMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKeyboardMap() { return SG1000_KEYCODE_MAP; }
|
getKeyboardMap() { return SG1000_KEYCODE_MAP; }
|
||||||
vdpInterrupt() { return this.cpu.NMI(); }
|
|
||||||
|
vdpInterrupt() {
|
||||||
|
return this.cpu.interrupt(0xff); // RST 0x38
|
||||||
|
//return this.cpu.NMI();
|
||||||
|
}
|
||||||
|
|
||||||
read = newAddressDecoder([
|
read = newAddressDecoder([
|
||||||
[0xc000, 0xffff, 0x3ff, (a) => { return this.ram[a]; }],
|
[0xc000, 0xffff, 0x3ff, (a) => { return this.ram[a]; }],
|
||||||
@ -216,7 +220,7 @@ export class SMS extends SG1000 {
|
|||||||
}
|
}
|
||||||
getDebugInfo(category, state) {
|
getDebugInfo(category, state) {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case 'CPU':
|
case 'SMS': // TODO
|
||||||
return super.getDebugInfo(category, state) +
|
return super.getDebugInfo(category, state) +
|
||||||
"\nBank Regs: " + this.pagingRegisters + "\n";
|
"\nBank Regs: " + this.pagingRegisters + "\n";
|
||||||
default: return super.getDebugInfo(category, state);
|
default: return super.getDebugInfo(category, state);
|
||||||
|
@ -26,6 +26,7 @@ class ColecoVisionPlatform extends BaseZ80MachinePlatform<ColecoVision> implemen
|
|||||||
getPresets() { return ColecoVision_PRESETS; }
|
getPresets() { return ColecoVision_PRESETS; }
|
||||||
getDefaultExtension() { return ".c"; };
|
getDefaultExtension() { return ".c"; };
|
||||||
readAddress(a) { return this.machine.read(a); }
|
readAddress(a) { return this.machine.read(a); }
|
||||||
|
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
|
||||||
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
|
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ class MSXPlatform extends BaseZ80MachinePlatform<MSX1> implements Platform {
|
|||||||
getPresets() { return MSX_BIOS_PRESETS; }
|
getPresets() { return MSX_BIOS_PRESETS; }
|
||||||
getDefaultExtension() { return ".c"; };
|
getDefaultExtension() { return ".c"; };
|
||||||
readAddress(a) { return this.machine.read(a); }
|
readAddress(a) { return this.machine.read(a); }
|
||||||
|
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
|
||||||
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
|
// TODO loadBios(bios) { this.machine.loadBIOS(a); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ class SG1000Platform extends BaseZ80MachinePlatform<SG1000> implements Platform
|
|||||||
getPresets() { return SG1000_PRESETS; }
|
getPresets() { return SG1000_PRESETS; }
|
||||||
getDefaultExtension() { return ".c"; };
|
getDefaultExtension() { return ".c"; };
|
||||||
readAddress(a) { return this.machine.read(a); }
|
readAddress(a) { return this.machine.read(a); }
|
||||||
|
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SMSPlatform extends BaseZ80MachinePlatform<SMS> implements Platform {
|
class SMSPlatform extends BaseZ80MachinePlatform<SMS> implements Platform {
|
||||||
@ -42,6 +43,7 @@ class SMSPlatform extends BaseZ80MachinePlatform<SMS> implements Platform {
|
|||||||
getPresets() { return SMS_PRESETS; }
|
getPresets() { return SMS_PRESETS; }
|
||||||
getDefaultExtension() { return ".c"; };
|
getDefaultExtension() { return ".c"; };
|
||||||
readAddress(a) { return this.machine.read(a); }
|
readAddress(a) { return this.machine.read(a); }
|
||||||
|
readVRAMAddress(a) { return this.machine.readVRAMAddress(a); }
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -30,7 +30,7 @@ describe('ZilogZ80', function() {
|
|||||||
cpu.reset();
|
cpu.reset();
|
||||||
let cycles = 0;
|
let cycles = 0;
|
||||||
let finish = false;
|
let finish = false;
|
||||||
var maxcyc = runall ? 10000000000 : 1000000;
|
var maxcyc = runall ? 10000000000 : 10000000;
|
||||||
for (var i=0; i<maxcyc; i++) {
|
for (var i=0; i<maxcyc; i++) {
|
||||||
cycles += cpu.advanceInsn(1);
|
cycles += cpu.advanceInsn(1);
|
||||||
var pc = cpu.getPC();
|
var pc = cpu.getPC();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user