Skip to content

Faxanadu level data VI - Putting it all together


Now that all necessary parts of parsing Faxanadu level data have been explained it's time to end this mini-series. The final step is to combine the knowledge gathered in the first five parts of the mini-series which in turn allows us to draw the entire Faxanadu world in the level editor.

Let's recall what we have so far. Drawing a screen from the Faxanadu world is a process that is comprised of several different steps: The first step is to read and parse the actual level data from the Faxanadu ROM file (see update one). The second step is to find the four 8x8 pixel tiles belonging to the 16x13 block that form one screen (see update two). Then it's necessary to find out which color the pixels in the individual tiles have (see update five) but because the color is stored independently from the tiles and because of some other oddities of the Faxanadu level data it's necessary to know how doors and scrolling work (see the updates three and four). And that last step, finding the correct color for the tiles and drawing the screens is what this update is all about.

What we have so far is a collection of Screen objects which contain the blocks and the palette used in the screen. The tiles that form the blocks are also known. Connecting the pixels of the tiles with a color from the palette is all that's left now.

Each tile of 8x8 = 64 pixels is 0x10 bytes = 128 bits long. That means two bits are used to encode the color of each pixel. The two bits that are used for each pixel can not be found right next to each other though. For a brief description of how NES graphics are stored see The Art of ROM Hacking (Search for "NES Graphics Format").

Now a palette contains 16 colors though, therefore four bits are necessary to address the entire palette. The two missing bits can be found in the attributes data of each block. Attributes have not yet been covered by me but they're sufficiently well explained in Vagla's document about Faxanadu internals. Basically every block has a 1 byte long attribute (2 bits for each of it's four tiles). These two bits for each tile are the missing two bits used to address the entire palette. The formula to get the correct color for a pixel of a tile is therefore: Color = 4 * TileAttribute + Pixel where Pixel is the two bit value from the image itself.

That's it. Unless I've forgotten to something everything necessary to draw Faxanadu screens is now available in this mini-series.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
BBCode format allowed
Form options

Submitted comments will be subject to moderation before being displayed.