Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 66 → Rev 67

/install/install.c
18,6 → 18,9
#include "input.h"
#include "video.h"
 
/* keyboard layouts and locales */
#include "keylay.h"
#include "keyoff.h"
 
/* color scheme (color, mono) */
static unsigned short COLOR_TITLEBAR[2] = {0x7000,0x7000};
31,7 → 34,20
/* how much disk space does Svarog386 require (in MiB) */
#define SVAROG_DISK_REQ 8
 
/* a convenience 'function' used for debugging */
#define DBG(x) { video_putstringfix(24, 0, 0x4F00u, x, 80); }
 
struct slocales {
char lang[4];
char *keybcode;
unsigned int codepage;
int egafile;
int keybfile;
int keyboff;
int keyblen;
};
 
 
/* reboot the computer */
static void reboot(void) {
void ((far *bootroutine)()) = (void (far *)()) 0xFFFF0000L;
77,30 → 93,10
}
 
 
#define LDEC(x,y) (((unsigned short)x << 8) | (unsigned short)y)
/* provides codepage and country files required by lang */
static int getnlscp(char *lang, int *egafile) {
unsigned short l;
l = lang[0];
l <<= 8;
l |= lang[1];
switch (l) {
case LDEC('E','N'):
*egafile = 0;
return(437);
case LDEC('P','L'):
*egafile = 10;
return(991);
}
*egafile = 0;
return(437);
}
 
 
static int menuselect(int ypos, int xpos, int height, char **list) {
static int menuselect(int ypos, int xpos, int height, char **list, int listlen) {
int i, offset = 0, res = 0, count, width = 0;
/* count how many languages there is */
for (count = 0; list[count] != NULL; count++) {
/* count how many positions there is, and check their width */
for (count = 0; (list[count] != NULL) && (count != listlen); count++) {
int len = strlen(list[count]);
if (len > width) width = len;
}
173,16 → 169,14
video_movecursor(25,0);
}
 
static int selectlang(char *lang) {
int choice;
int x;
static int selectlang(struct slocales *locales) {
int choice, x;
char *msg;
char *code;
char *langlist[] = {
"English\0EN",
/* "French\0FR",*/
"Polish\0PL",
/* "Turkish\0TR",*/
"English",
"French",
"Polish",
"Turkish",
NULL
};
 
192,16 → 186,81
video_putstring(4, x, COLOR_BODY[mono], msg, -1);
video_putcharmulti(5, x, COLOR_BODY[mono], '=', strlen(msg), 1);
putstringnls(8, -1, COLOR_BODY[mono], 1, 1, "Please select your language from the list below:");
choice = menuselect(11, -1, 3, langlist);
choice = menuselect(11, -1, 6, langlist, -1);
if (choice < 0) return(-1);
/* write short language code into lang */
for (code = langlist[choice]; *code != 0; code++);
memcpy(lang, code + 1, 2);
lang[2] = 0;
/* populate locales with default values */
memset(locales, 0, sizeof(struct slocales));
switch (choice) {
case 1:
strcpy(locales->lang, "FR");
locales->keyboff = OFFLOC_FR;
locales->keyblen = OFFLEN_FR;
break;
case 2:
strcpy(locales->lang, "PL");
locales->keyboff = OFFLOC_PL;
locales->keyblen = OFFLEN_PL;
break;
case 3:
strcpy(locales->lang, "TR");
locales->keyboff = OFFLOC_TR;
locales->keyblen = OFFLEN_TR;
break;
default:
strcpy(locales->lang, "EN");
locales->keyboff = 0;
locales->keyblen = OFFCOUNT;
break;
}
/* populate the slocales struct */
for (msg = kblayouts[locales->keyboff]; *msg != 0; msg++); /* skip layout name */
msg++;
/* skip keyb code and copy it to locales.keybcode */
locales->keybcode = msg;
for (; *msg != 0; msg++);
/* */
locales->codepage = ((unsigned short)msg[1] << 8) | msg[2];
locales->egafile = msg[3];
locales->keybfile = msg[4];
/* */
return(0);
}
 
 
#define LTODEC(x, y) ((unsigned short)(x << 8) | (y))
static int selectkeyb(struct slocales *locales) {
int keyboff, keyblen, menuheight;
unsigned short lang;
lang = LTODEC(locales->lang[0], locales->lang[1]);
 
switch (lang) {
case LTODEC('F', 'R'):
keyboff = OFFLOC_FR;
keyblen = OFFLEN_FR;
break;
case LTODEC('P', 'L'):
keyboff = OFFLOC_PL;
keyblen = OFFLEN_PL;
break;
case LTODEC('T', 'R'):
keyboff = OFFLOC_TR;
keyblen = OFFLEN_TR;
break;
default: /* otherwise propose all possible keyoard layouts */
keyboff = 0;
keyblen = OFFCOUNT;
break;
}
if (keyblen == 1) return(0); /* do not ask for keyboard layout if only one is available for given language */
newscreen();
putstringnls(5, 1, COLOR_BODY[mono], 1, 5, "Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.");
menuheight = keyblen + 2;
if (menuheight > 13) menuheight = 13;
if (menuselect(10, -1, menuheight, &(kblayouts[keyboff]), keyblen) < 0) return(-1);
return(0);
}
 
 
/* returns 0 if installation must proceed, non-zero otherwise */
static int welcomescreen(void) {
char *choice[] = {"Install Svarog386 to disk", "Quit to DOS", NULL};
209,7 → 268,7
choice[1] = kittengets(0, 2, choice[1]);
newscreen();
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.");
return(menuselect(13, -1, 4, choice));
return(menuselect(13, -1, 4, choice, -1));
}
 
 
277,7 → 336,7
list[2] = kittengets(0, 2, list[2]);
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);
putstringwrap(4, 1, COLOR_BODY[mono], buff);
switch (menuselect(14, -1, 5, list)) {
switch (menuselect(14, -1, 5, list, -1)) {
case 0:
system("FDISK /AUTO");
break;
311,7 → 370,7
list[1] = kittengets(0, 2, list[1]);
snprintf(buff, sizeof(buff), kittengets(3, 3, "ERROR: Drive %c: seems to be unformated. Do you wish to format it?"), cselecteddrive);
video_putstring(7, 1, COLOR_BODY[mono], buff, -1);
if (menuselect(12, -1, 4, list) != 0) return(-1);
if (menuselect(12, -1, 4, list, -1) != 0) return(-1);
video_clear(0x0700, 0);
video_movecursor(0, 0);
snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
336,7 → 395,7
list[1] = kittengets(0, 2, list[1]);
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);
y += putstringwrap(y, 1, COLOR_BODY[mono], buff);
if (menuselect(++y, -1, 4, list) != 0) return(-1);
if (menuselect(++y, -1, 4, list, -1) != 0) return(-1);
video_clear(0x0700, 0);
video_movecursor(0, 0);
snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVAROG386", cselecteddrive);
349,7 → 408,7
list[1] = kittengets(0, 2, list[1]);
snprintf(buff, sizeof(buff), kittengets(3, 6, "The installation of Svarog386 to %c: is about to begin."), cselecteddrive);
video_putstring(7, -1, COLOR_BODY[mono], buff, -1);
if (menuselect(10, -1, 4, list) != 0) return(-1);
if (menuselect(10, -1, 4, list, -1) != 0) return(-1);
snprintf(buff, sizeof(buff), "SYS A: %c: > NUL", cselecteddrive);
system(buff);
snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
384,11 → 443,9
}
 
 
static void bootfilesgen(int targetdrv, char *lang, int cdromdrv) {
static void bootfilesgen(int targetdrv, struct slocales *locales, int cdromdrv) {
char buff[128];
int cp, egafile;
FILE *fd;
cp = getnlscp(lang, &egafile);
/*** CONFIG.SYS ***/
snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", targetdrv);
fd = fopen(buff, "wb");
408,7 → 465,7
fprintf(fd, "SET TEMP=%c:\\TEMP\r\n", targetdrv);
fprintf(fd, "SET DOSDIR=%c:\\SYSTEM\\SVAROG.386\r\n", targetdrv);
fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
fprintf(fd, "SET LANG=%s\r\n", lang);
fprintf(fd, "SET LANG=%s\r\n", locales->lang);
fprintf(fd, "SET DIRCMD=/OGNE/P/4\r\n");
fprintf(fd, "SET FDNPKG.CFG=%c:\\SYSTEM\\CFG\\FDNPKG.CFG\r\n", targetdrv);
fprintf(fd, "SET WATTCP.CFG=%c:\\SYSTEM\\CFG\\WATTCP.CFG\r\n", targetdrv);
418,14 → 475,19
fprintf(fd, "ALIAS HALT=FDAPM POWEROFF\r\n");
fprintf(fd, "FDAPM APMDOS\r\n");
fprintf(fd, "\r\n");
if (egafile > 0) {
if (locales->egafile > 0) {
fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
if (egafile == 1) {
fprintf(fd, "MODE CON CP PREPARE=((%d) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA.CPX)\r\n", cp, targetdrv);
if (locales->egafile == 1) {
fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA.CPX)\r\n", locales->codepage, targetdrv);
} else {
fprintf(fd, "MODE CON CP PREPARE=((%d) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA%d.CPX)\r\n", cp, targetdrv, egafile);
fprintf(fd, "MODE CON CP PREPARE=((%u) %c:\\SYSTEM\\SVAROG.386\\CPI\\EGA%d.CPX)\r\n", locales->codepage, targetdrv, locales->egafile);
}
fprintf(fd, "MODE CON CP SELECT=%d\r\n", cp);
fprintf(fd, "MODE CON CP SELECT=%u\r\n", locales->codepage);
if (locales->keybfile == 1) {
fprintf(fd, "KEYB %s,%d,%c:\\SYSTEM\\SVAROG.386\\BIN\\KEYBOARD.SYS\r\n", locales->keybcode, locales->codepage, targetdrv);
} else {
fprintf(fd, "KEYB %s,%d,%c:\\SYSTEM\\SVAROG.386\\BIN\\KEYBRD%d.SYS\r\n", locales->keybcode, locales->codepage, targetdrv, locales->keybfile);
}
fprintf(fd, "\r\n");
}
fprintf(fd, "SHSUCDX /d:SVCD0001\r\n");
540,19 → 602,17
}
 
 
static void loadcp(char *lang) {
int cp, egafile;
static void loadcp(struct slocales *locales) {
char buff[64];
cp = getnlscp(lang, &egafile);
if (cp == 437) return;
if (locales->codepage == 437) return;
video_movecursor(1, 0);
if (egafile == 1) {
snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%d) A:\\EGA.CPX) > NUL", cp);
if (locales->egafile == 1) {
snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA.CPX) > NUL", locales->codepage);
} else {
snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%d) A:\\EGA%d.CPX) > NUL", cp, egafile);
snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
}
system(buff);
snprintf(buff, sizeof(buff), "MODE CON CP SEL=%d > NUL", cp);
snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
system(buff);
/* below I re-init the video controller - apparently this is required if
* I want the new glyph symbols to be actually applied, at least some
570,7 → 630,7
 
/* checks CD drive drv for the presence of the Svarog386 install CD
* returns 0 if found, non-zero otherwise */
static int checkcd(char drv) {
/*static int checkcd(char drv) {
FILE *fd;
char fname[32];
snprintf(fname, sizeof(fname), "%c:\\CORE\\MEM.ZIP", drv);
578,11 → 638,11
if (fd == NULL) return(-1);
fclose(fd);
return(0);
}
}*/
 
 
int main(void) {
char lang[4];
struct slocales locales;
int targetdrv;
int cdromdrv;
 
593,10 → 653,10
return(1);
}
cdromdrv += 'A'; /* convert the cdrom 'id' (A=0) to an actual drive letter */
if (checkcd(cdromdrv) != 0) {
/*if (checkcd(cdromdrv) != 0) {
printf("ERROR: SVAROG386 INSTALLATION CD NOT FOUND IN THE DRIVE.\r\n");
return(1);
}
}*/
 
/* init screen and detect mono status */
mono = video_init();
603,18 → 663,18
 
for (;;) { /* fake loop, it's here just to break out easily */
kittenopen("INSTALL"); /* NLS support */
if (selectlang(lang) < 0) break; /* welcome to svarog, select your language */
setenv("LANG", lang, 1);
loadcp(lang);
if (selectlang(&locales) < 0) break; /* welcome to svarog, select your language */
setenv("LANG", locales.lang, 1);
loadcp(&locales);
kittenclose(); /* reload NLS with new language */
kittenopen("INSTALL"); /* NLS support */
/*selectkeyb();*/ /* what keyb layout should we use? */
if (selectkeyb(&locales) != 0) break; /* what keyb layout should we use? */
if (welcomescreen() != 0) break; /* what svarog386 is, ask whether to run live dos or install */
targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
if (targetdrv < 0) break;
/*askaboutsources();*/ /* IF sources are available, ask if installing with them */
installpackages(targetdrv, cdromdrv); /* install packages */
bootfilesgen(targetdrv, lang, cdromdrv); /* generate boot files and other configurations */
bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
/*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
/*netcfg();*/ /* basic networking config */
finalreboot(); /* remove the CD and reboot */
/install/keylay.h
0,0 → 1,17
char *kblayouts[] = {
/****** EN ******/
"English (US)\0en\0\1\265\0\0",
"English (UK)\0uk\0\1\265\0\1",
/****** FR ******/
"French (France)\0fr\0\3\132\1\1",
"French (Canada, standard)\0cf\0\3\137\11\1",
"French (Canada, legacy)\0cf501\0\3\137\11\1",
/****** DE ******/
"German\0de\0\3\132\1\1",
/****** PL ******/
"Polish\0pl\0\3\337\12\1",
/****** ES ******/
"Spanish\0es\0\3\132\1\1",
/****** TR ******/
"Turkish\0tr\0\3\131\1\2",
NULL};
/install/keyoff.h
0,0 → 1,13
#define OFFLOC_EN 0
#define OFFLEN_EN 2
#define OFFLOC_FR 2
#define OFFLEN_FR 3
#define OFFLOC_DE 5
#define OFFLEN_DE 1
#define OFFLOC_PL 6
#define OFFLEN_PL 1
#define OFFLOC_ES 7
#define OFFLEN_ES 1
#define OFFLOC_TR 8
#define OFFLEN_TR 1
#define OFFCOUNT 9
/install/locales.c
0,0 → 1,110
/*
* This program creates a header file for the Svarog386 installer, that
* contains the list of all supported keyboard layouts, along with a way to
* select sets of keyboard layouts that apply to only a specific region.
*
* Copyright (C) 2016 Mateusz Viste
*/
 
/* the kblayouts list is a NULL-terminated array that contains entries in the
* following format:
* human description string <0> layout code string <0> <codepage number as a 16bit value> <ega.sys file number as a single byte> <keyboard.sys file number as a single byte>
 
char *kblayouts[] = {
"English (US)\0xxxx",
"Polish\0pl\0xxxx"};
};
*/
 
 
#include <stdio.h>
#include <string.h>
 
 
/* global file pointers */
FILE *fdkeyb, *fdoff;
 
 
/* Converts a positive base_10 into base_8 */
static unsigned int dec2oct(int n) {
int res=0, digitPos=1;
while (n) {
res += (n & 7) * digitPos;
n >>= 3;
digitPos *= 10;
}
return(res);
}
 
 
static void addnew(char *countrycode, char *humanlang, char *keybcode, unsigned short cp, unsigned char egafile, unsigned char keybfile) {
static char lastcountry[4] = {0};
static int curoffset = 0, curcountryoffset = 0;
/* if new country, declare an offset */
if (strcmp(countrycode, lastcountry) != 0) {
/* close previous one, if any */
if (lastcountry[0] != 0) {
fprintf(fdoff, "#define OFFLEN_%s %d\r\n", lastcountry, curoffset - curcountryoffset);
} else {
fprintf(fdkeyb, "char *kblayouts[] = {\r\n");
}
/* open new one, if any */
if (countrycode[0] != 0) {
fprintf(fdkeyb, " /****** %s ******/\r\n", countrycode);
curcountryoffset = curoffset;
fprintf(fdoff, "#define OFFLOC_%s %d\r\n", countrycode, curoffset);
strcpy(lastcountry, countrycode);
} else {
fprintf(fdoff, "#define OFFCOUNT %d\r\n", curoffset);
}
}
/* */
if (countrycode[0] != 0) {
fprintf(fdkeyb, " \"%s\\0%s\\0\\%d\\%d\\%d\\%d\",\r\n", humanlang, keybcode, dec2oct(cp >> 8), dec2oct(cp & 0xff), dec2oct(egafile), dec2oct(keybfile));
} else {
fprintf(fdkeyb, " NULL};\r\n");
}
curoffset++;
}
 
 
int main(void) {
 
/*** open files ***/
fdkeyb = fopen("keylay.h", "wb");
fdoff = fopen("keyoff.h", "wb");
 
/******************* LAYOUTS LIST START *******************/
 
/* English */
addnew("EN", "English (US)", "en", 437, 0, 0);
addnew("EN", "English (UK)", "uk", 437, 0, 1);
 
/* French */
addnew("FR", "French (France)", "fr", 858, 1, 1);
addnew("FR", "French (Canada, standard)", "cf", 863, 9, 1);
addnew("FR", "French (Canada, legacy)", "cf501", 863, 9, 1);
 
/* German */
addnew("DE", "German", "de", 858, 1, 1);
 
/* Polish */
addnew("PL", "Polish", "pl", 991, 10, 1);
 
/* Spanish */
addnew("ES", "Spanish", "es", 858, 1, 1);
 
/* Turkish */
addnew("TR", "Turkish", "tr", 857, 1, 2);
 
/******************* LAYOUTS LIST STOP *******************/
 
/* end of list - DO NOT REMOVE */
addnew("", "", "", 0, 0, 0);
 
/* close files */
fclose(fdoff);
fclose(fdkeyb);
 
return(0);
}
/install/makefile
9,10 → 9,17
 
all: install.com
 
install.com: install.c cdrom.c input.c video.c
install.com: keylay.h install.c cdrom.c input.c video.c
wcl -0 -y -cc -wx -mt -lr -we -d0 -ox install.c cdrom.c input.c video.c kitten\kitten.c
upx --8086 -9 install.com
 
locales.exe: locales.c
wcl -0 -y -cc -wx -ml -lr -we -d0 -ox locales.c
 
keylay.h: locales.exe
locales.exe
 
clean: .SYMBOLIC
del install.com
del locales.exe
del *.obj
/install/nls/install.en
14,9 → 14,10
0.5:Press any key...
0.6:Proceed with formatting
 
### LANGUAGE SELECTION SCREEN ###
### LANGUAGE SELECTION & KEYBOARD LAYOUT SCREENS ###
1.0:Welcome to Svarog386
1.1:Please select your language from the list below:
1.5:Svarog386 supports the keyboard layouts used in different countries. Choose the keyboard layout you want.
 
### WELCOME SCREEN ###
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.
/install/nls/install.pl
14,9 → 14,10
0.5:Nacižnij dowolny klawisz...
0.6:Formatuj
 
### LANGUAGE SELECTION SCREEN ###
### LANGUAGE SELECTION & KEYBOARD LAYOUT SCREENS ###
1.0:Witaj w systemie Svarog386
1.1:Wybierz sw¢j j‘zyk z poni§szej listy:
1.5:Svarog386 wspiera uk’ady klawiatur wspierane w r¢§nych krajach. Wybierz uk’ad klawiatury kt¢ry ci odpowiada.
 
### WELCOME SCREEN ###
2.0:Za chwil‘ rozpocznie si‘ instalacja systemu Svarog386: bezp’atnego systemu operacyjnego opartego na j†drze FreeDOS, i kompatybilnego z MSDOS. Svarog386 jest przeznaczony dla komputer¢w klasy 386 wzwy§, i zawiera mn¢stwo aplikacji dodatkowych.\n\nUWAGA: Ježli tw¢j komputer posiada ju§ inny system operacyjny, system ten mo§e nie zdo’a si‘ uruchomi po instalacji Svarog386.