[Scummvm-cvs-logs] SF.net SVN: scummvm:[44712] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Oct 6 19:45:57 CEST 2009


Revision: 44712
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44712&view=rev
Author:   thebluegr
Date:     2009-10-06 17:45:57 +0000 (Tue, 06 Oct 2009)

Log Message:
-----------
- Fixed kGetTime() again
- Removed the odd way of calculating elapsed time in SciGui(). We got _system->getMillis() for that purpose
- Replaced the code in SciGui::wait() with the one in SciGui32::wait (which works fine, and is correct). The code in SciGui() was not polling for events while waiting, either

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kmisc.cpp
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_palette.cpp
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h

Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-10-06 17:45:57 UTC (rev 44712)
@@ -116,11 +116,11 @@
 
 reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
 	tm loc_time;
-	uint32 start_time;
+	uint32 elapsedTime;
 	int retval = 0; // Avoid spurious warning
 
 	g_system->getTimeAndDate(loc_time);
-	start_time = g_system->getMillis() - s->game_start_time;
+	elapsedTime = g_system->getMillis() - s->game_start_time;
 
 	if ((s->_flags & GF_SCI0_OLDGETTIME) && argc) { // Use old semantics
 		retval = (loc_time.tm_hour % 12) * 3600 + loc_time.tm_min * 60 + loc_time.tm_sec;
@@ -132,8 +132,7 @@
 
 	switch (mode) {
 	case K_NEW_GETTIME_TICKS :
-		retval = s->gui->getTimeTicks();	// FIXME
-		//retval = start_time * 60 / 1000;
+		retval = elapsedTime * 60 / 1000;
 		debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
 		break;
 	case K_NEW_GETTIME_TIME_12HOUR :

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 17:45:57 UTC (rev 44712)
@@ -27,6 +27,7 @@
 #include "common/util.h"
 
 #include "sci/sci.h"
+#include "sci/debug.h"	// for g_debug_sleeptime_factor
 #include "sci/engine/state.h"
 #include "sci/tools.h"
 #include "sci/gui/gui.h"
@@ -43,7 +44,6 @@
 SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen)
 	: _system(system), _s(state), _screen(screen) {
 	_picNotValid = 0;
-	_sysTicks = 0;
 
 	_palette = new SciGuiPalette(_s, this, _screen);
 	_gfx = new SciGuiGfx(_s, _screen, _palette);
@@ -54,30 +54,26 @@
 }
 
 SciGui::~SciGui() {
-	_system->getTimerManager()->removeTimerProc(&timerHandler);
 }
 
 void SciGui::init(bool usesOldGfxFunctions) {
-	_sysSpeed = 1000000 / 60;
-	Common::TimerManager *tm = _system->getTimerManager();
-	tm->removeTimerProc(&timerHandler);
-	tm->installTimerProc(&timerHandler, _sysSpeed, this);
 }
 
-void SciGui::timerHandler(void *ref) {
-	((SciGui *)ref)->_sysTicks++;
-}
 
-int16 SciGui::getTimeTicks() {
-	return _sysTicks;
-}
-
 void SciGui::wait(int16 ticks) {
-	uint32 waitto = _sysTicks + ticks;
-	do {
-		//eventMgr->pollEvents();
-		_system->delayMillis(_sysSpeed >> 11);
-	} while (_sysTicks < waitto);
+	uint32 time;
+
+	time = g_system->getMillis();
+	_s->r_acc = make_reg(0, ((long)time - (long)_s->last_wait_time) * 60 / 1000);
+	_s->last_wait_time = time;
+
+	ticks *= g_debug_sleeptime_factor;
+	gfxop_sleep(_s->gfx_state, ticks * 1000 / 60);
+
+
+	// Reset speed throttler: Game is playing along nicely anyway
+	if (ticks > 0)
+		_s->speedThrottler->reset();
 }
 
 void SciGui::setPort(uint16 portPtr) {

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 17:45:57 UTC (rev 44712)
@@ -46,7 +46,6 @@
 
 	virtual void init(bool usesOldGfxFunctions);
 
-	virtual int16 getTimeTicks();
 	virtual void wait(int16 ticks);
 	virtual void setPort(uint16 portPtr);
 	virtual void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft);
@@ -93,8 +92,6 @@
 	int _picNotValid; // possible values 0, 1 and 2
 
 private:
-	static void timerHandler(void*ref);
-
 	OSystem *_system;
 	EngineState *_s;
 	SciGuiScreen *_screen;
@@ -102,8 +99,6 @@
 	SciGuiGfx *_gfx;
 	SciGuiresources *_resources;
 	SciGuiWindowMgr *_windowMgr;
-	uint32 _sysTicks;
-	int32 _sysSpeed; // ticker timer in ms 
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-06 17:45:57 UTC (rev 44712)
@@ -229,10 +229,10 @@
 			pTo->colors[res & 0xFF].used |= 0x10;
 		}
 	}
-	pTo->timestamp = _gui->getTimeTicks();
+	pTo->timestamp = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;;
 }
 
-uint16 SciGuiPalette::matchColor(GuiPalette*pPal, byte r, byte g, byte b) {
+uint16 SciGuiPalette::matchColor(GuiPalette *pPal, byte r, byte g, byte b) {
 	byte found = 0xFF;
 	int diff = 0x2FFFF, cdiff;
 	int16 dr,dg,db;
@@ -275,7 +275,7 @@
 void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) {
 	GuiColor col;
 	int len = toColor - fromColor - 1;
-	uint32 now = _gui->getTimeTicks();
+	uint32 now = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;;
 	// search for sheduled animations with the same 'from' value
 	int sz = _palSchedules.size();
 	for (int i = 0; i < sz; i++) {

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 17:45:57 UTC (rev 44712)
@@ -79,12 +79,6 @@
 	port_origin_y = 0;
 }
 
-int16 SciGui32::getTimeTicks() {
-	uint32 start_time;
-	start_time = _system->getMillis() - s->game_start_time;
-	return start_time * 60 / 1000;
-}
-
 void SciGui32::wait(int16 ticks) {
 	uint32 time;
 

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 17:44:17 UTC (rev 44711)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 17:45:57 UTC (rev 44712)
@@ -40,7 +40,6 @@
 
 	void init(bool oldGfxFunctions);
 
-	int16 getTimeTicks();
 	void wait(int16 ticks);
 	void setPort(uint16 portPtr);
 	void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list