NES Emulator Part #1: Bitwise Basics & Overview

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Now let’s see him program an NES emulator in Scratch!

πŸ‘οΈŽ︎ 315 πŸ‘€οΈŽ︎ u/BohrMe πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

Top-notch stuff - the explanations especially. Source: have been following this guy for a while now. Great effort into editing and getting the right level of explanations at every stage. Highly recommended.

πŸ‘οΈŽ︎ 43 πŸ‘€οΈŽ︎ u/[deleted] πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

This is the same guy who made an ascii based fps engine akin to wolf 3d. He's talented as fuck and so relaxing to watch. If I were half the c++ programmer he is I'd be in a much better spot with my confidence.

πŸ‘οΈŽ︎ 25 πŸ‘€οΈŽ︎ u/cheezballs πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

All his video’s are great. πŸ‘πŸ»πŸ‘πŸ»πŸ‘πŸ»

πŸ‘οΈŽ︎ 126 πŸ‘€οΈŽ︎ u/Fexelein πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

Still a project id like to try once. Especially since id finally have a project to try out rust for.

πŸ‘οΈŽ︎ 26 πŸ‘€οΈŽ︎ u/[deleted] πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

The theory is not difficult, and the design of the program will be simple. The problem is emulating the hardware bugs, all of which must be corner-cased. If this is not done, most games won't run the same as on the physical console.

πŸ‘οΈŽ︎ 103 πŸ‘€οΈŽ︎ u/moxxari πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

Writing an emulator of any kind is really a great way to learn. I decided to write a MOS 6502 CPU emulator, which took me a couple months to get right.

Then I decided since the NES was powered by the same CPU, all I needed to do was emulate the PPU and I would have a working Nintendo Emulator. That took over a year.

This video series really highlights the wizardry hardware designers and software developers in that time had to perform in order to get results with the limitations that faced them.

πŸ‘οΈŽ︎ 9 πŸ‘€οΈŽ︎ u/wndrbr3d πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

co-worker did this. He said in two days he already had sound working. It's apparently easy to get emulation working if you read about it.

And this guy at work went from knowing nothing about writing emulators to having a hello world version working in two days.

πŸ‘οΈŽ︎ 20 πŸ‘€οΈŽ︎ u/kfh227 πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies

Referring younger colleagues of mine to this guys videos got their brain to snap into gear of realizing "hey, C++ isn't actually that scary, it's almost the same as C#/Java" and start learning some C++.

It was already difficult enough to get school learned C# coders to realize Java is almost the same and school learned Java coders to realize C# is almost the same.

He's a fantastic teacher and does interesting "simple" projects that demystify the subjectmatter the projects are about and dear lord is he awesome in commenting his code.

πŸ‘οΈŽ︎ 6 πŸ‘€οΈŽ︎ u/Endarkend πŸ“…οΈŽ︎ Sep 07 2019 πŸ—«︎ replies
Captions
[Music] [Music] [Music] [Applause] [Music] [Music] [Music] there's nothing else for it I suppose hello let's make an emulator I thought I'd start the series by showing you where I'm up to so far and I'm about 90% of the way through so this is the emulator it runs in the pixel game engine and what I want to stress here is I've not just taken somebody else's code and implemented that in the pixel game engine this is an emulator from scratch so let's get started here with a game and as you can see I'm using my controller now we'll start with the moon level everybody likes the moon level the emulation isn't quite complete there's an audio channel missing and there's a few little glitches with other aspects to it such as the graphics are little bit sticky at the moment not the timing isn't quite right and I've not implemented all of the available mappers now that might mean nothing at all to most of you at this point but we these are all points that we will come opes diaper these are all points that we will cover in the series this project has been a complete passion project I've always wanted to create an emulator and because I've known I've always wanted to go to Ness emulator I've deliberately avoided looking at source code for nez emulators I knew one day I would want to do this and so I've built this emulator from publicly available reversed engineering information and data sheets one of the nice things about building your own emulator is you can display all of the internals in real time too so clearly I've got the main game screen happening here I can see live memory updates too and the state of the CPU in fact I can also see what instruction is currently being executed but be under no illusion this has been a complicated project and there's a lot to it and there's probably going to be quite a few parts to this series in this first part I'm not even going to start writing some code because we need to acquaint ourselves with the basics required so I'm going to look at hexadecimal notation binary tricks bit fields and the overall architecture of the nest oh that's no good I was never any good at this game there's also absolutely no conceivable way I can cover every single last detail of how to do this on a series of YouTube videos probably about 45 minutes to an hour each so I will be creating all of the source code and making it available and I'm writing the source code in such a way that it can be used as a studying aid so it's deliberately verbose I'm not trying to do any fancy programming tricks I'm not trying to make the most optimal emulation it's certainly not the most accurate emulation but it's been a lot of fun doing and it's great to be able to finally touch and feel and hear the nez games that I enjoyed in my childhood now when it comes to emulation there's a great big elephant in the room how legal is it well emulating the console itself is not illegal it's simply a circuit there's no proprietary software on there to which I could perform some sort of copyright infringement however the distribution of the games is illegal so downloading the games online that's illegal so I'm going to have to use my current stock of games to get the memories from in order to run them in my emulator however I can't just go and download the equivalent online because that would be legal I'm participating in the distribution of what are called drums and so instead I've purchased myself one of these and it's a wrong number and I can take one of my cartridges I can insert it into this little circuit board and I can extract the memory contents from the cartridge and in one of the later videos of this series I'll be talking about how this device works because it works in a very similar way to our emulator I have a reasonably small collection of nez games and I thought it would be fun showing them so here I've got the one that came with the nez which is mario brothers and duck hunt now then we've got Super Mario Brothers - diggity rock a boy in his blob that was a great game we've got some old ones as well so excite bike and I've got a feeling games like this may come in handy whilst building the emulator classic one Goonies - very fun but never finished it another old one here come Oh shadowgate some of the best music ever in a game really taxing lots of fun completing that one this was a bit odd high-speed pinball now don't rate that one ah now we've got to obviously rubbish games here the first is the Legend of Zelda and of course its sequel The Adventures of link we've also got Marble Madness that's quite an old one oh here this is a classic Super Mario Brothers 3 Double Dragon 3 was never really into the beats mock games no but one here that's a bit strange I don't think we'll be able to emulate this one but this is a Micro Machines ah and I've got the Disney fantastic one so I've got a chip and dale rescue rangers ducktales 1 of course the best game ever made and that ducktales - which i don't want to lose that one that's for sure and I've got a few that don't have boxes but at excellence this is Captain Skyhawk and this one is Mega Man everyone zoom in on here so we get some of the Mega Man artwork on the cartridge it's not too blurry doesn't look anything like the in-game Mega Man and Donkey Kong's classics which is also going to be quite useful for emulation and Teenage Mutant hero turtles I never got past the water stage and you can see these ones don't have boxes because I bought them in second-hand markets my plan is to use this device to extract the contents of the read only memories on the cartridges in effect I'm making a backup of the software that I own but of course I need some way of implementing this backup in order to play the games and thus why I need to build an emulator the very first thing I want to do however is point out a website called wickedness dev comm because creating a nose emulator would have been completely impossible without this fantastic resource this website has been put together presumably combining hundreds of thousands of man-hours of dedicated enthusiasts reverse engineering the nares and this resource has proven to be completely invaluable in creating my emulation but what I like about it the most is not just the sheer technical content of how the nares works and what it does is it doesn't really include any code it is a behavioral description of what's going on and so this was perfect for my project for example let's take one of the audio channels here and we'll see a lot more of this in a specific episode later in the series there is no code it doesn't tell you how to do it all it does is tell you what the behavior is so it tells you what the clock frequencies are of the different components it tells you what certain memory registers should do and it tells you what the behavior should be but it doesn't ever give you any code wikidot nez dev comm it's just a fantastically incredibly thorough resource it is the work of many people incredibly dedicated people far smarter than I am who have had to reverse-engineer this because there was no documentation released by Nintendo so they've had to write programs perform experiments get some electronic gear out get the oscilloscopes out and work out how it all works and they've provided it for free so thank you very very very much to these guys I cannot stress that enough I'm going to start with a very basic concept hexadecimal notation now I know many of you will be familiar with this and use it all the time but there will be some of you that aren't familiar with it and if you're not then the rest of the series is not going to make very much sense so look at hexadecimal notation and some of the bitwise and logic operations that we'll be applying to the emulation I'm hoping that by virtue of watching this channel you have the most basic familiarity of the concept of binary numbers so if I take a decimal number let's say 65 because an easy one to remember it's binary equivalent is 0 1 0 0 0 0 0 1 these two numbers are equivalent they just have different bases so in this case this is 5 times 10 to the 0 plus 6 times 10 to the 1 this is what we're all familiar with it is decimal it is base 10 notation starting with the rightmost digit being 0 1 2 3 4 etc etc base 2 notation is no different 0 1 2 3 4 5 6 7 but because we only have 2 available digits to represent our number our basis - so in this case I've got one times two to the zero and I've got one times two to the six everything else in between is zero anything to the power zero is equal to one which means I've got 1 times 1 which is 1 2 to the power 6 is 64 so I've got 1 times 64 these two are added together and lo and behold we've got 64 plus 1 equals 65 and when I refer to the zeroth bit I mean the one that is furthest to the right and typically for a byte of 8 bits bit 7 is the one to the left emulation is all about representing the hardware and hardware exists of well hard worried things like transistors and flip-flops and busses and wires there is no fundamental hardware component that can understand a decimal number in the format of 65 so instead we use binary a series of on and off switches whilst binary is great for computers it's terrible for humans because the numbers get large quite quickly here we've got 8 bits and so we can represent the range 0 to 255 that's not very large so to store larger numbers we need more bits when I want to convey to another human being this 16 bit number ideally I'd prefer to do it in a decimal because if I was telling my friend that I wanted the number 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 despite it sounding like a flight of the conchords song it's just not a feasible way to communicate that information but the problem with the decimal equivalent is it doesn't really give me any visual recognition of what the binary sequence is my brains just not wired that way to see decimal numbers represented as binary what we need is a format that lies halfway between being able to see which bits are active but also as being a human being gives me an appreciable scale of the numbers value and that is of course hexadecimal notation where we're going to group the bits into groups of 4 for binary bits gives you a range zero and 15 and so for this first grouping here we can see we've got eight plus four plus two so that's 14 here we've got eight plus one that'll be nine here we've just got a 1 so that's still just a 1 and here we've got a 4 and a 2 so that's a 6 in this new notation we can't have double-digit numbers so we're going to use a different symbol we've got 16 different symbols to store I'm going to stick with the traditional 0 to 9 for the numeric digits and then I'm going to have a b c d e and f where 0 represents 0 and F represents 15 so my hexadecimal equivalent just shorthand into hex is going to be 6 1 9 e and so after a little bit of practice I can perceive that the binary construction of this number at some point contains this sequence but I can also immediately tell that 6 1 9 e is larger than 6 1 9 B for example in the literature you'll see different notations for numbering systems used interchangeably but in C++ to represent a binary number directly we prefix it with 0 B and hexadecimal digits are prefixed with 0x and in this case we can see we've got no eight so four two and once that is going to be a four and this second grouping is just going to be a 1 but you may see in the literature other notations so the dollar sign for t1 means the same thing sometimes you'll see hash for t1 and sometimes you'll just see X 41 now if you're thinking what is the point of all of this why not just use the decimal values well the answer is simply because hardware tries to be as optimal as it possibly can and it does so in a way that doesn't always align with the friendly concepts we're used to in programming so for example in C++ we're used to a char being an 8-bit data type one byte but where is you and I may look at that as being a numeric value hardware may look at that a bit differently within this one bite there may be lots of different types of information perhaps these three values at the bottom are used to represent some value in the range 0 to 7 perhaps these two bits in the middle represent some state of which there are only four possible states to exist within these two next bits may only need to be simply bits they just control switches in the hardware they're either on or off and finally this bit may simply not be required the system only requires this seven bits of information but on the computer we can't store seven bits conveniently so we use a char and simply ignore one of the bits since I'm building an emulation of hardware it's important that I know how to extract the relevant parts of the overall eight bit number and interpret what they mean conversely I might need to construct the bits required for the hardware out of information I'm storing as other data types to facilitate this form of data processing we need to use bitwise operations let's say out of this data all I'm interested in right now are these bottom three digits how do I get to those in principle I can construct a binary mask of the digits I'm interested in in this case I'm not interested in these digits but I am interested in the bottom three if I perform a logic and between this word and this word I get the following results 0 + 0 is 0 1 + 0 is 0 0 0 0 now this time I've got 0 + 1 that's still a zero but I've got 1 + 1 twice so we can see that performing the bitwise logic and has given me a byte that I can work with in software that represents just these bottom three bits in a similar way of course I can extract any of the bits in my original word so let's have a look at these 2 bits representing some state this time my mask is applied to the two bits that I'm interested in looking at performing a bitwise log you can of course extracts those two bits for me but to begin with we made the assumption that these two bits represent some value 0 1 2 or 3 clearly these values are not the same as this value in effect we need to shift this value three bits to the right and we can do that with the bitwise shift operator so it's a shift right it's two angle brackets facing right let's say my variable was X I want to shift it right three bits well that's the operation of course I can also shift left to shifting right effectively divides by two each bit and shifting left multiplies by two each bit now let's take a look at our switches these are either on or off I've created a mask which has the switch position and again if I perform a bitwise and well in this case it looks just like my mask if I wanted to test if this switch was on ie not zero I can simply take whatever the decimal equivalent of this is and test it to see if it's larger than zero and in C++ in many cases I don't even need to do that because an if will branch based on the condition of true or false ie is it zero or not zero so making a decision based on a single bit in a word could look something like this let's say X is my word and I want to see if a single bit of it is active I could simply test it with say the hexadecimal equivalent in this case which would be 20 we get 8 4 2 0 alternatively I could test it with a constant we construct at compile time I want to take a 1 and shift it 5 bits 1 2 3 4 5 my point is there are multiple ways to achieve the same goal and you'll choose one based on what is the most readable in that given situation this notation to me immediately says I'm testing to see if bit 5 in word has been set so we've seen that we can use the bitwise and operator to extract information from a word we'll use the bitwise or operator or vertical bar to set parts of the word so let's take a blank 8-bit word and this is my intention to set these three bits with a value between zero and seven I'm going to say five which we know can be represented as binary has 1 0 1 firstly I'm going to want to shift these bits into the correct location I want to shift everything by 2 to the left this will give me 0 is 0 0 1 0 1 0 0 so the 3 bits are now in the right place to set the bits in X I'm going to use the bitwise or operator I'm going to use it on X itself so X is equal to X or this binary word but hopefully you can see with some simple arithmetic and bitwise operations we can certainly set individual bits in groups in a word setting an individual bit in a word is very simple how do you unset a bit how do you set a particular bit to be equal to 0 let's say I want to clear this specific bit out of this 8 bit word I can construct a mask easily enough using the bitwise or operator and some bit shiftings and if I use the invert operator which is the tills symbol to invert all of those bits I can now use the and operator with the inverted word and my original word to clear that bit because now we've got one and one it's once that's original 0 and 1 is 0 so that's the same as the original this is the bit we're clearing which is now 1 and 0 which is 0 and the rest follows but two words are identical except for the bit that we've changed so we can clear a specific bit in the following way and it goes without saying that we can clear groups of bits in the same way too there's one more common use case and that is the ability to toggle a specific bit so it might be a 1 and I want it to become a 0 or it might be a 0 and I want it to become a 1 I don't know ahead of time what situation will be and we've looked at the operations of and an inversion and or there is another one which is exclusive or which is the Hat symbol so I've got a bit highlighted here let's say that's the bit I want to toggle I can construct my mask again that identifies which specific bit in the word I want to toggle and I can take the exclusive or between these two words so one and zero exclusively odd together is 1 0 and 0 is 0 1 and 1 is 0 1 and 0 is 1 1 and 0 is 1 0 and 0 is 0 etc etc so we can see that I've got a new word which is the same as my previous word but the one bit that I've identified has been toggled and if you don't believe me if I apply the exclusive or bitwise between these two words I get 0 1 which is a 1 a 0 I've got 1 or 0 again 1 1 1 0 1 1 so you can see that is the same as the very first word and so there you have a very brief summary of the 6 primary bitwise operations logic and logic or logic naught or inversion logic exclusive or which can be used for toggling shifting left which multiplies by 2 and shifting right which divides by 2 and even though I've shown these operations being applied to binary words they can of course be applied to decimal numbers and hexadecimal numbers you just need to think about what you're doing if you know you're going to be working with bitwise operations a lot and in emulation we will be sometimes it's a lot more convenient to create a structure that represents a binary word that's already broken apart into convenient properties C++ provides a facility for this it's called bit fields it is possible to tell the C++ compiler to construct a data structure where it only allocates specific bits to a particular word so let's replicate the example we have before the bottom 3 bits represented some value between 0 & 8 but I only wanted to allocate 3 bits of accuracy to that value well in a struct I can declare how many bits I want by using the colon and say 3 bits please the next one was a two-bit value to represent a state then I had a couple of values individual bits to represent switches so I'll call that SW 1 we'll give that 1 bit for some semicolons in and SW 2 and that's also one bit we also had one that was unused so I'm going to include that too and what's very important here is that these numbers add up to something that can be represented in C++ so in total we've got 8 bits so let's say I had a variable called a that was the same type as this structure I can represent the individual bits as simply a dot value and treat it like any other components of a C++ expression so I can assign numbers to it and I can read from it and of course I can represent the other properties of it too so let's say I wanted two sets which is 2 to 0 so by doing this I don't need to do all of the bitwise operations we'll see throughout this series that in some situations this is an applicable solution and in other situations handling the binary mechanically and by hand is the correct solution but in this scenario how would I go about setting all of the bits to 0 simultaneously that might be something that's required during a reset well the simplest option is to create a union between this struct and another variable that has a type of the same number of bits and we know we've got 8 bits we know a char is 8 bits so I'm just going to call that create a variable in the char 8 bit reg and so now if I have type a of this Union I can simply say a dot reg equals 0 X 0 0 which will set all of the bits to 0 and I can still access the individual bits as required and it's up to you how far you go with this you can create quite intricate nesting structures and unions to best represent elaborate data structures but as I mentioned before it's entirely situation dependent what's the best approach and I always try to go for a readability compared to modern machines then there's may seem quite simple but don't be fooled it's a rich and complicated machine in its own right in this series I'm going to break the nest down into its fundamental components and talk about them individually in separate videos in isolation these videos aren't going to make very much sense so I'm going to give a brief overview of how the nez is constructed and how the various components talk to each other I'm not going to go into any code in this video this is purely a very high-level look at how the nares is constructed like most computer systems the nurse has a CPU central processing unit and its designation is 2a o3 that's the type of chip that the CPU is made of it's actually a variant of what is called the 6502 which was really prolific in that era as the micro controller of choice in fact it is just a 6 502 the only thing that makes it difference it is got inbuilt audio circuitry which the 6502 didn't have so for my emulation I'm going to just simply implement a 6502 processor because that gives me the opportunity to use it in other things in the future the CPU has no internal memory and so it must be connected to some veera bus other things are connected to this bus and even though I'm going to draw them as discrete objects they might not necessarily be they could be combined together CPUs typically need some memory and the nez has a whopping two kilobytes of memory fundamentally the CPU is an 8-bit device its internal registers are only capable of storing 8 bits of information however it can address a 16-bit range so potentially it could interface to a 64 kilobyte memory on this bus the memory is mapped to locations 0 0 0 0 2 0 7f f that's 2 kilobytes in hex so when the CPU puts an address on the bus that lies within that Ray this particular object is going to respond and so even though the CPU can address 64 kilobytes of memory most of those addresses will resolve to nothing and we'll come back to that in a minute there could be other devices attached to the bus let's take for example the APU which is the audio processing unit responsible for generating the sound in reality the APU is actually part of the CPU but conceptually it's more convenient to think of it in terms as being a separate peripheral attached to the bus there aren't many addresses mapped to the APU but it starts at 4,000 and goes to 4017 at this stage this is an incredibly high level look at the architecture there's a lot more detail in each of these units and we'll look at them in individual videos there's really only a couple more things attached to the bus connected to the CPU well come back to a major one in a minute but let's just finish this one off the big one attached here is the cartridge itself so this is the device that contains the memories that typically have the programs that the CPU runs and the cartridge may typically be mapped from 4020 all the way to the end of the addressable range F F F F so what we're starting to see already is we can't just represent the giant address space as an array depending on the address that the CPU is interested in reading or writing to we need to respond differently there is an additional device connected to the bus and it's arguably the most important one and certainly the most complicated one and that is the picture processing unit otherwise known as PPU sometimes called pixel processing unit by me accidentally and this only has a very small mapping given its importance and its relationship to the CPU it's addressed the range 2000 to 2007 and you may notice I'm already starting to do some hexadecimal slip-ups of course this is a hexadecimal 2007 not a decimal 2007 the PPU is a completely separate device it's official designation is a to co2 feeding these devices are clocks so every time a clock ticks the CPU does something or the PPU does something and in particularly the PPU every clock tick it outputs a pixel to the screen the CPU and PPU actually run at different clock speeds and we'll go into that later in many ways you can think of the PPU as being one of the earliest graphics cards the CPU is not really responsible at all for drawing anything to the screen instead it structures the data within the PPU in such a way that the PPU can compose a picture that we see on the screen as such we can think of the PPU as being a parallel processing unit just to add to the PP eunice confusion and it's a sophisticated little device it has a bus of its own and whereas the CPU had a 64 kilobyte addressable range the PPU has a 16 kilobyte addressable range but the bus works in exactly the same way as the CPU bus it has different things connected to it early on on the bus it has some memory mapped to graphics this is the actual pixel data the sprites or the tiles that make up the scenes in the games there are 8 kilobytes of available graphics memory however this memory doesn't necessarily exist on the nests in fact it exists on the cartridge the next component is a small V Ram a video memory and in total there are 2 kilobytes of this memory typically this memory is used to store identifies that represent which tiles to draw in the background this is stored between 2002 7f f when we start talking about the PPU in detail later in the series we'll see that there's actually some additional complication to how this unit is addressed the final unit connected to the PPU bus controls the palettes and these exist between 3 F 0 0 and the end of the addressable range unlike the graphics were familiar with today where things are stored as bitmaps or JPEGs or PNG s on the nez it had its own proprietary format and again later in the series we'll look at this in some detail but if a actively all of the graphics on the nares were 2 bits per pixel and those 2 bits were indexed into a palette to choose all of the available colors that we saw on the screen the PPU has one final additional thing connected to it which is not available via any bus and it's a small memory called the object attribute memory and this memory is used to store the locations of the sprites that we see on the screen the CPU effectively only has 8 letterboxes through which to deposit information and exchange information with the PPU that doesn't seem like very many given the complexity of the task the PPU has to perform sprites and things moving around on the screen are clearly positioned by the CPU the PPU just does drawing doesn't implement any physics or movement so the cpu needs to populate this OAM memory every frame the PPU is clocked at three times the frequency of the CPU so the cpu updating the object attribute memory manually would be far too slow so the nez provides a dedicated peripheral just for doing this and it's a primitive form of DMA direct memory access which temporarily suspends the CPU and transfers memory directly into the object attribute memory this way the CPU can prepare a region of its own address space with where the sprites should be but it doesn't need to bog itself down with manually transferring that information through this limited space those of you watching with a keen eye may have noticed a bit of a limitation with this setup firstly 8 kilobytes of graphics doesn't sound like very much when the nez was first released and the games were quite simple it was an adequate amount that graphics are low resolution after all and who were simplistic but over time it grew in its sophistication and its audience became more demanding for more sophisticated graphics the designers at Nintendo were clearly very forward-thinking about this and they knew that extending the capabilities of the nez would be vitally important to its success as a long-term device so to that end they included additional circuitry on the cartridges and of course that made them expensive this circuitry is called a mapper and there are a whole host of different types of mappers in total I think there are around 700 licensed Nintendo games for this console but fortunately for my needs most of those games use just three or four different configurations of mapping circuit so as part of our emulation were also going to have to emulate this device and this device was responsible for what is known as Bank switching and this is where the CPU can configure the mapper on the cartridge to give different data for the same address ranges so in one instance let's say Bank a contains the graphics for level 1 when you reach level 2 the cartridge is programmed so that all of the graphics map on to bank B so you get different graphics for that level and the nice thing is nothing has to be loaded or transacted along the bus we're simply changing the mapping of the addresses to different memory locations on the cartridge to the PPU and CPU addressing those locations on their buses they see no difference they don't know anything has changed but the mapper delivers different data and it's through this that we can have significantly larger memories devoted to graphics and programs the program data is obviously stored on the cartridge - as is all of the information for all of the different level layouts and configurations it may well be that all of the memory required for a specific game far exceeds the 64 kilobyte allowance that the addressable range of the CPU allows and so again the CPU can configure this mapping circuit to change what memory banks are connected to the bus and as we've seen with the PPU that can change the graphics with the CPU that can change the running program as I've said several times already it's my intention to make several videos in this series the first is going to be dedicated to the CPU and its bus this will be a nice cell contained module which we can use in other things in part two we'll look at half of the PPU and we'll be looking at how it handles the background rendering on the screen in part three we'll look at the second half of the PPU how we handle the sprites in part four we'll look at mapping circuits and hopefully finally in part five we'll look at how it generates audio I don't currently plan on there being a part six it would be a very long series if that was however this is the type of project that because for me it's so personal and I'm so pleased to be doing it it's never really going to be finished until I'm absolutely happy with it however as you've seen already what I currently got is a working nez emulation and I hope to deliver enough content in this series that you can get one working on your own but you will need some of the information available on nez dev it is not my intention in this series to go through byte by byte how to create a Nintendo emulator instead what I'm trying to provide is some insight into how do you go about emulating systems in general and I'm going to try and deliver fairly deep understanding into the inner workings of the nares in particular because it's a fascinating machine and I love it a bit I'm personally really pleased to have started this series it's something I've wanted to do for so long and now that it has been started I can at least start showing things and uploading clips to the sister channel Java decks 9 extra there won't be any source code immediately simply because if I deliver it in chunks people might start wanting to try using it straight away and I'll try and make sure that the source code is relevant to the video at the time I appreciate this video in particular has been a bit light on technical content and code but it was a necessary step before embarking on a journey like this so if you've enjoyed it please give me a big thumbs up have a think about subscribing and I very much hope I'll see you next time take care you
Info
Channel: javidx9
Views: 316,598
Rating: 4.9789591 out of 5
Keywords: one lone coder, onelonecoder, learning, programming, tutorial, c++, beginner, olcconsolegameengine, command prompt, ascii, game, game engine, pixelgameengine, olc::pixelgameengine, NES, nintendo entertainment system, emulation
Id: F8kx56OZQhg
Channel Id: undefined
Length: 40min 11sec (2411 seconds)
Published: Fri Aug 09 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.