<pre><code>emu.read(address, type, signed = false)
emu.readWord(address, type, signed = false)
</code></pre>
<p><strong>Parameters</strong><br>
address - <em>Integer</em> The address/offset to read from.<br>
type - <em>Enum</em> The type of memory to read from. See <ahref=../apireference/enums.html#memtype>memType</a>.<br>
signed - (optional) <em>Boolean</em> If true, the value returned will be interpreted as a signed value.</p>
<p><strong>Return value</strong><br>
An 8-bit (read) or 16-bit (readWord) value.</p>
<p><strong>Description</strong><br>
Reads a value from the specified <ahref=../apireference/enums.html#memtype>memory type</a>.</p>
<p>When calling read / readWord with the <ahref=../apireference/enums.html#memtype>memType.cpu</a> or <ahref=../apireference/enums.html#memtype>memType.ppu</a> memory types, emulation side-effects may occur.<br>
To avoid triggering side-effects, use the <ahref=../apireference/enums.html#memtype>memType.cpuDebug</a> or <ahref=../apireference/enums.html#memtype>memType.ppuDebug</a> types, which will not cause side-effects.</p>
<h2id=write--writeword>write / writeWord</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.write(address, value, type)
emu.writeWord(address, value, type)
</code></pre>
<p><strong>Parameters</strong><br>
address - <em>Integer</em> The address/offset to write to. <br>
value - <em>Integer</em> The value to write.<br>
type - <em>Enum</em> The type of memory to write to. See <ahref=../apireference/enums.html#memtype>memType</a>.</p>
<p><strong>Return value</strong><br>
<em>None</em></p>
<p><strong>Description</strong><br>
Writes an 8-bit or 16-bit value to the specified <ahref=../apireference/enums.html#memtype>memory type</a>.</p>
<p>Normally read-only types such as PRG-ROM or CHR-ROM can be written to when using <ahref=../apireference/enums.html#memtype>memType.prgRom</a> or <ahref=../apireference/enums.html#memtype>memType.chrRom</a>.<br>
Changes will remain in effect until a power cycle occurs.<br>
To revert changes done to ROM, see <ahref=#revertprgchrchanges>revertPrgChrChanges</a>.</p>
<p>When calling write / writeWord with the <ahref=../apireference/enums.html#memtype>memType.cpu</a> or <ahref=../apireference/enums.html#memtype>memType.ppu</a> memory types, emulation side-effects may occur.<br>
To avoid triggering side-effects, use the <ahref=../apireference/enums.html#memtype>memType.cpuDebug</a> or <ahref=../apireference/enums.html#memtype>memType.ppuDebug</a> types, which will not cause side-effects.</p>
Reverts all modifications done to PRG-ROM and CHR-ROM via write/writeWord calls.</p>
<h2id=getprgromoffset>getPrgRomOffset</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.getPrgRomOffset(address)
</code></pre>
<p><strong>Parameters</strong><br>
address - <em>Integer</em> A CPU address (Valid range: $0000-$FFFF)</p>
<p><strong>Return value</strong><br>
<em>Integer</em> The corresponding byte offset in PRG ROM</p>
<p><strong>Description</strong><br>
Returns an integer representing the byte offset of the specified CPU address in PRG ROM based on the mapper’s current configuration. Returns -1 when the specified address is not mapped to PRG ROM.</p>
<h2id=getchrromoffset>getChrRomOffset</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.getChrRomOffset(address)
</code></pre>
<p><strong>Parameters</strong><br>
address - <em>Integer</em> A PPU address (Valid range: $0000-$3FFF)</p>
<p><strong>Return value</strong><br>
<em>Integer</em> The corresponding byte offset in CHR ROM</p>
<p><strong>Description</strong><br>
Returns an integer representing the byte offset of the specified PPU address in CHR ROM based on the mapper’s current configuration. Returns -1 when the specified address is not mapped to CHR ROM.</p>
<h2id=getlabeladdress>getLabelAddress</h2>
<p><strong>Syntax</strong></p>
<pre><code>emu.getLabelAddress(label)
</code></pre>
<p><strong>Parameters</strong><br>
label - <em>String</em> The label to look up</p>
<p><strong>Return value</strong><br>
<em>Integer</em> The corresponding CPU address</p>
<p><strong>Description</strong><br>
Returns the address of the specified label. This address can be used with the memory read/write functions (<code>read()</code>, <code>readWord()</code>, <code>write()</code>, <code>writeWord()</code>) using the <code>emu.memType.cpu</code> or <code>emu.memType.cpuDebug</code> memory types.</p>