Subversion Repositories SvarDOS

Rev

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

Rev 128 Rev 133
1
/*
1
/*
2
 * SVAROG386 INSTALL
2
 * SVAROG386 INSTALL
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE, ALL RIGHTS RESERVED.
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE, ALL RIGHTS RESERVED.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
6
 * modification, are permitted provided that the following conditions are met:
7
 *
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 * this list of conditions and the following disclaimer.
9
 * this list of conditions and the following disclaimer.
10
 *
10
 *
11
 * 2. Redistributions in binary form must reproduce the above copyright
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 * notice, this list of conditions and the following disclaimer in the
12
 * notice, this list of conditions and the following disclaimer in the
13
 * documentation and/or other materials provided with the distribution.
13
 * documentation and/or other materials provided with the distribution.
14
 *
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
 * POSSIBILITY OF SUCH DAMAGE.
25
 * POSSIBILITY OF SUCH DAMAGE.
26
 *
26
 *
27
 * http://svarog386.sf.net
27
 * http://svarog386.sf.net
28
 */
28
 */
29
 
29
 
30
#include <dos.h>
30
#include <dos.h>
31
#include <direct.h>  /* mkdir() */
31
#include <direct.h>  /* mkdir() */
32
#include <stdio.h>   /* printf() and friends */
32
#include <stdio.h>   /* printf() and friends */
33
#include <stdlib.h>  /* system() */
33
#include <stdlib.h>  /* system() */
34
#include <string.h>  /* memcpy() */
34
#include <string.h>  /* memcpy() */
35
#include <unistd.h>
35
#include <unistd.h>
36
 
36
 
37
#include "kitten\kitten.h"
37
#include "kitten\kitten.h"
38
 
38
 
39
#include "cdrom.h"
39
#include "cdrom.h"
40
#include "input.h"
40
#include "input.h"
41
#include "video.h"
41
#include "video.h"
42
 
42
 
43
/* keyboard layouts and locales */
43
/* keyboard layouts and locales */
44
#include "keylay.h"
44
#include "keylay.h"
45
#include "keyoff.h"
45
#include "keyoff.h"
46
 
46
 
47
/* color scheme (color, mono) */
47
/* color scheme (color, mono) */
48
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
48
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
49
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
49
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
50
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
50
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
51
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
51
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
52
 
52
 
53
/* mono flag */
53
/* mono flag */
54
static int mono = 0;
54
static int mono = 0;
55
 
55
 
56
/* how much disk space does Svarog386 require (in MiB) */
56
/* how much disk space does Svarog386 require (in MiB) */
57
#define SVAROG_DISK_REQ 8
57
#define SVAROG_DISK_REQ 8
58
 
58
 
59
/* menu screens can output only one of these: */
59
/* menu screens can output only one of these: */
60
#define MENUNEXT 0
60
#define MENUNEXT 0
61
#define MENUPREV -1
61
#define MENUPREV -1
62
#define MENUQUIT -2
62
#define MENUQUIT -2
63
 
63
 
64
/* a convenience 'function' used for debugging */
64
/* a convenience 'function' used for debugging */
65
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
65
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
66
 
66
 
67
struct slocales {
67
struct slocales {
68
  char lang[4];
68
  char lang[4];
69
  char *keybcode;
69
  char *keybcode;
70
  unsigned int codepage;
70
  unsigned int codepage;
71
  int egafile;
71
  int egafile;
72
  int keybfile;
72
  int keybfile;
73
  int keyboff;
73
  int keyboff;
74
  int keyblen;
74
  int keyblen;
75
  unsigned int keybid;
75
  unsigned int keybid;
76
};
76
};
77
 
77
 
78
 
78
 
79
/* reboot the computer */
79
/* reboot the computer */
80
static void reboot(void) {
80
static void reboot(void) {
81
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
81
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
82
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
82
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
83
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
83
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
84
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
84
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
85
}
85
}
86
 
86
 
87
 
87
 
88
/* outputs a string to screen with taking care of word wrapping. returns amount of lines. */
88
/* outputs a string to screen with taking care of word wrapping. returns amount of lines. */
89
static int putstringwrap(int y, int x, unsigned short attr, char *s) {
89
static int putstringwrap(int y, int x, unsigned short attr, char *s) {
90
  int linew, lincount;
90
  int linew, lincount;
91
  linew = 80;
91
  linew = 80;
92
  if (x >= 0) linew -= (x << 1);
92
  if (x >= 0) linew -= (x << 1);
93
 
93
 
94
  for (lincount = 1; y+lincount < 25; lincount++) {
94
  for (lincount = 1; y+lincount < 25; lincount++) {
95
    int i, len = linew;
95
    int i, len = linew;
96
    for (i = 0; i <= linew; i++) {
96
    for (i = 0; i <= linew; i++) {
97
      if (s[i] == ' ') len = i;
97
      if (s[i] == ' ') len = i;
98
      if (s[i] == '\n') {
98
      if (s[i] == '\n') {
99
        len = i;
99
        len = i;
100
        break;
100
        break;
101
      }
101
      }
102
      if (s[i] == 0) {
102
      if (s[i] == 0) {
103
        len = i;
103
        len = i;
104
        break;
104
        break;
105
      }
105
      }
106
    }
106
    }
107
    video_putstring(y++, x, attr, s, len);
107
    video_putstring(y++, x, attr, s, len);
108
    s += len;
108
    s += len;
109
    if (*s == 0) break;
109
    if (*s == 0) break;
110
    s += 1; /* skip the whitespace char */
110
    s += 1; /* skip the whitespace char */
111
  }
111
  }
112
  return(lincount);
112
  return(lincount);
113
}
113
}
114
 
114
 
115
 
115
 
116
/* an NLS wrapper around video_putstring(), also performs line wrapping when
116
/* an NLS wrapper around video_putstring(), also performs line wrapping when
117
 * needed. returns the amount of lines that were output */
117
 * needed. returns the amount of lines that were output */
118
static int putstringnls(int y, int x, unsigned short attr, int nlsmaj, int nlsmin, char *s) {
118
static int putstringnls(int y, int x, unsigned short attr, int nlsmaj, int nlsmin, char *s) {
119
  s = kittengets(nlsmaj, nlsmin, s);
119
  s = kittengets(nlsmaj, nlsmin, s);
120
  return(putstringwrap(y, x, attr, s));
120
  return(putstringwrap(y, x, attr, s));
121
}
121
}
122
 
122
 
123
 
123
 
