From 37a7ded8af44964577a779da48f8f0dee3c9f49a Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Tue, 4 Nov 2014 23:36:58 +0200 Subject: [PATCH] (MESS) victor9k: Floppy WIP. (nw) --- src/lib/formats/victor9k_dsk.c | 115 +++++++++++++++- src/lib/formats/victor9k_dsk.h | 6 + src/mess/drivers/victor9k.c | 19 +-- src/mess/machine/victor9k_fdc.c | 231 ++++++++++++++++++-------------- src/mess/machine/victor9k_fdc.h | 27 ++-- 5 files changed, 273 insertions(+), 125 deletions(-) diff --git a/src/lib/formats/victor9k_dsk.c b/src/lib/formats/victor9k_dsk.c index bbc0b45aac9..afda79c95cd 100644 --- a/src/lib/formats/victor9k_dsk.c +++ b/src/lib/formats/victor9k_dsk.c @@ -36,6 +36,8 @@ 7 71-79 63-74 12 149.6 401 8 unused 75-79 11 144.0 417 + Interleave factor 3 + */ #include "emu.h" @@ -60,14 +62,121 @@ const char *victor9k_format::extensions() const return "img"; } +int victor9k_format::find_size(io_generic *io, UINT32 form_factor) +{ + UINT64 size = io_generic_size(io); + for(int i=0; formats[i].sector_count; i++) { + const format &f = formats[i]; + if(size == (UINT32) f.sector_count*f.sector_base_size*f.head_count) + return i; + } + return -1; +} + int victor9k_format::identify(io_generic *io, UINT32 form_factor) { + int type = find_size(io, form_factor); + + if (type != -1) + return 50; + return 0; } +floppy_image_format_t::desc_e* victor9k_format::get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2) +{ + static floppy_image_format_t::desc_e desc[] = { + /* 00 */ { SECTOR_LOOP_START, 0, -1 }, + /* 01 */ { RAWBYTE, 0xff, 5 }, + /* 02 */ { GCR5, 0x08, 1 }, + /* 03 */ { CRC, 1 }, + /* 04 */ { CRC_CBM_START, 1 }, + /* 05 */ { SECTOR_ID_GCR5 }, + /* 06 */ { TRACK_ID_DOS2_GCR5 }, + /* 07 */ { GCR5, id2, 1 }, + /* 08 */ { GCR5, id1, 1 }, + /* 09 */ { CRC_END, 1 }, + /* 10 */ { GCR5, 0x0f, 2 }, + /* 11 */ { RAWBYTE, 0x55, f.gap_1 }, + /* 12 */ { RAWBYTE, 0xff, 5 }, + /* 13 */ { GCR5, 0x07, 1 }, + /* 14 */ { CRC_CBM_START, 2 }, + /* 15 */ { SECTOR_DATA_GCR5, -1 }, + /* 16 */ { CRC_END, 2 }, + /* 17 */ { CRC, 2 }, + /* 18 */ { GCR5, 0x00, 2 }, + /* 19 */ { RAWBYTE, 0x55, gap_2 }, + /* 20 */ { SECTOR_LOOP_END }, + /* 21 */ { RAWBYTE, 0x55, 0 }, + /* 22 */ { RAWBITS, 0x5555, 0 }, + /* 23 */ { END } + }; + + current_size = 40 + (1+1+4+2)*10 + (f.gap_1)*8 + 40 + (1+f.sector_base_size+1+2)*10 + gap_2*8; + + current_size *= sector_count; + return desc; +} + +void victor9k_format::build_sector_description(const format &f, UINT8 *sectdata, offs_t sect_offs, desc_s *sectors, int sector_count) const +{ + for (int i = 0; i < sector_count; i++) { + sectors[i].data = sectdata + sect_offs; + sectors[i].size = f.sector_base_size; + sectors[i].sector_id = i; + + sect_offs += sectors[i].size; + } +} + bool victor9k_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) { - return false; + int type = find_size(io, form_factor); + if(type == -1) + return false; + + const format &f = formats[type]; + + UINT64 size = io_generic_size(io); + dynamic_buffer img; + img.resize(size); + + io_generic_read(io, img, 0, size); + + int track_offset = 0; + + UINT8 id1 = 0xde, id2 = 0xad; // TODO + + for (int head = 0; head < f.head_count; head++) { + for (int track = 0; track < f.track_count; track++) { + int current_size = 0; + int total_size = 200000000./cell_size[speed_zone[head][track]]; + int sector_count = sectors_per_track[head][track]; + int track_size = sector_count*f.sector_base_size; + + floppy_image_format_t::desc_e *desc = get_sector_desc(f, current_size, sector_count, id1, id2, f.gap_2); + + int remaining_size = total_size - current_size; + if(remaining_size < 0) + throw emu_fatalerror("victor9k_format: Incorrect track layout, max_size=%d, current_size=%d", total_size, current_size); + + // Fixup the end gap + desc[21].p2 = remaining_size / 8; + desc[22].p2 = remaining_size & 7; + desc[22].p1 >>= remaining_size & 0x01; + + desc_s sectors[40]; + + build_sector_description(f, img, track_offset, sectors, sector_count); + generate_track(desc, track, head, sectors, sector_count, total_size, image); + + track_offset += track_size; + } + } + + image->set_variant(f.variant); + + return true; } bool victor9k_format::supports_save() const @@ -77,10 +186,10 @@ bool victor9k_format::supports_save() const const victor9k_format::format victor9k_format::formats[] = { { // - floppy_image::FF_525, floppy_image::SSDD, 80, 1, 512 + floppy_image::FF_525, floppy_image::SSDD, 1224, 80, 1, 512, 9, 8 }, { // - floppy_image::FF_525, floppy_image::DSDD, 80, 2, 512 + floppy_image::FF_525, floppy_image::DSDD, 2448, 80, 2, 512, 9, 8 }, {} }; diff --git a/src/lib/formats/victor9k_dsk.h b/src/lib/formats/victor9k_dsk.h index e13568b75eb..dec2d88cd2f 100644 --- a/src/lib/formats/victor9k_dsk.h +++ b/src/lib/formats/victor9k_dsk.h @@ -19,9 +19,12 @@ public: UINT32 form_factor; // See floppy_image for possible values UINT32 variant; // See floppy_image for possible values + UINT16 sector_count; UINT8 track_count; UINT8 head_count; UINT16 sector_base_size; + UINT8 gap_1; + UINT8 gap_2; }; victor9k_format(); @@ -30,7 +33,10 @@ public: virtual const char *description() const; virtual const char *extensions() const; + int find_size(io_generic *io, UINT32 form_factor); virtual int identify(io_generic *io, UINT32 form_factor); + floppy_image_format_t::desc_e* get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2); + void build_sector_description(const format &f, UINT8 *sectdata, offs_t sect_offs, desc_s *sectors, int sector_count) const; virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); virtual bool supports_save() const; diff --git a/src/mess/drivers/victor9k.c b/src/mess/drivers/victor9k.c index 77c7eb6b29a..50c8a08b059 100644 --- a/src/mess/drivers/victor9k.c +++ b/src/mess/drivers/victor9k.c @@ -38,18 +38,19 @@ static ADDRESS_MAP_START( victor9k_mem, AS_PROGRAM, 8, victor9k_state ) // AM_RANGE(0x00000, 0xdffff) AM_RAM + AM_RANGE(0x20000, 0xdffff) AM_NOP AM_RANGE(0xe0000, 0xe0001) AM_DEVREADWRITE(I8259A_TAG, pic8259_device, read, write) AM_RANGE(0xe0020, 0xe0023) AM_DEVREADWRITE(I8253_TAG, pit8253_device, read, write) AM_RANGE(0xe0040, 0xe0043) AM_DEVREADWRITE(UPD7201_TAG, upd7201_device, cd_ba_r, cd_ba_w) - AM_RANGE(0xe8000, 0xe8000) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, status_r, address_w) - AM_RANGE(0xe8001, 0xe8001) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, register_r, register_w) - AM_RANGE(0xe8020, 0xe802f) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write) - AM_RANGE(0xe8040, 0xe804f) AM_DEVREADWRITE(M6522_2_TAG, via6522_device, read, write) - AM_RANGE(0xe8060, 0xe8061) AM_DEVREADWRITE(MC6852_TAG, mc6852_device, read, write) - AM_RANGE(0xe8080, 0xe808f) AM_DEVREADWRITE(M6522_3_TAG, via6522_device, read, write) - AM_RANGE(0xe80a0, 0xe80af) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs5_r, cs5_w) - AM_RANGE(0xe80c0, 0xe80cf) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs6_r, cs6_w) - AM_RANGE(0xe80e0, 0xe80ef) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs7_r, cs7_w) + AM_RANGE(0xe8000, 0xe8000) AM_MIRROR(0x7f00) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, status_r, address_w) + AM_RANGE(0xe8001, 0xe8001) AM_MIRROR(0x7f00) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, register_r, register_w) + AM_RANGE(0xe8020, 0xe802f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write) + AM_RANGE(0xe8040, 0xe804f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_2_TAG, via6522_device, read, write) + AM_RANGE(0xe8060, 0xe8061) AM_MIRROR(0x7f00) AM_DEVREADWRITE(MC6852_TAG, mc6852_device, read, write) + AM_RANGE(0xe8080, 0xe808f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_3_TAG, via6522_device, read, write) + AM_RANGE(0xe80a0, 0xe80af) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs5_r, cs5_w) + AM_RANGE(0xe80c0, 0xe80cf) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs6_r, cs6_w) + AM_RANGE(0xe80e0, 0xe80ef) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs7_r, cs7_w) AM_RANGE(0xf0000, 0xf0fff) AM_MIRROR(0x1000) AM_RAM AM_SHARE("video_ram") AM_RANGE(0xfe000, 0xfffff) AM_ROM AM_REGION(I8088_TAG, 0) ADDRESS_MAP_END diff --git a/src/mess/machine/victor9k_fdc.c b/src/mess/machine/victor9k_fdc.c index 1f8f3d3360e..ebb4f21c47f 100644 --- a/src/mess/machine/victor9k_fdc.c +++ b/src/mess/machine/victor9k_fdc.c @@ -15,7 +15,6 @@ - floppy format - spindle speed - - stepper - read PLL - write logic @@ -29,7 +28,7 @@ // MACROS / CONSTANTS //************************************************************************** -#define LOG 0 +#define LOG 1 #define I8048_TAG "5d" #define M6522_4_TAG "1f" @@ -85,60 +84,28 @@ ADDRESS_MAP_END // SLOT_INTERFACE( victor9k_floppies ) //------------------------------------------------- -void victor_9000_fdc_t::ready0_cb(floppy_image_device *device, int state) -{ - m_rdy0 = state; - - m_via5->write_ca2(m_rdy0); -} - int victor_9000_fdc_t::load0_cb(floppy_image_device *device) { - m_ds0 = 0; - - m_via4->write_ca1(m_ds0); + m_via4->write_ca1(0); return IMAGE_INIT_PASS; } void victor_9000_fdc_t::unload0_cb(floppy_image_device *device) { - m_ds0 = 1; - - m_via4->write_ca1(m_ds0); -} - -void victor_9000_fdc_t::index0_cb(floppy_image_device *device, int state) -{ - m_tach0 = state; -} - -void victor_9000_fdc_t::ready1_cb(floppy_image_device *device, int state) -{ - m_rdy1 = state; - - m_via5->write_cb2(m_rdy1); + m_via4->write_ca1(1); } int victor_9000_fdc_t::load1_cb(floppy_image_device *device) { - m_ds1 = 0; - - m_via4->write_cb1(m_ds1); + m_via4->write_cb1(0); return IMAGE_INIT_PASS; } void victor_9000_fdc_t::unload1_cb(floppy_image_device *device) { - m_ds1 = 1; - - m_via4->write_cb1(m_ds1); -} - -void victor_9000_fdc_t::index1_cb(floppy_image_device *device, int state) -{ - m_tach1 = state; + m_via4->write_cb1(1); } static SLOT_INTERFACE_START( victor9k_floppies ) @@ -215,18 +182,21 @@ victor_9000_fdc_t::victor_9000_fdc_t(const machine_config &mconfig, const char * m_via6(*this, M6522_6_TAG), m_floppy0(*this, I8048_TAG":0:525qd"), m_floppy1(*this, I8048_TAG":1:525qd"), + m_rom(*this, I8048_TAG), m_gcr_rom(*this, "gcr"), m_da(0), m_da0(0), m_da1(0), + m_start0(1), + m_stop0(1), + m_start1(1), + m_stop1(1), m_sel0(0), m_sel1(0), m_tach0(0), m_tach1(0), m_rdy0(0), m_rdy1(0), - m_ds0(1), - m_ds1(1), m_l0ms(0), m_l1ms(0), m_st0(0), @@ -256,20 +226,24 @@ victor_9000_fdc_t::victor_9000_fdc_t(const machine_config &mconfig, const char * void victor_9000_fdc_t::device_start() { // allocate timer - t_gen = timer_alloc(0); + t_gen = timer_alloc(TM_GEN); + t_tach0 = timer_alloc(TM_TACH0); + t_tach1 = timer_alloc(TM_TACH1); // state saving save_item(NAME(m_da)); save_item(NAME(m_da0)); save_item(NAME(m_da1)); + save_item(NAME(m_start0)); + save_item(NAME(m_stop0)); + save_item(NAME(m_start1)); + save_item(NAME(m_stop1)); save_item(NAME(m_sel0)); save_item(NAME(m_sel1)); save_item(NAME(m_tach0)); save_item(NAME(m_tach1)); save_item(NAME(m_rdy0)); save_item(NAME(m_rdy1)); - save_item(NAME(m_ds0)); - save_item(NAME(m_ds1)); save_item(NAME(m_l0ms)); save_item(NAME(m_l1ms)); save_item(NAME(m_st0)); @@ -307,14 +281,11 @@ void victor_9000_fdc_t::device_reset() m_via6->reset(); // set floppy callbacks - m_floppy0->setup_ready_cb(floppy_image_device::ready_cb(FUNC(victor_9000_fdc_t::ready0_cb), this)); m_floppy0->setup_load_cb(floppy_image_device::load_cb(FUNC(victor_9000_fdc_t::load0_cb), this)); m_floppy0->setup_unload_cb(floppy_image_device::unload_cb(FUNC(victor_9000_fdc_t::unload0_cb), this)); - m_floppy0->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(victor_9000_fdc_t::index0_cb), this)); - m_floppy1->setup_ready_cb(floppy_image_device::ready_cb(FUNC(victor_9000_fdc_t::ready1_cb), this)); + m_floppy1->setup_load_cb(floppy_image_device::load_cb(FUNC(victor_9000_fdc_t::load1_cb), this)); m_floppy1->setup_unload_cb(floppy_image_device::unload_cb(FUNC(victor_9000_fdc_t::unload1_cb), this)); - m_floppy1->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(victor_9000_fdc_t::index1_cb), this)); } @@ -324,8 +295,21 @@ void victor_9000_fdc_t::device_reset() void victor_9000_fdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - live_sync(); - live_run(); + switch (id) + { + case TM_GEN: + live_sync(); + live_run(); + break; + + case TM_TACH0: + m_tach0 = 1; + break; + + case TM_TACH1: + m_tach1 = 1; + break; + } } @@ -360,27 +344,7 @@ READ8_MEMBER( victor_9000_fdc_t::floppy_p1_r ) READ8_MEMBER( victor_9000_fdc_t::floppy_p2_r ) { - /* - - bit description - - 0 - 1 - 2 - 3 - 4 - 5 - 6 RDY0 - 7 RDY1 - - */ - - UINT8 data = 0; - - data |= m_rdy0 << 6; - data |= m_rdy1 << 7; - - return data; + return m_p2; // TODO needed because of ORL/ANL P2, should be in mcs48.c } @@ -400,22 +364,26 @@ WRITE8_MEMBER( victor_9000_fdc_t::floppy_p2_w ) 3 STOP1 4 SEL1 5 SEL0 - 6 - 7 + 6 RDY0 + 7 RDY1 */ + m_p2 = data; + bool sync = false; - int mtr0 = m_mtr0; - if ((data & 0x03) == 0x01) mtr0 = 0; - if ((data & 0x03) == 0x02) mtr0 = 1; - if (m_mtr0 != mtr0) sync = true; + int start0 = BIT(data, 0); + if (m_start0 != start0) sync = true; - int mtr1 = m_mtr1; - if ((data & 0x0c) == 0x04) mtr1 = 0; - if ((data & 0x0c) == 0x08) mtr1 = 1; - if (m_mtr1 != mtr1) sync = true; + int stop0 = BIT(data, 1); + if (m_stop0 != stop0) sync = true; + + int start1 = BIT(data, 2); + if (m_start1 != start1) sync = true; + + int stop1 = BIT(data, 3); + if (m_stop1 != stop1) sync = true; int sel0 = BIT(data, 5); if (m_sel0 != sel0) sync = true; @@ -423,21 +391,28 @@ WRITE8_MEMBER( victor_9000_fdc_t::floppy_p2_w ) int sel1 = BIT(data, 4); if (m_sel1 != sel1) sync = true; + m_rdy0 = BIT(data, 6); + m_rdy1 = BIT(data, 7); + + if (LOG) logerror("%s %s START0/STOP0/SEL0/RDY0 %u/%u/%u/%u START1/STOP1/SEL1/RDY1 %u/%u/%u/%u\n", machine().time().as_string(), machine().describe_context(), start0, stop0, sel0, m_rdy0, start1, stop1, sel1, m_rdy1); + if (sync) { live_sync(); - m_mtr0 = mtr0; - m_mtr1 = mtr1; + m_start0 = start0; + m_stop0 = stop0; m_sel0 = sel0; + update_spindle_motor(m_floppy0, t_tach0, m_start0, m_stop0, m_sel0, m_da0); + + m_start1 = start1; + m_stop1 = stop1; m_sel1 = sel1; + update_spindle_motor(m_floppy1, t_tach1, m_start1, m_stop1, m_sel1, m_da1); - if (LOG) logerror("%s MTR0 %u MTR1 %u SEL0 %u SEL1 %u\n", machine().time().as_string(), m_mtr0, m_mtr1, m_sel0, m_sel1); - - update_spindle_motor(); checkpoint(); - if (!m_mtr0 || !m_mtr1) { + if (!m_floppy0->mon_r() || !m_floppy1->mon_r()) { if(cur_live.state == IDLE) { live_start(); } @@ -456,7 +431,11 @@ WRITE8_MEMBER( victor_9000_fdc_t::floppy_p2_w ) READ8_MEMBER( victor_9000_fdc_t::tach0_r ) { - return m_tach0; + int tach0 = m_tach0; + + m_tach0 = 0; + + return tach0; } @@ -466,24 +445,58 @@ READ8_MEMBER( victor_9000_fdc_t::tach0_r ) READ8_MEMBER( victor_9000_fdc_t::tach1_r ) { - return m_tach1; + int tach1 = m_tach1; + + m_tach1 = 0; + + return tach1; } void victor_9000_fdc_t::update_stepper_motor(floppy_image_device *floppy, int stp, int old_st, int st) { - // TODO + if (stp) return; + + int tracks = 0; + + switch (old_st) + { + case 6: if (st == 0xa) tracks++; else if (st == 5) tracks--; break; + case 5: if (st == 6) tracks++; else if (st == 9) tracks--; break; + case 9: if (st == 5) tracks++; else if (st == 0xa) tracks--; break; + case 0xa: if (st == 9) tracks++; else if (st == 6) tracks--; break; + } + + if (tracks == -1) + { + floppy->dir_w(1); + floppy->stp_w(1); + floppy->stp_w(0); + } + else if (tracks == 1) + { + floppy->dir_w(0); + floppy->stp_w(1); + floppy->stp_w(0); + } } -void victor_9000_fdc_t::update_spindle_motor() +void victor_9000_fdc_t::update_spindle_motor(floppy_image_device *floppy, emu_timer *t_tach, bool start, bool stop, bool sel, UINT8 &da) { - if (m_sel0) m_da0 = m_da; - m_floppy0->mon_w(m_mtr0); - m_floppy0->set_rpm(300); // TODO + if (!start && !stop && floppy->mon_r()) { + if (LOG) logerror("%s: motor start\n", floppy->tag()); + floppy->mon_w(0); + } else if (stop && !floppy->mon_r()) { + if (LOG) logerror("%s: motor stop\n", floppy->tag()); + floppy->mon_w(1); + } - if (m_sel1) m_da1 = m_da; - m_floppy1->mon_w(m_mtr1); - m_floppy1->set_rpm(300); // TODO + if (sel) { + da = m_da; + } + + floppy->set_rpm(300); // TODO + t_tach->adjust(attotime::from_hz(5)); // TODO } @@ -497,7 +510,9 @@ WRITE8_MEMBER( victor_9000_fdc_t::da_w ) { live_sync(); m_da = data; - update_spindle_motor(); + if (LOG) logerror("%s %s DA %02x\n", machine().time().as_string(), machine().describe_context(), data); + update_spindle_motor(m_floppy0, t_tach0, m_start0, m_stop0, m_sel0, m_da0); + update_spindle_motor(m_floppy1, t_tach1, m_start1, m_stop1, m_sel1, m_da1); checkpoint(); live_run(); } @@ -529,6 +544,7 @@ WRITE8_MEMBER( victor_9000_fdc_t::via4_pa_w ) live_sync(); update_stepper_motor(m_floppy0, m_stp0, st0, m_st0); m_st0 = st0; + if (LOG) logerror("%s %s L0MS %01x ST0 %01x\n", machine().time().as_string(), machine().describe_context(), m_l0ms, st0); checkpoint(); live_run(); } @@ -560,6 +576,7 @@ WRITE8_MEMBER( victor_9000_fdc_t::via4_pb_w ) live_sync(); update_stepper_motor(m_floppy1, m_stp1, st1, m_st1); m_st1 = st1; + if (LOG) logerror("%s %s L1MS %01x ST1 %01x\n", machine().time().as_string(), machine().describe_context(), m_l1ms, st1); checkpoint(); live_run(); } @@ -627,8 +644,8 @@ WRITE8_MEMBER( victor_9000_fdc_t::via5_pb_w ) if (m_wd != data) { live_sync(); - m_wd = data; - cur_live.wd = data; + m_wd = cur_live.wd = data; + if (LOG) logerror("%s %s WD %02x\n", machine().time().as_string(), machine().describe_context(), data); checkpoint(); live_run(); } @@ -659,6 +676,8 @@ READ8_MEMBER( victor_9000_fdc_t::via6_pa_r ) */ + if (LOG) logerror("%s %s TRK0D0 %u TRK0D1 %u\n", machine().time().as_string(), machine().describe_context(), m_floppy0->trk00_r(),m_floppy1->trk00_r()); + UINT8 data = 0; // track 0 drive A sense @@ -721,6 +740,8 @@ WRITE8_MEMBER( victor_9000_fdc_t::via6_pa_w ) m_drive = drive; cur_live.drive = drive; + if (LOG) logerror("%s %s SIDE %u DRIVE %u\n", machine().time().as_string(), machine().describe_context(), side, drive); + checkpoint(); live_run(); } @@ -752,10 +773,10 @@ READ8_MEMBER( victor_9000_fdc_t::via6_pb_r ) data |= m_rdy1 << 1; // door B sense - data |= m_ds1 << 3; + data |= (m_floppy1->exists() ? 0 : 1) << 3; // door A sense - data |= m_ds0 << 4; + data |= (m_floppy0->exists() ? 0 : 1) << 4; // single/double sided data |= (m_drive ? m_floppy1->twosid_r() : m_floppy0->twosid_r()) << 5; @@ -804,6 +825,8 @@ WRITE8_MEMBER( victor_9000_fdc_t::via6_pb_w ) m_stp1 = stp1; update_stepper_motor(m_floppy1, m_stp1, m_st1, m_st1); + if (LOG) logerror("%s %s STP0 %u STP1 %u\n", machine().time().as_string(), machine().describe_context(), stp0, stp1); + checkpoint(); live_run(); } @@ -816,7 +839,7 @@ WRITE_LINE_MEMBER( victor_9000_fdc_t::drw_w ) live_sync(); m_drw = cur_live.drw = state; checkpoint(); - if (LOG) logerror("%s DRW %u\n", machine().time().as_string(), state); + if (LOG) logerror("%s %s DRW %u\n", machine().time().as_string(), machine().describe_context(), state); if (state) { stop_writing(machine().time()); } else { @@ -833,7 +856,7 @@ WRITE_LINE_MEMBER( victor_9000_fdc_t::erase_w ) live_sync(); m_erase = cur_live.erase = state; checkpoint(); - if (LOG) logerror("%s ERASE %u\n", machine().time().as_string(), state); + if (LOG) logerror("%s %s ERASE %u\n", machine().time().as_string(), machine().describe_context(), state); live_run(); } } @@ -851,6 +874,7 @@ READ8_MEMBER( victor_9000_fdc_t::cs7_r ) { live_sync(); cur_live.lbrdy = 1; + if (LOG) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); m_lbrdy_cb(1); checkpoint(); live_run(); @@ -865,6 +889,7 @@ WRITE8_MEMBER( victor_9000_fdc_t::cs7_w ) { live_sync(); cur_live.lbrdy = 1; + if (LOG) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); m_lbrdy_cb(1); checkpoint(); live_run(); diff --git a/src/mess/machine/victor9k_fdc.h b/src/mess/machine/victor9k_fdc.h index d6eb959b659..e47b1116e17 100644 --- a/src/mess/machine/victor9k_fdc.h +++ b/src/mess/machine/victor9k_fdc.h @@ -97,6 +97,13 @@ protected: virtual machine_config_constructor device_mconfig_additions() const; private: + enum + { + TM_GEN, + TM_TACH0, + TM_TACH1 + }; + enum { LED_A = 0, @@ -154,34 +161,34 @@ private: required_device m_via6; required_device m_floppy0; required_device m_floppy1; + required_memory_region m_rom; required_memory_region m_gcr_rom; void update_stepper_motor(floppy_image_device *floppy, int stp, int old_st, int st); - void update_spindle_motor(); + void update_spindle_motor(floppy_image_device *floppy, emu_timer *t_tach, bool start, bool stop, bool sel, UINT8 &da); - void ready0_cb(floppy_image_device *, int device); int load0_cb(floppy_image_device *device); void unload0_cb(floppy_image_device *device); - void index0_cb(floppy_image_device *device, int state); - void ready1_cb(floppy_image_device *, int device); + int load1_cb(floppy_image_device *device); void unload1_cb(floppy_image_device *device); - void index1_cb(floppy_image_device *device, int state); + + UINT8 m_p2; /* floppy state */ UINT8 m_da; UINT8 m_da0; UINT8 m_da1; - int m_mtr0; - int m_mtr1; + int m_start0; + int m_stop0; + int m_start1; + int m_stop1; int m_sel0; int m_sel1; int m_tach0; int m_tach1; int m_rdy0; int m_rdy1; - int m_ds0; - int m_ds1; UINT8 m_l0ms; UINT8 m_l1ms; int m_st0; @@ -204,7 +211,7 @@ private: attotime m_period; live_info cur_live, checkpoint_live; - emu_timer *t_gen; + emu_timer *t_gen, *t_tach0, *t_tach1; floppy_image_device* get_floppy(); void live_start();