diff options
author | 2020-03-02 20:51:08 +0100 | |
---|---|---|
committer | 2020-03-02 20:51:21 +0100 | |
commit | ef8a892525bf036fc4786df745443dd040603ccf (patch) | |
tree | cf3426dc08145b4e3983e795a76251f403160348 /src/mame/drivers/craft.cpp | |
parent | a5415190577320fc24095d8ae639773fd315d59b (diff) |
-avr8: Miscellaneous optimizations (nw)
Diffstat (limited to 'src/mame/drivers/craft.cpp')
-rw-r--r-- | src/mame/drivers/craft.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mame/drivers/craft.cpp b/src/mame/drivers/craft.cpp index 973de68b04d..d13abd1981e 100644 --- a/src/mame/drivers/craft.cpp +++ b/src/mame/drivers/craft.cpp @@ -11,6 +11,7 @@ #include "sound/dac.h" #include "sound/volt_reg.h" #include "screen.h" +#include "emupal.h" #include "speaker.h" #define MASTER_CLOCK 20000000 @@ -31,6 +32,7 @@ public: : driver_device(mconfig, type, tag) , m_maincpu(*this, "maincpu") , m_screen(*this, "screen") + , m_palette(*this, "palette") , m_dac(*this, "dac") { } @@ -48,11 +50,13 @@ private: DECLARE_READ8_MEMBER(port_r); DECLARE_WRITE8_MEMBER(port_w); + void init_palette(palette_device &palette) const; void video_update(); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); required_device<avr8_device> m_maincpu; required_device<screen_device> m_screen; + required_device<palette_device> m_palette; required_device<dac_byte_interface> m_dac; uint32_t m_last_cycles; @@ -149,6 +153,17 @@ void craft_state::craft_io_map(address_map &map) // VIDEO //************************************************************************** +void craft_state::init_palette(palette_device &palette) const +{ + for (int i = 0; i < 0x40; i++) + { + uint8_t r = 0x55 * ((i & 0x30) >> 4); + uint8_t g = 0x55 * ((i & 0x0c) >> 2); + uint8_t b = 0x55 * (i & 0x03); + palette.set_pen_color(i, rgb_t(r, g, b)); + } +} + void craft_state::video_update() { uint64_t cycles = machine().time().as_ticks(MASTER_CLOCK); @@ -182,16 +197,14 @@ void craft_state::video_update() uint32_t craft_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { + const pen_t *pens = m_palette->pens(); for(int y = 0; y < LINES_PER_FRAME; y++) { - uint32_t *line = &bitmap.pix32(y); + uint32_t *dst = &bitmap.pix32(y); + uint8_t *src = &m_pixels[y * LINE_CYCLES]; for(int x = 0; x < LINE_CYCLES; x++) { - uint8_t pixel = m_pixels[y * LINE_CYCLES + x]; - uint8_t r = 0x55 * ((pixel & 0x30) >> 4); - uint8_t g = 0x55 * ((pixel & 0x0c) >> 2); - uint8_t b = 0x55 * (pixel & 0x03); - line[x] = 0xff000000 | (r << 16) | (g << 8) | b; + *dst++ = pens[*src++]; } } return 0; @@ -246,6 +259,8 @@ void craft_state::craft(machine_config &config) m_screen->set_raw(MASTER_CLOCK, 635, 47, 527, 525, 36, 516); m_screen->set_screen_update(FUNC(craft_state::screen_update)); + PALETTE(config, m_palette, FUNC(craft_state::init_palette), 64); + /* sound hardware */ SPEAKER(config, "avr8").front_center(); DAC_6BIT_R2R(config, "dac", 0).add_route(0, "avr8", 0.25); // pd1/pd2/pd4/pd5/pd6/pd7 + 2k(x7) + 1k(x5) |