Subversion Repositories SvarDOS

Rev

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

Rev 28 Rev 29
1
/*
1
/*
2
 * SVAROG386 INSTALL
2
 * SVAROG386 INSTALL
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE
3
 * COPYRIGHT (C) 2016 MATEUSZ VISTE
4
 */
4
 */
5
 
5
 
6
#include <dos.h>
6
#include <dos.h>
7
#include <stdio.h>   /* printf() and friends */
7
#include <stdio.h>   /* printf() and friends */
8
#include <stdlib.h>  /* system() */
8
#include <stdlib.h>  /* system() */
9
#include <string.h>  /* memcpy() */
9
#include <string.h>  /* memcpy() */
10
#include <unistd.h>
10
#include <unistd.h>
11
#include "input.h"
11
#include "input.h"
12
#include "video.h"
12
#include "video.h"
13
 
13
 
-
 
14
/* color scheme (color, mono) */
14
#define COLOR_TITLEBAR 0x7000
15
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
15
#define COLOR_BODY 0x1700
16
static unsigned short COLOR_BODY[2] = {0x1700,0x0700};
16
#define COLOR_SELECT 0x7000
17
static unsigned short COLOR_SELECT[2] = {0x7000,0x7000};
17
#define COLOR_SELECTCUR 0x1F00
18
static unsigned short COLOR_SELECTCUR[2] = {0x1F00,0x0700};
18
 
19
 
-
 
20
/* mono flag */
-
 
21
static int mono = 0;
19
 
22
 
20
 
23
 
21
/* reboot the computer */
24
/* reboot the computer */
22
static void reboot(void) {
25
static void reboot(void) {
23
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
26
  void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
24
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
27
  int far *rstaddr = (int far *)0x00400072L; /* BIOS boot flag is at 0040:0072 */
25
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
28
  *rstaddr = 0x1234; /* 0x1234 = warm boot, 0 = cold boot */
26
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
29
  (*bootroutine)(); /* jump to the BIOS reboot routine at FFFF:0000 */
27
}
30
}
28
 
31
 
29
static int menuselect(int ypos, int xpos, int height, char **list) {
32
static int menuselect(int ypos, int xpos, int height, char **list) {
30
  int i, offset = 0, res = 0, count, width = 0;
33
  int i, offset = 0, res = 0, count, width = 0;
31
  /* count how many languages there is */
34
  /* count how many languages there is */
32
  for (count = 0; list[count] != NULL; count++) {
35
  for (count = 0; list[count] != NULL; count++) {
33
    int len = strlen(list[count]);
36
    int len = strlen(list[count]);
34
    if (len > width) width = len;
37
    if (len > width) width = len;
35
  }
38
  }
36
 
39
 
37
  /* if xpos negative, means 'center out' */
40
  /* if xpos negative, means 'center out' */
38
  if (xpos < 0) xpos = 39 - (width >> 1);
41
  if (xpos < 0) xpos = 39 - (width >> 1);
39
 
42
 
40
  video_putchar(ypos, xpos+width+2, COLOR_SELECT, 0xBF);         /*       \ */
43
  video_putchar(ypos, xpos+width+2, COLOR_SELECT[mono], 0xBF);         /*       \ */
41
  video_putchar(ypos, xpos-1, COLOR_SELECT, 0xDA);               /*  /      */
44
  video_putchar(ypos, xpos-1, COLOR_SELECT[mono], 0xDA);               /*  /      */
42
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT, 0xC0);      /*  \      */
45
  video_putchar(ypos+height-1, xpos-1, COLOR_SELECT[mono], 0xC0);      /*  \      */
43
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT, 0xD9);/*      /  */
46
  video_putchar(ypos+height-1, xpos+width+2, COLOR_SELECT[mono], 0xD9);/*      /  */
44
  video_putcharmulti(ypos, xpos, COLOR_SELECT, 0xC4, width + 2, 1);
47
  video_putcharmulti(ypos, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
45
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT, 0xC4, width + 2, 1);
48
  video_putcharmulti(ypos+height-1, xpos, COLOR_SELECT[mono], 0xC4, width + 2, 1);
