Re: A89: Sprite Question


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

Re: A89: Sprite Question




well, binary would work to define sprites to. i think you can give C a
binary number, cant you?  i just dont remember exactly how.


anyway, binary to hex conversion is actually qite simple and just takes a
bit of practice.

if you need to, just write yourself a short chart to help:

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


most of these quads should eventually be memorized, but some keys until then
are using offsets.
for example, 0000(0) thourhg 0011(3) should be the first you memorize, as
well as 0111(7), 1000(8),  and 1111(F).  Then everything else is a few
movements from these.
1010 is 2 up from 8, or A.
1101 is two down from F, so its D.
0100 is one up from 3, so its 4.

Do you see what I mean?  but seriously, memorizeing this short 16 entry
chart is a must.

then, you jsut break binary numbers into quads, starting at the extreme
right, and convert each quad. if the final set isnt a full four, add zeros
to it.
actually, this quad setup should be the way you write binary numbers always.
its a good habit to get into and makes conversion and copying much easier
(of course, if you are typing inot a program or code, then you can use the
spaces. :)


11101011101011010010010100100100010010010001000100
becomes
11 1010 1110 1011 0100 1001 0100 1001 0001 0010 0100 0100 0100
and adding the zeros:
0011 1010 1110 1011 0100 1001 0100 1001 0001 0010 0100 0100 0100

then you go forward with hex conversion:
  3      A       E      B     4        9      4      9      1      2       4
4      4
combining that, you get:
3AEB494912444
and in C, this is represented to show that it is a hex number like so:
0x3AEB494912444
now, hex is really nice.  since every thing is in sets of 4, its very
simple.
each nibble (4bits) is one hex digit.  each byte(8bit) is always 2 hex
digits.  a word(16bit) is 4, a double word(32 bit) is 8, a quad word(64bit)
is 16, etc.

NIBBLE:    0xB
BYTE:       0xEF
WORD:     0xA5C0
DWORD:   0xD50EA8FF
QWORD:   0xFFFFFFF00016C801

Well, I'm bored early this morning, just got done talking to my girl,s o i
thought i would ramble a bit. :) hope this helps.
im going to bed.

--kaus


----- Original Message -----
From: "Ahmed El-Helw" <ahmedre@mindspring.com>
To: <assembly-89@lists.ticalc.org>
Sent: Tuesday, June 13, 2000 8:10 PM
Subject: RE: A89: Sprite Question


>
> 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
>
>




References: