1: /*
   2:  * Copyright (c) 1985 University of Alberta *
   3:  */
   4: 
   5: #ifndef lint
   6: static char *rcsid_dofile_c = "$Header: dofile.c,v 10.2 86/02/01 15:59:47 tony Rel $";
   7: #endif
   8: 
   9: #include "site.h"
  10: #include "imPdefs.h"
  11: #include "imPcodes.h"
  12: #include "impv.h"
  13: #include <stdio.h>
  14: #ifndef XWIND
  15: #include <pixrect/pixrect_hs.h>
  16: #endif
  17: 
  18: dofile()
  19: {
  20:     register int i, j, code;
  21:     register struct glyph *gp;
  22:     register unsigned char *p;
  23: #ifdef COLOR
  24:     register int k, *tp;
  25:     int t, tmp[1000];
  26:     unsigned char setcolor();
  27: #endif COLOR
  28:     short rwid, iwid;
  29:     short hsize, vsize;
  30:     MSKWORD mw;
  31: 
  32:     while ((code = gc()) == '@')    /* skip document control stuff */
  33:         while ((code = gc()) != ')')
  34:         if (code == '"') while(gc() != '"');
  35:     do{
  36:         if(code & 0200) decode(code);
  37:         switch(code){
  38:         case ASP0:
  39:             HPos += SpaceSize;
  40:             break;
  41:         case ASP1:
  42:             HPos += SpaceSize + 1;
  43:             break;
  44:         case AM:
  45:             EXTSIGN(1);
  46:             HPos += V(1);
  47:             break;
  48:         case AMM:
  49:             HPos--;
  50:             break;
  51:         case AMP:
  52:             HPos++;
  53:             break;
  54:         case ASRULE:
  55:             EXTSIGN(3);
  56:             P_rule();
  57:             break;
  58:         case ABRULE:
  59:             P_rule();
  60:             break;
  61:         case ASGLY:
  62:             EXTSIGN(4);
  63:             EXTSIGN(6);
  64:         case ABGLY:
  65:             fam = (V(1)>>7)&0177;
  66:             if(family[fam] == 0){
  67:                 family[fam] = (struct glyph *)malloc((unsigned)sizeof font0);
  68:                 for(i=127; i >= 0; i--)
  69:                     family[fam][i].bits = 0;
  70:                 fam_rot[fam] = (V(1)>>14) & 03;
  71:             }
  72:             gp = &family[fam][0177&V(1)];
  73:             gp->advance = V(2);
  74:             gp->left = V(4);
  75:             gp->top = V(6);
  76:             rwid = ( V(3) + 7) >> 3;
  77: #ifdef COLOR
  78:             if( slide )
  79:             {
  80:                 gp->width = (V(3) + 2) / 3;
  81:                 gp->height = (V(5) + 2) / 3;
  82:                 iwid = gp->height * gp->width;
  83:                 gp->bits = (unsigned char *)malloc((unsigned)iwid);
  84:                 for (p = gp->bits, i = iwid; i--;) *p++ = 0;
  85:                 for (tp = tmp, i = (gp->width * 3); i--;) *tp++ = 0;
  86: 
  87:                 for (i = 0; i < V(5); i++)
  88:                 {
  89:                 for (j = 0; j < rwid; j++)
  90:                 {
  91:                     t = gc();
  92:                     for (k = 8; k--;)
  93:                     tmp[j * 8 + (7 - k)]
  94:                         = (t & (1 << k)) ? 1 : 0;
  95:                 }
  96:                 tp = tmp;
  97:                 p = &gp->bits[i/3 * gp->width];
  98:                 for (j = gp->width; j--;)
  99:                     *p++ += *tp++ + *tp++ + *tp++;
 100:                 }
 101:                 for (p = gp->bits, i = iwid; i--; p++)
 102:                 *p = (*p + 1) / 2;
 103:             } else
 104: #endif COLOR
 105:             {
 106:                 gp->width = (V(3) + 1) >> 1;
 107:                 gp->height = (V(5) + 1) >> 1;
 108:                 /*round size to nearest byte size */
 109:                 iwid = ( gp->width + 7) >> 3;
 110:                 gp->bits = (unsigned char *)malloc((unsigned)gp->height * iwid);
 111:                 /* for the height of the glyph */
 112:                 for (i=0; i<V(5); i++) {
 113:                 /* point at the bytes of glyph storage*/
 114:                 p = &gp->bits[(i>>1) * iwid];
 115:                 /* for two bytes at a time */
 116:                 for (j=0; j < rwid; j += 2, p++) {
 117:                     /* squeez the first byte 4 left */
 118:                     mw = map8_4[gc()]<<4;
 119:                     /* if not the last byte squeez */
 120:                     /* in another */
 121:                     if (j < (rwid - 1))
 122:                          mw |= map8_4[gc()];
 123:                     /* or store byte if i odd */
 124:                     if(i&1) *p |= mw;
 125:                     /* store byte if even */
 126:                     else *p = mw;
 127:                 }
 128:                 }
 129:             }
 130:             break;
 131:         case ADELC:
 132:         case ADELG:
 133:             gp = &family[0177 & (V(1)>>7) ][0177 & V(1)];
 134:             if(gp->bits) free((char *)gp->bits);
 135:             gp->bits = 0;
 136:             break;
 137:         case ADELF:
 138:             fam =0177 & V(1);
 139:             if(family[fam] == 0) break;
 140:             for(i = 127; i >= 0; i--){
 141:                 gp = &family[fam][i];
 142:                 if(gp->bits) free((char *)gp->bits);
 143:                 gp->bits = 0;
 144:             }
 145:             break;
 146:         case AMARGIN:
 147:             BeginOfLine = V(1);
 148:             break;
 149:         case ABSKIP:
 150:             InterLine = V(1);
 151:             break;
 152:         case AN:
 153:             HPos = BeginOfLine;
 154:             VPos += InterLine;
 155:             break;
 156:         case AEND:
 157:             if( ppause()) return;
 158:         case APAGE:
 159:             HPos = VPos = 0;
 160:             break;
 161:         case AF:
 162:             CurFamily =0177&V(1);
 163:             break;
 164:         case ASETSP:
 165:             SpaceSize = V(1);
 166:             break;
 167:         case AH:
 168:             if( V(1) & 01) HPos += V(1) >> 1;
 169:             else HPos = V(1) >> 1;
 170:             break;
 171:         case AV:
 172:             if( V(1) & 01) VPos += V(1) >> 1;
 173:             else VPos = V(1) >> 1;
 174:             break;
 175:         case ASET_HV_SYS:
 176:             /*page orientation  not done*/
 177:             set_hv_sys();
 178:             break;
 179:         case ASET_ABS_H:
 180:             /*set abs major advance pos*/
 181:             HPos = V(1);
 182:             break;
 183:         case ASET_ABS_V:
 184:             /*set abs minor advance pos*/
 185:             VPos = V(1);
 186:             break;
 187:         case ASET_REL_H:
 188:             /*set rel major advance pos*/
 189:             HPos += V(1);
 190:             break;
 191:         case ASET_REL_V:
 192:             /*set rel minor advance pos*/
 193:             VPos += V(1);
 194:             break;
 195:         case AROTMS:
 196:             /*set advance directions not done*/
 197:             advance_dir = v(1);
 198:             break;
 199:         case AMMOVE:
 200:             /*add to main dir  not done*/
 201:             if(orient == 0) HPos += V(1);
 202:             break;
 203:         case ASMOVE:
 204:             /*add to main dir  not done*/
 205:             if(orient == 0) VPos += V(1);
 206:             break;
 207:         case ACREATE_MAP:
 208:             /*create font map not done*/
 209:             /* get name  and size*/
 210:             map_name = v(1);
 211:             ntuples = v(2);
 212:             /* read and throw away bytes */
 213:             for (i=0;i<ntuples*4;i++) (void)gc();
 214: #ifdef notdef
 215:             /* get memory for ntuples*/
 216:             map = (map_ptr *)malloc(ntuples * sizeof int);
 217:             /* read in map */
 218:             for(i=0;i<ntuples;i++) {
 219:                 get and store byte word byte
 220:                     map = map;
 221:             }
 222: #endif
 223:             break;
 224:         case ACREATE_FAMILY:
 225:             /* create family table not done */
 226:             /* get family name and size*/
 227:             fam_in = v(1);
 228:             ntuples = v(2);
 229:             for (i=0;i<ntuples;i++) {
 230:                 (void)gc();
 231:                 while(gc()!=NULL);
 232:             }
 233: #ifdef notdef
 234:             /* get memory for ntuples*/
 235:             /* read in family */
 236:             for(i=0;i<ntuples;i++) {
 237:                 get and store byte string*
 238:             }
 239: #endif
 240:             break;
 241:         case AFORCE_GLY_DELETE:
 242:             /*delete marked glyphs  */
 243:             break;
 244:         case ASET_PATH:
 245:             /*get a line path */
 246:             /*get vertexcount*/
 247:             vertex_count = V(1);
 248:             path_point = (struct path *)malloc
 249:                 (vertex_count * 2 * (sizeof(short)));
 250: #ifdef COLOR
 251:             if (slide)
 252:                 for (i=0; i<vertex_count; i++) {
 253:                     (path_point+i)->hor = getint() / 3;
 254:                     (path_point+i)->vert = getint() / 3;
 255:                 }
 256:             else
 257: #endif COLOR
 258:             {
 259:                 for (i=0; i<vertex_count; i++) {
 260:                     (path_point+i)->hor = (getint() >> 1);
 261:                     (path_point+i)->vert = (getint() >> 1);
 262:                 }
 263:             }
 264:             break;
 265:         case ASET_TEXTURE:
 266:             /*set texture for lines? */
 267:             fam = (V(1) >> 7) & 0177;
 268:             member = V(1) & 0177;
 269:             break;
 270:         case ASET_PEN:
 271:             /*set pen diameter */
 272: #ifdef COLOR
 273:             if(slide)
 274:                 diameter = (v(1)+2) / 3;
 275:             else
 276: #endif COLOR
 277:                 diameter = (v(1)+1) > 1;
 278:             break;
 279:         case ADRAW_PATH:
 280:             /* draw a path of bits or lines */
 281:             operation = v(1);
 282:             if (diameter < 4){ /* draw up to 4 || lines */
 283:                 for(j=0; j<(vertex_count-1); j++){
 284:                     for(i=0; i<diameter; i++){
 285:                         draw_path1((path_point+j)->hor,
 286:                         (path_point+j)->vert,
 287:                         (path_point+j+1)->hor,
 288:                         (path_point+j+1)->vert);
 289:                     }
 290:                 }
 291:             }
 292:             else {
 293:                 /* draw a path wider than 4 lines */
 294:                 for(j=0; j<vertex_count; j++) (void)fflush(stdout);
 295:             }
 296:             break;
 297:         case AFILL_PATH:
 298:             /* fill in a polygon   not done*/
 299:             operation = v(1);
 300:             break;
 301:         case ABIT_MAP:
 302:             /* get a bit map  not done*/
 303:             operation = v(1);
 304:             hsize = v(2);
 305:             vsize = v(3);
 306:             Prnt_Bitmap(hsize,vsize);
 307:             break;
 308:         case ASET_MAGNIFICATION:
 309:             magnification = v(1);
 310:             break;
 311:         case ASET_PUSH_MASK:
 312:             /* set the state mask */
 313:             push_mask = V(1);
 314:             break;
 315:         case APUSH:
 316:             /*push a state onto the state stack */
 317:             push_stack[pushed] = (struct state *)
 318:                 malloc((unsigned)sizeof pstack);
 319:             stap = push_stack[pushed];
 320:             stap->push_mask =push_mask;
 321:             if(push_mask& 0400) {
 322:                 stap->diameter = diameter;
 323:                 stap->texture = texture;
 324:             }
 325:             if(push_mask& 0200) stap->SpaceSize = SpaceSize;
 326:             if(push_mask& 0100) stap->InterLine = InterLine;
 327:             if(push_mask& 040) stap->BeginOfLine = BeginOfLine;
 328:             if(push_mask& 020) stap->fam = fam;
 329:             if(push_mask& 010) {
 330:                 stap->HPos = HPos;
 331:                 stap->VPos = VPos;
 332:             }
 333:             if(push_mask& 04) stap->advance_dir = advance_dir;
 334:             if(push_mask& 02) {
 335:                 stap->horigin = horigin;
 336:                 stap->vorigin = vorigin;
 337:             }
 338:             if(push_mask& 01) stap->orient = orient;
 339:             pushed++;
 340:             break;
 341:         case APOP:
 342:             /*pop a state off the state stack */
 343:             if(pushed >= 1) {
 344:                 pushed--;
 345:                 stap = push_stack[pushed];
 346:                 push_mask =  stap->push_mask;
 347:                 if(push_mask& 0400) {
 348:                     diameter = stap->diameter;
 349:                     texture = stap->texture;
 350:                 }
 351:                 if(push_mask& 0200) SpaceSize = stap->SpaceSize;
 352:                 if(push_mask& 0100) InterLine = stap->InterLine;
 353:                 if(push_mask& 040) BeginOfLine = stap->BeginOfLine;
 354:                 if(push_mask& 020) fam = stap->fam;
 355:                 if(push_mask& 010) {
 356:                     HPos = stap->HPos;
 357:                     VPos = stap->VPos;
 358:                 }
 359:                 if(push_mask& 04) advance_dir = stap->advance_dir;
 360:                 if(push_mask& 02) {
 361:                     horigin = stap->horigin;
 362:                     vorigin = stap->vorigin;
 363:                 }
 364:                 if(push_mask& 01) orient = stap->orient;
 365:                 free((char *)push_stack[pushed]);
 366:             }
 367:             else fprintf(stderr, "Can not pop more states\n");
 368:             break;
 369:         case ADEFINE_MACRO:
 370:             /* define a macro  */
 371:             /* get the name v(1) and length V(2) of the macro*/
 372: #ifdef COLOR
 373:             if (v(1) == 255)
 374:             {
 375:                 if (gc() == 0 )
 376:                 {
 377:                 bc.red = (float)gc();
 378:                 bc.green = (float)gc();
 379:                 bc.blue = (float)gc();
 380:                 if( slide )
 381:                 {
 382:                     backcolor = setcolor(0);
 383:                     p = (unsigned char *)(mpr_d(pscreen)->md_image);
 384:                     for (i = scr_size; i--;)
 385:                         *p++ = backcolor;
 386:                  }
 387:                 }
 388:                 else
 389:                 {
 390:                 cc.red = (float)gc();
 391:                 cc.green = (float)gc();
 392:                 cc.blue = (float)gc();
 393:                 }
 394:                  }
 395:              else
 396: #endif COLOR
 397:              {
 398:              macro[v(1)].length = V(2);
 399:              macro_length = V(2);
 400:              /* get space equal to length */
 401:              mp = macro[v(1)].pointer =
 402:                  (unsigned char *)malloc((unsigned)macro_length);
 403:              /*read the macro into the got space*/
 404:              for(i=0;i<macro_length; i++) mp[i] = gc();
 405:              }
 406:             break;
 407:         case AEXECUTE_MACRO:
 408:             /* execute a macro */
 409:             macro_length = macro[v(1)].length;
 410:             mp = macro[v(1)].pointer;
 411:             macro_on = TRUE;
 412:             break;
 413:         case ANOP:
 414:             break;
 415:         default:
 416:             if(!(code&0200)) {
 417:                 gp = &family[CurFamily][code];
 418:                 Prnt_Glyph(&family[CurFamily][code]);
 419:             }
 420:             else {
 421:                 (void)write(1,'$',1);
 422:             }
 423:         }
 424:     }
 425:     while (AEOF != (code=gc()) );
 426: }
 427: 
 428: char r_mask[9] = {
 429:     0, 01, 03, 07, 017, 037, 077, 0177, 0377 };
 430: char l_mask[9] = {
 431:     0377, 0376, 0374, 0370, 0360, 0340, 0300, 0200, 00 };
 432: Prnt_Glyph(gp)
 433: register struct glyph *gp;
 434: {
 435:     register int i, bit_width, skew;
 436:     register unsigned char *sp, *base;
 437:     register unsigned char *bp = gp->bits;
 438:     short  x_bit_pos, y_bit_pos;
 439: #ifdef COLOR
 440:     short int j;
 441:     unsigned char setcolor();
 442: #endif COLOR
 443: 
 444: #ifdef COLOR
 445:     if( slide )
 446:     {
 447:         x_bit_pos = (HPos - gp->left + 2) / 3;
 448:         y_bit_pos = (VPos - gp->top + 2) / 3;
 449:         base = ((unsigned char *)(mpr_d(pscreen)->md_image))
 450:            + y_bit_pos * scr_x + x_bit_pos;
 451:     }
 452:     else
 453: #endif COLOR
 454:     {
 455:         x_bit_pos = (HPos - gp->left + 1) >> 1;
 456:         y_bit_pos = (VPos - gp->top + 1) >> 1;
 457:         if(((((HPos+1) >>1) + gp->width) > scr_x) ||
 458:             ((((VPos+1)>>1) + gp->height) > scr_y) || bp == 0)
 459:         {
 460:             big++;
 461:             return;
 462:         }
 463:         if((x_bit_pos < 0) || (y_bit_pos < 0) )
 464:         {
 465:             (void)write(1,'-',1);
 466:             little++;
 467:             return;
 468:         }
 469: #ifdef XWIND
 470:         base = pscreen
 471: #else XWIND
 472:         base = ((unsigned char *)(mpr_d(pscreen)->md_image))
 473: #endif XWIND
 474:            + (y_bit_pos * wide) + (x_bit_pos >> 3);
 475:     }
 476:     /* skew is bits displacement of glyph from a byte edge*/
 477:     skew = 8 - (x_bit_pos & 07);
 478: 
 479: #ifdef COLOR
 480:     if (slide)
 481:     {
 482:         for (i = gp->height; i--; base += scr_x)
 483:         {
 484:             sp = base;
 485:             for (j = gp->width; j--;)
 486:                 if( *bp != 0 )
 487:                     *sp++ = setcolor(*bp++);
 488:                 else
 489:                 {
 490:                     bp++;
 491:                     sp++;
 492:                 }
 493:         }
 494:     }
 495:     else
 496: #endif COLOR
 497:     {
 498:         for(i = gp->height; i--; base += wide){
 499:         sp = base;
 500:         for(bit_width = gp->width; bit_width > 0;){
 501:             if(skew == 8){
 502:                 *sp++ |= *bp++;
 503:                 bit_width -= 8;
 504:             }
 505:             else {
 506:                 *sp++ |= (*bp >> (8 - skew)) & r_mask[skew];
 507:                 if((bit_width -= skew) <= 0){
 508:                     bp++;
 509:                     break;
 510:                 }
 511:                 *sp |= (*bp++ << skew) & l_mask[skew];
 512:                 bit_width -= (8 - skew);
 513:             }
 514:         }
 515:         }
 516:     }
 517:     HPos += gp->advance;
 518: }
 519: 
 520: char l_bits[8] = {
 521:     0377, 0200, 0300, 0340, 0360, 0370, 0374, 0376};
 522: P_rule()
 523: {
 524:     register int i, bit_width, skew;
 525:     register unsigned char *sp, *base;
 526:     register int bits_l;
 527:     short  x_bit_pos, y_bit_pos;
 528: 
 529:     if(((V(1) + HPos) > 2048) || ((V(2) + VPos) > 2640)) {
 530:         big++;
 531:         return;
 532:     }
 533:     x_bit_pos = (HPos + 1) >> 1;
 534:     y_bit_pos = (VPos + V(3) + 1) >> 1;
 535:     if((x_bit_pos < 0) || (y_bit_pos < 0)){
 536:         (void)write(1,'-',1);
 537:         little++;
 538:         return;
 539:     }
 540: #ifdef XWIND
 541:     base = pscreen
 542: #else
 543:     base = ((unsigned char *)(mpr_d(pscreen)->md_image))
 544: #endif
 545:         + (y_bit_pos * wide) + (x_bit_pos >> 3);
 546:     skew = 8 - (x_bit_pos & 07);
 547:     V(1) = (V(1) + 1) >> 1;
 548:     V(2) = (V(2) + 1) >> 1;
 549:     for(i = V(2); i--; base += wide){
 550:         sp = base;
 551:         for(bit_width = V(1); bit_width > 0;){
 552:             bits_l = l_bits[bit_width>7 ? 0 : bit_width];
 553:             if(skew == 8){
 554:                 *sp++ |= bits_l;
 555:                 bit_width -= 8;
 556:             }
 557:             else {
 558:                 *sp++ |= (bits_l >> (8 - skew)) & r_mask[skew];
 559:                 if((bit_width -= skew) <= 0) break;
 560:                 *sp |= (bits_l << skew) & l_mask[skew];
 561:                 bit_width -= (8 - skew);
 562:             }
 563:         }
 564:     }
 565: }
 566: 
 567: set_hv_sys()
 568: {
 569:     register int norigin, naxes, norient;
 570: 
 571:     /*set a logical page orientation relative to the physical pagenot done*/
 572:     norigin = (v(1)>>5 )& 03;
 573:     naxes = (v(1)>>3)& 03;
 574:     norient = v(1)&07;
 575:     if(norient < 4) orient = (orient+norient)%4;
 576:     else orient = norient - 4;
 577:     set_axes(naxes, norigin);
 578: 
 579: }
 580: 
 581: set_axes(ax, or)
 582: int ax, or;
 583: {
 584:     switch (ax){
 585:     case 0:
 586:         break;
 587:     case 1:
 588:         hvangle = -hvangle;
 589:         break;
 590:     case 2:
 591:         hvangle = 1;
 592:         break;
 593:     case 3:
 594:         hvangle = -1;
 595:         break;
 596:     }
 597:     set_origin(or);
 598: }
 599: 
 600: set_origin(or)
 601: int or;
 602: {
 603:     /*set the origin of the logical page relative to the physical*/
 604:     switch (or){
 605:     case 0:
 606:         break;
 607:     case 1:
 608:         break;
 609:     case 2:
 610:         originlv =  0;
 611:         switch (orient){
 612:         case 0:
 613:             originlh =  0;
 614:             break;
 615:         case 1:
 616:             originlh =  MAXx;
 617:             break;
 618:         case 2:
 619:         case 3:
 620:             originlh =  MAXy;
 621:             break;
 622:         }
 623:     case 3:
 624:         if(orient == 1 ||orient == 3){
 625:             originlh =  xpos;
 626:             originlv =  ypos;
 627:         }
 628:         else{
 629:             originlv =  xpos;
 630:             originlh =  ypos;
 631:         }
 632:         break;
 633:     }
 634: }
 635: 
 636: draw_path1(x0, y0, x1, y1)  /* draw line from here to x0, y0, x1, y1 */
 637: int x0, y0, x1, y1;
 638: {
 639:     int d, xd, yd, dx, dy, incr1, incr2;
 640:     int i, numdots;
 641:     int motincrx, motincry;
 642: 
 643:     xd = x1 - x0;
 644:     yd = y1 - y0;
 645:     dx = abs(xd);
 646:     dy = abs(yd);
 647:     /* sort between vertical, horizontal and in between */
 648:     put1(x0, y0);
 649:     if (xd == 0) {
 650:         numdots = abs (yd);
 651:         motincry = (yd<0)? -1 : 1;
 652:         for (i = 0; i < numdots; i++) {
 653:             y0 += motincry;
 654:             put1(x0, y0);
 655:         }
 656:         return;
 657:     }
 658:     if (yd == 0) {
 659:         numdots = abs (xd);
 660:         motincrx = (xd<0)? -1 : 1;
 661:         for (i = 0; i < numdots; i++) {
 662:             x0 += motincrx;
 663:             put1(x0, y0);
 664:         }
 665:         return;
 666:     }
 667:     if (abs (xd) > abs (yd)) { /* slope less than 1 */
 668:         d = 2 * dy -dx;
 669:         incr1 = 2 * dy;
 670:         incr2 = 2 * (dy - dx);
 671:         numdots = abs (xd);
 672:         motincrx = (xd<0)? -1 : 1;
 673:         motincry = (yd<0)? -1 : 1;
 674:         for (i = 0; i < numdots; i++) {
 675:             put1(x0, y0);
 676:             x0 += motincrx;
 677:             if(d < 0) d = d + incr1;
 678:             else{
 679:                 y0 += motincry;
 680:                 d = d + incr2;
 681:             }
 682:         }
 683:     }
 684:     else { /* slope more than 1 */
 685:         d = 2 * dx -dy;
 686:         incr1 = 2 * dx;
 687:         incr2 = 2 * (dx - dy);
 688:         numdots = abs (yd);
 689:         motincrx = (xd<0)? -1 : 1;
 690:         motincry = (yd<0)? -1 : 1;
 691:         for (i = 0; i < numdots; i++) {
 692:             put1(x0, y0);
 693:             y0 += motincry;
 694:             if(d < 0) d = d + incr1;
 695:             else{
 696:                 x0 += motincrx;
 697:                 d = d + incr2;
 698:             }
 699:         }
 700:     }
 701: }
 702: 
 703: 
 704: /* set the value of a t byte (texture) */
 705: t_byte(x, y)
 706: int x, y;
 707: {
 708: 
 709:     if(fam == 0 && member == 0)
 710:         return(r_mask[9]);
 711:     /* else find the byte in the glyph mask */
 712:     return( *(family[fam][member].bits + ((x & 017) >> 3) + 2 * (y & 017)) );
 713: }
 714: 
 715: /* put a pixel onto a page image. */
 716: put1(x,y)
 717: int x, y;
 718: {
 719:     register int skew;
 720:     short  x_bit_pos, y_bit_pos;
 721:     register unsigned char *pbyte, tbyte;
 722: #ifdef COLOR
 723:     unsigned char setcolor();
 724: #endif COLOR
 725: 
 726:     x_bit_pos = x;
 727:     y_bit_pos = y;
 728:     if((x_bit_pos > scr_x) || (y_bit_pos > scr_y)) {
 729:         (void)write(1, "+pix", 4);
 730:         return;
 731:     }
 732:     if((x_bit_pos < 0) || (y_bit_pos < 0) ) {
 733:         (void)write(1,'-',1);
 734:         return;
 735:     }
 736: #ifdef COLOR
 737:     if( slide )
 738:     {
 739:         pbyte = ((unsigned char *)(mpr_d(pscreen)->md_image))
 740:            + (y_bit_pos * scr_x) + x_bit_pos;
 741:     }
 742:     else
 743: #endif COLOR
 744:     {
 745: #ifdef XWIND
 746:         pbyte = pscreen
 747: #else
 748:         pbyte = ((unsigned char *)(mpr_d(pscreen)->md_image))
 749: #endif
 750:             +(y_bit_pos * wide) + (x_bit_pos >> 3);
 751:     }
 752:     /* skew is bits displacement of pixel from a byte edge*/
 753:     skew = 8 - (x_bit_pos & 07);
 754: #ifdef COLOR
 755:     if(slide)
 756:     {
 757:         switch(operation) {
 758:         case(0):
 759:             *pbyte = backcolor;
 760:             break;
 761:         case(3):
 762:         case(7):
 763:         default:
 764:             *pbyte = setcolor(5);
 765:             break;
 766:         }
 767:     }
 768:     else
 769: #endif COLOR
 770:     {
 771:         switch(operation)
 772:         {
 773:         case(0): /* clear the bit */
 774:             if (skew == 8) *pbyte &= r_mask[skew-1];
 775:             else *pbyte &= (r_mask[skew-1] | l_mask[skew+1]);
 776:             return;
 777:         case(3): /* opaque with t bit */
 778:             tbyte = t_byte(x, y);
 779:             if (skew == 8) *pbyte &= r_mask[skew-1];
 780:             else *pbyte &= (r_mask[skew-1] | l_mask[skew+1]);
 781:             if (skew == 8) tbyte &= r_mask[skew-1];
 782:             else tbyte &= (r_mask[skew-1] | l_mask[skew+1]);
 783:             *pbyte &= tbyte;
 784:             return;
 785:         case(7):/* or with t bit */
 786:             tbyte = t_byte(x, y);
 787:             if (skew == 8) tbyte &= r_mask[skew-1];
 788:             else tbyte &= (r_mask[skew-1] | l_mask[skew+1]);
 789:             *pbyte |= tbyte;
 790:             return;
 791:         default: /* black the bit */
 792:             if(skew == 8) *(pbyte-1) |=  1;
 793:             else *pbyte |=  1 << skew;
 794:             return;
 795:         }
 796:     }
 797: }
 798: 
 799: #ifdef notdef
 800: /* put a line onto a page image. */
 801: putline(xstart,xend,y)
 802: int xstart,xend,y;
 803: {
 804:     register int nbytes, xh, xs, i;
 805:     unsigned char pbyte, tbyte, *scptr;
 806: 
 807:     /* find how many bytes are affected by the line*/
 808:     nbytes=1;
 809:     if (xstart/8 != xend/8) nbytes += xend/8 - xstart/8;
 810:     switch(operation){
 811:         case(0): /* clear the bytes */
 812:         for(i=0; i< nbytes; i++){
 813:             xh = xstart/8;
 814:             xs = xstart%8;
 815: #ifdef XWIND
 816:             scptr = pscreen;
 817: #else
 818:             scptr = (unsigned char *)(mpr_d(pscreen)->md_image);
 819: #endif
 820:             pbyte = *scptr+y*wide+xh;
 821:             if((xend+1)/8 > xh+1)
 822:                 pbyte &= l_mask[xs];
 823:             else
 824:                 pbyte &= (l_mask[xs]
 825:                     & r_mask[(xend+1)%8]);
 826:             *(scptr+y*wide+xh) = pbyte;
 827:             xstart = xstart + 8 - xs;
 828:         }
 829:         return;
 830: 
 831:         case(15):/* black the bit */
 832:         for(i=0; i< nbytes; i++){
 833:             xh = xstart/8;
 834:             xs = xstart%8;
 835:             pbyte = *scptr+y*wide+xh;
 836:             if((xend+1)/8 > xh+1)
 837:                 pbyte &= r_mask[8 - xs];
 838:             else
 839:                 pbyte &= (r_mask[8 - xs]
 840:                     & l_mask[8 - (xend+1)%8]);
 841:             *(scptr+y*wide+xh) = pbyte;
 842:             xstart = xstart + 8 - xs;
 843:         }
 844:         return;
 845: 
 846:         case(3): /* opaque with t bit */
 847:         for(i=0; i< nbytes; i++){
 848:             xh = xstart >> 3;
 849:             xs = xstart & 07;
 850:             pbyte = *scptr+wide*y+xh;
 851:             if((xend+1)/8 > xh+1)
 852:                 pbyte &= l_mask[xs]
 853:                 & t_byte(xstart, (xstart+8-xs), y);
 854:             else
 855:                 pbyte &= (l_mask[xs]
 856:                     & r_mask[(xend+1)%8])
 857:                     & t_byte(xstart, xend, y);
 858:             *(scptr+y*wide+xh) = pbyte;
 859:             xstart = xstart + 8 - xs;
 860:         }
 861:         return;
 862: 
 863:         case(7):/* or with t bit */
 864:         for(i=0; i< nbytes; i++){
 865:             xh = xstart/8;
 866:             xs = xstart%8;
 867:             pbyte = *scptr+wide*y+xh;
 868:             if((xend+1)/8 > xh+1)
 869:                 pbyte |=
 870:                 t_byte(xstart, (xstart+8-xs), y);
 871:             else
 872:                 pbyte |=
 873:                     t_byte(xstart, xend, y);
 874:             *(scptr+y*wide+xh) = pbyte;
 875:             xstart = xstart + 8 - xs;
 876:         }
 877:         return;
 878:     }
 879: }
 880: #endif
 881: Prnt_Bitmap(hsize, vsize)
 882: short int hsize, vsize;
 883: {
 884:     register short int i, j, k, l;
 885:     register unsigned char *sp;
 886:     unsigned char mw, *base, *basev, *baseb;
 887:     short  x_bit_pos, y_bit_pos;
 888: 
 889:     /*
 890: 		 * get the bits and put them ???
 891: 		 */
 892:     x_bit_pos = (HPos + 1) >> 1;
 893:     y_bit_pos = (VPos + 1) >> 1;
 894:     if((((HPos+hsize*4+1) >> 1)  > scr_x) || (((VPos+vsize*32+1) >> 1) > scr_y)){
 895:         big++;
 896:         return;
 897:     }
 898:     if((x_bit_pos < 0) || (y_bit_pos < 0) ) {
 899:         (void)write(1,'-',1);
 900:         little++;
 901:         return;
 902:     }
 903: #ifdef XWIND
 904:     base = pscreen
 905: #else
 906:     base = ((unsigned char *)(mpr_d(pscreen)->md_image))
 907: #endif
 908:         +(y_bit_pos * wide) + (x_bit_pos >> 3);
 909:     basev = base;
 910:     if(magnification == 0) for(i=0;i<vsize;i++) {
 911:         /* rows of cols of 32*32 blocks */
 912:         baseb = basev;
 913:         /* cols of 32*32 blocks */
 914:         for(j=0;j<hsize;j++) {
 915:             sp = baseb;
 916:             /* block of 32*32 */
 917:             for(k=0;k<32;k++) {
 918:                 /* row of 32 bits in 32*32 block*/
 919:                 /* point at the bytes of glyph storage*/
 920:                 /* for two bytes at a time */
 921:                 for (l=0; l < 2; l++, sp++) {
 922:                     /* squeez the first byte 4 left */
 923:                     mw = map8_4[gc()]<<4;
 924:                     mw |= map8_4[gc()];
 925:                     /* or store byte if k odd */
 926:                     if(k&1) *sp |= mw;
 927:                     /* store byte if even */
 928:                     else *sp = mw;
 929:                 }
 930:                 sp = baseb + wide * ((1+k)>>1);
 931:                 /* add 1 line to v pos if odd*/
 932:             }
 933:             baseb = basev + 2 * (j+1);
 934:             /* add 16 bits to h pos */
 935:         }
 936:         basev = base + wide * 16 *(i+1);
 937:         /* squeeze to 1/2 height*/
 938:     }
 939:     else if (magnification == 1)
 940:         for (i=0; i<vsize; i++) {
 941:         baseb = basev;
 942:         for (j=0; j<hsize; j++) {
 943:             sp = baseb;
 944:             for (k=0; k<32; k++) {
 945:                 /* point at the bytes of glyph storage*/
 946:                 for (l=4; l; l--) *sp++ = gc();
 947:                 sp += 124;
 948:             }
 949:             baseb += 4;
 950:         }
 951:         basev = base + wide * 32 *i;
 952:     }
 953: }

Defined functions

P_rule defined in line 522; used 2 times
Prnt_Bitmap defined in line 881; used 1 times
Prnt_Glyph defined in line 432; used 1 times
dofile defined in line 18; used 1 times
draw_path1 defined in line 636; used 1 times
put1 defined in line 716; used 5 times
putline defined in line 801; never used
set_axes defined in line 581; used 1 times
set_hv_sys defined in line 567; used 1 times
set_origin defined in line 600; used 1 times
t_byte defined in line 705; used 6 times

Defined variables

l_bits defined in line 520; used 1 times
l_mask defined in line 430; used 11 times
r_mask defined in line 428; used 15 times
rcsid_dofile_c defined in line 6; never used
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2169
Valid CSS Valid XHTML 1.0 Strict