home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SGTOOL12.ARC / EXAMPLES.ARC / SAVECHRS.C < prev    next >
C/C++ Source or Header  |  1993-08-09  |  1KB  |  63 lines

  1. /*
  2. SG C Tools 1.2
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Saves both VDC character sets to a file.
  8.  
  9. Compiled with HI-TECH C 3.09 (CP/M-80).
  10.  
  11. To compile with HI-TECH C and SG C Tools source on same disk use:
  12. C SAVECHRS.C -LC128
  13. */
  14.  
  15. #include <stdio.h>
  16. #include <hitech.h>
  17. #include <vdc.h>
  18.  
  19. void disphelp(void);
  20. void savecharsets(char *FileName);
  21.  
  22. extern ushort vdcCharMem;
  23. extern ushort vdcCharMemSize;
  24.  
  25. main(int argc, char *argv[])
  26. {
  27.   puts("\nSAVECHRS (C) 1993 Steve Goldsmith");
  28.   if (argc == 2)
  29.   {
  30.     savevdc();
  31.     mapvdc();
  32.     savecharsets(argv[1]);
  33.     restorevdc();
  34.   }
  35.   else
  36.     disphelp();
  37. }
  38.  
  39. void disphelp(void)
  40. {
  41.   puts("\nTo save VDC character definitions use:\n");
  42.   puts("SAVECHRS FILENAME.EXT");
  43. }
  44.  
  45. void savecharsets(char *FileName)
  46. {
  47.   uchar  *BufPtr;
  48.   FILE   *CharFile;
  49.  
  50.   if ((CharFile = fopen(FileName,"wb")) != NULL)
  51.   {
  52.     puts("\nCopying VDC character definitions to buffer...");
  53.     BufPtr = memtobufvdc(vdcCharMem,vdcCharMemSize);
  54.     if (BufPtr != NULL)
  55.     {
  56.       printf("Copying buffer to %s...\n",FileName);
  57.       fwrite(BufPtr,sizeof(uchar),vdcCharMemSize,CharFile);
  58.       free(BufPtr);
  59.     }
  60.     fclose(CharFile);
  61.   }
  62. }
  63.