Skip to content

Commit d0b00a5

Browse files
authored
heathzenith/h89.cpp: Add wait states for mms 77316 fdc (#12502)
1 parent 21d5d9c commit d0b00a5

File tree

3 files changed

+49
-21
lines changed

3 files changed

+49
-21
lines changed

src/mame/heathzenith/h89.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ class h89_base_state : public driver_device
150150

151151
void h89_base_io(address_map &map);
152152

153+
void set_wait_state(int data);
154+
153155
u8 raise_NMI_r();
154156
void raise_NMI_w(u8 data);
155157
void console_intr(int data);
@@ -247,14 +249,14 @@ class h89_mms_state : public h89_base_state
247249
public:
248250
h89_mms_state(const machine_config &mconfig, device_type type, const char *tag):
249251
h89_base_state(mconfig, type, tag),
250-
m_mms(*this, "mms_fdc")
252+
m_mms316(*this, "mms77316")
251253
{
252254
}
253255

254256
void h89_mms(machine_config &config);
255257

256258
protected:
257-
required_device<mms77316_fdc_device> m_mms;
259+
required_device<mms77316_fdc_device> m_mms316;
258260

259261
void h89_mms_io(address_map &map);
260262
};
@@ -466,7 +468,7 @@ void h89_mms_state::h89_mms_io(address_map &map)
466468
h89_base_state::h89_base_io(map);
467469

468470
// Add MMS 77316 Double Density Controller
469-
map(0x38,0x3f).rw(m_mms, FUNC(mms77316_fdc_device::read), FUNC(mms77316_fdc_device::write));
471+
map(0x38,0x3f).rw(m_mms316, FUNC(mms77316_fdc_device::read), FUNC(mms77316_fdc_device::write));
470472
}
471473

472474

@@ -783,6 +785,16 @@ void h89_base_state::machine_reset()
783785
update_mem_view();
784786
}
785787

788+
void h89_base_state::set_wait_state(int data)
789+
{
790+
m_maincpu->set_input_line(Z80_INPUT_LINE_WAIT, data);
791+
if (data)
792+
{
793+
machine().scheduler().synchronize();
794+
m_maincpu->defer_access();
795+
}
796+
}
797+
786798
u8 h89_base_state::raise_NMI_r()
787799
{
788800
m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::from_usec(2));
@@ -1010,9 +1022,10 @@ void h89_mms_state::h89_mms(machine_config &config)
10101022
m_intr_socket->set_default_option("mms");
10111023
m_intr_socket->set_fixed(true);
10121024

1013-
MMS77316_FDC(config, m_mms);
1014-
m_mms->drq_cb().set(m_intr_socket, FUNC(heath_intr_socket::set_drq));
1015-
m_mms->irq_cb().set(m_intr_socket, FUNC(heath_intr_socket::set_irq));
1025+
MMS77316_FDC(config, m_mms316);
1026+
m_mms316->drq_cb().set(m_intr_socket, FUNC(heath_intr_socket::set_drq));
1027+
m_mms316->irq_cb().set(m_intr_socket, FUNC(heath_intr_socket::set_irq));
1028+
m_mms316->wait_cb().set(FUNC(h89_mms_state::set_wait_state));
10161029
}
10171030

10181031

src/mame/heathzenith/mms77316_fdc.cpp

