New static recompiler tool N64Recomp aims to seamlessly modernize N64 games

zelda.png

As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The onward marching of time and evolution of technology also means that video games that were once landmark titles in their day, are now thought of as clunky, awkward, or just not viable by today's standards.

These reasons are why so many individuals have dedicated years of their lives to reverse engineering beloved video games, combining their efforts to create decompilations that allow for classic games to be experienced in new ways, on new technology, with new features and improvements that were never possible on original hardware or through emulation. These decompilation projects take massive amounts of effort, however; for example, one such undertaking for The Legend of Zelda: Majora's Mask, has been worked on since early 2021, and after years of steady, painstaking progress, is still not yet ready for release.

A new piece of software might be a big game-changer in that department, though. A modder by the name of Mr-Wiseguy quietly released two projects--one of which is titled Zelda 64: Recompiled, which can play The Legend of Zelda: Majora's Mask with numerous modern-day features, including support for autosaves, ultrawide resolutions, high framerates, gyro aiming, custom textures, and more. All of this can be utilized by downloading his release of Zelda 64: Recompiled, and providing your own legal cart dump of Majora's Mask.



According to Mr-Wiseguy, the project was made using a tool he created: N64 Recomp. It is a static recompiler for Nintendo 64 games that can turn N64 binaries into C code, and then be compiled into a platform of your choosing. By using N64 Recomp, the modder was able to create "recompilations" of Nintendo 64 games that lack decompilations, such as Rocket Robot on Wheels, Banjo-Kazooie, and Superman 64.

A highly-detailed breakdown of the process is explained below.

The recompiler works by accepting a list of symbols and metadata alongside the binary with the goal of splitting the input binary into functions that are each individually recompiled into a C function, named according to the metadata.

Instructions are processed one-by-one and corresponding C code is emitted as each one gets processed. This translation is very literal in order to keep complexity low. For example, the instruction addiu $r4, $r4, 0x20, which adds 0x20 to the 32-bit value in the low bytes of register $r4 and stores the sign extended 64-bit result in $r4, gets recompiled into ctx->r4 = ADD32(ctx->r4, 0X20); The jal (jump-and-link) instruction is recompiled directly into a function call, and j or b instructions (unconditional jumps and branches) that can be identified as tail-call optimizations are also recompiled into function calls as well. Branch delay slots are handled by duplicating instructions as necessary. There are other specific behaviors for certain instructions, such as the recompiler attempting to turn a jr instruction into a switch-case statement if it can tell that it's being used with a jump table. The recompiler has mostly been tested on binaries built with old MIPS compilers (e.g. mips gcc 2.7.2 and IDO) as well as modern clang targeting mips. Modern mips gcc may trip up the recompiler due to certain optimizations it can do, but those cases can probably be avoided by setting specific compilation flags.

Every output function created by the recompiler is currently emitted into its own file. An option may be provided in the future to group functions together into output files, which should help improve build times of the recompiler output by reducing file I/O in the build process.

Recompiler output can be compiled with any C compiler (tested with msvc, gcc and clang). The output is expected to be used with a runtime that can provide the necessary functionality and macro implementations to run it. An example of most of the required macro implementations can be found in the Zelda 64: Recompiled project here, with the project also containing accompanying code for implementing the rest of the required runtime.

Additionally, a collaborative video between Mr-Wiseguy and YouTuber Narrel was released, which goes into further technical explanation on how the tool works, and what it can be capable of. It also showcases demos of recompiled games running.



Zelda 64: Recompiled currently supports The Legend of Zelda: Majora's Mask, with plans to support Ocarina of Time soon. A release on GitHub is linked below. N64 Recomp is not publically available yet, though you can browse the GitHub page for the project below as well, so that you can keep up to date on any new updates as they happen.

:arrow: Source: Zelda 64 Recompiled GitHub
:arrow: Source: N64Recomp GitHub
 

floxi

Member
Newcomer
Joined
Mar 2, 2022
Messages
9
Trophies
0
Location
Salzburg
XP
90
Country
Austria
It would be good to get the original running natively on PC.
The source code for Quake II was released more than 20 years ago. ;) Yamagi Quake is the version you want if you're aiming for a vanilla experience. https://quake.fandom.com/wiki/List_of_Quake_II_Source_ports
If you have an RT-capable GPU, I suggest giving Quake II RTX a try https://www.pcgamingwiki.com/wiki/Quake_II_RTX (>60 fps in 1080p on a 4060 and in 1440p on a 4070 to give you an idea of how much RT power you need)
 
  • Like
Reactions: BuddhaHunterMac

TheStonedModder

Well-Known Member
Member
Joined
Dec 25, 2022
Messages
887
Trophies
0
Age
27
XP
1,739
Country
United States

As each year passes, retro games become harder and harder to play, as the physical media begins to fall apart and becomes more difficult and expensive to obtain. The onward marching of time and evolution of technology also means that video games that were once landmark titles in their day, are now thought of as clunky, awkward, or just not viable by today's standards.

These reasons are why so many individuals have dedicated years of their lives to reverse engineering beloved video games, combining their efforts to create decompilations that allow for classic games to be experienced in new ways, on new technology, with new features and improvements that were never possible on original hardware or through emulation. These decompilation projects take massive amounts of effort, however; for example, one such undertaking for The Legend of Zelda: Majora's Mask, has been worked on since early 2021, and after years of steady, painstaking progress, is still not yet ready for release.

A new piece of software might be a big game-changer in that department, though. A modder by the name of Mr-Wiseguy quietly released two projects--one of which is titled Zelda 64: Recompiled, which can play The Legend of Zelda: Majora's Mask with numerous modern-day features, including support for autosaves, ultrawide resolutions, high framerates, gyro aiming, custom textures, and more. All of this can be utilized by downloading his release of Zelda 64: Recompiled, and providing your own legal cart dump of Majora's Mask.



According to Mr-Wiseguy, the project was made using a tool he created: N64 Recomp. It is a static recompiler for Nintendo 64 games that can turn N64 binaries into C code, and then be compiled into a platform of your choosing. By using N64 Recomp, the modder was able to create "recompilations" of Nintendo 64 games that lack decompilations, such as Rocket Robot on Wheels, Banjo-Kazooie, and Superman 64.

A highly-detailed breakdown of the process is explained below.



Additionally, a collaborative video between Mr-Wiseguy and YouTuber Narrel was released, which goes into further technical explanation on how the tool works, and what it can be capable of. It also showcases demos of recompiled games running.



Zelda 64: Recompiled currently supports The Legend of Zelda: Majora's Mask, with plans to support Ocarina of Time soon. A release on GitHub is linked below. N64 Recomp is not publically available yet, though you can browse the GitHub page for the project below as well, so that you can keep up to date on any new updates as they happen.

:arrow: Source: Zelda 64 Recompiled GitHub
:arrow: Source: N64Recomp GitHub

I cant wait to see someone do this with conkers bad fur day
 

HandsomeJack

Well-Known Member
Member
Joined
Dec 24, 2021
Messages
227
Trophies
0
Age
51
XP
1,334
Country
United Kingdom
  • Angry
Reactions: poughstings

Robert Newbie

Well-Known Member
Member
Joined
May 10, 2014
Messages
214
Trophies
1
Age
44
XP
446
Country
United States
I'm not sure which games would be compatible, but I can't stop thinking about Goldeneye 007 with these features. Harvest Moon 64 would be really nice because I heard it doesn't emulate correctly, and I have no idea if the situation's changed in the last few years or so.

@ShadowOne333 had the great suggestion of Resident Evil 2, which was a truly impressive port. Seriously, N64 RE2 used the expansion pak and everything.
 
  • Love
Reactions: ShadowOne333

HandsomeJack

Well-Known Member
Member
Joined
Dec 24, 2021
Messages
227
Trophies
0
Age
51
XP
1,334
Country
United Kingdom
I know that, but you said: "The remastered PC version has annoying-as-fuck gameplay differences. It would be good to get the original running natively on PC."
Yes. The remastered PC version has enemy behaviour differences. The N64 version of Quake 2 was built on the N64 engine for Quake 1. Essentially, it's different Quake 2 levels with Quake 1 gameplay.
 

Kazuma77

