m6809,6522via,6840ptm: zerofill more variables at device start,

6840ptm: clear output ports at reset
This commit is contained in:
hap 2023-07-22 22:28:11 +02:00
parent b055029659
commit 1d840de9bd
10 changed files with 124 additions and 57 deletions

View File

@ -168,13 +168,11 @@ void hd6309_device::device_start()
state_add(HD6309_U, "U", m_u.w).mask(0xffff);
// initialize variables
m_q.q = 0x00000000;
m_v.w = 0xffff; // v is initialized to $ffff at reset
m_md = 0x00;
m_temp_im = 0x00;
// setup regtable
save_item(NAME(m_q.r.w));
save_item(NAME(m_v.w));
save_item(NAME(m_md));
save_item(NAME(m_temp_im));

View File

@ -186,15 +186,28 @@ void m6809_base_device::device_start()
// initialize variables
m_cc = 0;
m_pc.w = 0;
m_ppc.w = 0;
m_s.w = 0;
m_u.w = 0;
m_q.q = 0;
m_x.w = 0;
m_y.w = 0;
m_dp = 0;
m_reg = 0;
m_temp.w = 0;
m_opcode = 0;
m_reg8 = nullptr;
m_reg16 = nullptr;
m_reg = 0;
m_nmi_line = false;
m_nmi_asserted = false;
m_firq_line = false;
m_irq_line = false;
m_lds_encountered = false;
m_state = 0;
m_cond = false;
m_free_run = false;
// setup regtable
save_item(NAME(m_pc.w));
@ -208,6 +221,7 @@ void m6809_base_device::device_start()
save_item(NAME(m_cc));
save_item(NAME(m_temp.w));
save_item(NAME(m_opcode));
save_item(NAME(m_nmi_asserted));
save_item(NAME(m_nmi_line));
save_item(NAME(m_firq_line));

View File

@ -86,7 +86,7 @@ protected:
ADDRESSING_MODE_EA = 1,
ADDRESSING_MODE_REGISTER_A = 2,
ADDRESSING_MODE_REGISTER_B = 3,
ADDRESSING_MODE_REGISTER_D = 4
ADDRESSING_MODE_REGISTER_D = 4
};
// flag bits in the cc register
@ -277,7 +277,7 @@ private:
const address_space_config m_sprogram_config;
// other state
uint32_t m_state;
uint32_t m_state;
bool m_cond;
bool m_free_run;

View File

