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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Mar 7 17:14:20 CET 2009


Revision: 39189
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39189&view=rev
Author:   thebluegr
Date:     2009-03-07 16:14:20 +0000 (Sat, 07 Mar 2009)

Log Message:
-----------
Replaced getInt16, getUInt16 and putInt16

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kpathing.cpp
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/message.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/script.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/engine/vm.h
    scummvm/trunk/engines/sci/gfx/resource/sci_pal_1.cpp
    scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp
    scummvm/trunk/engines/sci/scicore/vocab.cpp
    scummvm/trunk/engines/sci/sfx/iterator.cpp
    scummvm/trunk/engines/sci/tools.cpp
    scummvm/trunk/engines/sci/tools.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -286,7 +286,7 @@
 
 	offset = 2 + (classId << 2);
 
-	return getInt16(res->data + offset);
+	return (int16)READ_LE_UINT16(res->data + offset);
 }
 
 int test_cursor_style(EngineState *s) {
@@ -319,14 +319,14 @@
 		Resource *heap = s->resmgr->findResource(kResourceTypeHeap, scriptnr, 0);
 
 		if (heap) {
-			int global_vars = getUInt16(heap->data + 2);
+			int global_vars = READ_LE_UINT16(heap->data + 2);
 
 			seeker_ptr = (char*)heap->data + 4 + global_vars * 2;
 			seeker_offset = 4 + global_vars * 2;
 
-			while (getUInt16((byte*)seeker_ptr) == SCRIPT_OBJECT_MAGIC_NUMBER) {
-				if (getUInt16((byte*)seeker_ptr + 14) & SCRIPT_INFO_CLASS) {
-					classnr = getUInt16((byte*)seeker_ptr + 10);
+			while (READ_LE_UINT16((byte*)seeker_ptr) == SCRIPT_OBJECT_MAGIC_NUMBER) {
+				if (READ_LE_UINT16((byte*)seeker_ptr + 14) & SCRIPT_INFO_CLASS) {
+					classnr = READ_LE_UINT16((byte*)seeker_ptr + 10);
 					if (classnr >= s->classtable_size) {
 						if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) {
 							fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n",
@@ -346,8 +346,8 @@
 					s->classtable[classnr].script = scriptnr;
 				}
 
-				seeker_ptr += getUInt16((byte*)seeker_ptr + 2) * 2;
-				seeker_offset += getUInt16((byte*)seeker_ptr + 2) * 2;
+				seeker_ptr += READ_LE_UINT16((byte*)seeker_ptr + 2) * 2;
+				seeker_offset += READ_LE_UINT16((byte*)seeker_ptr + 2) * 2;
 			}
 		}
 	}
@@ -383,10 +383,10 @@
 			do {
 				while (seeker < script->size)	{
 					unsigned int lastseeker = seeker;
-					objtype = getInt16(script->data + seeker);
+					objtype = (int16)READ_LE_UINT16(script->data + seeker);
 					if (objtype == sci_obj_class || objtype == sci_obj_terminator)
 						break;
-					seeker += getInt16(script->data + seeker + 2);
+					seeker += (int16)READ_LE_UINT16(script->data + seeker + 2);
 					if (seeker <= lastseeker) {
 						sciprintf("Warning: Script version is invalid.\n");
 						free(s->classtable);
@@ -399,7 +399,7 @@
 
 					seeker -= SCRIPT_OBJECT_MAGIC_OFFSET; // Adjust position; script home is base +8 bytes
 
-					classnr = getInt16(script->data + seeker + 4 + SCRIPT_SPECIES_OFFSET);
+					classnr = (int16)READ_LE_UINT16(script->data + seeker + 4 + SCRIPT_SPECIES_OFFSET);
 					if (classnr >= s->classtable_size) {
 
 						if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) {
@@ -427,7 +427,7 @@
 					}
 
 					seeker += SCRIPT_OBJECT_MAGIC_OFFSET; // Re-adjust position
-					seeker += getInt16(script->data + seeker + 2); // Move to next
+					seeker += (int16)READ_LE_UINT16(script->data + seeker + 2); // Move to next
 				}
 
 			} while (objtype != sci_obj_terminator && seeker <= script->size);

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -598,7 +598,7 @@
 		if (s->seg_manager->heap[argv[1].segment]->type == MEM_OBJ_LOCALS)
 			return *((reg_t *) ref);
 		else
-			return make_reg(0, getInt16(ref));
+			return make_reg(0, (int16)READ_LE_UINT16(ref));
 		break;
 	}
 	case K_MEMORY_POKE : {
@@ -615,7 +615,7 @@
 			if (argv[2].segment) {
 				SCIkdebug(SCIkERROR, "Attempt to poke memory reference "PREG" to "PREG"!\n", PRINT_REG(argv[2]), PRINT_REG(argv[1]));
 				return s->r_acc;
-				putInt16(ref, argv[2].offset); // ???
+				WRITE_LE_UINT16(ref, argv[2].offset); // ???
 			}
 		}
 		return s->r_acc;

Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -40,13 +40,13 @@
 #define POLY_POINT_SIZE 4
 
 static void POLY_GET_POINT(byte *p, int i, Common::Point &pt) {
-	pt.x = getInt16((p) + (i) * POLY_POINT_SIZE);
-	pt.y = getInt16((p) + (i) * POLY_POINT_SIZE + 2);
+	pt.x = (int16)READ_LE_UINT16((p) + (i) * POLY_POINT_SIZE);
+	pt.y = (int16)READ_LE_UINT16((p) + (i) * POLY_POINT_SIZE + 2);
 }
 
 static void POLY_SET_POINT(byte *p, int i, const Common::Point &pt) {
-	putInt16((p) + (i) * POLY_POINT_SIZE, pt.x);
-	putInt16((p) + (i) * POLY_POINT_SIZE + 2, pt.y);
+	WRITE_LE_UINT16((p) + (i) * POLY_POINT_SIZE, pt.x);
+	WRITE_LE_UINT16((p) + (i) * POLY_POINT_SIZE + 2, pt.y);
 }
 
 static void POLY_GET_POINT_REG_T(reg_t *p, int i, Common::Point &pt) {

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -229,8 +229,8 @@
 					 * Lars */
 				} else
 					for (i = 0; i < synonyms_nr; i++) {
-						s->synonyms[synpos].replaceant = getInt16(synonyms + i * 4);
-						s->synonyms[synpos].replacement = getInt16(synonyms + i * 4 + 2);
+						s->synonyms[synpos].replaceant = (int16)READ_LE_UINT16(synonyms + i * 4);
+						s->synonyms[synpos].replacement = (int16)READ_LE_UINT16(synonyms + i * 4 + 2);
 
 						synpos++;
 					}

Modified: scummvm/trunk/engines/sci/engine/message.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/message.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/message.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -52,7 +52,7 @@
 #if 0
 // Unreferenced - removed
 static void index_record_get_text_2101(IndexRecordCursor *cursor, char *buffer, int buffer_size) {
-	int offset = getUInt16(cursor->index_record + 2);
+	int offset = READ_LE_UINT16(cursor->index_record + 2);
 	char *stringptr = (char *)cursor->resource_beginning + offset;
 
 	strncpy(buffer, stringptr, buffer_size);
@@ -62,7 +62,7 @@
 #if 0
 // Unreferenced - removed
 static int header_get_index_record_count_2101(byte *header) {
-	return getUInt16(header + 4);
+	return READ_LE_UINT16(header + 4);
 }
 #endif
 
@@ -85,14 +85,14 @@
 }
 
 static void index_record_get_text_3411(IndexRecordCursor *cursor, char *buffer, int buffer_size) {
-	int offset = getUInt16(cursor->index_record + 5);
+	int offset = READ_LE_UINT16(cursor->index_record + 5);
 	char *stringptr = (char *)cursor->resource_beginning + offset;
 
 	strncpy(buffer, stringptr, buffer_size);
 }
 
 static int header_get_index_record_count_3411(byte *header) {
-	return getUInt16(header + 8);
+	return READ_LE_UINT16(header + 8);
 }
 
 // Generic code from here on
@@ -192,7 +192,7 @@
 	//if (tester == NULL)
 	//	return;
 
-	//version = getUInt16(tester->data);
+	//version = READ_LE_UINT16(tester->data);
 
 	state->initialized = 1;
 	state->_module = -1;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -4904,13 +4904,13 @@
 
 	buf += magic_pos_adder;
 	do {
-		int seeker_type = getUInt16(buf);
+		int seeker_type = READ_LE_UINT16(buf);
 		int seeker_size;
 
 		if (seeker_type == 0) break;
 		if (seeker_type == type) return buf;
 
-		seeker_size = getUInt16(buf + 2);
+		seeker_size = READ_LE_UINT16(buf + 2);
 		buf += seeker_size;
 	} while(1);
 
@@ -5010,13 +5010,13 @@
 					byte *data = scr->buf + scr->objects[j].pos.offset;
 
 					if (self->isSci1_1) {
-						uint16 *funct_area = (uint16 *) (scr->buf + getUInt16( data + 6 ));
-						uint16 *prop_area = (uint16 *) (scr->buf + getUInt16( data + 4 ));
+						uint16 *funct_area = (uint16 *) (scr->buf + READ_LE_UINT16( data + 6 ));
+						uint16 *prop_area = (uint16 *) (scr->buf + READ_LE_UINT16( data + 4 ));
 
 						scr->objects[j].base_method = funct_area;
 						scr->objects[j].base_vars = prop_area;
 					} else {
-						int funct_area = getUInt16( data + SCRIPT_FUNCTAREAPTR_OFFSET );
+						int funct_area = READ_LE_UINT16( data + SCRIPT_FUNCTAREAPTR_OFFSET );
 						Object *base_obj;
 
 						base_obj = obj_get(s, scr->objects[j].variables[SCRIPT_SPECIES_SELECTOR]);

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -238,9 +238,9 @@
 
 static void script_dump_object(char *data, int seeker, int objsize, const Common::StringList &selectorNames) {
 	int selectors, overloads, selectorsize;
-	int species = getInt16((unsigned char *) data + 8 + seeker);
-	int superclass = getInt16((unsigned char *) data + 10 + seeker);
-	int namepos = getInt16((unsigned char *) data + 14 + seeker);
+	int species = (int16)READ_LE_UINT16((unsigned char *) data + 8 + seeker);
+	int superclass = (int16)READ_LE_UINT16((unsigned char *) data + 10 + seeker);
+	int namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + seeker);
 	int i = 0;
 
 	sciprintf("Object\n");
@@ -251,29 +251,29 @@
 	sciprintf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>");
 	sciprintf("Superclass: %x\n", superclass);
 	sciprintf("Species: %x\n", species);
-	sciprintf("-info-:%x\n", getInt16((unsigned char *) data + 12 + seeker) & 0xffff);
+	sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *) data + 12 + seeker) & 0xffff);
 
-	sciprintf("Function area offset: %x\n", getInt16((unsigned char *) data + seeker + 4));
-	sciprintf("Selectors [%x]:\n", selectors = (selectorsize = getInt16((unsigned char *) data + seeker + 6)));
+	sciprintf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *) data + seeker + 4));
+	sciprintf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *) data + seeker + 6)));
 
 	seeker += 8;
 
 	while (selectors--) {
-		sciprintf("  [#%03x] = 0x%x\n", i++, getInt16((unsigned char *)data + seeker) & 0xffff);
+		sciprintf("  [#%03x] = 0x%x\n", i++, (int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
 
 		seeker += 2;
 	}
 
-	sciprintf("Overridden functions: %x\n", selectors = overloads = getInt16((unsigned char *)data + seeker));
+	sciprintf("Overridden functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
 
 	seeker += 2;
 
 	if (overloads < 100)
 		while (overloads--) {
-			int selector = getInt16((unsigned char *) data + (seeker));
+			int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker));
 
 			sciprintf("  [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)selectorNames.size()) ? selectorNames[selector].c_str() : "<?>");
-			sciprintf("%04x\n", getInt16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff);
+			sciprintf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff);
 
 			seeker += 2;
 		}
@@ -281,9 +281,9 @@
 
 static void script_dump_class(char *data, int seeker, int objsize, const Common::StringList &selectorNames) {
 	int selectors, overloads, selectorsize;
-	int species = getInt16((unsigned char *) data + 8 + seeker);
-	int superclass = getInt16((unsigned char *) data + 10 + seeker);
-	int namepos = getInt16((unsigned char *) data + 14 + seeker);
+	int species = (int16)READ_LE_UINT16((unsigned char *) data + 8 + seeker);
+	int superclass = (int16)READ_LE_UINT16((unsigned char *) data + 10 + seeker);
+	int namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + seeker);
 
 	sciprintf("Class\n");
 
@@ -292,35 +292,35 @@
 	sciprintf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>");
 	sciprintf("Superclass: %x\n", superclass);
 	sciprintf("Species: %x\n", species);
-	sciprintf("-info-:%x\n", getInt16((unsigned char *)data + 12 + seeker) & 0xffff);
+	sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *)data + 12 + seeker) & 0xffff);
 
