Subversion Repositories SvarDOS

Rev

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

Rev 69 Rev 73
Line 32... Line 32...
32
static int mono = 0;
32
static int mono = 0;
33
 
33
 
34
/* how much disk space does Svarog386 require (in MiB) */
34
/* how much disk space does Svarog386 require (in MiB) */
35
#define SVAROG_DISK_REQ 8
35
#define SVAROG_DISK_REQ 8
36
 
36
 
-
 
37
/* menu screens can output only one of these: */
-
 
38
#define MENUNEXT 0
-
 
39
#define MENUPREV -1
-
 
40
#define MENUQUIT -2
-
 
41
 
37
/* a convenience 'function' used for debugging */
42
/* a convenience 'function' used for debugging */
38
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
43
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
39
 
44
 
40
struct slocales {
45
struct slocales {
41
  char lang[4];
46
  char lang[4];
Line 185... Line 190...
185
  x = 40 - (strlen(msg) >> 1);
190
  x = 40 - (strlen(msg) >> 1);
186
  video_putstring(4, x, COLOR_BODY[mono], msg, -1);
191
  video_putstring(4, x, COLOR_BODY[mono], msg, -1);
187
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
192
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
188
  putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
193
  putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
189
  choice = menuselect(11, -1, 6, langlist, -1);
194
  choice = menuselect(11, -1, 6, langlist, -1);
190
  if (choice < 0) return(-1);
195
  if (choice < 0) return(MENUPREV);
191
  /* populate locales with default values */
196
  /* populate locales with default values */
192
  memset(locales, 0, sizeof(struct slocales));
197
  memset(locales, 0, sizeof(struct slocales));
193
  switch (choice) {
198
  switch (choice) {
194
    case 1:
199
    case 1:
195
      strcpy(locales->lang, "FR");
200
      strcpy(locales->lang, "FR");
Line 221... Line 226...
221
  /* */
226
  /* */
222
  locales->codepage = ((unsigned short)msg[1] << 8) | msg[2];
227
  locales->codepage = ((unsigned short)msg[1] << 8) | msg[2];
223
  locales->egafile = msg[3];
228
  locales->egafile = msg[3];
224
  locales->keybfile = msg[4];
229
  locales->keybfile = msg[4];
225
  /* */
230
  /* */
226
  return(0);
231
  return(MENUNEXT);
227
}
232
}
228
 
233
 
229
 
234
 
230
#define LTODEC(x, y) ((unsigned short)(x << 8) | (y))
235
#define LTODEC(x, y) ((unsigned short)(x << 8) | (y))
231
static int selectkeyb(struct slocales *locales) {
236
static int selectkeyb(struct slocales *locales) {
Line 249... Line 254...
249
    default: /* otherwise propose all possible keyoard layouts */
254
    default: /* otherwise propose all possible keyoard layouts */
250
      keyboff = 0;
255
      keyboff = 0;
251
      keyblen = OFFCOUNT;
256
      keyblen = OFFCOUNT;
252
      break;
257
      break;
253
  }
258
  }
254
  if (keyblen == 1) return(0); /* do not ask for keyboard layout if only one is available for given language */
259
  if (keyblen == 1) return(MENUNEXT); /* do not ask for keyboard layout if only one is available for given language */
255
  newscreen();
260
  newscreen();
256
  putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.");
261
  putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.");
257
  menuheight = keyblen + 2;
262
  menuheight = keyblen + 2;
258
  if (menuheight > 13) menuheight = 13;
263
  if (menuheight > 13) menuheight = 13;
259
  if (menuselect(10, -1, menuheight, &(kblayouts[keyboff]), keyblen) < 0) return(-1);
264
  if (menuselect(10, -1, menuheight, &(kblayouts[keyboff]), keyblen) < 0) return(MENUPREV);
260
  return(0);
265
  return(MENUNEXT);
261
}
266
}
262
 
267
 
263
 
268
 
