Your main loop is this:



MAIN:

COM=$A6:GOSUB SEND_COMMAND '$A6=NORMAL MODE;$A7=INVERSE MODE
'PAUSE 100
COM=$2E:GOSUB SEND_COMMAND
COM=$27:GOSUB SEND_COMMAND