aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/logic_he.cpp32
-rw-r--r--engines/scumm/he/logic_he.h8
-rw-r--r--engines/scumm/he/palette_he.cpp4
-rw-r--r--engines/scumm/he/resource_he.cpp293
-rw-r--r--engines/scumm/he/resource_he.h2
-rw-r--r--engines/scumm/he/script_v100he.cpp7
-rw-r--r--engines/scumm/he/script_v60he.cpp7
-rw-r--r--engines/scumm/he/script_v70he.cpp1
-rw-r--r--engines/scumm/he/script_v72he.cpp9
-rw-r--r--engines/scumm/he/script_v80he.cpp1
-rw-r--r--engines/scumm/he/script_v90he.cpp55
-rw-r--r--engines/scumm/he/sound_he.cpp6
-rw-r--r--engines/scumm/he/wiz_he.cpp3
-rw-r--r--engines/scumm/he/wiz_he.h3
14 files changed, 237 insertions, 194 deletions
diff --git a/engines/scumm/he/logic_he.cpp b/engines/scumm/he/logic_he.cpp
index add9b982e2..ed92c33105 100644
--- a/engines/scumm/he/logic_he.cpp
+++ b/engines/scumm/he/logic_he.cpp
@@ -77,11 +77,11 @@ int32 LogicHE::dispatch(int op, int numArgs, int32 *args) {
#if 1
Common::String str;
- str = Common::String::printf("LogicHE::dispatch(%d, %d, [", op, numArgs);
+ str = Common::String::format("LogicHE::dispatch(%d, %d, [", op, numArgs);
if (numArgs > 0)
- str += Common::String::printf("%d", args[0]);
+ str += Common::String::format("%d", args[0]);
for (int i = 1; i < numArgs; i++) {
- str += Common::String::printf(", %d", args[i]);
+ str += Common::String::format(", %d", args[i]);
}
str += "])";
@@ -232,7 +232,7 @@ int32 LogicHErace::op_1101(int32 *args) {
int32 retval;
float temp;
- temp = args[0] / _userData[532];
+ temp = args[0] / _userData[532];
if (_userData[519] != temp) {
_userData[519] = temp;
op_sub3(temp);
@@ -955,6 +955,30 @@ int LogicHEsoccer::op_1021(int32 *args) {
}
/***********************
+ * Backyard Baseball 2001
+ *
+ */
+
+int LogicHEbaseball2001::versionID() {
+ return 1;
+}
+
+int32 LogicHEbaseball2001::dispatch(int op, int numArgs, int32 *args) {
+ int res = 0;
+
+ switch (op) {
+ case 3001:
+ // Check network status
+ break;
+
+ default:
+ LogicHE::dispatch(op, numArgs, args);
+ }
+
+ return res;
+}
+
+/***********************
* Backyard Basketball
*
*/
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index 7dd141c5b1..ab952abd5e 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -133,6 +133,14 @@ private:
int op_1021(int32 *args);
};
+class LogicHEbaseball2001 : public LogicHE {
+public:
+ LogicHEbaseball2001(ScummEngine_v90he *vm) : LogicHE(vm) {}
+
+ int versionID();
+ int32 dispatch(int op, int numArgs, int32 *args);
+};
+
class LogicHEbasketball : public LogicHE {
public:
LogicHEbasketball(ScummEngine_v90he *vm) : LogicHE(vm) {}
diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp
index 6ef68d981e..ad3f90b8eb 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -203,8 +203,8 @@ void ScummEngine_v90he::setHEPaletteFromImage(int palSlot, int resId, int state)
uint8 *data = getResourceAddress(rtImage, resId);
assert(data);
const uint8 *rgbs = findWrappedBlock(MKID_BE('RGBS'), data, state, 0);
- assert(rgbs);
- setHEPaletteFromPtr(palSlot, rgbs);
+ if (rgbs)
+ setHEPaletteFromPtr(palSlot, rgbs);
}
void ScummEngine_v90he::setHEPaletteFromRoom(int palSlot, int resId, int state) {
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index c259c3ffd2..f7a7d3a567 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "scumm/scumm.h"
#include "scumm/file.h"
#include "scumm/he/intern_he.h"
@@ -40,9 +39,13 @@
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 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
}
-/* 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 @@ const char *Win32ResExtractor::res_type_id_to_string(int id) {
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,22 +245,18 @@ const char *Win32ResExtractor::res_type_string_to_id(const char *type) {
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,
- WinResource *type_wr, WinResource *name_wr,
+ WinResource *type_wr, WinResource *name_wr,
WinResource *lang_wr, byte **data) {
int size;
bool free_it;
@@ -281,19 +280,21 @@ int Win32ResExtractor::extract_resources(WinLibrary *fi, WinResource *wr,
if ((id = strtol(type_wr->id, 0, 10)) != 0)
type = res_type_id_to_string(id);
- debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s%s%s [size=%d]",
- name_wr->get_resource_id_quoted(),
- (lang_wr->id[0] != '\0' ? " language: " : ""),
- lang_wr->get_resource_id_quoted(), size);
-
+ if (lang_wr != NULL && lang_wr->id[0] != '\0') {
+ debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s language: %s [size=%d]",
+ name_wr->getQuotedResourceId().c_str(), lang_wr->getQuotedResourceId().c_str(), size);
+ } else {
+ debugC(DEBUG_RESOURCE, "extractCursor(). Found cursor name: %s [size=%d]",
+ 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) {
+ bool *free_it, char *type, char *lang, bool raw) {
char *str;
int32 intval;
@@ -320,20 +321,20 @@ byte *Win32ResExtractor::extract_resource(WinLibrary *fi, WinResource *wr, int *
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) {
+ int *ressize, bool is_icon) {
Win32CursorIconDir *icondir;
Win32CursorIconFileDir *fileicondir;
byte *memory;
@@ -357,7 +358,7 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
WinResource *fwr;
RETURN_IF_BAD_POINTER(NULL, icondir->entries[c]);
- /*printf("%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\n", c,
+ /*debug("%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d", c,
FROM_LE_32(icondir->entries[c].bytes_in_res),
(is_icon ? icondir->entries[c].res_info.icon.width : FROM_LE_16(icondir->entries[c].res_info.cursor.width)),
(is_icon ? icondir->entries[c].res_info.icon.height : FROM_LE_16(icondir->entries[c].res_info.cursor.height)),
@@ -374,20 +375,20 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
}
if (get_resource_entry(fi, fwr, &iconsize) != NULL) {
- if (iconsize == 0) {
+ if (iconsize == 0) {
debugC(DEBUG_RESOURCE, "%s: icon resource `%s' is empty, skipping", _fileName.c_str(), name);
skipped++;
continue;
- }
- if ((uint32)iconsize != FROM_LE_32(icondir->entries[c].bytes_in_res)) {
+ }
+ if ((uint32)iconsize != FROM_LE_32(icondir->entries[c].bytes_in_res)) {
debugC(DEBUG_RESOURCE, "%s: mismatch of size in icon resource `%s' and group (%d != %d)",
_fileName.c_str(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res));
- }
- size += iconsize; /* size += FROM_LE_32(icondir->entries[c].bytes_in_res); */
+ }
+ size += iconsize; /* size += FROM_LE_32(icondir->entries[c].bytes_in_res); */
- /* cursor resources have two additional WORDs that contain
- * hotspot info */
- if (!is_icon)
+ /* cursor resources have two additional WORDs that contain
+ * hotspot info */
+ if (!is_icon)
size -= sizeof(uint16)*2;
}
}
@@ -428,8 +429,8 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
return NULL;
}
if (size == 0) {
- skipped++;
- continue;
+ skipped++;
+ continue;
}
/* copy ICONDIRENTRY (not including last dwImageOffset) */
@@ -465,10 +466,10 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR
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);
@@ -485,8 +486,8 @@ bool Win32ResExtractor::check_offset(byte *memory, int total_size, const char *n
}
-/* 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;
@@ -494,7 +495,7 @@ int Win32ResExtractor::do_resources(WinLibrary *fi, const char *type, char *name
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;
@@ -521,14 +522,11 @@ int Win32ResExtractor::do_resources_recurs(WinLibrary *fi, WinResource *base,
/* 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));
@@ -555,7 +553,9 @@ bool Win32ResExtractor::compare_resource_id(WinResource *wr, const char *id) {
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] == '-')
@@ -643,9 +643,9 @@ Win32ResExtractor::WinResource *Win32ResExtractor::list_pe_resources(WinLibrary
}
-/* 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)
@@ -657,10 +657,9 @@ Win32ResExtractor::WinResource *Win32ResExtractor::list_resources(WinLibrary *fi
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' */
@@ -695,7 +694,9 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) {
/* calc_vma_size has reported error */
return false;
}
- fi->memory = (byte *)realloc(fi->memory, fi->total_size);
+ byte *ptr = (byte *)realloc(fi->memory, fi->total_size);
+ assert(ptr);
+ fi->memory = ptr;
/* relocate memory, start from last section */
pe_header = PE_HEADER(fi->memory);
@@ -739,13 +740,13 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) {
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;
- int c, segcount, size;
+ Win32ImageSectionHeader *seg;
+ int c, segcount, size;
size = 0;
RETURN_IF_BAD_POINTER(-1, PE_HEADER(fi->memory)->file_header.number_of_sections);
@@ -760,7 +761,7 @@ int Win32ResExtractor::calc_vma_size(WinLibrary *fi) {
seg = PE_SECTIONS(fi->memory);
RETURN_IF_BAD_POINTER(-1, *seg);
- for (c = 0 ; c < segcount ; c++) {
+ for (c = 0 ; c < segcount ; c++) {
RETURN_IF_BAD_POINTER(0, *seg);
fix_win32_image_section_header(seg);
@@ -768,9 +769,9 @@ int Win32ResExtractor::calc_vma_size(WinLibrary *fi) {
/* I have no idea what misc.virtual_size is for... */
size = MAX((uint32)size, seg->virtual_address + seg->misc.virtual_size);
seg++;
- }
+ }
- return size;
+ return size;
}
Win32ResExtractor::WinResource *Win32ResExtractor::find_with_resource_array(WinLibrary *fi, WinResource *wr, const char *id) {
@@ -914,8 +915,8 @@ int Win32ResExtractor::convertIcons(byte *data, int datasize, byte **cursor, int
if (entries[c].dib_size != bitmap.size + image_size + mask_size + palette_count * sizeof(Win32RGBQuad))
debugC(DEBUG_RESOURCE, "incorrect total size of bitmap (%d specified; %d real)",
- entries[c].dib_size,
- (int)(bitmap.size + image_size + mask_size + palette_count * sizeof(Win32RGBQuad))
+ entries[c].dib_size,
+ (int)(bitmap.size + image_size + mask_size + palette_count * sizeof(Win32RGBQuad))
);
image_data = (byte *)malloc(image_size);
@@ -977,9 +978,9 @@ int Win32ResExtractor::convertIcons(byte *data, int datasize, byte **cursor, int
row[4*x+2] = (color >> 0) & 0xFF;
}
if (bitmap.bit_count == 32)
- row[4*x+3] = (color >> 24) & 0xFF;
+ row[4*x+3] = (color >> 24) & 0xFF;
else
- row[4*x+3] = simple_vec(mask_data, x + mmod, 1) ? 0 : 0xFF;
+ row[4*x+3] = simple_vec(mask_data, x + mmod, 1) ? 0 : 0xFF;
*/
}
@@ -1051,93 +1052,93 @@ uint32 Win32ResExtractor::simple_vec(byte *data, uint32 ofs, byte size) {
}
void Win32ResExtractor::fix_win32_cursor_icon_file_dir_endian(Win32CursorIconFileDir *obj) {
- LE16(obj->reserved);
+ LE16(obj->reserved);
LE16(obj->type);
- LE16(obj->count);
+ LE16(obj->count);
}
void Win32ResExtractor::fix_win32_bitmap_info_header_endian(Win32BitmapInfoHeader *obj) {
- LE32(obj->size);
- LE32(obj->width);
- LE32(obj->height);
- LE16(obj->planes);
- LE16(obj->bit_count);
- LE32(obj->compression);
- LE32(obj->size_image);
- LE32(obj->x_pels_per_meter);
- LE32(obj->y_pels_per_meter);
- LE32(obj->clr_used);
- LE32(obj->clr_important);
+ LE32(obj->size);
+ LE32(obj->width);
+ LE32(obj->height);
+ LE16(obj->planes);
+ LE16(obj->bit_count);
+ LE32(obj->compression);
+ LE32(obj->size_image);
+ LE32(obj->x_pels_per_meter);
+ LE32(obj->y_pels_per_meter);
+ LE32(obj->clr_used);
+ LE32(obj->clr_important);
}
void Win32ResExtractor::fix_win32_cursor_icon_file_dir_entry_endian(Win32CursorIconFileDirEntry *obj) {
- LE16(obj->hotspot_x);
- LE16(obj->hotspot_y);
- LE32(obj->dib_size);
- LE32(obj->dib_offset);
+ LE16(obj->hotspot_x);
+ LE16(obj->hotspot_y);
+ LE32(obj->dib_size);
+ LE32(obj->dib_offset);
}
void Win32ResExtractor::fix_win32_image_section_header(Win32ImageSectionHeader *obj) {
- LE32(obj->misc.physical_address);
- LE32(obj->virtual_address);
- LE32(obj->size_of_raw_data);
- LE32(obj->pointer_to_raw_data);
- LE32(obj->pointer_to_relocations);
- LE32(obj->pointer_to_linenumbers);
- LE16(obj->number_of_relocations);
- LE16(obj->number_of_linenumbers);
- LE32(obj->characteristics);
+ LE32(obj->misc.physical_address);
+ LE32(obj->virtual_address);
+ LE32(obj->size_of_raw_data);
+ LE32(obj->pointer_to_raw_data);
+ LE32(obj->pointer_to_relocations);
+ LE32(obj->pointer_to_linenumbers);
+ LE16(obj->number_of_relocations);
+ LE16(obj->number_of_linenumbers);
+ LE32(obj->characteristics);
}
/* fix_win32_image_header_endian:
* NOTE: This assumes that the optional header is always available.
*/
void Win32ResExtractor::fix_win32_image_header_endian(Win32ImageNTHeaders *obj) {
- LE32(obj->signature);
- LE16(obj->file_header.machine);
- LE16(obj->file_header.number_of_sections);
- LE32(obj->file_header.time_date_stamp);
- LE32(obj->file_header.pointer_to_symbol_table);
- LE32(obj->file_header.number_of_symbols);
- LE16(obj->file_header.size_of_optional_header);
- LE16(obj->file_header.characteristics);
+ LE32(obj->signature);
+ LE16(obj->file_header.machine);
+ LE16(obj->file_header.number_of_sections);
+ LE32(obj->file_header.time_date_stamp);
+ LE32(obj->file_header.pointer_to_symbol_table);
+ LE32(obj->file_header.number_of_symbols);
+ LE16(obj->file_header.size_of_optional_header);
+ LE16(obj->file_header.characteristics);
// FIXME: Does this assert ever trigger? If so, we should modify this function
// to properly deal with it.
assert(obj->file_header.size_of_optional_header >= sizeof(obj->optional_header));
- LE16(obj->optional_header.magic);
- LE32(obj->optional_header.size_of_code);
- LE32(obj->optional_header.size_of_initialized_data);
- LE32(obj->optional_header.size_of_uninitialized_data);
- LE32(obj->optional_header.address_of_entry_point);
- LE32(obj->optional_header.base_of_code);
- LE32(obj->optional_header.base_of_data);
- LE32(obj->optional_header.image_base);
- LE32(obj->optional_header.section_alignment);
- LE32(obj->optional_header.file_alignment);
- LE16(obj->optional_header.major_operating_system_version);
- LE16(obj->optional_header.minor_operating_system_version);
- LE16(obj->optional_header.major_image_version);
- LE16(obj->optional_header.minor_image_version);
- LE16(obj->optional_header.major_subsystem_version);
- LE16(obj->optional_header.minor_subsystem_version);
- LE32(obj->optional_header.win32_version_value);
- LE32(obj->optional_header.size_of_image);
- LE32(obj->optional_header.size_of_headers);
- LE32(obj->optional_header.checksum);
- LE16(obj->optional_header.subsystem);
- LE16(obj->optional_header.dll_characteristics);
- LE32(obj->optional_header.size_of_stack_reserve);
- LE32(obj->optional_header.size_of_stack_commit);
- LE32(obj->optional_header.size_of_heap_reserve);
- LE32(obj->optional_header.size_of_heap_commit);
- LE32(obj->optional_header.loader_flags);
- LE32(obj->optional_header.number_of_rva_and_sizes);
+ LE16(obj->optional_header.magic);
+ LE32(obj->optional_header.size_of_code);
+ LE32(obj->optional_header.size_of_initialized_data);
+ LE32(obj->optional_header.size_of_uninitialized_data);
+ LE32(obj->optional_header.address_of_entry_point);
+ LE32(obj->optional_header.base_of_code);
+ LE32(obj->optional_header.base_of_data);
+ LE32(obj->optional_header.image_base);
+ LE32(obj->optional_header.section_alignment);
+ LE32(obj->optional_header.file_alignment);
+ LE16(obj->optional_header.major_operating_system_version);
+ LE16(obj->optional_header.minor_operating_system_version);
+ LE16(obj->optional_header.major_image_version);
+ LE16(obj->optional_header.minor_image_version);
+ LE16(obj->optional_header.major_subsystem_version);
+ LE16(obj->optional_header.minor_subsystem_version);
+ LE32(obj->optional_header.win32_version_value);
+ LE32(obj->optional_header.size_of_image);
+ LE32(obj->optional_header.size_of_headers);
+ LE32(obj->optional_header.checksum);
+ LE16(obj->optional_header.subsystem);
+ LE16(obj->optional_header.dll_characteristics);
+ LE32(obj->optional_header.size_of_stack_reserve);
+ LE32(obj->optional_header.size_of_stack_commit);
+ LE32(obj->optional_header.size_of_heap_reserve);
+ LE32(obj->optional_header.size_of_heap_commit);
+ LE32(obj->optional_header.loader_flags);
+ LE32(obj->optional_header.number_of_rva_and_sizes);
}
void Win32ResExtractor::fix_win32_image_data_directory(Win32ImageDataDirectory *obj) {
- LE32(obj->virtual_address);
- LE32(obj->size);
+ LE32(obj->virtual_address);
+ LE32(obj->size);
}
diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h
index 4567c598a3..65190ea41c 100644
--- a/engines/scumm/he/resource_he.h
+++ b/engines/scumm/he/resource_he.h
@@ -184,7 +184,7 @@ class Win32ResExtractor : public ResExtractor {
bool numeric_id;
bool is_directory;
- char *get_resource_id_quoted();
+ Common::String getQuotedResourceId() const;
} PACKED_STRUCT;
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 3555f55d95..ca4a65ac74 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -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"
@@ -1623,13 +1622,11 @@ void ScummEngine_v100he::o100_roomOps() {
case 137:
byte buffer[256];
- int r;
copyScriptString((byte *)buffer, sizeof(buffer));
- r = convertFilePath(buffer, sizeof(buffer));
- memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
- debug(1, "o100_roomOps: case 137: filename %s", _saveLoadFileName);
+ _saveLoadFileName = (char *)buffer + convertFilePath(buffer, sizeof(buffer));
+ debug(1, "o100_roomOps: case 137: filename %s", _saveLoadFileName.c_str());
_saveLoadFlag = pop();
_saveLoadSlot = 255;
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index 8ade78c1b5..9d62a31f6d 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -283,15 +283,14 @@ void ScummEngine_v60he::o60_roomOps() {
break;
case 221:
byte buffer[100];
- int len, r;
+ int len;
convertMessageToString(_scriptPointer, buffer, sizeof(buffer));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- r = convertFilePath(buffer, sizeof(buffer));
- memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
- debug(1, "o60_roomOps: case 221: filename %s", _saveLoadFileName);
+ _saveLoadFileName = (char *)buffer + convertFilePath(buffer, sizeof(buffer));
+ debug(1, "o60_roomOps: case 221: filename %s", _saveLoadFileName.c_str());
_saveLoadFlag = pop();
_saveLoadSlot = 255;
diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp
index 979b2b3df4..9b160151b0 100644
--- a/engines/scumm/he/script_v70he.cpp
+++ b/engines/scumm/he/script_v70he.cpp
@@ -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"
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index baa57c7821..76daacbd54 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -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"
@@ -173,7 +172,7 @@ int ScummEngine_v72he::readArray(int array, int idx2, int idx1) {
}
const int offset = (FROM_LE_32(ah->dim1end) - FROM_LE_32(ah->dim1start) + 1) *
- (idx2 - FROM_LE_32(ah->dim2start)) - FROM_LE_32(ah->dim1start) + idx1;
+ (idx2 - FROM_LE_32(ah->dim2start)) + (idx1 - FROM_LE_32(ah->dim1start));
switch (FROM_LE_32(ah->type)) {
case kByteArray:
@@ -711,13 +710,11 @@ void ScummEngine_v72he::o72_roomOps() {
case 221:
byte buffer[256];
- int r;
copyScriptString((byte *)buffer, sizeof(buffer));
- r = convertFilePath(buffer, sizeof(buffer));
- memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
- debug(1, "o72_roomOps: case 221: filename %s", _saveLoadFileName);
+ _saveLoadFileName = (char *)buffer + convertFilePath(buffer, sizeof(buffer));
+ debug(1, "o72_roomOps: case 221: filename %s", _saveLoadFileName.c_str());
_saveLoadFlag = pop();
_saveLoadSlot = 255;
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index dd44180fa0..b06dc712d9 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -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"
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 6acc16a804..841eba960d 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -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"
@@ -1948,42 +1947,51 @@ void ScummEngine_v90he::getArrayDim(int array, int *dim2start, int *dim2end, int
}
}
+static int sortArrayOffset;
+
static int compareByteArray(const void *a, const void *b) {
- int va = *((const uint8 *)a);
- int vb = *((const uint8 *)a);
+ int va = *((const uint8 *)a + sortArrayOffset);
+ int vb = *((const uint8 *)b + sortArrayOffset);
return va - vb;
}
static int compareByteArrayReverse(const void *a, const void *b) {
- int va = *((const uint8 *)a);
- int vb = *((const uint8 *)a);
+ int va = *((const uint8 *)a + sortArrayOffset);
+ int vb = *((const uint8 *)b + sortArrayOffset);
return vb - va;
}
static int compareIntArray(const void *a, const void *b) {
- int va = (int16)READ_LE_UINT16((const uint8 *)a);
- int vb = (int16)READ_LE_UINT16((const uint8 *)b);
+ int va = (int16)READ_LE_UINT16((const uint8 *)a + sortArrayOffset * 2);
+ int vb = (int16)READ_LE_UINT16((const uint8 *)b + sortArrayOffset * 2);
return va - vb;
}
static int compareIntArrayReverse(const void *a, const void *b) {
- int va = (int16)READ_LE_UINT16((const uint8 *)a);
- int vb = (int16)READ_LE_UINT16((const uint8 *)b);
+ int va = (int16)READ_LE_UINT16((const uint8 *)a + sortArrayOffset * 2);
+ int vb = (int16)READ_LE_UINT16((const uint8 *)b + sortArrayOffset * 2);
return vb - va;
}
static int compareDwordArray(const void *a, const void *b) {
- int va = (int32)READ_LE_UINT32((const uint8 *)a);
- int vb = (int32)READ_LE_UINT32((const uint8 *)b);
+ int va = (int32)READ_LE_UINT32((const uint8 *)a + sortArrayOffset * 4);
+ int vb = (int32)READ_LE_UINT32((const uint8 *)b + sortArrayOffset * 4);
return va - vb;
}
static int compareDwordArrayReverse(const void *a, const void *b) {
- int va = (int32)READ_LE_UINT32((const uint8 *)a);
- int vb = (int32)READ_LE_UINT32((const uint8 *)b);
+ int va = (int32)READ_LE_UINT32((const uint8 *)a + sortArrayOffset * 4);
+ int vb = (int32)READ_LE_UINT32((const uint8 *)b + sortArrayOffset * 4);
return vb - va;
}
+
+/**
+ * Sort a row range in a two-dimensional array by the value in a given column.
+ *
+ * We sort the data in the row range [dim2start..dim2end], according to the value
+ * in column dim1start == dim1end.
+ */
void ScummEngine_v90he::sortArray(int array, int dim2start, int dim2end, int dim1start, int dim1end, int sortOrder) {
debug(9, "sortArray(%d, [%d,%d,%d,%d], %d)", array, dim2start, dim2end, dim1start, dim1end, sortOrder);
@@ -1992,11 +2000,21 @@ void ScummEngine_v90he::sortArray(int array, int dim2start, int dim2end, int dim
ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(array));
assert(ah);
- const int num = dim2end - dim2start + 1;
- const int pitch = FROM_LE_32(ah->dim1end) - FROM_LE_32(ah->dim1start) + 1;
- const int offset = pitch * (dim2start - FROM_LE_32(ah->dim2start))
- + dim1start - FROM_LE_32(ah->dim1start);
-
+ const int num = dim2end - dim2start + 1; // number of rows to sort
+ const int pitch = FROM_LE_32(ah->dim1end) - FROM_LE_32(ah->dim1start) + 1; // length of a row = number of columns in it
+ const int offset = pitch * (dim2start - FROM_LE_32(ah->dim2start)); // memory offset to the first row to be sorted
+ sortArrayOffset = dim1start - FROM_LE_32(ah->dim1start); // offset to the column by which we sort
+
+ // Now we just have to invoke qsort on the appropriate row range. We
+ // need to pass sortArrayOffset as an implicit parameter to the
+ // comparison functions, which makes it necessary to use a global
+ // (albeit local to this file) variable.
+ // This could be avoided by using qsort_r or a self-written portable
+ // analog (this function passes an additional, user determined
+ // parameter to the comparison function).
+ // Another idea would be to use Common::sort, but that only is
+ // suitable if you sort objects of fixed size, which must be known
+ // during compilation time; clearly this not the case here.
switch (FROM_LE_32(ah->type)) {
case kByteArray:
case kStringArray:
@@ -2039,7 +2057,6 @@ void ScummEngine_v90he::o90_sortArray() {
int dim2end = pop();
int dim2start = pop();
getArrayDim(array, &dim2start, &dim2end, &dim1start, &dim1end);
- checkArrayLimits(array, dim2start, dim2end, dim1start, dim1end);
sortArray(array, dim2start, dim2end, dim1start, dim1end, sortOrder);
}
break;
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 314697869c..1d02a95b30 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -240,7 +240,7 @@ int SoundHE::isSoundCodeUsed(int sound) {
chan = i;
}
- if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
+ if (chan != -1 && _mixer->isSoundHandleActive(_heSoundChannels[chan])) {
return _heChannel[chan].sbngBlock;
} else {
return 0;
@@ -254,7 +254,7 @@ int SoundHE::getSoundPos(int sound) {
chan = i;
}
- if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
+ if (chan != -1 && _mixer->isSoundHandleActive(_heSoundChannels[chan])) {
int time = _vm->getHETimer(chan + 4) * _heChannel[chan].rate / 1000;
return time;
} else {
@@ -275,7 +275,7 @@ int SoundHE::getSoundVar(int sound, int var) {
chan = i;
}
- if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
+ if (chan != -1 && _mixer->isSoundHandleActive(_heSoundChannels[chan])) {
debug(5, "getSoundVar: sound %d var %d result %d", sound, var, _heChannel[chan].soundVars[var]);
return _heChannel[chan].soundVars[var];
} else {
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 361a3bc165..ddbbb2101f 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -358,6 +358,7 @@ static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w,
void Wiz::writeColor(uint8 *dstPtr, int dstType, uint16 color) {
switch (dstType) {
+ case kDstCursor:
case kDstScreen:
WRITE_UINT16(dstPtr, color);
break;
@@ -1519,7 +1520,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int
cw = width;
ch = height;
dstPitch = cw * _vm->_bytesPerPixel;
- dstType = kDstMemory;
+ dstType = (_cursorImage) ? kDstCursor : kDstMemory;
} else {
if (dstResNum) {
uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 1fa9564486..c255e27d14 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -145,7 +145,8 @@ enum {
enum DstSurface {
kDstScreen = 0,
kDstMemory = 1,
- kDstResource = 2
+ kDstResource = 2,
+ kDstCursor = 3
};
class ScummEngine_v71he;