Azahar 3DS emulator

v0.1.0
io.github.michvllni/mcp-azahar Checked 1 day ago Published 14 days ago

Test 3DS homebrew in the Azahar emulator: input, screenshots, memory, symbols, save states

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

azahar_attach

Register an Azahar started by hand (RPC server enabled, app loaded) as a session.

ParameterTypeDescription
addressstringRPC address host:port (default 127.0.0.1:45987)
elfstringELF with symbols
logstringAzahar's log file, for azahar_logs
sessionstringsession name (default: the server's default session)

azahar_circle_pad

Move the circle pad to x, y in -154..154 each (0, 0 is centered; x right, y up): for for_ms (default 100 ms) or held until azahar_release.

ParameterTypeDescription
x *integerx coordinate (range in the tool description)
y *integery coordinate (range in the tool description)
for_msintegerduration in milliseconds without hold (default 100)
holdbooleankeep it until azahar_release
sessionstringsession name (default: the server's default session)

azahar_hold

Hold buttons until azahar_release; press, touch and circle pad apply on top. Buttons: A B X Y L R ZL ZR START SELECT UP DOWN LEFT RIGHT HOME POWER (case-insensitive).

ParameterTypeDescription
buttons *null | arraybutton names
sessionstringsession name (default: the server's default session)

azahar_launch

Start Azahar headless with an app in a new session and wait until its RPC server answers (up to 2 minutes). Fails if the session exists or another emulator holds the RPC port. Linux/macOS only. The emulator keeps running until azahar_stop.

ParameterTypeDescription
app *stringpath of the homebrew to boot (.3dsx .cci .3ds .cxi .app .elf)
displaystringexisting X display (e.g. :0) instead of a private Xvfb
elfstringmatching ELF with symbols, for azahar_read_symbol, azahar_wait_for and azahar_symbols
sessionstringsession name (default: the server's default session)

azahar_load_state

Load the state in slot 0-10 (it must exist). Held input is applied again afterwards.

ParameterTypeDescription
slot *integersave state slot 0-10
sessionstringsession name (default: the server's default session)

azahar_logs

Return the last matching lines of Azahar's log (complete lines only) and the byte offset to pass as from next time, to get only lines written since.

ParameterTypeDescription
containsstringonly lines containing this text
fromintegerbyte offset to start at: the offset of a previous call, to get only newer lines
sessionstringsession name (default: the server's default session)
tailintegeronly the last N matching lines (default 200, at most 1000)

azahar_press

Press buttons for for_ms (default 100 ms), then return to the held input. Buttons: A B X Y L R ZL ZR START SELECT UP DOWN LEFT RIGHT HOME POWER (case-insensitive).

ParameterTypeDescription
buttons *null | arraybutton names
for_msintegerhow long to press in milliseconds (default 100)
sessionstringsession name (default: the server's default session)

azahar_read_memory

Read bytes of the app's memory; returns them as hex. Prefer azahar_read_symbol when the app's ELF is known.

ParameterTypeDescription
address *stringvirtual address, hex 0x... or decimal
length *integernumber of bytes, at most 4096 (unmapped memory reads as zeros)
sessionstringsession name (default: the server's default session)

azahar_read_symbol

Read a variable (or address) and decode it by its C type: numbers, bools, enums by name, plain char arrays as text, structs and arrays as JSON. Values over 16 KiB are refused: read a field or element. target is a variable of the app's ELF: a name, then .field and [index] parts ("test_state.touch.x", "table[2]"); C++ "ns::name", static locals "func::name", a static sharing its name "file.c:name". Or an address (hex 0x... or decimal) with type (default u32). Types: u8 u16 u32 u64 s8 s16 s32 s64 f32 f64 bool string bytes (string/bytes need len for addresses).

ParameterTypeDescription
target *stringvariable expression or address
elfstringELF file instead of the session's
lenintegerbyte count for type string/bytes
sessionstringsession name (default: the server's default session)
typestringdecode as this type instead of the DWARF type

azahar_release

Release held buttons, the held touch or circle pad; with nothing named, everything. Buttons: A B X Y L R ZL ZR START SELECT UP DOWN LEFT RIGHT HOME POWER (case-insensitive).

ParameterTypeDescription
buttonsnull | arraybuttons to release; with nothing named everything is released
circle_padbooleancenter the held circle pad
sessionstringsession name (default: the server's default session)
touchbooleanrelease the held touch

azahar_save_state

Save the emulator state to slot 0-10 (overwrites it). For launched sessions it waits until the file is written.

ParameterTypeDescription
slot *integersave state slot 0-10
sessionstringsession name (default: the server's default session)

azahar_screenshot

Capture the next rendered frame of the top, bottom or both screens and return it as PNG image content. With output the PNG is also written to that file (overwritten).

ParameterTypeDescription
outputstringalso save the PNG to this file path
scalenull | integerresolution scale 1-4 (default 1); 0 is Azahar's internal resolution
screenstringtop (default, 400x240), bottom (320x240) or both (two consecutive frames, in 3DS arrangement)
sessionstringsession name (default: the server's default session)
splitbooleanwith screen both: one image per screen

azahar_sequence

Run a scripted test: steps, each with exactly one action and an optional name: press (buttons, with for: 300ms), hold, release (buttons or "all"), touch {x, y, for|hold}, circle_pad {x, y, for|hold}, wait (duration), screenshot {screen, output, scale, split}, write {address, bytes}, assert {target, op, value, type, len}, wait_for {target, op, value, timeout, interval}, save_state (slot), load_state (slot), log_contains {text, timeout}. Durations like 100ms or 2s. The whole sequence is checked before the first step runs; it stops at the first failure. log_contains only matches lines logged duri…

ParameterTypeDescription
elfstringELF for symbol steps instead of the sequence's or session's
filestringsequence file (YAML or JSON); its paths are relative to it
scriptstringsequence as YAML or JSON text instead of file; its paths are relative to the server's first allowed directory
sessionstringsession name (default: the server's default session)

azahar_sessions

List sessions (stale ones are removed).

azahar_status

Show the session: whether the emulator runs and answers RPC, its processes, app, log file and held input. A session that is not running is reported, not an error.

ParameterTypeDescription
sessionstringsession name (default: the server's default session)

azahar_stop

Stop the session's emulator (launched sessions) or forget it (attached sessions). Deletes the session directory unless keep_files.

ParameterTypeDescription
keep_filesbooleankeep the session directory (logs, save states)
sessionstringsession name (default: the server's default session)

azahar_symbols

List variables and functions of the app's ELF (address, size, kind, C type), sorted by name; at most 500, use filter to narrow.

ParameterTypeDescription
elfstringELF file instead of the session's
filterstringonly names containing this text (case-insensitive)
sessionstringsession name (default: the server's default session)

azahar_touch

Touch the bottom screen at x 0-319, y 0-239 (pixels, origin top left): for for_ms (default 100 ms) or held until azahar_release.

ParameterTypeDescription
x *integerx coordinate (range in the tool description)
y *integery coordinate (range in the tool description)
for_msintegerduration in milliseconds without hold (default 100)
holdbooleankeep it until azahar_release
sessionstringsession name (default: the server's default session)

azahar_wait_for

Poll a variable (or address) until it compares true with value, or until timeout_ms (a check failure with the last value). Numbers compare numerically; bools, strings and enum names with eq/ne; changed waits for any change from the first read. target is a variable of the app's ELF: a name, then .field and [index] parts ("test_state.touch.x", "table[2]"); C++ "ns::name", static locals "func::name", a static sharing its name "file.c:name". Or an address (hex 0x... or decimal) with type (default u32). Types: u8 u16 u32 u64 s8 s16 s32 s64 f32 f64 bool string bytes (string/bytes need len for addres…

ParameterTypeDescription
target *stringvariable expression or address
elfstringELF file instead of the session's
interval_msintegerpoll interval in milliseconds (default 50)
lenintegerbyte count for type string/bytes
opstringeq (default), ne, lt, le, gt, ge, or changed (no value)
sessionstringsession name (default: the server's default session)
timeout_msintegerhow long to wait in milliseconds (default 10000)
typestringdecode as this type instead of the DWARF type
valuestringliteral: number (decimal or 0x), true/false, string or enum name

azahar_write_memory

Write bytes to the app's memory and verify by reading back. Writes outside the app's image and heaps are ignored by Azahar and reported as an error.

ParameterTypeDescription
address *stringvirtual address, hex 0x... or decimal
bytes *stringhex bytes in memory order, e.g. "de ad be ef" (0x1234 means bytes 12 34)
sessionstringsession name (default: the server's default session)