Sorry if the translation is strange, I've really made it quickly! Mail me if something's wrong.
I am not certain that much Oricians own today the Mageco light pen. But, a while ago, Fabrice Frances added its emulation to Euphoric (I tortured him ;-). Weren't you surprised by this curious gray point on the screen? Well yes, it's the pointer of the light pen. If you don't see anything, refer to Euphoric's doc, which will tell you more about this point. Just know that this pointer indicates the zone where you want... To point! You move it using the PC mouse and activate it by pressing the button. In short, under Euphoric, you now have a mouse! :-) The objective of this page is to help you programming the pen.
I - Ze docs
1- Plug the pencil
2- How to set up the sensitivity of the pencil
3- The screen and the values of PEEK(992) and PEEK(993)
4- Program allowing a choice in a menu
5- Drawing program
6- Subroutine for automatic calibration
II - More help...
1- Running the light pen with Euphoric
2- Exemple: how to replace a GET A$
3- Small trap: odd coordinates
The end
I - Ze docs
I've reproduced here the exact contents of the (small) docs that came with the light pen... (c) Mageco of course.
The light pen that you have just acquired works whatever the memory size of your Oric is, it does not require any particular extension.
It can be used with a television set, color or black and white; the position of the pencil will be validated on bright areas.
It uses 2 bytes in memory: 992 for the position on horizontal axis (x) and 993 for the position on the vertical axis (Y).
Back to menu
1- PLUG THE PENCIL
1. Disconnect the power supply of your Oric.
2. Connect the light pen using the flexible female-female extension cable or the mother board.
3. Connect the male DIN plug in the Oric's RVB plug.
4. The possible extensions connected previously on Oric's RVB will be connected in the DIN female plug of the light pen.
5. Connect the power supply of your Oric.
Back to menu
2- HOW TO SET UP THE SENSITIVITY OF THE PENCIL
Type exactly:
10 ? PEEK(992), PEEK(993)
20 GOTO 10
You will see two columns of figures, point the pencil on the screen and adjust contrast and light so that the figures of the right and left columns do not change any more. Then move the pencil, the figures must change. The left column determines the displacement in the horizontal direction, the right one the displacement of the pencil in the vertical direction.
Back to menu
3- THE SCREEN and the values of PEEK(992) and PEEK(993):
(the values I put here are the ones provided by Euphoric, and are very close to those of the original doc that Fabrice reproduced; however on real Oric, they can heavily vary according to the adjustments of your screen)
4- PROGRAM ALLOWING A CHOICE IN A MENU
10 CLS
20 ?"Option 1"
30 ?:?"Option 2"
40 ?:?"Option 3"
50 IF PEEK (993) < 72 THEN GOTO 100
60 IF PEEK (993) > 72 AND PEEK (993) < 88 THEN GOTO 200
70 IF PEEK (993) > 88 AND PEEK (993) < 104 THEN GOTO 300
80 GOTO 50
100 ?"Option 1":END
200 ?"Option 2":END
300 ?"Option 3":END
Back to menu
5- DRAWING PROGRAM
10 HIRES:PAPER7:INK0
30 GOSUB 1030
35 X1=X:Y1=Y
110 GOSUB 1030
170 DRAW(X1-X),(Y1-Y),1:REM line
180 GOTO 30
1030 X=0:Y=0
1040 FOR N=0 TO 3
1050 X=X+PEEK(992)-220:Y=Y+PEEK(993)-56
1052 WAIT 2:NEXT N:REM Improvement of the precision by measuring 4 times
1057 X=X/4:Y=Y/4
1060 IF Y < 0 THEN Y=255+Y
1065 IF X < 0 THEN X=255+X
1070 IF X > 239 THEN X=239
1075 IF Y > 199 THEN Y=199:REM Repositioning of the cursor
1080 CURSET X,Y,1:WAIT 30:CURSET X,Y,0:REM Flickering
1096 IF KEY$="Z" THEN RETURN
1100 GOTO 1030
You see a white screen, it is normal. Now point your pencil on the screen, you must see a small black point flickering at the place where is positioned the pencil. Press Z key to validate the place, move the pencil to another place and press Z key again. Now Oric draws a line between the 2 points previously determined.
Back to menu
6- SUBROUTINE FOR AUTOMATIC CALIBRATION
Launch this at the beginning of program. Put the pencil on the point; validation of calibration is made by pressing Z (DX adjusts the position of the pencil into horizontal, DY into vertical).
2000 X=120:Y=120
2010 CURSET X,Y,1
2040 IF KEY$="Z" THEN GOTO 2060
2050 GOTO 2010
2060 DX=PEEK(992)-X:DY=PEEK(993)-Y
Back to menu
Here we are, the doc is finished! Do not write to me about the, erm, light (should I say "heavy") programming of the examples of this doc... Here are now some examples from my own.
II- MORE HELP...
Well, ok, documentation is quite nice, but I think that it can be useful to add some explanations and some examples of frequently used commands. I remind you that my small program Ex-SIP (French only sorry) is able to use the light pen; it's certainly not extremly well programmed (I was young at that time :), but it gives an idea of the possible achivements.
1- RUNNING THE LIGHT PEN WITH EUPHORIC
Let's see first what Euphoric's doc says:
"To use the light pen, simply specify the line LightPen=Yes in the INI file. The light pen is simulated by the PC mouse, and a small grey marker appears at the position of the light pen on the screen. But do not forget that the pen must touch the screen to point to a zone: this action is replaced by pressing the mouse button. Also don't forget that the pen can only work on light areas of the screen, so don't try to select a black zone... You must have a mouse driver working before you start Euphoric, otherwise the grey marker won't move."
It is necessary to pay attention to several things. First of all, if you are under Windows 95, the chances are that you need a mouse driver under DOS, as for many games by the way. To check if your mouse runs under DOS, launch EDIT for example, and see if you move a pointer with the mouse... If not, install a driver. You'll find some on the Internet, then, generally, all you have to do is to add 1 line in your AUTOEXEC.BAT filr, like: LH C:\DOS\MOUSE\mscmouse.com, simply describing the name of the driver and its installation path.
Then, edit the EUPHORIC.INI file. As described, at the line LightPen =, put yes. And check the line SerialPort =... If the serial port is defined to use COM1, and that your mouse was also configured in COM1 (it is most of the time), there will be a conflict problem. So you'd rather put rather SerialPort=com2 or SerialPort=none.
Back to menu
2- EXAMPLE: HOW TO REPLACE A GET A$
Here a first example of subroutine BASIC, which waits until the user strikes a key or points the screen with the pencil. Usually, one uses a GET or equivalent... Well with this routine, just do a GOSUB14020.
14020 REM PRESS A KEY OR LIGHTPEN(A$)
14022 A=PEEK(992):B=PEEK(993)
14024 A$=KEY$:IF A<>PEEK(992) OR B<>PEEK(993) OR A$<>"" THEN RETURN
14026 GOTO14024
Explanations: this routine loops, waiting for an event: any key pressed or a pointing. First, the key: no surprise, A$=KEY$ initializes A$ to empty, therefore with " ". As soon as A$ is not empty anymore, the loop ends.
For the pencil, it's a little bit more complicated. I considered that one points as soon as the co-ordinates in memory (992 and 993) change. Inevitably, if they changed, it's because the user pointed somewhere. The only weak point of this method would be the case where the user would point exactly at the same place than before, but believe me it's really unlikely, especially on a real Oric. It's necessary to memorize the values in (992) and (993), that I put here in A and B, and to permanently compare them with the current values in (992) and (993). As soon as one of them (at least) changes, the loop ends.
Back to menu
3- SMALL TRAP: ODD COORDINATES
You undoubtedly saw it on the screen picture, the values of PEEK(992) and PEEK(993) memorize the coordinates of the place where you pointed the pencil. But these coordinates are rather curious; for example the point (0;0) is at the intersection of the two red lines. In other words, the pencil coordiantes don't corrsepond to the usual co-ordinates of the HIRES mode: all is shifted. It's a delicate problem when the user points in a particular zone which is crossed by these "red axes". You will have to make additional tests. For example, here a test which checks if the user clicked on the icon in reversed video, or on the sentence "A- Voir les jeux", which both are crossed by the vertical axis:
14100 REM ### CHOIX ICONES ###
14105 A=PEEK(992):B=PEEK(993)
14110 A$=KEY$:IF A<>PEEK(992) OR B<>PEEK(993) OR A$<>"" THEN 14120 ELSE 14110
14119 REM ### CHOIX JEUX ###
14120 IFA$="A" OR A$="B" OR A$="C" OR A$="D" THEN RETURN
14122 IFA$<>"" THEN 14110
14124 A=PEEK(992):B=PEEK(993)
14125 IF B>172 AND B<229 AND A>239 THEN 14500
14130 IF B>172 AND B<229 AND A<27 THEN 14500
14135 IF B>70 AND B<79 AND A>243 AND A<255 THEN 14500
14136 IF B>70 AND B<79 AND A>0 AND A<119 THEN 14500
14500 A$="A":RETURN
The test for the pencil is made in lines 14125 to 14136. The icon and the sentence are tested, and as you can see it, it is necessary to make a test for the values of A (X-coordinate) higher than 0, and for those " lower ", i.e. going up to 255... It is not very clear but I recommend the practice, you'll understand much better!
Here we are, I hope you'll be curious to use this extension which finally is very close to a mouse (with 1 button)...
To be followed, probably...
For any comment or question, contact me: Simon, symoonmyself@hotmail.com