Category : C Source Code
Archive   : VIDMODES.ZIP
Filename : VIDMODES.C

 
Output of file : VIDMODES.C contained in archive : VIDMODES.ZIP
/********************** vidmodes.c **************************
30 September 1986 VIDMODES.C version 1.1

** This allows the user to check on what video mode the IBM
** video board is in and optionally change the video mode to
** the desired video mode.
** usage:
** vidmode will report on the video mode currently
** in use.
**
** vidmode n will report on the video mode currently
** in use, and then change the mode to
** the mode number 'n' as requested. It
** will then report on the new videomode.
** Note: Just as the EGA will allow you to set the video mode
** to modes that it will not support, so will this program.
** It will allow you to set the mode in ranges between 0-16.

Copywrong (c) 1986 by Paul M. Sittler.
All rights reversed. The copyright owner hereby authorizes the no-charge,
noncommercial making and/or distribution of copies of the entirety of
this work changed and incorporated in any other work (espec. "LiBRary"
or "ARChive" disk files for the sole purpose of no-charge noncommercial
distribution). No other reproduction or use is unauthorized without the
express prior written consent of the copyright owner.

Once upon a time, in a kingdom far away, people shared source code and
many of us benefited from the sharing. This silly little program is here
presented with source in hopes that it may stimulate the renewed sharing
of our efforts.

send any comments to: Paul Sittler
Department of Veterinary Public Health
(409) 845-3517 voice Texas A&M University
(409) 845-0509 modem College Station, TX 77843-4468
(409) 764-0056 modem

*********************************************************************/

/***** Constants defined ***********/
#define TRUE 1
#define FALSE 0

#include "stdio.h"

main(argc,argv)
int argc;
char *argv[];
{
int ega, cga, mono;
int prev_scrn_mode[4]; /* scrn_mode[0] == mode number */
/* scrn_mode[1] == columns on screen */
/* scrn_mode[2] == active page number */
int curr_scrn_mode[4]; /* scrn_mode[0] == mode number */
/* scrn_mode[1] == columns on screen */
/* scrn_mode[2] == active page number */
int ega_prms[4]; /* ega_prms[0] == 0 for color mode */
/* 1 for mono mode */
/* ega_prms[1] == EGA memory in Kbytes */
/* ega_prms[2] == EGA dipswitch settings */
/* ega_prms[3] == EGA info byte at 00:487 */
ega = cga = mono = FALSE; /* set all board types to false */

rd_mode(prev_scrn_mode);/* read previous screen mode */

ega = ega_present(ega_prms); /* determine EGA presence */

if (!ega)
if (prev_scrn_mode[0] == 7) /* check for mode 7 (mono) */
mono = TRUE;
else
cga = TRUE;

if (argc == 2) /* want to change video mode */
set_mode(atoi(argv[1]));

rd_mode(curr_scrn_mode);/* read previous screen mode */

if (ega) /* EGA installed */
{
printf
("%dK EGA board is installed, in %s mode, dipswitch setting %02x hex.\n",
ega_prms[1], ega_prms[0] ? "mono" : "color", ega_prms[2]);
printf("EGA info byte at 487 hex is %02x.\n", ega_prms[3]);
}
else
if (mono)
printf
("Monochrome board is installed.\n");
else
if (cga)
printf
("CGA or CGA clone board is installed.\n");


if (argc == 2) /* we have changed video mode */
printf
("Previous screen mode was %2d, and active page %d, %d columns wide.\n",
prev_scrn_mode[0], prev_scrn_mode[2], prev_scrn_mode[1]);
printf(" Current screen mode is %2d, and active page %d, %d columns wide.\n",
curr_scrn_mode[0], curr_scrn_mode[2], curr_scrn_mode[1]);
}


int ega_present(ega_prms) /* determine EGA presence */
/* if ega present, return info about its */
/*current mode (mono or color), how much */
/* screen memory it has in Kbytes, its */
/* dipswitch settings, and its info byte. */
int ega_prms[]; /* ega_prms[0] == 0 for color mode */
/* 1 for mono mode */
/* ega_prms[1] == EGA memory in Kbytes */
/* ega_prms[2] == EGA dipswitch settings */
/* ega_prms[3] == EGA info byte at 00:487 */
{
int prm[4]; /* array for regs ax-dx return */
bios(18, 0, 0x7F10, 0x0F, 0, prm); /* alternate function select 12h */
/* BL = 10h means return EGA info */
if ( (prm[2] % 256) < 0x0C ) /* CL returns dipswitch settings */
/* on rear of EGA board. Values of */
/* 12 - 16 are not valid settings for */
/* EGA board */
if ( (prm[1] / 256) < 2 ) /* BH returns 0 for color mode */
/* 1 for mono mode */
/* 0 and 1 are only valid settings */
/* for EGA board */
if ( (prm[1] % 256) < 4) /* BL returns memory installed where */
/* 0:64Kb 1:128Kb 2:192Kb 3:256Kb */
/* thus 0 - 3 are only valid settings */
/* for EGA board */
{ /* we have EGA board installed */
ega_prms[0] = prm[1] / 256; /* BH returns 0 for color mode */
/* 1 for mono mode */
ega_prms[1] = (prm[1] % 256 + 1) * 64;
/* BL returns memory installed where */
/* 0:64Kb 1:128Kb 2:192Kb 3:256Kb */
ega_prms[2] = prm[2] % 256; /* CL returns dipswitch settings */
/* on rear of EGA board. */
ega_prms[3] = _peek(0x487, 0);/* EGA info byte at 00:487 */
return (TRUE);
}
else return (FALSE);
}


/* Functions below from Software Spare Parts by Kent Porter */

bios() /* call bios for screen control */
{
/* Parms are registers ah, al, bx, cx, dx, and a pointer
to an array of integers where the bios will return the
ax - dx register values after the function executes */
/* NOTE: inline assembly code for DeSmet C -- check your
compiler's documentation, change calling conventions
and inline directives if appropriate. */
#asm
mov ah, [bp + 4]
mov al, [bp + 6]
mov bx, [bp + 8]
mov cx, [bp + 10]
mov dx, [bp + 12]
int 10h
push bp
mov bp, [bp + 14]
mov [bp + 0], ax
mov [bp + 2], bx
mov [bp + 4], cx
mov [bp + 6], dx
pop bp
#
}


void rd_mode(ret_val) /* read current screen mode */
int ret_val[];
{
int prm[4];
bios(15, 0, 0, 0, 0, prm);
ret_val[0] = prm[0] % 256; /* mode number */
ret_val[1] = prm[0] / 256; /* columns on screen */
ret_val[2] = prm[1] / 256; /* active page number */
}


int set_mode(mode) /* set screen mode */
int mode;
{
int dummy[4]; /* needed to satisfy bios() */
if (mode < 0 || mode > 16)
return (0); /* error */
bios(0, mode, 0, 0, 0, dummy);
return(1); /* normal exit */
}

/**************************************************************/


  3 Responses to “Category : C Source Code
Archive   : VIDMODES.ZIP
Filename : VIDMODES.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/