From 74e8e6a16d7ebd830133a1f18f28e16a57322e85 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Thu, 4 Nov 2021 20:53:06 +0900 Subject: [PATCH] boot: retain last mode when toggle to text mode --- boot/platform.c | 18 +++++++++++------- boot/video.c | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/boot/platform.c b/boot/platform.c index 5479aa74..669c2d13 100644 --- a/boot/platform.c +++ b/boot/platform.c @@ -77,6 +77,14 @@ int bios_text_mode(void) { text_reset(); } +int last_video_mode = -1; +void bios_set_video(int mode) { + last_video_mode = mode; + do_bios_call(2, mode); + do_bios_call(3, mode | 0x4000); + init_graphics(); +} + int bios_video_mode(void) { int best_match = 0; int match_score = 0; @@ -107,25 +115,21 @@ int bios_video_mode(void) { MATCH(1920,1080,6); MATCH(1440,900,7); } - - //print_int_(vbe_info_width); print_("x"); print_int_(vbe_info_height); print_("x"); print_int_(vbe_info_bpp); print_("bpp\n"); } if (best_match) { - do_bios_call(2, best_match); - do_bios_call(3, best_match | 0x4000); + bios_set_video(best_match); } else { vbe_info_width = 0; } - init_graphics(); } void bios_toggle_mode(void) { if (in_graphics_mode) { bios_text_mode(); - } else { - bios_video_mode(); + } else if (last_video_mode != -1) { + bios_set_video(last_video_mode); } } diff --git a/boot/video.c b/boot/video.c index 1ee1af63..accd810a 100644 --- a/boot/video.c +++ b/boot/video.c @@ -226,8 +226,8 @@ int platform_list_modes(int sel, int select_this_mode) { } if (select_this_mode && sel == index) { - do_bios_call(3, *x | 0x4000); - init_graphics(); + extern void bios_set_video(int); + bios_set_video(*x); return 1; }