[Scummvm-cvs-logs] SF.net SVN: scummvm:[42206] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Jul 7 09:44:26 CEST 2009


Revision: 42206
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42206&view=rev
Author:   thebluegr
Date:     2009-07-07 07:44:25 +0000 (Tue, 07 Jul 2009)

Log Message:
-----------
- Added auto-detection for EGA graphics. As a result of this, GF_SCI1_EGA has been removed and versions SCI_VERSION_01_EGA and SCI_VERSION_01_VGA have been merged into SCI_VERSION_01
- Simplified the checks for EGA and VGA graphics
- Fixed a bug in script_adjust_opcode_formats()
- Simplified the code in GfxResManager::getView() a bit

Modified Paths:
--------------
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/gfx/res_view.cpp
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h
    scummvm/trunk/engines/sci/vocabulary.cpp

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -457,7 +457,7 @@
 	      {"resource.005", 0, "58942b1aa6d6ffeb66e9f8897fd4435f", 469243},
 	      {"resource.006", 0, "8c767b3939add63d11274065e46aad04", 713158},
 	      {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
-	      GF_SCI1_EGA,
+	      0,
 	      SCI_VERSION_AUTODETECT,
 	      SCI_VERSION_1
 	},
@@ -949,8 +949,8 @@
 		{"resource.004", 0, "9ae2a13708d691cd42f9129173c4b39d", 820443},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// King's Quest 1 SCI Remake - English DOS Non-Interactive Demo
@@ -2066,8 +2066,8 @@
 		{"resource.001", 0, "9e33566515b18bee7915db448063bba2", 871853},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// Mixed-Up Fairy Tales v1.000 - English DOS (supplied by markcoolio in bug report #2723791)
@@ -2081,8 +2081,8 @@
 		{"resource.004", 0, "f79daa70390d73746742ffcfc3dc4471", 937580},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// Mixed-Up Fairy Tales - English DOS Floppy (from jvprat)
@@ -2095,8 +2095,8 @@
 		{"resource.003", 0, "dd6cef0c592eadb7e6be9a25307c57a2", 1344719},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// Mixed-Up Mother Goose - English Amiga (from www.back2roots.org)
@@ -2108,8 +2108,8 @@
 		{"resource.002", 0, "fb552ae550ca1dac19ed8f6a3767612d", 817191},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// Mixed-Up Mother Goose v2.000 - English DOS Floppy (supplied by markcoolio in bug report #2723795)
@@ -2119,8 +2119,8 @@
 		{"resource.000", 0, "b7ecd8ae9e254e80310b5a668b276e6e", 2948975},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
 		0,
-		SCI_VERSION_01_EGA,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01,
+		SCI_VERSION_01
 	},
 
 	// Mixed-Up Mother Goose - English DOS CD (from jvprat)
@@ -2520,7 +2520,7 @@
 		{NULL, 0, NULL, 0}}, Common::JA_JPN, Common::kPlatformPC98, 0, GUIO_NOSPEECH},
 		0,
 		SCI_VERSION_AUTODETECT,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01
 	},
 
 	// Quest for Glory 1 - Japanese PC-98 5.25" Floppy
@@ -2533,7 +2533,7 @@
 		{NULL, 0, NULL, 0}}, Common::JA_JPN, Common::kPlatformPC98, 0, GUIO_NOSPEECH},
 		0,
 		SCI_VERSION_AUTODETECT,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01
 	},
 
 	// Quest for Glory 1 - English Amiga
@@ -2606,7 +2606,7 @@
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH},
 		0,
 		SCI_VERSION_AUTODETECT,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01
 	},
 
 	// Quest for Glory 2 - English (from FRG)
@@ -2621,7 +2621,7 @@
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
 		0,
 		SCI_VERSION_AUTODETECT,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01
 	},
 
 	// Quest for Glory 2 - English DOS
@@ -2639,7 +2639,7 @@
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH},
 		0,
 		SCI_VERSION_AUTODETECT,
-		SCI_VERSION_01_EGA
+		SCI_VERSION_01
 	},
 
 	// Quest for Glory 3 - English DOS Non-Interactive Demo (from FRG)
