ACCESS: Separate timer updates from frame updates, and overall delay cleanup
This commit is contained in:
parent
781c6ff8c4
commit
547f3debb2
9 changed files with 43 additions and 40 deletions
|
@ -410,9 +410,7 @@ void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
|
||||||
|
|
||||||
while (!shouldQuit() && !_video->_videoEnd) {
|
while (!shouldQuit() && !_video->_videoEnd) {
|
||||||
_video->playVideo();
|
_video->playVideo();
|
||||||
|
_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
_events->pollEvents();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,8 +535,7 @@ void AmazonEngine::startChapter(int chapter) {
|
||||||
|
|
||||||
// Wait loop
|
// Wait loop
|
||||||
while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
|
while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
|
||||||
_events->pollEvents();
|
_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,8 +575,7 @@ void AmazonEngine::startChapter(int chapter) {
|
||||||
|
|
||||||
// Wait loop
|
// Wait loop
|
||||||
while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
|
while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
|
||||||
_events->pollEvents();
|
_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
}
|
}
|
||||||
if (shouldQuit())
|
if (shouldQuit())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -687,10 +687,7 @@ void Plane::mWhileFly() {
|
||||||
++_pCount;
|
++_pCount;
|
||||||
|
|
||||||
while (!_vm->shouldQuit() && events._vbCount > 0) {
|
while (!_vm->shouldQuit() && events._vbCount > 0) {
|
||||||
// To be rewritten when NEWTIMER is done
|
|
||||||
events.checkForNextFrameCounter();
|
|
||||||
_vm->_sound->playSound(0);
|
_vm->_sound->playSound(0);
|
||||||
|
|
||||||
events.pollEventsAndWait();
|
events.pollEventsAndWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
|
||||||
_cursorExitFlag = false;
|
_cursorExitFlag = false;
|
||||||
_vbCount = 0;
|
_vbCount = 0;
|
||||||
_keyCode = Common::KEYCODE_INVALID;
|
_keyCode = Common::KEYCODE_INVALID;
|
||||||
|
_priorTimerTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventsManager::~EventsManager() {
|
EventsManager::~EventsManager() {
|
||||||
|
@ -124,9 +125,12 @@ bool EventsManager::isCursorVisible() {
|
||||||
|
|
||||||
void EventsManager::pollEvents(bool skipTimers) {
|
void EventsManager::pollEvents(bool skipTimers) {
|
||||||
if (checkForNextFrameCounter()) {
|
if (checkForNextFrameCounter()) {
|
||||||
nextFrame(skipTimers);
|
nextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (checkForNextTimerUpdate() && !skipTimers)
|
||||||
|
nextTimer();
|
||||||
|
|
||||||
_wheelUp = _wheelDown = false;
|
_wheelUp = _wheelDown = false;
|
||||||
|
|
||||||
Common::Event event;
|
Common::Event event;
|
||||||
|
@ -233,7 +237,7 @@ void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) {
|
||||||
|
|
||||||
void EventsManager::pollEventsAndWait() {
|
void EventsManager::pollEventsAndWait() {
|
||||||
pollEvents();
|
pollEvents();
|
||||||
g_system->delayMillis(10);
|
delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventsManager::checkForNextFrameCounter() {
|
bool EventsManager::checkForNextFrameCounter() {
|
||||||
|
@ -250,13 +254,19 @@ bool EventsManager::checkForNextFrameCounter() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventsManager::nextFrame(bool skipTimers) {
|
bool EventsManager::checkForNextTimerUpdate() {
|
||||||
if (!skipTimers) {
|
// Check for next timer update
|
||||||
// Update timers
|
uint32 milli = g_system->getMillis();
|
||||||
_vm->_animation->updateTimers();
|
if ((milli - _priorTimerTime) >= GAME_TIMER_TIME) {
|
||||||
_vm->_timers.updateTimers();
|
_priorTimerTime = milli;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventsManager::nextFrame() {
|
||||||
// Give time to the debugger
|
// Give time to the debugger
|
||||||
_vm->_debugger->onFrame();
|
_vm->_debugger->onFrame();
|
||||||
|
|
||||||
|
@ -264,6 +274,11 @@ void EventsManager::nextFrame(bool skipTimers) {
|
||||||
_vm->_screen->updateScreen();
|
_vm->_screen->updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventsManager::nextTimer() {
|
||||||
|
_vm->_animation->updateTimers();
|
||||||
|
_vm->_timers.updateTimers();
|
||||||
|
}
|
||||||
|
|
||||||
void EventsManager::delay(int time) {
|
void EventsManager::delay(int time) {
|
||||||
g_system->delayMillis(time);
|
g_system->delayMillis(time);
|
||||||
}
|
}
|
||||||
|
@ -288,8 +303,7 @@ bool EventsManager::isKeyPending() const {
|
||||||
|
|
||||||
void EventsManager::debounceLeft() {
|
void EventsManager::debounceLeft() {
|
||||||
while (_leftButton && !_vm->shouldQuit()) {
|
while (_leftButton && !_vm->shouldQuit()) {
|
||||||
pollEvents();
|
pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +315,7 @@ void EventsManager::clearEvents() {
|
||||||
void EventsManager::waitKeyMouse() {
|
void EventsManager::waitKeyMouse() {
|
||||||
while (!_vm->shouldQuit() && !isKeyMousePressed()) {
|
while (!_vm->shouldQuit() && !isKeyMousePressed()) {
|
||||||
pollEvents(true);
|
pollEvents(true);
|
||||||
g_system->delayMillis(10);
|
delay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ enum CursorType {
|
||||||
|
|
||||||
#define GAME_FRAME_RATE 100
|
#define GAME_FRAME_RATE 100
|
||||||
#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
|
#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
|
||||||
|
#define GAME_TIMER_TIME 15
|
||||||
|
|
||||||
class AccessEngine;
|
class AccessEngine;
|
||||||
|
|
||||||
|
@ -46,10 +47,14 @@ private:
|
||||||
AccessEngine *_vm;
|
AccessEngine *_vm;
|
||||||
uint32 _frameCounter;
|
uint32 _frameCounter;
|
||||||
uint32 _priorFrameTime;
|
uint32 _priorFrameTime;
|
||||||
|
uint32 _priorTimerTime;
|
||||||
Common::KeyCode _keyCode;
|
Common::KeyCode _keyCode;
|
||||||
|
|
||||||
Graphics::Surface _invCursor;
|
Graphics::Surface _invCursor;
|
||||||
void nextFrame(bool skipTimers);
|
bool checkForNextFrameCounter();
|
||||||
|
bool checkForNextTimerUpdate();
|
||||||
|
void nextFrame();
|
||||||
|
void nextTimer();
|
||||||
void keyControl(Common::KeyCode keycode, bool isKeyDown);
|
void keyControl(Common::KeyCode keycode, bool isKeyDown);
|
||||||
public:
|
public:
|
||||||
CursorType _cursorId;
|
CursorType _cursorId;
|
||||||
|
@ -117,7 +122,7 @@ public:
|
||||||
|
|
||||||
bool isKeyPending() const;
|
bool isKeyPending() const;
|
||||||
|
|
||||||
void delay(int time);
|
void delay(int time = 5);
|
||||||
|
|
||||||
void debounceLeft();
|
void debounceLeft();
|
||||||
|
|
||||||
|
@ -125,8 +130,6 @@ public:
|
||||||
|
|
||||||
void waitKeyMouse();
|
void waitKeyMouse();
|
||||||
|
|
||||||
bool checkForNextFrameCounter();
|
|
||||||
|
|
||||||
Common::Point &getMousePos() { return _mousePos; }
|
Common::Point &getMousePos() { return _mousePos; }
|
||||||
|
|
||||||
Common::Point calcRawMouse();
|
Common::Point calcRawMouse();
|
||||||
|
|
|
@ -321,8 +321,7 @@ void InventoryManager::chooseItem() {
|
||||||
|
|
||||||
while (!_vm->shouldQuit()) {
|
while (!_vm->shouldQuit()) {
|
||||||
// Check for events
|
// Check for events
|
||||||
events.pollEvents();
|
events.pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
|
|
||||||
int selIndex;
|
int selIndex;
|
||||||
// Poll events and wait for a click on a known area
|
// Poll events and wait for a click on a known area
|
||||||
|
@ -414,8 +413,7 @@ void InventoryManager::combineItems() {
|
||||||
// Item drag handling loop if left button is held down
|
// Item drag handling loop if left button is held down
|
||||||
while (!_vm->shouldQuit() && events._leftButton) {
|
while (!_vm->shouldQuit() && events._leftButton) {
|
||||||
// Poll for events
|
// Poll for events
|
||||||
events.pollEvents();
|
events.pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
|
|
||||||
// Check positioning
|
// Check positioning
|
||||||
if (lastMouse == events._mousePos)
|
if (lastMouse == events._mousePos)
|
||||||
|
@ -485,8 +483,7 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh
|
||||||
_invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35);
|
_invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35);
|
||||||
|
|
||||||
while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) {
|
while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) {
|
||||||
_vm->_events->pollEvents();
|
_vm->_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(5);
|
|
||||||
|
|
||||||
_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);
|
_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);
|
||||||
if (backItem != -1) {
|
if (backItem != -1) {
|
||||||
|
|
|
@ -81,9 +81,8 @@ void Room::doRoom() {
|
||||||
|
|
||||||
// Poll for events
|
// Poll for events
|
||||||
_vm->_canSaveLoad = true;
|
_vm->_canSaveLoad = true;
|
||||||
_vm->_events->pollEvents();
|
_vm->_events->pollEventsAndWait();
|
||||||
_vm->_canSaveLoad = false;
|
_vm->_canSaveLoad = false;
|
||||||
g_system->delayMillis(5);
|
|
||||||
|
|
||||||
_vm->_player->walk();
|
_vm->_player->walk();
|
||||||
_vm->_midi->midiRepeat();
|
_vm->_midi->midiRepeat();
|
||||||
|
|
|
@ -158,7 +158,7 @@ void Screen::forceFadeOut() {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePalette();
|
updatePalette();
|
||||||
g_system->delayMillis(10);
|
_vm->_events->pollEventsAndWait();
|
||||||
} while (repeatFlag && !_vm->shouldQuit());
|
} while (repeatFlag && !_vm->shouldQuit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ void Screen::forceFadeIn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePalette();
|
updatePalette();
|
||||||
g_system->delayMillis(10);
|
_vm->_events->pollEventsAndWait();
|
||||||
} while (repeatFlag);
|
} while (repeatFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,12 +521,11 @@ void Scripts::cmdSaveRect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripts::cmdVideoEnded() {
|
void Scripts::cmdVideoEnded() {
|
||||||
_vm->_events->pollEvents();
|
_vm->_events->pollEventsAndWait();
|
||||||
|
|
||||||
if (_vm->_video->_videoEnd) {
|
if (_vm->_video->_videoEnd) {
|
||||||
cmdGoto();
|
cmdGoto();
|
||||||
} else {
|
} else {
|
||||||
g_system->delayMillis(10);
|
|
||||||
_data->skip(2);
|
_data->skip(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,8 +730,7 @@ void Scripts::cmdWait() {
|
||||||
_vm->_midi->midiRepeat();
|
_vm->_midi->midiRepeat();
|
||||||
charLoop();
|
charLoop();
|
||||||
|
|
||||||
_vm->_events->pollEvents();
|
_vm->_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_events->debounceLeft();
|
_vm->_events->debounceLeft();
|
||||||
|
@ -819,8 +817,7 @@ void Scripts::cmdPlayVideoSound() {
|
||||||
_vm->_video->_soundFlag = true;
|
_vm->_video->_soundFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_vm->_events->pollEvents();
|
_vm->_events->pollEventsAndWait();
|
||||||
g_system->delayMillis(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripts::cmdPrintWatch() {
|
void Scripts::cmdPrintWatch() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue