trunk/src/emu/sound/cdp1864.c
| r24860 | r24861 | |
| 22 | 22 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | | |
| 26 | | #include "emu.h" |
| 27 | 25 | #include "cdp1864.h" |
| 28 | 26 | |
| 29 | 27 | |
| r24860 | r24861 | |
| 38 | 36 | #define CDP1864_CYCLES_DMA_ACTIVE 8*8 |
| 39 | 37 | #define CDP1864_CYCLES_DMA_WAIT 6*8 |
| 40 | 38 | |
| 41 | | static const int CDP1864_BACKGROUND_COLOR_SEQUENCE[] = { 2, 0, 1, 4 }; |
| 39 | const int cdp1864_device::bckgnd[] = { 2, 0, 4, 1 }; |
| 42 | 40 | |
| 43 | 41 | |
| 44 | 42 | |
| 45 | 43 | //************************************************************************** |
| 46 | | // GLOBAL VARIABLES |
| 44 | // DEVICE DEFINITIONS |
| 47 | 45 | //************************************************************************** |
| 48 | 46 | |
| 49 | 47 | // devices |
| r24860 | r24861 | |
| 52 | 50 | |
| 53 | 51 | |
| 54 | 52 | //************************************************************************** |
| 55 | | // INLINE HELPERS |
| 56 | | //************************************************************************** |
| 57 | | |
| 58 | | //------------------------------------------------- |
| 59 | | // initialize_palette - |
| 60 | | //------------------------------------------------- |
| 61 | | |
| 62 | | inline void cdp1864_device::initialize_palette() |
| 63 | | { |
| 64 | | const int resistances_r[] = { m_chr_r }; |
| 65 | | const int resistances_g[] = { m_chr_g }; |
| 66 | | const int resistances_b[] = { m_chr_b }; |
| 67 | | |
| 68 | | double color_weights_r[1], color_weights_g[1], color_weights_b[1]; |
| 69 | | double color_weights_bkg_r[1], color_weights_bkg_g[1], color_weights_bkg_b[1]; |
| 70 | | |
| 71 | | compute_resistor_weights(0, 0xff, -1.0, |
| 72 | | 1, resistances_r, color_weights_r, 0, m_chr_bkg, |
| 73 | | 1, resistances_g, color_weights_g, 0, m_chr_bkg, |
| 74 | | 1, resistances_b, color_weights_b, 0, m_chr_bkg); |
| 75 | | |
| 76 | | compute_resistor_weights(0, 0xff, -1.0, |
| 77 | | 1, resistances_r, color_weights_bkg_r, m_chr_bkg, 0, |
| 78 | | 1, resistances_g, color_weights_bkg_g, m_chr_bkg, 0, |
| 79 | | 1, resistances_b, color_weights_bkg_b, m_chr_bkg, 0); |
| 80 | | |
| 81 | | for (int i = 0; i < 8; i++) |
| 82 | | { |
| 83 | | UINT8 r = combine_1_weights(color_weights_r, BIT(i, 0)); |
| 84 | | UINT8 b = combine_1_weights(color_weights_b, BIT(i, 1)); |
| 85 | | UINT8 g = combine_1_weights(color_weights_g, BIT(i, 2)); |
| 86 | | |
| 87 | | m_palette[i] = MAKE_RGB(r, g, b); |
| 88 | | |
| 89 | | r = combine_1_weights(color_weights_bkg_r, BIT(i, 0)); |
| 90 | | b = combine_1_weights(color_weights_bkg_b, BIT(i, 1)); |
| 91 | | g = combine_1_weights(color_weights_bkg_g, BIT(i, 2)); |
| 92 | | |
| 93 | | m_palette[i + 8] = MAKE_RGB(r, g, b); |
| 94 | | } |
| 95 | | } |
| 96 | | |
| 97 | | |
| 98 | | |
| 99 | | //************************************************************************** |
| 100 | 53 | // LIVE DEVICE |
| 101 | 54 | //************************************************************************** |
| 102 | 55 | |
| r24860 | r24861 | |
| 398 | 351 | |
| 399 | 352 | for (int x = 0; x < 8; x++) |
| 400 | 353 | { |
| 401 | | int color = CDP1864_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8; |
| 354 | int color = bckgnd[m_bgcolor] + 8; |
| 402 | 355 | |
| 403 | 356 | if (BIT(data, 7)) |
| 404 | 357 | { |
| r24860 | r24861 | |
| 458 | 411 | if (m_disp) |
| 459 | 412 | { |
| 460 | 413 | copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); |
| 461 | | m_bitmap.fill(m_palette[CDP1864_BACKGROUND_COLOR_SEQUENCE[m_bgcolor] + 8], cliprect); |
| 414 | m_bitmap.fill(m_palette[bckgnd[m_bgcolor] + 8], cliprect); |
| 462 | 415 | } |
| 463 | 416 | else |
| 464 | 417 | { |
| 465 | | bitmap.fill(m_palette[0], cliprect); |
| 418 | bitmap.fill(RGB_BLACK, cliprect); |
| 466 | 419 | } |
| 467 | 420 | |
| 468 | 421 | return 0; |
| 469 | 422 | } |
| 423 | |
| 424 | |
| 425 | //------------------------------------------------- |
| 426 | // initialize_palette - |
| 427 | //------------------------------------------------- |
| 428 | |
| 429 | void cdp1864_device::initialize_palette() |
| 430 | { |
| 431 | const int resistances_r[] = { m_chr_r }; |
| 432 | const int resistances_g[] = { m_chr_g }; |
| 433 | const int resistances_b[] = { m_chr_b }; |
| 434 | |
| 435 | double color_weights_r[1], color_weights_g[1], color_weights_b[1]; |
| 436 | double color_weights_bkg_r[1], color_weights_bkg_g[1], color_weights_bkg_b[1]; |
| 437 | |
| 438 | compute_resistor_weights(0, 0xff, -1.0, |
| 439 | 1, resistances_r, color_weights_r, 0, m_chr_bkg, |
| 440 | 1, resistances_g, color_weights_g, 0, m_chr_bkg, |
| 441 | 1, resistances_b, color_weights_b, 0, m_chr_bkg); |
| 442 | |
| 443 | compute_resistor_weights(0, 0xff, -1.0, |
| 444 | 1, resistances_r, color_weights_bkg_r, m_chr_bkg, 0, |
| 445 | 1, resistances_g, color_weights_bkg_g, m_chr_bkg, 0, |
| 446 | 1, resistances_b, color_weights_bkg_b, m_chr_bkg, 0); |
| 447 | |
| 448 | for (int i = 0; i < 8; i++) |
| 449 | { |
| 450 | // foreground colors |
| 451 | UINT8 r = 0, g = 0, b = 0; |
| 452 | |
| 453 | if (m_chr_r != RES_INF) r = combine_1_weights(color_weights_r, BIT(i, 0)); |
| 454 | if (m_chr_b != RES_INF) b = combine_1_weights(color_weights_b, BIT(i, 1)); |
| 455 | if (m_chr_g != RES_INF) g = combine_1_weights(color_weights_g, BIT(i, 2)); |
| 456 | |
| 457 | m_palette[i] = MAKE_RGB(r, g, b); |
| 458 | |
| 459 | // background colors |
| 460 | r = 0, g = 0, b = 0; |
| 461 | |
| 462 | if (m_chr_r != RES_INF) r = combine_1_weights(color_weights_bkg_r, BIT(i, 0)); |
| 463 | if (m_chr_b != RES_INF) b = combine_1_weights(color_weights_bkg_b, BIT(i, 1)); |
| 464 | if (m_chr_g != RES_INF) g = combine_1_weights(color_weights_bkg_g, BIT(i, 2)); |
| 465 | |
| 466 | m_palette[i + 8] = MAKE_RGB(r, g, b); |
| 467 | } |
| 468 | } |