[Scummvm-cvs-logs] CVS: residual driver_tinygl.cpp,1.28,1.29 engine.cpp,1.88,1.89 engine.h,1.34,1.35 lua.cpp,1.152,1.153

Pawel Kolodziejski aquadran at users.sourceforge.net
Sat Aug 13 09:27:00 CEST 2005


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4707

Modified Files:
	driver_tinygl.cpp engine.cpp engine.h lua.cpp 
Log Message:
next main loop changes and few others

Index: driver_tinygl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- driver_tinygl.cpp	13 Aug 2005 11:33:12 -0000	1.28
+++ driver_tinygl.cpp	13 Aug 2005 16:25:51 -0000	1.29
@@ -103,7 +103,7 @@
 	_screenBPP = screenBPP;
 	_isFullscreen = fullscreen;
 
-	SDL_WM_SetCaption("Residual: Modified TinyGL - Software Renderer", "Residual");
+	SDL_WM_SetCaption("Residual: Software 3D Renderer", "Residual");
 
 	_zb = ZB_open(screenW, screenH, ZB_MODE_5R6G5B, 0, NULL, NULL, _screen->pixels);
 	tglInit(_zb);

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- engine.cpp	13 Aug 2005 13:35:43 -0000	1.88
+++ engine.cpp	13 Aug 2005 16:25:51 -0000	1.89
@@ -59,6 +59,8 @@
 	_speechMode = 3; // VOICE + TEXT
 	_textSpeed = 6;
 	_mode = _previousMode = ENGINE_MODE_IDLE;
+	_flipEnable = true;
+	_refreshDrawNeeded = true;
 	g_searchFile = NULL;
 
 	textObjectDefaults.x = 0;
@@ -111,68 +113,6 @@
 	lua_endblock();
 }
 
