Z3DK is a modern toolchain for SNES development, specializing in The Legend of Zelda: A Link to the Past (Zelda 3) ROM hacking. It is a hard fork of Asar (v1.81+) that adds structured output, a language server, and deep integration for modern IDEs.
Status: Active Development (Alpha)
| Tool | Description |
|---|---|
| z3asm | Enhanced Asar assembler with TOML config, JSON diagnostics, and source maps. |
| z3disasm | Smart ROM disassembler that uses symbols to generate re-assemblable bank_XX.asm files. |
| z3lsp | Language Server Protocol implementation for VS Code, Neovim, and Emacs. |
| libz3dk | C++ API for embedding the assembler/disassembler into other tools (like YAZE). |
Build from Source (macOS/Linux):
git clone https://github.com/scawful/z3dk.git
cd z3dk
mkdir build && cd build
cmake ..
makeIf your compiler lacks C++20, disable the language server with cmake -DZ3DK_BUILD_LSP=OFF ...
Executables:
build/bin/z3asmbuild/bin/z3disasmbuild/bin/z3lsp
Create a z3dk.toml in your project root to configure the assembler. This replaces the need for complex CLI flags.
# z3dk.toml
preset = "alttp" # Sets sane defaults for Zelda 3
mapper = "lorom" # Memory mapping
rom_size = 0x200000 # 2MB
include_paths = ["src", "include"]
symbols = "wla" # Generates .sym file
warn_unused_symbols = true
prohibited_memory_ranges = [
"$7E0000-$7E01FF: SRAM scratchpad"
]
lsp_log_enabled = true
lsp_log_path = "z3lsp.log"
# Define compilation targets
emit = [
"diagnostics.json", # For VS Code problem matchers
"symbols.mlb", # For Mesen2 debugging
"hooks.json" # For Z3DK hook tracking
]prohibited_memory_ranges accepts inclusive SNES address ranges. You can use $ or 0x prefixes and add an
optional reason after : (used in diagnostics). lsp_log_enabled toggles z3lsp JSON/error logging, and
lsp_log_path overrides the default temp log location (relative paths resolve to the config directory).
Main file discovery: If you do not create a z3dk.toml, the LSP still picks a main candidate by convention:
any root-level file named Main.asm, *_main.asm, or *-main.asm (e.g. Oracle_main.asm, Meadow_main.asm).
For single-entry projects, a minimal z3dk.toml with main = "Main.asm" and include_paths = ["."] is enough.
Include paths: When all incsrc paths are relative to the project root (or the main file’s directory),
include_paths = ["."] is sufficient. Subdirs like Music/, Engine/, Sprites/ are then found from the root.
- Oracle of Secrets:
z3dk.tomlwithmain = "Oracle_main.asm",include_paths = [".", "Core", "Sprites", ...]. Entry point and modules live under named dirs; LSP and assembler use the configured main. - Poltergeist (AllHallows Eve): Flat root with
Main.asmandinclude_paths = ["."]. Allincsrcpaths (e.g.Music/...,Engine/...) are relative to the root; a minimalz3dk.tomlwithmain = "Main.asm"andinclude_paths = ["."]is enough for LSP and assembly.
Assembly:
# Uses settings from z3dk.toml if present
z3asm src/main.asm game.sfcCLI output is quiet by default. Pass --summary to show the result/summary line items, or --no-summary to force them off.
Disassembly:
# Disassemble bank $02 with symbols
z3disasm --rom game.sfc --symbols game.mlb --bank-start 02 --bank-end 02 --out src/IDE Integration:
- VS Code: Install the extension in
extensions/vscode-z3dk. - Neovim: Configure
lspconfigto usez3lsp.
- Z3ASM overview:
docs/newbook/src/z3asm.md - Z3ASM vs Asar:
docs/newbook/src/z3asm-differences.md - Asar 2.0 compatibility:
docs/newbook/src/z3asm-compat.md - Legacy Asar manual:
docs/newbook/src/legacy-asar.mdanddocs/legacy/
- Structured Output: Emits JSON for errors, warnings, and labels. No more parsing stdout.
- Mesen2 Integration: Native support for
.mlbsymbol files for source-level debugging in Mesen2. - Project-Aware:
z3dk.tomlallows defining the project environment (defines, includes) in one place. - Language Server:
z3lspprovides Go-to-Definition, Hover info, and real-time diagnostics. - Hook Management: Explicit support for defining and tracking hooks (hijacks) in the ROM.
Z3DK is open-source software.
- Original Asar code is licensed under the GPL/LGPL/WTFPL (see
docs/legacy/). - New Z3DK components are licensed under the MIT License.
- Asar Team: Alcaro, RPGHacker, randomdude999, and contributors for the rock-solid base.
- Scawful: Z3DK fork maintainer.