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
 

ShadowOne333

QVID PRO QVO
Editorial Team
Joined
Jan 17, 2013
Messages
12,498
Trophies
2
XP
39,482
Country
Mexico
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.
Dude one of the features and perks of the N64 version over any of the others is just that... "First person" controls I think is what the option is called in-game.
The option is already there in all N64 releases, you can move the character with the control stick in any direction, without tank controls, similar to the new controls options from the RE1 Remake and RE0 Remastered versions.
 
  • Like
Reactions: raxadian

stanleyopar2000

It is morally correct to pirate Nintendo
Member
Joined
Jun 22, 2007
Messages
4,928
Trophies
2
Location
C-137
Website
www.youtube.com
XP
4,064
Country
United States
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.
Perfect dark has already been decompiled
 
  • Like
Reactions: raxadian

Kazuma77

Well-Known Member
Member
Joined
May 11, 2008
Messages
1,067
Trophies
1
XP
1,001
Country
United States
Dude one of the features and perks of the N64 version over any of the others is just that... "First person" controls I think is what the option is called in-game.
The option is already there in all N64 releases, you can move the character with the control stick in any direction, without tank controls, similar to the new controls options from the RE1 Remake and RE0 Remastered versions.
Ah, guess I just didn't mess with it long enough to discover that option. The PSX games had already soured my opinion of the series at that point, so I probably just ran it on my Z64 long enough to confirm that the release was valid. If it has direct movement like the remakes on PSN, OK, that could be interesting.
 

ShadowOne333

QVID PRO QVO
Editorial Team
Joined
Jan 17, 2013
Messages
12,498
Trophies
2
XP
39,482
Country
Mexico
Ah, guess I just didn't mess with it long enough to discover that option. The PSX games had already soured my opinion of the series at that point, so I probably just ran it on my Z64 long enough to confirm that the release was valid. If it has direct movement like the remakes on PSN, OK, that could be interesting.
Try it out, it sure is a breath of fresh air to have that as an option for RE2, makes knifing Lickers a breeze
 

Kazuma77

Well-Known Member
Member
Joined
May 11, 2008
Messages
1,067
Trophies
1
XP
1,001
Country
United States
Static linking means it's running natively in the host operating system.

It should be possible to eventually use an LLM trained on this tool to speed up the process of porting over all N64 games.
Just curious, how long does such training take? Because I know some of these things have decades or even centuries of training time. That seems like something that could take a lifetime without a large team working on it. Or would it not need that much time due to the relatively limited nature of this process?

I am relatively new to all this AI stuff. It's crossed my mind to ask a coding LLM to complete the Jaguar core for the MiSTer by disassembling BigPEmu (I'm sure if it was that easy, we'd have it already, I'm just curious to see how far it gets). I stopped short of doing that because I don't see one trained in FPGA languages in Ollama. Oh well, it was worth a look.
 

HandsomeJack

Well-Known Member
Member
Joined
Dec 24, 2021
Messages
237
Trophies
0
Age
51
XP
1,523
Country
United Kingdom
Just curious, how long does such training take? Because I know some of these things have decades or even centuries of training time. That seems like something that could take a lifetime without a large team working on it. Or would it not need that much time due to the relatively limited nature of this process?

I am relatively new to all this AI stuff. It's crossed my mind to ask a coding LLM to complete the Jaguar core for the MiSTer by disassembling BigPEmu (I'm sure if it was that easy, we'd have it already, I'm just curious to see how far it gets). I stopped short of doing that because I don't see one trained in FPGA languages in Ollama. Oh well, it was worth a look.
It's more that the AI will learn code optimisation each time a port is made to figure out what to do with the next port. It should learn code changes / build commands pretty quickly.
 

Keylogger

Well-Known Member
Member
Joined
May 3, 2006
Messages
2,675
Trophies
1
Age
35
Website
Visit site
XP
6,976
Country
France
I have a bug: i have closed the game without saving and the last save was an autosave into deku castle.
Now im back to clock town but i can’t use any item
all butons are grayed even the sword, masks, ocarina…
I think my save is fucked now
 
  • Wow
Reactions: cearp

_47iscool

Hacker
Member
Joined
Nov 18, 2013
Messages
787
Trophies
1
XP
1,363
Country
United States
Hopefully this will support D3D11/Windows 7 eventually. There really is not a reason these old games should only work on Windows 10 and later. Besides Linux, which is fine.
 

Azhrei

Active Member
Newcomer
Joined
Apr 14, 2008
Messages
33
Trophies
1
XP
116
Country
Amazing work. The thought of being able to play Conker's Bad Fur Day or Perfect Dark at a high, stable frame rate is a nice one indeed.

I've mucked around with it and it's impressive. Can cheats be used with it? I'll be honest, when playing old games on an emulator nowadays it's rare that I don't use an infinite lives cheat or something!
 

MariArch

Well-Known Member
Member
Joined
May 9, 2021
Messages
386
Trophies
0
Age
24
XP
1,938
Country
United States
Wait why hasn’t there been any pc ports for other decompiled games ie minish cap, paper Mario 64, yoshis island, Kirby, etc? Is it really that big of a commitment to make one? 🤔
 

cearp

瓜老外
Developer
Joined
May 26, 2008
Messages
8,804
Trophies
2
XP
8,871
Country
Tuvalu
Wait why hasn’t there been any pc ports for other decompiled games ie minish cap, paper Mario 64, yoshis island, Kirby, etc? Is it really that big of a commitment to make one? 🤔
Yes. It's not super simple to take the source for a game and port it to another platform.
There's tons of open source games that could be released to switch (for example) but it takes effort.

Wrapping or reimplementing all of the graphics functionality is a big part of that.

Working with a gba decomp and making it use SDL2 would be a good project for someone with some time :)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    SylverReZ @ SylverReZ: @Psionic Roshambo, Response was "No." +2