NES Emulator Part #7: More About Mappers

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ก.ย. 2024
  • In this video, I look at how I've implemented NES Mappers 0, 1, 2, 3, 4 & 66 as part of my NES emulator. Given this is part #7 its presented in a different style, and assumes you have watched the previous episodes.
    Source: github.com/One...
    Patreon: / javidx9
    TH-cam: / javidx9
    / javidx9extra
    Discord: / discord
    Twitter: / javidx9
    Twitch: / javidx9
    GitHub: www.github.com...
    Homepage: www.onelonecod...
    Community Blog: community.onel...

ความคิดเห็น • 98

  • @thomasmurphy8749
    @thomasmurphy8749 4 ปีที่แล้ว +49

    Great! I was beginning to fear that you had abandoned this series. Excited to keep learning more while I develop my emulator in parallel :) This is one of the best resources on the NES that I've seen.

    • @javidx9
      @javidx9  4 ปีที่แล้ว +15

      Thanks Thomas, certainly not abandoned, but I (and most of my audience XD) needed a short break from NES for a bit. I definitely have at least one more left, finishing up the sound, but it will be mixed in with normal videos. I'm unsure after that, I may do a quick one about save states, and user interfaces.

    • @GeneralAtrox1
      @GeneralAtrox1 4 ปีที่แล้ว +6

      @@javidx9 perhaps a video on theory crafting improvements you could consider adding to the NES emulator to improve the experience?
      Whether its adding post process effects like scanlines, texture filtering, Super Eagle, netplay, or... how did those devs make the NES 3D? (Vid for ref: th-cam.com/video/46kxc03W37w/w-d-xo.html)

  • @gabrieljosereyesacosta7007
    @gabrieljosereyesacosta7007 4 ปีที่แล้ว +25

    I nominate this as one of the best programming class/ lesson of the year

    • @somerandomchannel382
      @somerandomchannel382 ปีที่แล้ว

      was the sound sorted out? SMB3 in demonic tunes was an.... experience :)

  • @johnforde7735
    @johnforde7735 3 ปีที่แล้ว +17

    For other viewers, at 32:19, there is an error in line 201 on the screen. I believe that should be 0x1000 rather than 0x2000. I got Zelda 2 working with this change.

    • @oracleoftroy
      @oracleoftroy 2 ปีที่แล้ว

      Thank you! Now my towns aren't invaded by monsters!
      Alternatively, you can left shift the bank by 1 (or divide it by 2) to put it in an 8k range. I'm thinking of scrapping my current version (or at least doing a third refactoring of this mapper), but I currently have it treat the 4k banks as 4k and 8k banks as 8k instead of treating 8k banks as two 4k banks.

  • @figloalds
    @figloalds 4 ปีที่แล้ว +27

    Awesome, such high quality and deep knowledge shared 👏

    • @javidx9
      @javidx9  4 ปีที่แล้ว +2

      Cheers Felype!

    • @tunit6458
      @tunit6458 2 ปีที่แล้ว

      +

  • @zerobyte802
    @zerobyte802 4 ปีที่แล้ว +18

    Part 8 - I need it!

  • @Nob1ej0n
    @Nob1ej0n 3 ปีที่แล้ว +3

    It's taken me ages, but I've finally caught up with this series. Not just in terms of watching it, but I've also got my own emulator now with everything but sound working! Thank you so much for this series. It was a great resource and a fantastic barometer for how far my understanding had come. More than once I had to stop a video halfway through and take a few weeks to catch up before I understood enough to finish the video. It was so much fun each time to feel like the information that used to be Greek to me suddenly seem simple! This has been a wild and enjoyable ride. Thank you so much for doing this series, and a ton of other interesting programming projects! I love your channel, not just this one series. Haha

    • @javidx9
      @javidx9  3 ปีที่แล้ว +1

      Lol thanks Jon, it's fun building an emulator huh?

    • @Nob1ej0n
      @Nob1ej0n 3 ปีที่แล้ว +1

      @@javidx9 Haven't had this much fun in years! And dev is my day job. Haha

  • @gertjohansen4849
    @gertjohansen4849 ปีที่แล้ว +1

    I know this is an older series, but I have just watched it (repeatedly) and I'm very impressed. Very good explanations.
    With the information given in this series, I managed to create my own emulator in C# and WPF using the NAudio library for sound.
    I made it more modular, so I have a library with just the bus and CPU and some baseclasses for devices. Then I made the emulator, by adding the Cartridge, PPU, Apu and Controller as classes inheriting from DeviceBase. This way I should be able to create a C64 emulator, based on the same framework, if I ever feel confident enough to take it on ;)
    I did end up copy/pasting some of your code and rewriting it in C#, because some of the more technical details were too complicated for me. But I gain more and more understanding of it, the more I mess around with the code.
    For me, the PPU was the hardest to understand. The sound gave me some problems as well, but once I could see, that my sample-value was the same as yours, I could focus on NAudio and figure out how to output it correctly.
    If I understand correctly, your sound implementation gets 1 sample at the time? NAudio wants 6615 samples at a time (with the default samplerate and 1 channel), so I just needed to keep clocking until I had all the samples and not only 1.
    So all-in-all... Awesome job. I really enjoyed the very detailed explanations and drawings.

  • @tzisorey
    @tzisorey 3 ปีที่แล้ว +1

    I like how you can tell from the reflection in the door behind him, that he's "talking with his hands", but you don't actually have them in-shot.

  • @ConfusedNDazed
    @ConfusedNDazed 2 ปีที่แล้ว +1

    Getting back to my Emulator after leaving it for a couple of years, abandoned after not being able to fix a colour issue in Super Mario Bros and scrolling. Still haven’t fixed it, but am moving on to mappers so I can test some different side scrolling games to see if that helps locate the bug. This video is so clear in how to translate those nesdev mapper pages to code that i think i can probably complete the same mappers in a weekend. Just taking your explanations and not the code, like to work out the code side myself.
    Also I really like the way your code uses a bus, seems so obvious to me now to use a bus class, but it didn’t when I started.

  • @mrflamewars
    @mrflamewars 4 ปีที่แล้ว +1

    One of the neatest MMC3 tricks is switching frames of animation out in real time in games like Super Mario Bros 3, the animated tiles on the world maps and the scrolling question mark blocks are all using the MMC to page the blocks of animation without involving the CPU doing it directly.

  • @speedyc88
    @speedyc88 4 ปีที่แล้ว

    Hello! Javidx9, I just watched part 7 of your NES Emulator series. With great Interest, this series is an epic just like a good book it leaves me wanting more, or anyone else who has been watching this great series. Javidx9, I hope this video series never ends, or you may decide to create NES Emulator 2.0 one day LOL. All the best from ‘Speedy C’

  • @gmaz6687
    @gmaz6687 4 ปีที่แล้ว

    With these videos you are making real not only your dream but also the dream of thousands of people like you. Thank you a lot, this is the best nes emulator series tutorial.

  • @johnforde7735
    @johnforde7735 3 ปีที่แล้ว +3

    Great series. I have followed along and built a NES emulator in Swift for iOS and Mac. I did the sound quite differently to use Cocoa audio libraries, (however, it's not sounding that great). It was an effort to get the performance. Swift uses reference counting (like smart pointers) to manage your memory, which can cost if you aren't careful.

    • @ConfusedNDazed
      @ConfusedNDazed 2 ปีที่แล้ว

      I am also doing a NES emulator in Swift. I did a synthesizer in Swift a few years back and found that both AVAudioEngine and Swifts ARC (as you mention) really mess with Audio Programming. I was hoping to hook up the synth to the Emulator in a similar way to Javidx9, but I don’t think that is going work unless I drop down to Audio Units and C++ for the APU. Swift performance has been a big disappointment when working with both Audio and Emulators, and when you combine them 😭

    • @johnforde7735
      @johnforde7735 2 ปีที่แล้ว +1

      @@ConfusedNDazed For a start, you need to compile in release mode to get anything going with any performance and you should use the time profiler performance to see where you are getting performance hits. I found that using a protocol for the mappers was a big hit, so I removed that. I used classes for everything and put some time in writing an efficient loopy register, which is a struct. I get 60 fps on my 8 year old 4 core Mac and 75 - 80 fps on my new iPhone (before I lock it to 60fps). I got audio sounding a lot better now. I use AVAudioEngine as well and circular sample buffers.

    • @ConfusedNDazed
      @ConfusedNDazed 2 ปีที่แล้ว

      Yes I'm in Release mode, my day job for past 10 years is as an iOS App developer. I must admit that I find Xcode's Profilers quite difficult to use, compared to the old command line prof tools I used 20 years ago on unix platforms. I recently got a big speed boost by doing two things. I added @inline(always) to all of of my frequently called functions in the CPU and PPU, and I found a place where I was allocating 8 bytes of memory for the Sprites each frame (rookie mistake). I did try converting from reference types to value types for the CPU and PPU, but go change in performance.
      My main complaint is around my Synth which seems to struggle using AVAudioEngine, I get noticeable static when more than one note is playing, which I believe is due to Swift performance issues, Apple advises not to use Swift in the real time buffer generation code. I have done things like caching AVPlayerNodes and using Neon commands in my loops. I ended up just buying a Behringer synth in the end and putting the Swift one away. But I will get back to it soon when I start the APU, hopefully it will be a case of fresh eyes finding an obvious bug and not have to drop down to C++ or lower level Audio frameworks.

    • @johnforde7735
      @johnforde7735 2 ปีที่แล้ว +1

      @@ConfusedNDazed Well, I did get quite a bit of static with audio, but it is a lot better now. This is my buffer code, which I stole from some article online:
      final class AudioGenerator {
      private var length: UInt32
      var sourceNode: AVAudioSourceNode!
      var sampleBuffer: ApuSampleBuffer
      init(length: UInt32) {
      self.length = length
      sampleBuffer = ApuSampleBuffer(audioLengthSamples: length)
      sourceNode = AVAudioSourceNode { _, _, frameCount, audioBufferList -> OSStatus in
      let ablPointer = UnsafeMutableAudioBufferListPointer(audioBufferList)
      for frame in 0..

    • @ConfusedNDazed
      @ConfusedNDazed 2 ปีที่แล้ว

      @@johnforde7735 I really really appreciate you posting your code. I think I can see why this works better than my code, the use of

  • @mrflamewars
    @mrflamewars 4 ปีที่แล้ว +1

    The bank switching hardware inside NES/Famicom carts really saved the system from being a historical footnote. The original Super Mario Bros was supposed to be the biggest possible cart game and would have been had it not been for the "Multi Memory Controller" or "Memory Management Controller" or whatever it's supposed to be. I always wondered as a kid why Super Mario Bros. 3 was so much more sophisticated than Mario 1. The answer is it had an MMC3 and Extra RAM in the cartridge.

  • @arthurvin2937
    @arthurvin2937 3 ปีที่แล้ว +3

    This reminds me how far from the roots I have drifted, being a Java EE developer for 10 years. The lack of understanding of low level machinery hits you hard later in career. Considering that Java is relatively low level compared to some Python or PHP - RIP Python and PHP developers.

  • @valeyard93
    @valeyard93 4 ปีที่แล้ว +1

    Great info. I'd implemented an Atari 2600 emulator last year and it uses bankswitching as well. I started working on a NES emulator when you came out with your series. I have a few mappers working there as well.

    • @ConfusedNDazed
      @ConfusedNDazed 4 ปีที่แล้ว

      Jordan Hargrave I’m wanting to do a 2600 emulator next but haven’t found much information, do you have any good resources ?

    • @valeyard93
      @valeyard93 4 ปีที่แล้ว +1

      @@ConfusedNDazed Stella programmer's guide (atariage.com/forums/applications/core/interface/file/attachment.php?id=594256) gives detail of the register and I/O ports.
      Also the Atari 2600 programming for Newbies has some sample kernels with very basic code to make sure you get the display working.
      www.randomterrain.com/atari-2600-memories-tutorial-andrew-davie-08.html

  • @jaysistar2711
    @jaysistar2711 ปีที่แล้ว

    At the beginning, the dog that's probably staring at him can be seen in the reflection. Interestingly, the Turbo Grafix 16 (PC Engine) carts are small, and more like cards, and I haven't seen any of them use mappers at all. The NES and Famicom used them quite a bit, but the Famicom Disk System, like the HuCard of the TG16, couldn't add any hardware beyond the Nintendo RAM cart, which did add another sound channel, and because you had the disk, you could read contents into the extra RAM to use them like banks, although that couldn't be done very quickly. There also was nothing like the SMB3 virtual vertical space with mapper made horizontal scrolling.

  • @ultraman6950
    @ultraman6950 3 ปีที่แล้ว +2

    Looking forward to the Switch one.

  • @mohammednihad6755
    @mohammednihad6755 4 ปีที่แล้ว +4

    Thanks a lot for all the effort you put in your tutorials, God bless you 💙
    But where is the source of part #6? ☹️

  • @yokrysty
    @yokrysty 4 ปีที่แล้ว +6

    Love this series, best content so far. Will you continue the series?

    • @javidx9
      @javidx9  4 ปีที่แล้ว +3

      Thanks! I have put together material for a sort of "finishing off" video, but the core emulation is verbosely described by this point.

    • @jdunlap1974
      @jdunlap1974 3 ปีที่แล้ว +4

      @@javidx9 I actually wish that you would finish off the APU portion. You had said there was going to be another part to put it all together, but we haven't seen that yet.

    • @bobapplemac
      @bobapplemac ปีที่แล้ว

      ⁠@@javidx9 I would also love to see the 2nd APU video!

  • @esabaliauskas
    @esabaliauskas 4 ปีที่แล้ว +3

    wow, this is amazing!

  • @Niko-ex3bn
    @Niko-ex3bn 4 ปีที่แล้ว

    You got a sub from me. I have concidered working on an NES emulator as my next project after I finish up adding features to my gameboy emulator and fixing bugs.
    I shall likely use these videos as a reference point and in case i have difficulty understanding some concepts.

    • @demolitionist42
      @demolitionist42 4 ปีที่แล้ว

      What should I start emulating if I am new to this? I'm comfortable with C++

    • @Niko-ex3bn
      @Niko-ex3bn 4 ปีที่แล้ว

      @@demolitionist42 Mmm, Chip-8 is a very good start. Its fairly simple to get started with and gives a good foundation on how to emulate more complex systems.

  • @irene1307
    @irene1307 4 ปีที่แล้ว

    New video - insta-like. Great content always

  • @pedrolopez3830
    @pedrolopez3830 4 ปีที่แล้ว +2

    You always make me to abandon de couch and go straight to programming, for that huge thank you ♥️

    • @javidx9
      @javidx9  4 ปีที่แล้ว

      Sorry XD its also late on a Sunday night too!

    • @qwerasdfhjkio
      @qwerasdfhjkio 4 ปีที่แล้ว +1

      @@javidx9 I mean... Time zones exist xD

    • @pedrolopez3830
      @pedrolopez3830 4 ปีที่แล้ว

      @@javidx9 don't worry, I'm from Chile so here it's really early, about 7 pm now, and the sun sets at 10pm so I still have some time ahaha

  • @ConfusedNDazed
    @ConfusedNDazed 4 ปีที่แล้ว +5

    I’m going to be that guy. Are you going to do part 2 of the APU ? It was so interesting, almost as good as the PPU video.

    • @javidx9
      @javidx9  4 ปีที่แล้ว +3

      I will be yes. Barely covered the APU in that video, it was more about integrating sound into a real time application.

    • @ConfusedNDazed
      @ConfusedNDazed 4 ปีที่แล้ว

      javidx9 awesome, looking forward to it. I quite liked this one too as there isn’t a whole lot of good info on how to implement mappers available.

  • @ZomB1986
    @ZomB1986 4 ปีที่แล้ว +1

    48:17 Bug found: Line 93, 95, 100, and 102: you must use inclusive-OR instead of addition to prevent corruption of the bank registers in the same spirit as the masking in the lines directly above. Github link: github.com/OneLoneCoder/olcNES/blob/1db7fcad56591d22de36300b53da603a7c996125/Part%20%237%20-%20Mappers%20%26%20Basic%20Sounds/Mapper_004.cpp#L147

  • @supersquare
    @supersquare 4 ปีที่แล้ว +1

    The legend returns!!

  • @johneygd
    @johneygd 4 ปีที่แล้ว +1

    Am curious if the mmc3 chip could also optionally hijack the nes cpu to allow multi scrolling backgrounds via tile updates on the fly trough the extra added video ram ,because multi scrolling overlaping backgrounds are seen in games such as metal storm,buki o hare, i know that games such as ninja gaiden 3 and batman rtoftj uses line scrolling for paralax scrolling effects,
    THX alot.

  • @razcodes
    @razcodes 4 ปีที่แล้ว +1

    Are you using a graphics tablet for One Note? If so, which model? Thanks!

  • @wadimajason
    @wadimajason 4 ปีที่แล้ว

    good serie, your house looks like Resident evil house hehe

  • @vaendryl
    @vaendryl 4 ปีที่แล้ว +1

    cool to see you created the whole vid just the day before lol.
    was hoping the 7th episode was going to continue on the subject of sound. oh well

    • @ConfusedNDazed
      @ConfusedNDazed 4 ปีที่แล้ว +1

      vaen dryl me too, was hoping for sound part 2

  • @aliusa6327
    @aliusa6327 4 ปีที่แล้ว +1

    thanks 👍 you are awsome

  • @Omnituens
    @Omnituens 4 ปีที่แล้ว

    In the Game Boy the lower half of the address space is ROM, and usually bank 0 is fixed into the lo half of that. The NES and Game Boy share quite a lot of features, but it seems mapping was flipped on its head for the Game Boy, maybe because of the Z80-esque chip in it? Or because the zero page/stack of the 6502 in the NES warrented the need to use the upper part of the address space for ROM, and for the Game Boy they thought it was better the have lo be ROM?

  • @benjaminentertainment5526
    @benjaminentertainment5526 4 ปีที่แล้ว +1

    This is so cool! Its like making an nes classic all by yourself!
    Just wondering, is it possible to make an emulator for ps1 as well? What's the difference between nes and ps1 emulators?

    • @NethTech
      @NethTech 3 ปีที่แล้ว

      Difference between nes and ps1 emulators is literally the difference between a nes and a ps1. Entirely different, Albeit the same methodology for development

  • @sakealex
    @sakealex 4 ปีที่แล้ว

    bless you sir

  • @timbodyne
    @timbodyne 3 ปีที่แล้ว +2

    Just curious as to whether or not you're planning on publishing the next episode in this series?

    • @javidx9
      @javidx9  3 ปีที่แล้ว +2

      There's not much left to show? Other than a GUI to load roms, noise channel is just noise. The triangle channel is interesting but not enough for a specific video. I'm happy you've enjoyed it so far, but it's finished isn't it? Maybe it does need a conclusion of sorts 🤔

    • @timbodyne
      @timbodyne 3 ปีที่แล้ว +2

      @@javidx9 I guess in a way it is, although I was hoping to see more in the way of the "finished product". I have to say that your project has shown me that the NES was a far better product for delivering console software than I originally thought! And my complements to you and your engineering prowess as well. You demonstrate an ease and facility with problem decomposition and refactoring that is just, well, fun to watch. All the best!

    • @javidx9
      @javidx9  3 ปีที่แล้ว +6

      Hey thanks man, that's very kind. I will seriously consider a conclusion for the series. It would be good to bookend it!

  • @aqmf2424
    @aqmf2424 4 ปีที่แล้ว +1

    Aw yiss

  • @KevinMcgaw1988
    @KevinMcgaw1988 4 ปีที่แล้ว

    Would be awesome to see a nice nes emulator for ps vita and support touch feature and can play games like duck hunt

  • @vcokltfre
    @vcokltfre 4 ปีที่แล้ว

    This seems to happen to me all the time, just yesterday I found the NES Emulator series and a few months after the last part within a couple of days there is a new video... It happens all the time to me... Well, I'm sure it will be good

  • @libb3n
    @libb3n 4 ปีที่แล้ว +1

    Finally!

  • @philtoa334
    @philtoa334 4 ปีที่แล้ว

    NiCE , nice .

  • @zilidavid373
    @zilidavid373 3 ปีที่แล้ว

    Hello!I've been trying to follow your video to code my own Emulator. It seems that Mapper66 is incorrect? The game, DragonPower, is loading the wrong background tiles. But according to Nesdev I don't think you got it wrong, so what could be the problem?

  • @josephwoodrell9922
    @josephwoodrell9922 4 ปีที่แล้ว +2

    your cats reflection in the window behind you ;)

  • @lusiaa_
    @lusiaa_ 4 ปีที่แล้ว +3

    I wanted to go to sleep in order to wake up easily for school tomorrow... but eh, that can wait

    • @Whateverworksism
      @Whateverworksism 4 ปีที่แล้ว +2

      I feel the same but for me it's work instead of school. The scenario is practically the same though, we can't stay away from another Javid video! Why sleep when we can learn? :D

    • @lusiaa_
      @lusiaa_ 4 ปีที่แล้ว

      @@Whateverworksism Exactly!

  • @racheljacobson1993
    @racheljacobson1993 4 ปีที่แล้ว

    This is cool, would be great to build an emulator for DOS games, I think there's only 1

    • @_polpon
      @_polpon 4 ปีที่แล้ว

      We have DOSbox which is damn near perfect! I guess that it's very hard to build a emulator for DOS games since there's so many peripherals (sound cards, graphic cards, multitude of controllers which have different specs), the DOS era was just....very bad when it comes to standard configurations, you could have many graphics cards that each had to be configured and treated differently, it's just a mess and much harder than emulating any more specific-purpose system like the NES. I know that I'm a bit pessimistic, but I remember how hard it was just to get things working those days, and that's with a fully functional perfect DOS which was DOS itself :), don't let that get you down though, if you are really in to it, then you might succeed. If you do it better than DOSbox I will be the first to applaud you :)

  • @hayefahayefa4874
    @hayefahayefa4874 4 ปีที่แล้ว

    greeeaat

  • @gabochoa553
    @gabochoa553 2 ปีที่แล้ว

    I need some help bro , I want to change the Mapper of master fighter vi in order to make run this game on everdrive n8, can you help me?

  • @code-dredd
    @code-dredd 4 ปีที่แล้ว +1

    @14:55: The destructor in the pure virtual class (i.e. interface) should be virtual.

  • @mqxim630
    @mqxim630 4 ปีที่แล้ว

    Лайк однозначно

  • @jimmymartinez1676
    @jimmymartinez1676 2 ปีที่แล้ว

    thank you, awesome, but olcNes #8 :(

  • @Bluresco
    @Bluresco 2 ปีที่แล้ว

    I have a big problem, I want to record a nes hack with mapper 90, super mario world, but it is impossible for me, due to the mapper, is there any way to modify the mapper 90? any advice?

  • @goshisanniichi
    @goshisanniichi 4 ปีที่แล้ว

    Gamepads and joysticks etc. are a pain in the butt, but it would be cool if you eventually added support for modern controllers.

    • @javidx9
      @javidx9  4 ปีที่แล้ว

      The controller extension for PixelGameEngine supports ps4 and xbox controllers. Adding modern controller support is the easy bit, but the console only cares about the buttons it expects to see in hardware.

  • @asas-dz4uf
    @asas-dz4uf 2 ปีที่แล้ว

    i get error compiling olc2C02.cpp error: use of deleted function 'olc::Sprite::Sprite(const olc::Sprite&)' after part 3

  • @Blonder_Studio
    @Blonder_Studio 2 ปีที่แล้ว

    Nintendo: im about to end this man's whole career

  • @diederickfloor4261
    @diederickfloor4261 4 ปีที่แล้ว

    Can you talk about hyperoperations and how you would design such a algorithm.
    en.wikipedia.org/wiki/Hyperoperation

  • @SuperTyroneGaming
    @SuperTyroneGaming 8 หลายเดือนก่อน

    Try To Code A Wii u Emulator For Android

    • @SuperTyroneGaming
      @SuperTyroneGaming 8 หลายเดือนก่อน

      And make That You Don't have to get any roms

  • @RoyalOats23
    @RoyalOats23 4 ปีที่แล้ว

    Second/Third

  • @narekhovsepian4552
    @narekhovsepian4552 4 ปีที่แล้ว

    Hello, how can I run the games, please tell me!

  • @belstar1128
    @belstar1128 4 ปีที่แล้ว

    Hey what is nes radio?

  • @Vincent_007
    @Vincent_007 4 ปีที่แล้ว

    I watch your vidoes but i don't know what you do

  • @neefofway8746
    @neefofway8746 4 ปีที่แล้ว

    8th lol