Skip to content

Commit

Permalink
ACCESS: Use a variable delay of up to 20ms instead of a fix 50ms
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Aug 19, 2014
1 parent 992ea95 commit b4f74b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 12 additions & 1 deletion engines/access/access.cpp
Expand Up @@ -99,6 +99,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_rKeyFlag = 0;
_mapOffset = 0;
_screenVirtX = 0;
_lastTime = g_system->getMillis();
_curTime = 0;
}

AccessEngine::~AccessEngine() {
Expand Down Expand Up @@ -171,7 +173,16 @@ void AccessEngine::dummyLoop() {
// Dummy game loop
while (!shouldQuit()) {
_events->pollEvents();
g_system->delayMillis(50);

_curTime = g_system->getMillis();
// Process machine once every tick
while (_curTime - _lastTime < 20) {
g_system->delayMillis(5);
_curTime = g_system->getMillis();
}

_lastTime = _curTime;

g_system->updateScreen();

if (_events->_leftButton) {
Expand Down
2 changes: 2 additions & 0 deletions engines/access/access.h
Expand Up @@ -73,6 +73,8 @@ struct AccessGameDescription;

class AccessEngine : public Engine {
private:
uint32 _lastTime, _curTime;

/**
* Handles basic initialisation
*/
Expand Down
4 changes: 0 additions & 4 deletions engines/access/room.cpp
Expand Up @@ -79,10 +79,6 @@ void Room::doRoom() {
_vm->_screen->fadeIn();
}

// TODO: Game loop doesn't seem to have any delay. For now,
// introduce a slight delay here
_vm->_events->delay(50);

// Handle any events
_vm->_events->pollEvents();

Expand Down

0 comments on commit b4f74b9

Please sign in to comment.