home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 311.lha / Wipedemo_v4.0 / mywipe2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-12-10  |  30.9 KB  |  1,527 lines

  1. /* mywipe.h by Paul Falstad */
  2.  
  3. extern long numplanes;
  4. long mx,my,cx,cy,bx,by,topcol,yadd,bpr,D4Store,A5Store;
  5. long rsa[32],gsa[32],bsa[32],rsb[32],gsb[32],bsb[32];
  6. #include "wipecount.h"
  7. #include "jiff.h"
  8. #define CX(X) ((X) << cx)
  9. #define CY(Y) ((Y) << cy)
  10. struct RastPort *MaskRast = 0;
  11. struct BitMap *OldMap,*NewMap;
  12. WORD BMod;
  13. PLANEPTR AllocClearRaster();
  14.  
  15. struct BitMap *SetupMaps(info,wn)
  16. struct ILBM_info *info;
  17. int wn;
  18. {
  19. static struct BitMap MBitMap,OBitMap,NBitMap;
  20. static struct RastPort MRast;
  21. int t0,neww,newh;
  22.  
  23.    InitBitMap(&NBitMap,numplanes,mx,my);
  24.    for (t0 = 0; t0 != numplanes; t0++)
  25.       if (!(NBitMap.Planes[t0] = AllocClearRaster(mx,my)))
  26.          {
  27.          while (t0)
  28.             FreeRaster(NBitMap.Planes[--t0],mx,my);
  29.          free_planes(&info->bitmap);
  30.          TheEnd();
  31.          }
  32.    NewMap = &NBitMap;
  33.    neww = info->header.w;
  34.    newh = info->header.h;
  35.    if (neww > mx)
  36.       neww = mx;
  37.    if (newh > my)
  38.       newh = my;
  39.    BltBitMap(&info->bitmap,0L,0L,NewMap,((long) mx-neww) >> 1,
  40.          ((long) my-newh) >> 1,(long) neww,(long) newh,0xc0L,
  41.          (1L << info->header.nPlanes)-1L,0L);
  42.    WaitBlit();
  43.    free_planes(&info->bitmap);
  44.    InitBitMap(&MBitMap,1L,mx,my);
  45.    if ((MBitMap.Planes[0] = (PLANEPTR) AllocRaster(mx,my)) == NULL)
  46.       {
  47.       for (t0 = 0; t0 != numplanes; t0++)
  48.          FreeRaster(NBitMap.Planes[t0],mx,my);
  49.       TheEnd();
  50.       }
  51.    InitRastPort(&MRast);
  52.    MRast.BitMap = &MBitMap;
  53.    SetAPen(&MRast,1L);
  54.    DoTmpStuff(&MRast);
  55.    MaskRast = &MRast;
  56.    InitBitMap(&OBitMap,numplanes,mx,my);
  57.    for (t0 = 0; t0 != numplanes; t0++)
  58.       if ((OBitMap.Planes[t0] = (PLANEPTR) AllocRaster(mx,my)) == NULL)
  59.          {
  60.          while (t0)
  61.             FreeRaster(OBitMap.Planes[--t0],mx,my);
  62.          for (t0 = 0; t0 != numplanes; t0++)
  63.             FreeRaster(NBitMap.Planes[t0],mx,my);
  64.          FreeRaster(MBitMap.Planes[0],mx,my);
  65.          TheEnd();
  66.          }
  67.    OldMap = &OBitMap;
  68.    printf("wipe #%d\n",wn);
  69. }
  70.  
  71. LoadPict(name,WipeScreen,wipesel,cycsel,fadeflag,exclmap,hires,lace)
  72. struct Screen *WipeScreen;
  73. char *name;
  74. int wipesel,fadeflag,cycsel;
  75. BOOL exclmap[WIPECOUNT],hires,lace;
  76. {
  77. int t0,whichwipe,numleft;
  78. struct ILBM_info *info;
  79. static UWORD oldcmap[32];
  80. static BOOL RandMap[WIPECOUNT];
  81. struct BitMap *ScrnMap;
  82. UWORD startword;
  83. long modes;
  84.  
  85. if (hires) { mx = 768; cx = 1; topcol = 16; }
  86.       else { mx = 384; cx = 0; topcol = 32; }
  87. if (lace)  { my = 480; cy = 1; } else { my = 240; cy = 0; }
  88. startword = ((lace) ? 0x7800 : 0x3c00) | ((hires) ? 0x0030 : 0x0018);
  89. bpr = mx/8;
  90.  
  91. bx = mx-1; by = my-1;
  92. modes = WipeScreen->ViewPort.Modes & ~(HAM | EXTRA_HALFBRITE);
  93. StopCringe();
  94. info = read_iff(name,NULL);
  95. if (info == NULL)
  96.    return(NULL);
  97.  
  98. if (info->camg)
  99.    modes = info->camg;
  100.  
  101. if (wipesel == -1)
  102.    {
  103.    for (t0 = numleft = 0; t0 != WIPECOUNT; t0++)
  104.       if (!RandMap[t0] && !exclmap[t0])
  105.          numleft++;
  106.    if (!numleft)
  107.       for (t0 = 0; t0 != WIPECOUNT; t0++)
  108.          RandMap[t0] = FALSE;
  109.    do
  110.       whichwipe = rand() % WIPECOUNT;
  111.    while (RandMap[whichwipe] || exclmap[whichwipe]);
  112.  
  113.    RandMap[whichwipe] = TRUE;
  114.    }
  115. else
  116.    whichwipe = wipesel;
  117.  
  118. SetupMaps(info,whichwipe);
  119.  
  120. GetCols(&WipeScreen->ViewPort,&oldcmap[0]);
  121. for (t0 = 0; t0 != topcol*3; t0++)
  122.    info->cmap[t0] >>= 4;
  123.  
  124. if (!(rand() % 3) && fadeflag)
  125.    {
  126.    if (WipeScreen->ViewPort.Modes & HAM)
  127.       WipeOut(&WipeScreen->ViewPort,&WipeScreen->RastPort,&oldcmap[0],
  128.          info->cmap,mx,my,(int) topcol);
  129.    else
  130.       FadeOut(&WipeScreen->ViewPort,&oldcmap[0],info->cmap);
  131.    SetRast(&WipeScreen->RastPort,0L);
  132.    WipeScreen->ViewPort.Modes = modes;
  133.    }
  134. else
  135.    WipeScreen->ViewPort.Modes = modes;
  136. MakeScreen(WipeScreen);
  137. RethinkDisplay();
  138. BltBitMap(WipeScreen->RastPort.BitMap,
  139.    0L,0L,OldMap,0L,0L,mx,my,0xC0L,(numplanes == 6) ? 0x3fL : 0x0fL,0L);
  140. yadd = BMod = 0;
  141. ScrnMap = WipeScreen->RastPort.BitMap;
  142. for (t0 = 0; t0 != 64; t0++)
  143.    {
  144.    Wipe(ScrnMap,t0,whichwipe,startword);
  145.    FadeColors(&WipeScreen->ViewPort,oldcmap,&info->cmap[0],t0);
  146.    }
  147. FreeAll();
  148. if (cycsel)
  149.    CycleScreen(WipeScreen,info);
  150. }
  151.  
  152. FreeAll()
  153. {
  154. int t0;
  155.  
  156.    for (t0 = 0; t0 != numplanes; t0++)
  157.       FreeRaster(OldMap->Planes[t0],mx,my);
  158.    for (t0 = 0; t0 != numplanes; t0++)
  159.       FreeRaster(NewMap->Planes[t0],mx,my);
  160.    FreeRaster(MaskRast->TmpRas->RasPtr,mx+10L,my+10L);
  161.    FreeRaster(MaskRast->BitMap->Planes[0],mx,my);
  162. }
  163.  
  164. GetCols(vport,cmap)
  165. UWORD *cmap;
  166. struct ViewPort *vport;
  167. {
  168. long t0;
  169.  
  170.    for (t0 = 0; t0 != topcol; t0++)
  171.       {
  172.       cmap[t0] = GetRGB4(vport->ColorMap,t0);
  173.       rsa[t0] = ((cmap[t0] >> 8) & 0x0f) << 6;
  174.       gsa[t0] = ((cmap[t0] >> 4) & 0x0f) << 6;
  175.       bsa[t0] = ((cmap[t0]) & 0x0f) << 6;
  176.       rsb[t0] = gsb[t0] = bsb[t0] = 0;
  177.       }
  178. }
  179.  
  180. FadeOut(vport,cmap,ncmap)
  181. UWORD *cmap;
  182. UBYTE *ncmap;
  183. struct ViewPort *vport;
  184. {
  185. long r,g,b,col;
  186. int or,og,ob;
  187. int nfix;
  188. int step;
  189.  
  190.    for (step = 0; step != 32; step++)
  191.       {
  192.       Delay(1L);
  193.       nfix = 31-step;
  194.       for (col = 0; col != topcol; col++)
  195.          {
  196.          r = (nfix * ((cmap[col] >> 8) & 0x0f));
  197.          g = (nfix * ((cmap[col] >> 4) & 0x0f));
  198.          b = (nfix * ((cmap[col]) & 0x0f));
  199.          SetRGB4(vport,col,r >> 5,g >> 5,b >> 5);
  200.          }
  201.       }
  202.  
  203.    for (col = 0; col != topcol; col++)
  204.       {
  205.       or = ncmap[col*3]; og = ncmap[col*3+1]; ob = ncmap[col*3+2];
  206.       cmap[col] = (or << 8) | (og << 4) | ob;
  207.       rsa[col] = or << 6;
  208.       gsa[col] = og << 6;
  209.       bsa[col] = ob << 6;
  210.       }
  211. }
  212.  
  213. FadeColors(vport,ocmap,ncmap,step)
  214. int step;
  215. BYTE *ncmap;
  216. UWORD *ocmap;
  217. struct ViewPort *vport;
  218. {
  219. long r,g,b,col;
  220. int or,og,ob,cz;
  221.  
  222.    for (col = cz = 0; col != topcol; col++,cz += 3)
  223.       {
  224.       rsa[col] -= (ocmap[col] >> 8) & 0x0f;
  225.       gsa[col] -= (ocmap[col] >> 4) & 0x0f;
  226.       bsa[col] -= (ocmap[col]) & 0x0f;
  227.       rsb[col] += ncmap[cz];
  228.       gsb[col] += ncmap[cz+1];
  229.       bsb[col] += ncmap[cz+2];
  230.       SetRGB4(vport,col,(rsa[col]+rsb[col]) >> 6,
  231.                         (gsa[col]+gsb[col]) >> 6,(bsa[col]+bsb[col]) >> 6);
  232.       }
  233. }
  234.  
  235. void DoTheBlitSh_t(),Sh_tLoop();
  236.  
  237. Wipe(dispbits,step,wipeid,startword)
  238. struct BitMap *dispbits;
  239. int step,wipeid; /* step 0 to 63 */
  240. UWORD startword;
  241. {
  242. int plane;
  243. static BOOL rastinited = FALSE;
  244. PLANEPTR *p1,*p2,p3,*p4;
  245.  
  246. if (step == 0)
  247.    SetRast(MaskRast,0L);
  248.  
  249. switch(wipeid) {
  250.  case 0:
  251.    UpAndDownPanel(MaskRast,step);
  252.    break;
  253.  case 1:
  254.    Random(MaskRast,step);
  255.    break;
  256.  case 2:
  257.    LeftLinePanel(MaskRast,step);
  258.    break;
  259.  case 3:
  260.    Dice(MaskRast,step);
  261.    break;
  262.  case 4:
  263.    GrowBoxes(MaskRast,step);
  264.    break;
  265.  case 5:
  266.    SideToSide(MaskRast,step);
  267.    break;
  268.  case 6:
  269.    TwoClock(MaskRast,step);
  270.    break;
  271.  case 7:
  272.    OneClock(MaskRast,step);
  273.    break;
  274.  case 8:
  275.    RandomOut(MaskRast,step);
  276.    break;
  277.  case 9:
  278.    Spiral(MaskRast,step);
  279.    break;
  280.  case 10:
  281.    ExpandBox(MaskRast,step);
  282.    break;
  283.  case 11:
  284.    Doors(MaskRast,step);
  285.    break;
  286.  case 12:
  287.    WipeUp(MaskRast,step);
  288.    break;
  289.  case 13:
  290.    WipeDown(MaskRast,step);
  291.    break;
  292.  case 14:
  293.    WipeLeft(MaskRast,step);
  294.    break;
  295.  case 15:
  296.    WipeRight(MaskRast,step);
  297.    break;
  298.  case 16:
  299.    WipeDiag(MaskRast,step);
  300.    break;
  301.  case 17:
  302.    TwoBox(MaskRast,step);
  303.    break;
  304.  case 18:
  305.    Shades(MaskRast,step);
  306.    break;
  307.  case 19:
  308.    RandomShade(MaskRast,step);
  309.    break;
  310.  case 20:
  311.    SymArr(MaskRast,step);
  312.    break;
  313.  case 21:
  314.    FourSweep(MaskRast,step);
  315.    break;
  316.  case 22:
  317.    FourLines(MaskRast,step);
  318.    break;
  319.  case 23:
  320.    HexSweep(MaskRast,step);
  321.    break;
  322.  case 24:
  323.    DiagSplit(MaskRast,step);
  324.    break;
  325.  case 25:
  326.    Xes(MaskRast,step);
  327.    break;
  328.  case 26:
  329.    SlideBoxes(MaskRast,step);
  330.    break;
  331.  case 27:
  332.    Cannon(MaskRast,step);
  333.    break;
  334.  case 28:
  335.    Drip(MaskRast,step);
  336.    break;
  337.  case 29:
  338.    MovingWindow(MaskRast,step);
  339.    break;
  340.  case 30:
  341.    Sun(MaskRast,step);
  342.    break;
  343.  case 31:
  344.    Monolith(MaskRast,step);
  345.    break;
  346.  case 32:
  347.    Rain(MaskRast,step);
  348.    break;
  349.  case 33:
  350.    MergeWindows(MaskRast,step);
  351.    break;
  352.  case 34:
  353.    Slides(MaskRast,step);
  354.    break;
  355.  case 35:
  356.    RandomDown(MaskRast,step);
  357.    break;
  358.  case 36:
  359.    Stretch(MaskRast,step);
  360.    break;
  361.  case 37:
  362.    ExpandSlide(MaskRast,step);
  363.    break;
  364.  case 38:
  365.    SlideSlabs(MaskRast,step);
  366.    break;
  367.  case 39:
  368.    Checkerboard(MaskRast,step);
  369.    break;
  370.  case 40:
  371.    MiniRandom(MaskRast,step);
  372.    break;
  373.  case 41:
  374.    ConcentricRectangles(MaskRast,step);
  375.    break;
  376.  case 42:
  377.    Cloverleaf(MaskRast,step);
  378.    break;
  379.  case 43:
  380.    Cloverleaf2(MaskRast,step);
  381.    break;
  382.  case 44:
  383.    ConcentricRectangles2(MaskRast,step);
  384.    break;
  385.    };
  386.  
  387. if (step == 63)
  388.    {
  389.    SetRast(MaskRast,1L);
  390.    yadd = 0;
  391.    }
  392. p1 = &dispbits->Planes[numplanes];
  393. p2 = &NewMap->Planes[numplanes];
  394. p3 = MaskRast->BitMap->Planes[0];
  395. p4 = &OldMap->Planes[numplanes];
  396.  
  397.    OwnBlitter();
  398.    WaitBlit();
  399.    Forbid();
  400.    DoTheBlitSh_t(p1,p2,p3,p4,startword,(int) (numplanes-1));
  401.    Permit();
  402.    DisownBlitter();
  403. }
  404.  
  405. #asm
  406.       cseg
  407. _DoTheBlitSh_t:
  408.       move.l d4,_D4Store
  409.       move.l a5,_A5Store
  410.       clr.l d4
  411.       move.w 22(sp),d4     ;# planes
  412.       movea.l 4(sp),a2     ;&Dest
  413.       movea.l 8(sp),a3     ;&New
  414.       movea.l 16(sp),a5    ;&Old
  415. _Sh_tLoop:
  416.       move.l 12(sp),$dff050 ; A get mask argument
  417.       clr.w $dff060  ; modulos
  418.       move.w _BMod,$dff062   ;BMod
  419.       clr.l $dff064
  420.       move.l #$0fca0000,$dff040 ;bltcon01
  421.       move.l -(a3),d0        ; B
  422.       add.l _yadd,d0        ; add yadd
  423.       move.l d0,$dff04c      ; B
  424.       move.l #$ffffffff,$dff044 ; first & last word masks
  425.       move.l -(a5),$dff048    ;C 
  426.       move.l -(a2),$dff054   ; D
  427.  
  428.       move.w #$8400,$dff096  ; set Blitter Nasty
  429.       move.w 20(sp),$dff058  ; go! (should be $3c18) AB+nAC
  430.       jsr _WaitBlit
  431.       move.w #$0400,$dff096  ; Blitter Nice
  432.       dbf.w d4,_Sh_tLoop
  433.       move.l _D4Store,d4
  434.       movea.l _A5Store,a5
  435.       rts
  436.  
  437. #endasm
  438.  
  439. DoTmpStuff(rp)
  440. struct RastPort *rp;
  441. {
  442. static UWORD areabuffer[125];
  443. PLANEPTR TmpRasPlane;
  444. static struct TmpRas MyTmpRas;
  445. static struct AreaInfo MyAreaInfo;
  446.  
  447. InitArea(&MyAreaInfo,&areabuffer[0],50L);
  448. rp->AreaInfo = &MyAreaInfo;
  449. if (!(TmpRasPlane = AllocRaster(mx+10L,my+10L)))
  450.    TheEnd();
  451. InitTmpRas(&MyTmpRas,TmpRasPlane,RASSIZE(mx+10L,my+10L));
  452. rp->TmpRas = &MyTmpRas;
  453. }
  454.  
  455. PLANEPTR AllocClearRaster(xm,ym)
  456. long xm,ym;
  457. {
  458. PLANEPTR pl;
  459.  
  460.    pl = AllocMem(xm/8L*ym,MEMF_CHIP|MEMF_CLEAR);
  461.    if (!pl)
  462.       return(0L);
  463.    return(pl);
  464. }
  465.  
  466. UpAndDownPanel(rp,step)
  467. struct RastPort *rp;
  468. int step;
  469. {
  470. long t0,t1,t2,t3;
  471.  
  472.    t3 = (step*by)/63;
  473.    for (t0 = 0, t1 = 24, t2 = 48; t0 != 384; t0 += 48, t1 += 48, t2 += 48)
  474.       {
  475.       RectFill(rp,CX(t0),0L,CX(t1)-1L,t3);
  476.       RectFill(rp,CX(t1),by-t3,CX(t2)-1L,by);
  477.       }
  478. }
  479.  
  480. Dice(rp,step)
  481. struct RastPort *rp;
  482. int step;
  483. {
  484. long s3,s2;
  485.  
  486.    s3 = bx*step/126;
  487.    s2 = by*step/126;
  488.    RectFill(rp,0L,0L,s3,s2);
  489.    RectFill(rp,0L,by-s2,s3,by);
  490.    RectFill(rp,bx-s3,0L,bx,s2);
  491.    RectFill(rp,bx-s3,by-s2,bx,by);
  492.    RectFill(rp,bx/2-CX(step),by/2-CY(step),bx/2+CX(step),by/2+CY(step));
  493. }
  494.  
  495. Random(rp,step)
  496. struct RastPort *rp;
  497. int step;
  498. {
  499. static unsigned char matx[64];
  500. int t0,qx;
  501. long x,y;
  502.  
  503.    if (step == 0)
  504.       for (t0 = 0; t0 != 64; t0++)
  505.          matx[t0] = t0;
  506.  
  507.    t0 = (rand() % (64-step))+step;
  508.    qx = matx[t0];
  509.    matx[t0] = matx[step];
  510.    matx[step] = qx;
  511.    x = CX((qx & 7)*48);
  512.    y = CY((qx >> 3)*30);
  513.    RectFill(rp,x,y,x+CX(48)-1L,y+CY(30)-1L);
  514. }
  515.  
  516. LeftLinePanel(rp,step)
  517. struct RastPort *rp;
  518. int step;
  519. {
  520. long x,y;
  521.  
  522.    x = (step*bx)/63;
  523.    for (y = 0; y != my; y += 2)
  524.       {
  525.       Move(rp,0L,y);
  526.       Draw(rp,x,y);
  527.       Move(rp,bx-x,y+1L);
  528.       Draw(rp,bx,y+1L);
  529.       }
  530. }
  531.  
  532. GrowBoxes(rp,step)
  533. struct RastPort *rp;
  534. int step;
  535. {
  536. long x1,y1,x2,y2;
  537. int stepx,stepy;
  538.  
  539.    if ((step & 3) != 0)
  540.       return;
  541.    stepx = 15-(step >> 2);
  542.    stepy = 3-(step >> 4);
  543.    for (x1 = CX(stepx), x2 = CX(32-stepx)-1; x1 < mx;
  544.          x1 += CX(32L), x2 += CX(32L))
  545.       for (y1 = CY(stepy), y2 = CY(8-stepy)-1; y1 < my;
  546.             y1 += CY(8L), y2 += CY(8L))
  547.          RectFill(rp,x1,y1,x2,y2);
  548. }
  549.  
  550. SideToSide(rp,step)
  551. struct RastPort *rp;
  552. int step;
  553. {
  554. long xstep,bx2;
  555.  
  556.    if ((step & 1) != 0)
  557.       return;
  558.    bx2 = bx/2;
  559.    xstep = CX(188-(step >> 1)*6);
  560.    RectFill(rp,0L,0L,bx2-xstep,by);
  561.    RectFill(rp,bx2+xstep,0L,bx,by);
  562. }
  563.  
  564. int XYClock[130] = {
  565.  0,99,-16,99,-31,97,-46,95,-61,91,-75,87,-88,82,
  566. -101,77,-112,70,-123,63,-132,55,-140,47,-147,38,-152,29,
  567. -156,19,-158,10,-159,0,-158, -10,-156, -19,-152, -29,-147, -38,
  568. -140, -47,-132, -55,-123, -63,-112, -70,-101, -77,-88, -82,-75, -87,
  569. -61, -91,-46, -95,-31, -97,-16, -99, 0, -99, 16, -99, 31, -97,
  570.  46, -95, 61, -91, 75, -87, 88, -82, 101, -77, 112, -70, 123, -63,
  571.  132, -55, 140, -47, 147, -38, 152, -29, 156, -19, 158, -10, 159,0,
  572.  158,10, 156,19, 152,29, 147,38, 140,47, 132,55, 123,63,
  573.  112,70, 101,77, 88,82, 75,87, 61,91, 46,95, 31,97,
  574.  16,99, 0,99
  575.    };
  576.  
  577. OneClock(rp,step)
  578. struct RastPort *rp;
  579. int step;
  580. {
  581. long step48,ccx,ccy;
  582.  
  583.    ccx = cx+1; ccy = cy+1;
  584.    AreaMove(rp,ccx*(192L+XYClock[step*2]*191L/159),
  585.       ccy*(120L+XYClock[step*2+1]*119L/99));
  586.    AreaDraw(rp,mx/2,my/2);
  587.    AreaDraw(rp,ccx*(192L+XYClock[step*2+2]*191L/159),
  588.       ccy*(120L+XYClock[step*2+3]*119L/99));
  589.    AreaEnd(rp);
  590.    if (step > 47)
  591.       {
  592.       step48 = step-48;
  593.       RectFill(rp,0L,0L,CX(step48*12L),CY(step48*8L));
  594.       RectFill(rp,0L,by-CY(step48*8L),CX(step48*12L),by);
  595.       RectFill(rp,bx-CX(step48*12L),0L,bx,CY(step48*8L));
  596.       RectFill(rp,bx-CX(step48*12L),by-CY(step48*8L),bx,by);
  597.       }
  598. }
  599.  
  600. RandomOut(rp,step)
  601. struct RastPort *rp;
  602. int step;
  603. {
  604. long x,y,x1,x2,y1,y2;
  605. int i,num;
  606.  
  607.    x1 = mx/2-CX(step*5)/2;
  608.    x2 = CX(step*5+1);
  609.    y1 = my/2-CY(step*25)/16;
  610.    y2 = CY(step*3+4);
  611.    num = 7*step;
  612.    for (i = 0; i != num; i++)
  613.       {
  614.       x = x1+(rand() % x2);
  615.       y = y1+(rand() % y2);
  616.       WritePixel(rp,x,y);
  617.       }
  618.    if (step > 47)
  619.       {
  620.       RectFill(rp,CX(371L-12L*(step & 15)),0L,bx-CX(12L*(step & 15)),by);
  621.       RectFill(rp,CX(12L*(step & 15)),0L,CX(12L*(1+(step & 15)))-1L,by);
  622.       }
  623. }
  624.  
  625. TwoClock(rp,step)
  626. struct RastPort *rp;
  627. int step;
  628. {
  629. long line,nx,ny;
  630. static long ox,oy;
  631.  
  632.    if (!step)
  633.       ox = oy = 0;
  634.  
  635.    line = (622L*step)/63L;
  636.    if (line < 384)
  637.       {
  638.       nx = line;
  639.       ny = 0;
  640.       }
  641.    else
  642.       {
  643.       nx = 383;
  644.       ny = line-384;
  645.       }
  646.    AreaMove(rp,CX(ox),CY(oy));
  647.    AreaDraw(rp,CX(nx),CY(ny));
  648.    AreaDraw(rp,mx/2,my/2);
  649.    AreaMove(rp,bx-CX(ox),by-CY(oy));
  650.    AreaDraw(rp,bx-CX(nx),by-CY(ny));
  651.    AreaDraw(rp,bx/2,by/2);
  652.    AreaEnd(rp);
  653.    ox = nx;
  654.    oy = ny;
  655. }
  656.  
  657. ExpandBox(rp,step)
  658. struct RastPort *rp;
  659. int step;
  660. {
  661. int x,y;
  662.  
  663.    x = step*mx/126;
  664.    y = step*my/126;
  665.    RectFill(rp,(long) (mx/2-x),(long) (my/2-y),
  666.                (long) (mx/2+x),(long) (my/2+y));
  667. }
  668.  
  669. Doors(rp,step)
  670. struct RastPort *rp;
  671. int step;
  672. {
  673. long doorx,doory;
  674.  
  675.    doorx = CX(step*191/63);
  676.    doory = CY(63-step);
  677.    AreaMove(rp,0L,0L);
  678.    AreaDraw(rp,doorx,doory);
  679.    AreaDraw(rp,doorx,by-doory);
  680.    AreaDraw(rp,0L,by);
  681.    AreaEnd(rp);
  682.    AreaMove(rp,bx,0L);
  683.    AreaDraw(rp,bx-doorx,doory);
  684.    AreaDraw(rp,bx-doorx,by-doory);
  685.    AreaDraw(rp,bx,by);
  686.    AreaEnd(rp);
  687. }
  688.  
  689. Spiral(rp,step)
  690. struct RastPort *rp;
  691. int step;
  692. {
  693. int qx;
  694. long x,y;
  695. static int spiral[64] = {
  696.    0,1,2,3,4,5,6,7,15,23,31,39,47,55,63,
  697.    62,61,60,59,58,57,56,48,40,32,24,16,8,
  698.    9,10,11,12,13,14,22,30,38,46,54,53,52,
  699.    51,50,49,41,33,25,17,18,19,20,21,29,37,
  700.    45,44,43,42,34,26,27,28,36,35
  701.    };
  702.  
  703.    qx = spiral[step];
  704.    x = CX((qx & 7)*48);
  705.    y = CY((qx >> 3)*30);
  706.    RectFill(rp,x,y,x+CX(48)-1L,y+CY(30)-1L);
  707. }
  708.  
  709. WipeUp(rp,step)
  710. struct RastPort *rp;
  711. int step;
  712. {
  713. long y;
  714.  
  715.    y = (step * by) / 63;
  716.    yadd = -(by-y)*bpr;
  717.    RectFill(rp,0L,by-y,bx,by);
  718. }
  719.  
  720. WipeDown(rp,step)
  721. struct RastPort *rp;
  722. int step;
  723. {
  724. long y;
  725.  
  726.    y = (step * my) / 63;
  727.    yadd = (by-y)*bpr;
  728.    RectFill(rp,0L,0L,bx,y);
  729. }
  730.  
  731. WipeRight(rp,step)
  732. struct RastPort *rp;
  733. int step;
  734. {
  735.    RectFill(rp,CX(step*6L),0L,CX((step+1)*6L)-1,by);
  736. }
  737.  
  738. WipeLeft(rp,step)
  739. struct RastPort *rp;
  740. int step;
  741. {
  742.    RectFill(rp,mx-CX((step+1)*6L),0L,bx-CX(step*6L),by);
  743. }
  744.  
  745. WipeDiag(rp,step)
  746. struct RastPort *rp;
  747. int step;
  748. {
  749. long x,y;
  750.  
  751.    x = 12*(step+1);
  752.    y = 8*(step+1);
  753.    AreaMove(rp,0L,0L);
  754.    if (x < 384)
  755.       AreaClip(rp,CX(x),0L);
  756.    else
  757.       {
  758.       AreaClip(rp,bx,0L);
  759.       AreaClip(rp,bx,CY(y-255L)); /* y = 8/12 x */
  760.       }
  761.    if (y < 240)
  762.       AreaClip(rp,0L,CY(y));
  763.    else
  764.       {
  765.       AreaClip(rp,CX(x-358L),by); /* x = 12/8 y */
  766.       AreaClip(rp,0L,by);
  767.       }
  768.    AreaEnd(rp);
  769. }
  770.  
  771. TwoBox(rp,step)
  772. struct RastPort *rp;
  773. int step;
  774. {
  775. long x,y;
  776.  
  777.    x = (step * 95) / 63;
  778.    y = (step * 119) / 63;
  779.    RectFill(rp,CX(95L-x),CY(119L-y),CX(96L+x),CY(120L+y));
  780.    RectFill(rp,CX(287L-x),CY(119L-y),CX(288L+x),CY(120L+y));
  781. }
  782.  
  783. Shades(rp,step)
  784. struct RastPort *rp;
  785. int step;
  786. {
  787. long x,y;
  788.  
  789.    for (x = 0; x != 384; x += 64)
  790.       for (y = 0; y != 240; y += 60)
  791.          {
  792.          Move(rp,CX(x+step),CY(y));
  793.          Draw(rp,CX(x+step),CY(y+30L)-1L);
  794.          Move(rp,CX(x+64-step)-1L,CY(y+30L));
  795.          Draw(rp,CX(x+64-step)-1L,CY(y+60L)-1L);
  796.          if (cx == 1)
  797.             {
  798.             Move(rp,CX(x+step)+1L,CY(y));
  799.             Draw(rp,CX(x+step)+1L,CY(y+30L)-1L);
  800.             Move(rp,CX(x+64-step)-2L,CY(y+30L));
  801.             Draw(rp,CX(x+64-step)-2L,CY(y+60L)-1L);
  802.             }
  803.          }
  804. }
  805.  
  806. RandomShade(rp,step)
  807. struct RastPort *rp;
  808. int step;
  809. {
  810. static unsigned char matx[16];
  811. int t0,qx,num;
  812. static long x,y;
  813.  
  814.    if (step == 0)
  815.       for (t0 = 0; t0 != 16; t0++)
  816.          matx[t0] = t0;
  817.    if ((step & 3) == 0)
  818.       {
  819.       num = step/4;
  820.       t0 = (rand() % (16-num))+num;
  821.       qx = matx[t0];
  822.       matx[t0] = matx[num];
  823.       matx[num] = qx;
  824.       x = (qx & 3)*96;
  825.       y = (qx >> 2)*60;
  826.       }
  827.    step &= 3;
  828.    RectFill(rp,CX(x+step*24L),CY(y),CX(x+(step+1)*24L)-1L,CY(y+60L)-1L);
  829. }
  830.  
  831. SymArr(rp,step)
  832. struct RastPort *rp;
  833. int step;
  834. {
  835. long x,y;
  836.  
  837.    x = 6*step;
  838.    if (x < 192)
  839.       {
  840.       y = (120*x)/192;
  841.       AreaMove(rp,0L,CY(119L-y));
  842.       AreaDraw(rp,CX(x),CY(120L)-1L);
  843.       AreaDraw(rp,0L,CY(120L+y));
  844.       AreaMove(rp,bx,CY(119L-y));
  845.       AreaDraw(rp,bx-CX(x),CY(120L)-1L);
  846.       AreaDraw(rp,bx,CY(120L+y));
  847.       AreaEnd(rp);
  848.       }
  849.    else
  850.       {
  851.       RectFill(rp,0L,0L,CX(x-192L),by);
  852.       RectFill(rp,CX(575L-x),0L,bx,by);
  853.       AreaMove(rp,CX(x-192L),0L);
  854.       AreaDraw(rp,CX(x),CY(119L));
  855.       AreaDraw(rp,CX(x-192L),by);
  856.       AreaEnd(rp);
  857.       AreaMove(rp,CX(575L-x),0L);
  858.       AreaDraw(rp,bx-CX(x),CY(119L));
  859.       AreaDraw(rp,CX(575L-x),by);
  860.       AreaEnd(rp);
  861.       }
  862. }
  863.  
  864. AreaClip(rp,x,y)
  865. long x,y;
  866. struct RastPort *rp;
  867. {
  868.    if (x > bx)
  869.       x = bx;
  870.    if (y > by)
  871.       y = by;
  872.    if (x < 0)
  873.       x = 0;
  874.    if (y < 0)
  875.       y = 0;
  876.    AreaDraw(rp,x,y);
  877. }
  878.  
  879. FourSweep(rp,step)
  880. struct RastPort *rp;
  881. int step;
  882. {
  883. static long x1,y1;
  884. long x2,y2,x3,y3;
  885.  
  886.    if (step == 0)
  887.       x1 = y1 = 0;
  888.    x2 = (step+1)*6-1;
  889.    y2 = ((step+1)*240)/64-1;
  890.    x1 = CX(x1);   y1 = CY(y1);
  891.    x3 = CX(x2);   y3 = CY(y2);
  892.    AreaMove(rp,x1,0L);
  893.    AreaDraw(rp,x3,0L);
  894.    AreaDraw(rp,bx-x3,by);
  895.    AreaDraw(rp,bx-x1,by);
  896.    AreaMove(rp,0L,by-y1);
  897.    AreaDraw(rp,0L,by-y3);
  898.    AreaDraw(rp,bx,y3);
  899.    AreaDraw(rp,bx,y1);
  900.    AreaEnd(rp);
  901.    x1 = x2;
  902.    y1 = y2;
  903. }
  904.  
  905. HexSweep(rp,step)
  906. struct RastPort *rp;
  907. int step;
  908. {
  909. long x,y,xa,ya;
  910.  
  911.    xa = (step * 95) / 63;
  912.    ya = (step * 59) / 63;
  913.    for (x = 0; x != 384; x += 96)
  914.       for (y = 0; y != 240; y += 60)
  915.          {
  916.          RectFill(rp,CX(x),CY(y),CX(x+96L-xa)-1L,CY(y+ya+1L));
  917.          RectFill(rp,CX(x+xa),CY(y+59L-ya)-1L,CX(x+96L)-1L,CY(y+60L)-1L);
  918.          }
  919. }
  920.  
  921. FourLines(rp,step)
  922. struct RastPort *rp;
  923. int step;
  924. {
  925. long z1,z2;
  926. int step8;
  927.  
  928.    if (step & 1)
  929.       return;
  930.    step8 = (step & 0x0f)/2;
  931.    switch (step >> 4)
  932.       {
  933.       case 0:
  934.       case 1:
  935.          step8 = (step & 0x1f)/2;
  936.          z1 = CX(24*step8);
  937.          for (z2 = 0; z2 != CX(24); z2 += 2)
  938.             {
  939.             Move(rp,z1+z2,0L);
  940.             Draw(rp,z1+z2,by);
  941.             }
  942.          break;
  943.       case 2:
  944.          z1 = CY(30*step8);
  945.          for (z2 = 0; z2 != CY(30); z2 += 2)
  946.             {
  947.             Move(rp,0L,z1+z2);
  948.             Draw(rp,bx,z1+z2);
  949.             }
  950.          break;
  951.       case 3:
  952.          z1 = CX(40*step8);
  953.          for (z2 = 0; z2 != CX(48); z2 += 2)
  954.             {
  955.             Move(rp,bx-(z1+z2),0L);
  956.             Draw(rp,bx-(z1+z2),by);
  957.             }
  958.          break;
  959.       }
  960. }
  961.  
  962. DiagSplit(rp,step)
  963. struct RastPort *rp;
  964. int step;
  965. {
  966. int qx;
  967. long x,y;
  968. static int split[64] = {
  969.    56,49,42,35,28,21,14,7,
  970.    6,13,20,27,34,41,48,
  971.    40,33,26,19,12,5,
  972.    4,11,18,25,32,
  973.    24,17,10,3,
  974.    2,9,16,
  975.    8,1,
  976.    0,
  977.    63,
  978.    62,55,
  979.    47,54,61,
  980.    60,53,46,39,
  981.    31,38,45,52,59,
  982.    58,51,44,37,30,23,
  983.    15,22,29,36,43,50,57
  984.    };
  985.  
  986.    qx = split[step];
  987.    x = (qx & 7)*48;
  988.    y = (qx >> 3)*30;
  989.    RectFill(rp,CX(x),CY(y),CX(x+48)-1L,CY(y+30)-1L);
  990. }
  991.  
  992. Xes(rp,step)
  993. struct RastPort *rp;
  994. int step;
  995. {
  996. static unsigned char matx[64];
  997. int t0,qx;
  998. long x,y;
  999.  
  1000.    if (step == 0)
  1001.       for (t0 = 0; t0 != 64; t0++)
  1002.          matx[t0] = t0;
  1003.    t0 = (rand() % (64-step))+step;
  1004.    qx = matx[t0];
  1005.    matx[t0] = matx[step];
  1006.    matx[step] = qx;
  1007.    x = (qx & 7)*48;
  1008.    y = (qx >> 3)*30;
  1009.    AreaMove(rp,CX(x),CY(y));
  1010.    AreaClip(rp,CX(x+5L),CY(y));
  1011.    AreaClip(rp,CX(x+23L),CY(y+12L));
  1012.    AreaClip(rp,CX(x+41L),CY(y));
  1013.    AreaClip(rp,CX(x+48L)-1L,CY(y));
  1014.    AreaClip(rp,CX(x+48L)-1L,CY(y+4L));
  1015.    AreaClip(rp,CX(x+30L),CY(y+14L));
  1016.    AreaClip(rp,CX(x+48L)-1L,CY(y+25L));
  1017.    AreaClip(rp,CX(x+48L)-1L,CY(y+30L)-1L);
  1018.    AreaClip(rp,CX(x+41L),CY(y+30L)-1L);
  1019.    AreaClip(rp,CX(x+23L),CY(y+17L));
  1020.    AreaClip(rp,CX(x+5L),CY(y+30L)-1L);
  1021.    AreaClip(rp,CX(x),CY(y+30L)-1L);
  1022.    AreaClip(rp,CX(x),CY(y+25L));
  1023.    AreaClip(rp,CX(x+18L),CY(y+14L));
  1024.    AreaClip(rp,CX(x),CY(y+4L));
  1025.    AreaEnd(rp);
  1026.    if (step >= 32)
  1027.       RectFill(rp,CX(step-32)*12L,0L,CX(step-31)*12L-1L,by);
  1028. }
  1029.  
  1030. SlideBoxes(rp,step)
  1031. struct RastPort *rp;
  1032. int step;
  1033. {
  1034. long x,y,xa,ya;
  1035.  
  1036.    xa = (step * 95)/63;
  1037.    ya = (step * 59)/63;
  1038.    for (x = 0; x != 384; x += 96)
  1039.       for (y = 0; y != 240; y += 60)
  1040.          RectFill(rp,CX(x),CY(y),CX(x+xa),CY(y+ya));
  1041. }
  1042.  
  1043. Cannon(rp,step)
  1044. struct RastPort *rp;
  1045. int step;
  1046. {
  1047. int sstep,tstep;
  1048.  
  1049.    sstep = step & 0x0f;
  1050.    switch (step >> 4)
  1051.       {
  1052.       case 0:
  1053.          RectFill(rp,CX(247L),CY(115L),CX(260L)-1L,CY(125L)-1L);
  1054.          RectFill(rp,CX(sstep*5L),CY(108L),CX(sstep*5L+5L)-1L,CY(131L));
  1055.          break;
  1056.       case 1:
  1057.          RectFill(rp,CX(80L+sstep*5L),CY(114L),CX(sstep*5L+85L)-1L,CY(126L)-1L);
  1058.          break;
  1059.       case 2:
  1060.          SetAPen(rp,0L);
  1061.          RectFill(rp,CX(160L),CY(119L),CX(247L)-1L,CY(120L));
  1062.          RectFill(rp,CX(155L-sstep*5L),CY(114L),CX(159L-sstep*5L),CY(126L)-1L);
  1063.          SetAPen(rp,1L);
  1064.          RectFill(rp,CX(160L+sstep*5L),CY(119L),CX(164L+sstep*5L),CY(120L));
  1065.          break;
  1066.       case 3:
  1067.          for (tstep = 0; tstep != 40; tstep++)
  1068.             {
  1069.             Move(rp,CX(247L),CY(119L));
  1070.             Draw(rp,rand() % mx,rand() % my);
  1071.             }
  1072.          if (sstep > 7)
  1073.             {
  1074.             tstep = sstep-8;
  1075.             RectFill(rp,CX(247L-(tstep*247L)/7L),CY(119L-(tstep*119L)/7L),
  1076.                CX(247L+(tstep*137L)/7L),CY(120L+(tstep*119L)/7L));
  1077.             }
  1078.          break;
  1079.       }
  1080. }
  1081.  
  1082. Drip(rp,step)
  1083. struct BitMap *rp;
  1084. int step;
  1085. {
  1086. static long y1[8] = {450,310,750,600,239,400,350,270};
  1087. long y;
  1088. int t0;
  1089.  
  1090.    for (t0 = 0; t0 != 8; t0++)
  1091.       {
  1092.       y = CY((y1[t0]*step)/63);
  1093.       if (y > by)
  1094.          y = by;
  1095.       RectFill(rp,CX(t0*48L),0L,CY((t0+1)*48L)-1L,y);
  1096.       }
  1097. }
  1098.  
  1099. MovingWindow(rp,step)
  1100. struct BitMap *rp;
  1101. int step;
  1102. {
  1103. long x,y;
  1104.  
  1105.    if (step < 48)
  1106.       {
  1107.       SetRast(rp,0L);
  1108.       x = (172L*step)/47;
  1109.       y = (100L*step)/47;
  1110.       yadd = bpr*(47-step);
  1111.       RectFill(rp,CX(x),CY(y),CX(x+40)-1L,CY(y+40)-1L);
  1112.       }
  1113.    else
  1114.       {
  1115.       x = ((step-48)*172L)/15L+20L;
  1116.       y = ((step-48)*100L)/15L+20L;
  1117.       RectFill(rp,CX(192L-x),CY(120L-y),CX(191L+x),CY(119L+y));
  1118.       }
  1119. }
  1120.  
  1121. int RoughSin(ang)
  1122. int ang;
  1123. {
  1124. static int sintab[8] = {
  1125.    1,7,8,5,-1,-7,-8,-5
  1126.    };
  1127.  
  1128.    return(sintab[ang & 0x07]);
  1129. }
  1130.  
  1131. Monolith(rp,step)
  1132. struct RastPort *rp;
  1133. int step;
  1134. {
  1135. long maxy,x1,x2,y,bx2,by2;
  1136.  
  1137.    bx2 = bx/2; by2 = by/2;
  1138.    SetRast(rp,0L);
  1139.    maxy = (120L*step)/63L;
  1140.    x1 = CX((170L*step)/63L);
  1141.    x2 = CX((190L*step)/63L);
  1142.    y = CY((maxy*RoughSin(step+4))/8);
  1143.    if (y < 0)
  1144.       {
  1145.       BMod = -2*bpr;
  1146.       yadd = bpr*by;
  1147.       }
  1148.    else
  1149.       {
  1150.       BMod = 0;
  1151.       yadd = 0;
  1152.       }
  1153.    AreaMove(rp,bx2,by2);
  1154.    AreaClip(rp,bx2-x1,by2-y);
  1155.    AreaClip(rp,bx2+x1,by2-y);
  1156.    AreaClip(rp,bx2+x2,by2+1+y);
  1157.    AreaClip(rp,bx2-x2,by2+y);
  1158.    AreaClip(rp,bx2-x1,by2+1-y);
  1159.    AreaEnd(rp);
  1160. }
  1161.  
  1162. Sun(rp,step)
  1163. struct RastPort *rp;
  1164. int step;
  1165. {
  1166. int t0;
  1167. long x,y;
  1168.  
  1169.    x = (191L*step)/63;
  1170.    y = (119L*step)/63;
  1171.    SetRast(rp,0L);
  1172.    for (t0 = 0; t0 != 50; t0++)
  1173.       {
  1174.       Move(rp,bx/2,by/2);
  1175.       Draw(rp,rand() % mx,rand() % my);
  1176.       }
  1177.    RectFill(rp,CX(191L-x),CY(119L-y),CX(192L+x),CY(120L+y));
  1178. }
  1179.  
  1180. MergeWindows(rp,step)
  1181. struct RastPort *rp;
  1182. int step;
  1183. {
  1184. long x,ss;
  1185.  
  1186.    SetRast(rp,0L);
  1187.    SetDrMd(rp,COMPLEMENT);
  1188.    x = (156L*step)/47L;
  1189.    if (step < 48)
  1190.       {
  1191.       RectFill(rp,CX(x),CY(78L),CX(x+71L),CY(137L));
  1192.       RectFill(rp,CX(312L-x),CY(102L),bx-CX(x),CY(161L));
  1193.       yadd = 2*bpr*(48-step);
  1194.       }
  1195.    if (step > 47 && step < 58)
  1196.       {
  1197.       ss = step-48;
  1198.       RectFill(rp,CX(156L),CY(78L+ss),CX(227L),CY(137L+ss));
  1199.       RectFill(rp,CX(156L),CY(102L-ss),CX(227L),CY(161L-ss));
  1200.       yadd = 0;
  1201.       }
  1202.    if (step > 47)
  1203.       {
  1204.       ss = CY((119L*(step-48))/15L);
  1205.       RectFill(rp,0L,0L,bx,ss);
  1206.       RectFill(rp,0L,by-ss,bx,by);
  1207.       }
  1208.    SetDrMd(rp,JAM1);
  1209. }
  1210.  
  1211. Slides(rp,step)
  1212. struct RastPort *rp;
  1213. int step;
  1214. {
  1215. static int right,brick;
  1216.  
  1217.    if (step == 0)
  1218.       {
  1219.       right = 11;
  1220.       brick = 0;
  1221.       }
  1222.    else
  1223.       {
  1224.       brick++;
  1225.       if (brick != right)
  1226.          {
  1227.          SetAPen(rp,0L);
  1228.          RectFill(rp,CX(34L*brick-35L),0L,CX(34L*brick)-1L,by);
  1229.          }
  1230.       else
  1231.          {
  1232.          right--; 
  1233.          brick = 0;
  1234.          }
  1235.       }
  1236.    SetAPen(rp,1L);
  1237.    RectFill(rp,CX(34L*brick),0L,34L*CX(brick+1)-1L,by);
  1238. }
  1239.  
  1240. Rain(rp,step)
  1241. struct RastPort *rp;
  1242. int step;
  1243. {
  1244. static unsigned char matx[64];
  1245. int t0,t1,qx;
  1246. long x,y;
  1247.  
  1248.    if (step == 0)
  1249.       for (t0 = 0; t0 != 64; t0++)
  1250.          matx[t0] = 0;
  1251.  
  1252.    for (t0 = 0; t0 != 8; t0++)
  1253.       for (t1 = 6; t1 >= 0; t1--)
  1254.          {
  1255.          qx = t0+t1*8;
  1256.          if (matx[qx] == 1 && matx[qx+8] == 0)
  1257.             {
  1258.             x = t0*48;
  1259.             y = t1*30;
  1260.             SetAPen(rp,0L);
  1261.             RectFill(rp,CX(x),CY(y),CX(x+48)-1L,CY(y+30)-1L);
  1262.             matx[qx] = 0;
  1263.             matx[qx+8] = 1;
  1264.             SetAPen(rp,1L);
  1265.             RectFill(rp,CX(x),CY(y+30L),CX(x+48L)-1L,CY(y+60L)-1L);
  1266.             }
  1267.          }
  1268.    while (matx[t0 = (rand() % 8)]);
  1269.    matx[t0] = 1;
  1270.    RectFill(rp,CX(t0*48L),0L,CX(t0+1)*48L-1L,CY(30L)-1L);
  1271. }
  1272.  
  1273. RandomDown(rp,step)
  1274. struct RastPort *rp;
  1275. int step;
  1276. {
  1277. static unsigned char matx[16];
  1278. int t0,qx,num;
  1279. static long x,y;
  1280.  
  1281.    if (step == 0)
  1282.       for (t0 = 0; t0 != 16; t0++)
  1283.          matx[t0] = t0;
  1284.    if ((step & 3) == 0)
  1285.       {
  1286.       num = step/4;
  1287.       t0 = (rand() % (16-num))+num;
  1288.       qx = matx[t0];
  1289.       matx[t0] = matx[num];
  1290.       matx[num] = qx;
  1291.       x = (qx & 3)*96;
  1292.       y = (qx >> 2)*60;
  1293.       }
  1294.    step &= 3;
  1295.    RectFill(rp,CX(x),CY(y+step*15),CX(x+96L)-1L,CY(y+step*15+15L)-1L);
  1296. }
  1297.  
  1298. Stretch(rp,step)
  1299. struct RastPort *rp;
  1300. int step;
  1301. {
  1302. long y,zmod;
  1303.  
  1304.    y = (by*step)/63;
  1305.    RectFill(rp,0L,by-y,bx,by);
  1306.    zmod = 16*bpr;
  1307.    if (y > 15)
  1308.       zmod = 8*bpr;
  1309.    if (y > 30)
  1310.       zmod = 4*bpr;
  1311.    if (y > 60)
  1312.       zmod = 2*bpr;
  1313.    if (y > 120)
  1314.       zmod = bpr;
  1315.    BMod = zmod-bpr;
  1316.    yadd = -(by-y)*zmod;
  1317. }
  1318.  
  1319. ExpandSlide(rp,step)
  1320. struct RastPort *rp;
  1321. int step;
  1322. {
  1323. long x,y,yz;
  1324. long x1,y1,x2,y2;
  1325.  
  1326.    yz = (my*step)/63;
  1327.    yadd = -bpr*(my-yz);
  1328.    x = step*mx/126;
  1329.    y = step*yz/126;
  1330.    x1 = mx/2-x;
  1331.    y1 = my-yz/2-y;
  1332.    x2 = mx/2+x;
  1333.    y2 = my-yz/2+y;
  1334.    if (x1 < 0)
  1335.       x1 = 0;
  1336.    if (y1 < 0)
  1337.       y1 = 0;
  1338.    if (x2 > bx)
  1339.       x2 = bx;
  1340.    if (y2 > by)
  1341.       y2 = by;
  1342.    if (x1 > x2)
  1343.       x1 = x2;
  1344.    if (y1 > y2)
  1345.       y1 = y2;
  1346.    RectFill(rp,x1,y1,x2,y2);
  1347. }
  1348.  
  1349. SlideSlabs(rp,step)
  1350. struct RastPort *rp;
  1351. int step;
  1352. {
  1353. long y,ya;
  1354.  
  1355.    ya = (step * 59)/63;
  1356.    for (y = 0; y != 240; y += 60)
  1357.       RectFill(rp,0L,CY(y),bx,CY(y+ya));
  1358.    yadd = (59-ya)*bpr;
  1359. }
  1360.  
  1361. HalfPic(rp,step)
  1362. struct RastPort *rp;
  1363. int step;
  1364. {
  1365. int step15;
  1366.  
  1367.    step15 = step & 15;
  1368.    switch (step / 16)
  1369.       {
  1370.       case 0:
  1371.          BMod = bpr;
  1372.          SetAPen(rp,1L);
  1373.          RectFill(rp,step15*bx/16,0L,(step15+1)*bx/16-1L,my/2-1L);
  1374.          break;
  1375.       case 1:
  1376.          SetAPen(rp,0L);
  1377.          RectFill(rp,step15*bx/16,0L,(step15+1)*bx/16-1L,my/2-1L);
  1378.          break;
  1379.       case 2:
  1380.       case 3:
  1381.          BMod = 0;
  1382.          SetAPen(rp,1L);
  1383.          step15 = step & 31;
  1384.          RectFill(rp,bx-(step15+1)*bx/32,0L,bx-step15*bx/32,by);
  1385.          break;
  1386.       }
  1387. }
  1388.  
  1389. Checkerboard(rp,step)
  1390. struct RastPort *rp;
  1391. int step;
  1392. {
  1393. long y;
  1394. int ww,wh,t0;
  1395.  
  1396.    if (step & 1)
  1397.       return;
  1398.    step >>= 1;
  1399.    ww = CX(16); wh = CY(15);
  1400.    if (step < 16)
  1401.       {
  1402.       y = (wh*step);
  1403.       wh--;
  1404.       for (t0 = (step & 1); t0 < 24; t0 += 2)
  1405.          RectFill(rp,(long) (t0*ww),y,(long) ((t0+1)*ww-1),y+wh);
  1406.       }
  1407.    else
  1408.       {
  1409.       y = by-(wh*(step & 15));
  1410.       wh--;
  1411.       for (t0 = (step & 1); t0 < 24; t0 += 2)
  1412.          RectFill(rp,(long) (t0*ww),y-wh,(long) ((t0+1)*ww-1),y);
  1413.       }
  1414. }
  1415.  
  1416. MiniRandom(rp,step)
  1417. struct RastPort *rp;
  1418. int step;
  1419. {
  1420. static unsigned char matx[256];
  1421. int t0,qx,t1,step4;
  1422. long x,y;
  1423.  
  1424.    if (step == 0)
  1425.       for (t0 = 0; t0 != 256; t0++)
  1426.          matx[t0] = t0;
  1427.    step4 = step << 2;
  1428.    for (t1 = 0; t1 != 4; t1++, step4++)
  1429.       {
  1430.       t0 = (rand() % (256-step4))+step4;
  1431.       qx = matx[t0];
  1432.       matx[t0] = matx[step4];
  1433.       matx[step4] = qx;
  1434.       x = CX((qx & 15)*24);
  1435.       y = CY((qx >> 4)*15);
  1436.       RectFill(rp,x,y,x+CX(24)-1L,y+CY(15)-1L);
  1437.       }
  1438. }
  1439.  
  1440. ConcentricRectangles(rp,step)
  1441. struct RastPort *rp;
  1442. int step;
  1443. {
  1444. long divx,divy,x30,y30;
  1445.  
  1446.    SetRast(rp,0L);
  1447.    divx = CX(15)*step/64;
  1448.    divy = CY(15)*step/64;
  1449.    x30 = CX(30); y30 = CY(30);
  1450.    SetDrMd(rp,COMPLEMENT);
  1451.    RectFill(rp,0L,0L,bx,by);
  1452.    RectFill(rp,divx,divy,bx-divx,by-divy);
  1453.    RectFill(rp,x30-divx,y30-divy,bx-x30+divx,by-y30+divy);
  1454.    RectFill(rp,x30+divx,y30+divy,bx-x30-divx,by-y30-divy);
  1455.    RectFill(rp,x30*2-divx,y30*2-divy,bx-x30*2+divx,by-y30*2+divy);
  1456.    RectFill(rp,x30*2+divx,y30*2+divy,bx-x30*2-divx,by-y30*2-divy);
  1457.    RectFill(rp,x30*3-divx,y30*3-divy,bx-x30*3+divx,by-y30*3+divy);
  1458.    RectFill(rp,x30*3+divx,y30*3+divy,bx-x30*3-divx,by-y30*3-divy);
  1459.    if (divx > 1)
  1460.       RectFill(rp,x30*4-divx,y30*4-divy,bx-x30*4+divx,by-y30*4+divy);
  1461.    SetDrMd(rp,JAM1);
  1462. }
  1463.  
  1464. Flash(rp,step)
  1465. struct RastPort *rp;
  1466. int step;
  1467. {
  1468.    SetRast(rp,(long) (step & 1));
  1469. }
  1470.  
  1471. Cloverleaf(rp,step)
  1472. struct RastPort *rp;
  1473. int step;
  1474. {
  1475. long tx,ty,hbx,hby,hmx,hmy;
  1476.  
  1477.    hmx = mx >> 1;
  1478.    hmy = my >> 1;
  1479.    hbx = (hmx-1);
  1480.    hby = (hmy-1);
  1481.    tx = step*hbx/64;
  1482.    ty = step*hby/64;
  1483.    RectFill(rp,0L,0L,tx,hby);
  1484.    RectFill(rp,hmx,0L,bx,ty);
  1485.    RectFill(rp,bx-tx,hmy,bx,by);
  1486.    RectFill(rp,0L,by-ty,hbx,by);
  1487. }
  1488.  
  1489. Cloverleaf2(rp,step)
  1490. struct RastPort *rp;
  1491. int step;
  1492. {
  1493. long tx,ty,hbx,hby,hmx,hmy;
  1494.  
  1495.    hmx = mx >> 1;
  1496.    hmy = my >> 1;
  1497.    hbx = (hmx-1);
  1498.    hby = (hmy-1);
  1499.    tx = step*hbx/64;
  1500.    ty = step*hby/64;
  1501.    RectFill(rp,0L,hby-ty,hbx,hby);
  1502.    RectFill(rp,hmx,0L,hmx+tx,hby);
  1503.    RectFill(rp,hmx,hmy,bx,ty+hmy);
  1504.    RectFill(rp,hbx-tx,hmy,hbx,by);
  1505. }
  1506.  
  1507. ConcentricRectangles2(rp,step)
  1508. struct RastPort *rp;
  1509. int step;
  1510. {
  1511. long divx,divy,x60,y60;
  1512.  
  1513.    SetRast(rp,0L);
  1514.    divx = CX(30)*step/64;
  1515.    divy = CY(30)*step/64;
  1516.    x60 = CX(60); y60 = CY(60);
  1517.    SetDrMd(rp,COMPLEMENT);
  1518.    RectFill(rp,0L,0L,bx,by);
  1519.    RectFill(rp,divx,divy,bx-divx,by-divy);
  1520.    RectFill(rp,x60-divx,y60-divy,bx-x60+divx,by-y60+divy);
  1521.    RectFill(rp,x60+divx,y60+divy,bx-x60-divx,by-y60-divy);
  1522.    if (divx > 1)
  1523.       RectFill(rp,x60*2-divx,y60*2-divy,bx-x60*2+divx,by-y60*2+divy);
  1524.    SetDrMd(rp,JAM1);
  1525. }
  1526.  
  1527.