home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / DANUTILS.ZIP / WARDIAL.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1987-02-14  |  33.9 KB  |  1,354 lines

  1.  
  2. {                         Wardial 1.1 By Jim Everingham
  3.                           ------------------------------
  4.        This Program is released to public domain by Jim Everingham. It
  5.        May be distributed and modified at will.  This program utilizes
  6.        the commcall routines by Allen Bishop.  I have not cleaned up
  7.        this source code, so it may seem a bit messy.  It can be shortened
  8.        substantially if given a little time. Any questions can be sent
  9.        to:
  10.                               Jim Everingham
  11.                               215 West Fairmount Ave
  12.                               Apt 306 Fairmount Hills
  13.                               State College, Pa 16801
  14. }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. {$C-}
  26. Procedure wardial;forward;
  27. Procedure menu;forward;
  28. Procedure Set_modem_parameters;forward;
  29. Procedure beep; forward;
  30.  
  31. const
  32.    Windows    = 5;
  33.    Wtab       : array[1..Windows,1..5] of Integer
  34.                 = (( 5,  2,  75, 10,  1),
  35.                    ( 5,  14,  33, 23,  1),
  36.                    ( 46, 14,  75, 23,  1),
  37.                    ( 5,  23,  75, 24, 1),
  38.                    ( 1,  1,   80, 21, 1)
  39.                   );
  40.    recv_buf_size = 4096;   {Recieve buffer size, can be changed}
  41.  
  42. type buffer_pointer   = integer;
  43.      smallstring      = string[2];
  44.      bigstring        = string[255];
  45.      storage          = byte;
  46.      check_bit        = (none,even);
  47.      sd = string[40];
  48.      st = string[8];
  49.      string255=string[255];
  50.  
  51.  
  52. var leave                 : boolean;  {end of routine marker}
  53.     buf_start, buf_end    : buffer_pointer;
  54.     stop_time             : sd;
  55.     recv_buffer           : array [1..recv_buf_size] of storage;
  56.     speed                 : integer;
  57.     Service_number, Checksum_number,code: sd;
  58.     dbits                 : integer;
  59.     stop_bits             : integer;
  60.     parity                : check_bit;
  61.     code_found            : array[1..20] of sd;
  62.     zz,code_length        : integer;
  63.     ch                    : char;
  64.     ii                    : integer;
  65.     Xon,Xoff              : char;
  66.     screen1               : Array[1..4000] of byte absolute $B800:$0000;
  67.     screen2               : Array[1..4000] of byte;
  68.     Xcoord,ycoord,x2,y2   : Integer;
  69.     Dial_Speed,Dial_type,Speaker,Duplex,Command_echo,Response_time:sd;
  70.     maincolor             : integer;
  71.     Print_stat            : boolean;
  72.     Printer               : boolean;
  73.     Dial_command,Pause_command:string[20];
  74.  
  75. Procedure init_screen;
  76. begin
  77. lowvideo;
  78. window(1,1,80,25);
  79. clrscr;
  80. end;
  81.  
  82.  
  83. function time2 : st;
  84. type
  85.   registors = record
  86.               ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  87.               end;
  88. var
  89.   regisrec               : registors;
  90.   hour , minute , second : string[2];
  91.   cx , dx                : integer;
  92. begin
  93.   with regisrec do
  94.   begin
  95.     ax := $2C shl 8;
  96.   end;
  97.   msdos(regisrec);
  98.   with regisrec do
  99.   begin
  100.     str(cx shr 8 , hour);
  101.     str(cx mod 256 , minute);
  102.     str(dx shr 8 , second);
  103.   end;
  104.   if length(hour  ) = 1 then insert('0',hour  ,1);
  105.   if length(minute) = 1 then insert('0',minute,1);
  106.   if length(second) = 1 then insert('0',second,1);
  107.   time2:= hour + ':' + minute + ':' + second
  108. end;
  109.  
  110.  
  111.  
  112. function time : st;
  113. type
  114.   registors = record
  115.               ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  116.               end;
  117. var
  118.   regisrec               : registors;
  119.   hour , minute , second : string[2];
  120.   cx , dx                : integer;
  121. begin
  122.   with regisrec do
  123.   begin
  124.     ax := $2C shl 8;
  125.   end;
  126.   msdos(regisrec);
  127.   with regisrec do
  128.   begin
  129.     str(cx shr 8 , hour);
  130.     str(cx mod 256 , minute);
  131.     str(dx shr 8 , second);
  132.   end;
  133.   if length(hour  ) = 1 then insert(' ',hour  ,1);
  134.   if length(minute) = 1 then insert('0',minute,1);
  135.   if length(second) = 1 then insert('0',second,1);
  136.   time := minute + second
  137. end;
  138.  
  139.  
  140.  
  141. procedure check_range(var range : integer);
  142. begin
  143.  if range > recv_buf_size then range := 1;
  144. end;
  145.  
  146. function commpressed : boolean;
  147. begin
  148.  commpressed := (buf_start <> buf_end);
  149. end;
  150.  
  151. function cinkey : smallstring;
  152. var result : smallstring;
  153.     temp   : integer;
  154. begin
  155.  if not commpressed then result := ''
  156.  else
  157.  begin
  158.   inline ($FA);  {very important}
  159.   temp := recv_buffer[buf_start];
  160.   buf_start := buf_start +1;
  161.   check_range(buf_start);
  162.   inline ($FB);  {very important}
  163.   result := chr(temp);
  164.  end;
  165.  cinkey := result;
  166. end;
  167.  
  168.  
  169. function carrier : boolean;
  170. begin
  171.  carrier := odd(port[$3FE] shr 7);
  172. end;
  173.  
  174. procedure set_up_recv_buffer;
  175. begin
  176.  buf_start := 1;
  177.  buf_end   := 1;
  178. end;
  179.  
  180. procedure set_baud(rate : integer);
  181. var a : byte;
  182.     divided : real;
  183. begin
  184.  if rate<=9600 then
  185.  begin
  186.   speed := rate;
  187.   divided := 115200.0/rate;
  188.   rate := trunc(divided);
  189.   a := port[$3fb];
  190.   if a < 128 then a := a+128;
  191.   port[$3fb] := a;
  192.   port[$3f8] := lo(rate);
  193.   port[$3f9] := hi(rate);
  194.   port[$3fb] := a-128;
  195.  end;
  196. end;
  197.  
  198. procedure update_uart;
  199. var a : byte;
  200. begin
  201.  a := dbits-5;
  202.  if stop_bits = 2 then a := a + 4;
  203.  if parity = even then a := a + 24;
  204.  port[$3fb] := a;
  205. end;
  206.  
  207.  
  208. procedure init_port;
  209. var a,b : integer;
  210.     buf_len : integer;
  211. begin
  212.  update_uart;
  213.  port[$3f9] := 1;             {interupt enable}
  214.  a := port[$3fc];
  215.  if odd(a) then a := 1 else a := 0;   {keep terminal ready}
  216.  a := a+10;
  217.  port[$3fc] := a;                     {turn on req to send and out2}
  218.  a := port[$3fa];
  219.  port[$21]  := $c;
  220.  set_baud(speed);
  221.  buf_len := recv_buf_size;
  222.  
  223.  {this is the background routine}
  224.  
  225.  inline (
  226.   $1E/
  227.   $0E/
  228.   $1F/
  229.   $BA/*+23/
  230.   $B8/$0C/$25/
  231.   $CD/$21/
  232.   $8B/$BE/BUF_LEN/
  233.   $89/$3E/*+87/
  234.   $1F/
  235.   $2E/$8C/$1E/*+83/
  236.   $EB/$51/
  237.   $FB/
  238.   $1E/
  239.   $50/
  240.   $53/
  241.   $52/
  242.   $56/
  243.   $2E/$8E/$1E/*+70/
  244.   $BA/$F8/$03/
  245.   $EC/
  246.   $BE/RECV_BUFFER/
  247.   $8B/$1E/BUF_END/
  248.   $88/$40/$FF/
  249.   $43/
  250.   $E8/$22/$00/
  251.   $89/$1E/BUF_END/
  252.   $3B/$1E/BUF_START/
  253.   $75/$0C/
  254.   $8B/$1E/BUF_START/
  255.   $43/
  256.   $E8/$10/$00/
  257.   $89/$1E/BUF_START/
  258.   $BA/$20/$00/
  259.   $B0/$20/
  260.   $EE/
  261.   $5E/
  262.   $5A/
  263.   $5B/
  264.   $58/
  265.   $1F/
  266.   $CF/
  267.   $2E/$8B/$16/*+11/
  268.   $42/
  269.   $39/$DA/
  270.   $75/$03/
  271.   $BB/$01/$00/
  272.   $C3/
  273.   $00/$00/
  274.   $00/$01/
  275.   $90
  276.  );
  277. end;
  278.  
  279. procedure term_ready(state : boolean);
  280. var a : byte;
  281. begin
  282.  a := port[$3fc];
  283.  if odd(a) then a := a - 1;
  284.  a := a + ord(state);
  285.  port[$3fc] := a;
  286. end;
  287.  
  288. procedure remove_port;
  289. var a : byte;
  290. begin
  291.  port[$3f9] := 0;
  292.  a := port[$3fc];
  293.  if odd(a) then a := 1 else a := 0;
  294.  port[$3fc] := a;
  295.  port[$21]  := $BC;
  296. end;
  297.  
  298. procedure write_byte(to_send : bigstring);
  299. var a,b,c : byte;
  300. begin
  301.  for b := 1 to length(to_send) do
  302.  begin
  303.   c := ord(to_send[b]);
  304.   repeat a := port[$3fd];
  305.   until odd(a shr 5);
  306.   port[$3f8] := c;
  307.  end;
  308. end;
  309.  
  310.    procedure Frame(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY: Integer);
  311.    var
  312.       i: Integer;
  313.    begin
  314.       GotoXY(UpperLeftX, UpperLeftY);  Write(chr(201));
  315.       for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  316.       Write(chr(187));
  317.       for i:=UpperLeftY+1 to LowerRightY-1 do
  318.       begin
  319.          GotoXY(UpperLeftX , i);  Write(chr(186));
  320.          GotoXY(LowerRightX, i);  Write(chr(186));
  321.       end;
  322.       GotoXY(UpperLeftX, LowerRightY);
  323.       Write(chr(200));
  324.       for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  325.       Write(chr(188));
  326.    end  { Frame };
  327.  
  328. {$I Send_asc.pas}
  329. {$I Rcv_asc.pas}
  330.  
  331. procedure break;
  332. var a,b : byte;
  333. begin
  334.  a := port[$3fb];
  335.  b := a;
  336.  if b > 127 then b := b - 128;
  337.  if b <= 63 then b := b + 64;
  338.  port[$3fb] := b;
  339.  delay(400);
  340.  port[$3fb] := a;
  341. end;
  342.  
  343. procedure setup;
  344. var a : byte;
  345. begin
  346.  dbits        := 8;
  347.  parity       := none;
  348.  stop_bits    := 1;
  349.  speed        := 1200;
  350.  init_port;
  351.  term_ready(true);
  352. end;
  353.  
  354. Procedure Help_wardial;
  355. var a:char;
  356. begin
  357.      write_byte(chr(13));
  358.      xcoord:=wherex;
  359.      ycoord:=wherey;
  360.      move(screen1,screen2,4000);
  361.      normvideo;
  362.      lowvideo;
  363.      window(1,1,80,25);
  364.      normvideo;
  365.      textcolor(12);
  366.      frame(24,9,56,21);
  367.      lowvideo;
  368.      window(25,10,55,20);
  369.      textcolor(15);
  370.      clrscr;
  371.      gotoxy(10,1);
  372.      writeln('Help Menu');
  373.      gotoxy(1,3);
  374.      textcolor(7);
  375.      writeln('  <Alt-P>  Toggle Printer ');
  376.      writeln('  <Alt-M>  Set Modem Params');
  377.      writeln('  <Alt-X>  Exit to Menu');
  378.      gotoxy(1,10);
  379.      textcolor(white+blink);
  380.      writeln('        Hit any Key');
  381.      repeat until keypressed;
  382.      normvideo;
  383.      lowvideo;
  384.      window(1,1,80,25);
  385.      normvideo;
  386.      textcolor(12);
  387.      move(screen2,screen1,4000);
  388.      window(5,14,33,23);
  389.      gotoxy(xcoord,ycoord);
  390. end;
  391.  
  392.  
  393.  
  394. Procedure beep;
  395. begin
  396.      sound(1500);
  397.      delay(100);
  398.      nosound;
  399. end;
  400.  
  401.  
  402.    procedure SelectWindow(Win: Integer);
  403.    begin
  404.       Window(Wtab[Win,1], Wtab[Win,2], Wtab[Win,3], Wtab[Win,4])
  405.    end  { SelectWindow };
  406.  
  407. Procedure Toggle_printer;
  408. var b,temp:sd;
  409. begin
  410. beep;
  411. if Print_stat then
  412.      begin
  413.            Print_stat:=false;
  414.            write(lst,chr(12));
  415.      end
  416. else
  417.     begin
  418.          b:=service_number;
  419.          write(lst,'WARDIAL 1.1':25,'SEARCHING:':30);
  420.          if copy(b,5,1)='1' then temp:=copy(b,5,1)+'-'
  421.          else temp:=copy(b,5,3)+'-';
  422.          if copy(b,6,3)='800' then temp:=temp+'800-'+copy(b,9,3)+'-'+copy(b,12,4)
  423.          else temp:=copy(b,6,3)+'-'+copy(b,9,4);
  424.          write(lst,temp);
  425.          writeln(lst);
  426.          Print_stat:=true;
  427.          writeln(lst);
  428.          writeln(lst,'Code Number':12,'Code':12);
  429.          writeln(lst);
  430.     end;
  431. end;
  432.  
  433. Procedure Toggle3_printer;
  434. var b,temp:sd;
  435. begin
  436. beep;
  437. if Print_stat then
  438.      begin
  439.            Print_stat:=false;
  440.            write(lst,chr(12));
  441.      end
  442. else
  443.     begin
  444.          writeln(lst,'WARDIAL 1.1':25,'SEARCHING FOR CARRIERS':30);
  445.          writeln(lst);
  446.          Print_stat:=true;
  447.          writeln(lst);
  448.          writeln(lst,'Carriers at':10);
  449.          writeln(lst);
  450.     end;
  451. end;
  452.  
  453. Procedure All_codes;
  454. var k:integer;
  455. begin
  456. if zz>0 then
  457.       begin
  458.            Normvideo;
  459.            lowvideo;
  460.            window(1,1,80,25);
  461.            normvideo;
  462.            textcolor(12);
  463.            Frame(9,3,21,20);
  464.            lowvideo;
  465.            textcolor(7);
  466.            window(10,4,20,19);
  467.            ClrScr;
  468.            gotoxy(1,15);
  469.            textcolor(7);
  470.            for k:=1 to zz do
  471.                begin
  472.                     writeln(code_found[k]:8);
  473.                     if k=13 then
  474.                              begin
  475.                                   textcolor(white+blink);
  476.                                   write(' Hit a Key');
  477.                                   repeat until keypressed;
  478.                                   textcolor(7);
  479.                              end;
  480.                     insline;
  481.                end;
  482.          textcolor(white+blink);
  483.          write(' Hit a Key');
  484.          repeat until keypressed;
  485.     end;
  486. end;
  487.  
  488.  
  489. Procedure test_carrier(var test:boolean; code:sd; timing_constant:integer);
  490. var i,j,k,result: integer;
  491.               cr: char;
  492. begin
  493.      val(time,i,result);
  494.      j:=i+timing_constant;
  495.      while (j>i) do
  496.            begin
  497.            val(time,i,result);
  498.            if carrier then
  499.               begin
  500.               zz:=zz+1;
  501.               code_found[zz]:=code;
  502.               textcolor(white+blink);
  503.               write('Code Found!');
  504.               sound(1000);
  505.               delay(500);
  506.               nosound;
  507.               if Print_stat then  writeln(lst,zz:6,code:20);
  508.               write_byte('+++');
  509.               delay (3000);
  510.               Write_byte('ATH0');
  511.               j:=i-26;
  512.               end;
  513.            if keypressed then
  514.               begin
  515.                    read(kbd,cr);
  516.                    if cr=chr(25) then toggle_printer else
  517.                    if cr=chr(35) then Help_wardial else
  518.                    if cr=chr(50) then begin
  519.                                            set_modem_parameters;
  520.                                            gotoxy(xcoord,ycoord);
  521.                                            end
  522.                                       else
  523.                    if cr=chr(45) then
  524.                       begin
  525.                          j:=i-26;
  526.                          test:=true;
  527.                          All_codes;
  528.                          end;
  529.                       end;
  530.            end;
  531. write_byte('-');
  532. write_byte(chr(13));
  533. for i:=1 to maxint do ;;
  534. end;
  535.  
  536. Procedure Send_code(service_number,code,checksum_number:sd);
  537. var i,j: integer;
  538. outword:sd;
  539. begin
  540. outword:=service_number+code+checksum_number+chr(13);
  541. Lowvideo;
  542. selectwindow(2);
  543. gotoxy(1,1);
  544. insline;
  545. textcolor(12);
  546. writeln;
  547. write('   TRYING: ',code);
  548. normvideo;
  549. write_byte(outword);
  550. end;
  551.  
  552. Procedure write_codes;
  553. var i:integer;
  554. begin
  555. lowvideo;
  556. selectwindow(3);
  557. gotoxy(1,1);
  558. CLrScr;
  559. textcolor(12);
  560. if zz=0 then writeln('   NO CODES')
  561. else for i:=1 to zz do writeln('  CODE AT: ',code_found[i]);
  562. normvideo;
  563. end;
  564.  
  565.  
  566. Procedure Get_code(var code:sd);
  567. var i,j: integer;
  568. a,b: sd;
  569. begin
  570.      repeat
  571.            i:=random(999)
  572.      until i > 100;
  573.      str(i,a);
  574.      if code_length > 5 then
  575.               begin
  576.                    i:=random(9);
  577.                    str(i,b);
  578.                    a:=a+b;
  579.               end;
  580.      if code_length > 6 then
  581.               begin
  582.                    i:=random(9);
  583.                    str(i,b);
  584.                    a:=a+b;
  585.               end;
  586.  
  587.      if code_length > 7 then
  588.               begin
  589.                    i:=random(9);
  590.                    str(i,b);
  591.                    a:=a+b;
  592.               end;
  593.      i:=random(9);
  594.      str(i,b);
  595.      code:='1'+a+b;
  596. end;
  597.  
  598. Procedure help;
  599. begin
  600. xcoord:=whereX;
  601. ycoord:=wherey;
  602. move (screen1,screen2,4000);
  603. textcolor(lightblue);
  604. frame(45,1,75,16);
  605. lowvideo;
  606. window(46,2,74,15);
  607. textcolor(15);
  608. clrscr;
  609. gotoxy(1,1);
  610. writeln('        Help Menu');
  611. textcolor(7);writeln;
  612. writeln(' <Alt-Y>  Displays menu');
  613. writeln(' <Alt-P>  To set Parameters');
  614. writeln(' <Alt-E>  To Toggle Echo');
  615. writeln(' <Alt-Q>  Returns to menu');
  616. Writeln(' <Alt-O>  Hangs up Modem');
  617. writeln(' <Alt-A>  Modem Parameters');
  618. writeln(' <Alt-S>  Send Ascii File');
  619. writeln(' <Alt-R>  Recieve file Ascii');
  620. writeln(' <Alt-W>  Dial Number ');
  621. gotoxy(1,14);
  622. textcolor(white+blink);
  623. write('      Press Any Key');
  624. repeat until keypressed;
  625. normvideo;
  626. lowvideo;
  627. selectwindow(5);
  628. textcolor(lightcyan);
  629. move(screen2,screen1,4000);
  630. gotoxy(xcoord,ycoord);
  631. end;
  632.  
  633.  
  634. Procedure Set_parameters;
  635. var temp: sd;
  636. result:integer;
  637. begin
  638. xcoord:=whereX;
  639. ycoord:=whereY;
  640. move (screen1,screen2, 4000);
  641. textcolor(lightblue);
  642. frame(10,5,65,15);
  643. lowvideo;
  644. window(11,6,64,14);
  645. writeln;
  646. normvideo;
  647. clrscr;
  648. gotoxy(1,2);
  649. if parity=even then temp:='Even' else temp:='None';
  650. textcolor(7);
  651. writeln('   Current Parameters: ',Speed:4,'-',Stop_bits:2,'-',temp:5,'-',Dbits:2 );writeln;
  652. write('   Enter Baud      : ');readln(temp);
  653. if length(temp)>1 then val(temp,speed,result);
  654. write('   Enter Stop bits : ');readln(temp);
  655. if length(temp)>0 then val(temp,stop_bits,result);
  656. write('   Parity <E>ven <N>one : ');readln(temp);
  657. if length(temp) >0 then if (copy(temp,1,1)='E') or (copy(temp,1,1)='e') then parity:=even
  658. else parity:=none;
  659. write('   Enter Data bits : ');readln(temp);
  660. if length(temp)>0 then val(temp,dbits,result);
  661. init_port;
  662. textcolor(lightcyan);
  663. lowvideo;
  664. selectwindow(5);
  665. move (screen2,screen1, 4000);
  666. gotoxy(Xcoord,Ycoord);
  667. end;
  668.  
  669. Procedure Set_Modem_Parameters;
  670. var temp:sd;
  671. begin
  672. write_byte(chr(13));
  673. xcoord:=wherex;
  674. ycoord:=wherey;
  675. move (screen1,screen2,4000);
  676. NormVideo;
  677. lowvideo;
  678. window(1,1,80,25);
  679. Normvideo;
  680. Textcolor(blue);
  681. frame(40,1,75,11);
  682. LowVideo;
  683. window(41,2,74,10);
  684. Clrscr;
  685. gotoxy(1,1);
  686. textcolor(white);
  687. writeln('          Modem Pameters');
  688. gotoxy(1,3);
  689. textcolor(7);
  690. Writeln('      Dial Speed     ',Dial_speed:3,': ');
  691. Writeln('      <P>ulse <T>one ',Dial_type:3,': ');
  692. if Speaker='M0' then temp:='OFF' else temp:='ON';
  693. writeln('      Speaker        ',Temp:3,': ');
  694. if Duplex='F0' then temp:='HALF' else Temp:='FULL';
  695. writeln('      Duplex is     ',temp:4,': ');
  696. if Command_echo='E0' then temp:='OFF' else temp:='ON';
  697. writeln('      Command Echo   ',temp:3,': ');
  698. writeln('      Response Time  ',Response_time:3,': ');
  699. gotoxy(1,10);
  700. textcolor(white+blink);
  701. write('           Enter Values');
  702. textcolor(7);
  703. gotoxy(27,3);readln(temp);
  704. if length(temp) > 1 then Dial_speed:=temp;
  705. gotoxy(27,4);readln(temp);
  706. if length(temp) > 0 then dial_type:=upcase(copy(temp,1,1));
  707. gotoxy(27,5);readln(temp);
  708. if length(temp) > 0 then if (temp='Off') or (temp='off') or (temp='OFF') then Speaker:='M0';
  709. gotoxy(27,6);readln(temp);
  710. if length(temp) > 0 then if Upcase(copy(temp,1,1))='H' then Duplex:='F0';
  711. gotoxy(27,7);readln(temp);
  712. if length(temp) > 0 then if (temp='Off') or (temp='off') or (temp='OFF') then Command_echo:='E0';
  713. gotoxy(27,8);readln(temp);
  714. if length(temp) > 0 then response_time:=temp;
  715. gotoxy(1,10);textcolor(lightcyan+blink);
  716. write('      Please Wait: Working');
  717. if carrier then write_byte('+++');
  718. delay(2000);
  719. temp:='ATS11='+dial_speed+chr(13);write_byte(temp);delay(1000);
  720. temp:='AT'+Speaker+chr(13);write_byte(temp);delay(1000);
  721. temp:='AT'+Duplex+chr(13);write_byte(temp);delay(1000);
  722. temp:='AT'+Command_echo+chr(13);write_byte(temp);delay(1000);
  723. temp:='ATS9='+response_time+chr(13);write_byte(temp);delay(1000);
  724. if carrier then write_byte('ATA');write_byte(chr(13));beep;beep;
  725. normvideo;
  726. lowvideo;
  727. window(1,1,80,25);
  728. move(screen2,screen1,4000);
  729. textcolor(maincolor);
  730. end;
  731.  
  732.  
  733.  
  734.  
  735. Procedure Hang_up;
  736. var i,j:integer;
  737. begin
  738. Sound(500);
  739. delay(100);
  740. nosound;
  741. write_byte('+++');
  742. delay (3000);
  743. Write_byte('ATH0');
  744. Write_byte(chr(13));
  745. sound(500);
  746. delay(100);
  747. nosound;
  748. Delay(200);
  749. sound(500);
  750. delay(100);
  751. nosound;
  752. end;
  753.  
  754.  
  755. Procedure Sequential_dial;
  756. var prefix,temp,start_pos,end_pos,t2:sd;
  757.     a,b,c,i,j,k,timing_Constant:integer;
  758.     dial_stop:boolean;
  759.     ab:char;
  760. begin
  761.       NormVideo;
  762.       Lowvideo;
  763.       window(1,1,80,25);
  764.       normvideo;
  765.       clrscr;
  766.       textcolor(12);
  767.       frame(5,2,75,6);
  768.       textcolor(11);
  769.       frame(5,8,75,21);
  770.       gotoxy(7,4);
  771.       textcolor(15);
  772.       Write('                  Wardial 1.1       Sequential dialer');
  773.       lowvideo;
  774.       window(6,9,73,19);
  775.       gotoxy(1,3);
  776.       textcolor(12);
  777.       Writeln('  Set Paramters');
  778.       textcolor(cyan);
  779.       writeln;
  780.       write('  Enter Prefix to dial : ');
  781.       textcolor(11);
  782.       readln(prefix);
  783.       textcolor(cyan);
  784.       write('  Starting At (XXXX)   : ');
  785.       textcolor(11);
  786.       readln(Start_pos);
  787.       zz:=0;
  788.       textcolor(cyan);
  789.       write('  Ending At   (XXXX)   : ');
  790.       textcolor(11);
  791.       readln(End_pos);
  792.       textcolor(cyan);
  793.       write('  Timing Constant      : ');
  794.       textcolor(11);
  795.       readln(temp);
  796.       if length(temp)>0 then val(temp,timing_constant,i) else timing_constant:=14;
  797.       writeln;
  798.       textcolor(7);
  799.       write('  <');textcolor(white);write('Alt-H');textcolor(7);write('> For Help Menu');
  800.       val(start_pos,a,i);
  801.       val(end_pos,b,i);
  802.       dial_stop:=false;
  803.       gotoxy(48,3);
  804.       textcolor(11);
  805.       zz:=0;
  806.       write(' Status');
  807.       repeat
  808.             temp:='';
  809.             start_pos:='';
  810.             if a<9 then temp:='000';
  811.             if (a<99) and (a>9) then temp:='00';
  812.             if (a<999) and (a>99) then temp:='0';
  813.             str(a,start_pos);
  814.             t2:=temp+start_pos;
  815.             write_byte(chr(13));
  816.             delay(1000);
  817.             temp:=Dial_command+Prefix+t2+chr(13);
  818.             write_byte(temp);
  819.             gotoxy(48,5);
  820.             textcolor(cyan);
  821.             write('Dialing: ');textcolor(white);write(Prefix);
  822.             textcolor(12);write('-');textcolor(white);write(t2);
  823.             textcolor(cyan);
  824.             gotoxy(48,7);
  825.             write('Codes Found: ');
  826.             textcolor(white);
  827.             write(zz);
  828.             textcolor(cyan);
  829.             gotoxy(48,9);
  830.             if zz>0 then write('Last found:',code_found[zz],'    ') else write('Last found: None');
  831.             val(time,i,j);
  832.             j:=i+timing_constant;
  833.             repeat
  834.                   if carrier then
  835.                              begin
  836.                                   zz:=zz+1;
  837.                                   code_found[zz]:=prefix+'-'+t2;
  838.                                   if print_stat then write(lst,code_found[zz]:10);
  839.                                   hang_up;
  840.                                   j:=i-26;
  841.                                   Beep;
  842.                              end;
  843.                    val(time,i,k);
  844.                    if keypressed then
  845.                              begin
  846.                                   write_byte(chr(13));
  847.                                   read(kbd,ab);
  848.                                   if ab=chr(45) then
  849.                                               begin
  850.                                                     all_codes;
  851.                                                     menu;
  852.                                               end;
  853.                                   if ab=chr(50) then
  854.                                      begin
  855.                                           set_modem_parameters;
  856.                                           normvideo;
  857.                                           lowvideo;
  858.                                           window(1,1,80,25);
  859.                                           normvideo;
  860.                                           lowvideo;
  861.                                           window(6,9,73,19);
  862.                                       end;
  863.                                   if ab=chr(35) then
  864.                                      begin
  865.                                           help_wardial;
  866.                                           normvideo;
  867.                                           lowvideo;
  868.                                           window(1,1,80,25);
  869.                                           normvideo;
  870.                                           lowvideo;
  871.                                           window(6,9,73,19);
  872.                                      end;
  873.                                   if ab=chr(25) then toggle3_printer;
  874.                              end;
  875.             until i>j;
  876.       a:=a+1;
  877.       until dial_stop or (a>b);
  878.       beep;delay(1000);beep;delay(1000);beep;delay(1000);
  879.       write_byte(chr(13));
  880.       if zz>0 then all_codes;
  881.       menu;
  882. end;
  883.  
  884. Procedure Write_Status;
  885. var strg,strg2:sd;
  886. begin
  887. x2:=wherex;
  888. y2:=wherey;
  889. NormVideo;
  890. SelectWindow(4);
  891. gotoxy(1,1);
  892. if parity=none then strg:='None' else strg:='Even';
  893. textcolor(7);
  894. write(' Terminal Mode  ',speed:4,'-',strg:4,'-',Dbits:1,'-',Stop_bits:1,'                         <Alt-Y> for Help');
  895. NormVideo;
  896. Lowvideo;
  897. SelectWindow(5);
  898. gotoxy(x2,y2);
  899. end;
  900.  
  901.  
  902.  
  903. Procedure redial;
  904. var number,t,number_to_dial:sd;
  905.     i,j,k,l:integer;
  906.     leave:boolean;
  907. begin
  908. xcoord:=wherex;
  909. ycoord:=wherey;
  910. move(screen1,screen2,4000);
  911. Normvideo;
  912. lowvideo;
  913. window(1,1,80,25);
  914. normvideo;
  915. textcolor(3);
  916. frame(40,5,65,15);
  917. lowvideo;
  918. window(41,6,64,14);
  919. clrscr;
  920. gotoxy(1,1);
  921. textcolor(white);
  922. writeln('   Redial Number');
  923. textcolor(7);
  924. writeln;
  925. writeln(' Enter Number dial');
  926. write(' > ');
  927. readln(number);
  928. if length(number)>0 then
  929.         begin
  930.         textcolor(white+blink);
  931.         gotoxy(1,8);write(' ',chr(16));
  932.         textcolor(7);write('      Dialing      ');
  933.         textcolor(white+blink);write(chr(17));
  934.         leave:=false;
  935.         number_to_dial:=Dial_command+dial_type+number+chr(13);
  936.         repeat
  937.               if keypressed then leave:=true;
  938.               val(time,j,k);
  939.               i:=j+27;
  940.               write_byte(Number_to_dial);
  941.               repeat
  942.                     if carrier then
  943.                           begin
  944.                                leave:=true;
  945.                                i:=j-1;
  946.                                beep;beep;beep;
  947.                           end;
  948.                     val(time,j,k);
  949.                     if keypressed then leave:=true;
  950.               until  (j>i) or leave;
  951.         until leave;
  952.         end;
  953.         Normvideo;
  954.         lowvideo;
  955.         window(1,1,80,21);
  956.         move(screen2,screen1,4000);
  957.         set_up_recv_buffer;
  958.         gotoxy(xcoord,ycoord);
  959.         textcolor(maincolor);
  960. end;
  961.  
  962. Procedure Terminal;
  963. var leave, echo : boolean;
  964.     a     : char;
  965.     b     : smallstring;
  966.     strg,prt:sd;
  967.     tempbuf:string[81];
  968.     bufpoint,i:integer;
  969.  
  970. begin
  971.  Init_screen;
  972.  Clrscr;
  973.  textcolor(12);
  974.  frame(wtab[4,1]-1,wtab[4,2]-1,wtab[4,3]+1,wtab[4,4]);
  975.  lowvideo;
  976.  selectWindow(4);
  977.  gotoxy(1,1);
  978.  maincolor:=11;
  979.  if parity=none then strg:='None' else strg:='Even';
  980.  textcolor(7);
  981.  if printer then prt:='ON'else Prt:='OFF';
  982.  write(' Terminal Mode  ',speed:4,'-',strg:4,'-',Dbits:1,'-',Stop_bits:1,'                        <Alt-Y> for Help');
  983.  normvideo;
  984.  lowvideo;
  985.  textcolor(lightcyan);
  986.  selectWindow(5);
  987.  gotoxy(1,1);
  988.  bufpoint:=1;
  989.  init_port;
  990.  tempbuf:='';
  991.  writeln('Terminal ready. <Alt-Y> for Menu. <Alt-P> for Parameters.');
  992.  beep;
  993.  echo:=false;
  994.  set_up_recv_buffer;
  995.  leave := false;
  996.  while not leave do
  997.  begin
  998.   if keypressed then
  999.   begin
  1000.    repeat read(kbd,a) until a <> chr(27);
  1001.       i:=ord(a);
  1002.       case i of
  1003.           30:begin
  1004.                        Set_modem_parameters;
  1005.                        Selectwindow(5);
  1006.                   end;
  1007.           17:redial;
  1008.           19:rcv_asc;
  1009.           31:Send_asc;
  1010.           24:hang_up;
  1011.           21:help;
  1012.           16:Menu;
  1013.           27:break;
  1014.           25:begin
  1015.                        Set_parameters;
  1016.                        Write_status;
  1017.                        Textcolor(11);
  1018.                   end;
  1019.           end;
  1020.    if (a = chr(18)) and echo then
  1021.           begin
  1022.               echo:=false;
  1023.               beep;
  1024.           end
  1025.    else
  1026.    if (a = chr(18)) and not echo then
  1027.          begin
  1028.               writeln;Writeln('Echo On.');
  1029.               echo:=true;
  1030.               beep;
  1031.          end
  1032.   else
  1033.   if (a<chr(15)) or (a>chr(31)) then
  1034.        begin
  1035.           if echo then write(a);
  1036.           write_byte(a);
  1037.        end;
  1038.   end;
  1039.   if commpressed then write(cinkey);
  1040.  end;
  1041. end;
  1042.  
  1043.  
  1044. Procedure Menu;
  1045. var i:integer;
  1046.     cr:char;
  1047. begin
  1048. normvideo;
  1049. lowvideo;
  1050. window(1,1,80,25);
  1051. normvideo;
  1052. textcolor(12);
  1053. frame(9,4,70,17);
  1054. lowvideo;
  1055. remove_port;
  1056. window(10,5,69,16);
  1057. clrscr;
  1058. gotoxy(1,1);
  1059. textcolor(15);
  1060. Writeln('                       Wardial 1.1');
  1061. textcolor(7);
  1062. writeln('                            by   ');
  1063. Writeln('                       Jim Everingham ');
  1064. textcolor(15);
  1065. writeln('                           1984 ');
  1066. writeln;
  1067. textcolor(7);write('                <');textcolor(15);write('1');textcolor(7);writeln('> Long Distance Service Codes');
  1068. textcolor(7);write('                <');textcolor(15);write('2');textcolor(7);writeln('> Sequential Dialer');
  1069. textcolor(7);write('                <');textcolor(15);write('3');textcolor(7);writeln('> Terminal Mode');
  1070. textcolor(7);write('                <');textcolor(15);write('4');textcolor(7);writeln('> Modem Parameters');
  1071. textcolor(7);write('                <');textcolor(15);write('5');textcolor(7);writeln('> Exit to System');
  1072. beep;
  1073. print_stat:=false;
  1074. Term_ready(false);
  1075. term_ready(true);
  1076. repeat
  1077. repeat
  1078. read(kbd,cr)
  1079. Until (ord(cr) > 48) and (ord(cr) < 55);
  1080. if (abs(55-ord(cr)) > 1) then
  1081.       begin
  1082.       case abs(48-ord(cr)) of
  1083.           1: wardial;
  1084.           2: Sequential_dial;
  1085.           3: begin
  1086.                   terminal;
  1087.                   set_up_recv_buffer;
  1088.              end;
  1089.           4: Set_modem_parameters;
  1090.           5: begin
  1091.                   init_screen;
  1092.                   gotoxy(1,1);
  1093.                   write('Terminated');
  1094.                   gotoxy(1,25);
  1095.                   halt;
  1096.              end;
  1097.           end;
  1098.       end;
  1099. until cr='5';
  1100. normvideo;
  1101. ClrScr;
  1102. Window(1,1,80,25);
  1103. ClrScr;
  1104. end;
  1105.  
  1106. Procedure Opening_Screen;
  1107. begin
  1108. crtinit;
  1109. textcolor(white);
  1110. frame(4,4,76,21);
  1111. Lowvideo;
  1112. window(5,5,75,20);
  1113. textcolor(7);
  1114. ClrScr;
  1115. gotoxy(1,2);
  1116. writeln;Writeln('                             WARDIAL 1.1');
  1117. Writeln;
  1118. Writeln('       The Author of this Program takes no responsibility for the');
  1119. Writeln('       results of it''s uses.   It was  Developed for  experimental');
  1120. writeln('       purposes and to illistrate certain techniques.');
  1121. writeln('       ');
  1122. writeln('       Any inquiries can be sent to:');
  1123. Writeln('               ');
  1124. writeln('                          Jim Everingham');
  1125. writeln('                          215 West Fairmount Ave.');
  1126. writeln('                          Apt #306 Fairmount Hills');
  1127. writeln('                          State College PA, 16801');
  1128. beep;
  1129. crtexit;
  1130. repeat until keypressed;
  1131. Normvideo;
  1132. crtexit;
  1133. lowvideo;
  1134. window(1,1,80,25);
  1135. normvideo;
  1136. clrscr;
  1137. end;
  1138.  
  1139.  
  1140. Procedure Wardial;
  1141. var test : boolean;
  1142.     a     : char;
  1143.     b     : smallstring;
  1144.     temp: sd;
  1145.     timing_constant,result: integer;
  1146.  
  1147. begin
  1148. lowvideo;
  1149. window(1,1,80,25);
  1150. clrscr;
  1151. textcolor(11);
  1152. writeln('Time is: ',time2);
  1153. writeln('Enter time to stop in format above ');
  1154. write('<Return> for none: ');
  1155. readln(Stop_time);
  1156. if length(stop_time)=7 then stop_time:='0'+stop_time;
  1157. normvideo;
  1158. clrscr;
  1159. beep;
  1160. gotoxy(7,12);textcolor(11);writeln('Trying Code:');
  1161. gotoxy(47,12);textcolor(11);writeln('Codes Found:');
  1162. textcolor(lightblue);
  1163. for ii:=1 to 3 do
  1164.        frame(wtab[ii,1]-1,wtab[ii,2]-1,wtab[ii,3]+1,wtab[ii,4]+1);
  1165. Lowvideo;
  1166. selectwindow(1);
  1167. gotoxy(1,1);
  1168. insline;
  1169. textcolor(15);
  1170. writeln('                       ==>   Wardial 1.1   <==');
  1171. textcolor(3);writeln;
  1172. Write('   Enter Service Number: ');
  1173. textcolor(11);
  1174. readln(temp);
  1175. textcolor(3);
  1176. service_number:=Dial_command+Dial_type+temp+Pause_command;
  1177. write('   Enter Checksum Number: ');
  1178. textcolor(11);
  1179. readln(checksum_number);
  1180. textcolor(3);
  1181. write('   Enter timing Constant: ');
  1182. textcolor(11);
  1183. readln(temp);
  1184. val(temp,timing_constant,result);
  1185. if timing_constant <=5 then timing_constant:=27;
  1186. textcolor(3);
  1187. write('   Enter Code Length: ');
  1188. textcolor(11);
  1189. readln(temp);
  1190. writeln;
  1191. val(temp,code_length,result);
  1192. if code_length<5 then code_length:=5;
  1193. textcolor(7);write('   <');
  1194. textcolor(15);write('Alt-H');
  1195. textcolor(7);write('> For Help menu');
  1196. if length(stop_time)=8 then begin
  1197.                textcolor(cyan);
  1198.                gotoxy(45,3);
  1199.                writeln('Program timed to stop ');
  1200.                gotoxy(45,4);
  1201.                write('at: ');
  1202.                textcolor(lightred+blink);
  1203.                write(stop_time);
  1204.                end;
  1205. normvideo;
  1206.  leave := false;
  1207.  zz:=0;
  1208.  while not leave do
  1209.  begin
  1210.   if keypressed then
  1211.   begin
  1212.   leave:=true;
  1213.   end
  1214.   else
  1215.   begin
  1216.        test:=false;
  1217.        get_code(code);
  1218.        if (length(stop_time)=8) and (time2 > stop_time) then
  1219.                          begin
  1220.                               leave:=true;
  1221.                               beep;delay(1000);beep;delay(1000);delay(1000);
  1222.                               if zz>0 then all_codes;
  1223.                               set_up_recv_buffer;
  1224.                               menu;
  1225.                           end;
  1226.        Send_code(Service_number,code,checksum_number);
  1227.        test_carrier(test,code,timing_constant);
  1228.        if test then
  1229.           begin
  1230.           remove_port;
  1231.           Menu;
  1232.           end;
  1233.        write_codes;
  1234.   end;
  1235.  end;
  1236.   if zz>0 then all_codes;
  1237.   beep;delay(1000);beep;delay(1000);beep;delay(1000);
  1238.   set_up_recv_buffer;
  1239.   menu;
  1240. end;
  1241.  
  1242. Procedure Make_data_file;
  1243. var a:string[20];
  1244.     infile:text;
  1245.     file_name:string[20];
  1246. begin
  1247. file_name:='WARDIAL.DTA';
  1248. assign(infile,file_name);
  1249. rewrite(infile);
  1250. textcolor(lightgreen);
  1251. writeln;Writeln('Creating  WARDIAL.DTA.');
  1252. write('Enter Baud      : ');
  1253. readln(a);
  1254. if (a='1200') or (a='300') or (a='9600') then writeln(infile,a)
  1255. else writeln(infile,'1200');
  1256. write('Enter Stop bits : ');
  1257. readln(a);
  1258. if (a<>'1') or (a<>'2') then writeln(infile,'1')
  1259. else writeln(infile,a);
  1260. write('Parity (E/N)    : ');
  1261. readln(a);
  1262. if upcase(copy(a,1,1))='E' then writeln(infile,'E') else writeln(infile,'N');
  1263. write('Enter Data Bits : ');
  1264. readln(a);
  1265. if (a='7') or (a='8') then writeln(infile,a) else writeln(infile,'8');
  1266. writeln;write('Are you Using a Hayes Or comatible Modem ? ');
  1267. readln(a);
  1268. if (copy(a,1,1)='Y') or (copy(a,1,1)='y') then begin
  1269.                            writeln;
  1270.                            writeln('Hayes Mode selected.');
  1271.                            writeln(infile,'ATD');
  1272.                            dial_type:='ATD';
  1273.                            writeln(infile,'WDT');
  1274.                            pause_command:='WDT';
  1275.                            end
  1276. else
  1277.     begin
  1278.          writeln;
  1279.          writeln('Non-Hayes Mode Selected.');
  1280.          write('Enter Dial Command (ie. ATDT): ');
  1281.          readln(dial_command);
  1282.          writeln(infile,dial_command);
  1283.          write('Enter Pause Command          : ');
  1284.          readln(Pause_command);
  1285.          writeln(infile,pause_command);
  1286.          Dial_type:='';
  1287.     end;
  1288. delay(2000);
  1289. close(infile);
  1290. end;
  1291.  
  1292.  
  1293.  
  1294. Procedure Initial_Setup;
  1295. var a:string[40];
  1296.     ok: boolean;
  1297.     infile:text;
  1298.     file_name:string[20];
  1299.     result:integer;
  1300. begin
  1301. ok:=false;
  1302. ClrScr;
  1303. textcolor(11);
  1304. Writeln('Reading in data...');
  1305. file_name:='WARDIAL.DTA';
  1306. assign(infile,file_name);
  1307. {$I-} reset(infile) {$I+};
  1308. ok:=(ioresult=0);
  1309. if not ok then make_Data_file
  1310. else
  1311. begin
  1312.   readln(infile,a);
  1313.   val(a,speed,result);
  1314.   readln(infile,a);
  1315.   val(a,stop_bits,result);
  1316.   readln(infile,a);
  1317.   if a='E' then parity:=even else parity:=none;
  1318.   readln(infile,a);
  1319.   val(a,dbits,result);
  1320.   readln(infile,dial_command);
  1321.   readln(infile,pause_command);
  1322.   close(infile);
  1323. end;
  1324. ClrScr;
  1325. term_ready(true);
  1326. end;
  1327.  
  1328.  
  1329. var a     : char;
  1330.     b     : smallstring;
  1331.  
  1332. (* This is the Main Program *)
  1333.  
  1334. begin
  1335.      Dial_speed:='70';
  1336.      maincolor:=11;
  1337.      xon:=chr(31);
  1338.      xoff:=chr(16);
  1339.      Print_stat:=false;
  1340.      Dial_type:='T';
  1341.      Speaker:='M1';
  1342.      Duplex:='F1';
  1343.      Command_echo:='E1';
  1344.      textcolor(lightcyan);
  1345.      Response_time:='6';
  1346.      Setup;
  1347.      Remove_port;
  1348.      Opening_screen;
  1349.      initial_setup;
  1350.      repeat
  1351.      menu;
  1352.      until keypressed;
  1353. end.
  1354.