From a6ea0544f226e7c86f4d6b405f2f66b76ccc7cdd Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 18 Dec 2024 15:34:39 +0100 Subject: route16: merge driver --- src/mame/sunelectronics/route16.cpp | 228 +++++++++++++++++++++++++++++++++- src/mame/sunelectronics/route16.h | 94 -------------- src/mame/sunelectronics/route16_v.cpp | 145 --------------------- 3 files changed, 227 insertions(+), 240 deletions(-) delete mode 100644 src/mame/sunelectronics/route16.h delete mode 100644 src/mame/sunelectronics/route16_v.cpp diff --git a/src/mame/sunelectronics/route16.cpp b/src/mame/sunelectronics/route16.cpp index 3321a7bca7e..202a242ef4b 100644 --- a/src/mame/sunelectronics/route16.cpp +++ b/src/mame/sunelectronics/route16.cpp @@ -157,15 +157,71 @@ PL2 Button | 7A | 7B | PL1 Button ***************************************************************************/ #include "emu.h" -#include "route16.h" #include "cpu/z80/z80.h" #include "sound/ay8910.h" #include "sound/dac.h" #include "sound/sn76477.h" +#include "emupal.h" +#include "screen.h" #include "speaker.h" + +namespace { + +class route16_state : public driver_device +{ +public: + route16_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_cpu1(*this, "cpu1") + , m_cpu2(*this, "cpu2") + , m_videoram(*this, "videoram%u", 1U) + , m_proms(*this, "proms") + , m_palette(*this, "palette") + , m_screen(*this, "screen") + { } + + void routex(machine_config &config); + void route16(machine_config &config); + + void init_route16(); + void init_route16a(); + void init_route16c(); + void init_route16d(); + +protected: + virtual void machine_start() override ATTR_COLD; + + void out0_w(uint8_t data); + void out1_w(uint8_t data); + + uint32_t screen_update_route16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + uint32_t screen_update_stratvox(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + + required_device m_cpu1; + required_device m_cpu2; + + required_shared_ptr_array m_videoram; + required_region_ptr m_proms; + required_device m_palette; + required_device m_screen; + + uint8_t m_protection_data = 0; + uint8_t m_flipscreen = 0; + uint8_t m_palreg[2] = { }; + +private: + uint8_t route16_prot_r(); + uint8_t routex_prot_r(); + + void cpu1_io_map(address_map &map) ATTR_COLD; + void route16_cpu1_map(address_map &map) ATTR_COLD; + void route16_cpu2_map(address_map &map) ATTR_COLD; + void routex_cpu1_map(address_map &map) ATTR_COLD; +}; + class speakres_state : public route16_state { public: @@ -199,6 +255,37 @@ private: attotime m_speakres_vrx; }; +class jongpute_state : public route16_state +{ +public: + jongpute_state(const machine_config &mconfig, device_type type, const char *tag) + : route16_state(mconfig, type, tag) + , m_decrypted_opcodes(*this, "decrypted_opcodes") + , m_key(*this, "KEY%u", 0U) + { } + + void jongpute(machine_config &config); + void vscompmj(machine_config &config); + + void init_vscompmj(); + +protected: + virtual void machine_start() override ATTR_COLD; + +private: + void input_w(uint8_t data); + template uint8_t input_r(); + + void jongpute_cpu1_map(address_map &map) ATTR_COLD; + void vscompmj_cpu1_map(address_map &map) ATTR_COLD; + void vscompmj_decrypted_opcodes(address_map &map) ATTR_COLD; + + optional_shared_ptr m_decrypted_opcodes; + required_ioport_array<8> m_key; + + uint8_t m_port_select = 0; +}; + /************************************* * @@ -341,6 +428,141 @@ void jongpute_state::init_vscompmj() // only opcodes encrypted +/************************************* + * + * Video update + * + *************************************/ + +uint32_t route16_state::screen_update_route16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + uint8_t *color_prom1 = &m_proms[0x000]; + uint8_t *color_prom2 = &m_proms[0x100]; + + for (offs_t offs = 0; offs < m_videoram[0].bytes(); offs++) + { + uint8_t y = offs >> 6; + uint8_t x = offs << 2; + + uint8_t data1 = m_videoram[0][offs]; + uint8_t data2 = m_videoram[1][offs]; + + for (int i = 0; i < 4; i++) + { + uint8_t dx = x, dy = y; + + // Game observation shows that Route 16 can blank each bitmap by setting bit 1 of the + // palette register. Since the schematics are missing the relevant pages, I cannot confirm + // how this works, but I am 99% sure the bit 1 would be connected to A7 of the color PROM. + // Since the color PROMs contain 0 in the upper half, this would produce a black output. + + uint8_t color1 = color_prom1[((m_palreg[0] << 6) & 0x80) | + (m_palreg[0] << 2) | + ((data1 >> 3) & 0x02) | + ((data1 >> 0) & 0x01)]; + + uint8_t color2 = color_prom2[((m_palreg[1] << 6) & 0x80) | + (m_palreg[1] << 2) | + ((data2 >> 3) & 0x02) | + ((data2 >> 0) & 0x01)]; + + // the final color is the OR of the two colors (verified) + uint8_t final_color = (color1 | color2) & 0x07; + + if (m_flipscreen) + { + dy = 255 - dy; + dx = 255 - dx; + } + + if (cliprect.contains(dx, dy)) + bitmap.pix(dy, dx) = m_palette->pen_color(final_color); + + x++; + data1 >>= 1; + data2 >>= 1; + } + } + + return 0; +} + + +// The Stratovox video connections have been verified from the schematics + +uint32_t route16_state::screen_update_stratvox(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + uint8_t *color_prom1 = &m_proms[0x000]; + uint8_t *color_prom2 = &m_proms[0x100]; + + for (offs_t offs = 0; offs < m_videoram[0].bytes(); offs++) + { + uint8_t y = offs >> 6; + uint8_t x = offs << 2; + + uint8_t data1 = m_videoram[0][offs]; + uint8_t data2 = m_videoram[1][offs]; + + for (int i = 0; i < 4; i++) + { + uint8_t dx = x, dy = y; + + uint8_t color1 = color_prom1[(m_palreg[0] << 2) | + ((data1 >> 3) & 0x02) | + ((data1 >> 0) & 0x01)]; + + // bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 (verified) + uint8_t color2 = color_prom2[(((data1 << 3) & 0x80) | ((data1 << 7) & 0x80)) | + (m_palreg[1] << 2) | + ((data2 >> 3) & 0x02) | + ((data2 >> 0) & 0x01)]; + + // the final color is the OR of the two colors + uint8_t final_color = (color1 | color2) & 0x07; + + if (m_flipscreen) + { + dy = 255 - dy; + dx = 255 - dx; + } + + if (cliprect.contains(dx, dy)) + bitmap.pix(dy, dx) = m_palette->pen_color(final_color); + + x++; + data1 >>= 1; + data2 >>= 1; + } + } + + return 0; +} + + + +/************************************* + * + * Memory handlers + * + *************************************/ + +void route16_state::out0_w(uint8_t data) +{ + m_palreg[0] = data & 0x1f; + + machine().bookkeeping().coin_counter_w(0, (data >> 5) & 0x01); +} + + +void route16_state::out1_w(uint8_t data) +{ + m_palreg[1] = data & 0x1f; + + m_flipscreen = (data >> 5) & 0x01; +} + + + /************************************* * * Protection handling @@ -990,6 +1212,7 @@ void jongpute_state::vscompmj(machine_config &config) } + /************************************* * * ROM definitions @@ -1437,6 +1660,9 @@ ROM_START( vscompmj ) ROM_LOAD( "82s129.9r", 0x0000, 0x0100, CRC(20ac25d8) SHA1(6f06472ac7fcb22c9060092a2d456be5d3ca6d5f) ) ROM_END +} // anonymous namespace + + /************************************* * diff --git a/src/mame/sunelectronics/route16.h b/src/mame/sunelectronics/route16.h deleted file mode 100644 index 270f096369b..00000000000 --- a/src/mame/sunelectronics/route16.h +++ /dev/null @@ -1,94 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Zsolt Vasvari -#ifndef MAME_SUNELECTRONICS_ROUTE16_H -#define MAME_SUNELECTRONICS_ROUTE16_H - -#pragma once - -#include "emupal.h" -#include "screen.h" - -class route16_state : public driver_device -{ -public: - route16_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_cpu1(*this, "cpu1") - , m_cpu2(*this, "cpu2") - , m_videoram(*this, "videoram%u", 1U) - , m_proms(*this, "proms") - , m_palette(*this, "palette") - , m_screen(*this, "screen") - { } - - void routex(machine_config &config); - void route16(machine_config &config); - - void init_route16(); - void init_route16a(); - void init_route16c(); - void init_route16d(); - -protected: - virtual void machine_start() override ATTR_COLD; - - void out0_w(uint8_t data); - void out1_w(uint8_t data); - - uint32_t screen_update_route16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - uint32_t screen_update_stratvox(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - - required_device m_cpu1; - required_device m_cpu2; - - required_shared_ptr_array m_videoram; - required_region_ptr m_proms; - required_device m_palette; - required_device m_screen; - - uint8_t m_protection_data = 0; - uint8_t m_flipscreen = 0; - uint8_t m_palreg[2] = { }; - -private: - uint8_t route16_prot_r(); - uint8_t routex_prot_r(); - - void cpu1_io_map(address_map &map) ATTR_COLD; - void route16_cpu1_map(address_map &map) ATTR_COLD; - void route16_cpu2_map(address_map &map) ATTR_COLD; - void routex_cpu1_map(address_map &map) ATTR_COLD; -}; - -class jongpute_state : public route16_state -{ -public: - jongpute_state(const machine_config &mconfig, device_type type, const char *tag) - : route16_state(mconfig, type, tag) - , m_decrypted_opcodes(*this, "decrypted_opcodes") - , m_key(*this, "KEY%u", 0U) - { } - - void jongpute(machine_config &config); - void vscompmj(machine_config &config); - - void init_vscompmj(); - -protected: - virtual void machine_start() override ATTR_COLD; - -private: - void input_w(uint8_t data); - template uint8_t input_r(); - - void jongpute_cpu1_map(address_map &map) ATTR_COLD; - void vscompmj_cpu1_map(address_map &map) ATTR_COLD; - void vscompmj_decrypted_opcodes(address_map &map) ATTR_COLD; - - optional_shared_ptr m_decrypted_opcodes; - required_ioport_array<8> m_key; - - uint8_t m_port_select = 0; -}; - -#endif // MAME_SUNELECTRONICS_ROUTE16_H diff --git a/src/mame/sunelectronics/route16_v.cpp b/src/mame/sunelectronics/route16_v.cpp deleted file mode 100644 index d7e22cb3bd3..00000000000 --- a/src/mame/sunelectronics/route16_v.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Zsolt Vasvari -/*************************************************************************** - - route16.cpp - - Functions to emulate the video hardware of the machine. - -***************************************************************************/ - -#include "emu.h" -#include "route16.h" - -/************************************* - * - * Memory handlers - * - *************************************/ - -void route16_state::out0_w(uint8_t data) -{ - m_palreg[0] = data & 0x1f; - - machine().bookkeeping().coin_counter_w(0, (data >> 5) & 0x01); -} - - -void route16_state::out1_w(uint8_t data) -{ - m_palreg[1] = data & 0x1f; - - m_flipscreen = (data >> 5) & 0x01; -} - - - -/************************************* - * - * Video update - * - *************************************/ - -uint32_t route16_state::screen_update_route16(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - uint8_t *color_prom1 = &m_proms[0x000]; - uint8_t *color_prom2 = &m_proms[0x100]; - - for (offs_t offs = 0; offs < m_videoram[0].bytes(); offs++) - { - uint8_t y = offs >> 6; - uint8_t x = offs << 2; - - uint8_t data1 = m_videoram[0][offs]; - uint8_t data2 = m_videoram[1][offs]; - - for (int i = 0; i < 4; i++) - { - uint8_t dx = x, dy = y; - - // Game observation shows that Route 16 can blank each bitmap by setting bit 1 of the - // palette register. Since the schematics are missing the relevant pages, I cannot confirm - // how this works, but I am 99% sure the bit 1 would be connected to A7 of the color PROM. - // Since the color PROMs contain 0 in the upper half, this would produce a black output. - - uint8_t color1 = color_prom1[((m_palreg[0] << 6) & 0x80) | - (m_palreg[0] << 2) | - ((data1 >> 3) & 0x02) | - ((data1 >> 0) & 0x01)]; - - uint8_t color2 = color_prom2[((m_palreg[1] << 6) & 0x80) | - (m_palreg[1] << 2) | - ((data2 >> 3) & 0x02) | - ((data2 >> 0) & 0x01)]; - - // the final color is the OR of the two colors (verified) - uint8_t final_color = (color1 | color2) & 0x07; - - if (m_flipscreen) - { - dy = 255 - dy; - dx = 255 - dx; - } - - if (cliprect.contains(dx, dy)) - bitmap.pix(dy, dx) = m_palette->pen_color(final_color); - - x++; - data1 >>= 1; - data2 >>= 1; - } - } - - return 0; -} - - -// The Stratovox video connections have been verified from the schematics - -uint32_t route16_state::screen_update_stratvox(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - uint8_t *color_prom1 = &m_proms[0x000]; - uint8_t *color_prom2 = &m_proms[0x100]; - - for (offs_t offs = 0; offs < m_videoram[0].bytes(); offs++) - { - uint8_t y = offs >> 6; - uint8_t x = offs << 2; - - uint8_t data1 = m_videoram[0][offs]; - uint8_t data2 = m_videoram[1][offs]; - - for (int i = 0; i < 4; i++) - { - uint8_t dx = x, dy = y; - - uint8_t color1 = color_prom1[(m_palreg[0] << 2) | - ((data1 >> 3) & 0x02) | - ((data1 >> 0) & 0x01)]; - - // bit 7 of the 2nd color is the OR of the 1st color bits 0 and 1 (verified) - uint8_t color2 = color_prom2[(((data1 << 3) & 0x80) | ((data1 << 7) & 0x80)) | - (m_palreg[1] << 2) | - ((data2 >> 3) & 0x02) | - ((data2 >> 0) & 0x01)]; - - // the final color is the OR of the two colors - uint8_t final_color = (color1 | color2) & 0x07; - - if (m_flipscreen) - { - dy = 255 - dy; - dx = 255 - dx; - } - - if (cliprect.contains(dx, dy)) - bitmap.pix(dy, dx) = m_palette->pen_color(final_color); - - x++; - data1 >>= 1; - data2 >>= 1; - } - } - - return 0; -} -- cgit v1.2.3