568 lines
No EOL
16 KiB
HTML
568 lines
No EOL
16 KiB
HTML
<!doctype html><html lang=en class="js csstransforms3d">
|
|
<head>
|
|
<meta charset=utf-8>
|
|
<meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
|
|
<meta name=generator content="Hugo 0.89.4">
|
|
<meta name=description content>
|
|
<link rel="shortcut icon" href=../images/favicon.png type=image/x-icon>
|
|
<link rel=icon href=../images/favicon.png type=image/x-icon>
|
|
<title>Emulation :: Mesen Documentation</title>
|
|
<link href=../css/nucleus.css?1637878444 rel=stylesheet>
|
|
<link href=../css/font-awesome.min.css?1637878444 rel=stylesheet>
|
|
<link href=../css/hybrid.css?1637878444 rel=stylesheet>
|
|
<link href=../css/featherlight.min.css?1637878444 rel=stylesheet>
|
|
<link href=../css/perfect-scrollbar.min.css?1637878444 rel=stylesheet>
|
|
<link href=../css/horsey.css?1637878444 rel=stylesheet>
|
|
<link href=../css/theme.css?1637878444 rel=stylesheet>
|
|
<link href=../css/hugo-theme.css?1637878444 rel=stylesheet>
|
|
<link href=../css/custom.css?1637878444 rel=stylesheet>
|
|
<link href=../css/theme-green.css?1637878444 rel=stylesheet>
|
|
<script src=../js/jquery-2.x.min.js?1637878444></script>
|
|
<style type=text/css>:root #header+#content>#left>#rlblock_left{display:none!important}</style>
|
|
</head>
|
|
<body data-url=../apireference/emulation.html>
|
|
<nav id=sidebar>
|
|
<div id=header-wrapper>
|
|
<div id=header>
|
|
<a id=logo href=../index.html>
|
|
<img src=../images/MesenIcon.png>
|
|
</a>
|
|
</div>
|
|
<div class=searchbox>
|
|
<label for=search-by><i class="fa fa-search"></i></label>
|
|
<input data-search-input id=search-by type=text placeholder=Search...>
|
|
<span data-search-clear><i class="fa fa-close"></i></span>
|
|
</div>
|
|
<script type=text/javascript src=../js/lunr.min.js?1637878444></script>
|
|
<script type=text/javascript src=../js/horsey.js?1637878444></script>
|
|
<script type=text/javascript>var baseurl=""</script>
|
|
<script type=text/javascript src=../js/searchjson.js?1637878444></script>
|
|
<script type=text/javascript src=../js/search.js?1637878444></script>
|
|
</div>
|
|
<div class=highlightable>
|
|
<ul class=topics>
|
|
<li data-nav-id=/gettingstarted.html title="Getting Started" class=dd-item>
|
|
<a href=../gettingstarted.html>
|
|
Getting Started
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/configuration.html title=Configuration class=dd-item>
|
|
<a href=../configuration.html>
|
|
Configuration
|
|
</a>
|
|
<ul>
|
|
<li data-nav-id=/configuration/audio.html title="Audio Options" class=dd-item>
|
|
<a href=../configuration/audio.html>
|
|
Audio Options
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/configuration/input.html title="Input Options" class=dd-item>
|
|
<a href=../configuration/input.html>
|
|
Input Options
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/configuration/video.html title="Video Options" class=dd-item>
|
|
<a href=../configuration/video.html>
|
|
Video Options
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/configuration/emulation.html title="Emulation Options" class=dd-item>
|
|
<a href=../configuration/emulation.html>
|
|
Emulation Options
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/configuration/preferences.html title=Preferences class=dd-item>
|
|
<a href=../configuration/preferences.html>
|
|
Preferences
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li data-nav-id=/tools.html title=Tools class=dd-item>
|
|
<a href=../tools.html>
|
|
Tools
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging.html title="Debugging Tools" class=dd-item>
|
|
<a href=../debugging.html>
|
|
Debugging Tools
|
|
</a>
|
|
<ul>
|
|
<li data-nav-id=/debugging/debugger.html title=Debugger class=dd-item>
|
|
<a href=../debugging/debugger.html>
|
|
Debugger
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/apuviewer.html title="APU Viewer" class=dd-item>
|
|
<a href=../debugging/apuviewer.html>
|
|
APU Viewer
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/assembler.html title=Assembler class=dd-item>
|
|
<a href=../debugging/assembler.html>
|
|
Assembler
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/eventviewer.html title="Event Viewer" class=dd-item>
|
|
<a href=../debugging/eventviewer.html>
|
|
Event Viewer
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/memorytools.html title="Memory Tools" class=dd-item>
|
|
<a href=../debugging/memorytools.html>
|
|
Memory Tools
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/performanceprofiler.html title="Performance Profiler" class=dd-item>
|
|
<a href=../debugging/performanceprofiler.html>
|
|
Performance Profiler
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/ppuviewer.html title="PPU Viewer" class=dd-item>
|
|
<a href=../debugging/ppuviewer.html>
|
|
PPU Viewer
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/scriptwindow.html title="Script Window" class=dd-item>
|
|
<a href=../debugging/scriptwindow.html>
|
|
Script Window
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/texthooker.html title="Text Hooker" class=dd-item>
|
|
<a href=../debugging/texthooker.html>
|
|
Text Hooker
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/tracelogger.html title="Trace Logger" class=dd-item>
|
|
<a href=../debugging/tracelogger.html>
|
|
Trace Logger
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/debugging/debuggerintegration.html title="Integration with compilers" class=dd-item>
|
|
<a href=../debugging/debuggerintegration.html>
|
|
Integration with compilers
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li data-nav-id=/hdpacks.html title="HD Packs" class=dd-item>
|
|
<a href=../hdpacks.html>
|
|
HD Packs
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference.html title="Lua API reference" class="dd-item
|
|
parent">
|
|
<a href=../apireference.html>
|
|
Lua API reference
|
|
</a>
|
|
<ul>
|
|
<li data-nav-id=/apireference/changelog.html title=Changelog class=dd-item>
|
|
<a href=../apireference/changelog.html>
|
|
Changelog
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/callbacks.html title=Callbacks class=dd-item>
|
|
<a href=../apireference/callbacks.html>
|
|
Callbacks
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/drawing.html title=Drawing class=dd-item>
|
|
<a href=../apireference/drawing.html>
|
|
Drawing
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/emulation.html title=Emulation class="dd-item active">
|
|
<a href=../apireference/emulation.html>
|
|
Emulation
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/input.html title=Input class=dd-item>
|
|
<a href=../apireference/input.html>
|
|
Input
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/logging.html title=Logging class=dd-item>
|
|
<a href=../apireference/logging.html>
|
|
Logging
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/memoryaccess.html title="Memory Access" class=dd-item>
|
|
<a href=../apireference/memoryaccess.html>
|
|
Memory Access
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/misc.html title=Miscellaneous class=dd-item>
|
|
<a href=../apireference/misc.html>
|
|
Miscellaneous
|
|
</a>
|
|
</li>
|
|
<li data-nav-id=/apireference/enums.html title=Enums class=dd-item>
|
|
<a href=../apireference/enums.html>
|
|
Enums
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<section id=shortcuts>
|
|
<h3>More</h3>
|
|
<ul>
|
|
<li role>
|
|
<a class=padding href=https://www.mesen.ca><img style=vertical-align:middle src=../images/favicon.png> <span style=display:inline;vertical-align:middle>Website</span></a>
|
|
</li>
|
|
<li role>
|
|
<a class=padding href=https://github.com/SourMesen/Mesen><i class="fa fa-github"></i> GitHub</a>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
<div id=menuspacer></div>
|
|
<section id=footer>
|
|
<div class=menuFooter>
|
|
<div class=donateButton><a href=https://www.mesen.ca/Donate.php><img src=../images/patreon.png alt="Become a Patron!" width=66% height=66%></a></div>
|
|
<div class=donateButton><a class=bmc-button target=_blank href=https://www.mesen.ca/BuyCoffee.php><img src=../images/BMC-btn-logo.svg alt=Donate><span style=margin-left:5px>Donate</span></a></div>
|
|
Version: <b>0.9.9</b><br>
|
|
Last Updated: <b>2021-11-25</b>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</nav>
|
|
<section id=body>
|
|
<div id=overlay></div>
|
|
<div class="padding highlightable sticky-parent">
|
|
<div class=sticky-spacer>
|
|
<div id=top-bar>
|
|
<div id=breadcrumbs itemscope itemtype=http://data-vocabulary.org/Breadcrumb>
|
|
<span id=sidebar-toggle-span>
|
|
<a href=# id=sidebar-toggle data-sidebar-toggle>
|
|
<i class="fa fa-bars"></i>
|
|
</a>
|
|
</span>
|
|
<span id=toc-menu><i class="fa fa-list-alt"></i></span>
|
|
<span class=links>
|
|
<a href=../>Home</a> > <a href=../apireference.html>Lua API reference</a> > Emulation
|
|
</span>
|
|
</div>
|
|
<div class=progress>
|
|
<div class=wrapper>
|
|
<nav id=TableOfContents>
|
|
<ul>
|
|
<li><a href=#getstate>getState</a></li>
|
|
<li><a href=#setstate>setState</a></li>
|
|
<li><a href=#breakexecution>breakExecution</a></li>
|
|
<li><a href=#execute>execute</a></li>
|
|
<li><a href=#stepout>stepOut</a></li>
|
|
<li><a href=#stepover>stepOver</a></li>
|
|
<li><a href=#reset>reset</a></li>
|
|
<li><a href=#stop>stop</a></li>
|
|
<li><a href=#resume>resume</a></li>
|
|
<li><a href=#rewind>rewind</a></li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id=body-inner>
|
|
<h1>Emulation</h1>
|
|
<div class=toc>
|
|
<div><nav id=TableOfContents>
|
|
<ul>
|
|
<li><a href=#getstate>getState</a></li>
|
|
<li><a href=#setstate>setState</a></li>
|
|
<li><a href=#breakexecution>breakExecution</a></li>
|
|
<li><a href=#execute>execute</a></li>
|
|
<li><a href=#stepout>stepOut</a></li>
|
|
<li><a href=#stepover>stepOver</a></li>
|
|
<li><a href=#reset>reset</a></li>
|
|
<li><a href=#stop>stop</a></li>
|
|
<li><a href=#resume>resume</a></li>
|
|
<li><a href=#rewind>rewind</a></li>
|
|
</ul>
|
|
</nav></div>
|
|
</div>
|
|
<h2 id=getstate>getState</h2>
|
|
<p><strong>Syntax</strong></p>
|
|
<pre><code>emu.getState()
|
|
</code></pre>
|
|
<p><strong>Return value</strong><br>
|
|
<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>
|
|
<h2 id=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 <a href=#getstate>getState()</a><br>
|
|
<strong>Note:</strong> the state of the APU or cartridge cannot be modified by using setState().</p>
|
|
<h2 id=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>
|
|
<h2 id=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 <a href=../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>
|
|
<h2 id=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>
|
|
<h2 id=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>
|
|
<h2 id=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>
|
|
<h2 id=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 <a href=../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 <a href=../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>
|
|
<h2 id=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>
|
|
<h2 id=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>
|
|
<footer class=footline>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
<div id=navigation>
|
|
<a class="nav nav-prev" href=../apireference/drawing.html title=Drawing> <i class="fa fa-chevron-left"></i></a>
|
|
<a class="nav nav-next" href=../apireference/input.html title=Input style=margin-right:0><i class="fa fa-chevron-right"></i></a>
|
|
</div>
|
|
</section>
|
|
<div style=left:-1000px;overflow:scroll;position:absolute;top:-1000px;border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px>
|
|
<div style=border:none;box-sizing:content-box;height:200px;margin:0;padding:0;width:200px></div>
|
|
</div>
|
|
<script src=../js/clipboard.min.js?1637878444></script>
|
|
<script src=../js/perfect-scrollbar.min.js?1637878444></script>
|
|
<script src=../js/perfect-scrollbar.jquery.min.js?1637878444></script>
|
|
<script src=../js/jquery.sticky-kit.min.js?1637878444></script>
|
|
<script src=../js/featherlight.min.js?1637878444></script>
|
|
<script src=../js/html5shiv-printshiv.min.js?1637878444></script>
|
|
<script src=../js/highlight.pack.js?1637878444></script>
|
|
<script>hljs.initHighlightingOnLoad()</script>
|
|
<script src=../js/modernizr.custom.71422.js?1637878444></script>
|
|
<script src=../js/learn.js?1637878444></script>
|
|
<script src=../js/hugo-learn.js?1637878444></script>
|
|
<link href=../mermaid/mermaid.css?1637878444 type=text/css rel=stylesheet>
|
|
<script src=../mermaid/mermaid.js?1637878444></script>
|
|
<script>mermaid.initialize({startOnLoad:!0})</script>
|
|
</body>
|
|
</html> |