Re: A89: Sprite Question


[Prev][Next][Index][Thread]

Re: A89: Sprite Question




I just realized you could need a full table to understand.

0000  0
0001  1
0010  2
0011  3
0100  4
0101  5
0110  6
0111  7
1000  8
1001  9
1010  A (10)
1011  B (11)
1100  C (12)
1101  D (13)
1110  E (14)
1111  F (15)

The binary counting works just like counting with regular numbers, but with only
0-1 instead of 0-9. As you can see, the hex numbers 0-F represent all
combinations possible with four 1s and/or 0s. So every group of 4 binary digits,
represent one hex digit. As you probably already know, each binary digit
represent one pixel in the image. Isn't much of a format, just raw image data.

//Olle

Olle Hedman wrote:
> 
> look at the table in the letter you replied to, read the letter carefully, and
> think a bit :)
> binary <-> hex conversion is the easiest conversion there is. (That's why they
> came up with hex in the first place. It's a compact way of writeing binary.)
> Any asm coder should be able to do binary to hex, and hex to binary without calc
> or paper.. I use my fingers if I get a "brainout" :)
> the "format" isn't much different, it is just written in another numberbase in
> the code.
> 
> //Olle
> 
> Ahmed El-Helw wrote:
> >
> > Hi,
> > Haha, I know how to make a sprite in z80 or just in the normal way, but I
> > just didn't know how to convert it to hex.  I just don't really understand
> > what you mean when you say to combine the hex numbers... maybe if I learn to
> > convert binary to hex I'll figure it out :)  Thanks though that's a really
> > good start for me :)
> >
> > -Ahmed
> >
> > -----Original Message-----
> > From: owner-assembly-89@lists.ticalc.org
> > [mailto:owner-assembly-89@lists.ticalc.org]On Behalf Of Nathaniel Gibson
> > Sent: Tuesday, June 13, 2000 5:18 PM
> > To: assembly-89@lists.ticalc.org
> > Subject: Re: A89: Sprite Question
> >
> > >I know this is a really dumb question probably, but could someone tell me
> > >how to convert sprites into the format needed for TIGCC, I've never seen
> > >that format before.  Thanks.
> > >
> > >-Ahmed
> >
> > The best way I can describe it is to do it by hand...
> >
> > Take a piece of graph paper and make a 16x16 square of blocks. Within
> > that, draw your sprite. Now, starting at the top line of pixels, take
> > the first four blocks and pretend that colored in equals 1, and empty
> > equals 0. Now, put the four numbers together and pretend it's a
> > binary number. Convert that number to hex. That's the first 'number'.
> > Do this for the next 3 groups of 4 block in the first row. Put all
> > four hex digits together, and that's one index.
> >
> > Example: take this ball below.
> >
> > 0000    1111    1111    0000    0x0ff0
> > 0001    1111    1111    1000    0x1ff8
> > 0011    1111    1111    1100    0x3ffc
> > 0111    1111    1111    1110    0x7ffe
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 1111    1111    1111    1111    0xffff
> > 0111    1111    1111    1110    0x7ffe
> > 0011    1111    1111    1100    0x3ffc
> > 0001    1111    1111    1000    0x1ff8
> > 0000    1111    1111    0000    0x0ff0
> >
> > Now, put this in the actual declaration...
> >
> > static unsigned ball [] = {0x0ff0, 0x1ff8, 0x3ffc, 0x7ffe, 0xffff,
> > 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x7ffe,
> > 0x3ffc, 0x1ff8, 0x0ff0};
> >
> > FYI: Sprite16 is buggy, so you'll have to use Sprite32. In this case
> > your declaration would be...
> >
> > static unsigned ball [] = {0x0ff00000, 0x1ff80000, 0x3ffc0000,
> > 0x7ffe0000, 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000,
> > 0xffff0000, 0xffff0000, 0xffff0000, 0xffff0000, 0x7ffe0000,
> > 0x3ffc0000, 0x1ff80000, 0x0ff00000};
> >
> > Hope this helps,
> >
> > Nathaniel Gibson
> > ngibson@ptd.net



Follow-Ups: References: