/* Record a key/joy sequence return <0 if more input is needed return ==0 if sequence succesfully recorded return >0 if aborted */ int seq_read_async(InputSeq* seq, int first) { InputCode newkey; if (input_ui_pressed(IPT_UI_CANCEL)) return 1; if (record_count == SEQ_MAX || (record_count > 0 && clock() > record_last + RECORD_TIME)) { int k = 0; if (!first) { /* search the first space free */ while (k < SEQ_MAX && (*seq)[k] != CODE_NONE) ++k; } /* if no space restart */ if (k + record_count + (k!=0) > SEQ_MAX) k = 0; /* insert */ if (k + record_count + (k!=0) <= SEQ_MAX) { int j; if (k!=0) (*seq)[k++] = CODE_OR; for(j=0;j<record_count;++j,++k) (*seq)[k] = record_seq[j]; } /* fill to end */ while (k < SEQ_MAX) { (*seq)[k] = CODE_NONE; ++k; } if (!seq_valid(seq)) seq_set_1(seq,CODE_NONE); return 0; } newkey = code_read_async(); if (newkey != CODE_NONE) { /* if code is duplicate negate the code */ if (record_count && newkey == record_seq[record_count-1]) record_seq[record_count-1] = CODE_NOT; record_seq[record_count++] = newkey; record_last = clock(); } return -1; }
void mess_ui_update(void) { static int ui_toggle_key = 0; static int ui_display_count = 30; char buf[2048]; int id; const struct IODevice *dev; /* traditional MESS interface */ if (Machine->gamedrv->flags & GAME_COMPUTER) { if( input_ui_pressed(IPT_UI_TOGGLE_UI) ) { if( !ui_toggle_key ) { ui_toggle_key = 1; ui_active = !ui_active; ui_display_count = 30; schedule_full_refresh(); } } else { ui_toggle_key = 0; } if (ui_active) { if( ui_display_count > 0 ) { buf[0] = 0; strcpy(buf,ui_getstring (UI_keyb1)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb2)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb3)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb5)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb2)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb7)); strcat(buf,"\n"); ui_draw_message_window(buf); if( --ui_display_count == 0 ) schedule_full_refresh(); } } else { if( ui_display_count > 0 ) { buf[0] = 0; strcpy(buf,ui_getstring (UI_keyb1)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb2)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb4)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb6)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb2)); strcat(buf,"\n"); strcat(buf,ui_getstring (UI_keyb7)); strcat(buf,"\n"); ui_draw_message_window(buf); if( --ui_display_count == 0 ) schedule_full_refresh(); } } } /* run display routine for device */ if (devices_inited) { for (dev = Machine->devices; dev->type < IO_COUNT; dev++) { if (dev->display) { for (id = 0; id < device_count(dev->type); id++) { mess_image *img = image_from_devtype_and_index(dev->type, id); dev->display(img, NULL); } } } } }
static void check_inputs(void) { // increment frameskip? if (input_ui_pressed(IPT_UI_FRAMESKIP_INC)) { // if autoframeskip, disable auto and go to 0 if (autoframeskip) { autoframeskip = 0; frameskip = 0; } // wrap from maximum to auto else if (frameskip == FRAMESKIP_LEVELS - 1) { frameskip = 0; autoframeskip = 1; } // else just increment else frameskip++; // display the FPS counter for 2 seconds ui_show_fps_temp(2.0); // reset the frame counter so we'll measure the average FPS on a consistent status frames_displayed = 0; } // decrement frameskip? if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC)) { // if autoframeskip, disable auto and go to max if (autoframeskip) { autoframeskip = 0; frameskip = FRAMESKIP_LEVELS - 1; } // wrap from 0 to auto else if (frameskip == 0) autoframeskip = 1; // else just decrement else frameskip--; // display the FPS counter for 2 seconds ui_show_fps_temp(2.0); // reset the frame counter so we'll measure the average FPS on a consistent status frames_displayed = 0; } // toggle throttle? if (input_ui_pressed(IPT_UI_THROTTLE)) { throttle ^= 1; // reset the frame counter so we'll measure the average FPS on a consistent status frames_displayed = 0; } #ifdef MESS // check for toggling menu bar if (input_ui_pressed(IPT_OSD_2)) win_toggle_menubar(); #endif }
/* Update the display. */ void osd_update_video_and_audio(struct osd_bitmap *bitmap) { static const int waittable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = { { 1,1,1,1,1,1,1,1,1,1,1,1 }, { 2,1,1,1,1,1,1,1,1,1,1,0 }, { 2,1,1,1,1,0,2,1,1,1,1,0 }, { 2,1,1,0,2,1,1,0,2,1,1,0 }, { 2,1,0,2,1,0,2,1,0,2,1,0 }, { 2,0,2,1,0,2,0,2,1,0,2,0 }, { 2,0,2,0,2,0,2,0,2,0,2,0 }, { 2,0,2,0,0,3,0,2,0,0,3,0 }, { 3,0,0,3,0,0,3,0,0,3,0,0 }, { 4,0,0,0,4,0,0,0,4,0,0,0 }, { 6,0,0,0,0,0,6,0,0,0,0,0 }, {12,0,0,0,0,0,0,0,0,0,0,0 } }; int i; static int showfps,showfpstemp; TICKER curr; static TICKER prev_measure=0,this_frame_base,prev; static int speed = 100; static int vups,vfcount; int have_to_clear_bitmap = 0; if (prev_measure==0) { /* first time through, initialize timer */ prev_measure = ticker() - FRAMESKIP_LEVELS * TICKS_PER_SEC/video_fps; } if (frameskip_counter == 0) this_frame_base = prev_measure + FRAMESKIP_LEVELS * TICKS_PER_SEC/video_fps; /* update audio */ msdos_update_audio(); if (osd_skip_this_frame() == 0) { if (showfpstemp) { showfpstemp--; if (showfps == 0 && showfpstemp == 0) { have_to_clear_bitmap = 1; } } if (input_ui_pressed(IPT_UI_SHOW_FPS)) { if (showfpstemp) { showfpstemp = 0; have_to_clear_bitmap = 1; } else { showfps ^= 1; if (showfps == 0) { have_to_clear_bitmap = 1; } } } /* now wait until it's time to update the screen */ if (throttle) { profiler_mark(PROFILER_IDLE); if (video_sync) { static TICKER last; do { vsync(); curr = ticker(); } while (TICKS_PER_SEC / (curr - last) > video_fps * 11 /10); last = curr; } else { TICKER target; /* wait for video sync but use normal throttling */ if (wait_vsync) vsync(); curr = ticker(); target = this_frame_base + frameskip_counter * TICKS_PER_SEC/video_fps; if ((curr < target) && (target-curr<TICKS_PER_SEC)) { do { #ifdef WIZ spend_cycles(1024); // WIZ #endif curr = ticker(); } while ((curr < target) && (target-curr<TICKS_PER_SEC)); } } profiler_mark(PROFILER_END); } else curr = ticker(); if (frameskip_counter == 0) { int divdr; divdr = video_fps * (curr - prev_measure) / (100 * FRAMESKIP_LEVELS); if (divdr==0) divdr=1; speed = (TICKS_PER_SEC + divdr/2) / divdr; prev_measure = curr; } prev = curr; vfcount += waittable[frameskip][frameskip_counter]; if (vfcount >= video_fps) { extern int vector_updates; /* avgdvg_go_w()'s per Mame frame, should be 1 */ vfcount = 0; vups = vector_updates; vector_updates = 0; } if (showfps || showfpstemp) { int fps; char buf[30]; int divdr; divdr = 100 * FRAMESKIP_LEVELS; fps = (video_fps * (FRAMESKIP_LEVELS - frameskip) * speed + (divdr / 2)) / divdr; sprintf(buf,"%s%2d%4d%%%4d/%d fps",autoframeskip?"auto":"fskp",frameskip,speed,fps,(int)(video_fps+0.5)); ui_text(bitmap,buf,Machine->uiwidth-strlen(buf)*Machine->uifontwidth,0); if (vector_game) { sprintf(buf," %d vector updates",vups); ui_text(bitmap,buf,Machine->uiwidth-strlen(buf)*Machine->uifontwidth,Machine->uifontheight); } } if (bitmap->depth == 8) { if (dirty_bright) { dirty_bright = 0; for (i = 0;i < 256;i++) { float rate = brightness * brightness_paused_adjust * pow(i / 255.0, 1 / osd_gamma_correction) / 100; bright_lookup[i] = 255 * rate + 0.5; } } if (dirtypalette) { dirtypalette = 0; for (i = 0;i < screen_colors;i++) { if (dirtycolor[i]) { unsigned char r,g,b; dirtycolor[i] = 0; r = current_palette[3*i+0]; g = current_palette[3*i+1]; b = current_palette[3*i+2]; if (i != Machine->uifont->colortable[1]) /* don't adjust the user interface text */ { r = bright_lookup[r]; g = bright_lookup[g]; b = bright_lookup[b]; } wiz_video_color8(i,r,g,b); } } wiz_video_setpalette(); } } else { if (dirty_bright) { dirty_bright = 0; for (i = 0;i < 256;i++) { float rate = brightness * brightness_paused_adjust * pow(i / 255.0, 1 / osd_gamma_correction) / 100; bright_lookup[i] = 255 * rate + 0.5; } } if (dirtypalette) { if (use_dirty) init_dirty(1); /* have to redraw the whole screen */ dirtypalette = 0; for (i = 0;i < screen_colors;i++) { if (dirtycolor[i]) { int r,g,b; dirtycolor[i] = 0; r = current_palette[3*i+0]; g = current_palette[3*i+1]; b = current_palette[3*i+2]; if (i != Machine->uifont->colortable[1]) /* don't adjust the user interface text */ { r = bright_lookup[r]; g = bright_lookup[g]; b = bright_lookup[b]; } palette_16bit_lookup[i] = makecol(r,g,b); } } } } /* copy the bitmap to screen memory */ profiler_mark(PROFILER_BLIT); update_screen(bitmap); profiler_mark(PROFILER_END); if (have_to_clear_bitmap) osd_clearbitmap(bitmap); if (use_dirty) { if (!vector_game) swap_dirty(); init_dirty(0); } if (have_to_clear_bitmap) osd_clearbitmap(bitmap); if (throttle && autoframeskip && frameskip_counter == 0) { static int frameskipadjust; int adjspeed; /* adjust speed to video refresh rate if vsync is on */ adjspeed = speed * video_fps / vsync_frame_rate; if (adjspeed >= 92) { frameskipadjust++; if (frameskipadjust >= 3) { frameskipadjust = 0; if (frameskip > 0) frameskip--; } } else { if (adjspeed < 80) frameskipadjust -= (90 - adjspeed) / 5; else { /* don't push frameskip too far if we are close to 100% speed */ if (frameskip < 8) frameskipadjust--; } while (frameskipadjust <= -2) { frameskipadjust += 2; #ifdef WIZ if (frameskip < 7) frameskip++; #else if (frameskip < FRAMESKIP_LEVELS-1) frameskip++; #endif } } } } /* Check for PGUP, PGDN and pan screen */ pan_display(); if (input_ui_pressed(IPT_UI_FRAMESKIP_INC)) { if (autoframeskip) { autoframeskip = 0; frameskip = 0; } else { if (frameskip == FRAMESKIP_LEVELS-1) { frameskip = 0; autoframeskip = 1; } else frameskip++; } if (showfps == 0) showfpstemp = 2*video_fps; } if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC)) { if (autoframeskip) { autoframeskip = 0; frameskip = FRAMESKIP_LEVELS-1; } else { if (frameskip == 0) autoframeskip = 1; else frameskip--; } if (showfps == 0) showfpstemp = 2*video_fps; } if (input_ui_pressed(IPT_UI_THROTTLE)) { throttle ^= 1; } frameskip_counter = (frameskip_counter + 1) % FRAMESKIP_LEVELS; }
static void check_osd_inputs(void) { // increment frameskip? if (input_ui_pressed(IPT_UI_FRAMESKIP_INC)) { // if autoframeskip, disable auto and go to 0 if (video_config.autoframeskip) { video_config.autoframeskip = 0; video_config.frameskip = 0; } // wrap from maximum to auto else if (video_config.frameskip == FRAMESKIP_LEVELS - 1) { video_config.frameskip = 0; video_config.autoframeskip = 1; } // else just increment else video_config.frameskip++; // display the FPS counter for 2 seconds ui_show_fps_temp(2.0); // reset the frame counter so we'll measure the average FPS on a consistent status fps_frames_displayed = 0; } // decrement frameskip? if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC)) { // if autoframeskip, disable auto and go to max if (video_config.autoframeskip) { video_config.autoframeskip = 0; video_config.frameskip = FRAMESKIP_LEVELS-1; } // wrap from 0 to auto else if (video_config.frameskip == 0) video_config.autoframeskip = 1; // else just decrement else video_config.frameskip--; // display the FPS counter for 2 seconds ui_show_fps_temp(2.0); // reset the frame counter so we'll measure the average FPS on a consistent status fps_frames_displayed = 0; } // toggle throttle? if (input_ui_pressed(IPT_UI_THROTTLE)) { video_config.throttle = !video_config.throttle; // reset the frame counter so we'll measure the average FPS on a consistent status fps_frames_displayed = 0; } // check for toggling fullscreen mode if (input_ui_pressed(IPT_OSD_1)) winwindow_toggle_full_screen(); #ifdef MESS // check for toggling menu bar if (input_ui_pressed(IPT_OSD_2)) win_toggle_menubar(); #endif // check for fast forward video_config.fastforward = input_port_type_pressed(IPT_OSD_3, 0); if (video_config.fastforward) ui_show_fps_temp(0.5); }