Re: A85: Accessing bits


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

Re: A85: Accessing bits




do you need to be able to compare the numbers to 0-3 specifically?  if
not, you could just use %00000011 (left), %00001100 (right), %00110000
(top), %11000000 (bottom) to "and" with the value in memory. Then
compare to 0,1,2,3 for left; 0,4,8,12 for right; etc.

-mike pearce

On Mon, 11 May 1998 18:58:22 -0400, you wrote:

>
>Let's say I have a byte stored in my ZShell program like this:
>
>SomeByte:
>.db %10110110
>
>How would I split that number up to this:
>10-11-01-10
>(Four new binary numbers ranging from 0 to 3)
>
>so that I could compare each segment to a value?
>
>My map algorithm for the game I'm working on requires that I be able to
>make these comparisons.  The game I'm working on is an RPG and I would
>have to use this for drawing and finding the clipping values of each
>room.  For clipping, here are the 4 numbers you would want to compare:
>
>Each room is box shaped and you can move up, down, left, or right.  Here
>are how the bits are organized:
>
>00000000  <-  This is the binary number
>12345678  <-  Here is the order of the bit values
>
>1 and 2, left clipping value
>3 and 4, right clipping value
>5 and 6, top clipping value
>7 and 8, bottom clipping value
>
>00  You can walk through this anytime.
>01  Locked, a key is required
>10  Locked, you must defeat a certain boss
>11  You can not walk through this under most circumstances
>
>So I how would I tell if I could walk through the top of the room I were
>in?
>
>Sorry if this is somewhat confusing.  It took me a month to come up with
>this and the clipping values are probably the least complex of the four
>bytes that make up each individual room.
>
>egillespie@juno.com
>erik_gillespie_1096@gwgate.kvcc.edu
>
>"In a prototypical world, nothing ever goes wrong." -Scott Meyers
>
>_____________________________________________________________________
>You don't need to buy Internet access to use free Internet e-mail.
>Get completely free e-mail from Juno at http://www.juno.com
>Or call Juno at (800) 654-JUNO [654-5866]
>


References: