[Scummvm-git-logs] scummvm master -> 4629bdc52ac38130293091a6c38053fa07a2401f
npjg
noreply at scummvm.org
Sat Jan 11 01:58:07 UTC 2025
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ae7d4d5715 MEDIASTATION: Correctly print event handler ASCII code in debug statement
40b1999af8 MEDIASTATION: Allow built-in script functions to be operands.
24dc49e493 MEDIASTATION: Print stream position on subfile read error
e23ac28e4a MEDIASTATION: Make the Screen an asset, as in the original
c5f0676fce MEDIASTATION: Handle mousedown and keydown events
866016a76a MEDIASTATION: Respect startup visibility for hotspots
4629bdc52a MEDIASTATION: Implement hotspot mouse methods
Commit: ae7d4d57155661fb9c3a6b95a1f5513c49a58759
https://github.com/scummvm/scummvm/commit/ae7d4d57155661fb9c3a6b95a1f5513c49a58759
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Correctly print event handler ASCII code in debug statement
Changed paths:
engines/mediastation/mediascript/eventhandler.cpp
diff --git a/engines/mediastation/mediascript/eventhandler.cpp b/engines/mediastation/mediascript/eventhandler.cpp
index 3086de74c98..1bb5364bb76 100644
--- a/engines/mediastation/mediascript/eventhandler.cpp
+++ b/engines/mediastation/mediascript/eventhandler.cpp
@@ -49,7 +49,9 @@ Operand EventHandler::execute(uint assetId) {
}
case kAsciiCodeEventHandlerArgument: {
- debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (ASCII code = %d) **********", assetId, static_cast<uint>(_type), _argumentValue.u.i);
+ // Not sure why the ASCII code isn't just stored as an integer, but it's not.
+ uint asciiCode = static_cast<uint>(_argumentValue.u.f);
+ debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (ASCII code = %d) **********", assetId, static_cast<uint>(_type), asciiCode);
break;
}
Commit: 40b1999af8bdea6806708e010e4659fc749595ae
https://github.com/scummvm/scummvm/commit/40b1999af8bdea6806708e010e4659fc749595ae
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Allow built-in script functions to be operands.
This is necessary for supporting a couple methods that can be called on collections, most notably send(), which is not implemented yet.
Changed paths:
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/operand.cpp
engines/mediastation/mediascript/operand.h
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index cea7784b997..c9fa38b77ad 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -150,7 +150,7 @@ Operand CodeChunk::executeNextStatement() {
}
case (kInstructionTypeOperand): {
- OperandType operandType = OperandType(Datum(*_bytecode).u.i);
+ OperandType operandType = static_cast<OperandType>(Datum(*_bytecode).u.i);
debugC(8, kDebugScript, " *** Operand %d ***", static_cast<uint>(operandType));
Operand operand(operandType);
switch (operandType) {
@@ -176,6 +176,12 @@ Operand CodeChunk::executeNextStatement() {
return operand;
}
+ case kOperandTypeFunction: {
+ uint functionId = Datum(*_bytecode).u.i;
+ operand.putFunction(functionId);
+ return operand;
+ }
+
default: {
error("CodeChunk::getNextStatement(): Got unknown operand type 0x%d", operandType);
}
diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index 0ca729b8217..92112b09937 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -162,10 +162,10 @@ Variable *Operand::getVariable() {
}
}
-void Operand::putFunction(Function *function) {
+void Operand::putFunction(uint functionId) {
switch (_type) {
case kOperandTypeFunction: {
- _u.function = function;
+ _u.functionId = functionId;
break;
}
@@ -175,10 +175,10 @@ void Operand::putFunction(Function *function) {
}
}
-Function *Operand::getFunction() {
+uint Operand::getFunctionId() {
switch (_type) {
case kOperandTypeFunction: {
- return _u.function;
+ return _u.functionId;
}
default: {
diff --git a/engines/mediastation/mediascript/operand.h b/engines/mediastation/mediascript/operand.h
index 14988e60626..8e97ad69246 100644
--- a/engines/mediastation/mediascript/operand.h
+++ b/engines/mediastation/mediascript/operand.h
@@ -72,8 +72,8 @@ public:
void putVariable(Variable *variable);
Variable *getVariable();
- void putFunction(Function *function);
- Function *getFunction();
+ void putFunction(uint functionId);
+ uint getFunctionId();
void putAsset(uint32 assetId);
Asset *getAsset();
@@ -85,9 +85,9 @@ private:
OperandType _type = kOperandTypeEmpty;
union {
uint assetId = 0;
+ uint functionId;
Common::String *string;
Variable *variable;
- Function *function;
int i;
double d;
} _u;
Commit: 24dc49e493ddc5d61afe932c0343fd3e7275276c
https://github.com/scummvm/scummvm/commit/24dc49e493ddc5d61afe932c0343fd3e7275276c
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Print stream position on subfile read error
Changed paths:
engines/mediastation/subfile.cpp
diff --git a/engines/mediastation/subfile.cpp b/engines/mediastation/subfile.cpp
index afcf82d931d..173fd9fbdf1 100644
--- a/engines/mediastation/subfile.cpp
+++ b/engines/mediastation/subfile.cpp
@@ -34,7 +34,7 @@ Subfile::Subfile(Common::SeekableReadStream *stream) : _stream(stream) {
_rootChunk = nextChunk();
if (_rootChunk._id != MKTAG('R', 'I', 'F', 'F'))
// TODO: These need to be interpreted as ASCII.
- error("Subfile::Subfile(): Expected \"RIFF\" chunk, got %s", tag2str(_rootChunk._id));
+ error("Subfile::Subfile(): Expected \"RIFF\" chunk, got %s (@0x%llx)", tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
_stream->skip(4); // IMTS
// READ RATE CHUNK.
@@ -43,7 +43,7 @@ Subfile::Subfile(Common::SeekableReadStream *stream) : _stream(stream) {
// TODO: Figure out what this actually is.
Chunk rateChunk = nextChunk();
if (rateChunk._id != MKTAG('r', 'a', 't', 'e'))
- error("Subfile::Subfile(): Expected \"rate\" chunk, got %s", tag2str(_rootChunk._id));
+ error("Subfile::Subfile(): Expected \"rate\" chunk, got %s (@0x%llx)", tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
_rate = _stream->readUint32LE();
// READ PAST LIST CHUNK.
@@ -51,7 +51,7 @@ Subfile::Subfile(Common::SeekableReadStream *stream) : _stream(stream) {
// QUEUE UP THE FIRST DATA CHUNK.
if (_stream->readUint32BE() != MKTAG('d', 'a', 't', 'a'))
- error("Subfile::Subfile(): Expected \"data\" as first bytes of subfile, got %s", tag2str(rateChunk._id));
+ error("Subfile::Subfile(): Expected \"data\" as first bytes of subfile, got %s @0x%llx)", tag2str(rateChunk._id), static_cast<long long int>(_stream->pos()));
}
Chunk Subfile::nextChunk() {
Commit: e23ac28e4a6973452b0ac351a033910817ae3ece
https://github.com/scummvm/scummvm/commit/e23ac28e4a6973452b0ac351a033910817ae3ece
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Make the Screen an asset, as in the original
Changed paths:
A engines/mediastation/assets/screen.cpp
A engines/mediastation/assets/screen.h
engines/mediastation/context.cpp
engines/mediastation/context.h
engines/mediastation/module.mk
diff --git a/engines/mediastation/assets/screen.cpp b/engines/mediastation/assets/screen.cpp
new file mode 100644
index 00000000000..fa55bc04ffd
--- /dev/null
+++ b/engines/mediastation/assets/screen.cpp
@@ -0,0 +1,35 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "mediastation/assets/screen.h"
+#include "mediastation/debugchannels.h"
+
+namespace MediaStation {
+
+Operand Screen::callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) {
+ switch (methodId) {
+ default: {
+ error("Screen::callMethod(): Got unimplemented method ID %d", methodId);
+ }
+ }
+}
+
+} // End of namespace MediaStation
diff --git a/engines/mediastation/assets/screen.h b/engines/mediastation/assets/screen.h
new file mode 100644
index 00000000000..5028bc68b86
--- /dev/null
+++ b/engines/mediastation/assets/screen.h
@@ -0,0 +1,44 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MEDIASTATION_SCREEN_H
+#define MEDIASTATION_SCREEN_H
+
+#include "mediastation/assetheader.h"
+#include "mediastation/asset.h"
+#include "mediastation/mediascript/operand.h"
+
+namespace MediaStation {
+
+// A Screen holds asset data and processes event handlers for a Context.
+// The original separated them this way - there is a ContextParameters section,
+// then a Screen asset header.
+class Screen : public Asset {
+public:
+ Screen(AssetHeader *header) : Asset(header) {};
+ ~Screen() = default;
+
+ virtual Operand callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) override;
+};
+
+} // End of namespace MediaStation
+
+#endif
\ No newline at end of file
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index cbc063e4df7..6adb2273db9 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -34,6 +34,7 @@
#include "mediastation/assets/sprite.h"
#include "mediastation/assets/hotspot.h"
#include "mediastation/assets/timer.h"
+#include "mediastation/assets/screen.h"
namespace MediaStation {
@@ -231,9 +232,7 @@ bool Context::readHeaderSection(Subfile &subfile, Chunk &chunk) {
break;
case kAssetTypeScreen:
- if (_screenAsset != nullptr) {
- error("Context::readHeaderSection(): Got multiple screen assets in the same context");
- }
+ asset = new Screen(header);
_screenAsset = header;
break;
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index be6f3008783..fb7093513c4 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -53,6 +53,8 @@ public:
uint32 _fileSize;
Graphics::Palette *_palette = nullptr;
ContextParameters *_parameters = nullptr;
+ // TODO: Eliminate this screenAsset because the screen that this context
+ // represents is now an asset in itself.
AssetHeader *_screenAsset = nullptr;
private:
diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index ffecac42e15..6ddd845989a 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
assets/hotspot.o \
assets/timer.o \
assets/canvas.o \
+ assets/screen.o \
mediascript/eventhandler.o \
mediascript/codechunk.o \
mediascript/function.o \
Commit: c5f0676fce18e1b074a3129fc5ce49df8ad908d2
https://github.com/scummvm/scummvm/commit/c5f0676fce18e1b074a3129fc5ce49df8ad908d2
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Handle mousedown and keydown events
Changed paths:
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index c931ec4293a..cf57eea4954 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -171,10 +171,23 @@ void MediaStationEngine::processEvents() {
}
case Common::EVENT_KEYDOWN: {
+ // TODO: Reading the current mouse position for hotspots might not
+ // be right, need to verify.
+ Common::Point mousePos = g_system->getEventManager()->getMousePos();
+ Asset *hotspot = findAssetToAcceptMouseEvents(mousePos);
+ if (hotspot != nullptr) {
+ debugC(1, kDebugEvents, "EVENT_KEYDOWN (%d): Sent to hotspot %d", e.kbd.ascii, hotspot->getHeader()->_id);
+ hotspot->runKeyDownEventHandlerIfExists(e.kbd);
+ }
break;
}
case Common::EVENT_LBUTTONDOWN: {
+ Asset *hotspot = findAssetToAcceptMouseEvents(e.mouse);
+ if (hotspot != nullptr) {
+ debugC(1, kDebugEvents, "EVENT_LBUTTONDOWN (%d, %d): Sent to hotspot %d", e.mouse.x, e.mouse.y, hotspot->getHeader()->_id);
+ hotspot->runEventHandlerIfExists(kMouseDownEvent);
+ }
break;
}
@@ -284,4 +297,36 @@ void MediaStationEngine::branchToScreen(uint32 contextId) {
_currentContext = context;
}
+Asset *MediaStationEngine::findAssetToAcceptMouseEvents(Common::Point point) {
+ Asset *intersectingAsset = nullptr;
+ // The z-indices seem to be reversed, so the highest z-index number is
+ // actually the lowest asset.
+ int lowestZIndex = INT_MAX;
+
+ for (auto it = _assets.begin(); it != _assets.end(); ++it) {
+ Asset *asset = it->_value;
+ // TODO: Currently only hotspots are found, but other asset types can
+ // likely get mouse events too.
+ if (asset->type() == kAssetTypeHotspot) {
+ Common::Rect *boundingBox = asset->getHeader()->_boundingBox;
+ if (boundingBox == nullptr) {
+ error("Hotspot %d has no bounding box", asset->getHeader()->_id);
+ }
+
+ if (!asset->isActive()) {
+ continue;
+ }
+
+ if (boundingBox->contains(point)) {
+ if (asset->zIndex() < lowestZIndex) {
+ lowestZIndex = asset->zIndex();
+ intersectingAsset = asset;
+ }
+ }
+ }
+ }
+
+ return intersectingAsset;
+}
+
} // End of namespace MediaStation
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index 9b991454f20..3b972d25ac5 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -104,6 +104,7 @@ private:
Context *loadContext(uint32 contextId);
void setPaletteFromHeader(AssetHeader *header);
void branchToScreen(uint32 contextId);
+ Asset *findAssetToAcceptMouseEvents(Common::Point point);
};
extern MediaStationEngine *g_engine;
Commit: 866016a76a86c90102065310b8e36ad16bfbc29f
https://github.com/scummvm/scummvm/commit/866016a76a86c90102065310b8e36ad16bfbc29f
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Respect startup visibility for hotspots
Changed paths:
engines/mediastation/assetheader.h
engines/mediastation/assets/hotspot.cpp
engines/mediastation/assets/hotspot.h
diff --git a/engines/mediastation/assetheader.h b/engines/mediastation/assetheader.h
index 04f8ef7c18e..90e41d54c4c 100644
--- a/engines/mediastation/assetheader.h
+++ b/engines/mediastation/assetheader.h
@@ -69,6 +69,11 @@ enum AssetType {
kAssetTypeFunction = 0x0069 // FUN
};
+enum AssetStartupType {
+ kAssetStartupInactive = 0,
+ kAssetStartupActive = 1
+};
+
enum AssetHeaderSectionType {
kAssetHeaderEmptySection = 0x0000,
kAssetHeaderSoundEncoding1 = 0x0001,
diff --git a/engines/mediastation/assets/hotspot.cpp b/engines/mediastation/assets/hotspot.cpp
index 8d501e1ea12..72212213aa9 100644
--- a/engines/mediastation/assets/hotspot.cpp
+++ b/engines/mediastation/assets/hotspot.cpp
@@ -23,6 +23,12 @@
namespace MediaStation {
+Hotspot::Hotspot(AssetHeader *header) : Asset(header) {
+ if (header->_startup == kAssetStartupActive) {
+ _isActive = true;
+ }
+}
+
Operand Hotspot::callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) {
switch (methodId) {
case kMouseActivateMethod: {
diff --git a/engines/mediastation/assets/hotspot.h b/engines/mediastation/assets/hotspot.h
index 93cc89a84a3..99b1cc8caf7 100644
--- a/engines/mediastation/assets/hotspot.h
+++ b/engines/mediastation/assets/hotspot.h
@@ -30,7 +30,7 @@ namespace MediaStation {
class Hotspot : public Asset {
public:
- Hotspot(AssetHeader *header) : Asset(header) {};
+ Hotspot(AssetHeader *header);
virtual ~Hotspot() override = default;
virtual Operand callMethod(BuiltInMethod methodId, Common::Array<Operand> &args) override;
Commit: 4629bdc52ac38130293091a6c38053fa07a2401f
https://github.com/scummvm/scummvm/commit/4629bdc52ac38130293091a6c38053fa07a2401f
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-10T20:41:35-05:00
Commit Message:
MEDIASTATION: Implement hotspot mouse methods
Changed paths:
engines/mediastation/assets/hotspot.cpp
diff --git a/engines/mediastation/assets/hotspot.cpp b/engines/mediastation/assets/hotspot.cpp
index 72212213aa9..c06cf852cb2 100644
--- a/engines/mediastation/assets/hotspot.cpp
+++ b/engines/mediastation/assets/hotspot.cpp
@@ -33,13 +33,13 @@ Operand Hotspot::callMethod(BuiltInMethod methodId, Common::Array<Operand> &args
switch (methodId) {
case kMouseActivateMethod: {
assert(args.empty());
- warning("Hotspot::callMethod(): BuiltInFunction::mouseActivate is not implemented");
+ _isActive = true;
return Operand();
}
case kMouseDeactivateMethod: {
assert(args.empty());
- warning("Hotspot::callMethod(): BuiltInFunction::mouseDeactivate is not implemented");
+ _isActive = false;
return Operand();
}
More information about the Scummvm-git-logs
mailing list