Archive for the 'Tiles' Category

Not that much fun but thought I’d stick it up anyway - I’m in the process of replacing the lovely Zelda artwork with my own crappy tiles.

The little dude is mine though!

Sprites!

Not quite - I was testing my VRAM stuff, wanted to load a map and some tiles - rather than drawing some I figured I’d just use a scene from one of my fave games: A Link To the Past. Because I haven’t bothered to write the function to load the palette yet it’s being drawn with my debug palette, and the result is a glorious image which looks like it’s straight from the good old Spectrum. Thought I’d share it!

A Link To the Past. Not on Spectrum.

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!

Bad Behavior has blocked 2 access attempts in the last 7 days.