Turkey

Developer(s): Joey Latimer
Date: 1983
Type: Program
Platform(s): TS 1000

This program draws an ASCII-art figure of a turkey on screen using a subroutine that plots filled ellipses. The ellipse-fill algorithm works by iterating over rows within a bounding box, computing the horizontal half-width at each row via the standard ellipse equation x = a·√(1 − y²/b²), and printing a character across that span.


Program Structure

The program is divided into two logical parts: a main section (lines 10–310) that sets parameters and calls a reusable ellipse subroutine, and the subroutine itself (lines 320–390). Execution ends at the busy-loop GOTO 310 on line 310, which freezes the display indefinitely after drawing is complete.

  1. Lines 10–60: Head ellipse — centre approximately (8.6, 15), radii b=9, a=12, fill char CHR$ 16
  2. Lines 70–110: Torso ellipse — centre (8.6, 15), radii b=8, a=7, fill char CHR$ 27
  3. Lines 120–170: Left leg ellipse — centre (7.7, 15), radii b=3.4, a=2.7, fill char CHR$ 8
  4. Lines 180–210: Right leg ellipse — same X, YY=14, radii b=5.4, a=5.4, fill char CHR$ 8
  5. Lines 220–300: Individual PRINT AT statements for facial features, hands, and feet

Ellipse Fill Subroutine (Lines 320–390)

The subroutine at line 320 fills an axis-aligned ellipse centred at (YY, XX) with vertical semi-axis B and horizontal semi-axis A. For each row Y in the range YY−B to YY+B, it computes the normalised vertical displacement squared P = (Y−YY)², then derives the horizontal half-width M = A·√(1 − P/B²). It then prints the fill character CHR$ I at every column from XX−M to XX+M.

VariableRole
YYRow centre of ellipse
XXColumn centre of ellipse
BVertical semi-axis (rows)
AHorizontal semi-axis (columns)
ICharacter code used to fill the ellipse
Y, XLoop variables (row, column)
PSquared vertical distance from centre
MComputed horizontal half-width at row Y

Notable Techniques

  • The ABS wrapper around 1 − P/B² on line 340 guards against tiny negative floating-point values that could cause a square-root error at the exact top and bottom of the ellipse.
  • Non-integer values for YY (8.6, 7.7) and the semi-axes shift the effective ellipse centre between character rows, giving the FOR loop slightly asymmetric extents and allowing finer positional tuning than integer coordinates alone.
  • Using **2 rather than multiplying a variable by itself is idiomatic but slightly slower; the inner loop already makes performance the main bottleneck since the subroutine uses a pixel-by-pixel horizontal fill.
  • The fill characters CHR$ 16, CHR$ 27, and CHR$ 8 are control codes that display as inverse or special block characters on the target system, giving each body region a visually distinct texture.
  • Individual body details (eyes, mouth dots, hands marked *, feet and joints marked I, +) are applied after the ellipses with direct PRINT AT statements, effectively painting over or beside the filled shapes.

Content

Appears On

Related Products

Related Articles

When the relatives arrive at your house on Thanksgiving Day to the sweet aroma of cooking turkey, keep them out...

Related Content

Image Gallery

Turkey

Source Code

 10 LET YY=8.6
 20 LET XX=15
 30 LET I=16
 40 LET B=9
 50 LET A=12
 60 GOSUB 320
 70 LET XX=15
 80 LET I=27
 90 LET B=8
 100 LET A=7
 110 GOSUB 320
 120 LET XX=15
 130 LET YY=7.7
 140 LET I=8
 150 LET A=2.7
 160 LET B=3.4
 170 GOSUB 320
 180 LET YY=14
 190 LET A=5.4
 200 LET B=5.4
 210 GOSUB 320
 220 PRINT AT 12,10; CHR$ 27; AT 17,20; CHR$ 8
 230 PRINT AT 19,18; CHR$ 8; AT 20,13; "I"
 240 PRINT AT 20,17; "I"; AT 8,12;"."
 250 PRINT AT 7,12;"."; AT 5,13;"."
 260 PRINT AT 4,15;"."; AT 7,14;"*"
 270 PRINT AT 7,16;"*"; AT 21,16;"I"
 280 PRINT AT 21,18;"I"; AT 21,12;"I"
 290 PRINT AT 21,14;"I"; AT 8,15;"+"
 300 PRINT AT 9,15;"+"; AT 10,15;"+"
 310 GOTO 310
 320 FOR Y=YY-B TO YY+B
 330 LET P=(ABS(Y-YY))**2
 340 LET M=A*SQR (ABS (1-P/B**2))
 350 FOR X=XX-M TO XX+M
 360 PRINT AT Y,X;CHR$ I
 370 NEXT X
 380 NEXT Y
 390 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top