Category : Files from Magazines
Archive   : PCTJ8707.ZIP
Filename : USE_EGA.C

 
Output of file : USE_EGA.C contained in archive : PCTJ8707.ZIP
/*
* use_ega -- Attempt to switch to an EGA graphics mode. Return
* to the default display and mode upon exit.
*/

#include
#include

/* --- video modes --- */
/* CGA modes */
#define CGA_M40 0
#define CGA_C40 1
#define CGA_M80 2
#define CGA_C80 3
#define CGA_CMRES 4
#define CGA_MMRES 5
#define CGA_MHRES 6
/* MDA mode */
#define MDA_M80 7
/* PCjr modes */
#define PCJR_CLRES 8
#define PCJR_CMRES 9
#define PCJR_CHRES 10
/* modes 11 and 12 are not currently used */
/* EGA modes */
#define EGA_CMRES 13
#define EGA_CHRES 14
#define EGA_MHRES 15
#define EGA_EHRES 16

/* current video state/mode information (declared in getstate) */
extern short Vmode;
extern short Vwidth;
extern short Vpage;

main()
{
int egaflag, oldmode;
int ega_mem, ega_mode;
unsigned int features, switches;
static int memtab[] = {
64, 128, 192, 256
};

extern int getstate();
extern int ega_info(int *, int *, unsigned *, unsigned *);
extern int setvmode(int);
extern void to_color();
extern void to_mono();

egaflag = 0;

/* get video state data */
getstate();
oldmode = Vmode;

/* look for an EGA */
if (ega_info(&ega_mem, &ega_mode, &features, &switches))
++egaflag;

/*
* if EGA found, switch video mode, display something, and
* then return to the display mode found upon entry
*/
if (egaflag) {
if (oldmode == MDA_M80)
to_color();
setvmode(EGA_CMRES);
printf("\nTESTING EGA IN GRAPHICS MODE\n");
getstate();
printf("Current video state:\n\tmode=%d width=%d page=%d\n",
Vmode, Vwidth, Vpage);
printf("\nPress ENTER to return to DOS:");
/* pause */
while (getchar() != '\n')
;
if (oldmode == MDA_M80)
to_mono();
setvmode(oldmode);
getstate();
printf("Current video state:\n\tmode=%d width=%d page=%d\n",
Vmode, Vwidth, Vpage);
}
else {
/* write to the default display */
puts("No EGA adapter installed");
exit(1);
}

exit(0);
}


  3 Responses to “Category : Files from Magazines
Archive   : PCTJ8707.ZIP
Filename : USE_EGA.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/