delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/04/05:18:13

Message-Id: <3.0.6.32.19990204051602.008e4920@pop.netaddress.com>
X-Sender: pderbysh AT pop DOT netaddress DOT com
X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32)
Date: Thu, 04 Feb 1999 05:16:02 -0500
To: djgpp AT delorie DOT com
From: Paul Derbyshire <pderbysh AT usa DOT net>
Subject: Re: Q: Forcing mode CO80
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

At 05:14 PM 2/2/99 -0800, you wrote:
>#include <dpmi.h>
>
>void set_mode(int m)
>{
>  __dpmi_regs r;
>  r.h.ah = 0;
>  r.h.al = m;
>  __dpmi_int(0x10, &r);
>}
>
>int get_mode(void)
>{
>  __dpmi_regs r;
>  r.h.ah = 0x0f;
>  __dpmi_int(0x10, &r);
>  return r.h.al;
>}

Thanks again. I tested the code and it works perfectly. I wrote a test
applet that got the current mode, set mode 13h, then restored the original
mode, reporting info on each step and waiting for a keypress at each step.

One question. How does one tell if the mode could not be set? the set_mode
you supplied doesn't appear to do any specific error checking, and it
doesn't return anything. I'd like to know how to modify the set_mode to
detect an error, which presumably would mean the mode requested isn't
available on the hardware.

Your set_mode passes the ADDRESS of a struct to __dpmi_int(), so I'd guess
that something in the struct is changed to reflect the error/success status
of the function. So checking some property of r should be done, I'd guess.
Or possibly checking the return code of __dpmi_int(), which is specified as
returning an int.

-- 
   .*.  "Clouds are not spheres, mountains are not cones, coastlines are not
-()  <  circles, and bark is not smooth, nor does lightning travel in a
   `*'  straight line."    -------------------------------------------------
        -- B. Mandelbrot  |http://surf.to/pgd.net
_____________________ ____|________     Paul Derbyshire     pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|

- Raw text -


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