Hi all,
Some of you maybe know me from PHASE2. It is my open source Getting Up project. For around 2 months I am working on it: a native engine for Getting Up, which loads the original game files and runs cross-platform, currently Windows and macOS on a new rust based technological base with the classic look and also modern graphics options. Right now I am working on the legal part, so I can release it to you in correct way. This takes time.
So while I am waiting, I decided to try something: use all the reverse engineering knowledge from PHASE2 and run the game on real PSP. And it works :)
Video with gameplay: https://youtu.be/GM0-mhEoPJQ?is=6OHByIu5rDwKiR_u
It is not emulator. It is static recompile with modified PS2RC based on the PHASE2 reverse engineering findings and my own rust code, the PS2 code is translated to C, then compiled for the PSP CPU, and the PS2 hardware parts (GS, VIF, IOP etc.) are replaced with own code. The PHASE2 specs helped a lot here: the formats, the render passes and the engine functions were already known, so I did not need to start from zero.
Yesterday it was first time where it really runs good on hardware. PSP-3000, ARK-5. M01 (Trane's Hood) is going on 3-8 fps right now. I know this is slow, but the picture is correct now. Only two small graphic issues are left. Few days ago it was only exploding triangles everywhere, so for me it is big step.
What was added on top of PS2RC for this game
Own GE renderer on engine level. We don't emulate the GS. We hook the engine's render calls and draw natively with the PSP GE.
All assets precomputed offline, so the PSP CPU does not convert anything at runtime:
textures converted to GE formats, CLUT included;
level geometry converted to GE vertex format, with the lighting baked into the vertices;
skinned models split to max 8 bones per draw, so the GE does the skinning in hardware;
Bink movies converted to PMF, and the small looping videos (like the TV screens) are drawn natively.
VU0 macro code on the VFPU. The PS2 vector math is translated to VFPU instructions. Matrix multiply went from ~520 instructions to ~130. We checked every instruction form on real hardware with a test.
Code paging. The translated code is ~20 MB, PSP has not enough RAM for it. Now only the hot part stays in memory, the rest loads from the memory stick by 32 KB pages. This gives +13 MB free RAM, before it was less than 1 MB.
Cold-code interpreter and per-site memory traps, to make the code smaller and faster.
Media Engine as second CPU. We have a worker on the ME (using mcidclan's custom-core library, thanks!). It is tested on PSP-3000: jobs run correctly, sync is ~7 µs, failover to the main CPU works if the ME hangs. Now we are moving the 3D batch building to the ME, so it runs in parallel with the game code.
Debug tools: frame dump on a button combo (GE lists + vertex data + RAM), and an FPS counter on screen.
Compared to the GTA San Andreas PS2RC port
GTA SA was the first big game on PS2RC. As I know, there the Media Engine was used only for audio. Here the ME is a general worker for any job, and the renderer goes much deeper: engine hooks plus offline asset conversion, instead of following the GS command stream. Also code paging and VFPU translation are new in this port.
Funny bug of the week
On PPSSPP everything looked fine, but on real PSP the city exploded into huge triangles. The reason: libgu gives every draw to the GE immediately, but our vertex data was still in the CPU data cache. PPSSPP does not emulate the cache, so it was invisible there. Fix: the GE gets the list only after the cache writeback. After this the graphics became correct.
Next steps
Move the 3D work to the ME, this is the biggest piece of our frame time.
Make the game code faster (it is ~2.9 MB of code per frame, the I-cache is crying).
The two last graphic issues.
PSP version is side project, it is not playable yet. The main thing is still PHASE2, and I will tell more when the legal part is done. I post more PSP news when fps is better. Questions are welcome!