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
This commit is contained in:
Filippos Karapetis committed 2020-01-23 00:36:14 +02:00
1 parent 9b63c7b83e
commit 87c8b60ee1
2 files changed
+17 -29

No files matched your search

+16 -26
View File
@@ -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::setVSyncInterrupt(bool flag) {
_vSyncInterrupt = flag;
}
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;
if (isPaused())
return;
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 {
+1 -3
View File
@@ -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();