From c53b36b892470df03616d3175245d4e465c9a35b Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 10 Mar 2024 23:38:41 +1100 Subject: [PATCH] -bus/a2bus: Added SNES MAX game controller interface card. -docs: Clarified description of EMULATOR make option. --- docs/source/initialsetup/compilingmame.rst | 5 +- scripts/src/bus.lua | 2 + src/devices/bus/a2bus/cards.cpp | 4 + src/devices/bus/a2bus/snesmax.cpp | 97 ++++++++++++++++++++++ src/devices/bus/a2bus/snesmax.h | 20 +++++ 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 src/devices/bus/a2bus/snesmax.cpp create mode 100644 src/devices/bus/a2bus/snesmax.h diff --git a/docs/source/initialsetup/compilingmame.rst b/docs/source/initialsetup/compilingmame.rst index f458f34af0860..c9ef6d3465afe 100644 --- a/docs/source/initialsetup/compilingmame.rst +++ b/docs/source/initialsetup/compilingmame.rst @@ -560,8 +560,9 @@ TOOLS Set to **1** to build additional tools along with the emulator, including **unidasm**, **chdman**, **romcmp**, and **srcclean**. EMULATOR - Set to **0** along with **TOOLS=1** to build *only* the tools and not the - main MAME emulator itself. + When set to **0**, the main emulator target will not be created. This is + intended to be used in conjunction with setting **TOOLS** to **1** to build + the additional tools without building the emulator. NO_OPENGL Set to **1** to disable building the OpenGL video output module. NO_USE_PORTAUDIO diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 97aae47503054..a8901b1d75c65 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2992,6 +2992,8 @@ if (BUSES["A2BUS"]~=null) then MAME_DIR .. "src/devices/bus/a2bus/romcard.h", MAME_DIR .. "src/devices/bus/a2bus/sider.cpp", MAME_DIR .. "src/devices/bus/a2bus/sider.h", + MAME_DIR .. "src/devices/bus/a2bus/snesmax.cpp", + MAME_DIR .. "src/devices/bus/a2bus/snesmax.h", MAME_DIR .. "src/devices/bus/a2bus/softcard3.cpp", MAME_DIR .. "src/devices/bus/a2bus/softcard3.h", MAME_DIR .. "src/devices/bus/a2bus/ssbapple.cpp", diff --git a/src/devices/bus/a2bus/cards.cpp b/src/devices/bus/a2bus/cards.cpp index 817553ee23954..5ab855ddf5e7f 100644 --- a/src/devices/bus/a2bus/cards.cpp +++ b/src/devices/bus/a2bus/cards.cpp @@ -62,6 +62,7 @@ #include "ramcard16k.h" #include "romcard.h" #include "sider.h" +#include "snesmax.h" #include "softcard3.h" #include "ssbapple.h" #include "ssprite.h" @@ -136,6 +137,7 @@ void apple2_cards(device_slot_interface &device) device.option_add("ssprite", A2BUS_SSPRITE); // Synetix SuperSprite Board device.option_add("ssbapple", A2BUS_SSBAPPLE); // SSB Apple speech board device.option_add("4play", A2BUS_4PLAY); // 4Play Joystick Card (Rev. B) + device.option_add("snesmax", A2BUS_SNES_MAX); // SNES MAX controller adapter device.option_add("ceyes2", A2BUS_COMPUTEREYES2); // ComputerEyes/2 Video Digitizer device.option_add("twarp", A2BUS_TRANSWARP); // AE TransWarp accelerator device.option_add("applesurance", A2BUS_APPLESURANCE); // Applesurance Diagnostic Controller @@ -212,6 +214,7 @@ void apple2e_cards(device_slot_interface &device) device.option_add("twarp", A2BUS_TRANSWARP); // AE TransWarp accelerator device.option_add("vulcan", A2BUS_VULCANIIE); // Applied Engineering Vulcan IDE drive device.option_add("4play", A2BUS_4PLAY); // 4Play Joystick Card (Rev. B) + device.option_add("snesmax", A2BUS_SNES_MAX); // SNES MAX controller adapter device.option_add("ceyes2", A2BUS_COMPUTEREYES2); // ComputerEyes/2 Video Digitizer device.option_add("applesurance", A2BUS_APPLESURANCE); // Applesurance Diagnostic Controller device.option_add("byte8251", A2BUS_BYTE8251); // BYTE Magazine 8251 serial card @@ -286,6 +289,7 @@ void apple2gs_cards(device_slot_interface &device) device.option_add("vulcan", A2BUS_VULCAN); // Applied Engineering Vulcan IDE drive device.option_add("vulcangold", A2BUS_VULCANGOLD); // Applied Engineering Vulcan Gold IDE drive device.option_add("4play", A2BUS_4PLAY); // 4Play Joystick Card (Rev. B) + device.option_add("snesmax", A2BUS_SNES_MAX); // SNES MAX controller adapter // device.option_add("magicmusician", A2BUS_MAGICMUSICIAN); // Magic Musician Card // device.option_add("pcxport", A2BUS_PCXPORTER); // Applied Engineering PC Transporter device.option_add("byte8251", A2BUS_BYTE8251); // BYTE Magazine 8251 serial card diff --git a/src/devices/bus/a2bus/snesmax.cpp b/src/devices/bus/a2bus/snesmax.cpp new file mode 100644 index 0000000000000..25638da62ed33 --- /dev/null +++ b/src/devices/bus/a2bus/snesmax.cpp @@ -0,0 +1,97 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +#include "emu.h" +#include "snesmax.h" + +#include "bus/snes_ctrl/ctrl.h" + +namespace { + +class a2bus_snes_max_device : public device_t, public device_a2bus_card_interface +{ +public: + a2bus_snes_max_device( + machine_config const &mconfig, + char const *tag, + device_t *owner, + u32 clock) : + device_t(mconfig, A2BUS_SNES_MAX, tag, owner, clock), + device_a2bus_card_interface(mconfig, *this), + m_controllers(*this, "%u", 1U), + m_latch_timer(nullptr), + m_data(0xff) + { + } + + virtual u8 read_c0nx(u8 offset) override + { + return m_data; + } + + virtual void write_c0nx(u8 offset, u8 data) override + { + if (BIT(offset, 0)) + { + m_data = + (m_controllers[0]->read_pin4() ? 0x00 : 0x80) | + (m_controllers[1]->read_pin4() ? 0x00 : 0x40) | + 0x3f; + } + else + { + machine().scheduler().synchronize(timer_expired_delegate(FUNC(a2bus_snes_max_device::set_latch), this), 0); + } + } + + virtual bool take_c800() override + { + return false; + } + +protected: + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD + { + SNES_CONTROL_PORT(config, m_controllers[0], snes_control_port_devices, "joypad"); + SNES_CONTROL_PORT(config, m_controllers[1], snes_control_port_devices, "joypad"); + } + + virtual void device_start() override ATTR_COLD + { + m_latch_timer = timer_alloc(FUNC(a2bus_snes_max_device::reset_latch), this); + + m_data = 0xff; + + save_item(NAME(m_data)); + + m_controllers[0]->write_strobe(0); + m_controllers[1]->write_strobe(0); + } + +private: + TIMER_CALLBACK_MEMBER(set_latch) + { + m_controllers[0]->write_strobe(1); + m_controllers[1]->write_strobe(1); + m_latch_timer->adjust(attotime::from_ticks(7, clock())); + } + + TIMER_CALLBACK_MEMBER(reset_latch) + { + m_controllers[0]->write_strobe(0); + m_controllers[1]->write_strobe(0); + + m_data = + (m_controllers[0]->read_pin4() ? 0x00 : 0x80) | + (m_controllers[1]->read_pin4() ? 0x00 : 0x40) | + 0x3f; + } + + required_device_array m_controllers; + emu_timer *m_latch_timer; + u8 m_data; +}; + +} // anonymous namespace + + +DEFINE_DEVICE_TYPE_PRIVATE(A2BUS_SNES_MAX, device_a2bus_card_interface, a2bus_snes_max_device, "a2snesmax", "SNES MAX Game Controller Interface") diff --git a/src/devices/bus/a2bus/snesmax.h b/src/devices/bus/a2bus/snesmax.h new file mode 100644 index 0000000000000..a28bae2de5c54 --- /dev/null +++ b/src/devices/bus/a2bus/snesmax.h @@ -0,0 +1,20 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/*********************************************************************** + + Orange Micro Grappler/Grappler+ Printer Interface + + https://lukazi.blogspot.com/2021/06/game-controller-snes-max-snes.html + +***********************************************************************/ +#ifndef MAME_BUS_A2BUS_SNESMAX_H +#define MAME_BUS_A2BUS_SNESMAX_H + +#pragma once + +#include "a2bus.h" + + +DECLARE_DEVICE_TYPE(A2BUS_SNES_MAX, device_a2bus_card_interface) + +#endif // MAME_BUS_A2BUS_SNESMAX_H