diff options
Diffstat (limited to 'src/devices/bus/ti99/peb/hfdc.cpp')
-rw-r--r-- | src/devices/bus/ti99/peb/hfdc.cpp | 104 |
1 files changed, 41 insertions, 63 deletions
diff --git a/src/devices/bus/ti99/peb/hfdc.cpp b/src/devices/bus/ti99/peb/hfdc.cpp index 2e5d7173c44..ad116788507 100644 --- a/src/devices/bus/ti99/peb/hfdc.cpp +++ b/src/devices/bus/ti99/peb/hfdc.cpp @@ -59,19 +59,20 @@ #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_GENERAL | 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(TI99_HFDC, bus::ti99::peb::myarc_hfdc_device, "ti99_hfdc", "Myarc Hard and Floppy Disk Controller") @@ -84,8 +85,6 @@ namespace bus::ti99::peb { #define NONE -1 -#define MOTOR_TIMER 1 - #define TAPE_ADDR 0x0fc0 #define HDC_R_ADDR 0x0fd0 #define HDC_W_ADDR 0x0fd2 @@ -103,6 +102,8 @@ myarc_hfdc_device::myarc_hfdc_device(const machine_config &mconfig, const char * m_motor_on_timer(nullptr), m_hdc9234(*this, FDC_TAG), 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), @@ -507,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); } @@ -548,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(); } @@ -728,7 +729,7 @@ 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. @@ -758,7 +759,7 @@ void myarc_hfdc_device::connect_harddisk_unit(int index) 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); @@ -820,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); @@ -842,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) @@ -854,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; } @@ -885,7 +886,7 @@ 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; @@ -944,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 @@ -965,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, @@ -1081,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 |