💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › apple8 › Pgms › rotat… captured on 2024-07-09 at 03:46:56.
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
There is a two-liner program, ROTATE.CUBE, from Nibble Magazine that does the same thing with a wireframe cube.--JaY 10 I=1.5708:T=6:HGR:HGR2: HCOLOR=3: FOR N=1 TO 1000: K=(N/2=INT(N/2)): POKE230,32 + (32 * K): FOR X=1 TO 4: A(X) =50*SIN(E)+140: B(X)=50*COS(E)+96: E=E+1: NEXT: FOR X = 1TO 2: HPLOT A(1)+C,B(1)-DTOA(2) + C,B(2)-D TO A(3) + C, B(3)-D TO A(4)+C,B(4)-D TO A (1)+C,B(1)-D: C=20: D=35 20 NEXT: HPLOT A(2),B(2) TO A(3) +C,B(3)-D: HPLOT A(3), B(3) TO A(2)+C,B(2)-D: FOR X=1 TO 4: HPLOT A(X),B(X) TO A(X)+C,B(X)-D: NEXT:POKE49236=K,0:POKE230,32+(32*(K=0)): CALL-3086: E=E+T: C=0: D=0: NEXT: TEXT: HOME: LIST: END << Does anybody have a copy of a demo program for the apple][ It was called "CUBE". (It was a machine language program) It simply displayed, and rotated a 3d cube on the graphics screen. I wish to disassemble it. When I saw it 20 years ago, I was in awe! Now I can follow assembly, I wish to dispell the 'mystery'. >> Jay wrote: >There is a two-liner program, ROTATE.CUBE, from Nibble Magazine that does the >same thing with a wireframe cube.--JaY > >10 I=1.5708:T=6:HGR:HGR2: HCOLOR=3: FOR N=1 TO 1000: K=(N/2=INT(N/2)): >POKE230,32 + (32 * K): FOR X=1 TO 4: A(X) =50*SIN(E)+140: B(X)=50*COS(E)+96: >E=E+1: NEXT: FOR X = 1TO 2: HPLOT A(1)+C,B(1)-DTOA(2) + C,B(2)-D TO A(3) + C, >B(3)-D TO A(4)+C,B(4)-D TO A (1)+C,B(1)-D: C=20: D=35 > >20 NEXT: HPLOT A(2),B(2) TO A(3) +C,B(3)-D: HPLOT A(3), B(3) TO >A(2)+C,B(2)-D: FOR X=1 TO 4: HPLOT A(X),B(X) TO A(X)+C,B(X)-D: >NEXT:POKE49236=K,0:POKE230,32+(32*(K=0)): CALL-3086: E=E+T: C=0: D=0: NEXT: >TEXT: HOME: LIST: END I couldn't help it--I had to try this out! ;-) It is about the level of complexity I'd expect for a wire-frame cube. This program was clearly transformed into a "two-liner", and in the process it lost most of its readability. It is a pretty nice cheat on a 3D transform, having "flat" perspective (it is like looking at the cube from far away through a telescope). When I typed it in, I found a couple of typos--a place where "I" was replaced by "1" and a place where "+" was replaced by "=". Here is the fixed up version: 10 I=1.5708:T=6:HGR:HGR2: HCOLOR=3: FOR N=1 TO 1000: K=(N/2=INT(N/2)): POKE230,32 + (32 * K): FOR X=1 TO 4: A(X) =50*SIN(E)+140: B(X)=50*COS(E)+96: E=E+I: NEXT: FOR X = 1TO 2: HPLOT A(1)+C,B(1)-DTOA(2) + C,B(2)-D TO A(3) + C, B(3)-D TO A(4)+C,B(4)-D TO A (1)+C,B(1)-D: C=20: D=35 20 NEXT: HPLOT A(2),B(2) TO A(3) +C,B(3)-D: HPLOT A(3), B(3) TO A(2)+C,B(2)-D: FOR X=1 TO 4: HPLOT A(X),B(X) TO A(X)+C,B(X)-D: NEXT:POKE49236+K,0:POKE230,32+(32*(K=0)): CALL-3086: E=E+T: C=0: D=0: NEXT: TEXT: HOME: LIST: END The program displays a wire-frame cube with one face marked with an "X" to distinguish it. The actual axis of rotation is ambiguous, and can be seen as either rotation around an axis which comes out of the screen and goes up over your right ear, or around an axis which comes out of the screen and goes down under your left arm. It may take a little time to see the "other" axis orientation once you see one of them. The speed of rotation (angle between successive frames) is set by "T=6" in the first line, and this angle is mod 2*pi, so 6 is about -0.28 radians per iteration. You can change the sign and value to make the rotation animation go any "speed" you want. (A value of 0.1 is nice if you have an accelerator.) A screen editor like Program Writer is _very_ handy for making changes to "packed" programs like this. The frame rate on an unaccelerated Apple II is a little more than one per second, but the program uses page flipping, so redraw is hidden. This could be increased a lot by compiling or re-writing it in machine language, with most of the remaining time spent drawing lines. The trig function evaluation is actually redundant, since a simple table of sines would do the job--and only one set per frame is needed. (The four evaluations are pi/2 apart, and so could be eliminated by unrolling, then swapping sine and cosine and appropriately negating.) It might be fun to use a shape table for this. You may also insert a "?CHR$(21)" at the beginning of line 10, so that any 80-column firmware is off to enable hi-res display. (I didn't count characters, since I had already shortened line 10 by replacing "K=(N/2=INT(N/2))" with an initializing "K=1:" and "K=1-K", so I knew I had a few extra characters to play with.) Although I was a Nibble subscriber, I seldom actually typed in the one-liners and two-liners, preferring to read them and figure out how they worked and what they did. Every couple of months, I'd see one that sufficiently fascinated or confused me that I would go to the computer and type it in. I must admit that this exercise was enough fun that I may try some more! ;-) -michael Check out amazing quality 8-bit Apple sound on my Home page: http://members.aol.com/MJMahon/