124
static int menuselect(int ypos, int xpos, int height, char **list, int listlen) {
124
static int menuselect(int ypos, int xpos, int height, char **list, int listlen) {
125
  int i, offset = 0, res = 0, count, width = 0;
125
  int i, offset = 0, res = 0, count, width = 0;
126
  /* count how many positions there is, and check their width */
126
  /* count how many positions there is, and check their width */
127
  for (count = 0; (list[count] != NULL) && (count != listlen); count++) {
127
  for (count = 0; (list[count] != NULL) && (count != listlen); count++) {
128
    int len = strlen(list[count]);
128
    int len = strlen(list[count]);
129
    if (len > width) width = len;
129
    if (len > width) width = len;
130
  }
130
  }
131
 
131
 
132
  /* if xpos negative, means 'center out' */
132
  /* if xpos negative, means 'center out' */
133
  if (xpos < 0) xpos = 39 - (width >> 1);
133
  if (xpos < 0) xpos = 39 - (width >> 1);
134
 
134
 
135
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
135
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
136
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
136
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
137
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
137
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
138
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
138
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
139
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
139
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
140
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
140
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
141
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
141
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
142
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
142
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
143
 
143
 
144
  for (;;) {
144
  for (;;) {
145
    int key;
145
    int key;
146
    /* list of selectable items */
146
    /* list of selectable items */
147
    for (i = 0; i < height - 2; i++) {
147
    for (i = 0; i < height - 2; i++) {
148
      if (i + offset == res) {
148
      if (i + offset == res) {
149
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
149
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
150
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
150
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
151
        video_movecursor(ypos + 1 + i, xpos);
151
        video_movecursor(ypos + 1 + i, xpos);
152
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
152
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
153
      } else if (i + offset < count) {
153
      } else if (i + offset < count) {
154
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
154
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
155
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
155
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
156
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
156
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
157
      } else {
157
      } else {
158
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
158
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
159
      }
159
      }
160
    }
160
    }
161
    key = input_getkey();
161
    key = input_getkey();
162
    if (key == 0x0D) { /* ENTER */
162
    if (key == 0x0D) { /* ENTER */
163
      return(res);
163
      return(res);
164
    } else if (key == 0x148) { /* up */
164
    } else if (key == 0x148) { /* up */
165
      if (res > 0) {
165
      if (res > 0) {
166
        res--;
166
        res--;
167
        if (res < offset) offset = res;
167
        if (res < offset) offset = res;
168
      }
168
      }
169
    } else if (key == 0x150) { /* down */
169
    } else if (key == 0x150) { /* down */
170
      if (res+1 < count) {
170
      if (res+1 < count) {
171
        res++;
171
        res++;
172
        if (res > offset + height - 3) offset = res - (height - 3);
172
        if (res > offset + height - 3) offset = res - (height - 3);
173
      }
173
      }
174
    } else if (key == 0x147) { /* home */
174
    } else if (key == 0x147) { /* home */
175
      res = 0;
175
      res = 0;
176
      offset = 0;
176
      offset = 0;
177
    } else if (key == 0x14F) { /* end */
177
    } else if (key == 0x14F) { /* end */
178
      res = count - 1;
178
      res = count - 1;
179
      if (res > offset + height - 3) offset = res - (height - 3);
179
      if (res > offset + height - 3) offset = res - (height - 3);
180
    } else if (key == 0x1B) {  /* ESC */
180
    } else if (key == 0x1B) {  /* ESC */
181
      return(-1);
181
      return(-1);
182
    }/* else {
182
    }/* else {
183
      char buf[8];
183
      char buf[8];
184
      snprintf(buf, sizeof(buf), "0x%02X ", key);
184
      snprintf(buf, sizeof(buf), "0x%02X ", key);
185
      video_putstring(1, 0, COLOR_BODY[mono], buf, -1);
185
      video_putstring(1, 0, COLOR_BODY[mono], buf, -1);
186
    }*/
186
    }*/
187
  }
187
  }
188
}
188
}
189
 
189
 
190
static void newscreen(int statusbartype) {
190
static void newscreen(int statusbartype) {
191
  char *msg;
191
  char *msg;
192
  msg = kittengets(0, 0, "SVAROG386 INSTALLATION");
192
  msg = kittengets(0, 0, "SVAROG386 INSTALLATION");
193
  video_putcharmulti(0, 0, COLOR_TITLEBAR[mono], ' ', 80, 1);
193
  video_putcharmulti(0, 0, COLOR_TITLEBAR[mono], ' ', 80, 1);
194
  video_putstring(0, 40 - (strlen(msg) >> 1), COLOR_TITLEBAR[mono], msg, -1);
194
  video_putstring(0, 40 - (strlen(msg) >> 1), COLOR_TITLEBAR[mono], msg, -1);
195
  video_clear(COLOR_BODY[mono], 80, -80);
195
  video_clear(COLOR_BODY[mono], 80, -80);
196
  switch (statusbartype) {
196
  switch (statusbartype) {
197
    case 1:
197
    case 1:
198
      msg = kittengets(0, 11, "Up/Down = Select entry | Enter = Validate your choice | ESC = Quit to DOS");
198
      msg = kittengets(0, 11, "Up/Down = Select entry | Enter = Validate your choice | ESC = Quit to DOS");
199
      break;
199
      break;
200
    case 2:
200
    case 2:
201
      msg = kittengets(0, 5, "Press any key...");
201
      msg = kittengets(0, 5, "Press any key...");
202
      break;
202
      break;
203
    case 3:
203
    case 3:
204
      msg = "";
204
      msg = "";
205
      break;
205
      break;
206
    default:
206
    default:
207
      msg = kittengets(0, 10, "Up/Down = Select entry | Enter = Validate your choice | ESC = Previous screen");
207
      msg = kittengets(0, 10, "Up/Down = Select entry | Enter = Validate your choice | ESC = Previous screen");
208
      break;
208
      break;
209
  }
209
  }
210
  video_putchar(24, 0, COLOR_TITLEBAR[mono], ' ');
210
  video_putchar(24, 0, COLOR_TITLEBAR[mono], ' ');
211
  video_putstringfix(24, 1, COLOR_TITLEBAR[mono], msg, 79);
211
  video_putstringfix(24, 1, COLOR_TITLEBAR[mono], msg, 79);
212
  video_movecursor(25,0);
212
  video_movecursor(25,0);
213
}
213
}
214
 
214
 
215
/* fills a slocales struct accordingly to the value of its keyboff member */
215
/* fills a slocales struct accordingly to the value of its keyboff member */
216
static void kblay2slocal(struct slocales *locales) {
216
static void kblay2slocal(struct slocales *locales) {
217
  char *m;
217
  char *m;
218
  for (m = kblayouts[locales->keyboff]; *m != 0; m++); /* skip layout name */
218
  for (m = kblayouts[locales->keyboff]; *m != 0; m++); /* skip layout name */
219
  m++;
219
  m++;
220
  /* skip keyb code and copy it to locales.keybcode */
220
  /* skip keyb code and copy it to locales.keybcode */
221
  locales->keybcode = m;
221
  locales->keybcode = m;
222
  for (; *m != 0; m++);
222
  for (; *m != 0; m++);
223
  /* */
223
  /* */
224
  locales->codepage = ((unsigned short)m[1] << 8) | m[2];
224
  locales->codepage = ((unsigned short)m[1] << 8) | m[2];
225
  locales->egafile = m[3];
225
  locales->egafile = m[3];
226
  locales->keybfile = m[4];
226
  locales->keybfile = m[4];
227
  locales->keybid = ((unsigned short)m[5] << 8) | m[6];
227
  locales->keybid = ((unsigned short)m[5] << 8) | m[6];
228
}
228
}
229
 
229
 
