Category : C Source Code
Archive   : IMDSRC78.ZIP
Filename : VESA.C

 
Output of file : VESA.C contained in archive : IMDSRC78.ZIP
/*** 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
#include
#include

/* * * * 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);

}




  3 Responses to “Category : C Source Code
Archive   : IMDSRC78.ZIP
Filename : VESA.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/