sms: better CPU cycle counting

This commit is contained in:
Steven Hugg 2018-12-01 14:14:09 -05:00
parent 403b4264fc
commit 4f0003fe76
4 changed files with 9 additions and 7 deletions

View File

@ -7,7 +7,7 @@ GPLv2
---
https://github.com/gasman/jsspeccy2
Z80 emulator
GPLv3
---

View File

@ -142,7 +142,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<button id="dbg_pause" type="button" title="Pause"><span class="glyphicon glyphicon-pause" aria-hidden="true"></span></button>
<button id="dbg_go" type="button" title="Run"><span class="glyphicon glyphicon-play" aria-hidden="true"></span></button>
<button id="dbg_step" type="button" title="Step"><span class="glyphicon glyphicon-step-forward" aria-hidden="true"></span></button>
<button id="dbg_tovsync" type="button" title="Single Frame"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
<button id="dbg_tovsync" type="button" title="Next Frame/Interrupt"><span class="glyphicon glyphicon-forward" aria-hidden="true"></span></button>
<button id="dbg_toline" type="button" title="Run To Line"><span class="glyphicon glyphicon-save" aria-hidden="true"></span></button>
<button id="dbg_stepout" type="button" title="Step Out of Subroutine"><span class="glyphicon glyphicon-hand-up" aria-hidden="true"></span></button>
<button id="dbg_stepback" type="button" title="Step Backwards"><span class="glyphicon glyphicon-step-backward" aria-hidden="true"></span></button>

View File

@ -166,10 +166,12 @@ class SG1000Platform extends BaseZ80Platform {
}
advance(novideo : boolean) {
var extraCycles = 0;
for (var sl=0; sl<this.numTotalScanlines; sl++) {
this.currentScanline = sl;
this.startLineTstates = this.cpu.getTstates();
this.runCPU(this.cpu, this.cpuCyclesPerLine);
this.startLineTstates = this.cpu.getTstates() + extraCycles;
extraCycles = this.runCPU(this.cpu, this.cpuCyclesPerLine - extraCycles); // TODO: HALT opcode?
//debug//this.video.getFrameData()[sl] = -1>>>extraCycles;
this.vdp.drawScanline(sl);
}
this.video.updateFrame();

View File

@ -501,7 +501,7 @@ export class TMS9918A {
readStatus() : number {
var i = this.statusRegister;
this.statusRegister = 0x1F; // TODO: &= 0x1f?
this.statusRegister = 0x1F; // TODO: & 0x1f?
if (this.interruptsOn) {
this.cru.setVDPInterrupt(false);
}
@ -564,6 +564,7 @@ export class TMS9918A {
s += lpad(row[0], w) + ": $" + hex(row[1],4) + " - $" + hex(row[1]+row[2]-1,4) + "\n";
}
s += lpad("Address Register",w) + ": $" + hex(this.addressRegister,4) + "\n";
s += lpad("Status Register",w) + ": $" + hex(this.statusRegister,2) + "\n";
s += lpad("Screen Mode",w) + ": " + this.screenMode + "\n";
s += lpad("Display On",w) + ": " + this.displayOn + "\n";
if (this.ramMask != 0x3fff)
@ -757,8 +758,7 @@ export class SMSVDP extends TMS9918A {
this.cram.set(state.cram);
}
drawScanline(y:number) {
if (this.screenMode == TMS9918A_Mode.MODE4) // TODO: check for other uses
//this.drawScanlineMode4(y);
if (this.screenMode == TMS9918A_Mode.MODE4)
this.rasterize_line(y); // special mode 4
else
super.drawScanline(y);