Mail Archives: djgpp/1999/02/05/00:40:14
Paul Derbyshire wrote:
>
> 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.
That would only apply if the interrupt itself went awry, which shouldn't
ever happen. Actually, I'm not sure how you detect if the mode set
failed-- RBIL doesn't seem to say. Perhaps the carry flag will be set
(bit 0 of EFLAGS)-- that seems to be a standard way to indicate errors.
Try something impossible like 0xff and see what happens.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -