Login
Forum Help



Post Your Message
="hidden" name="cat" value="Hardware">
Username: (Login)

Topic:
Message:
 


Previous Messages
Posted By

Crown
on 2024-10-29
08:48:56
 Re: Joystick Pinout descriptions - LightPen ?

So I've checked the code in the Trojan Lightpen code.

The keyboard check code is located at $1924 (relocated to $4924 when the code is running), it looks like this:
$1924 jsr $ffe4
$1927 bne $1935
$1929 lda #$ff
$192b sta $ff08
$192e lda $ff08
$1931 and #$04
$1933 bne $1924
$1935 rts
This is called from multiple places, but basically it checks whether a keyboard has been pressed, or whether the button on the lightpen is pressed. As it checks for #$04 we can deduce, that the button is wired on the joystick left line.

Because the lightpen does not uses the joystick select wire, we put #$ff into $ff08 as its value doesn't matter. This also highlights a side effect of the lightpen, that its signals are always available on the K lines of the TED, so whenever there is a latch on $ff08, both the state of the phototransistor and the button can interfere on the relevant keyboard lines.

The detecting of the lightpen line code starts at $13b7 (relocated to $43b7 when running)
$13b7 lda $ff1d
$13ba bne $13b7
$13bc sei
$13bd lda #$28
$13bf sta $ff08
$13c2 lda $ff08
$13c5 and #$40
$13c7 beq $13d3
$13c9 lda $ff1d
$13cc cmp #$cb
$13ce bcc $13bd
$13d0 jmp $43ec
$13d3 lda $ff1d
$13d6 cmp #$04
$13d8 bcc $13ec
$13da cmp#$cb
$13dc bcs $13ec
$13de sec
$13df sbc #$04
$13e1 pha
$13e2 lsr
$13e3 lsr
$13e4 lsr
$13e5 sta $43f0
$13e8 pla
$13e9 clc
$13ea cli
$13eb rts
$13ec sec
$13ed cli
$13ee rts

The inner loop is between $13bd and $13ce. The loop itself takes 21 cycles which is quite long, especially on a DMA line. This means that the signal coming from the phototransistor should at least lasts for the time of a full raster line. This depends partially on the CRT characteristics, the phototransistor, but most importantly on the capacitor.

Posted By

George
on 2024-11-05
06:17:49
 Re: Joystick Pinout descriptions - LightPen ?

Here is the Video @MMS refers to:


It took some time to get the pen working. Its overall of poor quality in my opinion. I thought its was broken in the beginning.
* The CRT had to be properly adjusted, so that it worked. Took some time to find the right settings
* The light conditions of the room also played a role
* The pen the is 40 years old.
* The photodiode inside was loose. I had to find the right position inside the tube Not to far out, not too far in.

Usage:
- In the menu, the software detected the pen-position (Menu-Point) without pressing any-key.
That didn't work very well.
- While drawing you had to press the ctr-key and it displayed a bar in the horizontal line you holded the pen, so it could se a point. This was not very precise and you had to adjust the point every time with the cursor keys.

My conclusion:
Its was not a mouse replacement. My particular lightpen was low-quality, difficult to set up and didn't work reliably. But none the less i had great fun trying out this kind of old technology.

Posted By

MMS
on 2024-10-28
19:54:03
 Re: Joystick Pinout descriptions - LightPen ?

Oh Guys, you are really the source of wisdom! Thank you! As the other one looks fake (not lightpen) I will do my version. Surely I have some empty pens around happy

So it is clearly different from the C64 connection (need 4,5,6,7 pins to be connected), so C64 ones cannot be used, similar to 1531 mouse and paddles :-(
And those two VIC-II registers, really well suits the task.

But the process Crown explained is crazy complex and should be painfully slow, so NOW I understand the speed I saw on George's video. Sure, it won't replace the mouse

My naive expactation (based on SVS Ultimate map), you set $FF0A Bit 2 for Lightpen IRQ, and when the raster line activated the sensor of the pen, you have get an IRQ, and you get the rasterline where the pen activated in $FF0b. I did not have the smallest idea on x coordinates happy. Silly me!

BTW C128 BASIC 7.0 has the command PEN, specifically created for this task, but with those VIC-II registres this is a pretty straingforward register reading task.
Octasoft BASIC 7.0 knows the token but did not realized the function/command.

Posted By

SukkoPera
on 2024-10-28
18:06:45
 Re: Joystick Pinout descriptions - LightPen ?

Well done!

I am not sure it never forgets... Today I have been looking for the OS96 sources by Solder. Apparently they were shared at some point, but I could no longer find any traces of them. sad

Posted By

Lavina
on 2024-10-28
17:57:25
 Re: Joystick Pinout descriptions - LightPen ?

Now at last I had a reason to reupload the old gotu site so here we go: http://gotu.static.domains

There in the hardware section you can find all info we had about the light pen. I see that the Internet does not forget, anyway :)

Posted By

SukkoPera
on 2024-10-28
17:29:17
 Re: Joystick Pinout descriptions - LightPen ?

I managed to find the relevant page in the Wayback Machine, check this out.

In any case, for posterity, here's a screenshot of the original page by @Lavina:


(@MMS, please note that the connector is mirrored wrt the one from your image, and the numbering is also different).

And here's my recreation:


I updated the BJTs to modern equivalents. Please let me know if you spot any mistakes! grin

