aboutsummaryrefslogtreecommitdiffstats
path: root/com32/mboot/initvesa.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-11-13 21:03:12 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-11-13 21:03:12 -0800
commit0a6dda6bb64472e0027cb6b93ed43ba37c8c84af (patch)
tree63b508ad1f2cca53f7c27fe0487f424069daa39b /com32/mboot/initvesa.c
parent7b04ddff50bc4903d50ed570daf01422ebfaa6ed (diff)
downloadsyslinux-0a6dda6bb64472e0027cb6b93ed43ba37c8c84af.tar.gz
syslinux-0a6dda6bb64472e0027cb6b93ed43ba37c8c84af.tar.xz
syslinux-0a6dda6bb64472e0027cb6b93ed43ba37c8c84af.zip
mboot.c32: fix the video mode selection algorithm
Make the video mode selection algorithm do what was intended... Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/mboot/initvesa.c')
-rw-r--r--com32/mboot/initvesa.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/com32/mboot/initvesa.c b/com32/mboot/initvesa.c
index 5452648d..cf2707df 100644
--- a/com32/mboot/initvesa.c
+++ b/com32/mboot/initvesa.c
@@ -129,7 +129,6 @@ void set_graphics_mode(const struct multiboot_header *mbh,
/* Must either be a packed-pixel mode or a direct color mode
(depending on VESA version ); must be a supported pixel format */
- pxf = 0; /* Not usable */
if (mi->bpp == 32 &&
(mi->memory_layout == 4 ||
@@ -151,17 +150,25 @@ void set_graphics_mode(const struct multiboot_header *mbh,
(mi->memory_layout == 6 && mi->rpos == 10 && mi->gpos == 5 &&
mi->bpos == 0)))
pxf = 15;
+ else
+ continue;
better = false;
-
err = abs(mi->h_res - wantx) + abs(mi->v_res - wanty);
+#define IS_GOOD(mi, bestx, besty) \
+ ((mi)->h_res >= (bestx) && (mi)->v_res >= (besty))
+
if (!bestpxf)
better = true;
- else if ((vesa_info.mi.h_res < wantx || vesa_info.mi.v_res < wantx) &&
- mi->h_res >= wantx && mi->v_res >= wanty)
+ else if (!IS_GOOD(&vesa_info.mi, wantx, wanty) &&
+ IS_GOOD(mi, wantx, wanty))
/* This matches criteria, which the previous one didn't */
better = true;
+ else if (IS_GOOD(&vesa_info.mi, wantx, wanty) &&
+ !IS_GOOD(mi, wantx, wanty))
+ /* This doesn't match criteria, and the previous one did */
+ better = false;
else if (err < besterr)
better = true;
else if (err == besterr && (pxf == (int)mbh->depth || pxf > bestpxf))