#168697 - wallacoloo - Sat May 16, 2009 1:32 am
So I have several cases in which I simply need to display a rectangle of a solid color. Rather than individually plotting each pixel, there's got to be another way. But how? I've tried using memcpy to copy 1 row at a time. I'm in mode 3, 16bit colors. When I tried implementing memcpy to redraw the entire screen gray, it worked quickly, but it didn't draw over the entire screen. Portions of the screen were solid gray, and other portions were interlaced gray and black. I have no idea why. Any suggestions?
Here's the code:
thanks for the help!
-Colin
Last edited by wallacoloo on Thu Jun 25, 2009 11:54 pm; edited 3 times in total
Here's the code:
Code: |
int main() { *(unsigned long*)0x4000000 = 0x403; // mode3, bg2 on unsigned short* Screen = (unsigned short*)0x6000000; unsigned char toCopy[480]; unsigned short spot = 0; while(spot < 480) { //fill an array so it represents 1 row of solid grey toCopy[spot] = 148; //byte 1 spot++; toCopy[spot] = 82; //byte 2 spot++; } unsigned int row = 0; while(row < 76800) { //thats 240 (width) * 160 (height) * 2 (bytes per pixel) memcpy(Screen+row,toCopy,480); //copy it onto the screen row += 480; } while(1) {} //wait forever... } |
thanks for the help!
-Colin
Last edited by wallacoloo on Thu Jun 25, 2009 11:54 pm; edited 3 times in total