| |
Oswald
Registered: Apr 2002 Posts: 5017 |
Reading spacebar via lightpen registers
Google doesnt help me with this topic, how is this done, and what is the explanation please? |
|
| |
Martin Piper
Registered: Nov 2007 Posts: 631 |
The light pen generates a signal when it detects the TV raster passing in front of it. This signal is passed through control port 1 pin 6 which is labelled BTNA/LP and PB4 going into CIA1 @ $dc0x: http://www.zimmers.net/anonftp/pub/cbm/schematics/computers/c64..
This signal comes into pin 9 for VIC: http://www.zimmers.net/anonftp/pub/cbm/schematics/computers/c64..
This causes the VIC to latch into LPX LPY registers the current raster position that is being drawn by the TV.
Now, since BTNA/LP also goes into CIA1 and since CIA1 is for keyboard rows, don't forget the problem with the port 1 joystick fire button being seen as a keyboard space bar (seen in the schematic), I suppose if someone presses the spacebar or the joystick button it can be treated as a light pen signal. This will probably cause the light pen LPX and LPY registers to get latched with whatever raster position is being drawn by the VIC. |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
thanks Martin, this brings up the question why is the LightPen trigger signal wired into the CIA ? |
| |
Martin Piper
Registered: Nov 2007 Posts: 631 |
Because it shares a signal with the joystick button. Which also shares a signal with the keyboard row. All going into the CIA.
I suppose they didn't want to have too many discrete signals for the control ports. |
| |
tlr
Registered: Sep 2003 Posts: 1702 |
Reading is fine, but more importantly you can get and IRQ on pressing space bar using this feature.
The reverse of this is also sometimes used for stable rasters, see: https://codebase64.org/doku.php?id=base:stable_raster_with_ligh.. |
| |
YTM
Registered: Apr 2021 Posts: 3 |
It also works in the opposite way: you can configure that line to be an output and a high to low transition with latch current beam location into lightpen registers.
Maybe it's not so useful with VIC, but it's a neat trick for VDC to get curent raster line estimation. |