Page 1 of 1

What am I doing wrong?

Posted: Mon Apr 20, 2009 5:11 am
by commodorejohn
Okay, I know I'm screwing up somewhere along the line here, but I'm not sure where. Uploaded here is the source code for a test project I've created from bits and pieces of a few tutorials (primarily the Drunken Coders 8-bit bitmap tutorial) and my own version of a quick-and-dirty anti-aliased line algorithm, ported over from SDL. I'm basically tossing things together to see if I can figure out how this works, but I can't figure out where my code is going wrong in attempting to draw to a framebuffer and then copy to the screen. I seem to be using the same initializations and copying technique as the Drunken Coders example, but for whatever reason, their program is drawing to the screen, whereas mine is not. Am I overlooking something obvious here?

Re: What am I doing wrong?

Posted: Mon Apr 20, 2009 4:01 pm
by Al_Bro
You're using dmaCopy to copy the palette from the stack which isn't working. Simply change your palette code in initVideo() to:

Code: Select all

u16 *c = new u16[32];
for (u16 i = 0; i <= 31; i++)
{
	c[i] = RGB15((u16)(i),(u16)(i * .75),0);
};
dmaCopy(c,BG_PALETTE, 64);
delete[] c;
Once that's done you should get lines on the screen.

Re: What am I doing wrong?

Posted: Mon Apr 20, 2009 6:09 pm
by commodorejohn
Ah. The palette seems a little off, but it works now. Thanks, things should be a lot easier to figure out with some working code to start from.

Re: What am I doing wrong?

Posted: Wed Apr 22, 2009 5:28 am
by Al_Bro
Been thinking about this a little more and it's probably best to avoid dmaCopy for this unless you can guarantee the DMA transfer has completed before destroying the palette array. In the original example code the array is permanent so it's not time-critical. Since in your code it's just an initialisation function it will probably be easiest to use one of the other copy routines and bypass DMA completely.