46
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT, 0xB3, height - 2, 80);
49
  video_putcharmulti(ypos+1, xpos-1, COLOR_SELECT[mono], 0xB3, height - 2, 80);
47
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT, 0xB3, height - 2, 80);
50
  video_putcharmulti(ypos+1, xpos+width+2, COLOR_SELECT[mono], 0xB3, height - 2, 80);
48
 
51
 
49
  for (;;) {
52
  for (;;) {
50
    int key;
53
    int key;
51
    /* list of selectable items */
54
    /* list of selectable items */
52
    for (i = 0; i < height - 2; i++) {
55
    for (i = 0; i < height - 2; i++) {
53
      if (i + offset == res) {
56
      if (i + offset == res) {
54
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR, 16);
57
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECTCUR[mono], 16);
55
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR, 17);
58
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECTCUR[mono], 17);
56
        video_movecursor(ypos + 1 + i, xpos);
59
        video_movecursor(ypos + 1 + i, xpos);
57
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR, list[i + offset], width);
60
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECTCUR[mono], list[i + offset], width);
58
      } else if (i + offset < count) {
61
      } else if (i + offset < count) {
59
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT, ' ');
62
        video_putchar(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ');
60
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT, ' ');
63
        video_putchar(ypos + 1 + i, xpos+width+1, COLOR_SELECT[mono], ' ');
61
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT, list[i + offset], width);
64
        video_putstringfix(ypos + 1 + i, xpos+1, COLOR_SELECT[mono], list[i + offset], width);
62
      } else {
65
      } else {
63
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT, ' ', width+2, 1);
66
        video_putcharmulti(ypos + 1 + i, xpos, COLOR_SELECT[mono], ' ', width+2, 1);
64
      }
67
      }
65
    }
68
    }
66
    key = input_getkey();
69
    key = input_getkey();
67
    if (key == 0x0D) { /* ENTER */
70
    if (key == 0x0D) { /* ENTER */
68
      return(res);
71
      return(res);
69
    } else if (key == 0x148) { /* up */
72
    } else if (key == 0x148) { /* up */
70
      if (res > 0) res--;
73
      if (res > 0) res--;
71
    } else if (key == 0x150) { /* down */
74
    } else if (key == 0x150) { /* down */
72
      if (res+1 < count) res++;
75
      if (res+1 < count) res++;
73
    } else if (key == 0x1B) {  /* ESC */
76
    } else if (key == 0x1B) {  /* ESC */
74
      return(-1);
77
      return(-1);
75
    }
78
    }
76
  }
79
  }
77
}
80
}
78
 
81
 
79
static void newscreen(void) {
82
static void newscreen(void) {
80
  int x;
83
  int x;
81
  for (x = 0; x < 80; x++) video_putchar(0, x, COLOR_TITLEBAR, ' ');
84
  for (x = 0; x < 80; x++) video_putchar(0, x, COLOR_TITLEBAR[mono], ' ');
82
  video_clear(COLOR_BODY, 80);
85
  video_clear(COLOR_BODY[mono], 80);
83
  video_putstring(0, 29, COLOR_TITLEBAR, "SVAROG386 INSTALLATION");
86
  video_putstring(0, 29, COLOR_TITLEBAR[mono], "SVAROG386 INSTALLATION");
84
}
87
}
85
 
88
 
86
 
89
 
