Cleaned up endBurst() and changed yieldCPU() to stop ending bursts prematurely (it only sets the new yield flag now)
This commit is contained in:
parent
1226392d9f
commit
3d36682396
8 changed files with 524 additions and 538 deletions
|
|
@ -963,10 +963,10 @@ class CPU extends Component {
|
|||
if (fReset || timer[1] < 0) {
|
||||
nCycles = this.getMSCycles(ms);
|
||||
/*
|
||||
* We must now confront the following problem: if the CPU is currently executing a burst of cycles,
|
||||
* the number of cycles it has executed in that burst so far must NOT be charged against the cycle
|
||||
* timeout we're about to set. The simplest way to resolve that is to immediately call endBurst()
|
||||
* and bias the cycle timeout by the number of cycles that the burst executed.
|
||||
* If the CPU is currently executing a burst of cycles, the number of cycles it has executed in
|
||||
* that burst so far must NOT be charged against the cycle timeout we're about to set. The simplest
|
||||
* way to resolve that is to immediately call endBurst() and bias the cycle timeout by the number
|
||||
* of cycles that the burst executed.
|
||||
*/
|
||||
if (this.flags.running) {
|
||||
nCycles += this.endBurst();
|
||||
|
|
@ -992,10 +992,10 @@ class CPU extends Component {
|
|||
if (iTimer >= 0 && iTimer < this.aTimers.length) {
|
||||
var timer = this.aTimers[iTimer];
|
||||
/*
|
||||
* We must now confront the following problem: if the CPU is currently executing a burst of cycles,
|
||||
* the number of cycles it has executed in that burst so far must NOT be charged against the cycle
|
||||
* timeout we're about to set. The simplest way to resolve that is to immediately call endBurst()
|
||||
* and bias the cycle timeout by the number of cycles that the burst executed.
|
||||
* If the CPU is currently executing a burst of cycles, the number of cycles it has executed in
|
||||
* that burst so far must NOT be charged against the cycle timeout we're about to set. The simplest
|
||||
* way to resolve that is to immediately call endBurst() and bias the cycle timeout by the number
|
||||
* of cycles that the burst executed.
|
||||
*/
|
||||
if (this.flags.running) {
|
||||
nCycles += this.endBurst();
|
||||
|
|
@ -1123,17 +1123,17 @@ class CPU extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* endBurst(fReset)
|
||||
* endBurst()
|
||||
*
|
||||
* @this {CPU}
|
||||
* @param {boolean} [fReset]
|
||||
* @return {number} (number of cycles executed in the most recent burst)
|
||||
*/
|
||||
endBurst(fReset)
|
||||
endBurst()
|
||||
{
|
||||
var nCycles = this.nBurstCycles -= this.nStepCycles;
|
||||
this.nStepCycles = 0;
|
||||
if (fReset) this.nBurstCycles = 0;
|
||||
var nCycles = this.nBurstCycles - this.nStepCycles;
|
||||
this.nBurstCycles = this.nStepCycles = 0;
|
||||
this.counts.nCyclesThisRun += nCycles;
|
||||
this.nRunCycles += nCycles;
|
||||
return nCycles;
|
||||
}
|
||||
|
||||
|
|
@ -1189,19 +1189,13 @@ class CPU extends Component {
|
|||
/*
|
||||
* Terminate the burst, returning the number of cycles that stepCPU() actually ran.
|
||||
*/
|
||||
nCycles = this.endBurst(true);
|
||||
|
||||
/*
|
||||
* Add nCycles to nCyclesThisRun, as well as nRunCycles (the cycle count since the CPU started).
|
||||
*/
|
||||
this.counts.nCyclesThisRun += nCycles;
|
||||
this.nRunCycles += nCycles;
|
||||
this.updateChecksum(nCycles);
|
||||
nCycles = this.endBurst();
|
||||
|
||||
/*
|
||||
* Update all timers, firing those whose cycle countdowns have reached (or dropped below) zero.
|
||||
*/
|
||||
this.updateTimers(nCycles);
|
||||
this.updateChecksum(nCycles);
|
||||
|
||||
} while (this.flags.running && !this.flags.yield);
|
||||
}
|
||||
|
|
@ -1327,7 +1321,6 @@ class CPU extends Component {
|
|||
*/
|
||||
yieldCPU()
|
||||
{
|
||||
this.endBurst();
|
||||
this.flags.yield = true;
|
||||
/*
|
||||
* The Debugger calls yieldCPU() after every message() to ensure browser responsiveness, but it looks
|
||||
|
|
|
|||
Loading…
Reference in a new issue