Mapbuffer is the temporary place where we indicate new indexes for single screen (256x192screeen is grid 32x24 of 8x8 tiles).
Single map-to-tile reference have 2 bytes therefore "short int" type is used here. Tilesize referer more to amount of tiles, knowing that 32bytes is one tile in 4bpp format so we can count the amount of tiles. Just to display unique ones.
(changed to tilesAmount)
This is one of many different graphics modes. In tiled-map graphic mode we can't just lit single pixel
or even tile just like that, tiles and maps works here very dependly but it makes a good use.
Map data is the structure that grit create automaticly...
Usualy first tile is empty or transparent, and next ones are unique ones.
Single change one 8x8 tile displayed on screen is in fact changing 2 bytes reference in map.
We can have one image with 16x16 tileset and create new images just by using text arrays and MapBuf
to map 16x16 tileset on the image file map, just in case to make in example sokoban stages...
I think that would be good use for single tileset loaded to memory.
I added that example. To show next stage just display 4th image first and then press Right on dpad.
(tileset from the chinese Carrier for SV handheld)
however you were right, mapbuffer should be 64 times less than that.
This sniplet seems more tidy
C++:
//map buffer for tileset preview, default background image tiles - 768 ( 256 * 192 / 64 pixels)
const short int TilesPerScreen = 256 * 192 / 64;
short int MapBuf[ TilesPerScreen ];
void ShowMyTileset(int c){
short int tilesAmount = DS_TilesLen[c] / 32;
for(short int i=0; i < TilesPerScreen; i++){
if(i < tilesAmount )
MapBuf[i] = i;
else
MapBuf[i] = 0;
//or more universal instead of DS00MapLen, better to use TilesPerScreen * sizeof (short int)
dmaCopy( MapBuf , bgGetMapPtr(bg), DS00MapLen );
return;
}
...and in the attachment - the working sniplet, when you press X button ( it shows what grit exactly did with the images ).