Skip to content

Commit

Permalink
machine/ncr53c90.cpp: Fix NCR53CF94 ID read sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrhacker committed Jan 7, 2025
1 parent 2a9cfda commit fd93123
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/devices/machine/ncr53c90.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,15 @@ void ncr53c90_device::command_pop_and_chain()
}
}

void ncr53c90_device::load_tcounter()
{
LOGMASKED(LOG_COMMAND, "DMA command: tcounter reloaded to %d\n", tcount & tcounter_mask);
tcounter = tcount & tcounter_mask;

// clear transfer count zero flag when counter is reloaded
status &= ~S_TC0;
}

void ncr53c90_device::start_command()
{
uint8_t c = command[0] & 0x7f;
Expand All @@ -932,11 +941,7 @@ void ncr53c90_device::start_command()
dma_command = command[0] & 0x80;
if (dma_command)
{
LOGMASKED(LOG_COMMAND, "DMA command: tcounter reloaded to %d\n", tcount);
tcounter = tcount;

// clear transfer count zero flag when counter is reloaded
status &= ~S_TC0;
load_tcounter();
}
else
{
Expand Down Expand Up @@ -1417,6 +1422,15 @@ void ncr53cf94_device::device_reset()
ncr53c94_device::device_reset();
}

void ncr53cf94_device::load_tcounter()
{
ncr53c94_device::load_tcounter();

// ID may be read by executing DMA NOP command twice, first with the features bit clear and then with it set
if ((config2 & S2FE) == 0)
tcount = (1 << 23) | (family_id << 19) | (revision_level << 16) | (tcount & 0xffff);
}

void ncr53cf94_device::conf2_w(uint8_t data)
{
tcounter_mask = (data & S2FE) ? 0xffffff : 0xffff;
Expand All @@ -1425,10 +1439,6 @@ void ncr53cf94_device::conf2_w(uint8_t data)

uint8_t ncr53cf94_device::tcounter_hi2_r()
{
// tcounter is 24-bit when the features bit is set, otherwise it returns the ID
if ((config2 & S2FE) == 0)
return (1 << 7) | (family_id << 3) | revision_level;

LOG("tcounter_hi2_r %02x (%s)\n", (tcounter >> 16) & 0xff, machine().describe_context());
return tcounter >> 16;
}
Expand Down
3 changes: 3 additions & 0 deletions src/devices/machine/ncr53c90.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class ncr53c90_device : public nscsi_device, public nscsi_slot_card_interface
void delay_cycles(int cycles);

void decrement_tcounter(int count = 1);
virtual void load_tcounter();

devcb_write_line m_irq_handler;
devcb_write_line m_drq_handler;
Expand Down Expand Up @@ -361,6 +362,8 @@ class ncr53cf94_device : public ncr53c94_device
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;

virtual void load_tcounter() override;

private:
u8 config4;
u8 family_id;
Expand Down

0 comments on commit fd93123

Please sign in to comment.