home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1992 January / 1992-01.d64 / lisa (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  6KB  |  182 lines

  1. 10 rem copyright 1992 - compute publications intl ltd - all rights reserved
  2. 20 if dk=0 then dk=1:load"lisa.ml",8,1
  3. 30 y=int(32768/256):x=int((32768/256-y)*256+.5):poke55,x:poke56,y:clr
  4. 40 dim pt(300,2),ln(300,2),rp(300,3):poke53280,6:poke53281,6:print"[147]"
  5. 50 pi=3.14159265:np=1:nl=1:cs=sqr(3)/2:sn=.5:an=pi/6:md=0:pc=0
  6. 60 :
  7. 70 if md=1 then md=0:sys 49152+6:rem text mode
  8. 80 print"[147]":a$="[204][201][211][193] - [204]ittle [201]sometric [193]rtist":gosub 1760:print"[159]"
  9. 90 print:a$="[195]opyright 1992":gosub 1760
  10. 100 a$="[195][207][205][208][213][212][197] [208]ublications [201]ntl, [204]td":gosub 1760
  11. 110 a$="[193]ll [210]ights [210]eserved":gosub 1760:print:print
  12. 120 a$="[208]lease choose:":gosub1760:print
  13. 130 a$="([206])ew [198]igure":gosub1760:a$="([199])raphic [211]creen":gosub1760
  14. 140 a$="([211])ave [208]icture":gosub 1760:a$="[211]et ([193])ngle of [212]urn":gosub 1760
  15. 150 a$="([204])oad [208]icture":gosub 1760:a$="([205])ake [211]lide [211]et":gosub 1760
  16. 160 a$="([197])dit":gosub 1760:a$="([200])elp":gosub 1760:a$="([196])emo":gosub 1760
  17. 170 get a$:if a$="" then 170
  18. 180 fl=0:b$="nghdsamel"
  19. 190 for x=1 to len(b$):if a$=mid$(b$,x,1) then fl=x
  20. 200 next:if fl=0 then 170
  21. 210 on fl goto 230,570,630,810,850,910,1020,350,520
  22. 220 rem -------------------
  23. 230 rem input a new figure
  24. 240 input"[147][159][200]ow many points are you entering";np
  25. 250 for x=1 to np:print"[147]":for y=asc("x") to asc("z")
  26. 260 print"[197]nter the ";chr$(y);" value for point";x;": ";
  27. 270 input rp(x,y-asc("w")):next y,x
  28. 280 input"[147][200]ow many edges are you entering";nl
  29. 290 for x=1 to nl:print"[147]"
  30. 300 print"[197]nter the starting point for edge";x;": ":input ln(x,1)
  31. 310 print"[197]nter the ending point for edge";x;": ":input ln(x,2)
  32. 320 next:print"[158]":a$="[195]alculating...":gosub 1760:goto 1150
  33. 330 rem -------------------
  34. 340 rem edit the data
  35. 350 for x=1 to np:print"[147]":for y=asc("x") to asc("z")
  36. 360 print"[212]he ";chr$(y);" value for point";x;": ";rp(x,y-asc("w")):next y
  37. 370 print:print"[210]eenter this point? ([217]/[206])":gosub 1800
  38. 380 if a$<>"y" then 420
  39. 390 print"":for y=asc("x") to asc("z")
  40. 400 print"[197]nter the ";chr$(y);" value for point";x;": ";
  41. 410 input rp(x,y-asc("w")):next y
  42. 420 next x:for x=1 to nl:print"[147]"
  43. 430 print"[212]he starting point for edge";x;": ";ln(x,1)
  44. 440 print"[212]he ending point for edge";x;": ";ln(x,2)
  45. 450 print:print"[210]eenter this edge? ([217]/[206])":gosub 1800
  46. 460 if a$<>"y" then 490
  47. 470 print:print"[197]nter the starting point for edge";x;": ":input ln(x,1)
  48. 480 print:print"[197]nter the ending point for edge";x;": ":input ln(x,2)
  49. 490 goto 320
  50. 500 rem -------------------
  51. 510 rem load the picture
  52. 520 print"[147][215]hat is the name of the picture?":input a$
  53. 530 x=len(a$):poke 53050,x:for y=1 to x:poke 53050+y,asc(mid$(a$,y,1)):next
  54. 540 if md=0 then md=1:sys 49152+3
  55. 550 sys 49152+18:pc=0:goto600
  56. 560 rem -------------------
  57. 570 rem go to the graphic screen
  58. 580 if md=0 then md=1:sys 49152+3:if pc then 1500
  59. 590 gosub 1800
  60. 600 if md=1 then md=0:print"[147]":sys 49152+6:rem text mode
  61. 610 goto 70
  62. 620 rem -------------------
  63. 630 rem post help screen
  64. 640 print"[147]":a$="[205]ain [205]enu [200]elp":gosub 1760:print"[159]"
  65. 650 a$="[195]reate a new figure by choosing '[206]' at":gosub 1760
  66. 660 a$="the main menu and entering point and":gosub 1760
  67. 670 a$="edge data when prompted.":gosub 1760
  68. 680 a$="[201]f a figure exists on the graphic":gosub 1760
  69. 690 a$="screen, it will be displayed by":gosub 1760
  70. 700 a$="pressing '[199]' at the main menu.":gosub 1760
  71. 710 a$="[195]hoosing '[196]' at the main menu will":gosub 1760
  72. 720 a$="cause a demo figure to be created,":gosub 1760
  73. 730 a$="with all the normal figure options":gosub 1760
  74. 740 a$="afterward.":gosub 1760
  75. 750 a$="[212]he ([204])oad and ([211])ave options work":gosub 1760
  76. 760 a$="with a high-resolution image.":gosub 1760
  77. 770 a$="[212]he slide set option saves a":gosub 1760
  78. 780 a$="full rotation sequence.":gosub 1760:print
  79. 790 gosub 1790:goto 70
  80. 800 rem -------------------
  81. 810 rem run demo
  82. 820 print:print"[158]":a$="[199]etting [196]ata...":gosub 1760:gosub 1640
  83. 830 goto 1150
  84. 840 rem -------------------
  85. 850 rem save the picture
  86. 860 if md=0 then md=1:sys 49152+3
  87. 870 sys 49152+15
  88. 880 if md=1 then md=0:print"[147]":sys 49152+6:rem text mode
  89. 890 goto 70
  90. 900 rem -------------------
  91. 910 rem set the angle of turn
  92. 920 print"[147][159]":a$="[215]hen first run, this program uses a":gosub 1760
  93. 930 a$="default turning increment of 1/12 of a":gosub 1760
  94. 940 a$="complete rotation. [208]lease either enter":gosub 1760
  95. 950 a$="a new increment (in radians), or a":gosub 1760
  96. 960 a$="negative value to abort.":gosub 1760
  97. 970 print:input"angle";x:print:print"[158]":if x<0 then 70
  98. 980 if x>2*pi then a$="[212]oo large... using default":gosub 1760:an=pi/6:goto 790
  99. 990 x=int(2*pi/x+.5):if x<=1 then x=2
  100. 1000 an=2*pi/x:a$="using"+str$(x)+" steps per rotation":gosub 1760:goto 790
  101. 1010 rem -------------------
  102. 1020 rem make the set of slides
  103. 1030 print"[147][158]":if pc then 1050
  104. 1040 a$="[212]here is no entered figure":gosub 1760:goto 790
  105. 1050 if 2*pi/an > 20 then an = 2*pi/20
  106. 1060 a$="[212]his slide set will take"+str$(int(2*pi/an+.5)*32)
  107. 1070 a$=a$+" blocks.":gosub 1760:gosub 1790
  108. 1080 sys 49152+3:for sx=1 to 2*pi/an
  109. 1090 sys 49152+15
  110. 1100 gosub 1570:gosub 1180:next
  111. 1110 if md=1 then md=0:print"[147]":sys 49152+6:rem text mode
  112. 1120 goto 70
  113. 1130 rem -------------------
  114. 1140 rem drawing the figure
  115. 1150 gosub 1180:goto 1500
  116. 1160 rem -------------------
  117. 1170 rem calculating the geometric center
  118. 1180 ax=0:ay=0:az=0
  119. 1190 for x=1 to np:ax=ax+rp(x,1):ay=ay+rp(x,2):az=az+rp(x,3):next
  120. 1200 ax=ax/np:ay=ay/np:az=az/np
  121. 1210 :
  122. 1220 for x=1 to np:rem convert to isometric image
  123. 1230 pt(x,1)=(rp(x,2)-rp(x,1)-ay+ax)*cs
  124. 1240 pt(x,2)=rp(x,3)-az-sn*(rp(x,2)+rp(x,1)-ax-ay)
  125. 1250 next
  126. 1260 :
  127. 1270 max=pt(1,1):min=max:rem initialize extrema
  128. 1280 for x=1 to np:for y=1 to 2
  129. 1290 if pt(x,y)>max then max=pt(x,y)
  130. 1300 if pt(x,y)<min then min=pt(x,y)
  131. 1310 next y,x
  132. 1320 sr=199/(max-min):rem the scale ratio
  133. 1330 ar=152/115:rem the aspect ratio
  134. 1340 os=160+min*sr*ar:rem x-offset to center the drawing
  135. 1350 for x=1 to np:for y=1 to 2
  136. 1360 pt(x,y) = (pt(x,y)-min)*sr
  137. 1370 next y,x
  138. 1380 if md=0 then md=1:sys 49152+3:rem switch to the graphics screen
  139. 1390 sys 49152+12:rem clear screen
  140. 1400 for x=1 to nl
  141. 1410 x1 = int(pt(ln(x,1),1)*ar+os+.5):y1 = int(pt(ln(x,1),2)+.5)
  142. 1420 x2 = int(pt(ln(x,2),1)*ar+os+.5):y2 = int(pt(ln(x,2),2)+.5)
  143. 1430 v(2)=int(x1/256):v(1)=int((x1/256-v(2))*256+.5)
  144. 1440 v(4)=int(y1/256):v(3)=int((y1/256-v(4))*256+.5)
  145. 1450 v(6)=int(x2/256):v(5)=int((x2/256-v(6))*256+.5)
  146. 1460 v(8)=int(y2/256):v(7)=int((y2/256-v(8))*256+.5)
  147. 1470 for y=0 to 7:poke 53000+y,v(y+1):next
  148. 1480 pc=-1:sys 49152+9:rem draw the line
  149. 1490 next:return
  150. 1500 get a$:if a$="" then 1500
  151. 1510 if a$="" then an = abs(an):gosub 1570:gosub 1180:goto 1500
  152. 1520 if a$="[157]" then an = -abs(an):gosub 1570:gosub 1180:goto 1500
  153. 1530 if md=1 then md=0:print"[147]":sys 49152+6:rem text mode
  154. 1540 goto 70
  155. 1550 :
  156. 1560 rem rotating the object
  157. 1570 for x=1 to np
  158. 1580 xx=rp(x,1):yy=rp(x,2)
  159. 1590 rp(x,1)=xx*cos(an)-yy*sin(an)
  160. 1600 rp(x,2)=xx*sin(an)+yy*cos(an)
  161. 1610 next:md=1:return
  162. 1620 :
  163. 1630 rem generating data for demo figure
  164. 1640 np=1:nl=1:a=10:b=5
  165. 1650 for th=0 to 3:for ph=0 to 9:gosub 1710
  166. 1660 ln(nl,1)=np:ln(nl,2)=np+1:ln(nl+1,1)=np:ln(nl+1,2)=np+10:nl=nl+2:np=np+1
  167. 1670 next ph:nl=nl-1:ln(nl-1,1)=np-1:ln(nl-1,2)=np+9:next th
  168. 1680 th=4:for ph=0 to 9:gosub 1710
  169. 1690 ln(nl,1)=np:ln(nl,2)=np+1:nl=nl+1:np=np+1:next ph
  170. 1700 np=np-1:nl=nl-1:ln(nl,1)=np:ln(nl,2)=np-9:return
  171. 1710 rp(np,1)=a*cos(th*pi/10)*cos(ph*pi/5)
  172. 1720 rp(np,2)=a*cos(th*pi/10)*sin(ph*pi/5)
  173. 1730 rp(np,3)=b*sin(th*pi/10):return
  174. 1740 :
  175. 1750 rem center print
  176. 1760 if len(a$)<38 then for lp=1 to 20-len(a$)/2:print chr$(32);:next
  177. 1770 printa$:return
  178. 1780 :
  179. 1790 print:print"[158]":a$="[208]ress any key":gosub 1760
  180. 1800 get a$:if a$="" then 1800
  181. 1810 return
  182.