FIXING the ENTIRE SM64 Source Code (INSANE N64 performance)
Kaze Emanuar7 HN recommenders · recommended in 7 months, 2022–2025
explainer · advanced · evergreen · 2022–2025 on HN
Kaze Emanuar explains how he rewrote and optimized the Super Mario 64 source code so it runs far faster on real N64 hardware. He covers performance bottlenecks and fixes in detail for his ROM hacks.
HN loves the deep, hands-on look at N64 hardware quirks such as bus contention and the surprisingly large wins from low-hanging optimizations.
Up next
3 mo on HNThe Most Underrated Algorithm
Veritasium
5 HN recommender · 2022–2024
5 mo on HNNoether's Theorem and The Symmetries of Reality
PBS Space Time
5 HN recommender · 2018–2026
4 mo on HNLearn music theory in half an hour.
ANDREW HUANG
4 HN recommender · 2019–2023
1 mo on HNSynthesizing Chicken Noodle Soup From Pure Chemicals
The Thought Emporium
1 HN recommend · 2023–2024
3 mo on HNDoes "land area" assume a country is perfectly flat?
Stand-up Maths
3 HN recommender · 2020–2023
10 mo on HNComputer program that learns to play classic NES games
suckerpinch
9 HN recommender · 2015–2025
7 mo on HNThe world's worst video card?
Ben Eater
8 HN recommender · 2019–2024
2 mo on HNWorld's worst video card? The exciting conclusion
Ben Eater
2 HN recommender · 2019–2020
16 mo on HNHow Python was Shaped by leaky Internals, Armin Ronacher, Flask framework
Видео с мероприятий {speach!
15 HN recommender · 2017–2025
11 mo on HNCppCon 2015: Andrei Alexandrescu “std::allocator...”
CppCon
7 HN recommender · 2017–2025
12 mo on HNPreventing the Collapse of Civilization / Jonathan Blow (Thekla, Inc)
DevGAMM
14 HN recommender · 2020–2025
10 mo on HN"Performance Matters" by Emery Berger
Strange Loop Conference
12 HN recommender · 2019–2025
12 comments from Hacker News
Not always, though it might depend on what platform you mean with retro. Kaze Emanuar on YT does a lot of development for the N64 and it feels like half the time he talks about how the memory bus affects all kinds of optimizations. In Mario 64 he replaced the original lookup table for the sine function because an approximation was faster and accurate enough (or rather two approximations for two different purposes). I love that channel, he reworked the entire Mario 64 code [0] to make it run at stable 60FPS...because he wanted his mods to run faster. [0] ▶ this video
There's an amazing video about refactoring Mario 64 to reach 30 FPS and render 6x faster on N64: ▶ this video The changes were much more extensive than just removing the debug flags. They were also able to get local coop and a 4 player split screen working which were features originally intended for the game but cut for performance reasons.
If you found the video on Super Mario 64 being published with debug symbols interesting, check this out: After finding out about the debug symbols, a developer took a deeper dive through the codebase and optimized the ever living hell out of to get 60fps+. FIXING the ENTIRE SM64 Source Code (INSANE N64 performance) ▶ this video
I've recently been enjoying watching this young modder on YouTube optimize all of the original SM64 source code, doubling frame rate, and modding his own Return To Yoshi's Island ▶ this video
If anyone is interested in new projects for N64 hardware, Kaze Emanuar has an amazing series about optimizing Super Mario 64 to run incredibly complex romhacks on original hardware. Interestingly, SM64 is usually throttled by memory speed. This means that using 'inline' is detrimental to performance, since making the program larger can cause another read from memory. Here's an overview video, he has many more specific videos about specific topics: ▶ this video
Excellent..more of this please. Super Mario 64 has also had stupendous rewrites from decompiled code I believe. ▶ this video His videos on the Sine function in sm64 is a fun watch as the limitations make nearly all optimizations justifiable.
If you like this stuff Kaze Emanuar does loads of neat work with the super mario 64 decompiled code. ▶ this video Loads of interesting quirks of the N64 to do with slow bus.
On a related note, Kaze has done a deep dive into optimizing the Super Mario 64 source code for his ROM hacks. Here’s one of his more popular videos on the subject: ▶ this video
> Lookup tables are always faster than calculation - is that true? I know it's not always true on the Nintendo 64, because it shared a single bus between the RAM and "GPU": ▶ this video , link
Both use a unified memory architecture, where the GPU and CPU share the same pool of memory. On the N64, the CPU always ends up bottlenecked by memory latency. The RAM latency is quite high to start with, your CPU is sitting idle for ~40 cycles if it ever misses the cache, assuming RCP is idle. If RCP is not idle, contention with can sometimes push that well over 150 cycles. Kaze Emanuar has a bunch of videos (like this one ▶ this video ) going into detail about this flaw. The gamecube fixed this flaw in multiple ways. They picked a CPU with a much better cache subsystem. The PowerPC 750 had Multi-way caches instead of a direct mapped, and a quite large L2 cache. Their customisations added special instructions to stream graphics commands without polluting the caches, resulting in way less cache misses. And when it did cache miss, the latency to main memory is under 20 cycles (despite the Gamecube's CPU running at 5x the clock speed). The engineers picked main memory that was super low latency. To fix the issue of bus contention, they created a complex bus arbitration scheme and gave CPU reads the highest priority. The gamecube also has much less traffic on the bus to start with, because many components were moved out of the unified memory. --------------------------- The N64 famously had only 4KB of TMEM (texture memory). Textures had to fit in just 4KB, and to enable mipmapping, they had to fit in half that. This lead to most games on the N64 using very small textures stretched o
For those who haven't heard, Kaze is the guy who optimized Mario 64's code, fixed some physics bugs, etc., claims roughly 6x speedup, so that he can make a mod / ROM-hack that runs smoother despite having better graphics: ▶ this video
Retro game coders achieve some pretty astounding results sometimes. One of my favorite examples is one who optimized super Mario 64 to such a degree that it runs with much better framerate on the original hardware. Also, multiplayer was added: ▶ this video