News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.  (Read 1384 times)

FAST6191

  • Hero Member
  • *****
  • Posts: 2577
    • View Profile
Was made aware of it over https://gbatemp.net/threads/super-mario-64-has-been-decompiled.542918/ and did not see any discussion here so thought I would at least note it in passing as plenty of discussions have happened here on the game, and hacking thereof, over the years.

Anyway it seems some people with a lot of time to kill used some choice skills* and finds to recreate the Mario 64 source code in its original C (the N64 being Nintendo's leap from assembly to C as the main basis for coding games) with nice function names and labels. Obviously you will be lacking comments beyond what they added, and the current version is a leaked version of that project so not all the various aspects are nicely named just yet. That said if you manage to get your hands on the relevant compiler it apparently compiles exactly as it did on the original ROM, such a thing being an apparent goal of said project.

*not sure what the approach used here was. C decompilation has advanced somewhat in recent years with all sorts of predictive methods (such things even making a few inroads into C++) serving to make compilation less of a one way process than some classical textbooks would have you believe, and while I don't know if it was used I would not be surprised to see some kind of dynamic recompilation emulation abused here to grab snippets in real time with a bit more background.

I have no clue as to the legality of all this (be it from Nintendo or the project owners), though as it is not exactly what one might call a clean room reverse engineering effort then be wary if such things might bother you.

Jorpho

  • Hero Member
  • *****
  • Posts: 4144
  • The cat screams with the voice of a man.
    • View Profile
Ahh, but have the mysteries of TTC Upwarp been decoded?
https://www.youtube.com/watch?v=aNzTUdOHm9A
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

SleepyFist

  • Hero Member
  • *****
  • Posts: 841
    • View Profile
Sweet! I could really use this when I go back to working on the Shindou project, I struggled a lot with not really understanding the code QueueRAM gave me last time, maybe I could get a better foothold with the complete disassembly.
Sleepy's tune of the week|| Lost Lullabies (Unreleased Samurai Champloo tracks)|| https://youtu.be/BK6PR8DPNOw

Polargames

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #3 on: August 16, 2019, 04:46:10 pm »
This is probably going to be taken down by Nintendo. They do not like such projects that use there stuff. This kinda reminds me of Super Mario 64 HD. That was very cool, but Nintendo C&D it. It sucks to say because it could do a lot of good especially finding errors that are in the game, or maybe unknown tweaks.

If someone or someones could redo the whole source code into open source without using any of the OG, then I think it could be free and clear in the legal terms, but as its sits, I see it being stopped.

I wish Nintendo would stop doing this because there old games, and no one is hurting anybody, but that is just my 2 cents.     

FAST6191

  • Hero Member
  • *****
  • Posts: 2577
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #4 on: August 16, 2019, 06:34:16 pm »
This is probably going to be taken down by Nintendo. They do not like such projects that use there stuff. This kinda reminds me of Super Mario 64 HD. That was very cool, but Nintendo C&D it. It sucks to say because it could do a lot of good especially finding errors that are in the game, or maybe unknown tweaks.

If someone or someones could redo the whole source code into open source without using any of the OG, then I think it could be free and clear in the legal terms, but as its sits, I see it being stopped.

I wish Nintendo would stop doing this because there old games, and no one is hurting anybody, but that is just my 2 cents.   

I don't know what Mario 64 HD specifically entailed but if it was a fan game then that is in line with trademark law, and trademark law requirements. If it was a ROM hack (or even an emulator retexturing) then that is a slightly different matter and I will go looking (I try to keep a list of interactions of game makers and ROM hackers), and possibly also a "reach for the stars" opening salvo that lawyers so often do. They would probably also tell you it is not an old game -- an iteration of it was made for the DS, and I have not checked but I imagine a version is available on their downloadable game services for modern consoles.

Anyway the source code is already out there, and this is not 2006 any more where people don't keep sharing the tapes of such things. They might be able to take out the final version of the project with all the supposedly nice function/variable names that it presently does not have but this is more than good enough for a springboard. On the flip side how many years now have there been disassemblies of pokemon and whatnot on public repositories?

Jorpho

  • Hero Member
  • *****
  • Posts: 4144
  • The cat screams with the voice of a man.
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #5 on: August 16, 2019, 10:10:07 pm »
This is probably going to be taken down by Nintendo. They do not like such projects that use there stuff.
If I'm not mistaken, the source code does not include any actual graphics, sounds, or music from the game, and you can't actually arrive at a "1:1 recreation of the original ROM" without separately extracting those assets.  I would expect someone else is already planning a completely separate set of open-source assets.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Polargames

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #6 on: August 17, 2019, 08:41:04 pm »
I don't know what Mario 64 HD specifically entailed but if it was a fan game then that is in line with trademark law, and trademark law requirements. If it was a ROM hack (or even an emulator retexturing) then that is a slightly different matter and I will go looking (I try to keep a list of interactions of game makers and ROM hackers), and possibly also a "reach for the stars" opening salvo that lawyers so often do. They would probably also tell you it is not an old game -- an iteration of it was made for the DS, and I have not checked but I imagine a version is available on their downloadable game services for modern consoles.

Anyway the source code is already out there, and this is not 2006 any more where people don't keep sharing the tapes of such things. They might be able to take out the final version of the project with all the supposedly nice function/variable names that it presently does not have but this is more than good enough for a springboard. On the flip side how many years now have there been disassemblies of pokemon and whatnot on public repositories?

I understand what you mean, I think the Super Mario 64 was HD textures, but I too do not know how it was made. Before I cold take a look at it Nintendo C&D the whole thing. Now I understand the trade mark laws, but I believe that Nintendo has also has the source code copyrighted. While I agree that its out on the net and more then likely been used in different project. Nintendo cold still swing there C&D hammer at any point. They did take down gb/gbc/gba emulator on git-hub not to long ago, and they also took down Pokemon uranium.

August 17, 2019, 08:49:40 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
If I'm not mistaken, the source code does not include any actual graphics, sounds, or music from the game, and you can't actually arrive at a "1:1 recreation of the original ROM" without separately extracting those assets.  I would expect someone else is already planning a completely separate set of open-source assets.

Yes, you are right, Source code does not have any visual items, but it can still be copyrighted by Nintendo, as they have not made it open source at all. Nintendo is very funny when it comes to stuff like this. I mean they could use anything to C&D a project of any sort if they wanted to. They have done it to a lot already, and while ago was on a Rampage of sorts. I hope that someone out there has made or is making an open source version of the games code because it would help to preserve the game and make awesome projects out of it. 

Really, its all about the money. I think its really silly that Nintendo goes nuts on stuff like this, when a lot of people just do this in there free time for no money, and just pure love of the games. If I ran Nintendo, I would not have any issue at all of people making fan remixes and/or recreating a game in HD as long they are not selling it. But maybe I am using my head and heart to much here. 
« Last Edit: August 17, 2019, 08:49:40 pm by Polargames »

FAST6191

  • Hero Member
  • *****
  • Posts: 2577
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #7 on: August 18, 2019, 09:44:37 am »
I thought that emulator bundled ROMs ( https://www.theregister.co.uk/2015/07/14/nintendo_github_takedown/ ). Pokemon uranium was a fan game as well. Pokemon Prism might have been a bit more contentious but everything I read there was more trademark stuff as their website(s) could have caused confusion among customers.

Took a look and assuming I found the same Super Mario 64 HD then it was a fan game made in unity ( https://roystanross.wordpress.com/super-mario-64-hd/ ) and using a potentially confusing name.

The copyrighted source code would probably be the thing they go after this sort of project with (it most definitely is not a clean room reverse engineering effort* that could spare us that issue).

*I read an interview with one of the people behind the dolphin emulator. They say they have to ban anybody that says they read the leaked SDK and care to contribute to their project. Whether that is overly cautious I don't know but it is in line with best practices.

As far as Nintendo going after things. I thought their youtube stuff was silly, even if justifiable under the law in most cases. I have not yet seen them go after a fan game or similar that I would not have done in their place either -- while you can let a bit of copyright get bruised you do want to defend your trademarks (if you don't then you risk losing them), and such works were making it to major industry publications. While one or two being in a few press pieces would not have landed them with a genericide verdict ( https://www.bbc.co.uk/news/business-27026704 https://www.eff.org/deeplinks/2013/11/trademark-law-does-not-require-companies-tirelessly-censor-internet ) then if I am Nintendo's legal team having them wander in, slap down a bunch of articles from the main press for my client's industry showcasing multiple projects released over years flagrantly flouting trademark law and saying they clearly don't care would not be a position I care to be in.

Jorpho

  • Hero Member
  • *****
  • Posts: 4144
  • The cat screams with the voice of a man.
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #8 on: August 18, 2019, 04:09:03 pm »
Yes, you are right, Source code does not have any visual items, but it can still be copyrighted by Nintendo, as they have not made it open source at all.
Except they never published the source code, so how could something that was never published be copyrighted?

I remember there was a lot of bafflement around twenty years ago when DeCSS was released, and people found it amusing to contemplate that the source code might somehow be illegal but various textual descriptions of the algorithms would be protected free speech.
http://www.cs.cmu.edu/~dst/DeCSS/Gallery/

I expect Nintendo would almost certainly want to keep something like this as quiet as possible rather than getting dragged into some intricate legal battle over a project whose existence the vast majority of the population will likely remain ignorant of.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

FAST6191

  • Hero Member
  • *****
  • Posts: 2577
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #9 on: August 18, 2019, 06:46:58 pm »
Except they never published the source code, so how could something that was never published be copyrighted?

I remember there was a lot of bafflement around twenty years ago when DeCSS was released, and people found it amusing to contemplate that the source code might somehow be illegal but various textual descriptions of the algorithms would be protected free speech.
http://www.cs.cmu.edu/~dst/DeCSS/Gallery/

I expect Nintendo would almost certainly want to keep something like this as quiet as possible rather than getting dragged into some intricate legal battle over a project whose existence the vast majority of the population will likely remain ignorant of.

You don't need to publish something to have it copyrighted. Copyright is inherent, and in some cases can be augmented by submitting it for inclusion in a copyright body library (varies by country and time period). If you are thinking the certified letter in the mail as a poor man's copyright ( https://www.youtube.com/watch?v=gY0XFbDX1hk did a nice breakdown of that one recently). Or if you prefer see the use of created in https://www.csusa.org/page/Definitions#term (though publication does have options).
Similarly the end result of the source code was made available and by a quirk of... physics I guess it can't be reversed (or was done in a format where reversing is not trivial).

If the code was generated by a coincidence (unlikely for a full game but can be likely for a substantial function within a program if there are few ways) then that is one thing, and if the code was regenerated by clean room reverse engineering (played the game, observed if the stick is pressed it runs, if a is pressed (or full pressed as the case may be) then a jump happens...) and the full game was regenerated (possibly by a team that never partook in the analysis) then that is another matter again.

The decss thing was a fun one (even more so the illegal primes stuff that fell from it) but that was a different topic and dealt with decryption of protected works and the DMCA.

Polargames

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #10 on: August 19, 2019, 02:48:38 am »
I thought that emulator bundled ROMs ( https://www.theregister.co.uk/2015/07/14/nintendo_github_takedown/ ). Pokemon uranium was a fan game as well. Pokemon Prism might have been a bit more contentious but everything I read there was more trademark stuff as their website(s) could have caused confusion among customers.

Took a look and assuming I found the same Super Mario 64 HD then it was a fan game made in unity ( https://roystanross.wordpress.com/super-mario-64-hd/ ) and using a potentially confusing name.

The copyrighted source code would probably be the thing they go after this sort of project with (it most definitely is not a clean room reverse engineering effort* that could spare us that issue).

*I read an interview with one of the people behind the dolphin emulator. They say they have to ban anybody that says they read the leaked SDK and care to contribute to their project. Whether that is overly cautious I don't know but it is in line with best practices.

As far as Nintendo going after things. I thought their youtube stuff was silly, even if justifiable under the law in most cases. I have not yet seen them go after a fan game or similar that I would not have done in their place either -- while you can let a bit of copyright get bruised you do want to defend your trademarks (if you don't then you risk losing them), and such works were making it to major industry publications. While one or two being in a few press pieces would not have landed them with a genericide verdict ( https://www.bbc.co.uk/news/business-27026704 https://www.eff.org/deeplinks/2013/11/trademark-law-does-not-require-companies-tirelessly-censor-internet ) then if I am Nintendo's legal team having them wander in, slap down a bunch of articles from the main press for my client's industry showcasing multiple projects released over years flagrantly flouting trademark law and saying they clearly don't care would not be a position I care to be in.


Yes, you have found the right sources. I did not know that the emulator had games in it. My bad. Could one also say that on the Pokemon games, I agree with you on the trademark stuff btw, might of had source code in them and could that also be a factor?

On Mario HD I agree with you on it not being clean, but could there been some open source code that we the general public might not know about? There could of been, but was over shadow by it not being 100% clean.

I did not know about the leak SDK for the dolphin emulator. That would be the right thing in legal was the right move. If I remember right though, didn't dolphin start off as being closed source at first? I had been told that a while ago, but I could be wrong.

You can say though its doing very well when it tricked Nintendo's servers into thinking it was a wii system. If that does not show dedication by fans, I do not know what does lol.

With the topic of emulators having been brought up. Could one say that Cemu emulator could be a new target on Nintendo's radar? I believe that its not open source and does require people giving money to there Patreon page to get the newest build before the general public can get it. I am torn on this because I know building emulators does take money, but holding the newest build for giving money,could that cross a legal line at all?

The you tube part is 100% silly, and its even worse now, Nintendo has taken down videos that talked about homebrew. I know they do not like homebrew at all, but taking videos down and helpful game walkthroughs when your stuck is getting way out of hand.

August 19, 2019, 02:57:41 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Except they never published the source code, so how could something that was never published be copyrighted?

I remember there was a lot of bafflement around twenty years ago when DeCSS was released, and people found it amusing to contemplate that the source code might somehow be illegal but various textual descriptions of the algorithms would be protected free speech.
http://www.cs.cmu.edu/~dst/DeCSS/Gallery/

I expect Nintendo would almost certainly want to keep something like this as quiet as possible rather than getting dragged into some intricate legal battle over a project whose existence the vast majority of the population will likely remain ignorant of.

The post before mine did a great job of summing things up, I just wanted to say that I understand what you mean. And one could say hypothetically in the eyes of the DMCA it could fall under free speech and fair use, but fair use has also be a back and forth game in the eyes of the law also. https://fairuse.stanford.edu/overview/fair-use/
« Last Edit: August 19, 2019, 02:57:41 am by Polargames »

FAST6191

  • Hero Member
  • *****
  • Posts: 2577
    • View Profile
Re: Mario 64 source recreation. Compiles to 1:1 recreation of original ROM.
« Reply #11 on: August 19, 2019, 08:07:05 am »
I don't know what being free, open source or not would have to do with the legality of emulation. You can't really copyright or patent an arrangement of chips (not to mention interoperability of code, development of code, accessibility and other "substantial non infringing uses" are also options here) so unless they are providing copyrighted firmware and BIOS files (even then there might be cause to allow it) then it makes little odds.

About the only time I have really seen emulators worried at a fundamental level was Sony vs Bleem however long ago that was, and it was considered dubious even then (Sony doing the "we have a bigger wallet" method of winning a case).

Nintendo makes the occasional noise which has scared some people ( https://www.gdcvault.com/play/1023470/-It-s-Just-Emulation , and might as well have the follow up as it is also good https://www.gdcvault.com/play/1025782/It-s-Still-Emulation-Saving ) but I don't know what avenue they would really have against the general case.

As for source code in fan games. No idea if there was and I don't know if Nintendo cared -- if their trademarks provided such an easy and understandable option for the courts then they probably did not care.

Also yeah forgot about the more recent anti hacking stuff (it goes back further -- I recall an install video for a wii mod chip being taken down back when that was first happening). I was thinking more about them vs let's plays.

August 25, 2019, 05:47:21 am - (Auto Merged - Double Posts are not allowed before 7 days.)
A more official version is out. Not sure what the policy on linking is (even it is presently on github) so I will skip that for now.

Have not had a chance to do anything like a proper audit but pulling up a couple of files on separate screens the new one might have better formatting in some places but it is not like the leaked version was lacking. It is supposedly ongoing but I am not seeing any crazy amount of extras as far as variable names, function names and what have you.

Main thing I would note thus far

From "mario_actions_airborne.c"
Leaked version
Code: [Select]
#if VERSION_US
void func_u_8026A090(struct MarioState *m)
{
    if (m->actionArg == 0 && (m->forwardVel <= -28.0f || m->forwardVel >= 28.0f))
        func_80250F50(m, SOUND_MARIO_DOH, MARIO_UNKNOWN_17);
    else
        func_80250F50(m, SOUND_MARIO_UH, MARIO_UNKNOWN_17);
}
#endif

Github Nintendo 64 decompilation version
Code: [Select]
#ifndef VERSION_JP
void func_u_8026A090(struct MarioState *m) {
    if (m->actionArg == 0 && (m->forwardVel <= -28.0f || m->forwardVel >= 28.0f))
        play_sound_if_no_flag(m, SOUND_MARIO_DOH, MARIO_ACTION_NOISE_PLAYED);
    else
        play_sound_if_no_flag(m, SOUND_MARIO_UH, MARIO_ACTION_NOISE_PLAYED);
}
#endif

Such things being repeated/"changed" to VERSION_JP throughout that file. This will make source patches a bit tricky so be sure what version you are all working on.
« Last Edit: August 25, 2019, 05:47:21 am by FAST6191 »