|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 2887 (0xb47) Types: TextFile Notes: UNIX file Names: »srotcube.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code └─⟦926b8033d⟧ UNIX Filesystem └─ ⟦this⟧ »u/demo/slide/srotcube.c«
/* rotcube.c 1.2 84/03/26 */ /* spinning "cube" although now maybe we will allow it to * be a parallelpiped. hacked over by vaughn pratt to * speed it up, then thrashed by djc to put in some "C" * like constructs and make it work on Sun 2 video and * in the window system. */ #include <stdio.h> #define UNCHANGED 0 #define CHANGED 1 #define XMAX ((long)1024) #define YMAX ((long)800) #define MAXCOUNT 1 short ccount = 0; long redo; long cx, cy; long x, y; long x1, y1, x2, y2, x3, y3, x4, y4; long nx1, ny1, nx2, ny2, nx3, ny3, nx4, ny4; long px1, py1, px2, py2, px3, py3, px4, py4; long pnx1, pny1, pnx2, pny2, pnx3, pny3, pnx4, pny4; long yd; long z, zsc; long Xmax, Ymax, Xmin, Ymin; long clipor; long yinc; cube() { long sp,spin(); yinc = (long)20; Restart: Xmin = 0; Ymin = 0; Xmax = XMAX; Ymax = YMAX; /*clearw();*/ zsc = (long)10; x = (long)(((long)-200<<16)); y = (long)(((long)200<<16)); z = 186268; yd = (long)0x14b0; cx = (700-508)/2 + 502; cy =(195-62)/2+ 62; redo = 1; while (ccount++ < MAXCOUNT) { for (sp = (long)8; sp > (long)2; sp--) if (spin( (long)4 )) goto Restart; for (sp = (long)2; sp < (long)8; sp++) if (spin((long)4 )) goto Restart; } } long spin(sp) long sp; { long square(); register long i, squareval; for (i = 0; i < (long)50; i++) { if (squareval = square(x,y)) break; x = x-(y>>sp); y = y+(x>>sp); /* yd+= yinc; if ((yd < (long)0x14b0)|| (yd > (long)0x24b0)) yinc = -yinc; */ } return(squareval); } long square(x,y) long x,y; { register long xx = x>>(long)16, yy = y>>(long)16; nx1 = xx; ny1 = yy; nx2 = yy; ny2 = - xx; nx3 = - xx; ny3 = - yy; nx4 = - yy; ny4 = xx; pnx1 = (nx1<<zsc)/(yd+ny1); pny1 = z/(yd+ny1); pnx2 = (nx2<<zsc)/(yd+ny2); pny2 = z/(yd+ny2); pnx3 = (nx3<<zsc)/(yd+ny3); pny3 = z/(yd+ny3); pnx4 = (nx4<<zsc)/(yd+ny4); pny4 = z/(yd+ny4); nvec(px1,py1,px1,-py1); nvec(pnx1,pny1,pnx1,-pny1); nvec(px2,py2,px2,-py2); nvec(pnx2,pny2,pnx2,-pny2); nvec(px3,py3,px3,-py3); nvec(pnx3,pny3,pnx3,-pny3); nvec(px4,py4,px4,-py4); nvec(pnx4,pny4,pnx4,-pny4); nvec(px1,py1,px2,py2); nvec(pnx1,pny1,pnx2,pny2); nvec(px2,py2,px3,py3); nvec(pnx2,pny2,pnx3,pny3); nvec(px3,py3,px4,py4); nvec(pnx3,pny3,pnx4,pny4); nvec(px4,py4,px1,py1); nvec(pnx4,pny4,pnx1,pny1); nvec(px1,-py1,px2,-py2); nvec(pnx1,-pny1,pnx2,-pny2); nvec(px2,-py2,px3,-py3); nvec(pnx2,-pny2,pnx3,-pny3); nvec(px3,-py3,px4,-py4); nvec(pnx3,-pny3,pnx4,-pny4); nvec(px4,-py4,px1,-py1); nvec(pnx4,-pny4,pnx1,-pny1); x1 = nx1, y1 = ny1; x2 = nx2, y2 = ny2; x3 = nx3, y3 = ny3; x4 = nx4, y4 = ny4; px1 = pnx1, py1 = pny1; px2 = pnx2, py2 = pny2; px3 = pnx3, py3 = pny3; px4 = pnx4, py4 = pny4; return(UNCHANGED); } nvec(x1,y1,x2,y2) long x1,y1,x2,y2; { line((short)(cx+x1), (short)(cy+y1), (short)(cx+x2),(short)(cy+y2)); }