Some things you should know:
1) I've loaded 8-bit graphics into SDRAM. These are 8x8 tiles.
2) I call a function called "drawScreen()" one time upon pressing Up.
3) Despite trying to get it to draw only a single 8x8 tile at a specific location on the screen, it gives me tall columns of various tiles. It doesn't seem to match the logic I have put into place *at all*.
Here's the code for the 'drawScreen()' method I'm working with:
Code: Select all
void drawScreen() {
volatile unsigned short *frameBuffer16 = &MARS_FRAMEBUFFER;
volatile unsigned short *sdramArt = &SDRAM_ART;
volatile unsigned int screenWidth = 320/2;
unsigned int tileOffsetX = 0;
unsigned int tileOffsetY = 0/2;
// Draw frame 1
//for (int i=64/2; i<bufferSize; i++) {
// frameBuffer16[tileOffsetX + (i & 3) + ((tileOffsetY + (i>>2)) * screenWidth)] = 0x6161;
//}
// Flip the framebuffer selection bit and wait for it to take effect
MARS_VDP_FBCTL = currentFrameBuffer ^ 1;
while ((MARS_VDP_FBCTL & MARS_VDP_FS) == currentFrameBuffer);
currentFrameBuffer ^= 1;
// Draw frame 2
for (int i=64/2; i<bufferSize; i++) {
frameBuffer16[tileOffsetX + (i & 3) + ((tileOffsetY + (i>>2)) * screenWidth)] = sdramArt[i+(4*0x40)]+0x6060;
}
}
(Also, please ignore the sloppiness of the code... I'm actively experimenting, so it's not intended to be neat.)