Hacker News new | ask | show | jobs
by internetter 910 days ago
But why specifically 999,999? That's not an overflow or anything...
3 comments

I'm not familiar with Tetris specifically, but for a score display it was rather common to store each individual digit as a tile ID, which helped to speed up drawing that score into the nametable. I wouldn't be surprised if the algorithm that handles score addition was a simple loop that doesn't check the bounds of the highest digit; this would cause it to eventually corrupt adjacent memory in RAM.

Edit: the article covers much of this! Based on the 3 byte display I'm guessing it is indeed BCD as others have noted, with slower software routines to get around the 2A03's lack of a decimal arithmetic mode. The slower operation may be part of why the crash is possible, but the mechanism is simple unguarded lag: NTSC isn't going to wait around forever and the program wasn't prepared for this.

I’d have to double check a screenshot but it’s likely the largest number that can be displayed in the area given for the score.
It's likely it's 3 bytes of BCD (binary coded decimal). It's a handy way of storing things like scores, especially on 6502 processors which have built-in BCD handling support.
No BCD support on the specific chip used in the NES, though.
Looks like it might be doing the bcd by hand. See, e.g., L93C7 (and following code) in the disassembly here: https://github.com/CelestialAmber/TetrisNESDisasm