[Scummvm-git-logs] scummvm master -> 881c94636162fc56ea9f409bce6390e959bbd6a1

yinsimei roseline.yin at gmail.com
Sun May 27 22:12:11 CEST 2018


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

Summary:
bf3084df0e SLUDGE: Move built-in function parameter number to structure
881c946361 SLUDGE: Move global variable lastFramesPerSecond to class Timer


Commit: bf3084df0eff1f21c9bc94d4254dff11e71b31bc
    https://github.com/scummvm/scummvm/commit/bf3084df0eff1f21c9bc94d4254dff11e71b31bc
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2018-05-27T22:11:38+02:00

Commit Message:
SLUDGE: Move built-in function parameter number to structure

Changed paths:
    engines/sludge/builtin.cpp
    engines/sludge/functionlist.h


diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index e06cea2..0867f7c 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -65,31 +65,6 @@ extern int numBIFNames, numUserFunc;
 extern Common::String *allUserFunc;
 extern Common::String *allBIFNames;
 
-int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1,    // SAY->MOVEMOUSE
-                   -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION
-                   2, 2, 0, 0, 2,                              // ANIMATE->SETSCALE
-                   -1, 2, 1, 0, 0, 0, 1, 0, 3,                 // new/push/pop stack, status stuff
-                   2, 0, 0, 3, 1, 0, 2,                        // delFromStack->completeTimers
-                   -1, -1, -1, 2, 2, 0, 3, 1,                  // anim, costume, pO, setC, wait, sS, substring, stringLength
-                   0, 1, 1, 0, 2,                              // dark, save, load, quit, rename
-                   1, 3, 3, 1, 2, 1, 1, 3, 1, 0, 0, 2, 1,      // stackSize, pasteString, startMusic, defvol, vol, stopmus, stopsound, setfont, alignStatus, show x 2, pos'Status, setFloor
-                   -1, -1, 1, 1, 2, 1, 1, 1, -1, -1, -1, 1, 1, // force, jump, peekstart, peekend, enqueue, getSavedGames, inFont, loopSound, removeChar, stopCharacter
-                   1, 0, 3, 3, 1, 2, 1, 2, 2,                  // launch, howFrozen, pastecol, litcol, checksaved, float, cancelfunc, walkspeed, delAll
-                   2, 3, 1, 2, 2, 0, 0, 1, 2, 3, 1, -1,        // extras, mixoverlay, pastebloke, getMScreenX/Y, setSound(Default/-)Volume, looppoints, speechMode, setLightMap
-                   -1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,           // think, getCharacterDirection, is(char/region/moving), deleteGame, renameGame, hardScroll, stringWidth, speechSpeed, normalCharacter
-                   2, 1, 2, 1, 3, 1, 1, 2, 1,                  // fetchEvent, setBrightness, spin, fontSpace, burnString, captureAll, cacheSound, setSpinSpeed, transitionMode
-                   1, 0, 0, 1, 0, 2, 1, 1, 1,                  // movie(Start/Abort/Playing), updateDisplay, getSoundCache, savedata, loaddata, savemode, freeSound
-                   3, 0, 3, 3, 2, 1, 1,                        // setParallax, clearParallax, setBlankColour, setBurnColour, getPixelColour, makeFastArray, getCharacterScale
-                   0, 2, 0,                                    // getLanguage, launchWith, getFramesPerSecond
-                   3, 2, 2, 0, 0, 1,                           // readThumbnail, setThumbnailSize, hasFlag, snapshot, clearSnapshot, anyFilename
-                   2, 1,                                       // regGet, fatal
-                   4, 3, -1, 0,                                // chr AA, max AA, setBackgroundEffect, doBackgroundEffect
-                   2,                                          // setCharacterAngleOffset
-                   2, 5,                                       // setCharacterTransparency, setCharacterColourise
-                   1,                                          // zoomCamera
-                   1, 0, 0                                     // playMovie, stopMovie, pauseMovie
-                 };
-
 bool failSecurityCheck(const Common::String &fn) {
 	if (fn.empty())
 		return true;
@@ -117,6 +92,7 @@ LoadedFunction *saverFunc;
 typedef BuiltReturn (*builtInSludgeFunc)(int numParams, LoadedFunction *fun);
 struct builtInFunctionData {
 	builtInSludgeFunc func;
+	int paramNum;
 };
 
 #define builtIn(a)          static BuiltReturn builtIn_ ## a (int numParams, LoadedFunction *fun)
@@ -2574,9 +2550,9 @@ BuiltReturn callBuiltIn(int whichFunc, int numParams, LoadedFunction *fun) {
 	}
 
 	if (whichFunc < NUM_FUNCS) {
-		if (paramNum[whichFunc] != -1) {
-			if (paramNum[whichFunc] != numParams) {
-				Common::String buff = Common::String::format("Built in function must have %i parameter%s", paramNum[whichFunc], (paramNum[whichFunc] == 1) ? "" : "s");
+		if (builtInFunctionArray[whichFunc].paramNum != -1) {
+			if (builtInFunctionArray[whichFunc].paramNum != numParams) {
+				Common::String buff = Common::String::format("Built in function must have %i parameter%s", builtInFunctionArray[whichFunc].paramNum, (builtInFunctionArray[whichFunc].paramNum == 1) ? "" : "s");
 				Common::String msg = buff;
 				fatal(msg);
 				return BR_ERROR;
diff --git a/engines/sludge/functionlist.h b/engines/sludge/functionlist.h
index 025f80a..c7858a2 100644
--- a/engines/sludge/functionlist.h
+++ b/engines/sludge/functionlist.h
@@ -29,178 +29,178 @@
 
 namespace Sludge {
 
-#define FUNC(special,name)      {builtIn_ ## name},
+#define FUNC(special,name,paramNum)      {builtIn_ ## name, paramNum},
 static builtInFunctionData builtInFunctionArray[] = {
-	FUNC(true, say)
-	FUNC(true, skipSpeech)
-	FUNC(true, statusText)
-	FUNC(true, pause)
-	FUNC(true, onLeftMouse)
-	FUNC(true, onRightMouse)
-	FUNC(true, setCursor)
-	FUNC(true, addOverlay)
-	FUNC(true, addCharacter)
-	FUNC(true, playSound)
-	FUNC(true, getMouseX)
-	FUNC(true, getMouseY)
-	FUNC(true, addScreenRegion)
-	FUNC(true, onMoveMouse)
-	FUNC(true, onFocusChange)
-	FUNC(true, getOverObject)
-	FUNC(true, blankScreen)
-	FUNC(true, moveCharacter)
-	FUNC(true, onKeyboard)
-	FUNC(true, getObjectX)
-	FUNC(true, getObjectY)
-	FUNC(true, random)
-	FUNC(true, spawnSub)
-	FUNC(true, blankArea)
-	FUNC(true, hideCharacter)
-	FUNC(true, showCharacter)
-	FUNC(true, callEvent)
-	FUNC(true, removeScreenRegion)
-	FUNC(true, animate)
-	FUNC(true, turnCharacter)
-	FUNC(true, removeAllCharacters)
-	FUNC(true, removeAllScreenRegions)
-	FUNC(true, setScale)
-	FUNC(true, newStack)
-	FUNC(true, pushToStack)
-	FUNC(true, popFromStack)
-	FUNC(true, clearStatus)
-	FUNC(true, addStatus)
-	FUNC(true, removeLastStatus)
-	FUNC(true, lightStatus)
-	FUNC(true, getStatusText)
-	FUNC(true, setStatusColour)
-	FUNC(true, deleteFromStack)
-	FUNC(true, freeze)
-	FUNC(true, unfreeze)
-	FUNC(true, pasteImage)
-	FUNC(true, copyStack)
-	FUNC(true, completeTimers)
-	FUNC(true, setCharacterDrawMode)
-	FUNC(true, anim)
-	FUNC(true, costume)
-	FUNC(true, pickOne)
-	FUNC(true, setCostume)
-	FUNC(true, wait)
-	FUNC(true, somethingSpeaking)
-	FUNC(true, substring)
-	FUNC(true, stringLength)
-	FUNC(true, darkBackground)
-	FUNC(true, saveGame)
-	FUNC(true, loadGame)
-	FUNC(true, quitGame)
-	FUNC(true, rename)
-	FUNC(true, stackSize)
-	FUNC(true, pasteString)
-	FUNC(true, startMusic)
-	FUNC(true, setDefaultMusicVolume)
-	FUNC(true, setMusicVolume)
-	FUNC(true, stopMusic)
-	FUNC(true, stopSound)
-	FUNC(true, setFont)
-	FUNC(true, alignStatus)
-	FUNC(true, showFloor)
-	FUNC(true, showBoxes)
-	FUNC(true, positionStatus)
-	FUNC(true, setFloor)
-	FUNC(true, forceCharacter)
-	FUNC(true, jumpCharacter)
-	FUNC(true, peekStart)
-	FUNC(true, peekEnd)
-	FUNC(true, enqueue)
-	FUNC(true, setZBuffer)
-	FUNC(true, getMatchingFiles)
-	FUNC(true, inFont)
-	FUNC(true, onLeftMouseUp)
-	FUNC(true, onRightMouseUp)
-	FUNC(true, loopSound)
-	FUNC(true, removeCharacter)
-	FUNC(true, stopCharacter)
-	FUNC(true, launch)
-	FUNC(true, howFrozen)
-	FUNC(true, setPasteColour)
-	FUNC(true, setLitStatusColour)
-	FUNC(true, fileExists)
-	FUNC(true, floatCharacter)
-	FUNC(true, cancelSub)
-	FUNC(true, setCharacterWalkSpeed)
-	FUNC(true, deleteAllFromStack)
-	FUNC(true, setCharacterExtra)
-	FUNC(true, mixOverlay)
-	FUNC(true, pasteCharacter)
-	FUNC(true, setSceneDimensions)
-	FUNC(true, aimCamera)
-	FUNC(true, getMouseScreenX)
-	FUNC(true, getMouseScreenY)
-	FUNC(true, setDefaultSoundVolume)
-	FUNC(true, setSoundVolume)
-	FUNC(true, setSoundLoopPoints)
-	FUNC(true, setSpeechMode)
-	FUNC(true, setLightMap)
-	FUNC(true, think)
-	FUNC(true, getCharacterDirection)
-	FUNC(true, isCharacter)
-	FUNC(true, isScreenRegion)
-	FUNC(true, isMoving)
-	FUNC(true, deleteFile)
-	FUNC(true, renameFile)
-	FUNC(true, hardScroll)
-	FUNC(true, stringWidth)
-	FUNC(true, setSpeechSpeed)
-	FUNC(true, normalCharacter)
-	FUNC(true, fetchEvent)
-	FUNC(true, transitionLevel)
-	FUNC(true, spinCharacter)
-	FUNC(true, setFontSpacing)
-	FUNC(true, burnString)
-	FUNC(true, captureAllKeys)
-	FUNC(true, cacheSound)
-	FUNC(true, setCharacterSpinSpeed)
-	FUNC(true, transitionMode)
-	FUNC(false, _rem_movieStart)
-	FUNC(false, _rem_movieAbort)
-	FUNC(false, _rem_moviePlaying)
-	FUNC(false, _rem_updateDisplay)
-	FUNC(true, getSoundCache)
-	FUNC(true, saveCustomData)
-	FUNC(true, loadCustomData)
-	FUNC(true, setCustomEncoding)
-	FUNC(true, freeSound)
-	FUNC(true, parallaxAdd)
-	FUNC(true, parallaxClear)
-	FUNC(true, setBlankColour)
-	FUNC(true, setBurnColour)
-	FUNC(true, getPixelColour)
-	FUNC(true, makeFastArray)
-	FUNC(true, getCharacterScale)
-	FUNC(true, getLanguageID)
-	FUNC(false, _rem_launchWith)
-	FUNC(true, getFramesPerSecond)
-	FUNC(true, showThumbnail)
-	FUNC(true, setThumbnailSize)
-	FUNC(true, hasFlag)
-	FUNC(true, snapshotGrab)
-	FUNC(true, snapshotClear)
-	FUNC(true, bodgeFilenames)
-	FUNC(false, _rem_registryGetString)
-	FUNC(true, quitWithFatalError)
-	FUNC(true, _rem_setCharacterAA)
-	FUNC(true, _rem_setMaximumAA)
-	FUNC(true, setBackgroundEffect)
-	FUNC(true, doBackgroundEffect)
-	FUNC(true, setCharacterAngleOffset)
-	FUNC(true, setCharacterTransparency)
-	FUNC(true, setCharacterColourise)
-	FUNC(true, zoomCamera)
-	FUNC(true, playMovie)
-	FUNC(true, stopMovie)
-	FUNC(true, pauseMovie)
+	FUNC(true, say, -1)
+	FUNC(true, skipSpeech, 0)
+	FUNC(true, statusText, 1)
+	FUNC(true, pause, 1)
+	FUNC(true, onLeftMouse, -1)
+	FUNC(true, onRightMouse, -1)
+	FUNC(true, setCursor, 1)
+	FUNC(true, addOverlay, 3)
+	FUNC(true, addCharacter, 4)
+	FUNC(true, playSound, 1)
+	FUNC(true, getMouseX, 0)
+	FUNC(true, getMouseY, 0)
+	FUNC(true, addScreenRegion, 8)
+	FUNC(true, onMoveMouse, -1)
+	FUNC(true, onFocusChange, -1)
+	FUNC(true, getOverObject, 0)
+	FUNC(true, blankScreen, 0)
+	FUNC(true, moveCharacter, -1)
+	FUNC(true, onKeyboard, -1)
+	FUNC(true, getObjectX, 1)
+	FUNC(true, getObjectY, 1)
+	FUNC(true, random, 1)
+	FUNC(true, spawnSub, 1)
+	FUNC(true, blankArea, 4)
+	FUNC(true, hideCharacter, 1)
+	FUNC(true, showCharacter, 1)
+	FUNC(true, callEvent, 2)
+	FUNC(true, removeScreenRegion, 1)
+	FUNC(true, animate, 2)
+	FUNC(true, turnCharacter, 2)
+	FUNC(true, removeAllCharacters, 0)
+	FUNC(true, removeAllScreenRegions, 0)
+	FUNC(true, setScale, 2)
+	FUNC(true, newStack, -1)
+	FUNC(true, pushToStack, 2)
+	FUNC(true, popFromStack, 1)
+	FUNC(true, clearStatus, 0)
+	FUNC(true, addStatus, 0)
+	FUNC(true, removeLastStatus, 0)
+	FUNC(true, lightStatus, 1)
+	FUNC(true, getStatusText, 0)
+	FUNC(true, setStatusColour, 3)
+	FUNC(true, deleteFromStack, 2)
+	FUNC(true, freeze, 0)
+	FUNC(true, unfreeze, 0)
+	FUNC(true, pasteImage, 3)
+	FUNC(true, copyStack, 1)
+	FUNC(true, completeTimers, 0)
+	FUNC(true, setCharacterDrawMode, 2)
+	FUNC(true, anim, -1)
+	FUNC(true, costume, -1)
+	FUNC(true, pickOne, -1)
+	FUNC(true, setCostume, 2)
+	FUNC(true, wait, 2)
+	FUNC(true, somethingSpeaking, 0)
+	FUNC(true, substring, 3)
+	FUNC(true, stringLength, 1)
+	FUNC(true, darkBackground, 0)
+	FUNC(true, saveGame, 1)
+	FUNC(true, loadGame, 1)
+	FUNC(true, quitGame, 0)
+	FUNC(true, rename, 2)
+	FUNC(true, stackSize, 1)
+	FUNC(true, pasteString, 3)
+	FUNC(true, startMusic, 3)
+	FUNC(true, setDefaultMusicVolume, 1)
+	FUNC(true, setMusicVolume, 2)
+	FUNC(true, stopMusic, 1)
+	FUNC(true, stopSound, 1)
+	FUNC(true, setFont, 3)
+	FUNC(true, alignStatus, 1)
+	FUNC(true, showFloor, 0)
+	FUNC(true, showBoxes, 0)
+	FUNC(true, positionStatus, 2)
+	FUNC(true, setFloor, 1)
+	FUNC(true, forceCharacter, -1)
+	FUNC(true, jumpCharacter, -1)
+	FUNC(true, peekStart, 1)
+	FUNC(true, peekEnd, 1)
+	FUNC(true, enqueue, 2)
+	FUNC(true, setZBuffer, 1)
+	FUNC(true, getMatchingFiles, 1)
+	FUNC(true, inFont, 1)
+	FUNC(true, onLeftMouseUp, -1)
+	FUNC(true, onRightMouseUp, -1)
+	FUNC(true, loopSound, -1)
+	FUNC(true, removeCharacter, 1)
+	FUNC(true, stopCharacter, 1)
+	FUNC(true, launch, 1)
+	FUNC(true, howFrozen, 0)
+	FUNC(true, setPasteColour, 3)
+	FUNC(true, setLitStatusColour, 3)
+	FUNC(true, fileExists, 1)
+	FUNC(true, floatCharacter, 2)
+	FUNC(true, cancelSub, 1)
+	FUNC(true, setCharacterWalkSpeed, 2)
+	FUNC(true, deleteAllFromStack, 2)
+	FUNC(true, setCharacterExtra, 2)
+	FUNC(true, mixOverlay, 3)
+	FUNC(true, pasteCharacter, 1)
+	FUNC(true, setSceneDimensions, 2)
+	FUNC(true, aimCamera, 2)
+	FUNC(true, getMouseScreenX, 0)
+	FUNC(true, getMouseScreenY, 0)
+	FUNC(true, setDefaultSoundVolume, 1)
+	FUNC(true, setSoundVolume, 2)
+	FUNC(true, setSoundLoopPoints, 3)
+	FUNC(true, setSpeechMode, 1)
+	FUNC(true, setLightMap, -1)
+	FUNC(true, think, -1)
+	FUNC(true, getCharacterDirection, 1)
+	FUNC(true, isCharacter, 1)
+	FUNC(true, isScreenRegion, 1)
+	FUNC(true, isMoving, 1)
+	FUNC(true, deleteFile, 1)
+	FUNC(true, renameFile, 2)
+	FUNC(true, hardScroll, 1)
+	FUNC(true, stringWidth, 1)
+	FUNC(true, setSpeechSpeed, 1)
+	FUNC(true, normalCharacter, 1)
+	FUNC(true, fetchEvent, 2)
+	FUNC(true, transitionLevel, 1)
+	FUNC(true, spinCharacter, 2)
+	FUNC(true, setFontSpacing, 1)
+	FUNC(true, burnString, 3)
+	FUNC(true, captureAllKeys, 1)
+	FUNC(true, cacheSound, 1)
+	FUNC(true, setCharacterSpinSpeed, 2)
+	FUNC(true, transitionMode, 1)
+	FUNC(false, _rem_movieStart, 1)
+	FUNC(false, _rem_movieAbort, 0)
+	FUNC(false, _rem_moviePlaying, 0)
+	FUNC(false, _rem_updateDisplay, 1)
+	FUNC(true, getSoundCache, 0)
+	FUNC(true, saveCustomData, 2)
+	FUNC(true, loadCustomData, 1)
+	FUNC(true, setCustomEncoding, 1)
+	FUNC(true, freeSound, 1)
+	FUNC(true, parallaxAdd, 3)
+	FUNC(true, parallaxClear, 0)
+	FUNC(true, setBlankColour, 3)
+	FUNC(true, setBurnColour, 3)
+	FUNC(true, getPixelColour, 2)
+	FUNC(true, makeFastArray, 1)
+	FUNC(true, getCharacterScale, 1)
+	FUNC(true, getLanguageID, 0)
+	FUNC(false, _rem_launchWith, 2)
+	FUNC(true, getFramesPerSecond, 0)
+	FUNC(true, showThumbnail, 3)
+	FUNC(true, setThumbnailSize, 2)
+	FUNC(true, hasFlag, 2)
+	FUNC(true, snapshotGrab, 0)
+	FUNC(true, snapshotClear, 0)
+	FUNC(true, bodgeFilenames, 1)
+	FUNC(false, _rem_registryGetString, 2)
+	FUNC(true, quitWithFatalError, 1)
+	FUNC(true, _rem_setCharacterAA, 4)
+	FUNC(true, _rem_setMaximumAA, 3)
+	FUNC(true, setBackgroundEffect, -1)
+	FUNC(true, doBackgroundEffect, 0)
+	FUNC(true, setCharacterAngleOffset, 2)
+	FUNC(true, setCharacterTransparency, 2)
+	FUNC(true, setCharacterColourise, 5)
+	FUNC(true, zoomCamera, 1)
+	FUNC(true, playMovie, 1)
+	FUNC(true, stopMovie, 0)
+	FUNC(true, pauseMovie, 0)
 };
 #undef FUNC
 
-int NUM_FUNCS = (sizeof (builtInFunctionArray) / sizeof (builtInFunctionArray[0]));
+const static int NUM_FUNCS = (sizeof (builtInFunctionArray) / sizeof (builtInFunctionArray[0]));
 
 } // End of namespace Sludge


Commit: 881c94636162fc56ea9f409bce6390e959bbd6a1
    https://github.com/scummvm/scummvm/commit/881c94636162fc56ea9f409bce6390e959bbd6a1
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2018-05-27T22:11:38+02:00

Commit Message:
SLUDGE: Move global variable lastFramesPerSecond to class Timer

Changed paths:
    engines/sludge/builtin.cpp
    engines/sludge/sludger.cpp
    engines/sludge/sludger.h
    engines/sludge/timing.cpp
    engines/sludge/timing.h


diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 0867f7c..8646dd4 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -56,7 +56,6 @@ namespace Sludge {
 
 Variable *launchResult = NULL;
 
-extern int lastFramesPerSecond;
 extern bool allowAnyFilename;
 extern VariableStack *noStack;
 extern StatusStuff  *nowStatus;
@@ -2403,7 +2402,7 @@ builtIn(_rem_launchWith) {
 
 builtIn(getFramesPerSecond) {
 	UNUSEDALL
-	setVariable(fun->reg, SVT_INT, lastFramesPerSecond);
+	setVariable(fun->reg, SVT_INT, g_sludge->_timer.getLastFps());
 	return BR_CONTINUE;
 }
 
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index dd3b319..8bbf76e 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -138,6 +138,7 @@ Common::File *openAndVerify(const Common::String &filename, char extra1, char ex
 }
 
 void initSludge() {
+	g_sludge->_timer.reset();
 	g_sludge->_languageMan->init();
 	g_sludge->_gfxMan->init();
 	g_sludge->_resMan->init();
@@ -161,7 +162,6 @@ void initSludge() {
 	numGlobals = 0;
 	launchResult = nullptr;
 
-	lastFramesPerSecond = -1;
 	allowAnyFilename = true;
 	noStack = nullptr;
 	numBIFNames = numUserFunc = 0;
@@ -243,7 +243,7 @@ bool initSludge(const Common::String &filename) {
 
 	int specialSettings = fp->readByte();
 	debugC(2, kSludgeDebugDataLoad, "specialSettings : %i", specialSettings);
-	g_sludge->_timer.setDesiredfps(1000 / fp->readByte());
+	g_sludge->_timer.setDesiredFPS(1000 / fp->readByte());
 
 	readString(fp);  // Unused - was used for registration purposes.
 
@@ -1033,7 +1033,4 @@ int startNewFunctionNum(uint funcNum, uint numParamsExpected,
 	return 1;
 }
 
-int lastFramesPerSecond = -1;
-int thisFramesPerSecond = -1;
-
 } // End of namespace Sludge
diff --git a/engines/sludge/sludger.h b/engines/sludge/sludger.h
index 8f554f8..2351cb9 100644
--- a/engines/sludge/sludger.h
+++ b/engines/sludge/sludger.h
@@ -67,7 +67,6 @@ void killSludge();
 void displayBase();
 void sludgeDisplay();
 int startNewFunctionNum(uint, uint, LoadedFunction *, VariableStack*&, bool = true);
-bool handleInput();
 void restartFunction(LoadedFunction *fun);
 bool loadFunctionCode(LoadedFunction *newFunc);
 void killAllFunctions();
diff --git a/engines/sludge/timing.cpp b/engines/sludge/timing.cpp
index 2e38654..c291f57 100644
--- a/engines/sludge/timing.cpp
+++ b/engines/sludge/timing.cpp
@@ -25,31 +25,63 @@
 
 namespace Sludge {
 
+Timer::Timer(){
+	reset();
+}
+
+void Timer::reset(void) {
+	_desiredFPS = 300;
+	_startTime = 0;
+	_endTime = 0;
+	_desiredFrameTime = 0;
+	_addNextTime = 0;
+
+	// FPS stats
+	_lastFPS = -1;
+	_thisFPS = -1;
+	_lastSeconds = 0;
+}
+
 void Timer::init(void) {
-	_desired_frame_time = 1000 / _desiredfps;
-	_starttime = g_system->getMillis();
+	_desiredFrameTime = 1000 / _desiredFPS;
+	_startTime = g_system->getMillis();
 }
 
 void Timer::initSpecial(int t) {
-	_desired_frame_time = 1000 / t;
-	_starttime = g_system->getMillis();
+	_desiredFrameTime = 1000 / t;
+	_startTime = g_system->getMillis();
+}
+
+void Timer::updateFpsStats() {
+	uint32 currentSeconds = g_system->getMillis() / 1000;
+	if (_lastSeconds != currentSeconds) {
+		_lastSeconds = currentSeconds;
+		_lastFPS = _thisFPS;
+		_thisFPS = 1;
+	} else {
+		++_thisFPS;
+	}
 }
 
 void Timer::waitFrame(void) {
-	static uint32 addNextTime = 0;
 	uint32 timetaken;
 
 	for (;;) {
-		_endtime = g_system->getMillis();
-		timetaken = addNextTime + _endtime - _starttime;
-		if (timetaken >= _desired_frame_time) break;
+		_endTime = g_system->getMillis();
+		timetaken = _addNextTime + _endTime - _startTime;
+		if (timetaken >= _desiredFrameTime)
+			break;
 		g_system->delayMillis(1);
 	}
 
-	addNextTime = timetaken - _desired_frame_time;
-	if (addNextTime > _desired_frame_time) addNextTime = _desired_frame_time;
+	_addNextTime = timetaken - _desiredFrameTime;
+	if (_addNextTime > _desiredFrameTime)
+		_addNextTime = _desiredFrameTime;
+
+	_startTime = _endTime;
 
-	_starttime = _endtime;
+	// Stats
+	updateFpsStats();
 }
 
 } // End of namespace Sludge
diff --git a/engines/sludge/timing.h b/engines/sludge/timing.h
index 0d7ffec..e04ddf4 100644
--- a/engines/sludge/timing.h
+++ b/engines/sludge/timing.h
@@ -25,18 +25,28 @@
 namespace Sludge {
 
 class Timer {
-private:
-	int _desiredfps; // desired frames per second
-	uint32 _starttime, _endtime;
-	uint32 _desired_frame_time;
-
 public:
-	void setDesiredfps(int t) { _desiredfps = t; }
+	Timer();
+
+	void setDesiredFPS(int t) { _desiredFPS = t; }
+	void reset(void);
 	void init(void);
 	void initSpecial(int t);
 	void waitFrame(void);
 
-	Timer():_desiredfps(300), _starttime(0), _endtime(0), _desired_frame_time(0){}
+	int getLastFps() const { return _lastFPS; }
+
+private:
+	int _desiredFPS; // desired frames per second
+	uint32 _startTime, _endTime;
+	uint32 _desiredFrameTime;
+	uint32 _addNextTime;
+
+	// FPS stats
+	void updateFpsStats();
+	int _lastFPS;
+	int _thisFPS;
+	uint32 _lastSeconds;
 };
 
 } // End of namespace Sludge





More information about the Scummvm-git-logs mailing list