GP32 Not Drawing All Of Image


Wa

Still Fresh
Joined
Sep 17, 2005
Messages
4
For some reason, when I draw my image it seems like it draws over a triangular wedge of the lower left corner of it, a big one. I think it's drawing over it cause it doesn't show the text I'm drawing there when I draw the sprite, but it shows the text when I don't draw the sprite. Before I put the image in the loop it displayed the whole thing. Anyways, I have no idea what's happening with it. Here's the code, I hope someone can help:

Code:
#include "gp32.h"
#include "fileio.h"
#include "color.h"

unsigned short *fb[2];
short bgcolor = 0;
short fgcolor = 0xffff;
int erlvl = 0;
int letter = 0;
extern unsigned char title[];
char capt[60] = "Command Prompt";

char buffer=0;
void swap_screen()
{
	gp_setFramebuffer(fb[buffer],1);
	buffer++;
	if(buffer == 2)
   buffer=0;
}

int length(char* str)
{
	int i=0;
	while(str[i] != '\0')
	{ i++; }
	return i;
}

int main()
{
	gp_setCpuspeed(33);
	fb[0] = (unsigned short*) FRAMEBUFFER;
	fb[1] = (unsigned short*) FRAMEBUFFER;
	gp_initFramebuffer(fb[0],16,85);
	gp_clearFramebuffer16(fb[0],bgcolor);
	gp_clearFramebuffer16(fb[1],bgcolor); 

	int i;
	while(1)
	{
  swap_screen();
  gp_clearFramebuffer16(fb[buffer],bgcolor);
  gp_drawSpriteH((u16*)title,0,0,fb[buffer]);
  gp_drawString(25,8,length(capt),capt,fgcolor,fb[buffer]);
	}
}
There's some keychecking after the drawing in the loop, too, but I don't think that's relevant. If you need the image or the object file, I can post it.
 
I tried for(i=0;i<1600000;i++); for(i=0;i<1900000;i++); and for(i=0;i<2000000;i++);
Now it flickers in that same section, the last one also makes the button checking a little too unresponsive. I tried them all before and after the drawing, too. :/ Thanks for the help, though.
 
The delay shouldn't be a problem.
Are you sure you are drawing on the hidden frame buffer?
Btw, we use to swap screens a the end of the loop, but that's not very important.
 
I'm sure... I'll try putting it at the bottom, though. The flickering leads me to believe that it's only not drawing that section on one of the screens, I'll figure out which one and post any more info I can think of that could help. Thanks for the help, though.
 
Reesy posted on Sep 20 2005 at 07:23 AM said:
Both of your frame buffers are pointing at the same place.


fb[0] = (unsigned short*) FRAMEBUFFER;
fb[1] = (unsigned short*) FRAMEBUFFER;

should be:

fb[0] = (unsigned short*) FRAMEBUFFER;
fb[1] = (unsigned short*) FRAMEBUFFER2;
 
Last edited by a moderator:
This is the first time I've ever looked at any c++ code and the first time I've ever looked at any gp32 code so I may be about to ask a couple of really dumb questions.

Wa posted on Sep 18 2005 at 09:46 PM said:
void swap_screen()
{
gp_setFramebuffer(fb[buffer],1);
buffer++;
if(buffer == 2)
  buffer=0;
}
Is this more efficient then something like this?
Code:
void swap_screen()
{
	gp_setFramebuffer(fb[buffer],1);
	if(buffer == 1) {
	buffer=0;
	} else {
	buffer=1;
	}
}
Seems like an extra increment that isn't needed to me!

Wa posted on Sep 18 2005 at 09:46 PM said:
int main()
{
gp_setCpuspeed(33);
fb[0] = (unsigned short*) FRAMEBUFFER;
fb[1] = (unsigned short*) FRAMEBUFFER;
gp_initFramebuffer(fb[0],16,85);
gp_clearFramebuffer16(fb[0],bgcolor);
gp_clearFramebuffer16(fb[1],bgcolor);
}

Is there a reason why you don't need to
Code:
gp_initFramebuffer(fb[1],16,85);
here? you do everything else for both buffers!

Forgive me if I'm being dumb here, I'm quite interested in programming for the GP32 and GP2x consoles but I am a newbie at this and don't know even nearly enough yet.
 
Last edited by a moderator:
woogal posted on Sep 28 2005 at 11:52 AM said:
Code:
void swap_screen()
{
        gp_setFramebuffer(fb[buffer],1);
        buffer^=1;
}
:)
:blink: It took about 30 mins of hunting through wikipedia to work out how that works! :ph34r:

I knew I was being dumb asking that question!
 
Last edited by a moderator:
:) Should really have explained it, but I was in a rush at the time.

For anyone who doesn't have 30 minutes to find out how it works -

^ is xor (exclusive or), which is 'A or B but not both'.
So 1 xor 1 is 0
0 xor 1 is 1
 
Back
Top