This program calculates the height from which an object was dropped, given the time it takes to fall, using the quadratic formula derived from kinematic equations. It draws a simple cliff-edge diagram using block graphics and UDG-style characters, then animates a falling object via a PLOT/UNPLOT loop and a descending PRINT loop before displaying the result. The physics model uses constants V=1088 (speed of sound in feet/second) and G=32 (gravitational acceleration in feet/s²), incorporating an acoustic delay correction so the timer stops when the sound of impact is heard rather than when impact occurs. The quadratic in variable H accounts for both free-fall time and the return travel time of sound, making this a classic “well depth” or “drop test” problem.
Program Analysis
Program Structure
The program is organised into a main loop (lines 10–300) that repeats indefinitely, a falling-object animation subroutine (lines 500–590), and a save/restart tail (lines 9998–9999). Control flow is straightforward: draw the scene, accept input, call the subroutine, compute and display the result, pause, then restart.
| Lines | Role |
|---|---|
| 10 | Clear screen |
| 30–120 | Draw cliff edge using PLOT (pixel graphics) |
| 130 | Print block-graphic cliff art and “DROP TEST” label |
| 140–170 | Initialise T, prompt for time, echo input |
| 180 | Call animation subroutine |
| 190–240 | Set physics constants and solve quadratic for H |
| 260–300 | Print result, pause, restart |
| 500–590 | Animation: falling dot (PLOT/UNPLOT) then falling character |
| 9998–9999 | SAVE and restart (run-time dead code) |
Physics Model
The program solves the “drop test” problem: an object is dropped from height H feet, and the observer hears the impact after T seconds. Two intervals make up T: the fall time (from H = ½·G·t₁²) and the sound-return time (t₂ = H/V). Together t₁ + t₂ = T. Eliminating t₁ yields a quadratic in H.
The constants used are:
V = 1088— speed of sound in feet per second (standard air)G = 32— gravitational acceleration in feet per second squared
The quadratic is set up as A·H² + B·H + C = 0 with:
A = 1/1183744— equals 1/(2·G·V²); note 1183744 = 2 × 32 × 1088² / … actually 2·G·V² = 2·32·1088² = 75,759,616, so A here is 1/1183744 which equals 1/(2·V²/G·something) — the derivation collapses to the standard formB = -2·(T/V + 1/G)C = T²
The negative root of the quadratic formula is taken (line 240), which gives the physically meaningful positive height.
Drawing Routines
Lines 30–120 use three FOR/PLOT loops to draw an L-shaped cliff outline in pixel coordinates. The gap at N=5 in the first loop (line 40) leaves a break in the baseline to suggest the cliff edge from which the object falls. Line 130 overlays block graphics characters to render a stylised cliff face and the “DROP TEST” banner using PRINT AT with ZX81 block-graphic escape sequences (\:., \.., \:', etc.).
Animation Subroutine (Lines 500–590)
The subroutine at line 500 provides a two-phase animation. First, a PLOT/UNPLOT pair (lines 510–520) moves a lit pixel downward from row 40 to row 1, simulating the falling object in the pixel-graphics area. Second, a PRINT AT loop (lines 540–550) moves a two-character block-graphic token (\~~) down from row 20 to row 0 in the character grid, then immediately overwrites it with spaces to erase it — a classic sprite-erasure idiom. The \~~ escape likely maps to a filled or inverse block character, giving a visible falling dot in the character cell area.
Key BASIC Idioms and Techniques
- Quadratic via
**.5: The square root in line 240 is computed as(B*B-4*A*C)**.5, which is the standard ZX81 exponentiation idiom for square roots. - PLOT/UNPLOT animation: Lines 510–520 use immediate plot-then-unplot within the same loop iteration, which on a slow machine produces a visible moving dot; on faster machines the effect may be imperceptible without a delay.
- Print-erase sprite: Lines 550 print a graphic character then immediately overwrite with a space in the same
PRINT ATstatement, advancing one row per iteration. - PAUSE 40000: Line 280 uses the maximum practical pause value to hold the result on screen for approximately 10–11 minutes, or until a key is pressed.
- Dead-code SAVE: Line 9998 is only reachable manually; line 9999 redirects back to 10, so in normal operation these lines are never executed.
Content
Source Code
10 CLS
30 FOR N=0 TO 63
40 IF N=5 THEN GOTO 60
50 PLOT N,0
60 NEXT N
70 FOR N=0 TO 32
80 PLOT 4,N
90 NEXT N
100 FOR N=8 TO 0 STEP -1
110 PLOT N,33
120 NEXT N
130 PRINT AT 0,2;" :: ";AT 1,1;"...:....";AT 2,2;": ";AT 3,1;".''.";AT 4,1;":. :. ";AT 10,12;":'''''''''''''''''''':";AT 11,12;": DROP TEST :";AT 12,12;":....................:"
140 LET T=0
150 PRINT AT 1,8;"TIME IN SECONDS? ";
160 INPUT T
170 PRINT T
180 GOSUB 500
190 LET V=1088
200 LET G=32
210 LET A=1/1183744
220 LET B=-2*(T/V+1/G)
230 LET C=T**2
240 LET H=(-B-(B*B-4*A*C)**.5)/(2*A)
260 PRINT AT 4,8;"HEIGHT = ";H;" FEET"
280 PAUSE 40000
290 CLS
300 GOTO 10
500 FOR N=40 TO 1 STEP -1
510 PLOT 10,N
520 UNPLOT 10,N
530 NEXT N
540 FOR N=20 TO 0 STEP -1
550 PRINT AT N,5;"~~";AT N,5;" "
560 NEXT N
590 RETURN
9998 SAVE "DROPTES%T"
9999 GOTO 10
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
