mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 02:10:28 +00:00
SLUDGE: replace sludge colours by pixelformat
This commit is contained in:
parent
d5379c212c
commit
77d5c7235d
@ -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;
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
#include "sludge/allfiles.h"
|
||||
#include "sludge/colours.h"
|
||||
#include "sludge/backdrop.h"
|
||||
#include "sludge/graphics.h"
|
||||
#include "sludge/newfatal.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user