Hey folks! This video recently hit 100k views, which is absolutely mind-blowing. This has become a series and I'm getting close to cracking that opening cinematic! Some context and corrections below: What this codebase is: I called it "source code" but it's really not. Here's the deal: First, Nintendo wrote the original C "source code" for Ocarina of Time. To run it on an N64, they compiled it down to "machine code" that the N64 understands, but is tough for humans to read. The ZeldaRET team then analyzed that machine code and reverse-engineered it into C code that compiles back to the original machine code. So, while both codebases create the same game, they aren’t the same code. Mistakes will be made: I hadn’t touched C in over a decade before this, and I record these off-the-cuff to keep it interesting. Minor mistakes are edited out, and future videos will include corrections when possible. My aim here is to share the process of diving into unknown territory and learning along the way. As one viewer put it, this is like exploring the Water Temple for the first time-but in C. Check out the comments: The comments have been an incredible resource for corrections and in-depth explanations. The community here has been awesome. A huge thank you to everyone who's enjoying the series. I'm glad this is as fun for others as it is for me.
Great stuff bro. Thought you had 2-300k subs upon clicking lol. I'm a new creator and get the same comments, so now I understand how they feel ;) Hope you keep growing, you deserve it
I suppose I cannot exactly blame you for misunderstanding the DmaHandler typedef given that your IDE did not actually take you to the definition of s32 for whatever reason, and function pointer syntax in C is miserable In case it is not mentioned later in the video, and in case anyone is curious: 'typedef s32 (*DmaHandler)(args...)' means that we are defining a type named DmaHandler, which can hold pointers to functions which have the arguments (args...) and return a value of type s32. The definition for s32 itself would look something like 'typedef ... s32'. The name of the type comes last usually. EDIT: Some more notes: 13:45 - A double is a 64-bit floating point value. A 'long long' is a generic type defined to hold at least as much as a 'long'. (It is vague because C's standard does not like to give actual bit counts to anything, so as to be more portable, but on most systems you will ever use, a 'long long' will be defined *in the implementation of the standard* as a 64-bit integer.) 17:55 - A short is usually 16 bits
Small correction: the N64 does not run any operating system. The code runs bare metal. The way those processes are created and handled is via interrupts. Each time a "process" has to run, the cpu jumps to the global exception handler and from there it jumps to the appropriate code (the "process" code)
@@SimoneN64 That seems like an OS? It is obviously far simpler than Windows or Linux, but those are not the only kinds of operating systems. I'm slowly confused by what distinction you imagine there is. Even an OS like Windows does not run code in some magical place; it is still on the CPU, just perhaps in a lower privilege level. And, it also uses interrupts to implement its scheduler!
If you were alive during OOT it was an experience. Everyday go home play, get stuck goto school and at the lunch table everyone would be trying to help each other get further. It was so fun when you found out something the group didn't know. A time when running to guides was way way less common.
You know what’s insane the same thing happened to breath of the wild for me in school and everyone would ask how to get the master sword… but I love all the old games better
Yeah those days were truly magical. My best friend and I resorted to calling a national "nintendo hotline" with a minute fee, where we'd get guidance on how to get unstuck in the Water Temple
my siblings and I pooled our allowance money to get this gem - probably a monthly wage back then in 1999 Nigeria. Booting it in the N64 was a surreal experience. Good times
hey mate, randomly got this in my youtube algorithm. i'm a dev from australia, and i thought this was a really great watch. very fun to see old games dissected and the thought patterns behind them
When I worked at Riot Games, I sometimes had to go through old code bases with no guidance and no documentation. I felt like an idiot, struggling to make sense of it all for long periods of time. This helped my imposter syndrome a bit to see someone else do something similar. Thank you 😂
I’m currently studying CS, I really underestimated how hard it is but I find this super interesting. Thanks UA-cam algorithm for recommending this dudes channel, great video dude
This is my most memorable game I ever played, I think I was around 11 years old when I played it and it took me like 3 months to finish and it was breathtaking all the way through. I did .net and java in university so I could somewhat follow along. What really strikes me is that this was created all by hand, no AI sh*t, nothing, just pure good old fashioned human ingenuity. Loved this video, enjoyed watching every minute of it! Kudos to you mate!
do {...} while(0) is a common idiom for C macros to ensure the body of the macro is a single statement that requires a semicolon after it. Basically, it makes the syntax when using macros identical to when calling a function.
I feel like such a dum-dum every time I try to read a big C project like this alone (coming from a higher level background like C#, js etc). It's so cool to get through it with you and see you have the same question I would have along the way, plus it's easier to see in video format, would love to see other things like these !
OoT started off as an N64DD game originally. So it's interesting that the devs left a lot of that disk drive boot code in the game at the beginning. Also, they were gonna use the storage on the disk to save things like link's footprints in sandy areas etc. It was going to be a persistent open world game, so it's cool to see when they downgraded the game, they left a lot of that ambitious stuff in the code base.
Thanks for posting a video like this. I wondered how programmers often delve into codebases and I wanted to learn from them and you're my first concrete example of how it's done.
Dude thank you for covering this! I'm on a binge of looking at old game source code and trying to mess with it -- please keep it up. I start with doom/wolfenstein, but just as OOT, there are more games out there! Keep it up man
Instantly subbed. I’ve been wanting someone to explore the codebase of this game for a while. The decomp is wonderful I also started streaming/playing master quest and managed to beat the Demi tree so far. 🤘🤘
This was super fun to watch! Would be neat to also see how they go about doing some actions like, how does their ledge detection work, or what goes into Links Attack, etc you name it!
Wow I love that they were using actual musical notation for the ocarina code. I mean of course they were, but you just never think about it unless you see it in text.
im only 10 minutes in but im really enjoying how you're explaining all this. i've been modding zelda oot since like, 2010, but it was all hex values and very rudimentary programs that could only do so much. ever since the game was decompiled, it's been my understanding its the premiere way to mod oot now, but i've never been able to interpret code quite like this. i don't know if you plan to go further, but i would watch a series of this. its pretty good
i just started my first year as CS undergrad, i may not understand everything just yet but the concept of this video is interesting and this was enjoyable to watch. nice video man
@@benvillalobos thank you, and also if you plan on looking into any other games if its possible to access the codebase for mario 64 or Mario galaxy ill definitely be tuning in 😩
Congrats on making a hit video! I found this super interesting. It made a great background video for me while I was studying. It helped me get in the right mindset to try to comprehend the geologic functions of volcanoes. Like coding to understand one thing in geology you need to understand [x] prior functions that make our world turn the way it does. So, thank you for your help! It was fun getting lost in this code of a game I also loved as a kid. When we saw "sword health" I became very curious and personally would've gotten lost down that rabbit hole for awhile, so if you ever figure out what "sword health" is, let me know! Also curious, how many total lines of code the game is, just for funsies. Hope to see more like this from you if you so desire to continue down this rabbit hole. As others have mentioned I'd love to see the likes of FF7, other FF titles, other Zelda titles, and since you seem to like the SuperNin era based on your choice of music, Chrono Trigger would be a neat one.
Oh man I wouldn't be surprised if the entire codebase was in the 100k+ range. Codebases have the habit of becoming jungles over time (or dungeons in this case). I took a note to check on sword health next time I see it. Cheers, and good luck on your studies!
Just found you and really enjoying the video so far. :-) I know it's been two weeks but I think I can add a bit of background to two things in the initial #includes: CIC is Nintendo's copy protection chip. One's on the cartridge, one in the console. N64DD is the Nintendo 64 Disc Drive, a failed addon to the N64. OOT was initially developed as a disc based game for this addon.
Damn, I didnt even know we have access to a decompiled version of OoT. I need to check out that code asap :D This game is literally what even got me into Programming 11 years ago, bc watching Speedruns of it was so mesmerizing. :)
39:10 do { ... } while (0) is an old C trick for defining a multi-statement macro that syntactically sort of behaves from the outside like a function call. It's the nearest macro equivalent to an inline function definition.
Now you can see why companies hesitate to release super old titles that they haven't touched in ages, as well as why it takes so long. This is the sort of thing I do for a living. Not being able to debug the code while trying to figure out what's happening is a nightmare.
@@SuperM789a lot of times it’s not enough, even then companies like Nintendo will want to update UI elements to match newer consoles along with a handful of features
From what I saw here, I would assume newf was the string used to initialize the new save file name, i.e. filling it with blanks for final builds, but for debug builds the string was "ZELDAZ"
Not a coder, but im interested in it and this was fun to watch you poke through this although I understood very little. Would love to see more poking around if youre up to it!
Over the years people have explored this game so hard like it’s the video game form of the Da Vinci code haha. I played this game so many times over the years and even did glitch speedruns when I got older that were fun. OOT itself is this weird game to me that feels very biblical in a lot of ways, and I’ve developed a deep personal connection to it after playing it so much, and mastering the different versions. I can’t really explain why though. I think the SRW series gives me that feeling too, but I dunno. It’s just a mindblowingly cool game.
Just started to dabble in C to learn some programming, this video sure is pretty insightfully for me even though I don't understand too much. Mainly I just wanted to throw in the analogy that watching this is like playing through Water Temple for the first time but in C :P
Does the ocarinanotes struct maybe indicate that they dynamically generated the notes based on a midi input? So instead of manually mapping a c or d or e note to the controller buttons it automatically determined the buttons?
Those kind of markers like the "ZELDAZ" string can be really useful when you have to look at a random piece of binary memory and figure out what is wrong with it.
19:00 i dont know the reason why they coded it like this, but probably the logic goes like this: is doubleMagicAcquired= a flag that is checked at the great fairy that doubles your magic, to see if its should display the cutscene and double it, or if that already happened. yes, you can infer this information from magicLevel, with something like: if magicLevel==16: play the cutscene, multiply magicLevel by 2, recover health to healthCapacity, and recover mana to magicLevel, else recover health to healthCapacity, and recover mana to magicLevel (skip the cutscene)... but that assume that the programer who coded this system already knew the value of the magicLevels that the final game would use, if the beta testers decided that the game is too easy or too hard with the current maximum magicLevel and change it to, lets say 24 (and 48 when doubled), that would have required found this hardcoded reference to the 16 number (if magicLevel==16) and if this value change again and again, the same problem would repeat, so it make sense to have 2 variables, one to see if the magic was already increased and other to register the final value. i dont know why 1 and 2 values were used.
The preprocessor conditionals are curious because those cannot come from decompilation. One could tediously derive local variable and struct field purposes to name them, but you cannot unwind macros or code that was never in the binary.
fb stands for framebuffer, sp stands for stack pointer. Stack Top gets the element from the top of the stack. Surprised you didn't know that, it's usually tought in Comp Sci
If my understanding of the TriForce% from GDC and my own experience with programming is any help: Overlays aren't menus. Menus are overlays. This game, and probably a lot of other games on the N64, tend to use a design pattern where an instance of an object will usually have its methods (Code for acting on their data structure proper.) copied into RAM and executed there, presumably to maximize performance as at this point ROM chips were definitely a lot slower than consoles. I don't know if we saw any of the actual overlay-loading code, but my guess is most the game states, like other objects, make use of this system.
@@Digitalgems9000 actually no, functions, function names and in fact all code is not the same. A decompiler takes machine instructions and translates it into C code that would compile into the original. So functions you see in this version may not even exist in the original. It's the people working on the decompiled version going through and naming things when they try to figure out what it actually represents. And that is why it's misleading to call this the source code for Ocarina of Time because the original source code will be totally different.
@@rosen8757 because i have a codebase for a game called risk your life 2, by planetwide games. it was a big mmo back in the day, and it even has the comments and the old visual studio build files. server library and client side engine. the whole shebang. it's gigantic. looks like a team or studio had to work on it it's so big.
@@Digitalgems9000 in some cases it can, for example if the N64 architecture has some system calls at specific values and the decompiler knows this it can mark those function calls with a correct name, but for any user code no.
The theme is One Dark Pro by `binaryify`. In terms of layout, I have my Primary Side Bar shifted to the right (you can right click it to move it to the opposite side). imo the side bar is cleaner on the right since it doesn't move the code around as you close/open it
i wish people would do stuff like this with other games, like for an actual dev to go through some leaked source (wouldn't touch any rockstar stuff with a 6 foot pole tho) and talk about what's good, what's shit, etc
@@Deczkin the Tetris attack song around the 10 minute mark here: ua-cam.com/video/SLgms78JVo0/v-deo.html thanks for the reminder to credit the playlist in the description!
Those _Init and _Main methods appear to never be called anywhere because they are being set as function pointers to the "state" struct You can see that happen in that SET_NEXT_GAMESTATE macro, ie "(state)->init = newInit" It's just a way to make a generic state object that can run custom "_init" and "_main" methods. The state->main method is invoked in the update loop and state->init is run on inititization of the new gamestate
Hey folks! This video recently hit 100k views, which is absolutely mind-blowing. This has become a series and I'm getting close to cracking that opening cinematic! Some context and corrections below:
What this codebase is: I called it "source code" but it's really not. Here's the deal: First, Nintendo wrote the original C "source code" for Ocarina of Time. To run it on an N64, they compiled it down to "machine code" that the N64 understands, but is tough for humans to read. The ZeldaRET team then analyzed that machine code and reverse-engineered it into C code that compiles back to the original machine code. So, while both codebases create the same game, they aren’t the same code.
Mistakes will be made: I hadn’t touched C in over a decade before this, and I record these off-the-cuff to keep it interesting. Minor mistakes are edited out, and future videos will include corrections when possible. My aim here is to share the process of diving into unknown territory and learning along the way. As one viewer put it, this is like exploring the Water Temple for the first time-but in C.
Check out the comments: The comments have been an incredible resource for corrections and in-depth explanations. The community here has been awesome.
A huge thank you to everyone who's enjoying the series. I'm glad this is as fun for others as it is for me.
Great stuff bro. Thought you had 2-300k subs upon clicking lol. I'm a new creator and get the same comments, so now I understand how they feel ;) Hope you keep growing, you deserve it
I suppose I cannot exactly blame you for misunderstanding the DmaHandler typedef given that your IDE did not actually take you to the definition of s32 for whatever reason, and function pointer syntax in C is miserable
In case it is not mentioned later in the video, and in case anyone is curious:
'typedef s32 (*DmaHandler)(args...)' means that we are defining a type named DmaHandler, which can hold pointers to functions which have the arguments (args...) and return a value of type s32.
The definition for s32 itself would look something like 'typedef ... s32'. The name of the type comes last usually.
EDIT: Some more notes:
13:45 - A double is a 64-bit floating point value. A 'long long' is a generic type defined to hold at least as much as a 'long'. (It is vague because C's standard does not like to give actual bit counts to anything, so as to be more portable, but on most systems you will ever use, a 'long long' will be defined *in the implementation of the standard* as a 64-bit integer.)
17:55 - A short is usually 16 bits
Thank you for such a detailed comment! Your explanation on DEFINE_GAMESTATE is extremely helpful, cheers!
That's why I love humans
You're a complete boss :D
Small correction: the N64 does not run any operating system. The code runs bare metal. The way those processes are created and handled is via interrupts. Each time a "process" has to run, the cpu jumps to the global exception handler and from there it jumps to the appropriate code (the "process" code)
@@SimoneN64 That seems like an OS? It is obviously far simpler than Windows or Linux, but those are not the only kinds of operating systems. I'm slowly confused by what distinction you imagine there is. Even an OS like Windows does not run code in some magical place; it is still on the CPU, just perhaps in a lower privilege level. And, it also uses interrupts to implement its scheduler!
I wish there was more content like this on the platform. I absolutely love watching breakdown of old games. Impressive C knowledge bro
Thanks for the kind words, more to come soon!
If you were alive during OOT it was an experience. Everyday go home play, get stuck goto school and at the lunch table everyone would be trying to help each other get further. It was so fun when you found out something the group didn't know. A time when running to guides was way way less common.
I took the day off work to buy it
You know what’s insane the same thing happened to breath of the wild for me in school and everyone would ask how to get the master sword… but I love all the old games better
Yeah those days were truly magical. My best friend and I resorted to calling a national "nintendo hotline" with a minute fee, where we'd get guidance on how to get unstuck in the Water Temple
@@DanielChristensen-mb5qr The water temple was our depression period lmao. No one could figure it out for weeks
my siblings and I pooled our allowance money to get this gem - probably a monthly wage back then in 1999 Nigeria. Booting it in the N64 was a surreal experience. Good times
hey mate, randomly got this in my youtube algorithm. i'm a dev from australia, and i thought this was a really great watch. very fun to see old games dissected and the thought patterns behind them
This was a total experiment, so I'm glad to see others enjoying it as well!
Same here
ggx profile picture
Epic, super-interesting content!!! Also love the style of the video
Cheers!
Best game man has ever made. Complete game changer in so many ways.
When I worked at Riot Games, I sometimes had to go through old code bases with no guidance and no documentation. I felt like an idiot, struggling to make sense of it all for long periods of time. This helped my imposter syndrome a bit to see someone else do something similar. Thank you 😂
I’m currently studying CS, I really underestimated how hard it is but I find this super interesting. Thanks UA-cam algorithm for recommending this dudes channel, great video dude
There's always something to learn, no matter how long you've been at it :) cheers!
Man, what a nice and different video, i'm not into the code word, but that breakdown of the game was amazing, make more content like this.
As a Zelda Fan & Coder, it makes me really appreciate looking at this code and being able to understand it.
This is my most memorable game I ever played, I think I was around 11 years old when I played it and it took me like 3 months to finish and it was breathtaking all the way through. I did .net and java in university so I could somewhat follow along. What really strikes me is that this was created all by hand, no AI sh*t, nothing, just pure good old fashioned human ingenuity. Loved this video, enjoyed watching every minute of it! Kudos to you mate!
Thanks for the extremely kind comment :D
@@benvillalobos You're most welcome, definitly make more content along the lines of this video, I'm sure many will appreciate the content!
do {...} while(0) is a common idiom for C macros to ensure the body of the macro is a single statement that requires a semicolon after it. Basically, it makes the syntax when using macros identical to when calling a function.
do (...) while(x) can also be used as one would use a while loop but ensure the loop runs once before evaluating if it should run again
Yes, but that's a more commonly understood fact because that's the intended use of do-while loops.
I feel like such a dum-dum every time I try to read a big C project like this alone (coming from a higher level background like C#, js etc).
It's so cool to get through it with you and see you have the same question I would have along the way, plus it's easier to see in video format, would love to see other things like these !
Subscribed!
Never seen your channel, but as a lifelong Zelda fan who recently stumbled into Tech I can say the timing could have never been better
OoT started off as an N64DD game originally. So it's interesting that the devs left a lot of that disk drive boot code in the game at the beginning. Also, they were gonna use the storage on the disk to save things like link's footprints in sandy areas etc. It was going to be a persistent open world game, so it's cool to see when they downgraded the game, they left a lot of that ambitious stuff in the code base.
Thanks for posting a video like this. I wondered how programmers often delve into codebases and I wanted to learn from them and you're my first concrete example of how it's done.
Dude thank you for covering this! I'm on a binge of looking at old game source code and trying to mess with it -- please keep it up. I start with doom/wolfenstein, but just as OOT, there are more games out there! Keep it up man
brb watching more of your series on this
Instantly subbed. I’ve been wanting someone to explore the codebase of this game for a while.
The decomp is wonderful
I also started streaming/playing master quest and managed to beat the Demi tree so far.
🤘🤘
This was super fun to watch!
Would be neat to also see how they go about doing some actions like, how does their ledge detection work, or what goes into Links Attack, etc you name it!
Ocarina of time... What a beautiful memory ❤
This video is incredible man. Thank you for this
This is the equivalent of staring at an absolute breathtaking sunset for me. Video game code is so amazing, I just adore it.
After 6 years of coding and a life-time of ocarina of time worshipping, I am ready for this video.
wow awesome video! Im glad youtube put this in my feed its a super interesting watch
I never write production C in my life, seeing this, I'm truly is a quiche eater
Took me 10 mins to remember I don't understand coding 🤣
Just because you don’t understand decompiled C that came out of Japan doesn’t mean coding is beyond your comprehension
If you ever want to fall down the rabbit hole, check out the free course CS50 by Harvard
Wait this is coding? I thought this was ASMR.
Great idea ! And you are right about the music its so good.
i was ready for this, 20 years ago
lets go
Wow I love that they were using actual musical notation for the ocarina code. I mean of course they were, but you just never think about it unless you see it in text.
im only 10 minutes in but im really enjoying how you're explaining all this. i've been modding zelda oot since like, 2010, but it was all hex values and very rudimentary programs that could only do so much. ever since the game was decompiled, it's been my understanding its the premiere way to mod oot now, but i've never been able to interpret code quite like this. i don't know if you plan to go further, but i would watch a series of this. its pretty good
I didn't know about mermaid, that's really cool! Thanks for making the video, found it fascinating
i just started my first year as CS undergrad, i may not understand everything just yet but the concept of this video is interesting and this was enjoyable to watch. nice video man
Thanks for the kind comment, good luck on the journey!
@@benvillalobos thank you, and also if you plan on looking into any other games if its possible to access the codebase for mario 64 or Mario galaxy ill definitely be tuning in 😩
Oh this is incredible, please make more!!
i used this as my asmr video to calm myself before sleeping
Congrats on making a hit video!
I found this super interesting. It made a great background video for me while I was studying. It helped me get in the right mindset to try to comprehend the geologic functions of volcanoes. Like coding to understand one thing in geology you need to understand [x] prior functions that make our world turn the way it does. So, thank you for your help!
It was fun getting lost in this code of a game I also loved as a kid. When we saw "sword health" I became very curious and personally would've gotten lost down that rabbit hole for awhile, so if you ever figure out what "sword health" is, let me know!
Also curious, how many total lines of code the game is, just for funsies.
Hope to see more like this from you if you so desire to continue down this rabbit hole. As others have mentioned I'd love to see the likes of FF7, other FF titles, other Zelda titles, and since you seem to like the SuperNin era based on your choice of music, Chrono Trigger would be a neat one.
Oh man I wouldn't be surprised if the entire codebase was in the 100k+ range. Codebases have the habit of becoming jungles over time (or dungeons in this case).
I took a note to check on sword health next time I see it. Cheers, and good luck on your studies!
Just found you and really enjoying the video so far. :-) I know it's been two weeks but I think I can add a bit of background to two things in the initial #includes:
CIC is Nintendo's copy protection chip. One's on the cartridge, one in the console.
N64DD is the Nintendo 64 Disc Drive, a failed addon to the N64. OOT was initially developed as a disc based game for this addon.
would love to see a whole series of this with Nintendo's N64 games.
Cracked myself up at "What is fb?". Good stuff.
@3:45 the way you talk about source code,
reminds me of a way to approach sheet music
Damn, I didnt even know we have access to a decompiled version of OoT. I need to check out that code asap :D This game is literally what even got me into Programming 11 years ago, bc watching Speedruns of it was so mesmerizing. :)
39:10 do { ... } while (0) is an old C trick for defining a multi-statement macro that syntactically sort of behaves from the outside like a function call. It's the nearest macro equivalent to an inline function definition.
Dis dude's hair is on another level. It's like, 'what if Akira Toriyama designed Max Fischer from Rushmore?'
Now you can see why companies hesitate to release super old titles that they haven't touched in ages, as well as why it takes so long. This is the sort of thing I do for a living. Not being able to debug the code while trying to figure out what's happening is a nightmare.
and also why they usually just emulate it.
Volunteers made a customizable PC version in a matter of months, what are you talking about?
@@SuperM789a lot of times it’s not enough, even then companies like Nintendo will want to update UI elements to match newer consoles along with a handful of features
high quality content you're going places so i'm subbin to follow!
I would watch 300 hours of this.
That title song hits so hard for me. It’s just a wash of good nostalgia coming over me.
From what I saw here, I would assume newf was the string used to initialize the new save file name, i.e. filling it with blanks for final builds, but for debug builds the string was "ZELDAZ"
Oh this is so dope
Subscribed in hope for more videos like this.
It is the best game ever made, i get goosebumps!!!
17:30 - I imagine that's just the "magic numbers" of a Zelda save file format:
en.m.wikipedia.org/wiki/List_of_file_signatures
Not a coder, but im interested in it and this was fun to watch you poke through this although I understood very little. Would love to see more poking around if youre up to it!
I have been blessed by the algorithm - this is awesome thanks.
If you're taking suggestions: Goldeneye please
Over the years people have explored this game so hard like it’s the video game form of the Da Vinci code haha. I played this game so many times over the years and even did glitch speedruns when I got older that were fun. OOT itself is this weird game to me that feels very biblical in a lot of ways, and I’ve developed a deep personal connection to it after playing it so much, and mastering the different versions. I can’t really explain why though. I think the SRW series gives me that feeling too, but I dunno. It’s just a mindblowingly cool game.
man i wish i can write code like this look so fun
This was pretty fun to watch. Super Mario 64 code is also great to analyze.
How did you link to a ty search like that?
Please continue doing this z64 video series. Triple Like!
my childhood game!
What a nice video. Thanks
Really cool stuff hope i see more
What a time to be alive!
Man you gotta link the playlist to the Nintendo ost that you were listening to! It’s so good
Check the description :)
08:45 DKC bangers make me feel some type of way
really cool video, an instant subscribe
So, have idea to make more this kinda of videos?
Greetings from Brazil
It's already a series ;) Thanks for the comment!
Just started to dabble in C to learn some programming, this video sure is pretty insightfully for me even though I don't understand too much.
Mainly I just wanted to throw in the analogy that watching this is like playing through Water Temple for the first time but in C :P
Does the ocarinanotes struct maybe indicate that they dynamically generated the notes based on a midi input? So instead of manually mapping a c or d or e note to the controller buttons it automatically determined the buttons?
I feel like an alien reading another alien's language
That blue paint/and/or wallpaper reminds me of a certain Scott that says hey all
"ZELDAZ" is probably a "magic number", it must be this exact value. If not, it is sure that the file is not valid.
Those kind of markers like the "ZELDAZ" string can be really useful when you have to look at a random piece of binary memory and figure out what is wrong with it.
19:00 i dont know the reason why they coded it like this, but probably the logic goes like this:
is doubleMagicAcquired= a flag that is checked at the great fairy that doubles your magic, to see if its should display the cutscene and double it, or if that already happened.
yes, you can infer this information from magicLevel, with something like: if magicLevel==16: play the cutscene, multiply magicLevel by 2, recover health to healthCapacity, and recover mana to magicLevel, else recover health to healthCapacity, and recover mana to magicLevel (skip the cutscene)...
but that assume that the programer who coded this system already knew the value of the magicLevels that the final game would use, if the beta testers decided that the game is too easy or too hard with the current maximum magicLevel and change it to, lets say 24 (and 48 when doubled), that would have required found this hardcoded reference to the 16 number (if magicLevel==16)
and if this value change again and again, the same problem would repeat, so it make sense to have 2 variables, one to see if the magic was already increased and other to register the final value.
i dont know why 1 and 2 values were used.
ZELDAZ is the equivalent to BM in a .bmp file or JFIF in a jpg file, or MZ in a executable PE/COFF file from Windows.
Rode the algorithm all the way here!
A video on how to compile into a useful rom would be helpful !
Not going to lie, when I saw the thumbnail I thought it was Dave Grohl playing zelda.
bro you gotta keep doing these videos! this was so informative!
This is me trying to review one of my coworkers Pull Requests
The preprocessor conditionals are curious because those cannot come from decompilation. One could tediously derive local variable and struct field purposes to name them, but you cannot unwind macros or code that was never in the binary.
Guessing the ZELDAZ might be an error checker for corrupt saves - ie the bytes need to start with that string to be a zelda save just a guess though
fb stands for framebuffer, sp stands for stack pointer. Stack Top gets the element from the top of the stack. Surprised you didn't know that, it's usually tought in Comp Sci
what is the song in the background ? 4:00
Amazing video !
Waterworld SNES soundtrack - Map. The playlist used is in the description. Cheers!
OoT is my #1.
Love this
If my understanding of the TriForce% from GDC and my own experience with programming is any help: Overlays aren't menus. Menus are overlays.
This game, and probably a lot of other games on the N64, tend to use a design pattern where an instance of an object will usually have its methods (Code for acting on their data structure proper.) copied into RAM and executed there, presumably to maximize performance as at this point ROM chips were definitely a lot slower than consoles. I don't know if we saw any of the actual overlay-loading code, but my guess is most the game states, like other objects, make use of this system.
awesome!
I listen to this before sleeping. I don’t know shit about coding, I’m not a native English speaker, I just like Zelda. lol
This was fun man, thanks! SNES Drunk background music?
He makes a good mix 👌
How did they get symbols (variable names, function names, files, etc) out of decompiling the ROM?
The ROM contains a bunch of debug messages, containing the names of variables, functions, and files.
This is not the source code for ocarina of time, this is a decompiled version
isn't it similar enough though? function names and stuff are the original, correct? maybe just comments are missing?
@@Digitalgems9000 actually no, functions, function names and in fact all code is not the same. A decompiler takes machine instructions and translates it into C code that would compile into the original. So functions you see in this version may not even exist in the original.
It's the people working on the decompiled version going through and naming things when they try to figure out what it actually represents.
And that is why it's misleading to call this the source code for Ocarina of Time because the original source code will be totally different.
@@rosen8757 ohh yeah that makes sense. i agree then, it's not the same at all. i thought a decompiler could xfer the function names and stuff
@@rosen8757 because i have a codebase for a game called risk your life 2, by planetwide games. it was a big mmo back in the day, and it even has the comments and the old visual studio build files. server library and client side engine. the whole shebang. it's gigantic. looks like a team or studio had to work on it it's so big.
@@Digitalgems9000 in some cases it can, for example if the N64 architecture has some system calls at specific values and the decompiler knows this it can mark those function calls with a correct name, but for any user code no.
i have no idea what is going on but i enjoyed this anyway
i love the mysterious bg music to this
Donkey Kong country!
Do you have a theme or layout for Visual Studio Code? (it looks like you are using that)
I really like your setup
The theme is One Dark Pro by `binaryify`. In terms of layout, I have my Primary Side Bar shifted to the right (you can right click it to move it to the opposite side).
imo the side bar is cleaner on the right since it doesn't move the code around as you close/open it
@@benvillalobos thanks! I agree about the primary bar. It's the way Visual Studio has it as well of course.
i wish people would do stuff like this with other games, like for an actual dev to go through some leaked source (wouldn't touch any rockstar stuff with a 6 foot pole tho) and talk about what's good, what's shit, etc
like ive literally been looking for this kinda thing pretty much since the sm64 decomp finished
what's the music around 5:46?
@@Deczkin the Tetris attack song around the 10 minute mark here: ua-cam.com/video/SLgms78JVo0/v-deo.html thanks for the reminder to credit the playlist in the description!
Those _Init and _Main methods appear to never be called anywhere because they are being set as function pointers to the "state" struct
You can see that happen in that SET_NEXT_GAMESTATE macro, ie
"(state)->init = newInit"
It's just a way to make a generic state object that can run custom "_init" and "_main" methods. The state->main method is invoked in the update loop and state->init is run on inititization of the new gamestate
Good shit I can vibe to.
Thanks for being smart.. making life fun for us all :) I could never lol
38:55 look up do {...} while (0) in macros
it's so the macro's expansion doesn't end in a semicolon
13:51 no a double is a floating point, longs are integers. both are still used today as is the language that is made in ~.~