home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / SGTOOL16.ARC / LIBC128.ARC / VDCPCX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-27  |  1.3 KB  |  63 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 vdc. */
  22.  
  23. void decodelinepcx(ushort X, ushort Y)
  24. {
  25.   register uchar KeyByte, RunCnt;
  26.   register ushort DecodeCnt = 0;
  27.   register ushort DispOfs;
  28.  
  29.   DispOfs = Y*vdcScrHorz+vdcDispMem+X;
  30.   outvdc(vdcUpdAddrHi,(uchar) (DispOfs >> 8));
  31.   outvdc(vdcUpdAddrLo,(uchar) DispOfs);
  32.   do
  33.   {
  34.     KeyByte = fgetc(pcxFile) & 0xFF;
  35.     if ((KeyByte & 0xC0) == 0xC0)
  36.     {
  37.       RunCnt = KeyByte & 0x3F;
  38.       KeyByte = fgetc(pcxFile);
  39.       outvdc(vdcVtSmScroll,(invdc(vdcVtSmScroll) & 0x7F));
  40.       outvdc(vdcCPUData,KeyByte);
  41.       if (RunCnt > 1)
  42.         outvdc(vdcWordCnt,RunCnt-1);
  43.       DispOfs += RunCnt;
  44.       DecodeCnt += RunCnt;
  45.     }
  46.     else
  47.     {
  48.       outvdc(vdcCPUData,KeyByte);
  49.       DispOfs++;
  50.       DecodeCnt++;
  51.     }
  52.   }
  53.   while(DecodeCnt < pcxHeader.BytesPerLine);
  54. }
  55.  
  56. void decodefilepcx(ushort X, ushort Y)
  57. {
  58.   register short I;
  59.  
  60.   for (I = 0; I < pcxYSize; I++, Y++)
  61.     decodelinepcx(X,Y);
  62. }
  63.