87
static int selectlang(char *lang) {
90
static int selectlang(char *lang) {
88
  int choice;
91
  int choice;
89
  char *code;
92
  char *code;
90
  char *langlist[] = {
93
  char *langlist[] = {
91
    "English\0EN",
94
    "English\0EN",
92
    "French\0FR",
95
    "French\0FR",
93
    "German\0DE",
96
    "German\0DE",
94
    "Italian\0IT",
97
    "Italian\0IT",
95
    "Polish\0PL",
98
    "Polish\0PL",
96
    "Russian\0RU",
99
    "Russian\0RU",
97
    "Slovenian\0SL",
100
    "Slovenian\0SL",
98
    "Spanish\0ES",
101
    "Spanish\0ES",
99
    "Turkish\0TR",
102
    "Turkish\0TR",
100
    NULL
103
    NULL
101
  };
104
  };
102
 
105
 
103
  newscreen();
106
  newscreen();
104
  video_putstring(3, 30, COLOR_BODY, "Welcome to Svarog386");
107
  video_putstring(3, 30, COLOR_BODY[mono], "Welcome to Svarog386");
105
  video_putstring(4, 30, COLOR_BODY, "====================");
108
  video_putstring(4, 30, COLOR_BODY[mono], "====================");
106
  video_putstring(6, 2, COLOR_BODY, "Svarog386 is an operating system based on the FreeDOS kernel. It targets");
109
  video_putstring(6, 2, COLOR_BODY[mono], "Svarog386 is an operating system based on the FreeDOS kernel. It targets");
107
  video_putstring(7, 2, COLOR_BODY, "386+ computers and comes with a variety of third-party applications. Before");
110
  video_putstring(7, 2, COLOR_BODY[mono], "386+ computers and comes with a variety of third-party applications. Before");
108
  video_putstring(8, 2, COLOR_BODY, "we get to serious business, please select your preferred language from the");
111
  video_putstring(8, 2, COLOR_BODY[mono], "we get to serious business, please select your preferred language from the");
109
  video_putstring(9, 2, COLOR_BODY, "list below, and press the ENTER key:");
112
  video_putstring(9, 2, COLOR_BODY[mono], "list below, and press the ENTER key:");
110
  choice = menuselect(11, -1, 12, langlist);
113
  choice = menuselect(11, -1, 12, langlist);
111
  if (choice < 0) return(-1);
114
  if (choice < 0) return(-1);
112
  /* write short language code into lang */
115
  /* write short language code into lang */
113
  for (code = langlist[choice]; *code != 0; code++);
116
  for (code = langlist[choice]; *code != 0; code++);
114
  memcpy(lang, code + 1, 2);
117
  memcpy(lang, code + 1, 2);
115
  lang[2] = 0;
118
  lang[2] = 0;
116
  return(0);
119
  return(0);
117
}
120
}
118
 
121
 
119
 
122
 
120
/* returns 0 if installation must proceed, non-zero otherwise */
123
/* returns 0 if installation must proceed, non-zero otherwise */
121
static int welcomescreen(void) {
124
static int welcomescreen(void) {
122
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
125
  char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
123
  newscreen();
126
  newscreen();
124
  video_putstring(4, 1, COLOR_BODY, "You are about to install Svarog386, a free, MSDOS-compatible operating system");
127
  video_putstring(4, 1, COLOR_BODY[mono], "You are about to install Svarog386, a free, MSDOS-compatible operating system");
125
  video_putstring(5, 1, COLOR_BODY, "based on the FreeDOS kernel.");
128
  video_putstring(5, 1, COLOR_BODY[mono], "based on the FreeDOS kernel.");
126
  video_putstring(7, 1, COLOR_BODY, "WARNING: If your PC has another operating system installed, this other system");
129
  video_putstring(7, 1, COLOR_BODY[mono], "WARNING: If your PC has another operating system installed, this other system");
127
  video_putstring(8, 1, COLOR_BODY, "         might be unable to boot once Svarog386 is installed.");
130
  video_putstring(8, 1, COLOR_BODY[mono], "         might be unable to boot once Svarog386 is installed.");
128
  return(menuselect(14, -1, 4, choice));
131
  return(menuselect(14, -1, 4, choice));
129
}
132
}
130
 
133
 
131
 
134
 
