Home » CEEFAX disks » telesoftware11.adl » 02-12-88/T\MOU02

02-12-88/T\MOU02

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 » telesoftware11.adl
Filename: 02-12-88/T\MOU02
Read OK:
File size: 275F bytes
Load address: 0000
Exec address: 0000
File contents
Using a mouse with the BBC microcomputer - by - Gordon Horsington
-----------------------------------------------------------------

Module 2. Tube compatible mouse software
----------------------------------------

Interrupts generated by I/O processor hardware are not passed to a second
processor. The IRQ1V and IRQ2V vectors are not implemented by the second
processor operating system. For this reason interrupts generated by a
mouse connected to the User Port must be dealt with by software in the I/O
processor.

It is quite straightforward to assemble code in the second processor and
use Osword &06 to transfer the code from the second processor to the I/O
processor. The real problem is to change the I/O processor primary
interrupt vector from a second processor. An interrupt vector should only
be altered with interrupts disabled but it is not possible to disable the
I/O processor interrupts from the second processor.

One way of overcoming this problem is to use either *CODE or *LINE to
alter the vector for you. Both *CODE and *LINE use the User Vector and
this vector can be altered with the I/O processor interrupts enabled. The
program SPMOUSE alters the User Vector and then uses *CODE to disable the
I/O processor interrupts, alter IRQ1V, and then re-enable the I/O
processor interrupts. An alternative method is available to disc users who
can assemble the I/O processor routine in the second processor, save it
onto disc and then *RUN it from disc in the I/O processor. This would be
far too inconvenient to do with a tape storage system.

The demonstration program SPMOUSE is assembled with the program counter
starting at &A00, the destination address for the I/O processor machine
code. After assembly the proceedure PROCwrite is used to transfer every
byte of the assembled machine code into page &0A of the I/O processor. It
is also used to revector the User Vector to point to &A00. The command
*CODE will then revector IRQ1V to point to the code labeled interrupt,
which is now in the I/O processor.

After IRQ1V has been revectored to the new I/O processor routine, the
mouse generated interrupts can be dealt with in the I/O processor in
exactly the same way as illustrated in module 1 and the result can be read
at any time by the second processor using Osword &05 (or simply peeked if
the second processor is not being used).

Osword &05 is implemented in the function FNread. This function reads a
byte of I/O processor memory and can be used from either the second
processor or the I/O processor. It is, however, very slow when compared
with using the BASIC indirection operators and, if the program using the
mouse is running in the I/O processor, it is far quicker to peek and poke
the memory locations directly than to use Osword &05.

Chain the program SPMOUSE which can be used with either a 6502 second
processor or with the I/O processor on its own. The mouse buttons are
polled using Osbyte &96 to read a byte in Sheila. This routine is Tube
compatible and faster than Osword &05. Osbytes &92 to &97 can be used to
read or write to memory mapped I/O hardware and are all much quicker than
using either Osword &05 or Osword &06 in this area of memory.


   10 REM> SPMOUSE
   20 DIM param &10 :REM: Osword parameter block
   30 DIM mcode &100 :REM: assemble at mcode
   40 ioaddr=&A00 :REM: address for machine code
   50 xcoord=&80 :REM: x coordinate, range 0-255
   60 ycoord=&81 :REM: y coordinate, range 0-255
   70 savereg=&FC :REM: interrupt accumulator save register
   80 userv=&200 :REM: user vector
   90 irq1v=&204 :REM: primary interrupt vector
  100 drb=&FE60 :REM: data register B
  110 ddrb=&FE62 :REM: data direction register B
  120 pcr=&FE6C :REM: peripheral control register
  130 ifr=&FE6D :REM: interrupt flag register
  140 ier=&FE6E :REM: interrupt enable register
  150 osword=&FFF1
  160 osbyte=&FFF4
  170 FOR pass=4 TO 6 STEP 2
  180 O%=mcode
  190 P%=ioaddr
  200 [       OPT pass
  210         CMP #&00      \ is this *CODE?
  220         BNE return    \ return if not *CODE
  230         LDX irq1v     \ current primary interrupt vector, low byte
  240         LDY irq1v+1   \ current primary interrupt vector, high byte
  250         CPY #interrupt DIV 256 \ compare high byte
  260         BEQ disable   \ restore old vector if altered
  270         STX oldirq1v  \ save original irq1 vector, low byte
  280         STY oldirq1v+1 \ save original irq1 vector, high byte
  290         LDX #interrupt MOD 256 \ new irq1 vector, low byte
  300         LDY #interrupt DIV 256 \ new irq1 vector, high byte
  310         SEI           \ set interrupt disable flag
  320         STX irq1v     \ alter irq1 vector, low byte
  330         STY irq1v+1   \ alter irq1 vector, high byte
  340         CLI           \ clear interrupt disable flag
  350         LDA #&98      \ %10011000, ie. enable CB1/2
  360         STA ier       \ interrupt enable register
  370         LDA pcr       \ peripheral control register
  380         AND #&0F      \ AND with %00001111, ie clear bits 4-7
  390         ORA #&50      \ OR with %01010000, ie. set bits 4 and 6
  400         STA pcr       \ interrupt on +ve transition, CB2 input,
                            \ DRB to clear
  410         LDA #0        \ user port input
  420         STA ddrb      \ data direction register B
  430         STA xcoord    \ initial value for x coordinate
  440         STA ycoord    \ initial value for y coordinate
  450 .return
  460         RTS           \ return to BASIC
  470 .disable
  480         LDA #&18      \ %00011000 ready to clear bits 3 and 4 of ier
  490         LDX oldirq1v  \ original irq1 vector, low byte
  500         LDY oldirq1v+1 \ original irq1 vector, high byte
  510         SEI           \ set interrupt disable flag
  520         STA ier       \ interrupt enable register
  530         LDA pcr       \ peripheral control register
  540         AND #&0F      \ clear bits 4-7
  550         STA pcr       \ peripheral control register
  560         STX irq1v     \ restore the original irq1 vector, low byte
  570         STY irq1v+1   \ restore the original irq1 vector, high byte
  580         CLI           \ clear interrupt disable flag
  590         RTS           \ return to BASIC
  600 .interrupt
  610         LDA savereg   \ interrupt accumulator save register
  620         PHA           \ and push it on the stack
  630         LDA ifr       \ interrupt flag register
  640         BPL notuser   \ bit 7 is set if VIA-B interrupt
  650         AND #&18      \ AND with %00011000, ie. test bits 3 and 4
  660         BEQ notuser   \ exit if not CB1 or CB2
  670         AND #&10      \ AND with %00010000, ie. test bit 4
  680         BNE xpulse    \ bit 4 set for an X direction movement
  690         LDA drb       \ Y direction, load data register B
  700         AND #&04      \ AND with %00000100, ie. test bit 2
  710         BNE ydown     \ if bit 2 is set then Y is going down
  720         INC ycoord    \ Y is going up so increment Y coordinate
  730         BNE exit      \ branch if in the range 1 to 255
  740         BEQ decy      \ if zero then alter to 255
  750 .ydown
  760         LDA ycoord    \ load Y coordinate
  770         BEQ exit      \ branch if zero because it can't go any lower
  780 .decy
  790         DEC ycoord    \ reduce Y coordinate by 1
  800         JMP exit      \ restore interrupt accumulator save register
                            \ and RTI
  810 .xpulse
  820         LDA drb       \ load data register B
  830         ROR A         \ bit 0 into carry
  840         BCS xdown     \ X is going down if bit 0 is set
  850         INC xcoord    \ X is going up if bit 0 is clear
  860         BNE exit      \ exit if X coordinate is in the range
                            \ from 1 to 255
  870         BEQ decx      \ if X coordinate = 0 then make it 255
  880 .xdown
  890         LDA xcoord    \ load X coordinate
  900         BEQ exit      \ if it is zero it can't go any lower
  910 .decx
  920         DEC xcoord    \ decrease X coordinate by 1
  930 .exit
  940         PLA           \ pull interrupt accumulator save register off
                            \ the stack
  950         STA savereg   \ and restore zero page
  960         RTI           \ return from interrupt
  970 .notuser
  980         PLA           \ pull the interrupt accumulator save register
                            \ off the stack
  990         STA savereg   \ restore the zero page address
 1000         JMP (oldirq1v) \ exit via the original vector
 1010 .oldirq1v
 1020         EQUW &00      \ original irq1 vector
 1030 .lastbyte
 1040 ]
 1050 NEXT
 1060 end=mcode+(lastbyte-ioaddr)
 1070 addr=ioaddr
 1080 FOR byte=mcode TO end
 1090 PROCwrite(?byte,addr)
 1100 addr=addr+1
 1110 NEXT
 1120 PROCwrite((ioaddr MOD 256),userv)
 1130 PROCwrite((ioaddr DIV 256),userv+1)
 1140 *CODE
 1150 MODE7
 1160 mouse$=CHR$141+CHR$132+CHR$157+CHR$131+
      "Mouse coordinates, range &00-&FF  "+CHR$156
 1170 PRINTTAB(0,1)mouse$
 1180 PRINTTAB(0,2)mouse$
 1190 ONERROR GOTO 1290
 1200 VDU23,1,0;0;0;0;
 1210 PRINTTAB(10,7)"Bytes used = &";~(lastbyte-ioaddr)
 1220 REPEAT
 1230 PRINTTAB(10,12)"X = &";~FNread(&80);" "
 1240 PRINTTAB(20,12)"Y = &";~FNread(&81);" "
 1250 IF FNright PRINTTAB(22,17)"Right" ELSE PRINTTAB(22,17)"     "
 1260 IF FNcentre PRINTTAB(15,17)"Centre" ELSE PRINTTAB(15,17)"      "
 1270 IF FNleft PRINTTAB(10,17)"Left" ELSE PRINTTAB(10,17)"    "
 1280 UNTIL FALSE
 1290 *CODE
 1300 VDU23,1,1;0;0;0;31,0,23
 1310 END
 1320 DEFPROCwrite(data,addr)
 1330 !param=addr OR &FFFF0000
 1340 param?4=data
 1350 A%=6
 1360 X%=param MOD 256
 1370 Y%=param DIV 256
 1380 CALL osword
 1390 ENDPROC
 1400 DEFFNread(addr)
 1410 !param=addr OR &FFFF0000
 1420 A%=5
 1430 X%=param MOD 256
 1440 Y%=param DIV 256
 1450 CALL osword
 1460 =param?4
 1470 DEFFNbutton
 1480 A%=&96
 1490 X%=&60
 1500 =(USR(osbyte) AND &FF0000)DIV&10000
 1510 DEFFNright
 1520 =((FNbutton AND &80)=0)
 1530 DEFFNcentre
 1540 =((FNbutton AND &40)=0)
 1550 DEFFNleft
 1560 =((FNbutton AND &20)=0)