@@ -3125,7 +3125,7 @@
 		{"resource.001", 0, "454684e3a7a68cbca073945e50778447", 1187088},
 		{"resource.002", 0, "6dc668326cc22cb9e8bd8ca9e68d2a66", 1181249},
 		{NULL, 0, NULL, 0}}, Common::JA_JPN, Common::kPlatformPC98, 0, GUIO_NOSPEECH},
-		GF_SCI1_EGA,
+		0,
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION_1
 	},
@@ -3138,7 +3138,7 @@
 		{"resource.001", 0, "454684e3a7a68cbca073945e50778447", 1187088},
 		{"resource.002", 0, "6dc668326cc22cb9e8bd8ca9e68d2a66", 1181249},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC98, 0, GUIO_NOSPEECH},
-		GF_SCI1_EGA,
+		0,
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION_1
 	},

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -43,10 +43,8 @@
 	gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 };
 	debug(2, "Initializing graphics");
 
-	if (s->resmgr->_sciVersion <= SCI_VERSION_01_EGA || (s->_flags & GF_SCI1_EGA)) {
-		int i;
-
-		for (i = 0; i < 16; i++) {
+	if (!s->resmgr->isVGA()) {
+		for (int i = 0; i < 16; i++) {
 			if (gfxop_set_color(s->gfx_state, &(s->ega_colors[i]), gfx_sci0_image_colors[sci0_palette][i].r,
 					gfx_sci0_image_colors[sci0_palette][i].g, gfx_sci0_image_colors[sci0_palette][i].b, 0, -1, -1)) {
 				return 1;
@@ -111,7 +109,7 @@
 	s->iconbar_port = new GfxPort(s->visual, gfx_rect(0, 0, 320, 200), s->ega_colors[0], transparent);
 	s->iconbar_port->_flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH;
 
-	if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) {
+	if (s->resmgr->isVGA()) {
 		// This bit sets the foreground and background colors in VGA SCI games
 		gfx_color_t fgcolor;
 		gfx_color_t bgcolor;
@@ -181,7 +179,7 @@
 }
 
 int game_init_sound(EngineState *s, int sound_flags) {
-	if (s->resmgr->_sciVersion >= SCI_VERSION_01_EGA)
+	if (s->resmgr->_sciVersion >= SCI_VERSION_01)
 		sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
 
 	s->sfx_init_flags = sound_flags;
@@ -466,7 +464,7 @@
 	s->successor = NULL; // No successor
 	s->_statusBarText.clear(); // Status bar is blank
 	s->status_bar_foreground = 0;
-	s->status_bar_background = (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) ? 255 : 15;
+	s->status_bar_background = !s->resmgr->isVGA() ? 15 : 255;
 
 	SystemString *str = &s->sys_strings->strings[SYS_STRING_PARSER_BASE];
 	str->name = strdup("parser-base");

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -832,8 +832,7 @@
 
 	switch (_resmgr->_sciVersion) {
 	case SCI_VERSION_0:
-	case SCI_VERSION_01_EGA:
-	case SCI_VERSION_01_VGA:
+	case SCI_VERSION_01:
 	case SCI_VERSION_01_VGA_ODD:
 	case SCI_VERSION_1:
 	case SCI_VERSION_1_1:

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -269,7 +269,7 @@
 }
 
 PaletteEntry get_pic_color(EngineState *s, int color) {
-	if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA)
+	if (!s->resmgr->isVGA())
 		return s->ega_colors[color].visual;
 
 	if (color == -1 || color == 255)     // -1 occurs in Eco Quest 1. Not sure if this is the best approach, but it seems to work
@@ -286,7 +286,7 @@
 static gfx_color_t graph_map_color(EngineState *s, int color, int priority, int control) {
 	gfx_color_t retval;
 
-	if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA) {
+	if (!s->resmgr->isVGA()) {
 		retval = s->ega_colors[(color >=0 && color < 16)? color : 0];
 		gfxop_set_color(s->gfx_state, &retval, (color < 0) ? -1 : retval.visual.r, retval.visual.g, retval.visual.b,
 		                (color == -1) ? 255 : 0, priority, control);
@@ -502,7 +502,7 @@
 
 	case K_GRAPH_GET_COLORS_NR:
 
-		return make_reg(0, s->resmgr->_sciVersion < SCI_VERSION_01_VGA ? 0x10 : 0x100);
+		return make_reg(0, !s->resmgr->isVGA() ? 0x10 : 0x100);
 		break;
 
 	case K_GRAPH_DRAW_LINE: {
@@ -2502,7 +2502,7 @@
 	int16 bgColor = (argc > 8 + argextra) ? argv[8 + argextra].toSint16() : 255;
 
 	if (bgColor >= 0) {
-		if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA)
+		if (!s->resmgr->isVGA())
 			bgcolor.visual = get_pic_color(s, MIN<int>(bgColor, 15));
 		else
 			bgcolor.visual = get_pic_color(s, bgColor);
@@ -2528,7 +2528,7 @@
 	black.alpha = 0;
 	black.control = -1;
 	black.priority = -1;
-	lWhite.visual = get_pic_color(s, s->resmgr->_sciVersion < SCI_VERSION_01_VGA ? 15 : 255);
+	lWhite.visual = get_pic_color(s, !s->resmgr->isVGA() ? 15 : 255);
 	lWhite.mask = GFX_MASK_VISUAL;
 	lWhite.alpha = 0;
 	lWhite.priority = -1;
@@ -3149,7 +3149,7 @@
 	bg_color = port->_bgcolor;
 	// TODO: in SCI1VGA the default colors for text and background are #0 (black)
 	// SCI0 case should be checked
-	if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) {
+	if (s->resmgr->isVGA()) {
 		// This priority check fixes the colors in the menus in KQ5
 		// TODO/FIXME: Is this correct?
 		if (color0.priority >= 0)
@@ -3191,10 +3191,10 @@
 
 			temp = argv[argpt++].toSint16();
 			debugC(2, kDebugLevelGraphics, "Display: set_color(%d)\n", temp);
-			if ((s->resmgr->_sciVersion < SCI_VERSION_01_VGA) && temp >= 0 && temp <= 15)
+			if (!s->resmgr->isVGA() && temp >= 0 && temp <= 15)
 				color0 = (s->ega_colors[temp]);
 			else
-				if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA && temp >= 0 && temp < 256) {
+				if (s->resmgr->isVGA() && temp >= 0 && temp < 256) {
 					color0.visual = get_pic_color(s, temp);
 					color0.mask = GFX_MASK_VISUAL;
 				} else
@@ -3208,10 +3208,10 @@
 
 			temp = argv[argpt++].toSint16();
 			debugC(2, kDebugLevelGraphics, "Display: set_bg_color(%d)\n", temp);
-			if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA && temp >= 0 && temp <= 15)
+			if (!s->resmgr->isVGA() && temp >= 0 && temp <= 15)
 				bg_color = s->ega_colors[temp];
 			else
-				if ((s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) && temp >= 0 && temp <= 256) {
+				if (s->resmgr->isVGA() && temp >= 0 && temp <= 256) {
 					bg_color.visual = get_pic_color(s, temp);
 					bg_color.mask = GFX_MASK_VISUAL;
 				} else

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -154,7 +154,7 @@
 	SongHandle handle;
 	int cue;
 
-	if (s->_version >= SCI_VERSION_01_EGA)
+	if (s->_version >= SCI_VERSION_01)
 		return;
 	/* SCI01 and later explicitly poll for everything */
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -693,7 +693,7 @@
 
 static void reconstruct_sounds(EngineState *s) {
 	Song *seeker;
-	SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01_EGA ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0;
+	SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01 ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0;
 
 	seeker = s->_sound._songlib._lib;
 

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -91,9 +91,8 @@
 void script_adjust_opcode_formats(int res_version) {
 	switch (res_version) {
 	case SCI_VERSION_0:
-	case SCI_VERSION_01_EGA:
 		break;
-	case SCI_VERSION_01_VGA:
+	case SCI_VERSION_01:
 	case SCI_VERSION_01_VGA_ODD:
 	case SCI_VERSION_1:
 	case SCI_VERSION_1_1:

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -49,14 +49,14 @@
 	GfxDriver *driver;
 };
 
-GfxResManager::GfxResManager(int version, bool isVGA, gfx_options_t *options, GfxDriver *driver, ResourceManager *resManager) :
-				_version(version), _isVGA(isVGA), _options(options), _driver(driver), _resManager(resManager),
+GfxResManager::GfxResManager(int version, gfx_options_t *options, GfxDriver *driver, ResourceManager *resManager) :
+				_version(version), _options(options), _driver(driver), _resManager(resManager),
 				_lockCounter(0), _tagLockCounter(0), _staticPalette(0) {
 	gfxr_init_static_palette();
 
 	_portBounds = Common::Rect(0, 10, 320, 200);	// default value, with a titlebar of 10px
 
-	if (_version < SCI_VERSION_01_VGA || !_isVGA) {
+	if (!_resManager->isVGA()) {
 		_staticPalette = gfx_sci0_pic_colors->getref();
 	} else if (_version == SCI_VERSION_1_1) {
 		debugC(2, kDebugLevelGraphics, "Palettes are not yet supported in this SCI version\n");
@@ -99,7 +99,7 @@
 		if (_version == SCI_VERSION_1_1)
 			gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _staticPalette, _portBounds);
 		else
-			gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _isVGA, _staticPalette, _portBounds);
+			gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id.number, _resManager->isVGA(), _staticPalette, _portBounds);
 	}
 
 	if (scaled_pic && scaled_pic->undithered_buffer)
@@ -108,9 +108,9 @@
 	if (_version == SCI_VERSION_1_1)
 		gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _staticPalette, _portBounds);
 	else
-		gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _isVGA, _staticPalette, _portBounds);
+		gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id.number, _resManager->isVGA(), _staticPalette, _portBounds);
 
-	if (!_isVGA) {
+	if (!_resManager->isVGA()) {
 		if (need_unscaled)
 			gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic);
 
@@ -144,7 +144,7 @@
 
 	case GFX_RESOURCE_TYPE_PIC:
 #ifdef CUSTOM_GRAPHICS_OPTIONS
-		if (_version >= SCI_VERSION_01_VGA)
+		if (_resManager->isVGA())
 			// NOTE: here, it is assumed that the upper port bound is always 10, but this doesn't seem to matter for the
 			// generated options hash anyway
 			return 10;
@@ -153,7 +153,7 @@
 			       | (_options->pic0_dither_pattern << 8) | (_options->pic0_brush_mode << 4)
 				   | (_options->pic0_line_mode);
 #else
-		if (_version >= SCI_VERSION_01_VGA)
+		if (_resManager->isVGA())
 			return 10;
 		else
 			return 0x10000 | (GFXR_DITHER_PATTERN_SCALED << 8) | (GFX_BRUSH_MODE_RANDOM_ELLIPSES << 4) | GFX_LINE_MODE_CORRECT;
@@ -340,12 +340,12 @@
 #ifdef CUSTOM_GRAPHICS_OPTIONS
 		if (_options->pic0_unscaled) {
 			need_unscaled = 0;
-			pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA);
+			pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA());
 		} else
-			pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA);
+			pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA());
 #else
 		need_unscaled = 0;
-		pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA);
+		pic = gfxr_init_pic(_driver->getMode(), GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA());
 #endif
 
 		if (!pic) {
@@ -356,7 +356,7 @@
 		gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);
 
 		if (need_unscaled) {
-			unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA);
+			unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _resManager->isVGA());
 			if (!unscaled_pic) {
 				error("Failed to allocate unscaled pic");
 				return NULL;
@@ -529,17 +529,16 @@
 			return NULL;
 
 		int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr);
+		
+		if (!_resManager->isVGA()) {
+			int pal = (_version == SCI_VERSION_0) ? -1 : palette;
+			view = getEGAView(resid, viewRes->data, viewRes->size, pal);
+		} else {
+			if (_version < SCI_VERSION_1_1)
+				view = getVGAView(resid, viewRes->data, viewRes->size, _staticPalette, false);
+			else
+				view = getVGAView(resid, viewRes->data, viewRes->size, 0, true);
 
-		if (_version < SCI_VERSION_01_EGA)
-			view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, -1);
-		else if (_version == SCI_VERSION_01_EGA || !_isVGA)
-			view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, palette);
-		else if (_version >= SCI_VERSION_01_VGA && _version <= SCI_VERSION_1)
-			view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, _staticPalette, false);
-		else if (_version >= SCI_VERSION_1_1)
-			view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, 0, true);
-
-		if (_isVGA) {
 			if (!view->palette) {
 				view->palette = new Palette(_staticPalette->size());
 				view->palette->name = "interpreter_get_view";
@@ -553,7 +552,6 @@
 					view->palette->setColor(i, sc.r, sc.g, sc.b);
 				}
 			}
