Category : Printer + Display Graphics
Archive   : CRITTER4.ZIP
Filename : CRIT_HGC.C
Output of file : CRIT_HGC.C contained in archive : CRITTER4.ZIP
Module: Crit_HGC
Version: 1.01 10-Aug-1989
Languages: Zortech C/C++ 1.07e
Microsoft C 5.10 and QuickC 2.01
Borland Turbo C v2.0
Environ: MS-DOS, Hercules Graphics Card or equivalent
Purpose: Provides a simple interface to Hercules monochrome graphics
Written by: Scott Robert Ladd
705 West Virginia
Gunnison, CO 81230
MCI ID: srl
FidoNet: 1:104/45.2
*/
#include "crit_hgc.h"
#include "conio.h"
#if defined(_MSC) || defined(_QC) || defined(__ZTC__)
OUT_PORT(port,val) outp(port,val)
#elif defined(__TURBOC__)
OUT_PORT(port,val) outportb(port,val)
#endif
/* Hercules video RAM segment */
static const unsigned int VID_SEG = 0xB000;
/* 6845 Video Controller ports */
static const unsigned int IDX_PORT = 0x03B4;
static const unsigned int DAT_PORT = 0x03B5;
static const unsigned int CTL_PORT = 0x03B8;
static const unsigned int CFG_PORT = 0x03BF;
/* Codes to be loaded to 6845 to set proper mode */
static const unsigned int GRAPH_CODES[12] =
{0x35,0x2D,0x2E,0x07,0x5B,2,0x57,0x57,2,3,0,0};
static const unsigned int TEXT_CODES[12] =
{0x61,0x50,0x52,0x0F,0x19,6,0x19,0x19,2,0x0D,0x0B,0x0C};
void graphon(void)
{
unsigned int i;
unsigned char far * screen;
OUT_PORT(CFG_PORT,3);
screen = (char far *)((long)VID_SEG << 16L);
OUT_PORT(CTL_PORT,2); /* set control port */
for (i = 0; i <= 11; ++i)
{
OUT_PORT(IDX_PORT,i);
OUT_PORT(DAT_PORT,GRAPH_CODES[i]);
}
for (i = 0; i <= 32767; ++i)
{
*screen = '\x00';
++screen;
}
OUT_PORT(CTL_PORT,10); /* set control port */
}
void graphoff(void)
{
unsigned int i;
unsigned char far * screen;
OUT_PORT(CFG_PORT,3);
screen = (char far *)((long)VID_SEG << 16L);
OUT_PORT(CTL_PORT,0x20); /* set control port */
for (i = 0; i <= 11; ++i)
{
OUT_PORT(IDX_PORT,i);
OUT_PORT(DAT_PORT,TEXT_CODES[i]);
}
for (i = 0; i <= 32767; ++i)
{
if (i % 2 == 1)
*screen = '\x07';
else
*screen = '\x20';
++screen;
}
OUT_PORT(CTL_PORT,0x28); /* set control port */
}
void plotpixel(int x, int y, int color)
{
unsigned offset, bit;
unsigned char far * vid_byte;
offset = (0x2000 * (y % 4)) + (90 * (y / 4)) + (x / 8);
bit = 2;
bit <<= (7 - (x % 8));
bit >>= 1;
vid_byte = (char far *)(((long)VID_SEG << 16L) + (long)offset);
if (color)
*vid_byte |= bit;
else
*vid_byte &= ~bit;
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/