The Random Curiosities of Derek Lomibao.net
← Projects

deloNES

Java · TeaVM · 2024–26

An NES emulator, written from scratch in Java.

I had always wanted to build an emulator. Knowing how a computer works is one thing and getting real games to run on one you wrote is another. I picked Java because there are not many NES emulators in it, so I could not lean on someone else's.

It started in 2024, with OneLoneCoder's olcNES as the first reference, and covers the 6502 processor, the picture unit, the sound unit, and the cartridge mappers that let games outgrow the console they shipped on.

How it runs in a browser

The emulator is ordinary Java on LibGDX. TeaVM compiles that Java to JavaScript, with WebGL drawing the picture and WebAudio playing the sound, so this page runs the same core as the desktop build.

Testing it

Most of the work went into testing.

  • The processor matches the nestest reference log on all 8,992 lines.
  • 836 tests cover the core.
  • A headless harness scripts controller input, watches memory, snapshots frames and records and replays whole play sessions, with no window open.

The harness found three bugs the standard test ROM cannot see. One of them made a game's hero invisible: BRK pushed a return address one byte too far, and the game used BRK to call its animation code.

Running it

It boots Spacegulls, a free homebrew game by Morphcat Games. Choose Load ROM or drop a .nes file on the screen to play your own. The file is read in your browser and never uploaded.

Keys: arrows, Z and X, Enter, Right Shift. On a phone a touch pad appears.