Category : C Source Code
Archive   : TCCLB2.ZIP
Filename : DRIVREAD.C

 
Output of file : DRIVREAD.C contained in archive : TCCLB2.ZIP
#include
#include
#include
#include "tcclib.h"
#include

#define SECTOR_SIZE 512

int DriveReady (char drv)
{
int cnt, retry = 1;
union REGS inregs, outregs;
struct SREGS segregs;
unsigned char *buffer;
char back[600];

buffer = malloc(SECTOR_SIZE); /* allocate temp sector buffer */
cnt = 0;
while (1) {
inregs.h.ah = 0x04; /* function # */
inregs.h.al = 1; /* # of sectors */
inregs.h.ch = 0; /* 1st cylinder */
inregs.h.cl = 1; /* 1st sector */
inregs.h.dh = 0; /* 1st side */
inregs.h.dl = toupper(drv) - 'A'; /* drive ('A' = 0) */
segregs.es = FP_SEG(buffer); /* ES:BX pt to buffer (for old BIOS's) */
inregs.x.bx = FP_OFF(buffer);
int86x(0x13, &inregs, &outregs, &segregs); /* call Int 13H */

if (!outregs.h.ah) break; /* status ok -- return */
if (++cnt > retry) break; /* already retried */

/* otherwise retry -- first issue reset */
inregs.h.ah = 0x00; /* function # */
inregs.h.dl = toupper(drv) - 'A'; /* drive ('A' = 0) */
int86(0x13, &inregs, &outregs); /* call Int 13H */
}

free(buffer);

if ( outregs.h.ah != 0 ) {
gettext( 22, 8, 57, 14, back );
BlockErase( 22, 8, 57, 14 );
ExplodeBox( 24, 9, 55, 13 );
CenterF( 11, "Drive %c is not ready ...", drv );
Center( 13, " Press any key ... " );
ChangeBlock( 24, 9, 55, 13, A_REVERSE );
GComm();
puttext( 22, 8, 57, 14, back );
}
return(!outregs.h.ah); /* return TRUE if drive ready */
}
#define SECTOR_SIZE 512


  3 Responses to “Category : C Source Code
Archive   : TCCLB2.ZIP
Filename : DRIVREAD.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/