Subversion Repositories SvarDOS

Rev

Rev 310 | Rev 313 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
28 mv_fox 1
/*
190 mateuszvis 2
 * SVARDOS INSTALL PROGRAM
206 mateuszvis 3
 * Copyright (C) 2021 Mateusz Viste
4
 *
190 mateuszvis 5
 * PUBLISHED UNDER THE TERMS OF THE MIT LICENSE
42 mv_fox 6
 *
190 mateuszvis 7
 * COPYRIGHT (C) 2016-2021 MATEUSZ VISTE, ALL RIGHTS RESERVED.
94 mv_fox 8
 *
190 mateuszvis 9
 * Permission is hereby granted, free of charge, to any person obtaining a
10
 * copy of this software and associated documentation files (the "Software"),
11
 * to deal in the Software without restriction, including without limitation
12
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
 * and/or sell copies of the Software, and to permit persons to whom the
14
 * Software is furnished to do so, subject to the following conditions:
94 mv_fox 15
 *
190 mateuszvis 16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
94 mv_fox 18
 *
190 mateuszvis 19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
 * DEALINGS IN THE SOFTWARE.
94 mv_fox 26
 *
190 mateuszvis 27
 * http://svardos.osdn.io
28 mv_fox 28
 */
29
 
30
#include <dos.h>
30 mv_fox 31
#include <direct.h>  /* mkdir() */
28 mv_fox 32
#include <stdio.h>   /* printf() and friends */
33
#include <stdlib.h>  /* system() */
34
#include <string.h>  /* memcpy() */
35
#include <unistd.h>
42 mv_fox 36
 
37
#include "kitten\kitten.h"
38
 
28 mv_fox 39
#include "input.h"
40
#include "video.h"
41
 
67 mv_fox 42
/* keyboard layouts and locales */
43
#include "keylay.h"
44
#include "keyoff.h"
42 mv_fox 45
 
29 mv_fox 46
/* color scheme (color, mono) */
47
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
48
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
49
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
50
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
28 mv_fox 51
 
29 mv_fox 52
/* mono flag */
53
static int mono = 0;
28 mv_fox 54
 
190 mateuszvis 55
/* how much disk space does SvarDOS require (in MiB) */
56
#define SVARDOS_DISK_REQ 8
28 mv_fox 57
 
73 mv_fox 58
/* menu screens can output only one of these: */
59
#define MENUNEXT 0
60
#define MENUPREV -1
61
#define MENUQUIT -2
62
 
67 mv_fox 63
/* a convenience 'function' used for debugging */
64
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
47 mv_fox 65
 
67 mv_fox 66
struct slocales {
67
  char lang[4];
68
  char *keybcode;
69
  unsigned int codepage;
70
  int egafile;
71
  int keybfile;
72
  int keyboff;
73
  int keyblen;
96 mv_fox 74
  unsigned int keybid;
67 mv_fox 75
};
76
 
77
 
28 mv_fox 78
/* reboot the computer */
79
static void reboot(void) {
80
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
81
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
82
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
83
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
84
}
85
 
42 mv_fox 86
 
56 mv_fox 87
/* outputs a string to screen with taking care of word wrapping. returns amount of lines. */
88
static int putstringwrap(int y, int x, unsigned short attr, char *s) {
89
  int linew, lincount;
90
  linew = 80;
91
  if (x >= 0) linew -= (x << 1);
92
 
93
  for (lincount = 1; y+lincount < 25; lincount++) {
94
    int i, len = linew;
95
    for (i = 0; i <= linew; i++) {
96
      if (s[i] == ' ') len = i;
97
      if (s[i] == '\n') {
98
        len = i;
99
        break;
100
      }
101
      if (s[i] == 0) {
102
        len = i;
103
        break;
104
      }
105
    }
106
    video_putstring(y++, x, attr, s, len);
107
    s += len;
108
    if (*s == 0) break;
109
    s += 1; /* skip the whitespace char */
110
  }
111
  return(lincount);
112
}
113
 
114
 
115
/* an NLS wrapper around video_putstring(), also performs line wrapping when
116
 * needed. returns the amount of lines that were output */
117
static int putstringnls(int y, int x, unsigned short attr, int nlsmaj, int nlsmin, char *s) {
42 mv_fox 118
  s = kittengets(nlsmaj, nlsmin, s);
56 mv_fox 119
  return(putstringwrap(y, x, attr, s));
42 mv_fox 120
}
121
 
122
 
280 mateuszvis 123
/* copy file f1 to f2 using buff as a buffer of buffsz bytes. f2 will be overwritten if it
124
 * exists already! returns 0 on success. */
125
static int fcopy(const char *f2, const char *f1, void *buff, size_t buffsz) {
126
  FILE *fd1, *fd2;
127
  size_t sz;
128
  int res = -1; /* assume failure */
129
 
130
  /* open files */
131
  fd1 = fopen(f1, "rb");
132
  fd2 = fopen(f2, "wb");
133
  if ((fd1 == NULL) || (fd2 == NULL)) goto QUIT;
134
 
135
  /* copy data */
136
  for (;;) {
137
    sz = fread(buff, 1, buffsz, fd1);
138
    if (sz == 0) {
139
      if (feof(fd1) != 0) break;
140
      goto QUIT;
141
    }
142
    if (fwrite(buff, 1, sz, fd2) != sz) goto QUIT;
143
  }
144
 
145
  res = 0; /* success */
146
 
147
  QUIT:
148
  if (fd1 != NULL) fclose(fd1);
149
  if (fd2 != NULL) fclose(fd2);
150
  return(res);
151
}
152
 
