psr540: Add the mks3

This commit is contained in:
Olivier Galibert 2024-10-26 18:00:28 +02:00
parent dbc8f01adb
commit a2a60395dc

View file

@ -3,6 +3,7 @@
#include "emu.h"
#include "mks3.h"
#include "bus/midi/midiinport.h"
#include "bus/midi/midioutport.h"
#include "cpu/sh/sh7042.h"
@ -28,6 +29,7 @@ public:
m_floppy(*this, "fdc:0"),
m_fdc(*this, "fdc"),
m_nvram(*this, "ram"),
m_mks3(*this, "mks3"),
m_inputs(*this, "B%u", 1U),
m_outputs(*this, "%02d.%x.%x", 0U, 0U, 0U),
m_sustain(*this, "SUSTAIN"),
@ -43,6 +45,7 @@ private:
required_device<floppy_connector> m_floppy;
required_device<hd63266f_device> m_fdc;
required_device<nvram_device> m_nvram;
required_device<mks3_device> m_mks3;
required_ioport_array<8> m_inputs;
output_finder<80, 8, 5> m_outputs;
required_ioport m_sustain;
@ -58,6 +61,7 @@ private:
u16 adc_midisw_r();
u16 adc_battery_r();
void pa_w(u16 data);
u16 pe_r();
void pe_w(u16 data);
u8 pf_r();
@ -125,6 +129,7 @@ void psr540_state::psr540(machine_config &config)
m_maincpu->read_adc<3>().set_constant(0);
m_maincpu->read_adc<4>().set_ioport(m_pitch_bend);
m_maincpu->read_adc<5>().set_constant(0); // Actually used as pf5
m_maincpu->write_porta().set(FUNC(psr540_state::pa_w));
m_maincpu->read_porte().set(FUNC(psr540_state::pe_r));
m_maincpu->write_porte().set(FUNC(psr540_state::pe_w));
m_maincpu->read_portf().set(FUNC(psr540_state::pf_r));
@ -133,6 +138,10 @@ void psr540_state::psr540(machine_config &config)
m_swx00->add_route(0, "lspeaker", 1.0);
m_swx00->add_route(1, "rspeaker", 1.0);
MKS3(config, m_mks3);
m_mks3->write_da().set(m_maincpu, FUNC(sh7042_device::sci_rx_w<1>));
m_mks3->write_clk().set(m_maincpu, FUNC(sh7042_device::sci_clk_w<1>));
KS0066(config, m_lcdc, 270000); // OSC = 91K resistor, TODO: actually KS0066U-10B
m_lcdc->set_default_bios_tag("f00");
m_lcdc->set_lcd_size(2, 40);
@ -200,11 +209,17 @@ void psr540_state::pe_w(u16 data)
m_lcdc->rs_w(BIT(m_pe, 11));
m_lcdc->e_w(BIT(m_pe, 9));
m_fdc->rate_w(!BIT(m_pe, 8));
m_mks3->ic_w(BIT(m_pe, 4));
if(BIT(m_pe, 4))
m_scan = m_led & 7;
}
void psr540_state::pa_w(u16 data)
{
m_mks3->req_w(BIT(data, 4));
}
void psr540_state::lcd_data_w(u8 data)
{
m_lcdc->db_w(data);
@ -250,7 +265,7 @@ static INPUT_PORTS_START( psr540 )
PORT_BIT(0x3ff, 0x200, IPT_PADDLE) PORT_NAME("Pitch Bend") PORT_SENSITIVITY(30)
PORT_START("B1")
PORT_BIT(0x001, IP_ACTIVE_LOW, IPT_UNUSED)
PORT_BIT(0x001, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("9") PORT_CODE(KEYCODE_9)
PORT_BIT(0x002, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Exit") PORT_CODE(KEYCODE_BACKSPACE)
PORT_BIT(0x004, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Utility") PORT_CODE(KEYCODE_Q)
PORT_BIT(0x008, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Save") PORT_CODE(KEYCODE_W)