Memory Access 5x7043

read / readWord 2o4o71

Syntax 2o344k

emu.read(address, type, signed = false)
emu.readWord(address, type, signed = false)

Parameters
address - Integer The address/offset to read from.
type - Enum The type of memory to read from. See memType.
signed - (optional) Boolean If true, the value returned will be interpreted as a signed value.

Return value
An 8-bit (read) or 16-bit (readWord) value.

Description
Reads a value from the specified memory type.

When calling read / readWord with the memType.ppu memory types, emulation side-effects may occur.
To avoid triggering side-effects, use the memType.ppuDebug types, which will not cause side-effects.

write / writeWord 6w6a24

Syntax

emu.write(address, value, type)
emu.writeWord(address, value, type)

Parameters
address - Integer The address/offset to write to.
value - Integer The value to write.
type - Enum The type of memory to write to. See memType.

Return value
None

Description
Writes an 8-bit or 16-bit value to the specified memory type.

Normally read-only types such as PRG-ROM or CHR-ROM can be written to when using memType.chrRom.
Changes will remain in effect until a power cycle occurs.
To revert changes done to ROM, see revertPrgChrChanges.

When calling write / writeWord with the memType.ppu memory types, emulation side-effects may occur.
To avoid triggering side-effects, use the memType.ppuDebug types, which will not cause side-effects.

revertPrgChrChanges 3r2y1s

Syntax

emu.revertPrgChrChanges()

Return value
None

Description
Reverts all modifications done to PRG-ROM and CHR-ROM via write/writeWord calls.

getPrgRomOffset 1hk26

Syntax

emu.getPrgRomOffset(address)

Parameters
address - Integer A U address (Valid range: $0000-$FFFF)

Return value
Integer The corresponding byte offset in PRG ROM

Description
Returns an integer representing the byte offset of the specified U address in PRG ROM based on the mapper’s current configuration. Returns -1 when the specified address is not mapped to PRG ROM.

getChrRomOffset f3q1l

Syntax

emu.getChrRomOffset(address)

Parameters
address - Integer A PPU address (Valid range: $0000-$3FFF)

Return value
Integer The corresponding byte offset in CHR ROM

Description
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.

getLabelAddress 44555y

Syntax

emu.getLabelAddress(label)

Parameters
label - String The label to look up

Return value
Integer The corresponding U address

Description
Returns the address of the specified label. This address can be used with the memory read/write functions (read(), readWord(), write(), writeWord()) using the emu.memType.u or emu.memType.uDebug memory types.