summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2018-05-13 17:46:27 -0400
committer AJR <ajrhacker@users.noreply.github.com>2018-05-13 17:46:27 -0400
commit7db49620b254036a7e78766c9eaf48ce1a0a8b34 (patch)
tree6537c349f9e4a11b47733921e6e347418e1ce86f /src/devices/video
parent00f85467d98b1ea289a5360e676dd11130ec4230 (diff)
tlc34076: Convert implementation to use device_palette_interface (nw)
Diffstat (limited to 'src/devices/video')
-rw-r--r--src/devices/video/tlc34076.cpp54
-rw-r--r--src/devices/video/tlc34076.h9
2 files changed, 36 insertions, 27 deletions
diff --git a/src/devices/video/tlc34076.cpp b/src/devices/video/tlc34076.cpp
index 9d25c044eeb..d484ef333c7 100644
--- a/src/devices/video/tlc34076.cpp
+++ b/src/devices/video/tlc34076.cpp
@@ -43,6 +43,7 @@ DEFINE_DEVICE_TYPE(TLC34076, tlc34076_device, "tlc34076", "TI TLC34076 VIP")
//-------------------------------------------------
tlc34076_device::tlc34076_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, TLC34076, tag, owner, clock)
+ , device_palette_interface(mconfig, *this)
, m_dacbits(6)
{
}
@@ -82,6 +83,9 @@ void tlc34076_device::device_reset()
m_regs[PALETTE_PAGE] = 0x00;
m_regs[TEST_REGISTER] = 0x00;
m_regs[RESET_STATE] = 0x00;
+
+ for (int i = 0; i < 0x100; i++)
+ update_pen(i);
}
@@ -90,41 +94,34 @@ void tlc34076_device::device_reset()
//**************************************************************************
//-------------------------------------------------
-// get_pens - retrieve current palette
+// update_pen - update color in current palette
//-------------------------------------------------
-const rgb_t *tlc34076_device::get_pens()
+void tlc34076_device::update_pen(uint8_t i)
{
- offs_t i;
+ int r, g, b;
- for (i = 0; i < 0x100; i++)
+ if ((i & m_regs[PIXEL_READ_MASK]) == i)
{
- int r, g, b;
-
- if ((i & m_regs[PIXEL_READ_MASK]) == i)
- {
- r = m_local_paletteram[0][i];
- g = m_local_paletteram[1][i];
- b = m_local_paletteram[2][i];
+ r = m_local_paletteram[0][i];
+ g = m_local_paletteram[1][i];
+ b = m_local_paletteram[2][i];
- if (m_dacbits == 6)
- {
- r = pal6bit(r);
- g = pal6bit(g);
- b = pal6bit(b);
- }
- }
- else
+ if (m_dacbits == 6)
{
- r = 0;
- g = 0;
- b = 0;
+ r = pal6bit(r);
+ g = pal6bit(g);
+ b = pal6bit(b);
}
-
- m_pens[i] = rgb_t(r, g, b);
+ }
+ else
+ {
+ r = 0;
+ g = 0;
+ b = 0;
}
- return m_pens.get();
+ set_pen_color(i, rgb_t(r, g, b));
}
@@ -189,11 +186,18 @@ WRITE8_MEMBER( tlc34076_device::write )
for (int i = 0; i < 3; i++)
m_local_paletteram[i][m_regs[PALETTE_WRITE_ADDR]] = m_palettedata[i];
+ update_pen(m_regs[PALETTE_WRITE_ADDR]);
+
m_writeindex = 0;
m_regs[PALETTE_WRITE_ADDR]++;
}
break;
+ case PIXEL_READ_MASK:
+ for (int i = 0; i < 0x100; i++)
+ update_pen(i);
+ break;
+
case PALETTE_READ_ADDR:
m_readindex = 0;
break;
diff --git a/src/devices/video/tlc34076.h b/src/devices/video/tlc34076.h
index ae17c54b3e0..9a7c956aa80 100644
--- a/src/devices/video/tlc34076.h
+++ b/src/devices/video/tlc34076.h
@@ -19,7 +19,7 @@
TYPE DEFINITIONS
***************************************************************************/
-class tlc34076_device : public device_t
+class tlc34076_device : public device_t, public device_palette_interface
{
public:
enum tlc34076_bits
@@ -35,7 +35,6 @@ public:
void set_bits(tlc34076_bits bits) { m_dacbits = bits; }
// public interface
- const rgb_t *get_pens();
DECLARE_READ8_MEMBER(read);
DECLARE_WRITE8_MEMBER(write);
@@ -44,7 +43,13 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
+ // device_palette_interface overrides
+ virtual uint32_t palette_entries() const override { return 0x100; }
+
private:
+ // internal helpers
+ void update_pen(uint8_t i);
+
// internal state
std::unique_ptr<uint8_t[]> m_local_paletteram[3];
uint8_t m_regs[0x10];