Home » CEEFAX disks » telesoftware12.adl » 27-01-89/T\Pen02
27-01-89/T\Pen02
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: | 27-01-89/T\Pen02 |
Read OK: | ✔ |
File size: | 5786 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
Using a light pen with the BBC microcomputer - by - Gordon Horsington --------------------------------------------------------------------- Module 2. Light pen interrupts ------------------------------ This module will describe how the light pen interrupt can be used to execute the code which calculates the light pen position. Using the light pen interrupt in this way ensures that the data available in memory locations &70 and &71 is always an up-to-date value of the light pen text coordinates. There are some alterations to be made to the code introduced in module 1 because interrupt routines cannot use operating system calls and must run in the I/O processor. Osbyte can not be used either to determine the screen mode or to access the CRCT registers. The CRTC registers have to be accessed directly and the screen mode can be read from memory location &355 which contains a copy of the screen mode, ignoring the shadow screen. Module 3 will discuss how these interrupt techniques can be made to be Tube compatible. The video strobe pulse (VSP), which is also known as the light pen strobe (LPSTB), is routed to CB2 of the system VIA. Light pen interrupts are not dealt with by the operating system and, when enabled, they are always passed first to the paged ROMs and then to IRQ2V, the secondary interrupt request vector. There are two 6522 VIAs in the BBC B. VIA-A is used for internal functions and the joystick fire buttons and is usually called the system VIA. VIA-B provides the parallel printer interface and the user port. A 6522 VIA is quite a complex device controled by 16 registers. The system VIA registers are mapped onto Sheila addresses &40 to &4F (ie. &FE40 to &FE4F) as shown in figure 1. Address Description Designation +-------+-------------------------------------+-------------+ | &FE4F | Data register A (no handshake) | DRA | +-------+-------------------------------------+-------------+ | &FE4E | Interrupt enable register | IER | +-------+-------------------------------------+-------------+ | &FE4D | Interrupt flag register | IFR | +-------+-------------------------------------+-------------+ | &FE4C | Peripheral control register | PCR | +-------+-------------------------------------+-------------+ | &FE4B | Auxiliary control register | ACR | +-------+-------------------------------------+-------------+ | &FE4A | Shift register | SR | +-------+-------------------------------------+-------------+ | &FE49 | Timer 2 initiate count | T2CH | +-------+-------------------------------------+-------------+ | &FE48 | Timer 2 write latch, read counter | T2CL | +-------+-------------------------------------+-------------+ | &FE47 | Timer 1 load latch, high byte | T1LH | +-------+-------------------------------------+-------------+ | &FE46 | Timer 1 load latch, low byte | T1LL | +-------+-------------------------------------+-------------+ | &FE45 | Timer 1 initiate count | T1CH | +-------+-------------------------------------+-------------+ | &FE44 | Timer 1 write latch, read counter | T1CL | +-------+-------------------------------------+-------------+ | &FE43 | Data direction register A | DDRA | +-------+-------------------------------------+-------------+ | &FE42 | Data direction register B | DDRB | +-------+-------------------------------------+-------------+ | &FE41 | Data register A | DRA | +-------+-------------------------------------+-------------+ | &FE40 | Data register B | DRB | +-------+-------------------------------------+-------------+ Figure 1 The System VIA registers -------- ------------------------ Four of these 16 registers are of interest when using a light pen. They are data register B (&FE40), the peripheral control register (&FE4C), the interrupt flag register (&FE4D), and the interrupt enable register (&FE4E). Both the system VIA and the user VIA have 20 I/O lines grouped into an A side and a B side of 10 lines each. These 10 lines are divided into 8 data lines and 2 handshake lines. The data lines are called PA0 to PA7 on the A side and PB0 to PB7 on the B side. Data lines PA0 to PA7 can be read from or written to data register A and data lines PB0 to PB7 can be read from or written to data register B. Data register B is useful when writing light pen software because the status of the two fire buttons can be read from this register. The right fire button clears bit 5 of DRB when the button is closed and sets bit five of DRB when it is open. The status of the left fire button can be read from bit 4 of DRB. The handshake lines are called CA1 and CA2 on the A side and CB1 and CB2 on the B side. Light pen interrupts are routed to CB2 of the system VIA. The peripheral control register is used to control the use of these handshake lines. The PCR and the interpretation of its bits is shown in figure 2. bit 7 6 5 4 3 2 1 0 +-------+-------+-------+-------+-------+-------+-------+-------+ | CB2 | CB1 | CA2 | CA1 | | control |control| control |control| +-------+-------+-------+-------+-------+-------+-------+-------+ Bit Interpretation if bit clear (0) Interpretation if bit set (1) +---+---------------------------------+---------------------------------+ | 0 |Set bit 1 of IFR on -ve going CA1|Set bit 1 of IFR on +ve going CA1| +---+---------------------------------+---------------------------------+ | 1 | DRA selected to clear interrupt | Interrupt not cleared by DRA | +---+---------------------------------+---------------------------------+ | 2 |Set bit 0 of IFR on -ve going CA2|Set bit 0 of IFR on +ve going CA2| +---+---------------------------------+---------------------------------+ | 3 | Set CA2 to input mode | Set CA2 to output mode | +---+---------------------------------+---------------------------------+ | 4 |Set bit 4 of IFR on -ve going CB1|Set bit 4 of IFR on +ve going CB1| +---+---------------------------------+---------------------------------+ | 5 | DRB selected to clear interrupt | Interrupt not cleared by DRB | +---+---------------------------------+---------------------------------+ | 6 |Set bit 3 of IFR on -ve going CB2|Set bit 3 of IFR on +ve going CB2| +---+---------------------------------+---------------------------------+ | 7 | Set CB2 to input mode | Set CB2 to output mode | +---+---------------------------------+---------------------------------+ Figure 2 The peripheral control register -------- ------------------------------- The light pen interrupt is routed to CB2 and so bits 5, 6 and 7 of the system VIA PCR control the interpretation of the video strobe pulse. We want use CB2 in the input mode (bit 7 clear), to generate an interrupt on a negative going pulse (bit 6 clear) and to clear the interrupt when DRB is selected (bit 5 clear). This is quite convenient because, by default, bits 5, 6 and 7 of the system PCR are clear. Unless these bits have been changed from their default values you do not have to alter the contents of the PCR to use light pen interrupts. Light pen interrupts are enabled by setting bit 3 of the interrupt enable register. Setting this bit uses an odd method. To alter a bit in the IER you must write a number to the IER with a 1 in the same bit position. If bit 7 of the number is a 1 then the selected bit (or bits) will also be set to 1. If bit 7 of the number is 0 then the selected bit (or bits) will be cleared. The selected bits (0 to 6) are set to the same state as bit 7. To set bit 3 of the IER you have to write the number &88 (%10001000) into the IER. Bit 3 will then take the value of bit 7 and will be set. When bit 3 of the IER is set a negative transition on CB2 will set bit 3 of the interrupt flag register and generate an IRQ interrupt. This can be recognised because both bits 7 and 3 of IFR will be set. Light pen interrupts are disabled by writing the number &08 (%00001000) into the IER. This clears bit 3 of the IER so that a negative going transition on CB2 will still set bit 3 of the IFR but it will not generate an IRQ interrupt. Light pen interrupts are usually enabled with ?&FE4E=&88 or *FX 151,78,136 and disabled with ?&FE4E=&08 or *FX 151,78,8 The interrupt enable and interrupt flag registers work as a pair and the flag register can be interrogated by a program to see if a light pen is the source of an interrupt. The interpretation of the bits in the system VIA interrupt flag register is tabulated in figure 3 which shows that bits 7 and 3 of the IFR will be set if a light pen is the source of an interrupt. If either bit 7 or bit 3 of the IFR is clear then a light pen was not the source of an interrupt. 7 6 5 4 3 2 1 0 +---------+-----+-----+-----+-----+-----+-----+-----+ &FE4E |Set/Clear| T1 | T2 | CB1 | CB2 | SR | CA1 | CA2 | IER +---------+-----+-----+-----+-----+-----+-----+-----+ &FE4D | IRQ | T1 | T2 | CB1 | CB2 | SR | CA1 | CA2 | IFR +---------+-----+-----+-----+-----+-----+-----+-----+ Bit Cause of interrupt Interpretation +---+-------------------------+-----------------------------------------+ | 0 | Change of signal on CA2 | Key pressed on keyboard | +---+-------------------------+-----------------------------------------+ | 1 | Change of signal on CA1 | Vertical sync pulse | +---+-------------------------+-----------------------------------------+ | 2 | Completion of 8 shifts | Shift register is not used by system. | | | in the shift register | Always passed to IRQ2V | +---+-------------------------+-----------------------------------------+ | 3 | Change of signal on CB2 | Light pen interrupt. Not used by system | | | | Always passed to user routine via IRQ2V | +---+-------------------------+-----------------------------------------+ | 4 | Change of signal on CB1 | ADC conversion completed | +---+-------------------------+-----------------------------------------+ | 5 | Timer 2 complete | Current speech word complete | +---+-------------------------+-----------------------------------------+ | 6 | Timer 1 complete | Increment internal clock | +---+-------------------------+-----------------------------------------+ | 7 | Any bit, 0 to 6, is set | One of the above interrupts has occured | +---+-------------------------+-----------------------------------------+ Figure 3. The interpretation of the system interrupt flag register --------- -------------------------------------------------------- A program should interogate bits 7 and 3 of the system IFR to find out if a light pen is the source of an IRQ interrupt. If it is then the interrupt must be cleared by reading the contents of DRB (because bit 5 of the PCR is clear). You can therefore read the status of the fire buttons and clear the interrupt at the same time. The program IOINTER uses this method and stores the status of the right fire button in memory location &72 for the progam user to access if he or she wants to know the fire button status at the last light pen interrupt. This will only be useful if the RH compatible design is used but it does not mean that other types of light pen cannot use the software. The fire button status at the last interrupt is not necessarily the same as the current fire button status and none of the demonstration programs in this series actually use the status at the last interrupt. In all the demonstration programs which use a light pen switch, the current status is determined by the BASIC function FNswitch which is in the last few lines of each program and can be altered to suit what ever light pen switch is being used. If, for example, you have a light pen without any switch you could use the space bar as a substitute and alter line 2320 of IOINTER to read: 2320 =INKEY(-99) If you have a pen with a touch sensitive switch connected to one of the analogue ports it will be measuring your skin resitance and you will need to alter line 2310 to something like: 2320 IF ADVAL(1)>1600 =TRUE ELSE =FALSE There could be other types of switches used by manufacturers and if you have bought a ready made light pen you should have the information you need to alter FNswitch in all the programs which use a light pen switch. The interrupt bit mask for the system VIA can be accessed using Osbyte &E9. The interrupt handling routine ANDs this value with the VIA IFR and any bit cleared by this is ignored by the operating system. You might therefore expect to have to issue Osbyte &E9 with X=&F7 (%11110111) and Y=&00 in order to ensure that the light pen interrupt is passed to IRQ2V but, because the operating system does not process the light pen interrupt, it is not necessary to make this Osbyte call. The Osbyte &E9 calls have been commented out in the program IOINTER. If you want to include this Osbyte call for the sake of completely legal coding then you can edit the program. To demonstrate the use of light pen interrupts chain the program IOINTER. The first time the machine code is called it will enable the light pen interrupts. The screen mode can be changed with the up and down cursor keys and the offset can be trimmed with the left and right cursor keys. The background colour can be altered by pressing P (P for paper) and the text colour can be altered with I (I for ink). The program will draw an asterisk on the screen whenever the light pen switch is open, ie. pressed. You can leave the program by pressing the Escape key. This will call the machine code a second time and disable the interrupt routine. 10 REM> IOINTER 20 A%=&EA 30 X%=0 40 Y%=&FF 50 IF ((USR(&FFF4)AND&FF00)DIV&100)<>0 END 60 mcode=&A00 70 xcoord=&70 80 ycoord=&71 90 !xcoord=0 100 PROCmcode 110 ONERROR CALL mcode:VDU23,1,1;0;0;0;:END 120 mode=4 130 paper=6 140 ink=4 150 MODE mode 160 PROCnewmode 170 REPEAT 180 IF INKEY(-58) PROCup:MODE mode:PROCnewmode 190 IF INKEY(-42) PROCdown:MODE mode:PROCnewmode 200 IF INKEY(-56) PROCpaper 210 IF INKEY(-38) PROCink 220 IF INKEY(-26) PROCleft 230 IF INKEY(-122) PROCright 240 PRINTTAB(13,2);?xcoord;" "TAB(13,3);?ycoord;" " 250 IF FNswitch VDU31,?xcoord,?ycoord,42 260 UNTIL FALSE 270 : 280 DEFPROCup 290 mode=mode+1 300 IF mode>7 mode=7 310 ENDPROC 320 : 330 DEFPROCdown 340 mode=mode-1 350 IF mode<0 mode=0 360 ENDPROC 370 : 380 DEFPROCleft 390 IF offsetlow?mode=12 ENDPROC 400 offsetlow?mode=offsetlow?mode+1 410 PROCdelay 420 ENDPROC 430 : 440 DEFPROCright 450 IF offsetlow?mode=0 ENDPROC 460 offsetlow?mode=offsetlow?mode-1 470 PROCdelay 480 ENDPROC 490 : 500 DEFPROCnewmode 510 VDU23,1,0;0;0;0; 520 IF mode=7 PROCseven:ENDPROC 530 VDU19,0,paper;0; 540 VDU19,1,ink;0; 550 COLOUR1 560 PROCdelay 570 ENDPROC 580 : 590 DEFPROCdelay 600 PRINTTAB(3,1)"Mode ";mode 610 PRINTTAB(3,2)"X coord = ";?xcoord 620 PRINTTAB(3,3)"Y coord = ";?ycoord 630 PRINTTAB(3,4)"offsetlow = ";offsetlow?mode 640 time=TIME+20 650 REPEAT UNTIL time<TIME 660 ENDPROC 670 : 680 DEFPROCink 690 ink=ink+1 700 IF ink=paper ink=ink+1 710 IF ink>7 ink=0 720 VDU19,1,ink;0; 730 IF mode=7 PROCseven 740 PROCdelay 750 ENDPROC 760 : 770 DEFPROCpaper 780 paper=paper+1 790 IF paper=ink paper=paper+1 800 IF paper>7 paper=1 810 VDU19,0,paper;0; 820 IF mode=7 PROCseven 830 PROCdelay 840 ENDPROC 850 : 860 DEFPROCseven 870 IF ink=0 ink=1 880 FOR line=0 TO 24 890 IF paper=0 VDU31,0,line,128+ink,32,32 ELSE VDU31,0,line,128+paper,157,128+ink 900 NEXT 910 PROCdelay 920 ENDPROC 930 : 940 DEFPROCmcode 950 fire=&72 :REM: fire button status 960 irq2v=&206 :REM: secondary interrupt vector 970 screen=&355 :REM: screen mode OS 1.2 980 sheila=&FE00 990 drb=&FE40 :REM: system 6522 input/output register B 1000 ifr=&FE4D :REM: system 6522 interrupt flag register 1010 ier=&FE4E :REM: system 6522 interrupt enable register 1020 osword=&FFF1 1030 osbyte=&FFF4 1040 FOR pass=0 TO 2 STEP 2 1050 P%=mcode 1060 [ OPT pass 1070 LDX irq2v \ secondary interrupt vector, low byte 1080 LDY irq2v+1 \ secondary interrupt vector, high byte 1090 CPY #interrupt DIV 256 \ has the high byte been altered? 1100 BEQ disable \ restore original vector if altered 1110 STX oldirq2v \ store original vector, low byte 1120 STY oldirq2v+1 \ store original vector, high byte 1130 LDX #interrupt MOD 256 \ new interrupt code, low byte 1140 LDY #interrupt DIV 256 \ new interrupt code, high byte 1150 SEI \ set interrupt disable flag 1160 STX irq2v \ alter vector, low byte 1170 STY irq2v+1 \ alter vector, high byte 1180 CLI \ clear interrupt disable flag 1190 LDA #&88 \ %10001000 1200 STA ier \ enable light pen interrupts 1210 \ LDA #&E9 \ write system VIA IRQ bit mask 1220 \ LDX #&F7 \ %11110111 1230 \ LDY #&00 1240 \ JSR osbyte \ bit mask = %11110111 1250 RTS 1260 .disable 1270 LDA #&08 \ %00001000 ready to disable light pen \ interrupts 1280 LDX oldirq2v \ original irq2 vector, low byte 1290 LDY oldirq2v+1 \ original irq2 vector, high byte 1300 SEI \ set interrupt disable flag 1310 STA ier \ disable light pen interrupt 1320 STX irq2v \ restore original vector, low byte 1330 STY irq2v+1 \ restore original vector, high byte 1340 CLI \ clear interrupt disable flag 1350 \ LDA #&E9 \ write system VIA IRQ bit mask 1360 \ LDX #&FF \ %11111111 1370 \ LDY #&00 1380 \ JSR osbyte \ bit mask = default 1390 RTS 1400 .exit 1410 PLA \ pull interrupt accumulator save register 1420 STA &FC \ restore interrupt accumulator save register 1430 JMP (oldirq2v) \ exit via original vector 1440 .interrupt 1450 LDA &FC \ load interrupt accumulator save register 1460 PHA \ and push it on the stack 1470 LDA ifr \ load system VIA interrupt status 1480 BPL exit \ exit if bit 7 clear 1490 AND #&08 \ AND with %00001000 1500 BEQ exit \ exit if not light pen interrupt 1510 TXA 1520 PHA 1530 TYA 1540 PHA 1550 LDA drb \ clear interrupt 1560 PHA \ push data register B 1570 LDY screen \ screen mode into Y register 1580 LDX #&11 \ light pen register, low byte 1590 STX sheila \ 6845 address register 1600 LDA sheila+1 \ 6845 data register 1610 CLD \ clear decimal flag 1620 SEC \ prepare for subtraction 1630 SBC offsetlow,Y \ subtract screen mode offset 1640 STA ycoord \ low byte - offset 1650 DEX \ X = &10, light pen register, high byte 1660 STX sheila \ 6845 address register 1670 LDA sheila+1 \ 6845 data register 1680 SBC offsethigh,Y \ subtract screen mode offset 1690 STA ycoord+1 \ high byte - offset 1700 LDA #&00 \ prepare for 16 bit division 1710 STA xcoord \ clear low partial dividend 1720 .next 1730 ASL ycoord \ shift dividend/quotient left 1740 ROL ycoord+1 \ shift dividend/quotient left 1750 ROL xcoord \ shift bits into partial dividend 1760 LDA xcoord \ load partial dividend 1770 SEC \ prepare for subtraction 1780 SBC width,Y \ subtract divisor 1790 BCC done \ branch if dividend < divisor 1800 INC ycoord \ increment quotient 1810 STA xcoord \ save new partial dividend 1820 .done 1830 DEX \ decrement bit counter 1840 BNE next \ branch for 16 bits 1850 LDA scale,Y \ screen mode scale 1860 BEQ pullout \ branch if modes 0, 3, 4, 6 or 7 1870 TAX \ in mode1 and mode5 X=1, in mode2 X=2 1880 LDA xcoord 1890 .reduce 1900 LSR A \ horizontal position / 2 1910 DEX 1920 BNE reduce 1930 STA xcoord 1940 .pullout 1950 PLA \ pull data register B 1960 AND #&20 \ %00100000 1970 STA fire \ store fire button status 1980 PLA 1990 TAY 2000 PLA 2010 TAX 2020 PLA 2030 STA &FC 2040 RTI \ return from interrupt 2050 .oldirq2v 2060 EQUW &00 \ original irq2 vector 2070 .offsetlow 2080 EQUB &04 \ mode0, untrimmed = &06 2090 EQUB &04 \ mode1, untrimmed = &06 2100 EQUB &04 \ mode2, untrimmed = &06 2110 EQUB &04 \ mode3, untrimmed = &06 2120 EQUB &03 \ mode4, untrimmed = &04 2130 EQUB &03 \ mode5, untrimmed = &04 2140 EQUB &03 \ mode6, untrimmed = &04 2150 EQUB &06 \ mode7, untrimmed = &08 2160 .offsethigh 2170 EQUD &08060606 \ modes 3-0 2180 EQUD &280C0B0B \ modes 7-4 2190 .scale 2200 EQUD &00020100 \ modes 3-0 2210 EQUD &00000100 \ modes 7-4 2220 .width 2230 EQUD &50505050 \ modes 3-0 2240 EQUD &28282828 \ modes 7-4 2250 .lastbyte 2260 ] 2270 NEXT 2280 CALL mcode 2290 ENDPROC 2300 : 2310 DEFFNswitch 2320 IF (ADVAL(0)AND3)=0 =TRUE ELSE =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 32 2e 20 4c 69 67 68 74 20 70 65 6e |ule 2. Light pen| 000000a0 20 69 6e 74 65 72 72 75 70 74 73 0d 2d 2d 2d 2d | interrupts.----| 000000b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000000c0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 54 68 69 |----------...Thi| 000000d0 73 20 6d 6f 64 75 6c 65 20 77 69 6c 6c 20 64 65 |s module will de| 000000e0 73 63 72 69 62 65 20 68 6f 77 20 74 68 65 20 6c |scribe how the l| 000000f0 69 67 68 74 20 70 65 6e 20 69 6e 74 65 72 72 75 |ight pen interru| 00000100 70 74 20 63 61 6e 20 62 65 20 75 73 65 64 20 74 |pt can be used t| 00000110 6f 0d 65 78 65 63 75 74 65 20 74 68 65 20 63 6f |o.execute the co| 00000120 64 65 20 77 68 69 63 68 20 63 61 6c 63 75 6c 61 |de which calcula| 00000130 74 65 73 20 74 68 65 20 6c 69 67 68 74 20 70 65 |tes the light pe| 00000140 6e 20 70 6f 73 69 74 69 6f 6e 2e 20 55 73 69 6e |n position. Usin| 00000150 67 20 74 68 65 20 6c 69 67 68 74 0d 70 65 6e 20 |g the light.pen | 00000160 69 6e 74 65 72 72 75 70 74 20 69 6e 20 74 68 69 |interrupt in thi| 00000170 73 20 77 61 79 20 65 6e 73 75 72 65 73 20 74 68 |s way ensures th| 00000180 61 74 20 74 68 65 20 64 61 74 61 20 61 76 61 69 |at the data avai| 00000190 6c 61 62 6c 65 20 69 6e 20 6d 65 6d 6f 72 79 0d |lable in memory.| 000001a0 6c 6f 63 61 74 69 6f 6e 73 20 26 37 30 20 61 6e |locations &70 an| 000001b0 64 20 26 37 31 20 69 73 20 61 6c 77 61 79 73 20 |d &71 is always | 000001c0 61 6e 20 75 70 2d 74 6f 2d 64 61 74 65 20 76 61 |an up-to-date va| 000001d0 6c 75 65 20 6f 66 20 74 68 65 20 6c 69 67 68 74 |lue of the light| 000001e0 20 70 65 6e 20 74 65 78 74 0d 63 6f 6f 72 64 69 | pen text.coordi| 000001f0 6e 61 74 65 73 2e 20 54 68 65 72 65 20 61 72 65 |nates. There are| 00000200 20 73 6f 6d 65 20 61 6c 74 65 72 61 74 69 6f 6e | some alteration| 00000210 73 20 74 6f 20 62 65 20 6d 61 64 65 20 74 6f 20 |s to be made to | 00000220 74 68 65 20 63 6f 64 65 20 69 6e 74 72 6f 64 75 |the code introdu| 00000230 63 65 64 0d 69 6e 20 6d 6f 64 75 6c 65 20 31 20 |ced.in module 1 | 00000240 62 65 63 61 75 73 65 20 69 6e 74 65 72 72 75 70 |because interrup| 00000250 74 20 72 6f 75 74 69 6e 65 73 20 63 61 6e 6e 6f |t routines canno| 00000260 74 20 75 73 65 20 6f 70 65 72 61 74 69 6e 67 20 |t use operating | 00000270 73 79 73 74 65 6d 20 63 61 6c 6c 73 0d 61 6e 64 |system calls.and| 00000280 20 6d 75 73 74 20 72 75 6e 20 69 6e 20 74 68 65 | must run in the| 00000290 20 49 2f 4f 20 70 72 6f 63 65 73 73 6f 72 2e 20 | I/O processor. | 000002a0 4f 73 62 79 74 65 20 63 61 6e 20 6e 6f 74 20 62 |Osbyte can not b| 000002b0 65 20 75 73 65 64 20 65 69 74 68 65 72 20 74 6f |e used either to| 000002c0 0d 64 65 74 65 72 6d 69 6e 65 20 74 68 65 20 73 |.determine the s| 000002d0 63 72 65 65 6e 20 6d 6f 64 65 20 6f 72 20 74 6f |creen mode or to| 000002e0 20 61 63 63 65 73 73 20 74 68 65 20 43 52 43 54 | access the CRCT| 000002f0 20 72 65 67 69 73 74 65 72 73 2e 20 54 68 65 20 | registers. The | 00000300 43 52 54 43 0d 72 65 67 69 73 74 65 72 73 20 68 |CRTC.registers h| 00000310 61 76 65 20 74 6f 20 62 65 20 61 63 63 65 73 73 |ave to be access| 00000320 65 64 20 64 69 72 65 63 74 6c 79 20 61 6e 64 20 |ed directly and | 00000330 74 68 65 20 73 63 72 65 65 6e 20 6d 6f 64 65 20 |the screen mode | 00000340 63 61 6e 20 62 65 20 72 65 61 64 0d 66 72 6f 6d |can be read.from| 00000350 20 6d 65 6d 6f 72 79 20 6c 6f 63 61 74 69 6f 6e | memory location| 00000360 20 26 33 35 35 20 77 68 69 63 68 20 63 6f 6e 74 | &355 which cont| 00000370 61 69 6e 73 20 61 20 63 6f 70 79 20 6f 66 20 74 |ains a copy of t| 00000380 68 65 20 73 63 72 65 65 6e 20 6d 6f 64 65 2c 0d |he screen mode,.| 00000390 69 67 6e 6f 72 69 6e 67 20 74 68 65 20 73 68 61 |ignoring the sha| 000003a0 64 6f 77 20 73 63 72 65 65 6e 2e 20 4d 6f 64 75 |dow screen. Modu| 000003b0 6c 65 20 33 20 77 69 6c 6c 20 64 69 73 63 75 73 |le 3 will discus| 000003c0 73 20 68 6f 77 20 74 68 65 73 65 20 69 6e 74 65 |s how these inte| 000003d0 72 72 75 70 74 0d 74 65 63 68 6e 69 71 75 65 73 |rrupt.techniques| 000003e0 20 63 61 6e 20 62 65 20 6d 61 64 65 20 74 6f 20 | can be made to | 000003f0 62 65 20 54 75 62 65 20 63 6f 6d 70 61 74 69 62 |be Tube compatib| 00000400 6c 65 2e 0d 0d 54 68 65 20 76 69 64 65 6f 20 73 |le...The video s| 00000410 74 72 6f 62 65 20 70 75 6c 73 65 20 28 56 53 50 |trobe pulse (VSP| 00000420 29 2c 20 77 68 69 63 68 20 69 73 20 61 6c 73 6f |), which is also| 00000430 20 6b 6e 6f 77 6e 20 61 73 20 74 68 65 20 6c 69 | known as the li| 00000440 67 68 74 20 70 65 6e 20 73 74 72 6f 62 65 0d 28 |ght pen strobe.(| 00000450 4c 50 53 54 42 29 2c 20 69 73 20 72 6f 75 74 65 |LPSTB), is route| 00000460 64 20 74 6f 20 43 42 32 20 6f 66 20 74 68 65 20 |d to CB2 of the | 00000470 73 79 73 74 65 6d 20 56 49 41 2e 20 4c 69 67 68 |system VIA. Ligh| 00000480 74 20 70 65 6e 20 69 6e 74 65 72 72 75 70 74 73 |t pen interrupts| 00000490 20 61 72 65 20 6e 6f 74 0d 64 65 61 6c 74 20 77 | are not.dealt w| 000004a0 69 74 68 20 62 79 20 74 68 65 20 6f 70 65 72 61 |ith by the opera| 000004b0 74 69 6e 67 20 73 79 73 74 65 6d 20 61 6e 64 2c |ting system and,| 000004c0 20 77 68 65 6e 20 65 6e 61 62 6c 65 64 2c 20 74 | when enabled, t| 000004d0 68 65 79 20 61 72 65 20 61 6c 77 61 79 73 0d 70 |hey are always.p| 000004e0 61 73 73 65 64 20 66 69 72 73 74 20 74 6f 20 74 |assed first to t| 000004f0 68 65 20 70 61 67 65 64 20 52 4f 4d 73 20 61 6e |he paged ROMs an| 00000500 64 20 74 68 65 6e 20 74 6f 20 49 52 51 32 56 2c |d then to IRQ2V,| 00000510 20 74 68 65 20 73 65 63 6f 6e 64 61 72 79 20 69 | the secondary i| 00000520 6e 74 65 72 72 75 70 74 0d 72 65 71 75 65 73 74 |nterrupt.request| 00000530 20 76 65 63 74 6f 72 2e 0d 0d 54 68 65 72 65 20 | vector...There | 00000540 61 72 65 20 74 77 6f 20 36 35 32 32 20 56 49 41 |are two 6522 VIA| 00000550 73 20 69 6e 20 74 68 65 20 42 42 43 20 42 2e 20 |s in the BBC B. | 00000560 56 49 41 2d 41 20 69 73 20 75 73 65 64 20 66 6f |VIA-A is used fo| 00000570 72 20 69 6e 74 65 72 6e 61 6c 20 66 75 6e 63 74 |r internal funct| 00000580 69 6f 6e 73 0d 61 6e 64 20 74 68 65 20 6a 6f 79 |ions.and the joy| 00000590 73 74 69 63 6b 20 66 69 72 65 20 62 75 74 74 6f |stick fire butto| 000005a0 6e 73 20 61 6e 64 20 69 73 20 75 73 75 61 6c 6c |ns and is usuall| 000005b0 79 20 63 61 6c 6c 65 64 20 74 68 65 20 73 79 73 |y called the sys| 000005c0 74 65 6d 20 56 49 41 2e 20 56 49 41 2d 42 0d 70 |tem VIA. VIA-B.p| 000005d0 72 6f 76 69 64 65 73 20 74 68 65 20 70 61 72 61 |rovides the para| 000005e0 6c 6c 65 6c 20 70 72 69 6e 74 65 72 20 69 6e 74 |llel printer int| 000005f0 65 72 66 61 63 65 20 61 6e 64 20 74 68 65 20 75 |erface and the u| 00000600 73 65 72 20 70 6f 72 74 2e 20 41 20 36 35 32 32 |ser port. A 6522| 00000610 20 56 49 41 20 69 73 0d 71 75 69 74 65 20 61 20 | VIA is.quite a | 00000620 63 6f 6d 70 6c 65 78 20 64 65 76 69 63 65 20 63 |complex device c| 00000630 6f 6e 74 72 6f 6c 65 64 20 62 79 20 31 36 20 72 |ontroled by 16 r| 00000640 65 67 69 73 74 65 72 73 2e 20 54 68 65 20 73 79 |egisters. The sy| 00000650 73 74 65 6d 20 56 49 41 20 72 65 67 69 73 74 65 |stem VIA registe| 00000660 72 73 0d 61 72 65 20 6d 61 70 70 65 64 20 6f 6e |rs.are mapped on| 00000670 74 6f 20 53 68 65 69 6c 61 20 61 64 64 72 65 73 |to Sheila addres| 00000680 73 65 73 20 26 34 30 20 74 6f 20 26 34 46 20 28 |ses &40 to &4F (| 00000690 69 65 2e 20 26 46 45 34 30 20 74 6f 20 26 46 45 |ie. &FE40 to &FE| 000006a0 34 46 29 20 61 73 20 73 68 6f 77 6e 0d 69 6e 20 |4F) as shown.in | 000006b0 66 69 67 75 72 65 20 31 2e 0d 0d 0d 0d 20 20 20 |figure 1..... | 000006c0 20 20 20 20 20 41 64 64 72 65 73 73 20 20 20 20 | Address | 000006d0 20 20 20 20 20 20 20 20 20 44 65 73 63 72 69 70 | Descrip| 000006e0 74 69 6f 6e 20 20 20 20 20 20 20 20 20 20 20 20 |tion | 000006f0 20 20 20 20 44 65 73 69 67 6e 61 74 69 6f 6e 0d | Designation.| 00000700 20 20 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b | +-------+| 00000710 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000730 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-----+----------| 00000740 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 7c 20 26 46 |---+. | &F| 00000750 45 34 46 20 7c 20 44 61 74 61 20 72 65 67 69 73 |E4F | Data regis| 00000760 74 65 72 20 41 20 28 6e 6f 20 68 61 6e 64 73 68 |ter A (no handsh| 00000770 61 6b 65 29 20 20 20 20 20 20 7c 20 44 52 41 20 |ake) | DRA | 00000780 20 20 20 20 20 20 20 20 7c 0d 20 20 20 20 20 20 | |. | 00000790 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d | +-------+------| 000007a0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000007b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b |---------------+| 000007c0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 |-------------+. | 000007d0 20 20 20 20 20 20 7c 20 26 46 45 34 45 20 7c 20 | | &FE4E | | 000007e0 49 6e 74 65 72 72 75 70 74 20 65 6e 61 62 6c 65 |Interrupt enable| 000007f0 20 72 65 67 69 73 74 65 72 20 20 20 20 20 20 20 | register | 00000800 20 20 20 20 7c 20 49 45 52 20 20 20 20 20 20 20 | | IER | 00000810 20 20 7c 0d 20 20 20 20 20 20 20 2b 2d 2d 2d 2d | |. +----| 00000820 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |---+------------| 00000830 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000840 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d |---------+------| 00000850 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 |-------+. | 00000860 7c 20 26 46 45 34 44 20 7c 20 49 6e 74 65 72 72 || &FE4D | Interr| 00000870 75 70 74 20 66 6c 61 67 20 72 65 67 69 73 74 65 |upt flag registe| 00000880 72 20 20 20 20 20 20 20 20 20 20 20 20 20 7c 20 |r | | 00000890 49 46 52 20 20 20 20 20 20 20 20 20 7c 0d 20 20 |IFR |. | 000008a0 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d | +-------+--| 000008b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000008d0 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |---+------------| 000008e0 2d 2b 0d 20 20 20 20 20 20 20 7c 20 26 46 45 34 |-+. | &FE4| 000008f0 43 20 7c 20 50 65 72 69 70 68 65 72 61 6c 20 63 |C | Peripheral c| 00000900 6f 6e 74 72 6f 6c 20 72 65 67 69 73 74 65 72 20 |ontrol register | 00000910 20 20 20 20 20 20 20 20 7c 20 50 43 52 20 20 20 | | PCR | 00000920 20 20 20 20 20 20 7c 0d 20 20 20 20 20 20 20 2b | |. +| 00000930 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d |-------+--------| 00000940 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000950 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d |-------------+--| 00000960 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 |-----------+. | 00000970 20 20 20 20 7c 20 26 46 45 34 42 20 7c 20 41 75 | | &FE4B | Au| 00000980 78 69 6c 69 61 72 79 20 63 6f 6e 74 72 6f 6c 20 |xiliary control | 00000990 72 65 67 69 73 74 65 72 20 20 20 20 20 20 20 20 |register | 000009a0 20 20 7c 20 41 43 52 20 20 20 20 20 20 20 20 20 | | ACR | 000009b0 7c 0d 20 20 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d ||. +------| 000009c0 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-+--------------| 000009d0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000009e0 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d |-------+--------| 000009f0 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 7c 20 |-----+. | | 00000a00 26 46 45 34 41 20 7c 20 53 68 69 66 74 20 72 65 |&FE4A | Shift re| 00000a10 67 69 73 74 65 72 20 20 20 20 20 20 20 20 20 20 |gister | 00000a20 20 20 20 20 20 20 20 20 20 20 20 20 7c 20 53 52 | | SR| 00000a30 20 20 20 20 20 20 20 20 20 20 7c 0d 20 20 20 20 | |. | 00000a40 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +-------+----| 00000a50 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000a70 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b |-+-------------+| 00000a80 0d 20 20 20 20 20 20 20 7c 20 26 46 45 34 39 20 |. | &FE49 | 00000a90 7c 20 54 69 6d 65 72 20 32 20 69 6e 69 74 69 61 || Timer 2 initia| 00000aa0 74 65 20 63 6f 75 6e 74 20 20 20 20 20 20 20 20 |te count | 00000ab0 20 20 20 20 20 20 7c 20 54 32 43 48 20 20 20 20 | | T2CH | 00000ac0 20 20 20 20 7c 0d 20 20 20 20 20 20 20 2b 2d 2d | |. +--| 00000ad0 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-----+----------| 00000ae0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000af0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d |-----------+----| 00000b00 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 |---------+. | 00000b10 20 20 7c 20 26 46 45 34 38 20 7c 20 54 69 6d 65 | | &FE48 | Time| 00000b20 72 20 32 20 77 72 69 74 65 20 6c 61 74 63 68 2c |r 2 write latch,| 00000b30 20 72 65 61 64 20 63 6f 75 6e 74 65 72 20 20 20 | read counter | 00000b40 7c 20 54 32 43 4c 20 20 20 20 20 20 20 20 7c 0d || T2CL |.| 00000b50 20 20 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b | +-------+| 00000b60 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000b80 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-----+----------| 00000b90 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 7c 20 26 46 |---+. | &F| 00000ba0 45 34 37 20 7c 20 54 69 6d 65 72 20 31 20 6c 6f |E47 | Timer 1 lo| 00000bb0 61 64 20 6c 61 74 63 68 2c 20 68 69 67 68 20 62 |ad latch, high b| 00000bc0 79 74 65 20 20 20 20 20 20 20 7c 20 54 31 4c 48 |yte | T1LH| 00000bd0 20 20 20 20 20 20 20 20 7c 0d 20 20 20 20 20 20 | |. | 00000be0 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d | +-------+------| 00000bf0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000c00 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b |---------------+| 00000c10 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 |-------------+. | 00000c20 20 20 20 20 20 20 7c 20 26 46 45 34 36 20 7c 20 | | &FE46 | | 00000c30 54 69 6d 65 72 20 31 20 6c 6f 61 64 20 6c 61 74 |Timer 1 load lat| 00000c40 63 68 2c 20 6c 6f 77 20 62 79 74 65 20 20 20 20 |ch, low byte | 00000c50 20 20 20 20 7c 20 54 31 4c 4c 20 20 20 20 20 20 | | T1LL | 00000c60 20 20 7c 0d 20 20 20 20 20 20 20 2b 2d 2d 2d 2d | |. +----| 00000c70 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |---+------------| 00000c80 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000c90 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d |---------+------| 00000ca0 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 |-------+. | 00000cb0 7c 20 26 46 45 34 35 20 7c 20 54 69 6d 65 72 20 || &FE45 | Timer | 00000cc0 31 20 69 6e 69 74 69 61 74 65 20 63 6f 75 6e 74 |1 initiate count| 00000cd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7c 20 | | | 00000ce0 54 31 43 48 20 20 20 20 20 20 20 20 7c 0d 20 20 |T1CH |. | 00000cf0 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d | +-------+--| 00000d00 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000d20 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |---+------------| 00000d30 2d 2b 0d 20 20 20 20 20 20 20 7c 20 26 46 45 34 |-+. | &FE4| 00000d40 34 20 7c 20 54 69 6d 65 72 20 31 20 77 72 69 74 |4 | Timer 1 writ| 00000d50 65 20 6c 61 74 63 68 2c 20 72 65 61 64 20 63 6f |e latch, read co| 00000d60 75 6e 74 65 72 20 20 20 7c 20 54 31 43 4c 20 20 |unter | T1CL | 00000d70 20 20 20 20 20 20 7c 0d 20 20 20 20 20 20 20 2b | |. +| 00000d80 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d |-------+--------| 00000d90 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000da0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d |-------------+--| 00000db0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 |-----------+. | 00000dc0 20 20 20 20 7c 20 26 46 45 34 33 20 7c 20 44 61 | | &FE43 | Da| 00000dd0 74 61 20 64 69 72 65 63 74 69 6f 6e 20 72 65 67 |ta direction reg| 00000de0 69 73 74 65 72 20 41 20 20 20 20 20 20 20 20 20 |ister A | 00000df0 20 20 7c 20 44 44 52 41 20 20 20 20 20 20 20 20 | | DDRA | 00000e00 7c 0d 20 20 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d ||. +------| 00000e10 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-+--------------| 00000e20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000e30 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d |-------+--------| 00000e40 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 20 20 7c 20 |-----+. | | 00000e50 26 46 45 34 32 20 7c 20 44 61 74 61 20 64 69 72 |&FE42 | Data dir| 00000e60 65 63 74 69 6f 6e 20 72 65 67 69 73 74 65 72 20 |ection register | 00000e70 42 20 20 20 20 20 20 20 20 20 20 20 7c 20 44 44 |B | DD| 00000e80 52 42 20 20 20 20 20 20 20 20 7c 0d 20 20 20 20 |RB |. | 00000e90 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +-------+----| 00000ea0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000ec0 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b |-+-------------+| 00000ed0 0d 20 20 20 20 20 20 20 7c 20 26 46 45 34 31 20 |. | &FE41 | 00000ee0 7c 20 44 61 74 61 20 72 65 67 69 73 74 65 72 20 || Data register | 00000ef0 41 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |A | 00000f00 20 20 20 20 20 20 7c 20 44 52 41 20 20 20 20 20 | | DRA | 00000f10 20 20 20 20 7c 0d 20 20 20 20 20 20 20 2b 2d 2d | |. +--| 00000f20 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-----+----------| 00000f30 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00000f40 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d |-----------+----| 00000f50 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 20 20 20 20 20 |---------+. | 00000f60 20 20 7c 20 26 46 45 34 30 20 7c 20 44 61 74 61 | | &FE40 | Data| 00000f70 20 72 65 67 69 73 74 65 72 20 42 20 20 20 20 20 | register B | 00000f80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000f90 7c 20 44 52 42 20 20 20 20 20 20 20 20 20 7c 0d || DRB |.| 00000fa0 20 20 20 20 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b | +-------+| 00000fb0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00000fd0 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |-----+----------| 00000fe0 2d 2d 2d 2b 0d 0d 46 69 67 75 72 65 20 31 20 20 |---+..Figure 1 | 00000ff0 54 68 65 20 53 79 73 74 65 6d 20 56 49 41 20 72 |The System VIA r| 00001000 65 67 69 73 74 65 72 73 0d 2d 2d 2d 2d 2d 2d 2d |egisters.-------| 00001010 2d 20 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |- -------------| 00001020 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 46 6f |-----------...Fo| 00001030 75 72 20 6f 66 20 74 68 65 73 65 20 31 36 20 72 |ur of these 16 r| 00001040 65 67 69 73 74 65 72 73 20 61 72 65 20 6f 66 20 |egisters are of | 00001050 69 6e 74 65 72 65 73 74 20 77 68 65 6e 20 75 73 |interest when us| 00001060 69 6e 67 20 61 20 6c 69 67 68 74 20 70 65 6e 2e |ing a light pen.| 00001070 20 54 68 65 79 0d 61 72 65 20 64 61 74 61 20 72 | They.are data r| 00001080 65 67 69 73 74 65 72 20 42 20 28 26 46 45 34 30 |egister B (&FE40| 00001090 29 2c 20 74 68 65 20 70 65 72 69 70 68 65 72 61 |), the periphera| 000010a0 6c 20 63 6f 6e 74 72 6f 6c 20 72 65 67 69 73 74 |l control regist| 000010b0 65 72 20 28 26 46 45 34 43 29 2c 20 74 68 65 0d |er (&FE4C), the.| 000010c0 69 6e 74 65 72 72 75 70 74 20 66 6c 61 67 20 72 |interrupt flag r| 000010d0 65 67 69 73 74 65 72 20 28 26 46 45 34 44 29 2c |egister (&FE4D),| 000010e0 20 61 6e 64 20 74 68 65 20 69 6e 74 65 72 72 75 | and the interru| 000010f0 70 74 20 65 6e 61 62 6c 65 20 72 65 67 69 73 74 |pt enable regist| 00001100 65 72 0d 28 26 46 45 34 45 29 2e 0d 0d 42 6f 74 |er.(&FE4E)...Bot| 00001110 68 20 74 68 65 20 73 79 73 74 65 6d 20 56 49 41 |h the system VIA| 00001120 20 61 6e 64 20 74 68 65 20 75 73 65 72 20 56 49 | and the user VI| 00001130 41 20 68 61 76 65 20 32 30 20 49 2f 4f 20 6c 69 |A have 20 I/O li| 00001140 6e 65 73 20 67 72 6f 75 70 65 64 20 69 6e 74 6f |nes grouped into| 00001150 20 61 6e 20 41 0d 73 69 64 65 20 61 6e 64 20 61 | an A.side and a| 00001160 20 42 20 73 69 64 65 20 6f 66 20 31 30 20 6c 69 | B side of 10 li| 00001170 6e 65 73 20 65 61 63 68 2e 20 54 68 65 73 65 20 |nes each. These | 00001180 31 30 20 6c 69 6e 65 73 20 61 72 65 20 64 69 76 |10 lines are div| 00001190 69 64 65 64 20 69 6e 74 6f 20 38 20 64 61 74 61 |ided into 8 data| 000011a0 0d 6c 69 6e 65 73 20 61 6e 64 20 32 20 68 61 6e |.lines and 2 han| 000011b0 64 73 68 61 6b 65 20 6c 69 6e 65 73 2e 20 54 68 |dshake lines. Th| 000011c0 65 20 64 61 74 61 20 6c 69 6e 65 73 20 61 72 65 |e data lines are| 000011d0 20 63 61 6c 6c 65 64 20 50 41 30 20 74 6f 20 50 | called PA0 to P| 000011e0 41 37 20 6f 6e 20 74 68 65 20 41 0d 73 69 64 65 |A7 on the A.side| 000011f0 20 61 6e 64 20 50 42 30 20 74 6f 20 50 42 37 20 | and PB0 to PB7 | 00001200 6f 6e 20 74 68 65 20 42 20 73 69 64 65 2e 20 44 |on the B side. D| 00001210 61 74 61 20 6c 69 6e 65 73 20 50 41 30 20 74 6f |ata lines PA0 to| 00001220 20 50 41 37 20 63 61 6e 20 62 65 20 72 65 61 64 | PA7 can be read| 00001230 20 66 72 6f 6d 0d 6f 72 20 77 72 69 74 74 65 6e | from.or written| 00001240 20 74 6f 20 64 61 74 61 20 72 65 67 69 73 74 65 | to data registe| 00001250 72 20 41 20 61 6e 64 20 64 61 74 61 20 6c 69 6e |r A and data lin| 00001260 65 73 20 50 42 30 20 74 6f 20 50 42 37 20 63 61 |es PB0 to PB7 ca| 00001270 6e 20 62 65 20 72 65 61 64 20 66 72 6f 6d 0d 6f |n be read from.o| 00001280 72 20 77 72 69 74 74 65 6e 20 74 6f 20 64 61 74 |r written to dat| 00001290 61 20 72 65 67 69 73 74 65 72 20 42 2e 20 44 61 |a register B. Da| 000012a0 74 61 20 72 65 67 69 73 74 65 72 20 42 20 69 73 |ta register B is| 000012b0 20 75 73 65 66 75 6c 20 77 68 65 6e 20 77 72 69 | useful when wri| 000012c0 74 69 6e 67 0d 6c 69 67 68 74 20 70 65 6e 20 73 |ting.light pen s| 000012d0 6f 66 74 77 61 72 65 20 62 65 63 61 75 73 65 20 |oftware because | 000012e0 74 68 65 20 73 74 61 74 75 73 20 6f 66 20 74 68 |the status of th| 000012f0 65 20 74 77 6f 20 66 69 72 65 20 62 75 74 74 6f |e two fire butto| 00001300 6e 73 20 63 61 6e 20 62 65 20 72 65 61 64 0d 66 |ns can be read.f| 00001310 72 6f 6d 20 74 68 69 73 20 72 65 67 69 73 74 65 |rom this registe| 00001320 72 2e 20 54 68 65 20 72 69 67 68 74 20 66 69 72 |r. The right fir| 00001330 65 20 62 75 74 74 6f 6e 20 63 6c 65 61 72 73 20 |e button clears | 00001340 62 69 74 20 35 20 6f 66 20 44 52 42 20 77 68 65 |bit 5 of DRB whe| 00001350 6e 20 74 68 65 0d 62 75 74 74 6f 6e 20 69 73 20 |n the.button is | 00001360 63 6c 6f 73 65 64 20 61 6e 64 20 73 65 74 73 20 |closed and sets | 00001370 62 69 74 20 66 69 76 65 20 6f 66 20 44 52 42 20 |bit five of DRB | 00001380 77 68 65 6e 20 69 74 20 69 73 20 6f 70 65 6e 2e |when it is open.| 00001390 20 54 68 65 20 73 74 61 74 75 73 20 6f 66 0d 74 | The status of.t| 000013a0 68 65 20 6c 65 66 74 20 66 69 72 65 20 62 75 74 |he left fire but| 000013b0 74 6f 6e 20 63 61 6e 20 62 65 20 72 65 61 64 20 |ton can be read | 000013c0 66 72 6f 6d 20 62 69 74 20 34 20 6f 66 20 44 52 |from bit 4 of DR| 000013d0 42 2e 0d 0d 54 68 65 20 68 61 6e 64 73 68 61 6b |B...The handshak| 000013e0 65 20 6c 69 6e 65 73 20 61 72 65 20 63 61 6c 6c |e lines are call| 000013f0 65 64 20 43 41 31 20 61 6e 64 20 43 41 32 20 6f |ed CA1 and CA2 o| 00001400 6e 20 74 68 65 20 41 20 73 69 64 65 20 61 6e 64 |n the A side and| 00001410 20 43 42 31 20 61 6e 64 20 43 42 32 0d 6f 6e 20 | CB1 and CB2.on | 00001420 74 68 65 20 42 20 73 69 64 65 2e 20 4c 69 67 68 |the B side. Ligh| 00001430 74 20 70 65 6e 20 69 6e 74 65 72 72 75 70 74 73 |t pen interrupts| 00001440 20 61 72 65 20 72 6f 75 74 65 64 20 74 6f 20 43 | are routed to C| 00001450 42 32 20 6f 66 20 74 68 65 20 73 79 73 74 65 6d |B2 of the system| 00001460 20 56 49 41 2e 0d 54 68 65 20 70 65 72 69 70 68 | VIA..The periph| 00001470 65 72 61 6c 20 63 6f 6e 74 72 6f 6c 20 72 65 67 |eral control reg| 00001480 69 73 74 65 72 20 69 73 20 75 73 65 64 20 74 6f |ister is used to| 00001490 20 63 6f 6e 74 72 6f 6c 20 74 68 65 20 75 73 65 | control the use| 000014a0 20 6f 66 20 74 68 65 73 65 0d 68 61 6e 64 73 68 | of these.handsh| 000014b0 61 6b 65 20 6c 69 6e 65 73 2e 20 54 68 65 20 50 |ake lines. The P| 000014c0 43 52 20 61 6e 64 20 74 68 65 20 69 6e 74 65 72 |CR and the inter| 000014d0 70 72 65 74 61 74 69 6f 6e 20 6f 66 20 69 74 73 |pretation of its| 000014e0 20 62 69 74 73 20 69 73 20 73 68 6f 77 6e 20 69 | bits is shown i| 000014f0 6e 0d 66 69 67 75 72 65 20 32 2e 0d 0d 0d 0d 62 |n.figure 2.....b| 00001500 69 74 20 20 20 20 37 20 20 20 20 20 20 20 36 20 |it 7 6 | 00001510 20 20 20 20 20 20 35 20 20 20 20 20 20 20 34 20 | 5 4 | 00001520 20 20 20 20 20 20 33 20 20 20 20 20 20 20 32 20 | 3 2 | 00001530 20 20 20 20 20 20 31 20 20 20 20 20 20 20 30 0d | 1 0.| 00001540 20 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +-------+----| 00001550 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d |---+-------+----| * 00001580 2d 2d 2d 2b 0d 20 20 20 7c 20 20 20 20 20 20 20 |---+. | | 00001590 20 20 20 43 42 32 20 20 20 20 20 20 20 20 20 20 | CB2 | 000015a0 7c 20 20 43 42 31 20 20 7c 20 20 20 20 20 20 20 || CB1 | | 000015b0 20 20 20 43 41 32 20 20 20 20 20 20 20 20 20 20 | CA2 | 000015c0 7c 20 20 43 41 31 20 20 7c 0d 20 20 20 7c 20 20 || CA1 |. | | 000015d0 20 20 20 20 20 20 63 6f 6e 74 72 6f 6c 20 20 20 | control | 000015e0 20 20 20 20 20 7c 63 6f 6e 74 72 6f 6c 7c 20 20 | |control| | 000015f0 20 20 20 20 20 20 63 6f 6e 74 72 6f 6c 20 20 20 | control | 00001600 20 20 20 20 20 7c 63 6f 6e 74 72 6f 6c 7c 0d 20 | |control|. | 00001610 20 20 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d | +-------+-----| 00001620 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d |--+-------+-----| * 00001650 2d 2d 2b 0d 0d 0d 20 42 69 74 20 20 49 6e 74 65 |--+... Bit Inte| 00001660 72 70 72 65 74 61 74 69 6f 6e 20 69 66 20 62 69 |rpretation if bi| 00001670 74 20 63 6c 65 61 72 20 28 30 29 20 20 20 49 6e |t clear (0) In| 00001680 74 65 72 70 72 65 74 61 74 69 6f 6e 20 69 66 20 |terpretation if | 00001690 62 69 74 20 73 65 74 20 28 31 29 0d 2b 2d 2d 2d |bit set (1).+---| 000016a0 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 000016b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000016c0 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 000016d0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000016e0 2d 2d 2d 2d 2b 0d 7c 20 30 20 7c 53 65 74 20 62 |----+.| 0 |Set b| 000016f0 69 74 20 31 20 6f 66 20 49 46 52 20 6f 6e 20 2d |it 1 of IFR on -| 00001700 76 65 20 67 6f 69 6e 67 20 43 41 31 7c 53 65 74 |ve going CA1|Set| 00001710 20 62 69 74 20 31 20 6f 66 20 49 46 52 20 6f 6e | bit 1 of IFR on| 00001720 20 2b 76 65 20 67 6f 69 6e 67 20 43 41 31 7c 0d | +ve going CA1|.| 00001730 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---+-----------| 00001740 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001750 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d |------+---------| 00001760 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001770 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 31 20 7c 20 |--------+.| 1 | | 00001780 44 52 41 20 73 65 6c 65 63 74 65 64 20 74 6f 20 |DRA selected to | 00001790 63 6c 65 61 72 20 69 6e 74 65 72 72 75 70 74 20 |clear interrupt | 000017a0 7c 20 49 6e 74 65 72 72 75 70 74 20 6e 6f 74 20 || Interrupt not | 000017b0 63 6c 65 61 72 65 64 20 62 79 20 44 52 41 20 20 |cleared by DRA | 000017c0 20 20 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d | |.+---+-------| 000017d0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000017e0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d |----------+-----| 000017f0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001800 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 |------------+.| | 00001810 32 20 7c 53 65 74 20 62 69 74 20 30 20 6f 66 20 |2 |Set bit 0 of | 00001820 49 46 52 20 6f 6e 20 2d 76 65 20 67 6f 69 6e 67 |IFR on -ve going| 00001830 20 43 41 32 7c 53 65 74 20 62 69 74 20 30 20 6f | CA2|Set bit 0 o| 00001840 66 20 49 46 52 20 6f 6e 20 2b 76 65 20 67 6f 69 |f IFR on +ve goi| 00001850 6e 67 20 43 41 32 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d |ng CA2|.+---+---| 00001860 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001870 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d |--------------+-| 00001880 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000018a0 2b 0d 7c 20 33 20 7c 20 53 65 74 20 43 41 32 20 |+.| 3 | Set CA2 | 000018b0 74 6f 20 69 6e 70 75 74 20 6d 6f 64 65 20 20 20 |to input mode | 000018c0 20 20 20 20 20 20 20 20 7c 20 53 65 74 20 43 41 | | Set CA| 000018d0 32 20 74 6f 20 6f 75 74 70 75 74 20 6d 6f 64 65 |2 to output mode| 000018e0 20 20 20 20 20 20 20 20 20 20 7c 0d 2b 2d 2d 2d | |.+---| 000018f0 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 00001900 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001910 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 00001920 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001930 2d 2d 2d 2d 2b 0d 7c 20 34 20 7c 53 65 74 20 62 |----+.| 4 |Set b| 00001940 69 74 20 34 20 6f 66 20 49 46 52 20 6f 6e 20 2d |it 4 of IFR on -| 00001950 76 65 20 67 6f 69 6e 67 20 43 42 31 7c 53 65 74 |ve going CB1|Set| 00001960 20 62 69 74 20 34 20 6f 66 20 49 46 52 20 6f 6e | bit 4 of IFR on| 00001970 20 2b 76 65 20 67 6f 69 6e 67 20 43 42 31 7c 0d | +ve going CB1|.| 00001980 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---+-----------| 00001990 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000019a0 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d |------+---------| 000019b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000019c0 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 35 20 7c 20 |--------+.| 5 | | 000019d0 44 52 42 20 73 65 6c 65 63 74 65 64 20 74 6f 20 |DRB selected to | 000019e0 63 6c 65 61 72 20 69 6e 74 65 72 72 75 70 74 20 |clear interrupt | 000019f0 7c 20 49 6e 74 65 72 72 75 70 74 20 6e 6f 74 20 || Interrupt not | 00001a00 63 6c 65 61 72 65 64 20 62 79 20 44 52 42 20 20 |cleared by DRB | 00001a10 20 20 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d | |.+---+-------| 00001a20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001a30 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d |----------+-----| 00001a40 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001a50 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 |------------+.| | 00001a60 36 20 7c 53 65 74 20 62 69 74 20 33 20 6f 66 20 |6 |Set bit 3 of | 00001a70 49 46 52 20 6f 6e 20 2d 76 65 20 67 6f 69 6e 67 |IFR on -ve going| 00001a80 20 43 42 32 7c 53 65 74 20 62 69 74 20 33 20 6f | CB2|Set bit 3 o| 00001a90 66 20 49 46 52 20 6f 6e 20 2b 76 65 20 67 6f 69 |f IFR on +ve goi| 00001aa0 6e 67 20 43 42 32 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d |ng CB2|.+---+---| 00001ab0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001ac0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d |--------------+-| 00001ad0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00001af0 2b 0d 7c 20 37 20 7c 20 53 65 74 20 43 42 32 20 |+.| 7 | Set CB2 | 00001b00 74 6f 20 69 6e 70 75 74 20 6d 6f 64 65 20 20 20 |to input mode | 00001b10 20 20 20 20 20 20 20 20 7c 20 53 65 74 20 43 42 | | Set CB| 00001b20 32 20 74 6f 20 6f 75 74 70 75 74 20 6d 6f 64 65 |2 to output mode| 00001b30 20 20 20 20 20 20 20 20 20 20 7c 0d 2b 2d 2d 2d | |.+---| 00001b40 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 00001b50 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001b60 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 00001b70 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001b80 2d 2d 2d 2d 2b 0d 0d 46 69 67 75 72 65 20 32 20 |----+..Figure 2 | 00001b90 20 54 68 65 20 70 65 72 69 70 68 65 72 61 6c 20 | The peripheral | 00001ba0 63 6f 6e 74 72 6f 6c 20 72 65 67 69 73 74 65 72 |control register| 00001bb0 0d 2d 2d 2d 2d 2d 2d 2d 2d 20 20 2d 2d 2d 2d 2d |.-------- -----| 00001bc0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00001bd0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d 0d 54 68 65 |----------...The| 00001be0 20 6c 69 67 68 74 20 70 65 6e 20 69 6e 74 65 72 | light pen inter| 00001bf0 72 75 70 74 20 69 73 20 72 6f 75 74 65 64 20 74 |rupt is routed t| 00001c00 6f 20 43 42 32 20 61 6e 64 20 73 6f 20 62 69 74 |o CB2 and so bit| 00001c10 73 20 35 2c 20 36 20 61 6e 64 20 37 20 6f 66 20 |s 5, 6 and 7 of | 00001c20 74 68 65 0d 73 79 73 74 65 6d 20 56 49 41 20 50 |the.system VIA P| 00001c30 43 52 20 63 6f 6e 74 72 6f 6c 20 74 68 65 20 69 |CR control the i| 00001c40 6e 74 65 72 70 72 65 74 61 74 69 6f 6e 20 6f 66 |nterpretation of| 00001c50 20 74 68 65 20 76 69 64 65 6f 20 73 74 72 6f 62 | the video strob| 00001c60 65 20 70 75 6c 73 65 2e 20 57 65 0d 77 61 6e 74 |e pulse. We.want| 00001c70 20 75 73 65 20 43 42 32 20 69 6e 20 74 68 65 20 | use CB2 in the | 00001c80 69 6e 70 75 74 20 6d 6f 64 65 20 28 62 69 74 20 |input mode (bit | 00001c90 37 20 63 6c 65 61 72 29 2c 20 74 6f 20 67 65 6e |7 clear), to gen| 00001ca0 65 72 61 74 65 20 61 6e 20 69 6e 74 65 72 72 75 |erate an interru| 00001cb0 70 74 20 6f 6e 0d 61 20 6e 65 67 61 74 69 76 65 |pt on.a negative| 00001cc0 20 67 6f 69 6e 67 20 70 75 6c 73 65 20 28 62 69 | going pulse (bi| 00001cd0 74 20 36 20 63 6c 65 61 72 29 20 61 6e 64 20 74 |t 6 clear) and t| 00001ce0 6f 20 63 6c 65 61 72 20 74 68 65 20 69 6e 74 65 |o clear the inte| 00001cf0 72 72 75 70 74 20 77 68 65 6e 20 44 52 42 0d 69 |rrupt when DRB.i| 00001d00 73 20 73 65 6c 65 63 74 65 64 20 28 62 69 74 20 |s selected (bit | 00001d10 35 20 63 6c 65 61 72 29 2e 20 54 68 69 73 20 69 |5 clear). This i| 00001d20 73 20 71 75 69 74 65 20 63 6f 6e 76 65 6e 69 65 |s quite convenie| 00001d30 6e 74 20 62 65 63 61 75 73 65 2c 20 62 79 20 64 |nt because, by d| 00001d40 65 66 61 75 6c 74 2c 0d 62 69 74 73 20 35 2c 20 |efault,.bits 5, | 00001d50 36 20 61 6e 64 20 37 20 6f 66 20 74 68 65 20 73 |6 and 7 of the s| 00001d60 79 73 74 65 6d 20 50 43 52 20 61 72 65 20 63 6c |ystem PCR are cl| 00001d70 65 61 72 2e 20 55 6e 6c 65 73 73 20 74 68 65 73 |ear. Unless thes| 00001d80 65 20 62 69 74 73 20 68 61 76 65 20 62 65 65 6e |e bits have been| 00001d90 0d 63 68 61 6e 67 65 64 20 66 72 6f 6d 20 74 68 |.changed from th| 00001da0 65 69 72 20 64 65 66 61 75 6c 74 20 76 61 6c 75 |eir default valu| 00001db0 65 73 20 79 6f 75 20 64 6f 20 6e 6f 74 20 68 61 |es you do not ha| 00001dc0 76 65 20 74 6f 20 61 6c 74 65 72 20 74 68 65 20 |ve to alter the | 00001dd0 63 6f 6e 74 65 6e 74 73 20 6f 66 0d 74 68 65 20 |contents of.the | 00001de0 50 43 52 20 74 6f 20 75 73 65 20 6c 69 67 68 74 |PCR to use light| 00001df0 20 70 65 6e 20 69 6e 74 65 72 72 75 70 74 73 2e | pen interrupts.| 00001e00 0d 0d 4c 69 67 68 74 20 70 65 6e 20 69 6e 74 65 |..Light pen inte| 00001e10 72 72 75 70 74 73 20 61 72 65 20 65 6e 61 62 6c |rrupts are enabl| 00001e20 65 64 20 62 79 20 73 65 74 74 69 6e 67 20 62 69 |ed by setting bi| 00001e30 74 20 33 20 6f 66 20 74 68 65 20 69 6e 74 65 72 |t 3 of the inter| 00001e40 72 75 70 74 20 65 6e 61 62 6c 65 0d 72 65 67 69 |rupt enable.regi| 00001e50 73 74 65 72 2e 20 53 65 74 74 69 6e 67 20 74 68 |ster. Setting th| 00001e60 69 73 20 62 69 74 20 75 73 65 73 20 61 6e 20 6f |is bit uses an o| 00001e70 64 64 20 6d 65 74 68 6f 64 2e 20 54 6f 20 61 6c |dd method. To al| 00001e80 74 65 72 20 61 20 62 69 74 20 69 6e 20 74 68 65 |ter a bit in the| 00001e90 20 49 45 52 0d 79 6f 75 20 6d 75 73 74 20 77 72 | IER.you must wr| 00001ea0 69 74 65 20 61 20 6e 75 6d 62 65 72 20 74 6f 20 |ite a number to | 00001eb0 74 68 65 20 49 45 52 20 77 69 74 68 20 61 20 31 |the IER with a 1| 00001ec0 20 69 6e 20 74 68 65 20 73 61 6d 65 20 62 69 74 | in the same bit| 00001ed0 20 70 6f 73 69 74 69 6f 6e 2e 20 49 66 0d 62 69 | position. If.bi| 00001ee0 74 20 37 20 6f 66 20 74 68 65 20 6e 75 6d 62 65 |t 7 of the numbe| 00001ef0 72 20 69 73 20 61 20 31 20 74 68 65 6e 20 74 68 |r is a 1 then th| 00001f00 65 20 73 65 6c 65 63 74 65 64 20 62 69 74 20 28 |e selected bit (| 00001f10 6f 72 20 62 69 74 73 29 20 77 69 6c 6c 20 61 6c |or bits) will al| 00001f20 73 6f 20 62 65 0d 73 65 74 20 74 6f 20 31 2e 20 |so be.set to 1. | 00001f30 49 66 20 62 69 74 20 37 20 6f 66 20 74 68 65 20 |If bit 7 of the | 00001f40 6e 75 6d 62 65 72 20 69 73 20 30 20 74 68 65 6e |number is 0 then| 00001f50 20 74 68 65 20 73 65 6c 65 63 74 65 64 20 62 69 | the selected bi| 00001f60 74 20 28 6f 72 20 62 69 74 73 29 20 77 69 6c 6c |t (or bits) will| 00001f70 0d 62 65 20 63 6c 65 61 72 65 64 2e 20 54 68 65 |.be cleared. The| 00001f80 20 73 65 6c 65 63 74 65 64 20 62 69 74 73 20 28 | selected bits (| 00001f90 30 20 74 6f 20 36 29 20 61 72 65 20 73 65 74 20 |0 to 6) are set | 00001fa0 74 6f 20 74 68 65 20 73 61 6d 65 20 73 74 61 74 |to the same stat| 00001fb0 65 20 61 73 20 62 69 74 20 37 2e 0d 54 6f 20 73 |e as bit 7..To s| 00001fc0 65 74 20 62 69 74 20 33 20 6f 66 20 74 68 65 20 |et bit 3 of the | 00001fd0 49 45 52 20 79 6f 75 20 68 61 76 65 20 74 6f 20 |IER you have to | 00001fe0 77 72 69 74 65 20 74 68 65 20 6e 75 6d 62 65 72 |write the number| 00001ff0 20 26 38 38 20 28 25 31 30 30 30 31 30 30 30 29 | &88 (%10001000)| 00002000 20 69 6e 74 6f 0d 74 68 65 20 49 45 52 2e 20 42 | into.the IER. B| 00002010 69 74 20 33 20 77 69 6c 6c 20 74 68 65 6e 20 74 |it 3 will then t| 00002020 61 6b 65 20 74 68 65 20 76 61 6c 75 65 20 6f 66 |ake the value of| 00002030 20 62 69 74 20 37 20 61 6e 64 20 77 69 6c 6c 20 | bit 7 and will | 00002040 62 65 20 73 65 74 2e 0d 0d 57 68 65 6e 20 62 69 |be set...When bi| 00002050 74 20 33 20 6f 66 20 74 68 65 20 49 45 52 20 69 |t 3 of the IER i| 00002060 73 20 73 65 74 20 61 20 6e 65 67 61 74 69 76 65 |s set a negative| 00002070 20 74 72 61 6e 73 69 74 69 6f 6e 20 6f 6e 20 43 | transition on C| 00002080 42 32 20 77 69 6c 6c 20 73 65 74 20 62 69 74 20 |B2 will set bit | 00002090 33 0d 6f 66 20 74 68 65 20 69 6e 74 65 72 72 75 |3.of the interru| 000020a0 70 74 20 66 6c 61 67 20 72 65 67 69 73 74 65 72 |pt flag register| 000020b0 20 61 6e 64 20 67 65 6e 65 72 61 74 65 20 61 6e | and generate an| 000020c0 20 49 52 51 20 69 6e 74 65 72 72 75 70 74 2e 20 | IRQ interrupt. | 000020d0 54 68 69 73 20 63 61 6e 20 62 65 0d 72 65 63 6f |This can be.reco| 000020e0 67 6e 69 73 65 64 20 62 65 63 61 75 73 65 20 62 |gnised because b| 000020f0 6f 74 68 20 62 69 74 73 20 37 20 61 6e 64 20 33 |oth bits 7 and 3| 00002100 20 6f 66 20 49 46 52 20 77 69 6c 6c 20 62 65 20 | of IFR will be | 00002110 73 65 74 2e 20 4c 69 67 68 74 20 70 65 6e 0d 69 |set. Light pen.i| 00002120 6e 74 65 72 72 75 70 74 73 20 61 72 65 20 64 69 |nterrupts are di| 00002130 73 61 62 6c 65 64 20 62 79 20 77 72 69 74 69 6e |sabled by writin| 00002140 67 20 74 68 65 20 6e 75 6d 62 65 72 20 26 30 38 |g the number &08| 00002150 20 28 25 30 30 30 30 31 30 30 30 29 20 69 6e 74 | (%00001000) int| 00002160 6f 20 74 68 65 0d 49 45 52 2e 20 54 68 69 73 20 |o the.IER. This | 00002170 63 6c 65 61 72 73 20 62 69 74 20 33 20 6f 66 20 |clears bit 3 of | 00002180 74 68 65 20 49 45 52 20 73 6f 20 74 68 61 74 20 |the IER so that | 00002190 61 20 6e 65 67 61 74 69 76 65 20 67 6f 69 6e 67 |a negative going| 000021a0 20 74 72 61 6e 73 69 74 69 6f 6e 20 6f 6e 0d 43 | transition on.C| 000021b0 42 32 20 77 69 6c 6c 20 73 74 69 6c 6c 20 73 65 |B2 will still se| 000021c0 74 20 62 69 74 20 33 20 6f 66 20 74 68 65 20 49 |t bit 3 of the I| 000021d0 46 52 20 62 75 74 20 69 74 20 77 69 6c 6c 20 6e |FR but it will n| 000021e0 6f 74 20 67 65 6e 65 72 61 74 65 20 61 6e 20 49 |ot generate an I| 000021f0 52 51 0d 69 6e 74 65 72 72 75 70 74 2e 20 4c 69 |RQ.interrupt. Li| 00002200 67 68 74 20 70 65 6e 20 69 6e 74 65 72 72 75 70 |ght pen interrup| 00002210 74 73 20 61 72 65 20 75 73 75 61 6c 6c 79 20 65 |ts are usually e| 00002220 6e 61 62 6c 65 64 20 77 69 74 68 20 3f 26 46 45 |nabled with ?&FE| 00002230 34 45 3d 26 38 38 20 6f 72 20 2a 46 58 0d 31 35 |4E=&88 or *FX.15| 00002240 31 2c 37 38 2c 31 33 36 20 61 6e 64 20 64 69 73 |1,78,136 and dis| 00002250 61 62 6c 65 64 20 77 69 74 68 20 3f 26 46 45 34 |abled with ?&FE4| 00002260 45 3d 26 30 38 20 6f 72 20 2a 46 58 20 31 35 31 |E=&08 or *FX 151| 00002270 2c 37 38 2c 38 0d 0d 54 68 65 20 69 6e 74 65 72 |,78,8..The inter| 00002280 72 75 70 74 20 65 6e 61 62 6c 65 20 61 6e 64 20 |rupt enable and | 00002290 69 6e 74 65 72 72 75 70 74 20 66 6c 61 67 20 72 |interrupt flag r| 000022a0 65 67 69 73 74 65 72 73 20 77 6f 72 6b 20 61 73 |egisters work as| 000022b0 20 61 20 70 61 69 72 20 61 6e 64 20 74 68 65 0d | a pair and the.| 000022c0 66 6c 61 67 20 72 65 67 69 73 74 65 72 20 63 61 |flag register ca| 000022d0 6e 20 62 65 20 69 6e 74 65 72 72 6f 67 61 74 65 |n be interrogate| 000022e0 64 20 62 79 20 61 20 70 72 6f 67 72 61 6d 20 74 |d by a program t| 000022f0 6f 20 73 65 65 20 69 66 20 61 20 6c 69 67 68 74 |o see if a light| 00002300 20 70 65 6e 20 69 73 0d 74 68 65 20 73 6f 75 72 | pen is.the sour| 00002310 63 65 20 6f 66 20 61 6e 20 69 6e 74 65 72 72 75 |ce of an interru| 00002320 70 74 2e 20 54 68 65 20 69 6e 74 65 72 70 72 65 |pt. The interpre| 00002330 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 62 69 |tation of the bi| 00002340 74 73 20 69 6e 20 74 68 65 20 73 79 73 74 65 6d |ts in the system| 00002350 0d 56 49 41 20 69 6e 74 65 72 72 75 70 74 20 66 |.VIA interrupt f| 00002360 6c 61 67 20 72 65 67 69 73 74 65 72 20 69 73 20 |lag register is | 00002370 74 61 62 75 6c 61 74 65 64 20 69 6e 20 66 69 67 |tabulated in fig| 00002380 75 72 65 20 33 20 77 68 69 63 68 20 73 68 6f 77 |ure 3 which show| 00002390 73 20 74 68 61 74 20 62 69 74 73 0d 37 20 61 6e |s that bits.7 an| 000023a0 64 20 33 20 6f 66 20 74 68 65 20 49 46 52 20 77 |d 3 of the IFR w| 000023b0 69 6c 6c 20 62 65 20 73 65 74 20 69 66 20 61 20 |ill be set if a | 000023c0 6c 69 67 68 74 20 70 65 6e 20 69 73 20 74 68 65 |light pen is the| 000023d0 20 73 6f 75 72 63 65 20 6f 66 20 61 6e 0d 69 6e | source of an.in| 000023e0 74 65 72 72 75 70 74 2e 20 49 66 20 65 69 74 68 |terrupt. If eith| 000023f0 65 72 20 62 69 74 20 37 20 6f 72 20 62 69 74 20 |er bit 7 or bit | 00002400 33 20 6f 66 20 74 68 65 20 49 46 52 20 69 73 20 |3 of the IFR is | 00002410 63 6c 65 61 72 20 74 68 65 6e 20 61 20 6c 69 67 |clear then a lig| 00002420 68 74 20 70 65 6e 0d 77 61 73 20 6e 6f 74 20 74 |ht pen.was not t| 00002430 68 65 20 73 6f 75 72 63 65 20 6f 66 20 61 6e 20 |he source of an | 00002440 69 6e 74 65 72 72 75 70 74 2e 0d 0d 0d 0d 20 20 |interrupt..... | 00002450 20 20 20 20 20 20 20 20 20 20 20 37 20 20 20 20 | 7 | 00002460 20 20 20 36 20 20 20 20 20 35 20 20 20 20 20 34 | 6 5 4| 00002470 20 20 20 20 20 33 20 20 20 20 20 32 20 20 20 20 | 3 2 | 00002480 20 31 20 20 20 20 20 30 0d 20 20 20 20 20 20 20 | 1 0. | 00002490 20 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +---------+----| 000024a0 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d |-+-----+-----+--| 000024b0 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b |---+-----+-----+| 000024c0 2d 2d 2d 2d 2d 2b 0d 20 20 26 46 45 34 45 20 7c |-----+. &FE4E || 000024d0 53 65 74 2f 43 6c 65 61 72 7c 20 54 31 20 20 7c |Set/Clear| T1 || 000024e0 20 54 32 20 20 7c 20 43 42 31 20 7c 20 43 42 32 | T2 | CB1 | CB2| 000024f0 20 7c 20 53 52 20 20 7c 20 43 41 31 20 7c 20 43 | | SR | CA1 | C| 00002500 41 32 20 7c 20 49 45 52 0d 20 20 20 20 20 20 20 |A2 | IER. | 00002510 20 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +---------+----| 00002520 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d |-+-----+-----+--| 00002530 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b |---+-----+-----+| 00002540 2d 2d 2d 2d 2d 2b 0d 20 20 26 46 45 34 44 20 7c |-----+. &FE4D || 00002550 20 20 20 49 52 51 20 20 20 7c 20 54 31 20 20 7c | IRQ | T1 || 00002560 20 54 32 20 20 7c 20 43 42 31 20 7c 20 43 42 32 | T2 | CB1 | CB2| 00002570 20 7c 20 53 52 20 20 7c 20 43 41 31 20 7c 20 43 | | SR | CA1 | C| 00002580 41 32 20 7c 20 49 46 52 0d 20 20 20 20 20 20 20 |A2 | IFR. | 00002590 20 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d | +---------+----| 000025a0 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d |-+-----+-----+--| 000025b0 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2b |---+-----+-----+| 000025c0 2d 2d 2d 2d 2d 2b 0d 0d 0d 0d 20 42 69 74 20 20 |-----+.... Bit | 000025d0 20 43 61 75 73 65 20 6f 66 20 69 6e 74 65 72 72 | Cause of interr| 000025e0 75 70 74 20 20 20 20 20 20 20 20 49 6e 74 65 72 |upt Inter| 000025f0 70 72 65 74 61 74 69 6f 6e 0d 2b 2d 2d 2d 2b 2d |pretation.+---+-| 00002600 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002610 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d |--------+-------| 00002620 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002640 2d 2d 2b 0d 7c 20 30 20 7c 20 43 68 61 6e 67 65 |--+.| 0 | Change| 00002650 20 6f 66 20 73 69 67 6e 61 6c 20 6f 6e 20 43 41 | of signal on CA| 00002660 32 20 7c 20 4b 65 79 20 70 72 65 73 73 65 64 20 |2 | Key pressed | 00002670 6f 6e 20 6b 65 79 62 6f 61 72 64 20 20 20 20 20 |on keyboard | 00002680 20 20 20 20 20 20 20 20 20 20 20 20 7c 0d 2b 2d | |.+-| 00002690 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 000026a0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d |------------+---| 000026b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 000026d0 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 31 20 7c 20 43 68 |------+.| 1 | Ch| 000026e0 61 6e 67 65 20 6f 66 20 73 69 67 6e 61 6c 20 6f |ange of signal o| 000026f0 6e 20 43 41 31 20 7c 20 56 65 72 74 69 63 61 6c |n CA1 | Vertical| 00002700 20 73 79 6e 63 20 70 75 6c 73 65 20 20 20 20 20 | sync pulse | 00002710 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002720 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d ||.+---+---------| 00002730 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002740 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 00002750 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002760 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 32 20 |----------+.| 2 | 00002770 7c 20 43 6f 6d 70 6c 65 74 69 6f 6e 20 6f 66 20 || Completion of | 00002780 38 20 73 68 69 66 74 73 20 20 7c 20 53 68 69 66 |8 shifts | Shif| 00002790 74 20 72 65 67 69 73 74 65 72 20 69 73 20 6e 6f |t register is no| 000027a0 74 20 75 73 65 64 20 62 79 20 73 79 73 74 65 6d |t used by system| 000027b0 2e 20 20 20 7c 0d 7c 20 20 20 7c 20 69 6e 20 74 |. |.| | in t| 000027c0 68 65 20 73 68 69 66 74 20 72 65 67 69 73 74 65 |he shift registe| 000027d0 72 20 20 20 7c 20 41 6c 77 61 79 73 20 70 61 73 |r | Always pas| 000027e0 73 65 64 20 74 6f 20 49 52 51 32 56 20 20 20 20 |sed to IRQ2V | 000027f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7c 0d | |.| 00002800 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---+-----------| 00002810 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d |--------------+-| 00002820 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002840 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 33 20 7c 20 |--------+.| 3 | | 00002850 43 68 61 6e 67 65 20 6f 66 20 73 69 67 6e 61 6c |Change of signal| 00002860 20 6f 6e 20 43 42 32 20 7c 20 4c 69 67 68 74 20 | on CB2 | Light | 00002870 70 65 6e 20 69 6e 74 65 72 72 75 70 74 2e 20 4e |pen interrupt. N| 00002880 6f 74 20 75 73 65 64 20 62 79 20 73 79 73 74 65 |ot used by syste| 00002890 6d 20 7c 0d 7c 20 20 20 7c 20 20 20 20 20 20 20 |m |.| | | 000028a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000028b0 20 20 7c 20 41 6c 77 61 79 73 20 70 61 73 73 65 | | Always passe| 000028c0 64 20 74 6f 20 75 73 65 72 20 72 6f 75 74 69 6e |d to user routin| 000028d0 65 20 76 69 61 20 49 52 51 32 56 20 7c 0d 2b 2d |e via IRQ2V |.+-| 000028e0 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 000028f0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d |------------+---| 00002900 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002920 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 34 20 7c 20 43 68 |------+.| 4 | Ch| 00002930 61 6e 67 65 20 6f 66 20 73 69 67 6e 61 6c 20 6f |ange of signal o| 00002940 6e 20 43 42 31 20 7c 20 41 44 43 20 63 6f 6e 76 |n CB1 | ADC conv| 00002950 65 72 73 69 6f 6e 20 63 6f 6d 70 6c 65 74 65 64 |ersion completed| 00002960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00002970 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d ||.+---+---------| 00002980 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002990 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |+---------------| 000029a0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 000029b0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d 7c 20 35 20 |----------+.| 5 | 000029c0 7c 20 54 69 6d 65 72 20 32 20 63 6f 6d 70 6c 65 || Timer 2 comple| 000029d0 74 65 20 20 20 20 20 20 20 20 7c 20 43 75 72 72 |te | Curr| 000029e0 65 6e 74 20 73 70 65 65 63 68 20 77 6f 72 64 20 |ent speech word | 000029f0 63 6f 6d 70 6c 65 74 65 20 20 20 20 20 20 20 20 |complete | 00002a00 20 20 20 20 7c 0d 2b 2d 2d 2d 2b 2d 2d 2d 2d 2d | |.+---+-----| 00002a10 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002a20 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----+-----------| 00002a30 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002a40 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0d |--------------+.| 00002a50 7c 20 36 20 7c 20 54 69 6d 65 72 20 31 20 63 6f || 6 | Timer 1 co| 00002a60 6d 70 6c 65 74 65 20 20 20 20 20 20 20 20 7c 20 |mplete | | 00002a70 49 6e 63 72 65 6d 65 6e 74 20 69 6e 74 65 72 6e |Increment intern| 00002a80 61 6c 20 63 6c 6f 63 6b 20 20 20 20 20 20 20 20 |al clock | 00002a90 20 20 20 20 20 20 20 20 7c 0d 2b 2d 2d 2d 2b 2d | |.+---+-| 00002aa0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| 00002ab0 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d |--------+-------| 00002ac0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002ae0 2d 2d 2b 0d 7c 20 37 20 7c 20 41 6e 79 20 62 69 |--+.| 7 | Any bi| 00002af0 74 2c 20 30 20 74 6f 20 36 2c 20 69 73 20 73 65 |t, 0 to 6, is se| 00002b00 74 20 7c 20 4f 6e 65 20 6f 66 20 74 68 65 20 61 |t | One of the a| 00002b10 62 6f 76 65 20 69 6e 74 65 72 72 75 70 74 73 20 |bove interrupts | 00002b20 68 61 73 20 6f 63 63 75 72 65 64 20 7c 0d 2b 2d |has occured |.+-| 00002b30 2d 2d 2b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |--+-------------| 00002b40 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 2d 2d 2d |------------+---| 00002b50 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002b70 2d 2d 2d 2d 2d 2d 2b 0d 0d 46 69 67 75 72 65 20 |------+..Figure | 00002b80 33 2e 20 54 68 65 20 69 6e 74 65 72 70 72 65 74 |3. The interpret| 00002b90 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 73 79 73 |ation of the sys| 00002ba0 74 65 6d 20 69 6e 74 65 72 72 75 70 74 20 66 6c |tem interrupt fl| 00002bb0 61 67 20 72 65 67 69 73 74 65 72 0d 2d 2d 2d 2d |ag register.----| 00002bc0 2d 2d 2d 2d 2d 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----- ----------| 00002bd0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d |----------------| * 00002bf0 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0d |--------------..| 00002c00 0d 41 20 70 72 6f 67 72 61 6d 20 73 68 6f 75 6c |.A program shoul| 00002c10 64 20 69 6e 74 65 72 6f 67 61 74 65 20 62 69 74 |d interogate bit| 00002c20 73 20 37 20 61 6e 64 20 33 20 6f 66 20 74 68 65 |s 7 and 3 of the| 00002c30 20 73 79 73 74 65 6d 20 49 46 52 20 74 6f 20 66 | system IFR to f| 00002c40 69 6e 64 20 6f 75 74 20 69 66 0d 61 20 6c 69 67 |ind out if.a lig| 00002c50 68 74 20 70 65 6e 20 69 73 20 74 68 65 20 73 6f |ht pen is the so| 00002c60 75 72 63 65 20 6f 66 20 61 6e 20 49 52 51 20 69 |urce of an IRQ i| 00002c70 6e 74 65 72 72 75 70 74 2e 20 49 66 20 69 74 20 |nterrupt. If it | 00002c80 69 73 20 74 68 65 6e 20 74 68 65 20 69 6e 74 65 |is then the inte| 00002c90 72 72 75 70 74 0d 6d 75 73 74 20 62 65 20 63 6c |rrupt.must be cl| 00002ca0 65 61 72 65 64 20 62 79 20 72 65 61 64 69 6e 67 |eared by reading| 00002cb0 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 6f 66 | the contents of| 00002cc0 20 44 52 42 20 28 62 65 63 61 75 73 65 20 62 69 | DRB (because bi| 00002cd0 74 20 35 20 6f 66 20 74 68 65 20 50 43 52 0d 69 |t 5 of the PCR.i| 00002ce0 73 20 63 6c 65 61 72 29 2e 20 59 6f 75 20 63 61 |s clear). You ca| 00002cf0 6e 20 74 68 65 72 65 66 6f 72 65 20 72 65 61 64 |n therefore read| 00002d00 20 74 68 65 20 73 74 61 74 75 73 20 6f 66 20 74 | the status of t| 00002d10 68 65 20 66 69 72 65 20 62 75 74 74 6f 6e 73 20 |he fire buttons | 00002d20 61 6e 64 20 63 6c 65 61 72 0d 74 68 65 20 69 6e |and clear.the in| 00002d30 74 65 72 72 75 70 74 20 61 74 20 74 68 65 20 73 |terrupt at the s| 00002d40 61 6d 65 20 74 69 6d 65 2e 0d 0d 54 68 65 20 70 |ame time...The p| 00002d50 72 6f 67 72 61 6d 20 49 4f 49 4e 54 45 52 20 75 |rogram IOINTER u| 00002d60 73 65 73 20 74 68 69 73 20 6d 65 74 68 6f 64 20 |ses this method | 00002d70 61 6e 64 20 73 74 6f 72 65 73 20 74 68 65 20 73 |and stores the s| 00002d80 74 61 74 75 73 20 6f 66 20 74 68 65 20 72 69 67 |tatus of the rig| 00002d90 68 74 0d 66 69 72 65 20 62 75 74 74 6f 6e 20 69 |ht.fire button i| 00002da0 6e 20 6d 65 6d 6f 72 79 20 6c 6f 63 61 74 69 6f |n memory locatio| 00002db0 6e 20 26 37 32 20 66 6f 72 20 74 68 65 20 70 72 |n &72 for the pr| 00002dc0 6f 67 61 6d 20 75 73 65 72 20 74 6f 20 61 63 63 |ogam user to acc| 00002dd0 65 73 73 20 69 66 20 68 65 20 6f 72 0d 73 68 65 |ess if he or.she| 00002de0 20 77 61 6e 74 73 20 74 6f 20 6b 6e 6f 77 20 74 | wants to know t| 00002df0 68 65 20 66 69 72 65 20 62 75 74 74 6f 6e 20 73 |he fire button s| 00002e00 74 61 74 75 73 20 61 74 20 74 68 65 20 6c 61 73 |tatus at the las| 00002e10 74 20 6c 69 67 68 74 20 70 65 6e 20 69 6e 74 65 |t light pen inte| 00002e20 72 72 75 70 74 2e 0d 54 68 69 73 20 77 69 6c 6c |rrupt..This will| 00002e30 20 6f 6e 6c 79 20 62 65 20 75 73 65 66 75 6c 20 | only be useful | 00002e40 69 66 20 74 68 65 20 52 48 20 63 6f 6d 70 61 74 |if the RH compat| 00002e50 69 62 6c 65 20 64 65 73 69 67 6e 20 69 73 20 75 |ible design is u| 00002e60 73 65 64 20 62 75 74 20 69 74 20 64 6f 65 73 0d |sed but it does.| 00002e70 6e 6f 74 20 6d 65 61 6e 20 74 68 61 74 20 6f 74 |not mean that ot| 00002e80 68 65 72 20 74 79 70 65 73 20 6f 66 20 6c 69 67 |her types of lig| 00002e90 68 74 20 70 65 6e 20 63 61 6e 6e 6f 74 20 75 73 |ht pen cannot us| 00002ea0 65 20 74 68 65 20 73 6f 66 74 77 61 72 65 2e 20 |e the software. | 00002eb0 54 68 65 20 66 69 72 65 0d 62 75 74 74 6f 6e 20 |The fire.button | 00002ec0 73 74 61 74 75 73 20 61 74 20 74 68 65 20 6c 61 |status at the la| 00002ed0 73 74 20 69 6e 74 65 72 72 75 70 74 20 69 73 20 |st interrupt is | 00002ee0 6e 6f 74 20 6e 65 63 65 73 73 61 72 69 6c 79 20 |not necessarily | 00002ef0 74 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 0d |the same as the.| 00002f00 63 75 72 72 65 6e 74 20 66 69 72 65 20 62 75 74 |current fire but| 00002f10 74 6f 6e 20 73 74 61 74 75 73 20 61 6e 64 20 6e |ton status and n| 00002f20 6f 6e 65 20 6f 66 20 74 68 65 20 64 65 6d 6f 6e |one of the demon| 00002f30 73 74 72 61 74 69 6f 6e 20 70 72 6f 67 72 61 6d |stration program| 00002f40 73 20 69 6e 20 74 68 69 73 0d 73 65 72 69 65 73 |s in this.series| 00002f50 20 61 63 74 75 61 6c 6c 79 20 75 73 65 20 74 68 | actually use th| 00002f60 65 20 73 74 61 74 75 73 20 61 74 20 74 68 65 20 |e status at the | 00002f70 6c 61 73 74 20 69 6e 74 65 72 72 75 70 74 2e 20 |last interrupt. | 00002f80 49 6e 20 61 6c 6c 20 74 68 65 0d 64 65 6d 6f 6e |In all the.demon| 00002f90 73 74 72 61 74 69 6f 6e 20 70 72 6f 67 72 61 6d |stration program| 00002fa0 73 20 77 68 69 63 68 20 75 73 65 20 61 20 6c 69 |s which use a li| 00002fb0 67 68 74 20 70 65 6e 20 73 77 69 74 63 68 2c 20 |ght pen switch, | 00002fc0 74 68 65 20 63 75 72 72 65 6e 74 20 73 74 61 74 |the current stat| 00002fd0 75 73 20 69 73 0d 64 65 74 65 72 6d 69 6e 65 64 |us is.determined| 00002fe0 20 62 79 20 74 68 65 20 42 41 53 49 43 20 66 75 | by the BASIC fu| 00002ff0 6e 63 74 69 6f 6e 20 46 4e 73 77 69 74 63 68 20 |nction FNswitch | 00003000 77 68 69 63 68 20 69 73 20 69 6e 20 74 68 65 20 |which is in the | 00003010 6c 61 73 74 20 66 65 77 20 6c 69 6e 65 73 0d 6f |last few lines.o| 00003020 66 20 65 61 63 68 20 70 72 6f 67 72 61 6d 20 61 |f each program a| 00003030 6e 64 20 63 61 6e 20 62 65 20 61 6c 74 65 72 65 |nd can be altere| 00003040 64 20 74 6f 20 73 75 69 74 20 77 68 61 74 20 65 |d to suit what e| 00003050 76 65 72 20 6c 69 67 68 74 20 70 65 6e 20 73 77 |ver light pen sw| 00003060 69 74 63 68 20 69 73 0d 62 65 69 6e 67 20 75 73 |itch is.being us| 00003070 65 64 2e 0d 0d 49 66 2c 20 66 6f 72 20 65 78 61 |ed...If, for exa| 00003080 6d 70 6c 65 2c 20 79 6f 75 20 68 61 76 65 20 61 |mple, you have a| 00003090 20 6c 69 67 68 74 20 70 65 6e 20 77 69 74 68 6f | light pen witho| 000030a0 75 74 20 61 6e 79 20 73 77 69 74 63 68 20 79 6f |ut any switch yo| 000030b0 75 20 63 6f 75 6c 64 20 75 73 65 20 74 68 65 0d |u could use the.| 000030c0 73 70 61 63 65 20 62 61 72 20 61 73 20 61 20 73 |space bar as a s| 000030d0 75 62 73 74 69 74 75 74 65 20 61 6e 64 20 61 6c |ubstitute and al| 000030e0 74 65 72 20 6c 69 6e 65 20 32 33 32 30 20 6f 66 |ter line 2320 of| 000030f0 20 49 4f 49 4e 54 45 52 20 74 6f 20 72 65 61 64 | IOINTER to read| 00003100 3a 0d 0d 20 20 32 33 32 30 20 3d 49 4e 4b 45 59 |:.. 2320 =INKEY| 00003110 28 2d 39 39 29 0d 0d 49 66 20 79 6f 75 20 68 61 |(-99)..If you ha| 00003120 76 65 20 61 20 70 65 6e 20 77 69 74 68 20 61 20 |ve a pen with a | 00003130 74 6f 75 63 68 20 73 65 6e 73 69 74 69 76 65 20 |touch sensitive | 00003140 73 77 69 74 63 68 20 63 6f 6e 6e 65 63 74 65 64 |switch connected| 00003150 20 74 6f 20 6f 6e 65 20 6f 66 20 74 68 65 0d 61 | to one of the.a| 00003160 6e 61 6c 6f 67 75 65 20 70 6f 72 74 73 20 69 74 |nalogue ports it| 00003170 20 77 69 6c 6c 20 62 65 20 6d 65 61 73 75 72 69 | will be measuri| 00003180 6e 67 20 79 6f 75 72 20 73 6b 69 6e 20 72 65 73 |ng your skin res| 00003190 69 74 61 6e 63 65 20 61 6e 64 20 79 6f 75 20 77 |itance and you w| 000031a0 69 6c 6c 20 6e 65 65 64 0d 74 6f 20 61 6c 74 65 |ill need.to alte| 000031b0 72 20 6c 69 6e 65 20 32 33 31 30 20 74 6f 20 73 |r line 2310 to s| 000031c0 6f 6d 65 74 68 69 6e 67 20 6c 69 6b 65 3a 0d 0d |omething like:..| 000031d0 20 20 32 33 32 30 20 49 46 20 41 44 56 41 4c 28 | 2320 IF ADVAL(| 000031e0 31 29 3e 31 36 30 30 20 3d 54 52 55 45 20 45 4c |1)>1600 =TRUE EL| 000031f0 53 45 20 3d 46 41 4c 53 45 0d 0d 54 68 65 72 65 |SE =FALSE..There| 00003200 20 63 6f 75 6c 64 20 62 65 20 6f 74 68 65 72 20 | could be other | 00003210 74 79 70 65 73 20 6f 66 20 73 77 69 74 63 68 65 |types of switche| 00003220 73 20 75 73 65 64 20 62 79 20 6d 61 6e 75 66 61 |s used by manufa| 00003230 63 74 75 72 65 72 73 20 61 6e 64 20 69 66 20 79 |cturers and if y| 00003240 6f 75 0d 68 61 76 65 20 62 6f 75 67 68 74 20 61 |ou.have bought a| 00003250 20 72 65 61 64 79 20 6d 61 64 65 20 6c 69 67 68 | ready made ligh| 00003260 74 20 70 65 6e 20 79 6f 75 20 73 68 6f 75 6c 64 |t pen you should| 00003270 20 68 61 76 65 20 74 68 65 20 69 6e 66 6f 72 6d | have the inform| 00003280 61 74 69 6f 6e 20 79 6f 75 0d 6e 65 65 64 20 74 |ation you.need t| 00003290 6f 20 61 6c 74 65 72 20 46 4e 73 77 69 74 63 68 |o alter FNswitch| 000032a0 20 69 6e 20 61 6c 6c 20 74 68 65 20 70 72 6f 67 | in all the prog| 000032b0 72 61 6d 73 20 77 68 69 63 68 20 75 73 65 20 61 |rams which use a| 000032c0 20 6c 69 67 68 74 20 70 65 6e 20 73 77 69 74 63 | light pen switc| 000032d0 68 2e 0d 0d 54 68 65 20 69 6e 74 65 72 72 75 70 |h...The interrup| 000032e0 74 20 62 69 74 20 6d 61 73 6b 20 66 6f 72 20 74 |t bit mask for t| 000032f0 68 65 20 73 79 73 74 65 6d 20 56 49 41 20 63 61 |he system VIA ca| 00003300 6e 20 62 65 20 61 63 63 65 73 73 65 64 20 75 73 |n be accessed us| 00003310 69 6e 67 20 4f 73 62 79 74 65 0d 26 45 39 2e 20 |ing Osbyte.&E9. | 00003320 54 68 65 20 69 6e 74 65 72 72 75 70 74 20 68 61 |The interrupt ha| 00003330 6e 64 6c 69 6e 67 20 72 6f 75 74 69 6e 65 20 41 |ndling routine A| 00003340 4e 44 73 20 74 68 69 73 20 76 61 6c 75 65 20 77 |NDs this value w| 00003350 69 74 68 20 74 68 65 20 56 49 41 20 49 46 52 20 |ith the VIA IFR | 00003360 61 6e 64 0d 61 6e 79 20 62 69 74 20 63 6c 65 61 |and.any bit clea| 00003370 72 65 64 20 62 79 20 74 68 69 73 20 69 73 20 69 |red by this is i| 00003380 67 6e 6f 72 65 64 20 62 79 20 74 68 65 20 6f 70 |gnored by the op| 00003390 65 72 61 74 69 6e 67 20 73 79 73 74 65 6d 2e 20 |erating system. | 000033a0 59 6f 75 20 6d 69 67 68 74 0d 74 68 65 72 65 66 |You might.theref| 000033b0 6f 72 65 20 65 78 70 65 63 74 20 74 6f 20 68 61 |ore expect to ha| 000033c0 76 65 20 74 6f 20 69 73 73 75 65 20 4f 73 62 79 |ve to issue Osby| 000033d0 74 65 20 26 45 39 20 77 69 74 68 20 58 3d 26 46 |te &E9 with X=&F| 000033e0 37 20 28 25 31 31 31 31 30 31 31 31 29 20 61 6e |7 (%11110111) an| 000033f0 64 0d 59 3d 26 30 30 20 69 6e 20 6f 72 64 65 72 |d.Y=&00 in order| 00003400 20 74 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20 | to ensure that | 00003410 74 68 65 20 6c 69 67 68 74 20 70 65 6e 20 69 6e |the light pen in| 00003420 74 65 72 72 75 70 74 20 69 73 20 70 61 73 73 65 |terrupt is passe| 00003430 64 20 74 6f 20 49 52 51 32 56 0d 62 75 74 2c 20 |d to IRQ2V.but, | 00003440 62 65 63 61 75 73 65 20 74 68 65 20 6f 70 65 72 |because the oper| 00003450 61 74 69 6e 67 20 73 79 73 74 65 6d 20 64 6f 65 |ating system doe| 00003460 73 20 6e 6f 74 20 70 72 6f 63 65 73 73 20 74 68 |s not process th| 00003470 65 20 6c 69 67 68 74 20 70 65 6e 0d 69 6e 74 65 |e light pen.inte| 00003480 72 72 75 70 74 2c 20 69 74 20 69 73 20 6e 6f 74 |rrupt, it is not| 00003490 20 6e 65 63 65 73 73 61 72 79 20 74 6f 20 6d 61 | necessary to ma| 000034a0 6b 65 20 74 68 69 73 20 4f 73 62 79 74 65 20 63 |ke this Osbyte c| 000034b0 61 6c 6c 2e 20 54 68 65 20 4f 73 62 79 74 65 20 |all. The Osbyte | 000034c0 26 45 39 0d 63 61 6c 6c 73 20 68 61 76 65 20 62 |&E9.calls have b| 000034d0 65 65 6e 20 63 6f 6d 6d 65 6e 74 65 64 20 6f 75 |een commented ou| 000034e0 74 20 69 6e 20 74 68 65 20 70 72 6f 67 72 61 6d |t in the program| 000034f0 20 49 4f 49 4e 54 45 52 2e 20 49 66 20 79 6f 75 | IOINTER. If you| 00003500 20 77 61 6e 74 20 74 6f 0d 69 6e 63 6c 75 64 65 | want to.include| 00003510 20 74 68 69 73 20 4f 73 62 79 74 65 20 63 61 6c | this Osbyte cal| 00003520 6c 20 66 6f 72 20 74 68 65 20 73 61 6b 65 20 6f |l for the sake o| 00003530 66 20 63 6f 6d 70 6c 65 74 65 6c 79 20 6c 65 67 |f completely leg| 00003540 61 6c 20 63 6f 64 69 6e 67 20 74 68 65 6e 20 79 |al coding then y| 00003550 6f 75 0d 63 61 6e 20 65 64 69 74 20 74 68 65 20 |ou.can edit the | 00003560 70 72 6f 67 72 61 6d 2e 0d 0d 54 6f 20 64 65 6d |program...To dem| 00003570 6f 6e 73 74 72 61 74 65 20 74 68 65 20 75 73 65 |onstrate the use| 00003580 20 6f 66 20 6c 69 67 68 74 20 70 65 6e 20 69 6e | of light pen in| 00003590 74 65 72 72 75 70 74 73 20 63 68 61 69 6e 20 74 |terrupts chain t| 000035a0 68 65 20 70 72 6f 67 72 61 6d 20 49 4f 49 4e 54 |he program IOINT| 000035b0 45 52 2e 0d 54 68 65 20 66 69 72 73 74 20 74 69 |ER..The first ti| 000035c0 6d 65 20 74 68 65 20 6d 61 63 68 69 6e 65 20 63 |me the machine c| 000035d0 6f 64 65 20 69 73 20 63 61 6c 6c 65 64 20 69 74 |ode is called it| 000035e0 20 77 69 6c 6c 20 65 6e 61 62 6c 65 20 74 68 65 | will enable the| 000035f0 20 6c 69 67 68 74 20 70 65 6e 0d 69 6e 74 65 72 | light pen.inter| 00003600 72 75 70 74 73 2e 20 54 68 65 20 73 63 72 65 65 |rupts. The scree| 00003610 6e 20 6d 6f 64 65 20 63 61 6e 20 62 65 20 63 68 |n mode can be ch| 00003620 61 6e 67 65 64 20 77 69 74 68 20 74 68 65 20 75 |anged with the u| 00003630 70 20 61 6e 64 20 64 6f 77 6e 20 63 75 72 73 6f |p and down curso| 00003640 72 0d 6b 65 79 73 20 61 6e 64 20 74 68 65 20 6f |r.keys and the o| 00003650 66 66 73 65 74 20 63 61 6e 20 62 65 20 74 72 69 |ffset can be tri| 00003660 6d 6d 65 64 20 77 69 74 68 20 74 68 65 20 6c 65 |mmed with the le| 00003670 66 74 20 61 6e 64 20 72 69 67 68 74 20 63 75 72 |ft and right cur| 00003680 73 6f 72 20 6b 65 79 73 2e 0d 54 68 65 20 62 61 |sor keys..The ba| 00003690 63 6b 67 72 6f 75 6e 64 20 63 6f 6c 6f 75 72 20 |ckground colour | 000036a0 63 61 6e 20 62 65 20 61 6c 74 65 72 65 64 20 62 |can be altered b| 000036b0 79 20 70 72 65 73 73 69 6e 67 20 50 20 28 50 20 |y pressing P (P | 000036c0 66 6f 72 20 70 61 70 65 72 29 20 61 6e 64 20 74 |for paper) and t| 000036d0 68 65 0d 74 65 78 74 20 63 6f 6c 6f 75 72 20 63 |he.text colour c| 000036e0 61 6e 20 62 65 20 61 6c 74 65 72 65 64 20 77 69 |an be altered wi| 000036f0 74 68 20 49 20 28 49 20 66 6f 72 20 69 6e 6b 29 |th I (I for ink)| 00003700 2e 20 54 68 65 20 70 72 6f 67 72 61 6d 20 77 69 |. The program wi| 00003710 6c 6c 20 64 72 61 77 20 61 6e 0d 61 73 74 65 72 |ll draw an.aster| 00003720 69 73 6b 20 6f 6e 20 74 68 65 20 73 63 72 65 65 |isk on the scree| 00003730 6e 20 77 68 65 6e 65 76 65 72 20 74 68 65 20 6c |n whenever the l| 00003740 69 67 68 74 20 70 65 6e 20 73 77 69 74 63 68 20 |ight pen switch | 00003750 69 73 20 6f 70 65 6e 2c 20 69 65 2e 20 70 72 65 |is open, ie. pre| 00003760 73 73 65 64 2e 0d 59 6f 75 20 63 61 6e 20 6c 65 |ssed..You can le| 00003770 61 76 65 20 74 68 65 20 70 72 6f 67 72 61 6d 20 |ave the program | 00003780 62 79 20 70 72 65 73 73 69 6e 67 20 74 68 65 20 |by pressing the | 00003790 45 73 63 61 70 65 20 6b 65 79 2e 20 54 68 69 73 |Escape key. This| 000037a0 20 77 69 6c 6c 20 63 61 6c 6c 20 74 68 65 0d 6d | will call the.m| 000037b0 61 63 68 69 6e 65 20 63 6f 64 65 20 61 20 73 65 |achine code a se| 000037c0 63 6f 6e 64 20 74 69 6d 65 20 61 6e 64 20 64 69 |cond time and di| 000037d0 73 61 62 6c 65 20 74 68 65 20 69 6e 74 65 72 72 |sable the interr| 000037e0 75 70 74 20 72 6f 75 74 69 6e 65 2e 0d 0d 0d 20 |upt routine.... | 000037f0 20 20 31 30 20 52 45 4d 3e 20 49 4f 49 4e 54 45 | 10 REM> IOINTE| 00003800 52 0d 20 20 20 32 30 20 41 25 3d 26 45 41 0d 20 |R. 20 A%=&EA. | 00003810 20 20 33 30 20 58 25 3d 30 0d 20 20 20 34 30 20 | 30 X%=0. 40 | 00003820 59 25 3d 26 46 46 0d 20 20 20 35 30 20 49 46 20 |Y%=&FF. 50 IF | 00003830 28 28 55 53 52 28 26 46 46 46 34 29 41 4e 44 26 |((USR(&FFF4)AND&| 00003840 46 46 30 30 29 44 49 56 26 31 30 30 29 3c 3e 30 |FF00)DIV&100)<>0| 00003850 20 45 4e 44 0d 20 20 20 36 30 20 6d 63 6f 64 65 | END. 60 mcode| 00003860 3d 26 41 30 30 0d 20 20 20 37 30 20 78 63 6f 6f |=&A00. 70 xcoo| 00003870 72 64 3d 26 37 30 0d 20 20 20 38 30 20 79 63 6f |rd=&70. 80 yco| 00003880 6f 72 64 3d 26 37 31 0d 20 20 20 39 30 20 21 78 |ord=&71. 90 !x| 00003890 63 6f 6f 72 64 3d 30 0d 20 20 31 30 30 20 50 52 |coord=0. 100 PR| 000038a0 4f 43 6d 63 6f 64 65 0d 20 20 31 31 30 20 4f 4e |OCmcode. 110 ON| 000038b0 45 52 52 4f 52 20 43 41 4c 4c 20 6d 63 6f 64 65 |ERROR CALL mcode| 000038c0 3a 56 44 55 32 33 2c 31 2c 31 3b 30 3b 30 3b 30 |:VDU23,1,1;0;0;0| 000038d0 3b 3a 45 4e 44 0d 20 20 31 32 30 20 6d 6f 64 65 |;:END. 120 mode| 000038e0 3d 34 0d 20 20 31 33 30 20 70 61 70 65 72 3d 36 |=4. 130 paper=6| 000038f0 0d 20 20 31 34 30 20 69 6e 6b 3d 34 0d 20 20 31 |. 140 ink=4. 1| 00003900 35 30 20 4d 4f 44 45 20 6d 6f 64 65 0d 20 20 31 |50 MODE mode. 1| 00003910 36 30 20 50 52 4f 43 6e 65 77 6d 6f 64 65 0d 20 |60 PROCnewmode. | 00003920 20 31 37 30 20 52 45 50 45 41 54 0d 20 20 31 38 | 170 REPEAT. 18| 00003930 30 20 49 46 20 49 4e 4b 45 59 28 2d 35 38 29 20 |0 IF INKEY(-58) | 00003940 50 52 4f 43 75 70 3a 4d 4f 44 45 20 6d 6f 64 65 |PROCup:MODE mode| 00003950 3a 50 52 4f 43 6e 65 77 6d 6f 64 65 0d 20 20 31 |:PROCnewmode. 1| 00003960 39 30 20 49 46 20 49 4e 4b 45 59 28 2d 34 32 29 |90 IF INKEY(-42)| 00003970 20 50 52 4f 43 64 6f 77 6e 3a 4d 4f 44 45 20 6d | PROCdown:MODE m| 00003980 6f 64 65 3a 50 52 4f 43 6e 65 77 6d 6f 64 65 0d |ode:PROCnewmode.| 00003990 20 20 32 30 30 20 49 46 20 49 4e 4b 45 59 28 2d | 200 IF INKEY(-| 000039a0 35 36 29 20 50 52 4f 43 70 61 70 65 72 0d 20 20 |56) PROCpaper. | 000039b0 32 31 30 20 49 46 20 49 4e 4b 45 59 28 2d 33 38 |210 IF INKEY(-38| 000039c0 29 20 50 52 4f 43 69 6e 6b 0d 20 20 32 32 30 20 |) PROCink. 220 | 000039d0 49 46 20 49 4e 4b 45 59 28 2d 32 36 29 20 50 52 |IF INKEY(-26) PR| 000039e0 4f 43 6c 65 66 74 0d 20 20 32 33 30 20 49 46 20 |OCleft. 230 IF | 000039f0 49 4e 4b 45 59 28 2d 31 32 32 29 20 50 52 4f 43 |INKEY(-122) PROC| 00003a00 72 69 67 68 74 0d 20 20 32 34 30 20 50 52 49 4e |right. 240 PRIN| 00003a10 54 54 41 42 28 31 33 2c 32 29 3b 3f 78 63 6f 6f |TTAB(13,2);?xcoo| 00003a20 72 64 3b 22 20 22 54 41 42 28 31 33 2c 33 29 3b |rd;" "TAB(13,3);| 00003a30 3f 79 63 6f 6f 72 64 3b 22 20 22 0d 20 20 32 35 |?ycoord;" ". 25| 00003a40 30 20 49 46 20 46 4e 73 77 69 74 63 68 20 56 44 |0 IF FNswitch VD| 00003a50 55 33 31 2c 3f 78 63 6f 6f 72 64 2c 3f 79 63 6f |U31,?xcoord,?yco| 00003a60 6f 72 64 2c 34 32 0d 20 20 32 36 30 20 55 4e 54 |ord,42. 260 UNT| 00003a70 49 4c 20 46 41 4c 53 45 0d 20 20 32 37 30 20 3a |IL FALSE. 270 :| 00003a80 0d 20 20 32 38 30 20 44 45 46 50 52 4f 43 75 70 |. 280 DEFPROCup| 00003a90 0d 20 20 32 39 30 20 6d 6f 64 65 3d 6d 6f 64 65 |. 290 mode=mode| 00003aa0 2b 31 0d 20 20 33 30 30 20 49 46 20 6d 6f 64 65 |+1. 300 IF mode| 00003ab0 3e 37 20 6d 6f 64 65 3d 37 0d 20 20 33 31 30 20 |>7 mode=7. 310 | 00003ac0 45 4e 44 50 52 4f 43 0d 20 20 33 32 30 20 3a 0d |ENDPROC. 320 :.| 00003ad0 20 20 33 33 30 20 44 45 46 50 52 4f 43 64 6f 77 | 330 DEFPROCdow| 00003ae0 6e 0d 20 20 33 34 30 20 6d 6f 64 65 3d 6d 6f 64 |n. 340 mode=mod| 00003af0 65 2d 31 0d 20 20 33 35 30 20 49 46 20 6d 6f 64 |e-1. 350 IF mod| 00003b00 65 3c 30 20 6d 6f 64 65 3d 30 0d 20 20 33 36 30 |e<0 mode=0. 360| 00003b10 20 45 4e 44 50 52 4f 43 0d 20 20 33 37 30 20 3a | ENDPROC. 370 :| 00003b20 0d 20 20 33 38 30 20 44 45 46 50 52 4f 43 6c 65 |. 380 DEFPROCle| 00003b30 66 74 0d 20 20 33 39 30 20 49 46 20 6f 66 66 73 |ft. 390 IF offs| 00003b40 65 74 6c 6f 77 3f 6d 6f 64 65 3d 31 32 20 45 4e |etlow?mode=12 EN| 00003b50 44 50 52 4f 43 0d 20 20 34 30 30 20 6f 66 66 73 |DPROC. 400 offs| 00003b60 65 74 6c 6f 77 3f 6d 6f 64 65 3d 6f 66 66 73 65 |etlow?mode=offse| 00003b70 74 6c 6f 77 3f 6d 6f 64 65 2b 31 0d 20 20 34 31 |tlow?mode+1. 41| 00003b80 30 20 50 52 4f 43 64 65 6c 61 79 0d 20 20 34 32 |0 PROCdelay. 42| 00003b90 30 20 45 4e 44 50 52 4f 43 0d 20 20 34 33 30 20 |0 ENDPROC. 430 | 00003ba0 3a 0d 20 20 34 34 30 20 44 45 46 50 52 4f 43 72 |:. 440 DEFPROCr| 00003bb0 69 67 68 74 0d 20 20 34 35 30 20 49 46 20 6f 66 |ight. 450 IF of| 00003bc0 66 73 65 74 6c 6f 77 3f 6d 6f 64 65 3d 30 20 45 |fsetlow?mode=0 E| 00003bd0 4e 44 50 52 4f 43 0d 20 20 34 36 30 20 6f 66 66 |NDPROC. 460 off| 00003be0 73 65 74 6c 6f 77 3f 6d 6f 64 65 3d 6f 66 66 73 |setlow?mode=offs| 00003bf0 65 74 6c 6f 77 3f 6d 6f 64 65 2d 31 0d 20 20 34 |etlow?mode-1. 4| 00003c00 37 30 20 50 52 4f 43 64 65 6c 61 79 0d 20 20 34 |70 PROCdelay. 4| 00003c10 38 30 20 45 4e 44 50 52 4f 43 0d 20 20 34 39 30 |80 ENDPROC. 490| 00003c20 20 3a 0d 20 20 35 30 30 20 44 45 46 50 52 4f 43 | :. 500 DEFPROC| 00003c30 6e 65 77 6d 6f 64 65 0d 20 20 35 31 30 20 56 44 |newmode. 510 VD| 00003c40 55 32 33 2c 31 2c 30 3b 30 3b 30 3b 30 3b 0d 20 |U23,1,0;0;0;0;. | 00003c50 20 35 32 30 20 49 46 20 6d 6f 64 65 3d 37 20 50 | 520 IF mode=7 P| 00003c60 52 4f 43 73 65 76 65 6e 3a 45 4e 44 50 52 4f 43 |ROCseven:ENDPROC| 00003c70 0d 20 20 35 33 30 20 56 44 55 31 39 2c 30 2c 70 |. 530 VDU19,0,p| 00003c80 61 70 65 72 3b 30 3b 0d 20 20 35 34 30 20 56 44 |aper;0;. 540 VD| 00003c90 55 31 39 2c 31 2c 69 6e 6b 3b 30 3b 0d 20 20 35 |U19,1,ink;0;. 5| 00003ca0 35 30 20 43 4f 4c 4f 55 52 31 0d 20 20 35 36 30 |50 COLOUR1. 560| 00003cb0 20 50 52 4f 43 64 65 6c 61 79 0d 20 20 35 37 30 | PROCdelay. 570| 00003cc0 20 45 4e 44 50 52 4f 43 0d 20 20 35 38 30 20 3a | ENDPROC. 580 :| 00003cd0 0d 20 20 35 39 30 20 44 45 46 50 52 4f 43 64 65 |. 590 DEFPROCde| 00003ce0 6c 61 79 0d 20 20 36 30 30 20 50 52 49 4e 54 54 |lay. 600 PRINTT| 00003cf0 41 42 28 33 2c 31 29 22 4d 6f 64 65 20 22 3b 6d |AB(3,1)"Mode ";m| 00003d00 6f 64 65 0d 20 20 36 31 30 20 50 52 49 4e 54 54 |ode. 610 PRINTT| 00003d10 41 42 28 33 2c 32 29 22 58 20 63 6f 6f 72 64 20 |AB(3,2)"X coord | 00003d20 3d 20 22 3b 3f 78 63 6f 6f 72 64 0d 20 20 36 32 |= ";?xcoord. 62| 00003d30 30 20 50 52 49 4e 54 54 41 42 28 33 2c 33 29 22 |0 PRINTTAB(3,3)"| 00003d40 59 20 63 6f 6f 72 64 20 3d 20 22 3b 3f 79 63 6f |Y coord = ";?yco| 00003d50 6f 72 64 0d 20 20 36 33 30 20 50 52 49 4e 54 54 |ord. 630 PRINTT| 00003d60 41 42 28 33 2c 34 29 22 6f 66 66 73 65 74 6c 6f |AB(3,4)"offsetlo| 00003d70 77 20 3d 20 22 3b 6f 66 66 73 65 74 6c 6f 77 3f |w = ";offsetlow?| 00003d80 6d 6f 64 65 0d 20 20 36 34 30 20 74 69 6d 65 3d |mode. 640 time=| 00003d90 54 49 4d 45 2b 32 30 0d 20 20 36 35 30 20 52 45 |TIME+20. 650 RE| 00003da0 50 45 41 54 20 55 4e 54 49 4c 20 74 69 6d 65 3c |PEAT UNTIL time<| 00003db0 54 49 4d 45 0d 20 20 36 36 30 20 45 4e 44 50 52 |TIME. 660 ENDPR| 00003dc0 4f 43 0d 20 20 36 37 30 20 3a 0d 20 20 36 38 30 |OC. 670 :. 680| 00003dd0 20 44 45 46 50 52 4f 43 69 6e 6b 0d 20 20 36 39 | DEFPROCink. 69| 00003de0 30 20 69 6e 6b 3d 69 6e 6b 2b 31 0d 20 20 37 30 |0 ink=ink+1. 70| 00003df0 30 20 49 46 20 69 6e 6b 3d 70 61 70 65 72 20 69 |0 IF ink=paper i| 00003e00 6e 6b 3d 69 6e 6b 2b 31 0d 20 20 37 31 30 20 49 |nk=ink+1. 710 I| 00003e10 46 20 69 6e 6b 3e 37 20 69 6e 6b 3d 30 0d 20 20 |F ink>7 ink=0. | 00003e20 37 32 30 20 56 44 55 31 39 2c 31 2c 69 6e 6b 3b |720 VDU19,1,ink;| 00003e30 30 3b 0d 20 20 37 33 30 20 49 46 20 6d 6f 64 65 |0;. 730 IF mode| 00003e40 3d 37 20 50 52 4f 43 73 65 76 65 6e 0d 20 20 37 |=7 PROCseven. 7| 00003e50 34 30 20 50 52 4f 43 64 65 6c 61 79 0d 20 20 37 |40 PROCdelay. 7| 00003e60 35 30 20 45 4e 44 50 52 4f 43 0d 20 20 37 36 30 |50 ENDPROC. 760| 00003e70 20 3a 0d 20 20 37 37 30 20 44 45 46 50 52 4f 43 | :. 770 DEFPROC| 00003e80 70 61 70 65 72 0d 20 20 37 38 30 20 70 61 70 65 |paper. 780 pape| 00003e90 72 3d 70 61 70 65 72 2b 31 0d 20 20 37 39 30 20 |r=paper+1. 790 | 00003ea0 49 46 20 70 61 70 65 72 3d 69 6e 6b 20 70 61 70 |IF paper=ink pap| 00003eb0 65 72 3d 70 61 70 65 72 2b 31 0d 20 20 38 30 30 |er=paper+1. 800| 00003ec0 20 49 46 20 70 61 70 65 72 3e 37 20 70 61 70 65 | IF paper>7 pape| 00003ed0 72 3d 31 0d 20 20 38 31 30 20 56 44 55 31 39 2c |r=1. 810 VDU19,| 00003ee0 30 2c 70 61 70 65 72 3b 30 3b 0d 20 20 38 32 30 |0,paper;0;. 820| 00003ef0 20 49 46 20 6d 6f 64 65 3d 37 20 50 52 4f 43 73 | IF mode=7 PROCs| 00003f00 65 76 65 6e 0d 20 20 38 33 30 20 50 52 4f 43 64 |even. 830 PROCd| 00003f10 65 6c 61 79 0d 20 20 38 34 30 20 45 4e 44 50 52 |elay. 840 ENDPR| 00003f20 4f 43 0d 20 20 38 35 30 20 3a 0d 20 20 38 36 30 |OC. 850 :. 860| 00003f30 20 44 45 46 50 52 4f 43 73 65 76 65 6e 0d 20 20 | DEFPROCseven. | 00003f40 38 37 30 20 49 46 20 69 6e 6b 3d 30 20 69 6e 6b |870 IF ink=0 ink| 00003f50 3d 31 0d 20 20 38 38 30 20 46 4f 52 20 6c 69 6e |=1. 880 FOR lin| 00003f60 65 3d 30 20 54 4f 20 32 34 0d 20 20 38 39 30 20 |e=0 TO 24. 890 | 00003f70 49 46 20 70 61 70 65 72 3d 30 20 56 44 55 33 31 |IF paper=0 VDU31| 00003f80 2c 30 2c 6c 69 6e 65 2c 31 32 38 2b 69 6e 6b 2c |,0,line,128+ink,| 00003f90 33 32 2c 33 32 0d 20 20 20 20 20 20 45 4c 53 45 |32,32. ELSE| 00003fa0 20 56 44 55 33 31 2c 30 2c 6c 69 6e 65 2c 31 32 | VDU31,0,line,12| 00003fb0 38 2b 70 61 70 65 72 2c 31 35 37 2c 31 32 38 2b |8+paper,157,128+| 00003fc0 69 6e 6b 0d 20 20 39 30 30 20 4e 45 58 54 0d 20 |ink. 900 NEXT. | 00003fd0 20 39 31 30 20 50 52 4f 43 64 65 6c 61 79 0d 20 | 910 PROCdelay. | 00003fe0 20 39 32 30 20 45 4e 44 50 52 4f 43 0d 20 20 39 | 920 ENDPROC. 9| 00003ff0 33 30 20 3a 0d 20 20 39 34 30 20 44 45 46 50 52 |30 :. 940 DEFPR| 00004000 4f 43 6d 63 6f 64 65 0d 20 20 39 35 30 20 66 69 |OCmcode. 950 fi| 00004010 72 65 3d 26 37 32 20 3a 52 45 4d 3a 20 66 69 72 |re=&72 :REM: fir| 00004020 65 20 62 75 74 74 6f 6e 20 73 74 61 74 75 73 0d |e button status.| 00004030 20 20 39 36 30 20 69 72 71 32 76 3d 26 32 30 36 | 960 irq2v=&206| 00004040 20 3a 52 45 4d 3a 20 73 65 63 6f 6e 64 61 72 79 | :REM: secondary| 00004050 20 69 6e 74 65 72 72 75 70 74 20 76 65 63 74 6f | interrupt vecto| 00004060 72 0d 20 20 39 37 30 20 73 63 72 65 65 6e 3d 26 |r. 970 screen=&| 00004070 33 35 35 20 3a 52 45 4d 3a 20 73 63 72 65 65 6e |355 :REM: screen| 00004080 20 6d 6f 64 65 20 4f 53 20 31 2e 32 0d 20 20 39 | mode OS 1.2. 9| 00004090 38 30 20 73 68 65 69 6c 61 3d 26 46 45 30 30 0d |80 sheila=&FE00.| 000040a0 20 20 39 39 30 20 64 72 62 3d 26 46 45 34 30 20 | 990 drb=&FE40 | 000040b0 3a 52 45 4d 3a 20 73 79 73 74 65 6d 20 36 35 32 |:REM: system 652| 000040c0 32 20 69 6e 70 75 74 2f 6f 75 74 70 75 74 20 72 |2 input/output r| 000040d0 65 67 69 73 74 65 72 20 42 0d 20 31 30 30 30 20 |egister B. 1000 | 000040e0 69 66 72 3d 26 46 45 34 44 20 3a 52 45 4d 3a 20 |ifr=&FE4D :REM: | 000040f0 73 79 73 74 65 6d 20 36 35 32 32 20 69 6e 74 65 |system 6522 inte| 00004100 72 72 75 70 74 20 66 6c 61 67 20 72 65 67 69 73 |rrupt flag regis| 00004110 74 65 72 0d 20 31 30 31 30 20 69 65 72 3d 26 46 |ter. 1010 ier=&F| 00004120 45 34 45 20 3a 52 45 4d 3a 20 73 79 73 74 65 6d |E4E :REM: system| 00004130 20 36 35 32 32 20 69 6e 74 65 72 72 75 70 74 20 | 6522 interrupt | 00004140 65 6e 61 62 6c 65 20 72 65 67 69 73 74 65 72 0d |enable register.| 00004150 20 31 30 32 30 20 6f 73 77 6f 72 64 3d 26 46 46 | 1020 osword=&FF| 00004160 46 31 0d 20 31 30 33 30 20 6f 73 62 79 74 65 3d |F1. 1030 osbyte=| 00004170 26 46 46 46 34 0d 20 31 30 34 30 20 46 4f 52 20 |&FFF4. 1040 FOR | 00004180 70 61 73 73 3d 30 20 54 4f 20 32 20 53 54 45 50 |pass=0 TO 2 STEP| 00004190 20 32 0d 20 31 30 35 30 20 50 25 3d 6d 63 6f 64 | 2. 1050 P%=mcod| 000041a0 65 0d 20 31 30 36 30 20 5b 20 20 20 20 20 20 20 |e. 1060 [ | 000041b0 4f 50 54 20 70 61 73 73 0d 20 31 30 37 30 20 20 |OPT pass. 1070 | 000041c0 20 20 20 20 20 20 20 4c 44 58 20 69 72 71 32 76 | LDX irq2v| 000041d0 20 20 20 20 20 5c 20 73 65 63 6f 6e 64 61 72 79 | \ secondary| 000041e0 20 69 6e 74 65 72 72 75 70 74 20 76 65 63 74 6f | interrupt vecto| 000041f0 72 2c 20 6c 6f 77 20 62 79 74 65 0d 20 31 30 38 |r, low byte. 108| 00004200 30 20 20 20 20 20 20 20 20 20 4c 44 59 20 69 72 |0 LDY ir| 00004210 71 32 76 2b 31 20 20 20 5c 20 73 65 63 6f 6e 64 |q2v+1 \ second| 00004220 61 72 79 20 69 6e 74 65 72 72 75 70 74 20 76 65 |ary interrupt ve| 00004230 63 74 6f 72 2c 20 68 69 67 68 20 62 79 74 65 0d |ctor, high byte.| 00004240 20 31 30 39 30 20 20 20 20 20 20 20 20 20 43 50 | 1090 CP| 00004250 59 20 23 69 6e 74 65 72 72 75 70 74 20 44 49 56 |Y #interrupt DIV| 00004260 20 32 35 36 20 5c 20 68 61 73 20 74 68 65 20 68 | 256 \ has the h| 00004270 69 67 68 20 62 79 74 65 20 62 65 65 6e 20 61 6c |igh byte been al| 00004280 74 65 72 65 64 3f 0d 20 31 31 30 30 20 20 20 20 |tered?. 1100 | 00004290 20 20 20 20 20 42 45 51 20 64 69 73 61 62 6c 65 | BEQ disable| 000042a0 20 20 20 5c 20 72 65 73 74 6f 72 65 20 6f 72 69 | \ restore ori| 000042b0 67 69 6e 61 6c 20 76 65 63 74 6f 72 20 69 66 20 |ginal vector if | 000042c0 61 6c 74 65 72 65 64 0d 20 31 31 31 30 20 20 20 |altered. 1110 | 000042d0 20 20 20 20 20 20 53 54 58 20 6f 6c 64 69 72 71 | STX oldirq| 000042e0 32 76 20 20 5c 20 73 74 6f 72 65 20 6f 72 69 67 |2v \ store orig| 000042f0 69 6e 61 6c 20 76 65 63 74 6f 72 2c 20 6c 6f 77 |inal vector, low| 00004300 20 62 79 74 65 0d 20 31 31 32 30 20 20 20 20 20 | byte. 1120 | 00004310 20 20 20 20 53 54 59 20 6f 6c 64 69 72 71 32 76 | STY oldirq2v| 00004320 2b 31 20 5c 20 73 74 6f 72 65 20 6f 72 69 67 69 |+1 \ store origi| 00004330 6e 61 6c 20 76 65 63 74 6f 72 2c 20 68 69 67 68 |nal vector, high| 00004340 20 62 79 74 65 0d 20 31 31 33 30 20 20 20 20 20 | byte. 1130 | 00004350 20 20 20 20 4c 44 58 20 23 69 6e 74 65 72 72 75 | LDX #interru| 00004360 70 74 20 4d 4f 44 20 32 35 36 20 5c 20 6e 65 77 |pt MOD 256 \ new| 00004370 20 69 6e 74 65 72 72 75 70 74 20 63 6f 64 65 2c | interrupt code,| 00004380 20 6c 6f 77 20 62 79 74 65 0d 20 31 31 34 30 20 | low byte. 1140 | 00004390 20 20 20 20 20 20 20 20 4c 44 59 20 23 69 6e 74 | LDY #int| 000043a0 65 72 72 75 70 74 20 44 49 56 20 32 35 36 20 5c |errupt DIV 256 \| 000043b0 20 6e 65 77 20 69 6e 74 65 72 72 75 70 74 20 63 | new interrupt c| 000043c0 6f 64 65 2c 20 68 69 67 68 20 62 79 74 65 0d 20 |ode, high byte. | 000043d0 31 31 35 30 20 20 20 20 20 20 20 20 20 53 45 49 |1150 SEI| 000043e0 20 20 20 20 20 20 20 20 20 20 20 5c 20 73 65 74 | \ set| 000043f0 20 69 6e 74 65 72 72 75 70 74 20 64 69 73 61 62 | interrupt disab| 00004400 6c 65 20 66 6c 61 67 0d 20 31 31 36 30 20 20 20 |le flag. 1160 | 00004410 20 20 20 20 20 20 53 54 58 20 69 72 71 32 76 20 | STX irq2v | 00004420 20 20 20 20 5c 20 61 6c 74 65 72 20 76 65 63 74 | \ alter vect| 00004430 6f 72 2c 20 6c 6f 77 20 62 79 74 65 0d 20 31 31 |or, low byte. 11| 00004440 37 30 20 20 20 20 20 20 20 20 20 53 54 59 20 69 |70 STY i| 00004450 72 71 32 76 2b 31 20 20 20 5c 20 61 6c 74 65 72 |rq2v+1 \ alter| 00004460 20 76 65 63 74 6f 72 2c 20 68 69 67 68 20 62 79 | vector, high by| 00004470 74 65 0d 20 31 31 38 30 20 20 20 20 20 20 20 20 |te. 1180 | 00004480 20 43 4c 49 20 20 20 20 20 20 20 20 20 20 20 5c | CLI \| 00004490 20 63 6c 65 61 72 20 69 6e 74 65 72 72 75 70 74 | clear interrupt| 000044a0 20 64 69 73 61 62 6c 65 20 66 6c 61 67 0d 20 31 | disable flag. 1| 000044b0 31 39 30 20 20 20 20 20 20 20 20 20 4c 44 41 20 |190 LDA | 000044c0 23 26 38 38 20 20 20 20 20 20 5c 20 25 31 30 30 |#&88 \ %100| 000044d0 30 31 30 30 30 0d 20 31 32 30 30 20 20 20 20 20 |01000. 1200 | 000044e0 20 20 20 20 53 54 41 20 69 65 72 20 20 20 20 20 | STA ier | 000044f0 20 20 5c 20 65 6e 61 62 6c 65 20 6c 69 67 68 74 | \ enable light| 00004500 20 70 65 6e 20 69 6e 74 65 72 72 75 70 74 73 0d | pen interrupts.| 00004510 20 31 32 31 30 20 5c 20 20 20 20 20 20 20 4c 44 | 1210 \ LD| 00004520 41 20 23 26 45 39 20 20 20 20 20 20 5c 20 77 72 |A #&E9 \ wr| 00004530 69 74 65 20 73 79 73 74 65 6d 20 56 49 41 20 49 |ite system VIA I| 00004540 52 51 20 62 69 74 20 6d 61 73 6b 0d 20 31 32 32 |RQ bit mask. 122| 00004550 30 20 5c 20 20 20 20 20 20 20 4c 44 58 20 23 26 |0 \ LDX #&| 00004560 46 37 20 20 20 20 20 20 5c 20 25 31 31 31 31 30 |F7 \ %11110| 00004570 31 31 31 0d 20 31 32 33 30 20 5c 20 20 20 20 20 |111. 1230 \ | 00004580 20 20 4c 44 59 20 23 26 30 30 0d 20 31 32 34 30 | LDY #&00. 1240| 00004590 20 5c 20 20 20 20 20 20 20 4a 53 52 20 6f 73 62 | \ JSR osb| 000045a0 79 74 65 20 20 20 20 5c 20 62 69 74 20 6d 61 73 |yte \ bit mas| 000045b0 6b 20 3d 20 25 31 31 31 31 30 31 31 31 0d 20 31 |k = %11110111. 1| 000045c0 32 35 30 20 20 20 20 20 20 20 20 20 52 54 53 0d |250 RTS.| 000045d0 20 31 32 36 30 20 2e 64 69 73 61 62 6c 65 0d 20 | 1260 .disable. | 000045e0 31 32 37 30 20 20 20 20 20 20 20 20 20 4c 44 41 |1270 LDA| 000045f0 20 23 26 30 38 20 20 20 20 20 20 5c 20 25 30 30 | #&08 \ %00| 00004600 30 30 31 30 30 30 20 72 65 61 64 79 20 74 6f 20 |001000 ready to | 00004610 64 69 73 61 62 6c 65 20 6c 69 67 68 74 20 70 65 |disable light pe| 00004620 6e 0d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |n. | 00004630 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00004640 69 6e 74 65 72 72 75 70 74 73 0d 20 31 32 38 30 |interrupts. 1280| 00004650 20 20 20 20 20 20 20 20 20 4c 44 58 20 6f 6c 64 | LDX old| 00004660 69 72 71 32 76 20 20 5c 20 6f 72 69 67 69 6e 61 |irq2v \ origina| 00004670 6c 20 69 72 71 32 20 76 65 63 74 6f 72 2c 20 6c |l irq2 vector, l| 00004680 6f 77 20 62 79 74 65 0d 20 31 32 39 30 20 20 20 |ow byte. 1290 | 00004690 20 20 20 20 20 20 4c 44 59 20 6f 6c 64 69 72 71 | LDY oldirq| 000046a0 32 76 2b 31 20 5c 20 6f 72 69 67 69 6e 61 6c 20 |2v+1 \ original | 000046b0 69 72 71 32 20 76 65 63 74 6f 72 2c 20 68 69 67 |irq2 vector, hig| 000046c0 68 20 62 79 74 65 0d 20 31 33 30 30 20 20 20 20 |h byte. 1300 | 000046d0 20 20 20 20 20 53 45 49 20 20 20 20 20 20 20 20 | SEI | 000046e0 20 20 20 5c 20 73 65 74 20 69 6e 74 65 72 72 75 | \ set interru| 000046f0 70 74 20 64 69 73 61 62 6c 65 20 66 6c 61 67 0d |pt disable flag.| 00004700 20 31 33 31 30 20 20 20 20 20 20 20 20 20 53 54 | 1310 ST| 00004710 41 20 69 65 72 20 20 20 20 20 20 20 5c 20 64 69 |A ier \ di| 00004720 73 61 62 6c 65 20 6c 69 67 68 74 20 70 65 6e 20 |sable light pen | 00004730 69 6e 74 65 72 72 75 70 74 0d 20 31 33 32 30 20 |interrupt. 1320 | 00004740 20 20 20 20 20 20 20 20 53 54 58 20 69 72 71 32 | STX irq2| 00004750 76 20 20 20 20 20 5c 20 72 65 73 74 6f 72 65 20 |v \ restore | 00004760 6f 72 69 67 69 6e 61 6c 20 76 65 63 74 6f 72 2c |original vector,| 00004770 20 6c 6f 77 20 62 79 74 65 0d 20 31 33 33 30 20 | low byte. 1330 | 00004780 20 20 20 20 20 20 20 20 53 54 59 20 69 72 71 32 | STY irq2| 00004790 76 2b 31 20 20 20 5c 20 72 65 73 74 6f 72 65 20 |v+1 \ restore | 000047a0 6f 72 69 67 69 6e 61 6c 20 76 65 63 74 6f 72 2c |original vector,| 000047b0 20 68 69 67 68 20 62 79 74 65 0d 20 31 33 34 30 | high byte. 1340| 000047c0 20 20 20 20 20 20 20 20 20 43 4c 49 20 20 20 20 | CLI | 000047d0 20 20 20 20 20 20 20 5c 20 63 6c 65 61 72 20 69 | \ clear i| 000047e0 6e 74 65 72 72 75 70 74 20 64 69 73 61 62 6c 65 |nterrupt disable| 000047f0 20 66 6c 61 67 0d 20 31 33 35 30 20 5c 20 20 20 | flag. 1350 \ | 00004800 20 20 20 20 4c 44 41 20 23 26 45 39 20 20 20 20 | LDA #&E9 | 00004810 20 20 5c 20 77 72 69 74 65 20 73 79 73 74 65 6d | \ write system| 00004820 20 56 49 41 20 49 52 51 20 62 69 74 20 6d 61 73 | VIA IRQ bit mas| 00004830 6b 0d 20 31 33 36 30 20 5c 20 20 20 20 20 20 20 |k. 1360 \ | 00004840 4c 44 58 20 23 26 46 46 20 20 20 20 20 20 5c 20 |LDX #&FF \ | 00004850 25 31 31 31 31 31 31 31 31 0d 20 31 33 37 30 20 |%11111111. 1370 | 00004860 5c 20 20 20 20 20 20 20 4c 44 59 20 23 26 30 30 |\ LDY #&00| 00004870 0d 20 31 33 38 30 20 5c 20 20 20 20 20 20 20 4a |. 1380 \ J| 00004880 53 52 20 6f 73 62 79 74 65 20 20 20 20 5c 20 62 |SR osbyte \ b| 00004890 69 74 20 6d 61 73 6b 20 3d 20 64 65 66 61 75 6c |it mask = defaul| 000048a0 74 0d 20 31 33 39 30 20 20 20 20 20 20 20 20 20 |t. 1390 | 000048b0 52 54 53 0d 20 31 34 30 30 20 2e 65 78 69 74 0d |RTS. 1400 .exit.| 000048c0 20 31 34 31 30 20 20 20 20 20 20 20 20 20 50 4c | 1410 PL| 000048d0 41 20 20 20 20 20 20 20 20 20 20 20 5c 20 70 75 |A \ pu| 000048e0 6c 6c 20 69 6e 74 65 72 72 75 70 74 20 61 63 63 |ll interrupt acc| 000048f0 75 6d 75 6c 61 74 6f 72 20 73 61 76 65 20 72 65 |umulator save re| 00004900 67 69 73 74 65 72 0d 20 31 34 32 30 20 20 20 20 |gister. 1420 | 00004910 20 20 20 20 20 53 54 41 20 26 46 43 20 20 20 20 | STA &FC | 00004920 20 20 20 5c 20 72 65 73 74 6f 72 65 20 69 6e 74 | \ restore int| 00004930 65 72 72 75 70 74 20 61 63 63 75 6d 75 6c 61 74 |errupt accumulat| 00004940 6f 72 20 73 61 76 65 20 72 65 67 69 73 74 65 72 |or save register| 00004950 0d 20 31 34 33 30 20 20 20 20 20 20 20 20 20 4a |. 1430 J| 00004960 4d 50 20 28 6f 6c 64 69 72 71 32 76 29 20 5c 20 |MP (oldirq2v) \ | 00004970 65 78 69 74 20 76 69 61 20 6f 72 69 67 69 6e 61 |exit via origina| 00004980 6c 20 76 65 63 74 6f 72 0d 20 31 34 34 30 20 2e |l vector. 1440 .| 00004990 69 6e 74 65 72 72 75 70 74 0d 20 31 34 35 30 20 |interrupt. 1450 | 000049a0 20 20 20 20 20 20 20 20 4c 44 41 20 26 46 43 20 | LDA &FC | 000049b0 20 20 20 20 20 20 5c 20 6c 6f 61 64 20 69 6e 74 | \ load int| 000049c0 65 72 72 75 70 74 20 61 63 63 75 6d 75 6c 61 74 |errupt accumulat| 000049d0 6f 72 20 73 61 76 65 20 72 65 67 69 73 74 65 72 |or save register| 000049e0 0d 20 31 34 36 30 20 20 20 20 20 20 20 20 20 50 |. 1460 P| 000049f0 48 41 20 20 20 20 20 20 20 20 20 20 20 5c 20 61 |HA \ a| 00004a00 6e 64 20 70 75 73 68 20 69 74 20 6f 6e 20 74 68 |nd push it on th| 00004a10 65 20 73 74 61 63 6b 0d 20 31 34 37 30 20 20 20 |e stack. 1470 | 00004a20 20 20 20 20 20 20 4c 44 41 20 69 66 72 20 20 20 | LDA ifr | 00004a30 20 20 20 20 5c 20 6c 6f 61 64 20 73 79 73 74 65 | \ load syste| 00004a40 6d 20 56 49 41 20 69 6e 74 65 72 72 75 70 74 20 |m VIA interrupt | 00004a50 73 74 61 74 75 73 0d 20 31 34 38 30 20 20 20 20 |status. 1480 | 00004a60 20 20 20 20 20 42 50 4c 20 65 78 69 74 20 20 20 | BPL exit | 00004a70 20 20 20 5c 20 65 78 69 74 20 69 66 20 62 69 74 | \ exit if bit| 00004a80 20 37 20 63 6c 65 61 72 0d 20 31 34 39 30 20 20 | 7 clear. 1490 | 00004a90 20 20 20 20 20 20 20 41 4e 44 20 23 26 30 38 20 | AND #&08 | 00004aa0 20 20 20 20 20 5c 20 41 4e 44 20 77 69 74 68 20 | \ AND with | 00004ab0 25 30 30 30 30 31 30 30 30 0d 20 31 35 30 30 20 |%00001000. 1500 | 00004ac0 20 20 20 20 20 20 20 20 42 45 51 20 65 78 69 74 | BEQ exit| 00004ad0 20 20 20 20 20 20 5c 20 65 78 69 74 20 69 66 20 | \ exit if | 00004ae0 6e 6f 74 20 6c 69 67 68 74 20 70 65 6e 20 69 6e |not light pen in| 00004af0 74 65 72 72 75 70 74 0d 20 31 35 31 30 20 20 20 |terrupt. 1510 | 00004b00 20 20 20 20 20 20 54 58 41 0d 20 31 35 32 30 20 | TXA. 1520 | 00004b10 20 20 20 20 20 20 20 20 50 48 41 0d 20 31 35 33 | PHA. 153| 00004b20 30 20 20 20 20 20 20 20 20 20 54 59 41 0d 20 31 |0 TYA. 1| 00004b30 35 34 30 20 20 20 20 20 20 20 20 20 50 48 41 0d |540 PHA.| 00004b40 20 31 35 35 30 20 20 20 20 20 20 20 20 20 4c 44 | 1550 LD| 00004b50 41 20 64 72 62 20 20 20 20 20 20 20 5c 20 63 6c |A drb \ cl| 00004b60 65 61 72 20 69 6e 74 65 72 72 75 70 74 0d 20 31 |ear interrupt. 1| 00004b70 35 36 30 20 20 20 20 20 20 20 20 20 50 48 41 20 |560 PHA | 00004b80 20 20 20 20 20 20 20 20 20 20 5c 20 70 75 73 68 | \ push| 00004b90 20 64 61 74 61 20 72 65 67 69 73 74 65 72 20 42 | data register B| 00004ba0 0d 20 31 35 37 30 20 20 20 20 20 20 20 20 20 4c |. 1570 L| 00004bb0 44 59 20 73 63 72 65 65 6e 20 20 20 20 5c 20 73 |DY screen \ s| 00004bc0 63 72 65 65 6e 20 6d 6f 64 65 20 69 6e 74 6f 20 |creen mode into | 00004bd0 59 20 72 65 67 69 73 74 65 72 0d 20 31 35 38 30 |Y register. 1580| 00004be0 20 20 20 20 20 20 20 20 20 4c 44 58 20 23 26 31 | LDX #&1| 00004bf0 31 20 20 20 20 20 20 5c 20 6c 69 67 68 74 20 70 |1 \ light p| 00004c00 65 6e 20 72 65 67 69 73 74 65 72 2c 20 6c 6f 77 |en register, low| 00004c10 20 62 79 74 65 0d 20 31 35 39 30 20 20 20 20 20 | byte. 1590 | 00004c20 20 20 20 20 53 54 58 20 73 68 65 69 6c 61 20 20 | STX sheila | 00004c30 20 20 5c 20 36 38 34 35 20 61 64 64 72 65 73 73 | \ 6845 address| 00004c40 20 72 65 67 69 73 74 65 72 0d 20 31 36 30 30 20 | register. 1600 | 00004c50 20 20 20 20 20 20 20 20 4c 44 41 20 73 68 65 69 | LDA shei| 00004c60 6c 61 2b 31 20 20 5c 20 36 38 34 35 20 64 61 74 |la+1 \ 6845 dat| 00004c70 61 20 72 65 67 69 73 74 65 72 0d 20 31 36 31 30 |a register. 1610| 00004c80 20 20 20 20 20 20 20 20 20 43 4c 44 20 20 20 20 | CLD | 00004c90 20 20 20 20 20 20 20 5c 20 63 6c 65 61 72 20 64 | \ clear d| 00004ca0 65 63 69 6d 61 6c 20 66 6c 61 67 0d 20 31 36 32 |ecimal flag. 162| 00004cb0 30 20 20 20 20 20 20 20 20 20 53 45 43 20 20 20 |0 SEC | 00004cc0 20 20 20 20 20 20 20 20 5c 20 70 72 65 70 61 72 | \ prepar| 00004cd0 65 20 66 6f 72 20 73 75 62 74 72 61 63 74 69 6f |e for subtractio| 00004ce0 6e 0d 20 31 36 33 30 20 20 20 20 20 20 20 20 20 |n. 1630 | 00004cf0 53 42 43 20 6f 66 66 73 65 74 6c 6f 77 2c 59 20 |SBC offsetlow,Y | 00004d00 5c 20 73 75 62 74 72 61 63 74 20 73 63 72 65 65 |\ subtract scree| 00004d10 6e 20 6d 6f 64 65 20 6f 66 66 73 65 74 0d 20 31 |n mode offset. 1| 00004d20 36 34 30 20 20 20 20 20 20 20 20 20 53 54 41 20 |640 STA | 00004d30 79 63 6f 6f 72 64 20 20 20 20 5c 20 6c 6f 77 20 |ycoord \ low | 00004d40 62 79 74 65 20 2d 20 6f 66 66 73 65 74 0d 20 31 |byte - offset. 1| 00004d50 36 35 30 20 20 20 20 20 20 20 20 20 44 45 58 20 |650 DEX | 00004d60 20 20 20 20 20 20 20 20 20 20 5c 20 58 20 3d 20 | \ X = | 00004d70 26 31 30 2c 20 6c 69 67 68 74 20 70 65 6e 20 72 |&10, light pen r| 00004d80 65 67 69 73 74 65 72 2c 20 68 69 67 68 20 62 79 |egister, high by| 00004d90 74 65 0d 20 31 36 36 30 20 20 20 20 20 20 20 20 |te. 1660 | 00004da0 20 53 54 58 20 73 68 65 69 6c 61 20 20 20 20 5c | STX sheila \| 00004db0 20 36 38 34 35 20 61 64 64 72 65 73 73 20 72 65 | 6845 address re| 00004dc0 67 69 73 74 65 72 0d 20 31 36 37 30 20 20 20 20 |gister. 1670 | 00004dd0 20 20 20 20 20 4c 44 41 20 73 68 65 69 6c 61 2b | LDA sheila+| 00004de0 31 20 20 5c 20 36 38 34 35 20 64 61 74 61 20 72 |1 \ 6845 data r| 00004df0 65 67 69 73 74 65 72 0d 20 31 36 38 30 20 20 20 |egister. 1680 | 00004e00 20 20 20 20 20 20 53 42 43 20 6f 66 66 73 65 74 | SBC offset| 00004e10 68 69 67 68 2c 59 20 5c 20 73 75 62 74 72 61 63 |high,Y \ subtrac| 00004e20 74 20 73 63 72 65 65 6e 20 6d 6f 64 65 20 6f 66 |t screen mode of| 00004e30 66 73 65 74 0d 20 31 36 39 30 20 20 20 20 20 20 |fset. 1690 | 00004e40 20 20 20 53 54 41 20 79 63 6f 6f 72 64 2b 31 20 | STA ycoord+1 | 00004e50 20 5c 20 68 69 67 68 20 62 79 74 65 20 2d 20 6f | \ high byte - o| 00004e60 66 66 73 65 74 0d 20 31 37 30 30 20 20 20 20 20 |ffset. 1700 | 00004e70 20 20 20 20 4c 44 41 20 23 26 30 30 20 20 20 20 | LDA #&00 | 00004e80 20 20 5c 20 70 72 65 70 61 72 65 20 66 6f 72 20 | \ prepare for | 00004e90 31 36 20 62 69 74 20 64 69 76 69 73 69 6f 6e 0d |16 bit division.| 00004ea0 20 31 37 31 30 20 20 20 20 20 20 20 20 20 53 54 | 1710 ST| 00004eb0 41 20 78 63 6f 6f 72 64 20 20 20 20 5c 20 63 6c |A xcoord \ cl| 00004ec0 65 61 72 20 6c 6f 77 20 70 61 72 74 69 61 6c 20 |ear low partial | 00004ed0 64 69 76 69 64 65 6e 64 0d 20 31 37 32 30 20 2e |dividend. 1720 .| 00004ee0 6e 65 78 74 0d 20 31 37 33 30 20 20 20 20 20 20 |next. 1730 | 00004ef0 20 20 20 41 53 4c 20 79 63 6f 6f 72 64 20 20 20 | ASL ycoord | 00004f00 20 5c 20 73 68 69 66 74 20 64 69 76 69 64 65 6e | \ shift dividen| 00004f10 64 2f 71 75 6f 74 69 65 6e 74 20 6c 65 66 74 0d |d/quotient left.| 00004f20 20 31 37 34 30 20 20 20 20 20 20 20 20 20 52 4f | 1740 RO| 00004f30 4c 20 79 63 6f 6f 72 64 2b 31 20 20 5c 20 73 68 |L ycoord+1 \ sh| 00004f40 69 66 74 20 64 69 76 69 64 65 6e 64 2f 71 75 6f |ift dividend/quo| 00004f50 74 69 65 6e 74 20 6c 65 66 74 0d 20 31 37 35 30 |tient left. 1750| 00004f60 20 20 20 20 20 20 20 20 20 52 4f 4c 20 78 63 6f | ROL xco| 00004f70 6f 72 64 20 20 20 20 5c 20 73 68 69 66 74 20 62 |ord \ shift b| 00004f80 69 74 73 20 69 6e 74 6f 20 70 61 72 74 69 61 6c |its into partial| 00004f90 20 64 69 76 69 64 65 6e 64 0d 20 31 37 36 30 20 | dividend. 1760 | 00004fa0 20 20 20 20 20 20 20 20 4c 44 41 20 78 63 6f 6f | LDA xcoo| 00004fb0 72 64 20 20 20 20 5c 20 6c 6f 61 64 20 70 61 72 |rd \ load par| 00004fc0 74 69 61 6c 20 64 69 76 69 64 65 6e 64 0d 20 31 |tial dividend. 1| 00004fd0 37 37 30 20 20 20 20 20 20 20 20 20 53 45 43 20 |770 SEC | 00004fe0 20 20 20 20 20 20 20 20 20 20 5c 20 70 72 65 70 | \ prep| 00004ff0 61 72 65 20 66 6f 72 20 73 75 62 74 72 61 63 74 |are for subtract| 00005000 69 6f 6e 0d 20 31 37 38 30 20 20 20 20 20 20 20 |ion. 1780 | 00005010 20 20 53 42 43 20 77 69 64 74 68 2c 59 20 20 20 | SBC width,Y | 00005020 5c 20 73 75 62 74 72 61 63 74 20 64 69 76 69 73 |\ subtract divis| 00005030 6f 72 0d 20 31 37 39 30 20 20 20 20 20 20 20 20 |or. 1790 | 00005040 20 42 43 43 20 64 6f 6e 65 20 20 20 20 20 20 5c | BCC done \| 00005050 20 62 72 61 6e 63 68 20 69 66 20 64 69 76 69 64 | branch if divid| 00005060 65 6e 64 20 3c 20 64 69 76 69 73 6f 72 0d 20 31 |end < divisor. 1| 00005070 38 30 30 20 20 20 20 20 20 20 20 20 49 4e 43 20 |800 INC | 00005080 79 63 6f 6f 72 64 20 20 20 20 5c 20 69 6e 63 72 |ycoord \ incr| 00005090 65 6d 65 6e 74 20 71 75 6f 74 69 65 6e 74 0d 20 |ement quotient. | 000050a0 31 38 31 30 20 20 20 20 20 20 20 20 20 53 54 41 |1810 STA| 000050b0 20 78 63 6f 6f 72 64 20 20 20 20 5c 20 73 61 76 | xcoord \ sav| 000050c0 65 20 6e 65 77 20 70 61 72 74 69 61 6c 20 64 69 |e new partial di| 000050d0 76 69 64 65 6e 64 0d 20 31 38 32 30 20 2e 64 6f |vidend. 1820 .do| 000050e0 6e 65 0d 20 31 38 33 30 20 20 20 20 20 20 20 20 |ne. 1830 | 000050f0 20 44 45 58 20 20 20 20 20 20 20 20 20 20 20 5c | DEX \| 00005100 20 64 65 63 72 65 6d 65 6e 74 20 62 69 74 20 63 | decrement bit c| 00005110 6f 75 6e 74 65 72 0d 20 31 38 34 30 20 20 20 20 |ounter. 1840 | 00005120 20 20 20 20 20 42 4e 45 20 6e 65 78 74 20 20 20 | BNE next | 00005130 20 20 20 5c 20 62 72 61 6e 63 68 20 66 6f 72 20 | \ branch for | 00005140 31 36 20 62 69 74 73 0d 20 31 38 35 30 20 20 20 |16 bits. 1850 | 00005150 20 20 20 20 20 20 4c 44 41 20 73 63 61 6c 65 2c | LDA scale,| 00005160 59 20 20 20 5c 20 73 63 72 65 65 6e 20 6d 6f 64 |Y \ screen mod| 00005170 65 20 73 63 61 6c 65 0d 20 31 38 36 30 20 20 20 |e scale. 1860 | 00005180 20 20 20 20 20 20 42 45 51 20 70 75 6c 6c 6f 75 | BEQ pullou| 00005190 74 20 20 20 5c 20 62 72 61 6e 63 68 20 69 66 20 |t \ branch if | 000051a0 6d 6f 64 65 73 20 30 2c 20 33 2c 20 34 2c 20 36 |modes 0, 3, 4, 6| 000051b0 20 6f 72 20 37 0d 20 31 38 37 30 20 20 20 20 20 | or 7. 1870 | 000051c0 20 20 20 20 54 41 58 20 20 20 20 20 20 20 20 20 | TAX | 000051d0 20 20 5c 20 69 6e 20 6d 6f 64 65 31 20 61 6e 64 | \ in mode1 and| 000051e0 20 6d 6f 64 65 35 20 58 3d 31 2c 20 69 6e 20 6d | mode5 X=1, in m| 000051f0 6f 64 65 32 20 58 3d 32 0d 20 31 38 38 30 20 20 |ode2 X=2. 1880 | 00005200 20 20 20 20 20 20 20 4c 44 41 20 78 63 6f 6f 72 | LDA xcoor| 00005210 64 0d 20 31 38 39 30 20 2e 72 65 64 75 63 65 0d |d. 1890 .reduce.| 00005220 20 31 39 30 30 20 20 20 20 20 20 20 20 20 4c 53 | 1900 LS| 00005230 52 20 41 20 20 20 20 20 20 20 20 20 5c 20 68 6f |R A \ ho| 00005240 72 69 7a 6f 6e 74 61 6c 20 70 6f 73 69 74 69 6f |rizontal positio| 00005250 6e 20 2f 20 32 0d 20 31 39 31 30 20 20 20 20 20 |n / 2. 1910 | 00005260 20 20 20 20 44 45 58 0d 20 31 39 32 30 20 20 20 | DEX. 1920 | 00005270 20 20 20 20 20 20 42 4e 45 20 72 65 64 75 63 65 | BNE reduce| 00005280 0d 20 31 39 33 30 20 20 20 20 20 20 20 20 20 53 |. 1930 S| 00005290 54 41 20 78 63 6f 6f 72 64 0d 20 31 39 34 30 20 |TA xcoord. 1940 | 000052a0 2e 70 75 6c 6c 6f 75 74 0d 20 31 39 35 30 20 20 |.pullout. 1950 | 000052b0 20 20 20 20 20 20 20 50 4c 41 20 20 20 20 20 20 | PLA | 000052c0 20 20 20 20 20 5c 20 70 75 6c 6c 20 64 61 74 61 | \ pull data| 000052d0 20 72 65 67 69 73 74 65 72 20 42 0d 20 31 39 36 | register B. 196| 000052e0 30 20 20 20 20 20 20 20 20 20 41 4e 44 20 23 26 |0 AND #&| 000052f0 32 30 20 20 20 20 20 20 5c 20 25 30 30 31 30 30 |20 \ %00100| 00005300 30 30 30 0d 20 31 39 37 30 20 20 20 20 20 20 20 |000. 1970 | 00005310 20 20 53 54 41 20 66 69 72 65 20 20 20 20 20 20 | STA fire | 00005320 5c 20 73 74 6f 72 65 20 66 69 72 65 20 62 75 74 |\ store fire but| 00005330 74 6f 6e 20 73 74 61 74 75 73 0d 20 31 39 38 30 |ton status. 1980| 00005340 20 20 20 20 20 20 20 20 20 50 4c 41 0d 20 31 39 | PLA. 19| 00005350 39 30 20 20 20 20 20 20 20 20 20 54 41 59 0d 20 |90 TAY. | 00005360 32 30 30 30 20 20 20 20 20 20 20 20 20 50 4c 41 |2000 PLA| 00005370 0d 20 32 30 31 30 20 20 20 20 20 20 20 20 20 54 |. 2010 T| 00005380 41 58 0d 20 32 30 32 30 20 20 20 20 20 20 20 20 |AX. 2020 | 00005390 20 50 4c 41 0d 20 32 30 33 30 20 20 20 20 20 20 | PLA. 2030 | 000053a0 20 20 20 53 54 41 20 26 46 43 0d 20 32 30 34 30 | STA &FC. 2040| 000053b0 20 20 20 20 20 20 20 20 20 52 54 49 20 20 20 20 | RTI | 000053c0 20 20 20 20 20 20 20 5c 20 72 65 74 75 72 6e 20 | \ return | 000053d0 66 72 6f 6d 20 69 6e 74 65 72 72 75 70 74 0d 20 |from interrupt. | 000053e0 32 30 35 30 20 2e 6f 6c 64 69 72 71 32 76 0d 20 |2050 .oldirq2v. | 000053f0 32 30 36 30 20 20 20 20 20 20 20 20 20 45 51 55 |2060 EQU| 00005400 57 20 26 30 30 20 20 20 20 20 20 5c 20 6f 72 69 |W &00 \ ori| 00005410 67 69 6e 61 6c 20 69 72 71 32 20 76 65 63 74 6f |ginal irq2 vecto| 00005420 72 0d 20 32 30 37 30 20 2e 6f 66 66 73 65 74 6c |r. 2070 .offsetl| 00005430 6f 77 0d 20 32 30 38 30 20 20 20 20 20 20 20 20 |ow. 2080 | 00005440 20 45 51 55 42 20 26 30 34 20 20 20 20 20 20 5c | EQUB &04 \| 00005450 20 6d 6f 64 65 30 2c 20 75 6e 74 72 69 6d 6d 65 | mode0, untrimme| 00005460 64 20 3d 20 26 30 36 0d 20 32 30 39 30 20 20 20 |d = &06. 2090 | 00005470 20 20 20 20 20 20 45 51 55 42 20 26 30 34 20 20 | EQUB &04 | 00005480 20 20 20 20 5c 20 6d 6f 64 65 31 2c 20 75 6e 74 | \ mode1, unt| 00005490 72 69 6d 6d 65 64 20 3d 20 26 30 36 0d 20 32 31 |rimmed = &06. 21| 000054a0 30 30 20 20 20 20 20 20 20 20 20 45 51 55 42 20 |00 EQUB | 000054b0 26 30 34 20 20 20 20 20 20 5c 20 6d 6f 64 65 32 |&04 \ mode2| 000054c0 2c 20 75 6e 74 72 69 6d 6d 65 64 20 3d 20 26 30 |, untrimmed = &0| 000054d0 36 0d 20 32 31 31 30 20 20 20 20 20 20 20 20 20 |6. 2110 | 000054e0 45 51 55 42 20 26 30 34 20 20 20 20 20 20 5c 20 |EQUB &04 \ | 000054f0 6d 6f 64 65 33 2c 20 75 6e 74 72 69 6d 6d 65 64 |mode3, untrimmed| 00005500 20 3d 20 26 30 36 0d 20 32 31 32 30 20 20 20 20 | = &06. 2120 | 00005510 20 20 20 20 20 45 51 55 42 20 26 30 33 20 20 20 | EQUB &03 | 00005520 20 20 20 5c 20 6d 6f 64 65 34 2c 20 75 6e 74 72 | \ mode4, untr| 00005530 69 6d 6d 65 64 20 3d 20 26 30 34 0d 20 32 31 33 |immed = &04. 213| 00005540 30 20 20 20 20 20 20 20 20 20 45 51 55 42 20 26 |0 EQUB &| 00005550 30 33 20 20 20 20 20 20 5c 20 6d 6f 64 65 35 2c |03 \ mode5,| 00005560 20 75 6e 74 72 69 6d 6d 65 64 20 3d 20 26 30 34 | untrimmed = &04| 00005570 0d 20 32 31 34 30 20 20 20 20 20 20 20 20 20 45 |. 2140 E| 00005580 51 55 42 20 26 30 33 20 20 20 20 20 20 5c 20 6d |QUB &03 \ m| 00005590 6f 64 65 36 2c 20 75 6e 74 72 69 6d 6d 65 64 20 |ode6, untrimmed | 000055a0 3d 20 26 30 34 0d 20 32 31 35 30 20 20 20 20 20 |= &04. 2150 | 000055b0 20 20 20 20 45 51 55 42 20 26 30 36 20 20 20 20 | EQUB &06 | 000055c0 20 20 5c 20 6d 6f 64 65 37 2c 20 75 6e 74 72 69 | \ mode7, untri| 000055d0 6d 6d 65 64 20 3d 20 26 30 38 0d 20 32 31 36 30 |mmed = &08. 2160| 000055e0 20 2e 6f 66 66 73 65 74 68 69 67 68 0d 20 32 31 | .offsethigh. 21| 000055f0 37 30 20 20 20 20 20 20 20 20 20 45 51 55 44 20 |70 EQUD | 00005600 26 30 38 30 36 30 36 30 36 20 5c 20 6d 6f 64 65 |&08060606 \ mode| 00005610 73 20 33 2d 30 0d 20 32 31 38 30 20 20 20 20 20 |s 3-0. 2180 | 00005620 20 20 20 20 45 51 55 44 20 26 32 38 30 43 30 42 | EQUD &280C0B| 00005630 30 42 20 5c 20 6d 6f 64 65 73 20 37 2d 34 0d 20 |0B \ modes 7-4. | 00005640 32 31 39 30 20 2e 73 63 61 6c 65 0d 20 32 32 30 |2190 .scale. 220| 00005650 30 20 20 20 20 20 20 20 20 20 45 51 55 44 20 26 |0 EQUD &| 00005660 30 30 30 32 30 31 30 30 20 5c 20 6d 6f 64 65 73 |00020100 \ modes| 00005670 20 33 2d 30 0d 20 32 32 31 30 20 20 20 20 20 20 | 3-0. 2210 | 00005680 20 20 20 45 51 55 44 20 26 30 30 30 30 30 31 30 | EQUD &0000010| 00005690 30 20 5c 20 6d 6f 64 65 73 20 37 2d 34 0d 20 32 |0 \ modes 7-4. 2| 000056a0 32 32 30 20 2e 77 69 64 74 68 0d 20 32 32 33 30 |220 .width. 2230| 000056b0 20 20 20 20 20 20 20 20 20 45 51 55 44 20 26 35 | EQUD &5| 000056c0 30 35 30 35 30 35 30 20 5c 20 6d 6f 64 65 73 20 |0505050 \ modes | 000056d0 33 2d 30 0d 20 32 32 34 30 20 20 20 20 20 20 20 |3-0. 2240 | 000056e0 20 20 45 51 55 44 20 26 32 38 32 38 32 38 32 38 | EQUD &28282828| 000056f0 20 5c 20 6d 6f 64 65 73 20 37 2d 34 0d 20 32 32 | \ modes 7-4. 22| 00005700 35 30 20 2e 6c 61 73 74 62 79 74 65 0d 20 32 32 |50 .lastbyte. 22| 00005710 36 30 20 5d 0d 20 32 32 37 30 20 4e 45 58 54 0d |60 ]. 2270 NEXT.| 00005720 20 32 32 38 30 20 43 41 4c 4c 20 6d 63 6f 64 65 | 2280 CALL mcode| 00005730 0d 20 32 32 39 30 20 45 4e 44 50 52 4f 43 0d 20 |. 2290 ENDPROC. | 00005740 32 33 30 30 20 3a 20 0d 20 32 33 31 30 20 44 45 |2300 : . 2310 DE| 00005750 46 46 4e 73 77 69 74 63 68 0d 20 32 33 32 30 20 |FFNswitch. 2320 | 00005760 49 46 20 28 41 44 56 41 4c 28 30 29 41 4e 44 33 |IF (ADVAL(0)AND3| 00005770 29 3d 30 20 3d 54 52 55 45 20 45 4c 53 45 20 3d |)=0 =TRUE ELSE =| 00005780 46 41 4c 53 45 0d |FALSE.| 00005786