[Scummvm-cvs-logs] scummvm master -> b79fd7e965e2792a18e477b830067182f35a216a

dreammaster dreammaster at scummvm.org
Sun Jul 21 00:48:18 CEST 2013


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:
b79fd7e965 TSAGE: Work on setup of R2R engine palette maps


Commit: b79fd7e965e2792a18e477b830067182f35a216a
    https://github.com/scummvm/scummvm/commit/b79fd7e965e2792a18e477b830067182f35a216a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2013-07-20T15:46:55-07:00

Commit Message:
TSAGE: Work on setup of R2R engine palette maps

Changed paths:
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/ringworld2/ringworld2_logic.cpp
    engines/tsage/ringworld2/ringworld2_logic.h
    engines/tsage/ringworld2/ringworld2_scenes0.cpp
    engines/tsage/ringworld2/ringworld2_scenes0.h



diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index b6ed17a..7ca529f 100644
--- a/engines/tsage/core.cpp
+++ b/engines/tsage/core.cpp
@@ -4291,10 +4291,15 @@ void SceneHandler::dispatch() {
 			GUIErrorMessage(SAVE_ERROR_MSG);
 	}
 	if (_loadGameSlot != -1) {
+		int priorSceneBeforeLoad = GLOBALS._sceneManager._previousScene;
+		int currentSceneBeforeLoad = GLOBALS._sceneManager._sceneNumber;
+
 		int loadSlot = _loadGameSlot;
 		_loadGameSlot = -1;
 		g_saver->restore(loadSlot);
 		g_globals->_events.setCursorFromFlag();
+
+		postLoad(priorSceneBeforeLoad, currentSceneBeforeLoad);
 	}
 
 	g_globals->_soundManager.dispatch();
diff --git a/engines/tsage/core.h b/engines/tsage/core.h
index 655bd23..1f9d7cd 100644
--- a/engines/tsage/core.h
+++ b/engines/tsage/core.h
@@ -900,6 +900,7 @@ public:
 protected:
 	virtual void playerAction(Event &event) {}
 	virtual void processEnd(Event &event) {}
+	virtual void postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad) {}
 public:
 	SceneHandler();
 	void registerHandler();
diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp
index 27cda63..316fb58 100644
--- a/engines/tsage/globals.cpp
+++ b/engines/tsage/globals.cpp
@@ -389,8 +389,10 @@ void Ringworld2Globals::reset() {
 	_scrollFollower = &_player;
 
 	// Reset fields
-	Common::fill(&_v1000[0], &_v1000[0x1000], 0);
-	_v1000Flag = false;
+	Common::fill(&_fadePaletteMap[0][0], &_fadePaletteMap[10][256], 0);
+	Common::fill(&_paletteMap[0], &_paletteMap[4096], 0);
+
+	_fadePaletteFlag = false;
 	_v5589E.set(0, 0, 0, 0);
 	_v558B6.set(0, 0, 0, 0);
 	_v558C2 = 0;
diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h
index 40254bd..ed27ff0 100644
--- a/engines/tsage/globals.h
+++ b/engines/tsage/globals.h
@@ -254,9 +254,9 @@ public:
 	ASoundExt _sound1, _sound2, _sound3, _sound4;
 	PlayStream _playStream;
 	StripProxy _stripProxy;
-	bool _v1000Flag;
-	byte _v1000[0x1000];
-	byte _palIndexList[10][256];
+	bool _fadePaletteFlag;
+	byte _fadePaletteMap[10][256];
+	byte _paletteMap[4096];
 	int _insetUp;
 	int _frameEdgeColour;	// _v421e
 	Rect _v5589E;
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 6dabbbc..c98d40e 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -339,8 +339,7 @@ void SceneExt::postInit(SceneObjectList *OwnerList) {
 	int sceneNumber = R2_GLOBALS._sceneManager._sceneNumber;
 	if (((prevScene == -1) && (sceneNumber != 180) && (sceneNumber != 205) && (sceneNumber != 50))
 			|| (sceneNumber == 50)
-			|| ((prevScene == 205) && (sceneNumber == 100))
-			|| ((prevScene == 180) && (sceneNumber == 100))) {
+			|| ((sceneNumber == 100) && (prevScene == 0 || prevScene == 180 || prevScene == 205))) {
 		static_cast<SceneHandlerExt *>(R2_GLOBALS._sceneHandler)->setupPaletteMaps();
 		R2_GLOBALS._uiElements._active = true;
 		R2_GLOBALS._uiElements.show();
@@ -425,12 +424,12 @@ bool SceneExt::display(CursorType action, Event &event) {
 			R2_GLOBALS._sound4.stop();
 			R2_GLOBALS._sound3.play(46);
 			SceneItem::display2(5, 15);
+
+			R2_GLOBALS._sound4.play(45);
 		} else {
 			R2_GLOBALS._sound3.play(43, 0);
 			SceneItem::display2(2, R2_SONIC_STUNNER);
 		}
-
-		R2_GLOBALS._sound4.play(45);
 		break;
 	case R2_COM_SCANNER:
 	case R2_COM_SCANNER_2:
@@ -596,11 +595,32 @@ void SceneHandlerExt::process(Event &event) {
 		SceneHandler::process(event);
 }
 
+void SceneHandlerExt::postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad) {
+	if (priorSceneBeforeLoad == -1 || priorSceneBeforeLoad == 50
+			|| priorSceneBeforeLoad == 180 || priorSceneBeforeLoad == 205)
+		setupPaletteMaps();
+
+	if (currentSceneBeforeLoad == 2900) {
+		R2_GLOBALS._gfxFontNumber = 50;
+		R2_GLOBALS._gfxColors.background = 0;
+		R2_GLOBALS._gfxColors.foreground = 59;
+		R2_GLOBALS._fontColors.background = 4;
+		R2_GLOBALS._fontColors.foreground = 15;
+		R2_GLOBALS._frameEdgeColour = 2;
+
+		R2_GLOBALS._scenePalette.loadPalette(0);
+		R2_GLOBALS._scenePalette.setEntry(255, 0xff, 0xff, 0xff);
+		R2_GLOBALS._fadePaletteFlag = false;
+		setupPaletteMaps();
+	}
+}
+
 void SceneHandlerExt::setupPaletteMaps() {
 	byte *palP = &R2_GLOBALS._scenePalette._palette[0];
 
-	if (!R2_GLOBALS._v1000Flag) {
-		R2_GLOBALS._v1000Flag = true;
+	// Set up the mapping table for giving faded versions of pixels at different fade percentages
+	if (!R2_GLOBALS._fadePaletteFlag) {
+		R2_GLOBALS._fadePaletteFlag = true;
 
 		for (int idx = 0; idx < 10; ++idx) {
 			for (int palIndex = 0; palIndex < 224; ++palIndex) {
@@ -650,7 +670,7 @@ void SceneHandlerExt::setupPaletteMaps() {
 					foundIndex = pIndex2;
 				}
 
-				R2_GLOBALS._palIndexList[idx][palIndex] = foundIndex;
+				R2_GLOBALS._fadePaletteMap[idx][palIndex] = foundIndex;
 			}
 		}
 	}
@@ -660,8 +680,8 @@ void SceneHandlerExt::setupPaletteMaps() {
 		int g = palP[palIndex * 3 + 1] >> 2;
 		int b = palP[palIndex * 3 + 2] >> 2;
 
-		int idx = (((r << 4) | g) << 4) | b;
-		R2_GLOBALS._v1000[idx] = palIndex;
+		int v = (r << 8) | (g << 4) | b;
+		R2_GLOBALS._paletteMap[v] = palIndex;
 	}
 
 	int vdx = 0;
@@ -669,9 +689,9 @@ void SceneHandlerExt::setupPaletteMaps() {
 	int palIndex = 224;
 
 	for (int vIndex = 0; vIndex < 4096; ++vIndex) {
-		int v = R2_GLOBALS._v1000[vIndex];
+		int v = R2_GLOBALS._paletteMap[vIndex];
 		if (!v) {
-			R2_GLOBALS._v1000[vIndex] = idx;
+			R2_GLOBALS._paletteMap[vIndex] = idx;
 		} else {
 			idx = v;
 		}
@@ -1259,6 +1279,32 @@ bool SceneActor::startAction(CursorType action, Event &event) {
 	return handled;
 }
 
+GfxSurface SceneActor::getFrame() {
+	GfxSurface frame = SceneObject::getFrame();
+
+	// TODO: Proper effects handling
+	switch (_effect) {
+	case 0:
+	case 5:
+		// TODO: Figure out purpose of setting image flags to 64, and getting
+		// scene priorities -1 or _shade
+		break;
+	case 1:
+		// TODO: Transposing using R2_GLOBALS._pixelArrayMap
+		break;
+	case 2:
+		// No effect
+		break;
+	case 4:
+		break;
+	default:
+		// TODO: Default effect
+		break;
+	}
+
+	return frame;
+}
+
 /*--------------------------------------------------------------------------*/
 
 SceneArea::SceneArea(): EventHandler() {
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index 2e7dd64..42ca071 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -114,6 +114,7 @@ class SceneHandlerExt: public SceneHandler {
 public:
 	virtual void postInit(SceneObjectList *OwnerList = NULL);
 	virtual void process(Event &event);
+	virtual void postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad);
 
 	void setupPaletteMaps();
 };
@@ -265,6 +266,7 @@ public:
 	virtual void postInit(SceneObjectList *OwnerList = NULL);
 	virtual void remove();
 	virtual bool startAction(CursorType action, Event &event);
+	virtual GfxSurface getFrame();
 };
 
 class SceneActorExt: public SceneActor {
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
index 634ecf3..92e92ea 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
@@ -226,9 +226,9 @@ bool Scene100::Terminal::startAction(CursorType action, Event &event) {
 /*--------------------------------------------------------------------------*/
 
 void Scene100::postInit(SceneObjectList *OwnerList) {
-	SceneExt::postInit();
 	loadScene(100);
 	R2_GLOBALS._scenePalette.loadPalette(0);
+	SceneExt::postInit();
 
 	if (R2_GLOBALS._sceneManager._previousScene != 125)
 		R2_GLOBALS._sound1.play(10);
@@ -5345,20 +5345,6 @@ void Scene525::signal() {
  *
  *--------------------------------------------------------------------------*/
 
-Scene600::Scene600() {
-	_field412 = 0;
-	for (int i = 0; i < 256; i++)
-		_fieldAD2[i] = 0;
-}
-
-void Scene600::synchronize(Serializer &s) {
-	SceneExt::synchronize(s);
-
-	s.syncAsSint16LE(_field412);
-	for (int i = 0; i < 256; i++)
-		s.syncAsByte(_fieldAD2[i]);
-}
-
 bool Scene600::CompartmentHotspot::startAction(CursorType action, Event &event) {
 	if ((action != R2_NEGATOR_GUN) || (!R2_GLOBALS.getFlag(5)) || (R2_GLOBALS.getFlag(8)))
 		return SceneHotspot::startAction(action, event);
@@ -5415,9 +5401,22 @@ bool Scene600::Actor4::startAction(CursorType action, Event &event) {
 	return false;
 }
 
-void Scene600::Actor4::draw() {
-	warning("TODO: Actor4::draw()");
-	SceneActor::draw();
+GfxSurface Scene600::Actor4::getFrame() {
+	GfxSurface frame = SceneActor::getFrame();
+
+	if (_effect) {
+		// Translate the frame using the scene's pixel map
+		byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap;
+		Graphics::Surface surface = frame.lockSurface();
+		byte *srcP = (byte *)surface.pixels;
+
+		while (srcP < ((byte *)surface.pixels + (surface.w * surface.h)))
+			*srcP++ = pixelMap[*srcP];
+
+		frame.unlockSurface();
+	}
+
+	return frame;
 }
 
 bool Scene600::Doorway::startAction(CursorType action, Event &event) {
@@ -5545,6 +5544,21 @@ bool Scene600::Aerosol::startAction(CursorType action, Event &event) {
 	}
 }
 
+/*--------------------------------------------------------------------------*/
+
+Scene600::Scene600() {
+	_field412 = 0;
+	Common::fill(&_pixelMap[0], &_pixelMap[256], 0);
+}
+
+void Scene600::synchronize(Serializer &s) {
+	SceneExt::synchronize(s);
+
+	s.syncAsSint16LE(_field412);
+	for (int i = 0; i < 256; i++)
+		s.syncAsByte(_pixelMap[i]);
+}
+
 bool Scene600::Actor8::startAction(CursorType action, Event &event) {
 	Scene600 *scene = (Scene600 *)R2_GLOBALS._sceneManager._scene;
 
@@ -5570,7 +5584,15 @@ void Scene600::postInit(SceneObjectList *OwnerList) {
 	R2_GLOBALS._walkRegions.enableRegion(3);
 	_field412 = 0;
 
-	warning("FIXME: loop to initialize _fieldAD2[]");
+	// Initialise pixel map for the obscuring effect
+	ScenePalette &pal = R2_GLOBALS._scenePalette;
+	uint r, g, b;
+	for (int i = 0; i < 256; ++i) {
+		pal.getEntry(i, &r, &g, &b);
+		int av = ((r + g + b) / 48);
+
+		_pixelMap[i] = R2_GLOBALS._paletteMap[(av << 8) | (av << 4) | av];
+	}
 
 	_doorway.postInit();
 	_doorway.setVisage(600);
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h
index 58dad85..51cdd88 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.h
@@ -628,7 +628,7 @@ class Scene600 : public SceneExt {
 	public:
 		virtual void signal();
 		virtual bool startAction(CursorType action, Event &event);
-		virtual void draw();
+		virtual GfxSurface getFrame();
 	};
 	class Doorway : public SceneActor {
 	public:
@@ -665,7 +665,7 @@ public:
 	ASoundExt _aSound1;
 	SequenceManager _sequenceManager1;
 	SequenceManager _sequenceManager2;
-	byte _fieldAD2[256];
+	byte _pixelMap[256];
 
 	Scene600();
 	virtual void postInit(SceneObjectList *OwnerList = NULL);






More information about the Scummvm-git-logs mailing list