Caves

The next larger point on my todo list for the remake is handling the first bosses of the game. But most bosses in this game are inside caves, and I did not have those sorted out yet, so I wanted to get that working first!

So how do caves work? The level stores its regular levels with a plain old height map file, plus a file that specifies a single texture to use for each height map square. How do we get ceilings from that?
If you've ever played the game you may already know the answer for that - the height map is simply mirrored. Doing that for the above boss room gives me the following:

Ignoring the shading for now, there's a clear difference: The ceiling is supposed to have lights, and the floor doesn't. But the file that specifies the textures to use doesn't allow for multiple textures. So what is going on here?
There's one easy piece of info we can use as a guide. If we look at the heightmap and its textures itself, we can see that very close to where the room is placed, there's a section where we can see the ceiling tiles! Now it's a matter of finding how this is stored in the files. What will also help is the coordinates: The heightmap coordinates for the floor are(123,124)-(129,130), and the coodinates of the ceiling tiles are (133,124)-(139,130).

A quick way to find out more is to simply compare with other levels in the game. Some other caves I used for information are in the screencaps below:


A pattern quickly emerges: we always find separate tiles a bit to the right of the actual cave, and counting the offset makes things clear: You simply find ceiling tiles at x+10 from your current heightmap tile. Since none of the files store offset coordinates like that, it seems this is simply a hardcoded value.

Much better! Sometimes reverse engineering takes a lot of time and effort, but there are also times like this when it's really straightforward.
Now to get the actual boss in here.