adnan@rice.edu (Sarmad Adnan) (07/09/90)
I have been trying to format a floppy inside an application program written in MSC5.1 as follows, and have not had success. The bios does not return any error code and the floppy remains unformatted. I think I am not filling the sector data array properly, I would appreciate any pointers(No pun intended **). ########################################################################### #include <stdio.h> #include <dos.h> #include <bios.h> #define DOS_DISPCHAR 2 main() { int track, head, sector, ndx; unsigned status=0; char buf[1000]; void far *pbuf; struct diskinfo_t info; printf("An attempt to format drive A: 360kb 9sectors 40 tracks\n"); pbuf = (void far *)(&buf[0]); info.buffer = pbuf; for(track=0; track<40; track++) { for(head=0; head<=1; head++) { info.drive = 0; info.head = head; info.track = track; info.nsectors = 9; info.sector = 1; /* I do not think I am filling this data array 'buf[]' properly */ for(sector=0; sector<9; sector++) { ndx=sector*4; buf[ndx]=track, buf[ndx+1]=head, buf[ndx+2]=sector+1, buf[ndx+3]=2; } status= _bios_disk(_DISK_FORMAT, &info); if( status>0xff ) printf("%x \n",status); else printf("Track %d\t Head %d \r", track, head); } } } ########################################################################## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sarmad Adnan (adnan@rice.edu) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~