Subversion Repositories SvarDOS

Rev

Rev 310 | Rev 313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 310 Rev 312
Line 384... Line 384...
384
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
384
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
385
static int disksize(int drv) {
385
static int disksize(int drv) {
386
  long res;
386
  long res;
387
  union REGS r;
387
  union REGS r;
388
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
388
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
389
  r.h.dl = drv;
389
  r.h.dl = drv;  /* A=1, B=2, etc */
390
  int86(0x21, &r, &r);
390
  int86(0x21, &r, &r);
391
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
391
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
392
  res = r.x.ax;  /* sectors per cluster */
392
  res = r.x.ax;  /* sectors per cluster */
393
  res *= r.x.dx; /* dx contains total clusters, bx contains free clusters */
393
  res *= r.x.dx; /* dx contains total clusters, bx contains free clusters */
394
  res *= r.x.cx; /* bytes per sector */
394
  res *= r.x.cx; /* bytes per sector */
Line 452... Line 452...
452
  int selecteddrive = 3; /* default to 'C:' */
452
  int selecteddrive = 3; /* default to 'C:' */
453
  int cselecteddrive;
453
  int cselecteddrive;
454
  int ds;
454
  int ds;
455
  int choice;
455
  int choice;
456
  char buff[1024];
456
  char buff[1024];
-
 
457
  int driveid = 1; /* fdisk runs on first drive (unless USB boot) */
-
 
458
  if (selecteddrive == get_cur_drive() + 1) { /* get_cur_drive() returns 0-based values (A=0) while selecteddrive is 1-based (A=1) */
457
  if (selecteddrive == get_cur_drive()) selecteddrive = 4; /* use D: if install is run from C: (typically because it was booted from USB?) */
459
    selecteddrive = 4; /* use D: if install is run from C: (typically because it was booted from USB?) */
-
 
460
    driveid = 2; /* primary drive is the emulated USB storage */
-
 
461
  }
458
  cselecteddrive = 'A' + selecteddrive - 1;
462
  cselecteddrive = 'A' + selecteddrive - 1;
459
  for (;;) {
463
  for (;;) {
460
    driveremovable = isdriveremovable(selecteddrive);
464
    driveremovable = isdriveremovable(selecteddrive);
461
    if (driveremovable < 0) {
465
    if (driveremovable < 0) {
462
      char *list[] = { "Create a partition automatically", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
466
      char *list[] = { "Create a partition automatically", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
Line 466... Line 470...
466
      list[2] = kittengets(0, 2, list[2]);
470
      list[2] = kittengets(0, 2, list[2]);
467
      snprintf(buff, sizeof(buff), kittengets(3, 0, "ERROR: Drive %c: could not be found. Perhaps your hard disk needs to be partitioned first. Please create at least one partition on your hard disk, so SvarDOS can be installed on it. Note, that SvarDOS requires at least %d MiB of available disk space.\n\nYou can use the FDISK partitioning tool for creating the required partition manually, or you can let the installer partitioning your disk automatically. You can also abort the installation to use any other partition manager of your choice."), cselecteddrive, SVARDOS_DISK_REQ);
471
      snprintf(buff, sizeof(buff), kittengets(3, 0, "ERROR: Drive %c: could not be found. Perhaps your hard disk needs to be partitioned first. Please create at least one partition on your hard disk, so SvarDOS can be installed on it. Note, that SvarDOS requires at least %d MiB of available disk space.\n\nYou can use the FDISK partitioning tool for creating the required partition manually, or you can let the installer partitioning your disk automatically. You can also abort the installation to use any other partition manager of your choice."), cselecteddrive, SVARDOS_DISK_REQ);
468
      putstringwrap(4, 1, COLOR_BODY[mono], buff);
472
      putstringwrap(4, 1, COLOR_BODY[mono], buff);
469
      switch (menuselect(14, -1, 5, list, -1)) {
473
      switch (menuselect(14, -1, 5, list, -1)) {
470
        case 0:
474
        case 0:
471
          system("FDISK /AUTO"); /* TODO DRIVE SHOULD BE SPECIFIED FOR MULTI-DRIVE SYSTEMS ! */
475
          sprintf(buff, "FDISK /AUTO %d", driveid);
-
 
476
          system(buff);
472
          break;
477
          break;
473
        case 1:
478
        case 1:
474
          video_clear(0x0700, 0, 0);
479
          video_clear(0x0700, 0, 0);
475
          video_movecursor(0, 0);
480
          video_movecursor(0, 0);
476
          system("FDISK");  /* TODO DRIVE SHOULD BE SPECIFIED FOR MULTI-DRIVE SYSTEMS ! */
481
          sprintf(buff, "FDISK %d", driveid);
-
 
482
          system(buff);
477
          break;
483
          break;
478
        case 2:
484
        case 2:
479
          return(MENUQUIT);
485
          return(MENUQUIT);
480
        default:
486
        default:
481
          return(-1);
487
          return(-1);
482
      }
488
      }
483
      /* write a temporary MBR which only skips the drive (in case BIOS would
489
      /* write a temporary MBR which only skips the drive (in case BIOS would
484
       * try to boot off the not-yet-ready C: disk) */
490
       * try to boot off the not-yet-ready C: disk) */
-
 
491
      sprintf(buff, "FDISK /AMBR %d", driveid);
485
      system("FDISK /AMBR"); /* writes BOOT.MBR into actual MBR */  /* TODO DRIVE SHOULD BE SPECIFIED FOR MULTI-DRIVE SYSTEMS ! */
492
      system(buff); /* writes BOOT.MBR into actual MBR */
486
      newscreen(2);
493
      newscreen(2);
487
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
494
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
488
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
495
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
489
      input_getkey();
496
      input_getkey();
490
      reboot();
497
      reboot();
Line 519... Line 526...
519
    /* check total disk space */
526
    /* check total disk space */
520
    ds = disksize(selecteddrive);
527
    ds = disksize(selecteddrive);
521
    if (ds < SVARDOS_DISK_REQ) {
528
    if (ds < SVARDOS_DISK_REQ) {
522
      int y = 9;
529
      int y = 9;
523
      newscreen(2);
530
      newscreen(2);
524
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! SvarDOS requires a disk of at least %d MiB."), cselecteddrive);
531
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! SvarDOS requires a disk of at least %d MiB."), cselecteddrive, SVARDOS_DISK_REQ);
525
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
532
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
526
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
533
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
527
      input_getkey();
534
      input_getkey();
528
      return(MENUQUIT);
535
      return(MENUQUIT);
529
    }
536
    }
Line 553... Line 560...
553
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
560
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
554
      choice = menuselect(10, -1, 4, list, -1);
561
      choice = menuselect(10, -1, 4, list, -1);
555
      if (choice < 0) return(MENUPREV);
562
      if (choice < 0) return(MENUPREV);
556
      if (choice == 1) return(MENUQUIT);
563
      if (choice == 1) return(MENUQUIT);
557
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
564
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
-
 
565
      puts(buff);
-
 
566
      system(buff);
-
 
567
      sprintf(buff, "FDISK /MBR %d", driveid);
-
 
568
      puts(buff);
558
      system(buff);
569
      system(buff);
559
      system("FDISK /MBR"); /* TODO DRIVE SHOULD BE SPECIFIED FOR MULTI-DRIVE SYSTEMS ! */
-
 
560
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
570
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
-
 
571
      puts(buff);
561
      mkdir(buff);
572
      mkdir(buff);
562
      return(cselecteddrive);
573
      return(cselecteddrive);
563
    }
574
    }
564
  }
575
  }
565
}
576
}
Line 603... Line 614...
603
  fd = fopen(buff, "wb");
614
  fd = fopen(buff, "wb");
604
  if (fd == NULL) return;
615
  if (fd == NULL) return;
605
  fprintf(fd, "DOS=UMB,HIGH\r\n"
616
  fprintf(fd, "DOS=UMB,HIGH\r\n"
606
              "LASTDRIVE=Z\r\n"
617
              "LASTDRIVE=Z\r\n"
607
              "FILES=50\r\n");
618
              "FILES=50\r\n");
608
  fprintf(fd, "DEVICE=%c:\\SVARDOS\\BIN\\HIMEMX.EXE\r\n", targetdrv);
619
  fprintf(fd, "DEVICE=C:\\SVARDOS\\BIN\\HIMEMX.EXE\r\n");
609
  if (strcmp(locales->lang, "EN") == 0) {
620
  if (strcmp(locales->lang, "EN") == 0) {
610
    strcpy(buff, "COMMAND");
621
    strcpy(buff, "COMMAND");
611
  } else {
622
  } else {
612
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
623
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
613
  }
624
  }
Line 862... Line 873...
862
 
873
 
863
 WelcomeScreen:
874
 WelcomeScreen:
864
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
875
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
865
  if (action == MENUQUIT) goto Quit;
876
  if (action == MENUQUIT) goto Quit;
866
  if (action == MENUPREV) goto SelectLang;
877
  if (action == MENUPREV) goto SelectLang;
867
  targetdrv = preparedrive(sourcedrv); /* what drive should we install to? check avail. space */
878
  targetdrv = preparedrive(sourcedrv); /* what drive should we install from? check avail. space */
868
  if (targetdrv == MENUQUIT) goto Quit;
879
  if (targetdrv == MENUQUIT) goto Quit;
869
  if (targetdrv == MENUPREV) goto WelcomeScreen;
880
  if (targetdrv == MENUPREV) goto WelcomeScreen;
870
  bootfilesgen(targetdrv, &locales); /* generate boot files and other configurations */
881
  bootfilesgen(targetdrv, &locales); /* generate boot files and other configurations */
871
  if (installpackages(targetdrv, sourcedrv, &locales) != 0) goto Quit;    /* install packages */
882
  if (installpackages(targetdrv, sourcedrv, &locales) != 0) goto Quit;    /* install packages */
872
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
883
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */