10 rem basicode 2 routines for c64 and commander x16 11 goto 1000:rem jump to init 20 rv=rnd(-ti) 21 rem see if screen width = 40 and number of lines 22 oc=79 23 poke783,1:sys65520:o0=peek(781) 24 printtab(39);" "; 25 poke783,1:sys65520 26 if peek(781)>o0 then oc=39 27 poke781,23:poke782,0:poke783,0:sys65520 28 ol=peek(781) 29 print:poke783,1:sys65520 30 if peek(781)>ol then 28 31 goto 1010:rem jump to start program 100 rem clear screen, upper/lower case 101 print chr$(147);chr$(14); 102 return 110 if ho>oc then ho=39:rem set cursor position 111 if ve>ol then ve=ol 112 poke781,ve:poke782,ho:poke783,0 113 sys65520:return 114 poke782,ho 115 poke783,0 116 sys65520 117 return 120 rem read cursor position 121 poke783,1 122 sys65520 123 ve=peek(781):ho=pos(782) 124 if ho>oc then ho=ho-oc-1 125 return 200 get in$:return:rem try to read character from the keyboard 210 get in$:if in$="" then 210:rem wait for key from the keyboard 211 return 250 print chr$(7):return:rem beep 260 rv=rnd(1):return:rem return random number 270 fr=fre(0):rem return amount of free memory 271 if fr<0 then fr=32767 272 return 300 sr$=str$(sr):rem convert number to string 301 if left$(sr$,1)="." then sr$="0"+sr$ 302 if left$(sr$,1)=" " then sr$=mid$(sr$,2,255) 303 return 310 sr$=str$(sr):rem convert number to a fixed width string 311 return 350 return:rem print to printer, not implemented 360 return:rem newline on printer, not implemented