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

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Sun Mar 1 00:46:51 CET 2009


Revision: 38988
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38988&view=rev
Author:   jvprat
Date:     2009-02-28 23:46:50 +0000 (Sat, 28 Feb 2009)

Log Message:
-----------
SCI: Use the ResourceType enum instead of integers where it makes sense

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kmenu.cpp
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/message.cpp
    scummvm/trunk/engines/sci/engine/savegame.cfsml
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptconsole.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp
    scummvm/trunk/engines/sci/scicore/decompress0.cpp
    scummvm/trunk/engines/sci/scicore/decompress01.cpp
    scummvm/trunk/engines/sci/scicore/decompress1.cpp
    scummvm/trunk/engines/sci/scicore/decompress11.cpp
    scummvm/trunk/engines/sci/scicore/resource.cpp
    scummvm/trunk/engines/sci/scicore/resource.h
    scummvm/trunk/engines/sci/scicore/resource_map.cpp
    scummvm/trunk/engines/sci/scicore/resource_patch.cpp
    scummvm/trunk/engines/sci/scicore/script.cpp
    scummvm/trunk/engines/sci/scicore/vocab.cpp
    scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
    scummvm/trunk/engines/sci/sfx/player/polled.cpp
    scummvm/trunk/engines/sci/sfx/player/realtime.cpp

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -142,7 +142,7 @@
 			file.close();
 			_sci1_alloc_system_colors(s);
 		} else {
-			resource = s->resmgr->findResource(sci_palette, 999, 1);
+			resource = s->resmgr->findResource(kResourceTypePalette, 999, 1);
 			if (resource) {
 				if (s->version < SCI_VERSION(1, 001, 000))
 					s->gfx_state->resstate->static_palette = gfxr_read_pal1(999, &s->gfx_state->resstate->static_palette_entries,
@@ -151,7 +151,7 @@
 					s->gfx_state->resstate->static_palette = gfxr_read_pal11(999, &s->gfx_state->resstate->static_palette_entries,
 																			resource->data, resource->size);
 				_sci1_alloc_system_colors(s);
-				s->resmgr->unlockResource(resource, sci_palette, 999);
+				s->resmgr->unlockResource(resource, 999, kResourceTypePalette);
 			} else {
 				sciprintf("Couldn't find the default palette!\n");
 			}
@@ -184,7 +184,7 @@
 
 	font_nr = -1;
 	do {
-		resource = s->resmgr->testResource(sci_font, ++font_nr);
+		resource = s->resmgr->testResource(kResourceTypeFont, ++font_nr);
 	} while ((!resource) && (font_nr < sci_max_resource_nr[s->resmgr->_sciVersion]));
 
 	if (!resource) {
@@ -295,7 +295,7 @@
 	int ok = 0;
 
 	do {
-		ok |= s->resmgr->testResource(sci_cursor, resource_nr++) != NULL;
+		ok |= s->resmgr->testResource(kResourceTypeCursor, resource_nr++) != NULL;
 	} while (resource_nr < 1000 && !ok);
 
 	return ok;
@@ -307,7 +307,7 @@
 	char *seeker_ptr;
 	int classnr;
 
-	Resource *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1);
+	Resource *vocab996 = s->resmgr->findResource(kResourceTypeVocab, 996, 1);
 
 	if (!vocab996)
 		s->classtable_size = 20;
@@ -317,7 +317,7 @@
 	s->classtable = (Class*)sci_calloc(sizeof(Class), s->classtable_size);
 
 	for (scriptnr = 0; scriptnr < 1000; scriptnr++) {
-		Resource *heap = s->resmgr->findResource(sci_heap, scriptnr, 0);
+		Resource *heap = s->resmgr->findResource(kResourceTypeHeap, scriptnr, 0);
 
 		if (heap) {
 			int global_vars = getUInt16(heap->data + 2);
@@ -362,7 +362,7 @@
 	int classnr;
 	int magic_offset; // For strange scripts in older SCI versions
 
-	Resource *vocab996 = s->resmgr->findResource(sci_vocab, 996, 1);
+	Resource *vocab996 = s->resmgr->findResource(kResourceTypeVocab, 996, 1);
 
 	if (!vocab996)
 		s->classtable_size = 20;
@@ -373,7 +373,7 @@
 
 	for (scriptnr = 0; scriptnr < 1000; scriptnr++) {
 		int objtype = 0;
-		Resource *script = s->resmgr->findResource(sci_script, scriptnr, 0);
+		Resource *script = s->resmgr->findResource(kResourceTypeScript, scriptnr, 0);
 
 		if (script) {
 			if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER)
@@ -435,7 +435,7 @@
 
 		}
 	}
-	s->resmgr->unlockResource(vocab996, sci_vocab, 996);
+	s->resmgr->unlockResource(vocab996, 996, kResourceTypeVocab);
 	vocab996 = NULL;
 	return 0;
 }

Modified: scummvm/trunk/engines/sci/engine/kmenu.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -210,7 +210,7 @@
 
 	i = 999;
 	while (!bodyfont_res && (i > -1))
-		bodyfont_res = s->resmgr->testResource(sci_font, i--);
+		bodyfont_res = s->resmgr->testResource(kResourceTypeFont, i--);
 
 	if (i == -1) {
 		sciprintf("Sorry, couldn't find a font...\n");

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -118,7 +118,8 @@
 	int restype = KP_UINT(argv[0]);
 	int resnr = KP_UINT(argv[1]);
 
-	if (restype == sci_memory) // Request to dynamically allocate hunk memory for later use
+	// Request to dynamically allocate hunk memory for later use
+	if (restype == kResourceTypeMemory)
 		return kalloc(s, "kLoad()", resnr);
 
 	return make_reg(0, ((restype << 11) | resnr)); // Return the resource identifier as handle
@@ -133,11 +134,11 @@
 
 	switch (state) {
 	case 1 :
-		s->resmgr->findResource(restype, resnr, 1);
+		s->resmgr->findResource((ResourceType)restype, resnr, 1);
 		break;
 	case 0 :
-		which = s->resmgr->findResource(restype, resnr, 0);
-		s->resmgr->unlockResource(which, resnr, restype);
+		which = s->resmgr->findResource((ResourceType)restype, resnr, 0);
+		s->resmgr->unlockResource(which, resnr, (ResourceType)restype);
 		break;
 	}
 	return s->r_acc;
@@ -148,7 +149,7 @@
 	int restype = KP_UINT(argv[0]);
 	reg_t resnr = argv[1];
 
-	if (restype == sci_memory)
+	if (restype == kResourceTypeMemory)
 		kfree(s, resnr);
 
 	return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -93,7 +93,7 @@
 
 static void script_set_priority(EngineState *s, reg_t obj, int priority) {
 	int song_nr = GET_SEL32V(obj, number);
-	Resource *song = s->resmgr->findResource(sci_sound, song_nr, 0);
+	Resource *song = s->resmgr->findResource(kResourceTypeSound, song_nr, 0);
 	int flags = GET_SEL32V(obj, flags);
 
 	if (priority == -1) {
@@ -110,7 +110,7 @@
 }
 
 song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
-	Resource *song = s->resmgr->findResource(sci_sound, song_nr, 0);
+	Resource *song = s->resmgr->findResource(kResourceTypeSound, song_nr, 0);
 
 	if (!song)
 		return NULL;
@@ -486,7 +486,7 @@
 		//int vol = GET_SEL32V(obj, vol);
 		//int pri = GET_SEL32V(obj, pri);
 
-		if (obj.segment && (s->resmgr->testResource(sci_sound, number))) {
+		if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
 			sciprintf("Initializing song number %d\n", number);
 			SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
 			                                build_iterator(s, number,
@@ -802,7 +802,7 @@
 		}
 
 		if (!GET_SEL32V(obj, nodePtr) && obj.segment) {
-			if (!s->resmgr->testResource(sci_sound, number)) {
+			if (!s->resmgr->testResource(kResourceTypeSound, number)) {
 				sciprintf("Could not open song number %d\n", number);
 				return NULL_REG;
 			}
@@ -839,7 +839,7 @@
 			sfx_remove_song(&s->sound, handle);
 		}
 
-		if (obj.segment && (s->resmgr->testResource(sci_sound, number))) {
+		if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
 			sciprintf("Initializing song number %d\n", number);
 			SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
 			                                build_iterator(s, number,

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -48,7 +48,7 @@
 	else {
 		int textlen;
 		int _index = index;
-		textres = s->resmgr->findResource(sci_text, address.offset, 0);
+		textres = s->resmgr->findResource(kResourceTypeText, address.offset, 0);
 
 		if (!textres) {
 			SCIkwarn(SCIkERROR, "text.%03d not found\n", address);
@@ -709,7 +709,7 @@
 
 
 reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	Resource *textres = s->resmgr->findResource(sci_text, UKPV(0), 0);
+	Resource *textres = s->resmgr->findResource(kResourceTypeText, UKPV(0), 0);
 	char *seeker;
 	int counter = UKPV(1);
 

Modified: scummvm/trunk/engines/sci/engine/message.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/message.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/message.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -161,7 +161,7 @@
 		return 1;
 
 	state->module = module;
-	state->current_res = state->resmgr->findResource(sci_message, module, 0);
+	state->current_res = state->resmgr->findResource(kResourceTypeMessage, module, 0);
 
 	if (state->current_res == NULL || state->current_res->data == NULL) {
 		sciprintf("Message subsystem: Failed to load %d.MSG\n", module);
@@ -186,7 +186,7 @@
 };
 
 void message_state_initialize(ResourceManager *resmgr, MessageState *state) {
-	//Resource *tester = resmgr->findResource(sci_message, 0, 0);
+	//Resource *tester = resmgr->findResource(kResourceTypeMessage, 0, 0);
 	//int version;
 
 	//if (tester == NULL)

Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-28 23:46:50 UTC (rev 38988)
@@ -851,9 +851,9 @@
 
 	scr->buf = (byte *)malloc(scr->buf_size);
 
-	script = s->resmgr->findResource(sci_script, scr->nr, 0);
+	script = s->resmgr->findResource(kResourceTypeScript, scr->nr, 0);
 	if (s->version >= SCI_VERSION(1,001,000))
-		heap = s->resmgr->findResource(sci_heap, scr->nr, 0);
+		heap = s->resmgr->findResource(kResourceTypeHeap, scr->nr, 0);
 
 	switch (s->seg_manager->isSci1_1) {
 	case 0 :

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -4947,9 +4947,9 @@
 
 	scr->buf = (byte *)malloc(scr->buf_size);
 
-	script = s->resmgr->findResource(sci_script, scr->nr, 0);
+	script = s->resmgr->findResource(kResourceTypeScript, scr->nr, 0);
 	if (s->version >= SCI_VERSION(1,001,000))
-		heap = s->resmgr->findResource(sci_heap, scr->nr, 0);
+		heap = s->resmgr->findResource(kResourceTypeHeap, scr->nr, 0);
 
 	switch (s->seg_manager->isSci1_1) {
 	case 0 :

Modified: scummvm/trunk/engines/sci/engine/scriptconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -677,13 +677,13 @@
 
 // Console commands and support functions
 
-static int get_resource_number(char *resid) {
+static ResourceType parseResourceType(char *resid) {
 	// Gets the resource number of a resource string, or returns -1
-	int i, res = -1;
+	ResourceType res = kResourceTypeInvalid;
 
-	for (i = 0; i < sci_invalid_resource; i++)
-		if (strcmp(sci_resource_types[i], resid) == 0)
-			res = i;
+	for (int i = 0; i < kResourceTypeInvalid; i++)
+		if (strcmp(getResourceTypeName((ResourceType)i), resid) == 0)
+			res = (ResourceType)i;
 
 	return res;
 }
@@ -833,16 +833,16 @@
 			else if (!strcmp("words", cmd_params[0].str))
 				return c_list_words(s);
 			else if (strcmp("restypes", cmd_params[0].str) == 0) {
-				for (i = 0; i < sci_invalid_resource; i++)
-					sciprintf("%s\n", sci_resource_types[i]);
+				for (i = 0; i < kResourceTypeInvalid; i++)
+					sciprintf("%s\n", getResourceTypeName((ResourceType)i));
 			} else {
-				int res = get_resource_number(cmd_params[0].str);
-				if (res == -1)
+				ResourceType res = parseResourceType(cmd_params[0].str);
+				if (res == kResourceTypeInvalid)
 					sciprintf("Unknown resource type: '%s'\n", cmd_params[0].str);
 				else {
 					for (i = 0; i < sci_max_resource_nr[s->resmgr->_sciVersion]; i++)
 						if (s->resmgr->testResource(res, i))
-							sciprintf("%s.%03d\n", sci_resource_types[res], i);
+							sciprintf("%s.%03d\n", getResourceTypeName((ResourceType)res), i);
 				}
 			}
 		}
@@ -909,8 +909,8 @@
 }
 
 static int c_size(EngineState *s) {
-	int res = get_resource_number(cmd_params[0].str);
-	if (res == -1)
+	ResourceType res = parseResourceType(cmd_params[0].str);
+	if (res == kResourceTypeInvalid)
 		sciprintf("Resource type '%s' is not valid\n", cmd_params[0].str);
 	else {
 		Resource *resource = s->resmgr->findResource(res, cmd_params[1].val, 0);
@@ -924,9 +924,9 @@
 }
 
 static int c_dump(EngineState *s) {
-	int res = get_resource_number(cmd_params[0].str);
+	ResourceType res = parseResourceType(cmd_params[0].str);
 
-	if (res == -1)
+	if (res == kResourceTypeInvalid)
 		sciprintf("Resource type '%s' is not valid\n", cmd_params[0].str);
 	else {
 		Resource *resource = s->resmgr->findResource(res, cmd_params[1].val, 0);
@@ -940,10 +940,11 @@
 }
 
 static int c_hexgrep(EngineState *s) {
-	int i, seeklen, resnr, restype, resmax;
+	int i, seeklen, resnr, resmax;
 	unsigned char *seekstr = NULL;
 	Resource *script = NULL;
 	char *dot = strchr(cmd_params[0].str, '.');
+	ResourceType restype;
 
 	if (NULL == s) {
 		fprintf(stderr, "console.c: c_hexgrep(): NULL passed for s\r\n");
@@ -968,7 +969,8 @@
 		resmax = 999;
 	}
 
-	if ((restype = get_resource_number(cmd_params[0].str)) == -1) {
+	restype = parseResourceType(cmd_params[0].str);
+	if (restype == kResourceTypeInvalid) {
 		sciprintf("Unknown resource type \"%s\"\n", cmd_params[0].str);
 		free(seekstr);
 		return 1;
@@ -992,7 +994,7 @@
 						seeker = seekerold + 1;
 
 						if (!output_script_name) {
-							sciprintf("\nIn %s.%03d:\n", sci_resource_types[restype], resnr);
+							sciprintf("\nIn %s.%03d:\n", getResourceTypeName((ResourceType)restype), resnr);
 							output_script_name = 1;
 						}
 						sciprintf("   0x%04x\n", seekerold);

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -248,7 +248,7 @@
 #undef SONGDATA
 
 int c_sfx_01_header(EngineState *s) {
-	Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0);
+	Resource *song = s->resmgr->findResource(kResourceTypeSound, cmd_params[0].val, 0);
 
 	if (!song) {
 		sciprintf("Doesn't exist\n");
@@ -261,7 +261,7 @@
 }
 
 int c_sfx_01_track(EngineState *s) {
-	Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0);
+	Resource *song = s->resmgr->findResource(kResourceTypeSound, cmd_params[0].val, 0);
 
 	int offset = cmd_params[1].val;
 
@@ -2204,7 +2204,7 @@
 static int c_resource_id(EngineState *s) {
 	int id = cmd_params[0].val;
 
-	sciprintf("%s.%d (0x%x)\n", sci_resource_types[id >> 11], id &0x7ff, id & 0x7ff);
+	sciprintf("%s.%d (0x%x)\n", getResourceTypeName((ResourceType)(id >> 11)), id & 0x7ff, id & 0x7ff);
 
 	return 0;
 }
@@ -2409,7 +2409,7 @@
 }
 
 static int c_is_sample(EngineState *s) {
-	Resource *song = s->resmgr->findResource(sci_sound, cmd_params[0].val, 0);
+	Resource *song = s->resmgr->findResource(kResourceTypeSound, cmd_params[0].val, 0);
 	song_iterator_t *songit;
 	sfx_pcm_feed_t *data;
 

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -152,8 +152,8 @@
 }
 
 void SegManager::setScriptSize(MemObject *mem, EngineState *s, int script_nr) {
-	Resource *script = s->resmgr->findResource(sci_script, script_nr, 0);
-	Resource *heap = s->resmgr->findResource(sci_heap, script_nr, 0);
+	Resource *script = s->resmgr->findResource(kResourceTypeScript, script_nr, 0);
+	Resource *heap = s->resmgr->findResource(kResourceTypeHeap, script_nr, 0);
 
 	mem->data.script.script_size = script->size;
 	mem->data.script.heap_size = 0; // Set later

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -1595,13 +1595,13 @@
 	int c;
 	Resource *script = {0};
 
-	if (s->resmgr->findResource(sci_heap, 0, 0)) {
+	if (s->resmgr->findResource(kResourceTypeHeap, 0, 0)) {
 		version_require_later_than(s, SCI_VERSION(1, 001, 000));
 		return;
 	}
 
 	for (c = 0; c < 1000; c++) {
-		if ((script = s->resmgr->findResource(sci_script, c, 0))) {
+		if ((script = s->resmgr->findResource(kResourceTypeScript, c, 0))) {
 
 			int id = getInt16(script->data);
 
@@ -1679,9 +1679,9 @@
 
 	*was_new = 1;
 
-	*script = s->resmgr->findResource(sci_script, script_nr, 0);
+	*script = s->resmgr->findResource(kResourceTypeScript, script_nr, 0);
 	if (s->version >= SCI_VERSION(1, 001, 000))
-		*heap = s->resmgr->findResource(sci_heap, script_nr, 0);
+		*heap = s->resmgr->findResource(kResourceTypeHeap, script_nr, 0);
 
 	if (!*script || (s->version >= SCI_VERSION(1, 001, 000) && !heap)) {
 		sciprintf("Script 0x%x requested but not found\n", script_nr);

Modified: scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_resmgr.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -71,7 +71,7 @@
 int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
 	int flags, int default_palette, int nr, void *internal) {
 	ResourceManager *resmgr = (ResourceManager *)state->misc_payload;
-	Resource *res = resmgr->findResource(sci_pic, nr, 0);
+	Resource *res = resmgr->findResource(kResourceTypePic, nr, 0);
 	int need_unscaled = unscaled_pic != NULL;
 	gfxr_pic0_params_t style, basic_style;
 
@@ -149,7 +149,7 @@
 
 gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) {
 	ResourceManager *resmgr = (ResourceManager *) state->misc_payload;
-	Resource *res = resmgr->findResource(sci_view, nr, 0);
+	Resource *res = resmgr->findResource(kResourceTypeView, nr, 0);
 	int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr);
 	gfxr_view_t *result = 0;
 
@@ -188,7 +188,7 @@
 
 gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) {
 	ResourceManager *resmgr = (ResourceManager *)state->misc_payload;
-	Resource *res = resmgr->findResource(sci_font, nr, 0);
+	Resource *res = resmgr->findResource(kResourceTypeFont, nr, 0);
 	if (!res || !res->data)
 		return NULL;
 
@@ -197,7 +197,7 @@
 
 gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) {
 	ResourceManager *resmgr = (ResourceManager *) state->misc_payload;
-	Resource *res = resmgr->findResource(sci_cursor, nr, 0);
+	Resource *res = resmgr->findResource(kResourceTypeCursor, nr, 0);
 	int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr);
 
 	if (!res || !res->data)
@@ -216,7 +216,7 @@
 
 int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int version, int *entries_nr, void *internal) {
 	ResourceManager *resmgr = (ResourceManager *) state->misc_payload;
-	int restype;
+	ResourceType restype;
 	int *resources;
 	int count = 0;
 	int top = sci_max_resource_nr[version] + 1;
@@ -224,19 +224,19 @@
 	switch (type) {
 
 	case GFX_RESOURCE_TYPE_VIEW:
-		restype = sci_view;
+		restype = kResourceTypeView;
 		break;
 
 	case GFX_RESOURCE_TYPE_PIC:
-		restype = sci_pic;
+		restype = kResourceTypePic;
 		break;
 
 	case GFX_RESOURCE_TYPE_CURSOR:
-		restype = sci_cursor;
+		restype = kResourceTypeCursor;
 		break;
 
 	case GFX_RESOURCE_TYPE_FONT:
-		restype = sci_font;
+		restype = kResourceTypeFont;
 		break;
 
 	default:
@@ -270,7 +270,7 @@
 	if (version < SCI_VERSION_01_VGA)
 		return NULL;
 
-	res = resmgr->findResource(sci_palette, nr, 0);
+	res = resmgr->findResource(kResourceTypePalette, nr, 0);
 	if (!res || !res->data)
 		return NULL;
 

Modified: scummvm/trunk/engines/sci/scicore/decompress0.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress0.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/decompress0.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -244,11 +244,13 @@
 		return SCI_ERROR_IO_ERROR;
 
 	result->number = result->id & 0x07ff;
-	result->type = result->id >> 11;
+	uint8 type = result->id >> 11;
 
-	if ((result->number > sci_max_resource_nr[sci_version]) || (result->type > sci_invalid_resource))
+	if ((result->number > sci_max_resource_nr[sci_version]) || (type > kResourceTypeInvalid))
 		return SCI_ERROR_DECOMPRESSION_INSANE;
 
+	result->type = (ResourceType)type;
+
 	compressedLength = stream.readUint16LE();
 	result->size = stream.readUint16LE();
 	compressionMethod = stream.readUint16LE();
@@ -280,7 +282,7 @@
 #ifdef _SCI_DECOMPRESS_DEBUG
 	fprintf(stderr, "Resource %s.%03hi encrypted with method %hi at %.2f%%"
 	        " ratio\n",
-	        sci_resource_types[result->type], result->number, compressionMethod,
+	        getResourceTypeName(result->type), result->number, compressionMethod,
 	        (result->size == 0) ? -1.0 :
 	        (100.0 * compressedLength / result->size));
 	fprintf(stderr, "  compressedLength = 0x%hx, actualLength=0x%hx\n",
@@ -324,7 +326,7 @@
 
 	default:
 		fprintf(stderr, "Resource %s.%03hi: Compression method %hi not "
-		        "supported!\n", sci_resource_types[result->type], result->number,
+		        "supported!\n", getResourceTypeName(result->type), result->number,
 		        compressionMethod);
 		free(result->data);
 		result->data = 0; // So that we know that it didn't work

Modified: scummvm/trunk/engines/sci/scicore/decompress01.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress01.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/decompress01.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -500,11 +500,13 @@
 		return SCI_ERROR_IO_ERROR;
 
 	result->number = result->id & 0x07ff;
-	result->type = result->id >> 11;
+	uint8 type = result->id >> 11;
 
-	if ((result->number > sci_max_resource_nr[sci_version] || (result->type > sci_invalid_resource)))
+	if ((result->number > sci_max_resource_nr[sci_version] || (type > kResourceTypeInvalid)))
 		return SCI_ERROR_DECOMPRESSION_INSANE;
 
+	result->type = (ResourceType)type;
+
 	compressedLength = stream.readUint16LE();
 	result->size = stream.readUint16LE();
 	compressionMethod = stream.readUint16LE();
@@ -611,7 +613,7 @@
 
 	default:
 		fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not "
-		        "supported!\n", sci_resource_types[result->type], result->number,
+		        "supported!\n", getResourceTypeName(result->type), result->number,
 		        compressionMethod);
 		free(result->data);
 		result->data = 0; // So that we know that it didn't work

Modified: scummvm/trunk/engines/sci/scicore/decompress1.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress1.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/decompress1.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -278,22 +278,26 @@
 			return SCI_ERROR_IO_ERROR;
 
 		result->number = result->id & 0x07ff;
-		result->type = result->id >> 11;
+		uint16 type = result->id >> 11;
 
-		if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_EARLY]) || (result->type > sci_invalid_resource))
+		if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_EARLY]) || (type > kResourceTypeInvalid))
 			return SCI_ERROR_DECOMPRESSION_INSANE;
+
+		result->type = (ResourceType)type;
 	} else {
 		result->id = stream.readByte();
 		if (stream.err())
 			return SCI_ERROR_IO_ERROR;
 
-		result->type = result->id & 0x7f;
+		uint16 type = result->id & 0x7f;
 		result->number = stream.readUint16LE();
 		if (stream.err())
 			return SCI_ERROR_IO_ERROR;
 
-		if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_LATE]) || (result->type > sci_invalid_resource))
+		if ((result->number >= sci_max_resource_nr[SCI_VERSION_1_LATE]) || (type > kResourceTypeInvalid))
 			return SCI_ERROR_DECOMPRESSION_INSANE;
+
+		result->type = (ResourceType)type;
 	}
 
 	compressedLength = stream.readUint16LE();
@@ -399,7 +403,7 @@
 
 	default:
 		fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not "
-		        "supported!\n", sci_resource_types[result->type], result->number,
+		        "supported!\n", getResourceTypeName(result->type), result->number,
 		        compressionMethod);
 		free(result->data);
 		result->data = 0; // So that we know that it didn't work

Modified: scummvm/trunk/engines/sci/scicore/decompress11.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress11.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/decompress11.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -49,9 +49,10 @@
 	if (stream.err())
 		return SCI_ERROR_IO_ERROR;
 
-	result->type = result->id & 0x7f;
-	if ((result->type > sci_invalid_resource))
+	uint16 type = result->id & 0x7f;
+	if (type > kResourceTypeInvalid)
 		return SCI_ERROR_DECOMPRESSION_INSANE;
+	result->type = (ResourceType)type;
 
 	result->number = stream.readUint16LE();
 	compressedLength = stream.readUint16LE();
@@ -91,7 +92,7 @@
 #ifdef _SCI_DECOMPRESS_DEBUG
 	fprintf(stderr, "Resource %i.%s encrypted with method SCI1.1/%hi at %.2f%%"
 	        " ratio\n",
-	        result->number, sci_resource_type_suffixes[result->type],
+	        result->number, getResourceTypeSuffix(result->type),
 	        compressionMethod,
 	        (result->size == 0) ? -1.0 :
 	        (100.0 * compressedLength / result->size));
@@ -130,7 +131,7 @@
 	case 3:
 	case 4: // NYI
 		fprintf(stderr, "Resource %d.%s: Warning: compression type #%d not yet implemented\n",
-		        result->number, sci_resource_type_suffixes[result->type], compressionMethod);
+		        result->number, getResourceTypeSuffix(result->type), compressionMethod);
 		free(result->data);
 		result->data = NULL;
 		result->status = SCI_STATUS_NOMALLOC;
@@ -138,7 +139,7 @@
 
 	default:
 		fprintf(stderr, "Resource %d.%s: Compression method SCI1/%hi not "
-		        "supported!\n", result->number, sci_resource_type_suffixes[result->type],
+		        "supported!\n", result->number, getResourceTypeSuffix(result->type),
 		        compressionMethod);
 		free(result->data);
 		result->data = NULL; // So that we know that it didn't work

Modified: scummvm/trunk/engines/sci/scicore/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/resource.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -65,20 +65,29 @@
 	"SCI version is unsupported"
 };
 
-const char *sci_resource_types[] = {"view", "pic", "script", "text", "sound",
-                                    "memory", "vocab", "font", "cursor",
-                                    "patch", "bitmap", "palette", "cdaudio",
-                                    "audio", "sync", "message", "map", "heap"
-                                   };
 // These are the 18 resource types supported by SCI1
+const char *resourceTypeNames[] = {
+	"view", "pic", "script", "text", "sound",
+	"memory", "vocab", "font", "cursor",
+	"patch", "bitmap", "palette", "cdaudio",
+	"audio", "sync", "message", "map", "heap"
+};
 
-const char *sci_resource_type_suffixes[] = {"v56", "p56", "scr", "tex", "snd",
-        "   ", "voc", "fon", "cur", "pat",
-        "bit", "pal", "cda", "aud", "syn",
-        "msg", "map", "hep"
-                                           };
+const char *resourceTypeSuffixes[] = {
+	"v56", "p56", "scr", "tex", "snd",
+	"   ", "voc", "fon", "cur", "pat",
+	"bit", "pal", "cda", "aud", "syn",
+	"msg", "map", "hep"
+};
 
+const char *getResourceTypeName(ResourceType restype) {
+	return resourceTypeNames[restype];
+}
 
+const char *getResourceTypeSuffix(ResourceType restype) {
+	return resourceTypeSuffixes[restype];
+}
+
 int resourcecmp(const void *first, const void *second);
 
 typedef int decomp_funct(Resource *result, Common::ReadStream &stream, int sci_version);
@@ -133,7 +142,7 @@
 	res->alt_sources = rsrc;
 }
 
-Resource *ResourceManager::findResourceUnsorted(Resource *res, int res_nr, int type, int number) {
+Resource *ResourceManager::findResourceUnsorted(Resource *res, int res_nr, ResourceType type, int number) {
 	int i;
 	for (i = 0; i < res_nr; i++)
 		if (res[i].number == number && res[i].type == type)
@@ -258,7 +267,7 @@
 
 		if (error) {
 			sciprintf("Error %d occured while reading %s.%03d from resource file: %s\n",
-			          error, sci_resource_types[res->type], res->number, sci_error_types[error]);
+			          error, getResourceTypeName(res->type), res->number, sci_error_types[error]);
 
 			if (protect)
 				memcpy(res, &backup, sizeof(Resource));
@@ -271,7 +280,7 @@
 
 }
 
-Resource *ResourceManager::testResource(int type, int number) {
+Resource *ResourceManager::testResource(ResourceType type, int number) {
 	Resource binseeker;
 	binseeker.type = type;
 	binseeker.number = number;
@@ -290,7 +299,7 @@
 	mgr->_sciVersion = SCI_VERSION_AUTODETECT;
 
 	for (i = 0; i < 1000; i++) {
-		res = mgr->testResource(sci_view, i);
+		res = mgr->testResource(kResourceTypeView, i);
 
 		if (!res)
 			continue;
@@ -315,7 +324,7 @@
 
 	// Try the same thing with pics
 	for (i = 0; i < 1000; i++) {
-		res = mgr->testResource(sci_pic, i);
+		res = mgr->testResource(kResourceTypePic, i);
 
 		if (!res)
 			continue;
@@ -479,7 +488,7 @@
 	if (version == SCI_VERSION_AUTODETECT)
 		switch (resmap_version) {
 		case SCI_VERSION_0:
-			if (testResource(sci_vocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB)) {
+			if (testResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB)) {
 				version = sci_test_view_type(this);
 				if (version == SCI_VERSION_01_VGA) {
 					sciprintf("Resmgr: Detected KQ5 or similar\n");
@@ -487,12 +496,12 @@
 					sciprintf("Resmgr: Detected SCI0\n");
 					version = SCI_VERSION_0;
 				}
-			} else if (testResource(sci_vocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB)) {
+			} else if (testResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB)) {
 				version = sci_test_view_type(this);
 				if (version == SCI_VERSION_01_VGA) {
 					sciprintf("Resmgr: Detected KQ5 or similar\n");
 				} else {
-					if (testResource(sci_vocab, 912)) {
+					if (testResource(kResourceTypeVocab, 912)) {
 						sciprintf("Resmgr: Running KQ1 or similar, using SCI0 resource encoding\n");
 						version = SCI_VERSION_0;
 					} else {
@@ -515,7 +524,7 @@
 			sciprintf("Resmgr: Detected Jones/CD or similar\n");
 			break;
 		case SCI_VERSION_1: {
-			Resource *res = testResource(sci_script, 0);
+			Resource *res = testResource(kResourceTypeScript, 0);
 
 			_sciVersion = version = SCI_VERSION_1_EARLY;
 			loadResource(res, true);
@@ -611,7 +620,7 @@
 	_memoryLRU += res->size;
 #if (SCI_VERBOSE_RESMGR > 1)
 	fprintf(stderr, "Adding %s.%03d (%d bytes) to lru control: %d bytes total\n",
-	        sci_resource_types[res->type], res->number, res->size,
+	        getResourceTypeName(res->type), res->number, res->size,
 	        mgr->_memoryLRU);
 
 #endif
@@ -626,7 +635,7 @@
 
 	while (res) {
 		fprintf(stderr, "\t%s.%03d: %d bytes\n",
-		        sci_resource_types[res->type], res->number,
+		        getResourceTypeName(res->type), res->number,
 		        res->size);
 		mem += res->size;
 		++entries;
@@ -650,18 +659,18 @@
 		removeFromLRU(goner);
 		unalloc(goner);
 #ifdef SCI_VERBOSE_RESMGR
-		sciprintf("Resmgr-debug: LRU: Freeing %s.%03d (%d bytes)\n", sci_resource_types[goner->type], goner->number, goner->size);
+		sciprintf("Resmgr-debug: LRU: Freeing %s.%03d (%d bytes)\n", getResourceTypeName(goner->type), goner->number, goner->size);
 #endif
 	}
 }
 
-Resource *ResourceManager::findResource(int type, int number, int lock) {
+Resource *ResourceManager::findResource(ResourceType type, int number, int lock) {
 	Resource *retval;
 
 	if (number >= sci_max_resource_nr[_sciVersion]) {
 		int modded_number = number % sci_max_resource_nr[_sciVersion];
 		sciprintf("[resmgr] Requested invalid resource %s.%d, mapped to %s.%d\n",
-		          sci_resource_types[type], number, sci_resource_types[type], modded_number);
+		          getResourceTypeName(type), number, getResourceTypeName(type), modded_number);
 		number = modded_number;
 	}
 
@@ -697,23 +706,23 @@
 	if (retval->data)
 		return retval;
 	else {
-		sciprintf("Resmgr: Failed to read %s.%03d\n", sci_resource_types[retval->type], retval->number);
+		sciprintf("Resmgr: Failed to read %s.%03d\n", getResourceTypeName(retval->type), retval->number);
 		return NULL;
 	}
 }
 
-void ResourceManager::unlockResource(Resource *res, int resnum, int restype) {
+void ResourceManager::unlockResource(Resource *res, int resnum, ResourceType restype) {
 	if (!res) {
-		if (restype >= ARRAYSIZE(sci_resource_types))
+		if (restype == kResourceTypeInvalid)
 			sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %03d.%03d!\n", restype, resnum);
 		else
-			sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d!\n", sci_resource_types[restype], resnum);
+			sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d!\n", getResourceTypeName(restype), resnum);
 		return;
 	}
 
 	if (res->status != SCI_STATUS_LOCKED) {
 		sciprintf("Resmgr: Warning: Attempt to unlock unlocked resource %s.%03d\n",
-		          sci_resource_types[res->type], res->number);
+		          getResourceTypeName(res->type), res->number);
 		return;
 	}
 

Modified: scummvm/trunk/engines/sci/scicore/resource.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.h	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/resource.h	2009-02-28 23:46:50 UTC (rev 38988)
@@ -97,30 +97,48 @@
 
 extern const char *sci_error_types[];
 extern const char *sci_version_types[];
-extern const char *sci_resource_types[];
-extern const char *sci_resource_type_suffixes[]; /* Suffixes for SCI1 patch files */
 extern const int sci_max_resource_nr[]; /* Highest possible resource numbers */
 
 
-enum ResourceTypes {
-	sci_view = 0, sci_pic, sci_script, sci_text,
-	sci_sound, sci_memory, sci_vocab, sci_font,
-	sci_cursor, sci_patch, sci_bitmap, sci_palette,
-	sci_cdaudio, sci_audio, sci_sync, sci_message,
-	sci_map, sci_heap, sci_invalid_resource
+enum ResourceType {
+	kResourceTypeView = 0,
+	kResourceTypePic,
+	kResourceTypeScript,
+	kResourceTypeText,
+	kResourceTypeSound,
+	kResourceTypeMemory,
+	kResourceTypeVocab,
+	kResourceTypeFont,
+	kResourceTypeCursor,
+	kResourceTypePatch,
+	kResourceTypeBitmap,
+	kResourceTypePalette,
+	kResourceTypeCdAudio,
+	kResourceTypeAudio,
+	kResourceTypeSync,
+	kResourceTypeMessage,
+	kResourceTypeMap,
+	kResourceTypeHeap,
+	kResourceTypeInvalid
 };
 
-#define sci0_last_resource sci_patch
-#define sci1_last_resource sci_heap
+const char *getResourceTypeName(ResourceType restype);
+// Suffixes for SCI1 patch files
+const char *getResourceTypeSuffix(ResourceType restype);
+
+#define sci0_last_resource kResourceTypePatch
+#define sci1_last_resource kResourceTypeHeap
 /* Used for autodetection */
 
 
+#if 0
 struct resource_index_struct {
 	unsigned short resource_id;
 	unsigned int resource_location;
 }; /* resource type as stored in the resource.map file */
 
 typedef struct resource_index_struct resource_index_t;
+#endif
 
 struct ResourceSource {
 	ResSourceType source_type;
@@ -147,7 +165,7 @@
 // to let the rest of the engine compile without changes
 	unsigned char *data;
 	unsigned short number;
-	unsigned short type;
+	ResourceType type;
 	uint16 id; /* contains number and type */
 	unsigned int size;
 	unsigned int file_offset; /* Offset in file */
@@ -163,6 +181,7 @@
 class ResourceManager {
 public:
 	int _sciVersion; /* SCI resource version to use */
+
 	/**
 	 * Creates a new FreeSCI resource manager.
 	 * @param version		The SCI version to look for; use SCI_VERSION_AUTODETECT
@@ -180,7 +199,9 @@
 	** Returns: A pointer to the added source structure, or NULL if an error occurred.
 	*/
 	ResourceSource *addPatchDir(const char *path);
+
 	ResourceSource *getVolume(ResourceSource *map, int volume_nr);
+
 	//! Add a volume to the resource manager's list of sources.
 	/** @param map		The map associated with this volume
 	 *	@param filename	The name of the volume to add
@@ -190,17 +211,20 @@
 	 */
 	ResourceSource *addVolume(ResourceSource *map, const char *filename,
 		int number, int extended_addressing);
+
 	//! Add an external (i.e. separate file) map resource to the resource manager's list of sources.
 	/**	@param file_name	 The name of the volume to add
 	 *	@return		A pointer to the added source structure, or NULL if an error occurred.
 	 */
 	ResourceSource *addExternalMap(const char *file_name);
+
 	//! Scans newly registered resource sources for resources, earliest addition first.
 	/** @param detected_version: Pointer to the detected version number,
 	 *					 used during startup. May be NULL.
 	 * @return One of SCI_ERROR_*.
 	 */
 	int scanNewSources(int *detected_version, ResourceSource *source);
+
 	//! Looks up a resource's data
 	/**	@param type: The resource type to look for
 	 *	@param number: The resource number to search
@@ -209,16 +233,18 @@
 	 *	@note Locked resources are guaranteed not to have their contents freed until
 	 *		they are unlocked explicitly (by unlockResource).
 	 */
-	Resource *findResource(int type, int number, int lock);
+	Resource *findResource(ResourceType type, int number, int lock);
+
 	/* Unlocks a previously locked resource
 	**             (Resource *) res: The resource to free
-	**             (int) type: Type of the resource to check (for error checking)
 	**             (int) number: Number of the resource to check (ditto)
+	**             (ResourceType) type: Type of the resource to check (for error checking)
 	** Returns   : (void)
 	*/
-	void unlockResource(Resource *res, int restype, int resnum);
+	void unlockResource(Resource *res, int restype, ResourceType resnum);
+
 	/* Tests whether a resource exists
-	**             (int) type: Type of the resource to check
+	**             (ResourceType) type: Type of the resource to check
 	**             (int) number: Number of the resource to check
 	** Returns   : (Resource *) non-NULL if the resource exists, NULL otherwise
 	** This function may often be much faster than finding the resource
@@ -227,7 +253,7 @@
 	** it should be used with care, as it may be unallocated.
 	** Use scir_find_resource() if you want to use the data contained in the resource.
 	*/
-	Resource *testResource(int type, int number);
+	Resource *testResource(ResourceType type, int number);
 
 protected:
 	int _maxMemory; /* Config option: Maximum total byte number allocated */
@@ -239,24 +265,25 @@
 	Resource *lru_first, *lru_last;	// Pointers to the first and last LRU queue entries
 										// LRU queue: lru_first points to the most recent entry
 
-
 	/* Frees a block of resources and associated data
 	** Parameters: (Resource *) resources: The resources to free
 	**             (int) _resourcesNr: Number of resources in the block
 	** Returns   : (void)
 	*/
 	void freeResources(Resource *resources, int _resourcesNr);
+
 	/* Finds a resource matching type.number in an unsorted Resource block
 	** To be used during initial resource loading, when the resource list
 	** may not have been sorted yet.
 	** Parameters: (Resource *) res: Pointer to the block to search in
 	**             (int) res_nr: Number of Resource structs allocated and defined
 	**                           in the block pointed to by res
-	**             (int) type: Type of the resource to look for
+	**             (ResourceType) type: Type of the resource to look for
 	**             (int) number: Number of the resource to look for
 	** Returns   : (Resource) The matching resource entry, or NULL if not found
 	*/
-	Resource *findResourceUnsorted(Resource *res, int res_nr, int type, int number);
+	Resource *findResourceUnsorted(Resource *res, int res_nr, ResourceType type, int number);
+
 	/* Adds an alternative source to a resource
 	** Parameters: (Resource *) res: The resource to add to
 	**             (ResourceSource *) source: The source of the resource
@@ -264,8 +291,9 @@
 	**                            is stored at
 	** Returns   : (void)
 	*/
+	void addAltSource(Resource *res, ResourceSource *source, unsigned int file_offset);
+
 	int addAppropriateSources();
-	void addAltSource(Resource *res, ResourceSource *source, unsigned int file_offset);
 	void freeResourceSources(ResourceSource *rss);
 	void freeAltSources(resource_altsource_t *dynressrc);
 
@@ -282,17 +310,19 @@
 	** Returns   : (int) 0 on success, an SCI_ERROR_* code otherwise
 	*/
 	int readResourceMapSCI0(ResourceSource *map, int *sci_version);
+
 	/* Reads the SCI1 resource.map file from a local directory
 	** Parameters: (char *) path: (unused)
 	**             (int) sci_version: SCI resource version
 	** Returns   : (int) 0 on success, an SCI_ERROR_* code otherwise
 	*/
 	int readResourceMapSCI1(ResourceSource *map, ResourceSource *vol, int *sci_version);
+
 	int isSCI10or11(int *types);
 	int detectOddSCI01(Common::File &file);
 	int resReadEntry(ResourceSource *map, byte *buf, Resource *res, int sci_version);
-	int resTypeSCI1(int ofs, int *types, int lastrt);
-	int parseHeaderSCI1(Common::ReadStream &stream, int *types, int *lastrt);
+	ResourceType resTypeSCI1(int ofs, int *types, ResourceType lastrt);
+	int parseHeaderSCI1(Common::ReadStream &stream, int *types, ResourceType *lastrt);
 
 	/**--- Patch management functions ---*/
 
@@ -319,9 +349,10 @@
 	** Returns   : (int) 0 on success, an SCI_ERROR_* code otherwise
 	*/
 	int readResourcePatchesSCI1(ResourceSource *source);
-	void process_patch(ResourceSource *source, Common::ArchiveMember &member, int restype,
-		int resnumber);
 
+	void process_patch(ResourceSource *source, Common::ArchiveMember &member,
+		ResourceType restype, int resnumber);
+
 	void printLRU();
 	void addToLRU(Resource *res);
 	void removeFromLRU(Resource *res);
@@ -372,7 +403,6 @@
 	**               encountered.
 	*/
 
-
 	int decompress11(Resource *result, Common::ReadStream &stream, int sci_version);
 	/* Decrypts resource data and stores the result for SCI1.1-style compression.
 	** Parameters : result: The Resource the decompressed data is stored in.
@@ -382,7 +412,6 @@
 	**               encountered.
 	*/
 
-
 	int decrypt2(uint8* dest, uint8* src, int length, int complength);
 	/* Huffman token decryptor - defined in decompress0.c and used in decompress01.c
 	*/

Modified: scummvm/trunk/engines/sci/scicore/resource_map.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource_map.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/resource_map.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -121,7 +121,7 @@
 
 int ResourceManager::resReadEntry(ResourceSource *map, byte *buf, Resource *res, int sci_version) {
 	res->id = buf[0] | (buf[1] << 8);
-	res->type = SCI0_RESID_GET_TYPE(buf);
+	res->type = (ResourceType)SCI0_RESID_GET_TYPE(buf);
 	res->number = SCI0_RESID_GET_NUMBER(buf);
 	res->status = SCI_STATUS_NOMALLOC;
 
@@ -156,20 +156,20 @@
 	return 0;
 }
 
-int ResourceManager::resTypeSCI1(int ofs, int *types, int lastrt) {
-	int i, last = -1;
+ResourceType ResourceManager::resTypeSCI1(int ofs, int *types, ResourceType lastrt) {
+	ResourceType last = kResourceTypeInvalid;
 
-	for (i = 0; i <= sci1_last_resource;i++)
+	for (int i = 0; i <= sci1_last_resource; i++)
 		if (types[i]) {
 			if (types[i] > ofs)
 				return last;
-			last = i;
+			last = (ResourceType)i;
 		}
 
 	return lastrt;
 }
 
-int ResourceManager::parseHeaderSCI1(Common::ReadStream &stream, int *types, int *lastrt) {
+int ResourceManager::parseHeaderSCI1(Common::ReadStream &stream, int *types, ResourceType *lastrt) {
 	unsigned char rtype;
 	unsigned char offset[2];
 	int read_ok;
@@ -184,7 +184,7 @@
 			read_ok = 0;
 		if (rtype != 0xff) {
 			types[rtype&0x7f] = (offset[1] << 8) | (offset[0]);
-			*lastrt = rtype & 0x7f;
+			*lastrt = (ResourceType)(rtype & 0x7f);
 		}
 		size += 3;
 	} while (read_ok && (rtype != 0xFF));
@@ -344,7 +344,7 @@
 	int this_restype = 0;
 	int next_restype = 1;
 
-	while (next_restype <= sci_heap) {
+	while (next_restype <= kResourceTypeHeap) {
 		int could_be_10 = 0;
 		int could_be_11 = 0;
 
@@ -381,7 +381,7 @@
 	int *types = (int *)sci_malloc(sizeof(int) * (sci1_last_resource + 1));
 	int i;
 	byte buf[SCI1_RESMAP_ENTRIES_SIZE];
-	int lastrt;
+	ResourceType lastrt;
 	int entrysize;
 	int entry_size_selector;
 

Modified: scummvm/trunk/engines/sci/scicore/resource_patch.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource_patch.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/resource_patch.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -32,19 +32,19 @@
 namespace Sci {
 
 void sci0_sprintf_patch_file_name(char *string, Resource *res) {
-	sprintf(string, "%s.%03i", sci_resource_types[res->type], res->number);
+	sprintf(string, "%s.%03i", getResourceTypeName(res->type), res->number);
 }
 
 void sci1_sprintf_patch_file_name(char *string, Resource *res) {
-	sprintf(string, "%d.%s", res->number, sci_resource_type_suffixes[res->type]);
+	sprintf(string, "%d.%s", res->number, getResourceTypeSuffix(res->type));
 }
 
 // version-agnostic patch application
 void ResourceManager::process_patch(ResourceSource *source,
-	Common::ArchiveMember &member, int restype, int resnumber) {
+	Common::ArchiveMember &member, ResourceType restype, int resnumber) {
 	Common::File file;
 
-	if (restype == sci_invalid_resource)
+	if (restype == kResourceTypeInvalid)
 		return;
 
 	printf("Patching \"%s\": ", member.getName().c_str());
@@ -103,28 +103,26 @@
 
 	for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
 		const Common::String name = (*x)->getName();
-		int restype = sci_invalid_resource;
+		ResourceType restype = kResourceTypeInvalid;
 		int resnumber = -1;
-		int i;
 		unsigned int resname_len;
 		char *endptr;
 
-		for (i = sci_view; i < sci_invalid_resource; i++)
-			if (scumm_strnicmp(sci_resource_types[i], name.c_str(), strlen(sci_resource_types[i])) == 0)
-				restype = i;
+		for (int i = kResourceTypeView; i < kResourceTypeInvalid; i++)
+			if (scumm_strnicmp(getResourceTypeName((ResourceType)i), name.c_str(), strlen(getResourceTypeName((ResourceType)i))) == 0)
+				restype = (ResourceType)i;
 
-		if (restype != sci_invalid_resource) {
-
-			resname_len = strlen(sci_resource_types[restype]);
+		if (restype != kResourceTypeInvalid) {
+			resname_len = strlen(getResourceTypeName(restype));
 			if (name[resname_len] != '.')
-				restype = sci_invalid_resource;
+				restype = kResourceTypeInvalid;
 			else {
 				resnumber = strtol(name.c_str() + 1 + resname_len, &endptr, 10); // Get resource number
 				if ((*endptr != '\0') || (resname_len + 1 == name.size()))
-					restype = sci_invalid_resource;
+					restype = kResourceTypeInvalid;
 
 				if ((resnumber < 0) || (resnumber > 1000))
-					restype = sci_invalid_resource;
+					restype = kResourceTypeInvalid;
 			}
 		}
 
@@ -140,31 +138,30 @@
 
 	for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
 		const Common::String name = (*x)->getName();
-		int restype = sci_invalid_resource;
+		ResourceType restype = kResourceTypeInvalid;
 		int resnumber = -1;
-		int i;
 		char *endptr;
 		const char *dot = strchr(name.c_str(), '.');
 
-		for (i = sci_view; i < sci_invalid_resource; i++) {
+		for (int i = kResourceTypeView; i < kResourceTypeInvalid; i++) {
 			if (dot != NULL) {
-				if (scumm_strnicmp(sci_resource_type_suffixes[i], dot + 1, 3) == 0) {
-					restype = i;
+				if (scumm_strnicmp(getResourceTypeSuffix((ResourceType)i), dot + 1, 3) == 0) {
+					restype = (ResourceType)i;
 				}
 			}
 		}
 
-		if (restype != sci_invalid_resource) {
+		if (restype != kResourceTypeInvalid) {
 			resnumber = strtol(name.c_str(), &endptr, 10); // Get resource number
 
 			if (endptr != dot)
-				restype = sci_invalid_resource;
+				restype = kResourceTypeInvalid;
 
 			if (*(dot + 4) != '\0')
-				restype = sci_invalid_resource;
+				restype = kResourceTypeInvalid;
 
 			if ((resnumber < 0) || (resnumber > 8192))
-				restype = sci_invalid_resource;
+				restype = kResourceTypeInvalid;
 		}
 
 		process_patch(source, **x, restype, resnumber);

Modified: scummvm/trunk/engines/sci/scicore/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/script.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/script.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -329,7 +329,7 @@
 void script_dissect(ResourceManager *resmgr, int res_no, const Common::StringList &selectorNames) {
 	int objectctr[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 	unsigned int _seeker = 0;
-	Resource *script = resmgr->findResource(sci_script, res_no, 0);
+	Resource *script = resmgr->findResource(kResourceTypeScript, res_no, 0);
 	word_t **words;
 	int word_count;
 

Modified: scummvm/trunk/engines/sci/scicore/vocab.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/vocab.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -75,12 +75,12 @@
 	Resource *resource;
 
 	// First try to load the SCI0 vocab resource.
-	resource = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB, 0);
+	resource = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI0_MAIN_VOCAB, 0);
 	vocab_version = 0;
 
 	if (!resource) {
 		warning("SCI0: Could not find a main vocabulary, trying SCI01");
-		resource = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB, 0);
+		resource = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB, 0);
 		vocab_version = 1;
 	}
 
@@ -179,7 +179,7 @@
 suffix_t **vocab_get_suffices(ResourceManager *resmgr, int *suffices_nr) {
 	int counter = 0;
 	suffix_t **suffices;
-	Resource *resource = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_SUFFIX_VOCAB, 1);
+	Resource *resource = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SUFFIX_VOCAB, 1);
 	unsigned int seeker = 1;
 
 	if (!resource) {
@@ -226,8 +226,8 @@
 void vocab_free_suffices(ResourceManager *resmgr, suffix_t **suffices, int suffices_nr) {
 	int i;
 
-	resmgr->unlockResource(resmgr->findResource(sci_vocab, VOCAB_RESOURCE_SUFFIX_VOCAB, 0),
-	                     VOCAB_RESOURCE_SUFFIX_VOCAB, sci_vocab);
+	resmgr->unlockResource(resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_SUFFIX_VOCAB, 0),
+	                     VOCAB_RESOURCE_SUFFIX_VOCAB, kResourceTypeVocab);
 
 	for (i = 0; i < suffices_nr; i++)
 		free(suffices[i]);
@@ -241,7 +241,7 @@
 }
 
 parse_tree_branch_t *vocab_get_branches(ResourceManager * resmgr, int *branches_nr) {
-	Resource *resource = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_PARSE_TREE_BRANCHES, 0);
+	Resource *resource = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_PARSE_TREE_BRANCHES, 0);
 	parse_tree_branch_t *retval;
 	int i;
 

Modified: scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -159,7 +159,7 @@
 	int *c;
 	unsigned int i;
 
-	if ((r = resmgr->findResource(sci_vocab, 996, 0)) == NULL)
+	if ((r = resmgr->findResource(kResourceTypeVocab, 996, 0)) == NULL)
 		return 0;
 
 	c = (int *)sci_malloc(sizeof(int) * r->size / 2);
@@ -174,7 +174,7 @@
 int vocabulary_get_class_count(ResourceManager *resmgr) {
 	Resource* r;
 
-	if ((r = resmgr->findResource(sci_vocab, 996, 0)) == 0)
+	if ((r = resmgr->findResource(kResourceTypeVocab, 996, 0)) == 0)
 		return 0;
 
 	return r->size / 4;
@@ -183,7 +183,7 @@
 bool vocabulary_get_snames(ResourceManager *resmgr, sci_version_t version, Common::StringList &selectorNames) {
 	int count;
 
-	Resource *r = resmgr->findResource(sci_vocab, 997, 0);
+	Resource *r = resmgr->findResource(kResourceTypeVocab, 997, 0);
 
 	if (!r) // No such resource?
 		return false;
@@ -218,7 +218,7 @@
 opcode* vocabulary_get_opcodes(ResourceManager *resmgr) {
 	opcode* o;
 	int count, i = 0;
-	Resource* r = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_OPCODES, 0);
+	Resource* r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_OPCODES, 0);
 
 	// if the resource couldn't be loaded, leave
 	if (r == NULL) {
@@ -295,7 +295,7 @@
 static char **vocabulary_get_knames0(ResourceManager *resmgr, int* names) {
 	char** t;
 	int count, i, index = 2, empty_to_add = 1;
-	Resource *r = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_KNAMES, 0);
+	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
 
 	if (!r) { // No kernel name table found? Fall back to default table
 		t = (char **)sci_malloc((SCI0_KNAMES_DEFAULT_ENTRIES_NR + 1) * sizeof(char*));
@@ -345,7 +345,7 @@
 static char **vocabulary_get_knames1(ResourceManager *resmgr, int *count) {
 	char **t = NULL;
 	unsigned int size = 64, used = 0, pos = 0;
-	Resource *r = resmgr->findResource(sci_vocab, VOCAB_RESOURCE_KNAMES, 0);
+	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
 
 	while (pos < r->size) {
 		int len;

Modified: scummvm/trunk/engines/sci/sfx/player/polled.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/player/polled.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/sfx/player/polled.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -176,11 +176,11 @@
 	}
 
 	if (seq->patch_nr != SFX_SEQ_PATCHFILE_NONE) {
-		res = resmgr->findResource(sci_patch, seq->patch_nr, 0);
+		res = resmgr->findResource(kResourceTypePatch, seq->patch_nr, 0);
 	}
 
 	if (seq->patch2_nr != SFX_SEQ_PATCHFILE_NONE) {
-		res2 = resmgr->findResource(sci_patch, seq->patch2_nr, 0);
+		res2 = resmgr->findResource(kResourceTypePatch, seq->patch2_nr, 0);
 	}
 
 	if (seq->init(seq,

Modified: scummvm/trunk/engines/sci/sfx/player/realtime.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/player/realtime.cpp	2009-02-28 23:23:10 UTC (rev 38987)
+++ scummvm/trunk/engines/sci/sfx/player/realtime.cpp	2009-02-28 23:46:50 UTC (rev 38988)
@@ -132,7 +132,7 @@
 	Resource *res = NULL;
 
 	if (patchfile != SFX_SEQ_PATCHFILE_NONE) {
-		res = resmgr->findResource(sci_patch, patchfile, 0);
+		res = resmgr->findResource(kResourceTypePatch, patchfile, 0);
 		if (!res) {
 			fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n",
 			        patchfile, seq_name);


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