[Scummvm-cvs-logs] SF.net SVN: scummvm:[41453] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Thu Jun 11 20:32:35 CEST 2009


Revision: 41453
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41453&view=rev
Author:   buddha_
Date:     2009-06-11 18:32:35 +0000 (Thu, 11 Jun 2009)

Log Message:
-----------
Fix Operation Stealth's 2nd arcade sequence's revolving doors.
- Now the doors actually do revolve when before they didn't.
- The fix was to alias the 9th background with the collision
  page directly when loading collision page data. This way
  changes written to the 9th background go to the collision
  page and vice versa (And there were changes in the labyrinth).
- Also converted _bgTable from a pure array to a Common::Array

Modified Paths:
--------------
    scummvm/trunk/engines/cine/bg.cpp
    scummvm/trunk/engines/cine/gfx.cpp
    scummvm/trunk/engines/cine/gfx.h

Modified: scummvm/trunk/engines/cine/bg.cpp
===================================================================
--- scummvm/trunk/engines/cine/bg.cpp	2009-06-11 15:45:52 UTC (rev 41452)
+++ scummvm/trunk/engines/cine/bg.cpp	2009-06-11 18:32:35 UTC (rev 41453)
@@ -82,7 +82,6 @@
 	ptr += 2;
 
 	if (bpp == 8) {
-		memcpy(collisionPage, ptr + 256 * 3, 320 * 200);
 		renderer->loadCt256(ptr, ctName);
 	} else {
 		gfxConvertSpriteToRaw(collisionPage, ptr + 32, 160, 200);

Modified: scummvm/trunk/engines/cine/gfx.cpp
===================================================================
--- scummvm/trunk/engines/cine/gfx.cpp	2009-06-11 15:45:52 UTC (rev 41452)
+++ scummvm/trunk/engines/cine/gfx.cpp	2009-06-11 18:32:35 UTC (rev 41453)
@@ -874,35 +874,25 @@
 
 /*! \brief Initialize Operation Stealth renderer
  */
-OSRenderer::OSRenderer() : FWRenderer(), _currentBg(0), _scrollBg(0),
+OSRenderer::OSRenderer() : FWRenderer(), _bgTable(), _currentBg(0), _scrollBg(0),
 	_bgShift(0) {
 
-	int i;
-	for (i = 0; i < 9; i++) {
-		_bgTable[i].bg = NULL;
-		_bgTable[i].pal.clear();
-		memset(_bgTable[i].name, 0, sizeof (_bgTable[i].name));
-	}
+	_bgTable.resize(9); // Resize the background table to its required size
 }
 
 /*! \brief Destroy Operation Stealth renderer
  */
 OSRenderer::~OSRenderer() {
-	for (int i = 0; i < 9; i++) {
-		delete[] _bgTable[i].bg;
-		_bgTable[i].pal.clear();
+	for (uint i = 0; i < _bgTable.size(); i++) {
+		_bgTable[i].clear();
 	}
 }
 
 /*! \brief Reset Operation Stealth renderer state
  */
 void OSRenderer::clear() {
-	for (int i = 0; i < 9; i++) {
-		delete[] _bgTable[i].bg;
-
-		_bgTable[i].bg = NULL;
-		_bgTable[i].pal.clear();
-		memset(_bgTable[i].name, 0, sizeof (_bgTable[i].name));
+	for (uint i = 0; i < _bgTable.size(); i++) {
+		_bgTable[i].clear();
 	}
 
 	_currentBg = 0;
@@ -1172,7 +1162,10 @@
  * \param name Background filename
  */
 void OSRenderer::loadCt16(const byte *ct, const char *name) {
-	loadBg16(ct, name, 8);
+	// Make the 9th background point directly to the collision page
+	// and load the picture into it.
+	_bgTable[kCollisionPageBgIdxAlias].bg = collisionPage;
+	loadBg16(ct, name, kCollisionPageBgIdxAlias);
 }
 
 /*! \brief Load 256 color background into renderer
@@ -1199,7 +1192,10 @@
  * \param name Background filename
  */
 void OSRenderer::loadCt256(const byte *ct, const char *name) {
-	loadBg256(ct, name, 8);
+	// Make the 9th background point directly to the collision page
+	// and load the picture into it.
+	_bgTable[kCollisionPageBgIdxAlias].bg = collisionPage;
+	loadBg256(ct, name, kCollisionPageBgIdxAlias);
 }
 
 /*! \brief Select active background and load its palette
@@ -1255,10 +1251,7 @@
 		_scrollBg = 0;
 	}
 
-	delete[] _bgTable[idx].bg;
-	_bgTable[idx].bg = NULL;
-	_bgTable[idx].pal.clear();
-	memset(_bgTable[idx].name, 0, sizeof (_bgTable[idx].name));
+	_bgTable[idx].clear();
 }
 
 void OSRenderer::saveBgNames(Common::OutSaveFile &fHandle) {

Modified: scummvm/trunk/engines/cine/gfx.h
===================================================================
--- scummvm/trunk/engines/cine/gfx.h	2009-06-11 15:45:52 UTC (rev 41452)
+++ scummvm/trunk/engines/cine/gfx.h	2009-06-11 18:32:35 UTC (rev 41453)
@@ -31,12 +31,34 @@
 
 namespace Cine {
 
+extern byte *collisionPage;
+static const int kCollisionPageBgIdxAlias = 8;
+
 /*! \brief Background with palette
  */
 struct palBg {
 	byte *bg; ///< Background data
 	Cine::Palette pal; ///< Background color palette
 	char name[15]; ///< Background filename
+
+	/** @brief Default constructor. */
+	palBg() : bg(NULL), pal(), name() {
+		// Make sure the name is empty (Maybe this is not needed?)
+		memset(this->name, 0, sizeof(this->name));
+	}
+
+	/** @brief Clears the struct (Releases allocated memory etc). */
+	void clear() {
+		// In Operation Stealth the 9th background is sometimes aliased to
+		// the collision page so we should take care not to double delete it
+		// (The collision page is deleted elsewhere).
+		if (this->bg != collisionPage) {
+			delete[] this->bg;
+		}
+		this->bg = NULL;
+		this->pal.clear();
+		memset(this->name, 0, sizeof(this->name));
+	}
 };
 
 /*! \brief Future Wars renderer
@@ -129,8 +151,7 @@
  */
 class OSRenderer : public FWRenderer {
 private:
-	// FIXME: Background table's size is probably 8 instead of 9. Check to make sure and correct if necessary.
-	palBg _bgTable[9]; ///< Table of backgrounds loaded into renderer
+	Common::Array<palBg> _bgTable; ///< Table of backgrounds loaded into renderer (Maximum is 9)
 	unsigned int _currentBg; ///< Current background
 	unsigned int _scrollBg; ///< Current scroll background
 	unsigned int _bgShift; ///< Background shift
@@ -175,7 +196,6 @@
 
 void gfxDrawSprite(byte *src4, uint16 sw, uint16 sh, byte *dst4, int16 sx, int16 sy);
 
-extern byte *collisionPage;
 extern FWRenderer *renderer;
 
 void setMouseCursor(int cursor);


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