Subversion Repositories SvarDOS

Rev

Rev 47 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 47 Rev 48
1
/*
1
/*
2
 * SVAROG386 INSTALL
2
 * SVAROG386 INSTALL
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE
4
 *
4
 *
5
 * http://svarog386.sf.net
5
 * http://svarog386.sf.net
6
 */
6
 */
7
 
7
 
8
#include <dos.h>
8
#include <dos.h>
9
#include <direct.h>  /* mkdir() */
9
#include <direct.h>  /* mkdir() */
10
#include <stdio.h>   /* printf() and friends */
10
#include <stdio.h>   /* printf() and friends */
11
#include <stdlib.h>  /* system() */
11
#include <stdlib.h>  /* system() */
12
#include <string.h>  /* memcpy() */
12
#include <string.h>  /* memcpy() */
13
#include <unistd.h>
13
#include <unistd.h>
14
 
14
 
15
#include "kitten\kitten.h"
15
#include "kitten\kitten.h"
16
 
16
 
17
#include "input.h"
17
#include "input.h"
18
#include "video.h"
18
#include "video.h"
19
 
19
 
20
 
20
 
21
/* color scheme (color, mono) */
21
/* color scheme (color, mono) */
22
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
22
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
23
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
23
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
24
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
24
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
25
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
25
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
26
 
26
 
27
/* mono flag */
27
/* mono flag */
28
static int mono = 0;
28
static int mono = 0;
29
 
29
 
30
/* how much disk space does Svarog386 require (in MiB) */
30
/* how much disk space does Svarog386 require (in MiB) */
31
#define SVAROG_DISK_REQ 8
31
#define SVAROG_DISK_REQ 8
32
 
32
 
33
 
33
 
34
/* reboot the computer */
34
/* reboot the computer */
35
static void reboot(void) {
35
static void reboot(void) {
36
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
36
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
37
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
37
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
38
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
38
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
39
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
39
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
40
}
40
}
41
 
41
 
42
 
42
 
43
/* an NLS wrapper around video_putstring() */
43
/* an NLS wrapper around video_putstring() */
44
static void putstringnls(int y, int x, unsigned short attr, int nlsmaj, int nlsmin, char *s) {
44
static void putstringnls(int y, int x, unsigned short attr, int nlsmaj, int nlsmin, char *s) {
45
  s = kittengets(nlsmaj, nlsmin, s);
45
  s = kittengets(nlsmaj, nlsmin, s);
46
  video_putstring(y, x, attr, s);
46
  video_putstring(y, x, attr, s);
47
}
47
}
48
 
48
 
49
 
49
 
50
#define LDEC(x,y) (((unsigned short)x << 8) | (unsigned short)y)
50
#define LDEC(x,y) (((unsigned short)x << 8) | (unsigned short)y)
51
/* provides codepage and country files required by lang */
51
/* provides codepage and country files required by lang */
52
static int getnlscp(char *lang, int *egafile) {
52
static int getnlscp(char *lang, int *egafile) {
53
  unsigned short l;
53
  unsigned short l;
54
  l = lang[0];
54
  l = lang[0];
55
  l <<= 8;
55
  l <<= 8;
56
  l |= lang[1];
56
  l |= lang[1];
57
  switch (l) {
57
  switch (l) {
58
    case LDEC('E','N'):
58
    case LDEC('E','N'):
59
      *egafile = 0;
59
      *egafile = 0;
60
      return(437);
60
      return(437);
61
    case LDEC('P','L'):
61
    case LDEC('P','L'):
62
      *egafile = 10;
62
      *egafile = 10;
63
      return(991);
63
      return(991);
64
  }
64
  }
65
  *egafile = 0;
65
  *egafile = 0;
66
  return(437);
66
  return(437);
67
}
67
}
68
 
68
 
69
 
69
 
70
static int menuselect(int ypos, int xpos, int height, char **list) {
70
static int menuselect(int ypos, int xpos, int height, char **list) {
71
  int i, offset = 0, res = 0, count, width = 0;
71
  int i, offset = 0, res = 0, count, width = 0;
72
  /* count how many languages there is */
72
  /* count how many languages there is */
73
  for (count = 0; list[count] != NULL; count++) {
73
  for (count = 0; list[count] != NULL; count++) {
74
    int len = strlen(list[count]);
74
    int len = strlen(list[count]);
75
    if (len > width) width = len;
75
    if (len > width) width = len;
76
  }
76
  }
77
 
77
 
78
  /* if xpos negative, means 'center out' */
78
  /* if xpos negative, means 'center out' */
79
  if (xpos < 0) xpos = 39 - (width >> 1);
79
  if (xpos < 0) xpos = 39 - (width >> 1);
80
 
80
 
81
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
81
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
82
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
82
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
83
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
83
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
84
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
84
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
85
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
85
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
86
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
86
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
87
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
87
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
88
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
88
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
89
 
89
 
90
  for (;;) {
90
  for (;;) {
91
    int key;
91
    int key;
92
    /* list of selectable items */
92
    /* list of selectable items */
93
    for (i = 0; i < height - 2; i++) {
93
    for (i = 0; i < height - 2; i++) {
94
      if (i + offset == res) {
94
      if (i + offset == res) {
95
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
95
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
96
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
96
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
97
        video_movecursor(ypos + 1 + i, xpos);
97
        video_movecursor(ypos + 1 + i, xpos);
98
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
98
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
99
      } else if (i + offset < count) {
99
      } else if (i + offset < count) {
100
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
100
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
101
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
101
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
102
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
102
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
103
      } else {
103
      } else {
104
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
104
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
105
      }
105
      }
106
    }
106
    }
107
    key = input_getkey();
107
    key = input_getkey();
108
    if (key == 0x0D) { /* ENTER */
108
    if (key == 0x0D) { /* ENTER */
109
      return(res);
109
      return(res);
110
    } else if (key == 0x148) { /* up */
110
    } else if (key == 0x148) { /* up */
111
      if (res > 0) {
111
      if (res > 0) {
112
        res--;
112
        res--;
113
        if (res < offset) offset = res;
113
        if (res < offset) offset = res;
114
      }
114
      }
115
    } else if (key == 0x150) { /* down */
115
    } else if (key == 0x150) { /* down */
116
      if (res+1 < count) {
116
      if (res+1 < count) {
117
        res++;
117
        res++;
118
        if (res > offset + height - 3) offset = res - (height - 3);
118
        if (res > offset + height - 3) offset = res - (height - 3);
119
      }
119
      }
120
    } else if (key == 0x147) { /* home */
120
    } else if (key == 0x147) { /* home */
121
      res = 0;
121
      res = 0;
122
      offset = 0;
122
      offset = 0;
123
    } else if (key == 0x14F) { /* end */
123
    } else if (key == 0x14F) { /* end */
124
      res = count - 1;
124
      res = count - 1;
125
      if (res > offset + height - 3) offset = res - (height - 3);
125
      if (res > offset + height - 3) offset = res - (height - 3);
126
    } else if (key == 0x1B) {  /* ESC */
126
    } else if (key == 0x1B) {  /* ESC */
127
      return(-1);
127
      return(-1);
128
    } else {
128
    } else {
129
      char buf[8];
129
      char buf[8];
130
      sprintf(buf, "0x%02X ", key);
130
      sprintf(buf, "0x%02X ", key);
131
      video_putstring(1, 0, COLOR_BODY[mono], buf);
131
      video_putstring(1, 0, COLOR_BODY[mono], buf);
132
    }
132
    }
133
  }
133
  }
134
}
134
}
135
 
135
 
136
static void newscreen(void) {
136
static void newscreen(void) {
137
  int x;
137
  int x;
138
  char *title;
138
  char *title;
139
  title = kittengets(0, 0, "SVAROG386 INSTALLATION");
139
  title = kittengets(0, 0, "SVAROG386 INSTALLATION");
140
  for (x = 0; x < 80; x++) video_putchar(0, x, COLOR_TITLEBAR[mono], ' ');
140
  for (x = 0; x < 80; x++) video_putchar(0, x, COLOR_TITLEBAR[mono], ' ');
141
  video_putstring(0, 40 - (strlen(title) >> 1), COLOR_TITLEBAR[mono], title);
141
  video_putstring(0, 40 - (strlen(title) >> 1), COLOR_TITLEBAR[mono], title);
142
  video_clear(COLOR_BODY[mono], 80);
142
  video_clear(COLOR_BODY[mono], 80);
143
  video_movecursor(25,0);
143
  video_movecursor(25,0);
144
}
144
}
145
 
145
 
