ok i feel qualified to explain this:
when i make a print("Hello World!") program, the text file is the source code. a compilator then takes that code, and makes a binary file. The binary file turns that code into a couple things, but most importantly:
- calls to the cpu (every cpu architecture works differently, so ARM/x86/RISC-V all have wildly different outputs)
- system calls (every operating system has different ways to do things. Printing something to the terminal, displaying a picture - etc on linux, windows, bsd or solaris all refer to different programs, paths)
So, the PS2Recomp project analyzes binary file, and since we:
Know the cpu's architecture
And the os (technically ps2 doesn't have an os but it's close enough)
We can take the compiled game's binary (rom), analyze what calls it's made of, then turn those calls back into C++ code
We now have the obfuscated source code of the game. That's 90% of the work needed. The next steps are to make the code more readable (the binary file doesn't save comments variable names, function names - so when we look at it - it's all junk. Someone has to manually go in and see what parts of the code do what.)
Then we can fix platform-specific bugs (sometimes games rely on the system actively not working as intended. A famous example would be GTA sand andreas' skimmer plane crashing the game on newer windows versions, cause it relied on fgets() failing to read it's corrupted config, and replaced it with junk random data (which is better than it crashing))
Then there's probably other stuff you have to do that i'm not familiar with. Probably translating things like where to store files, how to read input.
Annnnd we now have the game's decompiled code! We can do with it whatever we want. Windows builds, linux builds, 3ds, mobile - whatever we want.
Additionally since we're no longer relying on magic, and we can run debugges on the application, it's easier to fix bugs and mod in content.
When we emulate PS2 games, all we translate R5900 (that's ps2's cpu architecture) calls to that of our pc's as the application runs. Basically, instead of talking to our cpu, the game talks to a translator to do the calls for you. This is really, really slow (and also do other stuff)
Important part is, when we translate the game's calls to x86/arm ahead of time, and run it natively with nothing in the way, the game runs as fast as anything else. It's no different than if the game was made for that platform from scratch.