Jump to content
IGNORED

Bitmaps to sprites in cc65


karri

Recommended Posts

In the Ubuntu 20.04 there is a new version of Gimp that produce pcx files that seem to crash the sp65 program that does the coversion to sprites.

 

At the same time I realized that it was impossible to generate 8-colour sprites (BPP_3).

 

So I added a new keyword "bpp=3" to the conversion phase.

 

Here is a small tutorial of converting bitmaps to shaped sprites. In order to make my life a little easier I start with a 17 colour bitmap. The last colour is violet that is not included in the default palette.

264945570_Screenshotfrom2020-09-1910-58-10.png.618cfef39e986957c9d57f15fb7f9088.png

 

This makes it a bit easier to see the desired shape of the sprite.

 

In order to convert this to a sprite I will use a command line like this:

sp65 -r spr.pcx -c lynx-sprite,mode=shaped,edge=16,ax=32,ay=32 -w spr.c,ident=spr,bytesperline=8

 

This will create a file that defines the sprite like:

#define spr_BPP          4
#define spr_WIDTH        64
#define spr_HEIGHT       64
const unsigned char spr[] = {


 

In the C-code I define the sprite as:

static SCB_REHV_PAL Spr = {
    BPP_4 | TYPE_BACKGROUND,
    PACKED | REHV,
    NO_COLLIDE,
    0,
    spr,
    80, 51,
    0x100, 0x100,
    {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}
};


 

702897030_Screenshotfrom2020-09-1920-38-12.png.618e290ee432d7b3adb6ec644caaa3a0.png

 

The result is circular as the violet area was not converted to the sprite.

 

It is also possible to map the colours during the sprite conversion process with the keyword pen=0123456789abcdef

 

Just for fun I now change the mapping to the inverse with

sp65 -r spr.pcx -c lynx-sprite,mode=shaped,edge=16,ax=32,ay=32,pen=fedcba9876543210x -w spr.c,ident=spr,bytesperline=8

 

259977810_Screenshotfrom2020-09-1920-45-15.png.b3780b631af3c673c70b7d3562cd5ec6.png

 

In the next step we want to force the colours to 8 colours only. Without editing the graphics we can map the colours with the keyword bpp=3

 

$(SP) -r spr.pcx -c lynx-sprite,mode=shaped,edge=16,ax=32,ay=32,bpp=3 -w spr.c,ident=spr,bytesperline=8

 

1836714867_Screenshotfrom2020-09-1920-48-49.png.2d5397ca84598c2fa58e063c50a52190.png

 

Or with bpp=2

495304196_Screenshotfrom2020-09-1920-52-16.png.cebaf64d8008e9bfa3536ad9a0e0a847.png

 

And finally bpp=1

1990915465_Screenshotfrom2020-09-1920-53-41.png.f0f1a0efd7cf180948bb321bc4ab72bf.png

 

As the last one is a bit dull I could also add the pen-attribute like:

 

$(SP) -r spr.pcx -c lynx-sprite,mode=shaped,edge=16,ax=32,ay=32,bpp=1,pen=0123765489abfedcx -w spr.c,ident=spr,bytesperline=8

1608893104_Screenshotfrom2020-09-1921-07-09.png.433b33c52e05843809c3370e38618369.png

  • Like 4
Link to comment
Share on other sites

14 minutes ago, 42bs said:

Nice feature. Do you mind if  I "borrow" it for sprpck?

Not at all. Please do it.

 

Actually these shaped sprites is the way to go for making patches to old-time carts. If you leave out the "edge" it will default to 0. So this means that even when used on normal sprites you can omit the last stride to the edge of the extent of the sprite if the colour index is 0.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...