Did Nintendo really forget to Optimize Super Mario 64 ? | MVG

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Did anyone actually think that Nintendo forgot? Isn't it pretty obvious that it was on purpose? Sure, it's a surprise that they wouldn't do it, but no one actually thought it was an accident, right?

👍︎︎ 29 👤︎︎ u/ReallyNeededANewName 📅︎︎ Feb 03 2020 🗫︎ replies

What I don't understand is why it was optimized for the EU version but not the US.

And wouldn't they have optimized the final release candidate and then tested it? Didn't appear to be any issues with the optimized version shown.

👍︎︎ 9 👤︎︎ u/tasteslikefun 📅︎︎ Feb 03 2020 🗫︎ replies

Considering the original Legend of Zelda..

👍︎︎ 1 👤︎︎ u/AtemAndrew 📅︎︎ Feb 04 2020 🗫︎ replies

Mistakes were not made

👍︎︎ 1 👤︎︎ u/BitcoinCitadel 📅︎︎ Feb 04 2020 🗫︎ replies
Captions
[Music] in 1996 Nintendo released a game that would change videogames forever [Music] Super Mario 64 was a landmark achievement many felt that 2d Mario was gaming perfection and that somehow the translation to 3d would dilute the experience but the end result redefined the platforming genre and gave away too many 3d games that came after it oh and it sold a cool 11 million copies it showed off what the Nintendo 64 could do complete with colourful 3d graphics that were fully texture mapped and filtered exceptional audio and of course analog controls it wasn't perfect the game was criticized for its camera which took some getting used to but with the ability to adjust perspective it certainly wasn't a major issue and over 20 years later Super Mario 64 still holds up it's a masterpiece and a true killer app for the Nintendo 64 Mario 64 was first playable in emulation as early as 1999 and for years people have been interested in dissecting the game to learn more of its secrets one particular method involved the generation of source code for the entire game in the middle of 2019 the source code for Super Mario 64 was released onto the Internet however this was not a leak of the official source code to the game rather it was a D compilation project that was performed painstakingly over many many months for those that may not be familiar with D compilation and reverse engineering tools like ITA Pro or even better guidry which is free and open source it's actually possible to generate raw C code from the binary the tools are that good so let's take a quick pause why do we care about any of this there was a recent video made by fellow youtuber Matt Casey who made a very interesting discovery that Super Mario 64 could actually run faster with a simple one-line change to a file I recommend checking out his video on this topic and I'll have a link in the description below so before we get technical let's see if any of this is actually true this is running on real hardware with a never drive cartridge the speed ups are very apparent on the level dire dire docks and indeed if we compare the patched optimized version to the unmodified original game there is a performance increase doing some quick framerate analysis shows this as well this is pretty interesting as you can see the patched optimized version can run significantly faster frequently hitting 30 frames per second the unmodified original version is notorious for slowdown and lag on the die die docs level and as you can see it's sometimes struggled to keep up and it will bottom out at sometimes less than 20 frames per second so this was all achieved by utilizing Ghidorah ad compilation and reverse engineering tool if we provide deidre with a mario 64 rom it will decompile the ROM successfully and generate rossi code however the function names will be generic which aren't that useful because there is no context so the next step from here is to update the code to understand what it's actually doing the mario 64 d compilation project is the work of many many months of research and developed but in the end the project is capable of generating a Mario 64 ROM file that exactly matches byte for byte the US version of the game that's pretty impressive there's never any guarantee of that but it shows how good d compilation techniques have become so let's go back to that one line change it was performed in a file that was known as a make file this is a file which contains a list of instructions to tell the MIPS C compiler how to build the wrong it also contains information about the optimization settings that it should apply when building a release candidate for the game recall that the original US Mario 64 ROM matches the D compilations project ROM bike for byte based on the make file so as it turns out we can see that there was no optimization flag enabled before the game went retail so this is the pub that seems very strange Nintendo for some reason decided to release mario 64 in the USA without any optimisation at all what this make file is telling us is that the European version is running an optimization known as Oh - well the North American version is not running optimization at all in fact - G means to generate debug output so is Super Mario 64 not optimized at all in the US version that has been the source of the recent discussion point that somehow Mario 64 fell through the cracks when it was being released in the USA without any optimization and as soon as I heard about this story I was immediately skeptical before we throw our hands up in the air and blame Nintendo for being lazy let's do some digging and see if there's a logical explanation for all this as someone who is AC program and has many years of C programming experience this story really perked my interest because the initial takeaway is Nintendo somehow managed to omit the o2 optimization on Super Mario 64 but I think it's important to really deep dive and understand how optimization works on C compilers as well as take a look at some of the development documents from Nintendo back in 1996 when you develop code in C the compiler will do its best to optimize it for you but there are some additional levels of optimization that you can also apply they are o 0 or no optimization this is the equivalent of having the flag omitted this option is not recommended except for debugging purposes next is oh one this is a basic optimization level the compiler tends to produce smaller code Oh 2 is a step up from oh one and it's the recommended level of optimization in most instances it will increase code performance quite nicely then there is oh 3 which is the highest level it's aggressive and it's known to break code it's usage is not recommended however the gains can be significant so let's consider this piece of code here it's a simple mem copy function that takes a source and copies it to a destination it's not really important to understand the assembly language and its generating on the right hand side but notice that it's generating around fifty two lines of assembly from the basic mem copied C function if we specify that we want o 2 as our optimization pattern you can see that the assembly code is significantly reduced in general terms less assembly instructions means faster code so it's 1996 Nintendo is about to launch the Nintendo 64 with mario 64 in the US and we're led to believe that somehow they forgot to add the o2 optimization flag to the US version of the game now the developer in me tells me that there is more to this story than meets the eye so this is the programming guide and reference manual if you were a developer from the Nintendo 64 you'd be quite familiar with this documentation pretty much all the information you need to code n64 games is here back in the early days developers were using Silicon Graphics workstations and then later partner Nintendo 64 hardware development kits on PCs and writing code in C many developers came from the Super Nintendo where things were done using assembly language so there was a bit of a learning curve here C has some intricacies and pitfalls particularly around typecasting that can catch you out if you're not careful and then adding optimizations into the mix can easily break code looking through the online documentation came up with some interesting bits of information Tendo themselves recommended that any non debug code is compiled with the o2 optimization flag in fact looking at the samples that came with the STK further proves that oh two should have been the target so why was it omitted in Mario 64 simply because Mario 64 was a launch title development kit hardware was expensive the tools and the SDK was not yet established and there is strong evidence that points to compiler issues that were later patched for example one particular one that stands out is back-to-back floating point multiplication that is if you multiplied through floating point numbers then take the result of the first multiplication and then multiply that with another number it could provide incorrect results now this may seem harmless but incorrect math floating point values would likely affect geometry and textures attempting to track down and fix these types of bugs can take many many hours to triage and resolve Nintendo offered a software workaround and later patched it during the development of Mario 64 it's likely that optimization was disabled so developers could be in control of this issue there's also other interesting things looking at the SDK patched nodes can reveal some additional information this particular patch note was from late 1996 essentially what it's saying is if owed to was enabled any warning that the compiler would spit out is suppressed in other words if there's a chance that the compiler will generate bugs and inform the dev they'll never see it again something that was later addressed but Mario 64 is our launch game and developers wanted full control over their code and not risk it the main takeaway here is that Mario 64 was developed with early versions of the SDK that contained bugs Dylan Cuthbert who worked with Nintendo on the Super NES and Nintendo 64 also confirmed that oh - and even oh three introduced problems for developers that were not familiar with C compilers there is one more interesting piece of information that I want to share with you guys about this story and that is it's easy to conclude that Nintendo did not optimize Mario 64 in the US however that is not entirely true although the OT flag does help Super Mario 64 of the games aren't massive the difference between debug and is fairly significant there's two things going on here first o to want help with the GPU and second and perhaps more importantly the discovery that Oh 2 was not enabled is not 100% accurate in fact you could say it's a little misleading most nintendo 64 games that were developed would use a common library known as Lib ultra and developers of games would build common libraries that were shared across their titles Mario 64 uses Lib ultra and other libraries to handle math audio and additional calculations if we go back to the make file we saw earlier but scroll down further there are libraries that are also compiled into the game but most of them have o to and even oh 3 enabled it means while some of the sauce indeed isn't optimized the libraries that work with the game well and truly are and referencing these makes up a large part of the game so how does a true debug or non optimized Mario 64 run well let's go ahead and disable optimization from every single source file in this code and see how well it performs now as you can see on the intro screen on the left hand side is the debug version and there's already a few frames per second difference it's a lot slower the o2 and bass versions run at around the same level of performance so the o2 version isn't really any more optimized than the base version only in select places so in conclusion Nintendo certainly did not forget to optimize Super Mario 64 they knew exactly what they were doing given the tools that they had to work with at the time all thing is considered the game turned out to be an absolute masterpiece and performed exceptionally well back in those days we weren't as concerned about frame rates and lag as we are now I really love to see these types of D compilation projects and one game that really stands out to me that could really use something like this would be pilot wings now pilot wings was another game that had slowdowns you know he'd play through the game and then all of a sudden the game would basically have its frame rate so I'm not suggesting that this is a similar type of thing but it could be something that would benefit from a decomp elation and another look at the code to see if there's any modern techniques that can be a in order to improve performance and I think that type of project work or that type of you know discoveries are very interesting to me so there's definitely more things there that I'm very excited to see and hopefully more D compilation project teams start to rally around and get more of this project ste compiled so we can start looking at them and and really applying modern compilation techniques to some of the things that we're trying to do in order to increase performance well guys I'm going to leave it here for this video thank you so much for watching if you liked it you know what to do leave me a thumbs up and as always don't forget to Like and subscribe and I'll catch you guys in the next video bye for now [Music] Oh
Info
Channel: Modern Vintage Gamer
Views: 1,219,172
Rating: undefined out of 5
Keywords: nintendo 64, n64, super mario 64, mario, slow, emulator, everdrive 64, retro, gaming, classic, vintage, mvg, modern vintage gamer, gcc, n64 devkit, devkit, optimization, performance, dire dire docks, giles goddard, lag
Id: NKlbE2eROC0
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Mon Feb 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.