levelsio 用 Claude Code 将 Battlefield 1942 反编译并移植到网页
levelsio 让 Claude Code 把 Battlefield 1942 反编译搬到网页还能联机,57000 个函数转成 10 万行 C,全程基本靠模型自己干,值得看看效果。
开发者 levelsio 将 Battlefield 1942 免费共享版反编译后移植到网页,支持多人联机。此前移植 Quake 和 DOOM 时已有开源项目可参考,而 Battlefield 1942 没有任何现成引擎或开源代码。Claude Code 将 x86 机器码反汇编出 57,000 个函数,翻译成约 100,000 行 C 代码,再经 Emscripten 编译为 WebAssembly。团队还重写了 300 个 Windows 和 Direct3D 函数以适配 WebGL 2,并基于 WebSockets 自建了联机网络栈。
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 2 and OpenGL to work on the web - then we had to build our own network stack so it could connect to our multiplayer server via WebSockets
I have no idea how it did any of this but it did it and it seems to work! 😊
Come play and report any bugs here!