@@ -248,7 +248,18 @@ void i8256_device::device_reset()
248248
249249	m_status = 0x30 ; //  TRE and TBE
250250
251- 	m_timer->adjust (attotime::from_hz (16000 ), 0 , attotime::from_hz (16000 )); // default is 16kHz from the datasheet, is later changed to a calculated one
251+ 	reset_timer ();
252+ }
253+ 
254+ void  i8256_device::reset_timer ()
255+ {
256+ 	int  divider = 64 ; // default is 16kHz from the datasheet, it may later be changed to a slower one
257+ 	if  (BIT (m_command1, I8256_CMD1_FRQ))
258+ 	{
259+ 		divider = 1024 ;
260+ 	}
261+ 	const  attotime time = attotime::from_hz ((clock () / sysclock_divider[(m_command2 & 0x30  >> 4 )]) / divider);
262+ 	m_timer->adjust (time, 0 , time);
252263}
253264
254265TIMER_CALLBACK_MEMBER (i8256_device::timer_check)
@@ -258,9 +269,9 @@ TIMER_CALLBACK_MEMBER(i8256_device::timer_check)
258269		if  (m_timers[i] > 0 )
259270		{
260271			m_timers[i]--;
261- 			if  (m_timers[i] == 0  && BIT (m_interrupts,TIMER_INTERRUPTS [i])) //  If the interrupt is enabled
272+ 			if  (m_timers[i] == 0  && BIT (m_interrupts,timer_interrupts [i])) //  If the interrupt is enabled
262273			{
263- 				m_current_interrupt_level = TIMER_INTERRUPTS [i];
274+ 				m_current_interrupt_level = timer_interrupts [i];
264275				m_out_int_cb (1 ); //  it occurs when the counter changes from 1 to 0.
265276			}
266277		}
@@ -335,14 +346,7 @@ void i8256_device::write(offs_t offset, u8 data)
335346			{
336347				m_command1 = data;
337348
338- 				if  (BIT (m_command1,I8256_CMD1_FRQ))
339- 				{
340- 					m_timer->adjust (attotime::from_hz ((clock () / SYSCLOCK_DIVIDER[(m_command2 & 0x30  >> 4 )]) / 1024 ), 0 , attotime::from_hz ((clock () / SYSCLOCK_DIVIDER[(m_command2 & 0x30  >> 4 )]) / 1024 ));
341- 				}
342- 				else 
343- 				{
344- 					m_timer->adjust (attotime::from_hz ((clock () / SYSCLOCK_DIVIDER[(m_command2 & 0x30  >> 4 )]) / 64 ), 0 , attotime::from_hz ((clock () / SYSCLOCK_DIVIDER[(m_command2 & 0x30  >> 4 )]) / 64 ));
345- 				}
349+ 				reset_timer ();
346350
347351				if  (BIT (m_command1,I8256_CMD1_8086))
348352					LOG (" I8256 Enabled 8086 mode\n " 
@@ -358,7 +362,7 @@ void i8256_device::write(offs_t offset, u8 data)
358362			{
359363				m_command2 = data;
360364
361- 				set_rate (BAUD_RATES [m_command2 & 0x0f ]);
365+ 				set_rate (baud_rates [m_command2 & 0x0f ]);
362366
363367				if  (BIT (m_command2,I8256_CMD2_PARITY_ENABLE))
364368					m_parity = BIT (m_command2,I8256_CMD2_EVEN_PARITY) ? PARITY_EVEN : PARITY_ODD;
@@ -474,8 +478,8 @@ void i8256_device::receive_clock()
474478	//  receive enable?
475479	if  (BIT (m_command3, I8256_CMD3_RxE))
476480	{
477- 		const  bool  SYNC  = is_receive_register_synchronized ();
478- 		if  (SYNC )
481+ 		const  bool  sync  = is_receive_register_synchronized ();
482+ 		if  (sync )
479483		{
480484			--m_rxc_count;
481485			if  (m_rxc_count)
@@ -487,7 +491,7 @@ void i8256_device::receive_clock()
487491		// LOGBITS("8256: Rx Sampled %d\n", m_rxd);
488492		receive_register_update_bit (m_rxd);
489493		if  (is_receive_register_synchronized ())
490- 			m_rxc_count = SYNC  ? m_br_factor : (3  * m_br_factor / 2 );
494+ 			m_rxc_count = sync  ? m_br_factor : (3  * m_br_factor / 2 );
491495
492496		if  (is_receive_register_full ())
493497		{
0 commit comments