diff options
author | David Haywood <28625134+DavidHaywood@users.noreply.github.com> | 2020-03-11 14:42:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-11 10:42:00 -0400 |
commit | 4db634dfd908786cad140fa97a49c11a627a9019 (patch) | |
tree | 96522b0e7c5c474b0d1cf84aad1adf3b30c90ced /src/devices | |
parent | a00cd931207746bf37d0903100a12f05d54cc050 (diff) |
Plug & Play work (#6426)
* new NOT WORKING
----
Spider-Man Web Master (JAKKS Pacific TV Motion Game) [Sean Riddle, David Haywood]
* new WORKING machine
----
Who Wants To Be A Millionaire (UK, Character Options) [Sean Riddle, David Haywood]
* sh6578.work (nw)
* (nw)
* sh6578 work (nw)
* main screen turn on (nw)
* allow workram writes via DMA (nw)
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/video/ppu2c0x.cpp | 125 | ||||
-rw-r--r-- | src/devices/video/ppu2c0x.h | 1 |
2 files changed, 67 insertions, 59 deletions
diff --git a/src/devices/video/ppu2c0x.cpp b/src/devices/video/ppu2c0x.cpp index 4f2c6c587e7..664f9cfc7e5 100644 --- a/src/devices/video/ppu2c0x.cpp +++ b/src/devices/video/ppu2c0x.cpp @@ -322,15 +322,8 @@ void ppu2c0x_device::init_palette() init_palette(false); } -void ppu2c0x_device::init_palette(bool indirect) +rgb_t ppu2c0x_device::nespal_to_RGB(int color_intensity, int color_num) { - /* This routine builds a palette using a transformation from */ - /* the YUV (Y, B-Y, R-Y) to the RGB color space */ - - /* The NES has a 64 color palette */ - /* 16 colors, with 4 luminance levels for each color */ - /* The 16 colors circle around the YUV color space, */ - const double tint = 0.22; /* adjust to taste */ const double hue = 287.0; @@ -346,6 +339,68 @@ void ppu2c0x_device::init_palette(bool indirect) { 0, 0.24, 0.47, 0.77 } }; + double sat; + double y, u, v; + double rad; + + switch (color_num) + { + case 0: + sat = 0; rad = 0; + y = brightness[0][color_intensity]; + break; + + case 13: + sat = 0; rad = 0; + y = brightness[2][color_intensity]; + break; + + case 14: + case 15: + sat = 0; rad = 0; y = 0; + break; + + default: + sat = tint; + rad = M_PI * ((color_num * 30 + hue) / 180.0); + y = brightness[1][color_intensity]; + break; + } + + u = sat * cos(rad); + v = sat * sin(rad); + + /* Transform to RGB */ + double R = (y + Kv * v) * 255.0; + double G = (y - (Kb * Ku * u + Kr * Kv * v) / (1 - Kb - Kr)) * 255.0; + double B = (y + Ku * u) * 255.0; + + /* Clipping, in case of saturation */ + if (R < 0) + R = 0; + if (R > 255) + R = 255; + if (G < 0) + G = 0; + if (G > 255) + G = 255; + if (B < 0) + B = 0; + if (B > 255) + B = 255; + + return rgb_t(floor(R + .5), floor(G + .5), floor(B + .5)); +} + +void ppu2c0x_device::init_palette(bool indirect) +{ + /* This routine builds a palette using a transformation from */ + /* the YUV (Y, B-Y, R-Y) to the RGB color space */ + + /* The NES has a 64 color palette */ + /* 16 colors, with 4 luminance levels for each color */ + /* The 16 colors circle around the YUV color space, */ + int entry = 0; /* Loop through the emphasis modes (8 total) */ @@ -375,61 +430,13 @@ void ppu2c0x_device::init_palette(bool indirect) /* loop through the 16 colors */ for (int color_num = 0; color_num < 16; color_num++) { - double sat; - double y, u, v; - double rad; - - switch (color_num) - { - case 0: - sat = 0; rad = 0; - y = brightness[0][color_intensity]; - break; - - case 13: - sat = 0; rad = 0; - y = brightness[2][color_intensity]; - break; - - case 14: - case 15: - sat = 0; rad = 0; y = 0; - break; - - default: - sat = tint; - rad = M_PI * ((color_num * 30 + hue) / 180.0); - y = brightness[1][color_intensity]; - break; - } - - u = sat * cos(rad); - v = sat * sin(rad); - - /* Transform to RGB */ - double R = (y + Kv * v) * 255.0; - double G = (y - (Kb * Ku * u + Kr * Kv * v) / (1 - Kb - Kr)) * 255.0; - double B = (y + Ku * u) * 255.0; - - /* Clipping, in case of saturation */ - if (R < 0) - R = 0; - if (R > 255) - R = 255; - if (G < 0) - G = 0; - if (G > 255) - G = 255; - if (B < 0) - B = 0; - if (B > 255) - B = 255; + rgb_t col = nespal_to_RGB(color_intensity, color_num); /* Round, and set the value */ if (indirect) - set_indirect_color(entry++, rgb_t(floor(R + .5), floor(G + .5), floor(B + .5))); + set_indirect_color(entry++, col); else - set_pen_color(entry++, floor(R + .5), floor(G + .5), floor(B + .5)); + set_pen_color(entry++, col); } } } diff --git a/src/devices/video/ppu2c0x.h b/src/devices/video/ppu2c0x.h index 5660876674a..1a9900393e2 100644 --- a/src/devices/video/ppu2c0x.h +++ b/src/devices/video/ppu2c0x.h @@ -72,6 +72,7 @@ public: auto int_callback() { return m_int_callback.bind(); } /* routines */ + rgb_t nespal_to_RGB(int color_intensity, int color_num); virtual void init_palette(); void init_palette(bool indirect); virtual uint32_t palette_entries() const override { return 4*16*8; } |