summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/palette.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/palette.cpp')
-rw-r--r--src/lib/util/palette.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/lib/util/palette.cpp b/src/lib/util/palette.cpp
index 196031d3694..c6a9e07d9d6 100644
--- a/src/lib/util/palette.cpp
+++ b/src/lib/util/palette.cpp
@@ -38,7 +38,7 @@ const rgb_t rgb_t::amber(247, 170, 0);
// entry for brightness
//-------------------------------------------------
-inline rgb_t palette_t::adjust_palette_entry(rgb_t entry, float brightness, float contrast, const UINT8 *gamma_map)
+inline rgb_t palette_t::adjust_palette_entry(rgb_t entry, float brightness, float contrast, const uint8_t *gamma_map)
{
int r = rgb_t::clamp(float(gamma_map[entry.r()]) * contrast + brightness);
int g = rgb_t::clamp(float(gamma_map[entry.g()]) * contrast + brightness);
@@ -69,7 +69,7 @@ palette_client::dirty_state::dirty_state()
// min/max values
//-------------------------------------------------
-const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
+const uint32_t *palette_client::dirty_state::dirty_list(uint32_t &mindirty, uint32_t &maxdirty)
{
// fill in the mindirty/maxdirty
mindirty = m_mindirty;
@@ -85,10 +85,10 @@ const UINT32 *palette_client::dirty_state::dirty_list(UINT32 &mindirty, UINT32 &
// dirty
//-------------------------------------------------
-void palette_client::dirty_state::resize(UINT32 colors)
+void palette_client::dirty_state::resize(uint32_t colors)
{
// resize to the correct number of dwords and mark all entries dirty
- UINT32 dirty_dwords = (colors + 31) / 32;
+ uint32_t dirty_dwords = (colors + 31) / 32;
m_dirty.resize(dirty_dwords);
memset(&m_dirty[0], 0xff, dirty_dwords*4);
@@ -105,7 +105,7 @@ void palette_client::dirty_state::resize(UINT32 colors)
// mark_dirty - mark a single entry dirty
//-------------------------------------------------
-void palette_client::dirty_state::mark_dirty(UINT32 index)
+void palette_client::dirty_state::mark_dirty(uint32_t index)
{
m_dirty[index / 32] |= 1 << (index % 32);
m_mindirty = std::min(m_mindirty, index);
@@ -121,7 +121,7 @@ void palette_client::dirty_state::mark_dirty(UINT32 index)
void palette_client::dirty_state::reset()
{
// erase relevant entries in the new live one
- memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(UINT32));
+ memset(&m_dirty[m_mindirty / 32], 0, ((m_maxdirty / 32) + 1 - (m_mindirty / 32)) * sizeof(uint32_t));
m_mindirty = m_dirty.size() * 32 - 1;
m_maxdirty = 0;
}
@@ -146,7 +146,7 @@ palette_client::palette_client(palette_t &palette)
palette.ref();
// resize the dirty lists
- UINT32 total_colors = palette.num_colors() * palette.num_groups();
+ uint32_t total_colors = palette.num_colors() * palette.num_groups();
m_dirty[0].resize(total_colors);
m_dirty[1].resize(total_colors);
@@ -180,10 +180,10 @@ palette_client::~palette_client()
// list for a client
//-------------------------------------------------
-const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
+const uint32_t *palette_client::dirty_list(uint32_t &mindirty, uint32_t &maxdirty)
{
// if nothing to report, report nothing and don't swap
- const UINT32 *result = m_live->dirty_list(mindirty, maxdirty);
+ const uint32_t *result = m_live->dirty_list(mindirty, maxdirty);
if (result == nullptr)
return nullptr;
@@ -207,7 +207,7 @@ const UINT32 *palette_client::dirty_list(UINT32 &mindirty, UINT32 &maxdirty)
// alloc - static allocator
//-------------------------------------------------
-palette_t *palette_t::alloc(UINT32 numcolors, UINT32 numgroups)
+palette_t *palette_t::alloc(uint32_t numcolors, uint32_t numgroups)
{
return new palette_t(numcolors, numgroups);
}
@@ -217,7 +217,7 @@ palette_t *palette_t::alloc(UINT32 numcolors, UINT32 numgroups)
// palette_t - constructor
//-------------------------------------------------
-palette_t::palette_t(UINT32 numcolors, UINT32 numgroups)
+palette_t::palette_t(uint32_t numcolors, uint32_t numgroups)
: m_refcount(1),
m_numcolors(numcolors),
m_numgroups(numgroups),
@@ -233,25 +233,25 @@ palette_t::palette_t(UINT32 numcolors, UINT32 numgroups)
m_client_list(nullptr)
{
// initialize gamma map
- for (UINT32 index = 0; index < 256; index++)
+ for (uint32_t index = 0; index < 256; index++)
m_gamma_map[index] = index;
// initialize the per-entry data
- for (UINT32 index = 0; index < numcolors; index++)
+ for (uint32_t index = 0; index < numcolors; index++)
{
m_entry_color[index] = rgb_t::black;
m_entry_contrast[index] = 1.0f;
}
// initialize the per-group data
- for (UINT32 index = 0; index < numgroups; index++)
+ for (uint32_t index = 0; index < numgroups; index++)
{
m_group_bright[index] = 0.0f;
m_group_contrast[index] = 1.0f;
}
// initialize the expanded data
- for (UINT32 index = 0; index < numcolors * numgroups; index++)
+ for (uint32_t index = 0; index < numcolors * numgroups; index++)
{
m_adjusted_color[index] = rgb_t::black;
m_adjusted_rgb15[index] = rgb_t::black.as_rgb15();
@@ -359,7 +359,7 @@ void palette_t::set_gamma(float gamma)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_color(UINT32 index, rgb_t rgb)
+void palette_t::entry_set_color(uint32_t index, rgb_t rgb)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index] == rgb)
@@ -379,7 +379,7 @@ void palette_t::entry_set_color(UINT32 index, rgb_t rgb)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_red_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_red_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].r() == level)
@@ -399,7 +399,7 @@ void palette_t::entry_set_red_level(UINT32 index, UINT8 level)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_green_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_green_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].g() == level)
@@ -419,7 +419,7 @@ void palette_t::entry_set_green_level(UINT32 index, UINT8 level)
// given palette index
//-------------------------------------------------
-void palette_t::entry_set_blue_level(UINT32 index, UINT8 level)
+void palette_t::entry_set_blue_level(uint32_t index, uint8_t level)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_color[index].b() == level)
@@ -439,7 +439,7 @@ void palette_t::entry_set_blue_level(UINT32 index, UINT8 level)
// adjustment for a single palette index
//-------------------------------------------------
-void palette_t::entry_set_contrast(UINT32 index, float contrast)
+void palette_t::entry_set_contrast(uint32_t index, float contrast)
{
// if out of range, or unchanged, ignore
if (index >= m_numcolors || m_entry_contrast[index] == contrast)
@@ -459,7 +459,7 @@ void palette_t::entry_set_contrast(UINT32 index, float contrast)
// brightness for a palette group
//-------------------------------------------------
-void palette_t::group_set_brightness(UINT32 group, float brightness)
+void palette_t::group_set_brightness(uint32_t group, float brightness)
{
// convert incoming value to normalized result
brightness = (brightness - 1.0f) * 256.0f;
@@ -482,7 +482,7 @@ void palette_t::group_set_brightness(UINT32 group, float brightness)
// contrast for a palette group
//-------------------------------------------------
-void palette_t::group_set_contrast(UINT32 group, float contrast)
+void palette_t::group_set_contrast(uint32_t group, float contrast)
{
// if out of range, or unchanged, ignore
if (group >= m_numgroups || m_group_contrast[group] == contrast)
@@ -502,43 +502,43 @@ void palette_t::group_set_contrast(UINT32 group, float contrast)
// entries
//-------------------------------------------------
-void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_max)
+void palette_t::normalize_range(uint32_t start, uint32_t end, int lum_min, int lum_max)
{
// clamp within range
start = std::max(start, 0U);
end = std::min(end, m_numcolors - 1);
// find the minimum and maximum brightness of all the colors in the range
- INT32 ymin = 1000 * 255, ymax = 0;
- for (UINT32 index = start; index <= end; index++)
+ int32_t ymin = 1000 * 255, ymax = 0;
+ for (uint32_t index = start; index <= end; index++)
{
rgb_t rgb = m_entry_color[index];
- UINT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- ymin = (std::min<UINT32>)(ymin, y);
- ymax = (std::max<UINT32>)(ymax, y);
+ uint32_t y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
+ ymin = (std::min<uint32_t>)(ymin, y);
+ ymax = (std::max<uint32_t>)(ymax, y);
}
// determine target minimum/maximum
- INT32 tmin = (lum_min < 0) ? ((ymin + 500) / 1000) : lum_min;
- INT32 tmax = (lum_max < 0) ? ((ymax + 500) / 1000) : lum_max;
+ int32_t tmin = (lum_min < 0) ? ((ymin + 500) / 1000) : lum_min;
+ int32_t tmax = (lum_max < 0) ? ((ymax + 500) / 1000) : lum_max;
// now normalize the palette
- for (UINT32 index = start; index <= end; index++)
+ for (uint32_t index = start; index <= end; index++)
{
rgb_t rgb = m_entry_color[index];
- INT32 y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
- INT32 u = ((INT32)rgb.b()-y /1000)*492 / 1000;
- INT32 v = ((INT32)rgb.r()-y / 1000)*877 / 1000;
- INT32 target = tmin + ((y - ymin) * (tmax - tmin + 1)) / (ymax - ymin);
- UINT8 r = rgb_t::clamp(target + 1140 * v / 1000);
- UINT8 g = rgb_t::clamp(target - 395 * u / 1000 - 581 * v / 1000);
- UINT8 b = rgb_t::clamp(target + 2032 * u / 1000);
+ int32_t y = 299 * rgb.r() + 587 * rgb.g() + 114 * rgb.b();
+ int32_t u = ((int32_t)rgb.b()-y /1000)*492 / 1000;
+ int32_t v = ((int32_t)rgb.r()-y / 1000)*877 / 1000;
+ int32_t target = tmin + ((y - ymin) * (tmax - tmin + 1)) / (ymax - ymin);
+ uint8_t r = rgb_t::clamp(target + 1140 * v / 1000);
+ uint8_t g = rgb_t::clamp(target - 395 * u / 1000 - 581 * v / 1000);
+ uint8_t b = rgb_t::clamp(target + 2032 * u / 1000);
entry_set_color(index, rgb_t(r, g, b));
}
}
/**
- * @fn void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
+ * @fn void palette_t::update_adjusted_color(uint32_t group, uint32_t index)
*
* @brief -------------------------------------------------
* update_adjusted_color - update a color index by group and index pair
@@ -548,7 +548,7 @@ void palette_t::normalize_range(UINT32 start, UINT32 end, int lum_min, int lum_m
* @param index Zero-based index of the.
*/
-void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
+void palette_t::update_adjusted_color(uint32_t group, uint32_t index)
{
// compute the adjusted value
rgb_t adjusted = adjust_palette_entry(m_entry_color[index],
@@ -557,7 +557,7 @@ void palette_t::update_adjusted_color(UINT32 group, UINT32 index)
m_gamma_map);
// if not different, ignore
- UINT32 finalindex = group * m_numcolors + index;
+ uint32_t finalindex = group * m_numcolors + index;
if (m_adjusted_color[finalindex] == adjusted)
return;