230
static int selectlang(struct slocales *locales) {
230
static int selectlang(struct slocales *locales) {
231
  int choice, x;
231
  int choice, x;
232
  char *msg;
232
  char *msg;
233
  char *langlist[] = {
233
  char *langlist[] = {
234
    "English",
234
    "English",
235
    "French",
235
    "French",
-
 
236
    "German",
236
    "Italian",
237
    "Italian",
237
    "Polish",
238
    "Polish",
238
    "Russian",
239
    "Russian",
239
    "Slovene",
240
    "Slovene",
240
    "Swedish",
241
    "Swedish",
241
    "Turkish",
242
    "Turkish",
242
    NULL
243
    NULL
243
  };
244
  };
244
 
245
 
245
  newscreen(1);
246
  newscreen(1);
246
  msg = kittengets(1, 0, "Welcome to Svarog386");
247
  msg = kittengets(1, 0, "Welcome to Svarog386");
247
  x = 40 - (strlen(msg) >> 1);
248
  x = 40 - (strlen(msg) >> 1);
248
  video_putstring(4, x, COLOR_BODY[mono], msg, -1);
249
  video_putstring(4, x, COLOR_BODY[mono], msg, -1);
249
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
250
  video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
250
  putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
251
  putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
251
  choice = menuselect(11, -1, 10, langlist, -1);
252
  choice = menuselect(11, -1, 11, langlist, -1);
252
  if (choice < 0) return(MENUPREV);
253
  if (choice < 0) return(MENUPREV);
253
  /* populate locales with default values */
254
  /* populate locales with default values */
254
  memset(locales, 0, sizeof(struct slocales));
255
  memset(locales, 0, sizeof(struct slocales));
255
  switch (choice) {
256
  switch (choice) {
256
    case 1:
257
    case 1:
257
      strcpy(locales->lang, "FR");
258
      strcpy(locales->lang, "FR");
258
      locales->keyboff = OFFLOC_FR;
259
      locales->keyboff = OFFLOC_FR;
259
      locales->keyblen = OFFLEN_FR;
260
      locales->keyblen = OFFLEN_FR;
260
      break;
261
      break;
261
    case 2:
262
    case 2:
-
 
263
      strcpy(locales->lang, "DE");
-
 
264
      locales->keyboff = OFFLOC_DE;
-
 
265
      locales->keyblen = OFFLEN_DE;
-
 
266
      break;
-
 
267
    case 3:
262
      strcpy(locales->lang, "IT");
268
      strcpy(locales->lang, "IT");
263
      locales->keyboff = OFFLOC_IT;
269
      locales->keyboff = OFFLOC_IT;
264
      locales->keyblen = OFFLEN_IT;
270
      locales->keyblen = OFFLEN_IT;
265
      break;
271
      break;
266
    case 3:
272
    case 4:
267
      strcpy(locales->lang, "PL");
273
      strcpy(locales->lang, "PL");
268
      locales->keyboff = OFFLOC_PL;
274
      locales->keyboff = OFFLOC_PL;
269
      locales->keyblen = OFFLEN_PL;
275
      locales->keyblen = OFFLEN_PL;
270
      break;
276
      break;
271
    case 4:
277
    case 5:
272
      strcpy(locales->lang, "RU");
278
      strcpy(locales->lang, "RU");
273
      locales->keyboff = OFFLOC_RU;
279
      locales->keyboff = OFFLOC_RU;
274
      locales->keyblen = OFFLEN_RU;
280
      locales->keyblen = OFFLEN_RU;
275
      break;
281
      break;
276
    case 5:
282
    case 6:
277
      strcpy(locales->lang, "SI");
283
      strcpy(locales->lang, "SI");
278
      locales->keyboff = OFFLOC_SI;
284
      locales->keyboff = OFFLOC_SI;
279
      locales->keyblen = OFFLEN_SI;
285
      locales->keyblen = OFFLEN_SI;
280
      break;
286
      break;
281
    case 6:
287
    case 7:
282
      strcpy(locales->lang, "SV");
288
      strcpy(locales->lang, "SV");
283
      locales->keyboff = OFFLOC_SV;
289
      locales->keyboff = OFFLOC_SV;
284
      locales->keyblen = OFFLEN_SV;
290
      locales->keyblen = OFFLEN_SV;
285
      break;
291
      break;
286
    case 7:
292
    case 8:
287
      strcpy(locales->lang, "TR");
293
      strcpy(locales->lang, "TR");
288
      locales->keyboff = OFFLOC_TR;
294
      locales->keyboff = OFFLOC_TR;
289
      locales->keyblen = OFFLEN_TR;
295
      locales->keyblen = OFFLEN_TR;
290
      break;
296
      break;
291
    default:
297
    default:
292
      strcpy(locales->lang, "EN");
298
      strcpy(locales->lang, "EN");
293
      locales->keyboff = 0;
299
      locales->keyboff = 0;
294
      locales->keyblen = OFFCOUNT;
300
      locales->keyblen = OFFCOUNT;
295
      break;
301
      break;
296
  }
302
  }
297
  /* populate the slocales struct accordingly to the keyboff member */
303
  /* populate the slocales struct accordingly to the keyboff member */
298
  kblay2slocal(locales);
304
  kblay2slocal(locales);
299
  /* */
305
  /* */
300
  return(MENUNEXT);
306
  return(MENUNEXT);
301
}
307
}
302
 
308
 
303
 
309
 
304
static int selectkeyb(struct slocales *locales) {
310
static int selectkeyb(struct slocales *locales) {
305
  int menuheight, choice;
311
  int menuheight, choice;
306
  if (locales->keyblen == 1) return(MENUNEXT); /* do not ask for keyboard layout if only one is available for given language */
312
  if (locales->keyblen == 1) return(MENUNEXT); /* do not ask for keyboard layout if only one is available for given language */
307
  newscreen(0);
313
  newscreen(0);
308
  putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.");
314
  putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.");
309
  menuheight = locales->keyblen + 2;
315
  menuheight = locales->keyblen + 2;
310
  if (menuheight > 13) menuheight = 13;
316
  if (menuheight > 13) menuheight = 13;
311
  choice = menuselect(10, -1, menuheight, &(kblayouts[locales->keyboff]), locales->keyblen);
317
  choice = menuselect(10, -1, menuheight, &(kblayouts[locales->keyboff]), locales->keyblen);
312
  if (choice < 0) return(MENUPREV);
318
  if (choice < 0) return(MENUPREV);
313
  /* (re)load the keyboard layout & codepage setup */
319
  /* (re)load the keyboard layout & codepage setup */
314
  locales->keyboff += choice;
320
  locales->keyboff += choice;
315
  kblay2slocal(locales);
321
  kblay2slocal(locales);
316
  return(MENUNEXT);
322
  return(MENUNEXT);
317
}
323
}
318
 
324
 
319
 
325
 
