home *** CD-ROM | disk | FTP | other *** search
- /*********************
- *
- * gr_shape.c - Graphics shape functions.
- *
- * Purpose: This file contains functions to manage graphics shapes.
- *
- * Blackstar C Function Library
- * (c) Copyright 1985,1989 Sterling Castle Software
- *
- *******/
-
- #include <dos.h>
- #include "blackstr.h"
- #include "gr_head.h"
- #include "sc_head.h"
- #include "sy_head.h"
- #include "primitiv.h"
- #include <memory.h>
-
-
- /********
- *
- * gr_draw(shape) - draw a shape from shape table
- *
- **/
-
- void gr_draw(short int *shape)
- {
- int x,y,x1,y1;
-
- x = grx_, y=gry_; /* current point is relative */
- while (*shape!=EOS) {
- x1 = (*shape++) + x;
- y1 = (*shape++) + y;
- gr_setpt(x1,y1);
- }
- }
-
-
- /********
- *
- * gr_scale(shape,factor) - scale a shape by factor
- *
- **/
-
- void gr_scale(short int *shape, float factor)
- {
- while(*shape != EOS)
- *shape++ = (*shape * factor);
- }
-
-
- /********
- *
- * gr_scan(shape) - scan a shape from screen
- *
- **/
-
- short int *gr_scan(short int *shape)
- {
- short int *ptr;
- int i,j;
-
- ptr = shape;
- for(j=gr_miny_; j<=gr_maxy_; ++j)
- for(i=gr_minx_; i<=gr_maxx_; ++i)
- if(gr_getpt(i,j) == grfcol_) {
- *shape++ = i-gr_minx_;
- *shape++ = j-gr_miny_;
- }
- *shape++ = EOS;
- *shape = EOS;
- return(ptr);
- }
-
-
- /********
- *
- * gr_getp(pic) - get graphics picture to buffer
- *
- **/
-
- char *gr_getp(char *pic)
- {
- #if LDATA
- #else
- struct SREGS segs;
- int ptr,dseg;
- #endif
-
- #if LDATA
- memcpy(pic,gr_buf_,sc_mem_*1024);
-
- #else
- segread(&segs);
- dseg = segs.ds;
- ptr = (int)pic;
- movedata(gr_seg_,gr_off_,dseg,ptr,sc_mem_*1024);
- #endif
-
- return(pic);
- }
-
-
- /********
- *
- * gr_putp(pic) - put graphics picture to screen (small model)
- *
- **/
-
- void gr_putp(char *pic)
- {
- #if LDATA
- #else
- struct SREGS segs;
- int ptr,dseg;
- #endif
-
- #if LDATA
- memcpy(gr_buf_,pic,sc_mem_*1024);
-
- #else
- segread(&segs);
- dseg = segs.ds;
- ptr = (int)pic;
- movedata(dseg,ptr,gr_seg_,gr_off_,sc_mem_*1024);
- #endif
- }
-
-
- /********
- *
- * gr_box(x1,y1,x2,y2) - draw a box (absolute) from diagonal points
- *
- **/
-
- void gr_box(int x1, int y1, int x2, int y2)
- {
- gr_pos(x1,y1); /* start at upper left corner */
- gr_lineto(x2,y1);
- gr_lineto(x2,y2);
- gr_lineto(x1,y2);
- gr_lineto(x1,y1);
- }
-
-
- /********
- *
- * gr_poly(shape) - draw a shape with line segments
- *
- **/
-
- void gr_poly(short int *shape)
- {
- int x,y,dx,dy;
-
- dx = grx_, dy = gry_;
- while(*shape != EOS) {
- x = dx+(*shape++);
- y = dy+(*shape++);
- gr_lineto(x,y);
- }
- printf("exiting gr_shape...\n");
- }
-
-