Home » CEEFAX disks » telesoftware11.adl » 07-01-88/SWMOUSE

07-01-88/SWMOUSE

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: 07-01-88/SWMOUSE
Read OK:
File size: 1AD1 bytes
Load address: FFFF1900
Exec address: FFFF8023
File contents
   10REM> SWMOUSE
   20DIM mcode &200
   30address=&A8 :REM: zero page workspace
   40romnumber=&F4 :REM: currently selected ROM
   50savereg=&FC :REM: interrupt accumulator save register
   60bytev=&20A :REM: Osbyte indirection vector
   70drb=&FE60 :REM: data register B
   80ddrb=&FE62 :REM: data direction register B
   90pcr=&FE6C :REM: peripheral control register
  100ifr=&FE6D :REM: interrupt flag register
  110ier=&FE6E :REM: interrupt enable register
  120osbyte=&FFF4
  130FOR pass=4 TO 6 STEP 2
  140O%=mcode
  150P%=&8000
  160[OPT pass
  170BRK
  180BRK
  190BRK
  200JMP service \ service entry to ROM
  210EQUB &82 \ ROM type byte indicates a service entry
  220EQUB copyright MOD 256 \ copyright offset pointer
  230BRK \ binary version number
  240EQUS "Analogue mouse" \ title string
  250.copyright
  260BRK
  270EQUS "(C) Gordon Horsington 1987" \ copyright string
  280BRK \ copyright terminator
  290.service
  300CMP #&05 \ is this an unrecognised interrupt?
  310BEQ interrupt \ if it is branch to interrupt routine
  320CMP #&FE \ is this a Tube post init?
  330BNE return \ if not then return to operating system.
  340PHA \ push registers. This is a Tube post init
  350TXA \ and the registers must be unaltered when this
  360PHA \ service type is used for illegal purposes
  370TYA \ such as initialising the user port when
  380PHA \ the Break key is pressed.
  390LDA #&98 \ %10011000, ie. enable CB1/2
  400STA ier \ interrupt enable register
  410LDA pcr \ peripheral control register
  420AND #&0F \ AND with %00001111, ie clear bits 4-7
  430ORA #&50 \ OR with %01010000, ie. set bits 4 and 6
  440STA pcr \ interrupt on +ve transition, CB2 input, DRB to clear
  450LDA #&00 \ user port input
  460STA ddrb \ data direction register B
  470LDA #&10 \ ADC channel select
  480LDX #&00 \ sampling disabled
  490JSR osbyte
  500LDX bytev \ Osbyte indirection vector, low byte
  510LDY bytev+1 \ Osbyte indirection vector, high byte
  520STX oldbytev \ store the original vector, low byte
  530STY oldbytev+1 \ store the original vector, high byte
  540LDA #&A8 \ read address of ROM pointer table
  550LDX #&00 \ to read X = &00
  560LDY #&FF \ to read Y = &FF
  570JSR osbyte
  580STX address \ store in zero page for indirect addressing
  590STY address+1
  600LDY #&0F \ offset to extented Osbyte vector, low byte
  610LDA #analogue MOD 256 \ address of new Osbyte routine, low byte
  620STA (address),Y \ store in extended vector
  630INY \ offset to extended Osbyte vector, high byte
  640LDA #analogue DIV 256 \ address of new Osbyte routine, high byte
  650STA (address),Y \ store in extended vector
  660INY \ offset to Osbyte extended vector, ROM number
  670LDA romnumber \ load the number of this ROM
  680STA (address),Y \ store in extended vector
  690LDX #&0F \ offset to Osbyte entry to extended vectors, low byte
  700LDY #&FF \ extended vector entry, high byte
  710STX bytev \ alter Osbyte vector, low byte
  720STY bytev+1 \ alter Osbyte vector, high byte
  730PLA \ restore the registers.
  740TAY \ this is an illegal use for service type &FE
  750PLA \ the A, X and Y registers must be restored
  760TAX \ before return to the operating system.
  770PLA
  780.return
  790RTS
  800.interrupt
  810LDA savereg \ interrupt accumulator save register
  820PHA \ and push it on the stack
  830LDA ifr \ interrupt flag register
  840BPL notuser \ bit 7 is set if VIA-B interrupt
  850AND #&18 \ AND with %00011000, ie. test bits 3 and 4
  860BEQ notuser \ exit if not CB1 or CB2
  870AND #&10 \ AND with %00010000, ie. test CB1
  880BNE xpulse \ bit 4 set for an X direction movement
  890LDA drb \ Y direction, load data register B
  900AND #&04 \ AND with %00000100, ie. test bit 2
  910BNE ydown \ if bit 2 is set then Y is going down
  920INC ycoord \ Y is going up so increment Y coordinate
  930BNE exit \ branch if in the range 1 to 255
  940BEQ decy \ if zero then alter to 255
  950.ydown
  960LDA ycoord \ load Y coordinate
  970BEQ exit \ branch if zero because it can't go any lower
  980.decy
  990DEC ycoord \ reduce Y coordinate by 1
 1000JMP exit \ restore interrupt accumulator save register and RTI
 1010.xpulse
 1020LDA drb \ load data register B
 1030ROR A \ bit 0 into carry
 1040BCC xdown \ fudge to reverse joystick
 1050INC xcoord \ fudge to increase X when its going down
 1060BNE exit \ exit if X coordinate is in the range from 1 to 255
 1070BEQ decx \ if X coordinate = 0 then make it 255
 1080.xdown
 1090LDA xcoord \ load X coordinate
 1100BEQ exit \ if it is zero it can't go any lower
 1110.decx
 1120DEC xcoord \ decrease X coordinate by 1
 1130.exit
 1140PLA \ pull interrupt accumulator save register off the stack
 1150STA savereg \ and restore zero page
 1160LDA #&00
 1170RTS
 1180.notuser
 1190PLA \ pull the interrupt accumulator save register off the stack
 1200STA savereg \ restore the zero page address
 1210LDA #&05 \ service type 5
 1220RTS \ return to operating system
 1230.oldadval
 1240PLP \ pull status register
 1250.original
 1260JMP (oldbytev) \ exit via original Osbyte vector
 1270.analogue
 1280PHP \ push the status register
 1290CMP #&80 \ is this Osbyte &80, read ADC channel
 1300BNE oldadval \ if not exit via original Osbyte vector
 1310CPX #&00 \ is this ADVAL(0) ie. read fire buttons?
 1320BEQ firebuttons \ if it is branch to new fire buttons routine
 1330TXA \ channel number is in X register
 1340ROR A \ bit 0 of channel number into carry
 1350LDA ycoord \ Y coordinate from mouse movement
 1360BCC skipxcoord \ carry clear if channel 2 or 4
 1370LDA xcoord \ X coordinate from mouse movement
 1380.skipxcoord
 1390TAY \ simulated ADVAL(1-4), high byte
 1400AND #&F0 \ AND with %11110000, ie. clear bits 0-3
 1410TAX \ simulated ADVAL(1-4), low byte
 1420LDA #&80 \ Osbyte &80
 1430PLP \ restore status register
 1440RTS \ return to BASIC
 1450.firebuttons
 1460JSR original \ perform the original ADVAL(0)
 1470TXA \ result in bits 0 and 1 of the X register
 1480PHA \ push the result onto stack
 1490LDA drb \ data register B
 1500ROL A \ bit 7 into carry
 1510BCC right \ bit 7 clear if right button pressed
 1520ROL A \ bit 6 into carry
 1530BCC centre \ bit 6 clear if centre button pressed
 1540ROL A \ bit 5 into carry
 1550BCS nopress \ if bit 5 set then no mouse buttons pressed
 1560PLA \ left button pressed, pull result of original ADVAL(0)
 1570ORA #&01 \ set bit 0 to simulate fire button pressed
 1580BNE getout \ unconditional branch to exit
 1590.right
 1600PLA \ pull result of original ADVAL(0)
 1610ORA #&02 \ set bit 1 to simulate fire button pressed
 1620BNE getout \ unconditional branch to exit
 1630.centre
 1640PLA \ pull result of original ADVAL(0)
 1650ORA #&03 \ set bits 0 and 1 to simulate both fire buttons
 1660BNE getout \ unconditional branch
 1670.nopress
 1680PLA \ pull the result byte off the stack
 1690.getout
 1700TAX \ transfer result byte to the X register
 1710LDA #&80 \ Osbyte &80
 1720PLP \ pull the status register
 1730RTS \ return to BASIC
 1740.xcoord
 1750EQUB &80 \ mouse X coordinate 0-255
 1760.ycoord
 1770EQUB &80 \ mouse Y coordinate 0-255
 1780.oldbytev
 1790EQUW &00 \ original Osbyte indirection vector
 1800.lastbyte
 1810]
 1820NEXT
 1830*OPT1,2
 1840OSCLI("SAVE SWRMICE "+STR$~(mcode)+" + "+STR$~(lastbyte-&8000)+" FFFF8000 FFFF8000")
 1850*OPT0,0

