void psxrcnt_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { int n_counter = id; psx_root *root = &root_counter[ n_counter ]; verboselog( machine(), 2, "root_finished( %d ) %04x\n", n_counter, root_current( n_counter ) ); //if( ( root->n_mode & PSX_RC_COUNTTARGET ) != 0 ) { /* TODO: wrap should be handled differently as PSX_RC_COUNTTARGET & PSX_RC_IRQTARGET don't have to be the same. */ root->n_count = 0; root->n_start = gettotalcycles(); } if( ( root->n_mode & PSX_RC_REPEAT ) != 0 ) { root_timer_adjust( n_counter ); } if( ( root->n_mode & PSX_RC_IRQOVERFLOW ) != 0 || ( root->n_mode & PSX_RC_IRQTARGET ) != 0 ) { switch( n_counter ) { case 0: m_irq0_handler(1); break; case 1: m_irq1_handler(1); break; case 2: m_irq2_handler(1); break; } } }
UINT16 psxrcnt_device::root_current( int n_counter ) { psx_root *root = &root_counter[ n_counter ]; if( ( root->n_mode & PSX_RC_STOP ) != 0 ) { return root->n_count; } else { UINT64 n_current; n_current = gettotalcycles() - root->n_start; n_current /= root_divider( n_counter ); n_current += root->n_count; if( n_current > 0xffff ) { /* TODO: use timer for wrap on 0x10000. */ root->n_count = n_current; root->n_start = gettotalcycles(); } return n_current; } }
void psxrcnt_device::root_finished( void *ptr, int param ) { int n_counter = param; psx_root *root = &root_counter[ n_counter ]; verboselog( machine(), 2, "root_finished( %d ) %04x\n", n_counter, root_current( n_counter ) ); //if( ( root->n_mode & PSX_RC_COUNTTARGET ) != 0 ) { /* TODO: wrap should be handled differently as PSX_RC_COUNTTARGET & PSX_RC_IRQTARGET don't have to be the same. */ root->n_count = 0; root->n_start = gettotalcycles(); } if( ( root->n_mode & PSX_RC_REPEAT ) != 0 ) { root_timer_adjust( n_counter ); } if( ( root->n_mode & PSX_RC_IRQOVERFLOW ) != 0 || ( root->n_mode & PSX_RC_IRQTARGET ) != 0 ) { psx_irq_set( machine(), PSX_IRQ_ROOTCOUNTER0 << n_counter ); } }