top | item 31075622

Overhauling Mario 64's code to reach 30 FPS and render 6x faster on N64 [video]

699 points| kibwen | 4 years ago |youtube.com | reply

260 comments

order
[+] Lerc|3 years ago|reply
This is a good lesson about the benefit of time when it comes to software development. Mario 64 could have been a much much better game on the same hardware, but the time cost would have resulted in a release late enough that the entire game might have been considered irrelevant.

Game consoles have had the benefit of the platform freezing for a few years allowing improvements to accumulate and later titles utilizing knowledge gained from the earlier titles.

Much of the software we use every day could benefit from this level of scrutiny but the pressure to deliver on time means we won't get to see such benefits unless it becomes a crazy persons labour of love.

[+] egypturnash|3 years ago|reply
There are externalities to consider that make a later release less likely, too - it was a launch title, to match the pack-in of SMB in the NES and Super Mario World as one of two games available when the SNES launched.

Wikipedia’s entry on SM64 tells me that the N64’s launch was delayed because Miyamoto wanted more time to polish the game. I don’t think a later release would have been possible. This was the flagship title, the system seller. Come play Mario. In 3d.

[+] bscphil|3 years ago|reply
I watched the video through only once, but unless I'm mistaken (the video is a little confusing on this point), the claim is that the original game did run consistently at 30fps (the design framerate of the console), and the point of these hacks is to improve framerate for mods and devices that can play the game at higher rates. Unless I misunderstood something, it sounds like the original game was exactly as good as it needed to be, as released. And that's before you get to the fact that the mods require the RAM expansion pack.
[+] finnh|3 years ago|reply
> ... unless it becomes a crazy persons labour of love

Or there are valid business reasons to keep chipping away, in particular on performance-per-dollar problems at scale. If you're spending $1M/month on hardware to run something, each 10% win is worth enough to employ a couple senior engineers.

[+] gernb|3 years ago|reply
Much of the software we use every day does benefit from this level of scrutiny. There was a popular post today about changing C++ std::sort for more perf. There's JavaScript engines running 100x faster for a given CPU than they were in the 90s? gcc and llvm optimize more than ever?
[+] giantrobot|3 years ago|reply
Super Mario 64 was a launch title for the N64. One of two launch titles in North America. There really was no way to delay the game without delaying the console.

With that in mind, SM64 is a pretty impressive game for a console launch title. It makes good use of the N64 controller, performs well, and is pretty fun. It's not the best game of all time but it's definitely not a bad game.

[+] phillipcarter|3 years ago|reply
"roll those loops back up and don't compile in debug mode to achieve significant performance gains" is not the takeaway I thought I'd have going in, heh.
[+] infogulch|3 years ago|reply
Unrolled loops trade instruction cache for cycles. Whether it's good depends on what your bottleneck is, in this case ram access is a bigger bottleneck than cpu due to being shared with the rendering coprocessor. I wonder if we'll hit this crossover point again in the future.
[+] butwhywhyoh|3 years ago|reply
He did so much more than that. The not compiling in debug mode was well known before this video, and he addresses that. His speedups are independent of not compiling in debug mode.
[+] astrange|3 years ago|reply
It was common belief in that era that you made code faster by making it longer and more complicated. The opposite is true now (because of cache size and deep OoO) - simple predictable loops are great - but even then people tended to overdo it.

Of course, it's a way worse problem that they compiled at -O0.

[+] jart|3 years ago|reply
Now that's a 10x programmer if I ever saw one. I'm sure the compiler helped too. The generated code of C compilers from the 80's and 90's versus the generated code created by something like modern GCC -- it's like night and day. We're able to build faster tinier software than we ever have before, and it really helps to illuminate the impact modern tools have had when we apply that advantage to something old we already know.
[+] pupppet|3 years ago|reply
I always wonder if the original devs ever find these videos and are like oh shit we should've done that.
[+] Timpy|3 years ago|reply
None of the games I play these days are CPU intensive so while I understand FPS is important to a large group of gamers I have never paid attention to it. Before clicking I thought "does frame rate really matter for Mario 64? How big of a difference can it make?" I'm absolutely blown away, I can't believe how smooth this looks. I don't know what else to say, I'm speechless. Stellar job. Vroom vroom.
[+] antifa|3 years ago|reply
High framerates are cool but often I wish more games had the option to cap framerate at 30/40/45 and use less battery/produce less heat instead of racing to 120fps.
[+] simooooo|3 years ago|reply
Ever played on a 144hz+ monitor?
[+] vmception|3 years ago|reply
pretty amazing what you can do when you push the release deadline back by 26 years.
[+] iforgotpassword|3 years ago|reply
Heh, but even then, 6x is still impressive. I doubt in 26 years you could optimize a tripe A title from today to the same extent. It seems that the vast majority of optimizations is actually achieved manually and not through Compiler magic and other modern tools. But then again maybe in 26 years we will have magic tools that will get the job done. ;)
[+] jccalhoun|3 years ago|reply
And have access to the ram pack that the original devs didn't have.
[+] amatecha|3 years ago|reply
Wow, this is amazing! Plus he's adding split-screen co-op mode??! Mind blown. Impressive work, seriously.
[+] YesBox|3 years ago|reply
How would one learn about this depth of C and its optimizations? I'm interested in it as an art form, something to do in my spare time.
[+] Gravyness|4 years ago|reply
Its absolutely amazing the level of expertise and dedication a single person can have on the inner workings of something.
[+] Forgeties79|3 years ago|reply
Mario 64 has to be one of the most dissected games ever. It’s kind of wild what speed runners, modders, etc. have uncovered.
[+] soulbadguy|3 years ago|reply
Naive question : how did we get access to the source ? Is that from a disassembler or did the source code leaks at some points
[+] nebula8804|3 years ago|reply
From what I understand he used Mario 64 decomp code.

