← All spotlightsHardware / Input

Spotlight › CGA light pen

CGA light pen

Point at the screen itself. With a light pen on a CGA card, you can now press, drag and release on the os8088 desktop.

A pen at work, emulated
MartyPC's emulated IBM 5150 at 4.77 MHz, with the pen's position fed to the emulated CGA by a script. 20 seconds of video are 20 seconds of the machine's time.
Position steps
16 x 2 pixels
Memory while loaded
512 bytes
Screens it works on
CGA

01 / What it is

What it is

Illustration: a light pen
Black and white drawing of a pen-shaped stylus with a push switch near its tip and a coiled cable ending in a small connector.
An illustration made with an image generator, not a photograph.
Illustration: using it
Black and white drawing of a hand touching a light pen to the glass of a CRT monitor.
An illustration made with an image generator, not a photograph.

A light pen is a stylus with a light sensor in its tip, from the years before most computers had a mouse. A CRT, the picture tube of an old monitor, draws its picture with a spot that sweeps the screen line by line. When the spot passes under the pen, the sensor sees it, and the graphics card notes where the spot was at that instant.

CGA, the colour graphics card of the first IBM PCs, has a connector for such a pen. os8088 now has a driver for it: hold the pen to the screen and press its switch to click, keep it pressed to drag, and let go to release.

02 / On the screen

On the screen

Switching it on
The Drivers page of the Control Panel with CGA Light Pen ticked and marked Loaded.
Tick CGA Light Pen on the Drivers page. MartyPC.
A menu, pulled down by pen
The File menu open on the CGA desktop with New Folder highlighted.
MartyPC, IBM 5150.
A folder, opened by two taps
A Disk window showing the MEDIA folder with two files.
MartyPC, IBM 5150.

03 / How it works

How it works

Once each clock tick, about 18 times a second, the driver reads the pen's switch and the card's record of where the pen last saw light. From that it works out a position and moves the pointer there.

The card can only say which 8-pixel byte it was reading, and in this mode that comes out as steps of 16 pixels across and 2 lines down. Release works even over a dark part of the screen, where the pen sees nothing. The mouse and keyboard pointer keep working alongside it.

04 / What it does not do

What it does not do

It has not been tried with a real pen on a real monitor. Everything here was tested on an emulator that imitates the card's pen circuit. A report from real hardware is welcome.

It is coarse. Use the mouse for pixel work. A pen needs something lit under it to click.

CGA only, as the main screen. The 286 edition and the 128KB edition of os8088 do not have the driver.

05 / Run it

Run it

  1. Connect a switched light pen to the CGA card.

  2. Boot os8088 from the standard system disk on the CGA monitor.

  3. Open Control Panel > Drivers and tick CGA Light Pen. Close the Control Panel to keep the choice.

  4. Aim at a bright part of an item and press the pen's switch.