@ -182,14 +182,11 @@ via6522_device::via6522_device(const machine_config &mconfig, device_type type,
m_in_a(0xff),
m_in_ca1(0),
m_in_ca2(0),
m_out_ca2(0),
m_in_b(0xff),
m_in_cb1(0),
m_in_cb2(0),
m_pcr(0),
m_acr(0),
m_ier(0),
m_ifr(0)
m_acr(0)
{
}
@ -198,8 +195,8 @@ via6522_device::via6522_device(const machine_config &mconfig, device_type type,
// mos6522_device - constructor
//-------------------------------------------------
mos6522_device::mos6522_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: via6522_device(mconfig, MOS6522, tag, owner, clock)
mos6522_device::mos6522_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
via6522_device(mconfig, MOS6522, tag, owner, clock)
{
}
@ -208,8 +205,8 @@ mos6522_device::mos6522_device(const machine_config &mconfig, const char *tag, d
// r65c22_device - constructor
//-------------------------------------------------
r65c22_device::r65c22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: via6522_device(mconfig, R65C22, tag, owner, clock)
r65c22_device::r65c22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
via6522_device(mconfig, R65C22, tag, owner, clock)
{
}
@ -218,8 +215,8 @@ r65c22_device::r65c22_device(const machine_config &mconfig, const char *tag, dev
// r65c22_device - constructor
//-------------------------------------------------
r65nc22_device::r65nc22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: via6522_device(mconfig, R65NC22, tag, owner, clock)
r65nc22_device::r65nc22_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
via6522_device(mconfig, R65NC22, tag, owner, clock)
{
}
@ -228,8 +225,8 @@ r65nc22_device::r65nc22_device(const machine_config &mconfig, const char *tag, d
// w65c22s_device - constructor
//-------------------------------------------------
w65c22s_device::w65c22s_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: via6522_device(mconfig, W65C22S, tag, owner, clock)
w65c22s_device::w65c22s_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
via6522_device(mconfig, W65C22S, tag, owner, clock)
{
}
@ -244,9 +241,10 @@ void via6522_device::device_start()
m_t1lh = 0xb5; /* ports are not written by kernel! */
m_t2ll = 0xff; /* taken from vice */
m_t2lh = 0xff;
m_sr = 0;
m_time2 = m_time1 = machine().time();
m_time1 = machine().time();
m_time2 = machine().time();
m_t1 = timer_alloc(FUNC(via6522_device::t1_tick), this);
m_t2 = timer_alloc(FUNC(via6522_device::t2_tick), this);
m_ca2_timer = timer_alloc(FUNC(via6522_device::ca2_tick), this);
@ -254,7 +252,34 @@ void via6522_device::device_start()
m_shift_timer = timer_alloc(FUNC(via6522_device::shift_tick), this);
m_shift_irq_timer = timer_alloc(FUNC(via6522_device::shift_irq_tick), this);
/* save state register */
// zerofill other
m_out_a = 0;
m_out_ca2 = 0;
m_ddr_a = 0;
m_latch_a = 0;
m_out_b = 0;
m_out_cb1 = 0;
m_out_cb2 = 0;
m_ddr_b = 0;
m_latch_b = 0;
m_t1cl = 0;
m_t1ch = 0;
m_t2cl = 0;
m_t2ch = 0;
m_sr = 0;
m_pcr = 0;
m_acr = 0;
m_ier = 0;
m_ifr = 0;
m_t1_active = 0;
m_t1_pb7 = 0;
m_t2_active = 0;
m_shift_counter = 0;
// save state register
save_item(NAME(m_in_a));
save_item(NAME(m_in_ca1));
save_item(NAME(m_in_ca2));
@ -262,6 +287,7 @@ void via6522_device::device_start()
save_item(NAME(m_out_ca2));
save_item(NAME(m_ddr_a));
save_item(NAME(m_latch_a));
save_item(NAME(m_in_b));
save_item(NAME(m_in_cb1));
save_item(NAME(m_in_cb2));
@ -270,6 +296,7 @@ void via6522_device::device_start()
save_item(NAME(m_out_cb2));
save_item(NAME(m_ddr_b));
save_item(NAME(m_latch_b));
save_item(NAME(m_t1cl));
save_item(NAME(m_t1ch));
save_item(NAME(m_t1ll));
@ -278,11 +305,13 @@ void via6522_device::device_start()
save_item(NAME(m_t2ch));
save_item(NAME(m_t2ll));
save_item(NAME(m_t2lh));
save_item(NAME(m_sr));
save_item(NAME(m_pcr));
save_item(NAME(m_acr));
save_item(NAME(m_ier));
save_item(NAME(m_ifr));
save_item(NAME(m_time1));
save_item(NAME(m_t1_active));
save_item(NAME(m_t1_pb7));
@ -444,7 +473,7 @@ void via6522_device::shift_out()
void via6522_device::shift_in()
{
// Only shift in data on raising edge
if ( !(m_shift_counter & 1) )
if (!(m_shift_counter & 1))
{
LOGSHIFT("%s shift In SR: %02x->", tag(), m_sr);
m_sr = (m_sr << 1) | (m_in_cb2 & 1);
@ -863,7 +892,7 @@ void via6522_device::write(offs_t offset, u8 data)
break;
case VIA_DDRB:
if ( data != m_ddr_b )
if (data != m_ddr_b)
{
m_ddr_b = data;
@ -1052,7 +1081,7 @@ void via6522_device::set_pa_line(int line, int state)
m_in_a &= ~(1 << line);
}
void via6522_device::write_pa( u8 data )
void via6522_device::write_pa(u8 data)
{
m_in_a = data;
}
@ -1123,7 +1152,7 @@ void via6522_device::set_pb_line(int line, int state)
}
}
void via6522_device::write_pb( u8 data )
void via6522_device::write_pb(u8 data)
{
if (!BIT(data, 6) && BIT(m_in_b, 6))
counter2_decrement();

View File

@ -97,7 +97,7 @@ public:
void write_pa5(int state) { set_pa_line(5, state); }
void write_pa6(int state) { set_pa_line(6, state); }
void write_pa7(int state) { set_pa_line(7, state); }
void write_pa( u8 data );
void write_pa(u8 data);
void write_ca1(int state);
void write_ca2(int state);
@ -109,7 +109,7 @@ public:
void write_pb5(int state) { set_pb_line(5, state); }
void write_pb6(int state) { set_pb_line(6, state); }
void write_pb7(int state) { set_pb_line(7, state); }
void write_pb( u8 data );
void write_pb(u8 data);
void write_cb1(int state);
void write_cb2(int state);

View File

@ -7,7 +7,7 @@
Programmable Timer Module
Written By J.Wallace based on previous work by Aaron Giles,
'Re-Animator' and Mathis Rosenhauer.
'Re-Animator' and Mathis Rosenhauer.
Todo:
Confirm handling for 'Single Shot' operation.
@ -99,6 +99,27 @@ void ptm6840_device::device_start()
elem->enable(false);
}
// zerofill
m_t3_divisor = 1;
m_t3_scaler = 0;
m_irq = 0;
m_status_reg = 0;
m_status_read_since_int = 0;
m_lsb_buffer = 0;
m_msb_buffer = 0;
for (int i = 0; i < 3; i++)
{
m_control_reg[i] = 0;
m_counter[i] = 0;
m_latch[i] = 0;
m_output[i] = false;
m_clk[i] = false;
m_single_fired[i] = false;
m_enabled[i] = false;
m_mode[i] = 0;
}
// register for state saving
save_item(NAME(m_lsb_buffer));
save_item(NAME(m_msb_buffer));
@ -128,26 +149,32 @@ void ptm6840_device::device_start()
void ptm6840_device::device_reset()
{
m_control_reg[2] = 0;
m_control_reg[1] = 0;
m_control_reg[0] = 1;
m_status_reg = 0;
m_t3_divisor = 1;
m_t3_divisor = 1;
m_t3_scaler = 0;
m_status_reg = 0;
m_status_read_since_int = 0;
m_irq = 0;
m_t3_scaler = 0;
for (int i = 0; i < 3; i++)
{
m_counter[i] = 0xffff;
m_latch[i] = 0xffff;
m_control_reg[i] = 0;
m_counter[i] = 0xffff;
m_latch[i] = 0xffff;
m_disable_time[i] = attotime::never;
m_output[i] = false;
m_clk[i] = false;
m_output[i] = false;
m_clk[i] = false;
m_single_fired[i] = false;
m_enabled[i] = false;
m_mode[i] = 0;
m_enabled[i] = false;
m_mode[i] = 0;
}
m_control_reg[0] = 1;
// clear outputs
m_irq = 0;
m_irq_cb(CLEAR_LINE);
for (int i = 0; i < 3; i++)
m_out_cb[i](0);
}
void ptm6840_device::device_resolve_objects()

View File

@ -20,7 +20,7 @@
// ======================> ptm6840_device
class ptm6840_device : public device_t
class ptm6840_device : public device_t
{
public:
// construction/destruction

View File

@ -33,18 +33,18 @@ DEFINE_DEVICE_TYPE(TIMER, timer_device, "timer", "Timer")
// timer_device - constructor
//-------------------------------------------------
timer_device::timer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, TIMER, tag, owner, clock),
m_type(TIMER_TYPE_GENERIC),
m_callback(*this),
m_start_delay(attotime::zero),
m_period(attotime::zero),
m_param(0),
m_screen(*this, finder_base::DUMMY_TAG),
m_first_vpos(0),
m_increment(0),
m_timer(nullptr),
m_first_time(true)
timer_device::timer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
device_t(mconfig, TIMER, tag, owner, clock),
m_type(TIMER_TYPE_GENERIC),
m_callback(*this),
m_start_delay(attotime::zero),
m_period(attotime::zero),
m_param(0),
m_screen(*this, finder_base::DUMMY_TAG),
m_first_vpos(0),
m_increment(0),
m_timer(nullptr),
m_first_time(true)
{
}

View File

@ -64,8 +64,8 @@ private:
sound_stream *m_stream;
uint8_t m_chord; // 4-bit
uint8_t m_step; // 3-bit
uint8_t m_chord; // 3-bit
uint8_t m_step; // 4-bit
bool m_sb;
};

View File

@ -1711,7 +1711,6 @@ void tms5220_device::device_reset()
m_next_is_address = false;
m_addr_bit = 0;
m_CTL_buffer = 0;
}
TIMER_CALLBACK_MEMBER(tms5220_device::set_io_ready)
@ -1828,7 +1827,7 @@ void tms5220_device::wsq_w(int state)
LOGMASKED(LOG_RS_WS, "tms5220_wsq_w: illegal\n");
return;
}
else if ( new_val == 3)
else if (new_val == 3)
{
/* high impedance */
m_read_latch = 0xff;