I managed to get the palette info on VRAM.
But then I try to write some tiles to VRAM $1000 and then read them back to test if all went ok, the following happens:
- - on most emulators, only zeros come out.
- on Jnes the info that was written appears when read, but shifted one byte to the right. The sprite doesn't show.
- on my PMP with NES emulation, the same info than in Jnes is read, but here the sprite shows perfectly!
So there are two ways of doing it, in CHR-ROM and in VRAM, right?
The CHR info I (try to) write to $1000 VRAM:
Code: Select all
byte tiledata[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 1st tile: blank (16 bytes)
0x18,0x24,0x66,0x99,0x99,0x66,0x24,0x18,
0x00,0x18,0x18,0x66,0x66,0x18,0x18,0x00 // 2nd tile: diamond ( another 16 bytes )
};Code: Select all
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x24,0x66,0x99,0x99,0x66,0x24, // note that this is the start of the 2nd tile,
0x18,0x00,0x18,0x18,0x66,0x66,0x18,0x18 // but shifted 1 byte to the rightCode: Select all
...
#define sizeof_tiledata 32
unsigned char i;
unsigned char *p;
// write 2 tiles to VRAM ...
addr(0x2006) = 0x10;
addr(0x2006) = 0x00;
for( i=0, p=tiledata; i!=sizeof_tiledata; ++i, ++p )
addr(0x2007) = *p; // write 2 tiles, 16 bytes each
// ... Read them back
for( i=0; i!=sizeof_tiledata; ++i )
{
addr(0x2006) = 0x10;
addr(0x2006) = i;
cprintf("%02X.", addr(0x2007) );
}
Thanks in advance!
PS: If I haven't explained myself enough, please ask.