summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2022-02-25 19:29:20 +0100
committer hap <happppp@users.noreply.github.com>2022-02-25 19:29:32 +0100
commitd196d072ff54277a7c3ad0c5048f8fdc6b7e18c8 (patch)
tree57a626d3764d1e650dff09f6783ab46f5d80b7e3
parent45b02a490f066feb186df56b83c5c19c5499bff5 (diff)
rendlay: add optional alpha attribute to digit elements
-rw-r--r--docs/source/techspecs/layout_files.rst44
-rw-r--r--src/emu/rendlay.cpp52
-rw-r--r--src/emu/rendlay.h1
3 files changed, 60 insertions, 37 deletions
diff --git a/docs/source/techspecs/layout_files.rst b/docs/source/techspecs/layout_files.rst
index c43a7df8e1b..de2ba2f8a8e 100644
--- a/docs/source/techspecs/layout_files.rst
+++ b/docs/source/techspecs/layout_files.rst
@@ -517,36 +517,24 @@ text
be an integer, where 0 (zero) means centred, 1 (one) means left-aligned, and
2 (two) means right-aligned. If the ``align`` attribute is absent, the text
will be centred.
-dotmatrix
- Draws an eight-pixel horizontal segment of a dot matrix display, using
- circular pixels in the specified colour. The bits of the element’s state
- determine which pixels are lit, with the least significant bit corresponding
- to the leftmost pixel. Unlit pixels are drawn at low intensity (0x20/0xff).
-dotmatrix5dot
- Draws a five-pixel horizontal segment of a dot matrix display, using
- circular pixels in the specified colour. The bits of the element’s state
- determine which pixels are lit, with the least significant bit corresponding
- to the leftmost pixel. Unlit pixels are drawn at low intensity (0x20/0xff).
-dotmatrixdot
- Draws a single element of a dot matrix display as a circular pixels in the
- specified colour. The least significant bit of the element’s state
- determines whether the pixel is lit. An unlit pixel is drawn at low
- intensity (0x20/0xff).
led7seg
Draws a standard seven-segment (plus decimal point) digital LED/fluorescent
display in the specified colour. The low eight bits of the element’s state
control which segments are lit. Starting from the least significant bit,
the bits correspond to the top segment, the upper right-hand segment,
continuing clockwise to the upper left segment, the middle bar, and the
- decimal point. Unlit segments are drawn at low intensity (0x20/0xff).
+ decimal point. An optional ``alpha`` attribute determines the opacity for
+ unlit segments. It ranges from 0.0 to 1.0 as with ``color``, and when
+ omitted, it defaults to 0.125.
led8seg_gts1
Draws an eight-segment digital fluorescent display of the type used in
Gottlieb System 1 pinball machines (actually a Futaba part). Compared to
standard seven-segment displays, these displays have no decimal point, the
horizontal middle bar is broken in the centre, and there is a broken
vertical middle bar controlled by the bit that would control the decimal
- point in a standard seven-segment display. Unlit segments are drawn at low
- intensity (0x20/0xff).
+ point in a standard seven-segment display. An optional ``alpha`` attribute
+ determines the opacity for unlit segments. It ranges from 0.0 to 1.0 as
+ with ``color``, and when omitted, it defaults to 0.125.
led14seg
Draws a standard fourteen-segment alphanumeric LED/fluorescent display in
the specified colour. The low fourteen bits of the element’s state control
@@ -554,15 +542,18 @@ led14seg
correspond to the top segment, the upper right-hand segment, continuing
clockwise to the upper left segment, the left-hand and right-hand halves of
the horizontal middle bar, the upper and lower halves of the vertical middle
- bar, and the diagonal bars clockwise from lower left to lower right. Unlit
- segments are drawn at low intensity (0x20/0xff).
+ bar, and the diagonal bars clockwise from lower left to lower right. An
+ optional ``alpha`` attribute determines the opacity for unlit segments. It
+ ranges from 0.0 to 1.0 as with ``color``, and when omitted, it defaults to
+ 0.125.
led14segsc
Draws a standard fourteen-segment alphanumeric LED/fluorescent display with
decimal point/comma in the specified colour. The low sixteen bits of the
element’s state control which segments are lit. The low fourteen bits
correspond to the same segments as in the ``led14seg`` component. Two
- additional bits correspond to the decimal point and comma tail. Unlit
- segments are drawn at low intensity (0x20/0xff).
+ additional bits correspond to the decimal point and comma tail. An optional
+ ``alpha`` attribute determines the opacity for unlit segments. It ranges
+ from 0.0 to 1.0 as with ``color``, and when omitted, it defaults to 0.125.
led16seg
Draws a standard sixteen-segment alphanumeric LED/fluorescent display in the
specified colour. The low sixteen bits of the element’s state control which
@@ -571,14 +562,17 @@ led16seg
top bar, continuing clockwise to the upper left segment, the left-hand and
right-hand halves of the horizontal middle bar, the upper and lower halves
of the vertical middle bar, and the diagonal bars clockwise from lower left
- to lower right. Unlit segments are drawn at low intensity (0x20/0xff).
+ to lower right. An optional ``alpha`` attribute determines the opacity for
+ unlit segments. It ranges from 0.0 to 1.0 as with ``color``, and when
+ omitted, it defaults to 0.125.
led16segsc
Draws a standard sixteen-segment alphanumeric LED/fluorescent display with
decimal point/comma in the specified colour. The low eighteen bits of the
element’s state control which segments are lit. The low sixteen bits
correspond to the same segments as in the ``led16seg`` component. Two
- additional bits correspond to the decimal point and comma tail. Unlit
- segments are drawn at low intensity (0x20/0xff).
+ additional bits correspond to the decimal point and comma tail. An optional
+ ``alpha`` attribute determines the opacity for unlit segments. It ranges
+ from 0.0 to 1.0 as with ``color``, and when omitted, it defaults to 0.125.
simplecounter
Displays the numeric value of the element’s state using the system font in
the specified colour. The value is formatted in decimal notation. A
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 88cc161e22f..b312637c0a9 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -2465,6 +2465,7 @@ public:
// construction/destruction
led7seg_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2475,7 +2476,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- rgb_t const offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
// sizes for computation
int const bmwidth = 250;
@@ -2517,6 +2518,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
@@ -2527,6 +2532,7 @@ public:
// construction/destruction
led8seg_gts1_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2537,7 +2543,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- rgb_t const offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
rgb_t const backpen = rgb_t(0x00, 0x00, 0x00, 0x00);
// sizes for computation
@@ -2585,6 +2591,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
@@ -2595,6 +2605,7 @@ public:
// construction/destruction
led14seg_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2605,7 +2616,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- rgb_t const offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
// sizes for computation
int const bmwidth = 250;
@@ -2697,6 +2708,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
@@ -2707,6 +2722,7 @@ public:
// construction/destruction
led16seg_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2716,14 +2732,14 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
- const rgb_t onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- const rgb_t offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
// sizes for computation
- int bmwidth = 250;
- int bmheight = 400;
- int segwidth = 40;
- int skewwidth = 40;
+ int const bmwidth = 250;
+ int const bmheight = 400;
+ int const segwidth = 40;
+ int const skewwidth = 40;
// allocate a temporary bitmap for drawing
bitmap_argb32 tempbitmap(bmwidth + skewwidth, bmheight);
@@ -2819,6 +2835,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
@@ -2829,6 +2849,7 @@ public:
// construction/destruction
led14segsc_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2839,7 +2860,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- rgb_t const offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
// sizes for computation
int const bmwidth = 250;
@@ -2942,6 +2963,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
@@ -2952,6 +2977,7 @@ public:
// construction/destruction
led16segsc_component(environment &env, util::xml::data_node const &compnode)
: component(env, compnode)
+ , m_alpha(std::clamp(env.get_attribute_float(compnode, "alpha", 0.125F), 0.0F, 1.0F))
{
}
@@ -2962,7 +2988,7 @@ protected:
virtual void draw_aligned(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
{
rgb_t const onpen = rgb_t(0xff, 0xff, 0xff, 0xff);
- rgb_t const offpen = rgb_t(0x20, 0xff, 0xff, 0xff);
+ rgb_t const offpen = rgb_t(m_alpha * 0xff, 0xff, 0xff, 0xff);
// sizes for computation
int const bmwidth = 250;
@@ -3074,6 +3100,10 @@ protected:
// resample to the target size
render_resample_argb_bitmap_hq(dest, tempbitmap, color(state));
}
+
+private:
+ // internal state
+ float m_alpha; // opacity for off-segments
};
diff --git a/src/emu/rendlay.h b/src/emu/rendlay.h
index c58823e18ce..d0e8bb2e582 100644
--- a/src/emu/rendlay.h
+++ b/src/emu/rendlay.h
@@ -183,7 +183,6 @@ private:
// internal helpers
static void element_scale(bitmap_argb32 &dest, bitmap_argb32 &source, const rectangle &sbounds, void *param);
template <typename T> static component::ptr make_component(environment &env, util::xml::data_node const &compnode);
- template <int D> static component::ptr make_dotmatrix_component(environment &env, util::xml::data_node const &compnode);
static make_component_map const s_make_component; // maps component XML names to creator functions