I've been reading through these:
http://uzebox.org/wiki/index.php?title=Global_Vram
http://uzebox.org/wiki/index.php?title= ... _Detection
They are informative but I am missing out on how vram works. I understand that it is a VRAM_TILES_H*VRAM_TILES_V sized array. I also understand that in mode 3 that the first tiles in this array are the ram tiles.
What I don't understand is the rest. My goal is to be able to check what tile a sprite occupies. For simplicity my sprite is 1x1. I want to pull the right value out of Vram and then display it near the top of the screen. It seems that all of the screen's tiles are there but they are in the wrong order. Therefore, I believe that I am accessing them wrong.
The kernel settings of my Makefile:
Code: Select all
## Kernel settings
KERNEL_DIR = ../../../kernel
KERNEL_OPTIONS = -DVIDEO_MODE=3 -DINTRO_LOGO=0 -DSOUND_CHANNEL_4_ENABLE=0 -DSCROLLING=1 -DSOUND_MIXER=1
KERNEL_OPTIONS += -DMAX_SPRITES=5 -DSCREEN_TILES_V=27 -DRAM_TILES_COUNT=1
#
#-DFIRST_RENDER_LINE=24
KERNEL_OPTIONS += -DVRAM_TILES_V=32
Code: Select all
unsigned char GetMapTile(unsigned char x, unsigned char y, char direction){
//x=x>>3;
//x=x*8;
//y=y>>3;
//y=y+testvalue;
//;index formula is vram[((y>>3)*256)+8x+(y&7)]
//unsigned char thevalue = (vram[(y*28)+x]-RAM_TILES_COUNT);
unsigned char thevalue = (vram[((y>>3) * VRAM_TILES_H + (x>>3))-RAM_TILES_COUNT]);
//unsigned char thevalue = (vram[(y>>3) * VRAM_TILES_H-1 + (x>>3)]);
//if (vram[(y) * VRAM_TILES_H + (x>>3)]) == 18)
//if (vram[(Y>>3) * VRAM_TILES_H + (X>>3)] == TILE_WOOD)
Print(22, 3, PSTR("# ")); PrintByte (26, 3, thevalue-RAM_TILES_COUNT, true);
SetTile(21,3,thevalue-RAM_TILES_COUNT);
return thevalue-RAM_TILES_COUNT;
//return (vram[122+(y*30)+x]-RAM_TILES_COUNT);
}