0 REM ROTSQRS.BAS.txt

10 REM - Rotating Square Program (30° Increments for Full Rotation)
20 GOSUB 1000 : REM Clear the Screen
30 PI = 3.14159
40 DZOP "C",1 : REM Color mode [Range = 16-23]
50 C = 17 : REM Initial color
60 XC = 128 : YC = 128 : REM Center coordinates

70 FOR ROTATION = 0 TO 2*PI STEP PI/6 : REM Rotate by 30° increments (PI/6)
80 GOSUB 2000 : REM Draw rotated square
90 C = C + 1 : IF C > 23 THEN C = 16 : REM Cycle through colors
100 GOSUB 3000 : REM Pause and clear screen between rotations
110 NEXT ROTATION

999 GOTO 9999 : REM End of Program

1000 REM Clear the Screen Routine
1010 DZOP "C",16
1020 DZOP "P",0,0
1030 DZOP "R",255,255
1040 RETURN

2000 REM Rotated Square Drawing Routine
2010 DZOP "C",C : REM Set color
2020 FOR VERTEX = 0 TO 3 : REM 4 vertices of the square
2030 X1 = XC + 50 * COS(ROTATION + PI/2 * VERTEX) : REM Apply rotation to each vertex
2040 Y1 = YC + 50 * SIN(ROTATION + PI/2 * VERTEX) : REM Adjust angle for each side
2050 IF VERTEX = 0 THEN GOSUB 2100 : REM Move to the first vertex
2060 X2 = XC + 50 * COS(ROTATION + PI/2 * (VERTEX+1))
2070 Y2 = YC + 50 * SIN(ROTATION + PI/2 * (VERTEX+1))
2080 DZOP "L",X2,Y2 : REM Draw line to the next vertex
2090 NEXT VERTEX
2095 RETURN

2100 REM Move to the first vertex
2110 DZOP "P",X1,Y1
2120 RETURN

3000 REM Small Pause and Clear Screen between rotations
3010 FOR PAUSE = 1 TO 300 : NEXT PAUSE : REM Short pause
3020 GOSUB 1000 : REM Clear the screen after each rotation
3030 RETURN

9999 REM End of Program
10000 END
