GP32 Problem With Drawing Sprite


FabreNZ

Member
Joined
Dec 21, 2004
Messages
132
I'm new to GP32 developing (and to the GP32 itself), and I've come across a problem. I used the example Garfield sprite's raw C file for my sprite drawing script:

Code:
#include "gp32.h"
#include "garfield.c"

unsigned short *framebuffer;
unsigned short *screen;

int main() {
  short x=100,y=100;
  int i;
  framebuffer = (u16*) FRAMEBUFFER;
  gp_setCpuspeed(66);
  gp_initFramebuffer(framebuffer,16,85);

  for (i=0;i<320*240;i++) {framebuffer[i]=0xFFFF;}

  gp_drawSprite((u16*)garfield,x,y,framebuffer,160,160);

  while (1) { }
}

This compiles and runs fine, but part of Garfield's right half appears on the left. I've probably done some stupid n00b mistake, that's why I'm posting here :D
 
Looks ok to me. Is garfeild.c just the one that comes with the example?
Also, do you have a BLU+? And if so, are you using Mr.Mirkos new SDK? - you are using Mr.Mirkos SDK right?

p.s. and are you from NZ?
 
Thanks for replying!

Is garfeild.c just the one that comes with the example?

Yes, it's the raw sprite file included with the sprite example

Also, do you have a BLU+? And if so, are you using Mr.Mirkos new SDK?

No, I have an FLU

You are using Mr.Mirkos SDK right?

Yes

p.s. and are you from NZ?

Yes I am. I was actually signed up before, and you asked me that same question, but my account got deleted when the server had a hiccup recently.
 
hello,

sizeof(garfield) gives 51208 (160*160*2=51200) : sprite header in array ?

with :

gp_drawSprite((u16*)(garfield+8),x,y,framebuffer,160,160);

it works.

in the array you can see size : 160,0,160,0 (offset 4)
don't know what 4 first bytes are...
 
hello,

sizeof(garfield) gives 51208 (160*160*2=51200) : sprite header in array ?

with :

gp_drawSprite((u16*)(garfield+8),x,y,framebuffer,160,160);

it works.

in the array you can see size : 160,0,160,0 (offset 4)
don't know what 4 first bytes are...

The garfield sprite comes with a header, instead of
gp_drawSprite((u16*)(garfield+8),x,y,framebuffer,160,160);
you can use :
gp_drawSpriteHT ( (u16*)garfield, 90, 50, framebuffer, 0xFFFE );

In the header is the size of the sprite stored... Have a closer look to the example and docs.
 
Last edited by a moderator:
Back
Top