Computing Pi on the NES

209,598
0
Published 2023-03-03
An NES game that computes the digits of pi.

Become a Patron - patreon.com/NesHacker
Buy my t-shirt (Amazon Affiliate Link) - amzn.to/3ksOPmR
Get the ROM - github.com/NesHacker/NesPi/raw/main/nes-pi.nes
See the Code - github.com/NesHacker/NesPi

Pi-Spigot Algorithm Paper (Rabinowitz & Wagon, 1995):
www.maa.org/sites/default/files/pdf/pubs/amm_suppl…

Music:

“Raintown (My Love For You) - Instrumental Version” by Alchemorph
“Maldito” by Family Kush
“Boiling Point - Instrumental Version” by Evgeny Bardyuzha
“Night Chase” by Raz Burg

Chapters:

0:00 Introduction
2:20 Choosing a Mapper
3:16 Math Routines
5:22 The Spigot Algorithm
7:18 Coding the Game

All Comments (21)
  • I remember when I realized that game console were just special-built computers and not just "magic game machines" - so cool
  • @nict2
    This video is going to blow up on Pi Day. 🥧
  • @vdubs4189
    I would love to learn more about NMIs and graphics programming.
  • @Josh2102
    NES translations 1:03 「あのー、フロップは何ですか?」= umm, what’s a flop? 5:00 「そうです」= that’s right
  • @BlocPanda
    I love the fact that the NES is asking "What is 'Flop'?". Just a nice touch. Also, 1:00
  • @LukeAvedon
    Super cool! Loved, "do you even flop bro"
  • @JoshJones720
    Great video. The use of visuals on this channel to explain assembly and binary operations are very helpful.
  • @cerulity32k
    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.
  • 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!
  • @Zygorg
    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!
  • 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
    This video deserves 1000x the views it currently has. Thank you sir. This was Great!
  • @v1x4z
    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.
  • @llaffer
    I like the joke at 1:00 :) "What is the flop?" :)
  • @ImSquiggs
    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.
  • @Mentalbox52
    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.
  • @jumanji4037
    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.
  • @TauGeneration
    ah yes , my videogame from my childhood. Pi for the NES. i especially loved it's requel/remake "Super Pi" fore SNES
  • @matte.309
    This is really cool. I'm loving your recent videos.