-void Engine::updateScreen() {
-	g_driver->clearScreen();
-
-	if (_currScene != NULL) {
-		_currScene->drawBackground();
-	}
-
-	// Draw underlying scene components
-	if (_currScene != NULL) {
-		// Background objects are drawn underneath everything except the background
-		// There are a bunch of these, especially in the tube-switcher room
-		_currScene->drawBitmaps(ObjectState::OBJSTATE_BACKGROUND);
-		// Underlay objects are just above the background
-		_currScene->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
-		// State objects are drawn on top of other things, such as the flag
-		// on Manny's message tube
-		_currScene->drawBitmaps(ObjectState::OBJSTATE_STATE);
-	}
-
-	// Play SMUSH Animations
-	// This should occur on top of all underlying scene objects,
-	// a good example is the tube switcher room where some state objects
-	// need to render underneath the animation or you can't see what's going on
-	// This should not occur on top of everything though or Manny gets covered
-	// up when he's next to Glottis's service room
-	if (g_smush->isPlaying()) {
-		_movieTime = g_smush->getMovieTime();
-		if (g_smush->isUpdateNeeded()) {
-			g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
-			g_smush->clearUpdateNeeded();
-		}
-		if (g_smush->getFrame() > 0)
-			g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
-	}
-
-	if (_currScene != NULL) {
-		_currScene->setupCamera();
-	}
-
-	g_driver->set3DMode();
-
-	if (_currScene != NULL) {
-		_currScene->setupLights();
-	}
-
-	// Draw actors
-	for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
-		Actor *a = *i;
-		if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
-			a->draw();
-		if (_currScene != NULL)
-			a->undraw(a->inSet(_currScene->name()) && a->visible());
-	}
-
-	// Draw overlying scene components
-	if (_currScene != NULL) {
-		// The overlay objects should be drawn on top of everything else,
-		// including 3D objects such as Manny and the message tube
-		_currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
-	}
-}
-
 void Engine::handleDebugLoadResource() {
 	void *resource;
 	int c, i = 0;
@@ -244,6 +184,7 @@
 
 	if (_mode == ENGINE_MODE_SMUSH) {
 		if (g_smush->isPlaying()) {
+			//_mode = ENGINE_MODE_NORMAL; ???
 			_movieTime = g_smush->getMovieTime();
 			if (g_smush->isUpdateNeeded()) {
 				g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
@@ -261,14 +202,83 @@
 			}
 		}
 	} else if (_mode == ENGINE_MODE_NORMAL) {
+		if (_currScene == NULL)
+			return;
+
+		// Update actor costumes & sets
+		for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
+			Actor *a = *i;
+
+			// Update the actor's costumes & chores
+			g_currentUpdatedActor = *i;
+			// Note that the actor need not be visible to update chores, for example:
+			// when Manny has just brought Meche back he is offscreen several times
+			// when he needs to perform certain chores
+			if (a->inSet(_currScene->name()))
+				a->update();
+		}
+		g_currentUpdatedActor = NULL;
+
 		_prevSmushFrame = 0;
-		updateScreen();
+
+		g_driver->clearScreen();
+
+		_currScene->drawBackground();
+
+		// Draw underlying scene components
+		// Background objects are drawn underneath everything except the background
+		// There are a bunch of these, especially in the tube-switcher room
+		_currScene->drawBitmaps(ObjectState::OBJSTATE_BACKGROUND);
+		// State objects are drawn on top of other things, such as the flag
+		// on Manny's message tube
+		_currScene->drawBitmaps(ObjectState::OBJSTATE_STATE);
+
+		// Play SMUSH Animations
+		// This should occur on top of all underlying scene objects,
+		// a good example is the tube switcher room where some state objects
+		// need to render underneath the animation or you can't see what's going on
+		// This should not occur on top of everything though or Manny gets covered
+		// up when he's next to Glottis's service room
+		if (g_smush->isPlaying()) {
+			_movieTime = g_smush->getMovieTime();
+			if (g_smush->isUpdateNeeded()) {
+				g_driver->prepareSmushFrame(g_smush->getWidth(), g_smush->getHeight(), g_smush->getDstPtr());
+				g_smush->clearUpdateNeeded();
+			}
+			if (g_smush->getFrame() > 0)
+				g_driver->drawSmushFrame(g_smush->getX(), g_smush->getY());
+		}
+
+		// Underlay objects are just above the background
+		_currScene->drawBitmaps(ObjectState::OBJSTATE_UNDERLAY);
+
+		_currScene->setupCamera();
+
+		g_driver->set3DMode();
+
+		_currScene->setupLights();
+
+		// Draw actors
+		for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
+			Actor *a = *i;
+			if (a->inSet(_currScene->name()) && a->visible())
+				a->draw();
+			a->undraw(a->inSet(_currScene->name()) && a->visible());
+		}
+
+		// Draw overlying scene components
+		// The overlay objects should be drawn on top of everything else,
+		// including 3D objects such as Manny and the message tube
+		_currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY);
 	} else if (_mode == ENGINE_MODE_DRAW) {
-		lua_beginblock();
-		lua_Object drawHandler = getEventHandler("userPaintHandler");
-		if (drawHandler != LUA_NOOBJECT)
-			lua_callfunction(drawHandler);
-		lua_endblock();
+		if (_refreshDrawNeeded) {
+			lua_beginblock();
+			lua_Object drawHandler = getEventHandler("userPaintHandler");
+			if (drawHandler != LUA_NOOBJECT)
+				lua_callfunction(drawHandler);
+			lua_endblock();
+		}
+		_refreshDrawNeeded = false;
 	}
 
 	// Draw Primitives
@@ -282,10 +292,11 @@
 		(*i)->draw();
 		doFlip = true;
 	}
+
 	if (SHOWFPS_GLOBAL)
 		g_driver->drawEmergString(550, 25, fps, Color(255, 255, 255));
 
-	if (doFlip)
+	if (doFlip && _flipEnable)
 		g_driver->flipBuffer();
 
 	// don't kill CPU
@@ -359,22 +370,6 @@
 
 		luaUpdate();
 
