コード例 #1
0
ファイル: europc.c プロジェクト: BirchJD/xmame-0.103-RPi
static void europc_rtc_timer(int param)
{
	int month, year;
	europc_rtc.data[0]=bcd_adjust(europc_rtc.data[0]+1);
	if (europc_rtc.data[0]>=0x60) {
		europc_rtc.data[0]=0;
		europc_rtc.data[1]=bcd_adjust(europc_rtc.data[1]+1);
		if (europc_rtc.data[1]>=0x60) {
			europc_rtc.data[1]=0;
			europc_rtc.data[2]=bcd_adjust(europc_rtc.data[2]+1);
			if (europc_rtc.data[2]>=0x24) {
				europc_rtc.data[2]=0;
				europc_rtc.data[3]=bcd_adjust(europc_rtc.data[3]+1);
				month=bcd_2_dec(europc_rtc.data[4]);
				year=bcd_2_dec(europc_rtc.data[5])+2000; /* save for julian_days_in_month_calculation */
				if (europc_rtc.data[3]> gregorian_days_in_month(month, year)) {
					europc_rtc.data[3]=1;
					europc_rtc.data[4]=bcd_adjust(europc_rtc.data[4]+1);
					if (europc_rtc.data[4]>0x12) {
						europc_rtc.data[4]=1;
						europc_rtc.data[5]=bcd_adjust(europc_rtc.data[5]+1)&0xff;
					}
				}
			}
		}
	}
}
コード例 #2
0
ファイル: cms.cpp プロジェクト: SailorSat/cabmame
void cms_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	int month, year;

	switch (id)
	{
	case TIMER_RTC:
		m_rtc_data[0] = bcd_adjust(m_rtc_data[0] + 1);
		if (m_rtc_data[0] >= 0x60)
		{
			m_rtc_data[0] = 0;
			m_rtc_data[1] = bcd_adjust(m_rtc_data[1] + 1);
			if (m_rtc_data[1] >= 0x60)
			{
				m_rtc_data[1] = 0;
				m_rtc_data[2] = bcd_adjust(m_rtc_data[2] + 1);
				if (m_rtc_data[2] >= 0x24)
				{
					m_rtc_data[2] = 0;
					m_rtc_data[3] = bcd_adjust(m_rtc_data[3] + 1);
					month = bcd_2_dec(m_rtc_data[4]);
					year = bcd_2_dec(m_rtc_data[5]) + 2000; // save for julian_days_in_month_calculation
					if (m_rtc_data[3]> gregorian_days_in_month(month, year))
					{
						m_rtc_data[3] = 1;
						m_rtc_data[4] = bcd_adjust(m_rtc_data[4] + 1);
						if (m_rtc_data[4]>0x12)
						{
							m_rtc_data[4] = 1;
							m_rtc_data[5] = bcd_adjust(m_rtc_data[5] + 1) & 0xff;
						}
					}
				}
			}
		}
		break;
	}
}
コード例 #3
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;
		if (!m_out_irq_func.isnull()) m_out_irq_func(CLEAR_LINE);
		return;
	}

	if (m_type == MC146818_UTC) {
		// hack: set correct real time even for overloaded emulation
		// (at least for apollo)
		static osd_ticks_t t0 = 0;
		osd_ticks_t t1 = osd_ticks();
		int n_seconds;

		if (t0 == 0) {
			t0 = t1;
		}

		n_seconds =  (t1 - t0) / osd_ticks_per_second();
		t0 = t1 - (t1 - t0) % osd_ticks_per_second();
		if (n_seconds <= 0) {
			// we were called to early
			return;
		}

		m_data[0] += n_seconds;
	} else {
		m_data[0] += 1;
	}

	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] -= 60;
			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
	if (!m_out_irq_func.isnull()) m_out_irq_func((m_data[0x0c] & 0x80) ? CLEAR_LINE : ASSERT_LINE);

	m_updated = true;  /* clock has been updated */
	m_last_refresh = machine().time();
}
コード例 #4
0
ファイル: mc146818.c プロジェクト: DarrenBranford/MAME4iOS
static TIMER_CALLBACK( mc146818_timer )
{
	int year/*, month*/;

	if (BCD_MODE)
	{
		mc146818->data[0]=bcd_adjust(mc146818->data[0]+1);
		if (mc146818->data[0]>=0x60)
		{
			mc146818->data[0]=0;
			mc146818->data[2]=bcd_adjust(mc146818->data[2]+1);
			if (mc146818->data[2]>=0x60)
			{
				mc146818->data[2]=0;
				mc146818->data[4]=bcd_adjust(mc146818->data[4]+1);
				// different handling of hours
				if (mc146818->data[4]>=0x24)
				{
					mc146818->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 (mc146818->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 (mc146818->type!=MC146818_IGNORE_CENTURY)
							{
								if (year>=0x100)
								{
									CENTURY=bcd_adjust(CENTURY+1);
								}
							}
						}
					}
				}
			}
		}
	}
	else
	{
		mc146818->data[0]=mc146818->data[0]+1;
		if (mc146818->data[0]>=60)
		{
			mc146818->data[0]=0;
			mc146818->data[2]=mc146818->data[2]+1;
			if (mc146818->data[2]>=60) {
				mc146818->data[2]=0;
				mc146818->data[4]=mc146818->data[4]+1;
				// different handling of hours //?
				if (mc146818->data[4]>=24) {
					mc146818->data[4]=0;
					WEEK_DAY=(WEEK_DAY+1)%7;
					year=YEAR;
					if (mc146818->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 (mc146818->type!=MC146818_IGNORE_CENTURY) {
								if (YEAR>=100) { CENTURY++;YEAR=0; }
							} else {
								YEAR%=100;
							}
						}
					}
				}
			}
		}
	}
	mc146818->updated = 1;  /* clock has been updated */
	mc146818->last_refresh = timer_get_time(machine);
}
コード例 #5
0
ファイル: mc146818.c プロジェクト: LeWoY/MAMEHub
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();
}