bevy-atari: a 'Good Enough' Atari XL/XE Emulator in Rust for the Browser

In November 2021 the developer mrk (GitHub: mrk-its) published the README for bevy-atari, his "Good Enough Atari XL/XE Emulator". It had been in development for a year, and it was soon linked on AtariAge in the thread about his Web POKEY sound emulator, which he had written for it. It is not meant to compete with Altirra for accuracy. Its aim is to run a large part of the Atari library directly in a browser tab, with nothing to install and nothing to configure.

What makes it different

bevy-atari is written from scratch in Rust on top of the Bevy game engine. Its main target is WebAssembly in the browser, though native Linux, Windows and macOS builds are possible.

  • ANTIC and GTIA run on the GPU. The display is produced by a fragment shader (WebGL2 required), which takes load off the browser's single main thread.
  • CPU: a cycle-accurate 6502 core with the undocumented opcodes and proper DMA cycle stealing.
  • Sound: POKEY, including stereo, comes from Web POKEY.
  • Memory and media: 256 KB of extended memory by default, ATR disk images, and the standard 8 KB, AtariMax 128 KB and AtariMax 1 MB cartridge types. Gamepads work through the browser's Gamepad API.
  • Configured by URL. Software is loaded by adding the image's address after a # in the emulator's URL (for example #xex=… or #disk_1=…). A CORS proxy lets it fetch files from other sites, so a single link can launch a game.

The README's demo links included Avalon's Robbo, bocianu's FloB, the ABBUC 2021 entries Gacek and Last Squadron, and Prince of Persia. A bonus "Atari Wall" page runs nine emulated machines side by side, each playing a different demo or game.

Development

The commit history shows the work. The first commits in November 2020 rendered real ANTIC display lists and a Robbo title screen from an atari800 state file. A CPU core, DLIs and multiple character sets followed within days. In autumn 2021 mrk added stereo and the move to Web POKEY, a SAP recorder, bank-switched memory, writable ATR images, multiple drives and local files. By the end of 2021 there was an on-screen debugger and IndexedDB storage. In the first half of 2022 he added native sound, remote GDB debugging, a keystrokes URL parameter that types into the emulated Atari, a file browser for browser storage, an emulator-configuration panel saved in the browser, and console-speaker key clicks.

Limitations

The README is frank about the gaps. The ANTIC/GTIA emulation is simplified, so registers changed mid-screen do not show immediately. POKEY interrupts are not supported, and disk access goes through an SIO patch instead of emulated serial hardware. There is no cassette support, and some programs show glitches or crash. Users found the odd quirk too: wiggling the mouse made emulation run faster in one early build.

Where to try it

The source is at github.com/mrk-its/bevy-atari, and the live version and the demo links from the README run at mrk.sed.pl/bevy-atari. A modern browser with WebGL2 is all you need. To build it yourself you need Rust and cargo-make; cargo make serve starts a local copy on port 4000.

Credits