A85: Accessing bits


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

A85: Accessing bits




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]


Follow-Ups: