What am I doing wrong?

Post Reply
commodorejohn
Posts: 2
Joined: Mon Apr 20, 2009 5:02 am

What am I doing wrong?

Post by commodorejohn » Mon Apr 20, 2009 5:11 am

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?

Al_Bro
Posts: 15
Joined: Wed Apr 08, 2009 10:33 pm

Re: What am I doing wrong?

Post by Al_Bro » Mon Apr 20, 2009 4:01 pm

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.

commodorejohn
Posts: 2
Joined: Mon Apr 20, 2009 5:02 am

Re: What am I doing wrong?

Post by commodorejohn » Mon Apr 20, 2009 6:09 pm

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.

Al_Bro
Posts: 15
Joined: Wed Apr 08, 2009 10:33 pm

Re: What am I doing wrong?

Post by Al_Bro » Wed Apr 22, 2009 5:28 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests