Exemplo n.º 1
0
void pc9801_kbd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
    if(id == RX_TIMER)
    {
        int i;

        /* key up */
        for(i=0; i<0x80; i++)
        {
            if(m_rx_buf[i] == 2)
            {
                m_keyb_tx = i | 0x80;
                m_write_irq(ASSERT_LINE);
                m_key_avail = true;
                m_rx_buf[i] = 0;
                return;
            }
        }

        /* key down */
        for(i=0x7f; i>=0; i--)
        {
            if(m_rx_buf[i] == 1)
            {
                m_keyb_tx = i;
                m_write_irq(ASSERT_LINE);
                m_key_avail = true;
                m_rx_buf[i] = 0;
                return;
            }
        }
    }
}
Exemplo n.º 2
0
void mc146818_device::update_irq()
{
	// IRQ line is active low
	if (((m_data[REG_C] & REG_C_UF) && (m_data[REG_B] & REG_B_UIE)) ||
		((m_data[REG_C] & REG_C_AF) && (m_data[REG_B] & REG_B_AIE)) ||
		((m_data[REG_C] & REG_C_PF) && (m_data[REG_B] & REG_B_PIE)))
	{
		m_data[REG_C] |= REG_C_IRQF;
		m_write_irq(CLEAR_LINE);
	}
	else
	{
		m_data[REG_C] &= REG_C_IRQF;
		m_write_irq(ASSERT_LINE);
	}
}
Exemplo n.º 3
0
inline void i8214_device::trigger_interrupt(int level)
{
	if (LOG) logerror("I8214 '%s' Interrupt Level %u\n", tag().c_str(), level);

	m_a = level;

	// disable interrupts
	m_int_dis = 1;

	// disable next level group
	m_write_enlg(0);

	// toggle interrupt line
	m_write_irq(ASSERT_LINE);
	m_write_irq(CLEAR_LINE);
}
Exemplo n.º 4
0
void i8214_device::trigger_interrupt(int level)
{
	if (LOG) logerror("I8214 '%s' Interrupt Level %u\n", tag(), level);

	m_a = level;

	// disable more interrupts from being latched
	m_int_dis = 1;

	// disable next level group
	m_write_enlg(0);

	// set interrupt line
	m_write_irq(ASSERT_LINE);
	m_write_irq(CLEAR_LINE);
}
Exemplo n.º 5
0
void i8275x_device::device_reset()
{
	memset(m_buffer, 0, sizeof(m_buffer));

	m_status &= ~ST_IE;

	m_write_irq(CLEAR_LINE);
}
Exemplo n.º 6
0
void dave_device::device_reset()
{
	m_write_irq(CLEAR_LINE);

	for (auto & elem : m_segment)
		elem = 0;

	m_irq_status = 0;
	m_irq_enable = 0;

	for (auto & elem : m_regs)
		elem = 0;
}
Exemplo n.º 7
0
Arquivo: dave.c Projeto: Overx/mame
void dave_device::device_reset()
{
	m_write_irq(CLEAR_LINE);

	for (int i = 0; i < 4; i++)
		m_segment[i] = 0;

	m_irq_status = 0;
	m_irq_enable = 0;

	for (int i = 0; i < 32; i++)
		m_regs[i] = 0;
}
Exemplo n.º 8
0
void cdp1861_device::device_reset()
{
	m_int_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0));
	m_efx_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0));
	m_dma_timer->adjust(clocks_to_attotime(CDP1861_CYCLES_DMA_START));

	m_disp = 0;
	m_dmaout = 0;
	m_dispon = 0;

	m_write_irq(CLEAR_LINE);
	m_write_dma_out(CLEAR_LINE);
	m_write_efx(CLEAR_LINE);
}
Exemplo n.º 9
0
void mos6551_device::tra_complete()
{
	if (!(m_st & ST_TDRE))
	{
		transmit_register_setup(m_tdr);
		m_st |= ST_TDRE;

		if ((m_cmd & CMD_TC_MASK) == CMD_TC_TIE_RTS_LO)
		{
			m_st |= ST_IRQ;
			m_write_irq(ASSERT_LINE);
		}
	}
}
Exemplo n.º 10
0
void tms5501_device::check_interrupt()
{
	int state = (m_irq & m_mr) ? ASSERT_LINE : CLEAR_LINE;

	if (state == ASSERT_LINE)
	{
		if (LOG) logerror("TMS5501 '%s' Interrupt Assert\n", tag());

		m_sta |= STA_IP;
	}
	else
	{
		m_sta &= ~STA_IP;
	}

	if (m_cmd & CMD_IAE)
	{
		m_write_irq(state);
	}
	else
	{
		m_write_irq(CLEAR_LINE);
	}
}
Exemplo n.º 11
0
void mos6551_device::rcv_complete()
{
	if (m_st & ST_RDRF)
	{
		m_st |= ST_OR;
	}

	m_st &= ~(ST_FE | ST_PE);

	m_st |= ST_RDRF;

	if (!(m_cmd & CMD_RIE))
	{
		m_st |= ST_IRQ;
		m_write_irq(ASSERT_LINE);
	}
}
Exemplo n.º 12
0
/* called after ISR or STRB has changed */
void mc6843_device::status_update( )
{
	int irq = 0;

	/* ISR3 */
	if ( (m_CMR & 0x40) || ! m_STRB )
		m_ISR &= ~8;
	else
		m_ISR |=  8;

	/* interrupts */
	if ( m_ISR & 4 )
		irq = 1; /* unmaskable */
	if ( ! (m_CMR & 0x80) )
	{
		/* maskable */
		if ( m_ISR & ~4 )
			irq = 1;
	}

	m_write_irq( irq );
	LOG(( "status_update: irq=%i (CMR=%02X, ISR=%02X)\n", irq, m_CMR, m_ISR ));
}
Exemplo n.º 13
0
void i8275x_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	//int y = m_screen->vpos();
	//int x = m_screen->hpos();
	int rc = m_scanline / SCANLINES_PER_ROW;
	int lc = m_scanline % SCANLINES_PER_ROW;

	switch (id)
	{
	case TIMER_HRTC_ON:
		//logerror("I8275 '%s' y %u x %u HRTC 1\n", tag(), y, x);
		m_write_hrtc(1);
		break;

	case TIMER_DRQ_ON:
		//logerror("I8275 '%s' y %u x %u DRQ 1\n", tag(), y, x);
		m_write_drq(1);
		m_drq_off_timer->adjust(clocks_to_attotime(DMA_BURST_COUNT));
		break;

	case TIMER_DRQ_OFF:
		if (m_buffer_idx == 0)
		{
			m_status |= ST_DU;
			m_du = true;
			//logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x);
			m_write_drq(0);
		}
		else if (m_buffer_idx == CHARACTERS_PER_ROW)
		{
			//logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x);
			m_write_drq(0);
		}
		else if (DMA_BURST_SPACE > 0)
		{
			//logerror("I8275 '%s' y %u x %u DRQ 0\n", tag(), y, x);
			m_write_drq(0);
			m_drq_on_timer->adjust(clocks_to_attotime(DMA_BURST_SPACE));
		}
		break;

	case TIMER_SCANLINE:
		if (!(m_status & ST_VE)) break;

		//logerror("I8275 '%s' y %u x %u HRTC 0\n", tag(), y, x);
		m_write_hrtc(0);

		if (m_scanline == 0)
		{
			//logerror("I8275 '%s' y %u x %u VRTC 0\n", tag(), y, x);
			m_write_vrtc(0);
		}
		else if (m_scanline == m_irq_scanline)
		{
			if (m_status & ST_IE)
			{
				//logerror("I8275 '%s' y %u x %u IRQ 1\n", tag(), y, x);
				m_status |= ST_IR;
				m_write_irq(ASSERT_LINE);
			}
		}
		else if (m_scanline == m_vrtc_scanline)
		{
			//logerror("I8275 '%s' y %u x %u VRTC 1\n", tag(), y, x);
			m_write_vrtc(1);

			// reset field attributes
			m_hlgt = 0;
			m_vsp = 0;
			m_gpa = 0;
			m_rvv = 0,
			m_lten = 0;

			m_du = false;

			m_cursor_blink++;
			m_cursor_blink &= 0x1f;

			m_char_blink++;
			m_char_blink &= 0x3f;
		}

		if (lc == 0)
		{
			// swap line buffers
			m_buffer_dma = !m_buffer_dma;
			m_buffer_idx = 0;
			m_fifo_idx = 0;

			if (!m_du && ((m_scanline < m_vrtc_scanline - SCANLINES_PER_ROW) || (m_scanline == m_vrtc_drq_scanline)))
			{
				// start DMA burst
				m_drq_on_timer->adjust(clocks_to_attotime(DMA_BURST_SPACE));
			}
		}

		if (m_scanline < m_vrtc_scanline)
		{
			for (int sx = 0; sx < CHARACTERS_PER_ROW; sx++)
			{
				int m_lineattr = 0;
				int lten = 0;
				int vsp = 0;

				UINT8 data = m_buffer[!m_buffer_dma][sx];

				if (data & 0x80)
				{
					if ((data & 0xc0) == 0x80)
					{
						// field attribute code
						m_hlgt = (data & FAC_H) ? 1 : 0;
						m_vsp = (data & FAC_B) ? 1 : 0;
						m_gpa = (data & FAC_GG) >> 2;
						m_rvv = (data & FAC_R) ? 1 : 0;
						m_lten = (data & FAC_U) ? 1 : 0;

						if (!VISIBLE_FIELD_ATTRIBUTE)
						{
							int fifo_idx = 0;

							data = m_fifo[!m_buffer_dma][fifo_idx];

							fifo_idx++;
							fifo_idx &= 0xf;
						}
						else
						{
							vsp = 1;
						}
					}
					else
					{
						// character attribute code
					}
				}

				if (!vsp && m_vsp)
				{
					vsp = (m_char_blink < 32) ? 1 : 0;
				}

				if ((rc == m_param[REG_CUR_ROW]) && (sx == m_param[REG_CUR_COL]))
				{
					int vis = 1;

					if (!(CURSOR_FORMAT & 0x02))
					{
						vis = (m_cursor_blink < 16) ? 1 : 0;
					}

					if (CURSOR_FORMAT & 0x01)
					{
						lten = (lc == UNDERLINE) ? vis : 0;
					}
					else
					{
						lten = vis;
					}
				}

				if (OFFSET_LINE_COUNTER)
				{
					lc = (lc - 1) & 0x0f;
				}

				if (m_display_pixels)
				m_display_pixels(this, m_bitmap,
					sx * m_hpixels_per_column, // x position on screen of starting point
					m_scanline, // y position on screen
					lc, // current line of char
					(data & 0x7f),  // char code to be displayed
					m_lineattr,  // line attribute code
					lten | m_lten,  // light enable signal
					m_rvv,  // reverse video signal
					vsp, // video suppression
					m_gpa,  // general purpose attribute code
					m_hlgt  // highlight
				);
			}
		}
Exemplo n.º 14
0
void cdp1861_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	int scanline = m_screen->vpos();

	switch (id)
	{
	case TIMER_INT:
		if (scanline == CDP1861_SCANLINE_INT_START)
		{
			if (m_disp)
			{
				m_write_irq(ASSERT_LINE);
			}

			m_int_timer->adjust(m_screen->time_until_pos( CDP1861_SCANLINE_INT_END, 0));
		}
		else
		{
			if (m_disp)
			{
				m_write_irq(CLEAR_LINE);
			}

			m_int_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_INT_START, 0));
		}
		break;

	case TIMER_EFX:
		switch (scanline)
		{
		case CDP1861_SCANLINE_EFX_TOP_START:
			m_write_efx(ASSERT_LINE);
			m_efx_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_END, 0));
			break;

		case CDP1861_SCANLINE_EFX_TOP_END:
			m_write_efx(CLEAR_LINE);
			m_efx_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_START, 0));
			break;

		case CDP1861_SCANLINE_EFX_BOTTOM_START:
			m_write_efx(ASSERT_LINE);
			m_efx_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_EFX_BOTTOM_END, 0));
			break;

		case CDP1861_SCANLINE_EFX_BOTTOM_END:
			m_write_efx(CLEAR_LINE);
			m_efx_timer->adjust(m_screen->time_until_pos(CDP1861_SCANLINE_EFX_TOP_START, 0));
			break;
		}
		break;

	case TIMER_DMA:
		if (m_dmaout)
		{
			if (m_disp)
			{
				if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END)
				{
					m_write_dma_out(CLEAR_LINE);
				}
			}

			m_dma_timer->adjust(clocks_to_attotime(CDP1861_CYCLES_DMA_WAIT));

			m_dmaout = CLEAR_LINE;
		}
		else
		{
			if (m_disp)
			{
				if (scanline >= CDP1861_SCANLINE_DISPLAY_START && scanline < CDP1861_SCANLINE_DISPLAY_END)
				{
					m_write_dma_out(ASSERT_LINE);
				}
			}

			m_dma_timer->adjust(clocks_to_attotime(CDP1861_CYCLES_DMA_ACTIVE));

			m_dmaout = ASSERT_LINE;
		}
		break;
	}
}
Exemplo n.º 15
0
void i8275_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	//int y = m_screen->vpos();
	//int x = m_screen->hpos();
	int rc = m_scanline / SCANLINES_PER_ROW;
	int lc = m_scanline % SCANLINES_PER_ROW;

	switch (id)
	{
	case TIMER_HRTC_ON:
		//LOG("I8275 y %u x %u HRTC 1\n", y, x);
		m_write_hrtc(1);
		break;

	case TIMER_DRQ_ON:
		//LOG("I8275 y %u x %u DRQ 1\n", y, x);
		m_write_drq(1);
		break;

	case TIMER_SCANLINE:
		if (!(m_status & ST_VE)) break;

		//LOG("I8275 y %u x %u HRTC 0\n", y, x);
		m_write_hrtc(0);

		if (m_scanline == 0)
		{
			//LOG("I8275 y %u x %u VRTC 0\n", y, x);
			m_write_vrtc(0);
		}

		if (m_scanline <= (m_vrtc_scanline - SCANLINES_PER_ROW))
		{
			if (lc == 0)
			{
				if (m_buffer_idx < CHARACTERS_PER_ROW)
				{
					m_status |= ST_DU;
					m_du = true;

					//LOG("I8275 y %u x %u DMA Underrun\n", y, x);

					m_write_drq(0);
				}

				if (!m_du && !m_dma_stop)
				{
					// swap line buffers
					m_buffer_dma = !m_buffer_dma;
					m_buffer_idx = 0;
					m_fifo_idx = 0;

					if ((m_scanline < (m_vrtc_scanline - SCANLINES_PER_ROW)))
					{
						// start DMA burst
						m_drq_on_timer->adjust(clocks_to_attotime(DMA_BURST_SPACE));
					}
				}
			}
		}

		if (m_scanline == m_irq_scanline)
		{
			if (m_status & ST_IE)
			{
				//LOG("I8275 y %u x %u IRQ 1\n", y, x);
				m_status |= ST_IR;
				m_write_irq(ASSERT_LINE);
			}
		}

		if (m_scanline == m_vrtc_scanline)
		{
			//LOG("I8275 y %u x %u VRTC 1\n", y, x);
			m_write_vrtc(1);

			// reset field attributes
			m_hlgt = 0;
			m_vsp = 0;
			m_gpa = 0;
			m_rvv = 0,
			m_lten = 0;

			m_du = false;
			m_dma_stop = false;
			m_end_of_screen = false;

			m_cursor_blink++;
			m_cursor_blink &= 0x1f;

			m_char_blink++;
			m_char_blink &= 0x3f;
			m_stored_attr = 0;
		}

		if (m_scanline == m_vrtc_drq_scanline)
		{
			// swap line buffers
			m_buffer_dma = !m_buffer_dma;
			m_buffer_idx = 0;
			m_fifo_idx = 0;

			// start DMA burst
			m_drq_on_timer->adjust(clocks_to_attotime(DMA_BURST_SPACE));
		}

		if (m_scanline < m_vrtc_scanline)
		{
			int line_counter = OFFSET_LINE_COUNTER ? ((lc - 1) % SCANLINES_PER_ROW) : lc;
			bool end_of_row = false;
			int fifo_idx = 0;
			m_hlgt = (m_stored_attr & FAC_H) ? 1 : 0;
			m_vsp = (m_stored_attr & FAC_B) ? 1 : 0;
			m_gpa = (m_stored_attr & FAC_GG) >> 2;
			m_rvv = (m_stored_attr & FAC_R) ? 1 : 0;
			m_lten = ((m_stored_attr & FAC_U) != 0) && (lc == UNDERLINE) ? 1 : 0;

			for (int sx = 0; sx < CHARACTERS_PER_ROW; sx++)
			{
				int m_lineattr = 0;
				int lten = 0;
				int vsp = 0;
				int rvv = 0;

				uint8_t data = (end_of_row || m_end_of_screen) ? 0 : m_buffer[!m_buffer_dma][sx];

				if (data & 0x80)
				{
					if ((data & 0xc0) == 0x80)
					{
						// field attribute code
						m_hlgt = (data & FAC_H) ? 1 : 0;
						m_vsp = (data & FAC_B) ? 1 : 0;
						m_gpa = (data & FAC_GG) >> 2;
						m_rvv = (data & FAC_R) ? 1 : 0;
						m_lten = ((data & FAC_U) != 0) && (lc == UNDERLINE) ? 1 : 0;
						if ((SCANLINES_PER_ROW - lc)==1)
							m_stored_attr = data;

						if (!VISIBLE_FIELD_ATTRIBUTE)
						{
							data = m_fifo[!m_buffer_dma][fifo_idx];

							fifo_idx++;
							fifo_idx &= 0xf;
						}
						else
						{
							vsp = 1;
						}
					}
					else
					{
						if ((data & 0xf0) == 0xf0)
						{
							// special control character
							switch (data)
							{
							case SCC_END_OF_ROW:
							case SCC_END_OF_ROW_DMA:
								end_of_row = true;
								break;

							case SCC_END_OF_SCREEN:
							case SCC_END_OF_SCREEN_DMA:
								m_end_of_screen = true;
								break;
							}
							//vsp = 1;
						}
						else
						{
							// character attribute code
							m_hlgt = (data & CA_H) ? 1 : 0;
							m_vsp = (data & CA_B) ? 1 : 0;

							uint8_t ca;
							int cccc = (data >> 2) & 0x0f;

							if (line_counter < UNDERLINE)
							{
								ca = character_attribute[0][cccc];
							}
							else if (line_counter == UNDERLINE)
							{
								ca = character_attribute[1][cccc];
							}
							else
							{
								ca = character_attribute[2][cccc];
							}

							m_lten = (ca & CA_LTEN) ? 1 : 0;
							m_vsp = (ca & CA_VSP) ? 1 : 0;
							m_lineattr = ca >> 2;
						}
					}
				}

				if (!vsp && m_vsp)
				{
					vsp = (m_char_blink < 32) ? 1 : 0;
				}

				if ((rc == m_param[REG_CUR_ROW]) && (sx == m_param[REG_CUR_COL]))
				{
					int vis = 1;

					if (!(CURSOR_FORMAT & 0x02))
					{
						vis = (m_cursor_blink < 16) ? 1 : 0;
					}

					if (CURSOR_FORMAT & 0x01)
					{
						lten = (lc == UNDERLINE) ? vis : 0;
					}
					else
					{
						rvv = vis;
					}
				}

				if (end_of_row || m_end_of_screen)
				{
					vsp = 1;
				}

				if (!m_display_cb.isnull())
				m_display_cb(m_bitmap,
					sx * m_hpixels_per_column, // x position on screen of starting point
					m_scanline, // y position on screen
					line_counter, // current line of char
					(data & 0x7f),  // char code to be displayed
					m_lineattr,  // line attribute code
					lten | m_lten,  // light enable signal
					rvv ^ m_rvv,  // reverse video signal
					vsp, // video suppression
					m_gpa,  // general purpose attribute code
					m_hlgt  // highlight
				);
			}
Exemplo n.º 16
0
void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	int year/*, month*/;

	if (id == TIMER_PERIODIC) {
		m_data[0x0c] |= 0xc0;
		m_write_irq(CLEAR_LINE);
		return;
	}

	if (BCD_MODE)
	{
		m_data[0]=bcd_adjust(m_data[0]+1);
		if (m_data[0]>=0x60)
		{
			m_data[0]=0;
			m_data[2]=bcd_adjust(m_data[2]+1);
			if (m_data[2]>=0x60)
			{
				m_data[2]=0;
				m_data[4]=bcd_adjust(m_data[4]+1);
				// different handling of hours
				if (m_data[4]>=0x24)
				{
					m_data[4]=0;
					WEEK_DAY=bcd_adjust(WEEK_DAY+1)%7;
					DAY=bcd_adjust(DAY+1);
					//month=bcd_2_dec(MONTH);
					year=bcd_2_dec(YEAR);
					if (m_type!=MC146818_IGNORE_CENTURY) year+=bcd_2_dec(CENTURY)*100;
					else year+=2000; // save for julian_days_in_month calculation
					DAY=bcd_adjust(DAY+1);
					if (DAY>gregorian_days_in_month(MONTH, year))
					{
						DAY=1;
						MONTH=bcd_adjust(MONTH+1);
						if (MONTH>0x12)
						{
							MONTH=1;
							YEAR=year=bcd_adjust(YEAR+1);
							if (m_type!=MC146818_IGNORE_CENTURY)
							{
								if (year>=0x100)
								{
									CENTURY=bcd_adjust(CENTURY+1);
								}
							}
						}
					}
				}
			}
		}
	}
	else
	{
		m_data[0]=m_data[0]+1;
		if (m_data[0]>=60)
		{
			m_data[0]=0;
			m_data[2]=m_data[2]+1;
			if (m_data[2]>=60) {
				m_data[2]=0;
				m_data[4]=m_data[4]+1;
				// different handling of hours //?
				if (m_data[4]>=24) {
					m_data[4]=0;
					WEEK_DAY=(WEEK_DAY+1)%7;
					year=YEAR;
					if (m_type!=MC146818_IGNORE_CENTURY) year+=CENTURY*100;
					else year+=2000; // save for julian_days_in_month calculation
					if (++DAY>gregorian_days_in_month(MONTH, year)) {
						DAY=1;
						if (++MONTH>12) {
							MONTH=1;
							YEAR++;
							if (m_type!=MC146818_IGNORE_CENTURY) {
								if (YEAR>=100) { CENTURY++;YEAR=0; }
							} else {
								YEAR%=100;
							}
						}
					}
				}
			}
		}
	}

	if (m_data[1] == m_data[0] && //
		m_data[3] == m_data[2] && //
		m_data[5] == m_data[4]) {
		// set the alarm interrupt flag AF
		m_data[0x0c] |= 0x20;
	} else {
		// clear the alarm interrupt flag AF
		m_data[0x0c] &= ~0x20;
		if ((m_data[0x0c] & 0x70) == 0) {
			// clear IRQF
			m_data[0x0c] &= ~0x80;
		}
	}

	// set the update-ended interrupt Flag UF
	m_data[0x0c] |=  0x10;

	// set the interrupt request flag IRQF
	// FIXME: should throw IRQ line as well
	if ((m_data[0x0b] & m_data[0x0c] & 0x30) != 0) {
		m_data[0x0c] |=  0x80;
	}

	// IRQ line is active low
	m_write_irq((m_data[0x0c] & 0x80) ? CLEAR_LINE : ASSERT_LINE);

	m_updated = true;  /* clock has been updated */
	m_last_refresh = machine().time();
}