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
 

Ecchi95

Well-Known Member
Member
Joined
Jul 7, 2019
Messages
121
Trophies
0
Age
29
XP
891
Country
United States
Guess what else you can use? Diaphora
The function signatures are different (because optimizations), so that would fail. I already have a working method and started on it.
 
Last edited by Foxi4, , Reason: No need to be rude. Your post has been edited

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
It's not Nintendo's code, technically.
For the purposes of most copyright courts it is.

If the people doing this had played it, observed its behaviour, fed it a bunch of inputs and then recreated the whole thing from observed behaviours (probably also with a different team to those that did the looking just to ensure nobody accidentally saw a disassembly and used it) aka a traditional clean room reverse engineering effort then it would be their own code.

As it stands the people doing this have all but admitted they used disassembly and decompilation* to regenerate the original source code (the whole compiles to 1:1 thing alone attesting to that, especially as this game has unused code like the trampoline stuff I was contemplating in the other thread that has comments generated upon it from this project) it falls under various things from derived works to out and out copying. How much damages Nintendo might be able to recover (or be assigned as I am assuming like most hackers the people here are broke as you like) and what sort of arguments they would make as far as it deprives them of potential revenue I don't actually know and don't know of any similar cases at this point. Historically Nintendo have not cared much either so I am not expecting too much here; we have had functional equivalents in terms of full commented disassemblies of Mario, Pokemon and more for many years now, all of which have been completely unmolested as far as I know, and observing interactions of the law and ROM hacking related fields is one of my things. Though at the same time if you and a few hundred other viewers of this cared to clone the GIT (they even have a nice download all as zip button) in an event of a keep sharing the tapes scenario then that is not a bad plan.
If it comes to pass that someone takes the code, tweaks it such that it compiles with a modern compiler for a modern OS or other embedded device and then we can all have our own custom builds made with a current version of code:blocks, visual studio or something equally easy to use then that might be a different matter and we could be awakening a sleeping giant as it were. Definitely want some Streisand effect in that case.

