[Scummvm-cvs-logs] CVS: scummvm/sword1 animation.h,1.3,1.4 animation.cpp,1.6,1.7

Max Horn fingolfin at users.sourceforge.net
Fri Jan 30 13:07:25 CET 2004


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

Modified Files:
	animation.h animation.cpp 
Log Message:
avoid using huge static structs - they can't be stripped, and increase the exe size (in this case, 16 MB...)

Index: animation.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/animation.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- animation.h	30 Jan 2004 20:47:21 -0000	1.3
+++ animation.h	30 Jan 2004 20:57:23 -0000	1.4
@@ -111,10 +111,8 @@
 		byte pal[4 * 256];
 	} palettes[50];
 #else
-	static NewGuiColor lookup2[BITDEPTH * BITDEPTH * 256];
+	static NewGuiColor *lookup;
 	NewGuiColor * overlay;
-	static bool lookupInit;
-
 #endif
 
 public:
@@ -131,7 +129,7 @@
 	void buildLookup(int p, int lines);
 	bool checkPaletteSwitch();
 #else
-	void buildLookup2(void);
+	void buildLookup(void);
 	void plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat);
 #endif
 };

Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/animation.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- animation.cpp	30 Jan 2004 20:47:21 -0000	1.6
+++ animation.cpp	30 Jan 2004 20:57:23 -0000	1.7
@@ -103,7 +103,7 @@
 	lut2 = lookup[1];
 	lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2);
 #else
-	buildLookup2();
+	buildLookup();
 	overlay = (NewGuiColor*)calloc(640 * 400, sizeof(NewGuiColor));
 	_sys->show_overlay();
 #endif
@@ -217,13 +217,13 @@
 
 #else
 
-bool AnimationState::lookupInit = false;
-NewGuiColor AnimationState::lookup2[BITDEPTH * BITDEPTH * 256];
+NewGuiColor *AnimationState::lookup = 0;
 
-void AnimationState::buildLookup2() {
+void AnimationState::buildLookup() {
+	if (lookup)
+		return;
 
-	if (lookupInit) return;
-	lookupInit = true;
+	lookup = (NewGuiColor *)calloc(BITDEPTH * BITDEPTH * 256, sizeof(NewGuiColor));
 
 	int y, cb, cr;
 	int r, g, b;
@@ -237,13 +237,13 @@
 				b = ((y-16) * 256 + (int) (2.018 * 256) * ((cb << SHIFT) - 128)) / 256;
 
 				if (r < 0) r = 0;
-				if (r > 255) r = 255;
+				else if (r > 255) r = 255;
 				if (g < 0) g = 0;
-				if (g > 255) g = 255;
+				else if (g > 255) g = 255;
 				if (b < 0) b = 0;
-				if (b > 255) b = 255;
+				else if (b > 255) b = 255;
 
-				lookup2[pos++] = _sys->RGBToColor(r, g, b);
+				lookup[pos++] = _sys->RGBToColor(r, g, b);
 			}
 		}
 	}
@@ -340,7 +340,7 @@
 #else
 
 				if ((bgSoundStream == NULL) || (bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < (framenum+3)){
-					plotYUV(lookup2, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
+					plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
 
 					if (bgSoundStream) {
 						while ((bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < framenum+1)





More information about the Scummvm-git-logs mailing list