From 706502c615bd5cb96059c5878c5582c6d8604874 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 4 Dec 2024 20:54:28 +0100 Subject: [PATCH] videopac: add 7seg outputs for testcartpl --- hash/videopac.xml | 2 +- src/devices/bus/odyssey2/rally.cpp | 61 ++++++++++++++++++++++++++++-- src/devices/bus/odyssey2/rally.h | 1 + src/devices/bus/odyssey2/slot.cpp | 2 + src/devices/bus/odyssey2/slot.h | 3 +- 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/hash/videopac.xml b/hash/videopac.xml index 4f6bef3a88a..73e9fe4def9 100644 --- a/hash/videopac.xml +++ b/hash/videopac.xml @@ -2556,7 +2556,7 @@ distinguished by the changed copyright from Magnavox to N.A.P. (North American P Philips - + diff --git a/src/devices/bus/odyssey2/rally.cpp b/src/devices/bus/odyssey2/rally.cpp index 491a725367f..37ad1d2c89c 100644 --- a/src/devices/bus/odyssey2/rally.cpp +++ b/src/devices/bus/odyssey2/rally.cpp @@ -14,6 +14,9 @@ Used in: #55 and #58 also work on the G7000. +It's used by the Videopac+ Service Test cartridge too, with 2 7segs added. The +7segs are just for showing error codes, it will still work fine without them. + ******************************************************************************/ #include "emu.h" @@ -25,12 +28,16 @@ namespace { // initialization //------------------------------------------------- +// Rally / shared + class o2_rally_device : public device_t, public device_o2_cart_interface { public: o2_rally_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); protected: + o2_rally_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); + virtual void device_start() override ATTR_COLD; virtual void cart_init() override; @@ -41,16 +48,19 @@ protected: virtual void write_p1(u8 data) override { m_control = data; } virtual void io_write(offs_t offset, u8 data) override; -private: u8 m_control = 0; u8 m_bank = 0; }; -o2_rally_device::o2_rally_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - device_t(mconfig, O2_ROM_RALLY, tag, owner, clock), +o2_rally_device::o2_rally_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, type, tag, owner, clock), device_o2_cart_interface(mconfig, *this) { } +o2_rally_device::o2_rally_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + o2_rally_device(mconfig, O2_ROM_RALLY, tag, owner, clock) +{ } + void o2_rally_device::device_start() { save_item(NAME(m_control)); @@ -64,6 +74,35 @@ void o2_rally_device::cart_init() } +// Service Test Cartridge + +class o2_testpl_device : public o2_rally_device +{ +public: + o2_testpl_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + +protected: + virtual void device_start() override ATTR_COLD; + + virtual void io_write(offs_t offset, u8 data) override; + +private: + output_finder<2> m_digit_out; +}; + +o2_testpl_device::o2_testpl_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + o2_rally_device(mconfig, O2_ROM_TESTPL, tag, owner, clock), + m_digit_out(*this, "tc_digit%u", 0U) +{ } + +void o2_testpl_device::device_start() +{ + o2_rally_device::device_start(); + + m_digit_out.resolve(); +} + + //------------------------------------------------- // mapper specific handlers //------------------------------------------------- @@ -81,7 +120,23 @@ void o2_rally_device::io_write(offs_t offset, u8 data) m_bank = data; } +void o2_testpl_device::io_write(offs_t offset, u8 data) +{ + o2_rally_device::io_write(offset, data); + + // write to 7segs if P11 is low + if (~m_control & 2) + { + static const u8 ls48_map[0x10] = + { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67,0x58,0x4c,0x62,0x69,0x78,0x00 }; + + m_digit_out[0] = ls48_map[data >> 4]; + m_digit_out[1] = ls48_map[data & 0xf]; + } +} + } // anonymous namespace DEFINE_DEVICE_TYPE_PRIVATE(O2_ROM_RALLY, device_o2_cart_interface, o2_rally_device, "o2_rally", "Videopac+ 60 Cartridge") +DEFINE_DEVICE_TYPE_PRIVATE(O2_ROM_TESTPL, device_o2_cart_interface, o2_testpl_device, "o2_testpl", "Videopac+ Service Test Cartridge") diff --git a/src/devices/bus/odyssey2/rally.h b/src/devices/bus/odyssey2/rally.h index 9f022d02031..b9715050e49 100644 --- a/src/devices/bus/odyssey2/rally.h +++ b/src/devices/bus/odyssey2/rally.h @@ -14,5 +14,6 @@ #include "slot.h" DECLARE_DEVICE_TYPE(O2_ROM_RALLY, device_o2_cart_interface) +DECLARE_DEVICE_TYPE(O2_ROM_TESTPL, device_o2_cart_interface) #endif // MAME_BUS_ODYSSEY2_RALLY_H diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp index dba3fa09ff3..5705e68db14 100644 --- a/src/devices/bus/odyssey2/slot.cpp +++ b/src/devices/bus/odyssey2/slot.cpp @@ -102,6 +102,7 @@ static const o2_slot slot_list[] = { O2_CHESS, "o2_chess" }, { O2_HOMECOMP, "o2_homecomp" }, { O2_TEST, "o2_test" }, + { O2_TESTPL, "o2_testpl" }, { O2_VOICE, "o2_voice" } }; @@ -291,5 +292,6 @@ void o2_cart(device_slot_interface &device) device.option_add_internal("o2_chess", O2_ROM_CHESS); device.option_add_internal("o2_homecomp", O2_ROM_HOMECOMP); device.option_add_internal("o2_test", O2_ROM_TEST); + device.option_add_internal("o2_testpl", O2_ROM_TESTPL); device.option_add_internal("o2_voice", O2_ROM_VOICE); } diff --git a/src/devices/bus/odyssey2/slot.h b/src/devices/bus/odyssey2/slot.h index ce59d0704a8..70f1b8d555c 100644 --- a/src/devices/bus/odyssey2/slot.h +++ b/src/devices/bus/odyssey2/slot.h @@ -34,7 +34,7 @@ on Videopac+, B is used for video mixer override */ -/* PCB */ +// PCB enum { O2_STD = 0, @@ -44,6 +44,7 @@ enum O2_CHESS, O2_HOMECOMP, O2_TEST, + O2_TESTPL, O2_VOICE };