132
static int testdrive(int drv) {
135
static int testdrive(int drv) {
133
  union REGS r;
136
  union REGS r;
134
  /* try to switch to new drive */
137
  /* try to switch to new drive */
135
  r.h.ah = 0x0E;
138
  r.h.ah = 0x0E;
136
  r.h.dl = drv;
139
  r.h.dl = drv;
137
  int86(0x21, &r, &r);
140
  int86(0x21, &r, &r);
138
  /* has it worked? if yes, then the drive is valid */
141
  /* has it worked? if yes, then the drive is valid */
139
  r.h.ah = 0x19;
142
  r.h.ah = 0x19;
140
  int86(0x21, &r, &r);
143
  int86(0x21, &r, &r);
141
  if (r.h.al == drv) return(0);
144
  if (r.h.al == drv) return(0);
142
  return(-1);
145
  return(-1);
143
}
146
}
144
 
147
 
145
 
148
 
146
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid
149
/* returns total disk space of drive drv (in MiB, max 2048), or -1 if drive invalid
147
 * also sets emptyflag to 1 if drive is empty, or to 0 otherwise */
150
 * also sets emptyflag to 1 if drive is empty, or to 0 otherwise */
148
static int disksize(int drv, int *emptyflag) {
151
static int disksize(int drv, int *emptyflag) {
149
  long res;
152
  long res;
150
  union REGS r;
153
  union REGS r;
151
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
154
  r.h.ah = 0x36; /* DOS 2+ get free disk space */
152
  r.h.dl = drv;
155
  r.h.dl = drv;
153
  int86(0x21, &r, &r);
156
  int86(0x21, &r, &r);
154
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
157
  if (r.x.ax == 0xffffu) return(-1); /* AX set to FFFFh if drive invalid */
155
  res = r.x.ax;
158
  res = r.x.ax;
156
  res *= r.x.bx;
159
  res *= r.x.bx;
157
  res *= r.x.cx;
160
  res *= r.x.cx;
158
  res >>= 20; /* bytes to MiB */
161
  res >>= 20; /* bytes to MiB */
159
  if (r.x.dx != r.x.bx) { /* DX is total number of clusters, while BX is only free clusters */
162
  if (r.x.dx != r.x.bx) { /* DX is total number of clusters, while BX is only free clusters */
160
    *emptyflag = 0;
163
    *emptyflag = 0;
161
  } else {
164
  } else {
162
    *emptyflag = 1;
165
    *emptyflag = 1;
163
  }
166
  }
164
  return(res);
167
  return(res);
165
}
168
}
166
 
169
 
167
 
170
 