320
/* returns 0 if installation must proceed, non-zero otherwise */
326
/* returns 0 if installation must proceed, non-zero otherwise */
321
static int welcomescreen(void) {
327
static int welcomescreen(void) {
322
  int c;
328
  int c;
323
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
329
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
324
  choice[0] = kittengets(0, 1, choice[0]);
330
  choice[0] = kittengets(0, 1, choice[0]);
325
  choice[1] = kittengets(0, 2, choice[1]);
331
  choice[1] = kittengets(0, 2, choice[1]);
326
  newscreen(0);
332
  newscreen(0);
327
  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.");
333
  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.");
328
  c = menuselect(13, -1, 4, choice, -1);
334
  c = menuselect(13, -1, 4, choice, -1);
329
  if (c < 0) return(MENUPREV);
335
  if (c < 0) return(MENUPREV);
330
  if (c == 0) return(MENUNEXT);
336
  if (c == 0) return(MENUNEXT);
331
  return(MENUQUIT);
337
  return(MENUQUIT);
332
}
338
}
333
 
339
 
334
 
340
 
335
/* returns 1 if drive is removable, 0 if not, -1 on error */
341
/* returns 1 if drive is removable, 0 if not, -1 on error */
336
static int isdriveremovable(int drv) {
342
static int isdriveremovable(int drv) {
337
  union REGS r;
343
  union REGS r;
338
  r.x.ax = 0x4408;
344
  r.x.ax = 0x4408;
339
  r.h.bl = drv;
345
  r.h.bl = drv;
340
  int86(0x21, &r, &r);
346
  int86(0x21, &r, &r);
341
  /* CF set on error, AX set to 0 if removable, 1 if fixed */
347
  /* CF set on error, AX set to 0 if removable, 1 if fixed */
342
  if (r.x.cflag != 0) return(-1);
348
  if (r.x.cflag != 0) return(-1);
343
  if (r.x.ax == 0) return(1);
349
  if (r.x.ax == 0) return(1);
344
  return(0);
350
  return(0);
345
}
351
}
346
 
352
 
347
 
353
 
348
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
354
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid */
349
static int disksize(int drv) {
355
static int disksize(int drv) {
350
  long res;
356
  long res;
351
  union REGS r;
357
  union REGS r;
352
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
358
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
353
  r.h.dl = drv;
359
  r.h.dl = drv;
354
  int86(0x21, &r, &r);
360
  int86(0x21, &r, &r);
355
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
361
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
356
  res = r.x.ax;  /* sectors per cluster */
362
  res = r.x.ax;  /* sectors per cluster */
357
  res *= r.x.dx; /* dx contains total clusters, bx contains free clusters */
363
  res *= r.x.dx; /* dx contains total clusters, bx contains free clusters */
358
  res *= r.x.cx; /* bytes per sector */
364
  res *= r.x.cx; /* bytes per sector */
359
  res >>= 20;    /* convert bytes to MiB */
365
  res >>= 20;    /* convert bytes to MiB */
360
  return(res);
366
  return(res);
361
}
367
}
362
 
368
 
363
 
369
 
364
/* returns 0 if disk is empty, non-zero otherwise */
370
/* returns 0 if disk is empty, non-zero otherwise */
365
static int diskempty(int drv) {
371
static int diskempty(int drv) {
366
  unsigned int rc;
372
  unsigned int rc;
367
  int res;
373
  int res;
368
  char buff[8];
374
  char buff[8];
369
  struct find_t fileinfo;
375
  struct find_t fileinfo;
370
  snprintf(buff, sizeof(buff), "%c:\\*.*", 'A' + drv - 1);
376
  snprintf(buff, sizeof(buff), "%c:\\*.*", 'A' + drv - 1);
371
  rc = _dos_findfirst(buff, _A_NORMAL | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM, &fileinfo);
377
  rc = _dos_findfirst(buff, _A_NORMAL | _A_SUBDIR | _A_HIDDEN | _A_SYSTEM, &fileinfo);
372
  if (rc == 0) {
378
  if (rc == 0) {
373
    res = 1; /* call successfull means disk is not empty */
379
    res = 1; /* call successfull means disk is not empty */
374
  } else {
380
  } else {
375
    res = 0;
381
    res = 0;
376
  }
382
  }
377
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
383
  /* _dos_findclose(&fileinfo); */ /* apparently required only on OS/2 */
378
  return(res);
384
  return(res);
379
}
385
}
380
 
386
 
381
 
387
 
