diff options
Diffstat (limited to 'src/devices/bus/ti99/peb/hfdc.cpp')
-rw-r--r-- | src/devices/bus/ti99/peb/hfdc.cpp | 146 |
1 files changed, 71 insertions, 75 deletions
diff --git a/src/devices/bus/ti99/peb/hfdc.cpp b/src/devices/bus/ti99/peb/hfdc.cpp index 8659e111d69..ad116788507 100644 --- a/src/devices/bus/ti99/peb/hfdc.cpp +++ b/src/devices/bus/ti99/peb/hfdc.cpp @@ -59,30 +59,31 @@ #include "formats/mfm_hd.h" #include "formats/ti99_dsk.h" // Format -#define LOG_WARN (1U<<1) // Warnings -#define LOG_EMU (1U<<2) -#define LOG_COMP (1U<<3) -#define LOG_RAM (1U<<4) -#define LOG_ROM (1U<<5) -#define LOG_LINES (1U<<6) -#define LOG_DMA (1U<<7) -#define LOG_MOTOR (1U<<8) -#define LOG_INT (1U<<9) -#define LOG_CRU (1U<<10) -#define LOG_CONFIG (1U<<15) // Configuration - -#define VERBOSE ( LOG_CONFIG | LOG_WARN ) +#define LOG_WARN (1U << 1) // Warnings +#define LOG_EMU (1U << 2) +#define LOG_COMP (1U << 3) +#define LOG_RAM (1U << 4) +#define LOG_ROM (1U << 5) +#define LOG_LINES (1U << 6) +#define LOG_DMA (1U << 7) +#define LOG_MOTOR (1U << 8) +#define LOG_INT (1U << 9) +#define LOG_CRU (1U << 10) +#define LOG_SKCOM (1U << 11) +#define LOG_CONFIG (1U << 15) // Configuration + +#define VERBOSE (LOG_GENERAL | LOG_CONFIG | LOG_WARN) #include "logmacro.h" -DEFINE_DEVICE_TYPE_NS(TI99_HFDC, bus::ti99::peb, myarc_hfdc_device, "ti99_hfdc", "Myarc Hard and Floppy Disk Controller") +DEFINE_DEVICE_TYPE(TI99_HFDC, bus::ti99::peb::myarc_hfdc_device, "ti99_hfdc", "Myarc Hard and Floppy Disk Controller") -namespace bus { namespace ti99 { namespace peb { +namespace bus::ti99::peb { #define BUFFER "ram" #define FDC_TAG "hdc9234" #define CLOCK_TAG "mm58274c" -#define MOTOR_TIMER 1 +#define NONE -1 #define TAPE_ADDR 0x0fc0 #define HDC_R_ADDR 0x0fd0 @@ -100,8 +101,14 @@ myarc_hfdc_device::myarc_hfdc_device(const machine_config &mconfig, const char * device_ti99_peribox_card_interface(mconfig, *this), m_motor_on_timer(nullptr), m_hdc9234(*this, FDC_TAG), - m_clock(*this, CLOCK_TAG), m_current_floppy(nullptr), - m_current_harddisk(nullptr), m_see_switches(false), + m_clock(*this, CLOCK_TAG), + m_floppy(*this, "f%u", 1), + m_harddisk(*this, "h%u", 1), + m_current_floppy(nullptr), + m_current_harddisk(nullptr), + m_current_floppy_index(NONE), + m_current_hd_index(NONE), + m_see_switches(false), m_irq(), m_dip(), m_motor_running(false), m_inDsrArea(false), m_HDCsel(false), m_RTCsel(false), m_tapesel(false), m_RAMsel(false), m_ROMsel(false), m_address(0), @@ -501,7 +508,7 @@ void myarc_hfdc_device::cruwrite(offs_t offset, uint8_t data) /* Monoflop has gone back to the OFF state. */ -void myarc_hfdc_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(myarc_hfdc_device::motor_off) { set_floppy_motors_running(false); } @@ -542,7 +549,7 @@ void myarc_hfdc_device::harddisk_ready_callback(mfm_harddisk_device *harddisk, i */ void myarc_hfdc_device::harddisk_skcom_callback(mfm_harddisk_device *harddisk, int state) { - LOGMASKED(LOG_LINES, "HD seek complete = %d\n", state); + LOGMASKED(LOG_SKCOM, "HD seek complete = %d\n", state); set_bits(m_status_latch, hdc92x4_device::DS_SKCOM, (state==ASSERT_LINE)); signal_drive_status(); } @@ -714,7 +721,7 @@ enum void myarc_hfdc_device::connect_floppy_unit(int index) { // Check if we have a new floppy - if (m_floppy_unit[index] != m_current_floppy) + if (index != m_current_floppy_index) { // Clear all latched flags from other drives m_status_latch = 0; @@ -722,7 +729,8 @@ void myarc_hfdc_device::connect_floppy_unit(int index) LOGMASKED(LOG_LINES, "Select floppy drive DSK%d\n", index+1); // Connect new drive - m_current_floppy = m_floppy_unit[index]; + m_current_floppy = m_floppy[index]->get_device(); + m_current_floppy_index = index; // We don't use the READY line of floppy drives. // READY is asserted when DSKx = 1 @@ -732,7 +740,9 @@ void myarc_hfdc_device::connect_floppy_unit(int index) m_current_floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(&myarc_hfdc_device::floppy_index_callback, this)); else LOGMASKED(LOG_WARN, "Connection to DSK%d failed because no drive is connected\n", index+1); - m_hdc9234->connect_floppy_drive(m_floppy_unit[index]); + + // Connect to HDC (or disconnect) + m_hdc9234->connect_floppy_drive(m_current_floppy); } // We can only run a floppy or a harddisk at a time, not both @@ -741,15 +751,16 @@ void myarc_hfdc_device::connect_floppy_unit(int index) void myarc_hfdc_device::connect_harddisk_unit(int index) { - if (m_harddisk_unit[index] != m_current_harddisk) + if (index != m_current_hd_index) { - // Clear all latched flags form other drives + // Clear all latched flags from other drives m_status_latch = 0; disconnect_hard_drives(); LOGMASKED(LOG_LINES, "Select hard disk WDS%d\n", index+1); // Connect new drive - m_current_harddisk = m_harddisk_unit[index]; + m_current_harddisk = m_harddisk[index]->get_device(); + m_current_hd_index = index; LOGMASKED(LOG_LINES, "Connect index callback WDS%d\n", index+1); if (m_current_harddisk != nullptr) @@ -760,6 +771,8 @@ void myarc_hfdc_device::connect_harddisk_unit(int index) } else LOGMASKED(LOG_WARN, "Connection to WDS%d failed because no drive is connected\n", index+1); + + // Connect to HDC (or disconnect) m_hdc9234->connect_hard_drive(m_current_harddisk); } @@ -776,6 +789,7 @@ void myarc_hfdc_device::disconnect_floppy_drives() m_current_floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb()); m_current_floppy = nullptr; } + m_current_floppy_index = NONE; } void myarc_hfdc_device::disconnect_hard_drives() @@ -787,6 +801,7 @@ void myarc_hfdc_device::disconnect_hard_drives() m_current_harddisk->setup_seek_complete_cb(mfm_harddisk_device::seek_complete_cb()); m_current_harddisk = nullptr; } + m_current_hd_index = NONE; } /* @@ -806,14 +821,14 @@ void myarc_hfdc_device::set_floppy_motors_running(bool run) } // Set all motors - for (auto & elem : m_floppy_unit) - if (elem != nullptr) elem->mon_w((run)? 0 : 1); + for (auto & elem : m_floppy) + if (elem->get_device() != nullptr) elem->get_device()->mon_w((run)? 0 : 1); } /* Called whenever the state of the HDC9234 interrupt pin changes. */ -WRITE_LINE_MEMBER( myarc_hfdc_device::intrq_w ) +void myarc_hfdc_device::intrq_w(int state) { m_irq = (line_state)state; LOGMASKED(LOG_INT, "INT pin from controller = %d, propagating to INTA*\n", state); @@ -828,7 +843,7 @@ WRITE_LINE_MEMBER( myarc_hfdc_device::intrq_w ) Called whenever the HDC9234 desires bus access to the buffer RAM. The controller expects a call to dmarq in 1 byte time. */ -WRITE_LINE_MEMBER( myarc_hfdc_device::dmarq_w ) +void myarc_hfdc_device::dmarq_w(int state) { LOGMASKED(LOG_DMA, "DMARQ pin from controller = %d\n", state); if (state == ASSERT_LINE) @@ -840,7 +855,7 @@ WRITE_LINE_MEMBER( myarc_hfdc_device::dmarq_w ) /* Called whenever the state of the HDC9234 DMA in progress changes. */ -WRITE_LINE_MEMBER( myarc_hfdc_device::dip_w ) +void myarc_hfdc_device::dip_w(int state) { m_dip = (line_state)state; } @@ -871,10 +886,12 @@ void myarc_hfdc_device::write_buffer(uint8_t data) void myarc_hfdc_device::device_start() { m_dsrrom = memregion(TI99_DSRROM)->base(); - m_motor_on_timer = timer_alloc(MOTOR_TIMER); + m_motor_on_timer = timer_alloc(FUNC(myarc_hfdc_device::motor_off), this); // The HFDC does not use READY; it has on-board RAM for DMA m_current_floppy = nullptr; m_current_harddisk = nullptr; + m_current_floppy_index = NONE; + m_current_hd_index = NONE; // Parent class members save_item(NAME(m_senila)); @@ -928,20 +945,20 @@ void myarc_hfdc_device::device_reset() m_lastval = 0; m_readyflags = 0; - for (int i=0; i < 4; i++) + for (auto &flop : m_floppy) { - if (m_floppy_unit[i] != nullptr) - LOGMASKED(LOG_CONFIG, "FD connector %d with %s\n", i+1, m_floppy_unit[i]->name()); + if (flop->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "FD connector %d with %s\n", flop->basetag(), flop->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "FD connector %d has no floppy attached\n", i+1); + LOGMASKED(LOG_CONFIG, "FD connector %d has no floppy attached\n", flop->basetag()); } - for (int i=0; i < 3; i++) + for (auto &hard : m_harddisk) { - if (m_harddisk_unit[i] != nullptr) - LOGMASKED(LOG_CONFIG, "HD connector %d with %s\n", i+1, m_harddisk_unit[i]->name()); + if (hard->get_device() != nullptr) + LOGMASKED(LOG_CONFIG, "HD connector %d with %s\n", hard->basetag(), hard->get_device()->name()); else - LOGMASKED(LOG_CONFIG, "HD connector %d has no drive attached\n", i+1); + LOGMASKED(LOG_CONFIG, "HD connector %d has no floppy attached\n", hard->basetag()); } // Disconnect all units @@ -949,29 +966,6 @@ void myarc_hfdc_device::device_reset() disconnect_hard_drives(); } -void myarc_hfdc_device::device_config_complete() -{ - for (int i=0; i < 3; i++) - { - m_floppy_unit[i] = nullptr; - m_harddisk_unit[i] = nullptr; - } - m_floppy_unit[3] = nullptr; - - // Seems to be null when doing a "-listslots" - if (subdevice("f1")!=nullptr) - { - m_floppy_unit[0] = static_cast<floppy_connector*>(subdevice("f1"))->get_device(); - m_floppy_unit[1] = static_cast<floppy_connector*>(subdevice("f2"))->get_device(); - m_floppy_unit[2] = static_cast<floppy_connector*>(subdevice("f3"))->get_device(); - m_floppy_unit[3] = static_cast<floppy_connector*>(subdevice("f4"))->get_device(); - - m_harddisk_unit[0] = static_cast<mfm_harddisk_connector*>(subdevice("h1"))->get_device(); - m_harddisk_unit[1] = static_cast<mfm_harddisk_connector*>(subdevice("h2"))->get_device(); - m_harddisk_unit[2] = static_cast<mfm_harddisk_connector*>(subdevice("h3"))->get_device(); - } -} - /* The HFDC controller can be configured for different CRU base addresses, but DSK1-DSK4 are only available for CRU 1100. For all other addresses, @@ -1025,10 +1019,12 @@ INPUT_PORTS_START( ti99_hfdc ) PORT_DIPSETTING( 0x30, "80 track HD, 2 ms") INPUT_PORTS_END -FLOPPY_FORMATS_MEMBER(myarc_hfdc_device::floppy_formats) - FLOPPY_TI99_SDF_FORMAT, - FLOPPY_TI99_TDF_FORMAT -FLOPPY_FORMATS_END +void myarc_hfdc_device::floppy_formats(format_registration &fr) +{ + fr.add_mfm_containers(); + fr.add(FLOPPY_TI99_SDF_FORMAT); + fr.add(FLOPPY_TI99_TDF_FORMAT); +} static void hfdc_floppies(device_slot_interface &device) { @@ -1063,15 +1059,15 @@ void myarc_hfdc_device::device_add_mconfig(machine_config& config) m_hdc9234->dmaout_cb().set(FUNC(myarc_hfdc_device::write_buffer)); // First two floppy drives shall be connected by default - FLOPPY_CONNECTOR(config, "f1", hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "f2", hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "f3", hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); - FLOPPY_CONNECTOR(config, "f4", hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[0], hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[1], hfdc_floppies, "525dd", myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[2], hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); + FLOPPY_CONNECTOR(config, m_floppy[3], hfdc_floppies, nullptr, myarc_hfdc_device::floppy_formats).enable_sound(true); // Hard disks don't go without image (other than floppy drives) - MFM_HD_CONNECTOR(config, "h1", hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); - MFM_HD_CONNECTOR(config, "h2", hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); - MFM_HD_CONNECTOR(config, "h3", hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[0], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[1], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); + MFM_HD_CONNECTOR(config, m_harddisk[2], hfdc_harddisks, nullptr, MFM_BYTE, 3000, 20, MFMHD_GEN_FORMAT); MM58274C(config, CLOCK_TAG, 0).set_mode_and_day(1, 0); // 24h, sunday @@ -1088,4 +1084,4 @@ ioport_constructor myarc_hfdc_device::device_input_ports() const return INPUT_PORTS_NAME( ti99_hfdc ); } -} } } // end namespace bus::ti99::peb +} // end namespace bus::ti99::peb |