emu_create
Create a new emulator instance.Returns
- Non-null pointer: Successfully created emulator instance
- NULL: Allocation failure (out of memory)
Description
Allocates and initializes a new thread-safe emulator instance. The returned pointer is opaque and should only be used with other API functions. The emulator starts in a reset state with no ROM loaded. All operations on the returned pointer are thread-safe due to internal synchronization via mutex.Example
Notes
- Always check for NULL return value
- Must call
emu_destroy()when done to prevent memory leaks - The instance starts with no ROM loaded - call
emu_load_rom()before execution
emu_destroy
Destroy an emulator instance and free all resources.Parameters
- emu: Pointer to emulator instance (may be NULL)
Description
Frees all memory associated with the emulator instance, including internal buffers, framebuffer, and emulation state. Safe to call with a NULL pointer (no-op). After calling this function, the pointer is invalid and must not be used.Example
Notes
- Safe to call with NULL pointer
- Blocks if another thread holds the internal mutex (waits for completion)
- All pointers obtained from the emulator (framebuffer, etc.) become invalid
emu_reset
Reset the emulator to initial state.Parameters
- emu: Pointer to emulator instance
Description
Resets the emulator to its initial power-off state. This clears CPU registers, resets peripherals, and clears RAM, but preserves the loaded ROM. This is equivalent to removing the batteries from the calculator and reinserting them. To start execution after reset, callemu_power_on().
Example
Notes
- Safe to call with NULL pointer (no-op)
- ROM remains loaded - no need to call
emu_load_rom()again - RAM is cleared - any programs or data in RAM are lost
- Must call
emu_power_on()after reset to begin execution
emu_power_on
Power on the calculator by simulating ON key press and release.Parameters
- emu: Pointer to emulator instance
Description
Simulates pressing and releasing the ON key, which wakes the calculator from powered-off state and begins execution. Must be called afteremu_load_rom() and before emu_run_cycles() to start the boot sequence.
This triggers the boot process where the TI-OS initializes hardware, checks for OS updates, and eventually displays the home screen.
Example
Notes
- Safe to call with NULL pointer (no-op)
- Must be called after
emu_load_rom()for execution to begin - Can be called multiple times (simulates repeated ON key presses)
- The boot process takes approximately 1-2 seconds of emulated time
Complete Lifecycle Example
emu_set_log_callback
Set an optional log callback for emulator events.Parameters
- callback: Function pointer to log callback, or NULL to disable logging
Description
Sets a callback function that will be invoked when the emulator generates log messages. The callback receives a null-terminated C string containing the log message. Pass NULL to disable logging.Example
Notes
- The callback is global and applies to all emulator instances
- The message pointer is only valid during the callback
- The callback must be thread-safe if using multiple emulator instances
- Logging can impact performance in tight loops
See Also
- ROM Management - Load ROM and send files
- Execution - Run emulation cycles
- C API Overview - General usage patterns