Unfinished proof of concept regarding my compromise with LordHoto in IRC.
svn-id: r41464
This commit is contained in:
parent
6adbd0c41e
commit
2ee51a8fa1
6 changed files with 48 additions and 17 deletions
|
@ -128,7 +128,7 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
|
||||||
errors |= kTransactionPixelFormatNotSupported;
|
errors |= kTransactionPixelFormatNotSupported;
|
||||||
|
|
||||||
_videoMode.format = _oldVideoMode.format;
|
_videoMode.format = _oldVideoMode.format;
|
||||||
_screenFormat = getPixelFormat(_videoMode.format);
|
_screenFormat = _videoMode.format;
|
||||||
#endif
|
#endif
|
||||||
} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
|
} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
|
||||||
errors |= kTransactionSizeChangeFailed;
|
errors |= kTransactionSizeChangeFailed;
|
||||||
|
@ -362,7 +362,7 @@ Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List<Graphics::Col
|
||||||
|
|
||||||
//no need to keep searching if the screen
|
//no need to keep searching if the screen
|
||||||
//is already in one of the desired formats
|
//is already in one of the desired formats
|
||||||
if (format == _videoMode.format)
|
if (getPixelFormat(format) == _videoMode.format)
|
||||||
return format;
|
return format;
|
||||||
|
|
||||||
formatList.pop_front();
|
formatList.pop_front();
|
||||||
|
@ -380,7 +380,7 @@ Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List<Graphics::Col
|
||||||
return Graphics::kFormatCLUT8;
|
return Graphics::kFormatCLUT8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSystem_SDL::initFormat(Graphics::ColorMode format) {
|
void OSystem_SDL::initFormat(Graphics::PixelFormat format) {
|
||||||
assert(_transactionMode == kTransactionActive);
|
assert(_transactionMode == kTransactionActive);
|
||||||
|
|
||||||
//avoid redundant format changes
|
//avoid redundant format changes
|
||||||
|
@ -389,10 +389,11 @@ void OSystem_SDL::initFormat(Graphics::ColorMode format) {
|
||||||
|
|
||||||
_videoMode.format = format;
|
_videoMode.format = format;
|
||||||
_transactionDetails.formatChanged = true;
|
_transactionDetails.formatChanged = true;
|
||||||
_screenFormat = getPixelFormat(format);
|
_screenFormat = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
//This should only ever be called with a format that is known supported.
|
//TODO: Move this out of OSystem and into Graphics, where engine can access it.
|
||||||
|
//TODO: ABGR support
|
||||||
Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) {
|
Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) {
|
||||||
Graphics::PixelFormat result;
|
Graphics::PixelFormat result;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
@ -407,6 +408,35 @@ Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) {
|
||||||
result.gLoss = 2;
|
result.gLoss = 2;
|
||||||
result.rLoss = result.bLoss = 3;
|
result.rLoss = result.bLoss = 3;
|
||||||
break;
|
break;
|
||||||
|
case Graphics::kFormatXRGB1555:
|
||||||
|
//Special case, alpha bit is always high in this mode.
|
||||||
|
result.aLoss = 7;
|
||||||
|
result.bytesPerPixel = 2;
|
||||||
|
result.rLoss = result.gLoss = result.bLoss = 3;
|
||||||
|
result.bShift = 0;
|
||||||
|
result.gShift = result.bShift + result.bBits();
|
||||||
|
result.rShift = result.gShift + result.gBits();
|
||||||
|
result.aShift = result.rShift + result.rBits();
|
||||||
|
//HACK: there should be a clean way to handle setting
|
||||||
|
//up the color order without prematurely returning
|
||||||
|
return result;
|
||||||
|
case Graphics::kFormatRGBA4444:
|
||||||
|
result.bytesPerPixel = 2;
|
||||||
|
result.aLoss = result.gLoss = result.rLoss = result.bLoss = 4;
|
||||||
|
break;
|
||||||
|
case Graphics::kFormatRGB888:
|
||||||
|
result.bytesPerPixel = 3;
|
||||||
|
result.aLoss = 8;
|
||||||
|
result.gLoss = result.rLoss = result.bLoss = 0;
|
||||||
|
break;
|
||||||
|
case Graphics::kFormatRGBA6666:
|
||||||
|
result.bytesPerPixel = 3;
|
||||||
|
result.aLoss = result.gLoss = result.rLoss = result.bLoss = 2;
|
||||||
|
break;
|
||||||
|
case Graphics::kFormatRGBA8888:
|
||||||
|
result.bytesPerPixel = 4;
|
||||||
|
result.aLoss = result.gLoss = result.rLoss = result.bLoss = 0;
|
||||||
|
break;
|
||||||
case Graphics::kFormatCLUT8:
|
case Graphics::kFormatCLUT8:
|
||||||
default:
|
default:
|
||||||
result.bytesPerPixel = 1;
|
result.bytesPerPixel = 1;
|
||||||
|
@ -414,6 +444,7 @@ Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) {
|
||||||
result.rLoss = result.gLoss = result.bLoss = result.aLoss = 8;
|
result.rLoss = result.gLoss = result.bLoss = result.aLoss = 8;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.aShift = 0;
|
result.aShift = 0;
|
||||||
result.bShift = result.aBits();
|
result.bShift = result.aBits();
|
||||||
result.gShift = result.bShift + result.bBits();
|
result.gShift = result.bShift + result.bBits();
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
// Set the depth and format of the video bitmap
|
// Set the depth and format of the video bitmap
|
||||||
// Typically, CLUT8
|
// Typically, CLUT8
|
||||||
virtual void initFormat(Graphics::ColorMode format);
|
virtual void initFormat(Graphics::PixelFormat format);
|
||||||
|
|
||||||
// Game screen
|
// Game screen
|
||||||
virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
|
virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
|
||||||
|
@ -302,7 +302,7 @@ protected:
|
||||||
int screenWidth, screenHeight;
|
int screenWidth, screenHeight;
|
||||||
int overlayWidth, overlayHeight;
|
int overlayWidth, overlayHeight;
|
||||||
#ifdef ENABLE_16BIT
|
#ifdef ENABLE_16BIT
|
||||||
Graphics::ColorMode format;
|
Graphics::PixelFormat format;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
VideoState _videoMode, _oldVideoMode;
|
VideoState _videoMode, _oldVideoMode;
|
||||||
|
|
|
@ -227,7 +227,7 @@ static void setupGraphics(OSystem &system) {
|
||||||
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
|
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
|
||||||
|
|
||||||
#ifdef ENABLE_16BIT
|
#ifdef ENABLE_16BIT
|
||||||
system.initFormat(Graphics::kFormatCLUT8);
|
system.initFormat(system.getPixelFormat(Graphics::kFormatCLUT8));
|
||||||
#endif
|
#endif
|
||||||
system.initSize(320, 200);
|
system.initSize(320, 200);
|
||||||
|
|
||||||
|
|
|
@ -374,7 +374,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param format A pixel format that the backend screen will use
|
* @param format A pixel format that the backend screen will use
|
||||||
*/
|
*/
|
||||||
virtual void initFormat(Graphics::ColorMode format) = 0;
|
virtual void initFormat(Graphics::PixelFormat format) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the pixel format description of the screen.
|
* Returns the pixel format description of the screen.
|
||||||
|
|
|
@ -139,7 +139,7 @@ void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Gr
|
||||||
#ifdef ENABLE_16BIT
|
#ifdef ENABLE_16BIT
|
||||||
Graphics::ColorMode format = g_system->findCompatibleFormat(formatList);
|
Graphics::ColorMode format = g_system->findCompatibleFormat(formatList);
|
||||||
debug("%X",format); //TODO: set up the pixelFormat here
|
debug("%X",format); //TODO: set up the pixelFormat here
|
||||||
g_system->initFormat(format);
|
g_system->initFormat(g_system->getPixelFormat(format));
|
||||||
#endif
|
#endif
|
||||||
g_system->initSize(width, height);
|
g_system->initSize(width, height);
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,15 @@ namespace Graphics {
|
||||||
* to get the applicable color order.
|
* to get the applicable color order.
|
||||||
*/
|
*/
|
||||||
enum ColorMode {
|
enum ColorMode {
|
||||||
kFormatCLUT8 = 0,
|
kFormatCLUT8 = 0, //256 color palette.
|
||||||
kFormatRGB555 = 1,
|
kFormatRGB555 = 1,
|
||||||
kFormatRGB556 = 2, // 6 bits for blue, in case this ever happens
|
kFormatXRGB1555 = 2, // Special case, high bit has special purpose, which may be alpha.
|
||||||
|
// Engines should probably handle this bit internally and pass RGB only, though
|
||||||
kFormatRGB565 = 3,
|
kFormatRGB565 = 3,
|
||||||
kFormatRGB655 = 4, // 6 bits for red, in case this ever happens
|
kFormatRGBA4444 = 4, // since this mode is commonly supported in game hardware, some unimplemented engines may use it?
|
||||||
kFormatRGBA4444 = 5,
|
kFormatRGB888 = 5,
|
||||||
kFormatRGB888 = 6,
|
kFormatRGBA6666 = 6, // I've never heard of this, but it's vaguely plausible
|
||||||
kFormatRGBA6666 = 7, // I've never heard of this, but it's theoretically possible
|
kFormatRGBA8888 = 7
|
||||||
kFormatRGBA8888 = 8
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue