--- title: "MODified Squares" id: 77459 type: "computer_media" slug: "modified-squares" url: "http://localhost/computer_media/modified-squares/" markdown_url: "http://localhost/computer_media/modified-squares.md" published_at: "2026-11-15T18:38:23+00:00" modified_at: "2026-11-15T18:38:23+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/11/modified-squares-1.png" excerpt: "A grid of spiralling squares drawn with a MOD subroutine, for the TS2068 and hi-res ZX81 systems." post_tag: - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "ZX81" slug: "zx81" taxonomy: "post_tag" url: "http://localhost/tag/zx81/" model: - name: "Sinclair ZX81" slug: "zx81" taxonomy: "model" url: "http://localhost/model/zx81/" - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Peter McMullin" slug: "peter-mcmullin" taxonomy: "indiv" url: "http://localhost/indiv/peter-mcmullin/" genre: - name: "Graphics" slug: "graphics" taxonomy: "genre" url: "http://localhost/type/graphics/" media_type: "Program" programmers: - name: "Peter McMullin" slug: "peter-mcmullin" taxonomy: "indiv" url: "http://localhost/indiv/peter-mcmullin/" mediadate: "1986" images: - url: "http://localhost/wp-content/uploads/2026/11/modified-squares-1.png" article_media: - id: 42043 title: "ZX81 Resources" type: "article" url: "http://localhost/article/zx81-resources-4/" media_type_tags: "Graphics" license: false --- # MODified Squares A 4 by 4 grid of squares, each drawn eighteen times and turned a little each time so that the corners spiral inward; neighbouring squares turn opposite ways. Like MODified Triangles it uses a one-line MOD subroutine, and it is Program 2 of Peter McMullin’s adaptation of Paul W. Carlson’s “MODified Shapes for IBM” (COMPUTE!, May 1986). Printed for the TS2068 (line 865) and for a ZX81 with the JLO video system and JOBASIC or PIXL-ATR (line 855), or any hi-res package with a DRAW or LINE command, with margin notes for the TS2068 versions of lines 25 and 30; the reader deletes the line for the other machine. As printed, with both lines in place, it stops at line 855 with variable V not found. Published in Sinc-Link November-December 1986 ([ZX81 Resources](https://timexsinclair.com/article/zx81-resources-4/)). ## Source Code ``` 2 REM For ZX81: INITIALIZE JOBASIC OR PIXL-ATR ETC. 3 GOTO 40 5 REM MODULO SUBROUTINE 6 LET RES=ARG-INT (ARG/MOD)*MOD 7 RETURN 10 REM IBM>SINCLAIR PLOT SCALING 15 LET XX1=(X1/1.25)+XSET 20 LET XX2=(X2/1.25)+XSET 2068: USE 25 LET YY1=191-(Y1/1.1) YY1=175-(Y1/1.3) 30 LET YY2=191-(Y2/1.1) YY2=175-(Y2/1.3) 35 RETURN 40 DIM X(4) 50 DIM Y(4) 60 DIM Z(4) 70 DIM T(4) 80 LET XSET=-3 100 LET SU=.12 110 LET RU=1-SU 200 FOR I=0 TO 3 210 FOR J=0 TO 3 220 LET ARG=I 230 LET MOD=2 240 GOSUB 5 250 LET RI=RES 260 LET ARG=J 270 GOSUB 5 280 IF RI=RES THEN GOTO 400 300 LET Y(1)=49 310 LET Y(2)=0 320 LET Y(3)=0 330 LET Y(4)=49 340 GOTO 500 400 LET Y(1)=0 410 LET Y(2)=49 420 LET Y(3)=49 430 LET Y(4)=0 500 LET X(1)=20 510 LET X(2)=20 520 LET X(3)=89 530 LET X(4)=89 600 FOR N=0 TO 17 610 LET X1=X(4)+I*69 620 LET Y1=Y(4)+J*49 700 FOR M=1 TO 4 710 LET X2=X(M)+I*69 720 LET Y2=Y(M)+J*49 800 LET ARG=M 810 LET MOD=2 820 GOSUB 5 830 LET C=RES+1 835 REM SET INK COLOUR BY C 840 GOSUB 10 850 REM DRAW SIDE (JOBASIC) 855 IF USR V THEN LPRINT D;XX1,YY1;XX2,YY2 860 REM DRAW SIDE (2068) 865 PLOT XX1,YY1: DRAW XX2-XX1,YY2-YY1 870 LET X1=X2 875 LET Y1=Y2 880 LET ARG=M 885 LET MOD=4 890 GOSUB 5 895 LET NJ=RES+1 900 LET Z(M)=RU*X(M)+SU*X(NJ) 910 LET T(M)=RU*Y(M)+SU*Y(NJ) 920 NEXT M 1000 FOR P=1 TO 4 1010 LET X(P)=Z(P) 1020 LET Y(P)=T(P) 1030 NEXT P 1040 NEXT N 1050 NEXT J 1060 NEXT I 1070 IF INKEY$="" THEN GOTO 1070 1080 STOP ```