Graphics Library (part 2 of 5)

Dave Lewis lewis at m2-net.UUCP
Fri Jul 1 14:01:41 AEST 1988


------------------------------  cut here  ------------------------------
# To recover, type "sh archive"
echo restoring box.c
sed 's/^X//' > box.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) box.c 4.3 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Fri Jul  3 23:43:36 EDT 1987
X * dtlewis
X * Routine to draw a box.
X */
X
Xint box(x1,y1,x2,y2)  
X	int x1, y1, x2, y2;
X{
X	int movepen(), draw();
X	if (movepen(x1,y1)) return(1);
X	if (draw(x2,y1)) return(1);
X	if (draw(x2,y2)) return(1);
X	if (draw(x1,y2)) return(1);
X	if (draw(x1,y1)) return(1);
X	return(0);
X}
XxX--EOF--XxX
echo restoring cellchar.c
sed 's/^X//' > cellchar.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) cellchar.c 4.4 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Write a graphics character to the screen.				*/
X/* This routine uses bit mapped character cell fonts.			*/
X/* The character will be drawn such that the current graphics cursor	*/
X/* denotes the upper left corner of the character cell.  The graphics	*/
X/* cursor will be incremented in the X direction by an amount corres-	*/
X/* ponding to one character cell.					*/
X
X/* x and y are in PIXEL COORDINATES, not normalized coordinates.	*/
X/* Tue Mar 15 22:46:31 EST 1988						*/
X/* system5 dtlewis 2 2.3.0-U AT						*/
X
X#include "graphics.h"
X#include "cellfont.h"
X
Xextern struct SVAT_graphics graphics;
X
Xint cellchar(asc_char)  
Xunsigned char asc_char;
X{
X	int x, y, i, j;
X	int write_pix();
X
X	char *bits; 
X
X	/* Get the pixel location, and check for Y out of range.	*/
X	x = conv_x_coord(graphics.x_cursor);
X	y = conv_y_coord(graphics.y_cursor);
X 	if ((y<0) || ((y + Y_CELL_BITS) >= graphics.y_extent)) return(1);
X
X	/* Increment the graphics cursor, check X range.		*/
X	if ((graphics.x_cursor += (int)(NORM_X_RANGE * X_CELL_BITS 
X		/ graphics.x_extent)) < 0)
X		return(1);
X
X	/* Point at the character bit map to print.			*/
X	bits = (char *) &(charcell[asc_char * Y_CELL_BITS]);
X
X	/* Write the character.						*/
X	for (i=y; i < y + Y_CELL_BITS; i++, bits++) {
X		j=x;
X		if (*bits & 0x80) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x40) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x20) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x10) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x08) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x04) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x02) if (write_pix(j,i)) return(1); j++;
X		if (*bits & 0x01) if (write_pix(j,i)) return(1); j++;
X	}
X
X	return(0);
X}
XxX--EOF--XxX
echo restoring cellstr.c
sed 's/^X//' > cellstr.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) cellstr.c 4.3 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Write string of a graphics characters to the screen.			*/
X/* Sat Mar 19 23:56:46 EST 1988						*/
X/* system5 dtlewis 2 2.3.0-U AT						*/
X
X/* Routine to display cell mode text string with upper left corner of	*/
X/* first character located at the current graphics cursor.  The cursor	*/
X/* is incremented as characters are written.				*/
X
X#include <stdio.h>
X
Xint cellstr(strng)  
Xchar strng[];
X{
X	int i;
X	int cellchar();
X	for(i=0; strng[i] != NULL; i++)  {
X		if (cellchar(strng[i])) return(1);
X	}
X	return(0);
X}
X
XxX--EOF--XxX
echo restoring clear.c
sed 's/^X//' > clear.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) clear.c 4.4 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/*
X *	Routine to clear video memory (or print buffer memory).  
X *	dtlewis 6-28-87
X *	Sun Mar 13 21:13:59 EST 1988
X */
X
X#include "graphics.h"
X
Xint clear()  
X{
X	extern struct SVAT_graphics graphics;
X	int i, j;
X	switch (graphics.grafmode) {
X		case CGA_COLOR_MODE:
X			for(i=0; i<100; i++)  {
X				for(j=0; j<80; j++)  {
X					(graphics.cgamem)->page1[i][j] = 0x0;
X					(graphics.cgamem)->page2[i][j] = 0x0;
X				}
X			}
X			break;
X
X		case CGA_HI_RES_MODE:
X			for(i=0; i<100; i++)  {
X				for(j=0; j<80; j++)  {
X					(graphics.cgamem)->page1[i][j] = 0x0;
X					(graphics.cgamem)->page2[i][j] = 0x0;
X				}
X			}
X			break;
X
X		case EGA_COLOR_MODE:
X			for (i=0 ; i<350 ; i++) {
X				for (j=0 ; j<80 ; j++) {
X					(graphics.egamem)->mem[i][j] = 0x0;
X				}
X			}
X			break;
X
X		case HERC_GRAF_MODE:
X			for(i=0; i<87; i++)  {
X				for(j=0; j<90; j++)  {
X					(graphics.hercmem)->page1[i][j] = 0x0;
X					(graphics.hercmem)->page2[i][j] = 0x0;
X					(graphics.hercmem)->page3[i][j] = 0x0;
X					(graphics.hercmem)->page4[i][j] = 0x0;
X				}
X			}
X			break;
X
X		case IBM_PRINTER:
X			for(i=0; i<PRINTLINES; i++)  {
X				for(j=0; j<PRINTDENSITY; j++)  {
X					(graphics.printbuf1)->buf[i][j] = 0x0;
X					(graphics.printbuf2)->buf[i][j] = 0x0;
X					(graphics.printbuf3)->buf[i][j] = 0x0;
X				}
X			}
X			break;
X
X		default:
X			return(1);
X
X	}
X	return(0);
X}
XxX--EOF--XxX
echo restoring cursor.c
sed 's/^X//' > cursor.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) cursor.c 4.3 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Move the graphics cursor as if it were a text cursor.  The cursor	*/
X/* is positioned such that a cell character may be drawn at the		*/
X/* specified character row and column.					*/
X/* This routine uses bit mapped character cell fonts.			*/
X/* The character will be drawn such that the current graphics cursor	*/
X/* denotes the upper left corner of the character cell.			*/
X
X/* Columns and rows are numbered 1 through N, not 0 through N !!!!	*/
X
X#include "graphics.h"
X
Xextern struct SVAT_graphics graphics;
Xextern int movepen();
X
Xint cursor(row, col)
Xint row, col;
X{
X	long xval, yval;
X
X	/* Check valid range for this screen type.			*/
X	if (col <= 0 || col > graphics.cellfont.chars_per_line) return(1);
X	if (row <= 0 || row > graphics.cellfont.lines_per_screen) return(1);
X
X	/* Move the graphics cursor.  Add a 1/2 pixel offset so we will	*/
X	/* always round down to the correct pixel value.		*/
X
X	xval = (col-1) * graphics.cellfont.xtic;	/* The value...	*/
X	xval += NORM_X_RANGE / graphics.x_extent / 2;	/* Plus 1/2 pix	*/
X
X	yval = (row-1) * graphics.cellfont.ytic;
X	yval += NORM_Y_RANGE / graphics.y_extent / 2;
X
X	if (movepen((int)xval, (int)yval)) return(1);
X
X	return(0);
X}
XxX--EOF--XxX
echo restoring draw.c
sed 's/^X//' > draw.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) draw.c 4.4 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/*  Sat Mar 21 22:59:10 EST 1987 */
X/*  dtl 2-8-87
X**
X**	Write a line on the CGA or Hercules adapter.
X**	This routine assumes that the current graphics cursor position is
X**	set, and draws a line to the indicated point.
X*/
X
X#include "graphics.h"
X
Xextern struct SVAT_graphics graphics;
X
Xdraw(new_x_cursor,new_y_cursor)  
X	int new_x_cursor, new_y_cursor;
X{
X
X        /* Draw line from current cursor to new position. */
X        /* Parameters are in normalized 2-D coordinates. */
X
X        int x_dist;     /* Pixel coordinates */
X        int y_dist;     /* Pixel coordinates */
X        int x_start;    /* Pixel coordinates */
X        int y_start;    /* Pixel coordinates */
X        int x_final; 	/* Pixel coordinates */
X        int y_final; 	/* Pixel coordinates */
X        int x_current;  /* Pixel coordinates */
X        int y_current;  /* Pixel coordinates */
X	int x_pixels;	/* X distance in pixels */
X	int y_pixels;	/* Y distance in pixels */
X        long int slope;
X        int offset;
X        long int idx;
X
X	int write_pix();
X
X	/* Check for out of range. */
X
X	if (new_x_cursor < 0 || new_y_cursor < 0) return(1);
X
X        /* Find the starting point in pixel coordinates. */
X  
X        x_current = x_start = conv_x_coord(graphics.x_cursor);
X        y_current = y_start = conv_y_coord(graphics.y_cursor);
X
X        /* Find the end point in pixel coordinates. */
X  
X        x_final = conv_x_coord(new_x_cursor);
X        y_final = conv_y_coord(new_y_cursor);
X
X	/* Find the distances in pixel coordinates. */
X
X        x_dist = x_final - x_start;
X        y_dist = y_final - y_start;
X
X	/* Find the number of pixels to travel in the x any y directions. */
X
X	x_pixels = abs(x_dist);
X	y_pixels = abs(y_dist);
X
X        /* Step across the screen pixel by pixel.  Do this in the x 	*/
X        /* direction if x_dist is greater than y_dist; else, do it in	*/
X        /* the y direction.						*/
X
X        if (x_pixels > y_pixels) {
X                /* Stepwise in x direction. */
X
X                /* Calculate the slope to use (rise over run). */
X                /* Shift left 16 bits for precision. */
X                if (x_dist != 0) slope = (long)y_dist * 0x010000L / 
X                (long)x_dist;
X                else slope = 0x7FFFFFFFL; /* Infinity */
X
X                /* Figure a fudge factor to be used in offsetting the */
X                /* pixels by 1/2 pixel. */
X                if (slope > 0) offset = 1;
X                else if (slope < 0) offset = -1;
X                else offset = 0;
X
X                /* Write the line on the screen. */
X
X                if (x_final - x_start >= 0)  {
X                        if (slope==0)  {
X                                while (x_current <= x_final)
X					if (write_pix(x_current++, 
X						y_current)) return(1);
X                        }
X                        else for (idx=0; idx <= x_pixels; idx++, x_current++)  {
X                                y_current = y_start + (idx*slope/0x08000L 
X                                + offset)/2;
X                                if (write_pix(x_current, y_current))
X					return(1);
X                        }
X                }
X                else  {
X                        if (slope==0)  {
X				while (x_current >= x_final)
X                                        if (write_pix(x_current--, 
X						y_current)) return(1);
X                        }
X                        else for (idx=0; idx <= x_pixels; idx++, x_current--)  {
X                                y_current = y_start - (idx*slope/0x08000L 
X                                + offset)/2;
X                                if (write_pix(x_current, y_current)) 
X					return(1);
X                        }
X                }
X        }
X        else  {
X                /* Stepwise in y direction. */
X
X                /* Calculate the inverse slope to use (run over rise). */
X                /* Shift left 16 bits for precision. */
X                if (y_dist != 0) slope = (long)x_dist * 0x010000L / 
X                (long)y_dist;
X                else slope = 0x7FFFFFFF; /* Infinity */
X
X                /* Figure a fudge factor to be used in offsetting the */
X                /* pixels by 1/2 pixel. */
X                if (slope > 0) offset = 1;
X                else if (slope < 0) offset = -1;
X                else offset = 0;
X
X               /* Write the line on the screen. */
X
X                if (y_final - y_start >= 0)  {
X                        if (slope==0)  {
X                                while (y_current <= y_final)
X                                        if (write_pix(x_current, 
X						y_current++)) return(1);
X                        }
X                        else for (idx=0; idx <= y_pixels; idx++, y_current++)  {
X                                x_current = x_start + (idx*slope/0x08000L 
X                                + offset)/2;
X                                if (write_pix(x_current, y_current))
X					return(1);
X                        }
X                }
X                else  {
X                        if (slope==0)  {
X				while (y_current >= y_final)
X                                        if (write_pix(x_current, 
X						y_current--)) return(1);
X                        }
X                        else for (idx=0; idx <= y_pixels; idx++, y_current--)  {
X                                x_current = x_start - (idx*slope/0x08000L 
X                                + offset)/2;
X                                if (write_pix(x_current, y_current))
X					return(1);
X                        }
X                }
X        }
X        /* Advance the cursor to the new position. */
X        graphics.x_cursor = new_x_cursor;
X        graphics.y_cursor = new_y_cursor;
X	return(0);
X}
XxX--EOF--XxX
echo restoring grafchar.c
sed 's/^X//' > grafchar.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) grafchar.c 4.4 88/06/20";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Write a graphics character to the screen.				*/
X/* Sat Dec 12 12:51:27 EST 1987						*/
X/* system5 dtlewis 2 2.2-U AT						*/
X
X#include "font.h"
X
Xint grafchar(asc_char,x,y,vsize,hsize)  
Xunsigned char asc_char;
Xint x, y, vsize, hsize;
X{
X	int x1, y1, x2, y2, i;
X	int linedraw();
X
X	union  
X		{
X		struct  
X			{
X			unsigned col2 : 4;
X			unsigned row2 : 4;
X			unsigned col1 : 4;
X			unsigned row1 : 4;
X			}  part;
X		struct
X			{
X			unsigned word;
X			}  whole;
X		}  font;
X
X	for (i=0; i<=35; i++)  {
X		if ((font.whole.word = stroke[asc_char][i]) != 0xFFFF) 
X			if (linedraw(
X				x1 = x+font.part.col1*hsize,
X				y1 = y+font.part.row1*vsize,
X				x2 = x+font.part.col2*hsize,
X				y2 = y+font.part.row2*vsize)
X				) return(1);
X	}
X	return(0);
X}
X
XxX--EOF--XxX
echo restoring grafstr.c
sed 's/^X//' > grafstr.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) grafstr.c 4.3 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Write string of a graphics characters to the screen.			*/
X/* Sat Dec 12 12:51:27 EST 1987						*/
X/* system5 dtlewis 2 2.2-U AT						*/
X
X#include <stdio.h>
X
Xint grafstr(strng,x,y,vsize,hsize,spacing)  
Xchar strng[];
Xint 	x,		/* X position of upper left corner of character cell */
X	y,		/* Y position of character cell			*/
X	vsize,		/* Vertical size of character cell		*/
X	hsize,		/* Horizontal size of character cell		*/	
X	spacing;	/* Distance between characters			*/
X{
X	int i;
X	int grafchar();
X	for(i=0; strng[i] != NULL; i++)  {
X		if (grafchar(strng[i],x,y,vsize,hsize)) return(1);
X		x += spacing;
X	}
X	return(0);
X}
X
XxX--EOF--XxX
echo restoring init.c
sed 's/^X//' > init.c <<XxX--EOF--XxX
X#ifndef lint
Xstatic char sccsid[] = "@(#) init.c 4.4 88/06/19";
X#endif
X
X/*
X *	Copyright (c) David T. Lewis 1987, 1988
X *	All rights reserved.
X *
X *	Permission is granted to use this for any personal noncommercial use.
X *	You may not distribute source or executable code for profit, nor
X *	may you distribute it with a commercial product without the written
X *	consent of the author.  Please send modifications to the author for
X *	inclusion in updates to the program.  Thanks.
X */
X
X/* Sat Nov 28 17:10:53 EST 1987 */
X/* Initialize shared memory for use in graphics I/O.  This routine is	*/
X/* specific to Microport System V/AT, and presumes that shared memory	*/
X/* segments have been defined (usually at system boot time) such that	*/
X/* the shared memory keys are "B8000L" for CGA adapter, and so on.	*/
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/ipc.h>
X#include <math.h>
X#include <malloc.h>
X#include "graphics.h"
X
Xstruct SVAT_graphics graphics;
X
Xint init(mode)
Xint mode;
X/* Mode is the video mode that will be used when in graphics mode.	*/
X/* By implication, this gives us the memory location we want to attach	*/
X/* to, as well as the dimensions of the screen.				*/
X
X{
X	char *shmat();
X	int shmid;
X	char *malloc();
X	int clear();
X	extern int errno;
X	static char initialized = 'N';	/* Flag to prevent reinitialization */
X
X	graphics.grafmode = mode;
X
X	/* Attach to the appropriate shared memory segment, and set the	*/
X	/* values of graphics.x_extent and graphics.y_extent, according	*/
X	/* to the video mode requested.					*/
X
X	switch (graphics.grafmode)  {
X	case CGA_COLOR_MODE:
X		graphics.x_extent = 319;
X		graphics.y_extent = 199;
X		graphics.x_window_ll = 0;
X		graphics.y_window_ll = 0;
X		graphics.x_window_ur = 319;
X		graphics.y_window_ur = 199;
X		graphics.aspect_ratio = 0.7;
X		graphics.cellfont.chars_per_line = 40;
X		graphics.cellfont.lines_per_screen = 25;
X		graphics.strokefont.xtic = 800;
X		graphics.strokefont.ytic = 1500;
X		graphics.strokefont.xsize = 100;
X		graphics.strokefont.ysize = 160;
X		if ((shmid = shmget(0xB8000L, 32768, IPC_CREAT)) < 0)
X			return(errno);
X		graphics.cgamem = (CGA_BUF_TYPE *)shmat(shmid, 0L, 0);
X		break;
X	case CGA_HI_RES_MODE:
X		graphics.x_extent = 639;
X		graphics.y_extent = 199;
X		graphics.x_window_ll = 0;
X		graphics.y_window_ll = 0;
X		graphics.x_window_ur = 639;
X		graphics.y_window_ur = 199;
X		graphics.aspect_ratio = 0.7;
X		graphics.cellfont.chars_per_line = 80;
X		graphics.cellfont.lines_per_screen = 25;
X		graphics.strokefont.xtic = 480;
X		graphics.strokefont.ytic = 1500;
X		graphics.strokefont.xsize = 60;
X		graphics.strokefont.ysize = 160;
X		if ((shmid = shmget(0xB8000L, 32768, IPC_CREAT)) < 0)
X			return(errno);
X		graphics.cgamem = (CGA_BUF_TYPE *)shmat(shmid, 0L, 0);
X		break;
X	case HERC_GRAF_MODE:
X		graphics.x_extent = 719;
X		graphics.y_extent = 347;
X		graphics.x_window_ll = 0;
X		graphics.y_window_ll = 0;
X		graphics.x_window_ur = 719;
X		graphics.y_window_ur = 347;
X		graphics.aspect_ratio = 0.7;
X		graphics.cellfont.chars_per_line = 90;
X		graphics.cellfont.lines_per_screen = 43;
X		graphics.strokefont.xtic = 400;
X		graphics.strokefont.ytic = 1500;
X		graphics.strokefont.xsize = 50;
X		graphics.strokefont.ysize = 160;
X		if ((shmid = shmget(0xB0000L, 32768, IPC_CREAT)) < 0)
X			return(errno);
X		graphics.hercmem = (HERC_BUF_TYPE *)shmat(shmid, 0L, 0);
X		break;
X	case EGA_COLOR_MODE:
X		/* (not implemented yet) */
X		graphics.x_extent = 639;
X		graphics.y_extent = 349;
X		graphics.x_window_ll = 0;
X		graphics.y_window_ll = 0;
X		graphics.x_window_ur = 639;
X		graphics.y_window_ur = 349;
X		graphics.aspect_ratio = 0.7;
X		graphics.cellfont.chars_per_line = 80;
X		graphics.cellfont.lines_per_screen = 43;
X		graphics.strokefont.xtic = 480;
X		graphics.strokefont.ytic = 1500;
X		graphics.strokefont.xsize = 60;
X		graphics.strokefont.ysize = 160;
X		if ((shmid = shmget(0xA0000L, 32768, IPC_CREAT)) < 0)
X			return(errno);
X		graphics.egamem = (EGA_BUF_TYPE *)shmat(shmid, 0L, 0);
X		break;
X	case IBM_PRINTER:
X		graphics.x_extent = 719;
X		graphics.y_extent = 959;
X		graphics.x_window_ll = 0;
X		graphics.y_window_ll = 0;
X		graphics.x_window_ur = 719;
X		graphics.y_window_ur = 959;
X		graphics.aspect_ratio = 0.7;
X		graphics.cellfont.chars_per_line = 90;
X		graphics.cellfont.lines_per_screen = 120;
X		graphics.strokefont.xtic = 400;
X		graphics.strokefont.ytic = 1000;
X		graphics.strokefont.xsize = 50;
X		graphics.strokefont.ysize = 100;
X		if ((graphics.printbuf1 = (PR_BUF_TYPE *)malloc
X			(sizeof(PR_BUF_TYPE))) == NULL) return(1);
X		if ((graphics.printbuf2 = (PR_BUF_TYPE *)malloc
X			(sizeof(PR_BUF_TYPE))) == NULL) return(1);
X		if ((graphics.printbuf3 = (PR_BUF_TYPE *)malloc
X			(sizeof(PR_BUF_TYPE))) == NULL) return(1);
X		break;
X
X	default:
X		/* The programmer is probably confused at this point,	*/
X		/* so we may as well exit.				*/
X		printf ("Unable to initialize in routine init().  Mode %d requested.\n",graphics.grafmode);
X		exit (1);
X	}
X
X	/* Set other variables to reasonable values.			*/
X
X	graphics.color = 2;
X	graphics.wrt_mode = OR;
X	graphics.xlate_x = 0;
X	graphics.xlate_y = 0;
X	graphics.xlate_z = 0;
X	graphics.offset_x = 0;
X	graphics.offset_y = 0;
X	graphics.offset_z = 0;
X	graphics.theta_x = 0;
X	graphics.theta_y = 0;
X	graphics.theta_z = 0;
X	graphics.c_tz_c_ty = 1.0;
X	graphics.s_tz = 0.0;
X	graphics.s_ty = 0.0;
X	graphics.c_tz_c_tx = 1.0;
X	graphics.s_tx = 0.0;
X	graphics.scale_factor = 1.0;
X	graphics.perspect_dist = HUGE;
X	graphics.x_vport_ll = NORM_X_MIN;
X	graphics.y_vport_ll = NORM_Y_MAX;
X	graphics.x_vport_ur = NORM_X_MIN;
X	graphics.y_vport_ur = NORM_Y_MAX;
X
X	graphics.strokefont.angle = 0;
X	graphics.strokefont.angle = 0;
X
X	/* Character cell spacing in normalized coordinates.  This is	*/
X	/* the distance in normalized coordinates.  The calculation	*/
X	/* must account for leftover scan lines on the bottom of the	*/
X	/* screen.							*/
X	graphics.cellfont.xtic = 
X		NORM_X_RANGE
X		* (graphics.x_extent 
X		- (graphics.x_extent + 1) % X_CELL_BITS)
X		/ graphics.x_extent
X		/ graphics.cellfont.chars_per_line;
X	/* The (integer) value just got rounded down, but we want to	*/
X	/* round up always, so that we won't lose a pixel.  Therefore	*/
X	/* increment the value by 1.					*/
X	graphics.cellfont.xtic++;
X
X	graphics.cellfont.ytic =
X		NORM_Y_RANGE 
X		* (graphics.y_extent 
X		- (graphics.y_extent + 1) % Y_CELL_BITS)
X		/ graphics.y_extent
X		/ graphics.cellfont.lines_per_screen;
X	graphics.cellfont.ytic++;
X
X	graphics.cellfont.xmult = 1;	/* Cell size multipliers	*/
X	graphics.cellfont.ymult = 1;
X
X	/* Erase graphics memory.					*/
X	if (clear()) return(1);
X
X	return(0);
X}
XxX--EOF--XxX
-- 
Dave Lewis
Ann Arbor, MI
...![ itivax umix ]!m-net!dtlewis!lewis



More information about the Comp.unix.microport mailing list