Skip to content

C64API ​

cpp
#include <VirtualC64.h>
cpp
class C64API

Defined in VirtualC64.h:1739

C64 API

Public Methods ​

ReturnNameDescription
const C64Config &getConfig constReturns the component's current configuration.
const C64Info &getInfo constReturns the component's current state.
const C64Info &getCachedInfo constReturns the most recent state snapshot recorded by the emulator thread (see getInfo()).
voiddump constPrints debug information about the component.
RomTraitsgetRomTraits constReturns information about one of the installed Roms.
boolgetMsgReads a message from the message queue.
u64getAutoInspectionMask constGets the current auto-inspection mask The GUI utilizes Auto-Inspection to display life updates of the internal emulator state in the Inspector panel. As soon as an auto-inspection mask is set, the emulator caches the internal states of the inspected components at periodic intervals. The inspected components are specified as a bit mask.
voidsetAutoInspectionMaskSets the current auto-inspection mask.
voidsetAutoInspectionMaskAsyncAsynchronous version of setAutoInspectionMask(): queues the request and returns at once.
voidloadWorkspaceLoads a workspace.
voidloadWorkspaceLoads, saves, or asynchronously saves the workspace of an SVM.
voidsaveWorkspace constSaves a workspace to disk.
voidsaveWorkspace constSaves the workspace into an SVM that is already open (see loadWorkspace()).
voidsaveWorkspaceAsync constSaves a workspace to disk asynchronously.
voidsaveWorkspaceAsync constAsynchronous version of saveWorkspace(): queues the request and returns at once.
std::unique_ptr< Snapshot >takeSnapshotTakes a snapshot.
voidloadSnapshotLoads a snapshot.
voidloadSnapshotLoads a snapshot.
voidloadSnapshotAsyncAsynchronous version of loadSnapshot(): queues the request and returns at once.
voidsaveSnapshot constSaves a snapshot to disk.
voidsaveSnapshot constSaves a snapshot, including a screenshot, into an SVM.
voidsaveSnapshotAsync constSaves a snapshot to disk asynchronously.
voidsaveSnapshotAsync constAsynchronous version of saveSnapshot(): queues the request and returns at once.
voidhibernate constHibernates the machine into a virtual machine bundle.
voidhibernate constHibernates the machine into an SVM that is already open.
voidhibernateAsync constHibernates the machine asynchronously.
voidhibernateAsync constAsynchronous version of hibernate(): queues the request and returns at once.
voidloadRomLoads a ROM from a file The ROM type is determined automatically.
voidloadRomLoads a ROM from a file and installs it as the given ROM type.
voidloadRomAsyncAsynchronous version of loadRom(): queues the request and returns at once.
voidloadRomAsyncAsynchronous version of loadRom(path, rom).
voiddeleteRomRemoves an installed ROM The ROM contents is overwritten with zeroes.
voiddeleteRomsRemoves all installed ROMs including the floppy drive ROMs. The ROM contents is overwritten with zeroes.
voidsaveRomSaves a ROM to disk.
voidinstallOpenRomInstalles a MEGA65 OpenRom.
voidinstallOpenRomsInstall all three MEGA65 OpenROMs.
voidflashFlashes a file into memory.
voidflashAsyncAsynchronous version of flash(): queues the request and returns at once.

getConfig ​

const

cpp
const C64Config & getConfig() const

Defined in VirtualC64.h:1752

Returns the component's current configuration.


getInfo ​

const

cpp
const C64Info & getInfo() const

Defined in VirtualC64.h:1763

Returns the component's current state.

getInfo() reads the live state on the calling thread. The result is only consistent if the emulator is paused or suspended. getCachedInfo() returns the snapshot the emulator thread has recorded most recently, which is the one to use while the emulator runs. Both return references that can be overwritten by a later call or by the emulator thread, so copy the data if you need to keep it.


getCachedInfo ​

const

cpp
const C64Info & getCachedInfo() const

Defined in VirtualC64.h:1765

Returns the most recent state snapshot recorded by the emulator thread (see getInfo()).


dump ​

const

cpp
void dump(Category category, std::ostream & os) const

Defined in VirtualC64.h:1772

Prints debug information about the component.

Parameters ​

ParameterTypeDescription
categoryCategoryDebug information category
osstd::ostream &Output stream

getRomTraits ​

const

cpp
RomTraits getRomTraits(RomType type) const

Defined in VirtualC64.h:1778

Returns information about one of the installed Roms.

Parameters ​

ParameterTypeDescription
typeRomTypeThe ROM type

getMsg ​

cpp
bool getMsg(Message & msg, std::exception_ptr & exception)

Defined in VirtualC64.h:1791

Reads a message from the message queue.

Returns ​

True if a message could be read, false if the queue was empty

Parameters ​

ParameterTypeDescription
msgMessage &The returned message (if any)
exceptionstd::exception_ptr &The exception the message reports (null if none)

getAutoInspectionMask ​

const

cpp
u64 getAutoInspectionMask() const

Defined in VirtualC64.h:1807

