TOOLKIT\CHKSYS.C  ·  C  ·  4.4 KB  ·  1989-07-01  ·  from PersonalComputer_Jul-1989
#include <dos.h>
#include <conio.h>

int country, hours, minutes, seconds = 0;
int memory, devices, display, Printers = 0;
int driveno, major, minor, day, month, year = 0;
int DiskDrives, RS232, GameIO, M8087 = 0;
union REGS inregs, outregs;

GetHard(int driveno)
{
	int sc, ac, bs, tc;
	float c1, c, r;
	int syscall = 0x21;

	inregs.h.ah = 0x36;
	inregs.h.dl = driveno;
	int86(syscall,&inregs,&outregs);
	sc = outregs.x.ax;
	ac = outregs.x.bx;
	bs = outregs.x.cx;
	tc = outregs.x.dx;

	driveno = driveno + 64;
	c1 = sc * bs;
	 c = (tc * c1)/1E6;
	 r = (ac * c1)/1E6;
	if (sc >= 2)
		{
		printf("\nHard disc found at drive %c: ",driveno);
		printf(" Capacity: %2.4fMb ",c);
		printf(" Free space: %2.4fMb\n",r);
		}
}

GetDosVer()
{
	int syscall = 0x21;

	inregs.h.ah = 0x30;
	int86(syscall,&inregs,&outregs);
	major = outregs.h.al;
	minor = outregs.h.ah;
	return (major,minor);
}

GetCountry()
{
	int syscall = 0x21;

	inregs.h.ah = 0x38;
	inregs.h.al = 0x0;
	inregs.x.dx = 0xa0ff;
	int86(syscall,&inregs,&outregs);
	country = outregs.x.bx;
	return (country);
}

GetDate()
{
	int syscall = 0x21;

	inregs.h.ah = 0x2a;
	int86(syscall, &inregs, &outregs);
	day = outregs.h.dl;
	month = outregs.h.dh;
	year = outregs.x.cx;
	return (day,month,year);
}

GetTime()
{
	int syscall = 0x21;

	inregs.h.ah = 0x2c;
	int86(syscall,&inregs,&outregs);
	hours = outregs.h.ch;
	minutes = outregs.h.cl;
	seconds = outregs.h.dh;
	return (hours,minutes,seconds);
}

AvailMem()
{
	int syscall = 0x12;

	int86(syscall, &inregs, &outregs);
	memory = outregs.x.ax;
	return (memory);
}

EquipStat()
{
	int syscall = 0x11;

	int86(syscall, &inregs, &outregs);
	devices = outregs.x.ax;
	return (devices);
}

DispType()
{
	int syscall = 0x10;
	inregs.h.ah = 0x0F;
	int86(syscall, &inregs, &outregs);
	display = outregs.h.al;
	return (display);
}

GetVidMode()
{
	int syscall = 0x10;
	int video;

	inregs.h.ah = 0x0f;
	int86(syscall,&inregs,&outregs);
	video = outregs.h.al;
	switch (video)  {
		case 0:
			printf("40 x 25 mono text, colour adapter\n");
			break;
		case 1:
			printf("40 x 25 colour text\n");
			break;
		case 2:
			printf("80 x 25 mono text\n");
			break;
		case 3:
			printf("80 x 25 colour text\n");
			break;
		case 4:
			printf("320 x 200, four-colour graphics\n");
			break;
		case 5:
			printf("320 x 200, 4-col graphics, no colour burst\n");
			break;
		case 6:
			printf("640 x 200, two-colour graphics\n");
			break;
		case 7:
			printf("Mono adapter text\n");
			}
}

GetEquipStat()
{
	memory = AvailMem();
	devices = EquipStat();
	Printers = (devices & 0xC000) >> 14;
	DiskDrives = ((devices & 0x00C0) >> 6) + 1;
	RS232 = (devices & 0x0E00) >> 9;
	GameIO = (devices & 0x1000) >> 12;
	M8087 = (devices & 0x0002) >> 1;
}

DispEquipStat()
{
	printf("A check of this equipment on ");
	if (day < 10)
		printf("0%d/",day);
	else
		printf("%d/",day);
	if (month < 10)
		printf("0%d/",month);
	else
		printf("%d/",month);
	printf("%d at ",year);
	if (hours < 10)
		printf("0%d:",hours);
	else
		printf("%d:",hours);
	if (minutes < 10)
		printf("0%d:",minutes);
	else
		printf("%d:",minutes);
	if (seconds <10)
		printf("0%d reveals:\n\n",seconds);
	else
		printf("%d reveals:\n\n",seconds);
	printf("Dos version: ....................... %d.%d\n",major,minor);
	printf("Country code: ...................... 0%d\n",country);
	printf("System memory: ..................... %dk\n",memory);
	printf("Floppy disc drives: ................ %d\n",DiskDrives);
	printf("Parallel printer ports: ............ %d\n",Printers);
	printf("RS232 serial ports: ................ %d\n",RS232);
	printf("Monitor type: ...................... ");
	display = DispType();
	switch (display) {
		case 2:
			printf("Composite colour\n");
			break;
		case 3:
			printf("RGB colour\n");
			break;
		case 7:
			printf("Monochrome\n");
		}

	printf("Video mode: ........................ ");
	GetVidMode();
	if (GameIO == 1)
		printf("Game adapter port:                   %d\n",GameIO);
	else
		printf("No Game adapter port found\n");

	if (M8087 == 1)
		printf("8087 Math co-processor found\n");
	else
		printf("No 8087 Math co-processor found\n");
}

main()
{
	GetEquipStat();
	GetDate();
	GetTime();
	GetDosVer();
	GetCountry();
	DispEquipStat();
	for (driveno = 3; driveno <= 24; ++driveno)
		GetHard(driveno);
}