382
static int preparedrive(void) {
388
static int preparedrive(void) {
383
  int driveremovable;
389
  int driveremovable;
384
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
390
  int selecteddrive = 3; /* hardcoded to 'C:' for now */
385
  int cselecteddrive;
391
  int cselecteddrive;
386
  int ds;
392
  int ds;
387
  int choice;
393
  int choice;
388
  char buff[1024];
394
  char buff[1024];
389
  cselecteddrive = 'A' + selecteddrive - 1;
395
  cselecteddrive = 'A' + selecteddrive - 1;
390
  for (;;) {
396
  for (;;) {
391
    driveremovable = isdriveremovable(selecteddrive);
397
    driveremovable = isdriveremovable(selecteddrive);
392
    if (driveremovable < 0) {
398
    if (driveremovable < 0) {
393
      char *list[] = { "Create a partition automatically", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
399
      char *list[] = { "Create a partition automatically", "Run the FDISK partitioning tool", "Quit to DOS", NULL};
394
      newscreen(0);
400
      newscreen(0);
395
      list[0] = kittengets(0, 3, list[0]);
401
      list[0] = kittengets(0, 3, list[0]);
396
      list[1] = kittengets(0, 4, list[1]);
402
      list[1] = kittengets(0, 4, list[1]);
397
      list[2] = kittengets(0, 2, list[2]);
403
      list[2] = kittengets(0, 2, list[2]);
398
      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 Svarog386 can be installed on it. Note, that Svarog386 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, SVAROG_DISK_REQ);
404
      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 Svarog386 can be installed on it. Note, that Svarog386 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, SVAROG_DISK_REQ);
399
      putstringwrap(4, 1, COLOR_BODY[mono], buff);
405
      putstringwrap(4, 1, COLOR_BODY[mono], buff);
400
      switch (menuselect(14, -1, 5, list, -1)) {
406
      switch (menuselect(14, -1, 5, list, -1)) {
401
        case 0:
407
        case 0:
402
          system("FDISK /AUTO");
408
          system("FDISK /AUTO");
403
          break;
409
          break;
404
        case 1:
410
        case 1:
405
          video_clear(0x0700, 0, 0);
411
          video_clear(0x0700, 0, 0);
406
          video_movecursor(0, 0);
412
          video_movecursor(0, 0);
407
          system("FDISK");
413
          system("FDISK");
408
          break;
414
          break;
409
        case 2:
415
        case 2:
410
          return(MENUQUIT);
416
          return(MENUQUIT);
411
        default:
417
        default:
412
          return(-1);
418
          return(-1);
413
      }
419
      }
414
      /* write a temporary MBR which only skips the drive (in case BIOS would
420
      /* write a temporary MBR which only skips the drive (in case BIOS would
415
       * try to boot off the not-yet-ready C: disk) */
421
       * try to boot off the not-yet-ready C: disk) */
416
      system("FDISK /AMBR"); /* writes BOOT.MBR into actual MBR */
422
      system("FDISK /AMBR"); /* writes BOOT.MBR into actual MBR */
417
      newscreen(2);
423
      newscreen(2);
418
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
424
      putstringnls(10, 10, COLOR_BODY[mono], 3, 1, "Your computer will reboot now.");
419
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
425
      putstringnls(12, 10, COLOR_BODY[mono], 0, 5, "Press any key...");
420
      input_getkey();
426
      input_getkey();
421
      reboot();
427
      reboot();
422
      return(MENUQUIT);
428
      return(MENUQUIT);
423
    } else if (driveremovable > 0) {
429
    } else if (driveremovable > 0) {
424
      newscreen(2);
430
      newscreen(2);
425
      snprintf(buff, sizeof(buff), kittengets(3, 2, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
431
      snprintf(buff, sizeof(buff), kittengets(3, 2, "ERROR: Drive %c: is a removable device. Installation aborted."), cselecteddrive);
426
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
432
      video_putstring(9, 1, COLOR_BODY[mono], buff, -1);
427
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
433
      putstringnls(11, 2, COLOR_BODY[mono], 0, 5, "Press any key...");
428
      return(MENUQUIT);
434
      return(MENUQUIT);
429
    }
435
    }
430
    /* if not formatted, propose to format it right away (try to create a directory) */
436
    /* if not formatted, propose to format it right away (try to create a directory) */
431
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
437
    snprintf(buff, sizeof(buff), "%c:\\SVWRTEST.123", cselecteddrive);
432
    if (mkdir(buff) == 0) {
438
    if (mkdir(buff) == 0) {
433
      rmdir(buff);
439
      rmdir(buff);
434
    } else {
440
    } else {
435
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
441
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
436
      newscreen(0);
442
      newscreen(0);
437
      list[0] = kittengets(0, 6, list[0]);
443
      list[0] = kittengets(0, 6, list[0]);
438
      list[1] = kittengets(0, 2, list[1]);
444
      list[1] = kittengets(0, 2, list[1]);
439
      snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
445
      snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
440
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
446
      video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
441
      choice = menuselect(12, -1, 4, list, -1);
447
      choice = menuselect(12, -1, 4, list, -1);
442
      if (choice < 0) return(MENUPREV);
448
      if (choice < 0) return(MENUPREV);
443
      if (choice == 1) return(MENUQUIT);
449
      if (choice == 1) return(MENUQUIT);
444
      video_clear(0x0700, 0, 0);
450
      video_clear(0x0700, 0, 0);
445
      video_movecursor(0, 0);
451
      video_movecursor(0, 0);
446
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
452
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
447
      system(buff);
453
      system(buff);
448
      continue;
454
      continue;
449
    }
455
    }
450
    /* check total disk space */
456
    /* check total disk space */
451
    ds = disksize(selecteddrive);
457
    ds = disksize(selecteddrive);
452
    if (ds < SVAROG_DISK_REQ) {
458
    if (ds < SVAROG_DISK_REQ) {
453
      int y = 9;
459
      int y = 9;
454
      newscreen(2);
460
      newscreen(2);
455
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! Svarog386 requires a disk of at least %d MiB."), cselecteddrive);
461
      snprintf(buff, sizeof(buff), kittengets(3, 4, "ERROR: Drive %c: is not big enough! Svarog386 requires a disk of at least %d MiB."), cselecteddrive);
456
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
462
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
457
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
463
      putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
458
      input_getkey();
464
      input_getkey();
459
      return(MENUQUIT);
465
      return(MENUQUIT);
460
    }
466
    }
461
    /* is the disk empty? */
467
    /* is the disk empty? */
462
    newscreen(0);
468
    newscreen(0);
463
    if (diskempty(selecteddrive) != 0) {
469
    if (diskempty(selecteddrive) != 0) {
464
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
470
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
465
      int y = 6;
471
      int y = 6;
466
      list[0] = kittengets(0, 6, list[0]);
472
      list[0] = kittengets(0, 6, list[0]);
467
      list[1] = kittengets(0, 2, list[1]);
473
      list[1] = kittengets(0, 2, list[1]);
468
      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);
474
      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);
469
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
475
      y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
470
      choice = menuselect(++y, -1, 4, list, -1);
476
      choice = menuselect(++y, -1, 4, list, -1);
471
      if (choice < 0) return(MENUPREV);
477
      if (choice < 0) return(MENUPREV);
472
      if (choice == 1) return(MENUQUIT);
478
      if (choice == 1) return(MENUQUIT);
473
      video_clear(0x0700, 0, 0);
479
      video_clear(0x0700, 0, 0);
474
      video_movecursor(0, 0);
480
      video_movecursor(0, 0);
475
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
481
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
476
      system(buff);
482
      system(buff);
477
      continue;
483
      continue;
478
    } else {
484
    } else {
479
      /* final confirmation */
485
      /* final confirmation */
480
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
486
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
481
      list[0] = kittengets(0, 1, list[0]);
487
      list[0] = kittengets(0, 1, list[0]);
482
      list[1] = kittengets(0, 2, list[1]);
488
      list[1] = kittengets(0, 2, list[1]);
483
      snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
489
      snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
484
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
490
      video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
485
      choice = menuselect(10, -1, 4, list, -1);
491
      choice = menuselect(10, -1, 4, list, -1);
486
      if (choice < 0) return(MENUPREV);
492
      if (choice < 0) return(MENUPREV);
487
      if (choice == 1) return(MENUQUIT);
493
      if (choice == 1) return(MENUQUIT);
488
      snprintf(buff, sizeof(buff), "SYS A: %c: > NUL", cselecteddrive);
494
      snprintf(buff, sizeof(buff), "SYS A: %c: > NUL", cselecteddrive);
489
      system(buff);
495
      system(buff);
490
      system("FDISK /MBR");
496
      system("FDISK /MBR");
491
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
497
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
492
      mkdir(buff);
498
      mkdir(buff);
493
      return(cselecteddrive);
499
      return(cselecteddrive);
494
    }
500
    }
495
  }
501
  }
496
}
502
}
497
 
503
 
498
 
504
 
499
/* copy file src into dst, substituting all characters c1 by c2 */
505
/* copy file src into dst, substituting all characters c1 by c2 */
500
static void fcopysub(char *dst, char *src, char c1, char c2) {
506
static void fcopysub(char *dst, char *src, char c1, char c2) {
501
  FILE *fdd, *fds;
507
  FILE *fdd, *fds;
502
  int buff;
508
  int buff;
503
  fds = fopen(src, "rb");
509
  fds = fopen(src, "rb");
504
  if (fds == NULL) return;
510
  if (fds == NULL) return;
505
  fdd = fopen(dst, "wb");
511
  fdd = fopen(dst, "wb");
506
  if (fdd == NULL) {
512
  if (fdd == NULL) {
507
    fclose(fds);
513
    fclose(fds);
508
    return;
514
    return;
509
  }
515
  }
510
  /* */
516
  /* */
511
  for (;;) {
517
  for (;;) {
512
    buff = fgetc(fds);
518
    buff = fgetc(fds);
513
    if (buff == EOF) break;
519
    if (buff == EOF) break;
514
    if (buff == c1) buff = c2;
520
    if (buff == c1) buff = c2;
515
    fprintf(fdd, "%c", buff);
521
    fprintf(fdd, "%c", buff);
516
  }
522
  }
517
  /* close files and return */
523
  /* close files and return */
518
  fclose(fdd);
524
  fclose(fdd);
519
  fclose(fds);
525
  fclose(fds);
520
}
526
}
521
 
