[Scummvm-git-logs] scummvm master -> aedf820328bd239e83bab34d98e9e9ffe3a71928
sev-
sev at scummvm.org
Thu Jul 15 11:58:36 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8522ef0f4f SCUMM: Patch the MI2 Mac boot script
d2758e913a SCUMM: Use the MI2 Mac specific boot param to bypass the copy protection
4fe3889861 SCUMM: Handle failure to patch MI2 Mac boot script more gracefully
aedf820328 SCUMM: Changed tabs to spaces
Commit: 8522ef0f4f51eec83e6b43e93bfa66ddf4f8337d
https://github.com/scummvm/scummvm/commit/8522ef0f4f51eec83e6b43e93bfa66ddf4f8337d
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-07-15T13:58:31+02:00
Commit Message:
SCUMM: Patch the MI2 Mac boot script
There are (at least) two different versions of MI2 for the Mac. The one
that was distributed with the LucasArts Mac CD Game Pack II has a
modified boot script that completely removes the copy protection screen
(yay!) and the difficulty selection (boo!).
To re-instastate the difficulty selection, patch the boot script to be
identical to the other version, which was presumably released on
floppies.
This patching is only done if the boot script has the exact expected
length of the CD version's script, and if the patched script matches the
floppy version's. That should be safe enough.
Changed paths:
engines/scumm/resource.cpp
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 24e0735b19..7c7397e327 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -20,7 +20,9 @@
*
*/
+#include "common/md5.h"
#include "common/str.h"
+#include "common/memstream.h"
#include "common/macresman.h"
#ifndef MACOSX
#include "common/config-manager.h"
@@ -700,6 +702,8 @@ int ScummEngine::loadResource(ResType type, ResId idx) {
applyWorkaroundIfNeeded(type, idx);
+ // NB: The workaround may have changed the resource size, so don't rely on 'size' after this.
+
// dump the resource if requested
if (_dumpScripts && type == rtScript) {
dumpResource("script-", idx, getResourceAddress(rtScript, idx));
@@ -1645,13 +1649,14 @@ const char *nameOfResType(ResType type) {
}
}
-
void ScummEngine::applyWorkaroundIfNeeded(ResType type, int idx) {
+ int size = getResourceSize(type, idx);
+
// WORKAROUND: FM-TOWNS Zak used the extra 40 pixels at the bottom to increase the inventory to 10 items
// if we trim to 200 pixels, we can show only 6 items
// therefore we patch the inventory script (20)
// replacing the 5 occurences of 10 as limit to 6
- if (_game.platform == Common::kPlatformFMTowns && _game.id == GID_ZAK && ConfMan.getBool("trim_fmtowns_to_200_pixels"))
+ if (_game.platform == Common::kPlatformFMTowns && _game.id == GID_ZAK && ConfMan.getBool("trim_fmtowns_to_200_pixels")) {
if (type == rtScript && idx == 20) {
byte *ptr = getResourceAddress(rtScript, idx);
for (int cnt = 5; cnt; ptr++) {
@@ -1661,6 +1666,68 @@ void ScummEngine::applyWorkaroundIfNeeded(ResType type, int idx) {
}
}
}
+ }
+
+ // WORKAROUND: The Mac version of Monkey Island 2 that was distributed
+ // on CD as the LucasArts Adventure Game Pack II is missing the part of
+ // the boot script that shows the copy protection and difficulty
+ // selection screen. Presumably it didn't include the code wheel. In
+ // fact, none of the games on this CD have any copy protection.
+ //
+ // The games on the first Game Pack CD does have copy protection, but
+ // since I only own the discs I can neither confirm nor deny if the
+ // necessary documentation was included.
+ //
+ // However, this means that there is no way to pick the difficulty
+ // level. Since ScummVM bypasses the copy protection check, there is
+ // no harm in showing the screen by simply re-inserging the missing
+ // part of the script.
+
+ else if (_game.id == GID_MONKEY2 && _game.platform == Common::kPlatformMacintosh && type == rtScript && idx == 1 && size == 6718) {
+ byte *unpatchedScript = getResourceAddress(type, idx);
+
+ const byte patch[] = {
+0x48, 0x00, 0x40, 0x00, 0x00, 0x13, 0x00, // if (Local[0] == 0) {
+0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
+0x0a, 0x82, 0xff, // startScript(130,[]);
+0x80, // breakHere();
+0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
+0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
+ // }
+0x48, 0x00, 0x40, 0x3f, 0xe1, 0x1d, 0x00, // if (Local[0] == -7873) [
+0x1a, 0x32, 0x00, 0x3f, 0x01, // VAR_MAINMENU_KEY = 319;
+0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
+0x0a, 0x82, 0xff, // startScript(130,[]);
+0x80, // breakHere();
+0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
+0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
+0x1a, 0x00, 0x40, 0x00, 0x00 // Local[0] = 0;
+ // }
+ };
+
+ byte *patchedScript = new byte[6780];
+
+ memcpy(patchedScript, unpatchedScript, 2350);
+ memcpy(patchedScript + 2350, patch, sizeof(patch));
+ memcpy(patchedScript + 2350 + sizeof(patch), unpatchedScript + 2350, 6718 - 2350);
+
+ WRITE_BE_UINT32(patchedScript + 4, 6780);
+
+ Common::MemoryReadStream stream(patchedScript, 6780);
+
+ // Just to be completely safe, check that the patched script now
+ // matches the boot script from the other known Mac version.
+ // Only if it does can we replace the unpatched script.
+
+ Common::String md5 = Common::computeStreamMD5AsString(stream);
+ if (md5 == "92b1cb7902b57d02b8e7434903d8508b") {
+ byte *newResource = _res->createResource(type, idx, 6780);
+ memcpy(newResource, patchedScript, 6780);
+ } else
+ warning("Could not patch MI2 Mac boot script: Bad checksum '%s'", md5.c_str());
+
+ delete[] patchedScript;
+ }
}
Commit: d2758e913a57cbedae823f367d9507810f5b22b6
https://github.com/scummvm/scummvm/commit/d2758e913a57cbedae823f367d9507810f5b22b6
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-07-15T13:58:31+02:00
Commit Message:
SCUMM: Use the MI2 Mac specific boot param to bypass the copy protection
ScummVM already disables the copy protection by not checking that you
enter the correct values, so we may as well skip it completely.
Changed paths:
engines/scumm/scumm.cpp
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index cb6c1de234..34361c9613 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1577,6 +1577,14 @@ void ScummEngine::setupScumm(const Common::String &macResourceFile) {
_bootParam = -7873;
}
+ // This boot param does not exist in the DOS version, but skips straight
+ // to the difficulty selection screen in the Mac versions. (One of them
+ // didn't show the difficulty selection screen at all, but we patch the
+ // boot script to enable that.)
+ if (!_copyProtection && _game.id == GID_MONKEY2 && _game.platform == Common::kPlatformMacintosh && _bootParam == 0) {
+ _bootParam = -7873;
+ }
+
if (!_copyProtection && _game.id == GID_SAMNMAX && _bootParam == 0) {
_bootParam = -1;
}
Commit: 4fe38898616147a52ac5ce10fdd5418cb39b23ca
https://github.com/scummvm/scummvm/commit/4fe38898616147a52ac5ce10fdd5418cb39b23ca
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-07-15T13:58:31+02:00
Commit Message:
SCUMM: Handle failure to patch MI2 Mac boot script more gracefully
If another Mac version of MI2 is ever discovered, and its boot script
doesn't match any of the known ones, we can't know what the "skip copy
protection" boot param will do. Safer, then, to use the default boot
param. ScummVM may still skip the copy protection, but if so it will do
it the old-fashioned way.
Changed paths:
engines/scumm/resource.cpp
engines/scumm/scumm.cpp
engines/scumm/scumm.h
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 7c7397e327..5c326504a3 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -1713,22 +1713,39 @@ void ScummEngine::applyWorkaroundIfNeeded(ResType type, int idx) {
WRITE_BE_UINT32(patchedScript + 4, 6780);
- Common::MemoryReadStream stream(patchedScript, 6780);
-
// Just to be completely safe, check that the patched script now
// matches the boot script from the other known Mac version.
// Only if it does can we replace the unpatched script.
- Common::String md5 = Common::computeStreamMD5AsString(stream);
- if (md5 == "92b1cb7902b57d02b8e7434903d8508b") {
+ if (verifyMI2MacBootScript(patchedScript, 6780)) {
byte *newResource = _res->createResource(type, idx, 6780);
memcpy(newResource, patchedScript, 6780);
} else
- warning("Could not patch MI2 Mac boot script: Bad checksum '%s'", md5.c_str());
+ warning("Could not patch MI2 Mac boot script");
delete[] patchedScript;
}
}
+bool ScummEngine::verifyMI2MacBootScript() {
+ return verifyMI2MacBootScript(getResourceAddress(rtScript, 1), getResourceSize(rtScript, 1));
+}
+
+bool ScummEngine::verifyMI2MacBootScript(byte *buf, int size) {
+ if (size == 6780) {
+ Common::MemoryReadStream stream(buf, size);
+ Common::String md5 = Common::computeStreamMD5AsString(stream);
+
+ if (md5 != "92b1cb7902b57d02b8e7434903d8508b") {
+ warning("Unexpected MI2 Mac boot script checksum: %s", md5.c_str());
+ return false;
+ }
+ } else {
+ warning("Unexpected MI2 Mac boot script length: %d", size);
+ return false;
+ }
+ return true;
+}
+
} // End of namespace Scumm
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 34361c9613..c2ea724cdd 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2891,6 +2891,23 @@ void ScummEngine::restart() {
void ScummEngine::runBootscript() {
int args[NUM_SCRIPT_LOCAL];
memset(args, 0, sizeof(args));
+
+ // There are two known versions of Monkey Island 2 for the Mac. This
+ // boot param only exists in the floppy release. The version that was
+ // distributed on CD has a different boot script which doesn't show
+ // the copy protection (or difficulty selection) screen at all. We try
+ // to patch the script to put these features back, and use the boot
+ // param to bypass the copy protection screen (since ScummVM already
+ // disables the copy protection check in it).
+ //
+ // But if the script patching somehow failed, clear the boot param to
+ // avoid errors.
+
+ if (_game.id == GID_MONKEY2 && _game.platform == Common::kPlatformMacintosh && _bootParam == -7873 && !verifyMI2MacBootScript()) {
+ warning("Unknown MI2 Mac boot script. Using default boot param");
+ _bootParam = 0;
+ }
+
args[0] = _bootParam;
if (_game.id == GID_MANIAC && (_game.features & GF_DEMO) && (_game.platform != Common::kPlatformC64))
runScript(9, 0, 0, args);
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 9445a91c53..8db9b371a4 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -699,6 +699,8 @@ public:
const byte *findResourceData(uint32 tag, const byte *ptr);
const byte *findResource(uint32 tag, const byte *ptr);
void applyWorkaroundIfNeeded(ResType type, int idx);
+ bool verifyMI2MacBootScript();
+ bool verifyMI2MacBootScript(byte *buf, int size);
int getResourceDataSize(const byte *ptr) const;
void dumpResource(const char *tag, int index, const byte *ptr, int length = -1);
Commit: aedf820328bd239e83bab34d98e9e9ffe3a71928
https://github.com/scummvm/scummvm/commit/aedf820328bd239e83bab34d98e9e9ffe3a71928
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-07-15T13:58:31+02:00
Commit Message:
SCUMM: Changed tabs to spaces
I know the default tab width for ScummVM is supposed to be 4, but I
can't be bothered to change it in my editor (where it's 8) and I assume
I'm not alone in that. So I've changed the tabs here so that the hex
code and script text should line up nicely regardless of your editor
settings.
Changed paths:
engines/scumm/resource.cpp
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 5c326504a3..b2cc02d266 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -1687,22 +1687,22 @@ void ScummEngine::applyWorkaroundIfNeeded(ResType type, int idx) {
byte *unpatchedScript = getResourceAddress(type, idx);
const byte patch[] = {
-0x48, 0x00, 0x40, 0x00, 0x00, 0x13, 0x00, // if (Local[0] == 0) {
-0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
-0x0a, 0x82, 0xff, // startScript(130,[]);
-0x80, // breakHere();
-0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
-0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
- // }
-0x48, 0x00, 0x40, 0x3f, 0xe1, 0x1d, 0x00, // if (Local[0] == -7873) [
-0x1a, 0x32, 0x00, 0x3f, 0x01, // VAR_MAINMENU_KEY = 319;
-0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
-0x0a, 0x82, 0xff, // startScript(130,[]);
-0x80, // breakHere();
-0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
-0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
-0x1a, 0x00, 0x40, 0x00, 0x00 // Local[0] = 0;
- // }
+0x48, 0x00, 0x40, 0x00, 0x00, 0x13, 0x00, // if (Local[0] == 0) {
+0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
+0x0a, 0x82, 0xff, // startScript(130,[]);
+0x80, // breakHere();
+0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
+0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
+ // }
+0x48, 0x00, 0x40, 0x3f, 0xe1, 0x1d, 0x00, // if (Local[0] == -7873) [
+0x1a, 0x32, 0x00, 0x3f, 0x01, // VAR_MAINMENU_KEY = 319;
+0x33, 0x03, 0x00, 0x00, 0xc8, 0x00, // SetScreen(0,200);
+0x0a, 0x82, 0xff, // startScript(130,[]);
+0x80, // breakHere();
+0x68, 0x00, 0x00, 0x82, // VAR_RESULT = isScriptRunning(130);
+0x28, 0x00, 0x00, 0xf6, 0xff, // unless (!VAR_RESULT) goto 0955;
+0x1a, 0x00, 0x40, 0x00, 0x00 // Local[0] = 0;
+ // }
};
byte *patchedScript = new byte[6780];
More information about the Scummvm-git-logs
mailing list