Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Converting to sprites
2009-07-02 04:33
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Converting to sprites

Ok, so i have run into a problem.. hehe

I have 52 bmp pics, which are each the size of 2x2 C64 sprites.

So there's room for them all in 1 VIC bank..
Now problem is to convert them..

I tried Gang-Ed, but it only imports bmp as hires/mcol bitmap/char, and blows up the small image to fullscreen!

So i saved all the frames as a koala pr pic.. hahaha

Now i am stuck with 52 koala pics, that need to be transformed into 4 sprites each, bwahaha..

This is really silly..

What i really need is:

1) convert the 48x48 pixel bmp to 4 colors
2) convert this to 4 sprites

Is there an editor, where i can load bmp/gif into a sprite editor ? they have correct size, just need to be fixed to 4 cols.. which i can do with a batchconvert in thumbs plus (reduce nr of colors)

??

Thanks for any help!
 
... 56 posts hidden. Click here to view all posts....
 
2013-01-21 22:38
Burglar

Registered: Dec 2004
Posts: 1101
this might work

.macro LoadSpritesFromPicture( filename,
                               xsize, ysize,
                               bgcolor, color0, color1, color2 ) {
    .var picture = LoadPicture( filename, List().add(bgcolor, color0, color1, color2) )
    .for (var ysprite = 0; ysprite < ysize; ysprite++) {
        .for (var xsprite = 0; xsprite < xsize; xsprite++) {
            .for (var i = 0; i < [3 * 21]; i++) {
                .byte picture.getMulticolorByte(
                    [[xsprite * 3]  + mod(i,21)],
                    [[ysprite * 21] + floor(i / 3)]
                )
            }
            .byte 0
        }
    }
}
2013-01-22 08:37
enthusi

Registered: May 2004
Posts: 677
http://www.codebase64.org/doku.php?id=base:sprite_converter
Personally I prefer the assembler doing the assembling and tools acting as tool ;-)
2013-01-22 14:48
Magnar

Registered: Aug 2009
Posts: 61
@Burglar, it almost worked. One error only;

parsing
flex pass 1
.for (var ysprite = 0; ysprite < ysize; ysprite++) {
.for (var xsprite = 0; xsprite < xsize; xsprite++) {
.for (var i = 0; i < [3 * 21]; i++) {
.byte picture.getMulticolorByte(
^

Error: byte x coordinate out of range : 3

Maybe you see what to correct?
2013-01-22 15:09
Burglar

Registered: Dec 2004
Posts: 1101
your image.gif is too small in width, u need to double it.

multicolor pixels are 2 pixels wide, so 2x3 sprites should be:

2 * 3 * 8 pixels wide = 48
3 * 21    pixels high = 63
2013-01-22 15:10
Burglar

Registered: Dec 2004
Posts: 1101
Quote: http://www.codebase64.org/doku.php?id=base:sprite_converter
Personally I prefer the assembler doing the assembling and tools acting as tool ;-)


so, where's your multicolor tool? ;)
2013-01-22 15:13
Cruzer

Registered: Dec 2001
Posts: 1048
Shouldn't it be mod(i,3)?
2013-01-22 16:07
Magnar

Registered: Aug 2009
Posts: 61
@Burglar, still not working. Now I am using a GIF file with 48x63 pixels, 4 colors.

Gives error:
flex pass 1
.for (var ysprite = 0; ysprite < ysize; ysprite++) {
.for (var xsprite = 0; xsprite < xsize; xsprite++) {
.for (var i = 0; i < [3 * 21]; i++) {
.byte picture.getMulticolorByte(
^

Error: byte x coordinate out of range : 6

Sourcecode:

.var bgcolor= $000000
.var color0 = $ffffff
.var color1 = $696259
.var color2 = $000000
.var xsize = 48
.var ysize = 63

.pc = $3000 "Sprite Data"
spriteData:

:LoadSpriteFromPicture("C:\anna_1.gif",xsize,ysize,bgcolor,color0,color1,color2 )
:LoadSpriteFromPicture("C:\anna_2.gif",xsize,ysize,bgcolor,color0,color1,color2 )

.macro LoadSpriteFromPicture( filename,
xsize, ysize,
bgcolor, color0, color1, color2 ) {
.var picture = LoadPicture( filename, List().add(bgcolor, color0, color1, color2) )
.for (var ysprite = 0; ysprite < ysize; ysprite++) {
.for (var xsprite = 0; xsprite < xsize; xsprite++) {
.for (var i = 0; i < [3 * 21]; i++) {
.byte picture.getMulticolorByte(
[[xsprite * 3] + mod(i,21)],
[[ysprite * 21] + floor(i / 3)]
)
}
.byte 0
}
}
}
2013-01-22 16:17
Burglar

Registered: Dec 2004
Posts: 1101
.var xsize = 2
.var ysize = 3

xsize/ysize is in sprites, not pixels.
2013-01-22 18:50
Magnar

Registered: Aug 2009
Posts: 61
Unfortunately same error even after changing the xsize and ysize values.
2013-01-22 18:53
Cruzer

Registered: Dec 2001
Posts: 1048
Give my previous comment a chance :)
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
algorithm
MWR/Visdom
Steffan/BOOM!
Sulevi/Virtual Dreams
Barfly/Extend
DJB/Onslaught / Blue..
Guests online: 102
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Sabbi  (9.5)
4 Morpheus  (9.4)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.042 sec.