program TestCrtWinX;
{$F+}
uses
  Crt,
  CrtWin,
  Proc1X,
  Kernel
{$IFNDEF DOS}
  ,
  RemoTerm,
  ComType,
  KernMon
{$ENDIF}  ;

const
  cName     = 'TestCrtWinX';      { jmeno jednotky }
  cVer      = 'v1.11, 8.1.2003';  { verze a datum jednotky }

const
  MaxProc=4;
  ARect : array[1..MaxProc] of TRect=(
           (X:  2; Y:  2; W: 38; H: 10),
           (X: 42; Y:  2; W: 38; H: 10),
           (X:  2; Y: 14; W: 38; H: 10),
           (X: 42; Y: 14; W: 38; H: 10));
  TbCol : array[1..MaxProc] of Byte=(
           $9,$a,$c,$7);

var FI, FO : Text;

procedure TermO(Rect: TRect; S: String; AS, AR, AW: Byte);
var
  Win : PCrtWin;
  SS  : String;
begin
  Start('TI',2000,90,254);Exit;
  Win:=New(PCrtWin,Init(Rect,S,FrameD,AS,AR,AW, 7,8));
  if Win=nil then RunError(203);
  repeat
    Win^.LockWin;
    Write('Zadej : ');
    ReadLn(SS);
    if SS='p' then Dly:=2*Dly else
    if SS='r' then Dly:=(Dly+1) div 2 else
    if SS='x' then Abort('*');
{$IFNDEF DOS}
    Writeln(FO, SS);
{$ENDIF}
    Win^.UnLockWin;
  until false;
end;

procedure TermI(Rect: TRect; S: String; AS, AR, AW: Byte);
var
  Win : PCrtWin;
  SS  : String;
begin
  Start('TO',2000,90,254);Exit;
  Win:=New(PCrtWin,Init(Rect,S,FrameD,AS,AR,AW, 7,8));
  if Win=nil then RunError(203);
  repeat
    ReadLn(FI, SS);
    if SS='p' then Dly:=2*Dly else
    if SS='r' then Dly:=(Dly+1) div 2 else
    if SS='x' then Abort('*');
    Win^.LockWin;
    Writeln(SS);
    Win^.UnLockWin;
  until False;
end;

var
  i,j : Byte;
  W    : PMyCrtWin;
  Name : Char;

begin
{$IFNDEF DOS}
  AssignRemote(FI);
  AssignRemote(FO);
  Rewrite(FO);
  Reset(FI);
{$ENDIF}
  TextMode(CO80);
  StartMain(250,254);
  InitInterruptStack(2, 512);
  StartTimeSlicing($8);
{$IFNDEF DOS}
  KernelMonitor(Com1, ACom1, Bd4800, IRQ4, 1);
{$ENDIF}

  CrtInit;
  MainWin^.HiddenCursor;
  Name:='A';
  for j:=1 to 2 do
    begin
      W:=New(PMyCrtWin,Init(Arect[j], '<< Okno '+Chr($30+j)+' >>',FrameD, $7, $7, $7, $20, 0));
      if W=nil then RunError(203);
      for i:=1 to 4 do
        begin P1(Name, i,j, W); Inc(Name) end;
    end;
{$IFNDEF DOS}
  TermI(ARect[3],'<< Okno 3 >>',$7,$7,TbCol[MaxProc]);
{$ENDIF}

  TermO(ARect[4],'<< Okno 4 >>',$7,$7,TbCol[MaxProc]);

  TerminateMain;
end.
