diff options
Diffstat (limited to 'engines/avalanche/bootstrp.cpp')
-rw-r--r-- | engines/avalanche/bootstrp.cpp | 503 |
1 files changed, 265 insertions, 238 deletions
diff --git a/engines/avalanche/bootstrp.cpp b/engines/avalanche/bootstrp.cpp index 905944796a..add361327a 100644 --- a/engines/avalanche/bootstrp.cpp +++ b/engines/avalanche/bootstrp.cpp @@ -11,7 +11,7 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License @@ -39,21 +39,23 @@ const integer run_dosshell = 2; const integer run_ghostroom = 3; const integer run_golden = 4; -const array<false,true,varying_string<2> > runcodes = {{"et","Go"}}; +const array<false, true, varying_string<2> > runcodes = {{"et", "Go"}}; const integer reset_ = 0; -const boolean jsb = true; const boolean no_jsb = false; -const boolean bflight = true; const boolean no_bflight = false; +const boolean jsb = true; +const boolean no_jsb = false; +const boolean bflight = true; +const boolean no_bflight = false; struct { - byte operation; - word skellern; - array<1,10000,byte> contents; + byte operation; + word skellern; + array<1, 10000, byte> contents; } storage; -string arguments,demo_args,args_with_no_filename; +string arguments, demo_args, args_with_no_filename; boolean first_time; @@ -64,314 +66,339 @@ string segofs; boolean zoomy; -longint soundcard,speed,baseaddr,irq,dma; +longint soundcard, speed, baseaddr, irq, dma; -void cursor_off() /*assembler; */ -{; -/* asm - mov ah,01; { Change cursor size. */ -/* mov cx,8224; { CH & CL are now 32. */ -/* int $10; { Call the Bios */ +void cursor_off() { /*assembler; */ + ; + /* asm + mov ah,01; { Change cursor size. */ + /* mov cx,8224; { CH & CL are now 32. */ + /* int $10; { Call the Bios */ } /* That's all. */ -void cursor_on() /*assembler; */ -{; -/* -asm - mov ah,01; { Change cursor size. */ -/* mov ch,5; { Top line is 5. */ -/* mov cl,7; { Bottom line is 7. */ -/* int $10; { Call the Bios. */ +void cursor_on() { /*assembler; */ + ; + /* + asm + mov ah,01; { Change cursor size. */ + /* mov ch,5; { Top line is 5. */ + /* mov cl,7; { Bottom line is 7. */ + /* int $10; { Call the Bios. */ } -void quit() -{ - cursor_on(); - exit(0); +void quit() { + cursor_on(); + exit(0); } -string strf(longint x) -{ - string q; -string strf_result; -; - str(x,q); strf_result=q; -return strf_result; +string strf(longint x) { + string q; + string strf_result; + ; + str(x, q); + strf_result = q; + return strf_result; } -string command_com() -{ - string temp; +string command_com() { + string temp; - string command_com_result; - temp=getenv("comspec"); - if (temp=="") - output << "avvy_bootstrap: COMSPEC not defined, => cannot run Dos shell." << NL; - command_com_result=temp; - return command_com_result; + string command_com_result; + temp = getenv("comspec"); + if (temp == "") + output << "avvy_bootstrap: COMSPEC not defined, => cannot run Dos shell." << NL; + command_com_result = temp; + return command_com_result; } -void explain(byte error) -{ - output << " ("; - switch (error) { - case 2: output << "it's not there"; break; - case 8: output << "out of memory"; break; - default: output << "error " << error; - } - output << ")." << NL; +void explain(byte error) { + output << " ("; + switch (error) { + case 2: + output << "it's not there"; + break; + case 8: + output << "out of memory"; + break; + default: + output << "error " << error; + } + output << ")." << NL; } /*$F+*/ -void b_flight() /*interrupt;*/ -{ - storage.skellern += 1; +void b_flight() { /*interrupt;*/ + storage.skellern += 1; } /*$F-*/ -void bflight_on() -{ - storage.skellern=reset_; - setintvec(0x1c,&b_flight); +void bflight_on() { + storage.skellern = reset_; + setintvec(0x1c, &b_flight); } -void bflight_off() -{ - setintvec(0x1c,old_1c); +void bflight_off() { + setintvec(0x1c, old_1c); } -void run(string what, boolean with_jsb,boolean with_bflight, elm how); - - -static string elm2str(elm how) -{ - string elm2str_result; - switch (how) { - case normal: case musical: elm2str_result="jsb"; break; - case regi: elm2str_result="REGI"; break; - case elmpoyten: elm2str_result="ELMPOYTEN"; break; - } - return elm2str_result; +void run(string what, boolean with_jsb, boolean with_bflight, elm how); + + +static string elm2str(elm how) { + string elm2str_result; + switch (how) { + case normal: + case musical: + elm2str_result = "jsb"; + break; + case regi: + elm2str_result = "REGI"; + break; + case elmpoyten: + elm2str_result = "ELMPOYTEN"; + break; + } + return elm2str_result; } -void run(string what, boolean with_jsb,boolean with_bflight, elm how) -{ - string which_dir,args; - integer error; +void run(string what, boolean with_jsb, boolean with_bflight, elm how) { + string which_dir, args; + integer error; - if (what=="") return; + if (what == "") return; - getdir(0,which_dir); + getdir(0, which_dir); - if (with_jsb) - { - if (how==musical) - args=elm2str(how)+' '+args_with_no_filename; /* FN is NOT given if musical*/ - else - args=elm2str(how)+' '+arguments; - } else args=""; + if (with_jsb) { + if (how == musical) + args = elm2str(how) + ' ' + args_with_no_filename; /* FN is NOT given if musical*/ + else + args = elm2str(how) + ' ' + arguments; + } else args = ""; - if (how==musical) args=args+strf(soundcard)+' '+strf(speed)+' '+ - strf(baseaddr)+' '+strf(dma)+' '+strf(irq); - if (with_bflight) bflight_on(); + if (how == musical) args = args + strf(soundcard) + ' ' + strf(speed) + ' ' + + strf(baseaddr) + ' ' + strf(dma) + ' ' + strf(irq); + if (with_bflight) bflight_on(); - swapvectors; - exec(what,args); - swapvectors; - cursor_off(); + swapvectors; + exec(what, args); + swapvectors; + cursor_off(); - error=doserror; + error = doserror; - if (with_bflight) bflight_off(); + if (with_bflight) bflight_off(); - chdir(which_dir); + chdir(which_dir); - if (error!=0) - { - output << "avvy_bootstrap: cannot execute " << what << '!'; - explain(error); - output << "Press Enter:"; input >> NL; quit(); - } + if (error != 0) { + output << "avvy_bootstrap: cannot execute " << what << '!'; + explain(error); + output << "Press Enter:"; + input >> NL; + quit(); + } } -void run_avalot() -{ - integer error; +void run_avalot() { + integer error; - bflight_on(); + bflight_on(); - swapvectors; - exec("avalot.avx",runcodes[first_time]+arguments); - swapvectors; + swapvectors; + exec("avalot.avx", runcodes[first_time] + arguments); + swapvectors; - error=doserror; + error = doserror; - bflight_off(); + bflight_off(); - if (error!=0) - { - output << "avvy_bootstrap: error in loading AVALOT.AVX!"; - explain(error); - quit(); - } + if (error != 0) { + output << "avvy_bootstrap: error in loading AVALOT.AVX!"; + explain(error); + quit(); + } - first_time=false; + first_time = false; } -void run_the_demo() -{ - string args; +void run_the_demo() { + string args; - args=arguments; - arguments=demo_args; /* Force the demo. */ + args = arguments; + arguments = demo_args; /* Force the demo. */ - run_avalot(); + run_avalot(); - arguments=args; /* Put all back to normal again. */ - first_time=true; + arguments = args; /* Put all back to normal again. */ + first_time = true; } -void get_arguments() -{ - byte fv; +void get_arguments() { + byte fv; - arguments=""; + arguments = ""; - for( fv=1; fv <= paramcount; fv ++) - arguments=arguments+paramstr(fv)+' '; + for (fv = 1; fv <= paramcount; fv ++) + arguments = arguments + paramstr(fv) + ' '; - arguments[0] -= 1; /* Get rid of the trailing space. */ + arguments[0] -= 1; /* Get rid of the trailing space. */ - segofs=string(' ')+strf(seg(storage))+' '+strf(ofs(storage)); + segofs = string(' ') + strf(seg(storage)) + ' ' + strf(ofs(storage)); - arguments=segofs+' '+arguments; + arguments = segofs + ' ' + arguments; } -void dos_shell() -{ - registers r; +void dos_shell() { + registers r; - r.ax=original_mode; intr(0x10,r); - output << NL; - output << "The Avalot Dos Shell." << NL; - output << "---------------------" << NL; - output << NL; - output << "Type EXIT to return to Avalot." << NL; - output << NL; + r.ax = original_mode; + intr(0x10, r); + output << NL; + output << "The Avalot Dos Shell." << NL; + output << "---------------------" << NL; + output << NL; + output << "Type EXIT to return to Avalot." << NL; + output << NL; - cursor_on(); - run(command_com(),no_jsb,no_bflight,normal); - cursor_off(); + cursor_on(); + run(command_com(), no_jsb, no_bflight, normal); + cursor_off(); - output << "Please wait, restoring your game..." << NL; + output << "Please wait, restoring your game..." << NL; } boolean keypressed1() { - registers r; + registers r; - boolean keypressed1_result; - r.ah=0xb; - msdos(r); - keypressed1_result=r.al==0xff; - return keypressed1_result; - } + boolean keypressed1_result; + r.ah = 0xb; + msdos(r); + keypressed1_result = r.al == 0xff; + return keypressed1_result; +} void flush_buffer() { - registers r; r.ah=7; - while (keypressed1()) msdos(r); } + registers r; + r.ah = 7; + while (keypressed1()) msdos(r); +} -void demo() -{ - run_the_demo(); if (keypressed1()) return; - run("intro.avx",jsb,bflight,musical); if (keypressed1()) return; - run("stars.avx",jsb,no_bflight,musical); if (keypressed1()) return; +void demo() { + run_the_demo(); + if (keypressed1()) return; + run("intro.avx", jsb, bflight, musical); + if (keypressed1()) return; + run("stars.avx", jsb, no_bflight, musical); + if (keypressed1()) return; - flush_buffer(); + flush_buffer(); } -void call_menu() -{ - run("stars.avx",jsb,no_bflight,musical); - flush_buffer(); - do { - run("avmenu.avx",jsb,no_bflight,normal); - - switch (storage.operation) { - case 1: return; break; /* Play the game. */ - case 2: run("intro.avx",jsb,bflight,musical); break; - case 3: run("preview1.avd",jsb,no_bflight,normal); break; - case 4: run("viewdocs.avx",jsb,bflight,elmpoyten); break; - case 5: run("viewdocs.avx",jsb,bflight,regi); break; - case 6: quit(); break; - case 177: demo(); break; - } - - flush_buffer(); - } while (!false); +void call_menu() { + run("stars.avx", jsb, no_bflight, musical); + flush_buffer(); + do { + run("avmenu.avx", jsb, no_bflight, normal); + + switch (storage.operation) { + case 1: + return; + break; /* Play the game. */ + case 2: + run("intro.avx", jsb, bflight, musical); + break; + case 3: + run("preview1.avd", jsb, no_bflight, normal); + break; + case 4: + run("viewdocs.avx", jsb, bflight, elmpoyten); + break; + case 5: + run("viewdocs.avx", jsb, bflight, regi); + break; + case 6: + quit(); + break; + case 177: + demo(); + break; + } + + flush_buffer(); + } while (!false); } -void get_slope() -{ - run("slope.avx",jsb,no_bflight,normal); - if (dosexitcode!=0) - { - cursor_on(); - exit(0); - } - - move(storage.contents,arguments,sizeof(arguments)); - move(storage.contents[4998],soundcard,4); - move(storage.contents[5002],baseaddr,4); - move(storage.contents[5006],irq,4); - move(storage.contents[5010],dma,4); - move(storage.contents[5014],speed,4); - - zoomy=(arguments[8]=='y') || (arguments[2]=='y'); - demo_args=arguments; demo_args[7]='y'; - arguments=segofs+' '+arguments; - demo_args=segofs+' '+demo_args; - - args_with_no_filename=arguments; - if (arguments[length(arguments)]!=' ') - { /* Filename was given */ - args_with_no_filename=arguments; - while ((args_with_no_filename!="") - && (args_with_no_filename[length(args_with_no_filename)]!=' ')) - args_with_no_filename[0] -= 1; /* Strip off the filename. */ - } +void get_slope() { + run("slope.avx", jsb, no_bflight, normal); + if (dosexitcode != 0) { + cursor_on(); + exit(0); + } + + move(storage.contents, arguments, sizeof(arguments)); + move(storage.contents[4998], soundcard, 4); + move(storage.contents[5002], baseaddr, 4); + move(storage.contents[5006], irq, 4); + move(storage.contents[5010], dma, 4); + move(storage.contents[5014], speed, 4); + + zoomy = (arguments[8] == 'y') || (arguments[2] == 'y'); + demo_args = arguments; + demo_args[7] = 'y'; + arguments = segofs + ' ' + arguments; + demo_args = segofs + ' ' + demo_args; + + args_with_no_filename = arguments; + if (arguments[length(arguments)] != ' ') { + /* Filename was given */ + args_with_no_filename = arguments; + while ((args_with_no_filename != "") + && (args_with_no_filename[length(args_with_no_filename)] != ' ')) + args_with_no_filename[0] -= 1; /* Strip off the filename. */ + } } -int main(int argc, const char* argv[]) -{ - pio_initialize(argc, argv); - original_mode=mem[seg0040*0x49]; getintvec(0x1c,old_1c); - first_time=true; cursor_off(); - - get_arguments(); - get_slope(); - - if (! zoomy) call_menu(); /* Not run when zoomy. */ - - do { - run_avalot(); - - if (dosexitcode!=77) quit(); /* Didn't stop for us. */ - - switch (storage.operation) { - case run_shootemup: run("seu.avx",jsb,bflight,normal); break; - case run_dosshell: dos_shell(); break; - case run_ghostroom: run("g-room.avx",jsb,no_bflight,normal); break; - case run_golden: run("golden.avx",jsb,bflight,musical); break; - } - - } while (!false); - return EXIT_SUCCESS; +int main(int argc, const char *argv[]) { + pio_initialize(argc, argv); + original_mode = mem[seg0040 * 0x49]; + getintvec(0x1c, old_1c); + first_time = true; + cursor_off(); + + get_arguments(); + get_slope(); + + if (! zoomy) call_menu(); /* Not run when zoomy. */ + + do { + run_avalot(); + + if (dosexitcode != 77) quit(); /* Didn't stop for us. */ + + switch (storage.operation) { + case run_shootemup: + run("seu.avx", jsb, bflight, normal); + break; + case run_dosshell: + dos_shell(); + break; + case run_ghostroom: + run("g-room.avx", jsb, no_bflight, normal); + break; + case run_golden: + run("golden.avx", jsb, bflight, musical); + break; + } + + } while (!false); + return EXIT_SUCCESS; } } // End of namespace Avalanche.
\ No newline at end of file |