--- title: "Crack Safe" id: 50607 type: "computer_media" slug: "crack-safe" url: "http://localhost/computer_media/crack-safe/" markdown_url: "http://localhost/computer_media/crack-safe.md" published_at: "2023-06-23T11:26:00+00:00" modified_at: "2026-03-30T21:41:34+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2019/02/20230809-041332.jpg" excerpt: "Guess three secret numbers to crack a combination safe, guided by musical pitch hints, before your security units run out." 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: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Crack%20Safe%20%28198x%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2023/06/SCR-20260329-prfp.png" media_type_tags: "Game" --- This program simulates a combination lock safe-cracking game in which the player must guess three secret numbers between 1 and 50. The screen displays a graphical safe door drawn with PLOT, DRAW, and CIRCLE commands, including concentric filled circles for a dial effect using INK 0 and INVERSE. As the player dials each number, a BEEP sequence plays with pitch values calculated from a parabolic curve centered on the target number, providing an audio hint about proximity. The player starts with 10 security units, losing one for each incorrect guess; reaching zero triggers a flashing security alert and a 50-note alarm loop before halting. *** ## Program Analysis ### Program Structure The program is organized into three distinct phases: screen setup and graphics (lines 5–45), the main game loop across three combinations (lines 50–200), and the endgame resolution (lines 210–220). The outer `FOR c=1 TO 3` loop at line 50 controls the three combination stages, with a shared input/validation/feedback cycle inside it. ### Screen and Graphics Setup Lines 5–8 paint a green background and white inner panel, then use `PLOT`/`DRAW` to draw a rectangular border at pixel coordinates (64,23) with dimensions 127×128. Lines 15–20 draw the safe dial: a solid ring of concentric circles in INK 1 (blue) for radii 25–45, then a smaller filled circle in INK 0 (black) for radii 56–64 to erase the center, giving a donut appearance. Line 40 draws solid block-graphic borders down the left and right edges using the `\::` (█) escape character. ### Combination and Pitch Calculation At line 60, each secret number `n` is chosen randomly: `INT(RND*46+5)`, giving a range of 5–50. Line 70 populates the 50-element array `b()` with pitch values using a piecewise linear formula centered on `n`: - For `i < n`: pitch = `25 - (n-1)/2` (a constant below target, scaled) - For `i > n`: pitch = `25 - (i-n)/2` (decreasing above target) - For `i = n`: pitch is set to `-10` (a distinct low note marking the exact target) The Boolean arithmetic `(in)` evaluate to -1 (true) or 0 (false) in Spectrum BASIC, so the expression correctly selects the appropriate branch without an `IF` statement — a classic Sinclair idiom. There is a subtle anomaly in the formula: the `i < n` branch evaluates to `25 - (n-1)/2` regardless of `i`, making all positions below the target play the same pitch. This means the audio hint is asymmetric: the pitch only changes as the dial passes above the target number. ### Dial Animation Lines 100–120 animate the dial movement. The loop `FOR k=x TO d STEP 1-2*(dn)*(i-n)/2: NEXT i 75 LET b(n)=-10 80 INPUT FLASH 1;"Enter next number:";d 90 LET d=INT d: IF d<1 OR d>50 OR d=x THEN PRINT INK 2; FLASH 1;AT 10,7;"UNAUTHORIZED ENTRY": LET su=0: GO TO 210 100 PRINT PAPER 4; FLASH 1;AT 3,15;"--" 110 FOR k=x TO d STEP 1-2*(dn THEN GO TO 160 140 FOR i=1 TO c: BEEP 0.5,-5*i: NEXT i 150 PRINT AT 10,7;"Section ";c;" unlocked": GO TO 200 160 LET su=su-1: PRINT AT 20,1;"You have ";su;" security units left." 170 IF su=0 THEN PRINT AT 10,0; INK 2; FLASH 1;"** SECURITY ALERT - INTRUDER **": GO TO 210 180 IF su=1 THEN PRINT AT 15,12; PAPER 2; FLASH 1;"Warning!" 190 GO TO 80 200 NEXT c 210 IF su=0 THEN FOR i=1 TO 50: BEEP 0.5,10: BEEP 0.5,20: NEXT i: STOP 220 PRINT AT 15,0; PAPER 2; INK 7;"Well done! You have opened the safe with ";su;" turns to spare!": STOP ```