A86: 3-color icons


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

A86: 3-color icons



 
KewlAid mentioned greyscale icons.  A good way to store them would be

     .db size       ; 8 or 16
     .db mask1...   ; 8x8 icons have 8 bytes here
                    ; 16x16 icons have 16 words here
     .db mask2...   ; similar to mask1

Mask1 and mask2 are combined in the following way:

     m1  m2  output
     --- --- ------
      1   1  grey
      1   0  transparent
      0   1  black
      0   0  white

Algorithm for drawing greyscale icons (and sprites):
1. AND LCD buffer1 with mask1          (b1 = b1*m1 + m2)
2. OR LCD buffer1 with mask2
3. copy mask1 into a temporary buffer  (b2 = b2*m1*m2' + m1'*m2)
4. AND temporary buffer with the complement of mask2
3. AND LCD buffer1 with the temporary buffer
6. invert mask1 into the temporary buffer
7. AND temporary buffer with mask2
8. OR LCD buffer2 with temporary buffer

Notes:
1. Notice that mask2 is always used after mask1, never the other way
   around.  This should reduce the drawing time.

2. For black and white, steps 1 and 2 would be sufficient.  Grey would 
   show as black.  As you can see, black and white is *much* faster than
   grey.
 
3. This storage format could also be utilized for collision detection.


Any comments?

      
--------
Dan Eble (mailto:eble@cis.ohio-state.edu)
         (http://www.cis.ohio-state.edu/~eble)