[Scummvm-cvs-logs] CVS: scummvm/queen display.cpp,1.61,1.62 display.h,1.44,1.45 graphics.cpp,1.99,1.100

Gregory Montoir cyx at users.sourceforge.net
Thu Mar 18 14:04:03 CET 2004


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

Modified Files:
	display.cpp display.h graphics.cpp 
Log Message:
minor cleanup

Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- display.cpp	17 Mar 2004 14:10:51 -0000	1.61
+++ display.cpp	18 Mar 2004 21:53:49 -0000	1.62
@@ -134,10 +134,7 @@
 	}
 
 	uint offset = (y / 4) * 160 + (x / 4);
-	if (offset >= sizeof(_dynalum.msk)) {
-		debug(6, "Graphics::dynalumUpdate(%d, %d) - invalid offset: %08x", x, y, offset);
-		return;
-	}
+	assert(offset < sizeof(_dynalum.msk));
 
 	uint8 colMask = _dynalum.msk[offset];
 	debug(9, "Display::dynalumUpdate(%d, %d) - colMask = %d", x, y, colMask);
@@ -350,7 +347,7 @@
 			j += jdir;
 			if(j <= 0 || j >= 14) {
 				jdir = -jdir;
-				if (_vm->randomizer.getRandomNumber(1)) {
+				if (_rnd.getRandomNumber(1)) {
 					if (ABS(jdir) == 1) {
 						jdir *= 2;
 					} else {
@@ -956,8 +953,8 @@
 	uint8 buf[32 * 32];
 	while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
 		for(int i = 0; i < 2; ++i) {    
-			uint16 x = _vm->randomizer.getRandomNumber(SCREEN_W - 32 - 2) + 1;
-			uint16 y = _vm->randomizer.getRandomNumber(SCREEN_H - 32 - 2) + 1;
+			uint16 x = _rnd.getRandomNumber(SCREEN_W - 32 - 2) + 1;
+			uint16 y = _rnd.getRandomNumber(SCREEN_H - 32 - 2) + 1;
 			uint8 *p = _screenBuf + SCREEN_W * y + x;
 			uint8 *q = buf;
 			uint16 h = 32;
@@ -966,16 +963,9 @@
 				p += SCREEN_W;
 				q += 32;
 			}
-			if (_vm->randomizer.getRandomNumber(1)) {
-				--x;
-			} else {
-				++x;
-			}
-			if (_vm->randomizer.getRandomNumber(1)) {
-				--y;
-			} else {
-				++y;
-			}
+			const int inc[] = { -1, 1 };
+			x += inc[_rnd.getRandomNumber(1)];
+			y += inc[_rnd.getRandomNumber(1)];
 			_system->copy_rect(buf, 32, x, y, 32, 32);
 			_system->updateScreen();
 			_vm->input()->delay(10);
@@ -985,11 +975,11 @@
 
 void Display::blankScreenEffect2() {
 	while (_vm->input()->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
-		uint16 x = _vm->randomizer.getRandomNumber(SCREEN_W - 2);
-		uint16 y = _vm->randomizer.getRandomNumber(SCREEN_H - 2);
+		uint16 x = _rnd.getRandomNumber(SCREEN_W - 2);
+		uint16 y = _rnd.getRandomNumber(SCREEN_H - 2);
 		uint8 *p = _screenBuf + y * SCREEN_W + x;
 		uint8 c = 0;
-		switch (_vm->randomizer.getRandomNumber(3)) {
+		switch (_rnd.getRandomNumber(3)) {
 		case 0:
 			c = *p;
 			break;
@@ -1022,8 +1012,8 @@
 			memset(_screenBuf, 0, SCREEN_W * SCREEN_H);
 			_system->copy_rect(_screenBuf, SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);			
 		} else {
-			uint16 x = _vm->randomizer.getRandomNumber(SCREEN_W - 2);
-			uint16 y = _vm->randomizer.getRandomNumber(SCREEN_H - 2);
+			uint16 x = _rnd.getRandomNumber(SCREEN_W - 2);
+			uint16 y = _rnd.getRandomNumber(SCREEN_H - 2);
 			uint8 *p = _screenBuf + SCREEN_W * y + x;
 			uint8 p0 = *p;
 			uint8 p1 = *(p + 1);

Index: display.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- display.h	17 Mar 2004 14:10:51 -0000	1.44
+++ display.h	18 Mar 2004 21:53:49 -0000	1.45
@@ -170,6 +170,7 @@
 
 	bool _gotTick;	
 
+	Common::RandomSource _rnd;
 	Dynalum _dynalum;
 	OSystem *_system;
 	QueenEngine *_vm;

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- graphics.cpp	17 Mar 2004 14:10:51 -0000	1.99
+++ graphics.cpp	18 Mar 2004 21:53:49 -0000	1.100
@@ -310,37 +310,19 @@
 	assert(new_w * new_h < BOB_SHRINK_BUF_SIZE);
 
 	if (new_w != 0 && new_h != 0) {
-
 		_shrinkBuffer.width  = new_w;
 		_shrinkBuffer.height = new_h;
 
-		uint32 shrinker = (100 << 0x10) / percentage;
-		uint16 x_scale = shrinker >> 0x10;
-		uint16 y_scale = x_scale * bf->width;   
-		shrinker &= 0xFFFF;
-
-		uint8* src = bf->data;
+		uint16 x, y;
+		uint16 sh[GAME_SCREEN_WIDTH];
+		for (x = 0; x < MAX(new_h, new_w); ++x) {
+			sh[x] = x * 100 / percentage;
+		}
 		uint8* dst = _shrinkBuffer.data;
-
-		uint32 y_count = 0;
-		while (new_h--) {
-			uint16 i;
-			uint32 x_count = 0;
-			uint8 *p = src;
-			for(i = 0; i < new_w; ++i) {
-				*dst++ = *p;
-				p += x_scale;
-				x_count += shrinker;
-				if (x_count > 0xFFFF) {
-					++p;
-					x_count &= 0xFFFF;
-				}
-			}
-			src += y_scale;
-			y_count += shrinker;
-			if (y_count > 0xFFFF) {
-				src += bf->width;
-				y_count &= 0xFFFF;
+		for (y = 0; y < new_h; ++y) {
+			uint8 *p = bf->data + sh[y] * bf->width;
+			for(x = 0; x < new_w; ++x) {
+				*dst++ = *(p + sh[x]);
 			}
 		}
 	}





More information about the Scummvm-git-logs mailing list