-		if (_mode == ENGINE_MODE_NORMAL) {
-			// Update actor costumes & sets
-			for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) {
-				Actor *a = *i;
-
-				// Update the actor's costumes & chores
-				g_currentUpdatedActor = *i;
-				// Note that the actor need not be visible to update chores, for example:
-				// when Manny has just brought Meche back he is offscreen several times
-				// when he needs to perform certain chores
-				if (_currScene != NULL && a->inSet(_currScene->name()))
-					a->update();
-			}
-			g_currentUpdatedActor = NULL;
-		}
-
 		if (_mode != ENGINE_MODE_PAUSE) {
 			updateDisplayScene();
 		}

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- engine.h	13 Aug 2005 13:35:43 -0000	1.34
+++ engine.h	13 Aug 2005 16:25:51 -0000	1.35
@@ -100,10 +100,12 @@
 	void setSpeechMode(int mode) { _speechMode = mode; }
 	int getSpeechMode() { return _speechMode; }
 
-	void updateScreen();
 	void handleDebugLoadResource();
 	void luaUpdate();
 	void updateDisplayScene();
+	void setFlipEnable(bool state) { _flipEnable = state; }
+	bool getFlipEnable() { return _flipEnable; }
+	void refreshDrawMode() { _refreshDrawNeeded = true; }
 
 	void mainLoop();
 	unsigned frameStart() const { return _frameStart; }
@@ -213,6 +215,8 @@
 	int _mode, _previousMode;
 	int _speechMode;
 	int _textSpeed;
+	bool _flipEnable;
+	bool _refreshDrawNeeded;
 
 	unsigned _frameStart, _frameTime, _movieTime;
 	unsigned int _frameTimeCollection;

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- lua.cpp	13 Aug 2005 13:35:43 -0000	1.152
+++ lua.cpp	13 Aug 2005 16:25:51 -0000	1.153
@@ -2956,6 +2956,7 @@
 		g_engine->setMode(ENGINE_MODE_DRAW);
 	} else if (lua_isnil(param1)) {
 		g_smush->pause(false);
+		g_engine->refreshDrawMode();
 		g_engine->setMode(g_engine->getPreviousMode());
 	} else {
 		error("RenderModeUser() Unknown type of param");
@@ -2970,33 +2971,25 @@
 
 static void Display() {
 	DEBUG_FUNCTION();
-
-	g_engine->updateScreen();
+	if (g_engine->getFlipEnable())
+		g_driver->flipBuffer();
 }
 
 static void EngineDisplay() {
-	lua_Object param1;
-	bool mode;
-
 	// it enable/disable updating display
 	DEBUG_FUNCTION();
-	param1 = lua_getparam(1);
-	if (lua_isnumber(param1)) {
-		mode = check_int(1) != 0;
-	} else if (lua_isnil(param1)) {
-		mode = false;
+	bool mode = check_int(1) != 0;
+	if (mode) {
+		g_engine->setFlipEnable(true);
 	} else {
-		error("EngineDisplay() Unknown type of param");
-	}
-	if (debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL) {
-		if (mode) {
-			printf("EngineDisplay() Enable\n");
-		} else {
-			printf("EngineDisplay() Disable\n");
-		}
+		g_engine->setFlipEnable(false);
 	}
 }
 
+static void ForceRefresh() {
+	g_engine->refreshDrawMode();
+}
+
 static void JustLoaded() {
 	DEBUG_FUNCTION();
 	if(debugLevel == DEBUG_ERROR || debugLevel == DEBUG_ALL)
@@ -3109,7 +3102,6 @@
 STUB_FUNC(SetActorShadowPlane)
 STUB_FUNC(ActivateActorShadow)
 STUB_FUNC(SetShadowColor)
-STUB_FUNC(ForceRefresh)
 STUB_FUNC(LightMgrStartup)
 STUB_FUNC(SetLightIntensity)
 STUB_FUNC(SetLightPosition)





More information about the Scummvm-git-logs mailing list