aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp38
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.h5
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes0.cpp58
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes0.h2
4 files changed, 62 insertions, 41 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 4cfcc29d24..a06899fe5a 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -1623,7 +1623,7 @@ AnimationPlayer::AnimationPlayer(): EventHandler() {
_screenBounds = R2_GLOBALS._gfxManagerInstance._bounds;
_rect1 = R2_GLOBALS._gfxManagerInstance._bounds;
- _paletteMode = 0;
+ _paletteMode = ANIMPALMODE_REPLACE_PALETTE;
_field3A = 1;
_sliceHeight = 1;
_field58 = 1;
@@ -1709,7 +1709,7 @@ bool AnimationPlayer::load(int animId, Action *endAction) {
debugC(1, ktSageDebugGraphics, "Data needed %d", _dataNeeded);
- // Set up animation data array
+ // Set up animation data objects
_animData1 = new AnimationData();
_sliceCurrent = _animData1;
@@ -1737,21 +1737,25 @@ bool AnimationPlayer::load(int animId, Action *endAction) {
// Handle starting palette
switch (_paletteMode) {
- case 0:
- // Use existing active palette
+ case ANIMPALMODE_REPLACE_PALETTE:
+ // Use the palette provided with the animation directly
_palette.getPalette();
for (int idx = _subData._palStart; idx < (_subData._palStart + _subData._palSize); ++idx) {
- uint r, g, b;
- _palette.getEntry(idx, &r, &g, &b);
+ byte r = _subData._palData[idx * 3];
+ byte g = _subData._palData[idx * 3 + 1];
+ byte b = _subData._palData[idx * 3 + 2];
+
R2_GLOBALS._scenePalette.setEntry(idx, r, g, b);
}
R2_GLOBALS._sceneManager._hasPalette = true;
break;
- case 2:
+ case ANIMPALMODE_NONE:
break;
default:
+ // ANIMPALMODE_CURR_PALETTE
+ // Use the closest matching colours in the currently active palette to those specified in the animation
for (int idx = _subData._palStart; idx < (_subData._palStart + _subData._palSize); ++idx) {
byte r = _subData._palData[idx * 3];
byte g = _subData._palData[idx * 3 + 1];
@@ -1858,12 +1862,26 @@ void AnimationPlayer::drawFrame(int sliceIndex) {
break;
}
- if (_field56 == 42) {
+ // Unlock the screen surface
+ R2_GLOBALS._screenSurface.unlockSurface();
+
+ if (_objectMode == 42) {
_screenBounds.expandPanes();
+
+ // Copy the drawn frame to the back surface
+ Rect srcRect = R2_GLOBALS._screenSurface.getBounds();
+ Rect destRect = srcRect;
+ destRect.translate(-g_globals->_sceneOffset.x, -g_globals->_sceneOffset.y);
+ R2_GLOBALS._sceneManager._scene->_backSurface.copyFrom(R2_GLOBALS._screenSurface,
+ srcRect, destRect);
+
+ // Draw any objects into the scene
R2_GLOBALS._sceneObjects->draw();
} else {
- if (R2_GLOBALS._sceneManager._hasPalette)
+ if (R2_GLOBALS._sceneManager._hasPalette) {
+ R2_GLOBALS._sceneManager._hasPalette = false;
R2_GLOBALS._scenePalette.refresh();
+ }
}
}
@@ -1916,7 +1934,7 @@ void AnimationPlayer::close() {
// Close the resource file
_resourceFile.close();
- if (_field56 != 42) {
+ if (_objectMode != 42) {
// flip screen in original
}
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index b63c0ac2a7..0b573bf7f0 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -375,6 +375,9 @@ public:
int _animSlicesSize;
};
+enum AnimationPaletteMode { ANIMPALMODE_REPLACE_PALETTE = 0, ANIMPALMODE_CURR_PALETTE = 1,
+ ANIMPALMODE_NONE = 2 };
+
class AnimationPlayer: public EventHandler {
private:
void rleDecode(const byte *pSrc, byte *pDest, int size);
@@ -390,7 +393,7 @@ public:
Rect _rect1, _screenBounds;
int _field38;
int _field3A, _paletteMode;
- int _field56;
+ int _objectMode;
int _field58, _sliceHeight;
byte _palIndexes[256];
ScenePalette _palette;
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
index 94a119338a..4c98fcf00a 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp
@@ -1549,18 +1549,18 @@ void Scene180::signal() {
switch (_sceneMode++) {
case 0:
- setFrameInc(6);
+ setSceneDelay(6);
break;
case 1:
_field412 = 1;
R2_GLOBALS._sceneManager._hasPalette = true;
- _animationPlayer._paletteMode = 2;
+ _animationPlayer._paletteMode = ANIMPALMODE_NONE;
_animationPlayer._v = 1;
- _animationPlayer._field56 = 1;
+ _animationPlayer._objectMode = 1;
R2_GLOBALS._scene180Mode = 1;
- _animationPlayer.load(1, NULL);
+ _animationPlayer.load(1);
R2_GLOBALS._scenePalette.loadPalette(_animationPlayer._subData._palData, 0, 256);
R2_GLOBALS._sound1.play(1);
@@ -1571,9 +1571,9 @@ void Scene180::signal() {
R2_GLOBALS._paneRefreshFlag[0] = 3;
if (R2_GLOBALS._sound1.isPlaying()) {
- setFrameInc(1);
+ setSceneDelay(1);
} else {
- setFrameInc(180);
+ setSceneDelay(180);
}
break;
@@ -1583,7 +1583,7 @@ void Scene180::signal() {
if (R2_GLOBALS._sound1.isPlaying())
_sceneMode = 3;
- setFrameInc(1);
+ setSceneDelay(1);
break;
case 4:
@@ -1598,9 +1598,9 @@ void Scene180::signal() {
break;
case 5:
- _animationPlayer._paletteMode = 2;
+ _animationPlayer._paletteMode = ANIMPALMODE_NONE;
_animationPlayer._v = 1;
- _animationPlayer._field56 = 1;
+ _animationPlayer._objectMode = 1;
R2_GLOBALS._scene180Mode = 2;
_animationPlayer.load(2);
@@ -1614,9 +1614,9 @@ void Scene180::signal() {
R2_GLOBALS._paneRefreshFlag[0] = 3;
if (R2_GLOBALS._sound1.isPlaying()) {
- setFrameInc(1);
+ setSceneDelay(1);
} else {
- setFrameInc(180);
+ setSceneDelay(180);
}
break;
@@ -1625,19 +1625,19 @@ void Scene180::signal() {
R2_GLOBALS._scene180Mode = 2;
if (R2_GLOBALS._sound1.isPlaying())
_sceneMode = 7;
- setFrameInc(1);
+ setSceneDelay(1);
break;
case 9:
R2_GLOBALS._sound1.play(3);
clearScreen();
- setFrameInc(2);
+ setSceneDelay(2);
break;
case 10:
loadScene(4002);
R2_GLOBALS._scenePalette.loadPalette(0);
- setFrameInc(6);
+ setSceneDelay(6);
break;
case 11:
@@ -1656,7 +1656,7 @@ void Scene180::signal() {
case 24:
case 26:
case 46:
- setFrameInc((R2_GLOBALS._speechSubtitles & 1) ? 1 : 18);
+ setSceneDelay((R2_GLOBALS._speechSubtitles & 1) ? 1 : 18);
break;
case 13:
@@ -1691,7 +1691,7 @@ void Scene180::signal() {
_field412 = 0;
_object4.remove();
_object5.remove();
- setFrameInc(2);
+ setSceneDelay(2);
break;
case 28:
@@ -1703,9 +1703,9 @@ void Scene180::signal() {
case 29:
_field412 = 1;
- _animationPlayer._paletteMode = 0;
+ _animationPlayer._paletteMode = ANIMPALMODE_REPLACE_PALETTE;
_animationPlayer._v = 1;
- _animationPlayer._field56 = 42;
+ _animationPlayer._objectMode = 42;
R2_GLOBALS._scene180Mode = 3;
_animationPlayer.load(3);
break;
@@ -1727,7 +1727,7 @@ void Scene180::signal() {
if (R2_GLOBALS._sceneManager._hasPalette)
R2_GLOBALS._scenePalette.refresh();
- setFrameInc(6);
+ setSceneDelay(6);
break;
case 32:
@@ -1799,19 +1799,19 @@ void Scene180::signal() {
case 39:
R2_GLOBALS._sound1.changeSound(8);
- setFrameInc(1);
+ setSceneDelay(1);
break;
case 40:
- _animationPlayer._paletteMode = 2;
- _animationPlayer._field56 = 1;
+ _animationPlayer._paletteMode = ANIMPALMODE_NONE;
+ _animationPlayer._objectMode = 1;
R2_GLOBALS._scene180Mode = 4;
if (_animationPlayer.load(4)) {
_animationPlayer.dispatch();
R2_GLOBALS._scenePalette.addFader(_animationPlayer._subData._palData, 256, 8, this);
} else {
_sceneMode = 43;
- setFrameInc(1);
+ setSceneDelay(1);
}
break;
@@ -1823,7 +1823,7 @@ void Scene180::signal() {
case 42:
R2_GLOBALS._scene180Mode = 4;
R2_GLOBALS._paneRefreshFlag[0] = 3;
- setFrameInc(1);
+ setSceneDelay(1);
break;
case 44:
@@ -1832,7 +1832,7 @@ void Scene180::signal() {
if (R2_GLOBALS._sceneManager._hasPalette)
R2_GLOBALS._scenePalette.refresh();
- setFrameInc(6);
+ setSceneDelay(6);
break;
case 45:
@@ -1841,9 +1841,9 @@ void Scene180::signal() {
case 48:
_field412 = 1;
- _animationPlayer._paletteMode = 2;
+ _animationPlayer._paletteMode = ANIMPALMODE_NONE;
_animationPlayer._v = 1;
- _animationPlayer._field56 = 1;
+ _animationPlayer._objectMode = 1;
R2_GLOBALS._scene180Mode = 15;
_animationPlayer.load(15, NULL);
@@ -1854,7 +1854,7 @@ void Scene180::signal() {
case 49:
R2_GLOBALS._scene180Mode = 15;
R2_GLOBALS._paneRefreshFlag[0] = 3;
- setFrameInc(1);
+ setSceneDelay(1);
break;
case 50:
@@ -1865,7 +1865,7 @@ void Scene180::signal() {
}
}
-void Scene180::setFrameInc(int v) {
+void Scene180::setSceneDelay(int v) {
_frameInc = v;
_frameNumber = R2_GLOBALS._events.getFrameNumber();
}
diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h
index e39efbca3d..2f52f9578f 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes0.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes0.h
@@ -195,7 +195,7 @@ class Scene180: public SceneExt {
void signal();
};
private:
- void setFrameInc(int v);
+ void setSceneDelay(int v);
public:
SpeakerWebbster _webbsterSpeaker;
SpeakerDutyOfficer _dutyOfficerSpeaker;