Saturday, October 22, 2022

Another 3D Plot

A quick port from the Atari. 
I haven't optimized this other than to hide pixels that are behind other pixels using array R().





0 POKE65497,0:CX=320:CY=192:HSCREEN 2:HCOLOR3

1 DIM R(CX):FOR I=0 TO CX:R(I)=CY:NEXT I:GOTO 10


2 R=SQR(X*X+Y*Y)*1.5: IF R=0 THEN F=90:GOTO 4
3 F=90*SIN(R)/R
4 A=10*X+160-5*Y:B=5*Y+2.5*X+93:RETURN



10 FOR Y=10 TO -10 STEP -0.1

REM REMOVED FROM ORIGINAL CODE
REM 20 IF Y=INT(Y) THEN 70
REM 30 FOR X=10 TO -10 STEP -1
REM 40 GOSUB 2:IF R(A)>B-F THEN R(A)=B-F:HSET(A,B-F)
REM 50 NEXT X,Y:GOTO 101

70 FOR X=10 TO -10 STEP -0.1
80 GOSUB 2:IF R(A)>B-F THEN R(A)=B-F:HSET(A,B-F)
90 NEXT X,Y

101 GOTO 101






10 FOR Y=10 TO -10.1 STEP -0.1
20 IF Y-INT(Y)<.1 THEN 70
30 FOR X=10 TO -10 STEP -1

40 GOSUB 2:IF R(A)>B-F THEN R(A)=B-F:HSET(A,B-F)

50 NEXT X,Y :GOTO 101

No comments:

Post a Comment