diff --git a/hash/fmtowns_cd.xml b/hash/fmtowns_cd.xml index b91ff7dfc18..e7d7dea93da 100644 --- a/hash/fmtowns_cd.xml +++ b/hash/fmtowns_cd.xml @@ -1479,7 +1479,7 @@ User/save disks that can be created from the game itself are not included. - + - The 4th Unit 5 - D-Again (Demo) + The 4th Unit 5 - D-Again (demo) 1990 データウエスト (Data West) @@ -1566,7 +1566,7 @@ User/save disks that can be created from the game itself are not included. - + - + - Taito Chase H.Q. (Demo) + Taito Chase H.Q. (demo) 1991 ビング (Ving) @@ -7448,7 +7448,7 @@ User/save disks that can be created from the game itself are not included. --> - Emit Vol. 1 - Toki no Maigo (Demo) + Emit Vol. 1 - Toki no Maigo (demo) 1994 光栄 (Koei) @@ -13244,7 +13244,7 @@ User/save disks that can be created from the game itself are not included. - + - Indiana Jones and the Last Crusade (Pre-Release Version) + Indiana Jones and the Last Crusade (pre-release version) 1990 富士通 (Fujitsu) @@ -17409,7 +17409,7 @@ User/save disks that can be created from the game itself are not included. - + - Megamorph (Demo) + Megamorph (demo) 1994 富士通 (Fujitsu) @@ -22807,7 +22807,7 @@ User/save disks that can be created from the game itself are not included. - + - Psychic Detective Series Vol. 2 - Memories (Demo) + Psychic Detective Series Vol. 2 - Memories (demo) 1989 データウエスト (Data West) @@ -22909,7 +22909,7 @@ User/save disks that can be created from the game itself are not included. - + - + - Psychic Detective Series Vol. 4 - Orgel (Demo) + Psychic Detective Series Vol. 4 - Orgel (demo) 1991 データウエスト (Data West) @@ -23055,7 +23055,7 @@ User/save disks that can be created from the game itself are not included. - + - + - Psychic Detective Series Final - Solitude Gekan (Demo) + Psychic Detective Series Final - Solitude Gekan (demo) 1993 データウエスト (Data West) @@ -25035,13 +25035,13 @@ User/save disks that can be created from the game itself are not included. - + - Sherlock Holmes - Consulting Detective (Demo) + Sherlock Holmes - Consulting Detective (demo) 1990 富士通 (Fujitsu) @@ -25506,7 +25506,7 @@ User/save disks that can be created from the game itself are not included. - + - Super Street Fighter II - The New Challengers (Sample Disc) + Super Street Fighter II - The New Challengers (sample disc) 1994 カプコン (Capcom) diff --git a/hash/pc1512_hdd.xml b/hash/pc1512_hdd.xml index f23c5ac154b..17666630196 100644 --- a/hash/pc1512_hdd.xml +++ b/hash/pc1512_hdd.xml @@ -10,7 +10,7 @@ license:CC0-1.0 1986 Amstrad - + diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index e2e2a6031d9..e7b5a6150ea 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2574,6 +2574,8 @@ if (BUSES["VCS_CTRL"]~=null) then files { MAME_DIR .. "src/devices/bus/vcs_ctrl/ctrl.cpp", MAME_DIR .. "src/devices/bus/vcs_ctrl/ctrl.h", + MAME_DIR .. "src/devices/bus/vcs_ctrl/cx85.cpp", + MAME_DIR .. "src/devices/bus/vcs_ctrl/cx85.h", MAME_DIR .. "src/devices/bus/vcs_ctrl/joystick.cpp", MAME_DIR .. "src/devices/bus/vcs_ctrl/joystick.h", MAME_DIR .. "src/devices/bus/vcs_ctrl/joybooster.cpp", @@ -5540,14 +5542,16 @@ end --------------------------------------------------- -- ---@src/devices/bus/plg100/plg100.h,BUSES["PLG100"] = true +--@src/devices/bus/plg1x0/plg1x0.h,BUSES["PLG1X0"] = true --------------------------------------------------- -if (BUSES["PLG100"]~=null) then +if (BUSES["PLG1X0"]~=null) then files { - MAME_DIR .. "src/devices/bus/plg100/plg100.cpp", - MAME_DIR .. "src/devices/bus/plg100/plg100.h", - MAME_DIR .. "src/devices/bus/plg100/vl.cpp", - MAME_DIR .. "src/devices/bus/plg100/vl.h", + MAME_DIR .. "src/devices/bus/plg1x0/plg1x0.cpp", + MAME_DIR .. "src/devices/bus/plg1x0/plg1x0.h", + MAME_DIR .. "src/devices/bus/plg1x0/plg100-vl.cpp", + MAME_DIR .. "src/devices/bus/plg1x0/plg100-vl.h", + MAME_DIR .. "src/devices/bus/plg1x0/plg150-ap.cpp", + MAME_DIR .. "src/devices/bus/plg1x0/plg150-ap.h", } end diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua index 23f66cd7d5c..8fee43f4ab1 100644 --- a/scripts/src/cpu.lua +++ b/scripts/src/cpu.lua @@ -899,6 +899,14 @@ if CPUS["SH"] then MAME_DIR .. "src/devices/cpu/sh/sh7032.h", MAME_DIR .. "src/devices/cpu/sh/sh7042.cpp", MAME_DIR .. "src/devices/cpu/sh/sh7042.h", + MAME_DIR .. "src/devices/cpu/sh/sh_adc.cpp", + MAME_DIR .. "src/devices/cpu/sh/sh_adc.h", + MAME_DIR .. "src/devices/cpu/sh/sh_cmt.cpp", + MAME_DIR .. "src/devices/cpu/sh/sh_cmt.h", + MAME_DIR .. "src/devices/cpu/sh/sh_intc.cpp", + MAME_DIR .. "src/devices/cpu/sh/sh_intc.h", + MAME_DIR .. "src/devices/cpu/sh/sh_port.cpp", + MAME_DIR .. "src/devices/cpu/sh/sh_port.h", MAME_DIR .. "src/devices/cpu/sh/sh7604_bus.cpp", MAME_DIR .. "src/devices/cpu/sh/sh7604_bus.h", MAME_DIR .. "src/devices/cpu/sh/sh7604_sci.cpp", diff --git a/src/devices/bus/plg100/plg100.cpp b/src/devices/bus/plg100/plg100.cpp deleted file mode 100644 index 80da3152c7c..00000000000 --- a/src/devices/bus/plg100/plg100.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert - -#include "emu.h" -#include "plg100.h" - -#include "vl.h" - -DEFINE_DEVICE_TYPE(PLG100_CONNECTOR, plg100_connector, "plg100_connector", "PLG100 extension connector") - -plg100_connector::plg100_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, PLG100_CONNECTOR, tag, owner, clock), - device_single_card_slot_interface(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), - m_midi_tx(*this) -{ -} - -void plg100_connector::device_start() -{ - save_item(NAME(m_state_system_is_annoying)); -} - -void plg100_connector::midi_rx(int state) -{ - auto card = get_card_device(); - if(card) - card->midi_rx(state); -} - -void plg100_intf(device_slot_interface &device) -{ - device.option_add("vl", PLG100_VL); -} - -device_plg100_interface::device_plg100_interface(const machine_config &mconfig, device_t &device) : - device_interface(device, "plg100"), - m_connector(nullptr) -{ -} - -device_plg100_interface::~device_plg100_interface() -{ -} - -void device_plg100_interface::interface_pre_start() -{ - m_connector = downcast(device().owner()); -} diff --git a/src/devices/bus/plg100/vl.h b/src/devices/bus/plg100/vl.h deleted file mode 100644 index 57e1b520a38..00000000000 --- a/src/devices/bus/plg100/vl.h +++ /dev/null @@ -1,15 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert - -#ifndef MAME_BUS_PLG100_VL_H -#define MAME_BUS_PLG100_VL_H - -// Yamaha PLG100-VL - -#pragma once - -#include "plg100.h" - -DECLARE_DEVICE_TYPE(PLG100_VL, device_plg100_interface) - -#endif // MAME_BUS_PLG100_VL_H diff --git a/src/devices/bus/plg100/vl.cpp b/src/devices/bus/plg1x0/plg100-vl.cpp similarity index 92% rename from src/devices/bus/plg100/vl.cpp rename to src/devices/bus/plg1x0/plg100-vl.cpp index 58a150cbaea..177813052df 100644 --- a/src/devices/bus/plg100/vl.cpp +++ b/src/devices/bus/plg1x0/plg100-vl.cpp @@ -8,14 +8,14 @@ // Build around a h8 for the control and a dsp-v for the synthesis #include "emu.h" -#include "vl.h" +#include "plg100-vl.h" #include "cpu/h8/h83002.h" #include "sound/dspv.h" namespace { -class plg100_vl_device : public device_t, public device_plg100_interface +class plg100_vl_device : public device_t, public device_plg1x0_interface { public: plg100_vl_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -38,7 +38,7 @@ class plg100_vl_device : public device_t, public device_plg100_interface plg100_vl_device::plg100_vl_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, PLG100_VL, tag, owner, clock), - device_plg100_interface(mconfig, *this), + device_plg1x0_interface(mconfig, *this), m_cpu(*this, "cpu"), m_dspv(*this, "dspv") { @@ -93,4 +93,4 @@ const tiny_rom_entry *plg100_vl_device::device_rom_region() const } // anonymous namespace -DEFINE_DEVICE_TYPE_PRIVATE(PLG100_VL, device_plg100_interface, plg100_vl_device, "plg100_vl", "Yamaha PLG100-VL") +DEFINE_DEVICE_TYPE_PRIVATE(PLG100_VL, device_plg1x0_interface, plg100_vl_device, "plg100_vl", "Yamaha PLG100-VL") diff --git a/src/devices/bus/plg1x0/plg100-vl.h b/src/devices/bus/plg1x0/plg100-vl.h new file mode 100644 index 00000000000..6ff3cd48a8f --- /dev/null +++ b/src/devices/bus/plg1x0/plg100-vl.h @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_BUS_PLG1X0_PLG100VL_H +#define MAME_BUS_PLG1X0_PLG100VL_H + +// Yamaha PLG100-VL + +#pragma once + +#include "plg1x0.h" + +DECLARE_DEVICE_TYPE(PLG100_VL, device_plg1x0_interface) + +#endif // MAME_BUS_PLG1X0_PLG100_VL_H diff --git a/src/devices/bus/plg1x0/plg150-ap.cpp b/src/devices/bus/plg1x0/plg150-ap.cpp new file mode 100644 index 00000000000..103e7a2c8c7 --- /dev/null +++ b/src/devices/bus/plg1x0/plg150-ap.cpp @@ -0,0 +1,89 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// Yamaha PLG150-AP + +// Acoustic Piano, a plugin dedicated to a high-quality piano sound + +// Dual SWX00 + +#include "emu.h" +#include "plg150-ap.h" + +#include "cpu/h8/swx00.h" + +namespace { + +class plg150_ap_device : public device_t, public device_plg1x0_interface +{ +public: + plg150_ap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + virtual ~plg150_ap_device(); + + virtual void midi_rx(int state) override; + +protected: + virtual void device_start() override; + virtual void device_reset() override; + const tiny_rom_entry *device_rom_region() const override; + virtual void device_add_mconfig(machine_config &config) override; + +private: + required_device m_cpu; + + void map(address_map &map); +}; + +plg150_ap_device::plg150_ap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, PLG150_AP, tag, owner, clock), + device_plg1x0_interface(mconfig, *this), + m_cpu(*this, "cpu") +{ +} + +plg150_ap_device::~plg150_ap_device() +{ +} + +void plg150_ap_device::midi_rx(int state) +{ + m_cpu->sci_rx_w<1>(state); +} + +void plg150_ap_device::map(address_map &map) +{ + map(0x000000, 0x07ffff).rom().region("cpu", 0); +} + +void plg150_ap_device::device_add_mconfig(machine_config &config) +{ + SWX00(config, m_cpu, 8.4672_MHz_XTAL, 1); + m_cpu->set_addrmap(AS_PROGRAM, &plg150_ap_device::map); + m_cpu->write_sci_tx<1>().set([this] (int state) { m_connector->do_midi_tx(state); }); +} + +ROM_START( plg150_ap ) + ROM_REGION( 0x80000, "cpu", 0 ) + ROM_LOAD16_WORD_SWAP( "x5757b0.ic03", 0x00000, 0x80000, CRC(5383b363) SHA1(b8e8e0673439c80dc9aecd6638f1c20454c82080) ) + + ROM_REGION( 0x1000000, "swx00", 0 ) + ROM_LOAD( "x575810.ic09", 0x000000, 0x800000, CRC(273b4574) SHA1(b33d67f7fe3a020c19133cc52bd6a228227941c5) ) + ROM_LOAD( "x575910.ic11", 0x800000, 0x800000, CRC(32a37ef3) SHA1(c0b5dfb1fbb5a3ddd33e6303039fbc197478abd2) ) +ROM_END + +void plg150_ap_device::device_start() +{ +} + +void plg150_ap_device::device_reset() +{ +} + +const tiny_rom_entry *plg150_ap_device::device_rom_region() const +{ + return ROM_NAME(plg150_ap); +} + +} // anonymous namespace + +DEFINE_DEVICE_TYPE_PRIVATE(PLG150_AP, device_plg1x0_interface, plg150_ap_device, "plg150_ap", "Yamaha PLG150-AP") diff --git a/src/devices/bus/plg1x0/plg150-ap.h b/src/devices/bus/plg1x0/plg150-ap.h new file mode 100644 index 00000000000..8e56ed6061c --- /dev/null +++ b/src/devices/bus/plg1x0/plg150-ap.h @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_BUS_PLG1X0_PLG150AP_H +#define MAME_BUS_PLG1X0_PLG150AP_H + +// Yamaha PLG150-AP + +#pragma once + +#include "plg1x0.h" + +DECLARE_DEVICE_TYPE(PLG150_AP, device_plg1x0_interface) + +#endif // MAME_BUS_PLG1X0_PLG150_AP_H diff --git a/src/devices/bus/plg1x0/plg1x0.cpp b/src/devices/bus/plg1x0/plg1x0.cpp new file mode 100644 index 00000000000..6abd5100209 --- /dev/null +++ b/src/devices/bus/plg1x0/plg1x0.cpp @@ -0,0 +1,51 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "plg1x0.h" + +#include "plg100-vl.h" +#include "plg150-ap.h" + +DEFINE_DEVICE_TYPE(PLG1X0_CONNECTOR, plg1x0_connector, "plg1x0_connector", "PLG1x0 extension connector") + +plg1x0_connector::plg1x0_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, PLG1X0_CONNECTOR, tag, owner, clock), + device_single_card_slot_interface(mconfig, *this), + device_mixer_interface(mconfig, *this, 2), + m_midi_tx(*this) +{ +} + +void plg1x0_connector::device_start() +{ + save_item(NAME(m_state_system_is_annoying)); +} + +void plg1x0_connector::midi_rx(int state) +{ + auto card = get_card_device(); + if(card) + card->midi_rx(state); +} + +void plg1x0_intf(device_slot_interface &device) +{ + device.option_add("plg100vl", PLG100_VL); + device.option_add("plg150ap", PLG150_AP); +} + +device_plg1x0_interface::device_plg1x0_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "plg1x0"), + m_connector(nullptr) +{ +} + +device_plg1x0_interface::~device_plg1x0_interface() +{ +} + +void device_plg1x0_interface::interface_pre_start() +{ + m_connector = downcast(device().owner()); +} diff --git a/src/devices/bus/plg100/plg100.h b/src/devices/bus/plg1x0/plg1x0.h similarity index 53% rename from src/devices/bus/plg100/plg100.h rename to src/devices/bus/plg1x0/plg1x0.h index 18864f7e2df..8c049c215d5 100644 --- a/src/devices/bus/plg100/plg100.h +++ b/src/devices/bus/plg1x0/plg1x0.h @@ -5,6 +5,9 @@ // MU series of expanders. It mostly provides two midi-rate (and midi // protocol) serial lines (in and out) and two stereo serial sample // streams (in and out too). +// +// The PLG150 series, the successor, seems essentially compatible. +// The main difference is (in some cases) nvram to save settings. // Known existing cards: // PLG100-DX: DX7 as a plugin @@ -12,20 +15,29 @@ // PLG100-VH: Voice Harmonizer, harmony effects on the A/D inputs // PLG100-VL: Virtual Acoustic Synthesis, physical-modelling synthesis, a VL70-m on a plugin card // PLG100-XG: MU50 as a plugin +// +// PLG150-AN: Analog Physical Modeling +// PLG150-AP: Acoustic Piano +// PLG150-DR: Drums +// PLG150-DX: DX7 as a plugin +// PLG150-PC: Latin drums +// PLG150-PF: Piano +// PLG150-VL: Virtual Acoustic Synthesis -#ifndef MAME_BUS_PLG100_PLG100_H -#define MAME_BUS_PLG100_PLG100_H + +#ifndef MAME_BUS_PLG1X0_PLG1X0_H +#define MAME_BUS_PLG1X0_PLG1X0_H #pragma once -class device_plg100_interface; +class device_plg1x0_interface; -class plg100_connector: public device_t, public device_single_card_slot_interface, public device_mixer_interface +class plg1x0_connector: public device_t, public device_single_card_slot_interface, public device_mixer_interface { public: template - plg100_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) - : plg100_connector(mconfig, tag, owner, (uint32_t)0) + plg1x0_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : plg1x0_connector(mconfig, tag, owner, (uint32_t)0) { option_reset(); opts(*this); @@ -33,7 +45,7 @@ class plg100_connector: public device_t, public device_single_card_slot_interfac set_fixed(false); } - plg100_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + plg1x0_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); void midi_rx(int state); auto midi_tx() { return m_midi_tx.bind(); } @@ -47,24 +59,24 @@ class plg100_connector: public device_t, public device_single_card_slot_interfac virtual void device_start() override; }; -class device_plg100_interface: public device_interface +class device_plg1x0_interface: public device_interface { public: - virtual ~device_plg100_interface(); + virtual ~device_plg1x0_interface(); virtual void midi_rx(int state) = 0; protected: - plg100_connector *m_connector; + plg1x0_connector *m_connector; - device_plg100_interface(const machine_config &mconfig, device_t &device); + device_plg1x0_interface(const machine_config &mconfig, device_t &device); virtual void interface_pre_start() override; }; -DECLARE_DEVICE_TYPE(PLG100_CONNECTOR, plg100_connector) +DECLARE_DEVICE_TYPE(PLG1X0_CONNECTOR, plg1x0_connector) -void plg100_intf(device_slot_interface &device); +void plg1x0_intf(device_slot_interface &device); -#endif // MAME_BUS_PLG100_PLG100_H +#endif // MAME_BUS_PLG1X0_PLG1X0_H diff --git a/src/devices/bus/vcs_ctrl/ctrl.cpp b/src/devices/bus/vcs_ctrl/ctrl.cpp index 2ff11e88040..0ddccd7f2ed 100644 --- a/src/devices/bus/vcs_ctrl/ctrl.cpp +++ b/src/devices/bus/vcs_ctrl/ctrl.cpp @@ -65,6 +65,7 @@ void vcs_control_port_device::device_start() // SLOT_INTERFACE( vcs_control_port_devices ) //------------------------------------------------- +#include "cx85.h" #include "joybooster.h" #include "joystick.h" #include "keypad.h" @@ -88,4 +89,6 @@ void a800_control_port_devices(device_slot_interface &device) { vcs_control_port_devices(device); device.set_option_machine_config("pad", &vcs_paddles_device::reverse_players); + + device.option_add("cx85", ATARI_CX85); } diff --git a/src/devices/bus/vcs_ctrl/cx85.cpp b/src/devices/bus/vcs_ctrl/cx85.cpp new file mode 100644 index 00000000000..6f987a99250 --- /dev/null +++ b/src/devices/bus/vcs_ctrl/cx85.cpp @@ -0,0 +1,123 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/********************************************************************** + + Atari CX85 Numeric Keypad + +**********************************************************************/ + +#include "emu.h" +#include "cx85.h" + +#include "machine/rescap.h" + + +//************************************************************************** +// DEVICE TYPE DEFINITION +//************************************************************************** + +DEFINE_DEVICE_TYPE(ATARI_CX85, atari_cx85_device, "atari_cx85", "Atari CX85 Numeric Keypad") + + +//************************************************************************** +// INPUT PORTS +//************************************************************************** + +static INPUT_PORTS_START(atari_cx85) + PORT_START("X1") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad -") PORT_CODE(KEYCODE_PLUS_PAD) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 3") PORT_CODE(KEYCODE_3_PAD) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 9") PORT_CODE(KEYCODE_9_PAD) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 6") PORT_CODE(KEYCODE_6_PAD) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED) + + PORT_START("X2") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad + Enter") PORT_CODE(KEYCODE_ENTER_PAD) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 2") PORT_CODE(KEYCODE_2_PAD) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 8") PORT_CODE(KEYCODE_8_PAD) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 5") PORT_CODE(KEYCODE_5_PAD) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED) + + PORT_START("X3") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad .") PORT_CODE(KEYCODE_DEL_PAD) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 1") PORT_CODE(KEYCODE_1_PAD) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 7") PORT_CODE(KEYCODE_7_PAD) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 4") PORT_CODE(KEYCODE_4_PAD) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED) + + PORT_START("X4") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad 0") PORT_CODE(KEYCODE_0_PAD) + PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F4 (Yes)") PORT_CODE(KEYCODE_MINUS_PAD) + PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F2 (No)") PORT_CODE(KEYCODE_SLASH_PAD) + PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F3 (Delete)") PORT_CODE(KEYCODE_ASTERISK) + PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYPAD) PORT_NAME("Keypad F1 (Escape)") PORT_CODE(KEYCODE_NUMLOCK) +INPUT_PORTS_END + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// atari_cx85_device - constructor +//------------------------------------------------- + +atari_cx85_device::atari_cx85_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, ATARI_CX85, tag, owner, clock) + , device_vcs_control_port_interface(mconfig, *this) + , m_encoder(*this, "encoder") +{ +} + +//------------------------------------------------- +// device_add_mconfig - add device configuration +//------------------------------------------------- + +void atari_cx85_device::device_add_mconfig(machine_config &config) +{ + MM74C923(config, m_encoder, 0); // MCM74C923N + m_encoder->set_cap_osc(CAP_U(.1)); + m_encoder->set_cap_debounce(CAP_U(.47)); + m_encoder->data_tri_callback().set_constant(0); + m_encoder->x1_rd_callback().set_ioport("X1"); + m_encoder->x2_rd_callback().set_ioport("X2"); + m_encoder->x3_rd_callback().set_ioport("X3"); + m_encoder->x4_rd_callback().set_ioport("X4"); + m_encoder->da_wr_callback().set(FUNC(atari_cx85_device::trigger_w)).invert(); +} + +//------------------------------------------------- +// device_input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor atari_cx85_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(atari_cx85); +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void atari_cx85_device::device_start() +{ +} + +//------------------------------------------------- +// vcs_joy_r - read digital inputs +//------------------------------------------------- + +u8 atari_cx85_device::vcs_joy_r() +{ + // 74C923 outputs are buffered through 4049B + return (~m_encoder->read() & 0x0f) | (m_encoder->da_r() ? 0 : 0x20); +} + +//------------------------------------------------- +// vcs_pot_x_r - sample B pot +//------------------------------------------------- + +u8 atari_cx85_device::vcs_pot_x_r() +{ + return BIT(m_encoder->read(), 4) ? 0 : 0xff; +} diff --git a/src/devices/bus/vcs_ctrl/cx85.h b/src/devices/bus/vcs_ctrl/cx85.h new file mode 100644 index 00000000000..32fca503a9f --- /dev/null +++ b/src/devices/bus/vcs_ctrl/cx85.h @@ -0,0 +1,54 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/********************************************************************** + + Atari CX85 Numeric Keypad + +**********************************************************************/ + +#ifndef MAME_BUS_VCS_CTRL_CX85_H +#define MAME_BUS_VCS_CTRL_CX85_H + +#pragma once + +#include "ctrl.h" +#include "machine/mm74c922.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> atari_cx85_device + +class atari_cx85_device : public device_t, + public device_vcs_control_port_interface +{ +public: + // construction/destruction + atari_cx85_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_add_mconfig(machine_config &config) override; + + // optional information overrides + virtual ioport_constructor device_input_ports() const override; + + // device_vcs_control_port_interface overrides + virtual u8 vcs_joy_r() override; + virtual u8 vcs_pot_x_r() override; + + virtual bool has_pot_x() override { return true; } + virtual bool has_pot_y() override { return false; } // pin 9 not used + +private: + required_device m_encoder; +}; + + +// device type declaration +DECLARE_DEVICE_TYPE(ATARI_CX85, atari_cx85_device) + +#endif // MAME_BUS_VCS_CTRL_CX85_H diff --git a/src/devices/cpu/h8/h83217.h b/src/devices/cpu/h8/h83217.h index 9a6195aaf50..aba652de119 100644 --- a/src/devices/cpu/h8/h83217.h +++ b/src/devices/cpu/h8/h83217.h @@ -8,7 +8,7 @@ H8-300-based mcus. - Variant ROM RAM + Variant ROM RAM H8/3217 60K 2K H8/3216 48K 2K H8/3214 32K 1K diff --git a/src/devices/cpu/h8/h8325.h b/src/devices/cpu/h8/h8325.h index c046208b014..43c3a575ad6 100644 --- a/src/devices/cpu/h8/h8325.h +++ b/src/devices/cpu/h8/h8325.h @@ -8,7 +8,7 @@ H8-300-based mcus. - Variant ROM RAM + Variant ROM RAM H8/3257 60K 2K H8/3256 48K 2K H8/325 32K 1K diff --git a/src/devices/cpu/h8/h8_adc.cpp b/src/devices/cpu/h8/h8_adc.cpp index bab8bc6aa37..e88a0f015d2 100644 --- a/src/devices/cpu/h8/h8_adc.cpp +++ b/src/devices/cpu/h8/h8_adc.cpp @@ -368,12 +368,12 @@ int h8_adc_2320_device::conversion_time(bool first, bool poweron) { int tm; if(first) - if(m_adcr & 0x04) + if(m_adcr & 0x08) tm = m_adcsr & 0x08 ? 134 : 266; else - tm = m_adcsr & 0x08 ? 68 : 580; + tm = m_adcsr & 0x08 ? 68 : 530; else - if(m_adcr & 0x04) + if(m_adcr & 0x08) tm = m_adcsr & 0x08 ? 128 : 256; else tm = m_adcsr & 0x08 ? 64 : 512; diff --git a/src/devices/cpu/h8/h8_adc.h b/src/devices/cpu/h8/h8_adc.h index bb180703c64..8155f5bcd1d 100644 --- a/src/devices/cpu/h8/h8_adc.h +++ b/src/devices/cpu/h8/h8_adc.h @@ -19,7 +19,11 @@ class h8_adc_device : public device_t { public: - template void set_info(T &&cpu, U &&intc, int vect) { m_cpu.set_tag(std::forward(cpu)), m_intc.set_tag(std::forward(intc)); m_intc_vector = vect; } + template void set_info(T &&cpu, U &&intc, int vect) { + m_cpu.set_tag(std::forward(cpu)); + m_intc.set_tag(std::forward(intc)); + m_intc_vector = vect; + } u8 addr8_r(offs_t offset); u16 addr16_r(offs_t offset); diff --git a/src/devices/cpu/h8/h8_intc.cpp b/src/devices/cpu/h8/h8_intc.cpp index c84a0faa4a4..f599f5e93db 100644 --- a/src/devices/cpu/h8/h8_intc.cpp +++ b/src/devices/cpu/h8/h8_intc.cpp @@ -305,16 +305,6 @@ void h8h_intc_device::icr_w(offs_t offset, u8 data) logerror("icr %d = %02x\n", offset, data); } -u8 h8h_intc_device::icrc_r() -{ - return icr_r(2); -} - -void h8h_intc_device::icrc_w(u8 data) -{ - icr_w(2, data); -} - const int h8h_intc_device::vector_to_slot[64] = { -1, -1, -1, -1, -1, -1, -1, -1, // NMI at 7 -1, -1, -1, -1, 0, 1, 2, 2, // IRQ 0-3 @@ -371,16 +361,6 @@ void h8s_intc_device::ipr_w(offs_t offset, u8 data) logerror("ipr %d = %02x\n", offset, data); } -u8 h8s_intc_device::iprk_r() -{ - return ipr_r(10); -} - -void h8s_intc_device::iprk_w(u8 data) -{ - ipr_w(10, data); -} - u8 h8s_intc_device::iscrh_r() { return m_iscr >> 8; diff --git a/src/devices/cpu/h8/h8_intc.h b/src/devices/cpu/h8/h8_intc.h index 424137d7614..15fe2952f5f 100644 --- a/src/devices/cpu/h8/h8_intc.h +++ b/src/devices/cpu/h8/h8_intc.h @@ -98,8 +98,6 @@ class h8h_intc_device : public h8_intc_device { void isr_w(u8 data); u8 icr_r(offs_t offset); void icr_w(offs_t offset, u8 data); - u8 icrc_r(); - void icrc_w(u8 data); protected: static const int vector_to_slot[]; @@ -125,8 +123,6 @@ class h8s_intc_device : public h8h_intc_device { u8 ipr_r(offs_t offset); void ipr_w(offs_t offset, u8 data); - u8 iprk_r(); - void iprk_w(u8 data); u8 iscrh_r(); void iscrh_w(u8 data); u8 iscrl_r(); diff --git a/src/devices/cpu/h8/h8_timer16.cpp b/src/devices/cpu/h8/h8_timer16.cpp index f5c16c6f691..059cb8b9a39 100644 --- a/src/devices/cpu/h8/h8_timer16.cpp +++ b/src/devices/cpu/h8/h8_timer16.cpp @@ -238,6 +238,7 @@ void h8_timer16_channel_device::update_counter(u64 cur_time) } u64 base_time = m_last_clock_update; + m_last_clock_update = cur_time; u64 new_time = cur_time; if(m_clock_divider) { base_time = (base_time + m_phase) >> m_clock_divider; @@ -289,7 +290,6 @@ void h8_timer16_channel_device::update_counter(u64 cur_time) logerror("decrementing counter\n"); exit(1); } - m_last_clock_update = cur_time; } void h8_timer16_channel_device::recalc_event(u64 cur_time) diff --git a/src/devices/cpu/h8/h8_timer8.cpp b/src/devices/cpu/h8/h8_timer8.cpp index af0e1a27859..fe458e0922b 100644 --- a/src/devices/cpu/h8/h8_timer8.cpp +++ b/src/devices/cpu/h8/h8_timer8.cpp @@ -212,21 +212,22 @@ u64 h8_timer8_channel_device::internal_update(u64 current_time) return m_event_time; } -void h8_timer8_channel_device::update_counter(u64 cur_time) +void h8_timer8_channel_device::update_counter(u64 cur_time, u64 delta) { - if(m_clock_type != DIV) - return; - - if(!cur_time) - cur_time = m_cpu->total_cycles(); + if(m_clock_type == DIV) { + if(!cur_time) + cur_time = m_cpu->total_cycles(); + + u64 base_time = (m_last_clock_update + m_clock_divider/2) / m_clock_divider; + m_last_clock_update = cur_time; + u64 new_time = (cur_time + m_clock_divider/2) / m_clock_divider; + delta = new_time - base_time; + } - u64 base_time = (m_last_clock_update + m_clock_divider/2) / m_clock_divider; - u64 new_time = (cur_time + m_clock_divider/2) / m_clock_divider; - if(new_time == base_time) + if(!delta) return; u8 prev = m_tcnt; - u64 delta = new_time - base_time; u64 tt = m_tcnt + delta; if(prev >= m_counter_cycle) { @@ -264,7 +265,6 @@ void h8_timer8_channel_device::update_counter(u64 cur_time) m_intc->internal_interrupt(m_irq_v); } } - m_last_clock_update = cur_time; } void h8_timer8_channel_device::recalc_event(u64 cur_time) @@ -317,45 +317,13 @@ void h8_timer8_channel_device::recalc_event(u64 cur_time) void h8_timer8_channel_device::chained_timer_overflow() { if(m_clock_type == CHAIN_OVERFLOW) - timer_tick(); + update_counter(0, 1); } void h8_timer8_channel_device::chained_timer_tcora() { if(m_clock_type == CHAIN_A) - timer_tick(); -} - -void h8_timer8_channel_device::timer_tick() -{ - m_tcnt++; - - if(m_tcnt == m_tcor[0]) { - if(m_chained_timer) - m_chained_timer->chained_timer_tcora(); - - if(!(m_tcsr & TCSR_CMFA)) { - m_tcsr |= TCSR_CMFA; - if(m_tcr & TCR_CMIEA) - m_intc->internal_interrupt(m_irq_ca); - } - } - - if(!(m_tcsr & TCSR_CMFB) && m_tcnt == m_tcor[1]) { - m_tcsr |= TCSR_CMFB; - if(m_tcr & TCR_CMIEB) - m_intc->internal_interrupt(m_irq_cb); - } - - if(m_tcnt == 0x00) { - if(m_chained_timer) - m_chained_timer->chained_timer_overflow(); - if(!(m_tcsr & TCSR_OVF)) { - m_tcsr |= TCSR_OVF; - if(m_tcr & TCR_OVIE) - m_intc->internal_interrupt(m_irq_v); - } - } + update_counter(0, 1); } h8h_timer8_channel_device::h8h_timer8_channel_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : diff --git a/src/devices/cpu/h8/h8_timer8.h b/src/devices/cpu/h8/h8_timer8.h index c5f6dd98f39..c791892a3ce 100644 --- a/src/devices/cpu/h8/h8_timer8.h +++ b/src/devices/cpu/h8/h8_timer8.h @@ -100,10 +100,9 @@ class h8_timer8_channel_device : public device_t { virtual void device_start() override; virtual void device_reset() override; - void update_counter(u64 cur_time = 0); + void update_counter(u64 cur_time = 0, u64 delta = 0); void recalc_event(u64 cur_time = 0); - void timer_tick(); void update_tcr(); }; diff --git a/src/devices/cpu/h8/h8s2245.cpp b/src/devices/cpu/h8/h8s2245.cpp index fe93cbca226..f03e2d77a92 100644 --- a/src/devices/cpu/h8/h8s2245.cpp +++ b/src/devices/cpu/h8/h8s2245.cpp @@ -73,8 +73,7 @@ void h8s2245_device::map(address_map &map) map(0xfffebd, 0xfffebd).w(m_porte, FUNC(h8_port_device::ddr_w)); map(0xfffebe, 0xfffebe).w(m_portf, FUNC(h8_port_device::ddr_w)); map(0xfffebf, 0xfffebf).w(m_portg, FUNC(h8_port_device::ddr_w)); - map(0xfffec0, 0xfffec1).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); - map(0xfffec2, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icrc_r), FUNC(h8s_intc_device::icrc_w)); + map(0xfffec0, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); map(0xffff2c, 0xffff2c).rw(m_intc, FUNC(h8s_intc_device::iscrh_r), FUNC(h8s_intc_device::iscrh_w)); map(0xffff2d, 0xffff2d).rw(m_intc, FUNC(h8s_intc_device::iscrl_r), FUNC(h8s_intc_device::iscrl_w)); map(0xffff2e, 0xffff2e).rw(m_intc, FUNC(h8s_intc_device::ier_r), FUNC(h8s_intc_device::ier_w)); diff --git a/src/devices/cpu/h8/h8s2320.cpp b/src/devices/cpu/h8/h8s2320.cpp index b853310a79e..8b22d7ebd9c 100644 --- a/src/devices/cpu/h8/h8s2320.cpp +++ b/src/devices/cpu/h8/h8s2320.cpp @@ -133,10 +133,7 @@ void h8s2320_device::map(address_map &map) map(0xfffebd, 0xfffebd).w(m_porte, FUNC(h8_port_device::ddr_w)); map(0xfffebe, 0xfffebe).w(m_portf, FUNC(h8_port_device::ddr_w)); map(0xfffebf, 0xfffebf).w(m_portg, FUNC(h8_port_device::ddr_w)); - map(0xfffec0, 0xfffec1).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); - map(0xfffec2, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icrc_r), FUNC(h8s_intc_device::icrc_w)); - map(0xfffec4, 0xfffecd).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); - map(0xfffece, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w)); + map(0xfffec4, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); if(type() != H8S2321) { map(0xfffee0, 0xfffee1).rw(m_dma0, FUNC(h8s_dma_channel_device::marah_r), FUNC(h8s_dma_channel_device::marah_w)); diff --git a/src/devices/cpu/h8/h8s2357.cpp b/src/devices/cpu/h8/h8s2357.cpp index b8378575c84..73a9a8f06ea 100644 --- a/src/devices/cpu/h8/h8s2357.cpp +++ b/src/devices/cpu/h8/h8s2357.cpp @@ -111,8 +111,7 @@ void h8s2357_device::map(address_map &map) map(0xfffebd, 0xfffebd).w(m_porte, FUNC(h8_port_device::ddr_w)); map(0xfffebe, 0xfffebe).w(m_portf, FUNC(h8_port_device::ddr_w)); map(0xfffebf, 0xfffebf).w(m_portg, FUNC(h8_port_device::ddr_w)); - map(0xfffec4, 0xfffecd).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); - map(0xfffece, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w)); + map(0xfffec4, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); map(0xfffee0, 0xfffee1).rw(m_dma0, FUNC(h8s_dma_channel_device::marah_r), FUNC(h8s_dma_channel_device::marah_w)); map(0xfffee2, 0xfffee3).rw(m_dma0, FUNC(h8s_dma_channel_device::maral_r), FUNC(h8s_dma_channel_device::maral_w)); map(0xfffee4, 0xfffee5).rw(m_dma0, FUNC(h8s_dma_channel_device::ioara_r), FUNC(h8s_dma_channel_device::ioara_w)); diff --git a/src/devices/cpu/h8/h8s2655.cpp b/src/devices/cpu/h8/h8s2655.cpp index 54a644ded06..ba2423ce859 100644 --- a/src/devices/cpu/h8/h8s2655.cpp +++ b/src/devices/cpu/h8/h8s2655.cpp @@ -88,10 +88,8 @@ void h8s2655_device::map(address_map &map) map(0xfffebd, 0xfffebd).w(m_porte, FUNC(h8_port_device::ddr_w)); map(0xfffebe, 0xfffebe).w(m_portf, FUNC(h8_port_device::ddr_w)); map(0xfffebf, 0xfffebf).w(m_portg, FUNC(h8_port_device::ddr_w)); - map(0xfffec0, 0xfffec1).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); - map(0xfffec2, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icrc_r), FUNC(h8s_intc_device::icrc_w)); - map(0xfffec4, 0xfffecd).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); - map(0xfffece, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w)); + map(0xfffec0, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); + map(0xfffec4, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); map(0xfffee0, 0xfffee1).rw(m_dma0, FUNC(h8s_dma_channel_device::marah_r), FUNC(h8s_dma_channel_device::marah_w)); map(0xfffee2, 0xfffee3).rw(m_dma0, FUNC(h8s_dma_channel_device::maral_r), FUNC(h8s_dma_channel_device::maral_w)); diff --git a/src/devices/cpu/h8/swx00.cpp b/src/devices/cpu/h8/swx00.cpp index c65a10e301c..7ddb1c85f10 100644 --- a/src/devices/cpu/h8/swx00.cpp +++ b/src/devices/cpu/h8/swx00.cpp @@ -81,10 +81,8 @@ void swx00_device::map(address_map &map) map(0xfffebd, 0xfffebd).w(m_porte, FUNC(h8_port_device::ddr_w)); map(0xfffebe, 0xfffebe).w(m_portf, FUNC(h8_port_device::ddr_w)); map(0xfffebf, 0xfffebf).w(m_portg, FUNC(h8_port_device::ddr_w)); - map(0xfffec0, 0xfffec1).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); - map(0xfffec2, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icrc_r), FUNC(h8s_intc_device::icrc_w)); - map(0xfffec4, 0xfffecd).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); - map(0xfffece, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::iprk_r), FUNC(h8s_intc_device::iprk_w)); + map(0xfffec0, 0xfffec2).rw(m_intc, FUNC(h8s_intc_device::icr_r), FUNC(h8s_intc_device::icr_w)); + map(0xfffec4, 0xfffece).rw(m_intc, FUNC(h8s_intc_device::ipr_r), FUNC(h8s_intc_device::ipr_w)); map(0xfffee0, 0xfffee1).rw(m_dma0, FUNC(h8s_dma_channel_device::marah_r), FUNC(h8s_dma_channel_device::marah_w)); map(0xfffee2, 0xfffee3).rw(m_dma0, FUNC(h8s_dma_channel_device::maral_r), FUNC(h8s_dma_channel_device::maral_w)); diff --git a/src/devices/cpu/hcd62121/hcd62121.cpp b/src/devices/cpu/hcd62121/hcd62121.cpp index 00faac4f7a2..67d5452ebb2 100644 --- a/src/devices/cpu/hcd62121/hcd62121.cpp +++ b/src/devices/cpu/hcd62121/hcd62121.cpp @@ -61,6 +61,7 @@ hcd62121_cpu_device::hcd62121_cpu_device(const machine_config &mconfig, const ch , m_dseg(0) , m_sseg(0) , m_f(0) + , m_time(0) , m_lar(0) , m_opt(0) , m_port(0) @@ -1443,11 +1444,18 @@ void hcd62121_cpu_device::execute_run() break; case 0xB1: /* unk_B1 reg/i8 - PORTx control/direction? */ - case 0xB3: /* unk_B3 reg/i8 - timer/irq related? */ logerror("%02x:%04x: unimplemented instruction %02x encountered\n", m_cseg, m_ip-1, op); read_op(); break; + case 0xB3: /* timer_set i8 */ + { + u8 arg = read_op(); + + m_time = arg; + } + break; + case 0xB4: /* out koh,reg */ m_koh_cb(m_reg[read_op() & 0x7f]); break; @@ -1710,6 +1718,15 @@ void hcd62121_cpu_device::execute_run() } break; + case 0xEA: /* movw reg,pc */ + { + u8 reg1 = read_op(); + + m_reg[reg1 & 0x7f] = m_ip & 0xff; + m_reg[(reg1 + 1) & 0x7f] = m_ip >> 8; + } + break; + case 0xEB: /* movw reg,sp */ { u8 reg1 = read_op(); @@ -1719,6 +1736,14 @@ void hcd62121_cpu_device::execute_run() } break; + case 0xED: /* movb reg,ds */ + m_reg[read_op() & 0x7f] = m_dseg; + break; + + case 0xEE: /* movb reg,cs */ + m_reg[read_op() & 0x7f] = m_cseg; + break; + case 0xEF: /* movb reg,ss */ m_reg[read_op() & 0x7f] = m_sseg; break; @@ -1736,20 +1761,164 @@ void hcd62121_cpu_device::execute_run() case 0xF1: /* unk_F1 reg/i8 (out?) */ case 0xF3: /* unk_F3 reg/i8 (out?) */ case 0xF5: /* unk_F5 reg/i8 (out?) */ - case 0xF7: /* unk_F7 reg/i8 (out?) */ + case 0xF7: /* timer_ctrl i8 */ logerror("%02x:%04x: unimplemented instruction %02x encountered\n", m_cseg, m_ip-1, op); read_op(); break; case 0xFC: /* unk_FC - disable interrupts/stop timer?? */ case 0xFD: /* unk_FD */ - case 0xFE: /* unk_FE - wait for/start timer */ - if (op == 0xFE) - m_icount -= 75000; // TODO: temporary value that makes emulation speed acceptable - logerror("%02x:%04x: unimplemented instruction %02x encountered\n", m_cseg, m_ip-1, op); break; + case 0xFE: /* timer_wait */ + if (m_time & 0x01) { + /* + When timer control is set with operand 0xC0, the CPU periodically reads + from external RAM (address range 0x7c00..0x7fff) at an interval of + 832 clock cycles, with the reads themselves taking another 64 clock cycles. + This needs to be explicitly setup, involving writes to unknown segments + 0x11 and 0xE1 (see cfx9850.bin @ 00:00fe), otherwise there's only activity + on address lines without any reads. + + The total sum of these state reads can be approximated to the closest + power of two to define timeout values. Multiple samples were averaged, + as the state read interval can start at a distinct point in time from + the timer wait execution. + */ + const u64 TIMER_STATE_READ_CYCLES = 832 + 64; + u64 cycles_until_timeout = 0; + switch (m_time) { + case 0x11: + case 0x13: + case 0x15: + case 0x17: + case 0x19: + case 0x1b: + case 0x1d: + case 0x1f: + case 0x31: + case 0x33: + case 0x35: + case 0x37: + case 0x39: + case 0x3b: + case 0x3d: + case 0x3f: + case 0x51: + case 0x53: + case 0x55: + case 0x57: + case 0x59: + case 0x5b: + case 0x5d: + case 0x5f: + case 0x71: + case 0x73: + case 0x75: + case 0x77: + case 0x79: + case 0x7b: + case 0x7d: + case 0x7f: + case 0x91: + case 0x93: + case 0x95: + case 0x97: + case 0x99: + case 0x9b: + case 0x9d: + case 0x9f: + case 0xb1: + case 0xb3: + case 0xb5: + case 0xb7: + case 0xb9: + case 0xbb: + case 0xbd: + case 0xbf: + case 0xd1: + case 0xd3: + case 0xd5: + case 0xd7: + case 0xd9: + case 0xdb: + case 0xdd: + case 0xdf: + // Approximately 814.32us + cycles_until_timeout = 0x4 * TIMER_STATE_READ_CYCLES; + break; + case 0x21: + case 0x23: + case 0x25: + case 0x27: + case 0x29: + case 0x2b: + case 0x2d: + case 0x2f: + case 0x61: + case 0x63: + case 0x65: + case 0x67: + case 0x69: + case 0x6b: + case 0x6d: + case 0x6f: + case 0xa1: + case 0xa3: + case 0xa5: + case 0xa7: + case 0xa9: + case 0xab: + case 0xad: + case 0xaf: + // Approximately 1.63ms + cycles_until_timeout = 0x8 * TIMER_STATE_READ_CYCLES; + break; + case 0x05: + case 0x07: + case 0x0d: + case 0x0f: + case 0x45: + case 0x47: + case 0x4d: + case 0x4f: + case 0xc5: + case 0xc7: + case 0xcd: + case 0xcf: + // Approximately 209.34ms + cycles_until_timeout = 0x400 * TIMER_STATE_READ_CYCLES; + break; + case 0x49: + case 0x4b: + case 0xc9: + case 0xcb: + // Approximately 837.61ms + cycles_until_timeout = 0x1000 * TIMER_STATE_READ_CYCLES; + break; + case 0x41: + case 0x43: + case 0xc1: + case 0xc3: + // Approximately 1.68s + cycles_until_timeout = 0x2000 * TIMER_STATE_READ_CYCLES; + break; + case 0x81: + case 0x83: + // Approximately 100.58s + cycles_until_timeout = 0x7a800 * TIMER_STATE_READ_CYCLES; + break; + default: + logerror("%02x:%04x: unimplemented timer value %02x encountered\n", m_cseg, m_ip-1, m_time); + break; + } + m_icount -= cycles_until_timeout; + } else { + logerror("%02x:%04x: wait for disabled timer? value %02x\n", m_cseg, m_ip-1, m_time); + } + break; + case 0xFF: /* nop */ break; diff --git a/src/devices/cpu/hcd62121/hcd62121.h b/src/devices/cpu/hcd62121/hcd62121.h index d7d35a881dd..785a283076a 100644 --- a/src/devices/cpu/hcd62121/hcd62121.h +++ b/src/devices/cpu/hcd62121/hcd62121.h @@ -91,6 +91,7 @@ class hcd62121_cpu_device : public cpu_device u8 m_dseg; u8 m_sseg; u8 m_f; + u8 m_time; u16 m_lar; u8 m_reg[0x80]; diff --git a/src/devices/cpu/sh/sh7042.cpp b/src/devices/cpu/sh/sh7042.cpp index 35f559b47ce..7ef10f19ce1 100644 --- a/src/devices/cpu/sh/sh7042.cpp +++ b/src/devices/cpu/sh/sh7042.cpp @@ -21,13 +21,61 @@ sh7043_device::sh7043_device(const machine_config &mconfig, const char *tag, dev sh7042_device::sh7042_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : sh2_device(mconfig, type, tag, owner, clock, CPU_TYPE_SH2, address_map_constructor(FUNC(sh7042_device::map), this), 32, 0xffffffff), + m_intc(*this, "intc"), + m_adc(*this, "adc"), + m_cmt(*this, "cmt"), + m_porta(*this, "porta"), + m_portb(*this, "portb"), + m_portc(*this, "portc"), + m_portd(*this, "portd"), + m_porte(*this, "porte"), + m_portf(*this, "portf"), m_read_adc(*this, 0), - m_sci_tx(*this) + m_sci_tx(*this), + m_read_port16(*this, 0xffff), + m_write_port16(*this), + m_read_port32(*this, 0xffffffff), + m_write_port32(*this) { + m_port16_names = "bcef"; + m_port32_names = "ad"; for(unsigned int i=0; i != m_read_adc.size(); i++) m_read_adc[i].bind().set([this, i]() { return adc_default(i); }); + for(unsigned int i=0; i != m_read_port16.size(); i++) { + m_read_port16[i].bind().set([this, i]() { return port16_default_r(i); }); + m_write_port16[i].bind().set([this, i](u16 data) { port16_default_w(i, data); }); + } + for(unsigned int i=0; i != m_read_port32.size(); i++) { + m_read_port32[i].bind().set([this, i]() { return port32_default_r(i); }); + m_write_port32[i].bind().set([this, i](u32 data) { port32_default_w(i, data); }); + } } +u16 sh7042_device::port16_default_r(int port) +{ + if(!machine().side_effects_disabled()) + logerror("read of un-hooked port %c\n", m_port16_names[port]); + return 0xffff; +} + +void sh7042_device::port16_default_w(int port, u16 data) +{ + logerror("write of un-hooked port %c %04x\n", m_port16_names[port], data); +} + +u32 sh7042_device::port32_default_r(int port) +{ + if(!machine().side_effects_disabled()) + logerror("read of un-hooked port %c\n", m_port32_names[port]); + return 0xffff; +} + +void sh7042_device::port32_default_w(int port, u32 data) +{ + logerror("write of un-hooked port %c %04x\n", m_port32_names[port], data); +} + + u16 sh7042_device::adc_default(int adc) { logerror("read of un-hooked adc %d\n", adc); @@ -38,70 +86,214 @@ void sh7042_device::device_start() { sh2_device::device_start(); - save_item(NAME(m_addr)); - save_item(NAME(m_adcsr)); - save_item(NAME(m_adcr)); + m_event_timer = timer_alloc(FUNC(sh7042_device::event_timer_tick), this); + + save_item(NAME(m_pcf_ah)); + save_item(NAME(m_pcf_al)); + save_item(NAME(m_pcf_b)); + save_item(NAME(m_pcf_c)); + save_item(NAME(m_pcf_dh)); + save_item(NAME(m_pcf_dl)); + save_item(NAME(m_pcf_e)); + save_item(NAME(m_pcf_if)); + + m_pcf_ah = 0; + m_pcf_al = 0; + m_pcf_b = 0; + m_pcf_c = 0; + m_pcf_dh = 0; + m_pcf_dl = 0; + m_pcf_e = 0; + m_pcf_if = 0; } void sh7042_device::device_reset() { sh2_device::device_reset(); - - memset(m_addr, 0, sizeof(m_addr)); - m_adcsr = m_adcr = 0; } + void sh7042_device::map(address_map &map) { - map(0xffff83e0, 0xffff83e0).rw(FUNC(sh7042_device::adcsr_r), FUNC(sh7042_device::adcsr_w)); - map(0xffff83e1, 0xffff83e1).rw(FUNC(sh7042_device::adcr_r), FUNC(sh7042_device::adcr_w)); - map(0xffff83f0, 0xffff83ff).r(FUNC(sh7042_device::addr_r)); + map(0xffff8348, 0xffff8357).rw(m_intc, FUNC(sh_intc_device::ipr_r), FUNC(sh_intc_device::ipr_w)); + map(0xffff8358, 0xffff8359).rw(m_intc, FUNC(sh_intc_device::icr_r), FUNC(sh_intc_device::icr_w)); + map(0xffff835a, 0xffff835b).rw(m_intc, FUNC(sh_intc_device::isr_r), FUNC(sh_intc_device::isr_w)); + + map(0xffff8380, 0xffff8383).rw(m_porta, FUNC(sh_port32_device::dr_r), FUNC(sh_port32_device::dr_w)); + map(0xffff8384, 0xffff8387).rw(m_porta, FUNC(sh_port32_device::io_r), FUNC(sh_port32_device::io_w)); + map(0xffff8388, 0xffff8389).rw(FUNC(sh7042_device::pcf_ah_r), FUNC(sh7042_device::pcf_ah_w)); + map(0xffff838c, 0xffff838f).rw(FUNC(sh7042_device::pcf_al_r), FUNC(sh7042_device::pcf_al_w)); + map(0xffff8390, 0xffff8391).rw(m_portb, FUNC(sh_port16_device::dr_r), FUNC(sh_port16_device::dr_w)); + map(0xffff8392, 0xffff8393).rw(m_portc, FUNC(sh_port16_device::dr_r), FUNC(sh_port16_device::dr_w)); + map(0xffff8394, 0xffff8395).rw(m_portb, FUNC(sh_port16_device::io_r), FUNC(sh_port16_device::io_w)); + map(0xffff8396, 0xffff8397).rw(m_portc, FUNC(sh_port16_device::io_r), FUNC(sh_port16_device::io_w)); + map(0xffff8398, 0xffff839b).rw(FUNC(sh7042_device::pcf_b_r), FUNC(sh7042_device::pcf_b_w)); + map(0xffff839c, 0xffff839d).rw(FUNC(sh7042_device::pcf_c_r), FUNC(sh7042_device::pcf_c_w)); + map(0xffff83a0, 0xffff83a3).rw(m_portd, FUNC(sh_port32_device::dr_r), FUNC(sh_port32_device::dr_w)); + map(0xffff83a4, 0xffff83a7).rw(m_portd, FUNC(sh_port32_device::io_r), FUNC(sh_port32_device::io_w)); + map(0xffff83a8, 0xffff83ab).rw(FUNC(sh7042_device::pcf_dh_r), FUNC(sh7042_device::pcf_dh_w)); + map(0xffff83ac, 0xffff83ad).rw(FUNC(sh7042_device::pcf_dl_r), FUNC(sh7042_device::pcf_dl_w)); + map(0xffff83b0, 0xffff83b1).rw(m_porte, FUNC(sh_port16_device::dr_r), FUNC(sh_port16_device::dr_w)); + map(0xffff83b2, 0xffff83b3).r (m_portf, FUNC(sh_port16_device::dr_r)); + map(0xffff83b4, 0xffff83b5).rw(m_porte, FUNC(sh_port16_device::io_r), FUNC(sh_port16_device::io_w)); + map(0xffff83b8, 0xffff83bb).rw(FUNC(sh7042_device::pcf_e_r), FUNC(sh7042_device::pcf_e_w)); + map(0xffff83c8, 0xffff83c9).rw(FUNC(sh7042_device::pcf_if_r), FUNC(sh7042_device::pcf_if_w)); + + map(0xffff83d0, 0xffff83d1).rw(m_cmt, FUNC(sh_cmt_device::cmstr_r), FUNC(sh_cmt_device::cmstr_w)); + map(0xffff83d2, 0xffff83d3).rw(m_cmt, FUNC(sh_cmt_device::cmcsr0_r), FUNC(sh_cmt_device::cmcsr0_w)); + map(0xffff83d4, 0xffff83d5).rw(m_cmt, FUNC(sh_cmt_device::cmcnt0_r), FUNC(sh_cmt_device::cmcnt0_w)); + map(0xffff83d6, 0xffff83d7).rw(m_cmt, FUNC(sh_cmt_device::cmcor0_r), FUNC(sh_cmt_device::cmcor0_w)); + map(0xffff83d8, 0xffff83d9).rw(m_cmt, FUNC(sh_cmt_device::cmcsr1_r), FUNC(sh_cmt_device::cmcsr1_w)); + map(0xffff83da, 0xffff83db).rw(m_cmt, FUNC(sh_cmt_device::cmcnt1_r), FUNC(sh_cmt_device::cmcnt1_w)); + map(0xffff83dc, 0xffff83dd).rw(m_cmt, FUNC(sh_cmt_device::cmcor1_r), FUNC(sh_cmt_device::cmcor1_w)); + + map(0xffff83e0, 0xffff83e0).rw(m_adc, FUNC(sh_adc_device::adcsr_r), FUNC(sh_adc_device::adcsr_w)); + map(0xffff83e1, 0xffff83e1).rw(m_adc, FUNC(sh_adc_device::adcr_r), FUNC(sh_adc_device::adcr_w)); + map(0xffff83f0, 0xffff83ff).r(m_adc, FUNC(sh_adc_device::addr_r)); map(0xfffff000, 0xffffffff).ram(); } +void sh7042_device::device_add_mconfig(machine_config &config) +{ + SH_INTC(config, m_intc, *this); + SH_ADC(config, m_adc, *this, m_intc, 136); + SH_CMT(config, m_cmt, *this, m_intc, 144, 148); + SH_PORT32(config, m_porta, *this, 0, 0x00000000, 0xff000000); + SH_PORT16(config, m_portb, *this, 0, 0x0000, 0xfc00); + SH_PORT16(config, m_portc, *this, 1, 0x0000, 0x0000); + SH_PORT32(config, m_portd, *this, 1, 0x0000, 0x0000); + SH_PORT16(config, m_porte, *this, 2, 0x0000, 0x0000); + SH_PORT16(config, m_portf, *this, 3, 0x0000, 0xff00); +} -// ADC section +void sh7042_device::do_sci_w(int sci, int state) +{ + logerror("sci %d %d\n", sci, state); +} -u16 sh7042_device::addr_r(offs_t offset) +void sh7042_device::internal_update() { - logerror("addr16_r %d %03x\n", offset, m_addr[offset]); - return m_addr[offset]; + internal_update(current_cycles()); } -u8 sh7042_device::adcsr_r() +void sh7042_device::add_event(u64 &event_time, u64 new_event) { - logerror("adcsr_r %02x\n", m_adcsr); - return m_adcsr; + if(!new_event) + return; + if(!event_time || event_time > new_event) + event_time = new_event; } -u8 sh7042_device::adcr_r() +void sh7042_device::recompute_timer(u64 event_time) { - logerror("adcr_r %02x\n", m_adcr); - return m_adcr; + if(!event_time) { + m_event_timer->adjust(attotime::never); + return; + } + + m_event_timer->adjust(attotime::from_ticks(2*event_time + 1, 2*clock()) - machine().time()); } -void sh7042_device::adcsr_w(u8 data) +TIMER_CALLBACK_MEMBER(sh7042_device::event_timer_tick) { - logerror("adcsr_w %02x\n", data); - // u8 prev = m_adcsr; - m_adcsr = (data & 0x7f) | (m_adcsr & data & CSR_ADF); + internal_update(); } -void sh7042_device::adcr_w(u8 data) +void sh7042_device::internal_update(u64 current_time) { - static const char *const tg_modes[4] = { "soft", "mtu", "?", "external" }; - static const char *const buf_modes[4] = { "normal", "a->b", "a,b->c,d", "a->b->c->d" }; - logerror("adcr_w speed=%d trigger=%s mode=%s sampling=%s buffering=%s\n", - BIT(data, 6) ? "high" : "low", - tg_modes[(data >> 4) & 3], - BIT(data, 3) ? "scan" : "single", - BIT(data, 2) ? "simultaneous" : "normal", - buf_modes[data & 3]); - m_adcr = data; + u64 event_time = 0; + + add_event(event_time, m_adc->internal_update(current_time)); + add_event(event_time, m_cmt->internal_update(current_time)); + + recompute_timer(event_time); } -void sh7042_device::do_sci_w(int sci, int state) +u16 sh7042_device::pcf_ah_r() { - logerror("sci %d %d\n", sci, state); + return m_pcf_ah; +} + +void sh7042_device::pcf_ah_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_pcf_ah); + logerror("pcf ah = %04x\n", m_pcf_ah); +} + +u32 sh7042_device::pcf_al_r() +{ + return m_pcf_al; +} + +void sh7042_device::pcf_al_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_pcf_al); + logerror("pcf al = %08x\n", m_pcf_al); +} + +u32 sh7042_device::pcf_b_r() +{ + return m_pcf_b; +} + +void sh7042_device::pcf_b_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_pcf_b); + logerror("pcf b = %08x\n", m_pcf_b); +} + +u16 sh7042_device::pcf_c_r() +{ + return m_pcf_c; +} + +void sh7042_device::pcf_c_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_pcf_c); + logerror("pcf c = %04x\n", m_pcf_c); +} + +u32 sh7042_device::pcf_dh_r() +{ + return m_pcf_dh; +} + +void sh7042_device::pcf_dh_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_pcf_dh); + logerror("pcf dh = %08x\n", m_pcf_dh); +} + +u16 sh7042_device::pcf_dl_r() +{ + return m_pcf_dl; +} + +void sh7042_device::pcf_dl_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_pcf_dl); + logerror("pcf dl = %04x\n", m_pcf_dl); +} + +u32 sh7042_device::pcf_e_r() +{ + return m_pcf_e; +} + +void sh7042_device::pcf_e_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_pcf_e); + logerror("pcf e = %08x\n", m_pcf_e); +} + +u16 sh7042_device::pcf_if_r() +{ + return m_pcf_if; +} + +void sh7042_device::pcf_if_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_pcf_if); + logerror("pcf if = %04x\n", m_pcf_if); } diff --git a/src/devices/cpu/sh/sh7042.h b/src/devices/cpu/sh/sh7042.h index dabcb7c272b..55795fd8282 100644 --- a/src/devices/cpu/sh/sh7042.h +++ b/src/devices/cpu/sh/sh7042.h @@ -1,7 +1,7 @@ // license:BSD-3-Clause // copyright-holders:Olivier Galibert -// SH7042, sh2 variant +// SH704x, sh2 variant #ifndef MAME_CPU_SH_SH7042_H #define MAME_CPU_SH_SH7042_H @@ -9,6 +9,10 @@ #pragma once #include "sh2.h" +#include "sh_intc.h" +#include "sh_adc.h" +#include "sh_cmt.h" +#include "sh_port.h" class sh7042_device : public sh2_device { @@ -19,8 +23,30 @@ class sh7042_device : public sh2_device template void sci_rx_w(int state) { do_sci_w(Sci, state); } template auto write_sci_tx() { return m_sci_tx[Sci].bind(); } + auto read_porta() { return m_read_port32 [0].bind(); } + auto write_porta() { return m_write_port32[0].bind(); } + auto read_portb() { return m_read_port16 [0].bind(); } + auto write_portb() { return m_write_port16[0].bind(); } + auto read_portc() { return m_read_port16 [1].bind(); } + auto write_portc() { return m_write_port16[1].bind(); } + auto read_portd() { return m_read_port32 [1].bind(); } + auto write_portd() { return m_write_port32[1].bind(); } + auto read_porte() { return m_read_port16 [2].bind(); } + auto write_porte() { return m_write_port16[2].bind(); } + auto read_portf() { return m_read_port16 [3].bind(); } + + void internal_update(); + u16 do_read_adc(int port) { return m_read_adc[port](); } + u16 do_read_port16(int port) { return m_read_port16[port](); } + void do_write_port16(int port, u16 data, u16 ddr) { m_write_port16[port](0, data, ddr); } + u32 do_read_port32(int port) { return m_read_port32[port](); } + void do_write_port32(int port, u32 data, u32 ddr) { m_write_port32[port](0, data, ddr); } + + u64 current_cycles() { return machine().time().as_ticks(clock()); } protected: + const char *m_port16_names; + const char *m_port32_names; enum { CSR_ADF = 0x80, CSR_ADIE = 0x40, @@ -42,25 +68,68 @@ class sh7042_device : public sh2_device virtual void device_start() override; virtual void device_reset() override; + virtual void device_add_mconfig(machine_config &config) override; private: + required_device m_intc; + required_device m_adc; + required_device m_cmt; + required_device m_porta; + required_device m_portb; + required_device m_portc; + required_device m_portd; + required_device m_porte; + required_device m_portf; + devcb_read16::array<8> m_read_adc; devcb_write_line::array<2> m_sci_tx; + devcb_read16::array<4> m_read_port16; + devcb_write16::array<4> m_write_port16; + devcb_read32::array<2> m_read_port32; + devcb_write32::array<2> m_write_port32; + + emu_timer *m_event_timer; + + u16 m_pcf_ah; + u32 m_pcf_al; + u32 m_pcf_b; + u16 m_pcf_c; + u32 m_pcf_dh; + u16 m_pcf_dl; + u32 m_pcf_e; + u16 m_pcf_if; void map(address_map &map); - // ADC section - uint16_t m_addr[8]; - uint8_t m_adcsr, m_adcr; - u16 adc_default(int adc); - u16 addr_r(offs_t offset); - u8 adcsr_r(); - u8 adcr_r(); - void adcsr_w(u8 data); - void adcr_w(u8 data); - + u16 port16_default_r(int port); + void port16_default_w(int port, u16 data); + u32 port32_default_r(int port); + void port32_default_w(int port, u32 data); + + void add_event(u64 &event_time, u64 new_event); + void recompute_timer(u64 event_time); + TIMER_CALLBACK_MEMBER(event_timer_tick); + void internal_update(u64 current_time); + void do_sci_w(int sci, int state); + + u16 pcf_ah_r(); + void pcf_ah_w(offs_t, u16 data, u16 mem_mask); + u32 pcf_al_r(); + void pcf_al_w(offs_t, u32 data, u32 mem_mask); + u32 pcf_b_r(); + void pcf_b_w(offs_t, u32 data, u32 mem_mask); + u16 pcf_c_r(); + void pcf_c_w(offs_t, u16 data, u16 mem_mask); + u32 pcf_dh_r(); + void pcf_dh_w(offs_t, u32 data, u32 mem_mask); + u16 pcf_dl_r(); + void pcf_dl_w(offs_t, u16 data, u16 mem_mask); + u32 pcf_e_r(); + void pcf_e_w(offs_t, u32 data, u32 mem_mask); + u16 pcf_if_r(); + void pcf_if_w(offs_t, u16 data, u16 mem_mask); }; class sh7043_device : public sh7042_device diff --git a/src/devices/cpu/sh/sh_adc.cpp b/src/devices/cpu/sh/sh_adc.cpp new file mode 100644 index 00000000000..d9e1da01921 --- /dev/null +++ b/src/devices/cpu/sh/sh_adc.cpp @@ -0,0 +1,315 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "sh_adc.h" +#include "sh7042.h" +#include "sh_intc.h" + +// Verbosity level +// 0 = no messages +// 1 = everything +static constexpr int V = 0; + +DEFINE_DEVICE_TYPE(SH_ADC, sh_adc_device, "sh_adc", "SH2/704x ADC") + +sh_adc_device::sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, SH_ADC, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG), + m_intc(*this, finder_base::DUMMY_TAG), + m_intc_vector(0), m_adcsr(0), m_adcr(0), m_register_mask(0), m_trigger(0), m_start_mode(0), m_start_channel(0), + m_end_channel(0), m_start_count(0), m_mode(0), m_channel(0), m_count(0), m_analog_powered(false), m_adtrg(false), m_next_event(0) +{ + m_suspend_on_interrupt = true; + m_register_mask = 7; + m_analog_power_control = false; +} + +u16 sh_adc_device::addr_r(offs_t offset) +{ + if(V>=1) logerror("addr_r %d %03x\n", offset, m_addr[offset]); + return m_addr[offset]; +} + +u8 sh_adc_device::adcsr_r() +{ + if(V>=1) logerror("adcsr_r %02x\n", m_adcsr); + return m_adcsr; +} + +u8 sh_adc_device::adcr_r() +{ + if(V>=1) logerror("adcr_r %02x\n", m_adcr); + return m_adcr; +} + +void sh_adc_device::adcsr_w(u8 data) +{ + if(V>=1) logerror("adcsr_w %02x\n", data); + u8 prev = m_adcsr; + m_adcsr = (data & 0x7f) | (m_adcsr & data & F_ADF); + mode_update(); + if((prev & F_ADF) && !(m_adcsr & F_ADF)) { + if(m_mode & HALTED) { + m_mode &= ~HALTED; + if(!(m_adcsr & F_ADST)) { + sampling(); + conversion_wait(false, false); + } else + done(); + } + } + + if(!(prev & F_ADST) && (m_adcsr & F_ADST)) + start_conversion(); +} + +void sh_adc_device::adcr_w(u8 data) +{ + if(V>=1) logerror("adcr_w %02x\n", data); + m_adcr = data; + mode_update(); +} + +void sh_adc_device::adtrg_w(int state) +{ + if(state != m_adtrg) { + m_adtrg = state; + if(!m_adtrg && (m_trigger & T_EXT) && !(m_adcsr & F_ADST)) { + m_adcsr |= F_ADST; + start_conversion(); + } + } +} + +void sh_adc_device::set_suspend(bool suspend) +{ +} + +void sh_adc_device::device_start() +{ + save_item(NAME(m_addr)); + save_item(NAME(m_buf)); + save_item(NAME(m_adcsr)); + save_item(NAME(m_adcr)); + save_item(NAME(m_trigger)); + save_item(NAME(m_start_mode)); + save_item(NAME(m_start_channel)); + save_item(NAME(m_end_channel)); + save_item(NAME(m_start_count)); + save_item(NAME(m_suspend_on_interrupt)); + save_item(NAME(m_analog_power_control)); + save_item(NAME(m_mode)); + save_item(NAME(m_channel)); + save_item(NAME(m_count)); + save_item(NAME(m_analog_powered)); + save_item(NAME(m_next_event)); + save_item(NAME(m_adtrg)); +} + +void sh_adc_device::device_reset() +{ + memset(m_addr, 0, sizeof(m_addr)); + memset(m_buf, 0, sizeof(m_buf)); + m_adcsr = m_adcr = 0; + m_trigger = T_SOFT; + m_start_mode = IDLE; + m_start_channel = m_end_channel = 0; + m_start_count = 1; + m_mode = IDLE; + m_channel = 0; + m_count = 0; + m_next_event = 0; + mode_update(); + m_analog_powered = !m_analog_power_control; + m_adtrg = true; +} + +void sh_adc_device::done() +{ + m_mode = IDLE; + m_adcsr &= ~F_ADST; + if(m_analog_power_control) + m_analog_powered = false; +} + +u64 sh_adc_device::internal_update(u64 current_time) +{ + if(m_next_event && m_next_event <= current_time) { + m_next_event = 0; + timeout(current_time); + } + return m_next_event; +} + +void sh_adc_device::conversion_wait(bool first, bool poweron, u64 current_time) +{ + if(current_time) + m_next_event = current_time + conversion_time(first, poweron); + else { + m_next_event = m_cpu->total_cycles() + conversion_time(first, poweron); + m_cpu->internal_update(); + } +} + +void sh_adc_device::buffer_value(int port, int buffer) +{ + m_buf[buffer] = m_cpu->do_read_adc(port); + if(V>=1) logerror("adc buffer %d -> %d:%03x\n", port, buffer, m_buf[buffer]); +} + +void sh_adc_device::commit_value(int reg, int buffer) +{ + reg &= m_register_mask; + if(V>=1) logerror("adc commit %d -> %d:%03x\n", buffer, reg, m_buf[buffer]); + m_addr[reg] = m_buf[buffer]; +} + +void sh_adc_device::sampling() +{ + if(m_mode & COUNTED) + m_channel = get_channel_index(m_start_count - m_count); + if(m_mode & DUAL) { + buffer_value(m_channel, 0); + buffer_value(m_channel+1, 1); + } else + buffer_value(m_channel); +} + +void sh_adc_device::start_conversion() +{ + m_mode = m_start_mode; + m_channel = m_start_channel; + m_count = m_start_count; + sampling(); + conversion_wait(true, !m_analog_powered); + m_analog_powered = true; +} + +void sh_adc_device::timeout(u64 current_time) +{ + if(m_mode & BUFFER) { + do_buffering((m_mode & DUAL) && (m_channel & 1)); + if((m_mode & DUAL) && !(m_channel & 1)) { + m_channel++; + conversion_wait(false, false, current_time); + return; + } + } else { + if(m_mode & DUAL) { + if(m_channel & 1) + commit_value(m_channel, 1); + else { + commit_value(m_channel, 0); + m_channel++; + conversion_wait(false, false, current_time); + return; + } + } else + commit_value(m_channel); + } + + if(m_mode & ROTATE) { + if(m_channel != m_end_channel) { + m_channel++; + sampling(); + conversion_wait(false, false, current_time); + return; + } + m_channel = m_start_channel; + } + + if(m_mode & COUNTED) { + m_count--; + if(m_count) { + sampling(); + conversion_wait(false, false, current_time); + return; + } + } + + m_adcsr |= F_ADF; + if(m_adcsr & F_ADIE) + m_intc->internal_interrupt(m_intc_vector); + + if(m_mode & REPEAT) { + if(m_suspend_on_interrupt && (m_adcsr & F_ADIE)) { + m_mode |= HALTED; + return; + } + m_channel = m_start_channel; + m_count = m_start_count; + sampling(); + conversion_wait(false, false, current_time); + return; + } + + done(); +} + +int sh_adc_device::conversion_time(bool first, bool poweron) +{ + int tm = m_adcsr & 0x10 ? 44 : 24; + if(first) + tm += m_adcsr & 0x10 ? 20 : 10; + if(poweron) + tm += 200; + return tm; +} + +void sh_adc_device::mode_update() +{ + m_trigger = 1 << ((m_adcr >> 4) & 3); + m_analog_power_control = !(m_adcr & 0x40); + + m_mode = ACTIVE | (m_adcr & 0x08 ? REPEAT : 0); + + if(m_adcsr & 0x03) { + m_mode |= BUFFER; + + } + + if(m_adcsr & 0x08) { + m_mode |= ROTATE; + m_start_channel = 0; + if(m_adcr & 0x04) { + m_mode |= DUAL; + m_end_channel = (m_adcsr & 6)+1; + } else + m_end_channel = m_adcsr & 7; + } else + m_start_channel = m_end_channel = m_adcsr & 7; + +} + +void sh_adc_device::do_buffering(int buffer) +{ + if((m_mode & COUNTED) && m_channel >= 2) { + commit_value(m_channel, buffer); + return; + } + switch(m_adcsr & 3) { + case 0: + commit_value(m_channel, buffer); + break; + case 1: + m_addr[1] = m_addr[0]; + commit_value(0, buffer); + break; + case 2: + m_addr[2+buffer] = m_addr[buffer]; + commit_value(buffer, buffer); + break; + case 3: + m_addr[3] = m_addr[2]; + m_addr[2] = m_addr[1]; + m_addr[1] = m_addr[0]; + commit_value(0, buffer); + break; + } +} + +int sh_adc_device::get_channel_index(int count) +{ + abort(); +} diff --git a/src/devices/cpu/sh/sh_adc.h b/src/devices/cpu/sh/sh_adc.h new file mode 100644 index 00000000000..9a48e3f804b --- /dev/null +++ b/src/devices/cpu/sh/sh_adc.h @@ -0,0 +1,100 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_adc.h + + SH Analog to Digital Converter subsystem + + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_ADC_H +#define MAME_CPU_SH_SH_ADC_H + +#pragma once + +class sh7042_device; +class sh_intc_device; + +class sh_adc_device : public device_t { +public: + sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + + template sh_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, + T &&cpu, U &&intc, int vect) : + sh_adc_device(mconfig, tag, owner) + { + m_cpu.set_tag(std::forward(cpu)); + m_intc.set_tag(std::forward(intc)); + m_intc_vector = vect; + } + + u16 addr_r(offs_t offset); + u8 adcsr_r(); + u8 adcr_r(); + void adcsr_w(u8 data); + void adcr_w(u8 data); + void adtrg_w(int state); + + void set_suspend(bool suspend); + u64 internal_update(u64 current_time); + +protected: + required_device m_cpu; + required_device m_intc; + int m_intc_vector; + + enum { + T_SOFT = 1<<0, + T_TPU = 1<<1, + T_TIMER = 1<<2, + T_EXT = 1<<3 + }; + + enum { + F_ADF = 0x80, + F_ADIE = 0x40, + F_ADST = 0x20 + }; + + enum { + IDLE = 0, + ACTIVE = 1, + HALTED = 2, + REPEAT = 4, + ROTATE = 8, + DUAL = 16, + BUFFER = 32, + COUNTED = 64 + }; + + u16 m_addr[8], m_buf[2]; + u8 m_adcsr, m_adcr; + int m_register_mask; + int m_trigger, m_start_mode, m_start_channel, m_end_channel, m_start_count; + bool m_suspend_on_interrupt, m_analog_power_control; + int m_mode, m_channel, m_count; + bool m_analog_powered, m_adtrg; + u64 m_next_event; + + virtual void device_start() override; + virtual void device_reset() override; + + void sampling(); + void start_conversion(); + void conversion_wait(bool first, bool poweron, u64 current_time = 0); + void buffer_value(int port, int buffer = 0); + void commit_value(int reg, int buffer = 0); + void timeout(u64 current_time); + void done(); + + int conversion_time(bool first, bool poweron); + void mode_update(); + void do_buffering(int buffer); + int get_channel_index(int count); +}; + +DECLARE_DEVICE_TYPE(SH_ADC, sh_adc_device) + +#endif // MAME_CPU_SH_SH_ADC_H diff --git a/src/devices/cpu/sh/sh_cmt.cpp b/src/devices/cpu/sh/sh_cmt.cpp new file mode 100644 index 00000000000..1e659080e75 --- /dev/null +++ b/src/devices/cpu/sh/sh_cmt.cpp @@ -0,0 +1,197 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_cmt.h + + SH Compare/Match timer subsystem + + +***************************************************************************/ + +#include "emu.h" +#include "sh7042.h" +#include "sh_intc.h" + +DEFINE_DEVICE_TYPE(SH_CMT, sh_cmt_device, "sh_cmt", "SH2/704x CMT") + +sh_cmt_device::sh_cmt_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, SH_CMT, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG), + m_intc(*this, finder_base::DUMMY_TAG), + m_intc_vector{0, 0}, + m_str(0), + m_csr{ 0, 0 }, + m_cnt{ 0, 0 }, + m_cor{ 0xffff, 0xffff } +{ +} + +void sh_cmt_device::device_start() +{ +} + +void sh_cmt_device::device_reset() +{ +} + +u64 sh_cmt_device::internal_update(u64 current_time) +{ + u64 next = 0; + for(int i = 0; i != 2; i++) { + if(m_next_event[i] && current_time >= m_next_event[i]) { + m_csr[i] |= 0x80; + if(BIT(m_csr[i], 6)) + m_intc->internal_interrupt(m_intc_vector[i]); + cnt_update(i, current_time); + } + if(!next || (m_next_event[i] && m_next_event[i] < next)) + next = m_next_event[i]; + } + return next; +} + + +u16 sh_cmt_device::cmstr_r() +{ + return m_str; +} + +u16 sh_cmt_device::cmcsr0_r() +{ + return m_csr[0]; +} + +u16 sh_cmt_device::cmcnt0_r() +{ + cnt_update(0, m_cpu->current_cycles()); + return m_cnt[0]; +} + +u16 sh_cmt_device::cmcor0_r() +{ + return m_cor[0]; +} + +u16 sh_cmt_device::cmcsr1_r() +{ + return m_csr[1]; +} + +u16 sh_cmt_device::cmcnt1_r() +{ + cnt_update(1, m_cpu->current_cycles()); + return m_cnt[1]; +} + +u16 sh_cmt_device::cmcor1_r() +{ + return m_cor[1]; +} + +void sh_cmt_device::cmcsr0_w(offs_t, u16 data, u16 mem_mask) +{ + csr_w(0, data, mem_mask); +} + +void sh_cmt_device::cmcsr1_w(offs_t, u16 data, u16 mem_mask) +{ + csr_w(1, data, mem_mask); +} + +void sh_cmt_device::cmcnt0_w(offs_t, u16 data, u16 mem_mask) +{ + cnt_w(0, data, mem_mask); +} + +void sh_cmt_device::cmcnt1_w(offs_t, u16 data, u16 mem_mask) +{ + cnt_w(1, data, mem_mask); +} + +void sh_cmt_device::cmcor0_w(offs_t, u16 data, u16 mem_mask) +{ + cor_w(0, data, mem_mask); +} + +void sh_cmt_device::cmcor1_w(offs_t, u16 data, u16 mem_mask) +{ + cor_w(1, data, mem_mask); +} + +void sh_cmt_device::cmstr_w(offs_t, u16 data, u16 mem_mask) +{ + cnt_update(0, m_cpu->current_cycles()); + cnt_update(1, m_cpu->current_cycles()); + u16 old = m_str; + COMBINE_DATA(&m_str); + logerror("active %c %c\n", m_str & 1 ? '0' : '-', m_str & 2 ? '1' : '-'); + for(int i=0; i != 2; i++) + if(!BIT(old, i) && BIT(m_str, i)) + clock_start(i); + else if(!BIT(m_str, i)) + m_next_event[i] = 0; + m_cpu->internal_update(); +} + +void sh_cmt_device::csr_w(int reg, u16 data, u16 mem_mask) +{ + cnt_update(reg, m_cpu->current_cycles()); + u16 old = m_csr[reg]; + COMBINE_DATA(&m_csr[reg]); + if(!(old & 0x80)) + m_csr[reg] &= ~0x80; + if((old ^ m_csr[reg]) & 0x7f) + logerror("csr_w %d f=%d ie=%d div=%d\n", reg, BIT(m_csr[reg], 7), BIT(m_csr[reg], 6), 8 << (2*BIT(m_csr[reg], 0, 2))); +} + +void sh_cmt_device::cnt_w(int reg, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_cnt[reg]); + logerror("cnt_w %d, %04x\n", reg, m_cnt[reg]); + if((m_str >> reg) & 1) { + compute_next_event(reg); + m_cpu->internal_update(); + } +} + +void sh_cmt_device::cor_w(int reg, u16 data, u16 mem_mask) +{ + cnt_update(reg, m_cpu->current_cycles()); + COMBINE_DATA(&m_cor[reg]); + logerror("cor_w %d, %04x\n", reg, m_cor[reg]); + if((m_str >> reg) & 1) { + compute_next_event(reg); + m_cpu->internal_update(); + } +} + +void sh_cmt_device::clock_start(int clk) +{ + logerror("start clock %d %dHz\n", clk, (m_cpu->clock() >> (3 + 2*BIT(m_csr[clk], 0, 2))) / (m_cor[clk] + 1)); + compute_next_event(clk); +} + +void sh_cmt_device::compute_next_event(int clk) +{ + u64 step1 = 1 << (3 + 2*BIT(m_csr[clk], 0, 2)); + u64 time = m_cpu->current_cycles(); + if(time & (step1 - 1)) + time = (time | (step1 - 1)) + 1; + s32 counts = m_cor[clk] + 1 - m_cnt[clk]; + if(counts < 0) + counts += 0x10000; + time += step1 * counts; + m_next_event[clk] = time; +} + +void sh_cmt_device::cnt_update(int clk, u64 current_time) +{ + if(!((m_str >> clk) & 1)) + return; + u64 step = (m_cor[clk] + 1) << (3 + 2*BIT(m_csr[clk], 0, 2)); + while(current_time >= m_next_event[clk]) + m_next_event[clk] += step; + u64 delta = m_next_event[clk] - current_time; + m_cnt[clk] = m_cor[clk] - ((delta - 1) >> (3 + 2*BIT(m_csr[clk], 0, 2))); +} diff --git a/src/devices/cpu/sh/sh_cmt.h b/src/devices/cpu/sh/sh_cmt.h new file mode 100644 index 00000000000..e365be37fb1 --- /dev/null +++ b/src/devices/cpu/sh/sh_cmt.h @@ -0,0 +1,75 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_cmt.h + + SH Compare/Match timer subsystem + + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_CMT_H +#define MAME_CPU_SH_SH_CMT_H + +#pragma once + +class sh7042_device; +class sh_intc_device; + +class sh_cmt_device : public device_t { +public: + sh_cmt_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + + template sh_cmt_device(const machine_config &mconfig, const char *tag, device_t *owner, + T &&cpu, U &&intc, int vect0, int vect1) : + sh_cmt_device(mconfig, tag, owner) + { + m_cpu.set_tag(std::forward(cpu)); + m_intc.set_tag(std::forward(intc)); + m_intc_vector[0] = vect0; + m_intc_vector[1] = vect1; + } + + u64 internal_update(u64 current_time); + + u16 cmstr_r(); + void cmstr_w(offs_t, u16 data, u16 mem_mask); + u16 cmcsr0_r(); + void cmcsr0_w(offs_t, u16 data, u16 mem_mask); + u16 cmcnt0_r(); + void cmcnt0_w(offs_t, u16 data, u16 mem_mask); + u16 cmcor0_r(); + void cmcor0_w(offs_t, u16 data, u16 mem_mask); + u16 cmcsr1_r(); + void cmcsr1_w(offs_t, u16 data, u16 mem_mask); + u16 cmcnt1_r(); + void cmcnt1_w(offs_t, u16 data, u16 mem_mask); + u16 cmcor1_r(); + void cmcor1_w(offs_t, u16 data, u16 mem_mask); + +protected: + required_device m_cpu; + required_device m_intc; + std::array m_next_event; + std::array m_intc_vector; + u16 m_str; + std::array m_csr; + std::array m_cnt; + std::array m_cor; + + virtual void device_start() override; + virtual void device_reset() override; + + void csr_w(int reg, u16 data, u16 mem_mask); + void cnt_w(int reg, u16 data, u16 mem_mask); + void cor_w(int reg, u16 data, u16 mem_mask); + + void clock_start(int clk); + void compute_next_event(int clk); + void cnt_update(int clk, u64 current_time); +}; + +DECLARE_DEVICE_TYPE(SH_CMT, sh_cmt_device) + +#endif // MAME_CPU_SH_SH_CMT_H diff --git a/src/devices/cpu/sh/sh_intc.cpp b/src/devices/cpu/sh/sh_intc.cpp new file mode 100644 index 00000000000..d13f8f55853 --- /dev/null +++ b/src/devices/cpu/sh/sh_intc.cpp @@ -0,0 +1,75 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_intc.cpp + + SH interrupt controllers family + +***************************************************************************/ + +#include "emu.h" +#include "sh_intc.h" + +#include "sh7042.h" + +DEFINE_DEVICE_TYPE(SH_INTC, sh_intc_device, "sh_intc", "SH interrupt controller") + +sh_intc_device::sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, SH_INTC, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG) +{ +} + +void sh_intc_device::device_start() +{ +} + +void sh_intc_device::device_reset() +{ +} + +int sh_intc_device::interrupt_taken(int vector) +{ + return 0; +} + +void sh_intc_device::internal_interrupt(int vector) +{ + logerror("Internal interrupt %d\n", vector); +} + +void sh_intc_device::set_input(int inputnum, int state) +{ +} + +u16 sh_intc_device::icr_r() +{ + return 0; +} + +void sh_intc_device::icr_w(offs_t, u16 data, u16 mem_mask) +{ + logerror("icr_w %04x @ %04x\n", data, mem_mask); +} + +u16 sh_intc_device::isr_r() +{ + return 0; +} + +void sh_intc_device::isr_w(offs_t, u16 data, u16 mem_mask) +{ + logerror("isr_w %04x @ %04x\n", data, mem_mask); +} + +u16 sh_intc_device::ipr_r(offs_t offset) +{ + return 0; +} + +void sh_intc_device::ipr_w(offs_t offset, u16 data, u16 mem_mask) +{ + logerror("ipr_w %x, %04x @ %04x\n", offset, data, mem_mask); +} + diff --git a/src/devices/cpu/sh/sh_intc.h b/src/devices/cpu/sh/sh_intc.h new file mode 100644 index 00000000000..b93444d8e32 --- /dev/null +++ b/src/devices/cpu/sh/sh_intc.h @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_intc.h + + SH interrupt controllers family + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_INTC_H +#define MAME_CPU_SH_SH_INTC_H + +#pragma once + +class sh7042_device; + +class sh_intc_device : public device_t { +public: + sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + template sh_intc_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu) : + sh_intc_device(mconfig, tag, owner) + { + m_cpu.set_tag(std::forward(cpu)); + } + + int interrupt_taken(int vector); + void internal_interrupt(int vector); + void set_input(int inputnum, int state); + + u16 icr_r(); + void icr_w(offs_t, u16 data, u16 mem_mask); + u16 isr_r(); + void isr_w(offs_t, u16 data, u16 mem_mask); + u16 ipr_r(offs_t offset); + void ipr_w(offs_t offset, u16 data, u16 mem_mask); + +protected: + required_device m_cpu; + + virtual void device_start() override; + virtual void device_reset() override; +}; + +DECLARE_DEVICE_TYPE(SH_INTC, sh_intc_device) + +#endif // MAME_CPU_SH_SH_INTC_H diff --git a/src/devices/cpu/sh/sh_port.cpp b/src/devices/cpu/sh/sh_port.cpp new file mode 100644 index 00000000000..8bc962f65cd --- /dev/null +++ b/src/devices/cpu/sh/sh_port.cpp @@ -0,0 +1,109 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_port.h + + SH i/o ports + +***************************************************************************/ + +#include "emu.h" +#include "sh_intc.h" + +#include "sh7042.h" + +DEFINE_DEVICE_TYPE(SH_PORT16, sh_port16_device, "sh_port16", "SH 16-bits port") +DEFINE_DEVICE_TYPE(SH_PORT32, sh_port32_device, "sh_port32", "SH 32-bits port") + +sh_port16_device::sh_port16_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, SH_PORT16, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG) +{ +} + +void sh_port16_device::device_start() +{ + m_io = m_default_io; + save_item(NAME(m_dr)); + save_item(NAME(m_io)); +} + +void sh_port16_device::device_reset() +{ +} + +u16 sh_port16_device::dr_r() +{ + if(~m_io & ~m_mask) + return (m_dr & m_io) | (m_cpu->do_read_port16(m_index) & ~m_io); + return m_dr; +} + +void sh_port16_device::dr_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_dr); + m_dr &= ~m_mask; + if(m_io) + m_cpu->do_write_port16(m_index, m_dr & m_io, m_io); +} + +u16 sh_port16_device::io_r() +{ + return m_io; +} + +void sh_port16_device::io_w(offs_t, u16 data, u16 mem_mask) +{ + COMBINE_DATA(&m_io); + m_io &= ~m_mask; + if(m_io) + m_cpu->do_write_port16(m_index, m_dr & m_io, m_io); +} + + +sh_port32_device::sh_port32_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : + device_t(mconfig, SH_PORT32, tag, owner, clock), + m_cpu(*this, finder_base::DUMMY_TAG) +{ +} + +void sh_port32_device::device_start() +{ + m_io = m_default_io; + save_item(NAME(m_dr)); + save_item(NAME(m_io)); +} + +void sh_port32_device::device_reset() +{ +} + +u32 sh_port32_device::dr_r() +{ + if(~m_io & ~m_mask) + return (m_dr & m_io) | (m_cpu->do_read_port32(m_index) & ~m_io); + return m_dr; +} + +void sh_port32_device::dr_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_dr); + m_dr &= ~m_mask; + if(m_io) + m_cpu->do_write_port32(m_index, m_dr & m_io, m_io); +} + +u32 sh_port32_device::io_r() +{ + return m_io; +} + +void sh_port32_device::io_w(offs_t, u32 data, u32 mem_mask) +{ + COMBINE_DATA(&m_io); + m_io &= ~m_mask; + if(m_io) + m_cpu->do_write_port32(m_index, m_dr & m_io, m_io); +} + diff --git a/src/devices/cpu/sh/sh_port.h b/src/devices/cpu/sh/sh_port.h new file mode 100644 index 00000000000..ec2a19228ee --- /dev/null +++ b/src/devices/cpu/sh/sh_port.h @@ -0,0 +1,75 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + sh_port.h + + SH i/o ports + +***************************************************************************/ + +#ifndef MAME_CPU_SH_SH_PORT_H +#define MAME_CPU_SH_SH_PORT_H + +#pragma once + +class sh7042_device; + +class sh_port16_device : public device_t { +public: + sh_port16_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + template sh_port16_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu, int index, u16 default_io, u16 mask) : + sh_port16_device(mconfig, tag, owner) + { + m_index = index; + m_default_io = default_io; + m_mask = mask; + m_cpu.set_tag(std::forward(cpu)); + } + + u16 dr_r(); + void dr_w(offs_t, u16 data, u16 mem_mask); + u16 io_r(); + void io_w(offs_t, u16 data, u16 mem_mask); + +protected: + required_device m_cpu; + int m_index; + u16 m_default_io, m_mask; + u16 m_dr, m_io; + + virtual void device_start() override; + virtual void device_reset() override; +}; + +class sh_port32_device : public device_t { +public: + sh_port32_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + template sh_port32_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&cpu, int index, u32 default_io, u32 mask) : + sh_port32_device(mconfig, tag, owner) + { + m_index = index; + m_default_io = default_io; + m_mask = mask; + m_cpu.set_tag(std::forward(cpu)); + } + + u32 dr_r(); + void dr_w(offs_t, u32 data, u32 mem_mask); + u32 io_r(); + void io_w(offs_t, u32 data, u32 mem_mask); + +protected: + required_device m_cpu; + int m_index; + u32 m_default_io, m_mask; + u32 m_dr, m_io; + + virtual void device_start() override; + virtual void device_reset() override; +}; + +DECLARE_DEVICE_TYPE(SH_PORT16, sh_port16_device) +DECLARE_DEVICE_TYPE(SH_PORT32, sh_port32_device) + +#endif // MAME_CPU_SH_SH_PORT_H diff --git a/src/devices/machine/sis85c496.cpp b/src/devices/machine/sis85c496.cpp index 89cd9e2b9d2..bc2f52e547d 100644 --- a/src/devices/machine/sis85c496.cpp +++ b/src/devices/machine/sis85c496.cpp @@ -34,6 +34,7 @@ void sis85c496_host_device::config_map(address_map &map) ); map(0x58, 0x59).rw(FUNC(sis85c496_host_device::ide_vesa_config_r), FUNC(sis85c496_host_device::ide_vesa_config_w)); map(0x5a, 0x5a).rw(FUNC(sis85c496_host_device::smram_ctrl_r), FUNC(sis85c496_host_device::smram_ctrl_w)); + map(0xc0, 0xc3).rw(FUNC(sis85c496_host_device::pirqrc_r), FUNC(sis85c496_host_device::pirqrc_w)); map(0xc8, 0xcb).rw(FUNC(sis85c496_host_device::mailbox_r), FUNC(sis85c496_host_device::mailbox_w)); map(0xd0, 0xd0).rw(FUNC(sis85c496_host_device::bios_config_r), FUNC(sis85c496_host_device::bios_config_w)); map(0xd1, 0xd1).rw(FUNC(sis85c496_host_device::isa_decoder_r), FUNC(sis85c496_host_device::isa_decoder_w)); @@ -194,6 +195,9 @@ void sis85c496_host_device::device_start() set_spaces(&m_maincpu->space(AS_PROGRAM), &m_maincpu->space(AS_IO)); + m_pci_root->set_pin_mapper(pci_pin_mapper(*this, FUNC(sis85c496_host_device::pin_mapper))); + m_pci_root->set_irq_handler(pci_irq_handler(*this, FUNC(sis85c496_host_device::irq_handler))); + memory_window_start = 0; memory_window_end = 0xffffffff; memory_offset = 0; @@ -235,6 +239,8 @@ void sis85c496_host_device::device_reset() m_shadctrl = 0; m_smramctrl = 0; m_ide_vesa_ctrl = 0; + + memset(m_pirqrc, 0x80, sizeof(m_pirqrc)); } void sis85c496_host_device::device_config_complete() @@ -596,6 +602,115 @@ void sis85c496_host_device::pc_irq12m_w(int state) { m_pic8259_slave->ir4_w(stat void sis85c496_host_device::pc_irq14_w(int state) { m_pic8259_slave->ir6_w(state); } void sis85c496_host_device::pc_irq15_w(int state) { m_pic8259_slave->ir7_w(state); } +uint8_t sis85c496_host_device::pirqrc_r(offs_t offset) +{ + return m_pirqrc[offset]; +} + +void sis85c496_host_device::pirqrc_w(offs_t offset, uint8_t data) +{ + m_pirqrc[offset] = data; + logerror("pirqrc[%d] = %02x\n", offset, m_pirqrc[offset]); +} + +int sis85c496_host_device::pin_mapper(int pin) +{ + if(pin < 0 || pin >= 4 || (m_pirqrc[pin] & 0x80)) + return -1; + return m_pirqrc[pin]; +} + +void sis85c496_host_device::irq_handler(int line, int state) +{ + if(line < 0 && line >= 16) + return; + + logerror("irq_handler %d %d\n", line, state); + redirect_irq(line, state); +} + +void sis85c496_host_device::pc_pirqa_w(int state) +{ + int irq = m_pirqrc[0] & 15; + + if (!(BIT(m_pirqrc[0], 7))) + return; + redirect_irq(irq, state); +} + +void sis85c496_host_device::pc_pirqb_w(int state) +{ + int irq = m_pirqrc[1] & 15; + + if (!(BIT(m_pirqrc[1], 7))) + return; + redirect_irq(irq, state); +} + +void sis85c496_host_device::pc_pirqc_w(int state) +{ + int irq = m_pirqrc[2] & 15; + + if (!(BIT(m_pirqrc[2], 7))) + return; + redirect_irq(irq, state); +} + +void sis85c496_host_device::pc_pirqd_w(int state) +{ + int irq = m_pirqrc[3] & 15; + + if (!(BIT(m_pirqrc[3], 7))) + return; + redirect_irq(irq, state); +} + +void sis85c496_host_device::redirect_irq(int irq, int state) +{ + switch (irq) + { + case 0: + case 1: + case 2: + case 8: + case 13: + break; + case 3: + m_pic8259_master->ir3_w(state); + break; + case 4: + m_pic8259_master->ir4_w(state); + break; + case 5: + m_pic8259_master->ir5_w(state); + break; + case 6: + m_pic8259_master->ir6_w(state); + break; + case 7: + m_pic8259_master->ir7_w(state); + break; + case 9: + m_pic8259_slave->ir1_w(state); + break; + case 10: + m_pic8259_slave->ir2_w(state); + break; + case 11: + m_pic8259_slave->ir3_w(state); + break; + case 12: + m_pic8259_slave->ir4_w(state); + break; + case 14: + m_pic8259_slave->ir6_w(state); + break; + case 15: + m_pic8259_slave->ir7_w(state); + break; + } +} + uint8_t sis85c496_host_device::at_portb_r() { uint8_t data = m_at_speaker; diff --git a/src/devices/machine/sis85c496.h b/src/devices/machine/sis85c496.h index f1ec6de304e..47cb0729655 100644 --- a/src/devices/machine/sis85c496.h +++ b/src/devices/machine/sis85c496.h @@ -46,6 +46,11 @@ class sis85c496_host_device : public pci_host_device { void set_cpu_tag(const char *tag); void set_ram_size(int ram_size); + void pc_pirqa_w(int state); + void pc_pirqb_w(int state); + void pc_pirqc_w(int state); + void pc_pirqd_w(int state); + void pc_irq1_w(int state); void pc_irq3_w(int state); void pc_irq4_w(int state); @@ -104,6 +109,8 @@ class sis85c496_host_device : public pci_host_device { uint8_t m_channel_check; uint8_t m_nmi_enabled; + uint8_t m_pirqrc[4]; + int ram_size; std::vector ram; uint32_t m_mailbox; @@ -175,6 +182,13 @@ class sis85c496_host_device : public pci_host_device { void pc_dma_write_word(offs_t offset, uint8_t data); void cpu_a20_w(int state); void cpu_reset_w(int state); + + uint8_t pirqrc_r(offs_t offset); + void pirqrc_w(offs_t offset, uint8_t data); + void redirect_irq(int irq, int state); + + int pin_mapper(int pin); + void irq_handler(int line, int state); }; DECLARE_DEVICE_TYPE(SIS85C496_HOST, sis85c496_host_device) diff --git a/src/mame/konami/blockhl.cpp b/src/mame/konami/blockhl.cpp index 82443b6f44a..65cfb7dce4c 100644 --- a/src/mame/konami/blockhl.cpp +++ b/src/mame/konami/blockhl.cpp @@ -192,6 +192,8 @@ void blockhl_state::machine_start() { // the first 0x8000 are banked, the remaining 0x8000 are directly accessible m_rombank->configure_entries(0, 4, memregion("maincpu")->base(), 0x2000); + + m_view5800.select(0); } void blockhl_state::banking_callback(uint8_t data) diff --git a/src/mame/layout/mastmind.lay b/src/mame/layout/mastmind.lay index 64bdbf6b333..f732bd27c72 100644 --- a/src/mame/layout/mastmind.lay +++ b/src/mame/layout/mastmind.lay @@ -9,22 +9,20 @@ authors:hap - - - - - - - - - - - - - - - - + + + + + + + + + + + + + ]]> @@ -43,7 +41,7 @@ authors:hap - + diff --git a/src/mame/layout/smastmind.lay b/src/mame/layout/smastmind.lay index 2c9d9201237..e29685ac59f 100644 --- a/src/mame/layout/smastmind.lay +++ b/src/mame/layout/smastmind.lay @@ -9,27 +9,25 @@ authors:hap - - - + + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + ]]> @@ -49,7 +47,7 @@ authors:hap - + diff --git a/src/mame/misc/coinmvga.cpp b/src/mame/misc/coinmvga.cpp index 7114281c1f5..8d2bf031e90 100644 --- a/src/mame/misc/coinmvga.cpp +++ b/src/mame/misc/coinmvga.cpp @@ -219,12 +219,14 @@ *******************************************************************************/ #include "emu.h" + #include "cpu/h8/h83002.h" //#include "cpu/h8/h83006.h" #include "sound/ymz280b.h" #include "machine/i2cmem.h" #include "machine/msm6242.h" #include "video/ramdac.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" @@ -250,9 +252,6 @@ class coinmvga_state : public driver_device , m_palette(*this, "palette%u", 0U) { } - void init_colorama(); - void init_cmrltv75(); - void coinmvga(machine_config &config); protected: @@ -938,19 +937,6 @@ ROM_START( cmkenospa ) ROM_LOAD( "rwc497ym.sp4", 0x300000, 0x100000, CRC(b5729ae7) SHA1(0e63fbb81ff5f2fef3c653f769db8073dff1214b) ) ROM_END - -/************************* -* Driver Init * -*************************/ - -void coinmvga_state::init_colorama() -{ -} - -void coinmvga_state::init_cmrltv75() -{ -} - } // anonymous namespace @@ -958,11 +944,11 @@ void coinmvga_state::init_cmrltv75() * Game Drivers * *************************/ -// YEAR NAME PARENT MACHINE INPUT STATE INIT ROT COMPANY FULLNAME FLAGS -GAME( 2000, colorama, 0, coinmvga, coinmvga, coinmvga_state, init_colorama, ROT0, "Coinmaster-Gaming, Ltd.", "Colorama (P521, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2000, coloramas, colorama, coinmvga, coinmvga, coinmvga_state, init_colorama, ROT0, "Coinmaster-Gaming, Ltd.", "Colorama (P521 V13, Spanish)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2000, wof_v16, 0, coinmvga, coinmvga, coinmvga_state, init_colorama, ROT0, "Coinmaster-Gaming, Ltd.", "Wheel of Fortune (P517 V16, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2000, wof_v11, wof_v16, coinmvga, coinmvga, coinmvga_state, init_colorama, ROT0, "Coinmaster-Gaming, Ltd.", "Wheel of Fortune (P517 V11, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2001, cmrltv75, 0, coinmvga, coinmvga, coinmvga_state, init_cmrltv75, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Roulette P497 V75 (Y2K, Spanish)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2000, cmkenosp, 0, coinmvga, coinmvga, coinmvga_state, empty_init, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Keno (Y2K, Spanish, 2000-12-14)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) -GAME( 2000, cmkenospa, cmkenosp, coinmvga, coinmvga, coinmvga_state, empty_init, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Keno (Y2K, Spanish, 2000-12-02)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +// YEAR NAME PARENT MACHINE INPUT STATE INIT ROT COMPANY FULLNAME FLAGS +GAME( 2000, colorama, 0, coinmvga, coinmvga, coinmvga_state, empty_init, ROT0, "Coinmaster-Gaming, Ltd.", "Colorama (P521, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2000, coloramas, colorama, coinmvga, coinmvga, coinmvga_state, empty_init, ROT0, "Coinmaster-Gaming, Ltd.", "Colorama (P521 V13, Spanish)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2000, wof_v16, 0, coinmvga, coinmvga, coinmvga_state, empty_init, ROT0, "Coinmaster-Gaming, Ltd.", "Wheel of Fortune (P517 V16, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2000, wof_v11, wof_v16, coinmvga, coinmvga, coinmvga_state, empty_init, ROT0, "Coinmaster-Gaming, Ltd.", "Wheel of Fortune (P517 V11, English)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2001, cmrltv75, 0, coinmvga, coinmvga, coinmvga_state, empty_init, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Roulette P497 V75 (Y2K, Spanish)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2000, cmkenosp, 0, coinmvga, coinmvga, coinmvga_state, empty_init, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Keno (Y2K, Spanish, 2000-12-14)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAME( 2000, cmkenospa, cmkenosp, coinmvga, coinmvga, coinmvga_state, empty_init, ROT90, "Coinmaster-Gaming, Ltd.", "Coinmaster Keno (Y2K, Spanish, 2000-12-02)", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) diff --git a/src/mame/misc/itgamble.cpp b/src/mame/misc/itgamble.cpp index 17e9d189c9a..7524005c5db 100644 --- a/src/mame/misc/itgamble.cpp +++ b/src/mame/misc/itgamble.cpp @@ -4,7 +4,7 @@ Nazionale Elettronica + others (mostly Italian) Gambling games mostly based on H8/3048 + OKI 6295 or similar. -. + These all use MCUs with internal ROM for their programs, they can't be dumped easily, and thus we can't emulate them at the moment because there is nothing to emulate diff --git a/src/mame/misc/rawthrillspc.cpp b/src/mame/misc/rawthrillspc.cpp index f4e64b32d85..708fc4dd68c 100644 --- a/src/mame/misc/rawthrillspc.cpp +++ b/src/mame/misc/rawthrillspc.cpp @@ -147,5 +147,5 @@ ROM_END } // Anonymous namespace GAME(2013, doodlejmp, 0, rawthrillspc, rawthrillspc, rawthrillspc_state, empty_init, ROT0, "ICE / Raw Thrills (Lima Sky license)", "Doodle Jump Arcade (v1.16)", MACHINE_IS_SKELETON) -GAME(2004, fnf, 0, rawthrillspc, rawthrillspc, rawthrillspc_state, empty_init, ROT0, "Raw Thrills", "The Fast And The Furious (v3.06)", MACHINE_IS_SKELETON) +GAME(2004, fnf, 0, rawthrillspc, rawthrillspc, rawthrillspc_state, empty_init, ROT0, "Raw Thrills", "The Fast And The Furious (v3.06)", MACHINE_IS_SKELETON) GAME(2008, guitarheroac, 0, rawthrillspc, rawthrillspc, rawthrillspc_state, empty_init, ROT0, "Raw Thrills (Activision / Konami license)", "Guitar Hero Arcade (v1.0.5)", MACHINE_IS_SKELETON) diff --git a/src/mame/pc/pcipc_sis.cpp b/src/mame/pc/pcipc_sis.cpp index 1d14b594ae1..9fa42529dd5 100644 --- a/src/mame/pc/pcipc_sis.cpp +++ b/src/mame/pc/pcipc_sis.cpp @@ -16,6 +16,7 @@ #include "emu.h" #include "bus/isa/isa_cards.h" +#include "bus/pci/pci_slot.h" #include "bus/rs232/hlemouse.h" #include "bus/rs232/null_modem.h" #include "bus/rs232/rs232.h" @@ -158,6 +159,9 @@ void sis496_voodoo1_state::sis496_voodoo1(machine_config &config) m_screen->set_size(640, 480); m_screen->set_visarea(0, 640 - 1, 0, 480 - 1); m_screen->set_screen_update(PCI_ID_VIDEO, FUNC(voodoo_1_pci_device::screen_update)); + + PCI_SLOT(config, "pci:1", pci_cards, 10, 0, 1, 2, 3, nullptr); + PCI_SLOT(config, "pci:2", pci_cards, 11, 1, 2, 3, 0, nullptr); } // generic placeholder for unknown BIOS types diff --git a/src/mame/snk/hng64.cpp b/src/mame/snk/hng64.cpp index 678e0471870..ef01605613e 100644 --- a/src/mame/snk/hng64.cpp +++ b/src/mame/snk/hng64.cpp @@ -462,7 +462,7 @@ for the exact number of ROMs used per game and ROM placements. Games that use the LVS-DG1 cart: Road's Edge / Round Trip RV Xtreme Rally / Off Beat Racer! Beast Busters: Second Nightmare - Samurai Shodown 64 / Samurai Spirits / Pae Wang Jeon Seol 64 + Samurai Shodown 64 / Samurai Spirits / Paewang Jeonseol 64 Games that use the LVS-DG2 cart: Fatal Fury: Wild Ambition / Garou Densetsu: Wild Ambition Buriki One: World Grapple Tournament '99 in Tokyo diff --git a/src/mame/toaplan/toaplan2.cpp b/src/mame/toaplan/toaplan2.cpp index b81a6d374f4..37481ca647d 100644 --- a/src/mame/toaplan/toaplan2.cpp +++ b/src/mame/toaplan/toaplan2.cpp @@ -6469,20 +6469,20 @@ GAME( 1991, pipibibsbl3, pipibibs, pipibibsbl, pipibibsbl, toaplan2_state, emp GAME( 1993, enmadaio, 0, enmadaio, enmadaio, toaplan2_state, init_enmadaio, ROT0, "Toaplan / Taito", "Enma Daio (Japan)", 0 ) // TP-031 // region is in eeprom (and also requires correct return value from a v25 mapped address??) -GAME( 1992, fixeight, 0, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Europe)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightk, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Korea)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeighth, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Hong Kong)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeighttw, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Taiwan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeighta, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Southeast Asia)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightu, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (USA)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightj, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight - Jigoku no Eiyuu Densetsu (Japan)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Europe, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightkt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Korea, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightht, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Hong Kong, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeighttwt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Taiwan, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightat, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Southeast Asia, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightut, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (USA, Taito license)", MACHINE_SUPPORTS_SAVE ) -GAME( 1992, fixeightjt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight - Jigoku no Eiyuu Densetsu (Japan, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeight, 0, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Europe)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightk, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Korea)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeighth, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Hong Kong)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeighttw, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Taiwan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeighta, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (Southeast Asia)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightu, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight (USA)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightj, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan", "FixEight - Jigoku no Eiyuu Densetsu (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Europe, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightkt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Korea, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightht, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Hong Kong, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeighttwt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Taiwan, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightat, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (Southeast Asia, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightut, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight (USA, Taito license)", MACHINE_SUPPORTS_SAVE ) +GAME( 1992, fixeightjt, fixeight, fixeight, fixeight, truxton2_state, init_fixeight, ROT270, "Toaplan (Taito license)", "FixEight - Jigoku no Eiyuu Densetsu (Japan, Taito license)", MACHINE_SUPPORTS_SAVE ) GAME( 1992, fixeightbl, fixeight, fixeightbl, fixeightbl, truxton2_state, init_fixeightbl, ROT270, "bootleg", "FixEight (Korea, bootleg)", MACHINE_SUPPORTS_SAVE ) @@ -6508,7 +6508,7 @@ GAME( 1994, snowbro2b2, snowbro2, snowbro2, snowbro2, toaplan2_state, empty GAME( 1994, snowbro2b3, snowbro2, snowbro2b3, snowbro2b3, toaplan2_state, empty_init, ROT0, "bootleg", "Snow Bros. 2 - With New Elves / Otenki Paradise (bootleg, set 3)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // GFX offsets not 100% correct GAME( 1993, sstriker, 0, mahoudai, sstriker, truxton2_state, empty_init, ROT270, "Raizing", "Sorcer Striker", MACHINE_SUPPORTS_SAVE ) // verified on two different PCBs -GAME( 1993, sstrikerk, sstriker, mahoudai, sstrikerk, truxton2_state, empty_init, ROT270, "Raizing (Unite Trading license)", "Sorcer Striker (Korea)" , MACHINE_SUPPORTS_SAVE ) // Although the region jumper is functional, it's a Korean board / version +GAME( 1993, sstrikerk, sstriker, mahoudai, sstrikerk, truxton2_state, empty_init, ROT270, "Raizing (Unite Trading license)", "Sorcer Striker (Korea)", MACHINE_SUPPORTS_SAVE ) // Although the region jumper is functional, it's a Korean board / version GAME( 1993, mahoudai, sstriker, mahoudai, mahoudai, truxton2_state, empty_init, ROT270, "Raizing (Able license)", "Mahou Daisakusen (Japan)", MACHINE_SUPPORTS_SAVE ) GAME( 1994, kingdmgp, 0, shippumd, kingdmgp, truxton2_state, empty_init, ROT270, "Raizing / Eighting", "Kingdom Grandprix", MACHINE_SUPPORTS_SAVE ) // from Korean board, missing letters on credits screen but this is correct @@ -6519,8 +6519,8 @@ GAME( 1996, bgareggat, bgaregga, bgaregga, bgaregga, truxton2_state, init_ GAME( 1996, bgareggahk, bgaregga, bgaregga, bgareggahk, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga (Austria / Hong Kong) (Sat Feb 3 1996)", MACHINE_SUPPORTS_SAVE ) GAME( 1996, bgareggatw, bgaregga, bgaregga, bgareggatw, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga (Taiwan / Germany) (Thu Feb 1 1996)", MACHINE_SUPPORTS_SAVE ) GAME( 1996, bgareggak, bgaregga, bgaregga, bgareggak, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga (Korea / Greece) (Wed Feb 7 1996)", MACHINE_SUPPORTS_SAVE ) -GAME( 1996, bgaregganv, bgaregga, bgaregga, bgareggahk, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)" , MACHINE_SUPPORTS_SAVE ) // displays New Version only when set to HK -GAME( 1996, bgareggat2, bgaregga, bgaregga, bgaregga, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)" , MACHINE_SUPPORTS_SAVE ) // displays Type 2 only when set to Europe +GAME( 1996, bgaregganv, bgaregga, bgaregga, bgareggahk, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)", MACHINE_SUPPORTS_SAVE ) // displays New Version only when set to HK +GAME( 1996, bgareggat2, bgaregga, bgaregga, bgaregga, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)", MACHINE_SUPPORTS_SAVE ) // displays Type 2 only when set to Europe GAME( 1996, bgareggacn, bgaregga, bgaregga, bgareggacn, truxton2_state, init_bgaregga, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Denmark / China) (Tue Apr 2 1996)", MACHINE_SUPPORTS_SAVE ) // displays Type 2 only when set to Denmark GAME( 1998, bgareggabl, bgaregga, bgareggabl, bgareggabl, truxton2_state, init_bgaregga, ROT270, "bootleg (Melody)", "1945 Er Dai / 1945 Part-2 (Chinese hack of Battle Garegga)", MACHINE_SUPPORTS_SAVE ) // based on Thu Feb 1 1996 set, Region hardcoded to China GAME( 1997, bgareggabla, bgaregga, bgareggabl, bgareggabl, truxton2_state, init_bgaregga, ROT270, "bootleg (Melody)", "Leishen Chuan / Thunder Deity Biography (Chinese hack of Battle Garegga)", MACHINE_SUPPORTS_SAVE ) // based on Thu Feb 1 1996 set, Region hardcoded to Asia diff --git a/src/mame/tvgames/xavix_a.cpp b/src/mame/tvgames/xavix_a.cpp index 9470f8536de..ebddb577444 100644 --- a/src/mame/tvgames/xavix_a.cpp +++ b/src/mame/tvgames/xavix_a.cpp @@ -116,7 +116,6 @@ bool xavix_sound_device::is_voice_enabled(int voice) void xavix_sound_device::enable_voice(int voice, bool update_only) { m_stream->update(); - int voicemembase = voice * 0x10; uint16_t freq_mode = (m_readregs_cb(voicemembase + 0x1) << 8) | (m_readregs_cb(voicemembase + 0x0)); // sample rate maybe? diff --git a/src/mame/unico/unico.cpp b/src/mame/unico/unico.cpp index e831e85fcf6..b4caf8aa6ee 100644 --- a/src/mame/unico/unico.cpp +++ b/src/mame/unico/unico.cpp @@ -275,20 +275,20 @@ static INPUT_PORTS_START( burglarx ) PORT_START("DSW1") /* $80001a.b */ PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_SERVICE( 0x0100, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Free_Play ) ) + PORT_SERVICE( 0x0100, IP_ACTIVE_LOW ) PORT_DIPLOCATION("DIP-A:1") + PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("DIP-A:2") PORT_DIPSETTING( 0x0200, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0400, 0x0400, "Unknown 1-2" ) + PORT_DIPNAME( 0x0400, 0x0400, "Unknown A-3" ) PORT_DIPLOCATION("DIP-A:3") PORT_DIPSETTING( 0x0400, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0800, 0x0000, DEF_STR( Demo_Sounds ) ) + PORT_DIPNAME( 0x0800, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("DIP-A:4") PORT_DIPSETTING( 0x0800, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x1000, 0x1000, "Unknown 1-4" ) + PORT_DIPNAME( 0x1000, 0x1000, "Unknown A-5" ) PORT_DIPLOCATION("DIP-A:5") PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0xe000, 0xe000, DEF_STR( Coinage ) ) + PORT_DIPNAME( 0xe000, 0xe000, DEF_STR( Coinage ) ) PORT_DIPLOCATION("DIP-A:6,7,8") PORT_DIPSETTING( 0x0000, DEF_STR( 5C_1C ) ) PORT_DIPSETTING( 0x2000, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0x4000, DEF_STR( 3C_1C ) ) @@ -300,23 +300,23 @@ static INPUT_PORTS_START( burglarx ) PORT_START("DSW2") /* $80001c.b */ PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Bonus_Life ) ) + PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("DIP-B:1,2") PORT_DIPSETTING( 0x0200, DEF_STR( None ) ) PORT_DIPSETTING( 0x0300, "A" ) PORT_DIPSETTING( 0x0100, "B" ) PORT_DIPSETTING( 0x0000, "C" ) - PORT_DIPNAME( 0x0400, 0x0400, "Unknown 2-2" ) + PORT_DIPNAME( 0x0400, 0x0400, "Unknown B-3" ) PORT_DIPLOCATION("DIP-B:3") PORT_DIPSETTING( 0x0400, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0800, 0x0800, "Energy" ) + PORT_DIPNAME( 0x0800, 0x0800, "Energy" ) PORT_DIPLOCATION("DIP-B:4") PORT_DIPSETTING( 0x0000, "2" ) PORT_DIPSETTING( 0x0800, "3" ) - PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Difficulty ) ) + PORT_DIPNAME( 0x3000, 0x3000, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("DIP-B:5,6") PORT_DIPSETTING( 0x2000, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x3000, DEF_STR( Normal ) ) PORT_DIPSETTING( 0x1000, DEF_STR( Hard ) ) PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0xc000, 0xc000, DEF_STR( Lives ) ) + PORT_DIPNAME( 0xc000, 0xc000, DEF_STR( Lives ) ) PORT_DIPLOCATION("DIP-B:7,8") PORT_DIPSETTING( 0x8000, "2" ) PORT_DIPSETTING( 0xc000, "3" ) PORT_DIPSETTING( 0x4000, "4" ) @@ -352,22 +352,22 @@ static INPUT_PORTS_START( zeropnt ) PORT_START("DSW1") /* $80001a.b */ PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-A:!1") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0100, DEF_STR( On ) ) - PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Free_Play ) ) + PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("DIP-A:!2") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0200, DEF_STR( On ) ) - PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-A:!3") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0400, DEF_STR( On ) ) - PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Demo_Sounds ) ) + PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("DIP-A:!4") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0800, DEF_STR( On ) ) - PORT_DIPNAME( 0x1000, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x1000, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-A:!5") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x1000, DEF_STR( On ) ) - PORT_DIPNAME( 0xe000, 0x0000, DEF_STR( Coinage ) ) + PORT_DIPNAME( 0xe000, 0x0000, DEF_STR( Coinage ) ) PORT_DIPLOCATION("DIP-A:!6,!7,!8") PORT_DIPSETTING( 0xe000, DEF_STR( 5C_1C ) ) PORT_DIPSETTING( 0xc000, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0xa000, DEF_STR( 3C_1C ) ) @@ -379,23 +379,23 @@ static INPUT_PORTS_START( zeropnt ) PORT_START("DSW2") /* $80001c.b */ PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-B:!1") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0100, DEF_STR( On ) ) - PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-B:!2") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0200, DEF_STR( On ) ) - PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-B:!3") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0400, DEF_STR( On ) ) - PORT_DIPNAME( 0x0800, 0x0000, DEF_STR( Unused ) ) + PORT_DIPNAME( 0x0800, 0x0000, DEF_STR( Unused ) ) PORT_DIPLOCATION("DIP-B:!4") PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0800, DEF_STR( On ) ) - PORT_DIPNAME( 0x3000, 0x0000, DEF_STR( Difficulty ) ) + PORT_DIPNAME( 0x3000, 0x0000, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("DIP-B:!5,!6") PORT_DIPSETTING( 0x1000, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x0000, DEF_STR( Normal ) ) PORT_DIPSETTING( 0x2000, DEF_STR( Hard ) ) - PORT_DIPNAME( 0xc000, 0x0000, DEF_STR( Lives ) ) + PORT_DIPNAME( 0xc000, 0x0000, DEF_STR( Lives ) ) PORT_DIPLOCATION("DIP-B:!7,!8") PORT_DIPSETTING( 0x4000, "2" ) PORT_DIPSETTING( 0x0000, "3" ) PORT_DIPSETTING( 0x8000, "4" ) @@ -436,21 +436,21 @@ static INPUT_PORTS_START( zeropnt2 ) PORT_START("DSW1") /* $80001a.b */ PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00ff0000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_DIPNAME( 0x01000000, 0x01000000, DEF_STR( Free_Play ) ) + PORT_DIPNAME( 0x01000000, 0x01000000, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("DIP-A:1") PORT_DIPSETTING( 0x01000000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x02000000, 0x02000000, "? Coins To Continue ?" ) - PORT_DIPSETTING( 0x00000000, "1" ) - PORT_DIPSETTING( 0x02000000, "2" ) - PORT_DIPNAME( 0x0c000000, 0x0c000000, "Gun Reloading" ) + PORT_DIPNAME( 0x02000000, 0x02000000, "Continue Mode" ) PORT_DIPLOCATION("DIP-A:2") // Doesn't work? + PORT_DIPSETTING( 0x00000000, DEF_STR( Off ) ) // Manual says 'Continue Mode' and defaults to ON but it doesn't appear to do anthing different when on + PORT_DIPSETTING( 0x02000000, DEF_STR( On ) ) // or off and continue with 1 credit is always available regardless. Maybe it wasn't implemented in the code? + PORT_DIPNAME( 0x0c000000, 0x0c000000, "Gun Reloading" ) PORT_DIPLOCATION("DIP-A:3,4") PORT_DIPSETTING( 0x08000000, DEF_STR(No) ) PORT_DIPSETTING( 0x04000000, DEF_STR(Yes) ) PORT_DIPSETTING( 0x0c000000, "Factory Setting" ) // PORT_DIPSETTING( 0x00000000, "unused?" ) - PORT_DIPNAME( 0x10000000, 0x10000000, DEF_STR( Language ) ) + PORT_DIPNAME( 0x10000000, 0x10000000, DEF_STR( Language ) ) PORT_DIPLOCATION("DIP-A:5") PORT_DIPSETTING( 0x10000000, DEF_STR( English ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( Japanese ) ) - PORT_DIPNAME( 0xe0000000, 0xe0000000, DEF_STR( Coinage ) ) + PORT_DIPNAME( 0xe0000000, 0xe0000000, DEF_STR( Coinage ) ) PORT_DIPLOCATION("DIP-A:6,7,8") PORT_DIPSETTING( 0x00000000, DEF_STR( 5C_1C ) ) PORT_DIPSETTING( 0x20000000, DEF_STR( 4C_1C ) ) PORT_DIPSETTING( 0x40000000, DEF_STR( 3C_1C ) ) @@ -463,13 +463,13 @@ static INPUT_PORTS_START( zeropnt2 ) PORT_START("DSW2") /* $80001c.b */ PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x00ff0000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Korean Language" ) + PORT_DIPNAME( 0x01000000, 0x01000000, "Korean Language" ) PORT_DIPLOCATION("DIP-B:1") PORT_DIPSETTING( 0x01000000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x02000000, 0x00000000, DEF_STR( Demo_Sounds ) ) + PORT_DIPNAME( 0x02000000, 0x00000000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("DIP-B:2") PORT_DIPSETTING( 0x02000000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x1c000000, 0x1c000000, DEF_STR( Lives ) ) + PORT_DIPNAME( 0x1c000000, 0x1c000000, DEF_STR( Lives ) ) PORT_DIPLOCATION("DIP-B:3,4,5") PORT_DIPSETTING( 0x10000000, "2" ) PORT_DIPSETTING( 0x0c000000, "3" ) PORT_DIPSETTING( 0x1c000000, "4" ) @@ -478,10 +478,10 @@ static INPUT_PORTS_START( zeropnt2 ) PORT_DIPSETTING( 0x08000000, "4 (duplicate)" ) PORT_DIPSETTING( 0x04000000, "4 (duplicate)" ) PORT_DIPSETTING( 0x00000000, "4 (duplicate)" ) - PORT_DIPNAME( 0x20000000, 0x20000000, DEF_STR( Unknown ) ) + PORT_DIPNAME( 0x20000000, 0x20000000, DEF_STR( Unknown ) ) PORT_DIPLOCATION("DIP-B:6") PORT_DIPSETTING( 0x20000000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0xc0000000, 0xc0000000, DEF_STR( Difficulty ) ) + PORT_DIPNAME( 0xc0000000, 0xc0000000, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("DIP-B:7,8") PORT_DIPSETTING( 0x80000000, DEF_STR( Easy ) ) PORT_DIPSETTING( 0xc0000000, DEF_STR( Normal ) ) PORT_DIPSETTING( 0x40000000, DEF_STR( Harder ) ) @@ -590,7 +590,7 @@ void unico_state::burglarx(machine_config &config) ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.40); ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.40); - OKIM6295(config, m_oki, 32_MHz_XTAL/32, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified + OKIM6295(config, m_oki, 32_MHz_XTAL/32, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 verified m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.80); m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.80); } diff --git a/src/mame/yamaha/ymmu100.cpp b/src/mame/yamaha/ymmu100.cpp index 641beef4794..d82d134770e 100644 --- a/src/mame/yamaha/ymmu100.cpp +++ b/src/mame/yamaha/ymmu100.cpp @@ -127,7 +127,7 @@ #include "cpu/h8/h8s2655.h" #include "mulcd.h" #include "sound/swp30.h" -#include "bus/plg100/plg100.h" +#include "bus/plg1x0/plg1x0.h" #include "debugger.h" #include "speaker.h" @@ -185,8 +185,8 @@ class mu100_state : public driver_device required_device m_maincpu; required_device m_swp30; required_device m_lcd; - required_device m_ext1; - optional_device m_ext2; + required_device m_ext1; + optional_device m_ext2; required_ioport m_ioport_p7; required_ioport m_ioport_p8; @@ -473,7 +473,7 @@ void mu100_state::mu100(machine_config &config) MULCD(config, m_lcd); - PLG100_CONNECTOR(config, m_ext1, plg100_intf, "vl"); + PLG1X0_CONNECTOR(config, m_ext1, plg1x0_intf, nullptr); m_ext1->midi_tx().set(FUNC(mu100_state::e1_tx)); SPEAKER(config, "lspeaker").front_left(); @@ -501,7 +501,7 @@ void mu100r_state::mu100r(machine_config &config) { mu100(config); - PLG100_CONNECTOR(config, m_ext2, plg100_intf, nullptr); + PLG1X0_CONNECTOR(config, m_ext2, plg1x0_intf, nullptr); m_ext2->midi_tx().set(FUNC(mu100r_state::e2_tx)); } diff --git a/src/mame/yamaha/ymmu128.cpp b/src/mame/yamaha/ymmu128.cpp index b0a15fcfc92..8743612aadc 100644 --- a/src/mame/yamaha/ymmu128.cpp +++ b/src/mame/yamaha/ymmu128.cpp @@ -53,25 +53,76 @@ class mu128_state : public driver_device required_device m_sci; required_shared_ptr m_ram; + u16 m_pe; + void map(address_map &map); void swp30_map(address_map &map); virtual void machine_start() override; virtual void machine_reset() override; + + u16 pe_r(); + void pe_w(u16 data); }; - + void mu128_state::machine_start() { + save_item(NAME(m_pe)); + m_pe = 0; } - + void mu128_state::machine_reset() { } +// Port E: +// 0: lcd-r/w +// 1: nc +// 2: lcd-rs +// 3: lcread (secondary functions on lcread edge) +// 4: lcd-e +// 5: 1mclk +// 6: siclk +// 7: sws +// 8-a: db 0-2, lcdc a-c +// b-c: db 3-4, mic/line +// d: db 5, swp reset +// e: db 6, sireset +// f: db 7, breset + +u16 mu128_state::pe_r() +{ + if(BIT(m_pe, 4)) { + if(BIT(m_pe, 0)) { + if(BIT(m_pe, 2)) + return m_lcd->data_read() << 8; + else + return m_lcd->control_read() << 8; + } else + return 0x0000; + } + + return 0; +} + +void mu128_state::pe_w(u16 data) +{ + u16 prev = m_pe; + m_pe = data; + if(BIT(m_pe, 4) && !BIT(prev, 4)) { + if(!BIT(m_pe, 0)) { + if(BIT(m_pe, 2)) + m_lcd->data_write(m_pe >> 8); + else + m_lcd->control_write(m_pe >> 8); + } + } +} + void mu128_state::map(address_map &map) { map(0x000000, 0x1fffff).rom().region("maincpu", 0); - map(0x200000, 0x21ffff).ram().share(m_ram); + map(0x400000, 0x43ffff).ram().share(m_ram); map(0x800000, 0x801fff).m(m_swp30m, FUNC(swp30_device::map)); map(0x802000, 0x803fff).m(m_swp30s, FUNC(swp30_device::map)); map(0xc00000, 0xc00000).rw(m_sci, FUNC(i8251_device::data_r), FUNC(i8251_device::data_w)).mirror(0x3ffffe); @@ -87,6 +138,8 @@ void mu128_state::mu128(machine_config &config) { SH7043(config, m_maincpu, 7_MHz_XTAL * 4); m_maincpu->set_addrmap(AS_PROGRAM, &mu128_state::map); + m_maincpu->read_porte().set(FUNC(mu128_state::pe_r)); + m_maincpu->write_porte().set(FUNC(mu128_state::pe_w)); NVRAM(config, m_nvram, nvram_device::DEFAULT_NONE); diff --git a/src/osd/modules/input/input_common.cpp b/src/osd/modules/input/input_common.cpp index ec9521ab4b8..f3de3ca186e 100644 --- a/src/osd/modules/input/input_common.cpp +++ b/src/osd/modules/input/input_common.cpp @@ -20,7 +20,9 @@ #if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32) #include -#define KEY_TRANS_WIN32(disc, virtual) KEY_##disc, virtual, +#include +#define DIK_UNKNOWN 0xffff // intentionally impossible +#define KEY_TRANS_WIN32(disc, virtual) DIK_##disc, virtual, #else #define KEY_TRANS_WIN32(disc, virtual) #endif @@ -41,147 +43,147 @@ #endif #if defined(OSD_WINDOWS) || defined(OSD_SDL) + key_trans_entry keyboard_trans_table::s_default_table[] = { - // MAME key sdl scancode di scancode virtual key ascii ui - KEY_TRANS_ENTRY0(ESC, ESCAPE, ESCAPE, VK_ESCAPE, 27, "ESCAPE"), - KEY_TRANS_ENTRY1(1, 1, 1, '1', '1'), - KEY_TRANS_ENTRY1(2, 2, 2, '2', '2'), - KEY_TRANS_ENTRY1(3, 3, 3, '3', '3'), - KEY_TRANS_ENTRY1(4, 4, 4, '4', '4'), - KEY_TRANS_ENTRY1(5, 5, 5, '5', '5'), - KEY_TRANS_ENTRY1(6, 6, 6, '6', '6'), - KEY_TRANS_ENTRY1(7, 7, 7, '7', '7'), - KEY_TRANS_ENTRY1(8, 8, 8, '8', '8'), - KEY_TRANS_ENTRY1(9, 9, 9, '9', '9'), - KEY_TRANS_ENTRY1(0, 0, 0, '0', '0'), - KEY_TRANS_ENTRY1(MINUS, MINUS, MINUS, VK_OEM_MINUS, '-'), - KEY_TRANS_ENTRY1(EQUALS, EQUALS, EQUALS, VK_OEM_PLUS, '='), - KEY_TRANS_ENTRY1(BACKSPACE, BACKSPACE, BACK, VK_BACK, 8), - KEY_TRANS_ENTRY1(TAB, TAB, TAB, VK_TAB, 9), - KEY_TRANS_ENTRY1(Q, Q, Q, 'Q', 'Q'), - KEY_TRANS_ENTRY1(W, W, W, 'W', 'W'), - KEY_TRANS_ENTRY1(E, E, E, 'E', 'E'), - KEY_TRANS_ENTRY1(R, R, R, 'R', 'R'), - KEY_TRANS_ENTRY1(T, T, T, 'T', 'T'), - KEY_TRANS_ENTRY1(Y, Y, Y, 'Y', 'Y'), - KEY_TRANS_ENTRY1(U, U, U, 'U', 'U'), - KEY_TRANS_ENTRY1(I, I, I, 'I', 'I'), - KEY_TRANS_ENTRY1(O, O, O, 'O', 'O'), - KEY_TRANS_ENTRY1(P, P, P, 'P', 'P'), - KEY_TRANS_ENTRY1(OPENBRACE, LEFTBRACKET, LBRACKET, VK_OEM_4, '['), - KEY_TRANS_ENTRY1(CLOSEBRACE, RIGHTBRACKET, RBRACKET, VK_OEM_6, ']'), - KEY_TRANS_ENTRY0(ENTER, RETURN, RETURN, VK_RETURN, 13, "RETURN"), - KEY_TRANS_ENTRY1(LCONTROL, LCTRL, LCONTROL, VK_LCONTROL, 0), - KEY_TRANS_ENTRY1(A, A, A, 'A', 'A'), - KEY_TRANS_ENTRY1(S, S, S, 'S', 'S'), - KEY_TRANS_ENTRY1(D, D, D, 'D', 'D'), - KEY_TRANS_ENTRY1(F, F, F, 'F', 'F'), - KEY_TRANS_ENTRY1(G, G, G, 'G', 'G'), - KEY_TRANS_ENTRY1(H, H, H, 'H', 'H'), - KEY_TRANS_ENTRY1(J, J, J, 'J', 'J'), - KEY_TRANS_ENTRY1(K, K, K, 'K', 'K'), - KEY_TRANS_ENTRY1(L, L, L, 'L', 'L'), - KEY_TRANS_ENTRY1(COLON, SEMICOLON, SEMICOLON, VK_OEM_1, ';'), - KEY_TRANS_ENTRY1(QUOTE, APOSTROPHE, APOSTROPHE, VK_OEM_7, '\''), - KEY_TRANS_ENTRY1(TILDE, GRAVE, GRAVE, VK_OEM_3, '`'), - KEY_TRANS_ENTRY1(LSHIFT, LSHIFT, LSHIFT, VK_LSHIFT, 0), - KEY_TRANS_ENTRY1(BACKSLASH, BACKSLASH, BACKSLASH, VK_OEM_5, '\\'), + // MAME key SDL scancode DI scancode virtual key ASCII UI + KEY_TRANS_ENTRY0(ESC, ESCAPE, ESCAPE, VK_ESCAPE, 27, "ESCAPE"), + KEY_TRANS_ENTRY1(1, 1, 1, '1', '1'), + KEY_TRANS_ENTRY1(2, 2, 2, '2', '2'), + KEY_TRANS_ENTRY1(3, 3, 3, '3', '3'), + KEY_TRANS_ENTRY1(4, 4, 4, '4', '4'), + KEY_TRANS_ENTRY1(5, 5, 5, '5', '5'), + KEY_TRANS_ENTRY1(6, 6, 6, '6', '6'), + KEY_TRANS_ENTRY1(7, 7, 7, '7', '7'), + KEY_TRANS_ENTRY1(8, 8, 8, '8', '8'), + KEY_TRANS_ENTRY1(9, 9, 9, '9', '9'), + KEY_TRANS_ENTRY1(0, 0, 0, '0', '0'), + KEY_TRANS_ENTRY1(MINUS, MINUS, MINUS, VK_OEM_MINUS, '-'), + KEY_TRANS_ENTRY1(EQUALS, EQUALS, EQUALS, VK_OEM_PLUS, '='), + KEY_TRANS_ENTRY1(BACKSPACE, BACKSPACE, BACK, VK_BACK, 8), + KEY_TRANS_ENTRY1(TAB, TAB, TAB, VK_TAB, 9), + KEY_TRANS_ENTRY1(Q, Q, Q, 'Q', 'Q'), + KEY_TRANS_ENTRY1(W, W, W, 'W', 'W'), + KEY_TRANS_ENTRY1(E, E, E, 'E', 'E'), + KEY_TRANS_ENTRY1(R, R, R, 'R', 'R'), + KEY_TRANS_ENTRY1(T, T, T, 'T', 'T'), + KEY_TRANS_ENTRY1(Y, Y, Y, 'Y', 'Y'), + KEY_TRANS_ENTRY1(U, U, U, 'U', 'U'), + KEY_TRANS_ENTRY1(I, I, I, 'I', 'I'), + KEY_TRANS_ENTRY1(O, O, O, 'O', 'O'), + KEY_TRANS_ENTRY1(P, P, P, 'P', 'P'), + KEY_TRANS_ENTRY1(OPENBRACE, LEFTBRACKET, LBRACKET, VK_OEM_4, '['), + KEY_TRANS_ENTRY1(CLOSEBRACE, RIGHTBRACKET, RBRACKET, VK_OEM_6, ']'), + KEY_TRANS_ENTRY0(ENTER, RETURN, RETURN, VK_RETURN, 13, "RETURN"), + KEY_TRANS_ENTRY1(LCONTROL, LCTRL, LCONTROL, VK_LCONTROL, 0), + KEY_TRANS_ENTRY1(A, A, A, 'A', 'A'), + KEY_TRANS_ENTRY1(S, S, S, 'S', 'S'), + KEY_TRANS_ENTRY1(D, D, D, 'D', 'D'), + KEY_TRANS_ENTRY1(F, F, F, 'F', 'F'), + KEY_TRANS_ENTRY1(G, G, G, 'G', 'G'), + KEY_TRANS_ENTRY1(H, H, H, 'H', 'H'), + KEY_TRANS_ENTRY1(J, J, J, 'J', 'J'), + KEY_TRANS_ENTRY1(K, K, K, 'K', 'K'), + KEY_TRANS_ENTRY1(L, L, L, 'L', 'L'), + KEY_TRANS_ENTRY1(COLON, SEMICOLON, SEMICOLON, VK_OEM_1, ';'), + KEY_TRANS_ENTRY1(QUOTE, APOSTROPHE, APOSTROPHE, VK_OEM_7, '\''), + KEY_TRANS_ENTRY1(TILDE, GRAVE, GRAVE, VK_OEM_3, '`'), + KEY_TRANS_ENTRY1(LSHIFT, LSHIFT, LSHIFT, VK_LSHIFT, 0), + KEY_TRANS_ENTRY1(BACKSLASH, BACKSLASH, BACKSLASH, VK_OEM_5, '\\'), // KEY_TRANS_ENTRY1(BACKSLASH2, NONUSHASH, UNKNOWN, OEM_102, VK_OEM_102, '<'), // This is the additional key that ISO keyboards have over ANSI ones, located between left shift and Y. - KEY_TRANS_ENTRY1(BACKSLASH2, NONUSBACKSLASH, OEM_102, VK_OEM_102, '<'), - KEY_TRANS_ENTRY1(Z, Z, Z, 'Z', 'Z'), - KEY_TRANS_ENTRY1(X, X, X, 'X', 'X'), - KEY_TRANS_ENTRY1(C, C, C, 'C', 'C'), - KEY_TRANS_ENTRY1(V, V, V, 'V', 'V'), - KEY_TRANS_ENTRY1(B, B, B, 'B', 'B'), - KEY_TRANS_ENTRY1(N, N, N, 'N', 'N'), - KEY_TRANS_ENTRY1(M, M, M, 'M', 'M'), - KEY_TRANS_ENTRY1(COMMA, COMMA, COMMA, VK_OEM_COMMA, ','), - KEY_TRANS_ENTRY1(STOP, PERIOD, PERIOD, VK_OEM_PERIOD, '.'), - KEY_TRANS_ENTRY1(SLASH, SLASH, SLASH, VK_OEM_2, '/'), - KEY_TRANS_ENTRY1(RSHIFT, RSHIFT, RSHIFT, VK_RSHIFT, 0), - KEY_TRANS_ENTRY1(ASTERISK, KP_MULTIPLY, MULTIPLY, VK_MULTIPLY, '*'), - KEY_TRANS_ENTRY1(LALT, LALT, LMENU, VK_LMENU, 0), - KEY_TRANS_ENTRY1(SPACE, SPACE, SPACE, VK_SPACE, ' '), - KEY_TRANS_ENTRY1(CAPSLOCK, CAPSLOCK, CAPITAL, VK_CAPITAL, 0), - KEY_TRANS_ENTRY1(F1, F1, F1, VK_F1, 0), - KEY_TRANS_ENTRY1(F2, F2, F2, VK_F2, 0), - KEY_TRANS_ENTRY1(F3, F3, F3, VK_F3, 0), - KEY_TRANS_ENTRY1(F4, F4, F4, VK_F4, 0), - KEY_TRANS_ENTRY1(F5, F5, F5, VK_F5, 0), - KEY_TRANS_ENTRY1(F6, F6, F6, VK_F6, 0), - KEY_TRANS_ENTRY1(F7, F7, F7, VK_F7, 0), - KEY_TRANS_ENTRY1(F8, F8, F8, VK_F8, 0), - KEY_TRANS_ENTRY1(F9, F9, F9, VK_F9, 0), - KEY_TRANS_ENTRY1(F10, F10, F10, VK_F10, 0), - KEY_TRANS_ENTRY1(NUMLOCK, NUMLOCKCLEAR, NUMLOCK, VK_NUMLOCK, 0), - KEY_TRANS_ENTRY1(SCRLOCK, SCROLLLOCK, SCROLL, VK_SCROLL, 0), - KEY_TRANS_ENTRY1(7_PAD, KP_7, NUMPAD7, VK_NUMPAD7, 0), - KEY_TRANS_ENTRY1(8_PAD, KP_8, NUMPAD8, VK_NUMPAD8, 0), - KEY_TRANS_ENTRY1(9_PAD, KP_9, NUMPAD9, VK_NUMPAD9, 0), - KEY_TRANS_ENTRY1(MINUS_PAD, KP_MINUS, SUBTRACT, VK_SUBTRACT, 0), - KEY_TRANS_ENTRY1(4_PAD, KP_4, NUMPAD4, VK_NUMPAD4, 0), - KEY_TRANS_ENTRY1(5_PAD, KP_5, NUMPAD5, VK_NUMPAD5, 0), - KEY_TRANS_ENTRY1(6_PAD, KP_6, NUMPAD6, VK_NUMPAD6, 0), - KEY_TRANS_ENTRY1(PLUS_PAD, KP_PLUS, ADD, VK_ADD, 0), - KEY_TRANS_ENTRY1(1_PAD, KP_1, NUMPAD1, VK_NUMPAD1, 0), - KEY_TRANS_ENTRY1(2_PAD, KP_2, NUMPAD2, VK_NUMPAD2, 0), - KEY_TRANS_ENTRY1(3_PAD, KP_3, NUMPAD3, VK_NUMPAD3, 0), - KEY_TRANS_ENTRY1(0_PAD, KP_0, NUMPAD0, VK_NUMPAD0, 0), - KEY_TRANS_ENTRY1(DEL_PAD, KP_PERIOD, DECIMAL, VK_DECIMAL, 0), - KEY_TRANS_ENTRY1(F11, F11, F11, VK_F11, 0), - KEY_TRANS_ENTRY1(F12, F12, F12, VK_F12, 0), - KEY_TRANS_ENTRY1(F13, F13, F13, VK_F13, 0), - KEY_TRANS_ENTRY1(F14, F14, F14, VK_F14, 0), - KEY_TRANS_ENTRY1(F15, F15, F15, VK_F15, 0), - KEY_TRANS_ENTRY1(ENTER_PAD, KP_ENTER, NUMPADENTER, VK_RETURN, 0), - KEY_TRANS_ENTRY1(RCONTROL, RCTRL, RCONTROL, VK_RCONTROL, 0), - KEY_TRANS_ENTRY1(SLASH_PAD, KP_DIVIDE, DIVIDE, VK_DIVIDE, 0), - KEY_TRANS_ENTRY1(PRTSCR, PRINTSCREEN, SYSRQ, 0, 0), - KEY_TRANS_ENTRY1(RALT, RALT, RMENU, VK_RMENU, 0), - KEY_TRANS_ENTRY1(HOME, HOME, HOME, VK_HOME, 0), - KEY_TRANS_ENTRY1(UP, UP, UP, VK_UP, 0), - KEY_TRANS_ENTRY1(PGUP, PAGEUP, PRIOR, VK_PRIOR, 0), - KEY_TRANS_ENTRY1(LEFT, LEFT, LEFT, VK_LEFT, 0), - KEY_TRANS_ENTRY1(RIGHT, RIGHT, RIGHT, VK_RIGHT, 0), - KEY_TRANS_ENTRY1(END, END, END, VK_END, 0), - KEY_TRANS_ENTRY1(DOWN, DOWN, DOWN, VK_DOWN, 0), - KEY_TRANS_ENTRY1(PGDN, PAGEDOWN, NEXT, VK_NEXT, 0), - KEY_TRANS_ENTRY1(INSERT, INSERT, INSERT, VK_INSERT, 0), - KEY_TRANS_ENTRY0(DEL, DELETE, DELETE, VK_DELETE, 0, "DELETE"), - KEY_TRANS_ENTRY1(LWIN, LGUI, LWIN, VK_LWIN, 0), - KEY_TRANS_ENTRY1(RWIN, RGUI, RWIN, VK_RWIN, 0), - KEY_TRANS_ENTRY1(MENU, MENU, APPS, VK_APPS, 0), - KEY_TRANS_ENTRY1(PAUSE, PAUSE, PAUSE, VK_PAUSE, 0), - KEY_TRANS_ENTRY0(CANCEL, CANCEL, UNKNOWN, 0, 0, "CANCEL"), - KEY_TRANS_ENTRY1(BS_PAD, KP_BACKSPACE, UNKNOWN, 0, 0), - KEY_TRANS_ENTRY1(TAB_PAD, KP_TAB, UNKNOWN, 0, 0), - KEY_TRANS_ENTRY1(00_PAD, KP_00, UNKNOWN, 0, 0), - KEY_TRANS_ENTRY1(000_PAD, KP_000, UNKNOWN, 0, 0), - KEY_TRANS_ENTRY1(COMMA_PAD, KP_COMMA, NUMPADCOMMA, 0, 0), - KEY_TRANS_ENTRY1(EQUALS_PAD, KP_EQUALS, NUMPADEQUALS, 0, 0), - - // New keys introduced in Windows 2000. These have no MAME codes to - // preserve compatibility with old config files that may refer to them - // as e.g. FORWARD instead of e.g. KEYCODE_WEBFORWARD. They need table - // entries anyway because otherwise they aren't recognized when - // GetAsyncKeyState polling is used (as happens currently when MAME is - // paused). Some codes are missing because the mapping to vkey codes - // isn't clear, and MapVirtualKey is no help. - KEY_TRANS_ENTRY1(OTHER_SWITCH, MUTE, MUTE, VK_VOLUME_MUTE, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, VOLUMEDOWN, VOLUMEDOWN, VK_VOLUME_DOWN, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, VOLUMEUP, VOLUMEUP, VK_VOLUME_UP, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_HOME, WEBHOME, VK_BROWSER_HOME, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_SEARCH, WEBSEARCH, VK_BROWSER_SEARCH, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_BOOKMARKS, WEBFAVORITES, VK_BROWSER_FAVORITES, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_REFRESH, WEBREFRESH, VK_BROWSER_REFRESH, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_STOP, WEBSTOP, VK_BROWSER_STOP, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_FORWARD, WEBFORWARD, VK_BROWSER_FORWARD, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, AC_BACK, WEBBACK, VK_BROWSER_BACK, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, MAIL, MAIL, VK_LAUNCH_MAIL, 0), - KEY_TRANS_ENTRY1(OTHER_SWITCH, MEDIASELECT, MEDIASELECT, VK_LAUNCH_MEDIA_SELECT, 0), - KEY_TRANS_ENTRY0(INVALID, UNKNOWN, ESCAPE, 0, 0, "INVALID") + KEY_TRANS_ENTRY1(BACKSLASH2, NONUSBACKSLASH, OEM_102, VK_OEM_102, '<'), + KEY_TRANS_ENTRY1(Z, Z, Z, 'Z', 'Z'), + KEY_TRANS_ENTRY1(X, X, X, 'X', 'X'), + KEY_TRANS_ENTRY1(C, C, C, 'C', 'C'), + KEY_TRANS_ENTRY1(V, V, V, 'V', 'V'), + KEY_TRANS_ENTRY1(B, B, B, 'B', 'B'), + KEY_TRANS_ENTRY1(N, N, N, 'N', 'N'), + KEY_TRANS_ENTRY1(M, M, M, 'M', 'M'), + KEY_TRANS_ENTRY1(COMMA, COMMA, COMMA, VK_OEM_COMMA, ','), + KEY_TRANS_ENTRY1(STOP, PERIOD, PERIOD, VK_OEM_PERIOD, '.'), + KEY_TRANS_ENTRY1(SLASH, SLASH, SLASH, VK_OEM_2, '/'), + KEY_TRANS_ENTRY1(RSHIFT, RSHIFT, RSHIFT, VK_RSHIFT, 0), + KEY_TRANS_ENTRY1(ASTERISK, KP_MULTIPLY, MULTIPLY, VK_MULTIPLY, '*'), + KEY_TRANS_ENTRY1(LALT, LALT, LMENU, VK_LMENU, 0), + KEY_TRANS_ENTRY1(SPACE, SPACE, SPACE, VK_SPACE, ' '), + KEY_TRANS_ENTRY1(CAPSLOCK, CAPSLOCK, CAPITAL, VK_CAPITAL, 0), + KEY_TRANS_ENTRY1(F1, F1, F1, VK_F1, 0), + KEY_TRANS_ENTRY1(F2, F2, F2, VK_F2, 0), + KEY_TRANS_ENTRY1(F3, F3, F3, VK_F3, 0), + KEY_TRANS_ENTRY1(F4, F4, F4, VK_F4, 0), + KEY_TRANS_ENTRY1(F5, F5, F5, VK_F5, 0), + KEY_TRANS_ENTRY1(F6, F6, F6, VK_F6, 0), + KEY_TRANS_ENTRY1(F7, F7, F7, VK_F7, 0), + KEY_TRANS_ENTRY1(F8, F8, F8, VK_F8, 0), + KEY_TRANS_ENTRY1(F9, F9, F9, VK_F9, 0), + KEY_TRANS_ENTRY1(F10, F10, F10, VK_F10, 0), + KEY_TRANS_ENTRY1(NUMLOCK, NUMLOCKCLEAR, NUMLOCK, VK_NUMLOCK, 0), + KEY_TRANS_ENTRY1(SCRLOCK, SCROLLLOCK, SCROLL, VK_SCROLL, 0), + KEY_TRANS_ENTRY1(7_PAD, KP_7, NUMPAD7, VK_NUMPAD7, 0), + KEY_TRANS_ENTRY1(8_PAD, KP_8, NUMPAD8, VK_NUMPAD8, 0), + KEY_TRANS_ENTRY1(9_PAD, KP_9, NUMPAD9, VK_NUMPAD9, 0), + KEY_TRANS_ENTRY1(MINUS_PAD, KP_MINUS, SUBTRACT, VK_SUBTRACT, 0), + KEY_TRANS_ENTRY1(4_PAD, KP_4, NUMPAD4, VK_NUMPAD4, 0), + KEY_TRANS_ENTRY1(5_PAD, KP_5, NUMPAD5, VK_NUMPAD5, 0), + KEY_TRANS_ENTRY1(6_PAD, KP_6, NUMPAD6, VK_NUMPAD6, 0), + KEY_TRANS_ENTRY1(PLUS_PAD, KP_PLUS, ADD, VK_ADD, 0), + KEY_TRANS_ENTRY1(1_PAD, KP_1, NUMPAD1, VK_NUMPAD1, 0), + KEY_TRANS_ENTRY1(2_PAD, KP_2, NUMPAD2, VK_NUMPAD2, 0), + KEY_TRANS_ENTRY1(3_PAD, KP_3, NUMPAD3, VK_NUMPAD3, 0), + KEY_TRANS_ENTRY1(0_PAD, KP_0, NUMPAD0, VK_NUMPAD0, 0), + KEY_TRANS_ENTRY1(DEL_PAD, KP_PERIOD, DECIMAL, VK_DECIMAL, 0), + KEY_TRANS_ENTRY1(F11, F11, F11, VK_F11, 0), + KEY_TRANS_ENTRY1(F12, F12, F12, VK_F12, 0), + KEY_TRANS_ENTRY1(F13, F13, F13, VK_F13, 0), + KEY_TRANS_ENTRY1(F14, F14, F14, VK_F14, 0), + KEY_TRANS_ENTRY1(F15, F15, F15, VK_F15, 0), + KEY_TRANS_ENTRY1(ENTER_PAD, KP_ENTER, NUMPADENTER, VK_RETURN, 0), + KEY_TRANS_ENTRY1(RCONTROL, RCTRL, RCONTROL, VK_RCONTROL, 0), + KEY_TRANS_ENTRY1(SLASH_PAD, KP_DIVIDE, DIVIDE, VK_DIVIDE, 0), + KEY_TRANS_ENTRY1(PRTSCR, PRINTSCREEN, SYSRQ, 0, 0), + KEY_TRANS_ENTRY1(RALT, RALT, RMENU, VK_RMENU, 0), + KEY_TRANS_ENTRY1(HOME, HOME, HOME, VK_HOME, 0), + KEY_TRANS_ENTRY1(UP, UP, UP, VK_UP, 0), + KEY_TRANS_ENTRY1(PGUP, PAGEUP, PRIOR, VK_PRIOR, 0), + KEY_TRANS_ENTRY1(LEFT, LEFT, LEFT, VK_LEFT, 0), + KEY_TRANS_ENTRY1(RIGHT, RIGHT, RIGHT, VK_RIGHT, 0), + KEY_TRANS_ENTRY1(END, END, END, VK_END, 0), + KEY_TRANS_ENTRY1(DOWN, DOWN, DOWN, VK_DOWN, 0), + KEY_TRANS_ENTRY1(PGDN, PAGEDOWN, NEXT, VK_NEXT, 0), + KEY_TRANS_ENTRY1(INSERT, INSERT, INSERT, VK_INSERT, 0), + KEY_TRANS_ENTRY0(DEL, DELETE, DELETE, VK_DELETE, 0, "DELETE"), + KEY_TRANS_ENTRY1(LWIN, LGUI, LWIN, VK_LWIN, 0), + KEY_TRANS_ENTRY1(RWIN, RGUI, RWIN, VK_RWIN, 0), + KEY_TRANS_ENTRY1(MENU, MENU, APPS, VK_APPS, 0), + KEY_TRANS_ENTRY1(PAUSE, PAUSE, PAUSE, VK_PAUSE, 0), + KEY_TRANS_ENTRY1(CANCEL, CANCEL, UNKNOWN, 0, 0), + KEY_TRANS_ENTRY1(BS_PAD, KP_BACKSPACE, UNKNOWN, 0, 0), + KEY_TRANS_ENTRY1(TAB_PAD, KP_TAB, UNKNOWN, 0, 0), + KEY_TRANS_ENTRY1(00_PAD, KP_00, UNKNOWN, 0, 0), + KEY_TRANS_ENTRY1(000_PAD, KP_000, UNKNOWN, 0, 0), + KEY_TRANS_ENTRY1(COMMA_PAD, KP_COMMA, NUMPADCOMMA, VK_SEPARATOR, 0), + KEY_TRANS_ENTRY1(EQUALS_PAD, KP_EQUALS, NUMPADEQUALS, VK_OEM_NEC_EQUAL, 0), + + // keys that have no specific MAME input item IDs + KEY_TRANS_ENTRY0(OTHER_SWITCH, AUDIONEXT, NEXTTRACK, VK_MEDIA_NEXT_TRACK, 0, "AUDIONEXT"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AUDIOMUTE, MUTE, VK_VOLUME_MUTE, 0, "VOLUMEMUTE"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AUDIOPLAY, PLAYPAUSE, VK_MEDIA_PLAY_PAUSE, 0, "AUDIOPLAY"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AUDIOSTOP, MEDIASTOP, VK_MEDIA_STOP, 0, "AUDIOSTOP"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, VOLUMEDOWN, VOLUMEDOWN, VK_VOLUME_DOWN, 0, "VOLUMEDOWN"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, VOLUMEUP, VOLUMEUP, VK_VOLUME_UP, 0, "VOLUMEUP"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_HOME, WEBHOME, VK_BROWSER_HOME, 0, "NAVHOME"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_SEARCH, WEBSEARCH, VK_BROWSER_SEARCH, 0, "NAVSEARCH"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_BOOKMARKS, WEBFAVORITES, VK_BROWSER_FAVORITES, 0, "NAVFAVORITES"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_REFRESH, WEBREFRESH, VK_BROWSER_REFRESH, 0, "NAVREFRESH"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_STOP, WEBSTOP, VK_BROWSER_STOP, 0, "NAVSTOP"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_FORWARD, WEBFORWARD, VK_BROWSER_FORWARD, 0, "NAVFORWARD"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, AC_BACK, WEBBACK, VK_BROWSER_BACK, 0, "NAVBACK"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, MAIL, MAIL, VK_LAUNCH_MAIL, 0, "MAIL"), + KEY_TRANS_ENTRY0(OTHER_SWITCH, MEDIASELECT, MEDIASELECT, VK_LAUNCH_MEDIA_SELECT, 0, "MEDIASEL"), + + // sentinel + KEY_TRANS_ENTRY0(INVALID, UNKNOWN, UNKNOWN, 0, 0, "INVALID") }; // The private constructor to create the default instance @@ -190,14 +192,18 @@ keyboard_trans_table::keyboard_trans_table() m_table = s_default_table; m_table_size = std::size(s_default_table); } -#else + +#else // defined(OSD_WINDOWS) || defined(OSD_SDL) + keyboard_trans_table::keyboard_trans_table() { m_table = nullptr; m_table_size = 0; } -#endif +#endif // defined(OSD_WINDOWS) || defined(OSD_SDL) + + // public constructor to allow creation of non-default instances keyboard_trans_table::keyboard_trans_table(std::unique_ptr entries, unsigned int size) { @@ -248,11 +254,10 @@ int keyboard_trans_table::vkey_for_mame_code(input_code code) const // only works for keyboard switches if (code.device_class() == DEVICE_CLASS_KEYBOARD && code.item_class() == ITEM_CLASS_SWITCH) { - input_item_id id = code.item_id(); - int tablenum; + const input_item_id id = code.item_id(); // scan the table for a match - for (tablenum = 0; tablenum < m_table_size; tablenum++) + for (int tablenum = 0; tablenum < m_table_size; tablenum++) if (m_table[tablenum].mame_key == id) return m_table[tablenum].virtual_key; } diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index e767d2b07f2..28e53fb0ccb 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -47,155 +47,6 @@ enum #define MAX_HATS 8 #define MAX_POV 4 -/**************************************************************************** -* DirectInput compatible keyboard scan codes -****************************************************************************/ -#define KEY_UNKNOWN 0x00 -#define KEY_ESCAPE 0x01 -#define KEY_1 0x02 -#define KEY_2 0x03 -#define KEY_3 0x04 -#define KEY_4 0x05 -#define KEY_5 0x06 -#define KEY_6 0x07 -#define KEY_7 0x08 -#define KEY_8 0x09 -#define KEY_9 0x0A -#define KEY_0 0x0B -#define KEY_MINUS 0x0C /* - on main keyboard */ -#define KEY_EQUALS 0x0D -#define KEY_BACK 0x0E /* backspace */ -#define KEY_TAB 0x0F -#define KEY_Q 0x10 -#define KEY_W 0x11 -#define KEY_E 0x12 -#define KEY_R 0x13 -#define KEY_T 0x14 -#define KEY_Y 0x15 -#define KEY_U 0x16 -#define KEY_I 0x17 -#define KEY_O 0x18 -#define KEY_P 0x19 -#define KEY_LBRACKET 0x1A -#define KEY_RBRACKET 0x1B -#define KEY_RETURN 0x1C /* Enter on main keyboard */ -#define KEY_LCONTROL 0x1D -#define KEY_A 0x1E -#define KEY_S 0x1F -#define KEY_D 0x20 -#define KEY_F 0x21 -#define KEY_G 0x22 -#define KEY_H 0x23 -#define KEY_J 0x24 -#define KEY_K 0x25 -#define KEY_L 0x26 -#define KEY_SEMICOLON 0x27 -#define KEY_APOSTROPHE 0x28 -#define KEY_GRAVE 0x29 /* accent grave */ -#define KEY_LSHIFT 0x2A -#define KEY_BACKSLASH 0x2B -#define KEY_Z 0x2C -#define KEY_X 0x2D -#define KEY_C 0x2E -#define KEY_V 0x2F -#define KEY_B 0x30 -#define KEY_N 0x31 -#define KEY_M 0x32 -#define KEY_COMMA 0x33 -#define KEY_PERIOD 0x34 /* . on main keyboard */ -#define KEY_SLASH 0x35 /* / on main keyboard */ -#define KEY_RSHIFT 0x36 -#define KEY_MULTIPLY 0x37 /* * on numeric keypad */ -#define KEY_LMENU 0x38 /* left Alt */ -#define KEY_SPACE 0x39 -#define KEY_CAPITAL 0x3A -#define KEY_F1 0x3B -#define KEY_F2 0x3C -#define KEY_F3 0x3D -#define KEY_F4 0x3E -#define KEY_F5 0x3F -#define KEY_F6 0x40 -#define KEY_F7 0x41 -#define KEY_F8 0x42 -#define KEY_F9 0x43 -#define KEY_F10 0x44 -#define KEY_NUMLOCK 0x45 -#define KEY_SCROLL 0x46 /* Scroll Lock */ -#define KEY_NUMPAD7 0x47 -#define KEY_NUMPAD8 0x48 -#define KEY_NUMPAD9 0x49 -#define KEY_SUBTRACT 0x4A /* - on numeric keypad */ -#define KEY_NUMPAD4 0x4B -#define KEY_NUMPAD5 0x4C -#define KEY_NUMPAD6 0x4D -#define KEY_ADD 0x4E /* + on numeric keypad */ -#define KEY_NUMPAD1 0x4F -#define KEY_NUMPAD2 0x50 -#define KEY_NUMPAD3 0x51 -#define KEY_NUMPAD0 0x52 -#define KEY_DECIMAL 0x53 /* . on numeric keypad */ -#define KEY_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ -#define KEY_F11 0x57 -#define KEY_F12 0x58 -#define KEY_F13 0x64 /* (NEC PC98) */ -#define KEY_F14 0x65 /* (NEC PC98) */ -#define KEY_F15 0x66 /* (NEC PC98) */ -#define KEY_KANA 0x70 /* (Japanese keyboard) */ -#define KEY_ABNT_C1 0x73 /* /? on Brazilian keyboard */ -#define KEY_CONVERT 0x79 /* (Japanese keyboard) */ -#define KEY_NOCONVERT 0x7B /* (Japanese keyboard) */ -#define KEY_YEN 0x7D /* (Japanese keyboard) */ -#define KEY_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ -#define KEY_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define KEY_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ -#define KEY_AT 0x91 /* (NEC PC98) */ -#define KEY_COLON 0x92 /* (NEC PC98) */ -#define KEY_UNDERLINE 0x93 /* (NEC PC98) */ -#define KEY_KANJI 0x94 /* (Japanese keyboard) */ -#define KEY_STOP 0x95 /* (NEC PC98) */ -#define KEY_AX 0x96 /* (Japan AX) */ -#define KEY_UNLABELED 0x97 /* (J3100) */ -#define KEY_NEXTTRACK 0x99 /* Next Track */ -#define KEY_NUMPADENTER 0x9C /* Enter on numeric keypad */ -#define KEY_RCONTROL 0x9D -#define KEY_MUTE 0xA0 /* Mute */ -#define KEY_CALCULATOR 0xA1 /* Calculator */ -#define KEY_PLAYPAUSE 0xA2 /* Play / Pause */ -#define KEY_MEDIASTOP 0xA4 /* Media Stop */ -#define KEY_VOLUMEDOWN 0xAE /* Volume - */ -#define KEY_VOLUMEUP 0xB0 /* Volume + */ -#define KEY_WEBHOME 0xB2 /* Web home */ -#define KEY_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ -#define KEY_DIVIDE 0xB5 /* / on numeric keypad */ -#define KEY_SYSRQ 0xB7 -#define KEY_RMENU 0xB8 /* right Alt */ -#define KEY_PAUSE 0xC5 /* Pause */ -#define KEY_HOME 0xC7 /* Home on arrow keypad */ -#define KEY_UP 0xC8 /* UpArrow on arrow keypad */ -#define KEY_PRIOR 0xC9 /* PgUp on arrow keypad */ -#define KEY_LEFT 0xCB /* LeftArrow on arrow keypad */ -#define KEY_RIGHT 0xCD /* RightArrow on arrow keypad */ -#define KEY_END 0xCF /* End on arrow keypad */ -#define KEY_DOWN 0xD0 /* DownArrow on arrow keypad */ -#define KEY_NEXT 0xD1 /* PgDn on arrow keypad */ -#define KEY_INSERT 0xD2 /* Insert on arrow keypad */ -#define KEY_DELETE 0xD3 /* Delete on arrow keypad */ -#define KEY_LWIN 0xDB /* Left Windows key */ -#define KEY_RWIN 0xDC /* Right Windows key */ -#define KEY_APPS 0xDD /* AppMenu key */ -#define KEY_POWER 0xDE /* System Power */ -#define KEY_SLEEP 0xDF /* System Sleep */ -#define KEY_WAKE 0xE3 /* System Wake */ -#define KEY_WEBSEARCH 0xE5 /* Web Search */ -#define KEY_WEBFAVORITES 0xE6 /* Web Favorites */ -#define KEY_WEBREFRESH 0xE7 /* Web Refresh */ -#define KEY_WEBSTOP 0xE8 /* Web Stop */ -#define KEY_WEBFORWARD 0xE9 /* Web Forward */ -#define KEY_WEBBACK 0xEA /* Web Back */ -#define KEY_MYCOMPUTER 0xEB /* My Computer */ -#define KEY_MAIL 0xEC /* Mail */ -#define KEY_MEDIASELECT 0xED /* Media Select */ - //============================================================ // device_info @@ -342,7 +193,7 @@ struct key_trans_entry int sdl_scancode; #endif #if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32) - int scan_code; + uint16_t scan_code; unsigned char virtual_key; #endif diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index eec5904b3ac..7732d610bba 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -194,7 +194,7 @@ void dinput_keyboard_device::configure(input_device &device) { // populate it char defname[20]; - for (int keynum = 0; keynum < MAX_KEYS; keynum++) + for (unsigned keynum = 0; keynum < MAX_KEYS; keynum++) { input_item_id itemid = keyboard_trans_table::instance().map_di_scancode_to_itemid(keynum); diff --git a/src/osd/modules/input/input_rawinput.cpp b/src/osd/modules/input/input_rawinput.cpp index 3ee8e2d8f7e..3b5491fd09d 100644 --- a/src/osd/modules/input/input_rawinput.cpp +++ b/src/osd/modules/input/input_rawinput.cpp @@ -25,9 +25,11 @@ #include #include +#include #include #include #include +#include // standard windows headers #include @@ -307,23 +309,75 @@ class rawinput_keyboard_device : public rawinput_device public: rawinput_keyboard_device(std::string &&name, std::string &&id, input_module &module, HANDLE handle) : rawinput_device(std::move(name), std::move(id), module, handle), + m_pause_pressed(std::chrono::steady_clock::time_point::min()), + m_e1(0xffff), m_keyboard({ { 0 } }) { } virtual void reset() override { + m_pause_pressed = std::chrono::steady_clock::time_point::min(); memset(&m_keyboard, 0, sizeof(m_keyboard)); + m_e1 = 0xffff; + } + + virtual void poll(bool relative_reset) override + { + rawinput_device::poll(relative_reset); + + if (m_keyboard.state[0x80 | 0x45] && (std::chrono::steady_clock::now() > (m_pause_pressed + std::chrono::milliseconds(30)))) + m_keyboard.state[0x80 | 0x45] = 0x00; } virtual void process_event(RAWINPUT const &rawinput) override { // determine the full DIK-compatible scancode - uint8_t scancode = (rawinput.data.keyboard.MakeCode & 0x7f) | ((rawinput.data.keyboard.Flags & RI_KEY_E0) ? 0x80 : 0x00); + uint8_t scancode; - // scancode 0xaa is a special shift code we need to ignore - if (scancode == 0xaa) + // the only thing that uses this is Pause + if (rawinput.data.keyboard.Flags & RI_KEY_E1) + { + m_e1 = rawinput.data.keyboard.MakeCode; return; + } + else if (0xffff != m_e1) + { + auto const e1 = std::exchange(m_e1, 0xffff); + if (!(rawinput.data.keyboard.Flags & RI_KEY_E0)) + { + if (((e1 & ~USHORT(0x80)) == 0x1d) && ((rawinput.data.keyboard.MakeCode & ~USHORT(0x80)) == 0x45)) + { + if (rawinput.data.keyboard.Flags & RI_KEY_BREAK) + return; // RawInput generates a fake break immediately after the make - ignore it + + m_pause_pressed = std::chrono::steady_clock::now(); + scancode = 0x80 | 0x45; + } + else + { + return; // no idea + } + } + else + { + return; // shouldn't happen, ignore it + } + } + else + { + // strip bit 7 of the make code to work around dodgy drivers that set it for key up events + if (rawinput.data.keyboard.MakeCode & ~USHORT(0xff)) + { + // won't fit in a byte along with the E0 flag + return; + } + scancode = (rawinput.data.keyboard.MakeCode & 0x7f) | ((rawinput.data.keyboard.Flags & RI_KEY_E0) ? 0x80 : 0x00); + + // fake shift generated with cursor control and Ins/Del for compatibility with very old DOS software + if (scancode == 0xaa) + return; + } // set or clear the key m_keyboard.state[scancode] = (rawinput.data.keyboard.Flags & RI_KEY_BREAK) ? 0x00 : 0x80; @@ -333,13 +387,20 @@ class rawinput_keyboard_device : public rawinput_device { keyboard_trans_table const &table = keyboard_trans_table::instance(); - for (int keynum = 0; keynum < MAX_KEYS; keynum++) + // FIXME: GetKeyNameTextW is for scan codes from WM_KEYDOWN, which aren't quite the same as DIK_* keycodes + // in particular, NumLock and Pause are reversed for US-style keyboard systems + for (unsigned keynum = 0; keynum < MAX_KEYS; keynum++) { input_item_id itemid = table.map_di_scancode_to_itemid(keynum); WCHAR keyname[100]; // generate the name - if (GetKeyNameTextW(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, std::size(keyname)) == 0) + // FIXME: GetKeyNameText gives bogus names for media keys and various other things + // in many cases it ignores the "extended" bit and returns the key name corresponding to the scan code alone + LONG lparam = ((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17); + if ((keynum & 0x7f) == 0x45) + lparam ^= 0x0100'0000; // horrid hack + if (GetKeyNameTextW(lparam, keyname, std::size(keyname)) == 0) _snwprintf(keyname, std::size(keyname), L"Scan%03d", keynum); std::string name = text::from_wstring(keyname); @@ -354,6 +415,8 @@ class rawinput_keyboard_device : public rawinput_device } private: + std::chrono::steady_clock::time_point m_pause_pressed; + uint16_t m_e1; keyboard_state m_keyboard; }; diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 1eaed99f16b..fb478511a99 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -617,13 +617,8 @@ class sdl_keyboard_device : public sdl_device for (int keynum = 0; m_trans_table[keynum].mame_key != ITEM_ID_INVALID; keynum++) { input_item_id itemid = m_trans_table[keynum].mame_key; - - // generate the default / modified name - char defname[20]; - snprintf(defname, sizeof(defname) - 1, "%s", m_trans_table[keynum].ui_name); - device.add_item( - defname, + m_trans_table[keynum].ui_name, std::string_view(), itemid, generic_button_get_state, @@ -1977,8 +1972,7 @@ class sdl_keyboard_module : public sdl_input_module { public: sdl_keyboard_module() : - sdl_input_module(OSD_KEYBOARDINPUT_PROVIDER, "sdl"), - m_key_trans_table(nullptr) + sdl_input_module(OSD_KEYBOARDINPUT_PROVIDER, "sdl") { } @@ -1993,7 +1987,7 @@ class sdl_keyboard_module : public sdl_input_module subscribe(osd(), event_types); // Read our keymap and store a pointer to our table - m_key_trans_table = sdlinput_read_keymap(); + sdlinput_read_keymap(); osd_printf_verbose("Keyboard: Start initialization\n"); @@ -2009,12 +2003,27 @@ class sdl_keyboard_module : public sdl_input_module } private: - keyboard_trans_table *sdlinput_read_keymap() + void sdlinput_read_keymap() { keyboard_trans_table &default_table = keyboard_trans_table::instance(); + // Allocate a block of translation entries big enough to hold what's in the default table + auto key_trans_entries = std::make_unique(default_table.size()); + + // copy the elements from the default table and ask SDL for key names + for (int i = 0; i < default_table.size(); i++) + { + key_trans_entries[i] = default_table[i]; + char const *const name = SDL_GetScancodeName(SDL_Scancode(default_table[i].sdl_scancode)); + if (name && *name) + key_trans_entries[i].ui_name = name; + } + + // Allocate the trans table to be associated with the machine so we don't have to free it + m_key_trans_table = std::make_unique(std::move(key_trans_entries), default_table.size()); + if (!options()->bool_value(SDLOPTION_KEYMAP)) - return &default_table; + return; const char *const keymap_filename = dynamic_cast(*options()).keymap_file(); osd_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename); @@ -2023,19 +2032,9 @@ class sdl_keyboard_module : public sdl_input_module if (!keymap_file) { osd_printf_warning("Keymap: Unable to open keymap %s, using default\n", keymap_filename); - return &default_table; + return; } - // Allocate a block of translation entries big enough to hold what's in the default table - auto key_trans_entries = std::make_unique(default_table.size()); - - // copy the elements from the default table - for (int i = 0; i < default_table.size(); i++) - key_trans_entries[i] = default_table[i]; - - // Allocate the trans table to be associated with the machine so we don't have to free it - m_custom_table = std::make_unique(std::move(key_trans_entries), default_table.size()); - int line = 1; int sdl2section = 0; while (!feof(keymap_file)) @@ -2068,7 +2067,7 @@ class sdl_keyboard_module : public sdl_input_module if (sk >= 0 && index >= 0) { - key_trans_entry &entry = (*m_custom_table)[index]; + key_trans_entry &entry = (*m_key_trans_table)[index]; entry.sdl_scancode = sk; entry.ui_name = const_cast(m_ui_names.emplace_back(kns).c_str()); osd_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns); @@ -2083,12 +2082,9 @@ class sdl_keyboard_module : public sdl_input_module } fclose(keymap_file); osd_printf_verbose("Keymap: Processed %d lines\n", line); - - return m_custom_table.get(); } - keyboard_trans_table *m_key_trans_table; - std::unique_ptr m_custom_table; + std::unique_ptr m_key_trans_table; std::list m_ui_names; }; diff --git a/src/osd/modules/input/input_win32.cpp b/src/osd/modules/input/input_win32.cpp index 6919c8d5c42..3803bc2a180 100644 --- a/src/osd/modules/input/input_win32.cpp +++ b/src/osd/modules/input/input_win32.cpp @@ -59,6 +59,8 @@ class win32_keyboard_device : public event_based_device TCHAR keyname[100]; // generate the name + // FIXME: GetKeyNameText gives bogus names for media keys and various other things + // in many cases it ignores the "extended" bit and returns the key name corresponding to the scan code alone if (GetKeyNameText(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, std::size(keyname)) == 0) _sntprintf(keyname, std::size(keyname), TEXT("Scan%03d"), keynum); std::string name = text::from_tstring(keyname); diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index f7d88a6b6a0..4eb229584dd 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -31,10 +31,10 @@ #include "modules/monitor/monitor_common.h" -#define NOT_ALREADY_DOWN(x) (x & 0x40000000) == 0 +#define NOT_ALREADY_DOWN(x) ((x & 0x40000000) == 0) #define SCAN_CODE(x) ((x >> 16) & 0xff) -#define IS_EXTENDED(x) (0x01000000 & x) -#define MAKE_DI_SCAN(scan, isextended) (scan & 0x7f) | (isextended ? 0x80 : 0x00) +#define IS_EXTENDED(x) ((x >> 24) & 0x01) +#define MAKE_DI_SCAN(scan, isextended) ((scan & 0x7f) | (isextended ? 0x80 : 0x00)) #define WINOSD(machine) downcast(&machine.osd()) //============================================================