(mess) upd765: Implement LOCK [O. Galibert]

This commit is contained in:
Olivier Galibert 2012-10-11 21:51:32 +00:00
parent f5a8f929ff
commit 380e2da737
2 changed files with 25 additions and 9 deletions

View File

@ -132,9 +132,16 @@ void upd765_family_device::device_start()
poll_timer = NULL; poll_timer = NULL;
cur_irq = false; cur_irq = false;
locked = false;
} }
void upd765_family_device::device_reset() void upd765_family_device::device_reset()
{
dor = dor_reset;
locked = false;
}
void upd765_family_device::soft_reset()
{ {
main_phase = PHASE_CMD; main_phase = PHASE_CMD;
for(int i=0; i<4; i++) { for(int i=0; i<4; i++) {
@ -150,7 +157,8 @@ void upd765_family_device::device_reset()
fifo_pos = 0; fifo_pos = 0;
command_pos = 0; command_pos = 0;
result_pos = 0; result_pos = 0;
fifocfg = FIF_DIS; if(!locked)
fifocfg = FIF_DIS;
cur_live.fi = 0; cur_live.fi = 0;
drq = false; drq = false;
cur_live.tm = attotime::never; cur_live.tm = attotime::never;
@ -159,7 +167,6 @@ void upd765_family_device::device_reset()
cur_live.fi = NULL; cur_live.fi = NULL;
tc_done = false; tc_done = false;
st0 = st1 = st2 = st3 = 0x00; st0 = st1 = st2 = st3 = 0x00;
dor = dor_reset;
check_irq(); check_irq();
if(ready_polled) if(ready_polled)
@ -240,12 +247,8 @@ WRITE8_MEMBER(upd765_family_device::dor_w)
logerror("%s: dor = %02x\n", tag(), data); logerror("%s: dor = %02x\n", tag(), data);
UINT8 diff = dor ^ data; UINT8 diff = dor ^ data;
dor = data; dor = data;
if(diff & 4) { if(diff & 4)
UINT8 tmp = dor_reset; soft_reset();
dor_reset = dor;
device_reset();
dor_reset = tmp;
}
for(int i=0; i<4; i++) { for(int i=0; i<4; i++) {
floppy_info &fi = flopi[i]; floppy_info &fi = flopi[i];
@ -972,6 +975,9 @@ int upd765_family_device::check_command()
case 0x13: case 0x13:
return command_pos == 4 ? C_CONFIGURE : C_INCOMPLETE; return command_pos == 4 ? C_CONFIGURE : C_INCOMPLETE;
case 0x14:
return C_LOCK;
default: default:
return C_INVALID; return C_INVALID;
} }
@ -997,6 +1003,14 @@ void upd765_family_device::start_command(int cmd)
format_track_start(flopi[command[1] & 3]); format_track_start(flopi[command[1] & 3]);
break; break;
case C_LOCK:
locked = command[0] & 0x80;
main_phase = PHASE_RESULT;
result[0] = locked ? 0x10 : 0x00;
result_pos = 1;
logerror("%s: command lock (%s)\n", tag(), locked ? "on" : "off");
break;
case C_PERPENDICULAR: case C_PERPENDICULAR:
logerror("%s: command perpendicular\n", tag()); logerror("%s: command perpendicular\n", tag());
main_phase = PHASE_CMD; main_phase = PHASE_CMD;

View File

@ -284,7 +284,7 @@ protected:
live_info cur_live, checkpoint_live; live_info cur_live, checkpoint_live;
line_cb intrq_cb, drq_cb; line_cb intrq_cb, drq_cb;
bool cur_irq, data_irq, drq, internal_drq, tc, tc_done; bool cur_irq, data_irq, drq, internal_drq, tc, tc_done, locked;
floppy_info flopi[4]; floppy_info flopi[4];
int fifo_pos, fifo_expected, command_pos, result_pos; int fifo_pos, fifo_expected, command_pos, result_pos;
@ -304,6 +304,7 @@ protected:
enum { enum {
C_CONFIGURE, C_CONFIGURE,
C_FORMAT_TRACK, C_FORMAT_TRACK,
C_LOCK,
C_PERPENDICULAR, C_PERPENDICULAR,
C_READ_DATA, C_READ_DATA,
C_READ_ID, C_READ_ID,
@ -321,6 +322,7 @@ protected:
void delay_cycles(emu_timer *tm, int cycles); void delay_cycles(emu_timer *tm, int cycles);
void check_irq(); void check_irq();
void soft_reset();
void fifo_expect(int size, bool write); void fifo_expect(int size, bool write);
void fifo_push(UINT8 data, bool internal); void fifo_push(UINT8 data, bool internal);
UINT8 fifo_pop(bool internal); UINT8 fifo_pop(bool internal);