$COM1 1024
$COM2 1024
OPEN "COM1: 110,N,7,2,DS,CD" AS #1 LEN=1
OPEN "COM2: 9600,N,8,1,RS,CS,DS,CD" AS #3 LEN=1
WHILE 1=1
 A$ = INKEY$
 IF MID$(A$,1,1) = CHR$(27) THEN END
 IF MID$(A$,1,1) = "L" THEN
  CALL LOADFILE
  A$=""
 END IF
 IF MID$(A$,1,1) = "Z" THEN
  CALL HIGHSPEED
  A$=""
 END IF
 IF LEN(A$) <> 0 THEN PRINT #1,A$;
 IF LOC(1) > 0 THEN PRINT INPUT$(LOC(1),#1);
WEND

SUB HIGHSPEED

WHILE 1=1
 A$ = INKEY$
 IF MID$(A$,1,1) = CHR$(27) THEN RETURN
 IF LEN(A$) <> 0 THEN PRINT #3,A$;
 IF LOC(3) > 0 THEN PRINT INPUT$(LOC(3),#3);
WEND

END SUB

SUB LOADFILE

INPUT "HEX FILE NAME ", A$
OPEN A$ AS #2

I% = 0
WHILE I% = 0

WHILE INPUT$(1,#2) <> ":"
 WEND

VH% = ASC(INPUT$(1,#2)) - ASC("0")
IF VH% > 9 THEN VH% = VH% - 7
VL% = ASC(INPUT$(1,#2)) - ASC("0")
IF VL% > 9 THEN VL% = VL% - 7
RECLEN% = 16 * VH% + VL%

IF RECLEN% = 0 THEN
I%=1

ELSE

CALL SENDCHAR("I")

FOR J%= 1 TO 4
CALL SENDCHAR(INPUT$(1,#2))
NEXT J%

CALL SENDCHAR(CHR$(13))

DUM$ = INPUT$(2,#2)

FOR J% = 1 TO 2*RECLEN%
CALL SENDCHAR(INPUT$(1,#2))
NEXT J%

CALL SENDCHAR(CHR$(27))

T$ = ""
WHILE  T$ <> "."
T$ = INPUT$(LOC(1),#1)
IF LEN(T$) > 0 THEN PRINT T$;
WEND
FOR CK%=1 TO 3
FOR CC%=1 TO 32000
NEXT CC%
NEXT CK%

END IF

WEND

CLOSE #2

END SUB

SUB SENDCHAR(B$)

PRINT #1,MID$(B$,1,1);
FOR CK%=1 TO 3
FOR CC%=1 TO 32000
NEXT CC%
NEXT CK%
WHILE LOC(1) = 0
WEND
PRINT INPUT$(LOC(1),#1);


END SUB

END
