UNIT SCREEN;

INTERFACE

PROCEDURE CLEARSCREEN;
PROCEDURE CLEARSPACE(X,Y,N : INTEGER);
PROCEDURE SAVECURSOR(VAR X,Y : INTEGER);

IMPLEMENTATION

PROCEDURE CLEARSCREEN;
  VAR LF : PACKED ARRAY [1..24] OF CHAR;
      I : INTEGER;
  BEGIN
    GOTOXY(0,23);
    FOR I := 1 TO 24 DO LF[I] := CHR(10);
    UNITWRITE(1,LF,24);
    GOTOXY(0,0)
  END;

PROCEDURE CLEARSPACE (*X,Y,N : INTEGER*);
  VAR I : INTEGER;
      CS :PACKED ARRAY [1..160] OF 0..255;
  BEGIN
    GOTOXY(X,Y);
    FOR I := 1 TO N DO CS[I] := 32;
    FOR I := N+1 TO N+N DO CS[I] := 8;
    UNITWRITE(1,CS[1],N);
    UNITWRITE(1,CS[N+1],N)
  END;
  
PROCEDURE SAVECURSOR (*VAR X,Y : INTEGER*);
  VAR T : PACKED ARRAY [0..7] OF 0..255;
  BEGIN
    T[0] := 27;
    T[1] := ORD('j');
    T[2] := 27;
    T[3] := ORD('n');
    UNITWRITE(1,T,4);
    UNITREAD(2,T[4],4);
    X := T[7] - 32;
    Y := T[6] - 32
  END;
  
END.
