Skip to content
AI Primer
workflow

Levelsio says Claude Code helped port Battlefield 1942 to the browser

Levelsio released a browser-playable multiplayer port of the Battlefield 1942 demo. He reports using one million output tokens to decompile the game and convert it to C and WebAssembly.

3 min read
Levelsio says Claude Code helped port Battlefield 1942 to the browser
Levelsio says Claude Code helped port Battlefield 1942 to the browser

TL;DR

He says he revived a six-month-old failed attempt with “Opus 5.5” and the prompt “can you try port the BF1942 demo in this folder to web”. The build ran on a MacBook Pro before deployment to Ubuntu, according to his reply about the setup.

From x86 to WebAssembly

Levelsio says he started with compiled machine code and worked through six stages:

  1. Disassembly: Identify approximately 57,000 x86 functions in the executable.
  2. x86 → C: Translate machine instructions into C functions. His example turns mov eax, [esi+0x110] into eax = READ32(esi + 0x110).
  3. C output: Generate approximately 100,000 lines of C.
  4. C → WebAssembly: Compile that output with Emscripten.
  5. Windows/Direct3D → WebGL 2/OpenGL: Rewrite approximately 300 platform-specific functions for the browser.
  6. Multiplayer networking: Build a custom network stack connecting the browser client to a multiplayer server through WebSockets.

The playable project’s page identifies the graphics work more specifically as DirectX 8 reimplemented on WebGL 2. Rebuilding those Windows-facing interfaces is the impressive bit.

Emscripten’s graphics documentation describes an OpenGL subset that maps directly to WebGL; its networking documentation explains that browsers cannot open TCP sockets directly.

Benchmarks that moved

The server hit its 16-player ceiling after launch. Levelsio then announced 64 slots: 16 → 64, +48 slots.

Across his old-game ports, he also claimed faster loading than on his RTX 5090 gaming PC. The posts provide no timed loading comparison, frame-rate measurements or latency results.

One million output tokens

Levelsio says the work ran through his $100/month Claude subscription. Expanding from output alone to every category in his usage ledger changes the accounting:

  • Tokens counted, in millions: 1.0 → 291.2, approximately +290.2 million tokens when input and cache operations are included. Most of that volume consists of repeated reads of cached context.
  • Estimated API cost, in dollars: 19.99 → 102.50, approximately +82.51 dollars when input and cache operations are included.

These comparisons count the same run at different scopes; the dollar figures estimate API billing.

Where it regressed

Levelsio describes this as harder than his Quake and DOOM ports: those benefited from existing open-source work, while Battlefield 1942 had no open-source engine to build on, according to his account.

The playable scope is the free demo, as he emphasized in a reply. He also calls the game “abandonware”.

EA’s November 2012 announcement offered a free PC copy through Origin, subject to conditions. That announcement contains no permission to publish a modified browser build.

The browser project describes itself as non-commercial, unofficial and unaffiliated with EA or DICE.

The browser-game museum

Levelsio’s Quake III and DOOM projects already offer browser multiplayer. He describes the goal as “open tab, instant multiplayer”.

His other creator invitation is more outdoorsy: in a separate conversation, he offered to travel and film walks with people doing interesting work.

Further reading

Discussion across the web

Where this story is being discussed, in original context.

On X· 6 threads
TL;DR3 posts
From x86 to WebAssembly1 post
Benchmarks that moved2 posts
One million output tokens1 post
Where it regressed2 posts
The browser-game museum3 posts
Share on X