MMBasic for Windows - support for Xbox and DualShock 4 controllers
Author
Message
electricat Senior Member Joined: 30/11/2020 Location: LithuaniaPosts: 299
Posted: 03:05pm 06 Aug 2024
I know too SUB`s must inefficient, and that DEC idea was only to make it pretty, yes. I wrote once some bit manipulation functions bit.set, bit.res, bit.test only becouse it was fun and nostalgic but not the most efficient way
So yes, there are many ways to solve same task .. CSUB`s etc.. :)
Wrote them while writing z80 disasm :D
function bit_res.0 (bt) bit_res.0=bt and 254 end function
function bit_res.1 (bt)
bit_res.1=bt and 253 end function
function bit_res.2 (bt) bit_res.2=bt and 251 end function
function bit_res.3 (bt) bit_res.3=bt and 247 end function
function bit_res.4 (bt) bit_res.4=bt and 239 end function
function bit_res.5 (bt) bit_res.5=bt and 223 end function
function bit_res.6 (bt) bit_res.6=bt and 191 end function
function bit_res.7 (bt) bit_res.7=bt and 127 end function
function bit_set.0 (bt) bit_set.0=bt or 1 end function
function bit_set.1 (bt) bit_set.1=bt or 2 end function
function bit_set.2 (bt) bit_set.2=bt or 4 end function
function bit_set.3 (bt) bit_set.3=bt or 8 end function
function bit_set.4 (bt) bit_set.4=bt or 16 end function
function bit_set.5 (bt) bit_set.5=bt or 32 end function
function bit_set.6 (bt) bit_set.6=bt or 64 end function
function bit_set.7 (bt) bit_set.7=bt or 128 end function
' test bit. If bit set, returns 1 if offset returns 0
function bit.0 (test_byte) as integer bit.0=(test_byte and 1) end function
function bit.1 (test_byte) as integer bit.1=(test_byte and 2) >> 1 end function
function bit.2 (test_byte) as integer bit.2=(test_byte and 4) >> 2 end function
function bit.3 (test_byte) as integer bit.3=(test_byte and 8) >> 3 end function
function bit.4 (test_byte) as integer bit.4=(test_byte and 16) >> 4 end function
function bit.5 (test_byte) as integer bit.5=(test_byte and 32) >> 5 end function
function bit.6 (test_byte) as integer bit.6=(test_byte and 64) >> 6 end function
function bit.7 (test_byte) as integer bit.7=(test_byte and 128) >> 7 end function