static void command_end(void) { /* at the end of our test */ state = STATE_DONE; final_time = timer_get_time(); mame_schedule_exit(); }
void osd_update(running_machine *machine, int skip_redraw){ nitroinput_update(); const render_primitive_list *primlist; int minwidth, minheight; // get the minimum width/height for the current layout render_target_get_minimum_size(our_target, &minwidth, &minheight); if(our_target){ // make that the size of our target render_target_set_bounds(our_target, minwidth, minheight, 0); // get the list of primitives for the target at the current size primlist = render_target_get_primitives(our_target); // lock them, and then render them osd_lock_acquire(primlist->lock); // do the drawing here osd_lock_release(primlist->lock); } // after 5 seconds, exit if (attotime_compare(timer_get_time(machine), attotime_make(5, 0)) > 0) mame_schedule_exit(machine); }
static void update_fps(mame_time emutime) { osd_ticks_t curr = osd_ticks(); // update stats for the FPS average calculation if (fps_start_time == 0) { // start the timer going 1 second into the game if (emutime.seconds > 1) fps_start_time = osd_ticks(); } else { fps_frames_displayed++; if (fps_frames_displayed == video_config.framestorun) { mame_file_error filerr; mame_file *fp; char name[20]; // make a filename with an underscore prefix sprintf(name, "_%.8s.png", Machine->gamedrv->name); // write out the screenshot filerr = mame_fopen(SEARCHPATH_SCREENSHOT, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &fp); if (filerr == FILERR_NONE) { video_screen_save_snapshot(fp, 0); mame_fclose(fp); } mame_schedule_exit(Machine); } fps_end_time = curr; } }
void winwindow_process_events(int ingame) { int is_debugger_visible = 0; MSG message; assert(GetCurrentThreadId() == main_threadid); // if we're running, disable some parts of the debugger #if defined(MAME_DEBUG) if (ingame) { is_debugger_visible = (options.mame_debug && debugwin_is_debugger_visible()); debugwin_update_during_game(); } #endif // remember the last time we did this last_event_check = osd_ticks(); do { // if we are paused, lets wait for a message if (ui_temp_pause > 0) WaitMessage(); // loop over all messages in the queue while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { int dispatch = TRUE; switch (message.message) { // ignore keyboard messages case WM_SYSKEYUP: case WM_SYSKEYDOWN: #ifndef MESS case WM_KEYUP: case WM_KEYDOWN: case WM_CHAR: #endif dispatch = is_debugger_visible; break; // special case for quit case WM_QUIT: fatalerror("Unexpected WM_QUIT message\n"); break; // temporary pause from the window thread case WM_USER_UI_TEMP_PAUSE: winwindow_ui_pause_from_main_thread(message.wParam); dispatch = FALSE; break; // request exit from the window thread case WM_USER_REQUEST_EXIT: mame_schedule_exit(Machine); dispatch = FALSE; break; // execute arbitrary function case WM_USER_EXEC_FUNC: { void (*func)(void *) = (void (*)(void *)) message.wParam; void *param = (void *) message.lParam; func(param); } break; // forward mouse button downs to the input system case WM_LBUTTONDOWN: input_mouse_button_down(0, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); dispatch = is_debugger_visible; break; case WM_RBUTTONDOWN: input_mouse_button_down(1, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); dispatch = is_debugger_visible; break; case WM_MBUTTONDOWN: input_mouse_button_down(2, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); dispatch = is_debugger_visible; break; case WM_XBUTTONDOWN: input_mouse_button_down(3, GET_X_LPARAM(message.lParam), GET_Y_LPARAM(message.lParam)); dispatch = is_debugger_visible; break; // forward mouse button ups to the input system case WM_LBUTTONUP: input_mouse_button_up(0); dispatch = is_debugger_visible; break; case WM_RBUTTONUP: input_mouse_button_up(1); dispatch = is_debugger_visible; break; case WM_MBUTTONUP: input_mouse_button_up(2); dispatch = is_debugger_visible; break; case WM_XBUTTONUP: input_mouse_button_up(3); dispatch = is_debugger_visible; break; } // dispatch if necessary if (dispatch) { TranslateMessage(&message); DispatchMessage(&message); } } } while(ui_temp_pause > 0); }
LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) { LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA); win_window_info *window = (win_window_info *)ptr; // we may get called before SetWindowLongPtr is called if (window != NULL) { assert(GetCurrentThreadId() == window_threadid); update_minmax_state(window); } // handle a few messages switch (message) { // paint: redraw the last bitmap case WM_PAINT: { PAINTSTRUCT pstruct; HDC hdc = BeginPaint(wnd, &pstruct); draw_video_contents(window, hdc, TRUE); if (win_has_menu(window)) DrawMenuBar(window->hwnd); EndPaint(wnd, &pstruct); break; } // non-client paint: punt if full screen case WM_NCPAINT: if (!window->fullscreen || HAS_WINDOW_MENU) return DefWindowProc(wnd, message, wparam, lparam); break; // input: handle the raw mouse input case WM_INPUT: if (win_use_raw_mouse) win_raw_mouse_update((HRAWINPUT)lparam); break; // syskeys - ignore case WM_SYSKEYUP: case WM_SYSKEYDOWN: break; // pause the system when we start a menu or resize case WM_ENTERSIZEMOVE: window->resize_state = RESIZE_STATE_RESIZING; case WM_ENTERMENULOOP: winwindow_ui_pause_from_window_thread(TRUE); break; // unpause the system when we stop a menu or resize and force a redraw case WM_EXITSIZEMOVE: window->resize_state = RESIZE_STATE_PENDING; case WM_EXITMENULOOP: winwindow_ui_pause_from_window_thread(FALSE); InvalidateRect(wnd, NULL, FALSE); break; // get min/max info: set the minimum window size case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lparam; minmax->ptMinTrackSize.x = MIN_WINDOW_DIM; minmax->ptMinTrackSize.y = MIN_WINDOW_DIM; break; } // sizing: constrain to the aspect ratio unless control key is held down case WM_SIZING: { RECT *rect = (RECT *)lparam; if (video_config.keepaspect && !(GetAsyncKeyState(VK_CONTROL) & 0x8000)) constrain_to_aspect_ratio(window, rect, wparam); InvalidateRect(wnd, NULL, FALSE); break; } // syscommands: catch win_start_maximized case WM_SYSCOMMAND: { // prevent screensaver or monitor power events if (wparam == SC_MONITORPOWER || wparam == SC_SCREENSAVE) return 1; // most SYSCOMMANDs require us to invalidate the window InvalidateRect(wnd, NULL, FALSE); // handle maximize if ((wparam & 0xfff0) == SC_MAXIMIZE) { update_minmax_state(window); if (window->ismaximized) minimize_window(window); else maximize_window(window); break; } return DefWindowProc(wnd, message, wparam, lparam); } // track whether we are in the foreground case WM_ACTIVATEAPP: in_background = !wparam; break; // close: cause MAME to exit case WM_CLOSE: if (multithreading_enabled) PostThreadMessage(main_threadid, WM_USER_REQUEST_EXIT, 0, 0); else mame_schedule_exit(Machine); break; // destroy: clean up all attached rendering bits and NULL out our hwnd case WM_DESTROY: (*draw.window_destroy)(window); window->hwnd = NULL; return DefWindowProc(wnd, message, wparam, lparam); // self redraw: draw ourself in a non-painty way case WM_USER_REDRAW: { HDC hdc = GetDC(wnd); mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW begin"); window->primlist = (const render_primitive_list *)lparam; draw_video_contents(window, hdc, FALSE); mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW end"); ReleaseDC(wnd, hdc); break; } // self destruct case WM_USER_SELF_TERMINATE: DestroyWindow(window->hwnd); break; // fullscreen set case WM_USER_SET_FULLSCREEN: set_fullscreen(window, wparam); break; // minimum size set case WM_USER_SET_MINSIZE: minimize_window(window); break; // maximum size set case WM_USER_SET_MAXSIZE: maximize_window(window); break; // set focus: if we're not the primary window, switch back // commented out ATM because this prevents us from resizing secondary windows // case WM_SETFOCUS: // if (window != win_window_list && win_window_list != NULL) // SetFocus(win_window_list->hwnd); // break; // everything else: defaults default: return DefWindowProc(wnd, message, wparam, lparam); } return 0; }
int osd_update(mame_time emutime) { int i; double time_limit; double current_time; int cpunum; render_target_get_primitives(target); /* is this the first update? if so, eat it */ if (!seen_first_update) { seen_first_update = TRUE; goto done; } /* if we have already aborted or completed, our work is done */ if ((state == STATE_ABORTED) || (state == STATE_DONE)) { mame_schedule_exit(Machine); goto done; } /* have we hit the time limit? */ current_time = timer_get_time(); time_limit = (current_testcase.time_limit != 0.0) ? current_testcase.time_limit : TIME_IN_SEC(600); if (current_time > time_limit) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Time limit of %.2f seconds exceeded", time_limit); goto done; } /* update the runtime hash */ if (0) { for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++) { runtime_hash *= 57; runtime_hash ^= cpunum_get_reg(cpunum, REG_PC); /* TODO - Add more registers? */ } } for (i = 0; i < sizeof(commands) / sizeof(commands[i]); i++) { if (current_command->command_type == commands[i].command_type) { commands[i].proc(); break; } } /* if we are ready for the next command, advance to it */ if (state == STATE_READY) { /* if we are at the end, and we are dumping screenshots, and we didn't * just dump a screenshot, dump one now */ if ((test_flags & MESSTEST_ALWAYS_DUMP_SCREENSHOT) && (current_command[0].command_type != MESSTEST_COMMAND_SCREENSHOT) && (current_command[1].command_type == MESSTEST_COMMAND_END)) { dump_screenshot(TRUE); } current_command++; } done: return FALSE; }
void on_exit_activate(GtkMenuItem *item, gpointer user_data) { mame_schedule_exit((running_machine *)user_data); }
static void debugmain_destroy(GtkObject *obj, gpointer user_data) { debugmain_i *dmain = (debugmain_i *)user_data; mame_schedule_exit(dmain->machine); }