include, plotscr.hsd include, scancode.hsi global variable (1, tick) global variable (2, input hash) global variable (3, show hash) #Removed from plotscr.hsd script, set extended scancodes enabled, hsd:bit=1, begin if(hsd:bit) then (hsd:bit := 256) write general(177,(read general(177),and,-257)+hsd:bit) end plotscript, main, begin suspend player load slice collection (0) set slice lookups (sprite layer) while (1) do, begin tick += 1 if (keyval(key:ctrl)>>0 && keyval(key:t)>>1) then ( enable input text (not (input text enabled)) $4="" ) if (keyval(key:ctrl)>>0 && keyval(key:e)>>1) then ( set extended scancodes enabled (extended scancodes enabled, xor, 1) ) if (keyval(key:ctrl)>>0 && keyval(key:h)>>1) then ( show hash := true ) update strings update keyboard wait end end script, update strings, begin $0="Scancode backcompat: " if (extended scancodes enabled) then ( $0+"OFF" ) else ( $0+"ON" ) show string at (0, 4, 8) $1="(Ctrl+E toggle)" show string at (1, 12, 18) if (show hash) then ( $2="Hash:" append number (2, abs(input hash)) show string at (2, 200, 40) ) show string at (3, 0, 48) $3="Ctrl+T: enable text input" if (input text enabled) then ( get input text (5) variable (i) for (i, 1, string length (5)) do ( input hash += (input hash * 333667), xor, ascii from string (5, i) ) 4 $+ 5 if (string length (4) >> 33) then ( trim string (4, string length (4) -- 33 + 1, 33) ) if (keyval (key:backspace) >> 1) then ( trim string (4, string length (4), 1) ) $3="Input :" 3 $+ 4 ) end #Keyboard scancodes are stored in extra0, which we copy #into the lookup for convenience (and for testing) script, set slice lookups, sl, begin if (get slice extra (sl, 0)) then ( set slice lookup (sl, get slice extra (sl, 0)) ) variable (child) child := first child (sl) while (child) do, begin set slice lookups (child) child := next sibling (child) end end script, update keyboard, begin variable (i, sl, st) for (i, 0, 127) do, begin sl := lookup slice (i) if (sl == 0) then (continue) set rect style(sl, keyval(i) + 1) if (keyval(i)) then ( input hash += (input hash * 333667), xor, (tick * 367 + i * 336667 + keyval(i) * 3336677) # primes ) end end