[Scummvm-cvs-logs] SF.net SVN: scummvm:[38992] scummvm/trunk/engines/sci/scicore/vocab_debug. cpp

gregfrieger at users.sourceforge.net gregfrieger at users.sourceforge.net
Sun Mar 1 02:52:50 CET 2009


Revision: 38992
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38992&view=rev
Author:   gregfrieger
Date:     2009-03-01 01:52:50 +0000 (Sun, 01 Mar 2009)

Log Message:
-----------
Added default kernel functions table to be used if vocab.999 can't be loaded in SCI1
Added SCI1.1 kernel functions table reader

Modified Paths:
--------------
    scummvm/trunk/engines/sci/scicore/vocab_debug.cpp

Modified: scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-03-01 00:51:59 UTC (rev 38991)
+++ scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-03-01 01:52:50 UTC (rev 38992)
@@ -32,6 +32,7 @@
 // Default kernel name table
 #define SCI0_KNAMES_WELL_DEFINED 0x6e
 #define SCI0_KNAMES_DEFAULT_ENTRIES_NR 0x72
+#define SCI1_KNAMES_DEFAULT_ENTRIES_NR 0x7E
 
 const char *sci0_default_knames[SCI0_KNAMES_DEFAULT_ENTRIES_NR] = {
 	/*0x00*/ "Load",
@@ -150,6 +151,135 @@
 	/*0x71*/ SCRIPT_UNKNOWN_FUNCTION_STRING
 };
 
+const char *sci1_default_knames[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = {
+	"Load",
+	"UnLoad",
+	"ScriptID",
+	"DisposeScript",
+	"Clone",
+	"DisposeClone",
+	"IsObject",
+	"RespondsTo",
+	"DrawPic",
+	"Show",
+	"PicNotValid",
+	"Animate",
+	"SetNowSeen",
+	"NumLoops",
+	"NumCels",
+	"CelWide",
+	"CelHigh",
+	"DrawCel",
+	"AddToPic",
+	"NewWindow",
+	"GetPort",
+	"SetPort",
+	"DisposeWindow",
+	"DrawControl",
+	"HiliteControl",
+	"EditControl",
+	"TextSize",
+	"Display",
+	"GetEvent",
+	"GlobalToLocal",
+	"LocalToGlobal",
+	"MapKeyToDir",
+	"DrawMenuBar",
+	"MenuSelect",
+	"AddMenu",
+	"DrawStatus",
+	"Parse",
+	"Said",
+	"SetSynonyms",
+	"HaveMouse",
+	"SetCursor",
+	"SaveGame",
+	"RestoreGame",
+	"RestartGame",
+	"GameIsRestarting",
+	"DoSound",
+	"NewList",
+	"DisposeList",
+	"NewNode",
+	"FirstNode",
+	"LastNode",
+	"EmptyList",
+	"NextNode",
+	"PrevNode",
+	"NodeValue",
+	"AddAfter",
+	"AddToFront",
+	"AddToEnd",
+	"FindKey",
+	"DeleteKey",
+	"Random",
+	"Abs",
+	"Sqrt",
+	"GetAngle",
+	"GetDistance",
+	"Wait",
+	"GetTime",
+	"StrEnd",
+	"StrCat",
+	"StrCmp",
+	"StrLen",
+	"StrCpy",
+	"Format",
+	"GetFarText",
+	"ReadNumber",
+	"BaseSetter",
+	"DirLoop",
+	"CanBeHere",
+	"OnControl",
+	"InitBresen",
+	"DoBresen",
+	"DoAvoider",
+	"SetJump",
+	"SetDebug",
+	"InspectObj",
+	"ShowSends",
+	"ShowObjs",
+	"ShowFree",
+	"MemoryInfo",
+	"StackUsage",
+	"Profiler",
+	"GetMenu",
+	"SetMenu",
+	"GetSaveFiles",
+	"GetCWD",
+	"CheckFreeSpace",
+	"ValidPath",
+	"CoordPri",
+	"StrAt",
+	"DeviceInfo",
+	"GetSaveDir",
+	"CheckSaveGame",
+	"ShakeScreen",
+	"FlushResources",
+	"SinMult",
+	"CosMult",
+	"SinDiv",
+	"CosDiv",
+	"Graph",
+	"Joystick",
+	"ShiftScreen",
+	"Palette",
+	"MemorySegment",
+	"Intersections",
+	"Memory",
+	"ListOps",
+	"FileIO",
+	"DoAudio",
+	"DoSync",
+	"AvoidPath",
+	"Sort",
+	"ATan",
+	"Lock",         
+	"StrSplit",       
+	"GetMessage",
+	SCRIPT_UNKNOWN_FUNCTION_STRING
+};
+
 int getInt(unsigned char* d) {
 	return d[0] | (d[1] << 8);
 }
@@ -346,7 +476,17 @@
 	char **t = NULL;
 	unsigned int size = 64, used = 0, pos = 0;
 	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
+	if(r == NULL) {// failed to open vocab.999 (happens with SCI1 demos)
+		t = (char **)sci_malloc((SCI1_KNAMES_DEFAULT_ENTRIES_NR + 1) * sizeof(char*));
+		*count = SCI1_KNAMES_DEFAULT_ENTRIES_NR - 1; // index of last element
 
+		for (int i = 0; i < SCI1_KNAMES_DEFAULT_ENTRIES_NR; i++)
+			t[i] = sci_strdup(sci1_default_knames[i]);
+
+		t[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = NULL; // Terminate list
+
+		return t;
+	}
 	while (pos < r->size) {
 		int len;
 		if ((used == size - 1) || (!t)) {
@@ -365,7 +505,39 @@
 
 	return t;
 }
+//
+static char **vocabulary_get_knames11(ResourceManager *resmgr, int *count) {
+/*
+ 999.voc format for SCI1.1 games:
+	[b] # of kernel functions
+	[w] unknown
+	[offset to function name info]
+		...
+    {[w name-len][function name]}
+		...
+*/
+	char **t = NULL;
+	unsigned int size = 64, pos = 3;
+	int len;
+	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
+	if(r == NULL) // failed to open vocab.999 (happens with SCI1 demos)
+		return 0; // FIXME: should return a default table for this engine 
+	byte nCnt = *r->data, i;
+	t = (char **)sci_malloc(nCnt * sizeof(char*) + 1);
+	
+	for (i = 0; i < nCnt; i++) {
+		int off = READ_LE_UINT16(r->data + 2 * i + 2);
+		len = READ_LE_UINT16(r->data + off);
+		t[i] = (char *)sci_malloc(len + 1);
+		memcpy(t[i], (char *)r->data + off + 2, len);
+		t[i][len] = 0;
+	}
+	*count = nCnt;
+	t[nCnt] = NULL;
 
+	return t;
+}
+
 char **vocabulary_get_knames(ResourceManager *resmgr, int *count) {
 	switch (resmgr->_sciVersion) {
 	case SCI_VERSION_0:
@@ -375,9 +547,10 @@
 		return vocabulary_get_knames0(resmgr, count);
 	case SCI_VERSION_1_EARLY:
 	case SCI_VERSION_1_LATE:
+		return vocabulary_get_knames1(resmgr, count);
 	case SCI_VERSION_1_1:
 	case SCI_VERSION_32:
-		return vocabulary_get_knames1(resmgr, count);
+		return vocabulary_get_knames11(resmgr, count);
 	default:
 		return 0;
 	}


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