Posted By

Crown
on 2024-10-28
16:24:52
 Re: Joystick Pinout descriptions - LightPen ?

Back in the day, I've had a light pen which did have a button. We essentially reverse engineered the Light pen software we had, and built it based on what we saw in the code. It was connected to the joystick port, one line went to the phototransistor and one line to the button.
The software was like the Trojan one, I'm not sure whether it was the same, or a modified version of that. But instead pressing the Control button, you could press the button on the light pen, and triggered the same functionality, as the Control button does in the Trojan software. It might be possible that the Trojan software supports both method, I would need to check and verify that.

As for why it takes so much time, you have to understand how a light pen works on a 264 series machine. There is no light pen interrupt or any HW support for light pens, which means the TED doesn't store the x,y coordinates into a register when a pulse comes in from the phototransistor. You just have a joystick port bit which goes high for a short amount of time, then goes back to zero (or the inverted version of this), so you have to establish the coordinates from software.
What the code does is the following: when you press the Control button, it sets the whole screen to white, then busy tests $ff08, when it gets a hit it reads $ff1d, so it knows the Y coordinates from that. To establish the X coordinates, it restores the previous screen, except the character line around the Y coordinates, then it will scan this area by displaying white areas at different locations at every frame, and checks if the strobe is triggered or not. On the tool selection screen this means filling up the checkboxes, a different one every frame, until there is a hit. This is quick and barely visible. On the drawing screen this manifest in a growing white bar from the left edge on the screen, longer every frame until there is a hit. If this is done 1 pixel per frame then it can be up to 160 frames in multicolor or 320 frames in high resolution mode, which can take up to 3 to 6 seconds. A binary search like pattern would have been way faster, but they optioned for this linear search approach, when scanning for the x coordinate.

Posted By

MMS
on 2024-10-28
15:11:30
 Re: Joystick Pinout descriptions - LightPen ?

@SukkoPera thank you , it would be great!

BTW I am more or less sure,that the Lightpen listed there is not a lightpen.
Because there was no such a thing on PC as RS232 lightpen.
-CGA, MDA and even few EGA cards had light pen connection, but a 6 pin simple one (not RS232),
-even the IBM PCjr had a built-in light pen support and connector, but also only a 6 pin very simple connector.
You can see it here. ( This is Sparta! grin)
https://cdm.link/8-bit-painting-watch-a-diy-light-pen-for-the-ibm-pcjr/

I found nowhere a RS232 DB9 based Light Pen for PC, so it is more probably a barcode reader or something like that.

Also, watching again @George video, I noticed that Trojan pen also seems do not have a button.
You put it at the position and wait to pick.
I am curious, why it took so much time for the pen to pick a position, as the screen scanned 50 times in a second, so the recognition of the position should happen in miliseconds, but surely not for 1-2 seconds as I saw.
Do you have any idea? Maybe the black background George used made the phototransistor less sensitive? Maybe a white background would do the job?

The Amiga Trojan Light Pen could be used instead of mouse (at least for some seconds happy )
https://www.youtube.com/watch?v=WxQgoeyoWaA

Posted By

SukkoPera
on 2024-10-28
05:35:25
 Re: Joystick Pinout descriptions - LightPen ?

Coincidentally, I have also been looking into light pens recently.

I think I have managed to recover @Lavina's schematics and used that to add Light pen support to my OpenC16JoyAdapter. The idea is that you just need 3 wires, a phototransistor and some old pen to put it into happy. I have also bought some different types of phototransistors to see if they work, but I haven't tested anything, yet. I don't even have a CRT here.

I don't have the schematics handy right now, but from memory I seem to recall that the phototransistor just pulls the fire button line low when it detects light. Other than that, you only need +5V and GND from the port. There are no buttons on the pen itself, but of course they could be added on any other pins as long as the software is able to read and detect them.

Posted By

MMS
on 2024-10-27
15:57:43
 Joystick Pinout descriptions - LightPen ?

Hello

It will be a little arkwards question. I cannot find the info, to which joystick port pin the Light pen need to be connected on C16.

but I checked all my documents (including 264 Hardware specs by Bil Herd and Dave Haynie) but next to the remarks that the ligh pen can be connected, I cannot find it anywhere mentioned which pin. (the 264 Hardware specs is missing the Joystick and Datasette piout and the video pinout just listed, but no picture - seems Dave already liked the beer at that time too happy )

BTW I checked the Plus4Reference manual and even SVS Ultimate map, and a lot more. Nowhere it is mentioned. GOTU page (the main refenece by most) is down.
We know from Trojan Light pen (recently tested by @George) that it really works, sooo. BTW YAPE emulates the User Port Lightpen, not the Joystick lightpen from Trojan.

Why it is interesting?
On the following FB page there is a guy who has 200 NOS Light Pens. Maybe it is not light pen, but looks like as one.
It is connected to a RS232 father connector(??? strange, PC RS232 mouses have female connector) , and most probably it is not for C64 (or ATARI or MSX etc) too, as C64 lightpen requires 4 pins to connect, but this one uses only 2 pins.

Why it could be interesting? Because if the connection is clarified on C16, it would be very easy to create a big bunch of cheap (?) Light Pen for the scene (IF it is really a PC lightpen). (Well, I know it could be used only with CRT TV or monitor.)



The parts:




Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon