aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2
diff options
context:
space:
mode:
Diffstat (limited to 'engines/cge2')
-rw-r--r--engines/cge2/cge2.cpp2
-rw-r--r--engines/cge2/cge2.h5
-rw-r--r--engines/cge2/cge2_main.cpp63
-rw-r--r--engines/cge2/cge2_main.h8
-rw-r--r--engines/cge2/vga13h.cpp6
-rw-r--r--engines/cge2/vga13h.h2
6 files changed, 78 insertions, 8 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index fe94e16387..89ec3b0b42 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -70,6 +70,8 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_sex = true;
_mouseTop = kWorldHeight / 3;
_dark = false;
+ _lastFrame = 0;
+ _lastTick = 0;
}
void CGE2Engine::init() {
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index 5e16864cb5..0c3670ff00 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -86,6 +86,9 @@ public:
};
class CGE2Engine : public Engine {
+private:
+ uint32 _lastFrame, _lastTick;
+ void tick();
public:
CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription);
virtual bool hasFeature(EngineFeature f) const;
@@ -118,6 +121,8 @@ public:
int findActivePocket(int ref);
void pocFul();
void killText();
+ void mainLoop();
+ void handleFrame();
void setEye(V3D &e);
void setEye(const V2D& e2, int z = -kScrWidth);
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 05dcc802bf..ad1d3a6a4c 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -330,8 +330,15 @@ void CGE2Engine::movie(const char *ext) {
loadScript(fn);
caveUp(_now);
+ while (!_commandHandler->idle() && !_quitFlag)
+ mainLoop();
+
warning("STUB: CGE2Engine::movie()");
+ _commandHandler->addCommand(kCmdClear, -1, 0, nullptr);
+ _commandHandlerTurbo->addCommand(kCmdClear, -1, 0, nullptr);
+ _vga->_showQ->clear();
+ _spare->clear();
_now = now;
}
}
@@ -383,8 +390,62 @@ void CGE2Engine::showBak(int ref) {
}
}
+void CGE2Engine::mainLoop() {
+ _vga->show();
+ _commandHandlerTurbo->runCommand();
+ _commandHandler->runCommand();
+
+ // Handle a delay between game frames
+ handleFrame();
+
+ // Handle any pending events
+ //_eventManager->poll();
+ warning("STUB: CGE2Engine::mainLoop() - Event handling is missing!");
+
+ // Check shouldQuit()
+ _quitFlag = shouldQuit();
+}
+
+void CGE2Engine::handleFrame() {
+ // Game frame delay
+ uint32 millis = g_system->getMillis();
+ while (!_quitFlag && (millis < (_lastFrame + kGameFrameDelay))) {
+ // Handle any pending events
+ //_eventManager->poll();
+ warning("STUB: CGE2Engine::handleFrame() - Event handling is missing!");
+
+ if (millis >= (_lastTick + kGameTickDelay)) {
+ // Dispatch the tick to any active objects
+ tick();
+ _lastTick = millis;
+ }
+
+ // Slight delay
+ g_system->delayMillis(5);
+ millis = g_system->getMillis();
+ }
+ _lastFrame = millis;
+
+ if (millis >= (_lastTick + kGameTickDelay)) {
+ // Dispatch the tick to any active objects
+ tick();
+ _lastTick = millis;
+ }
+}
+
+void CGE2Engine::tick() {
+ for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) {
+ if (spr->_time) {
+ if (!spr->_flags._hide) {
+ if (--spr->_time == 0)
+ spr->tick();
+ }
+ }
+ }
+}
+
void CGE2Engine::loadMap(int cav) {
- warning("STUB: CGE2Engine::loadMap()");
+ warning("STUB: CGE2Engine::loadMap()");
}
void CGE2Engine::openPocket() {
diff --git a/engines/cge2/cge2_main.h b/engines/cge2/cge2_main.h
index 1472e2ef7b..a0a8bd16a1 100644
--- a/engines/cge2/cge2_main.h
+++ b/engines/cge2/cge2_main.h
@@ -31,11 +31,13 @@
namespace CGE2 {
#define kLineMax 512
-#define kIntroExt ".I80"
-#define kNoByte -1 // Recheck this! We have no proof for it's original value.
-#define kTabName "CGE.TAB"
+#define kIntroExt ".I80"
+#define kNoByte -1 // Recheck this! We have no proof for it's original value.
+#define kTabName "CGE.TAB"
#define kInfoW 140
#define kPocketFull 170
+#define kGameFrameDelay (1000 / 50)
+#define kGameTickDelay (1000 / 62)
} // End of namespace CGE2
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 992d0c0d10..46515e7171 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -458,9 +458,9 @@ void Sprite::step(int nr) {
warning("STUB: Sprite::step()");
}
-//void Sprite::tick() {
-// step();
-//}
+void Sprite::tick() {
+ step();
+}
void Sprite::makeXlat(uint8 *x) {
if (!_ext)
diff --git a/engines/cge2/vga13h.h b/engines/cge2/vga13h.h
index 6750aeebd1..77a2fd35be 100644
--- a/engines/cge2/vga13h.h
+++ b/engines/cge2/vga13h.h
@@ -152,7 +152,7 @@ public:
Seq *setSeq(Seq *seq);
CommandHandler::Command *snList(Action type);
//virtual void touch(uint16 mask, int x, int y, Common::KeyCode keyCode);
- //virtual void tick();
+ virtual void tick();
void clrHide(void) { if (_ext) _ext->_b0 = NULL; }
void sync(Common::Serializer &s);