NES Emulator Part #3: Buses, RAMs, ROMs & Mappers

Ғылым және технология

In this video I explain how I've "glued" together the different components of my NES emulation, looking at how the cartridge is loaded, and how the CPU and other devices interact with each other in a flexible way, through the use of Mappers.
Source: github.com/OneLoneCoder/olcNES
KZread: / javidx9
/ javidx9extra
Discord: / discord
Twitter: / javidx9
Twitch: / javidx9
GitHub: www.github.com/onelonecoder
Patreon: / javidx9
Homepage: www.onelonecoder.com

Пікірлер: 257

  • @javidx9
    @javidx94 жыл бұрын

    Hello! I'm interested in some feedback, should my next video be continuing with NES (we're half way through)? or taking a brief break with something else for a single video? As I appreciate not everyone loves the NES as much as I do :D

  • @jonathanmichaux8641

    @jonathanmichaux8641

    4 жыл бұрын

    Thumbs up for NES!

  • @jonathanmichaux8641

    @jonathanmichaux8641

    4 жыл бұрын

    Thumbs up for non-NES content!

  • @leonardochiruzzi7642

    @leonardochiruzzi7642

    4 жыл бұрын

    Anything is fine for me. But the important thing is not to stop the NES series.

  • @Fergobirck

    @Fergobirck

    4 жыл бұрын

    I do love this NES series, but I'm still looking forward to more updates on the TDCBCC Game, or perhaps some more videos on computer graphics basics using olcCGE/olcPGE? I really enjoyed the videos where you implemented the barebones of 3D game engines and I still thinks that are some topics to cover there :D

  • @Jeacom

    @Jeacom

    4 жыл бұрын

    Yes, more NES, this project is getting interesting.

  • @eformance
    @eformance4 жыл бұрын

    I definitely thought this video was NEScessary!

  • @vegardt3433

    @vegardt3433

    4 жыл бұрын

    You beat me to it!

  • @kingzeeb319

    @kingzeeb319

    4 жыл бұрын

    See yourself out.

  • @arcticcat74
    @arcticcat744 жыл бұрын

    I love this series, can't wait for the rest...

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thanks ArcticCat!

  • @harryfox4389
    @harryfox43894 жыл бұрын

    👍👍👍 not making an emulator but I'm learning a lot from these videos

  • @javidx9

    @javidx9

    4 жыл бұрын

    Oh good I am pleased, I'm trying to do them in such a way that they have a broader appeal so that's encouraging feedback, thanks Prof. Fox!

  • @brecoldyls
    @brecoldyls2 жыл бұрын

    That bug you found at the end was so subtle, amazing that you found it! This series is wonderful, thank you for the great videos

  • @abblabblabalaba
    @abblabblabalaba4 жыл бұрын

    Your work is beautiful. You explain things well, you show the code, you are keeping it presented in a linear and very understandable fashion. Inspiring. Thanks.

  • @KerboOnYT
    @KerboOnYT4 жыл бұрын

    Fascinating stuff. Thank you for doing such a detailed series

  • @sebastianschneider9383
    @sebastianschneider93834 жыл бұрын

    I have never seen such a marvellous way of teaching programming, and I love that you explain everything as the things you discuss are bare necessities when building an emulator

  • @CodeSourcerer
    @CodeSourcerer4 жыл бұрын

    You've inspired me... I'm writing my own emulator based on these vids but in C#. Thank you! So far, I got it working up to the point you had in the last video and now I'm working on changes you did here.

  • @MarcRidders
    @MarcRidders4 жыл бұрын

    Again a very entertaining video which explains the inner works of your NES emulator very well.

  • @adam3141
    @adam31414 жыл бұрын

    This is great. I wanted to start out by coding up a 68000 as I want to create a Genesis emulator but it occurred to me that I always rush headlong into projects that are complex. I kind of short-circuited my thinking and decided to try for a lower spec processor and came across your tutorials. So I have started to code up a 6502 emulator and your tutorials are very clear. Thank you.

  • @jensborgmann2588
    @jensborgmann25884 жыл бұрын

    I really appreciate your videos, they are allways fun and informative. This is the only channel, to my knowledge, with videos about C++ in the full range from beginner to advanced game prgromming.,I like your style, even out of my perspective as a IT teacher. The C++ videos concerning your game engine and those in the code-it-yourself playlist are well made and a good starting point for young programmers.

  • @lupinedreamexpress
    @lupinedreamexpress4 жыл бұрын

    Been following this and learning a lot about writing emulators. Thank you!

  • @krrishxxx
    @krrishxxx4 жыл бұрын

    Finally, after a long wait, the third part is here and it is so amazing. Thank you javidx9

  • @francescodizzia
    @francescodizzia4 жыл бұрын

    Javid, this is incredible! I discovered your channel a few days ago and every video keeps surpassing the previous ones. Keep this going, because your content is really an hidden gem! :)

  • @javidx9

    @javidx9

    4 жыл бұрын

    Lol thanks Francesco!

  • @tails_the_god

    @tails_the_god

    3 жыл бұрын

    @@javidx9 still useful in officially following this project now! :D

  • @mehulajax21
    @mehulajax214 жыл бұрын

    Dear Javidx9, I stumbled upon your channel and since then I have watched a lot of your videos. I must say this is one of the best technical youtube channels around. Thanks for awesome content.

  • @javidx9

    @javidx9

    4 жыл бұрын

    Thanks Mehul! Much appreciated and I will!

  • @SuyDesignz
    @SuyDesignz3 жыл бұрын

    Thank your for this video series!! Helped me alot for my University project! keep doing such videos like this

  • @Diamonddrake
    @Diamonddrake4 жыл бұрын

    Great video as always! Really enjoying this series!

  • @ConfusedNDazed
    @ConfusedNDazed4 жыл бұрын

    Thanks for always uploading these perfectly on time for Saturday morning in Australia 😃

  • @billybest5276

    @billybest5276

    4 жыл бұрын

    My favorite way to spend my weekend morning or a cold rainy day

  • @keithrobinson2016
    @keithrobinson2016 Жыл бұрын

    Unbelievable content and absolutely free! Will definitely be following this channel.

  • @riccardofranchi7468
    @riccardofranchi74684 жыл бұрын

    Definitely the best series on KZread! Can't wait for the other episodes

  • @m1geo
    @m1geo10 ай бұрын

    Not only is this interesting as a NES Emulator, but I'm enjoying watching someone competent with C++ work!

  • @justcallmenoah5743
    @justcallmenoah57432 жыл бұрын

    Javid, my man, you make such incredibly engaging content man. Keep up the great work, just so long as it doesn't interfere with you're new family! Congrats btw!!

  • @Wick011000
    @Wick0110004 жыл бұрын

    First off, what an excelent series, can't wait for the next one as this is also been something i have been playing with on and off over the years, it's now got me motivated again on my emulator. be fun if you did some nes asm games to go along with with thsi project :)

  • @code-dredd
    @code-dredd4 жыл бұрын

    @25:20: I don't know if anyone has mentioned this, but in the `Mapper` class, the `~Mapper` destructor also needs to be marked as `virtual`.

  • @cxzuk

    @cxzuk

    4 жыл бұрын

    +1, Yep. Holding the reference to the mapper with the abstract class (std::shared_ptr) so needs a virtual deconstructor.

  • @rickyrico80
    @rickyrico804 жыл бұрын

    Awesome series, thank you!

  • @MattZelda
    @MattZelda4 жыл бұрын

    Planning on doing an implementation of this in Rust. One to learn the language better, two to have an emulator, three to understand the fundamentals. You've been quite helpful. Thank you sir.

  • @bensas42

    @bensas42

    Жыл бұрын

    Did you end up doing it? It's exactly what I'm doing right now haha

  • @jaysistar2711
    @jaysistar27114 жыл бұрын

    Mappers were why I didn't make an NES emulator first. I've worked on quite a few emulators for quite a few different systems since then, but this series has renewed my interest in this hardware.

  • @LittleRainGames
    @LittleRainGames4 жыл бұрын

    Great video, dont worry that it wasnt very visual, I loved it.

  • @minirop
    @minirop4 жыл бұрын

    Great explanations that are a good addition to the "Retro Game Mechanics Explained" channel. (theory vs practice)

  • @billybest5276
    @billybest52764 жыл бұрын

    Thank you sir for another great video!

  • @teckyify
    @teckyify4 жыл бұрын

    Dude dude dude, you can explain everything good AF, you should have been my prof at uni 😱👌🏻

  • @BryanKelly
    @BryanKelly4 жыл бұрын

    First of all, love the videos so far! Just noticed something in Bus.Clock(). I think you'll have an extra clock of the CPU when nSystemClockCounter overflows. 4294967295 (max value for 32-bit unsigned) % 3 == 0, then next increment nSystemClockCounter will be 0. 0 % 3 == 0. So you will clock the CPU twice. This might not even be noticeable, but just wanted to point it out.

  • @ushiookasaki
    @ushiookasaki4 жыл бұрын

    I like this serie. I want to see the next video 😊

  • @pichonPoP
    @pichonPoP4 жыл бұрын

    ohh god!!! finally. Thanks for making this kind of videos.

  • @schnert0
    @schnert04 жыл бұрын

    I’ve never clicked a video so fast

  • @zaferkacmaz8214
    @zaferkacmaz82144 жыл бұрын

    "Thank you for existing" :)

  • @frac
    @frac4 жыл бұрын

    Loving this!

  • @hellangel28
    @hellangel284 жыл бұрын

    really love your videos

  • @RealNekoGamer
    @RealNekoGamer2 жыл бұрын

    Been trying to follow along in plain C for an added challenge. Got up this far using just the standard input/output, even adding functions for RAM dumping to screen and file, as well as a disassembler. For the bus, I went a step further and added a single linked list for untyped device pointers. Come the graphical, audio, etc stuff, I plan to leverage SDL2. When it comes to systems programming, emulators aside, C is a must. Despite the lack of type safety and using preprocessor, I want to develop a discipline in C so that when it comes to real system development, I won't have to re-learn how to do things. Plus, I've a passion for bare simplicity if I can utilise it.

  • @monstersuperdan3931
    @monstersuperdan39314 жыл бұрын

    good job!I love nes game

  • @coolmind2476
    @coolmind24764 жыл бұрын

    Great video. Love this series and hope to get a complete picture. By the way, everything you say can be copied 1:1 to paper and published as a book without editing, great explanations. Only thing which gets me confused sometimes is which class is currently edited and how all these call methods of the other. Maybe a picture would help. Maybe it's just because I am not familiar with C++.

  • @CyberWolf755

    @CyberWolf755

    4 жыл бұрын

    If there is a cut in the video, I pause and check the selected file on the top of the code editor window. Helps me out a lot.

  • @annybodykila
    @annybodykila4 жыл бұрын

    Lovin the nes emu

  • @zerobyte802
    @zerobyte8024 жыл бұрын

    Got notification. Watched video. Re-watched video. Now, back into the cryogenic-tube so I don't have to wait for the next video. 😉

  • @orbyfied
    @orbyfied3 жыл бұрын

    javid you are amazing. your content is truly educating but also really entertaining. and i think that the like-dislike ratio says the same

  • @javidx9

    @javidx9

    3 жыл бұрын

    Thanks Orby 😄

  • @johneygd
    @johneygd4 жыл бұрын

    It sounds very complicated but interesting, especially those exterrnal mappers.

  • @MegaDeox
    @MegaDeox4 жыл бұрын

    Fucking. Fascinating. Thank you so much for this series.

  • @brianmac8260
    @brianmac82604 жыл бұрын

    87k subs holy fark. Congrats man, you deserve a knighthood too.

  • @javidx9

    @javidx9

    4 жыл бұрын

    lol scary stuff from our first humble exchanges huh?

  • @carlhudson83
    @carlhudson834 жыл бұрын

    Hey Javid! Excellent tutorials sir.. Are you planning on adding some wrapper functions to turn the emulator into a multiplatform games dev environment? *hint hint*

  • @TheMohsell
    @TheMohsell4 жыл бұрын

    Man you are awesome,

  • @vdvman1
    @vdvman14 жыл бұрын

    You mentioned that the CPU is 3 times slower than the PPU, I presume that this means you only intend to support NSTC region games and not PAL, since the ratio is different for PAL?

  • @skilz8098
    @skilz80984 жыл бұрын

    Have you thought about modeling the 6502 in Logisim?

  • @hayefahayefa4874
    @hayefahayefa48744 жыл бұрын

    greeeaaatttt video thx

  • @dynamagon
    @dynamagon Жыл бұрын

    16:54 ohhh so that's why that glitch in megaman 2 happens when you touch the air man door during the boss fight and it loads the whily stage with air stage graphics, it's because it loaded it without changing the bank! Thanks for teaching me!

  • @Dexter101x
    @Dexter101x4 жыл бұрын

    Considering these days, games requires gigabytes of ram, it somehow amazes me how they managed to get something like Sabre Wulf for the ZX Spectrum 48K to work

  • @ChupoCro

    @ChupoCro

    4 жыл бұрын

    Sabre Wulf looked more complicated than it really was from the programming point of view. Alien 8, Knight Lore and similar games looked really impossible. I recommend you the book *Steven Hugg - Making Games for the Atari 2600* to see how the games were made on 1 MHz 6502 CPU with just 128 bytes of RAM where the programmer had to update the graphics processor's registers on the fly at the exact moment when the electron beam was at the right place meaning the game logic could be updated only during the vertical blank periods and during some of the horizontal blank periods. Some Spectrum games were updating the border (port #FE) in sync with the electron beam too, for making the line through the border and some changed the attributes in sync with the electron beam to make possible more than 2 colors per character which was similar to how every Atari 2600 program had to work because of the hardware limitations. Spectrum at least had 6144 bytes of video RAM (+768 bytes for attributes) covering the full screen where one could draw the pixels but Atari 2600 didn't have enough RAM even for a single scan line of the picture :-) Atari was designed to run games such as Pong or Tank with a few moving pixels and a static background but at the end programmes made even 3D games, flight simulators etc. A lot of Spectrum games were really extraordinary considering the hardware limitations (and Sabre Wulf sure is one of them) but looking at what was made on Atari 2600 and knowing its hardware limitations looks even more impressive compared to Spectrum. I still remember my surprise when I saw Alien 8 on ZX Spectrum for the first time :-) Not to forget Spectrum's multichannel sound routines with full ADSR envelope made without any sound hardware by "just" toggling one bit of the port #FE (the same port where 3 lowest bits are for the border color).

  • @ChupoCro

    @ChupoCro

    4 жыл бұрын

    @rokker333 Yes, you are right Spectrum and Atari required a different kind of programming but both required an ammount of ingenuity to make some games - at least compared to the computers with different hardware concepts. Even making a 'redefine key' routine for Spectrum wasn't trivial. On the other hand, even displaying a character on Atari required counting T-states. Yes, Elite was an incredible port. The animated circles I saw in Elite made me researching the fastest way to draw a circle on Spectrum :-) BTW, Elite's routine for clearing the screen was faster than using LDIR instruction specificaly designed for such purposes. Instead of using LDIR they moved the stack pointer to the end of the screen and then there was 16 (or maybe 32, I don't remember) PUSH instructions in a loop which is faster because every PUSH clears two bytes in less T-states than LDIR. I learnt programming by disassembling various loading routines (speedlock, bumping header, ...) and by disassembling multichannel sound routines from some games (e.g. Ping Pong by Imagine/Konami was quite tricky). I did some 6502 programming on C64 too but not so much as on Z80. Unfortunately I skipped Amiga and Atari ST and later started using microcontrollers which I still do and I started to examine Atari 2600 only recently. Maybe you forgot the details about C64 and Amiga intros but I am sure you could still make an intro using an emulator + cross compiler :-) I sometimes still write some Spectrum routines for fun using z88dk which can output snapshot files for using with Spectrum's emulator, I am sure there is something similar for 68000 + Amiga. As for counting the clock cycles (T-states) to write to video chip registers on Atari 2600, there was even more complicated project back in the 90s using 16F84 microcontroller where there wasn't any video hardware but the microcontroller had to generate composite video signal and audio for the game (Tetris) without help of WSYNC or HSYNC signals and if I remember correctly the same pins were used for both generating the video signal and reading the buttons. And everything was made with just 1K of program memory and 68 bytes of RAM :-) I still have that 16F84 Tetris on an old breadboard. Thank you for the link, I will sure watch :-) Regards

  • @gizaha

    @gizaha

    4 жыл бұрын

    They used their brain. Today marketing is enough. Gamer's hype reactions feed marketing and make it stronger.

  • @carlfranz6805

    @carlfranz6805

    3 жыл бұрын

    @@ChupoCro Ah, yes. Programming to the Raster. That brings back, um, er, nightmares.

  • @samljer
    @samljer4 жыл бұрын

    I have to wait 2 weeks for the PPU video, GAH! lol

  • @hardee8742
    @hardee87424 жыл бұрын

    well done, спасибо

  • @icupiii
    @icupiii4 жыл бұрын

    Just Wow!

  • @kd9kck376
    @kd9kck3764 жыл бұрын

    Also the cartridge preventing the CPU from actually writing could be for emulation prevention. Like in some modern games they check to see if there memory is actually read only like they expect or not.

  • @i_youtube_
    @i_youtube_4 жыл бұрын

    What do you thing of using C++ for Windows Application in 2019?

  • @MaiconMatos08
    @MaiconMatos084 жыл бұрын

    Isso que o Cara Falou No Vídeo é Tudo Verdade.

  • @lonnybulldozer8426
    @lonnybulldozer84264 жыл бұрын

    Very nice. Your diagrams look crisp and are quite helpful. Unrelated and you probably answered it somewhere, but where does your name "javidx9" come from? Is it random or is there a backstory? Cheers.

  • @allansousa1853
    @allansousa18534 жыл бұрын

    Gold content

  • @manuellehmann267
    @manuellehmann2674 жыл бұрын

    Will you implement the illegal op-codes at some point?

  • @timothydahlin5321
    @timothydahlin53214 жыл бұрын

    Can you go through your build process in a video or have a write up in the git repository?

  • @robertboran6234
    @robertboran62344 жыл бұрын

    Great !

  • @ItzSkyBound
    @ItzSkyBound4 жыл бұрын

    Hey! Quick question, I've made C# Desktop Applications (not in console), but I'm not yet sure how to do this in C++?

  • @JohnDlugosz

    @JohnDlugosz

    4 жыл бұрын

    You are expecting a quick answer? Try looking at the Microsoft's C++ with .NET extensions that compile to MISL. Then you can use all the .NET desktop application classes you already know.

  • @TheTobylyn
    @TheTobylyn Жыл бұрын

    Hi, amazing videos :D Question: I during a project where i want to read sprite data directly from the cartridge, not running the game itself( maybe with a atmega1284p). I quess i can read the pattern tables directly from the character ROM and the pins connected to it. But i need the OAM data to know how the tiles are connected and how many to each sprite and so on. I'm a bit confused on where to find this data? Is it different from each game, or is there a pattern to look for? I think i have seen and read too many tutorials and got a bit confused:b

  • @javidx9

    @javidx9

    Жыл бұрын

    Thanks! Sadly there isn't such a thing as sprite data. The OAM is entirely algorithmically constructed. The best you can do is rip the pattern tables, and then manually glue the cells together. Even if you could easily read OAM during runtime, it would still need deciphering with which components are part of which sprite

  • @imnotblackpinkfanimtheirai5300
    @imnotblackpinkfanimtheirai53004 жыл бұрын

    Hey Javid. I have one problem with olcConsoleGameEngine.h. how can I get keyboard event when I press letters such as 'a', 'd', 'w', 's',...? tkanks

  • @Bluresco
    @Bluresco3 жыл бұрын

    Hi, I hope you can help me, I want to burn a supermario world nes rom in a cartridge, however the cartridge does not support mapper 90, which is the rom mapper, do you know any way to modify the mapper without damaging the rom? thanks

  • @bubuche1987
    @bubuche19874 жыл бұрын

    If I understand correctly, the mapper is "something that doesn't give the same answer for the same question". Which is basically what a web server do. So there is no limit of the size addressable with a mapper, there isn't even the constraint that the address actually maps something (I am thinking of a vector image with infinite zoom). So, would it be possible, or even feasible to have a LUA mapper. The mapper (c++ side) would just delegate the job to a lua script and let it do whatever it wants and provide whatever answer it wants. Technically, you could have a game running entirely in lua and give the final result to the ppu. You could also have a "cartridge" that actually has an internet connexion, and have online multiplayer on your virtual nes, or a screen with games selection, or 3D with advanced shaders (and repalettized in the final step). (I think I have tinnitus right now, I am hearing "heretic ! heretic !" :) ) The main question is : how fast is lua ? I heard it's really fast, but here we are talking about maybe 60 fps which may be a bit too much. I am entirely in favor of a customized nes (and for everything above I remember that the condition for this is "a mapper delegating things to lua, so it's not hard to do). A nice customization I think about since the first video of this serie is the possibility to change the internal frequence of the cpu, or even decide when a frame should end. Of course it would be for custom games only.

  • @NesrocksGamingVideos

    @NesrocksGamingVideos

    4 жыл бұрын

    David Keller there is something like this. Look up pi in a nes cart.

  • @mrflamewars
    @mrflamewars4 жыл бұрын

    I got to look at a Zelda 1 PCB recently, and it surprised me by using Character RAM instead of ROM. There's another 8KB SRAM for the save in there and an MMC1. NES Carts are weird.

  • @guxershmeg
    @guxershmeg4 жыл бұрын

    nice

  • @WilliamLDeRieuxIV
    @WilliamLDeRieuxIV3 жыл бұрын

    9:33 You can simply the logic in cpuWrite to one comparison per each if block. if (addr cpuRam[addr & 0x07FF] = data; } else if (addr ppu.cpuWrite(addr & 0x0007, data); }

  • @seditt5146
    @seditt51464 жыл бұрын

    12:03 "Little Red Wiggly"..... Is that a Technical term,... and if so is it going to be on the test?

  • @TomershalevMan
    @TomershalevMan4 жыл бұрын

    hi, have you considered using compile time polymorphism instead of runtime for implementing the mappers. the runtime polymorphism is highly inferior performance wise (although it reads more easily). I would love to see a benchmark comparison on that point. keep up the great work

  • @2k10clarky

    @2k10clarky

    8 ай бұрын

    Or just use a switch ... see 'clean code horrible performance' although for 6502 emulation I'm pretty sure that any modern processor would handle it with plenty to spare

  • @shadyalnajjar1082
    @shadyalnajjar10824 жыл бұрын

    ❤❤❤❤❤

  • @theharbingerofconflation
    @theharbingerofconflation4 жыл бұрын

    How does an and between addresses work?

  • @fnjesusfreak
    @fnjesusfreak4 жыл бұрын

    I tend to use the phrase "incomplete decoding" rather than mirroring (possibly because of my history with the Apple ][).

  • @ilikemorestuff
    @ilikemorestuff4 жыл бұрын

    More NES please :0)

  • @ryanstewart6834
    @ryanstewart68343 жыл бұрын

    Hey Javid In your previous video you said that the Pixel Game Engine would not affect emulation at all and was just a visualiser. However from 31:48 you start including PGE code into the PPU itself such as Sprite and Pixel. This was a big part of the emulation to me eg. I really wanted to build an emulator that doesn't rely on any external code bar OpenGl or similar. Is this temporary or is the rest of the emulator built on top of the Pixel Game Engine? Thanks for the what I'm sure was hundreds of hours of work PS.thanks for the vindication re: the bug i the disassembly, it was driving me crazy and I wasn't sure if it was my own code at fault or not! lol

  • @javidx9

    @javidx9

    3 жыл бұрын

    Hi Ryan, the emulator doesnt rely upon PGE in any real way - but ultimately I do need to draw things to the screen. Since all PGE does is draw pixels to a window, it seemed like an appropriate tool. The olc::Sprite buffer is just an array of olc::Pixels, which are 4 component RGBA integers. No special magic involved. PGE uses OpenGL too, so anything you implement would probably look very similar.

  • @ryanstewart6834

    @ryanstewart6834

    3 жыл бұрын

    @@javidx9 Thanks very much, I suppose if i make it though this emulator i'll just follow your game engine tutorial too to remove that "black box" - thanks again!

  • @HarryPotterFan134

    @HarryPotterFan134

    3 жыл бұрын

    @@ryanstewart6834 How did you get on with using the pge? I followed part 3 and ended up getting runtime errors deep in the pge code which is quite hard to debug because its code i've had to copy and paste in with no context Drawing the pixels is a main aspect of the emulation and to be 2+ hours into a tutorial before we find out we'll be depending completely on this external code is frustrating

  • @ryanstewart6834

    @ryanstewart6834

    3 жыл бұрын

    @@HarryPotterFan134 Runtime errors there could be a symptom of a bad CPU or PPE implementation, I had an issue with a runaway program counter that manifested itself as read access exception in the engine. I had the same initial reaction, but really the PGE allows you to focus on the important stuff - emulating a NES internally. I plan to finish the series then go back and write my own implementation once I know my emulation is good

  • @marcink.2393
    @marcink.23934 жыл бұрын

    Hello! Definitely NES :)

  • @GustavoValdiviesso
    @GustavoValdiviesso4 жыл бұрын

    Yeap, my interest in building my own emulator is also to make my own mapper. But, I intent to build it physically, in hardware. If you think that sounds like a nice project, drop a message. 😉

  • @fathimaabdullah3365
    @fathimaabdullah33654 жыл бұрын

    Can we have a series on high level emulation next? maybe the gameboy advanced?

  • 4 жыл бұрын

    34:13 why do you prefer _>= 341_ & _>= 261_ instead of _> 340_ & _> 260_ ?

  • @javidx9

    @javidx9

    4 жыл бұрын

    Visually they inform me of more information quickly. I can see straight away that 341 is an important number that needs to be included in my comparison rather than it be implied. At the same time, im uninterested in the value 340.

  • @dynamagon
    @dynamagon Жыл бұрын

    I'm trying to do this in lua right now, and I'm stuck at the mapper part. It seems like you put in code that isn't even used and it's really confusing me... is there something I'm missing?

  • @InverseOfficial

    @InverseOfficial

    10 ай бұрын

    Very late to this one but I'm in the same boat right now but using python. I will post another reply when I get it working. I've tried to understand it all, but the cpu reads and writes go immediately to the bus, and the mapper and cartridge never interact at all.

  • @TheRandomSpectator
    @TheRandomSpectator4 жыл бұрын

    I've seen you do this several times, and perhaps you already explained it (I don't have c++ experience myself), but why do you call a function, then immediately call it again with "~" in front of it? What purpose does the tilde serve? For example, at 13:23 public: olc2C02(); ~olc2C02();

  • @davidmcgill1000

    @davidmcgill1000

    4 жыл бұрын

    Constructors and destructors. Constructors are called when the object memory needs initialized and destructors are called when its memory is getting freed and object removed.

  • @michaelburns8073

    @michaelburns8073

    4 жыл бұрын

    These are not actually calls. This is part of the definition of the class, and what these two lines are saying is this class has two special 'methods' that it plans on defining. These methods always have the same name as the class you are defining. The first one (olc2C02) is called a constructor, and (with some simplification) when you actually create an object of the olc2C02 class (using something like *new* keyword) you will call the olc2C02 constructor that you defined as part of the olc2C02 class. Conversely, the the ~olc2C02() is going to define something called a destructor, and with some simplification here also, once you are done with object, it will call the ~olc2C02() destructor that is defined for the class. Defining these two types of functions helps with setting up (in the case of the constructor) or cleaning up (in the case of the destructor) as you use an object. This is all a part of a basic understanding of C++, so as a suggestion you might want to review about how C++ declares classes and especially what constructors/destructors do and how/why they are used. Hope this helps!

  • @TheRandomSpectator

    @TheRandomSpectator

    4 жыл бұрын

    @@michaelburns8073 I've done plenty of Java work, so I'm familiar with constructors, but thanks for clarifying the destructor. So it's basically malloc() and free() for that specific object (as C would put it), right? Also, is the destuctor called automatically? I know in C++, and especially C, you really have to work at managing memory, and I've not seen a ton of C++ code, but I don't recall seeing an explicit call to a destructor before (other than in the declaration that I asked about).

  • @techgo4431

    @techgo4431

    4 жыл бұрын

    @@TheRandomSpectator yes it's called automatically

  • @michaelburns8073

    @michaelburns8073

    4 жыл бұрын

    @@TheRandomSpectator It's similar to malloc and free, but to me it's much more, because malloc() and free() generally only obtain/free memory, but object creation/destruction is much more than that, but I understand what you mean. Yes, you do have to manage your memory in C++, which in Java is usually handled by the garbage collector. In C++, once an object goes out of scope, then it's destructor is called. If your C++ object did things like allocate memory, then the destructor needs to free and clean it up. In Java, although it can cause problems if you hold memory for a while, in most cases you don't worry about it because the GC will get around to cleaning it up once it can. Java does have the finalize() method to help do similar things like you might need to do in a C++ destructor, like close file references or network ports, etc. For fun, I thought about trying to do at least the 6502 emulator in Java, since I do Java development for a living, but tbh, C++ is better suited for this kind of thing, although I think it would be an interesting technical challenge to try it.

  • @danielf.7151
    @danielf.71513 жыл бұрын

    I know this vid is almost a year old, but how can you use std::shared_ptr without including ?

  • @mutated__donkey5840
    @mutated__donkey58404 жыл бұрын

    Where did you get the nestest.nes file

  • @mathieu1881

    @mathieu1881

    4 жыл бұрын

    Might be late to the question but you can find it in the nesdev wiki under cpu section second from last. I was wondering that too since the simulation just opens a blank screen and closes if it doesn't find the file. There is some nice documentation too for that test. wiki.nesdev.com/w/index.php/Emulator_tests

  • @nathanericschwabenland88888
    @nathanericschwabenland888882 жыл бұрын

    Wow easy to learn hard to master

  • @nathanericschwabenland88888

    @nathanericschwabenland88888

    2 жыл бұрын

    I am learning c plus plus so far

  • @nathanericschwabenland88888

    @nathanericschwabenland88888

    2 жыл бұрын

    I am age 31 years old and have barely even gotten this deep into the Nintendo entertainment system

  • @jeffdowling1682
    @jeffdowling16822 жыл бұрын

    At 32:00 that code just breaks everything from this video on for me. Compiler error c2280 “attempting to reference a deleted function”.

  • @joshuamaldonado1721
    @joshuamaldonado17213 жыл бұрын

    I'm getting an error at 32:05 and its driving me crazy, line that's messing me up is olc::Sprite sprScreen = olc::Sprite(256, 240); and its producing four errors (all the exact same Severity) C2280 'olc::Sprite::Sprite(const olc::Sprite &)': attempting to reference a deleted function is this just a basic thing that I am too stupid to understand

  • @jeffdowling1682

    @jeffdowling1682

    2 жыл бұрын

    Glad its not just me any updates or did you give up like I am about to.

  • @javidx9

    @javidx9

    2 жыл бұрын

    The error means that trying to copy the sprite is no longer allowed, which is correct in current versions of PGE. Either use the PGE version with the emulator or use the sprite's Clone() function to create a copy.

  • @jeffdowling1682

    @jeffdowling1682

    2 жыл бұрын

    Thank you so much for answering all this time later! I was thinking it was an update issue since there is no PGE file included with this series zip file. I dug deeper on github and found all the releases and got the version closest to this video’s date and it…still didn’t work because I didn’t have nestest but once I got that it worked. I think I had worked a fix before but still failed because of missing nestest. I really appreciate your videos that are helping me learn and more so helping years later. Thank you so much!

  • @javidx9

    @javidx9

    2 жыл бұрын

    Glad you're enjoying the puzzle that is emulator programming!

  • @ludoattuoni3681

    @ludoattuoni3681

    Жыл бұрын

    @@jeffdowling1682 Where did you get the nestest.nes file if you dont mind me asking?

  • @vilkillian
    @vilkillian10 ай бұрын

    7:23 it's checking for address to be in range of 0x0000 to 0xFFFF for uint16_t is kinda.... redundant?

  • @javidx9

    @javidx9

    10 ай бұрын

    No. The compiler will obviously optimise that out. But what I get for free is a highly visual filtering system so it's easy to see what's going on. Also pretty useful for folk who follow along and don't use typed languages.

  • @vilkillian

    @vilkillian

    10 ай бұрын

    @@javidx9 i'm absolutely amazed that you've checking and replying comments for videos that are 3yrs old. Thank you for reply! In terms of educational piece of code and video, yes, you're absolutely right in terms of readability. Though, it would be a performance issue in some kind of interpreted language without JIT, which is not the case here. Also, can't wait for the next code jam :)

  • @TomershalevMan
    @TomershalevMan4 жыл бұрын

    pure gold. you should instruct at Udemy

  • @iProgramInCpp
    @iProgramInCpp4 жыл бұрын

    One of the improved NES capabilities you could give it is give it 8KB of RAM instead of just 2. The way you'd do that is very simple in emulators - just give up the & 0x07FF part and raise the RAM amount to 8KB. Some idiotic programmers might have decided to use RAM mirroring to their advantage, so I'd also suggest that when you write 0xFF to (for example) 0x3FFF, it would not write to the PPU, but would enable the 8KB mode. You can also do that in real hardware, however it's a little difficult. The address mapper has 2 unused pins that would have linked to the higher 2 bits of the RAM address, but don't, thus the mirroring. So what you could do is replace the RAM chip with an 8KB chip and use these normally unused bits. It would take a little bit more time to also implement the enabling of this mode, however it is possible.

  • @fredg8328

    @fredg8328

    4 жыл бұрын

    But what's the point to give it 8kb if the original software don't use it ? If you run it on a PC with 4Gb of RAM you could even allow the NES to acces all this RAM with a bank switching mechanism. But again what's the point if no software uses it ?

  • @iProgramInCpp

    @iProgramInCpp

    4 жыл бұрын

    @@fredg8328 homebrew AND what Javid wanted (he wanted some games that only worked on his emulator)

  • @rob-890
    @rob-8904 жыл бұрын

    I love this channel!! PS4 emulator for your next project 🤣

  • @javidx9

    @javidx9

    4 жыл бұрын

    lol thanks rob-DEV!

  • @skilz8098

    @skilz8098

    4 жыл бұрын

    That is currently a PIPE Dream ATM because RPCS3 is still in development of the PS3 Emulation, they've been at it now for at least 4-5 years, and it is still considered early development and the core engine is constantly changing; and this isn't being done by a single person; it is being done by hundreds or even thousands of people within an open source community... I could maybe see the SNES, the Sega Genesis and possibly even the N64 but once you get to the consoles that moved away from ROM Cartridges and started using DISC formats, the challenge of Emulation increases exponentially, especially when they add copyright protection algorithms, compression and decompression, anti-piracy etc. to the mix. Take a Blu Ray Disc for example; if you zoom in on the outer layer of the "Pressed Disc" not "Burnt", you will see what appears to be a form of a sine wave that encompasses the outer edge of the disc. There are many different patterns of these waves that can be generated during disc manufacturing either it be a Blu Ray movie or a PS3 - PS4 game etc. A burner can not mimic this as this is done within the pressing stage of making the disc. Also there are some discs that have periodic blank spots which also can not be done by a Burner. These in combination gives the manufactures the ability to hard code onto the disc anti-piracy - anti-copying. This is why you have to periodically update your Blu Ray player over the internet. A new movie or game comes out and the Player or Console can not even as much read the disc because they generated a new wave form with different blank spots on the disc. So asking for a single person to Emulate a PS3 is a bit much never mind the PS4!

  • @rob-890

    @rob-890

    4 жыл бұрын

    @@skilz8098 It was a JOKE! :)

  • @skilz8098

    @skilz8098

    4 жыл бұрын

    @@rob-890 I know but I was stating the obvious for other readers...

  • @skilz8098

    @skilz8098

    4 жыл бұрын

    Let's emulate a quantum cpu on a 6502!

  • @henke37
    @henke374 жыл бұрын

    Why does the Cartridge class do the actual access when the mapper is the only one who actually knows how the access should be done? I strongly suspect that at least one mapper will want to do something funky instead of just accessing the arrays.

  • @LeKukie
    @LeKukie4 жыл бұрын

    "Imagine that there's a BUS"

  • @jeffreyvedha4871

    @jeffreyvedha4871

    4 жыл бұрын

    Is that u darbian?

  • @FP63
    @FP634 жыл бұрын

    Why nintendo decided to use mirroring for RAM instead of direct access to third, fourth kb?

  • @javidx9

    @javidx9

    4 жыл бұрын

    Ram was very very expensive! So it was provided as the bare minimum thought to be required.

  • @ryanfarrell153
    @ryanfarrell1534 жыл бұрын

    I don't think I've ever been this early, damn😂

  • @javidx9

    @javidx9

    4 жыл бұрын

    lol, that was pretty quick!

Келесі