aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTravis Howell2006-03-25 11:01:00 +0000
committerTravis Howell2006-03-25 11:01:00 +0000
commitef6baca2ac40bc4652bba9a791db96ca07b2a6a9 (patch)
tree9e670543b0bda20122253ed46f4aaf2d0f4d9800 /engines
parenta98aea6efd08840fed7fc2bd2e5d2826eb5e4897 (diff)
downloadscummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.tar.gz
scummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.tar.bz2
scummvm-rg350-ef6baca2ac40bc4652bba9a791db96ca07b2a6a9.zip
Move convertFilePath() to ScummEngine_v60he, to allow use by earlier HE games
svn-id: r21450
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/intern_he.h4
-rw-r--r--engines/scumm/he/script_v60he.cpp45
-rw-r--r--engines/scumm/he/script_v72he.cpp45
-rw-r--r--engines/scumm/he/wiz_he.cpp29
4 files changed, 58 insertions, 65 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index b87247c963..c319c319ac 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -66,8 +66,11 @@ protected:
void redimArray(int arrayId, int newX, int newY, int d);
int readFileToArray(int slot, int32 size);
void writeFileFromArray(int slot, int resID);
+
int virtScreenSave(byte *dst, int x1, int y1, int x2, int y2);
void virtScreenLoad(int resIdx, int x1, int y1, int x2, int y2);
+
+ int convertFilePath(byte *dst, bool setFilePath = false);
virtual void decodeParseString(int a, int b);
void swapObjects(int object1, int object2);
@@ -267,7 +270,6 @@ protected:
virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false);
void copyScriptString(byte *dst, int dstSize);
- int convertFilePath(byte *dst, bool setFilePath = false);
int findObject(int x, int y, int num, int *args);
int getSoundResourceSize(int id);
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index e26dd413a4..0ccb12555b 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -399,6 +399,51 @@ const char *ScummEngine_v60he::getOpcodeDesc(byte i) {
return _opcodesv60he[i].desc;
}
+int ScummEngine_v60he::convertFilePath(byte *dst, bool setFilePath) {
+ debug(1, "convertFilePath: original filePath is %s", dst);
+
+ int len = resStrLen(dst) + 1;
+ if (dst[0] == ':') {
+ // Switch all : to / for portablity
+ int j = 0;
+ for (int i = 1; i < len; i++) {
+ if (dst[i] == ':')
+ dst[j++] = '/';
+ else
+ dst[j++] = dst[i];
+ }
+ } else {
+ // Switch all \ to / for portablity
+ for (int i = 0; i < len; i++) {
+ if (dst[i] == '\\')
+ dst[i] = '/';
+ }
+ }
+
+ // Strip path
+ int r = 0;
+ if (dst[0] == '.' && dst[1] == '/') {
+ r = 2;
+ } else if (dst[0] == 'c' && dst[1] == ':') {
+ for (r = len; r != 0; r--) {
+ if (dst[r - 1] == '/')
+ break;
+ }
+ }
+
+ if (setFilePath) {
+ char filePath[256];
+ sprintf(filePath, "%s", dst + r);
+ if (!Common::File::exists(filePath)) {
+ sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r);
+ }
+ strcpy((char *)dst, filePath);
+ debug(1, "convertFilePath: filePath is %s", dst);
+ }
+
+ return r;
+}
+
void ScummEngine_v60he::o60_setState() {
int state = pop();
int obj = pop();
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index dfa04811eb..154fbfbda9 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -526,51 +526,6 @@ void ScummEngine_v72he::readArrayFromIndexFile() {
}
}
-int ScummEngine_v72he::convertFilePath(byte *dst, bool setFilePath) {
- debug(1, "convertFilePath: original filePath is %s", dst);
-
- int len = resStrLen(dst) + 1;
- if (dst[0] == ':') {
- // Switch all : to / for portablity
- int j = 0;
- for (int i = 1; i < len; i++) {
- if (dst[i] == ':')
- dst[j++] = '/';
- else
- dst[j++] = dst[i];
- }
- } else {
- // Switch all \ to / for portablity
- for (int i = 0; i < len; i++) {
- if (dst[i] == '\\')
- dst[i] = '/';
- }
- }
-
- // Strip path
- int r = 0;
- if (dst[0] == '.' && dst[1] == '/') {
- r = 2;
- } else if (dst[0] == 'c' && dst[1] == ':') {
- for (r = len; r != 0; r--) {
- if (dst[r - 1] == '/')
- break;
- }
- }
-
- if (setFilePath) {
- char filePath[256];
- sprintf(filePath, "%s", dst + r);
- if (!Common::File::exists(filePath)) {
- sprintf(filePath, "%s%s", _saveFileMan->getSavePath(), dst + r);
- }
- strcpy((char *)dst, filePath);
- debug(1, "convertFilePath: filePath is %s", dst);
- }
-
- return r;
-}
-
void ScummEngine_v72he::copyScriptString(byte *dst, int dstSize) {
byte string[1024];
byte chr;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index befda8f5c6..6449a69830 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1873,8 +1873,7 @@ void Wiz::remapWizImagePal(const WizParameters *params) {
}
void Wiz::processWizImage(const WizParameters *params) {
- char buf[512];
- unsigned int i;
+ byte filename[260];
debug(2, "processWizImage: processMode %d", params->processMode);
switch (params->processMode) {
@@ -1891,14 +1890,10 @@ void Wiz::processWizImage(const WizParameters *params) {
if (params->processFlags & kWPFUseFile) {
Common::File f;
- // Convert Windows path separators to something more portable
- strncpy(buf, (const char *)params->filename, 512);
- for (i = 0; i < strlen(buf); i++) {
- if (buf[i] == '\\')
- buf[i] = '/';
- }
+ memcpy(filename, params->filename, 260);
+ _vm->convertFilePath(filename);
- if (f.open((const char *)buf, Common::File::kFileReadMode)) {
+ if (f.open((const char *)filename, Common::File::kFileReadMode)) {
uint32 id = f.readUint32BE();
if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) {
uint32 size = f.readUint32BE();
@@ -1906,7 +1901,7 @@ void Wiz::processWizImage(const WizParameters *params) {
byte *p = _vm->res.createResource(rtImage, params->img.resNum, size);
if (f.read(p, size) != size) {
_vm->res.nukeResource(rtImage, params->img.resNum);
- error("i/o error when reading '%s'", buf);
+ error("i/o error when reading '%s'", filename);
_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
_vm->VAR(119) = -2;
} else {
@@ -1922,7 +1917,7 @@ void Wiz::processWizImage(const WizParameters *params) {
} else {
_vm->VAR(_vm->VAR_GAME_LOADED) = -3;
_vm->VAR(119) = -3;
- debug(0, "Unable to open for read '%s'", buf);
+ debug(0, "Unable to open for read '%s'", filename);
}
}
break;
@@ -1938,15 +1933,11 @@ void Wiz::processWizImage(const WizParameters *params) {
// TODO Write image to file
break;
case 0:
- // Convert Windows path separators to something more portable
- strncpy(buf, (const char *)params->filename, 512);
- for (i = 0; i < strlen(buf); i++) {
- if (buf[i] == '\\')
- buf[i] = '/';
- }
+ memcpy(filename, params->filename, 260);
+ _vm->convertFilePath(filename);
- if (!f.open((const char *)buf, Common::File::kFileWriteMode)) {
- debug(0, "Unable to open for write '%s'", buf);
+ if (!f.open((const char *)filename, Common::File::kFileWriteMode)) {
+ debug(0, "Unable to open for write '%s'", filename);
_vm->VAR(119) = -3;
} else {
byte *p = _vm->getResourceAddress(rtImage, params->img.resNum);