Hercules Graphics Driver (src)

John Antypas jantypas at ucrmath.UUCP
Fri Sep 30 00:35:54 AEST 1988


THe code below is a driver for Micropport Sys V/AT 2.3 which allows the
user (on the console) to use the graphics abilities of the hercules video
display card.  It's similar to an earlier post, but I had a few major bugs
to fix and a test program is included.

Any questions, comments can be sent to: jantypas at Soft21.Riverside.CA.US
  or for those who don't handle MX Receords ...!garp!soft21!jantypas


#--------------------------Cut Here--------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before the "#! /bin/sh" line,
# then unpack it by saving it in a file and typing "sh file."
#
# Wrapped by John Antypas (root) at soft21 on Sun Sep 18 18:01:21 1988
#
# unpacks with default permissions
#
# Contents : herc.c herc.h herc.readme herctest.c
#
if `test ! -s herc.c`
then
echo "x - herc.c"
cat > herc.c << '@\Rogue\Monster\'
/* ================= Hercules Graphics Code =========================== */
/* These routines provide basic line drawing graphics for the hercules  */
/* monographics card under Microport Unix Sys V/AT 2.3.  Written by     */
/* John Antypas 8/10/88 						*/
/* Property of Microport Inc.                                           */
/*                                                                      */
/* ==================================================================== */

#define CLICKP1		0x5C0		/* Click addr of Page 2		*/
#define CLICKP2		0x600		/* Click addr of end of page 2	*/
#define PAGE1		0xB0000		/* Graphics pages in clicks	*/
#define PAGE2		0xB8000 
#define PAGE_SIZE	0x8000

/* Include files */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mmu.h>
#include <sys/seg.h>
#include <sys/map.h>
#include <sys/signal.h>
#include <sys/dir.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/user.h>
#include <sys/sysmacros.h>
#include <sys/herc.h>

int	herc_state;		/* If !=0 herc in use.		*/
char	command;		/* Command byte			*/
char	*herc_base;		/* Memory base			*/

char param_g[12]={		/* parameter table for 6845 video chip */
	0x35, 0x2d, 0x2e, 0x07, 	/* graphics setup */
	0x5b, 0x02, 0x57, 0x57,
	0x02, 0x03, 0x00, 0x00};

char param_t[12]={		/* parameter table for 6845 video chip */
	0x61, 0x50, 0x52, 0x0f,	/* text setup */
	0x19, 0x06, 0x19, 0x19,
	0x02, 0x0d, 0x0b, 0x0c};

char masks[8]={
	0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};

/* RAM-Loadable Character Sets for the IBM PC
 Richard Wilton
 July 1986

/* definitions for 8 by 8 characters 00 through FF */

