Super Mario 64's source code has been decompiled and officially released

supermario64.png

After having been decompiled back in July, the source code for Super Mario 64 has been completely reverse-engineered, and is now publicly available. Available on GitHub is a full decompilation of the beloved 3D platformer, Super Mario 64. The decompilation works for the NTSC-U and NTSC-J builds of the game, with (E) ROM support coming soon. To keep things legal, you will need to provide your own copy of the game, in order to compile the data, with the exact process being detailed, below. If you've ever wanted to see some of the magic that went into creating such an iconic game, you can now finally see into all of the finer details.

Linux
  1. For each version (jp/us/eu) that you want to build a ROM for, put an existing ROM at ./baserom.<version>.z64 for asset extraction.

  2. Install the following packages:
Debian / Ubuntu

  • git
  • binutils-mips-linux-gnu / mips64-elf (>= 2.27)
  • python3 (>= 3.7)
  • build-essential
  • pkg-config
  • zlib1g-dev
  • libaudiofile-dev
Arch Linux

  1. Install qemu-irix
3.a Options: 1. Clone https://github.com/n64decomp/qemu-irix to somewhere and follow its install instructions in the README. 2. Optionally, grab the prebuilt qemu-irix from the Releases section. 3. (Arch) Use AUR package qemu-irix-git

3.b (For options 1 or 2), copy executable qemu-irix from irix-linux-user to somewhere convenient with a relatively short path.

mkdir -p /opt/qemu-irix/bin
cp irix-linux-user/qemu-irix /opt/qemu-irix/bin

3.c Define QEMU_IRIX environment variable in your ~/.bashrc to point to this qemu-irix executable.

export QEMU_IRIX=/opt/qemu-irix/bin/qemu-irix

  1. Run make to build the ROM (defaults to us version). Make sure your path to the repo is not too long or else this process will error, as the emulated IDO compiler cannot handle paths longer than 255 characters. Build examples:
make VERSION=jp -j4 # build (J) version instead with 4 jobs
make VERSION=eu COMPARE=0 # non-matching EU version still WIP

Windows
For Windows, install WSL and a distro of your choice and follow the Linux guide.

:arrow: Source
 

x65943

i can be your sega dreamcast or sega nightmarecast
Supervisor
GBAtemp Patron
Joined
Jun 23, 2014
Messages
6,230
Trophies
3
Location
ΗΠΑ
XP
26,427
Country
United States
The game was released incomplete and buggy as hell to compete with Crash Bandicot. The DS port is actually better and you can actually beat it without using the touchscreen on the levels.

In fact while is nicer to play the game on a big screen, I beat the DS game three times from zero, while the Nintendo 64 version was just played until I beat Bowser and I didn't even care to get all the Stars.
Incomplete and buggy?

I played this game nonstop as a kid on the N64 and never experienced any game breaking or even significant bugs

Honestly this game was way more polished than most modern games
 

emmanu888

6 years and still going strong
Member
Joined
Jan 25, 2009
Messages
1,486
Trophies
1
Age
29
Location
Victoriaville,Québec
XP
2,288
Country
Canada
First of all, that means the game can be ported to another system right?

But most important of all, does this means that future romhacks could be compatible with original hardware now that the decompiled code is out in the wild?
 

diggeloid

Alex
Member
Joined
Apr 29, 2019
Messages
469
Trophies
0
Age
34
Location
gbatemp.net
XP
2,395
Country
United States
It's worth mentioning that this is decompiled source code, it's missing all of the original commentary and it's "written" as a machine would understand it, not necessarily as a programmer would code it. This can make even simple functions quite difficult to wrap your head around, so it will take an experienced group of coders to make any significant use of this. What this does for average users is shedding a better light on the internal workings of the game, which is interesting in and out of itself. Very good, and an almost impossible task to achieve given the complexity of the average video game binary.

