trunk/src/emu/video/tea1002.c
| r0 | r242605 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | TEA1002 |
| 4 | |
| 5 | license: MAME, GPL-2.0+ |
| 6 | copyright-holders: Dirk Best |
| 7 | |
| 8 | PAL colour encoder and video summer |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | #include "tea1002.h" |
| 13 | |
| 14 | |
| 15 | //************************************************************************** |
| 16 | // CONSTANTS |
| 17 | //************************************************************************** |
| 18 | |
| 19 | const float tea1002_device::m_luminance[] = |
| 20 | { |
| 21 | 0, 22.5, 44, 66.5, 8.5, 31, 52.5, 100, // INV = 0 |
| 22 | 75, 52.5, 31, 8.5, 66.5, 44, 22.5, 0 // INV = 1 |
| 23 | }; |
| 24 | |
| 25 | const int tea1002_device::m_phase[] = |
| 26 | { |
| 27 | 0, 103, 241, 167, 347, 61, 283, 0, // INV = 0 |
| 28 | 0, 283, 61, 347, 167, 241, 103, 0 // INV = 1 |
| 29 | }; |
| 30 | |
| 31 | const int tea1002_device::m_amplitute[] = |
| 32 | { |
| 33 | 0, 48, 44, 33, 33, 44, 48, 0, // INV = 0 |
| 34 | 0, 24, 22, 17, 17, 22, 24, 0 // INV = 1 |
| 35 | }; |
| 36 | |
| 37 | |
| 38 | //************************************************************************** |
| 39 | // DEVICE DEFINITIONS |
| 40 | //************************************************************************** |
| 41 | |
| 42 | const device_type TEA1002 = &device_creator<tea1002_device>; |
| 43 | |
| 44 | |
| 45 | //************************************************************************** |
| 46 | // LIVE DEVICE |
| 47 | //************************************************************************** |
| 48 | |
| 49 | //------------------------------------------------- |
| 50 | // paula_device - constructor |
| 51 | //------------------------------------------------- |
| 52 | |
| 53 | tea1002_device::tea1002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 54 | device_t(mconfig, TEA1002, "TEA1002 PAL colour encoder", tag, owner, clock, "tea1002", __FILE__) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | //------------------------------------------------- |
| 59 | // device_start - device-specific startup |
| 60 | //------------------------------------------------- |
| 61 | |
| 62 | void tea1002_device::device_start() |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | |
| 67 | //************************************************************************** |
| 68 | // IMPLEMENTATION |
| 69 | //************************************************************************** |
| 70 | |
| 71 | // this could be done in device_start() and cached, but it's only |
| 72 | // accessed once at PALETTE_INIT anyway |
| 73 | rgb_t tea1002_device::color(int index) |
| 74 | { |
| 75 | // calculate yuv |
| 76 | double y = m_luminance[index] / 100; |
| 77 | double u = cos((m_phase[index] + m_tint) * M_PI / 180) * m_amplitute[index] / 100; |
| 78 | double v = sin((m_phase[index] + m_tint) * M_PI / 180) * m_amplitute[index] / 100; |
| 79 | |
| 80 | // and convert to rgb |
| 81 | double r = y + v * 1.14; |
| 82 | double g = y - u * 0.395 - v * 0.581; |
| 83 | double b = y + u * 2.032; |
| 84 | |
| 85 | return rgb_t(rgb_t::clamp(r * 255), rgb_t::clamp(g * 255), rgb_t::clamp(b * 255)); |
| 86 | } |
trunk/src/emu/video/tea1002.h
| r0 | r242605 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | TEA1002 |
| 4 | |
| 5 | license: MAME, GPL-2.0+ |
| 6 | copyright-holders: Dirk Best |
| 7 | |
| 8 | PAL colour encoder and video summer |
| 9 | |
| 10 | _____ _____ |
| 11 | INV 1 |* \_/ | 18 CBLNK |
| 12 | R 2 | | 17 3,54 MHz |
| 13 | G 3 | | 16 GND |
| 14 | B 4 | | 15 CBF |
| 15 | _CSYNC 5 | TEA1002 | 14 8,86 MHz |
| 16 | lum. delay line 6 | | 13 8,86 MHz |
| 17 | lum. delay line 7 | | 12 PAL switch |
| 18 | comp. video to mod. 8 | | 11 chroma band limiting |
| 19 | d.c. adj. / colour bar 9 |_____________| 10 Vp |
| 20 | |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #ifndef __TEA1002_H__ |
| 26 | #define __TEA1002_H__ |
| 27 | |
| 28 | #include "emu.h" |
| 29 | |
| 30 | |
| 31 | //************************************************************************** |
| 32 | // INTERFACE CONFIGURATION MACROS |
| 33 | //************************************************************************** |
| 34 | |
| 35 | #define MCFG_TEA1002_ADD(_tag, _clock) \ |
| 36 | MCFG_DEVICE_ADD(_tag, TEA1002, _clock) |
| 37 | |
| 38 | |
| 39 | //************************************************************************** |
| 40 | // TYPE DEFINITIONS |
| 41 | //************************************************************************** |
| 42 | |
| 43 | // ======================> tea1002_device |
| 44 | |
| 45 | class tea1002_device : public device_t |
| 46 | { |
| 47 | public: |
| 48 | // construction/destruction |
| 49 | tea1002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 50 | |
| 51 | rgb_t color(int index); |
| 52 | |
| 53 | protected: |
| 54 | // device_t overrides |
| 55 | virtual void device_start(); |
| 56 | |
| 57 | private: |
| 58 | static const int m_tint = -6; // what is this based on? |
| 59 | static const float m_luminance[16]; |
| 60 | static const int m_phase[16]; |
| 61 | static const int m_amplitute[16]; |
| 62 | }; |
| 63 | |
| 64 | // device type definition |
| 65 | extern const device_type TEA1002; |
| 66 | |
| 67 | #endif // __TEA1002_H__ |
trunk/src/mess/includes/aquarius.h
| r242604 | r242605 | |
| 9 | 9 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "cpu/z80/z80.h" |
| 12 | #include "video/tea1002.h" |
| 12 | 13 | #include "imagedev/cassette.h" |
| 13 | 14 | #include "machine/ram.h" |
| 14 | 15 | #include "sound/ay8910.h" |
| r242604 | r242605 | |
| 38 | 39 | m_y7(*this, "Y7"), |
| 39 | 40 | m_gfxdecode(*this, "gfxdecode"), |
| 40 | 41 | m_screen(*this, "screen"), |
| 42 | m_tea1002(*this, "encoder"), |
| 41 | 43 | m_palette(*this, "palette") |
| 42 | 44 | { } |
| 43 | 45 | |
| r242604 | r242605 | |
| 58 | 60 | required_ioport m_y7; |
| 59 | 61 | required_device<gfxdecode_device> m_gfxdecode; |
| 60 | 62 | required_device<screen_device> m_screen; |
| 63 | required_device<tea1002_device> m_tea1002; |
| 61 | 64 | required_device<palette_device> m_palette; |
| 62 | 65 | |
| 63 | 66 | UINT8 m_scrambler; |
trunk/src/mess/video/aquarius.c
| r242604 | r242605 | |
| 10 | 10 | #include "includes/aquarius.h" |
| 11 | 11 | |
| 12 | 12 | |
| 13 | | |
| 14 | | static const rgb_t aquarius_colors[] = |
| 15 | | { |
| 16 | | rgb_t::black, /* Black */ |
| 17 | | rgb_t(0xff, 0x00, 0x00), /* Red */ |
| 18 | | rgb_t(0x00, 0xff, 0x00), /* Green */ |
| 19 | | rgb_t(0xff, 0xff, 0x00), /* Yellow */ |
| 20 | | rgb_t(0x00, 0x00, 0xff), /* Blue */ |
| 21 | | rgb_t(0x7f, 0x00, 0x7f), /* Violet */ |
| 22 | | rgb_t(0x7f, 0xff, 0xff), /* Light Blue-Green */ |
| 23 | | rgb_t::white, /* White */ |
| 24 | | rgb_t(0xc0, 0xc0, 0xc0), /* Light Gray */ |
| 25 | | rgb_t(0x00, 0xff, 0xff), /* Blue-Green */ |
| 26 | | rgb_t(0xff, 0x00, 0xff), /* Magenta */ |
| 27 | | rgb_t(0x00, 0x00, 0x7f), /* Dark Blue */ |
| 28 | | rgb_t(0xff, 0xff, 0x7f), /* Light Yellow */ |
| 29 | | rgb_t(0x7f, 0xff, 0x7f), /* Light Green */ |
| 30 | | rgb_t(0xff, 0x7f, 0x00), /* Orange */ |
| 31 | | rgb_t(0x7f, 0x7f, 0x7f) /* Dark Gray */ |
| 32 | | }; |
| 33 | | |
| 34 | 13 | static const unsigned short aquarius_palette[] = |
| 35 | 14 | { |
| 36 | 15 | 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, |
| r242604 | r242605 | |
| 56 | 35 | int i; |
| 57 | 36 | |
| 58 | 37 | for (i = 0; i < 16; i++) |
| 59 | | m_palette->set_indirect_color(i, aquarius_colors[i]); |
| 38 | m_palette->set_indirect_color(i, m_tea1002->color(i)); |
| 60 | 39 | |
| 61 | 40 | for (i = 0; i < 512; i++) |
| 62 | 41 | m_palette->set_pen_indirect(i, aquarius_palette[i]); |