168
static int preparedrive(void) {
171
static int preparedrive(void) {
169
  int driveexists;
172
  int driveexists;
170
  int selecteddrive = 3; /* hardcoded to 'C:' */
173
  int selecteddrive = 3; /* hardcoded to 'C:' */
171
  int ds, emptydriveflag;
174
  int ds, emptydriveflag;
172
  for (;;) {
175
  for (;;) {
173
    newscreen();
176
    newscreen();
174
    driveexists = testdrive(selecteddrive);
177
    driveexists = testdrive(selecteddrive);
175
    if (driveexists != 0) {
178
    if (driveexists != 0) {
176
      char *list[] = { "Run the FDISK partitionning tool", "Quit to DOS", NULL};
179
      char *list[] = { "Run the FDISK partitionning tool", "Quit to DOS", NULL};
177
      video_putstring(4, 2, COLOR_BODY, "ERROR: Drive C: could not be found. Perhaps your hard disk needs to be");
180
      video_putstring(4, 2, COLOR_BODY[mono], "ERROR: Drive C: could not be found. Perhaps your hard disk needs to be");
178
      video_putstring(5, 2, COLOR_BODY, "       partitionned first. Please create at least one partition on your");
181
      video_putstring(5, 2, COLOR_BODY[mono], "       partitionned first. Please create at least one partition on your");
179
      video_putstring(6, 2, COLOR_BODY, "       hard disk, so Svarog386 can be installed on it. Note, that");
182
      video_putstring(6, 2, COLOR_BODY[mono], "       hard disk, so Svarog386 can be installed on it. Note, that");
180
      video_putstring(7, 2, COLOR_BODY, "       Svarog386 requires at least 16 MiB of available disk space.");
183
      video_putstring(7, 2, COLOR_BODY[mono], "       Svarog386 requires at least 16 MiB of available disk space.");
181
      video_putstring(9, 2, COLOR_BODY, "You can use the FDISK partitioning tool for creating the required partition,");
184
      video_putstring(9, 2, COLOR_BODY[mono], "You can use the FDISK partitioning tool for creating the required partition,");
182
      video_putstring(10, 2, COLOR_BODY, "or abort the installation and use any other partition manager of your choice.");
185
      video_putstring(10, 2, COLOR_BODY[mono], "or abort the installation and use any other partition manager of your choice.");
183
      if (menuselect(12, -1, 4, list) != 0) return(-1);
186
      if (menuselect(12, -1, 4, list) != 0) return(-1);
184
      video_clear(0x0700, 0);
187
      video_clear(0x0700, 0);
185
      video_movecursor(0, 0);
188
      video_movecursor(0, 0);
186
      system("fdisk");
189
      system("fdisk");
187
      newscreen();
190
      newscreen();
188
      video_putstring(13, 10, COLOR_BODY, "Your computer will reboot now. Press any key.");
191
      video_putstring(13, 10, COLOR_BODY[mono], "Your computer will reboot now. Press any key.");
189
      reboot();
192
      reboot();
190
      return(-1);
193
      return(-1);
191
    }
194
    }
192
    /* if not formatted, propose to format it right away */
195
    /* if not formatted, propose to format it right away */
193
    ds = disksize(selecteddrive, &emptydriveflag);
196
    ds = disksize(selecteddrive, &emptydriveflag);
194
    if (ds < 0) {
197
    if (ds < 0) {
195
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
198
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
196
      video_putstring(7, 2, COLOR_BODY, "ERROR: Drive C: seems to be unformated.");
199
      video_putstring(7, 2, COLOR_BODY[mono], "ERROR: Drive C: seems to be unformated.");
197
      video_putstring(8, 2, COLOR_BODY, "       Do you wish to format it?");
200
      video_putstring(8, 2, COLOR_BODY[mono], "       Do you wish to format it?");
198
      if (menuselect(12, -1, 4, list) != 0) return(-1);
201
      if (menuselect(12, -1, 4, list) != 0) return(-1);
199
      video_clear(0x0700, 0);
202
      video_clear(0x0700, 0);
200
      video_movecursor(0, 0);
203
      video_movecursor(0, 0);
201
      system("FORMAT /Q C:");
204
      system("FORMAT /Q C:");
202
      continue;
205
      continue;
203
    }
206
    }
204
    /* check total space */
207
    /* check total space */
205
    if (ds < 16) {
208
    if (ds < 16) {
206
      video_putstring(9, 2, COLOR_BODY, "ERROR: Drive C: is not big enough! Svarog386 requires a disk of at least 16 MiB.");
209
      video_putstring(9, 2, COLOR_BODY[mono], "ERROR: Drive C: is not big enough! Svarog386 requires a disk of at least 16 MiB.");
207
      video_putstring(11, 2, COLOR_BODY, "Press any key to return to DOS.");
210
      video_putstring(11, 2, COLOR_BODY[mono], "Press any key to return to DOS.");
208
      input_getkey();
211
      input_getkey();
209
      return(-1);
212
      return(-1);
210
    }
213
    }
211
    /* is the disk empty? */
214
    /* is the disk empty? */
212
    if (emptydriveflag != 0) {
215
    if (emptydriveflag != 0) {
213
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
216
      char *list[] = { "Proceed with formatting", "Quit to DOS", NULL};
214
      video_putstring(7, 2, COLOR_BODY, "ERROR: Drive C: is not empty. Svarog386 must be installed on an empty disk.");
217
      video_putstring(7, 2, COLOR_BODY[mono], "ERROR: Drive C: is not empty. Svarog386 must be installed on an empty disk.");
215
      video_putstring(8, 2, COLOR_BODY, "       You can format the disk now, to make it empty. Note however, that");
218
      video_putstring(8, 2, COLOR_BODY[mono], "       You can format the disk now, to make it empty. Note however, that");
216
      video_putstring(9, 2, COLOR_BODY, "       this will ERASE ALL CURRENT DATA on your disk.");
219
      video_putstring(9, 2, COLOR_BODY[mono], "       this will ERASE ALL CURRENT DATA on your disk.");
217
      if (menuselect(12, -1, 4, list) != 0) return(-1);
220
      if (menuselect(12, -1, 4, list) != 0) return(-1);
218
      video_clear(0x0700, 0);
221
      video_clear(0x0700, 0);
219
      video_movecursor(0, 0);
222
      video_movecursor(0, 0);
220
      system("FORMAT /Q C:");
223
      system("FORMAT /Q C:");
221
      continue;
224
      continue;
222
    } else {
225
    } else {
223
      /* final confirmation */
226
      /* final confirmation */
224
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
227
      char *list[] = { "Install Svarog386", "Quit to DOS", NULL};
225
      video_putstring(8, 2, COLOR_BODY, "The installation of Svarog386 to your C: disk is about to begin.");
228
      video_putstring(8, 2, COLOR_BODY[mono], "The installation of Svarog386 to your C: disk is about to begin.");
226
      if (menuselect(10, -1, 4, list) != 0) return(-1);
229
      if (menuselect(10, -1, 4, list) != 0) return(-1);
227
      system("SYS A: C:");
230
      system("SYS A: C:");
228
      return(0);
231
      return(0);
229
    }
232
    }
230
  }
233
  }
231
}
234
}
232
 
