Emu struct is the main emulator orchestrator that coordinates the CPU, bus, and peripherals to run the TI-84 Plus CE. It provides the high-level API for running the emulator and managing state.
Overview
TheEmu struct is defined in core/src/emu.rs and contains:
Creating an Emulator
Rust API
C API
SyncEmu, a thread-safe wrapper that contains a Mutex<Emu>. All FFI operations are synchronized to prevent data races.
Loading ROM
Before running the emulator, you must load a TI-84 Plus CE ROM:ROM Requirements
- Size: Up to 4MB (0x400000 bytes)
- Format: Raw binary dump from TI-84 Plus CE
- Source: Extracted from calculator or official TI OS
Powering On
After loading the ROM, power on the calculator:Running Cycles
The main emulation loop runs a specified number of CPU cycles:Cycle Counting
The emulator returns the actual number of cycles executed, which may differ from the requested amount due to:- HALT instruction: CPU stops until interrupt or key press
- Device power off: User pressed 2nd+ON or OS triggered APD
- Breakpoint hit: Debug breakpoint reached (Rust API only)
Frame Timing
For 60 FPS emulation at 48 MHz:Framebuffer Access
The emulator maintains a 320×240 ARGB8888 framebuffer:The framebuffer is updated by calling
render_frame() (Rust) or automatically during emu_run_cycles() (C API).Key Input
The keypad is an 8×8 matrix. Press/release keys with:Key Matrix Layout
The 8×8 key matrix maps to physical keys:| Row | Col 0 | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6 | Col 7 |
|---|---|---|---|---|---|---|---|---|
| 0 | Graph | Trace | Zoom | Wind | Y= | 2nd | Mode | Del |
| 1 | Sto | Ln | Log | x² | x⁻¹ | Math | Alpha | — |
| 2 | 0 | 1 | 4 | 7 | , | Sin | Apps | X,T,θ |
| 3 | . | 2 | 5 | 8 | ( | Cos | Prgm | Stat |
| 4 | (-) | 3 | 6 | 9 | ) | Tan | Vars | — |
| 5 | Enter | + | - | × | ÷ | ^ | Clear | — |
| 6 | Down | Left | Right | Up | — | — | — | — |
| 7 | — | — | — | — | — | — | — | — |
Row/column indices are zero-based. For example, the ENTER key is at row 5, column 0 (not row 6, column 1 as shown in some diagrams).
State Management
Save State
Load State
Sending Files
You can send .8xp (programs) and .8xv (variables) files to the emulator:Files must be sent after
load_rom() but before power_on(). The emulator injects them into the flash archive so TI-OS discovers them on boot.LCD State
Query LCD state for accurate display rendering:Public Methods
Core Methods
Display Methods
Input Methods
State Methods
File Transfer Methods
Internal Architecture
TheEmu struct orchestrates several subsystems:
Execution Flow
- Fetch: CPU reads instruction from memory via bus
- Decode: CPU decodes opcode and determines operation
- Execute: CPU performs operation, updating registers/memory
- Tick: Peripherals advance by elapsed cycles
- Schedule: Check for pending events (LCD refresh, timer overflow, etc.)
- Interrupt: Check for pending interrupts and handle if enabled
Next Steps
Memory Types
Learn about Flash, RAM, and memory map
CPU Module
Explore the eZ80 CPU implementation
Peripherals
Understand peripheral controllers
Testing
Test the emulator with boot/trace tools