I tried your program and the main problem is that your indexing is off by one. If you only correct this line in the PRINT_LAYER function:
if ( XonMAP > dbMemblockByte ( 100, 0 ) ) {
to this:
if ( XonMAP >= dbMemblockByte ( 100, 0 ) ) {
then the displayed image reflects the arrangement on your map. At least I can recognize the pattern all right.
I'm not sure that this is the only problem because to be honest, the program is confusing (for example I had no idea what the "layer" would mean and there are quite a number of global variables) and I had time only for a quick check.
I just wanted to write when I noticed your post above, I'm not sure though if you spotted the same problem or a different one.
Another error I noticed in the CHECK_X and CHECK_Y functions, but these are at present not used anywhere:
if ( RSIDE < dbSpriteX( TILENUMBER ) < LSIDE ) {
// and
if ( TOP < dbSpriteY ( TILENUMBER ) < BOTTOM ) {
You can't do this in C++. The compiler even issues warnings for these lines. You have to write all conditions separately and connect them with "logical and" or "logical or" operators.
if (RSIDE < dbSpriteX(TILENUMBER) && dbSpriteX(TILENUMBER) < LSIDE) {
// and
if (TOP < dbSpriteY(TILENUMBER) && dbSpriteY(TILENUMBER) < BOTTOM) {
I the PRINT_TILE function, erase this line:
dbSprite ( TILENUMBER, XPOS, YPOS, TILENUMBER );
It's not needed at all. It's enough to set the frame of the animated sprite and paste it. Also, you do not need to load the image from which you create the animated sprite because the dbCreateAnimatedSprite will load it from the file anyway.
When you zip a project to post it on the forum, please do not include the huge ncb file and the Debug directory. These are generated by the compiler, so they can be regenerated any time and they are not needed to open the project in Visual Studio. They only increase the download size.
I hope this helps somewhat. From tomorrow I don't have internet connection for at least two weeks, so I won't be able to answer more questions for a while.