diff options
author | Matthew Hoops | 2009-08-25 23:02:57 +0000 |
---|---|---|
committer | Matthew Hoops | 2009-08-25 23:02:57 +0000 |
commit | b5da8a5cdcd3cd232798ed60f7258bf23e2e9c74 (patch) | |
tree | 96611085dd8d4d422d6842000fbd3742d490642d /engines/sci/engine | |
parent | a039fc952f13e381278b7577f5fe1dd23c9d29a5 (diff) | |
download | scummvm-rg350-b5da8a5cdcd3cd232798ed60f7258bf23e2e9c74.tar.gz scummvm-rg350-b5da8a5cdcd3cd232798ed60f7258bf23e2e9c74.tar.bz2 scummvm-rg350-b5da8a5cdcd3cd232798ed60f7258bf23e2e9c74.zip |
- Split SCI_VERSION_32 into SCI_VERSION_2, SCI_VERSION_2_1, and SCI_VERSION_3 (each version has a different kernel table).
- Improve map detection.
- Fix SCI32 object and script initialization (Torin's Passage and GK1 scripts now start up, and probably most SCI2/2.1 games).
- Add SCI2 and SCI2.1 kernel tables.
svn-id: r43742
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 38 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 12 | ||||
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 359 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 6 |
4 files changed, 384 insertions, 31 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 33f4daf4c3..be744aac3c 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -335,6 +335,7 @@ SciKernelFunction kfunct_mappers[] = { DEFUN("SetVideoMode", kSetVideoMode, "i"), // Special and NOP stuff + DEFUN("Dummy", kStub, ".*"), {NULL, k_Unknown, NULL}, // Stub functions @@ -817,36 +818,17 @@ void Kernel::setDefaultKernelNames() { } } -#ifdef ENABLE_SCI32 -//static void vocab_get_knames11(ResourceManager *resourceManager, Common::StringList &names) { -/* - 999.voc format for SCI1.1 games: - [b] # of kernel functions - [w] unknown - [offset to function name info] - ... - {[w name-len][function name]} - ... -*/ -/* //unsigned int size = 64, pos = 3; - int len; - Resource *r = resourceManager->findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES), 0); - if(r == NULL) // failed to open vocab.999 (happens with SCI1 demos) - return; // FIXME: should return a default table for this engine - const byte nCnt = *r->data; - - names.resize(nCnt); - for (int i = 0; i < nCnt; i++) { - int off = READ_LE_UINT16(r->data + 2 * i + 2); - len = READ_LE_UINT16(r->data + off); - names[i] = Common::String((char *)r->data + off + 2, len); - } -}*/ -#endif - bool Kernel::loadKernelNames() { _kernelNames.clear(); - setDefaultKernelNames(); + +#ifdef ENABLE_SCI32 + if (_resourceManager->sciVersion() == SCI_VERSION_2) + setKernelNamesSci2(); + else if (_resourceManager->sciVersion() == SCI_VERSION_2_1) + setKernelNamesSci21(); + else +#endif + setDefaultKernelNames(); return true; } diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 46d7b82217..595816579b 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -134,6 +134,18 @@ private: * Sets the default kernel function names, based on the SCI version used */ void setDefaultKernelNames(); + +#ifdef ENABLE_SCI32 + /** + * Sets the default kernel function names to the SCI2 kernel functions + */ + void setKernelNamesSci2(); + + /** + * Sets the default kernel function names to the SCI2.1 kernel functions + */ + void setKernelNamesSci21(); +#endif /** * Loads the kernel selector names. diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp new file mode 100644 index 0000000000..eac0007ee3 --- /dev/null +++ b/engines/sci/engine/kernel32.cpp @@ -0,0 +1,359 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "sci/engine/kernel.h" + +namespace Sci { + +static const char *sci2_default_knames[] = { + /*0x00*/ "Load", + /*0x01*/ "UnLoad", + /*0x02*/ "ScriptID", + /*0x03*/ "DisposeScript", + /*0x04*/ "Lock", + /*0x05*/ "ResCheck", + /*0x06*/ "Purge", + /*0x07*/ "Clone", + /*0x08*/ "DisposeClone", + /*0x09*/ "RespondsTo", + /*0x0a*/ "SetNowSeen", + /*0x0b*/ "NumLoops", + /*0x0c*/ "NumCels", + /*0x0d*/ "CelWide", + /*0x0e*/ "CelHigh", + /*0x0f*/ "GetHighPlanePri", + /*0x10*/ "GetHighItemPri", + /*0x11*/ "ShakeScreen", + /*0x12*/ "OnMe", + /*0x13*/ "ShowMovie", + /*0x14*/ "SetVideoMode", + /*0x15*/ "AddScreenItem", + /*0x16*/ "DeleteScreenItem", + /*0x17*/ "UpdateScreenItem", + /*0x18*/ "FrameOut", + /*0x19*/ "AddPlane", + /*0x1a*/ "DeletePlane", + /*0x1b*/ "UpdatePlane", + /*0x1c*/ "RepaintPlane", + /*0x1d*/ "SetShowStyle", + /*0x1e*/ "ShowStylePercent", + /*0x1f*/ "SetScroll", + /*0x20*/ "AddMagnify", + /*0x21*/ "DeleteMagnify", + /*0x22*/ "IsHiRes", + /*0x23*/ "Graph", + /*0x24*/ "InvertRect", + /*0x25*/ "TextSize", + /*0x26*/ "Message", + /*0x27*/ "TextColors", + /*0x28*/ "TextFonts", + /*0x29*/ "Dummy", + /*0x2a*/ "SetQuitStr", + /*0x2b*/ "EditText", + /*0x2c*/ "InputText", + /*0x2d*/ "CreateTextBitmap", + /*0x2e*/ "DisposeTextBitmap", + /*0x2f*/ "GetEvent", + /*0x30*/ "GlobalToLocal", + /*0x31*/ "LocalToGlobal", + /*0x32*/ "MapKeyToDir", + /*0x33*/ "HaveMouse", + /*0x34*/ "SetCursor", + /*0x35*/ "VibrateMouse", + /*0x36*/ "SaveGame", + /*0x37*/ "RestoreGame", + /*0x38*/ "RestartGame", + /*0x39*/ "GameIsRestarting", + /*0x3a*/ "MakeSaveCatName", + /*0x3b*/ "MakeSaveFileName", + /*0x3c*/ "GetSaveFiles", + /*0x3d*/ "GetSaveDir", + /*0x3e*/ "CheckSaveGame", + /*0x3f*/ "CheckFreeSpace", + /*0x40*/ "DoSound", + /*0x41*/ "DoAudio", + /*0x42*/ "DoSync", + /*0x43*/ "NewList", + /*0x44*/ "DisposeList", + /*0x45*/ "NewNode", + /*0x46*/ "FirstNode", + /*0x47*/ "LastNode", + /*0x48*/ "EmptyList", + /*0x49*/ "NextNode", + /*0x4a*/ "PrevNode", + /*0x4b*/ "NodeValue", + /*0x4c*/ "AddAfter", + /*0x4d*/ "AddToFront", + /*0x4e*/ "AddToEnd", + /*0x4f*/ "Dummy", + /*0x50*/ "Dummy", + /*0x51*/ "FindKey", + /*0x52*/ "Dummy", + /*0x53*/ "Dummy", + /*0x54*/ "Dummy", + /*0x55*/ "DeleteKey", + /*0x56*/ "Dummy", + /*0x57*/ "Dummy", + /*0x58*/ "ListAt", + /*0x59*/ "ListIndexOf", + /*0x5a*/ "ListEachElementDo", + /*0x5b*/ "ListFirstTrue", + /*0x5c*/ "ListAllTrue", + /*0x5d*/ "Random", + /*0x5e*/ "Abs", + /*0x5f*/ "Sqrt", + /*0x60*/ "GetAngle", + /*0x61*/ "GetDistance", + /*0x62*/ "ATan", + /*0x63*/ "SinMult", + /*0x64*/ "CosMult", + /*0x65*/ "SinDiv", + /*0x66*/ "CosDiv", + /*0x67*/ "GetTime", + /*0x68*/ "Platform", + /*0x69*/ "BaseSetter", + /*0x6a*/ "DirLoop", + /*0x6b*/ "CanBeHere", + /*0x6c*/ "InitBresen", + /*0x6d*/ "DoBresen", + /*0x6e*/ "SetJump", + /*0x6f*/ "AvoidPath", + /*0x70*/ "InPolygon", + /*0x71*/ "MergePoly", + /*0x72*/ "Dummy", + /*0x73*/ "Dummy", + /*0x74*/ "Dummy", + /*0x75*/ "Dummy", + /*0x76*/ "Dummy", + /*0x77*/ "Dummy", + /*0x78*/ "Dummy", + /*0x79*/ "Dummy", + /*0x7a*/ "GetCWD", + /*0x7b*/ "ValidPath", + /*0x7c*/ "FileIO", + /*0x7d*/ "Dummy", + /*0x7e*/ "DeviceInfo", + /*0x7f*/ "Palette", + /*0x80*/ "PalVary", + /*0x81*/ "PalCycle", + /*0x82*/ "Array", + /*0x83*/ "String", + /*0x84*/ "RemapColors", + /*0x85*/ "Dummy", + /*0x86*/ "Dummy", + /*0x87*/ "ObjectIntersect", + /*0x88*/ "Dummy" + /*0x89*/ "TextWidth", + /*0x8a*/ "PointSize" +}; + +static const char *sci21_default_knames[] = { + /*0x00*/ "LNew", + /*0x01*/ "LDispose", + /*0x02*/ "LNewNode", + /*0x03*/ "LFirstNode", + /*0x04*/ "LLastNode", + /*0x05*/ "LEmpty", + /*0x06*/ "LNextNode", + /*0x07*/ "LPrevNode", + /*0x08*/ "LNodeValue", + /*0x09*/ "LAddAfter", + /*0x0a*/ "LAddToFront", + /*0x0b*/ "LAddToEnd", + /*0x0c*/ "LAddBefore", + /*0x0d*/ "LMoveToFront", + /*0x0e*/ "LMoveToEnd", + /*0x0f*/ "LFindKey", + /*0x10*/ "LDeleteKey", + /*0x11*/ "LAt", + /*0x12*/ "LIndexOf", + /*0x13*/ "LEachElementDo", + /*0x14*/ "LFirstTrue", + /*0x15*/ "LAllTrue", + /*0x16*/ "LSort", + /*0x17*/ "Load", + /*0x18*/ "UnLoad", + /*0x19*/ "ScriptID", + /*0x1a*/ "DisposeScript", + /*0x1b*/ "Lock", + /*0x1c*/ "ResCheck", + /*0x1d*/ "Purge", + /*0x1e*/ "SetLanguage", + /*0x1f*/ "Dummy", + /*0x20*/ "Dummy", + /*0x21*/ "Clone", + /*0x22*/ "DisposeClone", + /*0x23*/ "RespondsTo", + /*0x24*/ "FindSelector", + /*0x25*/ "FindClass", + /*0x26*/ "Dummy", + /*0x27*/ "Dummy", + /*0x28*/ "Dummy", + /*0x29*/ "Dummy", + /*0x2a*/ "Dummy", + /*0x2b*/ "SetNowSeen", + /*0x2c*/ "NumLoops", + /*0x2d*/ "NumCels", + /*0x2e*/ "IsOnMe", + /*0x2f*/ "AddMagnify", + /*0x30*/ "DeleteMagnify", + /*0x31*/ "CelRect", + /*0x32*/ "BaseLineSpan" + /*0x33*/ "CelWide", + /*0x34*/ "CelHigh", + /*0x35*/ "AddScreenItem", + /*0x36*/ "DeleteScreenItem", + /*0x37*/ "UpdateScreenItem", + /*0x38*/ "FrameOut", + /*0x39*/ "CelInfo", + /*0x3a*/ "Bitmap", + /*0x3b*/ "CelLink", + /*0x3c*/ "Dummy", + /*0x3d*/ "Dummy", + /*0x3e*/ "Dummy", + /*0x3f*/ "AddPlane", + /*0x40*/ "DeletePlane", + /*0x41*/ "UpdatePlane", + /*0x42*/ "RepaintPlane", + /*0x43*/ "GetHighPlanePri", + /*0x44*/ "GetHighItemPri", + /*0x45*/ "SetShowStyle", + /*0x46*/ "ShowStylePercent", + /*0x47*/ "SetScroll", + /*0x48*/ "MovePlaneItems", + /*0x49*/ "ShakeScreen", + /*0x4a*/ "Dummy", + /*0x4b*/ "Dummy", + /*0x4c*/ "Dummy", + /*0x4d*/ "Dummy", + /*0x4e*/ "IsHiRes", + /*0x4f*/ "SetVideoMode", + /*0x50*/ "ShowMovie", + /*0x51*/ "Robot", + /*0x52*/ "CreateTextBitmap", + /*0x53*/ "Random", + /*0x54*/ "Abs", + /*0x55*/ "Sqrt", + /*0x56*/ "GetAngle", + /*0x57*/ "GetDistance", + /*0x58*/ "ATan", + /*0x59*/ "SinMult", + /*0x5a*/ "CosMult", + /*0x5b*/ "SinDiv", + /*0x5c*/ "CosDiv", + /*0x5d*/ "Text", + /*0x5e*/ "Dummy", + /*0x5f*/ "Message", + /*0x60*/ "Font", + /*0x61*/ "EditText", + /*0x62*/ "InputText", + /*0x63*/ "ScrollWindow", + /*0x64*/ "Dummy", + /*0x65*/ "Dummy", + /*0x66*/ "Dummy", + /*0x67*/ "GetEvent", + /*0x68*/ "GlobalToLocal", + /*0x69*/ "LocalToGlobal", + /*0x6a*/ "MapKeyToDir", + /*0x6b*/ "HaveMouse", + /*0x6c*/ "SetCursor", + /*0x6d*/ "VibrateMouse", + /*0x6e*/ "Dummy", + /*0x6f*/ "Dummy", + /*0x70*/ "Dummy", + /*0x71*/ "Array", + /*0x72*/ "String", + /*0x73*/ "FileIO", + /*0x74*/ "BaseSetter", + /*0x75*/ "DirLoop", + /*0x76*/ "CanBeHere", + /*0x77*/ "InitBresen", + /*0x78*/ "DoBresen", + /*0x79*/ "SetJump", + /*0x7a*/ "AvoidPath", + /*0x7b*/ "InPolygon", + /*0x7c*/ "MergePoly", + /*0x7d*/ "ObjectIntersect", + /*0x7e*/ "Dummy", + /*0x7f*/ "MemoryInfo", + /*0x80*/ "DeviceInfo", + /*0x81*/ "Palette", + /*0x82*/ "PalVary", + /*0x83*/ "PalCycle", + /*0x84*/ "RemapColors", + /*0x85*/ "AddLine", + /*0x86*/ "DeleteLine", + /*0x87*/ "UpdateLine", + /*0x88*/ "AddPolygon", + /*0x89*/ "DeletePolygon", + /*0x8a*/ "UpdatePolygon", + /*0x8b*/ "DoSound", + /*0x8c*/ "DoAudio", + /*0x8d*/ "DoSync", + /*0x8e*/ "Save", + /*0x8f*/ "GetTime", + /*0x90*/ "Platform", + /*0x91*/ "CD", + /*0x92*/ "SetQuitStr", + /*0x93*/ "GetConfig", + /*0x94*/ "Table", + /*0x95*/ "Dummy", + /*0x96*/ "Dummy", + /*0x97*/ "Dummy", + /*0x98*/ "Dummy", + /*0x99*/ "Dummy", + /*0x9a*/ "Dummy", + /*0x9b*/ "Dummy", + /*0x9c*/ "Dummy", + /*0x9d*/ "Dummy", + /*0x9e*/ "Dummy", + /*0x9f*/ "Dummy", + /*0xa0*/ "LoadChunk", + /*0xa1*/ "SetPalStyleRange" + /*0xa2*/ "AddPicAt", + /*0xa3*/ "Dummy", + /*0xa4*/ "NewRoom", + /*0xa5*/ "Dummy", + /*0xa6*/ "Priority", + /*0xa7*/ "MorphOn", + /*0xa8*/ "PlayVMD", + /*0xa9*/ "SetHotRectangles", + /*0xaa*/ "MulDiv", + /*0xab*/ "Dummy", + /*0xac*/ "Dummy", + /*0xad*/ "Dummy", + /*0xae*/ "Dummy", + /*0xaf*/ "Dummy" +}; + +void Kernel::setKernelNamesSci2() { + _kernelNames = Common::StringList(sci2_default_knames, ARRAYSIZE(sci2_default_knames)); +} + +void Kernel::setKernelNamesSci21() { + _kernelNames = Common::StringList(sci21_default_knames, ARRAYSIZE(sci21_default_knames)); +} + +} // End of namespace Sci diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 2b9c30c1ab..b1c355bbb9 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -327,7 +327,7 @@ int SegManager::relocateBlock(Common::Array<reg_t> &block, int block_location, S return 0; } block[idx].segment = segment; // Perform relocation - if (_resourceManager->sciVersion() == SCI_VERSION_1_1) + if (_resourceManager->sciVersion() >= SCI_VERSION_1_1) block[idx].offset += getScript(segment)->script_size; return 1; @@ -589,7 +589,7 @@ Object *SegManager::scriptObjInit11(reg_t obj_pos) { } Object *SegManager::scriptObjInit(reg_t obj_pos) { - if (_resourceManager->sciVersion() != SCI_VERSION_1_1) + if (_resourceManager->sciVersion() < SCI_VERSION_1_1) return scriptObjInit0(obj_pos); else return scriptObjInit11(obj_pos); @@ -633,7 +633,7 @@ void SegManager::scriptInitialiseLocals(reg_t location) { VERIFY(location.offset + 1 < (uint16)scr->buf_size, "Locals beyond end of script\n"); - if (_resourceManager->sciVersion() == SCI_VERSION_1_1) + if (_resourceManager->sciVersion() >= SCI_VERSION_1_1) count = READ_LE_UINT16(scr->buf + location.offset - 2); else count = (READ_LE_UINT16(scr->buf + location.offset - 2) - 4) >> 1; |