|
|
1.1 ! root 1: #include <CC/jerq.h> ! 2: #include <CC/layer.h> ! 3: #include "jerqproc.h" ! 4: #include <CC/font.h> ! 5: static inhibited; ! 6: Texture *Ucursswitch(); ! 7: #define DB ((Word *)0x700000) ! 8: #define ONSCREEN(b) (b->base>=DB && b->base<DB+XMAX/WORDSIZE*YMAX) ! 9: ! 10: char * ! 11: Ualloc(n) ! 12: unsigned n; ! 13: { ! 14: extern char *realalloc(); ! 15: return realalloc(n, (char *)P); ! 16: } ! 17: Bitmap * ! 18: Uballoc(r) ! 19: Rectangle r; ! 20: { ! 21: extern Bitmap *realballoc(); ! 22: return realballoc(r, (char *)P); ! 23: } ! 24: Uexit(){ ! 25: extern windowproc(); ! 26: shutdown(P); ! 27: exec(windowproc); ! 28: } ! 29: Urequest(r) ! 30: { ! 31: extern struct Proc *kbdproc; ! 32: register struct Proc *p=P; ! 33: if(r&KBD) ! 34: p->state|=KBDLOCAL; ! 35: else ! 36: p->state&=~KBDLOCAL; ! 37: if(r&MOUSE){ ! 38: p->state|=MOUSELOCAL; ! 39: if(kbdproc==p){ ! 40: p->state|=GOTMOUSE; ! 41: if(p->state&GOTMOUSE) /* if not, it's windowproc */ ! 42: givemouse(p); ! 43: } ! 44: sleep(1); /* Let control() update the mouse */ ! 45: }else{ ! 46: Ucursallow(); ! 47: Ucursswitch((Texture *) 0); ! 48: p->state&=~(GOTMOUSE|MOUSELOCAL); ! 49: } ! 50: if(r&ALARM) ! 51: p->state|=ALARMREQD; ! 52: else ! 53: p->state&=~ALARMREQD; ! 54: } ! 55: Urcvchar(){ ! 56: if(P->nchars==0) ! 57: return -1; ! 58: return(getchar()); ! 59: } ! 60: Ukbdchar(){ ! 61: if((P->state&KBDLOCAL)==0) ! 62: return -1; ! 63: return(qgetc(&P->kbdqueue)); ! 64: } ! 65: Uown() ! 66: { ! 67: register got=CPU|SEND; ! 68: if(P->state&GOTMOUSE) ! 69: got|=MOUSE; ! 70: if(P->kbdqueue.c_cc>0) ! 71: got|=KBD; ! 72: if(P->nchars>0) ! 73: got|=RCV; ! 74: if(P->state&ALARMREQD && P->nticks== 0) ! 75: got|=ALARM; ! 76: return got; ! 77: } ! 78: Uwait(r) ! 79: register r; ! 80: { ! 81: register u; ! 82: ! 83: if((r&RCV) && P->nchars==0) ! 84: muxublk(P); ! 85: sw(1); ! 86: if(r==0) ! 87: return; /* dumb person */ ! 88: spl1(); ! 89: while((u=Uown()&r)==0 && (r&CPU)==0){ ! 90: spl0(); ! 91: sw(0); ! 92: spl1(); ! 93: } ! 94: spl0(); ! 95: return u; ! 96: } ! 97: Ucursallow(){ ! 98: if(P->state&MOUSELOCAL){ ! 99: if(ptinrect(mouse.xy, P->layer->rect) && (P->state&GOTMOUSE)) ! 100: cursallow(); ! 101: P->inhibited=0; ! 102: } ! 103: } ! 104: Ucursset(p) ! 105: Point p; ! 106: { ! 107: if(P->state&GOTMOUSE){ ! 108: cursset(p); ! 109: givemouse(P); ! 110: } ! 111: } ! 112: Ucursinhibit(){ ! 113: if(P->state&MOUSELOCAL){ ! 114: if(ptinrect(mouse.xy, P->layer->rect) && (P->state&GOTMOUSE)) ! 115: cursinhibit(); ! 116: P->inhibited=1; ! 117: } ! 118: } ! 119: Texture * ! 120: Ucursswitch(t) ! 121: register Texture *t; ! 122: { ! 123: Texture *ot; ! 124: ot=0; ! 125: if(P->state&MOUSELOCAL){ ! 126: ot=P->cursor; ! 127: if(ptinrect(mouse.xy, P->layer->rect) && (P->state&GOTMOUSE)) ! 128: cursswitch(t); ! 129: P->cursor=t; ! 130: } ! 131: sleep(1); ! 132: return ot; ! 133: } ! 134: Point ! 135: ostring(f,s,b,p,fc) ! 136: register Font *f; ! 137: unsigned char *s; ! 138: register Layer *b; ! 139: Point p; ! 140: int fc; ! 141: { ! 142: register c; ! 143: int full = (fc == F_STORE); ! 144: Point q; ! 145: Rectangle r; ! 146: register Fontchar *i; ! 147: inhibited=0; ! 148: if(fc!=F_XOR && ONSCREEN(b)){ ! 149: cursinhibit(); ! 150: inhibited=1; ! 151: } ! 152: if (full) { ! 153: r.origin.y = 0; ! 154: r.corner.y = f->height; ! 155: } ! 156: for (; c = *s++; p.x += i->width) { ! 157: i = f->info + c; ! 158: if (!full) { ! 159: r.origin.y = i->top; ! 160: r.corner.y = i->bottom; ! 161: } ! 162: r.origin.x = i->x; ! 163: r.corner.x = (i+1)->x; ! 164: q.x = p.x+((i->left&0x80)? (i->left|0xffffff00):i->left); ! 165: q.y = p.y+r.origin.y; ! 166: if (b->obs == 0) ! 167: bitblt(f->bits,r,b,q,fc); ! 168: else ! 169: lblt(f->bits,r,b,q,fc); ! 170: } ! 171: if(inhibited) ! 172: cursallow(); ! 173: return(p); ! 174: } ! 175: #define CWID 9 /* wired in for defont */ ! 176: Point ! 177: string(f,s,b,p,fc) /* highly 5620 dependent! */ ! 178: Font *f; ! 179: unsigned char *s; ! 180: register Layer *b; ! 181: Point p; ! 182: int fc; ! 183: { ! 184: register Word *src,*dst; /* %r7, %r6 */ ! 185: register m,shift,i; /* %r5, %r4, %r3 */ ! 186: static Bitmap *mrfont; /* local font, guaranteed to not straddle source */ ! 187: char *cp,mrbuf[2]; ! 188: int dw; ! 189: Fontchar *info = f->info; ! 190: if (b->obs != 0 || f != &defont || fc != F_XOR ! 191: || p.x < b->rect.origin.x || p.y < b->rect.origin.y ! 192: || p.y+f->height > b->rect.corner.y) ! 193: return(ostring(f,s,b,p,fc)); ! 194: i = p.x; ! 195: cp = s; ! 196: do i += CWID; while (*cp++); /* *s==0 doesn't matter */ ! 197: if (i > b->rect.corner.x) ! 198: return(ostring(f,s,b,p,fc)); ! 199: if (mrfont == 0) { /* create Mr Font */ ! 200: mrbuf[1] = 0; ! 201: mrfont = balloc(Rect(0,0,32,f->height*128)); ! 202: rectf(mrfont,mrfont->rect,F_CLR); ! 203: for (i = 0; i < 128; i++) { ! 204: mrbuf[0] = i; ! 205: ostring(f,mrbuf,mrfont,Pt(0,i*f->height),F_XOR); ! 206: } ! 207: } ! 208: dw = 4*b->width; ! 209: for (; m = *s++;) { ! 210: if (m&0x80) ! 211: continue; ! 212: i = info[m].top; ! 213: dst = addr(b,Pt(p.x,p.y+i)); ! 214: src = mrfont->base + f->height*m + i; ! 215: shift = p.x & 31; ! 216: i = info[m].bottom - i; ! 217: if (shift + CWID <= 32) { ! 218: do { ! 219: asm(" ROTW %r4,(%r7),%r5 "); ! 220: src++; ! 221: *dst ^= m; ! 222: (char *) dst += dw; ! 223: } while (--i > 0); ! 224: } ! 225: else { ! 226: ((short *) dst)++; ! 227: do { ! 228: asm(" ROTW %r4,(%r7),%r5 "); ! 229: src++; ! 230: asm(" XORH2 %r5,(%r6) "); ! 231: asm(" ROTW &16,%r5,%r5 "); ! 232: asm(" XORH2 %r5,2(%r6) "); ! 233: (char *) dst += dw; ! 234: } while (--i > 0); ! 235: } ! 236: p.x += CWID; ! 237: } ! 238: return(p); ! 239: } ! 240: Usendchar(c) ! 241: char c; ! 242: { ! 243: while(muxsendchar(c, P) == -1) ! 244: sw(1); ! 245: } ! 246: Upoint(l, p, f) ! 247: register Layer *l; ! 248: Point p; ! 249: { ! 250: inhibited=0; ! 251: if(f!=F_XOR && ONSCREEN(l)){ ! 252: cursinhibit(); ! 253: inhibited=1; ! 254: } ! 255: lpoint(l, p, f); ! 256: if(inhibited) ! 257: cursallow(); ! 258: } ! 259: Ubitblt(s, r, d, p, f) ! 260: Layer *s, *d; ! 261: Rectangle r; ! 262: Point p; ! 263: { ! 264: inhibited=0; ! 265: if((f!=F_XOR && ONSCREEN(d)) || ONSCREEN(s)){ ! 266: cursinhibit(); ! 267: inhibited=1; ! 268: } ! 269: lbitblt(s, r, d, p, f); ! 270: if(inhibited) ! 271: cursallow(); ! 272: } ! 273: Urectf(l, r, f) ! 274: Layer *l; ! 275: Rectangle r; ! 276: { ! 277: inhibited=0; ! 278: if(f!=F_XOR && ONSCREEN(l)){ ! 279: cursinhibit(); ! 280: inhibited=1; ! 281: } ! 282: /* speed hack: rectf clips */ ! 283: if(l->obs) ! 284: lrectf(l, r, f); ! 285: else ! 286: rectf(l, r, f); ! 287: if(inhibited) ! 288: cursallow(); ! 289: } ! 290: Usegment(l, p, q, f) ! 291: Layer *l; ! 292: Point p, q; ! 293: { ! 294: inhibited=0; ! 295: if(f!=F_XOR && ONSCREEN(l)){ ! 296: cursinhibit(); ! 297: inhibited=1; ! 298: } ! 299: lsegment(l, p, q, f); ! 300: if(inhibited) ! 301: cursallow(); ! 302: } ! 303: Utexture(l, r, t, f) ! 304: Layer *l; ! 305: Rectangle r; ! 306: Texture *t; ! 307: { ! 308: inhibited=0; ! 309: if(f!=F_XOR && ONSCREEN(l)){ ! 310: cursinhibit(); ! 311: inhibited=1; ! 312: } ! 313: /* speed hack; texture clips anyway */ ! 314: if(l->obs) ! 315: ltexture(l, r, t, f); ! 316: else ! 317: texture(l, r, t, f); ! 318: if(inhibited) ! 319: cursallow(); ! 320: } ! 321: Uscreenswap(b, r, s) ! 322: Bitmap *b; ! 323: Rectangle r, s; ! 324: { ! 325: cursinhibit(); ! 326: screenswap(b, r, s); ! 327: cursallow(); ! 328: } ! 329: struct Proc * ! 330: Unewproc(f) ! 331: int (*f)(); ! 332: { ! 333: extern windowproc(); ! 334: if(f==0) ! 335: f=windowproc; ! 336: return newproc(f); ! 337: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.