okeys got me this prob
when i try to format a 1.44mb disk it seems to only
format the first 9 of the 18 sectors on a track and
the last 9 on the track become invalid mark address or
something and i have NO idea why this is so as the
code seems sound... could one of you take a look
at it and tell me where i'm going wrong??
sorry if the code gets all split up and funky due to the
fido's transport layer.
//
//format.c
// (watcom btw)
#include
#include
#include
#include
#include
#pragma pack(1);
#define TRUE 0
#define FALSE !TRUE
#define MAX_SECTORS 36 // caters UP TO 2.88mb disks
enum
{
SECTOR_SIZE_128=0,
SECTOR_SIZE_256,
SECTOR_SIZE_512,
SECTOR_SIZE_1024,
SECTOR_MAX_SIZE
};
void format_track(short track, short head);
void verify_track(short track, short head);
void init_format(void);
void cmos_disktype(void);
short max_sectors;
short max_tracks;
short max_heads;
char verify=FALSE;
struct format_buffer
{
unsigned char track;
unsigned char head;
unsigned char sector;
unsigned char bytes;
};
struct format_buffer form_buffer[MAX_SECTORS];
void init_format(void)
{
union REGS inregs, outregs;
struct SREGS segregs;
inregs.h.ah=0x18;
inregs.h.al=max_sectors;
inregs.h.dl=0; // drive A:
inregs.h.dh=0;
inregs.h.ch=max_tracks-1;
inregs.h.cl=max_sectors;
inregs.x.bx=0;
int86x(0x13, &inregs, &outregs, &segregs);
inregs.x.ax=0x0;
int86x(0x13, &inregs, &outregs, &segregs);
}
void cmos_disktype(void)
{
char k;
outp(0x70, 0x10);
k=inp(0x71)>>4;
printf("\nCMOS reports disk size is : ");
switch(k)
{
case 1:
max_sectors=9;
max_tracks=40;
max_heads=2;
printf("360kb\n");
break;
case 2:
max_sectors=15;
max_tracks=80;
max_heads= 2;
printf("1.2mb\n");
break;
case 3:
max_sectors=9;
max_tracks=80;
max_heads=2;
printf("720kb\n");
break;
case 4:
max_sectors=18;
max_tracks=80;
max_heads=2;
printf("1.44mb\n");
break;
default:
printf("UNKNOWN!!\n");
exit(255);
break;
}
printf(" Number of Heads : %i\nSectors Per Track : %i\n Tracks
Per Disk : %i\n", max_heads, max_sectors, max_tracks);
}
void main(void)
{
short track, head;
max_sectors=18;
max_heads=2;
max_tracks=80;
cmos_disktype();
printf("\nFormatting a Disk in A:\nPress any key.\n");
getch();
init_format();
for(track=0; track * Origin: Comms Barrier BBS +61.3.9585.1112, +61.3.9583.6119 (3:632/358)
SEEN-BY: 633/267 270
@PATH: 632/533 107 360 50/99 635/728 633/267
|