153
 
67 mv_fox 154
static int menuselect(int ypos, int xpos, int height, char **list, int listlen) {
28 mv_fox 155
  int i, offset = 0, res = 0, count, width = 0;
67 mv_fox 156
  /* count how many positions there is, and check their width */
157
  for (count = 0; (list[count] != NULL) && (count != listlen); count++) {
28 mv_fox 158
    int len = strlen(list[count]);
159
    if (len > width) width = len;
160
  }
161
 
162
  /* if xpos negative, means 'center out' */
163
  if (xpos < 0) xpos = 39 - (width >> 1);
164
 
29 mv_fox 165
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
166
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
167
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
168
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
169
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
170
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
171
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
172
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
28 mv_fox 173
 
174
  for (;;) {
175
    int key;
176
    /* list of selectable items */
177
    for (i = 0; i < height - 2; i++) {
178
      if (i + offset == res) {
29 mv_fox 179
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
180
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
28 mv_fox 181
        video_movecursor(ypos + 1 + i, xpos);
29 mv_fox 182
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
28 mv_fox 183
      } else if (i + offset < count) {
29 mv_fox 184
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
185
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
186
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
28 mv_fox 187
      } else {
29 mv_fox 188
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
28 mv_fox 189
      }
190
    }
191
    key = input_getkey();
192
    if (key == 0x0D) { /* ENTER */
193
      return(res);
194
    } else if (key == 0x148) { /* up */
33 mv_fox 195
      if (res > 0) {
196
        res--;
197
        if (res < offset) offset = res;
198
      }
28 mv_fox 199
    } else if (key == 0x150) { /* down */
33 mv_fox 200
      if (res+1 < count) {
201
        res++;
202
        if (res > offset + height - 3) offset = res - (height - 3);
203
      }
204
    } else if (key == 0x147) { /* home */
205
      res = 0;
206
      offset = 0;
207
    } else if (key == 0x14F) { /* end */
208
      res = count - 1;
209
      if (res > offset + height - 3) offset = res - (height - 3);
28 mv_fox 210
    } else if (key == 0x1B) {  /* ESC */
211
      return(-1);
78 mv_fox 212
    }/* else {
33 mv_fox 213
      char buf[8];
55 mv_fox 214
      snprintf(buf, sizeof(buf), "0x%02X ", key);
56 mv_fox 215
      video_putstring(1, 0, COLOR_BODY[mono], buf, -1);
78 mv_fox 216
    }*/
28 mv_fox 217
  }
218
}
219
 
79 mv_fox 220
static void newscreen(int statusbartype) {
221
  char *msg;
190 mateuszvis 222
  msg = kittengets(0, 0, "SVARDOS INSTALLATION");
81 mv_fox 223
  video_putcharmulti(0, 0, COLOR_TITLEBAR[mono], ' ', 80, 1);
79 mv_fox 224
  video_putstring(0, 40 - (strlen(msg) >> 1), COLOR_TITLEBAR[mono], msg, -1);
81 mv_fox 225
  video_clear(COLOR_BODY[mono], 80, -80);
79 mv_fox 226
  switch (statusbartype) {
227
    case 1:
228
      msg = kittengets(0, 11, "Up/Down = Select entry | Enter = Validate your choice | ESC = Quit to DOS");
229
      break;
230
    case 2:
231
      msg = kittengets(0, 5, "Press any key...");
232
      break;
233
    case 3:
234
      msg = "";
235
      break;
236
    default:
237
      msg = kittengets(0, 10, "Up/Down = Select entry | Enter = Validate your choice | ESC = Previous screen");
238
      break;
239
  }
240
  video_putchar(24, 0, COLOR_TITLEBAR[mono], ' ');
241
  video_putstringfix(24, 1, COLOR_TITLEBAR[mono], msg, 79);
36 mv_fox 242
  video_movecursor(25,0);
28 mv_fox 243
}
244
 
96 mv_fox 245
/* fills a slocales struct accordingly to the value of its keyboff member */
246
static void kblay2slocal(struct slocales *locales) {
247
  char *m;
248
  for (m = kblayouts[locales->keyboff]; *m != 0; m++); /* skip layout name */
249
  m++;
250
  /* skip keyb code and copy it to locales.keybcode */
251
  locales->keybcode = m;
252
  for (; *m != 0; m++);
253
  /* */
254
  locales->codepage = ((unsigned short)m[1] << 8) | m[2];
255
  locales->egafile = m[3];
256
  locales->keybfile = m[4];
257
  locales->keybid = ((unsigned short)m[5] << 8) | m[6];
258
}
259
 
67 mv_fox 260
static int selectlang(struct slocales *locales) {
261
  int choice, x;
42 mv_fox 262
  char *msg;
28 mv_fox 263
  char *langlist[] = {
67 mv_fox 264
    "English",
265
    "French",
133 mv_fox 266
    "German",
119 mv_fox 267
    "Italian",
67 mv_fox 268
    "Polish",
116 mv_fox 269
    "Russian",
123 mv_fox 270
    "Slovene",
128 mv_fox 271
    "Swedish",
67 mv_fox 272
    "Turkish",
28 mv_fox 273
    NULL
274
  };
275
 
79 mv_fox 276
  newscreen(1);
190 mateuszvis 277
  msg = kittengets(1, 0, "Welcome to SvarDOS");
42 mv_fox 278
  x = 40 - (strlen(msg) >> 1);
56 mv_fox 279
  video_putstring(4, x, COLOR_BODY[mono], msg, -1);
42 mv_fox 280
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
49 mv_fox 281
  putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
133 mv_fox 282
  choice = menuselect(11, -1, 11, langlist, -1);
73 mv_fox 283
  if (choice < 0) return(MENUPREV);
67 mv_fox 284
  /* populate locales with default values */
285
  memset(locales, 0, sizeof(struct slocales));
286
  switch (choice) {
287
    case 1:
288
      strcpy(locales->lang, "FR");
289
      locales->keyboff = OFFLOC_FR;
290
      locales->keyblen = OFFLEN_FR;
291
      break;
292
    case 2:
133 mv_fox 293
      strcpy(locales->lang, "DE");
294
      locales->keyboff = OFFLOC_DE;
295
      locales->keyblen = OFFLEN_DE;
296
      break;
297
    case 3:
119 mv_fox 298
      strcpy(locales->lang, "IT");
299
      locales->keyboff = OFFLOC_IT;
300
      locales->keyblen = OFFLEN_IT;
301
      break;
133 mv_fox 302
    case 4:
67 mv_fox 303
      strcpy(locales->lang, "PL");
304
      locales->keyboff = OFFLOC_PL;
305
      locales->keyblen = OFFLEN_PL;
306
      break;
133 mv_fox 307
    case 5:
116 mv_fox 308
      strcpy(locales->lang, "RU");
309
      locales->keyboff = OFFLOC_RU;
310
      locales->keyblen = OFFLEN_RU;
311
      break;
133 mv_fox 312
    case 6:
123 mv_fox 313
      strcpy(locales->lang, "SI");
314
      locales->keyboff = OFFLOC_SI;
315
      locales->keyblen = OFFLEN_SI;
316
      break;
133 mv_fox 317
    case 7:
128 mv_fox 318
      strcpy(locales->lang, "SV");
319
      locales->keyboff = OFFLOC_SV;
320
      locales->keyblen = OFFLEN_SV;
321
      break;
133 mv_fox 322
    case 8:
67 mv_fox 323
      strcpy(locales->lang, "TR");
324
      locales->keyboff = OFFLOC_TR;
325
      locales->keyblen = OFFLEN_TR;
326
      break;
327
    default:
328
      strcpy(locales->lang, "EN");
329
      locales->keyboff = 0;
330
      locales->keyblen = OFFCOUNT;
331
      break;
332
  }
96 mv_fox 333
  /* populate the slocales struct accordingly to the keyboff member */
334
  kblay2slocal(locales);
67 mv_fox 335
  /* */
73 mv_fox 336
  return(MENUNEXT);
28 mv_fox 337
}
338
 
339
 
67 mv_fox 340
static int selectkeyb(struct slocales *locales) {
96 mv_fox 341
  int menuheight, choice;
342
  if (locales->keyblen == 1) return(MENUNEXT); /* do not ask for keyboard layout if only one is available for given language */
79 mv_fox 343
  newscreen(0);
197 mateuszvis 344
  putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "SvarDOS supports different keyboard layouts. Choose the keyboard layout that you want.");
96 mv_fox 345
  menuheight = locales->keyblen + 2;
67 mv_fox 346
  if (menuheight > 13) menuheight = 13;
96 mv_fox 347
  choice = menuselect(10, -1, menuheight, &(kblayouts[locales->keyboff]), locales->keyblen);
348
  if (choice < 0) return(MENUPREV);
349
  /* (re)load the keyboard layout & codepage setup */
350
  locales->keyboff += choice;
351
  kblay2slocal(locales);
73 mv_fox 352
  return(MENUNEXT);
67 mv_fox 353
}
354
 
355
 
28 mv_fox 356
/* returns 0 if installation must proceed, non-zero otherwise */
357
static int welcomescreen(void) {
73 mv_fox 358
  int c;
190 mateuszvis 359
  char *choice[] = {"Install SvarDOS to disk", "Quit to DOS", NULL};
42 mv_fox 360
  choice[0] = kittengets(0, 1, choice[0]);
361
  choice[1] = kittengets(0, 2, choice[1]);
79 mv_fox 362
  newscreen(0);
190 mateuszvis 363
  putstringnls(4, 1, COLOR_BODY[mono], 2, 0, "You are about to install SvarDOS: a free, MSDOS-compatible operating system based on the FreeDOS kernel. SvarDOS 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 SvarDOS is installed.");
73 mv_fox 364
  c = menuselect(13, -1, 4, choice, -1);
365
  if (c < 0) return(MENUPREV);
366
  if (c == 0) return(MENUNEXT);
367
  return(MENUQUIT);
28 mv_fox 368
}
369
 
370
 
