GP32 .SEF, and the GpTextOut function


TheMrCul

Still Fresh
Joined
Apr 18, 2003
Messages
52
Hi everyone.
I have two main questions.

First, the .sef file format
I have found code from gamepark that allows me to load .gpg files from a smc, assign them to a pointer and then allow me to use the GpBitBlt or GpTransBlt etc functions on them. However, I have found no code to do the same with .sef files. At the moment I can only embed them as .c files into my .fxe file, and it is getting rather large (sound files are heaps bigger than the graphics ones!!) Does anyone know how to load a .sef file from the smc and then be able to use the standard GpPcmOut function?

And the GpTextOut function
I have two integers, px and py, which are the player's x and y co-ordinates. I want to print their numbers to the screen, but when I use the
GpTextOut(NULL, &gpDraw[nflip], 20, 70,(char*)px, 0x00);
function, all it prints is garbage
I've tried combinations of pointers, creating char type casts, but they all print garbage. Can someone tell me how to print integer values?

Thanks everyone!
 
Thanks for all of your help generalnmx and Don. :)
But when I tried to use sprintf, it didn't actually display anything. I used:

char px2[14];
char py2[14];
sprintf(px, px2[14]);
sprintf(py, py2[14]);

char* px3[14];
px3[14] = &px2[14];
char* py3[14];
py3[14] = &py2[14];

GpTextOut(NULL, &gpDraw[nflip], 20, 60,px3[14], 0x00);
GpTextOut(NULL, &gpDraw[nflip], 20, 75,py3[14], 0x00);

Does anyone know what is wrong with it?
 
Woah! There's a few things wrong here.

When you have an array declared with say "char px2[14]", its members are numbered 0 to 13. A bit confusing, but that's the way it is. If you store anything in px2[14], you'll be writing memory that doesn't belong to px2 and you'll crash your gp32 or have some other problem.

I don't understand what you're trying to do with sprintf in the code you've shown, but you really need to read a C programming book or something to learn how to use it. Basically you use

sprintf ( destination, format string, data... )

where
destination is a character array to receive the string,
format string tells sprintf how to lay out the data, and
data is the data to include.

For example:

int a;
int b;
char str[30];

a = 10;
b = 20;

sprintf (str, "a = %d and b = %d",a,b);

GpTextOut (NULL, &gpDraw[nflip], 20, 60, str, 0x00);

The token "%d" tells sprintf to take a number from the data list and print it as decimal. There are heaps of others, like "%x" which tells sprintf to print a number as hexadecimal, "%X" which prints a number in hexadecimal in upper case, "%c" which prints a single character, and "%s" which prints a whole string.

Finally, make very sure that the number of items in the data list is the same as the number of % tokens in the format string.

Good luck!
 
Thanks a lot for your help guys. I looked in my programming books for the sprintf function to help me before I wrote the crazy code, but it wasn't there! There's another thing tho,

What changes do I have to make to minigp32 to be able to make 16-bit colour games? When I just try to do it, it says the function GpBitBlt16 does not exist, and I get 4 screens running simiultaneously! I know I have to do the
GpGraphicModeSet(16, NULL);

command, but what else do I have to do?
Thanks
 
Back
Top