Home » Archimedes archive » Acorn User » AU 1997-02 B.adf » Regulars » StarInfo/circles/Jeffs/Jellyfish

StarInfo/circles/Jeffs/Jellyfish

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 » Acorn User » AU 1997-02 B.adf » Regulars
Filename: StarInfo/circles/Jeffs/Jellyfish
Read OK:
File size: 06B7 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM  Acorn User circle challenge
   20REM  Jellyfish (animated) - by R W Jeffs
   30:
   40REM  The first ring in the tail follows a sin wave motion, but waits for
   50REM  the rest of the tail to catch up every 180 degrees.
   60REM  Each ring of the tail follows the leader.
   70REM  The rings are slower in opening than closing.
   80REM  Forward motion is increased on the 'push'.
   90:
  100MODE 27:PROCreserve:OFF
  110R%=20
  120DIM seqr(R%)
  130cx%=640:cy%=480:F%=512
  140:
  150space%=5:min%=40:expand%=10
  160REPEAT
  170 A%=0:Z%=(R%+1)*space%:X%=RND(300)-200:Y%=RND(300)-200
  180 REPEAT
  190  seqr(0)=min%+COS(RAD(A%))*expand%
  200  PROCjfish(X%,Y%)
  210  PROCswap_screens
  220  PROCflow
  230 UNTILINKEY-99 OR Z%>1500
  240UNTIL FALSE
  250END
  260:
  270REM  Draw the jellyfish
  280:
  290DEF PROCjfish(X%,Y%)
  300LOCAL P%,ZF%,x%,y%,r%
  310WAIT
  320FOR H%=45 TO 359 STEP 90
  330 CIRCLE (X%+SIN(RAD(H%))*20)/Z%*F%+cx%,(Y%+COS(RAD(H%))*20)/Z%*F%+cy%,10/Z%*F%
  340NEXT
  350CIRCLE X%/Z%*F%+cx%,Y%/Z%*F%+cy%,60/Z%*F%
  360FOR P%=0 TO R%
  370 ZF%=(Z%-P%*space%)
  380 x%=X%/ZF%*F%+cx%
  390 y%=Y%/ZF%*F%+cy%
  400 r%=seqr(P%)/ZF%*F%
  410 CIRCLE x%,y%,r%
  420NEXT
  430ENDPROC
  440:
  450REM  The following routine controls the tail.
  460:
  470DEF PROCflow
  480LOCAL S%
  490FOR S%=1 TO R%
  500 IF seqr(S%-1)>seqr(S%) THEN
  510  seqr(S%)+=(seqr(S%-1)-seqr(S%))*.3
  520 ELSE
  530  seqr(S%)+=(seqr(S%-1)-seqr(S%))*.4
  540 ENDIF
  550NEXT
  560IF (A% MOD 180)<>0 OR ABS(seqr(0)-seqr(R%))<2 THEN
  570 IF A%<180 Z%+=SIN(RAD(A%))*4+2:A%+=6 ELSE Z%+=1:A%+=5
  580ELSE
  590 Z%+=2
  600ENDIF
  610IF A%>=360 A%-=360
  620ENDPROC
  630:
  640REM  Reserve memory for 3 screens
  650:
  660DEF PROCreserve
  670SYS &5C,2 TO ,screenalloc
  680additional=320*480*3-screenalloc
  690IF additional>0 SYS &2A,2,additional
  700SYS 6,112,3:CLS:SYS 6,112,2:CLS:SYS 6,112,1:CLS:SYS 6,113,1
  710SYS 6,112,2:screen%=2
  720ENDPROC
  730:
  740DEF PROCswap_screens
  750WAIT:SYS 6,113,screen%
  760screen%+=1:IF screen%=4 screen%=1
  770SYS 6,112,screen%:CLS
  780ENDPROC
  790
  800