527
 
522
 
528
 
523
static void bootfilesgen(int targetdrv, struct slocales *locales, int cdromdrv) {
529
static void bootfilesgen(int targetdrv, struct slocales *locales, int cdromdrv) {
524
  char buff[128];
530
  char buff[128];
525
  char buff2[16];
531
  char buff2[16];
526
  char buff3[16];
532
  char buff3[16];
527
  FILE *fd;
533
  FILE *fd;
528
  /*** CONFIG.SYS ***/
534
  /*** CONFIG.SYS ***/
529
  snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", targetdrv);
535
  snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", targetdrv);
530
  fd = fopen(buff, "wb");
536
  fd = fopen(buff, "wb");
531
  if (fd == NULL) return;
537
  if (fd == NULL) return;
532
  fprintf(fd, "DOS=UMB,HIGH\r\n"
538
  fprintf(fd, "DOS=UMB,HIGH\r\n"
533
              "LASTDRIVE=Z\r\n"
539
              "LASTDRIVE=Z\r\n"
534
              "FILES=50\r\n");
540
              "FILES=50\r\n");
535
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEMX.EXE\r\n", targetdrv);
541
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEMX.EXE\r\n", targetdrv);
536
  if (strcmp(locales->lang, "EN") == 0) {
542
  if (strcmp(locales->lang, "EN") == 0) {
537
    strcpy(buff, "COMMAND");
543
    strcpy(buff, "COMMAND");
538
  } else {
544
  } else {
539
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
545
    snprintf(buff, sizeof(buff), "CMD-%s", locales->lang);
540
  }
546
  }
541
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\%s.COM /E:512 /P\r\n", targetdrv, buff);
547
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\%s.COM /E:512 /P\r\n", targetdrv, buff);
542
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\CONF\\COUNTRY.SYS\r\n", targetdrv);
548
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\CONF\\COUNTRY.SYS\r\n", targetdrv);
543
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
549
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\DRIVERS\\UDVD2\\UDVD2.SYS /D:SVCD0001 /H\r\n", targetdrv);
544
  fclose(fd);
550
  fclose(fd);
545
  /*** AUTOEXEC.BAT ***/
551
  /*** AUTOEXEC.BAT ***/
546
  snprintf(buff, sizeof(buff), "%c:\\AUTOEXEC.BAT", targetdrv);
552
  snprintf(buff, sizeof(buff), "%c:\\AUTOEXEC.BAT", targetdrv);
547
  fd = fopen(buff, "wb");
553
  fd = fopen(buff, "wb");
548
  if (fd == NULL) return;
554
  if (fd == NULL) return;
549
  fprintf(fd, "@ECHO OFF\r\n");
555
  fprintf(fd, "@ECHO OFF\r\n");
550
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
556
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
551
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
557
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
552
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
558
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
553
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
559
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
554
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
560
  fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
555
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n", targetdrv);
561
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n", targetdrv);
556
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n", targetdrv);
562
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n", targetdrv);
557
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%c:\\SYSTEM\\LINKS\r\n", targetdrv);
563
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%c:\\SYSTEM\\LINKS\r\n", targetdrv);
558
  fprintf(fd, "PROMPT $P$G\r\n");
564
  fprintf(fd, "PROMPT $P$G\r\n");
559
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
565
  fprintf(fd, "ALIAS REBOOT=FDAPM COLDBOOT\r\n");
560
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
566
  fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
561
  fprintf(fd, "FDAPM APMDOS\r\n");
567
  fprintf(fd, "FDAPM APMDOS\r\n");
562
  fprintf(fd, "\r\n");
568
  fprintf(fd, "\r\n");
563
  if (locales->egafile > 0) {
569
  if (locales->egafile > 0) {
564
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
570
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
565
    if (locales->egafile == 1) {
571
    if (locales->egafile == 1) {
566
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA.CPX)\r\n", locales->codepage, targetdrv);
572
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA.CPX)\r\n", locales->codepage, targetdrv);
567
    } else {
573
    } else {
568
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA%d.CPX)\r\n", locales->codepage, targetdrv, locales->egafile);
574
      fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA%d.CPX)\r\n", locales->codepage, targetdrv, locales->egafile);
569
    }
575
    }
570
    fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
576
    fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
571
  }
577
  }
572
  if (locales->keybfile > 0) {
578
  if (locales->keybfile > 0) {
573
    if (locales->keybfile == 1) {
579
    if (locales->keybfile == 1) {
574
      snprintf(buff2, sizeof(buff2), "KEYBOARD.SYS");
580
      snprintf(buff2, sizeof(buff2), "KEYBOARD.SYS");
575
    } else {
581
    } else {
576
      snprintf(buff2, sizeof(buff2), "KEYBRD%d.SYS", locales->keybfile);
582
      snprintf(buff2, sizeof(buff2), "KEYBRD%d.SYS", locales->keybfile);
577
    }
583
    }
578
    if (locales->keybid == 0) {
584
    if (locales->keybid == 0) {
579
      buff3[0] = 0;
585
      buff3[0] = 0;
580
    } else {
586
    } else {
581
      snprintf(buff3, sizeof(buff3), " /ID:%d", locales->keybid);
587
      snprintf(buff3, sizeof(buff3), " /ID:%d", locales->keybid);
582
    }
588
    }
583
    fprintf(fd, "KEYB %s,%d,%c:\\SYSTEM\\SVAROG.386\\BIN\\%s%s\r\n", locales->keybcode, locales->codepage, targetdrv, buff2, buff3);
589
    fprintf(fd, "KEYB %s,%d,%c:\\SYSTEM\\SVAROG.386\\BIN\\%s%s\r\n", locales->keybcode, locales->codepage, targetdrv, buff2, buff3);
584
    fprintf(fd, "\r\n");
590
    fprintf(fd, "\r\n");
585
  }
591
  }
586
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
592
  fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
587
  fprintf(fd, "\r\n");
593
  fprintf(fd, "\r\n");
588
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
594
  fprintf(fd, "REM Uncomment the line below for automatic mouse support\r\n");
589
  fprintf(fd, "REM CTMOUSE\r\n");
595
  fprintf(fd, "REM CTMOUSE\r\n");
590
  fprintf(fd, "\r\n");
596
  fprintf(fd, "\r\n");
591
  fprintf(fd, "ECHO.\r\n");
597
  fprintf(fd, "ECHO.\r\n");
592
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to Svarog386! Type 'HELP' if you need help."));
598
  fprintf(fd, "ECHO %s\r\n", kittengets(6, 0, "Welcome to Svarog386! Type 'HELP' if you need help."));
593
  fclose(fd);
599
  fclose(fd);
