Home » Personal collection » Acorn tapes » Electron_User » Electron_User_tape17a_acorn_eu_1990_december.wav » SaveSrc

SaveSrc

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 » Personal collection » Acorn tapes » Electron_User » Electron_User_tape17a_acorn_eu_1990_december.wav
Filename: SaveSrc
Read OK:
File size: 1A94 bytes
Load address: FFFF1A00
Exec address: FFFF8023
Duplicates

There are 2 duplicate copies of this file in the archive:

File contents
   10REM > SaveSrc
   20REM by Zak Kipling
   30REM (c) The Micro User
   40top=&12
   50page=&18
   60block=&70
   70addr=&70
   80userv=&200
   90eventv=&220
  100temp=&AF7
  110interval=&AF9
  120timebuf=&AFB
  130gsinit=&FFC2
  140gsread=&FFC5
  150osfile=&FFDD
  160osword=&FFF1
  170osbyte=&FFF4
  180REM Work out entry point for BASIC in use
  190V%=?(&8000+?&8007+7) AND &0F
  200IF V%=1 THEN entry=&1F
  210IF V%=2 THEN entry=&23
  220IF V%=4 THEN entry=&2B
  230IF V%<1 OR V%=3 OR V%>4 THEN entry=&00
  240FOR I%=0 TO 2 STEP 2
  250P%=&900
  260[OPT I%
  270.init  \ Initialise
  280  \ Check if user and event vectors already set
  290LDA eventv+1
  300CMP #event DIV &100
  310BNE setvecs
  320LDA eventv
  330CMP #event AND &FF
  340BEQ init_time
  350.setvecs  \ If not, set them
  360LDA eventv  \ Save event vector
  370STA oldvec
  380LDA eventv+1
  390STA oldvec+1
  400LDA #event AND &FF  \ Set event vector
  410STA eventv
  420LDA #event DIV &100
  430STA eventv+1
  440LDA userv  \ Save user vector
  450STA oldusr
  460LDA userv+1
  470STA oldusr+1
  480LDA #user AND &FF  \ Set user vector
  490STA userv
  500LDA #user DIV &100
  510STA userv+1
  520.init_time  \ Set time interval
  530LDA #&C0
  540STA interval
  550LDA #&5D
  560STA interval+1
  570.donevecs
  580  \ Load time into interval timer
  590SEC
  600LDA #&00  \ Byte 0 (Least Significant Byte)
  610SBC interval
  620STA timebuf
  630LDA #&00  \ Byte 1
  640SBC interval+1
  650STA timebuf+1
  660LDA #&FF
  670STA timebuf+2  \ Byte 2
  680STA timebuf+3  \ Byte 3
  690STA timebuf+4  \ Byte 4 (Most Significant Byte)
  700LDA #&04  \ Set timer
  710LDY #timebuf DIV &100
  720LDX #timebuf AND &FF
  730JSR osword
  740LDA #&0E  \ Enable event
  750LDX #&05  \ Interval timer crossing zero
  760JMP osbyte
  770.user  \ User vector code
  780CMP #&00  \ Check for *CODE (Save program now/Turn program off)
  790BNE ncode
  800CPX #&01  \ Check if first parameter 1
  810BNE not_off  \ If not, emulate timer event
  820LDA #&0D  \ Disable event
  830LDX #&05  \ Timer event
  840JMP osbyte
  850.not_off \ Emulate timer event
  860LDA #&05  \ If *CODE, act as for timer event
  870JMP event
  880.ncode
  890CMP #&01  \ Check for *LINE
  900BEQ line
  910JMP (oldusr)  \ If not, exit
  920.line  \ Code for *LINE (Set time interval amd enable interrupt)
  930SEI  \ Prevent timer event whilst altering time
  940LDA #&00  \ Set to zero
  950STA interval
  960STA interval+1
  970STX &F2  \ Load command line position into &F2/3, for GSREAD
  980STY &F3
  990LDY #&00  \ Set offset to zero
 1000CLC  \ String ends with space, CR, or second quote mark
 1010JSR gsinit
 1020BNE string  \ If string present, jump to decoding loop
 1030JMP init_time  \ Otherwise, re_initialise to 4 minutes
 1040.string  \ Decoding loop
 1050JSR gsread  \ Get character
 1060BCS end  \ If end of string, leave loop
 1070CMP #&30  \ Check if digit
 1080BCC ndigit
 1090CMP #&3A
 1100BCC digit
 1110.ndigit  \ If not digit:
 1120LDA #&0D  \ Disable event
 1130LDX #&05  \ Timer event
 1140JSR osbyte
 1150CLI  \ Enable interrupts to prevent lock-up
 1160BRK  \ Generate error
 1170EQUB &00  \ Error number
 1180EQUS "Bad digit"  \ Message
 1190EQUB &00  \ Message terminator
 1200.digit  \ If it was a digit:
 1210AND #&0F  \ Convert ASCII code to number
 1220CLC  \ Add digit on to number as Least Significant Digit
 1230ADC interval
 1240STA interval
 1250LDA #&00
 1260ADC interval+1
 1270STA interval+1
 1280JSR tentimes  \ Multiply by ten
 1290JMP string  \ Continue loop
 1300.end  \ Leave loop
 1310JSR tentimes  \ Multiply by ten again to get centiseconds
 1320CLI  \ Enable interrupts now alterations done
 1330JMP donevecs  \ Load into timer
 1340.tentimes  \ x10 subroutine (based on long multiplication):
 1350ASL interval  \ Multiply by two
 1360ROL interval+1
 1370LDA interval  \ Make copy of this number
 1380STA temp
 1390LDA interval+1
 1400STA temp+1
 1410ASL temp  \ Multiply copy by 2 (now original x4)
 1420ROL temp+1
 1430ASL temp  \ Multiply copy by 2 (x8)
 1440ROL temp+1
 1450CLC  \ Add (original x 8) to (original x 2) to get (original x 10)
 1460LDA temp
 1470ADC interval
 1480STA interval
 1490LDA temp+1
 1500ADC interval+1
 1510STA interval+1
 1520RTS
 1530.event  \ Event vector code
 1540PHP
 1550CMP #&05  \ Check if timer event
 1560BEQ timer  \ If it is, then go to main routine
 1570PLP
 1580JMP (oldvec)  \ Otherwise exit
 1590.timer  \ Main routine (Save program)
 1600PHA  \ Save registers
 1610TXA
 1620PHA
 1630TYA
 1640PHA
 1650JSR donevecs  \ Reload interval timer
 1660LDA page  \ Get PAGE and store in pointer
 1670STA addr+1
 1680LDA #&00
 1690STA addr
 1700TAY  \ Offset zero
 1710LDA (addr),Y  \ Check if first byte carraige return
 1720CMP #&0D
 1730BNE exit  \ If not, bad program, so exit
 1740INY  \ Next byte (Line number MSB)
 1750LDA (addr),Y
 1760BMI exit  \ If bit 7 set then empty program, so exit
 1770LDY #&04  \ First byte of actual program line
 1780JSR strip  \ Skip spaces
 1790LDA (addr),Y  \ Get byte
 1800CMP #&F4  \ Check for REM token
 1810BEQ comment  \ If it is, examine rest of line
 1820CMP #&5C  \ check if assembler comment '\'
 1830BNE exit  \ If not, then exit
 1840.comment  \ Examine rest of line and check format
 1850INY  \ Get next non-space character
 1860JSR strip
 1870LDA (addr),Y
 1880CMP #&3E  \ Check if '>'
 1890BNE exit  \ If not, bad format, so exit
 1900INY  \ Next non-space character
 1910JSR strip
 1920LDA (addr),Y
 1930CMP #&0D  \ Check for CR (End of line)
 1940BEQ exit  \ If not then no filename, so exit
 1950CMP #&22  \ Check for <">
 1960BNE nquote
 1970INY  \ Increment pointer to skip quote
 1980.nquote
 1990TYA  \ Add offset to base pointer, so it points to the filename for OSFILE
 2000CLC
 2010ADC addr
 2020STA addr
 2030BCC ncarry
 2040INC addr+1
 2050.ncarry
 2060  \ Set up rest of OSFILE parameter block
 2070LDA page  \ Load address (Byte 1) PAGE
 2080STA block+3
 2090LDX #&00  \ Load address (Byte 0/LSB)
 2100STX block+2
 2110STA block+11  \ Start address (Byte 1) same as load address
 2120STX block+10  \ Start address (Byte 0/LSB)
 2130LDA #entry  \ Execution address (Byte 0/LSB) BASIC rom entry point
 2140STA block+6
 2150LDA #&80  \ Execution address (Byte 1)
 2160STA block+7
 2170LDA top  \ End address (Byte 0/LSB) TOP
 2180STA block+14
 2190LDA top+1  \ End address (Byte 1)
 2200STA block+15
 2210LDA #&FF  \ Machine hi-order address for bytes 2/3 of addresses:
 2220STA block+4  \ Load address (Byte 2)
 2230STA block+5  \ Load address (Byte 3/MSB)
 2240STA block+8  \ Execution address (Byte 2)
 2250STA block+9  \ Execution address (Byte 3/MSB)
 2260STA block+12  \ Start address (Byte 2)
 2270STA block+13  \ Start address (Byte 3/MSB)
 2280STA block+16  \ End address (Byte 2)
 2290STA block+17  \ End address (Byte 3/MSB)
 2300LDY #block DIV &100
 2310LDX #block AND &FF
 2320LDA #&00  \ Save file
 2330JSR osfile
 2340.exit
 2350PLA  \ Retrieve registers
 2360TAY
 2370PLA
 2380TAX
 2390PLA
 2400PLP
 2410RTS
 2420.strip  \ Space skipping subroutine
 2430LDA (addr),Y  \ Get character
 2440CMP #&20  \ Check if space
 2450BNE stripped  \ If not, leave subroutine
 2460INY  \ Next byte
 2470JMP strip  \ Continue loop
 2480.stripped  \ Leave subroutine
 2490RTS
 2500.oldvec BRK:BRK  Dummy
 2510.oldusr BRK:BRK  Dummy
 2520]
 2530NEXT
 2540 PRINT" *SAVE AutoSav FFFF0900+"+STR$~(P%-&900)

