libretro.api.memory

Types that describe the address space of the Core’s emulated memory.

Module Attributes

RETRO_MEMORY_MASK

Mask for extracting the memory type from a memory ID.

RETRO_MEMORY_SAVE_RAM

Identifier for save RAM (battery-backed SRAM).

RETRO_MEMORY_RTC

Identifier for real-time clock memory.

RETRO_MEMORY_SYSTEM_RAM

Identifier for main system RAM.

RETRO_MEMORY_VIDEO_RAM

Identifier for video RAM.

Classes

MemoryDescriptorFlag

Flags that describe properties of a retro_memory_descriptor.

retro_memory_descriptor

Describes a region of emulated memory.

retro_memory_map

A collection of retro_memory_descriptors that define the address space of the Core's emulated memory.

class retro_memory_descriptor[source]

Bases: Structure

Describes a region of emulated memory.

Corresponds to retro_memory_descriptor in libretro.h.

>>> from libretro.api import retro_memory_descriptor
>>> desc = retro_memory_descriptor()
>>> desc.start
0
>>> desc.ptr is None
True
flags

Bitwise OR of MemoryDescriptorFlag values describing this region.

ptr

Pointer to the start of this memory region in the host’s address space.

offset

Offset relative to ptr.

start

Starting address within the emulated hardware’s address space.

Note

This is not represented as a pointer because it’s not necessarily valid in the host’s address space.

select

Bitmask of address bits that must match start.

disconnect

Bitmask of address bits not used for addressing.

len

Length of this memory region in bytes.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
addrspace

Short name for this address space.

__deepcopy__(_)[source]

Return a deep copy of this object, including all subobjects and strings. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_memory_descriptor
>>> copy.deepcopy(retro_memory_descriptor()).start
0
class retro_memory_map[source]

Bases: Structure

A collection of retro_memory_descriptors that define the address space of the Core’s emulated memory.

Corresponds to retro_memory_map in libretro.h.

>>> from libretro.api import retro_memory_map
>>> m = retro_memory_map()
>>> len(m)
0
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
descriptors

Array of memory descriptors.

num_descriptors

Number of entries in descriptors.

len(self)[source]

Return the number of memory descriptors.

>>> from libretro.api import retro_memory_map
>>> len(retro_memory_map())
0
self[item][source]
Overloads:
  • self, item (int) → retro_memory_descriptor

  • self, item (slice[retro_memory_descriptor]) → list[retro_memory_descriptor]

Return a descriptor by index or a list of descriptors by slice.

Parameters:

item – An integer index or slice.

Returns:

A single retro_memory_descriptor or a list of them.

Raises:
__deepcopy__(memodict=None)[source]

Return a deep copy of this object, including all subobjects and strings. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_memory_map
>>> copy.deepcopy(retro_memory_map()).num_descriptors
0
class MemoryDescriptorFlag[source]

Bases: IntFlag

Flags that describe properties of a retro_memory_descriptor.

Corresponds to the RETRO_MEMDESC_* constants in libretro.h.

>>> from libretro.api import MemoryDescriptorFlag
>>> MemoryDescriptorFlag.CONST
<MemoryDescriptorFlag.CONST: 1>
>>> MemoryDescriptorFlag.BIGENDIAN | MemoryDescriptorFlag.SAVE_RAM
<MemoryDescriptorFlag.SAVE_RAM|BIGENDIAN: 10>
CONST = 1
BIGENDIAN = 2
SYSTEM_RAM = 4
SAVE_RAM = 8
VIDEO_RAM = 16
ALIGN_2 = 65536
ALIGN_4 = 131072
ALIGN_8 = 196608
MINSIZE_2 = 16777216
MINSIZE_4 = 33554432
MINSIZE_8 = 50331648
__new__(value)
other in self

Returns True if self has at least the same flags set as other.

iter(self)

Returns flags in definition order.

len(self)

Return the number of members (no aliases)

classmethod self[name]

Return the member matching name.

__init__()
RETRO_MEMORY_MASK = 255

Mask for extracting the memory type from a memory ID.

RETRO_MEMORY_SAVE_RAM = 0

Identifier for save RAM (battery-backed SRAM).

RETRO_MEMORY_RTC = 1

Identifier for real-time clock memory.

RETRO_MEMORY_SYSTEM_RAM = 2

Identifier for main system RAM.

RETRO_MEMORY_VIDEO_RAM = 3

Identifier for video RAM.