-
 		}
 
 		if (!res) {

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-07-07 07:44:25 UTC (rev 42206)
@@ -90,7 +90,7 @@
 /** Graphics resource manager */
 class GfxResManager {
 public:
-	GfxResManager(int version, bool isVGA, gfx_options_t *options,
+	GfxResManager(int version, gfx_options_t *options,
 			GfxDriver *driver, ResourceManager *resManager);
 
 	~GfxResManager();
@@ -311,14 +311,12 @@
 	 *
 	 * @return	Number of pallete entries
 	 */
-	int getColorCount()
-	{
+	int getColorCount() {
 		return _staticPalette ? _staticPalette->size() : 0;
 	}
 
 private:
 	int _version;
-	bool _isVGA;
 	gfx_options_t *_options;
 	GfxDriver *_driver;
 	Palette *_staticPalette;

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-07-07 07:44:25 UTC (rev 42206)
@@ -245,7 +245,7 @@
 void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern);
 
 /**
- * Calculates a SCI0 view.
+ * Calculates an EGA view.
  *
  * @param[in] id		Resource ID of the view
  * @param[in] resource	Pointer to the resource to read
@@ -253,7 +253,7 @@
  * @param[in] palette	The palette to use
  * @return				The resulting view
  */
-gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette);
+gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette);
 
 /**
  * Calculates a SCI cursor.
@@ -265,8 +265,7 @@
  * @return				A newly allocated pixmap containing an index color
  * 						representation of the cursor
  */
-gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size,
-		bool isSci01);
+gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01);
 /** @} */
 
 
