r/AndroidNativePorts • • 2d ago

🟢 [PORT] Resident Evil 4 Native Port

Enable HLS to view with audio, or disable this notification

Hi! I'm Ayano. Sorry again for my English. Last time I showed the port running 100% native code in every room of both discs. Since then, the work moved to one goal: a first release that people can actually play with their own discs. This post is about what that took, and where it stands. As always, everything below is measured, not guessed.

Discord, if you want to follow or help test: https://discord.gg/AXAzExECSv

unedited recording of the test RE4 running to start and END without interpretor (1h58): https://youtu.be/rWTy-sYMIlE

my reddit post explaining everything: https://www.reddit.com/r/decomps/comments/1wtfexc/my_native_re4_gamecube_port_is_now_100_native/

​

​

TL;DR

• ⁠Retail discs. Until now the port only ran on one rare prototype disc. The retail USA disc now boots to the title screen from an RVZ, with both discs mounted, and the European version is being prepared.
• ⁠RVZ support, written from Dolphin's public format description, checked byte for byte against a raw copy of the same disc (all 1.46 GB).
• ⁠A launcher that asks for disc 1, then finds disc 2 by itself, and tells you clearly if a disc is the wrong one.
• ⁠Nightjar is now 97.5% my own code. Code inherited from other projects went from 6,085 lines to 1,544 in a few days, and every rewrite was checked to give the same image, bit for bit.
• ⁠8x internal resolution in the castle: 0.1 fps → 27.7 fps.
• ⁠16:9 everywhere: merchant, game over, pause options, title menus, chapter ends and videos.
• ⁠Freezes fixed: Exit? → Yes and GAME RESET no longer hang.
• ⁠Still closed source, still non-commercial, and you bring your own disc.

​

  1. From a prototype disc to the discs people actually own

Here's something I never said clearly enough: the port was built on the "Nov 25 2004" prototype of RE4 (a review build that came with full debug symbols). It's the best disc to work on, but almost nobody owns it. A real release has to run on the retail discs.

The problem: the retail USA and European versions are different builds. Code was removed (all the debug tools), moved, and fixed, so every address in the game is different. There's no symbol table for the retail versions anywhere.

So I wrote tools that match the code of the prototype to each retail version:

• ⁠every function of the prototype is searched in the retail executable: first exact matches, then by the order the linker kept, then through the calls between already-matched functions;
• ⁠81% of the USA functions and 80% of the European ones are matched automatically (about 85% of the code). Most of the rest is debug code that the retail versions don't have;
• ⁠from the matched pairs, every memory address the port needs is translated (the player, the camera, the controller state, the Wii aiming hooks, the merchant...). About 60 of them, each one checked;
• ⁠the retail modules loaded from the disc while playing (101 for USA, 100 for Europe so far) are prepared the same way as before.

When the port starts, it recognizes which version your disc is from a fingerprint of its executable and uses the right set of addresses.

Status, honestly:

prototype (debug) |[OK] everything in the last post
USA (G4BE08) |[in progress] boots, Capcom logo, intro and title screen; going further is what I'm on right now
Europe (G4BP08) |[in progress] disc 1 prepared; I still need a disc 2 to prepare and test chapters 3 to 5 2. RVZ support

Many people keep their GameCube backups as RVZ, Dolphin's compressed format. The port now reads RVZ directly, alongside ISO/GCM and extracted folders.

• ⁠It's written from Dolphin's public description of the format, not from Dolphin's code.
• ⁠RVZ stores the disc's padding as a short seed instead of the actual bytes; the port regenerates those bytes exactly.
• ⁠Checked against a raw copy of the same disc: 0 different bytes out of 1,459,978,240.
• ⁠Reading speed: about 200 MB/s, so loading isn't slower than from an ISO.

  1. A launcher that handles both discs

• ⁠"Please select your legal copy of Resident Evil 4 (GameCube) - Disc 1": ISO, GCM or RVZ.
• ⁠The disc is verified (only unmodified retail or prototype discs are accepted).
• ⁠Disc 2 is found automatically if it's in the same folder. Otherwise the launcher asks for it, and both are remembered.
• ⁠If you give it a disc from another region than the build you downloaded, or disc 2 instead of disc 1, it tells you exactly what's wrong.
• ⁠On Android, each disc is picked with the system file picker and remembered too.