Well-Known Member
Member
Joined
May 11, 2008
Messages
1,066
Trophies
1
XP
987
Country
United States
Nice. No more waiting for Ship to add MM (assuming it has a randomizer anyway -- as far as I'm concerned, the 3DS version in Citra on some nice XR glasses is the best way to play the N64 Zelda series, but Ship's randomizer was a game changer, literally, now if I could find one for SotN).

It will be interesting to see where this thing goes. I'm going to throw a bit of a hidden gem out there and suggest Beetle Adventure Racing. Sure, maybe it's no NFS, but it was fun finding all the hidden alternate routes.

I'll second Conker. I was livid when M$ promised an uncensored version, then censored it more instead.

As far as any FPS goes though, I suggest waiting until you add VR support. Dr. Beef has ruined flat screen FPS for me. At the very least add PS4/PS5 gyro aiming first (it's the only way I can play Doom and Quake on a flat screen now, the Xbox versions drive me nuts because their controllers don't have that feature).

I think Xbox did a good job with the Goldeneye port overall. However, I would love to see it with gyro and VR support, assuming this can support the DS5 and SteamVR or any of the various Flat2VR tools.

Please don't do RE2 unless you add direct movement. Maybe I could get used to tank/RC car controls if more games used them, but they don't. If I try to mix things up and play it alongside any other game, the clashing control schemes screw with me royally. I just can't get used to it. And I'm someone that generally enjoys mixing things up. I leveled a Rogue and Hunter in WoW simultaneously. But trying to make a tank control game click amidst a sea of direct movement titles (the Zeldas, Mario 64, Shadows of the Empire, Castlevania 64, DK64, Banjo, Conker, etc.) was just a bridge too far for me. It's like my brain sees RE2 as a test. If I play anything else for just 15 minutes, it thinks said test is over and dumps all that crap it will never need again. Every time I try to go back to RE2, it's like starting over.
 
Last edited by Kazuma77,

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,379
Trophies
4
Location
Space
XP
14,000
Country
Norway
This is big news.

I wonder how the result differs from what could be produced with Ghidra's decompiler alone. Ghidra is quite capable of producing C code already, which should be able to compile with little or no modifications. Is this simply porting the decompiled code Ghidra generates to run on PC, or is there more that goes into it to improve on the decompilation job already Ghidra does?

I might have to have a to go myself. Curious how easy it is to get a game running natively using this, and what goes into adding features and QoL improvements such as widescreen and 60 FPS. Since on the original ROMs, something as simple sounding as a 60 FPS patch can be difficult to the point many games don't have a usable 60 FPS patch to this day. Example, many things run too fast in both Zelda OoT and Banjo Kazooie with a 60 FPS patch, and in Banjo especially, since it makes enemy AI run twice as fast (making the game unfairly hard) as well as making parts unbeatable with it enabled (because timers are also sped up)

I can't read obfuscated code very well, so that is going to be the primary roadblock. Obviously, this tool can't deobfuscate, deobfuscation is almost always a manual job.
 

DaniPoo

Well-Known Member
Member
Joined
Jan 2, 2013
Messages
926
Trophies
1
Age
35
XP
2,303
Country
Wonder if N64 Recomp could be used to make Vita ports?

My guess is that this tool is designed for x86/64 architectures.
But in theory I believe the general method should be applicable on all architectures.

If this is the case then sure it could be used to make vita ports, but if it took about 2 years or whatever to make this for x86/64 then I wouldn't expect a Vita tool any time soon. However an ARM based version supporting MacOS and Android would be very welcome. Such a project could then probably be forked into Vita, Switch, 3DS or other versions (if someone is willing to work on it)

However I have not researched the topic of static recompilation in great detail so I might be incorrect about this.
 

shano

Well-Known Member
Member
Joined
Aug 27, 2012
Messages
224
Trophies
1
XP
1,877
Country
Australia
Mario Kart 64, Goldeneye 007, WWF No Mercy, Diddy Kong Racing, Wave Race 64, Perfect Dark, Paper Mario, Conkers Bad Fur Day, Star Fox 64, Snowboard Kids, Banjo-Kazooie

Mario Kart 64 at high framerates would be mindblowing. :)

Looking forward to seeing how this all develops in the future. Great stuff. Majora's Mask looks crispy as.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: https://www.youtube.com/watch?v=a9w_UTPpHjg