static char hercchars[2048]={
	0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,	/* 000 */
	0x07E,0x081,0x0A5,0x081,0x0BD,0x099,0x081,0x07E,	/* 001 */
	0x07E,0x0FF,0x000,0x0FF,0x0C3,0x0E7,0x0FF,0x07E,	/* 002 */
	0x06C,0x0FE,0x0FE,0x0FE,0x07C,0x038,0x010,0x000,	/* 003 */
	0x010,0x038,0x07C,0x0FE,0x07C,0x038,0x010,0x000,	/* 004 */
	0x038,0x07C,0x038,0x0FE,0x0FE,0x07C,0x038,0x07C,	/* 005 */
	0x010,0x010,0x038,0x07C,0x0FE,0x07C,0x038,0x07C,	/* 006 */
	0x000,0x000,0x018,0x03C,0x03C,0x018,0x000,0x000,	/* 007 */
	0x0FF,0x0FF,0x0E7,0x0C3,0x0C3,0x0E7,0x0FF,0x0FF,	/* 008 */
	0x000,0x03C,0x066,0x042,0x042,0x066,0x03C,0x000,	/* 009 */
	0x0FF,0x0C3,0x099,0x0BD,0x0BD,0x099,0x0C3,0x0FF,	/* 00A */
	0x00F,0x007,0x00F,0x07D,0x0CC,0x0CC,0x0CC,0x078,	/* 00B */
	0x03C,0x066,0x066,0x066,0x03C,0x018,0x07E,0x018,	/* 00C */
	0x03F,0x033,0x03F,0x030,0x030,0x070,0x0F0,0x0E0,	/* 00D */
	0x07F,0x063,0x07F,0x063,0x063,0x067,0x0E6,0x0C0,	/* 00E */
	0x099,0x05A,0x03C,0x0E7,0x0E7,0x03C,0x05A,0x099,	/* 00F */
	0x080,0x0E0,0x0F8,0x0FE,0x0F8,0x0E0,0x080,0x000,	/* 010 */
	0x002,0x00E,0x03E,0x0FE,0x03E,0x00E,0x002,0x000,	/* 011 */
	0x018,0x03C,0x07E,0x018,0x018,0x07E,0x03C,0x018,	/* 012 */
	0x066,0x066,0x066,0x066,0x066,0x000,0x066,0x000,	/* 013 */
	0x07F,0x000,0x000,0x07B,0x01B,0x01B,0x01B,0x000,	/* 014 */
	0x03E,0x063,0x038,0x06C,0x06C,0x038,0x0CC,0x078,	/* 015 */
	0x000,0x000,0x000,0x000,0x07E,0x07E,0x07E,0x000,	/* 016 */
	0x018,0x03C,0x07E,0x018,0x07E,0x03C,0x018,0x0FF,	/* 017 */
	0x018,0x03C,0x07E,0x018,0x018,0x018,0x018,0x000,	/* 018 */
	0x018,0x018,0x018,0x018,0x07E,0x03C,0x018,0x000,	/* 019 */
	0x000,0x018,0x00C,0x0FE,0x00C,0x018,0x000,0x000,	/* 01A */
	0x000,0x030,0x060,0x0FE,0x060,0x030,0x000,0x000,	/* 01B */
	0x000,0x000,0x0C0,0x0C0,0x0C0,0x0FE,0x000,0x000,	/* 01C */
	0x000,0x024,0x066,0x0FF,0x066,0x024,0x000,0x000,	/* 01D */
	0x000,0x018,0x03C,0x07E,0x0FF,0x0FF,0x000,0x000,	/* 01E */
	0x000,0x0FF,0x0FF,0x07E,0x03C,0x018,0x000,0x000,	/* 01F */
	0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,	/* 020 */
	0x030,0x078,0x078,0x030,0x030,0x000,0x030,0x000,	/* 021 */
	0x06C,0x06C,0x06C,0x000,0x000,0x000,0x000,0x000,	/* 022 */
	0x06C,0x06C,0x0FE,0x06C,0x0FE,0x06C,0x06C,0x000,	/* 023 */
	0x030,0x07C,0x0C0,0x078,0x00C,0x0F8,0x030,0x000,	/* 024 */
	0x000,0x0C6,0x0CC,0x018,0x030,0x066,0x0C6,0x000,	/* 025 */
	0x038,0x06C,0x038,0x076,0x0DC,0x0CC,0x076,0x000,	/* 026 */
	0x060,0x060,0x0C0,0x000,0x000,0x000,0x000,0x000,	/* 027 */
	0x018,0x030,0x060,0x060,0x060,0x030,0x018,0x000,	/* 028 */
	0x060,0x030,0x018,0x018,0x018,0x030,0x060,0x000,	/* 029 */
	0x000,0x066,0x03C,0x0FF,0x03C,0x066,0x000,0x000,	/* 02A */
	0x000,0x030,0x030,0x0FC,0x030,0x030,0x000,0x000,	/* 02B */
	0x000,0x000,0x000,0x000,0x000,0x030,0x030,0x060,	/* 02C */
	0x000,0x000,0x000,0x0FC,0x000,0x000,0x000,0x000,	/* 02D */
	0x000,0x000,0x000,0x000,0x000,0x030,0x030,0x000,	/* 02E */
	0x006,0x00C,0x018,0x030,0x060,0x0C0,0x080,0x000,	/* 02F */
	0x07C,0x0C6,0x0CE,0x0DE,0x0F6,0x0E6,0x07C,0x000,	/* 030 */
	0x030,0x070,0x030,0x030,0x030,0x030,0x0FC,0x000,	/* 031 */
	0x078,0x0CC,0x00C,0x038,0x060,0x0CC,0x0FC,0x000,	/* 032 */
	0x078,0x0CC,0x00C,0x038,0x00C,0x0CC,0x078,0x000,	/* 033 */
	0x01C,0x03C,0x06C,0x0CC,0x0FE,0x00C,0x01E,0x000,	/* 034 */
	0x0FC,0x0C0,0x0F8,0x00C,0x00C,0x0CC,0x078,0x000,	/* 035 */
	0x038,0x060,0x0C0,0x0F8,0x0CC,0x0CC,0x078,0x000,	/* 036 */
	0x0FC,0x0CC,0x00C,0x018,0x030,0x030,0x030,0x000,	/* 037 */
	0x078,0x0CC,0x0CC,0x078,0x0CC,0x0CC,0x078,0x000,	/* 038 */
	0x078,0x0CC,0x0CC,0x07C,0x00C,0x018,0x070,0x000,	/* 039 */
	0x000,0x030,0x030,0x000,0x000,0x030,0x030,0x000,	/* 03A */
	0x000,0x030,0x030,0x000,0x000,0x030,0x030,0x060,	/* 03B */
	0x018,0x030,0x060,0x0C0,0x060,0x030,0x018,0x000,	/* 03C */
	0x000,0x000,0x0FC,0x000,0x000,0x0FC,0x000,0x000,	/* 03D */
	0x060,0x030,0x018,0x00C,0x018,0x030,0x060,0x000,	/* 03E */
	0x078,0x0CC,0x00C,0x018,0x030,0x000,0x030,0x000,	/* 03F */
	0x07C,0x0C6,0x0DE,0x0DE,0x0DE,0x0C0,0x078,0x000,	/* 040 */
	0x030,0x078,0x0CC,0x0CC,0x0FC,0x0CC,0x0CC,0x000,	/* 041 */
	0x0FC,0x066,0x066,0x07C,0x066,0x066,0x0FC,0x000,	/* 042 */
	0x03C,0x066,0x0C0,0x0C0,0x0C0,0x066,0x03C,0x000,	/* 043 */
	0x0F8,0x06C,0x066,0x066,0x066,0x06C,0x0F8,0x000,	/* 044 */
	0x0FE,0x062,0x068,0x078,0x068,0x062,0x0FE,0x000,	/* 045 */
	0x0FE,0x062,0x068,0x078,0x068,0x060,0x0F0,0x000,	/* 046 */
	0x03C,0x066,0x0C0,0x0C0,0x0CE,0x066,0x03E,0x000,	/* 047 */
	0x0CC,0x0CC,0x0CC,0x0FC,0x0CC,0x0CC,0x0CC,0x000,	/* 048 */
	0x078,0x030,0x030,0x030,0x030,0x030,0x078,0x000,	/* 049 */
	0x01E,0x00C,0x00C,0x00C,0x0CC,0x0CC,0x078,0x000,	/* 04A */
	0x0E6,0x066,0x06C,0x078,0x06C,0x066,0x0E6,0x000,	/* 04B */
	0x0F0,0x060,0x060,0x060,0x062,0x066,0x0FE,0x000,	/* 04C */
	0x0C6,0x0EE,0x0FE,0x0FE,0x0D6,0x0C6,0x0C6,0x000,	/* 04D */
	0x0C6,0x0E6,0x0F6,0x0DE,0x0CE,0x0C6,0x0C6,0x000,	/* 04E */
	0x038,0x06C,0x0C6,0x0C6,0x0C6,0x06C,0x038,0x000,	/* 04F */
	0x0FC,0x066,0x066,0x07C,0x060,0x060,0x0F0,0x000,	/* 050 */
	0x078,0x0CC,0x0CC,0x0CC,0x0DC,0x078,0x01C,0x000,	/* 051 */
	0x0FC,0x066,0x066,0x07C,0x06C,0x066,0x0E6,0x000,	/* 052 */
	0x078,0x0CC,0x0E0,0x070,0x01C,0x0CC,0x078,0x000,	/* 053 */
	0x0FC,0x0B4,0x030,0x030,0x030,0x030,0x078,0x000,	/* 054 */
	0x0CC,0x0CC,0x0CC,0x0CC,0x0CC,0x0CC,0x0FC,0x000,	/* 055 */
	0x0CC,0x0CC,0x0CC,0x0CC,0x0CC,0x078,0x030,0x000,	/* 056 */
	0x0C6,0x0C6,0x0C6,0x0D6,0x0FE,0x0EE,0x0C6,0x000,	/* 057 */
	0x0C6,0x0C6,0x06C,0x038,0x038,0x06C,0x0C6,0x000,	/* 058 */
	0x0CC,0x0CC,0x0CC,0x078,0x030,0x030,0x078,0x000,	/* 059 */
	0x0FE,0x0C6,0x08C,0x018,0x032,0x066,0x0FE,0x000,	/* 05A */
	0x078,0x060,0x060,0x060,0x060,0x060,0x078,0x000,	/* 05B */
	0x0C0,0x060,0x030,0x018,0x00C,0x006,0x002,0x000,	/* 05C */
	0x078,0x018,0x018,0x018,0x018,0x018,0x078,0x000,	/* 05D */
	0x010,0x038,0x06C,0x0C6,0x000,0x000,0x000,0x000,	/* 05E */
	0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x0FF,	/* 05F */
	0x030,0x030,0x018,0x000,0x000,0x000,0x000,0x000,	/* 060 */
	0x000,0x000,0x078,0x00C,0x07C,0x0CC,0x076,0x000,	/* 061 */
	0x0E0,0x060,0x060,0x07C,0x066,0x066,0x0DC,0x000,	/* 062 */
	0x000,0x000,0x078,0x0CC,0x0C0,0x0CC,0x078,0x000,	/* 063 */
	0x01C,0x00C,0x00C,0x07C,0x0CC,0x0CC,0x076,0x000,	/* 064 */
	0x000,0x000,0x078,0x0CC,0x0FC,0x0C0,0x078,0x000,	/* 065 */
	0x038,0x06C,0x060,0x0F0,0x060,0x060,0x0F0,0x000,	/* 066 */
	0x000,0x000,0x076,0x0CC,0x0CC,0x07C,0x00C,0x0F8,	/* 067 */
	0x0E0,0x060,0x06C,0x076,0x066,0x066,0x0E6,0x000,	/* 068 */
	0x030,0x000,0x070,0x030,0x030,0x030,0x078,0x000,	/* 069 */
	0x00C,0x000,0x00C,0x00C,0x00C,0x0CC,0x0CC,0x078,	/* 06A */
	0x0E0,0x060,0x066,0x06C,0x078,0x06C,0x0E6,0x000,	/* 06B */
	0x070,0x030,0x030,0x030,0x030,0x030,0x078,0x000,	/* 06C */
	0x000,0x000,0x0CC,0x0FE,0x0FE,0x0D6,0x0C6,0x000,	/* 06D */
	0x000,0x000,0x0F8,0x0CC,0x0CC,0x0CC,0x0CC,0x000,	/* 06E */
	0x000,0x000,0x078,0x0CC,0x0CC,0x0CC,0x078,0x000,	/* 06F */
	0x000,0x000,0x0DC,0x066,0x066,0x07C,0x060,0x0F0,	/* 070 */
	0x000,0x000,0x076,0x0CC,0x0CC,0x07C,0x00C,0x01E,	/* 071 */
	0x000,0x000,0x0DC,0x076,0x066,0x060,0x0F0,0x000,	/* 072 */
	0x000,0x000,0x07C,0x0C0,0x078,0x00C,0x0F8,0x000,	/* 073 */
	0x010,0x030,0x07C,0x030,0x030,0x034,0x018,0x000,	/* 074 */
	0x000,0x000,0x0CC,0x0CC,0x0CC,0x0CC,0x076,0x000,	/* 075 */
	0x000,0x000,0x0CC,0x0CC,0x0CC,0x078,0x030,0x000,	/* 076 */
	0x000,0x000,0x0C6,0x0D6,0x0FE,0x0FE,0x06C,0x000,	/* 077 */
	0x000,0x000,0x0C6,0x06C,0x038,0x06C,0x0C6,0x000,	/* 078 */
	0x000,0x000,0x0CC,0x0CC,0x0CC,0x07C,0x00C,0x0F8,	/* 079 */
	0x000,0x000,0x0FC,0x098,0x030,0x064,0x0FC,0x000,	/* 07A */
	0x01C,0x030,0x030,0x0E0,0x030,0x030,0x01C,0x000,	/* 07B */
	0x018,0x018,0x018,0x000,0x018,0x018,0x018,0x000,	/* 07C */
	0x0E0,0x030,0x030,0x01C,0x030,0x030,0x0E0,0x000,	/* 07D */
	0x076,0x0DC,0x000,0x000,0x000,0x000,0x000,0x000,	/* 07E */
	0x000,0x010,0x038,0x06C,0x0C6,0x0C6,0x0FE,0x000,	/* 07F */
	0x078,0x0CC,0x0C0,0x0CC,0x078,0x018,0x00C,0x078,	/* 080 */
	0x000,0x066,0x000,0x066,0x066,0x066,0x03F,0x000,	/* 081 */
	0x00E,0x000,0x03C,0x066,0x07E,0x060,0x03C,0x000,	/* 082 */
	0x07E,0x0C3,0x03C,0x006,0x03E,0x066,0x03F,0x000,	/* 083 */
	0x066,0x000,0x03C,0x006,0x03E,0x066,0x03F,0x000,	/* 084 */
	0x070,0x000,0x03C,0x006,0x03E,0x066,0x03F,0x000,	/* 085 */
	0x018,0x018,0x03C,0x006,0x03E,0x066,0x03F,0x000,	/* 086 */
	0x000,0x000,0x03C,0x060,0x060,0x03C,0x006,0x01C,	/* 087 */
	0x07E,0x0C3,0x03C,0x066,0x07E,0x060,0x03C,0x000,	/* 088 */
	0x066,0x000,0x03C,0x066,0x07E,0x060,0x03C,0x000,	/* 089 */
	0x070,0x000,0x03C,0x066,0x07E,0x060,0x03C,0x000,	/* 08A */
	0x066,0x000,0x038,0x018,0x018,0x018,0x03C,0x000,	/* 08B */
	0x07C,0x0C6,0x038,0x018,0x018,0x018,0x03C,0x000,	/* 08C */
	0x070,0x000,0x038,0x018,0x018,0x018,0x03C,0x000,	/* 08D */
	0x063,0x01C,0x036,0x063,0x07F,0x063,0x063,0x000,	/* 08E */
	0x018,0x018,0x000,0x03C,0x066,0x07E,0x066,0x000,	/* 08F */
	0x00E,0x000,0x07E,0x030,0x03C,0x030,0x07E,0x000,	/* 090 */
	0x000,0x000,0x07F,0x00C,0x07F,0x0CC,0x07F,0x000,	/* 091 */
	0x01F,0x036,0x066,0x07F,0x066,0x066,0x067,0x000,	/* 092 */
	0x03C,0x066,0x000,0x03C,0x066,0x066,0x03C,0x000,	/* 093 */
	0x000,0x066,0x000,0x03C,0x066,0x066,0x03C,0x000,	/* 094 */
	0x000,0x070,0x000,0x03C,0x066,0x066,0x03C,0x000,	/* 095 */
	0x03C,0x066,0x000,0x066,0x066,0x066,0x03F,0x000,	/* 096 */
	0x000,0x070,0x000,0x066,0x066,0x066,0x03F,0x000,	/* 097 */
	0x000,0x066,0x000,0x066,0x066,0x03E,0x006,0x07C,	/* 098 */
	0x0C3,0x018,0x03C,0x066,0x066,0x03C,0x018,0x000,	/* 099 */
	0x066,0x000,0x066,0x066,0x066,0x066,0x03C,0x000,	/* 09A */
	0x018,0x018,0x07E,0x0C0,0x0C0,0x07E,0x018,0x018,	/* 09B */
	0x01C,0x036,0x032,0x078,0x030,0x073,0x07E,0x000,	/* 09C */
	0x066,0x066,0x03C,0x07E,0x018,0x07E,0x018,0x018,	/* 09D */
	0x0F8,0x0CC,0x0CC,0x0FA,0x0C6,0x0CF,0x0C6,0x0C7,	/* 09E */
	0x00E,0x01B,0x018,0x03C,0x018,0x018,0x0D8,0x070,	/* 09F */
	0x00E,0x000,0x03C,0x006,0x03E,0x066,0x03F,0x000,	/* 0A0 */
	0x01C,0x000,0x038,0x018,0x018,0x018,0x03C,0x000,	/* 0A1 */
	0x000,0x00E,0x000,0x03C,0x066,0x066,0x03C,0x000,	/* 0A2 */
	0x000,0x00E,0x000,0x066,0x066,0x066,0x03F,0x000,	/* 0A3 */
	0x000,0x07C,0x000,0x07C,0x066,0x066,0x066,0x000,	/* 0A4 */
	0x07E,0x000,0x066,0x076,0x07E,0x06E,0x066,0x000,	/* 0A5 */
	0x03C,0x06C,0x06C,0x03E,0x000,0x07E,0x000,0x000,	/* 0A6 */
	0x038,0x06C,0x06C,0x038,0x000,0x07C,0x000,0x000,	/* 0A7 */
	0x018,0x000,0x018,0x030,0x060,0x066,0x03C,0x000,	/* 0A8 */
	0x000,0x000,0x000,0x07E,0x060,0x060,0x000,0x000,	/* 0A9 */
	0x000,0x000,0x000,0x07E,0x006,0x006,0x000,0x000,	/* 0AA */
	0x0C3,0x0C6,0x0CC,0x0DE,0x033,0x066,0x0CC,0x00F,	/* 0AB */
	0x0C3,0x0C6,0x0CC,0x000,0x037,0x06F,0x0CF,0x003,	/* 0AC */
	0x018,0x018,0x000,0x018,0x018,0x018,0x018,0x000,	/* 0AD */
	0x000,0x033,0x066,0x0CC,0x066,0x033,0x000,0x000,	/* 0AE */
	0x000,0x0CC,0x066,0x033,0x066,0x0CC,0x000,0x000,	/* 0AF */
	0x022,0x088,0x022,0x088,0x022,0x088,0x022,0x088,	/* 0B0 */
	0x055,0x0AA,0x055,0x0AA,0x055,0x0AA,0x055,0x0AA,	/* 0B1 */
	0x000,0x077,0x000,0x0EE,0x000,0x077,0x000,0x0EE,	/* 0B2 */
	0x018,0x018,0x018,0x018,0x018,0x018,0x018,0x018,	/* 0B3 */
	0x018,0x018,0x018,0x018,0x0F8,0x018,0x018,0x018,	/* 0B4 */
	0x018,0x018,0x0F8,0x018,0x0F8,0x018,0x018,0x018,	/* 0B5 */
	0x036,0x036,0x036,0x036,0x0F6,0x036,0x036,0x036,	/* 0B6 */
	0x000,0x000,0x000,0x000,0x0FE,0x036,0x036,0x036,	/* 0B7 */
	0x000,0x000,0x0F8,0x018,0x0F8,0x018,0x018,0x018,	/* 0B8 */
	0x036,0x036,0x0F6,0x006,0x0F6,0x036,0x036,0x036,	/* 0B9 */
	0x036,0x036,0x036,0x036,0x036,0x036,0x036,0x036,	/* 0BA */
	0x000,0x000,0x0FE,0x006,0x0F6,0x036,0x036,0x036,	/* 0BB */
	0x036,0x036,0x0F6,0x006,0x0FE,0x000,0x000,0x000,	/* 0BC */
	0x036,0x036,0x036,0x036,0x0FE,0x000,0x000,0x000,	/* 0BD */
	0x018,0x018,0x0F8,0x018,0x0F8,0x000,0x000,0x000,	/* 0BE */
	0x000,0x000,0x000,0x000,0x0F8,0x018,0x018,0x018,	/* 0BF */
	0x018,0x018,0x018,0x018,0x01F,0x000,0x000,0x000,	/* 0C0 */
	0x018,0x018,0x018,0x018,0x0FF,0x000,0x000,0x000,	/* 0C1 */
	0x000,0x000,0x000,0x000,0x0FF,0x018,0x018,0x018,	/* 0C2 */
	0x018,0x018,0x018,0x018,0x01F,0x018,0x018,0x018,	/* 0C3 */
	0x000,0x000,0x000,0x000,0x0FF,0x000,0x000,0x000,	/* 0C4 */
	0x018,0x018,0x018,0x018,0x0FF,0x018,0x018,0x018,	/* 0C5 */
	0x018,0x018,0x01F,0x018,0x01F,0x018,0x018,0x018,	/* 0C6 */
	0x036,0x036,0x036,0x036,0x037,0x036,0x036,0x036,	/* 0C7 */
	0x036,0x036,0x037,0x030,0x03F,0x000,0x000,0x000,	/* 0C8 */
	0x000,0x000,0x03F,0x030,0x037,0x036,0x036,0x036,	/* 0C9 */
	0x036,0x036,0x0F7,0x000,0x0FF,0x000,0x000,0x000,	/* 0CA */
	0x000,0x000,0x0FF,0x000,0x0F7,0x036,0x036,0x036,	/* 0CB */
	0x036,0x036,0x037,0x030,0x037,0x036,0x036,0x036,	/* 0CC */
	0x000,0x000,0x0FF,0x000,0x0FF,0x000,0x000,0x000,	/* 0CD */
	0x036,0x036,0x0F7,0x000,0x0F7,0x036,0x036,0x036,	/* 0CE */
	0x018,0x018,0x0FF,0x000,0x0FF,0x000,0x000,0x000,	/* 0CF */
	0x036,0x036,0x036,0x036,0x0FF,0x000,0x000,0x000,	/* 0D0 */
	0x000,0x000,0x0FF,0x000,0x0FF,0x018,0x018,0x018,	/* 0D1 */
	0x000,0x000,0x000,0x000,0x0FF,0x036,0x036,0x036,	/* 0D2 */
	0x036,0x036,0x036,0x036,0x03F,0x000,0x000,0x000,	/* 0D3 */
	0x018,0x018,0x01F,0x018,0x01F,0x000,0x000,0x000,	/* 0D4 */
	0x000,0x000,0x01F,0x018,0x01F,0x018,0x018,0x018,	/* 0D5 */
	0x000,0x000,0x000,0x000,0x03F,0x036,0x036,0x036,	/* 0D6 */
	0x036,0x036,0x036,0x036,0x0FF,0x036,0x036,0x036,	/* 0D7 */
	0x018,0x018,0x0FF,0x018,0x0FF,0x018,0x018,0x018,	/* 0D8 */
	0x018,0x018,0x018,0x018,0x0F8,0x000,0x000,0x000,	/* 0D9 */
	0x000,0x000,0x000,0x000,0x01F,0x018,0x018,0x018,	/* 0DA */
	0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,	/* 0 */
	0x000,0x000,0x000,0x000,0x0FF,0x0FF,0x0FF,0x0FF,	/* 0DC */
	0x0F0,0x0F0,0x0F0,0x0F0,0x0F0,0x0F0,0x0F0,0x0F0,	/* 0DD */
	0x00F,0x00F,0x00F,0x00F,0x00F,0x00F,0x00F,0x00F,	/* 0DE */
	0x0FF,0x0FF,0x0FF,0x0FF,0x000,0x000,0x000,0x000,	/* 0DF */
	0x000,0x000,0x03B,0x06E,0x064,0x06E,0x03B,0x000,	/* 0E0 */
	0x000,0x03C,0x066,0x07C,0x066,0x07C,0x060,0x060,	/* 0E1 */
	0x000,0x07E,0x066,0x060,0x060,0x060,0x060,0x000,	/* 0E2 */
	0x000,0x07F,0x036,0x036,0x036,0x036,0x036,0x000,	/* 0E3 */
	0x07E,0x066,0x030,0x018,0x030,0x066,0x07E,0x000,	/* 0E4 */
	0x000,0x000,0x03F,0x06C,0x06C,0x06C,0x038,0x000,	/* 0E5 */
	0x000,0x033,0x033,0x033,0x033,0x03E,0x030,0x060,	/* 0E6 */
	0x000,0x03B,0x06E,0x00C,0x00C,0x00C,0x00C,0x000,	/* 0E7 */
	0x07E,0x018,0x03C,0x066,0x066,0x03C,0x018,0x07E,	/* 0E8 */
	0x01C,0x036,0x063,0x07F,0x063,0x036,0x01C,0x000,	/* 0E9 */
	0x01C,0x036,0x063,0x063,0x036,0x036,0x077,0x000,	/* 0EA */
	0x00E,0x018,0x00C,0x03E,0x066,0x066,0x03C,0x000,	/* 0EB */
	0x000,0x000,0x07E,0x000,0x000,0x07E,0x000,0x000,	/* 0EC */
	0x006,0x00C,0x07E,0x000,0x000,0x07E,0x060,0x0C0,	/* 0ED */
	0x01C,0x060,0x0C0,0x0FC,0x0C0,0x060,0x01C,0x000,	/* 0EE */
	0x03C,0x066,0x066,0x066,0x066,0x066,0x066,0x000,	/* 0EF */
	0x000,0x07E,0x000,0x07E,0x000,0x07E,0x000,0x000,	/* 0F0 */
	0x018,0x018,0x07E,0x018,0x018,0x000,0x07E,0x000,	/* 0F1 */
	0x030,0x018,0x00C,0x018,0x030,0x000,0x07E,0x000,	/* 0F2 */
	0x00C,0x018,0x030,0x018,0x00C,0x000,0x07E,0x000,	/* 0F3 */
	0x00E,0x01B,0x01B,0x018,0x018,0x018,0x018,0x018,	/* 0F4 */
	0x018,0x018,0x018,0x018,0x018,0x0D8,0x0D8,0x070,	/* 0F5 */
	0x018,0x018,0x000,0x07E,0x000,0x018,0x018,0x000,	/* 0F6 */
	0x000,0x076,0x0DC,0x000,0x076,0x0DC,0x000,0x000,	/* 0F7 */
	0x038,0x06C,0x06C,0x038,0x000,0x000,0x000,0x000,	/* 0F8 */
	0x000,0x000,0x000,0x018,0x018,0x000,0x000,0x000,	/* 0F9 */
	0x000,0x000,0x000,0x000,0x018,0x000,0x000,0x000,	/* 0FA */
	0x00F,0x00C,0x00C,0x00C,0x0EC,0x06C,0x03C,0x01C,	/* 0FB */
	0x078,0x06C,0x06C,0x06C,0x06C,0x000,0x000,0x000,	/* 0FC */
	0x070,0x018,0x030,0x060,0x078,0x000,0x000,0x000,	/* 0FD */
	0x000,0x000,0x03C,0x03C,0x03C,0x03C,0x000,0x000,	/* 0FE */
	0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000		/* 0FF */
};

