> ConvBas 1.02 M v1.01 22-Jun-2020: Tokenises 'BY', opt%=128 tokenises 'PRIVATE', 'EXIT' - v1.02 16-Sep-2023: Added &18-&1F tokens (: 2Z "Convert between Acorn/6502/6809/PDP11/32K/ARM"'" and Russell/Z80/80x86 BASIC files" <BasConvInit F, ::CloseAll:: "QUIT",>&FFFF): P Z. "Source file: "src$ dR "Source type (Acorn/Russell): "A$:srctype%=(".AaBbRrPpTt",A$,1))+2)/4 n. "Dest. file: "dst$ xR "Dest. type (Acorn/Russell/Text): "A$:dsttype%=(".AaBbRrPpTt",A$,1))+2)/4 . "List options: "opt% 3err%=BasConv(src$,srctype%,dst$,dsttype%,opt%) $ err%=214:"'"src$"' not found" % err%=192:"Can't open '"dst$"'" # err%=127:"Unknown file type" * err%=126:"Conversion not supported"   : I ------------------------------------------------------------------- @ src$=source file, srctype%=source type, 1=Acorn, 2=Russell H dst$=dest. file, dsttype%=dest. type, 1=Acorn, 2=Russell, 3=Text 0 opt%=LISTO options when outputting to text % bit 0: space after line number  bit 1: indent structures 2 bit 2: split lines at ":" (not implemented) "H bit 3: don't list line number (ignored if line destination found) ,9 bit 4: list tokens in lower case (not implemented) 66 bit 5: pause at end of screen (not implemented) @ bit 6: JH bit 7: extension: tokenise PRIVATE, EXIT; 2-byte immediate tokens T Returns 0=Ok, <>0=failure ^$ 126: conversion not supported h 127: unknown file type r- 192: couldn't save to destination file |! 214: source file not found I ------------------------------------------------------------------- /ݤBasConv(src$,srctype%,dst$,dsttype%,opt%) < srctype%<1 srctype%>3 dsttype%<0 dsttype%>3:=127 ) srctype%=3 srctype%=dsttype%:=126 in%=(src$): in%=0:=214 *out%=(dst$): out%=0:#in%:in%=0:=192 UConvert: dsttype%=3: lnum%: opt% 8:opt%=opt% -9:#in%=0:#out%=0:Convert  CloseAll =0 : BasConvInit in%=0:out%=0 ; tkn$(255),line% 3: A%=100 &11F: tkn$(A%255): A%  :  Convert &indent%=0:lnum%=0 0 srctype%=1:A%=#in% : dsttype%=1:#out%,13 D N4 srctype%=1:hi%=rd(255):lo%=rd(0):len%=rd(0) X4 srctype%=2:len%=rd(0):lo%=rd(0):hi%=rd(255) b4L$="":num%=hi%*256+lo%: len%:RdLine:len%=L$+3 l= dsttype%=1:#out%,hi%: hi%<>255:#out%,lo%:#out%,len% v2 dsttype%=2:#out%,len%:#out%,lo%:#out%,hi% " dsttype%=3:WrLine wr(L$)  #in% len%=0 hi%=&FF  :  RdLine  P$=" "  A%=#in%:B$=A%:len%=len%-1 H INSTR(CHR$&7F+CHR$&C7+CHR$&C6+CHR$&C8+CHR$&CC+"B",B$):B$=FNRdByte2 A srctype%=1: A%=&7F (A%>&C5 A%<&CF) A%=66:B$=RdByte2 G srctype%=2: dsttype%=1: A%<32 (A%>=&C6 A%<=&CC):B$=RdByte1 L$=L$+B$: B$<>" ":P$=B$  len%<4 7 dsttype%=2: L$,1)=" "::L$=L$,2): L$,1)<>" "   :  % Translate Russell 1-byte tokens * ݤRdByte1 4? A%=&00 A%=&0D:=A% : End of line >e A%<&0D+((opt%128)32):B%=("&"+"008F9D909791989394999C969A0DA500A6",A%*2+1,2)): B%:=&C8+B% HZ A%<&11:=tkn$(A%) : 'PRIVATE', 'EXIT', convert to text RK A%>&17: A%<&20:(opt%128)=0:=("&"+"C6C7CEC9C8CACCCD",A%*2-47,2)) \P A%>&17: A%<&20:(opt%128)>0:=&C7+("&"+"8F9192949597999A",A%*2-47,2)) f7 A%=&C6:=&C6+&8E : 'SUM' p9 A%=&C7:=&C8+&95 : 'WHILE' z8 A%=&C8:=&C8+&8E : 'CASE' @ A%=&CC:=&7F : 'OTHERWISE' A=A% : Leave as is : # Translate Acorn 2-byte tokens  &7F 1-byte OTHERWISE  &CC 1-byte ELSE 5 'B' 'BY' if immediately after DRAW/FILL/MOVE  &C6,xx 2-byte functions V &C7,xx 2-byte immediate commands, if &C7 must be non-ARM BASIC edited on RISC OS  &C8,xx 2-byte commands  ݤRdByte2 @ A%=&7F:=&CC : 'OTHERWISE' ; A%=&CC:=&8B : 'ELSE' DA%=A%*256+#in%:len%=len%-1 : Two-byte token C A%=&4259: &EC+&DF+&03,P$):=&0F : [MOVE|DRAW|FILL] 'BY' : A%=&C68E:=&C6 : 'SUM' $> A%=&C68F:=tkn$(117) : 'BEAT' .` A%>=&C78E: A%<=&C79A:=B%=("&"+"001800191A001B1C001D001E1F",(A%-&C78E)*2+1,2)): B%:=B% 8\ A%>=&C78E: A%<=&C79F:=tkn$(100+A%-&C78E) : No 1-byte equivalent, convert to text B\ A%>=&C88E: A%<=&C89D:=(("&"+"C8010305F00708C70B0406090C0C0A02",(A%-&C88E)*2+1,2))) L\ A%>=&C89E: A%<=&C8A4:=tkn$(118+A%-&C89E) : No 1-byte equivalent, convert to text VE A%>=&C8A5: A%<=&C8A6:=(&0E+(A%-&C8A5)*2) : 'PRIVATE', 'EXIT' `G#in%=#in%-1:len%=len%+1:A%=A%256 : Must be 1-byte token j@ A%>=&C6: A%<>&CB:=("&"+"18191C1B1D001E1F",A%*2-395,2)) tD=A% : Leave as is ~:  WrLine  L$="": G num%: (opt% 8)=0:wr(d(num%,5)) (opt% 8)=0:wr(" ")  opt% 1:#out%,32  ptr%=1 L$ > &ED+&FD+&CE+&CB+&CD,L$,ptr%,1)):indent%=indent%-1  ptr% 1 opt% 2:wr(2*indent% (indent%>0)," "))  ptr%=1 L$ B%=L$,ptr%,1) 5 B%=&8D:$line%=L$,ptr%+1,3):ptr%=ptr%+3:lnum%= S B%=&8D:wr((((line%?2 16*?line%)*256+(line%?1 (4*?line% &C0)))&FFFF)) 9 B%<&7F: B%>&1F:#out%,B% B%<>&8D:wr(tkn$(B%))  1 &E3+&F5+&C7+&C8,B%):indent%=indent%+1  ptr% ' L$,2)=&8C+13:indent%=indent%+1 ( #out%,10 2 <: F!ݤrd(A%): #in%:=A% =#in% P:wr(A$): A$<>"": A%=1 A$:#out%,A$,A%,1): A% Z d: nN APPEND,AUTO,CRUNCH,DELETE,EDIT,HELP,LIST,LOAD,LVAR,NEW,OLD,RENUMBER,SAVE x* TEXTLOAD,TEXTSAVE,TWIN,TWINO,INSTALL F BEAT,BEATS,TEMPO,VOICES,VOICE,STEREO,OVERLAY,MANDEL,PRIVATE,EXIT U OTHERWISE,AND,DIV,EOR,MOD,OR,ERROR,LINE,OFF,STEP,SPC,TAB(,ELSE,THEN,,OPENIN,PTR U PAGE,TIME,LOMEM,HIMEM,ABS,ACS,ADVAL,ASC,ASN,ATN,BGET,COS,COUNT,DEG,ERL,ERR,EVAL W EXP,EXT,FALSE,FN,GET,INKEY,INSTR(,INT,LEN,LN,LOG,NOT,OPENUP,OPENOUT,PI,POINT(,POS X RAD,RND,SGN,SIN,SQR,TAN,TO,TRUE,USR,VAL,VPOS,CHR$,GET$,INKEY$,LEFT$(,MID$(,RIGHT$( S STR$,STRING$(,EOF,SUM,WHILE,CASE,WHEN,OF,ENDCASE,OTHERWISE,ENDIF,ENDWHILE,PTR W PAGE,TIME,LOMEM,HIMEM,SOUND,BPUT,CALL,CHAIN,CLEAR,CLOSE,CLG,CLS,DATA,DEF,DIM,DRAW W END,ENDPROC,ENVELOPE,FOR,GOSUB,GOTO,GCOL,IF,INPUT,LET,LOCAL,MODE,MOVE,NEXT,ON,VDU W PLOT,PRINT,PROC,READ,REM,REPEAT,REPORT,RESTORE,RETURN,RUN,STOP,COLOUR,TRACE,UNTIL U WIDTH,OSCLI,,CIRCLE,ELLIPSE,FILL,MOUSE,ORIGIN,QUIT,RECTANGLE,SWAP,SYS,TINT,WAIT R INSTALL,,PRIVATE,BY,EXIT,,,,,,,,AUTO,DELETE,EDIT,LIST,LOAD,NEW,RENUMBER,SAVE : CloseAll 'out%=out%:out%:A%=out%:out%=0:#A% "in%=in%:in%:A%=in%:in%=0:#A%  ": ,#ݤd(A%,N%)=" "+A%,N%) 6: @A BY;by;"BY": BY 1,2: 1+BY,2: BY 1,2:Ȑ BY 1,2: GOTO 1510 J5Ǖ "file",address:ǚ "file",start,end:ǔ "file"