summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine
diff options
context:
space:
mode:
author angelosa <salese_corp_ltd@email.it>2018-05-17 20:28:08 +0200
committer angelosa <salese_corp_ltd@email.it>2018-05-17 21:55:09 +0200
commitf74f8b29dc59d3e0789ce22586013abca89d0c07 (patch)
tree494ee6dbf59eea018d22a316e4eef3a084b9253e /src/mame/machine
parent91c61667b8361b8c90e036bd0da4f7ceb9ef0aae (diff)
dc-ctrl.cpp: preliminary keyboard emulation, hooked up to The Typing of the Dead, La Keyboard and Lupin the Typing on Naomi [Angelo Salese]
new WORKING machines -------------------- Capcom vs SNK Pro [Samuele Zannoli, R. Belmont, ElSemi, David Haywood, Angelo Salese, Olivier Galibert, MetalliC] Cleopatra Fortune Plus [Samuele Zannoli, R. Belmont, ElSemi, David Haywood, Angelo Salese, Olivier Galibert, MetalliC]
Diffstat (limited to 'src/mame/machine')
-rw-r--r--src/mame/machine/dc-ctrl.cpp102
-rw-r--r--src/mame/machine/dc-ctrl.h36
-rw-r--r--src/mame/machine/naomi.cpp34
3 files changed, 172 insertions, 0 deletions
diff --git a/src/mame/machine/dc-ctrl.cpp b/src/mame/machine/dc-ctrl.cpp
index a24a84cfd6a..56a14ca3b4f 100644
--- a/src/mame/machine/dc-ctrl.cpp
+++ b/src/mame/machine/dc-ctrl.cpp
@@ -3,6 +3,12 @@
#include "emu.h"
#include "dc-ctrl.h"
+/*******************************
+ *
+ * Dreamcast Controller
+ *
+ ******************************/
+
DEFINE_DEVICE_TYPE(DC_CONTROLLER, dc_controller_device, "dcctrl", "Dreamcast Controller")
dc_controller_device::dc_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
@@ -48,6 +54,7 @@ void dc_controller_device::maple_w(const uint32_t *data, uint32_t in_size)
void dc_controller_device::fixed_status(uint32_t *dest)
{
+ // TODO: is this right? should be 0x01000000
dest[0] = 0x20000000; // Controller
dest[1] =
((port[2] != nullptr) ? 0x010000 : 0) |
@@ -73,6 +80,7 @@ void dc_controller_device::free_status(uint32_t *dest)
void dc_controller_device::read(uint32_t *dest)
{
+ // TODO: is this right? should be 0x01000000
dest[0] = 0x21000000; // Controller
dest[1] =
(port[0] ? port[0]->read() : 0xff) |
@@ -95,3 +103,97 @@ void dc_controller_device::device_start()
port[i] = ioport(port_tag[i]);
}
}
+
+/*******************************
+ *
+ * Dreamcast Keyboard
+ *
+ ******************************/
+
+DEFINE_DEVICE_TYPE(DC_KEYBOARD, dc_keyboard_device, "dckb", "Dreamcast Keyboard")
+
+dc_keyboard_device::dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ maple_device(mconfig, DC_KEYBOARD, tag, owner, clock)
+{
+ memset(port_tag, 0, sizeof(port_tag));
+
+ id = "92key Keyboard for JPN";
+ license = "Produced By or Under License From SEGA ENTERPRISES,LTD.";
+ versions = "Version 1.000,1998/06/12,315-6215-AD ,Key Scan Module: The 1st Edition. 05/20";
+}
+
+void dc_keyboard_device::maple_w(const uint32_t *data, uint32_t in_size)
+{
+ switch(data[0] & 0xff) {
+ case 0x01: // Device request
+ reply_start(5, 0x20, 29);
+ fixed_status(reply_buffer+1);
+ reply_ready_with_delay();
+ break;
+
+ case 0x02: // All status request
+ reply_start(6, 0x20, 49);
+ fixed_status(reply_buffer+1);
+ free_status(reply_buffer+29);
+ reply_ready_with_delay();
+ break;
+
+ case 0x03: // reset - we're stateless where it matters
+ reply_start(7, 0x20, 0);
+ reply_ready_with_delay();
+ break;
+
+ case 0x09: // get condition
+ if(1 || (in_size >= 2 && data[1] == 0x01000000)) {
+ reply_start(8, 0x20, 4);
+ read(reply_buffer+1);
+ reply_ready_with_delay();
+ }
+ break;
+ }
+}
+
+void dc_keyboard_device::fixed_status(uint32_t *dest)
+{
+ // 00000040 00102000 0800000000000000000
+ dest[0] = 0x40000000; // Keyboard
+ dest[1] = 0x00201000; // 1st function
+ dest[2] = 0x00000008; // No 2nd function
+ dest[3] = 0x00000000; // No 3rd function
+ dest[4] = 0x00000002; // Japan region
+ copy_with_spaces(((uint8_t *)dest) + 18, id, 30);
+ copy_with_spaces(((uint8_t *)dest) + 48, license, 60);
+ dest[27] = 0x0190015e; // standby 35mA, max 40mA
+}
+
+void dc_keyboard_device::free_status(uint32_t *dest)
+{
+ copy_with_spaces((uint8_t *)dest, versions, 80);
+}
+
+void dc_keyboard_device::read(uint32_t *dest)
+{
+ dest[0] = 0x40000000; // Keyboard
+ // key code
+ dest[1] =
+ (port[0] ? port[0]->read() : 0) |
+ ((port[1] ? port[1]->read() : 0) << 8) |
+ ((port[2] ? port[2]->read() : 0) << 16) |
+ ((port[3] ? port[3]->read() : 0) << 24);
+ dest[2] =
+ (port[4] ? port[4]->read() : 0) |
+ ((port[5] ? port[5]->read() : 0) << 8) |
+ ((port[6] ? port[6]->read() : 0) << 16) |
+ ((port[7] ? port[7]->read() : 0) << 24);
+}
+
+void dc_keyboard_device::device_start()
+{
+ maple_device::device_start();
+
+ for (int i = 0; i < 8; i++)
+ {
+ port[i] = ioport(port_tag[i]);
+ }
+}
+
diff --git a/src/mame/machine/dc-ctrl.h b/src/mame/machine/dc-ctrl.h
index fa809478bf7..6d994289b70 100644
--- a/src/mame/machine/dc-ctrl.h
+++ b/src/mame/machine/dc-ctrl.h
@@ -55,6 +55,42 @@ private:
ioport_port *port[8];
};
+#define MCFG_DC_KEYBOARD_ADD(_tag, _host_tag, _host_port, d0, d1, a0, a1, a2, a3, a4, a5) \
+ MCFG_MAPLE_DEVICE_ADD(_tag, DC_KEYBOARD, 0, _host_tag, _host_port) \
+ downcast<dc_controller_device &>(*device).set_port_tag(0, d0); \
+ downcast<dc_controller_device &>(*device).set_port_tag(1, d1); \
+ downcast<dc_controller_device &>(*device).set_port_tag(2, a0); \
+ downcast<dc_controller_device &>(*device).set_port_tag(3, a1); \
+ downcast<dc_controller_device &>(*device).set_port_tag(4, a2); \
+ downcast<dc_controller_device &>(*device).set_port_tag(5, a3); \
+ downcast<dc_controller_device &>(*device).set_port_tag(6, a4); \
+ downcast<dc_controller_device &>(*device).set_port_tag(7, a5);
+
+
+class dc_keyboard_device : public maple_device
+{
+public:
+ // construction/destruction
+ dc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ void maple_w(const uint32_t *data, uint32_t in_size) override;
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+private:
+ void fixed_status(uint32_t *dest);
+ void free_status(uint32_t *dest);
+ void read(uint32_t *dest);
+
+ const char *port_tag[8];
+ const char *id, *license, *versions;
+
+ ioport_port *port[8];
+};
+
DECLARE_DEVICE_TYPE(DC_CONTROLLER, dc_controller_device)
+DECLARE_DEVICE_TYPE(DC_KEYBOARD, dc_keyboard_device)
#endif // MAME_MACHINE_DC_CTRL_H
diff --git a/src/mame/machine/naomi.cpp b/src/mame/machine/naomi.cpp
index 477cd889962..dcaf49d86ac 100644
--- a/src/mame/machine/naomi.cpp
+++ b/src/mame/machine/naomi.cpp
@@ -229,6 +229,7 @@ INPUT_CHANGED_MEMBER(naomi_state::naomi_mp_w)
{
m_mp_mux = newval;
}
+
CUSTOM_INPUT_MEMBER(naomi_state::naomi_mp_r)
{
const char *tagptr = (const char *)param;
@@ -247,6 +248,39 @@ CUSTOM_INPUT_MEMBER(naomi_state::naomi_mp_r)
return retval;
}
+CUSTOM_INPUT_MEMBER(naomi_state::naomi_kb_r)
+{
+ // TODO: player 2 input reading
+// const int *tagptr = (const int *)param;
+ uint8_t retval = 0;
+ static const char *const keynames[] =
+ {
+ "P1.ROW0", "P1.ROW1", "P1.ROW2", "P1.ROW3", "P1.ROW4"
+ };
+
+ for(int i=0;i<5;i++)
+ {
+ uint32_t row;
+
+ // read the current row
+ row = ioport(keynames[i])->read();
+
+ // if anything is pressed, convert the 32-bit raw value to keycode
+ if(row != 0)
+ {
+ // base value x20
+ retval = i * 0x20;
+ for(int j=0;j<32;j++)
+ {
+ if(row & 1 << j)
+ return retval + j;
+ }
+ }
+ }
+
+ return retval;
+}
+
void naomi_state::init_naomi_mp()
{
//m_maincpu->space(AS_PROGRAM).install_read_handler(0xc2ad238, 0xc2ad23f, read64_delegate(FUNC(naomi_state::naomi_biose_idle_skip_r),this); // rev e bios