Home » CEEFAX disks » telesoftware11.adl » 07-01-88/T\MOU06

07-01-88/T\MOU06

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/T\MOU06
Read OK:
File size: 4AD5 bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
Using a mouse with the BBC microcomputer - by - Gordon Horsington
-----------------------------------------------------------------

Module 6. Sideways RAM (SWR) mouse software
-------------------------------------------

The demonstration program used in module 5 can be altered to run from
Sideways RAM. Unrecognised IRQ interrupts are first offered to the paged
ROMs and then to the user via the IRQ2 vector. An unprocessed mouse
interrupt will always be offered to the paged ROMs and it can therefore be
processed in SWR without having to revector IRQ1V.

Service call 5 is used to offer unrecognised interrupts to the paged ROMs.
A SWR mouse program should intercept service call 5 and poll the user VIA
interrupt flag register to see if a mouse was responsible for the
unrecognised interrupt. If a mouse is the source of the interrupt then the
interrupt must be cleared by reading the user VIA data register B. The
interrupt should then be processed and a return made to the operating
system. After processing an interrupt it is essential to return from SWR
with an RTS instruction (not an RTI) and with the accumulator containing
zero.

Although it is not necessary to alter the IRQ1V vector to produce a mouse
driven joystick simulator, it is necessary to alter the Osbyte indirection
vector to point into the SWR code. The vector can be altered during an
interception of the Tube system post initialisation service call, call
number &FE. This call is always issued when the Break key is pressed and,
if the contents of the registers are saved at the beginning and restored
before returning from the call, then it can be used to execute any SWR
code every time the Break key is pressed. It is better to use service call
&FE rather than service call 3 (ROM Auto-boot) because call 3 is cancelled
by the DFS and any program in a lower priority ROM socket than the DFS
will not recieve call 3 if it is trapped by the DFS. There are ways around
this problem and these have been covered in the BBC Telesoftware series
"Mastering Sideways RAM and ROM" but the easiest solution is to use
service call &FE.

The MOS vectors are in page two of memory from &200 to &235. There is also
an area of memory in page &0D known as the extended vector space (EVS)
which has a further three bytes, called an extended vector, available to
each vector. The first two bytes of an extended vector store the address
of a vectored routine if it is in a Sideways ROM and the third byte stores
the number of that ROM.

Vectored MOS routines can be revectored to point to an address in SWR.
To do this it is necessary to store the address and ROM number of the new
routine in the EVS and then change the address contained in the page &02
vector to point to an extended vector entry point in page &FF.

Each of the twenty seven MOS vectors has a vector number, n, such that the
vector can be found at location &200+(2*n). The extended vector entry
point for each vector can be found at &FF00+(3*n).

The start of the extended vector space should be found using Osbyte &A8
with X=&00 and Y=&FF. This returns the address of the first byte of the
extended vector space, V, in X and Y. In a BBC B with MOS 1.20 V=&0D9F.
The address and ROM number of the new routine must be stored in the
extended vector space starting at V+(3*n). The number 3*n can be thought
of as an offset on the first byte of the extended vector space for vector
number n.

This information has been summarised in figure 1 in which the number,
name, location, extended vector entry point (EVEP) and offset on the EVS
has been listed for all the MOS vectors.



No. Name   Location  EVEP       EVS offset
 n         &200+2*n  &FF00+3*n  3*n
------------------------------------------
 0  USERV  &200      &FF00      &00
 1  BRKV   &202      &FF03      &03
 2  IRQ1V  &204      &FF06      &06
 3  IRQ2V  &206      &FF09      &09
 4  CLIV   &208      &FF0C      &0C
 5  BYTEV  &20A      &FF0F      &0F
 6  WORDV  &20C      &FF12      &12
 7  WRCHV  &20E      &FF15      &15
 8  RDCHV  &20E      &FF18      &18
 9  FILEV  &212      &FF1B      &1B
10  ARGSV  &214      &FF1E      &1E
11  BGETV  &216      &FF21      &21
12  BPUTV  &218      &FF24      &24
13  GBPBV  &21A      &FF27      &27
14  FINDV  &21C      &FF2A      &2A
15  FSCV   &21E      &FF2D      &2D
16  EVENTV &220      &FF30      &30
17  UPTV   &222      &FF33      &33
18  NETV   &224      &FF36      &36
19  VDUV   &226      &FF39      &39
20  KEYV   &228      &FF3C      &3C
21  INSV   &22A      &FF3F      &3F
22  REMV   &22C      &FF42      &42
23  CNPV   &22E      &FF45      &45
24  IND1V  &230      &FF48      &48
25  IND2V  &232      &FF4B      &4B
26  IND3V  &234      &FF4E      &4E

Figure 1 The extended vector entry points and offsets
-----------------------------------------------------


You can use figure 1 to find the addresses that need to be altered to
point any vector into SWR software.

If, for example, you want to alter vector number 16, the event vector, to
point to a new SWR routine you first need to use Osbyte &A8 to find the
start of the extended vector space and store the start address in two
consecutive zero page bytes. Then, using post-indexed indirect addressing
with the EVS address stored in these two bytes and the EVS offset in the Y
register, store the address of the new routine and the ROM number of the
SWR program in the EVS. Lastly point the event vector into the SWR program
by storing the extended vector entry point for vector 16 (&FF30) in the
event vector (&220 and &221).

The coding in figure 2 has ben borrowed from the BBC Telesoftware series
"Mastering Sideways ROM and RAM" and shows how a SWR program header can
revector EVENTV to point to a new routine within the same rom image.


  LDA #&A8          \ Osbyte &A8
  LDX #&00
  LDY #&FF
  JSR &FFF4         \ find start of EVS
  STX &70           \ store least sig. byte of EVS
  STY &71           \ store most sig. byte of EVS
  LDY #&30          \ offset on EVS for EVENTV
  LDA #new MOD 256  \ least sig. byte of new routine
  STA (&70),Y       \ least sig. byte in EVS
  INY               \ increment offset for most sig. byte
  LDA #new DIV 256  \ most sig. byte of new routine
  STA (&70),Y       \ most sig. byte in EVS
  INY               \ increment offset for rom number
  LDA &F4           \ find rom number of new routine
  STA (&70),Y       \ store in EVS
  LDX #&30          \ least sig. byte of EVEP for EVENTV
  LDY #&FF          \ most sig. byte of EVEP for EVENTV
  SEI               \ set interupt disable flag
  STX &220          \ store EVEP in least sig. byte of EVENTV
  STY &221          \ store EVEP in most sig. byte of EVENTV
  CLI               \ clear interupt disable flag

Figure 2  Revectoring the event vector
---------------------------------------


This technique has been used in the demonstration program SWMOUSE to
revector the Osbyte indirection vector into the SWR socket which stores
the object code produced by the program. The object code file generated by
the program needs to be loaded into unprotected Sideways RAM and, every
time the Break key is pressed, service call &FE is trapped to initialise
the User Port for use with a mouse. At the same time the Osbyte
indirection vector will be altered to point to the code labeled analogue.

The code at analogue operates in the same way as the demonstration program
in module 5 except that it uses RAM workspace in SWR. Because the
workspace is in the same SWR bank as the program, the program can not be
used from an EPROM without modification. If you want to use the program
from an EPROM, or from write protected SWR, then you will have to move the
RAM workspace into user memory.

Load the object code file SWRMICE into a high priority SWR socket
(preferably socket &0F) and press the Break key. The ADVAL(0-4) commands
will then read the mouse coordinates and buttons as if they were an
analogue joystick. You can demonstrate that it works effectivly with the
program SWTEST.

