Line 9... |
Line 9... |
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;
|
Line 35... |
Line 38... |
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);
|
Line 76... |
Line 79... |
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;
|
Line 99... |
Line 102... |
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);
|
Line 119... |
Line 122... |
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) {
|
Line 172... |
Line 175... |
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 |
|
Line 333... |
Line 336... |
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 |
}
|
Line 346... |
Line 349... |
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 */
|