[Scummvm-git-logs] scummvm master -> 87c8b60ee1f0e071c0752aabcdf69ca0ce7d0b0a

bluegr bluegr at gmail.com
Wed Jan 22 22:36:36 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
87c8b60ee1 DREAMWEB: Change the vsync code to use a delay, instead of an interrupt


Commit: 87c8b60ee1f0e071c0752aabcdf69ca0ce7d0b0a
    https://github.com/scummvm/scummvm/commit/87c8b60ee1f0e071c0752aabcdf69ca0ce7d0b0a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-01-23T00:36:14+02:00

Commit Message:
DREAMWEB: Change the vsync code to use a delay, instead of an interrupt

This adjusts the screen update code to check for events more often,
which will help with the game's responsiveness on some platforms

Changed paths:
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h


diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 665e5b4..435f91b 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -49,8 +49,6 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
 	DebugMan.addDebugChannel(kDebugAnimation, "Animation", "Animation Debug Flag");
 	DebugMan.addDebugChannel(kDebugSaveLoad, "SaveLoad", "Track Save/Load Function");
 
-	_vSyncInterrupt = false;
-
 	_console = 0;
 	_sound = 0;
 	_speed = 1;
@@ -276,26 +274,21 @@ DreamWebEngine::~DreamWebEngine() {
 	delete _sound;
 }
 
-static void vSyncInterrupt(void *refCon) {
-	DreamWebEngine *vm = (DreamWebEngine *)refCon;
-
-	if (!vm->isPaused()) {
-		vm->setVSyncInterrupt(true);
-	}
-}
+void DreamWebEngine::waitForVSync() {
+	const uint32 previousTicks = _system->getMillis();
+	// Originally, this was an interval for a thread that was
+	// called every 1000000 / 70 nanoseconds. It has been
+	// adjusted to be a delay instead.
+	const uint32 delay = 800 / 70 / _speed;
 
-void DreamWebEngine::setVSyncInterrupt(bool flag) {
-	_vSyncInterrupt = flag;
-}
+	if (isPaused())
+		return;
 
-void DreamWebEngine::waitForVSync() {
 	processEvents();
 
-	if (!_turbo) {
-		while (!_vSyncInterrupt) {
-			_system->delayMillis(10);
-		}
-		setVSyncInterrupt(false);
+	while (!_turbo && _system->getMillis() - previousTicks < delay) {
+		processEvents(false);
+		_system->delayMillis(10);
 	}
 
 	doShake();
@@ -308,13 +301,15 @@ void DreamWebEngine::quit() {
 	_lastHardKey = Common::KEYCODE_ESCAPE;
 }
 
-void DreamWebEngine::processEvents() {
+void DreamWebEngine::processEvents(bool processSoundEvents) {
 	if (_eventMan->shouldQuit()) {
 		quit();
 		return;
 	}
 
-	_sound->soundHandler();
+	if (processSoundEvents)
+		_sound->soundHandler();
+
 	Common::Event event;
 	int softKey;
 	while (_eventMan->pollEvent(event)) {
@@ -411,21 +406,16 @@ Common::Error DreamWebEngine::run() {
 	_brightPalette = ConfMan.getBool("bright_palette");
 	_copyProtection = ConfMan.getBool("copy_protection");
 
-	_timer->installTimerProc(vSyncInterrupt, 1000000 / 70, this, "dreamwebVSync");
 	dreamweb();
 	dreamwebFinalize();
 	_quitRequested = false;
 
-	_timer->removeTimerProc(vSyncInterrupt);
-
 	return Common::kNoError;
 }
 
 void DreamWebEngine::setSpeed(uint speed) {
 	debug(0, "setting speed %u", speed);
 	_speed = speed;
-	_timer->removeTimerProc(vSyncInterrupt);
-	_timer->installTimerProc(vSyncInterrupt, 1000000 / 70 / speed, this, "dreamwebVSync");
 }
 
 Common::String DreamWebEngine::getSavegameFilename(int slot) const {
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index d770c20..ee4af33 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -102,7 +102,6 @@ class DreamWebEngine : public Engine {
 private:
 	DreamWebConsole			*_console;
 	DreamWebSound *_sound;
-	bool					_vSyncInterrupt;
 
 protected:
 	// Engine APIs
@@ -115,7 +114,6 @@ public:
 	DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gameDesc);
 	virtual ~DreamWebEngine();
 
-	void setVSyncInterrupt(bool flag);
 	void waitForVSync();
 
 	Common::Error loadGameState(int slot);
@@ -127,7 +125,7 @@ public:
 	uint8 randomNumber() { return _rnd.getRandomNumber(255); }
 
 	void mouseCall(uint16 *x, uint16 *y, uint16 *state); //fill mouse pos and button state
-	void processEvents();
+	void processEvents(bool processSoundEvents = true);
 	void blit(const uint8 *src, int pitch, int x, int y, int w, int h);
 	void cls();
 	bool isCD();




More information about the Scummvm-git-logs mailing list