@@ -304,7 +303,7 @@
 Palette *gfxr_read_pal11(int id, byte *resource, int size);
 
 /**
- * Calculates an SCI1 view.
+ * Calculates a VGA view.
  *
  * @param[in] id			Resource ID of the view
  * @param[in] resource		Pointer to the resource to read
@@ -313,7 +312,7 @@
  * @param[in] isSci11		true if SCI1.1, false otherwise
  * @return					The resulting view
  */
-gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal, bool isSci11);
+gfxr_view_t *getVGAView(int id, byte *resource, int size, Palette *static_pal, bool isSci11);
 
 gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, byte *cel_base, int size, gfxr_view_t *view, bool isAmiga, bool isSci11);
 /** @} */

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -404,7 +404,7 @@
 	(*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR);
 }
 
-int gfxop_init(int version, bool isVGA, GfxState *state, gfx_options_t *options, ResourceManager *resManager,
+int gfxop_init(int version, GfxState *state, gfx_options_t *options, ResourceManager *resManager,
 			   int xfact, int yfact, gfx_color_mode_t bpp) {
 	//int color_depth = bpp ? bpp : 1;
 	//int initialized = 0;
@@ -423,8 +423,8 @@
 
 	state->driver = new GfxDriver(xfact, yfact, bpp);
 
-	state->gfxResMan = new GfxResManager(version, isVGA, state->options, state->driver, resManager);
-
+	state->gfxResMan = new GfxResManager(version, state->options, state->driver, resManager);
+	
 	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
 
 	init_aux_pixmap(&(state->control_map));

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-07-07 07:44:25 UTC (rev 42206)
@@ -135,7 +135,6 @@
  * Initializes a graphics mode.
  *
  * @param[in] version		The interpreter version
- * @param[in] isVGA			true if using VGA resolution
  * @param[in] state			The state to initialize
  * @param[in] xfact			Horizontal scale factor
  * @param[in] yfact			Vertical scale factors
@@ -147,7 +146,7 @@
  * 							is unavailable, or GFX_FATAL if the graphics driver
  * 							is unable to provide any useful graphics support
  */
-int gfxop_init(int version, bool isVGA, GfxState *state, gfx_options_t *options,
+int gfxop_init(int version, GfxState *state, gfx_options_t *options,
 	ResourceManager *resManager, int xfact = 1, int yfact = 1,
 	gfx_color_mode_t bpp = GFX_COLOR_MODE_INDEX);
 

Modified: scummvm/trunk/engines/sci/gfx/res_view.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_view.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/gfx/res_view.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -135,7 +135,7 @@
 	return retval;
 }
 
-gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) {
+gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette) {
 	int i;
 	gfxr_view_t *view;
 	int mirror_bitpos = 1;
@@ -365,7 +365,7 @@
 	return retval;
 }
 
-gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal, bool isSci11) {
+gfxr_view_t *getVGAView(int id, byte *resource, int size, Palette *static_pal, bool isSci11) {
 	uint16 palOffset = READ_LE_UINT16(resource + V1_PALETTE_OFFSET + (isSci11 ? 2 : 0));
 	uint16 headerSize = isSci11 ? READ_LE_UINT16(resource + V2_HEADER_SIZE) : 0;
 	byte* seeker = resource + headerSize;

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -358,7 +358,7 @@
 		file.close();
 
 		if (compression == 3) {
-			return SCI_VERSION_01_VGA;
+			return SCI_VERSION_01;
 		}
 	}
 
@@ -382,7 +382,7 @@
 		file.close();
 
 		if (compression == 3) {
-			return SCI_VERSION_01_VGA;
+			return SCI_VERSION_01;
 		}
 	}
 
