Super Mario 64 has been decompiled

caff!!!

Member
Oct 29, 2017
1,382
Does this mean that rom hacks won't have top trash tier music now ?
It can allow the sound driver to be replaced, so now you get smash mouth in clear 8 bits
Another couple of noob questions, why has it taken 23 years? What’s the actual importance of this?
Turning complied code into a source code that compiles exactly the same takes effort and time, even if you got a roadmap for how it works like with SM64 or Diablo. As to why it will be important, it more or less means that super mario 64 can be 1:1 recreated on any platform with extra goodies on top (open transport tycoon deluxe is the best example of this kind of work,) allow for way cleaner edited versions to play on N64, and as a reference for tool assisted runs or programmers who want to see how all the pieces work.
 

Jiminy

Avenger
Mar 29, 2018
2,205
Another couple of noob questions, why has it taken 23 years? What’s the actual importance of this?
To add to what caff said - to put it in more layman terms, the game you get on a disc/download is like a very "mixed down" version of the game's actual files/content.

Imagine when you hear a music track on the radio - you just hear a WAV or an MP3 right? It's just a sound file. A flat waverform. Some 1s and 0s.

But on the producer's computer are all the "stems" - each individual sound file for each instrument/layer of the song at very, very high resolution. These are all "flattened" into one sound for the final output. In addition, more importantly, there will be an intelligent "project" file for whatever production software they use, which grabs all those "stems" and puts them in at the right places, with the right programming logic, with the right effects and compressors, etc, etc - and they can hit the Export button to "compile" all the sounds and logic into one flat audio file.

A game file is pretty much the same. On a disc/download, you've got the very purest "output" of the game's content. Just the engine logic required to run, just the assets required to show, just the script/logic files required to make it happen - all mixed down into a few assets and a flat "executable" for the game's running.

But on the developer's computer? A mass of other files - the full game engine, many versions and iterations of assets, ten times more script files used to pull everything together.

So the fact they've managed to retro-engineer a "decompile" of SM64 basically means they, for the first time ever, have managed to get SOME version of what was on the developer's computer at the time of final compile. They can pull apart all the parts and scripts and really look at them straight-on, without any obfuscation. Basically they've opened the black box that is the game's software. This will let them dig into stuff better - and more importantly (yet more dangerously) they can recompile/reconfigure the game basically however they want. This will include making .exe files which will run immediately on any machine with any hardware, the ability to tweak/adjust any systems and assets, etc, etc.

For Nintendo - pretty terrifying.
 
Last edited:

Blackpuppy

Member
Oct 28, 2017
1,466
Native 60 fps Mario64 with fixed camera code...here we goooooo !

Oh man, I want a 3ds port as well. Imagine this game in freakin’ 3d!
 

God_Of_Phwoar

Member
May 29, 2018
2,043
Near London UK
In terms of how code is compiled into binary form to run on the target machine there are different levels of coding. With just straight writing things in hexadecimal being the lowest, assembly code being even lower and c code also considered low level programming these days but considered higher levels programming in the past.

Through the use of a disassembler (something like IDA) you can read the assembly code of an executable. Knowing both how the machine code works, and starting to piece together different states and global variables as you go along through different subroutines, you can implement c functions for the various subroutines and then the overall program, a very time consuming effort, in this case it was even more time consuming because the guys involved were trying to get a 1:1 match on the code, by recompiling their c code and seeing if it matched. That is if this is the same project I'm thinking of by the guys from the pret discord, I thought their project was private but I'm guessing someone leaked it.
Thanks for this... It nearly makes sense to me. I think. So, it's like someone has gradually decoded the code and made it into a "finer powder"? As if they have gradually got more and more granular with how they turn it into a kind of code thats easier to fuck around with?
 

anexanhume

Member
Oct 25, 2017
4,249
I'd guess that the actual act of retro-engineering how a game works isn't illegal at all

But distributing it or sharing it or making ROMs with it probably, almost definitely is
Profiting, for sure. But I have trouble seeing a legal challenge to a reverse-engineered product not used to drive profit, and I highly doubt it infringes any patents.
 

