From 2c226a3b9fe794fa66b32ba09e6dc34c538118de Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 12 Mar 2023 04:37:30 +1100 Subject: Lua engine: Better bindings for device_state_interface. This avoids creating a table every time the state property of a device is accessed, adds proper support for getting/setting floating/point state entries from Lua, calls the state entry's formatting method to convert to a string (for flags fields, etc.) and exposes more properties. This is a breaking change as the exposed properties on state entries have changed, and the value property has different semantics for floating-point state entries. --- docs/source/techspecs/luareference.rst | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'docs/source/techspecs') diff --git a/docs/source/techspecs/luareference.rst b/docs/source/techspecs/luareference.rst index 28ee0c08c75..4c3c5098004 100644 --- a/docs/source/techspecs/luareference.rst +++ b/docs/source/techspecs/luareference.rst @@ -852,6 +852,11 @@ device.debug (read-only) The :ref:`debugger interface ` to the device if it is a CPU device, or ``nil`` if it is not a CPU device or the debugger is not enabled. +device.state[] (read-only) + The :ref:`state entries ` for devices that + expose the register state interface, indexed by symbol, or ``nil`` for other + devices. The index operator and ``index_of`` methods have O(n) complexity; + all other supported operations have O(1) complexity. device.spaces[] (read-only) A table of the device’s :ref:`address spaces `, indexed by name. Only valid for devices that implement the memory @@ -1311,6 +1316,46 @@ slot.options[] (read-only) slot.device (read-only) The underlying :ref:`device `. +.. _luareference-dev-stateentry: + +Device state entry +~~~~~~~~~~~~~~~~~~ + +Wraps MAME’s ``device_state_entry`` class, which allows access to named +registers exposed by a :ref:`device `. Supports +conversion to string for display. + +Instantiation +^^^^^^^^^^^^^ + +manager.machine.devices[tag].state[symbol] + Gets a state entry for a given device by symbol. + +Properties +^^^^^^^^^^ + +entry.value (read/write) + The numeric value of the state entry, as either an integer or floating-point + number. Attempting to set the value of a read-only state entry raises an + error. +entry.symbol (read-only) + The state entry’s symbolic name. +entry.visible (read-only) + A Boolean indicating whether the state entry should be displayed in the + debugger register view. +entry.writeable (read-only) + A Boolean indicating whether it is possible to modify the state entry’s + value. +entry.is_float (read-only) + A Boolean indicating whether the state entry’s value is a floating-point + number. +entry.datamask (read-only) + A bit mask of the valid bits of the value for integer state entries. +entry.datasize (read-only) + The size of the underlying value in bytes for integer state entries. +entry.max_length (read-only) + The maximum display string length for the state entry. + .. _luareference-dev-imagefmt: Media image format -- cgit v1.2.3-70-g09d2