mirror of
https://github.com/holub/mame
synced 2025-07-06 02:18:09 +03:00
add a not BIOS machine filter (useful in composite filters), support RGB PNG with transparent pen because why not
This commit is contained in:
parent
b978ce8af3
commit
1c4c96a0cf
@ -44,6 +44,7 @@ constexpr char const *machine_filter_names[machine_filter::COUNT] = {
|
|||||||
__("Category"),
|
__("Category"),
|
||||||
__("Favorites"),
|
__("Favorites"),
|
||||||
__("BIOS"),
|
__("BIOS"),
|
||||||
|
__("Not BIOS"),
|
||||||
__("Parents"),
|
__("Parents"),
|
||||||
__("Clones"),
|
__("Clones"),
|
||||||
__("Manufacturer"),
|
__("Manufacturer"),
|
||||||
@ -635,6 +636,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <machine_filter::type Type = machine_filter::BIOS>
|
||||||
|
class bios_machine_filter_impl : public simple_filter_impl_base<machine_filter, Type>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bios_machine_filter_impl(char const *value, emu_file *file, unsigned indent) { }
|
||||||
|
|
||||||
|
virtual bool apply(game_driver const &driver) const override { return driver.flags & machine_flags::IS_BIOS_ROOT; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <machine_filter::type Type = machine_filter::PARENTS>
|
template <machine_filter::type Type = machine_filter::PARENTS>
|
||||||
class parents_machine_filter_impl : public simple_filter_impl_base<machine_filter, Type>
|
class parents_machine_filter_impl : public simple_filter_impl_base<machine_filter, Type>
|
||||||
{
|
{
|
||||||
@ -694,15 +705,6 @@ public:
|
|||||||
// concrete machine filters
|
// concrete machine filters
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
class bios_machine_filter : public simple_filter_impl_base<machine_filter, machine_filter::BIOS>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bios_machine_filter(char const *value, emu_file *file, unsigned indent) { }
|
|
||||||
|
|
||||||
virtual bool apply(game_driver const &driver) const override { return driver.flags & machine_flags::IS_BIOS_ROOT; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class manufacturer_machine_filter : public choice_filter_impl_base<machine_filter, machine_filter::MANUFACTURER>
|
class manufacturer_machine_filter : public choice_filter_impl_base<machine_filter, machine_filter::MANUFACTURER>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -752,6 +754,7 @@ public:
|
|||||||
|
|
||||||
using working_machine_filter = working_machine_filter_impl<>;
|
using working_machine_filter = working_machine_filter_impl<>;
|
||||||
using mechanical_machine_filter = mechanical_machine_filter_impl<>;
|
using mechanical_machine_filter = mechanical_machine_filter_impl<>;
|
||||||
|
using bios_machine_filter = bios_machine_filter_impl<>;
|
||||||
using parents_machine_filter = parents_machine_filter_impl<>;
|
using parents_machine_filter = parents_machine_filter_impl<>;
|
||||||
using save_machine_filter = save_machine_filter_impl<>;
|
using save_machine_filter = save_machine_filter_impl<>;
|
||||||
using chd_machine_filter = chd_machine_filter_impl<>;
|
using chd_machine_filter = chd_machine_filter_impl<>;
|
||||||
@ -759,6 +762,7 @@ using vertical_machine_filter = vertical_machine_filter_impl<>;
|
|||||||
|
|
||||||
using not_working_machine_filter = inverted_machine_filter<working_machine_filter_impl, machine_filter::NOT_WORKING>;
|
using not_working_machine_filter = inverted_machine_filter<working_machine_filter_impl, machine_filter::NOT_WORKING>;
|
||||||
using not_mechanical_machine_filter = inverted_machine_filter<mechanical_machine_filter_impl, machine_filter::NOT_MECHANICAL>;
|
using not_mechanical_machine_filter = inverted_machine_filter<mechanical_machine_filter_impl, machine_filter::NOT_MECHANICAL>;
|
||||||
|
using not_bios_machine_filter = inverted_machine_filter<bios_machine_filter_impl, machine_filter::NOT_BIOS>;
|
||||||
using clones_machine_filter = inverted_machine_filter<parents_machine_filter_impl, machine_filter::CLONES>;
|
using clones_machine_filter = inverted_machine_filter<parents_machine_filter_impl, machine_filter::CLONES>;
|
||||||
using nosave_machine_filter = inverted_machine_filter<save_machine_filter_impl, machine_filter::NOSAVE>;
|
using nosave_machine_filter = inverted_machine_filter<save_machine_filter_impl, machine_filter::NOSAVE>;
|
||||||
using nochd_machine_filter = inverted_machine_filter<chd_machine_filter_impl, machine_filter::NOCHD>;
|
using nochd_machine_filter = inverted_machine_filter<chd_machine_filter_impl, machine_filter::NOCHD>;
|
||||||
@ -1150,6 +1154,8 @@ public:
|
|||||||
case NOT_WORKING: return WORKING == m;
|
case NOT_WORKING: return WORKING == m;
|
||||||
case MECHANICAL: return NOT_MECHANICAL == m;
|
case MECHANICAL: return NOT_MECHANICAL == m;
|
||||||
case NOT_MECHANICAL: return MECHANICAL == m;
|
case NOT_MECHANICAL: return MECHANICAL == m;
|
||||||
|
case BIOS: return NOT_BIOS == m;
|
||||||
|
case NOT_BIOS: return BIOS == m;
|
||||||
case PARENTS: return CLONES == m;
|
case PARENTS: return CLONES == m;
|
||||||
case CLONES: return PARENTS == m;
|
case CLONES: return PARENTS == m;
|
||||||
case SAVE: return NOSAVE == m;
|
case SAVE: return NOSAVE == m;
|
||||||
@ -1162,7 +1168,6 @@ public:
|
|||||||
case ALL:
|
case ALL:
|
||||||
case CATEGORY:
|
case CATEGORY:
|
||||||
case FAVORITE:
|
case FAVORITE:
|
||||||
case BIOS:
|
|
||||||
case MANUFACTURER:
|
case MANUFACTURER:
|
||||||
case YEAR:
|
case YEAR:
|
||||||
case CUSTOM:
|
case CUSTOM:
|
||||||
@ -1433,6 +1438,8 @@ machine_filter::ptr machine_filter::create(type n, char const *value, emu_file *
|
|||||||
return std::make_unique<favorite_machine_filter>(value, file, indent);
|
return std::make_unique<favorite_machine_filter>(value, file, indent);
|
||||||
case BIOS:
|
case BIOS:
|
||||||
return std::make_unique<bios_machine_filter>(value, file, indent);
|
return std::make_unique<bios_machine_filter>(value, file, indent);
|
||||||
|
case NOT_BIOS:
|
||||||
|
return std::make_unique<not_bios_machine_filter>(value, file, indent);
|
||||||
case PARENTS:
|
case PARENTS:
|
||||||
return std::make_unique<parents_machine_filter>(value, file, indent);
|
return std::make_unique<parents_machine_filter>(value, file, indent);
|
||||||
case CLONES:
|
case CLONES:
|
||||||
|
@ -133,6 +133,7 @@ public:
|
|||||||
CATEGORY,
|
CATEGORY,
|
||||||
FAVORITE,
|
FAVORITE,
|
||||||
BIOS,
|
BIOS,
|
||||||
|
NOT_BIOS,
|
||||||
PARENTS,
|
PARENTS,
|
||||||
CLONES,
|
CLONES,
|
||||||
MANUFACTURER,
|
MANUFACTURER,
|
||||||
|
@ -543,15 +543,16 @@ public:
|
|||||||
// handle grayscale non-alpha case
|
// handle grayscale non-alpha case
|
||||||
uint32_t const bpp(pnginfo.bit_depth >> 3);
|
uint32_t const bpp(pnginfo.bit_depth >> 3);
|
||||||
std::uint16_t const transpen(pnginfo.trans ? fetch_16bit(pnginfo.trans.get()) : 0U);
|
std::uint16_t const transpen(pnginfo.trans ? fetch_16bit(pnginfo.trans.get()) : 0U);
|
||||||
|
unsigned const samp_shift((8 < pnginfo.bit_depth) ? 8 : 0);
|
||||||
for (std::uint32_t y = 0; dimensions.second > y; ++y)
|
for (std::uint32_t y = 0; dimensions.second > y; ++y)
|
||||||
{
|
{
|
||||||
for (std::uint32_t x = 0; dimensions.first > x; ++x, src += bpp)
|
for (std::uint32_t x = 0; dimensions.first > x; ++x, src += bpp)
|
||||||
{
|
{
|
||||||
std::uint16_t i((8 < pnginfo.bit_depth) ? fetch_16bit(src) : fetch_8bit(src));
|
std::uint16_t i_val((8 < pnginfo.bit_depth) ? fetch_16bit(src) : fetch_8bit(src));
|
||||||
std::uint8_t const a((pnginfo.trans && (transpen == i)) ? 0x00 : 0xff);
|
std::uint8_t const a_val((pnginfo.trans && (transpen == i_val)) ? 0x00 : 0xff);
|
||||||
i >>= (8 < pnginfo.bit_depth) ? 8 : 0;
|
i_val >>= samp_shift;
|
||||||
accumalpha &= a;
|
accumalpha &= a_val;
|
||||||
bitmap.pix32((y << y_shift) + y_offs, (x << x_shift) + x_offs) = rgb_t(a, i, i, i);
|
bitmap.pix32((y << y_shift) + y_offs, (x << x_shift) + x_offs) = rgb_t(a_val, i_val, i_val, i_val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,12 +577,23 @@ public:
|
|||||||
uint32_t const r(0 * bps);
|
uint32_t const r(0 * bps);
|
||||||
uint32_t const g(1 * bps);
|
uint32_t const g(1 * bps);
|
||||||
uint32_t const b(2 * bps);
|
uint32_t const b(2 * bps);
|
||||||
|
std::uint16_t const transpen_r(pnginfo.trans ? fetch_16bit(&pnginfo.trans[0]) : 0U);
|
||||||
|
std::uint16_t const transpen_g(pnginfo.trans ? fetch_16bit(&pnginfo.trans[2]) : 0U);
|
||||||
|
std::uint16_t const transpen_b(pnginfo.trans ? fetch_16bit(&pnginfo.trans[4]) : 0U);
|
||||||
|
unsigned const samp_shift((8 < pnginfo.bit_depth) ? 8 : 0);
|
||||||
for (std::uint32_t y = 0; dimensions.second > y; ++y)
|
for (std::uint32_t y = 0; dimensions.second > y; ++y)
|
||||||
{
|
{
|
||||||
for (std::uint32_t x = 0; dimensions.first > x; ++x, src += bpp)
|
for (std::uint32_t x = 0; dimensions.first > x; ++x, src += bpp)
|
||||||
{
|
{
|
||||||
rgb_t const pix(0xff, src[r], src[g], src[b]);
|
uint16_t r_val((8 < pnginfo.bit_depth) ? fetch_16bit(src) : fetch_8bit(src + r));
|
||||||
bitmap.pix32((y << y_shift) + y_offs, (x << x_shift) + x_offs) = pix;
|
uint16_t g_val((8 < pnginfo.bit_depth) ? fetch_16bit(src) : fetch_8bit(src + g));
|
||||||
|
uint16_t b_val((8 < pnginfo.bit_depth) ? fetch_16bit(src) : fetch_8bit(src + b));
|
||||||
|
std::uint8_t const a_val((pnginfo.trans && (transpen_r == r_val) && (transpen_g == g_val) && (transpen_b == b_val)) ? 0x00 : 0xff);
|
||||||
|
r_val >>= samp_shift;
|
||||||
|
g_val >>= samp_shift;
|
||||||
|
b_val >>= samp_shift;
|
||||||
|
accumalpha &= a_val;
|
||||||
|
bitmap.pix32((y << y_shift) + y_offs, (x << x_shift) + x_offs) = rgb_t(a_val, r_val, g_val, b_val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user