"�  Acorn User circle challenge
*�  Jellyfish (animated) - by R W Jeffs
:
(J�  The first ring in the tail follows a sin wave motion, but waits for
2:�  the rest of the tail to catch up every 180 degrees.
<0�  Each ring of the tail follows the leader.
F4�  The rings are slower in opening than closing.
P1�  Forward motion is increased on the 'push'.
Z:
d� 27:�reserve:�
n	R%=20
x� seqr(R%)
�cx%=640:cy%=480:F%=512
�:
�space%=5:min%=40:expand%=10
��
�6 A%=0:Z%=(R%+1)*space%:X%=�(300)-200:Y%=�(300)-200
� �
�#  seqr(0)=min%+�(�(A%))*expand%
�  �jfish(X%,Y%)
�  �swap_screens
�  �flow
� ��-99 � Z%>1500
�� �
��
:
�  Draw the jellyfish
:
"� �jfish(X%,Y%)
,� P%,ZF%,x%,y%,r%
6Ȗ
@� H%=45 � 359 � 90
JF ȏ (X%+�(�(H%))*20)/Z%*F%+cx%,(Y%+�(�(H%))*20)/Z%*F%+cy%,10/Z%*F%
T�
^)ȏ X%/Z%*F%+cx%,Y%/Z%*F%+cy%,60/Z%*F%
h� P%=0 � R%
r ZF%=(Z%-P%*space%)
| x%=X%/ZF%*F%+cx%
� y%=Y%/ZF%*F%+cy%
� r%=seqr(P%)/ZF%*F%
� ȏ x%,y%,r%
��
��
�:
�/�  The following routine controls the tail.
�:
�� �flow
�� S%
�� S%=1 � R%
� � seqr(S%-1)>seqr(S%) �
�(  seqr(S%)+=(seqr(S%-1)-seqr(S%))*.3
 �
(  seqr(S%)+=(seqr(S%-1)-seqr(S%))*.4
 �
&�
0-� (A% � 180)<>0 � �(seqr(0)-seqr(R%))<2 �
:2 � A%<180 Z%+=�(�(A%))*4+2:A%+=6 � Z%+=1:A%+=5
D�
N
 Z%+=2
X�
b� A%>=360 A%-=360
l�
v:
�#�  Reserve memory for 3 screens
�:
�� �reserve
�ș &5C,2 � ,screenalloc
�$additional=320*480*3-screenalloc
�&� additional>0 ș &2A,2,additional
�5ș 6,112,3:�:ș 6,112,2:�:ș 6,112,1:�:ș 6,113,1
�ș 6,112,2:screen%=2
��
�:
�� �swap_screens
�Ȗ:ș 6,113,screen%
�$screen%+=1:� screen%=4 screen%=1
ș 6,112,screen%:�
�

 
�
00000000  0d 00 0a 22 f4 20 20 41  63 6f 72 6e 20 55 73 65  |...".  Acorn Use|
00000010  72 20 63 69 72 63 6c 65  20 63 68 61 6c 6c 65 6e  |r circle challen|
00000020  67 65 0d 00 14 2a f4 20  20 4a 65 6c 6c 79 66 69  |ge...*.  Jellyfi|
00000030  73 68 20 28 61 6e 69 6d  61 74 65 64 29 20 2d 20  |sh (animated) - |
00000040  62 79 20 52 20 57 20 4a  65 66 66 73 0d 00 1e 05  |by R W Jeffs....|
00000050  3a 0d 00 28 4a f4 20 20  54 68 65 20 66 69 72 73  |:..(J.  The firs|
00000060  74 20 72 69 6e 67 20 69  6e 20 74 68 65 20 74 61  |t ring in the ta|
00000070  69 6c 20 66 6f 6c 6c 6f  77 73 20 61 20 73 69 6e  |il follows a sin|
00000080  20 77 61 76 65 20 6d 6f  74 69 6f 6e 2c 20 62 75  | wave motion, bu|
00000090  74 20 77 61 69 74 73 20  66 6f 72 0d 00 32 3a f4  |t waits for..2:.|
000000a0  20 20 74 68 65 20 72 65  73 74 20 6f 66 20 74 68  |  the rest of th|
000000b0  65 20 74 61 69 6c 20 74  6f 20 63 61 74 63 68 20  |e tail to catch |
000000c0  75 70 20 65 76 65 72 79  20 31 38 30 20 64 65 67  |up every 180 deg|
000000d0  72 65 65 73 2e 0d 00 3c  30 f4 20 20 45 61 63 68  |rees...<0.  Each|
000000e0  20 72 69 6e 67 20 6f 66  20 74 68 65 20 74 61 69  | ring of the tai|
000000f0  6c 20 66 6f 6c 6c 6f 77  73 20 74 68 65 20 6c 65  |l follows the le|
00000100  61 64 65 72 2e 0d 00 46  34 f4 20 20 54 68 65 20  |ader...F4.  The |
00000110  72 69 6e 67 73 20 61 72  65 20 73 6c 6f 77 65 72  |rings are slower|
00000120  20 69 6e 20 6f 70 65 6e  69 6e 67 20 74 68 61 6e  | in opening than|
00000130  20 63 6c 6f 73 69 6e 67  2e 0d 00 50 31 f4 20 20  | closing...P1.  |
00000140  46 6f 72 77 61 72 64 20  6d 6f 74 69 6f 6e 20 69  |Forward motion i|
00000150  73 20 69 6e 63 72 65 61  73 65 64 20 6f 6e 20 74  |s increased on t|
00000160  68 65 20 27 70 75 73 68  27 2e 0d 00 5a 05 3a 0d  |he 'push'...Z.:.|
00000170  00 64 13 eb 20 32 37 3a  f2 72 65 73 65 72 76 65  |.d.. 27:.reserve|
00000180  3a 87 0d 00 6e 09 52 25  3d 32 30 0d 00 78 0e de  |:...n.R%=20..x..|
00000190  20 73 65 71 72 28 52 25  29 0d 00 82 1a 63 78 25  | seqr(R%)....cx%|
000001a0  3d 36 34 30 3a 63 79 25  3d 34 38 30 3a 46 25 3d  |=640:cy%=480:F%=|
000001b0  35 31 32 0d 00 8c 05 3a  0d 00 96 1f 73 70 61 63  |512....:....spac|
000001c0  65 25 3d 35 3a 6d 69 6e  25 3d 34 30 3a 65 78 70  |e%=5:min%=40:exp|
000001d0  61 6e 64 25 3d 31 30 0d  00 a0 05 f5 0d 00 aa 36  |and%=10........6|
000001e0  20 41 25 3d 30 3a 5a 25  3d 28 52 25 2b 31 29 2a  | A%=0:Z%=(R%+1)*|
000001f0  73 70 61 63 65 25 3a 58  25 3d b3 28 33 30 30 29  |space%:X%=.(300)|
00000200  2d 32 30 30 3a 59 25 3d  b3 28 33 30 30 29 2d 32  |-200:Y%=.(300)-2|
00000210  30 30 0d 00 b4 06 20 f5  0d 00 be 23 20 20 73 65  |00.... ....#  se|
00000220  71 72 28 30 29 3d 6d 69  6e 25 2b 9b 28 b2 28 41  |qr(0)=min%+.(.(A|
00000230  25 29 29 2a 65 78 70 61  6e 64 25 0d 00 c8 13 20  |%))*expand%.... |
00000240  20 f2 6a 66 69 73 68 28  58 25 2c 59 25 29 0d 00  | .jfish(X%,Y%)..|
00000250  d2 13 20 20 f2 73 77 61  70 5f 73 63 72 65 65 6e  |..  .swap_screen|
00000260  73 0d 00 dc 0b 20 20 f2  66 6c 6f 77 0d 00 e6 14  |s....  .flow....|
00000270  20 fd a6 2d 39 39 20 84  20 5a 25 3e 31 35 30 30  | ..-99 . Z%>1500|
00000280  0d 00 f0 07 fd 20 a3 0d  00 fa 05 e0 0d 01 04 05  |..... ..........|
00000290  3a 0d 01 0e 19 f4 20 20  44 72 61 77 20 74 68 65  |:.....  Draw the|
000002a0  20 6a 65 6c 6c 79 66 69  73 68 0d 01 18 05 3a 0d  | jellyfish....:.|
000002b0  01 22 13 dd 20 f2 6a 66  69 73 68 28 58 25 2c 59  |.".. .jfish(X%,Y|
000002c0  25 29 0d 01 2c 15 ea 20  50 25 2c 5a 46 25 2c 78  |%)..,.. P%,ZF%,x|
000002d0  25 2c 79 25 2c 72 25 0d  01 36 06 c8 96 0d 01 40  |%,y%,r%..6.....@|
000002e0  16 e3 20 48 25 3d 34 35  20 b8 20 33 35 39 20 88  |.. H%=45 . 359 .|
000002f0  20 39 30 0d 01 4a 46 20  c8 8f 20 28 58 25 2b b5  | 90..JF .. (X%+.|
00000300  28 b2 28 48 25 29 29 2a  32 30 29 2f 5a 25 2a 46  |(.(H%))*20)/Z%*F|
00000310  25 2b 63 78 25 2c 28 59  25 2b 9b 28 b2 28 48 25  |%+cx%,(Y%+.(.(H%|
00000320  29 29 2a 32 30 29 2f 5a  25 2a 46 25 2b 63 79 25  |))*20)/Z%*F%+cy%|
00000330  2c 31 30 2f 5a 25 2a 46  25 0d 01 54 05 ed 0d 01  |,10/Z%*F%..T....|
00000340  5e 29 c8 8f 20 58 25 2f  5a 25 2a 46 25 2b 63 78  |^).. X%/Z%*F%+cx|
00000350  25 2c 59 25 2f 5a 25 2a  46 25 2b 63 79 25 2c 36  |%,Y%/Z%*F%+cy%,6|
00000360  30 2f 5a 25 2a 46 25 0d  01 68 0f e3 20 50 25 3d  |0/Z%*F%..h.. P%=|
00000370  30 20 b8 20 52 25 0d 01  72 17 20 5a 46 25 3d 28  |0 . R%..r. ZF%=(|
00000380  5a 25 2d 50 25 2a 73 70  61 63 65 25 29 0d 01 7c  |Z%-P%*space%)..||
00000390  15 20 78 25 3d 58 25 2f  5a 46 25 2a 46 25 2b 63  |. x%=X%/ZF%*F%+c|
000003a0  78 25 0d 01 86 15 20 79  25 3d 59 25 2f 5a 46 25  |x%.... y%=Y%/ZF%|
000003b0  2a 46 25 2b 63 79 25 0d  01 90 17 20 72 25 3d 73  |*F%+cy%.... r%=s|
000003c0  65 71 72 28 50 25 29 2f  5a 46 25 2a 46 25 0d 01  |eqr(P%)/ZF%*F%..|
000003d0  9a 10 20 c8 8f 20 78 25  2c 79 25 2c 72 25 0d 01  |.. .. x%,y%,r%..|
000003e0  a4 05 ed 0d 01 ae 05 e1  0d 01 b8 05 3a 0d 01 c2  |............:...|
000003f0  2f f4 20 20 54 68 65 20  66 6f 6c 6c 6f 77 69 6e  |/.  The followin|
00000400  67 20 72 6f 75 74 69 6e  65 20 63 6f 6e 74 72 6f  |g routine contro|
00000410  6c 73 20 74 68 65 20 74  61 69 6c 2e 0d 01 cc 05  |ls the tail.....|
00000420  3a 0d 01 d6 0b dd 20 f2  66 6c 6f 77 0d 01 e0 08  |:..... .flow....|
00000430  ea 20 53 25 0d 01 ea 0f  e3 20 53 25 3d 31 20 b8  |. S%..... S%=1 .|
00000440  20 52 25 0d 01 f4 1c 20  e7 20 73 65 71 72 28 53  | R%.... . seqr(S|
00000450  25 2d 31 29 3e 73 65 71  72 28 53 25 29 20 8c 0d  |%-1)>seqr(S%) ..|
00000460  01 fe 28 20 20 73 65 71  72 28 53 25 29 2b 3d 28  |..(  seqr(S%)+=(|
00000470  73 65 71 72 28 53 25 2d  31 29 2d 73 65 71 72 28  |seqr(S%-1)-seqr(|
00000480  53 25 29 29 2a 2e 33 0d  02 08 06 20 cc 0d 02 12  |S%))*.3.... ....|
00000490  28 20 20 73 65 71 72 28  53 25 29 2b 3d 28 73 65  |(  seqr(S%)+=(se|
000004a0  71 72 28 53 25 2d 31 29  2d 73 65 71 72 28 53 25  |qr(S%-1)-seqr(S%|
000004b0  29 29 2a 2e 34 0d 02 1c  06 20 cd 0d 02 26 05 ed  |))*.4.... ...&..|
000004c0  0d 02 30 2d e7 20 28 41  25 20 83 20 31 38 30 29  |..0-. (A% . 180)|
000004d0  3c 3e 30 20 84 20 94 28  73 65 71 72 28 30 29 2d  |<>0 . .(seqr(0)-|
000004e0  73 65 71 72 28 52 25 29  29 3c 32 20 8c 0d 02 3a  |seqr(R%))<2 ...:|
000004f0  32 20 e7 20 41 25 3c 31  38 30 20 5a 25 2b 3d b5  |2 . A%<180 Z%+=.|
00000500  28 b2 28 41 25 29 29 2a  34 2b 32 3a 41 25 2b 3d  |(.(A%))*4+2:A%+=|
00000510  36 20 8b 20 5a 25 2b 3d  31 3a 41 25 2b 3d 35 0d  |6 . Z%+=1:A%+=5.|
00000520  02 44 05 cc 0d 02 4e 0a  20 5a 25 2b 3d 32 0d 02  |.D....N. Z%+=2..|
00000530  58 05 cd 0d 02 62 15 e7  20 41 25 3e 3d 33 36 30  |X....b.. A%>=360|
00000540  20 41 25 2d 3d 33 36 30  0d 02 6c 05 e1 0d 02 76  | A%-=360..l....v|
00000550  05 3a 0d 02 80 23 f4 20  20 52 65 73 65 72 76 65  |.:...#.  Reserve|
00000560  20 6d 65 6d 6f 72 79 20  66 6f 72 20 33 20 73 63  | memory for 3 sc|
00000570  72 65 65 6e 73 0d 02 8a  05 3a 0d 02 94 0e dd 20  |reens....:..... |
00000580  f2 72 65 73 65 72 76 65  0d 02 9e 1b c8 99 20 26  |.reserve...... &|
00000590  35 43 2c 32 20 b8 20 2c  73 63 72 65 65 6e 61 6c  |5C,2 . ,screenal|
000005a0  6c 6f 63 0d 02 a8 24 61  64 64 69 74 69 6f 6e 61  |loc...$additiona|
000005b0  6c 3d 33 32 30 2a 34 38  30 2a 33 2d 73 63 72 65  |l=320*480*3-scre|
000005c0  65 6e 61 6c 6c 6f 63 0d  02 b2 26 e7 20 61 64 64  |enalloc...&. add|
000005d0  69 74 69 6f 6e 61 6c 3e  30 20 c8 99 20 26 32 41  |itional>0 .. &2A|
000005e0  2c 32 2c 61 64 64 69 74  69 6f 6e 61 6c 0d 02 bc  |,2,additional...|
000005f0  35 c8 99 20 36 2c 31 31  32 2c 33 3a db 3a c8 99  |5.. 6,112,3:.:..|
00000600  20 36 2c 31 31 32 2c 32  3a db 3a c8 99 20 36 2c  | 6,112,2:.:.. 6,|
00000610  31 31 32 2c 31 3a db 3a  c8 99 20 36 2c 31 31 33  |112,1:.:.. 6,113|
00000620  2c 31 0d 02 c6 18 c8 99  20 36 2c 31 31 32 2c 32  |,1...... 6,112,2|
00000630  3a 73 63 72 65 65 6e 25  3d 32 0d 02 d0 05 e1 0d  |:screen%=2......|
00000640  02 da 05 3a 0d 02 e4 13  dd 20 f2 73 77 61 70 5f  |...:..... .swap_|
00000650  73 63 72 65 65 6e 73 0d  02 ee 17 c8 96 3a c8 99  |screens......:..|
00000660  20 36 2c 31 31 33 2c 73  63 72 65 65 6e 25 0d 02  | 6,113,screen%..|
00000670  f8 24 73 63 72 65 65 6e  25 2b 3d 31 3a e7 20 73  |.$screen%+=1:. s|
00000680  63 72 65 65 6e 25 3d 34  20 73 63 72 65 65 6e 25  |creen%=4 screen%|
00000690  3d 31 0d 03 02 16 c8 99  20 36 2c 31 31 32 2c 73  |=1...... 6,112,s|
000006a0  63 72 65 65 6e 25 3a db  0d 03 0c 05 e1 0d 03 16  |creen%:.........|
000006b0  04 0d 03 20 04 0d ff                              |... ...|
000006b7