Home » Archimedes archive » Archimedes World » AW-1991-02.adf » !AWFeb91/Goodies/ProgARM/Program2

!AWFeb91/Goodies/ProgARM/Program2

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 » Archimedes archive » Archimedes World » AW-1991-02.adf
Filename: !AWFeb91/Goodies/ProgARM/Program2
Read OK:
File size: 0B0A bytes
Load address: FFFFFB42
Exec address: CB48AF5A
File contents
   10REM >Program2
   30MODE 9
   50PROCsetup
   70REM PROCtest
   90name$="robert"
  110buffer%=FNload_sprite(name$)
  130sprite_start%=buffer%+buffer%!(2*4)
  140data_start%  =sprite_start%+sprite_start%!(8*4)
  150data_end%    =sprite_start%+sprite_start%!0
  160palette%     =sprite_start%+11*4
  180FOR I%=0 TO 15
  190  COLOURI%,palette%!(I%*4)
  200NEXT
  220SYS "OS_SpriteOp",34+256,buffer%,name$,0,0,0
  240key=GET
  270FORI%=data_start% TO data_end%-1
  290  sourcebyte% = ?I%
  310  nibA%=sourcebyte% AND &F
  320  nibB%=(sourcebyte% AND &F0)>>4
  340  codeA%=FNencode(nibA%)
  350  codeB%=FNencode(nibB%)
  370  codeA%=FNcorrupt(codeA%,7)
  380  codeB%=FNcorrupt(codeB%,7)
  400  finalA% = FNdecode(codeA%)
  410  finalB% = FNdecode(codeB%)
  430  ?I% = finalA% OR (finalB% << 4)
  450  IF (I% AND &3F ) = 0 THEN
  460    SYS "OS_SpriteOp",34+256,buffer%,name$,0,0,0
  470  ENDIF
  490NEXT
  510SYS "OS_SpriteOp",34+256,buffer%,name$,0,0,0
  530key=GET
  550END
  570DEFFNload_sprite(name$)
  580LOCALlen%,hand%,buf%
  590hand%=OPENIN(name$)
  600IF hand%<>0 THEN
  610  len%=EXT#hand%+&100
  620  DIM buf% len%
  630  buf%!0=len%
  640  buf%!4=0
  650  buf%!8=16
  660  buf%!12=16
  670  SYS "OS_SpriteOp",9+256,buf%
  680  SYS "OS_SpriteOp",10+256,buf%,name$
  690  CLOSE#hand%
  700ENDIF
  710=buf%
  712REM DEFFNcorrupt(data%,bits%)
  713REM =data% EOR FNrndbit(bits%)
  730DEFFNcorrupt(data%,bits%)
  740LOCALI%
  750FORI%=0TObits%-1
  760  IF RND(100) < 5 THEN
  770    data%= data% EOR (1<<I%)
  780  ENDIF
  790NEXT
  800=data%
  820DEFFNrndbit(bits%)
  830LOCALb%
  840b%=RND(bits%)-1
  850=1<<b%
  870DEFFNencode(data%)
  880REM Look up the data in the 16 entry encode table
  890=encodetable%(data%)
  910DEFFNdecode(data%)
  920REM Look up the data in the 128 entry decode table
  930REM Only 16 entries are valid
  940=decodetable%(data%)
  960DEFPROCsetup
  970DIM encodetable%(15)
  980FORI%=0TO15
  990  READ encodetable%(I%)
 1000NEXT
 1020DIM decodetable%(127)
 1040FOR I%=0 TO 127
 1050  decodetable%(I%) = -1
 1060  bestfit%=-1
 1070  bestscore%=8 :REM 8 bits different is impossible
 1080  FOR J%=0 TO 15
 1090    IF I% = encodetable%(J%) THEN
 1100      REM If I is the encode of J then J is the decode of I
 1110      decodetable%(I%) = J%
 1120    ELSE
 1130      score%=FNbitsdif(I%,encodetable%(J%))
 1140      IF score%<bestscore% THEN
 1150        bestfit%=J%
 1160        bestscore%=score%
 1170      ENDIF
 1180    ENDIF
 1190  NEXT
 1200  IF decodetable%(I%) = -1 THEN
 1210    REM This is one of the illegal patterns
 1220    decodetable%(I%) = bestfit%
 1230  ENDIF
 1240NEXT
 1260ENDPROC
 1280DEF FNbitsdif(a%,b%)
 1290LOCALI%,score%
 1300FORI%=0TO6
 1310  bitofa% = a% AND (1<<I%)
 1320  bitofb% = b% AND (1<<I%)
 1330  IF bitofa% = bitofb% THEN
 1340  ELSE
 1350    score%+=1
 1360  ENDIF
 1370NEXT
 1380=score%
 1410REM encode table (2)
 1430DATA %0000000
 1440DATA %1010101
 1450DATA %0110011
 1460DATA %1100110
 1470DATA %0001111
 1480DATA %1011010
 1490DATA %0111100
 1500DATA %1101001
 1520DATA %0010110
 1530DATA %0011001
 1540DATA %0100101
 1550DATA %0101010
 1560DATA %1000011
 1570DATA %1001100
 1580DATA %1110000
 1590DATA %1111111
 1610DEFPROCtest
 1630REPEAT
 1640in%=RND(16)-1
 1660code%=FNencode(in%)
 1680send%=code% EOR FNrndbit(7)
 1700out% = FNdecode(send%)
 1720IF in%<>out% THEN
 1730  PRINT"Error":END
 1740ELSE
 1750  PRINT"OK"
 1760ENDIF
 1780UNTILFALSE
 1800ENDPROC

