Commodore 128 System Manual page 339

Table of Contents

Advertisement

This example displays the contents of the registers of the VIC
chip.
PEN
Returns X and Y coordinates of the light pen
PEN(n)
where n=0 PEN returns the X coordinate of light pen position.
n=1 PEN returns the Y coordinate of light pen position.
n=2 PEN returns the X coordinate of the 80 column
display.
n= 3 PEN returns the Y coordinate of the 80 column
display.
n=4 PEN returns the light pen trigger value.
Note that, like sprite coordinates, the PEN value is not scaled and
uses real coordinates, not graphic bit map coordinates. The X
position is given as a number, ranging from approximately 60 to
320, while the Y position can be any number from 50 to 250.
These are the visible screen coordinate ranges, where all other
values are not visible on the screen. A value of zero for either
position means the light pen is off screen and has not triggered
an interrupt since the last read. Note that COLLISION need not
be active to use PEN. A white background is usually required to
stimulate the light pen. PEN values vary from system to system.
Unlike the 40 column (VIC) screen, the 80 column (8563)
coordinates are character row and column positions and not pixel
coordinates like the VIC screen. Both the 40 and 80 column
screen coordinate values are approximate and vary, due to the
nature of light pens. The read values are not valid until PEN(4) is
true.
EXAMPLES:
10 PRINT PEN(0);PEN(1)
10 DO UNTIL PEN(4):LOOP
20 X=PEN(2)
30 Y=PEN(3)
40 REM:REST OF PROGRAM
Display the X and Y
coordinates of the light pen.
Ensure the read values are
valid
18-11

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents