Now I'm following NES 101 to make some graphics.
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:
I'm trying to stick the Tile data this way, as I'm coding in C and cannot include it in CHR-ROM with things like .incbin .org .bank .advance, etc.
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:
The data read back from VRAM $1000: ( on Jnes and my PMP )
Program:
Any clues?
Thanks in advance!
PS: If I haven't explained myself enough, please ask.
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!
I'm trying to stick the Tile data this way, as I'm coding in C and cannot include it in CHR-ROM with things like .incbin .org .bank .advance, etc.
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:
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 )
};
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 )
};
The data read back from VRAM $1000: ( on Jnes and my PMP )
Code:
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 right
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 right
Program:
Code:
...
#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) );
}
#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) );
}
Any clues?
Thanks in advance!
PS: If I haven't explained myself enough, please ask.