--- title: "Doorway" id: 56233 type: "computer_media" slug: "doorway" url: "http://localhost/computer_media/doorway/" markdown_url: "http://localhost/computer_media/doorway.md" published_at: "2024-07-22T01:00:20+00:00" modified_at: "2026-03-30T21:41:44+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-seyu.png" excerpt: "A perspective doorway scene built entirely from PLOT and DRAW geometry — then brought to life with a hypnotic random-colour flash animation." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Art" slug: "art" taxonomy: "genre" url: "http://localhost/type/art/" - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 56205 title: "CATS Library Tape 11" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-11/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Doorway%20%281983%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-seyu.png" media_type_tags: "Art, Demo" --- # Doorway This program draws a perspective doorway scene using a series of PLOT and DRAW commands on the Spectrum’s high-resolution graphics display. It constructs the floor, ceiling, archway, and door frame through four distinct FOR loops that calculate vanishing-point coordinates geometrically. The door opening is filled with horizontal ink stripes, and an elliptical arch is drawn using DRAW’s optional angle parameter. A final animation loop flashes random PAPER and INK colours over the doorway area to simulate a flickering light effect, using OVER 1 to XOR the colours without permanently overwriting the underlying graphics. *** ## Program Analysis ### Program Structure The program is divided into clearly sequential phases, each handled by one or two numbered lines: 1. **Setup (line 10):** Sets INK 1 (blue), PAPER 6 (yellow), BORDER 3 (magenta), BRIGHT 1, and clears the screen. 2. **Door frame sides (line 20):** Draws the two vertical uprights of the door frame with a simple PLOT/DRAW pair. 3. **Floor perspective (line 30):** Iterates `f` from 100 to 1 in steps of −2, plotting horizontal lines that narrow and rise to simulate a receding floor. 4. **Ceiling perspective (line 40):** Similar loop going upward to form the ceiling above the doorway. 5. **Arch top (line 50):** Draws the top of the arch area with narrowing horizontal lines converging to a vanishing point. 6. **Door surround and arch (line 60):** Two iterations (`f=0` and `f=10`) draw the rectangular door frame sides and top, plus a semi-elliptical arch using `DRAW …,-PI`. 7. **Door fill (line 70):** Fills the door opening with INK 0 (black) horizontal stripes every 2 pixels. 8. **Arch highlight (line 80):** Uses `OVER 1` to XOR semi-ellipses in INK 2 (red) over the arch, creating a decorative inlay effect without destroying the background. 9. **Centre divider (line 90):** Draws a vertical line down the middle of the door. 10. **Caption (line 95):** Prints a description to the lower screen channel `#1`. 11. **Flash animation (line 100):** Triple-nested loop cycles through random PAPER, INK, and BORDER colours with FLASH 1 over the door area for an animated light-flicker effect. ### Geometric Techniques The perspective effect in lines 30–50 is achieved by a simple linear projection. For the floor (line 30), each horizontal stripe at depth `f` is positioned at x = `128−f/2` and y = `100−f`, with width `f`. This makes lines converge toward the point (128, 100) — the notional vanishing point at the centre of the doorway. The ceiling uses a similar formula but projects upward (`100+f/2`). Line 60 exploits the three-argument form of `DRAW x,y,angle`. Passing `-PI` as the angle argument draws a semi-ellipse, enabling the curved arch top without any trigonometric calculation in BASIC. ### Colour and Display Attributes Lines 70 and 80 make effective use of attribute modifiers within DRAW statements. `INK 0` in line 70 fills the door interior with black stripes, while `OVER 1; INK 2` in line 80 XOR-draws the arch highlight. Because OVER 1 XORs pixels rather than setting them, the highlight appears only where the arch outline already exists, avoiding colour clashes in the attribute grid. ### Animation Loop (Line 100) The animation in line 100 is a triple FOR loop: the outer loop (`f`, 50 iterations) controls duration; the middle loop (`g`, stepping by 2 through rows 9–20) selects screen rows; the inner loop (`h`, 0–1) prints two consecutive rows per iteration. Each PRINT uses `PAPER RND*8; OVER 1; FLASH 1` with a ten-space string to paint random colour attributes with flashing enabled over the doorway region. `BORDER RND*7` is also called each inner iteration, adding border-colour variation to the effect. ### Notable Idioms and Details - `PRINT #1;` in line 95 directs output to the lower screen (channel 1) rather than the main display area, preserving the graphics. - The `STEP -2` and `STEP 2` increments in the perspective loops reduce the number of iterations by half while still producing a solid visual fill at the resolution used. - The two-value iteration in line 60 (`STEP 10` over 0 and 10) is a compact way to draw both a thin inner and thicker outer door surround in a single loop. - `SAVE "doorway" LINE 10` at line 9998 saves the program with an auto-start at line 10, bypassing the REM header lines. ### Bugs and Anomalies The source REM at line 3 contains a typo — “Specyrum” instead of “Spectrum” — which appears to be a transcription error from the original book listing. There are no logical bugs in the drawing or animation routines. The `INK RND*8` expression in line 100 could theoretically yield INK 8 (transparent), which on the TS2068 would leave the ink colour unchanged rather than setting a new one, potentially reducing the randomness of the effect in some iterations. ## Source Code ``` 1 REM DOORWAY 2 REM 3 REM Typed from book "Better Programming For Your Specyrum and ZX81" 4 REM By S. Robert Speel 5 REM Fontana Computer Books 6 REM 7 REM 10 INK 1: PAPER 6: BORDER 3: BRIGHT 1: CLS 20 PLOT 78,0: DRAW 50,100: DRAW 50,-100 30 FOR f=100 TO 1 STEP -2: PLOT 128-f/2,100-f: DRAW f,0: NEXT f 40 FOR f=100 TO 1 STEP -1: PLOT 128-f/2,100+f/2: DRAW f,0: NEXT f 50 FOR f=0 TO 20: PLOT 128-f,165-f: DRAW f*2,0: NEXT f 60 FOR f=0 TO 10 STEP 10: PLOT 88-f,20-f*2: DRAW 0,80+f*3: DRAW 80+f*2,0,-PI: DRAW 0,-80-f*3: NEXT f 70 FOR f=20 TO 100 STEP 2: PLOT 88,f: DRAW INK 0;80,0: NEXT f 80 FOR f=1 TO 40 STEP 2: PLOT OVER 1;128-f,100: DRAW INK 2; OVER 1;2*f,0,-PI: NEXT f 90 PLOT 128,100: DRAW 0,-100 95 PRINT #1;"A demonstration of the graphics possible with the 2068 computer" 100 FOR f=1 TO 50: FOR g=9 TO 20 STEP 2: INK RND*8: FOR h=0 TO 1: BORDER RND*7: PRINT PAPER RND*8; OVER 1; FLASH 1;AT g+h,11;" ": NEXT h: NEXT g: NEXT f 9998 SAVE "doorway" LINE 10 ```