diff options
| author | Paul Gilbert | 2014-12-10 21:27:06 -0500 | 
|---|---|---|
| committer | Paul Gilbert | 2014-12-12 23:07:00 -0500 | 
| commit | 547f3debb2b44dfb8fb3d659ac09f3bd24a017c4 (patch) | |
| tree | f111226b04e2f2ba6cf2ecffd4918e9a2f0cc5de | |
| parent | 781c6ff8c44efd4e9411114d2628d547fab8ce33 (diff) | |
| download | scummvm-rg350-547f3debb2b44dfb8fb3d659ac09f3bd24a017c4.tar.gz scummvm-rg350-547f3debb2b44dfb8fb3d659ac09f3bd24a017c4.tar.bz2 scummvm-rg350-547f3debb2b44dfb8fb3d659ac09f3bd24a017c4.zip | |
ACCESS: Separate timer updates from frame updates, and overall delay cleanup
| -rw-r--r-- | engines/access/access.cpp | 4 | ||||
| -rw-r--r-- | engines/access/amazon/amazon_game.cpp | 6 | ||||
| -rw-r--r-- | engines/access/amazon/amazon_logic.cpp | 3 | ||||
| -rw-r--r-- | engines/access/events.cpp | 34 | ||||
| -rw-r--r-- | engines/access/events.h | 11 | ||||
| -rw-r--r-- | engines/access/inventory.cpp | 9 | ||||
| -rw-r--r-- | engines/access/room.cpp | 3 | ||||
| -rw-r--r-- | engines/access/screen.cpp | 4 | ||||
| -rw-r--r-- | engines/access/scripts.cpp | 9 | 
9 files changed, 43 insertions, 40 deletions
| diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 4201564e84..bb5414da31 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -410,9 +410,7 @@ void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {  	while (!shouldQuit() && !_video->_videoEnd) {  		_video->playVideo(); - -		g_system->delayMillis(10); -		_events->pollEvents(); +		_events->pollEventsAndWait();  	}  } diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 29466f1dee..63291bde52 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -535,8 +535,7 @@ void AmazonEngine::startChapter(int chapter) {  		// Wait loop  		while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { -			_events->pollEvents(); -			g_system->delayMillis(10); +			_events->pollEventsAndWait();  		}  	} @@ -576,8 +575,7 @@ void AmazonEngine::startChapter(int chapter) {  	// Wait loop  	while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { -		_events->pollEvents(); -		g_system->delayMillis(10); +		_events->pollEventsAndWait();  	}  	if (shouldQuit())  		return; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 49bc47fc64..320d87476a 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -687,10 +687,7 @@ void Plane::mWhileFly() {  		++_pCount;  		while (!_vm->shouldQuit() && events._vbCount > 0) { -			// To be rewritten when NEWTIMER is done -			events.checkForNextFrameCounter();  			_vm->_sound->playSound(0); -  			events.pollEventsAndWait();  		}  	} diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 5ed5ee2052..249ba15010 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -47,6 +47,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {  	_cursorExitFlag = false;  	_vbCount = 0;  	_keyCode = Common::KEYCODE_INVALID; +	_priorTimerTime = 0;  }  EventsManager::~EventsManager() { @@ -124,9 +125,12 @@ bool EventsManager::isCursorVisible() {  void EventsManager::pollEvents(bool skipTimers) {  	if (checkForNextFrameCounter()) { -		nextFrame(skipTimers); +		nextFrame();  	} +	if (checkForNextTimerUpdate() && !skipTimers) +		nextTimer(); +  	_wheelUp = _wheelDown = false;  	Common::Event event; @@ -233,7 +237,7 @@ void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) {  void EventsManager::pollEventsAndWait() {  	pollEvents(); -	g_system->delayMillis(10); +	delay();  }  bool EventsManager::checkForNextFrameCounter() { @@ -250,13 +254,19 @@ bool EventsManager::checkForNextFrameCounter() {  	return false;  } -void EventsManager::nextFrame(bool skipTimers) { -	if (!skipTimers) { -		// Update timers -		_vm->_animation->updateTimers(); -		_vm->_timers.updateTimers(); +bool EventsManager::checkForNextTimerUpdate() { +	// Check for next timer update +	uint32 milli = g_system->getMillis(); +	if ((milli - _priorTimerTime) >= GAME_TIMER_TIME) { +		_priorTimerTime = milli; + +		return true;  	} +	return false; +} + +void EventsManager::nextFrame() {  	// Give time to the debugger  	_vm->_debugger->onFrame(); @@ -264,6 +274,11 @@ void EventsManager::nextFrame(bool skipTimers) {  	_vm->_screen->updateScreen();  } +void EventsManager::nextTimer() { +	_vm->_animation->updateTimers(); +	_vm->_timers.updateTimers(); +} +  void EventsManager::delay(int time) {  	g_system->delayMillis(time);  } @@ -288,8 +303,7 @@ bool EventsManager::isKeyPending() const {  void EventsManager::debounceLeft() {  	while (_leftButton && !_vm->shouldQuit()) { -		pollEvents(); -		g_system->delayMillis(10); +		pollEventsAndWait();  	}  } @@ -301,7 +315,7 @@ void EventsManager::clearEvents() {  void EventsManager::waitKeyMouse() {  	while (!_vm->shouldQuit() && !isKeyMousePressed()) {  		pollEvents(true); -		g_system->delayMillis(10); +		delay();  	}  } diff --git a/engines/access/events.h b/engines/access/events.h index 04edd2bdf3..c43bf472f0 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -38,6 +38,7 @@ enum CursorType {  #define GAME_FRAME_RATE 100  #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) +#define GAME_TIMER_TIME 15  class AccessEngine; @@ -46,10 +47,14 @@ private:  	AccessEngine *_vm;  	uint32 _frameCounter;  	uint32 _priorFrameTime; +	uint32 _priorTimerTime;  	Common::KeyCode _keyCode;  	Graphics::Surface _invCursor; -	void nextFrame(bool skipTimers); +	bool checkForNextFrameCounter(); +	bool checkForNextTimerUpdate(); +	void nextFrame(); +	void nextTimer();  	void keyControl(Common::KeyCode keycode, bool isKeyDown);  public:  	CursorType _cursorId; @@ -117,7 +122,7 @@ public:  	bool isKeyPending() const; -	void delay(int time); +	void delay(int time = 5);  	void debounceLeft(); @@ -125,8 +130,6 @@ public:  	void waitKeyMouse(); -	bool checkForNextFrameCounter(); -  	Common::Point &getMousePos() { return _mousePos; }  	Common::Point calcRawMouse(); diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 4038929a67..acba60433f 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -321,8 +321,7 @@ void InventoryManager::chooseItem() {  	while (!_vm->shouldQuit()) {  		// Check for events -		events.pollEvents(); -		g_system->delayMillis(10); +		events.pollEventsAndWait();  		int selIndex;  		// 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  	while (!_vm->shouldQuit() && events._leftButton) {  		// Poll for events -		events.pollEvents(); -		g_system->delayMillis(10); +		events.pollEventsAndWait();  		// Check positioning  		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);  	while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) { -		_vm->_events->pollEvents(); -		g_system->delayMillis(5); +		_vm->_events->pollEventsAndWait();  		_vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect);  		if (backItem != -1) { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 57332f742d..e18bd4a329 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -81,9 +81,8 @@ void Room::doRoom() {  			// Poll for events  			_vm->_canSaveLoad = true; -			_vm->_events->pollEvents(); +			_vm->_events->pollEventsAndWait();  			_vm->_canSaveLoad = false; -			g_system->delayMillis(5);  			_vm->_player->walk();  			_vm->_midi->midiRepeat(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index f98552470c..318eb66516 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -158,7 +158,7 @@ void Screen::forceFadeOut() {  		}  		updatePalette(); -		g_system->delayMillis(10); +		_vm->_events->pollEventsAndWait();  	} while (repeatFlag && !_vm->shouldQuit());  } @@ -180,7 +180,7 @@ void Screen::forceFadeIn() {  		}  		updatePalette(); -		g_system->delayMillis(10); +		_vm->_events->pollEventsAndWait();  	} while (repeatFlag);  } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6c9f278736..d8f9a51e8f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -521,12 +521,11 @@ void Scripts::cmdSaveRect() {  }  void Scripts::cmdVideoEnded() { -	_vm->_events->pollEvents(); +	_vm->_events->pollEventsAndWait();  	if (_vm->_video->_videoEnd) {  		cmdGoto();  	} else { -		g_system->delayMillis(10);  		_data->skip(2);  	}  } @@ -731,8 +730,7 @@ void Scripts::cmdWait() {  		_vm->_midi->midiRepeat();  		charLoop(); -		_vm->_events->pollEvents(); -		g_system->delayMillis(10); +		_vm->_events->pollEventsAndWait();  	}  	_vm->_events->debounceLeft(); @@ -819,8 +817,7 @@ void Scripts::cmdPlayVideoSound() {  		_vm->_video->_soundFlag = true;  	} -	_vm->_events->pollEvents(); -	g_system->delayMillis(10); +	_vm->_events->pollEventsAndWait();  }  void Scripts::cmdPrintWatch() { | 
