From bd565771d0bb54eedaa1b51f1d0f1ab123d48249 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 7 Jun 2013 00:49:50 +0300 Subject: FULLPIPE: Started work on CObList loader --- engines/fullpipe/utils.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 engines/fullpipe/utils.cpp (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp new file mode 100644 index 0000000000..e1031cf0ed --- /dev/null +++ b/engines/fullpipe/utils.cpp @@ -0,0 +1,58 @@ +/* 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. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "common/file.h" + +#include "fullpipe/utils.h" +#include "fullpipe/objects.h" + +namespace Fullpipe { + +char *MfcArchive::readPascalString() { + char *tmp; + int len = readByte(); + tmp = (char *)calloc(len + 1, 1); + read(tmp, len); + + return tmp; +} + +int MfcArchive::readCount() { + int count = readUint16LE(); + + if (count == 0xffff) + count = readUint32LE(); + + return count; +} + +CObject *MfcArchive::parseClass() { + CObject *res; + + res = new CInventory2(); + + return res; +} + +} // End of namespace Fullpipe -- cgit v1.2.3 From 0c03278937d0b7e85da3b60f1edf8bf7764aecbc Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 7 Jun 2013 23:56:40 +0300 Subject: FULLPIPE: Start of reading CInteraction --- engines/fullpipe/utils.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index e1031cf0ed..75e5f69f8d 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -47,12 +47,61 @@ int MfcArchive::readCount() { return count; } +enum { + kCInteraction = 0 +}; + +const struct { + const char *name; + int id; +} classMap[] = { + { "CInteraction", kCInteraction }, + { 0, 0 } +}; + +MfcArchive::MfcArchive() { + for (int i; classMap[i].name; i++) { + _classMap[classMap[i].name] = classMap[i].id; + } + + _lastIndex = 1; +} + CObject *MfcArchive::parseClass() { - CObject *res; + char *name; + int objectId; + + uint obTag = readUint16LE(); + + if (obTag == 0xffff) { + int schema = readUint16LE(); + + name = readPascalString(); + + if (!_classMap.contains(name)) { + error("Unknown class in MfcArchive: %s", name); + } + + _objectMap[_lastIndex] = objectId = _classMap[name]; + _lastIndex++; + } else { + obTag &= ~0x8000; + + if (_objectMap.size() < obTag) { + error("Object index too big: %d", obTag); + } + + objectId = _objectMap[obTag]; + } - res = new CInventory2(); + switch (objectId) { + case kCInteraction: + return new CInteraction(); + default: + error("Unknown objectId: %d", objectId); + } - return res; + return 0; } } // End of namespace Fullpipe -- cgit v1.2.3 From 72aeac3f3634cacdfdafd15388b6033592b9d25f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 8 Jun 2013 17:05:51 +0300 Subject: FULLPIPE: Continue parsing CInteraction --- engines/fullpipe/utils.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 75e5f69f8d..b39ae423ea 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -29,9 +29,15 @@ namespace Fullpipe { -char *MfcArchive::readPascalString() { +char *MfcArchive::readPascalString(bool twoByte) { char *tmp; - int len = readByte(); + int len; + + if (twoByte) + len = readUint16LE(); + else + len = readByte(); + tmp = (char *)calloc(len + 1, 1); read(tmp, len); @@ -73,17 +79,21 @@ CObject *MfcArchive::parseClass() { uint obTag = readUint16LE(); + debug(0, "parseClass::obTag = %d", obTag); + if (obTag == 0xffff) { int schema = readUint16LE(); - name = readPascalString(); + debug(0, "parseClass::schema = %d", schema); + + name = readPascalString(true); if (!_classMap.contains(name)) { - error("Unknown class in MfcArchive: %s", name); + error("Unknown class in MfcArchive: <%s>", name); } - _objectMap[_lastIndex] = objectId = _classMap[name]; - _lastIndex++; + objectId = _classMap[name]; + _objectMap.push_back(objectId); } else { obTag &= ~0x8000; @@ -93,6 +103,8 @@ CObject *MfcArchive::parseClass() { objectId = _objectMap[obTag]; } + + debug(0, "objectId: %d", objectId); switch (objectId) { case kCInteraction: -- cgit v1.2.3 From e9fa2e52df6d5823499bd5731a16dba7c5c7c9db Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 00:27:42 +0300 Subject: FULLPIPE: Continued loading CInteraction --- engines/fullpipe/utils.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index b39ae423ea..954af848af 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -54,14 +54,18 @@ int MfcArchive::readCount() { } enum { - kCInteraction = 0 + kCInteraction = 0, + kMessageQueue = 1, + kExCommand = 2 }; const struct { const char *name; int id; } classMap[] = { - { "CInteraction", kCInteraction }, + { "CInteraction", kCInteraction }, + { "MessageQueue", kMessageQueue }, + { "ExCommand", kExCommand }, { 0, 0 } }; @@ -79,7 +83,7 @@ CObject *MfcArchive::parseClass() { uint obTag = readUint16LE(); - debug(0, "parseClass::obTag = %d", obTag); + debug(0, "parseClass::obTag = %d (%04x)", obTag, obTag); if (obTag == 0xffff) { int schema = readUint16LE(); @@ -87,6 +91,7 @@ CObject *MfcArchive::parseClass() { debug(0, "parseClass::schema = %d", schema); name = readPascalString(true); + debug(0, "parseClass::class <%s>", name); if (!_classMap.contains(name)) { error("Unknown class in MfcArchive: <%s>", name); @@ -94,14 +99,18 @@ CObject *MfcArchive::parseClass() { objectId = _classMap[name]; _objectMap.push_back(objectId); + + debug(0, "tag: %d", _objectMap.size()); } else { obTag &= ~0x8000; + debug(0, "parseClass::obTag <%d>", obTag); + if (_objectMap.size() < obTag) { - error("Object index too big: %d", obTag); + error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } - objectId = _objectMap[obTag]; + objectId = _objectMap[obTag - 1]; } debug(0, "objectId: %d", objectId); @@ -109,6 +118,10 @@ CObject *MfcArchive::parseClass() { switch (objectId) { case kCInteraction: return new CInteraction(); + case kMessageQueue: + return new MessageQueue(); + case kExCommand: + return new ExCommand(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From ad47d5a5e2f0a1b88d101aca9ad25b2af2f1beae Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 12:26:38 +0300 Subject: FULLPIPE: Attampt to fix serializer. Still not working --- engines/fullpipe/utils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 954af848af..d9fd3d829b 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -75,6 +75,8 @@ MfcArchive::MfcArchive() { } _lastIndex = 1; + + _objectMap.push_back(0); } CObject *MfcArchive::parseClass() { @@ -100,7 +102,7 @@ CObject *MfcArchive::parseClass() { objectId = _classMap[name]; _objectMap.push_back(objectId); - debug(0, "tag: %d", _objectMap.size()); + debug(0, "tag: %d", _objectMap.size() - 1); } else { obTag &= ~0x8000; @@ -110,7 +112,7 @@ CObject *MfcArchive::parseClass() { error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } - objectId = _objectMap[obTag - 1]; + objectId = _objectMap[obTag]; } debug(0, "objectId: %d", objectId); -- cgit v1.2.3 From 9395ab11d2020779dd27c7720ef1cb791b030116 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 12:32:14 +0300 Subject: FULLPIPE: Hack to enable object loader --- engines/fullpipe/utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index d9fd3d829b..36eb86c56e 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -101,6 +101,7 @@ CObject *MfcArchive::parseClass() { objectId = _classMap[name]; _objectMap.push_back(objectId); + _objectMap.push_back(objectId); // Gross HACK debug(0, "tag: %d", _objectMap.size() - 1); } else { -- cgit v1.2.3 From 67d30f29f9e658ce760b8a1a5f413fef4d2d586e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 12:51:23 +0300 Subject: FULLPIPE: Added ObjstateCommand loader --- engines/fullpipe/utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 36eb86c56e..1c324a020c 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -56,7 +56,8 @@ int MfcArchive::readCount() { enum { kCInteraction = 0, kMessageQueue = 1, - kExCommand = 2 + kExCommand = 2, + kCObjstateCommand = 3 }; const struct { @@ -66,6 +67,7 @@ const struct { { "CInteraction", kCInteraction }, { "MessageQueue", kMessageQueue }, { "ExCommand", kExCommand }, + { "CObjstateCommand", kCObjstateCommand }, { 0, 0 } }; @@ -125,6 +127,8 @@ CObject *MfcArchive::parseClass() { return new MessageQueue(); case kExCommand: return new ExCommand(); + case kCObjstateCommand: + return new CObjstateCommand(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 0b1bda78fc5144c8ea03e597face630c29a5a88f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 13:22:10 +0300 Subject: FULLPIPE: Fix object loading --- engines/fullpipe/utils.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 1c324a020c..5da63114b1 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -103,10 +103,14 @@ CObject *MfcArchive::parseClass() { objectId = _classMap[name]; _objectMap.push_back(objectId); - _objectMap.push_back(objectId); // Gross HACK + debug(0, "tag: %d (%x)", _objectMap.size() - 1, objectId); - debug(0, "tag: %d", _objectMap.size() - 1); + objectId = _classMap[name]; } else { + if ((obTag & 0x8000) == 0) { + error("Wrong object index format: %d at 0x%08x", obTag, pos() - 2); + } + obTag &= ~0x8000; debug(0, "parseClass::obTag <%d>", obTag); @@ -118,6 +122,8 @@ CObject *MfcArchive::parseClass() { objectId = _objectMap[obTag]; } + _objectMap.push_back(objectId); + debug(0, "objectId: %d", objectId); switch (objectId) { -- cgit v1.2.3 From da00b7143e08a0ed95142e4401896bd7653b04ab Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 13:33:22 +0300 Subject: FULLPIPE: Add more debug output to archive loading --- engines/fullpipe/utils.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 5da63114b1..6534c64269 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -71,8 +71,18 @@ const struct { { 0, 0 } }; +static const char *lookupObjectId(int id) { + for (int i = 0; classMap[i].name; i++) { + if (classMap[i].id == id) + return classMap[i].name; + } + + return ""; +} + + MfcArchive::MfcArchive() { - for (int i; classMap[i].name; i++) { + for (int i = 0; classMap[i].name; i++) { _classMap[classMap[i].name] = classMap[i].id; } @@ -87,7 +97,7 @@ CObject *MfcArchive::parseClass() { uint obTag = readUint16LE(); - debug(0, "parseClass::obTag = %d (%04x)", obTag, obTag); + debug(0, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); if (obTag == 0xffff) { int schema = readUint16LE(); @@ -113,12 +123,12 @@ CObject *MfcArchive::parseClass() { obTag &= ~0x8000; - debug(0, "parseClass::obTag <%d>", obTag); - if (_objectMap.size() < obTag) { error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } + debug(0, "parseClass::obTag <%s>", lookupObjectId(_objectMap[obTag])); + objectId = _objectMap[obTag]; } -- cgit v1.2.3 From 54624966ce933e8a43fbf32dff0731b0db517e4a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 9 Jun 2013 23:51:33 +0300 Subject: FULLPIPE: Finish loading CInteractions --- engines/fullpipe/utils.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 6534c64269..09f00b8042 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -41,6 +41,8 @@ char *MfcArchive::readPascalString(bool twoByte) { tmp = (char *)calloc(len + 1, 1); read(tmp, len); + debug(0, "readPascalString: %d <%s>", len, tmp); + return tmp; } @@ -54,10 +56,11 @@ int MfcArchive::readCount() { } enum { - kCInteraction = 0, - kMessageQueue = 1, - kExCommand = 2, - kCObjstateCommand = 3 + kNullObject = 0, + kCInteraction = 1, + kMessageQueue = 2, + kExCommand = 3, + kCObjstateCommand = 4 }; const struct { @@ -88,7 +91,7 @@ MfcArchive::MfcArchive() { _lastIndex = 1; - _objectMap.push_back(0); + _objectMap.push_back(kNullObject); } CObject *MfcArchive::parseClass() { @@ -116,10 +119,9 @@ CObject *MfcArchive::parseClass() { debug(0, "tag: %d (%x)", _objectMap.size() - 1, objectId); objectId = _classMap[name]; + } else if ((obTag & 0x8000) == 0) { + objectId = _objectMap[obTag]; } else { - if ((obTag & 0x8000) == 0) { - error("Wrong object index format: %d at 0x%08x", obTag, pos() - 2); - } obTag &= ~0x8000; @@ -145,6 +147,9 @@ CObject *MfcArchive::parseClass() { return new ExCommand(); case kCObjstateCommand: return new CObjstateCommand(); + case kNullObject: + warning("parseClass: NULL object at 0x%08x", pos() - 2); + return 0; default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 775065af1d23d9114594c96a77ecf04f1e722795 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 10 Jun 2013 01:03:15 +0300 Subject: FULLPIPE: Started CGameVar loading --- engines/fullpipe/utils.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 09f00b8042..aa4c270d54 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -60,7 +60,8 @@ enum { kCInteraction = 1, kMessageQueue = 2, kExCommand = 3, - kCObjstateCommand = 4 + kCObjstateCommand = 4, + kCGameVar = 5 }; const struct { @@ -71,6 +72,7 @@ const struct { { "MessageQueue", kMessageQueue }, { "ExCommand", kExCommand }, { "CObjstateCommand", kCObjstateCommand }, + { "CGameVar", kCGameVar }, { 0, 0 } }; @@ -94,6 +96,15 @@ MfcArchive::MfcArchive() { _objectMap.push_back(kNullObject); } +CObject *MfcArchive::readClass() { + CObject *res = parseClass(); + + if (res) + res->load(*this); + + return res; +} + CObject *MfcArchive::parseClass() { char *name; int objectId; @@ -139,6 +150,9 @@ CObject *MfcArchive::parseClass() { debug(0, "objectId: %d", objectId); switch (objectId) { + case kNullObject: + warning("parseClass: NULL object at 0x%08x", pos() - 2); + return 0; case kCInteraction: return new CInteraction(); case kMessageQueue: @@ -147,9 +161,8 @@ CObject *MfcArchive::parseClass() { return new ExCommand(); case kCObjstateCommand: return new CObjstateCommand(); - case kNullObject: - warning("parseClass: NULL object at 0x%08x", pos() - 2); - return 0; + case kCGameVar: + return new CGameVar(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From f106d791983223906847343c4b1f1ec7ffcc05d5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 10 Jun 2013 01:21:56 +0300 Subject: FULLPIPE: Fix object indexing --- engines/fullpipe/utils.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index aa4c270d54..a81665b48b 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -127,7 +127,7 @@ CObject *MfcArchive::parseClass() { objectId = _classMap[name]; _objectMap.push_back(objectId); - debug(0, "tag: %d (%x)", _objectMap.size() - 1, objectId); + debug(0, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); objectId = _classMap[name]; } else if ((obTag & 0x8000) == 0) { @@ -145,7 +145,8 @@ CObject *MfcArchive::parseClass() { objectId = _objectMap[obTag]; } - _objectMap.push_back(objectId); + if (objectId) + _objectMap.push_back(objectId); debug(0, "objectId: %d", objectId); -- cgit v1.2.3 From a116677e6e26ed9d0e8fcc40eaf88c0c40b25391 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 11 Jun 2013 01:17:11 +0300 Subject: FULLPIPE: Finish loading fullpipe.gam --- engines/fullpipe/utils.cpp | 92 +++++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 37 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index a81665b48b..5df9a28500 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -41,7 +41,7 @@ char *MfcArchive::readPascalString(bool twoByte) { tmp = (char *)calloc(len + 1, 1); read(tmp, len); - debug(0, "readPascalString: %d <%s>", len, tmp); + debug(9, "readPascalString: %d <%s>", len, tmp); return tmp; } @@ -85,6 +85,26 @@ static const char *lookupObjectId(int id) { return ""; } +static CObject *createObject(int objectId) { + switch (objectId) { + case kNullObject: + return 0; + case kCInteraction: + return new CInteraction(); + case kMessageQueue: + return new MessageQueue(); + case kExCommand: + return new ExCommand(); + case kCObjstateCommand: + return new CObjstateCommand(); + case kCGameVar: + return new CGameVar(); + default: + error("Unknown objectId: %d", objectId); + } + + return 0; +} MfcArchive::MfcArchive() { for (int i = 0; classMap[i].name; i++) { @@ -93,45 +113,60 @@ MfcArchive::MfcArchive() { _lastIndex = 1; - _objectMap.push_back(kNullObject); + _objectMap.push_back(0); + _objectIdMap.push_back(kNullObject); } CObject *MfcArchive::readClass() { - CObject *res = parseClass(); + bool isCopyReturned; + CObject *res = parseClass(&isCopyReturned); - if (res) + if (res && !isCopyReturned) res->load(*this); return res; } -CObject *MfcArchive::parseClass() { +CObject *MfcArchive::parseClass(bool *isCopyReturned) { char *name; - int objectId; + int objectId = 0; + CObject *res = 0; uint obTag = readUint16LE(); - debug(0, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); + debug(7, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); if (obTag == 0xffff) { int schema = readUint16LE(); - debug(0, "parseClass::schema = %d", schema); + debug(7, "parseClass::schema = %d", schema); name = readPascalString(true); - debug(0, "parseClass::class <%s>", name); + debug(7, "parseClass::class <%s>", name); if (!_classMap.contains(name)) { error("Unknown class in MfcArchive: <%s>", name); } objectId = _classMap[name]; - _objectMap.push_back(objectId); - debug(0, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); - objectId = _classMap[name]; + debug(7, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); + + res = createObject(objectId); + _objectMap.push_back(res); + _objectIdMap.push_back(objectId); + + _objectMap.push_back(res); // Basically a hack, but behavior is all correct + _objectIdMap.push_back(objectId); + + *isCopyReturned = false; } else if ((obTag & 0x8000) == 0) { - objectId = _objectMap[obTag]; + if (_objectMap.size() < obTag) { + error("Object index too big: %d at 0x%08x", obTag, pos() - 2); + } + res = _objectMap[obTag]; + + *isCopyReturned = true; } else { obTag &= ~0x8000; @@ -140,35 +175,18 @@ CObject *MfcArchive::parseClass() { error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } - debug(0, "parseClass::obTag <%s>", lookupObjectId(_objectMap[obTag])); + debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag])); - objectId = _objectMap[obTag]; - } - - if (objectId) - _objectMap.push_back(objectId); + objectId = _objectIdMap[obTag]; - debug(0, "objectId: %d", objectId); + res = createObject(objectId); + _objectMap.push_back(res); + _objectIdMap.push_back(objectId); - switch (objectId) { - case kNullObject: - warning("parseClass: NULL object at 0x%08x", pos() - 2); - return 0; - case kCInteraction: - return new CInteraction(); - case kMessageQueue: - return new MessageQueue(); - case kExCommand: - return new ExCommand(); - case kCObjstateCommand: - return new CObjstateCommand(); - case kCGameVar: - return new CGameVar(); - default: - error("Unknown objectId: %d", objectId); + *isCopyReturned = false; } - return 0; + return res; } } // End of namespace Fullpipe -- cgit v1.2.3 From ffd8ebacc51b873aca4e9e36227be11647e1442a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 11 Jun 2013 01:34:37 +0300 Subject: FULLPIPE: Removed excess debugging info and added variable levels --- engines/fullpipe/utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 5df9a28500..d85a01dd33 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -112,6 +112,7 @@ MfcArchive::MfcArchive() { } _lastIndex = 1; + _level = 0; _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); -- cgit v1.2.3 From d3d3d01eb08cd7ee37480a9427bc563242aceeed Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 13 Jun 2013 00:57:54 +0300 Subject: FULLPIPE: Started sc2 file loading implementation --- engines/fullpipe/utils.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index d85a01dd33..764da5abea 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -56,12 +56,12 @@ int MfcArchive::readCount() { } enum { - kNullObject = 0, - kCInteraction = 1, - kMessageQueue = 2, - kExCommand = 3, - kCObjstateCommand = 4, - kCGameVar = 5 + kNullObject, + kCInteraction, + kMessageQueue, + kExCommand, + kCObjstateCommand, + kCGameVar }; const struct { -- cgit v1.2.3 From e24ce22ca7b62982c31a8a907f8423983be39bde Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 15 Jun 2013 01:19:45 +0300 Subject: FULLPIPE: Continued work on loading sc2 files --- engines/fullpipe/utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 764da5abea..9c9246a5f2 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -61,7 +61,8 @@ enum { kMessageQueue, kExCommand, kCObjstateCommand, - kCGameVar + kCGameVar, + kCMctlCompound }; const struct { @@ -73,6 +74,7 @@ const struct { { "ExCommand", kExCommand }, { "CObjstateCommand", kCObjstateCommand }, { "CGameVar", kCGameVar }, + { "CMctlCompound", kCMctlCompound }, { 0, 0 } }; @@ -99,6 +101,8 @@ static CObject *createObject(int objectId) { return new CObjstateCommand(); case kCGameVar: return new CGameVar(); + case kCMctlCompound: + return new CMctlCompound(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 0f9c1281d4e4f0c4e2e942994f9162c88033c01f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 16 Jun 2013 15:07:33 +0300 Subject: FULLPIPE: CMovGraph loader --- engines/fullpipe/utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 9c9246a5f2..34cf3c57a4 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -62,7 +62,8 @@ enum { kExCommand, kCObjstateCommand, kCGameVar, - kCMctlCompound + kCMctlCompound, + kCMovGraph }; const struct { @@ -75,6 +76,7 @@ const struct { { "CObjstateCommand", kCObjstateCommand }, { "CGameVar", kCGameVar }, { "CMctlCompound", kCMctlCompound }, + { "CMovGraph", kCMovGraph }, { 0, 0 } }; @@ -103,6 +105,8 @@ static CObject *createObject(int objectId) { return new CGameVar(); case kCMctlCompound: return new CMctlCompound(); + case kCMovGraph: + return new CMovGraph(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From a8d733b2b2c8c110bada0c99ac801ecc1ca0b844 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 16 Jun 2013 15:11:18 +0300 Subject: FULLPIPE: Split out motion-related classes --- engines/fullpipe/utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 34cf3c57a4..ba014a54cc 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -26,6 +26,7 @@ #include "fullpipe/utils.h" #include "fullpipe/objects.h" +#include "fullpipe/motion.h" namespace Fullpipe { -- cgit v1.2.3 From 5ea45699a889cdc15f33f449a4d8c20dd231b8e9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 16 Jun 2013 16:10:46 +0300 Subject: FULLPIPE: Reading CMovGraphNode --- engines/fullpipe/utils.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index ba014a54cc..4add1bae22 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -56,6 +56,23 @@ int MfcArchive::readCount() { return count; } +double MfcArchive::readDouble() { + // FIXME: This is utterly cruel and unportable + + union { + struct { + int32 a; + int32 b; + } i; + double d; + } tmp; + + tmp.i.a = readUint32LE(); + tmp.i.b = readUint32LE(); + + return tmp.d; +} + enum { kNullObject, kCInteraction, @@ -64,7 +81,9 @@ enum { kCObjstateCommand, kCGameVar, kCMctlCompound, - kCMovGraph + kCMovGraph, + kCMovGraphLink, + kCMovGraphNode }; const struct { @@ -78,6 +97,8 @@ const struct { { "CGameVar", kCGameVar }, { "CMctlCompound", kCMctlCompound }, { "CMovGraph", kCMovGraph }, + { "CMovGraphLink", kCMovGraphLink }, + { "CMovGraphNode", kCMovGraphNode }, { 0, 0 } }; @@ -108,6 +129,10 @@ static CObject *createObject(int objectId) { return new CMctlCompound(); case kCMovGraph: return new CMovGraph(); + case kCMovGraphLink: + return new CMovGraphLink(); + case kCMovGraphNode: + return new CMovGraphNode(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 630d5526ee9618ac1f84021b2306477e81e343d2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 18 Jun 2013 10:04:29 -0400 Subject: FULLPIPE: Implemented CReactParallel loader --- engines/fullpipe/utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 4add1bae22..df6c869a82 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -83,7 +83,8 @@ enum { kCMctlCompound, kCMovGraph, kCMovGraphLink, - kCMovGraphNode + kCMovGraphNode, + kCReactParallel }; const struct { @@ -99,6 +100,7 @@ const struct { { "CMovGraph", kCMovGraph }, { "CMovGraphLink", kCMovGraphLink }, { "CMovGraphNode", kCMovGraphNode }, + { "CReactParallel", kCReactParallel }, { 0, 0 } }; @@ -133,6 +135,8 @@ static CObject *createObject(int objectId) { return new CMovGraphLink(); case kCMovGraphNode: return new CMovGraphNode(); + case kCReactParallel: + return new CReactParallel(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 195d52e625b1d24ea0cbda3bb8d65043d1b5eea5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 18 Jun 2013 10:23:49 -0400 Subject: FULLPIPE: Implement loading CReactPolygonal. That completes .sc2 loading --- engines/fullpipe/utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index df6c869a82..6a09174bc6 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -84,7 +84,8 @@ enum { kCMovGraph, kCMovGraphLink, kCMovGraphNode, - kCReactParallel + kCReactParallel, + kCReactPolygonal }; const struct { @@ -101,6 +102,7 @@ const struct { { "CMovGraphLink", kCMovGraphLink }, { "CMovGraphNode", kCMovGraphNode }, { "CReactParallel", kCReactParallel }, + { "CReactPolygonal", kCReactPolygonal }, { 0, 0 } }; @@ -137,6 +139,8 @@ static CObject *createObject(int objectId) { return new CMovGraphNode(); case kCReactParallel: return new CReactParallel(); + case kCReactPolygonal: + return new CReactPolygonal(); default: error("Unknown objectId: %d", objectId); } -- cgit v1.2.3 From 8de8a901cb7946f5506e990224b78bdfb4ca737e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 20 Jun 2013 14:44:59 -0400 Subject: FULLPIPE: Put all inventory-related classes into separate file --- engines/fullpipe/utils.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 6a09174bc6..b3d035bf06 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -24,12 +24,65 @@ #include "common/file.h" -#include "fullpipe/utils.h" #include "fullpipe/objects.h" #include "fullpipe/motion.h" namespace Fullpipe { +bool CObject::loadFile(const char *fname) { + MfcArchive file; + + if (!file.open(fname)) + return false; + + return load(file); +} + +bool CObList::load(MfcArchive &file) { + int count = file.readCount(); + + debug(9, "CObList::count: %d:", count); + + for (int i = 0; i < count; i++) { + debug(9, "CObList::[%d]", i); + CObject *t = file.readClass(); + + push_back(*t); + } + + return true; +} + +bool CObArray::load(MfcArchive &file) { + int count = file.readCount(); + + resize(count); + + for (int i = 0; i < count; i++) { + CObject *t = file.readClass(); + + push_back(*t); + } + + return true; +} + +bool CDWordArray::load(MfcArchive &file) { + int count = file.readCount(); + + debug(9, "CDWordArray::count: %d", count); + + resize(count); + + for (int i = 0; i < count; i++) { + int32 t = file.readUint32LE(); + + push_back(t); + } + + return true; +} + char *MfcArchive::readPascalString(bool twoByte) { char *tmp; int len; -- cgit v1.2.3 From bb4ea153ffa5eaf5be3e912e206566f7c9278a87 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 20 Jun 2013 16:39:05 -0400 Subject: FULLPIPE: Started scene loading --- engines/fullpipe/utils.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index b3d035bf06..26c03ceeea 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -285,4 +285,16 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { return res; } +char *genFileName(int superId, int sceneId, const char *ext) { + char *s = (char *)calloc(256, 1); + + if (superId) { + snprintf(s, 255, "%04d%04d.%s", superId, sceneId, ext); + } else { + snprintf(s, 255, "%04d.%s", sceneId, ext); + } + + return s; +} + } // End of namespace Fullpipe -- cgit v1.2.3 From 925f41b9c4055d39498c61c8f22388176ee25cce Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 20 Jun 2013 17:21:37 -0400 Subject: FULLPIPE: Made MfcArchive work with both files and archives --- engines/fullpipe/utils.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 26c03ceeea..468d03b6f9 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -30,12 +30,14 @@ namespace Fullpipe { bool CObject::loadFile(const char *fname) { - MfcArchive file; + Common::File file; if (!file.open(fname)) return false; - return load(file); + MfcArchive archive(&file); + + return load(archive); } bool CObList::load(MfcArchive &file) { @@ -201,7 +203,7 @@ static CObject *createObject(int objectId) { return 0; } -MfcArchive::MfcArchive() { +MfcArchive::MfcArchive(Common::SeekableReadStream *stream) { for (int i = 0; classMap[i].name; i++) { _classMap[classMap[i].name] = classMap[i].id; } @@ -209,6 +211,8 @@ MfcArchive::MfcArchive() { _lastIndex = 1; _level = 0; + _stream = stream; + _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } -- cgit v1.2.3 From 29f323fd27d67aede4668e07984eabd69180aee5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 21 Jun 2013 21:30:38 -0400 Subject: FULLPIPE: Completed Background loading --- engines/fullpipe/utils.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 468d03b6f9..0462c4ec3e 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -23,9 +23,11 @@ #include "fullpipe/fullpipe.h" #include "common/file.h" +#include "common/memstream.h" #include "fullpipe/objects.h" #include "fullpipe/motion.h" +#include "fullpipe/ngiarchive.h" namespace Fullpipe { @@ -102,6 +104,64 @@ char *MfcArchive::readPascalString(bool twoByte) { return tmp; } +MemoryObject::MemoryObject() { + _filename = 0; + _field_8 = 0; + _field_C = 0; + _field_10 = -1; + _field_14 = 1; + _dataSize = 0; + _flags = 0; + _libHandle = 0; + _data = 0; +} + +bool MemoryObject::load(MfcArchive &file) { + _filename = file.readPascalString(); + + if (g_fullpipe->_currArchive) { + _field_14 = 0; + _libHandle = g_fullpipe->_currArchive; + } + + return true; +} + +void MemoryObject::loadFile(char *filename) { + if (!_data) { + if (g_fullpipe->_currArchive != _libHandle) { + assert(0); + } + + Common::SeekableReadStream *s = _libHandle->createReadStreamForMember(filename); + + if (s) { + debug(0, "Reading %s", filename); + assert(s->size() > 0); + _data = calloc(s->size(), 1); + s->read(_data, s->size()); + + delete s; + } + } +} + +MemoryObject2::MemoryObject2() { + _data2 = 0; +} + +bool MemoryObject2::load(MfcArchive &file) { + MemoryObject::load(file); + + _flags |= 1; + + if (_filename) { + MemoryObject::loadFile(_filename); + } + + return true; +} + int MfcArchive::readCount() { int count = readUint16LE(); -- cgit v1.2.3 From 1c1d8db613fccbab568efd1e57a86a419dc813c9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 13 Jul 2013 11:51:22 +0300 Subject: FULLPIPE: Now StaticANIObject is loaded fully --- engines/fullpipe/utils.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 0462c4ec3e..5b6c972a0a 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -358,6 +358,8 @@ char *genFileName(int superId, int sceneId, const char *ext) { snprintf(s, 255, "%04d.%s", sceneId, ext); } + debug(7, "genFileName: %s", s); + return s; } -- cgit v1.2.3 From 68c5cfdf2c35d82b506dd4fc0c4335608a22a404 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 23 Jun 2013 23:32:51 -0400 Subject: FULLPIPE: Continued Scene loading --- engines/fullpipe/utils.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 5b6c972a0a..ff3cd71d42 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -136,7 +136,6 @@ void MemoryObject::loadFile(char *filename) { Common::SeekableReadStream *s = _libHandle->createReadStreamForMember(filename); if (s) { - debug(0, "Reading %s", filename); assert(s->size() > 0); _data = calloc(s->size(), 1); s->read(_data, s->size()); -- cgit v1.2.3 From 305692fefe567228441e6edea5225d0b4853a9f8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 26 Jun 2013 19:46:11 -0400 Subject: FULLPIPE: Fix MemoryObject loading --- engines/fullpipe/utils.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index ff3cd71d42..14388f7db3 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -129,14 +129,12 @@ bool MemoryObject::load(MfcArchive &file) { void MemoryObject::loadFile(char *filename) { if (!_data) { - if (g_fullpipe->_currArchive != _libHandle) { - assert(0); - } - - Common::SeekableReadStream *s = _libHandle->createReadStreamForMember(filename); + Common::SeekableReadStream *s = g_fullpipe->_currArchive->createReadStreamForMember(filename); if (s) { assert(s->size() > 0); + + debug(0, "Loading %s", filename); _data = calloc(s->size(), 1); s->read(_data, s->size()); -- cgit v1.2.3 From d4e572843df01ce2307ca696ebc1db2775701205 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 26 Jun 2013 20:46:14 -0400 Subject: FULLPIPE: Transcode Cyrillic into UTF-8 for debugging convenience --- engines/fullpipe/utils.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 14388f7db3..0b75ab5ede 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -99,7 +99,7 @@ char *MfcArchive::readPascalString(bool twoByte) { tmp = (char *)calloc(len + 1, 1); read(tmp, len); - debug(9, "readPascalString: %d <%s>", len, tmp); + debug(9, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp)); return tmp; } @@ -360,4 +360,50 @@ char *genFileName(int superId, int sceneId, const char *ext) { return s; } +// Translates cp-1251..utf-8 +byte *transCyrillic(byte *s) { + static byte tmp[1024]; + + static int trans[] = { 0xa8, 0xd081, 0xb8, 0xd191, 0xc0, 0xd090, + 0xc1, 0xd091, 0xc2, 0xd092, 0xc3, 0xd093, 0xc4, 0xd094, + 0xc5, 0xd095, 0xc6, 0xd096, 0xc7, 0xd097, 0xc8, 0xd098, + 0xc9, 0xd099, 0xca, 0xd09a, 0xcb, 0xd09b, 0xcc, 0xd09c, + 0xcd, 0xd09d, 0xce, 0xd09e, 0xcf, 0xd09f, 0xd0, 0xd0a0, + 0xd1, 0xd0a1, 0xd2, 0xd0a2, 0xd3, 0xd0a3, 0xd4, 0xd0a4, + 0xd5, 0xd0a5, 0xd6, 0xd0a6, 0xd7, 0xd0a7, 0xd8, 0xd0a8, + 0xd9, 0xd0a9, 0xda, 0xd0aa, 0xdb, 0xd0ab, 0xdc, 0xd0ac, + 0xdd, 0xd0ad, 0xde, 0xd0ae, 0xdf, 0xd0af, 0xe0, 0xd0b0, + 0xe1, 0xd0b1, 0xe2, 0xd0b2, 0xe3, 0xd0b3, 0xe4, 0xd0b4, + 0xe5, 0xd0b5, 0xe6, 0xd0b6, 0xe7, 0xd0b7, 0xe8, 0xd0b8, + 0xe9, 0xd0b9, 0xea, 0xd0ba, 0xeb, 0xd0bb, 0xec, 0xd0bc, + 0xed, 0xd0bd, 0xee, 0xd0be, 0xef, 0xd0bf, 0xf0, 0xd180, + 0xf1, 0xd181, 0xf2, 0xd182, 0xf3, 0xd183, 0xf4, 0xd184, + 0xf5, 0xd185, 0xf6, 0xd186, 0xf7, 0xd187, 0xf8, 0xd188, + 0xf9, 0xd189, 0xfa, 0xd18a, 0xfb, 0xd18b, 0xfc, 0xd18c, + 0xfd, 0xd18d, 0xfe, 0xd18e, 0xff, 0xd18f }; + + int i = 0; + + for (byte *p = s; *p; p++) { + if (*p < 128) { + tmp[i++] = *p; + } else { + int j; + for (j = 0; trans[j]; j += 2) { + if (trans[j] == *p) { + tmp[i++] = (trans[j + 1] >> 8) & 0xff; + tmp[i++] = trans[j + 1] & 0xff; + break; + } + } + + assert(trans[j]); + } + } + + tmp[i] = 0; + + return tmp; +} + } // End of namespace Fullpipe -- cgit v1.2.3 From c2103bb9cd4b8b2958ea99c7797df2cd4f0905d5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 6 Jul 2013 22:56:11 +0300 Subject: FULLPIPE: Fix indentation --- engines/fullpipe/utils.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 0b75ab5ede..88a21a08fe 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -105,7 +105,7 @@ char *MfcArchive::readPascalString(bool twoByte) { } MemoryObject::MemoryObject() { - _filename = 0; + _filename = 0; _field_8 = 0; _field_C = 0; _field_10 = -1; @@ -169,20 +169,20 @@ int MfcArchive::readCount() { } double MfcArchive::readDouble() { - // FIXME: This is utterly cruel and unportable - - union { - struct { - int32 a; - int32 b; - } i; - double d; - } tmp; - - tmp.i.a = readUint32LE(); - tmp.i.b = readUint32LE(); - - return tmp.d; + // FIXME: This is utterly cruel and unportable + + union { + struct { + int32 a; + int32 b; + } i; + double d; + } tmp; + + tmp.i.a = readUint32LE(); + tmp.i.b = readUint32LE(); + + return tmp.d; } enum { @@ -380,7 +380,7 @@ byte *transCyrillic(byte *s) { 0xf1, 0xd181, 0xf2, 0xd182, 0xf3, 0xd183, 0xf4, 0xd184, 0xf5, 0xd185, 0xf6, 0xd186, 0xf7, 0xd187, 0xf8, 0xd188, 0xf9, 0xd189, 0xfa, 0xd18a, 0xfb, 0xd18b, 0xfc, 0xd18c, - 0xfd, 0xd18d, 0xfe, 0xd18e, 0xff, 0xd18f }; + 0xfd, 0xd18d, 0xfe, 0xd18e, 0xff, 0xd18f }; int i = 0; -- cgit v1.2.3 From f18e318f788d126b6c39232afaf0012ef401d55d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 11 Jul 2013 08:09:11 +0300 Subject: FULLPIPE: Bitmap loading --- engines/fullpipe/utils.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 88a21a08fe..be1bcd38a6 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -134,15 +134,27 @@ void MemoryObject::loadFile(char *filename) { if (s) { assert(s->size() > 0); - debug(0, "Loading %s", filename); - _data = calloc(s->size(), 1); - s->read(_data, s->size()); + _dataSize = s->size(); + + debug(0, "Loading %s (%d bytes)", filename, _dataSize); + _data = (byte *)calloc(_dataSize, 1); + s->read(_data, _dataSize); delete s; } } } +void *MemoryObject::getData() { + load(); + + if (_field_14 || _flags & 1) { + return _data; + } else { + error("Unhandled packed data"); + } +} + MemoryObject2::MemoryObject2() { _data2 = 0; } -- cgit v1.2.3 From 56cb726ebc4446dfab6e625502a1589253deae4f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 12 Jul 2013 09:03:02 +0300 Subject: FULLPIPE: Added lots of debug output, Picture::setAOIDs() implementation --- engines/fullpipe/utils.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index be1bcd38a6..9227d3dc2c 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -43,6 +43,7 @@ bool CObject::loadFile(const char *fname) { } bool CObList::load(MfcArchive &file) { + debug(5, "CObList::load()"); int count = file.readCount(); debug(9, "CObList::count: %d:", count); @@ -58,6 +59,7 @@ bool CObList::load(MfcArchive &file) { } bool CObArray::load(MfcArchive &file) { + debug(5, "CObArray::load()"); int count = file.readCount(); resize(count); @@ -72,6 +74,7 @@ bool CObArray::load(MfcArchive &file) { } bool CDWordArray::load(MfcArchive &file) { + debug(5, "CWordArray::load()"); int count = file.readCount(); debug(9, "CDWordArray::count: %d", count); @@ -117,6 +120,7 @@ MemoryObject::MemoryObject() { } bool MemoryObject::load(MfcArchive &file) { + debug(5, "MemoryObject::load()"); _filename = file.readPascalString(); if (g_fullpipe->_currArchive) { @@ -128,6 +132,7 @@ bool MemoryObject::load(MfcArchive &file) { } void MemoryObject::loadFile(char *filename) { + debug(0, "MemoryObject::loadFile(<%s>)", filename); if (!_data) { Common::SeekableReadStream *s = g_fullpipe->_currArchive->createReadStreamForMember(filename); @@ -145,7 +150,7 @@ void MemoryObject::loadFile(char *filename) { } } -void *MemoryObject::getData() { +byte *MemoryObject::getData() { load(); if (_field_14 || _flags & 1) { @@ -156,10 +161,11 @@ void *MemoryObject::getData() { } MemoryObject2::MemoryObject2() { - _data2 = 0; + _rows = 0; } bool MemoryObject2::load(MfcArchive &file) { + debug(5, "MemoryObject2::load()"); MemoryObject::load(file); _flags |= 1; -- cgit v1.2.3 From 1aa11bd86fccc700de84571a24e2fef957abce3d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 12 Jul 2013 10:38:30 +0300 Subject: FULLPIPE: Further work on inventory --- engines/fullpipe/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 9227d3dc2c..78440d8d53 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -132,7 +132,7 @@ bool MemoryObject::load(MfcArchive &file) { } void MemoryObject::loadFile(char *filename) { - debug(0, "MemoryObject::loadFile(<%s>)", filename); + debug(5, "MemoryObject::loadFile(<%s>)", filename); if (!_data) { Common::SeekableReadStream *s = g_fullpipe->_currArchive->createReadStreamForMember(filename); -- cgit v1.2.3 From 57e03aedd3924cc9f675594b4b504b4f42958b40 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 16 Jul 2013 23:54:18 +0300 Subject: FULLPIPE: Initial code for bitmap rendering --- engines/fullpipe/utils.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 78440d8d53..6ca6a8e6b9 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -108,7 +108,7 @@ char *MfcArchive::readPascalString(bool twoByte) { } MemoryObject::MemoryObject() { - _filename = 0; + _memfilename = 0; _field_8 = 0; _field_C = 0; _field_10 = -1; @@ -121,7 +121,14 @@ MemoryObject::MemoryObject() { bool MemoryObject::load(MfcArchive &file) { debug(5, "MemoryObject::load()"); - _filename = file.readPascalString(); + _memfilename = file.readPascalString(); + + if (char *p = strchr(_memfilename, '\\')) { + for (char *d = _memfilename; *p;) { + p++; + *d++ = *p; + } + } if (g_fullpipe->_currArchive) { _field_14 = 0; @@ -170,8 +177,10 @@ bool MemoryObject2::load(MfcArchive &file) { _flags |= 1; - if (_filename) { - MemoryObject::loadFile(_filename); + debug(5, "MemoryObject2::load: <%s>", _memfilename); + + if (_memfilename && *_memfilename) { + MemoryObject::loadFile(_memfilename); } return true; -- cgit v1.2.3 From ba93c8d0842f4b786e6bea2725cfd03e0e132d4c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 18 Jul 2013 15:38:58 +0300 Subject: FULLPIPE: Added links to articles with floating point structure description --- engines/fullpipe/utils.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 6ca6a8e6b9..f6e19256c1 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -197,6 +197,9 @@ int MfcArchive::readCount() { double MfcArchive::readDouble() { // FIXME: This is utterly cruel and unportable + // Some articles on the matter: + // http://randomascii.wordpress.com/2013/02/07/float-precision-revisited-nine-digit-float-portability/ + // http://randomascii.wordpress.com/2012/01/11/tricks-with-the-floating-point-format/ union { struct { -- cgit v1.2.3 From c76bec26467efc8cad4554cf44903c9f927d3a8c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 20 Jul 2013 16:08:05 +0300 Subject: FULLPIPE: Further work on sceneSwitcher() --- engines/fullpipe/utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index f6e19256c1..3e153c1801 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -28,6 +28,7 @@ #include "fullpipe/objects.h" #include "fullpipe/motion.h" #include "fullpipe/ngiarchive.h" +#include "fullpipe/messagequeue.h" namespace Fullpipe { -- cgit v1.2.3 From 5a182df0994081512fae724689507b9acc141d3a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 26 Jul 2013 15:39:17 +0300 Subject: FULLPIPE: Unstubbed StaticANIObject::addReverseStatics() --- engines/fullpipe/utils.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 3e153c1801..ec6b59029b 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -120,6 +120,12 @@ MemoryObject::MemoryObject() { _data = 0; } +MemoryObject::~MemoryObject() { + freeData(); + if (_memfilename) + free(_memfilename); +} + bool MemoryObject::load(MfcArchive &file) { debug(5, "MemoryObject::load()"); _memfilename = file.readPascalString(); @@ -168,10 +174,37 @@ byte *MemoryObject::getData() { } } +byte *MemoryObject::loadData() { + load(); + return _data; +} + +void MemoryObject::freeData() { + if (_data) + free(_data); + + _data = 0; +} + +bool MemoryObject::testFlags() { + if (_field_8) + return false; + + if (_flags & 1) + return true; + + return false; +} + MemoryObject2::MemoryObject2() { _rows = 0; } +MemoryObject2::~MemoryObject2() { + if (_rows) + free(_rows); +} + bool MemoryObject2::load(MfcArchive &file) { debug(5, "MemoryObject2::load()"); MemoryObject::load(file); @@ -187,6 +220,16 @@ bool MemoryObject2::load(MfcArchive &file) { return true; } +void MemoryObject2::copyData(byte *src, int dataSize) { + if (_data) + freeData(); + + _dataSize = dataSize; + _data = (byte *)malloc(dataSize); + + memcpy(_data, src, _dataSize); +} + int MfcArchive::readCount() { int count = readUint16LE(); -- cgit v1.2.3 From 67bbf26ecd546d59304ec437125508eb70aab9a1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 26 Jul 2013 15:42:11 +0300 Subject: FULLPIPE: Rename messagequeue.* to messages.* --- engines/fullpipe/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index ec6b59029b..900ca84eea 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -28,7 +28,7 @@ #include "fullpipe/objects.h" #include "fullpipe/motion.h" #include "fullpipe/ngiarchive.h" -#include "fullpipe/messagequeue.h" +#include "fullpipe/messages.h" namespace Fullpipe { -- cgit v1.2.3 From 60ca9f74ac8dfbfcee4bdae3ffbce039fce42854 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 11 Aug 2013 01:19:23 +0300 Subject: FULLPIPE: Fix bug with lost picture palettes --- engines/fullpipe/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 900ca84eea..3684d3ccf5 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -155,7 +155,7 @@ void MemoryObject::loadFile(char *filename) { _dataSize = s->size(); - debug(0, "Loading %s (%d bytes)", filename, _dataSize); + debug(5, "Loading %s (%d bytes)", filename, _dataSize); _data = (byte *)calloc(_dataSize, 1); s->read(_data, _dataSize); -- cgit v1.2.3 From cee12678dca97e52f57c926f646530cb3e23b176 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 11 Aug 2013 13:39:05 +0300 Subject: FULLPIPE: Implement sceneHandler01() --- engines/fullpipe/utils.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 3684d3ccf5..042afd28df 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -29,6 +29,7 @@ #include "fullpipe/motion.h" #include "fullpipe/ngiarchive.h" #include "fullpipe/messages.h" +#include "fullpipe/interaction.h" namespace Fullpipe { -- cgit v1.2.3 From 13059906c5f68bebb6344cf5617dc62243d146cf Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 12 Aug 2013 12:32:49 +0300 Subject: FULLPIPE: Rename base class variables to avoid ambigiuity --- engines/fullpipe/utils.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 042afd28df..fb777cc4f2 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -111,12 +111,12 @@ char *MfcArchive::readPascalString(bool twoByte) { MemoryObject::MemoryObject() { _memfilename = 0; - _field_8 = 0; - _field_C = 0; - _field_10 = -1; - _field_14 = 1; + _mfield_8 = 0; + _mfield_C = 0; + _mfield_10 = -1; + _mfield_14 = 1; _dataSize = 0; - _flags = 0; + _mflags = 0; _libHandle = 0; _data = 0; } @@ -139,7 +139,7 @@ bool MemoryObject::load(MfcArchive &file) { } if (g_fullpipe->_currArchive) { - _field_14 = 0; + _mfield_14 = 0; _libHandle = g_fullpipe->_currArchive; } @@ -168,7 +168,7 @@ void MemoryObject::loadFile(char *filename) { byte *MemoryObject::getData() { load(); - if (_field_14 || _flags & 1) { + if (_mfield_14 || _mflags & 1) { return _data; } else { error("Unhandled packed data"); @@ -188,10 +188,10 @@ void MemoryObject::freeData() { } bool MemoryObject::testFlags() { - if (_field_8) + if (_mfield_8) return false; - if (_flags & 1) + if (_mflags & 1) return true; return false; @@ -210,7 +210,7 @@ bool MemoryObject2::load(MfcArchive &file) { debug(5, "MemoryObject2::load()"); MemoryObject::load(file); - _flags |= 1; + _mflags |= 1; debug(5, "MemoryObject2::load: <%s>", _memfilename); -- cgit v1.2.3 From 6b242c0f9f02332697d36c6706df86cd674408ed Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 5 Sep 2013 00:13:16 +0300 Subject: FULLPIPE: Implement GameObject::canInteractAny() --- engines/fullpipe/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/fullpipe/utils.cpp') diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index fb777cc4f2..ee73aeaa64 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -54,7 +54,7 @@ bool CObList::load(MfcArchive &file) { debug(9, "CObList::[%d]", i); CObject *t = file.readClass(); - push_back(*t); + push_back(t); } return true; -- cgit v1.2.3