Template:FeaturedFile/04-14
Featured File
Perhaps one of the most infamous bugs in gaming, Pac-Man renders garbage at Level 256. It is commonly referred to as "Split Screen" due to the right half of the screen looking garbled, while the left half is still intact.
The "Split Screen" or "Kill Screen" marks the end of the game, as the level no longer gives enough dots to progress to the next.
This happens due to a bug in the code responsible for retrieving the number of fruits to draw at the bottom right corner of the screen. Inside the routine, it loads the number of the current level (being 0-based and thus 255 for Level 256, or 0xFF in hexadecimal), then increases it by one. In the case of Level 256, this overflows the register and makes it loop back to 0 (0x00) since a byte cannot hold a number higher than 255, simply restarting from 0 if that is the case. The code does not check if an overflow has happened (which could be possible due to a so-called carry flag set in the CPU registers). In fact, it simply uses the resulting number in a check on which fruits to draw.
In Level 256, the loop counter is initialized with 0 from the start (line 0x2BFC). When decremented to possibly restart the loop again (line 0x2C17), it underflows back to 255 (since a byte can't hold values lower than 0, thus 0 minus 1 results in 255, or 0xFF). The loop now repeats as often as required to bring 255 back to 0. What this means is that the game is now instructed to loop over the fruit drawing code 256 times - these are by far too many fruits to draw. Running out of entries in the fruit table (which also point to the video memory holding the graphics of the fruits to draw), it starts accessing other parts of the video memory, grabbing seemingly random tiles of graphics and drawing them onto the screen into increasing video memory locations.
A full in-depth explanation can be found at the link below.
View more...Previous • Archive • Next