From eb1df97c6bc000fa6f06fbcb8cdab400224a077b Mon Sep 17 00:00:00 2001 From: tim lindner Date: Mon, 31 May 2021 13:29:01 -0700 Subject: bus/coco: add CoCo Max Hi Res Input Module (#8104) --- scripts/src/bus.lua | 2 + src/devices/bus/coco/coco_max.cpp | 172 ++++++++++++++++++++++++++++++++++++++ src/devices/bus/coco/coco_max.h | 14 ++++ src/devices/bus/coco/cococart.cpp | 2 + src/mame/drivers/coco12.cpp | 2 +- src/mame/drivers/dragon.cpp | 2 + src/mame/machine/6883sam.cpp | 81 +++++++++++++++--- 7 files changed, 263 insertions(+), 12 deletions(-) create mode 100644 src/devices/bus/coco/coco_max.cpp create mode 100644 src/devices/bus/coco/coco_max.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 4196c80050b..6808a5beb39 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -3455,6 +3455,8 @@ if (BUSES["COCO"]~=null) then MAME_DIR .. "src/devices/bus/coco/coco_fdc.h", MAME_DIR .. "src/devices/bus/coco/coco_gmc.cpp", MAME_DIR .. "src/devices/bus/coco/coco_gmc.h", + MAME_DIR .. "src/devices/bus/coco/coco_max.cpp", + MAME_DIR .. "src/devices/bus/coco/coco_max.h", MAME_DIR .. "src/devices/bus/coco/coco_midi.cpp", MAME_DIR .. "src/devices/bus/coco/coco_midi.h", MAME_DIR .. "src/devices/bus/coco/coco_multi.cpp", diff --git a/src/devices/bus/coco/coco_max.cpp b/src/devices/bus/coco/coco_max.cpp new file mode 100644 index 00000000000..82103e531d9 --- /dev/null +++ b/src/devices/bus/coco/coco_max.cpp @@ -0,0 +1,172 @@ +// license:BSD-3-Clause +// copyright-holders:tim lindner +/*************************************************************************** + + coco_max.cpp + + Code for emulating CoCo Max Hi-Res Input Module + +***************************************************************************/ + +#include "emu.h" +#include "coco_max.h" + +#include "machine/ram.h" + +#define MOUSE_SENSITIVITY 75 +#define COCOMAX_X_TAG "cocomax_x" +#define COCOMAX_Y_TAG "cocomax_y" +#define COCOMAX_BUTTONS "cocomax_buttons" + +// #define VERBOSE (LOG_GENERAL ) +#include "logmacro.h" + +//------------------------------------------------- +// INPUT_PORTS( cocomax_mouse ) +//------------------------------------------------- + +INPUT_PORTS_START( cocomax_mouse ) + PORT_START(COCOMAX_X_TAG) + PORT_BIT( 0xff, 0x00, IPT_AD_STICK_X) PORT_NAME("CoCo Max Mouse X") PORT_SENSITIVITY(MOUSE_SENSITIVITY) PORT_MINMAX(0x00,0xff) PORT_PLAYER(1) + PORT_START(COCOMAX_Y_TAG) + PORT_BIT( 0xff, 0x00, IPT_AD_STICK_Y) PORT_NAME("CoCo Max Mouse Y") PORT_SENSITIVITY(MOUSE_SENSITIVITY) PORT_MINMAX(0x00,0xff) PORT_PLAYER(1) + PORT_START(COCOMAX_BUTTONS) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("CoCo Max Left Button") PORT_CODE(KEYCODE_0_PAD) PORT_CODE(MOUSECODE_BUTTON1) PORT_PLAYER(1) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("CoCo Max Right Button") PORT_CODE(KEYCODE_DEL_PAD) PORT_CODE(MOUSECODE_BUTTON2) PORT_PLAYER(1) +INPUT_PORTS_END + +//************************************************************************** +// TYPE DECLARATIONS +//************************************************************************** + +namespace +{ + // ======================> coco_pak_device + + class coco_pak_max_device : + public device_t, + public device_cococart_interface + { + public: + // construction/destruction + coco_pak_max_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + virtual ioport_constructor device_input_ports() const override; + + u8 ff90_read(offs_t offset); + + private: + required_ioport m_mouse_x; + required_ioport m_mouse_y; + required_ioport m_buttons; + + uint8_t m_a2d_result; + }; +}; + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +DEFINE_DEVICE_TYPE_PRIVATE(COCO_PAK_MAX, device_cococart_interface, coco_pak_max_device, "cocopakmax", "CoCo Max HI-RES input module") + + + +//------------------------------------------------- +// coco_pak_device - constructor +//------------------------------------------------- + +coco_pak_max_device::coco_pak_max_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, COCO_PAK_MAX, tag, owner, clock) + , device_cococart_interface(mconfig, *this) + , m_mouse_x(*this, COCOMAX_X_TAG) + , m_mouse_y(*this, COCOMAX_Y_TAG) + , m_buttons(*this, COCOMAX_BUTTONS) + , m_a2d_result(0) +{ +} + + + +ioport_constructor coco_pak_max_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(cocomax_mouse); +} + + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void coco_pak_max_device::device_start() +{ + // initial state + m_a2d_result = 0; + + // save state + save_item(NAME(m_a2d_result)); + + // install $ff90-$ff93 handler + install_read_handler(0xff90, 0xff97, read8sm_delegate(*this, FUNC(coco_pak_max_device::ff90_read))); +} + + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void coco_pak_max_device::device_reset() +{ + m_a2d_result = 0; +} + + + +//------------------------------------------------- +// ff90_read +//------------------------------------------------- + +u8 coco_pak_max_device::ff90_read(offs_t offset) +{ + uint8_t result = m_a2d_result; + + switch (offset & 0x08) + { + case 0: + m_a2d_result = m_mouse_y->read(); + break; + case 1: + m_a2d_result = m_mouse_x->read(); + break; + case 2: + m_a2d_result = BIT(m_buttons->read(), 0) ? 0 : 0xff; + break; + case 3: + m_a2d_result = BIT(m_buttons->read(), 1) ? 0 : 0xff; + break; + case 4: + /* not connected*/ + break; + case 5: + /* not connected*/ + break; + case 6: + /* not connected*/ + break; + case 7: + /* not connected*/ + break; + default: + break; + } + + return result; +} diff --git a/src/devices/bus/coco/coco_max.h b/src/devices/bus/coco/coco_max.h new file mode 100644 index 00000000000..22e592cff25 --- /dev/null +++ b/src/devices/bus/coco/coco_max.h @@ -0,0 +1,14 @@ +// license:BSD-3-Clause +// copyright-holders:tim lindner +#ifndef MAME_BUS_COCO_COCO_MAX_H +#define MAME_BUS_COCO_COCO_MAX_H + +#pragma once + +#include "cococart.h" + +// device type definition +DECLARE_DEVICE_TYPE(COCO_PAK_MAX, device_cococart_interface) + +#endif // MAME_BUS_COCO_COCO_MAX_H + diff --git a/src/devices/bus/coco/cococart.cpp b/src/devices/bus/coco/cococart.cpp index 57e18871716..8f733cd6c6a 100644 --- a/src/devices/bus/coco/cococart.cpp +++ b/src/devices/bus/coco/cococart.cpp @@ -43,6 +43,7 @@ #include "coco_dcmodem.h" #include "coco_fdc.h" #include "coco_gmc.h" +#include "coco_max.h" #include "coco_midi.h" #include "coco_multi.h" #include "coco_orch90.h" @@ -699,6 +700,7 @@ void coco_cart_add_basic_devices(device_slot_interface &device) device.option_add("ccpsg", COCO_PSG); device.option_add("dcmodem", COCO_DCMODEM); device.option_add("gmc", COCO_PAK_GMC); + device.option_add("max", COCO_PAK_MAX); device.option_add("midi", COCO_MIDI); device.option_add("orch90", COCO_ORCH90); device.option_add("ram", COCO_PAK_RAM); diff --git a/src/mame/drivers/coco12.cpp b/src/mame/drivers/coco12.cpp index 79e8e689682..951800a5690 100644 --- a/src/mame/drivers/coco12.cpp +++ b/src/mame/drivers/coco12.cpp @@ -433,7 +433,7 @@ void coco_state::coco_sound(machine_config &config) void coco_state::coco_floating_map(address_map &map) { map(0x0000, 0xFFFF).r(FUNC(coco_state::floating_bus_r)); - map(0x0000, 0xFFFF).nopw(); /* suppress log warnings */ + map(0x0000, 0xFFFF).nopw(); /* suppress log warnings */ } diff --git a/src/mame/drivers/dragon.cpp b/src/mame/drivers/dragon.cpp index 4e8a1f29148..2b73e06162b 100644 --- a/src/mame/drivers/dragon.cpp +++ b/src/mame/drivers/dragon.cpp @@ -25,6 +25,7 @@ #include "bus/coco/coco_gmc.h" #include "bus/coco/coco_orch90.h" +#include "bus/coco/coco_max.h" #include "bus/coco/coco_midi.h" #include "bus/coco/coco_pak.h" #include "bus/coco/coco_psg.h" @@ -214,6 +215,7 @@ void dragon_cart(device_slot_interface &device) device.option_add("gmc", COCO_PAK_GMC); device.option_add("jcbsnd", DRAGON_JCBSND); device.option_add("jcbspch", DRAGON_JCBSPCH); + device.option_add("max", COCO_PAK_MAX); device.option_add("midi", DRAGON_MIDI); device.option_add("orch90", COCO_ORCH90); device.option_add("pak", COCO_PAK); diff --git a/src/mame/machine/6883sam.cpp b/src/mame/machine/6883sam.cpp index 8e20c5e940d..89ae03b2bc4 100644 --- a/src/mame/machine/6883sam.cpp +++ b/src/mame/machine/6883sam.cpp @@ -57,7 +57,25 @@ // CONSTANTS //************************************************************************** -#define LOG_SAM 0 +#define LOG_FBITS (1U << 1) +#define LOG_VBITS (1U << 2) +#define LOG_PBITS (1U << 3) +#define LOG_TBITS (1U << 4) +#define LOG_MBITS (1U << 5) +#define LOG_RBITS (1U << 6) + +#define VERBOSE (0) +// #define VERBOSE (LOG_FBITS) +// #define VERBOSE (LOG_FBITS | LOG_VBITS | LOG_PBITS | LOG_MBITS | LOG_RBITS) + +#include "logmacro.h" + +#define LOGFBITS(...) LOGMASKED(LOG_FBITS, __VA_ARGS__) +#define LOGVBITS(...) LOGMASKED(LOG_VBITS, __VA_ARGS__) +#define LOGPBITS(...) LOGMASKED(LOG_PBITS, __VA_ARGS__) +#define LOGTBITS(...) LOGMASKED(LOG_TBITS, __VA_ARGS__) +#define LOGMBITS(...) LOGMASKED(LOG_MBITS, __VA_ARGS__) +#define LOGRBITS(...) LOGMASKED(LOG_RBITS, __VA_ARGS__) DEFINE_DEVICE_TYPE(SAM6883, sam6883_device, "sam6883", "MC6883 SAM") @@ -302,16 +320,9 @@ void sam6883_device::update_memory() // 64k mode (dynamic) case SAM_STATE_M1|SAM_STATE_M0: // 64k mode (static) - if (m_sam_state & SAM_STATE_TY) - { - // full 64k RAM - m_counter_mask = 0xFFFF; - } - else - { - // ROM/RAM - m_counter_mask = 0x7FFF; - } + // full 64k RAM or ROM/RAM + // CoCo Max requires these two be treated the same + m_counter_mask = 0xfFFF; break; } } @@ -370,6 +381,54 @@ void sam6883_device::internal_write(offs_t offset, uint8_t data) update_memory(); if (xorval & (SAM_STATE_R1|SAM_STATE_R0)) update_cpu_clock(); + + if( xorval & (SAM_STATE_F6|SAM_STATE_F5|SAM_STATE_F4|SAM_STATE_F3|SAM_STATE_F2|SAM_STATE_F1|SAM_STATE_F0)) + { + /* Video frame buffer address changed */ + LOGFBITS("%s: SAM F Address: $%04x\n", + machine().describe_context(), + display_offset() ); + } + + if( xorval & (SAM_STATE_V0|SAM_STATE_V1|SAM_STATE_V2)) + { + /* Video frame buffer address changed */ + LOGVBITS("%s: SAM V Bits: $%02x\n", + machine().describe_context(), + (m_sam_state & (SAM_STATE_V0|SAM_STATE_V1|SAM_STATE_V2)) ); + } + + if( xorval & (SAM_STATE_P1)) + { + /* Video frame buffer address changed */ + LOGPBITS("%s: SAM P1 Bit: $%02x\n", + machine().describe_context(), + (m_sam_state & (SAM_STATE_P1)) >> 10 ); + } + + if( xorval & (SAM_STATE_TY)) + { + /* Video frame buffer address changed */ + LOGTBITS("%s: SAM TY Bits: $%02x\n", + machine().describe_context(), + (m_sam_state & (SAM_STATE_TY)) >> 15 ); + } + + if( xorval & (SAM_STATE_M0|SAM_STATE_M1)) + { + /* Video frame buffer address changed */ + LOGMBITS("%s: SAM M Bits: $%02x\n", + machine().describe_context(), + (m_sam_state & (SAM_STATE_M0|SAM_STATE_M1)) >> 9 ); + } + + if( xorval & (SAM_STATE_R0|SAM_STATE_R1)) + { + /* Video frame buffer address changed */ + LOGRBITS("%s: SAM R Bits: $%02x\n", + machine().describe_context(), + (m_sam_state & (SAM_STATE_R0|SAM_STATE_R1)) >> 11 ); + } } -- cgit v1.2.3