� >Program2
� 9
2
�setup
F� PROCtest
Zname$="robert"
nbuffer%=�load_sprite(name$)
�'sprite_start%=buffer%+buffer%!(2*4)
�3data_start%  =sprite_start%+sprite_start%!(8*4)
�/data_end%    =sprite_start%+sprite_start%!0
�$palette%     =sprite_start%+11*4
�� I%=0 � 15
�  �I%,palette%!(I%*4)
��
�/ș "OS_SpriteOp",34+256,buffer%,name$,0,0,0
�	key=�
!�I%=data_start% � data_end%-1
"  sourcebyte% = ?I%
6  nibA%=sourcebyte% � &F
@"  nibB%=(sourcebyte% � &F0)>>4
T  codeA%=�encode(nibA%)
^  codeB%=�encode(nibB%)
r  codeA%=�corrupt(codeA%,7)
|  codeB%=�corrupt(codeB%,7)
�  finalA% = �decode(codeA%)
�  finalB% = �decode(codeB%)
�$  ?I% = finalA% � (finalB% << 4)
�  � (I% � &3F ) = 0 �
�3    ș "OS_SpriteOp",34+256,buffer%,name$,0,0,0
�  �
��
�/ș "OS_SpriteOp",34+256,buffer%,name$,0,0,0
	key=�
