src/osd/sdl/video.c
| r2152 | r2153 | |
| 814 | 814 | |
| 815 | 815 | static void get_resolution(const char *name, sdl_window_config *config, int report_error) |
| 816 | 816 | { |
| 817 | const char *defdata = options_get_string(mame_options(), SDLOPTION_RESOLUTION("")); |
| 817 | 818 | const char *data = options_get_string(mame_options(), name); |
| 818 | 819 | |
| 819 | 820 | config->width = config->height = config->depth = config->refresh = 0; |
| 820 | 821 | if (strcmp(data, SDLOPTVAL_AUTO) == 0) |
| 821 | 822 | { |
| 822 | | return; |
| 823 | if (strcmp(defdata, SDLOPTVAL_AUTO) == 0) |
| 824 | { |
| 825 | return; |
| 826 | } |
| 827 | |
| 828 | data = defdata; |
| 823 | 829 | } |
| 824 | | else if (sscanf(data, "%dx%dx%d@%d", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error) |
| 830 | |
| 831 | if (sscanf(data, "%dx%dx%d@%d", &config->width, &config->height, &config->depth, &config->refresh) < 2 && report_error) |
| 825 | 832 | mame_printf_error("Illegal resolution value for %s = %s\n", name, data); |
| 826 | 833 | } |
| 827 | 834 | |
src/osd/sdl/window.c
| r2152 | r2153 | |
| 47 | 47 | // PARAMETERS |
| 48 | 48 | //============================================================ |
| 49 | 49 | |
| 50 | // these are arbitrary values since AFAIK there's no way to make X/SDL tell you |
| 51 | #define WINDOW_DECORATION_WIDTH (8) // should be more than plenty |
| 52 | #define WINDOW_DECORATION_HEIGHT (48) // title bar + bottom drag region |
| 53 | |
| 50 | 54 | #if 1 |
| 51 | 55 | #define ASSERT_USE(x) assert_always(SDL_ThreadID() == x, "Wrong Thread") |
| 52 | 56 | //#define ASSERT_USE(x) |
| r2152 | r2153 | |
| 128 | 132 | |
| 129 | 133 | |
| 130 | 134 | static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); |
| 135 | static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); |
| 131 | 136 | |
| 132 | 137 | static void *complete_create_wt(void *param, int threadid); |
| 133 | 138 | static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *view); |
| r2152 | r2153 | |
| 805 | 810 | window->refresh = config->refresh; |
| 806 | 811 | window->monitor = monitor; |
| 807 | 812 | window->fullscreen = !video_config.windowed; |
| 813 | |
| 814 | // set the initial maximized state |
| 815 | window->startmaximized = options_get_bool(mame_options(), SDLOPTION_MAXIMIZE); |
| 816 | |
| 808 | 817 | if (!window->fullscreen) |
| 809 | 818 | { |
| 810 | 819 | window->windowed_width = config->width; |
| r2152 | r2153 | |
| 1166 | 1175 | |
| 1167 | 1176 | static OSDWORK_CALLBACK( complete_create_wt ) |
| 1168 | 1177 | { |
| 1169 | | |
| 1170 | 1178 | worker_param *wp = (worker_param *) param; |
| 1171 | 1179 | sdl_window_info *window = wp->window; |
| 1172 | 1180 | int tempwidth, tempheight; |
| 1173 | | //sdl_info *sdl; |
| 1174 | 1181 | static int result[2] = {0,1}; |
| 1175 | 1182 | |
| 1176 | 1183 | ASSERT_WINDOW_THREAD(); |
| 1177 | 1184 | free(wp); |
| 1178 | 1185 | |
| 1179 | | //sdl = window->dxdata; |
| 1180 | | |
| 1181 | 1186 | if (window->fullscreen) |
| 1182 | 1187 | { |
| 1183 | 1188 | |
| r2152 | r2153 | |
| 1201 | 1206 | { |
| 1202 | 1207 | window->extra_flags = SDL_RESIZABLE; |
| 1203 | 1208 | |
| 1204 | | /* Create the window directly with the correct aspect |
| 1205 | | instead of letting sdlwindow_blit_surface_size() resize it |
| 1206 | | this stops the window from "flashing" from the wrong aspect |
| 1207 | | size to the right one at startup. */ |
| 1208 | | tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640; |
| 1209 | | tempheight = (window->maxheight != 0) ? window->maxheight : 480; |
| 1209 | if (window->startmaximized) |
| 1210 | { |
| 1211 | tempwidth = tempheight = 0; |
| 1212 | get_max_bounds(window, &tempwidth, &tempheight, video_config.keepaspect ); |
| 1213 | } |
| 1214 | else |
| 1215 | { |
| 1216 | /* Create the window directly with the correct aspect |
| 1217 | instead of letting sdlwindow_blit_surface_size() resize it |
| 1218 | this stops the window from "flashing" from the wrong aspect |
| 1219 | size to the right one at startup. */ |
| 1220 | tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640; |
| 1221 | tempheight = (window->maxheight != 0) ? window->maxheight : 480; |
| 1210 | 1222 | |
| 1211 | | get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect ); |
| 1223 | get_min_bounds(window, &tempwidth, &tempheight, video_config.keepaspect ); |
| 1224 | } |
| 1212 | 1225 | } |
| 1213 | 1226 | |
| 1214 | 1227 | #ifndef NO_OPENGL |
| r2152 | r2153 | |
| 1519 | 1532 | *window_width = minwidth; |
| 1520 | 1533 | *window_height = minheight; |
| 1521 | 1534 | } |
| 1535 | |
| 1536 | //============================================================ |
| 1537 | // get_max_bounds |
| 1538 | // (window thread) |
| 1539 | //============================================================ |
| 1540 | |
| 1541 | static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain) |
| 1542 | { |
| 1543 | INT32 maxwidth, maxheight; |
| 1544 | |
| 1545 | assert(GetCurrentThreadId() == window_threadid); |
| 1546 | |
| 1547 | // compute the maximum client area |
| 1548 | maxwidth = window->monitor->center_width; |
| 1549 | maxheight = window->monitor->center_height; |
| 1550 | |
| 1551 | // clamp to the window's max |
| 1552 | if (window->maxwidth != 0) |
| 1553 | { |
| 1554 | int temp = window->maxwidth + WINDOW_DECORATION_WIDTH; |
| 1555 | if (temp < maxwidth) |
| 1556 | maxwidth = temp; |
| 1557 | } |
| 1558 | if (window->maxheight != 0) |
| 1559 | { |
| 1560 | int temp = window->maxheight + WINDOW_DECORATION_HEIGHT; |
| 1561 | if (temp < maxheight) |
| 1562 | maxheight = temp; |
| 1563 | } |
| 1564 | |
| 1565 | // constrain to fit |
| 1566 | if (constrain) |
| 1567 | constrain_to_aspect_ratio(window, &maxwidth, &maxheight, WMSZ_BOTTOMRIGHT); |
| 1568 | else |
| 1569 | { |
| 1570 | maxwidth -= WINDOW_DECORATION_WIDTH; |
| 1571 | maxheight -= WINDOW_DECORATION_HEIGHT; |
| 1572 | *window_width = maxwidth; |
| 1573 | *window_height = maxheight; |
| 1574 | } |
| 1575 | } |
| 1576 | |
src/osd/sdl/sdlmain.c
| r2152 | r2153 | |
| 100 | 100 | { SDLOPTION_VIDEO, SDLOPTVAL_SOFT, 0, "video output method: soft or opengl" }, |
| 101 | 101 | { SDLOPTION_NUMSCREENS, "1", 0, "number of screens to create; SDLMAME only supports 1 at this time" }, |
| 102 | 102 | { SDLOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, |
| 103 | { SDLOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, |
| 103 | 104 | { SDLOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, |
| 104 | 105 | { SDLOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, |
| 105 | 106 | { SDLOPTION_EFFECT, SDLOPTVAL_NONE, 0, "name of a PNG file to use for visual effects, or 'none'" }, |