Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornComputing_199407.adf » 9407 » 10_10Frnch/BodyBuild/CoinCount

10_10Frnch/BodyBuild/CoinCount

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 » Recent acquisitions » Acorn ADFS disks » adfs_AcornComputing_199407.adf » 9407
Filename: 10_10Frnch/BodyBuild/CoinCount
Read OK:
File size: 0FD2 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM>CoinCount
   20MODE 9
   30PRINTTAB(0,2)"Linear CCD Sensor Coin Counter"
   40PRINTTAB(0,5)"       By Mike Cook"
   50PRINTTAB(0,8)"This needs the hardware described in:-"
   60PRINT"Body Building July 94 Acorn Computing"
   70PRINT:PRINT"Press Space to Continue"
   80A$=GET$
   90
  100DIM CODE% 500,PV%(4),CS%(5),CV%(4)
  110
  120PROC_INIT
  130
  140REM Set sensitivity Values from 0 to 255
  150SENS%=10
  160SYS 6,151,&64,SENS%+11
  170
  180
  190REPEAT
  200PROC_TITLE
  210IF(A$="L" OR A$="l") THEN PROC_Learn
  220
  230Total=0
  240Coins%=0
  250PRINT"Counting Coins - Space bar to reset"
  260
  270REPEAT
  280REM Wait for a coin
  290
  300REPEAT
  310IF(INKEY-99) THEN
  320Coins%=0:Total=0:PRINT"Reset"
  330REPEAT
  340UNTIL(NOT(INKEY-99))
  350B$=GET$
  360ENDIF
  370SYS 6,150,&60 TO ,,A%
  380IF (A% AND 64)<>0 THEN !FZ=0
  390UNTIL (A% AND 64)=0
  400
  410PROC_SAMPLE
  420Z%=!FZ
  430Coins%+=1
  440PROC_Fval(Z%)
  450Total=Total+V%/100
  460IF Coins%=1 THEN
  470PRINT;Coins%;" Coin  ";V%;"p Total �";Total
  480ELSE
  490PRINT;Coins%;" Coins ";V%;"p Total �";Total
  500ENDIF
  510UNTIL FALSE
  520END
  530
  540DEF PROC_Learn
  550FOR C%=0 TO 3
  560PRINT"Role down a ";CV%(C%);"p coin three times"
  570V%=0
  580FOR B%=1 TO 3
  590PROC_Coin
  600IF Z%>V% THEN V%=Z%
  610PRINTZ%
  620PRINTB%;" ";
  630NEXT
  640CS%(C%)=V%+4
  650PRINT
  660NEXT
  670ENDPROC
  680
  690DEF PROC_Coin
  700Z%=0
  710REPEAT
  720SYS 6,150,&60 TO ,,A%
  730IF (A% AND 64)<>0 THEN !FZ=0
  740UNTIL (A% AND 64)=0
  750PROC_SAMPLE
  760Z%=!FZ
  770ENDPROC
  780
  790DEF PROC_Fval(N%)
  800IF N%=1 THEN V%=5: ENDPROC
  810IF N%<CS%(0) THEN V%=1: ENDPROC
  820IF N%<CS%(1) THEN V%=20: ENDPROC
  830IF N%<CS%(2) THEN V%=100: ENDPROC
  840IF N%<CS%(3) THEN V%=10: ENDPROC
  850IF N%<CS%(4) THEN V%=2: ENDPROC
  860V%=50
  870ENDPROC
  880
  890DEF PROC_INIT
  900SYS(&40500) TO ,PodB%
  910PodB%=PodB% OR &2000
  920
  930REM Set up VIA Timer clock out bit 7
  940SYS 6,151,&6B,&C0
  950SYS 6,151,&65,&0
  960SYS 6,151,&64,&30
  970
  980REM Enable up CB1 Interrupt
  990SYS 6,151,&6E,&90
 1000
 1010REM User bits to inputs
 1020SYS 6,151,&62,&0
 1030
 1040FOR A%=0 TO 2 STEP 2
 1050P%=CODE%
 1060[
 1070OPT A%
 1080.VIA EQUD PodB%
 1090.FZ  EQUD 0
 1100.FV  EQUD 0
 1110
 1120.Rd \ Read in 64 pulses
 1130STMFD R13!,{R14}
 1140MOV R9,R15
 1150SWI "OS_EnterOS"
 1160TEQP R15,#&C000003 \DISABLE INTERRUPTS
 1170MOVNV R0,R0
 1180
 1190MOV R4,#&8 \ Do this 8 times
 1200.LL
 1210LDR R0,VIA
 1220ADR R6,LU
 1230
 1240\ First Pulse CB2 High syncronised with CB1 interrupts
 1250.HL1 LDR R1,[R0,#52] \Test for CB1 interrupt
 1260TST R1,#&10
 1270BEQ HL1     \ Loop until we see it
 1280LDR R3,[R0] \ Dummy read to clear interrupt
 1290
 1300MOV R3,#&E00000 \ CB2 High
 1310STR R3,[R0,#48]
 1320
 1330.HL2 LDR R1,[R0,#52] \Test for CB1 interrupt
 1340TST R1,#&10
 1350BEQ HL2     \ Loop until we see it
 1360LDR R3,[R0] \ Dummy read to clear interrupt
 1370
 1380MOV R3,#&C00000 \ CB2 Low
 1390STR R3,[R0,#48]
 1400LDR R3,[R0] \ Dummy read to clear interrupt
 1410
 1420\ Now start gathering in the data
 1430MOV R2,#64
 1440.GD
 1450LDR R3,[R0]  \ Get data
 1460AND R3,R3,#&F \ Mask out other bits
 1470LDRB R3,[R6,R3] \ Translate into binary code
 1480MOV R3,R3,LSL #5 \ Make it larger
 1490STRB R3,[R5,R2]   \ Store it
 1500.HL LDR R1,[R0,#52] \Test for CB1 interrupt
 1510TST R1,#&10
 1520BEQ HL     \ Loop until we see it
 1530SBCS R2,R2,#1      \ Count down bytes to go
 1540BNE GD
 1550
 1560LDR R3,[R0] \ Dummy read to clear interrupt
 1570SBCS R4,R4,#1
 1580BNE HL1
 1590
 1600\Look to see how far along the sensor we have zeros
 1610MOV R7,#0
 1620MOV R2,#128
 1630.ZSL
 1640ADD R7,R7,#1
 1650CMP R7,#65
 1660BEQ EX        \ Jump out if at end of memory
 1670LDRB R1,[R5,R7]
 1680CMP R1,R2
 1690BEQ ZSL
 1700
 1710.EX
 1720LDR R1,FZ
 1730CMP R7,R1
 1740
 1750STRGT R7,FZ   \ Store the result in First Zero
 1760ADD R4,R4,#1  \ Once more round
 1770LDR R3,[R0]  \ Get data
 1780ANDS R3,R3,#&40 \ Mask out other bits
 1790BEQ LL
 1800
 1810TEQP R9,#0
 1820MOVNV R0,R0
 1830LDMFD R13!, {PC} \ BACK FROM WHENST YOU CAME
 1840.LU \ LOOK UP TABLE
 1850EQUB &4
 1860EQUB &3
 1870EQUB &0
 1880EQUB &2
 1890
 1900EQUB &0
 1910EQUB &0
 1920EQUB &0
 1930EQUB &1
 1940
 1950EQUB &0
 1960EQUB &0
 1970EQUB &0
 1980EQUB &0
 1990
 2000EQUB &0
 2010EQUB &0
 2020EQUB &0
 2030EQUB &0
 2040.LD EQUD 0 \ Place to store the data
 2050]
 2060NEXT
 2070REM Fix the coin sizes
 2080FOR A%=0 TO 4
 2090READ CS%(A%)
 2100NEXT
 2110DATA 13,19,38,55,65
 2120FOR A%=0 TO 3
 2130READ CV%(A%)
 2140NEXT
 2150DATA 1,20,100,10
 2160ENDPROC
 2170
 2180DEF PROC_SAMPLE
 2190F%=LD-1
 2200CALL Rd
 2210ENDPROC
 2220
 2230DEF PROC_TITLE
 2240LOCAL A%,Y%,L%
 2250CLS
 2260PRINTTAB(4,1)"Linear CCD Sensor Coin Counter"
 2270PRINTTAB(4,3)"        By Mike Cook"
 2280PRINT
 2290PRINT"L - To Learn the coin sizes"
 2300PRINT"C - To Count the coins"
 2310A$=GET$
 2320PRINT
 2330ENDPROC

�>CoinCount
� 9
*�0,2)"Linear CCD Sensor Coin Counter"
(�0,5)"       By Mike Cook"
22�0,8)"This needs the hardware described in:-"
<,�"Body Building July 94 Acorn Computing"
F �:�"Press Space to Continue"
PA$=�
Z
d$� CODE% 500,PV%(4),CS%(5),CV%(4)
n
x
�_INIT
�
�*� Set sensitivity Values from 0 to 255
�SENS%=10
�ș 6,151,&64,SENS%+11
�
�
��
��_TITLE
� �(A$="L" � A$="l") � �_Learn
�
�Total=0
�Coins%=0
�*�"Counting Coins - Space bar to reset"

�
� Wait for a coin
"
,�
6
�(�-99) �
@Coins%=0:Total=0:�"Reset"
J�
T�(�(�-99))
^B$=�
h�
rș 6,150,&60 � ,,A%
|� (A% � 64)<>0 � !FZ=0
�� (A% � 64)=0
�
��_SAMPLE
�
Z%=!FZ
�
Coins%+=1
��_Fval(Z%)
�Total=Total+V%/100
�� Coins%=1 �
�+�;Coins%;" Coin  ";V%;"p Total �";Total
��
�+�;Coins%;" Coins ";V%;"p Total �";Total
��
�� �
�


� �_Learn
&� C%=0 � 3
00�"Role down a ";CV%(C%);"p coin three times"
:V%=0
D� B%=1 � 3
N
�_Coin
X� Z%>V% � V%=Z%
b�Z%
l�B%;" ";
v�
�CS%(C%)=V%+4
��
��
��
�
�� �_Coin
�Z%=0
��
�ș 6,150,&60 � ,,A%
�� (A% � 64)<>0 � !FZ=0
�� (A% � 64)=0
��_SAMPLE
�
Z%=!FZ
�

� �_Fval(N%)
 � N%=1 � V%=5: �
*� N%<CS%(0) � V%=1: �
4� N%<CS%(1) � V%=20: �
>� N%<CS%(2) � V%=100: �
H� N%<CS%(3) � V%=10: �
R� N%<CS%(4) � V%=2: �
\	V%=50
f�
p
z� �_INIT
�ș(&40500) � ,PodB%
�PodB%=PodB% � &2000
�
�&� Set up VIA Timer clock out bit 7
�ș 6,151,&6B,&C0
�ș 6,151,&65,&0
�ș 6,151,&64,&30
�
�� Enable up CB1 Interrupt
�ș 6,151,&6E,&90
�
�� User bits to inputs
�ș 6,151,&62,&0

� A%=0 � 2 � 2
P%=CODE%
$[
.
OPT A%
8.VIA EQUD PodB%
B.FZ  EQUD 0
L.FV  EQUD 0
V
`.Rd \ Read in 64 pulses
jSTMFD R13!,{R14}
tMOV R9,R15
~SWI "OS_EnterOS"
�(TEQP R15,#&C000003 \DISABLE �ERRUPTS
�MOVNV R0,R0
�
� MOV R4,#&8 \ Do this 8 times
�.LL
�LDR R0,VIA
�
ADR R6,LU
�
�:\ First Pulse CB2 High syncronised with CB1 interrupts
�0.HL1 LDR R1,[R0,#52] \Test for CB1 interrupt
�TST R1,#&10
�&BEQ HL1     \ Loop until we see it
/LDR R3,[R0] \ Dummy read to clear interrupt


MOV R3,#&E00000 \ CB2 High
STR R3,[R0,#48]
(
20.HL2 LDR R1,[R0,#52] \Test for CB1 interrupt
<TST R1,#&10
F&BEQ HL2     \ Loop until we see it
P/LDR R3,[R0] \ Dummy read to clear interrupt
Z
dMOV R3,#&C00000 \ CB2 Low
nSTR R3,[R0,#48]
x/LDR R3,[R0] \ Dummy read to clear interrupt
�
�%\ Now start gathering in the data
�MOV R2,#64
�.GD
�LDR R3,[R0]  \ Get data
�%� R3,R3,#&F \ Mask out other bits
�0LDRB R3,[R6,R3] \ Translate into binary code
�%MOV R3,R3,LSL #5 \ Make it larger
� STRB R3,[R5,R2]   \ Store it
�/.HL LDR R1,[R0,#52] \Test for CB1 interrupt
�TST R1,#&10
�%BEQ HL     \ Loop until we see it
�/SBCS R2,R2,#1      \ Count down bytes to go

BNE GD

/LDR R3,[R0] \ Dummy read to clear interrupt
"SBCS R4,R4,#1
,BNE HL1
6
@7\Look to see how far along the sensor we have zeros
J
MOV R7,#0
TMOV R2,#128
^.ZSL
hADD R7,R7,#1
rCMP R7,#65
|0BEQ EX        \ Jump out if at end of memory
�LDRB R1,[R5,R7]
�
CMP R1,R2
�BEQ ZSL
�
�.EX
�
LDR R1,FZ
�
CMP R7,R1
�
�2STRGT R7,FZ   \ Store the result in First Zero
�#ADD R4,R4,#1  \ Once more round
�LDR R3,[R0]  \ Get data
�'�S R3,R3,#&40 \ Mask out other bits
�
BEQ LL

TEQP R9,#0
MOVNV R0,R0
&-LDMFD R13!, {PC} \ BACK FROM �ST YOU CAME
0.LU \ LOOK UP TABLE
:EQUB &4
DEQUB &3
NEQUB &0
XEQUB &2
b
lEQUB &0
vEQUB &0
�EQUB &0
�EQUB &1
�
�EQUB &0
�EQUB &0
�EQUB &0
�EQUB &0
�
�EQUB &0
�EQUB &0
�EQUB &0
�EQUB &0
�(.LD EQUD 0 \ Place to store the data
]
�
� Fix the coin sizes
 � A%=0 � 4
*
� CS%(A%)
4�
>� 13,19,38,55,65
H� A%=0 � 3
R
� CV%(A%)
\�
f� 1,20,100,10
p�
z
�� �_SAMPLE
�F%=LD-1
�� Rd
��
�
�
� �_TITLE
�� A%,Y%,L%
��
�*�4,1)"Linear CCD Sensor Coin Counter"
� �4,3)"        By Mike Cook"
��
�"�"L - To Learn the coin sizes"
��"C - To Count the coins"
	A$=�
	�
	�
�
00000000  0d 00 0a 0f f4 3e 43 6f  69 6e 43 6f 75 6e 74 0d  |.....>CoinCount.|
00000010  00 14 07 eb 20 39 0d 00  1e 2a f1 8a 30 2c 32 29  |.... 9...*..0,2)|
00000020  22 4c 69 6e 65 61 72 20  43 43 44 20 53 65 6e 73  |"Linear CCD Sens|
00000030  6f 72 20 43 6f 69 6e 20  43 6f 75 6e 74 65 72 22  |or Coin Counter"|
00000040  0d 00 28 1f f1 8a 30 2c  35 29 22 20 20 20 20 20  |..(...0,5)"     |
00000050  20 20 42 79 20 4d 69 6b  65 20 43 6f 6f 6b 22 0d  |  By Mike Cook".|
00000060  00 32 32 f1 8a 30 2c 38  29 22 54 68 69 73 20 6e  |.22..0,8)"This n|
00000070  65 65 64 73 20 74 68 65  20 68 61 72 64 77 61 72  |eeds the hardwar|
00000080  65 20 64 65 73 63 72 69  62 65 64 20 69 6e 3a 2d  |e described in:-|
00000090  22 0d 00 3c 2c f1 22 42  6f 64 79 20 42 75 69 6c  |"..<,."Body Buil|
000000a0  64 69 6e 67 20 4a 75 6c  79 20 39 34 20 41 63 6f  |ding July 94 Aco|
000000b0  72 6e 20 43 6f 6d 70 75  74 69 6e 67 22 0d 00 46  |rn Computing"..F|
000000c0  20 f1 3a f1 22 50 72 65  73 73 20 53 70 61 63 65  | .:."Press Space|
000000d0  20 74 6f 20 43 6f 6e 74  69 6e 75 65 22 0d 00 50  | to Continue"..P|
000000e0  08 41 24 3d be 0d 00 5a  04 0d 00 64 24 de 20 43  |.A$=...Z...d$. C|
000000f0  4f 44 45 25 20 35 30 30  2c 50 56 25 28 34 29 2c  |ODE% 500,PV%(4),|
00000100  43 53 25 28 35 29 2c 43  56 25 28 34 29 0d 00 6e  |CS%(5),CV%(4)..n|
00000110  04 0d 00 78 0a f2 5f 49  4e 49 54 0d 00 82 04 0d  |...x.._INIT.....|
00000120  00 8c 2a f4 20 53 65 74  20 73 65 6e 73 69 74 69  |..*. Set sensiti|
00000130  76 69 74 79 20 56 61 6c  75 65 73 20 66 72 6f 6d  |vity Values from|
00000140  20 30 20 74 6f 20 32 35  35 0d 00 96 0c 53 45 4e  | 0 to 255....SEN|
00000150  53 25 3d 31 30 0d 00 a0  19 c8 99 20 36 2c 31 35  |S%=10...... 6,15|
00000160  31 2c 26 36 34 2c 53 45  4e 53 25 2b 31 31 0d 00  |1,&64,SENS%+11..|
00000170  aa 04 0d 00 b4 04 0d 00  be 05 f5 0d 00 c8 0b f2  |................|
00000180  5f 54 49 54 4c 45 0d 00  d2 20 e7 28 41 24 3d 22  |_TITLE... .(A$="|
00000190  4c 22 20 84 20 41 24 3d  22 6c 22 29 20 8c 20 f2  |L" . A$="l") . .|
000001a0  5f 4c 65 61 72 6e 0d 00  dc 04 0d 00 e6 0b 54 6f  |_Learn........To|
000001b0  74 61 6c 3d 30 0d 00 f0  0c 43 6f 69 6e 73 25 3d  |tal=0....Coins%=|
000001c0  30 0d 00 fa 2a f1 22 43  6f 75 6e 74 69 6e 67 20  |0...*."Counting |
000001d0  43 6f 69 6e 73 20 2d 20  53 70 61 63 65 20 62 61  |Coins - Space ba|
000001e0  72 20 74 6f 20 72 65 73  65 74 22 0d 01 04 04 0d  |r to reset".....|
000001f0  01 0e 05 f5 0d 01 18 15  f4 20 57 61 69 74 20 66  |......... Wait f|
00000200  6f 72 20 61 20 63 6f 69  6e 0d 01 22 04 0d 01 2c  |or a coin.."...,|
00000210  05 f5 0d 01 36 0d e7 28  a6 2d 39 39 29 20 8c 0d  |....6..(.-99) ..|
00000220  01 40 1d 43 6f 69 6e 73  25 3d 30 3a 54 6f 74 61  |.@.Coins%=0:Tota|
00000230  6c 3d 30 3a f1 22 52 65  73 65 74 22 0d 01 4a 05  |l=0:."Reset"..J.|
00000240  f5 0d 01 54 0e fd 28 ac  28 a6 2d 39 39 29 29 0d  |...T..(.(.-99)).|
00000250  01 5e 08 42 24 3d be 0d  01 68 05 cd 0d 01 72 17  |.^.B$=...h....r.|
00000260  c8 99 20 36 2c 31 35 30  2c 26 36 30 20 b8 20 2c  |.. 6,150,&60 . ,|
00000270  2c 41 25 0d 01 7c 1a e7  20 28 41 25 20 80 20 36  |,A%..|.. (A% . 6|
00000280  34 29 3c 3e 30 20 8c 20  21 46 5a 3d 30 0d 01 86  |4)<>0 . !FZ=0...|
00000290  11 fd 20 28 41 25 20 80  20 36 34 29 3d 30 0d 01  |.. (A% . 64)=0..|
000002a0  90 04 0d 01 9a 0c f2 5f  53 41 4d 50 4c 45 0d 01  |......._SAMPLE..|
000002b0  a4 0a 5a 25 3d 21 46 5a  0d 01 ae 0d 43 6f 69 6e  |..Z%=!FZ....Coin|
000002c0  73 25 2b 3d 31 0d 01 b8  0e f2 5f 46 76 61 6c 28  |s%+=1....._Fval(|
000002d0  5a 25 29 0d 01 c2 16 54  6f 74 61 6c 3d 54 6f 74  |Z%)....Total=Tot|
000002e0  61 6c 2b 56 25 2f 31 30  30 0d 01 cc 10 e7 20 43  |al+V%/100..... C|
000002f0  6f 69 6e 73 25 3d 31 20  8c 0d 01 d6 2b f1 3b 43  |oins%=1 ....+.;C|
00000300  6f 69 6e 73 25 3b 22 20  43 6f 69 6e 20 20 22 3b  |oins%;" Coin  ";|
00000310  56 25 3b 22 70 20 54 6f  74 61 6c 20 a3 22 3b 54  |V%;"p Total .";T|
00000320  6f 74 61 6c 0d 01 e0 05  cc 0d 01 ea 2b f1 3b 43  |otal........+.;C|
00000330  6f 69 6e 73 25 3b 22 20  43 6f 69 6e 73 20 22 3b  |oins%;" Coins ";|
00000340  56 25 3b 22 70 20 54 6f  74 61 6c 20 a3 22 3b 54  |V%;"p Total .";T|
00000350  6f 74 61 6c 0d 01 f4 05  cd 0d 01 fe 07 fd 20 a3  |otal.......... .|
00000360  0d 02 08 05 e0 0d 02 12  04 0d 02 1c 0d dd 20 f2  |.............. .|
00000370  5f 4c 65 61 72 6e 0d 02  26 0e e3 20 43 25 3d 30  |_Learn..&.. C%=0|
00000380  20 b8 20 33 0d 02 30 30  f1 22 52 6f 6c 65 20 64  | . 3..00."Role d|
00000390  6f 77 6e 20 61 20 22 3b  43 56 25 28 43 25 29 3b  |own a ";CV%(C%);|
000003a0  22 70 20 63 6f 69 6e 20  74 68 72 65 65 20 74 69  |"p coin three ti|
000003b0  6d 65 73 22 0d 02 3a 08  56 25 3d 30 0d 02 44 0e  |mes"..:.V%=0..D.|
000003c0  e3 20 42 25 3d 31 20 b8  20 33 0d 02 4e 0a f2 5f  |. B%=1 . 3..N.._|
000003d0  43 6f 69 6e 0d 02 58 13  e7 20 5a 25 3e 56 25 20  |Coin..X.. Z%>V% |
000003e0  8c 20 56 25 3d 5a 25 0d  02 62 07 f1 5a 25 0d 02  |. V%=Z%..b..Z%..|
000003f0  6c 0c f1 42 25 3b 22 20  22 3b 0d 02 76 05 ed 0d  |l..B%;" ";..v...|
00000400  02 80 10 43 53 25 28 43  25 29 3d 56 25 2b 34 0d  |...CS%(C%)=V%+4.|
00000410  02 8a 05 f1 0d 02 94 05  ed 0d 02 9e 05 e1 0d 02  |................|
00000420  a8 04 0d 02 b2 0c dd 20  f2 5f 43 6f 69 6e 0d 02  |....... ._Coin..|
00000430  bc 08 5a 25 3d 30 0d 02  c6 05 f5 0d 02 d0 17 c8  |..Z%=0..........|
00000440  99 20 36 2c 31 35 30 2c  26 36 30 20 b8 20 2c 2c  |. 6,150,&60 . ,,|
00000450  41 25 0d 02 da 1a e7 20  28 41 25 20 80 20 36 34  |A%..... (A% . 64|
00000460  29 3c 3e 30 20 8c 20 21  46 5a 3d 30 0d 02 e4 11  |)<>0 . !FZ=0....|
00000470  fd 20 28 41 25 20 80 20  36 34 29 3d 30 0d 02 ee  |. (A% . 64)=0...|
00000480  0c f2 5f 53 41 4d 50 4c  45 0d 02 f8 0a 5a 25 3d  |.._SAMPLE....Z%=|
00000490  21 46 5a 0d 03 02 05 e1  0d 03 0c 04 0d 03 16 10  |!FZ.............|
000004a0  dd 20 f2 5f 46 76 61 6c  28 4e 25 29 0d 03 20 14  |. ._Fval(N%).. .|
000004b0  e7 20 4e 25 3d 31 20 8c  20 56 25 3d 35 3a 20 e1  |. N%=1 . V%=5: .|
000004c0  0d 03 2a 19 e7 20 4e 25  3c 43 53 25 28 30 29 20  |..*.. N%<CS%(0) |
000004d0  8c 20 56 25 3d 31 3a 20  e1 0d 03 34 1a e7 20 4e  |. V%=1: ...4.. N|
000004e0  25 3c 43 53 25 28 31 29  20 8c 20 56 25 3d 32 30  |%<CS%(1) . V%=20|
000004f0  3a 20 e1 0d 03 3e 1b e7  20 4e 25 3c 43 53 25 28  |: ...>.. N%<CS%(|
00000500  32 29 20 8c 20 56 25 3d  31 30 30 3a 20 e1 0d 03  |2) . V%=100: ...|
00000510  48 1a e7 20 4e 25 3c 43  53 25 28 33 29 20 8c 20  |H.. N%<CS%(3) . |
00000520  56 25 3d 31 30 3a 20 e1  0d 03 52 19 e7 20 4e 25  |V%=10: ...R.. N%|
00000530  3c 43 53 25 28 34 29 20  8c 20 56 25 3d 32 3a 20  |<CS%(4) . V%=2: |
00000540  e1 0d 03 5c 09 56 25 3d  35 30 0d 03 66 05 e1 0d  |...\.V%=50..f...|
00000550  03 70 04 0d 03 7a 0c dd  20 f2 5f 49 4e 49 54 0d  |.p...z.. ._INIT.|
00000560  03 84 17 c8 99 28 26 34  30 35 30 30 29 20 b8 20  |.....(&40500) . |
00000570  2c 50 6f 64 42 25 0d 03  8e 17 50 6f 64 42 25 3d  |,PodB%....PodB%=|
00000580  50 6f 64 42 25 20 84 20  26 32 30 30 30 0d 03 98  |PodB% . &2000...|
00000590  04 0d 03 a2 26 f4 20 53  65 74 20 75 70 20 56 49  |....&. Set up VI|
000005a0  41 20 54 69 6d 65 72 20  63 6c 6f 63 6b 20 6f 75  |A Timer clock ou|
000005b0  74 20 62 69 74 20 37 0d  03 ac 14 c8 99 20 36 2c  |t bit 7...... 6,|
000005c0  31 35 31 2c 26 36 42 2c  26 43 30 0d 03 b6 13 c8  |151,&6B,&C0.....|
000005d0  99 20 36 2c 31 35 31 2c  26 36 35 2c 26 30 0d 03  |. 6,151,&65,&0..|
000005e0  c0 14 c8 99 20 36 2c 31  35 31 2c 26 36 34 2c 26  |.... 6,151,&64,&|
000005f0  33 30 0d 03 ca 04 0d 03  d4 1d f4 20 45 6e 61 62  |30......... Enab|
00000600  6c 65 20 75 70 20 43 42  31 20 49 6e 74 65 72 72  |le up CB1 Interr|
00000610  75 70 74 0d 03 de 14 c8  99 20 36 2c 31 35 31 2c  |upt...... 6,151,|
00000620  26 36 45 2c 26 39 30 0d  03 e8 04 0d 03 f2 19 f4  |&6E,&90.........|
00000630  20 55 73 65 72 20 62 69  74 73 20 74 6f 20 69 6e  | User bits to in|
00000640  70 75 74 73 0d 03 fc 13  c8 99 20 36 2c 31 35 31  |puts...... 6,151|
00000650  2c 26 36 32 2c 26 30 0d  04 06 04 0d 04 10 12 e3  |,&62,&0.........|
00000660  20 41 25 3d 30 20 b8 20  32 20 88 20 32 0d 04 1a  | A%=0 . 2 . 2...|
00000670  0c 50 25 3d 43 4f 44 45  25 0d 04 24 05 5b 0d 04  |.P%=CODE%..$.[..|
00000680  2e 0a 4f 50 54 20 41 25  0d 04 38 13 2e 56 49 41  |..OPT A%..8..VIA|
00000690  20 45 51 55 44 20 50 6f  64 42 25 0d 04 42 0f 2e  | EQUD PodB%..B..|
000006a0  46 5a 20 20 45 51 55 44  20 30 0d 04 4c 0f 2e 46  |FZ  EQUD 0..L..F|
000006b0  56 20 20 45 51 55 44 20  30 0d 04 56 04 0d 04 60  |V  EQUD 0..V...`|
000006c0  1b 2e 52 64 20 5c 20 52  65 61 64 20 69 6e 20 36  |..Rd \ Read in 6|
000006d0  34 20 70 75 6c 73 65 73  0d 04 6a 14 53 54 4d 46  |4 pulses..j.STMF|
000006e0  44 20 52 31 33 21 2c 7b  52 31 34 7d 0d 04 74 0e  |D R13!,{R14}..t.|
000006f0  4d 4f 56 20 52 39 2c 52  31 35 0d 04 7e 14 53 57  |MOV R9,R15..~.SW|
00000700  49 20 22 4f 53 5f 45 6e  74 65 72 4f 53 22 0d 04  |I "OS_EnterOS"..|
00000710  88 28 54 45 51 50 20 52  31 35 2c 23 26 43 30 30  |.(TEQP R15,#&C00|
00000720  30 30 30 33 20 5c 44 49  53 41 42 4c 45 20 a8 45  |0003 \DISABLE .E|
00000730  52 52 55 50 54 53 0d 04  92 0f 4d 4f 56 4e 56 20  |RRUPTS....MOVNV |
00000740  52 30 2c 52 30 0d 04 9c  04 0d 04 a6 20 4d 4f 56  |R0,R0....... MOV|
00000750  20 52 34 2c 23 26 38 20  5c 20 44 6f 20 74 68 69  | R4,#&8 \ Do thi|
00000760  73 20 38 20 74 69 6d 65  73 0d 04 b0 07 2e 4c 4c  |s 8 times.....LL|
00000770  0d 04 ba 0e 4c 44 52 20  52 30 2c 56 49 41 0d 04  |....LDR R0,VIA..|
00000780  c4 0d 41 44 52 20 52 36  2c 4c 55 0d 04 ce 04 0d  |..ADR R6,LU.....|
00000790  04 d8 3a 5c 20 46 69 72  73 74 20 50 75 6c 73 65  |..:\ First Pulse|
000007a0  20 43 42 32 20 48 69 67  68 20 73 79 6e 63 72 6f  | CB2 High syncro|
000007b0  6e 69 73 65 64 20 77 69  74 68 20 43 42 31 20 69  |nised with CB1 i|
000007c0  6e 74 65 72 72 75 70 74  73 0d 04 e2 30 2e 48 4c  |nterrupts...0.HL|
000007d0  31 20 4c 44 52 20 52 31  2c 5b 52 30 2c 23 35 32  |1 LDR R1,[R0,#52|
000007e0  5d 20 5c 54 65 73 74 20  66 6f 72 20 43 42 31 20  |] \Test for CB1 |
000007f0  69 6e 74 65 72 72 75 70  74 0d 04 ec 0f 54 53 54  |interrupt....TST|
00000800  20 52 31 2c 23 26 31 30  0d 04 f6 26 42 45 51 20  | R1,#&10...&BEQ |
00000810  48 4c 31 20 20 20 20 20  5c 20 4c 6f 6f 70 20 75  |HL1     \ Loop u|
00000820  6e 74 69 6c 20 77 65 20  73 65 65 20 69 74 0d 05  |ntil we see it..|
00000830  00 2f 4c 44 52 20 52 33  2c 5b 52 30 5d 20 5c 20  |./LDR R3,[R0] \ |
00000840  44 75 6d 6d 79 20 72 65  61 64 20 74 6f 20 63 6c  |Dummy read to cl|
00000850  65 61 72 20 69 6e 74 65  72 72 75 70 74 0d 05 0a  |ear interrupt...|
00000860  04 0d 05 14 1e 4d 4f 56  20 52 33 2c 23 26 45 30  |.....MOV R3,#&E0|
00000870  30 30 30 30 20 5c 20 43  42 32 20 48 69 67 68 0d  |0000 \ CB2 High.|
00000880  05 1e 13 53 54 52 20 52  33 2c 5b 52 30 2c 23 34  |...STR R3,[R0,#4|
00000890  38 5d 0d 05 28 04 0d 05  32 30 2e 48 4c 32 20 4c  |8]..(...20.HL2 L|
000008a0  44 52 20 52 31 2c 5b 52  30 2c 23 35 32 5d 20 5c  |DR R1,[R0,#52] \|
000008b0  54 65 73 74 20 66 6f 72  20 43 42 31 20 69 6e 74  |Test for CB1 int|
000008c0  65 72 72 75 70 74 0d 05  3c 0f 54 53 54 20 52 31  |errupt..<.TST R1|
000008d0  2c 23 26 31 30 0d 05 46  26 42 45 51 20 48 4c 32  |,#&10..F&BEQ HL2|
000008e0  20 20 20 20 20 5c 20 4c  6f 6f 70 20 75 6e 74 69  |     \ Loop unti|
000008f0  6c 20 77 65 20 73 65 65  20 69 74 0d 05 50 2f 4c  |l we see it..P/L|
00000900  44 52 20 52 33 2c 5b 52  30 5d 20 5c 20 44 75 6d  |DR R3,[R0] \ Dum|
00000910  6d 79 20 72 65 61 64 20  74 6f 20 63 6c 65 61 72  |my read to clear|
00000920  20 69 6e 74 65 72 72 75  70 74 0d 05 5a 04 0d 05  | interrupt..Z...|
00000930  64 1d 4d 4f 56 20 52 33  2c 23 26 43 30 30 30 30  |d.MOV R3,#&C0000|
00000940  30 20 5c 20 43 42 32 20  4c 6f 77 0d 05 6e 13 53  |0 \ CB2 Low..n.S|
00000950  54 52 20 52 33 2c 5b 52  30 2c 23 34 38 5d 0d 05  |TR R3,[R0,#48]..|
00000960  78 2f 4c 44 52 20 52 33  2c 5b 52 30 5d 20 5c 20  |x/LDR R3,[R0] \ |
00000970  44 75 6d 6d 79 20 72 65  61 64 20 74 6f 20 63 6c  |Dummy read to cl|
00000980  65 61 72 20 69 6e 74 65  72 72 75 70 74 0d 05 82  |ear interrupt...|
00000990  04 0d 05 8c 25 5c 20 4e  6f 77 20 73 74 61 72 74  |....%\ Now start|
000009a0  20 67 61 74 68 65 72 69  6e 67 20 69 6e 20 74 68  | gathering in th|
000009b0  65 20 64 61 74 61 0d 05  96 0e 4d 4f 56 20 52 32  |e data....MOV R2|
000009c0  2c 23 36 34 0d 05 a0 07  2e 47 44 0d 05 aa 1b 4c  |,#64.....GD....L|
000009d0  44 52 20 52 33 2c 5b 52  30 5d 20 20 5c 20 47 65  |DR R3,[R0]  \ Ge|
000009e0  74 20 64 61 74 61 0d 05  b4 25 80 20 52 33 2c 52  |t data...%. R3,R|
000009f0  33 2c 23 26 46 20 5c 20  4d 61 73 6b 20 6f 75 74  |3,#&F \ Mask out|
00000a00  20 6f 74 68 65 72 20 62  69 74 73 0d 05 be 30 4c  | other bits...0L|
00000a10  44 52 42 20 52 33 2c 5b  52 36 2c 52 33 5d 20 5c  |DRB R3,[R6,R3] \|
00000a20  20 54 72 61 6e 73 6c 61  74 65 20 69 6e 74 6f 20  | Translate into |
00000a30  62 69 6e 61 72 79 20 63  6f 64 65 0d 05 c8 25 4d  |binary code...%M|
00000a40  4f 56 20 52 33 2c 52 33  2c 4c 53 4c 20 23 35 20  |OV R3,R3,LSL #5 |
00000a50  5c 20 4d 61 6b 65 20 69  74 20 6c 61 72 67 65 72  |\ Make it larger|
00000a60  0d 05 d2 20 53 54 52 42  20 52 33 2c 5b 52 35 2c  |... STRB R3,[R5,|
00000a70  52 32 5d 20 20 20 5c 20  53 74 6f 72 65 20 69 74  |R2]   \ Store it|
00000a80  0d 05 dc 2f 2e 48 4c 20  4c 44 52 20 52 31 2c 5b  |.../.HL LDR R1,[|
00000a90  52 30 2c 23 35 32 5d 20  5c 54 65 73 74 20 66 6f  |R0,#52] \Test fo|
00000aa0  72 20 43 42 31 20 69 6e  74 65 72 72 75 70 74 0d  |r CB1 interrupt.|
00000ab0  05 e6 0f 54 53 54 20 52  31 2c 23 26 31 30 0d 05  |...TST R1,#&10..|
00000ac0  f0 25 42 45 51 20 48 4c  20 20 20 20 20 5c 20 4c  |.%BEQ HL     \ L|
00000ad0  6f 6f 70 20 75 6e 74 69  6c 20 77 65 20 73 65 65  |oop until we see|
00000ae0  20 69 74 0d 05 fa 2f 53  42 43 53 20 52 32 2c 52  | it.../SBCS R2,R|
00000af0  32 2c 23 31 20 20 20 20  20 20 5c 20 43 6f 75 6e  |2,#1      \ Coun|
00000b00  74 20 64 6f 77 6e 20 62  79 74 65 73 20 74 6f 20  |t down bytes to |
00000b10  67 6f 0d 06 04 0a 42 4e  45 20 47 44 0d 06 0e 04  |go....BNE GD....|
00000b20  0d 06 18 2f 4c 44 52 20  52 33 2c 5b 52 30 5d 20  |.../LDR R3,[R0] |
00000b30  5c 20 44 75 6d 6d 79 20  72 65 61 64 20 74 6f 20  |\ Dummy read to |
00000b40  63 6c 65 61 72 20 69 6e  74 65 72 72 75 70 74 0d  |clear interrupt.|
00000b50  06 22 11 53 42 43 53 20  52 34 2c 52 34 2c 23 31  |.".SBCS R4,R4,#1|
00000b60  0d 06 2c 0b 42 4e 45 20  48 4c 31 0d 06 36 04 0d  |..,.BNE HL1..6..|
00000b70  06 40 37 5c 4c 6f 6f 6b  20 74 6f 20 73 65 65 20  |.@7\Look to see |
00000b80  68 6f 77 20 66 61 72 20  61 6c 6f 6e 67 20 74 68  |how far along th|
00000b90  65 20 73 65 6e 73 6f 72  20 77 65 20 68 61 76 65  |e sensor we have|
00000ba0  20 7a 65 72 6f 73 0d 06  4a 0d 4d 4f 56 20 52 37  | zeros..J.MOV R7|
00000bb0  2c 23 30 0d 06 54 0f 4d  4f 56 20 52 32 2c 23 31  |,#0..T.MOV R2,#1|
00000bc0  32 38 0d 06 5e 08 2e 5a  53 4c 0d 06 68 10 41 44  |28..^..ZSL..h.AD|
00000bd0  44 20 52 37 2c 52 37 2c  23 31 0d 06 72 0e 43 4d  |D R7,R7,#1..r.CM|
00000be0  50 20 52 37 2c 23 36 35  0d 06 7c 30 42 45 51 20  |P R7,#65..|0BEQ |
00000bf0  45 58 20 20 20 20 20 20  20 20 5c 20 4a 75 6d 70  |EX        \ Jump|
00000c00  20 6f 75 74 20 69 66 20  61 74 20 65 6e 64 20 6f  | out if at end o|
00000c10  66 20 6d 65 6d 6f 72 79  0d 06 86 13 4c 44 52 42  |f memory....LDRB|
00000c20  20 52 31 2c 5b 52 35 2c  52 37 5d 0d 06 90 0d 43  | R1,[R5,R7]....C|
00000c30  4d 50 20 52 31 2c 52 32  0d 06 9a 0b 42 45 51 20  |MP R1,R2....BEQ |
00000c40  5a 53 4c 0d 06 a4 04 0d  06 ae 07 2e 45 58 0d 06  |ZSL.........EX..|
00000c50  b8 0d 4c 44 52 20 52 31  2c 46 5a 0d 06 c2 0d 43  |..LDR R1,FZ....C|
00000c60  4d 50 20 52 37 2c 52 31  0d 06 cc 04 0d 06 d6 32  |MP R7,R1.......2|
00000c70  53 54 52 47 54 20 52 37  2c 46 5a 20 20 20 5c 20  |STRGT R7,FZ   \ |
00000c80  53 74 6f 72 65 20 74 68  65 20 72 65 73 75 6c 74  |Store the result|
00000c90  20 69 6e 20 46 69 72 73  74 20 5a 65 72 6f 0d 06  | in First Zero..|
00000ca0  e0 23 41 44 44 20 52 34  2c 52 34 2c 23 31 20 20  |.#ADD R4,R4,#1  |
00000cb0  5c 20 4f 6e 63 65 20 6d  6f 72 65 20 72 6f 75 6e  |\ Once more roun|
00000cc0  64 0d 06 ea 1b 4c 44 52  20 52 33 2c 5b 52 30 5d  |d....LDR R3,[R0]|
00000cd0  20 20 5c 20 47 65 74 20  64 61 74 61 0d 06 f4 27  |  \ Get data...'|
00000ce0  80 53 20 52 33 2c 52 33  2c 23 26 34 30 20 5c 20  |.S R3,R3,#&40 \ |
00000cf0  4d 61 73 6b 20 6f 75 74  20 6f 74 68 65 72 20 62  |Mask out other b|
00000d00  69 74 73 0d 06 fe 0a 42  45 51 20 4c 4c 0d 07 08  |its....BEQ LL...|
00000d10  04 0d 07 12 0e 54 45 51  50 20 52 39 2c 23 30 0d  |.....TEQP R9,#0.|
00000d20  07 1c 0f 4d 4f 56 4e 56  20 52 30 2c 52 30 0d 07  |...MOVNV R0,R0..|
00000d30  26 2d 4c 44 4d 46 44 20  52 31 33 21 2c 20 7b 50  |&-LDMFD R13!, {P|
00000d40  43 7d 20 5c 20 42 41 43  4b 20 46 52 4f 4d 20 c9  |C} \ BACK FROM .|
00000d50  53 54 20 59 4f 55 20 43  41 4d 45 0d 07 30 17 2e  |ST YOU CAME..0..|
00000d60  4c 55 20 5c 20 4c 4f 4f  4b 20 55 50 20 54 41 42  |LU \ LOOK UP TAB|
00000d70  4c 45 0d 07 3a 0b 45 51  55 42 20 26 34 0d 07 44  |LE..:.EQUB &4..D|
00000d80  0b 45 51 55 42 20 26 33  0d 07 4e 0b 45 51 55 42  |.EQUB &3..N.EQUB|
00000d90  20 26 30 0d 07 58 0b 45  51 55 42 20 26 32 0d 07  | &0..X.EQUB &2..|
00000da0  62 04 0d 07 6c 0b 45 51  55 42 20 26 30 0d 07 76  |b...l.EQUB &0..v|
00000db0  0b 45 51 55 42 20 26 30  0d 07 80 0b 45 51 55 42  |.EQUB &0....EQUB|
00000dc0  20 26 30 0d 07 8a 0b 45  51 55 42 20 26 31 0d 07  | &0....EQUB &1..|
00000dd0  94 04 0d 07 9e 0b 45 51  55 42 20 26 30 0d 07 a8  |......EQUB &0...|
00000de0  0b 45 51 55 42 20 26 30  0d 07 b2 0b 45 51 55 42  |.EQUB &0....EQUB|
00000df0  20 26 30 0d 07 bc 0b 45  51 55 42 20 26 30 0d 07  | &0....EQUB &0..|
00000e00  c6 04 0d 07 d0 0b 45 51  55 42 20 26 30 0d 07 da  |......EQUB &0...|
00000e10  0b 45 51 55 42 20 26 30  0d 07 e4 0b 45 51 55 42  |.EQUB &0....EQUB|
00000e20  20 26 30 0d 07 ee 0b 45  51 55 42 20 26 30 0d 07  | &0....EQUB &0..|
00000e30  f8 28 2e 4c 44 20 45 51  55 44 20 30 20 5c 20 50  |.(.LD EQUD 0 \ P|
00000e40  6c 61 63 65 20 74 6f 20  73 74 6f 72 65 20 74 68  |lace to store th|
00000e50  65 20 64 61 74 61 0d 08  02 05 5d 0d 08 0c 05 ed  |e data....].....|
00000e60  0d 08 16 18 f4 20 46 69  78 20 74 68 65 20 63 6f  |..... Fix the co|
00000e70  69 6e 20 73 69 7a 65 73  0d 08 20 0e e3 20 41 25  |in sizes.. .. A%|
00000e80  3d 30 20 b8 20 34 0d 08  2a 0d f3 20 43 53 25 28  |=0 . 4..*.. CS%(|
00000e90  41 25 29 0d 08 34 05 ed  0d 08 3e 14 dc 20 31 33  |A%)..4....>.. 13|
00000ea0  2c 31 39 2c 33 38 2c 35  35 2c 36 35 0d 08 48 0e  |,19,38,55,65..H.|
00000eb0  e3 20 41 25 3d 30 20 b8  20 33 0d 08 52 0d f3 20  |. A%=0 . 3..R.. |
00000ec0  43 56 25 28 41 25 29 0d  08 5c 05 ed 0d 08 66 11  |CV%(A%)..\....f.|
00000ed0  dc 20 31 2c 32 30 2c 31  30 30 2c 31 30 0d 08 70  |. 1,20,100,10..p|
00000ee0  05 e1 0d 08 7a 04 0d 08  84 0e dd 20 f2 5f 53 41  |....z...... ._SA|
00000ef0  4d 50 4c 45 0d 08 8e 0b  46 25 3d 4c 44 2d 31 0d  |MPLE....F%=LD-1.|
00000f00  08 98 08 d6 20 52 64 0d  08 a2 05 e1 0d 08 ac 04  |.... Rd.........|
00000f10  0d 08 b6 0d dd 20 f2 5f  54 49 54 4c 45 0d 08 c0  |..... ._TITLE...|
00000f20  0e ea 20 41 25 2c 59 25  2c 4c 25 0d 08 ca 05 db  |.. A%,Y%,L%.....|
00000f30  0d 08 d4 2a f1 8a 34 2c  31 29 22 4c 69 6e 65 61  |...*..4,1)"Linea|
00000f40  72 20 43 43 44 20 53 65  6e 73 6f 72 20 43 6f 69  |r CCD Sensor Coi|
00000f50  6e 20 43 6f 75 6e 74 65  72 22 0d 08 de 20 f1 8a  |n Counter"... ..|
00000f60  34 2c 33 29 22 20 20 20  20 20 20 20 20 42 79 20  |4,3)"        By |
00000f70  4d 69 6b 65 20 43 6f 6f  6b 22 0d 08 e8 05 f1 0d  |Mike Cook"......|
00000f80  08 f2 22 f1 22 4c 20 2d  20 54 6f 20 4c 65 61 72  |.."."L - To Lear|
00000f90  6e 20 74 68 65 20 63 6f  69 6e 20 73 69 7a 65 73  |n the coin sizes|
00000fa0  22 0d 08 fc 1d f1 22 43  20 2d 20 54 6f 20 43 6f  |"....."C - To Co|
00000fb0  75 6e 74 20 74 68 65 20  63 6f 69 6e 73 22 0d 09  |unt the coins"..|
00000fc0  06 08 41 24 3d be 0d 09  10 05 f1 0d 09 1a 05 e1  |..A$=...........|
00000fd0  0d ff                                             |..|
00000fd2