smolka

#sprite

sprite is a Game Boy emulator written in drizzle and serves as the ultimate stress test for the programming language. It implements most components of the system with reasonable accuracy, but there is no sound or saves, and the cartridge types are limited to MBC0, MBC1, and MBC3.

Technology is incredible guy
Technology is incredible guy
Zelda intro sequence
Zelda intro sequence

The initial implementation didn't even manage to emulate the console at half speed. Optimizations like using a specializing adaptive interpreter in drizzle and replacing the class with free functions and variables in sprite increased the performance to 125%, which resulted in a stable frame rate at native speed.

#drizzle

drizzle is a dynamic interpreted programming language with a syntax similar to Python.

class Point:
  def init(x, y):
    this.x = x
    this.y = y
  def cross(other):
    return this.x * other.y - this.y * other.x

# Stokes' theorem
def area(polygon):
  var s = 0
  for i in 0 .. len(polygon):
    s = s + polygon[i - 1].cross(polygon[i])
  return s / 2

var triangle = [Point(0, 0), Point(4, 4), Point(0, 4)]

assert(area(triangle) == 8.0)

It started as an exercise for language design and whitespace-aware parsing and grew into something powerful enough to run a Game Boy emulator. It provides simple SDL2 and filesystem abstractions to achieve that. The latest version also features a specializing adaptive interpreter to squeeze out the last bit of performance.

Icon of drizzle rendered with SDL2
Icon of drizzle rendered with SDL2
Icon of eggvance rendered with SDL2
Icon of eggvance rendered with SDL2

#eggvance

eggvance is a fast and accurate Game Boy Advance emulator. The processor grew instruction by instruction in conjunction with its test suite to ensure a solid implementation with all edge cases covered.

Mew on Faraway Island
Mew on Faraway Island
Final moments of Mother 3
Final moments of Mother 3

Other components of the system soon followed, and the emulator got to a stage where it was able to run most games and demos you threw at it. Around that time, I spent a weekend porting it to WebAssembly. Audio emulation was something I had been putting off until the end due to my lack of experience, but I managed to do it eventually.

Pokémon Emerald battle frontier theme

The final year of development went into performance and accuracy improvements. I released version 1.0 around 2.5 years after the initial commit and wrote a couple of progress reports along the way.