Subversion Repositories SvarDOS

Rev

Rev 206 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 206 Rev 277
Line 522... Line 522...
522
    }
522
    }
523
  }
523
  }
524
}
524
}
525
 
525
 
526
 
526
 
527
/* copy file src into dst, substituting all characters c1 by c2 */
-
 
528
static void fcopysub(const char *dst, const char *src, char c1, char c2) {
-
 
529
  FILE *fdd, *fds;
-
 
530
  int buff;
-
 
531
  fds = fopen(src, "rb");
-
 
532
  if (fds == NULL) return;
-
 
533
  fdd = fopen(dst, "wb");
-
 
534
  if (fdd == NULL) {
-
 
535
    fclose(fds);
-
 
536
    return;
-
 
537
  }
-
 
538
  /* */
-
 
539
  for (;;) {
-
 
540
    buff = fgetc(fds);
-
 
541
    if (buff == EOF) break;
-
 
542
    if (buff == c1) buff = c2;
-
 
543
    fprintf(fdd, "%c", buff);
-
 
544
  }
-
 
545
  /* close files and return */
-
 
546
  fclose(fdd);
-
 
547
  fclose(fds);
-
 
548
}
-
 
549
 
-
 
550
 
-
 
551
static void bootfilesgen(char targetdrv, const struct slocales *locales, char cdromdrv) {
527
static void bootfilesgen(char targetdrv, const struct slocales *locales, char cdromdrv) {
552
  char buff[128];
528
  char buff[128];
553
  char buff2[16];
529
  char buff2[16];
554
  char buff3[16];
530
  char buff3[16];
555
  FILE *fd;
531
  FILE *fd;
Line 558... Line 534...
558
  fd = fopen(buff, "wb");
534
  fd = fopen(buff, "wb");
559
  if (fd == NULL) return;
535
  if (fd == NULL) return;
560
  fprintf(fd, "DOS=UMB,HIGH\r\n"
536
  fprintf(fd, "DOS=UMB,HIGH\r\n"
561
              "LASTDRIVE=Z\r\n"
537
              "LASTDRIVE=Z\r\n"
562
              "FILES=50\r\n");
538
              "FILES=50\r\n");
563
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVARDOS\\BIN\\HIMEMX.EXE\r\n", targetdrv);
539
  fprintf(fd, "DEVICE=%c:\\SVARDOS\\BIN\\HIMEMX.EXE\r\n", targetdrv);
564
  if (strcmp(locales->lang, "EN") == 0) {
540
  if (strcmp(locales->lang, "EN") == 0) {
565
    strcpy(buff, "COMMAND");
541
    strcpy(buff, "COMMAND");
566
  } else {
542
  } else {
567
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
543
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
568
  }
544
  }
569
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVARDOS\\BIN\\%s.COM /E:512 /P\r\n", targetdrv, buff);
545
  fprintf(fd, "SHELLHIGH=%c:\\SVARDOS\\BIN\\%s.COM /E:512 /P\r\n", targetdrv, buff);
570
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\CONF\\COUNTRY.SYS\r\n", targetdrv);
546
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SVARDOS\\CONF\\COUNTRY.SYS\r\n", targetdrv);
571
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
547
  fprintf(fd, "DEVICE=%c:\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
572
  fclose(fd);
548
  fclose(fd);
573
  /*** AUTOEXEC.BAT ***/
549
  /*** AUTOEXEC.BAT ***/
574
  snprintf(buff, sizeof(buff), "%c:\\AUTOEXEC.BAT", targetdrv);
550
  snprintf(buff, sizeof(buff), "%c:\\AUTOEXEC.BAT", targetdrv);
575
  fd = fopen(buff, "wb");
551
  fd = fopen(buff, "wb");
576
  if (fd == NULL) return;
552
  if (fd == NULL) return;
577
  fprintf(fd, "@ECHO OFF\r\n");
553
  fprintf(fd, "@ECHO OFF\r\n");
578
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
554
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
579
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVARDOS\r\n", targetdrv);
555
  fprintf(fd, "SET DOSDIR=%c:\\SVARDOS\r\n", targetdrv);
580
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
556
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
581
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
557
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
582
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
558
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
583
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n", targetdrv);
-
 
584
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n", targetdrv);
559
  fprintf(fd, "SET WATTCP.CFG=%c:\\SVARDOS\\CFG\\WATTCP.CFG\r\n", targetdrv);
585
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%c:\\SYSTEM\\LINKS\r\n", targetdrv);
560
  fprintf(fd, "PATH %%DOSDIR%%\\BIN\r\n", targetdrv);
586
  fprintf(fd, "PROMPT $P$G\r\n");
561
  fprintf(fd, "PROMPT $P$G\r\n");
587
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
562
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
588
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
563
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
589
  fprintf(fd, "FDAPM APMDOS\r\n");
564
  fprintf(fd, "FDAPM APMDOS\r\n");
590
  fprintf(fd, "\r\n");
565
  fprintf(fd, "\r\n");
591
  if (locales->egafile > 0) {
566
  if (locales->egafile > 0) {
592
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
567
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
593
    if (locales->egafile == 1) {
568
    if (locales->egafile == 1) {
594
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVARDOS\\CPI\\EGA.CPX)\r\n", locales->codepage, targetdrv);
569
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SVARDOS\\CPI\\EGA.CPX)\r\n", locales->codepage, targetdrv);
595
    } else {
570
    } else {
596
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVARDOS\\CPI\\EGA%d.CPX)\r\n", locales->codepage, targetdrv, locales->egafile);
571
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SVARDOS\\CPI\\EGA%d.CPX)\r\n", locales->codepage, targetdrv, locales->egafile);
597
    }
572
    }
598
    fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
573
    fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
599
  }