static long y_offset[348] = {
	0x00000,0x02000,0x04000,0x06000,0x0005a,0x0205a,0x0405a,
	0x0605a,0x000b4,0x020b4,0x040b4,0x060b4,0x0010e,0x0210e,
	0x0410e,0x0610e,0x00168,0x02168,0x04168,0x06168,0x001c2,
	0x021c2,0x041c2,0x061c2,0x0021c,0x0221c,0x0421c,0x0621c,
	0x00276,0x02276,0x04276,0x06276,0x002d0,0x022d0,0x042d0,
	0x062d0,0x0032a,0x0232a,0x0432a,0x0632a,0x00384,0x02384,
	0x04384,0x06384,0x003de,0x023de,0x043de,0x063de,0x00438,
	0x02438,0x04438,0x06438,0x00492,0x02492,0x04492,0x06492,
	0x004ec,0x024ec,0x044ec,0x064ec,0x00546,0x02546,0x04546,
	0x06546,0x005a0,0x025a0,0x045a0,0x065a0,0x005fa,0x025fa,
	0x045fa,0x065fa,0x00654,0x02654,0x04654,0x06654,0x006ae,
	0x026ae,0x046ae,0x066ae,0x00708,0x02708,0x04708,0x06708,
	0x00762,0x02762,0x04762,0x06762,0x007bc,0x027bc,0x047bc,
	0x067bc,0x00816,0x02816,0x04816,0x06816,0x00870,0x02870,
	0x04870,0x06870,0x008ca,0x028ca,0x048ca,0x068ca,0x00924,
	0x02924,0x04924,0x06924,0x0097e,0x0297e,0x0497e,0x0697e,
	0x009d8,0x029d8,0x049d8,0x069d8,0x00a32,0x02a32,0x04a32,
	0x06a32,0x00a8c,0x02a8c,0x04a8c,0x06a8c,0x00ae6,0x02ae6,
	0x04ae6,0x06ae6,0x00b40,0x02b40,0x04b40,0x06b40,0x00b9a,
	0x02b9a,0x04b9a,0x06b9a,0x00bf4,0x02bf4,0x04bf4,0x06bf4,
	0x00c4e,0x02c4e,0x04c4e,0x06c4e,0x00ca8,0x02ca8,0x04ca8,
	0x06ca8,0x00d02,0x02d02,0x04d02,0x06d02,0x00d5c,0x02d5c,
	0x04d5c,0x06d5c,0x00db6,0x02db6,0x04db6,0x06db6,0x00e10,
	0x02e10,0x04e10,0x06e10,0x00e6a,0x02e6a,0x04e6a,0x06e6a,
	0x00ec4,0x02ec4,0x04ec4,0x06ec4,0x00f1e,0x02f1e,0x04f1e,
	0x06f1e,0x00f78,0x02f78,0x04f78,0x06f78,0x00fd2,0x02fd2,
	0x04fd2,0x06fd2,0x0102c,0x0302c,0x0502c,0x0702c,0x01086,
	0x03086,0x05086,0x07086,0x010e0,0x030e0,0x050e0,0x070e0,
	0x0113a,0x0313a,0x0513a,0x0713a,0x01194,0x03194,0x05194,
	0x07194,0x011ee,0x031ee,0x051ee,0x071ee,0x01248,0x03248,
	0x05248,0x07248,0x012a2,0x032a2,0x052a2,0x072a2,0x012fc,
	0x032fc,0x052fc,0x072fc,0x01356,0x03356,0x05356,0x07356,
	0x013b0,0x033b0,0x053b0,0x073b0,0x0140a,0x0340a,0x0540a,
	0x0740a,0x01464,0x03464,0x05464,0x07464,0x014be,0x034be,
	0x054be,0x074be,0x01518,0x03518,0x05518,0x07518,0x01572,
	0x03572,0x05572,0x07572,0x015cc,0x035cc,0x055cc,0x075cc,
	0x01626,0x03626,0x05626,0x07626,0x01680,0x03680,0x05680,
	0x07680,0x016da,0x036da,0x056da,0x076da,0x01734,0x03734,
	0x05734,0x07734,0x0178e,0x0378e,0x0578e,0x0778e,0x017e8,
	0x037e8,0x057e8,0x077e8,0x01842,0x03842,0x05842,0x07842,
	0x0189c,0x0389c,0x0589c,0x0789c,0x018f6,0x038f6,0x058f6,
	0x078f6,0x01950,0x03950,0x05950,0x07950,0x019aa,0x039aa,
	0x059aa,0x079aa,0x01a04,0x03a04,0x05a04,0x07a04,0x01a5e,
	0x03a5e,0x05a5e,0x07a5e,0x01ab8,0x03ab8,0x05ab8,0x07ab8,
	0x01b12,0x03b12,0x05b12,0x07b12,0x01b6c,0x03b6c,0x05b6c,
	0x07b6c,0x01bc6,0x03bc6,0x05bc6,0x07bc6,0x01c20,0x03c20,
	0x05c20,0x07c20,0x01c7a,0x03c7a,0x05c7a,0x07c7a,0x01cd4,
	0x03cd4,0x05cd4,0x07cd4,0x01d2e,0x03d2e,0x05d2e,0x07d2e,
	0x01d88,0x03d88,0x05d88,0x07d88,0x01de2,0x03de2,0x05de2,
	0x07de2,0x01e3c,0x03e3c,0x05e3c,0x07e3c
};

