aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-10 10:55:36 +0000
committerFilippos Karapetis2009-03-10 10:55:36 +0000
commitd7b767d90c2c5bb19e3a76432a3ae6292324c89e (patch)
treef822699d238b84e0fd16f0fc306f6049aa5ef007
parentc908f3c3321fb04fbe5741a949ad4d20c85dfd68 (diff)
downloadscummvm-rg350-d7b767d90c2c5bb19e3a76432a3ae6292324c89e.tar.gz
scummvm-rg350-d7b767d90c2c5bb19e3a76432a3ae6292324c89e.tar.bz2
scummvm-rg350-d7b767d90c2c5bb19e3a76432a3ae6292324c89e.zip
Reverted some of the changes of commit #39192. The cursor reading code has been placed back in a separate file, and not in the resource manager (but it's now 1 function)
svn-id: r39293
-rw-r--r--engines/sci/gfx/gfx_resource.h10
-rw-r--r--engines/sci/gfx/resource/res_cursor.cpp92
-rw-r--r--engines/sci/gfx/resource/res_manager.cpp54
-rw-r--r--engines/sci/module.mk5
4 files changed, 106 insertions, 55 deletions
diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h
index 90911ef12d..f2736726b4 100644
--- a/engines/sci/gfx/gfx_resource.h
+++ b/engines/sci/gfx/gfx_resource.h
@@ -242,6 +242,16 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette);
** Returns : (gfxr_view_t *) The resulting view
*/
+gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01);
+/* Calculates n SCI cursor
+** Parameters: (int) id: The cursor's resource ID
+** (byte *) resource: Pointer to the resource data
+** (int) size: Resource size
+** (bool) isSci01: Set to true to load a SCI1 cursor
+** Returns : (gfx_pixmap_t *) A newly allocated pixmap containing an index
+** color representation of the cursor
+*/
+
/*********************/
/* SCI1 operations */
/*********************/
diff --git a/engines/sci/gfx/resource/res_cursor.cpp b/engines/sci/gfx/resource/res_cursor.cpp
new file mode 100644
index 0000000000..9a109f6ebf
--- /dev/null
+++ b/engines/sci/gfx/resource/res_cursor.cpp
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/* SCI cursor functions */
+
+#include "sci/gfx/gfx_system.h"
+#include "sci/gfx/gfx_resource.h"
+#include "sci/gfx/gfx_tools.h"
+
+namespace Sci {
+
+#define CURSOR_RESOURCE_SIZE 68
+#define CURSOR_SIZE 16
+
+#define GFX_SCI01_CURSOR_COLORS_NR 3
+#define GFX_SCI0_CURSOR_COLORS_NR 2
+
+#define GFX_CURSOR_TRANSPARENT 255
+
+gfx_pixmap_color_t gfx_sci01_cursor_colors[GFX_SCI01_CURSOR_COLORS_NR] = {
+ {GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x00},
+ {GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},
+ {GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa}
+};
+
+gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01) {
+ int colors[4] = {0, 1, GFX_CURSOR_TRANSPARENT, 1};
+ int line;
+ byte *data;
+ gfx_pixmap_t *retval;
+
+ if (isSci01)
+ colors[3] = 2;
+
+ if (size != CURSOR_RESOURCE_SIZE) {
+ GFXERROR("Expected resource size of %d, but found %d\n", CURSOR_RESOURCE_SIZE, size);
+ return NULL;
+ }
+
+ retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(CURSOR_SIZE, CURSOR_SIZE, id, 0, 0));
+ // FIXME: don't copy palette
+ retval->palette = new Palette(gfx_sci01_cursor_colors, isSci01 ? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR);
+ retval->palette->name = "cursor";
+ retval->color_key = GFX_CURSOR_TRANSPARENT;
+
+ if (isSci01) {
+ retval->xoffset = READ_LE_UINT16(resource);
+ retval->yoffset = READ_LE_UINT16(resource + 2);
+ } else if (resource[3]) // center
+ retval->xoffset = retval->yoffset = CURSOR_SIZE / 2;
+ else
+ retval->xoffset = retval->yoffset = 0;
+
+ resource += 4;
+
+ data = retval->index_data;
+ for (line = 0; line < 16; line++) {
+ int mask_a = READ_LE_UINT16(resource + (line << 1));
+ int mask_b = READ_LE_UINT16(resource + 32 + (line << 1));
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ int color_code = ((mask_a << i) & 0x8000) | (((mask_b << i) >> 1) & 0x4000);
+ *data++ = colors[color_code >> 14];
+ }
+ }
+ return retval;
+}
+
+} // End of namespace Sci
diff --git a/engines/sci/gfx/resource/res_manager.cpp b/engines/sci/gfx/resource/res_manager.cpp
index c3646eb6b4..ee0694725b 100644
--- a/engines/sci/gfx/resource/res_manager.cpp
+++ b/engines/sci/gfx/resource/res_manager.cpp
@@ -36,17 +36,6 @@
namespace Sci {
-#define CURSOR_RESOURCE_SIZE 68
-#define CURSOR_SIZE 16
-
-#define GFX_CURSOR_TRANSPARENT 255
-
-gfx_pixmap_color_t gfx_sci01_cursor_colors[3] = {
- {GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x00},
- {GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},
- {GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa}
-};
-
int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) {
switch (type) {
case GFX_RESOURCE_TYPE_VIEW:
@@ -204,10 +193,6 @@ gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *i
ResourceManager *resmgr = (ResourceManager *) state->misc_payload;
Resource *res = resmgr->findResource(kResourceTypeCursor, nr, 0);
int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr);
- int colors[4] = {0, 1, GFX_CURSOR_TRANSPARENT, 1};
- int line;
- byte *data;
- gfx_pixmap_t *retval;
if (!res || !res->data)
return NULL;
@@ -217,44 +202,7 @@ gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *i
return NULL;
}
- if (state->version != SCI_VERSION_0)
- colors[3] = 2;
-
- if (res->size != CURSOR_RESOURCE_SIZE) {
- GFXERROR("Expected resource size of %d, but found %d\n", CURSOR_RESOURCE_SIZE, res->size);
- return NULL;
- }
-
- byte *resource = res->data;
-
- retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(CURSOR_SIZE, CURSOR_SIZE, resid, 0, 0));
- // FIXME: don't copy palette
- retval->palette = new Palette(gfx_sci01_cursor_colors, (state->version != SCI_VERSION_0) ? 3 : 2);
- retval->palette->name = "cursor";
- retval->color_key = GFX_CURSOR_TRANSPARENT;
-
- if (state->version != SCI_VERSION_0) {
- retval->xoffset = READ_LE_UINT16(resource);
- retval->yoffset = READ_LE_UINT16(resource + 2);
- } else if (resource[3]) // center
- retval->xoffset = retval->yoffset = CURSOR_SIZE / 2;
- else
- retval->xoffset = retval->yoffset = 0;
-
- resource += 4;
-
- data = retval->index_data;
- for (line = 0; line < 16; line++) {
- int mask_a = READ_LE_UINT16(resource + (line << 1));
- int mask_b = READ_LE_UINT16(resource + 32 + (line << 1));
- int i;
-
- for (i = 0; i < 16; i++) {
- int color_code = ((mask_a << i) & 0x8000) | (((mask_b << i) >> 1) & 0x4000);
- *data++ = colors[color_code >> 14];
- }
- }
- return retval;
+ return gfxr_draw_cursor(resid, res->data, res->size, state->version != SCI_VERSION_0);
}
int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int version, int *entries_nr, void *internal) {
diff --git a/engines/sci/module.mk b/engines/sci/module.mk
index c96ba97c62..5a39391d3d 100644
--- a/engines/sci/module.mk
+++ b/engines/sci/module.mk
@@ -47,10 +47,11 @@ MODULE_OBJS = \
gfx/resmgr.o \
gfx/sbtree.o \
gfx/sci_widgets.o \
+ gfx/resource/sci_cursor.o \
gfx/resource/sci_font.o \
- gfx/resource/res_pal.o \
- gfx/resource/res_pic.o \
gfx/resource/res_manager.o \
+ gfx/resource/res_pal.o \
+ gfx/resource/res_pic.o \
gfx/resource/res_view0.o \
gfx/resource/res_view1.o \
scicore/sciconsole.o \