mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
AGS: Enable setting paletted graphics mode
This commit is contained in:
parent
827efed918
commit
aec0a06700
@ -181,13 +181,33 @@ SaveStateList AGSEngine::listSaves() const {
|
||||
return getMetaEngine()->listSaves(_targetName.c_str());
|
||||
}
|
||||
|
||||
void AGSEngine::setGraphicsMode(size_t w, size_t h) {
|
||||
bool AGSEngine::getPixelFormat(int depth, Graphics::PixelFormat &format) const {
|
||||
Common::List<Graphics::PixelFormat> supportedFormatsList = g_system->getSupportedFormats();
|
||||
|
||||
if (depth == 8) {
|
||||
format = Graphics::PixelFormat::createFormatCLUT8();
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Common::List<Graphics::PixelFormat>::iterator it =
|
||||
supportedFormatsList.begin(); it != supportedFormatsList.end(); ++it) {
|
||||
if (it->bpp() == depth) {
|
||||
format = *it;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void AGSEngine::setGraphicsMode(size_t w, size_t h, int colorDepth) {
|
||||
Common::List<Graphics::PixelFormat> supportedFormatsList = g_system->getSupportedFormats();
|
||||
Graphics::PixelFormat format;
|
||||
if (!supportedFormatsList.empty())
|
||||
format = supportedFormatsList.front();
|
||||
else
|
||||
format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
||||
if (!getPixelFormat(colorDepth, format))
|
||||
error("Unsupported color depth %d", colorDepth);
|
||||
//Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
||||
|
||||
initGraphics(w, h, &format);
|
||||
|
||||
_rawScreen = new Graphics::Screen();
|
||||
|
@ -117,9 +117,14 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Setse up the graphics mode
|
||||
* Returns a pixel format for the given color depth.
|
||||
*/
|
||||
void setGraphicsMode(size_t w, size_t h);
|
||||
bool getPixelFormat(int depth, Graphics::PixelFormat &format) const;
|
||||
|
||||
/**
|
||||
* Sets up the graphics mode
|
||||
*/
|
||||
void setGraphicsMode(size_t w, size_t h, int depth);
|
||||
|
||||
bool hasFeature(EngineFeature f) const override {
|
||||
return
|
||||
|
@ -58,15 +58,14 @@ ScummVMRendererGraphicsDriver::ScummVMRendererGraphicsDriver() {
|
||||
}
|
||||
|
||||
bool ScummVMRendererGraphicsDriver::IsModeSupported(const DisplayMode &mode) {
|
||||
if (mode.Width <= 0 || mode.Height <= 0) {
|
||||
warning("Invalid resolution parameters: %d x %d", mode.Width, mode.Height);
|
||||
if (mode.Width <= 0 || mode.Height <= 0 || mode.ColorDepth <= 0) {
|
||||
warning("Invalid resolution parameters: %d x %d x %d",
|
||||
mode.Width, mode.Height, mode.ColorDepth);
|
||||
return false;
|
||||
}
|
||||
if (mode.ColorDepth != 32) {
|
||||
warning("Display colour depth not supported: %d", mode.ColorDepth);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Graphics::PixelFormat format;
|
||||
return ::AGS::g_vm->getPixelFormat(mode.ColorDepth, format);
|
||||
}
|
||||
|
||||
int ScummVMRendererGraphicsDriver::GetDisplayDepthForNativeDepth(int native_color_depth) const {
|
||||
@ -112,7 +111,7 @@ bool ScummVMRendererGraphicsDriver::SetDisplayMode(const DisplayMode &mode) {
|
||||
return false;
|
||||
|
||||
const int driver = mode.Windowed ? GFX_SCUMMVM : GFX_SCUMMVM_FULLSCREEN;
|
||||
if (set_gfx_mode(driver, mode.Width, mode.Height, 0, 0) != 0)
|
||||
if (set_gfx_mode(driver, mode.Width, mode.Height, mode.ColorDepth) != 0)
|
||||
return false;
|
||||
|
||||
OnInit();
|
||||
|
@ -48,11 +48,6 @@ void color::writeToFile(AGS::Shared::Stream *file) const {
|
||||
file->WriteByte(filler);
|
||||
}
|
||||
|
||||
|
||||
void set_color(int idx, const RGB *p) {
|
||||
_G(current_palette)[idx] = *p;
|
||||
}
|
||||
|
||||
void set_palette(const PALETTE p) {
|
||||
for (int idx = 0; idx < PAL_SIZE; ++idx)
|
||||
_G(current_palette)[idx] = p[idx];
|
||||
|
@ -48,11 +48,11 @@ class Stream;
|
||||
#include "common/pack-start.h" // START STRUCT PACKING
|
||||
|
||||
struct color {
|
||||
byte r, g, b;
|
||||
byte filler;
|
||||
byte r, g, b;
|
||||
byte filler;
|
||||
|
||||
void readFromFile(AGS::Shared::Stream *file);
|
||||
void writeToFile(AGS::Shared::Stream *file) const;
|
||||
void readFromFile(AGS::Shared::Stream *file);
|
||||
void writeToFile(AGS::Shared::Stream *file) const;
|
||||
} PACKED_STRUCT;
|
||||
|
||||
typedef color RGB;
|
||||
@ -61,30 +61,29 @@ typedef RGB PALETTE[PAL_SIZE];
|
||||
#include "common/pack-end.h" // END STRUCT PACKING
|
||||
|
||||
struct RGB_MAP {
|
||||
byte data[32][32][32];
|
||||
byte data[32][32][32];
|
||||
};
|
||||
|
||||
struct COLOR_MAP {
|
||||
byte data[PAL_SIZE][PAL_SIZE];
|
||||
byte data[PAL_SIZE][PAL_SIZE];
|
||||
};
|
||||
|
||||
enum BlenderMode {
|
||||
kSourceAlphaBlender,
|
||||
kArgbToArgbBlender,
|
||||
kArgbToRgbBlender,
|
||||
kRgbToArgbBlender,
|
||||
kRgbToRgbBlender,
|
||||
kAlphaPreservedBlenderMode,
|
||||
kOpaqueBlenderMode,
|
||||
kAdditiveBlenderMode,
|
||||
kTintBlenderMode,
|
||||
kTintLightBlenderMode
|
||||
kSourceAlphaBlender,
|
||||
kArgbToArgbBlender,
|
||||
kArgbToRgbBlender,
|
||||
kRgbToArgbBlender,
|
||||
kRgbToRgbBlender,
|
||||
kAlphaPreservedBlenderMode,
|
||||
kOpaqueBlenderMode,
|
||||
kAdditiveBlenderMode,
|
||||
kTintBlenderMode,
|
||||
kTintLightBlenderMode
|
||||
};
|
||||
|
||||
AL_ARRAY(const int, _rgb_scale_5);
|
||||
AL_ARRAY(const int, _rgb_scale_6);
|
||||
|
||||
AL_FUNC(void, set_color, (int idx, AL_CONST RGB *p));
|
||||
AL_FUNC(void, set_palette, (AL_CONST PALETTE p));
|
||||
AL_FUNC(void, set_palette_range, (AL_CONST PALETTE p, int from, int to, int retracesync));
|
||||
|
||||
|
@ -44,11 +44,11 @@ int get_color_conversion() {
|
||||
return color_conversion;
|
||||
}
|
||||
|
||||
int set_gfx_mode(int card, int w, int h, int v_w, int v_h) {
|
||||
int set_gfx_mode(int card, int w, int h, int depth) {
|
||||
// Graphics shutdown can be ignored
|
||||
if (card != -1) {
|
||||
assert(card == SCUMMVM_ID);
|
||||
::AGS::g_vm->setGraphicsMode(w, h);
|
||||
::AGS::g_vm->setGraphicsMode(w, h, depth);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ namespace AGS3 {
|
||||
|
||||
AL_FUNC(void, set_color_conversion, (int mode));
|
||||
AL_FUNC(int, get_color_conversion, ());
|
||||
AL_FUNC(int, set_gfx_mode, (int card, int w, int h, int v_w, int v_h));
|
||||
AL_FUNC(int, set_gfx_mode, (int card, int w, int h, int depth));
|
||||
|
||||
AL_FUNC(void, set_clip_rect, (BITMAP *bitmap, int x1, int y1, int x2, int y2));
|
||||
AL_FUNC(void, get_clip_rect, (BITMAP *bitmap, int *x1, int *y1, int *x2, int *y2));
|
||||
|
Loading…
Reference in New Issue
Block a user