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
 

osaka35

Instructional Designer
Global Moderator
Joined
Nov 20, 2009
Messages
3,757
Trophies
2
Location
Silent Hill
XP
6,003
Country
United States
Are there similarly maintained projects for NES and SNES? Some quick Google searching doesn't turn up as much.

I'd love some (reasonably) ready made tools where I can throw my own ROMs at NES/SNES and the like and make some ready made executables for Windows and Linux for these old games.
the github mentions an NES one by name, which inspired this one. also mentions a different n64 one. dunno what else is out there, personally.
 

4d1xlaan

Well-Known Member
Newcomer
Joined
Apr 21, 2024
Messages
97
Trophies
0
XP
82
Country
United States
stealth release is good

announcing universal decompilation tool in advance to give time to Nintendo to send C&D though? why

Shouldn't as no original source code nor assets are being used for this, and if Nintendo gets clever enough it could be beneficial for them too.
sad eaglercraft noises
 

MikaDubbz

Well-Known Member
Member
Joined
Dec 12, 2017
Messages
3,878
Trophies
1
Age
36
XP
7,368
Country
United States
i read through the github, but I'm still not 100% on the extent and limits. I need to play around with this, and the apparent others floating around. maybe i can fix megaman 64...
Oh yeah, good idea. Are these decomps restricted by the size of how big N64 games could ever be? Or can we go beyond that size limit and give full HD audio soundtracks for games and stuff like that? My mind is reeling with possibilities. And of this stuff can be ported to hacked systems as other decomps have, then this could be huge for all sorts of homebrew scenes: Switch, Vita, Wii U, 3DS, even the freaking Dreamcast and I'm sure plenty more.
 

MikaDubbz

Well-Known Member
Member
Joined
Dec 12, 2017
Messages
3,878
Trophies
1
Age
36
XP
7,368
Country
United States
Why can't Nintendo just give us what we all want. A good Zelda remake like Cryzen made. Anyhow, this is so awesome thanks!
When it comes to the N64 Zelda games, I get the impression that they kinda want to wait a few more years because they did those 3DS remakes not so long ago. Otherwise, they do seem intent to get HD versions/remakes of most classic Zelda games (WW, TP, SS, LA). If I were to bet, I would say that next up are HD remakes of Oracle of Ages and Seasons using the Link's Awakening remake engine.
 

x65943

pronouns big/pingus
Supervisor
GBAtemp Patron
Joined
Jun 23, 2014
Messages
6,262
Trophies
3
Location
ΗΠΑ
XP
27,028
Country
United States
This is so beautiful, RT Majora's Mask is a dream come true

Really cool to see hidden gems like Superman 64 get the love they deserve with a decomp
 
  • Like
Reactions: Kioku

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,811
Trophies
2
Age
48
Location
Japan
XP
3,719
Country
United States
Oh yeah, good idea. Are these decomps restricted by the size of how big N64 games could ever be? Or can we go beyond that size limit and give full HD audio soundtracks for games and stuff like that? My mind is reeling with possibilities. And of this stuff can be ported to hacked systems as other decomps have, then this could be huge for all sorts of homebrew scenes: Switch, Vita, Wii U, 3DS, even the freaking Dreamcast and I'm sure plenty more.
As far as audio, you can already do that on real hardware with a flash cart that has an MSU-1 chip. Or on an emulator. I play Super Metroid randomizers (and even the untouched rom) all the time with full HD audio. Although the hardware option isn't cheap. The best SNES flash cart is like $225. But now that I think about it... I don't think that actually exists for N64. So in the end, it's possible to get way better audio from a SNES than from an N64! This is crazy... :wacko:
 

Ampersound

Well-Known Member
Member
Joined
Feb 4, 2018
Messages
284
Trophies
0
Age
37
XP
1,495
Country
Germany
So wait... We can just decompile any N64 ROM now all willy-nilly? Didn't the other N64 decomps take years?

I'd love to see Excitebike 64 recompiled in HD with a high framerates and maybe faster bikes. My biggest gripe was how slow the bikes are and the floaty gravity.
I think the distinction between those two things is,
that for manual reverse engineering of the source code, the devs can name and organize all the functions a game needs to run.
So that later someone could just go and tweak something in the MarioJump() function for example.

And this automatic recomp is more like a translation of all the low-level functions that would be run on an N64,
so without reverse engineering the code, games can run, but you can't modify the code since you have no idea what is what.
 
  • Like
Reactions: cearp

BlusterBong

Well-Known Member
Newcomer
Joined
Apr 22, 2019
Messages
57
Trophies
0
Age
30
XP
241
Country
United States
This would be very cool if it was for an obscure or lesser known console or platform like the Apple Pippin or Commodore Amiga, but alas, it's yet another Nintendo thing.... sigh
 

Marc_LFD

Well-Known Member
Member
Joined
Nov 3, 2021
Messages
5,719
Trophies
1
Age
34
XP
9,249
Country
United States
This is amazing I never liked the graphics of the N64 (except N64 exclusives), but this'll make me want to play them.
 

osaka35

Instructional Designer
Global Moderator
Joined
Nov 20, 2009
Messages
3,757
Trophies
2
Location
Silent Hill
XP
6,003
Country
United States
When it comes to the N64 Zelda games, I get the impression that they kinda want to wait a few more years because they did those 3DS remakes not so long ago. Otherwise, they do seem intent to get HD versions/remakes of most classic Zelda games (WW, TP, SS, LA). If I were to bet, I would say that next up are HD remakes of Oracle of Ages and Seasons using the Link's Awakening remake engine.
you'll be limited by hardware if you wanted it to play on original hardware. I suppose the benefit of using this sort of software over a romhack would be more control and flexibility over the final result.

a manual decompilation approach lets you label what does what in the code, and this more just converts stuff based on a template you provide (from my poor understanding). i wonder if you can comment and use plain english for stuff based on templates/metadata...either way, I'd imagine it can help speed decompilation up? I'm still iffy on the details. but decompilation projects are still the ultimate goal.

and as long as you're cool with it not being on original hardware, you'd only be limited by whatever your target device can handle. I don't actually have experience with things like that, so this tool will definitely help me learn. I'd imagine you'd be able to compile for new platforms with this if all done correctly and you knew what you were doing.

these are all the words of an inexperienced beginner, so take it with a grain of salt.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    BakerMan @ BakerMan: this one +1