src/osd/windows/debugwin.c
| r2354 | r2355 | |
| 220 | 220 | //static void generic_create_window(int type); |
| 221 | 221 | static void generic_recompute_children(debugwin_info *info); |
| 222 | 222 | |
| 223 | | static void memory_create_window(void); |
| 223 | static void memory_create_window(running_machine *machine); |
| 224 | 224 | static void memory_recompute_children(debugwin_info *info); |
| 225 | 225 | static void memory_process_string(debugwin_info *info, const char *string); |
| 226 | 226 | static void memory_update_menu(debugwin_info *info); |
| r2354 | r2355 | |
| 235 | 235 | static int disasm_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam); |
| 236 | 236 | static void disasm_update_caption(HWND wnd); |
| 237 | 237 | |
| 238 | | static void console_create_window(void); |
| 238 | static void console_create_window(running_machine *machine); |
| 239 | 239 | static void console_recompute_children(debugwin_info *info); |
| 240 | 240 | static void console_process_string(debugwin_info *info, const char *string); |
| 241 | | static void console_set_cpunum(int cpunum); |
| 241 | static void console_set_cpunum(running_machine *machine, int cpunum); |
| 242 | 242 | |
| 243 | 243 | static HMENU create_standard_menubar(void); |
| 244 | 244 | static int global_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lparam); |
| r2354 | r2355 | |
| 259 | 259 | |
| 260 | 260 | // create a console window |
| 261 | 261 | if (main_console == NULL) |
| 262 | | console_create_window(); |
| 262 | console_create_window(Machine); |
| 263 | 263 | |
| 264 | 264 | // update the views in the console to reflect the current CPU |
| 265 | 265 | if (main_console != NULL) |
| 266 | | console_set_cpunum(cpu_getactivecpu()); |
| 266 | console_set_cpunum(Machine, cpu_getactivecpu()); |
| 267 | 267 | |
| 268 | 268 | // make sure the debug windows are visible |
| 269 | 269 | waiting_for_debugger = TRUE; |
| 270 | 270 | smart_show_all(TRUE); |
| 271 | 271 | |
| 272 | 272 | // run input polling to ensure that our status is in sync |
| 273 | | wininput_poll(); |
| 273 | wininput_poll(Machine); |
| 274 | 274 | |
| 275 | 275 | // get and process messages |
| 276 | 276 | GetMessage(&message, NULL, 0, 0); |
| r2354 | r2355 | |
| 289 | 289 | |
| 290 | 290 | // process everything else |
| 291 | 291 | default: |
| 292 | | winwindow_dispatch_message(&message); |
| 292 | winwindow_dispatch_message(Machine, &message); |
| 293 | 293 | break; |
| 294 | 294 | } |
| 295 | 295 | |
| r2354 | r2355 | |
| 1673 | 1673 | // log_create_window |
| 1674 | 1674 | //============================================================ |
| 1675 | 1675 | |
| 1676 | | static void log_create_window(void) |
| 1676 | static void log_create_window(running_machine *machine) |
| 1677 | 1677 | { |
| 1678 | 1678 | debugwin_info *info; |
| 1679 | 1679 | char title[256]; |
| r2354 | r2355 | |
| 1681 | 1681 | RECT bounds; |
| 1682 | 1682 | |
| 1683 | 1683 | // create the window |
| 1684 | | _snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 1684 | _snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", machine->gamedrv->description, machine->gamedrv->name); |
| 1685 | 1685 | info = debug_window_create(title, NULL); |
| 1686 | 1686 | if (info == NULL || !debug_view_create(info, 0, DVT_LOG)) |
| 1687 | 1687 | return; |
| r2354 | r2355 | |
| 1718 | 1718 | // memory_determine_combo_items |
| 1719 | 1719 | //============================================================ |
| 1720 | 1720 | |
| 1721 | | static void memory_determine_combo_items(void) |
| 1721 | static void memory_determine_combo_items(running_machine *machine) |
| 1722 | 1722 | { |
| 1723 | 1723 | memorycombo_item **tail = &memorycombo; |
| 1724 | 1724 | UINT32 cpunum, spacenum; |
| r2354 | r2355 | |
| 1755 | 1755 | { |
| 1756 | 1756 | TCHAR* t_memory_region_name; |
| 1757 | 1757 | UINT8 *base = memory_region(rgnnum); |
| 1758 | | UINT32 type = memory_region_type(Machine, rgnnum); |
| 1758 | UINT32 type = memory_region_type(machine, rgnnum); |
| 1759 | 1759 | if (base != NULL && type > REGION_INVALID && (type - REGION_INVALID) < ARRAY_LENGTH(memory_region_names)) |
| 1760 | 1760 | { |
| 1761 | 1761 | memorycombo_item *ci = malloc_or_die(sizeof(*ci)); |
| 1762 | | UINT32 flags = memory_region_flags(Machine, rgnnum); |
| 1762 | UINT32 flags = memory_region_flags(machine, rgnnum); |
| 1763 | 1763 | UINT8 width, little_endian; |
| 1764 | 1764 | memset(ci, 0, sizeof(*ci)); |
| 1765 | 1765 | ci->base = base; |
| r2354 | r2355 | |
| 1841 | 1841 | // memory_create_window |
| 1842 | 1842 | //============================================================ |
| 1843 | 1843 | |
| 1844 | | static void memory_create_window(void) |
| 1844 | static void memory_create_window(running_machine *machine) |
| 1845 | 1845 | { |
| 1846 | 1846 | int curcpu = cpu_getactivecpu(), cursel = 0; |
| 1847 | 1847 | memorycombo_item *ci, *selci = NULL; |
| r2354 | r2355 | |
| 1900 | 1900 | |
| 1901 | 1901 | // populate the combobox |
| 1902 | 1902 | if (memorycombo == NULL) |
| 1903 | | memory_determine_combo_items(); |
| 1903 | memory_determine_combo_items(machine); |
| 1904 | 1904 | for (ci = memorycombo; ci; ci = ci->next) |
| 1905 | 1905 | { |
| 1906 | 1906 | int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)ci->name); |
| r2354 | r2355 | |
| 2547 | 2547 | // console_create_window |
| 2548 | 2548 | //============================================================ |
| 2549 | 2549 | |
| 2550 | | void console_create_window(void) |
| 2550 | void console_create_window(running_machine *machine) |
| 2551 | 2551 | { |
| 2552 | 2552 | debugwin_info *info; |
| 2553 | 2553 | int bestwidth, bestheight; |
| r2354 | r2355 | |
| 2560 | 2560 | if (info == NULL) |
| 2561 | 2561 | return; |
| 2562 | 2562 | main_console = info; |
| 2563 | | console_set_cpunum(0); |
| 2563 | console_set_cpunum(machine, 0); |
| 2564 | 2564 | |
| 2565 | 2565 | // create the views |
| 2566 | 2566 | if (!debug_view_create(info, 0, DVT_DISASSEMBLY)) |
| r2354 | r2355 | |
| 2610 | 2610 | info->minwidth = 0; |
| 2611 | 2611 | info->maxwidth = 0; |
| 2612 | 2612 | for (cpunum = MAX_CPU - 1; (INT32)cpunum >= 0; cpunum--) |
| 2613 | | if (Machine->config->cpu[cpunum].type != CPU_DUMMY) |
| 2613 | if (machine->config->cpu[cpunum].type != CPU_DUMMY) |
| 2614 | 2614 | { |
| 2615 | 2615 | UINT32 regchars, dischars, conchars; |
| 2616 | 2616 | UINT32 minwidth, maxwidth; |
| r2354 | r2355 | |
| 2749 | 2749 | // console_set_cpunum |
| 2750 | 2750 | //============================================================ |
| 2751 | 2751 | |
| 2752 | | static void console_set_cpunum(int cpunum) |
| 2752 | static void console_set_cpunum(running_machine *machine, int cpunum) |
| 2753 | 2753 | { |
| 2754 | 2754 | char title[256], curtitle[256]; |
| 2755 | 2755 | |
| r2354 | r2355 | |
| 2760 | 2760 | debug_view_set_property_UINT32(main_console->view[1].view, DVP_REGS_CPUNUM, cpunum); |
| 2761 | 2761 | |
| 2762 | 2762 | // then update the caption |
| 2763 | | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", Machine->gamedrv->name, cpu_getactivecpu(), activecpu_name()); |
| 2763 | snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", machine->gamedrv->name, cpu_getactivecpu(), activecpu_name()); |
| 2764 | 2764 | win_get_window_text_utf8(main_console->wnd, curtitle, ARRAY_LENGTH(curtitle)); |
| 2765 | 2765 | if (strcmp(title, curtitle)) |
| 2766 | 2766 | win_set_window_text_utf8(main_console->wnd, title); |
| r2354 | r2355 | |
| 2822 | 2822 | switch (LOWORD(wparam)) |
| 2823 | 2823 | { |
| 2824 | 2824 | case ID_NEW_MEMORY_WND: |
| 2825 | | memory_create_window(); |
| 2825 | memory_create_window(Machine); |
| 2826 | 2826 | return 1; |
| 2827 | 2827 | |
| 2828 | 2828 | case ID_NEW_DISASM_WND: |
| r2354 | r2355 | |
| 2830 | 2830 | return 1; |
| 2831 | 2831 | |
| 2832 | 2832 | case ID_NEW_LOG_WND: |
| 2833 | | log_create_window(); |
| 2833 | log_create_window(Machine); |
| 2834 | 2834 | return 1; |
| 2835 | 2835 | |
| 2836 | 2836 | case ID_RUN_AND_HIDE: |
src/osd/windows/drawdd.c
| r2354 | r2355 | |
| 166 | 166 | static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight); |
| 167 | 167 | |
| 168 | 168 | // video modes |
| 169 | | static int config_adapter_mode(win_window_info *window); |
| 169 | static int config_adapter_mode(running_machine *machine, win_window_info *window); |
| 170 | 170 | static void get_adapter_for_monitor(dd_info *dd, win_monitor_info *monitor); |
| 171 | | static void pick_best_mode(win_window_info *window); |
| 171 | static void pick_best_mode(running_machine *machine, win_window_info *window); |
| 172 | 172 | |
| 173 | 173 | // rendering |
| 174 | 174 | static void drawdd_rgb888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch); |
| r2354 | r2355 | |
| 255 | 255 | window->drawdata = dd; |
| 256 | 256 | |
| 257 | 257 | // configure the adapter for the mode we want |
| 258 | | if (config_adapter_mode(window)) |
| 258 | if (config_adapter_mode(Machine, window)) |
| 259 | 259 | goto error; |
| 260 | 260 | |
| 261 | 261 | // create the ddraw object |
| r2354 | r2355 | |
| 1101 | 1101 | // config_adapter_mode |
| 1102 | 1102 | //============================================================ |
| 1103 | 1103 | |
| 1104 | | static int config_adapter_mode(win_window_info *window) |
| 1104 | static int config_adapter_mode(running_machine *machine, win_window_info *window) |
| 1105 | 1105 | { |
| 1106 | 1106 | DDDEVICEIDENTIFIER2 identifier; |
| 1107 | 1107 | dd_info *dd = window->drawdata; |
| r2354 | r2355 | |
| 1148 | 1148 | |
| 1149 | 1149 | // if we're allowed to switch resolutions, override with something better |
| 1150 | 1150 | if (video_config.switchres) |
| 1151 | | pick_best_mode(window); |
| 1151 | pick_best_mode(machine, window); |
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | // release the DirectDraw object |
| r2354 | r2355 | |
| 1226 | 1226 | |
| 1227 | 1227 | |
| 1228 | 1228 | //============================================================ |
| 1229 | | // pick_best_mode |
| 1229 | // enum_modes_callback |
| 1230 | 1230 | //============================================================ |
| 1231 | 1231 | |
| 1232 | 1232 | static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) |
| r2354 | r2355 | |
| 1286 | 1286 | // pick_best_mode |
| 1287 | 1287 | //============================================================ |
| 1288 | 1288 | |
| 1289 | | static void pick_best_mode(win_window_info *window) |
| 1289 | static void pick_best_mode(running_machine *machine, win_window_info *window) |
| 1290 | 1290 | { |
| 1291 | | const device_config *primary_screen = video_screen_first(Machine->config); |
| 1291 | const device_config *primary_screen = video_screen_first(machine->config); |
| 1292 | 1292 | dd_info *dd = window->drawdata; |
| 1293 | 1293 | mode_enum_info einfo; |
| 1294 | 1294 | HRESULT result; |
src/osd/windows/window.c
| r2354 | r2355 | |
| 129 | 129 | static void draw_video_contents(win_window_info *window, HDC dc, int update); |
| 130 | 130 | |
| 131 | 131 | static unsigned __stdcall thread_entry(void *param); |
| 132 | | static int complete_create(win_window_info *window); |
| 132 | static int complete_create(running_machine *machine, win_window_info *window); |
| 133 | 133 | static void create_window_class(void); |
| 134 | | static void set_starting_view(int index, win_window_info *window, const char *view); |
| 134 | static void set_starting_view(running_machine *machine, int index, win_window_info *window, const char *view); |
| 135 | 135 | |
| 136 | 136 | static void constrain_to_aspect_ratio(win_window_info *window, RECT *rect, int adjustment); |
| 137 | 137 | static void get_min_bounds(win_window_info *window, RECT *bounds, int constrain); |
| r2354 | r2355 | |
| 309 | 309 | // (main thread) |
| 310 | 310 | //============================================================ |
| 311 | 311 | |
| 312 | | void winwindow_process_events_periodic(void) |
| 312 | void winwindow_process_events_periodic(running_machine *machine) |
| 313 | 313 | { |
| 314 | 314 | DWORD currticks = GetTickCount(); |
| 315 | 315 | |
| r2354 | r2355 | |
| 318 | 318 | // update once every 1/8th of a second |
| 319 | 319 | if (currticks - last_event_check < 1000 / 8) |
| 320 | 320 | return; |
| 321 | | winwindow_process_events(TRUE); |
| 321 | winwindow_process_events(machine, TRUE); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | |
| r2354 | r2355 | |
| 345 | 345 | // (main thread) |
| 346 | 346 | //============================================================ |
| 347 | 347 | |
| 348 | | void winwindow_process_events(int ingame) |
| 348 | void winwindow_process_events(running_machine *machine, int ingame) |
| 349 | 349 | { |
| 350 | 350 | MSG message; |
| 351 | 351 | |
| r2354 | r2355 | |
| 432 | 432 | |
| 433 | 433 | // dispatch if necessary |
| 434 | 434 | if (dispatch) |
| 435 | | winwindow_dispatch_message(&message); |
| 435 | winwindow_dispatch_message(machine, &message); |
| 436 | 436 | } |
| 437 | 437 | } while (ui_temp_pause > 0); |
| 438 | 438 | |
| 439 | 439 | // update the cursor state after processing events |
| 440 | | winwindow_update_cursor_state(); |
| 440 | winwindow_update_cursor_state(machine); |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | |
| r2354 | r2355 | |
| 447 | 447 | // (main thread) |
| 448 | 448 | //============================================================ |
| 449 | 449 | |
| 450 | | void winwindow_dispatch_message(MSG *message) |
| 450 | void winwindow_dispatch_message(running_machine *machine, MSG *message) |
| 451 | 451 | { |
| 452 | 452 | assert(GetCurrentThreadId() == main_threadid); |
| 453 | 453 | |
| r2354 | r2355 | |
| 456 | 456 | { |
| 457 | 457 | // special case for quit |
| 458 | 458 | case WM_QUIT: |
| 459 | | mame_schedule_exit(Machine); |
| 459 | mame_schedule_exit(machine); |
| 460 | 460 | break; |
| 461 | 461 | |
| 462 | 462 | // temporary pause from the window thread |
| 463 | 463 | case WM_USER_UI_TEMP_PAUSE: |
| 464 | | winwindow_ui_pause_from_main_thread(message->wParam); |
| 464 | winwindow_ui_pause_from_main_thread(machine, message->wParam); |
| 465 | 465 | break; |
| 466 | 466 | |
| 467 | 467 | // execute arbitrary function |
| r2354 | r2355 | |
| 535 | 535 | // (main thread) |
| 536 | 536 | //============================================================ |
| 537 | 537 | |
| 538 | | void winwindow_update_cursor_state(void) |
| 538 | void winwindow_update_cursor_state(running_machine *machine) |
| 539 | 539 | { |
| 540 | 540 | static POINT saved_cursor_pos = { -1, -1 }; |
| 541 | 541 | |
| r2354 | r2355 | |
| 547 | 547 | // 2. we also hide the cursor in full screen mode and when the window doesn't have a menu |
| 548 | 548 | // 3. we also hide the cursor in windowed mode if we're not paused and |
| 549 | 549 | // the input system requests it |
| 550 | | if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!mame_is_paused(Machine) && wininput_should_hide_mouse()))) |
| 550 | if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!mame_is_paused(machine) && wininput_should_hide_mouse()))) |
| 551 | 551 | { |
| 552 | 552 | win_window_info *window = win_window_list; |
| 553 | 553 | RECT bounds; |
| r2354 | r2355 | |
| 588 | 588 | // (main thread) |
| 589 | 589 | //============================================================ |
| 590 | 590 | |
| 591 | | void winwindow_video_window_create(int index, win_monitor_info *monitor, const win_window_config *config) |
| 591 | void winwindow_video_window_create(running_machine *machine, int index, win_monitor_info *monitor, const win_window_config *config) |
| 592 | 592 | { |
| 593 | 593 | win_window_info *window, *win; |
| 594 | 594 | char option[20]; |
| r2354 | r2355 | |
| 624 | 624 | |
| 625 | 625 | // set the specific view |
| 626 | 626 | sprintf(option, "view%d", index); |
| 627 | | set_starting_view(index, window, options_get_string(mame_options(), option)); |
| 627 | set_starting_view(machine, index, window, options_get_string(mame_options(), option)); |
| 628 | 628 | |
| 629 | 629 | // remember the current values in case they change |
| 630 | 630 | window->targetview = render_target_get_view(window->target); |
| r2354 | r2355 | |
| 633 | 633 | |
| 634 | 634 | // make the window title |
| 635 | 635 | if (video_config.numscreens == 1) |
| 636 | | sprintf(window->title, APPNAME ": %s [%s]", Machine->gamedrv->description, Machine->gamedrv->name); |
| 636 | sprintf(window->title, APPNAME ": %s [%s]", machine->gamedrv->description, machine->gamedrv->name); |
| 637 | 637 | else |
| 638 | | sprintf(window->title, APPNAME ": %s [%s] - Screen %d", Machine->gamedrv->description, Machine->gamedrv->name, index); |
| 638 | sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine->gamedrv->description, machine->gamedrv->name, index); |
| 639 | 639 | |
| 640 | 640 | // set the initial maximized state |
| 641 | 641 | window->startmaximized = options_get_bool(mame_options(), WINOPTION_MAXIMIZE); |
| r2354 | r2355 | |
| 651 | 651 | Sleep(1); |
| 652 | 652 | } |
| 653 | 653 | else |
| 654 | | window->init_state = complete_create(window) ? -1 : 1; |
| 654 | window->init_state = complete_create(machine, window) ? -1 : 1; |
| 655 | 655 | |
| 656 | 656 | // handle error conditions |
| 657 | 657 | if (window->init_state == -1) |
| r2354 | r2355 | |
| 840 | 840 | // (main thread) |
| 841 | 841 | //============================================================ |
| 842 | 842 | |
| 843 | | static void set_starting_view(int index, win_window_info *window, const char *view) |
| 843 | static void set_starting_view(running_machine *machine, int index, win_window_info *window, const char *view) |
| 844 | 844 | { |
| 845 | 845 | const char *defview = options_get_string(mame_options(), WINOPTION_VIEW); |
| 846 | 846 | int viewindex = -1; |
| r2354 | r2355 | |
| 873 | 873 | // if we don't have a match, default to the nth view |
| 874 | 874 | if (viewindex == -1) |
| 875 | 875 | { |
| 876 | | int scrcount = video_screen_count(Machine->config); |
| 876 | int scrcount = video_screen_count(machine->config); |
| 877 | 877 | |
| 878 | 878 | // if we have enough screens to be one per monitor, assign in order |
| 879 | 879 | if (video_config.numscreens >= scrcount) |
| r2354 | r2355 | |
| 921 | 921 | // (main thread) |
| 922 | 922 | //============================================================ |
| 923 | 923 | |
| 924 | | void winwindow_ui_pause_from_main_thread(int pause) |
| 924 | void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause) |
| 925 | 925 | { |
| 926 | 926 | int old_temp_pause = ui_temp_pause; |
| 927 | 927 | |
| r2354 | r2355 | |
| 934 | 934 | if (ui_temp_pause++ == 0) |
| 935 | 935 | { |
| 936 | 936 | // only call mame_pause if we weren't already paused due to some external reason |
| 937 | | ui_temp_was_paused = mame_is_paused(Machine); |
| 937 | ui_temp_was_paused = mame_is_paused(machine); |
| 938 | 938 | if (!ui_temp_was_paused) |
| 939 | | mame_pause(Machine, TRUE); |
| 939 | mame_pause(machine, TRUE); |
| 940 | 940 | |
| 941 | 941 | SetEvent(ui_pause_event); |
| 942 | 942 | } |
| r2354 | r2355 | |
| 950 | 950 | { |
| 951 | 951 | // but only do it if we were the ones who initiated it |
| 952 | 952 | if (!ui_temp_was_paused) |
| 953 | | mame_pause(Machine, FALSE); |
| 953 | mame_pause(machine, FALSE); |
| 954 | 954 | |
| 955 | 955 | ResetEvent(ui_pause_event); |
| 956 | 956 | } |
| r2354 | r2355 | |
| 967 | 967 | // (window thread) |
| 968 | 968 | //============================================================ |
| 969 | 969 | |
| 970 | | void winwindow_ui_pause_from_window_thread(int pause) |
| 970 | void winwindow_ui_pause_from_window_thread(running_machine *machine, int pause) |
| 971 | 971 | { |
| 972 | 972 | assert(GetCurrentThreadId() == window_threadid); |
| 973 | 973 | |
| r2354 | r2355 | |
| 984 | 984 | |
| 985 | 985 | // otherwise, we just do it directly |
| 986 | 986 | else |
| 987 | | winwindow_ui_pause_from_main_thread(pause); |
| 987 | winwindow_ui_pause_from_main_thread(machine, pause); |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | |
| r2354 | r2355 | |
| 1016 | 1016 | // winwindow_ui_is_paused |
| 1017 | 1017 | //============================================================ |
| 1018 | 1018 | |
| 1019 | | int winwindow_ui_is_paused(void) |
| 1019 | int winwindow_ui_is_paused(running_machine *machine) |
| 1020 | 1020 | { |
| 1021 | | return mame_is_paused(Machine) && ui_temp_was_paused; |
| 1021 | return mame_is_paused(machine) && ui_temp_was_paused; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | |
| r2354 | r2355 | |
| 1145 | 1145 | case WM_USER_FINISH_CREATE_WINDOW: |
| 1146 | 1146 | { |
| 1147 | 1147 | win_window_info *window = (win_window_info *)message.lParam; |
| 1148 | | window->init_state = complete_create(window) ? -1 : 1; |
| 1148 | window->init_state = complete_create(Machine, window) ? -1 : 1; |
| 1149 | 1149 | dispatch = FALSE; |
| 1150 | 1150 | break; |
| 1151 | 1151 | } |
| r2354 | r2355 | |
| 1169 | 1169 | // (window thread) |
| 1170 | 1170 | //============================================================ |
| 1171 | 1171 | |
| 1172 | | static int complete_create(win_window_info *window) |
| 1172 | static int complete_create(running_machine *machine, win_window_info *window) |
| 1173 | 1173 | { |
| 1174 | 1174 | RECT monitorbounds, client; |
| 1175 | 1175 | int tempwidth, tempheight; |
| r2354 | r2355 | |
| 1183 | 1183 | |
| 1184 | 1184 | // create the window menu if needed |
| 1185 | 1185 | #if HAS_WINDOW_MENU |
| 1186 | | if (win_create_menu(Machine, &menu)) |
| 1186 | if (win_create_menu(machine, &menu)) |
| 1187 | 1187 | return 1; |
| 1188 | 1188 | #endif |
| 1189 | 1189 | |
| r2354 | r2355 | |
| 1295 | 1295 | case WM_ENTERSIZEMOVE: |
| 1296 | 1296 | window->resize_state = RESIZE_STATE_RESIZING; |
| 1297 | 1297 | case WM_ENTERMENULOOP: |
| 1298 | | winwindow_ui_pause_from_window_thread(TRUE); |
| 1298 | winwindow_ui_pause_from_window_thread(Machine, TRUE); |
| 1299 | 1299 | break; |
| 1300 | 1300 | |
| 1301 | 1301 | // unpause the system when we stop a menu or resize and force a redraw |
| 1302 | 1302 | case WM_EXITSIZEMOVE: |
| 1303 | 1303 | window->resize_state = RESIZE_STATE_PENDING; |
| 1304 | 1304 | case WM_EXITMENULOOP: |
| 1305 | | winwindow_ui_pause_from_window_thread(FALSE); |
| 1305 | winwindow_ui_pause_from_window_thread(Machine, FALSE); |
| 1306 | 1306 | InvalidateRect(wnd, NULL, FALSE); |
| 1307 | 1307 | break; |
| 1308 | 1308 | |
src/osd/windows/window.h
| r2354 | r2355 | |
| 106 | 106 | void winwindow_init(running_machine *machine); |
| 107 | 107 | |
| 108 | 108 | // creation/deletion of windows |
| 109 | | void winwindow_video_window_create(int index, win_monitor_info *monitor, const win_window_config *config); |
| 109 | void winwindow_video_window_create(running_machine *machine, int index, win_monitor_info *monitor, const win_window_config *config); |
| 110 | 110 | |
| 111 | 111 | BOOL winwindow_has_focus(void); |
| 112 | | void winwindow_update_cursor_state(void); |
| 112 | void winwindow_update_cursor_state(running_machine *machine); |
| 113 | 113 | void winwindow_video_window_update(win_window_info *window); |
| 114 | 114 | win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed); |
| 115 | 115 | |
| 116 | 116 | LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); |
| 117 | 117 | void winwindow_toggle_full_screen(void); |
| 118 | 118 | |
| 119 | | void winwindow_process_events_periodic(void); |
| 120 | | void winwindow_process_events(int ingame); |
| 119 | void winwindow_process_events_periodic(running_machine *machine); |
| 120 | void winwindow_process_events(running_machine *machine, int ingame); |
| 121 | 121 | |
| 122 | | void winwindow_ui_pause_from_window_thread(int pause); |
| 123 | | void winwindow_ui_pause_from_main_thread(int pause); |
| 124 | | int winwindow_ui_is_paused(void); |
| 122 | void winwindow_ui_pause_from_window_thread(running_machine *machine, int pause); |
| 123 | void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause); |
| 124 | int winwindow_ui_is_paused(running_machine *machine); |
| 125 | 125 | |
| 126 | 126 | void winwindow_ui_exec_on_main_thread(void (*func)(void *), void *param); |
| 127 | | void winwindow_dispatch_message(MSG *message); |
| 127 | void winwindow_dispatch_message(running_machine *machine, MSG *message); |
| 128 | 128 | |
| 129 | 129 | #if HAS_WINDOW_MENU |
| 130 | 130 | int win_create_menu(running_machine *machine, HMENU *menus); |
src/osd/windows/drawd3d.c
| r2354 | r2355 | |
| 419 | 419 | static int device_test_cooperative(d3d_info *d3d); |
| 420 | 420 | |
| 421 | 421 | // video modes |
| 422 | | static int config_adapter_mode(win_window_info *window); |
| 422 | static int config_adapter_mode(running_machine *machine, win_window_info *window); |
| 423 | 423 | static int get_adapter_for_monitor(d3d_info *d3d, win_monitor_info *monitor); |
| 424 | | static void pick_best_mode(win_window_info *window); |
| 424 | static void pick_best_mode(running_machine *machine, win_window_info *window); |
| 425 | 425 | static int update_window_size(win_window_info *window); |
| 426 | 426 | |
| 427 | 427 | // drawing |
| r2354 | r2355 | |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // configure the adapter for the mode we want |
| 515 | | if (config_adapter_mode(window)) |
| 515 | if (config_adapter_mode(Machine, window)) |
| 516 | 516 | goto error; |
| 517 | 517 | |
| 518 | 518 | // create the device immediately for the full screen case (defer for window mode) |
| r2354 | r2355 | |
| 1120 | 1120 | // config_adapter_mode |
| 1121 | 1121 | //============================================================ |
| 1122 | 1122 | |
| 1123 | | static int config_adapter_mode(win_window_info *window) |
| 1123 | static int config_adapter_mode(running_machine *machine, win_window_info *window) |
| 1124 | 1124 | { |
| 1125 | 1125 | d3d_adapter_identifier identifier; |
| 1126 | 1126 | d3d_info *d3d = window->drawdata; |
| r2354 | r2355 | |
| 1184 | 1184 | |
| 1185 | 1185 | // if we're allowed to switch resolutions, override with something better |
| 1186 | 1186 | if (video_config.switchres) |
| 1187 | | pick_best_mode(window); |
| 1187 | pick_best_mode(machine, window); |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | // see if we can handle the device type |
| r2354 | r2355 | |
| 1236 | 1236 | // pick_best_mode |
| 1237 | 1237 | //============================================================ |
| 1238 | 1238 | |
| 1239 | | static void pick_best_mode(win_window_info *window) |
| 1239 | static void pick_best_mode(running_machine *machine, win_window_info *window) |
| 1240 | 1240 | { |
| 1241 | | const device_config *primary_screen = video_screen_first(Machine->config); |
| 1241 | const device_config *primary_screen = video_screen_first(machine->config); |
| 1242 | 1242 | double target_refresh = 60.0; |
| 1243 | 1243 | INT32 target_width, target_height; |
| 1244 | 1244 | d3d_info *d3d = window->drawdata; |
src/mess/osd/windows/dialog.c
| r2354 | r2355 | |
| 1112 | 1112 | // the Win32 OSD code thinks that we are paused, we need to temporarily |
| 1113 | 1113 | // unpause ourselves or else we will block |
| 1114 | 1114 | pause_count = 0; |
| 1115 | | while(mame_is_paused(Machine) && !winwindow_ui_is_paused()) |
| 1115 | while(mame_is_paused(Machine) && !winwindow_ui_is_paused(Machine)) |
| 1116 | 1116 | { |
| 1117 | | winwindow_ui_pause_from_main_thread(FALSE); |
| 1117 | winwindow_ui_pause_from_main_thread(Machine, FALSE); |
| 1118 | 1118 | pause_count++; |
| 1119 | 1119 | } |
| 1120 | 1120 | |
| r2354 | r2355 | |
| 1142 | 1142 | |
| 1143 | 1143 | // repause the OSD code |
| 1144 | 1144 | while(pause_count--) |
| 1145 | | winwindow_ui_pause_from_main_thread(TRUE); |
| 1145 | winwindow_ui_pause_from_main_thread(Machine, TRUE); |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | |
| r2354 | r2355 | |
| 1655 | 1655 | // before_display_dialog |
| 1656 | 1656 | //============================================================ |
| 1657 | 1657 | |
| 1658 | | static void before_display_dialog(void) |
| 1658 | static void before_display_dialog(running_machine *machine) |
| 1659 | 1659 | { |
| 1660 | 1660 | #ifdef UNDER_CE |
| 1661 | 1661 | // on WinCE, suspend GAPI |
| 1662 | 1662 | gx_suspend(); |
| 1663 | 1663 | #endif |
| 1664 | 1664 | |
| 1665 | | winwindow_ui_pause_from_window_thread(TRUE); |
| 1665 | winwindow_ui_pause_from_window_thread(machine, TRUE); |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | 1668 | |
| r2354 | r2355 | |
| 1671 | 1671 | // after_display_dialog |
| 1672 | 1672 | //============================================================ |
| 1673 | 1673 | |
| 1674 | | static void after_display_dialog(void) |
| 1674 | static void after_display_dialog(running_machine *machine) |
| 1675 | 1675 | { |
| 1676 | 1676 | #ifdef UNDER_CE |
| 1677 | 1677 | // on WinCE, resume GAPI |
| 1678 | 1678 | gx_resume(); |
| 1679 | 1679 | #endif |
| 1680 | 1680 | |
| 1681 | | winwindow_ui_pause_from_window_thread(FALSE); |
| 1681 | winwindow_ui_pause_from_window_thread(machine, FALSE); |
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | 1684 | |
| r2354 | r2355 | |
| 1687 | 1687 | // win_dialog_runmodal |
| 1688 | 1688 | //============================================================ |
| 1689 | 1689 | |
| 1690 | | void win_dialog_runmodal(HWND wnd, dialog_box *dialog) |
| 1690 | void win_dialog_runmodal(running_machine *machine, HWND wnd, dialog_box *dialog) |
| 1691 | 1691 | { |
| 1692 | 1692 | assert(dialog); |
| 1693 | 1693 | |
| r2354 | r2355 | |
| 1695 | 1695 | dialog_prime(dialog); |
| 1696 | 1696 | |
| 1697 | 1697 | // show the dialog |
| 1698 | | before_display_dialog(); |
| 1698 | before_display_dialog(machine); |
| 1699 | 1699 | #ifndef UNICODE |
| 1700 | 1700 | if (GetVersion() & 0x80000000) |
| 1701 | 1701 | DialogBoxIndirectParamA(NULL, dialog->handle, wnd, dialog_proc, (LPARAM) dialog); |
| 1702 | 1702 | else |
| 1703 | 1703 | #endif // UNICODE |
| 1704 | 1704 | DialogBoxIndirectParamW(NULL, dialog->handle, wnd, dialog_proc, (LPARAM) dialog); |
| 1705 | | after_display_dialog(); |
| 1705 | after_display_dialog(machine); |
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | |
| r2354 | r2355 | |
| 1765 | 1765 | // win_file_dialog |
| 1766 | 1766 | //============================================================ |
| 1767 | 1767 | |
| 1768 | | BOOL win_file_dialog(HWND parent, win_file_dialog_type dlgtype, dialog_box *custom_dialog, const char *filter, |
| 1768 | BOOL win_file_dialog(running_machine *machine, |
| 1769 | HWND parent, win_file_dialog_type dlgtype, dialog_box *custom_dialog, const char *filter, |
| 1769 | 1770 | const char *initial_dir, char *filename, size_t filename_len) |
| 1770 | 1771 | { |
| 1771 | 1772 | win_open_file_name ofn; |
| r2354 | r2355 | |
| 1797 | 1798 | |
| 1798 | 1799 | snprintf(ofn.filename, ARRAY_LENGTH(ofn.filename), "%s", filename); |
| 1799 | 1800 | |
| 1800 | | before_display_dialog(); |
| 1801 | before_display_dialog(machine); |
| 1801 | 1802 | result = win_get_file_name_dialog(&ofn); |
| 1802 | | after_display_dialog(); |
| 1803 | after_display_dialog(machine); |
| 1803 | 1804 | |
| 1804 | 1805 | snprintf(filename, filename_len, "%s", ofn.filename); |
| 1805 | 1806 | return result; |
src/mess/osd/windows/menu.c
| r2354 | r2355 | |
| 221 | 221 | goto done; |
| 222 | 222 | |
| 223 | 223 | /* ...and finally display the dialog */ |
| 224 | | win_dialog_runmodal(wnd, dlg); |
| 224 | win_dialog_runmodal(machine, wnd, dlg); |
| 225 | 225 | |
| 226 | 226 | done: |
| 227 | 227 | if (dlg) |
| r2354 | r2355 | |
| 332 | 332 | if (win_dialog_add_standard_buttons(dlg)) |
| 333 | 333 | goto done; |
| 334 | 334 | |
| 335 | | win_dialog_runmodal(wnd, dlg); |
| 335 | win_dialog_runmodal(machine, wnd, dlg); |
| 336 | 336 | |
| 337 | 337 | done: |
| 338 | 338 | if (dlg) |
| r2354 | r2355 | |
| 445 | 445 | if (win_dialog_add_standard_buttons(dlg)) |
| 446 | 446 | goto done; |
| 447 | 447 | |
| 448 | | win_dialog_runmodal(wnd, dlg); |
| 448 | win_dialog_runmodal(machine, wnd, dlg); |
| 449 | 449 | |
| 450 | 450 | done: |
| 451 | 451 | if (dlg) |
| r2354 | r2355 | |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | // display the dialog |
| 873 | | result = win_file_dialog(wnd, is_save ? WIN_FILE_DIALOG_SAVE : WIN_FILE_DIALOG_OPEN, |
| 873 | result = win_file_dialog(img->machine, wnd, is_save ? WIN_FILE_DIALOG_SAVE : WIN_FILE_DIALOG_OPEN, |
| 874 | 874 | dialog, filter, initial_dir, filename, sizeof(filename) / sizeof(filename[0])); |
| 875 | 875 | if (result) |
| 876 | 876 | { |
| r2354 | r2355 | |
| 942 | 942 | |
| 943 | 943 | static void pause(running_machine *machine) |
| 944 | 944 | { |
| 945 | | mame_pause(machine, !winwindow_ui_is_paused()); |
| 945 | mame_pause(machine, !winwindow_ui_is_paused(machine)); |
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | |
| r2354 | r2355 | |
| 1271 | 1271 | |
| 1272 | 1272 | set_command_state(menu_bar, ID_EDIT_PASTE, inputx_can_post() ? MFS_ENABLED : MFS_GRAYED); |
| 1273 | 1273 | |
| 1274 | | set_command_state(menu_bar, ID_OPTIONS_PAUSE, winwindow_ui_is_paused() ? MFS_CHECKED : MFS_ENABLED); |
| 1274 | set_command_state(menu_bar, ID_OPTIONS_PAUSE, winwindow_ui_is_paused(machine) ? MFS_CHECKED : MFS_ENABLED); |
| 1275 | 1275 | set_command_state(menu_bar, ID_OPTIONS_CONFIGURATION, has_config ? MFS_ENABLED : MFS_GRAYED); |
| 1276 | 1276 | set_command_state(menu_bar, ID_OPTIONS_DIPSWITCHES, has_dipswitch ? MFS_ENABLED : MFS_GRAYED); |
| 1277 | 1277 | set_command_state(menu_bar, ID_OPTIONS_MISCINPUT, has_misc ? MFS_ENABLED : MFS_GRAYED); |
| r2354 | r2355 | |
| 1514 | 1514 | |
| 1515 | 1515 | #if USE_TAPEDLG |
| 1516 | 1516 | case DEVOPTION_CASSETTE_DIALOG: |
| 1517 | | tapedialog_show(wnd, id); |
| 1517 | tapedialog_show(wnd, image_index_in_device(img)); |
| 1518 | 1518 | break; |
| 1519 | 1519 | #else |
| 1520 | 1520 | case DEVOPTION_CASSETTE_REWIND: |
| r2354 | r2355 | |
| 1662 | 1662 | |
| 1663 | 1663 | // pause while invoking certain commands |
| 1664 | 1664 | if (pause_for_command(command)) |
| 1665 | | winwindow_ui_pause_from_window_thread(TRUE); |
| 1665 | winwindow_ui_pause_from_window_thread(machine, TRUE); |
| 1666 | 1666 | |
| 1667 | 1667 | switch(command) |
| 1668 | 1668 | { |
| r2354 | r2355 | |
| 1890 | 1890 | |
| 1891 | 1891 | // resume emulation |
| 1892 | 1892 | if (pause_for_command(command)) |
| 1893 | | winwindow_ui_pause_from_window_thread(FALSE); |
| 1893 | winwindow_ui_pause_from_window_thread(machine, FALSE); |
| 1894 | 1894 | |
| 1895 | 1895 | return handled; |
| 1896 | 1896 | } |