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 / LOADCHRS.C < prev    next >
C/C++ Source or Header  |  1993-08-09  |  1KB  |  65 lines

  1. /*
  2. SG C Tools 1.2
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Loads both VDC character sets from a binary 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 <stdlib.h>
  17. #include <hitech.h>
  18. #include <vdc.h>
  19.  
  20. void disphelp(void);
  21. void loadcharsets(char *FileName);
  22.  
  23. extern ushort vdcCharMem;
  24. extern ushort vdcCharMemSize;
  25.  
  26. main(int argc, char *argv[])
  27. {
  28.   puts("\nLOADCHRS (C) 1993 Steve Goldsmith");
  29.   if (argc == 2)
  30.   {
  31.     savevdc();
  32.     mapvdc();
  33.     loadcharsets(argv[1]);
  34.     restorevdc();
  35.   }
  36.   else
  37.     disphelp();
  38. }
  39.  
  40. void disphelp(void)
  41. {
  42.   puts("\nTo load VDC character definitions use:\n");
  43.   puts("LOADCHRS FILENAME.EXT");
  44. }
  45.  
  46. void loadcharsets(char *FileName)
  47. {
  48.   uchar  *BufPtr;
  49.   FILE   *CharFile;
  50.  
  51.   if ((CharFile = fopen(FileName,"rb")) != NULL)
  52.   {
  53.     BufPtr = (uchar *) malloc(vdcCharMemSize);
  54.     if (BufPtr != NULL)
  55.     {
  56.       printf("\nCopying %s to buffer...\n",FileName);
  57.       fread(BufPtr,sizeof(uchar),vdcCharMemSize,CharFile);
  58.       puts("Copying buffer to VDC...");
  59.       buftomemvdc(BufPtr,vdcCharMem,vdcCharMemSize);
  60.       free(BufPtr);
  61.     }
  62.     fclose(CharFile);
  63.   }
  64. }
  65.