146
static int selectlang(char *lang) {
146
static int selectlang(char *lang) {
147
  int choice;
147
  int choice;
148
  int x;
148
  int x;
149
  char *msg;
149
  char *msg;
150
  char *code;
150
  char *code;
151
  char *langlist[] = {
151
  char *langlist[] = {
152
    "English\0EN",
152
    "English\0EN",
153
    "French\0FR",
153
    "French\0FR",
154
    "German\0DE",
154
    "German\0DE",
155
    "Italian\0IT",
155
    "Italian\0IT",
156
    "Polish\0PL",
156
    "Polish\0PL",
157
    "Russian\0RU",
157
    "Russian\0RU",
158
    "Slovenian\0SL",
158
    "Slovenian\0SL",
159
    "Spanish\0ES",
159
    "Spanish\0ES",
160
    "Turkish\0TR",
160
    "Turkish\0TR",
161
    NULL
161
    NULL
162
  };
162
  };
163
 
163
 
164
  newscreen();
164
  newscreen();
165
  msg = kittengets(1, 0, "Welcome to Svarog386");
165
  msg = kittengets(1, 0, "Welcome to Svarog386");
166
  x = 40 - (strlen(msg) >> 1);
166
  x = 40 - (strlen(msg) >> 1);
167
  video_putstring(4, x, COLOR_BODY[mono], msg);
167
  video_putstring(4, x, COLOR_BODY[mono], msg);
168
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
168
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
169
  putstringnls(8, 2, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
169
  putstringnls(8, 2, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
170
  choice = menuselect(10, -1, 12, langlist);
170
  choice = menuselect(10, -1, 12, langlist);
171
  if (choice < 0) return(-1);
171
  if (choice < 0) return(-1);
172
  /* write short language code into lang */
172
  /* write short language code into lang */
173
  for (code = langlist[choice]; *code != 0; code++);
173
  for (code = langlist[choice]; *code != 0; code++);
174
  memcpy(lang, code + 1, 2);
174
  memcpy(lang, code + 1, 2);
175
  lang[2] = 0;
175
  lang[2] = 0;
176
  return(0);
176
  return(0);
177
}
177
}
178
 
178
 
179
 
179
 
180
/* returns 0 if installation must proceed, non-zero otherwise */
180
/* returns 0 if installation must proceed, non-zero otherwise */
181
static int welcomescreen(void) {
181
static int welcomescreen(void) {
182
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
182
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
183
  choice[0] = kittengets(0, 1, choice[0]);
183
  choice[0] = kittengets(0, 1, choice[0]);
184
  choice[1] = kittengets(0, 2, choice[1]);
184
  choice[1] = kittengets(0, 2, choice[1]);
185
  newscreen();
185
  newscreen();
186
  putstringnls(4, 1, COLOR_BODY[mono], 2, 0, "You are about to install Svarog386: a free, MSDOS-compatible operating system");
186
  putstringnls(4, 1, COLOR_BODY[mono], 2, 0, "You are about to install Svarog386: a free, MSDOS-compatible operating system");
187
  putstringnls(5, 1, COLOR_BODY[mono], 2, 1, "based on the FreeDOS kernel. Svarog386 targets 386+ computers and comes with a");
187
  putstringnls(5, 1, COLOR_BODY[mono], 2, 1, "based on the FreeDOS kernel. Svarog386 targets 386+ computers and comes with a");
188
  putstringnls(6, 1, COLOR_BODY[mono], 2, 2, "variety of third-party applications.");
188
  putstringnls(6, 1, COLOR_BODY[mono], 2, 2, "variety of third-party applications.");
189
  putstringnls(8, 1, COLOR_BODY[mono], 2, 3, "WARNING: If your PC has another operating system installed, this other system");
189
  putstringnls(8, 1, COLOR_BODY[mono], 2, 3, "WARNING: If your PC has another operating system installed, this other system");
190
  putstringnls(9, 1, COLOR_BODY[mono], 2, 4, "         might be unable to boot once Svarog386 is installed.");
190
  putstringnls(9, 1, COLOR_BODY[mono], 2, 4, "         might be unable to boot once Svarog386 is installed.");
191
  return(menuselect(13, -1, 4, choice));
191
  return(menuselect(13, -1, 4, choice));
192
}
192
}
193
 
193
 
194
 
194
 
195
/* returns 1 if drive is removable, 0 if not, -1 on error */
195
/* returns 1 if drive is removable, 0 if not, -1 on error */
196
static int isdriveremovable(int drv) {
196
static int isdriveremovable(int drv) {
197
  union REGS r;
197
  union REGS r;
198
  r.x.ax = 0x4408;
198
  r.x.ax = 0x4408;
199
  r.h.bl = drv;
199
  r.h.bl = drv;
200
  int86(0x21, &r, &r);
200
  int86(0x21, &r, &r);
201
  /* CF set on error, AX set to 0 if removable, 1 if fixed */
201
  /* CF set on error, AX set to 0 if removable, 1 if fixed */
202
  if (r.x.cflag != 0) return(-1);
202
  if (r.x.cflag != 0) return(-1);
203
  if (r.x.ax == 0) return(1);
203
  if (r.x.ax == 0) return(1);
204
  return(0);
204
  return(0);
205
}
205
}
206
 
206
 
207
 
207
 
208
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
208
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
209
static int disksize(int drv) {
209
static int disksize(int drv) {
210
  long res;
210
  long res;
211
  union REGS r;
211
  union REGS r;
212
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
212
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
213
  r.h.dl = drv;
213
  r.h.dl = drv;
214
  int86(0x21, &r, &r);
214
  int86(0x21, &r, &r);
215
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
215
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
216
  res = r.x.ax;
216
  res = r.x.ax;
217
  res *= r.x.bx;
217
  res *= r.x.bx;
218
  res *= r.x.cx;
218
  res *= r.x.cx;
219
  return(res >> 20); /* return result after converting bytes to MiB */
219
  return(res >> 20); /* return result after converting bytes to MiB */
220
}
220
}
221
 
221
 
222
 
222
 
223
/* returns 0 if disk is empty, non-zero otherwise */
223
/* returns 0 if disk is empty, non-zero otherwise */
224
static int diskempty(int drv) {
224
static int diskempty(int drv) {
225
  unsigned int rc;
225
  unsigned int rc;
226
  int res;
226
  int res;
227
  char buff[8];
227
  char buff[8];
228
  struct find_t fileinfo;
228
  struct find_t fileinfo;
229
  sprintf(buff, "%c:\\*.*", 'A' + drv - 1);
229
  sprintf(buff, "%c:\\*.*", 'A' + drv - 1);
230
  rc = _dos_findfirst(buff, _A_NORMAL | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM, &fileinfo);
230
  rc = _dos_findfirst(buff, _A_NORMAL | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM, &fileinfo);
231
  if (rc == 0) {
231
  if (rc == 0) {
232
    res = 1; /* call successfull means disk is not empty */
232
    res = 1; /* call successfull means disk is not empty */
233
  } else {
233
  } else {
234
    res = 0;
234
    res = 0;
235
  }
235
  }
236
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
236
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
237
  return(res);
237
  return(res);
238
}
238
}
239
 
239
 
240
 
240
 
241
static int preparedrive(void) {
241
static int preparedrive(void) {
242
  int driveremovable;
242
  int driveremovable;
243
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
243
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
244
  int cselecteddrive;
244
  int cselecteddrive;
245
  int ds;
245
  int ds;
246
  char buff[128];
246
  char buff[128];
247
  cselecteddrive = 'A' + selecteddrive - 1;
247
  cselecteddrive = 'A' + selecteddrive - 1;
248
  for (;;) {
248
  for (;;) {
249
    newscreen();
249
    newscreen();
250
    driveremovable = isdriveremovable(selecteddrive);
250
    driveremovable = isdriveremovable(selecteddrive);
251
    if (driveremovable < 0) {
251
    if (driveremovable < 0) {
252
      char *list[] = { "Create an automatic partition", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
252
      char *list[] = { "Create an automatic partition", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
253
      list[0] = kittengets(0, 3, list[0]);
253
      list[0] = kittengets(0, 3, list[0]);
254
      list[1] = kittengets(0, 4, list[1]);
254
      list[1] = kittengets(0, 4, list[1]);
255
      list[2] = kittengets(0, 2, list[2]);
255
      list[2] = kittengets(0, 2, list[2]);
256
      sprintf(buff, kittengets(3, 0, "ERROR: Drive %c: could not be found. Perhaps your hard disk needs to be"), cselecteddrive);
256
      sprintf(buff, kittengets(3, 0, "ERROR: Drive %c: could not be found. Perhaps your hard disk needs to be"), cselecteddrive);
257
      video_putstring(4, 2, COLOR_BODY[mono], buff);
257
      video_putstring(4, 2, COLOR_BODY[mono], buff);
258
      putstringnls(5, 2, COLOR_BODY[mono], 3, 1, "       partitioned first. Please create at least one partition on your");
258
      putstringnls(5, 2, COLOR_BODY[mono], 3, 1, "       partitioned first. Please create at least one partition on your");
259
      putstringnls(6, 2, COLOR_BODY[mono], 3, 2, "       hard disk, so Svarog386 can be installed on it. Note, that");
259
      putstringnls(6, 2, COLOR_BODY[mono], 3, 2, "       hard disk, so Svarog386 can be installed on it. Note, that");
260
      sprintf(buff, kittengets(3, 3, "       Svarog386 requires at least %d MiB of available disk space."), SVAROG_DISK_REQ);
260
      sprintf(buff, kittengets(3, 3, "       Svarog386 requires at least %d MiB of available disk space."), SVAROG_DISK_REQ);
261
      video_putstring(7, 2, COLOR_BODY[mono], buff);
261
      video_putstring(7, 2, COLOR_BODY[mono], buff);
262
      putstringnls(9, 2, COLOR_BODY[mono], 3, 4, "You can use the FDISK partitioning tool for creating the required partition");
262
      putstringnls(9, 2, COLOR_BODY[mono], 3, 4, "You can use the FDISK partitioning tool for creating the required partition");
263
      putstringnls(10, 2, COLOR_BODY[mono], 3, 5, "manually, or you can let the installer partitioning your disk");
263
      putstringnls(10, 2, COLOR_BODY[mono], 3, 5, "manually, or you can let the installer partitioning your disk");
264
      putstringnls(11, 2, COLOR_BODY[mono], 3, 6, "automatically. You can also abort the installation to use any other");
264
      putstringnls(11, 2, COLOR_BODY[mono], 3, 6, "automatically. You can also abort the installation to use any other");
265
      putstringnls(12, 2, COLOR_BODY[mono], 3, 7, "partition manager of your choice.");
265
      putstringnls(12, 2, COLOR_BODY[mono], 3, 7, "partition manager of your choice.");
266
      switch (menuselect(14, -1, 5, list)) {
266
      switch (menuselect(14, -1, 5, list)) {
267
        case 0:
267
        case 0:
268
          system("FDISK /AUTO");
268
          system("FDISK /AUTO");
269
          break;
269
          break;
270
        case 1:
270
        case 1:
271
          video_clear(0x0700, 0);
271
          video_clear(0x0700, 0);
272
          video_movecursor(0, 0);
272
          video_movecursor(0, 0);
273
          system("FDISK");
273
          system("FDISK");
274
          break;
274
          break;
275
        case 2:
275
        case 2:
276
          return(-1);
276
          return(-1);
277
      }
277
      }
278
      newscreen();
278
      newscreen();
279
      putstringnls(11, 10, COLOR_BODY[mono], 3, 8, "Your computer will reboot now.");
279
      putstringnls(11, 10, COLOR_BODY[mono], 3, 8, "Your computer will reboot now.");
280
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
280
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
281
      input_getkey();
281
      input_getkey();
282
      reboot();
282
      reboot();
283
      return(-1);
283
      return(-1);
284
    } else if (driveremovable > 0) {
284
    } else if (driveremovable > 0) {
285
      sprintf(buff, kittengets(3, 9, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
285
      sprintf(buff, kittengets(3, 9, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
286
      video_putstring(9, 2, COLOR_BODY[mono], buff);
286
      video_putstring(9, 2, COLOR_BODY[mono], buff);
287
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
287
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
288
      return(-1);
288
      return(-1);
289
    }
289
    }
290
    /* if not formatted, propose to format it right away (try to create a directory) */
290
    /* if not formatted, propose to format it right away (try to create a directory) */
291
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
291
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
292
    if (mkdir(buff) != 0) {
292
    if (mkdir(buff) != 0) {
293
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
293
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
294
      list[0] = kittengets(0, 6, list[0]);
294
      list[0] = kittengets(0, 6, list[0]);
295
      list[1] = kittengets(0, 2, list[1]);
295
      list[1] = kittengets(0, 2, list[1]);
296
      sprintf(buff, kittengets(3, 10, "ERROR: Drive %c: seems to be unformated."), cselecteddrive);
296
      sprintf(buff, kittengets(3, 10, "ERROR: Drive %c: seems to be unformated."), cselecteddrive);
297
      video_putstring(7, 2, COLOR_BODY[mono], buff);
297
      video_putstring(7, 2, COLOR_BODY[mono], buff);
298
      putstringnls(8, 2, COLOR_BODY[mono], 3, 11, "       Do you wish to format it?");
298
      putstringnls(8, 2, COLOR_BODY[mono], 3, 11, "       Do you wish to format it?");
299
      if (menuselect(12, -1, 4, list) != 0) return(-1);
299
      if (menuselect(12, -1, 4, list) != 0) return(-1);
300
      video_clear(0x0700, 0);
300
      video_clear(0x0700, 0);
301
      video_movecursor(0, 0);
301
      video_movecursor(0, 0);
302
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
302
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
303
      system(buff);
303
      system(buff);
304
      continue;
304
      continue;
305
    }
305
    }
306
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
306
    sprintf(buff, "%c:\\SVWRTEST.123", cselecteddrive);
307
    rmdir(buff);
307
    rmdir(buff);
308
    /* check total disk space */
308
    /* check total disk space */
309
    ds = disksize(selecteddrive);
309
    ds = disksize(selecteddrive);
310
    if (ds < SVAROG_DISK_REQ) {
310
    if (ds < SVAROG_DISK_REQ) {
311
      sprintf(buff, kittengets(3, 12, "ERROR: Drive %c: is not big enough!"), cselecteddrive);
311
      sprintf(buff, kittengets(3, 12, "ERROR: Drive %c: is not big enough!"), cselecteddrive);
312
      video_putstring(9, 2, COLOR_BODY[mono], buff);
312
      video_putstring(9, 2, COLOR_BODY[mono], buff);
313
      sprintf(buff, kittengets(3, 13, "      Svarog386 requires a disk of at least %d MiB."), SVAROG_DISK_REQ);
313
      sprintf(buff, kittengets(3, 13, "      Svarog386 requires a disk of at least %d MiB."), SVAROG_DISK_REQ);
314
      video_putstring(10, 2, COLOR_BODY[mono], buff);
314
      video_putstring(10, 2, COLOR_BODY[mono], buff);
315
      putstringnls(12, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
315
      putstringnls(12, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
316
      input_getkey();
316
      input_getkey();
317
      return(-1);
317
      return(-1);
318
    }
318
    }
319
    /* is the disk empty? */
319
    /* is the disk empty? */
320
    if (diskempty(selecteddrive) != 0) {
320
    if (diskempty(selecteddrive) != 0) {
321
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
321
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
322
      list[0] = kittengets(0, 6, list[0]);
322
      list[0] = kittengets(0, 6, list[0]);
323
      list[1] = kittengets(0, 2, list[1]);
323
      list[1] = kittengets(0, 2, list[1]);
324
      sprintf(buff, kittengets(3, 14, "ERROR: Drive %c: is not empty. Svarog386 must be installed on an empty disk."), cselecteddrive);
324
      sprintf(buff, kittengets(3, 14, "ERROR: Drive %c: is not empty. Svarog386 must be installed on an empty disk."), cselecteddrive);
325
      video_putstring(7, 2, COLOR_BODY[mono], buff);
325
      video_putstring(7, 2, COLOR_BODY[mono], buff);
326
      putstringnls(8, 2, COLOR_BODY[mono], 3, 15, "       You can format the disk now, to make it empty. Note however, that");
326
      putstringnls(8, 2, COLOR_BODY[mono], 3, 15, "       You can format the disk now, to make it empty. Note however, that");
327
      putstringnls(9, 2, COLOR_BODY[mono], 3, 16, "       this will ERASE ALL CURRENT DATA on your disk.");
327
      putstringnls(9, 2, COLOR_BODY[mono], 3, 16, "       this will ERASE ALL CURRENT DATA on your disk.");
328
      if (menuselect(12, -1, 4, list) != 0) return(-1);
328
      if (menuselect(12, -1, 4, list) != 0) return(-1);
329
      video_clear(0x0700, 0);
329
      video_clear(0x0700, 0);
330
      video_movecursor(0, 0);
330
      video_movecursor(0, 0);
331
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
331
      sprintf(buff, "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
332
      system(buff);
332
      system(buff);
333
      continue;
333
      continue;
334
    } else {
334
    } else {
335
      /* final confirmation */
335
      /* final confirmation */
336
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
336
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
337
      list[0] = kittengets(0, 1, list[0]);
337
      list[0] = kittengets(0, 1, list[0]);
338
      list[1] = kittengets(0, 2, list[1]);
338
      list[1] = kittengets(0, 2, list[1]);
339
      sprintf(buff, kittengets(3, 17, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
339
      sprintf(buff, kittengets(3, 17, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
340
      video_putstring(7, 2, COLOR_BODY[mono], buff);
340
      video_putstring(7, 2, COLOR_BODY[mono], buff);
341
      if (menuselect(10, -1, 4, list) != 0) return(-1);
341
      if (menuselect(10, -1, 4, list) != 0) return(-1);
342
      sprintf(buff, "SYS A: %c:", cselecteddrive);
342
      sprintf(buff, "SYS A: %c:", cselecteddrive);
343
      system(buff);
343
      system(buff);
344
      sprintf(buff, "%c:\\TEMP", cselecteddrive);
344
      sprintf(buff, "%c:\\TEMP", cselecteddrive);
345
      mkdir(buff);
345
      mkdir(buff);
346
      return(cselecteddrive);
346
      return(cselecteddrive);
347
    }
347
    }
348
  }
348
  }
349
}
349
}
350
 
350
 
351
 
351
 
352
static void bootfilesgen(int targetdrv, char *lang) {
352
static void bootfilesgen(int targetdrv, char *lang) {
353
  char buff[128];
353
  char buff[128];
354
  FILE *fd;
354
  FILE *fd;
355
  /*** AUTOEXEC.BAT ***/
355
  /*** AUTOEXEC.BAT ***/
356
  sprintf(buff, "%c:\\AUTOEXEC.BAT", targetdrv);
356
  sprintf(buff, "%c:\\AUTOEXEC.BAT", targetdrv);
357
  fd = fopen(buff, "wb");
357
  fd = fopen(buff, "wb");
358
  if (fd == NULL) return;
358
  if (fd == NULL) return;
359
  fprintf(fd, "@ECHO OFF\r\n");
359
  fprintf(fd, "@ECHO OFF\r\n");
360
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
360
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
361
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
361
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
362
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n", targetdrv);
362
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n", targetdrv);
363
  fprintf(fd, "SET LANG=%s\r\n", lang);
363
  fprintf(fd, "SET LANG=%s\r\n", lang);
364
  fprintf(fd, "SET DIRCMD=/OGNE/P\r\n");
364
  fprintf(fd, "SET DIRCMD=/OGNE/P\r\n");
365
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n");
365
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n");
366
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n");
366
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n");
367
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%%DOSDIR%%\\LINKS\r\n");
367
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%%DOSDIR%%\\LINKS\r\n");
368
  fprintf(fd, "PROMPT $P$G\r\n");
368
  fprintf(fd, "PROMPT $P$G\r\n");
369
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
369
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
370
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
370
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
371
  fprintf(fd, "\r\n\r\n");
371
  fprintf(fd, "\r\n\r\n");
372
  fprintf(fd, "MODE CON CP PREPARE=((991) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA10.CPX)\r\n");
372
  fprintf(fd, "MODE CON CP PREPARE=((991) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA10.CPX)\r\n");
373
  fprintf(fd, "MODE CON CP SELECT=991\r\n");
373
  fprintf(fd, "MODE CON CP SELECT=991\r\n");
374
  fprintf(fd, "\r\n");
374
  fprintf(fd, "\r\n");
375
  fprintf(fd, "SHSUCDX /d:FDCD0001\r\n");
375
  fprintf(fd, "SHSUCDX /d:FDCD0001\r\n");
376
  fclose(fd);
376
  fclose(fd);
377
  /*** CONFIG.SYS ***/
377
  /*** CONFIG.SYS ***/
378
  sprintf(buff, "%c:\\CONFIG.SYS", targetdrv);
378
  sprintf(buff, "%c:\\CONFIG.SYS", targetdrv);
379
  fd = fopen(buff, "wb");
379
  fd = fopen(buff, "wb");
380
  if (fd == NULL) return;
380
  if (fd == NULL) return;
381
  fprintf(fd, "DOS=UMB,HIGH\r\n");
381
  fprintf(fd, "DOS=UMB,HIGH\r\n");
382
  fprintf(fd, "FILES=50\r\n");
382
  fprintf(fd, "FILES=50\r\n");
383
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEM.EXE\r\n", targetdrv);
383
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEM.EXE\r\n", targetdrv);
384
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512", targetdrv);
384
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512\r\n", targetdrv);
385
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
385
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
386
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\CDROM.SYS /D:FDCD0001\r\n", targetdrv);
386
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\CDROM.SYS /D:FDCD0001\r\n", targetdrv);
387
  fclose(fd);
387
  fclose(fd);
388
}
388
}
389
 
389
 
390
 
390
 
391
static void installpackages(int targetdrv) {
391
static void installpackages(int targetdrv) {
392
  char *pkglist[] = {
392
  char *pkglist[] = {
393
    "APPEND",
393
    "APPEND",
394
    "ASSIGN",
394
    "ASSIGN",
395
    "ATTRIB",
395
    "ATTRIB",
396
    "CHKDSK",
396
    "CHKDSK",
397
    "CHOICE",
397
    "CHOICE",
398
    "COMMAND",
398
    "COMMAND",
399
    "COMP",
399
    "COMP",
400
    "CPIDOS",
400
    "CPIDOS",
401
    "CTMOUSE",
401
    "CTMOUSE",
402
    "DEBUG",
402
    "DEBUG",
403
    "DEFRAG",
403
    "DEFRAG",
404
    "DELTREE",
404
    "DELTREE",
405
    "DEVLOAD",
405
    "DEVLOAD",
406
    "DISKCOMP",
406
    "DISKCOMP",
407
    "DISKCOPY",
407
    "DISKCOPY",
408
    "DISPLAY",
408
    "DISPLAY",
409
    "DOSFSCK",
409
    "DOSFSCK",
410
    "EDIT",
410
    "EDIT",
411
    "EDLIN",
411
    "EDLIN",
412
    "EXE2BIN",
412
    "EXE2BIN",
413
    "FC",
413
    "FC",
414
    "FDAPM",
414
    "FDAPM",
415
    "FDISK",
415
    "FDISK",
416
    "FDNPKG",
416
    "FDNPKG",
417
    "FIND",
417
    "FIND",
418
    "FORMAT",
418
    "FORMAT",
419
    "HELP",
419
    "HELP",
420
    "HIMEMX",
420
    "HIMEMX",
421
    "KERNEL",
421
    "KERNEL",
422
    "KEYB",
422
    "KEYB",
423
    "LABEL",
423
    "LABEL",
424
    "LBACACHE",
424
    "LBACACHE",
425
    "MEM",
425
    "MEM",
426
    "MIRROR",
426
    "MIRROR",
427
    "MODE",
427
    "MODE",
428
    "MORE",
428
    "MORE",
429
    "MOVE",
429
    "MOVE",
430
    "NANSI",
430
    "NANSI",
431
    "NLSFUNC",
431
    "NLSFUNC",
432
    "PRINT",
432
    "PRINT",
433
    "RDISK",
433
    "RDISK",
434
    "RECOVER",
434
    "RECOVER",
435
    "REPLACE",
435
    "REPLACE",
436
    "SHARE",
436
    "SHARE",
437
    "SHSUCDX",
437
    "SHSUCDX",
438
    "SORT",
438
    "SORT",
439
    "SWSUBST",
439
    "SWSUBST",
440
    "TREE",
440
    "TREE",
441
    "UNDELETE",
441
    "UNDELETE",
442
    "XCOPY",
442
    "XCOPY",
443
    NULL
443
    NULL
444
  };
444
  };
445
  int i, pkglistlen;
445
  int i, pkglistlen;
446
  char buff[64];
446
  char buff[64];
447
  newscreen();
447
  newscreen();
448
  /* count how long the pkg list is */
448
  /* count how long the pkg list is */
449
  for (pkglistlen = 0; pkglist[pkglistlen] != NULL; pkglistlen++);
449
  for (pkglistlen = 0; pkglist[pkglistlen] != NULL; pkglistlen++);
450
  /* set DOSDIR and friends */
450
  /* set DOSDIR and friends */
451
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVAROG.386", targetdrv);
451
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVAROG.386", targetdrv);
452
  setenv("DOSDIR", buff, 1);
452
  setenv("DOSDIR", buff, 1);
453
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
453
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
454
  setenv("TEMP", buff, 1);
454
  setenv("TEMP", buff, 1);
455
  /* install packages */
455
  /* install packages */
456
  for (i = 0; pkglist[i] != NULL; i++) {
456
  for (i = 0; pkglist[i] != NULL; i++) {
457
    char buff[128];
457
    char buff[128];
458
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
458
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
459
    strcat(buff, "       ");
459
    strcat(buff, "       ");
460
    video_putstring(10, 2, COLOR_BODY[mono], buff);
460
    video_putstring(10, 2, COLOR_BODY[mono], buff);
461
    sprintf(buff, "FDINST INSTALL X:\\BASE\\%s.ZIP > NUL", pkglist[i]);
461
    sprintf(buff, "FDINST INSTALL X:\\BASE\\%s.ZIP > NUL", pkglist[i]);
462
    system(buff);
462
    system(buff);
463
  }
463
  }
464
}
464
}
465
 
465
 
466
 
466
 
467
static void finalreboot(void) {
467
static void finalreboot(void) {
468
  newscreen();
468
  newscreen();
469
  putstringnls(10, 2, COLOR_BODY[mono], 5, 0, "Svarog386 installation is over. Your computer will reboot now.");
469
  putstringnls(10, 2, COLOR_BODY[mono], 5, 0, "Svarog386 installation is over. Your computer will reboot now.");
470
  putstringnls(11, 2, COLOR_BODY[mono], 5, 1, "Please remove the installation disk from your drive.");
470
  putstringnls(11, 2, COLOR_BODY[mono], 5, 1, "Please remove the installation disk from your drive.");
471
  putstringnls(13, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
471
  putstringnls(13, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
472
  input_getkey();
472
  input_getkey();
473
  reboot();
473
  reboot();
474
}
474
}
475
 
475
 
476
 
476
 
477
static void loadcp(char *lang) {
477
static void loadcp(char *lang) {
478
  int cp, egafile;
478
  int cp, egafile;
479
  char buff[64];
479
  char buff[64];
480
  cp = getnlscp(lang, &egafile);
480
  cp = getnlscp(lang, &egafile);
481
  if (cp == 437) return;
481
  if (cp == 437) return;
482
  video_movecursor(1, 0);
482
  video_movecursor(1, 0);
483
  if (egafile == 1) {
483
  if (egafile == 1) {
484
    sprintf(buff, "MODE CON CP PREP=((%d) A:\\EGA.CPX)", cp);
484
    sprintf(buff, "MODE CON CP PREP=((%d) A:\\EGA.CPX)", cp);
485
  } else {
485
  } else {
486
    sprintf(buff, "MODE CON CP PREP=((%d) A:\\EGA%d.CPX)", cp, egafile);
486
    sprintf(buff, "MODE CON CP PREP=((%d) A:\\EGA%d.CPX)", cp, egafile);
487
  }
487
  }
488
  system(buff);
488
  system(buff);
489
  sprintf(buff, "MODE CON CP SEL=%d", cp);
489
  sprintf(buff, "MODE CON CP SEL=%d", cp);
490
  system(buff);
490
  system(buff);
491
  /* below I re-init the video controller - apparently this is required if
491
  /* below I re-init the video controller - apparently this is required if
492
   * I want the new glyph symbols to be actually applied */
492
   * I want the new glyph symbols to be actually applied */
493
  {
493
  {
494
  union REGS r;
494
  union REGS r;
495
  r.h.ah = 0x0F; /* get current video mode */
495
  r.h.ah = 0x0F; /* get current video mode */
496
  int86(0x10, &r, &r); /* r.h.al contains the current video mode now */
496
  int86(0x10, &r, &r); /* r.h.al contains the current video mode now */
497
  r.h.ah = 0; /* set video mode (to whatever is set in AL) */
497
  r.h.ah = 0; /* set video mode (to whatever is set in AL) */
498
  int86(0x10, &r, &r);
498
  int86(0x10, &r, &r);
499
  }
499
  }
500
}
500
}
501
 
501
 
502
 
502
 
503
int main(void) {
503
int main(void) {
504
  char lang[4];
504
  char lang[4];
505
  int targetdrv;
505
  int targetdrv;
506
 
506
 
507
  /* init screen and detect mono status */
507
  /* init screen and detect mono status */
508
  mono = video_init();
508
  mono = video_init();
509
 
509
 
510
  for (;;) { /* fake loop, it's here just to break out easily */
510
  for (;;) { /* fake loop, it's here just to break out easily */
511
    if (selectlang(lang) < 0) break; /* welcome to svarog, select your language */
511
    if (selectlang(lang) < 0) break; /* welcome to svarog, select your language */
512
    setenv("LANG", lang, 1);
512
    setenv("LANG", lang, 1);
513
    loadcp(lang);
513
    loadcp(lang);
514
    kittenopen("INSTALL"); /* NLS support */
514
    kittenopen("INSTALL"); /* NLS support */
515
    /*selectkeyb();*/ /* what keyb layout should we use? */
515
    /*selectkeyb();*/ /* what keyb layout should we use? */
516
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
516
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
517
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
517
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
518
    if (targetdrv < 0) break;
518
    if (targetdrv < 0) break;
519
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
519
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
520
    installpackages(targetdrv);   /* install packages */
520
    installpackages(targetdrv);   /* install packages */
521
    bootfilesgen(targetdrv, lang); /* generate simple boot files */
521
    bootfilesgen(targetdrv, lang); /* generate simple boot files */
522
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
522
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
523
    /*netcfg();*/ /* basic networking config */
523
    /*netcfg();*/ /* basic networking config */
524
    /* TODO compute a customized FDNPKG file that looks either to local CD or net */
524
    /* TODO compute a customized FDNPKG file that looks either to local CD or net */
525
    finalreboot(); /* remove the CD and reboot */
525
    finalreboot(); /* remove the CD and reboot */
526
    break;
526
    break;
527
  }
527
  }
528
  kittenclose(); /* close NLS support */
528
  kittenclose(); /* close NLS support */
529
  video_clear(0x0700, 0);
529
  video_clear(0x0700, 0);
530
  video_movecursor(0, 0);
530
  video_movecursor(0, 0);
531
  return(0);
531
  return(0);
532
}
532
}
533
 
533