[Scummvm-git-logs] scummvm master -> f1ca9ccc6426a46a7da47bf4a36301bd849bf978

csnover csnover at users.noreply.github.com
Tue Jan 10 02:43:54 CET 2017


This automated email contains information about 19 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
97a47852c1 SCI32: Fix kSetShowStyle signature for SCI3
3e2f4a66f6 SCI32: Remove SCI3 workarounds hack
8987d9a889 SCI32: Enable playback of stereo audio
01e6d07360 SCI32: Split kCelInfo into subops
bd9bc7ce87 SCI32: Clean up comment on kSetHotRectangles
7567940ba1 SCI32: Clean up SCI3-only opcodes
8cce4f1b8c SCI32: Ignore attempts to free null array reg_ts
2ce1807359 SCI32: Generalise uninitialised read workarounds for RAMA
70cfdb6a1f SCI32: Ignore .OLD extension when searching Audio36 patches
b818e54027 SCI32: Fix crashes and bad cel positioning in GK2 demo
c8b05f03ad SCI32: Fix invalid bitmap deletion in AVIPlayer
c01b5fe619 SCI32: Mark non-interactive Lighthouse demo as non-interactive
4a930d0368 SCI32: Fix GUIOs for all SCI2-2.1late games
e729a31edc SCI32: Fix SQ6 demo crash
c48c24d1d3 SCI32: Fix Torin demo crash
126378fa26 SCI32: Fix bad coordinates in PQ:SWAT demo
b895b4b075 SCI32: Disable compression for Phantasmagoria save files
e18e6399ac SCI32: Fix bad rendering of Sierra logo in MGDX
f1ca9ccc64 SCI32: Fix kSetLanguage


Commit: 97a47852c1cb0747460fdde15e50419addee84a7
    https://github.com/scummvm/scummvm/commit/97a47852c1cb0747460fdde15e50419addee84a7
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix kSetShowStyle signature for SCI3

Changed paths:
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kgraphics32.cpp


diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 2db3c59..1241a97 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -868,7 +868,8 @@ static SciKernelMapEntry s_kernelMap[] = {
 	// our own memory manager and garbage collector, thus we simply call FlushResources, which in turn invokes
 	// our garbage collector (i.e. the SCI0-SCI1.1 semantics).
 	{ "Purge", kFlushResources,    SIG_EVERYWHERE,           "i",                     NULL,            NULL },
-	{ MAP_CALL(SetShowStyle),      SIG_EVERYWHERE,           "ioiiiii([ri])(i)",      NULL,            NULL },
+	{ MAP_CALL(SetShowStyle),      SIG_THRU_SCI21MID, SIGFOR_ALL, "ioiiiii([ri])(i)", NULL,            NULL },
+	{ MAP_CALL(SetShowStyle),      SIG_SINCE_SCI21LATE, SIGFOR_ALL, "ioiiiiii(r)(i)", NULL,            NULL },
 	{ MAP_CALL(String),            SIG_EVERYWHERE,           "(.*)",                  kString_subops,  NULL },
 	{ MAP_CALL(UpdatePlane),       SIG_EVERYWHERE,           "o",                     NULL,            NULL },
 	{ MAP_CALL(UpdateScreenItem),  SIG_EVERYWHERE,           "o",                     NULL,            NULL },
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index a3f7e4f..f710df1 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -389,13 +389,13 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv) {
 		pFadeArray = NULL_REG;
 		divisions = argc > 7 ? argv[7].toSint16() : -1;
 	}