574
  }
600
  if (locales->keybfile > 0) {
575
  if (locales->keybfile > 0) {
601
    if (locales->keybfile == 1) {
576
    if (locales->keybfile == 1) {
Line 606... Line 581...
606
    if (locales->keybid == 0) {
581
    if (locales->keybid == 0) {
607
      buff3[0] = 0;
582
      buff3[0] = 0;
608
    } else {
583
    } else {
609
      snprintf(buff3, sizeof(buff3), " /ID:%d", locales->keybid);
584
      snprintf(buff3, sizeof(buff3), " /ID:%d", locales->keybid);
610
    }
585
    }
611
    fprintf(fd, "KEYB %s,%d,%c:\\SYSTEM\\SVARDOS\\BIN\\%s%s\r\n", locales->keybcode, locales->codepage, targetdrv, buff2, buff3);
586
    fprintf(fd, "KEYB %s,%d,%c:\\SVARDOS\\BIN\\%s%s\r\n", locales->keybcode, locales->codepage, targetdrv, buff2, buff3);
612
    fprintf(fd, "\r\n");
587
    fprintf(fd, "\r\n");
613
  }
588
  }
614
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
589
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
615
  fprintf(fd, "\r\n");
590
  fprintf(fd, "\r\n");
616
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
591
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
Line 618... Line 593...
618
  fprintf(fd, "\r\n");
593
  fprintf(fd, "\r\n");
619
  fprintf(fd, "ECHO.\r\n");
594
  fprintf(fd, "ECHO.\r\n");
620
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to SvarDOS! Type 'HELP' if you need help."));
595
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to SvarDOS! Type 'HELP' if you need help."));
621
  fclose(fd);
596
  fclose(fd);
622
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
597
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
623
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM", targetdrv);
598
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS", targetdrv);
624
  mkdir(buff);
599
  mkdir(buff);
625
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
600
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG", targetdrv);
626
  mkdir(buff);
601
  mkdir(buff);
627
  /*** FDNPKG.CFG ***/
602
  /*** PKG.CFG ***/
628
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
603
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\PKG.CFG", targetdrv);
-
 
604
  fd = fopen(buff, "wb");
-
 
605
  if (fd == NULL) return;
-
 
606
  fprintf(fd, "# pkg config file - specifies locations where packages should be installed\r\n"
-
 
607
              "\r\n"
-
 
608
              "# Programs\r\n"
-
 
609
              "DIR PROGS C:\\\r\n"
-
 
610
              "\r\n"
-
 
611
              "# Games \r\n"
-
 
612
              "DIR GAMES C:\\\r\n"
-
 
613
              "\r\n"
-
 
614
              "# Drivers\r\n"
-
 
615
              "DIR DRIVERS C:\\DRIVERS\r\n"
-
 
616
              "\r\n"
-
 
617
              "# Development tools\r\n"
629
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
618
              "DIR DEVEL C:\\DEVEL\r\n");
-
 
619
  fclose(fd);
630
  /*** COUNTRY.SYS ***/
620
  /*** COUNTRY.SYS ***/
631
  /*** PICOTCP ***/
621
  /*** PICOTCP ***/
632
  /*** WATTCP ***/
622
  /*** WATTCP ***/
633
}
623
}
634
 
