|
|
1.1 ! root 1: #include "jerq.h" ! 2: /* These routines are NOT portable, but they are fast. */ ! 3: ! 4: Point ! 5: add (a, b) ! 6: Point a, b; ! 7: { ! 8: register short *ap= &a.x, *bp= &b.x; ! 9: *ap++ += *bp++; ! 10: *ap += *bp; ! 11: return a; ! 12: } ! 13: ! 14: Point ! 15: sub (a, b) ! 16: Point a, b; ! 17: { ! 18: register short *ap= &a.x, *bp= &b.x; ! 19: *ap++ -= *bp++; ! 20: *ap -= *bp; ! 21: return a; ! 22: } ! 23: ! 24: Point ! 25: mul (a, b) ! 26: Point a; ! 27: register b; ! 28: { ! 29: register short *ap= &a.x; ! 30: *(ap++)*=b; ! 31: *ap*=b; ! 32: return a; ! 33: } ! 34: ! 35: Point ! 36: div (a, b) ! 37: Point a; ! 38: register b; ! 39: { ! 40: register short *ap= &a.x; ! 41: *(ap++)/=b; ! 42: *ap/=b; ! 43: return a; ! 44: } ! 45: ! 46: eqpt (p, q) ! 47: Point p, q; ! 48: { ! 49: register long *pp=(long *)&p, *qq=(long *)&q; ! 50: return *pp==*qq; ! 51: } ! 52: ! 53: eqrect (r, s) ! 54: Rectangle r, s; ! 55: { ! 56: register long *rr=(long *)&r, *ss=(long *)&s; ! 57: return *rr++==*ss++ && *rr==*ss; ! 58: } ! 59: ! 60: Rectangle ! 61: inset (r,n) ! 62: Rectangle r; ! 63: register n; ! 64: { ! 65: register short *rp= &r.origin.x; ! 66: *rp++ += n; ! 67: *rp++ += n; ! 68: *rp++ -= n; ! 69: *rp -= n; ! 70: return r; ! 71: } ! 72: ! 73: /* muldiv is a macro in jerq.h */ ! 74: ! 75: ptinrect (p, r) ! 76: Point p; ! 77: Rectangle r; ! 78: { ! 79: return(p.x >= r.origin.x && p.x < r.corner.x ! 80: && p.y >= r.origin.y && p.y < r.corner.y); ! 81: } ! 82: ! 83: Rectangle ! 84: raddp (r, p) ! 85: Rectangle r; ! 86: Point p; ! 87: { ! 88: register short *rp= &r.origin.x, *pp= &p.x; ! 89: *rp++ += *pp++; ! 90: *rp++ += *pp--; ! 91: *rp++ += *pp++; ! 92: *rp += *pp; ! 93: return r; ! 94: } ! 95: ! 96: Rectangle ! 97: rsubp (r, p) ! 98: Rectangle r; ! 99: Point p; ! 100: { ! 101: register short *rp= &r.origin.x, *pp= &p.x; ! 102: *rp++ -= *pp++; ! 103: *rp++ -= *pp--; ! 104: *rp++ -= *pp++; ! 105: *rp -= *pp; ! 106: return r; ! 107: } ! 108: ! 109: rectXrect(r, s) ! 110: Rectangle r, s; ! 111: { ! 112: #define c corner ! 113: #define o origin ! 114: return(r.o.x<s.c.x && s.o.x<r.c.x && r.o.y<s.c.y && s.o.y<r.c.y); ! 115: } ! 116: ! 117: rectclip (rp, b) /* first by reference, second by value */ ! 118: register Rectangle *rp; ! 119: Rectangle b; ! 120: { ! 121: register Rectangle *bp= &b; ! 122: /* ! 123: * Expand rectXrect() in line for speed ! 124: */ ! 125: if((rp->o.x<bp->c.x && bp->o.x<rp->c.x && ! 126: rp->o.y<bp->c.y && bp->o.y<rp->c.y)==0) ! 127: return 0; ! 128: /* They must overlap */ ! 129: if(rp->origin.x<bp->origin.x) ! 130: rp->origin.x=bp->origin.x; ! 131: if(rp->origin.y<bp->origin.y) ! 132: rp->origin.y=bp->origin.y; ! 133: if(rp->corner.x>bp->corner.x) ! 134: rp->corner.x=bp->corner.x; ! 135: if(rp->corner.y>bp->corner.y) ! 136: rp->corner.y=bp->corner.y; ! 137: return 1; ! 138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.