Vibeleaderboard
← All Intel
Intel / post

Claude Code decompiles and ports Battlefield 1942 to the browser

Source
x.com
Date
@levelsio@levelsio

I decompiled probably my favorite game ever: Battlefield 1942 and I put it on the web with multiplayer for you to play here: 👉 https://t.co/6C8H8KtSaU 👈 (It's the free shareware demo) It was way harder than the other ports like Quake and DOOM I did because they already had lots of open source projects and work behind them In case of Battlefield 1942 there was literally absolutely nothing to work on top of, nobody had ever ported it and there was no open source engine for it, nor did the makers ever open source it (like id Software did with Quake 3) I tried it 6 months ago and essentiay gave up but I tried it today again with Opus 5.5 asking "can you try port the BF1942 demo in this folder to web" So me and Claude Code (well let's be honest mostly Claude Code) did crazy shit today: - it disassembled the x86 raw machine code to find 57,000 x86 functions - it translated each x86 function into a C function (mov eax, [esi+0x110] becomes eax = READ32(esi + 0x110), I have no idea what any of this means btw) - it outputed 100,000 lines of C - it then compiled that to WebAsswmbly with Emscripten - there were 300x Windows and Direct3D functions used which we had to rewrite to WebGL…

Read the full post on X

Context

Pieter Levels says Anthropic's Claude Code, running Opus 5.5, turned the 2002 Battlefield 1942 demo into a browser game with multiplayer in a single day, starting from the game's compiled program rather than any source code. Levels, who had earlier put Quake and DOOM on the web, writes in his post that he tried this port six months ago and essentially gave up. This time he asked the to "try port the BF1942 demo in this folder to web".

The difficulty, in his account, was that there was nothing to build on. Quake and DOOM had open-source engines and years of community work behind them; Battlefield 1942 had no released source code, no open engine and no earlier port. So the agent started from the raw x86 machine instructions that a Windows PC executes. According to Levels, it found 57,000 functions in that code, translated each one into a C function, producing 100,000 lines of C, and compiled the result to WebAssembly, a format browsers can run, with the Emscripten compiler. His example shows the style of translation: a processor instruction that loads a 32-bit value from a memory address into a register became a C line calling a READ32 helper on the same address. The game also called about 300 Windows and Direct3D functions, which had to be rewritten for WebGL 2 and OpenGL, and the two built their own networking so the game connects to a multiplayer server over WebSockets.

This is Levels's own description, and he is candid that he cannot vouch for the details. He says of the translated code, "I have no idea what any of this means", and his claim of success is that the game "seems to work", with an invitation to report bugs. The playable game page is the main evidence: it calls the project a non-commercial, unofficial preservation effort, says the free 2002 demo was recompiled from x86 to WebAssembly with DirectX 8 reimplemented on WebGL 2, notes that Battlefield 1942 was released as freeware in 2012, and requires desktop Chrome or Edge version 137 or later. In a narrated video, transcribed automatically, Levels says he believes the demo has only one multiplayer map.

Terms in this piece · Glossary
  • AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
More from @levelsio
Recommended reads
Comments

Checking sign-in…

Loading comments…