<em>Table</em> Current emulation state with the following structure:</p>
<pre><code>region: int,
clockRate: int,
cpu: {
status: int,
a: int,
irqFlag: int,
cycleCount: int (64-bit, unsigned),
pc: int,
y: int,
x: int,
sp: int,
nmiFlag: bool
},
ppu: {
cycle: int,
scanline: int,
frameCount: int,
control: {
backgroundEnabled: bool,
intensifyBlue: bool,
intensifyRed: bool,
backgroundPatternAddr: int,
grayscale: bool,
verticalWrite: bool,
intensifyGreen: bool,
nmiOnVBlank: bool,
spritesEnabled: bool,
spritePatternAddr: int,
spriteMask: bool,
largeSprites: bool,
backgroundMask: bool
},
status: {,
spriteOverflow: bool,
verticalBlank: bool,
sprite0Hit: bool
},
state: {
status: int,
lowBitShift: int,
xScroll: int,
highBitShift: int,
videoRamAddr: int,
control: int,
mask: int,
tmpVideoRamAddr: int,
writeToggle: bool,
spriteRamAddr: int
}
},
apu: {
square1: {
outputVolume: int,
frequency: float,
duty: int,
period: int,
enabled: bool,
dutyPosition: int,
sweepShift: int,
sweepPeriod: int,
sweepEnabled: bool,
sweepNegate: bool
envelope: {
counter: int,
loop: bool,
divider: int,
volume: int,
startFlag: bool,
constantVolume: bool
},
lengthCounter: {
halt: bool,
counter: int,
reloadValue: int
}
},
square2: {
outputVolume: int,
frequency: float,
duty: int,
period: int,
enabled: bool,
dutyPosition: int,
sweepShift: int,
sweepPeriod: int,
sweepEnabled: bool,
sweepNegate: bool,
envelope: {
counter: int,
loop: bool,
divider: int
volume: int,
startFlag: bool,
constantVolume: bool
},
lengthCounter: {
halt: bool,
counter: int,
reloadValue: int
}
},
triangle: {
outputVolume: int,
frequency: float,
sequencePosition: int,
period: int,
enabled: bool,
lengthCounter: {
halt: bool,
counter: int,
reloadValue: int
}
},
noise: {
modeFlag: bool,
enabled: bool,
outputVolume: int,
frequency: float,
period: int,
shiftRegister: int,
envelope: {
counter: int,
loop: bool,
divider: int,
volume: int,
startFlag: bool,
constantVolume: bool
},
lengthCounter: {
halt: bool,
counter: int,
reloadValue: int
}
},
dmc: {
sampleLength: int,
irqEnabled: bool,
loop: bool,
outputVolume: int,
bytesRemaining: int,
sampleAddr: int,
period: int,
sampleRate: float
},
frameCounter: {
fiveStepMode: int,
irqEnabled: int,
sequencePosition: int
}
},
cart: {
selectedPrgPages: array,
chrRomSize: int,
chrRamSize: int,
prgPageCount: int,
chrPageSize: int,
selectedChrPages: array,
chrPageCount: int,
prgRomSize: int,
prgPageSize: int,
}
</code></pre>
<p><strong>Description</strong><br>
Return a table containing information about the state of the CPU, PPU, APU and cartridge.</p>
<h2id=setstate>setState</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.setState(state)
</code></pre>
<p><strong>Parameters</strong><br>
state - <em>Table</em> A table containing the state of the emulation to apply.</p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Updates the CPU and PPU’s state.
The <em>state</em> parameter must be a table in the same format as the one returned by <ahref=#getstate>getState()</a><br>
<strong>Note:</strong> the state of the APU or cartridge cannot be modified by using setState().</p>
<h2id=breakexecution>breakExecution</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.breakExecution()
</code></pre>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Breaks the execution of the game and displays the debugger window.</p>
<h2id=execute>execute</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.execute(count, type)
</code></pre>
<p><strong>Parameters</strong><br>
count - <em>Integer</em> The number of cycles or instructions to run before breaking<br>
type - <em>Enum</em> See <ahref=../apireference/enums.html#executecounttype>executeCountType</a></p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Runs the emulator for the specified number of cycles/instructions and then breaks the execution.</p>
<h2id=stepout>stepOut</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.stepOut()
</code></pre>
<p><strong>Parameters</strong><br>
<em>None</em></p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Steps over the next instruction and then breaks the execution.</p>
<h2id=stepover>stepOver</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.stepOver()
</code></pre>
<p><strong>Parameters</strong><br>
<em>None</em></p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Steps out of the current subroutine and then breaks the execution.</p>
<h2id=reset>reset</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.reset()
</code></pre>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Resets the current game.</p>
<h2id=stop>stop</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.stop(exitCode)
</code></pre>
<p><strong>Parameters</strong><br>
exitCode - <em>Integer</em> The exit code that the Mesen process will return when exiting (when used in <ahref=../apireference.html#test-runner-mode>test runner mode</a>)</p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Stops and unloads the current game. When in <ahref=../apireference.html#test-runner-mode>test runner mode</a>, this will also exit Mesen itself and the Mesen process will return the specified exit code.</p>
<h2id=resume>resume</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.resume()
</code></pre>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Resumes execution after breaking.</p>
<h2id=rewind>rewind</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.rewind(seconds)
</code></pre>
<p><strong>Parameters</strong><br>
seconds - <em>Integer</em> The number of seconds to rewind</p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Instantly rewinds the emulation by the number of seconds specified.<br>
<strong>Note:</strong> this can only be called from within a “StartFrame” event callback.</p>