pub struct TrapDispatcher {Show 72 fields
pub ae_handlers: HashMap<(u32, u32), (u32, u32)>,
pub vfs: HashMap<String, Vec<u8>>,
pub vfs_rsrc: HashMap<String, Vec<u8>>,
pub locked_files: HashSet<String>,
pub output_dir: Option<PathBuf>,
pub hilite_color: (u16, u16, u16),
pub op_color: (u16, u16, u16),
pub char_extra: i32,
pub bk_pat: [u8; 8],
pub pn_pat: [u8; 8],
pub fullscreen_locked: bool,
pub menu_bar_hidden: bool,
pub sound_manager: SoundManager,
pub debug_getkeys_nonzero_count: u64,
pub debug_last_getkeys_nonzero_key_map: [u8; 16],
pub debug_key_event_delivery_count: u64,
pub debug_last_key_event_message: u32,
pub debug_wait_next_event_count: u64,
pub debug_get_next_event_count: u64,
pub debug_mouse_moved_event_count: u64,
pub debug_get_mouse_count: u64,
pub debug_get_mouse_local_change_count: u64,
pub debug_get_mouse_last_local: (i16, i16),
pub debug_get_mouse_last_global: (i16, i16),
pub debug_get_mouse_last_port: u32,
pub debug_get_mouse_last_port_bounds_top_left: (i16, i16),
pub debug_still_down_true_count: u64,
pub debug_still_down_false_count: u64,
pub debug_button_true_count: u64,
pub debug_button_false_count: u64,
pub debug_wait_mouse_up_true_count: u64,
pub debug_wait_mouse_up_false_count: u64,
pub debug_set_origin_count: u64,
pub debug_copy_bits_count: u64,
pub debug_scroll_rect_count: u64,
pub debug_scroll_rect_nonzero_delta_count: u64,
pub debug_scroll_rect_changed_byte_count: u64,
pub debug_scroll_rect_last_changed_bytes: u64,
pub debug_scroll_rect_last_rect: (i16, i16, i16, i16),
pub debug_scroll_rect_last_delta: (i16, i16),
pub debug_scroll_rect_last_port: u32,
pub debug_scroll_rect_last_base: u32,
pub debug_scroll_rect_last_row_bytes: u16,
pub debug_scroll_rect_last_port_bounds_top_left: (i16, i16),
pub debug_scroll_rect_last_is_color: bool,
pub pending_delay_ticks: u32,
pub trap_count: u64,
pub game_trap_count: u64,
pub trap_histogram: Box<[u64; 4096]>,
pub trap_time_ns: Box<[u64; 4096]>,
pub inline_skipped: Box<[u64; 4096]>,
pub copybits_screen_count: u64,
pub last_screen_copybits_rect: Option<ScreenCopyBitsRect>,
pub screen_event_count: u64,
pub copybits_screen_secs: Vec<u64>,
pub screen_mode: (u32, u32, u16, u16, u16),
pub device_clut: [[u16; 3]; 256],
pub color_manager_clut: [[u16; 3]; 256],
pub clut_protected: [bool; 256],
pub clut_reserved: [bool; 256],
pub fill_black_override: Option<[u8; 8]>,
pub dialog_tracking: Option<DialogTrackingState>,
pub dialog_items: HashMap<u32, Vec<DialogItem>>,
pub scrap_entries: Vec<([u8; 4], Vec<u8>)>,
pub scrap_count: i16,
pub scrap_in_memory: bool,
pub last_init_pack_id: Option<i16>,
pub scrap_handle: Option<u32>,
pub scrap_handle_dirty: bool,
pub scrap_stuff_ptr: Option<u32>,
pub res_load: bool,
pub res_purge: bool,
/* private fields */
}Expand description
Trap dispatcher with resource fork access and emulator state.
Fields§
§ae_handlers: HashMap<(u32, u32), (u32, u32)>AppleEvent handlers registered by the guest via Pack8 routine 31
(AEInstallEventHandler). Key is (eventClass, eventID) packed
as 4-char-codes; value is (handler_proc_ptr, handler_refcon).
Inside Macintosh Volume VI, 6-43.
vfs: HashMap<String, Vec<u8>>Virtual filesystem: filename -> data fork contents
vfs_rsrc: HashMap<String, Vec<u8>>Virtual filesystem: filename -> resource fork contents
locked_files: HashSet<String>Set of VFS keys whose ioFlAttrib lock bit is set.
Maintained by SetFilLock/HSetFLock ($A041/$A241) and
RstFilLock/HRstFLock ($A042/$A242); read by
fill_file_catalog_info to set bit 0 of ioFlAttrib.
Files 1992, 2-205 (ioFlAttrib field), 9302..9352 (HSetFLock/HRstFLock).
Public to mirror vfs/vfs_rsrc so frontends and tests can
inspect or seed lock state directly.
output_dir: Option<PathBuf>Host directory to write output files to (if set)
hilite_color: (u16, u16, u16)Current hilite color (RGBColor: R, G, B). Set by HiliteColor ($AA22) and conceptually stored in the cGrafPort’s grafVars handle per IM:V V-149. Systemless uses a single dispatcher field since most apps only have one cGrafPort active at a time.
op_color: (u16, u16, u16)Operation color (RGBColor: R, G, B) for arithmetic transfer modes (addPin, subPin, blend). Set by OpColor ($AA21) and stored in the grafVars handle’s rgbOpColor field per IM:V V-77. Initialized to black per IM:V V-63.
char_extra: i32Extra horizontal pixels added to each non-space character when drawing text, expressed as a Fixed16.16 value. Set by CharExtra ($AA23) per IM:V V-149.
bk_pat: [u8; 8]Current background pattern
pn_pat: [u8; 8]Current pen pattern
fullscreen_locked: boolSet once the game has entered fullscreen (window covers entire screen and MBarHeight was 0). While set, the menu bar is suppressed even if the game temporarily restores MBarHeight (e.g. on cursor-at-top).
Host-controlled override for menu bar visibility. When true, the menu
bar is suppressed regardless of game state — unlike fullscreen_locked
which the emulator auto-clears when the game writes MBarHeight > 0.
Defaults to true so the HLE renders like a kiosk by default; the
menu bar is a Mac OS chrome surface that has no analogue in a game-
only runtime, and showing it diverges screenshots from the
original-machine reference whenever the cursor hovers y < 20.
Set SYSTEMLESS_SHOW_MENU_BAR=1 (or assign menu_bar_hidden = false
after construction) to opt back in for environments where the menu
bar IS the user-facing surface (e.g. running a Mac app, not a game).
sound_manager: SoundManagerSound Manager state (channels, playback buffers).
debug_getkeys_nonzero_count: u64Debug counter for GetKeys calls that observed at least one held key.
debug_last_getkeys_nonzero_key_map: [u8; 16]Last non-zero KeyMap returned by GetKeys. Used by regression tests to prove games are polling the same key state a frontend injected.
debug_key_event_delivery_count: u64Debug counter for keyDown/keyUp records delivered through Event Manager.
debug_last_key_event_message: u32Last keyDown/keyUp EventRecord.message delivered through Event Manager.
debug_wait_next_event_count: u64Debug counter for WaitNextEvent calls observed by scripted probes.
debug_get_next_event_count: u64Debug counter for GetNextEvent calls observed by scripted probes.
debug_mouse_moved_event_count: u64Debug counter for mouse-moved OS events synthesized by WaitNextEvent.
debug_get_mouse_count: u64Debug counter for GetMouse calls observed by scripted probes.
debug_get_mouse_local_change_count: u64Debug snapshots for GetMouse coordinate conversion.
debug_get_mouse_last_local: (i16, i16)§debug_get_mouse_last_global: (i16, i16)§debug_get_mouse_last_port: u32§debug_get_mouse_last_port_bounds_top_left: (i16, i16)§debug_still_down_true_count: u64Debug counters for StillDown return values observed by scripted probes.
debug_still_down_false_count: u64Debug counters for Button return values observed by scripted probes.
debug_wait_mouse_up_true_count: u64Debug counters for WaitMouseUp return values observed by scripted probes.
debug_wait_mouse_up_false_count: u64§debug_set_origin_count: u64Debug counters for QuickDraw activity during scripted probes.
debug_copy_bits_count: u64§debug_scroll_rect_count: u64§debug_scroll_rect_nonzero_delta_count: u64§debug_scroll_rect_changed_byte_count: u64§debug_scroll_rect_last_changed_bytes: u64§debug_scroll_rect_last_rect: (i16, i16, i16, i16)§debug_scroll_rect_last_delta: (i16, i16)§debug_scroll_rect_last_port: u32§debug_scroll_rect_last_base: u32§debug_scroll_rect_last_row_bytes: u16§debug_scroll_rect_last_port_bounds_top_left: (i16, i16)§debug_scroll_rect_last_is_color: bool§pending_delay_ticks: u32Remaining ticks for the Delay ($A03B) trap to consume. On a real Mac, Delay blocks the application for numTicks; in our HLE the runner drains these one-at-a-time via advance_guest_tick(). Inside Macintosh Volume II, II-384
trap_count: u64Total number of A-line trap dispatches since emulator start.
game_trap_count: u64A-line traps dispatched from game code only (PC < 0x800000). Excludes ROM/system traps for cross-emulator deterministic sync.
trap_histogram: Box<[u64; 4096]>Per-trap dispatch counter, populated only when
SYSTEMLESS_TRACE_TRAP_COUNTS=1 is set. Indexed by the low 12 bits of
the trap word. Dump via print_trap_histogram.
trap_time_ns: Box<[u64; 4096]>Per-trap accumulated wall-clock time (ns), populated only when
SYSTEMLESS_TRACE_TRAP_TIMING=1 is set. The Instant::now() call adds
~20-30ns measurement overhead per trap when enabled. Dump via
print_trap_timing_histogram.
inline_skipped: Box<[u64; 4096]>Per-trap count of inline-skipped dispatches. Incremented by the
runner’s pre-dispatch fast paths for each virtual trap entry that
bypassed the real dispatch() body. Combined with
trap_histogram\[idx\] (total entries) and trap_time_ns\[idx\]
(only counts non-inline dispatches), gives:
actual_dispatches = trap_histogram\[idx\] - inline_skipped\[idx\]
per-actual-dispatch ns = trap_time_ns\[idx\] / actual_dispatches
copybits_screen_count: u64Number of copybits_screen events emitted (screen-affecting draws).
last_screen_copybits_rect: Option<ScreenCopyBitsRect>Most recent sizeable CopyBits blit into the screen framebuffer.
screen_event_count: u64Count of all screen-affecting trace events captured so far.
copybits_screen_secs: Vec<u64>screen_event_count values where the recorded event was specifically
a copybits_screen (framebuffer-mutating blit), in emission order.
Used by the trace interpreter to rebind checkpoints away from
non-CopyBits screen events (e.g. SetEntries CLUT updates) so the
captured snapshot reflects a settled framebuffer rather than a
transient mid-fade palette.
screen_mode: (u32, u32, u16, u16, u16)Screen mode: (screen_base, row_bytes, width, height, pixel_size) Defaults to 800x600 8bpp.
device_clut: [[u16; 3]; 256]Runtime device CLUT for 8bpp mode. 256 entries of [R, G, B] in 16-bit Mac values. Initialized to the standard Mac 8-bit system palette. Updated by SetEntries trap and low-level video driver cscSetEntries. Used for DISPLAY rendering only.
color_manager_clut: [[u16; 3]; 256]Color Manager CLUT for 8bpp mode. Updated only by high-level SetEntries ($AA3F) and ActivatePalette — NOT by low-level video driver palette fades. Used by QuickDraw shape drawing (PaintRect, etc.) for RGB→index mapping, mirroring the real Mac OS ITable which is derived from the Color Manager palette. Imaging With QuickDraw 1994, p. 4-82
clut_protected: [bool; 256]Per-entry protection bits for the device CLUT, set by ProtectEntry
($AA3D) and cleared by ProtectEntry(false). When clut_protected[i]
is true, SetEntries refuses to overwrite device_clut[i].
Inside Macintosh Volume V, V-145
clut_reserved: [bool; 256]Per-entry reservation bits for the device CLUT, set by ReserveEntry
($AA3E) and cleared by ReserveEntry(false). When clut_reserved[i]
is true the entry is excluded from Color2Index / RGBForeColor
matching (palette-animation slots), and SetEntries refuses to
overwrite it from a different client.
Inside Macintosh Volume V, V-145
fill_black_override: Option<[u8; 8]>Optional override pattern for FillRect when the game passes the QD black
global as the fill pattern. Used to work around games that should use a
dithered city/object pattern but were compiled with black instead.
dialog_tracking: Option<DialogTrackingState>Active dialog tracking state (non-None while ModalDialog is tracking input)
dialog_items: HashMap<u32, Vec<DialogItem>>Parsed dialog items keyed by dialog pointer, for GetDItem/ModalDialog
scrap_entries: Vec<([u8; 4], Vec<u8>)>Desk scrap contents: list of (type_code, data) entries. Each entry stores a 4-byte ResType and the raw data bytes. Inside Macintosh Volume I, I-453
scrap_count: i16Scrap change counter, incremented by ZeroScrap. Inside Macintosh Volume I, I-458
scrap_in_memory: boolTrue when the desk scrap is resident in memory. False means InfoScrap reports the scrap on disk and hides the handle until LoadScrap/ZeroScrap brings it back into memory.
last_init_pack_id: Option<i16>Most recent pack ID passed to InitPack. Kept as lightweight bookkeeping for future pack-specific heuristics.
scrap_handle: Option<u32>Guest address of the master pointer for the in-memory desk scrap. Lazily allocated on first InfoScrap call. Inside Macintosh Volume I, I-457
scrap_handle_dirty: boolTrue when the serialized desk scrap handle needs rebuilding from
scrap_entries before the next InfoScrap observation.
scrap_stuff_ptr: Option<u32>Guest address of the ScrapStuff record returned by InfoScrap. Lazily allocated on first InfoScrap call. Inside Macintosh Volume I, I-457
res_load: boolWhether SetResLoad(TRUE) is active (default: true). When false, resource-retrieval functions return empty handles. Inside Macintosh Volume I, I-118
res_purge: boolWhether SetResPurge(TRUE) is active (default: false). When true, resources are written to disk before purging if modified. Inside Macintosh Volume I, I-126
Implementations§
Source§impl TrapDispatcher
impl TrapDispatcher
Sourcepub fn te_auto_scroll_enabled(&self, te_handle: u32) -> bool
pub fn te_auto_scroll_enabled(&self, te_handle: u32) -> bool
Whether auto-scroll is enabled on the TextEdit record at
te_handle (set by TEAutoView per IM:V V-173). Public
projection over textedit_states[te].feature_bits so
integration tests can observe TEAutoView’s effect without
access to the private feature-bit constants.
Source§impl TrapDispatcher
impl TrapDispatcher
Number of menus currently loaded (added via InsertMenu, NewMenu, GetNewMBar, etc.). Used by ctx.json snapshots so observers can see whether the menu bar was populated at capture time without re-instrumenting.
Iterator over the loaded menu titles, in insertion order. Titles may include embedded bytes for Apple-menu icons etc.; callers should handle non-ASCII defensively.
Sourcepub fn front_window(&self) -> u32
pub fn front_window(&self) -> u32
Frontmost WindowPtr tracked by the Window Manager, or NIL.
Sourcepub fn window_bounds(&self) -> (i16, i16, i16, i16)
pub fn window_bounds(&self) -> (i16, i16, i16, i16)
Cached global bounds of the front window content rect.
Sourcepub fn visible_dialog_bounds(&self) -> Option<(i16, i16, i16, i16)>
pub fn visible_dialog_bounds(&self) -> Option<(i16, i16, i16, i16)>
Bounds of a retained visible dialog, if one is currently drawn.
Sourcepub fn window_count(&self) -> usize
pub fn window_count(&self) -> usize
Number of windows currently tracked by the Window Manager list.
Number of items in the menu identified by handle, or
None if no menu with that handle is registered. Used by
tests to observe AppendMenu / DeleteMenuItem /
InsertMenuItem / DeleteMenu effects on host-side state.
Sourcepub fn dialog_is_registered(&self, dialog_ptr: u32) -> bool
pub fn dialog_is_registered(&self, dialog_ptr: u32) -> bool
Whether the dialog at dialog_ptr is currently registered
with an item list. Used by tests to observe
NewDialog / GetNewDialog / DisposDialog effects on
dialog_items state.
Text of the 1-based item in the menu identified by
handle. Returns None if the menu isn’t registered or
item_one_based is out of range. Used by tests to observe
SetItem, AppendMenu-text, InsertMenuItem side effects.
Sourcepub fn set_current_port_for_test(&mut self, port: u32)
pub fn set_current_port_for_test(&mut self, port: u32)
Test-only: set the current port without going through SetPort. Used by integration test helpers like setup_with_cgraf_port().
Sourcepub fn save_dialog_pixels_for_test(
&self,
bus: &MacMemoryBus,
rect: (i16, i16, i16, i16),
) -> Vec<u8> ⓘ
pub fn save_dialog_pixels_for_test( &self, bus: &MacMemoryBus, rect: (i16, i16, i16, i16), ) -> Vec<u8> ⓘ
Test-only: invoke save_dialog_pixels for the byte-isomorphism gate. Used by tests asserting the bulk path returns the same bytes the per-pixel reference would have produced.
Sourcepub fn restore_dialog_pixels_for_test(
&self,
bus: &mut MacMemoryBus,
rect: (i16, i16, i16, i16),
saved: &[u8],
)
pub fn restore_dialog_pixels_for_test( &self, bus: &mut MacMemoryBus, rect: (i16, i16, i16, i16), saved: &[u8], )
Test-only: invoke restore_dialog_pixels for the byte-isomorphism gate. Used by tests asserting the bulk path writes the same bytes the per-pixel reference would have written.
Sourcepub fn set_tick_count_for_test(&mut self, tick: u32)
pub fn set_tick_count_for_test(&mut self, tick: u32)
Test-only: set the tick count. Production code uses advance_guest_tick() to update tick_count.
Sourcepub fn set_sent_open_app_event_for_test(&mut self, sent: bool)
pub fn set_sent_open_app_event_for_test(&mut self, sent: bool)
Test-only: mark the synthetic kAEOpenApplication event as already delivered so the next GetNextEvent/WaitNextEvent returns a real null event instead of the boot-time oapp stub.
Sourcepub fn set_screen_mode_for_test(
&mut self,
base: u32,
row_bytes: u32,
width: u16,
height: u16,
depth: u16,
)
pub fn set_screen_mode_for_test( &mut self, base: u32, row_bytes: u32, width: u16, height: u16, depth: u16, )
Test-only: set the screen mode (base, rowBytes, width, height, depth). Production code initializes screen_mode from the machine profile.
Sourcepub fn install_test_resource(
&mut self,
bus: &mut MacMemoryBus,
res_type: [u8; 4],
id: i16,
data: &[u8],
) -> u32
pub fn install_test_resource( &mut self, bus: &mut MacMemoryBus, res_type: [u8; 4], id: i16, data: &[u8], ) -> u32
Test-only: install a resource into the current application file (refnum 0)
without needing a parsed ResourceFork. Allocates data on the guest bus
and registers it under (type, id). Returns the guest address of the data.
Production code initializes resources by parsing a real fork via
load_resources. Use this helper in integration tests that just need a
resource visible to traps like GetResource, GetCursor, GetString, etc.
Sourcepub fn install_test_resource_in_file(
&mut self,
bus: &mut MacMemoryBus,
refnum: u16,
res_type: [u8; 4],
id: i16,
data: &[u8],
) -> u32
pub fn install_test_resource_in_file( &mut self, bus: &mut MacMemoryBus, refnum: u16, res_type: [u8; 4], id: i16, data: &[u8], ) -> u32
Test-only: variant of install_test_resource that targets a specific
refnum. Use when a test needs to assert current-file-vs-search-chain
semantics (e.g. Get1IndResource $A80E vs GetIndResource $A99D —
IM:IV-15). Refnums are appended to search_order in install order so
the file becomes part of the chain; the current file is left
unchanged so the test can drive UseResFile ($A998) explicitly.
Sourcepub fn install_named_test_resource_in_file(
&mut self,
bus: &mut MacMemoryBus,
refnum: u16,
res_type: [u8; 4],
id: i16,
name: &str,
data: &[u8],
) -> u32
pub fn install_named_test_resource_in_file( &mut self, bus: &mut MacMemoryBus, refnum: u16, res_type: [u8; 4], id: i16, name: &str, data: &[u8], ) -> u32
Test-only: variant of install_test_resource_in_file that also
records the resource name. Required by traps that walk the
resource fork by NAME (AddResMenu / InsertResMenu / GetNamedResource)
— without the named entry the resource is invisible to those
callers even though the (type, id) entry exists.
Sourcepub fn set_trace_sink(&mut self, sink: Box<dyn TraceSink>)
pub fn set_trace_sink(&mut self, sink: Box<dyn TraceSink>)
Install a trace sink to receive runtime events and screen
snapshots. The sink (and where it persists output) is the host’s
concern; see crate::trace::TraceSink.
pub fn trace_source(&self) -> Option<TraceSource>
pub fn enable_input_trace_capture(&mut self)
pub fn input_trace_text(&self) -> String
Sourcepub fn print_trap_histogram(&self, top_n: usize)
pub fn print_trap_histogram(&self, top_n: usize)
Dump the top-N traps by dispatch count in descending order. No-op
when SYSTEMLESS_TRACE_TRAP_COUNTS was not set at startup. Format:
[TRAP-HIST] 100234 $A9ED PostEvent
Sourcepub fn print_trap_timing_histogram(&self, top_n: usize)
pub fn print_trap_timing_histogram(&self, top_n: usize)
Dump the top-N traps by accumulated wall-clock time (descending).
No-op when SYSTEMLESS_TRACE_TRAP_TIMING was not set at startup.
Format:
[TRAP-TIME] 1234567 ns 12.5 ns/call (98765 calls) idx=$xxx …
Pairs with print_trap_histogram to distinguish “hot because called
a lot” from “hot because each call is slow”.
pub fn new() -> Self
pub fn set_ui_theme_id(&mut self, ui_theme_id: UiThemeId)
pub fn ui_theme_id(&self) -> UiThemeId
pub fn ui_theme(&self) -> &'static dyn UiTheme
Whether MenuSelect is actively tracking the mouse.
Sourcepub fn is_dialog_tracking(&self) -> bool
pub fn is_dialog_tracking(&self) -> bool
Whether ModalDialog is actively tracking user input.
Sourcepub fn is_standard_file_put_tracking(&self) -> bool
pub fn is_standard_file_put_tracking(&self) -> bool
Whether StandardPutFile/CustomPutFile is actively tracking input.
Sourcepub fn is_standard_file_get_tracking(&self) -> bool
pub fn is_standard_file_get_tracking(&self) -> bool
Whether StandardGetFile/CustomGetFile is actively tracking input.
Sourcepub fn is_control_tracking(&self) -> bool
pub fn is_control_tracking(&self) -> bool
Whether TrackControl is actively tracking a control.
Sourcepub fn is_tracking_refire(&self, opcode: u16) -> bool
pub fn is_tracking_refire(&self, opcode: u16) -> bool
Shared check used by both dispatch.rs (auto-pop push-back) and runner.rs (PC rewind for refire). Returns true when the given trap word should refire next frame because menu or dialog tracking is active and the trap is one of the refire-relevant kind. Strips the auto-pop bit (0x0400) so auto-pop variants ($AD3D, $AC0B, $AD91) match too.
Sourcepub fn register_segments(&mut self, segments: HashMap<i16, u32>)
pub fn register_segments(&mut self, segments: HashMap<i16, u32>)
Register loaded segments for LoadSeg trap.
pub fn launched_app_path(&self) -> Option<&str>
pub fn remove_vfs_path(&mut self, name: &str) -> bool
pub fn remove_vfs_path_relative_to_launched_app(&mut self, name: &str) -> bool
Sourcepub fn set_mouse_position(&mut self, v: i16, h: i16)
pub fn set_mouse_position(&mut self, v: i16, h: i16)
Update the current mouse position (called from GUI layer). Coordinates are in Mac screen space (0,0 = top-left of screen).
Sourcepub fn push_mouse_down(&mut self, v: i16, h: i16)
pub fn push_mouse_down(&mut self, v: i16, h: i16)
Push a mouse-down event into the event queue.
Sourcepub fn push_mouse_up(&mut self, v: i16, h: i16)
pub fn push_mouse_up(&mut self, v: i16, h: i16)
Push a mouse-up event into the event queue. Update the hardware button state immediately on release. Button() reflects the physical state, while StillDown()/WaitMouseUp() combine that state with pending mouse events to decide whether the original click is still in progress.
Sourcepub fn push_key_down(&mut self, key_code: u8, char_code: u8)
pub fn push_key_down(&mut self, key_code: u8, char_code: u8)
Push a key-down event into the event queue.
Sourcepub fn push_key_up(&mut self, key_code: u8, char_code: u8)
pub fn push_key_up(&mut self, key_code: u8, char_code: u8)
Push a key-up event into the event queue.
Sourcepub fn cursor(&self) -> Option<&CursorImage>
pub fn cursor(&self) -> Option<&CursorImage>
Get the current cursor data for rendering overlay.
Sourcepub fn show_cursor(&mut self)
pub fn show_cursor(&mut self)
Show the cursor (called by GUI on mouse move to undo ObscureCursor).
Sourcepub fn cursor_visible(&self) -> bool
pub fn cursor_visible(&self) -> bool
Check if cursor is visible (for debug logging).
Sourcepub fn cursor_level(&self) -> i16
pub fn cursor_level(&self) -> i16
Current cursor hide/show nesting level.
Sourcepub fn cursor_data_present(&self) -> bool
pub fn cursor_data_present(&self) -> bool
Whether a cursor image is installed, independent of visibility.
Sourcepub fn fullscreen_input_transform(&self) -> Option<ScreenCopyBitsRect>
pub fn fullscreen_input_transform(&self) -> Option<ScreenCopyBitsRect>
Explicit screen-space transform for frontends that need to map host mouse coordinates back into a fullscreen game’s source playfield.
This is derived only from a sizeable CopyBits call into the screen framebuffer, not from rendered pixels. It is active while a game is in fullscreen mode and has hidden the Mac cursor, which is the common contract for software-cursor playfields such as first-person or crosshair-driven games. Visible Mac cursor UI, including menu bars and title screens, keeps normal screen coordinates.
Sourcepub fn cursor_data(&self) -> Option<([u8; 32], [u8; 32], i16, i16)>
pub fn cursor_data(&self) -> Option<([u8; 32], [u8; 32], i16, i16)>
Current cursor bitmap + mask + hotspot, as installed by
SetCursor / InitCursor. Returns (data[32], mask[32], hotSpot.v, hotSpot.h). None when no cursor has been
installed and the dispatcher was never initialised (rare —
TrapDispatcher::new() seeds the default arrow). Used by
tests to observe SetCursor’s bitmap-storage effect.
Sourcepub fn mouse_position(&self) -> (i16, i16)
pub fn mouse_position(&self) -> (i16, i16)
Get the current mouse position.
Sourcepub fn timer_task_count(&self) -> usize
pub fn timer_task_count(&self) -> usize
Number of Time Manager tasks currently in the queue. Per IM:IV IV-300, InsTime adds a task and RmvTime removes one; this accessor lets tests observe the effect.
Sourcepub fn timer_task_active(&self, task_ptr: u32) -> Option<bool>
pub fn timer_task_active(&self, task_ptr: u32) -> Option<bool>
Whether the Time Manager task whose TMTask record lives at
task_ptr has been activated (via PrimeTime). Returns
None if no such task is installed, Some(bool) otherwise.
Per IM:IV IV-301, PrimeTime sets the active flag + schedules
fire_at_tick; this accessor lets tests observe both.
Sourcepub fn timer_task_fire_at(&self, task_ptr: u32) -> Option<u32>
pub fn timer_task_fire_at(&self, task_ptr: u32) -> Option<u32>
Scheduled fire tick for an installed Time Manager task.
Paired with timer_task_active for PrimeTime assertions.
Sourcepub fn has_resource_type(&self, res_type: &[u8; 4]) -> bool
pub fn has_resource_type(&self, res_type: &[u8; 4]) -> bool
Check whether a resource of the given type exists in the loaded resources.
Sourcepub fn load_resources(&mut self, fork: &ResourceFork, bus: &mut MacMemoryBus)
pub fn load_resources(&mut self, fork: &ResourceFork, bus: &mut MacMemoryBus)
Load resources into guest memory for trap access. Loads ALL resource types from the fork (not just a hardcoded whitelist).
Sourcepub fn merge_resources_from_fork(
&mut self,
fork: &ResourceFork,
bus: &mut MacMemoryBus,
refnum: u16,
)
pub fn merge_resources_from_fork( &mut self, fork: &ResourceFork, bus: &mut MacMemoryBus, refnum: u16, )
Load resources from a resource fork and merge them into the existing resource map. Used when the app opens additional resource files (e.g. Sounds, Images).
Source§impl TrapDispatcher
impl TrapDispatcher
Sourcepub fn redraw_chrome(&mut self, bus: &mut MacMemoryBus)
pub fn redraw_chrome(&mut self, bus: &mut MacMemoryBus)
Redraw the menu bar and window chrome into the framebuffer.
On a real Mac, the Window Manager maintains these UI elements and redraws them after any update. Our emulator draws them as raw framebuffer pixels, so game drawing (explosions, etc.) can overwrite them. This method restores the chrome and should be called after each frame of emulation.
Source§impl TrapDispatcher
impl TrapDispatcher
Sourcepub fn ensure_main_gdevice(&mut self, bus: &mut MacMemoryBus) -> u32
pub fn ensure_main_gdevice(&mut self, bus: &mut MacMemoryBus) -> u32
Allocate the main GDevice in guest memory if not yet done.
Source§impl TrapDispatcher
impl TrapDispatcher
Sourcepub fn load_double_buffer_samples(
bus: &mut MacMemoryBus,
chan: &mut SndChannel,
buf_ptr: u32,
sample_rate: u32,
num_channels: usize,
sample_size: usize,
)
pub fn load_double_buffer_samples( bus: &mut MacMemoryBus, chan: &mut SndChannel, buf_ptr: u32, sample_rate: u32, num_channels: usize, sample_size: usize, )
Read samples from a SndDoubleBuffer record into the channel’s PlayingBuffer. Called when starting double-buffer playback and after a callback refills a buffer.