Home » Archimedes archive » Acorn User » AU 1996-08.adf » Regulars » StarInfo/Northcott/3dblobs2

StarInfo/Northcott/3dblobs2

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 1996-08.adf » Regulars
Filename: StarInfo/Northcott/3dblobs2
Read OK:
File size: 0866 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >3dblobs2
   20REM Very simple program to plot some psuedo 3d blobs onto the
   30REM screen and control position with the mouse.
   40REM Conceived and Created by D.Northcott 06/03/1996
   50REM Originally was going to have a number of objects from which
   60REM to choose, however, because I wanted the program to run at
   70REM an acceptable speed on ALL Acorn 32-bit machines, that idea
   80REM went out the window, would have meant 2 sets of position
   90REM data, 1 for each speed type, cached & uncached, as each
  100REM speed uses a different number of blobs.
  110
  120REM Twice the screen memory we need, useful for shadow screen
  130REM use. THIS program uses 320x 256y 256c, could just as well
  140REM be ANY 256 colour mode.
  150mode%=13
  160MODE mode%
  170MODE mode%+128
  180
  190REM Error handler
  200ONERROR PROCER:END
  210REMove the cursor
  220OFF
  230PRINT "Mouse moves plot origin,"
  240PRINT " Click MIDDLE to exit,"
  250G%=INKEY(300)
  260
  270T%=TIME
  280FORA%=0TO10000:NEXT
  290T%=TIME-T%
  300IF T%>7 AA%=15 ELSE AA%=30
  310
  320DIM C%(AA%,1),X%(AA%,1),Y%(AA%,1),Z%(AA%,1),C(360),S(360)
  330FOR A%=0 TO 360
  340S(A%)=SIN(RAD(A%)):C(A%)=COS(RAD(A%)):NEXT
  350
  360B%=0:C%=1
  370SYS 6,112,B%:SYS 6,113,C%
  380MOUSE TO 640,512
  390S%=500
  400M%=S%*2
  410R%=0
  420V%=7
  430W%=8
  440FOR A%=1 TO AA%
  450C%(A%,0)=RND(62)+1
  460X%(A%,0)=RND(M%)-S%
  470Y%(A%,0)=RND(M%)-S%
  480Z%(A%,0)=RND(M%)-S%
  490NEXT
  500CLS
  510REM sorry about the non readability of the section below, speed demands
  520REM compact code, not easy to read code, essentially its calculating the
  530REM coordinates for the next frame, then sorting in the Z plane,
  540REM plotting the sorted blobs to the hidden screen bank, then swapping
  550REM the banks, simple really, or should that be really simple.
  560
  570REPEAT:C=C(R%):S=S(R%):FORA%=1TOAA%
  580C%(A%,1)=C%(A%,0):Y%(A%,1)=Y%(A%,0):X%(A%,1)=C*X%(A%,0)-S*Z%(A%,0):Z%(A%,1)=(S*X%(A%,0)+C*Z%(A%,0)+S%)/W%:NEXT
  590R%=(R%+V%)MOD360:FORI%=1TOAA%-1
  600K%=I%:FORJ%=I%+1TOAA%
  610IFZ%(J%,1)<Z%(K%,1) K%=J%
  620NEXT
  630IFI%<>K% SWAPZ%(K%,1),Z%(I%,1):SWAPY%(K%,1),Y%(I%,1):SWAPX%(K%,1),X%(I%,1):SWAPC%(K%,1),C%(I%,1)
  640NEXT
  650MOUSEX%,Y%,P%:FORA%=1TOAA%
  660GCOL0,C%(A%,1):CIRCLEFILLX%(A%,1)+X%,Y%(A%,1)+Y%,Z%(A%,1):NEXT
  670WAIT:SWAPB%,C%:SYS6,112,B%:SYS6,113,C%:CLS:UNTIL(P%AND2)=2
  671SYS "Wimp_CommandWindow",-1,-1
  710END
  720
  730DEFPROCER
  740MODE12:REPORT:PRINT" at line ";ERL
  750ENDPROC