@@ -495,14 +495,14 @@
 		switch (_mapVersion) {
 		case SCI_VERSION_0:
 			if (testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB))) {
-				version = guessSciVersion() ? SCI_VERSION_01_VGA : SCI_VERSION_0;
+				version = guessSciVersion() ? SCI_VERSION_01 : SCI_VERSION_0;
 			} else if (testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB))) {
 				version = guessSciVersion();
-				if (version != SCI_VERSION_01_VGA) {
-					version = testResource(ResourceId(kResourceTypeVocab, 912)) ? SCI_VERSION_0 : SCI_VERSION_01_EGA;
+				if (version != SCI_VERSION_01) {
+					version = testResource(ResourceId(kResourceTypeVocab, 912)) ? SCI_VERSION_0 : SCI_VERSION_01;
 				}
 			} else {
-				version = guessSciVersion() ? SCI_VERSION_01_VGA : SCI_VERSION_0;
+				version = guessSciVersion() ? SCI_VERSION_01 : SCI_VERSION_0;
 			}
 			break;
 		case SCI_VERSION_01_VGA_ODD:
@@ -519,18 +519,37 @@
 			version = SCI_VERSION_AUTODETECT;
 		}
 
+	_isVGA = false;
+
+	// Determine if the game is using EGA graphics or not
+	if (version == SCI_VERSION_0) {
+		_isVGA = false;		// There is no SCI0 VGA game
+	} else if (version >= SCI_VERSION_1_1) {
+		_isVGA = true;		// There is no SCI11 EGA game
+	} else {
+		// SCI01 or SCI1: EGA games have the second byte of their views set
+		// to 0, VGA ones to non-zero
+		int i = 0;
+
+		while (true) {
+			Resource *res = findResource(ResourceId(kResourceTypeView, i), 0);
+			if (res) {
+				_isVGA = (res->data[1] != 0);
+				break;
+			}
+			i++;
+		}
+	}
+
 	_sciVersion = version;
 	// temporary version printout - should be reworked later
 	switch (_sciVersion) {
 	case SCI_VERSION_0:
 		debug("Resmgr: Detected SCI0");
 		break;
-	case SCI_VERSION_01_EGA:
+	case SCI_VERSION_01:
 		debug("Resmgr: Detected SCI01");
 		break;
-	case SCI_VERSION_01_VGA:
-		debug("Resmgr: Detected SCI01VGA - KQ5 or similar");
-		break;
 	case SCI_VERSION_01_VGA_ODD:
 		debug("Resmgr: Detected SCI01VGA - Jones/CD or similar");
 		break;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/resource.h	2009-07-07 07:44:25 UTC (rev 42206)
@@ -214,6 +214,8 @@
 	int _mapVersion; //!< RESOURCE.MAP version
 	int _volVersion; //!< RESOURCE.0xx version
 
+	bool isVGA() const { return _isVGA; }
+
 	/**
 	 * Creates a new SCI resource manager.
 	 * @param version		The SCI version to look for; use SCI_VERSION_AUTODETECT
@@ -265,6 +267,7 @@
 	void setAudioLanguage(int language);
 
 protected:
+	bool _isVGA; // Used to determine if the game has EGA or VGA graphics
 	int _maxMemory; //!< Config option: Maximum total byte number allocated
 	Common::List<ResourceSource *> _sources;
 	int _memoryLocked;	//!< Amount of resource bytes in locked memory

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -43,11 +43,10 @@
 
 class GfxDriver;
 
-const char *versionNames[8] = {
+const char *versionNames[7] = {
 	"Autodetected",
 	"SCI0",
-	"SCI01 EGA",
-	"SCI01 VGA",
+	"SCI01",
 	"SCI01 VGA ODD",
 	"SCI1",
 	"SCI1.1",
@@ -151,9 +150,6 @@
 	// Verify that we haven't got an invalid game detection entry
 	if (version < SCI_VERSION_1) {
 		// SCI0/SCI01
-		if (flags & GF_SCI1_EGA) {
-			error("This game entry is erroneous. It's marked as SCI0/SCI01, but it has SCI1 flags set");
-		}
 	} else if (version == SCI_VERSION_1) {
 		// SCI1
 
@@ -162,10 +158,6 @@
 			error("This game entry is erroneous. It's marked as SCI1, but it has SCI0 flags set");
 		}
 	} else if (version == SCI_VERSION_1_1 || version == SCI_VERSION_32) {
-		if (flags & GF_SCI1_EGA) {
-			error("This game entry is erroneous. It's marked as SCI1.1/SCI32, but it has SCI1 flags set");
-		}
-
 		if (flags & GF_SCI0_OLD ||
 			flags & GF_SCI0_OLDGETTIME) {
 			error("This game entry is erroneous. It's marked as SCI1.1/SCI32, but it has SCI0 flags set");
@@ -218,8 +210,7 @@
 	// Default config ends
 #endif
 
-	bool isVGA = _resmgr->_sciVersion >= SCI_VERSION_01_VGA && !(getFlags() & GF_SCI1_EGA);
-	if (gfxop_init(_resmgr->_sciVersion, isVGA, &gfx_state, &gfx_options, _resmgr)) {
+	if (gfxop_init(_resmgr->_sciVersion, &gfx_state, &gfx_options, _resmgr)) {
 		warning("Graphics initialization failed. Aborting...");
 		return Common::kUnknownError;
 	}

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/sci.h	2009-07-07 07:44:25 UTC (rev 42206)
@@ -71,15 +71,14 @@
 enum SciGameVersions {
 	SCI_VERSION_AUTODETECT = 0,
 	SCI_VERSION_0 = 1,
-	SCI_VERSION_01_EGA = 2,
-	SCI_VERSION_01_VGA = 3,
-	SCI_VERSION_01_VGA_ODD = 4,
-	SCI_VERSION_1 = 5,
-	SCI_VERSION_1_1 = 6,
-	SCI_VERSION_32 = 7
+	SCI_VERSION_01 = 2,
+	SCI_VERSION_01_VGA_ODD = 3,
+	SCI_VERSION_1 = 4,
+	SCI_VERSION_1_1 = 5,
+	SCI_VERSION_32 = 6
 };
 
-extern const char *versionNames[8];
+extern const char *versionNames[7];
 
 enum SciGameFlags {
 	// SCI0 flags
@@ -96,16 +95,7 @@
 	/* Applies to all versions before 0.000.629
 	 * Older SCI versions had simpler code for GetTime()
 	 */
-	GF_SCI0_OLDGETTIME		= (1 << 1),
-
-	// ----------------------------------------------------------------------------
-
-	// SCI1 flags
-
-	/*
-	 * Used to distinguish SCI1 EGA games
-	 */
-	GF_SCI1_EGA				= (1 << 2)
+	GF_SCI0_OLDGETTIME		= (1 << 1)
 };
 
 class SciEngine : public Engine {

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-07-07 07:41:02 UTC (rev 42205)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-07-07 07:44:25 UTC (rev 42206)
@@ -91,7 +91,7 @@
 
 	debug(2, "Initializing vocabulary");
 
-	if (_resmgr->_sciVersion < SCI_VERSION_01_VGA && loadParserWords()) {
+	if (_resmgr->_sciVersion <= SCI_VERSION_01 && loadParserWords()) {
 		loadSuffixes();
 		if (loadBranches())
 			// Now build a GNF grammar out of this


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