264
/* returns 0 if installation must proceed, non-zero otherwise */
269
/* returns 0 if installation must proceed, non-zero otherwise */
265
static int welcomescreen(void) {
270
static int welcomescreen(void) {
-
 
271
  int c;
266
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
272
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
267
  choice[0] = kittengets(0, 1, choice[0]);
273
  choice[0] = kittengets(0, 1, choice[0]);
268
  choice[1] = kittengets(0, 2, choice[1]);
274
  choice[1] = kittengets(0, 2, choice[1]);
269
  newscreen();
275
  newscreen();
270
  putstringnls(4, 1, COLOR_BODY[mono], 2, 0, "You are about to install Svarog386: a free, MSDOS-compatible operating system based on the FreeDOS kernel. Svarog386 targets 386+ computers and comes with a variety of third-party applications.\n\nWARNING: If your PC has another operating system installed, this other system might be unable to boot once Svarog386 is installed.");
276
  putstringnls(4, 1, COLOR_BODY[mono], 2, 0, "You are about to install Svarog386: a free, MSDOS-compatible operating system based on the FreeDOS kernel. Svarog386 targets 386+ computers and comes with a variety of third-party applications.\n\nWARNING: If your PC has another operating system installed, this other system might be unable to boot once Svarog386 is installed.");
271
  return(menuselect(13, -1, 4, choice, -1));
277
  c = menuselect(13, -1, 4, choice, -1);
-
 
278
  if (c < 0) return(MENUPREV);
-
 
279
  if (c == 0) return(MENUNEXT);
-
 
280
  return(MENUQUIT);
272
}
281
}
273
 
282
 
274
 
283
 
