[Scummvm-cvs-logs] SF.net SVN: scummvm:[42050] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jul 3 11:01:51 CEST 2009


Revision: 42050
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42050&view=rev
Author:   thebluegr
Date:     2009-07-03 09:01:51 +0000 (Fri, 03 Jul 2009)

Log Message:
-----------
Simplified the kernel name loading code: Merged the default SCI0 and SCI1 kernel name tables in one table. vocab.999 is only used in SCI0 and SCI01 games if it exists as an override to the default kernel name table  (which works with SCI0/SCI01 demos with no vocab.999, like KQ1 and xmas1998). Removed GF_SCI0_SCI1VOCAB.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-07-03 07:06:48 UTC (rev 42049)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-07-03 09:01:51 UTC (rev 42050)
@@ -953,7 +953,7 @@
 		{"resource.map", 0, "59b13619078bd47011421468959ee5d4", 954},
 		{"resource.001", 0, "4cfb9040db152868f7cb6a1e8151c910", 296555},
 		{NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, GUIO_NOSPEECH},
-		GF_SCI0_SCI1VOCAB,
+		0,
 		SCI_VERSION_AUTODETECT,
 		SCI_VERSION_0
 	},

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-03 07:06:48 UTC (rev 42049)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-07-03 09:01:51 UTC (rev 42050)
@@ -38,10 +38,9 @@
 
 // Default kernel name table
 #define SCI0_KNAMES_WELL_DEFINED 0x6e
-#define SCI0_KNAMES_DEFAULT_ENTRIES_NR 0x72
-#define SCI1_KNAMES_DEFAULT_ENTRIES_NR 0x89
+#define SCI_KNAMES_DEFAULT_ENTRIES_NR 0x89
 