flip_page(mode)
int	mode;
{
	int	i;
	char	c;
	
	switch(mode)
	{
		case HERC_TEXT : {
					out(0x3bf, 0x03); 
					for(i=0;i<12;i++)
					{
						c = i; out(0x3b4, c);
						c = param_t[i];
						out(0x3b5, c);
					};
					/* Just swap page images */
					out(0x3b8, 0x28); 
					break;
				};
		case HERC_GRAF : {
					out(0x3bf, 0x03);
					for(i=0;i<12;i++)
					{
						c = i; out(0x3b4, c);
						c = param_g[i]; out(0x3b5, c);
					};
					/* Just swap page images */
				  	out(0x3b8, 0x8A);
					break;
				};
	};
}

int gron()
{
	int	i;
	char	c;
	
	/* Allow page flipping and graphics	*/
	/* Now, set graphics bit		*/
	out(0x3bf, 0x03); 
	/* Now, set up the 6845 */
	for(i=0;i<12;i++)
	{ c = i; out(0x3b4, c); c = param_g[i]; out(0x3b5, c); }
	/* Clear graphics memory */
	for (i=CLICKP1; i<CLICKP2; i++) { clearseg(i); };
	/* Now, turn display back on */
	out(0x3b8, 0x8A);
}

int groff()
{
	int	i;
	char	c;

	out(0x3bf, 0x03); 
	/* Now, set up the 6845 */
	for(i=0;i<12;i++)
	{ c = i; out(0x3b4, c); c = param_t[i]; out(0x3b5, c); }
	/* Now, turn display back on */
	out(0x3b8, 0x28);
}