00000000  55 73 69 6e 67 20 61 20  6d 6f 75 73 65 20 77 69  |Using a mouse wi|
00000010  74 68 20 74 68 65 20 42  42 43 20 6d 69 63 72 6f  |th the BBC micro|
00000020  63 6f 6d 70 75 74 65 72  20 2d 20 62 79 20 2d 20  |computer - by - |
00000030  47 6f 72 64 6f 6e 20 48  6f 72 73 69 6e 67 74 6f  |Gordon Horsingto|
00000040  6e 0d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |n.--------------|
00000050  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000080  2d 2d 2d 0d 0d 4d 6f 64  75 6c 65 20 32 2e 20 54  |---..Module 2. T|
00000090  75 62 65 20 63 6f 6d 70  61 74 69 62 6c 65 20 6d  |ube compatible m|
000000a0  6f 75 73 65 20 73 6f 66  74 77 61 72 65 0d 2d 2d  |ouse software.--|
000000b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000000d0  2d 2d 2d 2d 2d 2d 0d 0d  49 6e 74 65 72 72 75 70  |------..Interrup|
000000e0  74 73 20 67 65 6e 65 72  61 74 65 64 20 62 79 20  |ts generated by |
000000f0  49 2f 4f 20 70 72 6f 63  65 73 73 6f 72 20 68 61  |I/O processor ha|
00000100  72 64 77 61 72 65 20 61  72 65 20 6e 6f 74 20 70  |rdware are not p|
00000110  61 73 73 65 64 20 74 6f  20 61 20 73 65 63 6f 6e  |assed to a secon|
00000120  64 0d 70 72 6f 63 65 73  73 6f 72 2e 20 54 68 65  |d.processor. The|
00000130  20 49 52 51 31 56 20 61  6e 64 20 49 52 51 32 56  | IRQ1V and IRQ2V|
00000140  20 76 65 63 74 6f 72 73  20 61 72 65 20 6e 6f 74  | vectors are not|
00000150  20 69 6d 70 6c 65 6d 65  6e 74 65 64 20 62 79 20  | implemented by |
00000160  74 68 65 20 73 65 63 6f  6e 64 0d 70 72 6f 63 65  |the second.proce|
00000170  73 73 6f 72 20 6f 70 65  72 61 74 69 6e 67 20 73  |ssor operating s|
00000180  79 73 74 65 6d 2e 20 46  6f 72 20 74 68 69 73 20  |ystem. For this |
00000190  72 65 61 73 6f 6e 20 69  6e 74 65 72 72 75 70 74  |reason interrupt|
000001a0  73 20 67 65 6e 65 72 61  74 65 64 20 62 79 20 61  |s generated by a|
000001b0  0d 6d 6f 75 73 65 20 63  6f 6e 6e 65 63 74 65 64  |.mouse connected|
000001c0  20 74 6f 20 74 68 65 20  55 73 65 72 20 50 6f 72  | to the User Por|
000001d0  74 20 6d 75 73 74 20 62  65 20 64 65 61 6c 74 20  |t must be dealt |
000001e0  77 69 74 68 20 62 79 20  73 6f 66 74 77 61 72 65  |with by software|
000001f0  20 69 6e 20 74 68 65 20  49 2f 4f 0d 70 72 6f 63  | in the I/O.proc|
00000200  65 73 73 6f 72 2e 0d 0d  49 74 20 69 73 20 71 75  |essor...It is qu|
00000210  69 74 65 20 73 74 72 61  69 67 68 74 66 6f 72 77  |ite straightforw|
00000220  61 72 64 20 74 6f 20 61  73 73 65 6d 62 6c 65 20  |ard to assemble |
00000230  63 6f 64 65 20 69 6e 20  74 68 65 20 73 65 63 6f  |code in the seco|
00000240  6e 64 20 70 72 6f 63 65  73 73 6f 72 20 61 6e 64  |nd processor and|
00000250  0d 75 73 65 20 4f 73 77  6f 72 64 20 26 30 36 20  |.use Osword &06 |
00000260  74 6f 20 74 72 61 6e 73  66 65 72 20 74 68 65 20  |to transfer the |
00000270  63 6f 64 65 20 66 72 6f  6d 20 74 68 65 20 73 65  |code from the se|
00000280  63 6f 6e 64 20 70 72 6f  63 65 73 73 6f 72 20 74  |cond processor t|
00000290  6f 20 74 68 65 20 49 2f  4f 0d 70 72 6f 63 65 73  |o the I/O.proces|
000002a0  73 6f 72 2e 20 54 68 65  20 72 65 61 6c 20 70 72  |sor. The real pr|
000002b0  6f 62 6c 65 6d 20 69 73  20 74 6f 20 63 68 61 6e  |oblem is to chan|
000002c0  67 65 20 74 68 65 20 49  2f 4f 20 70 72 6f 63 65  |ge the I/O proce|
000002d0  73 73 6f 72 20 70 72 69  6d 61 72 79 0d 69 6e 74  |ssor primary.int|
000002e0  65 72 72 75 70 74 20 76  65 63 74 6f 72 20 66 72  |errupt vector fr|
000002f0  6f 6d 20 61 20 73 65 63  6f 6e 64 20 70 72 6f 63  |om a second proc|
00000300  65 73 73 6f 72 2e 20 41  6e 20 69 6e 74 65 72 72  |essor. An interr|
00000310  75 70 74 20 76 65 63 74  6f 72 20 73 68 6f 75 6c  |upt vector shoul|
00000320  64 20 6f 6e 6c 79 0d 62  65 20 61 6c 74 65 72 65  |d only.be altere|
00000330  64 20 77 69 74 68 20 69  6e 74 65 72 72 75 70 74  |d with interrupt|
00000340  73 20 64 69 73 61 62 6c  65 64 20 62 75 74 20 69  |s disabled but i|
00000350  74 20 69 73 20 6e 6f 74  20 70 6f 73 73 69 62 6c  |t is not possibl|
00000360  65 20 74 6f 20 64 69 73  61 62 6c 65 20 74 68 65  |e to disable the|
00000370  0d 49 2f 4f 20 70 72 6f  63 65 73 73 6f 72 20 69  |.I/O processor i|
00000380  6e 74 65 72 72 75 70 74  73 20 66 72 6f 6d 20 74  |nterrupts from t|
00000390  68 65 20 73 65 63 6f 6e  64 20 70 72 6f 63 65 73  |he second proces|
000003a0  73 6f 72 2e 0d 0d 4f 6e  65 20 77 61 79 20 6f 66  |sor...One way of|
000003b0  20 6f 76 65 72 63 6f 6d  69 6e 67 20 74 68 69 73  | overcoming this|
000003c0  20 70 72 6f 62 6c 65 6d  20 69 73 20 74 6f 20 75  | problem is to u|
000003d0  73 65 20 65 69 74 68 65  72 20 2a 43 4f 44 45 20  |se either *CODE |
000003e0  6f 72 20 2a 4c 49 4e 45  20 74 6f 0d 61 6c 74 65  |or *LINE to.alte|
000003f0  72 20 74 68 65 20 76 65  63 74 6f 72 20 66 6f 72  |r the vector for|
00000400  20 79 6f 75 2e 20 42 6f  74 68 20 2a 43 4f 44 45  | you. Both *CODE|
00000410  20 61 6e 64 20 2a 4c 49  4e 45 20 75 73 65 20 74  | and *LINE use t|
00000420  68 65 20 55 73 65 72 20  56 65 63 74 6f 72 20 61  |he User Vector a|
00000430  6e 64 0d 74 68 69 73 20  76 65 63 74 6f 72 20 63  |nd.this vector c|
00000440  61 6e 20 62 65 20 61 6c  74 65 72 65 64 20 77 69  |an be altered wi|
00000450  74 68 20 74 68 65 20 49  2f 4f 20 70 72 6f 63 65  |th the I/O proce|
00000460  73 73 6f 72 20 69 6e 74  65 72 72 75 70 74 73 20  |ssor interrupts |
00000470  65 6e 61 62 6c 65 64 2e  20 54 68 65 0d 70 72 6f  |enabled. The.pro|
00000480  67 72 61 6d 20 53 50 4d  4f 55 53 45 20 61 6c 74  |gram SPMOUSE alt|
00000490  65 72 73 20 74 68 65 20  55 73 65 72 20 56 65 63  |ers the User Vec|
000004a0  74 6f 72 20 61 6e 64 20  74 68 65 6e 20 75 73 65  |tor and then use|
000004b0  73 20 2a 43 4f 44 45 20  74 6f 20 64 69 73 61 62  |s *CODE to disab|
000004c0  6c 65 20 74 68 65 0d 49  2f 4f 20 70 72 6f 63 65  |le the.I/O proce|
000004d0  73 73 6f 72 20 69 6e 74  65 72 72 75 70 74 73 2c  |ssor interrupts,|
000004e0  20 61 6c 74 65 72 20 49  52 51 31 56 2c 20 61 6e  | alter IRQ1V, an|
000004f0  64 20 74 68 65 6e 20 72  65 2d 65 6e 61 62 6c 65  |d then re-enable|
00000500  20 74 68 65 20 49 2f 4f  0d 70 72 6f 63 65 73 73  | the I/O.process|
00000510  6f 72 20 69 6e 74 65 72  72 75 70 74 73 2e 20 41  |or interrupts. A|
00000520  6e 20 61 6c 74 65 72 6e  61 74 69 76 65 20 6d 65  |n alternative me|
00000530  74 68 6f 64 20 69 73 20  61 76 61 69 6c 61 62 6c  |thod is availabl|
00000540  65 20 74 6f 20 64 69 73  63 20 75 73 65 72 73 20  |e to disc users |
00000550  77 68 6f 0d 63 61 6e 20  61 73 73 65 6d 62 6c 65  |who.can assemble|
00000560  20 74 68 65 20 49 2f 4f  20 70 72 6f 63 65 73 73  | the I/O process|
00000570  6f 72 20 72 6f 75 74 69  6e 65 20 69 6e 20 74 68  |or routine in th|
00000580  65 20 73 65 63 6f 6e 64  20 70 72 6f 63 65 73 73  |e second process|
00000590  6f 72 2c 20 73 61 76 65  20 69 74 0d 6f 6e 74 6f  |or, save it.onto|
000005a0  20 64 69 73 63 20 61 6e  64 20 74 68 65 6e 20 2a  | disc and then *|
000005b0  52 55 4e 20 69 74 20 66  72 6f 6d 20 64 69 73 63  |RUN it from disc|
000005c0  20 69 6e 20 74 68 65 20  49 2f 4f 20 70 72 6f 63  | in the I/O proc|
000005d0  65 73 73 6f 72 2e 20 54  68 69 73 20 77 6f 75 6c  |essor. This woul|
000005e0  64 20 62 65 0d 66 61 72  20 74 6f 6f 20 69 6e 63  |d be.far too inc|
000005f0  6f 6e 76 65 6e 69 65 6e  74 20 74 6f 20 64 6f 20  |onvenient to do |
00000600  77 69 74 68 20 61 20 74  61 70 65 20 73 74 6f 72  |with a tape stor|
00000610  61 67 65 20 73 79 73 74  65 6d 2e 0d 0d 54 68 65  |age system...The|
00000620  20 64 65 6d 6f 6e 73 74  72 61 74 69 6f 6e 20 70  | demonstration p|
00000630  72 6f 67 72 61 6d 20 53  50 4d 4f 55 53 45 20 69  |rogram SPMOUSE i|
00000640  73 20 61 73 73 65 6d 62  6c 65 64 20 77 69 74 68  |s assembled with|
00000650  20 74 68 65 20 70 72 6f  67 72 61 6d 20 63 6f 75  | the program cou|
00000660  6e 74 65 72 0d 73 74 61  72 74 69 6e 67 20 61 74  |nter.starting at|
00000670  20 26 41 30 30 2c 20 74  68 65 20 64 65 73 74 69  | &A00, the desti|
00000680  6e 61 74 69 6f 6e 20 61  64 64 72 65 73 73 20 66  |nation address f|
00000690  6f 72 20 74 68 65 20 49  2f 4f 20 70 72 6f 63 65  |or the I/O proce|
000006a0  73 73 6f 72 20 6d 61 63  68 69 6e 65 0d 63 6f 64  |ssor machine.cod|
000006b0  65 2e 20 41 66 74 65 72  20 61 73 73 65 6d 62 6c  |e. After assembl|
000006c0  79 20 74 68 65 20 70 72  6f 63 65 65 64 75 72 65  |y the proceedure|
000006d0  20 50 52 4f 43 77 72 69  74 65 20 69 73 20 75 73  | PROCwrite is us|
000006e0  65 64 20 74 6f 20 74 72  61 6e 73 66 65 72 20 65  |ed to transfer e|
000006f0  76 65 72 79 0d 62 79 74  65 20 6f 66 20 74 68 65  |very.byte of the|
00000700  20 61 73 73 65 6d 62 6c  65 64 20 6d 61 63 68 69  | assembled machi|
00000710  6e 65 20 63 6f 64 65 20  69 6e 74 6f 20 70 61 67  |ne code into pag|
00000720  65 20 26 30 41 20 6f 66  20 74 68 65 20 49 2f 4f  |e &0A of the I/O|
00000730  20 70 72 6f 63 65 73 73  6f 72 2e 20 49 74 0d 69  | processor. It.i|
00000740  73 20 61 6c 73 6f 20 75  73 65 64 20 74 6f 20 72  |s also used to r|
00000750  65 76 65 63 74 6f 72 20  74 68 65 20 55 73 65 72  |evector the User|
00000760  20 56 65 63 74 6f 72 20  74 6f 20 70 6f 69 6e 74  | Vector to point|
00000770  20 74 6f 20 26 41 30 30  2e 20 54 68 65 20 63 6f  | to &A00. The co|
00000780  6d 6d 61 6e 64 0d 2a 43  4f 44 45 20 77 69 6c 6c  |mmand.*CODE will|
00000790  20 74 68 65 6e 20 72 65  76 65 63 74 6f 72 20 49  | then revector I|
000007a0  52 51 31 56 20 74 6f 20  70 6f 69 6e 74 20 74 6f  |RQ1V to point to|
000007b0  20 74 68 65 20 63 6f 64  65 20 6c 61 62 65 6c 65  | the code labele|
000007c0  64 20 69 6e 74 65 72 72  75 70 74 2c 0d 77 68 69  |d interrupt,.whi|
000007d0  63 68 20 69 73 20 6e 6f  77 20 69 6e 20 74 68 65  |ch is now in the|
000007e0  20 49 2f 4f 20 70 72 6f  63 65 73 73 6f 72 2e 0d  | I/O processor..|
000007f0  0d 41 66 74 65 72 20 49  52 51 31 56 20 68 61 73  |.After IRQ1V has|
00000800  20 62 65 65 6e 20 72 65  76 65 63 74 6f 72 65 64  | been revectored|
00000810  20 74 6f 20 74 68 65 20  6e 65 77 20 49 2f 4f 20  | to the new I/O |
00000820  70 72 6f 63 65 73 73 6f  72 20 72 6f 75 74 69 6e  |processor routin|
00000830  65 2c 20 74 68 65 0d 6d  6f 75 73 65 20 67 65 6e  |e, the.mouse gen|
00000840  65 72 61 74 65 64 20 69  6e 74 65 72 72 75 70 74  |erated interrupt|
00000850  73 20 63 61 6e 20 62 65  20 64 65 61 6c 74 20 77  |s can be dealt w|
00000860  69 74 68 20 69 6e 20 74  68 65 20 49 2f 4f 20 70  |ith in the I/O p|
00000870  72 6f 63 65 73 73 6f 72  20 69 6e 0d 65 78 61 63  |rocessor in.exac|
00000880  74 6c 79 20 74 68 65 20  73 61 6d 65 20 77 61 79  |tly the same way|
00000890  20 61 73 20 69 6c 6c 75  73 74 72 61 74 65 64 20  | as illustrated |
000008a0  69 6e 20 6d 6f 64 75 6c  65 20 31 20 61 6e 64 20  |in module 1 and |
000008b0  74 68 65 20 72 65 73 75  6c 74 20 63 61 6e 20 62  |the result can b|
000008c0  65 20 72 65 61 64 0d 61  74 20 61 6e 79 20 74 69  |e read.at any ti|
000008d0  6d 65 20 62 79 20 74 68  65 20 73 65 63 6f 6e 64  |me by the second|
000008e0  20 70 72 6f 63 65 73 73  6f 72 20 75 73 69 6e 67  | processor using|
000008f0  20 4f 73 77 6f 72 64 20  26 30 35 20 28 6f 72 20  | Osword &05 (or |
00000900  73 69 6d 70 6c 79 20 70  65 65 6b 65 64 20 69 66  |simply peeked if|
00000910  0d 74 68 65 20 73 65 63  6f 6e 64 20 70 72 6f 63  |.the second proc|
00000920  65 73 73 6f 72 20 69 73  20 6e 6f 74 20 62 65 69  |essor is not bei|
00000930  6e 67 20 75 73 65 64 29  2e 0d 0d 4f 73 77 6f 72  |ng used)...Oswor|
00000940  64 20 26 30 35 20 69 73  20 69 6d 70 6c 65 6d 65  |d &05 is impleme|
00000950  6e 74 65 64 20 69 6e 20  74 68 65 20 66 75 6e 63  |nted in the func|
00000960  74 69 6f 6e 20 46 4e 72  65 61 64 2e 20 54 68 69  |tion FNread. Thi|
00000970  73 20 66 75 6e 63 74 69  6f 6e 20 72 65 61 64 73  |s function reads|
00000980  20 61 0d 62 79 74 65 20  6f 66 20 49 2f 4f 20 70  | a.byte of I/O p|
00000990  72 6f 63 65 73 73 6f 72  20 6d 65 6d 6f 72 79 20  |rocessor memory |
000009a0  61 6e 64 20 63 61 6e 20  62 65 20 75 73 65 64 20  |and can be used |
000009b0  66 72 6f 6d 20 65 69 74  68 65 72 20 74 68 65 20  |from either the |
000009c0  73 65 63 6f 6e 64 0d 70  72 6f 63 65 73 73 6f 72  |second.processor|
000009d0  20 6f 72 20 74 68 65 20  49 2f 4f 20 70 72 6f 63  | or the I/O proc|
000009e0  65 73 73 6f 72 2e 20 49  74 20 69 73 2c 20 68 6f  |essor. It is, ho|
000009f0  77 65 76 65 72 2c 20 76  65 72 79 20 73 6c 6f 77  |wever, very slow|
00000a00  20 77 68 65 6e 20 63 6f  6d 70 61 72 65 64 0d 77  | when compared.w|
00000a10  69 74 68 20 75 73 69 6e  67 20 74 68 65 20 42 41  |ith using the BA|
00000a20  53 49 43 20 69 6e 64 69  72 65 63 74 69 6f 6e 20  |SIC indirection |
00000a30  6f 70 65 72 61 74 6f 72  73 20 61 6e 64 2c 20 69  |operators and, i|
00000a40  66 20 74 68 65 20 70 72  6f 67 72 61 6d 20 75 73  |f the program us|
00000a50  69 6e 67 20 74 68 65 0d  6d 6f 75 73 65 20 69 73  |ing the.mouse is|
00000a60  20 72 75 6e 6e 69 6e 67  20 69 6e 20 74 68 65 20  | running in the |
00000a70  49 2f 4f 20 70 72 6f 63  65 73 73 6f 72 2c 20 69  |I/O processor, i|
00000a80  74 20 69 73 20 66 61 72  20 71 75 69 63 6b 65 72  |t is far quicker|
00000a90  20 74 6f 20 70 65 65 6b  20 61 6e 64 20 70 6f 6b  | to peek and pok|
00000aa0  65 0d 74 68 65 20 6d 65  6d 6f 72 79 20 6c 6f 63  |e.the memory loc|
00000ab0  61 74 69 6f 6e 73 20 64  69 72 65 63 74 6c 79 20  |ations directly |
00000ac0  74 68 61 6e 20 74 6f 20  75 73 65 20 4f 73 77 6f  |than to use Oswo|
00000ad0  72 64 20 26 30 35 2e 0d  0d 43 68 61 69 6e 20 74  |rd &05...Chain t|
00000ae0  68 65 20 70 72 6f 67 72  61 6d 20 53 50 4d 4f 55  |he program SPMOU|
00000af0  53 45 20 77 68 69 63 68  20 63 61 6e 20 62 65 20  |SE which can be |
00000b00  75 73 65 64 20 77 69 74  68 20 65 69 74 68 65 72  |used with either|
00000b10  20 61 20 36 35 30 32 20  73 65 63 6f 6e 64 0d 70  | a 6502 second.p|
00000b20  72 6f 63 65 73 73 6f 72  20 6f 72 20 77 69 74 68  |rocessor or with|
00000b30  20 74 68 65 20 49 2f 4f  20 70 72 6f 63 65 73 73  | the I/O process|
00000b40  6f 72 20 6f 6e 20 69 74  73 20 6f 77 6e 2e 20 54  |or on its own. T|
00000b50  68 65 20 6d 6f 75 73 65  20 62 75 74 74 6f 6e 73  |he mouse buttons|
00000b60  20 61 72 65 0d 70 6f 6c  6c 65 64 20 75 73 69 6e  | are.polled usin|
00000b70  67 20 4f 73 62 79 74 65  20 26 39 36 20 74 6f 20  |g Osbyte &96 to |
00000b80  72 65 61 64 20 61 20 62  79 74 65 20 69 6e 20 53  |read a byte in S|
00000b90  68 65 69 6c 61 2e 20 54  68 69 73 20 72 6f 75 74  |heila. This rout|
00000ba0  69 6e 65 20 69 73 20 54  75 62 65 0d 63 6f 6d 70  |ine is Tube.comp|
00000bb0  61 74 69 62 6c 65 20 61  6e 64 20 66 61 73 74 65  |atible and faste|
00000bc0  72 20 74 68 61 6e 20 4f  73 77 6f 72 64 20 26 30  |r than Osword &0|
00000bd0  35 2e 20 4f 73 62 79 74  65 73 20 26 39 32 20 74  |5. Osbytes &92 t|
00000be0  6f 20 26 39 37 20 63 61  6e 20 62 65 20 75 73 65  |o &97 can be use|
00000bf0  64 20 74 6f 0d 72 65 61  64 20 6f 72 20 77 72 69  |d to.read or wri|
00000c00  74 65 20 74 6f 20 6d 65  6d 6f 72 79 20 6d 61 70  |te to memory map|
00000c10  70 65 64 20 49 2f 4f 20  68 61 72 64 77 61 72 65  |ped I/O hardware|
00000c20  20 61 6e 64 20 61 72 65  20 61 6c 6c 20 6d 75 63  | and are all muc|
00000c30  68 20 71 75 69 63 6b 65  72 20 74 68 61 6e 0d 75  |h quicker than.u|
00000c40  73 69 6e 67 20 65 69 74  68 65 72 20 4f 73 77 6f  |sing either Oswo|
00000c50  72 64 20 26 30 35 20 6f  72 20 4f 73 77 6f 72 64  |rd &05 or Osword|
00000c60  20 26 30 36 20 69 6e 20  74 68 69 73 20 61 72 65  | &06 in this are|
00000c70  61 20 6f 66 20 6d 65 6d  6f 72 79 2e 0d 0d 0d 20  |a of memory.... |
00000c80  20 20 31 30 20 52 45 4d  3e 20 53 50 4d 4f 55 53  |  10 REM> SPMOUS|
00000c90  45 0d 20 20 20 32 30 20  44 49 4d 20 70 61 72 61  |E.   20 DIM para|
00000ca0  6d 20 26 31 30 20 3a 52  45 4d 3a 20 4f 73 77 6f  |m &10 :REM: Oswo|
00000cb0  72 64 20 70 61 72 61 6d  65 74 65 72 20 62 6c 6f  |rd parameter blo|
00000cc0  63 6b 0d 20 20 20 33 30  20 44 49 4d 20 6d 63 6f  |ck.   30 DIM mco|
00000cd0  64 65 20 26 31 30 30 20  3a 52 45 4d 3a 20 61 73  |de &100 :REM: as|
00000ce0  73 65 6d 62 6c 65 20 61  74 20 6d 63 6f 64 65 0d  |semble at mcode.|
00000cf0  20 20 20 34 30 20 69 6f  61 64 64 72 3d 26 41 30  |   40 ioaddr=&A0|
00000d00  30 20 3a 52 45 4d 3a 20  61 64 64 72 65 73 73 20  |0 :REM: address |
00000d10  66 6f 72 20 6d 61 63 68  69 6e 65 20 63 6f 64 65  |for machine code|
00000d20  0d 20 20 20 35 30 20 78  63 6f 6f 72 64 3d 26 38  |.   50 xcoord=&8|
00000d30  30 20 3a 52 45 4d 3a 20  78 20 63 6f 6f 72 64 69  |0 :REM: x coordi|
00000d40  6e 61 74 65 2c 20 72 61  6e 67 65 20 30 2d 32 35  |nate, range 0-25|
00000d50  35 0d 20 20 20 36 30 20  79 63 6f 6f 72 64 3d 26  |5.   60 ycoord=&|
00000d60  38 31 20 3a 52 45 4d 3a  20 79 20 63 6f 6f 72 64  |81 :REM: y coord|
00000d70  69 6e 61 74 65 2c 20 72  61 6e 67 65 20 30 2d 32  |inate, range 0-2|
00000d80  35 35 0d 20 20 20 37 30  20 73 61 76 65 72 65 67  |55.   70 savereg|
00000d90  3d 26 46 43 20 3a 52 45  4d 3a 20 69 6e 74 65 72  |=&FC :REM: inter|
00000da0  72 75 70 74 20 61 63 63  75 6d 75 6c 61 74 6f 72  |rupt accumulator|
00000db0  20 73 61 76 65 20 72 65  67 69 73 74 65 72 0d 20  | save register. |
00000dc0  20 20 38 30 20 75 73 65  72 76 3d 26 32 30 30 20  |  80 userv=&200 |
00000dd0  3a 52 45 4d 3a 20 75 73  65 72 20 76 65 63 74 6f  |:REM: user vecto|
00000de0  72 0d 20 20 20 39 30 20  69 72 71 31 76 3d 26 32  |r.   90 irq1v=&2|
00000df0  30 34 20 3a 52 45 4d 3a  20 70 72 69 6d 61 72 79  |04 :REM: primary|
00000e00  20 69 6e 74 65 72 72 75  70 74 20 76 65 63 74 6f  | interrupt vecto|
00000e10  72 0d 20 20 31 30 30 20  64 72 62 3d 26 46 45 36  |r.  100 drb=&FE6|
00000e20  30 20 3a 52 45 4d 3a 20  64 61 74 61 20 72 65 67  |0 :REM: data reg|
00000e30  69 73 74 65 72 20 42 0d  20 20 31 31 30 20 64 64  |ister B.  110 dd|
00000e40  72 62 3d 26 46 45 36 32  20 3a 52 45 4d 3a 20 64  |rb=&FE62 :REM: d|
00000e50  61 74 61 20 64 69 72 65  63 74 69 6f 6e 20 72 65  |ata direction re|
00000e60  67 69 73 74 65 72 20 42  0d 20 20 31 32 30 20 70  |gister B.  120 p|
00000e70  63 72 3d 26 46 45 36 43  20 3a 52 45 4d 3a 20 70  |cr=&FE6C :REM: p|
00000e80  65 72 69 70 68 65 72 61  6c 20 63 6f 6e 74 72 6f  |eripheral contro|
00000e90  6c 20 72 65 67 69 73 74  65 72 0d 20 20 31 33 30  |l register.  130|
00000ea0  20 69 66 72 3d 26 46 45  36 44 20 3a 52 45 4d 3a  | ifr=&FE6D :REM:|
00000eb0  20 69 6e 74 65 72 72 75  70 74 20 66 6c 61 67 20  | interrupt flag |
00000ec0  72 65 67 69 73 74 65 72  0d 20 20 31 34 30 20 69  |register.  140 i|
00000ed0  65 72 3d 26 46 45 36 45  20 3a 52 45 4d 3a 20 69  |er=&FE6E :REM: i|
00000ee0  6e 74 65 72 72 75 70 74  20 65 6e 61 62 6c 65 20  |nterrupt enable |
00000ef0  72 65 67 69 73 74 65 72  0d 20 20 31 35 30 20 6f  |register.  150 o|
00000f00  73 77 6f 72 64 3d 26 46  46 46 31 0d 20 20 31 36  |sword=&FFF1.  16|
00000f10  30 20 6f 73 62 79 74 65  3d 26 46 46 46 34 0d 20  |0 osbyte=&FFF4. |
00000f20  20 31 37 30 20 46 4f 52  20 70 61 73 73 3d 34 20  | 170 FOR pass=4 |
00000f30  54 4f 20 36 20 53 54 45  50 20 32 0d 20 20 31 38  |TO 6 STEP 2.  18|
00000f40  30 20 4f 25 3d 6d 63 6f  64 65 0d 20 20 31 39 30  |0 O%=mcode.  190|
00000f50  20 50 25 3d 69 6f 61 64  64 72 0d 20 20 32 30 30  | P%=ioaddr.  200|
00000f60  20 5b 20 20 20 20 20 20  20 4f 50 54 20 70 61 73  | [       OPT pas|
00000f70  73 0d 20 20 32 31 30 20  20 20 20 20 20 20 20 20  |s.  210         |
00000f80  43 4d 50 20 23 26 30 30  20 20 20 20 20 20 5c 20  |CMP #&00      \ |
00000f90  69 73 20 74 68 69 73 20  2a 43 4f 44 45 3f 0d 20  |is this *CODE?. |
00000fa0  20 32 32 30 20 20 20 20  20 20 20 20 20 42 4e 45  | 220         BNE|
00000fb0  20 72 65 74 75 72 6e 20  20 20 20 5c 20 72 65 74  | return    \ ret|
00000fc0  75 72 6e 20 69 66 20 6e  6f 74 20 2a 43 4f 44 45  |urn if not *CODE|
00000fd0  0d 20 20 32 33 30 20 20  20 20 20 20 20 20 20 4c  |.  230         L|
00000fe0  44 58 20 69 72 71 31 76  20 20 20 20 20 5c 20 63  |DX irq1v     \ c|
00000ff0  75 72 72 65 6e 74 20 70  72 69 6d 61 72 79 20 69  |urrent primary i|
00001000  6e 74 65 72 72 75 70 74  20 76 65 63 74 6f 72 2c  |nterrupt vector,|
00001010  20 6c 6f 77 20 62 79 74  65 0d 20 20 32 34 30 20  | low byte.  240 |
00001020  20 20 20 20 20 20 20 20  4c 44 59 20 69 72 71 31  |        LDY irq1|
00001030  76 2b 31 20 20 20 5c 20  63 75 72 72 65 6e 74 20  |v+1   \ current |
00001040  70 72 69 6d 61 72 79 20  69 6e 74 65 72 72 75 70  |primary interrup|
00001050  74 20 76 65 63 74 6f 72  2c 20 68 69 67 68 20 62  |t vector, high b|
00001060  79 74 65 0d 20 20 32 35  30 20 20 20 20 20 20 20  |yte.  250       |
00001070  20 20 43 50 59 20 23 69  6e 74 65 72 72 75 70 74  |  CPY #interrupt|
00001080  20 44 49 56 20 32 35 36  20 5c 20 63 6f 6d 70 61  | DIV 256 \ compa|
00001090  72 65 20 68 69 67 68 20  62 79 74 65 0d 20 20 32  |re high byte.  2|
000010a0  36 30 20 20 20 20 20 20  20 20 20 42 45 51 20 64  |60         BEQ d|
000010b0  69 73 61 62 6c 65 20 20  20 5c 20 72 65 73 74 6f  |isable   \ resto|
000010c0  72 65 20 6f 6c 64 20 76  65 63 74 6f 72 20 69 66  |re old vector if|
000010d0  20 61 6c 74 65 72 65 64  0d 20 20 32 37 30 20 20  | altered.  270  |
000010e0  20 20 20 20 20 20 20 53  54 58 20 6f 6c 64 69 72  |       STX oldir|
000010f0  71 31 76 20 20 5c 20 73  61 76 65 20 6f 72 69 67  |q1v  \ save orig|
00001100  69 6e 61 6c 20 69 72 71  31 20 76 65 63 74 6f 72  |inal irq1 vector|
00001110  2c 20 6c 6f 77 20 62 79  74 65 0d 20 20 32 38 30  |, low byte.  280|
00001120  20 20 20 20 20 20 20 20  20 53 54 59 20 6f 6c 64  |         STY old|
00001130  69 72 71 31 76 2b 31 20  5c 20 73 61 76 65 20 6f  |irq1v+1 \ save o|
00001140  72 69 67 69 6e 61 6c 20  69 72 71 31 20 76 65 63  |riginal irq1 vec|
00001150  74 6f 72 2c 20 68 69 67  68 20 62 79 74 65 0d 20  |tor, high byte. |
00001160  20 32 39 30 20 20 20 20  20 20 20 20 20 4c 44 58  | 290         LDX|
00001170  20 23 69 6e 74 65 72 72  75 70 74 20 4d 4f 44 20  | #interrupt MOD |
00001180  32 35 36 20 5c 20 6e 65  77 20 69 72 71 31 20 76  |256 \ new irq1 v|
00001190  65 63 74 6f 72 2c 20 6c  6f 77 20 62 79 74 65 0d  |ector, low byte.|
000011a0  20 20 33 30 30 20 20 20  20 20 20 20 20 20 4c 44  |  300         LD|
000011b0  59 20 23 69 6e 74 65 72  72 75 70 74 20 44 49 56  |Y #interrupt DIV|
000011c0  20 32 35 36 20 5c 20 6e  65 77 20 69 72 71 31 20  | 256 \ new irq1 |
000011d0  76 65 63 74 6f 72 2c 20  68 69 67 68 20 62 79 74  |vector, high byt|
000011e0  65 0d 20 20 33 31 30 20  20 20 20 20 20 20 20 20  |e.  310         |
000011f0  53 45 49 20 20 20 20 20  20 20 20 20 20 20 5c 20  |SEI           \ |
00001200  73 65 74 20 69 6e 74 65  72 72 75 70 74 20 64 69  |set interrupt di|
00001210  73 61 62 6c 65 20 66 6c  61 67 0d 20 20 33 32 30  |sable flag.  320|
00001220  20 20 20 20 20 20 20 20  20 53 54 58 20 69 72 71  |         STX irq|
00001230  31 76 20 20 20 20 20 5c  20 61 6c 74 65 72 20 69  |1v     \ alter i|
00001240  72 71 31 20 76 65 63 74  6f 72 2c 20 6c 6f 77 20  |rq1 vector, low |
00001250  62 79 74 65 0d 20 20 33  33 30 20 20 20 20 20 20  |byte.  330      |
00001260  20 20 20 53 54 59 20 69  72 71 31 76 2b 31 20 20  |   STY irq1v+1  |
00001270  20 5c 20 61 6c 74 65 72  20 69 72 71 31 20 76 65  | \ alter irq1 ve|
00001280  63 74 6f 72 2c 20 68 69  67 68 20 62 79 74 65 0d  |ctor, high byte.|
00001290  20 20 33 34 30 20 20 20  20 20 20 20 20 20 43 4c  |  340         CL|
000012a0  49 20 20 20 20 20 20 20  20 20 20 20 5c 20 63 6c  |I           \ cl|
000012b0  65 61 72 20 69 6e 74 65  72 72 75 70 74 20 64 69  |ear interrupt di|
000012c0  73 61 62 6c 65 20 66 6c  61 67 0d 20 20 33 35 30  |sable flag.  350|
000012d0  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 26 39  |         LDA #&9|
000012e0  38 20 20 20 20 20 20 5c  20 25 31 30 30 31 31 30  |8      \ %100110|
000012f0  30 30 2c 20 69 65 2e 20  65 6e 61 62 6c 65 20 43  |00, ie. enable C|
00001300  42 31 2f 32 0d 20 20 33  36 30 20 20 20 20 20 20  |B1/2.  360      |
00001310  20 20 20 53 54 41 20 69  65 72 20 20 20 20 20 20  |   STA ier      |
00001320  20 5c 20 69 6e 74 65 72  72 75 70 74 20 65 6e 61  | \ interrupt ena|
00001330  62 6c 65 20 72 65 67 69  73 74 65 72 0d 20 20 33  |ble register.  3|
00001340  37 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 70  |70         LDA p|
00001350  63 72 20 20 20 20 20 20  20 5c 20 70 65 72 69 70  |cr       \ perip|
00001360  68 65 72 61 6c 20 63 6f  6e 74 72 6f 6c 20 72 65  |heral control re|
00001370  67 69 73 74 65 72 0d 20  20 33 38 30 20 20 20 20  |gister.  380    |
00001380  20 20 20 20 20 41 4e 44  20 23 26 30 46 20 20 20  |     AND #&0F   |
00001390  20 20 20 5c 20 41 4e 44  20 77 69 74 68 20 25 30  |   \ AND with %0|
000013a0  30 30 30 31 31 31 31 2c  20 69 65 20 63 6c 65 61  |0001111, ie clea|
000013b0  72 20 62 69 74 73 20 34  2d 37 0d 20 20 33 39 30  |r bits 4-7.  390|
000013c0  20 20 20 20 20 20 20 20  20 4f 52 41 20 23 26 35  |         ORA #&5|
000013d0  30 20 20 20 20 20 20 5c  20 4f 52 20 77 69 74 68  |0      \ OR with|
000013e0  20 25 30 31 30 31 30 30  30 30 2c 20 69 65 2e 20  | %01010000, ie. |
000013f0  73 65 74 20 62 69 74 73  20 34 20 61 6e 64 20 36  |set bits 4 and 6|
00001400  0d 20 20 34 30 30 20 20  20 20 20 20 20 20 20 53  |.  400         S|
00001410  54 41 20 70 63 72 20 20  20 20 20 20 20 5c 20 69  |TA pcr       \ i|
00001420  6e 74 65 72 72 75 70 74  20 6f 6e 20 2b 76 65 20  |nterrupt on +ve |
00001430  74 72 61 6e 73 69 74 69  6f 6e 2c 20 43 42 32 20  |transition, CB2 |
00001440  69 6e 70 75 74 2c 0d 20  20 20 20 20 20 20 20 20  |input,.         |
00001450  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001460  20 20 20 5c 20 44 52 42  20 74 6f 20 63 6c 65 61  |   \ DRB to clea|
00001470  72 0d 20 20 34 31 30 20  20 20 20 20 20 20 20 20  |r.  410         |
00001480  4c 44 41 20 23 30 20 20  20 20 20 20 20 20 5c 20  |LDA #0        \ |
00001490  75 73 65 72 20 70 6f 72  74 20 69 6e 70 75 74 0d  |user port input.|
000014a0  20 20 34 32 30 20 20 20  20 20 20 20 20 20 53 54  |  420         ST|
000014b0  41 20 64 64 72 62 20 20  20 20 20 20 5c 20 64 61  |A ddrb      \ da|
000014c0  74 61 20 64 69 72 65 63  74 69 6f 6e 20 72 65 67  |ta direction reg|
000014d0  69 73 74 65 72 20 42 0d  20 20 34 33 30 20 20 20  |ister B.  430   |
000014e0  20 20 20 20 20 20 53 54  41 20 78 63 6f 6f 72 64  |      STA xcoord|
000014f0  20 20 20 20 5c 20 69 6e  69 74 69 61 6c 20 76 61  |    \ initial va|
00001500  6c 75 65 20 66 6f 72 20  78 20 63 6f 6f 72 64 69  |lue for x coordi|
00001510  6e 61 74 65 0d 20 20 34  34 30 20 20 20 20 20 20  |nate.  440      |
00001520  20 20 20 53 54 41 20 79  63 6f 6f 72 64 20 20 20  |   STA ycoord   |
00001530  20 5c 20 69 6e 69 74 69  61 6c 20 76 61 6c 75 65  | \ initial value|
00001540  20 66 6f 72 20 79 20 63  6f 6f 72 64 69 6e 61 74  | for y coordinat|
00001550  65 0d 20 20 34 35 30 20  2e 72 65 74 75 72 6e 0d  |e.  450 .return.|
00001560  20 20 34 36 30 20 20 20  20 20 20 20 20 20 52 54  |  460         RT|
00001570  53 20 20 20 20 20 20 20  20 20 20 20 5c 20 72 65  |S           \ re|
00001580  74 75 72 6e 20 74 6f 20  42 41 53 49 43 0d 20 20  |turn to BASIC.  |
00001590  34 37 30 20 2e 64 69 73  61 62 6c 65 0d 20 20 34  |470 .disable.  4|
000015a0  38 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |80         LDA #|
000015b0  26 31 38 20 20 20 20 20  20 5c 20 25 30 30 30 31  |&18      \ %0001|
000015c0  31 30 30 30 20 72 65 61  64 79 20 74 6f 20 63 6c  |1000 ready to cl|
000015d0  65 61 72 20 62 69 74 73  20 33 20 61 6e 64 20 34  |ear bits 3 and 4|
000015e0  20 6f 66 20 69 65 72 0d  20 20 34 39 30 20 20 20  | of ier.  490   |
000015f0  20 20 20 20 20 20 4c 44  58 20 6f 6c 64 69 72 71  |      LDX oldirq|
00001600  31 76 20 20 5c 20 6f 72  69 67 69 6e 61 6c 20 69  |1v  \ original i|
00001610  72 71 31 20 76 65 63 74  6f 72 2c 20 6c 6f 77 20  |rq1 vector, low |
00001620  62 79 74 65 0d 20 20 35  30 30 20 20 20 20 20 20  |byte.  500      |
00001630  20 20 20 4c 44 59 20 6f  6c 64 69 72 71 31 76 2b  |   LDY oldirq1v+|
00001640  31 20 5c 20 6f 72 69 67  69 6e 61 6c 20 69 72 71  |1 \ original irq|
00001650  31 20 76 65 63 74 6f 72  2c 20 68 69 67 68 20 62  |1 vector, high b|
00001660  79 74 65 0d 20 20 35 31  30 20 20 20 20 20 20 20  |yte.  510       |
00001670  20 20 53 45 49 20 20 20  20 20 20 20 20 20 20 20  |  SEI           |
00001680  5c 20 73 65 74 20 69 6e  74 65 72 72 75 70 74 20  |\ set interrupt |
00001690  64 69 73 61 62 6c 65 20  66 6c 61 67 0d 20 20 35  |disable flag.  5|
000016a0  32 30 20 20 20 20 20 20  20 20 20 53 54 41 20 69  |20         STA i|
000016b0  65 72 20 20 20 20 20 20  20 5c 20 69 6e 74 65 72  |er       \ inter|
000016c0  72 75 70 74 20 65 6e 61  62 6c 65 20 72 65 67 69  |rupt enable regi|
000016d0  73 74 65 72 0d 20 20 35  33 30 20 20 20 20 20 20  |ster.  530      |
000016e0  20 20 20 4c 44 41 20 70  63 72 20 20 20 20 20 20  |   LDA pcr      |
000016f0  20 5c 20 70 65 72 69 70  68 65 72 61 6c 20 63 6f  | \ peripheral co|
00001700  6e 74 72 6f 6c 20 72 65  67 69 73 74 65 72 0d 20  |ntrol register. |
00001710  20 35 34 30 20 20 20 20  20 20 20 20 20 41 4e 44  | 540         AND|
00001720  20 23 26 30 46 20 20 20  20 20 20 5c 20 63 6c 65  | #&0F      \ cle|
00001730  61 72 20 62 69 74 73 20  34 2d 37 0d 20 20 35 35  |ar bits 4-7.  55|
00001740  30 20 20 20 20 20 20 20  20 20 53 54 41 20 70 63  |0         STA pc|
00001750  72 20 20 20 20 20 20 20  5c 20 70 65 72 69 70 68  |r       \ periph|
00001760  65 72 61 6c 20 63 6f 6e  74 72 6f 6c 20 72 65 67  |eral control reg|
00001770  69 73 74 65 72 0d 20 20  35 36 30 20 20 20 20 20  |ister.  560     |
00001780  20 20 20 20 53 54 58 20  69 72 71 31 76 20 20 20  |    STX irq1v   |
00001790  20 20 5c 20 72 65 73 74  6f 72 65 20 74 68 65 20  |  \ restore the |
000017a0  6f 72 69 67 69 6e 61 6c  20 69 72 71 31 20 76 65  |original irq1 ve|
000017b0  63 74 6f 72 2c 20 6c 6f  77 20 62 79 74 65 0d 20  |ctor, low byte. |
000017c0  20 35 37 30 20 20 20 20  20 20 20 20 20 53 54 59  | 570         STY|
000017d0  20 69 72 71 31 76 2b 31  20 20 20 5c 20 72 65 73  | irq1v+1   \ res|
000017e0  74 6f 72 65 20 74 68 65  20 6f 72 69 67 69 6e 61  |tore the origina|
000017f0  6c 20 69 72 71 31 20 76  65 63 74 6f 72 2c 20 68  |l irq1 vector, h|
00001800  69 67 68 20 62 79 74 65  0d 20 20 35 38 30 20 20  |igh byte.  580  |
00001810  20 20 20 20 20 20 20 43  4c 49 20 20 20 20 20 20  |       CLI      |
00001820  20 20 20 20 20 5c 20 63  6c 65 61 72 20 69 6e 74  |     \ clear int|
00001830  65 72 72 75 70 74 20 64  69 73 61 62 6c 65 20 66  |errupt disable f|
00001840  6c 61 67 0d 20 20 35 39  30 20 20 20 20 20 20 20  |lag.  590       |
00001850  20 20 52 54 53 20 20 20  20 20 20 20 20 20 20 20  |  RTS           |
00001860  5c 20 72 65 74 75 72 6e  20 74 6f 20 42 41 53 49  |\ return to BASI|
00001870  43 0d 20 20 36 30 30 20  2e 69 6e 74 65 72 72 75  |C.  600 .interru|
00001880  70 74 0d 20 20 36 31 30  20 20 20 20 20 20 20 20  |pt.  610        |
00001890  20 4c 44 41 20 73 61 76  65 72 65 67 20 20 20 5c  | LDA savereg   \|
000018a0  20 69 6e 74 65 72 72 75  70 74 20 61 63 63 75 6d  | interrupt accum|
000018b0  75 6c 61 74 6f 72 20 73  61 76 65 20 72 65 67 69  |ulator save regi|
000018c0  73 74 65 72 0d 20 20 36  32 30 20 20 20 20 20 20  |ster.  620      |
000018d0  20 20 20 50 48 41 20 20  20 20 20 20 20 20 20 20  |   PHA          |
000018e0  20 5c 20 61 6e 64 20 70  75 73 68 20 69 74 20 6f  | \ and push it o|
000018f0  6e 20 74 68 65 20 73 74  61 63 6b 0d 20 20 36 33  |n the stack.  63|
00001900  30 20 20 20 20 20 20 20  20 20 4c 44 41 20 69 66  |0         LDA if|
00001910  72 20 20 20 20 20 20 20  5c 20 69 6e 74 65 72 72  |r       \ interr|
00001920  75 70 74 20 66 6c 61 67  20 72 65 67 69 73 74 65  |upt flag registe|
00001930  72 0d 20 20 36 34 30 20  20 20 20 20 20 20 20 20  |r.  640         |
00001940  42 50 4c 20 6e 6f 74 75  73 65 72 20 20 20 5c 20  |BPL notuser   \ |
00001950  62 69 74 20 37 20 69 73  20 73 65 74 20 69 66 20  |bit 7 is set if |
00001960  56 49 41 2d 42 20 69 6e  74 65 72 72 75 70 74 0d  |VIA-B interrupt.|
00001970  20 20 36 35 30 20 20 20  20 20 20 20 20 20 41 4e  |  650         AN|
00001980  44 20 23 26 31 38 20 20  20 20 20 20 5c 20 41 4e  |D #&18      \ AN|
00001990  44 20 77 69 74 68 20 25  30 30 30 31 31 30 30 30  |D with %00011000|
000019a0  2c 20 69 65 2e 20 74 65  73 74 20 62 69 74 73 20  |, ie. test bits |
000019b0  33 20 61 6e 64 20 34 0d  20 20 36 36 30 20 20 20  |3 and 4.  660   |
000019c0  20 20 20 20 20 20 42 45  51 20 6e 6f 74 75 73 65  |      BEQ notuse|
000019d0  72 20 20 20 5c 20 65 78  69 74 20 69 66 20 6e 6f  |r   \ exit if no|
000019e0  74 20 43 42 31 20 6f 72  20 43 42 32 0d 20 20 36  |t CB1 or CB2.  6|
000019f0  37 30 20 20 20 20 20 20  20 20 20 41 4e 44 20 23  |70         AND #|
00001a00  26 31 30 20 20 20 20 20  20 5c 20 41 4e 44 20 77  |&10      \ AND w|
00001a10  69 74 68 20 25 30 30 30  31 30 30 30 30 2c 20 69  |ith %00010000, i|
00001a20  65 2e 20 74 65 73 74 20  62 69 74 20 34 0d 20 20  |e. test bit 4.  |
00001a30  36 38 30 20 20 20 20 20  20 20 20 20 42 4e 45 20  |680         BNE |
00001a40  78 70 75 6c 73 65 20 20  20 20 5c 20 62 69 74 20  |xpulse    \ bit |
00001a50  34 20 73 65 74 20 66 6f  72 20 61 6e 20 58 20 64  |4 set for an X d|
00001a60  69 72 65 63 74 69 6f 6e  20 6d 6f 76 65 6d 65 6e  |irection movemen|
00001a70  74 0d 20 20 36 39 30 20  20 20 20 20 20 20 20 20  |t.  690         |
00001a80  4c 44 41 20 64 72 62 20  20 20 20 20 20 20 5c 20  |LDA drb       \ |
00001a90  59 20 64 69 72 65 63 74  69 6f 6e 2c 20 6c 6f 61  |Y direction, loa|
00001aa0  64 20 64 61 74 61 20 72  65 67 69 73 74 65 72 20  |d data register |
00001ab0  42 0d 20 20 37 30 30 20  20 20 20 20 20 20 20 20  |B.  700         |
00001ac0  41 4e 44 20 23 26 30 34  20 20 20 20 20 20 5c 20  |AND #&04      \ |
00001ad0  41 4e 44 20 77 69 74 68  20 25 30 30 30 30 30 31  |AND with %000001|
00001ae0  30 30 2c 20 69 65 2e 20  74 65 73 74 20 62 69 74  |00, ie. test bit|
00001af0  20 32 0d 20 20 37 31 30  20 20 20 20 20 20 20 20  | 2.  710        |
00001b00  20 42 4e 45 20 79 64 6f  77 6e 20 20 20 20 20 5c  | BNE ydown     \|
00001b10  20 69 66 20 62 69 74 20  32 20 69 73 20 73 65 74  | if bit 2 is set|
00001b20  20 74 68 65 6e 20 59 20  69 73 20 67 6f 69 6e 67  | then Y is going|
00001b30  20 64 6f 77 6e 0d 20 20  37 32 30 20 20 20 20 20  | down.  720     |
00001b40  20 20 20 20 49 4e 43 20  79 63 6f 6f 72 64 20 20  |    INC ycoord  |
00001b50  20 20 5c 20 59 20 69 73  20 67 6f 69 6e 67 20 75  |  \ Y is going u|
00001b60  70 20 73 6f 20 69 6e 63  72 65 6d 65 6e 74 20 59  |p so increment Y|
00001b70  20 63 6f 6f 72 64 69 6e  61 74 65 0d 20 20 37 33  | coordinate.  73|
00001b80  30 20 20 20 20 20 20 20  20 20 42 4e 45 20 65 78  |0         BNE ex|
00001b90  69 74 20 20 20 20 20 20  5c 20 62 72 61 6e 63 68  |it      \ branch|
00001ba0  20 69 66 20 69 6e 20 74  68 65 20 72 61 6e 67 65  | if in the range|
00001bb0  20 31 20 74 6f 20 32 35  35 0d 20 20 37 34 30 20  | 1 to 255.  740 |
00001bc0  20 20 20 20 20 20 20 20  42 45 51 20 64 65 63 79  |        BEQ decy|
00001bd0  20 20 20 20 20 20 5c 20  69 66 20 7a 65 72 6f 20  |      \ if zero |
00001be0  74 68 65 6e 20 61 6c 74  65 72 20 74 6f 20 32 35  |then alter to 25|
00001bf0  35 0d 20 20 37 35 30 20  2e 79 64 6f 77 6e 0d 20  |5.  750 .ydown. |
00001c00  20 37 36 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 760         LDA|
00001c10  20 79 63 6f 6f 72 64 20  20 20 20 5c 20 6c 6f 61  | ycoord    \ loa|
00001c20  64 20 59 20 63 6f 6f 72  64 69 6e 61 74 65 0d 20  |d Y coordinate. |
00001c30  20 37 37 30 20 20 20 20  20 20 20 20 20 42 45 51  | 770         BEQ|
00001c40  20 65 78 69 74 20 20 20  20 20 20 5c 20 62 72 61  | exit      \ bra|
00001c50  6e 63 68 20 69 66 20 7a  65 72 6f 20 62 65 63 61  |nch if zero beca|
00001c60  75 73 65 20 69 74 20 63  61 6e 27 74 20 67 6f 20  |use it can't go |
00001c70  61 6e 79 20 6c 6f 77 65  72 0d 20 20 37 38 30 20  |any lower.  780 |
00001c80  2e 64 65 63 79 0d 20 20  37 39 30 20 20 20 20 20  |.decy.  790     |
00001c90  20 20 20 20 44 45 43 20  79 63 6f 6f 72 64 20 20  |    DEC ycoord  |
00001ca0  20 20 5c 20 72 65 64 75  63 65 20 59 20 63 6f 6f  |  \ reduce Y coo|
00001cb0  72 64 69 6e 61 74 65 20  62 79 20 31 0d 20 20 38  |rdinate by 1.  8|
00001cc0  30 30 20 20 20 20 20 20  20 20 20 4a 4d 50 20 65  |00         JMP e|
00001cd0  78 69 74 20 20 20 20 20  20 5c 20 72 65 73 74 6f  |xit      \ resto|
00001ce0  72 65 20 69 6e 74 65 72  72 75 70 74 20 61 63 63  |re interrupt acc|
00001cf0  75 6d 75 6c 61 74 6f 72  20 73 61 76 65 20 72 65  |umulator save re|
00001d00  67 69 73 74 65 72 0d 20  20 20 20 20 20 20 20 20  |gister.         |
00001d10  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001d20  20 20 20 5c 20 61 6e 64  20 52 54 49 0d 20 20 38  |   \ and RTI.  8|
00001d30  31 30 20 2e 78 70 75 6c  73 65 0d 20 20 38 32 30  |10 .xpulse.  820|
00001d40  20 20 20 20 20 20 20 20  20 4c 44 41 20 64 72 62  |         LDA drb|
00001d50  20 20 20 20 20 20 20 5c  20 6c 6f 61 64 20 64 61  |       \ load da|
00001d60  74 61 20 72 65 67 69 73  74 65 72 20 42 0d 20 20  |ta register B.  |
00001d70  38 33 30 20 20 20 20 20  20 20 20 20 52 4f 52 20  |830         ROR |
00001d80  41 20 20 20 20 20 20 20  20 20 5c 20 62 69 74 20  |A         \ bit |
00001d90  30 20 69 6e 74 6f 20 63  61 72 72 79 0d 20 20 38  |0 into carry.  8|
00001da0  34 30 20 20 20 20 20 20  20 20 20 42 43 53 20 78  |40         BCS x|
00001db0  64 6f 77 6e 20 20 20 20  20 5c 20 58 20 69 73 20  |down     \ X is |
00001dc0  67 6f 69 6e 67 20 64 6f  77 6e 20 69 66 20 62 69  |going down if bi|
00001dd0  74 20 30 20 69 73 20 73  65 74 0d 20 20 38 35 30  |t 0 is set.  850|
00001de0  20 20 20 20 20 20 20 20  20 49 4e 43 20 78 63 6f  |         INC xco|
00001df0  6f 72 64 20 20 20 20 5c  20 58 20 69 73 20 67 6f  |ord    \ X is go|
00001e00  69 6e 67 20 75 70 20 69  66 20 62 69 74 20 30 20  |ing up if bit 0 |
00001e10  69 73 20 63 6c 65 61 72  0d 20 20 38 36 30 20 20  |is clear.  860  |
00001e20  20 20 20 20 20 20 20 42  4e 45 20 65 78 69 74 20  |       BNE exit |
00001e30  20 20 20 20 20 5c 20 65  78 69 74 20 69 66 20 58  |     \ exit if X|
00001e40  20 63 6f 6f 72 64 69 6e  61 74 65 20 69 73 20 69  | coordinate is i|
00001e50  6e 20 74 68 65 20 72 61  6e 67 65 0d 20 20 20 20  |n the range.    |
00001e60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001e70  20 20 20 20 20 20 20 20  5c 20 66 72 6f 6d 20 31  |        \ from 1|
00001e80  20 74 6f 20 32 35 35 0d  20 20 38 37 30 20 20 20  | to 255.  870   |
00001e90  20 20 20 20 20 20 42 45  51 20 64 65 63 78 20 20  |      BEQ decx  |
00001ea0  20 20 20 20 5c 20 69 66  20 58 20 63 6f 6f 72 64  |    \ if X coord|
00001eb0  69 6e 61 74 65 20 3d 20  30 20 74 68 65 6e 20 6d  |inate = 0 then m|
00001ec0  61 6b 65 20 69 74 20 32  35 35 0d 20 20 38 38 30  |ake it 255.  880|
00001ed0  20 2e 78 64 6f 77 6e 0d  20 20 38 39 30 20 20 20  | .xdown.  890   |
00001ee0  20 20 20 20 20 20 4c 44  41 20 78 63 6f 6f 72 64  |      LDA xcoord|
00001ef0  20 20 20 20 5c 20 6c 6f  61 64 20 58 20 63 6f 6f  |    \ load X coo|
00001f00  72 64 69 6e 61 74 65 0d  20 20 39 30 30 20 20 20  |rdinate.  900   |
00001f10  20 20 20 20 20 20 42 45  51 20 65 78 69 74 20 20  |      BEQ exit  |
00001f20  20 20 20 20 5c 20 69 66  20 69 74 20 69 73 20 7a  |    \ if it is z|
00001f30  65 72 6f 20 69 74 20 63  61 6e 27 74 20 67 6f 20  |ero it can't go |
00001f40  61 6e 79 20 6c 6f 77 65  72 0d 20 20 39 31 30 20  |any lower.  910 |
00001f50  2e 64 65 63 78 0d 20 20  39 32 30 20 20 20 20 20  |.decx.  920     |
00001f60  20 20 20 20 44 45 43 20  78 63 6f 6f 72 64 20 20  |    DEC xcoord  |
00001f70  20 20 5c 20 64 65 63 72  65 61 73 65 20 58 20 63  |  \ decrease X c|
00001f80  6f 6f 72 64 69 6e 61 74  65 20 62 79 20 31 0d 20  |oordinate by 1. |
00001f90  20 39 33 30 20 2e 65 78  69 74 0d 20 20 39 34 30  | 930 .exit.  940|
00001fa0  20 20 20 20 20 20 20 20  20 50 4c 41 20 20 20 20  |         PLA    |
00001fb0  20 20 20 20 20 20 20 5c  20 70 75 6c 6c 20 69 6e  |       \ pull in|
00001fc0  74 65 72 72 75 70 74 20  61 63 63 75 6d 75 6c 61  |terrupt accumula|
00001fd0  74 6f 72 20 73 61 76 65  20 72 65 67 69 73 74 65  |tor save registe|
00001fe0  72 20 6f 66 66 0d 20 20  20 20 20 20 20 20 20 20  |r off.          |
00001ff0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002000  20 20 5c 20 74 68 65 20  73 74 61 63 6b 0d 20 20  |  \ the stack.  |
00002010  39 35 30 20 20 20 20 20  20 20 20 20 53 54 41 20  |950         STA |
00002020  73 61 76 65 72 65 67 20  20 20 5c 20 61 6e 64 20  |savereg   \ and |
00002030  72 65 73 74 6f 72 65 20  7a 65 72 6f 20 70 61 67  |restore zero pag|
00002040  65 0d 20 20 39 36 30 20  20 20 20 20 20 20 20 20  |e.  960         |
00002050  52 54 49 20 20 20 20 20  20 20 20 20 20 20 5c 20  |RTI           \ |
00002060  72 65 74 75 72 6e 20 66  72 6f 6d 20 69 6e 74 65  |return from inte|
00002070  72 72 75 70 74 0d 20 20  39 37 30 20 2e 6e 6f 74  |rrupt.  970 .not|
00002080  75 73 65 72 0d 20 20 39  38 30 20 20 20 20 20 20  |user.  980      |
00002090  20 20 20 50 4c 41 20 20  20 20 20 20 20 20 20 20  |   PLA          |
000020a0  20 5c 20 70 75 6c 6c 20  74 68 65 20 69 6e 74 65  | \ pull the inte|
000020b0  72 72 75 70 74 20 61 63  63 75 6d 75 6c 61 74 6f  |rrupt accumulato|
000020c0  72 20 73 61 76 65 20 72  65 67 69 73 74 65 72 0d  |r save register.|
000020d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000020e0  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 6f 66  |            \ of|
000020f0  66 20 74 68 65 20 73 74  61 63 6b 0d 20 20 39 39  |f the stack.  99|
00002100  30 20 20 20 20 20 20 20  20 20 53 54 41 20 73 61  |0         STA sa|
00002110  76 65 72 65 67 20 20 20  5c 20 72 65 73 74 6f 72  |vereg   \ restor|
00002120  65 20 74 68 65 20 7a 65  72 6f 20 70 61 67 65 20  |e the zero page |
00002130  61 64 64 72 65 73 73 0d  20 31 30 30 30 20 20 20  |address. 1000   |
00002140  20 20 20 20 20 20 4a 4d  50 20 28 6f 6c 64 69 72  |      JMP (oldir|
00002150  71 31 76 29 20 5c 20 65  78 69 74 20 76 69 61 20  |q1v) \ exit via |
00002160  74 68 65 20 6f 72 69 67  69 6e 61 6c 20 76 65 63  |the original vec|
00002170  74 6f 72 0d 20 31 30 31  30 20 2e 6f 6c 64 69 72  |tor. 1010 .oldir|
00002180  71 31 76 0d 20 31 30 32  30 20 20 20 20 20 20 20  |q1v. 1020       |
00002190  20 20 45 51 55 57 20 26  30 30 20 20 20 20 20 20  |  EQUW &00      |
000021a0  5c 20 6f 72 69 67 69 6e  61 6c 20 69 72 71 31 20  |\ original irq1 |
000021b0  76 65 63 74 6f 72 0d 20  31 30 33 30 20 2e 6c 61  |vector. 1030 .la|
000021c0  73 74 62 79 74 65 0d 20  31 30 34 30 20 5d 0d 20  |stbyte. 1040 ]. |
000021d0  31 30 35 30 20 4e 45 58  54 0d 20 31 30 36 30 20  |1050 NEXT. 1060 |
000021e0  65 6e 64 3d 6d 63 6f 64  65 2b 28 6c 61 73 74 62  |end=mcode+(lastb|
000021f0  79 74 65 2d 69 6f 61 64  64 72 29 0d 20 31 30 37  |yte-ioaddr). 107|
00002200  30 20 61 64 64 72 3d 69  6f 61 64 64 72 0d 20 31  |0 addr=ioaddr. 1|
00002210  30 38 30 20 46 4f 52 20  62 79 74 65 3d 6d 63 6f  |080 FOR byte=mco|
00002220  64 65 20 54 4f 20 65 6e  64 0d 20 31 30 39 30 20  |de TO end. 1090 |
00002230  50 52 4f 43 77 72 69 74  65 28 3f 62 79 74 65 2c  |PROCwrite(?byte,|
00002240  61 64 64 72 29 0d 20 31  31 30 30 20 61 64 64 72  |addr). 1100 addr|
00002250  3d 61 64 64 72 2b 31 0d  20 31 31 31 30 20 4e 45  |=addr+1. 1110 NE|
00002260  58 54 0d 20 31 31 32 30  20 50 52 4f 43 77 72 69  |XT. 1120 PROCwri|
00002270  74 65 28 28 69 6f 61 64  64 72 20 4d 4f 44 20 32  |te((ioaddr MOD 2|
00002280  35 36 29 2c 75 73 65 72  76 29 0d 20 31 31 33 30  |56),userv). 1130|
00002290  20 50 52 4f 43 77 72 69  74 65 28 28 69 6f 61 64  | PROCwrite((ioad|
000022a0  64 72 20 44 49 56 20 32  35 36 29 2c 75 73 65 72  |dr DIV 256),user|
000022b0  76 2b 31 29 0d 20 31 31  34 30 20 2a 43 4f 44 45  |v+1). 1140 *CODE|
000022c0  0d 20 31 31 35 30 20 4d  4f 44 45 37 0d 20 31 31  |. 1150 MODE7. 11|
000022d0  36 30 20 6d 6f 75 73 65  24 3d 43 48 52 24 31 34  |60 mouse$=CHR$14|
000022e0  31 2b 43 48 52 24 31 33  32 2b 43 48 52 24 31 35  |1+CHR$132+CHR$15|
000022f0  37 2b 43 48 52 24 31 33  31 2b 0d 20 20 20 20 20  |7+CHR$131+.     |
00002300  20 22 4d 6f 75 73 65 20  63 6f 6f 72 64 69 6e 61  | "Mouse coordina|
00002310  74 65 73 2c 20 72 61 6e  67 65 20 26 30 30 2d 26  |tes, range &00-&|
00002320  46 46 20 20 22 2b 43 48  52 24 31 35 36 0d 20 31  |FF  "+CHR$156. 1|
00002330  31 37 30 20 50 52 49 4e  54 54 41 42 28 30 2c 31  |170 PRINTTAB(0,1|
00002340  29 6d 6f 75 73 65 24 0d  20 31 31 38 30 20 50 52  |)mouse$. 1180 PR|
00002350  49 4e 54 54 41 42 28 30  2c 32 29 6d 6f 75 73 65  |INTTAB(0,2)mouse|
00002360  24 0d 20 31 31 39 30 20  4f 4e 45 52 52 4f 52 20  |$. 1190 ONERROR |
00002370  47 4f 54 4f 20 31 32 39  30 0d 20 31 32 30 30 20  |GOTO 1290. 1200 |
00002380  56 44 55 32 33 2c 31 2c  30 3b 30 3b 30 3b 30 3b  |VDU23,1,0;0;0;0;|
00002390  0d 20 31 32 31 30 20 50  52 49 4e 54 54 41 42 28  |. 1210 PRINTTAB(|
000023a0  31 30 2c 37 29 22 42 79  74 65 73 20 75 73 65 64  |10,7)"Bytes used|
000023b0  20 3d 20 26 22 3b 7e 28  6c 61 73 74 62 79 74 65  | = &";~(lastbyte|
000023c0  2d 69 6f 61 64 64 72 29  0d 20 31 32 32 30 20 52  |-ioaddr). 1220 R|
000023d0  45 50 45 41 54 0d 20 31  32 33 30 20 50 52 49 4e  |EPEAT. 1230 PRIN|
000023e0  54 54 41 42 28 31 30 2c  31 32 29 22 58 20 3d 20  |TTAB(10,12)"X = |
000023f0  26 22 3b 7e 46 4e 72 65  61 64 28 26 38 30 29 3b  |&";~FNread(&80);|
00002400  22 20 22 0d 20 31 32 34  30 20 50 52 49 4e 54 54  |" ". 1240 PRINTT|
00002410  41 42 28 32 30 2c 31 32  29 22 59 20 3d 20 26 22  |AB(20,12)"Y = &"|
00002420  3b 7e 46 4e 72 65 61 64  28 26 38 31 29 3b 22 20  |;~FNread(&81);" |
00002430  22 0d 20 31 32 35 30 20  49 46 20 46 4e 72 69 67  |". 1250 IF FNrig|
00002440  68 74 20 50 52 49 4e 54  54 41 42 28 32 32 2c 31  |ht PRINTTAB(22,1|
00002450  37 29 22 52 69 67 68 74  22 20 45 4c 53 45 20 50  |7)"Right" ELSE P|
00002460  52 49 4e 54 54 41 42 28  32 32 2c 31 37 29 22 20  |RINTTAB(22,17)" |
00002470  20 20 20 20 22 0d 20 31  32 36 30 20 49 46 20 46  |    ". 1260 IF F|
00002480  4e 63 65 6e 74 72 65 20  50 52 49 4e 54 54 41 42  |Ncentre PRINTTAB|
00002490  28 31 35 2c 31 37 29 22  43 65 6e 74 72 65 22 20  |(15,17)"Centre" |
000024a0  45 4c 53 45 20 50 52 49  4e 54 54 41 42 28 31 35  |ELSE PRINTTAB(15|
000024b0  2c 31 37 29 22 20 20 20  20 20 20 22 0d 20 31 32  |,17)"      ". 12|
000024c0  37 30 20 49 46 20 46 4e  6c 65 66 74 20 50 52 49  |70 IF FNleft PRI|
000024d0  4e 54 54 41 42 28 31 30  2c 31 37 29 22 4c 65 66  |NTTAB(10,17)"Lef|
000024e0  74 22 20 45 4c 53 45 20  50 52 49 4e 54 54 41 42  |t" ELSE PRINTTAB|
000024f0  28 31 30 2c 31 37 29 22  20 20 20 20 22 0d 20 31  |(10,17)"    ". 1|
00002500  32 38 30 20 55 4e 54 49  4c 20 46 41 4c 53 45 0d  |280 UNTIL FALSE.|
00002510  20 31 32 39 30 20 2a 43  4f 44 45 0d 20 31 33 30  | 1290 *CODE. 130|
00002520  30 20 56 44 55 32 33 2c  31 2c 31 3b 30 3b 30 3b  |0 VDU23,1,1;0;0;|
00002530  30 3b 33 31 2c 30 2c 32  33 0d 20 31 33 31 30 20  |0;31,0,23. 1310 |
00002540  45 4e 44 0d 20 31 33 32  30 20 44 45 46 50 52 4f  |END. 1320 DEFPRO|
00002550  43 77 72 69 74 65 28 64  61 74 61 2c 61 64 64 72  |Cwrite(data,addr|
00002560  29 0d 20 31 33 33 30 20  21 70 61 72 61 6d 3d 61  |). 1330 !param=a|
00002570  64 64 72 20 4f 52 20 26  46 46 46 46 30 30 30 30  |ddr OR &FFFF0000|
00002580  0d 20 31 33 34 30 20 70  61 72 61 6d 3f 34 3d 64  |. 1340 param?4=d|
00002590  61 74 61 0d 20 31 33 35  30 20 41 25 3d 36 0d 20  |ata. 1350 A%=6. |
000025a0  31 33 36 30 20 58 25 3d  70 61 72 61 6d 20 4d 4f  |1360 X%=param MO|
000025b0  44 20 32 35 36 0d 20 31  33 37 30 20 59 25 3d 70  |D 256. 1370 Y%=p|
000025c0  61 72 61 6d 20 44 49 56  20 32 35 36 0d 20 31 33  |aram DIV 256. 13|
000025d0  38 30 20 43 41 4c 4c 20  6f 73 77 6f 72 64 0d 20  |80 CALL osword. |
000025e0  31 33 39 30 20 45 4e 44  50 52 4f 43 0d 20 31 34  |1390 ENDPROC. 14|
000025f0  30 30 20 44 45 46 46 4e  72 65 61 64 28 61 64 64  |00 DEFFNread(add|
00002600  72 29 0d 20 31 34 31 30  20 21 70 61 72 61 6d 3d  |r). 1410 !param=|
00002610  61 64 64 72 20 4f 52 20  26 46 46 46 46 30 30 30  |addr OR &FFFF000|
00002620  30 0d 20 31 34 32 30 20  41 25 3d 35 0d 20 31 34  |0. 1420 A%=5. 14|
00002630  33 30 20 58 25 3d 70 61  72 61 6d 20 4d 4f 44 20  |30 X%=param MOD |
00002640  32 35 36 0d 20 31 34 34  30 20 59 25 3d 70 61 72  |256. 1440 Y%=par|
00002650  61 6d 20 44 49 56 20 32  35 36 0d 20 31 34 35 30  |am DIV 256. 1450|
00002660  20 43 41 4c 4c 20 6f 73  77 6f 72 64 0d 20 31 34  | CALL osword. 14|
00002670  36 30 20 3d 70 61 72 61  6d 3f 34 0d 20 31 34 37  |60 =param?4. 147|
00002680  30 20 44 45 46 46 4e 62  75 74 74 6f 6e 0d 20 31  |0 DEFFNbutton. 1|
00002690  34 38 30 20 41 25 3d 26  39 36 0d 20 31 34 39 30  |480 A%=&96. 1490|
000026a0  20 58 25 3d 26 36 30 0d  20 31 35 30 30 20 3d 28  | X%=&60. 1500 =(|
000026b0  55 53 52 28 6f 73 62 79  74 65 29 20 41 4e 44 20  |USR(osbyte) AND |
000026c0  26 46 46 30 30 30 30 29  44 49 56 26 31 30 30 30  |&FF0000)DIV&1000|
000026d0  30 0d 20 31 35 31 30 20  44 45 46 46 4e 72 69 67  |0. 1510 DEFFNrig|
000026e0  68 74 0d 20 31 35 32 30  20 3d 28 28 46 4e 62 75  |ht. 1520 =((FNbu|
000026f0  74 74 6f 6e 20 41 4e 44  20 26 38 30 29 3d 30 29  |tton AND &80)=0)|
00002700  0d 20 31 35 33 30 20 44  45 46 46 4e 63 65 6e 74  |. 1530 DEFFNcent|
00002710  72 65 0d 20 31 35 34 30  20 3d 28 28 46 4e 62 75  |re. 1540 =((FNbu|
00002720  74 74 6f 6e 20 41 4e 44  20 26 34 30 29 3d 30 29  |tton AND &40)=0)|
00002730  0d 20 31 35 35 30 20 44  45 46 46 4e 6c 65 66 74  |. 1550 DEFFNleft|
00002740  0d 20 31 35 36 30 20 3d  28 28 46 4e 62 75 74 74  |. 1560 =((FNbutt|
00002750  6f 6e 20 41 4e 44 20 26  32 30 29 3d 30 29 0d     |on AND &20)=0).|
0000275f
02-12-88/T\MOU02.m0
02-12-88/T\MOU02.m1
02-12-88/T\MOU02.m2
02-12-88/T\MOU02.m4
02-12-88/T\MOU02.m5