aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorTravis Howell2007-11-06 12:22:52 +0000
committerTravis Howell2007-11-06 12:22:52 +0000
commit443dff5285f0654be4a6f843b8262bd07bb95036 (patch)
tree4cf62d53140b7e6d756c05ee09a625865ce70580 /engines/scumm
parent3598192859797d8b7cc33a22af21f04bd45af01a (diff)
downloadscummvm-rg350-443dff5285f0654be4a6f843b8262bd07bb95036.tar.gz
scummvm-rg350-443dff5285f0654be4a6f843b8262bd07bb95036.tar.bz2
scummvm-rg350-443dff5285f0654be4a6f843b8262bd07bb95036.zip
Add support for original load/save system in HE games.
svn-id: r29434
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/he/script_v60he.cpp30
-rw-r--r--engines/scumm/he/script_v72he.cpp31
-rw-r--r--engines/scumm/saveload.cpp37
-rw-r--r--engines/scumm/scumm.cpp1
-rw-r--r--engines/scumm/scumm.h1
5 files changed, 68 insertions, 32 deletions
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index 2909a44223..6119e9e920 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -568,11 +568,19 @@ void ScummEngine_v60he::o60_roomOps() {
copyPalColor(a, b);
break;
case 221:
- int len;
+ byte buffer[100];
+ int len, r;
+
+ convertMessageToString(_scriptPointer, buffer, sizeof(buffer));
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
+
+ r = convertFilePath(buffer);
+ memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
+ debug(1, "o60_roomOps: case 221: filename %s", _saveLoadFileName);
+
_saveLoadFlag = pop();
- _saveLoadSlot = 1;
+ _saveLoadSlot = 255;
_saveTemporaryState = true;
break;
case 234: // HE 7.2
@@ -982,7 +990,6 @@ void ScummEngine_v60he::o60_openFile() {
const char *filename;
convertMessageToString(_scriptPointer, buffer, sizeof(buffer));
-
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
@@ -1042,34 +1049,35 @@ void ScummEngine_v60he::o60_deleteFile() {
const char *filename;
convertMessageToString(_scriptPointer, buffer, sizeof(buffer));
-
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
filename = (char *)buffer + convertFilePath(buffer);
+
debug(1, "o60_deleteFile stub (\"%s\")", filename);
+
+ _saveFileMan->removeSavefile(filename);
}
void ScummEngine_v60he::o60_rename() {
int len;
byte buffer1[100], buffer2[100];
- const char *filename1, *filename2;
+ const char *newFilename, *oldFilename;
convertMessageToString(_scriptPointer, buffer1, sizeof(buffer1));
-
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- filename1 = (char *)buffer1 + convertFilePath(buffer1);
-
convertMessageToString(_scriptPointer, buffer2, sizeof(buffer2));
-
len = resStrLen(_scriptPointer);
_scriptPointer += len + 1;
- filename2 = (char *)buffer2 + convertFilePath(buffer2);
+ oldFilename = (char *)buffer1 + convertFilePath(buffer1);
+ newFilename = (char *)buffer2 + convertFilePath(buffer2);
+
+ debug(1, "o60_rename stub (\"%s\" to \"%s\")", newFilename, oldFilename);
- debug(1, "o60_rename stub (\"%s\" to \"%s\")", filename1, filename2);
+ _saveFileMan->renameSavefile(oldFilename, newFilename);
}
int ScummEngine_v60he::readFileToArray(int slot, int32 size) {
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index df70fb7b0d..e5ffa12a37 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -978,7 +978,6 @@ void ScummEngine_v72he::o72_getNumFreeArrays() {
void ScummEngine_v72he::o72_roomOps() {
int a, b, c, d, e;
- byte filename[100];
byte subOp = fetchScriptByte();
@@ -1051,11 +1050,17 @@ void ScummEngine_v72he::o72_roomOps() {
break;
case 221:
- copyScriptString(filename, sizeof(filename));
- debug(1, "o72_roomOps: case 221: filename %s", filename);
+ byte buffer[256];
+ int r;
+
+ copyScriptString((byte *)buffer, sizeof(buffer));
+
+ r = convertFilePath(buffer);
+ memcpy(_saveLoadFileName, buffer + r, sizeof(buffer) - r);
+ debug(1, "o72_roomOps: case 221: filename %s", _saveLoadFileName);
_saveLoadFlag = pop();
- _saveLoadSlot = 1;
+ _saveLoadSlot = 255;
_saveTemporaryState = true;
break;
@@ -1871,18 +1876,26 @@ void ScummEngine_v72he::o72_findAllObjects() {
}
void ScummEngine_v72he::o72_deleteFile() {
- byte filename[256];
+ byte buffer[256];
- copyScriptString(filename, sizeof(filename));
+ copyScriptString(buffer, sizeof(buffer));
+ const char *filename = (char *)buffer + convertFilePath(buffer);
debug(1, "stub o72_deleteFile(%s)", filename);
+
+ _saveFileMan->removeSavefile(filename);
}
void ScummEngine_v72he::o72_rename() {
- byte oldFilename[100],newFilename[100];
+ byte buffer1[100],buffer2[100];
+
+ copyScriptString(buffer1, sizeof(buffer1));
+ copyScriptString(buffer2, sizeof(buffer2));
+
+ const char *newFilename = (char *)buffer1 + convertFilePath(buffer1);
+ const char *oldFilename = (char *)buffer2 + convertFilePath(buffer2);
- copyScriptString(newFilename, sizeof(newFilename));
- copyScriptString(oldFilename, sizeof(oldFilename));
+ _saveFileMan->renameSavefile(oldFilename, newFilename);
debug(1, "stub o72_rename(%s to %s)", oldFilename, newFilename);
}
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 2aa64ff409..17f0152b75 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -86,26 +86,34 @@ void ScummEngine::requestLoad(int slot) {
_saveLoadFlag = 2; // 2 for load
}
+static bool saveSaveGameHeader(Common::OutSaveFile *out, SaveGameHeader &hdr) {
+ hdr.type = MKID_BE('SCVM');
+ hdr.size = 0;
+ hdr.ver = CURRENT_VER;
+
+ out->writeUint32BE(hdr.type);
+ out->writeUint32LE(hdr.size);
+ out->writeUint32LE(hdr.ver);
+ out->write(hdr.name, sizeof(hdr.name));
+ return true;
+}
+
bool ScummEngine::saveState(int slot, bool compat) {
char filename[256];
Common::OutSaveFile *out;
SaveGameHeader hdr;
- makeSavegameName(filename, slot, compat);
-
+ if (_saveLoadSlot == 255) {
+ // Allow custom filenames for save game system in HE Games
+ memcpy(filename, _saveLoadFileName, sizeof(_saveLoadFileName));
+ } else {
+ makeSavegameName(filename, slot, compat);
+ }
if (!(out = _saveFileMan->openForSaving(filename)))
return false;
memcpy(hdr.name, _saveLoadName, sizeof(hdr.name));
-
- hdr.type = MKID_BE('SCVM');
- hdr.size = 0;
- hdr.ver = CURRENT_VER;
-
- out->writeUint32BE(hdr.type);
- out->writeUint32LE(hdr.size);
- out->writeUint32LE(hdr.ver);
- out->write(hdr.name, sizeof(hdr.name));
+ saveSaveGameHeader(out, hdr);
saveThumbnail(out);
saveInfos(out);
@@ -137,7 +145,12 @@ bool ScummEngine::loadState(int slot, bool compat) {
SaveGameHeader hdr;
int sb, sh;
- makeSavegameName(filename, slot, compat);
+ if (_saveLoadSlot == 255) {
+ // Allow custom filenames for save game system in HE Games
+ memcpy(filename, _saveLoadFileName, sizeof(_saveLoadFileName));
+ } else {
+ makeSavegameName(filename, slot, compat);
+ }
if (!(in = _saveFileMan->openForLoading(filename)))
return false;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index da01d7bbb8..24c23bc86b 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -200,6 +200,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_saveLoadSlot = 0;
_lastSaveTime = 0;
_saveTemporaryState = false;
+ memset(_saveLoadFileName, 0, sizeof(_saveLoadFileName));
memset(_saveLoadName, 0, sizeof(_saveLoadName));
memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
_scriptPointer = NULL;
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 510af6d1d2..f76a7c05e7 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -607,6 +607,7 @@ protected:
byte _saveLoadFlag, _saveLoadSlot;
uint32 _lastSaveTime;
bool _saveTemporaryState;
+ char _saveLoadFileName[32];
char _saveLoadName[32];
bool saveState(int slot, bool compat);