For the Multiplayer part: It's deterministic lockstep. Both browsers run the same C core (compiled to WebAssembly), and the only thing sent over the network is each player's button bitmask per frame. Local input is delayed by 4 frames (~67 ms), which hides normal internet latency; if the other player's input for a frame hasn't arrived yet, the game waits for it. Every 2 seconds both sides compare a hash of the game RAM to catch desyncs. Transport is a WebRTC data channel via PeerJS (its free cloud server handles matchmaking with a room code), with Google's STUN server for NAT traversal and Metered's free-tier TURN relay as a fallback when a direct connection isn't possible.
For AI usage: It was all done by Claude/Codex, but it wasn't that straight forward. First: i started in April and the models weren't good enough and would make errors. You could see those immediately in glitches. Then, i spent some time in building a harness and collect telemetry data in Mesen. Once, i had that: i just played the game in the emulator and asked Claude Opus 5.5 to use this as verification. The rest was smooth.
100% AI I'm sure. I played around with this kind of thing a month or so ago and Codex had no problems mashing games up from just the ROMs. In about 30 minutes I had the contra guys running through SMB 1 shooting enemies.
Can you elaborate on the process? Do you just provide it with the ROMs and it is able to pull apart the relevant sprites and code pieces, and recombine into a new ROM?
Yep. Fire up a new project, give it the two ROMs and the emulator to use and tell it what you what. I had to guide it a little bit about the sprite size and collison logic, but it was extremely painless.
One of the things that I'm curious about: How easy / hard is it to use the same NES game with higher resolution / color graphics, and sample-based sound?
Are there any emulators out there that let you swap in higher resolution assets so a game can be freshened without a complete port?
I would not think so, at least not in a meaningful way. That would require to edit the cartridge data thus the ROM, as all sprite data was contained within the cartridge. Sample based sound is impossible natively, as NES and older game consoles don't work with digital data but synthesizers. You could perhaps synthesize the music to WAV files and then enchance it. But then again, NES and thus its emulators have no way of playing digitized audio!
The NES in particular is probably not too difficult to upscale, because the graphics data is stored on its own ROM chip (sometimes RAM) in a well structured layout. SMB1 just uses a ROM chip containing many tile graphics which the CPU code addresses by tile index. It would be really easy for an emulator to use the same tile indices to address any arbitrary set of tiles loaded from a PNG. Some games use RAM, which makes it harder as you'd have to index the PNG by hash or something.
> Sample based sound is impossible natively, as NES and older game consoles don't work with digital data
The NES supports PCM audio. It was notably implemented wrong in the title screen of Double Dribble and fixed with a patch that produces clearer audio after bit reversal into the correct encoding for the hardware:
It does work with channels that produce pulse waves yes, but what I meant is that you can't supply samples of a wave and expect it to play it. The sound is still analog.
Yeah I noticed this when I was mucking about with emulators. Thought I was imagining things until I looked it up. As far as I remember it has better sound too, or maybe I'm remembering castlevania three.
I added audio support, but now you need to upload your own ROM. I didn't expect this to get so much attention. Since Konami is company behind Contra and they are known for DMCAing, i want to be better safe than sorry.
Contra is my favorite game of all time so this is a real treat, and the co-op idea is fantastic. Not to be greedy, but how hard would it be to add music? :)
Whenever I see a game that uses the arrow keys and doesn't offer WASD as well, I can't help but see a game written by a non-gamer. I consider these fundamentals, and a shibboleth of whether I should care.
While I'm not defending a slop port, I have to question your gamer credentials. Maybe by gamer you mean a Call of Duty player? WASD is traditional for FPS/TPS games that expect you to have one hand on the mouse. Most 2D games, and every emulator I've ever used, have never offered WASD.
correct me if i'm wrong, gamer credential questioner, but WASD was immortalized by the id Software "win Carmack's ferrari" tournament. Before then EDSF was also popular because it gave you more keys on the left side for hotkeys.
I do think you're objectively correct in your post, but I think what the grandparent meant was that "The author isn't actually interested in playing Contra on his website" which is why QoL stuff like that wasn't added and it "smells" like it should be there if you cared about playing on the thing you actually shared to HN.
I know the first thing I would do would be to add wasd + mouse support to Contra, since the control scheme is the reason I don't try to play it. But at the same time I have never been interested in games that deliberately limit your controls as a form of difficulty (feels like a Japanese gamedev thing, from Resident Evil to Dark Souls)
You awoke negative-nostalgia to membrane keyboards where I remember I couldn't hold Shift + W + A at the same time in Minecraft as a kid so you're definitely right about bad keyboards, but I remember dead keys on WASD as well.
I wasn't there, but the largest consensus seems to be that Quake popularized it, plain and simple. I'm sure other factors like what you mention helped it become the dominant layout as well
edit: figured out why that nostalgia happened. I was revisiting an old flash game I liked [0] and people were complaining to the dev about this exact key ghosting issue to him when it wasn't his fault but a fault of their keyboards, and in the Newgrounds description he links to a forum post [1] elaborating on the issue
I think because the computer mouse is typically on the right side of the keyboard (because most people are right-handed), WASD has the advantage of allowing your mouse to be controlled by your right hand and you can keep your left hand in the normal position it is used for typing and not have to have your left hand move all the way to the arrow keys to control directions.
Unfortunately, I'm a bit concerned that cool labor of love hacker projects like this will become much less common now that Anthropic (and possibly soon others) is moving to restrict this kind of usage. Oh well, so much for cool fun stuff.
I could write a well crafted reply, with a convincing argument, but why bother? You're just trolling. The whole anti AI coding thing is such a meme. I suppose you'd like to spend all the time it would take to reverse engineer a classic NES game by hand? Go familiarize yourself with 6502 assembly and everything else you'd need to know?
I would rather read a write up of someone doing just that. This exact thing has been done many times now and no one is really learning or demonstrating anything new. It is cool, insofar as AI tools are capable of reverse-engineering, mechanical translation, and automatic verification, but it is no longer _novel_ and borders on spam.
What if you've already played that game many other times during your 15 year long career? I mean the "game" of learning the ins and outs of a technical subtopic. And you know you could spend months ramping up on another thing just to see an idea take shape, but you only have limited resources in your life, a full time job, and so forth. And you'd still like to see an idea become a reality regardless of all that. So I guess that's not real work and it's cheating and it doesn't have value?
I mean, if you insist on doing everything by hand, go right ahead.
Afterthoughts: I really just don't get why people are so weird about this AI coding thing. What difference does it make to you if someone thinks they have more to learn from high-level planning work than from low-level coding work? A lot of the time, I get the vibe from people who talk this way that they are still early on in their career and think they have to prove their coding chops. I think that's why people like Linus Torvalds couldn't give a shit if people use AI or not, as long as it's not slop and suits its purpose. If you've already spent over a decade writing code and savoring the process, maybe you're just getting a little tired of it. And maybe agonizing over code perfection even drives you slightly insane sometimes. Who the f*** knows? In any case, it's none of your business. I don't know why I'm even writing all this. Because I know you'll just come back with the same old tired gatekeeping non-arguments.
The first project like this (of using AI to port old software from assembly) was interesting and novel. But every subsequent post has me wondering what new insight or lessons we have learned and if doing more of these is worth the energy burn.
Recently I did something similar (or even more labor-intensive). I recreated an existing game from scratch by manually rewriting its code without even thinking about LLM/"AI" tools usage. (see my submissions).
But I agree, that using an "AI" tool may be a serious temptation and thus way less new porting projects will be done with such care.
The whole thing (all banks) is more than 10,000 lines of assembly code. When I wrote assembly code for a university computer science course, it was hard to manage even 200 lines. I cannot imagine writing and managing 10,000 lines!
As much as I wouldn't want to write that much assembly, you make it less daunting the same way that you would with any other programming language. There are simple idioms for loops that you can macro-ize; similarly for function setup and teardown; more importantly, the concept of a function still exists at that level.
Bear in mind: the dissambly was done pre-LLMs. The early commits are from 2023. Although, ChatGPT 4 existed then, it was not capable of doing these things.
Nice! Can you speak to your process? How much structure did you give the agent? Did you have to "discover" the right way to do the port? Perhaps you just asked Claude, and then iterated? How do you feel about the final architecture/layout of the code, and would you approach a similar project in a new way given what you've learned?
You said in another comment:
> Then, i spent some time in building a harness and collect telemetry data in Mesen. Once, i had that: i just played the game in the emulator and asked Claude Opus 5.5 to use this as verification.
Can you comment on how this verification process worked?
You'll have to forgive me for not trying to answer these questions myself by investigating the code/git history, but... I hope you understand.
Actually, I am peeking around the code a bit and it's a bit disappointing, but it's what I should have expected having tried a project like this myself with a Game Boy game. I would like to see what an AI-produced semantic (?) rewrite of a retro game would look like. That is, what a port/rewrite that wasn't so faithful/wedded to the original ROM layout or platform architecture. For example, the agent (and you, presumably) was satisfied with writing a sort of RP2C02 emulator facade instead of doing the hard work of translating the bytes into platform-agnostic graphics rendering code. So now any customization/extensions you write to the game are fundamentally constrained to the abstractions of a specific chip from the 80s.
BSPtree | 14 hours ago
[OP] tevlon | 13 hours ago
For AI usage: It was all done by Claude/Codex, but it wasn't that straight forward. First: i started in April and the models weren't good enough and would make errors. You could see those immediately in glitches. Then, i spent some time in building a harness and collect telemetry data in Mesen. Once, i had that: i just played the game in the emulator and asked Claude Opus 5.5 to use this as verification. The rest was smooth.
esikich | 11 hours ago
waltbosz | 10 hours ago
esikich | 6 hours ago
gwbas1c | 13 hours ago
Are there any emulators out there that let you swap in higher resolution assets so a game can be freshened without a complete port?
kekebo | 13 hours ago
Edit: For SNES, not NES, my bad.
gwbas1c | 9 hours ago
unleaded | 13 hours ago
BSPtree | 13 hours ago
cowlevel | 13 hours ago
pantelisk | 13 hours ago
kevin_thibedeau | 10 hours ago
The NES supports PCM audio. It was notably implemented wrong in the title screen of Double Dribble and fixed with a patch that produces clearer audio after bit reversal into the correct encoding for the hardware:
https://www.youtube.com/watch?v=Jli0RGpuZDg
BSPtree | 47 minutes ago
vunderba | 13 hours ago
https://store.steampowered.com/app/1147940/3dSen_PC
[OP] tevlon | 13 hours ago
throwaway2037 | 2 hours ago
einpoklum | 13 hours ago
[OP] tevlon | 13 hours ago
raldi | 13 hours ago
[OP] tevlon | 57 minutes ago
pipes | 11 minutes ago
Dwedit | 12 hours ago
[OP] tevlon | 53 minutes ago
shinryudbz | 12 hours ago
[OP] tevlon | 56 minutes ago
gosen | 12 hours ago
egonschiele | 11 hours ago
[OP] tevlon | 54 minutes ago
pxx | 11 hours ago
msephton | 10 hours ago
I used it to get games written in Lua running on SNES and in my own language/engine running on Dreamcast, Wii, Web and more.
jasonlotito | 10 hours ago
anonymous908213 | 10 hours ago
literallyanythi | 10 hours ago
I do think you're objectively correct in your post, but I think what the grandparent meant was that "The author isn't actually interested in playing Contra on his website" which is why QoL stuff like that wasn't added and it "smells" like it should be there if you cared about playing on the thing you actually shared to HN. I know the first thing I would do would be to add wasd + mouse support to Contra, since the control scheme is the reason I don't try to play it. But at the same time I have never been interested in games that deliberately limit your controls as a form of difficulty (feels like a Japanese gamedev thing, from Resident Evil to Dark Souls)
justsomehnguy | 9 hours ago
literallyanythi | 9 hours ago
edit: figured out why that nostalgia happened. I was revisiting an old flash game I liked [0] and people were complaining to the dev about this exact key ghosting issue to him when it wasn't his fault but a fault of their keyboards, and in the Newgrounds description he links to a forum post [1] elaborating on the issue
[0] https://www.newgrounds.com/portal/view/547881
[1] https://board.flashkit.com/board/showthread.php?789015-wont-...
em3rgent0rdr | 8 hours ago
lightedman | 7 hours ago
You sure you're a gamer? I've been at it since about 1986.
pjmlp | 2 hours ago
pmarreck | 8 hours ago
erictheguy | 8 hours ago
davesque | 7 hours ago
pansa2 | 7 hours ago
I hadn’t heard about that - any details?
gnabgib | 7 hours ago
EmX_3000 | 6 hours ago
jkahrs595 | 6 hours ago
gnabgib | 5 hours ago
jkahrs595 | 5 hours ago
davesque | 4 hours ago
tadfisher | 2 hours ago
pjmlp | 2 hours ago
Buttons840 | 2 hours ago
pjmlp | 2 hours ago
When someone commissions a painting, or a sculpture, they might cut the ribbon that holds the curtain on the opening day, that is all.
davesque | an hour ago
I mean, if you insist on doing everything by hand, go right ahead.
Afterthoughts: I really just don't get why people are so weird about this AI coding thing. What difference does it make to you if someone thinks they have more to learn from high-level planning work than from low-level coding work? A lot of the time, I get the vibe from people who talk this way that they are still early on in their career and think they have to prove their coding chops. I think that's why people like Linus Torvalds couldn't give a shit if people use AI or not, as long as it's not slop and suits its purpose. If you've already spent over a decade writing code and savoring the process, maybe you're just getting a little tired of it. And maybe agonizing over code perfection even drives you slightly insane sometimes. Who the f*** knows? In any case, it's none of your business. I don't know why I'm even writing all this. Because I know you'll just come back with the same old tired gatekeeping non-arguments.
userbinator | 6 hours ago
em3rgent0rdr | 4 hours ago
Panzerschrek | 4 hours ago
But I agree, that using an "AI" tool may be a serious temptation and thus way less new porting projects will be done with such care.
Buttons840 | 2 hours ago
sfblah | 7 hours ago
[OP] tevlon | 54 minutes ago
throwaway2037 | 2 hours ago
The whole thing (all banks) is more than 10,000 lines of assembly code. When I wrote assembly code for a university computer science course, it was hard to manage even 200 lines. I cannot imagine writing and managing 10,000 lines!
zahlman | 2 hours ago
[OP] tevlon | 58 minutes ago
Impressive work, indeed. vermiceli the GOAT.
throwaway2037 | 43 minutes ago
incr_me | 44 minutes ago
You said in another comment:
> Then, i spent some time in building a harness and collect telemetry data in Mesen. Once, i had that: i just played the game in the emulator and asked Claude Opus 5.5 to use this as verification.
Can you comment on how this verification process worked?
You'll have to forgive me for not trying to answer these questions myself by investigating the code/git history, but... I hope you understand.
Actually, I am peeking around the code a bit and it's a bit disappointing, but it's what I should have expected having tried a project like this myself with a Game Boy game. I would like to see what an AI-produced semantic (?) rewrite of a retro game would look like. That is, what a port/rewrite that wasn't so faithful/wedded to the original ROM layout or platform architecture. For example, the agent (and you, presumably) was satisfied with writing a sort of RP2C02 emulator facade instead of doing the hard work of translating the bytes into platform-agnostic graphics rendering code. So now any customization/extensions you write to the game are fundamentally constrained to the abstractions of a specific chip from the 80s.