MYST3: Add support for archives with a decrypted header
This commit is contained in:
parent
637195a9cb
commit
96469bb219
2 changed files with 20 additions and 11 deletions
|
@ -31,17 +31,26 @@ 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;
|
|
||||||
|
|
||||||
|
if (encrypted) {
|
||||||
|
uint32 decryptedSize = size ^ addKey;
|
||||||
|
|
||||||
|
uint32 currentKey = 0;
|
||||||
for (uint i = 0; i < decryptedSize; i++) {
|
for (uint i = 0; i < decryptedSize; i++) {
|
||||||
currentKey += addKey;
|
currentKey += addKey;
|
||||||
outStream.writeUint32LE(inStream.readUint32LE() ^ currentKey);
|
outStream.writeUint32LE(inStream.readUint32LE() ^ currentKey);
|
||||||
currentKey *= multKey;
|
currentKey *= multKey;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (uint i = 0; i < size; i++) {
|
||||||
|
outStream.writeUint32LE(inStream.readUint32LE());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Archive::_readDirectory() {
|
void Archive::_readDirectory() {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue