GP32 My Graphics Code


Blah

Wanna Be Programmer
Joined
Dec 18, 2003
Messages
3,253
Age
34
Location
Oregon, USA
Website
Visit site
I have updated the code again. Support for 8bit graphics with transparency has been added. For more information, go to this thread: Graphics in Mr. Mirkos SDK.

There should be more updates, as this code is the first step in a new project I am starting that requires a good graphics core. :)

edit: I previously said to use memcpy to change your palette, but I figured out this was faster (hehe, I'm a cruddy programmer):

Code:
extern u32 my_palette[];
u32 *palette = (u32*) PALETTE;
*palette = *my_palette;

So your simply re-assigning the pointer, not copying over a palette.
This isn't too useful of information, but it would come in handy if your doing effects by fast palette shifting.

Make your sprites like this:

16 bit sprites:

bmp2bin -r -x sprite.bmp sprite.raw

8 bit sprites:

bmp2bin -i -r -x sprite.bmp sprite.raw
Make sure your bmp is 256 colors. Use the GP32 palette, or you can use your own
if you wish (generate the palette information with GP32converter).

edit: Update! gp_blit_8to16 added. This is used for blitting 8bit sprites to a 16bit framebuffer. Also theres gp_blitT_8to16, which does the same, but with transparency. The tiling functions have been updated with support for these features.

edit: Update!
Too lazy to write it twice, so here:

*  Changelog:

*  June 10 2005 - Blah on gp32x.de
*  First release
*
*  June 11 2005 - Blah on gp32x.de
*  Added transparency and headerless graphics support
*
*  June 18 2005 - Blah on gp32x.de
*  Added GNU GPL License
*  Added basic tile support
*  Added basic 8bit (256 color) graphics support
*  Changed function names to make more sense (and be shorter and easier on the typist)
*
*  June 21 2005 - Blah on gp32x.de
*  Added 8bit graphics with transparency support
*
*  June 22 2005 - Blah on gp32x.de
*  Added support for blitting 8bit sprites in 16bit mode with and without transparency headers, etc.
*
*  June 24 2005 - Blah on gp32x.de
*  Added support for blitting 8bit sprites in 16bit mode with alpha.
*  Cleaned up some functions.
*
*  Todo:
*  Clean up commenting
*  Add rotation support
*  Add scaling support
*  Add "hardware scrolling" (changing framebuffer pointer)
*  Add DMA support?
*  Fix bugs?
*  Anything else?
*/

Oops, I broke gp_blit16...Fixed.
 
Last edited by a moderator:
I have updated the code again. Support for 8bit graphics with transparency has been added. For more information, go to this thread: Graphics in Mr. Mirkos SDK.

There should be more updates, as this code is the first step in a new project I am starting that requires a good graphics core. :)

edit: I previously said to use memcpy to change your palette, but I figured out this was faster (hehe, I'm a cruddy programmer):

Code:
extern u32 my_palette[];
u32 *palette = (u32*) PALETTE;
*palette = *my_palette;

So your simply re-assigning the pointer, not copying over a palette.
This isn't too useful of information, but it would come in handy if your doing effects by fast palette shifting.

Make your sprites like this:

16 bit sprites:

bmp2bin -r -x sprite.bmp sprite.raw

8 bit sprites:

bmp2bin -i -r -x sprite.bmp sprite.raw
Make sure your bmp is 256 colors. Use the GP32 palette, or you can use your own
if you wish (generate the palette information with GP32converter).

edit: Update! gp_blit_8to16 added. This is used for blitting 8bit sprites to a 16bit framebuffer. Also theres gp_blitT_8to16, which does the same, but with transparency. The tiling functions have been updated with support for these features.

what the hell are you smoking???

dont tell me this line replaces the full palette...

Code:
*palette = *my_palette;

you only assign "what is pointed by palette" with "what is pointed by my_palette". (only the first word is assigned... which means 2 colors)
If you would like to change "wher is pointing palette" with "where is pointing my_palette" you have to write

Code:
palette = my_palette
but this just wont work

loki
 
Last edited by a moderator:
WTF?! sure you are not smoking anything?! how can you write a lib in a SINGLE .c WITHOUT a header file (.h) ?!?!
 
Ah geez. I'm lazy. Either #include the file, write your own .h, or shut up.

If your as much of a C noob as me, you don't need to be smoking anything.
...Unless this Mr. Pibb is laced with something :blink:
 
Back
Top