10
20
30 :
40 A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256:A%=254:X%=0:Y%=255:K%=(((USR&FFF4)AND&FF00)DIV256)OR128
50 escOn$="ESC ON":escOff$="ESC OFF":ON ERROR escOn$="FX229":escOff$="FX229,1"
60 A%=VPOS:OSCLIescOn$:ON ERROR OFF:IF A%<>VPOS:escOn$="":escOff$="":VDU11,11:PRINTSPC60;CHR$13;
70 OSCLIescOff$:FOR A%=0 TO 7:OSCLI"FX"+STR$(221+A%)+","+STR$((A%EOR4)*16+128):NEXT:OSCLI"FX219,9":*FX4,2
80 key%=0:kbd%=(os%<8):IF(INKEY-256AND&DB)=&53:kbd%=1
90 PRINT"Keypress input/character output test"'STRING$(36,"-")
100 PRINT"Program running on ";FNs(FNhost(os%));". ";
110 REPEAT
120 IF key%=0 OR kbd%=0:PRINTMID$("NativeForced",(K% AND 64)DIV10+1,6);" keycodes are:"
130 IF key%=0 OR kbd%=0:PROCkbdinfo(kbd%):PRINT"Esc+Esc to end"'
140 REPEAT
150 last%=key%:key%=GET
160 PRINT FNh0(key%,2);" ";FNc3(key%);" ";FNc1(key%);TAB(10);FNc0(key%);TAB(15);FNkeyname(key%)
170 key%=key% AND 255
180 UNTIL key%=27
190 K%=K% EOR 64:OSCLI"FX254,"+STR$K%
200 UNTIL key%=27 AND last%=27
210 OSCLIescOn$:OSCLI"FX225,1":OSCLI"FX254,"+STR$K%:*FX4
220 END
230 :
240 DEFFNkeyname(A%):LOCAL A$,K%:K%=A% AND 15
250 IF A%=8:="Ctrl-H BACKSPACE"
260 IF A%=9:="Ctrl-I TAB"
270 IF A%=13:="Ctrl-M RETURN"
280 IF A%=27:="Ctrl-[ ESCAPE"
290 IF A%<31:="Ctrl-"+CHR$(A%+64)
300 IF A%=32:="SPACE"
310 IF A%<127:=""
320 IF A%=127:="DELETE"
330 IF kbd%>0:IF A%=&80:="Ctrl-Left"
340 IF kbd%>0:IF A%=&81:="Ctrl-Right"
350 IF kbd%>0:IF (A% AND &F0)=&80:=MID$("HomeEnd PgUpPgDnIns Del LeftRghtDownUp MsDnMsUp",K%*4-7,4)
360 IF kbd%>0:A%=A%-16
370 IF A% AND 16:A$="Shift-"
380 IF A% AND 32:A$=A$+"Ctrl-"
390 IF kbd%=0:IF (A% AND 48)=48:A$="Alt-"
400 IF kbd%=0:IF (A% AND &CF)=&80:=A$+"Print/f0"
410 IF kbd%>=0:IF (A% AND &CE)=&8E:=MID$("ScrllBreak",K%*5-69,5)+"/f"+STR$K%
420 IF kbd%>=0:IF A%<192:=A$+"f"+STR$K%
430 IF kbd%=0:A$=A$+MID$("WindMenuWideKanjRomjTAB Ins Del HomeEnd PgDnPgUpLeftRghtDownUp",K%*4+1,4)
440 IF kbd%=0:=A$+LEFT$(CHR$8,K%=5)+LEFT$("/f"+STR$(K%+16),K%<5)+LEFT$("/NoConv",K%=5)
450 IF A%<192:IF K%<10:=A$+"f"+STR$K%
460 IF A%<192:=A$+MID$("BreakCopy Left RightDown Up",K%*5-49,5)
470 IF K%>9:=MID$("f10 f11 f12 Ins MsDnMsUp",K%*4-39,4)
480 IF K%<2:=MID$("WindMenu",K%*4+1,4)
490 =A$+"Japan"+STR$K%
500 :
510 DEFPROCkbdinfo(A%)
520 IF A%>0:IF (INKEY-256AND&DB)=&53:PRINT"&8x: c<-,c->,Home,End,PgUp,PgDn,Ins,Del,<-,->,Dn, Up,MsDn,MsUp"
530 IF A%>0:IF (INKEY-256AND&DB)=&53:PRINT"&9x: F0, F1, F2, F3, F4, F5, F6, F7, F8,F9,F10,F11,F12,F13,F14,F15":ENDPROC
540 IF A%=0:PRINT"&8x: F0,F1,F2,F3,F4,F5,F6, F7, F8, F9, F10, F11, F12,F13,F14,F15"
550 IF A%=0:PRINT"&Cx:"SPC18"Ins,Del,Home,End,PgDn,PgUp, <-, ->, Dn, Up":ENDPROC
560 IF A%<0:PRINT"&8x: F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,Break,Copy,<-,->, Dn , Up"
570 IF A%<0:PRINT"&9x:"SPC48"PgDn,PgUp"'"&Cx:"SPC32"F10, F11,F12,Ins"
580 ENDPROC
590 :
600 DEFFNhost(A%)
610 IF A%>27:IF A%<33:=MID$("Commodore 64/128TI Calculator Amstrad CPC ZX Spectrum DOS/Windows ",A%*16-447,16)
620 IF A%<11:=MID$("ElectronBBC B BBC B+ Master MasterETCompact RISC OS SpringbdUnix 6809UnixApple ",A%*8+1,8)
630 IF A%=17:="6809Beeb" ELSE IF A%=24:="CP/M" ELSE IF A%=43:="RT11/RSX/RSTS" ELSE IF A%=57:="6809DOS"
640 ="unknown"
650 :
660
670 DEFFNh0(A%,N%)=RIGHT$("0000000"+STR$~A%,N%)
680 DEFFNs(A$):IFLEFT$(A$,1)=" ":REPEATA$=MID$(A$,2):UNTILLEFT$(A$,1)<>" "
690 IFRIGHT$(A$,1)=" ":REPEATA$=LEFT$(A$,LENA$-1):UNTILRIGHT$(A$,1)<>" "
700 =A$
710 DEFFNc0(A%):IF A%>127:="|!"+FNc0(A% AND 127)
720 IF A%<32 OR A%=127:="|"+CHR$(A% EOR 64) ELSE =LEFT$("|",A%=34 OR A%=124)+CHR$A%
730 DEFFNc1(A%):IF ((A%+1) AND 127)<33:="^"+CHR$(A% EOR 64) ELSE =CHR$A%
740 DEFFNc2(A%):IF (A% AND 127)<32 OR A%=127:="." ELSE =CHR$A%
750 DEFFNc3(A%):IF ((A%+1) AND 127)<33:="." ELSE =CHR$A%