[Scummvm-cvs-logs] SF.net SVN: scummvm:[53739] scummvm/trunk/engines/scumm/he

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Oct 23 17:47:24 CEST 2010


Revision: 53739
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53739&view=rev
Author:   fingolfin
Date:     2010-10-23 15:47:23 +0000 (Sat, 23 Oct 2010)

Log Message:
-----------
SCUMM: Skip endian conversion on little endian systems (instead of assigning values back to themselves)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/resource_he.cpp
    scummvm/trunk/engines/scumm/he/resource_he.h
    scummvm/trunk/engines/scumm/he/script_v100he.cpp
    scummvm/trunk/engines/scumm/he/script_v70he.cpp
    scummvm/trunk/engines/scumm/he/script_v72he.cpp
    scummvm/trunk/engines/scumm/he/script_v80he.cpp
    scummvm/trunk/engines/scumm/he/script_v90he.cpp

Modified: scummvm/trunk/engines/scumm/he/resource_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/resource_he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -23,7 +23,6 @@
  *
  */
 
-
 #include "scumm/scumm.h"
 #include "scumm/file.h"
 #include "scumm/he/intern_he.h"
@@ -40,10 +39,14 @@
 
 namespace Scumm {
 
+#if defined(SCUMM_LITTLE_ENDIAN)
+#define LE16(x)
+#define LE32(x)
+#elif defined(SCUMM_BIG_ENDIAN)
 #define LE16(x)      ((x) = TO_LE_16(x))
 #define LE32(x)      ((x) = TO_LE_32(x))
+#endif
 
-
 ResExtractor::ResExtractor(ScummEngine_v70he *scumm)
 	: _vm(scumm) {
 
@@ -207,9 +210,9 @@
 }
 
 
-/* res_type_id_to_string:
- *   Translate a numeric resource type to it's corresponding string type.
- *   (For informative-ness.)
+/**
+ * Translate a numeric resource type to it's corresponding string type.
+ * (For informative-ness.)
  */
 const char *Win32ResExtractor::res_type_id_to_string(int id) {
 	if (id == 241)
@@ -219,9 +222,9 @@
 	return NULL;
 }
 
-/* res_type_string_to_id:
- *   Translate a resource type string to integer.
- *   (Used to convert the --type option.)
+/**
+ * Translate a resource type string to integer.
+ * (Used to convert the --type option.)
  */
 const char *Win32ResExtractor::res_type_string_to_id(const char *type) {
 	static const char *res_type_ids[] = {
@@ -242,18 +245,14 @@
 	return type;
 }
 
-/* return the resource id quoted if it's a string, otherwise just return it */
-char *Win32ResExtractor::WinResource::get_resource_id_quoted() {
-	// FIXME: Using a static var here is EVIL and in fact, broken when
-	// used multiple times in a row, e.g. in a single call to printf()
-	// or debug()... which is in fact how we use this function... :-)
-	static char tmp[WINRES_ID_MAXLEN+2];
-
+/**
+ * Return the resource id quoted if it is a string, otherwise (i.e. if
+ * it is numeric) just return it.
+ */
+Common::String Win32ResExtractor::WinResource::getQuotedResourceId() const {
 	if (numeric_id || id[0] == '\0')
 		return id;
-
-	sprintf(tmp, "'%s'", id);
-	return tmp;
+	return '"' + Common::String(id) + '"';
 }
 
 int Win32ResExtractor::extract_resources(WinLibrary *fi, WinResource *wr,
@@ -283,16 +282,16 @@
 
 	if (lang_wr != NULL && lang_wr->id[0] != '\0') {
 		debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s language: %s [size=%d]",
-		  name_wr->get_resource_id_quoted(), lang_wr->get_resource_id_quoted(), size);
+		  name_wr->getQuotedResourceId().c_str(), lang_wr->getQuotedResourceId().c_str(), size);
 	} else {
 		debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s [size=%d]",
-		  name_wr->get_resource_id_quoted(), size);
+		  name_wr->getQuotedResourceId().c_str(), size);
 	}
 	return size;
 }
 
-/* extract_resource:
- *   Extract a resource, returning pointer to data.
+/**
+ * Extract a resource, returning pointer to data.
  */
 byte *Win32ResExtractor::extract_resource(WinLibrary *fi, WinResource *wr, int *size,
 				  bool *free_it, char *type, char *lang, bool raw) {
@@ -322,17 +321,17 @@
 	return NULL;
 }
 
-/* extract_group_icon_resource:
- *   Create a complete RT_GROUP_ICON resource, that can be written to
- *   an `.ico' file without modifications. Returns an allocated
- *   memory block that should be freed with free() once used.
+/**
+ * Create a complete RT_GROUP_ICON resource, that can be written to
+ * an `.ico' file without modifications. Returns an allocated
+ * memory block that should be freed with free() once used.
  *
- *   `root' is the offset in file that specifies the resource.
- *   `base' is the offset that string pointers are calculated from.
- *   `ressize' should point to an integer variable where the size of
- *   the returned memory block will be placed.
- *   `is_icon' indicates whether resource to be extracted is icon
- *   or cursor group.
+ * `root' is the offset in file that specifies the resource.
+ * `base' is the offset that string pointers are calculated from.
+ * `ressize' should point to an integer variable where the size of
+ * the returned memory block will be placed.
+ * `is_icon' indicates whether resource to be extracted is icon
+ * or cursor group.
  */
 byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang,
 								   int *ressize, bool is_icon) {
@@ -467,10 +466,10 @@
 	return memory;
 }
 
-/* check_offset:
- *   Check if a chunk of data (determined by offset and size)
- *   is within the bounds of the WinLibrary file.
- *   Usually not called directly.
+/**
+ * Check if a chunk of data (determined by offset and size)
+ * is within the bounds of the WinLibrary file.
+ * Usually not called directly.
  */
 bool Win32ResExtractor::check_offset(byte *memory, int total_size, const char *name, void *offset, int size) {
 	int need_size = (int)((byte *)offset - memory + size);
@@ -487,8 +486,8 @@
 }
 
 
-/* do_resources:
- *   Do something for each resource matching type, name and lang.
+/**
+ * Do something for each resource matching type, name and lang.
  */
 int Win32ResExtractor::do_resources(WinLibrary *fi, const char *type, char *name, char *lang, byte **data) {
 	WinResource *type_wr;
@@ -496,7 +495,7 @@
 	WinResource *lang_wr;
 	int size;
 
-	type_wr = (WinResource *)calloc(sizeof(WinResource)*3, 1);
+	type_wr = (WinResource *)calloc(3, sizeof(WinResource));
 	name_wr = type_wr + 1;
 	lang_wr = type_wr + 2;
 
@@ -523,14 +522,11 @@
 	/* get a list of all resources at this level */
 	wr = list_resources(fi, base, &rescnt);
 	if (wr == NULL) {
-		if (size != 0)
-			return size;
-		else
-			return 0;
+		return size;
 	}
 
 	/* process each resource listed */
-	for (c = 0 ; c < rescnt ; c++) {
+	for (c = 0; c < rescnt; c++) {
 		/* (over)write the corresponding WinResource holder with the current */
 		memcpy(WINRESOURCE_BY_LEVEL(wr[c].level), wr+c, sizeof(WinResource));
 
@@ -557,7 +553,9 @@
 			return false;
 		if (id[0] == '-')
 			id++;
-		if (!(cmp1 = strtol(wr->id, 0, 10)) || !(cmp2 = strtol(id, 0, 10)) || cmp1 != cmp2)
+		cmp1 = strtol(wr->id, 0, 10);
+		cmp2 = strtol(id, 0, 10);
+		if (!cmp1 || !cmp2 || cmp1 != cmp2)
 			return false;
 	} else {
 		if (id[0] == '-')
@@ -645,9 +643,9 @@
 }
 
 
-/* list_resources:
- *   Return an array of WinResource's in the current
- *   resource level specified by _res->
+/**
+ * Return an array of WinResource's in the current
+ * resource level specified by _res->
  */
 Win32ResExtractor::WinResource *Win32ResExtractor::list_resources(WinLibrary *fi, WinResource *res, int *count) {
 	if (res != NULL && !res->is_directory)
@@ -659,10 +657,9 @@
 			 count);
 }
 
-/* read_library:
- *   Read header and get resource directory offset in a Windows library
- *    (AKA module).
- *
+/**
+ * Read header and get resource directory offset in a Windows library
+ * (AKA module).
  */
 bool Win32ResExtractor::read_library(WinLibrary *fi) {
 	/* check for DOS header signature `MZ' */
@@ -743,9 +740,9 @@
 	return false;
 }
 
-/* calc_vma_size:
- *   Calculate the total amount of memory needed for a 32-bit Windows
- *   module. Returns -1 if file was too small.
+/**
+ * Calculate the total amount of memory needed for a 32-bit Windows
+ * module. Returns -1 if file was too small.
  */
 int Win32ResExtractor::calc_vma_size(WinLibrary *fi) {
 	Win32ImageSectionHeader *seg;

Modified: scummvm/trunk/engines/scumm/he/resource_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/resource_he.h	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/resource_he.h	2010-10-23 15:47:23 UTC (rev 53739)
@@ -184,7 +184,7 @@
 		bool numeric_id;
 		bool is_directory;
 
-		char *get_resource_id_quoted();
+		Common::String getQuotedResourceId() const;
 	} PACKED_STRUCT;
 
 

Modified: scummvm/trunk/engines/scumm/he/script_v100he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v100he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/script_v100he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -34,7 +34,6 @@
 #include "scumm/he/intern_he.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
-#include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/he/sound_he.h"
 #include "scumm/he/sprite_he.h"

Modified: scummvm/trunk/engines/scumm/he/script_v70he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v70he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/script_v70he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -31,7 +31,6 @@
 #include "scumm/he/intern_he.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
-#include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/he/sound_he.h"
 #include "scumm/verbs.h"

Modified: scummvm/trunk/engines/scumm/he/script_v72he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v72he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/script_v72he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -36,7 +36,6 @@
 #include "scumm/he/intern_he.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
-#include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/he/sound_he.h"
 #include "scumm/util.h"

Modified: scummvm/trunk/engines/scumm/he/script_v80he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v80he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/script_v80he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -35,7 +35,6 @@
 #include "scumm/he/intern_he.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
-#include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/he/sound_he.h"
 

Modified: scummvm/trunk/engines/scumm/he/script_v90he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v90he.cpp	2010-10-23 15:46:50 UTC (rev 53738)
+++ scummvm/trunk/engines/scumm/he/script_v90he.cpp	2010-10-23 15:47:23 UTC (rev 53739)
@@ -32,7 +32,6 @@
 #include "scumm/he/logic_he.h"
 #include "scumm/object.h"
 #include "scumm/resource.h"
-#include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/sound.h"
 #include "scumm/he/sprite_he.h"


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