Wednesday, February 3, 2021

Grab an Off-Screen Mushroom in SMB #Shorts - YouTube


John Coffey
1 second ago
Speaking as a former videogame programmer, I am going to make a big assumption here, and maybe my assumption is wrong:  The collision detection is probably just using a single byte for the coordinates in both the horizontal and the vertical, giving it a range of only 0 to 255.  This would make sense because the 6502 processor only does math 8 bits at a time.  Doing 16-bit math here would be too much trouble, but maybe only the vertical is just using 8-bit math.  As the mushroom or Mario moves off-screen, the coordinate wraps to the other side.  The NES displayed 240 horizontal lines compared to the 224 lines on the SNES, so the objects wouldn't have to go far offscreen to wrap.

This is similar to a bug on Pac-Man/Ms. Pac-Man that turned into a useful feature. The different ghosts are trying to reach different locations depending upon which way Pac-Man is heading.  The pink ghost is trying to reach a location two characters (8x8 pixels) in front of the player.  However, Pac-Man does this math using 16 bits, which the Z80 processor supports, but the cordinates are two 8 bit values x and y combined into a single 16-bit word.  I don't remember why this is, but when Pac-Man is moving up this can create an overflow on the Y coordinate that ends up subtracting from the X coordinate.  This sometimes means that the Pink Ghost will move to the left when he wasn't supposed to, but this gives him extra "personality."

No comments:

Post a Comment