Mercurial > hg > openttd
changeset 18172:6b655732c349 draft
(svn r23001) -Feature: [NewGRF] Automatically switch to a 32 bpp blitter on NewGRF indication.
author | michi_cc <michi_cc@openttd.org> |
---|---|
date | Tue, 04 Oct 2011 21:35:52 +0000 |
parents | 00edd5060cd9 |
children | 4a83f4b2e636 |
files | src/gfxinit.cpp src/newgrf.cpp src/newgrf_config.h |
diffstat | 3 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -214,6 +214,13 @@ /* 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();
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6993,6 +6993,28 @@ 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('DESC', ChangeGRFDescription), AllowedSubtags('NPAR', ChangeGRFNumUsedParams), AllowedSubtags('PALS', ChangeGRFPalette), + AllowedSubtags('BLTR', ChangeGRFBlitter), AllowedSubtags('VRSN', ChangeGRFVersion), AllowedSubtags('MINV', ChangeGRFMinVersion), AllowedSubtags('PARA', HandleParameterInfo),
--- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -58,6 +58,8 @@ 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 @@ 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. };