Codetapper's Amiga Site


The Mask value will perform a bit-wise AND operation on each tile index. For example, to mask out the bottom 12 bits of a word map, you would enter $fff as the mask. The highest 4 bits will become 0.

Why on earth would you want to do this? Some games use some of the bits to store extra information about each tile. Examples include setting a specific bit to draw the tile upside-down, specifying that the tile will collapse when walked on, or that that a particular enemy will spawn from that location.

The most logical way to store maps in games is to create an array of the tile numbers. For example, a small 5 by 4 map might look like this:

$21, $22, $23, $24, $25
$31, $32, $33, $34, $35
$41, $42, $43, $44, $45

But if the game uses the highest 4 bits for other purposes, it may look like the following:

$8011, $12, $2013, $4014, $15
$c021, $22, $23, $24, $25
$f031, $f032, $33, $2034, $35
$f041, $f042, $c043, $8044, $1045

This poses a real problem for map ripping as the tile indexes will be difficult to locate, and the high bits need to be reset to 0 before drawing the map.

The program comes with a sophisticated map search function that will attempt to calculate the correct Mask and Shift values automatically.

When it comes time to display the map, you need to remove the extra bits, otherwise the wrong tiles will be drawn. This is where the Mask value is useful. In this example, if we specify $fff as the Mask value, each tile index will have a bit-wise AND operation performed on it, which will remove the 4 high bits and replace them with 0. The first tile would be read from memory ($8011), and masked with $fff to give $11, which is the actual tile number.

Post your comment


No one has commented on this page yet.


You may enjoy these articles...









The Ultimate Amiga Graphics, Level and Map Ripper!


Random Rants

A random assortment of rants relating to the Amiga!


Sprite Tricks
