[Scummvm-git-logs] scummvm master -> 51a1c568d9fb75f13554257ad648f80e2aeef3ea
neuromancer
noreply at scummvm.org
Wed Nov 23 12:16:00 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7d2f63681c FREESCAPE: refactoring to add basic function for implementing sensors
5103ee561f FREESCAPE: basic implementation of the SPFX instruction and color remappings
51a1c568d9 FREESCAPE: only remap colors when entering an new area in driller
Commit: 7d2f63681c93a66b4eb8b4a12d82133d90c7c8f5
https://github.com/scummvm/scummvm/commit/7d2f63681c93a66b4eb8b4a12d82133d90c7c8f5
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-23T13:17:02+01:00
Commit Message:
FREESCAPE: refactoring to add basic function for implementing sensors
Changed paths:
engines/freescape/freescape.cpp
engines/freescape/freescape.h
engines/freescape/gfx.h
engines/freescape/gfx_opengl.cpp
engines/freescape/gfx_opengl.h
engines/freescape/gfx_tinygl.cpp
engines/freescape/gfx_tinygl.h
engines/freescape/movement.cpp
diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index e07af023d38..56c9f29721a 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -220,12 +220,24 @@ void FreescapeEngine::checkSensors() {
if (sensor->isDestroyed() || sensor->isInvisible())
continue;
if ((sensor->getOrigin() - _position).length() <= sensor->_firingRange) {
- if (_ticks % sensor->_firingInterval == 0)
- warning("shoot!");
+ if (_ticks % sensor->_firingInterval == 0) {
+ drawSensorShoot(sensor);
+ takeDamageFromSensor();
+ }
}
}
}
+void FreescapeEngine::drawSensorShoot(Sensor *sensor) {
+ assert(sensor);
+ _gfx->renderSensorShoot(1, sensor->getOrigin(), _viewArea);
+}
+
+void FreescapeEngine::takeDamageFromSensor() {
+ _gameStateVars[k8bitVariableShield]--;
+}
+
+
void FreescapeEngine::drawFrame() {
_gfx->updateProjectionMatrix(70.0, _nearClipPlane, _farClipPlane);
_gfx->positionCamera(_position, _position + _cameraFront);
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 5c08352d951..86c16917c7e 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -36,6 +36,7 @@
#include "freescape/gfx.h"
#include "freescape/objects/entrance.h"
#include "freescape/objects/geometricobject.h"
+#include "freescape/objects/sensor.h"
namespace Common {
class RandomSource;
@@ -298,7 +299,8 @@ public:
virtual bool checkIfGameEnded();
ObjectArray _sensors;
void checkSensors();
-
+ void drawSensorShoot(Sensor *sensor);
+ void takeDamageFromSensor();
bool hasFeature(EngineFeature f) const override;
bool canLoadGameStateCurrently() override { return true; }
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 50a42154b04..5b598f5732f 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -81,7 +81,8 @@ public:
virtual void freeTexture(Texture *texture) = 0;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) = 0;
- virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) = 0;
+ virtual void renderSensorShoot(byte color, const Math::Vector3d position, const Common::Rect viewPort) = 0;
+ virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) = 0;
virtual void renderCube(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
virtual void renderRectangle(const Math::Vector3d &position, const Math::Vector3d &size, Common::Array<uint8> *colours);
virtual void renderPolygon(const Math::Vector3d &origin, const Math::Vector3d &size, const Common::Array<uint16> *ordinates, Common::Array<uint8> *colours);
diff --git a/engines/freescape/gfx_opengl.cpp b/engines/freescape/gfx_opengl.cpp
index 9d8450a3ec7..1825b4b5752 100644
--- a/engines/freescape/gfx_opengl.cpp
+++ b/engines/freescape/gfx_opengl.cpp
@@ -173,7 +173,10 @@ void OpenGLRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vecto
glTranslatef(-pos.x(), -pos.y(), -pos.z());
}
-void OpenGLRenderer::renderShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
+void OpenGLRenderer::renderSensorShoot(byte color, const Math::Vector3d position, const Common::Rect viewArea) {
+}
+
+void OpenGLRenderer::renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
uint8 r, g, b;
readFromPalette(color, r, g, b); // TODO: should use opposite color
diff --git a/engines/freescape/gfx_opengl.h b/engines/freescape/gfx_opengl.h
index 134bb248717..28d17fff1a5 100644
--- a/engines/freescape/gfx_opengl.h
+++ b/engines/freescape/gfx_opengl.h
@@ -73,7 +73,8 @@ public:
void freeTexture(Texture *texture) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
- virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
+ virtual void renderSensorShoot(byte color, const Math::Vector3d position, const Common::Rect viewPort) override;
+ virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
virtual void flipBuffer() override;
diff --git a/engines/freescape/gfx_tinygl.cpp b/engines/freescape/gfx_tinygl.cpp
index a6ea6dc6138..34b1a824248 100644
--- a/engines/freescape/gfx_tinygl.cpp
+++ b/engines/freescape/gfx_tinygl.cpp
@@ -122,7 +122,11 @@ void TinyGLRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vecto
tglTranslatef(-pos.x(), -pos.y(), -pos.z());
}
-void TinyGLRenderer::renderShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
+void TinyGLRenderer::renderSensorShoot(byte color, const Math::Vector3d position, const Common::Rect viewArea) {
+
+}
+
+void TinyGLRenderer::renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewArea) {
uint8 r, g, b;
readFromPalette(color, r, g, b); // TODO: should use opposite color
diff --git a/engines/freescape/gfx_tinygl.h b/engines/freescape/gfx_tinygl.h
index 1bfc7eab0b3..061ab5c6383 100644
--- a/engines/freescape/gfx_tinygl.h
+++ b/engines/freescape/gfx_tinygl.h
@@ -59,7 +59,8 @@ public:
void freeTexture(Texture *texture) override;
virtual void drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect, Texture *texture) override;
- virtual void renderShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
+ virtual void renderSensorShoot(byte color, const Math::Vector3d position, const Common::Rect viewPort) override;
+ virtual void renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewPort) override;
virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) override;
virtual void flipBuffer() override;
diff --git a/engines/freescape/movement.cpp b/engines/freescape/movement.cpp
index cebe125d797..f44892eb2c3 100644
--- a/engines/freescape/movement.cpp
+++ b/engines/freescape/movement.cpp
@@ -65,7 +65,7 @@ void FreescapeEngine::shoot() {
//_mixer->stopHandle(_soundFxHandle);
playSound(1, true);
_gfx->setViewport(_fullscreenViewArea);
- _gfx->renderShoot(0, _crossairPosition, _viewArea);
+ _gfx->renderPlayerShoot(0, _crossairPosition, _viewArea);
_gfx->setViewport(_viewArea);
Common::Point center(_viewArea.left + _viewArea.width() / 2, _viewArea.top + _viewArea.height() / 2);
Commit: 5103ee561fb3172bc2afcac52b6b689de5920d96
https://github.com/scummvm/scummvm/commit/5103ee561fb3172bc2afcac52b6b689de5920d96
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-23T13:17:02+01:00
Commit Message:
FREESCAPE: basic implementation of the SPFX instruction and color remappings
Changed paths:
engines/freescape/area.cpp
engines/freescape/area.h
engines/freescape/freescape.h
engines/freescape/gfx.cpp
engines/freescape/gfx.h
engines/freescape/language/8bitDetokeniser.cpp
engines/freescape/language/instruction.cpp
engines/freescape/language/token.h
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 934a4ce59b1..3554a4a002c 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -164,7 +164,13 @@ void Area::saveObjects(Common::WriteStream *stream) {
}
}
+void Area::remapColor(int index, int color) {
+ _colorRemaps[index] = color;
+}
+
+
void Area::draw(Freescape::Renderer *gfx) {
+ gfx->setColorRemaps(&_colorRemaps);
gfx->clear();
assert(_drawableObjects.size() > 0);
for (auto &obj : _drawableObjects) {
diff --git a/engines/freescape/area.h b/engines/freescape/area.h
index cdb605edb53..6abeddb4bc4 100644
--- a/engines/freescape/area.h
+++ b/engines/freescape/area.h
@@ -47,6 +47,7 @@ public:
uint16 getAreaID();
uint16 getAreaFlags();
uint8 getScale();
+ void remapColor(int index, int color);
void draw(Renderer *gfx);
void show();
@@ -71,6 +72,7 @@ public:
uint8 _scale;
uint8 _skyColor;
uint8 _groundColor;
+ ColorReMap _colorRemaps;
private:
uint16 _areaID;
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 86c16917c7e..8ed6da21ebf 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -247,6 +247,7 @@ public:
bool executeEndIfVisibilityIsEqual(FCLInstruction &instruction);
void executeSwapJet(FCLInstruction &instruction);
void executePrint(FCLInstruction &instruction);
+ void executeSPFX(FCLInstruction &instruction);
// Sound
Audio::SoundHandle _soundFxHandle;
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index d292356068f..10bbed2385c 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -42,6 +42,7 @@ Renderer::Renderer(int screenW, int screenH, Common::RenderMode renderMode) {
_keyColor = -1;
_palette = nullptr;
_colorMap = nullptr;
+ _colorRemaps = nullptr;
_renderMode = renderMode;
_isAccelerated = false;
}
@@ -54,8 +55,16 @@ void Renderer::readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b) {
b = _palette[3 * index + 2];
}
+void Renderer::setColorRemaps(ColorReMap *colorRemaps) {
+ _colorRemaps = colorRemaps;
+}
+
bool Renderer::getRGBAt(uint8 index, uint8 &r, uint8 &g, uint8 &b) {
+ if (_colorRemaps && _colorRemaps->contains(index)) {
+ index = (*_colorRemaps)[index];
+ }
+
if (index == _keyColor)
return false;
@@ -76,7 +85,6 @@ bool Renderer::getRGBAt(uint8 index, uint8 &r, uint8 &g, uint8 &b) {
for (int i = 0; i < 4; i++) {
byte be = *entry;
if (be != 0 && be != 0xff) {
- // TODO: fix colors for non-DOS releases
readFromPalette(index, r, g, b);
return true;
}
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 5b598f5732f..b7af8bdbe66 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -36,6 +36,7 @@ namespace Freescape {
#define kCoordsArraySize 4
typedef Common::Array<byte *> ColorMap;
+typedef Common::HashMap<int, int> ColorReMap;
class Renderer;
@@ -89,6 +90,7 @@ public:
virtual void renderPyramid(const Math::Vector3d &origin, const Math::Vector3d &size, const Common::Array<uint16> *ordinates, Common::Array<uint8> *colours, int type);
virtual void renderFace(const Common::Array<Math::Vector3d> &vertices) = 0;
+ void setColorRemaps(ColorReMap *colorRemaps);
virtual void setSkyColor(uint8 color) = 0;
virtual void drawFloor(uint8 color) = 0;
@@ -99,6 +101,7 @@ public:
bool getRGBAt(uint8 index, uint8 &r, uint8 &g, uint8 &b);
byte *_palette;
ColorMap *_colorMap;
+ ColorReMap *_colorRemaps;
int _keyColor;
/**
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 518827a7a76..ba09025bc0e 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -328,6 +328,14 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
case 25:
// this should toggle border colour or the room palette
detokenisedStream += "SPFX (";
+ currentInstruction = FCLInstruction(Token::SPFX);
+ currentInstruction.setSource(tokenisedCondition[bytePointer] >> 4);
+ currentInstruction.setDestination(tokenisedCondition[bytePointer] & 0xf);
+ detokenisedStream += Common::String::format("%d, %d)", currentInstruction._source, currentInstruction._destination);
+ conditionalInstructions->push_back(currentInstruction);
+ currentInstruction = FCLInstruction(Token::UNKNOWN);
+ bytePointer++;
+ numberOfArguments = 0;
break;
case 20:
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 40a2abd9623..637e8c068e8 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -161,6 +161,9 @@ void FreescapeEngine::executeCode(FCLInstructionVector &code, bool shot, bool co
case Token::PRINT:
executePrint(instruction);
break;
+ case Token::SPFX:
+ executeSPFX(instruction);
+ break;
case Token::BITNOTEQ:
if (executeEndIfBitNotEqual(instruction))
ip = codeSize;
@@ -203,6 +206,19 @@ void FreescapeEngine::executePrint(FCLInstruction &instruction) {
_currentAreaMessages.push_back(_messagesList[index]);
}
+void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
+ uint16 index = instruction._source;
+ uint16 color = instruction._destination;
+
+ debugC(1, kFreescapeDebugCode, "Switching palette from position %d to %d", index, color);
+ _currentArea->remapColor(index, color);
+ drawFrame();
+ _gfx->flipBuffer();
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+}
+
+
bool FreescapeEngine::executeEndIfVisibilityIsEqual(FCLInstruction &instruction) {
uint16 source = instruction._source;
uint16 additional = instruction._additional;
diff --git a/engines/freescape/language/token.h b/engines/freescape/language/token.h
index 4b18d36e408..90149d495e1 100644
--- a/engines/freescape/language/token.h
+++ b/engines/freescape/language/token.h
@@ -69,6 +69,7 @@ public:
START,
STARTANIM,
STOPANIM,
+ SPFX,
SUBVAR,
SYNCSND,
THEN,
Commit: 51a1c568d9fb75f13554257ad648f80e2aeef3ea
https://github.com/scummvm/scummvm/commit/51a1c568d9fb75f13554257ad648f80e2aeef3ea
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-11-23T13:17:02+01:00
Commit Message:
FREESCAPE: only remap colors when entering an new area in driller
Changed paths:
engines/freescape/area.cpp
engines/freescape/games/driller.cpp
diff --git a/engines/freescape/area.cpp b/engines/freescape/area.cpp
index 3554a4a002c..925e9100e1d 100644
--- a/engines/freescape/area.cpp
+++ b/engines/freescape/area.cpp
@@ -170,7 +170,6 @@ void Area::remapColor(int index, int color) {
void Area::draw(Freescape::Renderer *gfx) {
- gfx->setColorRemaps(&_colorRemaps);
gfx->clear();
assert(_drawableObjects.size() > 0);
for (auto &obj : _drawableObjects) {
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index fdd36e0bdc8..058df2f30a1 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -115,6 +115,7 @@ void DrillerEngine::gotoArea(uint16 areaID, int entranceID) {
playSound(5, false);
// Ignore sky/ground fields
_gfx->_keyColor = 0;
+ _gfx->setColorRemaps(&_currentArea->_colorRemaps);
if (isAmiga() || isAtariST())
swapPalette(areaID);
More information about the Scummvm-git-logs
mailing list