#include <stdio.h>
#include <string.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include "camkit.h"
main()
{
  char key;
  int DUMPUSER=0;
  strcpy(PATH,"c:");
  strcpy(MULTITASK,"NO");
  openall();
  LoadCnames(0); /*  Load Up Conference Number 0 [Main Board] into ConfRec */
		   /*  If an INVALID Number, the User Will Be Notifiied      */
  while(!DUMPUSER)
  {
    cls();
    pwhiteln ("                  Main Menu");
    NewLine();
    pcyanln  ("      (A)  Ansi Graphics Demo");
    plgreenln("      (C)  Display Conference Information");
    plblueln ("      (D)  Display System Information");
    predln   ("      (M)  Graphics Mode On/Off");
    pyellowln("      (T)  Display a Test Pattern");
    plcyanln ("      (Q)  Return to PCBoard");
    NewLine();
    do
    {
/*      display_time(); */
      pgray("     Command? ");
      getstring(1);
      NewLine();
    } while(command_string[0]=='\0');
    key = command_string[0];
    switch (toupper(key))
    {

      case 'A':
	ansi_demo();
	break;
      case 'C':
	displayconference();
	break;
      case 'D':
	displayinfo();
	break;
      case 'M':
	GraphicsOnOff();
	break;
      case 'T':
	test_pattern();
	break;
      case 'Q':
	DUMPUSER=1;
	break;
      default:
	break;
    }
  }
  exitit();
}
test_pattern(void)
{
    int  i;

    NewLine();
    for (i = 1; i < 21; i++)
    {
	   pwhite("(1234567890-abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)\r\n");
    }
    DisplayCurStr(20,25,"Press Enter To Continue\0");
    getstring(1);
}
ansi_demo(void) {

    short x,y;
    register short  i;
    int count=0;
    cls();
    colorit=1;
    if (color)
    {
      for (y=2; y < 24; y++)
      {
	++colorit;
	if(colorit>15)
	  colorit=1;
	DisplayCurStr(y,1,"³");
	DisplayCurStr(y,79,"³");
      }
      x = 2;
      DisplayCurStr(1,2,"\0");
      for(i = 0; i <= 1; i++)
      {
	while(x < 79)
	{
	  pwhite("Ä");
	  x++;
	}
	x = 2;
	DisplayCurStr(23,x,"\0");
      }
      DisplayCurStr(1,1,"Ú");
      DisplayCurStr(1,79,"¿");
      DisplayCurStr(23,1,"À");
      DisplayCurStr(23,79,"Ù");
      for(i = 1; i <= 8; i++)
      {
	colorit=i;
	DisplayCurStr(i+4,11,"ANSI Color display");
      }
      for(i = 15; i >= 8; i--)
      {
	colorit=i;
	/**************************************************************/
	/*   NOTE  This LOOP is to SLOW DOWN the OUTPUTProcess  To    */
	/*   Show that it can go in REVERSE, Otherwise it's TOO FAST  */
	/*   On the LOCAL SCREEN To SEE  REVERSE MOVEMENT             */
	/**************************************************************/
/*	for(count=0;count<32000;count++); */
	DisplayCurStr(i-3, 50,"ANSI Color display");
      }
      colorit=10;
      DisplayCurStr(14,28,"CAMKit For PCBoard 14.x");
      colorit=14;
      DisplayCurStr(16,14,"This is only a SMALL sample of what CAMKit can do! ");
      colorit=12;
      DisplayCurStr(20,26,"\0");
      /*  Draw Boxes Around ANSI Color Disply */
      for (y=5; y < 13; y++)
      {
	++colorit;
	if(colorit>15)
	  colorit=1;
	DisplayCurStr(y,9,"³");
	DisplayCurStr(y,30,"³");
      }
      x = 2;
      DisplayCurStr(4,10,"\0");
      x=10;
      for(i = 0; i <= 1; i++)
      {
	while(x < 30)
	{
	  ++colorit;
	  if(colorit>15)
	    colorit=1;
	  DisplayCurStr(4,x,"Ä");
	  x++;
	}
      }
      DisplayCurStr(4,9,"Ú");
      DisplayCurStr(4,30,"¿");
      DisplayCurStr(13,9,"À");
      DisplayCurStr(13,30,"Ù");

      DisplayCurStr(13,10,"\0");
      x=10;
      for(i = 0; i <= 1; i++)
      {
	while(x < 30)
	{
	  ++colorit;
	  if(colorit>15)
	    colorit=1;
	  DisplayCurStr(13,x,"Ä");
	  x++;
	}
      }
    }
    else
    {
      NewLine();
      pwhite("ANSI demo available only in GRAPHICS mode.\r\n");
    }
    DisplayCurStr(20,25,"Press Enter To Continue\0");
    getstring(6);
}
displayconference()
{
  short x,y;
  register short  i;

  cls();
  colorit=15;
  if (color)
  {
    for (y=2; y < 24; y++)
    {
      DisplayCurStr(y,1,"³");
      DisplayCurStr(y,79,"³");
    }
    x = 2;
    DisplayCurStr(1,2,"\0");
    for(i = 0; i <= 1; i++)
    {
      while(x < 79)
      {
	pwhite("Ä");
	x++;
      }
      x = 2;
      DisplayCurStr(23,x,"\0");
    }
    DisplayCurStr(1,1,"Ú");
    DisplayCurStr(1,79,"¿");
    DisplayCurStr(23,1,"À");
    DisplayCurStr(23,79,"Ù");
    sprintf(extra,"Confernce Name   : %s",CName);
    colorit=14;
    DisplayCurStr(2,3,extra);
    sprintf(extra,"AutoRejoin       : %c", (CAutoRejoin==0) ? 'N' : 'Y');
    DisplayCurStr(3,3,extra);
    sprintf(extra,"PublicConference : %c", (CPublicConf==0) ? 'N' : 'Y');
    DisplayCurStr(4,3,extra);
    sprintf(extra,"ViewMembers      : %c", (CViewMembers==0) ? 'N' : 'Y');
    DisplayCurStr(5,3,extra);
    sprintf(extra,"Uploads Private  : %c", (CPrivUplds==0)  ? 'N' : 'Y');
    DisplayCurStr(6,3,extra);
    sprintf(extra,"Private Messages : %c", (CPrivMsgs==0)   ? 'N' : 'Y');
    DisplayCurStr(7,3,extra);
    sprintf(extra,"Echo Mail        : %c", (CEchoMail==0)   ? 'N' : 'Y');
    DisplayCurStr(8,3,extra);
    sprintf(extra,"Location of MSGS File (PATH/NAME) : %s",CMsgFile);
    colorit=2;
    DisplayCurStr(10,3,extra);
    sprintf(extra,"Location of UserMenu (PATH/NAME)  : %s",CUserMenu);
    colorit=3;
    DisplayCurStr(11,3,extra);
    sprintf(extra,"Location of SysopMenu (PATH/NAME) : %s",CSysopMenu);
    colorit=4;
    DisplayCurStr(12,3,extra);
    sprintf(extra,"Location of NEWS File (PATH/NAME) : %s",CNewsFile);
    colorit=5;
    DisplayCurStr(13,3,extra);
  }
  else
  {
    sprintf(extra,"Confernce Name   : %s",CName);
    pwhiteln(extra);
    sprintf(extra,"AutoRejoin       : %c", (CAutoRejoin==0) ? 'N' : 'Y');
    pwhiteln(extra);
    sprintf(extra,"PublicConference : %c", (CPublicConf==0) ? 'N' : 'Y');
    pwhiteln(extra);
    sprintf(extra,"ViewMembers      : %c", (CViewMembers==0) ? 'N' : 'Y');
    pwhiteln(extra);
    sprintf(extra,"Uploads Private  : %c", (CPrivUplds==0)  ? 'N' : 'Y');
    plblueln(extra);
    sprintf(extra,"Private Messages : %c", (CPrivMsgs==0)   ? 'N' : 'Y');
    pblueln(extra);
    sprintf(extra,"Echo Mail        : %c", (CEchoMail==0)   ? 'N' : 'Y');
    pcyanln(extra);
    NewLine();
    sprintf(extra,"Location of MSGS File (PATH/NAME) : %s",CMsgFile);
    pyellowln(extra);
    sprintf(extra,"Location of UserMenu (PATH/NAME)  : %s",CUserMenu);
    pdgrayln(extra);
    sprintf(extra,"Location of SysopMenu (PATH/NAME) : %s",CSysopMenu);
    pmagentaln(extra);
    sprintf(extra,"Location of NEWS File (PATH/NAME) : %s",CNewsFile);
    plmagentaln(extra);
  }
    getstring(6);
}
displayinfo(void)
{
  char    string[18];

  cls();
  NewLine();
    pstrcolor(FirstName,", Here is your User information:",15,14,1);
    pstrcolor("    Fullname        = ",Name,15,14,1);
    pstrcolor("    Phone numbers   = ",BusDataPhone,13,12,0);
    pstrcolor(" / ",HomeVoicePhone,13,12,1);
    pstrcolor("    City            = ",City,15,6,1);
    pstrcolor("    Security level  = ",itoa((short)SecurityLevel,string,10),8,15,1);
    pstrcolor("    Baud Rate       = ",DisplayBaud,3,15,1);
    pstrcolor("    Last call date  = ",LastDateOn,14,5,1);
    pstrcolor("    Time On System  = ",itoa(ElapsedTimeOn,string,10),9,9,1);
    pstrcolor("    Minutes left    = ",itoa(timeleft,string,10),9,8,1);
    if (EventActive)
    {
      pstrcolor("    Event Active    = ","Y",12,15,1);
    }
    else
    {
      pstrcolor("    Event Active    = ","N",12,15,1);
    }
    pstrcolor("    Event Time      = ",EventTime,12,13,1);
    pwhiteln("    # of Downloads");
    pstrcolor("             Total  = ",ultoa(NumDownloads,string,10),14,15,1);
    pstrcolor("       Bytes Today  = ",ltoa(DailyDnldBytes,string,10),14,15,1);
    pstrcolor("     Allowed Bytes  = ",itoa(pcb.DLBytes,string,10),14,15,1);
    pcyanln("    # of Uploads");
    pstrcolor("             Total  = ",ultoa(NumUploads,string,10),4,15,1);
    pstrcolor("       Total Bytes  = ",ltoa(TotUpldBytes,string,10),4,15,1);
    pwhite("Press Return to Continue: ");
    getstring(6);
}
GraphicsOnOff()
{
  if(color==1)
  {
    color=0;
    NewLine();
    pstrcolor("    Graphics Mode Turned Off  ",NULL,14,1,0);
  }
  else
  {
    color=1;
    NewLine();
    pstrcolor("    Graphics Mode Turned On  ",NULL,14,1,0);
  }
  sleep(1);
}
