[Scummvm-git-logs] scummvm master -> 0fb6764759ad04b4d895c7cb95305b6f7393b0c4
npjg
noreply at scummvm.org
Sun Oct 19 17:37:31 UTC 2025
This automated email contains information about 13 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
aaf21a93d9 MEDIASTATION: Rename assets to actors
a3d915f0e7 MEDIASTATION: Rename asset to actor types
3a22eb510d MEDIASTATION: Migrate warnings/errors to use __func__
aba7527286 MEDIASTATION: Rename Function to ScriptFunction
ed1323dd68 MEDIASTATION: Refactor script constants to use hex digits
fe63ca5dc3 MEDIASTATION: Modularize stream loading, as in the original
1e64cc6244 MEDIASTATION: Rename context file number to ID
51541be708 MEDIASTATION: Rename file and stream maps
2bb2f2e747 MEDIASTATION: Add missing script constant labels
4a24261fc0 MEDIASTATION: Fix CLIPs that weren't actually assigning anything
9d25beea09 MEDIASTATION: Fix Lion King detection entry
72aa133469 MEDIASTATION: Fix early engine versions movie loading
0fb6764759 MEDIASTATION: Add preliminary work on stages
Commit: aaf21a93d9a0f96c13afbad67d5f666a827d081d
https://github.com/scummvm/scummvm/commit/aaf21a93d9a0f96c13afbad67d5f666a827d081d
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Rename assets to actors
This brings the names in line with the names in the debug symbols.
Changed paths:
A engines/mediastation/actor.cpp
A engines/mediastation/actor.h
A engines/mediastation/actors/canvas.cpp
A engines/mediastation/actors/canvas.h
A engines/mediastation/actors/document.cpp
A engines/mediastation/actors/document.h
A engines/mediastation/actors/font.cpp
A engines/mediastation/actors/font.h
A engines/mediastation/actors/hotspot.cpp
A engines/mediastation/actors/hotspot.h
A engines/mediastation/actors/image.cpp
A engines/mediastation/actors/image.h
A engines/mediastation/actors/movie.cpp
A engines/mediastation/actors/movie.h
A engines/mediastation/actors/palette.cpp
A engines/mediastation/actors/palette.h
A engines/mediastation/actors/path.cpp
A engines/mediastation/actors/path.h
A engines/mediastation/actors/screen.cpp
A engines/mediastation/actors/screen.h
A engines/mediastation/actors/sound.cpp
A engines/mediastation/actors/sound.h
A engines/mediastation/actors/sprite.cpp
A engines/mediastation/actors/sprite.h
A engines/mediastation/actors/text.cpp
A engines/mediastation/actors/text.h
A engines/mediastation/actors/timer.cpp
A engines/mediastation/actors/timer.h
R engines/mediastation/asset.cpp
R engines/mediastation/asset.h
R engines/mediastation/assets/canvas.cpp
R engines/mediastation/assets/canvas.h
R engines/mediastation/assets/document.cpp
R engines/mediastation/assets/document.h
R engines/mediastation/assets/font.cpp
R engines/mediastation/assets/font.h
R engines/mediastation/assets/hotspot.cpp
R engines/mediastation/assets/hotspot.h
R engines/mediastation/assets/image.cpp
R engines/mediastation/assets/image.h
R engines/mediastation/assets/movie.cpp
R engines/mediastation/assets/movie.h
R engines/mediastation/assets/palette.cpp
R engines/mediastation/assets/palette.h
R engines/mediastation/assets/path.cpp
R engines/mediastation/assets/path.h
R engines/mediastation/assets/screen.cpp
R engines/mediastation/assets/screen.h
R engines/mediastation/assets/sound.cpp
R engines/mediastation/assets/sound.h
R engines/mediastation/assets/sprite.cpp
R engines/mediastation/assets/sprite.h
R engines/mediastation/assets/text.cpp
R engines/mediastation/assets/text.h
R engines/mediastation/assets/timer.cpp
R engines/mediastation/assets/timer.h
engines/mediastation/bitmap.h
engines/mediastation/boot.cpp
engines/mediastation/boot.h
engines/mediastation/context.cpp
engines/mediastation/context.h
engines/mediastation/datafile.h
engines/mediastation/graphics.cpp
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/collection.cpp
engines/mediastation/mediascript/eventhandler.cpp
engines/mediastation/mediascript/eventhandler.h
engines/mediastation/mediascript/scriptvalue.cpp
engines/mediastation/mediascript/scriptvalue.h
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
engines/mediastation/module.mk
diff --git a/engines/mediastation/asset.cpp b/engines/mediastation/actor.cpp
similarity index 96%
rename from engines/mediastation/asset.cpp
rename to engines/mediastation/actor.cpp
index ab92d7b3b22..ab14c76ca62 100644
--- a/engines/mediastation/asset.cpp
+++ b/engines/mediastation/actor.cpp
@@ -21,7 +21,7 @@
#include "common/util.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/debugchannels.h"
#include "mediastation/mediascript/scriptconstants.h"
#include "mediastation/mediastation.h"
@@ -69,7 +69,7 @@ void Asset::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
default:
- error("Got unimplemented asset parameter 0x%x", static_cast<uint>(paramType));
+ error("Got unimplemented actor parameter 0x%x", static_cast<uint>(paramType));
}
}
@@ -78,11 +78,11 @@ ScriptValue Asset::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
void Asset::readChunk(Chunk &chunk) {
- error("Asset::readChunk(): Chunk reading for asset type 0x%x is not implemented", static_cast<uint>(_type));
+ error("Asset::readChunk(): Chunk reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
}
void Asset::readSubfile(Subfile &subfile, Chunk &chunk) {
- error("Asset::readSubfile(): Subfile reading for asset type 0x%x is not implemented", static_cast<uint>(_type));
+ error("Asset::readSubfile(): Subfile reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
}
void Asset::processTimeEventHandlers() {
@@ -115,12 +115,12 @@ void Asset::runEventHandlerIfExists(EventType eventType, const ScriptValue &arg)
}
if (arg == argToCheck) {
- debugC(5, kDebugScript, "Executing handler for event type %s on asset %d", eventTypeToStr(eventType), _id);
+ debugC(5, kDebugScript, "Executing handler for event type %s on actor %d", eventTypeToStr(eventType), _id);
eventHandler->execute(_id);
return;
}
}
- debugC(5, kDebugScript, "No event handler for event type %s on asset %d", eventTypeToStr(eventType), _id);
+ debugC(5, kDebugScript, "No event handler for event type %s on actor %d", eventTypeToStr(eventType), _id);
}
void Asset::runEventHandlerIfExists(EventType eventType) {
@@ -242,7 +242,7 @@ void SpatialEntity::readParameter(Chunk &chunk, AssetHeaderSectionType paramType
break;
case kAssetHeaderAssetReference:
- _assetReference = chunk.readTypedUint16();
+ _actorReference = chunk.readTypedUint16();
break;
default:
diff --git a/engines/mediastation/asset.h b/engines/mediastation/actor.h
similarity index 97%
rename from engines/mediastation/asset.h
rename to engines/mediastation/actor.h
index cdc2dffff35..614a1a02139 100644
--- a/engines/mediastation/asset.h
+++ b/engines/mediastation/actor.h
@@ -135,8 +135,8 @@ public:
virtual void initFromParameterStream(Chunk &chunk);
virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType);
- // These are not pure virtual so if an asset doesn't read any chunks or
- // subfiles it doesn't need to just implement these with an error message.
+ // These are not pure virtual so if an actor doesnʻt read any chunks or
+ // subfiles it doesnʻt need to just implement these with an error message.
virtual void readChunk(Chunk &chunk);
virtual void readSubfile(Subfile &subfile, Chunk &chunk);
@@ -151,7 +151,7 @@ public:
void setContextId(uint id) { _contextId = id; }
uint32 _chunkReference = 0;
- uint _assetReference = 0;
+ uint _actorReference = 0;
protected:
AssetType _type = kAssetTypeEmpty;
diff --git a/engines/mediastation/assets/canvas.cpp b/engines/mediastation/actors/canvas.cpp
similarity index 97%
rename from engines/mediastation/assets/canvas.cpp
rename to engines/mediastation/actors/canvas.cpp
index d5096f6f075..a6cb59d05c4 100644
--- a/engines/mediastation/assets/canvas.cpp
+++ b/engines/mediastation/actors/canvas.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/canvas.h"
+#include "mediastation/actors/canvas.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/canvas.h b/engines/mediastation/actors/canvas.h
similarity index 97%
rename from engines/mediastation/assets/canvas.h
rename to engines/mediastation/actors/canvas.h
index 485f4821256..7395b031a69 100644
--- a/engines/mediastation/assets/canvas.h
+++ b/engines/mediastation/actors/canvas.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_CANVAS_H
#define MEDIASTATION_CANVAS_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/document.cpp b/engines/mediastation/actors/document.cpp
similarity index 97%
rename from engines/mediastation/assets/document.cpp
rename to engines/mediastation/actors/document.cpp
index 8c09e95138c..7b224030886 100644
--- a/engines/mediastation/assets/document.cpp
+++ b/engines/mediastation/actors/document.cpp
@@ -20,7 +20,7 @@
*/
#include "mediastation/mediastation.h"
-#include "mediastation/assets/document.h"
+#include "mediastation/actors/document.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/document.h b/engines/mediastation/actors/document.h
similarity index 97%
rename from engines/mediastation/assets/document.h
rename to engines/mediastation/actors/document.h
index 6e5a0f1dbef..6aef876b8bd 100644
--- a/engines/mediastation/assets/document.h
+++ b/engines/mediastation/actors/document.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_DOCUMENT_H
#define MEDIASTATION_DOCUMENT_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/font.cpp b/engines/mediastation/actors/font.cpp
similarity index 98%
rename from engines/mediastation/assets/font.cpp
rename to engines/mediastation/actors/font.cpp
index bfc94798cdc..37daf55575e 100644
--- a/engines/mediastation/assets/font.cpp
+++ b/engines/mediastation/actors/font.cpp
@@ -20,7 +20,7 @@
*/
#include "mediastation/debugchannels.h"
-#include "mediastation/assets/font.h"
+#include "mediastation/actors/font.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/font.h b/engines/mediastation/actors/font.h
similarity index 98%
rename from engines/mediastation/assets/font.h
rename to engines/mediastation/actors/font.h
index f565ba5f220..d047bd07f9b 100644
--- a/engines/mediastation/assets/font.h
+++ b/engines/mediastation/actors/font.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_FONT_H
#define MEDIASTATION_FONT_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/bitmap.h"
#include "mediastation/datafile.h"
#include "mediastation/mediascript/scriptvalue.h"
diff --git a/engines/mediastation/assets/hotspot.cpp b/engines/mediastation/actors/hotspot.cpp
similarity index 98%
rename from engines/mediastation/assets/hotspot.cpp
rename to engines/mediastation/actors/hotspot.cpp
index 888babbc503..299bed8ca71 100644
--- a/engines/mediastation/assets/hotspot.cpp
+++ b/engines/mediastation/actors/hotspot.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/hotspot.h"
+#include "mediastation/actors/hotspot.h"
#include "mediastation/mediastation.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/hotspot.h b/engines/mediastation/actors/hotspot.h
similarity index 98%
rename from engines/mediastation/assets/hotspot.h
rename to engines/mediastation/actors/hotspot.h
index e7fcde1e71f..ac9c689eb70 100644
--- a/engines/mediastation/assets/hotspot.h
+++ b/engines/mediastation/actors/hotspot.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_HOTSPOT_H
#define MEDIASTATION_HOTSPOT_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/image.cpp b/engines/mediastation/actors/image.cpp
similarity index 95%
rename from engines/mediastation/assets/image.cpp
rename to engines/mediastation/actors/image.cpp
index 8b4a029de3c..2e0739bd7a0 100644
--- a/engines/mediastation/assets/image.cpp
+++ b/engines/mediastation/actors/image.cpp
@@ -20,14 +20,14 @@
*/
#include "mediastation/mediastation.h"
-#include "mediastation/assets/image.h"
+#include "mediastation/actors/image.h"
#include "mediastation/debugchannels.h"
namespace MediaStation {
Image::~Image() {
- if (_assetReference == 0) {
- // If we're just referencing another asset's bitmap,
+ if (_actorReference == 0) {
+ // If we're just referencing another actor's bitmap,
// don't delete that bitmap.
delete _bitmap;
}
diff --git a/engines/mediastation/assets/image.h b/engines/mediastation/actors/image.h
similarity index 98%
rename from engines/mediastation/assets/image.h
rename to engines/mediastation/actors/image.h
index 20195562672..c6a8d3759a7 100644
--- a/engines/mediastation/assets/image.h
+++ b/engines/mediastation/actors/image.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_IMAGE_H
#define MEDIASTATION_IMAGE_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/datafile.h"
#include "mediastation/bitmap.h"
#include "mediastation/mediascript/scriptvalue.h"
diff --git a/engines/mediastation/assets/movie.cpp b/engines/mediastation/actors/movie.cpp
similarity index 98%
rename from engines/mediastation/assets/movie.cpp
rename to engines/mediastation/actors/movie.cpp
index e515d694c93..b14d96abcd8 100644
--- a/engines/mediastation/assets/movie.cpp
+++ b/engines/mediastation/actors/movie.cpp
@@ -20,7 +20,7 @@
*/
#include "mediastation/mediastation.h"
-#include "mediastation/assets/movie.h"
+#include "mediastation/actors/movie.h"
#include "mediastation/debugchannels.h"
namespace MediaStation {
@@ -90,11 +90,11 @@ Movie::~Movie() {
void Movie::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
switch (paramType) {
case kAssetHeaderAssetId: {
- // We already have this asset's ID, so we will just verify it is the same
+ // We already have this actor's ID, so we will just verify it is the same
// as the ID we have already read.
uint32 duplicateAssetId = chunk.readTypedUint16();
if (duplicateAssetId != _id) {
- warning("Duplicate asset ID %d does not match original ID %d", duplicateAssetId, _id);
+ warning("Duplicate actor ID %d does not match original ID %d", duplicateAssetId, _id);
}
break;
}
diff --git a/engines/mediastation/assets/movie.h b/engines/mediastation/actors/movie.h
similarity index 99%
rename from engines/mediastation/assets/movie.h
rename to engines/mediastation/actors/movie.h
index a7b8c3acf3d..8d3cb23f08e 100644
--- a/engines/mediastation/assets/movie.h
+++ b/engines/mediastation/actors/movie.h
@@ -24,7 +24,7 @@
#include "common/array.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/audio.h"
#include "mediastation/datafile.h"
#include "mediastation/bitmap.h"
diff --git a/engines/mediastation/assets/palette.cpp b/engines/mediastation/actors/palette.cpp
similarity index 97%
rename from engines/mediastation/assets/palette.cpp
rename to engines/mediastation/actors/palette.cpp
index 1159686d224..cc9e852aefb 100644
--- a/engines/mediastation/assets/palette.cpp
+++ b/engines/mediastation/actors/palette.cpp
@@ -20,7 +20,7 @@
*/
#include "mediastation/mediastation.h"
-#include "mediastation/assets/palette.h"
+#include "mediastation/actors/palette.h"
#include "mediastation/debugchannels.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/palette.h b/engines/mediastation/actors/palette.h
similarity index 97%
rename from engines/mediastation/assets/palette.h
rename to engines/mediastation/actors/palette.h
index bf72ced7701..cad11c171da 100644
--- a/engines/mediastation/assets/palette.h
+++ b/engines/mediastation/actors/palette.h
@@ -24,7 +24,7 @@
#include "graphics/palette.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/path.cpp b/engines/mediastation/actors/path.cpp
similarity index 99%
rename from engines/mediastation/assets/path.cpp
rename to engines/mediastation/actors/path.cpp
index fee18c67262..b935ed6df43 100644
--- a/engines/mediastation/assets/path.cpp
+++ b/engines/mediastation/actors/path.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/path.h"
+#include "mediastation/actors/path.h"
#include "mediastation/mediastation.h"
#include "mediastation/debugchannels.h"
diff --git a/engines/mediastation/assets/path.h b/engines/mediastation/actors/path.h
similarity index 98%
rename from engines/mediastation/assets/path.h
rename to engines/mediastation/actors/path.h
index 92930d28bef..62e1ebc8f65 100644
--- a/engines/mediastation/assets/path.h
+++ b/engines/mediastation/actors/path.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_PATH_H
#define MEDIASTATION_PATH_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/screen.cpp b/engines/mediastation/actors/screen.cpp
similarity index 96%
rename from engines/mediastation/assets/screen.cpp
rename to engines/mediastation/actors/screen.cpp
index 2d6cb41a807..783c133afc4 100644
--- a/engines/mediastation/assets/screen.cpp
+++ b/engines/mediastation/actors/screen.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/screen.h"
+#include "mediastation/actors/screen.h"
#include "mediastation/debugchannels.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/screen.h b/engines/mediastation/actors/screen.h
similarity index 91%
rename from engines/mediastation/assets/screen.h
rename to engines/mediastation/actors/screen.h
index 3ee17f397cc..de25535c146 100644
--- a/engines/mediastation/assets/screen.h
+++ b/engines/mediastation/actors/screen.h
@@ -22,15 +22,15 @@
#ifndef MEDIASTATION_SCREEN_H
#define MEDIASTATION_SCREEN_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
namespace MediaStation {
-// A Screen holds asset data and processes event handlers for a Context.
+// A Screen holds actor data and processes event handlers for a Context.
// The original separated them this way - there is a ContextParameters section,
-// then a Screen asset header.
+// then a Screen actor header.
class Screen : public Asset {
public:
Screen() : Asset(kAssetTypeScreen) {};
diff --git a/engines/mediastation/assets/sound.cpp b/engines/mediastation/actors/sound.cpp
similarity index 95%
rename from engines/mediastation/assets/sound.cpp
rename to engines/mediastation/actors/sound.cpp
index c972f2595bd..45b3d9b1601 100644
--- a/engines/mediastation/assets/sound.cpp
+++ b/engines/mediastation/actors/sound.cpp
@@ -21,18 +21,18 @@
#include "mediastation/audio.h"
#include "mediastation/debugchannels.h"
-#include "mediastation/assets/sound.h"
+#include "mediastation/actors/sound.h"
namespace MediaStation {
void Sound::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
switch (paramType) {
case kAssetHeaderAssetId: {
- // We already have this asset's ID, so we will just verify it is the same
+ // We already have this actor's ID, so we will just verify it is the same
// as the ID we have already read.
uint32 duplicateAssetId = chunk.readTypedUint16();
if (duplicateAssetId != _id) {
- warning("Duplicate asset ID %d does not match original ID %d", duplicateAssetId, _id);
+ warning("Duplicate actor ID %d does not match original ID %d", duplicateAssetId, _id);
}
break;
}
diff --git a/engines/mediastation/assets/sound.h b/engines/mediastation/actors/sound.h
similarity index 98%
rename from engines/mediastation/assets/sound.h
rename to engines/mediastation/actors/sound.h
index 7ee75b1eba2..e21ba7ebc9a 100644
--- a/engines/mediastation/assets/sound.h
+++ b/engines/mediastation/actors/sound.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_ASSETS_SOUND_H
#define MEDIASTATION_ASSETS_SOUND_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/audio.h"
#include "mediastation/datafile.h"
#include "mediastation/mediascript/scriptvalue.h"
diff --git a/engines/mediastation/assets/sprite.cpp b/engines/mediastation/actors/sprite.cpp
similarity index 98%
rename from engines/mediastation/assets/sprite.cpp
rename to engines/mediastation/actors/sprite.cpp
index 6554d4c5047..e4eba002dbb 100644
--- a/engines/mediastation/assets/sprite.cpp
+++ b/engines/mediastation/actors/sprite.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/sprite.h"
+#include "mediastation/actors/sprite.h"
#include "mediastation/debugchannels.h"
#include "mediastation/mediastation.h"
@@ -61,9 +61,9 @@ uint32 SpriteFrame::index() {
}
Sprite::~Sprite() {
- // If we're just referencing another asset's frames,
+ // If we're just referencing another actor's frames,
// don't delete those frames.
- if (_assetReference == 0) {
+ if (_actorReference == 0) {
for (SpriteFrame *frame : _frames) {
delete frame;
}
diff --git a/engines/mediastation/assets/sprite.h b/engines/mediastation/actors/sprite.h
similarity index 99%
rename from engines/mediastation/assets/sprite.h
rename to engines/mediastation/actors/sprite.h
index 257f28b71ad..9172b1b1783 100644
--- a/engines/mediastation/assets/sprite.h
+++ b/engines/mediastation/actors/sprite.h
@@ -25,7 +25,7 @@
#include "common/rect.h"
#include "common/array.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/datafile.h"
#include "mediastation/bitmap.h"
#include "mediastation/mediascript/scriptvalue.h"
diff --git a/engines/mediastation/assets/text.cpp b/engines/mediastation/actors/text.cpp
similarity index 98%
rename from engines/mediastation/assets/text.cpp
rename to engines/mediastation/actors/text.cpp
index 935897fbedb..79ad2cc2d2a 100644
--- a/engines/mediastation/assets/text.cpp
+++ b/engines/mediastation/actors/text.cpp
@@ -19,7 +19,7 @@
*
*/
-#include "mediastation/assets/text.h"
+#include "mediastation/actors/text.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/text.h b/engines/mediastation/actors/text.h
similarity index 98%
rename from engines/mediastation/assets/text.h
rename to engines/mediastation/actors/text.h
index a3742e145ec..7cca11e498a 100644
--- a/engines/mediastation/assets/text.h
+++ b/engines/mediastation/actors/text.h
@@ -24,7 +24,7 @@
#include "common/str.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/assets/timer.cpp b/engines/mediastation/actors/timer.cpp
similarity index 98%
rename from engines/mediastation/assets/timer.cpp
rename to engines/mediastation/actors/timer.cpp
index 10a149a3cfd..22e45a9ceed 100644
--- a/engines/mediastation/assets/timer.cpp
+++ b/engines/mediastation/actors/timer.cpp
@@ -22,7 +22,7 @@
#include "mediastation/mediastation.h"
#include "mediastation/debugchannels.h"
-#include "mediastation/assets/timer.h"
+#include "mediastation/actors/timer.h"
namespace MediaStation {
diff --git a/engines/mediastation/assets/timer.h b/engines/mediastation/actors/timer.h
similarity index 97%
rename from engines/mediastation/assets/timer.h
rename to engines/mediastation/actors/timer.h
index bfd5b5f9e1c..ad0c6beaabf 100644
--- a/engines/mediastation/assets/timer.h
+++ b/engines/mediastation/actors/timer.h
@@ -22,7 +22,7 @@
#ifndef MEDIASTATION_TIMER_H
#define MEDIASTATION_TIMER_H
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/scriptvalue.h"
#include "mediastation/mediascript/scriptconstants.h"
diff --git a/engines/mediastation/bitmap.h b/engines/mediastation/bitmap.h
index 98108d03059..a68cf4b2db6 100644
--- a/engines/mediastation/bitmap.h
+++ b/engines/mediastation/bitmap.h
@@ -26,7 +26,7 @@
#include "graphics/managed_surface.h"
#include "mediastation/datafile.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
namespace MediaStation {
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index 3aabdda634a..dd53c9eb654 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -73,7 +73,7 @@ ScreenDeclaration::ScreenDeclaration(Chunk &chunk) {
if (kScreenDeclarationAssetId != sectionType) {
error("Got unexpected section type %d", static_cast<uint>(sectionType));
}
- _assetId = chunk.readTypedUint16();
+ _actorId = chunk.readTypedUint16();
sectionType = getSectionType(chunk);
if (kScreenDeclarationScreenId != sectionType) {
@@ -116,12 +116,12 @@ FileDeclarationSectionType FileDeclaration::getSectionType(Chunk &chunk) {
#pragma region SubfileDeclaration
SubfileDeclaration::SubfileDeclaration(Chunk &chunk) {
- // Read the asset ID.
+ // Read the actor ID.
SubfileDeclarationSectionType sectionType = getSectionType(chunk);
if (kSubfileDeclarationAssetId != sectionType) {
error("Got unexpected section type %d", static_cast<uint>(sectionType));
}
- _assetId = chunk.readTypedUint16();
+ _actorId = chunk.readTypedUint16();
// Read the file ID.
sectionType = getSectionType(chunk);
@@ -219,7 +219,7 @@ Boot::Boot(const Common::Path &path) : Datafile(path) {
uint flag = chunk.readTypedUint16();
while (flag != 0) {
ScreenDeclaration screenDeclaration = ScreenDeclaration(chunk);
- _screenDeclarations.setVal(screenDeclaration._assetId, screenDeclaration);
+ _screenDeclarations.setVal(screenDeclaration._actorId, screenDeclaration);
flag = chunk.readTypedUint16();
}
break;
@@ -239,7 +239,7 @@ Boot::Boot(const Common::Path &path) : Datafile(path) {
uint flag = chunk.readTypedUint16();
while (flag != 0) {
SubfileDeclaration subfileDeclaration = SubfileDeclaration(chunk);
- _subfileDeclarations.setVal(subfileDeclaration._assetId, subfileDeclaration);
+ _subfileDeclarations.setVal(subfileDeclaration._actorId, subfileDeclaration);
flag = chunk.readTypedUint16();
}
break;
diff --git a/engines/mediastation/boot.h b/engines/mediastation/boot.h
index 9509b48b8e6..275940794d1 100644
--- a/engines/mediastation/boot.h
+++ b/engines/mediastation/boot.h
@@ -65,7 +65,7 @@ public:
ScreenDeclaration(Chunk &chunk);
ScreenDeclaration() {};
- uint _assetId = 0;
+ uint _actorId = 0;
uint _screenId = 0;
private:
@@ -116,7 +116,7 @@ public:
SubfileDeclaration(Chunk &chunk);
SubfileDeclaration() {};
- uint _assetId = 0;
+ uint _actorId = 0;
uint _fileId = 0;
uint _startOffsetInFile = 0;
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index e9b4a64edcc..d6150928160 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -25,18 +25,18 @@
#include "mediastation/bitmap.h"
#include "mediastation/mediascript/collection.h"
-#include "mediastation/assets/canvas.h"
-#include "mediastation/assets/palette.h"
-#include "mediastation/assets/image.h"
-#include "mediastation/assets/path.h"
-#include "mediastation/assets/sound.h"
-#include "mediastation/assets/movie.h"
-#include "mediastation/assets/sprite.h"
-#include "mediastation/assets/hotspot.h"
-#include "mediastation/assets/timer.h"
-#include "mediastation/assets/screen.h"
-#include "mediastation/assets/font.h"
-#include "mediastation/assets/text.h"
+#include "mediastation/actors/canvas.h"
+#include "mediastation/actors/palette.h"
+#include "mediastation/actors/image.h"
+#include "mediastation/actors/path.h"
+#include "mediastation/actors/sound.h"
+#include "mediastation/actors/movie.h"
+#include "mediastation/actors/sprite.h"
+#include "mediastation/actors/hotspot.h"
+#include "mediastation/actors/timer.h"
+#include "mediastation/actors/screen.h"
+#include "mediastation/actors/font.h"
+#include "mediastation/actors/text.h"
namespace MediaStation {
@@ -68,35 +68,35 @@ Context::Context(const Common::Path &path) : Datafile(path) {
}
}
- // Read assets in the rest of the subfiles.
+ // Read actors in the rest of the subfiles.
for (uint i = 1; i < _subfileCount; i++) {
subfile = getNextSubfile();
readAssetFromLaterSubfile(subfile);
}
// Some sprites and images don't have any image data themselves, they just
- // reference the same image data in another asset. So we need to check for
+ // reference the same image data in another actor. So we need to check for
// these and create the appropriate references.
- for (auto it = _assets.begin(); it != _assets.end(); ++it) {
- Asset *asset = it->_value;
- uint referencedAssetId = asset->_assetReference;
+ for (auto it = _actors.begin(); it != _actors.end(); ++it) {
+ Asset *actor = it->_value;
+ uint referencedAssetId = actor->_actorReference;
if (referencedAssetId != 0) {
- switch (asset->type()) {
+ switch (actor->type()) {
case kAssetTypeImage: {
- Image *image = static_cast<Image *>(asset);
+ Image *image = static_cast<Image *>(actor);
Image *referencedImage = static_cast<Image *>(getAssetById(referencedAssetId));
if (referencedImage == nullptr) {
- error("Context::Context(): Asset %d references non-existent asset %d", asset->id(), referencedAssetId);
+ error("Context::Context(): Asset %d references non-existent actor %d", actor->id(), referencedAssetId);
}
image->_bitmap = referencedImage->_bitmap;
break;
}
case kAssetTypeSprite: {
- Sprite *sprite = static_cast<Sprite *>(asset);
+ Sprite *sprite = static_cast<Sprite *>(actor);
Sprite *referencedSprite = static_cast<Sprite *>(getAssetById(referencedAssetId));
if (referencedSprite == nullptr) {
- error("Context::Context(): Asset %d references non-existent asset %d", asset->id(), referencedAssetId);
+ error("Context::Context(): Asset %d references non-existent actor %d", actor->id(), referencedAssetId);
}
sprite->_frames = referencedSprite->_frames;
sprite->_clips = referencedSprite->_clips;
@@ -104,7 +104,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
}
default:
- error("Context::Context(): Asset type %d referenced, but reference not implemented yet", asset->type());
+ error("Context::Context(): Asset type %d referenced, but reference not implemented yet", actor->type());
}
}
}
@@ -114,12 +114,12 @@ Context::~Context() {
delete _palette;
_palette = nullptr;
- for (auto it = _assets.begin(); it != _assets.end(); ++it) {
+ for (auto it = _actors.begin(); it != _actors.end(); ++it) {
delete it->_value;
}
- _assets.clear();
- // The same asset pointers are in here, so don't delete again.
- _assetsByChunkReference.clear();
+ _actors.clear();
+ // The same actor pointers are in here, so don't delete again.
+ _actorsByChunkReference.clear();
for (auto it = _functions.begin(); it != _functions.end(); ++it) {
delete it->_value;
@@ -132,12 +132,12 @@ Context::~Context() {
_variables.clear();
}
-Asset *Context::getAssetById(uint assetId) {
- return _assets.getValOrDefault(assetId);
+Asset *Context::getAssetById(uint actorId) {
+ return _actors.getValOrDefault(actorId);
}
Asset *Context::getAssetByChunkReference(uint chunkReference) {
- return _assetsByChunkReference.getValOrDefault(chunkReference);
+ return _actorsByChunkReference.getValOrDefault(chunkReference);
}
Function *Context::getFunctionById(uint functionId) {
@@ -199,64 +199,64 @@ Asset *Context::readCreateAssetData(Chunk &chunk) {
uint id = chunk.readTypedUint16();
debugC(4, kDebugLoading, "_type = 0x%x, _id = 0x%x", static_cast<uint>(type), id);
- Asset *asset = nullptr;
+ Asset *actor = nullptr;
switch (type) {
case kAssetTypeImage:
- asset = new Image();
+ actor = new Image();
break;
case kAssetTypeMovie:
- asset = new Movie();
+ actor = new Movie();
break;
case kAssetTypeSound:
- asset = new Sound();
+ actor = new Sound();
break;
case kAssetTypePalette:
- asset = new Palette();
+ actor = new Palette();
break;
case kAssetTypePath:
- asset = new Path();
+ actor = new Path();
break;
case kAssetTypeTimer:
- asset = new Timer();
+ actor = new Timer();
break;
case kAssetTypeHotspot:
- asset = new Hotspot();
+ actor = new Hotspot();
break;
case kAssetTypeSprite:
- asset = new Sprite();
+ actor = new Sprite();
break;
case kAssetTypeCanvas:
- asset = new Canvas();
+ actor = new Canvas();
break;
case kAssetTypeScreen:
- asset = new Screen();
- _screenAsset = static_cast<Screen *>(asset);
+ actor = new Screen();
+ _screenAsset = static_cast<Screen *>(actor);
break;
case kAssetTypeFont:
- asset = new Font();
+ actor = new Font();
break;
case kAssetTypeText:
- asset = new Text();
+ actor = new Text();
break;
default:
- error("No class for asset type 0x%x (@0x%llx)", static_cast<uint>(type), static_cast<long long int>(chunk.pos()));
+ error("No class for actor type 0x%x (@0x%llx)", static_cast<uint>(type), static_cast<long long int>(chunk.pos()));
}
- asset->setId(id);
- asset->setContextId(contextId);
- asset->initFromParameterStream(chunk);
- return asset;
+ actor->setId(id);
+ actor->setContextId(contextId);
+ actor->initFromParameterStream(chunk);
+ return actor;
}
void Context::readCreateVariableData(Chunk &chunk) {
@@ -311,38 +311,38 @@ void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
void Context::readAssetInFirstSubfile(Chunk &chunk) {
if (chunk._id == MKTAG('i', 'g', 'o', 'd')) {
- warning("Context::readAssetInFirstSubfile(): Skippping \"igod\" asset link chunk");
+ warning("Context::readAssetInFirstSubfile(): Skippping \"igod\" actor link chunk");
chunk.skip(chunk.bytesRemaining());
return;
}
- // TODO: Make sure this is not an asset link.
- Asset *asset = getAssetByChunkReference(chunk._id);
- if (asset == nullptr) {
+ // TODO: Make sure this is not an actor link.
+ Asset *actor = getAssetByChunkReference(chunk._id);
+ if (actor == nullptr) {
// We should only need to look in the global scope when there is an
// install cache (INSTALL.CXT).
- asset = g_engine->getAssetByChunkReference(chunk._id);
- if (asset == nullptr) {
+ actor = g_engine->getAssetByChunkReference(chunk._id);
+ if (actor == nullptr) {
error("Context::readAssetInFirstSubfile(): Asset for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
- debugC(5, kDebugLoading, "\nContext::readAssetInFirstSubfile(): Got asset with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(asset->type()), static_cast<long long int>(chunk.pos()));
- asset->readChunk(chunk);
+ debugC(5, kDebugLoading, "\nContext::readAssetInFirstSubfile(): Got actor with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(actor->type()), static_cast<long long int>(chunk.pos()));
+ actor->readChunk(chunk);
}
void Context::readAssetFromLaterSubfile(Subfile &subfile) {
Chunk chunk = subfile.nextChunk();
- Asset *asset = getAssetByChunkReference(chunk._id);
- if (asset == nullptr) {
+ Asset *actor = getAssetByChunkReference(chunk._id);
+ if (actor == nullptr) {
// We should only need to look in the global scope when there is an
// install cache (INSTALL.CXT).
- asset = g_engine->getAssetByChunkReference(chunk._id);
- if (asset == nullptr) {
+ actor = g_engine->getAssetByChunkReference(chunk._id);
+ if (actor == nullptr) {
error("Context::readAssetFromLaterSubfile(): Asset for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
- debugC(5, kDebugLoading, "\nContext::readAssetFromLaterSubfile(): Got asset with chunk ID %s in later subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), asset->type(), static_cast<long long int>(chunk.pos()));
- asset->readSubfile(subfile, chunk);
+ debugC(5, kDebugLoading, "\nContext::readAssetFromLaterSubfile(): Got actor with chunk ID %s in later subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), actor->type(), static_cast<long long int>(chunk.pos()));
+ actor->readSubfile(subfile, chunk);
}
bool Context::readHeaderSection(Chunk &chunk) {
@@ -379,26 +379,26 @@ bool Context::readHeaderSection(Chunk &chunk) {
}
case kContextAssetHeaderSection: {
- Asset *asset = readCreateAssetData(chunk);
- _assets.setVal(asset->id(), asset);
- g_engine->registerAsset(asset);
- if (asset->_chunkReference != 0) {
- debugC(5, kDebugLoading, "Context::readHeaderSection(): Storing asset with chunk ID \"%s\" (0x%x)", tag2str(asset->_chunkReference), asset->_chunkReference);
- _assetsByChunkReference.setVal(asset->_chunkReference, asset);
+ Asset *actor = readCreateAssetData(chunk);
+ _actors.setVal(actor->id(), actor);
+ g_engine->registerAsset(actor);
+ if (actor->_chunkReference != 0) {
+ debugC(5, kDebugLoading, "Context::readHeaderSection(): Storing actor with chunk ID \"%s\" (0x%x)", tag2str(actor->_chunkReference), actor->_chunkReference);
+ _actorsByChunkReference.setVal(actor->_chunkReference, actor);
}
- if (asset->type() == kAssetTypeMovie) {
- Movie *movie = static_cast<Movie *>(asset);
+ if (actor->type() == kAssetTypeMovie) {
+ Movie *movie = static_cast<Movie *>(actor);
if (movie->_audioChunkReference != 0) {
- _assetsByChunkReference.setVal(movie->_audioChunkReference, asset);
+ _actorsByChunkReference.setVal(movie->_audioChunkReference, actor);
}
if (movie->_animationChunkReference != 0) {
- _assetsByChunkReference.setVal(movie->_animationChunkReference, asset);
+ _actorsByChunkReference.setVal(movie->_animationChunkReference, actor);
}
}
// TODO: This datum only appears sometimes.
uint unk2 = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Context::readHeaderSection(): Got unknown value at end of asset header section 0x%x", unk2);
+ debugC(5, kDebugLoading, "Context::readHeaderSection(): Got unknown value at end of actor header section 0x%x", unk2);
break;
}
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index 1b35b6ba6cd..f4a6770c06c 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -28,7 +28,7 @@
#include "graphics/palette.h"
#include "mediastation/datafile.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/mediascript/function.h"
namespace MediaStation {
@@ -66,7 +66,7 @@ public:
Graphics::Palette *_palette = nullptr;
Screen *_screenAsset = nullptr;
- Asset *getAssetById(uint assetId);
+ Asset *getAssetById(uint actorId);
Asset *getAssetByChunkReference(uint chunkReference);
Function *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
@@ -78,9 +78,9 @@ private:
uint _fileNumber = 0;
Common::String _contextName;
- Common::HashMap<uint, Asset *> _assets;
+ Common::HashMap<uint, Asset *> _actors;
Common::HashMap<uint, Function *> _functions;
- Common::HashMap<uint, Asset *> _assetsByChunkReference;
+ Common::HashMap<uint, Asset *> _actorsByChunkReference;
Common::HashMap<uint, ScriptValue *> _variables;
void readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk);
diff --git a/engines/mediastation/datafile.h b/engines/mediastation/datafile.h
index 03183c088e8..5693324013a 100644
--- a/engines/mediastation/datafile.h
+++ b/engines/mediastation/datafile.h
@@ -44,7 +44,7 @@ typedef Common::Array<Common::Point> Polygon;
// from some oddness at the start of the subfile, each subfile is basically
// standard sequence of chunks inside a LIST chunk, like you'd see in any RIFF
// file. These chunks have special IDs:
-// - igod: Indicates a chunk that contains metadata about asset(s) in metadata sections.
+// - igod: Indicates a chunk that contains metadata about actor(s) in metadata sections.
// - a000, where 000 is a string that represents a 3-digit hexadecimal number.
// Indicates a chunk that contains actor data (sounds and bitmaps).
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index 83518727fe0..00f16dc6351 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -23,7 +23,7 @@
#include "common/util.h"
#include "engines/util.h"
-#include "mediastation/assets/palette.h"
+#include "mediastation/actors/palette.h"
#include "mediastation/bitmap.h"
#include "mediastation/debugchannels.h"
#include "mediastation/dissolvepatterns.h"
@@ -448,38 +448,38 @@ void VideoDisplayManager::_colorShiftCurrentPalette(uint startIndex, uint shiftA
}
void VideoDisplayManager::_fadeToPaletteObject(uint paletteId, double fadeTime, uint startIndex, uint colorCount) {
- Asset *asset = _vm->getAssetById(paletteId);
- if (asset == nullptr) {
+ Asset *actor = _vm->getAssetById(paletteId);
+ if (actor == nullptr) {
error("Got null target palette");
- } else if (asset->type() != kAssetTypePalette) {
+ } else if (actor->type() != kAssetTypePalette) {
error("Asset %d is not a palette", paletteId);
}
- Graphics::Palette *palette = static_cast<Palette *>(asset)->_palette;
+ Graphics::Palette *palette = static_cast<Palette *>(actor)->_palette;
_fadeToPalette(fadeTime, *palette, startIndex, colorCount);
}
void VideoDisplayManager::_setToPaletteObject(uint paletteId, uint startIndex, uint colorCount) {
- Asset *asset = _vm->getAssetById(paletteId);
- if (asset == nullptr) {
+ Asset *actor = _vm->getAssetById(paletteId);
+ if (actor == nullptr) {
error("Got null target palette");
- } else if (asset->type() != kAssetTypePalette) {
+ } else if (actor->type() != kAssetTypePalette) {
error("Asset %d is not a palette", paletteId);
}
- Graphics::Palette *palette = static_cast<Palette *>(asset)->_palette;
+ Graphics::Palette *palette = static_cast<Palette *>(actor)->_palette;
_setPalette(*palette, startIndex, colorCount);
}
void VideoDisplayManager::_setPercentToPaletteObject(double percent, uint paletteId, uint startIndex, uint colorCount) {
- Asset *asset = _vm->getAssetById(paletteId);
- if (asset == nullptr) {
+ Asset *actor = _vm->getAssetById(paletteId);
+ if (actor == nullptr) {
error("Got null target palette");
- } else if (asset->type() != kAssetTypePalette) {
+ } else if (actor->type() != kAssetTypePalette) {
error("Asset %d is not a palette", paletteId);
}
- Graphics::Palette *targetPalette = static_cast<Palette *>(asset)->_palette;
+ Graphics::Palette *targetPalette = static_cast<Palette *>(actor)->_palette;
_setToPercentPalette(percent, *_registeredPalette, *targetPalette, startIndex, colorCount);
}
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 3806b7ab0a8..5fd4f77b1f6 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -233,9 +233,9 @@ ScriptValue CodeChunk::evaluateValue() {
}
case kOperandTypeAssetId: {
- uint assetId = _bytecode->readTypedUint16();
- debugC(5, kDebugScript, "%d ", assetId);
- returnValue.setToAssetId(assetId);
+ uint actorId = _bytecode->readTypedUint16();
+ debugC(5, kDebugScript, "%d ", actorId);
+ returnValue.setToAssetId(actorId);
return returnValue;
}
@@ -514,16 +514,16 @@ ScriptValue CodeChunk::evaluateMethodCall(BuiltInMethod method, uint paramCount)
switch (target.getType()) {
case kScriptValueTypeAssetId: {
if (target.asAssetId() == 0) {
- // It seems to be valid to call a method on a null asset ID, in
+ // It seems to be valid to call a method on a null actor ID, in
// which case nothing happens. Still issue warning for traceability.
- warning("Attempt to call method on a null asset ID");
+ warning("Attempt to call method on a null actor ID");
return returnValue;
} else {
- // This is a regular asset that we can process directly.
- uint assetId = target.asAssetId();
- Asset *targetAsset = g_engine->getAssetById(assetId);
+ // This is a regular actor that we can process directly.
+ uint actorId = target.asAssetId();
+ Asset *targetAsset = g_engine->getAssetById(actorId);
if (targetAsset == nullptr) {
- error("Attempt to call method on asset ID %d, which isn't loaded", target.asAssetId());
+ error("Attempt to call method on actor ID %d, which isn't loaded", target.asAssetId());
}
returnValue = targetAsset->callMethod(method, args);
return returnValue;
diff --git a/engines/mediastation/mediascript/collection.cpp b/engines/mediastation/mediascript/collection.cpp
index c78219e899b..560199e41f3 100644
--- a/engines/mediastation/mediascript/collection.cpp
+++ b/engines/mediastation/mediascript/collection.cpp
@@ -146,8 +146,8 @@ void Collection::send(const Common::Array<ScriptValue> &args) {
BuiltInMethod methodToSend = static_cast<BuiltInMethod>(args[0].asMethodId());
Common::Array<ScriptValue> sendArgs;
for (const ScriptValue &item : *this) {
- uint assetId = item.asAssetId();
- Asset *targetAsset = g_engine->getAssetById(assetId);
+ uint actorId = item.asAssetId();
+ Asset *targetAsset = g_engine->getAssetById(actorId);
if (targetAsset != nullptr) {
targetAsset->callMethod(methodToSend, argsToSend);
}
diff --git a/engines/mediastation/mediascript/eventhandler.cpp b/engines/mediastation/mediascript/eventhandler.cpp
index fa9fbbb9e68..f4f8b577826 100644
--- a/engines/mediastation/mediascript/eventhandler.cpp
+++ b/engines/mediastation/mediascript/eventhandler.cpp
@@ -33,18 +33,18 @@ EventHandler::EventHandler(Chunk &chunk) {
_code = new CodeChunk(chunk);
}
-ScriptValue EventHandler::execute(uint assetId) {
- // TODO: The assetId is only passed in for debug visibility, there should be
+ScriptValue EventHandler::execute(uint actorId) {
+ // TODO: The actorId is only passed in for debug visibility, there should be
// a better way to handle that.
- Common::String assetAndType = Common::String::format("(asset %d) (type = %s)", assetId, eventTypeToStr(_type));
+ Common::String actorAndType = Common::String::format("(actor %d) (type = %s)", actorId, eventTypeToStr(_type));
Common::String argValue = getDebugHeader();
- debugC(5, kDebugScript, "\n********** EVENT HANDLER %s %s **********", assetAndType.c_str(), argValue.c_str());
+ debugC(5, kDebugScript, "\n********** EVENT HANDLER %s %s **********", actorAndType.c_str(), argValue.c_str());
// The only argument that can be provided to an
// event handler is the _argumentValue.
ScriptValue returnValue = _code->execute();
- debugC(5, kDebugScript, "********** END EVENT HANDLER %s %s **********", assetAndType.c_str(), argValue.c_str());
+ debugC(5, kDebugScript, "********** END EVENT HANDLER %s %s **********", actorAndType.c_str(), argValue.c_str());
return returnValue;
}
diff --git a/engines/mediastation/mediascript/eventhandler.h b/engines/mediastation/mediascript/eventhandler.h
index 843a008e790..bee34d4c7ae 100644
--- a/engines/mediastation/mediascript/eventhandler.h
+++ b/engines/mediastation/mediascript/eventhandler.h
@@ -35,7 +35,7 @@ public:
EventHandler(Chunk &chunk);
~EventHandler();
- ScriptValue execute(uint assetId);
+ ScriptValue execute(uint actorId);
Common::String getDebugHeader();
EventType _type;
ScriptValue _argumentValue;
diff --git a/engines/mediastation/mediascript/scriptvalue.cpp b/engines/mediastation/mediascript/scriptvalue.cpp
index 75697963fa2..43258236dfa 100644
--- a/engines/mediastation/mediascript/scriptvalue.cpp
+++ b/engines/mediastation/mediascript/scriptvalue.cpp
@@ -59,8 +59,8 @@ ScriptValue::ScriptValue(ParameterReadStream *stream) {
}
case kScriptValueTypeAssetId: {
- uint assetId = stream->readTypedUint16();
- setToAssetId(assetId);
+ uint actorId = stream->readTypedUint16();
+ setToAssetId(actorId);
break;
}
@@ -163,14 +163,14 @@ uint ScriptValue::asParamToken() const {
}
}
-void ScriptValue::setToAssetId(uint assetId) {
+void ScriptValue::setToAssetId(uint actorId) {
_type = kScriptValueTypeAssetId;
- _u.assetId = assetId;
+ _u.actorId = actorId;
}
uint ScriptValue::asAssetId() const {
if (_type == kScriptValueTypeAssetId) {
- return _u.assetId;
+ return _u.actorId;
} else {
issueValueMismatchWarning(kScriptValueTypeAssetId);
return 0;
diff --git a/engines/mediastation/mediascript/scriptvalue.h b/engines/mediastation/mediascript/scriptvalue.h
index 2465d6a9358..fd45f77b570 100644
--- a/engines/mediastation/mediascript/scriptvalue.h
+++ b/engines/mediastation/mediascript/scriptvalue.h
@@ -55,7 +55,7 @@ public:
void setToParamToken(uint paramToken);
uint asParamToken() const;
- void setToAssetId(uint assetId);
+ void setToAssetId(uint actorId);
uint asAssetId() const;
void setToString(const Common::String &string);
@@ -94,7 +94,7 @@ private:
double d = 0;
bool b;
uint paramToken;
- uint assetId;
+ uint actorId;
uint functionId;
BuiltInMethod methodId;
} _u;
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 9fa02af597e..c9cf8795c49 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -26,12 +26,12 @@
#include "mediastation/detection.h"
#include "mediastation/boot.h"
#include "mediastation/context.h"
-#include "mediastation/asset.h"
-#include "mediastation/assets/document.h"
-#include "mediastation/assets/movie.h"
-#include "mediastation/assets/screen.h"
-#include "mediastation/assets/palette.h"
-#include "mediastation/assets/hotspot.h"
+#include "mediastation/actor.h"
+#include "mediastation/actors/document.h"
+#include "mediastation/actors/movie.h"
+#include "mediastation/actors/screen.h"
+#include "mediastation/actors/palette.h"
+#include "mediastation/actors/hotspot.h"
#include "mediastation/mediascript/scriptconstants.h"
namespace MediaStation {
@@ -68,13 +68,13 @@ MediaStationEngine::~MediaStationEngine() {
_loadedContexts.clear();
// Delete the document actor. The rest are deleted from their contexts.
- delete _assets[0];
+ delete _actors[0];
}
-Asset *MediaStationEngine::getAssetById(uint assetId) {
- for (auto asset : _assets) {
- if (asset->id() == assetId) {
- return asset;
+Asset *MediaStationEngine::getAssetById(uint actorId) {
+ for (auto actor : _actors) {
+ if (actor->id() == actorId) {
+ return actor;
}
}
return nullptr;
@@ -82,9 +82,9 @@ Asset *MediaStationEngine::getAssetById(uint assetId) {
Asset *MediaStationEngine::getAssetByChunkReference(uint chunkReference) {
for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
- Asset *asset = it->_value->getAssetByChunkReference(chunkReference);
- if (asset != nullptr) {
- return asset;
+ Asset *actor = it->_value->getAssetByChunkReference(chunkReference);
+ if (actor != nullptr) {
+ return actor;
}
}
return nullptr;
@@ -150,7 +150,7 @@ Common::Error MediaStationEngine::run() {
_cursor->showCursor();
Document *document = new Document;
- _assets.push_back(document);
+ _actors.push_back(document);
if (ConfMan.hasKey("entry_context")) {
// For development purposes, we can choose to start at an arbitrary context
@@ -182,8 +182,8 @@ Common::Error MediaStationEngine::run() {
}
debugC(5, kDebugGraphics, "***** START SCREEN UPDATE ***");
- for (Asset *asset : _assets) {
- asset->process();
+ for (Asset *actor : _actors) {
+ actor->process();
if (_needsHotspotRefresh) {
refreshActiveHotspot();
@@ -263,11 +263,11 @@ void MediaStationEngine::setCursor(uint id) {
}
void MediaStationEngine::refreshActiveHotspot() {
- Asset *asset = findAssetToAcceptMouseEvents();
- if (asset != nullptr && asset->type() != kAssetTypeHotspot) {
+ Asset *actor = findAssetToAcceptMouseEvents();
+ if (actor != nullptr && actor->type() != kAssetTypeHotspot) {
return;
}
- Hotspot *hotspot = static_cast<Hotspot *>(asset);
+ Hotspot *hotspot = static_cast<Hotspot *>(actor);
if (hotspot != _currentHotspot) {
if (_currentHotspot != nullptr) {
_currentHotspot->runEventHandlerIfExists(kMouseExitedEvent);
@@ -292,9 +292,9 @@ void MediaStationEngine::refreshActiveHotspot() {
void MediaStationEngine::draw() {
if (!_dirtyRects.empty()) {
- for (Asset *asset : _spatialEntities) {
- if (asset->isSpatialActor()) {
- SpatialEntity *entity = static_cast<SpatialEntity *>(asset);
+ for (Asset *actor : _spatialEntities) {
+ if (actor->isSpatialActor()) {
+ SpatialEntity *entity = static_cast<SpatialEntity *>(actor);
if (entity->isVisible()) {
entity->draw(_dirtyRects);
}
@@ -320,8 +320,8 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
// Get the file ID.
const SubfileDeclaration &subfileDeclaration = _boot->_subfileDeclarations.getVal(contextId);
- // There are other assets in a subfile too, so we need to make sure we're
- // referencing the screen asset, at the start of the file.
+ // There are other actors in a subfile too, so we need to make sure we're
+ // referencing the screen actor, at the start of the file.
if (subfileDeclaration._startOffsetInFile != 16) {
warning("MediaStationEngine::loadContext(): Requested ID wasn't for a context.");
return nullptr;
@@ -349,14 +349,14 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
return context;
}
-void MediaStationEngine::registerAsset(Asset *assetToAdd) {
- if (getAssetById(assetToAdd->id())) {
- error("Asset with ID 0x%d was already defined in this title", assetToAdd->id());
+void MediaStationEngine::registerAsset(Asset *actorToAdd) {
+ if (getAssetById(actorToAdd->id())) {
+ error("Asset with ID 0x%d was already defined in this title", actorToAdd->id());
}
- _assets.push_back(assetToAdd);
- if (assetToAdd->isSpatialActor()) {
- _spatialEntities.insert(static_cast<SpatialEntity *>(assetToAdd));
+ _actors.push_back(actorToAdd);
+ if (actorToAdd->isSpatialActor()) {
+ _spatialEntities.insert(static_cast<SpatialEntity *>(actorToAdd));
}
}
@@ -403,18 +403,18 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
}
}
- for (auto it = _assets.begin(); it != _assets.end();) {
- uint assetContextId = (*it)->contextId();
- if (assetContextId == contextId) {
- it = _assets.erase(it);
+ for (auto it = _actors.begin(); it != _actors.end();) {
+ uint actorContextId = (*it)->contextId();
+ if (actorContextId == contextId) {
+ it = _actors.erase(it);
} else {
++it;
}
}
for (auto it = _spatialEntities.begin(); it != _spatialEntities.end();) {
- uint assetContextId = (*it)->contextId();
- if (assetContextId == contextId) {
+ uint actorContextId = (*it)->contextId();
+ if (actorContextId == contextId) {
it = _spatialEntities.erase(it);
} else {
++it;
@@ -428,17 +428,17 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
Asset *MediaStationEngine::findAssetToAcceptMouseEvents() {
Asset *intersectingAsset = nullptr;
// The z-indices seem to be reversed, so the highest z-index number is
- // actually the lowest asset.
+ // actually the lowest actor.
int lowestZIndex = INT_MAX;
- for (Asset *asset : _assets) {
- if (asset->type() == kAssetTypeHotspot) {
- Hotspot *hotspot = static_cast<Hotspot *>(asset);
+ for (Asset *actor : _actors) {
+ if (actor->type() == kAssetTypeHotspot) {
+ Hotspot *hotspot = static_cast<Hotspot *>(actor);
debugC(5, kDebugGraphics, "findAssetToAcceptMouseEvents(): Hotspot %d (z-index %d)", hotspot->id(), hotspot->zIndex());
if (hotspot->isActive() && hotspot->isInside(_mousePos)) {
if (hotspot->zIndex() < lowestZIndex) {
lowestZIndex = hotspot->zIndex();
- intersectingAsset = asset;
+ intersectingAsset = actor;
}
}
}
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index 609abb783c4..e129e1fbe42 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -39,7 +39,7 @@
#include "mediastation/datafile.h"
#include "mediastation/boot.h"
#include "mediastation/context.h"
-#include "mediastation/asset.h"
+#include "mediastation/actor.h"
#include "mediastation/cursors.h"
#include "mediastation/graphics.h"
@@ -82,11 +82,11 @@ public:
void addDirtyRect(const Common::Rect &rect) { _dirtyRects.push_back(rect); }
void draw();
- void registerAsset(Asset *assetToAdd);
+ void registerAsset(Asset *actorToAdd);
void scheduleScreenBranch(uint screenId);
void scheduleContextRelease(uint contextId);
- Asset *getAssetById(uint assetId);
+ Asset *getAssetById(uint actorId);
Asset *getAssetByChunkReference(uint chunkReference);
Function *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
@@ -117,7 +117,7 @@ private:
VideoDisplayManager *_displayManager = nullptr;
Boot *_boot = nullptr;
- Common::Array<Asset *> _assets;
+ Common::Array<Asset *> _actors;
Common::SortedArray<SpatialEntity *, const SpatialEntity *> _spatialEntities;
Common::HashMap<uint, Context *> _loadedContexts;
Asset *_currentHotspot = nullptr;
diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index b86556b3dcc..25424f0a2cc 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -1,20 +1,20 @@
MODULE := engines/mediastation
MODULE_OBJS = \
- asset.o \
- assets/canvas.o \
- assets/document.o \
- assets/font.o \
- assets/hotspot.o \
- assets/image.o \
- assets/movie.o \
- assets/palette.o \
- assets/path.o \
- assets/screen.o \
- assets/sound.o \
- assets/sprite.o \
- assets/text.o \
- assets/timer.o \
+ actor.o \
+ actors/canvas.o \
+ actors/document.o \
+ actors/font.o \
+ actors/hotspot.o \
+ actors/image.o \
+ actors/movie.o \
+ actors/palette.o \
+ actors/path.o \
+ actors/screen.o \
+ actors/sound.o \
+ actors/sprite.o \
+ actors/text.o \
+ actors/timer.o \
audio.o \
bitmap.o \
boot.o \
Commit: a3d915f0e720687ec2717e5ce47ef3492cdd67ae
https://github.com/scummvm/scummvm/commit/a3d915f0e720687ec2717e5ce47ef3492cdd67ae
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Rename asset to actor types
Changed paths:
engines/mediastation/actor.cpp
engines/mediastation/actor.h
engines/mediastation/actors/canvas.cpp
engines/mediastation/actors/canvas.h
engines/mediastation/actors/document.cpp
engines/mediastation/actors/document.h
engines/mediastation/actors/font.cpp
engines/mediastation/actors/font.h
engines/mediastation/actors/hotspot.cpp
engines/mediastation/actors/hotspot.h
engines/mediastation/actors/image.cpp
engines/mediastation/actors/image.h
engines/mediastation/actors/movie.cpp
engines/mediastation/actors/movie.h
engines/mediastation/actors/palette.cpp
engines/mediastation/actors/palette.h
engines/mediastation/actors/path.cpp
engines/mediastation/actors/path.h
engines/mediastation/actors/screen.cpp
engines/mediastation/actors/screen.h
engines/mediastation/actors/sound.cpp
engines/mediastation/actors/sound.h
engines/mediastation/actors/sprite.cpp
engines/mediastation/actors/sprite.h
engines/mediastation/actors/text.cpp
engines/mediastation/actors/text.h
engines/mediastation/actors/timer.cpp
engines/mediastation/actors/timer.h
engines/mediastation/boot.cpp
engines/mediastation/boot.h
engines/mediastation/context.cpp
engines/mediastation/context.h
engines/mediastation/graphics.cpp
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/collection.cpp
engines/mediastation/mediascript/eventhandler.cpp
engines/mediastation/mediascript/scriptconstants.cpp
engines/mediastation/mediascript/scriptconstants.h
engines/mediastation/mediascript/scriptvalue.cpp
engines/mediastation/mediascript/scriptvalue.h
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
diff --git a/engines/mediastation/actor.cpp b/engines/mediastation/actor.cpp
index ab14c76ca62..b30d5f9b10a 100644
--- a/engines/mediastation/actor.cpp
+++ b/engines/mediastation/actor.cpp
@@ -28,7 +28,7 @@
namespace MediaStation {
-Asset::~Asset() {
+Actor::~Actor() {
for (auto it = _eventHandlers.begin(); it != _eventHandlers.end(); ++it) {
Common::Array<EventHandler *> &handlersForType = it->_value;
for (EventHandler *handler : handlersForType) {
@@ -39,10 +39,10 @@ Asset::~Asset() {
_eventHandlers.clear();
}
-void Asset::initFromParameterStream(Chunk &chunk) {
- AssetHeaderSectionType paramType = kAssetHeaderEmptySection;
+void Actor::initFromParameterStream(Chunk &chunk) {
+ ActorHeaderSectionType paramType = kActorHeaderEmptySection;
while (true) {
- paramType = static_cast<AssetHeaderSectionType>(chunk.readTypedUint16());
+ paramType = static_cast<ActorHeaderSectionType>(chunk.readTypedUint16());
if (paramType == 0) {
break;
} else {
@@ -51,16 +51,16 @@ void Asset::initFromParameterStream(Chunk &chunk) {
}
}
-void Asset::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void Actor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderEventHandler: {
+ case kActorHeaderEventHandler: {
EventHandler *eventHandler = new EventHandler(chunk);
Common::Array<EventHandler *> &eventHandlersForType = _eventHandlers.getOrCreateVal(eventHandler->_type);
// This is not a hashmap because we don't want to have to hash ScriptValues.
for (EventHandler *existingEventHandler : eventHandlersForType) {
if (existingEventHandler->_argumentValue == eventHandler->_argumentValue) {
- error("AssetHeader::readSection(): Event handler for %s (%s) already exists",
+ error("ActorHeader::readSection(): Event handler for %s (%s) already exists",
eventTypeToStr(eventHandler->_type), eventHandler->getDebugHeader().c_str());
}
}
@@ -73,19 +73,19 @@ void Asset::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Asset::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue Actor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
error("Got unimplemented method call %d (%s)", static_cast<uint>(methodId), builtInMethodToStr(methodId));
}
-void Asset::readChunk(Chunk &chunk) {
- error("Asset::readChunk(): Chunk reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
+void Actor::readChunk(Chunk &chunk) {
+ error("Actor::readChunk(): Chunk reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
}
-void Asset::readSubfile(Subfile &subfile, Chunk &chunk) {
- error("Asset::readSubfile(): Subfile reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
+void Actor::readSubfile(Subfile &subfile, Chunk &chunk) {
+ error("Actor::readSubfile(): Subfile reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
}
-void Asset::processTimeEventHandlers() {
+void Actor::processTimeEventHandlers() {
// TODO: Replace with a queue.
uint currentTime = g_system->getMillis();
const Common::Array<EventHandler *> &_timeHandlers = _eventHandlers.getValOrDefault(kTimerEvent);
@@ -96,14 +96,14 @@ void Asset::processTimeEventHandlers() {
bool timeEventAlreadyProcessed = timeEventInMilliseconds < _lastProcessedTime;
bool timeEventNeedsToBeProcessed = timeEventInMilliseconds <= currentTime - _startTime;
if (!timeEventAlreadyProcessed && timeEventNeedsToBeProcessed) {
- debugC(5, kDebugScript, "Asset::processTimeEventHandlers(): Running On Time handler for time %d ms", timeEventInMilliseconds);
+ debugC(5, kDebugScript, "Actor::processTimeEventHandlers(): Running On Time handler for time %d ms", timeEventInMilliseconds);
timeEvent->execute(_id);
}
}
_lastProcessedTime = currentTime - _startTime;
}
-void Asset::runEventHandlerIfExists(EventType eventType, const ScriptValue &arg) {
+void Actor::runEventHandlerIfExists(EventType eventType, const ScriptValue &arg) {
const Common::Array<EventHandler *> &eventHandlers = _eventHandlers.getValOrDefault(eventType);
for (EventHandler *eventHandler : eventHandlers) {
const ScriptValue &argToCheck = eventHandler->_argumentValue;
@@ -123,7 +123,7 @@ void Asset::runEventHandlerIfExists(EventType eventType, const ScriptValue &arg)
debugC(5, kDebugScript, "No event handler for event type %s on actor %d", eventTypeToStr(eventType), _id);
}
-void Asset::runEventHandlerIfExists(EventType eventType) {
+void Actor::runEventHandlerIfExists(EventType eventType) {
ScriptValue scriptValue;
runEventHandlerIfExists(eventType, scriptValue);
}
@@ -214,39 +214,39 @@ ScriptValue SpatialEntity::callMethod(BuiltInMethod methodId, Common::Array<Scri
break;
default:
- Asset::callMethod(methodId, args);
+ Actor::callMethod(methodId, args);
}
return returnValue;
}
-void SpatialEntity::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void SpatialEntity::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderBoundingBox:
+ case kActorHeaderBoundingBox:
_boundingBox = chunk.readTypedRect();
break;
- case kAssetHeaderDissolveFactor:
+ case kActorHeaderDissolveFactor:
_dissolveFactor = chunk.readTypedDouble();
break;
- case kAssetHeaderZIndex:
+ case kActorHeaderZIndex:
_zIndex = chunk.readTypedGraphicUnit();
break;
- case kAssetHeaderTransparency:
+ case kActorHeaderTransparency:
_hasTransparency = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderStageId:
+ case kActorHeaderStageId:
_stageId = chunk.readTypedUint16();
break;
- case kAssetHeaderAssetReference:
+ case kActorHeaderActorReference:
_actorReference = chunk.readTypedUint16();
break;
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
@@ -310,7 +310,7 @@ void SpatialEntity::invalidateLocalBounds() {
}
void SpatialEntity::invalidateLocalZIndex() {
- warning("STUB: Asset::invalidateLocalZIndex()");
+ warning("STUB: Actor::invalidateLocalZIndex()");
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/actor.h b/engines/mediastation/actor.h
index 614a1a02139..80ab9a30597 100644
--- a/engines/mediastation/actor.h
+++ b/engines/mediastation/actor.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef MEDIASTATION_ASSET_H
-#define MEDIASTATION_ASSET_H
+#ifndef MEDIASTATION_ACTOR_H
+#define MEDIASTATION_ACTOR_H
#include "common/keyboard.h"
@@ -31,98 +31,98 @@
namespace MediaStation {
-enum AssetType {
- kAssetTypeEmpty = 0x0000,
- kAssetTypeScreen = 0x0001, // SCR
- kAssetTypeStage = 0x0002, // STG
- kAssetTypePath = 0x0004, // PTH
- kAssetTypeSound = 0x0005, // SND
- kAssetTypeTimer = 0x0006, // TMR
- kAssetTypeImage = 0x0007, // IMG
- kAssetTypeHotspot = 0x000b, // HSP
- kAssetTypeSprite = 0x000e, // SPR
- kAssetTypeLKZazu = 0x000f,
- kAssetTypeLKConstellations = 0x0010,
- kAssetTypeDocument = 0x0011,
- kAssetTypeImageSet = 0x001d,
- kAssetTypeCursor = 0x000c, // CSR
- kAssetTypePrinter = 0x0019, // PRT
- kAssetTypeMovie = 0x0016, // MOV
- kAssetTypePalette = 0x0017,
- kAssetTypeText = 0x001a, // TXT
- kAssetTypeFont = 0x001b, // FON
- kAssetTypeCamera = 0x001c, // CAM
- kAssetTypeCanvas = 0x001e, // CVS
- kAssetTypeXsnd = 0x001f,
- kAssetTypeXsndMidi = 0x0020,
- kAssetTypeRecorder = 0x0021,
- kAssetTypeFunction = 0x0069 // FUN
+enum ActorType {
+ kActorTypeEmpty = 0x0000,
+ kActorTypeScreen = 0x0001, // SCR
+ kActorTypeStage = 0x0002, // STG
+ kActorTypePath = 0x0004, // PTH
+ kActorTypeSound = 0x0005, // SND
+ kActorTypeTimer = 0x0006, // TMR
+ kActorTypeImage = 0x0007, // IMG
+ kActorTypeHotspot = 0x000b, // HSP
+ kActorTypeSprite = 0x000e, // SPR
+ kActorTypeLKZazu = 0x000f,
+ kActorTypeLKConstellations = 0x0010,
+ kActorTypeDocument = 0x0011,
+ kActorTypeImageSet = 0x001d,
+ kActorTypeCursor = 0x000c, // CSR
+ kActorTypePrinter = 0x0019, // PRT
+ kActorTypeMovie = 0x0016, // MOV
+ kActorTypePalette = 0x0017,
+ kActorTypeText = 0x001a, // TXT
+ kActorTypeFont = 0x001b, // FON
+ kActorTypeCamera = 0x001c, // CAM
+ kActorTypeCanvas = 0x001e, // CVS
+ kActorTypeXsnd = 0x001f,
+ kActorTypeXsndMidi = 0x0020,
+ kActorTypeRecorder = 0x0021,
+ kActorTypeFunction = 0x0069 // FUN
};
-enum AssetHeaderSectionType {
- kAssetHeaderEmptySection = 0x0000,
- kAssetHeaderEventHandler = 0x0017,
- kAssetHeaderStageId = 0x0019,
- kAssetHeaderAssetId = 0x001a,
- kAssetHeaderChunkReference = 0x001b,
- kAssetHeaderMovieAnimationChunkReference = 0x06a4,
- kAssetHeaderMovieAudioChunkReference = 0x06a5,
- kAssetHeaderAssetReference = 0x077b,
- kAssetHeaderBoundingBox = 0x001c,
- kAssetHeaderMouseActiveArea = 0x001d,
- kAssetHeaderZIndex = 0x001e,
- kAssetHeaderStartup = 0x001f,
- kAssetHeaderTransparency = 0x0020,
- kAssetHeaderHasOwnSubfile = 0x0021,
- kAssetHeaderCursorResourceId = 0x0022,
- kAssetHeaderFrameRate = 0x0024,
- kAssetHeaderLoadType = 0x0032,
- kAssetHeaderSoundInfo = 0x0033,
- kAssetHeaderMovieLoadType = 0x0037,
- kAssetHeaderSpriteChunkCount = 0x03e8,
- kAssetHeaderPalette = 0x05aa,
- kAssetHeaderDissolveFactor = 0x05dc,
- kAssetHeaderGetOffstageEvents = 0x05dd,
- kAssetHeaderX = 0x05de,
- kAssetHeaderY = 0x05df,
+enum ActorHeaderSectionType {
+ kActorHeaderEmptySection = 0x0000,
+ kActorHeaderEventHandler = 0x0017,
+ kActorHeaderStageId = 0x0019,
+ kActorHeaderActorId = 0x001a,
+ kActorHeaderChunkReference = 0x001b,
+ kActorHeaderMovieAnimationChunkReference = 0x06a4,
+ kActorHeaderMovieAudioChunkReference = 0x06a5,
+ kActorHeaderActorReference = 0x077b,
+ kActorHeaderBoundingBox = 0x001c,
+ kActorHeaderMouseActiveArea = 0x001d,
+ kActorHeaderZIndex = 0x001e,
+ kActorHeaderStartup = 0x001f,
+ kActorHeaderTransparency = 0x0020,
+ kActorHeaderHasOwnSubfile = 0x0021,
+ kActorHeaderCursorResourceId = 0x0022,
+ kActorHeaderFrameRate = 0x0024,
+ kActorHeaderLoadType = 0x0032,
+ kActorHeaderSoundInfo = 0x0033,
+ kActorHeaderMovieLoadType = 0x0037,
+ kActorHeaderSpriteChunkCount = 0x03e8,
+ kActorHeaderPalette = 0x05aa,
+ kActorHeaderDissolveFactor = 0x05dc,
+ kActorHeaderGetOffstageEvents = 0x05dd,
+ kActorHeaderX = 0x05de,
+ kActorHeaderY = 0x05df,
// PATH FIELDS.
- kAssetHeaderStartPoint = 0x060e,
- kAssetHeaderEndPoint = 0x060f,
- kAssetHeaderPathTotalSteps = 0x0610,
- kAssetHeaderStepRate = 0x0611,
- kAssetHeaderDuration = 0x0612,
+ kActorHeaderStartPoint = 0x060e,
+ kActorHeaderEndPoint = 0x060f,
+ kActorHeaderPathTotalSteps = 0x0610,
+ kActorHeaderStepRate = 0x0611,
+ kActorHeaderDuration = 0x0612,
// CAMERA FIELDS.
- kAssetHeaderViewportOrigin = 0x076f,
- kAssetHeaderLensOpen = 0x0770,
+ kActorHeaderViewportOrigin = 0x076f,
+ kActorHeaderLensOpen = 0x0770,
// STAGE FIELDS.
- kAssetHeaderStageUnk1 = 0x0771,
- kAssetHeaderCylindricalX = 0x0772,
- kAssetHeaderCylindricalY = 0x0773,
- kAssetHeaderAssetName = 0x0bb8,
+ kActorHeaderStageUnk1 = 0x0771,
+ kActorHeaderCylindricalX = 0x0772,
+ kActorHeaderCylindricalY = 0x0773,
+ kActorHeaderActorName = 0x0bb8,
// TEXT FIELDS.
- kAssetHeaderEditable = 0x03eb,
- kAssetHeaderFontId = 0x0258,
- kAssetHeaderInitialText = 0x0259,
- kAssetHeaderTextMaxLength = 0x25a,
- kAssetHeaderTextJustification = 0x025b,
- kAssetHeaderTextPosition = 0x25f,
- kAssetHeaderTextUnk1 = 0x262,
- kAssetHeaderTextUnk2 = 0x263,
- kAssetHeaderTextCharacterClass = 0x0266,
+ kActorHeaderEditable = 0x03eb,
+ kActorHeaderFontId = 0x0258,
+ kActorHeaderInitialText = 0x0259,
+ kActorHeaderTextMaxLength = 0x25a,
+ kActorHeaderTextJustification = 0x025b,
+ kActorHeaderTextPosition = 0x25f,
+ kActorHeaderTextUnk1 = 0x262,
+ kActorHeaderTextUnk2 = 0x263,
+ kActorHeaderTextCharacterClass = 0x0266,
// SPRITE FIELDS.
- kAssetHeaderSpriteClip = 0x03e9,
- kAssetHeaderCurrentSpriteClip = 0x03ea
+ kActorHeaderSpriteClip = 0x03e9,
+ kActorHeaderCurrentSpriteClip = 0x03ea
};
-class Asset {
+class Actor {
public:
- Asset(AssetType type) : _type(type) {};
- virtual ~Asset();
+ Actor(ActorType type) : _type(type) {};
+ virtual ~Actor();
// Does any needed frame drawing, audio playing, event handlers, etc.
virtual void process() { return; }
@@ -133,7 +133,7 @@ public:
virtual bool isSpatialActor() const { return false; }
virtual void initFromParameterStream(Chunk &chunk);
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType);
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType);
// These are not pure virtual so if an actor doesnʻt read any chunks or
// subfiles it doesnʻt need to just implement these with an error message.
@@ -144,7 +144,7 @@ public:
void runEventHandlerIfExists(EventType eventType, const ScriptValue &arg);
void runEventHandlerIfExists(EventType eventType);
- AssetType type() const { return _type; }
+ ActorType type() const { return _type; }
uint id() const { return _id; }
uint contextId() const { return _contextId; }
void setId(uint id) { _id = id; }
@@ -154,7 +154,7 @@ public:
uint _actorReference = 0;
protected:
- AssetType _type = kAssetTypeEmpty;
+ ActorType _type = kActorTypeEmpty;
uint _id = 0;
uint _contextId = 0;
@@ -164,13 +164,13 @@ protected:
Common::HashMap<uint, Common::Array<EventHandler *> > _eventHandlers;
};
-class SpatialEntity : public Asset {
+class SpatialEntity : public Actor {
public:
- SpatialEntity(AssetType type) : Asset(type) {};
+ SpatialEntity(ActorType type) : Actor(type) {};
virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) { return; }
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual bool isSpatialActor() const override { return true; }
virtual bool isVisible() const { return _isVisible; }
diff --git a/engines/mediastation/actors/canvas.cpp b/engines/mediastation/actors/canvas.cpp
index a6cb59d05c4..7f8b8cd1256 100644
--- a/engines/mediastation/actors/canvas.cpp
+++ b/engines/mediastation/actors/canvas.cpp
@@ -23,9 +23,9 @@
namespace MediaStation {
-void Canvas::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void CanvasActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isVisible = static_cast<bool>(chunk.readTypedByte());
break;
@@ -34,10 +34,10 @@ void Canvas::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Canvas::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue CanvasActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
switch (methodId) {
case kClearToPaletteMethod: {
- error("Canvas::callMethod(): BuiltInFunction::clearToPalette is not implemented yet");
+ error("CanvasActor::callMethod(): BuiltInFunction::clearToPalette is not implemented yet");
}
default:
diff --git a/engines/mediastation/actors/canvas.h b/engines/mediastation/actors/canvas.h
index 7395b031a69..904bc5b9e5b 100644
--- a/engines/mediastation/actors/canvas.h
+++ b/engines/mediastation/actors/canvas.h
@@ -28,11 +28,11 @@
namespace MediaStation {
-class Canvas : public SpatialEntity {
+class CanvasActor : public SpatialEntity {
public:
- Canvas() : SpatialEntity(kAssetTypeCanvas) {};
+ CanvasActor() : SpatialEntity(kActorTypeCanvas) {};
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
};
diff --git a/engines/mediastation/actors/document.cpp b/engines/mediastation/actors/document.cpp
index 7b224030886..6bd1b6a5ec2 100644
--- a/engines/mediastation/actors/document.cpp
+++ b/engines/mediastation/actors/document.cpp
@@ -24,7 +24,7 @@
namespace MediaStation {
-ScriptValue Document::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue DocumentActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -34,19 +34,19 @@ ScriptValue Document::callMethod(BuiltInMethod methodId, Common::Array<ScriptVal
case kReleaseContextMethod: {
assert(args.size() == 1);
- uint32 contextId = args[0].asAssetId();
+ uint32 contextId = args[0].asActorId();
g_engine->scheduleContextRelease(contextId);
return returnValue;
}
default:
- return Asset::callMethod(methodId, args);
+ return Actor::callMethod(methodId, args);
}
}
-void Document::processBranch(Common::Array<ScriptValue> &args) {
+void DocumentActor::processBranch(Common::Array<ScriptValue> &args) {
assert(args.size() >= 1);
- uint contextId = args[0].asAssetId();
+ uint contextId = args[0].asActorId();
if (args.size() > 1) {
bool disableUpdates = static_cast<bool>(args[1].asParamToken());
if (disableUpdates)
diff --git a/engines/mediastation/actors/document.h b/engines/mediastation/actors/document.h
index 6aef876b8bd..3b049e6eeb6 100644
--- a/engines/mediastation/actors/document.h
+++ b/engines/mediastation/actors/document.h
@@ -28,9 +28,9 @@
namespace MediaStation {
-class Document : public Asset {
+class DocumentActor : public Actor {
public:
- Document() : Asset(kAssetTypeDocument) { _id = 1; };
+ DocumentActor() : Actor(kActorTypeDocument) { _id = 1; };
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
diff --git a/engines/mediastation/actors/font.cpp b/engines/mediastation/actors/font.cpp
index 37daf55575e..c7efde6e519 100644
--- a/engines/mediastation/actors/font.cpp
+++ b/engines/mediastation/actors/font.cpp
@@ -30,33 +30,33 @@ FontGlyph::FontGlyph(Chunk &chunk, uint asciiCode, uint unk1, uint unk2, BitmapH
_unk2 = unk2;
}
-Font::~Font() {
+FontActor::~FontActor() {
for (auto it = _glyphs.begin(); it != _glyphs.end(); ++it) {
delete it->_value;
}
_glyphs.clear();
}
-void Font::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void FontActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderChunkReference:
+ case kActorHeaderChunkReference:
_chunkReference = chunk.readTypedChunkReference();
break;
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
-void Font::readChunk(Chunk &chunk) {
- debugC(5, kDebugLoading, "Font::readChunk(): Reading font glyph (@0x%llx)", static_cast<long long int>(chunk.pos()));
+void FontActor::readChunk(Chunk &chunk) {
+ debugC(5, kDebugLoading, "FontActor::readChunk(): Reading font glyph (@0x%llx)", static_cast<long long int>(chunk.pos()));
uint asciiCode = chunk.readTypedUint16();
int unk1 = chunk.readTypedUint16();
int unk2 = chunk.readTypedUint16();
BitmapHeader *header = new BitmapHeader(chunk);
FontGlyph *glyph = new FontGlyph(chunk, asciiCode, unk1, unk2, header);
if (_glyphs.getValOrDefault(asciiCode) != nullptr) {
- error("Font::readChunk(): Glyph for ASCII code 0x%x already exists", asciiCode);
+ error("FontActor::readChunk(): Glyph for ASCII code 0x%x already exists", asciiCode);
}
_glyphs.setVal(asciiCode, glyph);
}
diff --git a/engines/mediastation/actors/font.h b/engines/mediastation/actors/font.h
index d047bd07f9b..98629fce76c 100644
--- a/engines/mediastation/actors/font.h
+++ b/engines/mediastation/actors/font.h
@@ -40,12 +40,12 @@ private:
int _unk2 = 0;
};
-class Font : public Asset {
+class FontActor : public Actor {
public:
- Font() : Asset(kAssetTypeFont) {};
- ~Font();
+ FontActor() : Actor(kActorTypeFont) {};
+ ~FontActor();
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual void readChunk(Chunk &chunk) override;
private:
diff --git a/engines/mediastation/actors/hotspot.cpp b/engines/mediastation/actors/hotspot.cpp
index 299bed8ca71..fcf25bf188c 100644
--- a/engines/mediastation/actors/hotspot.cpp
+++ b/engines/mediastation/actors/hotspot.cpp
@@ -24,9 +24,9 @@
namespace MediaStation {
-void Hotspot::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void HotspotActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderMouseActiveArea: {
+ case kActorHeaderMouseActiveArea: {
uint16 total_points = chunk.readTypedUint16();
for (int i = 0; i < total_points; i++) {
Common::Point point = chunk.readTypedPoint();
@@ -35,15 +35,15 @@ void Hotspot::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
break;
}
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isActive = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderCursorResourceId:
+ case kActorHeaderCursorResourceId:
_cursorResourceId = chunk.readTypedUint16();
break;
- case kAssetHeaderGetOffstageEvents:
+ case kActorHeaderGetOffstageEvents:
_getOffstageEvents = static_cast<bool>(chunk.readTypedByte());
break;
@@ -52,7 +52,7 @@ void Hotspot::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-bool Hotspot::isInside(const Common::Point &pointToCheck) {
+bool HotspotActor::isInside(const Common::Point &pointToCheck) {
// No sense checking the polygon if we're not even in the bbox.
if (!_boundingBox.contains(pointToCheck)) {
return false;
@@ -90,7 +90,7 @@ bool Hotspot::isInside(const Common::Point &pointToCheck) {
return ((rcross % 2) == 1);
}
-ScriptValue Hotspot::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue HotspotActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
diff --git a/engines/mediastation/actors/hotspot.h b/engines/mediastation/actors/hotspot.h
index ac9c689eb70..790fa5e1b12 100644
--- a/engines/mediastation/actors/hotspot.h
+++ b/engines/mediastation/actors/hotspot.h
@@ -28,16 +28,16 @@
namespace MediaStation {
-class Hotspot : public SpatialEntity {
+class HotspotActor : public SpatialEntity {
public:
- Hotspot() : SpatialEntity(kAssetTypeHotspot) {};
- virtual ~Hotspot() { _mouseActiveArea.clear(); }
+ HotspotActor() : SpatialEntity(kActorTypeHotspot) {};
+ virtual ~HotspotActor() { _mouseActiveArea.clear(); }
bool isInside(const Common::Point &pointToCheck);
virtual bool isVisible() const override { return false; }
bool isActive() const { return _isActive; }
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
uint _cursorResourceId = 0;
diff --git a/engines/mediastation/actors/image.cpp b/engines/mediastation/actors/image.cpp
index 2e0739bd7a0..dc823e4f82e 100644
--- a/engines/mediastation/actors/image.cpp
+++ b/engines/mediastation/actors/image.cpp
@@ -25,7 +25,7 @@
namespace MediaStation {
-Image::~Image() {
+ImageActor::~ImageActor() {
if (_actorReference == 0) {
// If we're just referencing another actor's bitmap,
// don't delete that bitmap.
@@ -34,25 +34,25 @@ Image::~Image() {
_bitmap = nullptr;
}
-void Image::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void ImageActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderChunkReference:
+ case kActorHeaderChunkReference:
_chunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isVisible = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderLoadType:
+ case kActorHeaderLoadType:
_loadType = chunk.readTypedByte();
break;
- case kAssetHeaderX:
+ case kActorHeaderX:
_xOffset = chunk.readTypedUint16();
break;
- case kAssetHeaderY:
+ case kActorHeaderY:
_yOffset = chunk.readTypedUint16();
break;
@@ -61,7 +61,7 @@ void Image::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Image::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue ImageActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
case kSpatialShowMethod: {
@@ -81,34 +81,34 @@ ScriptValue Image::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
}
-void Image::draw(const Common::Array<Common::Rect> &dirtyRegion) {
+void ImageActor::draw(const Common::Array<Common::Rect> &dirtyRegion) {
if (_isVisible) {
Common::Point origin = getBbox().origin();
g_engine->getDisplayManager()->imageBlit(origin, _bitmap, _dissolveFactor, dirtyRegion);
}
}
-void Image::invalidateLocalBounds() {
+void ImageActor::invalidateLocalBounds() {
g_engine->addDirtyRect(getBbox());
}
-void Image::spatialShow() {
+void ImageActor::spatialShow() {
_isVisible = true;
invalidateLocalBounds();
}
-void Image::spatialHide() {
+void ImageActor::spatialHide() {
_isVisible = false;
invalidateLocalBounds();
}
-Common::Rect Image::getBbox() const {
+Common::Rect ImageActor::getBbox() const {
Common::Point origin(_xOffset + _boundingBox.left, _yOffset + _boundingBox.top);
Common::Rect bbox(origin, _bitmap->width(), _bitmap->height());
return bbox;
}
-void Image::readChunk(Chunk &chunk) {
+void ImageActor::readChunk(Chunk &chunk) {
BitmapHeader *bitmapHeader = new BitmapHeader(chunk);
_bitmap = new Bitmap(chunk, bitmapHeader);
}
diff --git a/engines/mediastation/actors/image.h b/engines/mediastation/actors/image.h
index c6a8d3759a7..ac14e33a9a1 100644
--- a/engines/mediastation/actors/image.h
+++ b/engines/mediastation/actors/image.h
@@ -30,15 +30,15 @@
namespace MediaStation {
-class Image : public SpatialEntity {
+class ImageActor : public SpatialEntity {
friend class Context;
public:
- Image() : SpatialEntity(kAssetTypeImage) {};
- virtual ~Image() override;
+ ImageActor() : SpatialEntity(kActorTypeImage) {};
+ virtual ~ImageActor() override;
virtual void readChunk(Chunk &chunk) override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) override;
virtual void invalidateLocalBounds() override;
diff --git a/engines/mediastation/actors/movie.cpp b/engines/mediastation/actors/movie.cpp
index b14d96abcd8..33c258f925d 100644
--- a/engines/mediastation/actors/movie.cpp
+++ b/engines/mediastation/actors/movie.cpp
@@ -75,7 +75,7 @@ MovieFrameImage::~MovieFrameImage() {
// we don't need to delete that here.
}
-Movie::~Movie() {
+StreamMovieActor::~StreamMovieActor() {
for (MovieFrame *frame : _frames) {
delete frame;
}
@@ -87,47 +87,47 @@ Movie::~Movie() {
_images.clear();
}
-void Movie::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void StreamMovieActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderAssetId: {
+ case kActorHeaderActorId: {
// We already have this actor's ID, so we will just verify it is the same
// as the ID we have already read.
- uint32 duplicateAssetId = chunk.readTypedUint16();
- if (duplicateAssetId != _id) {
- warning("Duplicate actor ID %d does not match original ID %d", duplicateAssetId, _id);
+ uint32 duplicateActorId = chunk.readTypedUint16();
+ if (duplicateActorId != _id) {
+ warning("Duplicate actor ID %d does not match original ID %d", duplicateActorId, _id);
}
break;
}
- case kAssetHeaderMovieLoadType:
+ case kActorHeaderMovieLoadType:
_loadType = chunk.readTypedByte();
break;
- case kAssetHeaderChunkReference:
+ case kActorHeaderChunkReference:
_chunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderHasOwnSubfile: {
+ case kActorHeaderHasOwnSubfile: {
bool hasOwnSubfile = static_cast<bool>(chunk.readTypedByte());
if (!hasOwnSubfile) {
- error("Movie doesn't have a subfile");
+ error("StreamMovieActor doesn't have a subfile");
}
break;
}
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isVisible = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderMovieAudioChunkReference:
+ case kActorHeaderMovieAudioChunkReference:
_audioChunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderMovieAnimationChunkReference:
+ case kActorHeaderMovieAnimationChunkReference:
_animationChunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderSoundInfo:
+ case kActorHeaderSoundInfo:
_audioChunkCount = chunk.readTypedUint16();
_audioSequence.readParameters(chunk);
break;
@@ -137,7 +137,7 @@ void Movie::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Movie::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue StreamMovieActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -191,7 +191,7 @@ ScriptValue Movie::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
}
-void Movie::timePlay() {
+void StreamMovieActor::timePlay() {
// TODO: Play movies one chunk at a time, which more directly approximates
// the original's reading from the CD one chunk at a time.
if (_isPlaying) {
@@ -208,7 +208,7 @@ void Movie::timePlay() {
process();
}
-void Movie::timeStop() {
+void StreamMovieActor::timeStop() {
if (!_isPlaying) {
return;
}
@@ -228,7 +228,7 @@ void Movie::timeStop() {
runEventHandlerIfExists(kMovieStoppedEvent);
}
-void Movie::process() {
+void StreamMovieActor::process() {
if (_isVisible) {
if (_isPlaying) {
processTimeEventHandlers();
@@ -237,20 +237,20 @@ void Movie::process() {
}
}
-void Movie::setVisibility(bool visibility) {
+void StreamMovieActor::setVisibility(bool visibility) {
if (visibility != _isVisible) {
_isVisible = visibility;
invalidateLocalBounds();
}
}
-void Movie::updateFrameState() {
+void StreamMovieActor::updateFrameState() {
uint movieTime = 0;
if (_isPlaying) {
uint currentTime = g_system->getMillis();
movieTime = currentTime - _startTime;
}
- debugC(5, kDebugGraphics, "Movie::updateFrameState (%d): Starting update (movie time: %d)", _id, movieTime);
+ debugC(5, kDebugGraphics, "StreamMovieActor::updateFrameState (%d): Starting update (movie time: %d)", _id, movieTime);
// This complexity is necessary becuase movies can have more than one frame
// showing at the same time - for instance, a movie background and an
@@ -307,7 +307,7 @@ void Movie::updateFrameState() {
}
}
-void Movie::draw(const Common::Array<Common::Rect> &dirtyRegion) {
+void StreamMovieActor::draw(const Common::Array<Common::Rect> &dirtyRegion) {
for (MovieFrame *frame : _framesOnScreen) {
Common::Rect bbox = getFrameBoundingBox(frame);
@@ -333,13 +333,13 @@ void Movie::draw(const Common::Array<Common::Rect> &dirtyRegion) {
}
}
-Common::Rect Movie::getFrameBoundingBox(MovieFrame *frame) {
+Common::Rect StreamMovieActor::getFrameBoundingBox(MovieFrame *frame) {
Common::Point origin = _boundingBox.origin() + frame->leftTop;
Common::Rect bbox = Common::Rect(origin, frame->image->width(), frame->image->height());
return bbox;
}
-void Movie::readChunk(Chunk &chunk) {
+void StreamMovieActor::readChunk(Chunk &chunk) {
// Individual chunks are "stills" and are stored in the first subfile.
uint sectionType = chunk.readTypedUint16();
switch ((MovieSectionType)sectionType) {
@@ -357,20 +357,20 @@ void Movie::readChunk(Chunk &chunk) {
_hasStill = true;
}
-void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
+void StreamMovieActor::readSubfile(Subfile &subfile, Chunk &chunk) {
uint expectedRootSectionType = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Movie::readSubfile(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(expectedRootSectionType), static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(expectedRootSectionType), static_cast<long long int>(chunk.pos()));
if (kMovieRootSection != (MovieSectionType)expectedRootSectionType) {
error("Expected ROOT section type, got 0x%x", expectedRootSectionType);
}
uint chunkCount = chunk.readTypedUint16();
double unk1 = chunk.readTypedDouble();
- debugC(5, kDebugLoading, "Movie::readSubfile(): chunkCount = 0x%x, unk1 = %f (@0x%llx)", chunkCount, unk1, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): chunkCount = 0x%x, unk1 = %f (@0x%llx)", chunkCount, unk1, static_cast<long long int>(chunk.pos()));
Common::Array<uint> chunkLengths;
for (uint i = 0; i < chunkCount; i++) {
uint chunkLength = chunk.readTypedUint32();
- debugC(5, kDebugLoading, "Movie::readSubfile(): chunkLength = 0x%x (@0x%llx)", chunkLength, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): chunkLength = 0x%x (@0x%llx)", chunkLength, static_cast<long long int>(chunk.pos()));
chunkLengths.push_back(chunkLength);
}
@@ -380,14 +380,14 @@ void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
chunk = subfile.nextChunk();
// READ ALL THE FRAMES IN THIS CHUNK.
- debugC(5, kDebugLoading, "Movie::readSubfile(): (Frameset %d of %d) Reading animation chunks... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): (Frameset %d of %d) Reading animation chunks... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
bool isAnimationChunk = (chunk._id == _animationChunkReference);
if (!isAnimationChunk) {
- warning("Movie::readSubfile(): (Frameset %d of %d) No animation chunks found (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ warning("StreamMovieActor::readSubfile(): (Frameset %d of %d) No animation chunks found (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
}
while (isAnimationChunk) {
uint sectionType = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Movie::readSubfile(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
switch (MovieSectionType(sectionType)) {
case kMovieImageDataSection:
readImageData(chunk);
@@ -398,7 +398,7 @@ void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
break;
default:
- error("Movie::readSubfile(): Unknown movie animation section type 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+ error("StreamMovieActor::readSubfile(): Unknown movie animation section type 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
}
chunk = subfile.nextChunk();
@@ -406,24 +406,24 @@ void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
}
// READ THE AUDIO.
- debugC(5, kDebugLoading, "Movie::readSubfile(): (Frameset %d of %d) Reading audio chunk... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): (Frameset %d of %d) Reading audio chunk... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
bool isAudioChunk = (chunk._id == _audioChunkReference);
if (isAudioChunk) {
_audioSequence.readChunk(chunk);
chunk = subfile.nextChunk();
} else {
- debugC(5, kDebugLoading, "Movie::readSubfile(): (Frameset %d of %d) No audio chunk to read. (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): (Frameset %d of %d) No audio chunk to read. (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
}
- debugC(5, kDebugLoading, "Movie::readSubfile(): (Frameset %d of %d) Reading header chunk... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): (Frameset %d of %d) Reading header chunk... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
bool isHeaderChunk = (chunk._id == _chunkReference);
if (isHeaderChunk) {
if (chunk._length != 0x04) {
- error("Movie::readSubfile(): Expected movie header chunk of size 0x04, got 0x%x (@0x%llx)", chunk._length, static_cast<long long int>(chunk.pos()));
+ error("StreamMovieActor::readSubfile(): Expected movie header chunk of size 0x04, got 0x%x (@0x%llx)", chunk._length, static_cast<long long int>(chunk.pos()));
}
chunk.skip(chunk._length);
} else {
- error("Movie::readSubfile(): Expected header chunk, got %s (@0x%llx)", tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
+ error("StreamMovieActor::readSubfile(): Expected header chunk, got %s (@0x%llx)", tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
}
}
@@ -438,11 +438,11 @@ void Movie::readSubfile(Subfile &subfile, Chunk &chunk) {
}
}
-void Movie::invalidateRect(const Common::Rect &rect) {
+void StreamMovieActor::invalidateRect(const Common::Rect &rect) {
g_engine->addDirtyRect(rect);
}
-void Movie::decompressIntoAuxImage(MovieFrame *frame) {
+void StreamMovieActor::decompressIntoAuxImage(MovieFrame *frame) {
const Common::Point origin(0, 0);
Common::Rect test = Common::Rect(frame->keyframeImage->width(), frame->keyframeImage->height());
Common::Array<Common::Rect> allDirty(1);
@@ -452,13 +452,13 @@ void Movie::decompressIntoAuxImage(MovieFrame *frame) {
g_engine->getDisplayManager()->imageBlit(origin, frame->keyframeImage, 1.0, allDirty, &frame->keyframeImage->_image);
}
-void Movie::readImageData(Chunk &chunk) {
+void StreamMovieActor::readImageData(Chunk &chunk) {
MovieFrameHeader *header = new MovieFrameHeader(chunk);
MovieFrameImage *frame = new MovieFrameImage(chunk, header);
_images.push_back(frame);
}
-void Movie::readFrameData(Chunk &chunk) {
+void StreamMovieActor::readFrameData(Chunk &chunk) {
uint frameDataToRead = chunk.readTypedUint16();
for (uint i = 0; i < frameDataToRead; i++) {
MovieFrame *frame = new MovieFrame(chunk);
@@ -486,7 +486,7 @@ void Movie::readFrameData(Chunk &chunk) {
}
}
-int Movie::compareFramesByZIndex(const MovieFrame *a, const MovieFrame *b) {
+int StreamMovieActor::compareFramesByZIndex(const MovieFrame *a, const MovieFrame *b) {
if (b->zIndex > a->zIndex) {
return 1;
} else if (a->zIndex > b->zIndex) {
diff --git a/engines/mediastation/actors/movie.h b/engines/mediastation/actors/movie.h
index 8d3cb23f08e..9b7221f89c6 100644
--- a/engines/mediastation/actors/movie.h
+++ b/engines/mediastation/actors/movie.h
@@ -82,15 +82,15 @@ struct MovieFrame {
MovieFrameImage *keyframeImage = nullptr;
};
-class Movie : public SpatialEntity {
+class StreamMovieActor : public SpatialEntity {
public:
- Movie() : _framesOnScreen(Movie::compareFramesByZIndex), SpatialEntity(kAssetTypeMovie) {}
- virtual ~Movie() override;
+ StreamMovieActor() : _framesOnScreen(StreamMovieActor::compareFramesByZIndex), SpatialEntity(kActorTypeMovie) {}
+ virtual ~StreamMovieActor() override;
virtual void readChunk(Chunk &chunk) override;
virtual void readSubfile(Subfile &subfile, Chunk &chunk) override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual void process() override;
diff --git a/engines/mediastation/actors/palette.cpp b/engines/mediastation/actors/palette.cpp
index cc9e852aefb..f42d3b7a77f 100644
--- a/engines/mediastation/actors/palette.cpp
+++ b/engines/mediastation/actors/palette.cpp
@@ -25,14 +25,14 @@
namespace MediaStation {
-Palette::~Palette() {
+PaletteActor::~PaletteActor() {
delete _palette;
_palette = nullptr;
}
-void Palette::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void PaletteActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderPalette: {
+ case kActorHeaderPalette: {
byte *buffer = new byte[Graphics::PALETTE_SIZE];
chunk.read(buffer, Graphics::PALETTE_SIZE);
_palette = new Graphics::Palette(buffer, Graphics::PALETTE_COUNT, DisposeAfterUse::YES);
@@ -40,7 +40,7 @@ void Palette::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
diff --git a/engines/mediastation/actors/palette.h b/engines/mediastation/actors/palette.h
index cad11c171da..b4b5a1e214a 100644
--- a/engines/mediastation/actors/palette.h
+++ b/engines/mediastation/actors/palette.h
@@ -30,12 +30,12 @@
namespace MediaStation {
-class Palette : public Asset {
+class PaletteActor : public Actor {
public:
- Palette() : Asset(kAssetTypePalette) {};
- virtual ~Palette() override;
+ PaletteActor() : Actor(kActorTypePalette) {};
+ virtual ~PaletteActor() override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
Graphics::Palette *_palette = nullptr;
};
diff --git a/engines/mediastation/actors/path.cpp b/engines/mediastation/actors/path.cpp
index b935ed6df43..eabe7abb474 100644
--- a/engines/mediastation/actors/path.cpp
+++ b/engines/mediastation/actors/path.cpp
@@ -25,17 +25,17 @@
namespace MediaStation {
-void Path::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void PathActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderStartPoint:
+ case kActorHeaderStartPoint:
_startPoint = chunk.readTypedPoint();
break;
- case kAssetHeaderEndPoint:
+ case kActorHeaderEndPoint:
_endPoint = chunk.readTypedPoint();
break;
- case kAssetHeaderStepRate: {
+ case kActorHeaderStepRate: {
double _stepRateFloat = chunk.readTypedDouble();
// This should always be an integer anyway,
// so we'll cast away any fractional part.
@@ -43,22 +43,22 @@ void Path::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
break;
}
- case kAssetHeaderDuration:
+ case kActorHeaderDuration:
// These are stored in the file as fractional seconds,
// but we want milliseconds.
_duration = static_cast<uint32>(chunk.readTypedTime() * 1000);
break;
- case kAssetHeaderPathTotalSteps:
+ case kActorHeaderPathTotalSteps:
_totalSteps = chunk.readTypedUint16();
break;
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
-ScriptValue Path::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue PathActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -88,11 +88,11 @@ ScriptValue Path::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
default:
- return Asset::callMethod(methodId, args);
+ return Actor::callMethod(methodId, args);
}
}
-void Path::timePlay() {
+void PathActor::timePlay() {
if (_isPlaying) {
return;
}
@@ -116,7 +116,7 @@ void Path::timePlay() {
debugC(5, kDebugScript, "Path::timePlay(): No PathStart event handler");
}
-void Path::process() {
+void PathActor::process() {
if (!_isPlaying) {
return;
}
@@ -151,13 +151,13 @@ void Path::process() {
}
}
-void Path::setDuration(uint durationInMilliseconds) {
+void PathActor::setDuration(uint durationInMilliseconds) {
// TODO: Do we need to save the original duration?
debugC(5, kDebugScript, "Path::setDuration(): Setting duration to %d ms", durationInMilliseconds);
_duration = durationInMilliseconds;
}
-double Path::percentComplete() {
+double PathActor::percentComplete() {
debugC(5, kDebugScript, "Path::percentComplete(): Returning percent complete %f%%", _percentComplete * 100);
return _percentComplete;
}
diff --git a/engines/mediastation/actors/path.h b/engines/mediastation/actors/path.h
index 62e1ebc8f65..1e6c42b6efb 100644
--- a/engines/mediastation/actors/path.h
+++ b/engines/mediastation/actors/path.h
@@ -28,13 +28,13 @@
namespace MediaStation {
-class Path : public Asset {
+class PathActor : public Actor {
public:
- Path() : Asset(kAssetTypePath) {};
+ PathActor() : Actor(kActorTypePath) {};
virtual void process() override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
private:
diff --git a/engines/mediastation/actors/screen.cpp b/engines/mediastation/actors/screen.cpp
index 783c133afc4..ff2b64c8269 100644
--- a/engines/mediastation/actors/screen.cpp
+++ b/engines/mediastation/actors/screen.cpp
@@ -24,14 +24,14 @@
namespace MediaStation {
-void Screen::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void ScreenActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderCursorResourceId:
+ case kActorHeaderCursorResourceId:
_cursorResourceId = chunk.readTypedUint16();
break;
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
diff --git a/engines/mediastation/actors/screen.h b/engines/mediastation/actors/screen.h
index de25535c146..5167f7b526c 100644
--- a/engines/mediastation/actors/screen.h
+++ b/engines/mediastation/actors/screen.h
@@ -31,11 +31,11 @@ namespace MediaStation {
// A Screen holds actor data and processes event handlers for a Context.
// The original separated them this way - there is a ContextParameters section,
// then a Screen actor header.
-class Screen : public Asset {
+class ScreenActor : public Actor {
public:
- Screen() : Asset(kAssetTypeScreen) {};
+ ScreenActor() : Actor(kActorTypeScreen) {};
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
uint _cursorResourceId = 0;
};
diff --git a/engines/mediastation/actors/sound.cpp b/engines/mediastation/actors/sound.cpp
index 45b3d9b1601..17f4ebeeb22 100644
--- a/engines/mediastation/actors/sound.cpp
+++ b/engines/mediastation/actors/sound.cpp
@@ -25,41 +25,41 @@
namespace MediaStation {
-void Sound::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void SoundActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderAssetId: {
+ case kActorHeaderActorId: {
// We already have this actor's ID, so we will just verify it is the same
// as the ID we have already read.
- uint32 duplicateAssetId = chunk.readTypedUint16();
- if (duplicateAssetId != _id) {
- warning("Duplicate actor ID %d does not match original ID %d", duplicateAssetId, _id);
+ uint32 duplicateActorId = chunk.readTypedUint16();
+ if (duplicateActorId != _id) {
+ warning("Duplicate actor ID %d does not match original ID %d", duplicateActorId, _id);
}
break;
}
- case kAssetHeaderChunkReference:
+ case kActorHeaderChunkReference:
_chunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderHasOwnSubfile:
+ case kActorHeaderHasOwnSubfile:
_hasOwnSubfile = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderSoundInfo:
+ case kActorHeaderSoundInfo:
_chunkCount = chunk.readTypedUint16();
_sequence.readParameters(chunk);
break;
- case kAssetHeaderMovieLoadType:
+ case kActorHeaderMovieLoadType:
_loadType = chunk.readTypedByte();
break;
default:
- Asset::readParameter(chunk, paramType);
+ Actor::readParameter(chunk, paramType);
}
}
-void Sound::process() {
+void SoundActor::process() {
if (!_isPlaying) {
return;
}
@@ -72,7 +72,7 @@ void Sound::process() {
}
}
-ScriptValue Sound::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue SoundActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -97,11 +97,11 @@ ScriptValue Sound::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
default:
- return Asset::callMethod(methodId, args);
+ return Actor::callMethod(methodId, args);
}
}
-void Sound::readSubfile(Subfile &subfile, Chunk &chunk) {
+void SoundActor::readSubfile(Subfile &subfile, Chunk &chunk) {
uint32 expectedChunkId = chunk._id;
debugC(5, kDebugLoading, "Sound::readSubfile(): Reading %d chunks", _chunkCount);
@@ -116,7 +116,7 @@ void Sound::readSubfile(Subfile &subfile, Chunk &chunk) {
}
}
-void Sound::timePlay() {
+void SoundActor::timePlay() {
if (_isPlaying) {
return;
}
@@ -134,7 +134,7 @@ void Sound::timePlay() {
runEventHandlerIfExists(kSoundBeginEvent);
}
-void Sound::timeStop() {
+void SoundActor::timeStop() {
if (!_isPlaying) {
return;
}
diff --git a/engines/mediastation/actors/sound.h b/engines/mediastation/actors/sound.h
index e21ba7ebc9a..119839c1278 100644
--- a/engines/mediastation/actors/sound.h
+++ b/engines/mediastation/actors/sound.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef MEDIASTATION_ASSETS_SOUND_H
-#define MEDIASTATION_ASSETS_SOUND_H
+#ifndef MEDIASTATION_ACTORS_SOUND_H
+#define MEDIASTATION_ACTORS_SOUND_H
#include "mediastation/actor.h"
#include "mediastation/audio.h"
@@ -30,11 +30,11 @@
namespace MediaStation {
-class Sound : public Asset {
+class SoundActor : public Actor {
public:
- Sound() : Asset(kAssetTypeSound) {};
+ SoundActor() : Actor(kActorTypeSound) {};
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual void process() override;
diff --git a/engines/mediastation/actors/sprite.cpp b/engines/mediastation/actors/sprite.cpp
index e4eba002dbb..7e975e8c40e 100644
--- a/engines/mediastation/actors/sprite.cpp
+++ b/engines/mediastation/actors/sprite.cpp
@@ -60,7 +60,7 @@ uint32 SpriteFrame::index() {
return _bitmapHeader->_index;
}
-Sprite::~Sprite() {
+SpriteMovieActor::~SpriteMovieActor() {
// If we're just referencing another actor's frames,
// don't delete those frames.
if (_actorReference == 0) {
@@ -71,25 +71,25 @@ Sprite::~Sprite() {
_frames.clear();
}
-void Sprite::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void SpriteMovieActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderChunkReference:
+ case kActorHeaderChunkReference:
_chunkReference = chunk.readTypedChunkReference();
break;
- case kAssetHeaderFrameRate:
+ case kActorHeaderFrameRate:
_frameRate = static_cast<uint32>(chunk.readTypedDouble());
break;
- case kAssetHeaderLoadType:
+ case kActorHeaderLoadType:
_loadType = chunk.readTypedByte();
break;
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isVisible = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderSpriteChunkCount: {
+ case kActorHeaderSpriteChunkCount: {
_frameCount = chunk.readTypedUint16();
// Set the default clip.
@@ -102,7 +102,7 @@ void Sprite::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
break;
}
- case kAssetHeaderSpriteClip: {
+ case kActorHeaderSpriteClip: {
SpriteClip spriteClip;
spriteClip.id = chunk.readTypedUint16();
spriteClip.firstFrameIndex = chunk.readTypedUint16();
@@ -111,7 +111,7 @@ void Sprite::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
break;
}
- case kAssetHeaderCurrentSpriteClip: {
+ case kActorHeaderCurrentSpriteClip: {
uint clipId = chunk.readTypedUint16();
setCurrentClip(clipId);
break;
@@ -122,7 +122,7 @@ void Sprite::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Sprite::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue SpriteMovieActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -212,7 +212,7 @@ ScriptValue Sprite::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue
}
}
-bool Sprite::activateNextFrame() {
+bool SpriteMovieActor::activateNextFrame() {
if (_currentFrameIndex < _activeClip.lastFrameIndex) {
_currentFrameIndex++;
dirtyIfVisible();
@@ -221,7 +221,7 @@ bool Sprite::activateNextFrame() {
return false;
}
-bool Sprite::activatePreviousFrame() {
+bool SpriteMovieActor::activatePreviousFrame() {
if (_currentFrameIndex > _activeClip.firstFrameIndex) {
_currentFrameIndex--;
dirtyIfVisible();
@@ -230,20 +230,20 @@ bool Sprite::activatePreviousFrame() {
return false;
}
-void Sprite::dirtyIfVisible() {
+void SpriteMovieActor::dirtyIfVisible() {
if (_isVisible) {
invalidateLocalBounds();
}
}
-void Sprite::setVisibility(bool visibility) {
+void SpriteMovieActor::setVisibility(bool visibility) {
if (_isVisible != visibility) {
_isVisible = visibility;
invalidateLocalBounds();
}
}
-void Sprite::play() {
+void SpriteMovieActor::play() {
_isPlaying = true;
_startTime = g_system->getMillis();
_lastProcessedTime = 0;
@@ -252,12 +252,12 @@ void Sprite::play() {
scheduleNextFrame();
}
-void Sprite::stop() {
+void SpriteMovieActor::stop() {
_nextFrameTime = 0;
_isPlaying = false;
}
-void Sprite::setCurrentClip(uint clipId) {
+void SpriteMovieActor::setCurrentClip(uint clipId) {
if (_activeClip.id != clipId) {
if (_clips.contains(clipId)) {
_activeClip = _clips.getVal(clipId);
@@ -270,26 +270,26 @@ void Sprite::setCurrentClip(uint clipId) {
setCurrentFrameToInitial();
}
-void Sprite::setCurrentFrameToInitial() {
+void SpriteMovieActor::setCurrentFrameToInitial() {
if (_currentFrameIndex != _activeClip.firstFrameIndex) {
_currentFrameIndex = _activeClip.firstFrameIndex;
dirtyIfVisible();
}
}
-void Sprite::setCurrentFrameToFinal() {
+void SpriteMovieActor::setCurrentFrameToFinal() {
if (_currentFrameIndex != _activeClip.lastFrameIndex) {
_currentFrameIndex = _activeClip.lastFrameIndex;
dirtyIfVisible();
}
}
-void Sprite::process() {
+void SpriteMovieActor::process() {
updateFrameState();
// Sprites don't have time event handlers, separate timers do time handling.
}
-void Sprite::readChunk(Chunk &chunk) {
+void SpriteMovieActor::readChunk(Chunk &chunk) {
// Reads one frame from the sprite.
debugC(5, kDebugLoading, "Sprite::readFrame(): Reading sprite frame (@0x%llx)", static_cast<long long int>(chunk.pos()));
SpriteFrameHeader *header = new SpriteFrameHeader(chunk);
@@ -303,7 +303,7 @@ void Sprite::readChunk(Chunk &chunk) {
});
}
-void Sprite::scheduleNextFrame() {
+void SpriteMovieActor::scheduleNextFrame() {
if (!_isPlaying) {
return;
}
@@ -315,12 +315,12 @@ void Sprite::scheduleNextFrame() {
}
}
-void Sprite::scheduleNextTimerEvent() {
+void SpriteMovieActor::scheduleNextTimerEvent() {
uint frameDuration = 1000 / _frameRate;
_nextFrameTime += frameDuration;
}
-void Sprite::updateFrameState() {
+void SpriteMovieActor::updateFrameState() {
if (!_isPlaying) {
return;
}
@@ -333,7 +333,7 @@ void Sprite::updateFrameState() {
}
}
-void Sprite::timerEvent() {
+void SpriteMovieActor::timerEvent() {
if (!_isPlaying) {
error("Attempt to activate sprite frame when sprite is not playing");
return;
@@ -348,7 +348,7 @@ void Sprite::timerEvent() {
}
}
-void Sprite::postMovieEndEventIfNecessary() {
+void SpriteMovieActor::postMovieEndEventIfNecessary() {
if (_currentFrameIndex != _activeClip.lastFrameIndex) {
return;
}
@@ -362,7 +362,7 @@ void Sprite::postMovieEndEventIfNecessary() {
runEventHandlerIfExists(kSpriteMovieEndEvent, value);
}
-void Sprite::draw(const Common::Array<Common::Rect> &dirtyRegion) {
+void SpriteMovieActor::draw(const Common::Array<Common::Rect> &dirtyRegion) {
SpriteFrame *activeFrame = _frames[_currentFrameIndex];
if (_isVisible) {
Common::Rect frameBbox = activeFrame->boundingBox();
diff --git a/engines/mediastation/actors/sprite.h b/engines/mediastation/actors/sprite.h
index 9172b1b1783..12433b11d7b 100644
--- a/engines/mediastation/actors/sprite.h
+++ b/engines/mediastation/actors/sprite.h
@@ -64,17 +64,17 @@ private:
// Sprites are somewhat like movies, but they strictly show one frame at a time
// and don't have sound. They are intended for background/recurrent animations.
-class Sprite : public SpatialEntity {
+class SpriteMovieActor : public SpatialEntity {
friend class Context;
public:
- Sprite() : SpatialEntity(kAssetTypeSprite) {};
- ~Sprite();
+ SpriteMovieActor() : SpatialEntity(kActorTypeSprite) {};
+ ~SpriteMovieActor();
virtual void process() override;
virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) override;
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual bool isVisible() const override { return _isVisible; }
diff --git a/engines/mediastation/actors/text.cpp b/engines/mediastation/actors/text.cpp
index 79ad2cc2d2a..0f1fda8367c 100644
--- a/engines/mediastation/actors/text.cpp
+++ b/engines/mediastation/actors/text.cpp
@@ -23,41 +23,41 @@
namespace MediaStation {
-void Text::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
+void TextActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
switch (paramType) {
- case kAssetHeaderStartup:
+ case kActorHeaderStartup:
_isVisible = static_cast<bool>(chunk.readTypedByte());
break;
- case kAssetHeaderEditable:
+ case kActorHeaderEditable:
_editable = chunk.readTypedByte();
break;
- case kAssetHeaderLoadType:
+ case kActorHeaderLoadType:
_loadType = chunk.readTypedByte();
break;
- case kAssetHeaderFontId:
- _fontAssetId = chunk.readTypedUint16();
+ case kActorHeaderFontId:
+ _fontActorId = chunk.readTypedUint16();
break;
- case kAssetHeaderTextMaxLength:
+ case kActorHeaderTextMaxLength:
_maxTextLength = chunk.readTypedUint16();
break;
- case kAssetHeaderInitialText:
+ case kActorHeaderInitialText:
_text = chunk.readTypedString();
break;
- case kAssetHeaderTextJustification:
+ case kActorHeaderTextJustification:
_justification = static_cast<TextJustification>(chunk.readTypedUint16());
break;
- case kAssetHeaderTextPosition:
+ case kActorHeaderTextPosition:
_position = static_cast<TextPosition>(chunk.readTypedUint16());
break;
- case kAssetHeaderTextCharacterClass: {
+ case kActorHeaderTextCharacterClass: {
CharacterClass characterClass;
characterClass.firstAsciiCode = chunk.readTypedUint16();
characterClass.lastAsciiCode = chunk.readTypedUint16();
@@ -70,7 +70,7 @@ void Text::readParameter(Chunk &chunk, AssetHeaderSectionType paramType) {
}
}
-ScriptValue Text::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue TextActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -103,11 +103,11 @@ ScriptValue Text::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
}
-Common::String Text::text() const {
+Common::String TextActor::text() const {
return _text;
}
-void Text::setText(Common::String text) {
+void TextActor::setText(Common::String text) {
error("Text::setText(): Setting text not implemented yet");
}
diff --git a/engines/mediastation/actors/text.h b/engines/mediastation/actors/text.h
index 7cca11e498a..595c0582e37 100644
--- a/engines/mediastation/actors/text.h
+++ b/engines/mediastation/actors/text.h
@@ -47,12 +47,12 @@ struct CharacterClass {
uint lastAsciiCode = 0;
};
-class Text : public SpatialEntity {
+class TextActor : public SpatialEntity {
public:
- Text() : SpatialEntity(kAssetTypeText) {};
+ TextActor() : SpatialEntity(kActorTypeText) {};
virtual bool isVisible() const override { return _isVisible; }
- virtual void readParameter(Chunk &chunk, AssetHeaderSectionType paramType) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
private:
@@ -61,7 +61,7 @@ private:
bool _isVisible = false;
Common::String _text;
uint _maxTextLength = 0;
- uint _fontAssetId = 0;
+ uint _fontActorId = 0;
TextJustification _justification;
TextPosition _position;
Common::Array<CharacterClass> _acceptedInput;
diff --git a/engines/mediastation/actors/timer.cpp b/engines/mediastation/actors/timer.cpp
index 22e45a9ceed..44361c39592 100644
--- a/engines/mediastation/actors/timer.cpp
+++ b/engines/mediastation/actors/timer.cpp
@@ -26,7 +26,7 @@
namespace MediaStation {
-ScriptValue Timer::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ScriptValue TimerActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
ScriptValue returnValue;
switch (methodId) {
@@ -49,11 +49,11 @@ ScriptValue Timer::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
default:
- return Asset::callMethod(methodId, args);
+ return Actor::callMethod(methodId, args);
}
}
-void Timer::timePlay() {
+void TimerActor::timePlay() {
_isPlaying = true;
_startTime = g_system->getMillis();
_lastProcessedTime = 0;
@@ -75,7 +75,7 @@ void Timer::timePlay() {
debugC(5, kDebugScript, "Timer::timePlay(): Now playing for %d ms", _duration);
}
-void Timer::timeStop() {
+void TimerActor::timeStop() {
if (!_isPlaying) {
return;
}
@@ -85,7 +85,7 @@ void Timer::timeStop() {
_lastProcessedTime = 0;
}
-void Timer::process() {
+void TimerActor::process() {
if (_isPlaying) {
processTimeEventHandlers();
}
diff --git a/engines/mediastation/actors/timer.h b/engines/mediastation/actors/timer.h
index ad0c6beaabf..49a38c12fab 100644
--- a/engines/mediastation/actors/timer.h
+++ b/engines/mediastation/actors/timer.h
@@ -28,9 +28,9 @@
namespace MediaStation {
-class Timer : public Asset {
+class TimerActor : public Actor {
public:
- Timer() : Asset(kAssetTypeTimer) {};
+ TimerActor() : Actor(kActorTypeTimer) {};
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual void process() override;
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index dd53c9eb654..2a3e82ebddb 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -70,7 +70,7 @@ ContextDeclarationSectionType ContextDeclaration::getSectionType(Chunk &chunk) {
ScreenDeclaration::ScreenDeclaration(Chunk &chunk) {
// Make sure this declaration isn't empty.
ScreenDeclarationSectionType sectionType = getSectionType(chunk);
- if (kScreenDeclarationAssetId != sectionType) {
+ if (kScreenDeclarationActorId != sectionType) {
error("Got unexpected section type %d", static_cast<uint>(sectionType));
}
_actorId = chunk.readTypedUint16();
@@ -118,7 +118,7 @@ FileDeclarationSectionType FileDeclaration::getSectionType(Chunk &chunk) {
SubfileDeclaration::SubfileDeclaration(Chunk &chunk) {
// Read the actor ID.
SubfileDeclarationSectionType sectionType = getSectionType(chunk);
- if (kSubfileDeclarationAssetId != sectionType) {
+ if (kSubfileDeclarationActorId != sectionType) {
error("Got unexpected section type %d", static_cast<uint>(sectionType));
}
_actorId = chunk.readTypedUint16();
diff --git a/engines/mediastation/boot.h b/engines/mediastation/boot.h
index 275940794d1..d7bd1215ce7 100644
--- a/engines/mediastation/boot.h
+++ b/engines/mediastation/boot.h
@@ -56,7 +56,7 @@ private:
enum ScreenDeclarationSectionType {
kScreenDeclarationEmpty = 0x0000,
- kScreenDeclarationAssetId = 0x0009,
+ kScreenDeclarationActorId = 0x0009,
kScreenDeclarationScreenId = 0x0004
};
@@ -106,7 +106,7 @@ private:
enum SubfileDeclarationSectionType {
kSubfileDeclarationEmptySection = 0x0000,
- kSubfileDeclarationAssetId = 0x002a,
+ kSubfileDeclarationActorId = 0x002a,
kSubfileDeclarationFileId = 0x002b,
kSubfileDeclarationStartOffset = 0x002c
};
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index d6150928160..a8eeb89695a 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -62,7 +62,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
chunk = subfile._currentChunk;
while (!subfile.atEnd()) {
- readAssetInFirstSubfile(chunk);
+ readActorInFirstSubfile(chunk);
if (!subfile.atEnd()) {
chunk = subfile.nextChunk();
}
@@ -71,32 +71,32 @@ Context::Context(const Common::Path &path) : Datafile(path) {
// Read actors in the rest of the subfiles.
for (uint i = 1; i < _subfileCount; i++) {
subfile = getNextSubfile();
- readAssetFromLaterSubfile(subfile);
+ readActorFromLaterSubfile(subfile);
}
// Some sprites and images don't have any image data themselves, they just
// reference the same image data in another actor. So we need to check for
// these and create the appropriate references.
for (auto it = _actors.begin(); it != _actors.end(); ++it) {
- Asset *actor = it->_value;
- uint referencedAssetId = actor->_actorReference;
- if (referencedAssetId != 0) {
+ Actor *actor = it->_value;
+ uint referencedActorId = actor->_actorReference;
+ if (referencedActorId != 0) {
switch (actor->type()) {
- case kAssetTypeImage: {
- Image *image = static_cast<Image *>(actor);
- Image *referencedImage = static_cast<Image *>(getAssetById(referencedAssetId));
+ case kActorTypeImage: {
+ ImageActor *image = static_cast<ImageActor *>(actor);
+ ImageActor *referencedImage = static_cast<ImageActor *>(getActorById(referencedActorId));
if (referencedImage == nullptr) {
- error("Context::Context(): Asset %d references non-existent actor %d", actor->id(), referencedAssetId);
+ error("Context::Context(): Actor %d references non-existent actor %d", actor->id(), referencedActorId);
}
image->_bitmap = referencedImage->_bitmap;
break;
}
- case kAssetTypeSprite: {
- Sprite *sprite = static_cast<Sprite *>(actor);
- Sprite *referencedSprite = static_cast<Sprite *>(getAssetById(referencedAssetId));
+ case kActorTypeSprite: {
+ SpriteMovieActor *sprite = static_cast<SpriteMovieActor *>(actor);
+ SpriteMovieActor *referencedSprite = static_cast<SpriteMovieActor *>(getActorById(referencedActorId));
if (referencedSprite == nullptr) {
- error("Context::Context(): Asset %d references non-existent actor %d", actor->id(), referencedAssetId);
+ error("Context::Context(): Actor %d references non-existent actor %d", actor->id(), referencedActorId);
}
sprite->_frames = referencedSprite->_frames;
sprite->_clips = referencedSprite->_clips;
@@ -104,7 +104,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
}
default:
- error("Context::Context(): Asset type %d referenced, but reference not implemented yet", actor->type());
+ error("Context::Context(): Actor type %d referenced, but reference not implemented yet", actor->type());
}
}
}
@@ -132,11 +132,11 @@ Context::~Context() {
_variables.clear();
}
-Asset *Context::getAssetById(uint actorId) {
+Actor *Context::getActorById(uint actorId) {
return _actors.getValOrDefault(actorId);
}
-Asset *Context::getAssetByChunkReference(uint chunkReference) {
+Actor *Context::getActorByChunkReference(uint chunkReference) {
return _actorsByChunkReference.getValOrDefault(chunkReference);
}
@@ -193,61 +193,61 @@ void Context::readCreateContextData(Chunk &chunk) {
}
}
-Asset *Context::readCreateAssetData(Chunk &chunk) {
+Actor *Context::readCreateActorData(Chunk &chunk) {
uint contextId = chunk.readTypedUint16();
- AssetType type = static_cast<AssetType>(chunk.readTypedUint16());
+ ActorType type = static_cast<ActorType>(chunk.readTypedUint16());
uint id = chunk.readTypedUint16();
debugC(4, kDebugLoading, "_type = 0x%x, _id = 0x%x", static_cast<uint>(type), id);
- Asset *actor = nullptr;
+ Actor *actor = nullptr;
switch (type) {
- case kAssetTypeImage:
- actor = new Image();
+ case kActorTypeImage:
+ actor = new ImageActor();
break;
- case kAssetTypeMovie:
- actor = new Movie();
+ case kActorTypeMovie:
+ actor = new StreamMovieActor();
break;
- case kAssetTypeSound:
- actor = new Sound();
+ case kActorTypeSound:
+ actor = new SoundActor();
break;
- case kAssetTypePalette:
- actor = new Palette();
+ case kActorTypePalette:
+ actor = new PaletteActor();
break;
- case kAssetTypePath:
- actor = new Path();
+ case kActorTypePath:
+ actor = new PathActor();
break;
- case kAssetTypeTimer:
- actor = new Timer();
+ case kActorTypeTimer:
+ actor = new TimerActor();
break;
- case kAssetTypeHotspot:
- actor = new Hotspot();
+ case kActorTypeHotspot:
+ actor = new HotspotActor();
break;
- case kAssetTypeSprite:
- actor = new Sprite();
+ case kActorTypeSprite:
+ actor = new SpriteMovieActor();
break;
- case kAssetTypeCanvas:
- actor = new Canvas();
+ case kActorTypeCanvas:
+ actor = new CanvasActor();
break;
- case kAssetTypeScreen:
- actor = new Screen();
- _screenAsset = static_cast<Screen *>(actor);
+ case kActorTypeScreen:
+ actor = new ScreenActor();
+ _screenActor = static_cast<ScreenActor *>(actor);
break;
- case kAssetTypeFont:
- actor = new Font();
+ case kActorTypeFont:
+ actor = new FontActor();
break;
- case kAssetTypeText:
- actor = new Text();
+ case kActorTypeText:
+ actor = new TextActor();
break;
default:
@@ -309,39 +309,39 @@ void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
debugC(5, kDebugLoading, "Context::readNewStyleHeaderSections(): Finished reading sections (@0x%llx)", static_cast<long long int>(chunk.pos()));
}
-void Context::readAssetInFirstSubfile(Chunk &chunk) {
+void Context::readActorInFirstSubfile(Chunk &chunk) {
if (chunk._id == MKTAG('i', 'g', 'o', 'd')) {
- warning("Context::readAssetInFirstSubfile(): Skippping \"igod\" actor link chunk");
+ warning("Context::readActorInFirstSubfile(): Skippping \"igod\" actor link chunk");
chunk.skip(chunk.bytesRemaining());
return;
}
// TODO: Make sure this is not an actor link.
- Asset *actor = getAssetByChunkReference(chunk._id);
+ Actor *actor = getActorByChunkReference(chunk._id);
if (actor == nullptr) {
// We should only need to look in the global scope when there is an
// install cache (INSTALL.CXT).
- actor = g_engine->getAssetByChunkReference(chunk._id);
+ actor = g_engine->getActorByChunkReference(chunk._id);
if (actor == nullptr) {
- error("Context::readAssetInFirstSubfile(): Asset for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ error("Context::readActorInFirstSubfile(): Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
- debugC(5, kDebugLoading, "\nContext::readAssetInFirstSubfile(): Got actor with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(actor->type()), static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "\nContext::readActorInFirstSubfile(): Got actor with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(actor->type()), static_cast<long long int>(chunk.pos()));
actor->readChunk(chunk);
}
-void Context::readAssetFromLaterSubfile(Subfile &subfile) {
+void Context::readActorFromLaterSubfile(Subfile &subfile) {
Chunk chunk = subfile.nextChunk();
- Asset *actor = getAssetByChunkReference(chunk._id);
+ Actor *actor = getActorByChunkReference(chunk._id);
if (actor == nullptr) {
// We should only need to look in the global scope when there is an
// install cache (INSTALL.CXT).
- actor = g_engine->getAssetByChunkReference(chunk._id);
+ actor = g_engine->getActorByChunkReference(chunk._id);
if (actor == nullptr) {
- error("Context::readAssetFromLaterSubfile(): Asset for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ error("Context::readActorFromLaterSubfile(): Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
- debugC(5, kDebugLoading, "\nContext::readAssetFromLaterSubfile(): Got actor with chunk ID %s in later subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), actor->type(), static_cast<long long int>(chunk.pos()));
+ debugC(5, kDebugLoading, "\nContext::readActorFromLaterSubfile(): Got actor with chunk ID %s in later subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), actor->type(), static_cast<long long int>(chunk.pos()));
actor->readSubfile(subfile, chunk);
}
@@ -354,8 +354,8 @@ bool Context::readHeaderSection(Chunk &chunk) {
break;
}
- case kContextAssetLinkSection: {
- warning("Context::readHeaderSection(): ASSET_LINK not implemented yet");
+ case kContextActorLinkSection: {
+ warning("Context::readHeaderSection(): ACTOR_LINK not implemented yet");
chunk.skip(chunk.bytesRemaining());
break;
}
@@ -378,17 +378,17 @@ bool Context::readHeaderSection(Chunk &chunk) {
break;
}
- case kContextAssetHeaderSection: {
- Asset *actor = readCreateAssetData(chunk);
+ case kContextActorHeaderSection: {
+ Actor *actor = readCreateActorData(chunk);
_actors.setVal(actor->id(), actor);
- g_engine->registerAsset(actor);
+ g_engine->registerActor(actor);
if (actor->_chunkReference != 0) {
debugC(5, kDebugLoading, "Context::readHeaderSection(): Storing actor with chunk ID \"%s\" (0x%x)", tag2str(actor->_chunkReference), actor->_chunkReference);
_actorsByChunkReference.setVal(actor->_chunkReference, actor);
}
- if (actor->type() == kAssetTypeMovie) {
- Movie *movie = static_cast<Movie *>(actor);
+ if (actor->type() == kActorTypeMovie) {
+ StreamMovieActor *movie = static_cast<StreamMovieActor *>(actor);
if (movie->_audioChunkReference != 0) {
_actorsByChunkReference.setVal(movie->_audioChunkReference, actor);
}
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index f4a6770c06c..3512725cc6b 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -47,13 +47,13 @@ enum ContextSectionType {
kContextParametersSection = 0x000e,
kContextPaletteSection = 0x05aa,
kContextUnkAtEndSection = 0x0010,
- kContextAssetHeaderSection = 0x0011,
+ kContextActorHeaderSection = 0x0011,
kContextPoohSection = 0x057a,
- kContextAssetLinkSection = 0x0013,
+ kContextActorLinkSection = 0x0013,
kContextFunctionSection = 0x0031
};
-class Screen;
+class ScreenActor;
class Context : public Datafile {
public:
@@ -64,10 +64,10 @@ public:
uint32 _subfileCount;
uint32 _fileSize;
Graphics::Palette *_palette = nullptr;
- Screen *_screenAsset = nullptr;
+ ScreenActor *_screenActor = nullptr;
- Asset *getAssetById(uint actorId);
- Asset *getAssetByChunkReference(uint chunkReference);
+ Actor *getActorById(uint actorId);
+ Actor *getActorByChunkReference(uint chunkReference);
Function *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
@@ -78,9 +78,9 @@ private:
uint _fileNumber = 0;
Common::String _contextName;
- Common::HashMap<uint, Asset *> _actors;
+ Common::HashMap<uint, Actor *> _actors;
Common::HashMap<uint, Function *> _functions;
- Common::HashMap<uint, Asset *> _actorsByChunkReference;
+ Common::HashMap<uint, Actor *> _actorsByChunkReference;
Common::HashMap<uint, ScriptValue *> _variables;
void readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk);
@@ -88,11 +88,11 @@ private:
bool readHeaderSection(Chunk &chunk);
void readCreateContextData(Chunk &chunk);
- Asset *readCreateAssetData(Chunk &chunk);
+ Actor *readCreateActorData(Chunk &chunk);
void readCreateVariableData(Chunk &chunk);
- void readAssetInFirstSubfile(Chunk &chunk);
- void readAssetFromLaterSubfile(Subfile &subfile);
+ void readActorInFirstSubfile(Chunk &chunk);
+ void readActorFromLaterSubfile(Subfile &subfile);
};
} // End of namespace MediaStation
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index 00f16dc6351..a4d67f056b4 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -224,7 +224,7 @@ void VideoDisplayManager::fadeToPaletteObject(Common::Array<ScriptValue> &args)
uint colorCount = DEFAULT_PALETTE_TRANSITION_COLOR_COUNT;
if (args.size() >= 2) {
- paletteId = args[1].asAssetId();
+ paletteId = args[1].asActorId();
} else {
warning("fadeToPaletteObject: Too few script args");
return;
@@ -246,7 +246,7 @@ void VideoDisplayManager::setToPaletteObject(Common::Array<ScriptValue> &args) {
uint colorCount = DEFAULT_PALETTE_TRANSITION_COLOR_COUNT;
if (args.size() >= 2) {
- paletteId = args[1].asAssetId();
+ paletteId = args[1].asActorId();
} else {
warning("fadeToPaletteObject: Too few script args");
return;
@@ -267,7 +267,7 @@ void VideoDisplayManager::setToPercentOfPaletteObject(Common::Array<ScriptValue>
if (args.size() >= 3) {
percent = args[1].asFloat();
- paletteId = args[2].asAssetId();
+ paletteId = args[2].asActorId();
} else {
error("fadeToPaletteObject: Too few script args");
return;
@@ -448,38 +448,38 @@ void VideoDisplayManager::_colorShiftCurrentPalette(uint startIndex, uint shiftA
}
void VideoDisplayManager::_fadeToPaletteObject(uint paletteId, double fadeTime, uint startIndex, uint colorCount) {
- Asset *actor = _vm->getAssetById(paletteId);
+ Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
error("Got null target palette");
- } else if (actor->type() != kAssetTypePalette) {
- error("Asset %d is not a palette", paletteId);
+ } else if (actor->type() != kActorTypePalette) {
+ error("Actor %d is not a palette", paletteId);
}
- Graphics::Palette *palette = static_cast<Palette *>(actor)->_palette;
+ Graphics::Palette *palette = static_cast<PaletteActor *>(actor)->_palette;
_fadeToPalette(fadeTime, *palette, startIndex, colorCount);
}
void VideoDisplayManager::_setToPaletteObject(uint paletteId, uint startIndex, uint colorCount) {
- Asset *actor = _vm->getAssetById(paletteId);
+ Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
error("Got null target palette");
- } else if (actor->type() != kAssetTypePalette) {
- error("Asset %d is not a palette", paletteId);
+ } else if (actor->type() != kActorTypePalette) {
+ error("Actor %d is not a palette", paletteId);
}
- Graphics::Palette *palette = static_cast<Palette *>(actor)->_palette;
+ Graphics::Palette *palette = static_cast<PaletteActor *>(actor)->_palette;
_setPalette(*palette, startIndex, colorCount);
}
void VideoDisplayManager::_setPercentToPaletteObject(double percent, uint paletteId, uint startIndex, uint colorCount) {
- Asset *actor = _vm->getAssetById(paletteId);
+ Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
error("Got null target palette");
- } else if (actor->type() != kAssetTypePalette) {
- error("Asset %d is not a palette", paletteId);
+ } else if (actor->type() != kActorTypePalette) {
+ error("Actor %d is not a palette", paletteId);
}
- Graphics::Palette *targetPalette = static_cast<Palette *>(actor)->_palette;
+ Graphics::Palette *targetPalette = static_cast<PaletteActor *>(actor)->_palette;
_setToPercentPalette(percent, *_registeredPalette, *targetPalette, startIndex, colorCount);
}
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 5fd4f77b1f6..06c24227c27 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -232,10 +232,10 @@ ScriptValue CodeChunk::evaluateValue() {
return returnValue;
}
- case kOperandTypeAssetId: {
+ case kOperandTypeActorId: {
uint actorId = _bytecode->readTypedUint16();
debugC(5, kDebugScript, "%d ", actorId);
- returnValue.setToAssetId(actorId);
+ returnValue.setToActorId(actorId);
return returnValue;
}
@@ -512,20 +512,20 @@ ScriptValue CodeChunk::evaluateMethodCall(BuiltInMethod method, uint paramCount)
ScriptValue returnValue;
switch (target.getType()) {
- case kScriptValueTypeAssetId: {
- if (target.asAssetId() == 0) {
+ case kScriptValueTypeActorId: {
+ if (target.asActorId() == 0) {
// It seems to be valid to call a method on a null actor ID, in
// which case nothing happens. Still issue warning for traceability.
warning("Attempt to call method on a null actor ID");
return returnValue;
} else {
// This is a regular actor that we can process directly.
- uint actorId = target.asAssetId();
- Asset *targetAsset = g_engine->getAssetById(actorId);
- if (targetAsset == nullptr) {
- error("Attempt to call method on actor ID %d, which isn't loaded", target.asAssetId());
+ uint actorId = target.asActorId();
+ Actor *targetActor = g_engine->getActorById(actorId);
+ if (targetActor == nullptr) {
+ error("Attempt to call method on actor ID %d, which isn't loaded", target.asActorId());
}
- returnValue = targetAsset->callMethod(method, args);
+ returnValue = targetActor->callMethod(method, args);
return returnValue;
}
}
diff --git a/engines/mediastation/mediascript/collection.cpp b/engines/mediastation/mediascript/collection.cpp
index 560199e41f3..a33772d2a2a 100644
--- a/engines/mediastation/mediascript/collection.cpp
+++ b/engines/mediastation/mediascript/collection.cpp
@@ -146,10 +146,10 @@ void Collection::send(const Common::Array<ScriptValue> &args) {
BuiltInMethod methodToSend = static_cast<BuiltInMethod>(args[0].asMethodId());
Common::Array<ScriptValue> sendArgs;
for (const ScriptValue &item : *this) {
- uint actorId = item.asAssetId();
- Asset *targetAsset = g_engine->getAssetById(actorId);
- if (targetAsset != nullptr) {
- targetAsset->callMethod(methodToSend, argsToSend);
+ uint actorId = item.asActorId();
+ Actor *targetActor = g_engine->getActorById(actorId);
+ if (targetActor != nullptr) {
+ targetActor->callMethod(methodToSend, argsToSend);
}
}
}
diff --git a/engines/mediastation/mediascript/eventhandler.cpp b/engines/mediastation/mediascript/eventhandler.cpp
index f4f8b577826..3a5a01f9c1e 100644
--- a/engines/mediastation/mediascript/eventhandler.cpp
+++ b/engines/mediastation/mediascript/eventhandler.cpp
@@ -61,8 +61,8 @@ Common::String EventHandler::getDebugHeader() {
case kScriptValueTypeFloat:
return Common::String::format("(float = %f)", _argumentValue.asFloat());
- case kScriptValueTypeAssetId:
- return Common::String::format("(context = %d)", _argumentValue.asAssetId());
+ case kScriptValueTypeActorId:
+ return Common::String::format("(context = %d)", _argumentValue.asActorId());
case kScriptValueTypeTime:
return Common::String::format("(time = %f)", _argumentValue.asTime());
diff --git a/engines/mediastation/mediascript/scriptconstants.cpp b/engines/mediastation/mediascript/scriptconstants.cpp
index d8946caf7f1..170952caca2 100644
--- a/engines/mediastation/mediascript/scriptconstants.cpp
+++ b/engines/mediastation/mediascript/scriptconstants.cpp
@@ -329,8 +329,8 @@ const char *operandTypeToStr(OperandType type) {
return "String";
case kOperandTypeParamToken:
return "DollarSignVariable";
- case kOperandTypeAssetId:
- return "AssetId";
+ case kOperandTypeActorId:
+ return "ActorId";
case kOperandTypeTime:
return "Time";
case kOperandTypeVariable:
@@ -358,8 +358,8 @@ const char *scriptValueTypeToStr(ScriptValueType type) {
return "Time";
case kScriptValueTypeParamToken:
return "Int";
- case kScriptValueTypeAssetId:
- return "AssetId";
+ case kScriptValueTypeActorId:
+ return "ActorId";
case kScriptValueTypeString:
return "String";
case kScriptValueTypeCollection:
diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index b12308e5d3c..3f1bc154fe3 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -239,7 +239,7 @@ enum OperandType {
kOperandTypeInt = 153,
kOperandTypeString = 154,
kOperandTypeParamToken = 155,
- kOperandTypeAssetId = 156,
+ kOperandTypeActorId = 156,
kOperandTypeTime = 157,
kOperandTypeVariable = 158,
kOperandTypeFunctionId = 159,
@@ -254,7 +254,7 @@ enum ScriptValueType {
kScriptValueTypeBool = 2,
kScriptValueTypeTime = 3,
kScriptValueTypeParamToken = 4,
- kScriptValueTypeAssetId = 5,
+ kScriptValueTypeActorId = 5,
kScriptValueTypeString = 6,
kScriptValueTypeCollection = 7,
kScriptValueTypeFunctionId = 8,
diff --git a/engines/mediastation/mediascript/scriptvalue.cpp b/engines/mediastation/mediascript/scriptvalue.cpp
index 43258236dfa..4f9008cc5c5 100644
--- a/engines/mediastation/mediascript/scriptvalue.cpp
+++ b/engines/mediastation/mediascript/scriptvalue.cpp
@@ -58,9 +58,9 @@ ScriptValue::ScriptValue(ParameterReadStream *stream) {
break;
}
- case kScriptValueTypeAssetId: {
+ case kScriptValueTypeActorId: {
uint actorId = stream->readTypedUint16();
- setToAssetId(actorId);
+ setToActorId(actorId);
break;
}
@@ -163,16 +163,16 @@ uint ScriptValue::asParamToken() const {
}
}
-void ScriptValue::setToAssetId(uint actorId) {
- _type = kScriptValueTypeAssetId;
+void ScriptValue::setToActorId(uint actorId) {
+ _type = kScriptValueTypeActorId;
_u.actorId = actorId;
}
-uint ScriptValue::asAssetId() const {
- if (_type == kScriptValueTypeAssetId) {
+uint ScriptValue::asActorId() const {
+ if (_type == kScriptValueTypeActorId) {
return _u.actorId;
} else {
- issueValueMismatchWarning(kScriptValueTypeAssetId);
+ issueValueMismatchWarning(kScriptValueTypeActorId);
return 0;
}
}
@@ -257,8 +257,8 @@ bool ScriptValue::compare(Opcode op, const ScriptValue &lhs, const ScriptValue &
return compare(op, lhs.asParamToken(), rhs.asParamToken());
break;
- case kScriptValueTypeAssetId:
- return compare(op, lhs.asAssetId(), rhs.asAssetId());
+ case kScriptValueTypeActorId:
+ return compare(op, lhs.asActorId(), rhs.asActorId());
break;
case kScriptValueTypeString:
diff --git a/engines/mediastation/mediascript/scriptvalue.h b/engines/mediastation/mediascript/scriptvalue.h
index fd45f77b570..2c72067dd38 100644
--- a/engines/mediastation/mediascript/scriptvalue.h
+++ b/engines/mediastation/mediascript/scriptvalue.h
@@ -31,7 +31,7 @@
namespace MediaStation {
-class Asset;
+class Actor;
class ScriptValue {
public:
@@ -55,8 +55,8 @@ public:
void setToParamToken(uint paramToken);
uint asParamToken() const;
- void setToAssetId(uint actorId);
- uint asAssetId() const;
+ void setToActorId(uint actorId);
+ uint asActorId() const;
void setToString(const Common::String &string);
Common::String asString() const;
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index c9cf8795c49..888204fede7 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -41,7 +41,7 @@ MediaStationEngine *g_engine;
MediaStationEngine::MediaStationEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
_gameDescription(gameDesc),
_randomSource("MediaStation"),
- _spatialEntities(MediaStationEngine::compareAssetByZIndex) {
+ _spatialEntities(MediaStationEngine::compareActorByZIndex) {
g_engine = this;
_gameDataDir = Common::FSNode(ConfMan.getPath("path"));
@@ -71,7 +71,7 @@ MediaStationEngine::~MediaStationEngine() {
delete _actors[0];
}
-Asset *MediaStationEngine::getAssetById(uint actorId) {
+Actor *MediaStationEngine::getActorById(uint actorId) {
for (auto actor : _actors) {
if (actor->id() == actorId) {
return actor;
@@ -80,9 +80,9 @@ Asset *MediaStationEngine::getAssetById(uint actorId) {
return nullptr;
}
-Asset *MediaStationEngine::getAssetByChunkReference(uint chunkReference) {
+Actor *MediaStationEngine::getActorByChunkReference(uint chunkReference) {
for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
- Asset *actor = it->_value->getAssetByChunkReference(chunkReference);
+ Actor *actor = it->_value->getActorByChunkReference(chunkReference);
if (actor != nullptr) {
return actor;
}
@@ -149,7 +149,7 @@ Common::Error MediaStationEngine::run() {
}
_cursor->showCursor();
- Document *document = new Document;
+ DocumentActor *document = new DocumentActor;
_actors.push_back(document);
if (ConfMan.hasKey("entry_context")) {
@@ -182,7 +182,7 @@ Common::Error MediaStationEngine::run() {
}
debugC(5, kDebugGraphics, "***** START SCREEN UPDATE ***");
- for (Asset *actor : _actors) {
+ for (Actor *actor : _actors) {
actor->process();
if (_needsHotspotRefresh) {
@@ -219,7 +219,7 @@ void MediaStationEngine::processEvents() {
case Common::EVENT_KEYDOWN: {
// Even though this is a keydown event, we need to look at the mouse position.
- Asset *hotspot = findAssetToAcceptMouseEvents();
+ Actor *hotspot = findActorToAcceptMouseEvents();
if (hotspot != nullptr) {
debugC(1, kDebugEvents, "EVENT_KEYDOWN (%d): Sent to hotspot %d", _event.kbd.ascii, hotspot->id());
ScriptValue keyCode;
@@ -230,7 +230,7 @@ void MediaStationEngine::processEvents() {
}
case Common::EVENT_LBUTTONDOWN: {
- Asset *hotspot = findAssetToAcceptMouseEvents();
+ Actor *hotspot = findActorToAcceptMouseEvents();
if (hotspot != nullptr) {
debugC(1, kDebugEvents, "EVENT_LBUTTONDOWN (%d, %d): Sent to hotspot %d", _mousePos.x, _mousePos.y, hotspot->id());
hotspot->runEventHandlerIfExists(kMouseDownEvent);
@@ -263,11 +263,11 @@ void MediaStationEngine::setCursor(uint id) {
}
void MediaStationEngine::refreshActiveHotspot() {
- Asset *actor = findAssetToAcceptMouseEvents();
- if (actor != nullptr && actor->type() != kAssetTypeHotspot) {
+ Actor *actor = findActorToAcceptMouseEvents();
+ if (actor != nullptr && actor->type() != kActorTypeHotspot) {
return;
}
- Hotspot *hotspot = static_cast<Hotspot *>(actor);
+ HotspotActor *hotspot = static_cast<HotspotActor *>(actor);
if (hotspot != _currentHotspot) {
if (_currentHotspot != nullptr) {
_currentHotspot->runEventHandlerIfExists(kMouseExitedEvent);
@@ -280,7 +280,7 @@ void MediaStationEngine::refreshActiveHotspot() {
hotspot->runEventHandlerIfExists(kMouseEnteredEvent);
} else {
// There is no hotspot, so set the default cursor for this screen instead.
- setCursor(_currentContext->_screenAsset->_cursorResourceId);
+ setCursor(_currentContext->_screenActor->_cursorResourceId);
}
}
@@ -292,7 +292,7 @@ void MediaStationEngine::refreshActiveHotspot() {
void MediaStationEngine::draw() {
if (!_dirtyRects.empty()) {
- for (Asset *actor : _spatialEntities) {
+ for (Actor *actor : _spatialEntities) {
if (actor->isSpatialActor()) {
SpatialEntity *entity = static_cast<SpatialEntity *>(actor);
if (entity->isVisible()) {
@@ -349,9 +349,9 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
return context;
}
-void MediaStationEngine::registerAsset(Asset *actorToAdd) {
- if (getAssetById(actorToAdd->id())) {
- error("Asset with ID 0x%d was already defined in this title", actorToAdd->id());
+void MediaStationEngine::registerActor(Actor *actorToAdd) {
+ if (getActorById(actorToAdd->id())) {
+ error("Actor with ID 0x%d was already defined in this title", actorToAdd->id());
}
_actors.push_back(actorToAdd);
@@ -370,16 +370,16 @@ void MediaStationEngine::scheduleContextRelease(uint contextId) {
void MediaStationEngine::doBranchToScreen() {
if (_currentContext != nullptr) {
- _currentContext->_screenAsset->runEventHandlerIfExists(kExitEvent);
- releaseContext(_currentContext->_screenAsset->id());
+ _currentContext->_screenActor->runEventHandlerIfExists(kExitEvent);
+ releaseContext(_currentContext->_screenActor->id());
}
_currentContext = loadContext(_requestedScreenBranchId);
_currentHotspot = nullptr;
_displayManager->setRegisteredPalette(_currentContext->_palette);
- if (_currentContext->_screenAsset != nullptr) {
- _currentContext->_screenAsset->runEventHandlerIfExists(kEntryEvent);
+ if (_currentContext->_screenActor != nullptr) {
+ _currentContext->_screenActor->runEventHandlerIfExists(kEntryEvent);
}
_requestedScreenBranchId = 0;
@@ -425,25 +425,25 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
_loadedContexts.erase(contextId);
}
-Asset *MediaStationEngine::findAssetToAcceptMouseEvents() {
- Asset *intersectingAsset = nullptr;
+Actor *MediaStationEngine::findActorToAcceptMouseEvents() {
+ Actor *intersectingActor = nullptr;
// The z-indices seem to be reversed, so the highest z-index number is
// actually the lowest actor.
int lowestZIndex = INT_MAX;
- for (Asset *actor : _actors) {
- if (actor->type() == kAssetTypeHotspot) {
- Hotspot *hotspot = static_cast<Hotspot *>(actor);
- debugC(5, kDebugGraphics, "findAssetToAcceptMouseEvents(): Hotspot %d (z-index %d)", hotspot->id(), hotspot->zIndex());
+ for (Actor *actor : _actors) {
+ if (actor->type() == kActorTypeHotspot) {
+ HotspotActor *hotspot = static_cast<HotspotActor *>(actor);
+ debugC(5, kDebugGraphics, "findActorToAcceptMouseEvents(): Hotspot %d (z-index %d)", hotspot->id(), hotspot->zIndex());
if (hotspot->isActive() && hotspot->isInside(_mousePos)) {
if (hotspot->zIndex() < lowestZIndex) {
lowestZIndex = hotspot->zIndex();
- intersectingAsset = actor;
+ intersectingActor = actor;
}
}
}
}
- return intersectingAsset;
+ return intersectingActor;
}
ScriptValue MediaStationEngine::callBuiltInFunction(BuiltInFunction function, Common::Array<ScriptValue> &args) {
@@ -476,7 +476,7 @@ ScriptValue MediaStationEngine::callBuiltInFunction(BuiltInFunction function, Co
}
}
-int MediaStationEngine::compareAssetByZIndex(const SpatialEntity *a, const SpatialEntity *b) {
+int MediaStationEngine::compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b) {
int diff = b->zIndex() - a->zIndex();
if (diff < 0)
return -1; // a should come before b
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index e129e1fbe42..e4703e3e63f 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -46,7 +46,7 @@
namespace MediaStation {
struct MediaStationGameDescription;
-class Hotspot;
+class HotspotActor;
class Bitmap;
// Most Media Station titles follow this file structure from the root directory
@@ -82,12 +82,12 @@ public:
void addDirtyRect(const Common::Rect &rect) { _dirtyRects.push_back(rect); }
void draw();
- void registerAsset(Asset *actorToAdd);
+ void registerActor(Actor *actorToAdd);
void scheduleScreenBranch(uint screenId);
void scheduleContextRelease(uint contextId);
- Asset *getAssetById(uint actorId);
- Asset *getAssetByChunkReference(uint chunkReference);
+ Actor *getActorById(uint actorId);
+ Actor *getActorByChunkReference(uint chunkReference);
Function *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
VideoDisplayManager *getDisplayManager() { return _displayManager; }
@@ -117,19 +117,19 @@ private:
VideoDisplayManager *_displayManager = nullptr;
Boot *_boot = nullptr;
- Common::Array<Asset *> _actors;
+ Common::Array<Actor *> _actors;
Common::SortedArray<SpatialEntity *, const SpatialEntity *> _spatialEntities;
Common::HashMap<uint, Context *> _loadedContexts;
- Asset *_currentHotspot = nullptr;
+ Actor *_currentHotspot = nullptr;
uint _requestedScreenBranchId = 0;
Common::Array<uint> _requestedContextReleaseId;
void doBranchToScreen();
Context *loadContext(uint32 contextId);
void releaseContext(uint32 contextId);
- Asset *findAssetToAcceptMouseEvents();
+ Actor *findActorToAcceptMouseEvents();
- static int compareAssetByZIndex(const SpatialEntity *a, const SpatialEntity *b);
+ static int compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b);
};
extern MediaStationEngine *g_engine;
Commit: 3a22eb510d68771aac5751f5584b3941d791e5c4
https://github.com/scummvm/scummvm/commit/3a22eb510d68771aac5751f5584b3941d791e5c4
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Migrate warnings/errors to use __func__
Changed paths:
engines/mediastation/actor.cpp
engines/mediastation/actors/canvas.cpp
engines/mediastation/actors/document.cpp
engines/mediastation/actors/font.cpp
engines/mediastation/actors/movie.cpp
engines/mediastation/actors/path.cpp
engines/mediastation/actors/sound.cpp
engines/mediastation/actors/sprite.cpp
engines/mediastation/actors/text.cpp
engines/mediastation/audio.cpp
engines/mediastation/bitmap.cpp
engines/mediastation/boot.cpp
engines/mediastation/context.cpp
engines/mediastation/cursors.cpp
engines/mediastation/datafile.cpp
engines/mediastation/graphics.cpp
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/collection.cpp
engines/mediastation/mediascript/scriptvalue.cpp
engines/mediastation/mediastation.cpp
diff --git a/engines/mediastation/actor.cpp b/engines/mediastation/actor.cpp
index b30d5f9b10a..4ac4efe67bf 100644
--- a/engines/mediastation/actor.cpp
+++ b/engines/mediastation/actor.cpp
@@ -60,7 +60,7 @@ void Actor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
// This is not a hashmap because we don't want to have to hash ScriptValues.
for (EventHandler *existingEventHandler : eventHandlersForType) {
if (existingEventHandler->_argumentValue == eventHandler->_argumentValue) {
- error("ActorHeader::readSection(): Event handler for %s (%s) already exists",
+ error("%s: Event handler for %s (%s) already exists", __func__,
eventTypeToStr(eventHandler->_type), eventHandler->getDebugHeader().c_str());
}
}
@@ -78,11 +78,11 @@ ScriptValue Actor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue>
}
void Actor::readChunk(Chunk &chunk) {
- error("Actor::readChunk(): Chunk reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
+ error("%s: Chunk reading for actor type 0x%x is not implemented", __func__, static_cast<uint>(_type));
}
void Actor::readSubfile(Subfile &subfile, Chunk &chunk) {
- error("Actor::readSubfile(): Subfile reading for actor type 0x%x is not implemented", static_cast<uint>(_type));
+ error("%s: Subfile reading for actor type 0x%x is not implemented", __func__, static_cast<uint>(_type));
}
void Actor::processTimeEventHandlers() {
@@ -310,7 +310,7 @@ void SpatialEntity::invalidateLocalBounds() {
}
void SpatialEntity::invalidateLocalZIndex() {
- warning("STUB: Actor::invalidateLocalZIndex()");
+ warning("STUB: %s", __func__);
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/actors/canvas.cpp b/engines/mediastation/actors/canvas.cpp
index 7f8b8cd1256..57550ca4dd1 100644
--- a/engines/mediastation/actors/canvas.cpp
+++ b/engines/mediastation/actors/canvas.cpp
@@ -37,7 +37,7 @@ void CanvasActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType)
ScriptValue CanvasActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
switch (methodId) {
case kClearToPaletteMethod: {
- error("CanvasActor::callMethod(): BuiltInFunction::clearToPalette is not implemented yet");
+ error("%s: clearToPalette is not implemented yet", __func__);
}
default:
diff --git a/engines/mediastation/actors/document.cpp b/engines/mediastation/actors/document.cpp
index 6bd1b6a5ec2..8429b456fcf 100644
--- a/engines/mediastation/actors/document.cpp
+++ b/engines/mediastation/actors/document.cpp
@@ -50,7 +50,7 @@ void DocumentActor::processBranch(Common::Array<ScriptValue> &args) {
if (args.size() > 1) {
bool disableUpdates = static_cast<bool>(args[1].asParamToken());
if (disableUpdates)
- warning("processBranch: disableUpdates parameter not handled yet");
+ warning("%s: disableUpdates parameter not handled yet", __func__);
}
g_engine->scheduleScreenBranch(contextId);
diff --git a/engines/mediastation/actors/font.cpp b/engines/mediastation/actors/font.cpp
index c7efde6e519..e405337ff1e 100644
--- a/engines/mediastation/actors/font.cpp
+++ b/engines/mediastation/actors/font.cpp
@@ -56,7 +56,7 @@ void FontActor::readChunk(Chunk &chunk) {
BitmapHeader *header = new BitmapHeader(chunk);
FontGlyph *glyph = new FontGlyph(chunk, asciiCode, unk1, unk2, header);
if (_glyphs.getValOrDefault(asciiCode) != nullptr) {
- error("FontActor::readChunk(): Glyph for ASCII code 0x%x already exists", asciiCode);
+ error("%s: Glyph for ASCII code 0x%x already exists", __func__, asciiCode);
}
_glyphs.setVal(asciiCode, glyph);
}
diff --git a/engines/mediastation/actors/movie.cpp b/engines/mediastation/actors/movie.cpp
index 33c258f925d..d291b0c8c0c 100644
--- a/engines/mediastation/actors/movie.cpp
+++ b/engines/mediastation/actors/movie.cpp
@@ -94,7 +94,7 @@ void StreamMovieActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramT
// as the ID we have already read.
uint32 duplicateActorId = chunk.readTypedUint16();
if (duplicateActorId != _id) {
- warning("Duplicate actor ID %d does not match original ID %d", duplicateActorId, _id);
+ warning("%s: Duplicate actor ID %d does not match original ID %d", __func__, duplicateActorId, _id);
}
break;
}
@@ -110,7 +110,7 @@ void StreamMovieActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramT
case kActorHeaderHasOwnSubfile: {
bool hasOwnSubfile = static_cast<bool>(chunk.readTypedByte());
if (!hasOwnSubfile) {
- error("StreamMovieActor doesn't have a subfile");
+ error("%s: StreamMovieActor doesn't have a subfile", __func__);
}
break;
}
@@ -328,7 +328,7 @@ void StreamMovieActor::draw(const Common::Array<Common::Rect> &dirtyRegion) {
break;
default:
- error("Got unknown movie frame blit type: %d", frame->blitType);
+ error("%s: Got unknown movie frame blit type: %d", __func__, frame->blitType);
}
}
}
@@ -352,7 +352,7 @@ void StreamMovieActor::readChunk(Chunk &chunk) {
break;
default:
- error("Unknown movie still section type");
+ error("%s: Unknown movie still section type", __func__);
}
_hasStill = true;
}
@@ -361,7 +361,7 @@ void StreamMovieActor::readSubfile(Subfile &subfile, Chunk &chunk) {
uint expectedRootSectionType = chunk.readTypedUint16();
debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(expectedRootSectionType), static_cast<long long int>(chunk.pos()));
if (kMovieRootSection != (MovieSectionType)expectedRootSectionType) {
- error("Expected ROOT section type, got 0x%x", expectedRootSectionType);
+ error("%s: Expected ROOT section type, got 0x%x", __func__, expectedRootSectionType);
}
uint chunkCount = chunk.readTypedUint16();
double unk1 = chunk.readTypedDouble();
@@ -383,7 +383,7 @@ void StreamMovieActor::readSubfile(Subfile &subfile, Chunk &chunk) {
debugC(5, kDebugLoading, "StreamMovieActor::readSubfile(): (Frameset %d of %d) Reading animation chunks... (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
bool isAnimationChunk = (chunk._id == _animationChunkReference);
if (!isAnimationChunk) {
- warning("StreamMovieActor::readSubfile(): (Frameset %d of %d) No animation chunks found (@0x%llx)", i, chunkCount, static_cast<long long int>(chunk.pos()));
+ warning("%s: (Frameset %d of %d) No animation chunks found (@0x%llx)", __func__, i, chunkCount, static_cast<long long int>(chunk.pos()));
}
while (isAnimationChunk) {
uint sectionType = chunk.readTypedUint16();
@@ -398,7 +398,7 @@ void StreamMovieActor::readSubfile(Subfile &subfile, Chunk &chunk) {
break;
default:
- error("StreamMovieActor::readSubfile(): Unknown movie animation section type 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+ error("%s: Unknown movie animation section type 0x%x (@0x%llx)", __func__, static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
}
chunk = subfile.nextChunk();
@@ -419,11 +419,11 @@ void StreamMovieActor::readSubfile(Subfile &subfile, Chunk &chunk) {
bool isHeaderChunk = (chunk._id == _chunkReference);
if (isHeaderChunk) {
if (chunk._length != 0x04) {
- error("StreamMovieActor::readSubfile(): Expected movie header chunk of size 0x04, got 0x%x (@0x%llx)", chunk._length, static_cast<long long int>(chunk.pos()));
+ error("%s: Expected movie header chunk of size 0x04, got 0x%x (@0x%llx)", __func__, chunk._length, static_cast<long long int>(chunk.pos()));
}
chunk.skip(chunk._length);
} else {
- error("StreamMovieActor::readSubfile(): Expected header chunk, got %s (@0x%llx)", tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
+ error("%s: Expected header chunk, got %s (@0x%llx)", __func__, tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
}
}
diff --git a/engines/mediastation/actors/path.cpp b/engines/mediastation/actors/path.cpp
index eabe7abb474..ec54edf1336 100644
--- a/engines/mediastation/actors/path.cpp
+++ b/engines/mediastation/actors/path.cpp
@@ -98,9 +98,9 @@ void PathActor::timePlay() {
}
if (_duration == 0) {
- warning("Path::timePlay(): Got zero duration");
+ warning("%s: Got zero duration", __func__);
} else if (_stepRate == 0) {
- error("Path::timePlay(): Got zero step rate");
+ error("%s: Got zero step rate", __func__);
}
_isPlaying = true;
diff --git a/engines/mediastation/actors/sound.cpp b/engines/mediastation/actors/sound.cpp
index 17f4ebeeb22..e705a2e6b9e 100644
--- a/engines/mediastation/actors/sound.cpp
+++ b/engines/mediastation/actors/sound.cpp
@@ -110,7 +110,7 @@ void SoundActor::readSubfile(Subfile &subfile, Chunk &chunk) {
debugC(5, kDebugLoading, "Sound::readSubfile(): Reading chunk %d of %d", i, _chunkCount);
chunk = subfile.nextChunk();
if (chunk._id != expectedChunkId) {
- error("Sound::readSubfile(): Expected chunk %s, got %s", tag2str(expectedChunkId), tag2str(chunk._id));
+ error("%s: Expected chunk %s, got %s", __func__, tag2str(expectedChunkId), tag2str(chunk._id));
}
readChunk(chunk);
}
@@ -122,7 +122,7 @@ void SoundActor::timePlay() {
}
if (_sequence.isEmpty()) {
- warning("Sound::timePlay(): Sound has no contents, probably because the sound is in INSTALL.CXT and isn't loaded yet");
+ warning("%s: Sound has no contents, probably because the sound is in INSTALL.CXT and isn't loaded yet", __func__);
_isPlaying = false;
return;
}
diff --git a/engines/mediastation/actors/sprite.cpp b/engines/mediastation/actors/sprite.cpp
index 7e975e8c40e..5c20b7e0607 100644
--- a/engines/mediastation/actors/sprite.cpp
+++ b/engines/mediastation/actors/sprite.cpp
@@ -263,7 +263,7 @@ void SpriteMovieActor::setCurrentClip(uint clipId) {
_activeClip = _clips.getVal(clipId);
} else {
_activeClip.id = clipId;
- warning("Sprite clip %d not found in sprite %d", clipId, _id);
+ warning("%s: Sprite clip %d not found in sprite %d", __func__, clipId, _id);
}
}
@@ -335,7 +335,7 @@ void SpriteMovieActor::updateFrameState() {
void SpriteMovieActor::timerEvent() {
if (!_isPlaying) {
- error("Attempt to activate sprite frame when sprite is not playing");
+ error("%s: Attempt to activate sprite frame when sprite is not playing", __func__);
return;
}
diff --git a/engines/mediastation/actors/text.cpp b/engines/mediastation/actors/text.cpp
index 0f1fda8367c..2dedfa8b7da 100644
--- a/engines/mediastation/actors/text.cpp
+++ b/engines/mediastation/actors/text.cpp
@@ -76,25 +76,25 @@ ScriptValue TextActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptVa
switch (methodId) {
case kTextMethod: {
assert(args.empty());
- error("Text::callMethod(): Text() method not implemented yet");
+ error("%s: Text() method not implemented yet", __func__);
}
case kSetTextMethod: {
assert(args.size() == 1);
- error("Text::callMethod(): getText() method not implemented yet");
+ error("%s: getText() method not implemented yet", __func__);
}
case kSpatialShowMethod: {
assert(args.empty());
_isVisible = true;
- warning("Text::callMethod(): spatialShow method not implemented yet");
+ warning("%s: spatialShow method not implemented yet", __func__);
return returnValue;
}
case kSpatialHideMethod: {
assert(args.empty());
_isVisible = false;
- warning("Text::callMethod(): spatialHide method not implemented yet");
+ warning("%s: spatialHide method not implemented yet", __func__);
return returnValue;
}
@@ -108,7 +108,7 @@ Common::String TextActor::text() const {
}
void TextActor::setText(Common::String text) {
- error("Text::setText(): Setting text not implemented yet");
+ error("%s: Setting text not implemented yet", __func__);
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/audio.cpp b/engines/mediastation/audio.cpp
index 78322f42e49..f80c9d543fa 100644
--- a/engines/mediastation/audio.cpp
+++ b/engines/mediastation/audio.cpp
@@ -73,12 +73,12 @@ void AudioSequence::readChunk(Chunk &chunk) {
case 4: // IMA ADPCM-encoded
// TODO: The interface here is different. We can't pass in the
// buffers directly. We have to make a stream first.
- warning("ADPCM decoding not implemented yet");
+ warning("%s: ADPCM decoding not implemented yet", __func__);
chunk.skip(chunk.bytesRemaining());
break;
default:
- error("Unknown audio encoding 0x%x", static_cast<uint>(_bitsPerSample));
+ error("%s: Unknown audio encoding 0x%x", __func__, static_cast<uint>(_bitsPerSample));
}
_streams.push_back(stream);
debugC(5, kDebugLoading, "Finished reading audio chunk (@0x%llx)", static_cast<long long int>(chunk.pos()));
diff --git a/engines/mediastation/bitmap.cpp b/engines/mediastation/bitmap.cpp
index 1143c2e5e0d..13f59016d4d 100644
--- a/engines/mediastation/bitmap.cpp
+++ b/engines/mediastation/bitmap.cpp
@@ -35,7 +35,7 @@ BitmapHeader::BitmapHeader(Chunk &chunk) {
Bitmap::Bitmap(Chunk &chunk, BitmapHeader *bitmapHeader) : _bitmapHeader(bitmapHeader) {
if (stride() < width()) {
- warning("Bitmap: Got stride less than width");
+ warning("%s: Got stride less than width", __func__);
}
_unk1 = chunk.readUint16LE();
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index 2a3e82ebddb..db960248cdf 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -29,13 +29,13 @@ ContextDeclaration::ContextDeclaration(Chunk &chunk) {
// Read the file number.
ContextDeclarationSectionType sectionType = getSectionType(chunk);
if (kContextDeclarationContextId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_contextId = chunk.readTypedUint16();
sectionType = getSectionType(chunk);
if (kContextDeclarationStreamId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_streamId = chunk.readTypedUint16();
@@ -71,13 +71,13 @@ ScreenDeclaration::ScreenDeclaration(Chunk &chunk) {
// Make sure this declaration isn't empty.
ScreenDeclarationSectionType sectionType = getSectionType(chunk);
if (kScreenDeclarationActorId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_actorId = chunk.readTypedUint16();
sectionType = getSectionType(chunk);
if (kScreenDeclarationScreenId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_screenId = chunk.readTypedUint16();
}
@@ -92,14 +92,14 @@ FileDeclaration::FileDeclaration(Chunk &chunk) {
// Read the file ID.
FileDeclarationSectionType sectionType = getSectionType(chunk);
if (kFileDeclarationFileId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_id = chunk.readTypedUint16();
// Read the intended file location.
sectionType = getSectionType(chunk);
if (kFileDeclarationFileNameAndType != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_intendedLocation = static_cast<IntendedFileLocation>(chunk.readTypedUint16());
@@ -119,21 +119,21 @@ SubfileDeclaration::SubfileDeclaration(Chunk &chunk) {
// Read the actor ID.
SubfileDeclarationSectionType sectionType = getSectionType(chunk);
if (kSubfileDeclarationActorId != sectionType) {
- error("Got unexpected section type %d", static_cast<uint>(sectionType));
+ error("%s: Got unexpected section type %d", __func__, static_cast<uint>(sectionType));
}
_actorId = chunk.readTypedUint16();
// Read the file ID.
sectionType = getSectionType(chunk);
if (kSubfileDeclarationFileId != sectionType) {
- error("SubfileDeclaration(): Expected section type FILE_ID, got 0x%x", static_cast<uint>(sectionType));
+ error("%s: Expected section type FILE_ID, got 0x%x", __func__, static_cast<uint>(sectionType));
}
_fileId = chunk.readTypedUint16();
// Read the start offset from the absolute start of the file.
sectionType = getSectionType(chunk);
if (kSubfileDeclarationStartOffset != sectionType) {
- error("SubfileDeclaration(): Expected section type START_OFFSET, got 0x%x", static_cast<uint>(sectionType));
+ error("%s: Expected section type START_OFFSET, got 0x%x", __func__, static_cast<uint>(sectionType));
}
_startOffsetInFile = chunk.readTypedUint32();
}
@@ -200,7 +200,7 @@ Boot::Boot(const Common::Path &path) : Datafile(path) {
EngineResourceDeclaration resourceDeclaration = EngineResourceDeclaration(resourceName, resourceId);
_engineResourceDeclarations.setVal(resourceId, resourceDeclaration);
} else {
- error("Boot::Boot(): Got section type 0x%x when expecting ENGINE_RESOURCE_ID", static_cast<uint>(sectionType));
+ error("%s: Got section type 0x%x when expecting ENGINE_RESOURCE_ID", __func__, static_cast<uint>(sectionType));
}
break;
}
@@ -284,7 +284,7 @@ Boot::Boot(const Common::Path &path) : Datafile(path) {
}
default:
- warning("Boot::Boot(): Unknown section type %d", static_cast<uint>(sectionType));
+ warning("%s: Unknown section type %d", __func__, static_cast<uint>(sectionType));
}
sectionType = getSectionType(chunk);
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index a8eeb89695a..281a58dd7a6 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -43,7 +43,7 @@ namespace MediaStation {
Context::Context(const Common::Path &path) : Datafile(path) {
uint32 signature = _handle->readUint32BE();
if (signature != MKTAG('I', 'I', '\0', '\0')) {
- error("Context::Context(): Wrong signature for file %s: 0x%08x", _name.c_str(), signature);
+ error("%s: Wrong signature for file %s: 0x%08x", __func__, _name.c_str(), signature);
}
_unk1 = _handle->readUint32LE();
@@ -86,7 +86,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
ImageActor *image = static_cast<ImageActor *>(actor);
ImageActor *referencedImage = static_cast<ImageActor *>(getActorById(referencedActorId));
if (referencedImage == nullptr) {
- error("Context::Context(): Actor %d references non-existent actor %d", actor->id(), referencedActorId);
+ error("%s: Actor %d references non-existent actor %d", __func__, actor->id(), referencedActorId);
}
image->_bitmap = referencedImage->_bitmap;
break;
@@ -96,7 +96,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
SpriteMovieActor *sprite = static_cast<SpriteMovieActor *>(actor);
SpriteMovieActor *referencedSprite = static_cast<SpriteMovieActor *>(getActorById(referencedActorId));
if (referencedSprite == nullptr) {
- error("Context::Context(): Actor %d references non-existent actor %d", actor->id(), referencedActorId);
+ error("%s: Actor %d references non-existent actor %d", __func__, actor->id(), referencedActorId);
}
sprite->_frames = referencedSprite->_frames;
sprite->_clips = referencedSprite->_clips;
@@ -104,7 +104,7 @@ Context::Context(const Common::Path &path) : Datafile(path) {
}
default:
- error("Context::Context(): Actor type %d referenced, but reference not implemented yet", actor->type());
+ error("%s: Actor type %d referenced, but reference not implemented yet", __func__, actor->type());
}
}
}
@@ -158,19 +158,19 @@ void Context::readCreateContextData(Chunk &chunk) {
case kContextParametersName: {
uint repeatedFileNumber = chunk.readTypedUint16();
if (repeatedFileNumber != _fileNumber) {
- warning("ContextParameters::ContextParameters(): Repeated file number didn't match: %d != %d", repeatedFileNumber, _fileNumber);
+ warning("%s: Repeated file number didn't match: %d != %d", __func__, repeatedFileNumber, _fileNumber);
}
_contextName = chunk.readTypedString();
uint endingFlag = chunk.readTypedUint16();
if (endingFlag != 0) {
- warning("ContextParameters::ContextParameters(): Got non-zero ending flag 0x%x", endingFlag);
+ warning("%s: Got non-zero ending flag 0x%x", __func__, endingFlag);
}
break;
}
case kContextParametersFileNumber: {
- error("ContextParameters::ContextParameters(): Section type FILE_NUMBER not implemented yet");
+ error("%s: Section type FILE_NUMBER not implemented yet", __func__);
break;
}
@@ -186,7 +186,7 @@ void Context::readCreateContextData(Chunk &chunk) {
}
default:
- error("ContextParameters::ContextParameters(): Unknown section type 0x%x", static_cast<uint>(sectionType));
+ error("%s: Unknown section type 0x%x", __func__, static_cast<uint>(sectionType));
}
sectionType = static_cast<ContextParametersSectionType>(chunk.readTypedUint16());
@@ -251,7 +251,7 @@ Actor *Context::readCreateActorData(Chunk &chunk) {
break;
default:
- error("No class for actor type 0x%x (@0x%llx)", static_cast<uint>(type), static_cast<long long int>(chunk.pos()));
+ error("%s: No class for actor type 0x%x (@0x%llx)", __func__, static_cast<uint>(type), static_cast<long long int>(chunk.pos()));
}
actor->setId(id);
actor->setContextId(contextId);
@@ -262,12 +262,12 @@ Actor *Context::readCreateActorData(Chunk &chunk) {
void Context::readCreateVariableData(Chunk &chunk) {
uint repeatedFileNumber = chunk.readTypedUint16();
if (repeatedFileNumber != _fileNumber) {
- warning("Context::readCreateVariableData(): Repeated file number didn't match: %d != %d", repeatedFileNumber, _fileNumber);
+ warning("%s: Repeated file number didn't match: %d != %d", __func__, repeatedFileNumber, _fileNumber);
}
uint id = chunk.readTypedUint16();
if (g_engine->getVariable(id) != nullptr) {
- error("Global variable %d already exists", id);
+ error("%s: Global variable %d already exists", __func__, id);
}
ScriptValue *value = new ScriptValue(&chunk);
@@ -277,13 +277,13 @@ void Context::readCreateVariableData(Chunk &chunk) {
}
void Context::readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
- error("Context::readOldStyleHeaderSections(): Not implemented yet");
+ error("%s: Not implemented yet", __func__);
}
void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
bool moreSectionsToRead = (chunk._id == MKTAG('i', 'g', 'o', 'd'));
if (!moreSectionsToRead) {
- warning("Context::readNewStyleHeaderSections(): Got no header sections (@0x%llx)", static_cast<long long int>(chunk.pos()));
+ warning("%s: Got no header sections (@0x%llx)", __func__, static_cast<long long int>(chunk.pos()));
}
while (moreSectionsToRead) {
@@ -293,7 +293,7 @@ void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
debugC(5, kDebugLoading, "Context::readNewStyleHeaderSections(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
bool chunkIsHeader = (sectionType == 0x000d);
if (!chunkIsHeader) {
- error("Context::readNewStyleHeaderSections(): Expected header chunk, got %s (@0x%llx)", tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
+ error("%s: Expected header chunk, got %s (@0x%llx)", __func__, tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
}
// Read this header section.
@@ -311,7 +311,7 @@ void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
void Context::readActorInFirstSubfile(Chunk &chunk) {
if (chunk._id == MKTAG('i', 'g', 'o', 'd')) {
- warning("Context::readActorInFirstSubfile(): Skippping \"igod\" actor link chunk");
+ warning("%s: Skippping \"igod\" actor link chunk", __func__);
chunk.skip(chunk.bytesRemaining());
return;
}
@@ -323,7 +323,7 @@ void Context::readActorInFirstSubfile(Chunk &chunk) {
// install cache (INSTALL.CXT).
actor = g_engine->getActorByChunkReference(chunk._id);
if (actor == nullptr) {
- error("Context::readActorInFirstSubfile(): Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ error("%s: Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", __func__, tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
debugC(5, kDebugLoading, "\nContext::readActorInFirstSubfile(): Got actor with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(actor->type()), static_cast<long long int>(chunk.pos()));
@@ -338,7 +338,7 @@ void Context::readActorFromLaterSubfile(Subfile &subfile) {
// install cache (INSTALL.CXT).
actor = g_engine->getActorByChunkReference(chunk._id);
if (actor == nullptr) {
- error("Context::readActorFromLaterSubfile(): Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ error("%s: Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", __func__, tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
}
}
debugC(5, kDebugLoading, "\nContext::readActorFromLaterSubfile(): Got actor with chunk ID %s in later subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), actor->type(), static_cast<long long int>(chunk.pos()));
@@ -355,14 +355,14 @@ bool Context::readHeaderSection(Chunk &chunk) {
}
case kContextActorLinkSection: {
- warning("Context::readHeaderSection(): ACTOR_LINK not implemented yet");
+ warning("%s: ACTOR_LINK not implemented yet", __func__);
chunk.skip(chunk.bytesRemaining());
break;
}
case kContextPaletteSection: {
if (_palette != nullptr) {
- error("Context::readHeaderSection(): Got multiple palettes (@0x%llx)", static_cast<long long int>(chunk.pos()));
+ error("%s: Got multiple palettes (@0x%llx)", __func__, static_cast<long long int>(chunk.pos()));
}
byte *buffer = new byte[Graphics::PALETTE_SIZE];
@@ -373,7 +373,7 @@ bool Context::readHeaderSection(Chunk &chunk) {
// This is likely just an ending flag that we expect to be zero.
uint endingFlag = chunk.readTypedUint16();
if (endingFlag != 0) {
- warning("Context::readHeaderSection(): Got non-zero ending flag 0x%x", endingFlag);
+ warning("%s: Got non-zero ending flag 0x%x", __func__, endingFlag);
}
break;
}
@@ -408,7 +408,7 @@ bool Context::readHeaderSection(Chunk &chunk) {
if (!g_engine->isFirstGenerationEngine()) {
uint endingFlag = chunk.readTypedUint16();
if (endingFlag != 0) {
- warning("Context::readHeaderSection(): Got non-zero ending flag 0x%x in function section", endingFlag);
+ warning("%s: Got non-zero ending flag 0x%x in function section", __func__, endingFlag);
}
}
break;
@@ -422,17 +422,17 @@ bool Context::readHeaderSection(Chunk &chunk) {
}
case kContextEmptySection: {
- error("Context::readHeaderSection(): EMPTY Not implemented yet");
+ error("%s: EMPTY Not implemented yet", __func__);
break;
}
case kContextPoohSection: {
- error("Context::readHeaderSection(): POOH Not implemented yet");
+ error("%s: POOH Not implemented yet", __func__);
break;
}
default:
- error("Context::readHeaderSection(): Unknown section type 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+ error("%s: Unknown section type 0x%x (@0x%llx)", __func__, static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
}
return true;
diff --git a/engines/mediastation/cursors.cpp b/engines/mediastation/cursors.cpp
index 49071e18ffc..3f1d268d453 100644
--- a/engines/mediastation/cursors.cpp
+++ b/engines/mediastation/cursors.cpp
@@ -59,21 +59,21 @@ WindowsCursorManager::~WindowsCursorManager() {
void WindowsCursorManager::loadCursors(const Common::Path &appName) {
if (appName.empty()) {
- error("WindowsCursorManager::loadCursors(): No executable to load cursors from");
+ error("%s: No executable to load cursors from", __func__);
} else if (!Common::File::exists(appName)) {
- error("WindowsCursorManager::loadCursors(): Executable %s doesn't exist", appName.toString().c_str());
+ error("%s: Executable %s doesn't exist", __func__, appName.toString().c_str());
}
Common::WinResources *exe = Common::WinResources::createFromEXE(appName);
if (!exe->loadFromEXE(appName)) {
- error("WindowsCursorManager::loadCursors(): Could not load resources from executable %s", appName.toString().c_str());
+ error("%s: Could not load resources from executable %s", __func__, appName.toString().c_str());
}
const Common::Array<Common::WinResourceID> cursorGroups = exe->getIDList(Common::kWinGroupCursor);
for (Common::WinResourceID cursorGroup : cursorGroups) {
Common::String resourceString = cursorGroup.getString();
if (resourceString.empty()) {
- warning("WindowsCursorManager::loadCursors(): Got Windows cursor group with no string ID");
+ warning("%s: Got Windows cursor group with no string ID", __func__);
continue;
}
Graphics::WinCursorGroup *group = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroup);
@@ -88,20 +88,20 @@ void WindowsCursorManager::setCursor(const Common::String &name) {
Graphics::Cursor *cursor = group->cursors[0].cursor;
CursorMan.replaceCursor(cursor);
} else {
- error("WindowsCursorManager::setCursor(): Reqested Windows cursor %s not found", name.c_str());
+ error("%s: Reqested Windows cursor %s not found", __func__, name.c_str());
}
}
MacCursorManager::MacCursorManager(const Common::Path &appName) {
if (appName.empty()) {
- error("MacCursorManager::loadCursors(): No file to load cursors from");
+ error("%s: No file to load cursors from", __func__);
} else if (!Common::File::exists(appName)) {
- error("MacCursorManager::loadCursors(): File %s doesn't exist", appName.toString().c_str());
+ error("%s: File %s doesn't exist", __func__, appName.toString().c_str());
}
_resFork = new Common::MacResManager();
if (!_resFork->open(appName) || !_resFork->hasResFork()) {
- error("MacCursorManager::loadCursors(): Could not load resource fork from %s", appName.toString().c_str());
+ error("%s: Could not load resource fork from %s", __func__, appName.toString().c_str());
}
}
@@ -120,12 +120,12 @@ void MacCursorManager::setCursor(const Common::String &name) {
// Make sure we got a resource.
if (stream == nullptr) {
- error("MacCursorManager::setCursor(): Reqested Mac cursor %s not found", name.c_str());
+ error("%s: Reqested Mac cursor %s not found", __func__, name.c_str());
}
Graphics::MacCursor *macCursor = new Graphics::MacCursor();
if (!macCursor->readFromStream(*stream)) {
- error("MacCursorManager::setCursor(): Error parsing cursor %s from stream", name.c_str());
+ error("%s: Error parsing cursor %s from stream", __func__, name.c_str());
}
CursorMan.replaceCursor(macCursor);
diff --git a/engines/mediastation/datafile.cpp b/engines/mediastation/datafile.cpp
index 15ca2230751..d0cebdd6c73 100644
--- a/engines/mediastation/datafile.cpp
+++ b/engines/mediastation/datafile.cpp
@@ -27,7 +27,7 @@ namespace MediaStation {
void ParameterReadStream::readAndVerifyType(DatumType type) {
DatumType actualType = static_cast<DatumType>(readUint16LE());
if (actualType != type) {
- error("Expected datum type %d, got %d (@0x%llx)", type, actualType, static_cast<long long int>(pos()));
+ error("%s: Expected datum type %d, got %d (@0x%llx)", __func__, type, actualType, static_cast<long long int>(pos()));
}
}
@@ -146,7 +146,7 @@ Chunk::Chunk(Common::SeekableReadStream *stream) : _parentStream(stream) {
_dataEndOffset = _dataStartOffset + _length;
debugC(5, kDebugLoading, "Chunk::Chunk(): Got chunk with ID \"%s\" and size 0x%x", tag2str(_id), _length);
if (_length == 0)
- error("Encountered a zero-length chunk. This usually indicates corrupted data - maybe a CD-ROM read error.");
+ error("%s: Encountered a zero-length chunk. This usually indicates corrupted data - maybe a CD-ROM read error.", __func__);
}
uint32 Chunk::bytesRemaining() {
@@ -156,7 +156,7 @@ uint32 Chunk::bytesRemaining() {
uint32 Chunk::read(void *dataPtr, uint32 dataSize) {
if (pos() > _dataEndOffset) {
uint overrun = pos() - _dataEndOffset;
- error("Attempted to read 0x%x bytes at a location 0x%x bytes past end of chunk (@0x%llx)", dataSize, overrun, static_cast<long long int>(pos()));
+ error("%s: Attempted to read 0x%x bytes at a location 0x%x bytes past end of chunk (@0x%llx)", __func__, dataSize, overrun, static_cast<long long int>(pos()));
} else {
return _parentStream->read(dataPtr, dataSize);
}
@@ -182,7 +182,7 @@ Subfile::Subfile(Common::SeekableReadStream *stream) : _stream(stream) {
debugC(5, kDebugLoading, "\n*** Subfile::Subfile(): Got new subfile (@0x%llx) ***", static_cast<long long int>(_stream->pos()));
_rootChunk = nextChunk();
if (_rootChunk._id != MKTAG('R', 'I', 'F', 'F'))
- error("Subfile::Subfile(): Expected \"RIFF\" chunk, got %s (@0x%llx)", tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
+ error("%s: Expected \"RIFF\" chunk, got %s (@0x%llx)", __func__, tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
_stream->skip(4); // IMTS
// Read the RATE chunk.
@@ -191,14 +191,14 @@ 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 (@0x%llx)", tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
+ error("%s: Expected \"rate\" chunk, got %s (@0x%llx)", __func__, tag2str(_rootChunk._id), static_cast<long long int>(_stream->pos()));
_rate = _stream->readUint32LE();
// Queue up the first data chunk.
// First, we need to read past the LIST chunk.
nextChunk();
if (_stream->readUint32BE() != MKTAG('d', 'a', 't', 'a'))
- error("Subfile::Subfile(): Expected \"data\" as first bytes of subfile, got %s @0x%llx)", tag2str(rateChunk._id), static_cast<long long int>(_stream->pos()));
+ error("%s: Expected \"data\" as first bytes of subfile, got %s @0x%llx)", __func__, tag2str(rateChunk._id), static_cast<long long int>(_stream->pos()));
}
Chunk Subfile::nextChunk() {
@@ -217,7 +217,7 @@ bool Subfile::atEnd() {
Datafile::Datafile(const Common::Path &path) {
if (!open(path)) {
- error("Datafile::Datafile(): Failed to open %s", path.toString().c_str());
+ error("%s: Failed to open %s", __func__, path.toString().c_str());
}
}
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index a4d67f056b4..b10bc330384 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -45,7 +45,7 @@ VideoDisplayManager::~VideoDisplayManager() {
void VideoDisplayManager::effectTransition(Common::Array<ScriptValue> &args) {
if (args.empty()) {
- warning("effectTransition: Script args cannot be empty");
+ warning("%s: Script args cannot be empty", __func__);
return;
}
@@ -100,7 +100,7 @@ void VideoDisplayManager::effectTransition(Common::Array<ScriptValue> &args) {
break;
default:
- warning("effectTransition: Got unknown transition type %d", static_cast<uint>(transitionType));
+ warning("%s: Got unknown transition type %d", __func__, static_cast<uint>(transitionType));
}
}
@@ -190,7 +190,7 @@ void VideoDisplayManager::fadeToColor(Common::Array<ScriptValue> &args) {
void VideoDisplayManager::setToColor(Common::Array<ScriptValue> &args) {
if (args.size() < 6) {
- error("setToColor: Too few script args");
+ error("%s: Too few script args", __func__);
}
byte r = static_cast<byte>(args[1].asFloat());
@@ -204,7 +204,7 @@ void VideoDisplayManager::setToColor(Common::Array<ScriptValue> &args) {
void VideoDisplayManager::setToPercentOfPalette(Common::Array<ScriptValue> &args) {
if (args.size() < 7) {
- error("setToPercentOfPalette: Too few script args");
+ error("%s: Too few script args", __func__);
}
double percent = args[1].asFloat();
@@ -226,7 +226,7 @@ void VideoDisplayManager::fadeToPaletteObject(Common::Array<ScriptValue> &args)
if (args.size() >= 2) {
paletteId = args[1].asActorId();
} else {
- warning("fadeToPaletteObject: Too few script args");
+ warning("%s: Too few script args", __func__);
return;
}
if (args.size() >= 3) {
@@ -248,7 +248,7 @@ void VideoDisplayManager::setToPaletteObject(Common::Array<ScriptValue> &args) {
if (args.size() >= 2) {
paletteId = args[1].asActorId();
} else {
- warning("fadeToPaletteObject: Too few script args");
+ warning("%s: Too few script args", __func__);
return;
}
if (args.size() >= 4) {
@@ -269,7 +269,7 @@ void VideoDisplayManager::setToPercentOfPaletteObject(Common::Array<ScriptValue>
percent = args[1].asFloat();
paletteId = args[2].asActorId();
} else {
- error("fadeToPaletteObject: Too few script args");
+ error("%s: Too few script args", __func__);
return;
}
if (args.size() >= 5) {
@@ -282,7 +282,7 @@ void VideoDisplayManager::setToPercentOfPaletteObject(Common::Array<ScriptValue>
void VideoDisplayManager::colorShiftCurrentPalette(Common::Array<ScriptValue> &args) {
if (args.size() < 4) {
- warning("colorShiftCurrentPalette: Too few script args");
+ warning("%s: Too few script args", __func__);
return;
}
@@ -294,7 +294,7 @@ void VideoDisplayManager::colorShiftCurrentPalette(Common::Array<ScriptValue> &a
}
void VideoDisplayManager::circleOut(Common::Array<ScriptValue> &args) {
- warning("STUB: circleOut");
+ warning("%s: STUB", __func__);
}
void VideoDisplayManager::_setPalette(Graphics::Palette &palette, uint startIndex, uint colorCount) {
@@ -356,7 +356,7 @@ void VideoDisplayManager::_setPercentToColor(double percent, byte r, byte g, byt
void VideoDisplayManager::_setToPercentPalette(double percent, Graphics::Palette ¤tPalette, Graphics::Palette &targetPalette, uint startIndex, uint colorCount) {
if (percent < 0.0 || percent > 1.0) {
- warning("_setToPercentPalette: Got invalid palette percent value %f", percent);
+ warning("%s: Got invalid palette percent value %f", __func__, percent);
percent = CLIP<double>(percent, 0.0, 1.0);
}
@@ -381,7 +381,7 @@ void VideoDisplayManager::_setToPercentPalette(double percent, Graphics::Palette
void VideoDisplayManager::_fadeToPalette(double fadeTime, Graphics::Palette &targetPalette, uint startIndex, uint colorCount) {
if (fadeTime <= 0.0) {
// Set the fade time to something reasonable so we can continue.
- warning("_fadeToPalette: Got invalid fade time %f", fadeTime);
+ warning("%s: Got invalid fade time %f", __func__, fadeTime);
fadeTime = 0.1;
}
@@ -450,9 +450,9 @@ void VideoDisplayManager::_colorShiftCurrentPalette(uint startIndex, uint shiftA
void VideoDisplayManager::_fadeToPaletteObject(uint paletteId, double fadeTime, uint startIndex, uint colorCount) {
Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
- error("Got null target palette");
+ error("%s: Got null target palette", __func__);
} else if (actor->type() != kActorTypePalette) {
- error("Actor %d is not a palette", paletteId);
+ error("%s: Actor %d is not a palette", __func__, paletteId);
}
Graphics::Palette *palette = static_cast<PaletteActor *>(actor)->_palette;
@@ -462,9 +462,9 @@ void VideoDisplayManager::_fadeToPaletteObject(uint paletteId, double fadeTime,
void VideoDisplayManager::_setToPaletteObject(uint paletteId, uint startIndex, uint colorCount) {
Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
- error("Got null target palette");
+ error("%s: Got null target palette", __func__);
} else if (actor->type() != kActorTypePalette) {
- error("Actor %d is not a palette", paletteId);
+ error("%s: Actor %d is not a palette", __func__, paletteId);
}
Graphics::Palette *palette = static_cast<PaletteActor *>(actor)->_palette;
@@ -474,9 +474,9 @@ void VideoDisplayManager::_setToPaletteObject(uint paletteId, uint startIndex, u
void VideoDisplayManager::_setPercentToPaletteObject(double percent, uint paletteId, uint startIndex, uint colorCount) {
Actor *actor = _vm->getActorById(paletteId);
if (actor == nullptr) {
- error("Got null target palette");
+ error("%s: Got null target palette", __func__);
} else if (actor->type() != kActorTypePalette) {
- error("Actor %d is not a palette", paletteId);
+ error("%s: Actor %d is not a palette", __func__, paletteId);
}
Graphics::Palette *targetPalette = static_cast<PaletteActor *>(actor)->_palette;
@@ -512,12 +512,12 @@ void VideoDisplayManager::imageBlit(
break;
default:
- error("imageBlit: Got unknown bitmap compression type %d",
+ error("%s: Got unknown bitmap compression type %d", __func__,
static_cast<uint>(sourceImage->getCompressionType()));
}
if (dissolveFactor > 1.0 || dissolveFactor < 0.0) {
- warning("imageBlit: Got out-of-range dissolve factor: %f", dissolveFactor);
+ warning("%s: Got out-of-range dissolve factor: %f", __func__, dissolveFactor);
CLIP(dissolveFactor, 0.0, 1.0);
} else if (dissolveFactor == 0.0) {
// If the image is fully transparent, there is nothing to draw, so we can return now.
@@ -552,7 +552,7 @@ void VideoDisplayManager::imageBlit(
case kCccBlit | kClipEnabled:
case kCccTransparentBlit | kClipEnabled:
// CCC blitting is unimplemented for now because few, if any, titles actually use it.
- error("imageBlit: CCC blitting not implemented yet");
+ error("%s: CCC blitting not implemented yet", __func__);
break;
case kPartialDissolve | kClipEnabled:
@@ -566,7 +566,7 @@ void VideoDisplayManager::imageBlit(
break;
default:
- error("imageBlit: Got invalid blit mode: 0x%x", blitFlags);
+ error("%s: Got invalid blit mode: 0x%x", __func__, blitFlags);
}
}
@@ -656,7 +656,7 @@ void VideoDisplayManager::dissolveBlit1Rect(
break;
default:
- error("dissolveBlit1Rect: Unsupported compression type for dissolve blit: %d",
+ error("%s: Unsupported compression type for dissolve blit: %d", __func__,
static_cast<uint>(source->getCompressionType()));
}
@@ -686,11 +686,11 @@ void VideoDisplayManager::dissolveBlit1Rect(
if (destXInBounds && destYInBounds) {
dest->setPixel(destPos.x, destPos.y, sourcePixel);
} else {
- warning("dissolveBlit1Rect: Dest out of bounds");
+ warning("%s: Dest out of bounds", __func__);
}
}
} else {
- warning("dissolveBlit1Rect: Source out of bounds");
+ warning("%s: Source out of bounds", __func__);
}
}
}
@@ -706,10 +706,10 @@ void VideoDisplayManager::imageDeltaBlit(
const Common::Array<Common::Rect> &dirtyRegion) {
if (deltaFrame->getCompressionType() != kRle8BitmapCompression) {
- error("imageDeltaBlit: Unsupported delta frame compression type for delta blit: %d",
- static_cast<uint>(keyFrame->getCompressionType()));
+ error("%s: Unsupported delta frame compression type for delta blit: %d",
+ __func__, static_cast<uint>(keyFrame->getCompressionType()));
} else if (dissolveFactor != 1.0) {
- warning("imageDeltaBlit: Delta blit does not support dissolving");
+ warning("%s: Delta blit does not support dissolving", __func__);
}
switch (keyFrame->getCompressionType()) {
@@ -723,8 +723,8 @@ void VideoDisplayManager::imageDeltaBlit(
break;
default:
- error("imageDeltaBlit: Unsupported keyframe image type for delta blit: %d",
- static_cast<uint>(deltaFrame->getCompressionType()));
+ error("%s: Unsupported keyframe image type for delta blit: %d",
+ __func__, static_cast<uint>(deltaFrame->getCompressionType()));
}
}
@@ -780,7 +780,7 @@ void VideoDisplayManager::deltaRleBlit1Rect(
// compressed. However, real titles don't seem to use it, instead
// decompressing the keyframe separately and then passng it in.
// So this is left unimplemented until it's actually needed.
- warning("STUB: deltaRleBlit1Rect");
+ warning("STUB: %s", __func__);
}
Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
@@ -841,7 +841,7 @@ Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
byte *destPtr = static_cast<byte *>(dest.getBasePtr(destPos.x, destPos.y));
memcpy(destPtr, srcPtr, xToCopy);
} else {
- warning("decompressRle8Bitmap: Keyframe copy (multi-line) exceeds bounds");
+ warning("%s: Keyframe copy (multi-line) exceeds bounds", __func__);
}
}
@@ -855,7 +855,7 @@ Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
byte *destPtr = static_cast<byte *>(dest.getBasePtr(sourcePos.x, sourcePos.y));
memcpy(destPtr, srcPtr, xToCopy);
} else {
- warning("decompressRle8Bitmap: Keyframe copy (same line) exceeds bounds");
+ warning("%s: Keyframe copy (same line) exceeds bounds", __func__);
}
sourcePos += Common::Point(xToCopy, yToCopy);
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 06c24227c27..483e49ce7a5 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -49,7 +49,7 @@ ScriptValue CodeChunk::executeNextBlock() {
if (!_returnImmediately) {
uint bytesRead = _bytecode->pos() - startingPos;
if (bytesRead != blockSize) {
- error("Expected to have read %d script bytes, actually read %d", blockSize, bytesRead);
+ error("%s: Expected to have read %d script bytes, actually read %d", __func__, blockSize, bytesRead);
}
}
return returnValue;
@@ -102,7 +102,7 @@ ScriptValue CodeChunk::evaluateExpression(ExpressionType expressionType) {
break;
default:
- error("Got unimplemented expression type %s (%d)",
+ error("%s: Got unimplemented expression type %s (%d)", __func__,
expressionTypeToStr(expressionType), static_cast<uint>(expressionType));
}
return returnValue;
@@ -180,7 +180,7 @@ ScriptValue CodeChunk::evaluateOperation() {
break;
default:
- error("Got unimplemented opcode %s (%d)", opcodeToStr(opcode), static_cast<uint>(opcode));
+ error("%s: Got unimplemented opcode %s (%d)", __func__, opcodeToStr(opcode), static_cast<uint>(opcode));
}
return returnValue;
}
@@ -194,7 +194,7 @@ ScriptValue CodeChunk::evaluateValue() {
case kOperandTypeBool: {
int b = _bytecode->readTypedByte();
if (b != 0 && b != 1) {
- error("Got invalid literal bool value %d", b);
+ error("%s: Got invalid literal bool value %d", __func__, b);
}
debugC(5, kDebugScript, "%d ", b);
returnValue.setToBool(b == 1 ? true : false);
@@ -266,7 +266,7 @@ ScriptValue CodeChunk::evaluateValue() {
}
default:
- error("Got unknown ScriptValue type %s (%d)", operandTypeToStr(operandType), static_cast<uint>(operandType));
+ error("%s: Got unknown ScriptValue type %s (%d)", __func__, operandTypeToStr(operandType), static_cast<uint>(operandType));
}
}
@@ -285,7 +285,7 @@ ScriptValue *CodeChunk::readAndReturnVariable() {
case kVariableScopeGlobal: {
ScriptValue *variable = g_engine->getVariable(id);
if (variable == nullptr) {
- error("Global variable %d doesn't exist", id);
+ error("%s: Global variable %d doesn't exist", __func__, id);
}
return variable;
}
@@ -304,13 +304,13 @@ ScriptValue *CodeChunk::readAndReturnVariable() {
case kVariableScopeParameter: {
uint index = id - 1;
if (_args == nullptr) {
- error("Requested a parameter in a code chunk that has no parameters");
+ error("%s: Requested a parameter in a code chunk that has no parameters", __func__);
}
return &_args->operator[](index);
}
default:
- error("Got unknown variable scope %s (%d)", variableScopeToStr(scope), static_cast<uint>(scope));
+ error("%s: Got unknown variable scope %s (%d)", __func__, variableScopeToStr(scope), static_cast<uint>(scope));
}
}
@@ -318,7 +318,7 @@ void CodeChunk::evaluateIf() {
debugCN(5, kDebugScript, "\n condition: ");
ScriptValue condition = evaluateExpression();
if (condition.getType() != kScriptValueTypeBool) {
- error("evaluateIf: Expected bool condition, got %s", scriptValueTypeToStr(condition.getType()));
+ error("%s: Expected bool condition, got %s", __func__, scriptValueTypeToStr(condition.getType()));
}
if (condition.asBool()) {
@@ -332,7 +332,7 @@ void CodeChunk::evaluateIfElse() {
debugCN(5, kDebugScript, "\n condition: ");
ScriptValue condition = evaluateExpression();
if (condition.getType() != kScriptValueTypeBool) {
- error("evaluateIfElse: Expected bool condition, got %s", scriptValueTypeToStr(condition.getType()));
+ error("%s: Expected bool condition, got %s", __func__, scriptValueTypeToStr(condition.getType()));
}
if (condition.asBool()) {
@@ -352,14 +352,14 @@ ScriptValue CodeChunk::evaluateAssign() {
ScriptValue value = evaluateExpression();
if (value.getType() == kScriptValueTypeEmpty) {
- error("Attempt to assign an empty value to a variable");
+ error("%s: Attempt to assign an empty value to a variable", __func__);
}
if (targetVariable != nullptr) {
*targetVariable = value;
return value;
} else {
- error("Attempt to assign to null variable");
+ error("%s: Attempt to assign to null variable", __func__);
}
}
@@ -428,7 +428,7 @@ ScriptValue CodeChunk::evaluateBinaryOperation(Opcode op) {
break;
default:
- error("Got unknown binary operation opcode %s", opcodeToStr(op));
+ error("%s: Got unknown binary operation opcode %s", __func__, opcodeToStr(op));
}
return returnValue;
}
@@ -516,14 +516,14 @@ ScriptValue CodeChunk::evaluateMethodCall(BuiltInMethod method, uint paramCount)
if (target.asActorId() == 0) {
// It seems to be valid to call a method on a null actor ID, in
// which case nothing happens. Still issue warning for traceability.
- warning("Attempt to call method on a null actor ID");
+ warning("%s: Attempt to call method on a null actor ID", __func__);
return returnValue;
} else {
// This is a regular actor that we can process directly.
uint actorId = target.asActorId();
Actor *targetActor = g_engine->getActorById(actorId);
if (targetActor == nullptr) {
- error("Attempt to call method on actor ID %d, which isn't loaded", target.asActorId());
+ error("%s: Attempt to call method on actor ID %d, which isn't loaded", __func__, target.asActorId());
}
returnValue = targetActor->callMethod(method, args);
return returnValue;
diff --git a/engines/mediastation/mediascript/collection.cpp b/engines/mediastation/mediascript/collection.cpp
index a33772d2a2a..72825d56d76 100644
--- a/engines/mediastation/mediascript/collection.cpp
+++ b/engines/mediastation/mediascript/collection.cpp
@@ -119,7 +119,7 @@ ScriptValue Collection::callMethod(BuiltInMethod method, Common::Array<ScriptVal
break;
default:
- error("Attempt to call unimplemented method %s (%d)", builtInMethodToStr(method), static_cast<uint>(method));
+ error("%s: Attempt to call unimplemented method %s (%d)", __func__, builtInMethodToStr(method), static_cast<uint>(method));
}
return returnValue;
}
@@ -131,7 +131,7 @@ void Collection::apply(const Common::Array<ScriptValue> &args) {
for (const ScriptValue &item : *this) {
argsToApply[0] = item;
// TODO: Need to create and call FunctionManager.
- warning("Applying function %d not implemented", functionId);
+ warning("%s: Applying function %d not implemented", __func__, functionId);
}
}
diff --git a/engines/mediastation/mediascript/scriptvalue.cpp b/engines/mediastation/mediascript/scriptvalue.cpp
index 4f9008cc5c5..de078081677 100644
--- a/engines/mediastation/mediascript/scriptvalue.cpp
+++ b/engines/mediastation/mediascript/scriptvalue.cpp
@@ -40,7 +40,7 @@ ScriptValue::ScriptValue(ParameterReadStream *stream) {
case kScriptValueTypeBool: {
uint rawValue = stream->readTypedByte();
if (rawValue != 0 && rawValue != 1) {
- error("Got invalid literal bool value %d", rawValue);
+ error("%s: Got invalid literal bool value %d", __func__, rawValue);
}
setToBool(rawValue);
break;
@@ -95,7 +95,7 @@ ScriptValue::ScriptValue(ParameterReadStream *stream) {
}
default:
- error("Got unknown script value type %s", scriptValueTypeToStr(_type));
+ error("%s: Got unknown script value type %s", __func__, scriptValueTypeToStr(_type));
}
}
@@ -234,7 +234,7 @@ BuiltInMethod ScriptValue::asMethodId() const {
bool ScriptValue::compare(Opcode op, const ScriptValue &lhs, const ScriptValue &rhs) {
if (lhs.getType() != rhs.getType()) {
- error("Attempt to compare mismatched types %s and %s", scriptValueTypeToStr(lhs.getType()), scriptValueTypeToStr(rhs.getType()));
+ error("%s: Attempt to compare mismatched types %s and %s", __func__, scriptValueTypeToStr(lhs.getType()), scriptValueTypeToStr(rhs.getType()));
}
switch (lhs.getType()) {
@@ -278,7 +278,7 @@ bool ScriptValue::compare(Opcode op, const ScriptValue &lhs, const ScriptValue &
break;
default:
- error("Got unknown script value type %d", lhs.getType());
+ error("%s: Got unknown script value type %d", __func__, lhs.getType());
}
}
@@ -292,7 +292,7 @@ bool ScriptValue::compareEmptyValues(Opcode op) {
return false;
default:
- error("Got invalid empty value operation %s", opcodeToStr(op));
+ error("%s: Got invalid empty value operation %s", __func__, opcodeToStr(op));
}
}
@@ -317,7 +317,7 @@ bool ScriptValue::compareStrings(Opcode op, const Common::String &left, const Co
return (left >= right);
default:
- error("Got invalid string operation %s", opcodeToStr(op));
+ error("%s: Got invalid string operation %s", __func__, opcodeToStr(op));
}
}
@@ -330,7 +330,7 @@ bool ScriptValue::compare(Opcode op, uint left, uint right) {
return (left != right);
default:
- error("Got invalid param token operation %s", opcodeToStr(op));
+ error("%s: Got invalid param token operation %s", __func__, opcodeToStr(op));
}
}
@@ -343,7 +343,7 @@ bool ScriptValue::compare(Opcode op, bool left, bool right) {
return (left != right);
default:
- error("Got invalid bool operation %s", opcodeToStr(op));
+ error("%s: Got invalid bool operation %s", __func__, opcodeToStr(op));
}
}
@@ -368,7 +368,7 @@ bool ScriptValue::compare(Opcode op, double left, double right) {
return (left >= right);
default:
- error("Got invalid float operation %s", opcodeToStr(op));
+ error("%s: Got invalid float operation %s", __func__, opcodeToStr(op));
}
}
@@ -381,7 +381,7 @@ bool ScriptValue::compare(Opcode op, Common::SharedPtr<Collection> left, Common:
return (left != right);
default:
- error("Got invalid collection operation %s", opcodeToStr(op));
+ error("%s: Got invalid collection operation %s", __func__, opcodeToStr(op));
}
}
@@ -396,7 +396,7 @@ ScriptValue ScriptValue::evalMathOperation(Opcode op, const ScriptValue &left, c
} else if (right.getType() == kScriptValueTypeFloat) {
result = binaryMathOperation(op, left.asFloat(), right.asFloat());
} else {
- error("Attempted to do math operation on unsupported value type %s", scriptValueTypeToStr(right.getType()));
+ error("%s: Attempted to do math operation on unsupported value type %s", __func__, scriptValueTypeToStr(right.getType()));
}
returnValue.setToFloat(result);
break;
@@ -408,7 +408,7 @@ ScriptValue ScriptValue::evalMathOperation(Opcode op, const ScriptValue &left, c
} else if (right.getType() == kScriptValueTypeFloat) {
result = binaryMathOperation(op, left.asTime(), right.asFloat());
} else {
- error("Attempted to do math operation on unsupported value type %s", scriptValueTypeToStr(right.getType()));
+ error("%s: Attempted to do math operation on unsupported value type %s", __func__, scriptValueTypeToStr(right.getType()));
}
returnValue.setToFloat(result);
break;
@@ -420,7 +420,7 @@ ScriptValue ScriptValue::evalMathOperation(Opcode op, const ScriptValue &left, c
}
default:
- error("Attempted to do math operation on unsupported value type %s", scriptValueTypeToStr(right.getType()));
+ error("%s: Attempted to do math operation on unsupported value type %s", __func__, scriptValueTypeToStr(right.getType()));
}
return returnValue;
@@ -441,18 +441,18 @@ double ScriptValue::binaryMathOperation(Opcode op, double left, double right) {
if (right != 0.0) {
return left / right;
} else {
- error("Division by zero");
+ error("%s: Division by zero", __func__);
}
case kOpcodeModulo:
if (right != 0.0) {
return fmod(left, right);
} else {
- error("Division by zero");
+ error("%s: Division by zero", __func__);
}
default:
- error("Got unvalid binary math operation %s", opcodeToStr(op));
+ error("%s: Got unvalid binary math operation %s", __func__, opcodeToStr(op));
}
}
@@ -482,7 +482,7 @@ bool ScriptValue::operator>=(const ScriptValue &other) const {
bool ScriptValue::operator||(const ScriptValue &other) const {
if (getType() != kScriptValueTypeBool || other.getType() != kScriptValueTypeBool) {
- error("Expected bools for binary comparison, got %s and %s", scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
+ error("%s: Expected bools for binary comparison, got %s and %s", __func__, scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
}
return asBool() || other.asBool();
@@ -490,7 +490,7 @@ bool ScriptValue::operator||(const ScriptValue &other) const {
bool ScriptValue::operator^(const ScriptValue &other) const {
if (getType() != kScriptValueTypeBool || other.getType() != kScriptValueTypeBool) {
- error("Expected bools for binary comparison, got %s and %s", scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
+ error("%s: Expected bools for binary comparison, got %s and %s", __func__, scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
}
return asBool() ^ other.asBool();
@@ -498,7 +498,7 @@ bool ScriptValue::operator^(const ScriptValue &other) const {
bool ScriptValue::operator&&(const ScriptValue &other) const {
if (getType() != kScriptValueTypeBool || other.getType() != kScriptValueTypeBool) {
- error("Expected bools for binary comparison, got %s and %s", scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
+ error("%s: Expected bools for binary comparison, got %s and %s", __func__, scriptValueTypeToStr(getType()), scriptValueTypeToStr(other.getType()));
}
return asBool() && other.asBool();
@@ -536,7 +536,7 @@ ScriptValue ScriptValue::operator-() const {
break;
default:
- error("Attempted to negate type %s", scriptValueTypeToStr(getType()));
+ error("%s: Attempted to negate type %s", __func__, scriptValueTypeToStr(getType()));
}
return returnValue;
}
@@ -545,7 +545,7 @@ void ScriptValue::issueValueMismatchWarning(ScriptValueType expectedType) const
// The original just blithely returns 0 (or equivalent) when you call a
// getter for the wrong type (for instance, calling asFloat() on a bool),
// but for debugging purposes we'll issue a warning.
- warning("Script value type mismatch: Expected %s, got %s", scriptValueTypeToStr(expectedType), scriptValueTypeToStr(_type));
+ warning("%s: Script value type mismatch: Expected %s, got %s", __func__, scriptValueTypeToStr(expectedType), scriptValueTypeToStr(_type));
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 888204fede7..1f83e29636b 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -128,7 +128,7 @@ const char *MediaStationEngine::getAppName() const {
bool MediaStationEngine::isFirstGenerationEngine() {
if (_boot == nullptr) {
- error("Attempted to get engine version before BOOT.STM was read");
+ error("%s: Attempted to get engine version before BOOT.STM was read", __func__);
} else {
return (_boot->_versionInfo.major == 0);
}
@@ -145,7 +145,7 @@ Common::Error MediaStationEngine::run() {
} else if (getPlatform() == Common::kPlatformMacintosh) {
_cursor = new MacCursorManager(getAppName());
} else {
- error("MediaStationEngine::run(): Attempted to use unsupported platform %s", Common::getPlatformDescription(getPlatform()));
+ error("%s: Attempted to use unsupported platform %s", __func__, Common::getPlatformDescription(getPlatform()));
}
_cursor->showCursor();
@@ -156,7 +156,7 @@ Common::Error MediaStationEngine::run() {
// For development purposes, we can choose to start at an arbitrary context
// in this title. This might not work in all cases.
uint entryContextId = ConfMan.get("entry_context").asUint64();
- warning("Starting at user-requested context %d", entryContextId);
+ warning("%s: Starting at user-requested context %d", __func__, entryContextId);
_requestedScreenBranchId = entryContextId;
} else {
_requestedScreenBranchId = _boot->_entryContextId;
@@ -241,7 +241,7 @@ void MediaStationEngine::processEvents() {
case Common::EVENT_RBUTTONDOWN: {
// We are using the right button as a quick exit since the Media
// Station engine doesn't seem to use the right button itself.
- warning("EVENT_RBUTTONDOWN: Quitting for development purposes");
+ warning("%s: EVENT_RBUTTONDOWN: Quitting for development purposes", __func__);
quitGame();
break;
}
@@ -309,12 +309,12 @@ void MediaStationEngine::draw() {
Context *MediaStationEngine::loadContext(uint32 contextId) {
if (_boot == nullptr) {
- error("Cannot load contexts before BOOT.STM is read");
+ error("%s: Cannot load contexts before BOOT.STM is read", __func__);
}
debugC(5, kDebugLoading, "MediaStationEngine::loadContext(): Loading context %d", contextId);
if (_loadedContexts.contains(contextId)) {
- warning("MediaStationEngine::loadContext(): Context %d already loaded, returning existing context", contextId);
+ warning("%s: Context %d already loaded, returning existing context", __func__, contextId);
return _loadedContexts.getVal(contextId);
}
@@ -323,7 +323,7 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
// There are other actors in a subfile too, so we need to make sure we're
// referencing the screen actor, at the start of the file.
if (subfileDeclaration._startOffsetInFile != 16) {
- warning("MediaStationEngine::loadContext(): Requested ID wasn't for a context.");
+ warning("%s: Requested ID wasn't for a context.", __func__);
return nullptr;
}
uint fileId = subfileDeclaration._fileId;
@@ -351,7 +351,7 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
void MediaStationEngine::registerActor(Actor *actorToAdd) {
if (getActorById(actorToAdd->id())) {
- error("Actor with ID 0x%d was already defined in this title", actorToAdd->id());
+ error("%s: Actor with ID 0x%d was already defined in this title", __func__, actorToAdd->id());
}
_actors.push_back(actorToAdd);
@@ -389,7 +389,7 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
debugC(5, kDebugScript, "MediaStationEngine::releaseContext(): Releasing context %d", contextId);
Context *context = _loadedContexts.getValOrDefault(contextId);
if (context == nullptr) {
- error("MediaStationEngine::releaseContext(): Attempted to unload context %d that is not currently loaded", contextId);
+ error("%s: Attempted to unload context %d that is not currently loaded", __func__, contextId);
}
// Make sure nothing is still using this context.
@@ -461,18 +461,18 @@ ScriptValue MediaStationEngine::callBuiltInFunction(BuiltInFunction function, Co
case kDrawingFunction: {
// Not entirely sure what this function does, but it seems like a way to
// call into some drawing functions built into the IBM/Crayola executable.
- warning("MediaStationEngine::callBuiltInFunction(): Built-in drawing function not implemented");
+ warning("%s: Built-in drawing function not implemented", __func__);
return returnValue;
}
case kUnk1Function: {
- warning("MediaStationEngine::callBuiltInFunction(): Function 10 not implemented");
+ warning("%s: Function 10 not implemented", __func__);
returnValue.setToFloat(1.0);
return returnValue;
}
default:
- error("MediaStationEngine::callBuiltInFunction(): Got unknown built-in function %s (%d)", builtInFunctionToStr(function), static_cast<uint>(function));
+ error("%s: Got unknown built-in function %s (%d)", __func__, builtInFunctionToStr(function), static_cast<uint>(function));
}
}
Commit: aba7527286a7f3de06123d1187596159fbfe3119
https://github.com/scummvm/scummvm/commit/aba7527286a7f3de06123d1187596159fbfe3119
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Rename Function to ScriptFunction
Changed paths:
engines/mediastation/context.cpp
engines/mediastation/context.h
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/function.cpp
engines/mediastation/mediascript/function.h
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index 281a58dd7a6..7b3dca6c8b9 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -140,7 +140,7 @@ Actor *Context::getActorByChunkReference(uint chunkReference) {
return _actorsByChunkReference.getValOrDefault(chunkReference);
}
-Function *Context::getFunctionById(uint functionId) {
+ScriptFunction *Context::getFunctionById(uint functionId) {
return _functions.getValOrDefault(functionId);
}
@@ -180,7 +180,7 @@ void Context::readCreateContextData(Chunk &chunk) {
}
case kContextParametersBytecode: {
- Function *function = new Function(chunk);
+ ScriptFunction *function = new ScriptFunction(chunk);
_functions.setVal(function->_id, function);
break;
}
@@ -403,7 +403,7 @@ bool Context::readHeaderSection(Chunk &chunk) {
}
case kContextFunctionSection: {
- Function *function = new Function(chunk);
+ ScriptFunction *function = new ScriptFunction(chunk);
_functions.setVal(function->_id, function);
if (!g_engine->isFirstGenerationEngine()) {
uint endingFlag = chunk.readTypedUint16();
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index 3512725cc6b..55cb9c7c0b6 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -68,7 +68,7 @@ public:
Actor *getActorById(uint actorId);
Actor *getActorByChunkReference(uint chunkReference);
- Function *getFunctionById(uint functionId);
+ ScriptFunction *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
private:
@@ -79,7 +79,7 @@ private:
Common::String _contextName;
Common::HashMap<uint, Actor *> _actors;
- Common::HashMap<uint, Function *> _functions;
+ Common::HashMap<uint, ScriptFunction *> _functions;
Common::HashMap<uint, Actor *> _actorsByChunkReference;
Common::HashMap<uint, ScriptValue *> _variables;
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 483e49ce7a5..5a80296abca 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -465,7 +465,7 @@ ScriptValue CodeChunk::evaluateFunctionCall(uint functionId, uint paramCount) {
}
ScriptValue returnValue;
- Function *function = g_engine->getFunctionById(functionId);
+ ScriptFunction *function = g_engine->getFunctionById(functionId);
if (function != nullptr) {
// This is a title-defined function.
returnValue = function->execute(args);
diff --git a/engines/mediastation/mediascript/function.cpp b/engines/mediastation/mediascript/function.cpp
index 8f8de848757..61baa7c4b94 100644
--- a/engines/mediastation/mediascript/function.cpp
+++ b/engines/mediastation/mediascript/function.cpp
@@ -24,8 +24,8 @@
namespace MediaStation {
-Function::Function(Chunk &chunk) {
- _fileId = chunk.readTypedUint16();
+ScriptFunction::ScriptFunction(Chunk &chunk) {
+ _contextId = chunk.readTypedUint16();
// In PROFILE._ST (only present in some titles), the function ID is reported
// with 19900 added, so function 100 would be reported as 20000. But in
// bytecode, the zero-based ID is used, so that's what we'll store here.
@@ -33,12 +33,12 @@ Function::Function(Chunk &chunk) {
_code = new CodeChunk(chunk);
}
-Function::~Function() {
+ScriptFunction::~ScriptFunction() {
delete _code;
_code = nullptr;
}
-ScriptValue Function::execute(Common::Array<ScriptValue> &args) {
+ScriptValue ScriptFunction::execute(Common::Array<ScriptValue> &args) {
debugC(5, kDebugScript, "\n********** FUNCTION %d **********", _id);
ScriptValue returnValue = _code->execute(&args);
debugC(5, kDebugScript, "********** END FUNCTION **********");
diff --git a/engines/mediastation/mediascript/function.h b/engines/mediastation/mediascript/function.h
index b567095133f..0590d732a28 100644
--- a/engines/mediastation/mediascript/function.h
+++ b/engines/mediastation/mediascript/function.h
@@ -29,14 +29,14 @@
namespace MediaStation {
-class Function {
+class ScriptFunction {
public:
- Function(Chunk &chunk);
- ~Function();
+ ScriptFunction(Chunk &chunk);
+ ~ScriptFunction();
ScriptValue execute(Common::Array<ScriptValue> &args);
- uint _fileId;
+ uint _contextId;
uint _id;
private:
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 1f83e29636b..02e1e7842e6 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -90,9 +90,9 @@ Actor *MediaStationEngine::getActorByChunkReference(uint chunkReference) {
return nullptr;
}
-Function *MediaStationEngine::getFunctionById(uint functionId) {
+ScriptFunction *MediaStationEngine::getFunctionById(uint functionId) {
for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
- Function *function = it->_value->getFunctionById(functionId);
+ ScriptFunction *function = it->_value->getFunctionById(functionId);
if (function != nullptr) {
return function;
}
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index e4703e3e63f..755f55fda37 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -88,7 +88,7 @@ public:
Actor *getActorById(uint actorId);
Actor *getActorByChunkReference(uint chunkReference);
- Function *getFunctionById(uint functionId);
+ ScriptFunction *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
VideoDisplayManager *getDisplayManager() { return _displayManager; }
Commit: ed1323dd68fdeadc45ca3e1ae654d8baeab01e21
https://github.com/scummvm/scummvm/commit/ed1323dd68fdeadc45ca3e1ae654d8baeab01e21
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Refactor script constants to use hex digits
Changed paths:
engines/mediastation/actor.cpp
engines/mediastation/mediascript/scriptconstants.h
diff --git a/engines/mediastation/actor.cpp b/engines/mediastation/actor.cpp
index 4ac4efe67bf..7de7112ed85 100644
--- a/engines/mediastation/actor.cpp
+++ b/engines/mediastation/actor.cpp
@@ -74,7 +74,7 @@ void Actor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
}
ScriptValue Actor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
- error("Got unimplemented method call %d (%s)", static_cast<uint>(methodId), builtInMethodToStr(methodId));
+ error("%s: Got unimplemented method call 0x%x (%s)", __func__, static_cast<uint>(methodId), builtInMethodToStr(methodId));
}
void Actor::readChunk(Chunk &chunk) {
diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index 3f1bc154fe3..8e19c6ccc57 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -33,51 +33,51 @@ enum ExpressionType {
const char *expressionTypeToStr(ExpressionType type);
enum Opcode {
- kOpcodeIf = 201,
- kOpcodeIfElse = 202,
- kOpcodeAssignVariable = 203,
- kOpcodeOr = 204,
- kOpcodeXor = 205,
- kOpcodeAnd = 206,
- kOpcodeEquals = 207,
- kOpcodeNotEquals = 208,
- kOpcodeLessThan = 209,
- kOpcodeGreaterThan = 210,
- kOpcodeLessThanOrEqualTo = 211,
- kOpcodeGreaterThanOrEqualTo = 212,
- kOpcodeAdd = 213,
- kOpcodeSubtract = 214,
- kOpcodeMultiply = 215,
- kOpcodeDivide = 216,
- kOpcodeModulo = 217,
- kOpcodeNegate = 218,
- kOpcodeCallFunction = 219,
- kOpcodeCallMethod = 220,
- kOpcodeDeclareLocals = 221,
- kOpcodeReturn = 222,
- kOpcodeReturnNoValue = 223,
- kOpcodeWhile = 224,
- kOpcodeCallFunctionInVariable = 225, // IndirectCall
- kOpcodeCallMethodInVariable = 226 // IndirectMsg
+ kOpcodeIf = 0xC9,
+ kOpcodeIfElse = 0xCA,
+ kOpcodeAssignVariable = 0xCB,
+ kOpcodeOr = 0xCC,
+ kOpcodeXor = 0xCD,
+ kOpcodeAnd = 0xCE,
+ kOpcodeEquals = 0xCF,
+ kOpcodeNotEquals = 0xD0,
+ kOpcodeLessThan = 0xD1,
+ kOpcodeGreaterThan = 0xD2,
+ kOpcodeLessThanOrEqualTo = 0xD3,
+ kOpcodeGreaterThanOrEqualTo = 0xD4,
+ kOpcodeAdd = 0xD5,
+ kOpcodeSubtract = 0xD6,
+ kOpcodeMultiply = 0xD7,
+ kOpcodeDivide = 0xD8,
+ kOpcodeModulo = 0xD9,
+ kOpcodeNegate = 0xDA,
+ kOpcodeCallFunction = 0xDB,
+ kOpcodeCallMethod = 0xDC,
+ kOpcodeDeclareLocals = 0xDD,
+ kOpcodeReturn = 0xDE,
+ kOpcodeReturnNoValue = 0xDF,
+ kOpcodeWhile = 0xE0,
+ kOpcodeCallFunctionInVariable = 0xE1, // IndirectCall
+ kOpcodeCallMethodInVariable = 0xE2 // IndirectMsg
};
const char *opcodeToStr(Opcode opcode);
enum VariableScope {
- kVariableScopeLocal = 1,
- kVariableScopeParameter = 2,
- kVariableScopeIndirectParameter = 3,
- kVariableScopeGlobal = 4
+ kVariableScopeLocal = 0x1,
+ kVariableScopeParameter = 0x2,
+ kVariableScopeIndirectParameter = 0x3,
+ kVariableScopeGlobal = 0x4
};
const char *variableScopeToStr(VariableScope scope);
enum BuiltInFunction {
- kUnk1Function = 10,
+ kUnk1Function = 0xA,
// TODO: Figure out if effectTransitionOnSync = 13 is consistent across titles?
- kEffectTransitionFunction = 12, // PARAMS: 1
- kEffectTransitionOnSyncFunction = 13,
- kDrawingFunction = 37, // PARAMS: 5
+ kEffectTransitionFunction = 0xC,
+ kEffectTransitionOnSyncFunction = 0xD,
+ kDrawingFunction = 0x25,
// TODO: Figure out if TimeOfDay = 101 is consistent across titles.
- kDebugPrintFunction = 180, // PARAMS: 1+
+ kDebugPrintFunction = 0xB4,
// TODO: Figure out code for DebugPrint.
// TODO: Figure out code for Quit.
};
@@ -88,177 +88,177 @@ enum BuiltInMethod {
// TODO: What object types does CursorSet apply to?
// Currently it's only in var_7be1_cursor_currentTool in
// IBM/Crayola.
- kCursorSetMethod = 200, // PARAMS: 0
+ kCursorSetMethod = 0xC8,
// SPATIAL ENTITY METHODS.
- kSpatialHideMethod = 203, // PARAMS: 1
- kSpatialMoveToMethod = 204, // PARAMS: 2
- kSpatialMoveToByOffsetMethod = 205, // PARAMS: 2
- kSpatialZMoveToMethod = 216, // PARAMS: 1
- kSpatialShowMethod = 202, // PARAMS: 1
- kTimePlayMethod = 206, // PARAMS: 1
- kTimeStopMethod = 207, // PARAMS: 0
- kIsPlayingMethod = 372, // PARAMS: 0
- kSetDissolveFactorMethod = 241, // PARAMS: 1
- kSpatialCenterMoveToMethod = 230,
- kGetLeftXMethod = 233,
- kGetTopYMethod = 234,
- kGetWidthMethod = 235, // PARAMS: 0
- kGetHeightMethod = 236, // PARAMS: 0
- kGetCenterXMethod = 237,
- kGetCenterYMethod = 238,
- kGetZCoordinateMethod = 239,
- kIsPointInsideMethod = 246,
- kGetMouseXOffsetMethod = 264,
- kGetMouseYOffsetMethod = 265,
- kIsVisibleMethod = 269,
+ kSpatialHideMethod = 0xCB,
+ kSpatialMoveToMethod = 0xCC,
+ kSpatialMoveToByOffsetMethod = 0xCD,
+ kSpatialZMoveToMethod = 0xD8,
+ kSpatialShowMethod = 0xCA,
+ kTimePlayMethod = 0xCE,
+ kTimeStopMethod = 0xCF,
+ kIsPlayingMethod = 0x174,
+ kSetDissolveFactorMethod = 0xF1,
+ kSpatialCenterMoveToMethod = 0xE6,
+ kGetLeftXMethod = 0xE9,
+ kGetTopYMethod = 0xEA,
+ kGetWidthMethod = 0xEB,
+ kGetHeightMethod = 0xEC,
+ kGetCenterXMethod = 0xED,
+ kGetCenterYMethod = 0xEE,
+ kGetZCoordinateMethod = 0xEF,
+ kIsPointInsideMethod = 0xF6,
+ kGetMouseXOffsetMethod = 0x108,
+ kGetMouseYOffsetMethod = 0x109,
+ kIsVisibleMethod = 0x10D,
// HOTSPOT METHODS.
- kMouseActivateMethod = 210, // PARAMS: 1
- kMouseDeactivateMethod = 211, // PARAMS: 0
- kTriggerAbsXPositionMethod = 321, // PARAMS: 0
- kTriggerAbsYPositionMethod = 322, // PARAMS: 0
- kIsActiveMethod = 371, // PARAMS: 0
+ kMouseActivateMethod = 0xD2,
+ kMouseDeactivateMethod = 0xD3,
+ kTriggerAbsXPositionMethod = 0x141,
+ kTriggerAbsYPositionMethod = 0x142,
+ kIsActiveMethod = 0x173,
// SPRITE METHODS.
- kMovieResetMethod = 219, // PARAMS: 0
- kSetCurrentClipMethod = 220, // PARAMS: 1
- kIncrementFrameMethod = 221, // PARAMS: 0-1
- kDecrementFrameMethod = 222, // PARAMS: 0-1
- kGetCurrentClipIdMethod = 240, // PARAMS: 0
+ kMovieResetMethod = 0xDB,
+ kSetCurrentClipMethod = 0xDC,
+ kIncrementFrameMethod = 0xDD,
+ kDecrementFrameMethod = 0xDE,
+ kGetCurrentClipIdMethod = 0xF0,
// STAGE METHODS.
- kSetWorldSpaceExtentMethod = 363, // PARAMS: 2
- kSetBoundsMethod = 287, // PARAMS: 4
+ kSetWorldSpaceExtentMethod = 0x16B,
+ kSetBoundsMethod = 0x11F,
// CAMERA METHODS.
- kStopPanMethod = 350, // PARAMS: 0
- kViewportMoveToMethod = 352, // PARAMS: 2
- kYViewportPositionMethod = 357, // PARAMS: 0
- kPanToMethod = 370, // PARAMS: 4
+ kStopPanMethod = 0x15E,
+ kViewportMoveToMethod = 0x160,
+ kYViewportPositionMethod = 0x165,
+ kPanToMethod = 0x172,
// CANVAS METHODS.
- kClearToPaletteMethod = 379, // PARAMS: 1
+ kClearToPaletteMethod = 0x17B,
// DOCUMENT METHODS.
- kLoadContextMethod = 374, // PARAMS: 1
- kReleaseContextMethod = 375, // PARAMS: 1
- kBranchToScreenMethod = 201, // PARAMS: 1
- kIsLoadedMethod = 376, // PARAMS: 1
+ kLoadContextMethod = 0x176,
+ kReleaseContextMethod = 0x177,
+ kBranchToScreenMethod = 0xC9,
+ kIsLoadedMethod = 0x178,
// PATH METHODS.
- kSetDurationMethod = 262, // PARAMS: 1
- kPercentCompleteMethod = 263,
+ kSetDurationMethod = 0x106,
+ kPercentCompleteMethod = 0x107,
// TEXT METHODS.
- kTextMethod = 290,
- kSetTextMethod = 291,
- kSetMaximumTextLengthMethod = 293, // PARAM: 1
+ kTextMethod = 0x122,
+ kSetTextMethod = 0x123,
+ kSetMaximumTextLengthMethod = 0x125,
// COLLECTION METHODS.
// These are arrays used in Media Script.
- kAppendMethod = 247, // PARAMS: 1+
- kApplyMethod = 248, // PARAMS: 1+
- kCountMethod = 249, // PARAMS: 0
- kDeleteFirstMethod = 250, // PARAMS: 0
- kDeleteLastMethod = 251, // PARAMS: 0
- kEmptyMethod = 252, // PARAMS: 0
- kGetAtMethod = 253, // PARAMS: 1
- kIsEmptyMethod = 254, // PARAMS: 0
- kJumbleMethod = 255, // PARAMS: 0
- kSeekMethod = 256, // PARAMS: 1
- kSendMethod = 257, // PARAMS: 1+
- kDeleteAtMethod = 258, // PARAMS: 1
- kInsertAtMethod = 259, // PARAMS: 2
- kReplaceAtMethod = 260, // PARAMS: 2
- kPrependListMethod = 261, // PARAMS: 1+
- kSortMethod = 266, // PARAMS: 0
+ kAppendMethod = 0xF7,
+ kApplyMethod = 0xF8,
+ kCountMethod = 0xF9,
+ kDeleteFirstMethod = 0xFA,
+ kDeleteLastMethod = 0xFB,
+ kEmptyMethod = 0xFC,
+ kGetAtMethod = 0xFD,
+ kIsEmptyMethod = 0xFE,
+ kJumbleMethod = 0xFF,
+ kSeekMethod = 0x100,
+ kSendMethod = 0x101,
+ kDeleteAtMethod = 0x102,
+ kInsertAtMethod = 0x103,
+ kReplaceAtMethod = 0x104,
+ kPrependListMethod = 0x105,
+ kSortMethod = 0x10A,
// PRINTER METHODS.
- kOpenLensMethod = 346, // PARAMS: 0
- kCloseLensMethod = 347, // PARAMS: 0
+ kOpenLensMethod = 0x15A,
+ kCloseLensMethod = 0x15B,
};
const char *builtInMethodToStr(BuiltInMethod method);
enum EventType {
// TIMER EVENTS.
- kTimerEvent = 5,
+ kTimerEvent = 0x5,
// HOTSPOT EVENTS.
- kMouseDownEvent = 6,
- kMouseUpEvent = 7,
- kMouseMovedEvent = 8,
- kMouseEnteredEvent = 9,
- kMouseExitedEvent = 10,
- kKeyDownEvent = 13, // PARAMS: 1 - ASCII code.
+ kMouseDownEvent = 0x6,
+ kMouseUpEvent = 0x7,
+ kMouseMovedEvent = 0x8,
+ kMouseEnteredEvent = 0x9,
+ kMouseExitedEvent = 0xA,
+ kKeyDownEvent = 0xD,
// SOUND EVENTS.
- kSoundEndEvent = 14,
- kSoundAbortEvent = 19,
- kSoundFailureEvent = 20,
- kSoundStoppedEvent = 29,
- kSoundBeginEvent = 30,
+ kSoundEndEvent = 0xE,
+ kSoundAbortEvent = 0x13,
+ kSoundFailureEvent = 0x14,
+ kSoundStoppedEvent = 0x1D,
+ kSoundBeginEvent = 0x1E,
// MOVIE EVENTS.
- kMovieEndEvent = 15,
- kMovieAbortEvent = 21,
- kMovieFailureEvent = 22,
- kMovieStoppedEvent = 31,
- kMovieBeginEvent = 32,
+ kMovieEndEvent = 0xF,
+ kMovieAbortEvent = 0x15,
+ kMovieFailureEvent = 0x16,
+ kMovieStoppedEvent = 0x1F,
+ kMovieBeginEvent = 0x20,
// SPRITE EVENTS.
// Just "MovieEnd" in source.
- kSpriteMovieEndEvent = 23,
+ kSpriteMovieEndEvent = 0x17,
// SCREEN EVENTS.
- kEntryEvent = 17,
- kExitEvent = 27,
+ kEntryEvent = 0x11,
+ kExitEvent = 0x1B,
// CONTEXT EVENTS.
- kLoadCompleteEvent = 44, // PARAMS: 1 - Context ID
+ kLoadCompleteEvent = 0x2C,
// TEXT EVENTS.
- kInputEvent = 37,
- kErrorEvent = 38,
+ kInputEvent = 0x25,
+ kErrorEvent = 0x26,
// CAMERA EVENTS.
- kPanAbortEvent = 43,
- kPanEndEvent = 42,
+ kPanAbortEvent = 0x2B,
+ kPanEndEvent = 0x2A,
// PATH EVENTS.
- kStepEvent = 28,
- kPathStoppedEvent = 33,
- kPathEndEvent = 16
+ kStepEvent = 0x1C,
+ kPathStoppedEvent = 0x21,
+ kPathEndEvent = 0x10
};
const char *eventTypeToStr(EventType type);
enum OperandType {
- kOperandTypeEmpty = 0,
- kOperandTypeBool = 151,
- kOperandTypeFloat = 152,
- kOperandTypeInt = 153,
- kOperandTypeString = 154,
- kOperandTypeParamToken = 155,
- kOperandTypeActorId = 156,
- kOperandTypeTime = 157,
- kOperandTypeVariable = 158,
- kOperandTypeFunctionId = 159,
- kOperandTypeMethodId = 160,
- kOperandTypeCollection = 161
+ kOperandTypeEmpty = 0x0,
+ kOperandTypeBool = 0x97,
+ kOperandTypeFloat = 0x98,
+ kOperandTypeInt = 0x99,
+ kOperandTypeString = 0x9A,
+ kOperandTypeParamToken = 0x9B,
+ kOperandTypeActorId = 0x9C,
+ kOperandTypeTime = 0x9D,
+ kOperandTypeVariable = 0x9E,
+ kOperandTypeFunctionId = 0x9F,
+ kOperandTypeMethodId = 0xA0,
+ kOperandTypeCollection = 0xA1
};
const char *operandTypeToStr(OperandType type);
enum ScriptValueType {
- kScriptValueTypeEmpty = 0,
- kScriptValueTypeFloat = 1,
- kScriptValueTypeBool = 2,
- kScriptValueTypeTime = 3,
- kScriptValueTypeParamToken = 4,
- kScriptValueTypeActorId = 5,
- kScriptValueTypeString = 6,
- kScriptValueTypeCollection = 7,
- kScriptValueTypeFunctionId = 8,
- kScriptValueTypeMethodId = 9
+ kScriptValueTypeEmpty = 0x0,
+ kScriptValueTypeFloat = 0x1,
+ kScriptValueTypeBool = 0x2,
+ kScriptValueTypeTime = 0x3,
+ kScriptValueTypeParamToken = 0x4,
+ kScriptValueTypeActorId = 0x5,
+ kScriptValueTypeString = 0x6,
+ kScriptValueTypeCollection = 0x7,
+ kScriptValueTypeFunctionId = 0x8,
+ kScriptValueTypeMethodId = 0x9
};
const char *scriptValueTypeToStr(ScriptValueType type);
Commit: fe63ca5dc36d5db2d0e226bb2cf528601dfc75dd
https://github.com/scummvm/scummvm/commit/fe63ca5dc36d5db2d0e226bb2cf528601dfc75dd
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Modularize stream loading, as in the original
Changed paths:
A engines/mediastation/clients.cpp
A engines/mediastation/clients.h
engines/mediastation/actor.h
engines/mediastation/actors/screen.cpp
engines/mediastation/boot.cpp
engines/mediastation/boot.h
engines/mediastation/context.cpp
engines/mediastation/context.h
engines/mediastation/cursors.cpp
engines/mediastation/cursors.h
engines/mediastation/datafile.h
engines/mediastation/graphics.cpp
engines/mediastation/graphics.h
engines/mediastation/mediascript/codechunk.cpp
engines/mediastation/mediascript/function.cpp
engines/mediastation/mediascript/function.h
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
engines/mediastation/module.mk
diff --git a/engines/mediastation/actor.h b/engines/mediastation/actor.h
index 80ab9a30597..5ad3a64ed2c 100644
--- a/engines/mediastation/actor.h
+++ b/engines/mediastation/actor.h
@@ -134,6 +134,7 @@ public:
virtual void initFromParameterStream(Chunk &chunk);
virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType);
+ virtual void loadIsComplete() { _loadIsComplete = true; };
// These are not pure virtual so if an actor doesnʻt read any chunks or
// subfiles it doesnʻt need to just implement these with an error message.
@@ -155,6 +156,7 @@ public:
protected:
ActorType _type = kActorTypeEmpty;
+ bool _loadIsComplete = false;
uint _id = 0;
uint _contextId = 0;
diff --git a/engines/mediastation/actors/screen.cpp b/engines/mediastation/actors/screen.cpp
index ff2b64c8269..73347fd449a 100644
--- a/engines/mediastation/actors/screen.cpp
+++ b/engines/mediastation/actors/screen.cpp
@@ -21,6 +21,7 @@
#include "mediastation/actors/screen.h"
#include "mediastation/debugchannels.h"
+#include "mediastation/mediastation.h"
namespace MediaStation {
@@ -28,6 +29,9 @@ void ScreenActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType)
switch (paramType) {
case kActorHeaderCursorResourceId:
_cursorResourceId = chunk.readTypedUint16();
+ if (_cursorResourceId != 0) {
+ g_engine->getCursorManager()->registerAsPermanent(_cursorResourceId);
+ }
break;
default:
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index db960248cdf..3cd7d613606 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -21,6 +21,7 @@
#include "mediastation/boot.h"
#include "mediastation/debugchannels.h"
+#include "mediastation/mediastation.h"
namespace MediaStation {
@@ -158,152 +159,130 @@ Boot::Boot(const Common::Path &path) : Datafile(path) {
Subfile subfile = getNextSubfile();
Chunk chunk = subfile.nextChunk();
- uint32 beforeSectionTypeUnk = chunk.readTypedUint16(); // Usually 0x0001
- debugC(5, kDebugLoading, "Boot::Boot(): unk1 = 0x%x", beforeSectionTypeUnk);
-
- BootSectionType sectionType = getSectionType(chunk);
- bool notLastSection = (kBootLastSection != sectionType);
- while (notLastSection) {
- debugC(5, kDebugLoading, "Boot::Boot(): sectionType = 0x%x", static_cast<uint>(sectionType));
- switch (sectionType) {
- case kBootVersionInformation: {
- _gameTitle = chunk.readTypedString();
- debugC(5, kDebugLoading, " - gameTitle = %s", _gameTitle.c_str());
- _versionInfo = chunk.readTypedVersion();
- _engineInfo = chunk.readTypedString();
- debugC(5, kDebugLoading, " - versionInfo = %d.%d.%d (%s)",
- _versionInfo.major, _versionInfo.minor, _versionInfo.patch, _engineInfo.c_str());
- _sourceString = chunk.readTypedString();
- debugC(5, kDebugLoading, " - sourceString = %s", _sourceString.c_str());
+ // TODO: This is really analogous to RT_ImtGod::notifyBufferFilled.
+ // But we are currently only handling the DocumentDef part of it.
+ BootStreamType streamType = static_cast<BootStreamType>(chunk.readTypedUint16());
+ switch (streamType) {
+ case kBootDocumentDef:
+ readDocumentDef(chunk);
break;
- }
- case kBootUnk1:
- case kBootUnk2:
- case kBootUnk3: {
- uint unk = chunk.readTypedUint16();
- debugC(5, kDebugLoading, " - unk = 0x%x", unk);
+ case kBootControlCommands:
+ error("%s: STUB: readControlComments", __func__);
break;
- }
- case kBootUnk4: {
- double unk = chunk.readTypedTime();
- debugC(5, kDebugLoading, " - unk = %f", unk);
- break;
- }
+ default:
+ error("%s: Unhandled section type 0x%x", __func__, static_cast<uint>(streamType));
+ }
+}
- case kBootEngineResource: {
- Common::String resourceName = chunk.readTypedString();
- sectionType = getSectionType(chunk);
- if (sectionType == kBootEngineResourceId) {
- int resourceId = chunk.readTypedUint16();
- EngineResourceDeclaration resourceDeclaration = EngineResourceDeclaration(resourceName, resourceId);
- _engineResourceDeclarations.setVal(resourceId, resourceDeclaration);
- } else {
- error("%s: Got section type 0x%x when expecting ENGINE_RESOURCE_ID", __func__, static_cast<uint>(sectionType));
- }
- break;
- }
+BootSectionType Boot::getSectionType(Chunk &chunk) {
+ return static_cast<BootSectionType>(chunk.readTypedUint16());
+}
- case kBootContextDeclaration: {
- uint flag = chunk.readTypedUint16();
- while (flag != 0) {
- ContextDeclaration contextDeclaration = ContextDeclaration(chunk);
- _contextDeclarations.setVal(contextDeclaration._contextId, contextDeclaration);
- flag = chunk.readTypedUint16();
- }
- break;
- }
+Boot::~Boot() {
+ _contextDeclarations.clear();
+ _subfileDeclarations.clear();
+ _engineResourceDeclarations.clear();
+ _screenDeclarations.clear();
+ _fileDeclarations.clear();
+}
- case kBootScreenDeclaration: {
- uint flag = chunk.readTypedUint16();
- while (flag != 0) {
- ScreenDeclaration screenDeclaration = ScreenDeclaration(chunk);
- _screenDeclarations.setVal(screenDeclaration._actorId, screenDeclaration);
- flag = chunk.readTypedUint16();
- }
+void Boot::readDocumentDef(Chunk &chunk) {
+ BootSectionType sectionType = kBootLastSection;
+ while (true) {
+ sectionType = getSectionType(chunk);
+ if (sectionType == kBootLastSection) {
break;
}
+ readDocumentInfoFromStream(chunk, sectionType);
+ }
+}
- case kBootFileDeclaration: {
- uint flag = chunk.readTypedUint16();
- while (flag != 0) {
- FileDeclaration fileDeclaration = FileDeclaration(chunk);
- _fileDeclarations.setVal(fileDeclaration._id, fileDeclaration);
- flag = chunk.readTypedUint16();
- };
- break;
- }
+void Boot::readDocumentInfoFromStream(Chunk &chunk, BootSectionType sectionType) {
+ switch (sectionType) {
+ case kBootVersionInformation:
+ readVersionInfoFromStream(chunk);
+ break;
- case kBootSubfileDeclaration: {
- uint flag = chunk.readTypedUint16();
- while (flag != 0) {
- SubfileDeclaration subfileDeclaration = SubfileDeclaration(chunk);
- _subfileDeclarations.setVal(subfileDeclaration._actorId, subfileDeclaration);
- flag = chunk.readTypedUint16();
- }
- break;
- }
+ case kBootContextDeclaration:
+ readContextReferencesFromStream(chunk);
+ break;
- case kBootCursorDeclaration: {
- CursorDeclaration cursorDeclaration = CursorDeclaration(chunk);
- _cursorDeclarations.setVal(cursorDeclaration._id, cursorDeclaration);
- break;
- }
+ case kBootScreenDeclaration:
+ readScreenDeclarationsFromStream(chunk);
+ break;
- case kBootEmptySection: {
- // This semems to separate the cursor declarations from whatever comes
- // after it (what I formerly called the "footer"), but it has no data
- // itself.
- break;
- }
+ case kBootFileDeclaration:
+ readAndAddFileMaps(chunk);
+ break;
- case kBootEntryScreen: {
- _entryContextId = chunk.readTypedUint16();
- debugC(5, kDebugLoading, " - _entryContextId = %d", _entryContextId);
- break;
- }
+ case kBootSubfileDeclaration:
+ readAndAddStreamMaps(chunk);
+ break;
- case kBootAllowMultipleSounds: {
- _allowMultipleSounds = (chunk.readTypedByte() == 1);
- debugC(5, kDebugLoading, " - _allowMultipleSounds = %d", _allowMultipleSounds);
- break;
- }
+ case kBootUnk1:
+ _unk1 = chunk.readTypedUint16();
+ break;
- case kBootAllowMultipleStreams: {
- _allowMultipleStreams = (chunk.readTypedByte() == 1);
- debugC(5, kDebugLoading, " - _allowMultipleStreams = %d", _allowMultipleStreams);
- break;
- }
+ case kBootFunctionTableSize:
+ _functionTableSize = chunk.readTypedUint16();
+ break;
- case kBootUnk5: {
- uint32 unk1 = chunk.readTypedUint16();
- uint32 unk2 = chunk.readTypedUint16();
- debugC(5, kDebugLoading, " - unk1 = 0x%x, unk2 = 0x%x", unk1, unk2);
- break;
- }
+ case kBootUnk3:
+ _unk3 = chunk.readTypedUint16();
+ break;
- default:
- warning("%s: Unknown section type %d", __func__, static_cast<uint>(sectionType));
- }
+ default:
+ // See if any registered parameter clients know how to
+ // handle this parameter.
+ g_engine->readUnrecognizedFromStream(chunk, static_cast<uint>(sectionType));
+ }
+}
- sectionType = getSectionType(chunk);
- notLastSection = kBootLastSection != sectionType;
+void Boot::readVersionInfoFromStream(Chunk &chunk) {
+ _gameTitle = chunk.readTypedString();
+ _versionInfo = chunk.readTypedVersion();
+ _engineInfo = chunk.readTypedString();
+ _sourceString = chunk.readTypedString();
+}
+
+void Boot::readContextReferencesFromStream(Chunk &chunk) {
+ uint flag = chunk.readTypedUint16();
+ while (flag != 0) {
+ ContextDeclaration contextDeclaration(chunk);
+ _contextDeclarations.setVal(contextDeclaration._contextId, contextDeclaration);
+ flag = chunk.readTypedUint16();
}
}
-BootSectionType Boot::getSectionType(Chunk &chunk) {
- return static_cast<BootSectionType>(chunk.readTypedUint16());
+void Boot::readScreenDeclarationsFromStream(Chunk &chunk) {
+ uint flag = chunk.readTypedUint16();
+ while (flag != 0) {
+ ScreenDeclaration screenDeclaration(chunk);
+ _screenDeclarations.setVal(screenDeclaration._screenId, screenDeclaration);
+ flag = chunk.readTypedUint16();
+ }
}
-Boot::~Boot() {
- _contextDeclarations.clear();
- _subfileDeclarations.clear();
- _cursorDeclarations.clear();
- _engineResourceDeclarations.clear();
- _screenDeclarations.clear();
- _fileDeclarations.clear();
+void Boot::readAndAddFileMaps(Chunk &chunk) {
+ uint flag = chunk.readTypedUint16();
+ while (flag != 0) {
+ FileDeclaration fileDeclaration(chunk);
+ _fileDeclarations.setVal(fileDeclaration._id, fileDeclaration);
+ flag = chunk.readTypedUint16();
+ }
}
+
+void Boot::readAndAddStreamMaps(Chunk &chunk) {
+ uint flag = chunk.readTypedUint16();
+ while (flag != 0) {
+ SubfileDeclaration subfileDeclaration(chunk);
+ _subfileDeclarations.setVal(subfileDeclaration._actorId, subfileDeclaration);
+ flag = chunk.readTypedUint16();
+ }
+}
+
#pragma endregion
} // End of namespace MediaStation
diff --git a/engines/mediastation/boot.h b/engines/mediastation/boot.h
index d7bd1215ce7..5bc8779d6e3 100644
--- a/engines/mediastation/boot.h
+++ b/engines/mediastation/boot.h
@@ -32,7 +32,6 @@
namespace MediaStation {
enum ContextDeclarationSectionType {
- kContextDeclarationEmptySection = 0x0000,
kContextDeclarationPlaceholder = 0x0003,
kContextDeclarationContextId = 0x0004,
kContextDeclarationStreamId = 0x0005,
@@ -55,7 +54,6 @@ private:
};
enum ScreenDeclarationSectionType {
- kScreenDeclarationEmpty = 0x0000,
kScreenDeclarationActorId = 0x0009,
kScreenDeclarationScreenId = 0x0004
};
@@ -144,25 +142,23 @@ public:
int _id = 0;
};
+enum BootStreamType {
+ kBootDocumentDef = 0x01,
+ kBootControlCommands = 0x0d,
+};
+
enum BootSectionType {
kBootLastSection = 0x0000,
- kBootEmptySection = 0x002e,
kBootContextDeclaration = 0x0002,
kBootVersionInformation = 0x0190,
kBootUnk1 = 0x0191,
- kBootUnk2 = 0x0192,
+ kBootFunctionTableSize = 0x0192,
kBootUnk3 = 0x0193,
kBootEngineResource = 0x0bba,
kBootEngineResourceId = 0x0bbb,
kBootScreenDeclaration = 0x0007,
kBootFileDeclaration = 0x000a,
kBootSubfileDeclaration = 0x000b,
- kBootUnk5 = 0x000c,
- kBootCursorDeclaration = 0x0015,
- kBootEntryScreen = 0x002f,
- kBootAllowMultipleSounds = 0x0035,
- kBootAllowMultipleStreams = 0x0036,
- kBootUnk4 = 0x057b
};
class Boot : Datafile {
@@ -178,12 +174,20 @@ public:
Common::HashMap<uint32, ScreenDeclaration> _screenDeclarations;
Common::HashMap<uint32, FileDeclaration> _fileDeclarations;
Common::HashMap<uint32, SubfileDeclaration> _subfileDeclarations;
- Common::HashMap<uint32, CursorDeclaration> _cursorDeclarations;
Common::HashMap<uint32, EngineResourceDeclaration> _engineResourceDeclarations;
-
- uint32 _entryContextId = 0;
- bool _allowMultipleSounds = false;
- bool _allowMultipleStreams = false;
+ uint _unk1 = 0;
+ uint _functionTableSize = 0;
+ uint _unk3 = 0;
+
+ void readDocumentDef(Chunk &chunk);
+ void readDocumentInfoFromStream(Chunk &chunk, BootSectionType sectionType);
+ void readVersionInfoFromStream(Chunk &chunk);
+ void readContextReferencesFromStream(Chunk &chunk);
+ void readScreenDeclarationsFromStream(Chunk &chunk);
+ void readAndAddFileMaps(Chunk &chunk);
+ void readAndAddStreamMaps(Chunk &chunk);
+
+ void readStartupInformation(Chunk &chunk);
Boot(const Common::Path &path);
~Boot();
diff --git a/engines/mediastation/clients.cpp b/engines/mediastation/clients.cpp
new file mode 100644
index 00000000000..5c4afdba8d6
--- /dev/null
+++ b/engines/mediastation/clients.cpp
@@ -0,0 +1,76 @@
+/* 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/clients.h"
+
+namespace MediaStation {
+
+bool DeviceOwner::attemptToReadFromStream(Chunk &chunk, uint sectionType) {
+ bool handledParam = true;
+ switch (sectionType) {
+ case kDeviceOwnerAllowMultipleSounds:
+ _allowMultipleSounds = chunk.readTypedByte();
+ break;
+
+ case kDeviceOwnerAllowMultipleStreams:
+ _allowMultipleStreams = chunk.readTypedByte();
+ break;
+
+ default:
+ handledParam = false;
+ }
+
+ return handledParam;
+}
+
+void Document::readStartupInformation(Chunk &chunk) {
+ DocumentSectionType sectionType = static_cast<DocumentSectionType>(chunk.readTypedUint16());
+ switch (sectionType) {
+ case kDocumentEntryScreen:
+ _entryScreenId = chunk.readTypedUint16();
+ break;
+
+ default:
+ error("%s: Unhandled section type 0x%x", __func__, static_cast<uint>(sectionType));
+ }
+}
+
+bool Document::attemptToReadFromStream(Chunk &chunk, uint sectionType) {
+ bool handledParam = true;
+ switch (sectionType) {
+ case kDocumentContextLoadComplete: {
+ uint contextId = chunk.readTypedUint16();
+ warning("STUB: readContextLoadCompleteFromStream %d", contextId);
+ break;
+ }
+
+ case kDocumentStartupInformation:
+ readStartupInformation(chunk);
+ break;
+
+ default:
+ handledParam = false;
+ }
+
+ return handledParam;
+}
+
+} // End of namespace MediaStation
diff --git a/engines/mediastation/clients.h b/engines/mediastation/clients.h
new file mode 100644
index 00000000000..be2fb728e0a
--- /dev/null
+++ b/engines/mediastation/clients.h
@@ -0,0 +1,66 @@
+/* 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_CLIENTS_H
+#define MEDIASTATION_CLIENTS_H
+
+#include "mediastation/datafile.h"
+
+namespace MediaStation {
+
+class ParameterClient {
+public:
+ ParameterClient() {};
+ virtual ~ParameterClient() {};
+
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) = 0;
+};
+
+enum DeviceOwnerSectionType {
+ kDeviceOwnerAllowMultipleSounds = 0x35,
+ kDeviceOwnerAllowMultipleStreams = 0x36,
+};
+
+class DeviceOwner : public ParameterClient {
+public:
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
+
+ bool _allowMultipleSounds = false;
+ bool _allowMultipleStreams = false;
+};
+
+enum DocumentSectionType {
+ kDocumentContextLoadComplete = 0x10,
+ kDocumentStartupInformation = 0x2e,
+ kDocumentEntryScreen = 0x2f,
+};
+
+class Document : public ParameterClient {
+public:
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
+ void readStartupInformation(Chunk &chunk);
+
+ uint _entryScreenId = 0;
+};
+
+} // End of namespace MediaStation
+
+#endif
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index 7b3dca6c8b9..b6c1ec671c5 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -25,6 +25,7 @@
#include "mediastation/bitmap.h"
#include "mediastation/mediascript/collection.h"
+#include "mediastation/mediascript/function.h"
#include "mediastation/actors/canvas.h"
#include "mediastation/actors/palette.h"
#include "mediastation/actors/image.h"
@@ -51,22 +52,10 @@ Context::Context(const Common::Path &path) : Datafile(path) {
_fileSize = _handle->readUint32LE();
debugC(5, kDebugLoading, "Context::Context(): _unk1 = 0x%x", _unk1);
+ // Read headers and actors in the first subfile.
Subfile subfile = getNextSubfile();
Chunk chunk = subfile.nextChunk();
-
- if (g_engine->isFirstGenerationEngine()) {
- readOldStyleHeaderSections(subfile, chunk);
- } else {
- readNewStyleHeaderSections(subfile, chunk);
- }
-
- chunk = subfile._currentChunk;
- while (!subfile.atEnd()) {
- readActorInFirstSubfile(chunk);
- if (!subfile.atEnd()) {
- chunk = subfile.nextChunk();
- }
- }
+ readHeaderSections(subfile, chunk);
// Read actors in the rest of the subfiles.
for (uint i = 1; i < _subfileCount; i++) {
@@ -111,9 +100,6 @@ Context::Context(const Common::Path &path) : Datafile(path) {
}
Context::~Context() {
- delete _palette;
- _palette = nullptr;
-
for (auto it = _actors.begin(); it != _actors.end(); ++it) {
delete it->_value;
}
@@ -121,11 +107,6 @@ Context::~Context() {
// The same actor pointers are in here, so don't delete again.
_actorsByChunkReference.clear();
- for (auto it = _functions.begin(); it != _functions.end(); ++it) {
- delete it->_value;
- }
- _functions.clear();
-
for (auto it = _variables.begin(); it != _variables.end(); ++it) {
delete it->_value;
}
@@ -140,60 +121,46 @@ Actor *Context::getActorByChunkReference(uint chunkReference) {
return _actorsByChunkReference.getValOrDefault(chunkReference);
}
-ScriptFunction *Context::getFunctionById(uint functionId) {
- return _functions.getValOrDefault(functionId);
-}
-
ScriptValue *Context::getVariable(uint variableId) {
return _variables.getValOrDefault(variableId);
}
-void Context::readCreateContextData(Chunk &chunk) {
- _fileNumber = chunk.readTypedUint16();
-
- ContextParametersSectionType sectionType = static_cast<ContextParametersSectionType>(chunk.readTypedUint16());
- while (sectionType != kContextParametersEmptySection) {
- debugC(5, kDebugLoading, "ContextParameters::ContextParameters: sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
- switch (sectionType) {
- case kContextParametersName: {
- uint repeatedFileNumber = chunk.readTypedUint16();
- if (repeatedFileNumber != _fileNumber) {
- warning("%s: Repeated file number didn't match: %d != %d", __func__, repeatedFileNumber, _fileNumber);
- }
- _contextName = chunk.readTypedString();
-
- uint endingFlag = chunk.readTypedUint16();
- if (endingFlag != 0) {
- warning("%s: Got non-zero ending flag 0x%x", __func__, endingFlag);
- }
- break;
- }
-
- case kContextParametersFileNumber: {
- error("%s: Section type FILE_NUMBER not implemented yet", __func__);
- break;
+void Context::readControlCommands(Chunk &chunk) {
+ ContextSectionType command = kEndOfContextData;
+ do {
+ command = static_cast<ContextSectionType>(chunk.readTypedUint16());
+ if (command != kEndOfContextData) {
+ readCommandFromStream(command, chunk);
}
+ } while (command != kEndOfContextData);
+}
- case kContextParametersVariable: {
- readCreateVariableData(chunk);
- break;
- }
+void Context::readCreateContextData(Chunk &chunk) {
+ // The original had contexts created from the base engine class,
+ // but things are currently structured a bit differently, so this
+ // is a no-op for now.
+ _fileNumber = chunk.readTypedUint16();
+}
- case kContextParametersBytecode: {
- ScriptFunction *function = new ScriptFunction(chunk);
- _functions.setVal(function->_id, function);
- break;
- }
+void Context::readDestroyContextData(Chunk &chunk) {
+ uint contextId = chunk.readTypedUint16();
+ g_engine->releaseContext(contextId);
+}
- default:
- error("%s: Unknown section type 0x%x", __func__, static_cast<uint>(sectionType));
- }
+void Context::readDestroyActorData(Chunk &chunk) {
+ uint actorId = chunk.readTypedUint16();
+ // TODO: This really can't be done until we have this reading be part of the
+ // engine class, as it was in the original.
+ warning("%s: STUB: destroyActor %d", __func__, actorId);
+}
- sectionType = static_cast<ContextParametersSectionType>(chunk.readTypedUint16());
- }
+void Context::readActorLoadComplete(Chunk &chunk) {
+ uint actorId = chunk.readTypedUint16();
+ Actor *actor = g_engine->getActorById(actorId);
+ actor->loadIsComplete();
}
-Actor *Context::readCreateActorData(Chunk &chunk) {
+void Context::readCreateActorData(Chunk &chunk) {
uint contextId = chunk.readTypedUint16();
ActorType type = static_cast<ActorType>(chunk.readTypedUint16());
uint id = chunk.readTypedUint16();
@@ -256,7 +223,23 @@ Actor *Context::readCreateActorData(Chunk &chunk) {
actor->setId(id);
actor->setContextId(contextId);
actor->initFromParameterStream(chunk);
- return actor;
+
+ _actors.setVal(actor->id(), actor);
+ g_engine->registerActor(actor);
+ if (actor->_chunkReference != 0) {
+ debugC(5, kDebugLoading, "Context::readHeaderSection(): Storing actor with chunk ID \"%s\" (0x%x)", tag2str(actor->_chunkReference), actor->_chunkReference);
+ _actorsByChunkReference.setVal(actor->_chunkReference, actor);
+ }
+
+ if (actor->type() == kActorTypeMovie) {
+ StreamMovieActor *movie = static_cast<StreamMovieActor *>(actor);
+ if (movie->_audioChunkReference != 0) {
+ _actorsByChunkReference.setVal(movie->_audioChunkReference, actor);
+ }
+ if (movie->_animationChunkReference != 0) {
+ _actorsByChunkReference.setVal(movie->_animationChunkReference, actor);
+ }
+ }
}
void Context::readCreateVariableData(Chunk &chunk) {
@@ -276,58 +259,36 @@ void Context::readCreateVariableData(Chunk &chunk) {
id, scriptValueTypeToStr(value->getType()));
}
-void Context::readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
- error("%s: Not implemented yet", __func__);
-}
-
-void Context::readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk) {
- bool moreSectionsToRead = (chunk._id == MKTAG('i', 'g', 'o', 'd'));
- if (!moreSectionsToRead) {
- warning("%s: Got no header sections (@0x%llx)", __func__, static_cast<long long int>(chunk.pos()));
- }
-
- while (moreSectionsToRead) {
- // Verify this chunk is a header.
- // TODO: What are the situations when it's not?
- uint16 sectionType = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Context::readNewStyleHeaderSections(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
- bool chunkIsHeader = (sectionType == 0x000d);
- if (!chunkIsHeader) {
- error("%s: Expected header chunk, got %s (@0x%llx)", __func__, tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
- }
+void Context::readHeaderSections(Subfile &subfile, Chunk &chunk) {
+ do {
+ if (chunk._id == MKTAG('i', 'g', 'o', 'd')) {
+ StreamType streamType = static_cast<StreamType>(chunk.readTypedUint16());
+ if (streamType != kControlCommandsStream) {
+ error("%s: Expected header chunk, got %s (@0x%llx)", __func__, tag2str(chunk._id), static_cast<long long int>(chunk.pos()));
+ }
- // Read this header section.
- moreSectionsToRead = readHeaderSection(chunk);
- if (subfile.atEnd()) {
- break;
+ readControlCommands(chunk);
} else {
- debugC(5, kDebugLoading, "\nContext::readNewStyleHeaderSections(): Getting next chunk (@0x%llx)", static_cast<long long int>(chunk.pos()));
- chunk = subfile.nextChunk();
- moreSectionsToRead = (chunk._id == MKTAG('i', 'g', 'o', 'd'));
+ Actor *actor = getActorByChunkReference(chunk._id);
+ if (actor == nullptr) {
+ // We should only need to look in the global scope when there is an
+ // install cache (INSTALL.CXT).
+ actor = g_engine->getActorByChunkReference(chunk._id);
+ if (actor == nullptr) {
+ error("%s: Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", __func__, tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ }
+ }
+ actor->readChunk(chunk);
}
- }
- debugC(5, kDebugLoading, "Context::readNewStyleHeaderSections(): Finished reading sections (@0x%llx)", static_cast<long long int>(chunk.pos()));
-}
-void Context::readActorInFirstSubfile(Chunk &chunk) {
- if (chunk._id == MKTAG('i', 'g', 'o', 'd')) {
- warning("%s: Skippping \"igod\" actor link chunk", __func__);
- chunk.skip(chunk.bytesRemaining());
- return;
- }
+ if (chunk.bytesRemaining() != 0) {
+ warning("%s: %d bytes remaining at end of chunk", __func__, chunk.bytesRemaining());
+ }
- // TODO: Make sure this is not an actor link.
- Actor *actor = getActorByChunkReference(chunk._id);
- if (actor == nullptr) {
- // We should only need to look in the global scope when there is an
- // install cache (INSTALL.CXT).
- actor = g_engine->getActorByChunkReference(chunk._id);
- if (actor == nullptr) {
- error("%s: Actor for chunk \"%s\" (0x%x) does not exist or has not been read yet in this title. (@0x%llx)", __func__, tag2str(chunk._id), chunk._id, static_cast<long long int>(chunk.pos()));
+ if (!subfile.atEnd()) {
+ chunk = subfile.nextChunk();
}
- }
- debugC(5, kDebugLoading, "\nContext::readActorInFirstSubfile(): Got actor with chunk ID %s in first subfile (type: 0x%x) (@0x%llx)", tag2str(chunk._id), static_cast<uint>(actor->type()), static_cast<long long int>(chunk.pos()));
- actor->readChunk(chunk);
+ } while (!subfile.atEnd());
}
void Context::readActorFromLaterSubfile(Subfile &subfile) {
@@ -345,97 +306,49 @@ void Context::readActorFromLaterSubfile(Subfile &subfile) {
actor->readSubfile(subfile, chunk);
}
-bool Context::readHeaderSection(Chunk &chunk) {
- uint16 sectionType = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Context::readHeaderSection(): sectionType = 0x%x (@0x%llx)", static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+void Context::readContextNameData(Chunk &chunk) {
+ uint contextId = chunk.readTypedUint16();
+ if (contextId != _fileNumber) {
+ warning("%s: Repeated context ID didn't match: %d != %d", __func__, contextId, _fileNumber);
+ }
+
+ _name = chunk.readTypedString();
+}
+
+void Context::readCommandFromStream(ContextSectionType sectionType, Chunk &chunk) {
+ debugC(5, kDebugLoading, "%s: %d", __func__, static_cast<uint>(sectionType));
switch (sectionType) {
- case kContextParametersSection: {
+ case kContextCreateData:
readCreateContextData(chunk);
break;
- }
- case kContextActorLinkSection: {
- warning("%s: ACTOR_LINK not implemented yet", __func__);
- chunk.skip(chunk.bytesRemaining());
+ case kContextDestroyData:
+ readDestroyContextData(chunk);
break;
- }
-
- case kContextPaletteSection: {
- if (_palette != nullptr) {
- error("%s: Got multiple palettes (@0x%llx)", __func__, static_cast<long long int>(chunk.pos()));
- }
-
- byte *buffer = new byte[Graphics::PALETTE_SIZE];
- chunk.read(buffer, Graphics::PALETTE_SIZE);
- _palette = new Graphics::Palette(buffer, Graphics::PALETTE_COUNT, DisposeAfterUse::YES);
- debugC(5, kDebugLoading, "Context::readHeaderSection(): Read palette");
- // This is likely just an ending flag that we expect to be zero.
- uint endingFlag = chunk.readTypedUint16();
- if (endingFlag != 0) {
- warning("%s: Got non-zero ending flag 0x%x", __func__, endingFlag);
- }
+ case kContextCreateActorData:
+ readCreateActorData(chunk);
break;
- }
-
- case kContextActorHeaderSection: {
- Actor *actor = readCreateActorData(chunk);
- _actors.setVal(actor->id(), actor);
- g_engine->registerActor(actor);
- if (actor->_chunkReference != 0) {
- debugC(5, kDebugLoading, "Context::readHeaderSection(): Storing actor with chunk ID \"%s\" (0x%x)", tag2str(actor->_chunkReference), actor->_chunkReference);
- _actorsByChunkReference.setVal(actor->_chunkReference, actor);
- }
- if (actor->type() == kActorTypeMovie) {
- StreamMovieActor *movie = static_cast<StreamMovieActor *>(actor);
- if (movie->_audioChunkReference != 0) {
- _actorsByChunkReference.setVal(movie->_audioChunkReference, actor);
- }
- if (movie->_animationChunkReference != 0) {
- _actorsByChunkReference.setVal(movie->_animationChunkReference, actor);
- }
- }
- // TODO: This datum only appears sometimes.
- uint unk2 = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Context::readHeaderSection(): Got unknown value at end of actor header section 0x%x", unk2);
+ case kContextDestroyActorData:
+ readDestroyActorData(chunk);
break;
- }
- case kContextFunctionSection: {
- ScriptFunction *function = new ScriptFunction(chunk);
- _functions.setVal(function->_id, function);
- if (!g_engine->isFirstGenerationEngine()) {
- uint endingFlag = chunk.readTypedUint16();
- if (endingFlag != 0) {
- warning("%s: Got non-zero ending flag 0x%x in function section", __func__, endingFlag);
- }
- }
+ case kContextActorLoadComplete:
+ readActorLoadComplete(chunk);
break;
- }
- case kContextUnkAtEndSection: {
- int unk1 = chunk.readTypedUint16();
- int unk2 = chunk.readTypedUint16();
- debugC(5, kDebugLoading, "Context::readHeaderSection(): unk1 = %d, unk2 = %d", unk1, unk2);
- return false;
- }
-
- case kContextEmptySection: {
- error("%s: EMPTY Not implemented yet", __func__);
+ case kContextCreateVariableData:
+ readCreateVariableData(chunk);
break;
- }
- case kContextPoohSection: {
- error("%s: POOH Not implemented yet", __func__);
+ case kContextNameData:
+ readContextNameData(chunk);
break;
- }
default:
- error("%s: Unknown section type 0x%x (@0x%llx)", __func__, static_cast<uint>(sectionType), static_cast<long long int>(chunk.pos()));
+ g_engine->readUnrecognizedFromStream(chunk, static_cast<uint>(sectionType));
}
-
- return true;
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index 55cb9c7c0b6..9dad49cc9a0 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -29,28 +29,25 @@
#include "mediastation/datafile.h"
#include "mediastation/actor.h"
-#include "mediastation/mediascript/function.h"
namespace MediaStation {
-enum ContextParametersSectionType {
- kContextParametersEmptySection = 0x0000,
- kContextParametersVariable = 0x0014,
- kContextParametersName = 0x0bb9,
- kContextParametersFileNumber = 0x0011,
- kContextParametersBytecode = 0x0017
+enum StreamType {
+ kDocumentDefStream = 0x01,
+ kControlCommandsStream = 0x0D,
};
enum ContextSectionType {
- kContextEmptySection = 0x0000,
- kContextOldStyleSection = 0x000d,
- kContextParametersSection = 0x000e,
- kContextPaletteSection = 0x05aa,
- kContextUnkAtEndSection = 0x0010,
- kContextActorHeaderSection = 0x0011,
- kContextPoohSection = 0x057a,
- kContextActorLinkSection = 0x0013,
- kContextFunctionSection = 0x0031
+ kEndOfContextData = 0x00,
+ kContextCreateData = 0x0e,
+ kContextDestroyData = 0x0f,
+ kContextLoadCompleteSection = 0x10,
+ kContextCreateActorData = 0x11,
+ kContextDestroyActorData = 0x12,
+ kContextActorLoadComplete = 0x13,
+ kContextCreateVariableData = 0x14,
+ kContextFunctionSection = 0x31,
+ kContextNameData = 0xbb8
};
class ScreenActor;
@@ -63,12 +60,10 @@ public:
uint32 _unk1;
uint32 _subfileCount;
uint32 _fileSize;
- Graphics::Palette *_palette = nullptr;
ScreenActor *_screenActor = nullptr;
Actor *getActorById(uint actorId);
Actor *getActorByChunkReference(uint chunkReference);
- ScriptFunction *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
private:
@@ -79,19 +74,21 @@ private:
Common::String _contextName;
Common::HashMap<uint, Actor *> _actors;
- Common::HashMap<uint, ScriptFunction *> _functions;
Common::HashMap<uint, Actor *> _actorsByChunkReference;
Common::HashMap<uint, ScriptValue *> _variables;
- void readOldStyleHeaderSections(Subfile &subfile, Chunk &chunk);
- void readNewStyleHeaderSections(Subfile &subfile, Chunk &chunk);
+ void readHeaderSections(Subfile &subfile, Chunk &chunk);
- bool readHeaderSection(Chunk &chunk);
+ void readControlCommands(Chunk &chunk);
+ void readCommandFromStream(ContextSectionType sectionType, Chunk &chunk);
void readCreateContextData(Chunk &chunk);
- Actor *readCreateActorData(Chunk &chunk);
+ void readDestroyContextData(Chunk &chunk);
+ void readCreateActorData(Chunk &chunk);
+ void readDestroyActorData(Chunk &chunk);
+ void readActorLoadComplete(Chunk &chunk);
void readCreateVariableData(Chunk &chunk);
+ void readContextNameData(Chunk &chunk);
- void readActorInFirstSubfile(Chunk &chunk);
void readActorFromLaterSubfile(Subfile &subfile);
};
diff --git a/engines/mediastation/cursors.cpp b/engines/mediastation/cursors.cpp
index 3f1d268d453..42c8cb1a9a4 100644
--- a/engines/mediastation/cursors.cpp
+++ b/engines/mediastation/cursors.cpp
@@ -21,17 +21,102 @@
#include "mediastation/cursors.h"
#include "mediastation/debugchannels.h"
+#include "mediastation/mediastation.h"
#include "common/system.h"
#include "common/file.h"
#include "common/formats/winexe_ne.h"
#include "common/formats/winexe_pe.h"
#include "graphics/cursorman.h"
-#include "graphics/maccursor.h"
-#include "graphics/wincursor.h"
namespace MediaStation {
+CursorManager::~CursorManager() {
+ // It is up to the platform-specific cursor managers
+ // to actually delete their resources.
+ _cursors.clear();
+}
+
+bool CursorManager::attemptToReadFromStream(Chunk &chunk, uint param) {
+ bool handledParam = true;
+ switch (param) {
+ case kCursorManagerInit:
+ init(chunk);
+ break;
+
+ case kCursorManagerNewCursor:
+ newCursor(chunk);
+ break;
+
+ case kCursorManagerDisposeCursor:
+ disposeCursor(chunk);
+ break;
+
+ default:
+ handledParam = false;
+ }
+
+ return handledParam;
+}
+
+void CursorManager::init(Chunk &chunk) {
+ _baseCursorId = chunk.readTypedUint16();
+ _maxCursorId = chunk.readTypedUint16();
+
+ if (_maxCursorId < _baseCursorId || _baseCursorId == 0) {
+ error("%s: Got invalid cursor IDs", __func__);
+ }
+}
+
+void CursorManager::newCursor(Chunk &chunk) {
+ CursorType cursorType = static_cast<CursorType>(chunk.readTypedUint16());
+ uint16 cursorId = chunk.readTypedUint16();
+ switch (cursorType) {
+ case kPlatformCursor: {
+ uint16 platformCursorId = chunk.readTypedUint16();
+ newPlatformCursor(cursorId, platformCursorId);
+ break;
+ }
+
+ case kResourceCursor: {
+ // This first value isn't actually used.
+ chunk.readTypedUint16();
+ Common::String resourceName = chunk.readTypedFilename();
+ newResourceCursor(cursorId, resourceName);
+ break;
+ }
+
+ default:
+ error("%s: Got unknown cursor type %d", __func__, static_cast<uint>(cursorType));
+ }
+}
+
+void CursorManager::disposeCursor(Chunk &chunk) {
+ uint16 cursorId = chunk.readTypedUint16();
+ _cursors.erase(cursorId);
+ // We don't actually delete the underlying platform-specific
+ // cursor, just remove it from the hashmap. Otherwise, we'd
+ // mess up the platform-specific storage.
+}
+
+void CursorManager::newPlatformCursor(uint16 platformCursorId, uint16 cursorId) {
+ if (cursorId < _baseCursorId || cursorId > _maxCursorId || cursorId == 0) {
+ error("%s: Got invalid cursor ID %d", __func__, static_cast<uint>(cursorId));
+ }
+
+ warning("STUB: %s: Platform cursor %d, internal cursor %d", __func__, platformCursorId, cursorId);
+ // TODO: To implement this, we need have the default platform cursors for Windows and Mac.
+}
+
+void CursorManager::newResourceCursor(uint16 cursorId, const Common::String &resourceName) {
+ if (cursorId < _baseCursorId || cursorId > _maxCursorId || cursorId == 0) {
+ error("%s: Got invalid cursor ID %d", __func__, static_cast<uint>(cursorId));
+ }
+
+ Graphics::Cursor *cursor = loadResourceCursor(resourceName);
+ _cursors.setVal(cursorId, cursor);
+}
+
void CursorManager::showCursor() {
CursorMan.showMouse(true);
}
@@ -40,24 +125,61 @@ void CursorManager::hideCursor() {
CursorMan.showMouse(false);
}
-void CursorManager::setDefaultCursor() {
- Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
- CursorMan.replaceCursor(cursor);
- delete cursor;
+void CursorManager::registerAsPermanent(uint16 id) {
+ if (id != 0) {
+ _permanentCursorId = id;
+ }
}
-WindowsCursorManager::WindowsCursorManager(const Common::Path &appName) {
- loadCursors(appName);
+void CursorManager::setAsPermanent(uint16 id) {
+ bool cursorAlreadySet = _currentCursorId == id && _permanentCursorId == id;
+ bool cursorIsEmpty = id == 0;
+ if (cursorAlreadySet || cursorIsEmpty) {
+ return;
+ }
+
+ _permanentCursorId = id;
+ _currentCursorId = id;
+ resetCurrent();
}
-WindowsCursorManager::~WindowsCursorManager() {
- for (auto it = _cursors.begin(); it != _cursors.end(); ++it) {
- delete it->_value;
+void CursorManager::setAsTemporary(uint16 id) {
+ bool cursorAlreadySet = _currentCursorId == id;
+ bool cursorIsEmpty = id == 0;
+ if (cursorAlreadySet || cursorIsEmpty) {
+ return;
}
- _cursors.clear();
+
+ _currentCursorId = id;
+ resetCurrent();
+}
+
+void CursorManager::unsetPermanent() {
+ _permanentCursorId = 0;
+ _currentCursorId = 0;
}
-void WindowsCursorManager::loadCursors(const Common::Path &appName) {
+void CursorManager::unsetTemporary() {
+ if (_currentCursorId != _permanentCursorId) {
+ _currentCursorId = _permanentCursorId;
+ resetCurrent();
+ }
+}
+
+void CursorManager::resetCurrent() {
+ if (_currentCursorId != 0) {
+ Graphics::Cursor *cursor = _cursors.getVal(_currentCursorId);
+ CursorMan.replaceCursor(cursor);
+ }
+}
+
+void CursorManager::setDefaultCursor() {
+ Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
+ CursorMan.replaceCursor(cursor);
+ delete cursor;
+}
+
+WindowsCursorManager::WindowsCursorManager(const Common::Path &appName) : CursorManager(appName) {
if (appName.empty()) {
error("%s: No executable to load cursors from", __func__);
} else if (!Common::File::exists(appName)) {
@@ -77,22 +199,32 @@ void WindowsCursorManager::loadCursors(const Common::Path &appName) {
continue;
}
Graphics::WinCursorGroup *group = Graphics::WinCursorGroup::createCursorGroup(exe, cursorGroup);
- _cursors.setVal(resourceString, group);
+ _cursorGroups.setVal(resourceString, group);
}
delete exe;
}
-void WindowsCursorManager::setCursor(const Common::String &name) {
- Graphics::WinCursorGroup *group = _cursors.getValOrDefault(name);
+WindowsCursorManager::~WindowsCursorManager() {
+ for (auto it = _cursorGroups.begin(); it != _cursorGroups.end(); ++it) {
+ delete it->_value;
+ }
+ _cursorGroups.clear();
+
+ // We don't need to delete items in _cursors itself,
+ // because those cursors are part of _cursorGroups.
+}
+
+Graphics::Cursor *WindowsCursorManager::loadResourceCursor(const Common::String &name) {
+ Graphics::WinCursorGroup *group = _cursorGroups.getValOrDefault(name);
if (group != nullptr) {
Graphics::Cursor *cursor = group->cursors[0].cursor;
- CursorMan.replaceCursor(cursor);
+ return cursor;
} else {
error("%s: Reqested Windows cursor %s not found", __func__, name.c_str());
}
}
-MacCursorManager::MacCursorManager(const Common::Path &appName) {
+MacCursorManager::MacCursorManager(const Common::Path &appName) : CursorManager(appName) {
if (appName.empty()) {
error("%s: No file to load cursors from", __func__);
} else if (!Common::File::exists(appName)) {
@@ -106,11 +238,15 @@ MacCursorManager::MacCursorManager(const Common::Path &appName) {
}
MacCursorManager::~MacCursorManager() {
+ for (auto it = _cursors.begin(); it != _cursors.end(); ++it) {
+ delete it->_value;
+ }
+
delete _resFork;
_resFork = nullptr;
}
-void MacCursorManager::setCursor(const Common::String &name) {
+Graphics::Cursor *MacCursorManager::loadResourceCursor(const Common::String &name) {
// Try to load a color cursor first.
Common::SeekableReadStream *stream = _resFork->getResource(MKTAG('c', 'r', 's', 'r'), name);
if (stream == nullptr) {
@@ -127,10 +263,8 @@ void MacCursorManager::setCursor(const Common::String &name) {
if (!macCursor->readFromStream(*stream)) {
error("%s: Error parsing cursor %s from stream", __func__, name.c_str());
}
- CursorMan.replaceCursor(macCursor);
-
- delete macCursor;
delete stream;
+ return macCursor;
}
} // End of namespace MediaStation
diff --git a/engines/mediastation/cursors.h b/engines/mediastation/cursors.h
index 70a5f24621b..416cb058265 100644
--- a/engines/mediastation/cursors.h
+++ b/engines/mediastation/cursors.h
@@ -22,28 +22,69 @@
#ifndef MEDIASTATION_CURSORS_H
#define MEDIASTATION_CURSORS_H
+#include "common/platform.h"
#include "common/scummsys.h"
#include "common/hashmap.h"
#include "common/str.h"
#include "common/macresman.h"
#include "common/formats/winexe.h"
#include "graphics/wincursor.h"
+#include "graphics/maccursor.h"
+
+#include "mediastation/clients.h"
+#include "mediastation/datafile.h"
namespace MediaStation {
+enum CursorManagerCommandType {
+ kCursorManagerInit = 0x0c,
+ kCursorManagerNewCursor = 0x15,
+ kCursorManagerDisposeCursor = 0x16,
+};
+
+enum CursorType {
+ kPlatformCursor = 0,
+ kResourceCursor = 1,
+};
+
// Media Station stores cursors in the executable as named resources.
-class CursorManager {
+class CursorManager : public ParameterClient {
public:
- CursorManager() {}
- virtual ~CursorManager() {}
+ CursorManager(const Common::Path &appName) : _appName(appName) {}
+ virtual ~CursorManager();
+
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint param) override;
+ void init(Chunk &chunk);
+ void newCursor(Chunk &chunk);
+ void disposeCursor(Chunk &chunk);
- virtual void showCursor();
- virtual void hideCursor();
+ void newPlatformCursor(uint16 platformCursorId, uint16 cursorId);
+ void newResourceCursor(uint16 cursorId, const Common::String &resourceName);
+ // Some engine versions also have newBufferCursor that seems to be unused.
- virtual void setCursor(const Common::String &name) = 0;
+ void showCursor();
+ void hideCursor();
+
+ virtual void resetCurrent();
+ void registerAsPermanent(uint16 id);
+ void setAsPermanent(uint16 id);
+ void setAsTemporary(uint16 id);
+ void unsetPermanent();
+ void unsetTemporary();
protected:
- virtual void setDefaultCursor();
+ Common::Path _appName;
+
+ uint16 _baseCursorId = 0;
+ uint16 _maxCursorId = 0;
+ uint16 _currentCursorId = 0;
+ uint16 _permanentCursorId = 0;
+
+ // The original used an array with computed indices, but we use a hashmap for simplicity.
+ Common::HashMap<uint16, Graphics::Cursor *> _cursors;
+
+ virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) = 0;
+ void setDefaultCursor();
};
class WindowsCursorManager : public CursorManager {
@@ -51,13 +92,10 @@ public:
WindowsCursorManager(const Common::Path &appName);
~WindowsCursorManager() override;
- virtual void setCursor(const Common::String &name) override;
-
-protected:
- void loadCursors(const Common::Path &appName);
+ virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) override;
private:
- Common::HashMap<Common::String, Graphics::WinCursorGroup *> _cursors;
+ Common::HashMap<Common::String, Graphics::WinCursorGroup *> _cursorGroups;
};
class MacCursorManager : public CursorManager {
@@ -65,7 +103,7 @@ public:
explicit MacCursorManager(const Common::Path &appName);
~MacCursorManager() override;
- virtual void setCursor(const Common::String &name) override;
+ virtual Graphics::Cursor *loadResourceCursor(const Common::String &name) override;
private:
Common::MacResManager *_resFork;
diff --git a/engines/mediastation/datafile.h b/engines/mediastation/datafile.h
index 5693324013a..87e577437b9 100644
--- a/engines/mediastation/datafile.h
+++ b/engines/mediastation/datafile.h
@@ -68,7 +68,6 @@ enum DatumType {
kDatumTypeVersion = 0x13,
kDatumTypeChunkReference = 0x1b,
kDatumTypePolygon = 0x1d,
- kDatumTypePalette = 0x05aa
};
class ParameterReadStream : public Common::SeekableReadStream {
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index b10bc330384..dce705aff4b 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -40,9 +40,60 @@ VideoDisplayManager::VideoDisplayManager(MediaStationEngine *vm) : _vm(vm) {
VideoDisplayManager::~VideoDisplayManager() {
delete _screen;
_screen = nullptr;
+ delete _registeredPalette;
+ _registeredPalette = nullptr;
_vm = nullptr;
}
+bool VideoDisplayManager::attemptToReadFromStream(Chunk &chunk, uint sectionType) {
+ bool handledParam = true;
+ switch (sectionType) {
+ case kVideoDisplayManagerUpdateDirty:
+ // TODO: Call RT_DisplayUpdateManager::performUpdateDirty();
+ break;
+
+ case kVideoDisplayManagerUpdateAll:
+ // TODO: Call RT_DisplayUpdateManager::performUpdateAll();
+ break;
+
+ case kVideoDisplayManagerEffectTransition:
+ readAndEffectTransition(chunk);
+ break;
+
+ case kVideoDisplayManagerSetTime:
+ _defaultTransitionTime = chunk.readTypedTime();
+ break;
+
+ case kVideoDisplayManagerLoadPalette:
+ readAndRegisterPalette(chunk);
+ break;
+
+ default:
+ handledParam = false;
+ }
+
+ return handledParam;
+}
+
+void VideoDisplayManager::readAndEffectTransition(Chunk &chunk) {
+ uint argCount = chunk.readTypedUint16();
+ Common::Array<ScriptValue> args;
+ for (uint i = 0; i < argCount; i++) {
+ ScriptValue scriptValue(&chunk);
+ args.push_back(scriptValue);
+ }
+ effectTransition(args);
+}
+
+void VideoDisplayManager::readAndRegisterPalette(Chunk &chunk) {
+ byte *buffer = new byte[Graphics::PALETTE_SIZE];
+ chunk.read(buffer, Graphics::PALETTE_SIZE);
+ if (_registeredPalette != nullptr) {
+ delete _registeredPalette;
+ }
+ _registeredPalette = new Graphics::Palette(buffer, Graphics::PALETTE_COUNT, DisposeAfterUse::YES);
+}
+
void VideoDisplayManager::effectTransition(Common::Array<ScriptValue> &args) {
if (args.empty()) {
warning("%s: Script args cannot be empty", __func__);
diff --git a/engines/mediastation/graphics.h b/engines/mediastation/graphics.h
index 25466a14c25..5675464ac99 100644
--- a/engines/mediastation/graphics.h
+++ b/engines/mediastation/graphics.h
@@ -27,6 +27,7 @@
#include "graphics/managed_surface.h"
#include "graphics/screen.h"
+#include "mediastation/clients.h"
#include "mediastation/mediascript/scriptvalue.h"
namespace MediaStation {
@@ -61,11 +62,21 @@ enum TransitionType {
kTransitionCircleOut = 328
};
-class VideoDisplayManager {
+enum VideoDisplayManagerSectionType {
+ kVideoDisplayManagerUpdateDirty = 0x578,
+ kVideoDisplayManagerUpdateAll = 0x579,
+ kVideoDisplayManagerEffectTransition = 0x57a,
+ kVideoDisplayManagerSetTime = 0x57b,
+ kVideoDisplayManagerLoadPalette = 0x5aa,
+};
+
+class VideoDisplayManager : public ParameterClient {
public:
VideoDisplayManager(MediaStationEngine *vm);
~VideoDisplayManager();
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
+
void updateScreen() { _screen->update(); }
Graphics::Palette *getRegisteredPalette() { return _registeredPalette; }
void setRegisteredPalette(Graphics::Palette *palette) { _registeredPalette = palette; }
@@ -97,6 +108,10 @@ private:
Graphics::Screen *_screen = nullptr;
Graphics::Palette *_registeredPalette = nullptr;
Common::Array<ScriptValue> _scheduledTransitionOnSync;
+ double _defaultTransitionTime = 0.0;
+
+ void readAndEffectTransition(Chunk &chunk);
+ void readAndRegisterPalette(Chunk &chunk);
// Blitting methods.
// blitRectsClip encompasses the functionality of both opaqueBlitRectsClip
diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 5a80296abca..b9c932da97e 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -464,18 +464,7 @@ ScriptValue CodeChunk::evaluateFunctionCall(uint functionId, uint paramCount) {
args.push_back(arg);
}
- ScriptValue returnValue;
- ScriptFunction *function = g_engine->getFunctionById(functionId);
- if (function != nullptr) {
- // This is a title-defined function.
- returnValue = function->execute(args);
- } else {
- // This is a function built in (and global to) the engine.
- BuiltInFunction builtInFunctionId = static_cast<BuiltInFunction>(functionId);
- debugC(5, kDebugScript, " Function Name: %s ", builtInFunctionToStr(builtInFunctionId));
- returnValue = g_engine->callBuiltInFunction(builtInFunctionId, args);
- }
-
+ ScriptValue returnValue = g_engine->getFunctionManager()->call(functionId, args);
return returnValue;
}
diff --git a/engines/mediastation/mediascript/function.cpp b/engines/mediastation/mediascript/function.cpp
index 61baa7c4b94..a829d9e4485 100644
--- a/engines/mediastation/mediascript/function.cpp
+++ b/engines/mediastation/mediascript/function.cpp
@@ -21,9 +21,9 @@
#include "mediastation/mediascript/function.h"
#include "mediastation/debugchannels.h"
+#include "mediastation/mediastation.h"
namespace MediaStation {
-
ScriptFunction::ScriptFunction(Chunk &chunk) {
_contextId = chunk.readTypedUint16();
// In PROFILE._ST (only present in some titles), the function ID is reported
@@ -39,10 +39,88 @@ ScriptFunction::~ScriptFunction() {
}
ScriptValue ScriptFunction::execute(Common::Array<ScriptValue> &args) {
- debugC(5, kDebugScript, "\n********** FUNCTION %d **********", _id);
+ debugC(5, kDebugScript, "\n********** SCRIPT FUNCTION %d **********", _id);
ScriptValue returnValue = _code->execute(&args);
- debugC(5, kDebugScript, "********** END FUNCTION **********");
+ debugC(5, kDebugScript, "********** END SCRIPT FUNCTION **********");
return returnValue;
}
+FunctionManager::~FunctionManager() {
+ for (auto it = _functions.begin(); it != _functions.end(); ++it) {
+ delete it->_value;
+ }
+ _functions.clear();
+}
+
+bool FunctionManager::attemptToReadFromStream(Chunk &chunk, uint sectionType) {
+ bool handledParam = true;
+ switch (sectionType) {
+ case 0x31: {
+ ScriptFunction *function = new ScriptFunction(chunk);
+ _functions.setVal(function->_id, function);
+ break;
+ }
+
+ default:
+ handledParam = false;
+ }
+
+ return handledParam;
+}
+
+ScriptValue FunctionManager::call(uint functionId, Common::Array<ScriptValue> &args) {
+ ScriptValue returnValue;
+
+ // The original had a complex function registration system that I deemed too uselessly complex to
+ // reimplement. Here, we get basically the same behaviour by checking for default functions first,
+ // then falling through to title-defined functions.
+ switch (functionId) {
+ case kEffectTransitionFunction:
+ g_engine->getDisplayManager()->effectTransition(args);
+ break;
+
+ case kEffectTransitionOnSyncFunction:
+ g_engine->getDisplayManager()->setTransitionOnSync(args);
+ break;
+
+ case kDrawingFunction:
+ warning("STUB: %s", builtInFunctionToStr(static_cast<BuiltInFunction>(functionId)));
+ break;
+
+ case kUnk1Function:
+ warning("%s: Function Unk1 Not implemented", __func__);
+ returnValue.setToFloat(1.0);
+ break;
+
+ default: {
+ // Execute the title-defined function here.
+ ScriptFunction *scriptFunction = _functions.getValOrDefault(functionId);
+ if (scriptFunction != nullptr) {
+ returnValue = scriptFunction->execute(args);
+ } else {
+ error("%s: Unimplemented function 0x%02x", __func__, functionId);
+ }
+ }
+ }
+
+ return returnValue;
+}
+
+void FunctionManager::deleteFunctionsForContext(uint contextId) {
+ // Collect function IDs to delete first.
+ Common::Array<ScriptFunction *> functionsToDelete;
+ for (auto it = _functions.begin(); it != _functions.end(); ++it) {
+ ScriptFunction *scriptFunction = it->_value;
+ if (scriptFunction->_contextId == contextId) {
+ functionsToDelete.push_back(scriptFunction);
+ }
+ }
+
+ // Now delete them.
+ for (ScriptFunction *scriptFunction : functionsToDelete) {
+ _functions.erase(scriptFunction->_id);
+ delete scriptFunction;
+ }
+}
+
} // End of namespace MediaStation
diff --git a/engines/mediastation/mediascript/function.h b/engines/mediastation/mediascript/function.h
index 0590d732a28..d92ffa9e737 100644
--- a/engines/mediastation/mediascript/function.h
+++ b/engines/mediastation/mediascript/function.h
@@ -23,7 +23,9 @@
#define MEDIASTATION_MEDIASCRIPT_FUNCTION_H
#include "common/array.h"
+#include "common/hashmap.h"
+#include "mediastation/clients.h"
#include "mediastation/datafile.h"
#include "mediastation/mediascript/codechunk.h"
@@ -36,13 +38,28 @@ public:
ScriptValue execute(Common::Array<ScriptValue> &args);
- uint _contextId;
- uint _id;
+ uint _contextId = 0;
+ uint _id = 0;
private:
CodeChunk *_code = nullptr;
};
+class FunctionManager : public ParameterClient {
+public:
+ FunctionManager() {};
+ virtual ~FunctionManager();
+
+ virtual bool attemptToReadFromStream(Chunk &chunk, uint sectionType) override;
+ ScriptValue call(uint functionId, Common::Array<ScriptValue> &args);
+ void deleteFunctionsForContext(uint contextId);
+
+ ScriptValue script_Random(Common::Array<ScriptValue> &args);
+
+private:
+ Common::HashMap<uint, ScriptFunction *> _functions;
+};
+
} // End of namespace MediaStation
#endif
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 02e1e7842e6..6c58bb0d50f 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -56,8 +56,17 @@ MediaStationEngine::~MediaStationEngine() {
delete _displayManager;
_displayManager = nullptr;
- delete _cursor;
- _cursor = nullptr;
+ delete _cursorManager;
+ _cursorManager = nullptr;
+
+ delete _functionManager;
+ _functionManager = nullptr;
+
+ delete _document;
+ _document = nullptr;
+
+ delete _deviceOwner;
+ _deviceOwner = nullptr;
delete _boot;
_boot = nullptr;
@@ -90,16 +99,6 @@ Actor *MediaStationEngine::getActorByChunkReference(uint chunkReference) {
return nullptr;
}
-ScriptFunction *MediaStationEngine::getFunctionById(uint functionId) {
- for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
- ScriptFunction *function = it->_value->getFunctionById(functionId);
- if (function != nullptr) {
- return function;
- }
- }
- return nullptr;
-}
-
ScriptValue *MediaStationEngine::getVariable(uint variableId) {
for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
ScriptValue *variable = it->_value->getVariable(variableId);
@@ -135,23 +134,15 @@ bool MediaStationEngine::isFirstGenerationEngine() {
}
Common::Error MediaStationEngine::run() {
- _displayManager = new VideoDisplayManager(this);
+ initDisplayManager();
+ initCursorManager();
+ initFunctionManager();
+ initDocument();
+ initDeviceOwner();
Common::Path bootStmFilepath = Common::Path("BOOT.STM");
_boot = new Boot(bootStmFilepath);
- if (getPlatform() == Common::kPlatformWindows) {
- _cursor = new WindowsCursorManager(getAppName());
- } else if (getPlatform() == Common::kPlatformMacintosh) {
- _cursor = new MacCursorManager(getAppName());
- } else {
- error("%s: Attempted to use unsupported platform %s", __func__, Common::getPlatformDescription(getPlatform()));
- }
- _cursor->showCursor();
-
- DocumentActor *document = new DocumentActor;
- _actors.push_back(document);
-
if (ConfMan.hasKey("entry_context")) {
// For development purposes, we can choose to start at an arbitrary context
// in this title. This might not work in all cases.
@@ -159,7 +150,7 @@ Common::Error MediaStationEngine::run() {
warning("%s: Starting at user-requested context %d", __func__, entryContextId);
_requestedScreenBranchId = entryContextId;
} else {
- _requestedScreenBranchId = _boot->_entryContextId;
+ _requestedScreenBranchId = _document->_entryScreenId;
}
doBranchToScreen();
@@ -199,6 +190,41 @@ Common::Error MediaStationEngine::run() {
return Common::kNoError;
}
+void MediaStationEngine::initDisplayManager() {
+ _displayManager = new VideoDisplayManager(this);
+ _parameterClients.push_back(_displayManager);
+}
+
+void MediaStationEngine::initCursorManager() {
+ if (getPlatform() == Common::kPlatformWindows) {
+ _cursorManager = new WindowsCursorManager(getAppName());
+ } else if (getPlatform() == Common::kPlatformMacintosh) {
+ _cursorManager = new MacCursorManager(getAppName());
+ } else {
+ error("%s: Attempted to use unsupported platform %s", __func__, Common::getPlatformDescription(getPlatform()));
+ }
+ _parameterClients.push_back(_cursorManager);
+ _cursorManager->showCursor();
+}
+
+void MediaStationEngine::initFunctionManager() {
+ _functionManager = new FunctionManager();
+ _parameterClients.push_back(_functionManager);
+}
+
+void MediaStationEngine::initDocument() {
+ _document = new Document();
+ _parameterClients.push_back(_document);
+
+ DocumentActor *documentActor = new DocumentActor;
+ _actors.push_back(documentActor);
+}
+
+void MediaStationEngine::initDeviceOwner() {
+ _deviceOwner = new DeviceOwner();
+ _parameterClients.push_back(_deviceOwner);
+}
+
void MediaStationEngine::processEvents() {
while (g_system->getEventManager()->pollEvent(_event)) {
debugC(9, kDebugEvents, "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
@@ -252,16 +278,6 @@ void MediaStationEngine::processEvents() {
}
}
-void MediaStationEngine::setCursor(uint id) {
- // The cursor ID is not a resource ID in the executable, but a numeric ID
- // that's a lookup into BOOT.STM, which gives actual name the name of the
- // resource in the executable.
- if (id != 0) {
- const CursorDeclaration &cursorDeclaration = _boot->_cursorDeclarations.getVal(id);
- _cursor->setCursor(cursorDeclaration._name);
- }
-}
-
void MediaStationEngine::refreshActiveHotspot() {
Actor *actor = findActorToAcceptMouseEvents();
if (actor != nullptr && actor->type() != kActorTypeHotspot) {
@@ -276,11 +292,11 @@ void MediaStationEngine::refreshActiveHotspot() {
_currentHotspot = hotspot;
if (hotspot != nullptr) {
debugC(5, kDebugEvents, "refreshActiveHotspot(): (%d, %d): Entered hotspot %d", _mousePos.x, _mousePos.y, hotspot->id());
- setCursor(hotspot->_cursorResourceId);
+ _cursorManager->setAsTemporary(hotspot->_cursorResourceId);
hotspot->runEventHandlerIfExists(kMouseEnteredEvent);
} else {
// There is no hotspot, so set the default cursor for this screen instead.
- setCursor(_currentContext->_screenActor->_cursorResourceId);
+ _cursorManager->unsetTemporary();
}
}
@@ -376,7 +392,6 @@ void MediaStationEngine::doBranchToScreen() {
_currentContext = loadContext(_requestedScreenBranchId);
_currentHotspot = nullptr;
- _displayManager->setRegisteredPalette(_currentContext->_palette);
if (_currentContext->_screenActor != nullptr) {
_currentContext->_screenActor->runEventHandlerIfExists(kEntryEvent);
@@ -421,6 +436,8 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
}
}
+ _functionManager->deleteFunctionsForContext(contextId);
+
delete context;
_loadedContexts.erase(contextId);
}
@@ -446,36 +463,6 @@ Actor *MediaStationEngine::findActorToAcceptMouseEvents() {
return intersectingActor;
}
-ScriptValue MediaStationEngine::callBuiltInFunction(BuiltInFunction function, Common::Array<ScriptValue> &args) {
- ScriptValue returnValue;
-
- switch (function) {
- case kEffectTransitionFunction:
- _displayManager->effectTransition(args);
- return returnValue;
-
- case kEffectTransitionOnSyncFunction:
- _displayManager->setTransitionOnSync(args);
- return returnValue;
-
- case kDrawingFunction: {
- // Not entirely sure what this function does, but it seems like a way to
- // call into some drawing functions built into the IBM/Crayola executable.
- warning("%s: Built-in drawing function not implemented", __func__);
- return returnValue;
- }
-
- case kUnk1Function: {
- warning("%s: Function 10 not implemented", __func__);
- returnValue.setToFloat(1.0);
- return returnValue;
- }
-
- default:
- error("%s: Got unknown built-in function %s (%d)", __func__, builtInFunctionToStr(function), static_cast<uint>(function));
- }
-}
-
int MediaStationEngine::compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b) {
int diff = b->zIndex() - a->zIndex();
if (diff < 0)
@@ -488,4 +475,18 @@ int MediaStationEngine::compareActorByZIndex(const SpatialEntity *a, const Spati
}
}
+void MediaStationEngine::readUnrecognizedFromStream(Chunk &chunk, uint sectionType) {
+ bool paramHandled = false;
+ for (ParameterClient *client : g_engine->_parameterClients) {
+ if (client->attemptToReadFromStream(chunk, sectionType)) {
+ paramHandled = true;
+ break;
+ }
+ }
+
+ if (!paramHandled) {
+ error("%s: Unhandled section type 0x%x", __func__, static_cast<uint>(sectionType));
+ }
+}
+
} // End of namespace MediaStation
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index 755f55fda37..e69ee8b2a13 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -35,6 +35,7 @@
#include "engines/engine.h"
#include "engines/savestate.h"
+#include "mediastation/clients.h"
#include "mediastation/detection.h"
#include "mediastation/datafile.h"
#include "mediastation/boot.h"
@@ -42,6 +43,7 @@
#include "mediastation/actor.h"
#include "mediastation/cursors.h"
#include "mediastation/graphics.h"
+#include "mediastation/mediascript/function.h"
namespace MediaStation {
@@ -85,14 +87,18 @@ public:
void registerActor(Actor *actorToAdd);
void scheduleScreenBranch(uint screenId);
void scheduleContextRelease(uint contextId);
+ void readUnrecognizedFromStream(Chunk &chunk, uint sectionType);
+ void releaseContext(uint32 contextId);
Actor *getActorById(uint actorId);
Actor *getActorByChunkReference(uint chunkReference);
- ScriptFunction *getFunctionById(uint functionId);
ScriptValue *getVariable(uint variableId);
VideoDisplayManager *getDisplayManager() { return _displayManager; }
+ CursorManager *getCursorManager() { return _cursorManager; }
+ FunctionManager *getFunctionManager() { return _functionManager; }
+
+ Common::Array<ParameterClient *> _parameterClients;
- ScriptValue callBuiltInFunction(BuiltInFunction function, Common::Array<ScriptValue> &args);
Common::RandomSource _randomSource;
Context *_currentContext = nullptr;
@@ -109,12 +115,11 @@ private:
const ADGameDescription *_gameDescription;
Common::Array<Common::Rect> _dirtyRects;
- // In Media Station, only the cursors are stored in the executable; everything
- // else is in the Context (*.CXT) data files.
- CursorManager *_cursor;
- void setCursor(uint id);
-
VideoDisplayManager *_displayManager = nullptr;
+ CursorManager *_cursorManager = nullptr;
+ FunctionManager *_functionManager = nullptr;
+ Document *_document = nullptr;
+ DeviceOwner *_deviceOwner = nullptr;
Boot *_boot = nullptr;
Common::Array<Actor *> _actors;
@@ -124,9 +129,14 @@ private:
uint _requestedScreenBranchId = 0;
Common::Array<uint> _requestedContextReleaseId;
+ void initDisplayManager();
+ void initCursorManager();
+ void initFunctionManager();
+ void initDocument();
+ void initDeviceOwner();
+
void doBranchToScreen();
Context *loadContext(uint32 contextId);
- void releaseContext(uint32 contextId);
Actor *findActorToAcceptMouseEvents();
static int compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b);
diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index 25424f0a2cc..3b5921a7a55 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS = \
audio.o \
bitmap.o \
boot.o \
+ clients.o \
context.o \
cursors.o \
datafile.o \
Commit: 1e64cc624449be87e83e60e35d6c2ab3a14ae317
https://github.com/scummvm/scummvm/commit/1e64cc624449be87e83e60e35d6c2ab3a14ae317
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Rename context file number to ID
Changed paths:
engines/mediastation/context.cpp
engines/mediastation/context.h
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index b6c1ec671c5..4badc515529 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -139,7 +139,7 @@ void Context::readCreateContextData(Chunk &chunk) {
// The original had contexts created from the base engine class,
// but things are currently structured a bit differently, so this
// is a no-op for now.
- _fileNumber = chunk.readTypedUint16();
+ _id = chunk.readTypedUint16();
}
void Context::readDestroyContextData(Chunk &chunk) {
@@ -243,9 +243,9 @@ void Context::readCreateActorData(Chunk &chunk) {
}
void Context::readCreateVariableData(Chunk &chunk) {
- uint repeatedFileNumber = chunk.readTypedUint16();
- if (repeatedFileNumber != _fileNumber) {
- warning("%s: Repeated file number didn't match: %d != %d", __func__, repeatedFileNumber, _fileNumber);
+ uint contextId = chunk.readTypedUint16();
+ if (contextId != _id) {
+ warning("%s: Repeated context ID didn't match: %d != %d", __func__, contextId, _id);
}
uint id = chunk.readTypedUint16();
@@ -308,8 +308,8 @@ void Context::readActorFromLaterSubfile(Subfile &subfile) {
void Context::readContextNameData(Chunk &chunk) {
uint contextId = chunk.readTypedUint16();
- if (contextId != _fileNumber) {
- warning("%s: Repeated context ID didn't match: %d != %d", __func__, contextId, _fileNumber);
+ if (contextId != _id) {
+ warning("%s: Repeated context ID didn't match: %d != %d", __func__, contextId, _id);
}
_name = chunk.readTypedString();
diff --git a/engines/mediastation/context.h b/engines/mediastation/context.h
index 9dad49cc9a0..4a5722ad092 100644
--- a/engines/mediastation/context.h
+++ b/engines/mediastation/context.h
@@ -70,7 +70,7 @@ private:
// This is not an internal file ID, but the number of the file
// as it appears in the filename. For instance, the context in
// "100.cxt" would have file number 100.
- uint _fileNumber = 0;
+ uint _id = 0;
Common::String _contextName;
Common::HashMap<uint, Actor *> _actors;
Commit: 51541be708bc08a4ecb9727117a81dac490f8ebe
https://github.com/scummvm/scummvm/commit/51541be708bc08a4ecb9727117a81dac490f8ebe
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Rename file and stream maps
Changed paths:
engines/mediastation/boot.cpp
engines/mediastation/boot.h
engines/mediastation/mediastation.cpp
diff --git a/engines/mediastation/boot.cpp b/engines/mediastation/boot.cpp
index 3cd7d613606..974036e8d37 100644
--- a/engines/mediastation/boot.cpp
+++ b/engines/mediastation/boot.cpp
@@ -182,10 +182,10 @@ BootSectionType Boot::getSectionType(Chunk &chunk) {
Boot::~Boot() {
_contextDeclarations.clear();
- _subfileDeclarations.clear();
+ _streamMap.clear();
_engineResourceDeclarations.clear();
_screenDeclarations.clear();
- _fileDeclarations.clear();
+ _fileMap.clear();
}
void Boot::readDocumentDef(Chunk &chunk) {
@@ -269,7 +269,7 @@ void Boot::readAndAddFileMaps(Chunk &chunk) {
uint flag = chunk.readTypedUint16();
while (flag != 0) {
FileDeclaration fileDeclaration(chunk);
- _fileDeclarations.setVal(fileDeclaration._id, fileDeclaration);
+ _fileMap.setVal(fileDeclaration._id, fileDeclaration);
flag = chunk.readTypedUint16();
}
}
@@ -278,7 +278,7 @@ void Boot::readAndAddStreamMaps(Chunk &chunk) {
uint flag = chunk.readTypedUint16();
while (flag != 0) {
SubfileDeclaration subfileDeclaration(chunk);
- _subfileDeclarations.setVal(subfileDeclaration._actorId, subfileDeclaration);
+ _streamMap.setVal(subfileDeclaration._actorId, subfileDeclaration);
flag = chunk.readTypedUint16();
}
}
diff --git a/engines/mediastation/boot.h b/engines/mediastation/boot.h
index 5bc8779d6e3..2119225fafd 100644
--- a/engines/mediastation/boot.h
+++ b/engines/mediastation/boot.h
@@ -172,8 +172,8 @@ public:
Common::String _sourceString;
Common::HashMap<uint32, ContextDeclaration> _contextDeclarations;
Common::HashMap<uint32, ScreenDeclaration> _screenDeclarations;
- Common::HashMap<uint32, FileDeclaration> _fileDeclarations;
- Common::HashMap<uint32, SubfileDeclaration> _subfileDeclarations;
+ Common::HashMap<uint32, FileDeclaration> _fileMap;
+ Common::HashMap<uint32, SubfileDeclaration> _streamMap;
Common::HashMap<uint32, EngineResourceDeclaration> _engineResourceDeclarations;
uint _unk1 = 0;
uint _functionTableSize = 0;
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 6c58bb0d50f..9d8df3e1704 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -335,7 +335,7 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
}
// Get the file ID.
- const SubfileDeclaration &subfileDeclaration = _boot->_subfileDeclarations.getVal(contextId);
+ const SubfileDeclaration &subfileDeclaration = _boot->_streamMap.getVal(contextId);
// There are other actors in a subfile too, so we need to make sure we're
// referencing the screen actor, at the start of the file.
if (subfileDeclaration._startOffsetInFile != 16) {
@@ -345,7 +345,7 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
uint fileId = subfileDeclaration._fileId;
// Get the filename.
- const FileDeclaration &fileDeclaration = _boot->_fileDeclarations.getVal(fileId);
+ const FileDeclaration &fileDeclaration = _boot->_fileMap.getVal(fileId);
Common::Path entryCxtFilepath(fileDeclaration._name);
// Load any child contexts before we actually load this one. The child
Commit: 2bb2f2e747bac9e13501fa1062df8286c2727b00
https://github.com/scummvm/scummvm/commit/2bb2f2e747bac9e13501fa1062df8286c2727b00
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Add missing script constant labels
Changed paths:
engines/mediastation/mediascript/scriptconstants.cpp
diff --git a/engines/mediastation/mediascript/scriptconstants.cpp b/engines/mediastation/mediascript/scriptconstants.cpp
index 170952caca2..912e2c6c4db 100644
--- a/engines/mediastation/mediascript/scriptconstants.cpp
+++ b/engines/mediastation/mediascript/scriptconstants.cpp
@@ -103,6 +103,8 @@ const char *variableScopeToStr(VariableScope scope) {
return "Local";
case kVariableScopeParameter:
return "Parameter";
+ case kVariableScopeIndirectParameter:
+ return "IndirectParameter";
case kVariableScopeGlobal:
return "Global";
default:
@@ -135,6 +137,8 @@ const char *builtInMethodToStr(BuiltInMethod method) {
return "SpatialHide";
case kSpatialMoveToMethod:
return "SpatialMoveTo";
+ case kSpatialMoveToByOffsetMethod:
+ return "SpatialMoveToByOffset";
case kSpatialZMoveToMethod:
return "SpatialZMoveTo";
case kSpatialCenterMoveToMethod:
Commit: 4a24261fc027b4cd8af920fc3cbf47a87470a37e
https://github.com/scummvm/scummvm/commit/4a24261fc027b4cd8af920fc3cbf47a87470a37e
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Fix CLIPs that weren't actually assigning anything
Changed paths:
engines/mediastation/actor.cpp
engines/mediastation/graphics.cpp
engines/mediastation/graphics.h
diff --git a/engines/mediastation/actor.cpp b/engines/mediastation/actor.cpp
index 7de7112ed85..01ae6133eb6 100644
--- a/engines/mediastation/actor.cpp
+++ b/engines/mediastation/actor.cpp
@@ -298,7 +298,7 @@ void SpatialEntity::setZIndex(int zIndex) {
}
void SpatialEntity::setDissolveFactor(double dissolveFactor) {
- CLIP(dissolveFactor, 0.0, 1.0);
+ dissolveFactor = CLIP(dissolveFactor, 0.0, 1.0);
if (dissolveFactor != _dissolveFactor) {
_dissolveFactor = dissolveFactor;
invalidateLocalBounds();
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index dce705aff4b..451374ea8f5 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -366,9 +366,9 @@ void VideoDisplayManager::_setPaletteToColor(Graphics::Palette &targetPalette, b
}
uint VideoDisplayManager::_limitColorRange(uint &startIndex, uint &colorCount) {
- CLIP<uint>(startIndex, 0, Graphics::PALETTE_COUNT - 1);
+ startIndex = CLIP<uint>(startIndex, 0, Graphics::PALETTE_COUNT - 1);
uint endColorIndex = startIndex + colorCount;
- CLIP<uint>(endColorIndex, 0, Graphics::PALETTE_COUNT);
+ endColorIndex = CLIP<uint>(endColorIndex, 0, Graphics::PALETTE_COUNT);
colorCount = endColorIndex - startIndex;
return endColorIndex;
}
@@ -537,7 +537,7 @@ void VideoDisplayManager::_setPercentToPaletteObject(double percent, uint palett
void VideoDisplayManager::imageBlit(
const Common::Point &destinationPoint,
const Bitmap *sourceImage,
- const double dissolveFactor,
+ double dissolveFactor,
const Common::Array<Common::Rect> &dirtyRegion,
Graphics::ManagedSurface *targetImage) {
@@ -569,7 +569,7 @@ void VideoDisplayManager::imageBlit(
if (dissolveFactor > 1.0 || dissolveFactor < 0.0) {
warning("%s: Got out-of-range dissolve factor: %f", __func__, dissolveFactor);
- CLIP(dissolveFactor, 0.0, 1.0);
+ dissolveFactor = CLIP(dissolveFactor, 0.0, 1.0);
} else if (dissolveFactor == 0.0) {
// If the image is fully transparent, there is nothing to draw, so we can return now.
return;
@@ -670,7 +670,7 @@ void VideoDisplayManager::dissolveBlitRectsClip(
byte dissolveIndex = DISSOLVE_PATTERN_COUNT;
if (integralDissolveFactor != 50) {
dissolveIndex = ((integralDissolveFactor + 2) / 4) - 1;
- CLIP<byte>(dissolveIndex, 0, (DISSOLVE_PATTERN_COUNT - 1));
+ dissolveIndex = CLIP<byte>(dissolveIndex, 0, (DISSOLVE_PATTERN_COUNT - 1));
}
Common::Rect destRect(Common::Rect(destPos, source->width(), source->height()));
@@ -846,8 +846,12 @@ Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
int destSizeInBytes = source->width() * source->height();
Common::SeekableReadStream *chunk = source->_compressedStream;
- chunk->seek(0);
+ if (chunk == nullptr) {
+ warning("%s: Got empty image", __func__);
+ return dest;
+ }
+ chunk->seek(0);
bool imageFullyRead = false;
Common::Point sourcePos;
while (sourcePos.y < source->height()) {
@@ -921,7 +925,7 @@ Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
// The bounds check is structured this way because the run can extend across scanlines.
byte runLength = operation;
uint maxAllowedRun = destSizeInBytes - (sourcePos.y * dest.w + sourcePos.x);
- CLIP<uint>(runLength, 0, maxAllowedRun);
+ runLength = CLIP<uint>(runLength, 0, maxAllowedRun);
byte *destPtr = static_cast<byte *>(dest.getBasePtr(sourcePos.x, sourcePos.y));
chunk->read(destPtr, runLength);
@@ -936,7 +940,7 @@ Graphics::ManagedSurface VideoDisplayManager::decompressRle8Bitmap(
byte colorIndexToRepeat = chunk->readByte();
byte repetitionCount = operation;
uint maxAllowedCount = destSizeInBytes - (sourcePos.y * dest.w + sourcePos.x);
- CLIP<uint>(repetitionCount, 0, maxAllowedCount);
+ repetitionCount = CLIP<uint>(repetitionCount, 0, maxAllowedCount);
byte *destPtr = static_cast<byte *>(dest.getBasePtr(sourcePos.x, sourcePos.y));
memset(destPtr, colorIndexToRepeat, repetitionCount);
diff --git a/engines/mediastation/graphics.h b/engines/mediastation/graphics.h
index 5675464ac99..cd079cd0d67 100644
--- a/engines/mediastation/graphics.h
+++ b/engines/mediastation/graphics.h
@@ -84,7 +84,7 @@ public:
void imageBlit(
const Common::Point &destinationPoint,
const Bitmap *image,
- const double dissolveFactor,
+ double dissolveFactor,
const Common::Array<Common::Rect> &dirtyRegion,
Graphics::ManagedSurface *destinationImage = nullptr);
Commit: 9d25beea09d3621a2cfeafc9262829ace1712565
https://github.com/scummvm/scummvm/commit/9d25beea09d3621a2cfeafc9262829ace1712565
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Fix Lion King detection entry
Changed paths:
engines/mediastation/detection_tables.h
diff --git a/engines/mediastation/detection_tables.h b/engines/mediastation/detection_tables.h
index fe538641022..66aa98e9a8e 100644
--- a/engines/mediastation/detection_tables.h
+++ b/engines/mediastation/detection_tables.h
@@ -85,9 +85,9 @@ const ADGameDescription gameDescriptions[] = {
"lionking",
"v2.0/GB",
AD_ENTRY3s(
- "LIONKING.EXE", "9cc25600be13c402f4edf15772989393", 358368,
- "BOOT.STM", "72e9211eb97b968e8db20c0fec919eb4", 23610,
- "100.CXT", "069b86f0912627bc1fffb1dee9b68afa", 1455740
+ "LIONKING.EXE", "3239451c477eaa16015110502be031a5", 363232,
+ "BOOT.STM", "dd83fd1fb899b680f00c586404cc7b7c", 23610,
+ "100.CXT", "d5dc4d49df2ea6f2ff0aa33a3f385506", 1455740
),
Common::EN_GRB,
Common::kPlatformWindows,
Commit: 72aa133469ad0acdaf6ae98a4a2b92fffb2cee3a
https://github.com/scummvm/scummvm/commit/72aa133469ad0acdaf6ae98a4a2b92fffb2cee3a
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Fix early engine versions movie loading
Changed paths:
engines/mediastation/actors/movie.cpp
engines/mediastation/mediastation.cpp
diff --git a/engines/mediastation/actors/movie.cpp b/engines/mediastation/actors/movie.cpp
index d291b0c8c0c..71f63675879 100644
--- a/engines/mediastation/actors/movie.cpp
+++ b/engines/mediastation/actors/movie.cpp
@@ -32,17 +32,18 @@ MovieFrameHeader::MovieFrameHeader(Chunk &chunk) : BitmapHeader(chunk) {
}
MovieFrame::MovieFrame(Chunk &chunk) {
- layerId = chunk.readTypedUint32();
if (g_engine->isFirstGenerationEngine()) {
+ blitType = static_cast<MovieBlitType>(chunk.readTypedUint16());
startInMilliseconds = chunk.readTypedUint32();
endInMilliseconds = chunk.readTypedUint32();
// These are unsigned in the data files but ScummVM expects signed.
leftTop.x = static_cast<int16>(chunk.readTypedUint16());
leftTop.y = static_cast<int16>(chunk.readTypedUint16());
- unk3 = chunk.readTypedUint16();
- unk4 = chunk.readTypedUint16();
- index = chunk.readTypedUint16();
+ index = chunk.readTypedUint32();
+ keyframeIndex = chunk.readTypedUint32();
+ keepAfterEnd = chunk.readTypedByte();
} else {
+ layerId = chunk.readTypedUint32();
blitType = static_cast<MovieBlitType>(chunk.readTypedUint16());
startInMilliseconds = chunk.readTypedUint32();
endInMilliseconds = chunk.readTypedUint32();
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 9d8df3e1704..e13812d355c 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -335,7 +335,7 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
}
// Get the file ID.
- const SubfileDeclaration &subfileDeclaration = _boot->_streamMap.getVal(contextId);
+ const SubfileDeclaration &subfileDeclaration = _boot->_streamMap.getValOrDefault(contextId);
// There are other actors in a subfile too, so we need to make sure we're
// referencing the screen actor, at the start of the file.
if (subfileDeclaration._startOffsetInFile != 16) {
Commit: 0fb6764759ad04b4d895c7cb95305b6f7393b0c4
https://github.com/scummvm/scummvm/commit/0fb6764759ad04b4d895c7cb95305b6f7393b0c4
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-10-19T13:19:56-04:00
Commit Message:
MEDIASTATION: Add preliminary work on stages
Changed paths:
A engines/mediastation/actors/stage.cpp
A engines/mediastation/actors/stage.h
engines/mediastation/actor.cpp
engines/mediastation/actor.h
engines/mediastation/actors/hotspot.cpp
engines/mediastation/actors/hotspot.h
engines/mediastation/context.cpp
engines/mediastation/graphics.cpp
engines/mediastation/graphics.h
engines/mediastation/mediascript/scriptconstants.cpp
engines/mediastation/mediascript/scriptconstants.h
engines/mediastation/mediastation.cpp
engines/mediastation/mediastation.h
engines/mediastation/module.mk
diff --git a/engines/mediastation/actor.cpp b/engines/mediastation/actor.cpp
index 01ae6133eb6..cbe77e3f9bd 100644
--- a/engines/mediastation/actor.cpp
+++ b/engines/mediastation/actor.cpp
@@ -22,6 +22,7 @@
#include "common/util.h"
#include "mediastation/actor.h"
+#include "mediastation/actors/stage.h"
#include "mediastation/debugchannels.h"
#include "mediastation/mediascript/scriptconstants.h"
#include "mediastation/mediastation.h"
@@ -73,6 +74,13 @@ void Actor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
}
}
+void Actor::loadIsComplete() {
+ if (_loadIsComplete) {
+ warning("%s: Called more than once for actor %d", __func__, _id);
+ }
+ _loadIsComplete = true;
+}
+
ScriptValue Actor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
error("%s: Got unimplemented method call 0x%x (%s)", __func__, static_cast<uint>(methodId), builtInMethodToStr(methodId));
}
@@ -185,12 +193,14 @@ ScriptValue SpatialEntity::callMethod(BuiltInMethod methodId, Common::Array<Scri
break;
case kGetCenterXMethod: {
+ assert(args.empty());
int centerX = _boundingBox.left + (_boundingBox.width() / 2);
returnValue.setToFloat(centerX);
break;
}
case kGetCenterYMethod: {
+ assert(args.empty());
int centerY = _boundingBox.top + (_boundingBox.height() / 2);
returnValue.setToFloat(centerY);
break;
@@ -213,6 +223,46 @@ ScriptValue SpatialEntity::callMethod(BuiltInMethod methodId, Common::Array<Scri
returnValue.setToBool(isVisible());
break;
+ case kSetMousePositionMethod: {
+ assert(args.size() == 2);
+ int16 x = static_cast<int16>(args[0].asFloat());
+ int16 y = static_cast<int16>(args[1].asFloat());
+ setMousePosition(x, y);
+ break;
+ }
+
+ case kGetXScaleMethod1:
+ case kGetXScaleMethod2:
+ assert(args.empty());
+ returnValue.setToFloat(_scaleX);
+ break;
+
+ case kSetScaleMethod:
+ assert(args.size() == 1);
+ invalidateLocalBounds();
+ _scaleX = _scaleY = args[0].asFloat();
+ invalidateLocalBounds();
+ break;
+
+ case kSetXScaleMethod:
+ assert(args.size() == 1);
+ invalidateLocalBounds();
+ _scaleX = args[0].asFloat();
+ invalidateLocalBounds();
+ break;
+
+ case kGetYScaleMethod:
+ assert(args.empty());
+ returnValue.setToFloat(_scaleY);
+ break;
+
+ case kSetYScaleMethod:
+ assert(args.size() == 1);
+ invalidateLocalBounds();
+ _scaleY = args[0].asFloat();
+ invalidateLocalBounds();
+ break;
+
default:
Actor::callMethod(methodId, args);
}
@@ -237,7 +287,7 @@ void SpatialEntity::readParameter(Chunk &chunk, ActorHeaderSectionType paramType
_hasTransparency = static_cast<bool>(chunk.readTypedByte());
break;
- case kActorHeaderStageId:
+ case kActorHeaderChildActorId:
_stageId = chunk.readTypedUint16();
break;
@@ -245,11 +295,44 @@ void SpatialEntity::readParameter(Chunk &chunk, ActorHeaderSectionType paramType
_actorReference = chunk.readTypedUint16();
break;
+ case kActorHeaderScaleXAndY:
+ _scaleX = _scaleY = chunk.readTypedDouble();
+ break;
+
+ case kActorHeaderScaleX:
+ _scaleX = chunk.readTypedDouble();
+ break;
+
+ case kActorHeaderScaleY:
+ _scaleY = chunk.readTypedDouble();
+ break;
+
default:
Actor::readParameter(chunk, paramType);
}
}
+void SpatialEntity::loadIsComplete() {
+ Actor::loadIsComplete();
+ Actor *pendingParentStageActor = g_engine->getActorById(_stageId);
+ if (pendingParentStageActor == nullptr) {
+ error("%s: Actor %d doesn't exist", __func__, _stageId);
+ } else if (pendingParentStageActor->type() != kActorTypeStage) {
+ error("%s: Requested parent stage %d is not a stage", __func__, _stageId);
+ }
+ StageActor *pendingParentStage = static_cast<StageActor *>(pendingParentStageActor);
+ pendingParentStage->addChildSpatialEntity(this);
+}
+
+void SpatialEntity::invalidateMouse() {
+ // TODO: Invalidate the mouse properly when we have custom events.
+ // For now, we simulate the mouse update event with a mouse moved event.
+ Common::Event mouseEvent;
+ mouseEvent.type = Common::EVENT_MOUSEMOVE;
+ mouseEvent.mouse = g_system->getEventManager()->getMousePos();
+ g_system->getEventManager()->pushEvent(mouseEvent);
+}
+
void SpatialEntity::moveTo(int16 x, int16 y) {
Common::Point dest(x, y);
if (dest == _boundingBox.origin()) {
@@ -264,6 +347,9 @@ void SpatialEntity::moveTo(int16 x, int16 y) {
if (isVisible()) {
invalidateLocalBounds();
}
+ if (interactsWithMouse()) {
+ invalidateMouse();
+ }
}
void SpatialEntity::moveToCentered(int16 x, int16 y) {
@@ -285,6 +371,9 @@ void SpatialEntity::setBounds(const Common::Rect &bounds) {
if (isVisible()) {
invalidateLocalBounds();
}
+ if (interactsWithMouse()) {
+ invalidateMouse();
+ }
}
void SpatialEntity::setZIndex(int zIndex) {
@@ -295,6 +384,15 @@ void SpatialEntity::setZIndex(int zIndex) {
_zIndex = zIndex;
invalidateLocalZIndex();
+ if (interactsWithMouse()) {
+ invalidateMouse();
+ }
+}
+
+void SpatialEntity::setMousePosition(int16 x, int16 y) {
+ if (_parentStage) {
+ _parentStage->setMousePosition(x, y);
+ }
}
void SpatialEntity::setDissolveFactor(double dissolveFactor) {
diff --git a/engines/mediastation/actor.h b/engines/mediastation/actor.h
index 5ad3a64ed2c..151fc0d0f63 100644
--- a/engines/mediastation/actor.h
+++ b/engines/mediastation/actor.h
@@ -22,6 +22,7 @@
#ifndef MEDIASTATION_ACTOR_H
#define MEDIASTATION_ACTOR_H
+#include "common/events.h"
#include "common/keyboard.h"
#include "mediastation/datafile.h"
@@ -62,7 +63,7 @@ enum ActorType {
enum ActorHeaderSectionType {
kActorHeaderEmptySection = 0x0000,
kActorHeaderEventHandler = 0x0017,
- kActorHeaderStageId = 0x0019,
+ kActorHeaderChildActorId = 0x0019,
kActorHeaderActorId = 0x001a,
kActorHeaderChunkReference = 0x001b,
kActorHeaderMovieAnimationChunkReference = 0x06a4,
@@ -85,6 +86,11 @@ enum ActorHeaderSectionType {
kActorHeaderGetOffstageEvents = 0x05dd,
kActorHeaderX = 0x05de,
kActorHeaderY = 0x05df,
+ kActorHeaderScaleXAndY = 0x77a,
+ kActorHeaderScaleX = 0x77c,
+ kActorHeaderScaleY = 0x77d,
+ kActorHeaderUnk0 = 0x7d0,
+ kActorHeaderActorName = 0x0bb8,
// PATH FIELDS.
kActorHeaderStartPoint = 0x060e,
@@ -98,10 +104,9 @@ enum ActorHeaderSectionType {
kActorHeaderLensOpen = 0x0770,
// STAGE FIELDS.
- kActorHeaderStageUnk1 = 0x0771,
+ kActorHeaderStageSize = 0x0771,
kActorHeaderCylindricalX = 0x0772,
kActorHeaderCylindricalY = 0x0773,
- kActorHeaderActorName = 0x0bb8,
// TEXT FIELDS.
kActorHeaderEditable = 0x03eb,
@@ -119,6 +124,34 @@ enum ActorHeaderSectionType {
kActorHeaderCurrentSpriteClip = 0x03ea
};
+class SpatialEntity;
+
+struct MouseActorState {
+ SpatialEntity *keyDown = nullptr;
+ // There is no key up event.
+ SpatialEntity *mouseDown = nullptr;
+ SpatialEntity *mouseUp = nullptr;
+ SpatialEntity *mouseMoved = nullptr;
+ SpatialEntity *mouseExit = nullptr;
+ SpatialEntity *mouseEnter = nullptr;
+ SpatialEntity *mouseOutOfFocus = nullptr;
+};
+
+enum MouseEventFlag {
+ kNoFlag = 0x00,
+ kMouseDownFlag = 0x01,
+ kMouseUpFlag = 0x02,
+ kMouseMovedFlag = 0x04,
+ kMouseExitFlag = 0x10,
+ kMouseEnterFlag = 0x08,
+ kMouseUnk1Flag = 0x20,
+ kMouseOutOfFocusFlag = 0x40,
+ kKeyDownFlag = 0x80,
+ // There is no key up event.
+};
+
+class StageActor;
+
class Actor {
public:
Actor(ActorType type) : _type(type) {};
@@ -134,10 +167,10 @@ public:
virtual void initFromParameterStream(Chunk &chunk);
virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType);
- virtual void loadIsComplete() { _loadIsComplete = true; };
+ virtual void loadIsComplete();
- // These are not pure virtual so if an actor doesnʻt read any chunks or
- // subfiles it doesnʻt need to just implement these with an error message.
+ // These are not pure virtual so if an actor doesn't read any chunks or
+ // subfiles it doesn't need to just implement these with an error message.
virtual void readChunk(Chunk &chunk);
virtual void readSubfile(Subfile &subfile, Chunk &chunk);
@@ -173,28 +206,59 @@ public:
virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) { return; }
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
+ virtual void loadIsComplete() override;
virtual bool isSpatialActor() const override { return true; }
virtual bool isVisible() const { return _isVisible; }
virtual Common::Rect getBbox() const { return _boundingBox; }
int zIndex() const { return _zIndex; }
+ virtual void invalidateMouse();
+ virtual bool interactsWithMouse() const { return false; }
+
+ virtual uint16 findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) { return kNoFlag; }
+ virtual uint16 findActorToAcceptKeyboardEvents(
+ uint16 asciiCode,
+ uint16 eventMask,
+ MouseActorState &state) { return kNoFlag; }
+
+ virtual void mouseDownEvent(const Common::Event &event) { return; }
+ virtual void mouseUpEvent(const Common::Event &event) { return; }
+ virtual void mouseEnteredEvent(const Common::Event &event) { return; }
+ virtual void mouseExitedEvent(const Common::Event &event) { return; }
+ virtual void mouseMovedEvent(const Common::Event &event) { return; }
+ virtual void mouseOutOfFocusEvent(const Common::Event &event) { return; }
+ virtual void keyboardEvent(const Common::Event &event) { return; }
+
+ void setParentStage(StageActor *parentStage) { _parentStage = parentStage; }
+ void setToNoParentStage() { _parentStage = nullptr; }
+ StageActor *getParentStage() const { return _parentStage; }
+
+ virtual void invalidateLocalBounds();
+
protected:
uint _stageId = 0;
int _zIndex = 0;
double _dissolveFactor = 0.0;
+ double _scaleX = 0.0;
+ double _scaleY = 0.0;
Common::Rect _boundingBox;
bool _isVisible = false;
bool _hasTransparency = false;
bool _getOffstageEvents = false;
+ StageActor *_parentStage = nullptr;
void moveTo(int16 x, int16 y);
void moveToCentered(int16 x, int16 y);
void setBounds(const Common::Rect &bounds);
void setZIndex(int zIndex);
+ virtual void setMousePosition(int16 x, int16 y);
virtual void setDissolveFactor(double dissolveFactor);
- virtual void invalidateLocalBounds();
virtual void invalidateLocalZIndex();
};
diff --git a/engines/mediastation/actors/hotspot.cpp b/engines/mediastation/actors/hotspot.cpp
index fcf25bf188c..e2d960537c3 100644
--- a/engines/mediastation/actors/hotspot.cpp
+++ b/engines/mediastation/actors/hotspot.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "mediastation/debugchannels.h"
#include "mediastation/actors/hotspot.h"
#include "mediastation/mediastation.h"
@@ -96,15 +97,13 @@ ScriptValue HotspotActor::callMethod(BuiltInMethod methodId, Common::Array<Scrip
switch (methodId) {
case kMouseActivateMethod: {
assert(args.empty());
- _isActive = true;
- g_engine->_needsHotspotRefresh = true;
+ activate();
return returnValue;
}
case kMouseDeactivateMethod: {
assert(args.empty());
- _isActive = false;
- g_engine->_needsHotspotRefresh = true;
+ deactivate();
return returnValue;
}
@@ -115,13 +114,13 @@ ScriptValue HotspotActor::callMethod(BuiltInMethod methodId, Common::Array<Scrip
}
case kTriggerAbsXPositionMethod: {
- double mouseX = static_cast<double>(g_engine->_mousePos.x);
+ double mouseX = static_cast<double>(g_system->getEventManager()->getMousePos().x);
returnValue.setToFloat(mouseX);
return returnValue;
}
case kTriggerAbsYPositionMethod: {
- double mouseY = static_cast<double>(g_engine->_mousePos.y);
+ double mouseY = static_cast<double>(g_system->getEventManager()->getMousePos().y);
returnValue.setToFloat(mouseY);
return returnValue;
}
@@ -131,4 +130,123 @@ ScriptValue HotspotActor::callMethod(BuiltInMethod methodId, Common::Array<Scrip
}
}
+uint16 HotspotActor::findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool clipMouseEvents) {
+
+ uint16 result = 0;
+ if (isActive()) {
+ if (isInside(point)) {
+ if (eventMask & kMouseDownFlag) {
+ state.mouseDown = this;
+ result |= kMouseDownFlag;
+ }
+
+ if (eventMask & kMouseEnterFlag) {
+ state.mouseEnter = this;
+ result |= kMouseEnterFlag;
+ }
+
+ if (eventMask & kMouseMovedFlag) {
+ state.mouseMoved = this;
+ result |= kMouseMovedFlag;
+ }
+ }
+
+ if (this == g_engine->getMouseInsideHotspot() && (eventMask & kMouseExitFlag)) {
+ state.mouseExit = this;
+ result |= kMouseExitFlag;
+ }
+
+ if (this == g_engine->getMouseDownHotspot() && (eventMask & kMouseUpFlag)) {
+ state.mouseUp = this;
+ result |= kMouseUpFlag;
+ }
+ } else {
+ debugC(5, kDebugEvents, "%s: %d: Inactive", __func__, id());
+ }
+
+ return result;
+}
+
+void HotspotActor::activate() {
+ if (!_isActive) {
+ _isActive = true;
+ invalidateMouse();
+ }
+}
+
+void HotspotActor::deactivate() {
+ if (_isActive) {
+ _isActive = false;
+ if (g_engine->getMouseDownHotspot() == this) {
+ g_engine->setMouseDownHotspot(nullptr);
+ }
+ if (g_engine->getMouseInsideHotspot() == this) {
+ g_engine->setMouseDownHotspot(nullptr);
+ }
+
+ invalidateMouse();
+ }
+}
+
+void HotspotActor::mouseDownEvent(const Common::Event &event) {
+ if (!_isActive) {
+ warning("%s: Called on inactive hotspot", __func__);
+ return;
+ }
+
+ g_engine->setMouseDownHotspot(this);
+ runEventHandlerIfExists(kMouseDownEvent);
+}
+
+void HotspotActor::mouseUpEvent(const Common::Event &event) {
+ if (!_isActive) {
+ warning("%s: Called on inactive hotspot", __func__);
+ return;
+ }
+
+ g_engine->setMouseDownHotspot(nullptr);
+ runEventHandlerIfExists(kMouseUpEvent);
+}
+
+void HotspotActor::mouseEnteredEvent(const Common::Event &event) {
+ if (!_isActive) {
+ warning("%s: Called on inactive hotspot", __func__);
+ return;
+ }
+
+ g_engine->setMouseInsideHotspot(this);
+ if (_cursorResourceId != 0) {
+ debugC(5, kDebugEvents, "%s: Setting cursor %d for asset %d", __func__, _cursorResourceId, id());
+ g_engine->getCursorManager()->setAsTemporary(_cursorResourceId);
+ } else {
+ debugC(5, kDebugEvents, "%s: Unsetting cursor for asset %d", __func__, id());
+ g_engine->getCursorManager()->unsetTemporary();
+ }
+
+ runEventHandlerIfExists(kMouseEnteredEvent);
+}
+
+void HotspotActor::mouseMovedEvent(const Common::Event &event) {
+ if (!_isActive) {
+ warning("%s: Called on inactive hotspot", __func__);
+ return;
+ }
+
+ runEventHandlerIfExists(kMouseMovedEvent);
+}
+
+void HotspotActor::mouseExitedEvent(const Common::Event &event) {
+ if (!_isActive) {
+ warning("%s: Called on inactive hotspot", __func__);
+ return;
+ }
+
+ g_engine->setMouseInsideHotspot(nullptr);
+ runEventHandlerIfExists(kMouseExitedEvent);
+}
+
} // End of namespace MediaStation
diff --git a/engines/mediastation/actors/hotspot.h b/engines/mediastation/actors/hotspot.h
index 790fa5e1b12..44c8654e5d2 100644
--- a/engines/mediastation/actors/hotspot.h
+++ b/engines/mediastation/actors/hotspot.h
@@ -36,10 +36,26 @@ public:
bool isInside(const Common::Point &pointToCheck);
virtual bool isVisible() const override { return false; }
bool isActive() const { return _isActive; }
+ virtual bool interactsWithMouse() const override { return isActive(); }
virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
+ virtual uint16 findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) override;
+
+ void activate();
+ void deactivate();
+
+ virtual void mouseDownEvent(const Common::Event &event) override;
+ virtual void mouseUpEvent(const Common::Event &event) override;
+ virtual void mouseEnteredEvent(const Common::Event &event) override;
+ virtual void mouseExitedEvent(const Common::Event &event) override;
+ virtual void mouseMovedEvent(const Common::Event &event) override;
+
uint _cursorResourceId = 0;
Common::Array<Common::Point> _mouseActiveArea;
diff --git a/engines/mediastation/actors/stage.cpp b/engines/mediastation/actors/stage.cpp
new file mode 100644
index 00000000000..94c2e46b881
--- /dev/null
+++ b/engines/mediastation/actors/stage.cpp
@@ -0,0 +1,509 @@
+/* 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/mediastation.h"
+#include "mediastation/actors/stage.h"
+#include "mediastation/debugchannels.h"
+
+namespace MediaStation {
+
+StageActor::StageActor() : SpatialEntity(kActorTypeStage),
+ _children(StageActor::compareSpatialActorByZIndex) {
+}
+
+StageActor::~StageActor() {
+ removeAllChildren();
+}
+
+void StageActor::readParameter(Chunk &chunk, ActorHeaderSectionType paramType) {
+ switch (paramType) {
+ case kActorHeaderChildActorId: {
+ uint actorId = chunk.readTypedUint16();
+ _pendingChild = g_engine->getSpatialEntityById(actorId);
+ break;
+ }
+
+ case kActorHeaderStageSize: {
+ Common::Point size = chunk.readTypedGraphicSize();
+ _boundingBox.setWidth(size.x);
+ _boundingBox.setHeight(size.y);
+ break;
+ }
+
+ case kActorHeaderCylindricalX:
+ _cylindricalX = static_cast<bool>(chunk.readTypedByte());
+ break;
+
+ case kActorHeaderCylindricalY:
+ _cylindricalY = static_cast<bool>(chunk.readTypedByte());
+ break;
+
+ default:
+ SpatialEntity::readParameter(chunk, paramType);
+ }
+}
+
+void StageActor::draw(const Common::Array<Common::Rect> &dirtyRegion) {
+ for (SpatialEntity *entity : _children) {
+ if (entity->isVisible()) {
+ debugC(5, kDebugGraphics, "%s: Redrawing actor %d", __func__, entity->id());
+ entity->draw(dirtyRegion);
+ }
+ }
+}
+
+void StageActor::invalidateRect(const Common::Rect &rect) {
+ if (_parentStage != nullptr) {
+ Common::Point origin = _boundingBox.origin();
+ Common::Rect rectRelativeToParent = rect;
+ rectRelativeToParent.translate(origin.x, origin.y);
+ _parentStage->invalidateRect(rect);
+ } else {
+ error("%s: Attempt to invalidate rect without a parent stage", __func__);
+ }
+}
+
+void StageActor::loadIsComplete() {
+ Actor::loadIsComplete();
+ if (_pendingChild != nullptr) {
+ addChildSpatialEntity(_pendingChild);
+ _pendingChild = nullptr;
+ }
+}
+
+void StageActor::addActorToStage(uint actorId) {
+ // If actor has a current parent, remove it from that parent first.
+ SpatialEntity *spatialEntity = g_engine->getSpatialEntityById(actorId);
+ StageActor *currentParent = spatialEntity->getParentStage();
+ if (currentParent != nullptr) {
+ currentParent->removeChildSpatialEntity(spatialEntity);
+ }
+ addChildSpatialEntity(spatialEntity);
+}
+
+void StageActor::removeActorFromStage(uint actorId) {
+ SpatialEntity *spatialEntity = g_engine->getSpatialEntityById(actorId);
+ StageActor *currentParent = spatialEntity->getParentStage();
+ if (currentParent == this) {
+ // Remove the actor from this stage, and add it
+ // back to the root stage.
+ removeChildSpatialEntity(spatialEntity);
+ RootStage *rootStage = g_engine->getRootStage();
+ rootStage->addChildSpatialEntity(spatialEntity);
+ }
+}
+
+ScriptValue StageActor::callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) {
+ ScriptValue returnValue;
+ switch (methodId) {
+ case kAddActorToStageMethod: {
+ assert(args.size() == 1);
+ uint actorId = args[0].asActorId();
+ addActorToStage(actorId);
+ return returnValue;
+ }
+
+ case kRemoveActorFromStageMethod: {
+ assert(args.size() == 1);
+ uint actorId = args[0].asActorId();
+ removeActorFromStage(actorId);
+ return returnValue;
+ }
+
+ case kSetBoundsMethod: {
+ assert(args.size() == 4);
+ int16 x = static_cast<int16>(args[0].asFloat());
+ int16 y = static_cast<int16>(args[1].asFloat());
+ int16 width = static_cast<int16>(args[2].asFloat());
+ int16 height = static_cast<int16>(args[3].asFloat());
+ Common::Rect newBounds(Common::Point(x, y), width, height);
+ setBounds(newBounds);
+ return returnValue;
+ }
+
+ case kStageSetSizeMethod:
+ assert(args.size() == 2);
+ _boundingBox.setWidth(static_cast<int16>(args[0].asFloat()));
+ _boundingBox.setHeight(static_cast<int16>(args[1].asFloat()));
+ return returnValue;
+
+ case kStageGetWidthMethod:
+ returnValue.setToFloat(_boundingBox.width());
+ return returnValue;
+
+ case kStageGetHeightMethod:
+ returnValue.setToFloat(_boundingBox.height());
+ return returnValue;
+
+ default:
+ return SpatialEntity::callMethod(methodId, args);
+ }
+}
+
+void StageActor::addChildSpatialEntity(SpatialEntity *entity) {
+ if (!assertHasNoParent(entity)) {
+ error("%s: Attempt to add entity that already has a parent", __func__);
+ }
+
+ entity->setParentStage(this);
+ _children.insert(entity);
+
+ if (isVisible()) {
+ invalidateLocalBounds();
+ }
+}
+
+void StageActor::removeChildSpatialEntity(SpatialEntity *entity) {
+ if (!assertIsMyChild(entity)) {
+ error("%s: Attempt to remove entity that is not a child", __func__);
+ }
+
+ if (isVisible()) {
+ invalidateLocalBounds();
+ }
+
+ entity->setToNoParentStage();
+ for (auto it = _children.begin(); it != _children.end(); ++it) {
+ if (*it == entity) {
+ _children.erase(it);
+ break;
+ }
+ }
+}
+
+uint16 StageActor::findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) {
+
+ debugC(6, kDebugEvents, " --- %s ---", __func__);
+ if (!inBounds) {
+ if (!_boundingBox.contains(point)) {
+ inBounds = true;
+ }
+ }
+
+ uint16 result = 0;
+ Common::Point adjustedPoint = point - _boundingBox.origin();
+ for (auto childIterator = _children.end(); childIterator != _children.begin();) {
+ --childIterator; // Decrement first, then dereference
+ SpatialEntity *child = *childIterator;
+ debugC(7, kDebugEvents, " %s: Checking actor %d (z-index: %d) (eventMask: 0x%02x) (result: 0x%02x)", __func__, child->id(), child->zIndex(), eventMask, result);
+ uint16 handledEvents = child->findActorToAcceptMouseEvents(adjustedPoint, eventMask, state, inBounds);
+
+ eventMask &= ~handledEvents;
+ result |= handledEvents;
+ }
+
+ debugC(6, kDebugEvents, " --- END %s ---", __func__);
+ return result;
+}
+
+uint16 StageActor::findActorToAcceptKeyboardEvents(
+ uint16 asciiCode,
+ uint16 eventMask,
+ MouseActorState &state) {
+
+ uint16 result = 0;
+ for (SpatialEntity *child : _children) {
+ uint16 handledEvents = child->findActorToAcceptKeyboardEvents(asciiCode, eventMask, state);
+ if (handledEvents != 0) {
+ eventMask &= ~handledEvents;
+ result |= handledEvents;
+ }
+ }
+
+ return result;
+}
+
+bool StageActor::assertHasNoParent(const SpatialEntity *entity) {
+ // Make sure entity is not in our children.
+ for (SpatialEntity *child : _children) {
+ if (child == entity) {
+ return false;
+ }
+ }
+
+ // Make sure entity doesn't have a parent.
+ if (entity->getParentStage() != nullptr) {
+ return false;
+ }
+
+ return true;
+}
+
+void StageActor::removeAllChildren() {
+ for (SpatialEntity *child : _children) {
+ child->setToNoParentStage();
+ }
+ _children.clear();
+}
+
+void StageActor::setMousePosition(int16 x, int16 y) {
+ if (_parentStage != nullptr) {
+ x += _boundingBox.left;
+ y += _boundingBox.top;
+ _parentStage->setMousePosition(x, y);
+ }
+}
+
+void StageActor::invalidateLocalBounds() {
+ for (SpatialEntity *child : _children) {
+ if (child->isVisible()) {
+ child->invalidateLocalBounds();
+ }
+ }
+}
+
+void StageActor::invalidateLocalZIndex() {
+ if (_parentStage != nullptr) {
+ _parentStage->invalidateZIndexOf(this);
+ }
+}
+
+void StageActor::invalidateZIndexOf(const SpatialEntity *entity) {
+ if (!assertIsMyChild(entity)) {
+ error("%s: Attempt to invalidate local z-index of non-child", __func__);
+ }
+
+ // Remove the entity from the sorted array and re-insert it at the correct position.
+ for (auto it = _children.begin(); it != _children.end(); ++it) {
+ if (*it == entity) {
+ _children.erase(it);
+ _children.insert(const_cast<SpatialEntity *>(entity));
+ break;
+ }
+ }
+
+ // Mark the whole stage dirty since z-order changed.
+ if (isVisible()) {
+ invalidateLocalBounds();
+ }
+}
+
+int StageActor::compareSpatialActorByZIndex(const SpatialEntity *a, const SpatialEntity *b) {
+ int diff = b->zIndex() - a->zIndex();
+ if (diff < 0)
+ return -1; // a should come before b
+ else if (diff > 0)
+ return 1; // b should come before a
+ else {
+ // If z-indices are equal, compare pointers for stable sort
+ return (a < b) ? -1 : 1;
+ }
+}
+
+void StageActor::currentMousePosition(Common::Point &point) {
+ if (getParentStage() != nullptr) {
+ getParentStage()->currentMousePosition(point);
+ point -= getBbox().origin();
+ }
+}
+
+void RootStage::invalidateRect(const Common::Rect &rect) {
+ Common::Rect rectToAdd = rect;
+ rectToAdd.clip(_boundingBox);
+ _dirtyRegion.push_back(rectToAdd);
+}
+
+void RootStage::currentMousePosition(Common::Point &point) {
+ point = g_engine->getEventManager()->getMousePos();
+ point -= getBbox().origin();
+}
+
+void RootStage::drawAll() {
+ Common::Array<Common::Rect> region;
+ region.push_back(_boundingBox);
+ StageActor::draw(region);
+}
+
+void RootStage::drawDirtyRegion() {
+ if (!_dirtyRegion.empty()) {
+ StageActor::draw(_dirtyRegion);
+ _dirtyRegion.clear();
+ }
+}
+
+uint16 RootStage::findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) {
+
+ // Handle any mouse moved events.
+ uint16 result = StageActor::findActorToAcceptMouseEvents(point, eventMask, state, inBounds);
+ eventMask &= ~result;
+ if (eventMask & kMouseEnterFlag) {
+ state.mouseEnter = this;
+ result |= kMouseEnterFlag;
+ }
+ if (eventMask & kMouseOutOfFocusFlag) {
+ state.mouseOutOfFocus = this;
+ result |= kMouseOutOfFocusFlag;
+ }
+ return result;
+}
+
+void RootStage::mouseEnteredEvent(const Common::Event &event) {
+ _isMouseInside = true;
+ g_engine->getCursorManager()->unsetTemporary();
+}
+
+void RootStage::mouseExitedEvent(const Common::Event &event) {
+ _isMouseInside = false;
+}
+
+void RootStage::mouseOutOfFocusEvent(const Common::Event &event) {
+ _isMouseInside = true;
+ g_engine->getCursorManager()->unsetTemporary();
+}
+
+void RootStage::deleteChildrenFromContextId(uint contextId) {
+ for (auto it = _children.begin(); it != _children.end();) {
+ uint actorContextId = (*it)->contextId();
+ if (actorContextId == contextId) {
+ it = _children.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
+void RootStage::setMousePosition(int16 x, int16 y) {
+ x += _boundingBox.left;
+ y += _boundingBox.top;
+ warning("%s: STUB: (%d, %d)", __func__, x, y);
+}
+
+StageDirector::StageDirector() {
+ _rootStage = new RootStage;
+ Common::Rect rootStageBounds(MediaStationEngine::SCREEN_WIDTH, MediaStationEngine::SCREEN_HEIGHT);
+ _rootStage->setBounds(rootStageBounds);
+ g_engine->registerActor(_rootStage);
+}
+
+StageDirector::~StageDirector() {
+ delete _rootStage;
+ _rootStage = nullptr;
+}
+
+void StageDirector::drawAll() {
+ // TODO: This just passes through for now,
+ // but once the original DisplayContext stuff
+ // is reimplemented, there will be more here.
+ _rootStage->drawAll();
+}
+
+void StageDirector::drawDirtyRegion() {
+ // TODO: This just passes through for now,
+ // but once the original DisplayContext stuff
+ // is reimplemented, there will be more here.
+ _rootStage->drawDirtyRegion();
+}
+
+void StageDirector::clearDirtyRegion() {
+ // TODO: This just passes through for now,
+ // but once the original DisplayContext stuff
+ // is reimplemented, there will be more here.
+ _rootStage->clearDirtyRegion();
+}
+
+void StageDirector::handleKeyboardEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptKeyboardEvents(event.kbd.ascii, kKeyDownFlag, state);
+ if (flags & kKeyDownFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching to actor %d", __func__, state.keyDown->id());
+ state.keyDown->keyboardEvent(event);
+ }
+}
+
+void StageDirector::handleMouseDownEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptMouseEvents(event.mouse, kMouseDownFlag, state, false);
+ if (flags & kMouseDownFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching to actor %d", __func__, state.mouseDown->id());
+ state.mouseDown->mouseDownEvent(event);
+ }
+}
+
+void StageDirector::handleMouseUpEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptMouseEvents(event.mouse, kMouseUpFlag, state, false);
+ if (flags & kMouseUpFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching to actor %d", __func__, state.mouseUp->id());
+ state.mouseUp->mouseUpEvent(event);
+ }
+}
+
+void StageDirector::handleMouseMovedEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptMouseEvents(
+ event.mouse,
+ kMouseEnterFlag | kMouseExitFlag | kMouseMovedFlag,
+ state, false);
+ debugC(5, kDebugEvents, "%s: Calling sendMouseEnterExitEvent", __func__);
+
+ sendMouseEnterExitEvent(flags, state, event);
+ if (flags & kMouseMovedFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching mouse moved to actor %d", __func__, state.mouseMoved->id());
+ state.mouseMoved->mouseMovedEvent(event);
+ }
+}
+
+void StageDirector::handleMouseEnterExitEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptMouseEvents(event.mouse, kMouseEnterFlag | kMouseExitFlag, state, false);
+ sendMouseEnterExitEvent(flags, state, event);
+}
+
+void StageDirector::handleMouseOutOfFocusEvent(const Common::Event &event) {
+ MouseActorState state;
+ uint16 flags = _rootStage->findActorToAcceptMouseEvents(event.mouse, kMouseExitFlag | kMouseOutOfFocusFlag, state, false);
+
+ if (flags & kMouseExitFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching mouse enter to actor %d", __func__, state.mouseExit->id());
+ state.mouseExit->mouseExitedEvent(event);
+ }
+
+ if (flags & kMouseOutOfFocusFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching mouse out of focus to actor %d", __func__, state.mouseOutOfFocus->id());
+ state.mouseOutOfFocus->mouseOutOfFocusEvent(event);
+ }
+}
+
+void StageDirector::sendMouseEnterExitEvent(uint16 flags, MouseActorState &state, const Common::Event &event) {
+ if (state.mouseMoved != state.mouseEnter || state.mouseMoved != state.mouseExit) {
+ if (flags & kMouseEnterFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching mouse enter to actor %d", __func__, state.mouseEnter->id());
+ state.mouseEnter->mouseEnteredEvent(event);
+ }
+
+ if (flags & kMouseExitFlag) {
+ debugC(5, kDebugEvents, "%s: Dispatching mouse exit to actor %d", __func__, state.mouseExit->id());
+ state.mouseExit->mouseExitedEvent(event);
+ }
+ } else {
+ debugC(5, kDebugEvents, "%s: No hotspot to dispatch to", __func__);
+ }
+}
+
+} // End of namespace MediaStation
diff --git a/engines/mediastation/actors/stage.h b/engines/mediastation/actors/stage.h
new file mode 100644
index 00000000000..7c7bf41f770
--- /dev/null
+++ b/engines/mediastation/actors/stage.h
@@ -0,0 +1,140 @@
+/* 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_STAGE_H
+#define MEDIASTATION_STAGE_H
+
+#include "common/events.h"
+
+#include "mediastation/actor.h"
+#include "mediastation/mediascript/scriptvalue.h"
+#include "mediastation/mediascript/scriptconstants.h"
+
+namespace MediaStation {
+
+class StageActor : public SpatialEntity {
+public:
+ StageActor();
+ virtual ~StageActor();
+
+ virtual void draw(const Common::Array<Common::Rect> &dirtyRegion) override;
+ virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
+ virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
+ virtual bool isVisible() const override { return _children.size() > 0; }
+
+ void addChildSpatialEntity(SpatialEntity *entity);
+ void removeChildSpatialEntity(SpatialEntity *entity);
+
+ virtual uint16 findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) override;
+ virtual uint16 findActorToAcceptKeyboardEvents(
+ uint16 asciiCode,
+ uint16 eventMask,
+ MouseActorState &state) override;
+ virtual void currentMousePosition(Common::Point &point);
+ virtual void setMousePosition(int16 x, int16 y) override;
+
+ void invalidateZIndexOf(const SpatialEntity *entity);
+
+protected:
+ bool _cylindricalX = false;
+ bool _cylindricalY = false;
+ SpatialEntity *_pendingChild = nullptr;
+
+ void addActorToStage(uint actorId);
+ void removeActorFromStage(uint actorId);
+
+ bool assertHasNoParent(const SpatialEntity *entity);
+ bool assertHasParentThatIsNotMe(const SpatialEntity *entity) { return !assertIsMyChild(entity); }
+ bool assertIsMyChild(const SpatialEntity *entity) { return this == entity->getParentStage();}
+ void removeAllChildren();
+
+ virtual void invalidateLocalBounds() override;
+ virtual void invalidateLocalZIndex() override;
+ virtual void invalidateRect(const Common::Rect &rect);
+ virtual void loadIsComplete() override;
+
+ static int compareSpatialActorByZIndex(const SpatialEntity *a, const SpatialEntity *b);
+
+ Common::SortedArray<SpatialEntity *, const SpatialEntity *> _children;
+};
+
+class RootStage : public StageActor {
+public:
+ friend class StageDirector;
+ RootStage() : StageActor() { _id = ROOT_STAGE_ACTOR_ID; };
+
+ const Common::Array<Common::Rect> &getDirtyRegion() { return _dirtyRegion; }
+ void clearDirtyRegion() { _dirtyRegion.clear(); }
+
+ virtual uint16 findActorToAcceptMouseEvents(
+ const Common::Point &point,
+ uint16 eventMask,
+ MouseActorState &state,
+ bool inBounds) override;
+ virtual void currentMousePosition(Common::Point &point) override;
+ virtual void setMousePosition(int16 x, int16 y) override;
+ virtual void invalidateRect(const Common::Rect &rect) override;
+ virtual void deleteChildrenFromContextId(uint contextId);
+
+ virtual void mouseEnteredEvent(const Common::Event &event) override;
+ virtual void mouseExitedEvent(const Common::Event &event) override;
+ virtual void mouseOutOfFocusEvent(const Common::Event &event) override;
+
+ void drawAll();
+ void drawDirtyRegion();
+ void invalidateAll();
+
+private:
+ static const uint ROOT_STAGE_ACTOR_ID = 2;
+ Common::Array<Common::Rect> _dirtyRegion;
+ bool _isMouseInside = false;
+};
+
+class StageDirector {
+public:
+ StageDirector();
+ ~StageDirector();
+
+ RootStage *getRootStage() const { return _rootStage; }
+
+ void drawAll();
+ void drawDirtyRegion();
+ void clearDirtyRegion();
+
+ void handleKeyboardEvent(const Common::Event &event);
+ void handleMouseDownEvent(const Common::Event &event);
+ void handleMouseUpEvent(const Common::Event &event);
+ void handleMouseMovedEvent(const Common::Event &event);
+ void handleMouseEnterExitEvent(const Common::Event &event);
+ void handleMouseOutOfFocusEvent(const Common::Event &event);
+ void sendMouseEnterExitEvent(uint16 flags, MouseActorState &state, const Common::Event &event);
+
+private:
+ RootStage *_rootStage = nullptr;
+};
+
+} // End of namespace MediaStation
+
+#endif
diff --git a/engines/mediastation/context.cpp b/engines/mediastation/context.cpp
index 4badc515529..83afb44df82 100644
--- a/engines/mediastation/context.cpp
+++ b/engines/mediastation/context.cpp
@@ -149,9 +149,7 @@ void Context::readDestroyContextData(Chunk &chunk) {
void Context::readDestroyActorData(Chunk &chunk) {
uint actorId = chunk.readTypedUint16();
- // TODO: This really can't be done until we have this reading be part of the
- // engine class, as it was in the original.
- warning("%s: STUB: destroyActor %d", __func__, actorId);
+ g_engine->destroyActor(actorId);
}
void Context::readActorLoadComplete(Chunk &chunk) {
diff --git a/engines/mediastation/graphics.cpp b/engines/mediastation/graphics.cpp
index 451374ea8f5..aa889782f18 100644
--- a/engines/mediastation/graphics.cpp
+++ b/engines/mediastation/graphics.cpp
@@ -33,7 +33,7 @@
namespace MediaStation {
VideoDisplayManager::VideoDisplayManager(MediaStationEngine *vm) : _vm(vm) {
- initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT);
+ initGraphics(MediaStationEngine::SCREEN_WIDTH, MediaStationEngine::SCREEN_HEIGHT);
_screen = new Graphics::Screen();
}
@@ -49,11 +49,11 @@ bool VideoDisplayManager::attemptToReadFromStream(Chunk &chunk, uint sectionType
bool handledParam = true;
switch (sectionType) {
case kVideoDisplayManagerUpdateDirty:
- // TODO: Call RT_DisplayUpdateManager::performUpdateDirty();
+ performUpdateDirty();
break;
case kVideoDisplayManagerUpdateAll:
- // TODO: Call RT_DisplayUpdateManager::performUpdateAll();
+ performUpdateAll();
break;
case kVideoDisplayManagerEffectTransition:
@@ -162,6 +162,14 @@ void VideoDisplayManager::doTransitionOnSync() {
}
}
+void VideoDisplayManager::performUpdateDirty() {
+ g_engine->draw();
+}
+
+void VideoDisplayManager::performUpdateAll() {
+ g_engine->draw(false);
+}
+
void VideoDisplayManager::fadeToBlack(Common::Array<ScriptValue> &args) {
double fadeTime = DEFAULT_FADE_TRANSITION_TIME_IN_SECONDS;
uint startIndex = DEFAULT_PALETTE_TRANSITION_START_INDEX;
diff --git a/engines/mediastation/graphics.h b/engines/mediastation/graphics.h
index cd079cd0d67..5077c1a446b 100644
--- a/engines/mediastation/graphics.h
+++ b/engines/mediastation/graphics.h
@@ -100,10 +100,10 @@ public:
void setTransitionOnSync(Common::Array<ScriptValue> &args) { _scheduledTransitionOnSync = args; }
void doTransitionOnSync();
-private:
- static const uint SCREEN_WIDTH = 640;
- static const uint SCREEN_HEIGHT = 480;
+ void performUpdateDirty();
+ void performUpdateAll();
+private:
MediaStationEngine *_vm = nullptr;
Graphics::Screen *_screen = nullptr;
Graphics::Palette *_registeredPalette = nullptr;
diff --git a/engines/mediastation/mediascript/scriptconstants.cpp b/engines/mediastation/mediascript/scriptconstants.cpp
index 912e2c6c4db..27143d7aabd 100644
--- a/engines/mediastation/mediascript/scriptconstants.cpp
+++ b/engines/mediastation/mediascript/scriptconstants.cpp
@@ -171,8 +171,33 @@ const char *builtInMethodToStr(BuiltInMethod method) {
return "GetWidth";
case kGetHeightMethod:
return "GetHeight";
+ case kGetCenterXMethod:
+ return "GetCenterX";
+ case kGetCenterYMethod:
+ return "GetCenterY";
+ case kGetZCoordinateMethod:
+ return "GetZCoordinate";
+ case kIsPointInsideMethod:
+ return "IsPointInside";
+ case kGetMouseXOffsetMethod:
+ return "GetMouseXOffset";
+ case kGetMouseYOffsetMethod:
+ return "GetMouseYOffset";
case kIsVisibleMethod:
return "IsVisible";
+ case kSetMousePositionMethod:
+ return "SetMousePosition";
+ case kGetXScaleMethod1:
+ case kGetXScaleMethod2:
+ return "GetXScale";
+ case kSetScaleMethod:
+ return "SetScale";
+ case kSetXScaleMethod:
+ return "SetXScale";
+ case kGetYScaleMethod:
+ return "GetYScale";
+ case kSetYScaleMethod:
+ return "SetYScale";
case kMovieResetMethod:
return "MovieReset";
case kSetCurrentClipMethod:
@@ -187,6 +212,10 @@ const char *builtInMethodToStr(BuiltInMethod method) {
return "SetWorldSpaceExtent";
case kSetBoundsMethod:
return "SetBounds";
+ case kStageGetWidthMethod:
+ return "StageGetWidth";
+ case kStageGetHeightMethod:
+ return "StageGetHeight";
case kStopPanMethod:
return "StopPan";
case kViewportMoveToMethod:
diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index 8e19c6ccc57..1c405148260 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -112,8 +112,19 @@ enum BuiltInMethod {
kGetMouseXOffsetMethod = 0x108,
kGetMouseYOffsetMethod = 0x109,
kIsVisibleMethod = 0x10D,
+ kSetMousePositionMethod = 0x129,
+ // It isn't clear what the difference is meant to be
+ // between these two, as the code looks the same for both.
+ kGetXScaleMethod1 = 0x16E,
+ kGetXScaleMethod2 = 0x17E,
+ kSetScaleMethod = 0x16F,
+ kSetXScaleMethod = 0x17F,
+ kGetYScaleMethod = 0x180,
+ kSetYScaleMethod = 0x181,
// HOTSPOT METHODS.
+ // NOTE: IDs 0xD2 and 0xD3 seem to be double-assigned
+ // between two hotspot methods and two stage methods.
kMouseActivateMethod = 0xD2,
kMouseDeactivateMethod = 0xD3,
kTriggerAbsXPositionMethod = 0x141,
@@ -128,8 +139,15 @@ enum BuiltInMethod {
kGetCurrentClipIdMethod = 0xF0,
// STAGE METHODS.
+ // NOTE: IDs 0xD2 and 0xD3 seem to be double-assigned
+ // between two hotspot methods and two stage methods.
+ kAddActorToStageMethod = 0xD2,
+ kRemoveActorFromStageMethod = 0xD3,
kSetWorldSpaceExtentMethod = 0x16B,
kSetBoundsMethod = 0x11F,
+ kStageSetSizeMethod = 0x16B,
+ kStageGetWidthMethod = 0x16C,
+ kStageGetHeightMethod = 0x16D,
// CAMERA METHODS.
kStopPanMethod = 0x15E,
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index e13812d355c..9651f1b817e 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -32,6 +32,7 @@
#include "mediastation/actors/screen.h"
#include "mediastation/actors/palette.h"
#include "mediastation/actors/hotspot.h"
+#include "mediastation/actors/stage.h"
#include "mediastation/mediascript/scriptconstants.h"
namespace MediaStation {
@@ -40,8 +41,7 @@ MediaStationEngine *g_engine;
MediaStationEngine::MediaStationEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
_gameDescription(gameDesc),
- _randomSource("MediaStation"),
- _spatialEntities(MediaStationEngine::compareActorByZIndex) {
+ _randomSource("MediaStation") {
g_engine = this;
_gameDataDir = Common::FSNode(ConfMan.getPath("path"));
@@ -71,20 +71,32 @@ MediaStationEngine::~MediaStationEngine() {
delete _boot;
_boot = nullptr;
+ delete _stageDirector;
+ _stageDirector = nullptr;
+
for (auto it = _loadedContexts.begin(); it != _loadedContexts.end(); ++it) {
delete it->_value;
}
_loadedContexts.clear();
- // Delete the document actor. The rest are deleted from their contexts.
- delete _actors[0];
+ // Only delete the document actor.
+ // The root stage is deleted from stage director, and
+ // the other actors are deleted from their contexts.
+ delete _actors.getVal(1);
+ _actors.clear();
}
Actor *MediaStationEngine::getActorById(uint actorId) {
- for (auto actor : _actors) {
- if (actor->id() == actorId) {
- return actor;
+ return _actors.getValOrDefault(actorId);
+}
+
+SpatialEntity *MediaStationEngine::getSpatialEntityById(uint spatialEntityId){
+ Actor *actor = getActorById(spatialEntityId);
+ if (actor != nullptr) {
+ if (!actor->isSpatialActor()) {
+ error("%s: Actor %d is not a spatial actor", __func__, spatialEntityId);
}
+ return static_cast<SpatialEntity *>(actor);
}
return nullptr;
}
@@ -133,12 +145,17 @@ bool MediaStationEngine::isFirstGenerationEngine() {
}
}
+void MediaStationEngine::addDirtyRect(const Common::Rect &rect) {
+ getRootStage()->invalidateRect(rect);
+}
+
Common::Error MediaStationEngine::run() {
initDisplayManager();
initCursorManager();
initFunctionManager();
initDocument();
initDeviceOwner();
+ initStageDirector();
Common::Path bootStmFilepath = Common::Path("BOOT.STM");
_boot = new Boot(bootStmFilepath);
@@ -173,13 +190,8 @@ Common::Error MediaStationEngine::run() {
}
debugC(5, kDebugGraphics, "***** START SCREEN UPDATE ***");
- for (Actor *actor : _actors) {
- actor->process();
-
- if (_needsHotspotRefresh) {
- refreshActiveHotspot();
- _needsHotspotRefresh = false;
- }
+ for (auto it = _actors.begin(); it != _actors.end(); ++it) {
+ it->_value->process();
}
draw();
debugC(5, kDebugGraphics, "***** END SCREEN UPDATE ***");
@@ -217,7 +229,7 @@ void MediaStationEngine::initDocument() {
_parameterClients.push_back(_document);
DocumentActor *documentActor = new DocumentActor;
- _actors.push_back(documentActor);
+ registerActor(documentActor);
}
void MediaStationEngine::initDeviceOwner() {
@@ -225,6 +237,10 @@ void MediaStationEngine::initDeviceOwner() {
_parameterClients.push_back(_deviceOwner);
}
+void MediaStationEngine::initStageDirector() {
+ _stageDirector = new StageDirector;
+}
+
void MediaStationEngine::processEvents() {
while (g_system->getEventManager()->pollEvent(_event)) {
debugC(9, kDebugEvents, "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
@@ -232,92 +248,46 @@ void MediaStationEngine::processEvents() {
debugC(9, kDebugEvents, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
switch (_event.type) {
- case Common::EVENT_QUIT: {
- // TODO: Do any necessary clean-up.
- return;
- }
+ case Common::EVENT_MOUSEMOVE:
+ _stageDirector->handleMouseMovedEvent(_event);
+ break;
- case Common::EVENT_MOUSEMOVE: {
- _mousePos = g_system->getEventManager()->getMousePos();
- _needsHotspotRefresh = true;
+ case Common::EVENT_KEYDOWN:
+ _stageDirector->handleKeyboardEvent(_event);
break;
- }
- case Common::EVENT_KEYDOWN: {
- // Even though this is a keydown event, we need to look at the mouse position.
- Actor *hotspot = findActorToAcceptMouseEvents();
- if (hotspot != nullptr) {
- debugC(1, kDebugEvents, "EVENT_KEYDOWN (%d): Sent to hotspot %d", _event.kbd.ascii, hotspot->id());
- ScriptValue keyCode;
- keyCode.setToFloat(_event.kbd.ascii);
- hotspot->runEventHandlerIfExists(kKeyDownEvent, keyCode);
- }
+ case Common::EVENT_LBUTTONDOWN:
+ _stageDirector->handleMouseDownEvent(_event);
break;
- }
- case Common::EVENT_LBUTTONDOWN: {
- Actor *hotspot = findActorToAcceptMouseEvents();
- if (hotspot != nullptr) {
- debugC(1, kDebugEvents, "EVENT_LBUTTONDOWN (%d, %d): Sent to hotspot %d", _mousePos.x, _mousePos.y, hotspot->id());
- hotspot->runEventHandlerIfExists(kMouseDownEvent);
- }
+ case Common::EVENT_LBUTTONUP:
+ _stageDirector->handleMouseUpEvent(_event);
break;
- }
- case Common::EVENT_RBUTTONDOWN: {
+ case Common::EVENT_FOCUS_LOST:
+ _stageDirector->handleMouseOutOfFocusEvent(_event);
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
// We are using the right button as a quick exit since the Media
// Station engine doesn't seem to use the right button itself.
warning("%s: EVENT_RBUTTONDOWN: Quitting for development purposes", __func__);
quitGame();
break;
- }
default:
+ // Avoid warnings about unimplemented cases by having an explicit
+ // default case.
break;
}
}
}
-void MediaStationEngine::refreshActiveHotspot() {
- Actor *actor = findActorToAcceptMouseEvents();
- if (actor != nullptr && actor->type() != kActorTypeHotspot) {
- return;
- }
- HotspotActor *hotspot = static_cast<HotspotActor *>(actor);
- if (hotspot != _currentHotspot) {
- if (_currentHotspot != nullptr) {
- _currentHotspot->runEventHandlerIfExists(kMouseExitedEvent);
- debugC(5, kDebugEvents, "refreshActiveHotspot(): (%d, %d): Exited hotspot %d", _mousePos.x, _mousePos.y, _currentHotspot->id());
- }
- _currentHotspot = hotspot;
- if (hotspot != nullptr) {
- debugC(5, kDebugEvents, "refreshActiveHotspot(): (%d, %d): Entered hotspot %d", _mousePos.x, _mousePos.y, hotspot->id());
- _cursorManager->setAsTemporary(hotspot->_cursorResourceId);
- hotspot->runEventHandlerIfExists(kMouseEnteredEvent);
- } else {
- // There is no hotspot, so set the default cursor for this screen instead.
- _cursorManager->unsetTemporary();
- }
- }
-
- if (hotspot != nullptr) {
- debugC(5, kDebugEvents, "refreshActiveHotspot(): (%d, %d): Sent to hotspot %d", _mousePos.x, _mousePos.y, hotspot->id());
- hotspot->runEventHandlerIfExists(kMouseMovedEvent);
- }
-}
-
-void MediaStationEngine::draw() {
- if (!_dirtyRects.empty()) {
- for (Actor *actor : _spatialEntities) {
- if (actor->isSpatialActor()) {
- SpatialEntity *entity = static_cast<SpatialEntity *>(actor);
- if (entity->isVisible()) {
- entity->draw(_dirtyRects);
- }
- }
- }
-
- _dirtyRects.clear();
+void MediaStationEngine::draw(bool dirtyOnly) {
+ if (dirtyOnly) {
+ _stageDirector->drawDirtyRegion();
+ } else {
+ _stageDirector->drawAll();
}
_displayManager->updateScreen();
_displayManager->doTransitionOnSync();
@@ -369,10 +339,16 @@ void MediaStationEngine::registerActor(Actor *actorToAdd) {
if (getActorById(actorToAdd->id())) {
error("%s: Actor with ID 0x%d was already defined in this title", __func__, actorToAdd->id());
}
+ _actors.setVal(actorToAdd->id(), actorToAdd);
+}
- _actors.push_back(actorToAdd);
- if (actorToAdd->isSpatialActor()) {
- _spatialEntities.insert(static_cast<SpatialEntity *>(actorToAdd));
+void MediaStationEngine::destroyActor(uint actorId) {
+ Actor *actorToDestroy = getActorById(actorId);
+ if (actorToDestroy) {
+ _actors.erase(actorId);
+ // The actor will actually be deleted when the context is destroyed.
+ } else {
+ warning("%s: Actor %d is not currently loaded", __func__, actorId);
}
}
@@ -391,7 +367,6 @@ void MediaStationEngine::doBranchToScreen() {
}
_currentContext = loadContext(_requestedScreenBranchId);
- _currentHotspot = nullptr;
if (_currentContext->_screenActor != nullptr) {
_currentContext->_screenActor->runEventHandlerIfExists(kEntryEvent);
@@ -418,63 +393,29 @@ void MediaStationEngine::releaseContext(uint32 contextId) {
}
}
- for (auto it = _actors.begin(); it != _actors.end();) {
- uint actorContextId = (*it)->contextId();
+ // Collect actors to remove first, then delete them.
+ // This is necessary because calling erase on a hashmap invalidates
+ // the iterators, so collecting them all first makes more sense.
+ Common::Array<uint> actorsToRemove;
+ for (auto it = _actors.begin(); it != _actors.end(); ++it) {
+ uint actorContextId = it->_value->contextId();
if (actorContextId == contextId) {
- it = _actors.erase(it);
- } else {
- ++it;
+ actorsToRemove.push_back(it->_key);
}
}
- for (auto it = _spatialEntities.begin(); it != _spatialEntities.end();) {
- uint actorContextId = (*it)->contextId();
- if (actorContextId == contextId) {
- it = _spatialEntities.erase(it);
- } else {
- ++it;
- }
+ // Now remove the collected actors.
+ for (uint actorId : actorsToRemove) {
+ _actors.erase(actorId);
}
+ getRootStage()->deleteChildrenFromContextId(contextId);
_functionManager->deleteFunctionsForContext(contextId);
delete context;
_loadedContexts.erase(contextId);
}
-Actor *MediaStationEngine::findActorToAcceptMouseEvents() {
- Actor *intersectingActor = nullptr;
- // The z-indices seem to be reversed, so the highest z-index number is
- // actually the lowest actor.
- int lowestZIndex = INT_MAX;
-
- for (Actor *actor : _actors) {
- if (actor->type() == kActorTypeHotspot) {
- HotspotActor *hotspot = static_cast<HotspotActor *>(actor);
- debugC(5, kDebugGraphics, "findActorToAcceptMouseEvents(): Hotspot %d (z-index %d)", hotspot->id(), hotspot->zIndex());
- if (hotspot->isActive() && hotspot->isInside(_mousePos)) {
- if (hotspot->zIndex() < lowestZIndex) {
- lowestZIndex = hotspot->zIndex();
- intersectingActor = actor;
- }
- }
- }
- }
- return intersectingActor;
-}
-
-int MediaStationEngine::compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b) {
- int diff = b->zIndex() - a->zIndex();
- if (diff < 0)
- return -1; // a should come before b
- else if (diff > 0)
- return 1; // b should come before a
- else {
- // If z-indices are equal, compare pointers for stable sort
- return (a < b) ? -1 : 1;
- }
-}
-
void MediaStationEngine::readUnrecognizedFromStream(Chunk &chunk, uint sectionType) {
bool paramHandled = false;
for (ParameterClient *client : g_engine->_parameterClients) {
diff --git a/engines/mediastation/mediastation.h b/engines/mediastation/mediastation.h
index e69ee8b2a13..c32aa0f2eb7 100644
--- a/engines/mediastation/mediastation.h
+++ b/engines/mediastation/mediastation.h
@@ -44,11 +44,13 @@
#include "mediastation/cursors.h"
#include "mediastation/graphics.h"
#include "mediastation/mediascript/function.h"
+#include "mediastation/actors/stage.h"
namespace MediaStation {
struct MediaStationGameDescription;
class HotspotActor;
+class RootStage;
class Bitmap;
// Most Media Station titles follow this file structure from the root directory
@@ -80,31 +82,42 @@ public:
bool isFirstGenerationEngine();
void processEvents();
- void refreshActiveHotspot();
- void addDirtyRect(const Common::Rect &rect) { _dirtyRects.push_back(rect); }
- void draw();
+ void addDirtyRect(const Common::Rect &rect);
+ void draw(bool dirtyOnly = true);
void registerActor(Actor *actorToAdd);
+ void destroyActor(uint actorId);
+
void scheduleScreenBranch(uint screenId);
void scheduleContextRelease(uint contextId);
void readUnrecognizedFromStream(Chunk &chunk, uint sectionType);
void releaseContext(uint32 contextId);
Actor *getActorById(uint actorId);
+ SpatialEntity *getSpatialEntityById(uint spatialEntityId);
Actor *getActorByChunkReference(uint chunkReference);
ScriptValue *getVariable(uint variableId);
VideoDisplayManager *getDisplayManager() { return _displayManager; }
CursorManager *getCursorManager() { return _cursorManager; }
FunctionManager *getFunctionManager() { return _functionManager; }
+ RootStage *getRootStage() { return _stageDirector->getRootStage(); }
Common::Array<ParameterClient *> _parameterClients;
+ SpatialEntity *getMouseInsideHotspot() { return _mouseInsideHotspot; }
+ void setMouseInsideHotspot(SpatialEntity *entity) { _mouseInsideHotspot = entity; }
+ void clearMouseInsideHotspot() { _mouseInsideHotspot = nullptr; }
+
+ SpatialEntity *getMouseDownHotspot() { return _mouseDownHotspot; }
+ void setMouseDownHotspot(SpatialEntity *entity) { _mouseDownHotspot = entity; }
+ void clearMouseDownHotspot() { _mouseDownHotspot = nullptr; }
+
Common::RandomSource _randomSource;
Context *_currentContext = nullptr;
- Common::Point _mousePos;
- bool _needsHotspotRefresh = false;
+ static const uint SCREEN_WIDTH = 640;
+ static const uint SCREEN_HEIGHT = 480;
protected:
Common::Error run() override;
@@ -113,19 +126,19 @@ private:
Common::Event _event;
Common::FSNode _gameDataDir;
const ADGameDescription *_gameDescription;
- Common::Array<Common::Rect> _dirtyRects;
VideoDisplayManager *_displayManager = nullptr;
CursorManager *_cursorManager = nullptr;
FunctionManager *_functionManager = nullptr;
Document *_document = nullptr;
DeviceOwner *_deviceOwner = nullptr;
+ StageDirector *_stageDirector = nullptr;
Boot *_boot = nullptr;
- Common::Array<Actor *> _actors;
- Common::SortedArray<SpatialEntity *, const SpatialEntity *> _spatialEntities;
+ Common::HashMap<uint, Actor *> _actors;
Common::HashMap<uint, Context *> _loadedContexts;
- Actor *_currentHotspot = nullptr;
+ SpatialEntity *_mouseInsideHotspot = nullptr;
+ SpatialEntity *_mouseDownHotspot = nullptr;
uint _requestedScreenBranchId = 0;
Common::Array<uint> _requestedContextReleaseId;
@@ -134,12 +147,10 @@ private:
void initFunctionManager();
void initDocument();
void initDeviceOwner();
+ void initStageDirector();
void doBranchToScreen();
Context *loadContext(uint32 contextId);
- Actor *findActorToAcceptMouseEvents();
-
- static int compareActorByZIndex(const SpatialEntity *a, const SpatialEntity *b);
};
extern MediaStationEngine *g_engine;
diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index 3b5921a7a55..7823a91d258 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -13,6 +13,7 @@ MODULE_OBJS = \
actors/screen.o \
actors/sound.o \
actors/sprite.o \
+ actors/stage.o \
actors/text.o \
actors/timer.o \
audio.o \
More information about the Scummvm-git-logs
mailing list