Just a simple question: is it possible to get input from a light pen from within BASIC?
Quote from: ruthven on November 17, 2009, 04:02 AM
Just a simple question: is it possible to get input from a light pen from within BASIC?
Sure, just peek the proper registers in the VIC-II chip.
$D013 is X coordinate
$D014 is Y coordinate
Some lightpens might have a button or sensor on them to tell when you want to "draw" which would probably be connected to the "fire" line of the joystick 1 port. Alternately, you might want to check for a key like "shift" on the keyboard.
Steve
Thanks Steve. It was probably a dumb question--I'm sure just about anything that can connect to a C64/C128 can probably be peeked, but I just wanted to be sure before I go buy one. Always wanted a light pen...
Peeking will work on either the 64 or the 128. But on the 128 there are also special functions and commands you can use.
PEN(0) returns VIC-screen X (sprite ordinate / 2)
PEN(1) returns VIC-screen Y (sprite ordinate)
PEN(2) returns VDC-screen X (character ordinate)
PEN(3) returns VDC-screen Y (character ordinate)
PEN(4) returns VDC-screen trigger value
The last one needs a little explanation. The light pen values are updated once per screen refresh but only if the pen triggers the chips' latch. This should happen when the raster passes under the photosensor, but obviously won't if you're not holding the pen to the screen.
Which leads to VIC-Screen latching. You probably noticed there is no PEN() function for the VIC trigger. For this use
COLLISION 3, line#
What this does is makes BASIC call line# in your program whenever the VIC triggers an IRQ by the light pen. It should probably be coded like:
line# PX=PEN(0):PY=PEN(1):PT=1:RETURN
Then your main program might be something like:
DO:PT=0:DO UNTIL PT:LOOP:DRAW1,X*2-24,Y-50:LOOP
To summarize,
VIC triggers via IRQ so use COLLISION
VDC has no IRQ so use PEN(4) test
VDC returns character values
VIC returns sprite coordinate values (but X is halved)
I must say I'm envious. Always wanted a light pen!
Quote from: ruthven on November 17, 2009, 06:16 AM
Always wanted a light pen...
Far off in the annals of time, there was a simple plan to make a do-it-yourself lightpen out of an LED and a real pen. That plan is buried in one of the old magazines, like Commander or RUN or Compute's Gazette...
FWIW, the best lightpen was the Flexidraw lightpen - durable, fit the hand well, reliable, accurate.
And I've tried a whole bunch of lightpens in the past,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
And here I thought light pens had gone the way of Tele-Type machines and 8 inch floppy disks!
Quote from: BigDumbDinosaur on November 17, 2009, 03:57 PM...had gone the way of Tele-Type machines and 8 inch floppy disks!
I have a box of never-used 8-inch disks just waiting to be used in a CBM 8-inch floppy drive. :)
Now if anyone can find that elusive drive,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
Thanks for all the info guys. I've never actually used a light pen before (but always thought they seemed cool)... I'm wondering, would using one of these put the TV screen in danger of being scratched? It doesn't seem like the kind of thing I would willingly press onto a nice new high def flat screen; not that I have one anyway--luckily my old 13" color TV is expendable and I'm not really concerned, but I'm just wondering(?)
Also, can I use ANY old light pen that has the proper 9 pin plug? There's a "Madison Computer" light pen on eBay that I like the style of better than the proper Commodore "Edumate" that I found.
Quote from: ruthven on November 18, 2009, 03:23 AMI'm wondering, would using one of these put the TV screen in danger of being scratched?
All C= lightpens I have tried have the nose made of plastic. If your screen is glass, the plastic will not hurt it.
QuoteIt doesn't seem like the kind of thing I would willingly press onto a nice new high def flat screen...
Lightpens do not work with LCD/plasma screens. They need a CRT screen.
QuoteAlso, can I use ANY old light pen that has the proper 9 pin plug?
The pens that came with Picasso's Revenge and the Koalapen are not good - the former doesn't last and the latter doesn't read.
QuoteThere's a "Madison Computer" light pen on eBay that I like the style of better than the proper Commodore "Edumate" that I found.
The Madison McPen is my second favorite lightpen after the Flexidraw pen. It works well and has an adjustment wheel on the base to adjust its pickup sensitivity.
And the base has a handy pen holder,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
Oh yeah, I don't know what I was thinking but for a moment I forgot high def=LCD. Hey, those McPen units don't require batteries, do they?
Quote from: ruthven on November 18, 2009, 08:02 AMHey, those McPen units don't require batteries, do they?
No, no batteries required.
Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
Thanks... had to check--from the picture, the base seemed big enough where it might take batteries and that would just be a pain. This seems cool though and I'm definitely going to try to acquire one now.
Quote from: ruthven on November 18, 2009, 10:44 AMThis seems cool though and I'm definitely going to try to acquire one now.
In my experience, best commercial software to use with a lightpen... for multi-color, it's a 3-way tie between MicroIllustrator, Koalapainter, and Picasso's Revenge; and for hi-res, it is Flexidraw.
Though I've never tried a lightpen with GEOS,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
Having tried both lightpens and graphics tablets, I can heartily recommend a tablet over a pen. Why? For one, it gets tiring holding your arm up like that for long periods of time, not to mention how close you'll be to the screen. Also: in my experience, lightpens just don't work as well as a good old KoalaPad. The light pen requires high contrast which means you'll be working in black/white most of the time, to get the best pen location detection.
Kpads will run about $20 and are fairly common. You hardly ever see a good working lightpen on eBay.
Lights pens---for any computer---went out of style for some very serious usability concerns.
Oh.... and yes, you can use the Kpad with BASIC. :-)
Quote from: saehn on November 19, 2009, 05:05 AM...it gets tiring holding your arm up like that for long periods of time...
Unless you have one of those desks that mount the CRT under the desk with the screen forming the "tabletop" of the desk. :) I've always considered buying one of those desks.
QuoteThe light pen requires high contrast...
Yes, you need a screen that has high brightness and high contrast. A good lightpen, like a Flexidraw lightpen, is less susceptible to problems with brightness and contrast on a screen.
Quote...which means you'll be working in black/white most of the time...
Unless you are in multi-color mode using many colors.
Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
If you want to build your own light pen ...
http://www.classiccmp.org/cini/pdf/re/C64%20Light%20Pen%20(0685).pdf (http://www.classiccmp.org/cini/pdf/re/C64%20Light%20Pen%20(0685).pdf)
Has a couple of example BASIC programs which I'm sure would be useful.
Have fun!
Mark
Quote from: RobertB on November 19, 2009, 06:20 AMquote]...which means you'll be working in black/white most of the time...
Unless you are in multi-color mode using many colors.[/quote]
But that was my point... being in multi-color mode reduces the contrast and thus the location detection. I've bought several lightpens (including a Flexidraw) and have tried to get them to work. I just don't see that they produce clean enough results for any kind of prolonged graphics work, especially compared to a touch tablet. My C64 pixeling input device order preference: Touch tablet, mouse, joystick, keyboard, light pen. YMMV.
Quote from: saehn on November 20, 2009, 02:52 AM
...being in multi-color mode reduces the contrast and thus the location detection.
I prefer the flexibility of multi-color mode over more restrictive hi-res mode. (And colors are pretty!)
QuoteMy C64 pixeling input device order preference: Touch tablet, mouse, joystick, keyboard, light pen.
My preferences in order of most useful to the least useful: touch tablet, lightpen, joystick (a nice 8-way Kraft joystick), mouse, keyboard.
Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
I once converted an Othello program from a magazine to work with the light pen. It was great fun! I still have the pen somewhere, I think it's a Flexidraw. It even worked on a big screen projection TV, I just had to be careful not to scratch the surface.
Michael
Quote from: mikeebean on March 07, 2010, 05:45 AMI converted an Othello program from some magazine to work with the light pen.
Ooo, a program converted to work with the lightpen! If you can find it, can you post it?
Truly,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
The Other Group of Amigoids
http://www.calweb.com/~rabel1/ (http://www.calweb.com/~rabel1/)
Southern California Commodore & Amiga Network
http://www.sccaners.org (http://www.sccaners.org)
Robert-
I only just now discovered your post. I guess I didn't have "notify me" checked.
The program is... somewhere... if I find it certainly I will. My stuff is mostly boxed, and I've been on emulation-only mode for quite some time. I only really crack out the good stuff once a year or so for special projects. Wish I had more time!
Michael
Quote from: mikeebean on July 17, 2010, 09:24 AMThe program is... somewhere... if I find it certainly I will.
Heh, I'm in the same spot, too. It's somewhere... :)
Back from the United Kingdom,
Robert Bernardo
Fresno Commodore User Group
http://videocam.net.au/fcug (http://videocam.net.au/fcug)
July 24-25 Commodore Vegas Expo 2010 - http://www.portcommodore.com/commvex (http://www.portcommodore.com/commvex)