(* Wait for caller.  This could totally be rewrote and be alot smaller *)
(* and faster.                                                         *)

Unit Wfc;
Interface
uses dos,crt,io,protcomm,records,genstr,detector,netmodem;
Function Wfcm:Byte;
Procedure Draw_Stats(Page : Byte);
Implementation

type wfcrec = record
     Filename : string[12];
     statsx   : byte;
     statsy   : byte;
     modemx   : byte;
     modemy   : byte;
     on       : array[1..13] of string[30];
     off      : array[1..13] of string[30];
     op       : array[1..13] of string[30];
     x        : byte;
     y        : byte;
     max      : byte;
     end;

var wfcinfo:wfcrec;

procedure decode(fn:string);
  var t  : text;
      x  : integer;
      y  : integer;
      c  : char;
      s  : string;

  begin
  assign(t,fn);
  reset(t);
  fillchar(wfcinfo,sizeof(wfcinfo),#0);
  readln(t,wfcinfo.filename);
  readln(t,wfcinfo.x);
  readln(T,wfcinfo.y);
  readln(t,wfcinfo.statsx);
  readln(t,wfcinfo.statsy);
  readln(t,wfcinfo.modemx);
  readln(t,wfcinfo.modemy);
  readln(t,wfcinfo.max);
  for x:=1 to wfcinfo.max do readln(t,wfcinfo.on[x]);
  for x:=1 to wfcinfo.max do readln(t,wfcinfo.off[x]);
  for x:=1 to wfcinfo.max do readln(t,wfcinfo.op[x]);
  close(t);
  end;

Procedure Get_The_Baud(s : String);
Const Bauds : Array[1..22] of String[6] =
 ('12000','75','160','300','1200','2400','4800','7200','9600','14400','16800',
  '19200','21600','24000','26400','28800','31600','32400','33600','38400',
  '57600','115200');
Var
 X      : Byte;
 Result : Integer;

Begin
 For X := 1 to 21 do
  If Pos(Bauds[X],S)    >0 then BASICMCI[5].STR := bauds[x];
  If Pos('ARQ',S)       >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' ARQ ';
  If Pos('MNP',S)       >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' MNP ';
  If Pos('HST',S)       >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' HST ';
  If Pos('ALT',S)       >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' ALT ';
  If Pos('HST',s)       >0 then BASICMCI[6].STR := BASICMCI[6].STR+' High Speed Technology ';
  If Pos('MNP 5',s)     >0 then BASICMCI[6].STR := BASICMCI[6].STR+' MNP 5 ';
  If Pos('LAP-M',S)     >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' LAP-M ';
  If Pos('LAPM',S)      >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' LAPM ';
  If Pos('V.42BIS',s)   >0 then BASICMCI[6].STR := BASICMCI[6].STR+' V42BIS ';
  If Pos('V.42bis',s)   >0 then BASICMCI[6].STR := BASICMCI[6].STR+' V42bis BLTZ ';
  If Pos('V42',S)       >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' V42 ';
  If Pos('V.42',S)      >0 Then BASICMCI[6].STR := BASICMCI[6].STR+' V42 ';
  If BASICMCI[6].STR = ''  then BASICMCI[6].STR := 'None';
  If BASICMCI[6].STR = ''  then BASICMCI[6].STR := 'None';
  If BASICMCI[6].STR = ''  then BASICMCI[6].STR := 'None';
End;

Procedure Lwritexy(X,Y:Byte;S:String);
Begin
crt.gotoxy(x,y);
pipewrite(s);
End;

procedure lprint(s:String);
begin;
pipewrite(s);
end;

Procedure Draw_Stats(Page : Byte);
Const Page1 : Array[1..3,1..7] of String[35] =
((   '|B0|05L|13ast |05U|13ser           ',
        '|05P|13osts |05M|13ade          ',
        '|05U|13ploads             ',
        '|05D|13ownloads           ',
        '|05F|13eedback            ',
        '|05F|13ile |05C|13redits        ',
        '|05U|13ser |05N|13ote           '),
 (   '|B0|05T|13otal |05U|13sers         ',
        '|05T|13odays |05C|13alls        ',
        '|05U|13ploads |05T|13oday       ',
        '|05D|13ownloads |05T|13oday     ',
        '|05E|13mail |05T|13oday         ',
        '|05F|13eedback |05T|13oday      ',
        '|05T|13ime |05U|13sed |05T|13oday     '),
 (   '|B0|05T|13otal |05C|13alls         ',
        '|05T|13otal |05U|13ploads       ',
        '|05T|13otal |05D|13ownloads     ',
        '|05T|13otal |05E|13mail |05S|13ent    ',
        '|05T|13otal |05M|13essages      ',
        '|05T|13otal |05F|13iles         ',
        '|05T|13otal |05U|13sers         '));

Var X,Y : Byte;
    temp: string[15];
Begin
 if (running=false) and (page=5) then page:=6; {this is so it wont show netmodem info}
 For Y := 9 to 17 do For X := 2 to 49 do lprintxy(X,Y,'|B0|15 ');
 If Page < 4 then For Y := 1 to 7 do begin
                                     crt.gotoxy(11,8+y);
                                     pipewrite(Page1[Page,Y]);
                                     end;
 TimeSlice;
 textcolor(15);
 Case Page of
  1 : Begin
       lprintxy(31,9,Stat.Last_Alias);
       lprintxy(31,10,Strr(Stat.Last_Posts));
       lprintxy(31,11,Strr(Stat.Last_Ups));
       lprintxy(31,12,Strr(Stat.Last_Downs));
       lprintxy(31,13,Strr(Stat.Last_Feed));
       lprintxy(31,14,Strr(Stat.Last_Credits));
       lprintxy(31,15,Stat.Last_Note);
      End;
 2 : Begin
       lprintxy(31,9,Strr(Stat.Total_Users));
       lprintxy(31,10,Strr(Stat.Today_Calls));
       lprintxy(31,11,Strr(Stat.Today_Ups));
       lprintxy(31,12,Strr(Stat.Today_Dwns));
       lprintxy(31,13,Strr(Stat.Today_Email));
       lprintxy(31,14,Strr(Stat.Today_Feed));
       lprintxy(31,15,Strr(Stat.Today_Time));
      End;
  3 : Begin
       lprintxy(31,9,Strr(Stat.Total_Calls));
       lprintxy(31,10,Strr(Stat.Total_Ups));
       lprintxy(31,11,Strr(Stat.Total_Downs));
       lprintxy(31,12,Strr(Stat.Total_Email));
       lprintxy(31,13,Strr(Stat.Total_Mesgs));
       lprintxy(31,14,Strr(Stat.Total_Files));
       lprintxy(31,15,Strr(Stat.Total_Users));
      End;
 4 : Begin
       crt.gotoxy(5,9);
       pipewrite('|B0|05S|13ystem |05S|13tats');
       crt.gotoxy(5,10);
       pipewrite('|B0|05O|13perating |05S|13ystem |15'+whatos+' '+whatver);
       crt.gotoxy(5,11);
       pipewrite('|B0|05P|13rocessor |15'+cputype);
       crt.gotoxy(5,12);
       pipewrite('|B0|05T|13otal |05D|13isk |05S|13ize ');
       write(disktotal);
       crt.gotoxy(5,13);
       pipewrite('|B0|05T|13otal |05D|13isk |05F|13ree ');
       write(diskfrees);
       crt.gotoxy(5,14);
       Pipewrite('|B0|05B|13ase |05R|13am ');
       write(totalbaseram,'k');
       crt.gotoxy(5,15);
       Pipewrite('|B0|05E|13xtended |05R|13am ');
       write(totalextram,'k');
       crt.gotoxy(5,16);
      End;
  5 : begin
      crt.gotoxy(5,9);
      Pipewrite('|B0|05N|13etmodem |05I|13nformation ');
      crt.gotoxy(5,11);
      pipewrite('|B0|05L|13ocal Host Name|15 '+isf.localhostname+#10#13);
      crt.gotoxy(5,12);
      temp:=isf.localip;
      pipewrite('|B0|05L|13ocal IP       |15 ');
      write(isf.localip);
      crt.gotoxy(5,13);
      pipewrite('|B0|05V|13ersion        |15 '+isf.version+#10#13);
      crt.gotoxy(5,14);
      pipewrite('|B0|05R|13egistered     |15 '+yn(isf.registered)+#10#13);
      end;
  6 : Begin
       crt.gotoxy(5,9);
       pipewrite('|B0|05L|13ucid |05B|13BS |15v1b  |05B|13y |08Judge Dredd');
       crt.gotoxy(5,10);
       pipewrite('|13ÄÄÄ-Ä|05ÄÄ--|08ÄÄ -   -');
       crt.gotoxy(5,12);
       pipewrite('|05T|13hanks |05g|13o |05o|13ut |05t|13o..');
       crt.gotoxy(5,13);
       pipewrite('|05B|13urning |05C|13hrome, |05K|13argus, |05K|13abal, |05S|13kaboy');
       crt.gotoxy(5,14);
       pipewrite('|05R|13aekwon, |05K|13rider, |05E|13sc, |05T|13he |05R|13eaper, |05M|13ag69');
       crt.gotoxy(5,15);
       pipewrite('|08http|05://|13home.fuse.net/kechesse');
       crt.gotoxy(5,16);
       pipewrite('|08kechesse|05@|13fuse.net');

      End;
 End;
End;

Function Wfcm:Byte;
Var C:Char;
Var Wfcpull: Record
     U     : Array[1..12] Of String[70];
     H     : Array[1..12] Of String[70];
     X,Y   : Array[1..12] Of 1..80;
     End;
     modemcount : byte;
     Counter    : Integer;
     X,Y        : Integer;
     Current    : 1..12;
     Last       : 1..12;
     Enter      : Boolean;
     Check      : String;
     Lx,Ly      : Byte;
     Done       : Boolean;
     pagecount  : longint;
     key        : boolean;
     ttt        : byte;
     ringr      : string;
     qc         : char;
     page       : Byte;
Begin
ringr:='';
Lx:=44;
Ly:=16;
Check:=#0;
Enter:=False;
Current:=1;
Last:=1;
Fillchar(Wfcpull,Sizeof(Wfcpull),#0);
Textcolor(15);
Textbackground(0);
Wfcpull.U[1]:=  '|15|B0 |09L|01ogin  |09L|01ocal ';
Wfcpull.U[2]:=  '|15|B0  |09E|01xit |09L|01ucid  ';
Wfcpull.U[3]:=  '|15|B0 |09S|01hell |09t|01o |09D|01os ';
Wfcpull.U[4]:=  '|15|B0 |09A|01nswer |09M|01odem ';
Wfcpull.U[5]:=  '|15|B0 |09H|01angUp |09M|01odem ';
Wfcpull.U[6]:=  '|15|B0 |09I|01nit.  |09M|01odem ';
Wfcpull.U[7]:=  '|15|B0  |09E|01dit |09M|01enus  ';
Wfcpull.U[8]:=  '|15|B0  |09E|01dit |09U|01sers  ';
Wfcpull.U[9]:=  '|15|B0 |09S|01ysOp |09E|01-Mail ';
Wfcpull.U[10]:= '|15|B0 |09D|01aily |09E|01vents ';
Wfcpull.U[11]:= '|15|B0 |09E|01dit |09S|01trings ';
Wfcpull.U[12]:= '|15|B0  |09S|01ysOp |09L|01ogs  ';

Wfcpull.H[1]:=  '|15|B7 |09L|01ogin  |09L|01ocal ';
Wfcpull.H[2]:=  '|15|B7  |09E|01xit |09L|01ucid  ';
Wfcpull.H[3]:=  '|15|B7 |09S|01hell |09t|01o |09D|01os ';
Wfcpull.H[4]:=  '|15|B7 |09A|01nswer |09M|01odem ';
Wfcpull.H[5]:=  '|15|B7 |09H|01angUp |09M|01odem ';
Wfcpull.H[6]:=  '|15|B7 |09I|01nit.  |09M|01odem ';
Wfcpull.H[7]:=  '|15|B7  |09E|01dit |09M|01enus  ';
Wfcpull.H[8]:=  '|15|B7  |09E|01dit |09U|01sers  ';
Wfcpull.H[9]:=  '|15|B7 |09S|01ysOp |09E|01-Mail ';
Wfcpull.H[10]:= '|15|B7 |09D|01aily |09E|01vents ';
Wfcpull.H[11]:= '|15|B7 |09E|01dit |09S|01trings ';
Wfcpull.H[12]:= '|15|B7  |09S|01ysOp |09L|01ogs  ';


For X:=1 To 12 Do Wfcpull.X[X]:=59;
For X:=1 To 12 Do Wfcpull.Y[X]:=10+X;
Textattr:=7;
Clrscr;
Displayadf('lucid.adf');

For X:=1 To 12 Do Lwritexy(Wfcpull.X[X],Wfcpull.Y[X],Wfcpull.U[X]);
Lwritexy(Wfcpull.X[1],Wfcpull.Y[1],Wfcpull.H[1]);
If Not(Carrier) Then Begin
                     Window(6,19,50,23);
                     sendinit(config.initstr+#13);
                     window(1,1,80,25);
                     End;
Done:=False;
C:=#0;
Current:=1;
pagecount:=0;
page:=1;
Draw_Stats(Page);
modemcount:=1;
key:=false;
ttt:=1;
InitMulti;
Repeat
  if config.changepage then begin
  inc(pagecount);
  crt.gotoxy(1,1);   {dunno why.. but fixs fuck up in counter}
  If pageCount = 80000 then
   Begin
    If Page < 5 then Inc(Page) else Page := 1;
    pagecount:= 0;
    Draw_Stats(Page);
   End;
   end;
If Dataavailable=True Then Begin
                           Textattr:=15;
                          Window(6,19,50,23);
                           crt.Gotoxy(Lx,Ly);
                           qc:=chr(getchar);
                           Write(qc);
                           Lx:=Wherex;
                           Ly:=Wherey;
                           Window(1,1,80,25);
                           ringr:=ringr+qc;
                           End;

If pos('RING',ringr)>0 Then Begin
                crt.Gotoxy(1,25);
                Lprint('Answering Call.  Stoping in ');
                sendinit(config.answerstr);
                Repeat
                If Dataavailable=True Then
                           Begin
                           Textattr:=15;
                           Window(6 ,19,50,23);
                           crt.Gotoxy(Lx,Ly);
                           Write(chr(Getchar));
                           Lx:=Wherex;
                           Ly:=Wherey;
                           Window(1,1,80,25);
                           End;
                crt.Gotoxy(29,25);
                write(modemcount,' seconds. ');
                Delay(1000);
                inc(modemcount);
                Until (protcomm.Carrier) Or (modemcount=30);

                If modemCount=30 Then Begin
                                   crt.gotoxy(1,25);
                                   textattr:=7;
                                   clreol;
                                   Delay(500);
                                   sendinit(config.initstr);
                                   Delay(500);
                                   Textattr:=7;
                                   Clrscr;
                                   Displayadf('lucid.adf');
                                   modemcount:=1;
                                   For X:=1 To 12 Do Lwritexy(Wfcpull.X[X],Wfcpull.Y[X],Wfcpull.U[X]);
                                   Lwritexy(Wfcpull.X[Current],Wfcpull.Y[Current],Wfcpull.H[Current]);
                                   End else


                If carrier Then Begin
                           Sound(220);        { Beep }
                           Delay(200);        { For 200 ms }
                           NoSound;           { Relief! }
                           Delay(1000);
                           Localon:=False;
                           Check:='';
                           Wfcm:=1;
                           Textattr:=15;
                           Window(6,19,50,23);
                                Repeat
                                crt.Gotoxy(Lx,Ly);
                                C:=chr(Getchar);
                                Write(C);
                                Lx:=Wherex;
                                Ly:=Wherey;
                                Check:=Check+C;
                                Until Dataavailable=False;
                                Get_The_Baud(Check);
                                Delay(1000);
                                Done:=True;
                                End;
                                Window(1,1,80,25);
                                End;
              c:=#0;
              if keypressed then c:=readkey;
              If C in [#9,#13,#27,#72,#80] Then Begin
              key:=false;
              If C=#13 Then Begin
                            Wfcm:=Current;
                            Repeat
                            Getchar;
                            Until Dataavailable=False;
                            Exit;
                            End;
              if c=#9 then begin
                           If Page < 6 then Inc(Page) else Page := 1;
                           draw_Stats(page);
                           end;
              Lwritexy(Wfcpull.X[Current],Wfcpull.Y[Current],Wfcpull.U[Current]);
              If C=#72 Then Dec(Current);
              If Current=0 Then Current:=12;
              If C=#80 Then Inc(Current);
              If Current=13 Then Current:=1;
              Lwritexy(Wfcpull.X[Current],Wfcpull.Y[Current],Wfcpull.H[Current]);
              Textattr:=7;
{              page:=1;}
              End;


Until Done;
{Showcursor;}
End;

End.
