-	sciprintf("Function area offset: %x\n", getInt16((unsigned char *)data + seeker + 4));
-	sciprintf("Selectors [%x]:\n", selectors = (selectorsize = getInt16((unsigned char *)data + seeker + 6)));
+	sciprintf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + 4));
+	sciprintf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *)data + seeker + 6)));
 
 	seeker += 8;
 	selectorsize <<= 1;
 
 	while (selectors--) {
-		int selector = getInt16((unsigned char *) data + (seeker) + selectorsize);
+		int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker) + selectorsize);
 
 		sciprintf("  [%03x] %s = 0x%x\n", 0xffff & selector, (selector >= 0 && selector < (int)selectorNames.size()) ? selectorNames[selector].c_str() : "<?>",
-		          getInt16((unsigned char *)data + seeker) & 0xffff);
+		          (int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
 
 		seeker += 2;
 	}
 
 	seeker += selectorsize;
 
-	sciprintf("Overloaded functions: %x\n", selectors = overloads = getInt16((unsigned char *)data + seeker));
+	sciprintf("Overloaded functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
 
 	seeker += 2;
 
 	while (overloads--) {
-		int selector = getInt16((unsigned char *)data + (seeker));
+		int selector = (int16)READ_LE_UINT16((unsigned char *)data + (seeker));
 		fprintf(stderr, "selector=%d; selectorNames.size() =%d\n", selector, selectorNames.size());
 		sciprintf("  [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)selectorNames.size()) ?
 		          selectorNames[selector].c_str() : "<?>");
-		sciprintf("%04x\n", getInt16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff);
+		sciprintf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff);
 
 		seeker += 2;
 	}
