[Scummvm-git-logs] scummvm master -> 3b56dc346d31e27caa025f993e1372fa9fbf7462
neuromancer
noreply at scummvm.org
Fri Aug 11 19:36:04 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3b56dc346d FREESCAPE: improved parsing and handling of groups
Commit: 3b56dc346d31e27caa025f993e1372fa9fbf7462
https://github.com/scummvm/scummvm/commit/3b56dc346d31e27caa025f993e1372fa9fbf7462
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-08-11T21:30:20+02:00
Commit Message:
FREESCAPE: improved parsing and handling of groups
Changed paths:
engines/freescape/area.cpp
engines/freescape/freescape.h
engines/freescape/language/instruction.cpp
engines/freescape/objects/geometricobject.cpp
engines/freescape/objects/group.cpp
engines/freescape/objects/group.h
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 4bfacfbb996..6947e6ff256 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -235,6 +235,10 @@ void Area::draw(Freescape::Renderer *gfx, uint32 ticks) {
}
void Area::drawGroup(Freescape::Renderer *gfx, Group* group, uint32 ticks) {
+ if (group->_objectOperations[0] == 0x10)
+ if (!group->_active)
+ return;
+
uint32 groupSize = group->_objects.size();
uint32 frameSize = group->_objectPositions.size();
for (uint32 i = 0; i < groupSize ; i++) {
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 35ae836079e..7766619fcbb 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -315,6 +315,7 @@ public:
void executeSwapJet(FCLInstruction &instruction);
virtual void executePrint(FCLInstruction &instruction);
void executeSPFX(FCLInstruction &instruction);
+ void executeStartAnim(FCLInstruction &instruction);
// Sound
Audio::SoundHandle _soundFxHandle;
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 907b1ff0540..c17331353f7 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -235,6 +235,9 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
case Token::SCREEN:
// TODO
break;
+ case Token::STARTANIM:
+ executeStartAnim(instruction);
+ break;
case Token::BITNOTEQ:
if (executeEndIfBitNotEqual(instruction))
ip = codeSize;
@@ -647,4 +650,14 @@ void FreescapeEngine::executeSwapJet(FCLInstruction &instruction) {
// TODO: implement the rest of the changes (e.g. border)
}
+void FreescapeEngine::executeStartAnim(FCLInstruction &instruction) {
+ uint16 groupID = instruction._source + 1;
+ debugC(1, kFreescapeDebugCode, "Staring animation of group %d", groupID);
+ Group *group = (Group *)_currentArea->objectWithID(groupID);
+ assert(group);
+ assert(group->getType() == kGroupType);
+ group->_active = true;
+}
+
+
} // End of namespace Freescape
diff --git a/engines/freescape/objects/geometricobject.cpp b/engines/freescape/objects/geometricobject.cpp
index b3f444b0746..2f0071aed86 100644
--- a/engines/freescape/objects/geometricobject.cpp
+++ b/engines/freescape/objects/geometricobject.cpp
@@ -123,6 +123,7 @@ GeometricObject::GeometricObject(
FCLInstructionVector conditionInstructions_,
Common::String conditionSource_) {
_type = type_;
+ assert(_type != kGroupType);
_flags = flags_;
if (isDestroyed()) // If the object is destroyed, restore it
diff --git a/engines/freescape/objects/group.cpp b/engines/freescape/objects/group.cpp
index 7804a062bfa..a9218ed99cd 100644
--- a/engines/freescape/objects/group.cpp
+++ b/engines/freescape/objects/group.cpp
@@ -21,6 +21,7 @@
#include "freescape/freescape.h"
#include "freescape/objects/group.h"
#include "freescape/objects/geometricobject.h"
+#include "freescape/language/8bitDetokeniser.h"
namespace Freescape {
@@ -28,6 +29,7 @@ Group::Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_) {
_objectID = objectID_;
_flags = flags_;
_scale = 0;
+ _active = false;
int i;
for (i = 0; i < 5; i++) {
@@ -35,18 +37,37 @@ Group::Group(uint16 objectID_, uint16 flags_, const Common::Array<byte> data_) {
if (data_[i] > 0)
_objectIds.push_back(data_[i]);
}
- i = 5;
- while (i < int(data_.size() - 4)) {
- debugC(1, kFreescapeDebugParser, "group data[%d] = %d (index) ", i, data_[i]);
- _objectIndices.push_back(data_[i]);
-
- debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 1, data_[i + 1]);
- debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 2, data_[i + 2]);
- debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 3, data_[i + 3]);
- Math::Vector3d position(data_[i + 1], data_[i + 2], data_[i + 3]);
- _objectPositions.push_back(position);
-
- i = i + 4;
+ for (i = 5; i < 9; i++)
+ debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i, data_[i]);
+ i = 9;
+ while (i < int(data_.size())) {
+ int operation = data_[i];
+ debugC(1, kFreescapeDebugParser, "group data[%d] = %d (operation)", i, operation);
+ if (operation == 0x80)
+ i++;
+ else if (operation == 0x01) {
+ i++;
+ int scriptSize = data_[i];
+ assert(scriptSize > 0);
+ Common::Array<uint16> conditionData;
+ FCLInstructionVector instructions;
+ for (int j = i + 1; j < i + 1 + scriptSize && j < int(data_.size()); j++) {
+ conditionData.push_back(data_[j]);
+ }
+ Common::String conditionStr = detokenise8bitCondition(conditionData, instructions, false);
+ debugC(1, kFreescapeDebugParser, "group condition:\n%s", conditionStr.c_str());
+ i = i + 1 + scriptSize;
+ } else {
+ _objectOperations.push_back(operation);
+ if (i < int(data_.size() - 4)) {
+ debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 1, data_[i + 1]);
+ debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 2, data_[i + 2]);
+ debugC(1, kFreescapeDebugParser, "group data[%d] = %d", i + 3, data_[i + 3]);
+ Math::Vector3d position(data_[i + 1], data_[i + 2], data_[i + 3]);
+ _objectPositions.push_back(position);
+ }
+ i = i + 4;
+ }
}
if (isDestroyed()) // If the object is destroyed, restore it
diff --git a/engines/freescape/objects/group.h b/engines/freescape/objects/group.h
index 04587dbc386..c001a2b00c9 100644
--- a/engines/freescape/objects/group.h
+++ b/engines/freescape/objects/group.h
@@ -35,9 +35,10 @@ public:
Common::Array<Object *> _objects;
Common::Array<Math::Vector3d> _origins;
Common::Array<Math::Vector3d> _objectPositions;
- Common::Array<int16> _objectIndices;
+ Common::Array<int16> _objectOperations;
Common::Array<int16> _objectIds;
int _scale;
+ bool _active;
ObjectType getType() override { return ObjectType::kGroupType; };
bool isDrawable() override { return true; }
More information about the Scummvm-git-logs
mailing list