Blackpuppy

Member
Oct 28, 2017
1,466
Thanks for this... It nearly makes sense to me. I think. So, it's like someone has gradually decoded the code and made it into a "finer powder"? As if they have gradually got more and more granular with how they turn it into a kind of code thats easier to fuck around with?
Yeah basically. They were able to transform this:



To this:



That top photo is machine code. It’s just hexadecimal and cpu instructions. It’s difficult to read and decipher and the code can only work on the machine it was compiled to.

The next photo is C code. You can see that it’s written in a way that much easier to read and make changes to. You can take this code, make tweaks and compile it to Mac, PC, Wii, PS4 etc etc

(Ps: not actual sm64 code!)
 

Jayveer

Member
Oct 25, 2017
283
Thanks for this... It nearly makes sense to me. I think. So, it's like someone has gradually decoded the code and made it into a "finer powder"? As if they have gradually got more and more granular with how they turn it into a kind of code thats easier to fuck around with?
Yep exactly, now that it's in the state of the code that was programmed at the highest level to the N64. Due to that functionality of how the game runs can be changed, the N64 specific graphics redenerer can be changed to one for running on pc, same with input etc
 

Mirk

Member
Oct 25, 2017
326
Going to be crazy seeing this game with Odyssey assets fixed camera controls and added content.
 

Jroc

Member
Jun 9, 2018
792
I remember seeing this on /VR/ a few weeks ago. I hope that the leak doesn't impact the team or the eventual finished release. I'm also 99% sure that Kaze and the other SM64 gods are involved. I mean after a certain point it's pretty obvious that the crazy ROM hacks and experiments were using something a little more advanced than hex edits and assembly fiddling.

I wonder if this can be used as a launching point for an Ocarina of Time decompilation since they use the same engine. Part of what made this project possible was that Nintendo didn't use many (any?) of the optimization flags on their MIPS compiler so everything was straight forward.
 
OP
OP
signal

signal

Member
Oct 28, 2017
17,122
I remember seeing this on /VR/ a few weeks ago. I hope that the leak doesn't impact the team or the eventual finished release. I'm also 99% sure that Kaze and the other SM64 gods are involved. I mean after a certain point it's pretty obvious that the crazy ROM hacks and experiments were using something a little more advanced than hex edits and assembly fiddling.

I wonder if this can be used as a launching point for an Ocarina of Time decompilation since they use the same engine. Part of what made this project possible was that Nintendo didn't use many (any?) of the optimization flags on their MIPS compiler so everything was straight forward.
What are some examples of said crazy rom hacks?
 

ninjabreadman

Member
Dec 17, 2017
199
Cool stuff, but I would want to see the real code with the comments in it.

The lead dev quit the industry after the game went gold due to the stress of it, his code comments are probably amazing.

"Miyamotosan said he wants the baby penguin to be throwable off the cliff"

"@todo add Luigi select in here"
 

Stopdoor

Member
Oct 25, 2017
1,878
Profiting, for sure. But I have trouble seeing a legal challenge to a reverse-engineered product not used to drive profit, and I highly doubt it infringes any patents.
I'm not sure it's legal to just do anything unless you profit from it. Like, once people start making full on "Super Mario 64 with a brand new lighting engine and remastered music", Nintendo's straight up in a position of being usurped in products they could be making. Someone releasing it for free doesn't make that "ok", and obviously Nintendo will have the least lax viewpoint on this.

Like, emulation patches and stuff sort of work because it's all new code, added on top of a ROM that can't be distributed but you're assuming other people have - for modifications to work on this decompiled code, people will have to hand out the original source code, owned by Nintendo, with modifications. At least, that's what it seems like to me. I'm not sure how it would be possible to pretend there's a grey area distributing anything to do with this.
 
Oct 25, 2017
1,643
New York City
This is actually very impressive work. The video game community does crazy things.

As an aside, I wish that people did stuff like this with the "best" version of the game. For example, the Japanese only Mario 64 Shindou Edition with the rumble pak support added would have been better.

