1 #include "src\eng_core.h"
\r
3 #include "src\eng_snd.h"
\r
4 #include "src\eng_gfx.h"
\r
5 #include "src\eng_comm.h"
\r
6 #include "src\eng_ai.h"
\r
10 #include "src\lib\dos_gfx.h"
\r
11 #include "src\lib\opl2.h"
\r
12 #include "src\lib\dos_comm.h"
\r
18 // Hardware Initiation
\r
21 //default constructor
\r
22 this->fp = new std::list<void(Core::*)()>;
\r
23 this->msg = ENGINE_RUN;
\r
24 this->timer.start_timer();
\r
25 this->frames_per_second = 60;
27 this->fp->push_back(&Core::sound);
\r
28 this->fp->push_back(&Core::graphics);
\r
29 this->fp->push_back(&Core::comm);
\r
30 this->fp->push_back(&Core::ai);
\r
32 //this->fp.push_back(&core::sound);
\r
33 //this->fp.push_back(&core::graphics);
\r
34 //this->fp.push_back(&core::comm);
\r
35 //this->fp.push_back(&engine::core::ai);
38 this->qing = 4; // test global variable
\r
45 for (std::list<void(Core::*)()>::iterator i = fp->begin(); i != fp->end(); i++)
\r
46 //for (std::list<void(core::*)()>::iterator i = this->fp.begin(); i != this->fp.end(); i++)
\r
59 void Core::graphics()
\r
61 //int num_frames = 60;
\r
62 //double fps = 1.0 / num_frames;
\r
63 //double now = this->timer.elapsed_timer();
\r
64 //std::cout << "fps: " << fps << " now: " << now << std::endl;
\r
65 //if (this->timer.elapsed_timer() >= fps)
\r
69 //this->timer.start_timer();
\r
74 //int num_frames = 60;
\r
75 //double fps = 1.0 / num_frames;
\r
76 //double now = this->timer.elapsed_timer();
\r
77 //std::cout << "fps: " << fps << " now: " << now << std::endl;
\r
78 //if (this->timer.elapsed_timer() >= fps)
\r
81 this->msg = do_communication(scankey());
\r
82 //this->timer.start_timer();
\r
88 do_artificial_intelligence();
\r
91 engine_message Core::_msg()
\r
99 while (ENGINE_EXIT != this->msg)
\r
101 //next line for purely testing purposes
\r
102 //---- i++;if(i==600){char a;std::cin >> a;this->keeq[a] = true;i=0;}
\r
106 //tt std::cout << this->qing << std::endl;
111 bool xz = 0; // error switch...
\r
112 std::cout << "VIDEO INITIATION" << std::endl;
\r
115 std::cout << "Checking for Adlib sound card...." << std::endl;
\r
116 if(!AdlibExists()){
\r
117 std::cout << "not found." << std::endl;
\r
120 std::cout << "found." << std::endl;
\r
121 std::cout << "OPL2 INITIATION" << std::endl;
\r
123 std::cout << "\nPress ESC to quit the game engine core test." << std::endl;
\r
124 std::cout << "1 - 9 for graphical tests!" << std::endl;
\r
125 std::cout << "space bar for control and sprite test!" << std::endl;
\r
126 std::cout << "z key for noise!" << std::endl;
\r
127 std::cout << "Press press any key to continue!" << std::endl;
\r
129 std::cout << "INPUT INITIATION" << std::endl;
\r
131 std::cout << "INITIATION" << std::endl;
\r
135 void Core::release()
\r
137 //release contexts and set engine to exit
\r
142 this->msg = ENGINE_EXIT;
\r
145 void Core::input(){
\r
146 //retrieve input device information
\r
147 //dummy 'w' and 'p' down, t up
\r
148 //---- bool dummy_input_available = true;
\r
149 //---- if(dummy_input_available)
\r
150 //if (scankey() <= 128)
\r
152 //---- std::cout << "key down" << std::endl;
\r
153 //---- this->keeq['w'] = true;
\r
154 //---- this->keeq['p'] = true;
\r
155 //---- this->keeq['t'] = false;
\r
156 //notify engine that input occured
\r
157 this->msg = ENGINE_INPUT;
\r
161 //---- std::cout << "key up" << std::endl;
\r
162 //---- this->msg = ENGINE_RUN;
\r
168 if (this->timer.elapsed_timer() >= (1.0 / this->frames_per_second))
\r
170 //int a;std::cin >> a;
\r
171 this->fp->push_back(&Core::graphics);
\r
172 this->timer.start_timer();
\r
173 //==== std::cout << "GRAPHICS GRAPHICS GRAPHICS GRAPHICS GRAPHICS" << std::endl;
\r
177 this->fp->remove(&Core::graphics);
\r
179 if (ENGINE_INPUT == this->msg)
\r
181 this->fp->push_back(&Core::comm);
\r
185 this->fp->remove(&Core::comm);
\r
187 if (ENGINE_QUIT == this->msg)
\r
189 this->fp->push_back(&Core::release);
\r