home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / hard_prj / flop14st / hdflop.4 < prev   
Text File  |  1993-07-01  |  5KB  |  130 lines

  1. Atari ST High Density Disk Drives - Part 2
  2.  
  3. /* formath.c Formatter fuer High Density Disketten */
  4. /* nur fuer angepasste Hardware! Floppycontroller und Laufwerk */
  5. /* muessen High-Density tauglich sein! */
  6. /* Hartmut Semken, Lupsteiner Weg 67 1000 Berlin 37 */
  7. /* hase@hase_1.mbx.sub.org or hase@netmbx.mbx.sub.org */
  8. /* 03-SEP-89 */
  9. #include <stdio.h>
  10. #include <osbind.h>
  11. #include <time.h>
  12.  
  13. #define SLEEPTIME 1     /* 1: Zeitschleife, 0: Taste */
  14. #define BLANK (0xE5E5)
  15. #define MAGIC (0x87654321L)
  16. #define BUFSIZE (20*1024) /* Platz fuer mehr als 18 Sektoren... */
  17.  
  18. #define DEVICE 0        /* 0 = Floppy A, 1 = Floppy B   */
  19. #define SIDES 2         /* je                           */
  20. #define SECTORS 18      /* nach                         */
  21. #define TRACKS 80       /*Belieben                      */
  22.  
  23. #define TOTSEC (TRACKS * SIDES * SECTORS)
  24.  
  25. extern int errno;
  26.  
  27. main()?
  28.         int track;
  29.         int side;
  30.         int status;
  31.         short *bf;
  32.         register char reply;
  33.         short *middle;
  34.         char buffer[512];
  35.  
  36.         printf("\033E\n");
  37.         printf("Public Domain High Density Mini Formatter\n");
  38.         printf("von H. Semken\nDer Autor garantiert in keiner Weise fr die
  39.  Funktion\nDieses Programmes.\nBenutzung auf eigene Gefahr.\n");
  40.         printf("\n\n\n");
  41.         printf("\007\033pFormatiere Diskette in Drive %c\033q\n%d Seiten\n%d Sektoren
  42.  pro Spur\n%d Spuren\n\n", (65+DEVICE), SIDES, SECTORS, TRACKS);
  43.         printf("Wirklich formatieren? ");
  44.         fflush(stdout);
  45.         if ((reply = Crawcin()) != 'y' && reply != 'Y' && reply != 'j' && reply != 'J')
  46.  ?
  47.                 printf("Nein. Floppy nicht formatiert.\n");
  48.                 sleep(1);
  49.                 Pterm0();
  50.         ?
  51.         printf("Ja.\n");
  52.         printf("Diskette einlegen; Taste drcken...");
  53.         fflush(stdout);
  54.         Crawcin();
  55.         printf("\n");
  56.         bf = malloc(BUFSIZE);
  57.         for (track = TRACKS-1; track >= 0; track--) ?
  58.                 for (side = 0; side < SIDES; side++) ?
  59.                         printf("Formatiere Spur %d, Seite %d", track, side);
  60.                         fflush(stdout);
  61.                         status = Flopfmt(bf, 0L, DEVICE, SECTORS, track, side, 1, MAGIC, BLANK);
  62.                         if (status) ?
  63.                                 middle = bf;
  64.                                 printf("\t%d\n", status);
  65.                                 while (*middle) ?
  66.                                         printf("\tDefekter Sektor %d\n", *middle++);
  67.                                 ?
  68.                         ? else ?
  69.                                 printf("\tokay\r");
  70.                         ?
  71.                 ?
  72.         ?
  73.         printf("\n\nAlle Spuren formatiert\n");
  74.         printf("Initialisiere Directory\n");
  75.         for (track = 0; track < (BUFSIZE>>1); bf[track++] = 0);
  76.         for (track = 0; track < 2;track++) ?
  77.                 for (side = 0; side < SIDES; side++)?
  78.                 if (status = Flopwr(bf, 0L, DEVICE, 1, track, side, SECTORS)) ?
  79.                         errno = -status;
  80.                         perror("Write Error");
  81.                 ?
  82.                 ?
  83.         ?
  84.         Protobt(buffer, (long)Random(),3,0); /* Prototyp Bootsector fr
  85.                                               * 80 * 2 * 9 Sektoren */
  86.         /* Prototyp Bootsektor fr das neue Format anpassen */
  87.         /* Bytes 19 und 20 enthalten die Sektoren pro Disk */
  88.  
  89.         /* unteres Byte von TOTSEC */
  90.         buffer[19] = (char)(((TOTSEC>>8)<<8)~TOTSEC);
  91.         /* oberes Byte von TOTSEC; es lebe das Intel int-Format */
  92.         buffer[20] = (char)(TOTSEC>>8);
  93.         buffer[24] = (char)SECTORS; /* Sektoren pro Spur */
  94.         status = Flopwr(buffer, 0L, DEVICE, 1, 0, 0, 1);
  95.         if (status) ?
  96.                 errno = -status;
  97.                 perror("Write Error (Bootsector)");
  98.         ?
  99.         status = Flopver(buffer, 0L, DEVICE, 1, 0, 0, 1);
  100.         if (status) ?
  101.                 errno = -status;
  102.                 perror("Verify Error (Bootsector)");
  103.         ?
  104.         printf("Diskette in Laufwerk %c formatiert\n", (65+DEVICE));
  105.         sleep(1);
  106.         Pterm0();
  107. ?
  108.  
  109. sleep(seconds)
  110. int seconds;
  111. #if SLEEPTIME
  112. ?
  113.         clock_t t;
  114.         for(t = clock();clock() < (t + CLK_TCK*seconds););
  115. ?
  116. #else
  117. ?
  118.         printf("Taste druecken\n");
  119.         fflush(stdout);
  120.         Crawcin();
  121. ?
  122. #endif
  123. --
  124. Hartmut Semken, Lupsteiner Weg 67, 1000 Berlin 37 hase@hase_1.UUCP
  125. Dennis had stepped up into the top seat whet its founder had died of a
  126. lethal overdose of brick wall, taken while under the influence of a
  127. Ferrari and a bottle of tequila. (Douglas Adams; the long dark teatime...)
  128.  
  129. ------------------------------
  130. ə