Classic Computer Magazine Archive COMPUTE! ISSUE 11 / APRIL 1981 / PAGE 92

THE ATARI® GAZETTE

Super Cube

Steve Steinberg
Washington, DC

If you own an Atari and like to fiddle with graphics you're going to love this one. It's a program that allows you to draw cubes in different sizes and colors and also to use the cube itself as a cursor to make three dimensional bars, columns, and drawings reminiscent of the works of Escher. It can create some of the most impressive graphics displays you've yet seen on your monitor, and, to crow just a bit, it can't be done on an Apple.

Now, after all that buildup, a bit of mea culpa. While this program proves that a relative novice (never touched a computer until I bought my Atari last year) can make things happen on a home computer, the program is really nothing more than a synthesis of other people's work.

It all began when I started fooling around with the brilliant little program by David D. Thornburg that appeared in the May/June 1980 issue of COMPUTE! Mr. Thornburg's program enables you to draw a shaded three dimensional cube and change the colors by use of the keyboard. While playing with that one, Ray Daly of the Program Store in Washington, D.C., was kind enough to give me a program he wrote that puts a cursor on the screen and allows you to draw with a joystick. My question: why not change Ray's PLOT X,Y to GOSUB to a subroutine that will draw with a cube instead of with a point? My solution, with a few minor embellishments: to take David Thornburg's DRAW sequence and do just that.

Sound simple? It was, almost unbelievably so. Since then, I've been having a ball creating skyscrapers, harbors, cubist drawings and the like, and while I plead guilty to the charge of total plagiarism, it would be a shame not to share my fun with other Atari owners. Sorry, I can't tell you exactly how Ray's program works. I never really had to know. I can tell you that lines 600 to 670 set up the colors for the cube (sorry about that too, you can only get about 90 different color combinations!). Lines 720 to 830 are the cube drawing itself, with the input variable SQ setting the size. As far as the joystick commands are concerned, check them out in Atari's Basic Reference Manual; it's fairly easy to figure out what they do.

Now, for operating the program. The first thing the computer will ask you for is a dimension for the cube. Actually, you can enter numbers as large as 40 to 45, but this will cause problems if the cube or your drawing run off the screen, so until you've had a little practice, stick to dimension sizes between 1 and 10. Once you've entered your cube dimension, press RETURN and your Atari will go to the Graphics 7 mode.

The cursor is in the upper left hand corner of the screen. It may be a little difficult to see if you have a dark initial color, but you can change the display colors at any time by pushing the joystick button when the cursor is anywhere at the far left of the screen.

Next, using your joystick, move the cursor to wherever you want to begin your work of art and push the joystick button. Voila, a cube!

Whenever you let go of the joystick button, the cursor returns to the upper left hand corner of the screen. This keeps it out of the way of your drawing, since the cursor draws an erase line as it moves along. If you want to draw a bar or a column, or draw diagonally, hold the joystick button down while moving the cursor.

When you want to draw with a different sized cube, move the cursor to the bottom of the screen and press the joystick button. In the text window at the bottom of the screen, you'll be asked for a new dimension for the cube. Enter it, hit RETURN, and the cursor goes back to the upper left hand corner.

Certain three dimensional effects require that you go over what you have drawn. For example, to make a square shaped "O": Give yourself a cube dimension of, say, 6. Start somewhere near the center of the screen. Go up, straight up, about ten increments, across to the right another ten, down ten, and then draw carefully to the left, stopping when the left hand side of the drawing is just joined. Now, go back across to the right, stopping at the end of your original bottom bar line, and draw back up to the top.

Again, any time you want to change colors (it's more fun when whatever you're drawing is complete) either release the joystick button so that the cursor goes back to the upper left hand corner or just move the cursor to the far left of the screen and press the joystick button. Every now and then when you change colors, a cube will appear at the far left. If anyone figures out why this happens, please let me know.

This program is on the border line between 8K and 16K, so if you have only an 8K computer you will probably want to pack some of the program lines together, and eliminate the first two print statements. I've checked it out with only 8K in my Atari, and I can assure you it will work.

