# Mario 64 source code fun. Trying to keep track of the various versions out there.



## FAST6191 (Sep 23, 2020)

This is all getting quite confusing to keep track of. I sort of had a handle at one point but then it became the new toy of a thousand different coders, them having to play anonymous coder because of legal issues and my general indifference to various platforms I got lost.
Depending upon what goes I may end up pulling an executive decision and renaming some threads to avoid some confusion but that will be a discussion for a later day. It will likely just be thread names as I am not up for splitting off things of people talking cross purposes, theoretical ports, actual ports different to the one of the original thread purpose and whatever else.

I plan to cover the background to this sort of thing, the history, some misconceptions, what has been seen thus far (though this will be incomplete) and what will likely come from all this. Corrections and additions more than welcome, though that goes for anything I write around here (I would have thought the whole "discussion forum" would have given that away but apparently not).

*General background.*

Computers are simple devices at heart. They do one usually quite simple instruction after another and eventually (these days instructions per second is in the thousands of millions for some things, and millions was achieved years ago) you end up with your program doing something you actually want/appreciate. As programming a computer that way is a monstrous pain in any number of organs we got high level programming languages made, the N64 being one of the earlier examples of this being adopted into game consoles for widespread use with high performance games (high level stuff had existed for many years on other things).
Anyway owing to... maths (see halting problem among other things) this act of turning a high level language into the low level one the computer wants (a process called compilation -- you compile source code to make a binary that the computer runs) was historically considered a one way affair. Certainly there is no simplistic way you can turn any old random bit of code back into source like you might convert a image into another format.
With a lot of effort and the results of some seriously talented programmers, maths types and the like that one way affair is looking rather less one way for a lot of things, one of those being the C programming language which is what the N64 took to using (C++ is different and far harder for this, and used in newer devices as it has some nice abilities but enough of that). https://www.hex-rays.com/products/decompiler/ and https://github.com/radareorg/radeco if you are curious there, though it is still a field under heavy research. There is also the discussion of dynamic recompilation in emulators (though it has some applications to this in that it can produce info that guides those doing more general decompilation) which is why you had N64 emulation quite early on, and not on machines 10x as powerful as the N64 which was the traditional baseline for the power needed to achieve emulation. At the same time the code is made to run on the N64 so anything not as powerful as the N64 or too different in what its strengths are might struggle to get a port, though some seem to be going there.

Anyway seems some skilled programmers, hackers and the like teamed up to make use of these new developments in computer science to recreate the Mario 64 source code such that even though it might be different (and lacking any layout hints or comments that the original developers would have had in there). They claimed it was to help with tool assisted speedrunning, and it might well have been, but code is code and there are many other things you can do with it.

