Mail Archives: djgpp/1996/02/12/12:50:39
Where are the valid values for the device numbers documented?
I thought that the device numbers were just 0, 1, 2, ...
The following program works for devices A and B, but not for C.
/* READDISK.C: This program reads a disk sector.
*/
#include <conio.h>
#include <stdio.h>
#include <bios.h>
int main (int argc, char **argv)
{
unsigned char buffer [2352];
unsigned status = 0;
int i, drive;
drive = (int) toupper (argv[1] [0]) - (int) 'A';
struct _diskinfo_t disk_info;
disk_info.drive =0;
disk_info.head =0;
disk_info.track =0;
disk_info.sector =1;
disk_info.nsectors =1;
disk_info.buffer =&buffer [0];
disk_info.drive = drive;
printf("%d\n", drive);
status = _bios_disk(_DISK_RESET, &disk_info);
if (status & 0xff00) printf("DISK RESET Error: 0x%.4x\n", status);
printf("Insert disk into drive %c: and press any key\n", drive + 'A');
getchar();
status = _bios_disk(_DISK_READ, &disk_info);
if (status & 0xff00) printf("DISK READ Error: 0x%.4x\n", status);
for (i = 0; i < 62; i++)
{
if (i % 32 == 0) printf("\n%d\t",i);
printf("%02X", buffer [i]);
}
}
- Raw text -