#include #define Queues 4 #define Nqux 32 #define abs(x) ((x)<0?(-(x)):(x)) int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256]; int i,evwhich,dummy,rand,handle; int xstart,ystart,xwidth,ywidth,xcen,ycen; int pxy[4],mx; long Randx = 1; int width,height; main() { /* Set the system up to do GEM calls */ appl_init(); /* Get the handle of the desktop */ handle=graf_handle(&width,&height,&dummy,&dummy); /* Open the workstation. */ for(i=1; i<10; ++i) intin[i] = 1; intin[10] = 2; v_opnvwk(intin, &handle, intout); pxy[0]=0; pxy[1]=0;pxy[2]=intout[0];pxy[3]=intout[1]; xwidth=pxy[2]; ywidth= pxy[3]; /* vs_clip(handle,1,pxy); */ graf_mouse(0,i); draw_sample(); v_clsvwk(handle); /* Release GEM calls */ appl_exit(); } draw_sample() { int Dx[Queues], Dy[Queues]; int x[Queues][Nqux], y[Queues][Nqux]; int i=0, flag=0; v_clrwk(handle); vswr_mode(handle,3); Srand((long) Gettime()); for(i=0;i= Nqux) { i=0; flag=1; } } Vector (x[0][i], y[0][i], x[1][i], y[1][i]); Vector (x[1][i], y[1][i], x[2][i], y[2][i]); Vector (x[2][i], y[2][i], x[3][i], y[3][i]); Vector (x[1][i], y[1][i], x[3][i], y[3][i]); Vector (x[3][i], y[3][i], x[0][i], y[0][i]); Vector (x[2][i], y[2][i], x[0][i], y[0][i]); for(flag=(i+1)%Nqux;flag!=i;flag=(flag+1)%Nqux) { Vector (x[0][flag], y[0][flag], x[1][flag], y[1][flag]); Vector (x[1][flag], y[1][flag], x[2][flag], y[2][flag]); Vector (x[2][flag], y[2][flag], x[3][flag], y[3][flag]); Vector (x[1][flag], y[1][flag], x[3][flag], y[3][flag]); Vector (x[3][flag], y[3][flag], x[0][flag], y[0][flag]); Vector (x[2][flag], y[2][flag], x[0][flag], y[0][flag]); } } Srand(x) long x; { Randx = x; } Rand() { return((Randx = Randx * 505360173 + 907633385) & 0x7fffffff); } Rand2() { return(Rand()>>13); } Rand3() { return(((Randx = Randx * 505360173 + 907633385)>>13)&1 ? ((((Randx = Randx * 505360173 + 907633385)>>13)&1)+1) : -((((Randx = Randx * 505360173 + 907633385)>>13)&1)+1)); } bounce (x, off, dx, lim) int *x, off, *dx, lim; { int j; j = *dx + x[!off ? Nqux-1 : off-1]; if (j > lim) { j = lim; *dx = -(*dx); } else if (j < 1) { j = 1; *dx = -(*dx); } return(x[off] = j); } Vector(a,b,c,d) int a,b,c,d; { ptsin[0] = a; ptsin[1] = b; ptsin[2] = c; ptsin[3] = d; v_pline(handle, 2, ptsin); } ¡ú_pooff