#44145 - christosterone - Mon May 30, 2005 6:03 pm
I am royally confused. I can understand how to load images from arrays in header files, but as far as writing my own graphics as i go, I am having trouble.
if i write straight to teh videobuffer, it flickers. is the palettemem holding colors ( RGB ) and the videobuffer just holds indexes of those colors in the palettemem array?
any help would be greatly appreciated
Chris
#44148 - tepples - Mon May 30, 2005 6:15 pm
christosterone wrote: |
if i write straight to teh videobuffer, it flickers. |
Yes, you might get flicker if you draw to the page of video memory that's currently being displayed. There's a bit in DISPCNT that controls whether the display circuitry will start at 0x06000000 or 0x0600A000.
Quote: |
is the palettemem holding colors ( RGB ) and the videobuffer just holds indexes of those colors in the palettemem array? |
Correct.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#44151 - christosterone - Mon May 30, 2005 6:31 pm
so this is safe to assume:
(assuming RGB macro was defined )
Code: |
paletteMem[0] = RGB( 31,0,0 );
paletteMem[1] = RGB( 0,31,0 );
paletteMem[2] = RGB( 0,0,31 );
videoBuffer[50 + (240*50) ] = 0 // this will draw a red pixel at 50,50?
videoBuffer[60 + (240*60) ] = 1 // this will draw a green pixel at 60,60?
videoBuffer[70 + (240*70) ] = 2 // this will draw a blue pixel at 70,70?
|
when i tried that, it seemed that when i drew the pixel, it would draw every color in the paletteMem before it ( ex if the videobuffer had a value of 1, it would draw red AND green sidebyside )
thanks
Chris
#44153 - tepples - Mon May 30, 2005 6:40 pm
The video buffer is an array of 16-bit units. In mode 4, each unit represents two pixels. When you write to a pixel, you also write to the pixel next to it. Therefore, to modify one pixel in isolation, you have to read-modify-write.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#44158 - christosterone - Mon May 30, 2005 7:02 pm
if each element in the videoBuffer array contains 2 pixels, how can i define different colors in the paletteMem?
if i wanted the first 2 pixels on the screen to be red then green, would i code:
Code: |
paletteMem[0] = RGB(31,0,0);
paletteMem[1] = RGB(0,31,0);
//now would it be
videoBuffer[0] = 0 | 1;
//or would it be
videoBuffer[0] = 0 + 1;
// or some other contraption?
|
thanks again for all your help
Christosterone
#44160 - tepples - Mon May 30, 2005 7:12 pm
Each 16-bit unit corresponds to two pixels. The one on the left uses the lower 8 bits; the one on the right uses the upper 8 bits:
Code: |
videoBuffer[0] = 0 | 1<<8; |
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#44162 - christosterone - Mon May 30, 2005 7:18 pm
thank you so much ; )
uve been a life saver
chris