summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author MooglyGuy <therealmogminer@gmail.com>2019-01-20 05:12:08 +0100
committer MooglyGuy <therealmogminer@gmail.com>2019-01-20 05:12:08 +0100
commit953d9737d4519b19c9d2d77bfa175ad246889337 (patch)
tree0766d1096dbd8ce22ee79ea2b75e4f2f62580d60
parent53bf06db84459010c1c4571121994940c3b323e7 (diff)
-vsmile: Converted to use slot devices for controllers. Breaks controller input. Checkin in so Vas can look at it, nw
-rw-r--r--scripts/src/bus.lua4
-rw-r--r--src/devices/bus/vsmile/joystick.cpp46
-rw-r--r--src/devices/bus/vsmile/joystick.h39
-rw-r--r--src/devices/bus/vsmile/pad.cpp203
-rw-r--r--src/devices/bus/vsmile/pad.h78
-rw-r--r--src/devices/bus/vsmile/vsmile_ctrl.cpp4
-rw-r--r--src/mame/drivers/vsmile.cpp200
7 files changed, 301 insertions, 273 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 82280e51d1c..29c9f459fa1 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -3278,10 +3278,10 @@ if (BUSES["VSMILE"]~=null) then
files {
MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.cpp",
MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.h",
+ MAME_DIR .. "src/devices/bus/vsmile/pad.cpp",
+ MAME_DIR .. "src/devices/bus/vsmile/pad.h",
MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.cpp",
MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.h",
- MAME_DIR .. "src/devices/bus/vsmile/joystick.cpp",
- MAME_DIR .. "src/devices/bus/vsmile/joystick.h",
MAME_DIR .. "src/devices/bus/vsmile/rom.cpp",
MAME_DIR .. "src/devices/bus/vsmile/rom.h",
}
diff --git a/src/devices/bus/vsmile/joystick.cpp b/src/devices/bus/vsmile/joystick.cpp
deleted file mode 100644
index b3be2f25ce3..00000000000
--- a/src/devices/bus/vsmile/joystick.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-
-#include "emu.h"
-#include "joystick.h"
-
-
-//**************************************************************************
-// GLOBAL VARIABLES
-//**************************************************************************
-
-DEFINE_DEVICE_TYPE(VSMILE_JOYSTICK, vsmile_joystick_device, "vsmile_joystick", "V.Smile Joystick Controller")
-
-
-//**************************************************************************
-// V.Smile joystick controller
-//**************************************************************************
-
-vsmile_joystick_device::vsmile_joystick_device(
- machine_config const &mconfig,
- char const *tag,
- device_t *owner,
- uint32_t clock)
- : device_t(mconfig, VSMILE_JOYSTICK, tag, owner, clock)
- , device_vsmile_ctrl_interface(mconfig, *this)
-{
-}
-
-vsmile_joystick_device::~vsmile_joystick_device()
-{
-}
-
-void vsmile_joystick_device::device_start()
-{
- // TODO: initialise and register save state
-}
-
-void vsmile_joystick_device::cts_w(int state)
-{
- // TODO: CTS input changed
-}
-
-void vsmile_joystick_device::data_w(uint8_t data)
-{
- // TODO: data arrived
-}
diff --git a/src/devices/bus/vsmile/joystick.h b/src/devices/bus/vsmile/joystick.h
deleted file mode 100644
index 4fde270925f..00000000000
--- a/src/devices/bus/vsmile/joystick.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz
-#ifndef MAME_BUS_VSMILE_JOYSTICK_H
-#define MAME_BUS_VSMILE_JOYSTICK_H
-
-#pragma once
-
-#include "vsmile_ctrl.h"
-
-/***************************************************************************
- TYPE DEFINITIONS
- ***************************************************************************/
-
-// ======================> vsmile_joystick_device
-
-class vsmile_joystick_device : public device_t, public device_vsmile_ctrl_interface
-{
-public:
- // construction/destruction
- vsmile_joystick_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U);
- virtual ~vsmile_joystick_device();
-
-protected:
- // device_t implementation
- virtual void device_start() override;
-
- // device_vsmile_ctrl_interface implementation
- virtual void cts_w(int state) override;
- virtual void data_w(uint8_t data) override;
-};
-
-
-/***************************************************************************
- DEVICE TYPES
- ***************************************************************************/
-
-DECLARE_DEVICE_TYPE(VSMILE_JOYSTICK, vsmile_joystick_device)
-
-#endif // MAME_BUS_VSMILE_JOYSTICK_H
diff --git a/src/devices/bus/vsmile/pad.cpp b/src/devices/bus/vsmile/pad.cpp
new file mode 100644
index 00000000000..f2230c23f0d
--- /dev/null
+++ b/src/devices/bus/vsmile/pad.cpp
@@ -0,0 +1,203 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+
+#include "emu.h"
+#include "pad.h"
+
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(VSMILE_PAD, vsmile_pad_device, "vsmile_pad", "V.Smile Control Pad")
+
+
+//**************************************************************************
+// V.Smile control pad
+//**************************************************************************
+
+vsmile_pad_device::vsmile_pad_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, VSMILE_PAD, tag, owner, clock)
+ , device_vsmile_ctrl_interface(mconfig, *this)
+ , m_io_joy(*this, "JOY")
+ , m_io_colors(*this, "COLORS")
+ , m_io_buttons(*this, "BUTTONS")
+ , m_uart_tx_timer(nullptr)
+ , m_pad_timer(nullptr)
+{
+}
+
+vsmile_pad_device::~vsmile_pad_device()
+{
+}
+
+void vsmile_pad_device::device_start()
+{
+ m_pad_timer = timer_alloc(TIMER_PAD);
+ m_pad_timer->adjust(attotime::never);
+
+ m_uart_tx_timer = timer_alloc(TIMER_UART_TX);
+ m_uart_tx_timer->adjust(attotime::never);
+
+ save_item(NAME(m_ctrl_cts));
+ save_item(NAME(m_ctrl_probe_history));
+ save_item(NAME(m_ctrl_probe_count));
+ save_item(NAME(m_uart_tx_fifo));
+ save_item(NAME(m_uart_tx_fifo_start));
+ save_item(NAME(m_uart_tx_fifo_end));
+ save_item(NAME(m_uart_tx_fifo_count));
+}
+
+void vsmile_pad_device::device_reset()
+{
+ m_pad_timer->adjust(attotime::from_hz(1), 0, attotime::from_hz(1));
+ m_uart_tx_timer->adjust(attotime::from_hz(9600/10), 0, attotime::from_hz(9600/10));
+
+ m_ctrl_cts = false;
+ memset(m_ctrl_probe_history, 0, 2);
+ m_ctrl_probe_count = 0;
+ memset(m_uart_tx_fifo, 0, 32);
+ m_uart_tx_fifo_start = 0;
+ m_uart_tx_fifo_end = 0;
+ m_uart_tx_fifo_count = 0;
+ m_uart_tx_state = XMIT_STATE_IDLE;
+}
+
+void vsmile_pad_device::cts_w(int state)
+{
+ printf("Pad CTS: %d\n", state);
+ if (m_uart_tx_state == XMIT_STATE_RTS)
+ m_uart_tx_state = XMIT_STATE_CTS;
+}
+
+void vsmile_pad_device::data_w(uint8_t data)
+{
+ printf("Pad Receiving: %02x\n", data);
+ if ((data >> 4) == 7 || (data >> 4) == 11)
+ {
+ m_ctrl_probe_history[0] = m_ctrl_probe_history[1];
+ m_ctrl_probe_history[1] = data;
+ const uint8_t response = ((m_ctrl_probe_history[0] + m_ctrl_probe_history[1] + 0x0f) & 0x0f) ^ 0x05;
+ uart_tx_fifo_push(0xb0 | response);
+ }
+}
+
+void vsmile_pad_device::uart_tx_fifo_push(uint8_t data)
+{
+ if (m_uart_tx_fifo_count == ARRAY_LENGTH(m_uart_tx_fifo))
+ {
+ logerror("Warning: Trying to push more than %d bytes onto the controller Tx FIFO, data will be lost\n", ARRAY_LENGTH(m_uart_tx_fifo));
+ }
+
+ printf("Pushing %02x\n", data);
+ m_uart_tx_fifo[m_uart_tx_fifo_end] = data;
+ m_uart_tx_fifo_count++;
+ m_uart_tx_fifo_end = (m_uart_tx_fifo_end + 1) % ARRAY_LENGTH(m_uart_tx_fifo);
+}
+
+void vsmile_pad_device::handle_uart_tx()
+{
+ if (m_uart_tx_fifo_count == 0)
+ return;
+
+ if (m_uart_tx_state == XMIT_STATE_IDLE)
+ {
+ m_uart_tx_state = XMIT_STATE_RTS;
+ printf("Setting RTS\n");
+ rts_out(1);
+ return;
+ }
+
+ printf("Transmitting %02x\n", m_uart_tx_fifo[m_uart_tx_fifo_start]);
+ data_out(m_uart_tx_fifo[m_uart_tx_fifo_start]);
+ m_uart_tx_fifo_start = (m_uart_tx_fifo_start + 1) % ARRAY_LENGTH(m_uart_tx_fifo);
+ m_uart_tx_fifo_count--;
+ if (m_uart_tx_fifo_count == 0)
+ {
+ m_uart_tx_state = XMIT_STATE_IDLE;
+ printf("Clearing RTS\n");
+ rts_out(0);
+ }
+}
+
+void vsmile_pad_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+{
+ switch (id)
+ {
+ case TIMER_UART_TX:
+ handle_uart_tx();
+ break;
+ case TIMER_PAD:
+ uart_tx_fifo_push(0x55);
+ break;
+ default:
+ logerror("Unknown timer ID: %d\n", id);
+ break;
+ }
+}
+
+INPUT_CHANGED_MEMBER(vsmile_pad_device::pad_joy_changed)
+{
+ const uint8_t value = m_io_joy->read();
+
+ if (BIT(value, 2))
+ uart_tx_fifo_push(0xcf);
+ else if (BIT(value, 3))
+ uart_tx_fifo_push(0xc7);
+ else
+ uart_tx_fifo_push(0xc0);
+
+ if (BIT(value, 0))
+ uart_tx_fifo_push(0x87);
+ else if (BIT(value, 1))
+ uart_tx_fifo_push(0x8f);
+ else
+ uart_tx_fifo_push(0x80);
+}
+
+INPUT_CHANGED_MEMBER(vsmile_pad_device::pad_color_changed)
+{
+ uart_tx_fifo_push(0x90 | m_io_colors->read());
+}
+
+INPUT_CHANGED_MEMBER(vsmile_pad_device::pad_button_changed)
+{
+ const uint8_t value = m_io_buttons->read();
+ const size_t bit = reinterpret_cast<size_t>(param);
+ if (BIT(value, bit))
+ {
+ uart_tx_fifo_push(0xa1 + (uint8_t)bit);
+ }
+ else
+ {
+ uart_tx_fifo_push(0xa0);
+ }
+}
+
+static INPUT_PORTS_START( vsmile_pad )
+ PORT_START("JOY")
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_joy_changed, 0) PORT_NAME("Joypad Up")
+ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_joy_changed, 0) PORT_NAME("Joypad Down")
+ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_joy_changed, 0) PORT_NAME("Joypad Left")
+ PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_joy_changed, 0) PORT_NAME("Joypad Right")
+ PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
+
+ PORT_START("COLORS")
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_color_changed, 0) PORT_NAME("Green")
+ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_color_changed, 0) PORT_NAME("Blue")
+ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_color_changed, 0) PORT_NAME("Yellow")
+ PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_color_changed, 0) PORT_NAME("Red")
+ PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
+
+ PORT_START("BUTTONS")
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_button_changed, 0) PORT_NAME("OK")
+ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_button_changed, 1) PORT_NAME("Quit")
+ PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_button_changed, 2) PORT_NAME("Help")
+ PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_pad_device, pad_button_changed, 3) PORT_NAME("ABC")
+ PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
+INPUT_PORTS_END
+
+ioport_constructor vsmile_pad_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( vsmile_pad );
+}
diff --git a/src/devices/bus/vsmile/pad.h b/src/devices/bus/vsmile/pad.h
new file mode 100644
index 00000000000..1cf68a3fda2
--- /dev/null
+++ b/src/devices/bus/vsmile/pad.h
@@ -0,0 +1,78 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+#ifndef MAME_BUS_VSMILE_PAD_H
+#define MAME_BUS_VSMILE_PAD_H
+
+#pragma once
+
+#include "vsmile_ctrl.h"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+ ***************************************************************************/
+
+// ======================> vsmile_pad_device
+
+class vsmile_pad_device : public device_t, public device_vsmile_ctrl_interface
+{
+public:
+ // construction/destruction
+ vsmile_pad_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0U);
+ virtual ~vsmile_pad_device();
+
+ DECLARE_INPUT_CHANGED_MEMBER(pad_joy_changed);
+ DECLARE_INPUT_CHANGED_MEMBER(pad_color_changed);
+ DECLARE_INPUT_CHANGED_MEMBER(pad_button_changed);
+
+protected:
+ // device_t implementation
+ virtual void device_start() override;
+ virtual void device_reset() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+
+ // optional information overrides
+ virtual ioport_constructor device_input_ports() const override;
+
+ // device_vsmile_ctrl_interface implementation
+ virtual void cts_w(int state) override;
+ virtual void data_w(uint8_t data) override;
+
+private:
+ static const device_timer_id TIMER_UART_TX = 0;
+ static const device_timer_id TIMER_PAD = 1;
+
+ enum
+ {
+ XMIT_STATE_IDLE = 0,
+ XMIT_STATE_RTS = 1,
+ XMIT_STATE_CTS = 2
+ };
+
+ void uart_tx_fifo_push(uint8_t data);
+ void handle_uart_tx();
+
+ required_ioport m_io_joy;
+ required_ioport m_io_colors;
+ required_ioport m_io_buttons;
+
+ bool m_ctrl_cts;
+ uint8_t m_ctrl_probe_history[2];
+ uint8_t m_ctrl_probe_count;
+ uint8_t m_uart_tx_fifo[32]; // arbitrary size
+ uint8_t m_uart_tx_fifo_start;
+ uint8_t m_uart_tx_fifo_end;
+ uint8_t m_uart_tx_fifo_count;
+ emu_timer *m_uart_tx_timer;
+ int m_uart_tx_state;
+
+ emu_timer *m_pad_timer;
+};
+
+
+/***************************************************************************
+ DEVICE TYPES
+ ***************************************************************************/
+
+DECLARE_DEVICE_TYPE(VSMILE_PAD, vsmile_pad_device)
+
+#endif // MAME_BUS_VSMILE_PAD_H
diff --git a/src/devices/bus/vsmile/vsmile_ctrl.cpp b/src/devices/bus/vsmile/vsmile_ctrl.cpp
index c30f47384d9..21f4dfa4aea 100644
--- a/src/devices/bus/vsmile/vsmile_ctrl.cpp
+++ b/src/devices/bus/vsmile/vsmile_ctrl.cpp
@@ -103,9 +103,9 @@ void vsmile_ctrl_port_device::device_start()
}
-#include "joystick.h"
+#include "pad.h"
void vsmile_controllers(device_slot_interface &device)
{
- device.option_add("joy", VSMILE_JOYSTICK);
+ device.option_add("pad", VSMILE_PAD);
}
diff --git a/src/mame/drivers/vsmile.cpp b/src/mame/drivers/vsmile.cpp
index 14159f6aa5c..466a40bbefb 100644
--- a/src/mame/drivers/vsmile.cpp
+++ b/src/mame/drivers/vsmile.cpp
@@ -65,28 +65,15 @@ public:
: vsmile_base_state(mconfig, type, tag)
, m_cart(*this, "cartslot")
, m_ctrl(*this, "ctrl%u", 1U)
- , m_io_joy(*this, "JOY")
- , m_io_colors(*this, "COLORS")
- , m_io_buttons(*this, "BUTTONS")
, m_dsw_region(*this, "REGION")
- , m_uart_tx_timer(nullptr)
- , m_pad_timer(nullptr)
{ }
void vsmile(machine_config &config);
void vsmilep(machine_config &config);
- DECLARE_INPUT_CHANGED_MEMBER(pad_joy_changed);
- DECLARE_INPUT_CHANGED_MEMBER(pad_color_changed);
- DECLARE_INPUT_CHANGED_MEMBER(pad_button_changed);
-
private:
virtual void machine_start() override;
virtual void machine_reset() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
-
- static const device_timer_id TIMER_UART_TX = 0;
- static const device_timer_id TIMER_PAD = 1;
void banked_map(address_map &map);
@@ -97,8 +84,6 @@ private:
DECLARE_WRITE8_MEMBER(chip_sel_w);
DECLARE_WRITE8_MEMBER(uart_rx);
- void uart_tx_fifo_push(uint8_t data);
- void handle_uart_tx();
DECLARE_READ16_MEMBER(bank3_r);
@@ -118,31 +103,14 @@ private:
VSMILE_PORTC_TEST = 0x20,
VSMILE_PORTC_AMP = 0x40,
VSMILE_PORTC_SYSRESET = 0x80,
-
- XMIT_STATE_IDLE = 0,
- XMIT_STATE_RTS = 1,
- XMIT_STATE_CTS = 2
};
required_device<vsmile_cart_slot_device> m_cart;
required_device_array<vsmile_ctrl_port_device, 2> m_ctrl;
- required_ioport m_io_joy;
- required_ioport m_io_colors;
- required_ioport m_io_buttons;
required_ioport m_dsw_region;
- bool m_ctrl_cts[2];
bool m_ctrl_rts[2];
- uint8_t m_ctrl_probe_history[2];
- uint8_t m_ctrl_probe_count;
- uint8_t m_uart_tx_fifo[32]; // arbitrary size
- uint8_t m_uart_tx_fifo_start;
- uint8_t m_uart_tx_fifo_end;
- uint8_t m_uart_tx_fifo_count;
- emu_timer *m_uart_tx_timer;
- int m_uart_tx_state;
-
- emu_timer *m_pad_timer;
+ bool m_ctrl_cts[2];
};
class vsmileb_state : public vsmile_base_state
@@ -204,100 +172,23 @@ void vsmile_state::machine_start()
m_bankdev->set_bank(m_cart && m_cart->exists() ? 4 : 0);
- m_pad_timer = timer_alloc(TIMER_PAD);
- m_pad_timer->adjust(attotime::never);
-
- m_uart_tx_timer = timer_alloc(TIMER_UART_TX);
- m_uart_tx_timer->adjust(attotime::never);
-
- save_item(NAME(m_ctrl_cts));
save_item(NAME(m_ctrl_rts));
- save_item(NAME(m_ctrl_probe_history));
- save_item(NAME(m_ctrl_probe_count));
- save_item(NAME(m_uart_tx_fifo));
- save_item(NAME(m_uart_tx_fifo_start));
- save_item(NAME(m_uart_tx_fifo_end));
- save_item(NAME(m_uart_tx_fifo_count));
+ save_item(NAME(m_ctrl_cts));
}
void vsmile_state::machine_reset()
{
- m_pad_timer->adjust(attotime::from_hz(1), 0, attotime::from_hz(1));
- m_uart_tx_timer->adjust(attotime::from_hz(9600/10), 0, attotime::from_hz(9600/10));
-
- memset(m_ctrl_cts, 0, sizeof(bool) * 2);
memset(m_ctrl_rts, 0, sizeof(bool) * 2);
- memset(m_ctrl_probe_history, 0, 2);
- m_ctrl_probe_count = 0;
- memset(m_uart_tx_fifo, 0, 32);
- m_uart_tx_fifo_start = 0;
- m_uart_tx_fifo_end = 0;
- m_uart_tx_fifo_count = 0;
- m_uart_tx_state = XMIT_STATE_IDLE;
-}
-
-void vsmile_state::uart_tx_fifo_push(uint8_t data)
-{
- if (m_uart_tx_fifo_count == ARRAY_LENGTH(m_uart_tx_fifo))
- {
- logerror("Warning: Trying to push more than %d bytes onto the controller Tx FIFO, data will be lost\n", ARRAY_LENGTH(m_uart_tx_fifo));
- }
-
- m_uart_tx_fifo[m_uart_tx_fifo_end] = data;
- m_uart_tx_fifo_count++;
- m_uart_tx_fifo_end = (m_uart_tx_fifo_end + 1) % ARRAY_LENGTH(m_uart_tx_fifo);
-}
-
-void vsmile_state::handle_uart_tx()
-{
- if (m_uart_tx_fifo_count == 0)
- return;
-
- if (m_uart_tx_state == XMIT_STATE_IDLE)
- {
- m_uart_tx_state = XMIT_STATE_RTS;
- m_ctrl_rts[0] = true;
- m_spg->extint_w(0, true);
- return;
- }
-
- m_spg->uart_rx(m_uart_tx_fifo[m_uart_tx_fifo_start]);
- m_uart_tx_fifo_start = (m_uart_tx_fifo_start + 1) % ARRAY_LENGTH(m_uart_tx_fifo);
- m_uart_tx_fifo_count--;
- if (m_uart_tx_fifo_count == 0)
- {
- m_uart_tx_state = XMIT_STATE_IDLE;
- m_ctrl_rts[0] = false;
- m_spg->extint_w(0, false);
- //m_uart_tx_timer->adjust(attotime::never);
- }
+ memset(m_ctrl_cts, 0, sizeof(bool) * 2);
}
WRITE8_MEMBER(vsmile_state::uart_rx)
{
- if ((data >> 4) == 7 || (data >> 4) == 11)
- {
- m_ctrl_probe_history[0] = m_ctrl_probe_history[1];
- m_ctrl_probe_history[1] = data;
- const uint8_t response = ((m_ctrl_probe_history[0] + m_ctrl_probe_history[1] + 0x0f) & 0x0f) ^ 0x05;
- uart_tx_fifo_push(0xb0 | response);
- }
-}
-
-void vsmile_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
-{
- switch (id)
- {
- case TIMER_UART_TX:
- handle_uart_tx();
- break;
- case TIMER_PAD:
- uart_tx_fifo_push(0x55);
- break;
- default:
- logerror("Unknown timer ID: %d\n", id);
- break;
- }
+ printf("Receiving %02x\n", data);
+ if (m_ctrl_cts[0])
+ m_ctrl[0]->data_w(data);
+ if (m_ctrl_cts[1])
+ m_ctrl[1]->data_w(data);
}
READ16_MEMBER(vsmile_state::bank3_r)
@@ -325,50 +216,12 @@ WRITE16_MEMBER(vsmile_state::portc_w)
if (BIT(mem_mask, 8))
{
m_ctrl_cts[0] = BIT(data, 8);
- if (m_uart_tx_state == XMIT_STATE_RTS)
- m_uart_tx_state = XMIT_STATE_CTS;
+ m_ctrl[0]->cts_w(m_ctrl_cts[0]);
}
if (BIT(mem_mask, 9))
{
- m_ctrl_cts[1] = BIT(data, 9);
- }
-}
-
-INPUT_CHANGED_MEMBER(vsmile_state::pad_joy_changed)
-{
- const uint8_t value = m_io_joy->read();
-
- if (BIT(value, 2))
- uart_tx_fifo_push(0xcf);
- else if (BIT(value, 3))
- uart_tx_fifo_push(0xc7);
- else
- uart_tx_fifo_push(0xc0);
-
- if (BIT(value, 0))
- uart_tx_fifo_push(0x87);
- else if (BIT(value, 1))
- uart_tx_fifo_push(0x8f);
- else
- uart_tx_fifo_push(0x80);
-}
-
-INPUT_CHANGED_MEMBER(vsmile_state::pad_color_changed)
-{
- uart_tx_fifo_push(0x90 | m_io_colors->read());
-}
-
-INPUT_CHANGED_MEMBER(vsmile_state::pad_button_changed)
-{
- const uint8_t value = m_io_buttons->read();
- const size_t bit = reinterpret_cast<size_t>(param);
- if (BIT(value, bit))
- {
- uart_tx_fifo_push(0xa1 + (uint8_t)bit);
- }
- else
- {
- uart_tx_fifo_push(0xa0);
+ m_ctrl_cts[1] = BIT(data, 8);
+ m_ctrl[1]->cts_w(m_ctrl_cts[1]);
}
}
@@ -514,27 +367,6 @@ void vsmileb_state::banked_map(address_map &map)
************************************/
static INPUT_PORTS_START( vsmile )
- PORT_START("JOY")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Up")
- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Down")
- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Left")
- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_joy_changed, 0) PORT_NAME("Joypad Right")
- PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
-
- PORT_START("COLORS")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Green")
- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Blue")
- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Yellow")
- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_color_changed, 0) PORT_NAME("Red")
- PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
-
- PORT_START("BUTTONS")
- PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 0) PORT_NAME("OK")
- PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 1) PORT_NAME("Quit")
- PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 2) PORT_NAME("Help")
- PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(1) PORT_CHANGED_MEMBER(DEVICE_SELF, vsmile_state, pad_button_changed, 3) PORT_NAME("ABC")
- PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
-
PORT_START("REGION")
PORT_DIPNAME( 0x0f, 0x04, "BIOS Region" )
PORT_DIPSETTING( 0x04, "UK/US" )
@@ -605,13 +437,13 @@ void vsmile_state::vsmile(machine_config &config)
VSMILE_CART_SLOT(config, m_cart, vsmile_cart, nullptr);
- VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "joy");
- m_ctrl[0]->rts_cb().set([this] (int state) { logerror("controller 1 RTS: %d\n", state); });
- m_ctrl[0]->data_cb().set([this] (int data) { logerror("controller 1 data: %02X\n", data); });
+ VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "pad");
+ m_ctrl[0]->rts_cb().set([this] (int state) { m_ctrl_rts[0] = state; printf("Ctrl0 RTS: %d\n", state); });
+ m_ctrl[0]->data_cb().set([this] (uint8_t data) { m_spg->uart_rx(data); printf("Ctrl0 UART Tx: %02X\n", data); });
VSMILE_CTRL_PORT(config, m_ctrl[1], vsmile_controllers, nullptr);
- m_ctrl[1]->rts_cb().set([this] (int state) { logerror("controller 2 RTS: %d\n", state); });
- m_ctrl[1]->data_cb().set([this] (int data) { logerror("controller 2 data: %02X\n", data); });
+ m_ctrl[1]->rts_cb().set([this] (int state) { m_ctrl_rts[1] = state; printf("Ctrl1 RTS: %d\n", state); });
+ m_ctrl[1]->data_cb().set([this] (uint8_t data) { m_spg->uart_rx(data); printf("Ctrl1 UART Tx: %02X\n", data); });
SOFTWARE_LIST(config, "cart_list").set_original("vsmile_cart");
SOFTWARE_LIST(config, "cart_list2").set_original("vsmilem_cart");