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 / CPM / CPM3 / CCP105P.ARK / PUTCCP.C < prev    next >
Text File  |  1986-10-17  |  2KB  |  105 lines

  1. /*
  2.  * This program installs a CCP onto  a MDK-Format Double Density
  3.  * disk, geting the data from the declared filename.
  4.  * The file's data is transferred directly, not taking into account
  5.  * the 100H "load-offset".
  6.  *
  7.  * The CCP is located in sectors 9-16 (inclusive) of track-1 (4K).
  8.  *
  9.  * Sectors are 0.5K each.
  10.  *
  11.  * Written 9/1986 by Michael D. Kersenbrock
  12.  */
  13.  
  14. #include "c:stdio.h"
  15.  
  16. FILE *Infile;
  17. char Buffer[5000];
  18.  
  19. struct block {
  20.     char funct;
  21.     char areg;
  22.     int  bcreg;
  23.     int  dereg;
  24.     int  hlreg;
  25. } Biospb;
  26.  
  27. main(argc,argv)
  28. int argc;
  29. char *argv[];
  30. {
  31.     register int sector;
  32.     register int temp;
  33.  
  34.     if (argc != 2) {
  35.         Usage();
  36.         exit(1);
  37.     }
  38.  
  39.     if ((Infile=fopen(argv[1],"r")) == NULL ) {
  40.         fprintf(stderr,"\nCan't open file: %s\n",argv[1]);
  41.         Usage();
  42.         exit(2);
  43.     }
  44.  
  45.  
  46.     for (sector = 0 ; sector < 4096  ; sector++) {
  47.         if ((temp= getc(Infile)) == EOF)
  48.             break;
  49.         Buffer[sector] = temp;
  50.     }
  51.     fclose(Infile);
  52.  
  53.     for (sector = 9 ; sector <= 16 ; sector++) {
  54.         /*
  55.          *  Set track number
  56.          */
  57.         bioscall(10,1,0);
  58.  
  59.         /*
  60.          * Set sector number
  61.          */
  62.         bioscall(11,sector,0);
  63.  
  64.         /*
  65.          * Set the dma bank to '1'
  66.          */
  67.         bioscall(28,0,1);
  68.  
  69.         /*
  70.          * Set dma address
  71.          */
  72.         bioscall(12,&Buffer[(sector-9)*512],0);
  73.  
  74.         /*
  75.          * Write sector
  76.          */
  77.         bioscall(14,1,0);
  78.     }
  79. }
  80.  
  81.  
  82. bioscall(number,bc,a)
  83. int number;
  84. int bc;
  85. int a;
  86. {
  87.     Biospb.funct = number;
  88.     Biospb.bcreg = bc;
  89.     Biospb.areg = a;
  90.     return(bdos(0x32,&Biospb));
  91. }
  92.  
  93.  
  94.  
  95. Usage()
  96. {
  97.     fprintf(stderr,"\nUsage: putccp <filename-where-to-get-it>\n");
  98. }
  99. t argc;
  100. char *argv[];
  101. {
  102.     register int sector;
  103.     register int temp;
  104.  
  105.     if (argc