D-Bug & Automation Forum | |
D-Bug & Automation Forum >> Coding >> The Atari Enhanced Joystick Ports FAQ 0.90
http://d-bug.mooo.com/dbugforums/cgi-bin/yabb2/YaBB.pl?num=1313138581 Message started by ggn on 12.08.11 at 08:43:00 |
Title: Re: The Atari Enhanced Joystick Ports FAQ 0.90 Post by ggn on 12.08.11 at 08:45:18
[code]9.1 Light pens
================== A light pen is a device that responds to the bright light of the electron beam in a CRT (i.e. a monitor or television). It relays this as a pulse back to the computer, which is then able to calculate where the electron beam, and hence the light pen, were positioned. With a suitable criver, a light pen could be used in place of a mouse to "draw" on th screen. A variation on the same theme is a light gun, which works on a similar principle, but is designed to be used at a distance, for "shooting" games, etc. The inner workings of a light pen are quite straightforward, since it only has to detect the electron beam, then shape the resultant pulse to suit the input to the computer. In the early days of home computing there were many commercial and DIY implementations of light pens, and it may be possible to adapt one of these to suit the EJP. The biggest issue regarding a light pen and the EJP is that of buttons. The light pen can be used on port A, and the signal is fed into pin six. On a joypad this line is only used for the PAUSE button, so it would be conceivable to build a light pen supporting 20 buttons! In practice the most likely use for a light pen would be as a mouse replacement/complement, so any more than four buttons would be overkill. In fact, my prototype light pen only has two buttons, representing the left and right mouse buttons on a normal Atari mouse. It is my proposal that anyone building a light pen should map the buttons as follows:- "Left" button = Joypad LEFT "Right" button = Joypad RIGHT Button 3 = Joypad UP Button 4 = Joypad DOWN These buttons have been selected since they make most sense, and are all connected to one line within the joypad, reducing the time required to read them all (i.e. all four buttons are returned as a bitmask with one read, rather than with four reads). If anyone writes a driver to support a light pen as a mouse (i.e. outside of one specific program) then the notes about installing an "EJP0" cookie should be noted, and you are advised to contact me about the contents of the structure this should point to. In addition, such a driver should ideally work in co-operation with the existing mouse, and the driver should be able to "unhook" itself at the request of the user - i.e. if they want to run a program that needs the EJPs for something else. 9.2 Example light pen code ============================== I do not have any example code available for this at present, though it should be a "simple" case of reading address 0xFF9220 and 0xFF9222 for the x and y co-ordinates of the light pen respectively. The buttons will be read in the same way as for the joypad. There is a potential problem: according to "The Atari Compendium" only the lower ten bits are significant, giving a range of 0-1023. Since I have not tried any code for this, I do not know if that is in terms of pixels, or in terms of relative distance. If it is a pixel value the code will behave unpredictably for large (>1024 pixels) screens. In addition the light pen relies on the timing of the video system, so will probably be incompatible with video cards and maybe with resolution enhancers such as Blow Up or Screenblaster. All this, however, is pure speculation, and is simply included as a warning, or as a possibility for courageous readers to explore (let me have the results, though!). 9.3 Light pen circuit diagram ================================= I have a circuit diagram for a light pen designed to work with the old Atari 8-bit micros. I am in the middle of constructing this, although it is temporarily on hold due to other commitments. The design I am using was originally published in an old copy of "Electronics - The Maplin Magazine", and was subsequently republished in one of their compilation books. The book, unfortunately, is out of print, although if you really want to try to build your own light pen, you could try contacting Maplin (I got my copy from my local Maplin shop, who had a reference copy of the book, and photocopied the article for me). If/when I finish my light pen, and assuming it works, I shall try to get permission from Maplin to reproduce the circuit diagram here. 9.4 Programs which will use a light pen =========================================== None, as far as I know. 10.1 Other output devices ============================ As has been stated before, the joypad is configured by writing to four output lines. It is conceivable that these lines could be tapped off for other purposes, and I believe that some of the resolution enhancers for the Falcon rely on this trick to communicate with their hardware. It would be possible to build a full 8-bit output port from both EJPs, or a 4-bit output from one. If anyone builds such a device for any useful reason, please mail me with details. 11.1 Other input devices =========================== Similarly the EJP has a number of input lines, as well as 2 ADCs. It could consequently be used for a number of different input devices. For example, with both EJPs it would be possible to make a four channel "mixer" controller for sending out MIDI continuous controller data, or the digital inputs could be attached to footswitches for a similar purpose. If you design any device or code to support such devices, please mail me with full details so that I can include them here. ****************************************************************** END OF FAQ[/code] |
D-Bug & Automation Forum » Powered by YaBB 2.6.0! YaBB Forum Software © 2000-2024. All Rights Reserved. |