A light pen cannot see the screen it touches. Its tip holds one light sensor, and all the sensor can report is the instant it catches light. That is enough, because a cathode-ray tube never shows a whole picture at once. Its electron beam draws the image line by line, fifty or sixty times a second, and each spot of phosphor flares as the beam passes. If the computer knows where the beam was at the moment the pen fired, it knows where the pen is. In the 1950s that trick let air-defence operators pick out radar tracks; in the 1980s it let children paint on the family television with a BBC Micro, a Commodore 64 or a Spectrum.
Fast facts
- Origins: MIT’s Whirlwind computer, where the device was first called a “light gun”, in the early 1950s; then the SAGE air-defence consoles and Ivan Sutherland’s Sketchpad (1963).
- Principle: the pen reports when the CRT beam passes its tip; the computer converts that time to a position.
- In hardware: the 6845 CRT controller (BBC Micro, Amstrad CPC) and the VIC-II (Commodore 64) latch a position when the pen fires.
- In software: on the ZX Spectrum, the program watches an input bit and times the pulse itself.
- Precision: a character cell on the 6845 machines; two pixels across and one line down on the C64.
- Limits: a CRT only, a bright enough screen, and one reading per frame.
From Whirlwind to Sketchpad
The first light pens were built for the Whirlwind I computer at MIT between about 1951 and 1955, where the device was still called a “light gun” and was used to pick symbols off the display. Whirlwind led to SAGE, the US air-defence network, whose operator consoles, in Harry Henderson’s summary, “pioneered such features as CRT-based output and a touch interface using a light pen”. In 1963 Ivan Sutherland demonstrated Sketchpad on MIT’s TX-2, drawing on the screen with a light pen, and showed what interactive graphics could be.
The idea reached games by the same route. Ralph Baer’s team at Sanders Associates built a light pen for television quiz games in the 1960s and then turned it into the gun for what became the Magnavox Odyssey, as the light gun entry describes. A light gun and a light pen are the same sensor at different distances from the glass.
How a pen finds itself
The partwork The Home Computer Course explained the device to British readers in 1983. The pen holds a photodetector behind a lens, because “the amount of light emitted by a single pixel being refreshed is so small that a lens must be used to concentrate it”, and most pens had a switch, pressed by a finger or by pushing the tip against the screen, so that room lights did not trigger them. When the pen fires, the video chip “merely measures the length of time from when it last started drawing the lines at the top of the screen, to when a pulse comes from the light pen”, and from that works out which line the pen is on and how far along it.
Home computers did that measuring in two ways, the same two a light gun can use:
- A latch in the video chip. The chip that generates the picture already keeps counters for where the beam is. A pen input tells it to copy those counters into a register the program can read later. The BBC Micro, the Amstrad CPC and the Commodore 64 worked like this.
- A timed input. The pen’s pulse arrives on an ordinary input line, and the program watches that line while the picture is drawn and counts how long the pulse took to come. The Spectrum’s light pens worked like this.
BBC Micro and Amstrad CPC: the 6845 latch
Both machines generate their display with a 6845 CRT controller, a Motorola design. Its datasheet gives it a light pen strobe input: “a low-to-high transition on this high-impedance TTL/MOS-compatible input latches the current Refresh Address in the light pen register.” The register pair, R16 and R17, holds a 14-bit memory address, not a pair of coordinates. It records which character of screen memory the controller was fetching when the pen fired. The datasheet warns that because the pen’s pulse arrives at any moment, an internal synchroniser adds delay, so “the value of R16 and R17 will need to be corrected in software.”
On the BBC Micro the pen plugs into the analogue port on the back, where the strobe goes both to the 6845 and to the system VIA, which can raise an interrupt when the pen fires. Acorn’s operating system did nothing with it: “it has no software to support the light pen”, as The Advanced User Guide puts it. That guide gives the recipe. Subtract a correction for the screen mode (&0606 in modes 0 to 2, up to &2808 in mode 7), then divide by the number of characters per line: the quotient is the row and the remainder the column. The result is only as fine as the 6845’s idea of a character, “so this limits the resolution to a character cell”, or half a character in modes 1 and 5 and a quarter in mode 2. The guide also advises that the screen “should be cleared before using a light pen and not scrolled whilst the pen is in use”, since a scroll moves the start address the arithmetic depends on.
The pens themselves came from third parties. Acorn User compared four in December 1984: RH Electronics’ Colour Light Pen at £45.95, with an interface box and a microswitch probe; the Robin Educational Light Pen at £41.40, switched by finger-touch contact rings; Stack’s at £28; and Datapen’s at £25, with a thumb switch.
The Amstrad CPC uses the same 6845 and brings its light pen input out on the expansion port. Electric Studio Products sold two CPC pens, and its manual shows the 6845’s limit and one way round it. The Mark II “simply plugs into the expansion port” and “is a character accurate device”, so “if the pen nib is between 2 character positions the dot will ‘flick’ between them”. The Professional pen came with its own interface unit, and its read routine returned pixel values instead. Both needed calibrating to the monitor, and both struggled on dark backgrounds: the manual warns that “most problems will be encountered with the 8 darkest colours”. In its first issue, in October 1985, Amstrad Action reviewed the Electric Studio pen at £19.95 on cassette alongside a rival from DK’Tronics.
Commodore 64: the VIC-II latch
The C64’s VIC-II keeps the beam position itself, and latches it straight into two registers when the pen fires. Commodore’s Programmer’s Reference Guide explains that the input “latches the current screen position into a pair of registers (LPX, LPY) on a low-going edge”, at $D013 and $D014. The two axes are not equally precise. The horizontal position comes from a 9-bit, 512-state counter, and only its top 8 bits fit in LPX, so “resolution to 2 horizontal dots is provided”. LPY holds the raster line, giving “single raster resolution within the visible display”.
The pen plugs into control port 1, whose pin 6 is labelled “BUTTON A/LP”: the light pen input shares a pin with the joystick fire button. The VIC-II can raise an interrupt when the pen fires (bit 3 of the interrupt register, “set by negative transition of light pen (1 per frame)”), but the latch works only once per frame and ignores any later pulses. Commodore warned that one reading is not enough: “you must take several samples before turning the pen to the screen (3 or more samples average), depending upon the characteristics of your light pen.”
In America, Inkwell Systems sold the Flexidraw pen and drawing program for the C64. Its 1984 advertising listed freehand drawing, lines, boxes, arcs, circles, zooms, a sprite editor and 512 pattern fills.
ZX Spectrum: timing it in software
The Spectrum’s ULA has no light pen register. DK’Tronics’ Spectrum pen, reviewed by Sinclair User in July 1983 at £21.20, came as a pen on a 3.5 mm plug, a black plastic box that the computer’s power lead ran through, and a tape of software. The box sent its pulse to the Spectrum’s EAR socket, the cassette input, which the ULA presents to the processor as bit 6 of port FE. So a program has to find the pen by reading that bit over and over as the picture is drawn and timing when the pulse arrives. A knob on the box moved “the position of its reaction” up or down, and the pen had to be unplugged whenever the Spectrum loaded or saved a tape. The reviewer found that it worked “satisfactorily” with its instructions but that the suggested delay routine crashed the 48K machine; a reader wrote in the next month to say it worked perfectly for him.
The Vectrex had a light pen too, sold with the Art Master program in mid-1983. Its screen draws lines directly rather than scanning a raster. Retro Gamer’s history of the machine explains that the screen was “scanned invisibly to find where it is positioned”, with the pen drawing its power from the joystick port; three titles used it. The Vectrex entry has the console’s story.
What held them back
The pen needs light, and a spot of screen as small as a pixel gives very little. The Advanced User Guide reckoned that “a fairly large area of screen (ie. perhaps .5cm x .5cm) is usually required to provide sufficient light to operate the pen”, and dark paper colours could fail altogether. The latch, or the program’s timing, also has to know exactly where the picture starts, which is why pens needed calibrating and why scrolling broke them. And the method depends on the scanning beam. A flat-panel display has no beam to catch, so light pens, like light guns, stopped working when the CRT went.
Sources
- Wikipedia, “Light pen” and “Lightgun (Whirlwind)” (web, secondary, citing Robert Everett’s 1980 account of Whirlwind): the light gun on Whirlwind I, about 1951 to 1955, and its use in SAGE. https://en.wikipedia.org/wiki/Light_pen
- Harry Henderson, Encyclopedia of Computer Science and Technology, revised edition (Facts On File, 2009): SAGE’s consoles and light pen (p. 212); Sketchpad, the TX-2 and the 1963 demonstration (pp. 462-463).
- The Home Computer Course issue 8 (Orbis, 1983), “Magic Wands”, pp. 155-157: the photodetector, lens and switch, and how the video chip times the pen.
- Motorola, MC6845 CRT Controller datasheet (1977): the light pen strobe, the R16/R17 register and the need for software correction.
- Andrew C. Bray, Adrian C. Dickens and Mark A. Holmes, The Advanced User Guide for the BBC Microcomputer (Cambridge Microcomputer Centre, 1983): no operating-system support (p. 303); light pens, correction factors and resolution (pp. 367-369); the system VIA’s CB2 input (p. 418).
- Acorn User issue 29, December 1984, Chris Drage, “Guiding Lights” (p. 201): four BBC Micro light pens compared.
- R.A. and J.W. Penfold, An Introduction to Programming the Amstrad CPC464 and 664 (Bernard Babani, 1984), pp. 118-119: the CPC’s light pen input and the 6845’s registers 16 and 17.
- Electric Studio Products, Light Pen “Professional” / Mark II User Manual (1985): character accuracy, calibration, dark colours and the read routine.
- Amstrad Action issue 1, October 1985: the DK’Tronics and Electric Studio pens reviewed.
- Commodore Business Machines, Commodore 64 Programmer’s Reference Guide: the interrupt register (p. 151), the light pen latch (pp. 347, 446) and control port 1’s pinout (p. 395).
- Compute!‘s Gazette, November 1984: Inkwell Systems’ Flexidraw advertisement. Electronic Games, December 1984: Flexidraw described as a light pen.
- Sinclair User issue 16, July 1983, “Hardware World”, p. 24: the DK’Tronics Spectrum light pen. Sinclair User issue 18, September 1983: Alfred Bone’s letter in reply.
- Chris Smith, The ZX Spectrum ULA: How to Design a Microcomputer (ZX Design and Media, 2010), chapter 19: the EAR input on data bit 6.
- Electronic Games, September 1984, p. 84: the Vectrex light pen and Art Master.
- Retro Gamer, Videogames Hardware Handbook volume 1 (Imagine Publishing), “Retroinspection: Magnavox Odyssey” (Baer’s light pen and light gun) and the Vectrex section (the light pen, its power and its three titles).