� > SaveSrc
� by Zak Kipling
� (c) The Micro User
(top=&12
2page=&18
<
block=&70
Faddr=&70
Puserv=&200
Zeventv=&220
d
temp=&AF7
ninterval=&AF9
xtimebuf=&AFB
�gsinit=&FFC2
�gsread=&FFC5
�osfile=&FFDD
�osword=&FFF1
�osbyte=&FFF4
�+� Work out entry point for BASIC in use
�V%=?(&8000+?&8007+7) � &0F
�� V%=1 � entry=&1F
�� V%=2 � entry=&23
�� V%=4 � entry=&2B
�$� V%<1 � V%=3 � V%>4 � entry=&00
�� I%=0 � 2 � 2
�P%=&900
[OPT I%
.init  \ Initialise
3  \ Check if user and event vectors already set
"LDA eventv+1
,CMP #event � &100
6BNE setvecs
@LDA eventv
JCMP #event � &FF
TBEQ init_time
^ .setvecs  \ If not, set them
h#LDA eventv  \ Save event vector
rSTA oldvec
|LDA eventv+1
�STA oldvec+1
�(LDA #event � &FF  \ Set event vector
�STA eventv
�LDA #event � &100
�STA eventv+1
�!LDA userv  \ Save user vector
�STA oldusr
�LDA userv+1
�STA oldusr+1
�&LDA #user � &FF  \ Set user vector
�
STA userv
�LDA #user � &100
�STA userv+1
#.init_time  \ Set time interval
LDA #&C0
STA interval
&LDA #&5D
0STA interval+1
:
.donevecs
D%  \ Load time into interval timer
NSEC
X/LDA #&00  \ Byte 0 (Least Significant Byte)
bSBC interval
lSTA timebuf
vLDA #&00  \ Byte 1
�SBC interval+1
�STA timebuf+1
�LDA #&FF
�STA timebuf+2  \ Byte 2
�STA timebuf+3  \ Byte 3
�3STA timebuf+4  \ Byte 4 (Most Significant Byte)
�LDA #&04  \ Set timer
�LDY #timebuf � &100
�LDX #timebuf � &FF
�JSR osword
�LDA #&0E  \ Enable event
�,LDX #&05  \ Interval timer crossing zero
�JMP osbyte
.user  \ User vector code
CCMP #&00  \ Check for *CODE (Save program now/Turn program off)

BNE ncode
 *CPX #&01  \ Check if first parameter 1
*.BNE not_off  \ If not, emulate timer event
4LDA #&0D  \ Disable event
>LDX #&05  \ Timer event
HJMP osbyte
R".not_off \ Emulate timer event
\0LDA #&05  \ If *CODE, act as for timer event
f
JMP event
p
.ncode
zCMP #&01  \ Check for *�
�BEQ line
� JMP (oldusr)  \ If not, exit
�A.line  \ Code for *� (Set time interval amd enable interrupt)
�3SEI  \ Prevent timer event whilst altering time
�LDA #&00  \ Set to zero
�STA interval
�STA interval+1
�@STX &F2  \ Load command line position into &F2/3, for GSREAD
�STY &F3
�"LDY #&00  \ Set offset to zero
�;CLC  \ String ends with space, CR, or second quote mark
�JSR gsinit
�:BNE string  \ If string present, jump to decoding loop
:JMP init_time  \ Otherwise, re_initialise to 4 minutes
.string  \ Decoding loop
JSR gsread  \ Get character
$+BCS end  \ If end of string, leave loop
.CMP #&30  \ Check if digit
8BCC ndigit
BCMP #&3A
L
BCC digit
V.ndigit  \ If not digit:
`LDA #&0D  \ Disable event
jLDX #&05  \ Timer event
tJSR osbyte
~/CLI  \ Enable interrupts to prevent lock-up
�BRK  \ Generate error
�EQUB &00  \ Error number
�EQUS "Bad digit"  \ Message
�"EQUB &00  \ Message terminator
� .digit  \ If it was a digit:
�(� #&0F  \ Convert �II code to number
�<CLC  \ Add digit on to number as Least Significant Digit
�ADC interval
�STA interval
�LDA #&00
�ADC interval+1
�STA interval+1
#JSR tentimes  \ Multiply by ten

JMP string  \ Continue loop
.end  \ Leave loop
=JSR tentimes  \ Multiply by ten again to get centiseconds
(1CLI  \ Enable interrupts now alterations done
2#JMP donevecs  \ Load into timer
<?.tentimes  \ x10 subroutine (based on long multiplication):
F#ASL interval  \ Multiply by two
PROL interval+1
Z,LDA interval  \ Make copy of this number
dSTA temp
nLDA interval+1
xSTA temp+1
�4ASL temp  \ Multiply copy by 2 (now original x4)
�ROL temp+1
�'ASL temp  \ Multiply copy by 2 (x8)
�ROL temp+1
�FCLC  \ Add (original x 8) to (original x 2) to get (original x 10)
�LDA temp
�ADC interval
�STA interval
�LDA temp+1
�ADC interval+1
�STA interval+1
�RTS
�.event  \ Event vector code
PHP
$CMP #&05  \ Check if timer event
2BEQ timer  \ If it is, then go to main routine
"PLP
,"JMP (oldvec)  \ Otherwise exit
6).timer  \ Main routine (Save program)
@PHA  \ Save registers
JTXA
TPHA
^TYA
hPHA
r)JSR donevecs  \ Reload interval timer
|*LDA page  \ Get � and store in pointer
�STA addr+1
�LDA #&00
�STA addr
�TAY  \ Offset zero
�7LDA (addr),Y  \ Check if first byte carraige return
�CMP #&0D
�,BNE exit  \ If not, bad program, so exit
�&INY  \ Next byte (Line number MSB)
�LDA (addr),Y
�8BMI exit  \ If bit 7 set then empty program, so exit
�1LDY #&04  \ First byte of actual program line
�JSR strip  \ Skip spaces
�LDA (addr),Y  \ Get byte
!CMP #&F4  \ Check for � token
1BEQ comment  \ If it is, examine rest of line
.CMP #&5C  \ check if assembler comment '\'
&!BNE exit  \ If not, then exit
05.comment  \ Examine rest of line and check format
:'INY  \ Get next non-space character
D
JSR strip
NLDA (addr),Y
XCMP #&3E  \ Check if '>'
b+BNE exit  \ If not, bad format, so exit
l#INY  \ Next non-space character
v
JSR strip
�LDA (addr),Y
�*CMP #&0D  \ Check for CR (End of line)
�0BEQ exit  \ If not then no filename, so exit
�CMP #&22  \ Check for <">
�BNE nquote
�*INY  \ Increment pointer to skip quote
�.nquote
�NTYA  \ Add offset to base pointer, so it points to the filename for OSFILE
�CLC
�ADC addr
�STA addr
�BCC ncarry
�INC addr+1
.ncarry
-  \ Set up rest of OSFILE parameter block
'LDA page  \ Load address (Byte 1) �
 STA block+3
*)LDX #&00  \ Load address (Byte 0/LSB)
4STX block+2
>?STA block+11  \ Start address (Byte 1) same as load address
H.STX block+10  \ Start address (Byte 0/LSB)
RFLDA #entry  \ Execution address (Byte 0/LSB) BASIC rom entry point
\STA block+6
f*LDA #&80  \ Execution address (Byte 1)
pSTA block+7
z*LDA top  \ End address (Byte 0/LSB) �P
�STA block+14
�%LDA top+1  \ End address (Byte 1)
�STA block+15
�DLDA #&FF  \ Machine hi-order address for bytes 2/3 of addresses:
�(STA block+4  \ Load address (Byte 2)
�,STA block+5  \ Load address (Byte 3/MSB)
�-STA block+8  \ Execution address (Byte 2)
�1STA block+9  \ Execution address (Byte 3/MSB)
�*STA block+12  \ Start address (Byte 2)
�.STA block+13  \ Start address (Byte 3/MSB)
�(STA block+16  \ End address (Byte 2)
�,STA block+17  \ End address (Byte 3/MSB)
�LDY #block � &100
	LDX #block � &FF
	LDA #&00  \ Save file
	JSR osfile
	$	.exit
	.PLA  \ Retrieve registers
	8TAY
	BPLA
	LTAX
	VPLA
	`PLP
	jRTS
	t'.strip  \ Space skipping subroutine
	~!LDA (addr),Y  \ Get character
	�CMP #&20  \ Check if space
	�,BNE stripped  \ If not, leave subroutine
	�INY  \ Next byte
	�JMP strip  \ Continue loop
	�!.stripped  \ Leave subroutine
	�RTS
	�.oldvec BRK:BRK  Dummy
	�.oldusr BRK:BRK  Dummy
	�]
	��
	�, �" *SAVE AutoSav FFFF0900+"+�~(P%-&900)
�
00000000  0d 00 0a 0f f4 20 3e 20  53 61 76 65 53 72 63 0d  |..... > SaveSrc.|
00000010  00 14 14 f4 20 62 79 20  5a 61 6b 20 4b 69 70 6c  |.... by Zak Kipl|
00000020  69 6e 67 0d 00 1e 18 f4  20 28 63 29 20 54 68 65  |ing..... (c) The|
00000030  20 4d 69 63 72 6f 20 55  73 65 72 0d 00 28 0b 74  | Micro User..(.t|
00000040  6f 70 3d 26 31 32 0d 00  32 0c 70 61 67 65 3d 26  |op=&12..2.page=&|
00000050  31 38 0d 00 3c 0d 62 6c  6f 63 6b 3d 26 37 30 0d  |18..<.block=&70.|
00000060  00 46 0c 61 64 64 72 3d  26 37 30 0d 00 50 0e 75  |.F.addr=&70..P.u|
00000070  73 65 72 76 3d 26 32 30  30 0d 00 5a 0f 65 76 65  |serv=&200..Z.eve|
00000080  6e 74 76 3d 26 32 32 30  0d 00 64 0d 74 65 6d 70  |ntv=&220..d.temp|
00000090  3d 26 41 46 37 0d 00 6e  11 69 6e 74 65 72 76 61  |=&AF7..n.interva|
000000a0  6c 3d 26 41 46 39 0d 00  78 10 74 69 6d 65 62 75  |l=&AF9..x.timebu|
000000b0  66 3d 26 41 46 42 0d 00  82 10 67 73 69 6e 69 74  |f=&AFB....gsinit|
000000c0  3d 26 46 46 43 32 0d 00  8c 10 67 73 72 65 61 64  |=&FFC2....gsread|
000000d0  3d 26 46 46 43 35 0d 00  96 10 6f 73 66 69 6c 65  |=&FFC5....osfile|
000000e0  3d 26 46 46 44 44 0d 00  a0 10 6f 73 77 6f 72 64  |=&FFDD....osword|
000000f0  3d 26 46 46 46 31 0d 00  aa 10 6f 73 62 79 74 65  |=&FFF1....osbyte|
00000100  3d 26 46 46 46 34 0d 00  b4 2b f4 20 57 6f 72 6b  |=&FFF4...+. Work|
00000110  20 6f 75 74 20 65 6e 74  72 79 20 70 6f 69 6e 74  | out entry point|
00000120  20 66 6f 72 20 42 41 53  49 43 20 69 6e 20 75 73  | for BASIC in us|
00000130  65 0d 00 be 1e 56 25 3d  3f 28 26 38 30 30 30 2b  |e....V%=?(&8000+|
00000140  3f 26 38 30 30 37 2b 37  29 20 80 20 26 30 46 0d  |?&8007+7) . &0F.|
00000150  00 c8 16 e7 20 56 25 3d  31 20 8c 20 65 6e 74 72  |.... V%=1 . entr|
00000160  79 3d 26 31 46 0d 00 d2  16 e7 20 56 25 3d 32 20  |y=&1F..... V%=2 |
00000170  8c 20 65 6e 74 72 79 3d  26 32 33 0d 00 dc 16 e7  |. entry=&23.....|
00000180  20 56 25 3d 34 20 8c 20  65 6e 74 72 79 3d 26 32  | V%=4 . entry=&2|
00000190  42 0d 00 e6 24 e7 20 56  25 3c 31 20 84 20 56 25  |B...$. V%<1 . V%|
000001a0  3d 33 20 84 20 56 25 3e  34 20 8c 20 65 6e 74 72  |=3 . V%>4 . entr|
000001b0  79 3d 26 30 30 0d 00 f0  12 e3 20 49 25 3d 30 20  |y=&00..... I%=0 |
000001c0  b8 20 32 20 88 20 32 0d  00 fa 0b 50 25 3d 26 39  |. 2 . 2....P%=&9|
000001d0  30 30 0d 01 04 0b 5b 4f  50 54 20 49 25 0d 01 0e  |00....[OPT I%...|
000001e0  17 2e 69 6e 69 74 20 20  5c 20 49 6e 69 74 69 61  |..init  \ Initia|
000001f0  6c 69 73 65 0d 01 18 33  20 20 5c 20 43 68 65 63  |lise...3  \ Chec|
00000200  6b 20 69 66 20 75 73 65  72 20 61 6e 64 20 65 76  |k if user and ev|
00000210  65 6e 74 20 76 65 63 74  6f 72 73 20 61 6c 72 65  |ent vectors alre|
00000220  61 64 79 20 73 65 74 0d  01 22 10 4c 44 41 20 65  |ady set..".LDA e|
00000230  76 65 6e 74 76 2b 31 0d  01 2c 15 43 4d 50 20 23  |ventv+1..,.CMP #|
00000240  65 76 65 6e 74 20 81 20  26 31 30 30 0d 01 36 0f  |event . &100..6.|
00000250  42 4e 45 20 73 65 74 76  65 63 73 0d 01 40 0e 4c  |BNE setvecs..@.L|
00000260  44 41 20 65 76 65 6e 74  76 0d 01 4a 14 43 4d 50  |DA eventv..J.CMP|
00000270  20 23 65 76 65 6e 74 20  80 20 26 46 46 0d 01 54  | #event . &FF..T|
00000280  11 42 45 51 20 69 6e 69  74 5f 74 69 6d 65 0d 01  |.BEQ init_time..|
00000290  5e 20 2e 73 65 74 76 65  63 73 20 20 5c 20 49 66  |^ .setvecs  \ If|
000002a0  20 6e 6f 74 2c 20 73 65  74 20 74 68 65 6d 0d 01  | not, set them..|
000002b0  68 23 4c 44 41 20 65 76  65 6e 74 76 20 20 5c 20  |h#LDA eventv  \ |
000002c0  53 61 76 65 20 65 76 65  6e 74 20 76 65 63 74 6f  |Save event vecto|
000002d0  72 0d 01 72 0e 53 54 41  20 6f 6c 64 76 65 63 0d  |r..r.STA oldvec.|
000002e0  01 7c 10 4c 44 41 20 65  76 65 6e 74 76 2b 31 0d  |.|.LDA eventv+1.|
000002f0  01 86 10 53 54 41 20 6f  6c 64 76 65 63 2b 31 0d  |...STA oldvec+1.|
00000300  01 90 28 4c 44 41 20 23  65 76 65 6e 74 20 80 20  |..(LDA #event . |
00000310  26 46 46 20 20 5c 20 53  65 74 20 65 76 65 6e 74  |&FF  \ Set event|
00000320  20 76 65 63 74 6f 72 0d  01 9a 0e 53 54 41 20 65  | vector....STA e|
00000330  76 65 6e 74 76 0d 01 a4  15 4c 44 41 20 23 65 76  |ventv....LDA #ev|
00000340  65 6e 74 20 81 20 26 31  30 30 0d 01 ae 10 53 54  |ent . &100....ST|
00000350  41 20 65 76 65 6e 74 76  2b 31 0d 01 b8 21 4c 44  |A eventv+1...!LD|
00000360  41 20 75 73 65 72 76 20  20 5c 20 53 61 76 65 20  |A userv  \ Save |
00000370  75 73 65 72 20 76 65 63  74 6f 72 0d 01 c2 0e 53  |user vector....S|
00000380  54 41 20 6f 6c 64 75 73  72 0d 01 cc 0f 4c 44 41  |TA oldusr....LDA|
00000390  20 75 73 65 72 76 2b 31  0d 01 d6 10 53 54 41 20  | userv+1....STA |
000003a0  6f 6c 64 75 73 72 2b 31  0d 01 e0 26 4c 44 41 20  |oldusr+1...&LDA |
000003b0  23 75 73 65 72 20 80 20  26 46 46 20 20 5c 20 53  |#user . &FF  \ S|
000003c0  65 74 20 75 73 65 72 20  76 65 63 74 6f 72 0d 01  |et user vector..|
000003d0  ea 0d 53 54 41 20 75 73  65 72 76 0d 01 f4 14 4c  |..STA userv....L|
000003e0  44 41 20 23 75 73 65 72  20 81 20 26 31 30 30 0d  |DA #user . &100.|
000003f0  01 fe 0f 53 54 41 20 75  73 65 72 76 2b 31 0d 02  |...STA userv+1..|
00000400  08 23 2e 69 6e 69 74 5f  74 69 6d 65 20 20 5c 20  |.#.init_time  \ |
00000410  53 65 74 20 74 69 6d 65  20 69 6e 74 65 72 76 61  |Set time interva|
00000420  6c 0d 02 12 0c 4c 44 41  20 23 26 43 30 0d 02 1c  |l....LDA #&C0...|
00000430  10 53 54 41 20 69 6e 74  65 72 76 61 6c 0d 02 26  |.STA interval..&|
00000440  0c 4c 44 41 20 23 26 35  44 0d 02 30 12 53 54 41  |.LDA #&5D..0.STA|
00000450  20 69 6e 74 65 72 76 61  6c 2b 31 0d 02 3a 0d 2e  | interval+1..:..|
00000460  64 6f 6e 65 76 65 63 73  0d 02 44 25 20 20 5c 20  |donevecs..D%  \ |
00000470  4c 6f 61 64 20 74 69 6d  65 20 69 6e 74 6f 20 69  |Load time into i|
00000480  6e 74 65 72 76 61 6c 20  74 69 6d 65 72 0d 02 4e  |nterval timer..N|
00000490  07 53 45 43 0d 02 58 2f  4c 44 41 20 23 26 30 30  |.SEC..X/LDA #&00|
000004a0  20 20 5c 20 42 79 74 65  20 30 20 28 4c 65 61 73  |  \ Byte 0 (Leas|
000004b0  74 20 53 69 67 6e 69 66  69 63 61 6e 74 20 42 79  |t Significant By|
000004c0  74 65 29 0d 02 62 10 53  42 43 20 69 6e 74 65 72  |te)..b.SBC inter|
000004d0  76 61 6c 0d 02 6c 0f 53  54 41 20 74 69 6d 65 62  |val..l.STA timeb|
000004e0  75 66 0d 02 76 16 4c 44  41 20 23 26 30 30 20 20  |uf..v.LDA #&00  |
000004f0  5c 20 42 79 74 65 20 31  0d 02 80 12 53 42 43 20  |\ Byte 1....SBC |
00000500  69 6e 74 65 72 76 61 6c  2b 31 0d 02 8a 11 53 54  |interval+1....ST|
00000510  41 20 74 69 6d 65 62 75  66 2b 31 0d 02 94 0c 4c  |A timebuf+1....L|
00000520  44 41 20 23 26 46 46 0d  02 9e 1b 53 54 41 20 74  |DA #&FF....STA t|
00000530  69 6d 65 62 75 66 2b 32  20 20 5c 20 42 79 74 65  |imebuf+2  \ Byte|
00000540  20 32 0d 02 a8 1b 53 54  41 20 74 69 6d 65 62 75  | 2....STA timebu|
00000550  66 2b 33 20 20 5c 20 42  79 74 65 20 33 0d 02 b2  |f+3  \ Byte 3...|
00000560  33 53 54 41 20 74 69 6d  65 62 75 66 2b 34 20 20  |3STA timebuf+4  |
00000570  5c 20 42 79 74 65 20 34  20 28 4d 6f 73 74 20 53  |\ Byte 4 (Most S|
00000580  69 67 6e 69 66 69 63 61  6e 74 20 42 79 74 65 29  |ignificant Byte)|
00000590  0d 02 bc 19 4c 44 41 20  23 26 30 34 20 20 5c 20  |....LDA #&04  \ |
000005a0  53 65 74 20 74 69 6d 65  72 0d 02 c6 17 4c 44 59  |Set timer....LDY|
000005b0  20 23 74 69 6d 65 62 75  66 20 81 20 26 31 30 30  | #timebuf . &100|
000005c0  0d 02 d0 16 4c 44 58 20  23 74 69 6d 65 62 75 66  |....LDX #timebuf|
000005d0  20 80 20 26 46 46 0d 02  da 0e 4a 53 52 20 6f 73  | . &FF....JSR os|
000005e0  77 6f 72 64 0d 02 e4 1c  4c 44 41 20 23 26 30 45  |word....LDA #&0E|
000005f0  20 20 5c 20 45 6e 61 62  6c 65 20 65 76 65 6e 74  |  \ Enable event|
00000600  0d 02 ee 2c 4c 44 58 20  23 26 30 35 20 20 5c 20  |...,LDX #&05  \ |
00000610  49 6e 74 65 72 76 61 6c  20 74 69 6d 65 72 20 63  |Interval timer c|
00000620  72 6f 73 73 69 6e 67 20  7a 65 72 6f 0d 02 f8 0e  |rossing zero....|
00000630  4a 4d 50 20 6f 73 62 79  74 65 0d 03 02 1d 2e 75  |JMP osbyte.....u|
00000640  73 65 72 20 20 5c 20 55  73 65 72 20 76 65 63 74  |ser  \ User vect|
00000650  6f 72 20 63 6f 64 65 0d  03 0c 43 43 4d 50 20 23  |or code...CCMP #|
00000660  26 30 30 20 20 5c 20 43  68 65 63 6b 20 66 6f 72  |&00  \ Check for|
00000670  20 2a 43 4f 44 45 20 28  53 61 76 65 20 70 72 6f  | *CODE (Save pro|
00000680  67 72 61 6d 20 6e 6f 77  2f 54 75 72 6e 20 70 72  |gram now/Turn pr|
00000690  6f 67 72 61 6d 20 6f 66  66 29 0d 03 16 0d 42 4e  |ogram off)....BN|
000006a0  45 20 6e 63 6f 64 65 0d  03 20 2a 43 50 58 20 23  |E ncode.. *CPX #|
000006b0  26 30 31 20 20 5c 20 43  68 65 63 6b 20 69 66 20  |&01  \ Check if |
000006c0  66 69 72 73 74 20 70 61  72 61 6d 65 74 65 72 20  |first parameter |
000006d0  31 0d 03 2a 2e 42 4e 45  20 6e 6f 74 5f 6f 66 66  |1..*.BNE not_off|
000006e0  20 20 5c 20 49 66 20 6e  6f 74 2c 20 65 6d 75 6c  |  \ If not, emul|
000006f0  61 74 65 20 74 69 6d 65  72 20 65 76 65 6e 74 0d  |ate timer event.|
00000700  03 34 1d 4c 44 41 20 23  26 30 44 20 20 5c 20 44  |.4.LDA #&0D  \ D|
00000710  69 73 61 62 6c 65 20 65  76 65 6e 74 0d 03 3e 1b  |isable event..>.|
00000720  4c 44 58 20 23 26 30 35  20 20 5c 20 54 69 6d 65  |LDX #&05  \ Time|
00000730  72 20 65 76 65 6e 74 0d  03 48 0e 4a 4d 50 20 6f  |r event..H.JMP o|
00000740  73 62 79 74 65 0d 03 52  22 2e 6e 6f 74 5f 6f 66  |sbyte..R".not_of|
00000750  66 20 5c 20 45 6d 75 6c  61 74 65 20 74 69 6d 65  |f \ Emulate time|
00000760  72 20 65 76 65 6e 74 0d  03 5c 30 4c 44 41 20 23  |r event..\0LDA #|
00000770  26 30 35 20 20 5c 20 49  66 20 2a 43 4f 44 45 2c  |&05  \ If *CODE,|
00000780  20 61 63 74 20 61 73 20  66 6f 72 20 74 69 6d 65  | act as for time|
00000790  72 20 65 76 65 6e 74 0d  03 66 0d 4a 4d 50 20 65  |r event..f.JMP e|
000007a0  76 65 6e 74 0d 03 70 0a  2e 6e 63 6f 64 65 0d 03  |vent..p..ncode..|
000007b0  7a 1c 43 4d 50 20 23 26  30 31 20 20 5c 20 43 68  |z.CMP #&01  \ Ch|
000007c0  65 63 6b 20 66 6f 72 20  2a 86 0d 03 84 0c 42 45  |eck for *.....BE|
000007d0  51 20 6c 69 6e 65 0d 03  8e 20 4a 4d 50 20 28 6f  |Q line... JMP (o|
000007e0  6c 64 75 73 72 29 20 20  5c 20 49 66 20 6e 6f 74  |ldusr)  \ If not|
000007f0  2c 20 65 78 69 74 0d 03  98 41 2e 6c 69 6e 65 20  |, exit...A.line |
00000800  20 5c 20 43 6f 64 65 20  66 6f 72 20 2a 86 20 28  | \ Code for *. (|
00000810  53 65 74 20 74 69 6d 65  20 69 6e 74 65 72 76 61  |Set time interva|
00000820  6c 20 61 6d 64 20 65 6e  61 62 6c 65 20 69 6e 74  |l amd enable int|
00000830  65 72 72 75 70 74 29 0d  03 a2 33 53 45 49 20 20  |errupt)...3SEI  |
00000840  5c 20 50 72 65 76 65 6e  74 20 74 69 6d 65 72 20  |\ Prevent timer |
00000850  65 76 65 6e 74 20 77 68  69 6c 73 74 20 61 6c 74  |event whilst alt|
00000860  65 72 69 6e 67 20 74 69  6d 65 0d 03 ac 1b 4c 44  |ering time....LD|
00000870  41 20 23 26 30 30 20 20  5c 20 53 65 74 20 74 6f  |A #&00  \ Set to|
00000880  20 7a 65 72 6f 0d 03 b6  10 53 54 41 20 69 6e 74  | zero....STA int|
00000890  65 72 76 61 6c 0d 03 c0  12 53 54 41 20 69 6e 74  |erval....STA int|
000008a0  65 72 76 61 6c 2b 31 0d  03 ca 40 53 54 58 20 26  |erval+1...@STX &|
000008b0  46 32 20 20 5c 20 4c 6f  61 64 20 63 6f 6d 6d 61  |F2  \ Load comma|
000008c0  6e 64 20 6c 69 6e 65 20  70 6f 73 69 74 69 6f 6e  |nd line position|
000008d0  20 69 6e 74 6f 20 26 46  32 2f 33 2c 20 66 6f 72  | into &F2/3, for|
000008e0  20 47 53 52 45 41 44 0d  03 d4 0b 53 54 59 20 26  | GSREAD....STY &|
000008f0  46 33 0d 03 de 22 4c 44  59 20 23 26 30 30 20 20  |F3..."LDY #&00  |
00000900  5c 20 53 65 74 20 6f 66  66 73 65 74 20 74 6f 20  |\ Set offset to |
00000910  7a 65 72 6f 0d 03 e8 3b  43 4c 43 20 20 5c 20 53  |zero...;CLC  \ S|
00000920  74 72 69 6e 67 20 65 6e  64 73 20 77 69 74 68 20  |tring ends with |
00000930  73 70 61 63 65 2c 20 43  52 2c 20 6f 72 20 73 65  |space, CR, or se|
00000940  63 6f 6e 64 20 71 75 6f  74 65 20 6d 61 72 6b 0d  |cond quote mark.|
00000950  03 f2 0e 4a 53 52 20 67  73 69 6e 69 74 0d 03 fc  |...JSR gsinit...|
00000960  3a 42 4e 45 20 73 74 72  69 6e 67 20 20 5c 20 49  |:BNE string  \ I|
00000970  66 20 73 74 72 69 6e 67  20 70 72 65 73 65 6e 74  |f string present|
00000980  2c 20 6a 75 6d 70 20 74  6f 20 64 65 63 6f 64 69  |, jump to decodi|
00000990  6e 67 20 6c 6f 6f 70 0d  04 06 3a 4a 4d 50 20 69  |ng loop...:JMP i|
000009a0  6e 69 74 5f 74 69 6d 65  20 20 5c 20 4f 74 68 65  |nit_time  \ Othe|
000009b0  72 77 69 73 65 2c 20 72  65 5f 69 6e 69 74 69 61  |rwise, re_initia|
000009c0  6c 69 73 65 20 74 6f 20  34 20 6d 69 6e 75 74 65  |lise to 4 minute|
000009d0  73 0d 04 10 1c 2e 73 74  72 69 6e 67 20 20 5c 20  |s.....string  \ |
000009e0  44 65 63 6f 64 69 6e 67  20 6c 6f 6f 70 0d 04 1a  |Decoding loop...|
000009f0  1f 4a 53 52 20 67 73 72  65 61 64 20 20 5c 20 47  |.JSR gsread  \ G|
00000a00  65 74 20 63 68 61 72 61  63 74 65 72 0d 04 24 2b  |et character..$+|
00000a10  42 43 53 20 65 6e 64 20  20 5c 20 49 66 20 65 6e  |BCS end  \ If en|
00000a20  64 20 6f 66 20 73 74 72  69 6e 67 2c 20 6c 65 61  |d of string, lea|
00000a30  76 65 20 6c 6f 6f 70 0d  04 2e 1e 43 4d 50 20 23  |ve loop....CMP #|
00000a40  26 33 30 20 20 5c 20 43  68 65 63 6b 20 69 66 20  |&30  \ Check if |
00000a50  64 69 67 69 74 0d 04 38  0e 42 43 43 20 6e 64 69  |digit..8.BCC ndi|
00000a60  67 69 74 0d 04 42 0c 43  4d 50 20 23 26 33 41 0d  |git..B.CMP #&3A.|
00000a70  04 4c 0d 42 43 43 20 64  69 67 69 74 0d 04 56 1c  |.L.BCC digit..V.|
00000a80  2e 6e 64 69 67 69 74 20  20 5c 20 49 66 20 6e 6f  |.ndigit  \ If no|
00000a90  74 20 64 69 67 69 74 3a  0d 04 60 1d 4c 44 41 20  |t digit:..`.LDA |
00000aa0  23 26 30 44 20 20 5c 20  44 69 73 61 62 6c 65 20  |#&0D  \ Disable |
00000ab0  65 76 65 6e 74 0d 04 6a  1b 4c 44 58 20 23 26 30  |event..j.LDX #&0|
00000ac0  35 20 20 5c 20 54 69 6d  65 72 20 65 76 65 6e 74  |5  \ Timer event|
00000ad0  0d 04 74 0e 4a 53 52 20  6f 73 62 79 74 65 0d 04  |..t.JSR osbyte..|
00000ae0  7e 2f 43 4c 49 20 20 5c  20 45 6e 61 62 6c 65 20  |~/CLI  \ Enable |
00000af0  69 6e 74 65 72 72 75 70  74 73 20 74 6f 20 70 72  |interrupts to pr|
00000b00  65 76 65 6e 74 20 6c 6f  63 6b 2d 75 70 0d 04 88  |event lock-up...|
00000b10  19 42 52 4b 20 20 5c 20  47 65 6e 65 72 61 74 65  |.BRK  \ Generate|
00000b20  20 65 72 72 6f 72 0d 04  92 1c 45 51 55 42 20 26  | error....EQUB &|
00000b30  30 30 20 20 5c 20 45 72  72 6f 72 20 6e 75 6d 62  |00  \ Error numb|
00000b40  65 72 0d 04 9c 1f 45 51  55 53 20 22 42 61 64 20  |er....EQUS "Bad |
00000b50  64 69 67 69 74 22 20 20  5c 20 4d 65 73 73 61 67  |digit"  \ Messag|
00000b60  65 0d 04 a6 22 45 51 55  42 20 26 30 30 20 20 5c  |e..."EQUB &00  \|
00000b70  20 4d 65 73 73 61 67 65  20 74 65 72 6d 69 6e 61  | Message termina|
00000b80  74 6f 72 0d 04 b0 20 2e  64 69 67 69 74 20 20 5c  |tor... .digit  \|
00000b90  20 49 66 20 69 74 20 77  61 73 20 61 20 64 69 67  | If it was a dig|
00000ba0  69 74 3a 0d 04 ba 28 80  20 23 26 30 46 20 20 5c  |it:...(. #&0F  \|
00000bb0  20 43 6f 6e 76 65 72 74  20 97 49 49 20 63 6f 64  | Convert .II cod|
00000bc0  65 20 74 6f 20 6e 75 6d  62 65 72 0d 04 c4 3c 43  |e to number...<C|
00000bd0  4c 43 20 20 5c 20 41 64  64 20 64 69 67 69 74 20  |LC  \ Add digit |
00000be0  6f 6e 20 74 6f 20 6e 75  6d 62 65 72 20 61 73 20  |on to number as |
00000bf0  4c 65 61 73 74 20 53 69  67 6e 69 66 69 63 61 6e  |Least Significan|
00000c00  74 20 44 69 67 69 74 0d  04 ce 10 41 44 43 20 69  |t Digit....ADC i|
00000c10  6e 74 65 72 76 61 6c 0d  04 d8 10 53 54 41 20 69  |nterval....STA i|
00000c20  6e 74 65 72 76 61 6c 0d  04 e2 0c 4c 44 41 20 23  |nterval....LDA #|
00000c30  26 30 30 0d 04 ec 12 41  44 43 20 69 6e 74 65 72  |&00....ADC inter|
00000c40  76 61 6c 2b 31 0d 04 f6  12 53 54 41 20 69 6e 74  |val+1....STA int|
00000c50  65 72 76 61 6c 2b 31 0d  05 00 23 4a 53 52 20 74  |erval+1...#JSR t|
00000c60  65 6e 74 69 6d 65 73 20  20 5c 20 4d 75 6c 74 69  |entimes  \ Multi|
00000c70  70 6c 79 20 62 79 20 74  65 6e 0d 05 0a 1f 4a 4d  |ply by ten....JM|
00000c80  50 20 73 74 72 69 6e 67  20 20 5c 20 43 6f 6e 74  |P string  \ Cont|
00000c90  69 6e 75 65 20 6c 6f 6f  70 0d 05 14 16 2e 65 6e  |inue loop.....en|
00000ca0  64 20 20 5c 20 4c 65 61  76 65 20 6c 6f 6f 70 0d  |d  \ Leave loop.|
00000cb0  05 1e 3d 4a 53 52 20 74  65 6e 74 69 6d 65 73 20  |..=JSR tentimes |
00000cc0  20 5c 20 4d 75 6c 74 69  70 6c 79 20 62 79 20 74  | \ Multiply by t|
00000cd0  65 6e 20 61 67 61 69 6e  20 74 6f 20 67 65 74 20  |en again to get |
00000ce0  63 65 6e 74 69 73 65 63  6f 6e 64 73 0d 05 28 31  |centiseconds..(1|
00000cf0  43 4c 49 20 20 5c 20 45  6e 61 62 6c 65 20 69 6e  |CLI  \ Enable in|
00000d00  74 65 72 72 75 70 74 73  20 6e 6f 77 20 61 6c 74  |terrupts now alt|
00000d10  65 72 61 74 69 6f 6e 73  20 64 6f 6e 65 0d 05 32  |erations done..2|
00000d20  23 4a 4d 50 20 64 6f 6e  65 76 65 63 73 20 20 5c  |#JMP donevecs  \|
00000d30  20 4c 6f 61 64 20 69 6e  74 6f 20 74 69 6d 65 72  | Load into timer|
00000d40  0d 05 3c 3f 2e 74 65 6e  74 69 6d 65 73 20 20 5c  |..<?.tentimes  \|
00000d50  20 78 31 30 20 73 75 62  72 6f 75 74 69 6e 65 20  | x10 subroutine |
00000d60  28 62 61 73 65 64 20 6f  6e 20 6c 6f 6e 67 20 6d  |(based on long m|
00000d70  75 6c 74 69 70 6c 69 63  61 74 69 6f 6e 29 3a 0d  |ultiplication):.|
00000d80  05 46 23 41 53 4c 20 69  6e 74 65 72 76 61 6c 20  |.F#ASL interval |
00000d90  20 5c 20 4d 75 6c 74 69  70 6c 79 20 62 79 20 74  | \ Multiply by t|
00000da0  77 6f 0d 05 50 12 52 4f  4c 20 69 6e 74 65 72 76  |wo..P.ROL interv|
00000db0  61 6c 2b 31 0d 05 5a 2c  4c 44 41 20 69 6e 74 65  |al+1..Z,LDA inte|
00000dc0  72 76 61 6c 20 20 5c 20  4d 61 6b 65 20 63 6f 70  |rval  \ Make cop|
00000dd0  79 20 6f 66 20 74 68 69  73 20 6e 75 6d 62 65 72  |y of this number|
00000de0  0d 05 64 0c 53 54 41 20  74 65 6d 70 0d 05 6e 12  |..d.STA temp..n.|
00000df0  4c 44 41 20 69 6e 74 65  72 76 61 6c 2b 31 0d 05  |LDA interval+1..|
00000e00  78 0e 53 54 41 20 74 65  6d 70 2b 31 0d 05 82 34  |x.STA temp+1...4|
00000e10  41 53 4c 20 74 65 6d 70  20 20 5c 20 4d 75 6c 74  |ASL temp  \ Mult|
00000e20  69 70 6c 79 20 63 6f 70  79 20 62 79 20 32 20 28  |iply copy by 2 (|
00000e30  6e 6f 77 20 6f 72 69 67  69 6e 61 6c 20 78 34 29  |now original x4)|
00000e40  0d 05 8c 0e 52 4f 4c 20  74 65 6d 70 2b 31 0d 05  |....ROL temp+1..|
00000e50  96 27 41 53 4c 20 74 65  6d 70 20 20 5c 20 4d 75  |.'ASL temp  \ Mu|
00000e60  6c 74 69 70 6c 79 20 63  6f 70 79 20 62 79 20 32  |ltiply copy by 2|
00000e70  20 28 78 38 29 0d 05 a0  0e 52 4f 4c 20 74 65 6d  | (x8)....ROL tem|
00000e80  70 2b 31 0d 05 aa 46 43  4c 43 20 20 5c 20 41 64  |p+1...FCLC  \ Ad|
00000e90  64 20 28 6f 72 69 67 69  6e 61 6c 20 78 20 38 29  |d (original x 8)|
00000ea0  20 74 6f 20 28 6f 72 69  67 69 6e 61 6c 20 78 20  | to (original x |
00000eb0  32 29 20 74 6f 20 67 65  74 20 28 6f 72 69 67 69  |2) to get (origi|
00000ec0  6e 61 6c 20 78 20 31 30  29 0d 05 b4 0c 4c 44 41  |nal x 10)....LDA|
00000ed0  20 74 65 6d 70 0d 05 be  10 41 44 43 20 69 6e 74  | temp....ADC int|
00000ee0  65 72 76 61 6c 0d 05 c8  10 53 54 41 20 69 6e 74  |erval....STA int|
00000ef0  65 72 76 61 6c 0d 05 d2  0e 4c 44 41 20 74 65 6d  |erval....LDA tem|
00000f00  70 2b 31 0d 05 dc 12 41  44 43 20 69 6e 74 65 72  |p+1....ADC inter|
00000f10  76 61 6c 2b 31 0d 05 e6  12 53 54 41 20 69 6e 74  |val+1....STA int|
00000f20  65 72 76 61 6c 2b 31 0d  05 f0 07 52 54 53 0d 05  |erval+1....RTS..|
00000f30  fa 1f 2e 65 76 65 6e 74  20 20 5c 20 45 76 65 6e  |...event  \ Even|
00000f40  74 20 76 65 63 74 6f 72  20 63 6f 64 65 0d 06 04  |t vector code...|
00000f50  07 50 48 50 0d 06 0e 24  43 4d 50 20 23 26 30 35  |.PHP...$CMP #&05|
00000f60  20 20 5c 20 43 68 65 63  6b 20 69 66 20 74 69 6d  |  \ Check if tim|
00000f70  65 72 20 65 76 65 6e 74  0d 06 18 32 42 45 51 20  |er event...2BEQ |
00000f80  74 69 6d 65 72 20 20 5c  20 49 66 20 69 74 20 69  |timer  \ If it i|
00000f90  73 2c 20 74 68 65 6e 20  67 6f 20 74 6f 20 6d 61  |s, then go to ma|
00000fa0  69 6e 20 72 6f 75 74 69  6e 65 0d 06 22 07 50 4c  |in routine..".PL|
00000fb0  50 0d 06 2c 22 4a 4d 50  20 28 6f 6c 64 76 65 63  |P..,"JMP (oldvec|
00000fc0  29 20 20 5c 20 4f 74 68  65 72 77 69 73 65 20 65  |)  \ Otherwise e|
00000fd0  78 69 74 0d 06 36 29 2e  74 69 6d 65 72 20 20 5c  |xit..6).timer  \|
00000fe0  20 4d 61 69 6e 20 72 6f  75 74 69 6e 65 20 28 53  | Main routine (S|
00000ff0  61 76 65 20 70 72 6f 67  72 61 6d 29 0d 06 40 19  |ave program)..@.|
00001000  50 48 41 20 20 5c 20 53  61 76 65 20 72 65 67 69  |PHA  \ Save regi|
00001010  73 74 65 72 73 0d 06 4a  07 54 58 41 0d 06 54 07  |sters..J.TXA..T.|
00001020  50 48 41 0d 06 5e 07 54  59 41 0d 06 68 07 50 48  |PHA..^.TYA..h.PH|
00001030  41 0d 06 72 29 4a 53 52  20 64 6f 6e 65 76 65 63  |A..r)JSR donevec|
00001040  73 20 20 5c 20 52 65 6c  6f 61 64 20 69 6e 74 65  |s  \ Reload inte|
00001050  72 76 61 6c 20 74 69 6d  65 72 0d 06 7c 2a 4c 44  |rval timer..|*LD|
00001060  41 20 70 61 67 65 20 20  5c 20 47 65 74 20 90 20  |A page  \ Get . |
00001070  61 6e 64 20 73 74 6f 72  65 20 69 6e 20 70 6f 69  |and store in poi|
00001080  6e 74 65 72 0d 06 86 0e  53 54 41 20 61 64 64 72  |nter....STA addr|
00001090  2b 31 0d 06 90 0c 4c 44  41 20 23 26 30 30 0d 06  |+1....LDA #&00..|
000010a0  9a 0c 53 54 41 20 61 64  64 72 0d 06 a4 16 54 41  |..STA addr....TA|
000010b0  59 20 20 5c 20 4f 66 66  73 65 74 20 7a 65 72 6f  |Y  \ Offset zero|
000010c0  0d 06 ae 37 4c 44 41 20  28 61 64 64 72 29 2c 59  |...7LDA (addr),Y|
000010d0  20 20 5c 20 43 68 65 63  6b 20 69 66 20 66 69 72  |  \ Check if fir|
000010e0  73 74 20 62 79 74 65 20  63 61 72 72 61 69 67 65  |st byte carraige|
000010f0  20 72 65 74 75 72 6e 0d  06 b8 0c 43 4d 50 20 23  | return....CMP #|
00001100  26 30 44 0d 06 c2 2c 42  4e 45 20 65 78 69 74 20  |&0D...,BNE exit |
00001110  20 5c 20 49 66 20 6e 6f  74 2c 20 62 61 64 20 70  | \ If not, bad p|
00001120  72 6f 67 72 61 6d 2c 20  73 6f 20 65 78 69 74 0d  |rogram, so exit.|
00001130  06 cc 26 49 4e 59 20 20  5c 20 4e 65 78 74 20 62  |..&INY  \ Next b|
00001140  79 74 65 20 28 4c 69 6e  65 20 6e 75 6d 62 65 72  |yte (Line number|
00001150  20 4d 53 42 29 0d 06 d6  10 4c 44 41 20 28 61 64  | MSB)....LDA (ad|
00001160  64 72 29 2c 59 0d 06 e0  38 42 4d 49 20 65 78 69  |dr),Y...8BMI exi|
00001170  74 20 20 5c 20 49 66 20  62 69 74 20 37 20 73 65  |t  \ If bit 7 se|
00001180  74 20 74 68 65 6e 20 65  6d 70 74 79 20 70 72 6f  |t then empty pro|
00001190  67 72 61 6d 2c 20 73 6f  20 65 78 69 74 0d 06 ea  |gram, so exit...|
000011a0  31 4c 44 59 20 23 26 30  34 20 20 5c 20 46 69 72  |1LDY #&04  \ Fir|
000011b0  73 74 20 62 79 74 65 20  6f 66 20 61 63 74 75 61  |st byte of actua|
000011c0  6c 20 70 72 6f 67 72 61  6d 20 6c 69 6e 65 0d 06  |l program line..|
000011d0  f4 1c 4a 53 52 20 73 74  72 69 70 20 20 5c 20 53  |..JSR strip  \ S|
000011e0  6b 69 70 20 73 70 61 63  65 73 0d 06 fe 1c 4c 44  |kip spaces....LD|
000011f0  41 20 28 61 64 64 72 29  2c 59 20 20 5c 20 47 65  |A (addr),Y  \ Ge|
00001200  74 20 62 79 74 65 0d 07  08 21 43 4d 50 20 23 26  |t byte...!CMP #&|
00001210  46 34 20 20 5c 20 43 68  65 63 6b 20 66 6f 72 20  |F4  \ Check for |
00001220  f4 20 74 6f 6b 65 6e 0d  07 12 31 42 45 51 20 63  |. token...1BEQ c|
00001230  6f 6d 6d 65 6e 74 20 20  5c 20 49 66 20 69 74 20  |omment  \ If it |
00001240  69 73 2c 20 65 78 61 6d  69 6e 65 20 72 65 73 74  |is, examine rest|
00001250  20 6f 66 20 6c 69 6e 65  0d 07 1c 2e 43 4d 50 20  | of line....CMP |
00001260  23 26 35 43 20 20 5c 20  63 68 65 63 6b 20 69 66  |#&5C  \ check if|
00001270  20 61 73 73 65 6d 62 6c  65 72 20 63 6f 6d 6d 65  | assembler comme|
00001280  6e 74 20 27 5c 27 0d 07  26 21 42 4e 45 20 65 78  |nt '\'..&!BNE ex|
00001290  69 74 20 20 5c 20 49 66  20 6e 6f 74 2c 20 74 68  |it  \ If not, th|
000012a0  65 6e 20 65 78 69 74 0d  07 30 35 2e 63 6f 6d 6d  |en exit..05.comm|
000012b0  65 6e 74 20 20 5c 20 45  78 61 6d 69 6e 65 20 72  |ent  \ Examine r|
000012c0  65 73 74 20 6f 66 20 6c  69 6e 65 20 61 6e 64 20  |est of line and |
000012d0  63 68 65 63 6b 20 66 6f  72 6d 61 74 0d 07 3a 27  |check format..:'|
000012e0  49 4e 59 20 20 5c 20 47  65 74 20 6e 65 78 74 20  |INY  \ Get next |
000012f0  6e 6f 6e 2d 73 70 61 63  65 20 63 68 61 72 61 63  |non-space charac|
00001300  74 65 72 0d 07 44 0d 4a  53 52 20 73 74 72 69 70  |ter..D.JSR strip|
00001310  0d 07 4e 10 4c 44 41 20  28 61 64 64 72 29 2c 59  |..N.LDA (addr),Y|
00001320  0d 07 58 1c 43 4d 50 20  23 26 33 45 20 20 5c 20  |..X.CMP #&3E  \ |
00001330  43 68 65 63 6b 20 69 66  20 27 3e 27 0d 07 62 2b  |Check if '>'..b+|
00001340  42 4e 45 20 65 78 69 74  20 20 5c 20 49 66 20 6e  |BNE exit  \ If n|
00001350  6f 74 2c 20 62 61 64 20  66 6f 72 6d 61 74 2c 20  |ot, bad format, |
00001360  73 6f 20 65 78 69 74 0d  07 6c 23 49 4e 59 20 20  |so exit..l#INY  |
00001370  5c 20 4e 65 78 74 20 6e  6f 6e 2d 73 70 61 63 65  |\ Next non-space|
00001380  20 63 68 61 72 61 63 74  65 72 0d 07 76 0d 4a 53  | character..v.JS|
00001390  52 20 73 74 72 69 70 0d  07 80 10 4c 44 41 20 28  |R strip....LDA (|
000013a0  61 64 64 72 29 2c 59 0d  07 8a 2a 43 4d 50 20 23  |addr),Y...*CMP #|
000013b0  26 30 44 20 20 5c 20 43  68 65 63 6b 20 66 6f 72  |&0D  \ Check for|
000013c0  20 43 52 20 28 45 6e 64  20 6f 66 20 6c 69 6e 65  | CR (End of line|
000013d0  29 0d 07 94 30 42 45 51  20 65 78 69 74 20 20 5c  |)...0BEQ exit  \|
000013e0  20 49 66 20 6e 6f 74 20  74 68 65 6e 20 6e 6f 20  | If not then no |
000013f0  66 69 6c 65 6e 61 6d 65  2c 20 73 6f 20 65 78 69  |filename, so exi|
00001400  74 0d 07 9e 1d 43 4d 50  20 23 26 32 32 20 20 5c  |t....CMP #&22  \|
00001410  20 43 68 65 63 6b 20 66  6f 72 20 3c 22 3e 0d 07  | Check for <">..|
00001420  a8 0e 42 4e 45 20 6e 71  75 6f 74 65 0d 07 b2 2a  |..BNE nquote...*|
00001430  49 4e 59 20 20 5c 20 49  6e 63 72 65 6d 65 6e 74  |INY  \ Increment|
00001440  20 70 6f 69 6e 74 65 72  20 74 6f 20 73 6b 69 70  | pointer to skip|
00001450  20 71 75 6f 74 65 0d 07  bc 0b 2e 6e 71 75 6f 74  | quote.....nquot|
00001460  65 0d 07 c6 4e 54 59 41  20 20 5c 20 41 64 64 20  |e...NTYA  \ Add |
00001470  6f 66 66 73 65 74 20 74  6f 20 62 61 73 65 20 70  |offset to base p|
00001480  6f 69 6e 74 65 72 2c 20  73 6f 20 69 74 20 70 6f  |ointer, so it po|
00001490  69 6e 74 73 20 74 6f 20  74 68 65 20 66 69 6c 65  |ints to the file|
000014a0  6e 61 6d 65 20 66 6f 72  20 4f 53 46 49 4c 45 0d  |name for OSFILE.|
000014b0  07 d0 07 43 4c 43 0d 07  da 0c 41 44 43 20 61 64  |...CLC....ADC ad|
000014c0  64 72 0d 07 e4 0c 53 54  41 20 61 64 64 72 0d 07  |dr....STA addr..|
000014d0  ee 0e 42 43 43 20 6e 63  61 72 72 79 0d 07 f8 0e  |..BCC ncarry....|
000014e0  49 4e 43 20 61 64 64 72  2b 31 0d 08 02 0b 2e 6e  |INC addr+1.....n|
000014f0  63 61 72 72 79 0d 08 0c  2d 20 20 5c 20 53 65 74  |carry...-  \ Set|
00001500  20 75 70 20 72 65 73 74  20 6f 66 20 4f 53 46 49  | up rest of OSFI|
00001510  4c 45 20 70 61 72 61 6d  65 74 65 72 20 62 6c 6f  |LE parameter blo|
00001520  63 6b 0d 08 16 27 4c 44  41 20 70 61 67 65 20 20  |ck...'LDA page  |
00001530  5c 20 4c 6f 61 64 20 61  64 64 72 65 73 73 20 28  |\ Load address (|
00001540  42 79 74 65 20 31 29 20  90 0d 08 20 0f 53 54 41  |Byte 1) ... .STA|
00001550  20 62 6c 6f 63 6b 2b 33  0d 08 2a 29 4c 44 58 20  | block+3..*)LDX |
00001560  23 26 30 30 20 20 5c 20  4c 6f 61 64 20 61 64 64  |#&00  \ Load add|
00001570  72 65 73 73 20 28 42 79  74 65 20 30 2f 4c 53 42  |ress (Byte 0/LSB|
00001580  29 0d 08 34 0f 53 54 58  20 62 6c 6f 63 6b 2b 32  |)..4.STX block+2|
00001590  0d 08 3e 3f 53 54 41 20  62 6c 6f 63 6b 2b 31 31  |..>?STA block+11|
000015a0  20 20 5c 20 53 74 61 72  74 20 61 64 64 72 65 73  |  \ Start addres|
000015b0  73 20 28 42 79 74 65 20  31 29 20 73 61 6d 65 20  |s (Byte 1) same |
000015c0  61 73 20 6c 6f 61 64 20  61 64 64 72 65 73 73 0d  |as load address.|
000015d0  08 48 2e 53 54 58 20 62  6c 6f 63 6b 2b 31 30 20  |.H.STX block+10 |
000015e0  20 5c 20 53 74 61 72 74  20 61 64 64 72 65 73 73  | \ Start address|
000015f0  20 28 42 79 74 65 20 30  2f 4c 53 42 29 0d 08 52  | (Byte 0/LSB)..R|
00001600  46 4c 44 41 20 23 65 6e  74 72 79 20 20 5c 20 45  |FLDA #entry  \ E|
00001610  78 65 63 75 74 69 6f 6e  20 61 64 64 72 65 73 73  |xecution address|
00001620  20 28 42 79 74 65 20 30  2f 4c 53 42 29 20 42 41  | (Byte 0/LSB) BA|
00001630  53 49 43 20 72 6f 6d 20  65 6e 74 72 79 20 70 6f  |SIC rom entry po|
00001640  69 6e 74 0d 08 5c 0f 53  54 41 20 62 6c 6f 63 6b  |int..\.STA block|
00001650  2b 36 0d 08 66 2a 4c 44  41 20 23 26 38 30 20 20  |+6..f*LDA #&80  |
00001660  5c 20 45 78 65 63 75 74  69 6f 6e 20 61 64 64 72  |\ Execution addr|
00001670  65 73 73 20 28 42 79 74  65 20 31 29 0d 08 70 0f  |ess (Byte 1)..p.|
00001680  53 54 41 20 62 6c 6f 63  6b 2b 37 0d 08 7a 2a 4c  |STA block+7..z*L|
00001690  44 41 20 74 6f 70 20 20  5c 20 45 6e 64 20 61 64  |DA top  \ End ad|
000016a0  64 72 65 73 73 20 28 42  79 74 65 20 30 2f 4c 53  |dress (Byte 0/LS|
000016b0  42 29 20 b8 50 0d 08 84  10 53 54 41 20 62 6c 6f  |B) .P....STA blo|
000016c0  63 6b 2b 31 34 0d 08 8e  25 4c 44 41 20 74 6f 70  |ck+14...%LDA top|
000016d0  2b 31 20 20 5c 20 45 6e  64 20 61 64 64 72 65 73  |+1  \ End addres|
000016e0  73 20 28 42 79 74 65 20  31 29 0d 08 98 10 53 54  |s (Byte 1)....ST|
000016f0  41 20 62 6c 6f 63 6b 2b  31 35 0d 08 a2 44 4c 44  |A block+15...DLD|
00001700  41 20 23 26 46 46 20 20  5c 20 4d 61 63 68 69 6e  |A #&FF  \ Machin|
00001710  65 20 68 69 2d 6f 72 64  65 72 20 61 64 64 72 65  |e hi-order addre|
00001720  73 73 20 66 6f 72 20 62  79 74 65 73 20 32 2f 33  |ss for bytes 2/3|
00001730  20 6f 66 20 61 64 64 72  65 73 73 65 73 3a 0d 08  | of addresses:..|
00001740  ac 28 53 54 41 20 62 6c  6f 63 6b 2b 34 20 20 5c  |.(STA block+4  \|
00001750  20 4c 6f 61 64 20 61 64  64 72 65 73 73 20 28 42  | Load address (B|
00001760  79 74 65 20 32 29 0d 08  b6 2c 53 54 41 20 62 6c  |yte 2)...,STA bl|
00001770  6f 63 6b 2b 35 20 20 5c  20 4c 6f 61 64 20 61 64  |ock+5  \ Load ad|
00001780  64 72 65 73 73 20 28 42  79 74 65 20 33 2f 4d 53  |dress (Byte 3/MS|
00001790  42 29 0d 08 c0 2d 53 54  41 20 62 6c 6f 63 6b 2b  |B)...-STA block+|
000017a0  38 20 20 5c 20 45 78 65  63 75 74 69 6f 6e 20 61  |8  \ Execution a|
000017b0  64 64 72 65 73 73 20 28  42 79 74 65 20 32 29 0d  |ddress (Byte 2).|
000017c0  08 ca 31 53 54 41 20 62  6c 6f 63 6b 2b 39 20 20  |..1STA block+9  |
000017d0  5c 20 45 78 65 63 75 74  69 6f 6e 20 61 64 64 72  |\ Execution addr|
000017e0  65 73 73 20 28 42 79 74  65 20 33 2f 4d 53 42 29  |ess (Byte 3/MSB)|
000017f0  0d 08 d4 2a 53 54 41 20  62 6c 6f 63 6b 2b 31 32  |...*STA block+12|
00001800  20 20 5c 20 53 74 61 72  74 20 61 64 64 72 65 73  |  \ Start addres|
00001810  73 20 28 42 79 74 65 20  32 29 0d 08 de 2e 53 54  |s (Byte 2)....ST|
00001820  41 20 62 6c 6f 63 6b 2b  31 33 20 20 5c 20 53 74  |A block+13  \ St|
00001830  61 72 74 20 61 64 64 72  65 73 73 20 28 42 79 74  |art address (Byt|
00001840  65 20 33 2f 4d 53 42 29  0d 08 e8 28 53 54 41 20  |e 3/MSB)...(STA |
00001850  62 6c 6f 63 6b 2b 31 36  20 20 5c 20 45 6e 64 20  |block+16  \ End |
00001860  61 64 64 72 65 73 73 20  28 42 79 74 65 20 32 29  |address (Byte 2)|
00001870  0d 08 f2 2c 53 54 41 20  62 6c 6f 63 6b 2b 31 37  |...,STA block+17|
00001880  20 20 5c 20 45 6e 64 20  61 64 64 72 65 73 73 20  |  \ End address |
00001890  28 42 79 74 65 20 33 2f  4d 53 42 29 0d 08 fc 15  |(Byte 3/MSB)....|
000018a0  4c 44 59 20 23 62 6c 6f  63 6b 20 81 20 26 31 30  |LDY #block . &10|
000018b0  30 0d 09 06 14 4c 44 58  20 23 62 6c 6f 63 6b 20  |0....LDX #block |
000018c0  80 20 26 46 46 0d 09 10  19 4c 44 41 20 23 26 30  |. &FF....LDA #&0|
000018d0  30 20 20 5c 20 53 61 76  65 20 66 69 6c 65 0d 09  |0  \ Save file..|
000018e0  1a 0e 4a 53 52 20 6f 73  66 69 6c 65 0d 09 24 09  |..JSR osfile..$.|
000018f0  2e 65 78 69 74 0d 09 2e  1d 50 4c 41 20 20 5c 20  |.exit....PLA  \ |
00001900  52 65 74 72 69 65 76 65  20 72 65 67 69 73 74 65  |Retrieve registe|
00001910  72 73 0d 09 38 07 54 41  59 0d 09 42 07 50 4c 41  |rs..8.TAY..B.PLA|
00001920  0d 09 4c 07 54 41 58 0d  09 56 07 50 4c 41 0d 09  |..L.TAX..V.PLA..|
00001930  60 07 50 4c 50 0d 09 6a  07 52 54 53 0d 09 74 27  |`.PLP..j.RTS..t'|
00001940  2e 73 74 72 69 70 20 20  5c 20 53 70 61 63 65 20  |.strip  \ Space |
00001950  73 6b 69 70 70 69 6e 67  20 73 75 62 72 6f 75 74  |skipping subrout|
00001960  69 6e 65 0d 09 7e 21 4c  44 41 20 28 61 64 64 72  |ine..~!LDA (addr|
00001970  29 2c 59 20 20 5c 20 47  65 74 20 63 68 61 72 61  |),Y  \ Get chara|
00001980  63 74 65 72 0d 09 88 1e  43 4d 50 20 23 26 32 30  |cter....CMP #&20|
00001990  20 20 5c 20 43 68 65 63  6b 20 69 66 20 73 70 61  |  \ Check if spa|
000019a0  63 65 0d 09 92 2c 42 4e  45 20 73 74 72 69 70 70  |ce...,BNE stripp|
000019b0  65 64 20 20 5c 20 49 66  20 6e 6f 74 2c 20 6c 65  |ed  \ If not, le|
000019c0  61 76 65 20 73 75 62 72  6f 75 74 69 6e 65 0d 09  |ave subroutine..|
000019d0  9c 14 49 4e 59 20 20 5c  20 4e 65 78 74 20 62 79  |..INY  \ Next by|
000019e0  74 65 0d 09 a6 1e 4a 4d  50 20 73 74 72 69 70 20  |te....JMP strip |
000019f0  20 5c 20 43 6f 6e 74 69  6e 75 65 20 6c 6f 6f 70  | \ Continue loop|
00001a00  0d 09 b0 21 2e 73 74 72  69 70 70 65 64 20 20 5c  |...!.stripped  \|
00001a10  20 4c 65 61 76 65 20 73  75 62 72 6f 75 74 69 6e  | Leave subroutin|
00001a20  65 0d 09 ba 07 52 54 53  0d 09 c4 1a 2e 6f 6c 64  |e....RTS.....old|
00001a30  76 65 63 20 42 52 4b 3a  42 52 4b 20 20 44 75 6d  |vec BRK:BRK  Dum|
00001a40  6d 79 0d 09 ce 1a 2e 6f  6c 64 75 73 72 20 42 52  |my.....oldusr BR|
00001a50  4b 3a 42 52 4b 20 20 44  75 6d 6d 79 0d 09 d8 05  |K:BRK  Dummy....|
00001a60  5d 0d 09 e2 05 ed 0d 09  ec 2c 20 f1 22 20 2a 53  |]........, ." *S|
00001a70  41 56 45 20 41 75 74 6f  53 61 76 20 46 46 46 46  |AVE AutoSav FFFF|
00001a80  30 39 30 30 2b 22 2b c3  7e 28 50 25 2d 26 39 30  |0900+"+.~(P%-&90|
00001a90  30 29 0d ff                                       |0)..|
00001a94
SaveSrc.m0
SaveSrc.m1
SaveSrc.m2
SaveSrc.m4
SaveSrc.m5