From d7dc7f668b0cda9f1a9c0610a06f281bb4982238 Mon Sep 17 00:00:00 2001 From: Patrick Mackinlay Date: Wed, 4 Oct 2017 20:12:25 +0700 Subject: upd765: special case i82072 drive busy bit handling (nw) Fixes http://mametesters.org/view.php?id=6689. --- src/devices/machine/upd765.cpp | 37 +++++++++++++++++++++++++++++++++---- src/devices/machine/upd765.h | 3 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/devices/machine/upd765.cpp b/src/devices/machine/upd765.cpp index 1b3e0b9bafe..474f8fb7fc3 100644 --- a/src/devices/machine/upd765.cpp +++ b/src/devices/machine/upd765.cpp @@ -1421,11 +1421,10 @@ void upd765_family_device::command_end(floppy_info &fi, bool data_completion) for(int i=0; i != result_pos; i++) LOG(" %02x", result[i]); LOG("\n"); - fi.sub_state = IDLE; - if(data_completion) { - fi.main_state = IDLE; + fi.main_state = fi.sub_state = IDLE; + if(data_completion) data_irq = true; - } else { + else { other_irq = true; fi.st0_filled = true; } @@ -2602,6 +2601,36 @@ void i82072_device::execute_command(int cmd) } } +/* + * The Intel datasheet says that the drive busy bits in the MSR are supposed to remain + * set after a seek or recalibrate until a sense interrupt status status command is + * executed. The InterPro 2000 diagnostic routine goes further, and tests the drive + * status bits before and after the first sense interrupt status result byte is read, + * and expects the drive busy bit to clear only after. + * + * The Amstrad CPC6128 uses a upd765a and seems to expect the busy bits to be cleared + * immediately after the seek/recalibrate interrupt is generated. + * + * Special casing the i82072 here seems the only way to reconcile this apparently + * different behaviour for now. + */ +void i82072_device::command_end(floppy_info &fi, bool data_completion) +{ + LOG("command done (%s) -", data_completion ? "data" : "seek"); + for(int i=0; i != result_pos; i++) + LOG(" %02x", result[i]); + LOG("\n"); + fi.sub_state = IDLE; + if(data_completion) { + fi.main_state = IDLE; + data_irq = true; + } else { + other_irq = true; + fi.st0_filled = true; + } + check_irq(); +} + void i82072_device::motor_control(int fid, bool start_motor) { // check if motor control is enabled diff --git a/src/devices/machine/upd765.h b/src/devices/machine/upd765.h index 149f956c38b..a920d7dd875 100644 --- a/src/devices/machine/upd765.h +++ b/src/devices/machine/upd765.h @@ -386,7 +386,7 @@ protected: virtual int check_command(); virtual void start_command(int cmd); virtual void execute_command(int cmd); - void command_end(floppy_info &fi, bool data_completion); + virtual void command_end(floppy_info &fi, bool data_completion); void recalibrate_start(floppy_info &fi); void seek_start(floppy_info &fi); @@ -469,6 +469,7 @@ protected: virtual int check_command() override; virtual void start_command(int cmd) override; virtual void execute_command(int cmd) override; + virtual void command_end(floppy_info &fi, bool data_completion) override; virtual void index_callback(floppy_image_device *floppy, int state) override; void motor_control(int fid, bool start_motor); -- cgit v1.2.3