Subversion Repositories SvarDOS

Rev

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

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