  void set_video(void)
  {
  	u16 mode = boot_params.hdr.vid_mode;
-@@ -322,6 +356,9 @@ void set_video(void)
+@@ -322,6 +355,9 @@ void set_video(void)
  	save_screen();
  	probe_cards(0);
  

+				continue; /* Hidden mode */
+
+			unsigned long pixels = mi->x * mi->y;
+			if (max_pixels < pixels) {
+				mode = mode_id;
+				max_pixels = pixels;
+				max_depth = mi->depth;
+			} else if ((max_pixels == pixels) && (max_depth < mi->depth)) {
+				mode = mode_id;
+				max_pixels = pixels;
+				max_depth = mi->depth;
+			}
+		}
+	}

+
+	for (card = video_cards; card < video_cards_end; card++) {
+		mi = card->modes;
+		for (i = 0; i < card->nmodes; i++, mi++) {
+			int visible = mi->x && mi->y;
+			u16 mode_id = mi->mode ? mi->mode :
+					(mi->y << 8)+mi->x;
