LOGO: Reading the graphics screen

The following LOGO code allows the user to determine the setting of the bit of the graphics screen directly under the turtle (HITP), or at any point (DOTP).
This code may not give the expected results for colors other than black and white. Depending on HEADING, HITP may not always see the turtle if it is shown.

TO HITP
LOCAL "ADDR
MAKE "ADDR (.EXAMINE 916) + (.EXAMINE 127) + 256 * .EXAMINE 128
OP BITP .EXAMINE 917 .EXAMINE :ADDR
END

TO RESTORE
SETPOS :OLDPOS
SETPEN :OLDPEN
IF :OLDSHOWNP [ST]
END

TO BITP :BITSIG :BYTE
IF NOT :BITSIG < 128 [MAKE "BITSIG :BITSIG -128]
OP 1 = INT ((REMAINDER :BYTE 2 * :BITSIG) / :BITSIG)
END

TO DUMP :POSLIST
LOCAL "OLDSHOWNP
MAKE "OLDSHOWNP SHOWNP
LOCAL "OLDPOS
MAKE "OLDPOS POS
LOCAL "OLDPEN
MAKE "OLDPEN PEN
PU
HT
SETPOS :POSLIST
IF HITP [RESTORE OP "TRUE]
RESTORE
OP "FALSE
END
Published Date: Feb 18, 2012