I thought the 9th bit was used as a sort of error decection thing. (like ethernet cable they have one line that just sends a 1 bit data telling if the 8 bit is even or odd. if it says its even and the byte stream is odd. resent. works fine as long as the byte error is 1,3,5,7 bit off (its usally 1 bit so) causes probelm is 2 bits are off as that would result in a to says its odd when its odd and still be correct.
@@Zack_Wester yea, that's a parity bit for error correction. Same idea but the hardware doesn't use that bit for that. Generally only servers or higher-end professional workstations will implement parity on internal memory.
A proven way to get support for an exotic hardware feature is to make a demoscene demo with it, publish at a major party like Easter Revision in Germany, then suddenly a few weeks later a handful emulators support it.
@@christopherthibeault7502 According to Google, it's a demoscene demo for the N64. In my experience it seems that home computer emulator devs strive for accuracy while most (not all) console devs just want to get the games working.
0:35 I genuinely doubled-taked (took?) when I heard 9 bit per cell. I thought we were getting into some Apature Science "13% more byte per byte" shenanigans with this.
It always shocks me to see just how different old consoles were from standard computers, unlike current ones which often just use off the shelf parts. Edit: I did not mean this as a bad thing towards modern consoles lmao
@@erik3371he's not wrong. Modern consoles use very similar, if not cut-down, parts and components from Custom PC Parts. Right now it's the 4700G (without the igpu) and rx 6700 non xt. It's cheaper to buy what already exists (architecture wise) instead of spend money in R&D to make a custom part. That's why consoles are cheaper.
@@ENCHANTMEN_ They have too many built-in security and consistency features for such bleeding-edge optimisation. As cool as ACE is, you absolutely don't want to risk RCE. (Although Final Fantasy Crystal Chronicles has a few equipment glitches that are actually RCE!)
So much software from over the decades was built on top of these messy foundations. Why rebuild it when you can throw more silicon at it? Besides, it would probably take a lifetime to undo the gordian knot of software interactions. A lot of the problems are in code that you don't have access to, like the OS itself. There's a whole ecosystem of garbage to navigate now. Maybe the industry will be willing to roll up their sleeves once Moore's Law dies for good... and everyone gets past the existential crisis that presents.
Месяц назад+18
@@KopperNeomanAnd on modern computers self modifying code is generally a lot slower than treating your code as read only. It messes with all kinds of pipelining and other hardware optimisations.
13:29 Worth checking if the MiSTer's N64 core handles this correctly. If it doesn't, it's not entirely outside the realm of possibility that Robert Peip would implement it. He called the N64 core "done" over a year ago, but when new info surfaced on how to address the handful of games that had crashes because of timing limitations in the DE-10 nano board, he added bug fixes for them.
Mister is nearing end of life and the N64 core will never been 100% accurate with 100% of games. And even if the average person bought the Mister kit, they could never set it up properly. Analogue 3D is idiot proof and even Everdrive 64 is not hard (just drag da roms into the SD card). Analogue 3D is going to democratise what Mister N64 project has been trying to do.
I've known about the 18-bit color buffer and coverage values for a while. A while back, I wrote a software rasterizer that outputs to a bunch of obscure color formats, and one of the things I did was simulate how the Nintendo64 does antialiasing. Basically, the way that it works is that in the triangle rasterization code, you use fixed point coordinates with 2 fractional bits, which permits a 1/2^2 = 0.25 pixel precision. For the first and last scanline of the triangle, you map the fractional bits [0, 3] of the Y coordinate to a 4x4 vertical coverage mask (a 16-bit unsigned integer). For each scanline, you also use map the fractional bits of the X coordinate for the first and last pixel on the line to a 4x4 horizontal coverage mask. You then do a bitwise AND to combine the two coverage masks, do another bitwise AND with a checkerboard-patterned dithering mask, and then map the result to a coverage value [0, 7] based on how many bits are still set. If all 8 bits are set, wrap it back around to zero. This 3-bit coverage value is sort of like an alpha value, but not quite. It basically identifies whether or not a pixel is part of a silhoutte. A coverage value of 0 means that the pixel is either fully covered or fully uncovered, and thus nothing should be done. Any other value represent a constant that's used to do linear interpolation between the "foreground color" (the color of the pixel in question) and the "background color" (a combined color of the surrounding pixels. This has the effect of blending silhouette pixels into the background, thereby achieving an antialiasing effect; and in a way that requires *far* less memory or computational power than techniques like supersampling or jittering + accumulation buffering. On the N64, this post-processing effect is done in hardware, but in my code, I was basically writing coverage values to the alpha channel and then doing a tiled rendering of the window. There's also technically one more aspect that's required to make this all work, which is that the depth buffer has a "delta Z" component that's used to tell whether or not two triangles are coplanar in order to avoid accidentally categorizing the edge pixels of coplanar triangles as part of the silhouette. I never got around to fully working out the details of that.
Fascinating. And then the textures are low enough resolution to never have their own aliasing issues. It's fascinating how different SGI designed this compared to how the PS1 went for a much more naive implementation.
10:58 For those confused: "COMPILE WITH OS" refers to -Os flag in GCC which optimizes for size (and often results in more performance as well due to reduction of CPU cache pressure)
@@Velocifyer I have been using GCC for a decade, and do not automatically assume '-Os' when I read 'OS'. Believe it or not, 'OS' already has a pretty common meaning in computer science. The video is being needlessly confusing.
Error correction is exactly what RAMBUS dudes intended these bits for, as well. SGI decided to abuse them for extra antialiasing bits in framebuffer as Kaze explained, but my understanding was that they were impossible to access otherwise.
you know eventually you'll have to make something like a demoscene demo that showcases all this stuff you've uncovered properly. like a rotating fractel with fur rendering over its surface and ray traced lighting to light the scene
In all seriousness, I prefer what he's doing so much more than the demoscene stuff. There are so many cool tricks in those demos, but it's so much more satisfying to see them used in the context of a full game! But yes, Kaze, please throw in a boss character with fur rendering! :P Maybe Cat Bowser can return? (It's basically just a bunch of transparent textured shells, right? Can the N64 render that quickly enough, since we know the order in which to draw them, and Z sorting could be specified manually?)
@@GabrielAKAFinnI'd say "striving for 100% accuracy is the spirit of emulation!", but the goofy popular PS2 emulator also does not allow you to dump your own Magic gate data to make a handful of games compatible, so I guess it's whatever.
@@KeinNiemandYeah, I'd say kaze would be better off using these features in a one-off like peach's fury or letting someone else produce a demo using the extra ram once he releases the updated engine's source code
@TheCustomFHD I mean, the game was on PS3 and XBOX 360 as the Switch is more powerful than both of them, but Im guessing it's impressive because of the added things that made it more unsupported with updates
There's another 8KB of SPMEM most people don't know about. Other than RCP tasks, it is also used by boot emulators as part of bypassing the CIC lockout.
Kudos to you for being so incredibly talented at modding and general game design and dev, and still being an absolute boss at making captivating videos. And kudos to Ocaio for making such a beautiful visually appealing video here! The writing style and the palette is so cute-- and the transitions are so streamlined!
Very interesting. For the sake of preservation, we should get this feature into emulators. You should definitely keep making more videos like this. I'm a bit of a nerd and I enjoy learning about weird/interesting hardware things from older computers.
Do i plan on developing N64 games? Absolutely not. Do i enjoy hearing the nitty gritty details about the hardware and its quirks? You bet your bippy I do.
10:25 if you’re using the hidden bits to store dialog, you only need 6 bits, five if you don’t need lower case. Every ASCII letter begins with 01, so those bits are redundant. Since the data is being stored one bit at a time anyway, you can further optimize if you don’t store full bytes when you don’t need to, according to the use case.
Kaze Emanuar needs to collab with Pannenkoek one day. Just imagine what the sage of Mario 64 and the Sage of the Nintendo 64 could achieve if they worked together
Signed in just to leave a comment. No, I don't understand half of what you're talking about, but your passion is worth watching and the deep dive into the technical aspects of the N64 are really fun
Here's timestamps for each of the chapters in this video, and a conclusion chapter for clarity. The video's not particularly long or hard to sift through, but I had some free-time, so why not? 1:15 Chapter 1: Hidden Bits 3:11 Chapter 2: Using Hidden Bits 7:11 Chapter 3: Hacky Workarounds 8:57 Chapter 4: Extra RAM Advantage 11:07 Chapter 5: Donkey Kong 64 12:55 Conclusion I helped add timestamps to a previous video of his as well, so hopefully @KazeN64 will add these timestamps to the description to improve the viewing experience for repeat-watchers.
5:11 If you find a new way of using real hardware in a beneficial way then it's up to the emu developers to support it. Coding with emulator deficiencies in mind won't push emu devs to improve accuracy. One only has to look at the early NES and SNES romhack / translations to see projects that don't run on real hardware because they were built around Nesticle and zSNES behaviours.
This can kind of go two ways. You have Genesis indies who try to account for Mega Drive clones outright missing CPU opcodes, and then you have Wii modders who do cache size nonsense just to screw Dolphin users with weaker CPUs. Neither is reasonable, really.
@@stan-bi3hl It can also be argued that for emulation use, using the 16 MB mode (like devkits had) would be better since you'd have a full extra 8 MB instead of just 1 MB. The PS1 has something similar, with DuckStation having an option to enable 8 MB RAM mode (that's 4x the retail RAM size). Some cheats like the GT2 full detail AI cars make use of this to prevent geometry from flickering. Not all N64 emulators have a 16 MB mode, but it's far easier to implement in comparison. The downside of course is that this doesn't work on original hardware, so you'd need to make the functionality that depends on this mode optional.
It feels like the 9th bit was a left over in the hardware for ECC but there is a means to address it on the N64 through these methods. Some modern DRAM have this ‘hidden’ 9th bit on-die as well (and not just a 9th/10th chip on a DIMM). Also minor correction, ASCII is defined as 7 bit but traditional stored in a single byte for convenience. Upper, lower and the most common punctuation for English can be defined within 6 bits. This for text it’s be possible to hold three characters in 18 bits. As this video shows, it’d take a bit of work and parsing to extract them as intended.
These videos on how the N64 works are always super interesting. It’s fun to learn more about a console that has long since not been made and how even games on there can be further optimized
8:14 - "Whenever we read or write memory, these hidden bits get corrupted." Why does using typically-read-only regions like code help you not corrupt the bits? Won't the memory get read when the code is being executed? Did you not mean to say "read"?
This reminds me of the time I messed with Flash Cs2 to utilize a function to move all enemies at once that doesn't require the use of a FREAKING "while"Loop to work...and give me better performance no matter how many enemies I added to the function; Tried to do that with the loop, and the game stank performance with barely 30 enemies. But with that function..... I could go MAD with 500+ enemies and the game still worked fast enough. It's always fun to see what your hardware or software tools can do to and try to figure out ways to utilize it at your advantage!
4:31 Actually, you dont have to store the upper bits-pixel there bc all ASCII codes start with 0b01. 'a' only needs 3 pixels. You can add back the upper bits later when you reconstruct the letter.
yeah i refer to it as "emulating" features in the video too for this reason. it's clear the marketing claims are not honest but people seem really hyped about it which is why i am going to review it.
Really, the marketing only works because "software emulation" is for some reason a bit of a negative term in some communities and I really don't understand why. Sure, there have been some pretty bad emulators over the years, but the best can either be cycle accurate or use their inaccuracy to their advantage(While Dolphin still has to patch up a lot of edge cases, there are games that legitimately get better results on it than on a real GC/Wii).
@@lpfan4491 I'm thinking it's a mix of outdated info (remembering how PJ64 had low accuracy in 2003) and people just regurgitating whatever they heard on the internet (so business as usual). It is a little frustrating, since emulation is so good now. But hey, it's their loss!
Aye. Unless they’ve got the original netlist for every single part of the N64 at best they’re designing something based on the description provided by the documentation. It might be very good, and incredibly fast, but it’s still just trying to figure out a black box based on its description and poking at it with a stick.
I think there are already several reliable ways to do so already. I remember playing Peach's Fury in RMG and it went straight to 60 FPS automatically without needing me to do anything specific.
I love these types of videos and it would be great if you could make more! It's fun to listen to you talk about a topic you are passionate about and, even though I may not understand all of it, learning about the N64 on such a deep and technical level gives me a greater appreciation of the console, its games and developers as well as the work you put into your rom hacks.
Wasn't DK64's lighting data all cached? So instead of calculating the lights in real-time and keeping a sort of double buffer as it went along, it went through the calculations once, stored the vertex data for every single frame, and then cycled through those cached frames. That was my understanding, anyway. And yeah, there was some broken telephone around the memory leak thing. One of the Conker devs *did* say that DK64's 4 MB mode had to be cancelled due to an unfixable crash bug, but he never claimed that the crash was the reason for the Expansion Pak support in the first place! Filling in the blanks, it would seem that DK64 was always meant to have some Expansion Pak enhancements (like the lighting), but would have offered a downgraded experience for base N64 owners.
that sounds hundreds of times more reasonable, if their plan was to have the option for a precomputed 8mb mode and a slightly more laggy 4mb mode. though i can't imagine the 4mb mode crashing would have been such an impossible obstacle for them.
First off, enjoyed the choice of De Blob (2) music in the intro. Much love for an underrated soundtrack. Back to the video, learning about this kind of bit-hacking is very cool. It feels like a completely different world from low-level programming on modern hardware, especially the kind that runs in PCs/servers/consoles.
That was a fun deep dive, you always have the nichest insights into the innerworkings of the console and its games. Hope you have a fantastic festive season and happy new year!
I always had my suspicions that the lighting claim was BS for DK64. Glad to know I'm not alone. Once the dk64 decomp is finished (42% of the way there), it'll be fun trying to optimize the heck out of it to give ROM Hacks some more room to work with
Do emulators fail to render the anti-aliasing properly as a result of not emulating the 9th bit? Or do they not emulate the way the N64 GPU works to that extent? AFAIK they might just be translating the instructions given to the GPU by the CPU into a modern shader language like OpenGL or Vulkan.
I've been lurking this channel for years and I wouldn't have your content any other way. Never ever stop breaking down these mechanics far above my paygrade. Sometimes things hit and I get the high orders of amazing progress being made and other times I love getting lost in the woods and looking things up to keep up. Your enthusiasm shines through and I love seeing how modern tricks and understandings can be used produce games that look far beyond what was the norm at the time and like my memories of games I wanted or dreamed about at those times in my younger life simultaneously.
dev here!!! I love this dev videos! and you should ABSOLUTELY use the 9bit and share it with the emulator community, after all, they want ACCURATE emulation, one example of something like this is RE on the GameCube, it had a bug because it was cleaning memory ahead of the audio buffer playing the audio, and the Cube had a set of instructions that was cancelling that code to be ran, when trying to make dolphin accurate, the bug from the game jumped up and didn't knew what was causing it until way later
I love your technical breakdowns! Would be really interested in a video about how and why this was usee in Majoras Mask. (Especially because Majoras Mask suffered from a lot of time crunch meaning they must have had a very good reason to not just reuse the effect from Ocarina)
To be honest I sometimes get a little lost during these more technical videos, but they're some of my favorite to watch! It's so cool to see the problems faced by older generation software from a modern programming view
My guess is it was easier for the example to just say "ASCII is 8 bits" and move on, it's not the topic of this video and it's completely arbitrary data being stored anyway
*technically*, I think some implementations of "pure" ASCII also used the 8th bit for parity? Or maybe that was for FTP in text mode with parity? (I figure you might be interested in the weird edge cases, like me)
Modern gaming feels so bloated today... Like this guy understands how important optimization is. I can't even play all these newer games because Im behind on hardware. Im very impressed, this reminds me of when I was modding and the hacks wouldn't work because of filesize, so I tampered and resized textures and stuff that felt less important until it worked. I wish I studied game design and software more. I know abit of 3dsmax and maya but... not enough. I barely understand coding and scripts as I only know the bare min. I was more an artistic type of guy messing with colors and the way things look
So much can be done on integrated graphics i5 machines ... but nah, the game companies want you to get an expensive GPU for "immersive" redundant story lines, glitches and holes lol
If you want a good modern example of "well optimised games", take a look at doom 2016 on the switch. Either that or how they pulled off Titanfall on the Xbox 360
Fascinating Mr. Kaze! No need to worry about the entertainment value of these videos. So much of this flies over my head, but I find it compelling all the same.
at hardware level, how much RAM can the N64 technicly address? i have seen mods that replace the chips with high density ones that give you 8 mb onboard, if you mod an expansion pack to 8 mb, does the n64 can address the 16 mb??
16 MB could be the hardware limit for fast access RAM, but I'm not 100% confident. Games that are built off the SDK are generally limited to this address space due to the segment address system used by the RSP microcode. A segment address consists of a segment index part of the form x0-xF, followed by a 24 bit offset that maps to a 16 MB block of memory. Idea is the programmer can freely associate a segment to an address (e.g. a pointer to an asset file in RAM), then use the segment address to reference data within that segment. However segment 0 is almost always mapped to address 00000000 so that virtual addresses (CPU addresses in the 80xxxxxx range) can be treated as segment 0 address. If you tried addressing more than 16 MB, you'd go up to the 81xxxxxx+ range, bleeding into segment 1.
The region of memory that maps to the external RDRAMs is large enough to address up to 63MB. With some bank switching tricks it may be possible to address up to 512MB. However, the memory controller in the RCP lacks the capabilities to properly track and refresh more than 8MB of RDRAM, so 8MB is the hardware limit for all practical purposes unless you enter the realm of issuing manual refreshes to the RDRAMs which would cripple software performance. For more info on this you can read the n64brew wiki FAQ
No bro. You are not following your thought to it's full conclusion. If an official game had used this quirk then the emulators would have developed support for it. The only reason they don't have it supported is because nothing have used it's functionality.
I did actually consider that. I doubt that emulators would have wanted to deal with the performance and complexity costs of this, if they even knew the hardware details, at least for a long while. Obviously it would have likely been solved at some point.
We, the Mario audience, are probably filled with people who don't understand code and memory all the way. But we've had many good crash courses, thanks to major content creators like Bismuth, Summoning Salt, and Kosmic. So it's very much enjoyable to follow along with this type of video, knowing that it gives us clues to the kind of work you are doing, towards the release of your game!
I don't always understand everything, but I want you to know that this is the kind of content I subscribed to you for. Going into the details of such old hardware and showing how the time and experience we've had with it can be leveraged to do more than was done in it's time is so cool!! It makes me wonder what we could do if we just stopped upgrading consumer hardware and took the time to learn the ins and outs of what we're currently using
This man is so good at the N64, he figured out how to download more RAM.
He'll find a way to add 9 more RAM , just you wait .
Do you have a bad PC? Click here to download more space!
Why download more RAM when you can straight up use more RAM per RAM?
"You wouldn't steal a RAM"
It's using baker's kilobytes. "9 bits to the byte since you're such a good customer." (From xkcd)
You can almost hear all the iceburg creators rushing to add "the byte's 9th bit" to the bottom layer.
God I can't wait for climate change to really get going on those icebergs
I thought the 9th bit was used as a sort of error decection thing.
(like ethernet cable they have one line that just sends a 1 bit data telling if the 8 bit is even or odd. if it says its even and the byte stream is odd. resent.
works fine as long as the byte error is 1,3,5,7 bit off (its usally 1 bit so) causes probelm is 2 bits are off as that would result in a to says its odd when its odd and still be correct.
@@Zack_Wester in some systems a 9th bit probably does that but it doesn't seem like that's what it's used for in the N64.
@@Zack_Wester yea, that's a parity bit for error correction. Same idea but the hardware doesn't use that bit for that.
Generally only servers or higher-end professional workstations will implement parity on internal memory.
This will be going into my brain files of useless knowledge forever
A proven way to get support for an exotic hardware feature is to make a demoscene demo with it, publish at a major party like Easter Revision in Germany, then suddenly a few weeks later a handful emulators support it.
If that was the case emulators would support mgc2011
@@crashoveride879 Midwest Gaming Classic 2011? What exactly is mgc2011?
@@christopherthibeault7502 According to Google, it's a demoscene demo for the N64. In my experience it seems that home computer emulator devs strive for accuracy while most (not all) console devs just want to get the games working.
Thisss
@@christopherthibeault7502 A demo, I found it pretty easy through a little searching.
0:35 I genuinely doubled-taked (took?) when I heard 9 bit per cell. I thought we were getting into some Apature Science "13% more byte per byte" shenanigans with this.
aperture
@pepejw apetare
@@Rainbro359 apretur
Kaze Johnson here.
‘did a double-take’
I was always worried the N64 didn't have enouguh RAM and now I can finally sleep at night
It can't run a web browser, but then again, neither can anything else.
@@Khwerz Wha?
@@KhwerzWhat are you smoking?
@@Khwerz What on EARTH are you talking about you absolute LUNATIC?
@@Khwerz are you good bro
Imagine being so good with the hardware you can create a 9th bit with your mind.
Chakrom: With your miiiind.
@@Blackpapalink god damnit 10 minutes and someone already got the reference XD
(blows up 9th bit with mind)
@@pixelator5312i was thinking the same thing lmao
@@pixelator5312 ''my fucking rambus''
This dude's mind will melt when he discovers the Gamecube.
Can you imagine what he could pull off on a GameCube though???
@@DarkUndeadSpawn honestly it might be comparable to what is achieved on the original Xbox
maybe not, n64 is full or quirks, maybe the gamecube is too normal for him lol
Gamecube is kind of boring in comparison as far as abuse potential.
@@SianaGearz:( thats disappointing
It always shocks me to see just how different old consoles were from standard computers, unlike current ones which often just use off the shelf parts.
Edit: I did not mean this as a bad thing towards modern consoles lmao
Standardization is great, isn’t it?
Comments like this makes me wish more channels turned off their comments.
@@erik3371he's not wrong. Modern consoles use very similar, if not cut-down, parts and components from Custom PC Parts. Right now it's the 4700G (without the igpu) and rx 6700 non xt. It's cheaper to buy what already exists (architecture wise) instead of spend money in R&D to make a custom part. That's why consoles are cheaper.
@@erik3371 I agree in this case but would like to know if we think like that for the same reasons, could you elaborate?
@@erik3371most of your comments on this channel are lame ragebait. Find a hobby man
Dev here... those technical explanation videos are actually what I am looking forward to the most, and I do not even work with the N64 myself lol
I'm currently studying animation, but I've been in the game modding scene for 10 years now, and these kinds of videos just make my day.
You're most definitely not alone, there are not 300 thousand N64 developers on earth.
they are cool, but 80% of the people just watch for fun, not knowing wt,, these mean
If Kaze keeps this up, my next GPU upgrade will be an N64 and the most powerful game engine will be the Super Mario 64 one.
Crazy to think what our modern computers would be capable of if they were optimized to the same degree
@@ENCHANTMEN_ They have too many built-in security and consistency features for such bleeding-edge optimisation. As cool as ACE is, you absolutely don't want to risk RCE.
(Although Final Fantasy Crystal Chronicles has a few equipment glitches that are actually RCE!)
So much software from over the decades was built on top of these messy foundations. Why rebuild it when you can throw more silicon at it? Besides, it would probably take a lifetime to undo the gordian knot of software interactions. A lot of the problems are in code that you don't have access to, like the OS itself. There's a whole ecosystem of garbage to navigate now. Maybe the industry will be willing to roll up their sleeves once Moore's Law dies for good... and everyone gets past the existential crisis that presents.
@@KopperNeomanAnd on modern computers self modifying code is generally a lot slower than treating your code as read only. It messes with all kinds of pipelining and other hardware optimisations.
Moores law is already dead
13:29 Worth checking if the MiSTer's N64 core handles this correctly. If it doesn't, it's not entirely outside the realm of possibility that Robert Peip would implement it. He called the N64 core "done" over a year ago, but when new info surfaced on how to address the handful of games that had crashes because of timing limitations in the DE-10 nano board, he added bug fixes for them.
Mister is nearing end of life and the N64 core will never been 100% accurate with 100% of games. And even if the average person bought the Mister kit, they could never set it up properly. Analogue 3D is idiot proof and even Everdrive 64 is not hard (just drag da roms into the SD card). Analogue 3D is going to democratise what Mister N64 project has been trying to do.
@@keaton718 Democratise what? Analogue isnt known for taking user feedback in any timely manner.
@@Cicirifu It democratises actually using FPGA to play N64 games. In exchange for money and waiting lists.
@@keaton718 what are u on about?
@@keaton718 Do you even know what democratize means?
I've known about the 18-bit color buffer and coverage values for a while. A while back, I wrote a software rasterizer that outputs to a bunch of obscure color formats, and one of the things I did was simulate how the Nintendo64 does antialiasing.
Basically, the way that it works is that in the triangle rasterization code, you use fixed point coordinates with 2 fractional bits, which permits a 1/2^2 = 0.25 pixel precision. For the first and last scanline of the triangle, you map the fractional bits [0, 3] of the Y coordinate to a 4x4 vertical coverage mask (a 16-bit unsigned integer). For each scanline, you also use map the fractional bits of the X coordinate for the first and last pixel on the line to a 4x4 horizontal coverage mask. You then do a bitwise AND to combine the two coverage masks, do another bitwise AND with a checkerboard-patterned dithering mask, and then map the result to a coverage value [0, 7] based on how many bits are still set. If all 8 bits are set, wrap it back around to zero.
This 3-bit coverage value is sort of like an alpha value, but not quite. It basically identifies whether or not a pixel is part of a silhoutte. A coverage value of 0 means that the pixel is either fully covered or fully uncovered, and thus nothing should be done. Any other value represent a constant that's used to do linear interpolation between the "foreground color" (the color of the pixel in question) and the "background color" (a combined color of the surrounding pixels. This has the effect of blending silhouette pixels into the background, thereby achieving an antialiasing effect; and in a way that requires *far* less memory or computational power than techniques like supersampling or jittering + accumulation buffering. On the N64, this post-processing effect is done in hardware, but in my code, I was basically writing coverage values to the alpha channel and then doing a tiled rendering of the window.
There's also technically one more aspect that's required to make this all work, which is that the depth buffer has a "delta Z" component that's used to tell whether or not two triangles are coplanar in order to avoid accidentally categorizing the edge pixels of coplanar triangles as part of the silhouette. I never got around to fully working out the details of that.
Fascinating. And then the textures are low enough resolution to never have their own aliasing issues. It's fascinating how different SGI designed this compared to how the PS1 went for a much more naive implementation.
I wish I had math smarts
I love deep dives into hardware tricks that are so obscure that using them wouldn't run on any emulator.
10:58 For those confused: "COMPILE WITH OS" refers to -Os flag in GCC which optimizes for size (and often results in more performance as well due to reduction of CPU cache pressure)
I think evryone who is watching this has used gcc or clang before.
@@Velocifyer
not a safe assumption
@@Velocifyer Nope, I just like modding and nerdy stuff.
I think most people who watch Kaze know about -O2 and -Ofast, with -Os being reserved for people who have watched almost all
@@Velocifyer I have been using GCC for a decade, and do not automatically assume '-Os' when I read 'OS'. Believe it or not, 'OS' already has a pretty common meaning in computer science. The video is being needlessly confusing.
I heard the words “9 bit memory bus” and had to take a moment to process. Incredible
It's just the same as parity RDRAM where they are abusing the parity bit for other stuff than parity.
14:09 Completely unrelated, but I really like the "Please Feed The Animals" sign. Nice touch.
I grew up playing N64, and later became a computer engineer. I love hearing about the engineering and quirks of this console, please continue!
"unlocking the 9th bit" reminds me of someone who asked to disable the verification bit of ECC RAM to gain that bit back in addressable space
Error correction is exactly what RAMBUS dudes intended these bits for, as well. SGI decided to abuse them for extra antialiasing bits in framebuffer as Kaze explained, but my understanding was that they were impossible to access otherwise.
you know eventually you'll have to make something like a demoscene demo that showcases all this stuff you've uncovered properly. like a rotating fractel with fur rendering over its surface and ray traced lighting to light the scene
In all seriousness, I prefer what he's doing so much more than the demoscene stuff. There are so many cool tricks in those demos, but it's so much more satisfying to see them used in the context of a full game! But yes, Kaze, please throw in a boss character with fur rendering! :P Maybe Cat Bowser can return? (It's basically just a bunch of transparent textured shells, right? Can the N64 render that quickly enough, since we know the order in which to draw them, and Z sorting could be specified manually?)
Being unsupported by emulators is exactly WHY it should be used, as much as possible, so the emulators are fixed to work properly.
It's used in 1 of some 400 games, and just to make a rendering mask. You'll be pressed to find people who care that much about emulator accuracy
@@GabrielAKAFinn maybe if there was some impressive demo or game using it emulators would care about supporting it
@@GabrielAKAFinnI'd say "striving for 100% accuracy is the spirit of emulation!", but the goofy popular PS2 emulator also does not allow you to dump your own Magic gate data to make a handful of games compatible, so I guess it's whatever.
@@KeinNiemandYeah, I'd say kaze would be better off using these features in a one-off like peach's fury or letting someone else produce a demo using the extra ram once he releases the updated engine's source code
@@bastel_art He could make a Mario-themed compatibility benchmark that an emulator has to pass to claim 100% accuracy.
We need more versions of kaze for the rest of the nintendo consoles.
This type of videos are very interesting
I can't wait for 2040 when we'll have a kid from my generation doing this on the switch
@@mariogariazzo2024 afaik and iirc, there is a group porting gta v to the switch..
@TheCustomFHD Ok?
@TheCustomFHD I mean, the game was on PS3 and XBOX 360 as the Switch is more powerful than both of them, but Im guessing it's impressive because of the added things that made it more unsupported with updates
@@jorgeparrales7108 False.
There's another 8KB of SPMEM most people don't know about. Other than RCP tasks, it is also used by boot emulators as part of bypassing the CIC lockout.
1:24 I legitamately thought he was gonna say parallel universes
Nah that was Google this week
Me too lol
That's where the hidden bits are.
It HAD to be a reference to that SM64 video, right??? 😂
*BACKWARDS LONG JUMP SOUND*
Dont worry I watch these types of videos even if I dont know what youre talking about
We aren't worried, but maybe you should be. 😂
Glad I'm not the only one in this situation 🤣
Me too, I just like watching RUclips videos about any weird nerd-like thing. They just are way more interesting than other types of content.
something something 9 bits something something
lmao
Accessing the 9th bit sounds like accessing the 9th circle of hell
Kudos to you for being so incredibly talented at modding and general game design and dev, and still being an absolute boss at making captivating videos.
And kudos to Ocaio for making such a beautiful visually appealing video here! The writing style and the palette is so cute-- and the transitions are so streamlined!
Very interesting. For the sake of preservation, we should get this feature into emulators. You should definitely keep making more videos like this. I'm a bit of a nerd and I enjoy learning about weird/interesting hardware things from older computers.
Bro, I bet we all are a bit of nerd's who likes to learn about old computer and hardware.
Do i plan on developing N64 games? Absolutely not. Do i enjoy hearing the nitty gritty details about the hardware and its quirks?
You bet your bippy I do.
Please keep making these! I love technical breakdown videos like this and you are great at making them :3
Please make more of these video. I love them.
Surprised nobody went "OMG It's Tyler!".
10:25 if you’re using the hidden bits to store dialog, you only need 6 bits, five if you don’t need lower case. Every ASCII letter begins with 01, so those bits are redundant. Since the data is being stored one bit at a time anyway, you can further optimize if you don’t store full bytes when you don’t need to, according to the use case.
Him: We all know the N64 has 4MB of RAM
Me: Rrrrrrrriiiiiiiiiiiigggggggghhhhhhhttttt. I knew that....
and nowadays 4gb of ram is not enough 😅
Even when they’re trying to compensate for it, experts in anything wildly overestimate the average person’s familiarity with their field.
To be fair, he's channel is about deep dives into Mario 64, the flagship game for the N64
Next video: “I figured out how to make the N64 a quantum computer”
The ninth bit was key, for quantum error correction
i don't know the other guy, but hail to dodongo is also an n64 wizard, check out his channel kaze fans, the dude does bonkerz stuff, truly impressive
What channel do you refer to? Couldn't find anything with 'dodongo' or 'hail to dodongo'
@mmatiasautio HailToDodongo on youtube
@@guillaumefigarella1704 thanks!
Kaze Emanuar needs to collab with Pannenkoek one day. Just imagine what the sage of Mario 64 and the Sage of the Nintendo 64 could achieve if they worked together
we've made a mod called "the ABC trials" together!
@KazeN64 nice
@@KazeN64 I didn’t know that was your work! So cool!
@@KazeN64 it's at 69 likes
Signed in just to leave a comment. No, I don't understand half of what you're talking about, but your passion is worth watching and the deep dive into the technical aspects of the N64 are really fun
Here's timestamps for each of the chapters in this video, and a conclusion chapter for clarity. The video's not particularly long or hard to sift through, but I had some free-time, so why not?
1:15 Chapter 1: Hidden Bits
3:11 Chapter 2: Using Hidden Bits
7:11 Chapter 3: Hacky Workarounds
8:57 Chapter 4: Extra RAM Advantage
11:07 Chapter 5: Donkey Kong 64
12:55 Conclusion
I helped add timestamps to a previous video of his as well, so hopefully @KazeN64 will add these timestamps to the description to improve the viewing experience for repeat-watchers.
That smug yoshi has me dying, Great touch to the video lol
The editing is better than usual
I'm glad someone said it, that was the first thing I noticed.
5:11 If you find a new way of using real hardware in a beneficial way then it's up to the emu developers to support it. Coding with emulator deficiencies in mind won't push emu devs to improve accuracy. One only has to look at the early NES and SNES romhack / translations to see projects that don't run on real hardware because they were built around Nesticle and zSNES behaviours.
This can kind of go two ways. You have Genesis indies who try to account for Mega Drive clones outright missing CPU opcodes, and then you have Wii modders who do cache size nonsense just to screw Dolphin users with weaker CPUs. Neither is reasonable, really.
@@stan-bi3hl It can also be argued that for emulation use, using the 16 MB mode (like devkits had) would be better since you'd have a full extra 8 MB instead of just 1 MB. The PS1 has something similar, with DuckStation having an option to enable 8 MB RAM mode (that's 4x the retail RAM size). Some cheats like the GT2 full detail AI cars make use of this to prevent geometry from flickering. Not all N64 emulators have a 16 MB mode, but it's far easier to implement in comparison.
The downside of course is that this doesn't work on original hardware, so you'd need to make the functionality that depends on this mode optional.
A "secret ninth bit" is the sort of thing that would work as an April Fools video. That's how you know it's an incredible discovery.
"9 bit bytes aren't real, they can't hurt you."
9 bit bytes:
It feels like the 9th bit was a left over in the hardware for ECC but there is a means to address it on the N64 through these methods. Some modern DRAM have this ‘hidden’ 9th bit on-die as well (and not just a 9th/10th chip on a DIMM).
Also minor correction, ASCII is defined as 7 bit but traditional stored in a single byte for convenience. Upper, lower and the most common punctuation for English can be defined within 6 bits. This for text it’s be possible to hold three characters in 18 bits. As this video shows, it’d take a bit of work and parsing to extract them as intended.
I will wait 20 years more when this guy optimize Nintendo switch, and make zelta Totk run at 4K 60fps on native console.
Turns out there were pixels BETWEEN the pixels! You just have to bypass the firmware by addressing the screen through the left Joycon.
4K is a gimmick, bro.
@@IncognitoActivado4k is not a gimmick
8k is
@@AlexanderderGroe-rd1nk 8k is not a gimmick
16k is
@@General12th 16k is not a gimmick
32k is
The iQue 64 has 16 MB of DDR ram. I heard it can only address 8 bits so burns the extra RAM with the 9th bit. Well worth exploring as well.
These videos on how the N64 works are always super interesting. It’s fun to learn more about a console that has long since not been made and how even games on there can be further optimized
8:14 - "Whenever we read or write memory, these hidden bits get corrupted." Why does using typically-read-only regions like code help you not corrupt the bits? Won't the memory get read when the code is being executed? Did you not mean to say "read"?
Does look like he misspoke.
But maybe some memory access control changes how "read" works?
oh i definitely misspoke. it only gets corrupted when we write to it. shit!
If it's out of scope here, please make another video describing the masking technique in majoras mask (its my favorite game)
I wonder what OOT did differently.
This reminds me of the time I messed with Flash Cs2 to utilize a function to move all enemies at once that doesn't require the use of a FREAKING "while"Loop to work...and give me better performance no matter how many enemies I added to the function; Tried to do that with the loop, and the game stank performance with barely 30 enemies. But with that function..... I could go MAD with 500+ enemies and the game still worked fast enough.
It's always fun to see what your hardware or software tools can do to and try to figure out ways to utilize it at your advantage!
I'm a dev with 20 years exp, I love these videos from you; that said, you're 100% getting sideeye for that comment about self-modifying code.
4:31 Actually, you dont have to store the upper bits-pixel there bc all ASCII codes start with 0b01. 'a' only needs 3 pixels. You can add back the upper bits later when you reconstruct the letter.
All ASCII *letters* start with 01. ASCII in general only starts with 0
Numbers, control codes, and some punctuation all start with 00
@Starwort Ah yes my mistake
The analogue "this isnt emulation" is marketing hype. It very much is emulation. It's not software emulation.
yeah i refer to it as "emulating" features in the video too for this reason. it's clear the marketing claims are not honest but people seem really hyped about it which is why i am going to review it.
It's like how DECKARD (7500x) model PS2s aren't backwards compatible with PS1 in the true sense.
Really, the marketing only works because "software emulation" is for some reason a bit of a negative term in some communities and I really don't understand why. Sure, there have been some pretty bad emulators over the years, but the best can either be cycle accurate or use their inaccuracy to their advantage(While Dolphin still has to patch up a lot of edge cases, there are games that legitimately get better results on it than on a real GC/Wii).
@@lpfan4491 I'm thinking it's a mix of outdated info (remembering how PJ64 had low accuracy in 2003) and people just regurgitating whatever they heard on the internet (so business as usual). It is a little frustrating, since emulation is so good now. But hey, it's their loss!
Aye. Unless they’ve got the original netlist for every single part of the N64 at best they’re designing something based on the description provided by the documentation. It might be very good, and incredibly fast, but it’s still just trying to figure out a black box based on its description and poking at it with a stick.
I first learned about the 9th bit while studying how framebuffers work, and I've always wondered if it could be exploited.
i love your thumbnails! they really capture the look of nintendo's pre-release promotional materials for mario 64.
true
Probably the most useful thing this could be for is detecting if you’re on an emulator.
I think there are already several reliable ways to do so already. I remember playing Peach's Fury in RMG and it went straight to 60 FPS automatically without needing me to do anything specific.
Next video will be like, did you know the N64 has a hidden Nvidia RTX 4090 24GB gpu?
i work at nintendo and yeah we have that its in our nintendo nintenhouse
3:07 seizure warning
I love these types of videos and it would be great if you could make more! It's fun to listen to you talk about a topic you are passionate about and, even though I may not understand all of it, learning about the N64 on such a deep and technical level gives me a greater appreciation of the console, its games and developers as well as the work you put into your rom hacks.
Wasn't DK64's lighting data all cached? So instead of calculating the lights in real-time and keeping a sort of double buffer as it went along, it went through the calculations once, stored the vertex data for every single frame, and then cycled through those cached frames. That was my understanding, anyway.
And yeah, there was some broken telephone around the memory leak thing. One of the Conker devs *did* say that DK64's 4 MB mode had to be cancelled due to an unfixable crash bug, but he never claimed that the crash was the reason for the Expansion Pak support in the first place! Filling in the blanks, it would seem that DK64 was always meant to have some Expansion Pak enhancements (like the lighting), but would have offered a downgraded experience for base N64 owners.
that sounds hundreds of times more reasonable, if their plan was to have the option for a precomputed 8mb mode and a slightly more laggy 4mb mode. though i can't imagine the 4mb mode crashing would have been such an impossible obstacle for them.
Next, kaze will simulate a quantum accurate copy of the entire universe, with billions of simulated humans, all on the N64 at a trillion FPS
This is insanely cursed
Kaze casually upgrading his editing skills and presentation like:
First off, enjoyed the choice of De Blob (2) music in the intro. Much love for an underrated soundtrack.
Back to the video, learning about this kind of bit-hacking is very cool. It feels like a completely different world from low-level programming on modern hardware, especially the kind that runs in PCs/servers/consoles.
That was a fun deep dive, you always have the nichest insights into the innerworkings of the console and its games. Hope you have a fantastic festive season and happy new year!
I always had my suspicions that the lighting claim was BS for DK64. Glad to know I'm not alone. Once the dk64 decomp is finished (42% of the way there), it'll be fun trying to optimize the heck out of it to give ROM Hacks some more room to work with
Do emulators fail to render the anti-aliasing properly as a result of not emulating the 9th bit? Or do they not emulate the way the N64 GPU works to that extent? AFAIK they might just be translating the instructions given to the GPU by the CPU into a modern shader language like OpenGL or Vulkan.
that is what most emulators do. if you turn off antialiasing, most emulators keep rendering everything antialiased anyway.
At this rate, he will make his N64 a top 500 super computer. keep em coming !
I've been lurking this channel for years and I wouldn't have your content any other way. Never ever stop breaking down these mechanics far above my paygrade. Sometimes things hit and I get the high orders of amazing progress being made and other times I love getting lost in the woods and looking things up to keep up. Your enthusiasm shines through and I love seeing how modern tricks and understandings can be used produce games that look far beyond what was the norm at the time and like my memories of games I wanted or dreamed about at those times in my younger life simultaneously.
Now how long until emulator developers add support for the hidden bits after this video is out?
I'd be interested in an in-depth video about the MM lens effect
Forget "RAM bus go vroom vroom," THIS might just be your "First I need to talk to you about parallel dimensions," Kaze! XD
dev here!!! I love this dev videos! and you should ABSOLUTELY use the 9bit and share it with the emulator community, after all, they want ACCURATE emulation, one example of something like this is RE on the GameCube, it had a bug because it was cleaning memory ahead of the audio buffer playing the audio, and the Cube had a set of instructions that was cancelling that code to be ran, when trying to make dolphin accurate, the bug from the game jumped up and didn't knew what was causing it until way later
I love your technical breakdowns! Would be really interested in a video about how and why this was usee in Majoras Mask. (Especially because Majoras Mask suffered from a lot of time crunch meaning they must have had a very good reason to not just reuse the effect from Ocarina)
Production budget felt extra high today. I've learned a lot about how Hardware actually interacts with the software from watching your videos
I understand little to nothing about the technical aspects, but every single video amazes me. I also play on real hardware
Impressive hardware specialization. Would be nice to see how a 90's computer can emulate the n64 and if that is possible. What would it look like?
There was at least Mario 64 running in I believe 98 or 99 and pretty well at that
To be honest I sometimes get a little lost during these more technical videos, but they're some of my favorite to watch! It's so cool to see the problems faced by older generation software from a modern programming view
4:16 ascii is 7-bit?
My guess is it was easier for the example to just say "ASCII is 8 bits" and move on, it's not the topic of this video and it's completely arbitrary data being stored anyway
@@alydev23 yeah. i think it would be easy to do a two second clarification. but maybe i care about correctness too much
ASCII is only 7-bits, but code pages that use the 8th bit are extensions on top of the original ASCII standard
@@TheLamer5000 i know 👍
*technically*, I think some implementations of "pure" ASCII also used the 8th bit for parity? Or maybe that was for FTP in text mode with parity?
(I figure you might be interested in the weird edge cases, like me)
I'm shocked that the 9th bit wasn't related to ECC
Could you do a followup on how the Majora's Mask code works. How does that take advantage of this?
I love these technical breakdowns! I know they have a smaller audience but as a CS student they’re always my favorite
"but first, we need to talk about" hey i've heard this before
frohes neues jahr, Kaze Ema-nuar!
(hey that rhymes)
Modern gaming feels so bloated today... Like this guy understands how important optimization is. I can't even play all these newer games because Im behind on hardware. Im very impressed, this reminds me of when I was modding and the hacks wouldn't work because of filesize, so I tampered and resized textures and stuff that felt less important until it worked.
I wish I studied game design and software more. I know abit of 3dsmax and maya but... not enough. I barely understand coding and scripts as I only know the bare min. I was more an artistic type of guy messing with colors and the way things look
which I have to say, your very talented with your texture work :)
So much can be done on integrated graphics i5 machines ... but nah, the game companies want you to get an expensive GPU for "immersive" redundant story lines, glitches and holes lol
If you want a good modern example of "well optimised games", take a look at doom 2016 on the switch. Either that or how they pulled off Titanfall on the Xbox 360
You do a great job explaining it in "simple" terms, it's really good work...
A byte is a byte, you can have a 9/8 byte!
I love how good your editing has become
what is the song at 3:11?
Check Mii Out channel theme.
It sounds like man who sold the world
I remember it from the Wii, can't remember what channel. Either the Check Mii Out channel or the Everybody Votes channel.
Fascinating Mr. Kaze!
No need to worry about the entertainment value of these videos. So much of this flies over my head, but I find it compelling all the same.
at hardware level, how much RAM can the N64 technicly address? i have seen mods that replace the chips with high density ones that give you 8 mb onboard, if you mod an expansion pack to 8 mb, does the n64 can address the 16 mb??
I asked some folks who know the N64 about this a while ago. They said the address lines to support more than 8MB just aren't there.
16 MB could be the hardware limit for fast access RAM, but I'm not 100% confident. Games that are built off the SDK are generally limited to this address space due to the segment address system used by the RSP microcode. A segment address consists of a segment index part of the form x0-xF, followed by a 24 bit offset that maps to a 16 MB block of memory. Idea is the programmer can freely associate a segment to an address (e.g. a pointer to an asset file in RAM), then use the segment address to reference data within that segment. However segment 0 is almost always mapped to address 00000000 so that virtual addresses (CPU addresses in the 80xxxxxx range) can be treated as segment 0 address. If you tried addressing more than 16 MB, you'd go up to the 81xxxxxx+ range, bleeding into segment 1.
The region of memory that maps to the external RDRAMs is large enough to address up to 63MB. With some bank switching tricks it may be possible to address up to 512MB. However, the memory controller in the RCP lacks the capabilities to properly track and refresh more than 8MB of RDRAM, so 8MB is the hardware limit for all practical purposes unless you enter the realm of issuing manual refreshes to the RDRAMs which would cripple software performance. For more info on this you can read the n64brew wiki FAQ
These technical breakdowns are my favorite type of video you make. If you enjoy them and find them easiest to make, please keep it up 🎉
Sounds like the ultimate anti-emulation technology. Would have been interesting if an official game had used it for this reason.
No bro. You are not following your thought to it's full conclusion. If an official game had used this quirk then the emulators would have developed support for it.
The only reason they don't have it supported is because nothing have used it's functionality.
I did actually consider that. I doubt that emulators would have wanted to deal with the performance and complexity costs of this, if they even knew the hardware details, at least for a long while. Obviously it would have likely been solved at some point.
When the N64 was around emulators were just barely running SM64.
We, the Mario audience, are probably filled with people who don't understand code and memory all the way.
But we've had many good crash courses, thanks to major content creators like Bismuth, Summoning Salt, and Kosmic. So it's very much enjoyable to follow along with this type of video, knowing that it gives us clues to the kind of work you are doing, towards the release of your game!
I believe there’s a Mister core that runs DK64 properly
These kinds of videos are exactly why I come to your channel.
I get it... It's dark matter. Kaze found dark matter in the N64. But now the frames per second are negative and Mario controls you. Is this right?
You go to the parallel universe where Israel are committing genocide (and you therefore have their flag as your PFP instead)
I don't always understand everything, but I want you to know that this is the kind of content I subscribed to you for. Going into the details of such old hardware and showing how the time and experience we've had with it can be leveraged to do more than was done in it's time is so cool!! It makes me wonder what we could do if we just stopped upgrading consumer hardware and took the time to learn the ins and outs of what we're currently using
A 9th megabyte has hit the N64
The technical breakdowns are my favorite videos from you, keep them coming :)
Is there an alchemist way to combine ps1 and n64 in series?
It exist! Its called the PolyStation 64! 😄