-static const char *sci0_default_knames[SCI0_KNAMES_DEFAULT_ENTRIES_NR] = {
+static const char *sci_default_knames[SCI_KNAMES_DEFAULT_ENTRIES_NR] = {
 	/*0x00*/ "Load",
 	/*0x01*/ "UnLoad",
 	/*0x02*/ "ScriptID",
@@ -83,123 +82,6 @@
 	/*0x26*/ "SetSynonyms",
 	/*0x27*/ "HaveMouse",
 	/*0x28*/ "SetCursor",
-	/*0x29*/ "FOpen",
-	/*0x2a*/ "FPuts",
-	/*0x2b*/ "FGets",
-	/*0x2c*/ "FClose",
-	/*0x2d*/ "SaveGame",
-	/*0x2e*/ "RestoreGame",
-	/*0x2f*/ "RestartGame",
-	/*0x30*/ "GameIsRestarting",
-	/*0x31*/ "DoSound",
-	/*0x32*/ "NewList",
-	/*0x33*/ "DisposeList",
-	/*0x34*/ "NewNode",
-	/*0x35*/ "FirstNode",
-	/*0x36*/ "LastNode",
-	/*0x37*/ "EmptyList",
-	/*0x38*/ "NextNode",
-	/*0x39*/ "PrevNode",
-	/*0x3a*/ "NodeValue",
-	/*0x3b*/ "AddAfter",
-	/*0x3c*/ "AddToFront",
-	/*0x3d*/ "AddToEnd",
-	/*0x3e*/ "FindKey",
-	/*0x3f*/ "DeleteKey",
-	/*0x40*/ "Random",
-	/*0x41*/ "Abs",
-	/*0x42*/ "Sqrt",
-	/*0x43*/ "GetAngle",
-	/*0x44*/ "GetDistance",
-	/*0x45*/ "Wait",
-	/*0x46*/ "GetTime",
-	/*0x47*/ "StrEnd",
-	/*0x48*/ "StrCat",
-	/*0x49*/ "StrCmp",
-	/*0x4a*/ "StrLen",
-	/*0x4b*/ "StrCpy",
-	/*0x4c*/ "Format",
-	/*0x4d*/ "GetFarText",
-	/*0x4e*/ "ReadNumber",
-	/*0x4f*/ "BaseSetter",
-	/*0x50*/ "DirLoop",
-	/*0x51*/ "CanBeHere",
-	/*0x52*/ "OnControl",
-	/*0x53*/ "InitBresen",
-	/*0x54*/ "DoBresen",
-	/*0x55*/ "DoAvoider",
-	/*0x56*/ "SetJump",
-	/*0x57*/ "SetDebug",
-	/*0x58*/ "InspectObj",
-	/*0x59*/ "ShowSends",
-	/*0x5a*/ "ShowObjs",
-	/*0x5b*/ "ShowFree",
-	/*0x5c*/ "MemoryInfo",
-	/*0x5d*/ "StackUsage",
-	/*0x5e*/ "Profiler",
-	/*0x5f*/ "GetMenu",
-	/*0x60*/ "SetMenu",
-	/*0x61*/ "GetSaveFiles",
-	/*0x62*/ "GetCWD",
-	/*0x63*/ "CheckFreeSpace",
-	/*0x64*/ "ValidPath",
-	/*0x65*/ "CoordPri",
-	/*0x66*/ "StrAt",
-	/*0x67*/ "DeviceInfo",
-	/*0x68*/ "GetSaveDir",
-	/*0x69*/ "CheckSaveGame",
-	/*0x6a*/ "ShakeScreen",
-	/*0x6b*/ "FlushResources",
-	/*0x6c*/ "SinMult",
-	/*0x6d*/ "CosMult",
-	/*0x6e*/ "SinDiv",
-	/*0x6f*/ "CosDiv",
-	/*0x70*/ "Graph",
-	/*0x71*/ SCRIPT_UNKNOWN_FUNCTION_STRING
-};
-
-static const char *sci1_default_knames[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = {
-	/*0x00*/ "Load",
-	/*0x01*/ "UnLoad",
-	/*0x02*/ "ScriptID",
-	/*0x03*/ "DisposeScript",
-	/*0x04*/ "Clone",
-	/*0x05*/ "DisposeClone",
-	/*0x06*/ "IsObject",
-	/*0x07*/ "RespondsTo",
-	/*0x08*/ "DrawPic",
-	/*0x09*/ "Show",
-	/*0x0a*/ "PicNotValid",
-	/*0x0b*/ "Animate",
-	/*0x0c*/ "SetNowSeen",
-	/*0x0d*/ "NumLoops",
-	/*0x0e*/ "NumCels",
-	/*0x0f*/ "CelWide",
-	/*0x10*/ "CelHigh",
-	/*0x11*/ "DrawCel",
-	/*0x12*/ "AddToPic",
-	/*0x13*/ "NewWindow",
-	/*0x14*/ "GetPort",
-	/*0x15*/ "SetPort",
-	/*0x16*/ "DisposeWindow",
-	/*0x17*/ "DrawControl",
-	/*0x18*/ "HiliteControl",
-	/*0x19*/ "EditControl",
-	/*0x1a*/ "TextSize",
-	/*0x1b*/ "Display",
-	/*0x1c*/ "GetEvent",
-	/*0x1d*/ "GlobalToLocal",
-	/*0x1e*/ "LocalToGlobal",
-	/*0x1f*/ "MapKeyToDir",
-	/*0x20*/ "DrawMenuBar",
-	/*0x21*/ "MenuSelect",
-	/*0x22*/ "AddMenu",
-	/*0x23*/ "DrawStatus",
-	/*0x24*/ "Parse",
-	/*0x25*/ "Said",
-	/*0x26*/ "SetSynonyms",
-	/*0x27*/ "HaveMouse",
-	/*0x28*/ "SetCursor",
 	/*0x29*/ "SaveGame",
 	/*0x2a*/ "RestoreGame",
 	/*0x2b*/ "RestartGame",
@@ -846,18 +728,10 @@
 	return (reg_t*)_kernel_dereference_pointer(s, pointer, entries, sizeof(reg_t));
 }
 
-// Alternative kernel func names retriever. Required for KQ1/SCI (at least).
-static void _vocab_get_knames0alt(const Resource *r, Common::StringList &names) {
-	uint idx = 0;
-
-	while (idx < r->size) {
-		Common::String tmp((const char *)r->data + idx);
-		names.push_back(tmp);
-		idx += tmp.size() + 1;
-	}
-
-	// The mystery kernel function- one in each SCI0 package
-	names.push_back(SCRIPT_UNKNOWN_FUNCTION_STRING);
+void setDefaultKernelNames(Common::StringList &names) {
+	names.resize(SCI_KNAMES_DEFAULT_ENTRIES_NR);
+	for (int i = 0; i < SCI_KNAMES_DEFAULT_ENTRIES_NR; i++)
+		names[i] = sci_default_knames[i];
 }
 
 static void vocab_get_knames0(ResourceManager *resmgr, Common::StringList &names) {
@@ -865,16 +739,15 @@
 	Resource *r = resmgr->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES), 0);
 
 	if (!r) { // No kernel name table found? Fall back to default table
-		names.resize(SCI0_KNAMES_DEFAULT_ENTRIES_NR);
-		for (i = 0; i < SCI0_KNAMES_DEFAULT_ENTRIES_NR; i++)
-			names[i] = sci0_default_knames[i];
+		setDefaultKernelNames(names);
 		return;
 	}
 
 	count = READ_LE_UINT16(r->data);
 
 	if (count > 1023) {
-		_vocab_get_knames0alt(r, names);
+		// Newer kernel name table, found in KQ1. We can use the default table here
+		setDefaultKernelNames(names);
 		return;
 	}
 
@@ -898,20 +771,6 @@
 	}
 }
 
