Show HN: Arcade.js – Decompiling MAME ROMs into Idiomatic JavaScript with LLMs Arcade.js, an experimental project by developer qarl, uses an agentic harness with LLMs to decompile MAME ROMs into idiomatic JavaScript, demonstrated with Donkey Kong (1981) and The Pit (1982). The multi-stage process includes disassembly, translation, state testing, decompilation, pixel testing, and clarification to produce human-readable code that matches original game output. arcade-js is an experiment in using an agentic harness to decompile ROM machine code. A MAME ROM is a good candidate for porting — you can run it perfectly and capture its state. It is also a challenge — pure machine code running on odd hardware. To get from machine code to readable JavaScript, we go through several stages: 1 Disassembly — pull the raw bytes apart into instructions and data. 2 Translation — rewrite it one instruction at a time into JavaScript that's provably identical to the original. We call this "assembly-JavaScript": it's JavaScript, but its shape is the assembly's. 3 State testing — run the assembly-JavaScript next to MAME and check that every register, every byte of memory, and the cycle count all track it. Not bit-perfect real hardware has a CPU-vs-video-beam race we don't chase, etc. but close enough to catch errors. 4 Decompilation — rewrite that assembly-JavaScript into real, idiomatic JavaScript. 5 Pixel testing — the idiomatic code no longer tracks registers or cycles, so we check the only thing that ultimately matters: the output. 6 Clarification — the surprise, where an LLM reasons about the code and its behavior to create human-readable JavaScript. We point to two good examples of the technique: Donkey Kong 1981 , because everyone has heard of it; and The Pit 1982 , because no one has. https://github.com/qarl/arcade-js/blob/main/games/dkong/idio... https://github.com/qarl/arcade-js/blob/main/games/dkong/idiomatic/snapYToGirder.js https://github.com/qarl/arcade-js/blob/main/games/thepit/idi... https://github.com/qarl/arcade-js/blob/main/games/thepit/idiomatic/collectLootTile.js Note: the repo does not hold the original ROMs which contain copyrighted artwork . If you want to actually play the games, you must provide your own. Comments URL: https://news.ycombinator.com/item?id=49069383 https://news.ycombinator.com/item?id=49069383 Points: 1 Comments: 0