mirror of
https://github.com/holub/mame
synced 2025-07-08 19:31:59 +03:00
nec/pc6001.cpp: Fix joystick multiplexing; add port outputs and HSYNC and VSYNC readback
This commit is contained in:
parent
e6b401614c
commit
2bc32a86b6
@ -257,6 +257,42 @@ void pc6001_state::nec_ppi8255_w(offs_t offset, uint8_t data)
|
||||
m_ppi->write(offset,data);
|
||||
}
|
||||
|
||||
uint8_t pc6001_state::joystick_r()
|
||||
{
|
||||
uint8_t data = m_joymux->output_r();
|
||||
|
||||
// FIXME: bits 6 and 7 are supposed to be nHSYNC and nVSYNC
|
||||
if (m_screen->hblank())
|
||||
data &= 0xbf;
|
||||
else
|
||||
data |= 0x40;
|
||||
if (m_screen->vblank())
|
||||
data &= 0x7f;
|
||||
else
|
||||
data |= 0x80;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
uint8_t pc6001_state::joystick_out_r()
|
||||
{
|
||||
return m_joystick_out;
|
||||
}
|
||||
|
||||
void pc6001_state::joystick_out_w(uint8_t data)
|
||||
{
|
||||
// bit 7 is output enable for first part of 74LS367 buffer
|
||||
m_joy[1]->pin_6_w(BIT(data, 7) ? 1 : BIT(data, 0));
|
||||
m_joy[1]->pin_7_w(BIT(data, 7) ? 1 : BIT(data, 1));
|
||||
m_joy[0]->pin_6_w(BIT(data, 7) ? 1 : BIT(data, 2));
|
||||
m_joy[0]->pin_7_w(BIT(data, 7) ? 1 : BIT(data, 3));
|
||||
m_joy[1]->pin_8_w(BIT(data, 4));
|
||||
m_joy[0]->pin_8_w(BIT(data, 5));
|
||||
m_joymux->select_w(BIT(data, 6));
|
||||
|
||||
m_joystick_out = data;
|
||||
}
|
||||
|
||||
void pc6001_state::pc6001_map(address_map &map)
|
||||
{
|
||||
map.unmap_value_high();
|
||||
@ -1383,7 +1419,7 @@ uint8_t pc6001_state::check_keyboard_press()
|
||||
uint8_t pc6001_state::check_joy_press()
|
||||
{
|
||||
// TODO: this may really just rearrange keyboard key presses in a joystick like fashion, somehow akin to Sharp X1 mode
|
||||
uint8_t p1_key = m_joy[0]->read() ^ 0xff;
|
||||
uint8_t p1_key = m_joymux->output_r() ^ 0xff;
|
||||
uint8_t shift_key = m_io_key_modifiers->read() & 0x02;
|
||||
uint8_t space_key = m_io_keys[1]->read() & 0x01;
|
||||
uint8_t joy_press;
|
||||
@ -1694,10 +1730,13 @@ void pc6001_state::pc6001(machine_config &config)
|
||||
/* uart */
|
||||
I8251(config, "uart", 0);
|
||||
|
||||
// TODO: these are unchecked
|
||||
MSX_GENERAL_PURPOSE_PORT(config, m_joy[0], msx_general_purpose_port_devices, "joystick");
|
||||
MSX_GENERAL_PURPOSE_PORT(config, m_joy[1], msx_general_purpose_port_devices, "joystick");
|
||||
|
||||
LS157_X2(config, m_joymux);
|
||||
m_joymux->a_in_callback().set(m_joy[1], FUNC(msx_general_purpose_port_device::read));
|
||||
m_joymux->b_in_callback().set(m_joy[0], FUNC(msx_general_purpose_port_device::read));
|
||||
|
||||
GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "pc6001_cart");
|
||||
SOFTWARE_LIST(config, "cart_list_pc6001").set_original("pc6001_cart");
|
||||
|
||||
@ -1709,8 +1748,9 @@ void pc6001_state::pc6001(machine_config &config)
|
||||
|
||||
SPEAKER(config, "mono").front_center();
|
||||
AY8910(config, m_ay, PC6001_MAIN_CLOCK/4);
|
||||
m_ay->port_a_read_callback().set(m_joy[0], FUNC(msx_general_purpose_port_device::read));
|
||||
m_ay->port_b_read_callback().set(m_joy[1], FUNC(msx_general_purpose_port_device::read));
|
||||
m_ay->port_a_read_callback().set(FUNC(pc6001_state::joystick_r));
|
||||
m_ay->port_b_read_callback().set(FUNC(pc6001_state::joystick_out_r));
|
||||
m_ay->port_b_write_callback().set(FUNC(pc6001_state::joystick_out_w));
|
||||
m_ay->add_route(ALL_OUTPUTS, "mono", 1.00);
|
||||
|
||||
// TODO: accurate timing on this
|
||||
@ -1804,8 +1844,9 @@ void pc6001mk2sr_state::pc6001mk2sr(machine_config &config)
|
||||
|
||||
config.device_remove("aysnd");
|
||||
YM2203(config, m_ym, PC6001_MAIN_CLOCK/4);
|
||||
m_ym->port_a_read_callback().set(m_joy[0], FUNC(msx_general_purpose_port_device::read));
|
||||
m_ym->port_b_read_callback().set(m_joy[1], FUNC(msx_general_purpose_port_device::read));
|
||||
m_ym->port_a_read_callback().set(FUNC(pc6001mk2sr_state::joystick_r));
|
||||
m_ym->port_b_read_callback().set(FUNC(pc6001mk2sr_state::joystick_out_r));
|
||||
m_ym->port_b_write_callback().set(FUNC(pc6001mk2sr_state::joystick_out_w));
|
||||
m_ym->add_route(ALL_OUTPUTS, "mono", 1.00);
|
||||
|
||||
// TODO: 1D 3'5" floppy drive
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include "imagedev/floppy.h"
|
||||
#include "machine/74157.h"
|
||||
#include "machine/bankdev.h"
|
||||
#include "machine/i8251.h"
|
||||
#include "machine/i8255.h"
|
||||
@ -43,6 +44,7 @@ public:
|
||||
, m_maincpu(*this, "maincpu")
|
||||
, m_screen(*this, "screen")
|
||||
, m_joy(*this, "joy%u", 1U)
|
||||
, m_joymux(*this, "joymux")
|
||||
, m_cassette(*this, "cassette")
|
||||
, m_cas_hack(*this, "cas_hack")
|
||||
, m_cart(*this, "cartslot")
|
||||
@ -78,6 +80,10 @@ public:
|
||||
void ppi_portc_w(uint8_t data);
|
||||
uint8_t ppi_portc_r();
|
||||
|
||||
uint8_t joystick_r();
|
||||
uint8_t joystick_out_r();
|
||||
void joystick_out_w(uint8_t data);
|
||||
|
||||
void pc6001(machine_config &config);
|
||||
protected:
|
||||
required_device<i8255_device> m_ppi;
|
||||
@ -85,6 +91,7 @@ protected:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<screen_device> m_screen;
|
||||
required_device_array<msx_general_purpose_port_device, 2> m_joy;
|
||||
required_device<ls157_x2_device> m_joymux;
|
||||
optional_device<cassette_image_device> m_cassette;
|
||||
optional_device<generic_slot_device> m_cas_hack;
|
||||
required_device<generic_slot_device> m_cart;
|
||||
@ -150,6 +157,8 @@ private:
|
||||
uint32_t m_old_key3 = 0;
|
||||
u8 m_old_key_fn;
|
||||
|
||||
uint8_t m_joystick_out = 0xff;
|
||||
|
||||
emu_timer *m_sub_trig_timer = nullptr;
|
||||
|
||||
// IRQ model
|
||||
|
Loading…
Reference in New Issue
Block a user