From 079bc478a3265309821f67a11ee872343d5afe6b Mon Sep 17 00:00:00 2001 From: angelosa Date: Mon, 19 Feb 2018 00:24:18 +0100 Subject: model2.cpp: Testing sRGB color space (nw) --- src/mame/drivers/model2.cpp | 3 --- src/mame/includes/model2.h | 9 +++++++-- src/mame/video/model2.cpp | 12 +++++++++++- src/mame/video/model2rd.hxx | 14 +++++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/mame/drivers/model2.cpp b/src/mame/drivers/model2.cpp index 8c652a7b5d2..8abeeb98212 100644 --- a/src/mame/drivers/model2.cpp +++ b/src/mame/drivers/model2.cpp @@ -1810,7 +1810,6 @@ static INPUT_PORTS_START( manxtt ) PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED) PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_START1) PORT_NAME("P1 Start / VR") PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) - PORT_BIT(0x00, IP_ACTIVE_LOW, IPT_UNKNOWN) PORT_START("IN1") PORT_BIT(0xff, IP_ACTIVE_LOW, IPT_UNKNOWN) @@ -2172,8 +2171,6 @@ MACHINE_CONFIG_START(model2_state::model2_screen) MCFG_SCREEN_UPDATE_DRIVER(model2_state, screen_update_model2) MCFG_PALETTE_ADD("palette", 8192) - - MCFG_VIDEO_START_OVERRIDE(model2_state,model2) MACHINE_CONFIG_END /* original Model 2 */ diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h index 8a61551ec35..76f89d6e205 100644 --- a/src/mame/includes/model2.h +++ b/src/mame/includes/model2.h @@ -287,6 +287,11 @@ public: void model2o_mem(address_map &map); void rchase2_iocpu_map(address_map &map); void rchase2_ioport_map(address_map &map); + + uint8_t m_gamma_table[256]; + +protected: + virtual void video_start() override; }; @@ -331,14 +336,14 @@ static inline uint16_t get_texel( uint32_t base_x, uint32_t base_y, int x, int y struct triangle; -class model2_renderer : public poly_manager +class model2_renderer : public poly_manager { public: typedef void (model2_renderer::*scanline_render_func)(int32_t scanline, const extent_t& extent, const m2_poly_extra_data& object, int threadid); public: model2_renderer(model2_state& state) - : poly_manager(state.machine()) + : poly_manager(state.machine()) , m_state(state) , m_destmap(state.m_screen->width(), state.m_screen->height()) { diff --git a/src/mame/video/model2.cpp b/src/mame/video/model2.cpp index 413378425f2..3ce1560ce47 100644 --- a/src/mame/video/model2.cpp +++ b/src/mame/video/model2.cpp @@ -2583,7 +2583,7 @@ void model2_state::geo_parse( void ) /***********************************************************************************************/ -VIDEO_START_MEMBER(model2_state,model2) +void model2_state::video_start() { const rectangle &visarea = m_screen->visible_area(); int width = visarea.width(); @@ -2603,6 +2603,16 @@ VIDEO_START_MEMBER(model2_state,model2) m_palram = make_unique_clear(0x4000/2); m_colorxlat = make_unique_clear(0xc000/2); m_lumaram = make_unique_clear(0x10000/2); + + // convert (supposedly) 3d sRGB color space into linear + // TODO: might be slightly different algorithm (Daytona USA road/cars, VF2 character skins) + for(int i=0;i<256;i++) + { + double raw_value; + raw_value = 255.0 * pow((double)(i) / 255.0,2.2); + m_gamma_table[i] = (uint8_t)raw_value; +// printf("%02x: %02x %lf\n",i,m_gamma_table[i],raw_value); + } } uint32_t model2_state::screen_update_model2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) diff --git a/src/mame/video/model2rd.hxx b/src/mame/video/model2rd.hxx index 46fc606d4c6..181e90e608a 100644 --- a/src/mame/video/model2rd.hxx +++ b/src/mame/video/model2rd.hxx @@ -133,6 +133,7 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex uint32_t tex_mirr_x = object.texmirrorx; uint32_t tex_mirr_y = object.texmirrory; uint32_t *sheet = object.texsheet; + uint8_t *gamma_value = &state->m_gamma_table[0]; float ooz = extent.param[0].start; float uoz = extent.param[1].start; float voz = extent.param[2].start; @@ -155,7 +156,7 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex float z = recip_approx(ooz) * 256.0f; int32_t u = uoz * z; int32_t v = voz * z; - uint32_t tr, tg, tb; + int tr, tg, tb; uint16_t t; uint8_t luma; int u2; @@ -188,10 +189,13 @@ void MODEL2_FUNC_NAME(int32_t scanline, const extent_t& extent, const m2_poly_ex /* we have the 6 bits of luma information along with 5 bits per color component */ /* now build and index into the master color lookup table and extract the raw RGB values */ - tr = colortable_r[(luma)] & 0xff; - tg = colortable_g[(luma)] & 0xff; - tb = colortable_b[(luma)] & 0xff; - + tr = colortable_r[(luma^1)] & 0xff; + tg = colortable_g[(luma^1)] & 0xff; + tb = colortable_b[(luma^1)] & 0xff; + tr = gamma_value[tr]; + tg = gamma_value[tg]; + tb = gamma_value[tb]; + p[x] = rgb_t(tr, tg, tb); } } -- cgit v1.2.3