Re: light pens on Apple II (and reading >1 light pen on the same computer)



On Oct 31, 9:38 am, mad.scientist...@xxxxxxxxx wrote:
am wondering if it would be possible to modify the c64 light pen to
work with the Apple and plug in & detect >1 light pens simultaneously.

you have PB0 to PB3 I think. That's 4 TTL inputs. So you could
hook up 4 of them!

software: I played with a lightpen and the 6502 code to get "fast"
input from it. There are a few methods you can use to read the
pen.

1) start counting when VBL has ended. Watch the pen. When
the pen detects light, stop the counter. You can convert the counter
value into screen position. It doesn't work very high res on
the horizontal axis because 1 byte gets slammed to the video
circuits every cycle. 1 byte = 7 horizontal pixels. The 6502
takes too many cycles to LDa and BEQ to get high res on the
horiz.

2)skip the counter in the above, and just have:
LDA pen
BEQ
LDA PEN
BEQ
LDA PEN
BEQ
but you'll still have low horiz resolution. With the timing of the
detection code, there is a horizontal resolution of 10. It takes 4
cycles for each check of the port, and the screen is 40 bytes/40
cycles wide. 40/4=10.


3)blank all "pen-able" spots. make sure the pen reports "no light",
then
light up the "pen able" spots one by one. Check the pen for "light"
after
each one is lit. if the pen reports "light", you know it's pointing
at that
spot on the screen.

See:


http://rich12345.tripod.com/
http://rich12345.tripod.com/aiivideo/vbl.html
http://rich12345.tripod.com/aiivideo/pen.html
http://rich12345.tripod.com/bse/shot.html
---I used #3 from above on the shootemup

Rich







.