Now... let's see if we can make it run faster. I am going to assume that you are using a 2D array to store your tile information. There is nothing wrong with that. The problem may lie, however, in how you are referencing your tiles in that array. You are probably referencing the tile information via indexes. For example:
for(int Y = 0; Y < VIS_HEIGHT; Y++)
for(int X = 0; X < VIS_WIDTH; X++){
//Calculate the destination rect
//Calculate the source rect
//BitBlt the tile
}
That piece of code, although clean and easy to read, is slow and inefficient.
Here's a segment of a drawing routine that is better optimized:
//------------------------------
//Assumed:
// Map - 2D array of TILEINFO
TILEINFO *cur_tile;
long num_tiles, cnt;
int X, Y;
RECT dest_rect, src_rect;
//Set the dest_rect to the top left coord
SetRect(&dest_rect, 0, 0, TILE_WIDTH, TILE_HEIGHT);
//Initialize some variables
num_tiles = VIS_WIDTH * VIS_HEIGHT;
Y = 1; cnt = 0; X = 1;
cur_tile = Map; //Set the pointer to the beginning of the array
while(cnt < num_tiles){
//Get the source rect
//BitBlt your tile
X++; //Increment the X position
OffsetRect(&dest_rect, TILE_WIDTH, 0);
if(X >= VIS_WIDTH){
//Wrap to the next line
X = 1;
Y++;
SetRect(&dest_rect, 0, dest_rect.bottom, TILE_WIDTH, dest_rect.bottom + TILE_HEIGHT);
}
cur_tile++; //Move the pointer to the next element in the array
}
//------------------------------
Now not everything is there, but the general idea is that you should limit the number of calculations your doing. Also, for loops have a reputation for being slow. Notice how the destination rectange simply slides
to the right until the last tile is drawn. At that point it wraps to the next row and starts drawing that row.
The next important part of this is that we are not referencing the array via indexes. We start off with a pointer to the beginning of the array and simply traverse the entire array. In memory, a 2D array is still linear.
Since you are doing 3 layers, you may want 3 dest_rects. That way you're not recalculating the destination rectangle for each blt. You should be simply moving it in one direction until it has to wrap around.
There are probably a few minor bugs in here simply because I just typed it up and didn't compile it to see if it's perfect. It should give you the basic idea, though.
Hope this helps.
------------------
Dino M. Gambone
http://www.xyphus.com/users/dino
Good judgement is gained through experience. Experience, however, is gained through bad judgement.