275
/* returns 1 if drive is removable, 0 if not, -1 on error */
284
/* returns 1 if drive is removable, 0 if not, -1 on error */
276
static int isdriveremovable(int drv) {
285
static int isdriveremovable(int drv) {
Line 322... Line 331...
322
static int preparedrive(void) {
331
static int preparedrive(void) {
323
  int driveremovable;
332
  int driveremovable;
324
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
333
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
325
  int cselecteddrive;
334
  int cselecteddrive;
326
  int ds;
335
  int ds;
-
 
336
  int choice;
327
  char buff[1024];
337
  char buff[1024];
328
  cselecteddrive = 'A' + selecteddrive - 1;
338
  cselecteddrive = 'A' + selecteddrive - 1;
329
  for (;;) {
339
  for (;;) {
330
    newscreen();
340
    newscreen();
331
    driveremovable = isdriveremovable(selecteddrive);
341
    driveremovable = isdriveremovable(selecteddrive);
Line 343... Line 353...
343
        case 1:
353
        case 1:
344
          video_clear(0x0700, 0);
354
          video_clear(0x0700, 0);
345
          video_movecursor(0, 0);
355
          video_movecursor(0, 0);
346
          system("FDISK");
356
          system("FDISK");
347
          break;
357
          break;
-
 
358
        case 2:
-
 
359
          return(MENUQUIT);
348
        default:
360
        default:
349
          return(-1);
361
          return(-1);
350
      }
362
      }
351
      newscreen();
363
      newscreen();
352
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
364
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
353
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
365
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
354
      input_getkey();
366
      input_getkey();
355
      reboot();
367
      reboot();
356
      return(-1);
368
      return(MENUQUIT);
357
    } else if (driveremovable > 0) {
369
    } else if (driveremovable > 0) {
358
      snprintf(buff, sizeof(buff), kittengets(3, 2, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
370
      snprintf(buff, sizeof(buff), kittengets(3, 2, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
359
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
371
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
360
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
372
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
361
      return(-1);
373
      return(MENUQUIT);
362
    }
374
    }
363
    /* if not formatted, propose to format it right away (try to create a directory) */
375
    /* if not formatted, propose to format it right away (try to create a directory) */
364
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
376
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
365
    if (mkdir(buff) == 0) {
377
    if (mkdir(buff) == 0) {
366
      rmdir(buff);
378
      rmdir(buff);
Line 368... Line 380...
368
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
380
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
369
      list[0] = kittengets(0, 6, list[0]);
381
      list[0] = kittengets(0, 6, list[0]);
370
      list[1] = kittengets(0, 2, list[1]);
382
      list[1] = kittengets(0, 2, list[1]);
371
      snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
383
      snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
372
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
384
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
373
      if (menuselect(12, -1, 4, list, -1) != 0) return(-1);
385
      choice = menuselect(12, -1, 4, list, -1);
-
 
386
      if (choice < 0) return(MENUPREV);
-
 
387
      if (choice == 1) return(MENUQUIT);
374
      video_clear(0x0700, 0);
388
      video_clear(0x0700, 0);
375
      video_movecursor(0, 0);
389
      video_movecursor(0, 0);
376
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
390
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
377
      system(buff);
391
      system(buff);
378
      continue;
392
      continue;
Line 381... Line 395...
381
    ds = disksize(selecteddrive);
395
    ds = disksize(selecteddrive);
382
    if (ds < SVAROG_DISK_REQ) {
396
    if (ds < SVAROG_DISK_REQ) {
383
      int y = 9;
397
      int y = 9;
384
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! Svarog386 requires a disk of at least %d MiB."), cselecteddrive);
398
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! Svarog386 requires a disk of at least %d MiB."), cselecteddrive);
385
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
399
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
386
      putstringnls(++y, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
400
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
387
      input_getkey();
401
      input_getkey();
388
      return(-1);
402
      return(MENUQUIT);
389
    }
403
    }
390
    /* is the disk empty? */
404
    /* is the disk empty? */
391
    if (diskempty(selecteddrive) != 0) {
405
    if (diskempty(selecteddrive) != 0) {
392
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
406
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
393
      int y = 6;
407
      int y = 6;
394
      list[0] = kittengets(0, 6, list[0]);
408
      list[0] = kittengets(0, 6, list[0]);
395
      list[1] = kittengets(0, 2, list[1]);
409
      list[1] = kittengets(0, 2, list[1]);
396
      snprintf(buff, sizeof(buff), kittengets(3, 5, "ERROR: Drive %c: is not empty. Svarog386 must be installed on an empty disk.\n\nYou can format the disk now, to make it empty. Note however, that this will ERASE ALL CURRENT DATA on your disk."), cselecteddrive);
410
      snprintf(buff, sizeof(buff), kittengets(3, 5, "ERROR: Drive %c: is not empty. Svarog386 must be installed on an empty disk.\n\nYou can format the disk now, to make it empty. Note however, that this will ERASE ALL CURRENT DATA on your disk."), cselecteddrive);
397
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
411
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
398
      if (menuselect(++y, -1, 4, list, -1) != 0) return(-1);
412
      choice = menuselect(++y, -1, 4, list, -1);
-
 
413
      if (choice < 0) return(MENUPREV);
-
 
414
      if (choice == 1) return(MENUQUIT);
399
      video_clear(0x0700, 0);
415
      video_clear(0x0700, 0);
400
      video_movecursor(0, 0);
416
      video_movecursor(0, 0);
401
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
417
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
402
      system(buff);
418
      system(buff);
403
      continue;
419
      continue;
Line 406... Line 422...
406
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
422
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
407
      list[0] = kittengets(0, 1, list[0]);
423
      list[0] = kittengets(0, 1, list[0]);
408
      list[1] = kittengets(0, 2, list[1]);
424
      list[1] = kittengets(0, 2, list[1]);
409
      snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
425
      snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
410
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
426
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
411
      if (menuselect(10, -1, 4, list, -1) != 0) return(-1);
427
      choice = menuselect(10, -1, 4, list, -1);
-
 
428
      if (choice < 0) return(MENUPREV);
-
 
429
      if (choice == 1) return(MENUQUIT);
412
      snprintf(buff, sizeof(buff), "SYS A: %c: > NUL", cselecteddrive);
430
      snprintf(buff, sizeof(buff), "SYS A: %c: > NUL", cselecteddrive);
413
      system(buff);
431
      system(buff);
414
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
432
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
415
      mkdir(buff);
433
      mkdir(buff);
416
      return(cselecteddrive);
434
      return(cselecteddrive);
Line 593... Line 611...
593
 
611
 
594
 
612
 
595
static void finalreboot(void) {
613
static void finalreboot(void) {
596
  int y = 9;
614
  int y = 9;
597
  newscreen();
615
  newscreen();
598
  y += putstringnls(y, 2, COLOR_BODY[mono], 5, 0, "Svarog386 installation is over. Your computer will reboot now.\nPlease remove the installation disk from your drive.");
616
  y += putstringnls(y, 1, COLOR_BODY[mono], 5, 0, "Svarog386 installation is over. Your computer will reboot now.\nPlease remove the installation disk from your drive.");
599
  putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
617
  putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
600
  input_getkey();
618
  input_getkey();
601
  reboot();
619
  reboot();
602
}
620
}
603
 
621
 
Line 642... Line 660...
642
 
660
 
643
int main(void) {
661
int main(void) {
644
  struct slocales locales;
662
  struct slocales locales;
645
  int targetdrv;
663
  int targetdrv;
646
  int cdromdrv;
664
  int cdromdrv;
-
 
665
  int action;
647
 
666
 
648
  /* find where the cdrom drive is */
667
  /* find where the cdrom drive is */
649
  cdromdrv = cdrom_findfirst();
668
  cdromdrv = cdrom_findfirst();
650
  if (cdromdrv < 0) {
669
  if (cdromdrv < 0) {
651
    printf("ERROR: CD-ROM DRIVE NOT FOUND\r\n");
670
    printf("ERROR: CD-ROM DRIVE NOT FOUND\r\n");
Line 658... Line 677...
658
  }
677
  }
659
 
678
 
660
  /* init screen and detect mono status */
679
  /* init screen and detect mono status */
661
  mono = video_init();
680
  mono = video_init();
662
 
681
 
663
  for (;;) { /* fake loop, it's here just to break out easily */
-
 
664
    kittenopen("INSTALL"); /* NLS support */
682
  kittenopen("INSTALL"); /* load initial NLS support */
-
 
683
 
-
 
684
 SelectLang:
665
    if (selectlang(&locales) < 0) break; /* welcome to svarog, select your language */
685
  action = selectlang(&locales); /* welcome to svarog, select your language */
-
 
686
  if (action != MENUNEXT) goto Quit;
666
    setenv("LANG", locales.lang, 1);
687
  setenv("LANG", locales.lang, 1);
667
    loadcp(&locales);
688
  loadcp(&locales);
668
    kittenclose(); /* reload NLS with new language */
689
  kittenclose(); /* reload NLS with new language */
669
    kittenopen("INSTALL"); /* NLS support */
690
  kittenopen("INSTALL"); /* NLS support */
670
    if (selectkeyb(&locales) != 0) break;  /* what keyb layout should we use? */
691
  action = selectkeyb(&locales);  /* what keyb layout should we use? */
-
 
692
  if (action == MENUQUIT) goto Quit;
-
 
693
  if (action == MENUPREV) goto SelectLang;
-
 
694
 
-
 
695
 WelcomeScreen:
671
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
696
  action = welcomescreen(); /* what svarog386 is, ask whether to run live dos or install */
-
 
697
  if (action == MENUQUIT) goto Quit;
-
 
698
  if (action == MENUPREV) goto SelectLang;
672
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
699
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
673
    if (targetdrv < 0) break;
700
  if (targetdrv == MENUQUIT) goto Quit;
-
 
701
  if (targetdrv == MENUPREV) goto WelcomeScreen;
674
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
702
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
675
    installpackages(targetdrv, cdromdrv);    /* install packages */
703
  installpackages(targetdrv, cdromdrv);    /* install packages */
676
    bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
704
  bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
677
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
705
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
678
    /*netcfg();*/ /* basic networking config */
706
  /*netcfg();*/ /* basic networking config */
679
    finalreboot(); /* remove the CD and reboot */
707
  finalreboot(); /* remove the CD and reboot */
680
    break;
708
 
681
  }
709
 Quit:
682
  kittenclose(); /* close NLS support */
710
  kittenclose(); /* close NLS support */
683
  video_clear(0x0700, 0);
711
  video_clear(0x0700, 0);
684
  video_movecursor(0, 0);
712
  video_movecursor(0, 0);
685
  return(0);
713
  return(0);
686
}
714
}