Home » CEEFAX disks » telesoftware12.adl » 13-01-89/T\PEN00
13-01-89/T\PEN00
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware12.adl |
Filename: | 13-01-89/T\PEN00 |
Read OK: | ✔ |
File size: | 2C6A bytes |
Load address: | 000D |
Exec address: | 0000 |
File contents
Using a light pen with the BBC microcomputer - by - Gordon Horsington --------------------------------------------------------------------- Module 0. Introduction ---------------------- Light pens can be used with the BBC B, BBC B+ and Master 128 computers. This module introduces a block of six modules which deal with the design of both the hardware and software needed to use a light pen with a BBC microcomputer. The six modules are in files named T/PEN00 to T/PEN05. The following topics will be covered in these modules. Module 0. This module. Designing and testing a light pen. Programs: PENTEST, RHBOOT Module 1. Introduction to light pen software. Program: OFFSET Module 2. Light pen interrupts. Program: IOINTER Module 3. Tube compatible, interrupt driven, scrolling light pen software. Program: SPINTER Module 4. Using a light pen for graphics input. Program: GRAPHIC Module 5. Sideways RAM light pen drivers. Programs: SWTEXT, SWGRAPH, ARTIST The later modules develop the ideas and techniques described in the earlier modules and for this reason they need to be worked through from beginning to end rather than used as a reference guide. It is essential to have either BASIC 2 or BASIC 4 and operating system 1.20 (or higher) installed in your computer. Light pen design ---------------- A light pen generates a TTL pulse called a video strobe pulse (VSP) and the timing of this pulse corresponds with the position of the pen on the screen. The screen position at the falling edge of the VSP is latched into the 14 bit light pen register of the 6845 CRTC in the computer. The Acorn approved light pen uses a push tip micro switch to signal to the computer when the tip of the pen is touching the video monitor screen. The switch is connected the right fire button input (PB1 of the analogue port connector) and is normally closed. This means that when the pen is touching the screen then ADVAL(0)AND3=0, and when the pen is not pressed against the screen ADVAL(0)AND3=2. Using a normally closed switch is quite a good idea because software written for the Acorn approved design light pen can be used with a pen which does not have a switch without modifying the software. If you decide to make your own light pen try to incorporate a normally closed switch across pin 3 (0 Volts) and pin 10 (PB1, also known as IO1) of the analogue port connector. Only one design of light pen has been officially approved by Acorn for use with the BBC micro. This is the RH Electronics Colour Light Pen. If you choose to construct your own pen it is not necessary to copy the quite complicated RH design but, if you use the very simple design described in this module, you can make a pen that is compatible with software written for the Acorn approved instrument. The techniques and software described in the light pen modules can be used without modification on any RH compatible light pen but they can be adapted for use with almost any other type of BBC light pen. The light sensitive device used to construct a light pen should be a Honeywell sweet spot Schmitt reciever, or a compatible device. These can be bought from RS Components stockists, part number 303-292. The sweet spot has a built in lens and amplifier and it is suitable for direct connection to the BBC micro. Do not use a pin photo diode which will need an external amplifier if it is to be connected to a BBC computer. The connections to the analogue port for both the sweet spot and the normally closed switch are shown in figure 1. Pin 1 of the sweet spot is nearest the tag and pin 3 is furthest away. The 15 pin D connector required for the analogue port can also be obtained from RS Components stockists. Maplin also supply a new, easy to connect, 15 pin D conector. normally closed switch +---------------------------+ +------- pin 3 of sweet spot (0 Volts) | | | | 8 7 6 5 4 3 2 1 -- pin 1 of sweet spot (+5 Volts) \ | 15 14 13 12 11 10 9 ---- pin 2 of sweet spot (output) | | +----------------------------+ Figure 1. View into the analogue port showing light pen connections ------------------------------------------------------------------- The body of the pen can be any suitable tube which allows the light sensor to be glued into one end. Constructing a press switch operated by touching the screen would be quite tricky and probably the best substitute is to attach a finger operated switch to the side of the pen barrel. It is not essential to have a light pen switch, the space bar or any other keyboard switch can be just as effective. It is a good idea to construct a light shade from an opaque pen cap with a hole cut into its sharp end. This can be placed over the photo sensor when the pen is being used and will improve the resolution of the light pen quite dramaticly. It will cost about `14 to construct a light pen. You can buy ready made BBC light pens for about `20 and you might think that it is hardly worth the trouble of making one yourself. If you do not have any experience of soldering components or feel unsure about the connections to be made then do not attempt to make a light pen yourself. If you buy a pen then try to get one with a normally closed switch on PB1 (IO1). If you buy the rather expensive RH Electronics light pen then you will need to use the program RHBOOT to generate a !BOOT file which must be used to initialise the pen before using any of the software described in this series. Cassette users with an RH light pen should *RUN $.!BOOT before using the pen. Disc users with an RH light pen just need to press Shift+Break as normal with $.!BOOT files. The program RHBOOT is not needed with any other light pen. 10 REM> RHBOOT 20 REM use to create an RH light pen !BOOT file 30 DIM mcode &100 40 firstbyte=&2F00 50 drb=&FE40 60 ddrb=&FE42 70 pcr=&FE4C 80 ifr=&FE4D 90 ier=&FE4E 100 oswrch=&FFEE 110 FOR pass=4 TO 6 STEP 2 120 O%=mcode 130 P%=firstbyte 140 [ OPT pass 150 EQUW &FF0D 160 .start 170 LDA drb 180 AND #&20 \ %00100000 190 BEQ return 200 SEI 210 LDA #&08 \ %00001000 220 STA ifr 230 STA ier 240 LDA pcr 250 AND #&7F \ %01111111 260 ORA #&60 \ %01100000 270 STA pcr 280 LDA ddrb 290 AND #&CF \ %11001111 300 STA ddrb 310 LDA ddrb 320 ORA #&30 \ %00110000 330 STA ddrb 340 LDX #&06 350 .delay1 360 DEX 370 BNE delay1 380 LDA ddrb 390 AND #&EF \ %11101111 400 STA ddrb 410 LDX #&64 420 .delay2 430 DEX 440 BNE delay2 450 LDY #&08 460 LDA #&93 \ %10010011 470 .mainloop 480 ASL A 490 PHA 500 LDA ddrb 510 BCS carryset 520 ORA #&20 \ %00100000 530 BNE notzero 540 .carryset 550 AND #&DF \ %11011111 560 .notzero 570 STA ddrb 580 LDA ddrb 590 ORA #&10 \ %00010000 600 STA ddrb 610 AND #&EF \ %11101111 620 STA ddrb 630 LDX #&32 640 .delay3 650 DEX 660 BNE delay3 670 PLA 680 DEY 690 BNE mainloop 700 CLI 710 LDA drb 720 AND #&20 \ %00100000 730 BNE return 740 LDX #&00 750 .print 760 LDA message,X 770 BEQ return 780 JSR oswrch 790 INX 800 BNE print 810 .return 820 RTS 830 .message 840 EQUS "Press <BREAK> to initialise light pen" 850 EQUD &000A0A0D 860 .lastbyte 870 ] 880 NEXT 890 *OPT1,2 900 OSCLI("SAVE $.!BOOT "+STR$~(mcode)+"+"+STR$~(lastbyte-firstbyte) +" "+STR$~(&FFFF0000 OR start)+" "+STR$~(&FFFF0000 OR firstbyte)) 910 *OPT0,0 920 *OPT4,2 In theory, it should be possible to connect a light pen to a Master Compact computer using the joystick port. The light pen strobe and the User Port CB2 handshake line appear to share the same pin on the joystick connector. The User Port data lines PB0 to PB4 and CB1 are also available on the joystick connector so that a light pen switch could be connected. I have not used a light pen with a Compact computer and, if a light pen does work on this machine, the software described in this series will have to be modified to operate on the User Port rather than the system VIA. Testing your light pen ---------------------- If you have built your own light pen you will need to test it before going on to consider the design of light pen driver software. The light pen will produce a positive going TTL pulse whenever the sensor picks up light given out by the monitor screen. When the light pen strobe falls back from logic 1 to logic 0 a number which corresponds with the light pen position will be stored in registers 16 and 17 of the 6845 CRTC. Light pens are not sensitive to black because light is not given out by the screen where black is displayed. Some photo sensors are not sensitive to the red light given out by some monitor screens. This is because red is at the low energy end of the visible spectrum of light and can be below the energy threshold of the photo sensor. To test the light pen it is best to flood the screen with blue light and examine the contents of registers 16 and 17 of the CRTC as the pen is moved around the screen. The 6845 CRTC is mapped onto sheila addresses &FE00 and FE01. The 14 bit light pen register is in register 16 (high byte) and register 17 (low byte) of the 6845. In order to gain access to any of the 6845 CRTC registers, the register address must first be written into &FE00, the address register. After writing a 5 bit address into the address register, the selected CRTC register may be written to or read from &FE01, the data register. For example, to read the contents of CRTC register 17 you have to first select the register with ?&FE00=17 or *FX151,0,17. The contents of register 17 can then be read either directly from &FE01 or indirectly with Osbyte 150, X=1. The contents of the CRTC registers 16 and 17 are examined in the program PENTEST using Osbyte 151 (write to Sheila) and Osbyte 150 (read from Sheila). Connect your light pen to the analogue port and chain the program PENTEST. Before you point a light pen at the screen notice that the light pen register contains zero. Move the light pen around the screen and, if all is well, you will see the contents of the light pen register changing and hear a sound with every change. PENTEST does not use a light pen switch and works with all light pens. 10 REM> PENTEST 20 ONERROR VDU23,1,1;0;0;0;:END 30 MODE4 40 VDU23,1,0;0;0;0; 50 VDU19,0,4;0; 60 A%=150 70 X%=1 80 REPEAT 90 *FX151,0,17 100 R%=(USR(&FFF4)AND&FF0000)DIV&10000 110 *FX151,0,16 120 S%=(USR(&FFF4)AND&FF0000)DIV&10000 130 PRINTTAB(12,14)"Low byte = &";~R%;" " 140 PRINTTAB(12,16)"High byte= &";~S%;" " 150 IF R%<>T% SOUND 1,-10,100,1 160 IF S%<>U% SOUND 1,-10,50,1 170 T%=R% 180 U%=S% 190 UNTIL FALSE
00000000 55 73 69 6e 67 20 61 20 6c 69 67 68 74 20 70 65 |Using a light pe| 00000010 6e 20 77 69 74 68 20 74 68 65 20 42 42 43 20 6d |n with the BBC m| 00000020 69 63 72 6f 63 6f 6d 70 75 74 65 72 20 2d 20 62 |icrocomputer - b| 00000030 79 20 2d 20 47 6f 72 64 6f 6e 20 48 6f 72 73 69 |y - Gordon Horsi| 00000040 6e 67 74 6f 6e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |ngton.----------| 00000050 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000080 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 4d 6f 64 |-----------..Mod| 00000090 75 6c 65 20 30 2e 20 49 6e 74 72 6f 64 75 63 74 |ule 0. Introduct| 000000a0 69 6f 6e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |ion.------------| 000000b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 4c 69 67 68 |----------..Ligh| 000000c0 74 20 70 65 6e 73 20 63 61 6e 20 62 65 20 75 73 |t pens can be us| 000000d0 65 64 20 77 69 74 68 20 74 68 65 20 42 42 43 20 |ed with the BBC | 000000e0 42 2c 20 42 42 43 20 42 2b 20 61 6e 64 20 4d 61 |B, BBC B+ and Ma| 000000f0 73 74 65 72 20 31 32 38 20 63 6f 6d 70 75 74 65 |ster 128 compute| 00000100 72 73 2e 0d 54 68 69 73 20 6d 6f 64 75 6c 65 20 |rs..This module | 00000110 69 6e 74 72 6f 64 75 63 65 73 20 61 20 62 6c 6f |introduces a blo| 00000120 63 6b 20 6f 66 20 73 69 78 20 6d 6f 64 75 6c 65 |ck of six module| 00000130 73 20 77 68 69 63 68 20 64 65 61 6c 20 77 69 74 |s which deal wit| 00000140 68 20 74 68 65 20 64 65 73 69 67 6e 0d 6f 66 20 |h the design.of | 00000150 62 6f 74 68 20 74 68 65 20 68 61 72 64 77 61 72 |both the hardwar| 00000160 65 20 61 6e 64 20 73 6f 66 74 77 61 72 65 20 6e |e and software n| 00000170 65 65 64 65 64 20 74 6f 20 75 73 65 20 61 20 6c |eeded to use a l| 00000180 69 67 68 74 20 70 65 6e 20 77 69 74 68 20 61 20 |ight pen with a | 00000190 42 42 43 0d 6d 69 63 72 6f 63 6f 6d 70 75 74 65 |BBC.microcompute| 000001a0 72 2e 0d 0d 54 68 65 20 73 69 78 20 6d 6f 64 75 |r...The six modu| 000001b0 6c 65 73 20 61 72 65 20 69 6e 20 66 69 6c 65 73 |les are in files| 000001c0 20 6e 61 6d 65 64 20 54 2f 50 45 4e 30 30 20 74 | named T/PEN00 t| 000001d0 6f 20 54 2f 50 45 4e 30 35 2e 20 54 68 65 20 66 |o T/PEN05. The f| 000001e0 6f 6c 6c 6f 77 69 6e 67 0d 74 6f 70 69 63 73 20 |ollowing.topics | 000001f0 77 69 6c 6c 20 62 65 20 63 6f 76 65 72 65 64 20 |will be covered | 00000200 69 6e 20 74 68 65 73 65 20 6d 6f 64 75 6c 65 73 |in these modules| 00000210 2e 0d 0d 0d 4d 6f 64 75 6c 65 20 30 2e 20 54 68 |....Module 0. Th| 00000220 69 73 20 6d 6f 64 75 6c 65 2e 20 44 65 73 69 67 |is module. Desig| 00000230 6e 69 6e 67 20 61 6e 64 20 74 65 73 74 69 6e 67 |ning and testing| 00000240 20 61 20 6c 69 67 68 74 20 70 65 6e 2e 0d 20 20 | a light pen.. | 00000250 20 20 20 20 20 20 20 20 50 72 6f 67 72 61 6d 73 | Programs| 00000260 3a 20 50 45 4e 54 45 53 54 2c 20 52 48 42 4f 4f |: PENTEST, RHBOO| 00000270 54 0d 0d 4d 6f 64 75 6c 65 20 31 2e 20 49 6e 74 |T..Module 1. Int| 00000280 72 6f 64 75 63 74 69 6f 6e 20 74 6f 20 6c 69 67 |roduction to lig| 00000290 68 74 20 70 65 6e 20 73 6f 66 74 77 61 72 65 2e |ht pen software.| 000002a0 0d 20 20 20 20 20 20 20 20 20 20 50 72 6f 67 72 |. Progr| 000002b0 61 6d 3a 20 4f 46 46 53 45 54 0d 0d 4d 6f 64 75 |am: OFFSET..Modu| 000002c0 6c 65 20 32 2e 20 4c 69 67 68 74 20 70 65 6e 20 |le 2. Light pen | 000002d0 69 6e 74 65 72 72 75 70 74 73 2e 0d 20 20 20 20 |interrupts.. | 000002e0 20 20 20 20 20 20 50 72 6f 67 72 61 6d 3a 20 49 | Program: I| 000002f0 4f 49 4e 54 45 52 0d 0d 4d 6f 64 75 6c 65 20 33 |OINTER..Module 3| 00000300 2e 20 54 75 62 65 20 63 6f 6d 70 61 74 69 62 6c |. Tube compatibl| 00000310 65 2c 20 69 6e 74 65 72 72 75 70 74 20 64 72 69 |e, interrupt dri| 00000320 76 65 6e 2c 20 73 63 72 6f 6c 6c 69 6e 67 20 6c |ven, scrolling l| 00000330 69 67 68 74 20 70 65 6e 20 73 6f 66 74 77 61 72 |ight pen softwar| 00000340 65 2e 0d 20 20 20 20 20 20 20 20 20 20 50 72 6f |e.. Pro| 00000350 67 72 61 6d 3a 20 53 50 49 4e 54 45 52 0d 0d 4d |gram: SPINTER..M| 00000360 6f 64 75 6c 65 20 34 2e 20 55 73 69 6e 67 20 61 |odule 4. Using a| 00000370 20 6c 69 67 68 74 20 70 65 6e 20 66 6f 72 20 67 | light pen for g| 00000380 72 61 70 68 69 63 73 20 69 6e 70 75 74 2e 0d 20 |raphics input.. | 00000390 20 20 20 20 20 20 20 20 20 50 72 6f 67 72 61 6d | Program| 000003a0 3a 20 47 52 41 50 48 49 43 0d 0d 4d 6f 64 75 6c |: GRAPHIC..Modul| 000003b0 65 20 35 2e 20 53 69 64 65 77 61 79 73 20 52 41 |e 5. Sideways RA| 000003c0 4d 20 6c 69 67 68 74 20 70 65 6e 20 64 72 69 76 |M light pen driv| 000003d0 65 72 73 2e 0d 20 20 20 20 20 20 20 20 20 20 50 |ers.. P| 000003e0 72 6f 67 72 61 6d 73 3a 20 53 57 54 45 58 54 2c |rograms: SWTEXT,| 000003f0 20 53 57 47 52 41 50 48 2c 20 41 52 54 49 53 54 | SWGRAPH, ARTIST| 00000400 0d 0d 0d 54 68 65 20 6c 61 74 65 72 20 6d 6f 64 |...The later mod| 00000410 75 6c 65 73 20 64 65 76 65 6c 6f 70 20 74 68 65 |ules develop the| 00000420 20 69 64 65 61 73 20 61 6e 64 20 74 65 63 68 6e | ideas and techn| 00000430 69 71 75 65 73 20 64 65 73 63 72 69 62 65 64 20 |iques described | 00000440 69 6e 20 74 68 65 0d 65 61 72 6c 69 65 72 20 6d |in the.earlier m| 00000450 6f 64 75 6c 65 73 20 61 6e 64 20 66 6f 72 20 74 |odules and for t| 00000460 68 69 73 20 72 65 61 73 6f 6e 20 74 68 65 79 20 |his reason they | 00000470 6e 65 65 64 20 74 6f 20 62 65 20 77 6f 72 6b 65 |need to be worke| 00000480 64 20 74 68 72 6f 75 67 68 20 66 72 6f 6d 0d 62 |d through from.b| 00000490 65 67 69 6e 6e 69 6e 67 20 74 6f 20 65 6e 64 20 |eginning to end | 000004a0 72 61 74 68 65 72 20 74 68 61 6e 20 75 73 65 64 |rather than used| 000004b0 20 61 73 20 61 20 72 65 66 65 72 65 6e 63 65 20 | as a reference | 000004c0 67 75 69 64 65 2e 20 49 74 20 69 73 20 65 73 73 |guide. It is ess| 000004d0 65 6e 74 69 61 6c 20 74 6f 0d 68 61 76 65 20 65 |ential to.have e| 000004e0 69 74 68 65 72 20 42 41 53 49 43 20 32 20 6f 72 |ither BASIC 2 or| 000004f0 20 42 41 53 49 43 20 34 20 61 6e 64 20 6f 70 65 | BASIC 4 and ope| 00000500 72 61 74 69 6e 67 20 73 79 73 74 65 6d 20 31 2e |rating system 1.| 00000510 32 30 20 28 6f 72 20 68 69 67 68 65 72 29 0d 69 |20 (or higher).i| 00000520 6e 73 74 61 6c 6c 65 64 20 69 6e 20 79 6f 75 72 |nstalled in your| 00000530 20 63 6f 6d 70 75 74 65 72 2e 0d 0d 0d 4c 69 67 | computer....Lig| 00000540 68 74 20 70 65 6e 20 64 65 73 69 67 6e 0d 2d 2d |ht pen design.--| 00000550 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d |--------------..| 00000560 41 20 6c 69 67 68 74 20 70 65 6e 20 67 65 6e 65 |A light pen gene| 00000570 72 61 74 65 73 20 61 20 54 54 4c 20 70 75 6c 73 |rates a TTL puls| 00000580 65 20 63 61 6c 6c 65 64 20 61 20 76 69 64 65 6f |e called a video| 00000590 20 73 74 72 6f 62 65 20 70 75 6c 73 65 20 28 56 | strobe pulse (V| 000005a0 53 50 29 20 61 6e 64 0d 74 68 65 20 74 69 6d 69 |SP) and.the timi| 000005b0 6e 67 20 6f 66 20 74 68 69 73 20 70 75 6c 73 65 |ng of this pulse| 000005c0 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 77 69 74 | corresponds wit| 000005d0 68 20 74 68 65 20 70 6f 73 69 74 69 6f 6e 20 6f |h the position o| 000005e0 66 20 74 68 65 20 70 65 6e 20 6f 6e 20 74 68 65 |f the pen on the| 000005f0 0d 73 63 72 65 65 6e 2e 20 54 68 65 20 73 63 72 |.screen. The scr| 00000600 65 65 6e 20 70 6f 73 69 74 69 6f 6e 20 61 74 20 |een position at | 00000610 74 68 65 20 66 61 6c 6c 69 6e 67 20 65 64 67 65 |the falling edge| 00000620 20 6f 66 20 74 68 65 20 56 53 50 20 69 73 20 6c | of the VSP is l| 00000630 61 74 63 68 65 64 20 69 6e 74 6f 0d 74 68 65 20 |atched into.the | 00000640 31 34 20 62 69 74 20 6c 69 67 68 74 20 70 65 6e |14 bit light pen| 00000650 20 72 65 67 69 73 74 65 72 20 6f 66 20 74 68 65 | register of the| 00000660 20 36 38 34 35 20 43 52 54 43 20 69 6e 20 74 68 | 6845 CRTC in th| 00000670 65 20 63 6f 6d 70 75 74 65 72 2e 20 54 68 65 20 |e computer. The | 00000680 41 63 6f 72 6e 0d 61 70 70 72 6f 76 65 64 20 6c |Acorn.approved l| 00000690 69 67 68 74 20 70 65 6e 20 75 73 65 73 20 61 20 |ight pen uses a | 000006a0 70 75 73 68 20 74 69 70 20 6d 69 63 72 6f 20 73 |push tip micro s| 000006b0 77 69 74 63 68 20 74 6f 20 73 69 67 6e 61 6c 20 |witch to signal | 000006c0 74 6f 20 74 68 65 20 63 6f 6d 70 75 74 65 72 0d |to the computer.| 000006d0 77 68 65 6e 20 74 68 65 20 74 69 70 20 6f 66 20 |when the tip of | 000006e0 74 68 65 20 70 65 6e 20 69 73 20 74 6f 75 63 68 |the pen is touch| 000006f0 69 6e 67 20 74 68 65 20 76 69 64 65 6f 20 6d 6f |ing the video mo| 00000700 6e 69 74 6f 72 20 73 63 72 65 65 6e 2e 20 54 68 |nitor screen. Th| 00000710 65 20 73 77 69 74 63 68 0d 69 73 20 63 6f 6e 6e |e switch.is conn| 00000720 65 63 74 65 64 20 74 68 65 20 72 69 67 68 74 20 |ected the right | 00000730 66 69 72 65 20 62 75 74 74 6f 6e 20 69 6e 70 75 |fire button inpu| 00000740 74 20 28 50 42 31 20 6f 66 20 74 68 65 20 61 6e |t (PB1 of the an| 00000750 61 6c 6f 67 75 65 20 70 6f 72 74 0d 63 6f 6e 6e |alogue port.conn| 00000760 65 63 74 6f 72 29 20 61 6e 64 20 69 73 20 6e 6f |ector) and is no| 00000770 72 6d 61 6c 6c 79 20 63 6c 6f 73 65 64 2e 20 54 |rmally closed. T| 00000780 68 69 73 20 6d 65 61 6e 73 20 74 68 61 74 20 77 |his means that w| 00000790 68 65 6e 20 74 68 65 20 70 65 6e 20 69 73 0d 74 |hen the pen is.t| 000007a0 6f 75 63 68 69 6e 67 20 74 68 65 20 73 63 72 65 |ouching the scre| 000007b0 65 6e 20 74 68 65 6e 20 41 44 56 41 4c 28 30 29 |en then ADVAL(0)| 000007c0 41 4e 44 33 3d 30 2c 20 61 6e 64 20 77 68 65 6e |AND3=0, and when| 000007d0 20 74 68 65 20 70 65 6e 20 69 73 20 6e 6f 74 20 | the pen is not | 000007e0 70 72 65 73 73 65 64 0d 61 67 61 69 6e 73 74 20 |pressed.against | 000007f0 74 68 65 20 73 63 72 65 65 6e 20 41 44 56 41 4c |the screen ADVAL| 00000800 28 30 29 41 4e 44 33 3d 32 2e 20 55 73 69 6e 67 |(0)AND3=2. Using| 00000810 20 61 20 6e 6f 72 6d 61 6c 6c 79 20 63 6c 6f 73 | a normally clos| 00000820 65 64 20 73 77 69 74 63 68 20 69 73 20 71 75 69 |ed switch is qui| 00000830 74 65 0d 61 20 67 6f 6f 64 20 69 64 65 61 20 62 |te.a good idea b| 00000840 65 63 61 75 73 65 20 73 6f 66 74 77 61 72 65 20 |ecause software | 00000850 77 72 69 74 74 65 6e 20 66 6f 72 20 74 68 65 20 |written for the | 00000860 41 63 6f 72 6e 20 61 70 70 72 6f 76 65 64 20 64 |Acorn approved d| 00000870 65 73 69 67 6e 20 6c 69 67 68 74 0d 70 65 6e 20 |esign light.pen | 00000880 63 61 6e 20 62 65 20 75 73 65 64 20 77 69 74 68 |can be used with| 00000890 20 61 20 70 65 6e 20 77 68 69 63 68 20 64 6f 65 | a pen which doe| 000008a0 73 20 6e 6f 74 20 68 61 76 65 20 61 20 73 77 69 |s not have a swi| 000008b0 74 63 68 20 77 69 74 68 6f 75 74 20 6d 6f 64 69 |tch without modi| 000008c0 66 79 69 6e 67 0d 74 68 65 20 73 6f 66 74 77 61 |fying.the softwa| 000008d0 72 65 2e 20 49 66 20 79 6f 75 20 64 65 63 69 64 |re. If you decid| 000008e0 65 20 74 6f 20 6d 61 6b 65 20 79 6f 75 72 20 6f |e to make your o| 000008f0 77 6e 20 6c 69 67 68 74 20 70 65 6e 20 74 72 79 |wn light pen try| 00000900 20 74 6f 20 69 6e 63 6f 72 70 6f 72 61 74 65 0d | to incorporate.| 00000910 61 20 6e 6f 72 6d 61 6c 6c 79 20 63 6c 6f 73 65 |a normally close| 00000920 64 20 73 77 69 74 63 68 20 61 63 72 6f 73 73 20 |d switch across | 00000930 70 69 6e 20 33 20 28 30 20 56 6f 6c 74 73 29 20 |pin 3 (0 Volts) | 00000940 61 6e 64 20 70 69 6e 20 31 30 20 28 50 42 31 2c |and pin 10 (PB1,| 00000950 20 61 6c 73 6f 0d 6b 6e 6f 77 6e 20 61 73 20 49 | also.known as I| 00000960 4f 31 29 20 6f 66 20 74 68 65 20 61 6e 61 6c 6f |O1) of the analo| 00000970 67 75 65 20 70 6f 72 74 20 63 6f 6e 6e 65 63 74 |gue port connect| 00000980 6f 72 2e 0d 0d 4f 6e 6c 79 20 6f 6e 65 20 64 65 |or...Only one de| 00000990 73 69 67 6e 20 6f 66 20 6c 69 67 68 74 20 70 65 |sign of light pe| 000009a0 6e 20 68 61 73 20 62 65 65 6e 20 6f 66 66 69 63 |n has been offic| 000009b0 69 61 6c 6c 79 20 61 70 70 72 6f 76 65 64 20 62 |ially approved b| 000009c0 79 20 41 63 6f 72 6e 20 66 6f 72 20 75 73 65 0d |y Acorn for use.| 000009d0 77 69 74 68 20 74 68 65 20 42 42 43 20 6d 69 63 |with the BBC mic| 000009e0 72 6f 2e 20 54 68 69 73 20 69 73 20 74 68 65 20 |ro. This is the | 000009f0 52 48 20 45 6c 65 63 74 72 6f 6e 69 63 73 20 43 |RH Electronics C| 00000a00 6f 6c 6f 75 72 20 4c 69 67 68 74 20 50 65 6e 2e |olour Light Pen.| 00000a10 20 49 66 20 79 6f 75 0d 63 68 6f 6f 73 65 20 74 | If you.choose t| 00000a20 6f 20 63 6f 6e 73 74 72 75 63 74 20 79 6f 75 72 |o construct your| 00000a30 20 6f 77 6e 20 70 65 6e 20 69 74 20 69 73 20 6e | own pen it is n| 00000a40 6f 74 20 6e 65 63 65 73 73 61 72 79 20 74 6f 20 |ot necessary to | 00000a50 63 6f 70 79 20 74 68 65 20 71 75 69 74 65 0d 63 |copy the quite.c| 00000a60 6f 6d 70 6c 69 63 61 74 65 64 20 52 48 20 64 65 |omplicated RH de| 00000a70 73 69 67 6e 20 62 75 74 2c 20 69 66 20 79 6f 75 |sign but, if you| 00000a80 20 75 73 65 20 74 68 65 20 76 65 72 79 20 73 69 | use the very si| 00000a90 6d 70 6c 65 20 64 65 73 69 67 6e 20 64 65 73 63 |mple design desc| 00000aa0 72 69 62 65 64 20 69 6e 0d 74 68 69 73 20 6d 6f |ribed in.this mo| 00000ab0 64 75 6c 65 2c 20 79 6f 75 20 63 61 6e 20 6d 61 |dule, you can ma| 00000ac0 6b 65 20 61 20 70 65 6e 20 74 68 61 74 20 69 73 |ke a pen that is| 00000ad0 20 63 6f 6d 70 61 74 69 62 6c 65 20 77 69 74 68 | compatible with| 00000ae0 20 73 6f 66 74 77 61 72 65 20 77 72 69 74 74 65 | software writte| 00000af0 6e 0d 66 6f 72 20 74 68 65 20 41 63 6f 72 6e 20 |n.for the Acorn | 00000b00 61 70 70 72 6f 76 65 64 20 69 6e 73 74 72 75 6d |approved instrum| 00000b10 65 6e 74 2e 20 54 68 65 20 74 65 63 68 6e 69 71 |ent. The techniq| 00000b20 75 65 73 20 61 6e 64 20 73 6f 66 74 77 61 72 65 |ues and software| 00000b30 20 64 65 73 63 72 69 62 65 64 0d 69 6e 20 74 68 | described.in th| 00000b40 65 20 6c 69 67 68 74 20 70 65 6e 20 6d 6f 64 75 |e light pen modu| 00000b50 6c 65 73 20 63 61 6e 20 62 65 20 75 73 65 64 20 |les can be used | 00000b60 77 69 74 68 6f 75 74 20 6d 6f 64 69 66 69 63 61 |without modifica| 00000b70 74 69 6f 6e 20 6f 6e 20 61 6e 79 20 52 48 0d 63 |tion on any RH.c| 00000b80 6f 6d 70 61 74 69 62 6c 65 20 6c 69 67 68 74 20 |ompatible light | 00000b90 70 65 6e 20 62 75 74 20 74 68 65 79 20 63 61 6e |pen but they can| 00000ba0 20 62 65 20 61 64 61 70 74 65 64 20 66 6f 72 20 | be adapted for | 00000bb0 75 73 65 20 77 69 74 68 20 61 6c 6d 6f 73 74 20 |use with almost | 00000bc0 61 6e 79 20 6f 74 68 65 72 0d 74 79 70 65 20 6f |any other.type o| 00000bd0 66 20 42 42 43 20 6c 69 67 68 74 20 70 65 6e 2e |f BBC light pen.| 00000be0 0d 0d 54 68 65 20 6c 69 67 68 74 20 73 65 6e 73 |..The light sens| 00000bf0 69 74 69 76 65 20 64 65 76 69 63 65 20 75 73 65 |itive device use| 00000c00 64 20 74 6f 20 63 6f 6e 73 74 72 75 63 74 20 61 |d to construct a| 00000c10 20 6c 69 67 68 74 20 70 65 6e 20 73 68 6f 75 6c | light pen shoul| 00000c20 64 20 62 65 20 61 0d 48 6f 6e 65 79 77 65 6c 6c |d be a.Honeywell| 00000c30 20 73 77 65 65 74 20 73 70 6f 74 20 53 63 68 6d | sweet spot Schm| 00000c40 69 74 74 20 72 65 63 69 65 76 65 72 2c 20 6f 72 |itt reciever, or| 00000c50 20 61 20 63 6f 6d 70 61 74 69 62 6c 65 20 64 65 | a compatible de| 00000c60 76 69 63 65 2e 20 54 68 65 73 65 20 63 61 6e 0d |vice. These can.| 00000c70 62 65 20 62 6f 75 67 68 74 20 66 72 6f 6d 20 52 |be bought from R| 00000c80 53 20 43 6f 6d 70 6f 6e 65 6e 74 73 20 73 74 6f |S Components sto| 00000c90 63 6b 69 73 74 73 2c 20 70 61 72 74 20 6e 75 6d |ckists, part num| 00000ca0 62 65 72 20 33 30 33 2d 32 39 32 2e 20 54 68 65 |ber 303-292. The| 00000cb0 20 73 77 65 65 74 0d 73 70 6f 74 20 68 61 73 20 | sweet.spot has | 00000cc0 61 20 62 75 69 6c 74 20 69 6e 20 6c 65 6e 73 20 |a built in lens | 00000cd0 61 6e 64 20 61 6d 70 6c 69 66 69 65 72 20 61 6e |and amplifier an| 00000ce0 64 20 69 74 20 69 73 20 73 75 69 74 61 62 6c 65 |d it is suitable| 00000cf0 20 66 6f 72 20 64 69 72 65 63 74 0d 63 6f 6e 6e | for direct.conn| 00000d00 65 63 74 69 6f 6e 20 74 6f 20 74 68 65 20 42 42 |ection to the BB| 00000d10 43 20 6d 69 63 72 6f 2e 20 44 6f 20 6e 6f 74 20 |C micro. Do not | 00000d20 75 73 65 20 61 20 70 69 6e 20 70 68 6f 74 6f 20 |use a pin photo | 00000d30 64 69 6f 64 65 20 77 68 69 63 68 20 77 69 6c 6c |diode which will| 00000d40 20 6e 65 65 64 0d 61 6e 20 65 78 74 65 72 6e 61 | need.an externa| 00000d50 6c 20 61 6d 70 6c 69 66 69 65 72 20 69 66 20 69 |l amplifier if i| 00000d60 74 20 69 73 20 74 6f 20 62 65 20 63 6f 6e 6e 65 |t is to be conne| 00000d70 63 74 65 64 20 74 6f 20 61 20 42 42 43 20 63 6f |cted to a BBC co| 00000d80 6d 70 75 74 65 72 2e 20 54 68 65 0d 63 6f 6e 6e |mputer. The.conn| 00000d90 65 63 74 69 6f 6e 73 20 74 6f 20 74 68 65 20 61 |ections to the a| 00000da0 6e 61 6c 6f 67 75 65 20 70 6f 72 74 20 66 6f 72 |nalogue port for| 00000db0 20 62 6f 74 68 20 74 68 65 20 73 77 65 65 74 20 | both the sweet | 00000dc0 73 70 6f 74 20 61 6e 64 20 74 68 65 20 6e 6f 72 |spot and the nor| 00000dd0 6d 61 6c 6c 79 0d 63 6c 6f 73 65 64 20 73 77 69 |mally.closed swi| 00000de0 74 63 68 20 61 72 65 20 73 68 6f 77 6e 20 69 6e |tch are shown in| 00000df0 20 66 69 67 75 72 65 20 31 2e 20 50 69 6e 20 31 | figure 1. Pin 1| 00000e00 20 6f 66 20 74 68 65 20 73 77 65 65 74 20 73 70 | of the sweet sp| 00000e10 6f 74 20 69 73 20 6e 65 61 72 65 73 74 0d 74 68 |ot is nearest.th| 00000e20 65 20 74 61 67 20 61 6e 64 20 70 69 6e 20 33 20 |e tag and pin 3 | 00000e30 69 73 20 66 75 72 74 68 65 73 74 20 61 77 61 79 |is furthest away| 00000e40 2e 20 54 68 65 20 31 35 20 70 69 6e 20 44 20 63 |. The 15 pin D c| 00000e50 6f 6e 6e 65 63 74 6f 72 20 72 65 71 75 69 72 65 |onnector require| 00000e60 64 20 66 6f 72 0d 74 68 65 20 61 6e 61 6c 6f 67 |d for.the analog| 00000e70 75 65 20 70 6f 72 74 20 63 61 6e 20 61 6c 73 6f |ue port can also| 00000e80 20 62 65 20 6f 62 74 61 69 6e 65 64 20 66 72 6f | be obtained fro| 00000e90 6d 20 52 53 20 43 6f 6d 70 6f 6e 65 6e 74 73 20 |m RS Components | 00000ea0 73 74 6f 63 6b 69 73 74 73 2e 0d 4d 61 70 6c 69 |stockists..Mapli| 00000eb0 6e 20 61 6c 73 6f 20 73 75 70 70 6c 79 20 61 20 |n also supply a | 00000ec0 6e 65 77 2c 20 65 61 73 79 20 74 6f 20 63 6f 6e |new, easy to con| 00000ed0 6e 65 63 74 2c 20 31 35 20 70 69 6e 20 44 20 63 |nect, 15 pin D c| 00000ee0 6f 6e 65 63 74 6f 72 2e 0d 0d 0d 6e 6f 72 6d 61 |onector....norma| 00000ef0 6c 6c 79 0d 63 6c 6f 73 65 64 20 73 77 69 74 63 |lly.closed switc| 00000f00 68 0d 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |h. +----------| 00000f10 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000f20 2d 2b 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 20 70 69 |-+ +------- pi| 00000f30 6e 20 33 20 6f 66 20 73 77 65 65 74 20 73 70 6f |n 3 of sweet spo| 00000f40 74 20 28 30 20 56 6f 6c 74 73 29 0d 20 20 20 7c |t (0 Volts). || 00000f50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000f60 20 20 20 20 20 20 20 20 20 20 20 7c 20 20 20 7c | | || 00000f70 0d 20 20 20 7c 20 20 20 20 20 20 20 38 20 20 20 |. | 8 | 00000f80 37 20 20 20 36 20 20 20 35 20 20 20 34 20 20 20 |7 6 5 4 | 00000f90 33 20 20 20 32 20 20 20 31 20 2d 2d 20 70 69 6e |3 2 1 -- pin| 00000fa0 20 31 20 6f 66 20 73 77 65 65 74 20 73 70 6f 74 | 1 of sweet spot| 00000fb0 20 28 2b 35 20 56 6f 6c 74 73 29 0d 20 20 5c 0d | (+5 Volts). \.| 00000fc0 20 20 20 7c 20 20 20 20 20 20 20 20 31 35 20 20 | | 15 | 00000fd0 31 34 20 20 31 33 20 20 31 32 20 20 31 31 20 20 |14 13 12 11 | 00000fe0 31 30 20 20 20 39 20 2d 2d 2d 2d 20 70 69 6e 20 |10 9 ---- pin | 00000ff0 32 20 6f 66 20 73 77 65 65 74 20 73 70 6f 74 20 |2 of sweet spot | 00001000 28 6f 75 74 70 75 74 29 0d 20 20 20 7c 20 20 20 |(output). | | 00001010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00001020 20 20 20 20 20 20 20 20 20 7c 0d 20 20 20 2b 2d | |. +-| 00001030 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001040 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 0d 46 69 |-----------+..Fi| 00001050 67 75 72 65 20 31 2e 20 56 69 65 77 20 69 6e 74 |gure 1. View int| 00001060 6f 20 74 68 65 20 61 6e 61 6c 6f 67 75 65 20 70 |o the analogue p| 00001070 6f 72 74 20 73 68 6f 77 69 6e 67 20 6c 69 67 68 |ort showing ligh| 00001080 74 20 70 65 6e 20 63 6f 6e 6e 65 63 74 69 6f 6e |t pen connection| 00001090 73 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |s.--------------| 000010a0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000010d0 2d 2d 2d 2d 2d 0d 0d 0d 54 68 65 20 62 6f 64 79 |-----...The body| 000010e0 20 6f 66 20 74 68 65 20 70 65 6e 20 63 61 6e 20 | of the pen can | 000010f0 62 65 20 61 6e 79 20 73 75 69 74 61 62 6c 65 20 |be any suitable | 00001100 74 75 62 65 20 77 68 69 63 68 20 61 6c 6c 6f 77 |tube which allow| 00001110 73 20 74 68 65 20 6c 69 67 68 74 20 73 65 6e 73 |s the light sens| 00001120 6f 72 0d 74 6f 20 62 65 20 67 6c 75 65 64 20 69 |or.to be glued i| 00001130 6e 74 6f 20 6f 6e 65 20 65 6e 64 2e 20 43 6f 6e |nto one end. Con| 00001140 73 74 72 75 63 74 69 6e 67 20 61 20 70 72 65 73 |structing a pres| 00001150 73 20 73 77 69 74 63 68 20 6f 70 65 72 61 74 65 |s switch operate| 00001160 64 20 62 79 20 74 6f 75 63 68 69 6e 67 0d 74 68 |d by touching.th| 00001170 65 20 73 63 72 65 65 6e 20 77 6f 75 6c 64 20 62 |e screen would b| 00001180 65 20 71 75 69 74 65 20 74 72 69 63 6b 79 20 61 |e quite tricky a| 00001190 6e 64 20 70 72 6f 62 61 62 6c 79 20 74 68 65 20 |nd probably the | 000011a0 62 65 73 74 20 73 75 62 73 74 69 74 75 74 65 20 |best substitute | 000011b0 69 73 20 74 6f 0d 61 74 74 61 63 68 20 61 20 66 |is to.attach a f| 000011c0 69 6e 67 65 72 20 6f 70 65 72 61 74 65 64 20 73 |inger operated s| 000011d0 77 69 74 63 68 20 74 6f 20 74 68 65 20 73 69 64 |witch to the sid| 000011e0 65 20 6f 66 20 74 68 65 20 70 65 6e 20 62 61 72 |e of the pen bar| 000011f0 72 65 6c 2e 20 49 74 20 69 73 20 6e 6f 74 0d 65 |rel. It is not.e| 00001200 73 73 65 6e 74 69 61 6c 20 74 6f 20 68 61 76 65 |ssential to have| 00001210 20 61 20 6c 69 67 68 74 20 70 65 6e 20 73 77 69 | a light pen swi| 00001220 74 63 68 2c 20 74 68 65 20 73 70 61 63 65 20 62 |tch, the space b| 00001230 61 72 20 6f 72 20 61 6e 79 20 6f 74 68 65 72 20 |ar or any other | 00001240 6b 65 79 62 6f 61 72 64 0d 73 77 69 74 63 68 20 |keyboard.switch | 00001250 63 61 6e 20 62 65 20 6a 75 73 74 20 61 73 20 65 |can be just as e| 00001260 66 66 65 63 74 69 76 65 2e 20 49 74 20 69 73 20 |ffective. It is | 00001270 61 20 67 6f 6f 64 20 69 64 65 61 20 74 6f 20 63 |a good idea to c| 00001280 6f 6e 73 74 72 75 63 74 20 61 20 6c 69 67 68 74 |onstruct a light| 00001290 0d 73 68 61 64 65 20 66 72 6f 6d 20 61 6e 20 6f |.shade from an o| 000012a0 70 61 71 75 65 20 70 65 6e 20 63 61 70 20 77 69 |paque pen cap wi| 000012b0 74 68 20 61 20 68 6f 6c 65 20 63 75 74 20 69 6e |th a hole cut in| 000012c0 74 6f 20 69 74 73 20 73 68 61 72 70 20 65 6e 64 |to its sharp end| 000012d0 2e 20 54 68 69 73 20 63 61 6e 0d 62 65 20 70 6c |. This can.be pl| 000012e0 61 63 65 64 20 6f 76 65 72 20 74 68 65 20 70 68 |aced over the ph| 000012f0 6f 74 6f 20 73 65 6e 73 6f 72 20 77 68 65 6e 20 |oto sensor when | 00001300 74 68 65 20 70 65 6e 20 69 73 20 62 65 69 6e 67 |the pen is being| 00001310 20 75 73 65 64 20 61 6e 64 20 77 69 6c 6c 0d 69 | used and will.i| 00001320 6d 70 72 6f 76 65 20 74 68 65 20 72 65 73 6f 6c |mprove the resol| 00001330 75 74 69 6f 6e 20 6f 66 20 74 68 65 20 6c 69 67 |ution of the lig| 00001340 68 74 20 70 65 6e 20 71 75 69 74 65 20 64 72 61 |ht pen quite dra| 00001350 6d 61 74 69 63 6c 79 2e 0d 0d 49 74 20 77 69 6c |maticly...It wil| 00001360 6c 20 63 6f 73 74 20 61 62 6f 75 74 20 60 31 34 |l cost about `14| 00001370 20 74 6f 20 63 6f 6e 73 74 72 75 63 74 20 61 20 | to construct a | 00001380 6c 69 67 68 74 20 70 65 6e 2e 20 59 6f 75 20 63 |light pen. You c| 00001390 61 6e 20 62 75 79 20 72 65 61 64 79 20 6d 61 64 |an buy ready mad| 000013a0 65 0d 42 42 43 20 6c 69 67 68 74 20 70 65 6e 73 |e.BBC light pens| 000013b0 20 66 6f 72 20 61 62 6f 75 74 20 60 32 30 20 61 | for about `20 a| 000013c0 6e 64 20 79 6f 75 20 6d 69 67 68 74 20 74 68 69 |nd you might thi| 000013d0 6e 6b 20 74 68 61 74 20 69 74 20 69 73 20 68 61 |nk that it is ha| 000013e0 72 64 6c 79 20 77 6f 72 74 68 0d 74 68 65 20 74 |rdly worth.the t| 000013f0 72 6f 75 62 6c 65 20 6f 66 20 6d 61 6b 69 6e 67 |rouble of making| 00001400 20 6f 6e 65 20 79 6f 75 72 73 65 6c 66 2e 20 49 | one yourself. I| 00001410 66 20 79 6f 75 20 64 6f 20 6e 6f 74 20 68 61 76 |f you do not hav| 00001420 65 20 61 6e 79 20 65 78 70 65 72 69 65 6e 63 65 |e any experience| 00001430 20 6f 66 0d 73 6f 6c 64 65 72 69 6e 67 20 63 6f | of.soldering co| 00001440 6d 70 6f 6e 65 6e 74 73 20 6f 72 20 66 65 65 6c |mponents or feel| 00001450 20 75 6e 73 75 72 65 20 61 62 6f 75 74 20 74 68 | unsure about th| 00001460 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 20 74 6f |e connections to| 00001470 20 62 65 20 6d 61 64 65 20 74 68 65 6e 0d 64 6f | be made then.do| 00001480 20 6e 6f 74 20 61 74 74 65 6d 70 74 20 74 6f 20 | not attempt to | 00001490 6d 61 6b 65 20 61 20 6c 69 67 68 74 20 70 65 6e |make a light pen| 000014a0 20 79 6f 75 72 73 65 6c 66 2e 20 49 66 20 79 6f | yourself. If yo| 000014b0 75 20 62 75 79 20 61 20 70 65 6e 20 74 68 65 6e |u buy a pen then| 000014c0 20 74 72 79 20 74 6f 0d 67 65 74 20 6f 6e 65 20 | try to.get one | 000014d0 77 69 74 68 20 61 20 6e 6f 72 6d 61 6c 6c 79 20 |with a normally | 000014e0 63 6c 6f 73 65 64 20 73 77 69 74 63 68 20 6f 6e |closed switch on| 000014f0 20 50 42 31 20 28 49 4f 31 29 2e 0d 0d 49 66 20 | PB1 (IO1)...If | 00001500 79 6f 75 20 62 75 79 20 74 68 65 20 72 61 74 68 |you buy the rath| 00001510 65 72 20 65 78 70 65 6e 73 69 76 65 20 52 48 20 |er expensive RH | 00001520 45 6c 65 63 74 72 6f 6e 69 63 73 20 6c 69 67 68 |Electronics ligh| 00001530 74 20 70 65 6e 20 74 68 65 6e 20 79 6f 75 20 77 |t pen then you w| 00001540 69 6c 6c 0d 6e 65 65 64 20 74 6f 20 75 73 65 20 |ill.need to use | 00001550 74 68 65 20 70 72 6f 67 72 61 6d 20 52 48 42 4f |the program RHBO| 00001560 4f 54 20 74 6f 20 67 65 6e 65 72 61 74 65 20 61 |OT to generate a| 00001570 20 21 42 4f 4f 54 20 66 69 6c 65 20 77 68 69 63 | !BOOT file whic| 00001580 68 20 6d 75 73 74 20 62 65 20 75 73 65 64 0d 74 |h must be used.t| 00001590 6f 20 69 6e 69 74 69 61 6c 69 73 65 20 74 68 65 |o initialise the| 000015a0 20 70 65 6e 20 62 65 66 6f 72 65 20 75 73 69 6e | pen before usin| 000015b0 67 20 61 6e 79 20 6f 66 20 74 68 65 20 73 6f 66 |g any of the sof| 000015c0 74 77 61 72 65 20 64 65 73 63 72 69 62 65 64 20 |tware described | 000015d0 69 6e 20 74 68 69 73 0d 73 65 72 69 65 73 2e 20 |in this.series. | 000015e0 43 61 73 73 65 74 74 65 20 75 73 65 72 73 20 77 |Cassette users w| 000015f0 69 74 68 20 61 6e 20 52 48 20 6c 69 67 68 74 20 |ith an RH light | 00001600 70 65 6e 20 73 68 6f 75 6c 64 20 2a 52 55 4e 20 |pen should *RUN | 00001610 24 2e 21 42 4f 4f 54 20 62 65 66 6f 72 65 0d 75 |$.!BOOT before.u| 00001620 73 69 6e 67 20 74 68 65 20 70 65 6e 2e 20 44 69 |sing the pen. Di| 00001630 73 63 20 75 73 65 72 73 20 77 69 74 68 20 61 6e |sc users with an| 00001640 20 52 48 20 6c 69 67 68 74 20 70 65 6e 20 6a 75 | RH light pen ju| 00001650 73 74 20 6e 65 65 64 20 74 6f 20 70 72 65 73 73 |st need to press| 00001660 0d 53 68 69 66 74 2b 42 72 65 61 6b 20 61 73 20 |.Shift+Break as | 00001670 6e 6f 72 6d 61 6c 20 77 69 74 68 20 24 2e 21 42 |normal with $.!B| 00001680 4f 4f 54 20 66 69 6c 65 73 2e 20 54 68 65 20 70 |OOT files. The p| 00001690 72 6f 67 72 61 6d 20 52 48 42 4f 4f 54 20 69 73 |rogram RHBOOT is| 000016a0 20 6e 6f 74 20 6e 65 65 64 65 64 0d 77 69 74 68 | not needed.with| 000016b0 20 61 6e 79 20 6f 74 68 65 72 20 6c 69 67 68 74 | any other light| 000016c0 20 70 65 6e 2e 0d 0d 0d 20 20 20 31 30 20 52 45 | pen.... 10 RE| 000016d0 4d 3e 20 52 48 42 4f 4f 54 0d 20 20 20 32 30 20 |M> RHBOOT. 20 | 000016e0 52 45 4d 20 75 73 65 20 74 6f 20 63 72 65 61 74 |REM use to creat| 000016f0 65 20 61 6e 20 52 48 20 6c 69 67 68 74 20 70 65 |e an RH light pe| 00001700 6e 20 21 42 4f 4f 54 20 66 69 6c 65 0d 20 20 20 |n !BOOT file. | 00001710 33 30 20 44 49 4d 20 6d 63 6f 64 65 20 26 31 30 |30 DIM mcode &10| 00001720 30 0d 20 20 20 34 30 20 66 69 72 73 74 62 79 74 |0. 40 firstbyt| 00001730 65 3d 26 32 46 30 30 0d 20 20 20 35 30 20 64 72 |e=&2F00. 50 dr| 00001740 62 3d 26 46 45 34 30 0d 20 20 20 36 30 20 64 64 |b=&FE40. 60 dd| 00001750 72 62 3d 26 46 45 34 32 0d 20 20 20 37 30 20 70 |rb=&FE42. 70 p| 00001760 63 72 3d 26 46 45 34 43 0d 20 20 20 38 30 20 69 |cr=&FE4C. 80 i| 00001770 66 72 3d 26 46 45 34 44 0d 20 20 20 39 30 20 69 |fr=&FE4D. 90 i| 00001780 65 72 3d 26 46 45 34 45 0d 20 20 31 30 30 20 6f |er=&FE4E. 100 o| 00001790 73 77 72 63 68 3d 26 46 46 45 45 0d 20 20 31 31 |swrch=&FFEE. 11| 000017a0 30 20 46 4f 52 20 70 61 73 73 3d 34 20 54 4f 20 |0 FOR pass=4 TO | 000017b0 36 20 53 54 45 50 20 32 0d 20 20 31 32 30 20 4f |6 STEP 2. 120 O| 000017c0 25 3d 6d 63 6f 64 65 0d 20 20 31 33 30 20 50 25 |%=mcode. 130 P%| 000017d0 3d 66 69 72 73 74 62 79 74 65 0d 20 20 31 34 30 |=firstbyte. 140| 000017e0 20 5b 20 20 20 20 20 20 20 4f 50 54 20 70 61 73 | [ OPT pas| 000017f0 73 0d 20 20 31 35 30 20 20 20 20 20 20 20 20 20 |s. 150 | 00001800 45 51 55 57 20 26 46 46 30 44 0d 20 20 31 36 30 |EQUW &FF0D. 160| 00001810 20 2e 73 74 61 72 74 0d 20 20 31 37 30 20 20 20 | .start. 170 | 00001820 20 20 20 20 20 20 4c 44 41 20 64 72 62 0d 20 20 | LDA drb. | 00001830 31 38 30 20 20 20 20 20 20 20 20 20 41 4e 44 20 |180 AND | 00001840 23 26 32 30 20 20 20 20 20 20 5c 20 25 30 30 31 |#&20 \ %001| 00001850 30 30 30 30 30 0d 20 20 31 39 30 20 20 20 20 20 |00000. 190 | 00001860 20 20 20 20 42 45 51 20 72 65 74 75 72 6e 0d 20 | BEQ return. | 00001870 20 32 30 30 20 20 20 20 20 20 20 20 20 53 45 49 | 200 SEI| 00001880 0d 20 20 32 31 30 20 20 20 20 20 20 20 20 20 4c |. 210 L| 00001890 44 41 20 23 26 30 38 20 20 20 20 20 20 5c 20 25 |DA #&08 \ %| 000018a0 30 30 30 30 31 30 30 30 0d 20 20 32 32 30 20 20 |00001000. 220 | 000018b0 20 20 20 20 20 20 20 53 54 41 20 69 66 72 0d 20 | STA ifr. | 000018c0 20 32 33 30 20 20 20 20 20 20 20 20 20 53 54 41 | 230 STA| 000018d0 20 69 65 72 0d 20 20 32 34 30 20 20 20 20 20 20 | ier. 240 | 000018e0 20 20 20 4c 44 41 20 70 63 72 0d 20 20 32 35 30 | LDA pcr. 250| 000018f0 20 20 20 20 20 20 20 20 20 41 4e 44 20 23 26 37 | AND #&7| 00001900 46 20 20 20 20 20 20 5c 20 25 30 31 31 31 31 31 |F \ %011111| 00001910 31 31 0d 20 20 32 36 30 20 20 20 20 20 20 20 20 |11. 260 | 00001920 20 4f 52 41 20 23 26 36 30 20 20 20 20 20 20 5c | ORA #&60 \| 00001930 20 25 30 31 31 30 30 30 30 30 0d 20 20 32 37 30 | %01100000. 270| 00001940 20 20 20 20 20 20 20 20 20 53 54 41 20 70 63 72 | STA pcr| 00001950 0d 20 20 32 38 30 20 20 20 20 20 20 20 20 20 4c |. 280 L| 00001960 44 41 20 64 64 72 62 0d 20 20 32 39 30 20 20 20 |DA ddrb. 290 | 00001970 20 20 20 20 20 20 41 4e 44 20 23 26 43 46 20 20 | AND #&CF | 00001980 20 20 20 20 5c 20 25 31 31 30 30 31 31 31 31 0d | \ %11001111.| 00001990 20 20 33 30 30 20 20 20 20 20 20 20 20 20 53 54 | 300 ST| 000019a0 41 20 64 64 72 62 0d 20 20 33 31 30 20 20 20 20 |A ddrb. 310 | 000019b0 20 20 20 20 20 4c 44 41 20 64 64 72 62 0d 20 20 | LDA ddrb. | 000019c0 33 32 30 20 20 20 20 20 20 20 20 20 4f 52 41 20 |320 ORA | 000019d0 23 26 33 30 20 20 20 20 20 20 5c 20 25 30 30 31 |#&30 \ %001| 000019e0 31 30 30 30 30 0d 20 20 33 33 30 20 20 20 20 20 |10000. 330 | 000019f0 20 20 20 20 53 54 41 20 64 64 72 62 0d 20 20 33 | STA ddrb. 3| 00001a00 34 30 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 |40 LDX #| 00001a10 26 30 36 0d 20 20 33 35 30 20 2e 64 65 6c 61 79 |&06. 350 .delay| 00001a20 31 0d 20 20 33 36 30 20 20 20 20 20 20 20 20 20 |1. 360 | 00001a30 44 45 58 0d 20 20 33 37 30 20 20 20 20 20 20 20 |DEX. 370 | 00001a40 20 20 42 4e 45 20 64 65 6c 61 79 31 0d 20 20 33 | BNE delay1. 3| 00001a50 38 30 20 20 20 20 20 20 20 20 20 4c 44 41 20 64 |80 LDA d| 00001a60 64 72 62 0d 20 20 33 39 30 20 20 20 20 20 20 20 |drb. 390 | 00001a70 20 20 41 4e 44 20 23 26 45 46 20 20 20 20 20 20 | AND #&EF | 00001a80 5c 20 25 31 31 31 30 31 31 31 31 0d 20 20 34 30 |\ %11101111. 40| 00001a90 30 20 20 20 20 20 20 20 20 20 53 54 41 20 64 64 |0 STA dd| 00001aa0 72 62 0d 20 20 34 31 30 20 20 20 20 20 20 20 20 |rb. 410 | 00001ab0 20 4c 44 58 20 23 26 36 34 0d 20 20 34 32 30 20 | LDX #&64. 420 | 00001ac0 2e 64 65 6c 61 79 32 0d 20 20 34 33 30 20 20 20 |.delay2. 430 | 00001ad0 20 20 20 20 20 20 44 45 58 0d 20 20 34 34 30 20 | DEX. 440 | 00001ae0 20 20 20 20 20 20 20 20 42 4e 45 20 64 65 6c 61 | BNE dela| 00001af0 79 32 0d 20 20 34 35 30 20 20 20 20 20 20 20 20 |y2. 450 | 00001b00 20 4c 44 59 20 23 26 30 38 0d 20 20 34 36 30 20 | LDY #&08. 460 | 00001b10 20 20 20 20 20 20 20 20 4c 44 41 20 23 26 39 33 | LDA #&93| 00001b20 20 20 20 20 20 20 5c 20 25 31 30 30 31 30 30 31 | \ %1001001| 00001b30 31 0d 20 20 34 37 30 20 2e 6d 61 69 6e 6c 6f 6f |1. 470 .mainloo| 00001b40 70 0d 20 20 34 38 30 20 20 20 20 20 20 20 20 20 |p. 480 | 00001b50 41 53 4c 20 41 0d 20 20 34 39 30 20 20 20 20 20 |ASL A. 490 | 00001b60 20 20 20 20 50 48 41 0d 20 20 35 30 30 20 20 20 | PHA. 500 | 00001b70 20 20 20 20 20 20 4c 44 41 20 64 64 72 62 0d 20 | LDA ddrb. | 00001b80 20 35 31 30 20 20 20 20 20 20 20 20 20 42 43 53 | 510 BCS| 00001b90 20 63 61 72 72 79 73 65 74 0d 20 20 35 32 30 20 | carryset. 520 | 00001ba0 20 20 20 20 20 20 20 20 4f 52 41 20 23 26 32 30 | ORA #&20| 00001bb0 20 20 20 20 20 20 5c 20 25 30 30 31 30 30 30 30 | \ %0010000| 00001bc0 30 0d 20 20 35 33 30 20 20 20 20 20 20 20 20 20 |0. 530 | 00001bd0 42 4e 45 20 6e 6f 74 7a 65 72 6f 0d 20 20 35 34 |BNE notzero. 54| 00001be0 30 20 2e 63 61 72 72 79 73 65 74 0d 20 20 35 35 |0 .carryset. 55| 00001bf0 30 20 20 20 20 20 20 20 20 20 41 4e 44 20 23 26 |0 AND #&| 00001c00 44 46 20 20 20 20 20 20 5c 20 25 31 31 30 31 31 |DF \ %11011| 00001c10 31 31 31 0d 20 20 35 36 30 20 2e 6e 6f 74 7a 65 |111. 560 .notze| 00001c20 72 6f 0d 20 20 35 37 30 20 20 20 20 20 20 20 20 |ro. 570 | 00001c30 20 53 54 41 20 64 64 72 62 0d 20 20 35 38 30 20 | STA ddrb. 580 | 00001c40 20 20 20 20 20 20 20 20 4c 44 41 20 64 64 72 62 | LDA ddrb| 00001c50 0d 20 20 35 39 30 20 20 20 20 20 20 20 20 20 4f |. 590 O| 00001c60 52 41 20 23 26 31 30 20 20 20 20 20 20 5c 20 25 |RA #&10 \ %| 00001c70 30 30 30 31 30 30 30 30 0d 20 20 36 30 30 20 20 |00010000. 600 | 00001c80 20 20 20 20 20 20 20 53 54 41 20 64 64 72 62 0d | STA ddrb.| 00001c90 20 20 36 31 30 20 20 20 20 20 20 20 20 20 41 4e | 610 AN| 00001ca0 44 20 23 26 45 46 20 20 20 20 20 20 5c 20 25 31 |D #&EF \ %1| 00001cb0 31 31 30 31 31 31 31 0d 20 20 36 32 30 20 20 20 |1101111. 620 | 00001cc0 20 20 20 20 20 20 53 54 41 20 64 64 72 62 0d 20 | STA ddrb. | 00001cd0 20 36 33 30 20 20 20 20 20 20 20 20 20 4c 44 58 | 630 LDX| 00001ce0 20 23 26 33 32 0d 20 20 36 34 30 20 2e 64 65 6c | #&32. 640 .del| 00001cf0 61 79 33 0d 20 20 36 35 30 20 20 20 20 20 20 20 |ay3. 650 | 00001d00 20 20 44 45 58 0d 20 20 36 36 30 20 20 20 20 20 | DEX. 660 | 00001d10 20 20 20 20 42 4e 45 20 64 65 6c 61 79 33 0d 20 | BNE delay3. | 00001d20 20 36 37 30 20 20 20 20 20 20 20 20 20 50 4c 41 | 670 PLA| 00001d30 0d 20 20 36 38 30 20 20 20 20 20 20 20 20 20 44 |. 680 D| 00001d40 45 59 0d 20 20 36 39 30 20 20 20 20 20 20 20 20 |EY. 690 | 00001d50 20 42 4e 45 20 6d 61 69 6e 6c 6f 6f 70 0d 20 20 | BNE mainloop. | 00001d60 37 30 30 20 20 20 20 20 20 20 20 20 43 4c 49 0d |700 CLI.| 00001d70 20 20 37 31 30 20 20 20 20 20 20 20 20 20 4c 44 | 710 LD| 00001d80 41 20 64 72 62 0d 20 20 37 32 30 20 20 20 20 20 |A drb. 720 | 00001d90 20 20 20 20 41 4e 44 20 23 26 32 30 20 20 20 20 | AND #&20 | 00001da0 20 20 5c 20 25 30 30 31 30 30 30 30 30 0d 20 20 | \ %00100000. | 00001db0 37 33 30 20 20 20 20 20 20 20 20 20 42 4e 45 20 |730 BNE | 00001dc0 72 65 74 75 72 6e 0d 20 20 37 34 30 20 20 20 20 |return. 740 | 00001dd0 20 20 20 20 20 4c 44 58 20 23 26 30 30 0d 20 20 | LDX #&00. | 00001de0 37 35 30 20 2e 70 72 69 6e 74 0d 20 20 37 36 30 |750 .print. 760| 00001df0 20 20 20 20 20 20 20 20 20 4c 44 41 20 6d 65 73 | LDA mes| 00001e00 73 61 67 65 2c 58 0d 20 20 37 37 30 20 20 20 20 |sage,X. 770 | 00001e10 20 20 20 20 20 42 45 51 20 72 65 74 75 72 6e 0d | BEQ return.| 00001e20 20 20 37 38 30 20 20 20 20 20 20 20 20 20 4a 53 | 780 JS| 00001e30 52 20 6f 73 77 72 63 68 0d 20 20 37 39 30 20 20 |R oswrch. 790 | 00001e40 20 20 20 20 20 20 20 49 4e 58 0d 20 20 38 30 30 | INX. 800| 00001e50 20 20 20 20 20 20 20 20 20 42 4e 45 20 70 72 69 | BNE pri| 00001e60 6e 74 0d 20 20 38 31 30 20 2e 72 65 74 75 72 6e |nt. 810 .return| 00001e70 0d 20 20 38 32 30 20 20 20 20 20 20 20 20 20 52 |. 820 R| 00001e80 54 53 0d 20 20 38 33 30 20 2e 6d 65 73 73 61 67 |TS. 830 .messag| 00001e90 65 0d 20 20 38 34 30 20 20 20 20 20 20 20 20 20 |e. 840 | 00001ea0 45 51 55 53 20 22 50 72 65 73 73 20 3c 42 52 45 |EQUS "Press <BRE| 00001eb0 41 4b 3e 20 74 6f 20 69 6e 69 74 69 61 6c 69 73 |AK> to initialis| 00001ec0 65 20 6c 69 67 68 74 20 70 65 6e 22 0d 20 20 38 |e light pen". 8| 00001ed0 35 30 20 20 20 20 20 20 20 20 20 45 51 55 44 20 |50 EQUD | 00001ee0 26 30 30 30 41 30 41 30 44 0d 20 20 38 36 30 20 |&000A0A0D. 860 | 00001ef0 2e 6c 61 73 74 62 79 74 65 0d 20 20 38 37 30 20 |.lastbyte. 870 | 00001f00 5d 0d 20 20 38 38 30 20 4e 45 58 54 0d 20 20 38 |]. 880 NEXT. 8| 00001f10 39 30 20 2a 4f 50 54 31 2c 32 0d 20 20 39 30 30 |90 *OPT1,2. 900| 00001f20 20 4f 53 43 4c 49 28 22 53 41 56 45 20 24 2e 21 | OSCLI("SAVE $.!| 00001f30 42 4f 4f 54 20 22 2b 53 54 52 24 7e 28 6d 63 6f |BOOT "+STR$~(mco| 00001f40 64 65 29 2b 22 2b 22 2b 53 54 52 24 7e 28 6c 61 |de)+"+"+STR$~(la| 00001f50 73 74 62 79 74 65 2d 66 69 72 73 74 62 79 74 65 |stbyte-firstbyte| 00001f60 29 0d 20 20 20 20 20 20 2b 22 20 22 2b 53 54 52 |). +" "+STR| 00001f70 24 7e 28 26 46 46 46 46 30 30 30 30 20 4f 52 20 |$~(&FFFF0000 OR | 00001f80 73 74 61 72 74 29 2b 22 20 22 2b 53 54 52 24 7e |start)+" "+STR$~| 00001f90 28 26 46 46 46 46 30 30 30 30 20 4f 52 20 66 69 |(&FFFF0000 OR fi| 00001fa0 72 73 74 62 79 74 65 29 29 0d 20 20 39 31 30 20 |rstbyte)). 910 | 00001fb0 2a 4f 50 54 30 2c 30 0d 20 20 39 32 30 20 2a 4f |*OPT0,0. 920 *O| 00001fc0 50 54 34 2c 32 0d 0d 0d 49 6e 20 74 68 65 6f 72 |PT4,2...In theor| 00001fd0 79 2c 20 69 74 20 73 68 6f 75 6c 64 20 62 65 20 |y, it should be | 00001fe0 70 6f 73 73 69 62 6c 65 20 74 6f 20 63 6f 6e 6e |possible to conn| 00001ff0 65 63 74 20 61 20 6c 69 67 68 74 20 70 65 6e 20 |ect a light pen | 00002000 74 6f 20 61 20 4d 61 73 74 65 72 0d 43 6f 6d 70 |to a Master.Comp| 00002010 61 63 74 20 63 6f 6d 70 75 74 65 72 20 75 73 69 |act computer usi| 00002020 6e 67 20 74 68 65 20 6a 6f 79 73 74 69 63 6b 20 |ng the joystick | 00002030 70 6f 72 74 2e 20 54 68 65 20 6c 69 67 68 74 20 |port. The light | 00002040 70 65 6e 20 73 74 72 6f 62 65 20 61 6e 64 20 74 |pen strobe and t| 00002050 68 65 0d 55 73 65 72 20 50 6f 72 74 20 43 42 32 |he.User Port CB2| 00002060 20 68 61 6e 64 73 68 61 6b 65 20 6c 69 6e 65 20 | handshake line | 00002070 61 70 70 65 61 72 20 74 6f 20 73 68 61 72 65 20 |appear to share | 00002080 74 68 65 20 73 61 6d 65 20 70 69 6e 20 6f 6e 20 |the same pin on | 00002090 74 68 65 20 6a 6f 79 73 74 69 63 6b 0d 63 6f 6e |the joystick.con| 000020a0 6e 65 63 74 6f 72 2e 20 54 68 65 20 55 73 65 72 |nector. The User| 000020b0 20 50 6f 72 74 20 64 61 74 61 20 6c 69 6e 65 73 | Port data lines| 000020c0 20 50 42 30 20 74 6f 20 50 42 34 20 61 6e 64 20 | PB0 to PB4 and | 000020d0 43 42 31 20 61 72 65 20 61 6c 73 6f 20 61 76 61 |CB1 are also ava| 000020e0 69 6c 61 62 6c 65 0d 6f 6e 20 74 68 65 20 6a 6f |ilable.on the jo| 000020f0 79 73 74 69 63 6b 20 63 6f 6e 6e 65 63 74 6f 72 |ystick connector| 00002100 20 73 6f 20 74 68 61 74 20 61 20 6c 69 67 68 74 | so that a light| 00002110 20 70 65 6e 20 73 77 69 74 63 68 20 63 6f 75 6c | pen switch coul| 00002120 64 20 62 65 20 63 6f 6e 6e 65 63 74 65 64 2e 20 |d be connected. | 00002130 49 0d 68 61 76 65 20 6e 6f 74 20 75 73 65 64 20 |I.have not used | 00002140 61 20 6c 69 67 68 74 20 70 65 6e 20 77 69 74 68 |a light pen with| 00002150 20 61 20 43 6f 6d 70 61 63 74 20 63 6f 6d 70 75 | a Compact compu| 00002160 74 65 72 20 61 6e 64 2c 20 69 66 20 61 20 6c 69 |ter and, if a li| 00002170 67 68 74 20 70 65 6e 20 64 6f 65 73 0d 77 6f 72 |ght pen does.wor| 00002180 6b 20 6f 6e 20 74 68 69 73 20 6d 61 63 68 69 6e |k on this machin| 00002190 65 2c 20 74 68 65 20 73 6f 66 74 77 61 72 65 20 |e, the software | 000021a0 64 65 73 63 72 69 62 65 64 20 69 6e 20 74 68 69 |described in thi| 000021b0 73 20 73 65 72 69 65 73 20 77 69 6c 6c 20 68 61 |s series will ha| 000021c0 76 65 20 74 6f 0d 62 65 20 6d 6f 64 69 66 69 65 |ve to.be modifie| 000021d0 64 20 74 6f 20 6f 70 65 72 61 74 65 20 6f 6e 20 |d to operate on | 000021e0 74 68 65 20 55 73 65 72 20 50 6f 72 74 20 72 61 |the User Port ra| 000021f0 74 68 65 72 20 74 68 61 6e 20 74 68 65 20 73 79 |ther than the sy| 00002200 73 74 65 6d 20 56 49 41 2e 0d 0d 0d 54 65 73 74 |stem VIA....Test| 00002210 69 6e 67 20 79 6f 75 72 20 6c 69 67 68 74 20 70 |ing your light p| 00002220 65 6e 0d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |en.-------------| 00002230 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 49 66 20 79 6f |---------..If yo| 00002240 75 20 68 61 76 65 20 62 75 69 6c 74 20 79 6f 75 |u have built you| 00002250 72 20 6f 77 6e 20 6c 69 67 68 74 20 70 65 6e 20 |r own light pen | 00002260 79 6f 75 20 77 69 6c 6c 20 6e 65 65 64 20 74 6f |you will need to| 00002270 20 74 65 73 74 20 69 74 20 62 65 66 6f 72 65 20 | test it before | 00002280 67 6f 69 6e 67 0d 6f 6e 20 74 6f 20 63 6f 6e 73 |going.on to cons| 00002290 69 64 65 72 20 74 68 65 20 64 65 73 69 67 6e 20 |ider the design | 000022a0 6f 66 20 6c 69 67 68 74 20 70 65 6e 20 64 72 69 |of light pen dri| 000022b0 76 65 72 20 73 6f 66 74 77 61 72 65 2e 20 54 68 |ver software. Th| 000022c0 65 20 6c 69 67 68 74 20 70 65 6e 20 77 69 6c 6c |e light pen will| 000022d0 0d 70 72 6f 64 75 63 65 20 61 20 70 6f 73 69 74 |.produce a posit| 000022e0 69 76 65 20 67 6f 69 6e 67 20 54 54 4c 20 70 75 |ive going TTL pu| 000022f0 6c 73 65 20 77 68 65 6e 65 76 65 72 20 74 68 65 |lse whenever the| 00002300 20 73 65 6e 73 6f 72 20 70 69 63 6b 73 20 75 70 | sensor picks up| 00002310 20 6c 69 67 68 74 0d 67 69 76 65 6e 20 6f 75 74 | light.given out| 00002320 20 62 79 20 74 68 65 20 6d 6f 6e 69 74 6f 72 20 | by the monitor | 00002330 73 63 72 65 65 6e 2e 20 57 68 65 6e 20 74 68 65 |screen. When the| 00002340 20 6c 69 67 68 74 20 70 65 6e 20 73 74 72 6f 62 | light pen strob| 00002350 65 20 66 61 6c 6c 73 20 62 61 63 6b 20 66 72 6f |e falls back fro| 00002360 6d 0d 6c 6f 67 69 63 20 31 20 74 6f 20 6c 6f 67 |m.logic 1 to log| 00002370 69 63 20 30 20 61 20 6e 75 6d 62 65 72 20 77 68 |ic 0 a number wh| 00002380 69 63 68 20 63 6f 72 72 65 73 70 6f 6e 64 73 20 |ich corresponds | 00002390 77 69 74 68 20 74 68 65 20 6c 69 67 68 74 20 70 |with the light p| 000023a0 65 6e 20 70 6f 73 69 74 69 6f 6e 0d 77 69 6c 6c |en position.will| 000023b0 20 62 65 20 73 74 6f 72 65 64 20 69 6e 20 72 65 | be stored in re| 000023c0 67 69 73 74 65 72 73 20 31 36 20 61 6e 64 20 31 |gisters 16 and 1| 000023d0 37 20 6f 66 20 74 68 65 20 36 38 34 35 20 43 52 |7 of the 6845 CR| 000023e0 54 43 2e 20 4c 69 67 68 74 20 70 65 6e 73 20 61 |TC. Light pens a| 000023f0 72 65 20 6e 6f 74 0d 73 65 6e 73 69 74 69 76 65 |re not.sensitive| 00002400 20 74 6f 20 62 6c 61 63 6b 20 62 65 63 61 75 73 | to black becaus| 00002410 65 20 6c 69 67 68 74 20 69 73 20 6e 6f 74 20 67 |e light is not g| 00002420 69 76 65 6e 20 6f 75 74 20 62 79 20 74 68 65 20 |iven out by the | 00002430 73 63 72 65 65 6e 20 77 68 65 72 65 0d 62 6c 61 |screen where.bla| 00002440 63 6b 20 69 73 20 64 69 73 70 6c 61 79 65 64 2e |ck is displayed.| 00002450 20 53 6f 6d 65 20 70 68 6f 74 6f 20 73 65 6e 73 | Some photo sens| 00002460 6f 72 73 20 61 72 65 20 6e 6f 74 20 73 65 6e 73 |ors are not sens| 00002470 69 74 69 76 65 20 74 6f 20 74 68 65 20 72 65 64 |itive to the red| 00002480 20 6c 69 67 68 74 0d 67 69 76 65 6e 20 6f 75 74 | light.given out| 00002490 20 62 79 20 73 6f 6d 65 20 6d 6f 6e 69 74 6f 72 | by some monitor| 000024a0 20 73 63 72 65 65 6e 73 2e 20 54 68 69 73 20 69 | screens. This i| 000024b0 73 20 62 65 63 61 75 73 65 20 72 65 64 20 69 73 |s because red is| 000024c0 20 61 74 20 74 68 65 20 6c 6f 77 0d 65 6e 65 72 | at the low.ener| 000024d0 67 79 20 65 6e 64 20 6f 66 20 74 68 65 20 76 69 |gy end of the vi| 000024e0 73 69 62 6c 65 20 73 70 65 63 74 72 75 6d 20 6f |sible spectrum o| 000024f0 66 20 6c 69 67 68 74 20 61 6e 64 20 63 61 6e 20 |f light and can | 00002500 62 65 20 62 65 6c 6f 77 20 74 68 65 20 65 6e 65 |be below the ene| 00002510 72 67 79 0d 74 68 72 65 73 68 6f 6c 64 20 6f 66 |rgy.threshold of| 00002520 20 74 68 65 20 70 68 6f 74 6f 20 73 65 6e 73 6f | the photo senso| 00002530 72 2e 20 54 6f 20 74 65 73 74 20 74 68 65 20 6c |r. To test the l| 00002540 69 67 68 74 20 70 65 6e 20 69 74 20 69 73 20 62 |ight pen it is b| 00002550 65 73 74 20 74 6f 20 66 6c 6f 6f 64 0d 74 68 65 |est to flood.the| 00002560 20 73 63 72 65 65 6e 20 77 69 74 68 20 62 6c 75 | screen with blu| 00002570 65 20 6c 69 67 68 74 20 61 6e 64 20 65 78 61 6d |e light and exam| 00002580 69 6e 65 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 |ine the contents| 00002590 20 6f 66 20 72 65 67 69 73 74 65 72 73 20 31 36 | of registers 16| 000025a0 20 61 6e 64 20 31 37 0d 6f 66 20 74 68 65 20 43 | and 17.of the C| 000025b0 52 54 43 20 61 73 20 74 68 65 20 70 65 6e 20 69 |RTC as the pen i| 000025c0 73 20 6d 6f 76 65 64 20 61 72 6f 75 6e 64 20 74 |s moved around t| 000025d0 68 65 20 73 63 72 65 65 6e 2e 0d 0d 54 68 65 20 |he screen...The | 000025e0 36 38 34 35 20 43 52 54 43 20 69 73 20 6d 61 70 |6845 CRTC is map| 000025f0 70 65 64 20 6f 6e 74 6f 20 73 68 65 69 6c 61 20 |ped onto sheila | 00002600 61 64 64 72 65 73 73 65 73 20 26 46 45 30 30 20 |addresses &FE00 | 00002610 61 6e 64 20 46 45 30 31 2e 20 54 68 65 20 31 34 |and FE01. The 14| 00002620 20 62 69 74 0d 6c 69 67 68 74 20 70 65 6e 20 72 | bit.light pen r| 00002630 65 67 69 73 74 65 72 20 69 73 20 69 6e 20 72 65 |egister is in re| 00002640 67 69 73 74 65 72 20 31 36 20 28 68 69 67 68 20 |gister 16 (high | 00002650 62 79 74 65 29 20 61 6e 64 20 72 65 67 69 73 74 |byte) and regist| 00002660 65 72 20 31 37 20 28 6c 6f 77 0d 62 79 74 65 29 |er 17 (low.byte)| 00002670 20 6f 66 20 74 68 65 20 36 38 34 35 2e 20 49 6e | of the 6845. In| 00002680 20 6f 72 64 65 72 20 74 6f 20 67 61 69 6e 20 61 | order to gain a| 00002690 63 63 65 73 73 20 74 6f 20 61 6e 79 20 6f 66 20 |ccess to any of | 000026a0 74 68 65 20 36 38 34 35 20 43 52 54 43 0d 72 65 |the 6845 CRTC.re| 000026b0 67 69 73 74 65 72 73 2c 20 74 68 65 20 72 65 67 |gisters, the reg| 000026c0 69 73 74 65 72 20 61 64 64 72 65 73 73 20 6d 75 |ister address mu| 000026d0 73 74 20 66 69 72 73 74 20 62 65 20 77 72 69 74 |st first be writ| 000026e0 74 65 6e 20 69 6e 74 6f 20 26 46 45 30 30 2c 20 |ten into &FE00, | 000026f0 74 68 65 0d 61 64 64 72 65 73 73 20 72 65 67 69 |the.address regi| 00002700 73 74 65 72 2e 20 41 66 74 65 72 20 77 72 69 74 |ster. After writ| 00002710 69 6e 67 20 61 20 35 20 62 69 74 20 61 64 64 72 |ing a 5 bit addr| 00002720 65 73 73 20 69 6e 74 6f 20 74 68 65 20 61 64 64 |ess into the add| 00002730 72 65 73 73 20 72 65 67 69 73 74 65 72 2c 0d 74 |ress register,.t| 00002740 68 65 20 73 65 6c 65 63 74 65 64 20 43 52 54 43 |he selected CRTC| 00002750 20 72 65 67 69 73 74 65 72 20 6d 61 79 20 62 65 | register may be| 00002760 20 77 72 69 74 74 65 6e 20 74 6f 20 6f 72 20 72 | written to or r| 00002770 65 61 64 20 66 72 6f 6d 20 26 46 45 30 31 2c 20 |ead from &FE01, | 00002780 74 68 65 20 64 61 74 61 0d 72 65 67 69 73 74 65 |the data.registe| 00002790 72 2e 20 46 6f 72 20 65 78 61 6d 70 6c 65 2c 20 |r. For example, | 000027a0 74 6f 20 72 65 61 64 20 74 68 65 20 63 6f 6e 74 |to read the cont| 000027b0 65 6e 74 73 20 6f 66 20 43 52 54 43 20 72 65 67 |ents of CRTC reg| 000027c0 69 73 74 65 72 20 31 37 20 79 6f 75 20 68 61 76 |ister 17 you hav| 000027d0 65 0d 74 6f 20 66 69 72 73 74 20 73 65 6c 65 63 |e.to first selec| 000027e0 74 20 74 68 65 20 72 65 67 69 73 74 65 72 20 77 |t the register w| 000027f0 69 74 68 20 3f 26 46 45 30 30 3d 31 37 20 6f 72 |ith ?&FE00=17 or| 00002800 20 2a 46 58 31 35 31 2c 30 2c 31 37 2e 20 54 68 | *FX151,0,17. Th| 00002810 65 20 63 6f 6e 74 65 6e 74 73 0d 6f 66 20 72 65 |e contents.of re| 00002820 67 69 73 74 65 72 20 31 37 20 63 61 6e 20 74 68 |gister 17 can th| 00002830 65 6e 20 62 65 20 72 65 61 64 20 65 69 74 68 65 |en be read eithe| 00002840 72 20 64 69 72 65 63 74 6c 79 20 66 72 6f 6d 20 |r directly from | 00002850 26 46 45 30 31 20 6f 72 20 69 6e 64 69 72 65 63 |&FE01 or indirec| 00002860 74 6c 79 0d 77 69 74 68 20 4f 73 62 79 74 65 20 |tly.with Osbyte | 00002870 31 35 30 2c 20 58 3d 31 2e 20 54 68 65 20 63 6f |150, X=1. The co| 00002880 6e 74 65 6e 74 73 20 6f 66 20 74 68 65 20 43 52 |ntents of the CR| 00002890 54 43 20 72 65 67 69 73 74 65 72 73 20 31 36 20 |TC registers 16 | 000028a0 61 6e 64 20 31 37 20 61 72 65 0d 65 78 61 6d 69 |and 17 are.exami| 000028b0 6e 65 64 20 69 6e 20 74 68 65 20 70 72 6f 67 72 |ned in the progr| 000028c0 61 6d 20 50 45 4e 54 45 53 54 20 75 73 69 6e 67 |am PENTEST using| 000028d0 20 4f 73 62 79 74 65 20 31 35 31 20 28 77 72 69 | Osbyte 151 (wri| 000028e0 74 65 20 74 6f 20 53 68 65 69 6c 61 29 20 61 6e |te to Sheila) an| 000028f0 64 0d 4f 73 62 79 74 65 20 31 35 30 20 28 72 65 |d.Osbyte 150 (re| 00002900 61 64 20 66 72 6f 6d 20 53 68 65 69 6c 61 29 2e |ad from Sheila).| 00002910 0d 0d 43 6f 6e 6e 65 63 74 20 79 6f 75 72 20 6c |..Connect your l| 00002920 69 67 68 74 20 70 65 6e 20 74 6f 20 74 68 65 20 |ight pen to the | 00002930 61 6e 61 6c 6f 67 75 65 20 70 6f 72 74 20 61 6e |analogue port an| 00002940 64 20 63 68 61 69 6e 20 74 68 65 20 70 72 6f 67 |d chain the prog| 00002950 72 61 6d 20 50 45 4e 54 45 53 54 2e 0d 42 65 66 |ram PENTEST..Bef| 00002960 6f 72 65 20 79 6f 75 20 70 6f 69 6e 74 20 61 20 |ore you point a | 00002970 6c 69 67 68 74 20 70 65 6e 20 61 74 20 74 68 65 |light pen at the| 00002980 20 73 63 72 65 65 6e 20 6e 6f 74 69 63 65 20 74 | screen notice t| 00002990 68 61 74 20 74 68 65 20 6c 69 67 68 74 20 70 65 |hat the light pe| 000029a0 6e 0d 72 65 67 69 73 74 65 72 20 63 6f 6e 74 61 |n.register conta| 000029b0 69 6e 73 20 7a 65 72 6f 2e 20 4d 6f 76 65 20 74 |ins zero. Move t| 000029c0 68 65 20 6c 69 67 68 74 20 70 65 6e 20 61 72 6f |he light pen aro| 000029d0 75 6e 64 20 74 68 65 20 73 63 72 65 65 6e 20 61 |und the screen a| 000029e0 6e 64 2c 20 69 66 20 61 6c 6c 0d 69 73 20 77 65 |nd, if all.is we| 000029f0 6c 6c 2c 20 79 6f 75 20 77 69 6c 6c 20 73 65 65 |ll, you will see| 00002a00 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 6f 66 | the contents of| 00002a10 20 74 68 65 20 6c 69 67 68 74 20 70 65 6e 20 72 | the light pen r| 00002a20 65 67 69 73 74 65 72 20 63 68 61 6e 67 69 6e 67 |egister changing| 00002a30 20 61 6e 64 0d 68 65 61 72 20 61 20 73 6f 75 6e | and.hear a soun| 00002a40 64 20 77 69 74 68 20 65 76 65 72 79 20 63 68 61 |d with every cha| 00002a50 6e 67 65 2e 20 50 45 4e 54 45 53 54 20 64 6f 65 |nge. PENTEST doe| 00002a60 73 20 6e 6f 74 20 75 73 65 20 61 20 6c 69 67 68 |s not use a ligh| 00002a70 74 20 70 65 6e 20 73 77 69 74 63 68 0d 61 6e 64 |t pen switch.and| 00002a80 20 77 6f 72 6b 73 20 77 69 74 68 20 61 6c 6c 20 | works with all | 00002a90 6c 69 67 68 74 20 70 65 6e 73 2e 0d 0d 0d 20 20 |light pens.... | 00002aa0 20 31 30 20 52 45 4d 3e 20 50 45 4e 54 45 53 54 | 10 REM> PENTEST| 00002ab0 0d 20 20 20 32 30 20 4f 4e 45 52 52 4f 52 20 56 |. 20 ONERROR V| 00002ac0 44 55 32 33 2c 31 2c 31 3b 30 3b 30 3b 30 3b 3a |DU23,1,1;0;0;0;:| 00002ad0 45 4e 44 0d 20 20 20 33 30 20 4d 4f 44 45 34 0d |END. 30 MODE4.| 00002ae0 20 20 20 34 30 20 56 44 55 32 33 2c 31 2c 30 3b | 40 VDU23,1,0;| 00002af0 30 3b 30 3b 30 3b 0d 20 20 20 35 30 20 56 44 55 |0;0;0;. 50 VDU| 00002b00 31 39 2c 30 2c 34 3b 30 3b 0d 20 20 20 36 30 20 |19,0,4;0;. 60 | 00002b10 41 25 3d 31 35 30 0d 20 20 20 37 30 20 58 25 3d |A%=150. 70 X%=| 00002b20 31 0d 20 20 20 38 30 20 52 45 50 45 41 54 0d 20 |1. 80 REPEAT. | 00002b30 20 20 39 30 20 2a 46 58 31 35 31 2c 30 2c 31 37 | 90 *FX151,0,17| 00002b40 0d 20 20 31 30 30 20 52 25 3d 28 55 53 52 28 26 |. 100 R%=(USR(&| 00002b50 46 46 46 34 29 41 4e 44 26 46 46 30 30 30 30 29 |FFF4)AND&FF0000)| 00002b60 44 49 56 26 31 30 30 30 30 0d 20 20 31 31 30 20 |DIV&10000. 110 | 00002b70 2a 46 58 31 35 31 2c 30 2c 31 36 0d 20 20 31 32 |*FX151,0,16. 12| 00002b80 30 20 53 25 3d 28 55 53 52 28 26 46 46 46 34 29 |0 S%=(USR(&FFF4)| 00002b90 41 4e 44 26 46 46 30 30 30 30 29 44 49 56 26 31 |AND&FF0000)DIV&1| 00002ba0 30 30 30 30 0d 20 20 31 33 30 20 50 52 49 4e 54 |0000. 130 PRINT| 00002bb0 54 41 42 28 31 32 2c 31 34 29 22 4c 6f 77 20 62 |TAB(12,14)"Low b| 00002bc0 79 74 65 20 3d 20 26 22 3b 7e 52 25 3b 22 20 22 |yte = &";~R%;" "| 00002bd0 0d 20 20 31 34 30 20 50 52 49 4e 54 54 41 42 28 |. 140 PRINTTAB(| 00002be0 31 32 2c 31 36 29 22 48 69 67 68 20 62 79 74 65 |12,16)"High byte| 00002bf0 3d 20 26 22 3b 7e 53 25 3b 22 20 22 0d 20 20 31 |= &";~S%;" ". 1| 00002c00 35 30 20 49 46 20 52 25 3c 3e 54 25 20 53 4f 55 |50 IF R%<>T% SOU| 00002c10 4e 44 20 31 2c 2d 31 30 2c 31 30 30 2c 31 0d 20 |ND 1,-10,100,1. | 00002c20 20 31 36 30 20 49 46 20 53 25 3c 3e 55 25 20 53 | 160 IF S%<>U% S| 00002c30 4f 55 4e 44 20 31 2c 2d 31 30 2c 35 30 2c 31 0d |OUND 1,-10,50,1.| 00002c40 20 20 31 37 30 20 54 25 3d 52 25 0d 20 20 31 38 | 170 T%=R%. 18| 00002c50 30 20 55 25 3d 53 25 0d 20 20 31 39 30 20 55 4e |0 U%=S%. 190 UN| 00002c60 54 49 4c 20 46 41 4c 53 45 0d |TIL FALSE.| 00002c6a