home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / EXTRA-ST / CPM-80-E / CPM-0.2 / CPM-0 / cpm-0.2 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-21  |  3.2 KB  |  103 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    CP/M emulator version 0.1                         */
  5. /*                                         */
  6. /*    written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  7. /*    June-1994                                 */
  8. /*                                         */
  9. /*    This file is distributed under the GNU COPYRIGHT             */
  10. /*    see COPYRIGHT.GNU for Copyright details                     */
  11. /*                                         */
  12. /*                                         */
  13. /*****************************************************************************/
  14. #include "cpmemu.h"
  15. #include <unistd.h>
  16.  
  17. int debug = 0;
  18. int prompt = 1;
  19. int bdos_emulate = 1;    /* default = ON */
  20. int silent_exit = 0;
  21. int restricted_mode = 0;
  22. int hardware_access = 0;
  23. jmp_buf mainloop;
  24.  
  25. int main(int argc, char *argv[]) {
  26.     int i;
  27.     const char *systemfile = "/usr/local/lib/cpm/cpm.sys";
  28.     const char *load_file = NULL;
  29.     const char *cpmtty = NULL;
  30.     const char *startdir = NULL;
  31.     /* which disk to use? */
  32.     const char *imagefile = "/dev/fd1";    /* use setfdprm to set 10 sectors/track */
  33.     /* when setting dpb, you may ignore the fields BLM, EXM, AL0, and AL1. They are set by bios.c */
  34.     static struct dpb dpb0 = { 80, 4, 15, 0, 394, 255, 0xf0, 0x00, 64, 1 };
  35.  
  36.     for (i = 1; i < argc; ++i) {
  37.     if (!strcmp(argv[i], "-?") || !strcmp(argv[i], "-h")) {
  38.         fprintf(stderr, "usage: cpm [options] CP/M-command\n"
  39.             "where options are\n"
  40.             "-h or -?        display this message\n"
  41.             "-s (systemfile) use a different CCP/BDOS\n"
  42.             "-i (imagefile)  use a different Cp/M disk image\n"
  43.             "-p              no debugging prompt (for batch)\n"
  44.             "-d              enter debugging mode\n"
  45.             "-e              do not emulate BDOS (use imagefile)\n"
  46.             "-t (tty)        use (tty) for Cp/M console\n"
  47.             "-r              restricted mode: do not allow changing directories\n"
  48.             "-D (dir)        specify starting directory\n"
  49.             "-d              enter debugging mode at start\n"
  50.             "Note: Pressing ctrl-@ will enter the debugger\n");
  51.         exit(1);
  52.     } else if (!strcmp(argv[i], "-d"))
  53.         debug = 1;
  54.     else if (!strcmp(argv[i], "-e"))
  55.         bdos_emulate ^= 1;
  56.     else if (!strcmp(argv[i], "-r"))
  57.         restricted_mode ^= 1;
  58.     else if (!strcmp(argv[i], "-p"))
  59.         prompt = 0;
  60.     else if (!strcmp(argv[i], "-H"))
  61.         hardware_access = 1;    /* must be root to use this! */
  62.     else if (!strcmp(argv[i], "-t"))
  63.         cpmtty = argv[++i];
  64.     else if (!strcmp(argv[i], "-l"))
  65.         load_file = argv[++i];
  66.     else if (!strcmp(argv[i], "-s"))
  67.         systemfile = argv[++i];
  68.     else if (!strcmp(argv[i], "-D"))
  69.         startdir = argv[++i];
  70.     else if (!strcmp(argv[i], "-i"))
  71.         imagefile = argv[++i];
  72.     else
  73.         break;
  74.     }
  75.  
  76.     /* setup BIOS part of memory image */
  77.     if (hardware_access)
  78.     lowlevel_init();
  79.     cpm_init(imagefile, systemfile, &dpb0);
  80.     setup_io(cpmtty);        /* setting I/O to no-echo */
  81.     if (load_file)
  82.     loadfile(load_file);
  83.     cpminit2(argc-i, argv+i);
  84.     if (startdir)
  85.     if (chdir(startdir)) {
  86.         fprintf(stderr, "Cannot change directory to %s\n", startdir);
  87.         exit(1);
  88.     }
  89.     for (;;) {
  90.     while (setjmp(mainloop))
  91.         ;
  92.     if (debug) {
  93.         debug = 1;
  94.         commandloop();
  95.     } else {
  96.         z80run();    /* run until trap */
  97.         debug = 1;
  98.         /* break; */
  99.     }
  100.     }
  101.     return 0;
  102. }
  103.