Subject: v18i060: GL Graphics Library for AT-clone Unix, Part02/07 Newsgroups: comp.sources.unix Sender: sources Approved: rsalz@uunet.UU.NET Submitted-by: umix!m-net!dtlewis!lewis Posting-number: Volume 18, Issue 60 Archive-name: gl_plot/part02 # To recover, type "sh archive" echo restoring Makefile sed 's/^X//' > Makefile < BEGINNING OF USER CONFIGURATIONS <=== X X# Compiler flags: X# X# For Microport 286, use: XCFLAGS = -Ml -O X# For Xenix 286, use: X# (Warning: uSoft optimizer may mess you up; don't use it...) X# CFLAGS = -Ml -Me X# For Xenix 286 cross compile to MS-DOS target, use: X# CFLAGS = -Ml -Me -dos X X# Link library flags: X# X# For UNIX, use the math library: XLIBS = -lm X# For MS-DOS target, no math library needed: X# LIBS = X X# Suffix to stick on the end of the executable program: X# X# For UNIX, no suffix: XEXE_SUFFIX= X# For MS-DOS target, executables are called *.EXE: X# EXE_SUFFIX=.exe X X# ===> END OF USER CONFIGURATIONS <=== X XHDR = bitmaps.h cellfont.h config.h font.h graphics.h modes.h gl.h gf_types.h X XOBJ = g_clear.o n_mvpen.o n_draw.o n_box.o n_line.o p_wr_pix.o g_init.o n_gfchar.o n_gfstr.o g_finish.o c_cellch.o c_cellst.o c_cursor.o g_pixctl.o n_curves.o n_point.o plot.o g_fntctl.o xform.o trig.o machdep.o g_print.o X X# Default make operations, for Microport System V/AT Xuport: gl.a demo xdemo modeprog X X# Make operations for Xenix 286 Xxenix: gl.a demo xdemo X X# Make operations for Xenix cross compile to MS-DOS target Xdos: gl.a demo xdemo X Xclean: X rm \$(OBJ) X rm mode.o setmode.o X rm demo.o testpat.o xdemo.o X Xclobber: X rm modeprog demo xdemo gl.a X rm \$(OBJ) X rm mode.o setmode.o X rm demo.o testpat.o xdemo.o X Xmodeprog: mode.c setmode.c X cc -o modeprog\$(EXE_SUFFIX) mode.c setmode.c X chmod +x mode.sh X # X # If you have an EGA or CGA, you can use mode.sh instead of X # the mode.c program (mv mode.sh mode)." If you have an Everex X # Edge, use mode.c (mv modeprog mode). For other adapters, you X # may have to modify mode.c. A slightly modified version of X # mode.c may be required for standard hercules graphics. X # X # For Xenix 286, use mode.xenix (edit to taste). X # X # If you use mode.c, you must make the executable (mode) suid and X # owned by root. Put it in a safe path, of course. X # For example, sign as root, then: X # X # \$ mv modeprog /usr/bin/mode X # \$ chmod 4555 /usr/bin/mode X # X # Don't forget to create your video shared memory using shmcreate(1) X # (Microport only). This should be in your /etc/rc.d/shm.rc file. X # X # Try running demo and xdemo to see how things work. X Xgl.a: \$(OBJ) $(HDR) X ar rv gl.a \$(OBJ) X sh -c "if test -x /usr/bin/ranlib -o -x /bin/ranlib;then ranlib gl.a;fi" X Xdemo: demo.o testpat.o gl.a X cc -o demo\$(EXE_SUFFIX) $(CFLAGS) demo.o testpat.o gl.a $(LIBS) X Xxdemo: xdemo.o gl.a X cc -o xdemo\$(EXE_SUFFIX) $(CFLAGS) xdemo.o gl.a $(LIBS) X XxX--EOF--XxX echo restoring g_finish.c sed 's/^X//' > g_finish.c < X#if MIX_C X#else X#include X#include X#if TCC X#else X#include X#endif /* TCC */ X#endif /* MIX_C */ X#if MS_DOS Xextern int g_setmod(); Xextern int g_text; X#else X#include X#endif /* MS_DOS */ X#if HAS_SIG X#include X#endif /* HAS_SIG */ X#include "bitmaps.h" X#include "graphics.h" X#include "modes.h" X Xextern struct GL_graphics graphics; Xextern int errno; Xextern int g_clear(); Xextern char *getenv(); X#if HAS_SIG Xextern SIG_TYPE (*gl_last_int_handler)(); X#endif /* HAS_SIG */ X Xstatic FILE *fhandle; X Xextern int IBM_send_print(); Xextern int LJ_send_print(); X Xstatic int open_print() X{ X char printprog[60]; X char *envptr; X int istat; X /* Open a pipe to the print spooler (or straight to printer) */ X X /* Use the environment variable PLOTDEV if set. */ X X strcpy(printprog, PRINTPROG); X strcat(printprog, " "); X strcat(printprog, LP_DEV_FLAG); X#if HAS_ENV X if ((envptr = getenv(GL_PLOT_DEV)) != NULL) { X strcat(printprog, envptr); X } X else { X strcat(printprog, PRINTDEV); X } X#else X /* Some systems do not understand getenv() */ X strcat(printprog, PRINTDEV); X#endif /* HAS_ENV */ X X#if HAS_PIPES /* Pipe to a print spooler program. */ X if ((fhandle = popen(printprog, "w")) == NULL) { X fprintf(stderr, "%s: Error piping to %s\n", MODULE,printprog); X return(1); X } X#else /* No pipes; write directly to the printer device. */ X#if HAS_STDPRN /* Use predefined value of "stdprn" */ X fhandle = stdprn; X#else /* Hope that stream I/O works for the printer device */ X if ((fhandle = fopen(DOSPRINTER, "w")) == NULL) { X fprintf(stderr, "%s: Error opening %s\n", MODULE,DOSPRINTER); X return(1); X } X#endif /* HAS_STDPRN */ X#endif /* HAS_PIPES */ X return(0); X} X Xstatic int close_print() X{ X int istat; X#if HAS_PIPES X if ((istat=pclose(fhandle)) < 0) return(istat); X#else /* No pipe to close, but close the stream to printer if open */ X#if HAS_STDPRN /* Don't need to do anything -- stdprn stays open */ X#else /* Close the stream pointing at the printer */ X if ((istat=fclose(fhandle)) < 0) return(istat); X#endif /* HAS_STDPRN */ X#endif /* HAS_PIPES */ X return(0); X} X Xint g_finish() X{ X int istat; X X graphics.initialized = FALSE; X X#if HAS_SIG X#if DO_CLEANUP X /* Restore the SIGINT signal handler that was in effect prior */ X /* to the call to g_init(). */ X signal(SIGINT, gl_last_int_handler); X#endif /* DO_CLEANUP */ X#endif /* HAS_SIG */ X X switch (graphics.grafmode) { X X case CGA_HI_RES_MODE: X /* Erase graphics memory. */ X if (g_clear()) return(1); X /* Detach the shared memory segment. */ X#if SVAT X if (shmdt(graphics.cgamem) < 0) return(errno); X#endif /* SVAT */ X break; X X case CGA_COLOR_MODE: X /* Erase graphics memory. */ X if (g_clear()) return(1); X /* Detach the shared memory segment. */ X#if SVAT X if (shmdt(graphics.cgamem) < 0) return(errno); X#endif /* SVAT */ X break; X X case EGA_COLOR_MODE: X /* Erase graphics memory. */ X if (g_clear()) return(1); X /* Detach the shared memory segment. */ X#if SVAT X if (shmdt(graphics.egamem) < 0) return(errno); X#endif /* SVAT */ X break; X X case HERC_P0_MODE: X case HERC_P1_MODE: X /* Erase graphics memory. */ X if (g_clear()) return(1); X /* Detach the shared memory segment. */ X#if SVAT X if (shmdt(graphics.hercmem) < 0) return(errno); X#endif /* SVAT */ X break; X X case IBM_PRINTER: X X /* Print the buffer */ X if ((istat=open_print()) !=0) return(istat); X if ((istat=IBM_send_print(fhandle)) !=0) return(istat); X if ((istat=close_print()) !=0) return(istat); X X /* Free the allocated memory. */ X free(graphics.printbuf1); X free(graphics.printbuf2); X free(graphics.printbuf3); X X break; X X case LJ_PRINTER: X X /* Print the buffer */ X if ((istat=open_print()) !=0) return(istat); X if ((istat=LJ_send_print(fhandle)) !=0) return(istat); X if ((istat=close_print()) !=0) return(istat); X X /* Free the allocated memory. */ X free(graphics.lj_buf1); X free(graphics.lj_buf2); X free(graphics.lj_buf3); X X break; X X default: X return(1); X } X X /* Tell the hardware to go back to default (text) mode, using */ X /* the MODEPROG program. The default action of the mode */ X /* program is assumed to be text mode. */ X X if (graphics.grafmode <= MAXVIDEO) { X#if MS_DOS X g_setmod(g_text); X#else X system(MODEPROG); X#endif /* MS_DOS */ X } X X return(0); X} X X XxX--EOF--XxX echo restoring g_print.c sed 's/^X//' > g_print.c < X#include "config.h" X#if MS_DOS X#include X#endif /* MS_DOS */ X#if XENIX_286 X#include X#include X#include X#endif /* XENIX_286 */ X#include "bitmaps.h" X#include "gf_types.h" X#include "graphics.h" X#include "modes.h" X X/* Use BIOS output for printer on MS-DOS. */ X#if MS_DOS Xextern int bios_print(); X#define FWRITE(a,b,c,d) bios_print(a,b,c) X#else X#define FWRITE(a,b,c,d) fwrite(a,b,c,d) X#endif /* MS_DOS */ X Xextern struct GL_graphics graphics; X X#define FORM_FEED (014) X X#define EPSON_START_GRAPHICS 033, 'A', 07, 033, 02 X#define IBM_START_GRAPHICS 033, '1' X#define IBM_PAGE_END 033, 'A', 014, 033, 02 X#define IBM_LINE_START 033, 'L', 0300, 03 X#define IBM_LINE_END 015, 012 X Xstatic char IBM_pg_top[] = {EPSON_START_GRAPHICS, IBM_START_GRAPHICS}; Xstatic char IBM_pg_end[] = {IBM_PAGE_END}; Xstatic char IBM_pg_ff_end[] = {IBM_PAGE_END, FORM_FEED}; Xstatic char IBM_ln_start[] = {IBM_LINE_START}; Xstatic char IBM_ln_end[] = {IBM_LINE_END}; X X#define LJ_RESET 033, 'E' X#define LJ_150_DPI 033, '*', 't', '1', '5', '0', 'R' /* 150 dpi graphics */ X#define LJ_CUR_HOME 033, '&', 'a', '3', 'C' /* Cursor to column 3 */ X#define LJ_START_GRAPHICS 033, '*', 'r', '1', 'A' X#define LJ_XFER_GRAPHICS 033, '*', 'b', '1', '4', '0', 'W' /* 140 bytes */ X#define LJ_END_GRAPHICS 033, '*', 'r', 'B' X Xstatic char LJ_pg_top[]={LJ_RESET, LJ_150_DPI, LJ_CUR_HOME, LJ_START_GRAPHICS}; Xstatic char LJ_pg_end[] = {LJ_END_GRAPHICS, LJ_RESET}; Xstatic char LJ_pg_ff_end[] = {LJ_END_GRAPHICS, LJ_RESET}; Xstatic char LJ_ln_start[] = {LJ_XFER_GRAPHICS}; Xstatic char LJ_ln_end[] = {0}; /* No line end needed */ X X/* A do-nothing function. The printer function pointers will initially */ X/* point to this, just to avoid core dumps later on. */ X Xstatic int null_function(fp) XFILE *fp; X{ X return(0); X} X X/* For printers, the following four functions send data required to */ X/* start the print, end the print, start each line, and end each line. */ X/* These function pointers are defined globally here, and are used to */ X/* send data to printers in g_finish(). These are initialized to a */ X/* safe value now, and set to the appropriate values for the current */ X/* graphics mode later in g_init(). */ X Xint (*pr_head)() = null_function; Xint (*pr_tail)() = null_function; Xint (*pr_lnst)() = null_function; Xint (*pr_lnend)() = null_function; X X/* Following is the device specific code for each printer (sorry, there */ X/* is only one working so far, but I like to plan ahead). */ X X/* Start of IBM or Epson compatible dot matrix printer code. */ X Xint IBM_head(fp) XFILE *fp; X{ X /* Begin graphics mode; set line spacing */ X if((FWRITE(IBM_pg_top,sizeof(char),sizeof(IBM_pg_top),fp)) < X sizeof(IBM_pg_top)) return(1); X else return(0); X} X Xint IBM_tail(fp) XFILE *fp; X{ X /* End of page, begin text mode */ X#if HAS_PIPES X if((FWRITE(IBM_pg_end,sizeof(char),sizeof(IBM_pg_end),fp)) < X sizeof(IBM_pg_end)) return(1); X else return(0); X#else X /* If we are not piping to a print spooler program, then we */ X /* need to supply our own form feed command. */ X if((FWRITE(IBM_pg_ff_end,sizeof(char),sizeof(IBM_pg_ff_end),fp)) < X sizeof(IBM_pg_ff_end)) return(1); X else return(0); X#endif /* HAS_PIPES */ X} X Xint IBM_lnst(fp) XFILE *fp; X{ X /* Start a line of graphics data */ X if((FWRITE(IBM_ln_start,sizeof(char),sizeof(IBM_ln_start),fp)) < X sizeof(IBM_ln_start)) return(1); X else return(0); X} X Xint IBM_lnend(fp) XFILE *fp; X{ X /* End line of graphics data */ X if((FWRITE(IBM_ln_end,sizeof(char),sizeof(IBM_ln_end),fp)) < X sizeof(IBM_ln_end)) return(1); X else return(0); X} X Xint IBM_send_print(fp) XFILE *fp; X#define MODULE "IBM_send_print" X{ X int idx; X X /* Dump the print image to the file */ X X /* Set line feed pitch for graphics */ X X (*pr_head)(fp); X X /* Write the lines of data (3 buffers full) */ X for (idx=0; idxbuf[idx][0]), X sizeof(char), PRINTDENSITY, fp); X (*pr_lnend)(fp); X } X for (idx=0; idxbuf[idx][0]), X sizeof(char), PRINTDENSITY, fp); X (*pr_lnend)(fp); X } X for (idx=0; idxbuf[idx][0]), X sizeof(char), PRINTDENSITY, fp); X (*pr_lnend)(fp); X } X X /* Set line feed pitch back for text */ X X if ((*pr_tail)(fp)) { X fprintf(stderr,"%s: unable to write to printer\n",MODULE); X return(1); X } X return(0); X} X X/* End of IBM or Epson compatible dot matrix printer code. */ X X X/* Start of Laserjet+ printer code. */ X Xint LJ_head(fp) XFILE *fp; X{ X /* Begin graphics mode; set line spacing */ X if((FWRITE(LJ_pg_top,sizeof(char),sizeof(LJ_pg_top),fp)) < X sizeof(LJ_pg_top)) return(1); X else return(0); X} X Xint LJ_tail(fp) XFILE *fp; X{ X /* End of page, reset and eject page */ X if((FWRITE(LJ_pg_end,sizeof(char),sizeof(LJ_pg_end),fp)) < X sizeof(LJ_pg_end)) return(1); X else return(0); X} X Xint LJ_lnst(fp) XFILE *fp; X{ X /* Start a line of graphics data */ X if((FWRITE(LJ_ln_start,sizeof(char),sizeof(LJ_ln_start),fp)) < X sizeof(LJ_ln_start)) return(1); X else return(0); X} X Xint LJ_lnend(fp) XFILE *fp; X{ X /* End line of graphics data */ X return(0); X} X Xint LJ_send_print(fp) XFILE *fp; X#undef MODULE X#define MODULE "LJ_send_print" X{ X int idx; X X /* Dump the print image to the file */ X X /* Start page of graphics */ X X (*pr_head)(fp); X X /* Write the lines of data (3 buffers full) */ X for (idx=0; idxbuf[idx][0]), X sizeof(char), LJ_BYTES_PER_LINE, fp); X (*pr_lnend)(fp); X } X for (idx=0; idxbuf[idx][0]), X sizeof(char), LJ_BYTES_PER_LINE, fp); X (*pr_lnend)(fp); X } X for (idx=0; idxbuf[idx][0]), X sizeof(char), LJ_BYTES_PER_LINE, fp); X (*pr_lnend)(fp); X } X X /* End of page */ X X if ((*pr_tail)(fp)) { X fprintf(stderr,"%s: unable to write to printer\n",MODULE); X return(1); X } X return(0); X} X X/* End of Laserjet+ printer code. */ X X XxX--EOF--XxX echo restoring mode.c sed 's/^X//' > mode.c < X#include "config.h" X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int setmode(); X int modevalue, stat; X char *inbuf[20]; X X if (argc > 2) { X printf("Usage: mode n\n"); X exit(0); X } X X else if (argc == 2) { X if (sscanf(argv[1],"%d",&modevalue) != 1) { X printf("Unknown mode %s\n",argv[1]); X exit(1); X } X setmode(modevalue); X } X else if (argc == 1) { X#ifdef DEBUG X for ( ; ; ) { X stat=scanf("%d", &modevalue); X if (stat == EOF) exit(0); X /* Clear input stream if bad read. */ X if (stat == 0) gets(inbuf, 20, stdin); X if (stat == 1 && modevalue >= 0 && modevalue <=11) X setmode(modevalue); X } X#endif /* DEBUG */ X setmode(NORMAL_MODE); X } X } XxX--EOF--XxX echo restoring msc.mak sed 's/^X//' > msc.mak < n_mvpen.c < NRM_X_RANGE)) return(1); X if (((graphics.y_cursor = y) < 0) || (y > NRM_X_RANGE)) return(1); X#endif /* INT16 */ X X return(0); X} XxX--EOF--XxX echo restoring p_wr_pix.c sed 's/^X//' > p_wr_pix.c <> 1; X col = x >> 2; X X /* Select a color mask, consisting of four 2 bit patterns. */ X switch (graphics.color) { X case 0: bitmask = 0; X break; X case 1: bitmask = 0x055; X break; X case 2: bitmask = 0x0AA; X break; X case 3: bitmask = 0x0FF; X break; X default:bitmask = 0x0FF; X } X X /* Apply the color mask to the two bit pixel of interest. */ X switch (x & 0x0003) { X case 0: bitmask &= PIX0; X break; X case 1: bitmask &= PIX1; X break; X case 2: bitmask &= PIX2; X break; X case 3: bitmask &= PIX3; X break; X } X X /* Write pixel to the appropriate page for this line. */ X if (y & 0x0001) X switch (graphics.wrt_mode) { X case OR: X (graphics.cgamem)->page2[row][col] X |= bitmask; X break; X case XOR: X (graphics.cgamem)->page2[row][col] X ^= bitmask; X break; X } X else X switch (graphics.wrt_mode) { X case OR: X (graphics.cgamem)->page1[row][col] X |= bitmask; X break; X case XOR: X (graphics.cgamem)->page1[row][col] X ^= bitmask; X break; X } X break; X X case CGA_HI_RES_MODE: X X row = y >> 1; X col = x >> 3; X X bitmask = 0x80; X shiftcount = x & 0x0007; X bitmask = bitmask >> shiftcount; X X if (y & 0x0001) { X switch (graphics.wrt_mode) { X case OR: X (graphics.cgamem)->page2[row][col] X |= bitmask; X break; X case XOR: X (graphics.cgamem)->page2[row][col] X ^= bitmask; X break; X } X } X else { X switch (graphics.wrt_mode) { X case OR: X (graphics.cgamem)->page1[row][col] X |= bitmask; X break; X case XOR: X (graphics.cgamem)->page1[row][col] X ^= bitmask; X break; X } X } X break; X X case EGA_COLOR_MODE: X X col = x >> 3; X X bitmask = 0x80; X shiftcount = x & 0x0007; X bitmask = bitmask >> shiftcount; X X (graphics.egamem)->mem[y][col] |= bitmask; X break; X X case HERC_P0_MODE: X case HERC_P1_MODE: X X row = y >> 2; X col = x >> 3; X X bitmask = 0x80 >> (x & 0x0007); X X switch (y & 0x0003) { X X case 0: X switch (graphics.wrt_mode) { X case OR: X (graphics.hercmem) X ->page1[row][col] X |= bitmask; X break; X case XOR: X (graphics.hercmem) X ->page1[row][col] X ^= bitmask; X break; X } X break; X case 1: X switch (graphics.wrt_mode) { X case OR: X (graphics.hercmem) X ->page2[row][col] X |= bitmask; X break; X case XOR: X (graphics.hercmem) X ->page2[row][col] X ^= bitmask; X break; X } X break; X case 2: X switch (graphics.wrt_mode) { X case OR: X (graphics.hercmem) X ->page3[row][col] X |= bitmask; X break; X case XOR: X (graphics.hercmem) X ->page3[row][col] X ^= bitmask; X break; X } X break; X case 3: X switch (graphics.wrt_mode) { X case OR: X (graphics.hercmem) X ->page4[row][col] X |= bitmask; X break; X case XOR: X (graphics.hercmem) X ->page4[row][col] X ^= bitmask; X break; X } X break; X } X break; X X case IBM_PRINTER: X X col = PRINTDENSITY - y - 1; X X row = (x >> 3); X page = 0; X while (row >= PRINTLINES) { X row -= PRINTLINES; X ++page; X } X X bitmask = 0x80 >> (x & 0x0007); X X switch (page) { X X case 0: /* Page 0 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.printbuf1) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.printbuf1) X ->buf[row][col] X ^= bitmask; X break; X } X break; X case 1: /* Page 1 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.printbuf2) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.printbuf2) X ->buf[row][col] X ^= bitmask; X break; X } X break; X case 2: /* Page 2 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.printbuf3) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.printbuf3) X ->buf[row][col] X ^= bitmask; X break; X } X break; X } X break; X X case LJ_PRINTER: X X col = LJ_BYTES_PER_LINE - (y >> 3) - 1; X row = x; X page = 0; X while (row >= LJ_LINES) { X row -= LJ_LINES; X ++page; X } X X bitmask = 0x01 << (y & 0x0007); X X switch (page) { X X case 0: /* Page 0 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.lj_buf1) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.lj_buf1) X ->buf[row][col] X ^= bitmask; X break; X } X break; X case 1: /* Page 1 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.lj_buf2) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.lj_buf2) X ->buf[row][col] X ^= bitmask; X break; X } X break; X case 2: /* Page 2 */ X switch (graphics.wrt_mode) { X case OR: X (graphics.lj_buf3) X ->buf[row][col] X |= bitmask; X break; X case XOR: X (graphics.lj_buf3) X ->buf[row][col] X ^= bitmask; X break; X } X break; X } X break; X X default: X return(1); X } X return(0); X} XxX--EOF--XxX echo restoring setmode.c sed 's/^X//' > setmode.c < X#if UNIX X#include X#include X#endif X Xextern errno; X Xint fd; X X/* Define the mode register settings. */ Xunsigned char creg[12] = { X 0x2c, 0x28, 0x2d, 0x2d, 0x2a, 0x2e, 0x1e, 0x2d, 0x0e, 0x8e, 0x2d, 0x2d X}; X/* Define the Everex extended graphics register settings */ Xunsigned char ext_graf_reg[12] = { X 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x06, 0x06 X}; X Xunsigned char params[192] = { X/*0*/ 0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c, /* 40x25 b/w */ X 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*1*/ 0x38, 0x28, 0x2d, 0x0a, 0x1f, 0x06, 0x19, 0x1c, /* 40x25 color */ X 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*2*/ 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19, /* 80x25 b/w */ X 0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00, X X/*3*/ 0x71, 0x50, 0x5a, 0x0a, 0x1f, 0x06, 0x19, 0x1c, /* 80x25 color */ X 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*4*/ 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70, /* 320x200 color */ X 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*5*/ 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70, /* 320x200 b/w */ X 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*6*/ 0x38, 0x28, 0x2d, 0x0a, 0x7f, 0x06, 0x64, 0x70, /* 640x200 b/w */ X 0x02, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*7*/ 0x61, 0x50, 0x52, 0x0f, 0x19, 0x06, 0x19, 0x19, /* mono */ X 0x02, 0x0d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00, X X/*8*/ 0x36, 0x2d, 0x2e, 0x07, 0x5a, 0x02, 0x57, 0x57, /* Hercules 720x348 */ X 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X X/*9*/ 0x36, 0x2d, 0x2e, 0x07, 0x5a, 0x02, 0x57, 0x57, /* Hercules 720x348 */ X 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X X/*10*/ 0x9a, 0x84, 0x86, 0x0f, 0x19, 0x06, 0x19, 0x19, /* Everex 132x25b&w */ X 0x02, 0x0d, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, X X/*11*/ 0x9a, 0x84, 0x86, 0x0f, 0x2d, 0x02, 0x2c, 0x2c, /* Everex 132x44b&w */ X 0x02, 0x07, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00 X}; X Xsetmode(mode) Xint mode; X{ X int i, j; X int bport; X int cgaaddr = 0x3d4; /* cga 6845 port address */ X int monoaddr = 0x3b4; /* mda 6845 port address */ X X#if UNIX 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#endif X if ((mode == 2) | (mode == 7) | (mode == 8) | (mode == 9) | X (mode == 10) | (mode == 11)) { X /* Select mono mode on Everex Edge. */ X bport = cgaaddr; X outb(bport+9, 2); /* Extended Graphics Register */ X bport = monoaddr; X } X else { X /* Select CGA mode on Everex Edge. */ X bport = monoaddr; X outb(bport+9, 0); /* Extended Graphics Register */ X bport = cgaaddr; X } X X outb(bport+4, 0); /* Reset mode register */ X X outb(bport+11, 0x06); /* Enable all 64k of Everex X ** Edge video memory, for mono X ** adapter. X */ X X outb(bport+9, ext_graf_reg[mode]); /* set Everex "extended X graphics register" */ X j = (mode+1)*16; X X for(i = mode*16, j = 0; j < 16; i++, j++) { X outb(bport, j); /* select register */ X outb(bport+1, params[i]); /* send value */ X } X X outb(bport+4, creg[mode]); /* enable */ X if (mode == 6) X outb(bport+5, 0x3f); /* set overscan for 640x200 */ X else X outb(bport+5, 0x30); /* set normal overscan */ X close(fd); X return(0); X} X X#if UNIX 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} X#endif X X X#if MS_DOS Xoutb(portno, data) Xint portno; Xint data; X{ X outp(portno,data); X} X#endif X XxX--EOF--XxX echo restoring tcc.mak sed 's/^X//' > tcc.mak <