@@ -341,7 +341,7 @@
 	words = vocab_get_words(resmgr, &word_count);
 
 	while (_seeker < script->size) {
-		int objtype = getInt16(script->data + _seeker);
+		int objtype = (int16)READ_LE_UINT16(script->data + _seeker);
 		int objsize;
 		unsigned int seeker = _seeker + 4;
 
@@ -355,7 +355,7 @@
 
 		sciprintf("\n");
 
-		objsize = getInt16(script->data + _seeker + 2);
+		objsize = (int16)READ_LE_UINT16(script->data + _seeker + 2);
 
 		sciprintf("Obj type #%x, size 0x%x: ", objtype, objsize);
 

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -226,7 +226,7 @@
 
 			offset += 2;
 
-			track_offset = getUInt16(data + offset);
+			track_offset = READ_LE_UINT16(data + offset);
 			header1 = data[track_offset];
 			header2 = data[track_offset+1];
 			track_offset += 2;
@@ -234,7 +234,7 @@
 			if (track_offset < smallest_start)
 				smallest_start = track_offset;
 
-			end = getUInt16(data + offset + 2);
+			end = READ_LE_UINT16(data + offset + 2);
 			sciprintf("  - %04x -- %04x", track_offset, track_offset + end);
 
 			if (track_offset == 0xfe)
@@ -1214,7 +1214,7 @@
 		return -1;
 	}
 