hg_plot(x,y,c)
int x,y;
char c;
{
	static int prev_color, cycle_count;
	long offset;	/* location in graphics buffer */
	int color, on_bit, off_bit;
	char p;

	/* Colors are special here.  This color code affects 
   	   everything else so we have to be careful.  The color
	   integer is really a mask of the type:
		
		7 6 5 4 3 2 1 0
		L D X X X X X X

	   L = Lit bit.  This bit means that a color of N (0-63)
		will have N dots LIT before cycling over to off
	   D = Dark bit.  Same as lit but cylces N dots DARK before
		a lit bit.

	  Thus:  A color 0 is simply black all of the time, 1 is
		always white, and a color like 0xC4 means 
		
		Lit and Dark on with a 4 dot cycle for both.  If *
		is an "on" pixel and - is "off", a line with color E4
		would be:

		C4: ****----****----****----
		84: ****-****-****-****-****
		44: ----*----*----*----*----
		04: ************************
	*/
	if (x<0 || x>719) return(-1);
	if (y<0 || y>347) return(-1);
 	offset=y_offset[y]+(x>>3)+0x8000;
	p = herc_base[offset];
	/* Is it simply colors 0-63 -- if so just do it */
	if (c > 0 && c < 64)
	{ p |= masks[x%8]; herc_base[offset] = p; return(0); }; 
	if (c == 0)
	{ p &= (~masks[x%8]); herc_base[offset] = p; return(0); }; 
	/* If it's 64+ we have special patterns */
	if (prev_color == c)	/* We've been here before */
	{
		color = (c & 63);	/* Get color value itself */
		/* See if we do an "on" cycle */
		on_bit = (c & 0xC0) >> 7;
		off_bit = (c & 0x40) >> 6;
		if ( on_bit && (!(off_bit)))
		{
			/* Plot of L only */
			if (cycle_count == 0)
			{
				p &= (~masks[x%8]); herc_base[offset] = p;
				cycle_count = color;
			} else
			{
				p |= masks[x%8]; herc_base[offset] = p;
			};
			cycle_count --;
		};
		if ( off_bit && (!(on_bit)))
		{
			/* Plot of D only */
			if (cycle_count < 0)
			{
				p &= (~masks[x%8]); herc_base[offset] = p;
				cycle_count = color * -1;
			} else
			{
				p |= masks[x%8]; herc_base[offset] = p;
			};
			cycle_count ++;
		};
		if (on_bit && off_bit)
		{
			/* on & off cycle */
			if (cycle_count < 0)
			{
				 p &= (~masks[x%8]); herc_base[offset] = p;
				 cycle_count ++;
				 if (cycle_count >= 0)
				 { cycle_count = color; };
			} else
			{
				p |= masks[x%8]; herc_base[offset] = p;
				cycle_count --;
				if (cycle_count < 0)
				{ cycle_count = color * -1; };
			};
		};
	} else
	{
		prev_color = c;
		color = (c & 63);	/* Get color value itself */
		cycle_count = color;
		on_bit = (c & 0xC0) >> 7;
		off_bit = (c & 0x40) >> 6;
		if (on_bit) 
		{ cycle_count = color; };
		if (off_bit && (!(on_bit)))
		{ cycle_count = color * -1; };
	};
	return(0);
}

hg_plotchar(a,b,v)
int a, b, v;
{
	int i,x,y,index;
	long offset;
	char mask, p;
	
	if (( a < 0) || (a > 89)) { return(-1); };
	if (( b < 0) || (b > 42)) { return(-1); };
	x=a*8; y=b*8;
	index=(int)v*8;
	for (i=0;i<8;i++)
	{
		offset=y_offset[y]+(x>>3) + 0x8000;
		p = herc_base[offset];
		mask=hercchars[index+i];
		p ^= mask; herc_base[offset] = p; y++;
	};
}

# define max(a,b)	(((a) > (b)) ? (a) : (b))
# define abs(a)		(((a) < 0) ? (-a) : (a))
# define sign(a)	((a) > 0 ? 1 : ((a) == 0 ? 0 : (-1)))
# define TRUE		(-1)
# define FALSE		(0)
hg_line(x1,y1,x2,y2,c)
int x1,y1,x2,y2,c;
{
	int ix, iy, i, inc, x,y, dx, dy, plot, plotx, ploty;
	
	dx=x2-x1; dy=y2-y1; 
	ix = abs(dx);	iy = abs(dy);
	inc = max(ix, iy);
	plotx = x1;	ploty = y1;
	x = y = 0;
	for (i=0;i<=inc;++i)
	{
			x += ix;	y += iy;
			plot = FALSE;
			if (x > inc)
			{ 
				plot = TRUE;
				x -= inc;
				plotx += sign(dx);
			};
			if (y > inc)
			{
				plot = TRUE;
				y -= inc;
				ploty += sign(dy);
			};
			if (plot) { hg_plot(plotx, ploty, c); };
	};
}

int	hg_box(x1,y1,x2,y2,c)
int	x1,y1,x2,y2,c;	/* Plot box with corners at x1,y2 and x2,y2 as */
{			/* top left and bottom right corners           */

	int	dx,dy;

	dx = x2 - x1;   
	dy = y2 - y1;	/* Get values for hg_line lengths */
	hg_line(x1,y1,x1+dx,y1,c);		/* Right	*/
	hg_line(x1+dx,y1,x1+dx,y2,c);		/* Down		*/
	hg_line(x1+dx,y2,x1,y2,c);		/* Left		*/
	hg_line(x1,y2,x1,y1,c);			/* Back up	*/
	return(0);
}

hgopen(dev, flags)
int	dev, flags;
{
	if (herc_state) /* Make sure we're not already open */
	{ u.u_error = EMFILE; return; } else { herc_state = 1; };
	herc_base = gstokv(79); 	/* Get screen memory */
	gron(); 
	u.u_error = 0; return;
}

hgclose(dev)
int	dev;
{
	if (!herc_state)
	{ u.u_error = ENXIO; return; };
	groff(); herc_state = 0;
	u.u_error = 0; return;
}

hgioctl(dev, command, args, mode)
int	dev, command, mode;
herc_args	*args;
{
	herc_args t;
	int	i, xs, ys;
	char	sb[90];

	copyin(args, &t, sizeof(t));
	switch(command)
	{
		case HERC_TEXT : 
		case HERC_GRAF : { flip_page(command); break; };
		case HERC_CLEAR: { 
					for (i=CLICKP1; i<CLICKP2; i++)
					{ clearseg(i); }; break;
				 };
		case HERC_PLOT : { hg_plot(t.x1, t.y1, t.c); break; };
		case HERC_LINE : {
					hg_line(t.x1, t.y1, t.x2, t.y2, t.c);
					break;
				 };
		case HERC_BOX  : {
					hg_box(t.x1, t.y1, t.x2, t.y2, t.c);
					break;
				 };
		case HERC_CHAR : {
					hg_plotchar(t.x1, t.y1, t.c);
					break;
				 };
		case HERC_STR  : {
				 	copyin(t.str, sb, t.c);
				 	xs = t.x1; ys = t.y1;
					for (i = 0; i<t.c; i++)
					{
						hg_plotchar(xs, ys, sb[i]);
						xs++;
					};
					break;
				 };
	};
}
@\Rogue\Monster\
else
  echo "shar: Will not over write herc.c"
fi
if `test ! -s herc.h`
then
echo "x - herc.h"
cat > herc.h << '@\Rogue\Monster\'

/* ================= Hercules Graphics Code =========================== */
/* These routines provide basic line drawing graphics for the hercules  */
/* monographics card under Microport Unix Sys V/AT 2.3.  Written by     */
/* John Antypas 8/10/88 						*/
/* Property of Microport Inc.                                           */
/*                                                                      */
/* ==================================================================== */

#define	HERC_TEXT	0x01	/*Switch to text mode	*/
#define	HERC_GRAF	0x02	/*Switch to graphics 	*/
#define	HERC_CLEAR	0x03	/*Clear graphics screen	*/
#define	HERC_PLOT	0x04	/*Plot dot on screen	*/
#define	HERC_LINE	0x05	/*Draw line on screen 	*/
#define	HERC_BOX	0x06	/*Draw a box		*/
#define	HERC_CHAR	0x07	/*Plot character 	*/
#define	HERC_STR	0x08	/*Write string		*/

#define LITBIT		0x80	/* Lit bit count	*/
#define DARKBIT		0x40	/* Dark bit count	*/

typedef	struct
{
	int	x1, y1, x2, y2;
	int	c;		/* || ascii code || strlen	*/
	char	*str;		/* String			*/
} herc_args;
@\Rogue\Monster\
else
  echo "shar: Will not over write herc.h"
fi
if `test ! -s herc.readme`
then
echo "x - herc.readme"
cat > herc.readme << '@\Rogue\Monster\'
	A Hercules Graphics Driver for Microport Unix Sys V/AT

		Driver translation by John Antypas

			...!ucsd!ucrmath!soft21!jantypas
			jantypas at Soft21.Riverside.CA.US
			jantypas%soft21.Riverside.CA.US at Garp.MIT.EDU


The code that follows provides simple line graphics for a hercules monographics
card under Microport Unix Sys V/AT.  This code should work with any Sys V/AT
version, but I have only tested it on 2.3.1L.  It provides the full screen
window for graphics (720 x 350) and handles the details of switching the 
console out etc.

The code does NOT lock the console out!  ANY uuer openning /dev/herc will
cause the console to flip to graphics mode.  For this reason, one should only 
use graphics via a library which checks to see if that users termianl
is the console itself to prevent anyone from disturbing the work in progress
on the console displays!

When /dev/herc is openned, the console switches from text to graphics mode.
The screen will then clear.  Commands are sent to the driver via ioctl() calls.

HERC_TEXT	- Switch to text mode
HERC_GRAF	- Switch to graphics mode
HERC_CLEAR	- Clear graphics screen
HERC_PLOT	- Plot a dot on the screen of color C
HERC_LINE	- Draw a line on the screen of color C
HERC_BOX	- Draw a box
HERC_CHAR	- Plot a character on the screen (90 x 44)
HERC_STR	- Write a string via HERC_CHAR calls

All arguments are passed through a structure herc_args in the header file.
Not all paramters are required for all calls.  The color integer can be used
for many things ranging from a color code to a character code for CHAR calls or
the string length code in the HERC_STR call.  A test program is provided that
shows these in action.  

Some warnings.  Driver space is always scarce so no real checking is done
on parameters beyond those which, if they we're wrong, would panic the kernel.
Screen size is:

For graphics: 0 -> 719 X 0 -> 347
For Text:     0 -> 89 X 0 -> 42  { Characters 8x8 }

My master file and dfile look like this (choose your own device numbers)

herc	0	oci	c	hg	0	15	1	{ Master }
herc	0	1						{ dfile }

Improvements:

The documentation needs work, I'm working on a user C library interface
that also checks to see if the console is in use.

Changes:

Feel free to make any changes you like so long as I get copies of them.
(I want all of that neat stuff too!)  For those of you who
remember the earlier driver, I removed the string parsing because (a) why 
waste kernel time and (b) no one liked that idea anyway.. so I took it out.

The code (how ever crude) is entirely property of Microport Inc.  You are 
welcome to make any changes as you desire so long as you don't do anything
which would cause myself or John Sully, Keith, Mr. Plocher or any of the other
fine folks at Microport to lose money while you or others make it.  In other
words, D O N ' T  S E L L  T H I S ! ! !  

The test program included (herctest.c) must be compiled in the large model as
it uses the HERC_STR call.  This call passes a character pointer in the
argument structure.  Since the kernel is large model, when a program uses
this call, it, too, must be in the large model.  (cc -Ml herctest.c -o test -lm)

The driver understands color "types".  See hg_plot in the source for details.

@\Rogue\Monster\
else
  echo "shar: Will not over write herc.readme"
fi
if `test ! -s herctest.c`
then
echo "x - herctest.c"
cat > herctest.c << '@\Rogue\Monster\'
# include <stdio.h>
# include <fcntl.h>
# include <sys/herc.h>
# include <math.h>

main(argc, argv)
int	argc;
char	*argv[];
{
	int	fd, i;
	char	strbuff[90];
	herc_args	hv;

	fd = open("/dev/herc", O_WRONLY);
	ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
	/* Do some random dots */
	hv.x1 = 35 ; hv.y1 = 35; hv.c = strlen("Some random dots.");
	hv.str = "Some random dots.";
	ioctl(fd, HERC_STR, &hv);
	for (i = 0; i < 100; i ++)
	{
		hv.x1 = abs(lrand48() % 719);
		hv.y1 = abs(lrand48() % 347);
		hv.c = 1;
		ioctl(fd, HERC_PLOT, &hv);
	};
	sleep(10);
	/* Do some random lines */
	ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
	hv.x1 = 35 ; hv.y1 = 35; hv.c = strlen("Some random lines.");
	hv.str = "Some random lines.";
	ioctl(fd, HERC_STR, &hv);
	for (i = 0; i < 50; i ++)
	{
		hv.x1 = abs(lrand48() % 719);
		hv.y1 = abs(lrand48() % 347);
		hv.x2 = abs(lrand48() % 719);
		hv.y2 = abs(lrand48() % 347);
		hv.c = 0x01;
		ioctl(fd, HERC_LINE, &hv);
	};
	sleep(10);
	/* Do some random boxes */
	ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
	hv.x1 = 35 ; hv.y1 = 35; hv.c = strlen("Some random boxes.");
	hv.str = "Some random boxes.";
	ioctl(fd, HERC_STR, &hv);
	for (i = 0; i < 30; i ++)
	{
		hv.x1 = abs(lrand48() % 719);
		hv.y1 = abs(lrand48() % 347);
		hv.x2 = abs(lrand48() % 719);
		hv.y2 = abs(lrand48() % 347);
		hv.c = 0x01;
		ioctl(fd, HERC_BOX, &hv);
	};
	sleep(10);
	/* Some characters drawn the hard way --- char. by char. */
	ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
	for (i= 0; i< 30; i++)
	{
		hv.x1 = 5+(i*2); hv.y1 = 20; hv.c = i+40;
		ioctl(fd, HERC_CHAR, &hv);
	};
	sleep(10);
	/* Do some random boxes but show color "types" */
	for (i = 0; i < 10; i ++)
	{
		sprintf(strbuff, "Boxes with code %d", LITBIT+DARKBIT+(i*5));
		ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
		hv.x1 = 35 ; hv.y1 = 35;
		hv.c = strlen(strbuff);
		hv.str = strbuff;
		ioctl(fd, HERC_STR, &hv);
		hv.c = strlen("Lit and dark bits set.  See hgplot in source.");
		hv.str = "Lit and dark bits set.  See hgplot in source.";
		hv.x1 = 20 ; hv.y1 = 37;
		ioctl(fd, HERC_STR, &hv);
		hv.x1 = 150;
		hv.y1 = 50;
		hv.x2 = 600;
		hv.y2 = 250;
		hv.c = LITBIT+DARKBIT+(5*i);		/* Lit and dark bits */
		ioctl(fd, HERC_BOX, &hv);
		sleep(1);
	};
	sleep(10);
	/* Finish up */
	ioctl(fd, HERC_CLEAR, &hv);	/* Clear screen */
	for (i= 0; i<50; i++)
	{
		hv.x1 = 50+i*2;
		hv.y1 = 50+i*2;
		hv.x2 = 300-i*2;
		hv.y2 = 300-i*2;
		hv.c = i*2+192;
		ioctl(fd, HERC_BOX, &hv);
	};
	hv.str = "That's all folks!";
	hv.c = strlen("That's all folks!");
	hv.x1 = 55; hv.y1 = 35;
	ioctl(fd, HERC_STR, &hv);
	sleep(10);	
	close(fd);
}	
@\Rogue\Monster\
else
  echo "shar: Will not over write herctest.c"
fi
# to concatenate archives, remove anything after this line
exit 0



More information about the Comp.unix.microport mailing list