594
  /*** CREATE DIRECTORY FOR OTHER CONFIGURATION FILES ***/
600
  /*** CREATE DIRECTORY FOR OTHER CONFIGURATION FILES ***/
595
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
601
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG", targetdrv);
596
  mkdir(buff);
602
  mkdir(buff);
597
  /*** FDNPKG.CFG ***/
603
  /*** FDNPKG.CFG ***/
598
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
604
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\CFG\\FDNPKG.CFG", targetdrv);
599
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
605
  fcopysub(buff, "A:\\DAT\\FDNPKG.CFG", '$', cdromdrv);
600
  /*** COUNTRY.SYS ***/
606
  /*** COUNTRY.SYS ***/
601
  /*** PICOTCP ***/
607
  /*** PICOTCP ***/
602
  /*** WATTCP ***/
608
  /*** WATTCP ***/
603
}
609
}
604
 
610
 
605
 
611
 
606
static void installpackages(int targetdrv, int cdromdrv) {
612
static void installpackages(int targetdrv, int cdromdrv) {
607
  char *pkglist[] = {
613
  char *pkglist[] = {
608
    "A:\\UDVD2", /* this one's not part of CORE, hence it's stored right on the floppy */
614
    "A:\\UDVD2", /* this one's not part of CORE, hence it's stored right on the floppy */
609
    "APPEND",
615
    "APPEND",
610
    "ASSIGN",
616
    "ASSIGN",
611
    "ATTRIB",
617
    "ATTRIB",
612
    "CHKDSK",
618
    "CHKDSK",
613
    "CHOICE",
619
    "CHOICE",
614
    "COMMAND",
620
    "COMMAND",
615
    "COMP",
621
    "COMP",
616
    "CPIDOS",
622
    "CPIDOS",
617
    "CTMOUSE",
623
    "CTMOUSE",
618
    "DEBUG",
624
    "DEBUG",
619
    "DEFRAG",
625
    "DEFRAG",
620
    "DELTREE",
626
    "DELTREE",
621
    "DEVLOAD",
627
    "DEVLOAD",
622
    "DISKCOMP",
628
    "DISKCOMP",
623
    "DISKCOPY",
629
    "DISKCOPY",
624
    "DISPLAY",
630
    "DISPLAY",
625
    "DOSFSCK",
631
    "DOSFSCK",
626
    "EDIT",
632
    "EDIT",
627
    "EDLIN",
633
    "EDLIN",
628
    "EXE2BIN",
634
    "EXE2BIN",
629
    "FC",
635
    "FC",
630
    "FDAPM",
636
    "FDAPM",
631
    "FDISK",
637
    "FDISK",
632
    "FDNPKG",
638
    "FDNPKG",
633
    "FIND",
639
    "FIND",
634
    "FORMAT",
640
    "FORMAT",
635
    "HELP",
641
    "HELP",
636
    "HIMEMX",
642
    "HIMEMX",
637
    "KERNEL",
643
    "KERNEL",
638
    "KEYB",
644
    "KEYB",
639
    "KEYB_LAY",
645
    "KEYB_LAY",
640
    "LABEL",
646
    "LABEL",
641
    "LBACACHE",
647
    "LBACACHE",
642
    "MEM",
648
    "MEM",
643
    "MIRROR",
649
    "MIRROR",
644
    "MODE",
650
    "MODE",
645
    "MORE",
651
    "MORE",
646
    "MOVE",
652
    "MOVE",
647
    "NANSI",
653
    "NANSI",
648
    "NLSFUNC",
654
    "NLSFUNC",
649
    "PRINT",
655
    "PRINT",
650
    "RDISK",
656
    "RDISK",
651
    "RECOVER",
657
    "RECOVER",
652
    "REPLACE",
658
    "REPLACE",
653
    "SHARE",
659
    "SHARE",
654
    "SHSUCDX",
660
    "SHSUCDX",
655
    "SORT",
661
    "SORT",
656
    "SWSUBST",
662
    "SWSUBST",
657
    "TREE",
663
    "TREE",
658
    "UNDELETE",
664
    "UNDELETE",
659
    "XCOPY",
665
    "XCOPY",
660
    NULL
666
    NULL
661
  };
667
  };
662
  int i, pkglistlen;
668
  int i, pkglistlen;
663
  char buff[64];
669
  char buff[64];
664
  newscreen(3);
670
  newscreen(3);
665
  /* count how long the pkg list is */
671
  /* count how long the pkg list is */
666
  for (pkglistlen = 0; pkglist[pkglistlen] != NULL; pkglistlen++);
672
  for (pkglistlen = 0; pkglist[pkglistlen] != NULL; pkglistlen++);
667
  /* set DOSDIR and friends */
673
  /* set DOSDIR and friends */
668
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVAROG.386", targetdrv);
674
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVAROG.386", targetdrv);
669
  setenv("DOSDIR", buff, 1);
675
  setenv("DOSDIR", buff, 1);
670
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
676
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
671
  setenv("TEMP", buff, 1);
677
  setenv("TEMP", buff, 1);
672
  /* install packages */
678
  /* install packages */
673
  for (i = 0; pkglist[i] != NULL; i++) {
679
  for (i = 0; pkglist[i] != NULL; i++) {
674
    char buff[128];
680
    char buff[128];
675
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
681
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
676
    strcat(buff, "       ");
682
    strcat(buff, "       ");
677
    video_putstring(10, 1, COLOR_BODY[mono], buff, -1);
683
    video_putstring(10, 1, COLOR_BODY[mono], buff, -1);
678
    if (pkglist[i][1] == ':') {
684
    if (pkglist[i][1] == ':') {
679
      snprintf(buff, sizeof(buff), "FDINST INSTALL %s.ZIP > NUL", pkglist[i]);
685
      snprintf(buff, sizeof(buff), "FDINST INSTALL %s.ZIP > NUL", pkglist[i]);
680
    } else {
686
    } else {
681
      snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\CORE\\%s.ZIP > NUL", cdromdrv, pkglist[i]);
687
      snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\CORE\\%s.ZIP > NUL", cdromdrv, pkglist[i]);
682
    }
688
    }
683
    system(buff);
689
    system(buff);
684
  }
690
  }
685
}
691
}
686
 
692
 
687
 
693
 
688
static void finalreboot(void) {
694
static void finalreboot(void) {
689
  int y = 9;
695
  int y = 9;
690
  newscreen(2);
696
  newscreen(2);
691
  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.");
697
  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.");
692
  putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
698
  putstringnls(++y, 1, COLOR_BODY[mono], 0, 5, "Press any key...");
693
  input_getkey();
699
  input_getkey();
694
  reboot();
700
  reboot();
695
}
701
}
696
 
702
 
697
 
703
 
698
static void loadcp(struct slocales *locales) {
704
static void loadcp(struct slocales *locales) {
699
  char buff[64];
705
  char buff[64];
700
  if (locales->codepage == 437) return;
706
  if (locales->codepage == 437) return;
701
  video_movecursor(1, 0);
707
  video_movecursor(1, 0);
702
  if (locales->egafile == 1) {
708
  if (locales->egafile == 1) {
703
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA.CPX) > NUL", locales->codepage);
709
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA.CPX) > NUL", locales->codepage);
704
  } else {
710
  } else {
705
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
711
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
706
  }
712
  }
