예제 #1
0
static READ16_HANDLER( calendar_r )
{
    mame_system_time systime;

    mame_get_base_datetime(space->machine, &systime);

    switch (offset)
    {
    case 0:
        return ((systime.local_time.second/10)<<4) + (systime.local_time.second%10);
    case 1:
        return ((systime.local_time.minute/10)<<4) + (systime.local_time.minute%10);
    case 2:
        return ((systime.local_time.hour/10)<<4) + (systime.local_time.hour%10);
    case 3:
        return systime.local_time.weekday;
    case 4:
        return ((systime.local_time.mday/10)<<4) + (systime.local_time.mday%10);
    case 5:
        return (systime.local_time.month + 1);
    case 6:
        return (((systime.local_time.year%100)/10)<<4) + (systime.local_time.year%10);
    case 7:
    default:
        return 0;	/* status? the other registers are read only when bit 0 is clear */
    }
}
예제 #2
0
파일: timekpr.c 프로젝트: nitrologic/emu
static DEVICE_START(timekeeper)
{
	timekeeper_state *c = get_safe_token(device);
	emu_timer *timer;
	attotime duration;
	mame_system_time systime;

	/* validate some basic stuff */
	assert(device != NULL);
//  assert(device->static_config != NULL);
	assert(device->inline_config == NULL);
	assert(device->machine != NULL);
	assert(device->machine->config != NULL);

	mame_get_base_datetime(device->machine, &systime);

	c->device = device;
	c->control = 0;
	c->seconds = make_bcd( systime.local_time.second );
	c->minutes = make_bcd( systime.local_time.minute );
	c->hours = make_bcd( systime.local_time.hour );
	c->day = make_bcd( systime.local_time.weekday + 1 );
	c->date = make_bcd( systime.local_time.mday );
	c->month = make_bcd( systime.local_time.month + 1 );
	c->year = make_bcd( systime.local_time.year % 100 );
	c->century = make_bcd( systime.local_time.year / 100 );
	c->data = auto_alloc_array( device->machine, UINT8, c->size );

	c->default_data = device->region;
	if (c->default_data != NULL)
	{
		assert( device->regionbytes == c->size );
	}

	state_save_register_device_item( device, 0, c->control );
	state_save_register_device_item( device, 0, c->seconds );
	state_save_register_device_item( device, 0, c->minutes );
	state_save_register_device_item( device, 0, c->hours );
	state_save_register_device_item( device, 0, c->day );
	state_save_register_device_item( device, 0, c->date );
	state_save_register_device_item( device, 0, c->month );
	state_save_register_device_item( device, 0, c->year );
	state_save_register_device_item( device, 0, c->century );
	state_save_register_device_item_pointer( device, 0, c->data, c->size );

	timer = timer_alloc( device->machine, timekeeper_tick, c );
	duration = ATTOTIME_IN_SEC(1);
	timer_adjust_periodic( timer, duration, 0, duration );
}
예제 #3
0
파일: timekpr.c 프로젝트: broftkd/mess-cvs
void timekeeper_init( int chip, int type, UINT8 *data )
{
	mame_timer *timer;
	mame_time duration;
	mame_system_time systime;
	struct timekeeper_chip *c;

	if( chip >= MAX_TIMEKEEPER_CHIPS )
	{
		logerror( "timekeeper_init( %d ) invalid chip\n", chip );
		return;
	}
	c = &timekeeper[ chip ];

	c->type = type;

	switch( c->type )
	{
	case TIMEKEEPER_M48T02:
		c->offset_control = 0x7f8;
		c->offset_seconds = 0x7f9;
		c->offset_minutes = 0x7fa;
		c->offset_hours = 0x7fb;
		c->offset_day = 0x7fc;
		c->offset_date = 0x7fd;
		c->offset_month = 0x7fe;
		c->offset_year = 0x7ff;
		c->offset_century = -1;
		c->offset_flags = -1;
		c->size = 0x800;
		break;
	case TIMEKEEPER_M48T58:
		c->offset_control = 0x1ff8;
		c->offset_seconds = 0x1ff9;
		c->offset_minutes = 0x1ffa;
		c->offset_hours = 0x1ffb;
		c->offset_day = 0x1ffc;
		c->offset_date = 0x1ffd;
		c->offset_month = 0x1ffe;
		c->offset_year = 0x1fff;
		c->offset_century = -1;
		c->offset_flags = -1;
		c->size = 0x2000;
		break;
	case TIMEKEEPER_MK48T08:
		c->offset_control = 0x1ff8;
		c->offset_seconds = 0x1ff9;
		c->offset_minutes = 0x1ffa;
		c->offset_hours = 0x1ffb;
		c->offset_day = 0x1ffc;
		c->offset_date = 0x1ffd;
		c->offset_month = 0x1ffe;
		c->offset_year = 0x1fff;
		c->offset_century = 0x1ff1;
		c->offset_flags = 0x1ff0;
		c->size = 0x2000;
		break;
	}

	if( data == NULL )
	{
		data = auto_malloc( c->size );
		memset( data, 0xff, c->size );
	}
	c->data = data;

	mame_get_base_datetime(Machine, &systime);

	c->control = 0;
	c->seconds = make_bcd( systime.local_time.second );
	c->minutes = make_bcd( systime.local_time.minute );
	c->hours = make_bcd( systime.local_time.hour );
	c->day = make_bcd( systime.local_time.weekday + 1 );
	c->date = make_bcd( systime.local_time.mday );
	c->month = make_bcd( systime.local_time.month + 1 );
	c->year = make_bcd( systime.local_time.year % 100 );
	c->century = make_bcd( systime.local_time.year / 100 );

	state_save_register_item( "timekeeper", chip, c->control );
	state_save_register_item( "timekeeper", chip, c->seconds );
	state_save_register_item( "timekeeper", chip, c->minutes );
	state_save_register_item( "timekeeper", chip, c->hours );
	state_save_register_item( "timekeeper", chip, c->day );
	state_save_register_item( "timekeeper", chip, c->date );
	state_save_register_item( "timekeeper", chip, c->month );
	state_save_register_item( "timekeeper", chip, c->year );
	state_save_register_item( "timekeeper", chip, c->century );
	state_save_register_item_pointer( "timekeeper", chip, c->data, c->size );

	timer = mame_timer_alloc( timekeeper_tick );
	duration = make_mame_time( 1, 0 );
	mame_timer_adjust( timer, duration, chip, duration );
}
예제 #4
0
void DS1302_CLK(UINT8 val)
{
	if(val!=LastClk)
	{
		if(val)	//Rising, shift in command
		{
			ICount++;
			if(ICount==8)	//Command start
			{
				mame_system_time systime;
				mame_get_base_datetime(Machine, &systime);

				switch(ShiftIn)
				{
					case 0x81:	//Sec
						ShiftOut=bcd(systime.local_time.second);
						break;
					case 0x83:	//Min
						ShiftOut=bcd(systime.local_time.minute);
						break;
					case 0x85:	//Hour
						ShiftOut=bcd(systime.local_time.hour);
						break;
					case 0x87:	//Day
						ShiftOut=bcd(systime.local_time.mday);
						break;
					case 0x89:	//Month
						ShiftOut=bcd(systime.local_time.month+1);
						break;
					case 0x8b:	//weekday
						ShiftOut=bcd(systime.local_time.weekday);
						break;
					case 0x8d:	//Year
						ShiftOut=bcd(systime.local_time.year%100);
						break;
					default:
						ShiftOut=0x0;
				}
				if(ShiftIn>0xc0)
					ShiftOut=SRAM[(ShiftIn>>1)&0x1f];
				LastCmd=ShiftIn&0xff;
				ICount++;
			}
			if(ICount==17 && !(LastCmd&1))
			{
				UINT8 val=(ShiftIn>>9)&0xff;

				switch(LastCmd)
				{
					case 0x80:	//Sec

						break;
					case 0x82:	//Min

						break;
					case 0x84:	//Hour

						break;
					case 0x86:	//Day

						break;
					case 0x88:	//Month

						break;
					case 0x8a:	//weekday

						break;
					case 0x8c:	//Year

						break;
					default:
						ShiftOut=0x0;
				}
				if(LastCmd>0xc0)
				{
					SRAM[(LastCmd>>1)&0x1f]=val;
				}



			}