Exporting Sprites -> *.c

slinga

Established Member
Hey guys,

I need to fix up some sprites. I'm exporting them from the gimp to a c file but the format is not the same as what I've used before. Can anybody know what the specifications on saturn are for? From what I can tell the format looks to be:

unsigned short <spritename>[] =

{

0xhex value, ....,

...

...

...

};

unsigned long <spritename>Size = <sprite height * sprite width>


Where each hex value is 4 hex digits. Is this correct? Does each hex value represent a single pixel in the image?

If so I think I can whip up a simple filter to do the conversion process.
 
read the vdp2 documentation. it depend on the bpp and a few other things. i'd do something like:

Code:
unsigned short sprite_col[] = {

 0x8000,

 0x7FFF | 0x8000 /* color #1 */

};

unsigned char sprite_cel[] = {

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11,

 0x11,0x11,0x11,0x11

};

here is what i used to create 4bpp sprites:
Code:
 unsigned int i; // x

 unsigned int j; // y

 unsigned int index;

 unsigned int h0;

 unsigned int h1;

 unsigned int base_index;

   width /= 2;

   if (height > 8)

    height /= (height / 8);

   h0 = height;

   h1 = height;

   if (height > 8) {

    h0 /= 2;

    h1 /= 4;

   }

   index = ((y * height) * width) + (x * h1);

   base_index = index;

   for (j = 0; j < height; j++)

   {

    for(i = 0; i < width; i++) {

     printf("0x%02X,",buf[index]);

     index++;

    }

    puts("");

    base_index += width;

    index = base_index;
 
Can I see your entire file for the 4bpp? Are you simply reading an entire 4bpp bmp file into buf?
 
The format for sprites/textures used when exporting with 3DEditor is 15 bit RGB.

From SL_DEF.H:

Code:
#define   RGB(r,g,b) (0x8000|((b)<<10)|((g)<<5)|(r))

BGCON can be used for exporting sprites as .C, too. Use DOSBox to emulate.

Some Saturn GFX conversion utilities come with source code, like SSCONV.

SSConv will convert 24 bit raw files to 15 bit files for the Saturn. SSConv

can output a binary or C file. It also supports transparent settings (Sprite).
 
yes, i'm copying everything into the "buf" variable. the height and width variables is pretty self explanatory. by the way Rockin'-B, why would you convert a 4-bit image to a 15-bit sprite? makes no sense what so ever. that's a complete waste of resources if you ask me.
 
Originally posted by Piratero@Thu, 2005-11-03 @ 09:42 AM

why would you convert a 4-bit image to a 15-bit sprite? makes no sense what so ever. that's a complete waste of resources if you ask me.

[post=141311]Quoted post[/post]​


Initially, Slinga was not talking about 4-bit images.
 
I'm just looking for the easiest way to convert sprites for use on the Saturn. I enjoy coding, I hate working with sprites. I'll try both methods above, don't seem too bad.
 
Back
Top