235
 
233
 
236
 
234
static void finalreboot(void) {
237
static void finalreboot(void) {
235
  newscreen();
238
  newscreen();
236
  video_putstring(10, 2, COLOR_BODY, "Svarog386 installation is over. Please remove the");
239
  video_putstring(10, 2, COLOR_BODY[mono], "Svarog386 installation is over. Please remove the");
237
  video_putstring(10, 2, COLOR_BODY, "installation diskette and/or CD from the drive.");
240
  video_putstring(10, 2, COLOR_BODY[mono], "installation diskette and/or CD from the drive.");
238
  video_putstring(13, 2, COLOR_BODY, "Press any key to reboot...");
241
  video_putstring(13, 2, COLOR_BODY[mono], "Press any key to reboot...");
239
  input_getkey();
242
  input_getkey();
240
  reboot();
243
  reboot();
241
}
244
}
242
 
245
 
243
 
246
 
244
static void bootfilesgen(int targetdrv, char *lang) {
247
static void bootfilesgen(int targetdrv, char *lang) {
245
  char drv = 'A' + targetdrv - 1;
248
  char drv = 'A' + targetdrv - 1;
246
  char buff[128];
249
  char buff[128];
247
  FILE *fd;
250
  FILE *fd;
248
  /*** AUTOEXEC.BAT ***/
251
  /*** AUTOEXEC.BAT ***/
249
  sprintf(buff, "%c:\\AUTOEXEC.BAT", drv);
252
  sprintf(buff, "%c:\\AUTOEXEC.BAT", drv);
250
  fd = fopen(buff, "wb");
253
  fd = fopen(buff, "wb");
251
  if (fd == NULL) return;
254
  if (fd == NULL) return;
252
  fprintf(fd, "@ECHO OFF\r\n");
255
  fprintf(fd, "@ECHO OFF\r\n");
253
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", drv);
256
  fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", drv);
254
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", drv);
257
  fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", drv);
255
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n", drv);
258
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n", drv);
256
  fprintf(fd, "SET LANG=%s\r\n", lang);
259
  fprintf(fd, "SET LANG=%s\r\n", lang);
257
  fprintf(fd, "SET DIRCMD=/OGNE/P\r\n");
260
  fprintf(fd, "SET DIRCMD=/OGNE/P\r\n");
258
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n");
261
  fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n");
259
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n");
262
  fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n");
260
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%%DOSDIR%%\\LINKS\r\n");
263
  fprintf(fd, "PATH %%DOSDIR%%\\BIN;%%DOSDIR%%\\LINKS\r\n");
261
  fprintf(fd, "PROMPT $P$G\r\n");
264
  fprintf(fd, "PROMPT $P$G\r\n");
262
  fprintf(fd, "\r\n\r\n");
265
  fprintf(fd, "\r\n\r\n");
263
  fprintf(fd, "MODE CON CP PREPARE=((991) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA10.CPX\r\n");
266
  fprintf(fd, "MODE CON CP PREPARE=((991) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA10.CPX\r\n");
264
  fprintf(fd, "MODE CON CP SELECT=991\r\n");
267
  fprintf(fd, "MODE CON CP SELECT=991\r\n");
265
  fprintf(fd, "\r\n");
268
  fprintf(fd, "\r\n");
266
  fprintf(fd, "SHSUCDX /d:FDCD0001\r\n");
269
  fprintf(fd, "SHSUCDX /d:FDCD0001\r\n");
267
  fclose(fd);
270
  fclose(fd);
268
  /*** CONFIG.SYS ***/
271
  /*** CONFIG.SYS ***/
269
  sprintf(buff, "%c:\\CONFIG.SYS", drv);
272
  sprintf(buff, "%c:\\CONFIG.SYS", drv);
270
  fd = fopen(buff, "wb");
273
  fd = fopen(buff, "wb");
271
  if (fd == NULL) return;
274
  if (fd == NULL) return;
272
  fprintf(fd, "DOS=UMB,HIGH\r\n");
275
  fprintf(fd, "DOS=UMB,HIGH\r\n");
273
  fprintf(fd, "FILES=50\r\n");
276
  fprintf(fd, "FILES=50\r\n");
274
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEM.EXE\r\n", drv);
277
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\HIMEM.EXE\r\n", drv);
275
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512", drv);
278
  fprintf(fd, "SHELLHIGH=%c:\\SYSTEM\\SVAROG.386\\BIN\\COMMAND.COM /E:512", drv);
276
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\SVAROG.386\r\n", drv);
279
  fprintf(fd, "REM COUNTRY=001,437,%c:\\SYSTEM\\SVAROG.386\r\n", drv);
277
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\CDROM.SYS /D:FDCD0001\r\n", drv);
280
  fprintf(fd, "DEVICE=%c:\\SYSTEM\\SVAROG.386\\BIN\\CDROM.SYS /D:FDCD0001\r\n", drv);
278
  fclose(fd);
281
  fclose(fd);
279
}
282
}
280
 