I thought the point of this release was that they went through and actually added sensical names variables and functions, so you can actually work with it. I remember seeing this leaked a few weeks (months?) back in an "incomplete" state, which had some source files that were clearly straight out of a decompiler with meaningless names.
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,840
Country
Poland
I thought the point of this release was that they went through and actually added sensical names variables and functions, so you can actually work with it. I remember seeing this leaked a few weeks (months?) back in an "incomplete" state, which had some source files that were clearly straight out of a decompiler with meaningless names.
Oh, by all means, it's more understandable than pure machine code - you can actually look at it and they did add useful commentary. My point was that this isn't a reflection of how the original source files looked like when they were originally made, it's a faithful recreation based on the decompiled binaries that results in an accurate binary when compiled. You still need to be well-versed in the N64's way of doing things before you can work with it though. It's actually really impressive judging by what's hosted on the Github. You can't really "get" the original files out of a decompiler, but you can rearrange and rename things to make them more understandable for someone with experience, which is what this is.
 
  • Like
Reactions: CrashOveride

CrashOveride

Well-Known Member
Newcomer
Joined
May 29, 2017
Messages
50
Trophies
0
XP
127
Country
United States
Does this mean someone will port this to the switch and I won't have to use any emulator to run it?

The matter is someone MAY do it. The codebase relies heavily on libultra and is designed for the N64 and nothing else.
First of all, that means the game can be ported to another system right?

But most important of all, does this means that future romhacks could be compatible with original hardware now that the decompiled code is out in the wild?

Many romhacks(recent ones anyway) are console compatible, and Kaze recently got star road to run on console at 20-30 fps.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
I mentioned in other threads I did a little compare and contrast with some of the bigger and juicier files between the leaked version and this. Not a night and day difference (in the leaked code discussion thread some were claiming far nicer function names, comments everywhere and whatnot but not really) and some odd choices for changes as far as formatting (nothing dealbreaking, just odd) but probably best you move to this if you are doing anything.

Would this help with porting rom hacks like last impact to underpowered consoles like psp?
In theory it could.

In practice unless and until it gets remade into a form that works with more modern consoles probably not.

There is the halfway house of being able to alter the code to make it more amenable to emulation (especially dynamic recompilation like a lot of "faster" N64 emulators opt for) but I have never really seen that done before (however the N64 would be a reasonable candidate for it). Afraid it has been too long since I looked at N64 emulation so I don't know what percentage of the time this game spends running as dynarec rather than more traditional emulation. Source code is rare for ROM hackers, source code available for proper use even more so, but even then I would normally only expect to really see such mods done to things to make either widescreen hacks work better, dodge anti piracy, dodge resolution issues (could also apply to those games that change resolution and break signal adapter boxes), work around control limitations (got fewer buttons, sticks, touchscreens in the way... no worries any more where normally control hacking is tedious) and do similar such "small" but still quite tedious to do as a ROM hacker things.
 
  • Like
Reactions: Ryccardo

CrashOveride

Well-Known Member
Newcomer
Joined
May 29, 2017
Messages
50
Trophies
0
XP
127
Country
United States
I mentioned in other threads I did a little compare and contrast with some of the bigger and juicier files between the leaked version and this. Not a night and day difference (in the leaked code discussion thread some were claiming far nicer function names, comments everywhere and whatnot but not really) and some odd choices for changes as far as formatting (nothing dealbreaking, just odd) but probably best you move to this if you are doing anything.

Personally, I waited until the team released it themselves because I considered it morally repugnant to use the leak. If there wasn't a difference between leak and release I'd still use release. Especially after the annoying drama that unfolded in the last thread.
 

Ericthegreat

Not New Member
Member
Joined
Nov 8, 2008
Messages
3,455
Trophies
2
Location
Vana'diel
XP
4,279
Country
United States
Again from what I've read, this seems to not be a 100% reproduction of Nintendo's code, some spots it seems had to be filled in, and though I'm sure it works, it doesn't mean your seeing exactly how the Nintendo devs did it, which I think for many is the coolest part about this.

Please correct me if I'm wrong.
 
Last edited by Ericthegreat,
  • Like
Reactions: CrashOveride

CrashOveride

Well-Known Member
Newcomer
Joined
May 29, 2017
Messages
50
Trophies
0
XP
127
Country
United States
A 100% reproduction would be impossible tbh, this is the best we're gonna get unless Ninty releases the sources for their N64 output

(rare pls release n64 sauce codes)
 
  • Like
Reactions: Ericthegreat

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Veho @ Veho: The cybertruck is a death trap.