don't even think you can monetize videos when the account is registered on most parts of the world other than the usa. can't find it anywhere in my account for one thing. lol. youtube never understood much of the 'open one office in pakistan and just send everyone bitcoin' thing and think they have to open 'local offices' with 'local payment bullshit' everywhere. lol. for all i care they just pop the cash in an envelope. works anywhere where there is a mailman ;)
@jj zun i have experience yes but understanding the whole background of a system is another level of expertise you have to gather, and im thankful for every useful plate someone is able to serve.
Oh man, this series is coming at the best time. I love you. May I recommend Ben Eater's 8 bit computer on bread boards series for anyone wanting to understand the electrical underpinnings of a CPU.
Hardware Engineers have the Truth Tables, State Tables, Transition Tables, Implication Tables, and K-Maps of your Basic Logic Gates and the combinations of them!
I can't stop giggling. You have taken me right back in time. I wrote a 6800 Emulator (Dissassembler) in Pascal, during my second year at University in 1984! The Ureka moment for this most daunting of tasks was when I devised the table of Instructions and Addressing Modes. Once I'd created the table, the implementation of the CPU was a doddle. I love the elegance of your C++. You are a very clever cookie.
@53:43: This is an attempt to clarify a potential point of confusion for others who may not be too familiar with the stack. Normally, the stack pointer (i.e. `stkp`) should be pointing to the element at the top of the stack. However, in the code as shown, the `stkp` isn't really pointing directly to the top element. Rather, it's pointing to the (logically) "empty" location where the next element should go when pushed, which is why the `write(0x0100 + stkp, a)` call is made first in `PHA` before decrementing the pointer with `stkp--`. Consistent with this, in `PLA`, you can see that the `stkp` is first incremented before reading, so that it moves from the (logically) "empty" stack position down to the actual top element in the stack. I mention this because "normally", you'd expect the `stkp` to be pointing to the top element directly at all times, which would mean that on push, you'd be `stkp--` and then `write(...)`, and on pop you'd be doing `read(...)` and then `stkp++`, in that order. BTW, if you're wondering why `stkp` is decremented in value when the stack itself is supposed to be growing in size (and vice-versa), the reason is that stacks grow from high memory addresses down to lower memory addresses. GG
Same! I'm totally satisfied with this episode too, all the juicy details I wanted are included in a way which makes more sense than it ever did before!
It takes some skill to create something that a curious layman can follow and yet someone more tech-minded can actually use without being condescending. Hats off to you, sir. There’s something for everyone here!
Since your first video I already started building my own Emulator. You were right, it is such a wonderful project to work on. It was something I also wanted to do a long time ago, and your videos gave me the motivation to start. Thank you for that, and for making the videos so didactic.
In 1985 I was in computer science school and we did a course where you did a simulation of a assigned processor archeture and proceeded to write an assembler to feed the first program you wrote. So I fired up my new ibm clone with 256ram and two 360k drives and i put turbo pascal 3 in it with a tsr to give me source level debugging and off I went. Our processor was limited so you got the idea of address modes and instruction variants without the repeated details of even a 6502. But yes this was a awesome walk down memory lane watching this video. I was yes, Yes, and YES the whole way through. Nice for you to say this was not your first effort on this but a refined result. Because it looked VERY refined...awesome.
System Designers back in the day were geniuses. I had to design a Single Cycle CPU that performed all the bit wise operations and arithmetic operations for my computer organization class. It fried my brain by the end of the semester. Thanks for the vid it improved my knowledge of system design but also C++.
Uhhhh... I was so looking forward for this! I just wanted to say: Thx for your awesome work here! I'm learning so much from every single video you are posting. So much detail, so much passion. Again: Thx for sharing this stuff with us.
It’s beautiful seeing a deep-dive into the 6502 like this in video form. Even the simplest of microprocessor trainers don’t get this absolutely simple, I love it! Can’t wait to see you go through the rest of the NES’s hardware like this, this series is taking my knowledge from a rough, “good enough but never great” understanding to something much more refined and even simplified. Thank you very much for everything you’ve done so far, and I can’t wait for the rest of this series!
Fills so many gaps I never cared about to fill back in the days though it was all in front of me... had to care about so many other things. Great video.
I spit my coffee out when you said your wife checked the lookup table. Wow you are a lucky guy. I have so much information to watch with your channel. Thanks Dr. David.
Got a Sir David Frederick Attenborough vibe at 1:05:35 Your inflection was good. And the resolution inflection made me feel like I was watching David on the BBC nature channel. LOL. I admire your work, and your choice to not put ads in your videos.
I taught myself 6502 30-odd years ago as a 15 yr old and guessed at what your emu code would look like (which in fact was my assumption as to how I’d write one). This tho has been a masterclass. I can’t wait for the rest. Thank you sir!
Thanks Matt, I'm approaching the series with broad strokes, and the devices get more complicated as we progress so it will need a bit of "filling in the gaps" later.
I've tried to do something similar on my own before from reading the documentation from nesdev, and from listening to others but the one thing I kept struggling with was the different addressing modes. After following your source and typing it by hand in my own IDE, as I was reading through the mnemonics or functions and seeing how you implemented them in C++ then I started to understand the actual internal hardware of the CPU. I've worked in Logisim to create simple 4 bit single phase single address CPUs which are quite easy to build from basic gates, but now I think I finally got the full grasp of the different addressing modes of the 6502. I really appreciate videos like this; they help to fill in the gaps! After you complete this series I think building the 6502 - NES in Logisim as a step by step set of tutorial videos would be another exemplary set of worthwhile videos! I was hoping that Ben Eater would take his 8-bit Bread Board CPU and do the same in Logisim! Who know's maybe one day!
Amazing Video. I'm having fun cause I'm converting the code to C#. I've always wanted to write a NES emulator and I'm a C# guy so your video is a perfect match. You're helping me understand how they wrote a NES emulator in Javascript and other languages.
Hobbyist programmer here, but I haven't had the opportunity to write any software in years. Watching you write this NES Emulator is both so incredibly satisfying (your presentation, voice, style and knowledge is amazing) and inspiring (I wanna write something like this now - you make this large project seem do-able!). Thank you for sharing your obvious passion!
Totally hooked on this series having both played NES as a kid and later gone into _higher_ level programming; this brings back CompSci memories but if only those lectures were taught in this way.
I actually tried my hand at writing a 6502 emulator many years ago (I wanted to try making an NES emulator too), and I've got the code open while looking at what you're doing. Unsurprisingly, your implementation is *much* nicer - I used giant switch statements to process opcodes instead of function pointers, for example, and I never implemented a proper bus, choosing to just create a single 64K block of RAM, which meant I would have had to refactor things to get the other devices hooked up once I got past the mere CPU emulation stage. I doubt I'll revisit the project again, but I really enjoy watching someone that knows what they're doing go through the same steps that then-20-year old me did so many years ago.
This is amazing work. I've been trying to get a 6502 emulator going in Common Lisp for the last few months and it has been slow... Your work is extremely useful! You've inspired me to revisit my own implementation.
Usually I'm watching videos like this with x1.75 speed to get quickly what I need to know, but there is no need to do that with your videos. Very good work. Much appreciated. God bless.
Wow. Thank you! I'm studying computer science and I was having a bad time understanding assembly code and instructions. This project helped me a lot! Just finished writing my implementation in dotnet:)) looking forward for the next episode!!
Dude you have explained everything and implemented everything so abstractly and succinctly that I watched the whole last one, saw this one come out and watched it straight away.. Thanks for a great video, and I really hope you make this a great series! It's absolutely fascinating!
The video was wonderful, interesting, educational,easy to understand and decently paced. I also greatly appreciate the little things to do in your code for clarity, such as "x + 0" when getting the low byte of an adress so you don't think x is one greater than it actually is.
Its interesting Dan, people than "can" code already tend to give me grief about doing things like that, but I firmly stand by it as a way of enforcing mental clarity. Glad to see others appreciating its value!
@@javidx9 I really dislike is the, maybe subconscious, "elitism" you sometimes see. Code which is undocumented just because it's a cool trick trick that only "proper" coders would understand, etc. I say keep doing what you're doing! The videos are properly educational and exciting to watch, clearly made by someone who knows their stuff.
Only 5 minutes in and I can already tell this video is a great resource for anyone interested in 6502 and probably any processor/microcomputer understanding. Thanks for taking the time to explain things so well 😁
Hi Javidx9! I just want to thank you for making this available!!! In my early teens I wanted to program my own emulator but never knew where to start. I was around the time when NeoRage (first neogeo emulator) was being developed purely in assembly in the 90s and was fascinated by the coders accomplishments. Forward 20 odd years later here I am trying to learn how to make a Nes emulator in C++. I don't have a strong programming background so I have had to watch this several times. I now understand most of your code in this video. I look forward to watching the rest of the series and seeing Nes emulating on my screen. Thank you for making this happen!
Very very well articulated. Having written device drivers for the early part of my life, I know how difficult it was to visualize things.. this is very well done
I'm very glad you're making this series. The acronyms and abbreviations of the code make it fast to read and write (r/w) but is far from being intuitive to grasp at first.
Excellent video. You are a great teacher with very good presentation skills. I'm a self-taught 6502 programmer on a KIM-1 back in 1980-81.Some years later when I got an IBM PC and developed a 6502 table driven assembler in Quick Basic,later Turbo Pascal.
Such an amazing video. Perfect explanation. 10/10 quality. There's a game called Turing Complete that helped me a lot to understand a lot of concepts about CPUs addressed in this video.
Really good. Easy to understand structure and excellent explanation of ADC/SBC and Overflow. Extra good for introducing your olcPixelGameEngine engine and the handy mass:werk assembler.
I just found this series and it inspired me to build a Z80 emulator. It has a lot more instructions than 6502 but i use the ideas presented in this video/series during development. Thank you!
I stole your function definitions and filled the rest in myself. It was a lot of fun. Thank you for taking the time to write them it was a perfect template for me to get right into actually making it. I ended up doing it a bit differently but also similar. I don't really know where to start with the graphics so i look forward to that part. I also made a disassemble function and just finished inserting labels in. Yours looks a bit shorter
What a great instructional video! You tell potential emulator writers first to choose the level of detail at which the emulation will take place, then consistently explain coding choices for staying at that level. I wish I could explain things just as well.
There need to be more people like you in the world! This is some top notch sh*t, and a very few people explain things this good, and let alone make this good of docs + source available for everyone to use (with credits of course :P ) Keep it up, and don't stop teaching!
I stumbled over this when I was writing an emulator for Redcode (the assembly language for Core Wars, a Programming Game). It's fun watching you solve very similar problems than I faced and I kind of wish I could have used C++ as well, but it had to be JS.
Incredible! Been eagerly awaiting this video all week. There's a crater in my office floor where I've been nervously tapping my foot! Awesome video, it paints processor emulation in a simple and elegant light, and makes it appear very achievable.
This is amazing! I know it's a labor of love, but thanks so much for sharing. It really removes some of the more mysterious aspects behind how CPUs work. I'm really looking forward to the rest of the series.
Much respect! Especially when you explained how video editing makes it look much easier, i know alot of people dont realize that and it makes them feel dumb. Suprisingly enough, ive always wondered how to write an emulator, and i was actually pretty close! I dont give many videos a like, but this one is well deserved, by far.
Thanks and much appreciated LittleRainGames, with most of my videos Im always concerned that it makes things look easier than it really is, and I dont want people just jumping into emulation expecting to have mastered it in no time at all. Im pleased this was a good call.
20 seconds in, and this is one of those 1 hour long videos where I KNOW I'm going to watch through everything and I KNOW I'm gonna like it, so there you go, liked it already. Now I watch it.
What a gold mine.. you have one of the best youtube channel ive came across. I can feel how passionate your are about this subject through your explanations and it shows in the overall quality of the content. Amazing work.
wow, this is just amazing! i have only taken a short course on c++ at uni but understood most of what you were talking about, it was all very clear and super interesting. i would have never thought i'd get that much involved into c++
This takes me way back. The first assembly language programming I ever learned was the C64 assembly, which has a 6510 (which is basically a 6502). It was the easiest and most fun I had programming assembly I think. I also watched another video where a guy built a simple computer. That is, he built a CPU using off the shelf electronics, wiring it all up and explaining how the CPU works electrically. It was a great education. Each clock cycle you have electronic "switches" (logic gates etc) which does one thing, like, it gets the instruction, clock cycle, then it maybe read LDA, so the next cycle it transfers the contents of memory into the accumulator. For addition, those four cycles may be that cycle 1 it loads one value into the accumulator, then it loads another into say Y for the next cycle, then it adds the two, and finally, perhaps transfers the result to the accumulator, or maybe sets/clears a flag. The faster the clock, the faster things get done, but it was quite educational. There really isn't any other "programming code" inside the CPU, just a set of electrical switches that are changed around for each cycle of an instruction to complete what it needs to do. Fascinating anyhow, this just adds to that knowledge for me. If you're interested in the series where he builds a CPU, check out his videos, they're amazing in how he explains how exactly a CPU operates, and he explains it like you explain things. Easy to understand. ua-cam.com/video/HyznrdDSSGM/v-deo.html
I had no problems at all understanding this video, since when I was in High School I was programming 6502 assembler on an Apple ][+. This brought back many memories for me. One cool thing about the zero-page memory, I used it to *hack* many games into giving me unlimited lives. My homebrew Apple (I still have it!) had a switch that I could use to switch between AppleSoft and Integer Basic. So I would run a game, and keep note of how many lives it started off with. I would then play the game and get killed, then immediately put the switch to Integer Basic and hit reset (This needed to be done because most games would reboot on reset in AppleSoft), which would put you into the Apple Monitor, where you could examine the memory of the Apple, including the zero page. I would look through all the entries of the zero page, and see if it the count went down one, and keep it's location. Most game programmers put this kind of stuff in the zero-page area. I would start the game again and get killed a few more times, and see if there were zero-page memories that went down at the same time. Then, it was just a matter of loading up the code, using the monitor to look through the game code for something like "DEC $10" and NOP'ing (I still know it as the $EA opcode!) the code out. Then restarting the game, with now unlimited lives! Also, used to freak out schoolmates by putting their name in the game. Anyway, congrats on your 0x64 video. Will also sub as well.
Funny that you happened to be writing an NES emulator at the same as me! Maybe I’ll be able to learn what I’ve been doing wrong when I run into emulation errors. Thanks for your awesome vids, can’t wait for part 3
Excellent content, very easy to understand and follow. Love how you break everything down and the object oriented nature of C++ makes everything so much easier to visualise. I am trying to emulate IA64 architecture and hopefully get it to run Linux and Windows
I'd just like to say thanks for this video! I've recently written a 6502 emulator for a pet project, and it's randomly weirdly similar in design to yours (aside from the PGE)! I'm going to be revising it though as some of your decisions are definitely improvements on my initial code! I'm mostly a hardware guy, but wanted to emulate a 6502 based retro computer I'm working on, which will have pretty advanced graphics, sound and even networking, so should be cool to learn to code on, and play games 😁 I'll also be trying out your PGE as the emulation interface, so thanks again!
Few weeks before I watched this video I got through Ben Eater "Building an 8-bit breadboard computer!" playlist. It helped a lot to understand this topic for not-electronic, not-IT guy like me. For long time I knew some basics how computers work by Ben video series cleared up many confusions and misunderstandings of this topic. The series is bit long (44 of 1-20 min. videos) but it's worth to watch.
I miss probably something, but why we need to add 1 to the address at 35:11 ? Apart of my misunderstanding, you are a god !!! Thank you very much for your videos !!! Words cannot describe the quality of your content !
That was excellent and easy to follow. I hobby code a little in C Sharp (Unity) and LUA (Pico-8 and Pictotron), and as it relates to the 6502 I watch channels like Displaced Gamers. But the assembly-language world has always felt inscrutable black box-y. And yet now, after watching this, I feel like a have a much more clear understanding of the 6502. Thanks!
I honestly expected no less after seeing part #1, but this really shows how great of a complement it can be (for those interested) to Ben Eater's "8-bit computer on a breadboard" series! Love it! I honestly thought of implementing one in software after seeing his video, but didn't even think of pushing it to the extreme and emulate a console! Very inspirational! :-D
I'd just like to take a moment to really appreciate your implementation of the LUT for the instructions. Using the OPCODE as an array index is just genius. My naive approach was just a huge switch statement.
I really enjoy learning from this channel. Excellent and high quality content and free. Reminds me of the channel "Self Sufficient Me", similar accent :) Thanks for sharing.
Wow, these videos are excellent, with clear and concise explanations. You can tell a lot of time and effort went into making these videos by their quality. Thank you for making them and keep up the good work.
@1:03:09 BNE $FA jumps back 4 Bytes to $8010, the disassembly shows $8110 instead. Very interesting to see how you approach writing an emulator, and quite different to how I would have imagined doing it myself. Thanks for this walkthrough.
@@javidx9 if you want to know how addition of signed integers work, there is this one guy on the youtubes named javidx9, who explains it at about @42:40 of this hour-long video ;-)
Outstanding. Simply outstanding. 10/10. Great explanations, great approach of showing the code incrementally, engaging at all times. Thanks a lot, I will be looking forward to the rest of the series!
Can we just take a moment and appreciate the fact that this guy didn't put a single ad on an hour long video?
Thanks! Or any of my videos as it happens 😊
Never has, and doesn't intend to, iirc. Doesn't care about monetizing the channel, only cares about the community, code, and knowledge.
don't even think you can monetize videos when the account is registered on most parts of the world other than the usa. can't find it anywhere in my account for one thing. lol. youtube never understood much of the 'open one office in pakistan and just send everyone bitcoin' thing and think they have to open 'local offices' with 'local payment bullshit' everywhere. lol. for all i care they just pop the cash in an envelope. works anywhere where there is a mailman ;)
can i be your patron? :>
@@ObnovaDomu you certainly can!
1 hour of David speaking about opcodes? Is this heaven?
Not only do you learn about code, but its an awesome insomnia remedy too!
west Virginia
machine code is great for those cold winter nights.
Defeated swordsman pretty sure it's hell
No. Just mean you are crazy, like the rest of us!
Dude, your content is pure gold. I love the fact that you thoroughly explain every concept and not only show the code, while still being concise.
Thanks remique!
which is not only rare but also really awesome as you can follow along while programming in another language!
Man we don’t deserve this!!!! Holy shit
Life goals, having a wife that can double check my opcodes
"men only want one thing and it's disgusting"
@Serena Williams No, having a wife that can double check your opcodes
@Serena Williams Wants ≠ responsibilities
😅👍
I’m on UA-cam since 2005, I never been so excited to see a part 2 video in my entire life!
You are the personification for actual, usefull qualitycontent about c++. Be proud!
Thanks Great Bullet! I just want to show that fun applications are possible and far better to learn from than text books XD
TheChernoProject, Universo Programado and Bisqwit are too, :)
@@javidx9 thats my speech, books are outdated crap for the biggest part.
@jj zun i have experience yes but understanding the whole background of a system is another level of expertise you have to gather, and im thankful for every useful plate someone is able to serve.
@@josemaria2094 All the channels that i like... You're brazilian right?
Wow, you have a very patient and understanding wife.
Oh man, this series is coming at the best time. I love you. May I recommend Ben Eater's 8 bit computer on bread boards series for anyone wanting to understand the electrical underpinnings of a CPU.
Already Watched it; and if you want the math background check out 3Blue1Brown and for In Depth C++; check out Jason Turner!
@@skilz8098 I wanna throw out "The Cherno" as well, his tutorials into C++ are succinct and to the point.
@@deathscreton Yeah, he's good too!
Interesting I am subscribed to all the people named here.
Chemists have The Periodic Table of Elements.
We Software Engineers have The Mnemonic Table of Opcodes.
Hardware Engineers have the Truth Tables, State Tables, Transition Tables, Implication Tables, and K-Maps of your Basic Logic Gates and the combinations of them!
Of each processor
...but there is only one "machine" in chemistry, with a universal set of codes, versus many for the software guys! Can we compile C++ to chemistry?
@@bpark10001 I mean Silicone is a chemical compound sooooo 🤔🤔🤔
The test ROMs are a super nice thing to have.
A wife which is willing to check your code is even better.
Why are you much more interesting than my college professor when talking about the same subject? Good work!
I can't stop giggling. You have taken me right back in time.
I wrote a 6800 Emulator (Dissassembler) in Pascal, during my second year at University in 1984!
The Ureka moment for this most daunting of tasks was when I devised the table of Instructions and Addressing Modes. Once I'd created the table, the implementation of the CPU was a doddle.
I love the elegance of your C++.
You are a very clever cookie.
jesus! Do you still have the code!
@@kkeanie Sadly no. My wife's de-cluttering got rid of my history many years ago.
@@Simple_Simon_UK Bad wife; bad wife!
@@skilz8098 Nah. She's a fantastic Wife. She has put up with my s#it for over 37 years. She just likes to de-clutter once in a while.
@53:43:
This is an attempt to clarify a potential point of confusion for others who may not be too familiar with the stack. Normally, the stack pointer (i.e. `stkp`) should be pointing to the element at the top of the stack. However, in the code as shown, the `stkp` isn't really pointing directly to the top element. Rather, it's pointing to the (logically) "empty" location where the next element should go when pushed, which is why the `write(0x0100 + stkp, a)` call is made first in `PHA` before decrementing the pointer with `stkp--`. Consistent with this, in `PLA`, you can see that the `stkp` is first incremented before reading, so that it moves from the (logically) "empty" stack position down to the actual top element in the stack.
I mention this because "normally", you'd expect the `stkp` to be pointing to the top element directly at all times, which would mean that on push, you'd be `stkp--` and then `write(...)`, and on pop you'd be doing `read(...)` and then `stkp++`, in that order.
BTW, if you're wondering why `stkp` is decremented in value when the stack itself is supposed to be growing in size (and vice-versa), the reason is that stacks grow from high memory addresses down to lower memory addresses.
GG
Thank you. I was confused.
you misspelled stkp as stpk in some instances
@@senatorpoopypants7182 Fixed. Thanks.
I think I'm more exited about the well organized and educational content rather than the NES emulator itself ;)
This is honestly amazing! This is basically a college course that's free. Keep up the good work man!
YES! I was looking forward to second part of this new series.
Same! I'm totally satisfied with this episode too, all the juicy details I wanted are included in a way which makes more sense than it ever did before!
It takes some skill to create something that a curious layman can follow and yet someone more tech-minded can actually use without being condescending. Hats off to you, sir. There’s something for everyone here!
Thanks boredfish, I appreciate that, as it's what I aim for in my videos.
Since your first video I already started building my own Emulator. You were right, it is such a wonderful project to work on.
It was something I also wanted to do a long time ago, and your videos gave me the motivation to start.
Thank you for that, and for making the videos so didactic.
In 1985 I was in computer science school and we did a course where you did a simulation of a assigned processor archeture and proceeded to write an assembler to feed the first program you wrote. So I fired up my new ibm clone with 256ram and two 360k drives and i put turbo pascal 3 in it with a tsr to give me source level debugging and off I went. Our processor was limited so you got the idea of address modes and instruction variants without the repeated details of even a 6502. But yes this was a awesome walk down memory lane watching this video. I was yes, Yes, and YES the whole way through. Nice for you to say this was not your first effort on this but a refined result. Because it looked VERY refined...awesome.
You did your whole presentation, outside, in the heat and didn't take one sip of your soda.
You absolute legend. XD
System Designers back in the day were geniuses. I had to design a Single Cycle CPU that performed all the bit wise operations and arithmetic operations for my computer organization class. It fried my brain by the end of the semester. Thanks for the vid it improved my knowledge of system design but also C++.
Uhhhh... I was so looking forward for this!
I just wanted to say: Thx for your awesome work here! I'm learning so much from every single video you are posting. So much detail, so much passion. Again: Thx for sharing this stuff with us.
Hey my pleasure donnerbrenn!
The amount of effort you are putting.... not even a paid professor in a University would do the same thing...
Hats off to you good sir!
It’s beautiful seeing a deep-dive into the 6502 like this in video form. Even the simplest of microprocessor trainers don’t get this absolutely simple, I love it!
Can’t wait to see you go through the rest of the NES’s hardware like this, this series is taking my knowledge from a rough, “good enough but never great” understanding to something much more refined and even simplified. Thank you very much for everything you’ve done so far, and I can’t wait for the rest of this series!
Fills so many gaps I never cared about to fill back in the days though it was all in front of me... had to care about so many other things. Great video.
Incredible stuff - I programmed 6502 back in the day, and this brought back a lot of memories.
I spit my coffee out when you said your wife checked the lookup table. Wow you are a lucky guy. I have so much information to watch with your channel. Thanks Dr. David.
Got a Sir David Frederick Attenborough vibe at 1:05:35
Your inflection was good. And the resolution inflection made me feel like I was watching David on the BBC nature channel. LOL.
I admire your work, and your choice to not put ads in your videos.
I taught myself 6502 30-odd years ago as a 15 yr old and guessed at what your emu code would look like (which in fact was my assumption as to how I’d write one). This tho has been a masterclass. I can’t wait for the rest. Thank you sir!
Thanks Matt, I'm approaching the series with broad strokes, and the devices get more complicated as we progress so it will need a bit of "filling in the gaps" later.
I could listen to this top bloke talk about CPU architecture all day..
I've tried to do something similar on my own before from reading the documentation from nesdev, and from listening to others but the one thing I kept struggling with was the different addressing modes. After following your source and typing it by hand in my own IDE, as I was reading through the mnemonics or functions and seeing how you implemented them in C++ then I started to understand the actual internal hardware of the CPU. I've worked in Logisim to create simple 4 bit single phase single address CPUs which are quite easy to build from basic gates, but now I think I finally got the full grasp of the different addressing modes of the 6502. I really appreciate videos like this; they help to fill in the gaps! After you complete this series I think building the 6502 - NES in Logisim as a step by step set of tutorial videos would be another exemplary set of worthwhile videos! I was hoping that Ben Eater would take his 8-bit Bread Board CPU and do the same in Logisim! Who know's maybe one day!
Amazing Video. I'm having fun cause I'm converting the code to C#. I've always wanted to write a NES emulator and I'm a C# guy so your video is a perfect match. You're helping me understand how they wrote a NES emulator in Javascript and other languages.
It's one of those videos that gets you tempted to make several youtube accounts just so you can like it more than once.
Finnaly to the end. took me a few sessions. This was an amazing video thank you!
Hobbyist programmer here, but I haven't had the opportunity to write any software in years. Watching you write this NES Emulator is both so incredibly satisfying (your presentation, voice, style and knowledge is amazing) and inspiring (I wanna write something like this now - you make this large project seem do-able!). Thank you for sharing your obvious passion!
Totally hooked on this series having both played NES as a kid and later gone into _higher_ level programming; this brings back CompSci memories but if only those lectures were taught in this way.
I actually tried my hand at writing a 6502 emulator many years ago (I wanted to try making an NES emulator too), and I've got the code open while looking at what you're doing. Unsurprisingly, your implementation is *much* nicer - I used giant switch statements to process opcodes instead of function pointers, for example, and I never implemented a proper bus, choosing to just create a single 64K block of RAM, which meant I would have had to refactor things to get the other devices hooked up once I got past the mere CPU emulation stage. I doubt I'll revisit the project again, but I really enjoy watching someone that knows what they're doing go through the same steps that then-20-year old me did so many years ago.
A classic Englishman subtle, firm, and with evidence of code, presented by David or Javidx9.
This is amazing work. I've been trying to get a 6502 emulator going in Common Lisp for the last few months and it has been slow... Your work is extremely useful! You've inspired me to revisit my own implementation.
Usually I'm watching videos like this with x1.75 speed to get quickly what I need to know, but there is no need to do that with your videos. Very good work. Much appreciated. God bless.
Wow. Thank you! I'm studying computer science and I was having a bad time understanding assembly code and instructions. This project helped me a lot! Just finished writing my implementation in dotnet:)) looking forward for the next episode!!
I didn't expect to watch the entire hour+, but here I am. This was awesome
51:47 Shouldn't it be A = A - M - 1 + C ?
Yes, nice catch, so the +1 cancels out the -1
Dude you have explained everything and implemented everything so abstractly and succinctly that I watched the whole last one, saw this one come out and watched it straight away.. Thanks for a great video, and I really hope you make this a great series! It's absolutely fascinating!
The video was wonderful, interesting, educational,easy to understand and decently paced. I also greatly appreciate the little things to do in your code for clarity, such as "x + 0" when getting the low byte of an adress so you don't think x is one greater than it actually is.
Its interesting Dan, people than "can" code already tend to give me grief about doing things like that, but I firmly stand by it as a way of enforcing mental clarity. Glad to see others appreciating its value!
@@javidx9 I really dislike is the, maybe subconscious, "elitism" you sometimes see. Code which is undocumented just because it's a cool trick trick that only "proper" coders would understand, etc. I say keep doing what you're doing! The videos are properly educational and exciting to watch, clearly made by someone who knows their stuff.
Only 5 minutes in and I can already tell this video is a great resource for anyone interested in 6502 and probably any processor/microcomputer understanding. Thanks for taking the time to explain things so well 😁
Hi Javidx9! I just want to thank you for making this available!!! In my early teens I wanted to program my own emulator but never knew where to start. I was around the time when NeoRage (first neogeo emulator) was being developed purely in assembly in the 90s and was fascinated by the coders accomplishments. Forward 20 odd years later here I am trying to learn how to make a Nes emulator in C++. I don't have a strong programming background so I have had to watch this several times. I now understand most of your code in this video. I look forward to watching the rest of the series and seeing Nes emulating on my screen. Thank you for making this happen!
Rarely in life have I made a decision so obviously right and immediately rewarding as subscribing to this channel.
Very very well articulated. Having written device drivers for the early part of my life, I know how difficult it was to visualize things.. this is very well done
Wow. This channel has very unique and rare content. I did not knew i lacked so much basic knowledge until i watched David's videos.
I'm very glad you're making this series. The acronyms and abbreviations of the code make it fast to read and write (r/w) but is far from being intuitive to grasp at first.
Excellent video. You are a great teacher with very good presentation skills. I'm a self-taught 6502 programmer on a KIM-1 back in 1980-81.Some years later when I got an IBM PC and developed a 6502 table driven assembler in Quick Basic,later Turbo Pascal.
David, you are great, just so easy to understand and watch. Every your video inspires me. Thank you!
Such an amazing video. Perfect explanation. 10/10 quality. There's a game called Turing Complete that helped me a lot to understand a lot of concepts about CPUs addressed in this video.
Really good. Easy to understand structure and excellent explanation of ADC/SBC and Overflow. Extra good for introducing your olcPixelGameEngine engine and the handy mass:werk assembler.
Thanks xot!
I just found this series and it inspired me to build a Z80 emulator. It has a lot more instructions than 6502 but i use the ideas presented in this video/series during development. Thank you!
Ive been refreshing your channel since part 1... this is SO GUD.
This is so nice, this series is going to be really awesome!
I hope so Mah Moud, thanks!
I stole your function definitions and filled the rest in myself. It was a lot of fun. Thank you for taking the time to write them it was a perfect template for me to get right into actually making it. I ended up doing it a bit differently but also similar. I don't really know where to start with the graphics so i look forward to that part.
I also made a disassemble function and just finished inserting labels in. Yours looks a bit shorter
We do not deserve this amount of quality content and amount of educational resources from your part. Thank you very much!
Greetings from Mexico.
What a great instructional video! You tell potential emulator writers first to choose the level of detail at which the emulation will take place, then consistently explain coding choices for staying at that level. I wish I could explain things just as well.
There need to be more people like you in the world!
This is some top notch sh*t, and a very few people explain things this good, and let alone make this good of docs + source available for everyone to use (with credits of course :P )
Keep it up, and don't stop teaching!
I stumbled over this when I was writing an emulator for Redcode (the assembly language for Core Wars, a Programming Game). It's fun watching you solve very similar problems than I faced and I kind of wish I could have used C++ as well, but it had to be JS.
lol you use the word "solve" very optimistically, thanks Felix!
You should receive the equivalent of noble prize for content creation. Thank you for making this world a better place!
Incredible! Been eagerly awaiting this video all week. There's a crater in my office floor where I've been nervously tapping my foot! Awesome video, it paints processor emulation in a simple and elegant light, and makes it appear very achievable.
This is amazing! I know it's a labor of love, but thanks so much for sharing. It really removes some of the more mysterious aspects behind how CPUs work. I'm really looking forward to the rest of the series.
Amazing content. This is pure gold to someone who is learning systems programming and low level stuff in general. Thank you!
You make complex programing so easy to understand, you sir are a legend!
Thanks Frank!
Much respect! Especially when you explained how video editing makes it look much easier, i know alot of people dont realize that and it makes them feel dumb.
Suprisingly enough, ive always wondered how to write an emulator, and i was actually pretty close!
I dont give many videos a like, but this one is well deserved, by far.
Thanks and much appreciated LittleRainGames, with most of my videos Im always concerned that it makes things look easier than it really is, and I dont want people just jumping into emulation expecting to have mastered it in no time at all. Im pleased this was a good call.
This is a super-duper-awesome video. I can't imagine this video being much better... Thank you so much!
Cheers!
20 seconds in, and this is one of those 1 hour long videos where I KNOW I'm going to watch through everything and I KNOW I'm gonna like it, so there you go, liked it already. Now I watch it.
Congratulations on your 100th video, David! Thoroughly enjoyed it and am looking forward to more. Thanks!
Fab video David! :-) I learned lots and as ever the process was entirely enjoyable!
What a gold mine.. you have one of the best youtube channel ive came across. I can feel how passionate your are about this subject through your explanations and it shows in the overall quality of the content. Amazing work.
wow, this is just amazing! i have only taken a short course on c++ at uni but understood most of what you were talking about, it was all very clear and super interesting. i would have never thought i'd get that much involved into c++
Brilliant. I'm writing a Z80 emulator in Rust, and I am using your video for that purpose. Thanks a lot for the hard work put in those videos.
Thanks for your work sir, I binged on your vids the past week, I was off from work. I wish you the best of luck in all your endeavors.
This takes me way back. The first assembly language programming I ever learned was the C64 assembly, which has a 6510 (which is basically a 6502). It was the easiest and most fun I had programming assembly I think. I also watched another video where a guy built a simple computer. That is, he built a CPU using off the shelf electronics, wiring it all up and explaining how the CPU works electrically. It was a great education. Each clock cycle you have electronic "switches" (logic gates etc) which does one thing, like, it gets the instruction, clock cycle, then it maybe read LDA, so the next cycle it transfers the contents of memory into the accumulator. For addition, those four cycles may be that cycle 1 it loads one value into the accumulator, then it loads another into say Y for the next cycle, then it adds the two, and finally, perhaps transfers the result to the accumulator, or maybe sets/clears a flag. The faster the clock, the faster things get done, but it was quite educational. There really isn't any other "programming code" inside the CPU, just a set of electrical switches that are changed around for each cycle of an instruction to complete what it needs to do. Fascinating anyhow, this just adds to that knowledge for me. If you're interested in the series where he builds a CPU, check out his videos, they're amazing in how he explains how exactly a CPU operates, and he explains it like you explain things. Easy to understand.
ua-cam.com/video/HyznrdDSSGM/v-deo.html
Excellent Video! Congrats on 100 videos and thanks for your work & time!
how much i learn with this 2 videos thanks a lot! P.D. supporting ur channel is the only way can i say thanks.
I had no problems at all understanding this video, since when I was in High School I was programming 6502 assembler on an Apple ][+. This brought back many memories for me. One cool thing about the zero-page memory, I used it to *hack* many games into giving me unlimited lives. My homebrew Apple (I still have it!) had a switch that I could use to switch between AppleSoft and Integer Basic. So I would run a game, and keep note of how many lives it started off with. I would then play the game and get killed, then immediately put the switch to Integer Basic and hit reset (This needed to be done because most games would reboot on reset in AppleSoft), which would put you into the Apple Monitor, where you could examine the memory of the Apple, including the zero page. I would look through all the entries of the zero page, and see if it the count went down one, and keep it's location. Most game programmers put this kind of stuff in the zero-page area. I would start the game again and get killed a few more times, and see if there were zero-page memories that went down at the same time. Then, it was just a matter of loading up the code, using the monitor to look through the game code for something like "DEC $10" and NOP'ing (I still know it as the $EA opcode!) the code out. Then restarting the game, with now unlimited lives! Also, used to freak out schoolmates by putting their name in the game.
Anyway, congrats on your 0x64 video. Will also sub as well.
Funny that you happened to be writing an NES emulator at the same as me! Maybe I’ll be able to learn what I’ve been doing wrong when I run into emulation errors. Thanks for your awesome vids, can’t wait for part 3
Excellent content, very easy to understand and follow. Love how you break everything down and the object oriented nature of C++ makes everything so much easier to visualise. I am trying to emulate IA64 architecture and hopefully get it to run Linux and Windows
I'd just like to say thanks for this video! I've recently written a 6502 emulator for a pet project, and it's randomly weirdly similar in design to yours (aside from the PGE)! I'm going to be revising it though as some of your decisions are definitely improvements on my initial code! I'm mostly a hardware guy, but wanted to emulate a 6502 based retro computer I'm working on, which will have pretty advanced graphics, sound and even networking, so should be cool to learn to code on, and play games 😁 I'll also be trying out your PGE as the emulation interface, so thanks again!
Hey no problem Stabby! Your neoretro computer project sounds fun 😄
Big Thanks to you and your wife for providing completely accurate lookup table .. :)
This is one of the best series on YT. Thanks!
Few weeks before I watched this video I got through Ben Eater "Building an 8-bit breadboard computer!" playlist. It helped a lot to understand this topic for not-electronic, not-IT guy like me. For long time I knew some basics how computers work by Ben video series cleared up many confusions and misunderstandings of this topic. The series is bit long (44 of 1-20 min. videos) but it's worth to watch.
I miss probably something, but why we need to add 1 to the address at 35:11 ?
Apart of my misunderstanding, you are a god !!! Thank you very much for your videos !!! Words cannot describe the quality of your content !
That was excellent and easy to follow. I hobby code a little in C Sharp (Unity) and LUA (Pico-8 and Pictotron), and as it relates to the 6502 I watch channels like Displaced Gamers. But the assembly-language world has always felt inscrutable black box-y. And yet now, after watching this, I feel like a have a much more clear understanding of the 6502. Thanks!
this man is incredible, your content is amazing
I honestly expected no less after seeing part #1, but this really shows how great of a complement it can be (for those interested) to Ben Eater's "8-bit computer on a breadboard" series! Love it! I honestly thought of implementing one in software after seeing his video, but didn't even think of pushing it to the extreme and emulate a console! Very inspirational! :-D
just getting into this serie, so far its soooo good
I'd just like to take a moment to really appreciate your implementation of the LUT for the instructions. Using the OPCODE as an array index is just genius. My naive approach was just a huge switch statement.
Well, anyone exposed to the bit fiddling in those days would do it even if half unconscious.
I really enjoy learning from this channel. Excellent and high quality content and free.
Reminds me of the channel "Self Sufficient Me", similar accent :)
Thanks for sharing.
Wow, these videos are excellent, with clear and concise explanations. You can tell a lot of time and effort went into making these videos by their quality. Thank you for making them and keep up the good work.
@1:03:09 BNE $FA jumps back 4 Bytes to $8010, the disassembly shows $8110 instead. Very interesting to see how you approach writing an emulator, and quite different to how I would have imagined doing it myself. Thanks for this walkthrough.
Yeah its a little bug in how i visualise the assembly in the output of my hacked together disassembler XD
@@javidx9 if you want to know how addition of signed integers work, there is this one guy on the youtubes named javidx9, who explains it at about @42:40 of this hour-long video ;-)
Yeah, I noticed this too. Was going to mention it.
I was the same, looking ahead to see what was at 8110, before realising it must be a numeric error. Glad it wasn’t just me not understanding 😜
Haha I spotted this too! What an attentive audience - spotting hex errors 1hr 3 mins in 😀
Need to watch this several times to understand the meaning of each structure is. But this is a good place to start!
you are a true master and teacher to me and to others, you are who we strive to become as students
Outstanding. Simply outstanding. 10/10. Great explanations, great approach of showing the code incrementally, engaging at all times. Thanks a lot, I will be looking forward to the rest of the series!
Wow. What a great content!!! I'm waiting for the next part! Thank you, javidx9