-static void vocab_get_knames1(ResourceManager *resmgr, Common::StringList &names) {
-	// vocab.999/999.voc is notoriously unreliable in SCI1 games, and should not be used
-	// We hardcode the default SCI1 kernel names here (i.e. the ones inside the "special"
-	// 999.voc file from FreeSCI). All SCI1 games seem to be working with this change, but
-	// if any SCI1 game has different kernel vocabulary names, it might not work. It seems
-	// that all SCI1 games use the same kernel vocabulary names though, so this seems to be
-	// a safe change. If there's any SCI1 game with different kernel vocabulary names, we can
-	// add special flags to it to our detector
-
-	names.resize(SCI1_KNAMES_DEFAULT_ENTRIES_NR);
-	for (int i = 0; i < SCI1_KNAMES_DEFAULT_ENTRIES_NR; i++)
-		names[i] = sci1_default_knames[i];
-}
-
 #ifdef ENABLE_SCI32
 static void vocab_get_knames11(ResourceManager *resmgr, Common::StringList &names) {
 /*
@@ -945,27 +804,18 @@
 	switch (_resmgr->_sciVersion) {
 	case SCI_VERSION_0:
 	case SCI_VERSION_01:
-		// HACK: The KQ1 demo requires the SCI1 vocabulary.
-		if (((SciEngine*)g_engine)->getFlags() & GF_SCI0_SCI1VOCAB)
-			vocab_get_knames1(_resmgr, _kernelNames);
-		else
-			vocab_get_knames0(_resmgr, _kernelNames);
-		break;
 	case SCI_VERSION_01_VGA:
 	case SCI_VERSION_01_VGA_ODD:
-		// HACK: KQ5 needs the SCI1 default vocabulary names to work correctly.
-		// Having more vocabulary names (like in SCI1) doesn't seem to have any
-		// ill effects, other than resulting in unmapped functions towards the
-		// end, which are never used by the game interpreter anyway
-		// return vocab_get_knames0(resmgr, count);
+		vocab_get_knames0(_resmgr, _kernelNames);
+		break;
 	case SCI_VERSION_1_EARLY:
 	case SCI_VERSION_1_LATE:
-		vocab_get_knames1(_resmgr, _kernelNames);
-		break;
 	case SCI_VERSION_1_1:
-		vocab_get_knames1(_resmgr, _kernelNames);
-		// KQ6CD calls unimplemented function 0x26
-                _kernelNames[0x26] = "Dummy";
+		setDefaultKernelNames(_kernelNames);
+		if (_resmgr->_sciVersion == SCI_VERSION_1_1) {
+			// KQ6CD calls unimplemented function 0x26
+			_kernelNames[0x26] = "Dummy";
+		}
 		break;
 #ifdef ENABLE_SCI32
 	case SCI_VERSION_32:

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-07-03 07:06:48 UTC (rev 42049)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-07-03 09:01:51 UTC (rev 42050)
@@ -158,8 +158,7 @@
 
 		if (flags & GF_SCI0_OLD ||
 			flags & GF_SCI0_OLDGFXFUNCS ||
-			flags & GF_SCI0_OLDGETTIME ||
-			flags & GF_SCI0_SCI1VOCAB) {
+			flags & GF_SCI0_OLDGETTIME) {
 			error("This game entry is erroneous. It's marked as SCI1, but it has SCI0 flags set");
 		}
 	} else if (version == SCI_VERSION_1_1 || version == SCI_VERSION_32) {
@@ -171,8 +170,7 @@
 
 		if (flags & GF_SCI0_OLD ||
 			flags & GF_SCI0_OLDGFXFUNCS ||
-			flags & GF_SCI0_OLDGETTIME ||
-			flags & GF_SCI0_SCI1VOCAB) {
+			flags & GF_SCI0_OLDGETTIME) {
 			error("This game entry is erroneous. It's marked as SCI1.1/SCI32, but it has SCI0 flags set");
 		}
 

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-07-03 07:06:48 UTC (rev 42049)
+++ scummvm/trunk/engines/sci/sci.h	2009-07-03 09:01:51 UTC (rev 42050)
@@ -108,11 +108,6 @@
 	** Older SCI versions had simpler code for GetTime()
 	*/
 	GF_SCI0_OLDGETTIME		= (1 << 2),
-	
-	/* Applies to any game that requires the SCI1 kernel vocab
-	** Some games (such as the King's Quest I demo) require the default kernel vocab table.
-	*/
-	GF_SCI0_SCI1VOCAB       = (1 << 3),
 
 	// ----------------------------------------------------------------------------
 
@@ -123,18 +118,18 @@
 	/*
 	** Used to distinguish SCI1 EGA games
 	*/
-	GF_SCI1_EGA				= (1 << 4),
+	GF_SCI1_EGA				= (1 << 3),
 
 	/* Applies to all SCI1 versions after 1.000.200
     ** In late SCI1 versions, the argument of lofs[as] instructions
 	** is absolute rather than relative.
 	*/
-	GF_SCI1_LOFSABSOLUTE	= (1 << 5),
+	GF_SCI1_LOFSABSOLUTE	= (1 << 4),
 
 	/* Applies to all versions from 1.000.510 onwards
 	** kDoSound() is different than in earlier SCI1 versions.
 	*/
-	GF_SCI1_NEWDOSOUND		= (1 << 6)
+	GF_SCI1_NEWDOSOUND		= (1 << 5)
 };
 
 class SciEngine : public Engine {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list