�> SWMOUSE
� mcode &200
'address=&A8 :�: zero page workspace
(,romnumber=&F4 :�: currently selected ROM
27savereg=&FC :�: interrupt accumulator save register
<,bytev=&20A :�: Osbyte indirection vector
F!drb=&FE60 :�: data register B
P,ddrb=&FE62 :�: data direction register B
Z-pcr=&FE6C :�: peripheral control register
d)ifr=&FE6D :�: interrupt flag register
n+ier=&FE6E :�: interrupt enable register
xosbyte=&FFF4
�� pass=4 � 6 � 2
�O%=mcode
�P%=&8000
�
[OPT pass
�BRK
�BRK
�BRK
�&JMP service \ service entry to ROM
�6EQUB &82 \ ROM type byte indicates a service entry
�3EQUB copyright � 256 \ copyright offset pointer
�BRK \ binary version number
�(EQUS "Analogue mouse" \ title string
�.copyright
BRK
8EQUS "(C) Gordon Horsington 1987" \ copyright string
BRK \ copyright terminator
".service
,1CMP #&05 \ is this an unrecognised interrupt?
68BEQ interrupt \ if it is branch to interrupt routine
@(CMP #&FE \ is this a Tube post init?
J8BNE return \ if not then return to operating system.
T2PHA \ push registers. This is a Tube post init
^7TXA \ and the registers must be unaltered when this
h3PHA \ service type is used for illegal purposes
r1TYA \ such as initialising the user port when
|#PHA \ the Break key is pressed.
�*LDA #&98 \ %10011000, ie. enable CB1/2
�'STA ier \ interrupt enable register
�)LDA pcr \ peripheral control register
�0� #&0F \ � with %00001111, ie clear bits 4-7
�4�A #&50 \ � with %01010000, ie. set bits 4 and 6
�BSTA pcr \ interrupt on +ve transition, CB2 input, DRB to clear
�LDA #&00 \ user port input
�(STA ddrb \ data direction register B
�!LDA #&10 \ ADC channel select
� LDX #&00 \ sampling disabled
�JSR osbyte
�3LDX bytev \ Osbyte indirection vector, low byte
�6LDY bytev+1 \ Osbyte indirection vector, high byte
6STX oldbytev \ store the original vector, low byte
9STY oldbytev+1 \ store the original vector, high byte
0LDA #&A8 \ read address of ROM pointer table
&LDX #&00 \ to read X = &00
0LDY #&FF \ to read Y = &FF
:JSR osbyte
D<STX address \ store in zero page for indirect addressing
NSTY address+1
X9LDY #&0F \ offset to extented Osbyte vector, low byte
bALDA #analogue � 256 \ address of new Osbyte routine, low byte
l.STA (address),Y \ store in extended vector
v5INY \ offset to extended Osbyte vector, high byte
�BLDA #analogue � 256 \ address of new Osbyte routine, high byte
�.STA (address),Y \ store in extended vector
�6INY \ offset to Osbyte extended vector, ROM number
�/LDA romnumber \ load the number of this ROM
�.STA (address),Y \ store in extended vector
�CLDX #&0F \ offset to Osbyte entry to extended vectors, low byte
�/LDY #&FF \ extended vector entry, high byte
�-STX bytev \ alter Osbyte vector, low byte
�0STY bytev+1 \ alter Osbyte vector, high byte
� PLA \ restore the registers.
�5TAY \ this is an illegal use for service type &FE
�3PLA \ the A, X and Y registers must be restored
�0TAX \ before return to the operating system.
PLA
.return
RTS
 .interrupt
*5LDA savereg \ interrupt accumulator save register
4"PHA \ and push it on the stack
>%LDA ifr \ interrupt flag register
H1BPL notuser \ bit 7 is set if VIA-B interrupt
R4� #&18 \ � with %00011000, ie. test bits 3 and 4
\(BEQ notuser \ exit if not CB1 or CB2
f+� #&10 \ � with %00010000, ie. test CB1
p6BNE xpulse \ bit 4 set for an X direction movement
z/LDA drb \ Y direction, load data register B
�-� #&04 \ � with %00000100, ie. test bit 2
�4BNE ydown \ if bit 2 is set then Y is going down
�8INC ycoord \ Y is going up so increment Y coordinate
�.BNE exit \ branch if in the range 1 to 255
�(BEQ decy \ if zero then alter to 255
�
.ydown
�"LDA ycoord \ load Y coordinate
�;BEQ exit \ branch if zero because it can't go any lower
�	.decy
�)DEC ycoord \ reduce Y coordinate by 1
�BJMP exit \ restore interrupt accumulator save register and RTI
�.xpulse
�"LDA drb \ load data register B
ROR A \ bit 0 into carry
)BCC xdown \ fudge to reverse joystick
8INC xcoord \ fudge to increase X when its going down
$ABNE exit \ exit if X coordinate is in the range from 1 to 255
.3BEQ decx \ if X coordinate = 0 then make it 255
8
.xdown
B"LDA xcoord \ load X coordinate
L2BEQ exit \ if it is zero it can't go any lower
V	.decx
`+DEC xcoord \ decrease X coordinate by 1
j	.exit
t@PLA \ pull interrupt accumulator save register off the stack
~'STA savereg \ and restore zero page
�LDA #&00
�RTS
�.notuser
�DPLA \ pull the interrupt accumulator save register off the stack
�/STA savereg \ restore the zero page address
�LDA #&05 \ service type 5
�$RTS \ return to operating system
�
.oldadval
�PLP \ pull status register
�
.original
�4JMP (oldbytev) \ exit via original Osbyte vector
�
.analogue
"PHP \ push the status register

3CMP #&80 \ is this Osbyte &80, read ADC channel
9BNE oldadval \ if not exit via original Osbyte vector
2CPX #&00 \ is this �(0) ie. read fire buttons?
(ABEQ firebuttons \ if it is branch to new fire buttons routine
2)TXA \ channel number is in X register
<.ROR A \ bit 0 of channel number into carry
F1LDA ycoord \ Y coordinate from mouse movement
P2BCC skipxcoord \ carry clear if channel 2 or 4
Z1LDA xcoord \ X coordinate from mouse movement
d.skipxcoord
n%TAY \ simulated �(1-4), high byte
x1� #&F0 \ � with %11110000, ie. clear bits 0-3
�$TAX \ simulated �(1-4), low byte
�LDA #&80 \ Osbyte &80
�!PLP \ restore status register
�RTS \ return to BASIC
�.firebuttons
�,JSR original \ perform the original �(0)
�2TXA \ result in bits 0 and 1 of the X register
�$PHA \ push the result onto stack
�LDA drb \ data register B
�ROL A \ bit 7 into carry
�3BCC right \ bit 7 clear if right button pressed
�ROL A \ bit 6 into carry
�5BCC centre \ bit 6 clear if centre button pressed
ROL A \ bit 5 into carry
<BCS nopress \ if bit 5 set then no mouse buttons pressed
;PLA \ left button pressed, pull result of original �(0)
"7�A #&01 \ set bit 0 to simulate fire button pressed
,-BNE getout \ unconditional branch to exit
6
.right
@&PLA \ pull result of original �(0)
J7�A #&02 \ set bit 1 to simulate fire button pressed
T-BNE getout \ unconditional branch to exit
^.centre
h&PLA \ pull result of original �(0)
r<�A #&03 \ set bits 0 and 1 to simulate both fire buttons
|%BNE getout \ unconditional branch
�.nopress
�,PLA \ pull the result byte off the stack
�.getout
�0TAX \ transfer result byte to the X register
�LDA #&80 \ Osbyte &80
�"PLP \ pull the status register
�RTS \ return to BASIC
�.xcoord
�'EQUB &80 \ mouse X coordinate 0-255
�.ycoord
�'EQUB &80 \ mouse Y coordinate 0-255
�
.oldbytev
�1EQUW &00 \ original Osbyte indirection vector

.lastbyte
]
�
&*OPT1,2
0N�("SAVE SWRMICE "+�~(mcode)+" + "+�~(lastbyte-&8000)+" FFFF8000 FFFF8000")
:*OPT0,0
�
00000000  0d 00 0a 0e f4 3e 20 53  57 4d 4f 55 53 45 0d 00  |.....> SWMOUSE..|
00000010  14 10 de 20 6d 63 6f 64  65 20 26 32 30 30 0d 00  |... mcode &200..|
00000020  1e 27 61 64 64 72 65 73  73 3d 26 41 38 20 3a f4  |.'address=&A8 :.|
00000030  3a 20 7a 65 72 6f 20 70  61 67 65 20 77 6f 72 6b  |: zero page work|
00000040  73 70 61 63 65 0d 00 28  2c 72 6f 6d 6e 75 6d 62  |space..(,romnumb|
00000050  65 72 3d 26 46 34 20 3a  f4 3a 20 63 75 72 72 65  |er=&F4 :.: curre|
00000060  6e 74 6c 79 20 73 65 6c  65 63 74 65 64 20 52 4f  |ntly selected RO|
00000070  4d 0d 00 32 37 73 61 76  65 72 65 67 3d 26 46 43  |M..27savereg=&FC|
00000080  20 3a f4 3a 20 69 6e 74  65 72 72 75 70 74 20 61  | :.: interrupt a|
00000090  63 63 75 6d 75 6c 61 74  6f 72 20 73 61 76 65 20  |ccumulator save |
000000a0  72 65 67 69 73 74 65 72  0d 00 3c 2c 62 79 74 65  |register..<,byte|
000000b0  76 3d 26 32 30 41 20 3a  f4 3a 20 4f 73 62 79 74  |v=&20A :.: Osbyt|
000000c0  65 20 69 6e 64 69 72 65  63 74 69 6f 6e 20 76 65  |e indirection ve|
000000d0  63 74 6f 72 0d 00 46 21  64 72 62 3d 26 46 45 36  |ctor..F!drb=&FE6|
000000e0  30 20 3a f4 3a 20 64 61  74 61 20 72 65 67 69 73  |0 :.: data regis|
000000f0  74 65 72 20 42 0d 00 50  2c 64 64 72 62 3d 26 46  |ter B..P,ddrb=&F|
00000100  45 36 32 20 3a f4 3a 20  64 61 74 61 20 64 69 72  |E62 :.: data dir|
00000110  65 63 74 69 6f 6e 20 72  65 67 69 73 74 65 72 20  |ection register |
00000120  42 0d 00 5a 2d 70 63 72  3d 26 46 45 36 43 20 3a  |B..Z-pcr=&FE6C :|
00000130  f4 3a 20 70 65 72 69 70  68 65 72 61 6c 20 63 6f  |.: peripheral co|
00000140  6e 74 72 6f 6c 20 72 65  67 69 73 74 65 72 0d 00  |ntrol register..|
00000150  64 29 69 66 72 3d 26 46  45 36 44 20 3a f4 3a 20  |d)ifr=&FE6D :.: |
00000160  69 6e 74 65 72 72 75 70  74 20 66 6c 61 67 20 72  |interrupt flag r|
00000170  65 67 69 73 74 65 72 0d  00 6e 2b 69 65 72 3d 26  |egister..n+ier=&|
00000180  46 45 36 45 20 3a f4 3a  20 69 6e 74 65 72 72 75  |FE6E :.: interru|
00000190  70 74 20 65 6e 61 62 6c  65 20 72 65 67 69 73 74  |pt enable regist|
000001a0  65 72 0d 00 78 10 6f 73  62 79 74 65 3d 26 46 46  |er..x.osbyte=&FF|
000001b0  46 34 0d 00 82 14 e3 20  70 61 73 73 3d 34 20 b8  |F4..... pass=4 .|
000001c0  20 36 20 88 20 32 0d 00  8c 0c 4f 25 3d 6d 63 6f  | 6 . 2....O%=mco|
000001d0  64 65 0d 00 96 0c 50 25  3d 26 38 30 30 30 0d 00  |de....P%=&8000..|
000001e0  a0 0d 5b 4f 50 54 20 70  61 73 73 0d 00 aa 07 42  |..[OPT pass....B|
000001f0  52 4b 0d 00 b4 07 42 52  4b 0d 00 be 07 42 52 4b  |RK....BRK....BRK|
00000200  0d 00 c8 26 4a 4d 50 20  73 65 72 76 69 63 65 20  |...&JMP service |
00000210  5c 20 73 65 72 76 69 63  65 20 65 6e 74 72 79 20  |\ service entry |
00000220  74 6f 20 52 4f 4d 0d 00  d2 36 45 51 55 42 20 26  |to ROM...6EQUB &|
00000230  38 32 20 5c 20 52 4f 4d  20 74 79 70 65 20 62 79  |82 \ ROM type by|
00000240  74 65 20 69 6e 64 69 63  61 74 65 73 20 61 20 73  |te indicates a s|
00000250  65 72 76 69 63 65 20 65  6e 74 72 79 0d 00 dc 33  |ervice entry...3|
00000260  45 51 55 42 20 63 6f 70  79 72 69 67 68 74 20 83  |EQUB copyright .|
00000270  20 32 35 36 20 5c 20 63  6f 70 79 72 69 67 68 74  | 256 \ copyright|
00000280  20 6f 66 66 73 65 74 20  70 6f 69 6e 74 65 72 0d  | offset pointer.|
00000290  00 e6 1f 42 52 4b 20 5c  20 62 69 6e 61 72 79 20  |...BRK \ binary |
000002a0  76 65 72 73 69 6f 6e 20  6e 75 6d 62 65 72 0d 00  |version number..|
000002b0  f0 28 45 51 55 53 20 22  41 6e 61 6c 6f 67 75 65  |.(EQUS "Analogue|
000002c0  20 6d 6f 75 73 65 22 20  5c 20 74 69 74 6c 65 20  | mouse" \ title |
000002d0  73 74 72 69 6e 67 0d 00  fa 0e 2e 63 6f 70 79 72  |string.....copyr|
000002e0  69 67 68 74 0d 01 04 07  42 52 4b 0d 01 0e 38 45  |ight....BRK...8E|
000002f0  51 55 53 20 22 28 43 29  20 47 6f 72 64 6f 6e 20  |QUS "(C) Gordon |
00000300  48 6f 72 73 69 6e 67 74  6f 6e 20 31 39 38 37 22  |Horsington 1987"|
00000310  20 5c 20 63 6f 70 79 72  69 67 68 74 20 73 74 72  | \ copyright str|
00000320  69 6e 67 0d 01 18 1e 42  52 4b 20 5c 20 63 6f 70  |ing....BRK \ cop|
00000330  79 72 69 67 68 74 20 74  65 72 6d 69 6e 61 74 6f  |yright terminato|
00000340  72 0d 01 22 0c 2e 73 65  72 76 69 63 65 0d 01 2c  |r.."..service..,|
00000350  31 43 4d 50 20 23 26 30  35 20 5c 20 69 73 20 74  |1CMP #&05 \ is t|
00000360  68 69 73 20 61 6e 20 75  6e 72 65 63 6f 67 6e 69  |his an unrecogni|
00000370  73 65 64 20 69 6e 74 65  72 72 75 70 74 3f 0d 01  |sed interrupt?..|
00000380  36 38 42 45 51 20 69 6e  74 65 72 72 75 70 74 20  |68BEQ interrupt |
00000390  5c 20 69 66 20 69 74 20  69 73 20 62 72 61 6e 63  |\ if it is branc|
000003a0  68 20 74 6f 20 69 6e 74  65 72 72 75 70 74 20 72  |h to interrupt r|
000003b0  6f 75 74 69 6e 65 0d 01  40 28 43 4d 50 20 23 26  |outine..@(CMP #&|
000003c0  46 45 20 5c 20 69 73 20  74 68 69 73 20 61 20 54  |FE \ is this a T|
000003d0  75 62 65 20 70 6f 73 74  20 69 6e 69 74 3f 0d 01  |ube post init?..|
000003e0  4a 38 42 4e 45 20 72 65  74 75 72 6e 20 5c 20 69  |J8BNE return \ i|
000003f0  66 20 6e 6f 74 20 74 68  65 6e 20 72 65 74 75 72  |f not then retur|
00000400  6e 20 74 6f 20 6f 70 65  72 61 74 69 6e 67 20 73  |n to operating s|
00000410  79 73 74 65 6d 2e 0d 01  54 32 50 48 41 20 5c 20  |ystem...T2PHA \ |
00000420  70 75 73 68 20 72 65 67  69 73 74 65 72 73 2e 20  |push registers. |
00000430  54 68 69 73 20 69 73 20  61 20 54 75 62 65 20 70  |This is a Tube p|
00000440  6f 73 74 20 69 6e 69 74  0d 01 5e 37 54 58 41 20  |ost init..^7TXA |
00000450  5c 20 61 6e 64 20 74 68  65 20 72 65 67 69 73 74  |\ and the regist|
00000460  65 72 73 20 6d 75 73 74  20 62 65 20 75 6e 61 6c  |ers must be unal|
00000470  74 65 72 65 64 20 77 68  65 6e 20 74 68 69 73 0d  |tered when this.|
00000480  01 68 33 50 48 41 20 5c  20 73 65 72 76 69 63 65  |.h3PHA \ service|
00000490  20 74 79 70 65 20 69 73  20 75 73 65 64 20 66 6f  | type is used fo|
000004a0  72 20 69 6c 6c 65 67 61  6c 20 70 75 72 70 6f 73  |r illegal purpos|
000004b0  65 73 0d 01 72 31 54 59  41 20 5c 20 73 75 63 68  |es..r1TYA \ such|
000004c0  20 61 73 20 69 6e 69 74  69 61 6c 69 73 69 6e 67  | as initialising|
000004d0  20 74 68 65 20 75 73 65  72 20 70 6f 72 74 20 77  | the user port w|
000004e0  68 65 6e 0d 01 7c 23 50  48 41 20 5c 20 74 68 65  |hen..|#PHA \ the|
000004f0  20 42 72 65 61 6b 20 6b  65 79 20 69 73 20 70 72  | Break key is pr|
00000500  65 73 73 65 64 2e 0d 01  86 2a 4c 44 41 20 23 26  |essed....*LDA #&|
00000510  39 38 20 5c 20 25 31 30  30 31 31 30 30 30 2c 20  |98 \ %10011000, |
00000520  69 65 2e 20 65 6e 61 62  6c 65 20 43 42 31 2f 32  |ie. enable CB1/2|
00000530  0d 01 90 27 53 54 41 20  69 65 72 20 5c 20 69 6e  |...'STA ier \ in|
00000540  74 65 72 72 75 70 74 20  65 6e 61 62 6c 65 20 72  |terrupt enable r|
00000550  65 67 69 73 74 65 72 0d  01 9a 29 4c 44 41 20 70  |egister...)LDA p|
00000560  63 72 20 5c 20 70 65 72  69 70 68 65 72 61 6c 20  |cr \ peripheral |
00000570  63 6f 6e 74 72 6f 6c 20  72 65 67 69 73 74 65 72  |control register|
00000580  0d 01 a4 30 80 20 23 26  30 46 20 5c 20 80 20 77  |...0. #&0F \ . w|
00000590  69 74 68 20 25 30 30 30  30 31 31 31 31 2c 20 69  |ith %00001111, i|
000005a0  65 20 63 6c 65 61 72 20  62 69 74 73 20 34 2d 37  |e clear bits 4-7|
000005b0  0d 01 ae 34 84 41 20 23  26 35 30 20 5c 20 84 20  |...4.A #&50 \ . |
000005c0  77 69 74 68 20 25 30 31  30 31 30 30 30 30 2c 20  |with %01010000, |
000005d0  69 65 2e 20 73 65 74 20  62 69 74 73 20 34 20 61  |ie. set bits 4 a|
000005e0  6e 64 20 36 0d 01 b8 42  53 54 41 20 70 63 72 20  |nd 6...BSTA pcr |
000005f0  5c 20 69 6e 74 65 72 72  75 70 74 20 6f 6e 20 2b  |\ interrupt on +|
00000600  76 65 20 74 72 61 6e 73  69 74 69 6f 6e 2c 20 43  |ve transition, C|
00000610  42 32 20 69 6e 70 75 74  2c 20 44 52 42 20 74 6f  |B2 input, DRB to|
00000620  20 63 6c 65 61 72 0d 01  c2 1e 4c 44 41 20 23 26  | clear....LDA #&|
00000630  30 30 20 5c 20 75 73 65  72 20 70 6f 72 74 20 69  |00 \ user port i|
00000640  6e 70 75 74 0d 01 cc 28  53 54 41 20 64 64 72 62  |nput...(STA ddrb|
00000650  20 5c 20 64 61 74 61 20  64 69 72 65 63 74 69 6f  | \ data directio|
00000660  6e 20 72 65 67 69 73 74  65 72 20 42 0d 01 d6 21  |n register B...!|
00000670  4c 44 41 20 23 26 31 30  20 5c 20 41 44 43 20 63  |LDA #&10 \ ADC c|
00000680  68 61 6e 6e 65 6c 20 73  65 6c 65 63 74 0d 01 e0  |hannel select...|
00000690  20 4c 44 58 20 23 26 30  30 20 5c 20 73 61 6d 70  | LDX #&00 \ samp|
000006a0  6c 69 6e 67 20 64 69 73  61 62 6c 65 64 0d 01 ea  |ling disabled...|
000006b0  0e 4a 53 52 20 6f 73 62  79 74 65 0d 01 f4 33 4c  |.JSR osbyte...3L|
000006c0  44 58 20 62 79 74 65 76  20 5c 20 4f 73 62 79 74  |DX bytev \ Osbyt|
000006d0  65 20 69 6e 64 69 72 65  63 74 69 6f 6e 20 76 65  |e indirection ve|
000006e0  63 74 6f 72 2c 20 6c 6f  77 20 62 79 74 65 0d 01  |ctor, low byte..|
000006f0  fe 36 4c 44 59 20 62 79  74 65 76 2b 31 20 5c 20  |.6LDY bytev+1 \ |
00000700  4f 73 62 79 74 65 20 69  6e 64 69 72 65 63 74 69  |Osbyte indirecti|
00000710  6f 6e 20 76 65 63 74 6f  72 2c 20 68 69 67 68 20  |on vector, high |
00000720  62 79 74 65 0d 02 08 36  53 54 58 20 6f 6c 64 62  |byte...6STX oldb|
00000730  79 74 65 76 20 5c 20 73  74 6f 72 65 20 74 68 65  |ytev \ store the|
00000740  20 6f 72 69 67 69 6e 61  6c 20 76 65 63 74 6f 72  | original vector|
00000750  2c 20 6c 6f 77 20 62 79  74 65 0d 02 12 39 53 54  |, low byte...9ST|
00000760  59 20 6f 6c 64 62 79 74  65 76 2b 31 20 5c 20 73  |Y oldbytev+1 \ s|
00000770  74 6f 72 65 20 74 68 65  20 6f 72 69 67 69 6e 61  |tore the origina|
00000780  6c 20 76 65 63 74 6f 72  2c 20 68 69 67 68 20 62  |l vector, high b|
00000790  79 74 65 0d 02 1c 30 4c  44 41 20 23 26 41 38 20  |yte...0LDA #&A8 |
000007a0  5c 20 72 65 61 64 20 61  64 64 72 65 73 73 20 6f  |\ read address o|
000007b0  66 20 52 4f 4d 20 70 6f  69 6e 74 65 72 20 74 61  |f ROM pointer ta|
000007c0  62 6c 65 0d 02 26 1e 4c  44 58 20 23 26 30 30 20  |ble..&.LDX #&00 |
000007d0  5c 20 74 6f 20 72 65 61  64 20 58 20 3d 20 26 30  |\ to read X = &0|
000007e0  30 0d 02 30 1e 4c 44 59  20 23 26 46 46 20 5c 20  |0..0.LDY #&FF \ |
000007f0  74 6f 20 72 65 61 64 20  59 20 3d 20 26 46 46 0d  |to read Y = &FF.|
00000800  02 3a 0e 4a 53 52 20 6f  73 62 79 74 65 0d 02 44  |.:.JSR osbyte..D|
00000810  3c 53 54 58 20 61 64 64  72 65 73 73 20 5c 20 73  |<STX address \ s|
00000820  74 6f 72 65 20 69 6e 20  7a 65 72 6f 20 70 61 67  |tore in zero pag|
00000830  65 20 66 6f 72 20 69 6e  64 69 72 65 63 74 20 61  |e for indirect a|
00000840  64 64 72 65 73 73 69 6e  67 0d 02 4e 11 53 54 59  |ddressing..N.STY|
00000850  20 61 64 64 72 65 73 73  2b 31 0d 02 58 39 4c 44  | address+1..X9LD|
00000860  59 20 23 26 30 46 20 5c  20 6f 66 66 73 65 74 20  |Y #&0F \ offset |
00000870  74 6f 20 65 78 74 65 6e  74 65 64 20 4f 73 62 79  |to extented Osby|
00000880  74 65 20 76 65 63 74 6f  72 2c 20 6c 6f 77 20 62  |te vector, low b|
00000890  79 74 65 0d 02 62 41 4c  44 41 20 23 61 6e 61 6c  |yte..bALDA #anal|
000008a0  6f 67 75 65 20 83 20 32  35 36 20 5c 20 61 64 64  |ogue . 256 \ add|
000008b0  72 65 73 73 20 6f 66 20  6e 65 77 20 4f 73 62 79  |ress of new Osby|
000008c0  74 65 20 72 6f 75 74 69  6e 65 2c 20 6c 6f 77 20  |te routine, low |
000008d0  62 79 74 65 0d 02 6c 2e  53 54 41 20 28 61 64 64  |byte..l.STA (add|
000008e0  72 65 73 73 29 2c 59 20  5c 20 73 74 6f 72 65 20  |ress),Y \ store |
000008f0  69 6e 20 65 78 74 65 6e  64 65 64 20 76 65 63 74  |in extended vect|
00000900  6f 72 0d 02 76 35 49 4e  59 20 5c 20 6f 66 66 73  |or..v5INY \ offs|
00000910  65 74 20 74 6f 20 65 78  74 65 6e 64 65 64 20 4f  |et to extended O|
00000920  73 62 79 74 65 20 76 65  63 74 6f 72 2c 20 68 69  |sbyte vector, hi|
00000930  67 68 20 62 79 74 65 0d  02 80 42 4c 44 41 20 23  |gh byte...BLDA #|
00000940  61 6e 61 6c 6f 67 75 65  20 81 20 32 35 36 20 5c  |analogue . 256 \|
00000950  20 61 64 64 72 65 73 73  20 6f 66 20 6e 65 77 20  | address of new |
00000960  4f 73 62 79 74 65 20 72  6f 75 74 69 6e 65 2c 20  |Osbyte routine, |
00000970  68 69 67 68 20 62 79 74  65 0d 02 8a 2e 53 54 41  |high byte....STA|
00000980  20 28 61 64 64 72 65 73  73 29 2c 59 20 5c 20 73  | (address),Y \ s|
00000990  74 6f 72 65 20 69 6e 20  65 78 74 65 6e 64 65 64  |tore in extended|
000009a0  20 76 65 63 74 6f 72 0d  02 94 36 49 4e 59 20 5c  | vector...6INY \|
000009b0  20 6f 66 66 73 65 74 20  74 6f 20 4f 73 62 79 74  | offset to Osbyt|
000009c0  65 20 65 78 74 65 6e 64  65 64 20 76 65 63 74 6f  |e extended vecto|
000009d0  72 2c 20 52 4f 4d 20 6e  75 6d 62 65 72 0d 02 9e  |r, ROM number...|
000009e0  2f 4c 44 41 20 72 6f 6d  6e 75 6d 62 65 72 20 5c  |/LDA romnumber \|
000009f0  20 6c 6f 61 64 20 74 68  65 20 6e 75 6d 62 65 72  | load the number|
00000a00  20 6f 66 20 74 68 69 73  20 52 4f 4d 0d 02 a8 2e  | of this ROM....|
00000a10  53 54 41 20 28 61 64 64  72 65 73 73 29 2c 59 20  |STA (address),Y |
00000a20  5c 20 73 74 6f 72 65 20  69 6e 20 65 78 74 65 6e  |\ store in exten|
00000a30  64 65 64 20 76 65 63 74  6f 72 0d 02 b2 43 4c 44  |ded vector...CLD|
00000a40  58 20 23 26 30 46 20 5c  20 6f 66 66 73 65 74 20  |X #&0F \ offset |
00000a50  74 6f 20 4f 73 62 79 74  65 20 65 6e 74 72 79 20  |to Osbyte entry |
00000a60  74 6f 20 65 78 74 65 6e  64 65 64 20 76 65 63 74  |to extended vect|
00000a70  6f 72 73 2c 20 6c 6f 77  20 62 79 74 65 0d 02 bc  |ors, low byte...|
00000a80  2f 4c 44 59 20 23 26 46  46 20 5c 20 65 78 74 65  |/LDY #&FF \ exte|
00000a90  6e 64 65 64 20 76 65 63  74 6f 72 20 65 6e 74 72  |nded vector entr|
00000aa0  79 2c 20 68 69 67 68 20  62 79 74 65 0d 02 c6 2d  |y, high byte...-|
00000ab0  53 54 58 20 62 79 74 65  76 20 5c 20 61 6c 74 65  |STX bytev \ alte|
00000ac0  72 20 4f 73 62 79 74 65  20 76 65 63 74 6f 72 2c  |r Osbyte vector,|
00000ad0  20 6c 6f 77 20 62 79 74  65 0d 02 d0 30 53 54 59  | low byte...0STY|
00000ae0  20 62 79 74 65 76 2b 31  20 5c 20 61 6c 74 65 72  | bytev+1 \ alter|
00000af0  20 4f 73 62 79 74 65 20  76 65 63 74 6f 72 2c 20  | Osbyte vector, |
00000b00  68 69 67 68 20 62 79 74  65 0d 02 da 20 50 4c 41  |high byte... PLA|
00000b10  20 5c 20 72 65 73 74 6f  72 65 20 74 68 65 20 72  | \ restore the r|
00000b20  65 67 69 73 74 65 72 73  2e 0d 02 e4 35 54 41 59  |egisters....5TAY|
00000b30  20 5c 20 74 68 69 73 20  69 73 20 61 6e 20 69 6c  | \ this is an il|
00000b40  6c 65 67 61 6c 20 75 73  65 20 66 6f 72 20 73 65  |legal use for se|
00000b50  72 76 69 63 65 20 74 79  70 65 20 26 46 45 0d 02  |rvice type &FE..|
00000b60  ee 33 50 4c 41 20 5c 20  74 68 65 20 41 2c 20 58  |.3PLA \ the A, X|
00000b70  20 61 6e 64 20 59 20 72  65 67 69 73 74 65 72 73  | and Y registers|
00000b80  20 6d 75 73 74 20 62 65  20 72 65 73 74 6f 72 65  | must be restore|
00000b90  64 0d 02 f8 30 54 41 58  20 5c 20 62 65 66 6f 72  |d...0TAX \ befor|
00000ba0  65 20 72 65 74 75 72 6e  20 74 6f 20 74 68 65 20  |e return to the |
00000bb0  6f 70 65 72 61 74 69 6e  67 20 73 79 73 74 65 6d  |operating system|
00000bc0  2e 0d 03 02 07 50 4c 41  0d 03 0c 0b 2e 72 65 74  |.....PLA.....ret|
00000bd0  75 72 6e 0d 03 16 07 52  54 53 0d 03 20 0e 2e 69  |urn....RTS.. ..i|
00000be0  6e 74 65 72 72 75 70 74  0d 03 2a 35 4c 44 41 20  |nterrupt..*5LDA |
00000bf0  73 61 76 65 72 65 67 20  5c 20 69 6e 74 65 72 72  |savereg \ interr|
00000c00  75 70 74 20 61 63 63 75  6d 75 6c 61 74 6f 72 20  |upt accumulator |
00000c10  73 61 76 65 20 72 65 67  69 73 74 65 72 0d 03 34  |save register..4|
00000c20  22 50 48 41 20 5c 20 61  6e 64 20 70 75 73 68 20  |"PHA \ and push |
00000c30  69 74 20 6f 6e 20 74 68  65 20 73 74 61 63 6b 0d  |it on the stack.|
00000c40  03 3e 25 4c 44 41 20 69  66 72 20 5c 20 69 6e 74  |.>%LDA ifr \ int|
00000c50  65 72 72 75 70 74 20 66  6c 61 67 20 72 65 67 69  |errupt flag regi|
00000c60  73 74 65 72 0d 03 48 31  42 50 4c 20 6e 6f 74 75  |ster..H1BPL notu|
00000c70  73 65 72 20 5c 20 62 69  74 20 37 20 69 73 20 73  |ser \ bit 7 is s|
00000c80  65 74 20 69 66 20 56 49  41 2d 42 20 69 6e 74 65  |et if VIA-B inte|
00000c90  72 72 75 70 74 0d 03 52  34 80 20 23 26 31 38 20  |rrupt..R4. #&18 |
00000ca0  5c 20 80 20 77 69 74 68  20 25 30 30 30 31 31 30  |\ . with %000110|
00000cb0  30 30 2c 20 69 65 2e 20  74 65 73 74 20 62 69 74  |00, ie. test bit|
00000cc0  73 20 33 20 61 6e 64 20  34 0d 03 5c 28 42 45 51  |s 3 and 4..\(BEQ|
00000cd0  20 6e 6f 74 75 73 65 72  20 5c 20 65 78 69 74 20  | notuser \ exit |
00000ce0  69 66 20 6e 6f 74 20 43  42 31 20 6f 72 20 43 42  |if not CB1 or CB|
00000cf0  32 0d 03 66 2b 80 20 23  26 31 30 20 5c 20 80 20  |2..f+. #&10 \ . |
00000d00  77 69 74 68 20 25 30 30  30 31 30 30 30 30 2c 20  |with %00010000, |
00000d10  69 65 2e 20 74 65 73 74  20 43 42 31 0d 03 70 36  |ie. test CB1..p6|
00000d20  42 4e 45 20 78 70 75 6c  73 65 20 5c 20 62 69 74  |BNE xpulse \ bit|
00000d30  20 34 20 73 65 74 20 66  6f 72 20 61 6e 20 58 20  | 4 set for an X |
00000d40  64 69 72 65 63 74 69 6f  6e 20 6d 6f 76 65 6d 65  |direction moveme|
00000d50  6e 74 0d 03 7a 2f 4c 44  41 20 64 72 62 20 5c 20  |nt..z/LDA drb \ |
00000d60  59 20 64 69 72 65 63 74  69 6f 6e 2c 20 6c 6f 61  |Y direction, loa|
00000d70  64 20 64 61 74 61 20 72  65 67 69 73 74 65 72 20  |d data register |
00000d80  42 0d 03 84 2d 80 20 23  26 30 34 20 5c 20 80 20  |B...-. #&04 \ . |
00000d90  77 69 74 68 20 25 30 30  30 30 30 31 30 30 2c 20  |with %00000100, |
00000da0  69 65 2e 20 74 65 73 74  20 62 69 74 20 32 0d 03  |ie. test bit 2..|
00000db0  8e 34 42 4e 45 20 79 64  6f 77 6e 20 5c 20 69 66  |.4BNE ydown \ if|
00000dc0  20 62 69 74 20 32 20 69  73 20 73 65 74 20 74 68  | bit 2 is set th|
00000dd0  65 6e 20 59 20 69 73 20  67 6f 69 6e 67 20 64 6f  |en Y is going do|
00000de0  77 6e 0d 03 98 38 49 4e  43 20 79 63 6f 6f 72 64  |wn...8INC ycoord|
00000df0  20 5c 20 59 20 69 73 20  67 6f 69 6e 67 20 75 70  | \ Y is going up|
00000e00  20 73 6f 20 69 6e 63 72  65 6d 65 6e 74 20 59 20  | so increment Y |
00000e10  63 6f 6f 72 64 69 6e 61  74 65 0d 03 a2 2e 42 4e  |coordinate....BN|
00000e20  45 20 65 78 69 74 20 5c  20 62 72 61 6e 63 68 20  |E exit \ branch |
00000e30  69 66 20 69 6e 20 74 68  65 20 72 61 6e 67 65 20  |if in the range |
00000e40  31 20 74 6f 20 32 35 35  0d 03 ac 28 42 45 51 20  |1 to 255...(BEQ |
00000e50  64 65 63 79 20 5c 20 69  66 20 7a 65 72 6f 20 74  |decy \ if zero t|
00000e60  68 65 6e 20 61 6c 74 65  72 20 74 6f 20 32 35 35  |hen alter to 255|
00000e70  0d 03 b6 0a 2e 79 64 6f  77 6e 0d 03 c0 22 4c 44  |.....ydown..."LD|
00000e80  41 20 79 63 6f 6f 72 64  20 5c 20 6c 6f 61 64 20  |A ycoord \ load |
00000e90  59 20 63 6f 6f 72 64 69  6e 61 74 65 0d 03 ca 3b  |Y coordinate...;|
00000ea0  42 45 51 20 65 78 69 74  20 5c 20 62 72 61 6e 63  |BEQ exit \ branc|
00000eb0  68 20 69 66 20 7a 65 72  6f 20 62 65 63 61 75 73  |h if zero becaus|
00000ec0  65 20 69 74 20 63 61 6e  27 74 20 67 6f 20 61 6e  |e it can't go an|
00000ed0  79 20 6c 6f 77 65 72 0d  03 d4 09 2e 64 65 63 79  |y lower.....decy|
00000ee0  0d 03 de 29 44 45 43 20  79 63 6f 6f 72 64 20 5c  |...)DEC ycoord \|
00000ef0  20 72 65 64 75 63 65 20  59 20 63 6f 6f 72 64 69  | reduce Y coordi|
00000f00  6e 61 74 65 20 62 79 20  31 0d 03 e8 42 4a 4d 50  |nate by 1...BJMP|
00000f10  20 65 78 69 74 20 5c 20  72 65 73 74 6f 72 65 20  | exit \ restore |
00000f20  69 6e 74 65 72 72 75 70  74 20 61 63 63 75 6d 75  |interrupt accumu|
00000f30  6c 61 74 6f 72 20 73 61  76 65 20 72 65 67 69 73  |lator save regis|
00000f40  74 65 72 20 61 6e 64 20  52 54 49 0d 03 f2 0b 2e  |ter and RTI.....|
00000f50  78 70 75 6c 73 65 0d 03  fc 22 4c 44 41 20 64 72  |xpulse..."LDA dr|
00000f60  62 20 5c 20 6c 6f 61 64  20 64 61 74 61 20 72 65  |b \ load data re|
00000f70  67 69 73 74 65 72 20 42  0d 04 06 1c 52 4f 52 20  |gister B....ROR |
00000f80  41 20 5c 20 62 69 74 20  30 20 69 6e 74 6f 20 63  |A \ bit 0 into c|
00000f90  61 72 72 79 0d 04 10 29  42 43 43 20 78 64 6f 77  |arry...)BCC xdow|
00000fa0  6e 20 5c 20 66 75 64 67  65 20 74 6f 20 72 65 76  |n \ fudge to rev|
00000fb0  65 72 73 65 20 6a 6f 79  73 74 69 63 6b 0d 04 1a  |erse joystick...|
00000fc0  38 49 4e 43 20 78 63 6f  6f 72 64 20 5c 20 66 75  |8INC xcoord \ fu|
00000fd0  64 67 65 20 74 6f 20 69  6e 63 72 65 61 73 65 20  |dge to increase |
00000fe0  58 20 77 68 65 6e 20 69  74 73 20 67 6f 69 6e 67  |X when its going|
00000ff0  20 64 6f 77 6e 0d 04 24  41 42 4e 45 20 65 78 69  | down..$ABNE exi|
00001000  74 20 5c 20 65 78 69 74  20 69 66 20 58 20 63 6f  |t \ exit if X co|
00001010  6f 72 64 69 6e 61 74 65  20 69 73 20 69 6e 20 74  |ordinate is in t|
00001020  68 65 20 72 61 6e 67 65  20 66 72 6f 6d 20 31 20  |he range from 1 |
00001030  74 6f 20 32 35 35 0d 04  2e 33 42 45 51 20 64 65  |to 255...3BEQ de|
00001040  63 78 20 5c 20 69 66 20  58 20 63 6f 6f 72 64 69  |cx \ if X coordi|
00001050  6e 61 74 65 20 3d 20 30  20 74 68 65 6e 20 6d 61  |nate = 0 then ma|
00001060  6b 65 20 69 74 20 32 35  35 0d 04 38 0a 2e 78 64  |ke it 255..8..xd|
00001070  6f 77 6e 0d 04 42 22 4c  44 41 20 78 63 6f 6f 72  |own..B"LDA xcoor|
00001080  64 20 5c 20 6c 6f 61 64  20 58 20 63 6f 6f 72 64  |d \ load X coord|
00001090  69 6e 61 74 65 0d 04 4c  32 42 45 51 20 65 78 69  |inate..L2BEQ exi|
000010a0  74 20 5c 20 69 66 20 69  74 20 69 73 20 7a 65 72  |t \ if it is zer|
000010b0  6f 20 69 74 20 63 61 6e  27 74 20 67 6f 20 61 6e  |o it can't go an|
000010c0  79 20 6c 6f 77 65 72 0d  04 56 09 2e 64 65 63 78  |y lower..V..decx|
000010d0  0d 04 60 2b 44 45 43 20  78 63 6f 6f 72 64 20 5c  |..`+DEC xcoord \|
000010e0  20 64 65 63 72 65 61 73  65 20 58 20 63 6f 6f 72  | decrease X coor|
000010f0  64 69 6e 61 74 65 20 62  79 20 31 0d 04 6a 09 2e  |dinate by 1..j..|
00001100  65 78 69 74 0d 04 74 40  50 4c 41 20 5c 20 70 75  |exit..t@PLA \ pu|
00001110  6c 6c 20 69 6e 74 65 72  72 75 70 74 20 61 63 63  |ll interrupt acc|
00001120  75 6d 75 6c 61 74 6f 72  20 73 61 76 65 20 72 65  |umulator save re|
00001130  67 69 73 74 65 72 20 6f  66 66 20 74 68 65 20 73  |gister off the s|
00001140  74 61 63 6b 0d 04 7e 27  53 54 41 20 73 61 76 65  |tack..~'STA save|
00001150  72 65 67 20 5c 20 61 6e  64 20 72 65 73 74 6f 72  |reg \ and restor|
00001160  65 20 7a 65 72 6f 20 70  61 67 65 0d 04 88 0c 4c  |e zero page....L|
00001170  44 41 20 23 26 30 30 0d  04 92 07 52 54 53 0d 04  |DA #&00....RTS..|
00001180  9c 0c 2e 6e 6f 74 75 73  65 72 0d 04 a6 44 50 4c  |...notuser...DPL|
00001190  41 20 5c 20 70 75 6c 6c  20 74 68 65 20 69 6e 74  |A \ pull the int|
000011a0  65 72 72 75 70 74 20 61  63 63 75 6d 75 6c 61 74  |errupt accumulat|
000011b0  6f 72 20 73 61 76 65 20  72 65 67 69 73 74 65 72  |or save register|
000011c0  20 6f 66 66 20 74 68 65  20 73 74 61 63 6b 0d 04  | off the stack..|
000011d0  b0 2f 53 54 41 20 73 61  76 65 72 65 67 20 5c 20  |./STA savereg \ |
000011e0  72 65 73 74 6f 72 65 20  74 68 65 20 7a 65 72 6f  |restore the zero|
000011f0  20 70 61 67 65 20 61 64  64 72 65 73 73 0d 04 ba  | page address...|
00001200  1d 4c 44 41 20 23 26 30  35 20 5c 20 73 65 72 76  |.LDA #&05 \ serv|
00001210  69 63 65 20 74 79 70 65  20 35 0d 04 c4 24 52 54  |ice type 5...$RT|
00001220  53 20 5c 20 72 65 74 75  72 6e 20 74 6f 20 6f 70  |S \ return to op|
00001230  65 72 61 74 69 6e 67 20  73 79 73 74 65 6d 0d 04  |erating system..|
00001240  ce 0d 2e 6f 6c 64 61 64  76 61 6c 0d 04 d8 1e 50  |...oldadval....P|
00001250  4c 50 20 5c 20 70 75 6c  6c 20 73 74 61 74 75 73  |LP \ pull status|
00001260  20 72 65 67 69 73 74 65  72 0d 04 e2 0d 2e 6f 72  | register.....or|
00001270  69 67 69 6e 61 6c 0d 04  ec 34 4a 4d 50 20 28 6f  |iginal...4JMP (o|
00001280  6c 64 62 79 74 65 76 29  20 5c 20 65 78 69 74 20  |ldbytev) \ exit |
00001290  76 69 61 20 6f 72 69 67  69 6e 61 6c 20 4f 73 62  |via original Osb|
000012a0  79 74 65 20 76 65 63 74  6f 72 0d 04 f6 0d 2e 61  |yte vector.....a|
000012b0  6e 61 6c 6f 67 75 65 0d  05 00 22 50 48 50 20 5c  |nalogue..."PHP \|
000012c0  20 70 75 73 68 20 74 68  65 20 73 74 61 74 75 73  | push the status|
000012d0  20 72 65 67 69 73 74 65  72 0d 05 0a 33 43 4d 50  | register...3CMP|
000012e0  20 23 26 38 30 20 5c 20  69 73 20 74 68 69 73 20  | #&80 \ is this |
000012f0  4f 73 62 79 74 65 20 26  38 30 2c 20 72 65 61 64  |Osbyte &80, read|
00001300  20 41 44 43 20 63 68 61  6e 6e 65 6c 0d 05 14 39  | ADC channel...9|
00001310  42 4e 45 20 6f 6c 64 61  64 76 61 6c 20 5c 20 69  |BNE oldadval \ i|
00001320  66 20 6e 6f 74 20 65 78  69 74 20 76 69 61 20 6f  |f not exit via o|
00001330  72 69 67 69 6e 61 6c 20  4f 73 62 79 74 65 20 76  |riginal Osbyte v|
00001340  65 63 74 6f 72 0d 05 1e  32 43 50 58 20 23 26 30  |ector...2CPX #&0|
00001350  30 20 5c 20 69 73 20 74  68 69 73 20 96 28 30 29  |0 \ is this .(0)|
00001360  20 69 65 2e 20 72 65 61  64 20 66 69 72 65 20 62  | ie. read fire b|
00001370  75 74 74 6f 6e 73 3f 0d  05 28 41 42 45 51 20 66  |uttons?..(ABEQ f|
00001380  69 72 65 62 75 74 74 6f  6e 73 20 5c 20 69 66 20  |irebuttons \ if |
00001390  69 74 20 69 73 20 62 72  61 6e 63 68 20 74 6f 20  |it is branch to |
000013a0  6e 65 77 20 66 69 72 65  20 62 75 74 74 6f 6e 73  |new fire buttons|
000013b0  20 72 6f 75 74 69 6e 65  0d 05 32 29 54 58 41 20  | routine..2)TXA |
000013c0  5c 20 63 68 61 6e 6e 65  6c 20 6e 75 6d 62 65 72  |\ channel number|
000013d0  20 69 73 20 69 6e 20 58  20 72 65 67 69 73 74 65  | is in X registe|
000013e0  72 0d 05 3c 2e 52 4f 52  20 41 20 5c 20 62 69 74  |r..<.ROR A \ bit|
000013f0  20 30 20 6f 66 20 63 68  61 6e 6e 65 6c 20 6e 75  | 0 of channel nu|
00001400  6d 62 65 72 20 69 6e 74  6f 20 63 61 72 72 79 0d  |mber into carry.|
00001410  05 46 31 4c 44 41 20 79  63 6f 6f 72 64 20 5c 20  |.F1LDA ycoord \ |
00001420  59 20 63 6f 6f 72 64 69  6e 61 74 65 20 66 72 6f  |Y coordinate fro|
00001430  6d 20 6d 6f 75 73 65 20  6d 6f 76 65 6d 65 6e 74  |m mouse movement|
00001440  0d 05 50 32 42 43 43 20  73 6b 69 70 78 63 6f 6f  |..P2BCC skipxcoo|
00001450  72 64 20 5c 20 63 61 72  72 79 20 63 6c 65 61 72  |rd \ carry clear|
00001460  20 69 66 20 63 68 61 6e  6e 65 6c 20 32 20 6f 72  | if channel 2 or|
00001470  20 34 0d 05 5a 31 4c 44  41 20 78 63 6f 6f 72 64  | 4..Z1LDA xcoord|
00001480  20 5c 20 58 20 63 6f 6f  72 64 69 6e 61 74 65 20  | \ X coordinate |
00001490  66 72 6f 6d 20 6d 6f 75  73 65 20 6d 6f 76 65 6d  |from mouse movem|
000014a0  65 6e 74 0d 05 64 0f 2e  73 6b 69 70 78 63 6f 6f  |ent..d..skipxcoo|
000014b0  72 64 0d 05 6e 25 54 41  59 20 5c 20 73 69 6d 75  |rd..n%TAY \ simu|
000014c0  6c 61 74 65 64 20 96 28  31 2d 34 29 2c 20 68 69  |lated .(1-4), hi|
000014d0  67 68 20 62 79 74 65 0d  05 78 31 80 20 23 26 46  |gh byte..x1. #&F|
000014e0  30 20 5c 20 80 20 77 69  74 68 20 25 31 31 31 31  |0 \ . with %1111|
000014f0  30 30 30 30 2c 20 69 65  2e 20 63 6c 65 61 72 20  |0000, ie. clear |
00001500  62 69 74 73 20 30 2d 33  0d 05 82 24 54 41 58 20  |bits 0-3...$TAX |
00001510  5c 20 73 69 6d 75 6c 61  74 65 64 20 96 28 31 2d  |\ simulated .(1-|
00001520  34 29 2c 20 6c 6f 77 20  62 79 74 65 0d 05 8c 19  |4), low byte....|
00001530  4c 44 41 20 23 26 38 30  20 5c 20 4f 73 62 79 74  |LDA #&80 \ Osbyt|
00001540  65 20 26 38 30 0d 05 96  21 50 4c 50 20 5c 20 72  |e &80...!PLP \ r|
00001550  65 73 74 6f 72 65 20 73  74 61 74 75 73 20 72 65  |estore status re|
00001560  67 69 73 74 65 72 0d 05  a0 19 52 54 53 20 5c 20  |gister....RTS \ |
00001570  72 65 74 75 72 6e 20 74  6f 20 42 41 53 49 43 0d  |return to BASIC.|
00001580  05 aa 10 2e 66 69 72 65  62 75 74 74 6f 6e 73 0d  |....firebuttons.|
00001590  05 b4 2c 4a 53 52 20 6f  72 69 67 69 6e 61 6c 20  |..,JSR original |
000015a0  5c 20 70 65 72 66 6f 72  6d 20 74 68 65 20 6f 72  |\ perform the or|
000015b0  69 67 69 6e 61 6c 20 96  28 30 29 0d 05 be 32 54  |iginal .(0)...2T|
000015c0  58 41 20 5c 20 72 65 73  75 6c 74 20 69 6e 20 62  |XA \ result in b|
000015d0  69 74 73 20 30 20 61 6e  64 20 31 20 6f 66 20 74  |its 0 and 1 of t|
000015e0  68 65 20 58 20 72 65 67  69 73 74 65 72 0d 05 c8  |he X register...|
000015f0  24 50 48 41 20 5c 20 70  75 73 68 20 74 68 65 20  |$PHA \ push the |
00001600  72 65 73 75 6c 74 20 6f  6e 74 6f 20 73 74 61 63  |result onto stac|
00001610  6b 0d 05 d2 1d 4c 44 41  20 64 72 62 20 5c 20 64  |k....LDA drb \ d|
00001620  61 74 61 20 72 65 67 69  73 74 65 72 20 42 0d 05  |ata register B..|
00001630  dc 1c 52 4f 4c 20 41 20  5c 20 62 69 74 20 37 20  |..ROL A \ bit 7 |
00001640  69 6e 74 6f 20 63 61 72  72 79 0d 05 e6 33 42 43  |into carry...3BC|
00001650  43 20 72 69 67 68 74 20  5c 20 62 69 74 20 37 20  |C right \ bit 7 |
00001660  63 6c 65 61 72 20 69 66  20 72 69 67 68 74 20 62  |clear if right b|
00001670  75 74 74 6f 6e 20 70 72  65 73 73 65 64 0d 05 f0  |utton pressed...|
00001680  1c 52 4f 4c 20 41 20 5c  20 62 69 74 20 36 20 69  |.ROL A \ bit 6 i|
00001690  6e 74 6f 20 63 61 72 72  79 0d 05 fa 35 42 43 43  |nto carry...5BCC|
000016a0  20 63 65 6e 74 72 65 20  5c 20 62 69 74 20 36 20  | centre \ bit 6 |
000016b0  63 6c 65 61 72 20 69 66  20 63 65 6e 74 72 65 20  |clear if centre |
000016c0  62 75 74 74 6f 6e 20 70  72 65 73 73 65 64 0d 06  |button pressed..|
000016d0  04 1c 52 4f 4c 20 41 20  5c 20 62 69 74 20 35 20  |..ROL A \ bit 5 |
000016e0  69 6e 74 6f 20 63 61 72  72 79 0d 06 0e 3c 42 43  |into carry...<BC|
000016f0  53 20 6e 6f 70 72 65 73  73 20 5c 20 69 66 20 62  |S nopress \ if b|
00001700  69 74 20 35 20 73 65 74  20 74 68 65 6e 20 6e 6f  |it 5 set then no|
00001710  20 6d 6f 75 73 65 20 62  75 74 74 6f 6e 73 20 70  | mouse buttons p|
00001720  72 65 73 73 65 64 0d 06  18 3b 50 4c 41 20 5c 20  |ressed...;PLA \ |
00001730  6c 65 66 74 20 62 75 74  74 6f 6e 20 70 72 65 73  |left button pres|
00001740  73 65 64 2c 20 70 75 6c  6c 20 72 65 73 75 6c 74  |sed, pull result|
00001750  20 6f 66 20 6f 72 69 67  69 6e 61 6c 20 96 28 30  | of original .(0|
00001760  29 0d 06 22 37 84 41 20  23 26 30 31 20 5c 20 73  |).."7.A #&01 \ s|
00001770  65 74 20 62 69 74 20 30  20 74 6f 20 73 69 6d 75  |et bit 0 to simu|
00001780  6c 61 74 65 20 66 69 72  65 20 62 75 74 74 6f 6e  |late fire button|
00001790  20 70 72 65 73 73 65 64  0d 06 2c 2d 42 4e 45 20  | pressed..,-BNE |
000017a0  67 65 74 6f 75 74 20 5c  20 75 6e 63 6f 6e 64 69  |getout \ uncondi|
000017b0  74 69 6f 6e 61 6c 20 62  72 61 6e 63 68 20 74 6f  |tional branch to|
000017c0  20 65 78 69 74 0d 06 36  0a 2e 72 69 67 68 74 0d  | exit..6..right.|
000017d0  06 40 26 50 4c 41 20 5c  20 70 75 6c 6c 20 72 65  |.@&PLA \ pull re|
000017e0  73 75 6c 74 20 6f 66 20  6f 72 69 67 69 6e 61 6c  |sult of original|
000017f0  20 96 28 30 29 0d 06 4a  37 84 41 20 23 26 30 32  | .(0)..J7.A #&02|
00001800  20 5c 20 73 65 74 20 62  69 74 20 31 20 74 6f 20  | \ set bit 1 to |
00001810  73 69 6d 75 6c 61 74 65  20 66 69 72 65 20 62 75  |simulate fire bu|
00001820  74 74 6f 6e 20 70 72 65  73 73 65 64 0d 06 54 2d  |tton pressed..T-|
00001830  42 4e 45 20 67 65 74 6f  75 74 20 5c 20 75 6e 63  |BNE getout \ unc|
00001840  6f 6e 64 69 74 69 6f 6e  61 6c 20 62 72 61 6e 63  |onditional branc|
00001850  68 20 74 6f 20 65 78 69  74 0d 06 5e 0b 2e 63 65  |h to exit..^..ce|
00001860  6e 74 72 65 0d 06 68 26  50 4c 41 20 5c 20 70 75  |ntre..h&PLA \ pu|
00001870  6c 6c 20 72 65 73 75 6c  74 20 6f 66 20 6f 72 69  |ll result of ori|
00001880  67 69 6e 61 6c 20 96 28  30 29 0d 06 72 3c 84 41  |ginal .(0)..r<.A|
00001890  20 23 26 30 33 20 5c 20  73 65 74 20 62 69 74 73  | #&03 \ set bits|
000018a0  20 30 20 61 6e 64 20 31  20 74 6f 20 73 69 6d 75  | 0 and 1 to simu|
000018b0  6c 61 74 65 20 62 6f 74  68 20 66 69 72 65 20 62  |late both fire b|
000018c0  75 74 74 6f 6e 73 0d 06  7c 25 42 4e 45 20 67 65  |uttons..|%BNE ge|
000018d0  74 6f 75 74 20 5c 20 75  6e 63 6f 6e 64 69 74 69  |tout \ unconditi|
000018e0  6f 6e 61 6c 20 62 72 61  6e 63 68 0d 06 86 0c 2e  |onal branch.....|
000018f0  6e 6f 70 72 65 73 73 0d  06 90 2c 50 4c 41 20 5c  |nopress...,PLA \|
00001900  20 70 75 6c 6c 20 74 68  65 20 72 65 73 75 6c 74  | pull the result|
00001910  20 62 79 74 65 20 6f 66  66 20 74 68 65 20 73 74  | byte off the st|
00001920  61 63 6b 0d 06 9a 0b 2e  67 65 74 6f 75 74 0d 06  |ack.....getout..|
00001930  a4 30 54 41 58 20 5c 20  74 72 61 6e 73 66 65 72  |.0TAX \ transfer|
00001940  20 72 65 73 75 6c 74 20  62 79 74 65 20 74 6f 20  | result byte to |
00001950  74 68 65 20 58 20 72 65  67 69 73 74 65 72 0d 06  |the X register..|
00001960  ae 19 4c 44 41 20 23 26  38 30 20 5c 20 4f 73 62  |..LDA #&80 \ Osb|
00001970  79 74 65 20 26 38 30 0d  06 b8 22 50 4c 50 20 5c  |yte &80..."PLP \|
00001980  20 70 75 6c 6c 20 74 68  65 20 73 74 61 74 75 73  | pull the status|
00001990  20 72 65 67 69 73 74 65  72 0d 06 c2 19 52 54 53  | register....RTS|
000019a0  20 5c 20 72 65 74 75 72  6e 20 74 6f 20 42 41 53  | \ return to BAS|
000019b0  49 43 0d 06 cc 0b 2e 78  63 6f 6f 72 64 0d 06 d6  |IC.....xcoord...|
000019c0  27 45 51 55 42 20 26 38  30 20 5c 20 6d 6f 75 73  |'EQUB &80 \ mous|
000019d0  65 20 58 20 63 6f 6f 72  64 69 6e 61 74 65 20 30  |e X coordinate 0|
000019e0  2d 32 35 35 0d 06 e0 0b  2e 79 63 6f 6f 72 64 0d  |-255.....ycoord.|
000019f0  06 ea 27 45 51 55 42 20  26 38 30 20 5c 20 6d 6f  |..'EQUB &80 \ mo|
00001a00  75 73 65 20 59 20 63 6f  6f 72 64 69 6e 61 74 65  |use Y coordinate|
00001a10  20 30 2d 32 35 35 0d 06  f4 0d 2e 6f 6c 64 62 79  | 0-255.....oldby|
00001a20  74 65 76 0d 06 fe 31 45  51 55 57 20 26 30 30 20  |tev...1EQUW &00 |
00001a30  5c 20 6f 72 69 67 69 6e  61 6c 20 4f 73 62 79 74  |\ original Osbyt|
00001a40  65 20 69 6e 64 69 72 65  63 74 69 6f 6e 20 76 65  |e indirection ve|
00001a50  63 74 6f 72 0d 07 08 0d  2e 6c 61 73 74 62 79 74  |ctor.....lastbyt|
00001a60  65 0d 07 12 05 5d 0d 07  1c 05 ed 0d 07 26 0b 2a  |e....].......&.*|
00001a70  4f 50 54 31 2c 32 0d 07  30 4e ff 28 22 53 41 56  |OPT1,2..0N.("SAV|
00001a80  45 20 53 57 52 4d 49 43  45 20 22 2b c3 7e 28 6d  |E SWRMICE "+.~(m|
00001a90  63 6f 64 65 29 2b 22 20  2b 20 22 2b c3 7e 28 6c  |code)+" + "+.~(l|
00001aa0  61 73 74 62 79 74 65 2d  26 38 30 30 30 29 2b 22  |astbyte-&8000)+"|
00001ab0  20 46 46 46 46 38 30 30  30 20 46 46 46 46 38 30  | FFFF8000 FFFF80|
00001ac0  30 30 22 29 0d 07 3a 0b  2a 4f 50 54 30 2c 30 0d  |00")..:.*OPT0,0.|
00001ad0  ff                                                |.|
00001ad1
07-01-88/SWMOUSE.m0
07-01-88/SWMOUSE.m1
07-01-88/SWMOUSE.m2
07-01-88/SWMOUSE.m4
07-01-88/SWMOUSE.m5