Home » CEEFAX disks » telesoftware1.adl » Utils/LEARNER

Utils/LEARNER

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 » telesoftware1.adl
Filename: Utils/LEARNER
Read OK:
File size: 0893 bytes
Load address: 1900
Exec address: 8023
Duplicates

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

File contents
   10REM LEARN  by Andy Verwer
   20REM For Wordwise or View
   30REM (c) The Micro User
   40REM Detects a keypress event
   50REM CTRL L - enter learn mode
   60REM CTRL X - leave learn mode
   70REM or if not in learn mode
   80REM execute sequence.
   90osbyte=&FFF4
  100evntv=&220
  110code=&A00:buff=&C00
  120true=&FF:false=0
  130FOR pass%=0TO2STEP2
  140P%=code
  150[OPT pass%
  160.initialise
  170LDA evntv    \Set up event vector
  180STA evold
  190LDA evntv+1
  200STA evold+1
  210LDA #entry MOD&100
  220STA evntv
  230LDA #entry DIV&100
  240STA evntv+1
  250LDA #14      \Enable event 2
  260LDX #2
  270JMP osbyte
  280.entry
  290PHP:PHA      \Save P & A registers
  300CMP #2       \Keypress event ?
  310BEQ event2
  320PLA:PLP      \No, retrieve P & A and
  330JMP (evold)  \Jump to old event vector
  340.event2      \Yes, save remaining registers
  350TXA:PHA:TYA:PHA
  360LDX #0
  370LDA #&91
  380JSR osbyte   \Get chr from buffer
  390TYA
  400CMP #&0C     \Is it CTRL L ?
  410BNE noCTLL
  420LDX #true    \Yes, enter learn mode
  430STX lrnflg
  440LDX #0       \Reset buffer count
  450STX count
  460CLC:BCC return
  470.noCTLL
  480CMP #&18     \Is it CTRL X ?
  490BNE noCTLX
  500LDA lrnflg   \Yes, now check learn mode
  510CMP #true
  520BNE nolrnflg \Not in learn mode
  530LDA #false   \Leave learn mode
  540STA lrnflg
  550CLC:BCC return
  560.nolrnflg
  570LDA count
  580CMP #0       \Check buffer not empty
  590BNE exec
  600CLC:BCC return
  610.exec        \Execute learnt sequence
  620LDX #0       \Point to buffer start
  630.loop
  640LDY buff,X   \Pick up chr from buffer
  650TXA:PHA      \Save buffer pointer
  660LDX #0
  670LDA #&8A
  680JSR osbyte   \Insert chr into keyboard buffer
  690PLA:TAX      \Retrieve buffer pointer
  700INX
  710CPX count    \Done yet ?
  720BNE loop
  730CLC:BCC return
  740.noCTLX      \Not CTRL L or X !
  750PHA          \Save chr
  760LDA lrnflg   \In learn mode ?
  770CMP #false
  780BNE learn    \Yes,
  790PLA          \No, retrieve chr
  800CLC:BCC return
  810.learn       \Add chr to buffer
  820PLA          \Retrieve chr
  830LDX count
  840STA buff,X   \Add it to buffer
  850INX          \Increment buffer count
  860STX count    \and save it
  870.return
  880PLA:TAY:PLA:TAX:PLA:PLP
  890RTS
  900]
  910evold=P%
  920count=P%+2
  930lrnflg=P%+3
  940!P%=0:P%=P%+4
  950NEXT
  960PRINT" *SAVE LRN ";~code;" ";~P%

