X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Feng_core.cpp;h=853e64cc60419efa032766958dd4c41f6a91ff08;hb=ef18524eeb1d90569410f3660f8a7c7a7defdf1d;hp=67c50978ff8b24156f4c29cc5849854f01287e16;hpb=8546b30d561c27e4b1eab164e17baf4c84a5c42e;p=16.git diff --git a/src/eng_core.cpp b/src/eng_core.cpp index 67c50978..853e64cc 100644 --- a/src/eng_core.cpp +++ b/src/eng_core.cpp @@ -1,5 +1,5 @@ #include "src\eng_core.h" -#include + #include "src\eng_snd.h" #include "src\eng_gfx.h" #include "src\eng_comm.h" @@ -7,9 +7,9 @@ #include -#include "src\lib\dos_gfx.h" -#include "src\lib\opl2.h" -#include "src\lib\dos_comm.h" +//#include "src\lib\dos_gfx.h" +//#include "src\lib\opl2.h" +//#include "src\lib\dos_comm.h" namespace engine{ @@ -19,36 +19,39 @@ namespace engine{ this->init(); //default constructor - this->fp = new std::list; this->msg = ENGINE_RUN; this->timer.start_timer(); - this->frames_per_second = 60; - - this->fp->push_back(&Core::sound); - this->fp->push_back(&Core::graphics); - this->fp->push_back(&Core::comm); - this->fp->push_back(&Core::ai); - - //this->fp.push_back(&core::sound); - //this->fp.push_back(&core::graphics); - //this->fp.push_back(&core::comm); - //this->fp.push_back(&engine::core::ai); - - // Global Variables - this->qing = 4; // test global variable - this->x = 0; // X + this->frames_per_second = 60; + + // Global Variables + this->mode = 4; // test global variable + this->x = 0; // X this->y = 0; // Y + + // Start setttings of flags. I hope I got the same + // logic as it was before, with the STL list. + this->graphics_flag = true; + this->comm_flag = true; + this->release_flag = false; } void Core::update() - { - for (std::list::iterator i = fp->begin(); i != fp->end(); i++) + { + /*for (std::list::iterator i = fp->begin(); i != fp->end(); i++) //for (std::list::iterator i = this->fp.begin(); i != this->fp.end(); i++) { - (this->*(*i))(); - } - + }*/ + // call update functions, instead of traversing a function pointer + // list. Remove this comment! + sound(); + if ( graphics_flag ) + graphics(); + if ( comm_flag ) + comm(); + ai(); + if ( release_flag ) + release(); } void Core::sound() @@ -78,7 +81,7 @@ namespace engine{ //if (this->timer.elapsed_timer() >= fps) //{ //wrap comm lib - this->msg = do_communication(scankey()); + this->msg = do_communication(); //this->timer.start_timer(); //} } @@ -102,16 +105,15 @@ namespace engine{ //---- i++;if(i==600){char a;std::cin >> a;this->keeq[a] = true;i=0;} this->sync(); this->input(); - this->update(); -//tt std::cout << this->qing << std::endl; + this->update(); } } bool Core::init(){ bool xz = 0; // error switch... std::cout << "VIDEO INITIATION" << std::endl; - setvideo(0x13, 1); - setvbuff(1); +//____working on mode x setvideo(0x13, 1); +//____working on mode x setvbuff(1); std::cout << "Checking for Adlib sound card...." << std::endl; if(!AdlibExists()){ std::cout << "not found." << std::endl; @@ -124,8 +126,8 @@ namespace engine{ std::cout << "1 - 9 for graphical tests!" << std::endl; std::cout << "space bar for control and sprite test!" << std::endl; std::cout << "z key for noise!" << std::endl; - std::cout << "Press press any key to continue!" << std::endl; - getch(); + //std::cout << "Press press any key to continue!" << std::endl; + //getch(); std::cout << "INPUT INITIATION" << std::endl; setkb(1); std::cout << "INITIATION" << std::endl; @@ -135,8 +137,8 @@ namespace engine{ void Core::release() { //release contexts and set engine to exit - setvideo(0x03, 0); - setvbuff(0); +//____working on mode x setvideo(0x03, 0); +//____working on mode x setvbuff(0); setkb(0); FMReset(); this->msg = ENGINE_EXIT; @@ -147,7 +149,6 @@ namespace engine{ //dummy 'w' and 'p' down, t up //---- bool dummy_input_available = true; //---- if(dummy_input_available) - //if (scankey() <= 128) //---- { //---- std::cout << "key down" << std::endl; //---- this->keeq['w'] = true; @@ -168,32 +169,32 @@ namespace engine{ if (this->timer.elapsed_timer() >= (1.0 / this->frames_per_second)) { //int a;std::cin >> a; - this->fp->push_back(&Core::graphics); + graphics_flag = true; this->timer.start_timer(); -//==== std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl; +//==== std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl; +//____ updatevbuff(); } else { - this->fp->remove(&Core::graphics); + graphics_flag = false; } if (ENGINE_INPUT == this->msg) { - this->fp->push_back(&Core::comm); + comm_flag = true; } else { - this->fp->remove(&Core::comm); + comm_flag = false; } if (ENGINE_QUIT == this->msg) { - this->fp->push_back(&Core::release); + release_flag = true; } } Core::~Core() { //deconstructor - delete(this->fp); } }