atari-sources-request@daisy.UUCP (11/29/87)
Submitted by: imagen!decwrl!hplabs!ames!rochester!cornell!batcomputer!braner (braner) comp.sources.atari.st: Volume 0, Issue 47 Archive-name: ibmfmt.c ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- [Editor's Note] The following note from Moshe is pretty self explainatory, I can only test this on my DSDD 3.5" disk as I don't have a IBM system that uses 3.5" disks nor do I have a 5 1/4" B: disk. The program does compile under MegaMax C and runs as far as I can test it. the checksum is: bytes = 5891( 6071) cksm = 1030 ibmfmtr.c ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- Hi, James! Here is a submission for comp.*.atari.st (some for each): This is a corrected version of the 200% MS-DOS-compatible formatter. It will format 3.5" (720K, MS-DOS 3.3) disks in drive A and 5.25" (360K, MS-DOS 2.0) disks in drive B (assuming you have a 5.25" drive attached as drive B!). (Sorry, no frills!) The disks are NOT bootable (on MS-DOS) but both the Atari ST and MS-DOS machines can read and write files on them, even in subdirectories. The correction (of the early version that I posted to comp.sys.atari.st) is that now a random disk ID is created. In the early version, the same ID was always used (stupid me!). Thanks for doing the moderation job (must be a pain)! - Moshe Braner Here is the source code (Megamax C), followed by the uuencoded binary. ------------------ cut here ------------------ /** ** Program to format MS-DOS-compatible disks on the Atari ST ** Code for Megamax C compiler 871023 **/ #include <osbind.h> #define WORD int /* 16 bits!!! */ /* * IBM style boot sector for nonsystem 5.25" disk: * * (This is simply: * WORD boot5[256] = { 0xEB3C, ... }; * done in a sick way to bypass the sick element-by-element * array-initialization scheme used by Megamax...) */ extern boot5(); asm{ boot5: DC.W 0xEB3C,0x9049,0x424D,0x2020,0x322E,0x3000,0x0202,0x0100 DC.W 0x0270,0x00D0,0x02FD,0x0200,0x0900,0x0200,0x0000,0x2020 DC.W 0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020 DC.W 0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x0E1F DC.W 0x33C0,0xFA8E,0xD0BC,0x007C,0x36C7,0x0678,0x00F4,0x7C36 DC.W 0xA37A,0x00FB,0xCD13,0x7264,0xB850,0x008E,0xC033,0xDBB8 DC.W 0x0102,0xB906,0x0033,0xD2CD,0x1372,0x51B1,0x0B26,0x8A07 DC.W 0x3A87,0xDE7C,0x754E,0x268A,0x4720,0x3A87,0xE97C,0x7544 DC.W 0x43E2,0xEAB8,0x7000,0x8EC0,0x33DB,0xB806,0x02B1,0x04B6 DC.W 0x01CD,0x1372,0x27B7,0x0CB8,0x0902,0xB901,0x01B6,0x00CD DC.W 0x1372,0x19CD,0x11D0,0xC0D0,0xC025,0x0300,0x7501,0x4040 DC.W 0x8BC8,0x33C0,0xBB0C,0x00EA,0x0000,0x7000,0xBEFF,0x7CE8 DC.W 0x0E00,0xEBFE,0xBE15,0x7DE8,0x0600,0xB400,0xCD16,0xCD19 DC.W 0xAC84,0xC074,0x08B4,0x0EB3,0x07CD,0x10EB,0xF3C3,0x4942 DC.W 0x4D42,0x494F,0x2020,0x434F,0x4D49,0x424D,0x444F,0x5320 DC.W 0x2043,0x4F4D,0xDF02,0x2502,0x092A,0xFF50,0x000F,0x020D DC.W 0x0A44,0x6973,0x6B20,0x426F,0x6F74,0x2066,0x6169,0x6C75 DC.W 0x7265,0x0D0A,0x000D,0x0A4E,0x6F6E,0x2D53,0x7973,0x7465 DC.W 0x6D20,0x6469,0x736B,0x206F,0x7220,0x6469,0x736B,0x2065 DC.W 0x7272,0x6F72,0x0D0A,0x0D0A,0x5265,0x706C,0x6163,0x6520 DC.W 0x616E,0x6420,0x7374,0x7269,0x6B65,0x2061,0x6E79,0x206B DC.W 0x6579,0x2077,0x6865,0x6E20,0x7265,0x6164,0x790D,0x0A00 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0 DC.W 0,0,0,0,0,0,0,0x55AA } /* * IBM style boot sector for nonsystem 3.5" disk: */ extern boot3(); asm{ boot3: DC.W 0xEB34,0x9049,0x424D,0x2020,0x332E,0x3300,0x0202,0x0100 DC.W 0x0270,0x00A0,0x05F9,0x0300,0x0900,0x0200,0x0000,0x0000 DC.W 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0012 DC.W 0x0000,0x0000,0x0100,0xFA33,0xC08E,0xD0BC,0x007C,0x1607 DC.W 0xBB78,0x0036,0xC537,0x1E56,0x1653,0xBF2B,0x7CB9,0x0B00 DC.W 0xFCAC,0x2680,0x3D00,0x7403,0x268A,0x05AA,0x8AC4,0xE2F1 DC.W 0x061F,0x8947,0x02C7,0x072B,0x7CFB,0xCD13,0x7267,0xA010 DC.W 0x7C98,0xF726,0x167C,0x0306,0x1C7C,0x0306,0x0E7C,0xA33F DC.W 0x7CA3,0x377C,0xB820,0x00F7,0x2611,0x7C8B,0x1E0B,0x7C03 DC.W 0xC348,0xF7F3,0x0106,0x377C,0xBB00,0x05A1,0x3F7C,0xE89F DC.W 0x00B8,0x0102,0xE8B3,0x0072,0x198B,0xFBB9,0x0B00,0xBED6 DC.W 0x7DF3,0xA675,0x0D8D,0x7F20,0xBEE1,0x7DB9,0x0B00,0xF3A6 DC.W 0x7418,0xBE77,0x7DE8,0x6A00,0x32E4,0xCD16,0x5E1F,0x8F04 DC.W 0x8F44,0x02CD,0x19BE,0xC07D,0xEBEB,0xA11C,0x0533,0xD2F7 DC.W 0x360B,0x7CFE,0xC0A2,0x3C7C,0xA137,0x7CA3,0x3D7C,0xBB00 DC.W 0x07A1,0x377C,0xE849,0x00A1,0x187C,0x2A06,0x3B7C,0x4038 DC.W 0x063C,0x7C73,0x03A0,0x3C7C,0x50E8,0x4E00,0x5872,0xC628 DC.W 0x063C,0x7C74,0x0C01,0x0637,0x7CF7,0x260B,0x7C03,0xD8EB DC.W 0xD08A,0x2E15,0x7C8A,0x16FD,0x7D8B,0x1E3D,0x7CEA,0x0000 DC.W 0x7000,0xAC0A,0xC074,0x22B4,0x0EBB,0x0700,0xCD10,0xEBF2 DC.W 0x33D2,0xF736,0x187C,0xFEC2,0x8816,0x3B7C,0x33D2,0xF736 DC.W 0x1A7C,0x8816,0x2A7C,0xA339,0x7CC3,0xB402,0x8B16,0x397C DC.W 0xB106,0xD2E6,0x0A36,0x3B7C,0x8BCA,0x86E9,0x8A16,0xFD7D DC.W 0x8A36,0x2A7C,0xCD13,0xC30D,0x0A4E,0x6F6E,0x2D53,0x7973 DC.W 0x7465,0x6D20,0x6469,0x736B,0x206F,0x7220,0x6469,0x736B DC.W 0x2065,0x7272,0x6F72,0x0D0A,0x5265,0x706C,0x6163,0x6520 DC.W 0x616E,0x6420,0x7374,0x7269,0x6B65,0x2061,0x6E79,0x206B DC.W 0x6579,0x2077,0x6865,0x6E20,0x7265,0x6164,0x790D,0x0A00 DC.W 0x0D0A,0x4469,0x736B,0x2042,0x6F6F,0x7420,0x6661,0x696C DC.W 0x7572,0x650D,0x0A00,0x4942,0x4D42,0x494F,0x2020,0x434F DC.W 0x4D49,0x424D,0x444F,0x5320,0x2043,0x4F4D,0x0000,0x0000 DC.W 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x55AA } WORD buf[5000]; main() { register WORD *p; int i, j, virgin, five, tracks, drive; long a, b, magic; Cconws("\033E\r\n\n\tMS-DOS compatible disk formatter, v1.1"); Cconws("\r\n\n\tEnter size of disk (3/5): "); i = Cnecin(); if (i == '5') { five = 1; tracks = 40; drive = 1; } else { five = 0; tracks = 80; drive = 0; } /* format all tracks */ if (five) Cconws("\r\n\n\tAbout to >> FORMAT << 5.25\" disk in drive B."); else Cconws("\r\n\n\tAbout to >> FORMAT << 3.5\" disk in drive A."); Cconws("\r\n\n\t\tProceed (y/n)? "); i = Cnecin(); if (i!='y' && i!='Y') exit(0); Cconws("\r\n\n\tFormatting"); magic = 0x87654321; virgin = 0xE5E5; for (i=0; i<tracks; i++) { /* tracks */ if (five || (i&1)) Cconout('.'); for (j=0; j<2; j++) { /* sides */ if (Flopfmt(buf,0L,drive,9,i,j,1,magic,virgin)) { Cconws("\r\n\nError formatting track "); Cconout((i/10) + '0'); Cconout((i%10) + '0'); Cconws(" (decimal) on side "); Cconout(j+'0'); Cconws("!\r\n"); goto bye; } } } /* Boot sector, FAT and root directory */ for (i=0; i<2304; i++) /* one track */ buf[i] = 0; if (five) j = 2; else j = 9; a = Flopwr(buf, 0L, drive, 1, 0, 1, j); if (five) { buf[256] = 0xFDFF; /* start of first FAT */ buf[257] = 0xFF00; buf[768] = 0xFDFF; /* start of second FAT */ buf[769] = 0xFF00; p = (WORD *) &boot5; } else { buf[256] = 0xF9FF; buf[257] = 0xFF00; buf[1536] = 0xF9FF; buf[1537] = 0xFF00; p = (WORD *) &boot3; } for (i=0; i<256; i++) /* boot sector */ buf[i] = *p++; magic = Random()<<8; /* get a random ID number */ p = (WORD *) &magic; buf[4] = *p++; buf[5] = *p; b = Flopwr(buf, 0L, drive, 1, 0, 0, 9); if (a || b) Cconws("\r\n\n\tError writing root sectors! "); else Cconws("\r\n\n\tDone. Hit any key."); bye: Cnecin(); }