� LEARN  by Andy Verwer
� For Wordwise or View
� (c) The Micro User
(� Detects a keypress event
2� CTRL L - enter learn mode
<� CTRL X - leave learn mode
F� or if not in learn mode
P� execute sequence.
Zosbyte=&FFF4
devntv=&220
ncode=&A00:buff=&C00
xtrue=&FF:false=0
�� pass%=0�2�2
�P%=code
�[OPT pass%
�.initialise
�%LDA evntv    \Set up event vector
�
STA evold
�LDA evntv+1
�STA evold+1
�LDA #entry �&100
�
STA evntv
�LDA #entry �&100
�STA evntv+1
� LDA #14      \Enable event 2

LDX #2
JMP osbyte

.entry
"&PHP:PHA      \Save P & A registers
,"CMP #2       \Keypress event ?
6BEQ event2
@(PLA:PLP      \No, retrieve P & A and
J*JMP (evold)  \Jump to old event vector
T/.event2      \Yes, save remaining registers
^TXA:PHA:TYA:PHA
h
LDX #0
rLDA #&91
|%JSR osbyte   \Get chr from buffer
�TYA
� CMP #&0C     \Is it CTRL L ?
�BNE noCTLL
�'LDX #true    \Yes, enter learn mode
�STX lrnflg
�$LDX #0       \Reset buffer count
�
STX count
�CLC:BCC return
�.noCTLL
� CMP #&18     \Is it CTRL X ?
�BNE noCTLX
�+LDA lrnflg   \Yes, now check learn mode
�
CMP #true
#BNE nolrnflg \Not in learn mode
"LDA #false   \Leave learn mode
STA lrnflg
&CLC:BCC return
0
.nolrnflg
:
LDA count
D(CMP #0       \Check buffer not empty
NBNE exec
XCLC:BCC return
b).exec        \Execute learnt sequence
l'LDX #0       \Point to buffer start
v	.loop
�)LDY buff,X   \Pick up chr from buffer
�%TXA:PHA      \Save buffer pointer
�
LDX #0
�LDA #&8A
�1JSR osbyte   \Insert chr into keyboard buffer
�)PLA:TAX      \Retrieve buffer pointer
�INX
�CPX count    \Done yet ?
�BNE loop
�CLC:BCC return
�#.noCTLX      \Not CTRL L or X !
�PHA          \Save chr
�!LDA lrnflg   \In learn mode ?
CMP #false
BNE learn    \Yes,
"PLA          \No, retrieve chr
 CLC:BCC return
*#.learn       \Add chr to buffer
4PLA          \Retrieve chr
>
LDX count
H"STA buff,X   \Add it to buffer
R(INX          \Increment buffer count
\STX count    \and save it
f.return
pPLA:TAY:PLA:TAX:PLA:PLP
zRTS
�]
�evold=P%
�count=P%+2
�lrnflg=P%+3
�!P%=0:P%=P%+4
��
� �" *SAVE LRN ";~code;" ";~P%
�
00000000  0d 00 0a 1b f4 20 4c 45  41 52 4e 20 20 62 79 20  |..... LEARN  by |
00000010  41 6e 64 79 20 56 65 72  77 65 72 0d 00 14 1a f4  |Andy Verwer.....|
00000020  20 46 6f 72 20 57 6f 72  64 77 69 73 65 20 6f 72  | For Wordwise or|
00000030  20 56 69 65 77 0d 00 1e  18 f4 20 28 63 29 20 54  | View..... (c) T|
00000040  68 65 20 4d 69 63 72 6f  20 55 73 65 72 0d 00 28  |he Micro User..(|
00000050  1e f4 20 44 65 74 65 63  74 73 20 61 20 6b 65 79  |.. Detects a key|
00000060  70 72 65 73 73 20 65 76  65 6e 74 0d 00 32 1f f4  |press event..2..|
00000070  20 43 54 52 4c 20 4c 20  2d 20 65 6e 74 65 72 20  | CTRL L - enter |
00000080  6c 65 61 72 6e 20 6d 6f  64 65 0d 00 3c 1f f4 20  |learn mode..<.. |
00000090  43 54 52 4c 20 58 20 2d  20 6c 65 61 76 65 20 6c  |CTRL X - leave l|
000000a0  65 61 72 6e 20 6d 6f 64  65 0d 00 46 1d f4 20 6f  |earn mode..F.. o|
000000b0  72 20 69 66 20 6e 6f 74  20 69 6e 20 6c 65 61 72  |r if not in lear|
000000c0  6e 20 6d 6f 64 65 0d 00  50 17 f4 20 65 78 65 63  |n mode..P.. exec|
000000d0  75 74 65 20 73 65 71 75  65 6e 63 65 2e 0d 00 5a  |ute sequence...Z|
000000e0  10 6f 73 62 79 74 65 3d  26 46 46 46 34 0d 00 64  |.osbyte=&FFF4..d|
000000f0  0e 65 76 6e 74 76 3d 26  32 32 30 0d 00 6e 17 63  |.evntv=&220..n.c|
00000100  6f 64 65 3d 26 41 30 30  3a 62 75 66 66 3d 26 43  |ode=&A00:buff=&C|
00000110  30 30 0d 00 78 14 74 72  75 65 3d 26 46 46 3a 66  |00..x.true=&FF:f|
00000120  61 6c 73 65 3d 30 0d 00  82 11 e3 20 70 61 73 73  |alse=0..... pass|
00000130  25 3d 30 b8 32 88 32 0d  00 8c 0b 50 25 3d 63 6f  |%=0.2.2....P%=co|
00000140  64 65 0d 00 96 0e 5b 4f  50 54 20 70 61 73 73 25  |de....[OPT pass%|
00000150  0d 00 a0 0f 2e 69 6e 69  74 69 61 6c 69 73 65 0d  |.....initialise.|
00000160  00 aa 25 4c 44 41 20 65  76 6e 74 76 20 20 20 20  |..%LDA evntv    |
00000170  5c 53 65 74 20 75 70 20  65 76 65 6e 74 20 76 65  |\Set up event ve|
00000180  63 74 6f 72 0d 00 b4 0d  53 54 41 20 65 76 6f 6c  |ctor....STA evol|
00000190  64 0d 00 be 0f 4c 44 41  20 65 76 6e 74 76 2b 31  |d....LDA evntv+1|
000001a0  0d 00 c8 0f 53 54 41 20  65 76 6f 6c 64 2b 31 0d  |....STA evold+1.|
000001b0  00 d2 14 4c 44 41 20 23  65 6e 74 72 79 20 83 26  |...LDA #entry .&|
000001c0  31 30 30 0d 00 dc 0d 53  54 41 20 65 76 6e 74 76  |100....STA evntv|
000001d0  0d 00 e6 14 4c 44 41 20  23 65 6e 74 72 79 20 81  |....LDA #entry .|
000001e0  26 31 30 30 0d 00 f0 0f  53 54 41 20 65 76 6e 74  |&100....STA evnt|
000001f0  76 2b 31 0d 00 fa 20 4c  44 41 20 23 31 34 20 20  |v+1... LDA #14  |
00000200  20 20 20 20 5c 45 6e 61  62 6c 65 20 65 76 65 6e  |    \Enable even|
00000210  74 20 32 0d 01 04 0a 4c  44 58 20 23 32 0d 01 0e  |t 2....LDX #2...|
00000220  0e 4a 4d 50 20 6f 73 62  79 74 65 0d 01 18 0a 2e  |.JMP osbyte.....|
00000230  65 6e 74 72 79 0d 01 22  26 50 48 50 3a 50 48 41  |entry.."&PHP:PHA|
00000240  20 20 20 20 20 20 5c 53  61 76 65 20 50 20 26 20  |      \Save P & |
00000250  41 20 72 65 67 69 73 74  65 72 73 0d 01 2c 22 43  |A registers..,"C|
00000260  4d 50 20 23 32 20 20 20  20 20 20 20 5c 4b 65 79  |MP #2       \Key|
00000270  70 72 65 73 73 20 65 76  65 6e 74 20 3f 0d 01 36  |press event ?..6|
00000280  0e 42 45 51 20 65 76 65  6e 74 32 0d 01 40 28 50  |.BEQ event2..@(P|
00000290  4c 41 3a 50 4c 50 20 20  20 20 20 20 5c 4e 6f 2c  |LA:PLP      \No,|
000002a0  20 72 65 74 72 69 65 76  65 20 50 20 26 20 41 20  | retrieve P & A |
000002b0  61 6e 64 0d 01 4a 2a 4a  4d 50 20 28 65 76 6f 6c  |and..J*JMP (evol|
000002c0  64 29 20 20 5c 4a 75 6d  70 20 74 6f 20 6f 6c 64  |d)  \Jump to old|
000002d0  20 65 76 65 6e 74 20 76  65 63 74 6f 72 0d 01 54  | event vector..T|
000002e0  2f 2e 65 76 65 6e 74 32  20 20 20 20 20 20 5c 59  |/.event2      \Y|
000002f0  65 73 2c 20 73 61 76 65  20 72 65 6d 61 69 6e 69  |es, save remaini|
00000300  6e 67 20 72 65 67 69 73  74 65 72 73 0d 01 5e 13  |ng registers..^.|
00000310  54 58 41 3a 50 48 41 3a  54 59 41 3a 50 48 41 0d  |TXA:PHA:TYA:PHA.|
00000320  01 68 0a 4c 44 58 20 23  30 0d 01 72 0c 4c 44 41  |.h.LDX #0..r.LDA|
00000330  20 23 26 39 31 0d 01 7c  25 4a 53 52 20 6f 73 62  | #&91..|%JSR osb|
00000340  79 74 65 20 20 20 5c 47  65 74 20 63 68 72 20 66  |yte   \Get chr f|
00000350  72 6f 6d 20 62 75 66 66  65 72 0d 01 86 07 54 59  |rom buffer....TY|
00000360  41 0d 01 90 20 43 4d 50  20 23 26 30 43 20 20 20  |A... CMP #&0C   |
00000370  20 20 5c 49 73 20 69 74  20 43 54 52 4c 20 4c 20  |  \Is it CTRL L |
00000380  3f 0d 01 9a 0e 42 4e 45  20 6e 6f 43 54 4c 4c 0d  |?....BNE noCTLL.|
00000390  01 a4 27 4c 44 58 20 23  74 72 75 65 20 20 20 20  |..'LDX #true    |
000003a0  5c 59 65 73 2c 20 65 6e  74 65 72 20 6c 65 61 72  |\Yes, enter lear|
000003b0  6e 20 6d 6f 64 65 0d 01  ae 0e 53 54 58 20 6c 72  |n mode....STX lr|
000003c0  6e 66 6c 67 0d 01 b8 24  4c 44 58 20 23 30 20 20  |nflg...$LDX #0  |
000003d0  20 20 20 20 20 5c 52 65  73 65 74 20 62 75 66 66  |     \Reset buff|
000003e0  65 72 20 63 6f 75 6e 74  0d 01 c2 0d 53 54 58 20  |er count....STX |
000003f0  63 6f 75 6e 74 0d 01 cc  12 43 4c 43 3a 42 43 43  |count....CLC:BCC|
00000400  20 72 65 74 75 72 6e 0d  01 d6 0b 2e 6e 6f 43 54  | return.....noCT|
00000410  4c 4c 0d 01 e0 20 43 4d  50 20 23 26 31 38 20 20  |LL... CMP #&18  |
00000420  20 20 20 5c 49 73 20 69  74 20 43 54 52 4c 20 58  |   \Is it CTRL X|
00000430  20 3f 0d 01 ea 0e 42 4e  45 20 6e 6f 43 54 4c 58  | ?....BNE noCTLX|
00000440  0d 01 f4 2b 4c 44 41 20  6c 72 6e 66 6c 67 20 20  |...+LDA lrnflg  |
00000450  20 5c 59 65 73 2c 20 6e  6f 77 20 63 68 65 63 6b  | \Yes, now check|
00000460  20 6c 65 61 72 6e 20 6d  6f 64 65 0d 01 fe 0d 43  | learn mode....C|
00000470  4d 50 20 23 74 72 75 65  0d 02 08 23 42 4e 45 20  |MP #true...#BNE |
00000480  6e 6f 6c 72 6e 66 6c 67  20 5c 4e 6f 74 20 69 6e  |nolrnflg \Not in|
00000490  20 6c 65 61 72 6e 20 6d  6f 64 65 0d 02 12 22 4c  | learn mode..."L|
000004a0  44 41 20 23 66 61 6c 73  65 20 20 20 5c 4c 65 61  |DA #false   \Lea|
000004b0  76 65 20 6c 65 61 72 6e  20 6d 6f 64 65 0d 02 1c  |ve learn mode...|
000004c0  0e 53 54 41 20 6c 72 6e  66 6c 67 0d 02 26 12 43  |.STA lrnflg..&.C|
000004d0  4c 43 3a 42 43 43 20 72  65 74 75 72 6e 0d 02 30  |LC:BCC return..0|
000004e0  0d 2e 6e 6f 6c 72 6e 66  6c 67 0d 02 3a 0d 4c 44  |..nolrnflg..:.LD|
000004f0  41 20 63 6f 75 6e 74 0d  02 44 28 43 4d 50 20 23  |A count..D(CMP #|
00000500  30 20 20 20 20 20 20 20  5c 43 68 65 63 6b 20 62  |0       \Check b|
00000510  75 66 66 65 72 20 6e 6f  74 20 65 6d 70 74 79 0d  |uffer not empty.|
00000520  02 4e 0c 42 4e 45 20 65  78 65 63 0d 02 58 12 43  |.N.BNE exec..X.C|
00000530  4c 43 3a 42 43 43 20 72  65 74 75 72 6e 0d 02 62  |LC:BCC return..b|
00000540  29 2e 65 78 65 63 20 20  20 20 20 20 20 20 5c 45  |).exec        \E|
00000550  78 65 63 75 74 65 20 6c  65 61 72 6e 74 20 73 65  |xecute learnt se|
00000560  71 75 65 6e 63 65 0d 02  6c 27 4c 44 58 20 23 30  |quence..l'LDX #0|
00000570  20 20 20 20 20 20 20 5c  50 6f 69 6e 74 20 74 6f  |       \Point to|
00000580  20 62 75 66 66 65 72 20  73 74 61 72 74 0d 02 76  | buffer start..v|
00000590  09 2e 6c 6f 6f 70 0d 02  80 29 4c 44 59 20 62 75  |..loop...)LDY bu|
000005a0  66 66 2c 58 20 20 20 5c  50 69 63 6b 20 75 70 20  |ff,X   \Pick up |
000005b0  63 68 72 20 66 72 6f 6d  20 62 75 66 66 65 72 0d  |chr from buffer.|
000005c0  02 8a 25 54 58 41 3a 50  48 41 20 20 20 20 20 20  |..%TXA:PHA      |
000005d0  5c 53 61 76 65 20 62 75  66 66 65 72 20 70 6f 69  |\Save buffer poi|
000005e0  6e 74 65 72 0d 02 94 0a  4c 44 58 20 23 30 0d 02  |nter....LDX #0..|
000005f0  9e 0c 4c 44 41 20 23 26  38 41 0d 02 a8 31 4a 53  |..LDA #&8A...1JS|
00000600  52 20 6f 73 62 79 74 65  20 20 20 5c 49 6e 73 65  |R osbyte   \Inse|
00000610  72 74 20 63 68 72 20 69  6e 74 6f 20 6b 65 79 62  |rt chr into keyb|
00000620  6f 61 72 64 20 62 75 66  66 65 72 0d 02 b2 29 50  |oard buffer...)P|
00000630  4c 41 3a 54 41 58 20 20  20 20 20 20 5c 52 65 74  |LA:TAX      \Ret|
00000640  72 69 65 76 65 20 62 75  66 66 65 72 20 70 6f 69  |rieve buffer poi|
00000650  6e 74 65 72 0d 02 bc 07  49 4e 58 0d 02 c6 1c 43  |nter....INX....C|
00000660  50 58 20 63 6f 75 6e 74  20 20 20 20 5c 44 6f 6e  |PX count    \Don|
00000670  65 20 79 65 74 20 3f 0d  02 d0 0c 42 4e 45 20 6c  |e yet ?....BNE l|
00000680  6f 6f 70 0d 02 da 12 43  4c 43 3a 42 43 43 20 72  |oop....CLC:BCC r|
00000690  65 74 75 72 6e 0d 02 e4  23 2e 6e 6f 43 54 4c 58  |eturn...#.noCTLX|
000006a0  20 20 20 20 20 20 5c 4e  6f 74 20 43 54 52 4c 20  |      \Not CTRL |
000006b0  4c 20 6f 72 20 58 20 21  0d 02 ee 1a 50 48 41 20  |L or X !....PHA |
000006c0  20 20 20 20 20 20 20 20  20 5c 53 61 76 65 20 63  |         \Save c|
000006d0  68 72 0d 02 f8 21 4c 44  41 20 6c 72 6e 66 6c 67  |hr...!LDA lrnflg|
000006e0  20 20 20 5c 49 6e 20 6c  65 61 72 6e 20 6d 6f 64  |   \In learn mod|
000006f0  65 20 3f 0d 03 02 0e 43  4d 50 20 23 66 61 6c 73  |e ?....CMP #fals|
00000700  65 0d 03 0c 16 42 4e 45  20 6c 65 61 72 6e 20 20  |e....BNE learn  |
00000710  20 20 5c 59 65 73 2c 0d  03 16 22 50 4c 41 20 20  |  \Yes,..."PLA  |
00000720  20 20 20 20 20 20 20 20  5c 4e 6f 2c 20 72 65 74  |        \No, ret|
00000730  72 69 65 76 65 20 63 68  72 0d 03 20 12 43 4c 43  |rieve chr.. .CLC|
00000740  3a 42 43 43 20 72 65 74  75 72 6e 0d 03 2a 23 2e  |:BCC return..*#.|
00000750  6c 65 61 72 6e 20 20 20  20 20 20 20 5c 41 64 64  |learn       \Add|
00000760  20 63 68 72 20 74 6f 20  62 75 66 66 65 72 0d 03  | chr to buffer..|
00000770  34 1e 50 4c 41 20 20 20  20 20 20 20 20 20 20 5c  |4.PLA          \|
00000780  52 65 74 72 69 65 76 65  20 63 68 72 0d 03 3e 0d  |Retrieve chr..>.|
00000790  4c 44 58 20 63 6f 75 6e  74 0d 03 48 22 53 54 41  |LDX count..H"STA|
000007a0  20 62 75 66 66 2c 58 20  20 20 5c 41 64 64 20 69  | buff,X   \Add i|
000007b0  74 20 74 6f 20 62 75 66  66 65 72 0d 03 52 28 49  |t to buffer..R(I|
000007c0  4e 58 20 20 20 20 20 20  20 20 20 20 5c 49 6e 63  |NX          \Inc|
000007d0  72 65 6d 65 6e 74 20 62  75 66 66 65 72 20 63 6f  |rement buffer co|
000007e0  75 6e 74 0d 03 5c 1d 53  54 58 20 63 6f 75 6e 74  |unt..\.STX count|
000007f0  20 20 20 20 5c 61 6e 64  20 73 61 76 65 20 69 74  |    \and save it|
00000800  0d 03 66 0b 2e 72 65 74  75 72 6e 0d 03 70 1b 50  |..f..return..p.P|
00000810  4c 41 3a 54 41 59 3a 50  4c 41 3a 54 41 58 3a 50  |LA:TAY:PLA:TAX:P|
00000820  4c 41 3a 50 4c 50 0d 03  7a 07 52 54 53 0d 03 84  |LA:PLP..z.RTS...|
00000830  05 5d 0d 03 8e 0c 65 76  6f 6c 64 3d 50 25 0d 03  |.]....evold=P%..|
00000840  98 0e 63 6f 75 6e 74 3d  50 25 2b 32 0d 03 a2 0f  |..count=P%+2....|
00000850  6c 72 6e 66 6c 67 3d 50  25 2b 33 0d 03 ac 11 21  |lrnflg=P%+3....!|
00000860  50 25 3d 30 3a 50 25 3d  50 25 2b 34 0d 03 b6 05  |P%=0:P%=P%+4....|
00000870  ed 0d 03 c0 20 f1 22 20  2a 53 41 56 45 20 4c 52  |.... ." *SAVE LR|
00000880  4e 20 22 3b 7e 63 6f 64  65 3b 22 20 22 3b 7e 50  |N ";~code;" ";~P|
00000890  25 0d ff                                          |%..|
00000893
Utils/LEARNER.m0
Utils/LEARNER.m1
Utils/LEARNER.m2
Utils/LEARNER.m4
Utils/LEARNER.m5