&�
:ݤload_sprite(name$)
D�len%,hand%,buf%
Nhand%=�(name$)
X� hand%<>0 �
b  len%=�#hand%+&100
l  � buf% len%
v  buf%!0=len%
�  buf%!4=0
�  buf%!8=16
�  buf%!12=16
�!  ș "OS_SpriteOp",9+256,buf%
�(  ș "OS_SpriteOp",10+256,buf%,name$
�
  �#hand%
��
�	=buf%
�� DEFFNcorrupt(data%,bits%)
� � =data% EOR FNrndbit(bits%)
�ݤcorrupt(data%,bits%)
��I%
��I%=0�bits%-1
�  � �(100) < 5 �
    data%= data% � (1<<I%)
  �
�
 
=data%
4ݤrndbit(bits%)
>�b%
Hb%=�(bits%)-1
R
=1<<b%
fݤencode(data%)
p3� Look up the data in the 16 entry encode table
z=encodetable%(data%)
�ݤdecode(data%)
�4� Look up the data in the 128 entry decode table
�� Only 16 entries are valid
�=decodetable%(data%)
���setup
�� encodetable%(15)
��I%=0�15
�  � encodetable%(I%)
��
�� decodetable%(127)
� I%=0 � 127
  decodetable%(I%) = -1
$  bestfit%=-1
.4  bestscore%=8 :� 8 bits different is impossible
8  � J%=0 � 15
B!    � I% = encodetable%(J%) �
L=      � If I is the encode of J then J is the decode of I
V      decodetable%(I%) = J%
`	    �
j.      score%=�bitsdif(I%,encodetable%(J%))
t      � score%<bestscore% �
~        bestfit%=J%
�        bestscore%=score%
�      �
�	    �
�  �
�  � decodetable%(I%) = -1 �
�-    � This is one of the illegal patterns
�#    decodetable%(I%) = bestfit%
�  �
��
��
� �bitsdif(a%,b%)

�I%,score%
�I%=0�6
  bitofa% = a% � (1<<I%)
(  bitofb% = b% � (1<<I%)
2  � bitofa% = bitofb% �
<  �
F    score%+=1
P  �
Z�
d=score%
�� encode table (2)
�� %0000000
�� %1010101
�� %0110011
�� %1100110
�� %0001111
�� %1011010
�� %0111100
�� %1101001
�� %0010110
�� %0011001
� %0100101
� %0101010
� %1000011
"� %1001100
,� %1110000
6� %1111111
J
��test
^�
hin%=�(16)-1
|code%=�encode(in%)
�send%=code% � �rndbit(7)
�out% = �decode(send%)
�� in%<>out% �
�  �"Error":�
��
�  �"OK"
��
���
�
�
00000000  0d 00 0a 0f f4 20 3e 50  72 6f 67 72 61 6d 32 0d  |..... >Program2.|
00000010  00 1e 07 eb 20 39 0d 00  32 0a f2 73 65 74 75 70  |.... 9..2..setup|
00000020  0d 00 46 0e f4 20 50 52  4f 43 74 65 73 74 0d 00  |..F.. PROCtest..|
00000030  5a 12 6e 61 6d 65 24 3d  22 72 6f 62 65 72 74 22  |Z.name$="robert"|
00000040  0d 00 6e 1f 62 75 66 66  65 72 25 3d a4 6c 6f 61  |..n.buffer%=.loa|
00000050  64 5f 73 70 72 69 74 65  28 6e 61 6d 65 24 29 0d  |d_sprite(name$).|
00000060  00 82 27 73 70 72 69 74  65 5f 73 74 61 72 74 25  |..'sprite_start%|
00000070  3d 62 75 66 66 65 72 25  2b 62 75 66 66 65 72 25  |=buffer%+buffer%|
00000080  21 28 32 2a 34 29 0d 00  8c 33 64 61 74 61 5f 73  |!(2*4)...3data_s|
00000090  74 61 72 74 25 20 20 3d  73 70 72 69 74 65 5f 73  |tart%  =sprite_s|
000000a0  74 61 72 74 25 2b 73 70  72 69 74 65 5f 73 74 61  |tart%+sprite_sta|
000000b0  72 74 25 21 28 38 2a 34  29 0d 00 96 2f 64 61 74  |rt%!(8*4).../dat|
000000c0  61 5f 65 6e 64 25 20 20  20 20 3d 73 70 72 69 74  |a_end%    =sprit|
000000d0  65 5f 73 74 61 72 74 25  2b 73 70 72 69 74 65 5f  |e_start%+sprite_|
000000e0  73 74 61 72 74 25 21 30  0d 00 a0 24 70 61 6c 65  |start%!0...$pale|
000000f0  74 74 65 25 20 20 20 20  20 3d 73 70 72 69 74 65  |tte%     =sprite|
00000100  5f 73 74 61 72 74 25 2b  31 31 2a 34 0d 00 b4 0f  |_start%+11*4....|
00000110  e3 20 49 25 3d 30 20 b8  20 31 35 0d 00 be 19 20  |. I%=0 . 15.... |
00000120  20 fb 49 25 2c 70 61 6c  65 74 74 65 25 21 28 49  | .I%,palette%!(I|
00000130  25 2a 34 29 0d 00 c8 05  ed 0d 00 dc 2f c8 99 20  |%*4)......../.. |
00000140  22 4f 53 5f 53 70 72 69  74 65 4f 70 22 2c 33 34  |"OS_SpriteOp",34|
00000150  2b 32 35 36 2c 62 75 66  66 65 72 25 2c 6e 61 6d  |+256,buffer%,nam|
00000160  65 24 2c 30 2c 30 2c 30  0d 00 f0 09 6b 65 79 3d  |e$,0,0,0....key=|
00000170  a5 0d 01 0e 21 e3 49 25  3d 64 61 74 61 5f 73 74  |....!.I%=data_st|
00000180  61 72 74 25 20 b8 20 64  61 74 61 5f 65 6e 64 25  |art% . data_end%|
00000190  2d 31 0d 01 22 17 20 20  73 6f 75 72 63 65 62 79  |-1..".  sourceby|
000001a0  74 65 25 20 3d 20 3f 49  25 0d 01 36 1c 20 20 6e  |te% = ?I%..6.  n|
000001b0  69 62 41 25 3d 73 6f 75  72 63 65 62 79 74 65 25  |ibA%=sourcebyte%|
000001c0  20 80 20 26 46 0d 01 40  22 20 20 6e 69 62 42 25  | . &F..@"  nibB%|
000001d0  3d 28 73 6f 75 72 63 65  62 79 74 65 25 20 80 20  |=(sourcebyte% . |
000001e0  26 46 30 29 3e 3e 34 0d  01 54 1b 20 20 63 6f 64  |&F0)>>4..T.  cod|
000001f0  65 41 25 3d a4 65 6e 63  6f 64 65 28 6e 69 62 41  |eA%=.encode(nibA|
00000200  25 29 0d 01 5e 1b 20 20  63 6f 64 65 42 25 3d a4  |%)..^.  codeB%=.|
00000210  65 6e 63 6f 64 65 28 6e  69 62 42 25 29 0d 01 72  |encode(nibB%)..r|
00000220  1f 20 20 63 6f 64 65 41  25 3d a4 63 6f 72 72 75  |.  codeA%=.corru|
00000230  70 74 28 63 6f 64 65 41  25 2c 37 29 0d 01 7c 1f  |pt(codeA%,7)..|.|
00000240  20 20 63 6f 64 65 42 25  3d a4 63 6f 72 72 75 70  |  codeB%=.corrup|
00000250  74 28 63 6f 64 65 42 25  2c 37 29 0d 01 90 1f 20  |t(codeB%,7).... |
00000260  20 66 69 6e 61 6c 41 25  20 3d 20 a4 64 65 63 6f  | finalA% = .deco|
00000270  64 65 28 63 6f 64 65 41  25 29 0d 01 9a 1f 20 20  |de(codeA%)....  |
00000280  66 69 6e 61 6c 42 25 20  3d 20 a4 64 65 63 6f 64  |finalB% = .decod|
00000290  65 28 63 6f 64 65 42 25  29 0d 01 ae 24 20 20 3f  |e(codeB%)...$  ?|
000002a0  49 25 20 3d 20 66 69 6e  61 6c 41 25 20 84 20 28  |I% = finalA% . (|
000002b0  66 69 6e 61 6c 42 25 20  3c 3c 20 34 29 0d 01 c2  |finalB% << 4)...|
000002c0  19 20 20 e7 20 28 49 25  20 80 20 26 33 46 20 29  |.  . (I% . &3F )|
000002d0  20 3d 20 30 20 8c 0d 01  cc 33 20 20 20 20 c8 99  | = 0 ....3    ..|
000002e0  20 22 4f 53 5f 53 70 72  69 74 65 4f 70 22 2c 33  | "OS_SpriteOp",3|
000002f0  34 2b 32 35 36 2c 62 75  66 66 65 72 25 2c 6e 61  |4+256,buffer%,na|
00000300  6d 65 24 2c 30 2c 30 2c  30 0d 01 d6 07 20 20 cd  |me$,0,0,0....  .|
00000310  0d 01 ea 05 ed 0d 01 fe  2f c8 99 20 22 4f 53 5f  |......../.. "OS_|
00000320  53 70 72 69 74 65 4f 70  22 2c 33 34 2b 32 35 36  |SpriteOp",34+256|
00000330  2c 62 75 66 66 65 72 25  2c 6e 61 6d 65 24 2c 30  |,buffer%,name$,0|
00000340  2c 30 2c 30 0d 02 12 09  6b 65 79 3d a5 0d 02 26  |,0,0....key=...&|
00000350  05 e0 0d 02 3a 18 dd a4  6c 6f 61 64 5f 73 70 72  |....:...load_spr|
00000360  69 74 65 28 6e 61 6d 65  24 29 0d 02 44 14 ea 6c  |ite(name$)..D..l|
00000370  65 6e 25 2c 68 61 6e 64  25 2c 62 75 66 25 0d 02  |en%,hand%,buf%..|
00000380  4e 12 68 61 6e 64 25 3d  8e 28 6e 61 6d 65 24 29  |N.hand%=.(name$)|
00000390  0d 02 58 10 e7 20 68 61  6e 64 25 3c 3e 30 20 8c  |..X.. hand%<>0 .|
000003a0  0d 02 62 17 20 20 6c 65  6e 25 3d a2 23 68 61 6e  |..b.  len%=.#han|
000003b0  64 25 2b 26 31 30 30 0d  02 6c 11 20 20 de 20 62  |d%+&100..l.  . b|
000003c0  75 66 25 20 6c 65 6e 25  0d 02 76 11 20 20 62 75  |uf% len%..v.  bu|
000003d0  66 25 21 30 3d 6c 65 6e  25 0d 02 80 0e 20 20 62  |f%!0=len%....  b|
000003e0  75 66 25 21 34 3d 30 0d  02 8a 0f 20 20 62 75 66  |uf%!4=0....  buf|
000003f0  25 21 38 3d 31 36 0d 02  94 10 20 20 62 75 66 25  |%!8=16....  buf%|
00000400  21 31 32 3d 31 36 0d 02  9e 21 20 20 c8 99 20 22  |!12=16...!  .. "|
00000410  4f 53 5f 53 70 72 69 74  65 4f 70 22 2c 39 2b 32  |OS_SpriteOp",9+2|
00000420  35 36 2c 62 75 66 25 0d  02 a8 28 20 20 c8 99 20  |56,buf%...(  .. |
00000430  22 4f 53 5f 53 70 72 69  74 65 4f 70 22 2c 31 30  |"OS_SpriteOp",10|
00000440  2b 32 35 36 2c 62 75 66  25 2c 6e 61 6d 65 24 0d  |+256,buf%,name$.|
00000450  02 b2 0d 20 20 d9 23 68  61 6e 64 25 0d 02 bc 05  |...  .#hand%....|
00000460  cd 0d 02 c6 09 3d 62 75  66 25 0d 02 c8 1f f4 20  |.....=buf%..... |
00000470  44 45 46 46 4e 63 6f 72  72 75 70 74 28 64 61 74  |DEFFNcorrupt(dat|
00000480  61 25 2c 62 69 74 73 25  29 0d 02 c9 20 f4 20 3d  |a%,bits%)... . =|
00000490  64 61 74 61 25 20 45 4f  52 20 46 4e 72 6e 64 62  |data% EOR FNrndb|
000004a0  69 74 28 62 69 74 73 25  29 0d 02 da 1a dd a4 63  |it(bits%)......c|
000004b0  6f 72 72 75 70 74 28 64  61 74 61 25 2c 62 69 74  |orrupt(data%,bit|
000004c0  73 25 29 0d 02 e4 07 ea  49 25 0d 02 ee 11 e3 49  |s%).....I%.....I|
000004d0  25 3d 30 b8 62 69 74 73  25 2d 31 0d 02 f8 14 20  |%=0.bits%-1.... |
000004e0  20 e7 20 b3 28 31 30 30  29 20 3c 20 35 20 8c 0d  | . .(100) < 5 ..|
000004f0  03 02 1e 20 20 20 20 64  61 74 61 25 3d 20 64 61  |...    data%= da|
00000500  74 61 25 20 82 20 28 31  3c 3c 49 25 29 0d 03 0c  |ta% . (1<<I%)...|
00000510  07 20 20 cd 0d 03 16 05  ed 0d 03 20 0a 3d 64 61  |.  ........ .=da|
00000520  74 61 25 0d 03 34 13 dd  a4 72 6e 64 62 69 74 28  |ta%..4...rndbit(|
00000530  62 69 74 73 25 29 0d 03  3e 07 ea 62 25 0d 03 48  |bits%)..>..b%..H|
00000540  11 62 25 3d b3 28 62 69  74 73 25 29 2d 31 0d 03  |.b%=.(bits%)-1..|
00000550  52 0a 3d 31 3c 3c 62 25  0d 03 66 13 dd a4 65 6e  |R.=1<<b%..f...en|
00000560  63 6f 64 65 28 64 61 74  61 25 29 0d 03 70 33 f4  |code(data%)..p3.|
00000570  20 4c 6f 6f 6b 20 75 70  20 74 68 65 20 64 61 74  | Look up the dat|
00000580  61 20 69 6e 20 74 68 65  20 31 36 20 65 6e 74 72  |a in the 16 entr|
00000590  79 20 65 6e 63 6f 64 65  20 74 61 62 6c 65 0d 03  |y encode table..|
000005a0  7a 18 3d 65 6e 63 6f 64  65 74 61 62 6c 65 25 28  |z.=encodetable%(|
000005b0  64 61 74 61 25 29 0d 03  8e 13 dd a4 64 65 63 6f  |data%)......deco|
000005c0  64 65 28 64 61 74 61 25  29 0d 03 98 34 f4 20 4c  |de(data%)...4. L|
000005d0  6f 6f 6b 20 75 70 20 74  68 65 20 64 61 74 61 20  |ook up the data |
000005e0  69 6e 20 74 68 65 20 31  32 38 20 65 6e 74 72 79  |in the 128 entry|
000005f0  20 64 65 63 6f 64 65 20  74 61 62 6c 65 0d 03 a2  | decode table...|
00000600  1f f4 20 4f 6e 6c 79 20  31 36 20 65 6e 74 72 69  |.. Only 16 entri|
00000610  65 73 20 61 72 65 20 76  61 6c 69 64 0d 03 ac 18  |es are valid....|
00000620  3d 64 65 63 6f 64 65 74  61 62 6c 65 25 28 64 61  |=decodetable%(da|
00000630  74 61 25 29 0d 03 c0 0b  dd f2 73 65 74 75 70 0d  |ta%)......setup.|
00000640  03 ca 16 de 20 65 6e 63  6f 64 65 74 61 62 6c 65  |.... encodetable|
00000650  25 28 31 35 29 0d 03 d4  0c e3 49 25 3d 30 b8 31  |%(15).....I%=0.1|
00000660  35 0d 03 de 18 20 20 f3  20 65 6e 63 6f 64 65 74  |5....  . encodet|
00000670  61 62 6c 65 25 28 49 25  29 0d 03 e8 05 ed 0d 03  |able%(I%).......|
00000680  fc 17 de 20 64 65 63 6f  64 65 74 61 62 6c 65 25  |... decodetable%|
00000690  28 31 32 37 29 0d 04 10  10 e3 20 49 25 3d 30 20  |(127)..... I%=0 |
000006a0  b8 20 31 32 37 0d 04 1a  1b 20 20 64 65 63 6f 64  |. 127....  decod|
000006b0  65 74 61 62 6c 65 25 28  49 25 29 20 3d 20 2d 31  |etable%(I%) = -1|
000006c0  0d 04 24 11 20 20 62 65  73 74 66 69 74 25 3d 2d  |..$.  bestfit%=-|
000006d0  31 0d 04 2e 34 20 20 62  65 73 74 73 63 6f 72 65  |1...4  bestscore|
000006e0  25 3d 38 20 3a f4 20 38  20 62 69 74 73 20 64 69  |%=8 :. 8 bits di|
000006f0  66 66 65 72 65 6e 74 20  69 73 20 69 6d 70 6f 73  |fferent is impos|
00000700  73 69 62 6c 65 0d 04 38  11 20 20 e3 20 4a 25 3d  |sible..8.  . J%=|
00000710  30 20 b8 20 31 35 0d 04  42 21 20 20 20 20 e7 20  |0 . 15..B!    . |
00000720  49 25 20 3d 20 65 6e 63  6f 64 65 74 61 62 6c 65  |I% = encodetable|
00000730  25 28 4a 25 29 20 8c 0d  04 4c 3d 20 20 20 20 20  |%(J%) ...L=     |
00000740  20 f4 20 49 66 20 49 20  69 73 20 74 68 65 20 65  | . If I is the e|
00000750  6e 63 6f 64 65 20 6f 66  20 4a 20 74 68 65 6e 20  |ncode of J then |
00000760  4a 20 69 73 20 74 68 65  20 64 65 63 6f 64 65 20  |J is the decode |
00000770  6f 66 20 49 0d 04 56 1f  20 20 20 20 20 20 64 65  |of I..V.      de|
00000780  63 6f 64 65 74 61 62 6c  65 25 28 49 25 29 20 3d  |codetable%(I%) =|
00000790  20 4a 25 0d 04 60 09 20  20 20 20 cc 0d 04 6a 2e  | J%..`.    ...j.|
000007a0  20 20 20 20 20 20 73 63  6f 72 65 25 3d a4 62 69  |      score%=.bi|
000007b0  74 73 64 69 66 28 49 25  2c 65 6e 63 6f 64 65 74  |tsdif(I%,encodet|
000007c0  61 62 6c 65 25 28 4a 25  29 29 0d 04 74 1f 20 20  |able%(J%))..t.  |
000007d0  20 20 20 20 e7 20 73 63  6f 72 65 25 3c 62 65 73  |    . score%<bes|
000007e0  74 73 63 6f 72 65 25 20  8c 0d 04 7e 17 20 20 20  |tscore% ...~.   |
000007f0  20 20 20 20 20 62 65 73  74 66 69 74 25 3d 4a 25  |     bestfit%=J%|
00000800  0d 04 88 1d 20 20 20 20  20 20 20 20 62 65 73 74  |....        best|
00000810  73 63 6f 72 65 25 3d 73  63 6f 72 65 25 0d 04 92  |score%=score%...|
00000820  0b 20 20 20 20 20 20 cd  0d 04 9c 09 20 20 20 20  |.      .....    |
00000830  cd 0d 04 a6 07 20 20 ed  0d 04 b0 1f 20 20 e7 20  |.....  .....  . |
00000840  64 65 63 6f 64 65 74 61  62 6c 65 25 28 49 25 29  |decodetable%(I%)|
00000850  20 3d 20 2d 31 20 8c 0d  04 ba 2d 20 20 20 20 f4  | = -1 ....-    .|
00000860  20 54 68 69 73 20 69 73  20 6f 6e 65 20 6f 66 20  | This is one of |
00000870  74 68 65 20 69 6c 6c 65  67 61 6c 20 70 61 74 74  |the illegal patt|
00000880  65 72 6e 73 0d 04 c4 23  20 20 20 20 64 65 63 6f  |erns...#    deco|
00000890  64 65 74 61 62 6c 65 25  28 49 25 29 20 3d 20 62  |detable%(I%) = b|
000008a0  65 73 74 66 69 74 25 0d  04 ce 07 20 20 cd 0d 04  |estfit%....  ...|
000008b0  d8 05 ed 0d 04 ec 05 e1  0d 05 00 15 dd 20 a4 62  |............. .b|
000008c0  69 74 73 64 69 66 28 61  25 2c 62 25 29 0d 05 0a  |itsdif(a%,b%)...|
000008d0  0e ea 49 25 2c 73 63 6f  72 65 25 0d 05 14 0b e3  |..I%,score%.....|
000008e0  49 25 3d 30 b8 36 0d 05  1e 1c 20 20 62 69 74 6f  |I%=0.6....  bito|
000008f0  66 61 25 20 3d 20 61 25  20 80 20 28 31 3c 3c 49  |fa% = a% . (1<<I|
00000900  25 29 0d 05 28 1c 20 20  62 69 74 6f 66 62 25 20  |%)..(.  bitofb% |
00000910  3d 20 62 25 20 80 20 28  31 3c 3c 49 25 29 0d 05  |= b% . (1<<I%)..|
00000920  32 1b 20 20 e7 20 62 69  74 6f 66 61 25 20 3d 20  |2.  . bitofa% = |
00000930  62 69 74 6f 66 62 25 20  8c 0d 05 3c 07 20 20 cc  |bitofb% ...<.  .|
00000940  0d 05 46 11 20 20 20 20  73 63 6f 72 65 25 2b 3d  |..F.    score%+=|
00000950  31 0d 05 50 07 20 20 cd  0d 05 5a 05 ed 0d 05 64  |1..P.  ...Z....d|
00000960  0b 3d 73 63 6f 72 65 25  0d 05 82 16 f4 20 65 6e  |.=score%..... en|
00000970  63 6f 64 65 20 74 61 62  6c 65 20 28 32 29 0d 05  |code table (2)..|
00000980  96 0e dc 20 25 30 30 30  30 30 30 30 0d 05 a0 0e  |... %0000000....|
00000990  dc 20 25 31 30 31 30 31  30 31 0d 05 aa 0e dc 20  |. %1010101..... |
000009a0  25 30 31 31 30 30 31 31  0d 05 b4 0e dc 20 25 31  |%0110011..... %1|
000009b0  31 30 30 31 31 30 0d 05  be 0e dc 20 25 30 30 30  |100110..... %000|
000009c0  31 31 31 31 0d 05 c8 0e  dc 20 25 31 30 31 31 30  |1111..... %10110|
000009d0  31 30 0d 05 d2 0e dc 20  25 30 31 31 31 31 30 30  |10..... %0111100|
000009e0  0d 05 dc 0e dc 20 25 31  31 30 31 30 30 31 0d 05  |..... %1101001..|
000009f0  f0 0e dc 20 25 30 30 31  30 31 31 30 0d 05 fa 0e  |... %0010110....|
00000a00  dc 20 25 30 30 31 31 30  30 31 0d 06 04 0e dc 20  |. %0011001..... |
00000a10  25 30 31 30 30 31 30 31  0d 06 0e 0e dc 20 25 30  |%0100101..... %0|
00000a20  31 30 31 30 31 30 0d 06  18 0e dc 20 25 31 30 30  |101010..... %100|
00000a30  30 30 31 31 0d 06 22 0e  dc 20 25 31 30 30 31 31  |0011..".. %10011|
00000a40  30 30 0d 06 2c 0e dc 20  25 31 31 31 30 30 30 30  |00..,.. %1110000|
00000a50  0d 06 36 0e dc 20 25 31  31 31 31 31 31 31 0d 06  |..6.. %1111111..|
00000a60  4a 0a dd f2 74 65 73 74  0d 06 5e 05 f5 0d 06 68  |J...test..^....h|
00000a70  0f 69 6e 25 3d b3 28 31  36 29 2d 31 0d 06 7c 16  |.in%=.(16)-1..|.|
00000a80  63 6f 64 65 25 3d a4 65  6e 63 6f 64 65 28 69 6e  |code%=.encode(in|
00000a90  25 29 0d 06 90 1c 73 65  6e 64 25 3d 63 6f 64 65  |%)....send%=code|
00000aa0  25 20 82 20 a4 72 6e 64  62 69 74 28 37 29 0d 06  |% . .rndbit(7)..|
00000ab0  a4 19 6f 75 74 25 20 3d  20 a4 64 65 63 6f 64 65  |..out% = .decode|
00000ac0  28 73 65 6e 64 25 29 0d  06 b8 11 e7 20 69 6e 25  |(send%)..... in%|
00000ad0  3c 3e 6f 75 74 25 20 8c  0d 06 c2 10 20 20 f1 22  |<>out% .....  ."|
00000ae0  45 72 72 6f 72 22 3a e0  0d 06 cc 05 cc 0d 06 d6  |Error":.........|
00000af0  0b 20 20 f1 22 4f 4b 22  0d 06 e0 05 cd 0d 06 f4  |.  ."OK"........|
00000b00  06 fd a3 0d 07 08 05 e1  0d ff                    |..........|
00000b0a