The game was reverse engineered as 1-1 compilable to the original rom.

[1]:https://github.com/n64decomp/sm64

Fun fact: The people who did this moved on to Zelda 64 Ocarina of time and recently completed that project as well

[2]:https://zelda64.dev/

There are ongoing projects by other people for Mario Kart 64, Goldeneye, Perfect-Dark, Banjo-Kazooie and others although I think the next target for completion may probably be either Majora's Mask or The Minish Cap.

[+] BizarroLand|3 years ago|reply
IIRC from an earlier read about this, the code is from a disassembler.
[+] tambourine_man|3 years ago|reply
> I don’t fault them for making most of these mistakes. C was a rather new language at the time.

In the 90s? It was 20 years old by then and mostly ruling the world already.

[+] kibwen|3 years ago|reply
Not on game consoles, and perhaps not even for PC games more generally (hedging my bets in case Walter Bright waltzes in and starts talking about how he wrote Empire in C in 1972 or something :P ). It wasn't until the mid-90s that C ate the game industry. Recall that C wasn't standardized until 1989, that C compilers weren't free or ubiquitous or good, that plenty of now-forgotten contemporaneous languages existed, and that making entire games in assembly was still quite popular and liable to get you better performance anyway.
[+] IntelMiner|3 years ago|reply
I know they don't "owe" anyone anything. But it is disappointing they've apparently declined to release their code changes

It's also apparently unclear if the overhauled version will run on a real N64 or if it only runs in an emulator

[+] Quillbert182|3 years ago|reply
He is planning to release the source code at a later date. He is waiting because the source code is intertwined with a ROM Hack he made, and he is unable to release the improvements without releasing the ROM Hack in an unfinished state.

The overhauled version will run on a real N64 as long as it has the RAM expansion pack.

[+] djmips|3 years ago|reply
It will run on a real N64 but it needs the memory expansion. So that's one thing he mentioned but people do gloss over. It (the extra memory) helped a lot in reducing memory contention between the CPU and the GPU.
[+] sonicggg|3 years ago|reply
He has patreons backing this project, so he may actually owe them something.
[+] randomifcpfan|3 years ago|reply
Great work, but a significant fraction of the improvement comes from installing and using the 4MB RAM expansion pak, which isn’t really a fair comparison.
[+] fareesh|3 years ago|reply
Would be nice if it became the norm that the source code and assets for games were available as an open source purchase after X years
[+] lynguist|3 years ago|reply
25 years ought to be enough, no?
[+] darepublic|3 years ago|reply
Very interesting video and it brought back a lot of nostalgia. At the time this came out I was blown away by it. Remember watching some kid play the bbomb level at the department store. Looking back as an adult I no longer feel the awe, but have the greater satisfaction of learning about the ram bus and low level programming considerations
[+] gnutrino|3 years ago|reply
I remember playing it at the store thinking we had reached the pinnacle of computer graphics, and that there was no way they could get better. Boy was I wrong! Still one of my favorite games of all time.
[+] modeless|3 years ago|reply
Does this mean that Nintendo could have theoretically shipped Mario 64 as a 60 Hz game on N64? I know some of this stuff requires the RAM expansion, but not all of it.
[+] arriu|3 years ago|reply
This is a serious amount of effort for what I imagine is little payout. I really enjoy work like this and hope that he is able to make a living off it.

Anyone have thoughts on how to make projects like this more sustainable?

[+] magpi3|3 years ago|reply
Someone on HN once said, if you want to build a reputation and a brand, do interesting things and talk about it. This is the perfect example. No, this will not make him money because there is not a large market for superior Mario 64 performance, but you sure as hell know who he is now, don't you?

And I will say his youtube skills are top notch. The video is very entertaining and informative. I just cannot imagine this person will have trouble making money in the future.

EDIT: Added a missing word

[+] eigenvalue|3 years ago|reply
This seems to clearly be a passion project. The author is being paid in the satisfaction that he gets in improving this famous game way beyond what the original creators managed to do, all while being bound by the same technical limitations. He also gets to show off his skills to a fairly large (in absolute numbers at least) global audience of people who are also really into this particular game. I doubt you would see someone going to such great lengths for an obscure title that few other people would appreciate or care about.
[+] colechristensen|3 years ago|reply
People often do things for their own merits and not just in exchange for money.

But the guy has a Patreon and this video already has a half a million views which should be at least $1000 in revenue, possibly 2-3x and it's still quite new.

[+] jandrese|3 years ago|reply
He does have a Patreon so it's not entirely volunteer work.
[+] tantalor|3 years ago|reply
Art doesn't need to have a payout or be sustainable.
[+] Cloudef|3 years ago|reply
Submitted this few days ago but did not get any points. I have no idea how HN works
[+] namrog84|3 years ago|reply
Time of day and day of the week can impact such things. Lastly, that's just the fickleness of social media sometimes. Sometimes a thing will take off and sometimes it won't.

A recent example is Among Us was released for 1+ year as almost a 'failure' with very little players. Received no major updates and just went by unnoticed until the right people pushed for a thing and now it's seeped into so many other things. e.g. Among us player count https://i.imgur.com/M1j0UOw.png

[+] vmception|3 years ago|reply
is there any part of this video that is a side by side comparison? didn't see any obvious marks in the description or comments
[+] ydnaclementine|3 years ago|reply
At some point, these older games should be open source. They can follow the doom/quake model where textures/art aren't included, and Nintendo can also still sell the games on newer consoles for convenience because not everyone will want to compile it themselves

I guess you could argue a mario 64 custom levels mod competes directly with a new mario game. But halo and cod sell fine. Maybe I have a bias that thinks Nintendo is fearful that custom mods for old games will be more popular than anything new and official