/* Siriel4 engine */ //Allegro #include using namespace std; //Objects (look on SGI pages for more) #include #include #include #include #include //Standart functions #include #include #include //Libs #include //etxternal includes #include "ex_drs.h" #include "ex_scroll.h" //siriel functions #include "si_string.h" #include "si_system.h" #include "si_graphics.h" //siriel classes #include "cl_anim.h" #include "cl_config.h" #include "cl_gameobj.h" #include "cl_datadisc.h" //#include "cl_level.h" #include "cl_engine.h" #include "cl_univers.h" //siriel includes #include "define.h" #include "variable.h" volatile int time_counter; void my_time_handler() { time_counter++; } END_OF_FUNCTION(my_time_handler); int GRAPH_MODE = GFX_AUTODETECT; int wait_time; CONFIGURATION config; DATAFILE *datfont; FONT *mainfont; UNIVERS univ; void help() { cout << "-h|--help - this screen" << endl; cout << "--screen [full|window] - select window mode" << endl; } void conalleg_c::interprete_command(char *cmdstr) { string cmd; cmd = univ.expander.expand(cmdstr); univ.script.lua->exec((char *)cmd.c_str()); } //return parameter from configuration const char *cfg(char *name) { return config.get(name).c_str(); } //initialize all important graphic things int init_gfx() { BITMAP *scr; string mode = cfg(PARAM_SCREEN); cout << "Graphic init ... "; set_color_depth(COLOR_DEPTH); if(!mode.compare(SCREEN_FULL)) { GRAPH_MODE = GFX_AUTODETECT; cout << "[" << SCREEN_FULL << "]"; } else if(!mode.compare(SCREEN_WINDOW)) { GRAPH_MODE = GFX_AUTODETECT_WINDOWED; cout << "[" << SCREEN_WINDOW << "]"; } else { error("Wrong screen mode in configuration!\nUse: full, window"); } if(set_gfx_mode(GRAPH_MODE,SCREEN_SIZE_X,SCREEN_SIZE_Y,0,0)<0) { cout << allegro_error << endl; } text_mode(-1); NO_IMG = create_bitmap(16, 16); clear(NO_IMG); scr = create_bitmap(SCREEN_SIZE_X, SCREEN_SIZE_Y); if(!scr) { cout << "Caramba! Not enough memory for video buffer!" << endl; return 2; } univ.connect_screen(scr); univ.connect_config(&config); cout << " OK" << endl; return 0; } void init_step() { cout << "."; } //initialize basic structures of allegro void init_system() { cout << "Init"; init_step(); set_uformat(U_ASCII); init_step(); allegro_init(); init_step(); install_keyboard(); tst_key_init(); init_step(); install_mouse(); init_step(); install_timer(); init_step(); LOCK_VARIABLE(time_counter); LOCK_FUNCTION((void*)my_time_handler); install_int_ex(my_time_handler, BPS_TO_TIMER(24)); init_step(); atexit(&dumb_exit); init_step(); dumb_register_packfiles(); init_step(); cout << endl; if(install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) == -1) { cout << "No sound" << endl; } } //sets default configuration and replace it with //configuration from file int init_cfg(int argc, char **argv) { int i; string sw, val, tmp; config.init(); cout << "Configuration (" << CONFIG_FILE << ")... "; if(!config.load(CONFIG_FILE)) { cout << "OK" << endl; } cout << "Language = " << cfg(PARAM_LANGUAGE) << endl; for(i=1; i!=argc; i++) { tmp = argv[i]; if(tmp[0] == '-') { if(tmp[1] == '-') { sw = tmp.substr(2,tmp.length()); } else { sw = tmp.substr(1,tmp.length()); } } else { val = tmp; config.set(sw,val); } } return 0; } //check up if all important files are accesible int init_read() { if(!exists(config.get(PARAM_DATAFILE).c_str())) { cout << "Main datafile [" << config.get(PARAM_DATAFILE) << "] doesn't exist! " << endl; cout << "It may cause problem during engine run."< time_counter); wait_time = time_counter + TIME_STEP; if((key[KEY_ESC])|| (univ.colaps())) { stop = 1; } } while(!stop); DRS_exit(); univ.bigcrunch(); } //close or opened handlers void done_datafile() { unload_datafile_object(datfont); } //stop all graphic activities void done_gfx() { destroy_bitmap_safe(NO_IMG,"no_img"); // destroy_bitmap_safe(scr,"scr"); set_gfx_mode(GFX_TEXT,0,0,0,0); //be nice to window termination } //shut down allegro void done_system() { cout << "Terminating Allegro" <1) { cout << STR_ENGINE << " terminated with error " << i << endl; return 1; } if(i == 0) { run(); done(); } return 0; } END_OF_MAIN();