home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / cpmsim / srccpm / cpmbin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-11  |  1.1 KB  |  66 lines

  1. /*
  2.  * CP/M 2.2 Converts an CP/M kernel to Mostek binary format
  3.  *
  4.  * Copyright (C) 1990-93 by Udo Munk
  5.  *
  6.  * History:
  7.  * 23-DEZ-90 Development with Coherent 3.0
  8.  * 11-MAR-93 comments in english and ported to COHERENT 4.0
  9.  */
  10.  
  11. #include <stdio.h>
  12. #if defined(COHERENT) && !defined(_I386)
  13. #include <sys/fcntl.h>
  14. #else
  15. #include <fcntl.h>
  16. #endif
  17.  
  18. /*
  19.  *    This program converts a CPMxx.COM file, which was created
  20.  *    with MOVCPM, into a Mostek binary, that can be written to
  21.  *    the system tracks of the boot disk with putsys.
  22.  */
  23.  
  24.  
  25. char buf[128];
  26.  
  27. main(argc, argv)
  28. int argc;
  29. char *argv[];
  30. {
  31.     int in, out;
  32.  
  33.     if (argc != 2) {
  34.         puts("usage: cpmbin infile");
  35.         exit(1);
  36.     }
  37.  
  38.     if ((in = open(argv[1], O_RDONLY)) == -1) {
  39.         perror(argv[1]);
  40.         exit(2);
  41.     }
  42.  
  43.     if (creat("cpm.bin", 0644) == -1) {
  44.         perror("cpm.bin");
  45.         exit(3);
  46.     }
  47.  
  48.     if ((out = open("cpm.bin", O_WRONLY)) == -1) {
  49.         perror("cpm.bin");
  50.         exit(4);
  51.     }
  52.  
  53.     memset(buf, 0, 128);
  54.     buf[0] = 0xff;
  55.     write(out, buf, 3);
  56.     buf[0] = 0x00;
  57.     write(out, buf, 128);
  58.     write(out, buf, 128);
  59.     while (read(in, buf, 128) != 0)
  60.         write(out, buf, 128);
  61.  
  62.     close(out);
  63.     close(in);
  64.     exit(0);
  65. }
  66.