Gets the current auto-inspection mask The GUI utilizes Auto-Inspection to display life updates of the internal emulator state in the Inspector panel. As soon as an auto-inspection mask is set, the emulator caches the internal states of the inspected components at periodic intervals. The inspected components are specified as a bit mask.

Returns ​

A bit mask indicating the components under inspection


setAutoInspectionMask ​

cpp
void setAutoInspectionMask(u64 mask)

Defined in VirtualC64.h:1822

Sets the current auto-inspection mask.

Each bit selects one component class (the bit position is the numeric value of the Class entry). A component's getCachedInfo() and getCachedMetrics() only return up-to-date snapshots while its class is selected.

Example: The following call enables auto-inspections for the CIA chips and the CPU: setAutoInspectionMask(1LL << long(Class::CIA) | 1LL << long(Class::CPU));

Parameters ​

ParameterTypeDescription
masku64A bit mask indicating the components under inspection

setAutoInspectionMaskAsync ​

cpp
void setAutoInspectionMaskAsync(u64 mask)

Defined in VirtualC64.h:1825

Asynchronous version of setAutoInspectionMask(): queues the request and returns at once.


loadWorkspace ​

cpp
void loadWorkspace(const std::filesystem::path & path)

Defined in VirtualC64.h:1838

Loads a workspace.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Path to a workspace folder

Exceptions ​

ExceptionDescription
Errorif the file cannot be read or does not contain valid data.

loadWorkspace ​

cpp
void loadWorkspace(retro::vault::SVMFile & svm)

Defined in VirtualC64.h:1870

Loads, saves, or asynchronously saves the workspace of an SVM.

These work on the workspace folder of an SVM that is already open. Saving replaces the workspace, notes its preview image in the manifest and persists the SVM. As with hibernateAsync, the object is used on the emulator thread and must stay alive, and untouched, until the WORKSPACE_SAVED message has arrived.

Exceptions ​

ExceptionDescription
Errorif the SVM file cannot be read or written, or if its content is invalid (synchronous versions).

saveWorkspace ​

const

cpp
void saveWorkspace(const std::filesystem::path & path) const

Defined in VirtualC64.h:1846

Saves a workspace to disk.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Destination path

Exceptions ​

ExceptionDescription
Errorif the file cannot be written.

saveWorkspace ​

const

cpp
void saveWorkspace(retro::vault::SVMFile & svm) const

Defined in VirtualC64.h:1872

Saves the workspace into an SVM that is already open (see loadWorkspace()).


saveWorkspaceAsync ​

const

cpp
void saveWorkspaceAsync(const std::filesystem::path & path) const

Defined in VirtualC64.h:1857

Saves a workspace to disk asynchronously.

The request is handed to the emulator thread, which carries it out when it processes its command queue. The function returns immediately. The GUI is informed by a WORKSPACE_SAVED message, which carries an exception if the operation failed.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Destination path

saveWorkspaceAsync ​

const

cpp
void saveWorkspaceAsync(retro::vault::SVMFile & svm) const

Defined in VirtualC64.h:1874

Asynchronous version of saveWorkspace(): queues the request and returns at once.


takeSnapshot ​

cpp
std::unique_ptr< Snapshot > takeSnapshot(utl::Compressor compressor, isize delay = 0, bool repeat = false)

Defined in VirtualC64.h:1887

Takes a snapshot.

Returns ​

A pointer to the created Snapshot object.

NOTE

The function transfers the ownership to the caller. It is his responsibility of the caller to free the object.

Parameters ​

ParameterTypeDescription
compressorutl::CompressorThe snapshot compression method
delayisizeOptional delay in seconds
repeatboolif true, snapshots are taken continuously

loadSnapshot ​

cpp
void loadSnapshot(const Snapshot & snapshot)

Defined in VirtualC64.h:1893

Loads a snapshot.

Parameters ​

ParameterTypeDescription
snapshotconst Snapshot &Reference to a snapshot

loadSnapshot ​

cpp
void loadSnapshot(const std::filesystem::path & path)

Defined in VirtualC64.h:1901

Loads a snapshot.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Source path

Exceptions ​

ExceptionDescription
Errorif the file cannot be read or does not contain valid data.

loadSnapshotAsync ​

cpp
void loadSnapshotAsync(const std::filesystem::path & path)

Defined in VirtualC64.h:1907

Asynchronous version of loadSnapshot(): queues the request and returns at once.

Success and failure are both reported by the usual message (SNAPSHOT_RESTORED). If the request failed, the message carries the exception.


saveSnapshot ​

const

cpp
void saveSnapshot(const std::filesystem::path & path, utl::Compressor compressor) const

Defined in VirtualC64.h:1916

Saves a snapshot to disk.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Destination path
compressorutl::CompressorThe compression method applied to the snapshot data.

Exceptions ​

ExceptionDescription
Errorif the file cannot be written.

saveSnapshot ​

const

cpp
void saveSnapshot(retro::vault::SVMFile & svm, utl::Compressor compressor) const

Defined in VirtualC64.h:1941

Saves a snapshot, including a screenshot, into an SVM.

