While writing a quick and dirty function to get some debug tiles on the screen, I forgot (it’s been over a year since I last did any DS code) that you can’t write to VRAM 8 bits at a time. I think this might be true for all RAM, though in other cases it’s likely the hardware does a 32 bit read then write. Either way, if you want to write some debug tiles to the screen make sure you write either 32 or 16 bits at a time.
The following code simply ‘makes’ two tiles in VRAM, i.e. two blocks of 64 (8×8) pixels, filling the first with 0 (for the first palette entry) and the second with 1 (for the second palette entry).
u16 *pTiles = (u16 *) BG_TILE_RAM(1);
for (i = 0; i < 64; i++)
{
if (i > 31) pTiles[i] = (1 << 8) | 1; else pTiles[i] = (0); }
Obviously this isn’t the most flexible or attractive code around, but it illustrates the point!
Entries (RSS)