+27-14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ mms77316_fdc_device::mms77316_fdc_device(const machine_config &mconfig, const ch
4141
device_t(mconfig, MMS77316_FDC, tag, owner, 0),
4242
m_irq_cb(*this),
4343
m_drq_cb(*this),
44+
m_wait_cb(*this),
4445
m_fdc(*this, "mms_fdc"),
4546
m_floppies(*this, "mms_fdc:%u", 0U)
4647
{
@@ -84,7 +85,7 @@ void mms77316_fdc_device::ctrl_w(u8 val)
8485
floppy_image_device *floppy = elem->get_device();
8586
if (floppy)
8687
{
87-
// turn on all installed 5" floppies
88+
// set motor for installed 5" drives
8889
floppy->mon_w(!five_in_drv);
8990
}
9091
}
@@ -93,10 +94,12 @@ void mms77316_fdc_device::ctrl_w(u8 val)
9394

9495
void mms77316_fdc_device::data_w(u8 val)
9596
{
96-
if (burstMode())
97+
if (burst_mode_r() && !m_drq && !m_irq)
9798
{
98-
// TODO add wait states in burst mode, currently blocked on Z80 properly supporting wait states
99-
LOGBURST("%s: burst_mode: %d\n", FUNCNAME, val);
99+
LOGBURST("%s: burst_mode_r\n", FUNCNAME);
100+
m_wait_cb(ASSERT_LINE);
101+
102+
return;
100103
}
101104

102105
m_fdc->data_w(val);
@@ -133,10 +136,12 @@ void mms77316_fdc_device::write(offs_t reg, u8 val)
133136

134137
u8 mms77316_fdc_device::data_r()
135138
{
136-
if (burstMode())
139+
if (burst_mode_r() && !m_drq && !m_irq)
137140
{
138-
// TODO add wait states in burst mode, currently blocked on Z80 properly supporting wait states
139-
LOGBURST("%s: burst_mode\n", FUNCNAME);
141+
LOGBURST("%s: burst_mode setting wait state\n", FUNCNAME);
142+
m_wait_cb(ASSERT_LINE);
143+
144+
return(0x00);
140145
}
141146

142147
return m_fdc->data_r();
@@ -193,6 +198,7 @@ void mms77316_fdc_device::device_reset()
193198

194199
m_irq_cb(0);
195200
m_drq_cb(0);
201+
m_wait_cb(0);
196202
for (int i = 0; i < 4; i++)
197203
{
198204
auto elem = m_floppies[i];
@@ -265,6 +271,7 @@ void mms77316_fdc_device::set_irq(int state)
265271

266272
if (state)
267273
{
274+
m_wait_cb(CLEAR_LINE);
268275
m_drq_count = 0;
269276
}
270277

@@ -275,16 +282,22 @@ void mms77316_fdc_device::set_irq(int state)
275282

276283
void mms77316_fdc_device::set_drq(int state)
277284
{
278-
bool drq_allowed = false;
279-
280285
LOGLINES("set drq, allowed: %d state: %d\n", m_drq_allowed, state);
286+
281287
m_drq = state;
282288

283-
if (m_drq)
289+
if (burst_mode_r())
284290
{
285-
// even if drq bit is not set, trigger if the first one after an IRQ.
286-
drq_allowed = m_drq_allowed || (m_drq_count++ == 0);
287-
}
291+
LOGBURST("%s: in burst mode drq: %d, m_drq_count: %d\n", FUNCNAME, m_drq, m_drq_count);
292+
if (m_drq)
293+
{
294+
m_wait_cb(CLEAR_LINE);
295+
}
288296

289-
m_drq_cb(drq_allowed ? m_drq : CLEAR_LINE);
297+
m_drq_cb(m_drq_count == 0 ? m_drq : CLEAR_LINE);
298+
}
299+
else
300+
{
301+
m_drq_cb(m_drq_allowed ? m_drq : CLEAR_LINE);
302+
}
290303
}

src/mame/heathzenith/mms77316_fdc.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class mms77316_fdc_device : public device_t
2626

2727
auto irq_cb() { return m_irq_cb.bind(); }
2828
auto drq_cb() { return m_drq_cb.bind(); }
29+
auto wait_cb() { return m_wait_cb.bind(); }
2930

3031
protected:
3132

@@ -43,12 +44,13 @@ class mms77316_fdc_device : public device_t
4344
// Burst mode was required for a 2 MHz Z80 to handle 8" DD data rates.
4445
// The typical irq/drq was too slow, this utilizes wait states to read the
4546
// WD1797 data port once the drq line is high.
46-
inline bool burstMode() { return !m_drq_allowed; }
47+
inline bool burst_mode_r() { return !m_drq_allowed; }
4748

4849
private:
4950

5051
devcb_write_line m_irq_cb;
5152
devcb_write_line m_drq_cb;
53+
devcb_write_line m_wait_cb;
5254

5355
required_device<fd1797_device> m_fdc;
5456
required_device_array<floppy_connector, 8> m_floppies;

0 commit comments

Comments
 (0)