NesHacker
NesHacker
  • 39
  • 21 945 974
RNG on the NES
Try brilliant free for 30 days, and get 20% off an annual premium membership - brilliant.org/NesHacker/
In this episode I tackle Random Numbers on the NES and show a good way to implement RNG on 8-bit retro systems.
Support the channel: patreon.com/NesHacker
NES-RNG Example Project: github.com/NesHacker/NES-RNG
Credits:
Technical Editing - Kirby0Louise
Content Editing - Thomas O’Neil
Sources:
en.wikipedia.org/wiki/Pseudorandom_number_generator
en.wikipedia.org/wiki/Linear-feedback_shift_register
en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator
en.wikipedia.org/wiki/Randomness
en.wikipedia.org/wiki/Linear_bounded_automaton
en.wikipedia.org/wiki/Halting_problem
github.com/bbbradsmith/prng_6502
codebase64.org/doku.php?id=base:small_fast_8-bit_prng
docs.amd.com/v/u/en-US/xapp052
users.ece.cmu.edu/~koopman/lfsr/
www.eetimes.com/tutorial-linear-feedback-shift-registers-lfsrs-part-1/
forums.nesdev.org/viewtopic.php?t=21496
electronics.stackexchange.com/questions/248950/sram-isnt-blank-on-powerup-is-this-normal
research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
Music:
“Solar Flare” by Adi Goldstein
“Fragments” by Palm Blue
“Don’t Lose Your Grip” by Diamonds and Ice
“Blue Beings” by Tamuz Dekel
“Lost” by Downtown Binary
zhlédnutí: 50 901

Video

How Zelda Saves Your Game
zhlédnutí 231KPřed 3 měsíci
Sponsored by Brilliant - brilliant.org/NesHacker/ In this episode I explore the history and technology that allowed the Legend of Zelda to be one of the first games to have saves. Credits: Technical Editing - Kirby0Louise Japanese Language Research Support - Masayo Okamoto Sources: en.m.wikipedia.org/wiki/The_Legend_of_Zelda_(video_game) en.m.wikipedia.org/wiki/Saved_game tedium.co/2019/02/21/v...
Game Boy Graphics & How To Code Them
zhlédnutí 90KPřed 6 měsíci
In this episode I explain Game Boy graphics and fly through some of the code behind those graphics... Support the channel: patreon.com/NesHacker Game Boy Graphics Project - github.com/NesHacker/GameBoyGraphics
Game Boy Development Environment
zhlédnutí 249KPřed 7 měsíci
I show you how to set up a Game Boy development environment so you can start coding your own games. Support the channel - patreon.com/NesHacker Amazon Affiliate Links: Game Boy T-Shirt - amzn.to/3tW8TCu Everdrive GB X7 - amzn.to/3sgTA6N Everdrive GB X3 - amzn.to/475Hmgk Development Tools / Repo: RGBDS - rgbds.gbdev.io/ VS Code - code.visualstudio.com/ GitHub Demo Project - github.com/NesHacker/...
A Tour of Game Shops in Japan
zhlédnutí 17KPřed 9 měsíci
I take you on a tour of some awesome places to buy retro games in Japan. Support the Channel - patreon.com/NesHacker Akihabara: Akihabara Station - goo.gl/maps/YherehXMwXSRCtVx7 Super Potato - goo.gl/maps/zS4VYoG4xsLDgfR68 Mandrake Complex - goo.gl/maps/XnXqqkyP1J4izJzM9 BEEP - goo.gl/maps/2x2jb7w4fMZ6oBKB6 Surugaya - goo.gl/maps/U2H8YPbuvsKfKbHS6 Friends - goo.gl/maps/SmiT7276PUDnSmiS9 Hardoff...
The Code That Makes Mario Move
zhlédnutí 516KPřed 10 měsíci
The Code That Makes Mario Move
How NES Games Use State Machines For Everything
zhlédnutí 31KPřed rokem
How NES Games Use State Machines For Everything
Computing Pi on the NES
zhlédnutí 171KPřed rokem
Computing Pi on the NES
NES Hardware Explained
zhlédnutí 108KPřed rokem
NES Hardware Explained
Coding NES Subroutines
zhlédnutí 55KPřed rokem
Coding NES Subroutines
NesHacker Patreon
zhlédnutí 2,1KPřed rokem
NesHacker Patreon
Coding NES Loops
zhlédnutí 28KPřed rokem
Coding NES Loops
The CIC & 10NES Explained
zhlédnutí 59KPřed 2 lety
The CIC & 10NES Explained
NES Architecture Explained
zhlédnutí 275KPřed 2 lety
NES Architecture Explained
Bitwise Logic - 6502 Assembly Crash Course 04
zhlédnutí 21KPřed 2 lety
Bitwise Logic - 6502 Assembly Crash Course 04
Channel Update - October 2021
zhlédnutí 4,3KPřed 2 lety
Channel Update - October 2021
Zelda Warrior Princess
zhlédnutí 15KPřed 2 lety
Zelda Warrior Princess
Branching - 6502 Assembly Crash Course 03
zhlédnutí 23KPřed 2 lety
Branching - 6502 Assembly Crash Course 03
NES Controllers Explained
zhlédnutí 83KPřed 2 lety
NES Controllers Explained
RAM & Addition - 6502 Assembly Crash Course 02
zhlédnutí 39KPřed 2 lety
RAM & Addition - 6502 Assembly Crash Course 02
Basics - 6502 Assembly Crash Course 01
zhlédnutí 110KPřed 2 lety
Basics - 6502 Assembly Crash Course 01
NES Graphics Explained
zhlédnutí 226KPřed 3 lety
NES Graphics Explained
NES Development Environment
zhlédnutí 345KPřed 3 lety
NES Development Environment
Welcome to NesHacker
zhlédnutí 11KPřed 3 lety
Welcome to NesHacker
Final Fantasy Better Shops ROM Hack Pt. 3
zhlédnutí 7KPřed 3 lety
Final Fantasy Better Shops ROM Hack Pt. 3
Final Fantasy Better Shops ROM Hack Pt. 2
zhlédnutí 9KPřed 3 lety
Final Fantasy Better Shops ROM Hack Pt. 2
Final Fantasy Better Shops ROM Hack Pt. 1
zhlédnutí 13KPřed 3 lety
Final Fantasy Better Shops ROM Hack Pt. 1
Binary & Hexadecimal Demystified
zhlédnutí 16KPřed 3 lety
Binary & Hexadecimal Demystified
NES Carts Explained
zhlédnutí 35KPřed 3 lety
NES Carts Explained

