home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SGTOOL16.ARC / LIBC128.ARC / VDCPCXI.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-27  |  1.4 KB  |  72 lines

  1. /*
  2. SG C Tools 1.6
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Compiled with HI-TECH C 3.09 (CP/M-80).
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <hitech.h>
  12. #include <vdc.h>
  13. #include <pcx.h>
  14.  
  15. extern uchar   vdcScrHorz;
  16. extern ushort  vdcDispMem;
  17. extern FILE    *pcxFile;
  18. extern pcxHead pcxHeader;
  19. extern ushort  pcxYSize;
  20.  
  21. /* decode 2 bit .pcx line to interlace vdc. */
  22.  
  23. void decodelineintpcx(ushort X, ushort Y)
  24. {
  25.   register uchar KeyByte, RunCnt;
  26.   register ushort DecodeCnt = 0;
  27.   register ushort DispOfs;
  28.  
  29.   if ((Y & 1) == 0)
  30.   {
  31.     Y >>= 1;
  32.     DispOfs = Y*vdcScrHorz+vdcDispMem+X;
  33.   }
  34.   else
  35.   {
  36.     Y >>= 1;
  37.     DispOfs = Y*vdcScrHorz+vdcOddFldOfs+vdcDispMem+X;
  38.   }
  39.   outvdc(vdcUpdAddrHi,(uchar) (DispOfs >> 8));
  40.   outvdc(vdcUpdAddrLo,(uchar) DispOfs);
  41.   do
  42.   {
  43.     KeyByte = fgetc(pcxFile) & 0xFF;
  44.     if ((KeyByte & 0xC0) == 0xC0)
  45.     {
  46.       RunCnt = KeyByte & 0x3F;
  47.       KeyByte = fgetc(pcxFile);
  48.       outvdc(vdcVtSmScroll,(invdc(vdcVtSmScroll) & 0x7F));
  49.       outvdc(vdcCPUData,KeyByte);
  50.       if (RunCnt > 1)
  51.         outvdc(vdcWordCnt,RunCnt-1);
  52.       DispOfs += RunCnt;
  53.       DecodeCnt += RunCnt;
  54.     }
  55.     else
  56.     {
  57.       outvdc(vdcCPUData,KeyByte);
  58.       DispOfs++;
  59.       DecodeCnt++;
  60.     }
  61.   }
  62.   while(DecodeCnt < pcxHeader.BytesPerLine);
  63. }
  64.  
  65. void decodefileintpcx(ushort X, ushort Y)
  66. {
  67.   register short I;
  68.  
  69.   for (I = 0; I < pcxYSize; I++, Y++)
  70.     decodelineintpcx(X,Y);
  71. }
  72.