Wednesday, August 11, 2021

MASK

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.

Specifically, this sprite set.

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!

It uses Takua's color palette, if that matters to you.

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)

Pre-Patched ROM

Pre-Patched ROM with bonus MASK in the tutorial

Tuesday, August 10, 2021

Hammer Time

Happy 810NICLE Day, all! To celebrate, here's a highlight reel of weird firestaff/hammer interactions.

There are a few things going on here. One is that you can pick up and throw any enemy stunned by Vakama's Firestaff. You can even damage enemies by throwing them into each other! If you're skilled enough (I'm not), you could probably beat the Onu-Wahi Vatuka by stunning its rock familiars and throwing them at it. This is 100% intended, and it's a wonder that the game never tells you to do it at any point.

The second thing is that the hammer's coding does not distinguish between objects Takua can lift over his head. If it can be lifted, the hammer can smash it into rocks. Since everything you can pick up after getting the hammer (except the lightning bug) is a rock to begin with, this isn't a problem in normal gameplay... but if you use the item swapping trick from last post, you can absolutely destroy Nokama. I can only assume this behavior was not intended.

Finally: yes, you can stun the lightning bugs with the firestaff! I kinda like that the firestaff is useful outside of Onu-Wahi, though I question the logic of the spark gap Rahi being blinded by a flash of light. 

Unfortunately, throwing the bugs off a cliff causes the only game crash I know of. Why? Well, it's complicated, and gets into some other stuff unrelated to the topic at hand, so I'll save that for tomorrow's post. Watch this space!