| |
- cheat_add(index, code, enabled=True)
- Stores the given cheat code at the given index in the cheat list.
"index" must be an integer. Only one cheat can be stored at any given
index.
"code" must be a string containing a valid Game Genie cheat code, or
a sequence of them separated with plus signs like "DD62-3B1F+DD12-FA2C".
"enabled" must be a boolean. It determines whether the cheat code is
enabled or not.
- cheat_is_enabled(index)
- Returns true if the cheat at the given index is enabled.
"index" must be an integer previously passed to cheat_add.
- cheat_remove(index)
- Removes the cheat at the given index from the cheat list.
"index" must be an integer previously passed to cheat_add.
- cheat_set_enabled(index, enabled)
- Enables or disables the cheat at the given index in the cheat list.
"index" must be an integer previously passed to cheat_add.
"enabled" must be a boolean. It determines whether the cheat code is
enabled or not.
- load_cartridge_bsx(base_data, slot_data, base_sram=None, base_rtc=None, bsx_ram=None, bsx_pram=None, base_mapping=None, slot_mapping=None)
- Load a BS-X slotted cartridge into the emulated SNES.
"base_data" must be a string containing the uncompressed, de-interleaved,
headerless ROM image of the BS-X base cartridge.
"slot_data" must be a string containing the uncompressed, de-interleaved,
headerless ROM image of the cartridge loaded inside the BS-X base
cartridge.
"base_sram" should be a string containing the SRAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank SRAM region.
"base_rtc" should be a string containing the real-time-clock data saved
from the previous session. If not supplied or None, the cartridge will be
given a fresh, blank RTC region (most cartridges don't use an RTC).
"bsx_ram" should be a string containing the BS-X RAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank RAM region.
"bsx_pram" should be a string containing the BS-X PRAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank PRAM region.
"base_mapping" should be a string containing an XML document describing the
memory-mapping for the BS-X base cartridge. If not supplied or None,
a guessed mapping will be used (the guess should be correct for all
licenced games released in all regions).
"slot_mapping" should be a string containing an XML document describing the
memory-mapping for the cartridge loaded inside the BS-X base cartridge. If
not supplied or None, a guessed mapping will be used (the guess should be
correct for all licenced games released in all regions).
TODO: How on earth is this different from load_cartridge_bsx_slotted?
- load_cartridge_bsx_slotted(base_data, slot_data, base_sram=None, base_rtc=None, bsx_ram=None, bsx_pram=None, base_mapping=None, slot_mapping=None)
- Load a BS-X slotted cartridge into the emulated SNES.
"base_data" must be a string containing the uncompressed, de-interleaved,
headerless ROM image of the BS-X base cartridge.
"slot_data" must be a string containing the uncompressed, de-interleaved,
headerless ROM image of the cartridge loaded inside the BS-X base
cartridge.
"base_sram" should be a string containing the SRAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank SRAM region.
"base_rtc" should be a string containing the real-time-clock data saved
from the previous session. If not supplied or None, the cartridge will be
given a fresh, blank RTC region (most cartridges don't use an RTC).
TODO: Does the BS-X base cart use SRAM and/or RTC storage?
"bsx_ram" should be a string containing the BS-X RAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank RAM region.
"bsx_pram" should be a string containing the BS-X PRAM data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank PRAM region.
"base_mapping" should be a string containing an XML document describing the
memory-mapping for the BS-X base cartridge. If not supplied or None,
a guessed mapping will be used (the guess should be correct for all
licenced games released in all regions).
"slot_mapping" should be a string containing an XML document describing the
memory-mapping for the cartridge loaded inside the BS-X base cartridge. If
not supplied or None, a guessed mapping will be used (the guess should be
correct for all licenced games released in all regions).
- load_cartridge_normal(data, sram=None, rtc=None, mapping=None)
- Load an ordinary cartridge into the emulated SNES.
"data" must be a string containing the uncompressed, de-interleaved,
headerless ROM image.
"sram" should be a string containing the SRAM data saved from the previous
session. If not supplied or None, the cartridge will be given a fresh,
blank SRAM region.
"rtc" should be a string containing the real-time-clock data saved from the
previous session. If not supplied or None, the cartridge will be given
a fresh, blank RTC region (most cartridges don't use an RTC).
"mapping" should be a string containing an XML document describing the
required memory-mapping for this cartridge. If not supplied or None,
a guessed mapping will be used (the guess should be correct for all
licenced games released in all regions).
- power()
- Turn the emulated SNES off and back on.
Requires that a cartridge be loaded.
- reset()
- Press the front-panel Reset button on the emulated SNES.
Requires that a cartridge be loaded.
- run()
- Run the emulated SNES for one frame.
Before this function returns, the registered callbacks will be called at
least once each.
This function should be called fifty (for PAL cartridges) or sixty (for
NTSC cartridges) times per second for real-time emulation.
Requires that a cartridge be loaded.
- serialize()
- Serializes the state of the emulated SNES to a string.
This serialized data can be handed to unserialize() at a later time to
resume emulation from this point.
Requires that a cartridge be loaded.
- set_audio_sample_cb(callback)
- Sets the callback that will handle updated audio frames.
The callback should accept the following parameters:
"left" is an integer between 0 and 65535 that specifies the volume in
the left audio channel.
"right" is an integer between 0 and 65535 that specifies the volume in
the right audio channel.
The callback should return nothing.
- set_controller_port_device(port, device)
- Connects the given device to the given controller port.
Connecting a device to a port implicitly removes any device previously
connected to that port. To remove a device without connecting a new one,
pass DEVICE_NONE as the device parameter. From this point onward, the
callback passed to set_input_state_cb() will be called with the appropriate
device, index and id parameters.
If this function is never called, the default is to have no controllers
connected at all. (TODO: is this true?)
"port" must be one of the PORT_* constants, describing which port the given
controller will be connected to.
"device" must be one of the DEVICE_* (but not DEVICE_ID_*) constants,
describing what kind of device will be connected to the given port.
TODO: Is there any time it's not safe to call this method? For example, is
it safe to call this method from inside the input state callback?
- set_input_poll_cb(callback)
- Sets the callback that will check for updated input events.
The callback should accept no parameters and return nothing. It should just
read new input events and store them somewhere so they can be returned by
the input state callback.
- set_input_state_cb(callback)
- Sets the callback that reports the current state of input devices.
The callback should accept the following parameters:
"port" is one of the constants PORT_1 or PORT_2, describing which
controller port is being reported.
"device" is one of the DEVICE_* constants describing which type of
device is currently connected to the given port.
"index" is a number describing which of the devices connected to the
port is being reported. It's probably only useful for DEVICE_MULTITAP
and DEVICE_JUSTIFIERS (TODO: check this).
"id" is one of the DEVICE_ID_* constants for the given device,
describing which button or axis is being reported (for DEVICE_MULTITAP,
use the DEVICE_ID_JOYPAD_* IDs)
The callback should return a number between -32768 and 32767 representing
the value of the button or axis being reported (TODO: what do button inputs
return?).
- set_video_refresh_cb(callback)
- Sets the callback that will handle updated video frames.
The callback should accept the following parameters:
"data" is a pointer to the top-left of a 512*480 array of pixels. Each
pixel is an unsigned, 16-bit integer in XBGR1555 format.
"width" is the number of pixels in each row of the frame. It can be
either 256 (if the SNES is in "low-res" mode) or 512 (if the SNES is in
"hi-res" or "psuedo-hi-res" modes).
"height" is the number of pixel-rows in the frame. It can vary between
224 and 478, depending on whether the SNES has "interlace" and/or
"overscan" modes enabled.
"hires" is True if this frame is "hi-res" or "pseudo-hi-res".
"interlace" is True if this frame has "interlace" mode enabled.
"overscan" is True if this frame has "overscan" mode enabled.
"pitch" is the number of pixels from the beginning of one line to the
beginning of the text. In non-interlaced modes, every other line of the
frame-buffer is left blank.
The callback should return nothing.
- unload()
- Remove the cartridge and return its non-volatile storage contents.
Returns a list with an entry for each MEMORY_* constant in
VALID_MEMORY_TYPES. If the current cartridge uses that type of storage, the
corresponding index in the list will be a string containing the storage
contents, which can later be passed to load_cartridge_*. Otherwise, the
corresponding index is None.
Requires that a cartridge be loaded.
- unserialize(state)
- Restores the state of the emulated SNES from a string.
Note that the cartridge's SRAM data is part of the saved state.
Requires that the same cartridge that was loaded when serialize was called,
be loaded before unserialize is called.
|