33 mv_fox 371
/* returns 1 if drive is removable, 0 if not, -1 on error */
372
static int isdriveremovable(int drv) {
28 mv_fox 373
  union REGS r;
33 mv_fox 374
  r.x.ax = 0x4408;
375
  r.h.bl = drv;
28 mv_fox 376
  int86(0x21, &r, &r);
33 mv_fox 377
  /* CF set on error, AX set to 0 if removable, 1 if fixed */
378
  if (r.x.cflag != 0) return(-1);
379
  if (r.x.ax == 0) return(1);
380
  return(0);
28 mv_fox 381
}
382
 
383
 
35 mv_fox 384
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
385
static int disksize(int drv) {
28 mv_fox 386
  long res;
387
  union REGS r;
388
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
312 mateuszvis 389
  r.h.dl = drv;  /* A=1, B=2, etc */
28 mv_fox 390
  int86(0x21, &r, &r);
391
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
49 mv_fox 392
  res = r.x.ax;  /* sectors per cluster */
393
  res *= r.x.dx; /* dx contains total clusters, bx contains free clusters */
394
  res *= r.x.cx; /* bytes per sector */
395
  res >>= 20;    /* convert bytes to MiB */
396
  return(res);
35 mv_fox 397
}
398
 
399
 
400
/* returns 0 if disk is empty, non-zero otherwise */
401
static int diskempty(int drv) {
402
  unsigned int rc;
403
  int res;
404
  char buff[8];
405
  struct find_t fileinfo;
55 mv_fox 406
  snprintf(buff, sizeof(buff), "%c:\\*.*", 'A' + drv - 1);
35 mv_fox 407
  rc = _dos_findfirst(buff, _A_NORMAL | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM, &fileinfo);
408
  if (rc == 0) {
409
    res = 1; /* call successfull means disk is not empty */
28 mv_fox 410
  } else {
35 mv_fox 411
    res = 0;
28 mv_fox 412
  }
35 mv_fox 413
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
28 mv_fox 414
  return(res);
415
}
416
 
280 mateuszvis 417
#ifdef DEADCODE
200 mateuszvis 418
/* set new DOS "current drive" to drv ('A', 'B', etc). returns 0 on success */
419
static int set_cur_drive(char drv) {
420
  union REGS r;
421
  if ((drv < 'A') || (drv > 'Z')) return(-1);
422
  r.h.ah = 0x0E; /* DOS 1+ SELECT DEFAULT DRIVE */
423
  r.h.dl = drv - 'A';
424
  int86(0x21, &r, &r);
425
  if (r.h.al < drv - 'A') return(-1);
426
  return(0);
427
}
280 mateuszvis 428
#endif
200 mateuszvis 429
 
310 mateuszvis 430
 
431
/* get the DOS "current drive" (0=A:, 1=B:, etc) */
432
static int get_cur_drive(void) {
433
  union REGS r;
434
  r.h.ah = 0x19; /* DOS 1+ GET CURRENT DEFAULT DRIVE */
435
  int86(0x21, &r, &r);
436
  return(r.h.al);
437
}
438
 
439
 
200 mateuszvis 440
/* returns 0 if file exists, non-zero otherwise */
441
static int fileexists(const char *fname) {
442
  FILE *fd;
443
  fd = fopen(fname, "rb");
444
  if (fd == NULL) return(-1);
445
  fclose(fd);
446
  return(0);
447
}
448
 
449
 
310 mateuszvis 450
static int preparedrive(char sourcedrv) {
33 mv_fox 451
  int driveremovable;
310 mateuszvis 452
  int selecteddrive = 3; /* default to 'C:' */
36 mv_fox 453
  int cselecteddrive;
35 mv_fox 454
  int ds;
73 mv_fox 455
  int choice;
56 mv_fox 456
  char buff[1024];
312 mateuszvis 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) */
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
  }
36 mv_fox 462
  cselecteddrive = 'A' + selecteddrive - 1;