If you want to use the program SWRMICE with some commercially produced
games you will probably find that there are problems caused by some of the
'illegal' techniques used by games programmers to protect their software.
The most likely source of trouble will be that many programmers overwrite
all the MOS vectors by indirectly loading completely new pages &02 and
&0D. This is usually done to stop you copying the game by interrupting and
saving it but it does have the side effect of preventing you using a mouse
as a substitute for the joysticks. When you know what to look for it is
not too difficult to overcome this sort of problem if you think it is
worth all the trouble.


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


   10 REM> SWTEST
   20 MODE7
   30 mouse$=CHR$141+CHR$132+CHR$157+CHR$131+
      "SWR Mouse coords via ADVAL(0-4)   "+CHR$156
   40 PRINTTAB(0,5)mouse$
   50 PRINTTAB(0,6)mouse$
   60 ONERROR VDU23,1,1;0;0;0;31,0,23:END
   70 VDU23,1,0;0;0;0;
   80 REPEAT
   90 adval=ADVAL(0)AND3
  100 PRINTTAB(10,11)"ADVAL(0)AND3 = ";adval
  110 IF adval=2 PRINTTAB(22,15)"Right" ELSE PRINTTAB(22,15)"     "
  120 IF adval=3  PRINTTAB(16,15)"Both" ELSE PRINTTAB(16,15)"    "
  130 IF adval=1 PRINTTAB(10,15)"Left" ELSE PRINTTAB(10,15)"    "
  140 PRINTTAB(2,20)"ADVAL(1) = ";ADVAL(1);"    "
      TAB(22,20)"ADVAL(2) = ";ADVAL(2);"    "
  150 PRINTTAB(2,22)"ADVAL(3) = ";ADVAL(1);"    "
      TAB(22,22)"ADVAL(4) = ";ADVAL(4);"    "
  160 UNTIL FALSE
  170 VDU23,1,1;0;0;0;31,0,23
  180 END
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 36 2e 20 53  |---..Module 6. S|
00000090  69 64 65 77 61 79 73 20  52 41 4d 20 28 53 57 52  |ideways RAM (SWR|
000000a0  29 20 6d 6f 75 73 65 20  73 6f 66 74 77 61 72 65  |) mouse software|
000000b0  0d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |.---------------|
000000c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000000d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 0d 0d 54 68  |------------..Th|
000000e0  65 20 64 65 6d 6f 6e 73  74 72 61 74 69 6f 6e 20  |e demonstration |
000000f0  70 72 6f 67 72 61 6d 20  75 73 65 64 20 69 6e 20  |program used in |
00000100  6d 6f 64 75 6c 65 20 35  20 63 61 6e 20 62 65 20  |module 5 can be |
00000110  61 6c 74 65 72 65 64 20  74 6f 20 72 75 6e 20 66  |altered to run f|
00000120  72 6f 6d 0d 53 69 64 65  77 61 79 73 20 52 41 4d  |rom.Sideways RAM|
00000130  2e 20 55 6e 72 65 63 6f  67 6e 69 73 65 64 20 49  |. Unrecognised I|
00000140  52 51 20 69 6e 74 65 72  72 75 70 74 73 20 61 72  |RQ interrupts ar|
00000150  65 20 66 69 72 73 74 20  6f 66 66 65 72 65 64 20  |e first offered |
00000160  74 6f 20 74 68 65 20 70  61 67 65 64 0d 52 4f 4d  |to the paged.ROM|
00000170  73 20 61 6e 64 20 74 68  65 6e 20 74 6f 20 74 68  |s and then to th|
00000180  65 20 75 73 65 72 20 76  69 61 20 74 68 65 20 49  |e user via the I|
00000190  52 51 32 20 76 65 63 74  6f 72 2e 20 41 6e 20 75  |RQ2 vector. An u|
000001a0  6e 70 72 6f 63 65 73 73  65 64 20 6d 6f 75 73 65  |nprocessed mouse|
000001b0  0d 69 6e 74 65 72 72 75  70 74 20 77 69 6c 6c 20  |.interrupt will |
000001c0  61 6c 77 61 79 73 20 62  65 20 6f 66 66 65 72 65  |always be offere|
000001d0  64 20 74 6f 20 74 68 65  20 70 61 67 65 64 20 52  |d to the paged R|
000001e0  4f 4d 73 20 61 6e 64 20  69 74 20 63 61 6e 20 74  |OMs and it can t|
000001f0  68 65 72 65 66 6f 72 65  20 62 65 0d 70 72 6f 63  |herefore be.proc|
00000200  65 73 73 65 64 20 69 6e  20 53 57 52 20 77 69 74  |essed in SWR wit|
00000210  68 6f 75 74 20 68 61 76  69 6e 67 20 74 6f 20 72  |hout having to r|
00000220  65 76 65 63 74 6f 72 20  49 52 51 31 56 2e 0d 0d  |evector IRQ1V...|
00000230  53 65 72 76 69 63 65 20  63 61 6c 6c 20 35 20 69  |Service call 5 i|
00000240  73 20 75 73 65 64 20 74  6f 20 6f 66 66 65 72 20  |s used to offer |
00000250  75 6e 72 65 63 6f 67 6e  69 73 65 64 20 69 6e 74  |unrecognised int|
00000260  65 72 72 75 70 74 73 20  74 6f 20 74 68 65 20 70  |errupts to the p|
00000270  61 67 65 64 20 52 4f 4d  73 2e 0d 41 20 53 57 52  |aged ROMs..A SWR|
00000280  20 6d 6f 75 73 65 20 70  72 6f 67 72 61 6d 20 73  | mouse program s|
00000290  68 6f 75 6c 64 20 69 6e  74 65 72 63 65 70 74 20  |hould intercept |
000002a0  73 65 72 76 69 63 65 20  63 61 6c 6c 20 35 20 61  |service call 5 a|
000002b0  6e 64 20 70 6f 6c 6c 20  74 68 65 20 75 73 65 72  |nd poll the user|
000002c0  20 56 49 41 0d 69 6e 74  65 72 72 75 70 74 20 66  | VIA.interrupt f|
000002d0  6c 61 67 20 72 65 67 69  73 74 65 72 20 74 6f 20  |lag register to |
000002e0  73 65 65 20 69 66 20 61  20 6d 6f 75 73 65 20 77  |see if a mouse w|
000002f0  61 73 20 72 65 73 70 6f  6e 73 69 62 6c 65 20 66  |as responsible f|
00000300  6f 72 20 74 68 65 0d 75  6e 72 65 63 6f 67 6e 69  |or the.unrecogni|
00000310  73 65 64 20 69 6e 74 65  72 72 75 70 74 2e 20 49  |sed interrupt. I|
00000320  66 20 61 20 6d 6f 75 73  65 20 69 73 20 74 68 65  |f a mouse is the|
00000330  20 73 6f 75 72 63 65 20  6f 66 20 74 68 65 20 69  | source of the i|
00000340  6e 74 65 72 72 75 70 74  20 74 68 65 6e 20 74 68  |nterrupt then th|
00000350  65 0d 69 6e 74 65 72 72  75 70 74 20 6d 75 73 74  |e.interrupt must|
00000360  20 62 65 20 63 6c 65 61  72 65 64 20 62 79 20 72  | be cleared by r|
00000370  65 61 64 69 6e 67 20 74  68 65 20 75 73 65 72 20  |eading the user |
00000380  56 49 41 20 64 61 74 61  20 72 65 67 69 73 74 65  |VIA data registe|
00000390  72 20 42 2e 20 54 68 65  0d 69 6e 74 65 72 72 75  |r B. The.interru|
000003a0  70 74 20 73 68 6f 75 6c  64 20 74 68 65 6e 20 62  |pt should then b|
000003b0  65 20 70 72 6f 63 65 73  73 65 64 20 61 6e 64 20  |e processed and |
000003c0  61 20 72 65 74 75 72 6e  20 6d 61 64 65 20 74 6f  |a return made to|
000003d0  20 74 68 65 20 6f 70 65  72 61 74 69 6e 67 0d 73  | the operating.s|
000003e0  79 73 74 65 6d 2e 20 41  66 74 65 72 20 70 72 6f  |ystem. After pro|
000003f0  63 65 73 73 69 6e 67 20  61 6e 20 69 6e 74 65 72  |cessing an inter|
00000400  72 75 70 74 20 69 74 20  69 73 20 65 73 73 65 6e  |rupt it is essen|
00000410  74 69 61 6c 20 74 6f 20  72 65 74 75 72 6e 20 66  |tial to return f|
00000420  72 6f 6d 20 53 57 52 0d  77 69 74 68 20 61 6e 20  |rom SWR.with an |
00000430  52 54 53 20 69 6e 73 74  72 75 63 74 69 6f 6e 20  |RTS instruction |
00000440  28 6e 6f 74 20 61 6e 20  52 54 49 29 20 61 6e 64  |(not an RTI) and|
00000450  20 77 69 74 68 20 74 68  65 20 61 63 63 75 6d 75  | with the accumu|
00000460  6c 61 74 6f 72 20 63 6f  6e 74 61 69 6e 69 6e 67  |lator containing|
00000470  0d 7a 65 72 6f 2e 0d 0d  41 6c 74 68 6f 75 67 68  |.zero...Although|
00000480  20 69 74 20 69 73 20 6e  6f 74 20 6e 65 63 65 73  | it is not neces|
00000490  73 61 72 79 20 74 6f 20  61 6c 74 65 72 20 74 68  |sary to alter th|
000004a0  65 20 49 52 51 31 56 20  76 65 63 74 6f 72 20 74  |e IRQ1V vector t|
000004b0  6f 20 70 72 6f 64 75 63  65 20 61 20 6d 6f 75 73  |o produce a mous|
000004c0  65 0d 64 72 69 76 65 6e  20 6a 6f 79 73 74 69 63  |e.driven joystic|
000004d0  6b 20 73 69 6d 75 6c 61  74 6f 72 2c 20 69 74 20  |k simulator, it |
000004e0  69 73 20 6e 65 63 65 73  73 61 72 79 20 74 6f 20  |is necessary to |
000004f0  61 6c 74 65 72 20 74 68  65 20 4f 73 62 79 74 65  |alter the Osbyte|
00000500  20 69 6e 64 69 72 65 63  74 69 6f 6e 0d 76 65 63  | indirection.vec|
00000510  74 6f 72 20 74 6f 20 70  6f 69 6e 74 20 69 6e 74  |tor to point int|
00000520  6f 20 74 68 65 20 53 57  52 20 63 6f 64 65 2e 20  |o the SWR code. |
00000530  54 68 65 20 76 65 63 74  6f 72 20 63 61 6e 20 62  |The vector can b|
00000540  65 20 61 6c 74 65 72 65  64 20 64 75 72 69 6e 67  |e altered during|
00000550  20 61 6e 0d 69 6e 74 65  72 63 65 70 74 69 6f 6e  | an.interception|
00000560  20 6f 66 20 74 68 65 20  54 75 62 65 20 73 79 73  | of the Tube sys|
00000570  74 65 6d 20 70 6f 73 74  20 69 6e 69 74 69 61 6c  |tem post initial|
00000580  69 73 61 74 69 6f 6e 20  73 65 72 76 69 63 65 20  |isation service |
00000590  63 61 6c 6c 2c 20 63 61  6c 6c 0d 6e 75 6d 62 65  |call, call.numbe|
000005a0  72 20 26 46 45 2e 20 54  68 69 73 20 63 61 6c 6c  |r &FE. This call|
000005b0  20 69 73 20 61 6c 77 61  79 73 20 69 73 73 75 65  | is always issue|
000005c0  64 20 77 68 65 6e 20 74  68 65 20 42 72 65 61 6b  |d when the Break|
000005d0  20 6b 65 79 20 69 73 20  70 72 65 73 73 65 64 20  | key is pressed |
000005e0  61 6e 64 2c 0d 69 66 20  74 68 65 20 63 6f 6e 74  |and,.if the cont|
000005f0  65 6e 74 73 20 6f 66 20  74 68 65 20 72 65 67 69  |ents of the regi|
00000600  73 74 65 72 73 20 61 72  65 20 73 61 76 65 64 20  |sters are saved |
00000610  61 74 20 74 68 65 20 62  65 67 69 6e 6e 69 6e 67  |at the beginning|
00000620  20 61 6e 64 20 72 65 73  74 6f 72 65 64 0d 62 65  | and restored.be|
00000630  66 6f 72 65 20 72 65 74  75 72 6e 69 6e 67 20 66  |fore returning f|
00000640  72 6f 6d 20 74 68 65 20  63 61 6c 6c 2c 20 74 68  |rom the call, th|
00000650  65 6e 20 69 74 20 63 61  6e 20 62 65 20 75 73 65  |en it can be use|
00000660  64 20 74 6f 20 65 78 65  63 75 74 65 20 61 6e 79  |d to execute any|
00000670  20 53 57 52 0d 63 6f 64  65 20 65 76 65 72 79 20  | SWR.code every |
00000680  74 69 6d 65 20 74 68 65  20 42 72 65 61 6b 20 6b  |time the Break k|
00000690  65 79 20 69 73 20 70 72  65 73 73 65 64 2e 20 49  |ey is pressed. I|
000006a0  74 20 69 73 20 62 65 74  74 65 72 20 74 6f 20 75  |t is better to u|
000006b0  73 65 20 73 65 72 76 69  63 65 20 63 61 6c 6c 0d  |se service call.|
000006c0  26 46 45 20 72 61 74 68  65 72 20 74 68 61 6e 20  |&FE rather than |
000006d0  73 65 72 76 69 63 65 20  63 61 6c 6c 20 33 20 28  |service call 3 (|
000006e0  52 4f 4d 20 41 75 74 6f  2d 62 6f 6f 74 29 20 62  |ROM Auto-boot) b|
000006f0  65 63 61 75 73 65 20 63  61 6c 6c 20 33 20 69 73  |ecause call 3 is|
00000700  20 63 61 6e 63 65 6c 6c  65 64 0d 62 79 20 74 68  | cancelled.by th|
00000710  65 20 44 46 53 20 61 6e  64 20 61 6e 79 20 70 72  |e DFS and any pr|
00000720  6f 67 72 61 6d 20 69 6e  20 61 20 6c 6f 77 65 72  |ogram in a lower|
00000730  20 70 72 69 6f 72 69 74  79 20 52 4f 4d 20 73 6f  | priority ROM so|
00000740  63 6b 65 74 20 74 68 61  6e 20 74 68 65 20 44 46  |cket than the DF|
00000750  53 0d 77 69 6c 6c 20 6e  6f 74 20 72 65 63 69 65  |S.will not recie|
00000760  76 65 20 63 61 6c 6c 20  33 20 69 66 20 69 74 20  |ve call 3 if it |
00000770  69 73 20 74 72 61 70 70  65 64 20 62 79 20 74 68  |is trapped by th|
00000780  65 20 44 46 53 2e 20 54  68 65 72 65 20 61 72 65  |e DFS. There are|
00000790  20 77 61 79 73 20 61 72  6f 75 6e 64 0d 74 68 69  | ways around.thi|
000007a0  73 20 70 72 6f 62 6c 65  6d 20 61 6e 64 20 74 68  |s problem and th|
000007b0  65 73 65 20 68 61 76 65  20 62 65 65 6e 20 63 6f  |ese have been co|
000007c0  76 65 72 65 64 20 69 6e  20 74 68 65 20 42 42 43  |vered in the BBC|
000007d0  20 54 65 6c 65 73 6f 66  74 77 61 72 65 20 73 65  | Telesoftware se|
000007e0  72 69 65 73 0d 22 4d 61  73 74 65 72 69 6e 67 20  |ries."Mastering |
000007f0  53 69 64 65 77 61 79 73  20 52 41 4d 20 61 6e 64  |Sideways RAM and|
00000800  20 52 4f 4d 22 20 62 75  74 20 74 68 65 20 65 61  | ROM" but the ea|
00000810  73 69 65 73 74 20 73 6f  6c 75 74 69 6f 6e 20 69  |siest solution i|
00000820  73 20 74 6f 20 75 73 65  0d 73 65 72 76 69 63 65  |s to use.service|
00000830  20 63 61 6c 6c 20 26 46  45 2e 0d 0d 54 68 65 20  | call &FE...The |
00000840  4d 4f 53 20 76 65 63 74  6f 72 73 20 61 72 65 20  |MOS vectors are |
00000850  69 6e 20 70 61 67 65 20  74 77 6f 20 6f 66 20 6d  |in page two of m|
00000860  65 6d 6f 72 79 20 66 72  6f 6d 20 26 32 30 30 20  |emory from &200 |
00000870  74 6f 20 26 32 33 35 2e  20 54 68 65 72 65 20 69  |to &235. There i|
00000880  73 20 61 6c 73 6f 0d 61  6e 20 61 72 65 61 20 6f  |s also.an area o|
00000890  66 20 6d 65 6d 6f 72 79  20 69 6e 20 70 61 67 65  |f memory in page|
000008a0  20 26 30 44 20 6b 6e 6f  77 6e 20 61 73 20 74 68  | &0D known as th|
000008b0  65 20 65 78 74 65 6e 64  65 64 20 76 65 63 74 6f  |e extended vecto|
000008c0  72 20 73 70 61 63 65 20  28 45 56 53 29 0d 77 68  |r space (EVS).wh|
000008d0  69 63 68 20 68 61 73 20  61 20 66 75 72 74 68 65  |ich has a furthe|
000008e0  72 20 74 68 72 65 65 20  62 79 74 65 73 2c 20 63  |r three bytes, c|
000008f0  61 6c 6c 65 64 20 61 6e  20 65 78 74 65 6e 64 65  |alled an extende|
00000900  64 20 76 65 63 74 6f 72  2c 20 61 76 61 69 6c 61  |d vector, availa|
00000910  62 6c 65 20 74 6f 0d 65  61 63 68 20 76 65 63 74  |ble to.each vect|
00000920  6f 72 2e 20 54 68 65 20  66 69 72 73 74 20 74 77  |or. The first tw|
00000930  6f 20 62 79 74 65 73 20  6f 66 20 61 6e 20 65 78  |o bytes of an ex|
00000940  74 65 6e 64 65 64 20 76  65 63 74 6f 72 20 73 74  |tended vector st|
00000950  6f 72 65 20 74 68 65 20  61 64 64 72 65 73 73 0d  |ore the address.|
00000960  6f 66 20 61 20 76 65 63  74 6f 72 65 64 20 72 6f  |of a vectored ro|
00000970  75 74 69 6e 65 20 69 66  20 69 74 20 69 73 20 69  |utine if it is i|
00000980  6e 20 61 20 53 69 64 65  77 61 79 73 20 52 4f 4d  |n a Sideways ROM|
00000990  20 61 6e 64 20 74 68 65  20 74 68 69 72 64 20 62  | and the third b|
000009a0  79 74 65 20 73 74 6f 72  65 73 0d 74 68 65 20 6e  |yte stores.the n|
000009b0  75 6d 62 65 72 20 6f 66  20 74 68 61 74 20 52 4f  |umber of that RO|
000009c0  4d 2e 0d 0d 56 65 63 74  6f 72 65 64 20 4d 4f 53  |M...Vectored MOS|
000009d0  20 72 6f 75 74 69 6e 65  73 20 63 61 6e 20 62 65  | routines can be|
000009e0  20 72 65 76 65 63 74 6f  72 65 64 20 74 6f 20 70  | revectored to p|
000009f0  6f 69 6e 74 20 74 6f 20  61 6e 20 61 64 64 72 65  |oint to an addre|
00000a00  73 73 20 69 6e 20 53 57  52 2e 0d 54 6f 20 64 6f  |ss in SWR..To do|
00000a10  20 74 68 69 73 20 69 74  20 69 73 20 6e 65 63 65  | this it is nece|
00000a20  73 73 61 72 79 20 74 6f  20 73 74 6f 72 65 20 74  |ssary to store t|
00000a30  68 65 20 61 64 64 72 65  73 73 20 61 6e 64 20 52  |he address and R|
00000a40  4f 4d 20 6e 75 6d 62 65  72 20 6f 66 20 74 68 65  |OM number of the|
00000a50  20 6e 65 77 0d 72 6f 75  74 69 6e 65 20 69 6e 20  | new.routine in |
00000a60  74 68 65 20 45 56 53 20  61 6e 64 20 74 68 65 6e  |the EVS and then|
00000a70  20 63 68 61 6e 67 65 20  74 68 65 20 61 64 64 72  | change the addr|
00000a80  65 73 73 20 63 6f 6e 74  61 69 6e 65 64 20 69 6e  |ess contained in|
00000a90  20 74 68 65 20 70 61 67  65 20 26 30 32 0d 76 65  | the page &02.ve|
00000aa0  63 74 6f 72 20 74 6f 20  70 6f 69 6e 74 20 74 6f  |ctor to point to|
00000ab0  20 61 6e 20 65 78 74 65  6e 64 65 64 20 76 65 63  | an extended vec|
00000ac0  74 6f 72 20 65 6e 74 72  79 20 70 6f 69 6e 74 20  |tor entry point |
00000ad0  69 6e 20 70 61 67 65 20  26 46 46 2e 0d 0d 45 61  |in page &FF...Ea|
00000ae0  63 68 20 6f 66 20 74 68  65 20 74 77 65 6e 74 79  |ch of the twenty|
00000af0  20 73 65 76 65 6e 20 4d  4f 53 20 76 65 63 74 6f  | seven MOS vecto|
00000b00  72 73 20 68 61 73 20 61  20 76 65 63 74 6f 72 20  |rs has a vector |
00000b10  6e 75 6d 62 65 72 2c 20  6e 2c 20 73 75 63 68 20  |number, n, such |
00000b20  74 68 61 74 20 74 68 65  0d 76 65 63 74 6f 72 20  |that the.vector |
00000b30  63 61 6e 20 62 65 20 66  6f 75 6e 64 20 61 74 20  |can be found at |
00000b40  6c 6f 63 61 74 69 6f 6e  20 26 32 30 30 2b 28 32  |location &200+(2|
00000b50  2a 6e 29 2e 20 54 68 65  20 65 78 74 65 6e 64 65  |*n). The extende|
00000b60  64 20 76 65 63 74 6f 72  20 65 6e 74 72 79 0d 70  |d vector entry.p|
00000b70  6f 69 6e 74 20 66 6f 72  20 65 61 63 68 20 76 65  |oint for each ve|
00000b80  63 74 6f 72 20 63 61 6e  20 62 65 20 66 6f 75 6e  |ctor can be foun|
00000b90  64 20 61 74 20 26 46 46  30 30 2b 28 33 2a 6e 29  |d at &FF00+(3*n)|
00000ba0  2e 0d 0d 54 68 65 20 73  74 61 72 74 20 6f 66 20  |...The start of |
00000bb0  74 68 65 20 65 78 74 65  6e 64 65 64 20 76 65 63  |the extended vec|
00000bc0  74 6f 72 20 73 70 61 63  65 20 73 68 6f 75 6c 64  |tor space should|
00000bd0  20 62 65 20 66 6f 75 6e  64 20 75 73 69 6e 67 20  | be found using |
00000be0  4f 73 62 79 74 65 20 26  41 38 0d 77 69 74 68 20  |Osbyte &A8.with |
00000bf0  58 3d 26 30 30 20 61 6e  64 20 59 3d 26 46 46 2e  |X=&00 and Y=&FF.|
00000c00  20 54 68 69 73 20 72 65  74 75 72 6e 73 20 74 68  | This returns th|
00000c10  65 20 61 64 64 72 65 73  73 20 6f 66 20 74 68 65  |e address of the|
00000c20  20 66 69 72 73 74 20 62  79 74 65 20 6f 66 20 74  | first byte of t|
00000c30  68 65 0d 65 78 74 65 6e  64 65 64 20 76 65 63 74  |he.extended vect|
00000c40  6f 72 20 73 70 61 63 65  2c 20 56 2c 20 69 6e 20  |or space, V, in |
00000c50  58 20 61 6e 64 20 59 2e  20 49 6e 20 61 20 42 42  |X and Y. In a BB|
00000c60  43 20 42 20 77 69 74 68  20 4d 4f 53 20 31 2e 32  |C B with MOS 1.2|
00000c70  30 20 56 3d 26 30 44 39  46 2e 0d 54 68 65 20 61  |0 V=&0D9F..The a|
00000c80  64 64 72 65 73 73 20 61  6e 64 20 52 4f 4d 20 6e  |ddress and ROM n|
00000c90  75 6d 62 65 72 20 6f 66  20 74 68 65 20 6e 65 77  |umber of the new|
00000ca0  20 72 6f 75 74 69 6e 65  20 6d 75 73 74 20 62 65  | routine must be|
00000cb0  20 73 74 6f 72 65 64 20  69 6e 20 74 68 65 0d 65  | stored in the.e|
00000cc0  78 74 65 6e 64 65 64 20  76 65 63 74 6f 72 20 73  |xtended vector s|
00000cd0  70 61 63 65 20 73 74 61  72 74 69 6e 67 20 61 74  |pace starting at|
00000ce0  20 56 2b 28 33 2a 6e 29  2e 20 54 68 65 20 6e 75  | V+(3*n). The nu|
00000cf0  6d 62 65 72 20 33 2a 6e  20 63 61 6e 20 62 65 20  |mber 3*n can be |
00000d00  74 68 6f 75 67 68 74 0d  6f 66 20 61 73 20 61 6e  |thought.of as an|
00000d10  20 6f 66 66 73 65 74 20  6f 6e 20 74 68 65 20 66  | offset on the f|
00000d20  69 72 73 74 20 62 79 74  65 20 6f 66 20 74 68 65  |irst byte of the|
00000d30  20 65 78 74 65 6e 64 65  64 20 76 65 63 74 6f 72  | extended vector|
00000d40  20 73 70 61 63 65 20 66  6f 72 20 76 65 63 74 6f  | space for vecto|
00000d50  72 0d 6e 75 6d 62 65 72  20 6e 2e 0d 0d 54 68 69  |r.number n...Thi|
00000d60  73 20 69 6e 66 6f 72 6d  61 74 69 6f 6e 20 68 61  |s information ha|
00000d70  73 20 62 65 65 6e 20 73  75 6d 6d 61 72 69 73 65  |s been summarise|
00000d80  64 20 69 6e 20 66 69 67  75 72 65 20 31 20 69 6e  |d in figure 1 in|
00000d90  20 77 68 69 63 68 20 74  68 65 20 6e 75 6d 62 65  | which the numbe|
00000da0  72 2c 0d 6e 61 6d 65 2c  20 6c 6f 63 61 74 69 6f  |r,.name, locatio|
00000db0  6e 2c 20 65 78 74 65 6e  64 65 64 20 76 65 63 74  |n, extended vect|
00000dc0  6f 72 20 65 6e 74 72 79  20 70 6f 69 6e 74 20 28  |or entry point (|
00000dd0  45 56 45 50 29 20 61 6e  64 20 6f 66 66 73 65 74  |EVEP) and offset|
00000de0  20 6f 6e 20 74 68 65 20  45 56 53 0d 68 61 73 20  | on the EVS.has |
00000df0  62 65 65 6e 20 6c 69 73  74 65 64 20 66 6f 72 20  |been listed for |
00000e00  61 6c 6c 20 74 68 65 20  4d 4f 53 20 76 65 63 74  |all the MOS vect|
00000e10  6f 72 73 2e 0d 0d 0d 0d  4e 6f 2e 20 4e 61 6d 65  |ors.....No. Name|
00000e20  20 20 20 4c 6f 63 61 74  69 6f 6e 20 20 45 56 45  |   Location  EVE|
00000e30  50 20 20 20 20 20 20 20  45 56 53 20 6f 66 66 73  |P       EVS offs|
00000e40  65 74 0d 20 6e 20 20 20  20 20 20 20 20 20 26 32  |et. n         &2|
00000e50  30 30 2b 32 2a 6e 20 20  26 46 46 30 30 2b 33 2a  |00+2*n  &FF00+3*|
00000e60  6e 20 20 33 2a 6e 0d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |n  3*n.---------|
00000e70  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000e90  2d 0d 20 30 20 20 55 53  45 52 56 20 20 26 32 30  |-. 0  USERV  &20|
00000ea0  30 20 20 20 20 20 20 26  46 46 30 30 20 20 20 20  |0      &FF00    |
00000eb0  20 20 26 30 30 0d 20 31  20 20 42 52 4b 56 20 20  |  &00. 1  BRKV  |
00000ec0  20 26 32 30 32 20 20 20  20 20 20 26 46 46 30 33  | &202      &FF03|
00000ed0  20 20 20 20 20 20 26 30  33 0d 20 32 20 20 49 52  |      &03. 2  IR|
00000ee0  51 31 56 20 20 26 32 30  34 20 20 20 20 20 20 26  |Q1V  &204      &|
00000ef0  46 46 30 36 20 20 20 20  20 20 26 30 36 0d 20 33  |FF06      &06. 3|
00000f00  20 20 49 52 51 32 56 20  20 26 32 30 36 20 20 20  |  IRQ2V  &206   |
00000f10  20 20 20 26 46 46 30 39  20 20 20 20 20 20 26 30  |   &FF09      &0|
00000f20  39 0d 20 34 20 20 43 4c  49 56 20 20 20 26 32 30  |9. 4  CLIV   &20|
00000f30  38 20 20 20 20 20 20 26  46 46 30 43 20 20 20 20  |8      &FF0C    |
00000f40  20 20 26 30 43 0d 20 35  20 20 42 59 54 45 56 20  |  &0C. 5  BYTEV |
00000f50  20 26 32 30 41 20 20 20  20 20 20 26 46 46 30 46  | &20A      &FF0F|
00000f60  20 20 20 20 20 20 26 30  46 0d 20 36 20 20 57 4f  |      &0F. 6  WO|
00000f70  52 44 56 20 20 26 32 30  43 20 20 20 20 20 20 26  |RDV  &20C      &|
00000f80  46 46 31 32 20 20 20 20  20 20 26 31 32 0d 20 37  |FF12      &12. 7|
00000f90  20 20 57 52 43 48 56 20  20 26 32 30 45 20 20 20  |  WRCHV  &20E   |
00000fa0  20 20 20 26 46 46 31 35  20 20 20 20 20 20 26 31  |   &FF15      &1|
00000fb0  35 0d 20 38 20 20 52 44  43 48 56 20 20 26 32 30  |5. 8  RDCHV  &20|
00000fc0  45 20 20 20 20 20 20 26  46 46 31 38 20 20 20 20  |E      &FF18    |
00000fd0  20 20 26 31 38 0d 20 39  20 20 46 49 4c 45 56 20  |  &18. 9  FILEV |
00000fe0  20 26 32 31 32 20 20 20  20 20 20 26 46 46 31 42  | &212      &FF1B|
00000ff0  20 20 20 20 20 20 26 31  42 0d 31 30 20 20 41 52  |      &1B.10  AR|
00001000  47 53 56 20 20 26 32 31  34 20 20 20 20 20 20 26  |GSV  &214      &|
00001010  46 46 31 45 20 20 20 20  20 20 26 31 45 0d 31 31  |FF1E      &1E.11|
00001020  20 20 42 47 45 54 56 20  20 26 32 31 36 20 20 20  |  BGETV  &216   |
00001030  20 20 20 26 46 46 32 31  20 20 20 20 20 20 26 32  |   &FF21      &2|
00001040  31 0d 31 32 20 20 42 50  55 54 56 20 20 26 32 31  |1.12  BPUTV  &21|
00001050  38 20 20 20 20 20 20 26  46 46 32 34 20 20 20 20  |8      &FF24    |
00001060  20 20 26 32 34 0d 31 33  20 20 47 42 50 42 56 20  |  &24.13  GBPBV |
00001070  20 26 32 31 41 20 20 20  20 20 20 26 46 46 32 37  | &21A      &FF27|
00001080  20 20 20 20 20 20 26 32  37 0d 31 34 20 20 46 49  |      &27.14  FI|
00001090  4e 44 56 20 20 26 32 31  43 20 20 20 20 20 20 26  |NDV  &21C      &|
000010a0  46 46 32 41 20 20 20 20  20 20 26 32 41 0d 31 35  |FF2A      &2A.15|
000010b0  20 20 46 53 43 56 20 20  20 26 32 31 45 20 20 20  |  FSCV   &21E   |
000010c0  20 20 20 26 46 46 32 44  20 20 20 20 20 20 26 32  |   &FF2D      &2|
000010d0  44 0d 31 36 20 20 45 56  45 4e 54 56 20 26 32 32  |D.16  EVENTV &22|
000010e0  30 20 20 20 20 20 20 26  46 46 33 30 20 20 20 20  |0      &FF30    |
000010f0  20 20 26 33 30 0d 31 37  20 20 55 50 54 56 20 20  |  &30.17  UPTV  |
00001100  20 26 32 32 32 20 20 20  20 20 20 26 46 46 33 33  | &222      &FF33|
00001110  20 20 20 20 20 20 26 33  33 0d 31 38 20 20 4e 45  |      &33.18  NE|
00001120  54 56 20 20 20 26 32 32  34 20 20 20 20 20 20 26  |TV   &224      &|
00001130  46 46 33 36 20 20 20 20  20 20 26 33 36 0d 31 39  |FF36      &36.19|
00001140  20 20 56 44 55 56 20 20  20 26 32 32 36 20 20 20  |  VDUV   &226   |
00001150  20 20 20 26 46 46 33 39  20 20 20 20 20 20 26 33  |   &FF39      &3|
00001160  39 0d 32 30 20 20 4b 45  59 56 20 20 20 26 32 32  |9.20  KEYV   &22|
00001170  38 20 20 20 20 20 20 26  46 46 33 43 20 20 20 20  |8      &FF3C    |
00001180  20 20 26 33 43 0d 32 31  20 20 49 4e 53 56 20 20  |  &3C.21  INSV  |
00001190  20 26 32 32 41 20 20 20  20 20 20 26 46 46 33 46  | &22A      &FF3F|
000011a0  20 20 20 20 20 20 26 33  46 0d 32 32 20 20 52 45  |      &3F.22  RE|
000011b0  4d 56 20 20 20 26 32 32  43 20 20 20 20 20 20 26  |MV   &22C      &|
000011c0  46 46 34 32 20 20 20 20  20 20 26 34 32 0d 32 33  |FF42      &42.23|
000011d0  20 20 43 4e 50 56 20 20  20 26 32 32 45 20 20 20  |  CNPV   &22E   |
000011e0  20 20 20 26 46 46 34 35  20 20 20 20 20 20 26 34  |   &FF45      &4|
000011f0  35 0d 32 34 20 20 49 4e  44 31 56 20 20 26 32 33  |5.24  IND1V  &23|
00001200  30 20 20 20 20 20 20 26  46 46 34 38 20 20 20 20  |0      &FF48    |
00001210  20 20 26 34 38 0d 32 35  20 20 49 4e 44 32 56 20  |  &48.25  IND2V |
00001220  20 26 32 33 32 20 20 20  20 20 20 26 46 46 34 42  | &232      &FF4B|
00001230  20 20 20 20 20 20 26 34  42 0d 32 36 20 20 49 4e  |      &4B.26  IN|
00001240  44 33 56 20 20 26 32 33  34 20 20 20 20 20 20 26  |D3V  &234      &|
00001250  46 46 34 45 20 20 20 20  20 20 26 34 45 0d 0d 46  |FF4E      &4E..F|
00001260  69 67 75 72 65 20 31 20  54 68 65 20 65 78 74 65  |igure 1 The exte|
00001270  6e 64 65 64 20 76 65 63  74 6f 72 20 65 6e 74 72  |nded vector entr|
00001280  79 20 70 6f 69 6e 74 73  20 61 6e 64 20 6f 66 66  |y points and off|
00001290  73 65 74 73 0d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |sets.-----------|
000012a0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000012c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 0d 0d 0d 59 6f 75  |----------...You|
000012d0  20 63 61 6e 20 75 73 65  20 66 69 67 75 72 65 20  | can use figure |
000012e0  31 20 74 6f 20 66 69 6e  64 20 74 68 65 20 61 64  |1 to find the ad|
000012f0  64 72 65 73 73 65 73 20  74 68 61 74 20 6e 65 65  |dresses that nee|
00001300  64 20 74 6f 20 62 65 20  61 6c 74 65 72 65 64 20  |d to be altered |
00001310  74 6f 0d 70 6f 69 6e 74  20 61 6e 79 20 76 65 63  |to.point any vec|
00001320  74 6f 72 20 69 6e 74 6f  20 53 57 52 20 73 6f 66  |tor into SWR sof|
00001330  74 77 61 72 65 2e 0d 0d  49 66 2c 20 66 6f 72 20  |tware...If, for |
00001340  65 78 61 6d 70 6c 65 2c  20 79 6f 75 20 77 61 6e  |example, you wan|
00001350  74 20 74 6f 20 61 6c 74  65 72 20 76 65 63 74 6f  |t to alter vecto|
00001360  72 20 6e 75 6d 62 65 72  20 31 36 2c 20 74 68 65  |r number 16, the|
00001370  20 65 76 65 6e 74 20 76  65 63 74 6f 72 2c 20 74  | event vector, t|
00001380  6f 0d 70 6f 69 6e 74 20  74 6f 20 61 20 6e 65 77  |o.point to a new|
00001390  20 53 57 52 20 72 6f 75  74 69 6e 65 20 79 6f 75  | SWR routine you|
000013a0  20 66 69 72 73 74 20 6e  65 65 64 20 74 6f 20 75  | first need to u|
000013b0  73 65 20 4f 73 62 79 74  65 20 26 41 38 20 74 6f  |se Osbyte &A8 to|
000013c0  20 66 69 6e 64 20 74 68  65 0d 73 74 61 72 74 20  | find the.start |
000013d0  6f 66 20 74 68 65 20 65  78 74 65 6e 64 65 64 20  |of the extended |
000013e0  76 65 63 74 6f 72 20 73  70 61 63 65 20 61 6e 64  |vector space and|
000013f0  20 73 74 6f 72 65 20 74  68 65 20 73 74 61 72 74  | store the start|
00001400  20 61 64 64 72 65 73 73  20 69 6e 20 74 77 6f 0d  | address in two.|
00001410  63 6f 6e 73 65 63 75 74  69 76 65 20 7a 65 72 6f  |consecutive zero|
00001420  20 70 61 67 65 20 62 79  74 65 73 2e 20 54 68 65  | page bytes. The|
00001430  6e 2c 20 75 73 69 6e 67  20 70 6f 73 74 2d 69 6e  |n, using post-in|
00001440  64 65 78 65 64 20 69 6e  64 69 72 65 63 74 20 61  |dexed indirect a|
00001450  64 64 72 65 73 73 69 6e  67 0d 77 69 74 68 20 74  |ddressing.with t|
00001460  68 65 20 45 56 53 20 61  64 64 72 65 73 73 20 73  |he EVS address s|
00001470  74 6f 72 65 64 20 69 6e  20 74 68 65 73 65 20 74  |tored in these t|
00001480  77 6f 20 62 79 74 65 73  20 61 6e 64 20 74 68 65  |wo bytes and the|
00001490  20 45 56 53 20 6f 66 66  73 65 74 20 69 6e 20 74  | EVS offset in t|
000014a0  68 65 20 59 0d 72 65 67  69 73 74 65 72 2c 20 73  |he Y.register, s|
000014b0  74 6f 72 65 20 74 68 65  20 61 64 64 72 65 73 73  |tore the address|
000014c0  20 6f 66 20 74 68 65 20  6e 65 77 20 72 6f 75 74  | of the new rout|
000014d0  69 6e 65 20 61 6e 64 20  74 68 65 20 52 4f 4d 20  |ine and the ROM |
000014e0  6e 75 6d 62 65 72 20 6f  66 20 74 68 65 0d 53 57  |number of the.SW|
000014f0  52 20 70 72 6f 67 72 61  6d 20 69 6e 20 74 68 65  |R program in the|
00001500  20 45 56 53 2e 20 4c 61  73 74 6c 79 20 70 6f 69  | EVS. Lastly poi|
00001510  6e 74 20 74 68 65 20 65  76 65 6e 74 20 76 65 63  |nt the event vec|
00001520  74 6f 72 20 69 6e 74 6f  20 74 68 65 20 53 57 52  |tor into the SWR|
00001530  20 70 72 6f 67 72 61 6d  0d 62 79 20 73 74 6f 72  | program.by stor|
00001540  69 6e 67 20 74 68 65 20  65 78 74 65 6e 64 65 64  |ing the extended|
00001550  20 76 65 63 74 6f 72 20  65 6e 74 72 79 20 70 6f  | vector entry po|
00001560  69 6e 74 20 66 6f 72 20  76 65 63 74 6f 72 20 31  |int for vector 1|
00001570  36 20 28 26 46 46 33 30  29 20 69 6e 20 74 68 65  |6 (&FF30) in the|
00001580  0d 65 76 65 6e 74 20 76  65 63 74 6f 72 20 28 26  |.event vector (&|
00001590  32 32 30 20 61 6e 64 20  26 32 32 31 29 2e 0d 0d  |220 and &221)...|
000015a0  54 68 65 20 63 6f 64 69  6e 67 20 69 6e 20 66 69  |The coding in fi|
000015b0  67 75 72 65 20 32 20 68  61 73 20 62 65 6e 20 62  |gure 2 has ben b|
000015c0  6f 72 72 6f 77 65 64 20  66 72 6f 6d 20 74 68 65  |orrowed from the|
000015d0  20 42 42 43 20 54 65 6c  65 73 6f 66 74 77 61 72  | BBC Telesoftwar|
000015e0  65 20 73 65 72 69 65 73  0d 22 4d 61 73 74 65 72  |e series."Master|
000015f0  69 6e 67 20 53 69 64 65  77 61 79 73 20 52 4f 4d  |ing Sideways ROM|
00001600  20 61 6e 64 20 52 41 4d  22 20 61 6e 64 20 73 68  | and RAM" and sh|
00001610  6f 77 73 20 68 6f 77 20  61 20 53 57 52 20 70 72  |ows how a SWR pr|
00001620  6f 67 72 61 6d 20 68 65  61 64 65 72 20 63 61 6e  |ogram header can|
00001630  0d 72 65 76 65 63 74 6f  72 20 45 56 45 4e 54 56  |.revector EVENTV|
00001640  20 74 6f 20 70 6f 69 6e  74 20 74 6f 20 61 20 6e  | to point to a n|
00001650  65 77 20 72 6f 75 74 69  6e 65 20 77 69 74 68 69  |ew routine withi|
00001660  6e 20 74 68 65 20 73 61  6d 65 20 72 6f 6d 20 69  |n the same rom i|
00001670  6d 61 67 65 2e 0d 0d 0d  20 20 4c 44 41 20 23 26  |mage....  LDA #&|
00001680  41 38 20 20 20 20 20 20  20 20 20 20 5c 20 4f 73  |A8          \ Os|
00001690  62 79 74 65 20 26 41 38  0d 20 20 4c 44 58 20 23  |byte &A8.  LDX #|
000016a0  26 30 30 0d 20 20 4c 44  59 20 23 26 46 46 0d 20  |&00.  LDY #&FF. |
000016b0  20 4a 53 52 20 26 46 46  46 34 20 20 20 20 20 20  | JSR &FFF4      |
000016c0  20 20 20 5c 20 66 69 6e  64 20 73 74 61 72 74 20  |   \ find start |
000016d0  6f 66 20 45 56 53 0d 20  20 53 54 58 20 26 37 30  |of EVS.  STX &70|
000016e0  20 20 20 20 20 20 20 20  20 20 20 5c 20 73 74 6f  |           \ sto|
000016f0  72 65 20 6c 65 61 73 74  20 73 69 67 2e 20 62 79  |re least sig. by|
00001700  74 65 20 6f 66 20 45 56  53 0d 20 20 53 54 59 20  |te of EVS.  STY |
00001710  26 37 31 20 20 20 20 20  20 20 20 20 20 20 5c 20  |&71           \ |
00001720  73 74 6f 72 65 20 6d 6f  73 74 20 73 69 67 2e 20  |store most sig. |
00001730  62 79 74 65 20 6f 66 20  45 56 53 0d 20 20 4c 44  |byte of EVS.  LD|
00001740  59 20 23 26 33 30 20 20  20 20 20 20 20 20 20 20  |Y #&30          |
00001750  5c 20 6f 66 66 73 65 74  20 6f 6e 20 45 56 53 20  |\ offset on EVS |
00001760  66 6f 72 20 45 56 45 4e  54 56 0d 20 20 4c 44 41  |for EVENTV.  LDA|
00001770  20 23 6e 65 77 20 4d 4f  44 20 32 35 36 20 20 5c  | #new MOD 256  \|
00001780  20 6c 65 61 73 74 20 73  69 67 2e 20 62 79 74 65  | least sig. byte|
00001790  20 6f 66 20 6e 65 77 20  72 6f 75 74 69 6e 65 0d  | of new routine.|
000017a0  20 20 53 54 41 20 28 26  37 30 29 2c 59 20 20 20  |  STA (&70),Y   |
000017b0  20 20 20 20 5c 20 6c 65  61 73 74 20 73 69 67 2e  |    \ least sig.|
000017c0  20 62 79 74 65 20 69 6e  20 45 56 53 0d 20 20 49  | byte in EVS.  I|
000017d0  4e 59 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |NY              |
000017e0  20 5c 20 69 6e 63 72 65  6d 65 6e 74 20 6f 66 66  | \ increment off|
000017f0  73 65 74 20 66 6f 72 20  6d 6f 73 74 20 73 69 67  |set for most sig|
00001800  2e 20 62 79 74 65 0d 20  20 4c 44 41 20 23 6e 65  |. byte.  LDA #ne|
00001810  77 20 44 49 56 20 32 35  36 20 20 5c 20 6d 6f 73  |w DIV 256  \ mos|
00001820  74 20 73 69 67 2e 20 62  79 74 65 20 6f 66 20 6e  |t sig. byte of n|
00001830  65 77 20 72 6f 75 74 69  6e 65 0d 20 20 53 54 41  |ew routine.  STA|
00001840  20 28 26 37 30 29 2c 59  20 20 20 20 20 20 20 5c  | (&70),Y       \|
00001850  20 6d 6f 73 74 20 73 69  67 2e 20 62 79 74 65 20  | most sig. byte |
00001860  69 6e 20 45 56 53 0d 20  20 49 4e 59 20 20 20 20  |in EVS.  INY    |
00001870  20 20 20 20 20 20 20 20  20 20 20 5c 20 69 6e 63  |           \ inc|
00001880  72 65 6d 65 6e 74 20 6f  66 66 73 65 74 20 66 6f  |rement offset fo|
00001890  72 20 72 6f 6d 20 6e 75  6d 62 65 72 0d 20 20 4c  |r rom number.  L|
000018a0  44 41 20 26 46 34 20 20  20 20 20 20 20 20 20 20  |DA &F4          |
000018b0  20 5c 20 66 69 6e 64 20  72 6f 6d 20 6e 75 6d 62  | \ find rom numb|
000018c0  65 72 20 6f 66 20 6e 65  77 20 72 6f 75 74 69 6e  |er of new routin|
000018d0  65 0d 20 20 53 54 41 20  28 26 37 30 29 2c 59 20  |e.  STA (&70),Y |
000018e0  20 20 20 20 20 20 5c 20  73 74 6f 72 65 20 69 6e  |      \ store in|
000018f0  20 45 56 53 0d 20 20 4c  44 58 20 23 26 33 30 20  | EVS.  LDX #&30 |
00001900  20 20 20 20 20 20 20 20  20 5c 20 6c 65 61 73 74  |         \ least|
00001910  20 73 69 67 2e 20 62 79  74 65 20 6f 66 20 45 56  | sig. byte of EV|
00001920  45 50 20 66 6f 72 20 45  56 45 4e 54 56 0d 20 20  |EP for EVENTV.  |
00001930  4c 44 59 20 23 26 46 46  20 20 20 20 20 20 20 20  |LDY #&FF        |
00001940  20 20 5c 20 6d 6f 73 74  20 73 69 67 2e 20 62 79  |  \ most sig. by|
00001950  74 65 20 6f 66 20 45 56  45 50 20 66 6f 72 20 45  |te of EVEP for E|
00001960  56 45 4e 54 56 0d 20 20  53 45 49 20 20 20 20 20  |VENTV.  SEI     |
00001970  20 20 20 20 20 20 20 20  20 20 5c 20 73 65 74 20  |          \ set |
00001980  69 6e 74 65 72 75 70 74  20 64 69 73 61 62 6c 65  |interupt disable|
00001990  20 66 6c 61 67 0d 20 20  53 54 58 20 26 32 32 30  | flag.  STX &220|
000019a0  20 20 20 20 20 20 20 20  20 20 5c 20 73 74 6f 72  |          \ stor|
000019b0  65 20 45 56 45 50 20 69  6e 20 6c 65 61 73 74 20  |e EVEP in least |
000019c0  73 69 67 2e 20 62 79 74  65 20 6f 66 20 45 56 45  |sig. byte of EVE|
000019d0  4e 54 56 0d 20 20 53 54  59 20 26 32 32 31 20 20  |NTV.  STY &221  |
000019e0  20 20 20 20 20 20 20 20  5c 20 73 74 6f 72 65 20  |        \ store |
000019f0  45 56 45 50 20 69 6e 20  6d 6f 73 74 20 73 69 67  |EVEP in most sig|
00001a00  2e 20 62 79 74 65 20 6f  66 20 45 56 45 4e 54 56  |. byte of EVENTV|
00001a10  0d 20 20 43 4c 49 20 20  20 20 20 20 20 20 20 20  |.  CLI          |
00001a20  20 20 20 20 20 5c 20 63  6c 65 61 72 20 69 6e 74  |     \ clear int|
00001a30  65 72 75 70 74 20 64 69  73 61 62 6c 65 20 66 6c  |erupt disable fl|
00001a40  61 67 0d 0d 46 69 67 75  72 65 20 32 20 20 52 65  |ag..Figure 2  Re|
00001a50  76 65 63 74 6f 72 69 6e  67 20 74 68 65 20 65 76  |vectoring the ev|
00001a60  65 6e 74 20 76 65 63 74  6f 72 0d 2d 2d 2d 2d 2d  |ent vector.-----|
00001a70  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00001a90  2d 2d 0d 0d 0d 54 68 69  73 20 74 65 63 68 6e 69  |--...This techni|
00001aa0  71 75 65 20 68 61 73 20  62 65 65 6e 20 75 73 65  |que has been use|
00001ab0  64 20 69 6e 20 74 68 65  20 64 65 6d 6f 6e 73 74  |d in the demonst|
00001ac0  72 61 74 69 6f 6e 20 70  72 6f 67 72 61 6d 20 53  |ration program S|
00001ad0  57 4d 4f 55 53 45 20 74  6f 0d 72 65 76 65 63 74  |WMOUSE to.revect|
00001ae0  6f 72 20 74 68 65 20 4f  73 62 79 74 65 20 69 6e  |or the Osbyte in|
00001af0  64 69 72 65 63 74 69 6f  6e 20 76 65 63 74 6f 72  |direction vector|
00001b00  20 69 6e 74 6f 20 74 68  65 20 53 57 52 20 73 6f  | into the SWR so|
00001b10  63 6b 65 74 20 77 68 69  63 68 20 73 74 6f 72 65  |cket which store|
00001b20  73 0d 74 68 65 20 6f 62  6a 65 63 74 20 63 6f 64  |s.the object cod|
00001b30  65 20 70 72 6f 64 75 63  65 64 20 62 79 20 74 68  |e produced by th|
00001b40  65 20 70 72 6f 67 72 61  6d 2e 20 54 68 65 20 6f  |e program. The o|
00001b50  62 6a 65 63 74 20 63 6f  64 65 20 66 69 6c 65 20  |bject code file |
00001b60  67 65 6e 65 72 61 74 65  64 20 62 79 0d 74 68 65  |generated by.the|
00001b70  20 70 72 6f 67 72 61 6d  20 6e 65 65 64 73 20 74  | program needs t|
00001b80  6f 20 62 65 20 6c 6f 61  64 65 64 20 69 6e 74 6f  |o be loaded into|
00001b90  20 75 6e 70 72 6f 74 65  63 74 65 64 20 53 69 64  | unprotected Sid|
00001ba0  65 77 61 79 73 20 52 41  4d 20 61 6e 64 2c 20 65  |eways RAM and, e|
00001bb0  76 65 72 79 0d 74 69 6d  65 20 74 68 65 20 42 72  |very.time the Br|
00001bc0  65 61 6b 20 6b 65 79 20  69 73 20 70 72 65 73 73  |eak key is press|
00001bd0  65 64 2c 20 73 65 72 76  69 63 65 20 63 61 6c 6c  |ed, service call|
00001be0  20 26 46 45 20 69 73 20  74 72 61 70 70 65 64 20  | &FE is trapped |
00001bf0  74 6f 20 69 6e 69 74 69  61 6c 69 73 65 0d 74 68  |to initialise.th|
00001c00  65 20 55 73 65 72 20 50  6f 72 74 20 66 6f 72 20  |e User Port for |
00001c10  75 73 65 20 77 69 74 68  20 61 20 6d 6f 75 73 65  |use with a mouse|
00001c20  2e 20 41 74 20 74 68 65  20 73 61 6d 65 20 74 69  |. At the same ti|
00001c30  6d 65 20 74 68 65 20 4f  73 62 79 74 65 0d 69 6e  |me the Osbyte.in|
00001c40  64 69 72 65 63 74 69 6f  6e 20 76 65 63 74 6f 72  |direction vector|
00001c50  20 77 69 6c 6c 20 62 65  20 61 6c 74 65 72 65 64  | will be altered|
00001c60  20 74 6f 20 70 6f 69 6e  74 20 74 6f 20 74 68 65  | to point to the|
00001c70  20 63 6f 64 65 20 6c 61  62 65 6c 65 64 20 61 6e  | code labeled an|
00001c80  61 6c 6f 67 75 65 2e 0d  0d 54 68 65 20 63 6f 64  |alogue...The cod|
00001c90  65 20 61 74 20 61 6e 61  6c 6f 67 75 65 20 6f 70  |e at analogue op|
00001ca0  65 72 61 74 65 73 20 69  6e 20 74 68 65 20 73 61  |erates in the sa|
00001cb0  6d 65 20 77 61 79 20 61  73 20 74 68 65 20 64 65  |me way as the de|
00001cc0  6d 6f 6e 73 74 72 61 74  69 6f 6e 20 70 72 6f 67  |monstration prog|
00001cd0  72 61 6d 0d 69 6e 20 6d  6f 64 75 6c 65 20 35 20  |ram.in module 5 |
00001ce0  65 78 63 65 70 74 20 74  68 61 74 20 69 74 20 75  |except that it u|
00001cf0  73 65 73 20 52 41 4d 20  77 6f 72 6b 73 70 61 63  |ses RAM workspac|
00001d00  65 20 69 6e 20 53 57 52  2e 20 42 65 63 61 75 73  |e in SWR. Becaus|
00001d10  65 20 74 68 65 0d 77 6f  72 6b 73 70 61 63 65 20  |e the.workspace |
00001d20  69 73 20 69 6e 20 74 68  65 20 73 61 6d 65 20 53  |is in the same S|
00001d30  57 52 20 62 61 6e 6b 20  61 73 20 74 68 65 20 70  |WR bank as the p|
00001d40  72 6f 67 72 61 6d 2c 20  74 68 65 20 70 72 6f 67  |rogram, the prog|
00001d50  72 61 6d 20 63 61 6e 20  6e 6f 74 20 62 65 0d 75  |ram can not be.u|
00001d60  73 65 64 20 66 72 6f 6d  20 61 6e 20 45 50 52 4f  |sed from an EPRO|
00001d70  4d 20 77 69 74 68 6f 75  74 20 6d 6f 64 69 66 69  |M without modifi|
00001d80  63 61 74 69 6f 6e 2e 20  49 66 20 79 6f 75 20 77  |cation. If you w|
00001d90  61 6e 74 20 74 6f 20 75  73 65 20 74 68 65 20 70  |ant to use the p|
00001da0  72 6f 67 72 61 6d 0d 66  72 6f 6d 20 61 6e 20 45  |rogram.from an E|
00001db0  50 52 4f 4d 2c 20 6f 72  20 66 72 6f 6d 20 77 72  |PROM, or from wr|
00001dc0  69 74 65 20 70 72 6f 74  65 63 74 65 64 20 53 57  |ite protected SW|
00001dd0  52 2c 20 74 68 65 6e 20  79 6f 75 20 77 69 6c 6c  |R, then you will|
00001de0  20 68 61 76 65 20 74 6f  20 6d 6f 76 65 20 74 68  | have to move th|
00001df0  65 0d 52 41 4d 20 77 6f  72 6b 73 70 61 63 65 20  |e.RAM workspace |
00001e00  69 6e 74 6f 20 75 73 65  72 20 6d 65 6d 6f 72 79  |into user memory|
00001e10  2e 0d 0d 4c 6f 61 64 20  74 68 65 20 6f 62 6a 65  |...Load the obje|
00001e20  63 74 20 63 6f 64 65 20  66 69 6c 65 20 53 57 52  |ct code file SWR|
00001e30  4d 49 43 45 20 69 6e 74  6f 20 61 20 68 69 67 68  |MICE into a high|
00001e40  20 70 72 69 6f 72 69 74  79 20 53 57 52 20 73 6f  | priority SWR so|
00001e50  63 6b 65 74 0d 28 70 72  65 66 65 72 61 62 6c 79  |cket.(preferably|
00001e60  20 73 6f 63 6b 65 74 20  26 30 46 29 20 61 6e 64  | socket &0F) and|
00001e70  20 70 72 65 73 73 20 74  68 65 20 42 72 65 61 6b  | press the Break|
00001e80  20 6b 65 79 2e 20 54 68  65 20 41 44 56 41 4c 28  | key. The ADVAL(|
00001e90  30 2d 34 29 20 63 6f 6d  6d 61 6e 64 73 0d 77 69  |0-4) commands.wi|
00001ea0  6c 6c 20 74 68 65 6e 20  72 65 61 64 20 74 68 65  |ll then read the|
00001eb0  20 6d 6f 75 73 65 20 63  6f 6f 72 64 69 6e 61 74  | mouse coordinat|
00001ec0  65 73 20 61 6e 64 20 62  75 74 74 6f 6e 73 20 61  |es and buttons a|
00001ed0  73 20 69 66 20 74 68 65  79 20 77 65 72 65 20 61  |s if they were a|
00001ee0  6e 0d 61 6e 61 6c 6f 67  75 65 20 6a 6f 79 73 74  |n.analogue joyst|
00001ef0  69 63 6b 2e 20 59 6f 75  20 63 61 6e 20 64 65 6d  |ick. You can dem|
00001f00  6f 6e 73 74 72 61 74 65  20 74 68 61 74 20 69 74  |onstrate that it|
00001f10  20 77 6f 72 6b 73 20 65  66 66 65 63 74 69 76 6c  | works effectivl|
00001f20  79 20 77 69 74 68 20 74  68 65 0d 70 72 6f 67 72  |y with the.progr|
00001f30  61 6d 20 53 57 54 45 53  54 2e 0d 0d 49 66 20 79  |am SWTEST...If y|
00001f40  6f 75 20 77 61 6e 74 20  74 6f 20 75 73 65 20 74  |ou want to use t|
00001f50  68 65 20 70 72 6f 67 72  61 6d 20 53 57 52 4d 49  |he program SWRMI|
00001f60  43 45 20 77 69 74 68 20  73 6f 6d 65 20 63 6f 6d  |CE with some com|
00001f70  6d 65 72 63 69 61 6c 6c  79 20 70 72 6f 64 75 63  |mercially produc|
00001f80  65 64 0d 67 61 6d 65 73  20 79 6f 75 20 77 69 6c  |ed.games you wil|
00001f90  6c 20 70 72 6f 62 61 62  6c 79 20 66 69 6e 64 20  |l probably find |
00001fa0  74 68 61 74 20 74 68 65  72 65 20 61 72 65 20 70  |that there are p|
00001fb0  72 6f 62 6c 65 6d 73 20  63 61 75 73 65 64 20 62  |roblems caused b|
00001fc0  79 20 73 6f 6d 65 20 6f  66 20 74 68 65 0d 27 69  |y some of the.'i|
00001fd0  6c 6c 65 67 61 6c 27 20  74 65 63 68 6e 69 71 75  |llegal' techniqu|
00001fe0  65 73 20 75 73 65 64 20  62 79 20 67 61 6d 65 73  |es used by games|
00001ff0  20 70 72 6f 67 72 61 6d  6d 65 72 73 20 74 6f 20  | programmers to |
00002000  70 72 6f 74 65 63 74 20  74 68 65 69 72 20 73 6f  |protect their so|
00002010  66 74 77 61 72 65 2e 0d  54 68 65 20 6d 6f 73 74  |ftware..The most|
00002020  20 6c 69 6b 65 6c 79 20  73 6f 75 72 63 65 20 6f  | likely source o|
00002030  66 20 74 72 6f 75 62 6c  65 20 77 69 6c 6c 20 62  |f trouble will b|
00002040  65 20 74 68 61 74 20 6d  61 6e 79 20 70 72 6f 67  |e that many prog|
00002050  72 61 6d 6d 65 72 73 20  6f 76 65 72 77 72 69 74  |rammers overwrit|
00002060  65 0d 61 6c 6c 20 74 68  65 20 4d 4f 53 20 76 65  |e.all the MOS ve|
00002070  63 74 6f 72 73 20 62 79  20 69 6e 64 69 72 65 63  |ctors by indirec|
00002080  74 6c 79 20 6c 6f 61 64  69 6e 67 20 63 6f 6d 70  |tly loading comp|
00002090  6c 65 74 65 6c 79 20 6e  65 77 20 70 61 67 65 73  |letely new pages|
000020a0  20 26 30 32 20 61 6e 64  0d 26 30 44 2e 20 54 68  | &02 and.&0D. Th|
000020b0  69 73 20 69 73 20 75 73  75 61 6c 6c 79 20 64 6f  |is is usually do|
000020c0  6e 65 20 74 6f 20 73 74  6f 70 20 79 6f 75 20 63  |ne to stop you c|
000020d0  6f 70 79 69 6e 67 20 74  68 65 20 67 61 6d 65 20  |opying the game |
000020e0  62 79 20 69 6e 74 65 72  72 75 70 74 69 6e 67 20  |by interrupting |
000020f0  61 6e 64 0d 73 61 76 69  6e 67 20 69 74 20 62 75  |and.saving it bu|
00002100  74 20 69 74 20 64 6f 65  73 20 68 61 76 65 20 74  |t it does have t|
00002110  68 65 20 73 69 64 65 20  65 66 66 65 63 74 20 6f  |he side effect o|
00002120  66 20 70 72 65 76 65 6e  74 69 6e 67 20 79 6f 75  |f preventing you|
00002130  20 75 73 69 6e 67 20 61  20 6d 6f 75 73 65 0d 61  | using a mouse.a|
00002140  73 20 61 20 73 75 62 73  74 69 74 75 74 65 20 66  |s a substitute f|
00002150  6f 72 20 74 68 65 20 6a  6f 79 73 74 69 63 6b 73  |or the joysticks|
00002160  2e 20 57 68 65 6e 20 79  6f 75 20 6b 6e 6f 77 20  |. When you know |
00002170  77 68 61 74 20 74 6f 20  6c 6f 6f 6b 20 66 6f 72  |what to look for|
00002180  20 69 74 20 69 73 0d 6e  6f 74 20 74 6f 6f 20 64  | it is.not too d|
00002190  69 66 66 69 63 75 6c 74  20 74 6f 20 6f 76 65 72  |ifficult to over|
000021a0  63 6f 6d 65 20 74 68 69  73 20 73 6f 72 74 20 6f  |come this sort o|
000021b0  66 20 70 72 6f 62 6c 65  6d 20 69 66 20 79 6f 75  |f problem if you|
000021c0  20 74 68 69 6e 6b 20 69  74 20 69 73 0d 77 6f 72  | think it is.wor|
000021d0  74 68 20 61 6c 6c 20 74  68 65 20 74 72 6f 75 62  |th all the troub|
000021e0  6c 65 2e 0d 0d 0d 20 20  20 31 30 20 52 45 4d 3e  |le....   10 REM>|
000021f0  20 53 57 4d 4f 55 53 45  0d 20 20 20 32 30 20 44  | SWMOUSE.   20 D|
00002200  49 4d 20 6d 63 6f 64 65  20 26 32 30 30 0d 20 20  |IM mcode &200.  |
00002210  20 33 30 20 61 64 64 72  65 73 73 3d 26 41 38 20  | 30 address=&A8 |
00002220  3a 52 45 4d 3a 20 7a 65  72 6f 20 70 61 67 65 20  |:REM: zero page |
00002230  77 6f 72 6b 73 70 61 63  65 0d 20 20 20 34 30 20  |workspace.   40 |
00002240  72 6f 6d 6e 75 6d 62 65  72 3d 26 46 34 20 3a 52  |romnumber=&F4 :R|
00002250  45 4d 3a 20 63 75 72 72  65 6e 74 6c 79 20 73 65  |EM: currently se|
00002260  6c 65 63 74 65 64 20 52  4f 4d 0d 20 20 20 35 30  |lected ROM.   50|
00002270  20 73 61 76 65 72 65 67  3d 26 46 43 20 3a 52 45  | savereg=&FC :RE|
00002280  4d 3a 20 69 6e 74 65 72  72 75 70 74 20 61 63 63  |M: interrupt acc|
00002290  75 6d 75 6c 61 74 6f 72  20 73 61 76 65 20 72 65  |umulator save re|
000022a0  67 69 73 74 65 72 0d 20  20 20 36 30 20 62 79 74  |gister.   60 byt|
000022b0  65 76 3d 26 32 30 41 20  3a 52 45 4d 3a 20 4f 73  |ev=&20A :REM: Os|
000022c0  62 79 74 65 20 69 6e 64  69 72 65 63 74 69 6f 6e  |byte indirection|
000022d0  20 76 65 63 74 6f 72 0d  20 20 20 37 30 20 64 72  | vector.   70 dr|
000022e0  62 3d 26 46 45 36 30 20  3a 52 45 4d 3a 20 64 61  |b=&FE60 :REM: da|
000022f0  74 61 20 72 65 67 69 73  74 65 72 20 42 0d 20 20  |ta register B.  |
00002300  20 38 30 20 64 64 72 62  3d 26 46 45 36 32 20 3a  | 80 ddrb=&FE62 :|
00002310  52 45 4d 3a 20 64 61 74  61 20 64 69 72 65 63 74  |REM: data direct|
00002320  69 6f 6e 20 72 65 67 69  73 74 65 72 20 42 0d 20  |ion register B. |
00002330  20 20 39 30 20 70 63 72  3d 26 46 45 36 43 20 3a  |  90 pcr=&FE6C :|
00002340  52 45 4d 3a 20 70 65 72  69 70 68 65 72 61 6c 20  |REM: peripheral |
00002350  63 6f 6e 74 72 6f 6c 20  72 65 67 69 73 74 65 72  |control register|
00002360  0d 20 20 31 30 30 20 69  66 72 3d 26 46 45 36 44  |.  100 ifr=&FE6D|
00002370  20 3a 52 45 4d 3a 20 69  6e 74 65 72 72 75 70 74  | :REM: interrupt|
00002380  20 66 6c 61 67 20 72 65  67 69 73 74 65 72 0d 20  | flag register. |
00002390  20 31 31 30 20 69 65 72  3d 26 46 45 36 45 20 3a  | 110 ier=&FE6E :|
000023a0  52 45 4d 3a 20 69 6e 74  65 72 72 75 70 74 20 65  |REM: interrupt e|
000023b0  6e 61 62 6c 65 20 72 65  67 69 73 74 65 72 0d 20  |nable register. |
000023c0  20 31 32 30 20 6f 73 62  79 74 65 3d 26 46 46 46  | 120 osbyte=&FFF|
000023d0  34 0d 20 20 31 33 30 20  46 4f 52 20 70 61 73 73  |4.  130 FOR pass|
000023e0  3d 34 20 54 4f 20 36 20  53 54 45 50 20 32 0d 20  |=4 TO 6 STEP 2. |
000023f0  20 31 34 30 20 4f 25 3d  6d 63 6f 64 65 0d 20 20  | 140 O%=mcode.  |
00002400  31 35 30 20 50 25 3d 26  38 30 30 30 0d 20 20 31  |150 P%=&8000.  1|
00002410  36 30 20 5b 20 20 20 20  20 20 20 4f 50 54 20 70  |60 [       OPT p|
00002420  61 73 73 0d 20 20 31 37  30 20 20 20 20 20 20 20  |ass.  170       |
00002430  20 20 42 52 4b 0d 20 20  31 38 30 20 20 20 20 20  |  BRK.  180     |
00002440  20 20 20 20 42 52 4b 0d  20 20 31 39 30 20 20 20  |    BRK.  190   |
00002450  20 20 20 20 20 20 42 52  4b 0d 20 20 32 30 30 20  |      BRK.  200 |
00002460  20 20 20 20 20 20 20 20  4a 4d 50 20 73 65 72 76  |        JMP serv|
00002470  69 63 65 20 20 20 5c 20  73 65 72 76 69 63 65 20  |ice   \ service |
00002480  65 6e 74 72 79 20 74 6f  20 52 4f 4d 0d 20 20 32  |entry to ROM.  2|
00002490  31 30 20 20 20 20 20 20  20 20 20 45 51 55 42 20  |10         EQUB |
000024a0  26 38 32 20 20 20 20 20  20 5c 20 52 4f 4d 20 74  |&82      \ ROM t|
000024b0  79 70 65 20 62 79 74 65  20 69 6e 64 69 63 61 74  |ype byte indicat|
000024c0  65 73 20 61 20 73 65 72  76 69 63 65 20 65 6e 74  |es a service ent|
000024d0  72 79 0d 20 20 32 32 30  20 20 20 20 20 20 20 20  |ry.  220        |
000024e0  20 45 51 55 42 20 63 6f  70 79 72 69 67 68 74 20  | EQUB copyright |
000024f0  4d 4f 44 20 32 35 36 20  5c 20 63 6f 70 79 72 69  |MOD 256 \ copyri|
00002500  67 68 74 20 6f 66 66 73  65 74 20 70 6f 69 6e 74  |ght offset point|
00002510  65 72 0d 20 20 32 33 30  20 20 20 20 20 20 20 20  |er.  230        |
00002520  20 42 52 4b 20 20 20 20  20 20 20 20 20 20 20 5c  | BRK           \|
00002530  20 62 69 6e 61 72 79 20  76 65 72 73 69 6f 6e 20  | binary version |
00002540  6e 75 6d 62 65 72 0d 20  20 32 34 30 20 20 20 20  |number.  240    |
00002550  20 20 20 20 20 45 51 55  53 20 22 41 6e 61 6c 6f  |     EQUS "Analo|
00002560  67 75 65 20 6d 6f 75 73  65 22 20 5c 20 74 69 74  |gue mouse" \ tit|
00002570  6c 65 20 73 74 72 69 6e  67 0d 20 20 32 35 30 20  |le string.  250 |
00002580  2e 63 6f 70 79 72 69 67  68 74 0d 20 20 32 36 30  |.copyright.  260|
00002590  20 20 20 20 20 20 20 20  20 42 52 4b 0d 20 20 32  |         BRK.  2|
000025a0  37 30 20 20 20 20 20 20  20 20 20 45 51 55 53 20  |70         EQUS |
000025b0  22 28 43 29 20 47 6f 72  64 6f 6e 20 48 6f 72 73  |"(C) Gordon Hors|
000025c0  69 6e 67 74 6f 6e 20 31  39 38 37 22 20 5c 20 63  |ington 1987" \ c|
000025d0  6f 70 79 72 69 67 68 74  20 73 74 72 69 6e 67 0d  |opyright string.|
000025e0  20 20 32 38 30 20 20 20  20 20 20 20 20 20 42 52  |  280         BR|
000025f0  4b 20 20 20 20 20 20 20  20 20 20 20 5c 20 63 6f  |K           \ co|
00002600  70 79 72 69 67 68 74 20  74 65 72 6d 69 6e 61 74  |pyright terminat|
00002610  6f 72 0d 20 20 32 39 30  20 2e 73 65 72 76 69 63  |or.  290 .servic|
00002620  65 0d 20 20 33 30 30 20  20 20 20 20 20 20 20 20  |e.  300         |
00002630  43 4d 50 20 23 26 30 35  20 20 20 20 20 20 5c 20  |CMP #&05      \ |
00002640  69 73 20 74 68 69 73 20  61 6e 20 75 6e 72 65 63  |is this an unrec|
00002650  6f 67 6e 69 73 65 64 20  69 6e 74 65 72 72 75 70  |ognised interrup|
00002660  74 3f 0d 20 20 33 31 30  20 20 20 20 20 20 20 20  |t?.  310        |
00002670  20 42 45 51 20 69 6e 74  65 72 72 75 70 74 20 5c  | BEQ interrupt \|
00002680  20 69 66 20 69 74 20 69  73 20 62 72 61 6e 63 68  | if it is branch|
00002690  20 74 6f 20 69 6e 74 65  72 72 75 70 74 20 72 6f  | to interrupt ro|
000026a0  75 74 69 6e 65 0d 20 20  33 32 30 20 20 20 20 20  |utine.  320     |
000026b0  20 20 20 20 43 4d 50 20  23 26 46 45 20 20 20 20  |    CMP #&FE    |
000026c0  20 20 5c 20 69 73 20 74  68 69 73 20 61 20 54 75  |  \ is this a Tu|
000026d0  62 65 20 70 6f 73 74 20  69 6e 69 74 3f 0d 20 20  |be post init?.  |
000026e0  33 33 30 20 20 20 20 20  20 20 20 20 42 4e 45 20  |330         BNE |
000026f0  72 65 74 75 72 6e 20 20  20 20 5c 20 69 66 20 6e  |return    \ if n|
00002700  6f 74 20 74 68 65 6e 20  72 65 74 75 72 6e 20 74  |ot then return t|
00002710  6f 20 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |o operating syst|
00002720  65 6d 2e 0d 20 20 33 34  30 20 20 20 20 20 20 20  |em..  340       |
00002730  20 20 50 48 41 20 20 20  20 20 20 20 20 20 20 20  |  PHA           |
00002740  5c 20 70 75 73 68 20 72  65 67 69 73 74 65 72 73  |\ push registers|
00002750  2e 20 54 68 69 73 20 69  73 20 61 20 54 75 62 65  |. This is a Tube|
00002760  20 70 6f 73 74 20 69 6e  69 74 0d 20 20 33 35 30  | post init.  350|
00002770  20 20 20 20 20 20 20 20  20 54 58 41 20 20 20 20  |         TXA    |
00002780  20 20 20 20 20 20 20 5c  20 61 6e 64 20 74 68 65  |       \ and the|
00002790  20 72 65 67 69 73 74 65  72 73 20 6d 75 73 74 20  | registers must |
000027a0  62 65 20 75 6e 61 6c 74  65 72 65 64 20 77 68 65  |be unaltered whe|
000027b0  6e 20 74 68 69 73 0d 20  20 33 36 30 20 20 20 20  |n this.  360    |
000027c0  20 20 20 20 20 50 48 41  20 20 20 20 20 20 20 20  |     PHA        |
000027d0  20 20 20 5c 20 73 65 72  76 69 63 65 20 74 79 70  |   \ service typ|
000027e0  65 20 69 73 20 75 73 65  64 20 66 6f 72 20 69 6c  |e is used for il|
000027f0  6c 65 67 61 6c 20 70 75  72 70 6f 73 65 73 0d 20  |legal purposes. |
00002800  20 33 37 30 20 20 20 20  20 20 20 20 20 54 59 41  | 370         TYA|
00002810  20 20 20 20 20 20 20 20  20 20 20 5c 20 73 75 63  |           \ suc|
00002820  68 20 61 73 20 69 6e 69  74 69 61 6c 69 73 69 6e  |h as initialisin|
00002830  67 20 74 68 65 20 75 73  65 72 20 70 6f 72 74 20  |g the user port |
00002840  77 68 65 6e 0d 20 20 33  38 30 20 20 20 20 20 20  |when.  380      |
00002850  20 20 20 50 48 41 20 20  20 20 20 20 20 20 20 20  |   PHA          |
00002860  20 5c 20 74 68 65 20 42  72 65 61 6b 20 6b 65 79  | \ the Break key|
00002870  20 69 73 20 70 72 65 73  73 65 64 2e 0d 20 20 33  | is pressed..  3|
00002880  39 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |90         LDA #|
00002890  26 39 38 20 20 20 20 20  20 5c 20 25 31 30 30 31  |&98      \ %1001|
000028a0  31 30 30 30 2c 20 69 65  2e 20 65 6e 61 62 6c 65  |1000, ie. enable|
000028b0  20 43 42 31 2f 32 0d 20  20 34 30 30 20 20 20 20  | CB1/2.  400    |
000028c0  20 20 20 20 20 53 54 41  20 69 65 72 20 20 20 20  |     STA ier    |
000028d0  20 20 20 5c 20 69 6e 74  65 72 72 75 70 74 20 65  |   \ interrupt e|
000028e0  6e 61 62 6c 65 20 72 65  67 69 73 74 65 72 0d 20  |nable register. |
000028f0  20 34 31 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 410         LDA|
00002900  20 70 63 72 20 20 20 20  20 20 20 5c 20 70 65 72  | pcr       \ per|
00002910  69 70 68 65 72 61 6c 20  63 6f 6e 74 72 6f 6c 20  |ipheral control |
00002920  72 65 67 69 73 74 65 72  0d 20 20 34 32 30 20 20  |register.  420  |
00002930  20 20 20 20 20 20 20 41  4e 44 20 23 26 30 46 20  |       AND #&0F |
00002940  20 20 20 20 20 5c 20 41  4e 44 20 77 69 74 68 20  |     \ AND with |
00002950  25 30 30 30 30 31 31 31  31 2c 20 69 65 20 63 6c  |%00001111, ie cl|
00002960  65 61 72 20 62 69 74 73  20 34 2d 37 0d 20 20 34  |ear bits 4-7.  4|
00002970  33 30 20 20 20 20 20 20  20 20 20 4f 52 41 20 23  |30         ORA #|
00002980  26 35 30 20 20 20 20 20  20 5c 20 4f 52 20 77 69  |&50      \ OR wi|
00002990  74 68 20 25 30 31 30 31  30 30 30 30 2c 20 69 65  |th %01010000, ie|
000029a0  2e 20 73 65 74 20 62 69  74 73 20 34 20 61 6e 64  |. set bits 4 and|
000029b0  20 36 0d 20 20 34 34 30  20 20 20 20 20 20 20 20  | 6.  440        |
000029c0  20 53 54 41 20 70 63 72  20 20 20 20 20 20 20 5c  | STA pcr       \|
000029d0  20 69 6e 74 65 72 72 75  70 74 20 6f 6e 20 2b 76  | interrupt on +v|
000029e0  65 20 74 72 61 6e 73 69  74 69 6f 6e 2c 20 43 42  |e transition, CB|
000029f0  32 20 69 6e 70 75 74 2c  0d 20 20 20 20 20 20 20  |2 input,.       |
00002a00  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002a10  20 20 20 20 20 5c 20 44  52 42 20 74 6f 20 63 6c  |     \ DRB to cl|
00002a20  65 61 72 0d 20 20 34 35  30 20 20 20 20 20 20 20  |ear.  450       |
00002a30  20 20 4c 44 41 20 23 26  30 30 20 20 20 20 20 20  |  LDA #&00      |
00002a40  5c 20 75 73 65 72 20 70  6f 72 74 20 69 6e 70 75  |\ user port inpu|
00002a50  74 0d 20 20 34 36 30 20  20 20 20 20 20 20 20 20  |t.  460         |
00002a60  53 54 41 20 64 64 72 62  20 20 20 20 20 20 5c 20  |STA ddrb      \ |
00002a70  64 61 74 61 20 64 69 72  65 63 74 69 6f 6e 20 72  |data direction r|
00002a80  65 67 69 73 74 65 72 20  42 0d 20 20 34 37 30 20  |egister B.  470 |
00002a90  20 20 20 20 20 20 20 20  4c 44 41 20 23 26 31 30  |        LDA #&10|
00002aa0  20 20 20 20 20 20 5c 20  41 44 43 20 63 68 61 6e  |      \ ADC chan|
00002ab0  6e 65 6c 20 73 65 6c 65  63 74 0d 20 20 34 38 30  |nel select.  480|
00002ac0  20 20 20 20 20 20 20 20  20 4c 44 58 20 23 26 30  |         LDX #&0|
00002ad0  30 20 20 20 20 20 20 5c  20 73 61 6d 70 6c 69 6e  |0      \ samplin|
00002ae0  67 20 64 69 73 61 62 6c  65 64 0d 20 20 34 39 30  |g disabled.  490|
00002af0  20 20 20 20 20 20 20 20  20 4a 53 52 20 6f 73 62  |         JSR osb|
00002b00  79 74 65 0d 20 20 35 30  30 20 20 20 20 20 20 20  |yte.  500       |
00002b10  20 20 4c 44 58 20 62 79  74 65 76 20 20 20 20 20  |  LDX bytev     |
00002b20  5c 20 4f 73 62 79 74 65  20 69 6e 64 69 72 65 63  |\ Osbyte indirec|
00002b30  74 69 6f 6e 20 76 65 63  74 6f 72 2c 20 6c 6f 77  |tion vector, low|
00002b40  20 62 79 74 65 0d 20 20  35 31 30 20 20 20 20 20  | byte.  510     |
00002b50  20 20 20 20 4c 44 59 20  62 79 74 65 76 2b 31 20  |    LDY bytev+1 |
00002b60  20 20 5c 20 4f 73 62 79  74 65 20 69 6e 64 69 72  |  \ Osbyte indir|
00002b70  65 63 74 69 6f 6e 20 76  65 63 74 6f 72 2c 20 68  |ection vector, h|
00002b80  69 67 68 20 62 79 74 65  0d 20 20 35 32 30 20 20  |igh byte.  520  |
00002b90  20 20 20 20 20 20 20 53  54 58 20 6f 6c 64 62 79  |       STX oldby|
00002ba0  74 65 76 20 20 5c 20 73  74 6f 72 65 20 74 68 65  |tev  \ store the|
00002bb0  20 6f 72 69 67 69 6e 61  6c 20 76 65 63 74 6f 72  | original vector|
00002bc0  2c 20 6c 6f 77 20 62 79  74 65 0d 20 20 35 33 30  |, low byte.  530|
00002bd0  20 20 20 20 20 20 20 20  20 53 54 59 20 6f 6c 64  |         STY old|
00002be0  62 79 74 65 76 2b 31 20  5c 20 73 74 6f 72 65 20  |bytev+1 \ store |
00002bf0  74 68 65 20 6f 72 69 67  69 6e 61 6c 20 76 65 63  |the original vec|
00002c00  74 6f 72 2c 20 68 69 67  68 20 62 79 74 65 0d 20  |tor, high byte. |
00002c10  20 35 34 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 540         LDA|
00002c20  20 23 26 41 38 20 20 20  20 20 20 5c 20 72 65 61  | #&A8      \ rea|
00002c30  64 20 61 64 64 72 65 73  73 20 6f 66 20 52 4f 4d  |d address of ROM|
00002c40  20 70 6f 69 6e 74 65 72  20 74 61 62 6c 65 0d 20  | pointer table. |
00002c50  20 35 35 30 20 20 20 20  20 20 20 20 20 4c 44 58  | 550         LDX|
00002c60  20 23 26 30 30 20 20 20  20 20 20 5c 20 74 6f 20  | #&00      \ to |
00002c70  72 65 61 64 20 58 20 3d  20 26 30 30 0d 20 20 35  |read X = &00.  5|
00002c80  36 30 20 20 20 20 20 20  20 20 20 4c 44 59 20 23  |60         LDY #|
00002c90  26 46 46 20 20 20 20 20  20 5c 20 74 6f 20 72 65  |&FF      \ to re|
00002ca0  61 64 20 59 20 3d 20 26  46 46 0d 20 20 35 37 30  |ad Y = &FF.  570|
00002cb0  20 20 20 20 20 20 20 20  20 4a 53 52 20 6f 73 62  |         JSR osb|
00002cc0  79 74 65 0d 20 20 35 38  30 20 20 20 20 20 20 20  |yte.  580       |
00002cd0  20 20 53 54 58 20 61 64  64 72 65 73 73 20 20 20  |  STX address   |
00002ce0  5c 20 73 74 6f 72 65 20  69 6e 20 7a 65 72 6f 20  |\ store in zero |
00002cf0  70 61 67 65 20 66 6f 72  20 69 6e 64 69 72 65 63  |page for indirec|
00002d00  74 20 61 64 64 72 65 73  73 69 6e 67 0d 20 20 35  |t addressing.  5|
00002d10  39 30 20 20 20 20 20 20  20 20 20 53 54 59 20 61  |90         STY a|
00002d20  64 64 72 65 73 73 2b 31  0d 20 20 36 30 30 20 20  |ddress+1.  600  |
00002d30  20 20 20 20 20 20 20 4c  44 59 20 23 26 30 46 20  |       LDY #&0F |
00002d40  20 20 20 20 20 5c 20 6f  66 66 73 65 74 20 74 6f  |     \ offset to|
00002d50  20 65 78 74 65 6e 74 65  64 20 4f 73 62 79 74 65  | extented Osbyte|
00002d60  20 76 65 63 74 6f 72 2c  20 6c 6f 77 20 62 79 74  | vector, low byt|
00002d70  65 0d 20 20 36 31 30 20  20 20 20 20 20 20 20 20  |e.  610         |
00002d80  4c 44 41 20 23 61 6e 61  6c 6f 67 75 65 20 4d 4f  |LDA #analogue MO|
00002d90  44 20 32 35 36 20 5c 20  61 64 64 72 65 73 73 20  |D 256 \ address |
00002da0  6f 66 20 6e 65 77 20 4f  73 62 79 74 65 20 72 6f  |of new Osbyte ro|
00002db0  75 74 69 6e 65 2c 0d 20  20 20 20 20 20 20 20 20  |utine,.         |
00002dc0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002dd0  20 20 20 5c 20 6c 6f 77  20 62 79 74 65 0d 20 20  |   \ low byte.  |
00002de0  36 32 30 20 20 20 20 20  20 20 20 20 53 54 41 20  |620         STA |
00002df0  28 61 64 64 72 65 73 73  29 2c 59 20 5c 20 73 74  |(address),Y \ st|
00002e00  6f 72 65 20 69 6e 20 65  78 74 65 6e 64 65 64 20  |ore in extended |
00002e10  76 65 63 74 6f 72 0d 20  20 36 33 30 20 20 20 20  |vector.  630    |
00002e20  20 20 20 20 20 49 4e 59  20 20 20 20 20 20 20 20  |     INY        |
00002e30  20 20 20 5c 20 6f 66 66  73 65 74 20 74 6f 20 65  |   \ offset to e|
00002e40  78 74 65 6e 64 65 64 20  4f 73 62 79 74 65 20 76  |xtended Osbyte v|
00002e50  65 63 74 6f 72 2c 20 68  69 67 68 20 62 79 74 65  |ector, high byte|
00002e60  0d 20 20 36 34 30 20 20  20 20 20 20 20 20 20 4c  |.  640         L|
00002e70  44 41 20 23 61 6e 61 6c  6f 67 75 65 20 44 49 56  |DA #analogue DIV|
00002e80  20 32 35 36 20 5c 20 61  64 64 72 65 73 73 20 6f  | 256 \ address o|
00002e90  66 20 6e 65 77 20 4f 73  62 79 74 65 20 72 6f 75  |f new Osbyte rou|
00002ea0  74 69 6e 65 2c 0d 20 20  20 20 20 20 20 20 20 20  |tine,.          |
00002eb0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002ec0  20 20 5c 20 68 69 67 68  20 62 79 74 65 0d 20 20  |  \ high byte.  |
00002ed0  36 35 30 20 20 20 20 20  20 20 20 20 53 54 41 20  |650         STA |
00002ee0  28 61 64 64 72 65 73 73  29 2c 59 20 5c 20 73 74  |(address),Y \ st|
00002ef0  6f 72 65 20 69 6e 20 65  78 74 65 6e 64 65 64 20  |ore in extended |
00002f00  76 65 63 74 6f 72 0d 20  20 36 36 30 20 20 20 20  |vector.  660    |
00002f10  20 20 20 20 20 49 4e 59  20 20 20 20 20 20 20 20  |     INY        |
00002f20  20 20 20 5c 20 6f 66 66  73 65 74 20 74 6f 20 4f  |   \ offset to O|
00002f30  73 62 79 74 65 20 65 78  74 65 6e 64 65 64 20 76  |sbyte extended v|
00002f40  65 63 74 6f 72 2c 20 52  4f 4d 20 6e 75 6d 62 65  |ector, ROM numbe|
00002f50  72 0d 20 20 36 37 30 20  20 20 20 20 20 20 20 20  |r.  670         |
00002f60  4c 44 41 20 72 6f 6d 6e  75 6d 62 65 72 20 5c 20  |LDA romnumber \ |
00002f70  6c 6f 61 64 20 74 68 65  20 6e 75 6d 62 65 72 20  |load the number |
00002f80  6f 66 20 74 68 69 73 20  52 4f 4d 0d 20 20 36 38  |of this ROM.  68|
00002f90  30 20 20 20 20 20 20 20  20 20 53 54 41 20 28 61  |0         STA (a|
00002fa0  64 64 72 65 73 73 29 2c  59 20 5c 20 73 74 6f 72  |ddress),Y \ stor|
00002fb0  65 20 69 6e 20 65 78 74  65 6e 64 65 64 20 76 65  |e in extended ve|
00002fc0  63 74 6f 72 0d 20 20 36  39 30 20 20 20 20 20 20  |ctor.  690      |
00002fd0  20 20 20 4c 44 58 20 23  26 30 46 20 20 20 20 20  |   LDX #&0F     |
00002fe0  20 5c 20 6f 66 66 73 65  74 20 74 6f 20 4f 73 62  | \ offset to Osb|
00002ff0  79 74 65 20 65 6e 74 72  79 20 74 6f 20 65 78 74  |yte entry to ext|
00003000  65 6e 64 65 64 20 76 65  63 74 6f 72 73 2c 0d 20  |ended vectors,. |
00003010  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003020  20 20 20 20 20 20 20 20  20 20 20 5c 20 6c 6f 77  |           \ low|
00003030  20 62 79 74 65 0d 20 20  37 30 30 20 20 20 20 20  | byte.  700     |
00003040  20 20 20 20 4c 44 59 20  23 26 46 46 20 20 20 20  |    LDY #&FF    |
00003050  20 20 5c 20 65 78 74 65  6e 64 65 64 20 76 65 63  |  \ extended vec|
00003060  74 6f 72 20 65 6e 74 72  79 2c 20 68 69 67 68 20  |tor entry, high |
00003070  62 79 74 65 0d 20 20 37  31 30 20 20 20 20 20 20  |byte.  710      |
00003080  20 20 20 53 54 58 20 62  79 74 65 76 20 20 20 20  |   STX bytev    |
00003090  20 5c 20 61 6c 74 65 72  20 4f 73 62 79 74 65 20  | \ alter Osbyte |
000030a0  76 65 63 74 6f 72 2c 20  6c 6f 77 20 62 79 74 65  |vector, low byte|
000030b0  0d 20 20 37 32 30 20 20  20 20 20 20 20 20 20 53  |.  720         S|
000030c0  54 59 20 62 79 74 65 76  2b 31 20 20 20 5c 20 61  |TY bytev+1   \ a|
000030d0  6c 74 65 72 20 4f 73 62  79 74 65 20 76 65 63 74  |lter Osbyte vect|
000030e0  6f 72 2c 20 68 69 67 68  20 62 79 74 65 0d 20 20  |or, high byte.  |
000030f0  37 33 30 20 20 20 20 20  20 20 20 20 50 4c 41 20  |730         PLA |
00003100  20 20 20 20 20 20 20 20  20 20 5c 20 72 65 73 74  |          \ rest|
00003110  6f 72 65 20 74 68 65 20  72 65 67 69 73 74 65 72  |ore the register|
00003120  73 2e 0d 20 20 37 34 30  20 20 20 20 20 20 20 20  |s..  740        |
00003130  20 54 41 59 20 20 20 20  20 20 20 20 20 20 20 5c  | TAY           \|
00003140  20 74 68 69 73 20 69 73  20 61 6e 20 69 6c 6c 65  | this is an ille|
00003150  67 61 6c 20 75 73 65 20  66 6f 72 20 73 65 72 76  |gal use for serv|
00003160  69 63 65 20 74 79 70 65  20 26 46 45 0d 20 20 37  |ice type &FE.  7|
00003170  35 30 20 20 20 20 20 20  20 20 20 50 4c 41 20 20  |50         PLA  |
00003180  20 20 20 20 20 20 20 20  20 5c 20 74 68 65 20 41  |         \ the A|
00003190  2c 20 58 20 61 6e 64 20  59 20 72 65 67 69 73 74  |, X and Y regist|
000031a0  65 72 73 20 6d 75 73 74  20 62 65 20 72 65 73 74  |ers must be rest|
000031b0  6f 72 65 64 0d 20 20 37  36 30 20 20 20 20 20 20  |ored.  760      |
000031c0  20 20 20 54 41 58 20 20  20 20 20 20 20 20 20 20  |   TAX          |
000031d0  20 5c 20 62 65 66 6f 72  65 20 72 65 74 75 72 6e  | \ before return|
000031e0  20 74 6f 20 74 68 65 20  6f 70 65 72 61 74 69 6e  | to the operatin|
000031f0  67 20 73 79 73 74 65 6d  2e 0d 20 20 37 37 30 20  |g system..  770 |
00003200  20 20 20 20 20 20 20 20  50 4c 41 0d 20 20 37 38  |        PLA.  78|
00003210  30 20 2e 72 65 74 75 72  6e 0d 20 20 37 39 30 20  |0 .return.  790 |
00003220  20 20 20 20 20 20 20 20  52 54 53 0d 20 20 38 30  |        RTS.  80|
00003230  30 20 2e 69 6e 74 65 72  72 75 70 74 0d 20 20 38  |0 .interrupt.  8|
00003240  31 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 73  |10         LDA s|
00003250  61 76 65 72 65 67 20 20  20 5c 20 69 6e 74 65 72  |avereg   \ inter|
00003260  72 75 70 74 20 61 63 63  75 6d 75 6c 61 74 6f 72  |rupt accumulator|
00003270  20 73 61 76 65 20 72 65  67 69 73 74 65 72 0d 20  | save register. |
00003280  20 38 32 30 20 20 20 20  20 20 20 20 20 50 48 41  | 820         PHA|
00003290  20 20 20 20 20 20 20 20  20 20 20 5c 20 61 6e 64  |           \ and|
000032a0  20 70 75 73 68 20 69 74  20 6f 6e 20 74 68 65 20  | push it on the |
000032b0  73 74 61 63 6b 0d 20 20  38 33 30 20 20 20 20 20  |stack.  830     |
000032c0  20 20 20 20 4c 44 41 20  69 66 72 20 20 20 20 20  |    LDA ifr     |
000032d0  20 20 5c 20 69 6e 74 65  72 72 75 70 74 20 66 6c  |  \ interrupt fl|
000032e0  61 67 20 72 65 67 69 73  74 65 72 0d 20 20 38 34  |ag register.  84|
000032f0  30 20 20 20 20 20 20 20  20 20 42 50 4c 20 6e 6f  |0         BPL no|
00003300  74 75 73 65 72 20 20 20  5c 20 62 69 74 20 37 20  |tuser   \ bit 7 |
00003310  69 73 20 73 65 74 20 69  66 20 56 49 41 2d 42 20  |is set if VIA-B |
00003320  69 6e 74 65 72 72 75 70  74 0d 20 20 38 35 30 20  |interrupt.  850 |
00003330  20 20 20 20 20 20 20 20  41 4e 44 20 23 26 31 38  |        AND #&18|
00003340  20 20 20 20 20 20 5c 20  41 4e 44 20 77 69 74 68  |      \ AND with|
00003350  20 25 30 30 30 31 31 30  30 30 2c 20 69 65 2e 20  | %00011000, ie. |
00003360  74 65 73 74 20 62 69 74  73 20 33 20 61 6e 64 20  |test bits 3 and |
00003370  34 0d 20 20 38 36 30 20  20 20 20 20 20 20 20 20  |4.  860         |
00003380  42 45 51 20 6e 6f 74 75  73 65 72 20 20 20 5c 20  |BEQ notuser   \ |
00003390  65 78 69 74 20 69 66 20  6e 6f 74 20 43 42 31 20  |exit if not CB1 |
000033a0  6f 72 20 43 42 32 0d 20  20 38 37 30 20 20 20 20  |or CB2.  870    |
000033b0  20 20 20 20 20 41 4e 44  20 23 26 31 30 20 20 20  |     AND #&10   |
000033c0  20 20 20 5c 20 41 4e 44  20 77 69 74 68 20 25 30  |   \ AND with %0|
000033d0  30 30 31 30 30 30 30 2c  20 69 65 2e 20 74 65 73  |0010000, ie. tes|
000033e0  74 20 43 42 31 0d 20 20  38 38 30 20 20 20 20 20  |t CB1.  880     |
000033f0  20 20 20 20 42 4e 45 20  78 70 75 6c 73 65 20 20  |    BNE xpulse  |
00003400  20 20 5c 20 62 69 74 20  34 20 73 65 74 20 66 6f  |  \ bit 4 set fo|
00003410  72 20 61 6e 20 58 20 64  69 72 65 63 74 69 6f 6e  |r an X direction|
00003420  20 6d 6f 76 65 6d 65 6e  74 0d 20 20 38 39 30 20  | movement.  890 |
00003430  20 20 20 20 20 20 20 20  4c 44 41 20 64 72 62 20  |        LDA drb |
00003440  20 20 20 20 20 20 5c 20  59 20 64 69 72 65 63 74  |      \ Y direct|
00003450  69 6f 6e 2c 20 6c 6f 61  64 20 64 61 74 61 20 72  |ion, load data r|
00003460  65 67 69 73 74 65 72 20  42 0d 20 20 39 30 30 20  |egister B.  900 |
00003470  20 20 20 20 20 20 20 20  41 4e 44 20 23 26 30 34  |        AND #&04|
00003480  20 20 20 20 20 20 5c 20  41 4e 44 20 77 69 74 68  |      \ AND with|
00003490  20 25 30 30 30 30 30 31  30 30 2c 20 69 65 2e 20  | %00000100, ie. |
000034a0  74 65 73 74 20 62 69 74  20 32 0d 20 20 39 31 30  |test bit 2.  910|
000034b0  20 20 20 20 20 20 20 20  20 42 4e 45 20 79 64 6f  |         BNE ydo|
000034c0  77 6e 20 20 20 20 20 5c  20 69 66 20 62 69 74 20  |wn     \ if bit |
000034d0  32 20 69 73 20 73 65 74  20 74 68 65 6e 20 59 20  |2 is set then Y |
000034e0  69 73 20 67 6f 69 6e 67  20 64 6f 77 6e 0d 20 20  |is going down.  |
000034f0  39 32 30 20 20 20 20 20  20 20 20 20 49 4e 43 20  |920         INC |
00003500  79 63 6f 6f 72 64 20 20  20 20 5c 20 59 20 69 73  |ycoord    \ Y is|
00003510  20 67 6f 69 6e 67 20 75  70 20 73 6f 20 69 6e 63  | going up so inc|
00003520  72 65 6d 65 6e 74 20 59  20 63 6f 6f 72 64 69 6e  |rement Y coordin|
00003530  61 74 65 0d 20 20 39 33  30 20 20 20 20 20 20 20  |ate.  930       |
00003540  20 20 42 4e 45 20 65 78  69 74 20 20 20 20 20 20  |  BNE exit      |
00003550  5c 20 62 72 61 6e 63 68  20 69 66 20 69 6e 20 74  |\ branch if in t|
00003560  68 65 20 72 61 6e 67 65  20 31 20 74 6f 20 32 35  |he range 1 to 25|
00003570  35 0d 20 20 39 34 30 20  20 20 20 20 20 20 20 20  |5.  940         |
00003580  42 45 51 20 64 65 63 79  20 20 20 20 20 20 5c 20  |BEQ decy      \ |
00003590  69 66 20 7a 65 72 6f 20  74 68 65 6e 20 61 6c 74  |if zero then alt|
000035a0  65 72 20 74 6f 20 32 35  35 0d 20 20 39 35 30 20  |er to 255.  950 |
000035b0  2e 79 64 6f 77 6e 0d 20  20 39 36 30 20 20 20 20  |.ydown.  960    |
000035c0  20 20 20 20 20 4c 44 41  20 79 63 6f 6f 72 64 20  |     LDA ycoord |
000035d0  20 20 20 5c 20 6c 6f 61  64 20 59 20 63 6f 6f 72  |   \ load Y coor|
000035e0  64 69 6e 61 74 65 0d 20  20 39 37 30 20 20 20 20  |dinate.  970    |
000035f0  20 20 20 20 20 42 45 51  20 65 78 69 74 20 20 20  |     BEQ exit   |
00003600  20 20 20 5c 20 62 72 61  6e 63 68 20 69 66 20 7a  |   \ branch if z|
00003610  65 72 6f 20 62 65 63 61  75 73 65 20 69 74 20 63  |ero because it c|
00003620  61 6e 27 74 20 67 6f 0d  20 20 20 20 20 20 20 20  |an't go.        |
00003630  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003640  20 20 20 20 5c 20 61 6e  79 20 6c 6f 77 65 72 0d  |    \ any lower.|
00003650  20 20 39 38 30 20 2e 64  65 63 79 0d 20 20 39 39  |  980 .decy.  99|
00003660  30 20 20 20 20 20 20 20  20 20 44 45 43 20 79 63  |0         DEC yc|
00003670  6f 6f 72 64 20 20 20 20  5c 20 72 65 64 75 63 65  |oord    \ reduce|
00003680  20 59 20 63 6f 6f 72 64  69 6e 61 74 65 20 62 79  | Y coordinate by|
00003690  20 31 0d 20 31 30 30 30  20 20 20 20 20 20 20 20  | 1. 1000        |
000036a0  20 4a 4d 50 20 65 78 69  74 20 20 20 20 20 20 5c  | JMP exit      \|
000036b0  20 72 65 73 74 6f 72 65  20 69 6e 74 65 72 72 75  | restore interru|
000036c0  70 74 20 61 63 63 75 6d  75 6c 61 74 6f 72 20 73  |pt accumulator s|
000036d0  61 76 65 0d 20 20 20 20  20 20 20 20 20 20 20 20  |ave.            |
000036e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000036f0  5c 20 72 65 67 69 73 74  65 72 20 61 6e 64 20 52  |\ register and R|
00003700  54 49 0d 20 31 30 31 30  20 2e 78 70 75 6c 73 65  |TI. 1010 .xpulse|
00003710  0d 20 31 30 32 30 20 20  20 20 20 20 20 20 20 4c  |. 1020         L|
00003720  44 41 20 64 72 62 20 20  20 20 20 20 20 5c 20 6c  |DA drb       \ l|
00003730  6f 61 64 20 64 61 74 61  20 72 65 67 69 73 74 65  |oad data registe|
00003740  72 20 42 0d 20 31 30 33  30 20 20 20 20 20 20 20  |r B. 1030       |
00003750  20 20 52 4f 52 20 41 20  20 20 20 20 20 20 20 20  |  ROR A         |
00003760  5c 20 62 69 74 20 30 20  69 6e 74 6f 20 63 61 72  |\ bit 0 into car|
00003770  72 79 0d 20 31 30 34 30  20 20 20 20 20 20 20 20  |ry. 1040        |
00003780  20 42 43 43 20 78 64 6f  77 6e 20 20 20 20 20 5c  | BCC xdown     \|
00003790  20 66 75 64 67 65 20 74  6f 20 72 65 76 65 72 73  | fudge to revers|
000037a0  65 20 6a 6f 79 73 74 69  63 6b 0d 20 31 30 35 30  |e joystick. 1050|
000037b0  20 20 20 20 20 20 20 20  20 49 4e 43 20 78 63 6f  |         INC xco|
000037c0  6f 72 64 20 20 20 20 5c  20 66 75 64 67 65 20 74  |ord    \ fudge t|
000037d0  6f 20 69 6e 63 72 65 61  73 65 20 58 20 77 68 65  |o increase X whe|
000037e0  6e 20 69 74 73 20 67 6f  69 6e 67 20 64 6f 77 6e  |n its going down|
000037f0  0d 20 31 30 36 30 20 20  20 20 20 20 20 20 20 42  |. 1060         B|
00003800  4e 45 20 65 78 69 74 20  20 20 20 20 20 5c 20 65  |NE exit      \ e|
00003810  78 69 74 20 69 66 20 58  20 63 6f 6f 72 64 69 6e  |xit if X coordin|
00003820  61 74 65 20 69 73 20 69  6e 20 74 68 65 20 72 61  |ate is in the ra|
00003830  6e 67 65 0d 20 20 20 20  20 20 20 20 20 20 20 20  |nge.            |
00003840  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003850  5c 20 66 72 6f 6d 20 31  20 74 6f 20 32 35 35 0d  |\ from 1 to 255.|
00003860  20 31 30 37 30 20 20 20  20 20 20 20 20 20 42 45  | 1070         BE|
00003870  51 20 64 65 63 78 20 20  20 20 20 20 5c 20 69 66  |Q decx      \ if|
00003880  20 58 20 63 6f 6f 72 64  69 6e 61 74 65 20 3d 20  | X coordinate = |
00003890  30 20 74 68 65 6e 20 6d  61 6b 65 20 69 74 20 32  |0 then make it 2|
000038a0  35 35 0d 20 31 30 38 30  20 2e 78 64 6f 77 6e 0d  |55. 1080 .xdown.|
000038b0  20 31 30 39 30 20 20 20  20 20 20 20 20 20 4c 44  | 1090         LD|
000038c0  41 20 78 63 6f 6f 72 64  20 20 20 20 5c 20 6c 6f  |A xcoord    \ lo|
000038d0  61 64 20 58 20 63 6f 6f  72 64 69 6e 61 74 65 0d  |ad X coordinate.|
000038e0  20 31 31 30 30 20 20 20  20 20 20 20 20 20 42 45  | 1100         BE|
000038f0  51 20 65 78 69 74 20 20  20 20 20 20 5c 20 69 66  |Q exit      \ if|
00003900  20 69 74 20 69 73 20 7a  65 72 6f 20 69 74 20 63  | it is zero it c|
00003910  61 6e 27 74 20 67 6f 20  61 6e 79 20 6c 6f 77 65  |an't go any lowe|
00003920  72 0d 20 31 31 31 30 20  2e 64 65 63 78 0d 20 31  |r. 1110 .decx. 1|
00003930  31 32 30 20 20 20 20 20  20 20 20 20 44 45 43 20  |120         DEC |
00003940  78 63 6f 6f 72 64 20 20  20 20 5c 20 64 65 63 72  |xcoord    \ decr|
00003950  65 61 73 65 20 58 20 63  6f 6f 72 64 69 6e 61 74  |ease X coordinat|
00003960  65 20 62 79 20 31 0d 20  31 31 33 30 20 2e 65 78  |e by 1. 1130 .ex|
00003970  69 74 0d 20 31 31 34 30  20 20 20 20 20 20 20 20  |it. 1140        |
00003980  20 50 4c 41 20 20 20 20  20 20 20 20 20 20 20 5c  | PLA           \|
00003990  20 70 75 6c 6c 20 69 6e  74 65 72 72 75 70 74 20  | pull interrupt |
000039a0  61 63 63 75 6d 75 6c 61  74 6f 72 20 73 61 76 65  |accumulator save|
000039b0  20 72 65 67 69 73 74 65  72 0d 20 20 20 20 20 20  | register.      |
000039c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000039d0  20 20 20 20 20 20 5c 20  6f 66 66 20 74 68 65 20  |      \ off the |
000039e0  73 74 61 63 6b 0d 20 31  31 35 30 20 20 20 20 20  |stack. 1150     |
000039f0  20 20 20 20 53 54 41 20  73 61 76 65 72 65 67 20  |    STA savereg |
00003a00  20 20 5c 20 61 6e 64 20  72 65 73 74 6f 72 65 20  |  \ and restore |
00003a10  7a 65 72 6f 20 70 61 67  65 0d 20 31 31 36 30 20  |zero page. 1160 |
00003a20  20 20 20 20 20 20 20 20  4c 44 41 20 23 26 30 30  |        LDA #&00|
00003a30  0d 20 31 31 37 30 20 20  20 20 20 20 20 20 20 52  |. 1170         R|
00003a40  54 53 0d 20 31 31 38 30  20 2e 6e 6f 74 75 73 65  |TS. 1180 .notuse|
00003a50  72 0d 20 31 31 39 30 20  20 20 20 20 20 20 20 20  |r. 1190         |
00003a60  50 4c 41 20 20 20 20 20  20 20 20 20 20 20 5c 20  |PLA           \ |
00003a70  70 75 6c 6c 20 74 68 65  20 69 6e 74 65 72 72 75  |pull the interru|
00003a80  70 74 20 61 63 63 75 6d  75 6c 61 74 6f 72 20 73  |pt accumulator s|
00003a90  61 76 65 0d 20 20 20 20  20 20 20 20 20 20 20 20  |ave.            |
00003aa0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003ab0  5c 20 72 65 67 69 73 74  65 72 20 6f 66 66 20 74  |\ register off t|
00003ac0  68 65 20 73 74 61 63 6b  0d 20 31 32 30 30 20 20  |he stack. 1200  |
00003ad0  20 20 20 20 20 20 20 53  54 41 20 73 61 76 65 72  |       STA saver|
00003ae0  65 67 20 20 20 5c 20 72  65 73 74 6f 72 65 20 74  |eg   \ restore t|
00003af0  68 65 20 7a 65 72 6f 20  70 61 67 65 20 61 64 64  |he zero page add|
00003b00  72 65 73 73 0d 20 31 32  31 30 20 20 20 20 20 20  |ress. 1210      |
00003b10  20 20 20 4c 44 41 20 23  26 30 35 20 20 20 20 20  |   LDA #&05     |
00003b20  20 5c 20 73 65 72 76 69  63 65 20 74 79 70 65 20  | \ service type |
00003b30  35 0d 20 31 32 32 30 20  20 20 20 20 20 20 20 20  |5. 1220         |
00003b40  52 54 53 20 20 20 20 20  20 20 20 20 20 20 5c 20  |RTS           \ |
00003b50  72 65 74 75 72 6e 20 74  6f 20 6f 70 65 72 61 74  |return to operat|
00003b60  69 6e 67 20 73 79 73 74  65 6d 0d 20 31 32 33 30  |ing system. 1230|
00003b70  20 2e 6f 6c 64 61 64 76  61 6c 0d 20 31 32 34 30  | .oldadval. 1240|
00003b80  20 20 20 20 20 20 20 20  20 50 4c 50 20 20 20 20  |         PLP    |
00003b90  20 20 20 20 20 20 20 5c  20 70 75 6c 6c 20 73 74  |       \ pull st|
00003ba0  61 74 75 73 20 72 65 67  69 73 74 65 72 0d 20 31  |atus register. 1|
00003bb0  32 35 30 20 2e 6f 72 69  67 69 6e 61 6c 0d 20 31  |250 .original. 1|
00003bc0  32 36 30 20 20 20 20 20  20 20 20 20 4a 4d 50 20  |260         JMP |
00003bd0  28 6f 6c 64 62 79 74 65  76 29 20 5c 20 65 78 69  |(oldbytev) \ exi|
00003be0  74 20 76 69 61 20 6f 72  69 67 69 6e 61 6c 20 4f  |t via original O|
00003bf0  73 62 79 74 65 20 76 65  63 74 6f 72 0d 20 31 32  |sbyte vector. 12|
00003c00  37 30 20 2e 61 6e 61 6c  6f 67 75 65 0d 20 31 32  |70 .analogue. 12|
00003c10  38 30 20 20 20 20 20 20  20 20 20 50 48 50 20 20  |80         PHP  |
00003c20  20 20 20 20 20 20 20 20  20 5c 20 70 75 73 68 20  |         \ push |
00003c30  74 68 65 20 73 74 61 74  75 73 20 72 65 67 69 73  |the status regis|
00003c40  74 65 72 0d 20 31 32 39  30 20 20 20 20 20 20 20  |ter. 1290       |
00003c50  20 20 43 4d 50 20 23 26  38 30 20 20 20 20 20 20  |  CMP #&80      |
00003c60  5c 20 69 73 20 74 68 69  73 20 4f 73 62 79 74 65  |\ is this Osbyte|
00003c70  20 26 38 30 2c 20 72 65  61 64 20 41 44 43 20 63  | &80, read ADC c|
00003c80  68 61 6e 6e 65 6c 0d 20  31 33 30 30 20 20 20 20  |hannel. 1300    |
00003c90  20 20 20 20 20 42 4e 45  20 6f 6c 64 61 64 76 61  |     BNE oldadva|
00003ca0  6c 20 20 5c 20 69 66 20  6e 6f 74 20 65 78 69 74  |l  \ if not exit|
00003cb0  20 76 69 61 20 6f 72 69  67 69 6e 61 6c 20 4f 73  | via original Os|
00003cc0  62 79 74 65 20 76 65 63  74 6f 72 0d 20 31 33 31  |byte vector. 131|
00003cd0  30 20 20 20 20 20 20 20  20 20 43 50 58 20 23 26  |0         CPX #&|
00003ce0  30 30 20 20 20 20 20 20  5c 20 69 73 20 74 68 69  |00      \ is thi|
00003cf0  73 20 41 44 56 41 4c 28  30 29 20 69 65 2e 20 72  |s ADVAL(0) ie. r|
00003d00  65 61 64 20 66 69 72 65  20 62 75 74 74 6f 6e 73  |ead fire buttons|
00003d10  3f 0d 20 31 33 32 30 20  20 20 20 20 20 20 20 20  |?. 1320         |
00003d20  42 45 51 20 66 69 72 65  62 75 74 74 6f 6e 73 20  |BEQ firebuttons |
00003d30  5c 20 69 66 20 69 74 20  69 73 20 62 72 61 6e 63  |\ if it is branc|
00003d40  68 20 74 6f 20 6e 65 77  20 66 69 72 65 20 62 75  |h to new fire bu|
00003d50  74 74 6f 6e 73 0d 20 20  20 20 20 20 20 20 20 20  |ttons.          |
00003d60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003d70  20 20 5c 20 72 6f 75 74  69 6e 65 0d 20 31 33 33  |  \ routine. 133|
00003d80  30 20 20 20 20 20 20 20  20 20 54 58 41 20 20 20  |0         TXA   |
00003d90  20 20 20 20 20 20 20 20  5c 20 63 68 61 6e 6e 65  |        \ channe|
00003da0  6c 20 6e 75 6d 62 65 72  20 69 73 20 69 6e 20 58  |l number is in X|
00003db0  20 72 65 67 69 73 74 65  72 0d 20 31 33 34 30 20  | register. 1340 |
00003dc0  20 20 20 20 20 20 20 20  52 4f 52 20 41 20 20 20  |        ROR A   |
00003dd0  20 20 20 20 20 20 5c 20  62 69 74 20 30 20 6f 66  |      \ bit 0 of|
00003de0  20 63 68 61 6e 6e 65 6c  20 6e 75 6d 62 65 72 20  | channel number |
00003df0  69 6e 74 6f 20 63 61 72  72 79 0d 20 31 33 35 30  |into carry. 1350|
00003e00  20 20 20 20 20 20 20 20  20 4c 44 41 20 79 63 6f  |         LDA yco|
00003e10  6f 72 64 20 20 20 20 5c  20 59 20 63 6f 6f 72 64  |ord    \ Y coord|
00003e20  69 6e 61 74 65 20 66 72  6f 6d 20 6d 6f 75 73 65  |inate from mouse|
00003e30  20 6d 6f 76 65 6d 65 6e  74 0d 20 31 33 36 30 20  | movement. 1360 |
00003e40  20 20 20 20 20 20 20 20  42 43 43 20 73 6b 69 70  |        BCC skip|
00003e50  78 63 6f 6f 72 64 20 5c  20 63 61 72 72 79 20 63  |xcoord \ carry c|
00003e60  6c 65 61 72 20 69 66 20  63 68 61 6e 6e 65 6c 20  |lear if channel |
00003e70  32 20 6f 72 20 34 0d 20  31 33 37 30 20 20 20 20  |2 or 4. 1370    |
00003e80  20 20 20 20 20 4c 44 41  20 78 63 6f 6f 72 64 20  |     LDA xcoord |
00003e90  20 20 20 5c 20 58 20 63  6f 6f 72 64 69 6e 61 74  |   \ X coordinat|
00003ea0  65 20 66 72 6f 6d 20 6d  6f 75 73 65 20 6d 6f 76  |e from mouse mov|
00003eb0  65 6d 65 6e 74 0d 20 31  33 38 30 20 2e 73 6b 69  |ement. 1380 .ski|
00003ec0  70 78 63 6f 6f 72 64 0d  20 31 33 39 30 20 20 20  |pxcoord. 1390   |
00003ed0  20 20 20 20 20 20 54 41  59 20 20 20 20 20 20 20  |      TAY       |
00003ee0  20 20 20 20 5c 20 73 69  6d 75 6c 61 74 65 64 20  |    \ simulated |
00003ef0  41 44 56 41 4c 28 31 2d  34 29 2c 20 68 69 67 68  |ADVAL(1-4), high|
00003f00  20 62 79 74 65 0d 20 31  34 30 30 20 20 20 20 20  | byte. 1400     |
00003f10  20 20 20 20 41 4e 44 20  23 26 46 30 20 20 20 20  |    AND #&F0    |
00003f20  20 20 5c 20 41 4e 44 20  77 69 74 68 20 25 31 31  |  \ AND with %11|
00003f30  31 31 30 30 30 30 2c 20  69 65 2e 20 63 6c 65 61  |110000, ie. clea|
00003f40  72 20 62 69 74 73 20 30  2d 33 0d 20 31 34 31 30  |r bits 0-3. 1410|
00003f50  20 20 20 20 20 20 20 20  20 54 41 58 20 20 20 20  |         TAX    |
00003f60  20 20 20 20 20 20 20 5c  20 73 69 6d 75 6c 61 74  |       \ simulat|
00003f70  65 64 20 41 44 56 41 4c  28 31 2d 34 29 2c 20 6c  |ed ADVAL(1-4), l|
00003f80  6f 77 20 62 79 74 65 0d  20 31 34 32 30 20 20 20  |ow byte. 1420   |
00003f90  20 20 20 20 20 20 4c 44  41 20 23 26 38 30 20 20  |      LDA #&80  |
00003fa0  20 20 20 20 5c 20 4f 73  62 79 74 65 20 26 38 30  |    \ Osbyte &80|
00003fb0  0d 20 31 34 33 30 20 20  20 20 20 20 20 20 20 50  |. 1430         P|
00003fc0  4c 50 20 20 20 20 20 20  20 20 20 20 20 5c 20 72  |LP           \ r|
00003fd0  65 73 74 6f 72 65 20 73  74 61 74 75 73 20 72 65  |estore status re|
00003fe0  67 69 73 74 65 72 0d 20  31 34 34 30 20 20 20 20  |gister. 1440    |
00003ff0  20 20 20 20 20 52 54 53  20 20 20 20 20 20 20 20  |     RTS        |
00004000  20 20 20 5c 20 72 65 74  75 72 6e 20 74 6f 20 42  |   \ return to B|
00004010  41 53 49 43 0d 20 31 34  35 30 20 2e 66 69 72 65  |ASIC. 1450 .fire|
00004020  62 75 74 74 6f 6e 73 0d  20 31 34 36 30 20 20 20  |buttons. 1460   |
00004030  20 20 20 20 20 20 4a 53  52 20 6f 72 69 67 69 6e  |      JSR origin|
00004040  61 6c 20 20 5c 20 70 65  72 66 6f 72 6d 20 74 68  |al  \ perform th|
00004050  65 20 6f 72 69 67 69 6e  61 6c 20 41 44 56 41 4c  |e original ADVAL|
00004060  28 30 29 0d 20 31 34 37  30 20 20 20 20 20 20 20  |(0). 1470       |
00004070  20 20 54 58 41 20 20 20  20 20 20 20 20 20 20 20  |  TXA           |
00004080  5c 20 72 65 73 75 6c 74  20 69 6e 20 62 69 74 73  |\ result in bits|
00004090  20 30 20 61 6e 64 20 31  20 6f 66 20 74 68 65 20  | 0 and 1 of the |
000040a0  58 20 72 65 67 69 73 74  65 72 0d 20 31 34 38 30  |X register. 1480|
000040b0  20 20 20 20 20 20 20 20  20 50 48 41 20 20 20 20  |         PHA    |
000040c0  20 20 20 20 20 20 20 5c  20 70 75 73 68 20 74 68  |       \ push th|
000040d0  65 20 72 65 73 75 6c 74  20 6f 6e 74 6f 20 73 74  |e result onto st|
000040e0  61 63 6b 0d 20 31 34 39  30 20 20 20 20 20 20 20  |ack. 1490       |
000040f0  20 20 4c 44 41 20 64 72  62 20 20 20 20 20 20 20  |  LDA drb       |
00004100  5c 20 64 61 74 61 20 72  65 67 69 73 74 65 72 20  |\ data register |
00004110  42 0d 20 31 35 30 30 20  20 20 20 20 20 20 20 20  |B. 1500         |
00004120  52 4f 4c 20 41 20 20 20  20 20 20 20 20 20 5c 20  |ROL A         \ |
00004130  62 69 74 20 37 20 69 6e  74 6f 20 63 61 72 72 79  |bit 7 into carry|
00004140  0d 20 31 35 31 30 20 20  20 20 20 20 20 20 20 42  |. 1510         B|
00004150  43 43 20 72 69 67 68 74  20 20 20 20 20 5c 20 62  |CC right     \ b|
00004160  69 74 20 37 20 63 6c 65  61 72 20 69 66 20 72 69  |it 7 clear if ri|
00004170  67 68 74 20 62 75 74 74  6f 6e 20 70 72 65 73 73  |ght button press|
00004180  65 64 0d 20 31 35 32 30  20 20 20 20 20 20 20 20  |ed. 1520        |
00004190  20 52 4f 4c 20 41 20 20  20 20 20 20 20 20 20 5c  | ROL A         \|
000041a0  20 62 69 74 20 36 20 69  6e 74 6f 20 63 61 72 72  | bit 6 into carr|
000041b0  79 0d 20 31 35 33 30 20  20 20 20 20 20 20 20 20  |y. 1530         |
000041c0  42 43 43 20 63 65 6e 74  72 65 20 20 20 20 5c 20  |BCC centre    \ |
000041d0  62 69 74 20 36 20 63 6c  65 61 72 20 69 66 20 63  |bit 6 clear if c|
000041e0  65 6e 74 72 65 20 62 75  74 74 6f 6e 20 70 72 65  |entre button pre|
000041f0  73 73 65 64 0d 20 31 35  34 30 20 20 20 20 20 20  |ssed. 1540      |
00004200  20 20 20 52 4f 4c 20 41  20 20 20 20 20 20 20 20  |   ROL A        |
00004210  20 5c 20 62 69 74 20 35  20 69 6e 74 6f 20 63 61  | \ bit 5 into ca|
00004220  72 72 79 0d 20 31 35 35  30 20 20 20 20 20 20 20  |rry. 1550       |
00004230  20 20 42 43 53 20 6e 6f  70 72 65 73 73 20 20 20  |  BCS nopress   |
00004240  5c 20 69 66 20 62 69 74  20 35 20 73 65 74 20 74  |\ if bit 5 set t|
00004250  68 65 6e 20 6e 6f 20 6d  6f 75 73 65 20 62 75 74  |hen no mouse but|
00004260  74 6f 6e 73 20 70 72 65  73 73 65 64 0d 20 31 35  |tons pressed. 15|
00004270  36 30 20 20 20 20 20 20  20 20 20 50 4c 41 20 20  |60         PLA  |
00004280  20 20 20 20 20 20 20 20  20 5c 20 6c 65 66 74 20  |         \ left |
00004290  62 75 74 74 6f 6e 20 70  72 65 73 73 65 64 2c 20  |button pressed, |
000042a0  70 75 6c 6c 20 72 65 73  75 6c 74 20 6f 66 0d 20  |pull result of. |
000042b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000042c0  20 20 20 20 20 20 20 20  20 20 20 5c 20 6f 72 69  |           \ ori|
000042d0  67 69 6e 61 6c 20 41 44  56 41 4c 28 30 29 0d 20  |ginal ADVAL(0). |
000042e0  31 35 37 30 20 20 20 20  20 20 20 20 20 4f 52 41  |1570         ORA|
000042f0  20 23 26 30 31 20 20 20  20 20 20 5c 20 73 65 74  | #&01      \ set|
00004300  20 62 69 74 20 30 20 74  6f 20 73 69 6d 75 6c 61  | bit 0 to simula|
00004310  74 65 20 66 69 72 65 20  62 75 74 74 6f 6e 20 70  |te fire button p|
00004320  72 65 73 73 65 64 0d 20  31 35 38 30 20 20 20 20  |ressed. 1580    |
00004330  20 20 20 20 20 42 4e 45  20 67 65 74 6f 75 74 20  |     BNE getout |
00004340  20 20 20 5c 20 75 6e 63  6f 6e 64 69 74 69 6f 6e  |   \ uncondition|
00004350  61 6c 20 62 72 61 6e 63  68 20 74 6f 20 65 78 69  |al branch to exi|
00004360  74 0d 20 31 35 39 30 20  2e 72 69 67 68 74 0d 20  |t. 1590 .right. |
00004370  31 36 30 30 20 20 20 20  20 20 20 20 20 50 4c 41  |1600         PLA|
00004380  20 20 20 20 20 20 20 20  20 20 20 5c 20 70 75 6c  |           \ pul|
00004390  6c 20 72 65 73 75 6c 74  20 6f 66 20 6f 72 69 67  |l result of orig|
000043a0  69 6e 61 6c 20 41 44 56  41 4c 28 30 29 0d 20 31  |inal ADVAL(0). 1|
000043b0  36 31 30 20 20 20 20 20  20 20 20 20 4f 52 41 20  |610         ORA |
000043c0  23 26 30 32 20 20 20 20  20 20 5c 20 73 65 74 20  |#&02      \ set |
000043d0  62 69 74 20 31 20 74 6f  20 73 69 6d 75 6c 61 74  |bit 1 to simulat|
000043e0  65 20 66 69 72 65 20 62  75 74 74 6f 6e 20 70 72  |e fire button pr|
000043f0  65 73 73 65 64 0d 20 31  36 32 30 20 20 20 20 20  |essed. 1620     |
00004400  20 20 20 20 42 4e 45 20  67 65 74 6f 75 74 20 20  |    BNE getout  |
00004410  20 20 5c 20 75 6e 63 6f  6e 64 69 74 69 6f 6e 61  |  \ unconditiona|
00004420  6c 20 62 72 61 6e 63 68  20 74 6f 20 65 78 69 74  |l branch to exit|
00004430  0d 20 31 36 33 30 20 2e  63 65 6e 74 72 65 0d 20  |. 1630 .centre. |
00004440  31 36 34 30 20 20 20 20  20 20 20 20 20 50 4c 41  |1640         PLA|
00004450  20 20 20 20 20 20 20 20  20 20 20 5c 20 70 75 6c  |           \ pul|
00004460  6c 20 72 65 73 75 6c 74  20 6f 66 20 6f 72 69 67  |l result of orig|
00004470  69 6e 61 6c 20 41 44 56  41 4c 28 30 29 0d 20 31  |inal ADVAL(0). 1|
00004480  36 35 30 20 20 20 20 20  20 20 20 20 4f 52 41 20  |650         ORA |
00004490  23 26 30 33 20 20 20 20  20 20 5c 20 73 65 74 20  |#&03      \ set |
000044a0  62 69 74 73 20 30 20 61  6e 64 20 31 20 74 6f 20  |bits 0 and 1 to |
000044b0  73 69 6d 75 6c 61 74 65  20 62 6f 74 68 20 66 69  |simulate both fi|
000044c0  72 65 0d 20 20 20 20 20  20 20 20 20 20 20 20 20  |re.             |
000044d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 5c  |               \|
000044e0  20 62 75 74 74 6f 6e 73  0d 20 31 36 36 30 20 20  | buttons. 1660  |
000044f0  20 20 20 20 20 20 20 42  4e 45 20 67 65 74 6f 75  |       BNE getou|
00004500  74 20 20 20 20 5c 20 75  6e 63 6f 6e 64 69 74 69  |t    \ unconditi|
00004510  6f 6e 61 6c 20 62 72 61  6e 63 68 0d 20 31 36 37  |onal branch. 167|
00004520  30 20 2e 6e 6f 70 72 65  73 73 0d 20 31 36 38 30  |0 .nopress. 1680|
00004530  20 20 20 20 20 20 20 20  20 50 4c 41 20 20 20 20  |         PLA    |
00004540  20 20 20 20 20 20 20 5c  20 70 75 6c 6c 20 74 68  |       \ pull th|
00004550  65 20 72 65 73 75 6c 74  20 62 79 74 65 20 6f 66  |e result byte of|
00004560  66 20 74 68 65 20 73 74  61 63 6b 0d 20 31 36 39  |f the stack. 169|
00004570  30 20 2e 67 65 74 6f 75  74 0d 20 31 37 30 30 20  |0 .getout. 1700 |
00004580  20 20 20 20 20 20 20 20  54 41 58 20 20 20 20 20  |        TAX     |
00004590  20 20 20 20 20 20 5c 20  74 72 61 6e 73 66 65 72  |      \ transfer|
000045a0  20 72 65 73 75 6c 74 20  62 79 74 65 20 74 6f 20  | result byte to |
000045b0  74 68 65 20 58 20 72 65  67 69 73 74 65 72 0d 20  |the X register. |
000045c0  31 37 31 30 20 20 20 20  20 20 20 20 20 4c 44 41  |1710         LDA|
000045d0  20 23 26 38 30 20 20 20  20 20 20 5c 20 4f 73 62  | #&80      \ Osb|
000045e0  79 74 65 20 26 38 30 0d  20 31 37 32 30 20 20 20  |yte &80. 1720   |
000045f0  20 20 20 20 20 20 50 4c  50 20 20 20 20 20 20 20  |      PLP       |
00004600  20 20 20 20 5c 20 70 75  6c 6c 20 74 68 65 20 73  |    \ pull the s|
00004610  74 61 74 75 73 20 72 65  67 69 73 74 65 72 0d 20  |tatus register. |
00004620  31 37 33 30 20 20 20 20  20 20 20 20 20 52 54 53  |1730         RTS|
00004630  20 20 20 20 20 20 20 20  20 20 20 5c 20 72 65 74  |           \ ret|
00004640  75 72 6e 20 74 6f 20 42  41 53 49 43 0d 20 31 37  |urn to BASIC. 17|
00004650  34 30 20 2e 78 63 6f 6f  72 64 0d 20 31 37 35 30  |40 .xcoord. 1750|
00004660  20 20 20 20 20 20 20 20  20 45 51 55 42 20 26 38  |         EQUB &8|
00004670  30 20 20 20 20 20 20 5c  20 6d 6f 75 73 65 20 58  |0      \ mouse X|
00004680  20 63 6f 6f 72 64 69 6e  61 74 65 20 30 2d 32 35  | coordinate 0-25|
00004690  35 0d 20 31 37 36 30 20  2e 79 63 6f 6f 72 64 0d  |5. 1760 .ycoord.|
000046a0  20 31 37 37 30 20 20 20  20 20 20 20 20 20 45 51  | 1770         EQ|
000046b0  55 42 20 26 38 30 20 20  20 20 20 20 5c 20 6d 6f  |UB &80      \ mo|
000046c0  75 73 65 20 59 20 63 6f  6f 72 64 69 6e 61 74 65  |use Y coordinate|
000046d0  20 30 2d 32 35 35 0d 20  31 37 38 30 20 2e 6f 6c  | 0-255. 1780 .ol|
000046e0  64 62 79 74 65 76 0d 20  31 37 39 30 20 20 20 20  |dbytev. 1790    |
000046f0  20 20 20 20 20 45 51 55  57 20 26 30 30 20 20 20  |     EQUW &00   |
00004700  20 20 20 5c 20 6f 72 69  67 69 6e 61 6c 20 4f 73  |   \ original Os|
00004710  62 79 74 65 20 69 6e 64  69 72 65 63 74 69 6f 6e  |byte indirection|
00004720  20 76 65 63 74 6f 72 0d  20 31 38 30 30 20 2e 6c  | vector. 1800 .l|
00004730  61 73 74 62 79 74 65 0d  20 31 38 31 30 20 5d 0d  |astbyte. 1810 ].|
00004740  20 31 38 32 30 20 4e 45  58 54 0d 20 31 38 33 30  | 1820 NEXT. 1830|
00004750  20 2a 4f 50 54 31 2c 32  0d 20 31 38 34 30 20 4f  | *OPT1,2. 1840 O|
00004760  53 43 4c 49 28 22 53 41  56 45 20 53 57 52 4d 49  |SCLI("SAVE SWRMI|
00004770  43 45 20 22 2b 53 54 52  24 7e 28 6d 63 6f 64 65  |CE "+STR$~(mcode|
00004780  29 2b 22 20 2b 20 22 2b  0d 20 20 20 20 20 20 53  |)+" + "+.      S|
00004790  54 52 24 7e 28 6c 61 73  74 62 79 74 65 2d 26 38  |TR$~(lastbyte-&8|
000047a0  30 30 30 29 2b 22 20 46  46 46 46 38 30 30 30 20  |000)+" FFFF8000 |
000047b0  46 46 46 46 38 30 30 30  22 29 0d 20 31 38 35 30  |FFFF8000"). 1850|
000047c0  20 2a 4f 50 54 30 2c 30  0d 0d 0d 20 20 20 31 30  | *OPT0,0...   10|
000047d0  20 52 45 4d 3e 20 53 57  54 45 53 54 0d 20 20 20  | REM> SWTEST.   |
000047e0  32 30 20 4d 4f 44 45 37  0d 20 20 20 33 30 20 6d  |20 MODE7.   30 m|
000047f0  6f 75 73 65 24 3d 43 48  52 24 31 34 31 2b 43 48  |ouse$=CHR$141+CH|
00004800  52 24 31 33 32 2b 43 48  52 24 31 35 37 2b 43 48  |R$132+CHR$157+CH|
00004810  52 24 31 33 31 2b 0d 20  20 20 20 20 20 22 53 57  |R$131+.      "SW|
00004820  52 20 4d 6f 75 73 65 20  63 6f 6f 72 64 73 20 76  |R Mouse coords v|
00004830  69 61 20 41 44 56 41 4c  28 30 2d 34 29 20 20 20  |ia ADVAL(0-4)   |
00004840  22 2b 43 48 52 24 31 35  36 0d 20 20 20 34 30 20  |"+CHR$156.   40 |
00004850  50 52 49 4e 54 54 41 42  28 30 2c 35 29 6d 6f 75  |PRINTTAB(0,5)mou|
00004860  73 65 24 0d 20 20 20 35  30 20 50 52 49 4e 54 54  |se$.   50 PRINTT|
00004870  41 42 28 30 2c 36 29 6d  6f 75 73 65 24 0d 20 20  |AB(0,6)mouse$.  |
00004880  20 36 30 20 4f 4e 45 52  52 4f 52 20 56 44 55 32  | 60 ONERROR VDU2|
00004890  33 2c 31 2c 31 3b 30 3b  30 3b 30 3b 33 31 2c 30  |3,1,1;0;0;0;31,0|
000048a0  2c 32 33 3a 45 4e 44 0d  20 20 20 37 30 20 56 44  |,23:END.   70 VD|
000048b0  55 32 33 2c 31 2c 30 3b  30 3b 30 3b 30 3b 0d 20  |U23,1,0;0;0;0;. |
000048c0  20 20 38 30 20 52 45 50  45 41 54 0d 20 20 20 39  |  80 REPEAT.   9|
000048d0  30 20 61 64 76 61 6c 3d  41 44 56 41 4c 28 30 29  |0 adval=ADVAL(0)|
000048e0  41 4e 44 33 0d 20 20 31  30 30 20 50 52 49 4e 54  |AND3.  100 PRINT|
000048f0  54 41 42 28 31 30 2c 31  31 29 22 41 44 56 41 4c  |TAB(10,11)"ADVAL|
00004900  28 30 29 41 4e 44 33 20  3d 20 22 3b 61 64 76 61  |(0)AND3 = ";adva|
00004910  6c 0d 20 20 31 31 30 20  49 46 20 61 64 76 61 6c  |l.  110 IF adval|
00004920  3d 32 20 50 52 49 4e 54  54 41 42 28 32 32 2c 31  |=2 PRINTTAB(22,1|
00004930  35 29 22 52 69 67 68 74  22 20 45 4c 53 45 20 50  |5)"Right" ELSE P|
00004940  52 49 4e 54 54 41 42 28  32 32 2c 31 35 29 22 20  |RINTTAB(22,15)" |
00004950  20 20 20 20 22 0d 20 20  31 32 30 20 49 46 20 61  |    ".  120 IF a|
00004960  64 76 61 6c 3d 33 20 20  50 52 49 4e 54 54 41 42  |dval=3  PRINTTAB|
00004970  28 31 36 2c 31 35 29 22  42 6f 74 68 22 20 45 4c  |(16,15)"Both" EL|
00004980  53 45 20 50 52 49 4e 54  54 41 42 28 31 36 2c 31  |SE PRINTTAB(16,1|
00004990  35 29 22 20 20 20 20 22  0d 20 20 31 33 30 20 49  |5)"    ".  130 I|
000049a0  46 20 61 64 76 61 6c 3d  31 20 50 52 49 4e 54 54  |F adval=1 PRINTT|
000049b0  41 42 28 31 30 2c 31 35  29 22 4c 65 66 74 22 20  |AB(10,15)"Left" |
000049c0  45 4c 53 45 20 50 52 49  4e 54 54 41 42 28 31 30  |ELSE PRINTTAB(10|
000049d0  2c 31 35 29 22 20 20 20  20 22 0d 20 20 31 34 30  |,15)"    ".  140|
000049e0  20 50 52 49 4e 54 54 41  42 28 32 2c 32 30 29 22  | PRINTTAB(2,20)"|
000049f0  41 44 56 41 4c 28 31 29  20 3d 20 22 3b 41 44 56  |ADVAL(1) = ";ADV|
00004a00  41 4c 28 31 29 3b 22 20  20 20 20 22 0d 20 20 20  |AL(1);"    ".   |
00004a10  20 20 20 54 41 42 28 32  32 2c 32 30 29 22 41 44  |   TAB(22,20)"AD|
00004a20  56 41 4c 28 32 29 20 3d  20 22 3b 41 44 56 41 4c  |VAL(2) = ";ADVAL|
00004a30  28 32 29 3b 22 20 20 20  20 22 0d 20 20 31 35 30  |(2);"    ".  150|
00004a40  20 50 52 49 4e 54 54 41  42 28 32 2c 32 32 29 22  | PRINTTAB(2,22)"|
00004a50  41 44 56 41 4c 28 33 29  20 3d 20 22 3b 41 44 56  |ADVAL(3) = ";ADV|
00004a60  41 4c 28 31 29 3b 22 20  20 20 20 22 0d 20 20 20  |AL(1);"    ".   |
00004a70  20 20 20 54 41 42 28 32  32 2c 32 32 29 22 41 44  |   TAB(22,22)"AD|
00004a80  56 41 4c 28 34 29 20 3d  20 22 3b 41 44 56 41 4c  |VAL(4) = ";ADVAL|
00004a90  28 34 29 3b 22 20 20 20  20 22 0d 20 20 31 36 30  |(4);"    ".  160|
00004aa0  20 55 4e 54 49 4c 20 46  41 4c 53 45 0d 20 20 31  | UNTIL FALSE.  1|
00004ab0  37 30 20 56 44 55 32 33  2c 31 2c 31 3b 30 3b 30  |70 VDU23,1,1;0;0|
00004ac0  3b 30 3b 33 31 2c 30 2c  32 33 0d 20 20 31 38 30  |;0;31,0,23.  180|
00004ad0  20 45 4e 44 0d                                    | END.|
00004ad5
07-01-88/T\MOU06.m0
07-01-88/T\MOU06.m1
07-01-88/T\MOU06.m2
07-01-88/T\MOU06.m4
07-01-88/T\MOU06.m5