[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.100,1.101 gfx.cpp,1.44,1.45 gfx.h,1.22,1.23 interface.h,1.38,1.39 objectmap.cpp,1.37,1.38 render.cpp,1.51,1.52 sfuncs.cpp,1.89,1.90 xref.txt,1.20,1.21

Eugene Sandulenko sev at users.sourceforge.net
Thu Jan 27 12:21:03 CET 2005


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

Modified Files:
	actor.cpp gfx.cpp gfx.h interface.h objectmap.cpp render.cpp 
	sfuncs.cpp xref.txt 
Log Message:
Applied patch #1106775 "SAGA colours". This simplifies code considerably, and
moreover getBlack() didn't always work correctly for some reason. If IHNM
uses different colors we will switch to variables, but that could be addressed
later or at least when someone will start to work on it more time than now.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- actor.cpp	23 Jan 2005 21:55:13 -0000	1.100
+++ actor.cpp	27 Jan 2005 20:06:50 -0000	1.101
@@ -1518,7 +1518,7 @@
 	_activeSpeech.speechCoords[0] = actor->screenPosition;
 	_activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
 	_activeSpeech.speechColor[0] = actor->speechColor;
-	_activeSpeech.outlineColor[0] = _vm->_gfx->getBlack();
+	_activeSpeech.outlineColor[0] = kITEColorBlack;
 	_activeSpeech.sampleResourceId = sampleResourceId;
 	_activeSpeech.playing = false;
 	_activeSpeech.slowModeCharIndex = 0;

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- gfx.cpp	21 Jan 2005 23:18:32 -0000	1.44
+++ gfx.cpp	27 Jan 2005 20:06:51 -0000	1.45
@@ -60,8 +60,6 @@
 	// Set module data
 	_back_buf = back_buf;
 	_init = 1;
-	_white_index = -1;
-	_black_index = -1;
 
 	// For now, always show the mouse cursor.
 	setCursor();
@@ -749,90 +747,17 @@
 	return &_back_buf;
 }
 
-int Gfx::getWhite(void) {
-	return _white_index;
-}
-
-int Gfx::getBlack(void) {
-	return _black_index;
-}
-
-int Gfx::matchColor(unsigned long colormask) {
-	int i;
-	int red = (colormask & 0x0FF0000UL) >> 16;
-	int green = (colormask & 0x000FF00UL) >> 8;
-	int blue = colormask & 0x00000FFUL;
-	int dr;
-	int dg;
-	int db;
-	long color_delta;
-	long best_delta = LONG_MAX;
-	int best_index = 0;
-	byte *ppal;
-
-	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
-		dr = ppal[0] - red;
-		dr = ABS(dr);
-		dg = ppal[1] - green;
-		dg = ABS(dg);
-		db = ppal[2] - blue;
-		db = ABS(db);
-		ppal[3] = 0;
-
-		color_delta = (long)(dr * RED_WEIGHT + dg * GREEN_WEIGHT + db * BLUE_WEIGHT);
-
-		if (color_delta == 0) {
-			return i;
-		}
-
-		if (color_delta < best_delta) {
-			best_delta = color_delta;
-			best_index = i;
-		}
-	}
-
-	return best_index;
-}
-
 int Gfx::setPalette(SURFACE *surface, PALENTRY *pal) {
-	byte red;
-	byte green;
-	byte blue;
-	int color_delta;
-	int best_wdelta = 0;
-	int best_windex = 0;
-	int best_bindex = 0;
-	int best_bdelta = 1000;
 	int i;
 	byte *ppal;
 
 	for (i = 0, ppal = _cur_pal; i < PAL_ENTRIES; i++, ppal += 4) {
-		red = pal[i].red;
-		ppal[0] = red;
-		color_delta = red;
-		green = pal[i].green;
-		ppal[1] = green;
-		color_delta += green;
-		blue = pal[i].blue;
-		ppal[2] = blue;
-		color_delta += blue;
+		ppal[0] = pal[i].red;
+		ppal[1] = pal[i].green;
+		ppal[2] = pal[i].blue;
 		ppal[3] = 0;
-
-		if (color_delta < best_bdelta) {
-			best_bindex = i;
-			best_bdelta = color_delta;
-		}
-
-		if (color_delta > best_wdelta) {
-			best_windex = i;
-			best_wdelta = color_delta;
-		}
 	}
 
-	// Set whitest and blackest color indices
-	_white_index = best_windex;
-	_black_index = best_bindex;
-
 	_system->setPalette(_cur_pal, 0, PAL_ENTRIES);
 
 	return SUCCESS;

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- gfx.h	15 Jan 2005 13:41:57 -0000	1.22
+++ gfx.h	27 Jan 2005 20:07:01 -0000	1.23
@@ -68,20 +68,12 @@
 
 #define PAL_ENTRIES 256
 
-#define RGB_RED   0x00FF0000UL
-#define RGB_GREEN 0x0000FF00UL
-#define RGB_BLUE  0x000000FFUL
-
 #define CURSOR_W 7
 #define CURSOR_H 7
 
 #define CURSOR_ORIGIN_X 4
 #define CURSOR_ORIGIN_Y 4
 
-#define RED_WEIGHT 0.299
-#define GREEN_WEIGHT 0.587
-#define BLUE_WEIGHT 0.114
-
 int drawPalette(SURFACE *dst_s);
 int bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_rect, Point *dst_pt);
 int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src,
@@ -100,9 +92,6 @@
 
 	Gfx(OSystem *system, int width, int height, GameDetector &detector);
 	SURFACE *getBackBuffer();
