http://www.ousob.com --- Legacy Redefined #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <ctype.h> #include <graph.h> #include <time.h> #include <dos.h> #include <bios.h> #include <extend50.h> static char drive[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; union { unsigned equip; struct { unsigned diskette : 1; unsigned math_copr : 1; unsigned sys_mem : 2; unsigned video_mode : 2; unsigned num_drives : 2; unsigned dma : 1; unsigned serial_ports : 3; unsigned game_adapter : 1; unsigned serial_printer : 1; unsigned num_printers : 2; } equipment; } eq; char *vidtyp(void); char *xfloppytype(int drivenumber); long hdsize(void); long hdfree(void); long xtmem(void); long xpmem(void); long xptmem(void); char *tran(long num); int emm_present(void); int is_rodent(int *mb); void show_rodent(void); void hide_rodent(void); void cinkey(int seconds); int isprinter(int lpt_num); int iscomport(int com_port); #define BEEP printf("\x7"); #define RS232 0x14 #define B300 0x40 #define B1200 0x80 #define B2400 0xa0 #define NOPARITY 0x00 #define EVEN 0x18 #define ODD 0x08 #define WORD7 0x02 #define WORD8 0x03 #define STOP1 0x00 #define STOP2 0x40 #define MK_FP(seg,off) ((void far *) (((unsigned long) (seg) << 16 + (unsigned)(off))) CLIPPER b_equip() { int i, j; int mousebuttons = 0; char fd, buffr[256]; long elapsetime; long extmem; char *p_string, buffer[256]; unsigned memsize; struct tm *adjtime; long oldbkcolor; oldbkcolor = _getbkcolor(); _setbkcolor( (long)1 ); _settextcolor(15); _clearscreen(_GCLEARSCREEN); eq.equip = _bios_equiplist(); memsize = _bios_memsize(); time(&elapsetime); adjtime = localtime(&elapsetime); sprintf(buffr,"System Date %.2d/%.2d/%.2d\n",(adjtime->tm_mon +1), adjtime->tm_mday,adjtime->tm_year ); _outtext(buffr); sprintf(buffr,"System Time %.2d:%.2d:%.2d\n",adjtime->tm_hour, adjtime->tm_min, adjtime->tm_sec ); _outtext(buffr); sprintf(buffr,"DOS Version %d.%d\n", _osmajor,_osminor ); _outtext(buffr); sprintf(buffr,"Base Memory %sK\n", tran((long)memsize) ); _outtext(buffr); sprintf(buffr,"Extended Memory %s\n", tran(xtmem()) ); _outtext(buffr); sprintf(buffr,"EMM Present %s\n", emm_present() ? "Yes" : "No" ); _outtext(buffr); if( emm_present ){ sprintf(buffr,"Expanded Total %s\n", tran(xptmem()) ); _outtext(buffr); sprintf(buffr,"Expanded Avail. %s\n", tran(xpmem()) ); _outtext(buffr); } sprintf(buffr,"Video Type %s\n\0", vidtyp() ); _outtext(buffr); if( is_rodent(&mousebuttons) ){ sprintf(buffr,"Mouse Present %s\n", "Yes" ); _outtext(buffr); sprintf(buffr,"Mouse Buttons %d\n", mousebuttons ); _outtext(buffr); } sprintf(buffr,"Serial Port(s) "); _outtext(buffr); for(j=0; j<4; j++){ sprintf(buffr,"%cCOM%d ", iscomport(j) ? '*' : ' ', j+1); _outtext(buffr); } sprintf(buffr,"\n"); _outtext(buffr); sprintf(buffr,"Parallel Port(s) "); _outtext(buffr); for(j=0; j<4; j++){ sprintf(buffr,"%cLPT%d ", isprinter(j+1) ? '*' : ' ', j+1); _outtext(buffr); } sprintf(buffr,"\n"); _outtext(buffr); sprintf(buffr,"Coprocessor %s\n",eq.equipment.math_copr ? "Installed" : "Not Installed"); _outtext(buffr); sprintf(buffr,"Hard Drive Size %s Bytes\n", tran(hdsize()) ); _outtext(buffr); sprintf(buffr,"Hard Drive Free %s Bytes\n", tran(hdfree()) ); _outtext(buffr); for(i=0; i<eq.equipment.diskette+1; i++){ if( i == 0 ){ fd = 'A'; } else{ fd = 'B'; } sprintf(buffr,"Floppy %c: %s\n", fd, xfloppytype(i)); _outtext(buffr); } sprintf(buffr,"Game Adapter %s\n",eq.equipment.game_adapter ? "Installed" : "Not Installed"); _outtext(buffr); sprintf(buffr,"DMA %s\n",eq.equipment.dma ? "Present" : "Not Present"); _outtext(buffr); show_rodent(); _outtext("\n\nPress any key to continue..."); cinkey(0); hide_rodent(); _setbkcolor( oldbkcolor ); _ret(); } int is_rodent(int *mb) { union REGS regs; regs.x.ax = 0x00; int86(0x33, &regs, &regs); *mb = regs.x.bx; return(regs.x.ax); } void show_rodent(void) { union REGS regs; regs.x.ax = 0x01; int86(0x33,&regs,&regs); } void hide_rodent(void) { union REGS regs; regs.x.ax = 0x02; int86(0x33,&regs,&regs); } char *vidtyp(void) { int vid_typ; struct videoconfig config; _getvideoconfig(&config); vid_typ = config.adapter; switch(vid_typ){ case 0x0001 : return("MDPA"); case 0x0002 : return("CGA"); case 0x0004 : return("EGA"); case 0x0008 : return("VGA"); case 0x0010 : return("MCGA"); case 0x0020 : return("HGC"); default : return("UNKNOWN"); } } char *xfloppytype(int drivenumber) { union REGS regs; regs.h.ah = 0x08; regs.h.dl = drivenumber; int86(0x13,&regs,&regs); switch(regs.h.bl){ case 1 : return("5 360K"); case 2 : return("5 1.2Mb"); case 3 : return("3 720K"); case 4 : return("3 1.44Mb"); default : return("Unknown"); } } long hdsize(void) { unsigned drive_id; long dspace = 0; union REGS iregs, oregs; _dos_getdrive(&drive_id); iregs.h.ah = 0x36; iregs.h.dl = drive[drive_id] - 'A' + 1; intdos(&iregs,&oregs); dspace=(long) ((long) oregs.x.dx * (long) oregs.x.ax * (long) oregs.x.cx); return(dspace); } long hdfree(void) { unsigned drive_id; long fspace = 0; union REGS iregs, oregs; _dos_getdrive(&drive_id); iregs.h.ah = 0x36; iregs.h.dl = drive[drive_id] - 'A' + 1; intdos(&iregs,&oregs); fspace=(long) ((long) oregs.x.ax * (long) oregs.x.bx * (long) oregs.x.cx); return(fspace); } long xtmem(void) { union REGS regs; regs.h.ah = 0x88; int86(0x15,&regs,&regs); return( (long)regs.x.ax ); } long xpmem(void) { union REGS regs; regs.h.ah = 0x42; int86(0x67,&regs,&regs); return( (long)regs.x.bx *(long)16 * (long)1024 ); } long xptmem(void) { union REGS regs; regs.h.ah = 0x42; int86(0x67,&regs,&regs); return( (long)regs.x.dx *(long)16 * (long)1024 ); } int emm_present(void) { union REGS inregs, outregs; struct SREGS segregs; char far *emmname; char *template = "EMMXXXX0"; int count; inregs.h.ah = 0x35; inregs.h.al = 0x67; int86x(0x21, &inregs, &outregs, &segregs); emmname = MK_FP(segregs.es, 0)); emmname += 10; for(count=0; count<8; count++){ if( *emmname++ != *template++ ){ return(0); } } return(1); } void cinkey(int seconds) { long timeval = (time(NULL) + seconds); if( seconds <= 0 ){ getch(); } else{ while( (time(NULL) < timeval) && !kbhit() ){ ; /* NULL */ } } } int isprinter(int lpt_num) { union { unsigned rtrn; struct { unsigned time_out : 1; unsigned not_used : 2; unsigned io_error : 1; unsigned selected : 1; unsigned no_paper : 1; unsigned acknowlege : 1; unsigned ready : 1; unsigned high_byte : 8; } s; } status; unsigned outbyte; /* output byte to printer */ int lpt_port; /* lpt port */ lpt_port = (lpt_num - 1); status.rtrn = _bios_printer(_PRINTER_STATUS, lpt_port, outbyte); return( (status.s.selected) && (status.s.ready) ); } int iscomport(int com_port) { union REGS regs; regs.h.ah = 0x03; regs.x.dx = com_port; int86(RS232,&regs,&regs); return( regs.h.ah && regs.h.al ); } char *tran(long num) { int i = 0, j = 0, len = 0, spaces = 0; char buffr[256]; char buff2[256]; char *ptr; long value; int radix = 10; memset(buff2,0,256); ptr = ltoa(num,buffr,radix); if( strlen(ptr) <= 3 ){ sprintf(buff2,"%s\0",ptr); return(buff2); } len = strlen(buffr); if( (len % 3) == 0 ){ spaces = (len+(len/3)) -1; } else{ spaces = (len+(len/3) ); } for(i=spaces,j=strlen(ptr);i>=0;i--){ if( !((spaces-i) % 4) && (spaces-i != 0) ){ buff2[i] = ','; } else{ buff2[i] = ptr[j--]; } } return(buff2); }