vga_512x384_bitmap - How do you turn a pixel OFF???
jreeve
Posts: 6
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.
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
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.