-	return getUInt16(selectoroffset + prop_ofs);
+	return READ_LE_UINT16(selectoroffset + prop_ofs);
 }
 
 reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecode) {
@@ -1951,7 +1951,7 @@
 		return 1;
 	}
 
-	if ((getInt16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) {
+	if (((int16)READ_LE_UINT16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) {
 		sciprintf("Not an object.\n");
 		return 0;
 	}
@@ -2908,7 +2908,7 @@
 			int opcode = pc->offset >= code_buf_size ? 0 : code_buf[pc->offset];
 			int op = opcode >> 1;
 			int paramb1 = pc->offset + 1 >= code_buf_size ? 0 : code_buf[pc->offset + 1];
-			int paramf1 = (opcode & 1) ? paramb1 : (pc->offset + 2 >= code_buf_size ? 0 : getInt16(code_buf + pc->offset + 1));
+			int paramf1 = (opcode & 1) ? paramb1 : (pc->offset + 2 >= code_buf_size ? 0 : (int16)READ_LE_UINT16(code_buf + pc->offset + 1));
 
 			switch (_debug_seeking) {
 			case _DEBUG_SEEK_SPECIAL_CALLK:

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -163,8 +163,8 @@
 		return;
 	}
 	if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) {
-		mem->data.script.buf_size = script->size + getUInt16(script->data) * 2;
-		//locals_size = getUInt16(script->data) * 2;
+		mem->data.script.buf_size = script->size + READ_LE_UINT16(script->data) * 2;
+		//locals_size = READ_LE_UINT16(script->data) * 2;
 	} else if (s->version < SCI_VERSION(1, 001, 000)) {
 		mem->data.script.buf_size = script->size;
 	} else {
@@ -629,7 +629,7 @@
 	GET_SEGID();
 	if (offset) {
 		scr->export_table = (uint16 *)(scr->buf + offset + 2);
-		scr->exports_nr = getUInt16((byte *)(scr->export_table - 1));
+		scr->exports_nr = READ_LE_UINT16((byte *)(scr->export_table - 1));
 	} else {
 		scr->export_table = NULL;
 		scr->exports_nr = 0;
@@ -767,7 +767,7 @@
 
 	index = scr->code_blocks_nr - 1;
 	scr->code[index].pos = location;
-	scr->code[index].size = getUInt16(scr->buf + location.offset - 2);
+	scr->code[index].size = READ_LE_UINT16(scr->buf + location.offset - 2);
 }
 
 void SegManager::scriptRelocate(reg_t block) {
@@ -780,13 +780,13 @@
 
 	scr = &(mobj->data.script);
 
-	VERIFY(block.offset < (uint16)scr->buf_size && getUInt16(scr->buf + block.offset) * 2 + block.offset < (uint16)scr->buf_size,
+	VERIFY(block.offset < (uint16)scr->buf_size && READ_LE_UINT16(scr->buf + block.offset) * 2 + block.offset < (uint16)scr->buf_size,
 	       "Relocation block outside of script\n");
 
-	count = getUInt16(scr->buf + block.offset);
+	count = READ_LE_UINT16(scr->buf + block.offset);
 
 	for (i = 0; i <= count; i++) {
-		int pos = getUInt16(scr->buf + block.offset + 2 + (i * 2));
+		int pos = READ_LE_UINT16(scr->buf + block.offset + 2 + (i * 2));
 		if (!pos)
 			continue; // FIXME: A hack pending investigation
 
@@ -832,16 +832,16 @@
 
 	scr = &(mobj->data.script);
 
-	VERIFY(block.offset < (uint16)scr->heap_size && getUInt16(scr->heap_start + block.offset) * 2 + block.offset < (uint16)scr->buf_size,
+	VERIFY(block.offset < (uint16)scr->heap_size && READ_LE_UINT16(scr->heap_start + block.offset) * 2 + block.offset < (uint16)scr->buf_size,
 	       "Relocation block outside of script\n");
 
 	if (scr->relocated)
 		return;
 	scr->relocated = 1;
-	count = getUInt16(scr->heap_start + block.offset);
+	count = READ_LE_UINT16(scr->heap_start + block.offset);
 
 	for (i = 0; i < count; i++) {
-		int pos = getUInt16(scr->heap_start + block.offset + 2 + (i * 2)) + scr->script_size;
+		int pos = READ_LE_UINT16(scr->heap_start + block.offset + 2 + (i * 2)) + scr->script_size;
 
 		if (!relocateLocal(scr, block.segment, pos)) {
 			int k, done = 0;
@@ -904,7 +904,7 @@
 
 	{
 		byte *data = (byte *)(scr->buf + base);
-		int funct_area = getUInt16(data + SCRIPT_FUNCTAREAPTR_OFFSET);
+		int funct_area = READ_LE_UINT16(data + SCRIPT_FUNCTAREAPTR_OFFSET);
 		int variables_nr;
 		int functions_nr;
 		int is_class;
@@ -915,9 +915,9 @@
 
 		VERIFY(base + funct_area < scr->buf_size, "Function area pointer references beyond end of script");
 
-		variables_nr = getUInt16(data + SCRIPT_SELECTORCTR_OFFSET);
-		functions_nr = getUInt16(data + funct_area - 2);
-		is_class = getUInt16(data + SCRIPT_INFO_OFFSET) & SCRIPT_INFO_CLASS;
+		variables_nr = READ_LE_UINT16(data + SCRIPT_SELECTORCTR_OFFSET);
+		functions_nr = READ_LE_UINT16(data + funct_area - 2);
+		is_class = READ_LE_UINT16(data + SCRIPT_INFO_OFFSET) & SCRIPT_INFO_CLASS;
 
 		VERIFY(base + funct_area + functions_nr * 2
 		       // add again for classes, since those also store selectors
@@ -933,7 +933,7 @@
 		obj->base_vars = NULL;
 
 		for (i = 0; i < variables_nr; i++)
-			obj->variables[i] = make_reg(0, getUInt16(data + (i * 2)));
+			obj->variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2)));
 	}
 
 	return obj;
@@ -970,8 +970,8 @@
 
 	{
 		byte *data = (byte *)(scr->buf + base);
-		uint16 *funct_area = (uint16 *)(scr->buf + getUInt16(data + 6));
-		uint16 *prop_area = (uint16 *)(scr->buf + getUInt16(data + 4));
+		uint16 *funct_area = (uint16 *)(scr->buf + READ_LE_UINT16(data + 6));
+		uint16 *prop_area = (uint16 *)(scr->buf + READ_LE_UINT16(data + 4));
 		int variables_nr;
 		int functions_nr;
 		int is_class;
@@ -982,9 +982,9 @@
 
 		VERIFY((byte *) funct_area < scr->buf + scr->buf_size, "Function area pointer references beyond end of script");
 
-		variables_nr = getUInt16(data + 2);
+		variables_nr = READ_LE_UINT16(data + 2);
 		functions_nr = *funct_area;
-		is_class = getUInt16(data + 14) & SCRIPT_INFO_CLASS;
+		is_class = READ_LE_UINT16(data + 14) & SCRIPT_INFO_CLASS;
 
 		obj->base_method = funct_area;
 		obj->base_vars = prop_area;
@@ -1000,7 +1000,7 @@
 		obj->base_obj = data;
 
 		for (i = 0; i < variables_nr; i++)
-			obj->variables[i] = make_reg(0, getUInt16(data + (i * 2)));
+			obj->variables[i] = make_reg(0, READ_LE_UINT16(data + (i * 2)));
 	}
 
 	return obj;
@@ -1065,9 +1065,9 @@
 	VERIFY(location.offset + 1 < (uint16)scr->buf_size, "Locals beyond end of script\n");
 
 	if (isSci1_1)
-		count = getUInt16(scr->buf + location.offset - 2);
+		count = READ_LE_UINT16(scr->buf + location.offset - 2);
 	else
-		count = (getUInt16(scr->buf + location.offset - 2) - 4) >> 1;
+		count = (READ_LE_UINT16(scr->buf + location.offset - 2) - 4) >> 1;
 	// half block size
 
 	scr->locals_offset = location.offset;
@@ -1083,7 +1083,7 @@
 		byte *base = (byte *)(scr->buf + location.offset);
 
 		for (i = 0; i < count; i++)
-			locals->locals[i].offset = getUInt16(base + i * 2);
+			locals->locals[i].offset = READ_LE_UINT16(base + i * 2);
 	}
 }
 
@@ -1100,9 +1100,9 @@
 		/* We are forced to use an ugly heuristic here to distinguish function
 		   exports from object/class exports. The former kind points into the
 		   script resource, the latter into the heap resource.  */
-		location = getUInt16((byte *)(scr->export_table + i));
-		if (getUInt16(scr->heap_start + location) == SCRIPT_OBJECT_MAGIC_NUMBER) {
-			putInt16((byte *)(scr->export_table + i), location + scr->heap_start - scr->buf);
+		location = READ_LE_UINT16((byte *)(scr->export_table + i));
+		if (READ_LE_UINT16(scr->heap_start + location) == SCRIPT_OBJECT_MAGIC_NUMBER) {
+			WRITE_LE_UINT16((byte *)(scr->export_table + i), location + scr->heap_start - scr->buf);
 		} else {
 			// Otherwise it's probably a function export,
 			// and we don't need to do anything.
@@ -1118,12 +1118,12 @@
 	VERIFY(!(seg >= heap_size || mobj->type != MEM_OBJ_SCRIPT), "Attempt to relocate exports in non-script\n");
 
 	scr = &(mobj->data.script);
-	seeker = scr->heap_start + 4 + getUInt16(scr->heap_start + 2) * 2;
+	seeker = scr->heap_start + 4 + READ_LE_UINT16(scr->heap_start + 2) * 2;
 
-	while (getUInt16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
-		if (getUInt16(seeker + 14) & SCRIPT_INFO_CLASS) {
+	while (READ_LE_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
+		if (READ_LE_UINT16(seeker + 14) & SCRIPT_INFO_CLASS) {
 			int classpos = seeker - scr->buf;
-			int species = getUInt16(seeker + 10);
+			int species = READ_LE_UINT16(seeker + 10);
 
 			if (species < 0 || species >= s->classtable_size) {
 				sciprintf("Invalid species %d(0x%x) not in interval [0,%d) while instantiating script %d\n",
@@ -1136,11 +1136,11 @@
 			s->classtable[species].reg.segment = seg;
 			s->classtable[species].reg.offset = classpos;
 		}
-		seeker += getUInt16(seeker + 2) * 2;
+		seeker += READ_LE_UINT16(seeker + 2) * 2;
 	}
 
-	seeker = scr->heap_start + 4 + getUInt16(scr->heap_start + 2) * 2;
-	while (getUInt16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
+	seeker = scr->heap_start + 4 + READ_LE_UINT16(scr->heap_start + 2) * 2;
+	while (READ_LE_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
 		reg_t reg;
 		Object *obj;
 
@@ -1160,7 +1160,7 @@
 		// Copy base from species class, as we need its selector IDs
 		obj->variables[6] = INST_LOOKUP_CLASS(obj->variables[6].offset);
 
-		seeker += getUInt16(seeker + 2) * 2;
+		seeker += READ_LE_UINT16(seeker + 2) * 2;
 	}
 }
 
@@ -1242,7 +1242,7 @@
 
 	if (exports_wide)
 		pubfunct *= 2;
-	offset = getUInt16((byte *)(script->export_table + pubfunct));
+	offset = READ_LE_UINT16((byte *)(script->export_table + pubfunct));
 	VERIFY(offset < script->buf_size, "invalid export function pointer");
 
 	return offset;

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -239,10 +239,10 @@
 
 // Getting instruction parameters
 #define GET_OP_BYTE() ((uint8)code_buf[(xs->addr.pc.offset)++])
-#define GET_OP_WORD() (getUInt16(code_buf + ((xs->addr.pc.offset) += 2) - 2))
+#define GET_OP_WORD() (READ_LE_UINT16(code_buf + ((xs->addr.pc.offset) += 2) - 2))
 #define GET_OP_FLEX() ((opcode & 1)? GET_OP_BYTE() : GET_OP_WORD())
 #define GET_OP_SIGNED_BYTE() ((int8)(code_buf[(xs->addr.pc.offset)++]))
-#define GET_OP_SIGNED_WORD() ((getInt16(code_buf + ((xs->addr.pc.offset) += 2) - 2)))
+#define GET_OP_SIGNED_WORD() (((int16)READ_LE_UINT16(code_buf + ((xs->addr.pc.offset) += 2) - 2)))
 #define GET_OP_SIGNED_FLEX() ((opcode & 1)? GET_OP_SIGNED_BYTE() : GET_OP_SIGNED_WORD())
 
 #define SEG_GET_HEAP(s, reg) s->seg_manager->getHeap(reg)
@@ -1489,7 +1489,7 @@
 		obj->base_vars = (uint16 *) buf;
 
 		for (i = 0; i < varnum; i++)
-			if (getUInt16(buf + (i << 1)) == slc) // Found it?
+			if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it?
 				return i; // report success
 
 		return -1; // Failed
@@ -1502,7 +1502,7 @@
 			buf = ((byte *) obj_get(s, obj->variables[SCRIPT_SUPERCLASS_SELECTOR])->base_vars);
 
 		for (i = 0; i < varnum; i++)
-			if (getUInt16(buf + (i << 1)) == slc) // Found it?
+			if (READ_LE_UINT16(buf + (i << 1)) == slc) // Found it?
 				return i; // report success
 
 		return -1; // Failed
@@ -1534,9 +1534,9 @@
 		if (index >= 0) {
 			if (fptr) {
 				if (s->version < SCI_VERSION(1, 001, 000))
-					*fptr = make_reg(obj->pos.segment, getUInt16((byte *)(obj->base_method + index + obj->methods_nr + 1)));
+					*fptr = make_reg(obj->pos.segment, READ_LE_UINT16((byte *)(obj->base_method + index + obj->methods_nr + 1)));
 				else
-					*fptr = make_reg(obj->pos.segment, getUInt16((byte *)(obj->base_method + index * 2 + 2)));
+					*fptr = make_reg(obj->pos.segment, READ_LE_UINT16((byte *)(obj->base_method + index * 2 + 2)));
 			}
 
 			return kSelectorMethod;
@@ -1603,7 +1603,7 @@
 	for (c = 0; c < 1000; c++) {
 		if ((script = s->resmgr->findResource(kResourceTypeScript, c, 0))) {
 
-			int id = getInt16(script->data);
+			int id = (int16)READ_LE_UINT16(script->data);
 
 			if (id > 15) {
 				version_require_earlier_than(s, SCI_VERSION_FTU_NEW_SCRIPT_HEADER);
@@ -1654,7 +1654,7 @@
 	        && export_index < script->exports_nr
 	        && export_index >= 0)
 #endif
-		return make_reg(seg, getUInt16((byte *)(script->export_table + export_index)));
+		return make_reg(seg, READ_LE_UINT16((byte *)(script->export_table + export_index)));
 #ifndef DISABLE_VALIDATIONS
 	else {
 		CORE_ERROR("EXPORTS", "Export invalid or script missing ");
@@ -1753,7 +1753,7 @@
 
 	if (s->version < SCI_VERSION_FTU_NEW_SCRIPT_HEADER) {
 		//
-		int locals_nr = getUInt16(script->data);
+		int locals_nr = READ_LE_UINT16(script->data);
 
 		// Old script block
 		// There won't be a localvar block in this case
@@ -1906,7 +1906,7 @@
 	s->seg_manager->mcpyInOut(0, script->data, script->size, seg_id, SEG_ID);
 	s->seg_manager->mcpyInOut(heap_start, heap->data, heap->size, seg_id, SEG_ID);
 
-	if (getUInt16(script->data + 6) > 0)
+	if (READ_LE_UINT16(script->data + 6) > 0)
 		s->seg_manager->setExportTableOffset(6, seg_id, SEG_ID);
 
 	reg.segment = seg_id;
@@ -1916,7 +1916,7 @@
 	s->seg_manager->scriptRelocateExportsSci11(seg_id);
 	s->seg_manager->scriptInitialiseObjectsSci11(s, seg_id);
 
-	reg.offset = getUInt16(heap->data);
+	reg.offset = READ_LE_UINT16(heap->data);
 	s->seg_manager->heapRelocate(s, reg);
 
 	return seg_id;

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-03-07 16:14:20 UTC (rev 39189)
@@ -131,7 +131,7 @@
 };
 
 #define RAW_GET_CLASS_INDEX(scr, reg) ((scr)->obj_indices->checkKey(reg.offset, false))
-#define RAW_IS_OBJECT(datablock) (getUInt16(((byte *) datablock) + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER)
+#define RAW_IS_OBJECT(datablock) (READ_LE_UINT16(((byte *) datablock) + SCRIPT_OBJECT_MAGIC_OFFSET) == SCRIPT_OBJECT_MAGIC_NUMBER)
 
 #define IS_CLASS(obj) (obj->variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)
 
@@ -176,21 +176,21 @@
 
 #define VM_OBJECT_GET_VARSELECTOR(obj, i)  \
 	(s->version < SCI_VERSION(1,001,000) ? \
-	 getUInt16(obj->base_obj + obj->variables_nr * 2 + i*2) : \
+	 READ_LE_UINT16(obj->base_obj + obj->variables_nr * 2 + i*2) : \
 	 *(obj->base_vars + i))
 #define VM_OBJECT_READ_PROPERTY(obj, i) (obj->variables[i])
 #define VM_OBJECT_GET_FUNCSELECTOR(obj, i) \
 	(s->version < SCI_VERSION(1,001,000) ? \
-	 getUInt16((byte *) (obj->base_method + i)) : \
-	 getUInt16((byte *) (obj->base_method + i*2 + 1)))
+	 READ_LE_UINT16((byte *) (obj->base_method + i)) : \
+	 READ_LE_UINT16((byte *) (obj->base_method + i*2 + 1)))
 #define VM_OBJECT_READ_FUNCTION(obj, i) \
 	(s->version < SCI_VERSION(1,001,000) ? \
 	 make_reg(obj->pos.segment, \
-		 getUInt16((byte *) (obj->base_method \
+		 READ_LE_UINT16((byte *) (obj->base_method \
 				 + obj->methods_nr + 1 \
 				 + i))) : \
 	 make_reg(obj->pos.segment, \
-		 getUInt16((byte *) (obj->base_method \
+		 READ_LE_UINT16((byte *) (obj->base_method \
 				 + i * 2 + 2))))
 
 

Modified: scummvm/trunk/engines/sci/gfx/resource/sci_pal_1.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_pal_1.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_pal_1.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -45,7 +45,7 @@
 	int entry_size = 0;
 	gfx_pixmap_color_t *retval;
 	byte *pal_data = resource + 37;
-	int _colors_nr = *colors_nr = getUInt16(resource + 29);
+	int _colors_nr = *colors_nr = READ_LE_UINT16(resource + 29);
 	int i;
 
 	switch (format) {

Modified: scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/gfx/resource/sci_pic_0.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -1735,8 +1735,8 @@
 			goto end_op_loop;
 
 			case PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST: {
-				int first = getInt16(resource + pos);
-				int last = getInt16(resource + pos + 2);
+				int first = (int16)READ_LE_UINT16(resource + pos);
+				int last = (int16)READ_LE_UINT16(resource + pos + 2);
 				int nr;
 				int *pri_table;
 
@@ -1778,10 +1778,10 @@
 
 void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
 					 gfxr_pic0_params_t *style, int resid, gfx_pixmap_color_t *static_pal, int static_pal_nr) {
-	int has_bitmap = getUInt16(resource + 4);
-	int vector_data_ptr = getUInt16(resource + 16);
-	int palette_data_ptr = getUInt16(resource + 28);
-	int bitmap_data_ptr = getUInt16(resource + 32);
+	int has_bitmap = READ_LE_UINT16(resource + 4);
+	int vector_data_ptr = READ_LE_UINT16(resource + 16);
+	int palette_data_ptr = READ_LE_UINT16(resource + 28);
+	int bitmap_data_ptr = READ_LE_UINT16(resource + 32);
 	int sci_titlebar_size = style->pic_port_bounds.y;
 	//gfx_mode_t *mode;
 	gfx_pixmap_t *view = NULL;

Modified: scummvm/trunk/engines/sci/scicore/vocab.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/scicore/vocab.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -191,10 +191,10 @@
 
 		suffices[counter]->alt_suffix_length = alt_len;
 		suffices[counter]->word_suffix_length = word_len;
-		suffices[counter]->class_mask = inverse_16(getInt16(resource->data + seeker)); // Inverse endianness
+		suffices[counter]->class_mask = inverse_16((int16)READ_LE_UINT16(resource->data + seeker)); // Inverse endianness
 
 		seeker += word_len + 4;
-		suffices[counter]->result_class = inverse_16(getInt16(resource->data + seeker));
+		suffices[counter]->result_class = inverse_16((int16)READ_LE_UINT16(resource->data + seeker));
 		seeker += 3; // Next entry
 
 		++counter;
@@ -246,10 +246,10 @@
 
 		byte *base = resource->data + i * 20;
 
-		retval[i].id = getInt16(base);
+		retval[i].id = (int16)READ_LE_UINT16(base);
 
 		for (k = 0; k < 9; k++)
-			retval[i].data[k] = getUInt16(base + 2 + 2 * k);
+			retval[i].data[k] = READ_LE_UINT16(base + 2 + 2 * k);
 
 		retval[i].data[9] = 0; // Always terminate
 	}

Modified: scummvm/trunk/engines/sci/sfx/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -720,10 +720,10 @@
 		sciprintf("[iterator-1] In sample at offset 0x04x: Byte #1 is %02x instead of zero\n",
 		          self->_data[offset + 1]);
 
-	rate = getInt16(self->_data + offset + 2);
+	rate = (int16)READ_LE_UINT16(self->_data + offset + 2);
 	length = READ_LE_UINT16(self->_data + offset + 4);
-	begin = getInt16(self->_data + offset + 6);
-	end = getInt16(self->_data + offset + 8);
+	begin = (int16)READ_LE_UINT16(self->_data + offset + 6);
+	end = (int16)READ_LE_UINT16(self->_data + offset + 8);
 
 	CHECK_FOR_END_ABSOLUTE((uint)(offset + 10 + length));
 

Modified: scummvm/trunk/engines/sci/tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/tools.cpp	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/tools.cpp	2009-03-07 16:14:20 UTC (rev 39189)
@@ -27,15 +27,15 @@
 
 namespace Sci {
 
-int sci_ffs(int _mask) {
-	int retval = 0;
+int sci_ffs(int bits) {
+	if (!bits)
+		return 0;
 
-	if (!_mask)
-		return 0;
-	retval++;
-	while (!(_mask & 1)) {
+	int retval = 1;
+
+	while (!(bits & 1)) {
 		retval++;
-		_mask >>= 1;
+		bits >>= 1;
 	}
 
 	return retval;

Modified: scummvm/trunk/engines/sci/tools.h
===================================================================
--- scummvm/trunk/engines/sci/tools.h	2009-03-07 15:48:54 UTC (rev 39188)
+++ scummvm/trunk/engines/sci/tools.h	2009-03-07 16:14:20 UTC (rev 39189)
@@ -31,14 +31,6 @@
 
 namespace Sci {
 
-/**** FUNCTION DECLARATIONS ****/
-
-#define getInt16	(int16)READ_LE_UINT16
-#define getUInt16	READ_LE_UINT16
-#define putInt16	WRITE_LE_UINT16
-
-/* --- */
-
 int sciprintf(const char *fmt, ...) GCC_PRINTF(1, 2);
 #define gfxprintf sciprintf
 /* Prints a string to the console stack


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