283
 
281
 
284
 
282
static void installpackages(void) {
285
static void installpackages(void) {
283
  char *pkglist[] = {
286
  char *pkglist[] = {
284
    "APPEND",
287
    "APPEND",
285
    "ASSIGN",
288
    "ASSIGN",
286
    "ATTRIB",
289
    "ATTRIB",
287
    "CHKDSK",
290
    "CHKDSK",
288
    "CHOICE",
291
    "CHOICE",
289
    "COMMAND",
292
    "COMMAND",
290
    "COMP",
293
    "COMP",
291
    "CPIDOS",
294
    "CPIDOS",
292
    "CTMOUSE",
295
    "CTMOUSE",
293
    "DEBUG",
296
    "DEBUG",
294
    "DEFRAG",
297
    "DEFRAG",
295
    "DELTREE",
298
    "DELTREE",
296
    "DEVLOAD",
299
    "DEVLOAD",
297
    "DISKCOMP",
300
    "DISKCOMP",
298
    "DISKCOPY",
301
    "DISKCOPY",
299
    "DISPLAY",
302
    "DISPLAY",
300
    "DOSFSCK",
303
    "DOSFSCK",
301
    "EDIT",
304
    "EDIT",
302
    "EDLIN",
305
    "EDLIN",
303
    "EXE2BIN",
306
    "EXE2BIN",
304
    "FC",
307
    "FC",
305
    "FDAPM",
308
    "FDAPM",
306
    "FDISK",
309
    "FDISK",
307
    "FDNPKG",
310
    "FDNPKG",
308
    "FIND",
311
    "FIND",
309
    "FORMAT",
312
    "FORMAT",
310
    "HELP",
313
    "HELP",
311
    "HIMEMX",
314
    "HIMEMX",
312
    "KERNEL",
315
    "KERNEL",
313
    "KEYB",
316
    "KEYB",
314
    "LABEL",
317
    "LABEL",
315
    "LBACACHE",
318
    "LBACACHE",
316
    "MEM",
319
    "MEM",
317
    "MIRROR",
320
    "MIRROR",
318
    "MODE",
321
    "MODE",
319
    "MORE",
322
    "MORE",
320
    "MOVE",
323
    "MOVE",
321
    "NANSI",
324
    "NANSI",
322
    "NLSFUNC",
325
    "NLSFUNC",
323
    "PRINT",
326
    "PRINT",
324
    "RDISK",
327
    "RDISK",
325
    "RECOVER",
328
    "RECOVER",
326
    "REPLACE",
329
    "REPLACE",
327
    "SHARE",
330
    "SHARE",
328
    "SHSUCDX",
331
    "SHSUCDX",
329
    "SORT",
332
    "SORT",
330
    "SWSUBST",
333
    "SWSUBST",
331
    "TREE",
334
    "TREE",
332
    "UNDELETE",
335
    "UNDELETE",
333
    "XCOPY",
336
    "XCOPY",
334
    NULL
337
    NULL
335
  };
338
  };
336
  int i;
339
  int i;
337
  newscreen();
340
  newscreen();
338
  video_putstring(10, 2, COLOR_BODY, "Installing packages...");
341
  video_putstring(10, 2, COLOR_BODY[mono], "Installing packages...");
339
  for (i = 0; pkglist[i] != NULL; i++) {
342
  for (i = 0; pkglist[i] != NULL; i++) {
340
    char buff[32];
343
    char buff[32];
341
    sprintf(buff, "FDINST %s.ZIP > NULL");
344
    sprintf(buff, "FDINST %s.ZIP > NULL");
342
    system(buff);
345
    system(buff);
343
  }
346
  }
344
}
347
}
345
 