*not sure how much decompilation has been tested in court for non scripting languages (thinking stuff like python, java, autoit, C# and the like which have things that trivially spit out source code), as opposed to this sort of thing which takes a more creative toolkit (decompilation efforts for C and C++ attract some of the brightest minds in computer programming and computer science these days) and human effort to make sense of the results. However I don't expect a particular hangup here where it is all suddenly free and clear.

I am also not entirely sure what Nintendo might be able to do with the source code as far as releasing a new version using it if they have lost their old code or find this much better than whatever they have from back in the day (when it comes to public domain books then while the content might be unable to be copyrighted then it is usually held that the font, layout, formatting and such constitutes creative work done so I might not be able to scan a shiny new book of an old story and stick it online). Similarly there is no chance of any company (even if they wanted to wade through the 1990s vintage embedded C for a new console that was unknown and hard to program for) being able to use this to generate a commercial work, compared to most open source stuff where that is eminently possible.
 
D

Deleted User

Guest
unless you're putting effort in yourself, shut up.
Do you get off on being so bitter all the time? It was a simple suggestion, and I'm sure you could have taken it without being such a sourpuss.

All things considered, this is definitely gonna lead to some pretty nice advancements in the future and I'm looking forward to seeing what comes out of it.
 
  • Like
Reactions: CrashOveride

ShadowOne333

QVID PRO QVO
Editorial Team
Joined
Jan 17, 2013
Messages
12,184
Trophies
2
XP
33,715
Country
Mexico
explain why they cant because Mario's IP is still copyrighted hell NES games are still copyrighted and are still protected by that shitty law (F.U. G.W.)

For the purposes of most copyright courts it is.

If the people doing this had played it, observed its behaviour, fed it a bunch of inputs and then recreated the whole thing from observed behaviours (probably also with a different team to those that did the looking just to ensure nobody accidentally saw a disassembly and used it) aka a traditional clean room reverse engineering effort then it would be their own code.

As it stands the people doing this have all but admitted they used disassembly and decompilation* to regenerate the original source code (the whole compiles to 1:1 thing alone attesting to that, especially as this game has unused code like the trampoline stuff I was contemplating in the other thread that has comments generated upon it from this project) it falls under various things from derived works to out and out copying. How much damages Nintendo might be able to recover (or be assigned as I am assuming like most hackers the people here are broke as you like) and what sort of arguments they would make as far as it deprives them of potential revenue I don't actually know and don't know of any similar cases at this point. Historically Nintendo have not cared much either so I am not expecting too much here; we have had functional equivalents in terms of full commented disassemblies of Mario, Pokemon and more for many years now, all of which have been completely unmolested as far as I know, and observing interactions of the law and ROM hacking related fields is one of my things. Though at the same time if you and a few hundred other viewers of this cared to clone the GIT (they even have a nice download all as zip button) in an event of a keep sharing the tapes scenario then that is not a bad plan.
If it comes to pass that someone takes the code, tweaks it such that it compiles with a modern compiler for a modern OS or other embedded device and then we can all have our own custom builds made with a current version of code:blocks, visual studio or something equally easy to use then that might be a different matter and we could be awakening a sleeping giant as it were. Definitely want some Streisand effect in that case.

*not sure how much decompilation has been tested in court for non scripting languages (thinking stuff like python, java, autoit, C# and the like which have things that trivially spit out source code), as opposed to this sort of thing which takes a more creative toolkit (decompilation efforts for C and C++ attract some of the brightest minds in computer programming and computer science these days) and human effort to make sense of the results. However I don't expect a particular hangup here where it is all suddenly free and clear.

I am also not entirely sure what Nintendo might be able to do with the source code as far as releasing a new version using it if they have lost their old code or find this much better than whatever they have from back in the day (when it comes to public domain books then while the content might be unable to be copyrighted then it is usually held that the font, layout, formatting and such constitutes creative work done so I might not be able to scan a shiny new book of an old story and stick it online). Similarly there is no chance of any company (even if they wanted to wade through the 1990s vintage embedded C for a new console that was unknown and hard to program for) being able to use this to generate a commercial work, compared to most open source stuff where that is eminently possible.
Disassembly counts as reverse engineering, just fyi, and it holds legal grounds in courts, at least in NA as far as I know. So Nintendo can't claim nothing because RE is legal.
This is the same reason why Nintendo hasn't done jackshit to the already widely available Pokemon disassemblies, which vary from Gen 1 to Gen 3 as of this time of writing, and they've been available for years in GitHub of all places.

I don't know in what world a sane human would try to "reverse engineer" something just from observation and tried to recreate it from scratch. That's completely stupid. It's like trying to waste 1 year of your life to recreate Mario's jump from observation 1:1, while you can very much do it by debugging the ROM and see how the game engine does it with disassembly, alongside what routines are tied to it and the exact timing ticks, gravity variables, etc.

Disassembly is the very first step to any kind of RE, and most of the time they go hand by hand.
From here, people adept enough in the MIPS assembly language can work wonders.
And someone adept enough in both MIPS and C++ can start recreating the whole game in C++ from the base MIPS disassembly.

And remember, all of this is LEGAL.
So Nintendo can go fuck themselves with their bullshit DMCAs already and their IP copyright asshole attitude towards everything related to them.

Glad this was done.
 
Last edited by ShadowOne333,
  • Like
Reactions: Deleted User

Bimmel

~ Game Soundtrack Collector ~
Member
Joined
Jan 28, 2014
Messages
2,302
Trophies
2
Age
43
XP
3,792
Country
Gambia, The
Why do you say so?
Sorry, I forgot the emoticon.

Honestly, I can see the hard work that this project must have been. The reason why "soulless" comes to mind is hard to explain. Everything looks so clean und stiff, not natural at all.

In any case, it's a great proof of what is possible.
 

CrashOveride

Well-Known Member
Newcomer
Joined
May 29, 2017
Messages
50
Trophies
0
XP
127
Country
United States
That bullshit software won't help.

The function signatures are different (because optimizations), so that would fail. I already have a working method and started on it, so unless you're putting effort in yourself, shut up.


lol "fuck you because you suggested something nicely, shut up"
 

fudgi

Well-Known Member
Member
Joined
Apr 28, 2009
Messages
110
Trophies
1
XP
221
Country
Gambia, The
how were those sophisticated romhacks, with new features, physics etc possible if the source hadnt been altered?
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
Disassembly counts as reverse engineering, just fyi, and it holds legal grounds in courts, at least in NA as far as I know. So Nintendo can't claim nothing because RE is legal.
This is the same reason why Nintendo hasn't done jackshit to the already widely available Pokemon disassemblies, which vary from Gen 1 to Gen 3 as of this time of writing, and they've been available for years in GitHub of all places.

I don't know in what world a sane human would try to "reverse engineer" something just from observation and tried to recreate it from scratch. That's completely stupid. It's like trying to waste 1 year of your life to recreate Mario's jump from observation 1:1, while you can very much do it by debugging the ROM and see how the game engine does it with disassembly, alongside what routines are tied to it and the exact timing ticks, gravity variables, etc.

Disassembly is the very first step to any kind of RE, and most of the time they go hand by hand.
From here, people adept enough in the MIPS assembly language can work wonders.
And someone adept enough in both MIPS and C++ can start recreating the whole game in C++ from the base MIPS disassembly.

And remember, all of this is LEGAL.
So Nintendo can go fuck themselves with their bullshit DMCAs already and their IP copyright asshole attitude towards everything related to them.

Glad this was done.

Disassembly, and reverse engineering as a larger umbrella, might be legal for purposes of interoperability, accessibility, defeating anti piracy that is dead and preventing a work from being used, and all the other "substantial non infringing uses" that allow emulator projects to happen out in the open over decades but firing your decompiler or disassembler over a piece of code and releasing the result (even tarted up a bit) is hard to justify as some kind of fair use any more than me taking bitmaps of every frame of a film and releasing those as a slideshow is legal.
I am not sure why the pokemon stuff has remained so unbothered, however everything I have seen from Nintendo other than the emulator which bundled ROMs has been more from a trademark angle from what I can see, and I don't think the disassembly terribly bothers that.

I agree it would have been a nightmare, one you know you can end trivially with existing tools, to recreate a game even as old as this from observation -- such methods are traditionally saved for things like database formats, document formats, low level protocols and things like that to allow people to operate with them or convert between them. The method described before, generally known as clean room reverse engineering, is the traditional way you generate free and clear info for your projects that you want to interact with someone else's standard, code or similar if the have not provided the code in a manner you care to use.

I am also happy to see such things made, and happy to skirt the edges of laws to have cool things like this. Does not change the technical reality of the law though.

how were those sophisticated romhacks, with new features, physics etc possible if the source hadnt been altered?
Source makes things potentially a lot easier, however it is not impossible without it.
I am not sure how much depth is required for a reply like this but in an emulator you can watch for certain things to happen (buttons, standard cheat searches will yield character location, direction and speed, from there you can either watch things watching for the buttons or do something like that and figure out what jump routines are like) and from there figure out what code is fiddling with what. At that point you can do some fairly radical changes. Rinse and repeat for the various hats, walls/obstacles, enemies and the like.

Prior to the N64 (and PS1) most things were written in the assembly language you will likely be getting spat back out at you from the emulator and 16 bit era games still managed a fair bit of complexity. Or if you prefer you can have a read of https://stuff.pypt.lt/ggt80x86a/asm1.htm (it is for the PC but you can see how quickly you find yourself doing useful operations).
 

VzUh

you are now reading my custom title
Member
Joined
Feb 5, 2017
Messages
354
Trophies
0
Location
inside me
XP
385
Country
Spain
guys, gals, and whatever you are: now is the time to aswer one of the greatest questions ever

was luigi in mario64?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Maximumbeans @ Maximumbeans: butte