home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / PIPMAG-4.ARC / SAVDISK2.PIP < prev    next >
Encoding:
Text File  |  2019-04-13  |  9.1 KB  |  187 lines

  1.                               The Perils of Peggy
  2.                                    (Part 2)
  3.  
  4.                                       by
  5.  
  6.                                    D.FOWLER2
  7.  
  8.  
  9.         When last we saw our hero, he was diddling Faithful Nurse Stella, 
  10.     while her erstwhile paramour, Dr. Jameson was dallying with her half-
  11.     sister...
  12.  
  13.         Ooops, wrong plot line.
  14.  
  15.         Let's see.  In our last, suspense laden episode Peggy, the Light of 
  16.     my Life, had lost her camp alumnae newsletter in a litter of tumbled
  17.     bits and bytes.  Our dauntless disk diver had descended into the
  18.     dolorous deeps in a desperate dip to discern the dimensions of the
  19.     disastrous debacle.
  20.  
  21.         Oh oh.  Watch that alliteration.
  22.  
  23.         Anyway, it turned out, at the very least, that the directory track 
  24.     was succotash.
  25.  
  26.         Reentering the data was feasible, but not practical.  Much of it 
  27.     had been painstakingly extracted from letters and journals sent to
  28.     Peggy by her Faithful Friends.  Time, for our delectable heroine, was
  29.     in short supply.  The deadline was bearing down on her like a runaway
  30.     D&H locomotive.  She was in the midst of three big projects.
  31.  
  32.         It was all up to me.  I was going to have to troll the briney deeps 
  33.     for those files.
  34.  
  35.         The first thing I had to do was to see if they were still there. 
  36.     Using DU, unrolling a metaphorical string behind me so I could find my
  37.     way back out, I tip-toed delicately through the disk to see what lurked
  38.     in the labyrinth.
  39.  
  40.         A few spot checks revealed that (so far) the damage was limited to 
  41.     the directory track.  Everything else looked sound.
  42.  
  43.         But the files were scattered in bits and pieces all over the place. 
  44.     That, of course, is the way a computer works.  It looks for the first
  45.     free space in which to put a file.  If the space isn't big enough to
  46.     take the whole file, it'll stick a bit there, another piece in the next
  47.     available slot, and log in the directory where the bits and pieces are
  48.     located.
  49.  
  50.         Complicating the hunt, Peggy's single largest file had been worked 
  51.     on several times.  Pieces of old versions lurked as decoys amongst the
  52.     new.  To DU and me they all looked the same.  Adding to the confusion
  53.     were fragments of even older files mouldering like the mummies in
  54.     Raiders of the Lost Ark, files that had long ago been erased (marked on
  55.     the directory track as no longer needed, freeing up the space for re-
  56.     use) but still on the disk.  Well, I consoled myself, at least the data
  57.     was still there.
  58.  
  59.         So, I dug out a rusty old spear from my armory called DOCTOR.COM.
  60.     (I think I got it from a buddy way back in his TRS 80 days.  And we
  61.     know how long ago THAT was!)  The Old Physician was supposed to be able
  62.     to copy, track by track, from a damaged disk to a fresh one.  He was
  63.     not supposed to unscramble the scrambled track, but it would (I hoped)
  64.     give me a backup disk to muck around in without risking the main disk.
  65.  
  66.         Sadly, either senility had weakened his healing skills, or else a
  67.     Grue got the good DOCTOR.  He plodded along until he hit Track 28 and
  68.     then started myopically insisting he was getting "Hard Errors."  DU had
  69.     already told me track 28 was in perfect shape.  So much for DOCTOR.
  70.  
  71.         Obviously it was time to update my armament.  Trashed disks being a 
  72.     common hazard, the CP/M software library on GEnie had a half dozen
  73.     utilities to deal with the problem.  I took a chance on a couple, and
  74.     added the updated version (8.9) of DU to my shopping list.
  75.  
  76.         After downloading, un-librarying and uncrunching and the like, 
  77.     I studied what I had.
  78.  
  79.         DIRREP21, it turned out, was useful only if you had made a backup
  80.     copy of your directory ahead of time.  So much for THAT one.
  81.  
  82.         REPAIR.COM's documentation said it could be used to recover from a
  83.     trashed directory by allowing me to assemble the file fragments and
  84.     move them to a new disk under new names.  Just what I needed!  So, I
  85.     printed out its documentation (only 2 pages, and reasonably lucid),
  86.     cranked it up and told it to go to work on the disk in drive B.
  87.  
  88.         Over the years I have heard my TEAC disk drives make many different
  89.     sounds.  They whir.  They purr softly.  They grunt, chuckle and clack.
  90.     Sometimes I get a disk that ticks.  Nice, workman-like sounds.
  91.  
  92.         Drive B sounded off like a coffee grinder encountering a pound of
  93.     rivets.  I dislocated my elbow reaching for the reset button.
  94.  
  95.         So much for THAT program.  I frisbeed the disk across the room.  If
  96.     the window had been open it would have wound up in the pond.
  97.  
  98.         I was left with only that one copy of the lost files to work on, 
  99.     and my new, improved, turbo-charged, tail-finned and chrome trimmed
  100.     version of DU.  Like it or not, I was being upgraded from the band-aid
  101.     and iodine division into open skull neuro-surgery.
  102.  
  103.         DU has a raft of talents in addition to showing what is in each
  104.     sector on a disk.  A list, with minimal explanation, of DU's commands
  105.     would take up two single spaced pages.
  106.  
  107.         For one thing, you can use it to change individual bytes.  Just for
  108.     fun I've used it to change WordStar's opening menu to be more cheery on
  109.     a bleary morning.  Hacker fun.
  110.  
  111.         Theoretically, by plugging the right bytes in, I could re-construct
  112.     the ruined Directory Track that was the source of all our problems.
  113.     All I needed was an intimate understanding of how addresses are coded,
  114.     and to determine the address of every piece of every needed file on the
  115.     disk.
  116.  
  117.         Now, the former I understand (I think).  Files are stored in Groups
  118.     (identified by hexadecimal numbers) of eight Sectors.  There are ten    
  119.     sectors per track, and 40 tracks on a single sided disk (which this 
  120.     was).  And then there's something called Logical Extents, and ....
  121.     Well, you get the idea.  And hey, we're talking getting addresses for
  122.     fragments of files scattered in 128 (hexadecimal) groups over only 400
  123.     (decimal) sectors.  And of course, if I messed up ....
  124.  
  125.         I didn't waste much time on that approach.
  126.  
  127.         An alternative was to suck a sector of file at a time up into RAM
  128.     (another of DU's talents) and then unload it on to a new disk.  A
  129.     sector holds 128 bytes, about one long sentence.  Of course, I had no
  130.     idea just how big any of the files were supposed to be.  Fortunately,
  131.     files are stored in a logical numerical sequence.  DU's (M)ap command
  132.     gave me a chart of the group numbers under which the files might be
  133.     stored, but the map came from the bad directory track.
  134.  
  135.         Ah hmmm.  And I thought Exxon had trouble in Prince William Sound.
  136.  
  137.         Well, there seemed nothing to do but to go for it.  I could tell DU
  138.     to go to a Group (the G command), (Y)ank it Sector by Sector into
  139.     memory, then (L)og on to a new disk in drive A and (S)ave it.  Tedious
  140.     and painstaking, but feasible.
  141.  
  142.         And anyway, it was the only avenue still open to me.
  143.  
  144.         I automated the pickup stage by stacking DU's commands: D (to
  145.     display one sector); Z20 (take a nap for two seconds, Turkey, so I can
  146.     read the display); then, unless I stop you, (Y)ank it into RAM; + (step
  147.     forward one sector); and repeat (/).  The whole command looked like
  148.     this:
  149.  
  150.                   D;Z20;Y;+;/.
  151.  
  152.         As you've no doubt acutely observed, DU uses the semi-colon to
  153.     separate commands.  To speed the process up I tried Z10, but things
  154.     moved by too fast, making me dizzy.
  155.  
  156.         By keeping track of the sectors before they were slurped up, I
  157.     hoped to hit "C" to stop the process when I reached the end of that
  158.     section of the file and before I ran out of runway.
  159.  
  160.         Once I got a chunk of file in RAM, I would give it a name and
  161.     unload it on to a brand new disk.  Since not all the groups holding the
  162.     file were contiguous, I would wind up with each one of Peggy's files in
  163.     several little heaps, but, if I was lucky, at least it would all be
  164.     there - I hoped.  I was still flying partly blind, thanks to the
  165.     unreliable map off the directory track.
  166.  
  167.         Well, there was nothing to do but take a deep breath, and go
  168.     for it.
  169.  
  170.         Mirabile Dictu!  It worked!  I looked on the new disk and, Captain,
  171.     there be files here!
  172.                                          
  173.         The battle was more than half won.  Next I simply used my text
  174.     editor (VDE, of course) to check the heaps out and reassemble them in
  175.     the right order.
  176.  
  177.         The patient was in surgery for about 6 hours, but after a full data
  178.     transplant he made a complete recovery.
  179.  
  180.         Backing up your data is like fastening your seat belt when you get
  181.     behind the wheel -- you should always do it.  Two minutes spent backing
  182.     up those files in the first place would have avoided the whole problem.
  183.     But then, I wouldn't have had anything to write about for the last two
  184.     months, either.
  185.  
  186.                              Keep the Faith, fans.
  187.