-	// SCI 2.1mid–2.1late
-	else if (getSciVersion() < SCI_VERSION_3) {
+	// SCI 2.1mid
+	else if (getSciVersion() < SCI_VERSION_2_1_LATE) {
 		blackScreen = 0;
 		pFadeArray = argc > 7 ? argv[7] : NULL_REG;
 		divisions = argc > 8 ? argv[8].toSint16() : -1;
 	}
-	// SCI 3
+	// SCI 2.1late-3
 	else {
 		blackScreen = argv[7].toSint16();
 		pFadeArray = argc > 8 ? argv[8] : NULL_REG;
@@ -406,14 +406,6 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv) {
 		error("Illegal show style %d for plane %04x:%04x", type, PRINT_REG(planeObj));
 	}
 
-// TODO: Reuse later for SCI2 and SCI3 implementation and then discard
-//	warning("kSetShowStyle: effect %d, plane: %04x:%04x (%s), sec: %d, "
-//			"dir: %d, prio: %d, animate: %d, ref frame: %d, black screen: %d, "
-//			"pFadeArray: %04x:%04x (%s), divisions: %d",
-//			type, PRINT_REG(planeObj), s->_segMan->getObjectName(planeObj), seconds,
-//			back, priority, animate, refFrame, blackScreen,
-//			PRINT_REG(pFadeArray), s->_segMan->getObjectName(pFadeArray), divisions);
-
 	// NOTE: The order of planeObj and showStyle are reversed
 	// because this is how SCI3 called the corresponding method
 	// on the KernelMgr


Commit: 3e2f4a66f60ecebd2ee2cd42a303b881688bd626
    https://github.com/scummvm/scummvm/commit/3e2f4a66f60ecebd2ee2cd42a303b881688bd626
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Remove SCI3 workarounds hack

Changed paths:
    engines/sci/engine/workarounds.cpp


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index f3e22b7..971230d 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -842,15 +842,6 @@ const SciWorkaroundEntry kScrollWindowAdd_workarounds[] = {
 };
 
 SciWorkaroundSolution trackOriginAndFindWorkaround(int index, const SciWorkaroundEntry *workaroundList, SciCallOrigin *trackOrigin) {
-	// HACK for SCI3: Temporarily ignore this
-	if (getSciVersion() == SCI_VERSION_3) {
-		warning("SCI3 HACK: trackOriginAndFindWorkaround() called, ignoring");
-		SciWorkaroundSolution sci3IgnoreForNow;
-		sci3IgnoreForNow.type = WORKAROUND_FAKE;
-		sci3IgnoreForNow.value = 0;
-		return sci3IgnoreForNow;
-	}
-
 	const EngineState *state = g_sci->getEngineState();
 	ExecStack *lastCall = state->xs;
 	const SciGameId gameId = g_sci->getGameId();


Commit: 8987d9a889fb908b038e5615baab5403adf3073e
    https://github.com/scummvm/scummvm/commit/8987d9a889fb908b038e5615baab5403adf3073e
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Enable playback of stereo audio

Changed paths:
    engines/sci/sound/audio32.cpp
    engines/sci/sound/decoders/sol.cpp
    engines/sci/sound/decoders/sol.h
    engines/sci/video/robot_decoder.cpp


diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index d5a7ae1..ca2402c 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -159,9 +159,7 @@ int Audio32::writeAudioInternal(Audio::AudioStream *const sourceStream, Audio::R
 	// mono, in which case we need to request half
 	// as many samples from the mono stream and let
 	// the converter double them for stereo output
-	if (!sourceStream->isStereo()) {
-		samplesToRead >>= 1;
-	}
+	samplesToRead >>= 1;
 
 	int samplesWritten = 0;
 
@@ -182,12 +180,10 @@ int Audio32::writeAudioInternal(Audio::AudioStream *const sourceStream, Audio::R
 
 		samplesToRead -= loopSamplesWritten;
 		samplesWritten += loopSamplesWritten;
-		targetBuffer += loopSamplesWritten << 1;
+		targetBuffer += loopSamplesWritten << (sourceStream->isStereo() ? 0 : 1);
 	} while (loop && samplesToRead > 0);
 
-	if (!sourceStream->isStereo()) {
-		samplesWritten <<= 1;
-	}
+	samplesWritten <<= 1;
 
 	return samplesWritten;
 }
diff --git a/engines/sci/sound/decoders/sol.cpp b/engines/sci/sound/decoders/sol.cpp
index ee1ba35..2dbe98c 100644
--- a/engines/sci/sound/decoders/sol.cpp
+++ b/engines/sci/sound/decoders/sol.cpp
@@ -50,32 +50,42 @@ static const uint16 tableDPCM16[128] = {
 static const byte tableDPCM8[8] = { 0, 1, 2, 3, 6, 10, 15, 21 };
 
 /**
+ * Decompresses one channel of 16-bit DPCM compressed audio.
+ */
+static void deDPCM16Channel(int16 *out, int16 &sample, uint8 delta) {
+	if (delta & 0x80) {
+		sample -= tableDPCM16[delta & 0x7f];
+	} else {
+		sample += tableDPCM16[delta];
+	}
+	sample = CLIP<int16>(sample, -32768, 32767);
+	*out = TO_LE_16(sample);
+}
+
+/**
  * Decompresses 16-bit DPCM compressed audio. Each byte read
  * outputs one sample into the decompression buffer.
  */
-static void deDPCM16(int16 *out, Common::ReadStream &audioStream, const uint32 numBytes, int16 &sample) {
+static void deDPCM16Mono(int16 *out, Common::ReadStream &audioStream, const uint32 numBytes, int16 &sample) {
 	for (uint32 i = 0; i < numBytes; ++i) {
 		const uint8 delta = audioStream.readByte();
-		if (delta & 0x80) {
-			sample -= tableDPCM16[delta & 0x7f];
-		} else {
-			sample += tableDPCM16[delta];
-		}
-		sample = CLIP<int16>(sample, -32768, 32767);
-		*out++ = TO_LE_16(sample);
+		deDPCM16Channel(out++, sample, delta);
 	}
 }
 
-void deDPCM16(int16 *out, const byte *in, const uint32 numBytes, int16 &sample) {
+// Used by Robot
+void deDPCM16Mono(int16 *out, const byte *in, const uint32 numBytes, int16 &sample) {
 	for (uint32 i = 0; i < numBytes; ++i) {
 		const uint8 delta = *in++;
-		if (delta & 0x80) {
-			sample -= tableDPCM16[delta & 0x7f];
-		} else {
-			sample += tableDPCM16[delta];
-		}
-		sample = CLIP<int16>(sample, -32768, 32767);
-		*out++ = TO_LE_16(sample);
+		deDPCM16Channel(out++, sample, delta);
+	}
+}
+
+static void deDPCM16Stereo(int16 *out, Common::ReadStream &audioStream, const uint32 numBytes, int16 &sampleL, int16 &sampleR) {
+	assert((numBytes % 2) == 0);
+	for (uint32 i = 0; i < numBytes / 2; ++i) {
+		deDPCM16Channel(out++, sampleL, audioStream.readByte());
+		deDPCM16Channel(out++, sampleR, audioStream.readByte());
 	}
 }
 
@@ -98,7 +108,7 @@ static void deDPCM8Nibble(int16 *out, uint8 &sample, uint8 delta) {
  * Decompresses 8-bit DPCM compressed audio. Each byte read
  * outputs two samples into the decompression buffer.
  */
-static void deDPCM8(int16 *out, Common::ReadStream &audioStream, uint32 numBytes, uint8 &sample) {
+static void deDPCM8Mono(int16 *out, Common::ReadStream &audioStream, uint32 numBytes, uint8 &sample) {
 	for (uint32 i = 0; i < numBytes; ++i) {
 		const uint8 delta = audioStream.readByte();
 		deDPCM8Nibble(out++, sample, delta >> 4);
@@ -106,6 +116,14 @@ static void deDPCM8(int16 *out, Common::ReadStream &audioStream, uint32 numBytes
 	}
 }
 
+static void deDPCM8Stereo(int16 *out, Common::ReadStream &audioStream, uint32 numBytes, uint8 &sampleL, uint8 &sampleR) {
+	for (uint32 i = 0; i < numBytes; ++i) {
+		const uint8 delta = audioStream.readByte();
+		deDPCM8Nibble(out++, sampleL, delta >> 4);
+		deDPCM8Nibble(out++, sampleR, delta & 0xf);
+	}
+}
+
 # pragma mark -
 
 template<bool STEREO, bool S16BIT>
@@ -120,9 +138,9 @@ SOLStream<STEREO, S16BIT>::SOLStream(Common::SeekableReadStream *stream, const D
 		// carried values for each channel separately. See
 		// 60900.aud from Lighthouse for an example stereo file
 		if (S16BIT) {
-			_dpcmCarry16 = 0;
+			_dpcmCarry16.l = _dpcmCarry16.r = 0;
 		} else {
-			_dpcmCarry8 = 0x80;
+			_dpcmCarry8.l = _dpcmCarry8.r = 0x80;
 		}
 
 		const uint8 compressionRatio = 2;
@@ -143,9 +161,9 @@ bool SOLStream<STEREO, S16BIT>::seek(const Audio::Timestamp &where) {
 	}
 
 	if (S16BIT) {
-		_dpcmCarry16 = 0;
+		_dpcmCarry16.l = _dpcmCarry16.r = 0;
 	} else {
-		_dpcmCarry8 = 0x80;
+		_dpcmCarry8.l = _dpcmCarry8.r = 0x80;
 	}
 
 	return _stream->seek(_dataOffset, SEEK_SET);
@@ -171,9 +189,17 @@ int SOLStream<STEREO, S16BIT>::readBuffer(int16 *buffer, const int numSamples) {
 	}
 
 	if (S16BIT) {
-		deDPCM16(buffer, *_stream, bytesToRead, _dpcmCarry16);
+		if (STEREO) {
+			deDPCM16Stereo(buffer, *_stream, bytesToRead, _dpcmCarry16.l, _dpcmCarry16.r);
+		} else {
+			deDPCM16Mono(buffer, *_stream, bytesToRead, _dpcmCarry16.l);
+		}
 	} else {
-		deDPCM8(buffer, *_stream, bytesToRead, _dpcmCarry8);
+		if (STEREO) {
+			deDPCM8Stereo(buffer, *_stream, bytesToRead, _dpcmCarry8.l, _dpcmCarry8.r);
+		} else {
+			deDPCM8Mono(buffer, *_stream, bytesToRead, _dpcmCarry8.l);
+		}
 	}
 
 	const int samplesRead = bytesToRead * samplesPerByte;
diff --git a/engines/sci/sound/decoders/sol.h b/engines/sci/sound/decoders/sol.h
index 1046d0b..31914c0 100644
--- a/engines/sci/sound/decoders/sol.h
+++ b/engines/sci/sound/decoders/sol.h
@@ -61,8 +61,8 @@ private:
 	 * The last sample from the previous DPCM decode.
 	 */
 	union {
-		int16 _dpcmCarry16;
-		uint8 _dpcmCarry8;
+		struct { int16 l; int16 r; } _dpcmCarry16;
+		struct { uint8 l; uint8 r; } _dpcmCarry8;
 	};
 
 	/**
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp
index 446b986..296fdf8 100644
--- a/engines/sci/video/robot_decoder.cpp
+++ b/engines/sci/video/robot_decoder.cpp
@@ -43,7 +43,7 @@ namespace Sci {
 
 #pragma mark RobotAudioStream
 
-extern void deDPCM16(int16 *out, const byte *in, const uint32 numBytes, int16 &sample);
+extern void deDPCM16Mono(int16 *out, const byte *in, const uint32 numBytes, int16 &sample);
 
 RobotAudioStream::RobotAudioStream(const int32 bufferSize) :
 	_loopBuffer((byte *)malloc(bufferSize)),
@@ -181,7 +181,7 @@ void RobotAudioStream::fillRobotBuffer(const RobotAudioPacket &packet, const int
 		}
 
 		int16 carry = 0;
-		deDPCM16((int16 *)_decompressionBuffer, packet.data, packet.dataSize, carry);
+		deDPCM16Mono((int16 *)_decompressionBuffer, packet.data, packet.dataSize, carry);
 		_decompressionBufferPosition = packet.position;
 	}
 


Commit: 01e6d073604a3973d993ccefc162c437d2937660
    https://github.com/scummvm/scummvm/commit/01e6d073604a3973d993ccefc162c437d2937660
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Split kCelInfo into subops

Different subops have different call signature requirements.

Changed paths:
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kgraphics32.cpp


diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 5fb1ab6..335fec0 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -637,7 +637,12 @@ reg_t kMessageBox(EngineState *s, int argc, reg_t *argv);
 reg_t kGetConfig(EngineState *s, int argc, reg_t *argv);
 reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv);
 reg_t kPrintDebug(EngineState *s, int argc, reg_t *argv);
+
 reg_t kCelInfo(EngineState *s, int argc, reg_t *argv);
+reg_t kCelInfoGetOriginX(EngineState *s, int argc, reg_t *argv);
+reg_t kCelInfoGetOriginY(EngineState *s, int argc, reg_t *argv);
+reg_t kCelInfoGetPixel(EngineState *s, int argc, reg_t *argv);
+
 reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv);
 reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv);
 reg_t kSetFontHeight(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 1241a97..278d4d6 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -560,6 +560,16 @@ static const SciKernelMapSubEntry kString_subops[] = {
 };
 
 //    version,         subId, function-mapping,                    signature,              workarounds
+static const SciKernelMapSubEntry kCelInfo_subops[] = {
+	{ SIG_SINCE_SCI21MID,  0, MAP_CALL(CelInfoGetOriginX),         "iii",                  NULL },
+	{ SIG_SINCE_SCI21MID,  1, MAP_CALL(CelInfoGetOriginY),         "iii",                  NULL },
+	{ SIG_SINCE_SCI21MID,  2, MAP_EMPTY(CelInfo),                  "iii",                  NULL },
+	{ SIG_SINCE_SCI21MID,  3, MAP_EMPTY(CelInfo),                  "iii",                  NULL },
+	{ SIG_SINCE_SCI21MID,  4, MAP_CALL(CelInfoGetPixel),           "iiiii",                NULL },
+	SCI_SUBOPENTRY_TERMINATOR
+};
+
+//    version,         subId, function-mapping,                    signature,              workarounds
 static const SciKernelMapSubEntry kScrollWindow_subops[] = {
 	{ SIG_SCI32,           0, MAP_CALL(ScrollWindowCreate),        "oi",                   NULL },
 	{ SIG_SCI32,           1, MAP_CALL(ScrollWindowAdd),           "iriii(i)",             kScrollWindowAdd_workarounds },
@@ -933,7 +943,7 @@ static SciKernelMapEntry s_kernelMap[] = {
 	{ MAP_CALL(WinHelp),           SIG_EVERYWHERE,           "(.*)",                  NULL,            NULL },
 	{ MAP_CALL(GetConfig),         SIG_EVERYWHERE,           "ro",                    NULL,            NULL },
 	{ MAP_CALL(GetSierraProfileInt), SIG_EVERYWHERE,         "rri",                   NULL,            NULL },
-	{ MAP_CALL(CelInfo),           SIG_SINCE_SCI21MID, SIGFOR_ALL, "iiiiii",          NULL,            NULL },
+	{ MAP_CALL(CelInfo),           SIG_SINCE_SCI21MID, SIGFOR_ALL, "(.*)",            kCelInfo_subops, NULL },
 	{ MAP_CALL(SetLanguage),       SIG_SINCE_SCI21MID, SIGFOR_ALL, "r",               NULL,            NULL },
 	{ MAP_CALL(ScrollWindow),      SIG_EVERYWHERE,           "i(.*)",                 kScrollWindow_subops, NULL },
 	{ MAP_CALL(SetFontRes),        SIG_SCI21EARLY, SIGFOR_ALL, "ii",                  NULL,            NULL },
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index f710df1..f6aeeb7 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -430,31 +430,28 @@ reg_t kCelWide32(EngineState *s, int argc, reg_t *argv) {
 	return make_reg(0, mulru(celObj._width, Ratio(g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth, celObj._xResolution)));
 }
 
+// Used by Shivers 1, room 23601 to determine what blocks on the red door
+// puzzle board are occupied by pieces already, and by Phantasmagoria 2 when
+// saving the game from the in-game UI
 reg_t kCelInfo(EngineState *s, int argc, reg_t *argv) {
-	// Used by Shivers 1, room 23601 to determine what blocks on the red door puzzle board
-	// are occupied by pieces already
-
-	CelObjView view(argv[1].toUint16(), argv[2].toSint16(), argv[3].toSint16());
+	if (!s)
+		return make_reg(0, getSciVersion());
+	error("not supposed to call this");
+}
 
-	int16 result = 0;
+reg_t kCelInfoGetOriginX(EngineState *s, int argc, reg_t *argv) {
+	CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+	return make_reg(0, view._origin.x);
+}
 
-	switch (argv[0].toUint16()) {
-	case 0:
-		result = view._origin.x;
-		break;
-	case 1:
-		result = view._origin.y;
-		break;
-	case 2:
-	case 3:
-		// null operation
-		break;
-	case 4:
-		result = view.readPixel(argv[4].toSint16(), argv[5].toSint16(), view._mirrorX);
-		break;
-	}
+reg_t kCelInfoGetOriginY(EngineState *s, int argc, reg_t *argv) {
+	CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+	return make_reg(0, view._origin.y);
+}
 
-	return make_reg(0, result);
+reg_t kCelInfoGetPixel(EngineState *s, int argc, reg_t *argv) {
+	CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+	return make_reg(0, view.readPixel(argv[4].toSint16(), argv[5].toSint16(), view._mirrorX));
 }
 
 reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv) {


Commit: bd9bc7ce878dd2ccdce31ade062e9e91d5eb16a9
    https://github.com/scummvm/scummvm/commit/bd9bc7ce878dd2ccdce31ade062e9e91d5eb16a9
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Clean up comment on kSetHotRectangles

Since this feature is now implemented, it is not necessary to
describe its intended functionality here.

Changed paths:
    engines/sci/engine/kernel_tables.h


diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 278d4d6..e05348a 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -997,11 +997,7 @@ static SciKernelMapEntry s_kernelMap[] = {
 	{ MAP_DUMMY(GetSaveCDisc),      SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 	{ MAP_DUMMY(TestPoly),          SIG_EVERYWHERE,           "(.*)",                 NULL,            NULL },
 
-	// SCI2.1 unmapped functions - TODO!
-
-	// SetHotRectangles - used by Phantasmagoria 1, script 64981 (used in the chase scene)
-	//     <lskovlun> The idea, if I understand correctly, is that the engine generates events
-	//     of a special HotRect type continuously when the mouse is on that rectangle
+	// Used by Phantasmagoria 1, script 64981 (used in the chase scene)
 	{ MAP_CALL(SetHotRectangles), SIG_SINCE_SCI21MID, SIGFOR_ALL, "i(r)",             NULL,            NULL },
 
 	// Used by SQ6 to scroll through the inventory via the up/down buttons


Commit: 7567940ba14ef7d2277dea73161383c8d65e9ee6
    https://github.com/scummvm/scummvm/commit/7567940ba14ef7d2277dea73161383c8d65e9ee6
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Clean up SCI3-only opcodes

SCI3 includes four new opcodes:

* op_info[0x26][0] puts -info- flag in accumulator
* op_infoSP[0x26][1] pushes -info- flag to stack
* op_superP[0x27][0] puts -super- reference in accumulator
* op_superPSP[0x27][1] pushes -super- reference to stack

The implementation of these opcodes was correct already, but the
opcode names given were a bit misleading (the value is not always
stored to accumulator), and magic numbers were used for these
opcodes in places.

A review of the opcode table in Phant2 indicates that there are
no other new opcodes for SCI3.

Changed paths:
    engines/sci/engine/kernel.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h


diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 85cad99..1845eca 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -989,10 +989,8 @@ void script_adjust_opcode_formats() {
 	}
 
 	if (getSciVersion() >= SCI_VERSION_3) {
-		// TODO: There are also opcodes in
-		// here to get the superclass, and possibly the species too.
-		g_sci->_opcode_formats[0x4d/2][0] = Script_None;
-		g_sci->_opcode_formats[0x4e/2][0] = Script_None;
+		g_sci->_opcode_formats[op_info][0] = Script_None;
+		g_sci->_opcode_formats[op_superP][0] = Script_None;
 	}
 #endif
 }
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 8e407a6..74a2841 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -1043,7 +1043,7 @@ void run_vm(EngineState *s) {
 
 			break;
 
-		case op_infoToa: // (38)
+		case op_info: // (38)
 			if (getSciVersion() < SCI_VERSION_3)
 				error("Dummy opcode 0x%x called", opcode);	// should never happen
 
@@ -1053,7 +1053,7 @@ void run_vm(EngineState *s) {
 				PUSH32(obj->getInfoSelector());
 			break;
 
-		case op_superToa: // (39)
+		case op_superP: // (39)
 			if (getSciVersion() < SCI_VERSION_3)
 				error("Dummy opcode 0x%x called", opcode);	// should never happen
 
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 13f60fd..18549e3 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -198,8 +198,8 @@ enum SciOpcodes {
 	op_calle    = 0x23,	// 035
 	op_ret      = 0x24,	// 036
 	op_send     = 0x25,	// 037
-	op_infoToa  = 0x26,	// 038
-	op_superToa = 0x27,	// 039
+	op_info     = 0x26,	// 038
+	op_superP   = 0x27,	// 039
 	op_class    = 0x28,	// 040
 	// dummy      0x29,	// 041
 	op_self     = 0x2a,	// 042


Commit: 8cce4f1b8c175a52a035e01318a797d4797ecd85
    https://github.com/scummvm/scummvm/commit/8cce4f1b8c175a52a035e01318a797d4797ecd85
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Ignore attempts to free null array reg_ts

Changed paths:
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kstring.cpp
    engines/sci/engine/seg_manager.cpp


diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index e05348a..c611af4 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -511,7 +511,7 @@ static const SciKernelMapSubEntry kArray_subops[] = {
 	{ SIG_SCI32,           1, MAP_CALL(ArrayGetSize),              "r",                    NULL },
 	{ SIG_SCI32,           2, MAP_CALL(ArrayGetElement),           "ri",                   NULL },
 	{ SIG_SCI32,           3, MAP_CALL(ArraySetElements),          "ri(.*)",               kArraySetElements_workarounds },
-	{ SIG_SCI32,           4, MAP_CALL(ArrayFree),                 "r",                    NULL },
+	{ SIG_SCI32,           4, MAP_CALL(ArrayFree),                 "[0r]",                 NULL },
 	{ SIG_SCI32,           5, MAP_CALL(ArrayFill),                 "riii",                 NULL },
 	{ SIG_SCI32,           6, MAP_CALL(ArrayCopy),                 "ririi",                NULL },
 	// there is no subop 7
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index ab1f021..ae91ef0 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -663,9 +663,7 @@ reg_t kStringGetChar(EngineState *s, int argc, reg_t *argv) {
 }
 
 reg_t kStringFree(EngineState *s, int argc, reg_t *argv) {
-	if (!argv[0].isNull()) {
-		s->_segMan->freeArray(argv[0]);
-	}
+	s->_segMan->freeArray(argv[0]);
 	return s->r_acc;
 }
 
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 159d317..23d1942 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -892,6 +892,11 @@ SciArray *SegManager::lookupArray(reg_t addr) {
 }
 
 void SegManager::freeArray(reg_t addr) {
+	// SSCI memory manager ignores attempts to free null handles
+	if (addr.isNull()) {
+		return;
+	}
+
 	if (_heap[addr.getSegment()]->getType() != SEG_TYPE_ARRAY)
 		error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr));
 


Commit: 2ce180735916524de97593ba7c7c4657ad89d8b6
    https://github.com/scummvm/scummvm/commit/2ce180735916524de97593ba7c7c4657ad89d8b6
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Generalise uninitialised read workarounds for RAMA

Changed paths:
    engines/sci/engine/workarounds.cpp


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index 971230d..9051ab7 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -377,9 +377,8 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {
 	{ GID_QFG4,           -1, 64917, -1,              "Plane", "setBitmap",                       NULL,     3, { WORKAROUND_FAKE,   0 } }, // floppy version, happens sometimes in fight scenes
 	{ GID_QFG4,          520, 64950,  0,             "fLake2", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // CD version, at the lake, when meeting the Rusalka and attempting to leave
 	{ GID_QFG4,          800, 64950,  0,               "View", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // CD version, in the room with the spider pillar, when climbing on the pillar
-	{ GID_RAMA,           12, 64950, -1,   "InterfaceFeature", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // Demo, right when it starts
-	{ GID_RAMA,           12, 64950, -1,      "hiliteOptText", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // Demo, right when it starts
-	{ GID_RAMA,           12, 64950, -1,               "View", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // Demo, right when it starts
+	{ GID_RAMA,           -1, 64950, -1,   "InterfaceFeature", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // When clicking on the main game interface
+	{ GID_RAMA,           -1, 64950, -1,               "View", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // When clicking on main menu buttons
 	{ GID_SHIVERS,        -1,   952,  0,       "SoundManager", "stop",                            NULL,     2, { WORKAROUND_FAKE,   0 } }, // Just after Sierra logo
 	{ GID_SHIVERS,        -1, 64950,  0,            "Feature", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // When clicking on the locked door at the beginning
 	{ GID_SHIVERS,        -1, 64950,  0,               "View", "handleEvent",                     NULL,     0, { WORKAROUND_FAKE,   0 } }, // When clicking on the gargoyle eye at the beginning


Commit: 70cfdb6a1f79fa25a699e42bf27e6e3fdcb8521d
    https://github.com/scummvm/scummvm/commit/70cfdb6a1f79fa25a699e42bf27e6e3fdcb8521d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Ignore .OLD extension when searching Audio36 patches

KQ7 2.00b includes a SIERRINF.OLD file which should not be matched.

Changed paths:
    engines/sci/resource.cpp


diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 364ea2a..77c3d4e 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1507,7 +1507,7 @@ void ResourceManager::readResourcePatchesBase36() {
 
 			// The S/T prefixes often conflict with non-patch files and generate
 			// spurious warnings about invalid patches
-			if (name.hasSuffix(".DLL") || name.hasSuffix(".EXE") || name.hasSuffix(".TXT")) {
+			if (name.hasSuffix(".DLL") || name.hasSuffix(".EXE") || name.hasSuffix(".TXT") || name.hasSuffix(".OLD")) {
 				continue;
 			}
 


Commit: b818e54027bf7730893e4199e02684e2a02cfb99
    https://github.com/scummvm/scummvm/commit/b818e54027bf7730893e4199e02684e2a02cfb99
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix crashes and bad cel positioning in GK2 demo

Changed paths:
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/sound/music.cpp


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index 9051ab7..e574b96 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -553,6 +553,7 @@ const SciWorkaroundEntry kDoSoundPlay_workarounds[] = {
 	{ GID_PQ4,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // always passes an extra null argument
 	{ GID_KQ7,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // always passes an extra null argument
 	{ GID_GK1,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Mac version always passes an extra null argument
+	{ GID_GK2,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Demo passes an extra null argument when clicking on buttons
 	SCI_WORKAROUNDENTRY_TERMINATOR
 };
 
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index fe43c75..57512f1 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -85,7 +85,6 @@ GfxFrameout::GfxFrameout(SegManager *segMan, GfxPalette32 *palette, GfxTransitio
 
 	switch (g_sci->getGameId()) {
 	case GID_HOYLE5:
-	case GID_GK2:
 	case GID_LIGHTHOUSE:
 	case GID_LSL7:
 	case GID_PHANTASMAGORIA2:
@@ -95,6 +94,12 @@ GfxFrameout::GfxFrameout(SegManager *segMan, GfxPalette32 *palette, GfxTransitio
 		_currentBuffer.scriptWidth = 640;
 		_currentBuffer.scriptHeight = 480;
 		break;
+	case GID_GK2:
+		if (!g_sci->isDemo()) {
+			_currentBuffer.scriptWidth = 640;
+			_currentBuffer.scriptHeight = 480;
+		}
+		break;
 	default:
 		// default script width for other games is 320x200
 		break;
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 487d30e..488bd03 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -127,7 +127,8 @@ void SciMusic::init() {
 		_pMidiDrv->setTimerCallback(this, &miditimerCallback);
 		_dwTempo = _pMidiDrv->getBaseTempo();
 	} else {
-		if (g_sci->getGameId() == GID_FUNSEEKER) {
+		if (g_sci->getGameId() == GID_FUNSEEKER ||
+			(g_sci->getGameId() == GID_GK2 && g_sci->isDemo())) {
 			// HACK: The Fun Seeker's Guide demo doesn't have patch 3 and the version
 			// of the Adlib driver (adl.drv) that it includes is unsupported. That demo
 			// doesn't have any sound anyway, so this shouldn't be fatal.


Commit: c8b05f03ad31176ce8b6429c5d069f6800f29001
    https://github.com/scummvm/scummvm/commit/c8b05f03ad31176ce8b6429c5d069f6800f29001
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix invalid bitmap deletion in AVIPlayer

Changed paths:
    engines/sci/graphics/video32.cpp


diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp
index 4af1e76..f4eb2c2 100644
--- a/engines/sci/graphics/video32.cpp
+++ b/engines/sci/graphics/video32.cpp
@@ -140,6 +140,7 @@ AVIPlayer::AVIPlayer(SegManager *segMan, EventManager *eventMan) :
 	_scaleBuffer(nullptr),
 	_plane(nullptr),
 	_screenItem(nullptr),
+	_bitmap(NULL_REG),
 	_status(kAVINotOpen) {}
 
 AVIPlayer::~AVIPlayer() {
@@ -327,8 +328,10 @@ AVIPlayer::IOStatus AVIPlayer::close() {
 
 	_decoder->close();
 	_status = kAVINotOpen;
-	_segMan->freeBitmap(_bitmap);
-	_bitmap = NULL_REG;
+	if (_bitmap != NULL_REG) {
+		_segMan->freeBitmap(_bitmap);
+		_bitmap = NULL_REG;
+	}
 	g_sci->_gfxFrameout->deletePlane(*_plane);
 	_plane = nullptr;
 	_screenItem = nullptr;


Commit: c01b5fe619d8d2fc754e8aa790df1f9f999740af
    https://github.com/scummvm/scummvm/commit/c01b5fe619d8d2fc754e8aa790df1f9f999740af
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Mark non-interactive Lighthouse demo as non-interactive

Changed paths:
    engines/sci/detection_tables.h


diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 98dab7b..7392004 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -2684,7 +2684,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 	// Lighthouse - English Windows Demo (from jvprat)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.00"
-	{"lighthouse", "Demo", {
+	{"lighthouse", "Non-interactive Demo", {
 		{"resource.map", 0, "543124606352bfa5e07696ddf2a669be", 64},
 		{"resource.000", 0, "5d7714416b612463d750fb9c5690c859", 28952},
 		AD_LISTEND},


Commit: 4a930d0368496764a52e0d37749f674404776ce7
    https://github.com/scummvm/scummvm/commit/4a930d0368496764a52e0d37749f674404776ce7
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix GUIOs for all SCI2-2.1late games

Changed paths:
    engines/sci/detection_tables.h


diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h
index 7392004..90b9412 100644
--- a/engines/sci/detection_tables.h
+++ b/engines/sci/detection_tables.h
@@ -183,7 +183,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.map", 0, "9dd015e79cac4f91e7de805448f39775", 1912},
 		{"resource.000", 0, "e4efcd042f86679dd4e1834bb3a38edb", 3770943},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO3(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO7(GUIO_NOSUBTITLES, GUIO_NOMUSIC, GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMIDI, GUIO_NOLAUNCHLOAD, GUIO_NOASPECT)	},
 #endif
 
 	// Christmas Card 1988 - English DOS
@@ -722,14 +722,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		Common::EN_ANY, Common::kPlatformDOS, 0, GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
 
 #ifdef ENABLE_SCI32
-#define GUIO_GK1_FLOPPY GUIO4(GUIO_NOSPEECH, \
-                              GAMEOPTION_PREFER_DIGITAL_SFX, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD, \
-                              GAMEOPTION_FB01_MIDI)
-#define GUIO_GK1_CD     GUIO4(GAMEOPTION_PREFER_DIGITAL_SFX, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD, \
-                              GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \
-                              GAMEOPTION_FB01_MIDI)
+#define GUIO_GK1_FLOPPY GUIO2(GUIO_NOSPEECH, \
+                              GAMEOPTION_ORIGINAL_SAVELOAD)
+#define GUIO_GK1_CD     GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, \
+                              GAMEOPTION_HIGH_RESOLUTION_GRAPHICS)
 #define GUIO_GK1_MAC    GUIO_GK1_FLOPPY
 
 	// Gabriel Knight - English DOS Floppy
@@ -840,12 +836,21 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK | ADGF_UNSTABLE, GUIO_GK1_MAC },
 
-#define GUIO_GK2_DEMO GUIO3(GUIO_NOSPEECH, \
+#undef GUIO_GK1_FLOPPY
+#undef GUIO_GK1_CD
+#undef GUIO_GK1_MAC
+
+#define GUIO_GK2_DEMO GUIO6(GUIO_NOSUBTITLES, \
+                            GUIO_NOMUSIC, \
+                            GUIO_NOSPEECH, \
+                            GUIO_NOMIDI, \
+                            GUIO_NOLAUNCHLOAD, \
+                            GUIO_NOASPECT)
+#define GUIO_GK2      GUIO5(GUIO_NOSUBTITLES, \
+                            GUIO_NOMIDI, \
                             GUIO_NOASPECT, \
-                            GAMEOPTION_ORIGINAL_SAVELOAD)
-#define GUIO_GK2      GUIO3(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                            GUIO_NOASPECT, \
-                            GAMEOPTION_ORIGINAL_SAVELOAD)
+                            GAMEOPTION_ORIGINAL_SAVELOAD, \
+                            GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 #define GUIO_GK2_MAC  GUIO_GK2
 
 	// Gabriel Knight 2 - English Windows Non-Interactive Demo
@@ -912,6 +917,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK | ADGF_CD | ADGF_UNSTABLE, GUIO_GK2_MAC },
 
+#undef GUIO_GK2_DEMO
+#undef GUIO_GK2
+#undef GUIO_GK2_MAC
+
 #endif // ENABLE_SCI32
 
 	// Hoyle 1 - English DOS (supplied by ssburnout in bug report #3049193)
@@ -1125,9 +1134,9 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK, GUIO4(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI)	},
 
 #ifdef ENABLE_SCI32
-#define GUIO_HOYLE5 GUIO3(GUIO_NOSPEECH, \
-                          GUIO_NOASPECT, \
-                          GUIO_NOLAUNCHLOAD)
+#define GUIO_HOYLE5 GUIO3(GUIO_NOMIDI, \
+                          GUIO_NOLAUNCHLOAD, \
+                          GUIO_NOASPECT)
 
 	// Hoyle 5 (Hoyle Classic Games) - Windows demo
 	{"hoyle5", "Demo", {
@@ -1176,6 +1185,8 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO_HOYLE5 },
 
+#undef GUIO_HOYLE5
+
 #endif // ENABLE_SCI32
 
 	// ImagiNation Network (INN) Demo
@@ -1792,15 +1803,12 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_KQ7_DEMO GUIO5(GUIO_NOSPEECH, \
-                            GUIO_NOASPECT, \
-                            GAMEOPTION_PREFER_DIGITAL_SFX, \
-                            GAMEOPTION_ORIGINAL_SAVELOAD, \
-                            GAMEOPTION_FB01_MIDI)
-#define GUIO_KQ7      GUIO4(GUIO_NOASPECT, \
-                            GAMEOPTION_PREFER_DIGITAL_SFX, \
-                            GAMEOPTION_ORIGINAL_SAVELOAD, \
-                            GAMEOPTION_FB01_MIDI)
+#define GUIO_KQ7_DEMO GUIO4(GUIO_NOSUBTITLES, \
+                            GUIO_NOSPEECH, \
+                            GUIO_NOLAUNCHLOAD, \
+                            GUIO_NOASPECT)
+#define GUIO_KQ7      GUIO2(GUIO_NOASPECT, \
+                            GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// King's Quest 7 - English Windows (from the King's Quest Collection)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.4"
@@ -1877,13 +1885,16 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE | ADGF_CD, GUIO_KQ7_DEMO },
 
+#undef GUIO_KQ7_DEMO
+#undef GUIO_KQ7
+
 	// King's Questions mini-game from the King's Quest Collection
 	// SCI interpreter version 2.000.000
 	{"kquestions", "", {
 		{"resource.000", 0, "9b1cddecd4f0720d83661ba7aed28891", 162697},
 		{"resource.map", 0, "93a2251fa64e729d7a7d2fe56b217c8e", 502},
 		AD_LISTEND},
-		Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO3(GUIO_NOSPEECH, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_FB01_MIDI)	},
+		Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO6(GUIO_NOSUBTITLES, GUIO_NOMUSIC, GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMIDI, GUIO_NOLAUNCHLOAD)	},
 
 #endif // ENABLE_SCI32
 
@@ -2580,10 +2591,8 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_LSL6HIRES GUIO4(GUIO_NOASPECT, \
-                             GAMEOPTION_PREFER_DIGITAL_SFX, \
-                             GAMEOPTION_ORIGINAL_SAVELOAD, \
-                             GAMEOPTION_FB01_MIDI)
+#define GUIO_LSL6HIRES GUIO2(GUIO_NOASPECT, \
+                             GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Larry 6 - English/German DOS CD - HIRES
 	// SCI interpreter version 2.100.002
@@ -2609,16 +2618,17 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::FR_FRA, Common::kPlatformDOS, ADGF_CD | ADGF_UNSTABLE, GUIO_LSL6HIRES },
 
-#define GUIO_LSL7_DEMO GUIO5(GUIO_NOSPEECH, \
-                             GUIO_NOASPECT, \
-                             GAMEOPTION_PREFER_DIGITAL_SFX, \
-                             GAMEOPTION_ORIGINAL_SAVELOAD, \
-                             GAMEOPTION_FB01_MIDI)
-#define GUIO_LSL7      GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+#undef GUIO_LSL6HIRES
+
+// TODO: Correct GUIOs
+#define GUIO_LSL7_DEMO GUIO4(GUIO_NOASPECT, \
+                             GUIO_NOMIDI, \
+                             GUIO_NOLAUNCHLOAD, \
+                             GAMEOPTION_ORIGINAL_SAVELOAD)
+#define GUIO_LSL7      GUIO4(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
                              GUIO_NOASPECT, \
-                             GAMEOPTION_PREFER_DIGITAL_SFX, \
-                             GAMEOPTION_ORIGINAL_SAVELOAD, \
-                             GAMEOPTION_FB01_MIDI)
+                             GUIO_NOMIDI, \
+                             GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Larry 7 - English DOS Demo (provided by richiefs in bug report #2670691)
 	// SCI interpreter version 2.100.002
@@ -2668,19 +2678,19 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"ressci.000", 0, "32792f9bc1bf3633a88b382bb3f6e40d", 67071418},
 		AD_LISTEND},
 		Common::ES_ESP, Common::kPlatformDOS, ADGF_CD | ADGF_UNSTABLE, GUIO_LSL7 },
+
+#undef GUIO_LSL7_DEMO
+#undef GUIO_LSL7
+
 #endif
 
-#define GUIO_LIGHTHOUSE_DEMO GUIO5(GUIO_NOSPEECH, \
+// TODO: Correct GUIOs
+#define GUIO_LIGHTHOUSE_DEMO GUIO3(GUIO_NOSPEECH, \
                                    GUIO_NOASPECT, \
-                                   GAMEOPTION_PREFER_DIGITAL_SFX, \
-                                   GAMEOPTION_ORIGINAL_SAVELOAD, \
-                                   GAMEOPTION_FB01_MIDI)
-#define GUIO_LIGHTHOUSE      GUIO6(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                                   GUIO_NOSPEECH, \
+                                   GAMEOPTION_ORIGINAL_SAVELOAD)
+#define GUIO_LIGHTHOUSE      GUIO3(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
                                    GUIO_NOASPECT, \
-                                   GAMEOPTION_PREFER_DIGITAL_SFX, \
-                                   GAMEOPTION_ORIGINAL_SAVELOAD, \
-                                   GAMEOPTION_FB01_MIDI)
+                                   GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Lighthouse - English Windows Demo (from jvprat)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.00"
@@ -2728,6 +2738,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"ressci.002", 0, "3c8d627c555b0e3e4f1d9955bc0f0df4", 94631127},
 		AD_LISTEND},
 		Common::ES_ESP, Common::kPlatformDOS, ADGF_CD | ADGF_UNSTABLE, GUIO_LIGHTHOUSE },
+
+#undef GUIO_LIGHTHOUSE_DEMO
+#undef GUIO_LIGHTHOUSE
+
 #endif	// ENABLE_SCI3_GAMES
 
 #endif // ENABLE_SCI32
@@ -2850,10 +2864,8 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_MOTHERGOOSEHIRES GUIO4(GUIO_NOASPECT, \
-                                    GAMEOPTION_PREFER_DIGITAL_SFX, \
-                                    GAMEOPTION_ORIGINAL_SAVELOAD, \
-                                    GAMEOPTION_FB01_MIDI)
+#define GUIO_MOTHERGOOSEHIRES GUIO2(GUIO_NOASPECT, \
+                                    GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Mixed-Up Mother Goose Deluxe - English Windows/DOS CD (supplied by markcoolio in bug report #2723810)
 	// Executable scanning reports "2.100.002"
@@ -2870,6 +2882,9 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"ressci.000", 0, "227685bc59d90821978d330713e44a7a", 17205800},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformDOS, ADGF_CD | ADGF_UNSTABLE, GUIO_MOTHERGOOSEHIRES },
+
+#undef GUIO_MOTHERGOOSEHIRES
+
 #endif // ENABLE_SCI32
 
 	// Ms. Astro Chicken - English DOS
@@ -2882,18 +2897,12 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_PHANTASMAGORIA_DEMO GUIO6(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                                       GUIO_NOSPEECH, \
+#define GUIO_PHANTASMAGORIA_DEMO GUIO4(GUIO_NOSUBTITLES, \
                                        GUIO_NOASPECT, \
                                        GUIO_NOLAUNCHLOAD, \
-                                       GAMEOPTION_PREFER_DIGITAL_SFX, \
-                                       GAMEOPTION_FB01_MIDI)
+                                       GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 #define GUIO_PHANTASMAGORIA      GUIO_PHANTASMAGORIA_DEMO
-#define GUIO_PHANTASMAGORIA_MAC  GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                                       GUIO_NOASPECT, \
-                                       GUIO_NOLAUNCHLOAD, \
-                                       GAMEOPTION_PREFER_DIGITAL_SFX, \
-                                       GAMEOPTION_FB01_MIDI)
+#define GUIO_PHANTASMAGORIA_MAC  GUIO_PHANTASMAGORIA_DEMO
 
 	// Phantasmagoria - English DOS/Windows (from csnover)
 	// Windows executable scanning reports "2.100.002" - "Aug 06 1995"
@@ -3014,10 +3023,14 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 	 Common::EN_ANY, Common::kPlatformMacintosh, ADGF_CD | ADGF_MACRESFORK | ADGF_UNSTABLE, GUIO_PHANTASMAGORIA_MAC },
 
+#undef GUIO_PHANTASMAGORIA_DEMO
+#undef GUIO_PHANTASMAGORIA
+#undef GUIO_PHANTASMAGORIA_MAC
+
 #ifdef ENABLE_SCI3_GAMES
 
-#define GUIO_PHANTASMAGORIA2 GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                                   GUIO_NOSPEECH, \
+// TODO: Correct GUIOs
+#define GUIO_PHANTASMAGORIA2 GUIO4(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
                                    GUIO_NOASPECT, \
                                    GUIO_NOMIDI, \
                                    GAMEOPTION_ORIGINAL_SAVELOAD)
@@ -3305,14 +3318,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_PQ4_FLOPPY GUIO4(GUIO_NOSPEECH, \
-                              GAMEOPTION_PREFER_DIGITAL_SFX, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD, \
-                              GAMEOPTION_FB01_MIDI)
-#define GUIO_PQ4_CD     GUIO4(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \
-                              GAMEOPTION_PREFER_DIGITAL_SFX, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD, \
-                              GAMEOPTION_FB01_MIDI)
+#define GUIO_PQ4_FLOPPY GUIO2(GUIO_NOSPEECH, \
+                              GAMEOPTION_ORIGINAL_SAVELOAD)
+#define GUIO_PQ4_CD     GUIO2(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, \
+                              GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Police Quest 4 - English DOS CD (from the Police Quest Collection)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.100.000"
@@ -3354,16 +3363,17 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::DE_DEU, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO_PQ4_FLOPPY },
 
-#define GUIO_PQSWAT_DEMO GUIO5(GUIO_NOSPEECH, \
+#undef GUIO_PQ4_FLOPPY
+#undef GUIO_PQ4_CD
+
+#define GUIO_PQSWAT_DEMO GUIO4(GUIO_NOSUBTITLES, \
+                               GUIO_NOSPEECH, \
                                GUIO_NOASPECT, \
-                               GAMEOPTION_PREFER_DIGITAL_SFX, \
-                               GAMEOPTION_ORIGINAL_SAVELOAD, \
-                               GAMEOPTION_FB01_MIDI)
-#define GUIO_PQSWAT      GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+                               GUIO_NOLAUNCHLOAD)
+#define GUIO_PQSWAT      GUIO4(GUIO_NOMIDI, \
                                GUIO_NOASPECT, \
-                               GAMEOPTION_PREFER_DIGITAL_SFX, \
                                GAMEOPTION_ORIGINAL_SAVELOAD, \
-                               GAMEOPTION_FB01_MIDI)
+                               GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 
 	// Police Quest: SWAT - English DOS/Windows Demo (from jvprat)
 	// Executable scanning reports "2.100.002", VERSION file reports "0.001.200"
@@ -3395,6 +3405,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"ressci.004", 0, "b7e619e6ecf62fe65d5116a3a422e5f0", 46223872},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD | ADGF_UNSTABLE, GUIO_PQSWAT },
+
+#undef GUIO_PQSWAT_DEMO
+#undef GUIO_PQSWAT
+
 #endif // ENABLE_SCI32
 
 	// Quest for Glory 1 / Hero's Quest - English DOS 3.5" Floppy (supplied by merkur in bug report #2718784)
@@ -3753,13 +3767,9 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_QFG4_FLOPPY GUIO4(GUIO_NOSPEECH, \
-                               GAMEOPTION_PREFER_DIGITAL_SFX, \
-                               GAMEOPTION_ORIGINAL_SAVELOAD, \
-                               GAMEOPTION_FB01_MIDI)
-#define GUIO_QFG4_CD     GUIO3(GAMEOPTION_PREFER_DIGITAL_SFX, \
-                               GAMEOPTION_ORIGINAL_SAVELOAD, \
-                               GAMEOPTION_FB01_MIDI)
+#define GUIO_QFG4_FLOPPY GUIO2(GUIO_NOSPEECH, \
+                               GAMEOPTION_ORIGINAL_SAVELOAD)
+#define GUIO_QFG4_CD     GUIO1(GAMEOPTION_ORIGINAL_SAVELOAD)
 
 	// Quest for Glory 4 1.1 Floppy - English DOS (supplied by markcool in bug report #2723852)
 	// SCI interpreter version 2.000.000 (a guess?)
@@ -3801,12 +3811,18 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_CD | ADGF_UNSTABLE, GUIO_QFG4_CD	},
 
-#define GUIO_RAMA_DEMO GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+#undef GUIO_QFG4_FLOPPY
+#undef GUIO_QFG4_CD
+
+// TODO: Correct GUIOs
+#define GUIO_RAMA_DEMO GUIO4(GUIO_NOMIDI, \
+                             GUIO_NOLAUNCHLOAD, \
+                             GUIO_NOASPECT, \
+                             GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
+#define GUIO_RAMA      GUIO4(GUIO_NOMIDI, \
                              GUIO_NOASPECT, \
-                             GAMEOPTION_PREFER_DIGITAL_SFX, \
                              GAMEOPTION_ORIGINAL_SAVELOAD, \
-                             GAMEOPTION_FB01_MIDI)
-#define GUIO_RAMA      GUIO_RAMA_DEMO
+                             GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 
 	// RAMA - English DOS/Windows Demo
 	// Executable scanning reports "2.100.002", VERSION file reports "000.000.008"
@@ -3858,13 +3874,21 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resmap.001", 0, "70ba2ff04a2b7fb2c52420ba7fbd47c2", 8338},
 		AD_LISTEND},
 		Common::IT_ITA, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO_RAMA },
+
+#undef GUIO_RAMA_DEMO
+#undef GUIO_RAMA
+
 #endif	// ENABLE_SCI3_GAMES
 
-#define GUIO_SHIVERS_DEMO GUIO4(GUIO_NOASPECT, \
-                                GAMEOPTION_PREFER_DIGITAL_SFX, \
+#define GUIO_SHIVERS_DEMO GUIO5(GUIO_NOSUBTITLES, \
+                                GUIO_NOSPEECH, \
+                                GUIO_NOMIDI, \
+                                GUIO_NOLAUNCHLOAD, \
+                                GUIO_NOASPECT)
+#define GUIO_SHIVERS      GUIO4(GUIO_NOMIDI, \
+                                GUIO_NOASPECT, \
                                 GAMEOPTION_ORIGINAL_SAVELOAD, \
-                                GAMEOPTION_FB01_MIDI)
-#define GUIO_SHIVERS      GUIO_SHIVERS_DEMO
+                                GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 
 	// Shivers - English Windows (from jvprat)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.02"
@@ -3889,6 +3913,9 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO | ADGF_UNSTABLE, GUIO_SHIVERS },
 
+#undef GUIO_SHIVERS_DEMO
+#undef GUIO_SHIVERS
+
 	// Shivers 2 doesn't contain SCI scripts. The whole game logic has
 	// been reimplemented from SCI in native code placed in DLL files.
 	// Each room has its own DLL file, and some SCI functions have been
@@ -4460,16 +4487,11 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_SQ6_DEMO GUIO5(GUIO_NOSPEECH, \
-                            GUIO_NOASPECT, \
-                            GAMEOPTION_PREFER_DIGITAL_SFX, \
+#define GUIO_SQ6_DEMO GUIO2(GUIO_NOLAUNCHLOAD, \
+                            GUIO_NOASPECT)
+#define GUIO_SQ6      GUIO3(GUIO_NOASPECT, \
                             GAMEOPTION_ORIGINAL_SAVELOAD, \
-                            GAMEOPTION_FB01_MIDI)
-#define GUIO_SQ6      GUIO5(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
-                            GUIO_NOASPECT, \
-                            GAMEOPTION_PREFER_DIGITAL_SFX, \
-                            GAMEOPTION_ORIGINAL_SAVELOAD, \
-                            GAMEOPTION_FB01_MIDI)
+                            GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 
 	// Space Quest 6 - English DOS/Win3.11 CD (from the Space Quest Collection)
 	// Executable scanning reports "2.100.002", VERSION file reports "1.0"
@@ -4510,6 +4532,10 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"resource.000", 0, "ab12724e078dea34b624e0d2a38dcd7c", 2272050},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformDOS, ADGF_DEMO | ADGF_UNSTABLE, GUIO_SQ6_DEMO },
+
+#undef GUIO_SQ6_DEMO
+#undef GUIO_SQ6
+
 #endif // ENABLE_SCI32
 
 	// The Island of Dr. Brain - English DOS CD (from jvprat)
@@ -4538,13 +4564,13 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 
 #ifdef ENABLE_SCI32
 
-#define GUIO_TORIN_DEMO GUIO3(GUIO_NOASPECT, \
-                              GUIO_NOMIDI, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD)
-#define GUIO_TORIN      GUIO4(GAMEOPTION_ENABLE_BLACK_LINED_VIDEO, \
+#define GUIO_TORIN_DEMO GUIO3(GUIO_NOMIDI, \
+                              GUIO_NOLAUNCHLOAD, \
+                              GUIO_NOASPECT)
+#define GUIO_TORIN      GUIO4(GUIO_NOMIDI, \
                               GUIO_NOASPECT, \
-                              GUIO_NOMIDI, \
-                              GAMEOPTION_ORIGINAL_SAVELOAD)
+                              GAMEOPTION_ORIGINAL_SAVELOAD, \
+                              GAMEOPTION_ENABLE_BLACK_LINED_VIDEO)
 #define GUIO_TORIN_MAC  GUIO_TORIN
 
 	// Torin's Passage - English Windows Interactive Demo
@@ -4634,6 +4660,11 @@ static const struct ADGameDescription SciGameDescriptions[] = {
 		{"Data7", 0, "2afd9b5434102b89610916b904c3f73a", 7627374},
 		AD_LISTEND},
 		Common::EN_ANY, Common::kPlatformMacintosh, ADGF_MACRESFORK | ADGF_UNSTABLE | ADGF_CD, GUIO_TORIN_MAC },
+
+#undef GUIO_TORIN_DEMO
+#undef GUIO_TORIN
+#undef GUIO_TORIN_MAC
+
 #endif // ENABLE_SCI32
 
 	// SCI Fanmade Games


Commit: e729a31edc97ecd9057f536e7da3ee14c5cf5c0c
    https://github.com/scummvm/scummvm/commit/e729a31edc97ecd9057f536e7da3ee14c5cf5c0c
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix SQ6 demo crash

Changed paths:
    engines/sci/engine/workarounds.cpp


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index e574b96..cfc8749 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -552,6 +552,7 @@ const SciWorkaroundEntry kDoSoundPlay_workarounds[] = {
 	{ GID_QFG4,         -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // always passes an extra null argument
 	{ GID_PQ4,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // always passes an extra null argument
 	{ GID_KQ7,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // always passes an extra null argument
+	{ GID_SQ6,          -1,      0,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Demo passes an extra null argument on startup
 	{ GID_GK1,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Mac version always passes an extra null argument
 	{ GID_GK2,          -1,  64989,   0,          NULL,          "play",                    NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Demo passes an extra null argument when clicking on buttons
 	SCI_WORKAROUNDENTRY_TERMINATOR


Commit: c48c24d1d328cd0701075f636be3c853fa81e5c0
    https://github.com/scummvm/scummvm/commit/c48c24d1d328cd0701075f636be3c853fa81e5c0
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix Torin demo crash

Changed paths:
    engines/sci/engine/workarounds.cpp


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index cfc8749..d36d265 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -579,6 +579,7 @@ const SciWorkaroundEntry kGetAngle_workarounds[] = {
 //    gameID,           room,script,lvl,          object-name, method-name, local-call-signature, index,                workaround
 const SciWorkaroundEntry kFileIOOpen_workarounds[] = {
 	{ GID_TORIN,       61000, 61000,  0,       "roSierraLogo", "init",                      NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Missing second argument when the game checks for autosave.cat after the Sierra logo
+	{ GID_TORIN,       61100, 61100,  0,     "roPickAChapter", "init",                      NULL,     0, { WORKAROUND_STILLCALL, 0 } }, // Missing second argument when the game checks for autosave.cat after the Sierra logo in the demo
 	SCI_WORKAROUNDENTRY_TERMINATOR
 };
 


Commit: 126378fa263734c44072bc4ad14835cba23bb124
    https://github.com/scummvm/scummvm/commit/126378fa263734c44072bc4ad14835cba23bb124
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix bad coordinates in PQ:SWAT demo

Changed paths:
    engines/sci/graphics/frameout.cpp


diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 57512f1..08fdd51 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -88,13 +88,13 @@ GfxFrameout::GfxFrameout(SegManager *segMan, GfxPalette32 *palette, GfxTransitio
 	case GID_LIGHTHOUSE:
 	case GID_LSL7:
 	case GID_PHANTASMAGORIA2:
-	case GID_PQSWAT:
 	case GID_TORIN:
 	case GID_RAMA:
 		_currentBuffer.scriptWidth = 640;
 		_currentBuffer.scriptHeight = 480;
 		break;
 	case GID_GK2:
+	case GID_PQSWAT:
 		if (!g_sci->isDemo()) {
 			_currentBuffer.scriptWidth = 640;
 			_currentBuffer.scriptHeight = 480;


Commit: b895b4b075ee8b9ca327c027b620db3ea8059e8d
    https://github.com/scummvm/scummvm/commit/b895b4b075ee8b9ca327c027b620db3ea8059e8d
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Disable compression for Phantasmagoria save files

Changed paths:
    engines/sci/engine/file.cpp


diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index da1d00f..75aa4fa 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -200,6 +200,15 @@ reg_t file_open(EngineState *s, const Common::String &filename, kFileOpenMode mo
 		if (s->currentRoomNumber() == 52)
 			isCompressed = false;
 		break;
+#ifdef ENABLE_SCI32
+	// Phantasmagoria game scripts create their own save files, so they are
+	// interoperable with the original interpreter just by renaming them as long
+	// as they are not compressed. They are also never larger than a couple
+	// hundred bytes, so compression does not do much here anyway
+	case GID_PHANTASMAGORIA:
+		isCompressed = false;
+		break;
+#endif
 	default:
 		break;
 	}


Commit: e18e6399acd856231ed869812559eff1c998cef6
    https://github.com/scummvm/scummvm/commit/e18e6399acd856231ed869812559eff1c998cef6
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:34:54-06:00

Commit Message:
SCI32: Fix bad rendering of Sierra logo in MGDX

Changed paths:
    engines/sci/engine/script_patches.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 0c4f0da..6f06436 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -2864,6 +2864,43 @@ static const SciScriptPatcherEntry mothergoose256Signatures[] = {
 
 #ifdef ENABLE_SCI32
 #pragma mark -
+#pragma mark Mixed-up Mother Goose Deluxe
+
+// The game uses pic 10005 to render the Sierra logo, but then it also
+// initialises a logo object with view 502 on the same priority as the pic. In
+// the original interpreter, it is dumb luck which is drawn first (based on the
+// order of the memory IDs), though usually the pic is drawn first because not
+// many objects have been created at the start of the game. In ScummVM, the
+// renderer guarantees a sort order based on the creation order of screen items,
+// and since the view is created after the pic, it wins and is drawn on top.
+// This patch stops the view object from being created at all.
+//
+// Applies to at least: English CD from King's Quest Collection
+// Responsible method: sShowLogo::changeState
+static const uint16 mothergooseHiresSignatureLogo[] = {
+	0x38, SIG_UINT16(0x8e),          // pushi $8e
+	SIG_MAGICDWORD,
+	0x76,                            // push0
+	0x72, SIG_UINT16(0x82),          // lofsa logo[82]
+	0x4a, SIG_UINT16(0x04),          // send $4
+	SIG_END
+};
+
+static const uint16 mothergooseHiresPatchLogo[] = {
+	0x18, 0x18, 0x18,                // waste bytes
+	0x18,                            // waste bytes
+	0x18, 0x18, 0x18,                // waste bytes
+	0x18, 0x18, 0x18,                // waste bytes
+	PATCH_END
+};
+
+//          script, description,                                      signature                         patch
+static const SciScriptPatcherEntry mothergooseHiresSignatures[] = {
+	{  true,   108, "bad logo rendering",                          1, mothergooseHiresSignatureLogo,    mothergooseHiresPatchLogo },
+	SCI_SIGNATUREENTRY_TERMINATOR
+};
+
+#pragma mark -
 #pragma mark Phantasmagoria
 
 //          script, description,                                      signature                        patch
@@ -5147,6 +5184,10 @@ void ScriptPatcher::processScript(uint16 scriptNr, byte *scriptData, const uint3
 		signatureTable = mothergoose256Signatures;
 		break;
 #ifdef ENABLE_SCI32
+	case GID_MOTHERGOOSEHIRES:
+		signatureTable = mothergooseHiresSignatures;
+		break;
+
 	case GID_PHANTASMAGORIA:
 		signatureTable = phantasmagoriaSignatures;
 		break;


Commit: f1ca9ccc6426a46a7da47bf4a36301bd849bf978
    https://github.com/scummvm/scummvm/commit/f1ca9ccc6426a46a7da47bf4a36301bd849bf978
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-01-09T19:38:59-06:00

Commit Message:
SCI32: Fix kSetLanguage

Changed paths:
    engines/sci/engine/ksound.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp


diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index ed53b8d..4a5e4f3 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -493,10 +493,8 @@ reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv) {
 	// Basically, it instructs the interpreter to switch the audio resources
 	// (resource.aud and associated map files) and load them from the "Spanish"
 	// subdirectory instead.
-	Common::String audioDirectory = s->_segMan->getString(argv[0]);
-	//warning("SetLanguage: set audio resource directory to '%s'", audioDirectory.c_str());
+	const Common::String audioDirectory = s->_segMan->getString(argv[0]);
 	g_sci->getResMan()->changeAudioDirectory(audioDirectory);
-
 	return s->r_acc;
 }
 
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index e601a1c..5589129 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -372,7 +372,7 @@ public:
 
 	void setAudioLanguage(int language);
 	int getAudioLanguage() const;
-	void changeAudioDirectory(Common::String path);
+	void changeAudioDirectory(const Common::String &path);
 	bool isGMTrackIncluded();
 	bool isSci11Mac() const { return _volVersion == kResVersionSci11Mac; }
 	ViewType getViewType() const { return _viewType; }
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 7757445..bd6eee3 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -964,33 +964,53 @@ bool ResourceManager::addAudioSources() {
 	return true;
 }
 
-void ResourceManager::changeAudioDirectory(Common::String path) {
-	// TODO: This implementation is broken.
-	return;
-
-#if 0
-	// Remove all of the audio map resource sources, as well as the audio resource sources
-	for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end();) {
-		ResourceSource *source = *it;
-		ResSourceType sourceType = source->getSourceType();
-
-		// Remove the resource source, if it's an audio map or an audio file
-		if (sourceType == kSourceIntMap || sourceType == kSourceAudioVolume) {
-			// Don't remove 65535.map (the SFX map) or resource.sfx
-			if (source->_volumeNumber == 65535 || source->getLocationName() == "RESOURCE.SFX") {
-				++it;
+void ResourceManager::changeAudioDirectory(const Common::String &path) {
+	// Resources must be cleared before ResourceSources because the destructor
+	// of a Resource accesses its own ResourceSource
+	ResourceMap::iterator resIt = _resMap.begin();
+	while (resIt != _resMap.end()) {
+		Resource *resource = resIt->_value;
+		ResourceType type = resource->getType();
+		if (type == kResourceTypeMap ||
+			type == kResourceTypeAudio36 ||
+			type == kResourceTypeSync36) {
+
+			if (type == kResourceTypeMap && resource->getNumber() == 65535) {
+				++resIt;
 				continue;
 			}
 
-			// erase() will move the iterator to the next element
-			it = _sources.erase(it);
+			if (resource->_status == kResStatusLocked) {
+				resource->_lockers = 1;
+				unlockResource(resource);
+			}
+			if (resource->_status == kResStatusEnqueued) {
+				removeFromLRU(resource);
+			}
+			if (resource->_status != kResStatusNoMalloc) {
+				resource->unalloc();
+			}
+			delete resource;
+			_resMap.erase(resIt);
+		}
+
+		++resIt;
+	}
+
+	Common::List<ResourceSource *>::iterator sourceIt = _sources.begin();
+	while (sourceIt != _sources.end()) {
+		ResourceSource *source = *sourceIt;
+		ResSourceType sourceType = source->getSourceType();
+		if ((sourceType == kSourceIntMap && source->_volumeNumber != 65535) ||
+			(sourceType == kSourceAudioVolume && source->getLocationName() != "RESOURCE.SFX")) {
+
+			sourceIt = _sources.erase(sourceIt);
 			delete source;
 		} else {
-			++it;
+			++sourceIt;
 		}
 	}
 
-	// Now, readd the audio resource sources
 	Common::String mapName = "MAP";
 	Common::String audioResourceName = "RESOURCE.AUD";
 	if (!path.empty()) {
@@ -1002,16 +1022,14 @@ void ResourceManager::changeAudioDirectory(Common::String path) {
 	Common::List<ResourceId>::iterator it;
 	for (it = resources.begin(); it != resources.end(); ++it) {
 		// Don't readd 65535.map or resource.sfx
-		if ((it->getNumber() == 65535))
+		if (it->getNumber() == 65535)
 			continue;
 
 		ResourceSource *src = addSource(new IntMapResourceSource(mapName, 0, it->getNumber()));
 		addSource(new AudioVolumeResourceSource(this, audioResourceName, src, 0));
 	}
 
-	// Rescan the newly added resources
 	scanNewSources();
-#endif
 }
 
 } // End of namespace Sci





More information about the Scummvm-git-logs mailing list