home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / SURVIVALKIT1.SFX / help.xmodem-pad < prev    next >
Encoding:
Text File  |  1993-06-30  |  5.6 KB  |  108 lines

  1.  
  2.  
  3. Date: 930626
  4.  
  5. File: Xmodem Padding
  6.  
  7.  
  8. XMODEM Padding, How to deal with it!
  9. ====================================
  10.  
  11. So, Bunky, you've plugged into the telecom world.  You've downloaded a slew
  12. of really nifty programs and you're ready to roll!  Well, I really hate to tell
  13. you this, but there could be a GOTCHA in your way.  Who said life was fair?
  14.  
  15. The GOTCHA!
  16. ----------
  17.  
  18. The GOTCHA involves programs and XMODEM padding.  They sometimes don't get
  19. along at all.  The culprit here is the XMODEM protocol.  Remember, XMODEM was
  20. developed for CP/M systems, and it works fine on MS-DOS systems too. Trouble
  21. is, XMODEM only deals in 128-byte or 1024-byte blocks.  What happens when
  22. someone transmits a file that doesn't happen to be a multiple of 128/1024
  23. bytes?  Simple... XMODEM sticks padding on the end of the last block. This is
  24. the (in)famous XMODEM padding we all know and love.  The padding character is
  25. usually a NULL (a CHR$(0)) or control Z (a CHR$(26)), depending on the phase of
  26. the moon and the biorhythms of the programmer who wrote that particular
  27. implementation of XMODEM.
  28.  
  29. Most programs you download simply ignore the extra data at the end.  A very few
  30. (some machine language files and BASIC-64 and BASIC-128 compiled programs)
  31. depend on the end of the file being the LAST thing in memory.  With the extra
  32. XMODEM bytes at the end, these programs will go off to never-never land when
  33. RUN.
  34.  
  35. So how do we deal with padding?  Several ways.
  36.  
  37. 1) Download only ARC, SDA or SFX files.  ARC and SDA save the original file
  38. length as part of the file description and the padding never gets applied to an
  39. individual file.  However, this is the "chicken" way out and you'll end up
  40. missing some WONDERFUL programs!
  41.  
  42. 2) Use a terminal program that automatically strips off Xmodem padding from a
  43. file.  A few terminals will attempt to do this as the program downloads.  If it
  44. is successful, you'll never even SEE padding on a file.  This is a good choice,
  45. but it really limits you to your choices of terminal programs to use.  Most of
  46. the better terms don't attempt to chop off padding on the fly. WIZARD will
  47. perform this stripping automatically.
  48.  
  49. 3) Strip it off yourself, if you find you have to.  It's really pretty easy
  50. and just takes a short while.  After you've done it once or twice, it's no
  51. trouble at all.
  52.  
  53. There are several methods of stripping off Xmodem padding.  The simplest is to
  54. use a "padding stripper" program.  There are a couple here in the Commodore
  55. software libraries that allow you to easily remove the padding (CNTRL-Z's) from
  56. any file you choose.
  57.  
  58.  
  59. Another option is to use program that "edits" a section of memory.  One of the
  60. easiest is built right into Bob's Term Pro 64 and 128.  Simply load the program
  61. into the buffer.  Using the cursor controls, move to the very end of the file.
  62. If there is padding on the file it will usually be CHR$(26) or CHR$(0)
  63. characters.  CAUTION: Don't confuse xmodem padding with the normal end of a
  64. BASIC program.  All BASIC programs end with 3 CHR$(0) characters.  Since 99% of
  65. the padding you will encounter will be CHR$(26) this won't be a problem (just
  66. something to keep in mind SHOULD it pop up!)  Now, you're at the end and have
  67. located the padding.  Simply delete those extra characters and save the file to
  68. disk.  You should save it under a different filename from the original in case
  69. you make a mistake.  That way you won't nuke your only copy!
  70.  
  71. What happens if the file is too big to fit in your editor's buffer?  If you are
  72. using Bob's Term, just fill the buffer with the file you are checking, then
  73. write it back to disk with a different filename.  Then, load the 2nd half into
  74. the buffer with the FILL FROM BYTE command from the FILL menu.  You'll want to
  75. begin at the byte you left off on (which is the number shown as the size of the
  76. buffer when empty...28500 for the 64 version if I remember correctly).  Now
  77. when the 2nd half loads, you can scroll thru like usual, and delete the padding
  78. bytes at the end.  Then DUMP to DISK with the same filename as the first buffer
  79. save. It will tell you the filename is duplicate, and ask if you want to
  80. Replace or Append.  Just Append!  Your file will be restored to it's original
  81. size, less the padding!  (It's the same procedure that's used to split up great
  82. big SEQ files into something a little more manageable)!
  83.  
  84. A final option is to use a "sector editor" and edit the file directly on the
  85. disk.  While this is a perfectly valid option, it does require a little
  86. knowledge of disk data formats and a firm grasp of the hexadecimal numbering
  87. system.  Once you have your favorite sector editor fired up, move to the end of
  88. the file you need to strip.  On that last block the second byte in the file is
  89. the number of valid data bytes in this block.  Just locate and count the number
  90. of padding bytes and subtract this from the number of bytes in the block (the
  91. 2nd data byte on this disk block).  Change the byte and write the sector back
  92. to the disk.  If you use this method, BE SURE OF WHAT YOU ARE DOING!  Always
  93. work on a backup disk or you could easily destroy valid data in the sector you
  94. are working on or elsewhere on the disk.
  95.  
  96.  
  97. One redeeming factor.  Virtually all the files that have problems with Xmodem
  98. padding will be ARCed or in SDA format here in the Commodore RoundTable.  (One
  99. of the jobs of a SysOp is to watch out for these little buggers and head off
  100. problems BEFORE they get to you!)  Since ARC knows the proper size and stores
  101. it as part of the ARChive,padding is NEVER a problem if you have downloaded an
  102. ARC or SDA/SFX file.
  103.  
  104.  
  105.     ###############################
  106.        Back To Survival Kit Menu!
  107.     ###############################
  108.