NFSU.cc / Guides

How it works: a 2003 Windows game recompiled to WebAssembly

What runs in your tab is the game's own code from 2003. It was not rewritten and it is not emulated: the program was translated once, ahead of time, into something a browser can run.

A car driving through Olympic City in the browser version of Need for Speed Underground
The same physics, AI and HUD code as in 2003, now running as WebAssembly.

Static recompilation

The PC game is one Windows program, Speed.exe, made of machine code for 32-bit Intel processors. A tool reads that program and writes the same logic again as WebAssembly, the portable code format browsers run at close to native speed. This is called static recompilation: the translation happens before you ever open the page, not while you play.

An emulator would have to imitate a whole PC, instruction by instruction, every frame. Here the handling, the rival drivers, the menus and the career rules are the original ones, already in the browser's own format. The result is a file of about 70 MB that travels compressed in 11 MB.

A new home for an old program

The game still believes it is on Windows XP. It asks for windows, files, sound buffers, keyboard state and a DirectX 9 graphics card. A layer written for this project answers each of those calls with what a browser has:

The remaster layer

Because the page owns the drawing step, it can add things the 2003 renderer did not have: bloom on lights, edge smoothing, sharpening, anisotropic filtering, sharper car paint and optional high resolution textures. All of it is a layer on top. Switch the version to Original 2003 and the picture is the one the game always drew.

Try it

The quickest way to judge the result is to drive it: how to start playing takes a minute to read.

In the repo: tools/recomp · host · web · census

More guides