{$D-}

Unit Monitor;



interface

{***************************************************************************}

{***************************************************************************}



var

  BeepOn: boolean;

  Displayed: integer;

  KeyboardOn: boolean;



Procedure Change;

Procedure Init;

Procedure Switch;

Procedure Update;

Procedure Wr(InPort: integer; InStr: string);

Procedure WrL(InPort: integer; InStr: string);



implementation

{***************************************************************************}

{***************************************************************************}

uses

  BBSAlarm,

  BBSFuncs,

  BBSGlbls,

  Crt,

  Data,

  Dos,

  Glob,

  Keyb,

  Scrn;



Procedure Change;

{***************************************************************************}

var

  InChar: char;

begin

  if Keyb.AltKey(InChar) then

    case InChar of

      AltA:  AlarmToggle;

      AltB:  BeepOn := not(BeepOn);

      AltC:  Switch;

      AltK:  KeyboardOn := not(KeyboardOn);

      AltQ:  halt;

      AltR:  MainInit;

      else

        write(Beep);

    end; {case}

end;



Procedure Init;

{***************************************************************************}

begin

  Scrn.ReverseVideo(false);

  ClrScr;

  Displayed := 0;

  BeepOn := true;

  KeyboardOn := true;

  Update;

end;



Procedure Switch;

{***************************************************************************}

begin

  clrscr;

  inc(Displayed);

  if Displayed > NumPorts then

    begin

      Displayed := -1;

      WriteLn('Alt-A:  toggle Alarm on/off');

      WriteLn('Alt-B:  toggle Beep character on/off');

      WriteLn('Alt-C:  Change displayed screen to next port or help screen');

      WriteLn('Alt-K:  toggle Keyboard on/off');

      WriteLn('Alt-Q:  Quit/halt the program');

      WriteLn('Alt-R:  Reset the program');

    end;

end;



Procedure Update;

{***************************************************************************}

var

  alpha: integer;

  Hour,

  Minute,

  Sec,

  Sec100: word;

  OldX,

  OldY: byte;

begin

  OldX := WhereX;

  OldY := WhereY;

  Window(1,1,80,1);

  Scrn.ReverseVideo(true);

  write('Wyrm BBS');

  write(Glob.SingleVertical);

  if KeyboardOn then

    write('Keyboard On ')

  else

    write('Keyboard Off');

  write(Glob.SingleVertical);

  write('Port ', Displayed);

  write(Glob.SingleVertical);

  GetTime(Hour, Minute, Sec, Sec100);

  write(StrWrdZer(Hour,2),':',

    StrWrdZer(Minute,2),':',StrWrdZer(Sec,2),'.',StrWrdZer(Sec100,2));

  write(Glob.SingleVertical);



{*

  write('[ ');

  for alpha := 1 to AreaTOS[Now] do

    write(ord(Area[Now, alpha]), ' ');

  write(']    ');

  write(Glob.SingleVertical);

*}



  write('Alarm ');

  if AlarmOn then

    write('On ')

  else

    write('Off');

  write(' ', StrIntZer(AlarmHour, 2), ':', StrIntZer(AlarmMinute, 2));

  write(Glob.SingleVertical);

  write('Beep ');

  if BeepOn then

    write('On ')

  else

    write('Off');

  write(Glob.SingleVertical);

  write('Alt-H');

  Scrn.ReverseVideo(false);

  Window(1, 2, 80, 25);

  GotoXY(OldX, OldY);

end;



Procedure Wr(InPort: integer; InStr: string);

{***************************************************************************}

var

  Index: byte;

begin

  if InPort <> Displayed then

    exit;

  for Index := 1 to length(InStr) do

    if not(BeepOn) and (InStr[Index] = Beep) then

      write(QuietBeep)

    else

      write(InStr[Index]);

end;



Procedure WrL(InPort: integer; InStr: string);

{***************************************************************************}

begin

  Wr(InPort, InStr + Enter + CntrlEntr);

end;



{***************************************************************************}

{***************************************************************************}

{***************************************************************************}

begin

end.