Help converting sprites to MD
Moderator: Stef
Help converting sprites to MD
Hello everyone. I am Spanish and my English is not very good so apologize me.
I began a few days ago a new adventure with SGDK, and after i had been using libraries like Fenix/Bennu or Allegro some time ago, i discovered i am a nooby coding for Genesis. I had done and made some trials will all the wiki tutorials and i think i understad them, but after i had tried a lot of ways i can´t convert my sprites to MD format.
I am working from GenRes's SPRITE support, working with a sprite sheet, but each attemp i try converting my sheet to a Genesis compatible format doesn't work. I have read about 16 colors, 256 or 512, 8 pixel aligned... but i don´t understand for example how i can make transparencies (in Sonic tutorial the green backgroud is transparent on emulator but i doesn't work with my sheet) or the .size attribute. I think i need a program that convert my file to a compatible bmp, but all the programs i have read in wiki convert them to asm or bin and them i am completely lost with that.
Thanks for reading, i am waiting for your help.
I began a few days ago a new adventure with SGDK, and after i had been using libraries like Fenix/Bennu or Allegro some time ago, i discovered i am a nooby coding for Genesis. I had done and made some trials will all the wiki tutorials and i think i understad them, but after i had tried a lot of ways i can´t convert my sprites to MD format.
I am working from GenRes's SPRITE support, working with a sprite sheet, but each attemp i try converting my sheet to a Genesis compatible format doesn't work. I have read about 16 colors, 256 or 512, 8 pixel aligned... but i don´t understand for example how i can make transparencies (in Sonic tutorial the green backgroud is transparent on emulator but i doesn't work with my sheet) or the .size attribute. I think i need a program that convert my file to a compatible bmp, but all the programs i have read in wiki convert them to asm or bin and them i am completely lost with that.
Thanks for reading, i am waiting for your help.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
-
- Very interested
- Posts: 124
- Joined: Sun Jan 29, 2012 2:10 pm
- Location: North America
- Contact:
Have you already taken a look at the Tools forum? I've used _mic's tool called "sixpack" with some modifications. Read about it in this thread
I don't work with sprite sheets, I just create separate image files for each sprite image, so that may not be useful.
I don't work with sprite sheets, I just create separate image files for each sprite image, so that may not be useful.
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Hi there,
For transparencies, the pixels you want transparent need to be the first color in the 16 color palette. It'll work automatically. It doesn't matter what the actual color is, it just has to be the first one.
Hopefully this will make it more clear:
The pixels of the sprite that are using color 0 from the palette will be transparent.
Edit: I also use SGDK's support for genres and it works great.
My resource.rc looks something like this:
For transparencies, the pixels you want transparent need to be the first color in the 16 color palette. It'll work automatically. It doesn't matter what the actual color is, it just has to be the first one.
Hopefully this will make it more clear:
Code: Select all
palette colors:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
example sprite:
0 0 0 0 0 0 0
0 0 1 1 1 0 0
0 1 1 2 1 1 0
0 1 2 2 2 1 0
0 1 1 2 1 1 0
0 0 1 1 1 0 0
0 0 0 0 0 0 0
Edit: I also use SGDK's support for genres and it works great.
My resource.rc looks something like this:
Code: Select all
SPRITE goplanesSprite "data/goplanes.bmp" 24 24 ; individual sprites are 24x24 and the .bmp contains about 30 frames.
SPRITE fireballSprite "data/fireball.bmp" 16 16
SPRITE fireballPickupSprite "data/fireball_pickup.bmp" 24 24
; always finish with a blank line or comment
Thanks ammianus. I have tried sixpack but it is a bit difficult for me. I tested it converting a bmp various times but it didn't work, surely i was doing something wrong. I have read about an easy and intuitive tool called ImaGenesis. It seems nice but when i convert my bmp to 4bpp and i load it in my code SGDK compiler says the sprite is not 4bpp...
So i am sorry but i need some "for dummies" help and tools.
PD: In other forums about other libraries people recomend to load just 1 parent bitmap and then catch every sprite from it better than loading one for every sprite, to get better performance, i don´t know if it is true...
Thanks djcouchycouch. Ok i understand it. So now i need a tool to convert properly a bmp to 16 colors (i don't know how to do with Gimp and in MsPaint i get a poor result). Then i guess i need another one to edit the sprite and the palette so the transparect color match.
I see in your Resource.rc that the size of your frames is 16x16 or 24x24. In the wiki example they are 24x32. I know the bitmap size should be 8 pixel aligned but when i try 32x40 compiler loads 32x32... Its .size attribute is
i dont know where is the issue.
So i am sorry but i need some "for dummies" help and tools.
PD: In other forums about other libraries people recomend to load just 1 parent bitmap and then catch every sprite from it better than loading one for every sprite, to get better performance, i don´t know if it is true...
Thanks djcouchycouch. Ok i understand it. So now i need a tool to convert properly a bmp to 16 colors (i don't know how to do with Gimp and in MsPaint i get a poor result). Then i guess i need another one to edit the sprite and the palette so the transparect color match.
I see in your Resource.rc that the size of your frames is 16x16 or 24x24. In the wiki example they are 24x32. I know the bitmap size should be 8 pixel aligned but when i try 32x40 compiler loads 32x32... Its .size attribute is
Code: Select all
sonic.size = SPRITE_SIZE(4,5);
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
Thanks guys. I was beginning to think the maximun size is 32x32, thanks for confirm oofwill. No need to apologize KanedaFr, thanks for your work, do it when you can. I am learning working on a Sonic game and sonic sprites are about 29x39 so i will use 2 sprites as oofwill said.
By the way i tried to convert a bmp to 16 colors with Gimp but the SGDK compiler says something like "bmp header not compatible", and as i said MsPaint with 16 color returns a bad quality sprite... Do you recomend me another software, Photoshop for example?
By the way i tried to convert a bmp to 16 colors with Gimp but the SGDK compiler says something like "bmp header not compatible", and as i said MsPaint with 16 color returns a bad quality sprite... Do you recomend me another software, Photoshop for example?
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
Not necesarry.djcouchycouch wrote:For transparencies, the pixels you want transparent need to be the first color in the 16 color palette.
For Example -> SPRITE spritesDW "data/spritesDW.bmp" 32 32 0 2
Last number (2) - is number of transparent color for image. You can see palette in XnView and colors start counts from 0 to 15.
Yep, i encounter same problem.Manveru wrote: By the way i tried to convert a bmp to 16 colors with Gimp but the SGDK compiler says something like "bmp header not compatible", and as i said MsPaint with 16 color returns a bad quality sprite... Do you recomend me another software, Photoshop for example?
Ok, how to change image to 4 bit in GIMP.
Image->Mode->Indexed... (if it alredy selected, you can choose first RGB mode and after him Indexed)
When choose generate optimum palette and choose 16 colors.
Press convert.
You also can change order of colors in Colours->Map->Rearrange Colourmap
To fix bmp, when you Export image, in Compability Options check field Do no write colour space information
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Seems to me like Genres might be doing something during the bitmap conversion to support that. The hardware doc I looked up (Genesis_technical_overview.doc) says that the first color of each palette is always transparent. Could be wrong, though.Not necesarry.
For Example -> SPRITE spritesDW "data/spritesDW.bmp" 32 32 0 2
Last number (2) - is number of transparent color for image. You can see palette in XnView and colors start counts from 0 to 15.
For making sprites, I use Graphics Gale. It's more geared to towards sprite work.
Thanks lingh, now i can make transparences on sprites and Gimp seems to work...well maybe, this is my sprite sheet (160x32, 5 frames 32x32)
and this is what i get on an emu (5 frames the same result):
(seems like it draws a 16x32 sprite)
My resources.rc code is:
I don't know where is the issue...
and this is what i get on an emu (5 frames the same result):
(seems like it draws a 16x32 sprite)
My resources.rc code is:
Code: Select all
SPRITE sonic "data/sonic.bmp" 32 32 0 0
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
resources.rc
main.c
Code: Select all
SPRITE sp_parent_sonic "data/sonic.bmp" 32 32 0 0
Code: Select all
typedef struct
{
SpriteDef sp_sonic;
u16 nbTiles;
u8 status;
u8 frame;
int speed, count;
u8 flags;
} hedgehog;
struct genresSprites
{
u16 *pal;
u32 **sprites;
u16 count;
u16 width;
u16 height;
u16 size;
};
extern struct genresSprites sp_parent_sonic;
int main( )
{
hedgehog sonic;
sonic.nbTiles = sp_parent_sonic.count;
sonic.sp_sonic.posx = 40;
sonic.sp_sonic.posy = 140;
sonic.sp_sonic.size = SPRITE_SIZE(4,4); //i test sp_parent_sonic.size>>8; too.
sonic.sp_sonic.tile_attr = TILE_ATTR_FULL(PAL1,1,0,0,TILE1+sonic.nbTiles);
sonic.sp_sonic.link = 0;
VDP_setPalette(PAL1, sp_parent_sonic.pal);
VDP_loadTileData( sp_parent_sonic.sprites[0], TILE1+sonic.nbTiles, sonic.nbTiles, 0);
while(1)
{
VDP_setSpriteP(0, &sonic.sp_sonic);
VDP_updateSprites();
VDP_waitVSync();
}
return 0;
}
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
Manveru
Change
to
Change
Code: Select all
sonic.nbTiles = sp_parent_sonic.count;
Code: Select all
sonic.nbTiles = (sp_parent_sonic.width >> 3) * (sp_parent_sonic.height >> 3);
It works!!! thanks lingh, you are my herolingh wrote:Manveru
ChangetoCode: Select all
sonic.nbTiles = sp_parent_sonic.count;
Code: Select all
sonic.nbTiles = (sp_parent_sonic.width >> 3) * (sp_parent_sonic.height >> 3);
I thought .count was the number of frames in sprite, it worked well with the wiki code.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC