aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoryinsimei2017-06-06 01:35:25 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commit77d5c7235d5ad0aa36abc3625e0716582ee52318 (patch)
tree18b52942484e7e4af6b1892a8300201f49c41bdb /engines
parentd5379c212c4ee972083d825a6e586b1341f9e6f9 (diff)
downloadscummvm-rg350-77d5c7235d5ad0aa36abc3625e0716582ee52318.tar.gz
scummvm-rg350-77d5c7235d5ad0aa36abc3625e0716582ee52318.tar.bz2
scummvm-rg350-77d5c7235d5ad0aa36abc3625e0716582ee52318.zip
SLUDGE: replace sludge colours by pixelformat
Diffstat (limited to 'engines')
-rw-r--r--engines/sludge/backdrop.cpp3
-rw-r--r--engines/sludge/bg_effects.cpp1
-rw-r--r--engines/sludge/builtin.cpp4
-rw-r--r--engines/sludge/colours.h52
-rw-r--r--engines/sludge/cursors.cpp1
-rw-r--r--engines/sludge/fonttext.cpp1
-rw-r--r--engines/sludge/hsi.cpp7
-rw-r--r--engines/sludge/imgloader.cpp3
-rw-r--r--engines/sludge/sludge.cpp17
-rw-r--r--engines/sludge/sludge.h7
-rw-r--r--engines/sludge/sludger.cpp1
-rw-r--r--engines/sludge/sprites.cpp12
-rw-r--r--engines/sludge/statusba.cpp1
-rw-r--r--engines/sludge/thumbnail.cpp1
-rw-r--r--engines/sludge/transition.cpp1
15 files changed, 36 insertions, 76 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index d80a8aeec6..42b1c99a52 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -28,7 +28,6 @@
#include "sludge/allfiles.h"
#include "sludge/newfatal.h"
-#include "sludge/colours.h"
#include "sludge/fileset.h"
#include "sludge/backdrop.h"
#include "sludge/moreio.h"
@@ -70,7 +69,7 @@ int cameraPX = 0, cameraPY = 0;
unsigned int sceneWidth, sceneHeight;
int lightMapNumber;
-unsigned int currentBlankColour = makeColour(0, 0, 0);
+unsigned int currentBlankColour = g_sludge->getOrigPixelFormat().RGBToColor(0, 0, 0);
extern int cameraX, cameraY;
extern float cameraZoom;
diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp
index 100b9062d3..529556ef56 100644
--- a/engines/sludge/bg_effects.cpp
+++ b/engines/sludge/bg_effects.cpp
@@ -25,7 +25,6 @@
#include "sludge/allfiles.h"
#include "sludge/backdrop.h"
-#include "sludge/colours.h"
#include "sludge/debug.h"
#include "sludge/graphics.h"
#include "sludge/moreio.h"
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 873b523872..b15ed01b70 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -46,10 +46,10 @@
#include "sludge/movie.h"
#include "sludge/savedata.h"
#include "sludge/freeze.h"
-#include "sludge/colours.h"
#include "sludge/language.h"
#include "sludge/thumbnail.h"
#include "sludge/graphics.h"
+#include "sludge/sludge.h"
#include "sludge/CommonCode/utf8.h"
namespace Sludge {
@@ -849,7 +849,7 @@ builtIn(setBlankColour) {
if (!getRGBParams(red, green, blue, fun))
return BR_ERROR;
- currentBlankColour = makeColour(red & 255, green & 255, blue & 255);
+ currentBlankColour = g_sludge->getOrigPixelFormat().RGBToColor(red & 255, green & 255, blue & 255);
setVariable(fun->reg, SVT_INT, 1);
return BR_CONTINUE;
}
diff --git a/engines/sludge/colours.h b/engines/sludge/colours.h
deleted file mode 100644
index a613f6772c..0000000000
--- a/engines/sludge/colours.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef SLUDGE_COLOURS_H
-#define SLUDGE_COLOURS_H
-
-namespace Sludge {
-
-// Simple colour conversion routines to deal with 16-bit graphics
-//unsigned short int makeColour (byte r, byte g, byte b);
-
-inline unsigned short redValue(unsigned short c) {
- return (c >> 11) << 3;
-}
-inline unsigned short greenValue(unsigned short c) {
- return ((c >> 5) & 63) << 2;
-}
-inline unsigned short blueValue(unsigned short c) {
- return (c & 31) << 3;
-}
-
-inline unsigned short makeGrey(unsigned short int r) {
- return ((r >> 3) << 11) | ((r >> 2) << 5) | (r >> 3);
-}
-
-inline unsigned short makeColour(unsigned short int r, unsigned short int g,
- unsigned short int b) {
- return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
-}
-
-} // End of namespace Sludge
-
-#endif
diff --git a/engines/sludge/cursors.cpp b/engines/sludge/cursors.cpp
index abe09c86d3..519b6366dd 100644
--- a/engines/sludge/cursors.cpp
+++ b/engines/sludge/cursors.cpp
@@ -22,7 +22,6 @@
#include "sludge/allfiles.h"
#include "sludge/cursors.h"
-#include "sludge/colours.h"
#include "sludge/sprites.h"
#include "sludge/sprbanks.h"
#include "sludge/people.h"
diff --git a/engines/sludge/fonttext.cpp b/engines/sludge/fonttext.cpp
index f66cde54d6..c3c877c80b 100644
--- a/engines/sludge/fonttext.cpp
+++ b/engines/sludge/fonttext.cpp
@@ -24,7 +24,6 @@
#include "sludge/allfiles.h"
#include "sludge/stringy.h"
#include "sludge/sprites.h"
-#include "sludge/colours.h"
#include "sludge/fonttext.h"
#include "sludge/newfatal.h"
#include "sludge/moreio.h"
diff --git a/engines/sludge/hsi.cpp b/engines/sludge/hsi.cpp
index 22da4b4598..3ccdc148e4 100644
--- a/engines/sludge/hsi.cpp
+++ b/engines/sludge/hsi.cpp
@@ -25,7 +25,6 @@
#include "graphics/surface.h"
-#include "sludge/colours.h"
#include "sludge/hsi.h"
#include "sludge/sludge.h"
@@ -56,7 +55,7 @@ bool HSIDecoder::loadStream(Common::SeekableReadStream &stream) {
debug(kSludgeDebugGraphics, "picHeight : %i", height);
_surface = new Graphics::Surface();
- _surface->create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ _surface->create(width, height, g_sludge->getScreenPixelFormat());
for (uint16 y = 0; y < height; y++) {
uint16 x = 0;
while (x < width) {
@@ -76,9 +75,7 @@ bool HSIDecoder::loadStream(Common::SeekableReadStream &stream) {
target[3] = (byte)0;
} else {
target[0] = (byte)255;
- target[1] = (byte)blueValue(c);
- target[2] = (byte)greenValue(c);
- target[3] = (byte)redValue(c);
+ g_sludge->getOrigPixelFormat().colorToRGB(c, target[3], target[2], target[1]);
}
x++;
}
diff --git a/engines/sludge/imgloader.cpp b/engines/sludge/imgloader.cpp
index 8036b4c17d..eef18ee742 100644
--- a/engines/sludge/imgloader.cpp
+++ b/engines/sludge/imgloader.cpp
@@ -28,7 +28,6 @@
#include "sludge/allfiles.h"
#include "sludge/hsi.h"
#include "sludge/imgloader.h"
-#include "sludge/colours.h"
#include "sludge/sludge.h"
namespace Sludge {
@@ -50,7 +49,7 @@ bool ImgLoader::loadPNGImage(Common::SeekableReadStream *stream, Graphics::Surfa
if (!png.loadStream(*stream))
return false;
const Graphics::Surface *sourceSurface = png.getSurface();
- Graphics::Surface *pngSurface = sourceSurface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), png.getPalette());
+ Graphics::Surface *pngSurface = sourceSurface->convertTo(g_sludge->getScreenPixelFormat(), png.getPalette());
dest->copyFrom(*pngSurface);
pngSurface->free();
delete pngSurface;
diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp
index 6ea4b7ba4b..90bdd454ef 100644
--- a/engines/sludge/sludge.cpp
+++ b/engines/sludge/sludge.cpp
@@ -32,6 +32,15 @@
namespace Sludge {
+SludgeEngine *g_sludge;
+
+Graphics::PixelFormat SludgeEngine::getScreenPixelFormat() const { return _pixelFormat; }
+Graphics::PixelFormat SludgeEngine::getOrigPixelFormat() const {
+ return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+ //return _origFormat;
+ // TODO: get segmentation fault when returning _origFormat
+}
+
SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
@@ -62,9 +71,13 @@ SludgeEngine::~SludgeEngine() {
}
Common::Error SludgeEngine::run() {
+ // set global variable
+ g_sludge = this;
+
// init graphics
- Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
- initGraphics(640, 480, false, &format);
+ _origFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+ _pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
+ initGraphics(640, 480, false, &_pixelFormat);
// create console
_console = new SludgeConsole(this);
diff --git a/engines/sludge/sludge.h b/engines/sludge/sludge.h
index 57544828b0..5fe09c3b74 100644
--- a/engines/sludge/sludge.h
+++ b/engines/sludge/sludge.h
@@ -25,12 +25,15 @@
#include "common/random.h"
#include "engines/engine.h"
+#include "graphics/pixelformat.h"
#include "gui/debugger.h"
#include "sludge/console.h"
namespace Sludge {
+extern SludgeEngine *g_sludge;
+
class SludgeConsole;
struct SludgeGameDescription;
@@ -57,6 +60,8 @@ public:
const char *getGameId() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
+ Graphics::PixelFormat getScreenPixelFormat() const;
+ Graphics::PixelFormat getOrigPixelFormat() const;
const char *getGameFile() const;
@@ -65,6 +70,8 @@ public:
private:
SludgeConsole *_console;
Common::RandomSource *_rnd;
+ Graphics::PixelFormat _pixelFormat;
+ Graphics::PixelFormat _origFormat;
};
} // End of namespace Sludge
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 70f818060b..e9c724399f 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -27,7 +27,6 @@
#include "sludge/sludger.h"
#include "sludge/backdrop.h"
#include "sludge/cursors.h"
-#include "sludge/colours.h"
#include "sludge/objtypes.h"
#include "sludge/region.h"
#include "sludge/sprites.h"
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 1dc661993a..3ea82c8ab6 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -29,7 +29,6 @@
#include "sludge/sprites.h"
#include "sludge/moreio.h"
#include "sludge/newfatal.h"
-#include "sludge/colours.h"
#include "sludge/backdrop.h"
#include "sludge/sludger.h"
#include "sludge/zbuffer.h"
@@ -37,6 +36,7 @@
#include "sludge/graphics.h"
#include "sludge/imgloader.h"
#include "sludge/shaders.h"
+#include "sludge/sludge.h"
namespace Sludge {
@@ -181,9 +181,9 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
}
// init data
- loadhere.sprites[i].surface.create(picwidth, picheight, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ loadhere.sprites[i].surface.create(picwidth, picheight, g_sludge->getScreenPixelFormat());
if (isFont) {
- loadhere.sprites[i].burnSurface.create(picwidth, picheight, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ loadhere.sprites[i].burnSurface.create(picwidth, picheight, g_sludge->getScreenPixelFormat());
}
data = (byte *)new byte[picwidth * (picheight + 1)];
if (!checkNew(data)) return false;
@@ -230,7 +230,11 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
loadhere.myPalette.r[i + startIndex] = (byte)bigDataFile->readByte();
loadhere.myPalette.g[i + startIndex] = (byte)bigDataFile->readByte();
loadhere.myPalette.b[i + startIndex] = (byte)bigDataFile->readByte();
- loadhere.myPalette.pal[i + startIndex] = makeColour(loadhere.myPalette.r[i + startIndex], loadhere.myPalette.g[i + startIndex], loadhere.myPalette.b[i + startIndex]);
+ loadhere.myPalette.pal[i + startIndex] =
+ (uint16)g_sludge->getOrigPixelFormat().RGBToColor(
+ loadhere.myPalette.r[i + startIndex],
+ loadhere.myPalette.g[i + startIndex],
+ loadhere.myPalette.b[i + startIndex]);
}
loadhere.myPalette.originalRed = loadhere.myPalette.originalGreen = loadhere.myPalette.originalBlue = 255;
diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp
index 4bf665bad8..0ebe4e7363 100644
--- a/engines/sludge/statusba.cpp
+++ b/engines/sludge/statusba.cpp
@@ -24,7 +24,6 @@
#include "sludge/allfiles.h"
#include "sludge/backdrop.h"
-#include "sludge/colours.h"
#include "sludge/sprites.h"
#include "sludge/fonttext.h"
#include "sludge/moreio.h"
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index df0076c616..8e238f76fa 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -24,7 +24,6 @@
#include "sludge/errors.h"
#include "sludge/moreio.h"
#include "sludge/sludger.h"
-#include "sludge/colours.h"
#include "sludge/backdrop.h"
#include "sludge/graphics.h"
#include "sludge/newfatal.h"
diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp
index 05257d8041..207eca65d8 100644
--- a/engines/sludge/transition.cpp
+++ b/engines/sludge/transition.cpp
@@ -21,7 +21,6 @@
*/
#include "sludge/allfiles.h"
-#include "sludge/colours.h"
#include "sludge/backdrop.h"
#include "sludge/graphics.h"
#include "sludge/newfatal.h"