diff options
Diffstat (limited to 'src/mame/drivers/jangou.cpp')
-rw-r--r-- | src/mame/drivers/jangou.cpp | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/src/mame/drivers/jangou.cpp b/src/mame/drivers/jangou.cpp index 7d6f47ac171..1bc6fb59389 100644 --- a/src/mame/drivers/jangou.cpp +++ b/src/mame/drivers/jangou.cpp @@ -112,7 +112,7 @@ private: DECLARE_READ8_MEMBER(input_mux_r); DECLARE_READ8_MEMBER(input_system_r); - DECLARE_PALETTE_INIT(jangou); + void jangou_palette(palette_device &palette) const; DECLARE_MACHINE_START(jngolady); DECLARE_MACHINE_RESET(jngolady); DECLARE_MACHINE_START(common); @@ -142,42 +142,40 @@ private: * *************************************/ -/* guess: use the same resistor values as Crazy Climber (needs checking on the real HW) */ -PALETTE_INIT_MEMBER(jangou_state, jangou) +// guess: use the same resistor values as Crazy Climber (needs checking on the real hardware) +void jangou_state::jangou_palette(palette_device &palette) const { - const uint8_t *color_prom = memregion("proms")->base(); - static const int resistances_rg[3] = { 1000, 470, 220 }; - static const int resistances_b [2] = { 470, 220 }; - double weights_rg[3], weights_b[2]; - int i; + uint8_t const *const color_prom = memregion("proms")->base(); + static constexpr int resistances_rg[3] = { 1000, 470, 220 }; + static constexpr int resistances_b [2] = { 470, 220 }; - /* compute the color output resistor weights */ + // compute the color output resistor weights + double weights_rg[3], weights_b[2]; compute_resistor_weights(0, 255, -1.0, 3, resistances_rg, weights_rg, 0, 0, 2, resistances_b, weights_b, 0, 0, 0, nullptr, nullptr, 0, 0); - for (i = 0;i < palette.entries(); i++) + for (int i = 0;i < palette.entries(); i++) { int bit0, bit1, bit2; - int r, g, b; - /* red component */ - bit0 = (color_prom[i] >> 0) & 0x01; - bit1 = (color_prom[i] >> 1) & 0x01; - bit2 = (color_prom[i] >> 2) & 0x01; - r = combine_3_weights(weights_rg, bit0, bit1, bit2); + // red component + bit0 = BIT(color_prom[i], 0); + bit1 = BIT(color_prom[i], 1); + bit2 = BIT(color_prom[i], 2); + int const r = combine_3_weights(weights_rg, bit0, bit1, bit2); - /* green component */ - bit0 = (color_prom[i] >> 3) & 0x01; - bit1 = (color_prom[i] >> 4) & 0x01; - bit2 = (color_prom[i] >> 5) & 0x01; - g = combine_3_weights(weights_rg, bit0, bit1, bit2); + // green component + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const g = combine_3_weights(weights_rg, bit0, bit1, bit2); - /* blue component */ - bit0 = (color_prom[i] >> 6) & 0x01; - bit1 = (color_prom[i] >> 7) & 0x01; - b = combine_2_weights(weights_b, bit0, bit1); + // blue component + bit0 = BIT(color_prom[i], 6); + bit1 = BIT(color_prom[i], 7); + int const b = combine_2_weights(weights_b, bit0, bit1); palette.set_pen_color(i, rgb_t(r, g, b)); } @@ -190,16 +188,14 @@ void jangou_state::video_start() uint32_t jangou_state::screen_update_jangou(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int x, y; - - for (y = cliprect.min_y; y <= cliprect.max_y; ++y) + for (int y = cliprect.min_y; y <= cliprect.max_y; ++y) { const uint8_t *src = &m_blitter->blit_buffer(y, cliprect.min_x); uint16_t *dst = &m_tmp_bitmap->pix16(y, cliprect.min_x); - for (x = cliprect.min_x; x <= cliprect.max_x; x += 2) + for (int x = cliprect.min_x; x <= cliprect.max_x; x += 2) { - uint32_t srcpix = *src++; + uint32_t const srcpix = *src++; *dst++ = m_palette->pen(srcpix & 0xf); *dst++ = m_palette->pen((srcpix >> 4) & 0xf); } @@ -892,10 +888,9 @@ MACHINE_CONFIG_START(jangou_state::jangou) MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_RAW_PARAMS(MASTER_CLOCK/4,320,0,256,264,16,240) // assume same as nightgal.cpp MCFG_SCREEN_UPDATE_DRIVER(jangou_state, screen_update_jangou) - MCFG_SCREEN_PALETTE("palette") + MCFG_SCREEN_PALETTE(m_palette) - MCFG_PALETTE_ADD("palette", 32) - MCFG_PALETTE_INIT_OWNER(jangou_state, jangou) + PALETTE(config, m_palette, FUNC(jangou_state::jangou_palette), 32); /* sound hardware */ SPEAKER(config, "mono").front_center(); |