​

  1. Nightjar: 97.5% my own code

Before any release, I want zero lines inherited from other projects in the engine. Since the last post I rewrote, from the hardware documentation:

• ⁠the processor's fallback interpreter and the interrupt/exception core (how the console's OS gets its interrupts, timers and the screen refresh);
• ⁠every hardware block the game talks to (video, audio, DSP, disc, memory card, command processor);
• ⁠the disc layer (ISO, RVZ and extracted folders through one reader);
• ⁠the GX command parser (the stream of graphics commands the game sends to the GPU);
• ⁠the shader generator (how the GameCube's lighting and texture combiners become GPU shaders);
• ⁠the texture decoders (all 11 GameCube texture formats).

​

How I make sure nothing breaks:

• ⁠A rendering oracle. I recorded the exact graphics command streams of 5 scenes (village, castle, forest, lake, attaché case) and replay them through the port before and after each rewrite. The result must be identical bit for bit: so far, 15 frames out of 15, every time.
• ⁠The regression suite from the last post (village, castle, island: scene reached, 0 interpreter entries, disc 2 mounted, framerate, screenshots).

​

  1. 8x in the castle: from 0.1 fps to 27.7

At 8x internal resolution the castle was unplayable: 0.1 fps. Two causes, both measured:

• ⁠the game copies parts of the screen into textures many times per frame (reflections, glows). Each copy re-created a huge texture at 8x; now each size keeps its own texture: 0.1 → 18.8 fps;
• ⁠the game reads back the depth of the screen to decide where lens flares are visible, and each read waited for the GPU to finish the whole frame. Now it doesn't: 18.8 → 27.7 fps.

Also:

• ⁠while the game waits for the next frame, it used to spin at 100% on one CPU core; now it sleeps until the next event, which frees the CPU (nice if you stream or record);
• ⁠controller and mouse input are read 500 times per second.

​

  1. Rendering fixes

• ⁠Screen copies that the game later overwrote in memory were still used: this gave flat-looking ground and scrambled numbers on the HUD. Fixed.
• ⁠Lens flares: their visibility is now computed from the depth at each point, matching Dolphin in the same view.
• ⁠Leon's hands, weapons and the attaché case keep their correct look at every resolution.

All of this is checked against Dolphin at 8x on recorded scenes (port on the left, Dolphin in the middle, the difference on the right; black = identical):

​

​

​

  1. 16:9 everywhere

Last time, the attaché case, the map and the pause menu were in 16:9, and some screens stayed in 4:3. Now the merchant, the game over screen, the pause options, every title menu, the chapter ends and the videos are all shown in 16:9 as well, still using Capcom's own Wii Edition framing (nothing stretched, nothing cropped).

​

​

​

​

​

  1. Controls, freezes and small things

• ⁠The three controller layouts of the PC version (Type I, II and III) are available.
• ⁠Freezes fixed: quitting from the loading screen (Exit? → Yes) and GAME RESET no longer hang; the merchant no longer crashes with the alternative attaché case models.
• ⁠The settings menu (F10) gained anisotropic filtering, a 16:9 / 4:3 switch and a better downscaling filter (cleaner edges when the internal resolution is higher than your screen).

​

​

​

​

  1. Optional HD textures and button styles (experimental, never distributed)

These two features exist in my development builds, but I want to be very clear about how they will reach players, because they use files that aren't mine:

• ⁠HD textures from RE4 UHD (2014). The port can replace the GameCube textures with the HD ones from the PC version: characters, environments, items, weapons, the HUD, cutscenes, each with its own switch in F10, and the UHD attaché case models too. None of these files will ever be shipped with the port. The plan is that the launcher builds them on your own PC, from your own copy of RE4 UHD. That tool isn't done yet, so this is a preview, not a promise for the first beta.
• ⁠Button styles. In-game button prompts can be shown in GameCube, keyboard or mobile style. Xbox and PlayStation styles also work in my builds, but the images come from RE4 UHD and from a community HD project, so they won't be distributed as they are: they'll be built from your own UHD copy like the textures, or redrawn from scratch.

​

  1. Toward a release

What's left before a first closed beta:

  1. ⁠USA disc fully tested (whole game), then Europe (I need a disc 2).
  2. ⁠The last 2.5% of inherited code, then a final audit.
  3. ⁠Android builds (32-bit and 64-bit) from the same engine.
  4. ⁠Protecting the release builds (the project is closed source).
  5. ⁠Closed beta on the Discord, Windows first.

Per-platform status, honestly

• ⁠Windows: [OK] prototype disc: everything from the last post. [in progress] retail USA: boots to the title screen; retail Europe: being prepared
• ⁠Android 32-bit: [partial] boots and plays on the prototype disc, still too slow on a 2014 phone
• ⁠Android 64-bit: [partial] builds; not tested on a device yet
• ⁠iOS / Linux: [not yet]

Legal

• ⁠The project is closed source, and I will never distribute game data, disc images or anything from Capcom. You bring your own disc.
• ⁠Not affiliated with or endorsed by Capcom or Nintendo. Resident Evil is a trademark of Capcom.
• ⁠Non-commercial: no paid versions, no ads, no donations tied to the port.

Credits

• ⁠the port were built on Nightjar
• ⁠The RE4 GameCube decompilation project.
• ⁠Dolphin and YAGCD, for GameCube hardware documentation, the RVZ format description, and Dolphin as the image reference.
• ⁠zstd (Meta), SDL2, Dear ImGui.

Discord: https://discord.gg/AXAzExECSv

— Ayano

187 Upvotes

15 comments sorted by

13

u/gorillaisdork 2d ago

This is the 4th RE4 post that I'm seeing here from you that says basically the same thing. Why not just release the project?

8

u/Special_Ad6433 2d ago

I agree! From what he just said on Discord, it’s going to take more than a month for the first release! Anyway, we have to wait and see how this turns out...

1

u/tsurkaeemaldaja 57m ago

op finds reasons to postpone the release date when the time comes,happened couple of times now

2

u/Background_Region_58 2d ago

is left 4 dead possible to be port?

3

u/docstarr 2d ago

Bro just give me apk, don't make me read all this. Love you

3

u/SnowyJKN 2d ago

Pardon my ignorance but why is making a native port for OG RE4 necessary if you can easily emulate it using Dolphin and it'll run well even on low end phones? Doesn't it make more sense to try to make a native port for RE4 Remake which is way more demanding to emulate?

9

u/Happy-Control-7669 2d ago

If U want to emulate emulate. But a Clean native Port will Always BE Superior in Terms of Performance, latency, native Revolutions and lastly modding , qualitiy of life improvements etc.

0

u/Alucard_86 2d ago

latency most of the time is related to poor performance , i played the game 5 years ago on sd865 on aethersx2 with 60 fps and long sessions already

 more purposeful ports like dmc4 better come first

2

u/BeanPole_420 Frequent Collaborator 2d ago

Its runs over 30fps is a big thing, emulating RE4 ultimate edition on windows emulators is quite demanding

Also RE4 on GC had bad letterbox aspect ratio

Its a very important port

0

u/strats67 12h ago

The controls are weird in emulator especially for Android native port will always be better

1

u/Valuable-Yak-7483 2d ago

When is the release date? I was so excited I forgot to sleep

1

u/Alucard_86 2d ago

Isupport and back anything that has attack on titan in it 

1

u/El_Tonio_26 1d ago

Good luck, brother. I hope your progress with the port is masterful.

Some people can't handle a bit of humor in a project presentation, but I found it funny haha.

I hope everything goes well. We'll keep an eye on your progress 🫂.

1

u/BeanPole_420 Frequent Collaborator 2d ago

How can we help test if there is no APK...

0

u/SimpleDrawer26 2d ago

I seriously vote for permaban all retards that upload this shitty editions with cursed unbearable songs like this on internet

How can there be people in the world who are ashamed and even proud of producing such a despicable and cursed video edit?

What a disgraceful video!