MYST3: Add support for archives with a decrypted header

This commit is contained in:
Bastien Bouclet 2012-01-14 17:51:36 +01:00
parent 637195a9cb
commit 96469bb219
2 changed files with 20 additions and 11 deletions

View file

@ -31,16 +31,25 @@ void Archive::_decryptHeader(Common::SeekableReadStream &inStream, Common::Write
static const uint32 multKey = 0x0019660D; static const uint32 multKey = 0x0019660D;
inStream.seek(0); inStream.seek(0);
uint32 encryptedSize = inStream.readUint32LE(); uint32 size = inStream.readUint32LE();
uint32 decryptedSize = encryptedSize ^ addKey;
bool encrypted = size > 1000000;
inStream.seek(0); inStream.seek(0);
uint32 currentKey = 0;
for (uint i = 0; i < decryptedSize; i++) { if (encrypted) {
currentKey += addKey; uint32 decryptedSize = size ^ addKey;
outStream.writeUint32LE(inStream.readUint32LE() ^ currentKey);
currentKey *= multKey; uint32 currentKey = 0;
for (uint i = 0; i < decryptedSize; i++) {
currentKey += addKey;
outStream.writeUint32LE(inStream.readUint32LE() ^ currentKey);
currentKey *= multKey;
}
} else {
for (uint i = 0; i < size; i++) {
outStream.writeUint32LE(inStream.readUint32LE());
}
} }
} }

View file

@ -175,7 +175,7 @@ Script::Script(Myst3Engine *vm):
OP_4(184, drawFramesForVar, kVar, kValue, kValue, kValue ); OP_4(184, drawFramesForVar, kVar, kValue, kValue, kValue );
OP_3(185, drawFramesForVarEachTwoFrames, kVar, kValue, kValue ); OP_3(185, drawFramesForVarEachTwoFrames, kVar, kValue, kValue );
OP_3(186, drawFramesForVarStartEndVarEachTwoFrames, kVar, kVar, kVar ); OP_3(186, drawFramesForVarStartEndVarEachTwoFrames, kVar, kVar, kVar );
OP_1(187, runScript, kValue ); OP_1(187, runScript, kEvalValue );
OP_1(189, runCommonScript, kValue ); OP_1(189, runCommonScript, kValue );
OP_1(194, runPuzzle1, kValue ); OP_1(194, runPuzzle1, kValue );
OP_2(195, runPuzzle2, kValue, kValue ); OP_2(195, runPuzzle2, kValue, kValue );
@ -1315,13 +1315,11 @@ void Script::ifHeadingInRange(Context &c, const Opcode &cmd) {
if (cmd.args[1] > cmd.args[0]) { if (cmd.args[1] > cmd.args[0]) {
// If heading in range // If heading in range
if (heading > cmd.args[0] && heading < cmd.args[1]) { if (heading > cmd.args[0] && heading < cmd.args[1]) {
debug("in range true %d %d", cmd.args[0], cmd.args[1]);
return; return;
} }
} else { } else {
// If heading *not* in range // If heading *not* in range
if (heading > cmd.args[0] || heading < cmd.args[1]) { if (heading > cmd.args[0] || heading < cmd.args[1]) {
debug("not in range true %d %d", cmd.args[1], cmd.args[0]);
return; return;
} }
} }
@ -1672,7 +1670,9 @@ void Script::drawFramesForVarStartEndVarEachTwoFrames(Context &c, const Opcode &
void Script::runScript(Context &c, const Opcode &cmd) { void Script::runScript(Context &c, const Opcode &cmd) {
debugC(kDebugScript, "Opcode %d: Run scripts from node %d", cmd.op, cmd.args[0]); debugC(kDebugScript, "Opcode %d: Run scripts from node %d", cmd.op, cmd.args[0]);
_vm->runScriptsFromNode(cmd.args[0], _vm->_state->getLocationRoom()); uint16 node = _vm->_state->valueOrVarValue(cmd.args[0]);
_vm->runScriptsFromNode(node, _vm->_state->getLocationRoom());
} }
void Script::runCommonScript(Context &c, const Opcode &cmd) { void Script::runCommonScript(Context &c, const Opcode &cmd) {