I'm guessing that this isn't all that legal...

But it's certainly amazing.
I doubt it's legal to share, but there are definitely several game disassembles hosted on GitHub that haven't ever been taken down, like Super Mario 1, Metroid, and several Game Boy Pokemon games like Crystal. Though to be fair, in some of those cases, the graphics are not included (like with the NES games).

I guess they think of it no worse than sharing video game music or something, since you're not getting the actual game?
 

Shugga

Member
Oct 25, 2017
16,272
No, just the next graphical big step, hence why everybody is speaking about it. It makes everything looks much, much better, even older games or games like Minecraft. It can bring new appeal for older games.

https://www.youtube.com/watch?v=sFhc951RhfI

It would look wonder in SM64.
It's just hilarious seeing everybody ask for it when it's probably not that easy to implement and generally tanks performance (probably not a problem with SM64, but still)
Everybody drinking the nvidia kool aid
 

LakLak

Member
Jul 4, 2019
98
Profiting, for sure. But I have trouble seeing a legal challenge to a reverse-engineered product not used to drive profit, and I highly doubt it infringes any patents.
I work in reverse-engineering, not in video-game, but still. It depends on case-by-case basis, most companies are quite lax about 20 years old software and I know some companies would be glad/proud people are that interested in their work. Nintendo is very dumb when it comes to that sort of stuff though, so nobody really knows how they could react. They could claim - legally - that reverse engineering SM64 make people less interested in a potential remaster or re-release or some dumb shit like that.

It's just hilarious seeing everybody ask for it when it's probably not that easy to implement and generally tanks performance (probably not a problem with SM64, but still)
Everybody drinking the nvidia kool aid
Ray-tracing is just a computer tech based on the Fermat principle and it's not realted to Nvidia.

It's like the difference between G-sync and alternative-sync. Alternative-Sync is the name of the technology, G-sync is what Nvidia's own version of Alternative-Sync is called. RTX is what Nvidia call their Ray-tracing tech.

You have some free and open-source Ray-tracing rendering system that you can implement to every game engines quite easily. https://en.wikipedia.org/wiki/LuxRender is one of them and probably one of the best.

It's not just Nvidia's marketing, it's the next step and something dev I've been waiting to implement for years.
 
Last edited:

Jroc

Member
Jun 9, 2018
792
What are some examples of said crazy rom hacks?
Stuff like this:



 
OP
OP
signal

signal

Member
Oct 28, 2017
17,122
Stuff like this:



Cool, thanks.
 

Lylo

Member
Oct 25, 2017
851
This is actually pretty cool! Does something like this helps other Nintendo N64 games to be decompiled as well or it has to be done from scratch for each game? I heard Nintendo used a modified version of the same engine for a lot of their games, would love to see something like this for Ocarina of Time.
 

collige

Member
Oct 31, 2017
4,638
It's just hilarious seeing everybody ask for it when it's probably not that easy to implement and generally tanks performance (probably not a problem with SM64, but still)
Everybody drinking the nvidia kool aid
One of the advantages of ray tracing is that it's extremely easy to implement compared to all of the lighting hacks that modern video games use. When I was in college, every student had to write a ray tracer from scratch over the course of the semester for the graphics course.
 
Nov 13, 2017
4,451
Stuff like this:



I cannot believe what I'm seeing right now. This is amazing work.
 

gebler

Member
Oct 27, 2017
372
So the fact they've managed to retro-engineer a "decompile" of SM64 basically means they, for the first time ever, have managed to get SOME version of what was on the developer's computer at the time of final compile.
To elaborate on the "SOME" above, decompiled code is quite different from the original source code. Not only are the comments lost, but typically also all or most of the symbols (meaningful names used to refer to things internally in the code). So whereas the source code might have a variable called "numberOfLivesLeft" and a function called "resetLevel", those could appear as variable753 and function138 in the decompiled code. This is obviously much more difficult to understand, since you would have to understand what variable753 means from context ("hmm, it seems to be modified by function957 and function127, but what are those?") People working on decompiling a program could try to understand things like that and change placeholder names into meaningful names. And of course they could add their own comments as well. But that's really an added bonus, outside of the defining property of a decompiled program (which is that you can make changes to it in some high-level language, feed it to a compiler, and get something that runs.) In this case, I read that they have actually (re-)named 65% of the symbols appearing in the decompiled code, which is quite a lot.
 
