home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / 2.9-derivatives / 2.9bsd4pro350-kcwellsc / tarfiles / rx50ileave.c < prev    next >
C/C++ Source or Header  |  1999-03-13  |  1KB  |  54 lines

  1. /* Written by Warren Toomey. Hacked up in an hour, so this isn't
  2.  * very well written.
  3.  *
  4.  * Undo the RX50 interleaving on stdin, writing disk image to stdout.
  5.  */
  6.  
  7. #include <sys/types.h>
  8. #include <stdio.h>
  9. #include <unistd.h>
  10.  
  11. #define BLKSIZE 512
  12. #define BLKSPERTRACK 10
  13. #define TRACKS 79
  14.  
  15. /* The interleaving is a pattern of 10 tracks and 10 sectors.
  16.  * The table below shows the interleaving. If the current
  17.  * track (mod 10) is t, and the current sector is s, then
  18.  * the next block will be s + iltable[s][t].
  19.  */
  20.  
  21. int iltable[10][10]= {
  22.     { 1, 1, 1, 1, 1, 1, 1, 1, 6, 10 },
  23.     { 1, 1, 1, 1, 1, 1, 6, 10, 1, 1 },
  24.     { 1, 1, 1, 1, 6, 10, 1, 1, 1, 1 },
  25.     { 1, 1, 6, 10, 1, 1, 1, 1, 1, 1 },
  26.     { 1, 10, -4, -4, -4, -4, -4, -4, -4, -4 },
  27.     { 1, 1, 1, 1, 1, 1, 1, -3, 10, 1 },
  28.     { 1, 1, 1, 1, 1, -3, 10, 1, 1, 1 },
  29.     { 1, 1, 1, -3, 10, 1, 1, 1, 1, 1 },
  30.     { 1, -8, 10, 1, 1, 1, 1, 1, 1, 1 },
  31.     { 10, -4, -4, -4, -4, -4, -4, -4, -4, -8 }
  32. };
  33.  
  34.  
  35. main()
  36. {
  37.  char tkbuf[BLKSIZE * BLKSPERTRACK * TRACKS];
  38.  int track;
  39.  int sector;
  40.  int s,t,count;
  41.  
  42.  /* Read the entire disk */
  43.  for (track=0; track<TRACKS; track++) {
  44.    read(0,&tkbuf[track * BLKSIZE * BLKSPERTRACK], BLKSIZE * BLKSPERTRACK);
  45.  }
  46.  
  47.    /* Now output the track in interleave form */
  48.  for (track=0,sector=0, count=0; count<(BLKSPERTRACK*TRACKS); count++) {
  49.    write(1, &tkbuf[BLKSIZE * sector], BLKSIZE);
  50.    t= track % 10; s= sector % 10;
  51.    sector += iltable[s][t]; track= sector / BLKSPERTRACK;
  52.  }
  53. }
  54.