/* Setup.Cpp */
#include "app1.h"
void mainmenu(void);
void findfile(char * fp);
void text(int flag);
void select(void);
void helpmessage(void);
void programemain(void);
void quittodos(void);
void fhd(void);
void fnf(void);
void searchDospath(void);
void searchToolspath(void);
void searchMyDospath(void);
void wautoexec(void);
void wconfig(void);
void installDos(void);
void installTools(void);
void installMyDos(void);
void enoughspace(void);
main(int argc,char * argv[]){
if(argc == 1){
initDrv();
programemain();
}
else if(argc == 2 && !strcmp(argv[1],"/v")){
textmode(C80);
textcolor(15|128);
cprintf("BootDisk");
textcolor(9);
cprintf(" Version");
textcolor(2|128);
cprintf(" 2000 ");
textcolor(9);
cprintf("by GoodJob studio\n");
int y = wherey();
gotoxy(1,y);
cprintf("Writer : Yu Sheng");
textmode(-1);
exit(1);
}
else if(argc == 2 && !strcmp(argv[1],"/?")){
printf("BootDisk Version 2000.\n");
printf("/v To see the BootDisk Version\n");
printf("/fhd To format HardDisk\n");
printf("/id To install Dos\n");
printf("/it To install Tools\n");
printf("/imd To install MyDos\n");
printf("/? To see Quick Help");
}
else if(argc == 2 && !strcmp(argv[1],"/fhd")){
fhd();
}
else if(argc == 2 && !strcmp(argv[1],"/id")){
initDrv();
installDos();
}
else if(argc == 2 && !strcmp(argv[1],"/it")){
initDrv();
installTools();
}
else if(argc == 2 && !strcmp(argv[1],"/imd")){
initDrv();
installMyDos();
}
else{
initDrv();
programemain();
}
return 0;
}
void mainmenu(void){
draw_win_3D(50,50,cwinx(50),cwiny(50),1,"BootDisk Version 2000 Install Menu",2);
textbox(55,400,585,425,7,6,"Welcome to use BootDisk Version 2000");
setcolor(5);
settextstyle(1,1,7);
outtextxy(100,100,"BootDisk");
setcolor(4);
settextstyle(5,0,5);
outtextxy(265,75,"Selected Menu");
settextstyle(0,0,1);
buttonselect(275,155,490,185,"Format HardDisk");
buttonUp(275,190,490,220,"Install Dos");
buttonUp(275,225,490,255,"Install Tools");
buttonUp(275,260,490,290,"Install My Dos");
buttonUp(275,295,490,325,"About BootDisk");
buttonUp(275,330,490,360,"Exit");
}
void text(int flag){
if(flag == 1){
textbox(55,400,585,425,7,6,"To format your HardDisk");
}
else if(flag == 2){
textbox(55,400,585,425,7,6,"To install Microsoft Dos 6.22");
}
else if(flag == 3){
textbox(55,400,585,425,7,6,"To install some tools");
}
else if(flag == 4){
textbox(55,400,585,425,7,6,"We develop some tools for MS-DOS");
}
else if(flag == 5){
textbox(55,400,585,425,7,6,"To see BootDisk about information");
}
else if(flag == 6){
textbox(55,400,585,425,7,6,"Exit to Dos");
}
}
void select(void){
int flag = 1;
int key;
char Redo = 'Y';
while(Redo == 'Y'){
Redo = 'N';
key = bioskey(0);
switch(key){
case UPKEY: if(flag == 1){
buttonUp(275,155,490,185,"Format HardDisk");
buttonselect(275,330,490,360,"Exit");
flag = 6;
Redo = 'Y';
}
else if(flag == 2){
buttonUp(275,190,490,220,"Install Dos");
buttonselect(275,155,490,185,"Format HardDisk");
flag = 1;
Redo = 'Y';
}
else if(flag == 3){
buttonUp(275,225,490,255,"Install Tools");
buttonselect(275,190,490,220,"Install Dos");
flag = 2;
Redo = 'Y';
}
else if(flag == 4){
buttonUp(275,260,490,290,"Install My Dos");
buttonselect(275,225,490,255,"Install Tools");
flag = 3;
Redo = 'Y';
}
else if(flag == 5){
buttonUp(275,295,490,325,"About BootDisk");
buttonselect(275,260,490,290,"Install My Dos");
flag = 4;
Redo = 'Y';
}
else if(flag == 6){
buttonUp(275,330,490,360,"Exit");
buttonselect(275,295,490,325,"About BootDisk");
flag = 5;
Redo = 'Y';
}
text(flag);
break;
case DOWNKEY: if(flag == 1){
buttonUp(275,155,490,185,"Format HardDisk");
buttonselect(275,190,490,220,"Install Dos");
flag = 2;
Redo = 'Y';
}
else if(flag == 2){
buttonUp(275,190,490,220,"Install Dos");
buttonselect(275,225,490,255,"Install Tools");
flag = 3;
Redo = 'Y';
}
else if(flag == 3){
buttonUp(275,225,490,255,"Install Tools");
buttonselect(275,260,490,290,"Install My Dos");
flag = 4;
Redo = 'Y';
}
else if(flag == 4){
buttonUp(275,260,490,290,"Install My Dos");
buttonselect(275,295,490,325,"About BootDisk");
flag = 5;
Redo = 'Y';
}
else if(flag == 5){
buttonUp(275,295,490,325,"About BootDisk");
buttonselect(275,330,490,360,"Exit");
flag = 6;
Redo = 'Y';
}
else if(flag == 6){
buttonUp(275,330,490,360,"Exit");
buttonselect(275,155,490,185,"Format HardDisk");
flag = 1;
Redo = 'Y';
}
text(flag);
break;
case ENTER : if(flag == 6){
quittodos();
}
else if(flag == 5){
buttonDown(275,295,490,325,"About BootDisk");
delay(150);
buttonUp(275,295,490,325,"About BootDisk");
delay(150);
helpmessage();
}
else if(flag == 1){
buttonDown(275,155,490,185,"Format HardDisk");
delay(150);
buttonUp(275,155,490,185,"Format HardDisk");
delay(150);
fhd();
}
else if(flag == 2){
buttonDown(275,190,490,220,"Install Dos");
delay(150);
buttonUp(275,190,490,220,"Install Dos");
delay(150);
installDos();
}
else if(flag == 3){
buttonDown(275,225,490,255,"Install Tools");
delay(150);
buttonUp(275,225,490,255,"Install Tools");
delay(150);
installTools();
}
else if(flag == 4){
buttonDown(275,260,490,290,"Install My Dos");
delay(150);
buttonUp(275,260,490,290,"Install My Dos");
delay(150);
installMyDos();
}
break;
case ESC : closegraph();
exit(1); break;
case F1 : helpmessage(); break;
default : Redo = 'Y';
}
}
}
void quittodos(void){
buttonDown(275,330,490,360,"Exit");
delay(150);
buttonUp(275,330,490,360,"Exit");
delay(150);
closeDrv();
exit(1);
}
void findfile(char * fp){
FILE * file;
if((file = fopen(fp,"rb")) == NULL){
draw_win_3D(200,160,450,315,1,"Error",4);
setcolor(0);
int x = ctextx(200,450,"Cannot find file");
int y = ctexty(160,315);
outtextxy(x,y - 10,"Cannot find file");
setcolor(4);
x = ctextx(200,450,fp);
outtextxy(x,y,fp);
auto_line(205,275,445,275);
buttonselect(284,285,365,306,"Continue");
getch();
buttonDown(284,285,365,305,"Continue");
delay(150);
buttonselect(284,285,365,306,"Continue");
delay(150);
programemain();
}
fclose(file);
}
void helpmessage(void){
draw_win_3D(200,160,450,315,1,"About BootDisk",2);
setcolor(0);
int x = ctextx(200,450,"BootDisk Version 2000");
outtextxy(x,200,"BootDisk Version 2000");
outtextxy(x,210," by GoodJob studio ");
outtextxy(x,220," writer Yu Sheng ");
setcolor(9);
outtextxy(x-20,245,"Email Address:");
outtextxy(x+30,255,"goldyu@online.sh.cn");
auto_line(205,275,445,275);
buttonselect(284,285,365,306,"Continue");
getch();
buttonDown(284,285,365,305,"Continue");
delay(150);
buttonselect(284,285,365,306,"Continue");
delay(150);
programemain();
}
void programemain(void){
mainmenu();
select();
}
void fnf(void){
draw_win_3D(200,160,450,315,1,"Error",4);
setcolor(0);
int x = ctextx(200,450,"Cannot find file format.com");
int y = ctexty(160,310);
outtextxy(x,y,"Cannot find file format.com");
auto_line(205,275,445,275);
buttonselect(284,285,365,306,"Continue");
getch();
buttonDown(284,285,365,305,"Continue");
delay(150);
buttonselect(284,285,365,306,"Continue");
delay(150);
programemain();
}
void fhd(void){
FILE * fp;
if((fp = fopen("Format.com","rb")) == NULL){
fnf();
}
else{
closeDrv();
system("format c:/q/u/s/v:GoodJob");
initDrv();
programemain();
}
fclose(fp);
}
void installDos(void){
draw_win_3D(150,140,500,315,1,"Install Dos",2);
int x = ctextx(160,490,"Please wait a moment.");
setcolor(0);
outtextxy(x,180,"Please wait a moment");
x = ctextx(160,490,"it will updata your computer system");
outtextxy(x,195,"it will updata your computer system");
outtextxy(163,210,"After that,it will install MS-DOS on your");
outtextxy(163,225,"computer,it takes you only a few minutes.");
setcolor(1);
enoughspace();
searchDospath();
findfile("mscdex.exe");
x = ctextx(160,490,"Source File A:\\mscdex.exe");
outtextxy(x,240,"Source File A:\\mscdex.exe");
x = ctextx(160,490,"To C:\\dos\\mscdex.exe");
outtextxy(x,250,"To C:\\dos\\mscdex.exe");
copy(175,270,475,290,1,"mscdex.exe","c:\\dos\\mscdex.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("chkdsk.exe");
x = ctextx(160,490,"Source File A:\\chkdsk.exe");
outtextxy(x,240,"Source File A:\\chkdsk.exe");
x = ctextx(160,490,"To C:\\dos\\chkdsk.exe");
outtextxy(x,250,"To C:\\dos\\chkdsk.exe");
copy(175,270,475,290,1,"chkdsk.exe","c:\\dos\\chkdsk.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("cdrom.sys");
x = ctextx(160,490,"Source File A:\\cdrom.sys");
outtextxy(x,240,"Source File A:\\cdrom.sys");
x = ctextx(160,490,"To C:\\dos\\cdrom.sys");
outtextxy(x,250,"To C:\\dos\\cdrom.sys");
copy(175,270,475,290,1,"cdrom.sys","c:\\dos\\cdrom.sys");
kill_words(170,240,480,260);
setcolor(1);
findfile("fdisk.exe");
x = ctextx(160,490,"Source File A:\\fdisk.exe");
outtextxy(x,240,"Source File A:\\fdisk.exe");
x = ctextx(160,490,"To C:\\dos\\fdisk.exe");
outtextxy(x,250,"To C:\\dos\\fdisk.exe");
copy(175,270,475,290,1,"fdisk.exe","c:\\dos\\fdisk.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("format.com");
x = ctextx(160,490,"Source File A:\\format.com");
outtextxy(x,240,"Source File A:\\format.com");
x = ctextx(160,490,"To C:\\dos\\format.com");
outtextxy(x,250,"To C:\\dos\\format.com");
copy(175,270,475,290,1,"format.com","c:\\dos\\format.com");
kill_words(170,240,480,260);
setcolor(1);
findfile("smartdrv.exe");
x = ctextx(160,490,"Source File A:\\smartdrv.exe");
outtextxy(x,240,"Source File A:\\smartdrv.exe");
x = ctextx(160,490,"To C:\\dos\\smartdrv.exe");
outtextxy(x,250,"To C:\\dos\\smartdrv.exe");
copy(175,270,475,290,1,"smartdrv.exe","c:\\dos\\smartdrv.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("hdformat.exe");
x = ctextx(160,490,"Source File A:\\hdformat.exe");
outtextxy(x,240,"Source File A:\\hdformat.exe");
x = ctextx(160,490,"To C:\\dos\\hdformat.exe");
outtextxy(x,250,"To C:\\dos\\hdformat.exe");
copy(175,270,475,290,1,"hdformat.exe","c:\\dos\\hdformat.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("deltree.exe");
x = ctextx(160,490,"Source File A:\\deltree.exe");
outtextxy(x,240,"Source File A:\\deltree.exe");
x = ctextx(160,490,"To C:\\dos\\deltree.exe");
outtextxy(x,250,"To C:\\dos\\deltree.exe");
copy(175,270,475,290,1,"deltree.exe","c:\\dos\\deltree.exe");
kill_words(170,240,480,260);
setcolor(1);
findfile("himem.sys");
x = ctextx(160,490,"Source File A:\\himem.sys");
outtextxy(x,240,"Source File A:\\himem.sys");
x = ctextx(160,490,"To C:\\dos\\himem.sys");
outtextxy(x,250,"To C:\\dos\\himem.sys");
copy(175,270,475,290,1,"himem.sys","c:\\dos\\himem.sys");
kill_words(170,240,480,260);
setcolor(1);
findfile("sys.com");
x = ctextx(160,490,"Source File A:\\sys.com");
outtextxy(x,240,"Source File A:\\sys.com");
x = ctextx(160,490,"To C:\\dos\\sys.com");
outtextxy(x,250,"To C:\\dos\\sys.com");
copy(175,270,475,290,1,"sys.com","c:\\dos\\sys.com");
kill_words(170,240,480,260);
setcolor(1);
findfile("dos.exe");
x = ctextx(160,490,"Source File A:\\dos.exe");
outtextxy(x,240,"Source File A:\\dos.exe");
x = ctextx(160,490,"To C:\\dos\\dos.exe");
outtextxy(x,250,"To C:\\dos\\dos.exe");
copy(175,270,475,290,1,"dos.exe","c:\\dos\\dos.exe");
kill_words(170,240,480,260);
setcolor(1);
x = ctextx(160,490,"Decompression Files");
outtextxy(x,245,"Decompression Files");
system("c:");
system("cd\\dos");
system("dos > NUL");
unlink("dos.exe");
system("a:");
kill_words(170,240,480,260);
setcolor(1);
x = ctextx(160,490,"Write autoexec.bat");
outtextxy(x,245,"Write autoexec.bat");
wautoexec();
delay(250);
kill_words(170,240,480,260);
setcolor(1);
x = ctextx(160,490,"Write config.sys");
outtextxy(x,245,"Write config.sys");
wconfig();
delay(250);
programemain();
}
void installTools(void){
draw_win_3D(150,140,500,315,1,"Install Dos",2);
int x = ctextx(160,490,"Please wait a moment.");
setcolor(0);
outtextxy(x,180,"Please wait a moment");
x = ctextx(160,490,"it will updata your computer system");
outtextxy(x,195,"it will updata your computer system");
outtextxy(163,210,"After that,it will install Tools on your");
outtextxy(163,225,"computer,it takes you only a few minutes.");
setcolor(1);
enoughspace();
searchToolspath();
findfile("Tools.exe");
x = ctextx(160,490,"Source File A:\\Tools.exe");
outtextxy(x,240,"Source File A:\\Tools.exe");
x = ctextx(160,490,"To C:\\tools\\Tools.exe");
outtextxy(x,250,"To C:\\tools\\Tools.exe");
copy(175,270,475,290,1,"tools.exe","c:\\tools\\tools.exe");
kill_words(170,240,480,260);
setcolor(1);
x = ctextx(160,490,"Decompression Files");
outtextxy(x,245,"Decompression Files");
system("c:");
system("cd\\tools");
system("tools > NUL");
unlink("tools.exe");
system("a:");
programemain();
}