mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
-vsmile: Converted to use slot devices for controllers. Breaks controller input. Checkin in so Vas can look at it, nw
This commit is contained in:
parent
53bf06db84
commit
953d9737d4
@ -3278,10 +3278,10 @@ if (BUSES["VSMILE"]~=null) then
|
|||||||
files {
|
files {
|
||||||
MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.cpp",
|
MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.cpp",
|
||||||
MAME_DIR .. "src/devices/bus/vsmile/vsmile_ctrl.h",
|
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.cpp",
|
||||||
MAME_DIR .. "src/devices/bus/vsmile/vsmile_slot.h",
|
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.cpp",
|
||||||
MAME_DIR .. "src/devices/bus/vsmile/rom.h",
|
MAME_DIR .. "src/devices/bus/vsmile/rom.h",
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
||||||
}
|
|
@ -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
|
|
203
src/devices/bus/vsmile/pad.cpp
Normal file
203
src/devices/bus/vsmile/pad.cpp
Normal file
@ -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 );
|
||||||
|
}
|
78
src/devices/bus/vsmile/pad.h
Normal file
78
src/devices/bus/vsmile/pad.h
Normal file
@ -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
|
@ -103,9 +103,9 @@ void vsmile_ctrl_port_device::device_start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "joystick.h"
|
#include "pad.h"
|
||||||
|
|
||||||
void vsmile_controllers(device_slot_interface &device)
|
void vsmile_controllers(device_slot_interface &device)
|
||||||
{
|
{
|
||||||
device.option_add("joy", VSMILE_JOYSTICK);
|
device.option_add("pad", VSMILE_PAD);
|
||||||
}
|
}
|
||||||
|
@ -65,28 +65,15 @@ public:
|
|||||||
: vsmile_base_state(mconfig, type, tag)
|
: vsmile_base_state(mconfig, type, tag)
|
||||||
, m_cart(*this, "cartslot")
|
, m_cart(*this, "cartslot")
|
||||||
, m_ctrl(*this, "ctrl%u", 1U)
|
, 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_dsw_region(*this, "REGION")
|
||||||
, m_uart_tx_timer(nullptr)
|
|
||||||
, m_pad_timer(nullptr)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void vsmile(machine_config &config);
|
void vsmile(machine_config &config);
|
||||||
void vsmilep(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:
|
private:
|
||||||
virtual void machine_start() override;
|
virtual void machine_start() override;
|
||||||
virtual void machine_reset() 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);
|
void banked_map(address_map &map);
|
||||||
|
|
||||||
@ -97,8 +84,6 @@ private:
|
|||||||
DECLARE_WRITE8_MEMBER(chip_sel_w);
|
DECLARE_WRITE8_MEMBER(chip_sel_w);
|
||||||
|
|
||||||
DECLARE_WRITE8_MEMBER(uart_rx);
|
DECLARE_WRITE8_MEMBER(uart_rx);
|
||||||
void uart_tx_fifo_push(uint8_t data);
|
|
||||||
void handle_uart_tx();
|
|
||||||
|
|
||||||
DECLARE_READ16_MEMBER(bank3_r);
|
DECLARE_READ16_MEMBER(bank3_r);
|
||||||
|
|
||||||
@ -118,31 +103,14 @@ private:
|
|||||||
VSMILE_PORTC_TEST = 0x20,
|
VSMILE_PORTC_TEST = 0x20,
|
||||||
VSMILE_PORTC_AMP = 0x40,
|
VSMILE_PORTC_AMP = 0x40,
|
||||||
VSMILE_PORTC_SYSRESET = 0x80,
|
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<vsmile_cart_slot_device> m_cart;
|
||||||
required_device_array<vsmile_ctrl_port_device, 2> m_ctrl;
|
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;
|
required_ioport m_dsw_region;
|
||||||
|
|
||||||
bool m_ctrl_cts[2];
|
|
||||||
bool m_ctrl_rts[2];
|
bool m_ctrl_rts[2];
|
||||||
uint8_t m_ctrl_probe_history[2];
|
bool m_ctrl_cts[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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class vsmileb_state : public vsmile_base_state
|
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_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_rts));
|
||||||
save_item(NAME(m_ctrl_probe_history));
|
save_item(NAME(m_ctrl_cts));
|
||||||
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_state::machine_reset()
|
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_rts, 0, sizeof(bool) * 2);
|
||||||
memset(m_ctrl_probe_history, 0, 2);
|
memset(m_ctrl_cts, 0, sizeof(bool) * 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE8_MEMBER(vsmile_state::uart_rx)
|
WRITE8_MEMBER(vsmile_state::uart_rx)
|
||||||
{
|
{
|
||||||
if ((data >> 4) == 7 || (data >> 4) == 11)
|
printf("Receiving %02x\n", data);
|
||||||
{
|
if (m_ctrl_cts[0])
|
||||||
m_ctrl_probe_history[0] = m_ctrl_probe_history[1];
|
m_ctrl[0]->data_w(data);
|
||||||
m_ctrl_probe_history[1] = data;
|
if (m_ctrl_cts[1])
|
||||||
const uint8_t response = ((m_ctrl_probe_history[0] + m_ctrl_probe_history[1] + 0x0f) & 0x0f) ^ 0x05;
|
m_ctrl[1]->data_w(data);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
READ16_MEMBER(vsmile_state::bank3_r)
|
READ16_MEMBER(vsmile_state::bank3_r)
|
||||||
@ -325,50 +216,12 @@ WRITE16_MEMBER(vsmile_state::portc_w)
|
|||||||
if (BIT(mem_mask, 8))
|
if (BIT(mem_mask, 8))
|
||||||
{
|
{
|
||||||
m_ctrl_cts[0] = BIT(data, 8);
|
m_ctrl_cts[0] = BIT(data, 8);
|
||||||
if (m_uart_tx_state == XMIT_STATE_RTS)
|
m_ctrl[0]->cts_w(m_ctrl_cts[0]);
|
||||||
m_uart_tx_state = XMIT_STATE_CTS;
|
|
||||||
}
|
}
|
||||||
if (BIT(mem_mask, 9))
|
if (BIT(mem_mask, 9))
|
||||||
{
|
{
|
||||||
m_ctrl_cts[1] = BIT(data, 9);
|
m_ctrl_cts[1] = BIT(data, 8);
|
||||||
}
|
m_ctrl[1]->cts_w(m_ctrl_cts[1]);
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,27 +367,6 @@ void vsmileb_state::banked_map(address_map &map)
|
|||||||
************************************/
|
************************************/
|
||||||
|
|
||||||
static INPUT_PORTS_START( vsmile )
|
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_START("REGION")
|
||||||
PORT_DIPNAME( 0x0f, 0x04, "BIOS Region" )
|
PORT_DIPNAME( 0x0f, 0x04, "BIOS Region" )
|
||||||
PORT_DIPSETTING( 0x04, "UK/US" )
|
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_CART_SLOT(config, m_cart, vsmile_cart, nullptr);
|
||||||
|
|
||||||
VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "joy");
|
VSMILE_CTRL_PORT(config, m_ctrl[0], vsmile_controllers, "pad");
|
||||||
m_ctrl[0]->rts_cb().set([this] (int state) { logerror("controller 1 RTS: %d\n", state); });
|
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] (int data) { logerror("controller 1 data: %02X\n", data); });
|
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);
|
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]->rts_cb().set([this] (int state) { m_ctrl_rts[1] = state; printf("Ctrl1 RTS: %d\n", state); });
|
||||||
m_ctrl[1]->data_cb().set([this] (int data) { logerror("controller 2 data: %02X\n", data); });
|
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_list").set_original("vsmile_cart");
|
||||||
SOFTWARE_LIST(config, "cart_list2").set_original("vsmilem_cart");
|
SOFTWARE_LIST(config, "cart_list2").set_original("vsmilem_cart");
|
||||||
|
Loading…
Reference in New Issue
Block a user