Back

Show HN: PS2 games statically recompiled to WebAssembly

104 points7 hoursgithub.com
Megabinator • 59 minutes ago

What about compiling the compiler to WebAssembly so it can be hosted anywhere and convert a project directly from a browser?

kodablah • 34 minutes ago

Mentioned in other comment, but this is what I did at https://github.com/cretz/vitaslop for Vita. Generic ARM-to-WASM transpiler.

deadxwarrior • 45 minutes ago

yes, and its probably where this should go. The recompiler itself is plain C++ and builds for wasm easily, the heavy part is compiling its output (GoW2 becomes about 670k lines of Cpp), which would need clang running in the browser. The nicer route is to have the recompiler emit WebAssembly directly and let the browsers own engine compile it. I already do that for VU1 microprograms that were not seen AOT. It also solves distribution you'd pick your own ISO and the conversion would happen locally, so nothing derived from the game is ever hosted.

kodablah • 36 minutes ago

I did similar for PS Vita over the past few months: https://github.com/cretz/vitaslop

But instead of single games, I "built" an ARM-to-WASM transpiler in WASM. Also cool transcoding of WebGPU shaders, audio, and more.

Only have tested a few games so far, it's early days, but works quite well in Chrome mobile on flagship Android phones.

zuInnp • 2 hours ago

All of this recomp stuff is pretty amazing. I really don't like how AI changed my profession, but hey at least I get something good from it.

eluusive • 4 hours ago

Who would want to play Gran Turismo without long CD loading screens?

easyThrowaway • 3 hours ago

A better question: who would want to play Gran Turismo 3 or 4 without pressure sensitive controllers?

Even using the original ps2 or ps3 controller with the right drivers on PCSX2 doesn't really reproduce the same smooth acceleration/brake curve of the PS2.

Playing them on a keyboard or fully digital inputs is just a miserable experience.

suprjami • 1 hour ago

Right analog should be accelerate and brake.

Analog buttons were always a bad idea and should never be used.

These days you can map analog triggers to the sticks for a modern experience if you want that.

easyThrowaway • 30 minutes ago

> These days you can map analog triggers to the sticks for a modern experience if you want that.

It gets wonky if you press both analog triggers at the same time though. I've also tried mapping them to X and O to simulate the pressure, but the range is also somewhat off, with a way steeper curve (half pressing a trigger gives nearly 100% intensity of the OG buttons).

An alternate solution I've seen around is using a GMIX or similar devices and mapping the g29 wheel controls from the game to a modern Xbox/PS controller, but I've never tried it myself.

rickdeckard • 3 hours ago