The program also provides a dramatic demonstration of how much memory graphics require. Try this: load the program, type RUN, then BREAK, and then PRINT FRE(0) and RETURN, which will tell you how much memory you have left. Now RUN the program again, enter an initial cube dimension, and when the program goes to Graphics Mode 7, type BREAK and then PRINT FRE(0), and RETURN again. Where did it all go?

One final note: As I've mentioned, I'm a novice at all this and Super Cube could certainly use some additional improvement. For example, how about using a second joystick to draw pyramids?

Or controlling the colors with the keyboard instead of making them random? I'd be pleased to hear from anyone who has any further ideas to offer. In the meantime, Picasso! Move over! A new generation of cubists is about to begin work! Editor's Note: As you update Steve's program, send in your enhancements and we'll keep you posted. RCL

10 ? "}" : POSITION 10,5:? "3-D DRAWING":? :? :? "PRESS JOYSTICK BUTTON TO DRAW"
20 PRINT :PRINT :PRINT "TO CHANGE CUBE DIMENSION MOVE CURSOR TO BOTTOM OF SCREEN AND PRESS BUTTON"
30 ? :? :? "ENTER CUBE DIMENSION, THEN HIT RETURN:(Note: Dimensions
        larger than 10 may cause Errors)" :INPUT SQ
40 GRAPHICS?
50 PRINT "TO CHANGE COLORS PRESS BUTTON WHEN CURSOR IS AT EXTREME LEFT OR SCREEN"
70 GOSUB 600
80 IF STRIG < 0 >< >0 THEN GOSUB 500:GOTO 140
90 IF Y > 75 THEN PRINT "ENTER NEW DIMENSION FOR CUBE";: INPUT SQ:X = 0: Y = 0
120 POKE 77,0
130 IF STRIG (0) = 0 THEN GOSUB 700
140 GOSUB 1000
150 X = X + XDIF : Y = Y + YDIF
200 IF X > 143 THEN X = 143 : GOTO 300
210 IF Y > 80 THEN Y = 80:GOTO 300
300 IF X<0 THEN X = 0 : GOTO 300
310 IF Y<7 THEN Y = 7
400 GOTO 88
500 COLOR 1 : PLOT X, Y : FOR I = 1 TO 5 : NEXT I : COLOR 4:PLOT X,Y: RETURN
600 A = INT (RND (1) *15) + 1
610 B = INT (RND (1) *14) + 2
620 IF B < 4 THEN B = 10
630 SETCOLOR 1,A, B
640 SETCOLOR 2,A, B-2
650 SETCOLOR 0,A, B-4
660 IF X < 10 THEN GOTO 120
670 RETURN
700 IF X=0 THEN IF STRIG (0) = 0 THEN GOSUB 600
710 TRAP 80
720 COLOR 1
730 FOR I = 0 TO SQ
740 PLOT X, Y + I : DRAWTO X + SQ, Y + I
750 NEXT I
760 COLOR 2
770 FOR I = 1 TO INT(3 * SQ)/5
780 PLOT X + I, Y - I : DRAWTO X + I + SQ, Y-I
790 NEXT I
800 COLOR 3
810 FOR I = 1 TO INT(3 * SQ)/5
820 PLOT X + SQ + I, Y-1 : DRAWTO X + SQ + I, Y + SQ-I + 1
830 NEXT I
840 IF STRIG (0) <> 0 THEN X = 0: Y = 0
850 RETURN
1000 WHAT = STICK (0): XDIF = 0 : YDIF = 0
1100 IF WHAT=15 THEN RETURN
1110 IF WHAT=14 THEN YDIF=-1 : RETURN
1120 IF WHAT=13 THEN YDIF=1 : RETURN
1130 IF WHAT=11 THEN XDIF=-1 : RETURN
1140 IF WHAT=10 THEN XDIF= -1 : YDIF = -1 : RETURN
1150 IF WHAT=9 THEN YDIF=1 : XDIF = -1 : RETURN
1160 IF WHAT=7 THEN XDIF=1 : RETURN
1170 IF WHAT=6 THEN YDIF=-1 : XDIF=1 : RETURN
1180 IF WHAT=5 THEN XDIF=1 : YDIF=1 : RETURN