[A83] Question(bit checking)


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

[A83] Question(bit checking)




Ok, i would like to make it so that some basic flags in my game, could all be 
combined into 1 variable(well, 8 on/off flags would go into 1 spot in memory)
Ok, i was wondering how i would do this.  I have a rough idea, but i was 
wondering if there was anyway to optimise it for speed?

(checking the binary value of 11110111 for the 4th value, or, to get 0)
ld a,%11110111
sra a
sra a
sra a
sra a
and 1

so i could have a function like this?

(a = number to check, b= bit to check, returns a, the value of the bit)
BitFinder:
    sra a
    djnz BitFinder
    and 1
    ret
is that the best i could do? just wondering, and also, is that correct? ^_^ 
thanks