romdevtools 0.56.1 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,285 @@ All notable changes to `romdevtools`. Dates are release dates.
4
4
  (Published as `romdev-mcp` through 0.11.0; renamed to `romdevtools` in 0.13.0 —
5
5
  the `romdev-mcp` bin is kept as an alias.)
6
6
 
7
+ ## 0.70.0 — 2026-06-26
8
+
9
+ ### Dreamcast is ship-ready: verified build → run → screenshot, with a renderable example
10
+
11
+ The Dreamcast platform is now verified end-to-end and release-ready:
12
+
13
+ - **build → run → screenshot proven + regression-tested.** A C homebrew compiles via
14
+ sh-elf-gcc, boots DIRECTLY on Flycast's reios HLE BIOS (no GD-ROM image, no firmware),
15
+ and renders on the real GPU through native-gles at 640×480 — confirmed by the new
16
+ `test/dreamcast-runside.test.js`.
17
+ - **dc.h is now auto-bundled.** The PowerVR2 framebuffer helper (640×480 RGB565 bring-up:
18
+ FB_R_CTRL/SIZE/SOF1 + SPG) ships in the sh-c toolchain lib and is injected automatically,
19
+ so `#include "dc.h"` just works — a DC program is a single `main.c` with no glue. A
20
+ caller-supplied `dc.h` still overrides the bundled one.
21
+ - **A renderable example** — `examples/dreamcast/hello` (DCHELLO): the canonical starter
22
+ that paints a test pattern through the GPU pipeline. Registered with createProject /
23
+ scaffold like the other platforms.
24
+
25
+ (The 640×480 screenshot path was already correct — the GL FBO is sized to Flycast's
26
+ upscale bound and the host crops the readback to the core's reported geometry; a raw
27
+ readback without crop args was the only thing that looked oversized.)
28
+
29
+ ## 0.69.0 — 2026-06-26
30
+
31
+ ### PS1 renders on the REAL GPU via native-gles (Beetle PSX HW + OpenBIOS)
32
+
33
+ The PS1 core is now **Beetle PSX HW** (mednafen) with its GLES3/WebGL2 hardware renderer,
34
+ rendering the PS1 GPU on the real GPU through native-gles — the same path as glide64-N64
35
+ and Flycast-DC. It ships with **OpenBIOS embedded** (PCSX-Redux, MIT-licensed, region-free),
36
+ so there's NO copyrighted Sony firmware to ship and no BIOS file to supply. (Verified:
37
+ mod.GL exposed, SET_HW_RENDER fires, hwActive=true, the OpenBIOS 3D-cube boot animation
38
+ renders in shaded perspective through native-gles.)
39
+
40
+ - New package romdev-core-beetle-psx-hw (replaces romdev-core-pcsx-rearmed as the PS1
41
+ core); build-beetle-psx-hw.sh reuses the N64 GL recipe (all-.o link, -lGL +
42
+ GL_ENABLE_GET_PROC_ADDRESS + GL in EXPORTED_RUNTIME_METHODS, the libretro-common EXTRAS).
43
+ - Registry: ps1 → beetle_psx_hw, hwRender:true. Manifest: renderingKind 3d, run+screenshot
44
+ +disasm+decompile+build true; cpuState/audioDebug now false (beetle lacks the romdev
45
+ MIPS/SPU debug exports the old pcsx_rearmed-software build had — a future core patch;
46
+ pcsx had no WebGL2 GPU path).
47
+
48
+ NOTE (both MIPS platforms): the GL cores render RDP/GPU display lists, NOT raw CPU-written
49
+ framebuffers — so the romdev software-3D example libs (which rasterize into a framebuffer)
50
+ render black on them; REAL games with GPU geometry render correctly. SDK-based examples
51
+ (libdragon rdpq / PSn00bSDK GTE) are the renderable path. Suite 1059/1059.
52
+
53
+ ## 0.68.0 — 2026-06-26
54
+
55
+ ### N64 renders on the REAL GPU via native-gles (glide64), not software
56
+
57
+ parallel_n64 now renders the RDP through **glide64 → GLES2/WebGL2 → native-gles** (the
58
+ real GPU, headless EGL pbuffer), replacing the angrylion software-RDP build. SET_HW_RENDER
59
+ fires, the host's LibretroGL drives native-gles, and frames read back via glReadPixels —
60
+ the same GPU path as Flycast/Dreamcast. (Verified: hwActive=true, the GL context engages
61
+ from boot.)
62
+
63
+ The build + host fixes that made it work (every one was a real wall):
64
+ - **Link all .o directly**, not via a .bc/.a archive — the archive route drops the
65
+ GLSM/context_reset/glide64 objects (no externally-referenced symbol), so the core never
66
+ calls SET_HW_RENDER. (build-parallel-n64.sh)
67
+ - **`-lGL` + `GL_ENABLE_GET_PROC_ADDRESS=1` + `"GL"` in EXPORTED_RUNTIME_METHODS** — these
68
+ make Emscripten emit `Module["GL"]=GL`, so the returned module actually exposes the GL
69
+ context object the host needs. Without them, `mod.GL` is undefined and HW render never
70
+ initializes.
71
+ - **coreLoader: don't set `noInitialRun`/`wasmBinary` for GL (canvas) cores** — both
72
+ suppress the Emscripten GL runtime init; use `locateFile` so the .wasm loads the normal way.
73
+ - **Pre-seed PLATFORM_CORE_OPTIONS before `_retro_init`** (loadCore now infers the platform
74
+ from the core filename): the core picks its renderer (glide64 vs angrylion) from
75
+ `parallel-n64-gfxplugin` during retro_init, so the override must be set before then.
76
+ - Registry: n64 is now `hwRender:true` (glide64 GL).
77
+
78
+ ## 0.67.0 — 2026-06-26
79
+
80
+ ### Dreamcast examples + sh-c -O level fix
81
+
82
+ Four DC example programs (rom-games/dreamcast/): dchello (test card), bounce (animation),
83
+ starfield (shmup background), grid (puzzle/board) — all build via the WASM toolchain and
84
+ render distinct content through Flycast, exercising the dc.h helper (no-KOS PowerVR2
85
+ framebuffer + 2D primitives).
86
+
87
+ sh-c driver: a user-supplied `-O<level>` now wins over the default `-O2` (gcc honors the
88
+ LAST -O, so a default appended after the user's would clobber it — only add -O2 if absent).
89
+ This matters because the WASM cc1 hangs at -O2 on some sources (the interprocedural-
90
+ optimization phase; native sh-elf-gcc compiles them in <1s), and -O1 is the workaround.
91
+ Suite 1059/1059.
92
+
93
+ ## 0.66.0 — 2026-06-26
94
+
95
+ ### Dreamcast: build() works — full WASM toolchain + packaging
96
+
97
+ `build({platform:"dreamcast"})` now compiles SH-4 C to a bootable ELF entirely in WASM,
98
+ and the result boots + renders through Flycast — the complete zero-install pipeline
99
+ (build → run → screenshot), verified end-to-end via the public `buildForPlatform`.
100
+
101
+ - **sh-elf-gcc WASM toolchain** (cc1 + as + ld + objcopy + objdump): gcc 14.2.0 +
102
+ binutils 2.42 + newlib 4.4.0 for sh-elf (little-endian SH-4, m4-single-only). The cc1
103
+ build needed CC_FOR_BUILD forced native (emconfigure makes $(CC)=emcc, which would
104
+ build the gen tools as WASM) + the host-side libcpp/libiberty configured first.
105
+ - **sh-c build driver** + lib (dc-crt0.s zeroes .bss + calls main; dc.ld links at
106
+ 0x8c010000; newlib libc/libm/libgcc). The ELF IS the deliverable — reios boots it.
107
+ - **Packages:** romdev-core-flycast (the DC core) + romdev-toolchain-sh-gcc (the WASM
108
+ compiler), both added as romdevtools deps; the registry resolves the DC core from the
109
+ package. Manifest `dreamcast.build` is now true.
110
+
111
+ Dreamcast core parity reached: disasm + decompile + build + run + screenshot. Suite
112
+ 1059/1059.
113
+
114
+ ## 0.65.0 — 2026-06-26
115
+
116
+ ### Dreamcast: homebrew renders correct graphics + HW-frame crop-to-native
117
+
118
+ A minimal DC homebrew (no KallistiOS — a dependency-free `dc.h` helper that programs the
119
+ PowerVR2 FB_R_CTRL/FB_R_SIZE/FB_R_SOF1 + SPG for a 640x480 RGB565 framebuffer) builds with
120
+ the native sh-elf toolchain, boots via reios HLE, runs, and renders a test pattern that the
121
+ host captures **pixel-exact** (verified: dark-blue background + equal red/green/blue bars +
122
+ white frame, the program's exact colors). This closes the DC render-fidelity loop.
123
+
124
+ Host change (helps any HW-render core): the video_refresh callback now records the core's
125
+ reported active resolution, and the GL readback crops the FBO to it — so a 640x480 DC frame
126
+ no longer comes back as the full 853x853 GL viewport with a dead border. `readbackFrame`
127
+ takes optional (cropW, cropH); `_afterRun` passes the core's w/h. Suite 1059/1059.
128
+
129
+ ## 0.64.0 — 2026-06-26
130
+
131
+ ### Dreamcast: present-path verified — screenshot works
132
+
133
+ Flycast renders to the GL FBO and the host reads it back: a framebuffer-writing homebrew
134
+ program shows ~727k captured pixels through the host's normal frame path (hwFramePending →
135
+ readbackFrame). Manifest `dreamcast.screenshot` is now true. With the CPU executing
136
+ (0.63.0), the direct-framebuffer present path lights up.
137
+
138
+ Added `flycast_emulate_framebuffer: enabled` to the host's DC options — it scans the DC
139
+ framebuffer out on every VBlank (the 2D path, no PowerVR2 tile list), so simple homebrew
140
+ that writes RGB565 to VRAM presents reliably without authoring a full TA list. (Full
141
+ TA/3D fidelity + correct framebuffer addressing come with the KOS helper lib; the pipeline
142
+ itself — boot → run → render → host capture — is proven end-to-end.) Suite 1059/1059.
143
+
144
+ ## 0.63.0 — 2026-06-26
145
+
146
+ ### Dreamcast: HOMEBREW EXECUTES — run + memory introspection live
147
+
148
+ Custom Flycast core patches make the SH-4 actually execute guest code. A homebrew .elf
149
+ boots via reios HLE, the SH-4 runs it, and the guest's RAM writes are visible through the
150
+ host (verified: a 0xDC0DC0DC marker the test program writes appears in DC RAM). Manifest
151
+ `dreamcast.run` is now true.
152
+
153
+ Root cause (3 stacked bugs): (1) worker-thread aborts — fixed by single-thread +
154
+ `--wrap pthread_create` no-op (0.62.0); (2) HLE BIOS off — only the reios path loads a raw
155
+ .elf, and the option is latched at retro_init, so default `UseReios=true` in source for
156
+ emscripten; (3) THE BIG ONE — `ThreadedRendering` defaulted ON, which runs the CPU on a
157
+ `std::async` worker that our pthread no-op kills → the SH-4 never steps (PC stuck at the
158
+ reset vector, reios_boot never fires, RAM stays zero). Fixed by unconditionally
159
+ `config::ThreadedRendering.override(false)` for emscripten in update_variables.
160
+
161
+ `screenshot` stays false until the PowerVR2 present-path is verified with a TA-driving
162
+ program (the KOS helper lib — next phase). All patches reproducible in build-flycast.sh.
163
+ Suite 1059/1059.
164
+
165
+ ## 0.62.0 — 2026-06-26
166
+
167
+ ### Dreamcast run-side BREAKTHROUGH: Flycast boots + runs DC ELFs
168
+
169
+ The threading wall is solved. Flycast (the full DC emulator) now **boots a homebrew
170
+ .elf via reios HLE and runs frames** through the romdev host — `retro_init` /
171
+ `retro_load_game` / `retro_run` all succeed, av_info reports 640×480, and video_refresh
172
+ fires every frame. No abort, no `unwind`.
173
+
174
+ The fix (after trying PROXY_TO_PTHREAD + ASYNCIFY, which deadlocks in Node on the
175
+ GL↔proxy-thread dependency): build single-threaded and **`--wrap` pthread_create to a
176
+ no-op** (`scripts/patches/romdev-snippets/flycast-pthread-noop.c`). pthread_create
177
+ returns success but spawns nothing; join/detach are no-ops. So flycast's worker threads
178
+ (achievements/http/network/audio-async) never run, `std::thread`'s ctor doesn't abort
179
+ (no "thread constructor failed"), and — crucially — the main thread never blocks on a
180
+ worker, so there's no emscripten `unwind`. Emulation runs synchronously on retro_run
181
+ (ThreadedRendering defaulted false). This is far cleaner than stubbing thread sites
182
+ one-by-one (there were 4+ wrapper classes plus raw std::thread/std::async).
183
+
184
+ Also: the GL `get_proc_address` bridge fix (0.59.0) is what got context_reset past the
185
+ signature mismatch; the 512MB-mmap fallback (posix_vmem) got init past the trap.
186
+
187
+ NEXT: a DC program that actually renders via PowerVR2 (the KOS helper lib) to verify the
188
+ present path end-to-end, then flip run/screenshot true. Captured in build-flycast.sh.
189
+ Suite green.
190
+
191
+ ## 0.60.0 — 2026-06-26
192
+
193
+ ### Dreamcast: SuperH4 SLEIGH metadata shipped + Flycast threading progress
194
+
195
+ - **SuperH4 SLEIGH metadata committed** (`.ldefs`/`.pspec`/`.cspec`) — these ship
196
+ alongside the gitignored `.sla` (like every other CPU); without them the decompiler
197
+ couldn't load the SuperH4 spec at runtime. (0.57.0 shipped the wiring but missed the
198
+ metadata files. Now complete.)
199
+ - Flycast run-side threading: the single-threaded WASM build needs worker-thread
200
+ creation stubbed (emscripten can't spawn them without -pthread; with -pthread the
201
+ main thread can't block → unwind). Captured the patches in `build-flycast.sh`
202
+ (`cThread::Start` / `VPeriodicThread::start` no-op, `ThreadedRendering` defaults
203
+ false on emscripten) + the `flycast_threaded_rendering: disabled` host option.
204
+
205
+ KNOWN-OPEN: Flycast's load still aborts on a not-yet-located worker thread (no-pthread)
206
+ or unwinds (pthread). The thread/main-loop model integration is the remaining run-side
207
+ fight — see N64_PS1_LESSONS_FOR_DREAMCAST.md. DC analysis (disasm+decompile) is fully
208
+ shipped + tested. Suite 1059/1059.
209
+
210
+ ## 0.59.0 — 2026-06-26
211
+
212
+ ### Dreamcast run-side: Flycast loads ELFs + GL bridge fix (general)
213
+
214
+ Flycast WASM now boots a homebrew `.elf` (reios HLE — no BIOS/disc) and requests GL:
215
+ - threads: `-pthread -sPTHREAD_POOL_SIZE=8` (Flycast spawns std::threads; without
216
+ pthreads the ctor aborts). The pthread build bakes the module filename into the
217
+ worker bootstrap, so it MUST link with the final `flycast_libretro.js` name.
218
+ - **GL proc-address (general bridge fix in LibretroGL.js):** emscripten-WebGL cores
219
+ (Flycast) resolve GL via libretro `get_proc_address`. The bridge previously returned
220
+ a no-op 0-arg stub → the core called multi-arg GL fns through it → "null function or
221
+ function signature mismatch" in context_reset. Now the bridge returns the real
222
+ `emscripten_GetProcAddress` table pointer (built with `-sGL_ENABLE_GET_PROC_ADDRESS=1
223
+ -lGL`); the native-gles stub path stays as the glide64-N64 fallback. This fix helps
224
+ ANY future emscripten-WebGL core.
225
+ - `ROMDEV_CORE_LOG=1` env gates core stdout/stderr (was always suppressed) — found the
226
+ thread + mmap aborts with it.
227
+
228
+ KNOWN-OPEN: `retro_run` throws emscripten's `unwind` (Flycast yields via
229
+ emscripten_set_main_loop / Asyncify, incompatible with the host's synchronous
230
+ frame-step). That main-loop integration is the next run-side step. Suite 1059/1059.
231
+
232
+ ## 0.58.0 — 2026-06-26
233
+
234
+ ### Dreamcast run-side: Flycast WASM core builds + inits; sh-elf toolchain built
235
+
236
+ The two heaviest Dreamcast pieces, both landed (build infrastructure; host present-path
237
+ integration is the next step):
238
+
239
+ - **sh-elf-gcc toolchain** (SH-4): binutils 2.42 + gcc 14.2.0 + newlib 4.4.0, built
240
+ for `sh-elf` (m4-single-only, little-endian — the DC ABI). Compiles SH-4 C end to
241
+ end. `scripts/build-sh-toolchain.sh` (adapted from the mips one; SH-4 is single-
242
+ endian so no be/el split).
243
+ - **Flycast → WASM**: the full Dreamcast emulator (785 C++ files, GLES3/WebGL2)
244
+ compiled to a 5.9MB WASM module that instantiates with all libretro entry points
245
+ and `retro_init` succeeds. Flycast has no upstream emscripten build, so
246
+ `scripts/build-flycast.sh` applies the romdev WASM patches discovered here:
247
+ - a `CPU_GENERIC` host (no JIT) → the SH-4/ARM/DSP interpreters (`TARGET_NO_REC`);
248
+ CMake `DetectArchitecture` + `build.h` + the FPU-control / JIT-segfault-recovery
249
+ arch branches all get a generic no-op path.
250
+ - asio single-threaded (`ASIO_DISABLE_THREADS`) so it doesn't need POSIX
251
+ signal_blocker/tss_ptr (emscripten without -pthread isn't detected as POSIX).
252
+ - Vulkan OFF (WASM uses WebGL); networking/UPnP stubbed.
253
+ - **the key boot fix:** emscripten can't `mmap` a 512MB contiguous reservation (it
254
+ traps), so `posix_vmem::init` declines fast-vmem on emscripten → Flycast's
255
+ malloc-based memory fallback engages and `retro_init` succeeds.
256
+ - `dreamcast` registry entry (Flycast, hwRender — PowerVR2 is GPU-first, no software
257
+ framebuffer; HLE reios BIOS, no firmware to ship).
258
+
259
+ Suite 1059/1059. Next: the GL present-path (load_game + run + frame through the host's
260
+ WebGL2 bridge), then the helper lib + 5 example games + packaging.
261
+
262
+ ## 0.57.0 — 2026-06-26
263
+
264
+ ### Dreamcast (SH-4) analysis slice — disasm + decompile
265
+
266
+ First slice of Dreamcast support: the SH-4 (SuperH) reverse-engineering path, on the
267
+ same pattern as the PS1/N64 analysis slice.
268
+
269
+ - rizin's `sh` plugin (already in rizin.wasm) wired for disasm/cfg/xrefs/functions
270
+ (arch=sh, little-endian).
271
+ - Ghidra's **SuperH4** SLEIGH spec compiled (`SuperH4_le.sla`) + shipped in
272
+ romdev-analysis-decompiler → `decompile` produces real C (langid
273
+ `SuperH4:LE:32:default`). Verified: SH-4 bytes → disasm + decompiled C.
274
+ - analyze.js handles DC binaries: strips an ELF to its first PT_LOAD segment (vaddr =
275
+ loadBase 0x8c010000) or treats a raw image as flat; left-pads so flat offset ==
276
+ the VA's low bits + rebases the high bits (same trick PS1 needed for absolute-
277
+ addressed calls — SH-4's PC-relative + absolute addressing needs it too).
278
+ - `dreamcast` added to the capability manifest as the new `sh` tier (analysis-first;
279
+ run/build/etc. land in later phases). The 3D (PowerVR2) renderer's tile/sprite
280
+ inspectors are N/A by hardware with a stated reason. Excluded from the all-14
281
+ contract via the generalized NEXTGEN_TIER (mips + sh).
282
+
283
+ Suite 1059/1059. Run-side (Flycast WASM), build (sh-elf-gcc), the helper lib, and the
284
+ 5 example games are the next phases.
285
+
7
286
  ## 0.56.1 — 2026-06-26
8
287
 
9
288
  ### ascii screenshot: legible default grid + lighter default color (0.44.0 feedback #1)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # romdev
2
2
 
3
- The entry point for **romdev** — vibe-code real retro games. Build, run, inspect, and reverse-engineer actual homebrew ROMs (NES, SNES, Game Boy, Genesis, Atari, C64, GBA, and more) with one command — drive it yourself or let a coding assistant do it.
3
+ The entry point for **romdev** — vibe-code real retro games. Build, run, inspect, and reverse-engineer actual homebrew ROMs (NES, SNES, Game Boy, Genesis, Atari, C64, GBA, PC Engine, MSX — and the 3D consoles N64, PlayStation, and Dreamcast) with one command — drive it yourself or let a coding assistant do it.
4
4
 
5
5
  ```bash
6
6
  npx romdevtools
@@ -9,7 +9,7 @@ npx romdevtools
9
9
  **What you get:**
10
10
 
11
11
  - **Build** — bundled per-platform toolchains (cc65, SDCC, RGBDS, asar, vasm, SGDK, PVSnesLib, libtonc, …) as WASM. Write source, compile, get a real ROM.
12
- - **Run + see + drive** — load the ROM into an emulated console (libretro cores as WASM), step frames, screenshot, script controller input.
12
+ - **Run + see + drive** — load the ROM into an emulated console (libretro cores as WASM), step frames, screenshot, script controller input. The 2D consoles render in software; the 3D consoles (N64 via glide64, PlayStation via Beetle PSX HW, Dreamcast via Flycast) render on the **real GPU** through [`native-gles`](https://github.com/monteslu/native-gles) — headless OpenGL/EGL, no browser. PlayStation ships [OpenBIOS](https://github.com/grumpycoders/pcsx-redux) (MIT) embedded, so there's no proprietary firmware to supply.
13
13
  - **Inspect + romhack** — read CPU/video/save RAM, watch memory, write-breakpoints, the Cheat-Engine value-search loop, a bundled cheat database, mapper-aware disassembly, and a byte-exact rebuildable-project disassembler.
14
14
  - **Reverse-engineering analysis engine (all 14 platforms)** — control-flow graphs, deep cross-references, auto-detected functions (ranked real-code-first), a one-shot structural map, and a Ghidra **decompiler** (C-like pseudocode, with hardware registers named and 6502 SLEIGH clutter folded to readable C): `disasm({target:'cfg'|'xrefs'|'functions'|'decompile'})` and `symbols({op:'analyze'})`. And the piece no static tool has: **live computed-jumptable recovery** — `breakpoint({on:'jumptable'})` runs the emulator to resolve the `JMP (table,X)` / RTS-trick dispatchers (state machines, script/battle VMs) that static analysis collapses to "could not recover." Understand *how* a routine works before you touch it — no $3,000 IDA license, no install.
15
15
  - **Convert assets** — PNG → platform tiles/tilemaps, quantize-to-palette, audio importers (BRR for SNES, XGM2 PCM for Genesis).
@@ -20,7 +20,7 @@ Point any coding agent at it three ways:
20
20
  - **Agent Skill** — `GET /skills/romdev/SKILL.md` (the [Agent Skills](https://agentskills.io) standard; save it to your skills dir as `skills/romdev/SKILL.md`; ~100 tokens until invoked).
21
21
  - **MCP** — it's also a [Model Context Protocol](https://modelcontextprotocol.io/) server at `/mcp` for clients that want it.
22
22
 
23
- This package contains all the JavaScript — the tool surface, the WASM emulator host, the per-platform example games, runtime/library source, and debug helpers — but **no emulator or compiler WASM itself.** Those ship in the `romdev-*` binary packages it depends on, loaded on demand the first time you build or run a given platform.
23
+ This package contains all the JavaScript — the tool surface, the WASM emulator host, the per-platform example games, runtime/library source, and debug helpers — but **no emulator or compiler WASM itself.** Those ship in the `romdev-*` binary packages it depends on; each platform's core/toolchain WASM is resolved (`import.meta.resolve`) and instantiated only the first time you build or run that platform, so memory stays proportional to what you actually use.
24
24
 
25
25
  > For the full project — what romdev is, the supported-platform matrix, how the pieces fit together, and how to develop on it — see the [repository README](https://github.com/monteslu/romdev#readme).
26
26
 
@@ -34,11 +34,13 @@ This package contains all the JavaScript — the tool surface, the WASM emulator
34
34
 
35
35
  ## Dependencies
36
36
 
37
- `romdevtools` hard-depends (exact-pinned) on the binary/data packages it needs, so a single install gets a matched, tested set:
37
+ `romdevtools` depends on the binary/data packages it needs (exact-pinned), so a single install gets a matched, tested set:
38
38
 
39
- - Cores: `romdev-core-{fceumm,gambatte,gpgx,vice,handy,prosystem,geargrafx,bluemsx}`
40
- - Platforms: `romdev-platform-{snes,gba,atari2600}`
41
- - Toolchains: `romdev-toolchain-{cc65,sdcc,m68k-gcc,vasm,rgbds}`
39
+ - 2D cores: `romdev-core-{fceumm,gambatte,gpgx,vice,handy,prosystem,geargrafx,bluemsx}`
40
+ - 3D / GPU cores (rendered through `native-gles`): `romdev-core-{parallel-n64,beetle-psx-hw,flycast}`
41
+ - Platforms (core + dedicated toolchain bundled): `romdev-platform-{snes,gba,atari2600}`
42
+ - Toolchains: `romdev-toolchain-{cc65,sdcc,m68k-gcc,vasm,rgbds,mips-gcc,sh-gcc}` (mips-gcc = N64/PS1 C; sh-gcc = Dreamcast C)
43
+ - GPU deps (OPTIONAL — only the 3D cores need them; the 2D cores never touch GL): `native-gles` + `webgl-node`. A headless user without a GPU stack can still run all the 2D platforms.
42
44
  - Analysis: `romdev-analysis` (Rizin → WASM: control-flow graphs, cross-references, function detection) and `romdev-analysis-decompiler` (Ghidra's C++ decompiler → WASM + SLEIGH processor specs for all 14 CPUs). Power `disasm({target:'cfg'|'xrefs'|'functions'|'decompile'})` and `symbols({op:'analyze'})`. Lazy-loaded on first use.
43
45
  - Data: `romdev_game_codes` — the bundled game-code / cheat database (a free labeled RAM/code map for thousands of known ROMs), split out so it can grow independently. Lazy-loaded one platform at a time.
44
46
 
@@ -0,0 +1,24 @@
1
+ /* dchello — a minimal Dreamcast homebrew that draws a recognizable test pattern,
2
+ * proving the romdev DC pipeline renders program-controlled graphics end-to-end. */
3
+ #include "dc.h"
4
+
5
+ void main(void) {
6
+ dc_video_init();
7
+
8
+ /* Clear to a dark blue background. */
9
+ dc_clear(dc_rgb(16, 24, 64));
10
+
11
+ /* Three solid bars (red, green, blue) — distinct, easy to verify in a screenshot. */
12
+ dc_rect(64, 80, 160, 320, dc_rgb(220, 40, 40)); /* red */
13
+ dc_rect(240, 80, 160, 320, dc_rgb(40, 200, 60)); /* green */
14
+ dc_rect(416, 80, 160, 320, dc_rgb(50, 90, 230)); /* blue */
15
+
16
+ /* A white frame around the screen. */
17
+ dc_rect(0, 0, DC_W, 4, dc_rgb(255, 255, 255));
18
+ dc_rect(0, DC_H - 4, DC_W, 4, dc_rgb(255, 255, 255));
19
+ dc_rect(0, 0, 4, DC_H, dc_rgb(255, 255, 255));
20
+ dc_rect(DC_W - 4, 0, 4, DC_H, dc_rgb(255, 255, 255));
21
+
22
+ /* Hold the frame. */
23
+ for (;;) { }
24
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "romdevtools",
3
- "version": "0.56.1",
4
- "description": "Tool server giving coding agents full control of homebrew ROM development AND reverse-engineering/romhacking across 16 retro platforms (NES, SNES, GB, Genesis, Atari, C64, PC Engine, MSX, PlayStation, N64, ...) via WASM toolchains + emulator cores. Use over plain HTTP, as an Agent Skill, or as an MCP server.",
3
+ "version": "0.70.0",
4
+ "description": "Tool server giving coding agents full control of homebrew ROM development AND reverse-engineering/romhacking across 17 retro platforms (NES, SNES, GB, Genesis, Atari, C64, PC Engine, MSX, PlayStation, N64, Dreamcast, ...) via WASM toolchains + emulator cores. Use over plain HTTP, as an Agent Skill, or as an MCP server.",
5
5
  "type": "module",
6
6
  "main": "src/mcp/server.js",
7
7
  "bin": {
@@ -58,8 +58,9 @@
58
58
  "romdev-core-geargrafx": "0.7.0",
59
59
  "romdev-core-gpgx": "0.12.0",
60
60
  "romdev-core-handy": "0.7.0",
61
+ "romdev-core-flycast": "0.1.0",
61
62
  "romdev-core-parallel-n64": "0.1.0",
62
- "romdev-core-pcsx-rearmed": "0.1.0",
63
+ "romdev-core-beetle-psx-hw": "0.1.0",
63
64
  "romdev-core-prosystem": "0.8.0",
64
65
  "romdev-core-vice": "0.9.0",
65
66
  "romdev-famitone": "0.1.0",
@@ -72,6 +73,7 @@
72
73
  "romdev-toolchain-mips-gcc": "0.1.0",
73
74
  "romdev-toolchain-rgbds": "0.1.0",
74
75
  "romdev-toolchain-sdcc": "0.2.0",
76
+ "romdev-toolchain-sh-gcc": "0.1.0",
75
77
  "romdev-toolchain-vasm": "0.1.0",
76
78
  "romdev-xgm2": "0.1.0",
77
79
  "romdev_game_codes": "0.1.0",
@@ -135,13 +135,14 @@ export function sniffPlatform(p) {
135
135
  if (/\.pce$/i.test(p)) return "pce";
136
136
  if (/\.(z64|n64|v64)$/i.test(p)) return "n64";
137
137
  if (/\.(psexe|psx)$/i.test(p)) return "ps1"; // .exe/.bin ambiguous — pass platform explicitly
138
+ if (/\.(cdi|gdi)$/i.test(p)) return "dreamcast"; // DC disc images; .elf is cross-platform — pass platform explicitly
138
139
  if (/\.(gen|md|bin)$/i.test(p)) return "genesis";
139
140
  return null;
140
141
  }
141
142
 
142
143
  /** rizin asm.bits per arch (analysis defaults; rizin's loader usually sets
143
144
  * these for recognized formats, but raw blobs need a hint). */
144
- const BITS = { arm: 32, m68k: 32, snes: 16, mips: 32 };
145
+ const BITS = { arm: 32, m68k: 32, snes: 16, mips: 32, sh: 32 };
145
146
 
146
147
  /**
147
148
  * The rizin analysis-SEED command for a context. For the 8/16-bit platforms
@@ -154,7 +155,10 @@ const BITS = { arm: 32, m68k: 32, snes: 16, mips: 32 };
154
155
  * @returns {string} the seed command (no trailing semicolon)
155
156
  */
156
157
  function analysisSeed({ arch, codeStart }) {
157
- if (arch === "mips") {
158
+ // MIPS (N64/PS1) and SH-4 (Dreamcast) are raw code images with no rizin-recognized
159
+ // entry, so `aaa` finds nothing — seed a function at the code start + recursively
160
+ // analyze its call graph (`af` + `aac`). The 8/16-bit bin formats self-seed via aaa.
161
+ if (arch === "mips" || arch === "sh") {
158
162
  const at = "0x" + (codeStart || 0).toString(16);
159
163
  return `af @ ${at}; aac @ ${at}`;
160
164
  }
@@ -167,8 +171,12 @@ function analysisSeed({ arch, codeStart }) {
167
171
  * `rebase` so callers get real VAs that round-trip through the decompile
168
172
  * VA→fileOffset math. N64 (.z64) keeps its absolute VAs baked into the code and is
169
173
  * analyzed flat from codeStart, so no rebase. */
170
- function mipsAnalysisBase({ arch, platform, loadBase, codeStart }) {
171
- const rebase = (arch === "mips" && platform === "ps1" && loadBase) ? (loadBase & 0xfff00000) >>> 0 : 0;
174
+ function mipsAnalysisBase({ platform, loadBase, codeStart }) {
175
+ // PS1 (left-padded to the VA's low 20 bits) and Dreamcast (same, loadBase
176
+ // 0x8c010000) need the VA's HIGH bits added back so addresses round-trip. N64 runs
177
+ // flat with VAs already baked in (no rebase).
178
+ const padded = (platform === "ps1" || platform === "dreamcast") && loadBase;
179
+ const rebase = padded ? (loadBase & 0xfff00000) >>> 0 : 0;
172
180
  return { baddr: undefined, seedAt: codeStart, rebase };
173
181
  }
174
182
 
@@ -276,6 +284,39 @@ async function loadContext(romPath, platformOverride) {
276
284
  romBytes = text;
277
285
  }
278
286
  }
287
+ // Dreamcast SH-4: KOS produces an ELF (load base 0x8c010000) or a stripped flat
288
+ // binary. For an ELF, strip to the first PT_LOAD segment's bytes + take its vaddr
289
+ // as loadBase. Like PS1, SH-4 uses PC-relative + absolute addressing, so left-pad
290
+ // so flat offset == the VA's low bits and add the high bits back as rebase.
291
+ if (platform === "dreamcast") {
292
+ let text = romBytes, loadVa = 0x8c010000;
293
+ if (romBytes.length >= 0x34 && romBytes[0] === 0x7f && romBytes[1] === 0x45 &&
294
+ romBytes[2] === 0x4c && romBytes[3] === 0x46) { // "\x7fELF"
295
+ // ELF32 LE: e_phoff @0x1c, e_phentsize @0x2a, e_phnum @0x2c. Find first PT_LOAD.
296
+ const u32 = (o) => (romBytes[o] | (romBytes[o + 1] << 8) | (romBytes[o + 2] << 16) | (romBytes[o + 3] << 24)) >>> 0;
297
+ const u16 = (o) => romBytes[o] | (romBytes[o + 1] << 8);
298
+ const phoff = u32(0x1c), phentsize = u16(0x2a), phnum = u16(0x2c);
299
+ for (let i = 0; i < phnum; i++) {
300
+ const ph = phoff + i * phentsize;
301
+ if (u32(ph) === 1) { // PT_LOAD
302
+ const p_offset = u32(ph + 4), p_vaddr = u32(ph + 8), p_filesz = u32(ph + 16);
303
+ loadVa = p_vaddr >>> 0;
304
+ text = romBytes.subarray(p_offset, p_offset + p_filesz);
305
+ break;
306
+ }
307
+ }
308
+ }
309
+ loadBase = loadVa >>> 0;
310
+ const lowPad = loadBase & 0x000fffff;
311
+ if (lowPad > 0 && lowPad <= 0x200000) {
312
+ const padded = new Uint8Array(lowPad + text.length);
313
+ padded.set(text, lowPad);
314
+ romBytes = padded;
315
+ codeStart = lowPad;
316
+ } else {
317
+ romBytes = text;
318
+ }
319
+ }
279
320
 
280
321
  // A6: container/format sniff. Some dumps are interleaved/headered such that a
281
322
  // FLAT read scrambles every byte → fake "bad instruction" noise everywhere.
@@ -623,12 +664,26 @@ export async function analyzeDecompile(romPath, address, platformOverride) {
623
664
  // offset and decompile via the MIPS SLEIGH spec (MIPS:BE:32 for N64, MIPS:LE:32
624
665
  // for PS1). N64: normalize byte order, fileOff = vaddr - entryVaddr + 0x1000 (post
625
666
  // IPL3). PS1: strip PS-EXE, fileOff = vaddr - loadAddr.
626
- if (platform === "n64" || platform === "ps1") {
667
+ if (platform === "n64" || platform === "ps1" || platform === "dreamcast") {
627
668
  let fileOff;
628
669
  if (platform === "n64") {
629
670
  romBytes = normalizeN64ByteOrder(romBytes).bytes;
630
671
  const entry = ((romBytes[0x08] << 24) | (romBytes[0x09] << 16) | (romBytes[0x0a] << 8) | romBytes[0x0b]) >>> 0;
631
672
  fileOff = ((address >>> 0) - entry + 0x1000) >>> 0;
673
+ } else if (platform === "dreamcast") {
674
+ // SH-4: strip the ELF to its first PT_LOAD segment (vaddr = loadBase), or treat
675
+ // a raw image as flat at 0x8c010000. fileOff = address - segment vaddr.
676
+ let loadVa = 0x8c010000;
677
+ if (romBytes.length >= 0x34 && romBytes[0] === 0x7f && romBytes[1] === 0x45 && romBytes[2] === 0x4c && romBytes[3] === 0x46) {
678
+ const u32 = (o) => (romBytes[o] | (romBytes[o + 1] << 8) | (romBytes[o + 2] << 16) | (romBytes[o + 3] << 24)) >>> 0;
679
+ const u16 = (o) => romBytes[o] | (romBytes[o + 1] << 8);
680
+ const phoff = u32(0x1c), phentsize = u16(0x2a), phnum = u16(0x2c);
681
+ for (let i = 0; i < phnum; i++) {
682
+ const ph = phoff + i * phentsize;
683
+ if (u32(ph) === 1) { loadVa = u32(ph + 8) >>> 0; romBytes = romBytes.subarray(u32(ph + 4), u32(ph + 4) + u32(ph + 16)); break; }
684
+ }
685
+ }
686
+ fileOff = ((address >>> 0) - loadVa) >>> 0;
632
687
  } else {
633
688
  let loadAddr = 0;
634
689
  if (romBytes.length >= 0x800 && romBytes[0] === 0x50 && romBytes[1] === 0x53 && romBytes[2] === 0x2d && romBytes[3] === 0x58) {
@@ -51,6 +51,9 @@ export const SLEIGH_LANGID = {
51
51
  // 32-bit MIPS III code). Ghidra ships both MIPS variants in its stock SLEIGH.
52
52
  ps1: "MIPS:LE:32:default",
53
53
  n64: "MIPS:BE:32:default",
54
+ // Dreamcast = SH-4 (SuperH), little-endian. Ghidra ships SuperH4 in its stock
55
+ // SLEIGH; we compile SuperH4_le.sla (see scripts/build-decompiler.sh).
56
+ dreamcast: "SuperH4:LE:32:default",
54
57
  };
55
58
 
56
59
  /**
@@ -59,14 +59,16 @@ export const RIZIN_ARCH = {
59
59
  // below — same arch, different byte order.
60
60
  ps1: "mips",
61
61
  n64: "mips",
62
+ dreamcast: "sh", // SH-4 (SuperH) — rizin's `sh` plugin covers it
62
63
  };
63
64
 
64
65
  /** Byte order per platform, for shared-arch families that ship both (MIPS). Only
65
66
  * platforms NOT matching their arch default need an entry; absent → use the
66
- * loader/arch default. PS1 is little, N64 is big. */
67
+ * loader/arch default. PS1 is little, N64 is big. Dreamcast SH-4 is little. */
67
68
  export const RIZIN_ENDIAN = {
68
69
  ps1: "little",
69
70
  n64: "big",
71
+ dreamcast: "little",
70
72
  };
71
73
 
72
74
  /**
@@ -219,15 +219,19 @@ export const CAPABILITIES = {
219
219
  cpus: { main: "r3000", secondary: ["gte"] },
220
220
  audioChips: ["spu"],
221
221
  memoryRegions: [...GENERIC_REGIONS],
222
- renderingKind: "framebuffer", introspection: "shallow",
222
+ renderingKind: "3d", introspection: "shallow",
223
223
  ops: {
224
- // pcsx_rearmed: software render + HLE BIOS (no firmware, no GL). run/screenshot
225
- // + cpuState (R3000 regsnap) + cheats live; disasm + decompile work (MIPS
226
- // Capstone + the MIPS:LE:32 SLEIGH spec). build needs a PS1 toolchain
227
- // (PSn00bSDK, not yet). The framebuffer renderer has no tile/sprite inspectors.
224
+ // beetle_psx_hw: the GPU renders on the REAL GPU via the GLES3/WebGL2 hardware
225
+ // renderer through native-gles (like glide64-N64 + Flycast-DC), with OpenBIOS
226
+ // EMBEDDED (PCSX-Redux, MIT, region-free) no Sony firmware to ship, no BIOS file.
227
+ // run/screenshot + cheats live; disasm + decompile work (MIPS Capstone + the
228
+ // MIPS:LE:32 SLEIGH spec). cpuState/audioDebug are OFF: those need beetle-side
229
+ // romdev_mips_regs_get/romdev_spu_get exports (a future core patch — the old
230
+ // pcsx_rearmed-software build had them, but it has no WebGL2 GPU path). build needs
231
+ // a PS1 toolchain (PSn00bSDK, not yet).
228
232
  build: true, run: true, screenshot: true,
229
233
  inspectSprites: false, inspectPalette: false, inspectBackground: false,
230
- renderingContext: false, cpuState: true, audioDebug: true,
234
+ renderingContext: false, cpuState: false, audioDebug: false,
231
235
  cart: false, disasm: true, decompile: true,
232
236
  },
233
237
  },
@@ -248,6 +252,26 @@ export const CAPABILITIES = {
248
252
  cart: false, disasm: true, decompile: true,
249
253
  },
250
254
  },
255
+
256
+ dreamcast: {
257
+ cpuFamily: "sh", decompileQuality: "good", tier: "sh",
258
+ cpus: { main: "sh4", secondary: ["arm7"] }, // SH-4 main + ARM7 AICA sound CPU
259
+ audioChips: ["aica"],
260
+ memoryRegions: [...GENERIC_REGIONS],
261
+ renderingKind: "3d", introspection: "shallow",
262
+ ops: {
263
+ // Flycast WASM boots + RUNS homebrew .elf (reios HLE): the SH-4 executes guest
264
+ // code (run + memory introspection), and the PowerVR2 present-path works — flycast
265
+ // renders to the GL FBO and the host reads it back (verified: a framebuffer-writing
266
+ // program shows ~727k captured pixels). `build` lands with the sh-elf-gcc WASM
267
+ // toolchain. The 3D renderer has no tile/sprite inspectors (N/A by hw).
268
+ // disasm/decompile = SH-4 analysis slice (rizin `sh` + Ghidra SuperH4 SLEIGH).
269
+ build: true, run: true, screenshot: true,
270
+ inspectSprites: false, inspectPalette: false, inspectBackground: false,
271
+ renderingContext: false, cpuState: false, audioDebug: false,
272
+ cart: false, disasm: true, decompile: true,
273
+ },
274
+ },
251
275
  };
252
276
 
253
277
  /** The 32-bit MIPS tier (PS1/N64) — marked `tier:"mips"`. A PARTIAL tier: they
@@ -259,14 +283,22 @@ export const MIPS_TIER_PLATFORMS = Object.entries(CAPABILITIES)
259
283
  .filter(([, c]) => c.tier === "mips")
260
284
  .map(([p]) => p);
261
285
 
286
+ /** The next-gen tiers (32-bit CPU families added after the canonical 14): MIPS
287
+ * (PS1/N64) + SH (Dreamcast) + future. Any platform carrying a CPU-family `tier`
288
+ * is held to its OWN conformance, not the "all 14" cross-checks; a new platform
289
+ * starts here (analysis-first) and graduates as run/build/etc. land. */
290
+ export const NEXTGEN_TIER_PLATFORMS = Object.entries(CAPABILITIES)
291
+ .filter(([, c]) => c.tier === "mips" || c.tier === "sh")
292
+ .map(([p]) => p);
293
+
262
294
  /** Back-compat: the analysis-only set is now empty (PS1/N64 gained run/screenshot
263
295
  * in the run-side wiring). Kept so the name still resolves for older imports. */
264
296
  export const ANALYSIS_ONLY_PLATFORMS = [];
265
297
 
266
298
  /** The canonical tier-1 platforms (the 14): full op surface, universal build/run/
267
- * screenshot. Excludes the partial MIPS tier above. */
299
+ * screenshot. Excludes the partial next-gen tiers above. */
268
300
  export const CONTRACT_PLATFORMS = Object.keys(CAPABILITIES)
269
- .filter((p) => !MIPS_TIER_PLATFORMS.includes(p));
301
+ .filter((p) => !NEXTGEN_TIER_PLATFORMS.includes(p));
270
302
 
271
303
  /** Does `platform` support `op`? Unknown platform/op → false. */
272
304
  export function supports(platform, op) {
@@ -57,14 +57,19 @@ export const CORES = {
57
57
  // webgl-node bridge only when one of these boots (hwRender:true). The other 14 are
58
58
  // software-rendered and never touch GL, so a headless user without the GPU module
59
59
  // is unaffected.
60
- // parallel_n64 built headless-angrylion (software RDP + VI scanout, no GL) so raw
61
- // CPU-rendered homebrew framebuffers display the clean no-GL-dependency N64 path,
62
- // like pcsx_rearmed for PS1. (The GL/glide64 build only presents RDP display-lists.)
63
- n64: { platform: "n64", coreName: "parallel_n64", pkg: "romdev-core-parallel-n64", displayName: "Nintendo 64 (ParaLLEl N64, software)", hwRender: false },
64
- // pcsx_rearmed = SOFTWARE renderer + built-in HLE BIOS (no firmware to ship, no
65
- // GL dependency) the clean no-dependency PS1 path, like the other 14. The GL
66
- // beetle_psx_hw (+ real BIOS) stays available as a higher-fidelity alternative.
67
- ps1: { platform: "ps1", coreName: "pcsx_rearmed", pkg: "romdev-core-pcsx-rearmed", displayName: "Sony PlayStation (PCSX-ReARMed, HLE)", aka: "psx,playstation" },
60
+ // parallel_n64 renders the RDP on the REAL GPU through glide64 (GL HLE) native-gles
61
+ // (the host's WebGL2 bridge), same path as Flycast. The host forces the glide64 plugin
62
+ // via a core option. NOT software RDP (angrylion) that was the old headless build.
63
+ n64: { platform: "n64", coreName: "parallel_n64", pkg: "romdev-core-parallel-n64", displayName: "Nintendo 64 (ParaLLEl N64, glide64 GL)", hwRender: true },
64
+ // beetle_psx_hw = mednafen PSX with the GLES3/WebGL2 HARDWARE renderer rendered on
65
+ // the real GPU through native-gles (like glide64-N64 + Flycast-DC). Ships with OpenBIOS
66
+ // EMBEDDED (PCSX-Redux, MIT-licensed, region-free) so there's no copyrighted Sony
67
+ // firmware to ship and no BIOS file to supply the GPU PS1 path with an open BIOS.
68
+ ps1: { platform: "ps1", coreName: "beetle_psx_hw", pkg: "romdev-core-beetle-psx-hw", displayName: "Sony PlayStation (Beetle PSX HW, OpenBIOS)", aka: "psx,playstation", hwRender: true },
69
+ // Flycast = full Dreamcast emulator, GLES3/WebGL2 HW-render (PowerVR2 is GPU-first,
70
+ // no software framebuffer path) → driven through the native-gles/webgl-node bridge
71
+ // like the GL N64 build. HLE BIOS (reios) on by default — no firmware to ship.
72
+ dreamcast: { platform: "dreamcast", coreName: "flycast", pkg: "romdev-core-flycast", displayName: "Sega Dreamcast (Flycast)", aka: "dc", hwRender: true },
68
73
  };
69
74
 
70
75
  /** Try to get {jsPath,wasmPath} for a core from its binary package. */