(svn r23001) -Feature: [NewGRF] Automatically switch to a 32 bpp blitter on NewGRF indication.

pull/155/head
michi_cc 13 years ago
parent 7b35dd4f54
commit e07c107eb1

@ -214,6 +214,13 @@ static void SwitchNewGRFBlitter()
/* Get blitter of base set. */
bool is_32bpp = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP;
/* Get combined blitter mode of all NewGRFs. */
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_INIT_ONLY)) continue;
if (c->palette & GRFP_BLT_32BPP) is_32bpp = true;
}
/* A GRF would like a 32 bpp blitter, switch blitter if needed. Never switch if the blitter was specified by the user. */
if (_blitter_autodetected && is_32bpp && BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() != 0 && BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() < 16) {
const char *cur_blitter = BlitterFactoryBase::GetCurrentBlitter()->GetName();

@ -6993,6 +6993,28 @@ static bool ChangeGRFPalette(size_t len, ByteReader *buf)
return true;
}
/** Callback function for 'INFO'->'BLTR' to set the blitter info. */
static bool ChangeGRFBlitter(size_t len, ByteReader *buf)
{
if (len != 1) {
grfmsg(2, "StaticGRFInfo: expected only 1 byte for 'INFO'->'BLTR' but got " PRINTF_SIZE ", ignoring this field", len);
buf->Skip(len);
} else {
char data = buf->ReadByte();
GRFPalette pal = GRFP_BLT_UNSET;
switch (data) {
case '8': pal = GRFP_BLT_UNSET; break;
case '3': pal = GRFP_BLT_32BPP; break;
default:
grfmsg(2, "StaticGRFInfo: unexpected value '%02x' for 'INFO'->'BLTR', ignoring this field", data);
return true;
}
_cur.grfconfig->palette &= ~GRFP_BLT_MASK;
_cur.grfconfig->palette |= pal;
}
return true;
}
/** Callback function for 'INFO'->'VRSN' to the version of the NewGRF. */
static bool ChangeGRFVersion(size_t len, ByteReader *buf)
{
@ -7282,6 +7304,7 @@ AllowedSubtags _tags_info[] = {
AllowedSubtags('DESC', ChangeGRFDescription),
AllowedSubtags('NPAR', ChangeGRFNumUsedParams),
AllowedSubtags('PALS', ChangeGRFPalette),
AllowedSubtags('BLTR', ChangeGRFBlitter),
AllowedSubtags('VRSN', ChangeGRFVersion),
AllowedSubtags('MINV', ChangeGRFMinVersion),
AllowedSubtags('PARA', HandleParameterInfo),

@ -58,6 +58,8 @@ enum GRFPalette {
GRFP_USE_BIT = 0, ///< The bit used for storing the palette to use.
GRFP_GRF_OFFSET = 2, ///< The offset of the GRFP_GRF data.
GRFP_GRF_SIZE = 2, ///< The size of the GRFP_GRF data.
GRFP_BLT_OFFSET = 4, ///< The offset of the GRFP_BLT data.
GRFP_BLT_SIZE = 1, ///< The size of the GRFP_BLT data.
GRFP_USE_DOS = 0x0, ///< The palette state is set to use the DOS palette.
GRFP_USE_WINDOWS = 0x1, ///< The palette state is set to use the Windows palette.
@ -68,6 +70,10 @@ enum GRFPalette {
GRFP_GRF_WINDOWS = 0x2 << GRFP_GRF_OFFSET, ///< The NewGRF says the Windows palette can be used.
GRFP_GRF_ANY = GRFP_GRF_DOS | GRFP_GRF_WINDOWS, ///< The NewGRF says any palette can be used.
GRFP_GRF_MASK = GRFP_GRF_ANY, ///< Bitmask to get only the NewGRF supplied information.
GRFP_BLT_UNSET = 0x0 << GRFP_BLT_OFFSET, ///< The NewGRF provided no information or doesn't care about a 32 bpp blitter.
GRFP_BLT_32BPP = 0x1 << GRFP_BLT_OFFSET, ///< The NewGRF prefers a 32 bpp blitter.
GRFP_BLT_MASK = GRFP_BLT_32BPP, ///< Bitmask to only get the blitter information.
};

Loading…
Cancel
Save