[Scummvm-git-logs] scummvm master -> 77b3c31bdb2ba39c258257a2608efb9c3a29add4
neuromancer
noreply at scummvm.org
Sat Apr 29 20:41:24 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d43871de98 FREESCAPE: allow to parse conditions using the ACTIVATED trigger for castle
77b3c31bdb FREESCAPE: basic support for control flow opcodes of castle
Commit: d43871de98b1255c8ddcba8cc45fe32b9854f437
https://github.com/scummvm/scummvm/commit/d43871de98b1255c8ddcba8cc45fe32b9854f437
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-29T22:43:15+02:00
Commit Message:
FREESCAPE: allow to parse conditions using the ACTIVATED trigger for castle
Changed paths:
engines/freescape/games/driller/driller.cpp
engines/freescape/language/8bitDetokeniser.cpp
engines/freescape/language/8bitDetokeniser.h
engines/freescape/language/instruction.cpp
engines/freescape/loaders/8bitBinaryLoader.cpp
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index 5144aa8ba11..902354fcce9 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -206,7 +206,7 @@ void DrillerEngine::loadAssetsFullGame() {
conditionArray.push_back(0x7f);
conditionArray.push_back(0x0);
- Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions);
+ Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, false);
debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
_areaMap[18]->_conditions.push_back(instructions);
_areaMap[18]->_conditionSources.push_back(conditionSource);
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 3b76b2fa9e6..2e97886037b 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -33,7 +33,7 @@ uint8 k8bitMaxVariable = 64;
uint8 k8bitMaxShield = 64;
uint8 k8bitMaxEnergy = 64;
-Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions) {
+Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions, bool enableActivated) {
Common::String detokenisedStream;
Common::Array<uint8>::size_type bytePointer = 0;
Common::Array<uint8>::size_type sizeOfTokenisedContent = tokenisedCondition.size();
@@ -63,7 +63,9 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
// get the conditional type of the next operation
uint8 conditionalByte = tokenisedCondition[bytePointer];
- if (conditionalByte & 0x80)
+ if ((conditionalByte & 0xc0) && enableActivated) {
+ newConditional = Token::ACTIVATEDQ;
+ } else if (conditionalByte & 0x80)
newConditional = Token::SHOTQ;
else if (conditionalByte & 0x40)
newConditional = Token::TIMERQ;
@@ -92,6 +94,8 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
detokenisedStream += "IF TIMER? THEN\n";
else if (oldConditional == Token::COLLIDEDQ)
detokenisedStream += "IF COLLIDED? THEN\n";
+ else if (oldConditional == Token::ACTIVATEDQ)
+ detokenisedStream += "IF ACTIVATED? THEN\n";
else
error("Invalid conditional: %x", oldConditional);
}
diff --git a/engines/freescape/language/8bitDetokeniser.h b/engines/freescape/language/8bitDetokeniser.h
index b0c1047bb40..08326c2d5c9 100644
--- a/engines/freescape/language/8bitDetokeniser.h
+++ b/engines/freescape/language/8bitDetokeniser.h
@@ -40,7 +40,7 @@ extern uint8 k8bitMaxVariable;
extern uint8 k8bitMaxShield;
extern uint8 k8bitMaxEnergy;
-Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions);
+Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions, bool enableActivated);
} // End of namespace Freescape
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 5fc29ed61df..84f021f32a2 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -133,13 +133,20 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
debugC(1, kFreescapeDebugCode, "Executing ip: %d with type %d in code with size: %d", ip, instruction.getType(), codeSize);
switch (instruction.getType()) {
default:
- if (!isCastle())
- error("Instruction %x at ip: %d not implemented!", instruction.getType(), ip);
+ //if (!isCastle())
+ error("Instruction %x at ip: %d not implemented!", instruction.getType(), ip);
break;
case Token::NOP:
debugC(1, kFreescapeDebugCode, "Executing NOP at ip: %d", ip);
break;
+ case Token::ACTIVATEDQ:
+ if (collided) // TODO: implement interaction
+ executeCode(*instruction._thenInstructions, shot, collided, timer);
+ // else branch is always empty
+ assert(instruction._elseInstructions == nullptr);
+ break;
+
case Token::COLLIDEDQ:
if (collided)
executeCode(*instruction._thenInstructions, shot, collided, timer);
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 35f44a3225b..61265e7c4f2 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -187,7 +187,7 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
Common::String conditionSource;
if (byteSizeOfObject) {
Common::Array<uint8> conditionArray = readArray(file, byteSizeOfObject);
- conditionSource = detokenise8bitCondition(conditionArray, instructions);
+ conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
// instructions = getInstructions(conditionSource);
debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
}
@@ -257,7 +257,7 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
// grab the object condition, if there is one
if (byteSizeOfObject) {
Common::Array<uint8> conditionArray = readArray(file, byteSizeOfObject);
- conditionSource = detokenise8bitCondition(conditionArray, instructions);
+ conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
}
debugC(1, kFreescapeDebugParser, "End of object at %lx", file->pos());
@@ -536,7 +536,7 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
// get the condition
if (lengthOfCondition > 0) {
Common::Array<uint8> conditionArray = readArray(file, lengthOfCondition);
- Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions);
+ Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
area->_conditions.push_back(instructions);
area->_conditionSources.push_back(conditionSource);
debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
@@ -629,7 +629,7 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
// get the condition
if (lengthOfCondition > 0) {
Common::Array<uint8> conditionArray = readArray(file, lengthOfCondition);
- Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions);
+ Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
_conditions.push_back(instructions);
_conditionSources.push_back(conditionSource);
debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
Commit: 77b3c31bdb2ba39c258257a2608efb9c3a29add4
https://github.com/scummvm/scummvm/commit/77b3c31bdb2ba39c258257a2608efb9c3a29add4
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-04-29T22:43:15+02:00
Commit Message:
FREESCAPE: basic support for control flow opcodes of castle
Changed paths:
engines/freescape/freescape.h
engines/freescape/language/8bitDetokeniser.cpp
engines/freescape/language/instruction.cpp
engines/freescape/language/token.h
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index eb1f87275d1..385745bb4db 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -281,6 +281,7 @@ public:
void executeCode(FCLInstructionVector &code, bool shot, bool collided, bool timer);
// Instructions
+ bool checkIfGreaterOrEqual(FCLInstruction &instruction);
void executeIncrementVariable(FCLInstruction &instruction);
void executeDecrementVariable(FCLInstruction &instruction);
void executeSetVariable(FCLInstruction &instruction);
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 2e97886037b..37b76ab9854 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -374,28 +374,32 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
case 44:
detokenisedStream += "ELSE ";
+ currentInstruction = FCLInstruction(Token::ELSE);
+ conditionalInstructions->push_back(currentInstruction);
+ currentInstruction = FCLInstruction(Token::UNKNOWN);
+ numberOfArguments = 0;
break;
case 45:
detokenisedStream += "ENDIF ";
+ currentInstruction = FCLInstruction(Token::ENDIF);
+ conditionalInstructions->push_back(currentInstruction);
+ currentInstruction = FCLInstruction(Token::UNKNOWN);
+ numberOfArguments = 0;
break;
case 46:
- detokenisedStream += "IFGTE ";
- detokenisedStream += Common::String::format("(v%d, %d)", (int)tokenisedCondition[bytePointer], (int)tokenisedCondition[bytePointer + 1]);
- bytePointer += 2;
- numberOfArguments = 0;
+ detokenisedStream += "IFGTE (v";
+ currentInstruction = FCLInstruction(Token::IFGTEQ);
break;
case 47:
- detokenisedStream += "IFLTE ";
- detokenisedStream += Common::String::format("(v%d, %d)", (int)tokenisedCondition[bytePointer], (int)tokenisedCondition[bytePointer + 1]);
- bytePointer += 2;
- numberOfArguments = 0;
+ detokenisedStream += "IFLTE (v";
+ currentInstruction = FCLInstruction(Token::IFGTEQ);
break;
case 48:
- detokenisedStream += "EXECUTE ";
+ detokenisedStream += "EXECUTE (";
currentInstruction = FCLInstruction(Token::EXECUTE);
break;
}
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 84f021f32a2..b27b8bbffc9 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -126,11 +126,19 @@ void FreescapeEngine::executeLocalGlobalConditions(bool shot, bool collided, boo
void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool collided, bool timer) {
assert(!(shot && collided));
int ip = 0;
+ bool skip = false;
int codeSize = code.size();
assert(codeSize > 0);
while (ip <= codeSize - 1) {
FCLInstruction &instruction = code[ip];
debugC(1, kFreescapeDebugCode, "Executing ip: %d with type %d in code with size: %d", ip, instruction.getType(), codeSize);
+
+ if (skip && instruction.getType() != Token::ELSE && instruction.getType() != Token::ENDIF) {
+ debugC(1, kFreescapeDebugCode, "Instruction skipped!");
+ ip++;
+ continue;
+ }
+
switch (instruction.getType()) {
default:
//if (!isCastle())
@@ -141,7 +149,7 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
break;
case Token::ACTIVATEDQ:
- if (collided) // TODO: implement interaction
+ if (shot) // TODO: implement interaction
executeCode(*instruction._thenInstructions, shot, collided, timer);
// else branch is always empty
assert(instruction._elseInstructions == nullptr);
@@ -169,6 +177,18 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
if (executeEndIfNotEqual(instruction))
ip = codeSize;
break;
+ case Token::IFGTEQ:
+ skip = !checkIfGreaterOrEqual(instruction);
+ break;
+
+ case Token::ELSE:
+ skip = !skip;
+ break;
+
+ case Token::ENDIF:
+ skip = false;
+ break;
+
case Token::SWAPJET:
executeSwapJet(instruction);
break;
@@ -264,7 +284,7 @@ void FreescapeEngine::executeDelay(FCLInstruction &instruction) {
void FreescapeEngine::executePrint(FCLInstruction &instruction) {
uint16 index = instruction._source - 1;
- debugC(1, kFreescapeDebugCode, "Printing message %d", index);
+ debugC(1, kFreescapeDebugCode, "Printing message %d: \"%s\"", index, _messagesList[index].c_str());
_currentAreaMessages.clear();
_currentAreaMessages.push_back(_messagesList[index]);
}
@@ -335,6 +355,14 @@ bool FreescapeEngine::executeEndIfVisibilityIsEqual(FCLInstruction &instruction)
return (obj->isInvisible() == (value != 0));
}
+bool FreescapeEngine::checkIfGreaterOrEqual(FCLInstruction &instruction) {
+ uint16 variable = instruction._source;
+ uint16 value = instruction._destination;
+ debugC(1, kFreescapeDebugCode, "Check if variable %d is greater than equal to %d!", variable, value);
+ return (_gameStateVars[variable] >= value);
+}
+
+
bool FreescapeEngine::executeEndIfNotEqual(FCLInstruction &instruction) {
uint16 variable = instruction._source;
uint16 value = instruction._destination;
diff --git a/engines/freescape/language/token.h b/engines/freescape/language/token.h
index 77ec65b2dde..d108d93d780 100644
--- a/engines/freescape/language/token.h
+++ b/engines/freescape/language/token.h
@@ -80,8 +80,8 @@ public:
TRIGANIM,
UPDATEI,
VAREQ,
- VARGQ,
- VARLQ,
+ IFGTEQ,
+ IFGLEQ,
VISQ,
VIS,
WAIT,
More information about the Scummvm-git-logs
mailing list