624
 
Line 666... Line 656...
666
      case '\r':
656
      case '\r':
667
        pkglist[i] = 0;
657
        pkglist[i] = 0;
668
        break;
658
        break;
669
    }
659
    }
670
  }
660
  }
671
  /* set DOSDIR, TEMP, COMSPEC and FDNPKG.CFG */
661
  /* set DOSDIR and COMSPEC */
672
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVARDOS", targetdrv);
662
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS", targetdrv);
673
  setenv("DOSDIR", buff, 1);
663
  setenv("DOSDIR", buff, 1);
674
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
-
 
675
  setenv("TEMP", buff, 1);
-
 
676
  snprintf(buff, sizeof(buff), "%c:\\COMMAND.COM", targetdrv);
664
  snprintf(buff, sizeof(buff), "%c:\\COMMAND.COM", targetdrv);
677
  setenv("COMSPEC", buff, 1);
665
  setenv("COMSPEC", buff, 1);
678
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
-
 
679
  setenv("FDNPKG.CFG", buff, 1);
-
 
680
  /* copy pkginst to the new drive so it is not read from the floppy each time */
666
  /* copy pkginst to the new drive so it is not read from the floppy each time */
681
  snprintf(buff, sizeof(buff), "COPY A:\\FDINST.EXE %c:\\ > NUL", targetdrv);
667
  snprintf(buff, sizeof(buff), "COPY A:\\PKG.EXE %c:\\ > NUL", targetdrv);
682
  system(buff);
668
  system(buff);
683
  /* change current drive to target so I use the on-hdd fdinst from now on */
669
  /* change current drive to target so I use the on-hdd fdinst from now on */
684
  if (set_cur_drive(targetdrv) != 0) {
670
  if (set_cur_drive(targetdrv) != 0) {
685
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: CHANGING DRIVE TO TARGET FAILED", -1);
671
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: CHANGING DRIVE TO TARGET FAILED", -1);
686
    input_getkey();
672
    input_getkey();
Line 703... Line 689...
703
      putstringnls(12, 1, COLOR_BODY[mono], 4, 1, "*** INSERT THE DISK THAT CONTAINS THE REQUIRED FILE AND PRESS ANY KEY ***");
689
      putstringnls(12, 1, COLOR_BODY[mono], 4, 1, "*** INSERT THE DISK THAT CONTAINS THE REQUIRED FILE AND PRESS ANY KEY ***");
704
      input_getkey();
690
      input_getkey();
705
      video_putstringfix(12, 1, COLOR_BODY[mono], "", 80); /* erase the 'insert disk' message */
691
      video_putstringfix(12, 1, COLOR_BODY[mono], "", 80); /* erase the 'insert disk' message */
706
    }
692
    }
707
    /* proceed with package install */
693
    /* proceed with package install */
708
    snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\%s.ZIP > NUL", cdromdrv, pkgptr);
694
    snprintf(buff, sizeof(buff), "PKG INSTALL %c:\\%s.ZIP > NUL", cdromdrv, pkgptr);
709
    if (system(buff) != 0) {
695
    if (system(buff) != 0) {
710
      video_putstring(12, 30, COLOR_BODY[mono], "ERROR: PKG INSTALL FAILED", -1);
696
      video_putstring(12, 30, COLOR_BODY[mono], "ERROR: PKG INSTALL FAILED", -1);
711
      input_getkey();
697
      input_getkey();
712
      return(-1);
698
      return(-1);
713
    }
699
    }