Komentáře

  • @ReverendTed
    @ReverendTed Před 10 hodinami

    I'm unlikely to ever make practical use of any of the content in your videos, and as a result I'm frequently coasting through them without fully internalizing the details, but the manner in which you present these esoteric and technical topics is simply addictive to watch. I'm definitely on a binge! Thanks so much!

  • @ReverendTed
    @ReverendTed Před 10 hodinami

    Wonderful explanation! The only thing missing from this video is the "Nintendo Seal of Quality". (Except for being visible on the game boxes in the background.)

  • @Dr.W.Krueger
    @Dr.W.Krueger Před 11 hodinami

    It's to remind the scum who's boss. Nintendo always liked to flaunt their contempt for their audience.

  • @Clancydaenlightened
    @Clancydaenlightened Před 12 hodinami

    What can you do with a nes if you make a custom pcb with a altera max II CPLD 128k sram, and for shits and giggles throw an 8087 in there, and a esp32, and a small bit of flash,.im not sure if nes can boot from expansion port Throw a cartridge with another 128k of ram and ay8930, fpga, Put some serial ports and db25 and sd slot Now you have an nes thats just as capable as any c64

    • @Clancydaenlightened
      @Clancydaenlightened Před 12 hodinami

      Side load "apps" via Bluetooth from my phone And can play everything anyone ever made for it back then And does more your nes can't Interesting if you include 8087 with mmc3 for the scanline counter Or use 80187, doesn't have to be connected to an x86, if the 6502 knows how to address it

    • @Clancydaenlightened
      @Clancydaenlightened Před 12 hodinami

      Generate random numbers with 64bit precision quick then Including floating point!

    • @Clancydaenlightened
      @Clancydaenlightened Před 12 hodinami

      Then with the nes you have two processors the 6502 for the logic and code Then The ppu with it's own separate ram and ROM So all that modding was for the 6502 You can repeat the same thing with ppu And add some sram, fpga and flash memory to store certain textures and tiles and can be manipulated on the fly quick using all those CPU expansions

    • @Clancydaenlightened
      @Clancydaenlightened Před 12 hodinami

      Another mod you can do is replace both system ram and ppu vram with dual port sram So 4k dual port sram split in 2 2k banks ( iirc they both have 2k stock of ram) so they still from a stock point of view have their normal ram, but can also access another 2k page, just dont access the same memory location at the same time Interesting since now CPU has direct access to ppu ram and ppu can use CPU ram... so you also can use a shared or dynamic ram structure Blows Even Miyamoto and the rd1 engineers who made that Famicom minds なぜ私たちはそれを思いつかなかったのでしょうか?!

  • @test-rj2vl
    @test-rj2vl Před 16 hodinami

    I wonder how much CPU went for rendering and how much for computing? Would be interesting to see video side by side where on one side your current code fills screen and on other side entire number is calculated first and then everything is printed once and with no animation.

  • @raphanderconph
    @raphanderconph Před 22 hodinami

    Resume of Mario & Luigi: Brothership 1) Good: We got a amazing return of this saga. 2) Neutral: I cant process all of this, I was traumatized than this saga wont return cuz fault of Nintendo, and also the remakes Alphadream do just to SURVIVE, and Nintendo seeing them dying, without doing nothing...i hate this, they just spitted up this game, playing with our minds and making us suffering psicologicaly (if it wasnt for new and maker cant exist wonder) and economically...i cant process the trauma I just received yesterday...idk if cry or laugh of the boom-shot i receive... 2) Bad: I am upset cuz Toadsworth, Stuffwell, Alphadream and Charles Martinet are ☠️ rn cuz fault of Nintendo 🎉

  • @Nirakolov
    @Nirakolov Před 22 hodinami

    question for programming peeps; when using a deterministic RNG like that found in most games... what's a way to reliably randomize what the 'first' seed is on power on?

  • @user-zo1kn8ob7h
    @user-zo1kn8ob7h Před dnem

    jim jom jabackeram

  • @edwardcornell1263
    @edwardcornell1263 Před dnem

    Oh great! A battery inside a game cartridge. So what happens when the battery looses voltage and needs to be replaced?

  • @robertfilomeo346
    @robertfilomeo346 Před dnem

    ive been playing zelda 1 and 2 and crystalis for 30 years and have never had to hold reset before powering down. never once lost save data

  • @kales901
    @kales901 Před dnem

    2:58 16x16 or 4x4?

  • @johnforhan7087
    @johnforhan7087 Před dnem

    I had both Final Fantasy and Zelda and I NEVER held down the reset button. I never had any issues with it

  • @Dr.W.Krueger
    @Dr.W.Krueger Před dnem

    It's still very manageable for something with a scope like this. I have never written anything for 6502, but I can tell you that 68k assembly is actually p*ss easy compared to MIPS and x86 asm.

  • @Mangootango
    @Mangootango Před dnem

    I was literally going to say that I liked your T-shirt and then you you just gave me the link to buy it😊

  • @Gregory_12
    @Gregory_12 Před dnem

    tau

  • @jeffersonderrickson5371

    My muscle memory still holds reset to this day.

  • @nightshadow546
    @nightshadow546 Před 2 dny

    😂😂😂 the only way they can sue you for it is if they call you using one of the off Brands without their logo on it how would they know that you're using your own game and one of their devices it shouldn't be possible

  • @hcn6708
    @hcn6708 Před 2 dny

    Kirby's Adventure is one of the best NES games and the fact it came late into the system's lifecycle, literally after the SNES, is a huge reason why

  • @CM-xr9oq
    @CM-xr9oq Před 2 dny

    I never had to hold reset to get zelda to save. Never had any corruption issues, either

  • @dominicyeomans8107
    @dominicyeomans8107 Před 2 dny

    Do this but better. Makes no since.

  • @super.merienda
    @super.merienda Před 3 dny

    What is the NES cartridge with the largest amount of size inside? I played Empire Strike Back pirate for famicom and the chip was so big that it broke the case

  • @natescode
    @natescode Před 3 dny

    Too many bits? Eh throw away ! Good stuff

  • @pedro1492
    @pedro1492 Před 3 dny

    y u didnt call the video "randomNESs"?

    • @Deficard
      @Deficard Před 18 hodinami

      cause they never thought of that

  • @butterbluemchn
    @butterbluemchn Před 3 dny

    brotato theme heart

  • @shiro3146
    @shiro3146 Před 3 dny

    today i learned that by overloading my brain with such complex algorythm and sophisticated math at a faster pace i can go sleep faster

  • @petermuller608
    @petermuller608 Před 3 dny

    Epic! Did not know you could do so much stuff in the NMI

  • @petermuller608
    @petermuller608 Před 3 dny

    Great explanation!

  • @Furluge
    @Furluge Před 3 dny

    I always figured this was them being a bit too cautious. Back in the day I never did this and I never had a problem.

  • @hanswurst3811
    @hanswurst3811 Před 3 dny

    i had zelda back in the days ..i lever held reset before turning it off ...... ?!?! ......

  • @delqyrus2619
    @delqyrus2619 Před 3 dny

    Suddenly a windows user realizes: Most modern software is written in Assembly too. Programming languages like C, C++ and so on just convert their stuff into assembly.

  • @Marcusblack510
    @Marcusblack510 Před 4 dny

    Dam so letting my friends borrow my game when I was younger was a crime 😮

  • @adamb89
    @adamb89 Před 4 dny

    Another fun fact, you don't have to push the cartridge down. The games played just fine if you insert the cartridge and left it up.

  • @whtiequillBj
    @whtiequillBj Před 4 dny

    It is possible to create a better random number generator these days. There is a cool video by Shironeko Labs called, SuperRT - Realtime raytracing on the SNES. I don't know if a video on how a custom expansion chip actually works. That would be cool though.

  • @volbla
    @volbla Před 4 dny

    A blog called "The Cave of Dragonflies" has a great article about the rng in the first generation of pokemon games. If memory serves, the simplistic algorithm meant that when you're out of range and forced to reroll more than once the values end up highly correlated. This makes using certain balls to catch pokemon much harder than it's supposed to be 😅

  • @hansisbrucker813
    @hansisbrucker813 Před 4 dny

    I was looking for a way to more smoothly scale 0..255 to 0..20 after watching this video. ⌈20×tanh(x/128)⌉ where x is between 0 and 255 and ⌈⌉ means the ceiling function seems to produce a nice smooth (as smooth as integers can be) curve. 🤓 Having said that I do realize it would be absolutely slow on that (or any) hardware 🤔

  • @timonus
    @timonus Před 4 dny

    Great vid!

  • @menhirmike
    @menhirmike Před 5 dny

    If you're worried about the unpredictable cycle times of the d20 method (for reference, galois16o is 63 cycles) and you're willing to sacrifice 256 bytes of ROM, you could create a lookup table for each of the possible values of A to one of the 20 desired values. You could then e.g., use: "jsr galois16o, tay, lda d20_lookup_table,y", which has a predictable cycle count (tay is 2 cycles, lda has 5 if you don't cross a page boundary): Guaranteed 7 cycles instead of an unknown multitude of 63 cycles, doing the age-old Space vs. Time tradeoff.

    • @menhirmike
      @menhirmike Před 5 dny

      Though 256 doesn't evenly divide by 20. So you'd introduce bias since you have each number 12 times for 12*20=240 bytes and are then left with 16 bytes for 20 numbers. You can use that to your advantage if you want to bias toward the middle and reduce the number of 1's and 20's (or bias toward them), but yeah, it's going to be slightly biased because you're 4 bytes short of exactly 13 repetitions. Another potential trade-off to make.

  • @TheGamblingOdyssey-kk5tr

    I would have preferred the Japanese version because any of us who owned the original NES know that the front loading system wasn't all that great and broke a lot of the time period and the whole concept allowing the games to expand is a complete joke because when you're going vertical there is no limitation

  • @Petor12
    @Petor12 Před 5 dny

    Fun fact : I have never once held reset during power off, and I have never lost a single save from this.

  • @MrMagaManTron
    @MrMagaManTron Před 5 dny

    Best explanation I have ever heard for these concepts thank you!

  • @Novastar.SaberCombat

    I always enjoyed games where the RNG was the most unpredictable. It made it so you couldn't simply "go on autopilot" and repeat the same inputs just to force the same results. Sure, speedrunners can usually find ways around this, but to a casual gamer, excellent RNG is "truly" random. 🙂

  • @Hersatz
    @Hersatz Před 5 dny

    That food mnemonic for exclusive or is so good. Can't believe I never thought of it that way. No food on either side? Can't choose any. Food on each side? I can't decide, there's too many choices!

  • @CoolDudeClem
    @CoolDudeClem Před 5 dny

    in my dyslexic mind I read the title as "RING on the NES".

  • @BenMorse0
    @BenMorse0 Před 5 dny

    4:17 depending on the taps the number of random numbers can be way less than the size of the container

  • @8KilgoreTrout4
    @8KilgoreTrout4 Před 5 dny

    Cool stuff to share and no bs delivery is what I like

  • @halfsourlizard9319
    @halfsourlizard9319 Před 5 dny

    But, logicians know that when you offer 'sushi or pizza' the answer is 'yes'.

  • @PsychorGames
    @PsychorGames Před 5 dny

    Now I want to know how RNG works in real life.

  • @chuckistheman2000
    @chuckistheman2000 Před 5 dny

    Ummm did you forget that you need random numbers to prevent a satellite from crashing into your camp? Watch wet hot American summer to learn more

  • @PantlessSunshine
    @PantlessSunshine Před 5 dny

    Fascinating video, thank you for going so in depth.

  • @whtiequillBj
    @whtiequillBj Před 5 dny

    Is a dice random? I think its debatable. If you could use the same force, pressure, angle, spin and possibly a few other things one could conceivably have a repeatable way to throwing a die that isn't random. But for all practical purposes its random.