wow, how awesome it would be to play those games with Trackmania-like reload-times (if you restart the race in Trackmania, you're immediately at the starting line again).

I assume it would require some additional patching in those GT / NFS games though...

ssl-3 • 3 hours ago

That's easy enough to simulate, too, isn't it? Just pause the game manually at the right spots to make time to get up, make a sandwich, eat the sandwich, take the dog out, walk the dog around the block, and then use the bathroom before resuming. No worries.

ErroneousBosh • 1 hour ago

ITYM "Who would want to play Gran Turismo" [Preparing...] <fwsssssssssss rrrmp fssswsss grmp fsswsss grmp fssswsss grmp> <ejects disc, polishes on T-shirt> <fwsssssssssssssssssssssss> "without long CD" [Preparing...] <aw no not again...> "loading screens?"

embedding-shape • 3 hours ago

Or without the very-much-needed hold-your-breath moment at startup, where you listen to the sounds to see if the DVD actually loaded correctly. You get a ~1 second moment in there where life itself suddenly stops, before you hear the "viump" that tells you everything is OK in the world.

styleio • 2 hours ago

And you lose the acoustic error handling too: one seek noise meant resolve(), another meant reject().

simonmales • 3 hours ago

No GitHub pages so I can play?

svantana • 2 hours ago

The games themselves are copyrighted, no?

rvz • 2 hours ago

Yes they are, and Cloudflare gets DMCA requests to take them down.

CodeCompost • 2 hours ago

AI or no AI, this is amazing.

krystalgamer • 2 hours ago

ah yes, another recomp that still emulates a core system component.

https://github.com/snuri00/ps2-web-recomp/blob/1066c9eea78c2...

popcar2 • 54 minutes ago

It's really getting annoying. There are a lot of people advertising "decompilations" and "native PC ports" that just turn out to be the emulator packaged into an exe that immediately runs the game... Makes it hard to find actual recompilations of games now.

rvz • 4 minutes ago

This is how you know that most coders that use claude never read the code, nor their own READMEs.

xyzsparetimexyz • 1 hour ago

Theres a lot of lying going on with these types of AI projects. What I want to see is more 100% matching decompilation so that people who dont use AI can modify the rendering eyv glue and port them to new platforms

wasabinator • 34 minutes ago

I would say it could be less lying and more the various "authors" having not even the slightest idea what their creations actually do.

xyzsparetimexyz • 16 minutes ago

I don't see a difference tbh. The Human/AI cyborg knows what it is and is lying.

dmonterocrespo • 4 minutes ago

[dead]

ekremabiii01 • 2 hours ago

its still under development, system components will compile to cpu and VU1 modules will translate to gpu shaders

deadxwarrior • 1 hour ago

Fair point, the IOP is interpreted. Its the PS1-class I/O CPU, and here it only runs the driver modules a game ships on its disc (sound engine, pad, memory card). The IOP kernel and the 20 core Sony libraries are reimplemented natively. In a God of War2 fight that interpreter is about 2% of cpu time, so it hasnot been worth recompiling yet for me. Its the same relocatable module problem i already handle for SN systems overlays, so its on the list. The EE game code is fully recompiled AOT (a missing function is a hard error, there is no interpreter fallback), and VU1 microprograms are recompiled per game, with a JIT and an interpreter only for programs not seen before. Whats left is hardware; the GS runs on the GPU, plus DMA, VIF, SPU2 and CDVD. Every recomp has to model that part, the same way N64Recomp uses RT64 for the RDP as i checked.

spwa4 • 3 hours ago

VERY cool. I wish you could make this work for steam deck (and friends) though.

TheCapeGreek • 2 hours ago

Why would you want this to work on a dedicated gaming device that can emulate the titles outright?

Have a look at Decky loader and Emudeck.

spwa4 • 2 hours ago

Can't get decky loader to work on my (Lenovo) steam deck

hodgehog11 • 2 hours ago

You can definitely still get PCSX2 working on it though, and it's fantastic. PS2 and PS3 games are among my favourite uses for handheld PCs.

FanaHOVA • 2 hours ago

What's a Lenovo Steamdeck?

+1
nottorp • 33 minutes ago
deadxwarrior • 37 minutes ago

There is already a native Linux build (Vulkan through wgpu, SDL2 window, audio and gamepad support), so it can run on the Deck as a non-steam game, and the browser build should work in desktop mode too. Two things are missing, the native host still runs on one thread (the VU1 and GS threads only exist in the web host so far), and since i cant distribute anything built from a game, you currently have to convert your own ISO on a PC. Decks GPU is less than half of the laptop iGPU i test on, so 1x resolution is the realistic target for now.Please keep an eye on the repo update, i'll release the relevant update for u.

fonrex • 4 hours ago

I hope they'll be able to do that with Forza too !

squidmaster • 3 hours ago

[dead]

danxbuild • 6 hours ago

Impressive. How are you handling the PS2’s timing sensitive hardware, like the vector units, in a static recompilation? Curious how close you can get to correct behavior without emulating cycle by cycle.

deadxwarrior • 30 minutes ago

Thanks:) it isn't cycle-accurate, and for the games i have tried so far it hasnt needed to be. EE code is translated AOT, and each block subtracts its instruction count from a cycle budget. Interrupts, timers, DMA and vblank are events on one emulated clock, delivered at block boundaries, so the order is right and the timing is approximate. Most games sync on interrupts and semaphores rather than cycle counts. When one does depend on timing, it shows up as a specific bug i can fix.for example, ran off an HBLANK timer I had set to the PAL period on an NTSC game. VU programs are not really part of the executable; games upload them over DMA. So i record each microprogram the first time its uploaded and compile it aot, and in the browser i JIT any program i havent seen to wasm. The pipeline details games actually observe are modeled: MAC/status/clip flags become visible four instructions late (getting that wrong put blotches on GT4s cars), and PS2 floats, which are nott IEEE (no inf/NaN, clamping instead), are done bit-exact. VU1 runs on its own thread, synced to the EE through the VIF/GIF streams

DylanMerigaud • 5 hours ago

[dead]

anthk • 3 hours ago

On the PSP recomp, I wish they could somehow target GL 2.1 video cards (ancient Intel iGPU's) so legacy users like me could play most of the games on an n270 netbook.

fps-hero • 2 hours ago

Man, the netbooks were amazing for their time, but even by 2008 standards, they were not powerful computers.

At the time you needed a fairly capable gaming PC for PS2 emulation, which is a far cry from the igpu in an atom. Given a PSP is basically a cut down PS2, I don’t think emulation on that calibre hardware is an achievable goal. An atom doesn’t even have a hardware programmable vertex shaders, on windows I don’t even think they had GL 2.1.

I never thought I’d see the day where an atom would be vintage tech, and people would still be rocking said vintage tech. It’s amazing you’ve kept it running and usable. Modern PCs can’t even keep up with modern OS, and you’re still rocking the good old days of single core single thread. Rock on!

ant6n • 1 hour ago

I used to play GTA San Andreas on an n270 netbook, I believe at 1024x600. Didn’t run well, but was definitely playable.

mathgeek • 1 hour ago

Sounds like the epitome of amazing for its time but not a powerful computer.

pjmlp • 1 hour ago

I agree with the sentiment, however it needs to be at least OpenGL 3.3, and take advantage of shaders.

Narishma • 1 hour ago

GL 2.1 supports shaders.

pjmlp • 1 hour ago

I know, but it still has lots of baggage and missing features, which is why game engines that support OpenGL tend to target OpenGL 3.3 as the minimum baseline, given that it used to be widely deployed.

+1
Narishma • 60 minutes ago
m00dy • 3 hours ago

I don’t think it’ll happen. The market is too small, and the token costs don’t seem worth the potential upside.

Narishma • 1 hour ago

What do you mean by token costs? Does it cost more tokens to support an older graphics API than a newer one?

dewey • 40 minutes ago

Yes, because it would not be an "or" but an "and", more features = more tokens.

Narishma • 6 minutes ago

It's not an "and". GL 2.1 has all the features necessary for PS2 games and is still supported on modern systems. Older APIs may be slightly more verbose than newer APIs but that shouldn't matter to an AI.

sick_of_slop • 2 hours ago

[dead]