28 mv_fox 463
  for (;;) {
33 mv_fox 464
    driveremovable = isdriveremovable(selecteddrive);
465
    if (driveremovable < 0) {
49 mv_fox 466
      char *list[] = { "Create a partition automatically", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
79 mv_fox 467
      newscreen(0);
42 mv_fox 468
      list[0] = kittengets(0, 3, list[0]);
469
      list[1] = kittengets(0, 4, list[1]);
470
      list[2] = kittengets(0, 2, list[2]);
190 mateuszvis 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);
61 mv_fox 472
      putstringwrap(4, 1, COLOR_BODY[mono], buff);
67 mv_fox 473
      switch (menuselect(14, -1, 5, list, -1)) {
33 mv_fox 474
        case 0:
312 mateuszvis 475
          sprintf(buff, "FDISK /AUTO %d", driveid);
476
          system(buff);
33 mv_fox 477
          break;
478
        case 1:
81 mv_fox 479
          video_clear(0x0700, 0, 0);
33 mv_fox 480
          video_movecursor(0, 0);
312 mateuszvis 481
          sprintf(buff, "FDISK %d", driveid);
482
          system(buff);
33 mv_fox 483
          break;
73 mv_fox 484
        case 2:
485
          return(MENUQUIT);
56 mv_fox 486
        default:
33 mv_fox 487
          return(-1);
488
      }
113 mv_fox 489
      /* write a temporary MBR which only skips the drive (in case BIOS would
490
       * try to boot off the not-yet-ready C: disk) */
312 mateuszvis 491
      sprintf(buff, "FDISK /AMBR %d", driveid);
492
      system(buff); /* writes BOOT.MBR into actual MBR */
79 mv_fox 493
      newscreen(2);
61 mv_fox 494
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
42 mv_fox 495
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
33 mv_fox 496
      input_getkey();
28 mv_fox 497
      reboot();
73 mv_fox 498
      return(MENUQUIT);
33 mv_fox 499
    } else if (driveremovable > 0) {
79 mv_fox 500
      newscreen(2);
56 mv_fox 501
      snprintf(buff, sizeof(buff), kittengets(3, 2, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
61 mv_fox 502
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
42 mv_fox 503
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
73 mv_fox 504
      return(MENUQUIT);
28 mv_fox 505
    }
33 mv_fox 506
    /* if not formatted, propose to format it right away (try to create a directory) */
55 mv_fox 507
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
53 mv_fox 508
    if (mkdir(buff) == 0) {
509
      rmdir(buff);
510
    } else {
28 mv_fox 511
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
79 mv_fox 512
      newscreen(0);
42 mv_fox 513
      list[0] = kittengets(0, 6, list[0]);
514
      list[1] = kittengets(0, 2, list[1]);
56 mv_fox 515
      snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
61 mv_fox 516
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
73 mv_fox 517
      choice = menuselect(12, -1, 4, list, -1);
518
      if (choice < 0) return(MENUPREV);
519
      if (choice == 1) return(MENUQUIT);
81 mv_fox 520
      video_clear(0x0700, 0, 0);
28 mv_fox 521
      video_movecursor(0, 0);
190 mateuszvis 522
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
36 mv_fox 523
      system(buff);
28 mv_fox 524
      continue;
525
    }
33 mv_fox 526
    /* check total disk space */
35 mv_fox 527
    ds = disksize(selecteddrive);
190 mateuszvis 528
    if (ds < SVARDOS_DISK_REQ) {
56 mv_fox 529
      int y = 9;
79 mv_fox 530
      newscreen(2);
312 mateuszvis 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);
61 mv_fox 532
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
73 mv_fox 533
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
28 mv_fox 534
      input_getkey();
73 mv_fox 535
      return(MENUQUIT);
28 mv_fox 536
    }
537
    /* is the disk empty? */
79 mv_fox 538
    newscreen(0);
35 mv_fox 539
    if (diskempty(selecteddrive) != 0) {
28 mv_fox 540
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
65 mv_fox 541
      int y = 6;
42 mv_fox 542
      list[0] = kittengets(0, 6, list[0]);
543
      list[1] = kittengets(0, 2, list[1]);
190 mateuszvis 544
      snprintf(buff, sizeof(buff), kittengets(3, 5, "ERROR: Drive %c: is not empty. SvarDOS 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);
65 mv_fox 545
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
73 mv_fox 546
      choice = menuselect(++y, -1, 4, list, -1);
547
      if (choice < 0) return(MENUPREV);
548
      if (choice == 1) return(MENUQUIT);
81 mv_fox 549
      video_clear(0x0700, 0, 0);
28 mv_fox 550
      video_movecursor(0, 0);
190 mateuszvis 551
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
42 mv_fox 552
      system(buff);
28 mv_fox 553
      continue;
554
    } else {
555
      /* final confirmation */
190 mateuszvis 556
      char *list[] = { "Install SvarDOS", "Quit to DOS", NULL};
42 mv_fox 557
      list[0] = kittengets(0, 1, list[0]);
558
      list[1] = kittengets(0, 2, list[1]);
190 mateuszvis 559
      snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of SvarDOS to %c: is about to begin."), cselecteddrive);
56 mv_fox 560
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
73 mv_fox 561
      choice = menuselect(10, -1, 4, list, -1);
562
      if (choice < 0) return(MENUPREV);
563
      if (choice == 1) return(MENUQUIT);
310 mateuszvis 564
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
312 mateuszvis 565
      puts(buff);
36 mv_fox 566
      system(buff);
312 mateuszvis 567
      sprintf(buff, "FDISK /MBR %d", driveid);
568
      puts(buff);
569
      system(buff);
55 mv_fox 570
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
312 mateuszvis 571
      puts(buff);
36 mv_fox 572
      mkdir(buff);
573
      return(cselecteddrive);
28 mv_fox 574
    }
575
  }
576
}
577
 
578
 
280 mateuszvis 579
/* generates locales-related configurations and writes them to file (this
580
 * is used to compute autoexec.bat content) */
581
static void genlocalesconf(FILE *fd, const struct slocales *locales) {
582
  if (locales == NULL) return;
583
 
584
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
585
 
586
  if (locales->egafile > 0) {
587
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
588
    if (locales->egafile == 1) {
589
      fprintf(fd, "MODE CON CP PREPARE=((%u) %%DOSDIR%%\\CPI\\EGA.CPX)\r\n", locales->codepage);
590
    } else {
591
      fprintf(fd, "MODE CON CP PREPARE=((%u) %%DOSDIR%%\\CPI\\EGA%d.CPX)\r\n", locales->codepage, locales->egafile);
592
    }
593
    fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
594
  }
595
 
596
  if (locales->keybfile > 0) {
597
    fprintf(fd, "KEYB %s,%d,%%DOSDIR%%\\BIN\\", locales->keybcode, locales->codepage);
598
    if (locales->keybfile == 1) {
599
      fprintf(fd, "KEYBOARD.SYS");
600
    } else {
601
      fprintf(fd, "KEYBRD%d.SYS", locales->keybfile);
602
    }
603
    if (locales->keybid != 0) fprintf(fd, " /ID:%d", locales->keybid);
604
    fprintf(fd, "\r\n");
605
  }
606
}
607
 
608
 
609
static void bootfilesgen(char targetdrv, const struct slocales *locales) {
28 mv_fox 610
  char buff[128];
611
  FILE *fd;
53 mv_fox 612
  /*** CONFIG.SYS ***/
280 mateuszvis 613
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\CONFIG.SYS", targetdrv);
53 mv_fox 614
  fd = fopen(buff, "wb");
615
  if (fd == NULL) return;
101 mv_fox 616
  fprintf(fd, "DOS=UMB,HIGH\r\n"
617
              "LASTDRIVE=Z\r\n"
618
              "FILES=50\r\n");
312 mateuszvis 619
  fprintf(fd, "DEVICE=C:\\SVARDOS\\BIN\\HIMEMX.EXE\r\n");
77 mv_fox 620
  if (strcmp(locales->lang, "EN") == 0) {
95 mv_fox 621
    strcpy(buff, "COMMAND");
77 mv_fox 622
  } else {
623
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
624
  }
280 mateuszvis 625
  fprintf(fd, "SHELLHIGH=C:\\SVARDOS\\BIN\\%s.COM /E:512 /P\r\n", buff);
626
  fprintf(fd, "REM COUNTRY=001,437,C:\\SVARDOS\\CONF\\COUNTRY.SYS\r\n");
627
  fprintf(fd, "REM DEVICE=C:\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n");
53 mv_fox 628
  fclose(fd);
28 mv_fox 629
  /*** AUTOEXEC.BAT ***/
280 mateuszvis 630
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\AUTOEXEC.BAT", targetdrv);
28 mv_fox 631
  fd = fopen(buff, "wb");
632
  if (fd == NULL) return;
633
  fprintf(fd, "@ECHO OFF\r\n");
280 mateuszvis 634
  fprintf(fd, "SET TEMP=C:\\TEMP\r\n");
635
  fprintf(fd, "SET DOSDIR=C:\\SVARDOS\r\n");
49 mv_fox 636
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
53 mv_fox 637
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
303 mateuszvis 638
  fprintf(fd, "SET WATTCP.CFG=%%DOSDIR%%\\CFG\r\n");
280 mateuszvis 639
  fprintf(fd, "PATH %%DOSDIR%%\\BIN\r\n");
28 mv_fox 640
  fprintf(fd, "PROMPT $P$G\r\n");
30 mv_fox 641
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
642
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
56 mv_fox 643
  fprintf(fd, "FDAPM APMDOS\r\n");
28 mv_fox 644
  fprintf(fd, "\r\n");
280 mateuszvis 645
  genlocalesconf(fd, locales);
49 mv_fox 646
  fprintf(fd, "\r\n");
280 mateuszvis 647
  fprintf(fd, "REM Uncomment the line below for CDROM support\r\n");
648
  fprintf(fd, "REM SHSUCDX /d:SVCD0001\r\n");
649
  fprintf(fd, "\r\n");
49 mv_fox 650
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
651
  fprintf(fd, "REM CTMOUSE\r\n");
652
  fprintf(fd, "\r\n");
53 mv_fox 653
  fprintf(fd, "ECHO.\r\n");
190 mateuszvis 654
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to SvarDOS! Type 'HELP' if you need help."));
28 mv_fox 655
  fclose(fd);
200 mateuszvis 656
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
277 mateuszvis 657
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS", targetdrv);
200 mateuszvis 658
  mkdir(buff);
277 mateuszvis 659
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG", targetdrv);
53 mv_fox 660
  mkdir(buff);
277 mateuszvis 661
  /*** PKG.CFG ***/
662
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\PKG.CFG", targetdrv);
663
  fd = fopen(buff, "wb");
664
  if (fd == NULL) return;
665
  fprintf(fd, "# pkg config file - specifies locations where packages should be installed\r\n"
666
              "\r\n"
667
              "# Programs\r\n"
668
              "DIR PROGS C:\\\r\n"
669
              "\r\n"
670
              "# Games \r\n"
671
              "DIR GAMES C:\\\r\n"
672
              "\r\n"
673
              "# Drivers\r\n"
674
              "DIR DRIVERS C:\\DRIVERS\r\n"
675
              "\r\n"
676
              "# Development tools\r\n"
677
              "DIR DEVEL C:\\DEVEL\r\n");
678
  fclose(fd);
53 mv_fox 679
  /*** COUNTRY.SYS ***/
680
  /*** PICOTCP ***/
681
  /*** WATTCP ***/
303 mateuszvis 682
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\WATTCP.CFG", targetdrv);
683
  fd = fopen(buff, "wb");
684
  if (fd == NULL) return;
685
  fprintf(fd, "my_ip = dhcp\r\n"
686
              "#my_ip = 192.168.0.7\r\n"
687
              "#netmask = 255.255.255.0\r\n"
688
              "#nameserver = 192.168.0.1\r\n"
689
              "#nameserver = 192.168.0.2\r\n"
690
              "#gateway = 192.168.1.1\r\n");
691
  fclose(fd);
28 mv_fox 692
}
693
 
694
 
280 mateuszvis 695
static int installpackages(char targetdrv, char srcdrv, const struct slocales *locales) {
192 mateuszvis 696
  char pkglist[512];
30 mv_fox 697
  int i, pkglistlen;
192 mateuszvis 698
  size_t pkglistflen;
280 mateuszvis 699
  char buff[1024]; /* must be *at least* 1 sector big for efficient file copying */
700
  FILE *fd = NULL;
192 mateuszvis 701
  char *pkgptr;
79 mv_fox 702
  newscreen(3);
192 mateuszvis 703
  /* load pkg list */
704
  fd = fopen("install.lst", "rb");
705
  if (fd == NULL) {
706
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: INSTALL.LST NOT FOUND", -1);
707
    input_getkey();
708
    return(-1);
709
  }
710
  pkglistflen = fread(pkglist, 1, sizeof(pkglist), fd);
711
  fclose(fd);
712
  if (pkglistflen == sizeof(pkglist)) {
713
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: INSTALL.LST TOO LARGE", -1);
714
    input_getkey();
715
    return(-1);
716
  }
717
  pkglist[pkglistflen] = 0xff; /* mark the end of list */
718
  /* replace all \r and \n chars by 0 bytes, and count the number of packages */
719
  pkglistlen = 0;
720
  for (i = 0; i < pkglistflen; i++) {
721
    switch (pkglist[i]) {
722
      case '\n':
723
        pkglistlen++;
724
        /* FALLTHRU */
725
      case '\r':
726
        pkglist[i] = 0;
727
        break;
728
    }
729
  }
280 mateuszvis 730
  /* copy pkg.exe to the new drive, along with all packages */
731
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\pkg.exe", targetdrv);
732
  snprintf(buff + 64, sizeof(buff) - 64, "%c:\\pkg.exe", srcdrv);
733
  fcopy(buff, buff + 64, buff, sizeof(buff));
734
 
735
  /* open the post-install autoexec.bat and prepare initial instructions */
736
  snprintf(buff, sizeof(buff), "%c:\\temp\\postinst.bat", targetdrv);
737
  fd = fopen(buff, "wb");
738
  if (fd == NULL) return(-1);
739
  fprintf(fd, "@ECHO OFF\r\n");
740
 
741
  /* copy packages */
192 mateuszvis 742
  pkgptr = pkglist;
743
  for (i = 0;; i++) {
744
    /* move forward to nearest entry or end of list */
745
    while (*pkgptr == 0) pkgptr++;
746
    if (*pkgptr == 0xff) break;
747
    /* install the package */
748
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkgptr);
36 mv_fox 749
    strcat(buff, "       ");
192 mateuszvis 750
    video_putstringfix(10, 1, COLOR_BODY[mono], buff, sizeof(buff));
200 mateuszvis 751
    /* wait for new diskette if package not found */
280 mateuszvis 752
    snprintf(buff, sizeof(buff), "%c:\\%s.zip", srcdrv, pkgptr);
200 mateuszvis 753
    while (fileexists(buff) != 0) {
754
      putstringnls(12, 1, COLOR_BODY[mono], 4, 1, "*** INSERT THE DISK THAT CONTAINS THE REQUIRED FILE AND PRESS ANY KEY ***");
755
      input_getkey();
756
      video_putstringfix(12, 1, COLOR_BODY[mono], "", 80); /* erase the 'insert disk' message */
757
    }
280 mateuszvis 758
    /* proceed with package copy (buff contains the src filename already) */
759
    snprintf(buff + 32, sizeof(buff) - 32, "%c:\\temp\\%s.zip", targetdrv, pkgptr);
760
    if (fcopy(buff + 32, buff, buff, sizeof(buff)) != 0) {
761
      video_putstring(10, 30, COLOR_BODY[mono], "READ ERROR", -1);
192 mateuszvis 762
      input_getkey();
280 mateuszvis 763
      fclose(fd);
192 mateuszvis 764
      return(-1);
55 mv_fox 765
    }
280 mateuszvis 766
    /* write install instruction to post-install script */
767
    fprintf(fd, "pkg install %s.zip\r\ndel %s.zip\r\n", pkgptr, pkgptr);
192 mateuszvis 768
    /* jump to next entry or end of list */
769
    while ((*pkgptr != 0) && (*pkgptr != 0xff)) pkgptr++;
770
    if (*pkgptr == 0xff) break;
28 mv_fox 771
  }
280 mateuszvis 772
  /* set up locales so the "installation over" message is nicely displayed */
773
  genlocalesconf(fd, locales);
774
  /* replace autoexec.bat and config.sys now and write some nice message on screen */
775
  fprintf(fd, "DEL pkg.exe\r\n"
776
              "COPY CONFIG.SYS C:\\\r\n"
777
              "DEL CONFIG.SYS\r\n"
778
              "DEL C:\\AUTOEXEC.BAT\r\n"
779
              "COPY AUTOEXEC.BAT C:\\\r\n"
780
              "DEL AUTOEXEC.BAT\r\n");
781
  /* print out the "installation over" message */
782
  fprintf(fd, "ECHO.\r\n"
783
              "ECHO %s\r\n"
784
              "ECHO.\r\n", kittengets(5, 1, "SvarDOS installation is over. Please restart your computer now."));
785
  fclose(fd);
786
 
787
  /* prepare a dummy autoexec.bat that will call temp\postinst.bat */
788
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", targetdrv);
789
  fd = fopen(buff, "wb");
790
  if (fd == NULL) return(-1);
791
  fprintf(fd, "@ECHO OFF\r\n"
792
              "SET DOSDIR=C:\\SVARDOS\r\n"
793
              "SET NLSPATH=%%DOSDIR%%\\NLS\r\n"
794
              "PATH %%DOSDIR%%\\BIN\r\n");
795
  fprintf(fd, "CD TEMP\r\n"
796
              "postinst.bat\r\n");
797
  fclose(fd);
798
 
192 mateuszvis 799
  return(0);
28 mv_fox 800
}
801
 
802
 
42 mv_fox 803
static void finalreboot(void) {
56 mv_fox 804
  int y = 9;
79 mv_fox 805
  newscreen(2);
280 mateuszvis 806
  y += putstringnls(y, 1, COLOR_BODY[mono], 5, 0, "Your computer will reboot now.\nPlease remove the installation disk from your drive.");
61 mv_fox 807
  putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
42 mv_fox 808
  input_getkey();
809
  reboot();
810
}
811
 
812
 
192 mateuszvis 813
static void loadcp(const struct slocales *locales) {
42 mv_fox 814
  char buff[64];
67 mv_fox 815
  if (locales->codepage == 437) return;
42 mv_fox 816
  video_movecursor(1, 0);
67 mv_fox 817
  if (locales->egafile == 1) {
310 mateuszvis 818
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA.CPX) > NUL", locales->codepage);
42 mv_fox 819
  } else {
310 mateuszvis 820
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
42 mv_fox 821
  }
822
  system(buff);
67 mv_fox 823
  snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
42 mv_fox 824
  system(buff);
825
  /* below I re-init the video controller - apparently this is required if
65 mv_fox 826
   * I want the new glyph symbols to be actually applied, at least some
827
   * (broken?) BIOSes, like VBox, apply glyphs only at next video mode change */
42 mv_fox 828
  {
829
  union REGS r;
830
  r.h.ah = 0x0F; /* get current video mode */
831
  int86(0x10, &r, &r); /* r.h.al contains the current video mode now */
56 mv_fox 832
  r.h.al |= 128; /* set the high bit of AL to instruct BIOS not to flush VRAM's content (EGA+) */
833
  r.h.ah = 0; /* re-set video mode (to whatever is set in AL) */
42 mv_fox 834
  int86(0x10, &r, &r);
835
  }
836
}
837
 
