scummvm random work
[patches.git] / sdl-check-reversed.patch
CommitLineData
5e993f12 1Index: src/video/fbcon/SDL_fbvideo.c
2===================================================================
3--- src/video/fbcon/SDL_fbvideo.c (revision 2761)
4+++ src/video/fbcon/SDL_fbvideo.c (working copy)
5@@ -412,7 +412,7 @@ FB_CheckMode(_THIS, struct fb_var_screen
6
7 static int
8 FB_AddMode(_THIS, int index, unsigned int w, unsigned int h,
9- int check_timings)
10+ int check_timings, int reversed)
11 {
12 SDL_Rect *mode;
13 int i;
14@@ -435,10 +435,12 @@ FB_AddMode(_THIS, int index, unsigned in
15 if (check_timings) {
16 int found_timing = 0;
17 for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
18- if ((w == vesa_timings[i].xres) &&
19- (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) {
20- found_timing = 1;
21- break;
22+ if (vesa_timings[i].pixclock) {
23+ if (!reversed && w == vesa_timings[i].xres && h == vesa_timings[i].yres ||
24+ reversed && h == vesa_timings[i].xres && w == vesa_timings[i].yres) {
25+ found_timing = 1;
26+ break;
27+ }
28 }
29 }
30 if (!found_timing) {
31@@ -653,24 +655,33 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
32 SDL_modelist[i] = NULL;
33 }
34 if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) {
35- FB_AddMode(this, current_index, current_w, current_h, 0);
36+ FB_AddMode(this, current_index, current_w, current_h, 0, 0);
37 } else if (modesdb) {
38 while (read_fbmodes_mode(modesdb, &vinfo)) {
39 for (i = 0; i < NUM_MODELISTS; ++i) {
40 unsigned int w, h;
41+ int reversed = 0;
42
43 /* See if we are querying for the current mode */
44 w = vinfo.xres;
45 h = vinfo.yres;
46+try_reversed_dynamic:
47 if (i == current_index) {
48 if ((current_w > w) || (current_h > h)) {
49 /* Only check once */
50- FB_AddMode(this, i, current_w, current_h, 0);
51+ FB_AddMode(this, i, current_w, current_h, 0, reversed);
52 current_index = -1;
53 }
54 }
55 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
56- FB_AddMode(this, i, w, h, 0);
57+ FB_AddMode(this, i, w, h, 0, reversed);
58+ }
59+
60+ /* See if a reversed X/Y matches */
61+ if (!reversed) {
62+ unsigned tmp = w; w = h; h = tmp;
63+ reversed = 1;
64+ goto try_reversed_dynamic;
65 }
66 }
67 }
68@@ -680,19 +691,28 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
69 for (i = 0; i < NUM_MODELISTS; ++i) {
70 for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) {
71 unsigned int w, h;
72+ int reversed = 0;
73
74 /* See if we are querying for the current mode */
75 w = checkres[j].w;
76 h = checkres[j].h;
77+try_reversed_static:
78 if (i == current_index) {
79 if ((current_w > w) || (current_h > h)) {
80 /* Only check once */
81- FB_AddMode(this, i, current_w, current_h, 0);
82+ FB_AddMode(this, i, current_w, current_h, 0, reversed);
83 current_index = -1;
84 }
85 }
86 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
87- FB_AddMode(this, i, w, h, 1);
88+ FB_AddMode(this, i, w, h, 1, reversed);
89+ }
90+
91+ /* See if a reversed X/Y matches */
92+ if (!reversed) {
93+ unsigned tmp = w; w = h; h = tmp;
94+ reversed = 1;
95+ goto try_reversed_static;
96 }
97 }
98 }