Callbacks 5l1t39

addEventCallback 6o1r1x

Syntax 2o344k

emu.addEventCallback(function, type)

Parameters
function - A Lua function.
type - Enum See eventType.

Return value
Returns an integer value that can be used to remove the callback by calling removeEventCallback.

Description
s a callback function to be called whenever the specified event occurs.
The callback function receives no parameters.

removeEventCallback q161v

Syntax

emu.removeEventCallback(reference, type)

Parameters
reference - The value returned by the call to addEventCallback.
type - Enum See eventType.

Return value
None

Description
Removes a previously ed callback function.

addMemoryCallback 6a1x6p

Syntax

emu.addMemoryCallback(function, type, startAddress [, endAddress])

Parameters
function - A Lua function.
type - Enum See memCallbackType
startAddress - Integer Start of the U memory address range to the callback on.
endAddress - (optional) Integer End of the U memory address range to the callback on.

Return value
Returns an integer value that can be used to remove the callback by calling removeMemoryCallback.

Description
s a callback function to be called whenever the specified event occurs.
The callback function receives 2 parameters address and value that correspond to the address being written to or read from, and the value that is being read/written.

For reads, the callback is called after the read is performed.
For writes, the callback is called before the write is performed.

If the callback returns an integer value, it will replace the value – you can alter the results of read/write operation using this. e.g:

function writeCallback(address, value)
  --This sets bit 0 to 0 for all CHR RAM writes
  return value & 0xFE
end

emu.addMemoryCallback(writeCallback, emu.memCallbackType.ppuWrite, 0, 0x1FFF)

removeMemoryCallback 6e3t64

Syntax

emu.removeMemoryCallback(reference, type, startAddress [, endAddress])

Parameters
reference - The value returned by the call to addMemoryCallback.
type - Enum See memCallbackType.
startAddress - Integer Start of the U memory address range to un the callback from.
endAddress - (optional) Integer End of the U memory address range to un the callback from.

Return value
None

Description
Removes a previously ed callback function.