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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Mar 7 18:08:32 CET 2009


Revision: 39192
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39192&view=rev
Author:   thebluegr
Date:     2009-03-07 17:08:31 +0000 (Sat, 07 Mar 2009)

Log Message:
-----------
Merged all the different cursor drawing functions inside gfxr_interpreter_get_cursor()

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp
    scummvm/trunk/engines/sci/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sci/gfx/resource/sci_cursor_0.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-03-07 16:34:27 UTC (rev 39191)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-03-07 17:08:31 UTC (rev 39192)
@@ -323,28 +323,6 @@
 ** Returns   : (gfxr_view_t *) The resulting view
 */
 
-gfx_pixmap_t *gfxr_draw_cursor0(int id, byte *resource, int size);
-/* Calculates an SCI0 cursor
-** Parameters: (int) id: The cursor's resource ID
-**             (byte *) resource: Pointer to the resource data
-**             (int) size: Resource size
-** Returns   : (gfx_pixmap_t *) A newly allocated pixmap storing the cursor
-*/
-
-/**********************/
-/*  SCI01 operations  */
-/**********************/
-
-gfx_pixmap_t *gfxr_draw_cursor01(int id, byte *resource, int size);
-/* Calculates an SCI01 cursor
-** Parameters: (int) id: The cursor's resource ID
-**             (byte *) resource: Pointer to the resource data
-**             (int) size: Resource size
-** Returns   : (gfx_pixmap_t *) A newly allocated pixmap containing an index
-**                               color representation of the cursor
-*/
-
-
 /*********************/
 /*  SCI1 operations  */
 /*********************/

Deleted: scummvm/trunk/engines/sci/gfx/resource/sci_cursor_0.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_cursor_0.cpp	2009-03-07 16:34:27 UTC (rev 39191)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_cursor_0.cpp	2009-03-07 17:08:31 UTC (rev 39192)
@@ -1,98 +0,0 @@
-/* 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$
- *
- */
-
-#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}
-};
-
-static gfx_pixmap_t *_gfxr_draw_cursor(int id, byte *resource, int size, int sci01) {
-	int colors[4] = {0, 1, GFX_CURSOR_TRANSPARENT, 1};
-	int line;
-	byte *data;
-	gfx_pixmap_t *retval;
-
-	if (sci01)
-		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));
-	retval->colors = gfx_sci01_cursor_colors;
-	retval->colors_nr = sci01 ? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR;
-	retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
-	retval->color_key = GFX_CURSOR_TRANSPARENT;
-
-	if (sci01) {
-		retval->xoffset = get_int_16(resource);
-		retval->yoffset = get_int_16(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 = get_int_16(resource + (line << 1));
-		int mask_b = get_int_16(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;
-}
-
-gfx_pixmap_t *gfxr_draw_cursor0(int id, byte *resource, int size) {
-	return _gfxr_draw_cursor(id, resource, size, 0);
-}
-
-gfx_pixmap_t *gfxr_draw_cursor01(int id, byte *resource, int size) {
-	return _gfxr_draw_cursor(id, resource, size, 1);
-}
-
-} // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp	2009-03-07 16:34:27 UTC (rev 39191)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp	2009-03-07 17:08:31 UTC (rev 39192)
@@ -35,6 +35,17 @@
 
 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:
@@ -199,6 +210,10 @@
 	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;
@@ -208,10 +223,44 @@
 		return NULL;
 	}
 
-	if (state->version == SCI_VERSION_0)
-		return gfxr_draw_cursor0(resid, res->data, res->size);
+	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));
+	retval->colors = gfx_sci01_cursor_colors;
+	retval->colors_nr = (state->version != SCI_VERSION_0) ? 3 : 2;
+	retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
+	retval->color_key = GFX_CURSOR_TRANSPARENT;
+
+	if (state->version != SCI_VERSION_0) {
+		retval->xoffset = get_int_16(resource);
+		retval->yoffset = get_int_16(resource + 2);
+	} else if (resource[3]) // center
+		retval->xoffset = retval->yoffset = CURSOR_SIZE / 2;
 	else
-		return gfxr_draw_cursor01(resid, res->data, res->size);
+		retval->xoffset = retval->yoffset = 0;
+
+	resource += 4;
+
+	data = retval->index_data;
+	for (line = 0; line < 16; line++) {
+		int mask_a = get_int_16(resource + (line << 1));
+		int mask_b = get_int_16(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;
 }
 
 int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int version, int *entries_nr, void *internal) {

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-03-07 16:34:27 UTC (rev 39191)
+++ scummvm/trunk/engines/sci/module.mk	2009-03-07 17:08:31 UTC (rev 39192)
@@ -46,7 +46,6 @@
 	gfx/resmgr.o \
 	gfx/sbtree.o \
 	gfx/sci_widgets.o \
-	gfx/resource/sci_cursor_0.o \
 	gfx/resource/sci_font.o \
 	gfx/resource/sci_pal_1.o \
 	gfx/resource/sci_pic_0.o \


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