diff options
author | Jonathan Gray | 2003-08-31 14:58:56 +0000 |
---|---|---|
committer | Jonathan Gray | 2003-08-31 14:58:56 +0000 |
commit | f77faa2313deed248cf1dd9fcbeb842cb9a52b59 (patch) | |
tree | ddadbc15ebbbb4195c7684832aaf8316d2e90822 /scumm | |
parent | 3b62d9b4da96e4860ff596b0f11b18cc5ee0ff67 (diff) | |
download | scummvm-rg350-f77faa2313deed248cf1dd9fcbeb842cb9a52b59.tar.gz scummvm-rg350-f77faa2313deed248cf1dd9fcbeb842cb9a52b59.tar.bz2 scummvm-rg350-f77faa2313deed248cf1dd9fcbeb842cb9a52b59.zip |
some things needed for supporting original save/load screens in v3 games, doesn't fully work but doesn't break anything either
svn-id: r9940
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/intern.h | 2 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 106 |
2 files changed, 104 insertions, 4 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 942588458a..7596569815 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -46,6 +46,8 @@ protected: virtual void decodeParseString(); int getWordVararg(int *ptr); + void saveVars(); + void loadVars(); virtual int getVar(); virtual int getVarOrDirectByte(byte mask); diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index cacd4370bb..6531b599e6 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -831,7 +831,73 @@ void Scumm_v5::o5_getStringWidth() { void Scumm_v5::o5_saveLoadVars() { // TODO - error("o5_saveLoadVars not yet implemented"); + if (fetchScriptByte() == 1) + saveVars(); + else + loadVars(); +} + +void Scumm_v5::saveVars() { + int a, b; + + while ((_opcode = fetchScriptByte()) != 0) { + switch (_opcode & 0x1F) { + case 0x01: // write a range of variables + getResultPos(); + a = _resultVarNumber; + getResultPos(); + b = _resultVarNumber; + warning("stub saveVars: vars %d -> %d", a, b); + break; + + case 0x02: // write a range of string variables + a = getVarOrDirectByte(0x80); + b = getVarOrDirectByte(0x40); + warning("stub saveVars: strings %d -> %d", a, b); + break; + case 0x03: // open file + a = resStrLen(_scriptPointer); + warning("stub saveVars to %s", _scriptPointer); + _scriptPointer += a + 1; + break; + case 0x1F: // close file + warning("stub saveVars close file"); + break; + } + + } +} + +void Scumm_v5::loadVars() { + int a, b; + + hexdump(_scriptPointer, 64); + while ((_opcode = fetchScriptByte()) != 0) { + switch (_opcode & 0x1F) { + case 0x01: // read a range of variables + getResultPos(); + a = _resultVarNumber; + getResultPos(); + b = _resultVarNumber; + warning("stub loadVars: vars %d -> %d", a, b); + break; + case 0x02: // read a range of string variables + a = getVarOrDirectByte(0x80); + b = getVarOrDirectByte(0x40); + warning("stub loadVars: strings %d -> %d", a, b); + break; + case 0x03: // open file + a = resStrLen(_scriptPointer); + warning("stub loadVars from %s", _scriptPointer); + _scriptPointer += a + 1; + break; + case 0x1F: // close file + warning("stub loadVars close file"); + break; + } + + } + } void Scumm_v5::o5_expression() { @@ -1020,10 +1086,42 @@ void Scumm_v5::o5_getActorY() { void Scumm_v5::o5_getAnimCounter() { getResultPos(); // Loom uses this opcode in its load/save screen. - if (_gameId == GID_LOOM) { + //if (_gameId == GID_LOOM) { + if (_version <= 3) { byte a = getVarOrDirectByte(0x80); - warning("TODO: Loom saveLoad(%d)", a); - setResult(0); + byte slot = a & 0x1F; + byte result = 0; + + switch(a & 0xE0) { + case 0x00: // num slots available + result = 100; + break; + case 0x20: // dos drive? + result = 0; + break; + case 0x40: // load + if (loadState(slot, _saveLoadCompatible)) + result = 3; // sucess + else + result = 5; // failed to load + break; + case 0x80: // save + if (saveState(slot, _saveLoadCompatible)) + result = 0; + else + result = 2; + case 0xC0: // test if save exists + bool avail_saves[100]; + SaveFileManager *mgr = _system->get_savefile_manager(); + listSavegames(avail_saves, ARRAYSIZE(avail_saves), mgr); + delete mgr; + if (avail_saves[slot]) + result = 6; // save file exists + else + result = 7; // save file does not exist + break; + } + setResult(result); } else { int act = getVarOrDirectByte(0x80); Actor *a = derefActor(act, "o5_getAnimCounter"); |