� >3dblobs2
?� Very simple program to plot some psuedo 3d blobs onto the
1� screen and control position with the mouse.
(5� Conceived and Created by D.Northcott 06/03/1996
2A� Originally was going to have a number of objects from which
<@� to choose, however, because I wanted the program to run at
FA� an acceptable speed on ALL Acorn 32-bit machines, that idea
P>� went out the window, would have meant 2 sets of position
Z=� data, 1 for each speed type, cached & uncached, as each
d-� speed uses a different number of blobs.
n
x?� Twice the screen memory we need, useful for shadow screen
�?� use. THIS program uses 320x 256y 256c, could just as well
�� be ANY 256 colour mode.
�mode%=13
�� mode%
�� mode%+128
�
�� Error handler
�� �ER:�
��ove the cursor
��
� � "Mouse moves plot origin,"
�� " Click MIDDLE to exit,"
�
G%=�(300)

T%=�
�A%=0�10000:�
"T%=�-T%
,� T%>7 AA%=15 � AA%=30
6
@;� C%(AA%,1),X%(AA%,1),Y%(AA%,1),Z%(AA%,1),C(360),S(360)
J� A%=0 � 360
T#S(A%)=�(�(A%)):C(A%)=�(�(A%)):�
^
h
B%=0:C%=1
rș 6,112,B%:ș 6,113,C%
|ȗ � 640,512
�
S%=500
�M%=S%*2
�R%=0
�V%=7
�W%=8
�� A%=1 � AA%
�C%(A%,0)=�(62)+1
�X%(A%,0)=�(M%)-S%
�Y%(A%,0)=�(M%)-S%
�Z%(A%,0)=�(M%)-S%
��
��
�I� sorry about the non readability of the section below, speed demands
J� compact code, not easy to read code, essentially its calculating the
B� coordinates for the next frame, then sorting in the Z plane,
H� plotting the sorted blobs to the hidden screen bank, then swapping
&@� the banks, simple really, or should that be really simple.
0
:�:C=C(R%):S=S(R%):�A%=1�AA%
DoC%(A%,1)=C%(A%,0):Y%(A%,1)=Y%(A%,0):X%(A%,1)=C*X%(A%,0)-S*Z%(A%,0):Z%(A%,1)=(S*X%(A%,0)+C*Z%(A%,0)+S%)/W%:�
NR%=(R%+V%)�360:�I%=1�AA%-1
XK%=I%:�J%=I%+1�AA%
b�Z%(J%,1)<Z%(K%,1) K%=J%
l�
v[�I%<>K% ȔZ%(K%,1),Z%(I%,1):ȔY%(K%,1),Y%(I%,1):ȔX%(K%,1),X%(I%,1):ȔC%(K%,1),C%(I%,1)
��
�ȗX%,Y%,P%:�A%=1�AA%
�6�0,C%(A%,1):ȏȐX%(A%,1)+X%,Y%(A%,1)+Y%,Z%(A%,1):�
�0Ȗ:ȔB%,C%:ș6,112,B%:ș6,113,C%:�:�(P%�2)=2
�!ș "Wimp_CommandWindow",-1,-1
��
�
���ER
��12:�:�" at line ";�
��
�
00000000  0d 00 0a 0f f4 20 3e 33  64 62 6c 6f 62 73 32 0d  |..... >3dblobs2.|
00000010  00 14 3f f4 20 56 65 72  79 20 73 69 6d 70 6c 65  |..?. Very simple|
00000020  20 70 72 6f 67 72 61 6d  20 74 6f 20 70 6c 6f 74  | program to plot|
00000030  20 73 6f 6d 65 20 70 73  75 65 64 6f 20 33 64 20  | some psuedo 3d |
00000040  62 6c 6f 62 73 20 6f 6e  74 6f 20 74 68 65 0d 00  |blobs onto the..|
00000050  1e 31 f4 20 73 63 72 65  65 6e 20 61 6e 64 20 63  |.1. screen and c|
00000060  6f 6e 74 72 6f 6c 20 70  6f 73 69 74 69 6f 6e 20  |ontrol position |
00000070  77 69 74 68 20 74 68 65  20 6d 6f 75 73 65 2e 0d  |with the mouse..|
00000080  00 28 35 f4 20 43 6f 6e  63 65 69 76 65 64 20 61  |.(5. Conceived a|
00000090  6e 64 20 43 72 65 61 74  65 64 20 62 79 20 44 2e  |nd Created by D.|
000000a0  4e 6f 72 74 68 63 6f 74  74 20 30 36 2f 30 33 2f  |Northcott 06/03/|
000000b0  31 39 39 36 0d 00 32 41  f4 20 4f 72 69 67 69 6e  |1996..2A. Origin|
000000c0  61 6c 6c 79 20 77 61 73  20 67 6f 69 6e 67 20 74  |ally was going t|
000000d0  6f 20 68 61 76 65 20 61  20 6e 75 6d 62 65 72 20  |o have a number |
000000e0  6f 66 20 6f 62 6a 65 63  74 73 20 66 72 6f 6d 20  |of objects from |
000000f0  77 68 69 63 68 0d 00 3c  40 f4 20 74 6f 20 63 68  |which..<@. to ch|
00000100  6f 6f 73 65 2c 20 68 6f  77 65 76 65 72 2c 20 62  |oose, however, b|
00000110  65 63 61 75 73 65 20 49  20 77 61 6e 74 65 64 20  |ecause I wanted |
00000120  74 68 65 20 70 72 6f 67  72 61 6d 20 74 6f 20 72  |the program to r|
00000130  75 6e 20 61 74 0d 00 46  41 f4 20 61 6e 20 61 63  |un at..FA. an ac|
00000140  63 65 70 74 61 62 6c 65  20 73 70 65 65 64 20 6f  |ceptable speed o|
00000150  6e 20 41 4c 4c 20 41 63  6f 72 6e 20 33 32 2d 62  |n ALL Acorn 32-b|
00000160  69 74 20 6d 61 63 68 69  6e 65 73 2c 20 74 68 61  |it machines, tha|
00000170  74 20 69 64 65 61 0d 00  50 3e f4 20 77 65 6e 74  |t idea..P>. went|
00000180  20 6f 75 74 20 74 68 65  20 77 69 6e 64 6f 77 2c  | out the window,|
00000190  20 77 6f 75 6c 64 20 68  61 76 65 20 6d 65 61 6e  | would have mean|
000001a0  74 20 32 20 73 65 74 73  20 6f 66 20 70 6f 73 69  |t 2 sets of posi|
000001b0  74 69 6f 6e 0d 00 5a 3d  f4 20 64 61 74 61 2c 20  |tion..Z=. data, |
000001c0  31 20 66 6f 72 20 65 61  63 68 20 73 70 65 65 64  |1 for each speed|
000001d0  20 74 79 70 65 2c 20 63  61 63 68 65 64 20 26 20  | type, cached & |
000001e0  75 6e 63 61 63 68 65 64  2c 20 61 73 20 65 61 63  |uncached, as eac|
000001f0  68 0d 00 64 2d f4 20 73  70 65 65 64 20 75 73 65  |h..d-. speed use|
00000200  73 20 61 20 64 69 66 66  65 72 65 6e 74 20 6e 75  |s a different nu|
00000210  6d 62 65 72 20 6f 66 20  62 6c 6f 62 73 2e 0d 00  |mber of blobs...|
00000220  6e 04 0d 00 78 3f f4 20  54 77 69 63 65 20 74 68  |n...x?. Twice th|
00000230  65 20 73 63 72 65 65 6e  20 6d 65 6d 6f 72 79 20  |e screen memory |
00000240  77 65 20 6e 65 65 64 2c  20 75 73 65 66 75 6c 20  |we need, useful |
00000250  66 6f 72 20 73 68 61 64  6f 77 20 73 63 72 65 65  |for shadow scree|
00000260  6e 0d 00 82 3f f4 20 75  73 65 2e 20 54 48 49 53  |n...?. use. THIS|
00000270  20 70 72 6f 67 72 61 6d  20 75 73 65 73 20 33 32  | program uses 32|
00000280  30 78 20 32 35 36 79 20  32 35 36 63 2c 20 63 6f  |0x 256y 256c, co|
00000290  75 6c 64 20 6a 75 73 74  20 61 73 20 77 65 6c 6c  |uld just as well|
000002a0  0d 00 8c 1d f4 20 62 65  20 41 4e 59 20 32 35 36  |..... be ANY 256|
000002b0  20 63 6f 6c 6f 75 72 20  6d 6f 64 65 2e 0d 00 96  | colour mode....|
000002c0  0c 6d 6f 64 65 25 3d 31  33 0d 00 a0 0b eb 20 6d  |.mode%=13..... m|
000002d0  6f 64 65 25 0d 00 aa 0f  eb 20 6d 6f 64 65 25 2b  |ode%..... mode%+|
000002e0  31 32 38 0d 00 b4 04 0d  00 be 13 f4 20 45 72 72  |128......... Err|
000002f0  6f 72 20 68 61 6e 64 6c  65 72 0d 00 c8 0c ee 85  |or handler......|
00000300  20 f2 45 52 3a e0 0d 00  d2 13 f4 6f 76 65 20 74  | .ER:......ove t|
00000310  68 65 20 63 75 72 73 6f  72 0d 00 dc 05 87 0d 00  |he cursor.......|
00000320  e6 20 f1 20 22 4d 6f 75  73 65 20 6d 6f 76 65 73  |. . "Mouse moves|
00000330  20 70 6c 6f 74 20 6f 72  69 67 69 6e 2c 22 0d 00  | plot origin,"..|
00000340  f0 1e f1 20 22 20 43 6c  69 63 6b 20 4d 49 44 44  |... " Click MIDD|
00000350  4c 45 20 74 6f 20 65 78  69 74 2c 22 0d 00 fa 0d  |LE to exit,"....|
00000360  47 25 3d a6 28 33 30 30  29 0d 01 04 04 0d 01 0e  |G%=.(300).......|
00000370  08 54 25 3d 91 0d 01 18  11 e3 41 25 3d 30 b8 31  |.T%=......A%=0.1|
00000380  30 30 30 30 3a ed 0d 01  22 0b 54 25 3d 91 2d 54  |0000:...".T%=.-T|
00000390  25 0d 01 2c 1a e7 20 54  25 3e 37 20 41 41 25 3d  |%..,.. T%>7 AA%=|
000003a0  31 35 20 8b 20 41 41 25  3d 33 30 0d 01 36 04 0d  |15 . AA%=30..6..|
000003b0  01 40 3b de 20 43 25 28  41 41 25 2c 31 29 2c 58  |.@;. C%(AA%,1),X|
000003c0  25 28 41 41 25 2c 31 29  2c 59 25 28 41 41 25 2c  |%(AA%,1),Y%(AA%,|
000003d0  31 29 2c 5a 25 28 41 41  25 2c 31 29 2c 43 28 33  |1),Z%(AA%,1),C(3|
000003e0  36 30 29 2c 53 28 33 36  30 29 0d 01 4a 10 e3 20  |60),S(360)..J.. |
000003f0  41 25 3d 30 20 b8 20 33  36 30 0d 01 54 23 53 28  |A%=0 . 360..T#S(|
00000400  41 25 29 3d b5 28 b2 28  41 25 29 29 3a 43 28 41  |A%)=.(.(A%)):C(A|
00000410  25 29 3d 9b 28 b2 28 41  25 29 29 3a ed 0d 01 5e  |%)=.(.(A%)):...^|
00000420  04 0d 01 68 0d 42 25 3d  30 3a 43 25 3d 31 0d 01  |...h.B%=0:C%=1..|
00000430  72 1b c8 99 20 36 2c 31  31 32 2c 42 25 3a c8 99  |r... 6,112,B%:..|
00000440  20 36 2c 31 31 33 2c 43  25 0d 01 7c 10 c8 97 20  | 6,113,C%..|... |
00000450  b8 20 36 34 30 2c 35 31  32 0d 01 86 0a 53 25 3d  |. 640,512....S%=|
00000460  35 30 30 0d 01 90 0b 4d  25 3d 53 25 2a 32 0d 01  |500....M%=S%*2..|
00000470  9a 08 52 25 3d 30 0d 01  a4 08 56 25 3d 37 0d 01  |..R%=0....V%=7..|
00000480  ae 08 57 25 3d 38 0d 01  b8 10 e3 20 41 25 3d 31  |..W%=8..... A%=1|
00000490  20 b8 20 41 41 25 0d 01  c2 14 43 25 28 41 25 2c  | . AA%....C%(A%,|
000004a0  30 29 3d b3 28 36 32 29  2b 31 0d 01 cc 15 58 25  |0)=.(62)+1....X%|
000004b0  28 41 25 2c 30 29 3d b3  28 4d 25 29 2d 53 25 0d  |(A%,0)=.(M%)-S%.|
000004c0  01 d6 15 59 25 28 41 25  2c 30 29 3d b3 28 4d 25  |...Y%(A%,0)=.(M%|
000004d0  29 2d 53 25 0d 01 e0 15  5a 25 28 41 25 2c 30 29  |)-S%....Z%(A%,0)|
000004e0  3d b3 28 4d 25 29 2d 53  25 0d 01 ea 05 ed 0d 01  |=.(M%)-S%.......|
000004f0  f4 05 db 0d 01 fe 49 f4  20 73 6f 72 72 79 20 61  |......I. sorry a|
00000500  62 6f 75 74 20 74 68 65  20 6e 6f 6e 20 72 65 61  |bout the non rea|
00000510  64 61 62 69 6c 69 74 79  20 6f 66 20 74 68 65 20  |dability of the |
00000520  73 65 63 74 69 6f 6e 20  62 65 6c 6f 77 2c 20 73  |section below, s|
00000530  70 65 65 64 20 64 65 6d  61 6e 64 73 0d 02 08 4a  |peed demands...J|
00000540  f4 20 63 6f 6d 70 61 63  74 20 63 6f 64 65 2c 20  |. compact code, |
00000550  6e 6f 74 20 65 61 73 79  20 74 6f 20 72 65 61 64  |not easy to read|
00000560  20 63 6f 64 65 2c 20 65  73 73 65 6e 74 69 61 6c  | code, essential|
00000570  6c 79 20 69 74 73 20 63  61 6c 63 75 6c 61 74 69  |ly its calculati|
00000580  6e 67 20 74 68 65 0d 02  12 42 f4 20 63 6f 6f 72  |ng the...B. coor|
00000590  64 69 6e 61 74 65 73 20  66 6f 72 20 74 68 65 20  |dinates for the |
000005a0  6e 65 78 74 20 66 72 61  6d 65 2c 20 74 68 65 6e  |next frame, then|
000005b0  20 73 6f 72 74 69 6e 67  20 69 6e 20 74 68 65 20  | sorting in the |
000005c0  5a 20 70 6c 61 6e 65 2c  0d 02 1c 48 f4 20 70 6c  |Z plane,...H. pl|
000005d0  6f 74 74 69 6e 67 20 74  68 65 20 73 6f 72 74 65  |otting the sorte|
000005e0  64 20 62 6c 6f 62 73 20  74 6f 20 74 68 65 20 68  |d blobs to the h|
000005f0  69 64 64 65 6e 20 73 63  72 65 65 6e 20 62 61 6e  |idden screen ban|
00000600  6b 2c 20 74 68 65 6e 20  73 77 61 70 70 69 6e 67  |k, then swapping|
00000610  0d 02 26 40 f4 20 74 68  65 20 62 61 6e 6b 73 2c  |..&@. the banks,|
00000620  20 73 69 6d 70 6c 65 20  72 65 61 6c 6c 79 2c 20  | simple really, |
00000630  6f 72 20 73 68 6f 75 6c  64 20 74 68 61 74 20 62  |or should that b|
00000640  65 20 72 65 61 6c 6c 79  20 73 69 6d 70 6c 65 2e  |e really simple.|
00000650  0d 02 30 04 0d 02 3a 1f  f5 3a 43 3d 43 28 52 25  |..0...:..:C=C(R%|
00000660  29 3a 53 3d 53 28 52 25  29 3a e3 41 25 3d 31 b8  |):S=S(R%):.A%=1.|
00000670  41 41 25 0d 02 44 6f 43  25 28 41 25 2c 31 29 3d  |AA%..DoC%(A%,1)=|
00000680  43 25 28 41 25 2c 30 29  3a 59 25 28 41 25 2c 31  |C%(A%,0):Y%(A%,1|
00000690  29 3d 59 25 28 41 25 2c  30 29 3a 58 25 28 41 25  |)=Y%(A%,0):X%(A%|
000006a0  2c 31 29 3d 43 2a 58 25  28 41 25 2c 30 29 2d 53  |,1)=C*X%(A%,0)-S|
000006b0  2a 5a 25 28 41 25 2c 30  29 3a 5a 25 28 41 25 2c  |*Z%(A%,0):Z%(A%,|
000006c0  31 29 3d 28 53 2a 58 25  28 41 25 2c 30 29 2b 43  |1)=(S*X%(A%,0)+C|
000006d0  2a 5a 25 28 41 25 2c 30  29 2b 53 25 29 2f 57 25  |*Z%(A%,0)+S%)/W%|
000006e0  3a ed 0d 02 4e 1e 52 25  3d 28 52 25 2b 56 25 29  |:...N.R%=(R%+V%)|
000006f0  83 33 36 30 3a e3 49 25  3d 31 b8 41 41 25 2d 31  |.360:.I%=1.AA%-1|
00000700  0d 02 58 16 4b 25 3d 49  25 3a e3 4a 25 3d 49 25  |..X.K%=I%:.J%=I%|
00000710  2b 31 b8 41 41 25 0d 02  62 1c e7 5a 25 28 4a 25  |+1.AA%..b..Z%(J%|
00000720  2c 31 29 3c 5a 25 28 4b  25 2c 31 29 20 4b 25 3d  |,1)<Z%(K%,1) K%=|
00000730  4a 25 0d 02 6c 05 ed 0d  02 76 5b e7 49 25 3c 3e  |J%..l....v[.I%<>|
00000740  4b 25 20 c8 94 5a 25 28  4b 25 2c 31 29 2c 5a 25  |K% ..Z%(K%,1),Z%|
00000750  28 49 25 2c 31 29 3a c8  94 59 25 28 4b 25 2c 31  |(I%,1):..Y%(K%,1|
00000760  29 2c 59 25 28 49 25 2c  31 29 3a c8 94 58 25 28  |),Y%(I%,1):..X%(|
00000770  4b 25 2c 31 29 2c 58 25  28 49 25 2c 31 29 3a c8  |K%,1),X%(I%,1):.|
00000780  94 43 25 28 4b 25 2c 31  29 2c 43 25 28 49 25 2c  |.C%(K%,1),C%(I%,|
00000790  31 29 0d 02 80 05 ed 0d  02 8a 18 c8 97 58 25 2c  |1)...........X%,|
000007a0  59 25 2c 50 25 3a e3 41  25 3d 31 b8 41 41 25 0d  |Y%,P%:.A%=1.AA%.|
000007b0  02 94 36 e6 30 2c 43 25  28 41 25 2c 31 29 3a c8  |..6.0,C%(A%,1):.|
000007c0  8f c8 90 58 25 28 41 25  2c 31 29 2b 58 25 2c 59  |...X%(A%,1)+X%,Y|
000007d0  25 28 41 25 2c 31 29 2b  59 25 2c 5a 25 28 41 25  |%(A%,1)+Y%,Z%(A%|
000007e0  2c 31 29 3a ed 0d 02 9e  30 c8 96 3a c8 94 42 25  |,1):....0..:..B%|
000007f0  2c 43 25 3a c8 99 36 2c  31 31 32 2c 42 25 3a c8  |,C%:..6,112,B%:.|
00000800  99 36 2c 31 31 33 2c 43  25 3a db 3a fd 28 50 25  |.6,113,C%:.:.(P%|
00000810  80 32 29 3d 32 0d 02 9f  21 c8 99 20 22 57 69 6d  |.2)=2...!.. "Wim|
00000820  70 5f 43 6f 6d 6d 61 6e  64 57 69 6e 64 6f 77 22  |p_CommandWindow"|
00000830  2c 2d 31 2c 2d 31 0d 02  c6 05 e0 0d 02 d0 04 0d  |,-1,-1..........|
00000840  02 da 08 dd f2 45 52 0d  02 e4 18 eb 31 32 3a f6  |.....ER.....12:.|
00000850  3a f1 22 20 61 74 20 6c  69 6e 65 20 22 3b 9e 0d  |:." at line ";..|
00000860  02 ee 05 e1 0d ff                                 |......|
00000866