home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDXPCH / PART.BAK < prev    next >
Encoding:
Text File  |  2001-02-09  |  1.5 KB  |  102 lines

  1. /* part.c */
  2.  
  3.  
  4. /*
  5.  * 24-Nov-88    jye.     change and add codes so that can be used for MS-DOS
  6.  */
  7. #include "obdefs.h"
  8. #include "gemdefs.h"
  9. #include "osbind.h"
  10. #include "mydefs.h"
  11. #include "part.h"
  12. #include "bsl.h"
  13. #include "hdxpch.h"
  14. #include "addr.h"
  15.  
  16.  
  17.  
  18. /*
  19.  * Force checksum of sector image to a value
  20.  */
  21. forcesum(image, sum)
  22. UWORD *image;
  23. UWORD sum;
  24. {
  25.     register int i;
  26.     register UWORD w;
  27.  
  28.     w = 0;
  29.     /* up limit is half of buffer size - 2 */
  30.     for (i = 0; i < ((UWORD)BPS/2 - 1); ++i)
  31.     w += *image++;
  32.     *image++ = sum - w;
  33. }
  34.  
  35.  
  36. /*
  37.  * Put word in memory in 8086 byte-reversed format.
  38.  *
  39.  */
  40. iw(wp, w)
  41. UWORD *wp;
  42. UWORD w;
  43. {
  44.     char *p;
  45.  
  46.     p = (char *)wp;
  47.     p[0] = (w & 0xff);
  48.     p[1] = ((w >> 8) & 0xff);
  49. }
  50.  
  51. /*
  52.  * Put long word in memory in 8086 word-reversed format.
  53.  *
  54.  */
  55. ilong(lp, l)
  56. long *lp;
  57. long l;
  58. {
  59.     UWORD *p;
  60.  
  61.     p = (UWORD *)lp;
  62.     iw(&p[0],(UWORD)(l & 0xffff));
  63.     iw(&p[1],(UWORD)((l >> 16) & 0xffff));
  64. }
  65.  
  66. /*
  67.  * Get long word in memory, from 8086 word-reversed format.
  68.  *
  69.  */
  70. glong(al, lp)   /* al is a swaped return long word,*/
  71.                 /* lp is a to be swaped long word */
  72. long *al;
  73. long *lp;
  74.  
  75. {
  76.    char *p, *q;
  77.  
  78.     p = (char *)al;
  79.     q = (char *)lp;
  80.     p[0] = q[3];
  81.     p[1] = q[2];
  82.     p[2] = q[1];
  83.     p[3] = q[0];
  84. }
  85.  
  86. /*
  87.  * Get word in memory, from 8086 byte-reversed format.
  88.  *
  89.  */
  90. UWORD gw(wp, aw)
  91. UWORD *wp;
  92. UWORD *aw;
  93. {
  94.     char *p, *q;
  95.  
  96.     p = (char *)wp;
  97.     q = (char *)aw;
  98.     q[0] = p[1];
  99.     q[1] = p[0];
  100.     return *aw;
  101. }
  102.