Shop OBEX P1 Docs P2 Docs Learn Events
vga_512x384_bitmap - How do you turn a pixel OFF??? — Parallax Forums

vga_512x384_bitmap - How do you turn a pixel OFF???

jreevejreeve Posts: 6
edited 2007-12-12 15:52 in Propeller 1
Hello All. I've been playing around with the vga_512x384_bitmap demo program and object, and had a question about turning pixels off. The demo program gives the following subroutine to turn ON a pixel at x,y:

PRI plot(x,y) | i

if x => 0 and x < 512 and y => 0 and y < 384
pixels[noparse][[/noparse]y << 4 + x >> 5] |= |< x

I don't fully understand this subroutine, but imagine it is setting a single bit to 1 at a location in memory corresponding to location x,y. What I'd like to do is set that bit to 0 at the same location. I've tried to modify the subroutine as follows, note the change in the last line:

PRI plotoff(x,y) | i
if x => 0 and x < 512 and y => 0 and y < 384
pixels[noparse][[/noparse]y << 4 + x >> 5] ^= |< x

This seems to toggle the pixel on and off rather than just turning it off, not exactly what I had in mind. Any suggestions??? Thanks, John R.

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-12-12 00:54
    The universal clear is the & operator, so the line would look like pixels[noparse][[/noparse]y << 4 + x >> 5] &= ! |< x
    so what it does is create a bit mask for the bit to be changed, then invert it·(so all bits are 1 except the bit we want to clear which is 0). When the value is and'ed with the value stored in pixels, all bits will stay the same except the bit in question which is set to 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • jreevejreeve Posts: 6
    edited 2007-12-12 01:12
    Thanks very much! John R.
  • kittmasterkittmaster Posts: 77
    edited 2007-12-12 15:52
    so the application would be like a cluster of pixels that could be used as an "on/off" indication type vga feedback ?
Sign In or Register to comment.