So why does throwing the lightning bug into a pit crash the game? Long story short, the game tries to load a sprite set and fails.
For the long story, we have to get into how the sprites in this game work. Simply put, most sprites are made up of several sub-sprites. This was a way of saving space in the ROM by cutting out large transparent regions in each sprite. To illustrate, here's a crab:
If this Ussal were a single sprite, it would be 40x40 pixels, which corresponds to 800 bytes in the ROM. By separating it into the yellow, magenta, and cyan sub-sprites shown on the right (8x16, 16x32, and 16x16 pixels), this can be reduced to 768 bytes. 32 bytes per sprite is a modest amount of space to be saved, but in a game with several thousand sprites, it adds up.
Of course, once a sprite's been chopped into pieces like this, you need to include instructions for how to put those pieces together. Specifically, each subsprite has an associated list of numbers corresponding to its size (in bytes), shape, palette, and x- and y-offsets from the center of the sprite, arranged in a specific format and order that the game is programmed to parse. Let's call this "sprite data," for want of a better term.
There are unique sprites for the lightning bug falling into a pit, and they do have data detailing each sub-sprite's size, shape, offsets, and so on. However, the sprite data doesn't follow the same format as every other sprite in the game. For example, the falling bug x- and y-offsets are stored as 16-bit signed integers, but in the final format, they're 8-bit signed integers. (I suspect this is an older format that was changed to save space.) This means that when the game loads the falling bug sprites, it tries to interpret what is essentially junk data and crashes.
Anyway, having identified the problem, it's easy enough to fix it. Here are the sprites for the lightning bug falling to its doom, unseen for 20 years!
There's one other object in the game whose sprite uses the same data format as the falling bug, and it's a good one. Here it is!
If you collect it, it gives you this helpful message:
It doesn't do anything else. Perhaps this was a placeholder sprite for Takua's Copper Mask?
Finally, here's a small bug fix patch that will let you throw lightning bugs off cliffs to your heart's content!
Patch (for use with the European ROM on BMP)
No comments:
Post a Comment