fixed variable and parameter conflict (nw)

This commit is contained in:
smf- 2013-05-12 00:12:47 +00:00
parent 5807dc2c5a
commit 3b7335ea02
2 changed files with 74 additions and 74 deletions

View File

@ -40,31 +40,31 @@ void ds2401_device::device_start()
t_pdh = attotime::from_usec( 30); t_pdh = attotime::from_usec( 30);
t_pdl = attotime::from_usec(120); t_pdl = attotime::from_usec(120);
save_item(NAME(state)); save_item(NAME(m_state));
save_item(NAME(bit)); save_item(NAME(m_bit));
save_item(NAME(byte)); save_item(NAME(m_byte));
save_item(NAME(shift)); save_item(NAME(m_shift));
save_item(NAME(rx)); save_item(NAME(m_rx));
save_item(NAME(tx)); save_item(NAME(m_tx));
timer_main = timer_alloc(TIMER_MAIN); m_timer_main = timer_alloc(TIMER_MAIN);
timer_reset = timer_alloc(TIMER_RESET); m_timer_reset = timer_alloc(TIMER_RESET);
} }
void ds2401_device::device_reset() void ds2401_device::device_reset()
{ {
state = STATE_IDLE; m_state = STATE_IDLE;
bit = 0; m_bit = 0;
byte = 0; m_byte = 0;
shift = 0; m_shift = 0;
rx = true; m_rx = true;
tx = true; m_tx = true;
if(m_region) if(m_region)
{ {
if(m_region->bytes() == SIZE_DATA) if(m_region->bytes() == SIZE_DATA)
{ {
memcpy(data, m_region->base(), SIZE_DATA); memcpy(m_data, m_region->base(), SIZE_DATA);
return; return;
} }
@ -75,7 +75,7 @@ void ds2401_device::device_reset()
logerror("ds2401 %s: Warning, no id provided, answer will be all zeroes.\n", tag()); logerror("ds2401 %s: Warning, no id provided, answer will be all zeroes.\n", tag());
} }
memset(data, 0, SIZE_DATA); memset(m_data, 0, SIZE_DATA);
} }
void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
@ -84,64 +84,64 @@ void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param
{ {
case TIMER_RESET: case TIMER_RESET:
verboselog(1, "timer_reset\n"); verboselog(1, "timer_reset\n");
state = STATE_RESET; m_state = STATE_RESET;
timer_reset->adjust(attotime::never); m_timer_reset->adjust(attotime::never);
break; break;
case TIMER_MAIN: case TIMER_MAIN:
switch(state) switch(m_state)
{ {
case STATE_RESET1: case STATE_RESET1:
verboselog(2, "timer_main state_reset1 %d\n", rx); verboselog(2, "timer_main state_reset1 %d\n", m_rx);
tx = false; m_tx = false;
state = STATE_RESET2; m_state = STATE_RESET2;
timer_main->adjust(t_pdl); m_timer_main->adjust(t_pdl);
break; break;
case STATE_RESET2: case STATE_RESET2:
verboselog(2, "timer_main state_reset2 %d\n", rx); verboselog(2, "timer_main state_reset2 %d\n", m_rx);
tx = true; m_tx = true;
bit = 0; m_bit = 0;
shift = 0; m_shift = 0;
state = STATE_COMMAND; m_state = STATE_COMMAND;
break; break;
case STATE_COMMAND: case STATE_COMMAND:
verboselog(2, "timer_main state_command %d\n", rx); verboselog(2, "timer_main state_command %d\n", m_rx);
shift >>= 1; m_shift >>= 1;
if(rx) if(m_rx)
{ {
shift |= 0x80; m_shift |= 0x80;
} }
bit++; m_bit++;
if(bit == 8) if(m_bit == 8)
{ {
switch(shift) switch(m_shift)
{ {
case COMMAND_READROM: case COMMAND_READROM:
verboselog(1, "timer_main readrom\n"); verboselog(1, "timer_main readrom\n");
bit = 0; m_bit = 0;
byte = 0; m_byte = 0;
state = STATE_READROM; m_state = STATE_READROM;
break; break;
default: default:
verboselog(0, "timer_main command not handled %02x\n", shift); verboselog(0, "timer_main command not handled %02x\n", m_shift);
state = STATE_IDLE; m_state = STATE_IDLE;
break; break;
} }
} }
break; break;
case STATE_READROM: case STATE_READROM:
tx = true; m_tx = true;
if(byte == SIZE_DATA) if( m_byte == SIZE_DATA )
{ {
verboselog(1, "timer_main readrom finished\n"); verboselog(1, "timer_main readrom finished\n");
state = STATE_IDLE; m_state = STATE_IDLE;
} }
else else
{ {
@ -149,7 +149,7 @@ void ds2401_device::device_timer(emu_timer &timer, device_timer_id id, int param
} }
break; break;
default: default:
verboselog(0, "timer_main state not handled: %d\n", state); verboselog(0, "timer_main state not handled: %d\n", m_state);
break; break;
} }
} }
@ -159,71 +159,71 @@ WRITE_LINE_MEMBER( ds2401_device::write )
{ {
verboselog(1, "write(%d)\n", state); verboselog(1, "write(%d)\n", state);
if(!state && rx) if(!state && m_rx)
{ {
switch(state) switch(m_state)
{ {
case STATE_IDLE: case STATE_IDLE:
break; break;
case STATE_COMMAND: case STATE_COMMAND:
verboselog(2, "state_command\n"); verboselog(2, "state_command\n");
timer_main->adjust(t_samp); m_timer_main->adjust(t_samp);
break; break;
case STATE_READROM: case STATE_READROM:
if(!bit) if(!m_bit)
{ {
shift = data[7 - byte]; m_shift = m_data[7 - m_byte];
verboselog(1, "<- data %02x\n", shift); verboselog(1, "<- data %02x\n", m_shift);
} }
tx = shift & 1; m_tx = m_shift & 1;
shift >>= 1; m_shift >>= 1;
bit++; m_bit++;
if(bit == 8) if(m_bit == 8)
{ {
bit = 0; m_bit = 0;
byte++; m_byte++;
} }
verboselog(2, "state_readrom %d\n", tx); verboselog(2, "state_readrom %d\n", m_tx);
timer_main->adjust(t_rdv); m_timer_main->adjust(t_rdv);
break; break;
default: default:
verboselog(0, "state not handled: %d\n", state ); verboselog(0, "state not handled: %d\n", m_state );
break; break;
} }
timer_reset->adjust(t_rstl); m_timer_reset->adjust(t_rstl);
} }
else if(state && !rx) else if(state && !m_rx)
{ {
switch(state) switch(m_state)
{ {
case STATE_RESET: case STATE_RESET:
state = STATE_RESET1; m_state = STATE_RESET1;
timer_main->adjust(t_pdh); m_timer_main->adjust(t_pdh);
break; break;
} }
timer_reset->adjust(attotime::never); m_timer_reset->adjust(attotime::never);
} }
rx = state; m_rx = state;
} }
READ_LINE_MEMBER( ds2401_device::read ) READ_LINE_MEMBER( ds2401_device::read )
{ {
verboselog(2, "read %d\n", tx && rx); verboselog(2, "read %d\n", m_tx && m_rx);
return tx && rx; return m_tx && m_rx;
} }
UINT8 ds2401_device::direct_read(int index) UINT8 ds2401_device::direct_read(int index)
{ {
return data[index]; return m_data[index];
} }
/* /*

View File

@ -51,11 +51,11 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
// internal state // internal state
int state, bit, shift; int m_state, m_bit, m_shift;
UINT8 byte; UINT8 m_byte;
bool rx, tx; bool m_rx, m_tx;
UINT8 data[SIZE_DATA]; UINT8 m_data[SIZE_DATA];
emu_timer *timer_main, *timer_reset; emu_timer *m_timer_main, *m_timer_reset;
attotime t_samp, t_rdv, t_rstl, t_pdh, t_pdl; attotime t_samp, t_rdv, t_rstl, t_pdh, t_pdl;
private: private: