Article View: comp.sources.bugs
Article #2159Hercules fix for GL Graphics Library
From: Wietse Z. Venema
Date: Mon, 27 Mar 1989 22:06
Date: Mon, 27 Mar 1989 22:06
109 lines
3491 bytes
3491 bytes
I had some difficulty using the gl graphics libary with a vanilla
Hercules graphics adapter clone. The following replacement for
setmode.c may help if you experience the same problem. It may need
minor changes if your system does not run Microport System-V/AT.
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: hercmode.c
# Wrapped by wietse@wzv on Mon Mar 27 21:58:27 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'hercmode.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hercmode.c'\"
else
echo shar: Extracting \"'hercmode.c'\" \(1571 characters\)
sed "s/^X//" >'hercmode.c' <<'END_OF_FILE'
X/*
X * Switch hercules graphics/text mode for Microport SV/AT.
X * To be linked with mode.c (part of the gl distribution).
X * Only supports modes 2 (text) and 8 (page 0 graphics).
X *
X * W.Z. Venema (wietse@wzv.UUCP)
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/io_op.h>
X
Xint fd;
X
Xextern int errno;
X
Xchar gmode[12] = { /* graphics mode */
X 0x35, 0x2d, 0x2e, 0x07,
X 0x5b, 0x02, 0x57, 0x57,
X 0x02, 0x03, 0x00, 0x00
X};
X
Xchar tmode[12] = { /* text mode */
X 0x61, 0x50, 0x52, 0x0f,
X 0x19, 0x06, 0x19, 0x19,
X 0x02, 0x0d, 0x0b, 0x0c
X};
X
Xsetmode(mode)
Xint mode;
X{
X register int i;
X
X if ((fd = open("/dev/mem", 2)) < 0) {
X fprintf(stderr, "mode: open of /dev/mem failed\n");
X perror("mode");
X exit(1);
X }
X switch (mode) {
X case 2:
X outb(0x3bf, 0x03); /* "hgc full" */
X for (i = 0; i < 12; i++) {
X outb(0x3b4, i);
X outb(0x3b5, tmode[i]);
X }
X outb(0x3b8, 0x28); /* enable blinker */
X break;
X case 8:
X outb(0x3bf, 0x03); /* "hgc full" */
X for (i = 0; i < 12; i++) {
X outb(0x3b4, i);
X outb(0x3b5, gmode[i]);
X }
X outb(0x3b8, 0x0A); /* enable graphics page 0 */
X break;
X default:
X fprintf(stderr, "legal modes: 2 or 8\n");
X sleep(3); /* pause */
X exit(1);
X /* NOTREACHED */
X }
X}
X
Xoutb(portno, data)
Xint portno;
Xint data;
X{
X io_op_t iop;
X
X iop.io_port = portno;
X iop.io_byte = data;
X if (ioctl(fd, IOCIOP_WB, &iop) < 0) {
X fprintf(stderr, "mode: error on IOCIOP_WB\n");
X perror("mode");
X exit(1);
X }
X}
END_OF_FILE
if test 1571 -ne `wc -c <'hercmode.c'`; then
echo shar: \"'hercmode.c'\" unpacked with wrong size!
fi
# end of 'hercmode.c'
fi
echo shar: End of shell archive.
exit 0
--
work: wswietse@eutrc3.uucp | Eindhoven University of Technology
work: wswietse@heitue5.bitnet | Mathematics and Computing Science
home: wietse@wzv.uucp | 5600 MB Eindhoven, The Netherlands
Technical Details
Message-ID:
<256@wzv.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!hp4nl!eutrc3!wzv!wietseShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!hp4nl!eutrc3!wzv!wietse From: wietse@wzv.UUCP (Wietse Z. Venema) Newsgroups: comp.sources.bugs Subject: Hercules fix for GL Graphics Library Message-ID: <256@wzv.UUCP> Date: 27 Mar 89 22:06:54 GMT Organization: Eindhoven University of Technology, The Netherlands Lines: 109