-	int getWhite();
-	int getBlack();
-	int matchColor(unsigned long colormask);
 	int setPalette(SURFACE *surface, PALENTRY *pal);
 	int getCurrentPal(PALENTRY *src_pal);
 	int palToBlack(SURFACE *surface, PALENTRY *src_pal, double percent);
@@ -114,8 +103,6 @@
 	void setCursor();
 	int _init;
 	SURFACE _back_buf;
-	int _white_index;
-	int _black_index;
 	byte _cur_pal[PAL_ENTRIES * 4];
 	OSystem *_system;
 };

Index: interface.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- interface.h	21 Jan 2005 21:55:52 -0000	1.38
+++ interface.h	27 Jan 2005 20:07:01 -0000	1.39
@@ -99,6 +99,7 @@
 	kITEColorDarkGrey = 0x0b,
 	kITEColorGreen = 0xba,
 	kITEColorBlack = 0x0f,
+	kITEColorRed = 0x65,
 	kITEColorBlue = 0x93
 };
 

Index: objectmap.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/objectmap.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- objectmap.cpp	21 Jan 2005 21:55:52 -0000	1.37
+++ objectmap.cpp	27 Jan 2005 20:07:01 -0000	1.38
@@ -31,6 +31,7 @@
 #include "saga/gfx.h"
 #include "saga/console.h"
 #include "saga/font.h"
+#include "saga/interface.h"
 #include "saga/objectmap.h"
 #include "saga/stream.h"
 
@@ -206,7 +207,7 @@
 	if (hitZoneIndex != -1) {		
 		snprintf(txtBuf, sizeof(txtBuf), "hitZone %d", hitZoneIndex);
 		_vm->_font->draw(SMALL_FONT_ID, ds, txtBuf, 0, 2, 2,
-			_vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE);
+			kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
 
 	}
 }

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- render.cpp	21 Jan 2005 21:55:53 -0000	1.51
+++ render.cpp	27 Jan 2005 20:07:01 -0000	1.52
@@ -126,9 +126,9 @@
 			// Display scene maps, if applicable
 			if (getFlags() & RF_OBJECTMAP_TEST) {
 				if (_vm->_scene->_objectMap)
-					_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->getWhite(), _vm->_gfx->getBlack());
+					_vm->_scene->_objectMap->draw(backbuf_surface, mouse_pt, kITEColorBrightWhite, kITEColorBlack);
 				if (_vm->_scene->_actionMap)
-					_vm->_scene->_actionMap->draw(backbuf_surface, mouse_pt, _vm->_gfx->matchColor(RGB_RED), _vm->_gfx->getBlack());
+					_vm->_scene->_actionMap->draw(backbuf_surface, mouse_pt, kITEColorRed, kITEColorBlack);
 			}
 
 			// Draw queued actors
@@ -152,7 +152,7 @@
 		sprintf(txt_buf, "%d", _fps);
 		fps_width = _vm->_font->getStringWidth(SMALL_FONT_ID, txt_buf, 0, FONT_NORMAL);
 		_vm->_font->draw(SMALL_FONT_ID, backbuf_surface, txt_buf, 0, backbuf_surface->w - fps_width, 2,
-					_vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE);
+					kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
 	}
 
 	// Display "paused game" message, if applicable
@@ -160,7 +160,7 @@
 		int msg_len = strlen(PAUSEGAME_MSG);
 		int msg_w = _vm->_font->getStringWidth(BIG_FONT_ID, PAUSEGAME_MSG, msg_len, FONT_OUTLINE);
 		_vm->_font->draw(BIG_FONT_ID, backbuf_surface, PAUSEGAME_MSG, msg_len,
-				(backbuf_surface->w - msg_w) / 2, 90, _vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE);
+				(backbuf_surface->w - msg_w) / 2, 90, kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE);
 	}
 
 	// Update user interface
@@ -170,7 +170,7 @@
 	// Display text formatting test, if applicable
 	if (_flags & RF_TEXT_TEST) {
 		_vm->textDraw(MEDIUM_FONT_ID, backbuf_surface, test_txt, mouse_pt.x, mouse_pt.y,
-				_vm->_gfx->getWhite(), _vm->_gfx->getBlack(), FONT_OUTLINE | FONT_CENTERED);
+				kITEColorBrightWhite, kITEColorBlack, FONT_OUTLINE | FONT_CENTERED);
 	}
 
 	// Display palette test, if applicable

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- sfuncs.cpp	25 Jan 2005 18:16:02 -0000	1.89
+++ sfuncs.cpp	27 Jan 2005 20:07:02 -0000	1.90
@@ -1110,8 +1110,8 @@
 
 	_vm->_scene->getInfo(&scene_info);
 
-	text_entry.color = _vm->_gfx->getWhite();
-	text_entry.effect_color = _vm->_gfx->getBlack();
+	text_entry.color = kITEColorBrightWhite;
+	text_entry.effect_color = kITEColorBlack;
 	text_entry.text_x = _vm->getDisplayWidth() / 2;
 	text_entry.text_y = (_vm->getSceneHeight() - _vm->_font->getHeight(MEDIUM_FONT_ID)) / 2;
 	text_entry.font_id = MEDIUM_FONT_ID;

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/xref.txt,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- xref.txt	20 Jan 2005 13:59:12 -0000	1.20
+++ xref.txt	27 Jan 2005 20:07:04 -0000	1.21
@@ -103,6 +103,7 @@
 GREY_0A                    kITEColorGrey
 DK_GREY_0B                 kITEColorDarkGrey
 PITCH_BLACK                kITEColorBlack
+RED_65                     kITEColorRed
 BLUE_93                    kITEColorBlue
 GREEB_BA                   kITEColorGreen
 





More information about the Scummvm-git-logs mailing list