{$R-,S-,I-,D-,F+,V-,B-,N-,L+,O+}
{$M 63000,4800,28000}
{$DEFINE Overlays}

{ ViSiON BBS Software Written by Crimson Blade & The Elemental }
{ Compiled under Turbo Pascal v6.0 }
{ The BEST Kick-Ass software in the business!!! }


Uses
  Crt,       { Turbo Pascal CRT library }
  Dos,       { Turbo Pascal DOS library }
  Printer,   { Turbo Pascal Printer library }
  Overlay,   { Sets up the files to be put in the overlay file. }
  OvrCall,   { Calls the overlay files }
  gentypes,  { All type and constant declarations }
  configrt,  { Configuration declarations / procedures }
  modem,     { Modem support }
  statret,   { System status declarations / procedures }
  gensubs,   { General subroutines: lowest level }
  subs1,     { First subroutine library }
  windows,   { Routines to manage the split screen }
  subs2,     { Second subroutine library: higer level I/O }
  textret,   { Message base routines }
  mailret,   { E-mail routines }
  userret,   { User routines }
  flags,     { Board access flag routines }
  mainr1,    { High-level routines, set one }
  ansiedit,  { Full-screen editor }
  lineedit,  { Line editor }
  chatstuf,  { Chat mode routines }
  mainr2,    { High-level routines, set two }
  overret1,  { High-level routines, set three }
  Bulletin,  {        Bulletin section }
  Configur,  {   Configuration section }
  Database,  {        Database section }
  Doors,     {            Door section }
  Email,     { Electronic mail section }
  Filexfer,  {   File transfer section }
  Voting,    {          Voting section }
  Mycomman,  { Generic Shell Routines  }
  MainMenu,  { Main menu commands      }
  Main,      { Main menu shell         }
  Waitcall,  { Waiting for calls       }
  Getlogin,  { Log-in procedure        }
  Init,      { Initialization routines }
  Others,    { Other Routines (Overlayed), i.e. user routines }
  Subs3,     { Low Level routines #3 used in filexfer. }
  ExecSwap,  { Maximum Dos Shell Routines }
  Fossil;

{$IFDEF Overlays}
{$O Email}
{$O Init}
{$O Getlogin}
{$O Configur}
{$O Database}
{$O Doors}
{$O Voting}
{$O Mycomman}
{$O Filexfer}
{$O Waitcall}
{$O Bulletin}
{$O Lineedit}
{$O Ansiedit}
{$O Mailret}
{$O Menus}
{$O PCBoard}
{$O Others}
{$ENDIF}


 (* {}{}{}         ViSiON BBS Systems Main Program              {}{}{} *)


var gotoforumterm:boolean;
begin
  readconfig;
{ initializeasync; }  { SHIT STUFF! }
  UseEmsIfAvailable:=True;
  If Not InitExecSwap(HeapPtr,'SWAP.$$$') Then Begin
    WriteLn('Unable to allocate Swap Space!');
    Delay(1500);
  End;
  If Not Install_FOSSIL (ConfigSet.UseCo) Then Begin
    Writeln (#13#10'ERROR: There is no Fossil Driver Resident in Memory.');
    Halt (4);
  End;
  local:=FALSE;
  checkbreak:=false;
  validconfiguration;
  initforum(true);
  fromdoor:=paramcount>=3;
  repeat
    gotoforumterm:=false;
    returnfromdoor;
    if not fromdoor then begin
      gotoforumterm:=waitforacall;
       getloginproc
    end;
		if not gotoforumterm then begin
			newmailre;
			if not fromdoor then if tonext>-1 then begin
				WriteHdr('Message from Last User');
				PrintText(tonext);
			if sysopisavail then writehdr(configset.sysopi) else writehdr(configset.sysopo);
      end;
      votingbooth (true);
      mainmenuproc;
      writeln(direct,#27,'[0m');
      fromdoor:=false;
      if not disconnected then disconnect;
      ensureclosed;
      clrscr;
      dontanswer;
      if sysnext then
         begin
           closeport;
           textmode(co80);
           halt(4);
         end;
            initforum (false)
    end
	until not gotoforumterm;
    closeport;
    halt(0)
end.