Works on an SVM that is already open: the snapshot is added to its manifest, and the SVM is persisted. As with hibernateAsync, the object is used on the emulator thread by the asynchronous version and must stay alive, and untouched, until the SNAPSHOT_SAVED message has arrived.

Exceptions ​

ExceptionDescription
Errorif the SVM file cannot be read or written, or if its content is invalid (synchronous versions).

saveSnapshotAsync ​

const

cpp
void saveSnapshotAsync(const std::filesystem::path & path, utl::Compressor compressor) const

Defined in VirtualC64.h:1928

Saves a snapshot to disk asynchronously.

The request is handed to the emulator thread, which carries it out when it processes its command queue. The function returns immediately. The GUI is informed by a SNAPSHOT_SAVED message, which carries an exception if the operation failed.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Destination path
compressorutl::CompressorThe compression method applied to the snapshot data.

saveSnapshotAsync ​

const

cpp
void saveSnapshotAsync(retro::vault::SVMFile & svm, utl::Compressor compressor) const

Defined in VirtualC64.h:1943

Asynchronous version of saveSnapshot(): queues the request and returns at once.


hibernate ​

const

cpp
void hibernate(const std::filesystem::path & path, bool snapshot, bool workspace) const

Defined in VirtualC64.h:1955

Hibernates the machine into a virtual machine bundle.

Saves the workspace (if workspace is true) and a snapshot including a screenshot (if snapshot is true) into the SVM, and updates its manifest.

Parameters ​

ParameterTypeDescription
pathconst std::filesystem::path &Path of the SVM
snapshotboolSave a snapshot
workspaceboolSave the workspace

hibernate ​

const

cpp
void hibernate(retro::vault::SVMFile & svm, bool snapshot, bool workspace) const

Defined in VirtualC64.h:1976

Hibernates the machine into an SVM that is already open.

Works like the versions that take a path, but updates and persists the given object, so its manifest is current afterwards. The asynchronous version uses the object on the emulator thread: it must stay alive and must not be touched until the HIBERNATED message has arrived.

Exceptions ​

ExceptionDescription
Errorif the SVM file cannot be read or written, or if its content is invalid (synchronous versions).

hibernateAsync ​

const

cpp
void hibernateAsync(const std::filesystem::path & path, bool snapshot, bool workspace) const

Defined in VirtualC64.h:1964

Hibernates the machine asynchronously.

The request is handed to the emulator thread, which carries it out when it processes its command queue. The function returns immediately. The GUI is informed by a HIBERNATED message, which carries an error code and description if the operation failed.


hibernateAsync ​

const

cpp
void hibernateAsync(retro::vault::SVMFile & svm, bool snapshot, bool workspace) const

Defined in VirtualC64.h:1978

Asynchronous version of hibernate(): queues the request and returns at once.


loadRom ​

cpp
void loadRom(const std::filesystem::path & path)

Defined in VirtualC64.h:1990

Loads a ROM from a file The ROM type is determined automatically.

Exceptions ​

ExceptionDescription
Errorif the file cannot be read or does not contain valid data.

loadRom ​

cpp
void loadRom(const std::filesystem::path & path, RomType rom)

Defined in VirtualC64.h:1992

Loads a ROM from a file and installs it as the given ROM type.


loadRomAsync ​

cpp
void loadRomAsync(const std::filesystem::path & path)

Defined in VirtualC64.h:1998

Asynchronous version of loadRom(): queues the request and returns at once.

Success and failure are both reported by a ROM_LOADED message. If the request failed, the message carries the exception.


loadRomAsync ​

cpp
void loadRomAsync(const std::filesystem::path & path, RomType rom)

Defined in VirtualC64.h:2000

Asynchronous version of loadRom(path, rom).


deleteRom ​

cpp
void deleteRom(RomType type)

Defined in VirtualC64.h:2005

Removes an installed ROM The ROM contents is overwritten with zeroes.


deleteRoms ​

cpp
void deleteRoms()

Defined in VirtualC64.h:2010

Removes all installed ROMs including the floppy drive ROMs. The ROM contents is overwritten with zeroes.


saveRom ​

cpp
void saveRom(const std::filesystem::path & path, RomType rom)

Defined in VirtualC64.h:2016

Saves a ROM to disk.

Exceptions ​

ExceptionDescription
Errorif the file cannot be written.

installOpenRom ​

cpp
void installOpenRom(RomType type)

Defined in VirtualC64.h:2020

Installes a MEGA65 OpenRom.


installOpenRoms ​

cpp
void installOpenRoms()

Defined in VirtualC64.h:2024

Install all three MEGA65 OpenROMs.


flash ​

cpp
void flash(const std::filesystem::path & path, isize item = 0)

Defined in VirtualC64.h:2033

Flashes a file into memory.


flashAsync ​

cpp
void flashAsync(const std::filesystem::path & path, isize item = 0)

Defined in VirtualC64.h:2040

Asynchronous version of flash(): queues the request and returns at once.

The file is read on the emulator thread. Success and failure are both reported by the usual message (e.g., CRT_ATTACHED). If the request failed, the message carries the exception.