trunk/src/emu/video/huc6261.c
r17408 | r17409 | |
41 | 41 | huc6261_device::huc6261_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
42 | 42 | : device_t(mconfig, HUC6261, "HuC6261", tag, owner, clock) |
43 | 43 | { |
| 44 | // Set up UV lookup table |
| 45 | for ( int ur = 0; ur < 256; ur++ ) |
| 46 | { |
| 47 | for ( int vr = 0; vr < 256; vr++ ) |
| 48 | { |
| 49 | INT32 r,g,b; |
| 50 | INT32 u = ur - 128; |
| 51 | INT32 v = vr - 128; |
| 52 | |
| 53 | r = - 1.13983 * v; |
| 54 | g = -0.35465 * u - 0.58060 * v; |
| 55 | b = 2.03211 * u; |
| 56 | |
| 57 | m_uv_lookup[ ( ur << 8 ) | vr ][0] = r; |
| 58 | m_uv_lookup[ ( ur << 8 ) | vr ][1] = g; |
| 59 | m_uv_lookup[ ( ur << 8 ) | vr ][2] = b; |
| 60 | } |
| 61 | } |
44 | 62 | } |
45 | 63 | |
46 | 64 | |
| 65 | inline UINT32 huc6261_device::yuv2rgb(UINT32 yuv) |
| 66 | { |
| 67 | INT32 r, g, b; |
| 68 | UINT8 y = yuv >> 16; |
| 69 | UINT16 uv = yuv & 0xffff; |
| 70 | |
| 71 | r = y + m_uv_lookup[uv][0]; |
| 72 | g = y + m_uv_lookup[uv][1]; |
| 73 | b = y + m_uv_lookup[uv][2]; |
| 74 | |
| 75 | if ( r < 0 ) r = 0; |
| 76 | if ( g < 0 ) g = 0; |
| 77 | if ( b < 0 ) b = 0; |
| 78 | if ( r > 255 ) r = 255; |
| 79 | if ( g > 255 ) g = 255; |
| 80 | if ( b > 255 ) b = 255; |
| 81 | |
| 82 | return ( r << 16 ) | ( g << 8 ) | b; |
| 83 | } |
| 84 | |
47 | 85 | void huc6261_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
48 | 86 | { |
49 | 87 | int vpos = m_screen->vpos(); |
r17408 | r17409 | |
58 | 96 | { |
59 | 97 | g_profiler.start( PROFILER_VIDEO ); |
60 | 98 | /* Get next pixel information */ |
61 | | m_pixel_data = 0; //m_get_next_pixel_data( 0, 0xffff ); |
| 99 | m_pixel_data = m_huc6270_b->next_pixel( *machine().memory().first_space(), 0, 0xffff ); |
62 | 100 | g_profiler.stop(); |
63 | 101 | } |
64 | 102 | |
65 | | bitmap_line[ h ] = m_palette[ m_pixel_data ]; |
| 103 | bitmap_line[ h ] = yuv2rgb( ( ( m_palette[m_pixel_data] & 0xff00 ) << 8 ) | ( ( m_palette[m_pixel_data] & 0xf0 ) << 8 ) | ( ( m_palette[m_pixel_data] & 0x0f ) << 4 ) ); |
66 | 104 | m_pixel_clock = ( m_pixel_clock + 1 ) % m_pixels_per_clock; |
67 | 105 | h = ( h + 1 ) % HUC6261_WPF; |
68 | 106 | |