(mess) wd_fdc: Fix ready handling, allow ready connected to vcc [O. Galibert]

(mess) wd_fdc: Data overrun drops drq [O. Galibert]
(mess) kaypro: Fix motor on line, connect ready to vcc, disable the floppy delay [O. Galibert]
This commit is contained in:
Olivier Galibert 2013-09-05 13:21:51 +00:00
parent 217a0fbbd1
commit d2e5a7db13
4 changed files with 39 additions and 15 deletions

View File

@ -61,6 +61,12 @@ const device_type WD1773x = &device_creator<wd1773_t>;
wd_fdc_t::wd_fdc_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
device_t(mconfig, type, name, tag, owner, clock, shortname, source)
{
force_ready = false;
}
void wd_fdc_t::set_force_ready(bool _force_ready)
{
force_ready = _force_ready;
}
void wd_fdc_t::device_start()
@ -121,8 +127,7 @@ void wd_fdc_t::set_floppy(floppy_image_device *_floppy)
int prev_ready = floppy ? floppy->ready_r() : 1;
if(floppy) {
if(motor_control)
floppy->mon_w(1);
// Warning: deselecting a drive does *not* stop its motor if it was running
floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb());
floppy->setup_ready_cb(floppy_image_device::ready_cb());
}
@ -380,13 +385,15 @@ bool wd_fdc_t::sector_matches() const
bool wd_fdc_t::is_ready()
{
return !ready_hooked || (floppy && !floppy->ready_r());
return !ready_hooked || force_ready || (floppy && !floppy->ready_r());
}
void wd_fdc_t::read_sector_start()
{
if(!is_ready())
if(!is_ready()) {
command_end();
return;
}
main_state = READ_SECTOR;
status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY;
@ -474,8 +481,10 @@ void wd_fdc_t::read_sector_continue()
void wd_fdc_t::read_track_start()
{
if(!is_ready())
if(!is_ready()) {
command_end();
return;
}
main_state = READ_TRACK;
status = (status & ~(S_LOST|S_RNF)) | S_BUSY;
@ -541,8 +550,10 @@ void wd_fdc_t::read_track_continue()
void wd_fdc_t::read_id_start()
{
if(!is_ready())
if(!is_ready()) {
command_end();
return;
}
main_state = READ_ID;
status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY;
@ -606,8 +617,10 @@ void wd_fdc_t::read_id_continue()
void wd_fdc_t::write_track_start()
{
if(!is_ready())
if(!is_ready()) {
command_end();
return;
}
main_state = WRITE_TRACK;
status = (status & ~(S_WP|S_DDM|S_LOST|S_RNF)) | S_BUSY;
@ -702,8 +715,10 @@ void wd_fdc_t::write_track_continue()
void wd_fdc_t::write_sector_start()
{
if(!is_ready())
if(!is_ready()) {
command_end();
return;
}
main_state = WRITE_SECTOR;
status = (status & ~(S_CRC|S_LOST|S_RNF|S_WP|S_DDM)) | S_BUSY;
@ -1451,7 +1466,7 @@ void wd_fdc_t::live_run(attotime limit)
if(cur_live.bit_counter & 15)
break;
int slot = (cur_live.bit_counter >> 4)-1;
// fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).cstr(), slot, cur_live.data_reg, cur_live.crc);
// fprintf(stderr, "%s: slot[%d] = %02x crc = %04x\n", tts(cur_live.tm).cstr(), slot, cur_live.data_reg, cur_live.crc);
cur_live.idbuf[slot] = cur_live.data_reg;
if(slot == 5) {
live_delay(IDLE);
@ -1895,9 +1910,12 @@ void wd_fdc_t::live_run(attotime limit)
void wd_fdc_t::set_drq()
{
if(drq)
if(drq) {
status |= S_LOST;
else {
drq = false;
if(!drq_cb.isnull())
drq_cb(false);
} else if(!(status & S_LOST)) {
drq = true;
if(!drq_cb.isnull())
drq_cb(true);

View File

@ -108,6 +108,9 @@
#define MCFG_WD1773x_ADD(_tag, _clock) \
MCFG_DEVICE_ADD(_tag, WD1773x, _clock)
#define MCFG_WD_FDC_FORCE_READY \
downcast<wd_fdc_t *>(device)->set_force_ready(true);
class wd_fdc_t : public device_t {
public:
typedef delegate<void (bool state)> line_cb;
@ -120,6 +123,7 @@ public:
void setup_drq_cb(line_cb cb);
void setup_hld_cb(line_cb cb);
void setup_enp_cb(line_cb cb);
void set_force_ready(bool force_ready);
void cmd_w(UINT8 val);
UINT8 status_r();
@ -336,7 +340,7 @@ private:
emu_timer *t_gen, *t_cmd, *t_track, *t_sector;
bool dden, status_type_1, intrq, drq, hld, hlt, enp;
bool dden, status_type_1, intrq, drq, hld, hlt, enp, force_ready;
int main_state, sub_state;
UINT8 command, track, sector, data, status, intrq_cond;
int last_dir;

View File

@ -228,6 +228,7 @@ static MACHINE_CONFIG_START( kayproii, kaypro_state )
MCFG_Z80SIO_ADD( "z80sio", 4800, kaypro_sio_intf ) /* start at 300 baud */
MCFG_FD1793x_ADD("fdc", XTAL_20MHz / 20)
MCFG_WD_FDC_FORCE_READY
MCFG_FLOPPY_DRIVE_ADD("fdc:0", kaypro_floppies, "525dd", kaypro_state::kayproii_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fdc:1", kaypro_floppies, "525dd", kaypro_state::kayproii_floppy_formats)
MCFG_SOFTWARE_LIST_ADD("flop_list","kayproii")
@ -273,6 +274,7 @@ static MACHINE_CONFIG_START( kaypro2x, kaypro_state )
MCFG_Z80SIO_ADD( "z80sio", 4800, kaypro_sio_intf )
MCFG_Z80SIO_ADD( "z80sio_2x", 4800, kaypro_sio_intf ) /* extra sio for modem and printer */
MCFG_FD1793x_ADD("fdc", XTAL_16MHz / 16)
MCFG_WD_FDC_FORCE_READY
MCFG_FLOPPY_DRIVE_ADD("fdc:0", kaypro_floppies, "525dd", kaypro_state::kaypro2x_floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fdc:1", kaypro_floppies, "525dd", kaypro_state::kaypro2x_floppy_formats)
MACHINE_CONFIG_END

View File

@ -72,7 +72,7 @@ WRITE8_MEMBER( kaypro_state::common_pio_system_w )
if (m_floppy)
{
m_floppy->mon_w(BIT(data, 6) ? 0 : 1); // motor on
m_floppy->mon_w(BIT(data, 6)); // motor on
}
output_set_value("ledA", BIT(data, 0)); /* LEDs in artwork */
@ -300,7 +300,7 @@ void kaypro_state::fdc_intrq_w (bool state)
//WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_intrq_w )
{
if (state)
timer_set(attotime::from_usec(25), TIMER_FLOPPY);
timer_set(attotime::zero, TIMER_FLOPPY);
else
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}
@ -309,7 +309,7 @@ void kaypro_state::fdc_drq_w (bool state)
//WRITE_LINE_MEMBER( kaypro_state::kaypro_fdc_drq_w )
{
if (state)
timer_set(attotime::from_usec(25), TIMER_FLOPPY);
timer_set(attotime::zero, TIMER_FLOPPY);
else
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);