348
 
346
 
349
 
347
int main(void) {
350
int main(void) {
348
  char lang[4];
351
  char lang[4];
349
  int targetdrv;
352
  int targetdrv;
350
 
353
 
-
 
354
  /* init screen and detect mono status */
-
 
355
  mono = video_init();
-
 
356
 
351
  for (;;) { /* fake loop, it's here just to break out easily */
357
  for (;;) { /* fake loop, it's here just to break out easily */
352
    if (selectlang(lang) < 0) break; /* welcome to svarog, select your language */
358
    if (selectlang(lang) < 0) break; /* welcome to svarog, select your language */
353
    /*selectkeyb();*/ /* if non-english, what keyb layout should we use? */
359
    /*selectkeyb();*/ /* if non-english, what keyb layout should we use? */
354
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
360
    if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
355
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
361
    targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
356
    if (targetdrv < 0) break;
362
    if (targetdrv < 0) break;
357
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
363
    /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
358
    installpackages();   /* install packages */
364
    installpackages();   /* install packages */
359
    bootfilesgen(targetdrv, lang); /* generate simple boot files */
365
    bootfilesgen(targetdrv, lang); /* generate simple boot files */
360
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
366
    /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
361
    /*netcfg();*/ /* basic networking config? */
367
    /*netcfg();*/ /* basic networking config? */
362
    finalreboot(); /* remove the CD and reboot */
368
    finalreboot(); /* remove the CD and reboot */
363
    break;
369
    break;
364
  }
370
  }
365
  video_clear(0x0700, 0);
371
  video_clear(0x0700, 0);
366
  video_movecursor(0, 0);
372
  video_movecursor(0, 0);
367
  return(0);
373
  return(0);
368
}
374
}
369
 
375