Computing Pi on the NES

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 496

  • @NesHacker
    @NesHacker  Рік тому +183

    Happy Pi day, everyone 😄

  • @joshgribbon8510
    @joshgribbon8510 Рік тому +294

    I remember when I realized that game console were just special-built computers and not just "magic game machines" - so cool

    • @NesHacker
      @NesHacker  Рік тому +67

      I chose to become a software engineer as a kid the minute that realization hit me.

    • @kennystevens2923
      @kennystevens2923 Рік тому +3

      ​@@NesHacker Same here.

    • @syrus3k
      @syrus3k Рік тому +8

      Here in the UK many of us started with a microcomputer instead of a games console, which was kinda cool, but I really wanted to play sonic.

    • @РусланЗаурбеков-з6е
      @РусланЗаурбеков-з6е 5 місяців тому +2

      Computers without keyboards )))

    • @_..-.._..-.._
      @_..-.._..-.._ 5 місяців тому

      @@syrus3k Acorn BBC micro?

  • @vdubs4189
    @vdubs4189 Рік тому +300

    I would love to learn more about NMIs and graphics programming.

    • @NesHacker
      @NesHacker  Рік тому +41

      Got it, I'll start tooling around more with some ideas on the subject!

    • @williamdrum9899
      @williamdrum9899 Рік тому +1

      It's a tricky business. Essentially an NMI is a "ninja function" that can call itself even if your program doesn't. So it needs to leave everything the way it found it when it's finished.

    • @vdubs4189
      @vdubs4189 Рік тому +1

      @@williamdrum9899 No kidding. I've played around with it a little bit and oh boy the things that can go wrong if you don't use the stack

    • @ahmed.benaros
      @ahmed.benaros Рік тому

      ​@@NesHacker ❤طططططج❤❤❤❤❤❤❤❤❤❤❤❤ض رب في ص🎉
      😮 😢

    • @JiffyJames85
      @JiffyJames85 Рік тому

      I would love a quick tutorial along these lines in which you just show a sprite moving from left to right on the screen.
      I was able to make the "HELLO" scroll across the screen by updating your example in GitHub, but I know there is a better way to do it.

  • @BlocPanda
    @BlocPanda Рік тому +36

    I love the fact that the NES is asking "What is 'Flop'?". Just a nice touch. Also, 1:00

  • @Josh2102
    @Josh2102 Рік тому +70

    NES translations
    1:03 「あのー、フロップは何ですか?」= umm, what’s a flop?
    5:00 「そうです」= that’s right

    • @zackyzackyzacky1
      @zackyzackyzacky1 Рік тому +5

      素晴らしい、私も日本語が学んでいます。

    • @link_team3855
      @link_team3855 6 місяців тому +6

      its kinda strange seeing google translate the other side to be the exact same as eachother

    • @DarkonFullPower
      @DarkonFullPower 17 днів тому

      NES hit him with the "Et'oo" and the "Sodeska?"
      It would talk like an anime.

  • @LukeAvedon
    @LukeAvedon Рік тому +43

    Super cool! Loved, "do you even flop bro"

    • @NesHacker
      @NesHacker  Рік тому +21

      So, when that joke came to me, I was like 10 hours deep doing graphics work. I was so tired I basically fell apart laughing and had to animate it in 🤣

  • @cerulity32k
    @cerulity32k 6 місяців тому +20

    I love how starkly different the 6502 is from modern x86_64. It really shows how far we've come, going from no hardware multiplication to something like VFNMSUB132PD (Fused Negative Multiply-Subtract of Packed Double Precision Floating-Point Values). I don't even know if that instruction has ever been used for any meaningful purposes, but it's there.

    • @cmyk8964
      @cmyk8964 5 місяців тому +4

      It’s probably just for compilers to use.

    • @_..-.._..-.._
      @_..-.._..-.._ 5 місяців тому

      😃 yay! 🎉🎉🎉🎉

    • @whamer100
      @whamer100 4 місяці тому

      i just did a bit of research into the cpu extensions that use the set of instructions that comes from, and it doesn't surprise me at all that its a SIMD instruction. ive recently been learning SIMD for fun and its honestly pretty awesome stuff

    • @whamer100
      @whamer100 4 місяці тому

      looking into what exactly this instruction does, its actually surprisingly simple. its basically just doing "x = -(x * y) - z" over a set of data provided to it (SIMD stands for "Single Instruction, Multiple Data"). so it actually likely has a lot of practical use

  • @JoshJones720
    @JoshJones720 Рік тому +157

    Great video. The use of visuals on this channel to explain assembly and binary operations are very helpful.

    • @NesHacker
      @NesHacker  Рік тому +22

      When I was in school I couldn't *get* math or computer science stuff until I figured out a way to visualize, or *feel*, it in my head. So my hope with the channel is that I can help others do the same with the graphics and explanations.

    • @sophiacristina
      @sophiacristina Рік тому +1

      @@NesHacker Omg, me too, the school methodology: "throw a bunch of numbers; ask students to figure out".
      I began to understand math better when i began to mess with graphical calcs...

  • @Zygorg
    @Zygorg Рік тому +13

    Man, never thought ill watch a 9min vid about PI in the NES, but how you explain it and how you put it graphically makes it very engaging. Thanks for this video even though i dont have any idea of it!

    • @NesHacker
      @NesHacker  Рік тому

      Well, I am glad you enjoyed it, haha

    • @Zygorg
      @Zygorg Рік тому

      @@NesHacker yes, i did enjoy it

  • @nict2
    @nict2 Рік тому +535

    This video is going to blow up on Pi Day. 🥧

    • @kermitdafrog8
      @kermitdafrog8 Рік тому +41

      He should have released it on Pi day.

    • @biggiefrosty
      @biggiefrosty Рік тому +28

      I will share this all the places on Pi day. I am no one, so I don’t see how it will matter much, but this video is deserving of some serious Pi Day views, so I will do my part

    • @NesHacker
      @NesHacker  Рік тому +96

      I considered it, but I kinda thought it best to keep the release schedule consistent... otherwise it would have been a nearly a month and a half between releases :)

    • @kermitdafrog8
      @kermitdafrog8 Рік тому +5

      @@NesHacker Pi day is coming up in a couple of days.

    • @Psythik
      @Psythik Рік тому +3

      No it won't. Video was uploaded too early. I agree with Kermit.

  • @josephvanorden6373
    @josephvanorden6373 Рік тому +6

    I sold my stack of Megaman NES carts around 8 years ago... You just hit me so hard in the feels with your stack.

  • @Jennn
    @Jennn Рік тому +23

    This video deserves 1000x the views it currently has. Thank you sir. This was Great!

    • @NesHacker
      @NesHacker  Рік тому +4

      That's a lot of views 😆

  • @pedrotomazeti8450
    @pedrotomazeti8450 Рік тому +13

    I'm Brazilian and I study computer engineering, your videos inspired me a lot and I'm more and more interested in programming with the 6502. I would love to learn more about NMIs and I'm already following your playlist on basic assembly!

  • @Mentalbox52
    @Mentalbox52 Рік тому +17

    It's not entirely true that the nes lacks multiplication and division, but that it's limited. There are 4 bitwise opcodes, ROL, ROR, ASL, and LSR which you can use to shift the bits left and right which can be used to multiply and divide bytes by 2.

    • @NesHacker
      @NesHacker  Рік тому +8

      Indeed, I more meant "general arithmetic multiplication and division" such as a "mul" or "div" operation.

  • @v1x4z
    @v1x4z Рік тому +5

    A complex, daunting process explained in a very understandable and concise manner. The visuals are very smooth and helpful and your speech has a nice, relaxing cadence. Exceptional video, can't wait for more.

    • @NesHacker
      @NesHacker  Рік тому +1

      Thanks! I am glad you liked it :)

  • @radio_marco
    @radio_marco Рік тому +4

    Now I know, why a friend of my yesterday said he wants to make a NES-Pi calculator. He probably saw this video.

  • @jaysonl
    @jaysonl Рік тому +24

    This is great stuff! Finally! A concrete, complete, and not too complex example of how to get an NES to do some actual work!

    • @NesHacker
      @NesHacker  Рік тому +1

      I'm glad you like it :)

    • @jaysonl
      @jaysonl Рік тому +1

      @@NesHacker One of the first things I wanted to do as far as NES coding projects were concerned was to "simply" count frames since poweron so I could get an accurate idea of how my video capture device interacted with the console(s).
      Which means having to deal with enough PPU stuff to be able to set tiles on the screen, and enough math stuff to be able to increment and display, at bare minimum, a 16 bit integer.
      I figure there's enough I can glean from your code to muddle through it.... now all I need to do is find the time...

    • @Mainyehc
      @Mainyehc Рік тому

      I mean, you *could* trade stocks on a Famicom ;)
      ua-cam.com/video/Q9gbIZY1WY4/v-deo.html

  • @jumanji4037
    @jumanji4037 Рік тому +35

    This was a really great video, very well explained. I’d love it if you could go into more depth on handling interrupts, I had no clue you could save the address of a register on an interior call. Could also do a brief tutorial on NES audio programming, it’s one of the more difficult concepts I’m trying to grasp.

    • @NesHacker
      @NesHacker  Рік тому +8

      APU programming is a big one to tackle. As soon as I have a good way to explain it all and have done more research I'll be sure to cover it!

    • @jumanji4037
      @jumanji4037 Рік тому +2

      @@NesHacker thanks! I really appreciate that.

  • @gabrielbarrantes6946
    @gabrielbarrantes6946 Рік тому +8

    Wow, I was once assigned to do this using the 8086 assembly and didn't even try, was too hard back then but definitely knowing that algorithm would have changed a lot

  • @dhoyt902
    @dhoyt902 Рік тому +3

    As a Pi loving mathematician who has written many forms of the Spigot algorithm, bounded and unbounded, for various numbers... Well.. I'm jealous.

    • @NesHacker
      @NesHacker  Рік тому +2

      You have no idea how happy I am to hear that a mathematician is jealous of my work 😂

  • @milesdevinny5759
    @milesdevinny5759 Рік тому +8

    I have a video request: a video covering the ins and outs of scrolling on the NES.
    From what I understand, you need to go through all sorts of hoops to be able to get scrolling in all directions. I've studied enough of the hardware to understand it can do general scrolling in one direction, but beyond that is a mystery to me.
    What makes bi-directional scrolling so hard, how is it accomplished, and what are the limitations to it depending on the mapper you're using?
    NESMaker is a good example of how this frustrated me a lot in the past. They released this tool allowing you to build your own NES games without needing programming, but anytime they were asked why can't they provide four-way scrolling, they pretty much just said it's not possible and those of us not in the know were left just wonder "But why?"
    I'd LOVE to see you cover this, and Vdubs also suggested teaching more about "NMIs and graphics programming." I think a video on scrolling and all the hurdles would be a great start.

    • @NesHacker
      @NesHacker  Рік тому +3

      It's definitely on my list. 4-way scrolling *is* possible, I mean look at Super Mario Bros. 3... So I kinda wonder what's going on with NESMaker where they can't support it...

    • @milesdevinny5759
      @milesdevinny5759 Рік тому +1

      ​@@NesHacker Yep, not to mention all those RPGs!
      I'm almost certain I remember the main dev of NESMaker mentioning they sort of limited themselves due to the mapper they chose, but I think I've even seen a plain NROM demo with 4-way scrolling, so I'm still confused.

    • @Starwort
      @Starwort Рік тому +1

      @@NesHacker actually 4-way scrolling *isn't* possible. iIRC there's an RGMechEx video on how smb3 cheats but the gist is that there's a load of sprites on the left side of the screen to mask the fact that the tiles wrap around (and you can see colour glitches on the right hand side of the screen because of how NES colour mapping works)
      The NES has two scrolling modes: 2 screens vertically, and duplicated horizontally; or 2 screens horizontally, and duplicated vertically and SMB3 cheats by covering the left side of the wrapped tile

    • @binguloid
      @binguloid Рік тому +2

      4 way scrolling is possible, whether by including extra RAM on the cartridge for 2 more nametables, or "cheating" like in Super Mario Bros 3 and a ton of other games

  • @cwoelkers1
    @cwoelkers1 Рік тому +1

    A very cool video. You may not have planned this but I got a chuckle out of the NES "speaking" in Japanese as the NES was not released in Japan, the Famicom was.

    • @NesHacker
      @NesHacker  Рік тому +1

      Everyone knows that the NES' true home is Japan and that its an expat, jeeeezeee ;)

    • @RootVegetabIe
      @RootVegetabIe Рік тому +2

      ACKCHEWALLY

  • @ImSquiggs
    @ImSquiggs Рік тому +3

    It's so cool to me there's a way to compute pi without floating point math... and digit-by-digit like that... what a cool algorithm. Math is so freakin' cool sometimes.

    • @NesHacker
      @NesHacker  Рік тому +1

      Yeah I was pretty stoked when I found the paper detailing the algorithm

  • @idkjustsomedog
    @idkjustsomedog Рік тому +3

    Great vid, awesome production quality and a super interesting subject all explained very well!

  • @titoguidotti2397
    @titoguidotti2397 Рік тому +2

    Hey, thanks to the inspiration of this video I got a 10/10 in my parallel computing project, for university! Appreciated!

  • @jroweboy
    @jroweboy Рік тому +1

    Loved the video! Quick code note, when an interrupt is fired, the 6502 will push the current PC to the stack, and then will also push the current processor flags as well. This is why you use RTI as it pops both the processor flags and the PC. So anyway, all I'm trying to say is you don't need to do php/plp when an interrupt is fired since that is done for you.

    • @NesHacker
      @NesHacker  Рік тому +1

      Yep, another viewer pointed this out as well, my bad! Thanks for watching and letting me know :)

    • @jroweboy
      @jroweboy Рік тому

      @@NesHacker awesome! Sorry for that then, I tried reading the comments to see if someone else caught this but I didn't find one. Anyway, thanks for responding, can't wait to see the next upload!

  • @akko8210
    @akko8210 Рік тому +7

    This is very cool! Hasnt watched everthing but its sounds cool!

    • @NesHacker
      @NesHacker  Рік тому

      Hopefully you like it when you get to watch it all :)

    • @akko8210
      @akko8210 Рік тому

      @@NesHacker That was AMAZING very cool! Keep the good work man

  • @Bofner
    @Bofner Рік тому +9

    I've been living in Japan and learning assembly for the past 8 months now, but I was very surprised to see your NES speak in Japanese xD

    • @NesHacker
      @NesHacker  Рік тому +13

      I mean- of course it speaks Japanese... it's from Japan 🤔

  • @fluffycritter
    @fluffycritter Рік тому +1

    For some reason I assumed this would be about using a Raspberry Pi with a NES, like what suckerpinch did a few years back to implement custom video via MMC/PPU shenanigans.

  • @seanvinsick
    @seanvinsick Рік тому +5

    A youtuber called suckerpinch made an NES slideshow app.

  • @ShadowFoxInfinite
    @ShadowFoxInfinite Рік тому +1

    This makes sense considering 6502 is a general purpose CPU.
    Chances are there are limitless options to expand this chip by retrofitting current code so it can understand it for low watt, unattended processing.💯

  • @jefftheworld
    @jefftheworld Рік тому +4

    Cool way to bring in mappers to the series!

    • @AndrewGlitchMasterBalaschak
      @AndrewGlitchMasterBalaschak Рік тому

      Oh wow, pleasure seeing you here! I'm a senior in college and I've had your albums on my phone since middle school!

    • @NesHacker
      @NesHacker  Рік тому +1

      Thanks! I've been searching for a way to approach the subject more that is interesting without being just an info dump.

    • @jefftheworld
      @jefftheworld Рік тому

      @@AndrewGlitchMasterBalaschak That's wild, what a small world.
      Whereabouts did you find my music way back then?

    • @AndrewGlitchMasterBalaschak
      @AndrewGlitchMasterBalaschak Рік тому

      @@jefftheworld it was on Google play actually, I remember I didn't have a credit card or any way to buy stuff online so I just searched for all the free music I could find!

  • @ninfisgoat583
    @ninfisgoat583 5 місяців тому +1

    good job man keep up the work and continue working on this!!

  • @andrewsveikauskas
    @andrewsveikauskas Рік тому +1

    Nitpick: You talked about floating point with a graphic of stock quotes ... Due to rounding errors, using floating point for currency or stock shares is bad bad bad! You would need to use an integer math representing cents or even fractional cents.

    • @NesHacker
      @NesHacker  Рік тому

      That's true, and my bad. Mostly just needed some basic b-roll to fill in some space xD

  • @SmoggyLambGG
    @SmoggyLambGG Рік тому +3

    「あのー
    フロップは何ですか?」
    *"EVERYBODY DO THE FLOP!"*

  • @igsalexcodes
    @igsalexcodes Рік тому +18

    Amazing video! Visuals were amazing, and the breakdown of compilicated math algorithims made it easy to understand. Also cool because you pushed the limits of the NES!

    • @NesHacker
      @NesHacker  Рік тому +1

      Thanks! I'm glad you liked it, though I'd say I didn't push them too hard. You should see what some of the people in the demo scene do, haha

    • @vinigame7490
      @vinigame7490 Рік тому

      Why limits?

  • @matte.309
    @matte.309 Рік тому +1

    This is really cool. I'm loving your recent videos.

    • @NesHacker
      @NesHacker  Рік тому

      Thanks, I've been really happy with my recent ones too :)

  • @llaffer
    @llaffer Рік тому +8

    I like the joke at 1:00 :) "What is the flop?" :)

    • @NesHacker
      @NesHacker  Рік тому

      Yeah I am not sure if it's technically correct Japanese, but it's what I remember from lessons... 😂

    • @llaffer
      @llaffer Рік тому +1

      @@NesHacker it was good enough for Google Translate, I guess.

  • @TauGeneration
    @TauGeneration Рік тому +5

    ah yes , my videogame from my childhood. Pi for the NES. i especially loved it's requel/remake "Super Pi" fore SNES

    • @NesHacker
      @NesHacker  Рік тому +2

      Imho Super Pi was derivative and overrated :P

    • @TauGeneration
      @TauGeneration Рік тому

      @@NesHacker D:<
      to waaaaaar

    • @jmtradbr
      @jmtradbr 5 місяців тому

      Pi 64 was a 3D classic

  • @ImmortalAbsol
    @ImmortalAbsol Рік тому

    From the thumbnail I thought you were going to make a cart with a raspberry pi inside

    • @NesHacker
      @NesHacker  Рік тому

      Yeah a lot of people say that, I should totally do it now xD

  • @wcsoblake85
    @wcsoblake85 Рік тому

    Not gonna lie, I thought this video would be showing a raspberry pi built into an NES cartridge that had multiple games on it.

  • @mlann2333
    @mlann2333 18 днів тому

    So glad i found this channel, invaluable

  • @petermuller608
    @petermuller608 6 місяців тому

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

  • @dwcalle
    @dwcalle Рік тому +9

    +1 for NMI!

  • @tom13794
    @tom13794 5 місяців тому +1

    i wanna see this running on actual hardware just out of curiosity

  • @collieyy
    @collieyy Рік тому +1

    Omg You have 3.14k subs rn!!

    • @NesHacker
      @NesHacker  Рік тому

      Mmmm, 31.4k I think, but yeah really close to getting 10*pi on pi day, haha

  • @RudolfKlusal
    @RudolfKlusal Рік тому +2

    In our language the word "nespi" mean "don't sleep" 😀

    • @NesHacker
      @NesHacker  Рік тому +1

      That's a pretty accurate description of my life when I was editing the video :P

    • @RudolfKlusal
      @RudolfKlusal Рік тому

      @@NesHacker 😀

  • @amanda_bynes226
    @amanda_bynes226 Рік тому +3

    How come your videos is so dope

  • @daleatkin8927
    @daleatkin8927 Рік тому

    Great video. Not at all what I was expecting when I saw “NES Pi” in the vid title, but was interested anyways.

  • @Daniel-it1dp
    @Daniel-it1dp Рік тому +1

    Yes, I want to learn more about using interrupts to do graphics programming on the NES 🙂

  • @Mangootango
    @Mangootango 6 місяців тому

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

  • @flameofthephoenix8395
    @flameofthephoenix8395 5 місяців тому

    Very nice, personally I would have used my own algorithm that would have been super imprecise and slow. But aside from using a fast algorithm, you did a great job!

  • @x3n1aa
    @x3n1aa Рік тому +2

    you missed a big opportunity to name it PI-NES

    • @NesHacker
      @NesHacker  Рік тому +2

      I think it's more like I *dodged* that opportunity :P

    • @metalheadmaniac8686
      @metalheadmaniac8686 Рік тому

      @@NesHacker nah definitely missed XD

  • @chrisdible9298
    @chrisdible9298 Рік тому +2

    I would typically click on "like" but it is currently sitting at 314 and I just can't bring myself to break that perfection...

  • @xcoder1122
    @xcoder1122 Рік тому +2

    The Ricoh 2A03 and Ricoh 2A07 (those were the CPUs in the NES) are just 8 Bit CPUs with MOS 6502 instruction set running at 1.79 MHz. Oh boy, those CPUs used a technology node of 6 μm, today CPUs are below 6 nm (that's a factor of 1000 smaller). And the 6502 was just a stripped down version of the Motorola 6800 and it's the CPU also used in the Atari 2600, Apple II, Commodore 64, or BBC Micro, so of course it is capable of doing way more than running console games. It is a general purpose CPU even though a pretty limited one by today's standards.

  • @Kuumba
    @Kuumba Рік тому +5

    nice vid , I always try to stay away from floats and these type of stuff with 6502 since its always harder than on modern day processors . also not sure if you know this but you dont have to backup the Proccesor flags at the start of an interrupt , thats done automaticly . Otherwise RTI would be exactly the same as RTS

    • @NesHacker
      @NesHacker  Рік тому +2

      I thought it might be the case that the interrupt handler auto stored the status register, but I was like five days into deep hacking on the game, very tired, and figured a couple extra cycles wouldn't matter so I could be "safe" and just throw stack push and pop in there.
      Fully computing all 960 digits takes quite a while even on the highest speed settings I could get on Mesen, and even minor issues were causing all sorts of havoc with the final digit results. So I was definitely being over cautious when handling the rendering here, haha.

  • @Abubububu
    @Abubububu Рік тому +7

    Checked the whole video… didn’t understand anything 🙈

    • @NesHacker
      @NesHacker  Рік тому +3

      Imagine how I felt making it ;)

    • @Abubububu
      @Abubububu Рік тому

      @@NesHacker atleast you know what youre talking about :)

  • @OSharraps
    @OSharraps Рік тому +1

    You use the stack to store the values of the registers during an NMI interrupt, but isn't it better to store them into the zeropage ?
    It would use less clock cycle.

    • @NesHacker
      @NesHacker  Рік тому

      Yeah that would be more optimal, thankfully in this case it didn't matter much... But with more complex rendering routines it certainly would!

  • @proxy1035
    @proxy1035 Рік тому +2

    fixed point arithmetic would've also been an option, as it's functionally the same as floats but a lot easier on the hardware (and easier to implement).
    a lot of NES games actually use fixed point math to keep track of characters/enemies and their speed/acceleration and such!
    and honestly it did hurt my pride a bit that you didn't consider it because i made a fixed point library for cc65 (a 6502 C Compiler designed for these systems) for exactly these kinds of projects. :(

    • @NesHacker
      @NesHacker  Рік тому +1

      Oh, sorry about that, no offense intended at all! I don't know why but I had it in my mind that there just *had* to be a way to compute the digits using only integer math, so when I found the spigot algorithm I kinda just went with that :)

    • @proxy1035
      @proxy1035 Рік тому +1

      @@NesHacker no worries, important part is that you got something working at all!

    • @NesHacker
      @NesHacker  Рік тому

      @@proxy1035 Right on, and honestly this is all bound to come up in a future video, so I'll definitely give your library a spin when I get to covering the topic again :)

  • @VendettatheGreat
    @VendettatheGreat Рік тому

    Excellent video!
    One minor correction: for your Patreon credits, you listed it as "Feb 2022 Supporters" instead of 2023

    • @NesHacker
      @NesHacker  Рік тому

      Yeah my bad, appreciate it!

  • @WatchItGo
    @WatchItGo Рік тому

    can anyone pls explain to me why I end up watching this type of videos with so much interest from start to finish without understanding a thing of what is explained in this video :)))
    btw, you have a great voice/narration

  • @EeveeFromAlmia
    @EeveeFromAlmia 5 місяців тому +1

    As far as I’m aware, the famicom has two main functions: video game and horse betting

    • @ryderLiihe
      @ryderLiihe 4 місяці тому

      never actually thought of that, but technically true

  • @TChighbury
    @TChighbury 5 місяців тому +1

    Thank you Mario!... but our next decimal place is in another castle

  • @chengong388
    @chengong388 Рік тому +1

    I wonder how many instructions do modern CPUs actually have, as in, what is the list of micro code instructions.can a modern CPU actually do square root in hardware? Or is that just a series of micro code instructions?

    • @NesHacker
      @NesHacker  Рік тому +1

      Modern processors like the Ryzen 9 have many, *many* instructions. They also have integrated FPUs, which implement instructions like "fsqrt" for handling floating point roots.
      That said, take this with a grain of salt. I am not an expert on modern processor architectures, so if someone else knows more or wants to expand/correct, by all means! :D

  • @tscock
    @tscock Рік тому +12

    Honestly i would love to see the debugging process on nes, i have some problems with updating backgrounds and its like no one else had anything like that before, you should collect similar bugs and cover them

  • @SONofADAM007
    @SONofADAM007 Рік тому

    happy 3.14 - i did run this on the everdrive. the screen was slightly cut off, but tons of fun !!

  • @popcorn109i
    @popcorn109i Рік тому +4

    Really quality video! Very interesting, tnx!

    • @NesHacker
      @NesHacker  Рік тому

      Thanks, and you're very welcome!

  • @blushslice
    @blushslice Рік тому +5

    Love these videos bro!!

  • @test-rj2vl
    @test-rj2vl 6 місяців тому

    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.

  • @박강현-k9k
    @박강현-k9k 4 місяці тому

    This video was very intriguing even though I understood under 10% of it. What level of computing do you learn related with the video? The only thing I understand is the Pi and the first part, and though I know nothing of this field, this does seem awesome

  • @guilhermehenrique-zj5tt
    @guilhermehenrique-zj5tt Рік тому +2

    awesome video.
    can you make a series where we can build a entire game? sprite, animations etc... i would pay for it.

    • @NesHacker
      @NesHacker  Рік тому +2

      I very much would like to do that, but it's a really big undertaking and takes quite a bit of planning :)

  • @ethanwashoe5868
    @ethanwashoe5868 Рік тому

    I thought from the title you would be making a mini NES out of a raspberry pie but this was cool!

  • @pikaporeon
    @pikaporeon 4 місяці тому

    could you do it in system ram if you just pushed a digit to the screen and reused the memory address or would that segfault / not render properly / still not enough ram for the code?

  • @todayonthebench
    @todayonthebench 5 місяців тому

    The spigot algorithm sure is interesting.
    I approached the problem of calculating pi a bit differently back in the day when I were in high school and were bored.
    I approximated pi by calculating the length of a very short triangle and then multiplied that by how much of a circle it represented.
    It used a loop that started with a 90 degree corner.
    Ie, point A at X=0 and Y = 1 and point B at X = 1 and Y = 0.
    Find the center point C between these two point.
    Draw a line from origin to C, extend until it is of length 1, this point is our new point A.
    Repeat this n times.
    Each time we get 2x closer to pi.
    Our approximation of pi equal the distance from A to B multiplied by (4*2^n)/2
    We started with a rather lack luster approximation of 2.8284, kind of far off.
    The approximation is also always on the short side.
    Is it a great solution? Absolutely not, it is really slow and you have to do a massive multiplication in the end, and the distance between A and B has to be of slightly higher accuracy as the number of digits you want in the result. (and working with huge numbers is a very efficient way to be slow...)
    But it works and is simple enough to understand. Unlike a lot of more efficient and nuanced approaches that seem like magic in comparison.

  • @johanngambolputty5351
    @johanngambolputty5351 Рік тому +1

    Awesome, I've been meaning to do some non x86/non-desktop programming at some point, console is not a checkbox I've ticked yet, though I'm not quite sure I want to dive into assembly just yet, I'm working my way backwards. Though I guess the benefit of something like this is that its more pure, you won't have to disentangle some proprietary API such as what an xbox might have. Historically c wasn't used because it was slower? Is this still the case, how is c programming for something like the NES nowadays? Is inline assembly a good way to have the best of both?

    • @NesHacker
      @NesHacker  Рік тому

      You can do NES programming in C or Assembly, choice is yours. But some of the rendering stuff and advanced techniques requires precise cycle timing, so you have to break down into assembly to do that. I mostly teach assembly on the channel cause I think it's fun and a more natural way to program NES games.

  • @user-qd7zb4wm9b
    @user-qd7zb4wm9b 6 місяців тому

    quick question about the algorithm, if you need to store what base each digit is in, what makes the algorithm better than just storing all the digits in base 10? or is this just a proof of concept that the nes can indeed calculate the digits of pi 'by hand'?

    • @brucea9871
      @brucea9871 5 місяців тому

      This is just a guess but I suspect the games that run on the NES have the bases hard coded into them so no additional storage would be required.

  • @frogjmon
    @frogjmon Рік тому +2

    Someone get standupmaths over here, he always does a special video for pi day

    • @NesHacker
      @NesHacker  Рік тому +2

      I think he's behind most of my favorite numberphile videos :)

  • @danielfm123
    @danielfm123 Рік тому

    i expected an other retro pie tutorial, good video

  • @segaboy9894
    @segaboy9894 Рік тому

    I had a thought when watching this video - If an NES is not equipped with logic to do something, a library can just be designed to do it? For instance, the SNES has something called mode 7, and this is a hardware feature that developers can call upon. For machines that don't have this hardware, like the Sega Genesis, can a library be designed to achieve it?

  • @AmaroqStarwind
    @AmaroqStarwind 6 місяців тому

    What if you did this on the SNES using its high-res mode? (512 dots plus 448 interlaced lines)

  • @bytesandbikes
    @bytesandbikes Рік тому

    Nice video. Why do the divide algorithm for 2ⁿ values? I would have thought a shift right for the quotiant and a bit& for the remainder would work?

    • @NesHacker
      @NesHacker  Рік тому

      It's a divide algorithm in binary not for 2^n values. So it handles division between two arbitrary numbers.

    • @bytesandbikes
      @bytesandbikes Рік тому

      @@NesHacker Ah, sorry. I thought I saw a "divide by 8/16", but it must be 8 / 16 width

  • @NesrocksGamingVideos
    @NesrocksGamingVideos Рік тому +3

    Hey you could have done 1920 digits by using horizontal mirroring and scrolling down to the next nametable ;)

    • @NesHacker
      @NesHacker  Рік тому +1

      Indeed, but... At 1920 digits I'd need 2 × 1920 × 10 / 3 = 12,800 bytes for the array, which is 12.5 KB. With that number I'd need to use something like the MMC5 to fit the data into contiguous memory (I think you can map WRAM on an MMC5 board into $8000+ range, though I've never done it). Also it would take *much much* longer to compute, haha.

  • @VinsCool
    @VinsCool Рік тому +3

    At this point using a 960 bytes table compressed to something like LZ4 would make more sense to extract all the Pi digits I think lol

    • @NesHacker
      @NesHacker  Рік тому +2

      Yeah I guess that would technically be "computing" the digits as much as this is...

    • @VinsCool
      @VinsCool Рік тому +1

      ​@@NesHacker haha indeed :D

  • @TheWaterMiners
    @TheWaterMiners Місяць тому

    I tried implementing something like this on the GBA. It almost worked, but some of the digits are wrong since the algorithm outputs "10" as a digit sometimes. What did you do to fix this?

  • @princessmaly
    @princessmaly Рік тому

    The little NES going "ano..." is so cute x3

    • @NesHacker
      @NesHacker  Рік тому +1

      That whole sequence had me laughing to hard when I was doing the graphics :D

  • @alvarofranco4286
    @alvarofranco4286 Рік тому +1

    Cool part: my birthday is on Pi day, 3/14

  • @shiro3146
    @shiro3146 6 місяців тому

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

  • @weichun255
    @weichun255 Рік тому +2

    Thank you for the great video

  • @jadbridge
    @jadbridge Рік тому

    Great to see coders using assembler and struggling with little RAM. Back in the late 70s I did the same and resorted to using the video memory directly as storage. It’s been a while, but we have come a long way since 4k was total RAM.

    • @NesHacker
      @NesHacker  Рік тому

      Working in a more limited environment can be really fun because you often have to get creative. I didn't exist in the 70s, but I probably would have had a blast programming back then :)

    • @metalheadmaniac8686
      @metalheadmaniac8686 Рік тому

      If I remember correctly there is a fantasy console that has 1 kb of RAM.

  • @_..-.._..-.._
    @_..-.._..-.._ 5 місяців тому +1

    Where in the Northeast is your Shack?
    N.E.Shacker?

  • @Nathaly520
    @Nathaly520 Рік тому +1

    it could be possible for the nes to calculate the Fibonacci sequence?

    • @NesHacker
      @NesHacker  Рік тому +1

      Computing the Fibonacci sequence is kinda trivial compared to this. Even though it's inherently recursive, there's a *very* fast dynamic programming solution that requires storing only three variables.

  • @Kakerate2
    @Kakerate2 Рік тому

    the in real time showcase was so short, or is that bit at the end real time?

  • @pilotandy_com
    @pilotandy_com 6 місяців тому +3

    0:11 - all the digits of pi?

  • @kenjinks5465
    @kenjinks5465 Рік тому

    I haven't programmed 6502 assembly since the 90s on my C64, good memories. I had to do it on all on paper then poke all the bytes into memory with some C64 basic via the programmers ref guide, then call it with SYS xxxxxx. Hah, all that to make the text wiggle about on the screen or change char sets, make sprites. Fond memories.

  • @Gunbudder
    @Gunbudder Рік тому

    hmm you could have a NesPi NesPi. any rom you make for the NES would run on the NesPi emulator (a raspberry pi running emulation station). double Nes Pi?

  • @My1xT
    @My1xT Рік тому

    Can it really be seen as a general purpose computer tho if Nintendo decided what it ran, which was mainly if not exclusively games?

  • @GarbageAtSB
    @GarbageAtSB Рік тому

    1:03 あのー (Umm)
    フロップは何ですか? (What is flop?)

    • @dihydrogen
      @dihydrogen 5 місяців тому

      FLoating point OPeration

  • @ultiomos
    @ultiomos Рік тому

    nice video! i love the idea of using old game consoles as general use computers. i wanna make something like this on the gameboy

    • @NesHacker
      @NesHacker  Рік тому

      The Z80 is for real, give it a shot :)

  • @beefmaster7
    @beefmaster7 Рік тому

    I subscribed!
    I hope the algorithm bumps your video with March 14 around the corner.

  • @doc_sav
    @doc_sav Рік тому +4

    This is so sick!