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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Mar 18 12:07:29 CET 2009


Revision: 39513
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39513&view=rev
Author:   thebluegr
Date:     2009-03-18 11:07:29 +0000 (Wed, 18 Mar 2009)

Log Message:
-----------
Cleaned up graphics initialization a bit

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_driver.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-03-18 10:55:05 UTC (rev 39512)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-03-18 11:07:29 UTC (rev 39513)
@@ -43,7 +43,7 @@
 
 #define S ((struct _scummvm_driver_state *)(drv->state))
 
-static int scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) {
+static int scummvm_init(gfx_driver_t *drv, int xfact, int yfact, int bytespp) {
 	int i;
 
 	if (!drv->state) // = S
@@ -86,10 +86,6 @@
 	return GFX_OK;
 }
 
-static int scummvm_init(gfx_driver_t *drv) {
-	return scummvm_init_specific(drv, 1, 1, GFX_COLOR_MODE_INDEX);
-}
-
 static void scummvm_exit(gfx_driver_t *drv) {
 	int i;
 	if (S) {
@@ -331,7 +327,6 @@
 	0,		// flags here
 	0,
 	NULL,
-	scummvm_init_specific,
 	scummvm_init,
 	scummvm_exit,
 	scummvm_draw_line,

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-03-18 10:55:05 UTC (rev 39512)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-03-18 11:07:29 UTC (rev 39513)
@@ -111,7 +111,7 @@
 	** console).
 	*/
 
-	int (*init_specific)(gfx_driver_t *drv, int xres, int yres,
+	int (*init)(gfx_driver_t *drv, int xres, int yres,
 	                     int bytespp);
 	/* Attempts to initialize a specific graphics mode
 	** Parameters: (gfx_driver_t *) drv: The affected driver
@@ -129,18 +129,6 @@
 	** specified in gfx_tools.h.
 	*/
 
-	int (*init)(gfx_driver_t *drv);
-	/* Initialize any graphics mode
-	** Parameters: (gfx_driver_t *) drv: The affected driver
-	** Returns   : (int) GFX_OK on success, GFX_FATAL otherwise.
-	** This function attempts to set /any/ graphics mode, starting with the one
-	** most 'natural' to the graphics target. Target implementors have relatively
-	** free reign in choosing the heuristics used to determine the resulting
-	** mode.
-	** Must also set drv->mode, preferably with the gfx_new_mode() function
-	** specified in gfx_tools.h.
-	*/
-
 	void (*exit)(gfx_driver_t *drv);
 	/* Uninitializes the current graphics mode
 	** Paramters: (gfx_driver_t *) drv: The driver to uninitialize

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-18 10:55:05 UTC (rev 39512)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-18 11:07:29 UTC (rev 39513)
@@ -422,18 +422,42 @@
 	(*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR);
 }
 
-static int _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager) {
-	gfxr_init_static_palette();
+int gfxop_init(gfx_state_t *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;
 
+	BASIC_CHECKS(GFX_FATAL);
+
 	state->options = options;
+	state->visible_map = GFX_MASK_VISUAL;
+	state->fullscreen_override = NULL; // No magical override
+	state->options = options;
+	state->disable_dirty = 0;
+	state->_events.clear();
+	state->pic = state->pic_unscaled = NULL;
+	state->pic_nr = -1; // Set background pic number to an invalid value
+	state->tag_mode = 0;
+	state->dirty_rects = NULL;
+	state->static_palette = NULL;
 
+	do {
+		if (!state->driver->init(state->driver, xfact, yfact, color_depth))
+			initialized = 1;
+		else
+			color_depth++;
+	} while (!initialized && color_depth < 9 && !bpp);
+
+	if (!initialized)
+		return GFX_FATAL;
+
+	gfxr_init_static_palette();
+
 	if (!((state->resstate = gfxr_new_resource_manager(state->version, state->options, state->driver, resManager)))) {
 		GFXERROR("Failed to initialize resource manager!\n");
 		return GFX_FATAL;
 	}
 
-	state->static_palette = NULL;
-
 	if (state->version < SCI_VERSION_01_VGA) {
 		state->static_palette = gfx_sci0_pic_colors->getref();
 	} else if (state->version == SCI_VERSION_1_1 || state->version == SCI_VERSION_32) {
@@ -444,57 +468,15 @@
 			state->static_palette = gfxr_read_pal1(res->id, res->data, res->size);
 	}
 
-	state->visible_map = GFX_MASK_VISUAL;
-	state->fullscreen_override = NULL; // No magical override
 	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
 
 	init_aux_pixmap(&(state->control_map));
 	init_aux_pixmap(&(state->priority_map));
 	init_aux_pixmap(&(state->static_priority_map));
 
-	state->options = options;
-	state->disable_dirty = 0;
-	state->_events.clear();
-
-	state->pic = state->pic_unscaled = NULL;
-
-	state->pic_nr = -1; // Set background pic number to an invalid value
-
-	state->tag_mode = 0;
-
-	state->dirty_rects = NULL;
-
 	return GFX_OK;
 }
 
-int gfxop_init_default(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager) {
-	BASIC_CHECKS(GFX_FATAL);
-	if (state->driver->init(state->driver))
-		return GFX_FATAL;
-
-	return _gfxop_init_common(state, options, resManager);
-}
-
-int gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp,
-	gfx_options_t *options, ResourceManager *resManager) {
-	int color_depth = bpp ? bpp : 1;
-	int initialized = 0;
-
-	BASIC_CHECKS(GFX_FATAL);
-
-	do {
-		if (!state->driver->init_specific(state->driver, xfact, yfact, color_depth))
-			initialized = 1;
-		else
-			color_depth++;
-	} while (!initialized && color_depth < 9 && !bpp);
-
-	if (!initialized)
-		return GFX_FATAL;
-
-	return _gfxop_init_common(state, options, resManager);
-}
-
 int gfxop_set_parameter(gfx_state_t *state, char *attribute, char *value) {
 	BASIC_CHECKS(GFX_FATAL);
 

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-03-18 10:55:05 UTC (rev 39512)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-03-18 11:07:29 UTC (rev 39513)
@@ -139,18 +139,9 @@
 /* Fundamental operations */
 /**************************/
 
-int gfxop_init_default(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager);
-/* Initializes a graphics mode suggested by the graphics driver
-** Parameters: (gfx_state_ t *) state: The state to initialize in that mode
-**             (gfx_options_t *) options: Rendering options
-**             (void *) misc_info: Additional information for the interpreter
-**                      part of the resource loader
-** Returns   : (int) GFX_OK on success, GFX_FATAL otherwise
-*/
-
-int gfxop_init(gfx_state_t *state, int xfact, int yfact, gfx_color_mode_t bpp,
-	gfx_options_t *options, ResourceManager *resManager);
-/* Initializes a custom graphics mode
+int gfxop_init(gfx_state_t *state, gfx_options_t *options, ResourceManager *resManager,
+			   int xfact = 1, int yfact = 1, gfx_color_mode_t bpp = GFX_COLOR_MODE_INDEX);
+/* Initializes a graphics mode
 ** Parameters: (gfx_state_t *) state: The state to initialize
 **             (int x int) xfact, yfact: Horizontal and vertical scale factors
 **             (gfx_color_mode_t) bpp: Bytes per pixel to initialize with, or

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-03-18 10:55:05 UTC (rev 39512)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-03-18 11:07:29 UTC (rev 39513)
@@ -236,15 +236,15 @@
 	// Set the savegame dir
 	script_set_gamestate_save_dir(gamestate, ConfMan.get("savepath").c_str());
 
+	gfx_crossblit_alpha_threshold = 0x90;
+	gfx_state_t gfx_state;
+	gfx_state.driver = &gfx_driver_scummvm;
+	gfx_state.version = _resmgr->_sciVersion;
+
 	gamestate->port_serial = 0;
 	gamestate->have_mouse_flag = 1;
 	gamestate->animation_delay = 5;
 	gamestate->animation_granularity = 4;
-	gfx_crossblit_alpha_threshold = 0x90;
-
-	gfx_state_t gfx_state;
-	gfx_state.driver = &gfx_driver_scummvm;
-	gfx_state.version = _resmgr->_sciVersion;
 	gamestate->gfx_state = &gfx_state;
 
 	// Default config:
@@ -268,7 +268,7 @@
 	}
 	// Default config ends
 
-	if (gfxop_init_default(&gfx_state, &gfx_options, _resmgr)) {
+	if (gfxop_init(&gfx_state, &gfx_options, _resmgr)) {
 		fprintf(stderr, "Graphics initialization failed. Aborting...\n");
 		return Common::kUnknownError;
 	}


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