200 mateuszvis 838
 
310 mateuszvis 839
#ifdef DEADCODE
193 mateuszvis 840
/* checks that drive drv contains SvarDOS packages
65 mv_fox 841
 * returns 0 if found, non-zero otherwise */
193 mateuszvis 842
static int checkinstsrc(char drv) {
843
  char fname[16];
844
  snprintf(fname, sizeof(fname), "%c:\\ATTRIB.ZIP", drv);
200 mateuszvis 845
  return(fileexists(fname));
69 mv_fox 846
}
310 mateuszvis 847
#endif
65 mv_fox 848
 
849
 
28 mv_fox 850
int main(void) {
67 mv_fox 851
  struct slocales locales;
28 mv_fox 852
  int targetdrv;
193 mateuszvis 853
  int sourcedrv;
73 mv_fox 854
  int action;
28 mv_fox 855
 
310 mateuszvis 856
  sourcedrv = get_cur_drive() + 'A';
53 mv_fox 857
 
29 mv_fox 858
  /* init screen and detect mono status */
859
  mono = video_init();
860
 
73 mv_fox 861
  kittenopen("INSTALL"); /* load initial NLS support */
862
 
863
 SelectLang:
190 mateuszvis 864
  action = selectlang(&locales); /* welcome to svardos, select your language */
73 mv_fox 865
  if (action != MENUNEXT) goto Quit;
866
  setenv("LANG", locales.lang, 1);
867
  loadcp(&locales);
868
  kittenclose(); /* reload NLS with new language */
869
  kittenopen("INSTALL"); /* NLS support */
870
  action = selectkeyb(&locales);  /* what keyb layout should we use? */
871
  if (action == MENUQUIT) goto Quit;
872
  if (action == MENUPREV) goto SelectLang;
873
 
874
 WelcomeScreen:
190 mateuszvis 875
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
73 mv_fox 876
  if (action == MENUQUIT) goto Quit;
877
  if (action == MENUPREV) goto SelectLang;
312 mateuszvis 878
  targetdrv = preparedrive(sourcedrv); /* what drive should we install from? check avail. space */
73 mv_fox 879
  if (targetdrv == MENUQUIT) goto Quit;
880
  if (targetdrv == MENUPREV) goto WelcomeScreen;
280 mateuszvis 881
  bootfilesgen(targetdrv, &locales); /* generate boot files and other configurations */
882
  if (installpackages(targetdrv, sourcedrv, &locales) != 0) goto Quit;    /* install packages */
73 mv_fox 883
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
884
  /*netcfg();*/ /* basic networking config */
885
  finalreboot(); /* remove the CD and reboot */
886
 
887
 Quit:
42 mv_fox 888
  kittenclose(); /* close NLS support */
81 mv_fox 889
  video_clear(0x0700, 0, 0);
28 mv_fox 890
  video_movecursor(0, 0);
891
  return(0);
892
}