diff options
Diffstat (limited to 'engines/tsage/ringworld2')
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 68 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.h | 2 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes0.cpp | 60 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes0.h | 4 |
4 files changed, 102 insertions, 32 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 6dabbbc368..c98d40edb5 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -339,8 +339,7 @@ void SceneExt::postInit(SceneObjectList *OwnerList) { int sceneNumber = R2_GLOBALS._sceneManager._sceneNumber; if (((prevScene == -1) && (sceneNumber != 180) && (sceneNumber != 205) && (sceneNumber != 50)) || (sceneNumber == 50) - || ((prevScene == 205) && (sceneNumber == 100)) - || ((prevScene == 180) && (sceneNumber == 100))) { + || ((sceneNumber == 100) && (prevScene == 0 || prevScene == 180 || prevScene == 205))) { static_cast<SceneHandlerExt *>(R2_GLOBALS._sceneHandler)->setupPaletteMaps(); R2_GLOBALS._uiElements._active = true; R2_GLOBALS._uiElements.show(); @@ -425,12 +424,12 @@ bool SceneExt::display(CursorType action, Event &event) { R2_GLOBALS._sound4.stop(); R2_GLOBALS._sound3.play(46); SceneItem::display2(5, 15); + + R2_GLOBALS._sound4.play(45); } else { R2_GLOBALS._sound3.play(43, 0); SceneItem::display2(2, R2_SONIC_STUNNER); } - - R2_GLOBALS._sound4.play(45); break; case R2_COM_SCANNER: case R2_COM_SCANNER_2: @@ -596,11 +595,32 @@ void SceneHandlerExt::process(Event &event) { SceneHandler::process(event); } +void SceneHandlerExt::postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad) { + if (priorSceneBeforeLoad == -1 || priorSceneBeforeLoad == 50 + || priorSceneBeforeLoad == 180 || priorSceneBeforeLoad == 205) + setupPaletteMaps(); + + if (currentSceneBeforeLoad == 2900) { + R2_GLOBALS._gfxFontNumber = 50; + R2_GLOBALS._gfxColors.background = 0; + R2_GLOBALS._gfxColors.foreground = 59; + R2_GLOBALS._fontColors.background = 4; + R2_GLOBALS._fontColors.foreground = 15; + R2_GLOBALS._frameEdgeColour = 2; + + R2_GLOBALS._scenePalette.loadPalette(0); + R2_GLOBALS._scenePalette.setEntry(255, 0xff, 0xff, 0xff); + R2_GLOBALS._fadePaletteFlag = false; + setupPaletteMaps(); + } +} + void SceneHandlerExt::setupPaletteMaps() { byte *palP = &R2_GLOBALS._scenePalette._palette[0]; - if (!R2_GLOBALS._v1000Flag) { - R2_GLOBALS._v1000Flag = true; + // Set up the mapping table for giving faded versions of pixels at different fade percentages + if (!R2_GLOBALS._fadePaletteFlag) { + R2_GLOBALS._fadePaletteFlag = true; for (int idx = 0; idx < 10; ++idx) { for (int palIndex = 0; palIndex < 224; ++palIndex) { @@ -650,7 +670,7 @@ void SceneHandlerExt::setupPaletteMaps() { foundIndex = pIndex2; } - R2_GLOBALS._palIndexList[idx][palIndex] = foundIndex; + R2_GLOBALS._fadePaletteMap[idx][palIndex] = foundIndex; } } } @@ -660,8 +680,8 @@ void SceneHandlerExt::setupPaletteMaps() { int g = palP[palIndex * 3 + 1] >> 2; int b = palP[palIndex * 3 + 2] >> 2; - int idx = (((r << 4) | g) << 4) | b; - R2_GLOBALS._v1000[idx] = palIndex; + int v = (r << 8) | (g << 4) | b; + R2_GLOBALS._paletteMap[v] = palIndex; } int vdx = 0; @@ -669,9 +689,9 @@ void SceneHandlerExt::setupPaletteMaps() { int palIndex = 224; for (int vIndex = 0; vIndex < 4096; ++vIndex) { - int v = R2_GLOBALS._v1000[vIndex]; + int v = R2_GLOBALS._paletteMap[vIndex]; if (!v) { - R2_GLOBALS._v1000[vIndex] = idx; + R2_GLOBALS._paletteMap[vIndex] = idx; } else { idx = v; } @@ -1259,6 +1279,32 @@ bool SceneActor::startAction(CursorType action, Event &event) { return handled; } +GfxSurface SceneActor::getFrame() { + GfxSurface frame = SceneObject::getFrame(); + + // TODO: Proper effects handling + switch (_effect) { + case 0: + case 5: + // TODO: Figure out purpose of setting image flags to 64, and getting + // scene priorities -1 or _shade + break; + case 1: + // TODO: Transposing using R2_GLOBALS._pixelArrayMap + break; + case 2: + // No effect + break; + case 4: + break; + default: + // TODO: Default effect + break; + } + + return frame; +} + /*--------------------------------------------------------------------------*/ SceneArea::SceneArea(): EventHandler() { diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 2e7dd64fa2..42ca071e33 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -114,6 +114,7 @@ class SceneHandlerExt: public SceneHandler { public: virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void process(Event &event); + virtual void postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad); void setupPaletteMaps(); }; @@ -265,6 +266,7 @@ public: virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void remove(); virtual bool startAction(CursorType action, Event &event); + virtual GfxSurface getFrame(); }; class SceneActorExt: public SceneActor { diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index 634ecf3ddb..92e92ea578 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -226,9 +226,9 @@ bool Scene100::Terminal::startAction(CursorType action, Event &event) { /*--------------------------------------------------------------------------*/ void Scene100::postInit(SceneObjectList *OwnerList) { - SceneExt::postInit(); loadScene(100); R2_GLOBALS._scenePalette.loadPalette(0); + SceneExt::postInit(); if (R2_GLOBALS._sceneManager._previousScene != 125) R2_GLOBALS._sound1.play(10); @@ -5345,20 +5345,6 @@ void Scene525::signal() { * *--------------------------------------------------------------------------*/ -Scene600::Scene600() { - _field412 = 0; - for (int i = 0; i < 256; i++) - _fieldAD2[i] = 0; -} - -void Scene600::synchronize(Serializer &s) { - SceneExt::synchronize(s); - - s.syncAsSint16LE(_field412); - for (int i = 0; i < 256; i++) - s.syncAsByte(_fieldAD2[i]); -} - bool Scene600::CompartmentHotspot::startAction(CursorType action, Event &event) { if ((action != R2_NEGATOR_GUN) || (!R2_GLOBALS.getFlag(5)) || (R2_GLOBALS.getFlag(8))) return SceneHotspot::startAction(action, event); @@ -5415,9 +5401,22 @@ bool Scene600::Actor4::startAction(CursorType action, Event &event) { return false; } -void Scene600::Actor4::draw() { - warning("TODO: Actor4::draw()"); - SceneActor::draw(); +GfxSurface Scene600::Actor4::getFrame() { + GfxSurface frame = SceneActor::getFrame(); + + if (_effect) { + // Translate the frame using the scene's pixel map + byte *pixelMap = static_cast<Scene600 *>(R2_GLOBALS._sceneManager._scene)->_pixelMap; + Graphics::Surface surface = frame.lockSurface(); + byte *srcP = (byte *)surface.pixels; + + while (srcP < ((byte *)surface.pixels + (surface.w * surface.h))) + *srcP++ = pixelMap[*srcP]; + + frame.unlockSurface(); + } + + return frame; } bool Scene600::Doorway::startAction(CursorType action, Event &event) { @@ -5545,6 +5544,21 @@ bool Scene600::Aerosol::startAction(CursorType action, Event &event) { } } +/*--------------------------------------------------------------------------*/ + +Scene600::Scene600() { + _field412 = 0; + Common::fill(&_pixelMap[0], &_pixelMap[256], 0); +} + +void Scene600::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_field412); + for (int i = 0; i < 256; i++) + s.syncAsByte(_pixelMap[i]); +} + bool Scene600::Actor8::startAction(CursorType action, Event &event) { Scene600 *scene = (Scene600 *)R2_GLOBALS._sceneManager._scene; @@ -5570,7 +5584,15 @@ void Scene600::postInit(SceneObjectList *OwnerList) { R2_GLOBALS._walkRegions.enableRegion(3); _field412 = 0; - warning("FIXME: loop to initialize _fieldAD2[]"); + // Initialise pixel map for the obscuring effect + ScenePalette &pal = R2_GLOBALS._scenePalette; + uint r, g, b; + for (int i = 0; i < 256; ++i) { + pal.getEntry(i, &r, &g, &b); + int av = ((r + g + b) / 48); + + _pixelMap[i] = R2_GLOBALS._paletteMap[(av << 8) | (av << 4) | av]; + } _doorway.postInit(); _doorway.setVisage(600); diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h index 58dad85a4c..51cdd88cc1 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.h +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -628,7 +628,7 @@ class Scene600 : public SceneExt { public: virtual void signal(); virtual bool startAction(CursorType action, Event &event); - virtual void draw(); + virtual GfxSurface getFrame(); }; class Doorway : public SceneActor { public: @@ -665,7 +665,7 @@ public: ASoundExt _aSound1; SequenceManager _sequenceManager1; SequenceManager _sequenceManager2; - byte _fieldAD2[256]; + byte _pixelMap[256]; Scene600(); virtual void postInit(SceneObjectList *OwnerList = NULL); |