Last edited:

mattp

Member
Oct 25, 2017
724
NJ
ok now it's time for someone to translate all the n64 api calls and get this running on vulcan with ray tracing
 

Pop-O-Matic

Avenger
Oct 25, 2017
3,679
Sony and Microsoft have mentioned ray-tracing by the way, and what cards are in those machines?
AMD, but really it doesn't matter. "Ray-tracing" is just a box they have to check-off now because of Nvidia's marketing bullshit. Most major games on PS5/Xbox Scarlet won't utilize it because they most likely won't be powerful enough to handle it at anything other than slideshow levels. It'll only be used for gimmicky ports of old games (like that version of Quake 2) and the occasional indie title.
 
Oct 27, 2017
1,585
Florida.
AMD, but really it doesn't matter. "Ray-tracing" is just a box they have to check-off now because of Nvidia's marketing bullshit. Most major games on PS5/Xbox Scarlet won't utilize it because they most likely won't be powerful enough to handle it at anything other than slideshow levels. It'll only be used for gimmicky ports of old games (like that version of Quake 2) and the occasional indie title.
Maybe it's early for consoles but you realize that they have to start implementing it at some point right? It's the future of realtime graphics and it's not going to happen overnight.
 

Maya Fey

The Fallen
Oct 25, 2017
448
I was able to compile this and mess with things like jump heights, and the enemy behavior, and then get a working final ROM working on a real console, so this is legit. Seems clearly unfinished though so I wish they were able to finish their project since it seems like a leak.
 

Big One

Member
Oct 25, 2017
3,297
The Mario fan gaming community is gonna be nuts in the coming years with this. You can do so much more with this than a simple romhack. Afterall Ocarina of Time was built on the same engine as Mario 64 was.
 

Jiminy

Avenger
Mar 29, 2018
2,205
The Mario fan gaming community is gonna be nuts in the coming years with this. You can do so much more with this than a simple romhack. Afterall Ocarina of Time was built on the same engine as Mario 64 was.
Oh boy oh boy *rubs hands together*

If nothing else, this is a massive win for digital preservation.
 

ssnick37

Member
Oct 27, 2017
407
I would love a DS version of the game but with full analog control. I tried the DS version once the controls were just awful but i would love to play with the differetn characters.
 

tehz

Member
Oct 30, 2017
8
This is actually very impressive work. The video game community does crazy things.

As an aside, I wish that people did stuff like this with the "best" version of the game. For example, the Japanese only Mario 64 Shindou Edition with the rumble pak support added would have been better.


I doubt it's legal to share, but there are definitely several game disassembles hosted on GitHub that haven't ever been taken down, like Super Mario 1, Metroid, and several Game Boy Pokemon games like Crystal. Though to be fair, in some of those cases, the graphics are not included (like with the NES games).

I guess they think of it no worse than sharing video game music or something, since you're not getting the actual game?
This is a leak of an in-progress decompilation effort. I wonder what else the team could be working on for this game? Decompiling other versions perhaps?

But, to your main point, this code is far worse than sharing the actual game ROM. It's (semi-)portable C code that can be easily used to make incredible SM64 hacks. Or to port the game to Windows. Or to copy the physics into your own game. It's far more dangerous to Nintendo than an unportable disassembly of GB pokemon games.
 

Xharos

Member
Oct 25, 2017
3,639
Canary Islands, Spain
People are already playing with the source code

I really really want some madman to do a PC port with unlocked framerate.

Also, imagine if someone managed to integrate all the extra stages, characters and stars from the DS version into the framerate-unlocked PC port of Mario 64? We'd be living in the best timeline.