Note this is not leaked code. It is still legally dubious to use but it is not the same as a classical leak and certainly not the same as them releasing code for people to play with. The various leaks of Nintendo code seen over the course of the last year ( https://gbatemp.net/threads/summary-of-nintendo-leaks.573873/ ) did see a version of the Mario 64 code go along with it, though this looks like an earlier beta and does include some fun things that people were looking into (the Luigi stuff you might have seen recently being among this -- https://comicbook.com/gaming/news/super-mario-64-luigi-modders-discover-code-24-years-later/ ).
I have not seen a comparison ( https://gbatemp.net/threads/anybody...4-leaked-source-and-the-decompilation.571726/ ) between them done, and nobody is likely to be using fairly late stage beta code when you have full retail available under essentially the same restrictions.

*The decompilation itself.*
This decompilation project as it was nearing completion (it certainly compiled to make something identical to the final ROM, most things had nice names and more besides) someone presumably trusted to look at it and play with it decided to share it with the world. Technically this would be a leak but again it is not the same as the "gigaleak" stuff that is otherwise ongoing giving us all sorts of cool info, code, source, internal documents and more besides. Note that the code to Mario 64 DS (which has some notable changes https://www.mariowiki.com/Super_Mario_64_DS#List_of_changes_from_the_original_game ) was not made available by either the original decompilation project nor any of the "gigaleaks" we have had at time of writing (there are supposedly more to come so maybe). Those seeking a version with those changes are either going to have to remake them themselves or wait for someone else to do it and for it to filter down.

This unsanctioned released of the decompilation would be what you might have seen in July 2019
https://gbatemp.net/threads/super-mario-64-has-been-decompiled.542918/

Not much happened at first. At best there was the recompile using another flag that saw a slight framerate boost.
One video discussing things here

(he has another video on Diablo if this decompilation subject is of interest here, though what allowed that is not available for all things)
or if you want the "hack" to achieve the effect
https://www.romhacking.net/hacks/4905/
and maybe a few people experimenting with it rather than doing things via conventional ROM hacking means (might return to ROM hacks later, though do note that combining source code recompiles and hacks can be very tricky unless you set out to ensure mutual compatibility or are good enough to do it manually yourself).

Later on we saw an official release of the decompilation project. I did have a quick compare at the time (more has happened since). Not too many differences between them but you will want to know which version any given project is based on if you are using source code and want to combine changes (few different names of files, few different comments, few different formatting choices... I am not sure which I would pick as my chosen one all else being equal as there are perks to both).
Choice links there
https://github.com/n64decomp/sm64
https://gbatemp.net/threads/super-m...en-decompiled-and-officially-released.546814/

Most code releases, including for versions on other systems, at this point strip out any data so you still need the original ROM. Legally speaking it is a fig leaf (it is still a very clear and obvious derivative work using Nintendo's underlying code, do a search for "clean room reverse engineering" for more on that one, though you own your changes) but as this is all very public and Nintendo has in turn been smacking down simple download this and play builds since the early days and has seemingly left this alone despite being very public then there is that (what the law says and what your opponent will do/are doing/might be able to achieve need not be the same thing). At the same time do keep your own backup of such things offline, if nothing else it might save something when the developer gets bored and deletes their host (something we have seen many many many times before over the years).

*The PC port and the start of where we are today*
In May 2020 we saw the first proof of concept PC port (the original code was built to speak to the N64 controller, N64 audio, N64 graphics... rather than Windows or something on PC and that needed to be altered, ported if you will, to allow such things). https://gbatemp.net/threads/super-mario-64-pc-port-has-been-released.564235/
It was pretty crude (nothing really resembling options in the game and you had to recompile it to do anything) but started the avalanche.
Being on the PC you could do things like force it to have high resolution, widescreen, bump up frame rates, alter damage taken, layouts, textures, radically alter the nature of the camera, do all sorts of control tweaks, high draw distances... all with some rather rudimentary coding skills where most of that would take a seriously skilled ROM hacker a lot of time to do if it was even possible at all, and even emulators would struggle to do it anything like easily. If you were a good coder then your options are pretty much limitless.
Surprisingly it did not fracture into a thousand different coders pulling in a thousand different directions after the initial release and people having some fun and instead some clear leader builds were made. I however lost track of things here as people retreated to private discussions on various services.

Some pondered whether it being available as source meant we had a nice engine to play with. Short version not really and there are far better choices -- it is still largely a tech demo spun into a game for a home console in 1996 and all that such a thing entails. It is not clean code you can easily jump on in for, you are still going to face legal restrictions in what you can do, claim and release. For the most part this is good for having super nice versions of any number of devices, making serious improvements to the game, accomplishing things that normally take ROM hackers a great deal of effort to do far more quickly and easily, expanding the scope of the game (can make a version having 100000 coins if you really wanted), maybe having a bit of fun with the game itself (you could happily use it to make custom animated videos using the characters if you wanted) and analysing the game so you too can create something as involved as the infamous half a presses runs.

*Other ports*

This PC port also formed the basis for things to move to other devices (I presume anyway -- someone might have redone the initial porting efforts for their own port or version). The Switch was among the more notable early attempts here, and while it was slow at first it later got more optimised and started getting equally fun options lists of things you can modify.
https://gbatemp.net/threads/mario-64-port.564633/

The Switch being slow meant people were dubious about how quickly a 3ds port might appear (it is possible to go through games and alter code to use maths types more closely matching those which your target device is better at -- in homebrew the Quake ports to the DS are quite notable for this as the DS struggles to do floating point calculations quickly and Quake is all about those floating point operations, and this sort of thing is the bread and butter of commercial game ports). There is one today though and it is pretty playable.
https://gbatemp.net/threads/super-mario-64-port.564431/

A Vita version appeared somewhere in the mix
https://gbatemp.net/threads/super-mario-64-port-for-ps-vita.572469/
https://github.com/bythos14/sm64-vita/

Wii U
https://gbatemp.net/threads/super-mario-64-port-wii-u.571682/

Most recently we have seen it make its way to Android
https://gbatemp.net/threads/super-m...ayable-on-android-without-an-emulator.574131/

Most other things are people discussing theoretical possibilities (there is a thread on the PS1 around here somewhere, short version is that would be a serious effort, the PS1 being a very different device with less computing power that differs greatly from what Mario 64 leans into, though not outside the realm of reason. Being as it would mainly be for a joke it is deemed unlikely someone will put the effort in.).

*Conclusion/final words*

I am however missing much and most of what I have above is months out of date (I did not even check the latest posts there for most of those). Hopefully it is at least a start and clears up some misconceptions I have been seeing since the earliest days.
To that end am I missing any ports (including someone else doing another port to the same console as covered above, or forking it and doing better than one I linked above) and what are we mostly looking at for the PC these days (early on I saw the start of some cracks between the "ultimately a purist but improved" and "let's see how crazy this can get" sets, and such a thing has happened many times before)?
I have also largely been following this on gbatemp (and it has hosted some good discussions on many aspects of this) hence the links to things here for the most part but if there are more authoritative links (original devs doing things, interviews with such) then I am happy to add those.

*Very short version*
Modern computer science is a wondrous thing and allowed some very talented coders to reverse what was originally deemed a one way process. This allowed them to create something that is functionally identical to the original code underpinning the Mario 64 game (and will likely see more fall as time goes on), this despite Nintendo in no way releasing anything.
This was used to create a PC port (which was then improved upon in many ways that games tend get improved graphical, audio and gameplay) and subsequently many other ports to many other devices.
During all this Nintendo had some of their own actual code leaked. A late beta of Mario 64 was among those. This allowed people to see some of what did not make the final cut in the game, and port it back out. Some people are working on doing things between this and various other previously known/seen leaked betas of it too. It is however not the same thing as the decompilation.


----------



## Flame (Sep 23, 2020)

some people collect post stamps. i collect Super Mario 64 ports.

but you forgot about the Dreamcast, MS-DOS, PS2, PS3, PSP versions.


----------



## Anxiety_timmy (Sep 24, 2020)

someone port it to the gamecube


----------

