www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/04/12:02:33

Message-ID: <F77915E7F086D31197F4009027CC81C917B57F@probe-2.as-london.acclaim.com>
From: Shawn Hargreaves <SHargreaves AT acclaimstudios DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: VESA 1.2, cannot get current video mode!
Date: Tue, 4 Jan 2000 15:12:55 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

sl writes:
> So far all other functions work except this one. Do you happen to
> know how Allegro handles this problem? I tried taking a quick-look 
> at it and haven't been able to find a "get_current_video_mode" 
> function anywhere..

There isn't one: Allegro never tries to read that information. It
does have some rather simplistic code for restoring text modes
at the end of your program (in recent WIP versions, the 
sys_dos_save_console_state() and sys_dos_restore_console_state()
functions in src/dos/dsystem.c), but these only properly handle
VGA text modes, and have been considerably bodged around to avoid
problems (including some crashes!) on various machines. Earlier
versions used to just call 0x10, ax=0x0F00 to read the initial
mode, and then reset it on exit, but this didn't work reliably
for everyone, and I never investigated far enough to find out
exactly why. My guess would be that some BIOS implementations
are just broken in this regard: my experience is that the majority 
of video BIOS code is very sloppy and unreliable.

The VESA spec is somewhat vague about this, but as I interpret it,
it may even be correct behaviour that you not be able to get this
info. The VBE 2.0 spec is quite clear that you can't use the VESA
function 0x4F03 (return current VBE mode) to get info about modes
that were set using standard VGA calls, when it says:

   Note: This function is not guaranteed to return an accurate mode
   value if the mode set was not done with VBE Function 02h.

It is less clear about whether you can use standard VGA BIOS
function 0x0F to get info about modes that _were_ set by a VESA
call, but it does sort of imply not (albeit in the middle of 
talking about something entirely different):

  Version 2.x Note: Unlike version 1.x VBE implementations, the 
  memory clear flag will be returned. The application should NOT
  call the standard VGA BIOS Function 0Fh if the mode was set
  with VBE Function 02h.

I find that ambiguous as to whether you shouldn't call 0F at all,
or just not to read the memory clear flag, but it does seem very
probable that BIOS implementors will also have found this confusing,
and may have done all sorts of strange things. So I'm willing to bet
that at least on some systems, VESA calls can't return info about
VGA modes, and VGA calls can't return info about VESA modes. Since
there is no way to find out whether the current mode was set using
VGA or VESA calls (or indeed some other method entirely, such as
VBE/AF or direct register modification), I suspect that you are
pretty much out of luck here. Either redesign your program to avoid
needing this information, or do what Allegro does and try using
the BIOS calls, but hedge them about with failsafes and checks so
that you can give up gracefully if the BIOS tells you something 
bogus.

> Does the author of Allegro read these messages?

Intermittently. You can find me more regularly on the Allegro mailing
lists.


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019