TOOLKIT\PCI.C  ·  C  ·  6.4 KB  ·  1988-09-01  ·  from PersonalComputing_Sep-1988
/*==============================================================*/
/* PCI		Version 1.2	by Colin J Smith (c) 1988	*/
/*                                                              */
/* A program to display 'Personal Computer Information'         */
/*                                                              */
/* Written in Turbo C v1.5                                      */
/*==============================================================*/

#include <dir.h>
#include <dos.h>

#define DRVE      0x0001  /* masks for isolating status bits    */
#define DRV_MASK  0x00c0  /* bits to mask off no of disk drives */
#define DRV_SHIFT 0x06
#define PRN_SHIFT 0x0E
#define EQUIPCK   0x11    /* check equipment function           */
#define VIDEO     0x0030  /* mask to find initial video mode    */
#define EGA	  0x0000  /* determines EGA monitor fitted      */
#define BW4025    0x0010  /* determines if Black/White 40x25    */
#define BW8025	  0x0020  /* determines if Black/White 80x25    */
#define HERC      0x0030  /* determines if Monochrome Hercules  */

/*==============================================================*/

char *current_directory(char *path)
{
	strcpy(path, "X:\\");           /* routine to find current directory */
	path[0] = 'A' + getdisk();
	getcurdir(0, path+3);
	return(path);

} /* end of CURRENT DIRECTORY */

/*==============================================================*/

main()
{
	int number;	
        int index;
        int done;

        char curdir[MAXPATH];

        unsigned long diskfree;
        unsigned long diskcap;
        unsigned long diskused;
	unsigned ax;
	unsigned int equip;

	struct ffblk ffblk;
        struct date today;
        struct time now;

	union REGS iregs, oregs;
	
/* print heading */
	printf("PCI - Personal Computer Information (c) CJS \'88 -- VER. 1.2\n");

/* print time */
	gettime(&now);
	printf("At %02d:%02d:%02d.%02d ",now.ti_hour,now.ti_min,
		now.ti_sec,now.ti_hund);

/* print todays date */
	getdate(&today);
        printf("on %02d/%02d/%02d\n", today.da_day, today.da_mon,today.da_year);

/* print version of MD-DOS */
	printf("\nOperating System%23s%d.%d\n","» MS-DOS ",_osmajor,_osminor);

/* get equipment status value */
        equip = int86( EQUIPCK, &iregs, &oregs);

/* find number of disk drives attached */
	number = ((equip & DRV_MASK) >> DRV_SHIFT) +1;
        printf("No. of disk drives connected  » ");

/* print number of disk drives attached */
	if ( equip & DRVE != DRVE )
	  	printf("0");
	else
	  	printf("%d",number);

/* print number of printers attached */
	number =  equip >> PRN_SHIFT;
	printf("\nNo. of printers connected%5s» %d [PARALLEL-CENTRONICS]\n","",number);

/* print number of comms cards attached */
        number = ((equip & 0x0e00) >>9);
        printf("No. of communication cards%4s» %d [SERIAL-RS232]","",number);

/* print initial video mode */
	printf("\nInitial video mode setup%6s» ","");
	switch(equip & VIDEO) {
	 	case HERC   : printf ("Monochrome Hercules 80 X 25 B/W [TEXT]"); break;
	 	case BW8025 : printf ("CGA card 80 X 25 B/W [TEXT]"); break;
	 	case BW4025 : printf ("CGA card 40 X 25 B/W [TEXT]"); break;
	 	case EGA    : printf ("EGA card [TEXT]");
	}
	printf("\nCurrent video mode%12s» ","");

/* find and print current video mode */	
        iregs.h.ah = 15;
        int86( 0x10, &iregs, &oregs);
        switch(oregs.h.al) {
         	case 0 : printf ("CGA 40 X 25 B/W [TEXT]"); break;
         	case 1 : printf ("CGA 40 X 25 Colour [TEXT]"); break;
         	case 2 : printf ("CGA 80 X 25 B/W [TEXT]"); break;
         	case 3 : printf ("CGA 80 X 25 Colour [TEXT]"); break;
         	case 4 : printf ("CGA 320 X 200 Colour [GRAPHICS]"); break;
         	case 5 : printf ("CGA 320 X 200 B/W [GRAPHICS]"); break;
         	case 6 : printf ("CGA 640 X 200 B/W [GRAPHICS]"); break;
               default : printf ("Monochrome Hercules 80 X 25 B/W [TEXT]");
        }

/* print whether co-processor attached */
	printf("\nFloating point co-processor   » ");
	if (((equip & 0x0002) >> 1) == 1)
		printf("[YES]");
	else
		printf("[NO]");

/* print whether game card installed */
	printf("\nGame card (Input/Output)%6s» ","");
	number = ((equip & 0x1000) >> 12);
        switch(number){
		case 0: printf("[NO]");break;
		case 1: printf("[YES]");
	}

/* print whether mouse is installed */
        printf("\nMouse%25s» ","");
        iregs.h.al = 0;
        iregs.h.ah = 0;
        int86(0x33, &iregs, &oregs);
        if (oregs.h.al == 0)
        	printf("[NO]");
        else
         	printf("[YES]");

/* print size of motherboard memory */
	printf("\nMotherboard memory%12s» %u Kilo-bytes","",(((equip & 0x000c) >> 2)*16)+16);

/* print size of main memory */
	printf("\nMain memory%19s» %d Kilo-bytes","",biosmemory());

/* print location of program segment */
	printf("\nProgram segment address%7s» %05X hex\n","",_psp);

/* print current directory */
	current_directory(curdir);
	printf("Current directory%13s» %s","",curdir);

/* print number of files in current directory */
	number = 0;
	strcat(curdir,"*.*");
	done = findfirst(curdir,&ffblk,0);
        while(!done) {
         	number +=1;
         	done = findnext(&ffblk);
        }
        printf("\nNo. of files in current dir.  » %d",number);

/* find information about disk */
	iregs.h.ah = 0x36;
	iregs.h.dl = 0;
	int86(0x21, &iregs, &oregs);

/* print information about disk */
        printf("\nMaximum no. of clusters%7s» %u","",oregs.x.dx);
	printf("\nNo. of unused clusters%8s» %u","",oregs.x.bx);
	printf("\nNo. of sectors per cluster%4s» %u","",oregs.x.ax);
	printf("\nNo. of bytes per sector%7s» %u","",oregs.x.cx);

/* calculate information about disk */
	diskfree = (unsigned long)oregs.x.ax* (unsigned long) oregs.x.cx*(unsigned long)oregs.x.bx;
	diskcap = (unsigned long)oregs.x.ax*(unsigned long)oregs.x.cx*(unsigned long)oregs.x.dx;
	diskused = diskcap-diskfree;

/* print MAX disk capacity */
        ultoa(diskcap,curdir,10);
	printf("\nMaximum disk capacity%9s» %s bytes","",curdir);

/* print SPACE used */
	ultoa(diskused,curdir,10);
	printf("\nDisk space used%15s» %s bytes","",curdir);

/* print SPACE unused */
	ultoa(diskfree,curdir,10);
	printf("\nTotal disc space free%9s» %s bytes","",curdir);

} /* end of MAIN */

/*==============================================================*/