aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryinsimei2017-06-06 09:01:46 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commit78cba75570115cf598a0c6c27a660f1ae0e985d6 (patch)
treefb7c0de9d508ef975ccefa0006fbc2c49985acfa
parent839e7fb4d2d51c6abd38d1cc56a2d2cbd346d710 (diff)
downloadscummvm-rg350-78cba75570115cf598a0c6c27a660f1ae0e985d6.tar.gz
scummvm-rg350-78cba75570115cf598a0c6c27a660f1ae0e985d6.tar.bz2
scummvm-rg350-78cba75570115cf598a0c6c27a660f1ae0e985d6.zip
SLUDGE: change pixel formats to pointers and fix seg fault
-rw-r--r--engines/sludge/backdrop.cpp4
-rw-r--r--engines/sludge/builtin.cpp7
-rw-r--r--engines/sludge/hsi.cpp4
-rw-r--r--engines/sludge/imgloader.cpp2
-rw-r--r--engines/sludge/loadsave.cpp2
-rw-r--r--engines/sludge/sludge.cpp22
-rw-r--r--engines/sludge/sludge.h8
-rw-r--r--engines/sludge/sprites.cpp6
8 files changed, 33 insertions, 22 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 42b1c99a52..850a23d1ef 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -69,7 +69,9 @@ int cameraPX = 0, cameraPY = 0;
unsigned int sceneWidth, sceneHeight;
int lightMapNumber;
-unsigned int currentBlankColour = g_sludge->getOrigPixelFormat().RGBToColor(0, 0, 0);
+#if 0
+unsigned int currentBlankColour = g_sludge->getOrigPixelFormat()->RGBToColor(0, 0, 0);
+#endif
extern int cameraX, cameraY;
extern float cameraZoom;
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 131a90351e..3ac316d0c0 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -91,7 +91,9 @@ extern unsigned char brightnessLevel;
extern unsigned char fadeMode;
extern unsigned short saveEncoding;
extern frozenStuffStruct *frozenStuff;
+#if 0
extern unsigned int currentBlankColour;
+#endif
extern unsigned int languageID;
extern unsigned char currentBurnR, currentBurnG, currentBurnB;
@@ -848,8 +850,9 @@ builtIn(setBlankColour) {
if (!getRGBParams(red, green, blue, fun))
return BR_ERROR;
-
- currentBlankColour = g_sludge->getOrigPixelFormat().RGBToColor(red & 255, green & 255, blue & 255);
+#if 0
+ currentBlankColour = g_sludge->getOrigPixelFormat()->RGBToColor(red & 255, green & 255, blue & 255);
+#endif
setVariable(fun->reg, SVT_INT, 1);
return BR_CONTINUE;
}
diff --git a/engines/sludge/hsi.cpp b/engines/sludge/hsi.cpp
index 3ccdc148e4..6bb333f651 100644
--- a/engines/sludge/hsi.cpp
+++ b/engines/sludge/hsi.cpp
@@ -55,7 +55,7 @@ bool HSIDecoder::loadStream(Common::SeekableReadStream &stream) {
debug(kSludgeDebugGraphics, "picHeight : %i", height);
_surface = new Graphics::Surface();
- _surface->create(width, height, g_sludge->getScreenPixelFormat());
+ _surface->create(width, height, *g_sludge->getScreenPixelFormat());
for (uint16 y = 0; y < height; y++) {
uint16 x = 0;
while (x < width) {
@@ -75,7 +75,7 @@ bool HSIDecoder::loadStream(Common::SeekableReadStream &stream) {
target[3] = (byte)0;
} else {
target[0] = (byte)255;
- g_sludge->getOrigPixelFormat().colorToRGB(c, target[3], target[2], target[1]);
+ 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 eef18ee742..bfac7fa5da 100644
--- a/engines/sludge/imgloader.cpp
+++ b/engines/sludge/imgloader.cpp
@@ -49,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(g_sludge->getScreenPixelFormat(), png.getPalette());
+ Graphics::Surface *pngSurface = sourceSurface->convertTo(*g_sludge->getScreenPixelFormat(), png.getPalette());
dest->copyFrom(*pngSurface);
pngSurface->free();
delete pngSurface;
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index db6afb1f83..fb668b5b8b 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -74,7 +74,9 @@ extern bool captureAllKeys;
extern bool allowAnyFilename;
extern unsigned short saveEncoding; // in savedata.cpp
extern unsigned char currentBurnR, currentBurnG, currentBurnB;
+#if 0
extern unsigned int currentBlankColour; // in backdrop.cpp
+#endif
extern parallaxLayer *parallaxStuff; // "
extern int lightMapMode; // "
extern int languageNum;
diff --git a/engines/sludge/sludge.cpp b/engines/sludge/sludge.cpp
index 90bdd454ef..c4e3083466 100644
--- a/engines/sludge/sludge.cpp
+++ b/engines/sludge/sludge.cpp
@@ -34,12 +34,8 @@ 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
-}
+Graphics::PixelFormat *SludgeEngine::getScreenPixelFormat() const { return _pixelFormat; }
+Graphics::PixelFormat *SludgeEngine::getOrigPixelFormat() const { return _origFormat; }
SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
@@ -62,12 +58,20 @@ SludgeEngine::~SludgeEngine() {
// Dispose resources
delete _rnd;
+ _rnd = nullptr;
// Remove debug levels
DebugMan.clearAllDebugChannels();
// Dispose console
delete _console;
+ _console = nullptr;
+
+ // Dispose pixel formats
+ delete _origFormat;
+ _origFormat = nullptr;
+ delete _pixelFormat;
+ _pixelFormat = nullptr;
}
Common::Error SludgeEngine::run() {
@@ -75,9 +79,9 @@ Common::Error SludgeEngine::run() {
g_sludge = this;
// init graphics
- _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);
+ _origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+ _pixelFormat = new 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 5fe09c3b74..5ec197f915 100644
--- a/engines/sludge/sludge.h
+++ b/engines/sludge/sludge.h
@@ -60,8 +60,8 @@ public:
const char *getGameId() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
- Graphics::PixelFormat getScreenPixelFormat() const;
- Graphics::PixelFormat getOrigPixelFormat() const;
+ Graphics::PixelFormat *getScreenPixelFormat() const;
+ Graphics::PixelFormat *getOrigPixelFormat() const;
const char *getGameFile() const;
@@ -70,8 +70,8 @@ public:
private:
SludgeConsole *_console;
Common::RandomSource *_rnd;
- Graphics::PixelFormat _pixelFormat;
- Graphics::PixelFormat _origFormat;
+ Graphics::PixelFormat *_pixelFormat;
+ Graphics::PixelFormat *_origFormat;
};
} // End of namespace Sludge
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 3ea82c8ab6..dbbf74cb5c 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -181,9 +181,9 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
}
// init data
- loadhere.sprites[i].surface.create(picwidth, picheight, g_sludge->getScreenPixelFormat());
+ loadhere.sprites[i].surface.create(picwidth, picheight, *g_sludge->getScreenPixelFormat());
if (isFont) {
- loadhere.sprites[i].burnSurface.create(picwidth, picheight, g_sludge->getScreenPixelFormat());
+ loadhere.sprites[i].burnSurface.create(picwidth, picheight, *g_sludge->getScreenPixelFormat());
}
data = (byte *)new byte[picwidth * (picheight + 1)];
if (!checkNew(data)) return false;
@@ -231,7 +231,7 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
loadhere.myPalette.g[i + startIndex] = (byte)bigDataFile->readByte();
loadhere.myPalette.b[i + startIndex] = (byte)bigDataFile->readByte();
loadhere.myPalette.pal[i + startIndex] =
- (uint16)g_sludge->getOrigPixelFormat().RGBToColor(
+ (uint16)g_sludge->getOrigPixelFormat()->RGBToColor(
loadhere.myPalette.r[i + startIndex],
loadhere.myPalette.g[i + startIndex],
loadhere.myPalette.b[i + startIndex]);