diff options
author | Dirk Best <mail@dirk-best.de> | 2014-12-28 17:26:05 +0100 |
---|---|---|
committer | Dirk Best <mail@dirk-best.de> | 2014-12-28 17:26:25 +0100 |
commit | 4e9265719006f635c16a6197f903717a9b9c0f7e (patch) | |
tree | ad94ee3b008e8f7a08315781b1bea78b689853c2 | |
parent | 00e13528546bb1dc6918ef784743f90c6213fb40 (diff) |
Add a TEA1002 color encoder device and use it for the Aquarius. It might
make sense to make this a direct descendent of the palette_device
instead.
Color information based on TEA1002 datasheet. [Dirk Best, nitrofurano,
Bruce Abbott]
-rw-r--r-- | src/emu/video/tea1002.c | 86 | ||||
-rw-r--r-- | src/emu/video/tea1002.h | 67 | ||||
-rw-r--r-- | src/emu/video/video.mak | 9 | ||||
-rw-r--r-- | src/mess/drivers/aquarius.c | 1 | ||||
-rw-r--r-- | src/mess/includes/aquarius.h | 3 | ||||
-rw-r--r-- | src/mess/mess.mak | 1 | ||||
-rw-r--r-- | src/mess/video/aquarius.c | 23 |
7 files changed, 168 insertions, 22 deletions
diff --git a/src/emu/video/tea1002.c b/src/emu/video/tea1002.c new file mode 100644 index 00000000000..f9d014ae113 --- /dev/null +++ b/src/emu/video/tea1002.c @@ -0,0 +1,86 @@ +/*************************************************************************** + + TEA1002 + + license: MAME, GPL-2.0+ + copyright-holders: Dirk Best + + PAL colour encoder and video summer + +***************************************************************************/ + +#include "tea1002.h" + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +const float tea1002_device::m_luminance[] = +{ + 0, 22.5, 44, 66.5, 8.5, 31, 52.5, 100, // INV = 0 + 75, 52.5, 31, 8.5, 66.5, 44, 22.5, 0 // INV = 1 +}; + +const int tea1002_device::m_phase[] = +{ + 0, 103, 241, 167, 347, 61, 283, 0, // INV = 0 + 0, 283, 61, 347, 167, 241, 103, 0 // INV = 1 +}; + +const int tea1002_device::m_amplitute[] = +{ + 0, 48, 44, 33, 33, 44, 48, 0, // INV = 0 + 0, 24, 22, 17, 17, 22, 24, 0 // INV = 1 +}; + + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type TEA1002 = &device_creator<tea1002_device>; + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// paula_device - constructor +//------------------------------------------------- + +tea1002_device::tea1002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, TEA1002, "TEA1002 PAL colour encoder", tag, owner, clock, "tea1002", __FILE__) +{ +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void tea1002_device::device_start() +{ +} + + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +// this could be done in device_start() and cached, but it's only +// accessed once at PALETTE_INIT anyway +rgb_t tea1002_device::color(int index) +{ + // calculate yuv + double y = m_luminance[index] / 100; + double u = cos((m_phase[index] + m_tint) * M_PI / 180) * m_amplitute[index] / 100; + double v = sin((m_phase[index] + m_tint) * M_PI / 180) * m_amplitute[index] / 100; + + // and convert to rgb + double r = y + v * 1.14; + double g = y - u * 0.395 - v * 0.581; + double b = y + u * 2.032; + + return rgb_t(rgb_t::clamp(r * 255), rgb_t::clamp(g * 255), rgb_t::clamp(b * 255)); +} diff --git a/src/emu/video/tea1002.h b/src/emu/video/tea1002.h new file mode 100644 index 00000000000..d4e20c56e6d --- /dev/null +++ b/src/emu/video/tea1002.h @@ -0,0 +1,67 @@ +/*************************************************************************** + + TEA1002 + + license: MAME, GPL-2.0+ + copyright-holders: Dirk Best + + PAL colour encoder and video summer + + _____ _____ + INV 1 |* \_/ | 18 CBLNK + R 2 | | 17 3,54 MHz + G 3 | | 16 GND + B 4 | | 15 CBF + _CSYNC 5 | TEA1002 | 14 8,86 MHz + lum. delay line 6 | | 13 8,86 MHz + lum. delay line 7 | | 12 PAL switch + comp. video to mod. 8 | | 11 chroma band limiting + d.c. adj. / colour bar 9 |_____________| 10 Vp + +***************************************************************************/ + +#pragma once + +#ifndef __TEA1002_H__ +#define __TEA1002_H__ + +#include "emu.h" + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_TEA1002_ADD(_tag, _clock) \ + MCFG_DEVICE_ADD(_tag, TEA1002, _clock) + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> tea1002_device + +class tea1002_device : public device_t +{ +public: + // construction/destruction + tea1002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + rgb_t color(int index); + +protected: + // device_t overrides + virtual void device_start(); + +private: + static const int m_tint = -6; // what is this based on? + static const float m_luminance[16]; + static const int m_phase[16]; + static const int m_amplitute[16]; +}; + +// device type definition +extern const device_type TEA1002; + +#endif // __TEA1002_H__ diff --git a/src/emu/video/video.mak b/src/emu/video/video.mak index 72ce5eb341f..ff88683af5d 100644 --- a/src/emu/video/video.mak +++ b/src/emu/video/video.mak @@ -483,6 +483,15 @@ endif #------------------------------------------------- # +#@src/emu/video/tea1002.h,VIDEOS += TEA1002 +#------------------------------------------------- + +ifneq ($(filter TEA1002,$(VIDEOS)),) +VIDEOOBJS += $(VIDEOOBJ)/tea1002.o +endif + +#------------------------------------------------- +# #@src/emu/video/tlc34076.h,VIDEOS += TLC34076 #------------------------------------------------- diff --git a/src/mess/drivers/aquarius.c b/src/mess/drivers/aquarius.c index 87632a46d15..24966318e45 100644 --- a/src/mess/drivers/aquarius.c +++ b/src/mess/drivers/aquarius.c @@ -357,6 +357,7 @@ static MACHINE_CONFIG_START( aquarius, aquarius_state ) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", aquarius ) + MCFG_TEA1002_ADD("encoder", XTAL_8_867238MHz) MCFG_PALETTE_ADD("palette", 512) MCFG_PALETTE_INDIRECT_ENTRIES(16) MCFG_PALETTE_INIT_OWNER(aquarius_state, aquarius) diff --git a/src/mess/includes/aquarius.h b/src/mess/includes/aquarius.h index bc052d1f6a5..4716a3ea370 100644 --- a/src/mess/includes/aquarius.h +++ b/src/mess/includes/aquarius.h @@ -9,6 +9,7 @@ #include "emu.h" #include "cpu/z80/z80.h" +#include "video/tea1002.h" #include "imagedev/cassette.h" #include "machine/ram.h" #include "sound/ay8910.h" @@ -38,6 +39,7 @@ public: m_y7(*this, "Y7"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), + m_tea1002(*this, "encoder"), m_palette(*this, "palette") { } @@ -58,6 +60,7 @@ public: required_ioport m_y7; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; + required_device<tea1002_device> m_tea1002; required_device<palette_device> m_palette; UINT8 m_scrambler; diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 9c283ba4bfe..a2b8e696682 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -313,6 +313,7 @@ VIDEOS += SED1520 VIDEOS += SNES_PPU VIDEOS += STVVDP VIDEOS += T6A04 +VIDEOS += TEA1002 #VIDEOS += TLC34076 #VIDEOS += TMS34061 VIDEOS += TMS3556 diff --git a/src/mess/video/aquarius.c b/src/mess/video/aquarius.c index 7799a778bc8..f61f1ba0f5c 100644 --- a/src/mess/video/aquarius.c +++ b/src/mess/video/aquarius.c @@ -10,27 +10,6 @@ #include "includes/aquarius.h" - -static const rgb_t aquarius_colors[] = -{ - rgb_t::black, /* Black */ - rgb_t(0xff, 0x00, 0x00), /* Red */ - rgb_t(0x00, 0xff, 0x00), /* Green */ - rgb_t(0xff, 0xff, 0x00), /* Yellow */ - rgb_t(0x00, 0x00, 0xff), /* Blue */ - rgb_t(0x7f, 0x00, 0x7f), /* Violet */ - rgb_t(0x7f, 0xff, 0xff), /* Light Blue-Green */ - rgb_t::white, /* White */ - rgb_t(0xc0, 0xc0, 0xc0), /* Light Gray */ - rgb_t(0x00, 0xff, 0xff), /* Blue-Green */ - rgb_t(0xff, 0x00, 0xff), /* Magenta */ - rgb_t(0x00, 0x00, 0x7f), /* Dark Blue */ - rgb_t(0xff, 0xff, 0x7f), /* Light Yellow */ - rgb_t(0x7f, 0xff, 0x7f), /* Light Green */ - rgb_t(0xff, 0x7f, 0x00), /* Orange */ - rgb_t(0x7f, 0x7f, 0x7f) /* Dark Gray */ -}; - static const unsigned short aquarius_palette[] = { 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,10, 0,11, 0,12, 0,13, 0,14, 0,15, 0, @@ -56,7 +35,7 @@ PALETTE_INIT_MEMBER(aquarius_state, aquarius) int i; for (i = 0; i < 16; i++) - m_palette->set_indirect_color(i, aquarius_colors[i]); + m_palette->set_indirect_color(i, m_tea1002->color(i)); for (i = 0; i < 512; i++) m_palette->set_pen_indirect(i, aquarius_palette[i]); |