heathzenith/mms77316_fdc.cpp,z37_fdc.cpp: Minor cleanup, improve logs. (#12523)

This commit is contained in:
Mark Garlanger 2024-06-29 11:22:16 -05:00 committed by GitHub
parent 79e5eacf71
commit 5f4e3813eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 53 additions and 35 deletions

View file

@ -2,8 +2,11 @@
// copyright-holders:Mark Garlanger
/***************************************************************************
Magnolia Microsystems 77316 soft-sectored floppy controller
Magnolia Microsystems 77316 DD soft-sectored floppy controller
Supported upto 8 floppy drives
- 4 8" drives
- 4 5.25" drives
****************************************************************************/
@ -17,6 +20,7 @@
#define LOG_FUNC (1U << 4) // Function calls
#define LOG_ERR (1U << 5) // log errors
#define LOG_BURST (1U << 6) // burst mode
#define LOG_DATA (1U << 7) // data read/writes
#define VERBOSE (0)
@ -28,6 +32,7 @@
#define LOGFUNC(...) LOGMASKED(LOG_FUNC, __VA_ARGS__)
#define LOGERR(...) LOGMASKED(LOG_ERR, __VA_ARGS__)
#define LOGBURST(...) LOGMASKED(LOG_BURST, __VA_ARGS__)
#define LOGDATA(...) LOGMASKED(LOG_DATA, __VA_ARGS__)
#ifdef _MSC_VER
#define FUNCNAME __func__
@ -49,6 +54,8 @@ mms77316_fdc_device::mms77316_fdc_device(const machine_config &mconfig, const ch
void mms77316_fdc_device::ctrl_w(u8 val)
{
LOGREG("%s: val: %d\n", FUNCNAME, val);
u8 floppy_drive = BIT(val, 0, 3);
u8 five_in_drv = bool(BIT(val, ctrl_525DriveSel_c));
@ -58,6 +65,8 @@ void mms77316_fdc_device::ctrl_w(u8 val)
m_fdc->dden_w(BIT(val, ctrl_SetMFMRecording_c));
LOGLINES("%s: intrq allowed: %d, drq allowed: %d\n", FUNCNAME, m_irq_allowed, m_drq_allowed);
if (m_irq_allowed)
{
m_irq_cb(m_irq);
@ -69,12 +78,10 @@ void mms77316_fdc_device::ctrl_w(u8 val)
m_drq_cb(CLEAR_LINE);
}
LOGREG("%s: floppydrive: %d\n", FUNCNAME, floppy_drive);
LOGDRIVE("%s: floppydrive: %d, 5.25 in: %d\n", FUNCNAME, floppy_drive, five_in_drv);
m_fdc->set_floppy(m_floppies[floppy_drive]->get_device());
LOGREG("%s: intrq allowed: %d, drq allowed: %d\n", FUNCNAME, m_irq_allowed, m_drq_allowed);
m_fdc->set_clock(five_in_drv ? FIVE_IN_CLOCK : EIGHT_IN_CLOCK);
for (int i = 4; i < 8; i++)
@ -94,11 +101,13 @@ void mms77316_fdc_device::ctrl_w(u8 val)
void mms77316_fdc_device::data_w(u8 val)
{
LOGDATA("%s: val: %d\n", FUNCNAME, val);
if (burst_mode_r() && !m_drq && !m_irq)
{
LOGBURST("%s: burst_mode_r\n", FUNCNAME);
m_wait_cb(ASSERT_LINE);
m_wait_cb(ASSERT_LINE);
return;
}
@ -107,7 +116,7 @@ void mms77316_fdc_device::data_w(u8 val)
void mms77316_fdc_device::write(offs_t reg, u8 val)
{
LOGFUNC("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, val);
LOGREG("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, val);
switch (reg)
{
@ -117,7 +126,7 @@ void mms77316_fdc_device::write(offs_t reg, u8 val)
case 1:
case 2:
case 3:
LOGFUNC("%s: Unexpected port write reg: %d val: 0x%02x\n", FUNCNAME, reg, val);
LOGERR("%s: Unexpected port write reg: %d val: 0x%02x\n", FUNCNAME, reg, val);
break;
case 4:
m_fdc->cmd_w(val);
@ -136,15 +145,22 @@ void mms77316_fdc_device::write(offs_t reg, u8 val)
u8 mms77316_fdc_device::data_r()
{
u8 data = 0;
if (burst_mode_r() && !m_drq && !m_irq)
{
LOGBURST("%s: burst_mode setting wait state\n", FUNCNAME);
m_wait_cb(ASSERT_LINE);
return(0x00);
m_wait_cb(ASSERT_LINE);
}
else
{
data = m_fdc->data_r();
}
return m_fdc->data_r();
LOGDATA("%s: data: %d\n", FUNCNAME, data);
return data;
}
u8 mms77316_fdc_device::read(offs_t reg)
@ -175,7 +191,7 @@ u8 mms77316_fdc_device::read(offs_t reg)
break;
}
LOGFUNC("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, value);
LOGREG("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, value);
return value;
}
@ -196,9 +212,10 @@ void mms77316_fdc_device::device_reset()
m_irq = false;
m_drq_count = 0;
m_irq_cb(0);
m_drq_cb(0);
m_wait_cb(0);
m_irq_cb(CLEAR_LINE);
m_drq_cb(CLEAR_LINE);
m_wait_cb(CLEAR_LINE);
for (int i = 0; i < 4; i++)
{
auto elem = m_floppies[i];
@ -217,25 +234,25 @@ void mms77316_fdc_device::device_reset()
static void mms_5_in_floppies(device_slot_interface &device)
{
// H-17-1 -- SS 48tpi
device.option_add("5_ssdd", FLOPPY_525_SSDD);
device.option_add("5_ss_dd", FLOPPY_525_SSDD);
// SS 96tpi
device.option_add("5_ssqd", FLOPPY_525_SSQD);
device.option_add("5_ss_qd", FLOPPY_525_SSQD);
// DS 48tpi
device.option_add("5_dd", FLOPPY_525_DD);
device.option_add("5_ds_dd", FLOPPY_525_DD);
// H-17-4 / H-17-5 -- DS 96tpi
device.option_add("5_qd", FLOPPY_525_QD);
device.option_add("5_ds_qd", FLOPPY_525_QD);
}
static void mms_8_in_floppies(device_slot_interface &device)
{
// 8" DSDD
device.option_add("8_sssd", FLOPPY_8_SSSD);
device.option_add("8_ss_sd", FLOPPY_8_SSSD);
// 8" SSDD
device.option_add("8_dssd", FLOPPY_8_DSSD);
device.option_add("8_ds_sd", FLOPPY_8_DSSD);
// 8" DSDD
device.option_add("8_ssdd", FLOPPY_8_SSDD);
device.option_add("8_ss_dd", FLOPPY_8_SSDD);
// 8" SSDD
device.option_add("8_dsdd", FLOPPY_8_DSDD);
device.option_add("8_ds_dd", FLOPPY_8_DSDD);
}
void mms77316_fdc_device::device_add_mconfig(machine_config &config)
@ -245,23 +262,23 @@ void mms77316_fdc_device::device_add_mconfig(machine_config &config)
m_fdc->drq_wr_callback().set(FUNC(mms77316_fdc_device::set_drq));
// 8" Floppy drives
FLOPPY_CONNECTOR(config, m_floppies[0], mms_8_in_floppies, "8_dsdd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[0], mms_8_in_floppies, "8_ds_dd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[0]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[1], mms_8_in_floppies, "8_dsdd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[1], mms_8_in_floppies, "8_ds_dd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[1]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[2], mms_8_in_floppies, "8_dsdd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[2], mms_8_in_floppies, "8_ds_dd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[2]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[3], mms_8_in_floppies, "8_dsdd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[3], mms_8_in_floppies, "8_ds_dd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[3]->enable_sound(true);
// 5" Floppy drives
FLOPPY_CONNECTOR(config, m_floppies[4], mms_5_in_floppies, "5_qd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[4], mms_5_in_floppies, "5_ds_qd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[4]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[5], mms_5_in_floppies, "5_qd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[5], mms_5_in_floppies, "5_ds_qd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[5]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[6], mms_5_in_floppies, "5_qd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[6], mms_5_in_floppies, "5_ds_qd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[6]->enable_sound(true);
FLOPPY_CONNECTOR(config, m_floppies[7], mms_5_in_floppies, "5_qd", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, m_floppies[7], mms_5_in_floppies, "5_ds_qd", floppy_image_device::default_mfm_floppy_formats);
m_floppies[7]->enable_sound(true);
}
@ -269,14 +286,14 @@ void mms77316_fdc_device::set_irq(int state)
{
LOGLINES("set irq, allowed: %d state: %d\n", m_irq_allowed, state);
if (state)
m_irq = state;
if (m_irq)
{
m_wait_cb(CLEAR_LINE);
m_drq_count = 0;
}
m_irq = state;
m_irq_cb(m_irq_allowed ? m_irq : CLEAR_LINE);
}
@ -289,6 +306,7 @@ void mms77316_fdc_device::set_drq(int state)
if (burst_mode_r())
{
LOGBURST("%s: in burst mode drq: %d, m_drq_count: %d\n", FUNCNAME, m_drq, m_drq_count);
if (m_drq)
{
m_wait_cb(CLEAR_LINE);

View file

@ -131,7 +131,7 @@ u8 heath_z37_fdc_device::data_r()
void heath_z37_fdc_device::write(offs_t reg, u8 val)
{
LOGFUNC("%s: reg: %d val: %d\n", FUNCNAME, reg, val);
LOGFUNC("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, val);
switch (reg)
{
@ -169,7 +169,7 @@ u8 heath_z37_fdc_device::read(offs_t reg)
break;
}
LOGFUNC("%s: reg: %d val: %d\n", FUNCNAME, reg, value);
LOGFUNC("%s: reg: %d val: 0x%02x\n", FUNCNAME, reg, value);
return value;
}