Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI716.ASC

 
Output of file : TI716.ASC contained in archive : C-ALL.ZIP







PRODUCT : Borland C++ NUMBER : 716
VERSION : 2.0
OS : DOS
DATE : September 18, 1991 PAGE : 1/4

TITLE : Switching Between 25 and 43 Line Mode on EGA




/*************************************************************
This program shows how to switch between 25 and 43 line mode
on an EGA.
*************************************************************/

#include
#include
#include
#include

#define OFF 0
#define ON 1
#define NOCHANGE 2

#define TRUE 1
#define FALSE 0

void normvideo(void);
int in43linemode(void);
void ega43(int mode);
int egainstalled(void);
void setcursor(unsigned char start, unsigned char end);
int egacursoremu(int mode);
int egacursorsize(void);
extern unsigned char _video[];
void main(int argc, char *argv[])
{
int toggle = NOCHANGE, i;
_video[3] = 42;
_video[7] = 43;
if (!egainstalled()) {
fprintf(stderr, "EGA not installed.\n");
exit(1);
}

if (argc >= 2)
switch(argv[1][0]) {
case '?': toggle = NOCHANGE;
printf("usage: EGA43 [1][0]\n"
"1 = 43-line mode; "
"0 = 25-line mode; "
"no argument = toggle mode\n"
);













PRODUCT : Borland C++ NUMBER : 716
VERSION : 2.0
OS : DOS
DATE : September 18, 1991 PAGE : 2/4

TITLE : Switching Between 25 and 43 Line Mode on EGA




printf("43-line mode: %s\n",
in43linemode() ? "ON": "OFF");
printf("Cursor size : %d\n",
egacursorsize());
break;
case '0': toggle = OFF;
break;
case '1': toggle = ON;
break;
default : toggle = NOCHANGE;
}



if (argc == 1)
switch(in43linemode()) {
case TRUE: toggle = OFF; /*if already on, turn off*/
break;
case FALSE: toggle = ON; /* if already off, turn on*/
break;
}

if (toggle != NOCHANGE) normvideo();

if (toggle == ON) ega43(ON);
if (toggle == OFF) ega43(OFF);
for (i=0;i<43;i++) cprintf("%d\r\n",i);
getch();
}


void normvideo(void)
{
union REGS regs;

regs.h.ah = 0;
regs.h.al = 3;
int86(0x10, ®s, ®s);

}

void ega43(int mode)
{













PRODUCT : Borland C++ NUMBER : 716
VERSION : 2.0
OS : DOS
DATE : September 18, 1991 PAGE : 3/4

TITLE : Switching Between 25 and 43 Line Mode on EGA




union REGS regs;

if (mode == OFF)
regs.h.al = 0x11;
else
regs.h.al = 0x12;

regs.h.ah = 0x11;
regs.h.bl = 0;

int86(0x10, ®s, ®s);

egacursoremu(mode);
}

int egainstalled(void)
{
union REGS regs;

regs.x.ax = 0x1200;
regs.x.bx = 0x0010;
regs.x.cx = 0xFFFF;

int86(0x10, ®s, ®s);

if (regs.x.cx == 0xFFFF)
return(FALSE);
else
return(TRUE);
}

void setcursor(unsigned char start, unsigned char end)
{
union REGS regs;

regs.h.ah = 1;
regs.h.ch = start; /* starting scan line */
regs.h.cl = end; /* ending scan line */

int86(0x10, ®s, ®s);

}














PRODUCT : Borland C++ NUMBER : 716
VERSION : 2.0
OS : DOS
DATE : September 18, 1991 PAGE : 4/4

TITLE : Switching Between 25 and 43 Line Mode on EGA




int egacursoremu(int mode)
{
unsigned char far *emulation = MK_FP(0x40,0x87);

if (mode == OFF) {
*emulation &= ~0x01;
setcursor(6, 7);
}
else {
*emulation |= 0x01;
setcursor(5, 7);
}

return(mode);
}

int in43linemode(void)
{
unsigned char far *egamode = MK_FP(0x40,0x84);

return ( (*egamode == 42)? TRUE: FALSE);

}

int egacursorsize(void)
{
unsigned char far *size = MK_FP(0x40, 0x85);

return( (int) *size);
}





















  3 Responses to “Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI716.ASC

  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/