707
  system(buff);
713
  system(buff);
708
  snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
714
  snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
709
  system(buff);
715
  system(buff);
710
  /* below I re-init the video controller - apparently this is required if
716
  /* below I re-init the video controller - apparently this is required if
711
   * I want the new glyph symbols to be actually applied, at least some
717
   * I want the new glyph symbols to be actually applied, at least some
712
   * (broken?) BIOSes, like VBox, apply glyphs only at next video mode change */
718
   * (broken?) BIOSes, like VBox, apply glyphs only at next video mode change */
713
  {
719
  {
714
  union REGS r;
720
  union REGS r;
715
  r.h.ah = 0x0F; /* get current video mode */
721
  r.h.ah = 0x0F; /* get current video mode */
716
  int86(0x10, &r, &r); /* r.h.al contains the current video mode now */
722
  int86(0x10, &r, &r); /* r.h.al contains the current video mode now */
717
  r.h.al |= 128; /* set the high bit of AL to instruct BIOS not to flush VRAM's content (EGA+) */
723
  r.h.al |= 128; /* set the high bit of AL to instruct BIOS not to flush VRAM's content (EGA+) */
718
  r.h.ah = 0; /* re-set video mode (to whatever is set in AL) */
724
  r.h.ah = 0; /* re-set video mode (to whatever is set in AL) */
719
  int86(0x10, &r, &r);
725
  int86(0x10, &r, &r);
720
  }
726
  }
721
}
727
}
722
 
728
 
723
/* checks CD drive drv for the presence of the Svarog386 install CD
729
/* checks CD drive drv for the presence of the Svarog386 install CD
724
 * returns 0 if found, non-zero otherwise */
730
 * returns 0 if found, non-zero otherwise */
725
static int checkcd(char drv) {
731
static int checkcd(char drv) {
726
  FILE *fd;
732
  FILE *fd;
727
  char fname[32];
733
  char fname[32];
728
  snprintf(fname, sizeof(fname), "%c:\\CORE\\MEM.ZIP", drv);
734
  snprintf(fname, sizeof(fname), "%c:\\CORE\\MEM.ZIP", drv);
729
  fd = fopen(fname, "rb");
735
  fd = fopen(fname, "rb");
730
  if (fd == NULL) return(-1);
736
  if (fd == NULL) return(-1);
731
  fclose(fd);
737
  fclose(fd);
732
  return(0);
738
  return(0);
733
}
739
}
734
 
740
 
735
 
741
 
736
int main(void) {
742
int main(void) {
737
  struct slocales locales;
743
  struct slocales locales;
738
  int targetdrv;
744
  int targetdrv;
739
  int cdromdrv;
745
  int cdromdrv;
740
  int action;
746
  int action;
741
 
747
 
742
  /* find where the cdrom drive is */
748
  /* find where the cdrom drive is */
743
  cdromdrv = cdrom_findfirst();
749
  cdromdrv = cdrom_findfirst();
744
  if (cdromdrv < 0) {
750
  if (cdromdrv < 0) {
745
    printf("ERROR: CD-ROM DRIVE NOT FOUND\r\n");
751
    printf("ERROR: CD-ROM DRIVE NOT FOUND\r\n");
746
    return(1);
752
    return(1);
747
  }
753
  }
748
  cdromdrv += 'A'; /* convert the cdrom 'id' (A=0) to an actual drive letter */
754
  cdromdrv += 'A'; /* convert the cdrom 'id' (A=0) to an actual drive letter */
749
  if (checkcd(cdromdrv) != 0) {
755
  if (checkcd(cdromdrv) != 0) {
750
    printf("ERROR: SVAROG386 INSTALLATION CD NOT FOUND IN THE DRIVE.\r\n");
756
    printf("ERROR: SVAROG386 INSTALLATION CD NOT FOUND IN THE DRIVE.\r\n");
751
    return(1);
757
    return(1);
752
  }
758
  }
753
 
759
 
754
  /* init screen and detect mono status */
760
  /* init screen and detect mono status */
755
  mono = video_init();
761
  mono = video_init();
756
 
762
 
757
  kittenopen("INSTALL"); /* load initial NLS support */
763
  kittenopen("INSTALL"); /* load initial NLS support */
758
 
764
 
759
 SelectLang:
765
 SelectLang:
760
  action = selectlang(&locales); /* welcome to svarog, select your language */
766
  action = selectlang(&locales); /* welcome to svarog, select your language */
761
  if (action != MENUNEXT) goto Quit;
767
  if (action != MENUNEXT) goto Quit;
762
  setenv("LANG", locales.lang, 1);
768
  setenv("LANG", locales.lang, 1);
763
  loadcp(&locales);
769
  loadcp(&locales);
764
  kittenclose(); /* reload NLS with new language */
770
  kittenclose(); /* reload NLS with new language */
765
  kittenopen("INSTALL"); /* NLS support */
771
  kittenopen("INSTALL"); /* NLS support */
766
  action = selectkeyb(&locales);  /* what keyb layout should we use? */
772
  action = selectkeyb(&locales);  /* what keyb layout should we use? */
767
  if (action == MENUQUIT) goto Quit;
773
  if (action == MENUQUIT) goto Quit;
768
  if (action == MENUPREV) goto SelectLang;
774
  if (action == MENUPREV) goto SelectLang;
769
 
775
 
770
 WelcomeScreen:
776
 WelcomeScreen:
771
  action = welcomescreen(); /* what svarog386 is, ask whether to run live dos or install */
777
  action = welcomescreen(); /* what svarog386 is, ask whether to run live dos or install */
772
  if (action == MENUQUIT) goto Quit;
778
  if (action == MENUQUIT) goto Quit;
773
  if (action == MENUPREV) goto SelectLang;
779
  if (action == MENUPREV) goto SelectLang;
774
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
780
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
775
  if (targetdrv == MENUQUIT) goto Quit;
781
  if (targetdrv == MENUQUIT) goto Quit;
776
  if (targetdrv == MENUPREV) goto WelcomeScreen;
782
  if (targetdrv == MENUPREV) goto WelcomeScreen;
777
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
783
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
778
  installpackages(targetdrv, cdromdrv);    /* install packages */
784
  installpackages(targetdrv, cdromdrv);    /* install packages */
779
  bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
785
  bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
780
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
786
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
781
  /*netcfg();*/ /* basic networking config */
787
  /*netcfg();*/ /* basic networking config */
782
  finalreboot(); /* remove the CD and reboot */
788
  finalreboot(); /* remove the CD and reboot */
783
 
789
 
784
 Quit:
790
 Quit:
785
  kittenclose(); /* close NLS support */
791
  kittenclose(); /* close NLS support */
786
  video_clear(0x0700, 0, 0);
792
  video_clear(0x0700, 0, 0);
787
  video_movecursor(0, 0);
793
  video_movecursor(0, 0);
788
  return(0);
794
  return(0);
789
}
795
}
790
 
796