From 4c0d40e05e6ac3627af4e9308833adf131041f10 Mon Sep 17 00:00:00 2001 From: cracyc Date: Sat, 8 Apr 2023 19:08:07 -0500 Subject: [PATCH] lw700i: connect fdc and floppy drive, don't work yet because of dma --- src/devices/machine/upd765.cpp | 14 +++++++++++++- src/devices/machine/upd765.h | 1 + src/mame/brother/lw700i.cpp | 24 ++++++++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/devices/machine/upd765.cpp b/src/devices/machine/upd765.cpp index 0ca0e4d72cf..82421850d7b 100644 --- a/src/devices/machine/upd765.cpp +++ b/src/devices/machine/upd765.cpp @@ -3352,9 +3352,15 @@ void hd63266f_device::abort_w(u8 data) int hd63266f_device::check_command() { - switch(command[0] & 0x1f) { + switch(command[0]) { case 0x0e: return C_SLEEP; + case 0x0b: + case 0x2b: + return command_pos == 4 ? C_SPECIFY : C_INCOMPLETE; + case 0x4b: + case 0x6b: + return command_pos == 7 ? C_SPECIFY2 : C_INCOMPLETE; } return upd765_family_device::check_command(); } @@ -3370,6 +3376,12 @@ void hd63266f_device::execute_command(int cmd) motor_state = 0; LOGCOMMAND("sleep\n"); break; + case C_SPECIFY2: + spec = (command[1] << 8) | command[2]; + LOGCOMMAND("command specify2 %02x %02x: step_rate=%d ms, head_unload=%d ms, head_load=%d ms, non_dma=%s\n", + command[1], command[2], 16-(command[1]>>4), (command[1]&0x0f)<<4, command[2]&0xfe, ((command[2]&1)==1)? "true":"false"); + main_phase = PHASE_CMD; + break; case C_SENSE_DRIVE_STATUS: upd765_family_device::execute_command(cmd); if(inp_cb) diff --git a/src/devices/machine/upd765.h b/src/devices/machine/upd765.h index 6c25022770e..f28cc09db18 100644 --- a/src/devices/machine/upd765.h +++ b/src/devices/machine/upd765.h @@ -282,6 +282,7 @@ protected: C_VERSION, C_SLEEP, C_ABORT, + C_SPECIFY2, C_INVALID, C_INCOMPLETE diff --git a/src/mame/brother/lw700i.cpp b/src/mame/brother/lw700i.cpp index 282918d7a3b..85e0ddb9279 100644 --- a/src/mame/brother/lw700i.cpp +++ b/src/mame/brother/lw700i.cpp @@ -19,6 +19,8 @@ #include "machine/at28c16.h" #include "machine/nvram.h" #include "machine/timer.h" +#include "machine/upd765.h" +#include "imagedev/floppy.h" #include "screen.h" #include "speaker.h" @@ -36,14 +38,13 @@ public: m_maincpu(*this, "maincpu"), m_mainram(*this, "mainram"), m_screen(*this, "screen"), + m_fdc(*this, "fdc"), + m_floppy(*this, "fdc:1"), m_keyboard(*this, "X%u", 0) { } void lw700i(machine_config &config); - uint16_t status_r() { return 0x8080; } // "ready" - void data_w(uint16_t data) { } - uint8_t p7_r(); uint8_t pb_r(); void pb_w(uint8_t data); @@ -63,6 +64,8 @@ private: required_device m_maincpu; required_shared_ptr m_mainram; required_device m_screen; + required_device m_fdc; + required_device m_floppy; required_ioport_array<9> m_keyboard; // driver_device overrides @@ -117,6 +120,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(lw700i_state::vbl_interrupt) void lw700i_state::machine_reset() { + m_fdc->rate_w(1); // machine supports 250k and 500k rate, this must be controlled somewhere } void lw700i_state::machine_start() @@ -157,7 +161,7 @@ void lw700i_state::main_map(address_map &map) { map(0x000000, 0x1fffff).rom().region("maincpu", 0x0000); map(0x600000, 0x63ffff).ram().share("mainram"); // 256K of main RAM - map(0xe00000, 0xe00001).rw(FUNC(lw700i_state::status_r), FUNC(lw700i_state::data_w)); + map(0xe00000, 0xe00003).m(m_fdc, FUNC(hd63266f_device::map)); map(0xf00048, 0xf00049).ram(); } @@ -270,11 +274,17 @@ static INPUT_PORTS_START( lw700i ) INPUT_PORTS_END +static void lw700i_floppies(device_slot_interface &device) +{ + device.option_add("35hd", FLOPPY_35_HD); +} + void lw700i_state::lw700i(machine_config &config) { H83003(config, m_maincpu, XTAL(16'000'000)); m_maincpu->set_addrmap(AS_PROGRAM, &lw700i_state::main_map); m_maincpu->set_addrmap(AS_IO, &lw700i_state::io_map); + m_maincpu->tend0().set(m_fdc, FUNC(hd63266f_device::tc_line_w)); TIMER(config, "scantimer").configure_scanline(FUNC(lw700i_state::vbl_interrupt), "screen", 0, 1); SCREEN(config, m_screen, SCREEN_TYPE_LCD); @@ -283,6 +293,12 @@ void lw700i_state::lw700i(machine_config &config) m_screen->set_screen_update(FUNC(lw700i_state::screen_update)); m_screen->set_size(640, 400); m_screen->set_visarea(0, 480, 0, 128); + + HD63266F(config, m_fdc, XTAL(16'000'000)); + m_fdc->intrq_wr_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ4); + m_fdc->drq_wr_callback().set_inputline(m_maincpu, H8_INPUT_LINE_DREQ2); // dreq2 is not connected in the hd83003 + m_fdc->inp_rd_callback().set([this](){ return !m_floppy->get_device()->dskchg_r(); }); + FLOPPY_CONNECTOR(config, m_floppy, lw700i_floppies, "35hd", floppy_image_device::default_pc_floppy_formats); } ROM_START(lw700i)