FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MATHEMATICS

Twiddle bit


Don't know if this will help, but when I want to set a bit I use OR, and when I want to clear a bit I use AND NOT, like this

_kCanFly = &H00000001
_kCanSwim = &H00000080

Flags& = Flags& OR _kCanFly '(Sets bit 0)
Flags& = Flags& AND NOT _kCanSwim '(Clears bit 7)

Another thing to check:

Flags& = Flags& OR 3 Does not set bit 3. To set bit 3 you need to OR the value with another value that only has bit 3 set. &H04 will do that for ya.

joe k.


The BITSET statements require an address--a pointer to the starting bit.
You're passing an integer variable instead of a pointer. If I'm not mistaken, you've been setting bits in whatever zero-page word is pointed to by the value of cellState%.

CALL BITSET(#@cellState%,_bitFldOffset - _cellStateChangeBit)

BTW, I'm not perfectly clear on what the # does, but I seem to recall the compiler wont accept this construction without it.)

Jay


Bit twiddling can be fun...

Use OR to set a bit on; Anything XORed with itself is 0 so to guarantee that a bit field is 0 first turn then on with OR and then use the same bit pattern with XOR to force them off; Want to exchange 2 fields, A and B, without using any intermediate storage do the following...

A XOR B followed by B XOR A followed by A XOR B exchanges A and B!

Charlie Dickman