Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!spool.mu.edu!munnari.oz.au!manuel!csis!anucsd!pdact!dbell From: dbell@pdact.pd.necisa.oz.au (David I. Bell) Newsgroups: comp.os.minix Subject: MINI-X graphics package (part 3/9) Message-ID: <994@pdact.pd.necisa.oz.au> Date: 22 Apr 91 00:51:17 GMT Organization: NEC Information Systems Australia, Canberra Lines: 1355 #! /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 'mini-x/include/graphics.h' <<'END_OF_FILE' X/* Copyright (c) 1991 David I. Bell X * Permission is granted to use, distribute, or modify this source, X * provided that this copyright notice remains intact. X * X * mini-X graphics - public definitions X */ X X#ifndef GRAPHICS_H X#define GRAPHICS_H X X/* Basic typedefs. */ Xtypedef short GR_COORD; /* coordinate value */ Xtypedef short GR_SIZE; /* size value */ Xtypedef short GR_COUNT; /* number of items */ Xtypedef unsigned short GR_COLOR;/* full color value */ Xtypedef unsigned char GR_COLOR8;/* eight bit color value */ Xtypedef unsigned short GR_BITMAP; /* bitmap unit */ Xtypedef unsigned short GR_MODE; /* drawing mode */ Xtypedef unsigned char GR_CHAR; /* text character */ Xtypedef unsigned char GR_CHAR_WIDTH; /* width of character */ Xtypedef unsigned long GR_ID; /* resource ids */ Xtypedef GR_ID GR_DRAW_ID; /* drawable id */ Xtypedef GR_DRAW_ID GR_WINDOW_ID;/* window id */ Xtypedef GR_DRAW_ID GR_PIXMAP_ID;/* pixmap id (not yet used) */ Xtypedef GR_ID GR_GC_ID; /* graphics context id */ Xtypedef unsigned short GR_FONT; /* font number */ Xtypedef unsigned short GR_BOOL; /* boolean value */ Xtypedef unsigned short GR_FUNC; /* function codes */ Xtypedef int GR_ERROR; /* error value */ Xtypedef short GR_EVENT_TYPE; /* event types */ Xtypedef unsigned short GR_BUTTON; /* button flags */ Xtypedef unsigned short GR_MODIFIER; /* modifier flags (CTRL, SHIFT, etc) */ Xtypedef unsigned long GR_EVENT_MASK; /* event masks */ Xtypedef char GR_FUNC_NAME[20]; /* function name */ Xtypedef void (*GR_ERROR_FUNC) (); /* error function */ X X X/* Limits */ X#define GR_COORD_MIN ((GR_COORD) -32768) /* minimum coordinate value */ X#define GR_COORD_MAX ((GR_COORD) 32767) /* maximum coordinate value */ X#define GR_MAX_CLIPRECTS ((GR_COUNT) 200) /* maximum clip rectangles */ X#define GR_MAX_CURSOR_SIZE ((GR_SIZE) 16) /* maximum cursor size */ X X X/* Size of bitmaps. */ X#define GR_BITMAP_SIZE(width, height) ((height) * \ X (((width) + sizeof(GR_BITMAP) * 8 - 1) / (sizeof(GR_BITMAP) * 8))) X X#define GR_MAX_BITMAP_SIZE \ X GR_BITMAP_SIZE(GR_MAX_CURSOR_SIZE, GR_MAX_CURSOR_SIZE) X X X/* The root window id. */ X#define GR_ROOT_WINDOW_ID ((GR_WINDOW_ID) 1) X X X/* Drawing mode (used with GrSetGCMode). */ X#define GR_MODE_SET ((GR_MODE) 0) /* draw pixels as given (default) */ X#define GR_MODE_XOR ((GR_MODE) 1) /* draw pixels using XOR */ X#define GR_MODE_OR ((GR_MODE) 2) /* draw pixels using OR */ X#define GR_MODE_AND ((GR_MODE) 3) /* draw pixels using AND */ X#define GR_MAX_MODE ((GR_MODE) 3) /* maximum legal mode */ X X X/* Booleans. */ X#define GR_FALSE ((GR_BOOL) 0) X#define GR_TRUE ((GR_BOOL) 1) X X X/* Definition of a point. */ Xtypedef struct { X GR_COORD x; /* x coordinate */ X GR_COORD y; /* y coordinate */ X} GR_POINT; X X X/* Definition of a line. */ Xtypedef struct { X GR_COORD x1; /* x coordinate of first point */ X GR_COORD y1; /* y coordinate of first point */ X GR_COORD x2; /* x coordinate of second point */ X GR_COORD y2; /* y coordinate of second point */ X} GR_LINE; X X X/* Definition of an ellipse. */ Xtypedef struct { X GR_COORD x; /* x coordinate of center */ X GR_COORD y; /* y coordinate of center */ X GR_SIZE rx; /* radius in x direction */ X GR_SIZE ry; /* radius in y direction */ X} GR_ELLIPSE; X X X/* Definition of a rectangle. */ Xtypedef struct { X GR_COORD x; /* x coordinate of top left corner */ X GR_COORD y; /* y coordinate of top left corner */ X GR_SIZE width; /* width of rectangle */ X GR_SIZE height; /* height of rectangle */ X} GR_RECT; X X X/* Screen properties returned by the GrGetScreenInfo call. X * This describes the size of the screen and relative dots/cm of the pixels. X * The actual dots/mm vary depending on the actual monitor in use, but the X * relative sizes are still useful to compensate for non-square pixels for X * drawing perfect circles. (I am avoiding the use of floating point.) X */ Xtypedef struct { X GR_SIZE rows; /* number of rows on screen */ X GR_SIZE cols; /* number of columns on screen */ X GR_SIZE xdpcm; /* dots/centimeter in x direction */ X GR_SIZE ydpcm; /* dots/centimeter in y direction */ X GR_COLOR maxcolor; /* maximum legal color value */ X GR_COLOR black; /* the color black */ X GR_COLOR white; /* the color white */ X GR_BUTTON buttons; /* buttons which are implemented */ X GR_MODIFIER modifiers; /* modifiers which are implemented */ X GR_COUNT fonts; /* number of built-in fonts */ X} GR_SCREEN_INFO; X X X/* Window properties returned by the GrGetWindowInfo call. */ Xtypedef struct { X GR_WINDOW_ID wid; /* window id (or 0 if no such window) */ X GR_WINDOW_ID parent; /* parent window id */ X GR_WINDOW_ID child; /* first child window id (or 0) */ X GR_WINDOW_ID sibling; /* next sibling window id (or 0) */ X GR_BOOL inputonly; /* TRUE if window is input only */ X GR_BOOL mapped; /* TRUE if window is mapped */ X GR_COUNT unmapcount; /* reasons why window is unmapped */ X GR_COORD x; /* absolute x position of window */ X GR_COORD y; /* absolute y position of window */ X GR_SIZE width; /* width of window */ X GR_SIZE height; /* height of window */ X GR_SIZE bordersize; /* size of border */ X GR_COLOR bordercolor; /* color of border */ X GR_COLOR background; /* background color */ X GR_EVENT_MASK eventmask; /* current event mask for this client */ X} GR_WINDOW_INFO; X X X/* Graphics context properties returned by the GrGetGCInfo call. */ Xtypedef struct { X GR_GC_ID gcid; /* GC id (or 0 if no such GC) */ X GR_MODE mode; /* drawing mode */ X GR_FONT font; /* font number */ X GR_COLOR foreground; /* foreground color */ X GR_COLOR background; /* background color */ X GR_BOOL usebackground; /* use background in bitmaps */ X} GR_GC_INFO; X X X/* Font information. */ Xtypedef struct { X GR_FONT font; /* font number */ X GR_SIZE height; /* height of font */ X GR_SIZE maxwidth; /* maximum width of any char */ X GR_SIZE baseline; /* baseline of font */ X GR_BOOL fixed; /* TRUE if font is fixed width */ X GR_CHAR_WIDTH widths[256]; /* table of character widths */ X} GR_FONT_INFO; X X X/* Error codes */ X#define GR_ERROR_BAD_WINDOW_ID ((GR_ERROR) 1) X#define GR_ERROR_BAD_GC_ID ((GR_ERROR) 2) X#define GR_ERROR_BAD_CURSOR_SIZE ((GR_ERROR) 3) X#define GR_ERROR_MALLOC_FAILED ((GR_ERROR) 4) X#define GR_ERROR_BAD_WINDOW_SIZE ((GR_ERROR) 5) X#define GR_ERROR_KEYBOARD_ERROR ((GR_ERROR) 6) X#define GR_ERROR_MOUSE_ERROR ((GR_ERROR) 7) X#define GR_ERROR_INPUT_ONLY_WINDOW ((GR_ERROR) 8) X#define GR_ERROR_ILLEGAL_ON_ROOT_WINDOW ((GR_ERROR) 9) X#define GR_ERROR_TOO_MUCH_CLIPPING ((GR_ERROR) 10) X#define GR_ERROR_SCREEN_ERROR ((GR_ERROR) 11) X#define GR_ERROR_UNMAPPED_FOCUS_WINDOW ((GR_ERROR) 12) X#define GR_ERROR_BAD_DRAWING_MODE ((GR_ERROR) 13) X X X/* Event types. X * Mouse motion is generated for every motion of the mouse, and is used to X * track the entire history of the mouse (many events and lots of overhead). X * Mouse position ignores the history of the motion, and only reports the X * latest position of the mouse by only queuing the latest such event for X * any single client (good for rubber-banding). X */ X#define GR_EVENT_TYPE_ERROR ((GR_EVENT_TYPE) -1) X#define GR_EVENT_TYPE_NONE ((GR_EVENT_TYPE) 0) X#define GR_EVENT_TYPE_EXPOSURE ((GR_EVENT_TYPE) 1) X#define GR_EVENT_TYPE_BUTTON_DOWN ((GR_EVENT_TYPE) 2) X#define GR_EVENT_TYPE_BUTTON_UP ((GR_EVENT_TYPE) 3) X#define GR_EVENT_TYPE_MOUSE_ENTER ((GR_EVENT_TYPE) 4) X#define GR_EVENT_TYPE_MOUSE_EXIT ((GR_EVENT_TYPE) 5) X#define GR_EVENT_TYPE_MOUSE_MOTION ((GR_EVENT_TYPE) 6) X#define GR_EVENT_TYPE_MOUSE_POSITION ((GR_EVENT_TYPE) 7) X#define GR_EVENT_TYPE_KEY_DOWN ((GR_EVENT_TYPE) 8) X#define GR_EVENT_TYPE_KEY_UP ((GR_EVENT_TYPE) 9) X#define GR_EVENT_TYPE_FOCUS_IN ((GR_EVENT_TYPE) 10) X#define GR_EVENT_TYPE_FOCUS_OUT ((GR_EVENT_TYPE) 11) X X X/* Event masks */ X#define GR_EVENTMASK(n) (((GR_EVENT_MASK) 1) << (n)) X X#define GR_EVENT_MASK_NONE GR_EVENTMASK(GR_EVENT_TYPE_NONE) X#define GR_EVENT_MASK_ERROR GR_EVENTMASK(GR_EVENT_TYPE_ERROR) X#define GR_EVENT_MASK_EXPOSURE GR_EVENTMASK(GR_EVENT_TYPE_EXPOSURE) X#define GR_EVENT_MASK_BUTTON_DOWN GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_DOWN) X#define GR_EVENT_MASK_BUTTON_UP GR_EVENTMASK(GR_EVENT_TYPE_BUTTON_UP) X#define GR_EVENT_MASK_MOUSE_ENTER GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_ENTER) X#define GR_EVENT_MASK_MOUSE_EXIT GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_EXIT) X#define GR_EVENT_MASK_MOUSE_MOTION GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_MOTION) X#define GR_EVENT_MASK_MOUSE_POSITION GR_EVENTMASK(GR_EVENT_TYPE_MOUSE_POSITION) X#define GR_EVENT_MASK_KEY_DOWN GR_EVENTMASK(GR_EVENT_TYPE_KEY_DOWN) X#define GR_EVENT_MASK_KEY_UP GR_EVENTMASK(GR_EVENT_TYPE_KEY_UP) X#define GR_EVENT_MASK_FOCUS_IN GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_IN) X#define GR_EVENT_MASK_FOCUS_OUT GR_EVENTMASK(GR_EVENT_TYPE_FOCUS_OUT) X#define GR_EVENT_MASK_ALL ((GR_EVENT_MASK) -1L) X X X/* Modifiers generated by special keyboard shift-like keys. X * The state of these keys can be read as up or down, and don't X * generate any characters by themselves. X */ X#define GR_MODIFIER_SHIFT ((GR_MODIFIER) 0x01) /* shift */ X#define GR_MODIFIER_CTRL ((GR_MODIFIER) 0x02) /* control */ X#define GR_MODIFIER_META ((GR_MODIFIER) 0x03) /* meta or alt */ X#define GR_MODIFIER_ANY ((GR_MODIFIER) 0x07) /* any modifier */ X X X/* Button flags. */ X#define GR_BUTTON_1 ((GR_BUTTON) 0x01) /* button 1 */ X#define GR_BUTTON_2 ((GR_BUTTON) 0x02) /* button 2 */ X#define GR_BUTTON_3 ((GR_BUTTON) 0x04) /* button 3 */ X#define GR_BUTTON_ANY ((GR_BUTTON) 0x07) /* any button */ X X X/* Event for errors detected by the server. X * These events are not delivered to GrGetNextEvent, but instead call X * the user supplied error handling function. Only the first one of X * these errors at a time is saved for delivery to the client since X * there is not much to be done about errors anyway except complain X * and exit. X */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_FUNC_NAME name; /* function name which failed */ X GR_ERROR code; /* error code */ X GR_ID id; /* resource id (maybe useless) */ X} GR_EVENT_ERROR; X X X/* Event for a mouse button pressed down or released. */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_WINDOW_ID wid; /* window id event delivered to */ X GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */ X GR_COORD rootx; /* root window x coordinate */ X GR_COORD rooty; /* root window y coordinate */ X GR_COORD x; /* window x coordinate of mouse */ X GR_COORD y; /* window y coordinate of mouse */ X GR_BUTTON buttons; /* current state of all buttons */ X GR_BUTTON changebuttons; /* buttons which went down or up */ X GR_MODIFIER modifiers; /* modifiers (SHIFT, CTRL, etc) */ X} GR_EVENT_BUTTON; X X X/* Event for a keystroke typed for the window with has focus. */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_WINDOW_ID wid; /* window id event delived to */ X GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */ X GR_COORD rootx; /* root window x coordinate */ X GR_COORD rooty; /* root window y coordinate */ X GR_COORD x; /* window x coordinate of mouse */ X GR_COORD y; /* window y coordinate of mouse */ X GR_BUTTON buttons; /* current state of buttons */ X GR_MODIFIER modifiers; /* modifiers (SHIFT, CTRL, etc) */ X GR_CHAR ch; /* keystroke or function key */ X} GR_EVENT_KEYSTROKE; X X X/* Event for exposure for a region of a window. */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_WINDOW_ID wid; /* window id */ X GR_COORD x; /* window x coordinate of exposure */ X GR_COORD y; /* window y coordinate of exposure */ X GR_SIZE width; /* width of exposure */ X GR_SIZE height; /* height of exposure */ X} GR_EVENT_EXPOSURE; X X X/* General events for focus in or focus out for a window, or mouse enter X * or mouse exit from a window, or window unmapping or mapping, etc. X */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_WINDOW_ID wid; /* window id */ X} GR_EVENT_GENERAL; X X X/* Events for mouse motion or mouse position. */ Xtypedef struct { X GR_EVENT_TYPE type; /* event type */ X GR_WINDOW_ID wid; /* window id event delivered to */ X GR_WINDOW_ID subwid; /* sub-window id (pointer was in) */ X GR_COORD rootx; /* root window x coordinate */ X GR_COORD rooty; /* root window y coordinate */ X GR_COORD x; /* window x coordinate of mouse */ X GR_COORD y; /* window y coordinate of mouse */ X GR_BUTTON buttons; /* current state of buttons */ X GR_MODIFIER modifiers; /* modifiers (ALT, SHIFT, etc) */ X} GR_EVENT_MOUSE; X X X/* Union of all possible event structures. X * This is the structure returned by the GrGetNextEvent and similar routines. X */ Xtypedef union { X GR_EVENT_TYPE type; /* event type */ X GR_EVENT_ERROR error; /* error event */ X GR_EVENT_GENERAL general; /* general window events */ X GR_EVENT_BUTTON button; /* button events */ X GR_EVENT_KEYSTROKE keystroke; /* keystroke events */ X GR_EVENT_EXPOSURE exposure; /* exposure events */ X GR_EVENT_MOUSE mouse; /* mouse motion events */ X} GR_EVENT; X X X/* Public graphics routines. */ Xextern int GrOpen(); Xextern void GrClose(); Xextern void GrGetScreenInfo(); Xextern GR_ERROR_FUNC GrSetErrorHandler(); Xextern GR_WINDOW_ID GrNewWindow(); Xextern GR_WINDOW_ID GrNewInputWindow(); Xextern void GrDestroyWindow(); Xextern GR_GC_ID GrNewGC(); Xextern void GrGetGCInfo(); Xextern void GrDestroyGC(); Xextern void GrMapWindow(); Xextern void GrUnmapWindow(); Xextern void GrRaiseWindow(); Xextern void GrLowerWindow(); Xextern void GrMoveWindow(); Xextern void GrResizeWindow(); Xextern void GrGetWindowInfo(); Xextern void GrGetFontInfo(); Xextern void GrSetFocus(); Xextern void GrSetBorderColor(); Xextern void GrClearWindow(); Xextern void GrSelectEvents(); Xextern void GrGetNextEvent(); Xextern void GrCheckNextEvent(); Xextern void GrPeekEvent(); Xextern void GrFlush(); Xextern void GrLine(); Xextern void GrPoint(); Xextern void GrRect(); Xextern void GrFillRect(); Xextern void GrPoly(); Xextern void GrFillPoly(); Xextern void GrEllipse(); Xextern void GrFillEllipse(); Xextern void GrSetGCForeground(); Xextern void GrSetGCBackground(); Xextern void GrSetGCUseBackground(); Xextern void GrSetGCMode(); Xextern void GrSetGCFont(); Xextern void GrGetGCTextSize(); Xextern void GrReadArea8(); Xextern void GrArea8(); Xextern void GrBitmap(); Xextern void GrText(); Xextern void GrSetCursor(); Xextern void GrMoveCursor(); X X#endif X X/* END CODE */ END_OF_FILE if test 14242 -ne `wc -c <'mini-x/include/graphics.h'`; then echo shar: \"'mini-x/include/graphics.h'\" unpacked with wrong size! fi # end of 'mini-x/include/graphics.h' fi if test -f 'mini-x/kernel/graph_ega.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mini-x/kernel/graph_ega.c'\" else echo shar: Extracting \"'mini-x/kernel/graph_ega.c'\" \(14152 characters\) sed "s/^X//" >'mini-x/kernel/graph_ega.c' <<'END_OF_FILE' X/* Copyright (c) 1991 David I. Bell X * Permission is granted to use, distribute, or modify this source, X * provided that this copyright notice remains intact. X * X * Low level graphics mode for ega. X * Since these are "device level" routines, there is no need to check X * clipping since the higher level routines should have already done this. X * However, checking for values outside the screen memory is reasonable X * for safety. X */ X X#include "kernel.h" X#include "protect.h" X#include "graph_dev.h" X X X#define COLS 640 /* columns */ X#define ROWS 350 /* rows */ X#define COLORS 16 /* number of colors */ X#define BLACK 0 /* black */ X#define WHITE 15 /* white */ X X#define DONE 0 X#define IN 1 X#define OUT 2 X X#define ROM_SCAN_LINES 14 /* number of scan lines in fonts in ROM */ X#define RAM_SCAN_LINES 32 /* number of scan lines in fonts in RAM */ X#define FONT_CHARS 256 /* number of characters in font tables */ X#define CHAR_WIDTH 8 /* number of pixels for character width */ X#define EGA_BASE 0xa0000 /* location of enhanced display memory */ X X X X#define PALREG 0x3c0 X#define SEQREG 0x3c4 X#define SEQVAL 0x3c5 X#define GRREG 0x3ce X#define GRVAL 0x3cf X#define ATTRREG 0x3da X#define CRTCREG 0x3d4 X#define CRTCVAL 0x3d5 X X#define GENREG1 0x3c2 X#define GENREG2 0x3cc X#define GENREG3 0x3ca X X#define DATA_ROTATE 3 /* register number for data rotate */ X X XFORWARD int ega_init(); XFORWARD void ega_term(); XFORWARD void ega_setmode(); XFORWARD void ega_drawrow(); XFORWARD void ega_drawcol(); XFORWARD void ega_drawtext(); XFORWARD void ega_sizetext(); XFORWARD void ega_getscreeninfo(); XFORWARD void ega_getfontinfo(); X Xextern void ega_drawpoint(); Xextern void ega_drawline(); Xextern void ega_setgraphics(); Xextern void ega_getcharbits(); Xextern GR_COLOR ega_readpoint(); X X XGR_DEV gr_dev = { X ega_init, ega_term, ega_setmode, ega_drawpoint, ega_drawline, X ega_drawrow, ega_drawcol, gen_fillrect, gen_drawellipse, X gen_fillellipse, ega_drawtext, ega_sizetext, gen_drawarea8, X gen_drawbitmap, ega_readpoint, gen_setcursor, gen_movecursor, X gen_checkcursor, gen_fixcursor, gen_copyarea, ega_getcharbits, X ega_getscreeninfo, ega_getfontinfo, ROWS, COLS, COLORS, BLACK, WHITE X}; X Xtypedef struct { X int action; X int port1; X int data1; X int port2; X int data2; X} REGIO; X X XPRIVATE REGIO graphics_on[] = { X /* Reset attr F/F */ X IN, ATTRREG, 0, 0, 0, X X /* Disable palette */ X OUT, PALREG, 0, 0, 0, X X /* Reset sequencer regs */ X OUT, SEQREG, 0, SEQVAL, 0, X OUT, SEQREG, 1, SEQVAL, 1, X OUT, SEQREG, 2, SEQVAL, 0x0f, X OUT, SEQREG, 3, SEQVAL, 0, X OUT, SEQREG, 4, SEQVAL, 6, X X /* Misc out reg */ X OUT, GENREG1, 0xa7, 0, 0, X X /* Sequencer enable */ X OUT, SEQREG, 0, SEQVAL, 0x03, X X /* Unprotect crtc regs 0-7 */ X OUT, CRTCREG, 0x11, CRTCVAL, 0, X X /* Crtc */ X OUT, CRTCREG, 0, CRTCVAL, 0x5b, X OUT, CRTCREG, 1, CRTCVAL, 0x4f, X OUT, CRTCREG, 2, CRTCVAL, 0x53, X OUT, CRTCREG, 3, CRTCVAL, 0x37, X OUT, CRTCREG, 4, CRTCVAL, 0x52, X OUT, CRTCREG, 5, CRTCVAL, 0x00, X OUT, CRTCREG, 6, CRTCVAL, 0x6c, X OUT, CRTCREG, 7, CRTCVAL, 0x1f, X OUT, CRTCREG, 8, CRTCVAL, 0x00, X OUT, CRTCREG, 9, CRTCVAL, 0x00, X OUT, CRTCREG, 10, CRTCVAL, 0x00, X OUT, CRTCREG, 11, CRTCVAL, 0x00, X OUT, CRTCREG, 12, CRTCVAL, 0x00, X OUT, CRTCREG, 13, CRTCVAL, 0x00, X OUT, CRTCREG, 14, CRTCVAL, 0x00, X OUT, CRTCREG, 15, CRTCVAL, 0x00, X OUT, CRTCREG, 16, CRTCVAL, 0x5e, X OUT, CRTCREG, 17, CRTCVAL, 0x2b, X OUT, CRTCREG, 18, CRTCVAL, 0x5d, X OUT, CRTCREG, 19, CRTCVAL, 0x28, X OUT, CRTCREG, 20, CRTCVAL, 0x0f, X OUT, CRTCREG, 21, CRTCVAL, 0x5f, X OUT, CRTCREG, 22, CRTCVAL, 0x0a, X OUT, CRTCREG, 23, CRTCVAL, 0xe3, X OUT, CRTCREG, 24, CRTCVAL, 0xff, X X /* Graphics controller */ X OUT, GENREG2, 0x00, 0, 0, X OUT, GENREG3, 0x01, 0, 0, X OUT, GRREG, 0, GRVAL, 0x00, X OUT, GRREG, 1, GRVAL, 0x00, X OUT, GRREG, 2, GRVAL, 0x00, X OUT, GRREG, 3, GRVAL, 0x00, X OUT, GRREG, 4, GRVAL, 0x00, X OUT, GRREG, 5, GRVAL, 0x00, X OUT, GRREG, 6, GRVAL, 0x05, X OUT, GRREG, 7, GRVAL, 0x0f, X OUT, GRREG, 8, GRVAL, 0xff, X X /* Reset attribute flip/flop */ X IN, ATTRREG, 0, 0, 0, X X /* Palette */ X OUT, PALREG, 0, PALREG, 0x00, X OUT, PALREG, 1, PALREG, 0x01, X OUT, PALREG, 2, PALREG, 0x02, X OUT, PALREG, 3, PALREG, 0x03, X OUT, PALREG, 4, PALREG, 0x04, X OUT, PALREG, 5, PALREG, 0x05, X OUT, PALREG, 6, PALREG, 0x06, X OUT, PALREG, 7, PALREG, 0x07, X OUT, PALREG, 8, PALREG, 0x38, X OUT, PALREG, 9, PALREG, 0x39, X OUT, PALREG, 10, PALREG, 0x3a, X OUT, PALREG, 11, PALREG, 0x3b, X OUT, PALREG, 12, PALREG, 0x3c, X OUT, PALREG, 13, PALREG, 0x3d, X OUT, PALREG, 14, PALREG, 0x3e, X OUT, PALREG, 15, PALREG, 0x3f, X OUT, PALREG, 16, PALREG, 0x01, X OUT, PALREG, 17, PALREG, 0x00, X OUT, PALREG, 18, PALREG, 0x0f, X OUT, PALREG, 19, PALREG, 0x00, X X /* Enable palette */ X OUT, PALREG, 0x20, 0, 0, X X /* End of table */ X DONE, 0, 0, 0, 0 X}; X X XPRIVATE REGIO graph_off[] = { X /* Reset attr F/F */ X IN, ATTRREG, 0, 0, 0, X X /* Disable palette */ X OUT, PALREG, 0, 0, 0, X X /* Reset sequencer regs */ X OUT, SEQREG, 0, SEQVAL, 1, X OUT, SEQREG, 1, SEQVAL, 1, X OUT, SEQREG, 2, SEQVAL, 3, X OUT, SEQREG, 3, SEQVAL, 0, X OUT, SEQREG, 4, SEQVAL, 3, X X /* Misc out reg */ X OUT, GENREG1, 0xa7, 0, 0, X X /* Sequencer enable */ X OUT, SEQREG, 0, SEQVAL, 3, X X /* Crtc */ X OUT, CRTCREG, 0, CRTCVAL, 0x5b, /* horiz total */ X OUT, CRTCREG, 1, CRTCVAL, 0x4f, /* horiz end */ X OUT, CRTCREG, 2, CRTCVAL, 0x53, /* horiz blank */ X OUT, CRTCREG, 3, CRTCVAL, 0x37, /* end blank */ X OUT, CRTCREG, 4, CRTCVAL, 0x51, /* horiz retrace */ X OUT, CRTCREG, 5, CRTCVAL, 0x5b, /* end retrace */ X OUT, CRTCREG, 6, CRTCVAL, 0x6c, /* vert total */ X OUT, CRTCREG, 7, CRTCVAL, 0x1f, /* overflows */ X OUT, CRTCREG, 8, CRTCVAL, 0x00, /* row scan */ X OUT, CRTCREG, 9, CRTCVAL, 0x0d, /* max scan line */ X OUT, CRTCREG, 10, CRTCVAL, 0x00, /* cursor start */ X OUT, CRTCREG, 11, CRTCVAL, 0x0f, /* cursor end */ X OUT, CRTCREG, 12, CRTCVAL, 0x00, /* start high addr */ X OUT, CRTCREG, 13, CRTCVAL, 0x00, /* low addr */ X OUT, CRTCREG, 14, CRTCVAL, 0x00, /* cursor high */ X OUT, CRTCREG, 15, CRTCVAL, 0x00, /* cursor low */ X OUT, CRTCREG, 16, CRTCVAL, 0x5e, /* vert retrace */ X OUT, CRTCREG, 17, CRTCVAL, 0x2b, /* retrace end */ X OUT, CRTCREG, 18, CRTCVAL, 0x5d, /* vert end */ X OUT, CRTCREG, 19, CRTCVAL, 0x28, /* offset */ X OUT, CRTCREG, 20, CRTCVAL, 0x0f, /* underline */ X OUT, CRTCREG, 21, CRTCVAL, 0x5e, /* vert blank */ X OUT, CRTCREG, 22, CRTCVAL, 0x0a, /* end blank */ X OUT, CRTCREG, 23, CRTCVAL, 0xa3, /* crt mode */ X OUT, CRTCREG, 24, CRTCVAL, 0xff, /* line compare */ X X /* Graphics controller */ X OUT, GENREG2, 0x00, 0, 0, X OUT, GENREG3, 0x01, 0, 0, X OUT, GRREG, 0, GRVAL, 0x00, X OUT, GRREG, 1, GRVAL, 0x00, X OUT, GRREG, 2, GRVAL, 0x00, X OUT, GRREG, 3, GRVAL, 0x00, X OUT, GRREG, 4, GRVAL, 0x00, X OUT, GRREG, 5, GRVAL, 0x10, X OUT, GRREG, 6, GRVAL, 0x0e, X OUT, GRREG, 7, GRVAL, 0x00, X OUT, GRREG, 8, GRVAL, 0xff, X X /* Reset attribute flip/flop */ X IN, ATTRREG, 0, 0, 0, X X /* Palette */ X OUT, PALREG, 0, PALREG, 0x00, X OUT, PALREG, 1, PALREG, 0x01, X OUT, PALREG, 2, PALREG, 0x02, X OUT, PALREG, 3, PALREG, 0x03, X OUT, PALREG, 4, PALREG, 0x04, X OUT, PALREG, 5, PALREG, 0x05, X OUT, PALREG, 6, PALREG, 0x14, X OUT, PALREG, 7, PALREG, 0x07, X OUT, PALREG, 8, PALREG, 0x38, X OUT, PALREG, 9, PALREG, 0x39, X OUT, PALREG, 10, PALREG, 0x3a, X OUT, PALREG, 11, PALREG, 0x3b, X OUT, PALREG, 12, PALREG, 0x3c, X OUT, PALREG, 13, PALREG, 0x3d, X OUT, PALREG, 14, PALREG, 0x3e, X OUT, PALREG, 15, PALREG, 0x3f, X OUT, PALREG, 16, PALREG, 0x08, X OUT, PALREG, 17, PALREG, 0x00, X OUT, PALREG, 18, PALREG, 0x0f, X OUT, PALREG, 19, PALREG, 0x00, X X /* Enable palette */ X OUT, PALREG, 0x20, 0, 0, X X /* End of table */ X DONE, 0, 0, 0, 0 X}; X X X/* Values for the data rotate register to implement drawing modes. */ XPRIVATE unsigned char mode_table[GR_MAX_MODE + 1] = { X 0x00, 0x18, 0x10, 0x08 X}; X X X/*===========================================================================* X * writeregs * X *===========================================================================*/ XPRIVATE void writeregs(rp) Xregister REGIO *rp; X{ X/* Set the graphics registers as indicated by the given table */ X for (; rp->action != DONE; rp++) { X switch (rp->action) { X case IN: in_byte(rp->port1); break; X case OUT: X out_byte(rp->port1, rp->data1); X if (rp->port2) out_byte(rp->port2, rp->data2); X break; X } X } X} X X X/*===========================================================================* X * out_word * X *===========================================================================*/ XPRIVATE void out_word(p, d) Xunsigned int p; Xunsigned int d; X{ X/* Output a word to an I/O port. */ X out_byte(p, d & 0xff); X out_byte(p + 1, (d >> 8) & 0xff); X} X X X/*===========================================================================* X * ega_init * X *===========================================================================*/ XPRIVATE int ega_init(rows, cols, colors) XGR_SIZE rows; XGR_SIZE cols; Xlong colors; X{ X/* Setup for drawing to the ega. X * Returns nonzero if the parameters are illegal. X */ X if ((rows && (rows != ROWS)) || (cols && (cols != COLS)) X || (colors && (colors != COLORS))) X return -1; X writeregs(graphics_on); X for (rows = 0; rows < ROWS; rows++) ega_drawrow(0, COLS - 1, rows, BLACK); X return 0; X} X X X/*===========================================================================* X * ega_term * X *===========================================================================*/ XPRIVATE void ega_term() X{ X/* Terminate graphics mode for the EGA. X * This resets back to normal text mode. X */ X long srcoffset; X long destoffset; X int data; X int ch; X int row; X X ega_setmode(GR_MODE_SET); X for (row = 0; row < ROWS; row++) ega_drawrow(0, COLS - 1, row, BLACK); X X /* Copy character table from ROM back into bit plane 2 before turning X * off graphics. X */ X out_word(SEQREG, 0x0100); /* syn reset */ X out_word(SEQREG, 0x0402); /* cpu writes only to map 2 */ X out_word(SEQREG, 0x0704); /* sequential addressing */ X out_word(SEQREG, 0x0300); /* clear synchronous reset */ X X out_word(GRREG, 0x0204); /* select map 2 for CPU reads */ X out_word(GRREG, 0x0005); /* disable odd-even addressing */ X X srcoffset = rom_char_addr; X destoffset = EGA_BASE; X for (ch = 0; ch < FONT_CHARS; ch++) { X for (row = 0; row < ROM_SCAN_LINES; row++) { X data = get_byte(FLAT_DS_SELECTOR, srcoffset++); X put_byte(FLAT_DS_SELECTOR, destoffset++, data); X } X destoffset += (RAM_SCAN_LINES - ROM_SCAN_LINES); X } X X /* Finally set the registers back for text mode. */ X writeregs(graph_off); X} X X X/*===========================================================================* X * ega_setmode * X *===========================================================================*/ XPRIVATE void ega_setmode(mode) XGR_MODE mode; /* drawing mode */ X{ X/* Set the drawing mode. X * This is either SET, OR, AND, or XOR. X */ X if (mode > GR_MAX_MODE) return; X out_byte(GRREG, DATA_ROTATE); X out_byte(GRVAL, mode_table[mode]); X} X X X/*===========================================================================* X * ega_drawrow * X *===========================================================================*/ XPRIVATE void ega_drawrow(x1, x2, y, color) XGR_COORD x1; XGR_COORD x2; XGR_COORD y; XGR_COLOR color; X{ X ega_drawline(x1, y, x2, y, color); X} X X X/*===========================================================================* X * ega_drawcol * X *===========================================================================*/ XPRIVATE void ega_drawcol(x, y1, y2, color) XGR_COORD x; XGR_COORD y1; XGR_COORD y2; XGR_COLOR color; X{ X ega_drawline(x, y1, x, y2, color); X} X X X/*===========================================================================* X * ega_drawtext * X *===========================================================================*/ XPRIVATE void ega_drawtext(x, y, str, cc, fg) XGR_COORD x, y; /* bottom left location */ XGR_CHAR *str; /* character string */ XGR_SIZE cc; /* length of string */ XGR_COLOR fg; /* foreground color */ X{ X GR_SIZE width; /* width of character */ X GR_SIZE height; /* height of character */ X GR_BITMAP bitmap[ROM_SCAN_LINES]; /* bitmap for character */ X X y -= (ROM_SCAN_LINES - 1); X while (cc-- > 0) { X ega_getcharbits(*str++, bitmap, &width, &height); X gen_drawbitmap(x, y, width, height, bitmap, fg); X x += width; X } X} X X X/*===========================================================================* X * ega_sizetext * X *===========================================================================*/ XPRIVATE void ega_sizetext(buf, cc, retx, rety) XGR_CHAR *buf; XGR_SIZE cc; XGR_SIZE *retx; XGR_SIZE *rety; X{ X *retx = CHAR_WIDTH * cc; X *rety = ROM_SCAN_LINES; X} X X X/*===========================================================================* X * ega_getscreeninfo * X *===========================================================================*/ XPRIVATE void ega_getscreeninfo(ip) XGR_SCREEN_INFO *ip; /* where to return result */ X{ X/* Return the screen configuration information for the ega. */ X ip->rows = gr_dev.rows; X ip->cols = gr_dev.cols; X ip->xdpcm = 27; /* assumes screen width of 24 cm */ X ip->ydpcm = 19; /* assumes screen height of 18 cm */ X ip->maxcolor = gr_dev.colors - 1; X ip->black = gr_dev.black; X ip->white = gr_dev.white; X ip->fonts = 1; /* only 1 builtin font */ X} X X X/*===========================================================================* X * ega_getfontinfo * X *===========================================================================*/ XPRIVATE void ega_getfontinfo(font, fip) XGR_FONT font; /* font number */ XGR_FONT_INFO *fip; /* where to return result */ X{ X/* Return the font information about a font in the ega. X * Currently we only support one font. X */ X int i; X X fip->font = font; X if (font != 0) { X fip->height = 1; X fip->maxwidth = 1; X fip->baseline = 0; X fip->fixed = GR_TRUE; X for (i = 0; i < 256; i++) fip->widths[i] = 1; X } X fip->height = ROM_SCAN_LINES; X fip->maxwidth = CHAR_WIDTH; X fip->baseline = 3; X fip->fixed = GR_TRUE; X for (i = 0; i < 256; i++) fip->widths[i] = CHAR_WIDTH; X} X X/* END CODE */ END_OF_FILE if test 14152 -ne `wc -c <'mini-x/kernel/graph_ega.c'`; then echo shar: \"'mini-x/kernel/graph_ega.c'\" unpacked with wrong size! fi # end of 'mini-x/kernel/graph_ega.c' fi if test -f 'mini-x/kernel/graph_gen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mini-x/kernel/graph_gen.c'\" else echo shar: Extracting \"'mini-x/kernel/graph_gen.c'\" \(11017 characters\) sed "s/^X//" >'mini-x/kernel/graph_gen.c' <<'END_OF_FILE' X/* Copyright (c) 1991 David I. Bell X * Permission is granted to use, distribute, or modify this source, X * provided that this copyright notice remains intact. X * X * Generic device dependent routines. X * All of these routines use other device routines to perform their work, X * eventually getting to real device routines. In the worst case, the X * only real device routine implemented is drawpoint. In the best case, X * none of these generic routines are needed since the device can do X * them all efficiently. Since these are "device" level routines, no X * clip rectangle checks are necessary since they should have already been X * done by the calling routines, but clip checks against the device X * area is reasonable. X */ X X#include "kernel.h" X#include "graph_dev.h" X XFORWARD void draw4points(); X X X/*===========================================================================* X * gen_drawline * X *===========================================================================*/ XPUBLIC void gen_drawline(x1, y1, x2, y2, color) XGR_COORD x1; XGR_COORD y1; XGR_COORD x2; XGR_COORD y2; XGR_COLOR color; X{ X/* Generic draw line routine. */ X GR_COORD temp; X int xdelta; X int ydelta; X int xinc; X int yinc; X int rem; X X if (y1 == y2) { X (*gr_dev.drawrow) (x1, x2, y1, color); X return; X } X if (x1 == x2) { X (*gr_dev.drawcol) (x1, y1, y2, color); X return; X } X xdelta = x2 - x1; X ydelta = y2 - y1; X if (xdelta < 0) xdelta = -xdelta; X if (ydelta < 0) ydelta = -ydelta; X xinc = (x2 > x1) ? 1 : -1; X yinc = (y2 > y1) ? 1 : -1; X (*gr_dev.drawpoint) (x1, y1, color); X if (xdelta >= ydelta) { X rem = xdelta / 2; X do { X x1 += xinc; X rem += ydelta; X if (rem >= xdelta) { X rem -= xdelta; X y1 += yinc; X } X (*gr_dev.drawpoint) (x1, y1, color); X } while (x1 != x2); X } else { X rem = ydelta / 2; X do { X y1 += yinc; X rem += xdelta; X if (rem >= ydelta) { X rem -= ydelta; X x1 += xinc; X } X (*gr_dev.drawpoint) (x1, y1, color); X } while (y1 != y2); X } X} X X X/*===========================================================================* X * gen_drawrow * X *===========================================================================*/ XPUBLIC void gen_drawrow(x1, x2, y, color) XGR_COORD x1; XGR_COORD x2; XGR_COORD y; XGR_COLOR color; X{ X/* Generic draw row routine. */ X while (x1 <= x2) (*gr_dev.drawpoint) (x1++, y, color); X} X X X/*===========================================================================* X * gen_drawcol * X *===========================================================================*/ XPUBLIC void gen_drawcol(x, y1, y2, color) XGR_COORD x; XGR_COORD y1; XGR_COORD y2; XGR_COLOR color; X{ X/* Generic draw column routine. */ X while (y1 <= y2) (*gr_dev.drawpoint) (x, y1++, color); X} X X X/*===========================================================================* X * gen_fillrect * X *===========================================================================*/ XPUBLIC void gen_fillrect(x1, y1, x2, y2, color) XGR_COORD x1; XGR_COORD y1; XGR_COORD x2; XGR_COORD y2; XGR_COLOR color; X{ X/* Generic fill rectangle routine. */ X while (y1 <= y2) (*gr_dev.drawrow) (x1, x2, y1++, color); X} X X X/*===========================================================================* X * gen_drawellipse * X *===========================================================================*/ XPUBLIC void gen_drawellipse(x, y, rx, ry, color) XGR_COORD x, y; /* coordinates of center of ellipse */ XGR_SIZE rx; /* radius along x axis */ XGR_SIZE ry; /* radius along y axis */ X{ X/* Generic ellipse drawing routine. */ X int xp, yp; /* current point (based on center) */ X long Asquared; /* square of x semi axis */ X long TwoAsquared; X long Bsquared; /* square of y semi axis */ X long TwoBsquared; X long d; X long dx, dy; X X if ((rx < 0) || (ry < 0)) return; X X xp = 0; X yp = ry; X Asquared = rx * rx; X TwoAsquared = 2 * Asquared; X Bsquared = ry * ry; X TwoBsquared = 2 * Bsquared; X d = Bsquared - Asquared * ry + (Asquared >> 2); X dx = 0; X dy = TwoAsquared * ry; X X while (dx < dy) { X draw4points(x, y, xp, yp, color); X if (d > 0) { X yp--; X dy -= TwoAsquared; X d -= dy; X } X xp++; X dx += TwoBsquared; X d += (Bsquared + dx); X } X d += ((3L * (Asquared - Bsquared) / 2L - (dx + dy)) >> 1); X while (yp >= 0) { X draw4points(x, y, xp, yp, color); X if (d < 0) { X xp++; X dx += TwoBsquared; X d += dx; X } X yp--; X dy -= TwoAsquared; X d += (Asquared - dy); X } X} X X X/*===========================================================================* X * draw4points * X *===========================================================================*/ XPRIVATE void draw4points(x, y, px, py, color) XGR_COORD x, y; /* center of the points */ XGR_SIZE px, py; /* point to plot (based on center) */ XGR_COLOR color; X{ X/* Set four points symmetrically situated around a point. */ X (*gr_dev.drawpoint) (x + px, y + py, color); X (*gr_dev.drawpoint) (x - px, y + py, color); X (*gr_dev.drawpoint) (x + px, y - py, color); X (*gr_dev.drawpoint) (x - px, y - py, color); X} X X X/*===========================================================================* X * gen_fillellipse * X *===========================================================================*/ XPUBLIC void gen_fillellipse(x, y, rx, ry, color) XGR_COORD x, y; /* coordinates of center of ellipse */ XGR_SIZE rx; /* radius along x axis */ XGR_SIZE ry; /* radius along y axis */ XGR_COLOR color; X{ X/* Generic fill ellipse routine. */ X int xp, yp; /* current point (based on center) */ X long Asquared; /* square of x semi axis */ X long TwoAsquared; X long Bsquared; /* square of y semi axis */ X long TwoBsquared; X long d; X long dx, dy; X X if ((rx < 0) || (ry < 0)) return; X X xp = 0; X yp = ry; X Asquared = rx * rx; X TwoAsquared = 2 * Asquared; X Bsquared = ry * ry; X TwoBsquared = 2 * Bsquared; X d = Bsquared - Asquared * ry + (Asquared >> 2); X dx = 0; X dy = TwoAsquared * ry; X X while (dx < dy) { X (*gr_dev.drawrow) (x - xp, x + xp, y - yp, color); X (*gr_dev.drawrow) (x - xp, x + xp, y + yp, color); X if (d > 0) { X yp--; X dy -= TwoAsquared; X d -= dy; X } X xp++; X dx += TwoBsquared; X d += (Bsquared + dx); X } X d += ((3L * (Asquared - Bsquared) / 2L - (dx + dy)) >> 1); X while (yp >= 0) { X (*gr_dev.drawrow) (x - xp, x + xp, y - yp, color); X (*gr_dev.drawrow) (x - xp, x + xp, y + yp, color); X if (d < 0) { X xp++; X dx += TwoBsquared; X d += dx; X } X yp--; X dy -= TwoAsquared; X d += (Asquared - dy); X } X} X X X/*===========================================================================* X * gen_drawarea8 * X *===========================================================================*/ XPUBLIC void gen_drawarea8(x, y, width, height, table) XGR_COORD x; /* leftmost column of area */ XGR_COORD y; /* topmost row of area */ XGR_SIZE width; /* width of area */ XGR_SIZE height; /* height of area */ XGR_COLOR8 *table; /* table of 8 bit color values */ X{ X/* Generic drawing of rectangular area with 8 bit color values. X * The rectangle is composed of 8 bit color values so that each color X * only uses one character. If a color matches the background color, X * that that pixel is only drawn if the gr_usebg flag is set. X */ X long cellstodo; /* remaining number of cells */ X long count; /* number of cells of same color */ X long cc; /* current cell count */ X long rows; /* number of complete rows */ X GR_COORD minx; /* minimum x value */ X GR_COORD maxx; /* maximum x value */ X GR_COLOR color; /* color of these pixels */ X GR_BOOL dodraw; /* TRUE if draw these points */ X X minx = x; X maxx = x + width - 1; X cellstodo = width * height; X while (cellstodo > 0) { X /* See how many of the adjacent remaining points have the X * same color as the next point. X */ X color = *table++; X dodraw = (gr_usebg || (color != gr_background)); X count = 1; X cellstodo--; X while ((cellstodo > 0) && (color == *table)) { X table++; X count++; X cellstodo--; X } X X /* If there is only one point with this color, then draw it X * by itself. X */ X if (count == 1) { X if (dodraw) (*gr_dev.drawpoint) (x, y, color); X if (++x > maxx) { X x = minx; X y++; X } X continue; X } X X /* There are multiple points with the same color. If we are X * not at the start of a row of the rectangle, then draw this X * first row specially. X */ X if (x != minx) { X cc = count; X if (x + cc - 1 > maxx) cc = maxx - x + 1; X if (dodraw) (*gr_dev.drawrow) (x, x + cc - 1, y, color); X count -= cc; X x += cc; X if (x > maxx) { X x = minx; X y++; X } X } X X /* Now the x value is at the beginning of a row if there are X * any points left to be drawn. Draw all the complete rows X * with one call. X */ X rows = count / width; X if (rows > 0) { X if (dodraw) X (*gr_dev.fillrect) (x, y, maxx, y + rows - 1, color); X count %= width; X y += rows; X } X X /* If there is a final partial row of pixels left to be X * drawn, then do that. X */ X if (count > 0) { X if (dodraw) (*gr_dev.drawrow) (x, x + count - 1, y, color); X x += count; X } X } X} X X X/*===========================================================================* X * gen_drawbitmap * X *===========================================================================*/ XPUBLIC void gen_drawbitmap(x, y, width, height, table, fgcolor) XGR_COORD x; /* leftmost column of area */ XGR_COORD y; /* topmost row of area */ XGR_SIZE width; /* width of area */ XGR_SIZE height; /* height of area */ XGR_BITMAP *table; /* table of bitmaps */ XGR_COLOR fgcolor; /* foreground color */ X{ X/* Draw a rectanglular array of pixels in the foreground color as X * determined by the specified bitmap. This does not affect the X * background pixels. X */ X GR_COORD minx; X GR_COORD maxx; X GR_BITMAP bitvalue; /* bitmap word value */ X int bitcount; /* number of bits left in bitmap word */ X X minx = x; X maxx = x + width - 1; X bitcount = 0; X while (height > 0) { X if (bitcount <= 0) { X bitcount = GR_BITMAPBITS; X bitvalue = *table++; X } X if (GR_TESTBIT(bitvalue)) (*gr_dev.drawpoint) (x, y, fgcolor); X bitvalue = GR_SHIFTBIT(bitvalue); X bitcount--; X if (x++ == maxx) { X x = minx; X y++; X height--; X bitcount = 0; X } X } X} X X X/*===========================================================================* X * gen_copyarea * X *===========================================================================*/ XPUBLIC void gen_copyarea(srcx, srcy, width, height, destx, desty) XGR_COORD srcx; /* leftmost column of area to copy */ XGR_COORD srcy; /* topmost row of area to copy */ XGR_SIZE width; /* width of area to copy */ XGR_SIZE height; /* height of area to copy */ XGR_COORD destx; /* leftmost column of destination */ XGR_COORD desty; /* topmost row of destination */ X{ X/* Generic copy of an area from one rectangle to another. X * This bypasses clipping. X */ X GR_COORD row; X GR_COORD col; X GR_COLOR color; X X for (row = 0; row < height; row++) { X for (col = 0; col < width; col++) { X color = (*gr_dev.readpoint) (srcx + col, srcy + row); X (*gr_dev.drawpoint) (destx + col, desty + row, color); X } X } X} X X/* END CODE */ END_OF_FILE if test 11017 -ne `wc -c <'mini-x/kernel/graph_gen.c'`; then echo shar: \"'mini-x/kernel/graph_gen.c'\" unpacked with wrong size! fi # end of 'mini-x/kernel/graph_gen.c' fi echo shar: End of archive 3 \(of 9\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 9 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0