+int
+line_collide(int xov, struct shape *r, uint32_t *rbits, struct shape *s, uint32_t *sbits)
+{
+ int lshift, n, i, ret = 0;
+ uint32_t lbits;
+ struct shape *st;
+ uint32_t *bt;
+
+
+ if(xov < 0) {
+ st = r; r = s; s = st;
+ bt = rbits; rbits = sbits; sbits = bt;
+ xov = -xov;
+ }
+
+
+ lshift = (r->w - xov) & 31;
+ rbits += (r->w - xov) >> 5;
+ n = (xov + 31) >> 5;
+ for(i=0; i<n-1; i++) {
+ lbits = *rbits++ << lshift;
+ lbits |= *rbits >> (32 - lshift);
+ if(lbits & *sbits++) ret = 1;
+ }
+ lbits = *rbits << lshift;
+ if(lbits & *sbits) ret = 1;
+
+ return ret;
+}
+
+int
+mask_collide(int xov, int yov, struct shape *r, struct shape *s)
+{
+ int y, ry, sy;
+ uint32_t *rbits, *sbits;
+
+ if(yov > 0) {
+ ry = r->h - yov; sy = 0;
+ rbits = r->mask + (r->h - yov) * r->mw;
+ sbits = s->mask;
+ } else {
+ ry = 0; sy = s->h + yov;
+ rbits = r->mask;
+ sbits = s->mask + (s->h + yov) * s->mw;
+ }