home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Science
/
Science.zip
/
imdisp79.zip
/
VESA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-15
|
3KB
|
135 lines
/*** IMDISP module VESA.C
VESA contains the device dependent display routines for the
Color Graphics Adapter (CGA), the Enhanced Graphics Adapter (EGA),
the Professional Graphics Adapter (PGA) and the Video Graphics Array
(VGA). The global variables that define the device are allocated
and initialized here.
***/
#define __MSC
/* * * * INCLUDE files * * * */
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
/* * * * Defined Constants * * * */
#define VESA_Support 0x4f
#define VESA_Function_Supported 100
#define VESA_Call_Successful 0
#define VESA_Call_Failed -1
#define VESA_Function_Not_Supported 101
/* * * * External functions * * * */
/* * * * Function declarations * * * */
int VESA_Get_Info(void);
int VESA_Set_Mode(int);
int VESA_Set_Page(unsigned int);
/* * * * Global Variables * * * */
typedef unsigned int Word ;
typedef struct VESA_Block
{
char VESASignature[4];
Word VESAVersion;
char far *OEMStringPtr;
char Capabilities[4];
int far *VideoModePtr;
char filler[238]; /* Pad to 256 */
} VESA_Block ;
static VESA_Block *VESA_Info;
int VESA_Get_Info(void)
{
union REGS inreg, outreg;
struct SREGS segregs;
char error;
char status;
segregs.es = FP_SEG( VESA_Info );
inreg.x.di = FP_OFF( VESA_Info );
inreg.x.ax = 0x4F00;
int86x (0x10, &inreg, &outreg, &segregs);
error = outreg.h.al;
status = outreg.h.ah;
if (error != VESA_Support)
return (VESA_Function_Not_Supported);
else if (status != VESA_Call_Successful)
return (VESA_Call_Failed);
return(VESA_Call_Successful);
}
int VESA_Set_Mode(int mode)
{
int error, status, scratch;
union REGS inreg, outreg;
if (mode == -1)
{
status = VESA_Get_Info();
if (status == VESA_Call_Successful)
{
scratch = 0;
mode = 0;
while (scratch != 0x7fff)
{
scratch = *VESA_Info->VideoModePtr;
if (scratch > mode)
mode = scratch ;
VESA_Info->VideoModePtr++;
}
}
else
{
exit(0);
}
}
inreg.x.ax = 0x4F02; /* SVGA set video mode */
inreg.x.bx = mode;
int86 (0x10, &inreg, &outreg);
if (error != VESA_Support)
return (VESA_Function_Not_Supported);
else if (status != VESA_Call_Successful)
return (VESA_Call_Failed);
return(mode);
}
int VESA_Set_Page( unsigned int page )
{
union REGS inreg, outreg;
char error;
char status;
inreg.x.ax = 0x4F05; /* VESA Video memory window control */
inreg.x.bx = 0x0000; /* select window 0 */
inreg.x.dx = page ; /* set window position */
int86 (0x10, &inreg, &outreg);
error = outreg.h.al;
status = outreg.h.ah;
if (error != VESA_Support)
return (VESA_Function_Not_Supported);
else if (status == VESA_Call_Successful)
return ( page );
else
return (VESA_Call_Failed);
}