static mame_time choose_delay(unicode_char_t ch) { subseconds_t delay = 0; if (current_rate.seconds || current_rate.subseconds) return current_rate; if (queue_chars) { /* systems with queue_chars can afford a much smaller delay */ delay = DOUBLE_TO_SUBSECONDS(0.01); } else { switch(ch) { case '\r': delay = DOUBLE_TO_SUBSECONDS(0.2); break; default: delay = DOUBLE_TO_SUBSECONDS(0.05); break; } } return make_mame_time(0, delay); }
static WRITE8_HANDLER( output_port_0_w ) { /* Note: We compute the timeout time on a write here. Unfortunately, the situation is kind of weird, because the discrete sound system is also affected by this timeout. In fact, it is very important that our timing calculation timeout AFTER the sound system's equivalent computation, or else we will hang notes. */ UINT8 raw_game_speed = readinputport(6); double resistance = raw_game_speed * 25000 / 100; mame_time duration = make_mame_time(0, MAX_SUBSECONDS * 0.45 * 6.8e-6 * resistance * (data+1)); timeout_time = add_mame_times(mame_timer_get_time(), duration); discrete_sound_w(HITME_DOWNCOUNT_VAL, data); discrete_sound_w(HITME_OUT0, 1); }
static void node_input(xml_data_node *node) { /* <input> - inputs natural keyboard data into a system */ xml_attribute_node *attr_node; mame_time rate; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_INPUT; attr_node = xml_get_attribute(node, "rate"); rate = attr_node ? parse_time(attr_node->value) : make_mame_time(0, 0); new_command.u.input_args.rate = rate; new_command.u.input_args.input_chars = node->value; if (!append_command()) { error_outofmemory(); return; } }
mame_time video_screen_get_time_until_pos(int scrnum, int vpos, int hpos) { mame_time curdelta = sub_mame_times(mame_timer_get_time(), scrinfo[scrnum].vblank_time); subseconds_t targetdelta; assert(curdelta.seconds == 0); /* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */ vpos += Machine->screen[scrnum].height - (Machine->screen[scrnum].visarea.max_y + 1); vpos %= Machine->screen[scrnum].height; /* compute the delta for the given X,Y position */ targetdelta = (subseconds_t)vpos * scrinfo[scrnum].scantime + (subseconds_t)hpos * scrinfo[scrnum].pixeltime; /* if we're past that time, head to the next frame */ if (targetdelta <= curdelta.subseconds) targetdelta += DOUBLE_TO_SUBSECONDS(TIME_IN_HZ(Machine->screen[scrnum].refresh)); /* return the difference */ return make_mame_time(0, targetdelta - curdelta.subseconds); }
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 ); }
void inputx_post_utf8(const char *text) { inputx_post_utf8_rate(text, make_mame_time(0, 0)); }
void inputx_postn_coded(const char *text, size_t text_len) { inputx_postn_coded_rate(text, text_len, make_mame_time(0, 0)); }
void inputx_post_utf16(const utf16_char_t *text) { inputx_post_utf16_rate(text, make_mame_time(0, 0)); }
void inputx_postn_utf16(const utf16_char_t *text, size_t text_len) { inputx_postn_utf16_rate(text, text_len, make_mame_time(0, 0)); }
void inputx_postc(unicode_char_t ch) { inputx_postc_rate(ch, make_mame_time(0, 0)); }
void inputx_post(const unicode_char_t *text) { inputx_post_rate(text, make_mame_time(0, 0)); }
void inputx_postn(const unicode_char_t *text, size_t text_len) { inputx_postn_rate(text, text_len, make_mame_time(0, 0)); }