Jump to content

Photo

Convert from bitmask to screen location


1 reply to this topic

#1 unhuman OFFLINE  

unhuman

    Stargunner

  • 1,203 posts
  • Location:Vienna, VA

Posted Sat Mar 10, 2018 11:31 PM

Anyone have a good way to convert from bitmask to screen locations?  For the game I'm working on (which is finally coming together), I'm using a bitmask....

 

I'd like to be able to draw something so that if I have a value of 100011001, I'd like to be able to draw characters: *   **  *.  I'm currently doing this in a loop, checking each bit, but there's got to be a better way....

 

I'm using XB, but this will be compiled when done. 

 

-Howie



#2 OLD CS1 OFFLINE  

OLD CS1

    Quadrunner

  • 5,219 posts
  • Technology Samurai
  • Location:Tallahassee, FL

Posted Sun Mar 11, 2018 12:27 AM

I wrote a character defining program BITD and I used a 15 element string array indexed by the 8-bit value divided by 16 for the first nybble and the remainder for the second.

 

Like so:

 

B$(0-15) is set as the bit positions "    ","   *","  * "..."****", N1 and N2 are the nybble values, and B is the byte.  Therefore,

 

N1=INT(B/16)

N2=B-N1*16

C$=B$(N1)&B$(N2)






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users