Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,170 @@
/* 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 "common/scummsys.h"
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/effects/fog.h"
#include "zvision/scripting/script_manager.h"
namespace ZVision {
FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::Path &clouds):
GraphicsEffect(engine, key, region, ported) {
_map = Map;
_r = 0;
_g = 0;
_b = 0;
_pos = 0;
if (SearchMan.hasFile(clouds))
_engine->getRenderManager()->readImageToSurface(clouds, _fog);
else
_engine->getRenderManager()->readImageToSurface("cloud.tga", _fog);
_mp.resize(_fog.h);
for (int16 i = 0; i < _fog.h; i++) {
_mp[i].resize(_fog.w);
for (int16 j = 0; j < _fog.w; j++)
_mp[i][j] = true;
}
for (uint8 i = 0; i < 32; i++)
_colorMap[i] = 0;
}
FogFx::~FogFx() {
if (_map)
delete _map;
for (uint16 i = 0; i < _mp.size(); i++)
_mp[i].clear();
_mp.clear();
}
const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) {
_surface.copyFrom(srcSubRect);
EffectMap::iterator it = _map->begin();
uint32 cnt = 0;
for (uint16 j = 0; j < _surface.h; j++) {
uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
for (uint16 i = 0; i < _surface.w; i++) {
if (it->inEffect) {
// Not 100% equivalent, but looks nice and not buggy
uint8 sr, sg, sb;
_engine->_resourcePixelFormat.colorToRGB(lineBuf[i], sr, sg, sb);
uint16 fogColor = *(uint16 *)_fog.getBasePtr((i + _pos) % _fog.w, j);
uint8 dr, dg, db;
_engine->_resourcePixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db);
uint16 fr = dr + sr;
if (fr > 255)
fr = 255;
uint16 fg = dg + sg;
if (fg > 255)
fg = 255;
uint16 fb = db + sb;
if (fb > 255)
fb = 255;
lineBuf[i] = _engine->_resourcePixelFormat.RGBToColor(fr, fg, fb);
}
cnt++;
if (cnt >= it->count) {
it++;
cnt = 0;
}
if (it == _map->end())
break;
}
if (it == _map->end())
break;
}
return &_surface;
}
void FogFx::update() {
_pos += _engine->getScriptManager()->getStateValue(StateKey_EF9_Speed);
_pos %= _fog.w;
debugC(2, kDebugEffect, "Updating fog effect");
uint8 dr = _engine->getScriptManager()->getStateValue(StateKey_EF9_R);
uint8 dg = _engine->getScriptManager()->getStateValue(StateKey_EF9_G);
uint8 db = _engine->getScriptManager()->getStateValue(StateKey_EF9_B);
dr = CLIP((int)dr, 0, 31);
dg = CLIP((int)dg, 0, 31);
db = CLIP((int)db, 0, 31);
if (dr != _r || dg != _g || db != _b) {
if (_r > dr)
_r--;
else if (_r < dr)
_r++;
if (_g > dg)
_g--;
else if (_g < dg)
_g++;
if (_b > db)
_b--;
else if (_b < db)
_b++;
// Not 100% equivalent, but looks nice and not buggy
_colorMap[31] = _engine->_resourcePixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3);
for (uint8 i = 0; i < 31; i++) {
float perc = (float)i / 31.0;
uint8 cr = (uint8)((float)_r * perc);
uint8 cg = (uint8)((float)_g * perc);
uint8 cb = (uint8)((float)_b * perc);
_colorMap[i] = _engine->_resourcePixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3);
}
}
for (uint16 j = 0; j < _fog.h; j++) {
uint16 *pix = (uint16 *)_fog.getBasePtr(0, j);
for (uint16 i = 0; i < _fog.w; i++) {
if (_mp[j][i]) {
if ((pix[i] & 0x1F) == 0x1F) {
pix[i]--;
_mp[j][i] = false;
} else
pix[i]++;
} else {
if ((pix[i] & 0x1F) == 0) {
pix[i]++;
_mp[j][i] = true;
} else
pix[i]--;
}
}
}
}
} // End of namespace ZVision

View File

@@ -0,0 +1,52 @@
/* 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 ZVISION_FOG_H
#define ZVISION_FOG_H
#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
// Used by Zork: Nemesis for the mixing chamber gas effect in the gas puzzle (location tt5e, when the blinds are down)
class FogFx : public GraphicsEffect {
public:
FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::Path &clouds);
~FogFx() override;
const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) override;
void update() override;
private:
EffectMap *_map;
Graphics::Surface _fog;
uint8 _r, _g, _b;
int32 _pos;
Common::Array< Common::Array< bool > > _mp;
uint16 _colorMap[32];
};
} // End of namespace ZVision
#endif // ZVISION_FOG_H

View File

@@ -0,0 +1,106 @@
/* 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 "common/scummsys.h"
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/effects/light.h"
namespace ZVision {
LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD):
GraphicsEffect(engine, key, region, ported) {
_map = Map;
_delta = delta;
_up = true;
_pos = 0;
_minD = minD;
if (_minD < -delta)
_minD = -delta;
_maxD = maxD;
if (_maxD > delta)
_maxD = delta;
}
LightFx::~LightFx() {
if (_map)
delete _map;
}
const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) {
_surface.copyFrom(srcSubRect);
EffectMap::iterator it = _map->begin();
uint32 cnt = 0;
uint32 dcolor = 0;
if (_pos < 0) {
uint8 cc = ((-_pos) & 0x1F) << 3;
dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
} else {
uint8 cc = (_pos & 0x1F) << 3;
dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
}
for (uint16 j = 0; j < _surface.h; j++) {
uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j);
for (uint16 i = 0; i < _surface.w; i++) {
if (it->inEffect) {
if (_pos < 0) {
lineBuf[i] -= dcolor;
} else {
lineBuf[i] += dcolor;
}
}
cnt++;
if (cnt >= it->count) {
it++;
cnt = 0;
}
if (it == _map->end())
break;
}
if (it == _map->end())
break;
}
return &_surface;
}
void LightFx::update() {
if (_up)
_pos++;
else
_pos--;
if (_pos <= _minD) {
_up = !_up;
_pos = _minD;
} else if (_pos >= _maxD) {
_up = !_up;
_pos = _maxD;
}
}
} // End of namespace ZVision

View File

@@ -0,0 +1,52 @@
/* 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 LIGHTFX_H_INCLUDED
#define LIGHTFX_H_INCLUDED
#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
class LightFx : public GraphicsEffect {
public:
LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127);
~LightFx() override;
const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) override;
void update() override;
private:
EffectMap *_map;
int32 _delta;
bool _up;
int32 _pos;
int8 _minD;
int8 _maxD;
};
} // End of namespace ZVision
#endif // LIGHTFX_H_INCLUDED

View File

@@ -0,0 +1,142 @@
/* 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 "common/scummsys.h"
#include "zvision/zvision.h"
#include "zvision/graphics/render_manager.h"
#include "zvision/graphics/effects/wave.h"
namespace ZVision {
WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd):
GraphicsEffect(engine, key, region, ported) {
_frame = 0;
_frameCount = frames;
_ampls.resize(_frameCount);
_halfWidth = _region.width() / 2;
_halfHeight = _region.height() / 2;
int32 frmsize = _halfWidth * _halfHeight;
float phase = 0;
int16 quarterWidth = _halfWidth / 2;
int16 quarterHeight = _halfHeight / 2;
for (int16 i = 0; i < _frameCount; i++) {
_ampls[i].resize(frmsize);
for (int16 y = 0; y < _halfHeight; y++)
for (int16 x = 0; x < _halfWidth; x++) {
int16 dx = (x - quarterWidth);
int16 dy = (y - quarterHeight);
_ampls[i][x + y * _halfWidth] = (int8)(ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase));
}
phase += spd;
}
}
WaveFx::~WaveFx() {
for (uint16 i = 0; i < _ampls.size(); i++)
_ampls[i].clear();
_ampls.clear();
}
const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) {
for (int16 y = 0; y < _halfHeight; y++) {
uint16 *abc = (uint16 *)_surface.getBasePtr(0, y);
uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _halfHeight + y);
uint16 *abc3 = (uint16 *)_surface.getBasePtr(_halfWidth, y);
uint16 *abc4 = (uint16 *)_surface.getBasePtr(_halfWidth, _halfHeight + y);
for (int16 x = 0; x < _halfWidth; x++) {
int8 amnt = _ampls[_frame][x + _halfWidth * y];
int16 nX = x + amnt;
int16 nY = y + amnt;
if (nX < 0)
nX = 0;
if (nX >= _region.width())
nX = _region.width() - 1;
if (nY < 0)
nY = 0;
if (nY >= _region.height())
nY = _region.height() - 1;
*abc = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
nX = x + amnt + _halfWidth;
nY = y + amnt;
if (nX < 0)
nX = 0;
if (nX >= _region.width())
nX = _region.width() - 1;
if (nY < 0)
nY = 0;
if (nY >= _region.height())
nY = _region.height() - 1;
*abc3 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
nX = x + amnt;
nY = y + amnt + _halfHeight;
if (nX < 0)
nX = 0;
if (nX >= _region.width())
nX = _region.width() - 1;
if (nY < 0)
nY = 0;
if (nY >= _region.height())
nY = _region.height() - 1;
*abc2 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
nX = x + amnt + _halfWidth;
nY = y + amnt + _halfHeight;
if (nX < 0)
nX = 0;
if (nX >= _region.width())
nX = _region.width() - 1;
if (nY < 0)
nY = 0;
if (nY >= _region.height())
nY = _region.height() - 1;
*abc4 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY);
abc++;
abc2++;
abc3++;
abc4++;
}
}
return &_surface;
}
void WaveFx::update() {
_frame = (_frame + 1) % _frameCount;
}
} // End of namespace ZVision

View File

@@ -0,0 +1,50 @@
/* 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 WAVEFX_H_INCLUDED
#define WAVEFX_H_INCLUDED
#include "common/array.h"
#include "zvision/graphics/graphics_effect.h"
namespace ZVision {
class ZVision;
class WaveFx : public GraphicsEffect {
public:
WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd);
~WaveFx() override;
const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) override;
void update() override;
private:
int16 _frame;
int16 _frameCount;
int16 _halfWidth, _halfHeight;
Common::Array< Common::Array< int8 > > _ampls;
};
} // End of namespace ZVision
#endif // WAVEFX_H_INCLUDED