From a01f6e9417dee96e0c7ffb61acc4c811ac85c04f Mon Sep 17 00:00:00 2001 From: cracyc Date: Mon, 31 Dec 2012 02:12:38 +0000 Subject: [PATCH] [mess] pc.c:convert mc1502 to use wd_fdc (nw) will boot but changing disks doesn't currently work --- src/mess/drivers/pc.c | 25 +++++-------------------- src/mess/includes/pc.h | 1 + src/mess/machine/pc.c | 42 ++++++++++++++++++++++++++++-------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/mess/drivers/pc.c b/src/mess/drivers/pc.c index af165c959a9..8291594ff29 100644 --- a/src/mess/drivers/pc.c +++ b/src/mess/drivers/pc.c @@ -97,7 +97,7 @@ video HW too. #include "machine/am9517a.h" #include "sound/sn76496.h" -#include "machine/wd17xx.h" +#include "machine/wd_fdc.h" #include "machine/kb_7007_3.h" #include "machine/ram.h" @@ -161,10 +161,7 @@ static ADDRESS_MAP_START(mc1502_io, AS_IO, 8, pc_state ) AM_RANGE(0x0100, 0x0100) AM_READWRITE(mc1502_wd17xx_aux_r, mc1502_wd17xx_aux_w) AM_RANGE(0x0108, 0x0108) AM_READ(mc1502_wd17xx_drq_r) // blocking read! AM_RANGE(0x010a, 0x010a) AM_READ(mc1502_wd17xx_motor_r) - AM_RANGE(0x010c, 0x010c) AM_DEVREADWRITE_LEGACY("vg93", wd17xx_status_r, wd17xx_command_w) - AM_RANGE(0x010d, 0x010d) AM_DEVREADWRITE_LEGACY("vg93", wd17xx_track_r, wd17xx_track_w) - AM_RANGE(0x010e, 0x010e) AM_DEVREADWRITE_LEGACY("vg93", wd17xx_sector_r, wd17xx_sector_w) - AM_RANGE(0x010f, 0x010f) AM_DEVREADWRITE_LEGACY("vg93", wd17xx_data_r, wd17xx_data_w) + AM_RANGE(0x010c, 0x010f) AM_DEVREADWRITE("vg93", fd1793_t, read, write) ADDRESS_MAP_END static ADDRESS_MAP_START( zenith_map, AS_PROGRAM, 8, pc_state ) @@ -867,19 +864,6 @@ static const pc_lpt_interface pc_lpt_config = DEVCB_CPU_INPUT_LINE("maincpu", 0) }; -static const floppy_interface mc1502_floppy_interface = -{ - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - DEVCB_NULL, - FLOPPY_STANDARD_5_25_DSHD, - LEGACY_FLOPPY_OPTIONS_NAME(pc), - "floppy_5_25", - NULL -}; - FLOPPY_FORMATS_MEMBER( pc_state::floppy_formats ) FLOPPY_PC_FORMAT FLOPPY_FORMATS_END @@ -1398,8 +1382,9 @@ static MACHINE_CONFIG_START( mc1502, pc_state ) /* cassette */ MCFG_CASSETTE_ADD( CASSETTE_TAG, mc1502_cassette_interface ) // has no motor control - MCFG_FD1793_ADD( "vg93", default_wd17xx_interface_2_drives ) - MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(mc1502_floppy_interface) + MCFG_FD1793x_ADD("vg93", XTAL_8MHz / 8) // clock? + MCFG_FLOPPY_DRIVE_ADD("fd0", ibmpc_floppies, "525dd", 0, pc_state::floppy_formats) + MCFG_FLOPPY_DRIVE_ADD("fd1", ibmpc_floppies, "525dd", 0, pc_state::floppy_formats) /* internal ram */ MCFG_RAM_ADD(RAM_TAG) diff --git a/src/mess/includes/pc.h b/src/mess/includes/pc.h index d9fcb9ed369..c97e1b50806 100644 --- a/src/mess/includes/pc.h +++ b/src/mess/includes/pc.h @@ -145,6 +145,7 @@ public: void fdc_dma_drq(bool state); void pc_select_dma_channel(int channel, bool state); void pc_eop_w(int channel, bool state); + void mc1502_fdc_irq_drq(bool state); DECLARE_FLOPPY_FORMATS( floppy_formats ); }; diff --git a/src/mess/machine/pc.c b/src/mess/machine/pc.c index ca2a7b0a0b7..50319f283e2 100644 --- a/src/mess/machine/pc.c +++ b/src/mess/machine/pc.c @@ -37,7 +37,7 @@ #include "sound/speaker.h" #include "machine/am9517a.h" -#include "machine/wd17xx.h" +#include "machine/wd_fdc.h" #include "machine/ram.h" @@ -1280,16 +1280,22 @@ READ8_MEMBER(pc_state::mc1502_wd17xx_aux_r) WRITE8_MEMBER(pc_state::mc1502_wd17xx_aux_w) { + fd1793_t *fdc = machine().device("vg93"); + floppy_image_device *floppy0 = machine().device("fd0")->get_device(); + floppy_image_device *floppy1 = machine().device("fd1")->get_device(); + floppy_image_device *floppy = ((data & 0x10)?floppy1:floppy0); + fdc->set_floppy(floppy); + // master reset - wd17xx_mr_w(machine().device("vg93"), BIT(data, 0)); + if(data & 1) + fdc->reset(); // SIDE ONE - wd17xx_set_side(machine().device("vg93"), BIT(data, 1)); + floppy->ss_w((data & 2)?1:0); // bits 2, 3 -- motor on (drive 0, 1) - - // DRIVE SEL - wd17xx_set_drive(machine().device("vg93"), BIT(data, 4)); + floppy0->mon_w(!(data & 4)); + floppy1->mon_w(!(data & 8)); } /* @@ -1297,17 +1303,21 @@ WRITE8_MEMBER(pc_state::mc1502_wd17xx_aux_w) */ READ8_MEMBER(pc_state::mc1502_wd17xx_drq_r) { - UINT8 data; - UINT64 newpc; + fd1793_t *fdc = machine().device("vg93"); - data = wd17xx_drq_r(machine().device("vg93")); - if (!data && !wd17xx_intrq_r(machine().device("vg93"))) { - /* fake cpu halt by resetting PC one insn back */ - newpc = machine().firstcpu->pc(); - machine().firstcpu->set_pc( newpc - 1 ); + if (!fdc->drq_r() && !fdc->intrq_r()) { + /* fake cpu wait by resetting PC one insn back */ + m_maincpu->set_pc(m_maincpu->pc() - 1); + m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); } - return data; + return fdc->drq_r(); +} + +void pc_state::mc1502_fdc_irq_drq(bool state) +{ + if(state) + m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); } READ8_MEMBER(pc_state::mc1502_wd17xx_motor_r) @@ -1516,6 +1526,10 @@ MACHINE_START_MEMBER(pc_state,mc1502) memset(&mc1502_keyb, 0, sizeof(mc1502_keyb)); mc1502_keyb.keyb_signal_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(pc_state::mc1502_keyb_signal_callback),this)); mc1502_keyb.keyb_signal_timer->adjust( attotime::from_msec(20), 0, attotime::from_msec(20) ); + + fd1793_t *fdc = machine().device("vg93"); + fdc->setup_drq_cb(fd1793_t::line_cb(FUNC(pc_state::mc1502_fdc_irq_drq), this)); + fdc->setup_intrq_cb(fd1793_t::line_cb(FUNC(pc_state::mc1502_fdc_irq_drq), this)); }