aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-18 11:07:29 +0000
committerFilippos Karapetis2009-03-18 11:07:29 +0000
commitc9eff6e1f87231f63b3cd4a5dce4b04ffac96075 (patch)
tree85bd3b70fd6ea022d3ae4876dae33e25df7bf40e /engines/sci/gfx
parent739181c3b7bdc9dac18c696e0928819a836e1bf0 (diff)
downloadscummvm-rg350-c9eff6e1f87231f63b3cd4a5dce4b04ffac96075.tar.gz
scummvm-rg350-c9eff6e1f87231f63b3cd4a5dce4b04ffac96075.tar.bz2
scummvm-rg350-c9eff6e1f87231f63b3cd4a5dce4b04ffac96075.zip
Cleaned up graphics initialization a bit
svn-id: r39513
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r--engines/sci/gfx/gfx_driver.cpp7
-rw-r--r--engines/sci/gfx/gfx_driver.h14
-rw-r--r--engines/sci/gfx/operations.cpp74
-rw-r--r--engines/sci/gfx/operations.h15
4 files changed, 33 insertions, 77 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp
index 985033de09..95c1db3d94 100644
--- a/engines/sci/gfx/gfx_driver.cpp
+++ b/engines/sci/gfx/gfx_driver.cpp
@@ -43,7 +43,7 @@ struct _scummvm_driver_state {
#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 @@ static int scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int by
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 @@ gfx_driver_t gfx_driver_scummvm = {
0, // flags here
0,
NULL,
- scummvm_init_specific,
scummvm_init,
scummvm_exit,
scummvm_draw_line,
diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h
index e61f305e66..84b8526b7c 100644
--- a/engines/sci/gfx/gfx_driver.h
+++ b/engines/sci/gfx/gfx_driver.h
@@ -111,7 +111,7 @@ struct gfx_driver_t { /* Graphics driver */
** 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 @@ struct gfx_driver_t { /* Graphics driver */
** 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
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index c4bcaff5d2..245f7ba0ec 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -422,18 +422,42 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) {
(*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 @@ static int _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, Resour
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);
diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h
index e3ed29533b..6a5965d9bc 100644
--- a/engines/sci/gfx/operations.h
+++ b/engines/sci/gfx/operations.h
@@ -139,18 +139,9 @@ struct gfx_state_t {
/* 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