mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-12 06:00:48 +00:00
ZVISION: Set all the internal graphics operations to use RGB555 (1/2)
This is the first part of the changes to make the engine use RGB555 internally again. This is done to simplify the rendering pipeline - the engine will use RGB555 internally, but will output to RGB565. The overall changes have been broken into two commits, thus this first commit will break all the game colors
This commit is contained in:
parent
84341a889c
commit
e8e21fabe4
@ -37,7 +37,7 @@ class Effect {
|
||||
public:
|
||||
|
||||
Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) {
|
||||
_surface.create(_region.width(), _region.height(), _engine->_pixelFormat);
|
||||
_surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat);
|
||||
}
|
||||
virtual ~Effect() {}
|
||||
|
||||
|
@ -79,10 +79,10 @@ const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) {
|
||||
if (it->inEffect) {
|
||||
// Not 100% equivalent, but looks nice and not buggy
|
||||
uint8 sr, sg, sb;
|
||||
_engine->_pixelFormat.colorToRGB(lineBuf[i], 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->_pixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db);
|
||||
_engine->_resourcePixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db);
|
||||
uint16 fr = dr + sr;
|
||||
if (fr > 255)
|
||||
fr = 255;
|
||||
@ -92,7 +92,7 @@ const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) {
|
||||
uint16 fb = db + sb;
|
||||
if (fb > 255)
|
||||
fb = 255;
|
||||
lineBuf[i] = _engine->_pixelFormat.RGBToColor(fr, fg, fb);
|
||||
lineBuf[i] = _engine->_resourcePixelFormat.RGBToColor(fr, fg, fb);
|
||||
}
|
||||
cnt++;
|
||||
if (cnt >= it->count) {
|
||||
@ -138,14 +138,14 @@ void FogFx::update() {
|
||||
|
||||
// Not 100% equivalent, but looks nice and not buggy
|
||||
|
||||
_colorMap[31] = _engine->_pixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3);
|
||||
_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 = (float)_r * perc;
|
||||
uint8 cg = (float)_g * perc;
|
||||
uint8 cb = (float)_b * perc;
|
||||
_colorMap[i] = _engine->_pixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3);
|
||||
_colorMap[i] = _engine->_resourcePixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,10 +59,10 @@ const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) {
|
||||
|
||||
if (_pos < 0) {
|
||||
uint8 cc = ((-_pos) & 0x1F) << 3;
|
||||
dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc);
|
||||
dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
|
||||
} else {
|
||||
uint8 cc = (_pos & 0x1F) << 3;
|
||||
dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc);
|
||||
dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc);
|
||||
}
|
||||
|
||||
for (uint16 j = 0; j < _surface.h; j++) {
|
||||
|
@ -580,12 +580,6 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c
|
||||
// The two %*u are usually 0 and dont seem to have a use
|
||||
sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate);
|
||||
|
||||
if (_mask > 0) {
|
||||
byte r, g, b;
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
|
||||
_mask = _engine->_pixelFormat.RGBToColor(r, g, b);
|
||||
}
|
||||
|
||||
_fileName = Common::String(fileName);
|
||||
}
|
||||
|
||||
@ -648,12 +642,6 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C
|
||||
"%24s %u %u %u %u %u %u %d %*u %*u %d %d",
|
||||
fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate);
|
||||
|
||||
if (_mask > 0) {
|
||||
byte r, g, b;
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b);
|
||||
_mask = _engine->_pixelFormat.RGBToColor(r, g, b);
|
||||
}
|
||||
|
||||
_fileName = Common::String(fileName);
|
||||
}
|
||||
|
||||
@ -861,21 +849,12 @@ ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, c
|
||||
_y = 0;
|
||||
|
||||
char fileName[25];
|
||||
int color;
|
||||
|
||||
sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &color);
|
||||
sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &_backgroundColor);
|
||||
|
||||
_fileName = Common::String(fileName);
|
||||
|
||||
if (color >= 0) {
|
||||
byte r, g, b;
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b);
|
||||
_backgroundColor = _engine->_pixelFormat.RGBToColor(r, g, b);
|
||||
} else {
|
||||
_backgroundColor = color;
|
||||
}
|
||||
|
||||
if (color > 65535) {
|
||||
if (_backgroundColor > 65535) {
|
||||
warning("Background color for ActionSetPartialScreen is bigger than a uint16");
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ bool InputControl::process(uint32 deltaTimeInMillis) {
|
||||
// Blit the text using the RenderManager
|
||||
|
||||
Graphics::Surface txt;
|
||||
txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat);
|
||||
txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_resourcePixelFormat);
|
||||
|
||||
if (!_readOnly || !_focused)
|
||||
_txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt);
|
||||
|
@ -67,7 +67,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt
|
||||
|
||||
if (!_rectangle.isEmpty()) {
|
||||
_surface = new Graphics::Surface;
|
||||
_surface->create(_rectangle.width(), _rectangle.height(), _engine->_pixelFormat);
|
||||
_surface->create(_rectangle.width(), _rectangle.height(), _engine->_resourcePixelFormat);
|
||||
_surface->fillRect(Common::Rect(_surface->w, _surface->h), 0);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file
|
||||
|
||||
delete infile;
|
||||
}
|
||||
_img.create(_r.width(), _r.height(), _engine->_pixelFormat);
|
||||
_img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat);
|
||||
_style._sharp = true;
|
||||
_style.readAllStyle(_txtbuf);
|
||||
_style.setFont(_fnt);
|
||||
@ -158,7 +158,7 @@ void ttyTextNode::newline() {
|
||||
}
|
||||
|
||||
void ttyTextNode::outchar(uint16 chr) {
|
||||
uint32 clr = _engine->_pixelFormat.RGBToColor(_style._red, _style._green, _style._blue);
|
||||
uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue);
|
||||
|
||||
if (_dx + _fnt.getCharWidth(chr) > _r.width())
|
||||
newline();
|
||||
|
@ -298,7 +298,7 @@ void cTxtStyle::setFont(StyledTTFont &font) {
|
||||
|
||||
Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
|
||||
style.setFontStyle(fnt);
|
||||
uint32 clr = _engine->_pixelFormat.RGBToColor(style._red, style._green, style._blue);
|
||||
uint32 clr = _engine->_resourcePixelFormat.RGBToColor(style._red, style._green, style._blue);
|
||||
return fnt.renderSolidText(txt, clr);
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Gra
|
||||
|
||||
dst.fillRect(Common::Rect(dst.w, dst.h), 0);
|
||||
|
||||
uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue);
|
||||
uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue);
|
||||
|
||||
int16 w;
|
||||
|
||||
|
@ -218,7 +218,7 @@ Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint
|
||||
if (_font) {
|
||||
int16 w = _font->getStringWidth(str);
|
||||
if (w && w < 1024) {
|
||||
tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat);
|
||||
tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat);
|
||||
drawString(tmp, str, 0, 0, w, color);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream)
|
||||
return;
|
||||
}
|
||||
|
||||
_currentFrameBuffer.create(_width, _height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
|
||||
_currentFrameBuffer.create(_width, _height, getPixelFormat());
|
||||
_frameBufferByteSize = _width * _height * sizeof(uint16);
|
||||
|
||||
_frames = new Frame[_frameCount];
|
||||
@ -239,12 +239,7 @@ void RLFDecoder::RLFVideoTrack::decodeMaskedRunLengthEncoding(int8 *source, int8
|
||||
return;
|
||||
}
|
||||
|
||||
byte r, g, b;
|
||||
// NOTE: Color masks can't be used here, since accurate colors
|
||||
// are required to handle transparency correctly
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
|
||||
uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b);
|
||||
WRITE_UINT16(dest + destOffset, destColor);
|
||||
WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
|
||||
|
||||
sourceOffset += 2;
|
||||
destOffset += 2;
|
||||
@ -288,12 +283,7 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8
|
||||
return;
|
||||
}
|
||||
|
||||
byte r, g, b;
|
||||
// NOTE: Color masks can't be used here, since accurate colors
|
||||
// are required to handle transparency correctly
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
|
||||
uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b);
|
||||
WRITE_UINT16(dest + destOffset, destColor);
|
||||
WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
|
||||
|
||||
sourceOffset += 2;
|
||||
destOffset += 2;
|
||||
@ -307,11 +297,7 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8
|
||||
return;
|
||||
}
|
||||
|
||||
byte r, g, b;
|
||||
// NOTE: Color masks can't be used here, since accurate colors
|
||||
// are required to handle transparency correctly
|
||||
Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
|
||||
uint16 sampleColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b);
|
||||
uint16 sampleColor = READ_LE_UINT16(source + sourceOffset);
|
||||
sourceOffset += 2;
|
||||
|
||||
numberOfCopy = numberOfSamples + 2;
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
|
||||
uint16 getWidth() const { return _width; }
|
||||
uint16 getHeight() const { return _height; }
|
||||
Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); /*RGB 565*/ }
|
||||
Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); /* RGB 555 */ }
|
||||
int getCurFrame() const { return _curFrame; }
|
||||
int getFrameCount() const { return _frameCount; }
|
||||
const Graphics::Surface *decodeNextFrame();
|
||||
|
@ -191,7 +191,7 @@ void ZVision::initialize() {
|
||||
|
||||
// Create managers
|
||||
_scriptManager = new ScriptManager(this);
|
||||
_renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _screenPixelFormat);
|
||||
_renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat);
|
||||
_saveManager = new SaveManager(this);
|
||||
_stringManager = new StringManager(this);
|
||||
_cursorManager = new CursorManager(this, _resourcePixelFormat);
|
||||
|
Loading…
x
Reference in New Issue
Block a user