home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume10 / tec / part01 next >
Encoding:
Text File  |  1990-02-20  |  62.5 KB  |  1,330 lines

  1. Newsgroups: comp.sources.misc
  2. organization: MIT Lincoln Laboratory, Lexington MA
  3. subject: v10i077: Continental Drift Simulator part 1/2
  4. from: davea@ll-vlsi.arpa (Dave Allen)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 10, Issue 77
  8. Submitted-by: davea@ll-vlsi.arpa (Dave Allen)
  9. Archive-name: tec/part01
  10.  
  11. This is source for a continental drift simulator that has nice graphics
  12. on Suns, IBM PCs, and Amigas.  It will produce text output on any Unix
  13. machine.
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of shell archive."
  22. # Contents:  tec-v3/README-v3 tec-v3/tec.out.1 tec-v3/tec.out.2
  23. #   tec-v3/tec.out.3 tec-v3/howtorun.doc tec-v3/params.doc
  24. #   tec-v3/technical.doc tec-v3/ami.c tec-v3/unix.c tec-v3/sun.c
  25. #   tec-v3/const.h tec-v3/tec3.c
  26. # Wrapped by davea@vdd on Fri Feb 16 08:39:14 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'tec-v3/README-v3' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'tec-v3/README-v3'\"
  30. else
  31. echo shar: Extracting \"'tec-v3/README-v3'\" \(3537 characters\)
  32. sed "s/^X//" >'tec-v3/README-v3' <<'END_OF_FILE'
  33. This is the README file for Version 3 of tec, a plate tectonic
  34. simulator.  It is written in C and runs on: any UN*X machine using text
  35. or PostScript output; Amiga with nice color graphics and mouse support;
  36. IBM PC with Turbo C and CGA/MCGA/EGA/VGA; Sun-3s and Sun-4s using SunView.
  37. Copyright (c) 1990 by David Allen.  You may distribute this freely as long
  38. as you leave my name and copyright notice intact.
  39. X
  40. I'd really like your comments and feedback; send e-mail to
  41. davea@vlsi.ll.mit.edu, or send us-mail to David Allen, 10 O'Moore Ave,
  42. Maynard, MA 01754.
  43. X
  44. Version history:
  45. X1.  Posted to rec.games.frp and rec.games.programmer on 11 / 15 / 89
  46. X    - Runs only on Amiga, produces long text summary.
  47. X    - Includes PostScript translator for any PostScript printer.
  48. X2.  (Unreleased)
  49. X    - Added text-only mode so it runs on UN*X machines.
  50. X    - Added summary text output mode that fits on 80-character lines.
  51. X    - PostScript support merged into main program.
  52. X3.  Posted to comp.sources.misc on 2 / 15 / 90.
  53. X    - Parameters can come from an input file (see params.doc).
  54. X    - Graphics ported to Sun 3 and 4 systems.
  55. X    - Ported to IBM PC by Peter Lind.
  56. X
  57. Credits:
  58. Brian Love - conversion to Amiga Lattice C 5.02, Amiga beta tester.
  59. Peter Lind - port to IBM PC Turbo C with CGA/MCGA/EGA/VGA.
  60. X
  61. X
  62. WHAT DOES THE TECTONIC SIMULATOR DO?
  63. X
  64. TEC draws a map of some imaginary world and puts one big continent on it.
  65. The program then graphically simulates the breakup of this supercontinent by
  66. rifts and the drifting of the continents.  Mountains are built by
  67. subsuming and by continental collision, and are reduced by erosion.  As
  68. more time passes, the continents tend to drift back into a supercontinent
  69. and split up again, forming what some authors call a "supercontinent cycle."
  70. X
  71. The program produces a map of an imaginary world which contains realistic
  72. looking mountain ranges and continents which sometimes look like they fit
  73. together (like South America and Africa on Earth).
  74. X
  75. I've included some sample output in the files tec.out.[1-3]; they are
  76. short text files.  0's indicate ocean, 1's indicate land, and 2's indicate
  77. mountains.  Take a look.
  78. X
  79. X
  80. WHAT SYSTEMS DOES IT RUN ON?
  81. X
  82. Version 3 runs on a number of platforms.  Nongraphics mode runs on 
  83. Suns and Vaxen for sure, and should run on any UN*X system.  Minimal
  84. changes should be needed (random number generator) to run on any
  85. system with a C compiler.  Amiga systems tested include the Amiga 500,
  86. X1000 or 2000 with 1 meg, WB 1.2 or 1.3, and Lattice C 4.0 or 5.02.
  87. Sun graphics were tested on a Sun-3/60 and on a Sparcstation-1, each
  88. using SunView and SunOS 4.0.3.  The IBM PC version will run on any
  89. XXT/AT/100% compatible clone using Turbo C 2.0+.
  90. X
  91. X
  92. WHAT FILES ARE INCLUDED IN THIS RELEASE?
  93. X
  94. README-v3     - This file
  95. tec.out.[1-3] - sample text output files produced on a Sun-3
  96. howtorun.doc  - Instructions for compiling tec on the various machines
  97. technical.doc - Technical description of program algorithms
  98. params.doc    - Describes all the adjustable parameters
  99. const.h       - Some common defines with magic numbers
  100. var.h         - Include file for adjustable parameters
  101. tec1.c        - Contains most of the interesting functions
  102. tec2.c        - Contains functions to create rifts and split landmasses
  103. tec3.c        - Parameter reading functions
  104. ami.c         - Amiga-specific graphics and mouse functions
  105. unix.c        - UN*X-specific text output routines
  106. sun.c         - Sun graphics routines
  107. ibmpc.c       - IBM PC graphics routines, Turbo C 2.0+
  108. tec.mak       - Turbo C make file
  109. END_OF_FILE
  110. if test 3537 -ne `wc -c <'tec-v3/README-v3'`; then
  111.     echo shar: \"'tec-v3/README-v3'\" unpacked with wrong size!
  112. fi
  113. # end of 'tec-v3/README-v3'
  114. fi
  115. if test -f 'tec-v3/tec.out.1' -a "${1}" != "-c" ; then 
  116.   echo shar: Will not clobber existing file \"'tec-v3/tec.out.1'\"
  117. else
  118. echo shar: Extracting \"'tec-v3/tec.out.1'\" \(3504 characters\)
  119. sed "s/^X//" >'tec-v3/tec.out.1' <<'END_OF_FILE'
  120. X000000000000000000000000000000000000222222221110000000000000000000000000
  121. X000000000000001111110000000000000001222111111100000000000000000000000000
  122. X000000000000011111111000000000000011211111111000000000000000000000000000
  123. X000000000001111111111111000000000111111111110000001110000000000000000000
  124. X000000000011111111111111100000000111111111100000011100000000000000000000
  125. X000000000011111111111111110000001111111111000000011110000000000000000000
  126. X000000000111111111111111111000011111111100000000111110000000000000000000
  127. X000000000111111111111111111100111111111000000001111110000000000000000000
  128. X000000000111111111111111111001111111110000000011111111000000000000000000
  129. X000000000111111111111111111111111111100000000111111111000000000000000000
  130. X000000000111111111111111111111111110000000011111111111000000000000000000
  131. X000000000111111111111111111111111100000000111111111111000000000000000000
  132. X000000000111111111112211111222110000000001111111111110000000000000000000
  133. X000000000111111111122222221111100000000011111221111111000000000000000000
  134. X000000000111111111122222111000000000001111122212221111100000000000000000
  135. X000000000011111111112222100000000000011112222212111111100000000000000000
  136. X000000000011111111111121000000000011111222222211111111110000000000000000
  137. X000000000011111111111010000000000111112222222211111111111000000000000000
  138. X000000000011111111100000000001111111222221112111111111111100000000000000
  139. X000000000011111111000000000112211222222211122111111111111111000000000000
  140. X000000000011111111000000001211111222221111111111111111111110000000000000
  141. X000000000000001110000000011111122222111111111111111111111110000000000000
  142. X000000000000000000000000111111222221111111111111111111100000000000000000
  143. X000000000000000000000001111212222111111111111101111111000000000000000000
  144. X000000000000000000000001222122221111111111111001111111000000000000000000
  145. X000000000000000000000001222222111111111111111101111110000000000000000000
  146. X000000000000000000000001222111111111111111111100110000000000000000000000
  147. X000000000000000000000001211111111111111111111000000000000000000000000000
  148. X000000000000000000000001111111111111111111111000000000000000000000000000
  149. X000000000000000000000000111111111111111111110000000000000000000000000000
  150. X000000000000000000000000111111111111111100000000000000000000000000000000
  151. X000000000000000000000000111111111111111000000000000000000000000000000000
  152. X000000000000000000000000011011111111100000000000000000000000000000000000
  153. X000000000000000000000000000011111111000000000000000000000000000000000000
  154. X000000000000000000000000000000110000000000000000000000000000000000000000
  155. X000000000000000000000000000000000000000000000000000000000000000000000000
  156. X000000000000000000000000000000000000000000000000000000000000000000000000
  157. X000000000000000000000000000000000000000000000000000000000000000000000000
  158. X000000000000000000000000000000000000000000000000000000000000000000000000
  159. X000000000000000000000000000000000000000000000000000000000000000000000000
  160. X000000000000000000000000000000000000000000000000000000000000000000000000
  161. X000000000000000000000000000000000000000000000000000000000000000000000000
  162. X000000000000000000000000000000000000000000000000000000000000000000000000
  163. X000000000000000000000000000000000000000000000000000000000000000000000000
  164. X000000000000000000000000000000000000000000000000000000000000000000000000
  165. X000000000000000000000000000000000000000000000000000000000000000000000000
  166. X000000000000000000000000000000000000000000000000000000000000000000000000
  167. X000000000000000000000000000000000000000000000000000000000000000000000000
  168. END_OF_FILE
  169. if test 3504 -ne `wc -c <'tec-v3/tec.out.1'`; then
  170.     echo shar: \"'tec-v3/tec.out.1'\" unpacked with wrong size!
  171. fi
  172. # end of 'tec-v3/tec.out.1'
  173. fi
  174. if test -f 'tec-v3/tec.out.2' -a "${1}" != "-c" ; then 
  175.   echo shar: Will not clobber existing file \"'tec-v3/tec.out.2'\"
  176. else
  177. echo shar: Extracting \"'tec-v3/tec.out.2'\" \(3504 characters\)
  178. sed "s/^X//" >'tec-v3/tec.out.2' <<'END_OF_FILE'
  179. X000000000000000000000000000000000000000000000000011111111111221000000000
  180. X000000000000000000000000000000000000000000000000001111111111222000000000
  181. X000000000000000000000000000011000000000000000000001111111111122100000000
  182. X000000000000000000000000011111110000000000000000000111111111111100000000
  183. X000000000000000000000000111111111100000000000000000111111111111100000000
  184. X000000000000000000000000011111111100000000000000000011111111111001100000
  185. X000000000000000000110000000011111100000000000000000011111111111011110000
  186. X000000000000000001110000000001111100000000000000000001111111211121111000
  187. X000000000000000001110110000000011110000000000000000001111111221121111000
  188. X000000000000000001111100000000000111000000000000000000111111221121111000
  189. X000000000000000001111110000000000111000001000000000000111111221121111000
  190. X000000000000000001111111110000000111000001000000000000011111221111111000
  191. X000000000000000001111111111000001111000001000000000000001111211112111000
  192. X000000000000000001211111111100011111000001000000000000001111221112111000
  193. X000000000000000001111111111110111111000001100000000000000111122112111000
  194. X000000000000000001111111111111111111000001110000000000000111122112111000
  195. X000000000000000001111111111111111111000001111000000000000011122112111000
  196. X000000000000000001111111111111111111000001111000000000000011112111210000
  197. X000000000000000000111111111111111111000001111100000000000001112211110000
  198. X000000000000000000111111111111111111000001111110000000000000112211110000
  199. X000000000000000000111111111111111111000001111110000000000000011221110000
  200. X000000000000000000111111111111111111000001111111000000000000001111100000
  201. X000000000000000000121111111111111111000001111111000000000000000111000000
  202. X000000000000000000011111111111111111000001111111000000000000000010000000
  203. X000000000000000000001111111111111111000001111111100000000000000000000000
  204. X000000000000000000000000121111111111000001111111110000000000000000000000
  205. X000000000000000000000000111111111110000001111111111000000000000000000000
  206. X000000000000000000000000121111111100000001111111111100000000000000000000
  207. X000000000000000000000000011111111000000011111111111110000000000000000000
  208. X000000000000000000000000001111111000000011111111111110000000000000000000
  209. X000000000000000011111100000111111000000011111111111111000000000000000000
  210. X000000000000000112222110000000011000000011111111111111000000000000000000
  211. X000000000001011222222210000000001000000011111111111111100000000000000000
  212. X000000000011112221112211000000000000000001111111111111110000000000000000
  213. X000000000012222111111121000000000000000001111111111111110000000000000000
  214. X000000000012211111111121110000000000000001111111111111100000000000000000
  215. X000000000011111111111112211111000000000001111111111111000000000000000000
  216. X000000000001111111111112222221110000000001111111111110000000000000000000
  217. X000000000011111111111112222222221100000000000000000000000000000000000000
  218. X000000000011111111112222222222222110000000000000000000000000000000000000
  219. X000000000011111111112222222222222210000000000000000000000000000000000000
  220. X000000000001111001111111111111111110000000000000000000000000000000000000
  221. X000000000000000000000000000000000000000000000000000000000000000000000000
  222. X000000000000000000000000000000000000000000000000000000000000000000000000
  223. X000000000000000000000000000000000000000000000000000000000000000000000000
  224. X000000000000000000000000000000000000000000000000000000000000000000000000
  225. X000000000000000000000000000000000000000000000000000000000000000000000000
  226. X000000000000000000000000000000000000000000000000000000000000000000000000
  227. END_OF_FILE
  228. if test 3504 -ne `wc -c <'tec-v3/tec.out.2'`; then
  229.     echo shar: \"'tec-v3/tec.out.2'\" unpacked with wrong size!
  230. fi
  231. # end of 'tec-v3/tec.out.2'
  232. fi
  233. if test -f 'tec-v3/tec.out.3' -a "${1}" != "-c" ; then 
  234.   echo shar: Will not clobber existing file \"'tec-v3/tec.out.3'\"
  235. else
  236. echo shar: Extracting \"'tec-v3/tec.out.3'\" \(3504 characters\)
  237. sed "s/^X//" >'tec-v3/tec.out.3' <<'END_OF_FILE'
  238. X000000000000000000000000000000000000000000000000000000000000000000000000
  239. X000000000000000000000000000000000000000000000000000000000000000000000000
  240. X000000000000000000000000000000000000000000000000000000000000000000000000
  241. X000000000000000000000000000000000000000000000000000000000000000000000000
  242. X000000000000000000000000000001110000000000000000000011000000000000000000
  243. X000000000000000000000000000001101111111111111111111111000000000000000000
  244. X000000000000000000000000000000001111111111111111111111000000000000000000
  245. X000000000000000000000011000000000111111111111111111111000000000000000000
  246. X000000000000000000000011100000000001111111111111111111110000000000000000
  247. X000000000000000000000011111100000000011111111111111111110000000000000000
  248. X000000000000000000000011111100000000000111111111111111100000000000000000
  249. X000000000000000000000011111110000000000011111111111111100000000000000000
  250. X000000000000000000000011111111110000000001111111111110111111110000000000
  251. X000000000000000000000011111111111000000001111111111101111111111000000000
  252. X000000000000000000000011111111111110000000111111000001111111111110000000
  253. X000000000000000000000011111111111111000000011110000011111111111110000000
  254. X000000000000000000000011111111111110000000111110000111111111111000000000
  255. X000000000000000000000011111111111111100001111110001111111111110000000000
  256. X000000000000000000000011111111111111110011111111111111111111110000000000
  257. X000000000000000000000001111111111111111111111111111111111111111100000000
  258. X000000000000000000000001111111111111111111111111111111111111111110000000
  259. X000000000000000000000001111111111111111111111111111111111111111110000000
  260. X000000000000000000000001111111112221111111111111111111111111111110000000
  261. X000000000000000000000001111111112221111111111111111111111000010000000000
  262. X000000000000000000000000111111112211111111111111111111110000000000000000
  263. X000000000000000000000000000011122111111111111111111111111000000000000000
  264. X000000000000000000000000000111121111111111111111111111111100000000000000
  265. X000000000000000000000000001111111111111011111111111111111100000000000000
  266. X000000000000000000000000011112111111110011111111111111111100000000000000
  267. X000000000000000111111111111122111111110011111111111111111000000000000000
  268. X000000000000000111111111111111111111110011111111111111110000000000000000
  269. X000000000000000111111112222111111111110011111111111111000000000000000000
  270. X000000000000000111111222211111111111110011111111111111100000000000000000
  271. X000000000000000111111221111111111111111001111111111111110000000000000000
  272. X000000000000000111111111111111111111111101111111111111100000000000000000
  273. X000000000000000111111111111111111111111101111111111111000000000000000000
  274. X000000000000000111111111111111111111111001111111111110000000000000000000
  275. X000000000000000111111111111000111111100001111101101100000000000000000000
  276. X000000000000000111111111000000000000000000000000000000000000000000000000
  277. X000000000000000001111110000000000000000000000000000000000000000000000000
  278. X000000000000000000111000000000000000000000000000000000000000000000000000
  279. X000000000000000000010000000000000000000000000000000000000000000000000000
  280. X000000000000000000000000000000000000000000000000000000000000000000000000
  281. X000000000000000000000000000000000000000000000000000000000000000000000000
  282. X000000000000000000000000000000000000000000000000000000000000000000000000
  283. X000000000000000000000000000000000000000000000000000000000000000000000000
  284. X000000000000000000000000000000000000000000000000000000000000000000000000
  285. X000000000000000000000000000000000000000000000000000000000000000000000000
  286. END_OF_FILE
  287. if test 3504 -ne `wc -c <'tec-v3/tec.out.3'`; then
  288.     echo shar: \"'tec-v3/tec.out.3'\" unpacked with wrong size!
  289. fi
  290. # end of 'tec-v3/tec.out.3'
  291. fi
  292. if test -f 'tec-v3/howtorun.doc' -a "${1}" != "-c" ; then 
  293.   echo shar: Will not clobber existing file \"'tec-v3/howtorun.doc'\"
  294. else
  295. echo shar: Extracting \"'tec-v3/howtorun.doc'\" \(9224 characters\)
  296. sed "s/^X//" >'tec-v3/howtorun.doc' <<'END_OF_FILE'
  297. COMPILING AND RUNNING TEC ON THE AMIGA
  298. X
  299. Compile tec1.c, tec2.c, tec3.c and ami.c.  I have Lattice C 4.0
  300. and I use lc1 -oram:, lc2 -ccdb -v.  The -ccdb puts the entire
  301. executable into chip ram; this is overkill, but the custom chips have
  302. to be able to get to the graphics structures in ami.c.  Then BLink the
  303. four .o files along with the startup code and the lcm, lc and amiga
  304. libraries (lcm has to be before lc, but you knew that).
  305. X
  306. Tec doesn't need any command line arguments, but if you wish to store
  307. snapshots you should redirect standard output to a file, for example
  308. X
  309. tec >ram:tec.out
  310. X
  311. XEach snapshot is about 32K of text.
  312. X
  313. When the program comes up, it opens a 5 bitplane 320 x 200 screen with one
  314. big window.  If you need to see the Workbench screen again you can use
  315. left-amiga-m,n.  After a second or two, a big green blob will pop up.  This
  316. is the initial supercontinent. Every three seconds or so, another "step" will
  317. be computed and drawn.
  318. X
  319. Altitudes are represented by colors; from lowest to highest, these are:
  320. black (ocean), dark blue (deep continental shelf), bright blue (higher
  321. continental shelf), dark green (lowest abovewater elevation), bright green,
  322. dark red, bright red, purple, white, yellow.  There are about 24 visibly
  323. different altitude ranges, since each color has several shades.
  324. X
  325. As time passes, you will see the supercontinent split up; red and purple
  326. mountains will appear on the leading edges of drifting continents; when
  327. continents slow down, reverse course, and collide, high purple and white
  328. mountains will appear.  If you watch carefully, you can see erosion on
  329. mountains that are not growing; they turn dark red and then bright green.
  330. X
  331. At any time, you can click on the close window gadget to kill the program.
  332. It only checks the mouse once per update, so it may take the program a few
  333. seconds to notice you have killed it.
  334. X
  335. If you click the left mouse button anywhere but on the close gadget, the
  336. program will pause after the next update and write 450 lines of data to
  337. stdout.  If you have not redirected stdout to a file, it takes about two
  338. minutes for it all to come out; redirected to ram:, it takes about 30
  339. seconds.  The program obviously will not do anything else during this time.
  340. Typing ctrl-C will bring up a Lattice requester asking if you want to abort;
  341. I don't advise this, because the abort does not close the window and screen.
  342. X
  343. X
  344. COMPILING AND RUNNING TEC ON A UN*X PLATFORM
  345. X
  346. Type "cc -o tec tec?.c unix.c -lm" to create an executable called tec.
  347. Tec doesn't need any command line arguments and prints all its output
  348. to stdout.  To do almost anything interesting, you will have to adjust
  349. the parameters, as explained in the file params.doc.
  350. X
  351. X
  352. COMPILING AND RUNNING TEC UNDER SUNVIEW
  353. X
  354. Type "cc -o tec tec?.c sun.c -lsuntool -lsunwindow -lpixrect -lm" to make
  355. an executable called tec.  A canvas subwindow is opened; every second or so
  356. another step will be displayed.  On the Sparcstation several steps are
  357. displayed per second.  The colors displayed are identical to those
  358. used in the Amiga version.  Use the Sunview menu to exit the program.  I
  359. am using the simplest Sunview interface scheme, and you have to hold the
  360. mouse button down for a couple of seconds to get the menu.  Currently it is
  361. not possible to tell the Sunview version of tec to print output; use the
  362. Un*x version for that.
  363. X
  364. X
  365. COMPILING AND RUNNING TEC ON AN IBM PC/XT/AT OR 100% COMPATIBLE (TURBO C 2.00+)
  366. X(This section by Peter Lind)
  367. X
  368. Suggested Compiler Configuration
  369. The following compiler options are recommended to yield the fastest execution
  370. speed. Any or all may be changed as the user sees fit. On 80x86 machines (as
  371. opposed to the 8088), enabling word-boundary alignment will increase speed.
  372. On 80186/80286 machines, enabling the extended instruction set will also yield
  373. a speed-up. If an 80x87 is available, enable generation of 80x87 code. Finally,
  374. for best results, disable all debugging-oriented options.
  375. X
  376. X    Memory Model    : Compact (or Large or Huge).
  377. X    Optimization    : Optimize for speed
  378. X                      Use of registers      ON
  379. X                      Register optimization ON
  380. X                      Jump optimization     ON
  381. X
  382. Option 1 -- Integrated Environment
  383. Create a file called TEC.PRJ containing the lines 'tec1.c', 'tec2.c',
  384. X'tec3.c', 'ibmpc.c'.  Set the Project name to TEC.PRJ and press F9 to make.
  385. The resulting file will be called TEC.EXE. Ignore the warnings produced.
  386. X
  387. Option 2 -- Command Line Make
  388. Read through the comments in the make file TEC.MAK; the macro directory
  389. names may have to be changed to conform with your system; also, there are
  390. certain macros that can be changed to compile TEC for an 80186/80286
  391. and/or an 80x87.
  392. X
  393. Run the Turbo C MAKE utility with the command line: make -ftec.mak
  394. The included makefile TEC.MAK uses the command line options listed below;
  395. either of these may be changed to suit the user's preference:
  396. X        -mc        Compact memory model
  397. X        -G         Optimize for speed
  398. X        -w-        Suppress warnings
  399. X        -a         Align to word
  400. X
  401. A Note on Required Files (supplied with Turbo)
  402. X
  403. X   i) Either (or both) .BGI files (CGA.BGI and EGAVGA.BGI) must reside in the
  404. X      *current* DOS directory (where it is assumed TEC.EXE resides).
  405. X
  406. X  ii) If TEC is to be run in EGA/VGA mode, TRIP.CHR should reside in the 
  407. X      *current* DOS directory.
  408. X
  409. X      If TEC is to be run in CGA/MCGA mode, LITT.CHR should reside in the 
  410. X      *current* DOS directory.
  411. X
  412. X iii) If the programmer wants to execute TEC via the DOS search path, then
  413. X      modifications will have to be made to IBMPC.C, and (sorry, but) the
  414. X      programmer is on his/her own since this problem is not straightforward
  415. X      and could be solved in a variety of ways (most simple of which would be
  416. X      to place the *exact* DOS path in double quotes as the third parameter
  417. X      to grafinit() in IBMPC.C).
  418. X
  419. X
  420. Running the Program
  421. X
  422. The IBM PC version of TEC will run under CGA, MCGA, EGA or VGA graphics,
  423. auto-detecting the graphics hardware and choosing the mode with highest
  424. resolution. Since CGA and MCGA hi-res modes provide only two colors (black
  425. and white), a rudimentary 3-D plotting facility is provided to take the
  426. place of the standard multi-colored plotting. In EGA or VGA, the user may
  427. switch between the multi-colored and 3-D modes as desired. The 3-D facility
  428. is rather sluggish, but produces interesting plots; it can be run in either
  429. X"fast" or "slow". In slow mode, each "pixel" of the plate tectonics is drawn
  430. as a 3-D block. In fast mode, all "pixels" in the same row with the same height
  431. are merged and plotted as a wide "slab". The fast mode is faster, but the plot
  432. produced does not look as good as that generated by the slow mode.
  433. X
  434. When TEC.EXE is run, the introductory credits panel will first be displayed;
  435. press any key to cause the program to continue. A window will then be drawn on
  436. the screen with a title bar along the top and a message line along the bottom.
  437. The program will display the message "Setting up..." while the initial data
  438. structure preparation is performed. Then, TEC will enter its main loop that
  439. repeatedly generates one "time step" and displays the map.
  440. X
  441. a) Thinking Phase: TEC displays the message "Thinking..." while generating the
  442. X   next step. While TEC is "thinking", the user may press a key:
  443. X
  444. X        ESC        Abort to DOS when finished thinking
  445. X       SPACE       Pause after plotting until any key pressed
  446. X       p or P      Print (Generic, Text or Postscript)
  447. X       g or G      Change plotting style (Standard, Slow 3-D, Fast 3-D)
  448. X
  449. X   TEC will respond to the key press when it finishes thinking.
  450. X
  451. b) Plotting Phase: When finished thinking, and provided that the user did not
  452. X   abort the program, TEC will display the message "Plotting..." and begin
  453. X   plotting the current step. In CGA/MCGA, the plotting is always monochromatic
  454. X   simulated 3-D. In EGA/VGA, TEC displays different altitudes in different
  455. X   colors. From lowest to highest, these are: black (ocean), dark blue (deep
  456. X   continental shelf), light blue (higher continental shelf), dark green
  457. X   (lowest abovewater elevation), light green, yellow, magenta, light magenta,
  458. X   dark red, light red, brown, light gray, and white. There are 13 visibly
  459. X   different altitude ranges.
  460. X
  461. X   The following keys are recognized while plotting:
  462. X
  463. X        ESC        Abort to DOS immediately
  464. X         CR        Skip current plot (immediately start next thinking phase)
  465. X       p or P      Print (Generic, Text or Postscript) when done plotting
  466. X       g or G      Change plotting style (Standard, Slow 3D, Fast 3D)
  467. X
  468. X   If `p' (or `P') is pressed, the print operation will start after the plot is
  469. X   completed. Note that printing will not proceed unless stdout was redirected
  470. X   on the command line, as in:
  471. X
  472. X          TEC >TEC.OUT
  473. X
  474. X
  475. X   The action that TEC takes when `g' (or `G') is pressed depends on the
  476. X   graphics mode:
  477. X
  478. X      (i)  If TEC is running under CGA or MCGA, the user is able to switch
  479. X           immediately between fast or slow 3-D plotting (but is unable to
  480. X           switch to standard, color plotting).
  481. X
  482. X      (ii) If TEC is running under EGA or VGA, the command is deferred
  483. X           until the plot is finished (as the plot cannot be restarted).
  484. X
  485. END_OF_FILE
  486. if test 9224 -ne `wc -c <'tec-v3/howtorun.doc'`; then
  487.     echo shar: \"'tec-v3/howtorun.doc'\" unpacked with wrong size!
  488. fi
  489. # end of 'tec-v3/howtorun.doc'
  490. fi
  491. if test -f 'tec-v3/params.doc' -a "${1}" != "-c" ; then 
  492.   echo shar: Will not clobber existing file \"'tec-v3/params.doc'\"
  493. else
  494. echo shar: Extracting \"'tec-v3/params.doc'\" \(5099 characters\)
  495. sed "s/^X//" >'tec-v3/params.doc' <<'END_OF_FILE'
  496. If you give tec a filename as a command line argument, it will read 
  497. parameters from that file.  If you hand it '-' as an argument, it will
  498. read them from stdin.  For example, you could type "tec - < foo", or
  499. X"tec foo".  The '-' option is handy for pipes.
  500. X
  501. The parameter file is optional; all of the parameters you can change
  502. have defaults.  Thus, the parameter file need contain only the parameters
  503. you want to change.  A parameter file looks like LISP; for example,
  504. to change the XSIZE parameter, the file would have the one line
  505. X
  506. X(XSIZE 40)
  507. X
  508. Parameters can also be vectors; for example
  509. X
  510. X(MOVERATE (1 1 1))
  511. X
  512. The parameters are either easy or hard.  This rating concerns how much
  513. you have to know about the simulation to change the parameters.  Easy
  514. ones just affect run time, resolution, and so on.  Hard ones should
  515. only be changed if you understand the code pretty well.
  516. X
  517. XEasy parameters:
  518. DRAWMODE  - 0 produces no output, 1 produces a long text file (default),
  519. X            2 produces a summary text file and 3 produces PostScript
  520. X            grayscale drawings.
  521. DRAWEVERY - How many steps should be iterated for each output.  Default 1,
  522. X            but this produces an awful lot of text.  Reasonable values
  523. X            for non-interactive runs are 5 or 10.  Supercontinents appear
  524. X            every 25 steps or so.
  525. MAXSTEP   - How many steps to run before terminating.  Default 100.
  526. XXSIZE     - Horizontal size of arrays.  Default 90.  To produce summaries
  527. X            that fit on a normal page, I used 72.
  528. YSIZE     - Vertical size of arrays.  Default 90.  To produce the summaries
  529. X            included in tec.out.[1-3], I used 48.
  530. BLOBLEVEL - Indirectly related to size of initial supercontinent.  I made
  531. X            some 4000 blobs with different values of BLOBLEVEL to come up
  532. X            with this empirical relationship:  the average diameter of the
  533. X            supercontinent is 83 - (0.625 * BLOBLEVEL).  The blob is
  534. X            clipped to the size of the world and can not exceed a
  535. X            diameter of 64 anyway.
  536. X
  537. So to produce a text file with 10 pictures, you could use 
  538. X
  539. X(DRAWMODE 2) (DRAWEVERY 10) (XSIZE 72) (YSIZE 48) (BLOBLEVEL 80)
  540. X
  541. To produce a 20-page PostScript output with a little more detail, use
  542. X
  543. X(DRAWMODE 3) (DRAWEVERY 5)
  544. X
  545. Hard Parameters:
  546. ZINIT     - Initial altitude of supercontinent.  Default 22.
  547. ZSUBSUME  - Altitude added to leading edge of drifting plate.  Default 16.
  548. ZCOAST    - Sea level.  Everything below this is under water.  Default 16.
  549. ZSHELF    - Minimum altitude for continental shelf.  Default 8.
  550. ZMOUNTAIN - Used in DRAWMODE 2; altitude above which a square is counted
  551. X            as mountain instead of land.  Default 48.
  552. MAXBUMP   - If two plates overlap on more than this number of squares,
  553. X            the plates must be merged together.  Default 50. 
  554. BUMPTOL   - If the relative velocity of two touching plates is less than this
  555. X            value, the plates will be merged together.  Default 50.
  556. MOVERATE  - A vector of real numbers describing the rate at which plates
  557. X            move apart, slow down, and then drift back together.  Each
  558. X            plate has an age, measured in steps from its creation.  The age
  559. X            is used as an offset into the vector.  The result is a real
  560. X            between -1.0 and +1.0 which is multiplied by the plate's original
  561. X            movement vector.  The default vector is
  562. X            (1.0 1.0 1.0 0.7 0.4 0.1 -0.2 -0.5 -0.8 -1.0)
  563. X
  564. X            It can be interpreted this way.  The first three steps a plate is
  565. X            in motion, it moves at its normal velocity.  During the 4-6
  566. X            steps, it slows down.  During the 7-10 steps, it moves the
  567. X            opposite way from the way it started, at increasing speeds.
  568. X            Thereafter, it keeps moving at its final velocity.
  569. RIFTPCT   - Percent chance that a rift will occur in a given step.  Default 40.
  570. MAXCTRTRY - The number of tries the rift routine will make to find an
  571. X            acceptable place to start a rift.  Default 50.
  572. RIFTDIST  - The minimum allowable distance between a proposed rift center
  573. X            and the nearest coast.  Default 5.
  574. DOERODE   - Whether or not to compute erosion.  Default 1; if 0, the program
  575. X            will run about twice as fast but will generate way too many
  576. X            mountains, since the only thing that gets rid of mountains
  577. X            is erosion.
  578. XERODERND  - The rounding factor used in erosion.  Default 4.  As this 
  579. X            parameter goes from 0 to 7, erosion occurs faster.
  580. BENDEVERY - Each time a rift grows by this many squares, it is allowed to
  581. X            bend a little bit.  Default 6.
  582. BENDBY    - When a rift bends, it bends by a random angle in the range
  583. X            -BENDBY ... +BENDBY multiplied by pi/2000.  Default value is 100.
  584. X            If BENDBY is too high or BENDEVERY is too low, very curvy rifts
  585. X            will be generated, with unrealistic results.
  586. SPPEDBASE - The minimum speed at which new plates will travel.  Default 200.
  587. SPEEDRNG  - The actual speed at which a plate travels is SPEEDBASE +
  588. X            rnd (SPEEDRNG).  Default value is 300.
  589. END_OF_FILE
  590. if test 5099 -ne `wc -c <'tec-v3/params.doc'`; then
  591.     echo shar: \"'tec-v3/params.doc'\" unpacked with wrong size!
  592. fi
  593. # end of 'tec-v3/params.doc'
  594. fi
  595. if test -f 'tec-v3/technical.doc' -a "${1}" != "-c" ; then 
  596.   echo shar: Will not clobber existing file \"'tec-v3/technical.doc'\"
  597. else
  598. echo shar: Extracting \"'tec-v3/technical.doc'\" \(10300 characters\)
  599. sed "s/^X//" >'tec-v3/technical.doc' <<'END_OF_FILE'
  600. I.  MOTIVATION AND APPROACH
  601. X
  602. I wanted to write a program to generate maps of many imaginary worlds using
  603. a microcomputer.  Fractal techniques produce unacceptably random-looking maps.
  604. In other related fields, people have used simplified models of physical
  605. processes and then tweaked the model parameters to give results that "looked
  606. right".  Dole [1] simulated accretion of planets around stars.  Hart [2]
  607. simulated the evolution of a planetary atmosphere.  Forrester [3] simulated
  608. population dynamics for near-future Earth.  My approach was to find a physical
  609. model for continent formation, and then write a program to implement that model.
  610. X
  611. Geologists have proposed [4] that several times in history, the continents
  612. of Earth have drifted together to form a single "supercontinent", which later
  613. broke apart.  A recent paper [5] suggested a physical model for this
  614. X"supercontinent cycle", and I used that model for my program.
  615. X
  616. Their hypothesis runs like this.  (Disclaimer - I don't know anything about
  617. geology except what I got from reading a few papers.)  The Earth generates
  618. heat by radioactive decay; this heat is conducted away more slowly by
  619. continental crust than by oceanic crust.  Heat accumulates under large
  620. continents, causing them to dome upwards and eventually break apart.  After
  621. a certain amount of heat has escaped through the new ocean basin, the
  622. continental fragments are drawn back together by the subsiding basin.
  623. Over long periods of time, many oceans should open and close in the center
  624. of the land area, while the original superocean should remain about the same.
  625. X
  626. Any map of the Earth shows evidence to support this hypothesis.  The Atlantic
  627. and Mediterranean oceans are fairly recent, while the Pacific could be
  628. considered the superocean.  The Himalayas, the Pyrenees, and the Ukraine
  629. mountain ranges could have been formed by collisions between continental
  630. fragments.  The "Ring of Fire" around the Pacific represents subduction zones
  631. where new mountains, such as the Rockies, are forming as the continents drift
  632. further apart.  The older, lower Appalachian mountains might have been created
  633. during a collision between Europe and North America in the last supercontinent
  634. cycle.
  635. X
  636. X
  637. II.  REPRESENTATION
  638. X
  639. One data structure well-suited for storing topographic maps is a simple
  640. two-dimensional array, where each array element represents the height
  641. of the terrain at that point.  However, the Earth is spherical and a sphere
  642. can't be mapped onto a plane without some distortion.  After trying many
  643. mapping methods, I came back to the simplest:  I pretend Columbus was wrong,
  644. and the world really is flat.  Since the continents in the physical model
  645. drift toward and away from some central point, it is reasonable, if the map
  646. is large enough, to simply throw away the land area that falls off the
  647. edge of the map.  I used a simple square, flat surface with no "wraparound."
  648. X
  649. I could, and probably will at some point, write a couple of paragraphs about
  650. why doing plate movement on a sphere is so hard.  All of the methods I
  651. tried required too much data storage for each point, or too much real
  652. number computation, or resulted in unacceptable distortion.  The criterion
  653. I used was to place a small continent, say a 5 x 5 square, anywhere on
  654. the surface.  It should be able to travel one great circle in any direction
  655. and remain undisturbed though the entire journey.  The method should not
  656. require _any_ floating point computation once the initial velocity is
  657. computed since I want to do many iterations on a microcomputer.
  658. X
  659. A second representation issue is how to cause plates to drift apart and
  660. back together.  Maintaining the detailed structure of the ocean basin is
  661. complicated; consider a circular landmass which splits along a diameter.
  662. The ocean basin structure here is clear, since the rift remains in place and
  663. the new basin extends out from it in both directions.  Now suppose one of
  664. the semicircular fragments splits in half perpendicular to the first split.
  665. The motion of the landmasses can be computed easily, but the new rift must
  666. drift as well and the required motions in the basin seem self-contradictory.
  667. X
  668. I chose to ignore the ocean basin and concentrate on the landmasses.  Thus,
  669. rifts are not recorded in any way and the ocean floor does not move.  Since
  670. the basins are not simulated, some mechanism is needed to replace the physical
  671. mechanism of the sinking basin sucking the landmasses back together.  This
  672. is done by a velocity scaling profile which is coded directly into the
  673. movement routine.  The profile says that after a short time, forward motion
  674. of a landmass slows and then stops; after this point the landmass begins to
  675. move backwards towards its origin.
  676. X
  677. X
  678. III. ALGORITHM
  679. X
  680. The initial supercontinent is generated by a simple fractal algorithm; a
  681. fractal mountain is created by superimposing four two-dimensional fractal
  682. lines.  The mountain is then turned into a binary blob, that is, everything
  683. above a certain altitude is declared to be land, and everything else becomes
  684. water.  The blob is then "improved" by removing islands and internal oceans.
  685. This technique produces very irregular circular blobs of varying sizes.
  686. X
  687. The program then repeats a sequence of operations for each timestep.  First,
  688. a rift may be generated, splitting some continent into pieces; new velocities
  689. are generated for the new landmasses.  Second, the distance each landmass will
  690. move this timestep is determined by applying the velocity profile described
  691. above to the landmass velocity.  Third, the landmasses are moved and mountains
  692. are built.  Fourth, where the movement routine has caused landmasses to
  693. overlap, new velocities are computed for the overlapping landmasses, and they
  694. may be merged into a single landmass if they overlap sufficiently.  Fifth, the
  695. entire topography is eroded; if a square is higher than the square next to
  696. it, the altitudes are made more equal.  Finally, the screen is redrawn.
  697. X
  698. In step one, random coordinates are generated until a location is found
  699. which is at least five squares from any ocean.  This location will be the
  700. center of a rift, which is represented as a randomly curving line.  The
  701. distance requirement is there to ensure that if a rift occurs, it occurs
  702. on a fairly large continent where internal heat would accumulate.  When
  703. the rift is drawn, it is allowed to bend randomly but is drawn using
  704. conventional digital line-drawing techniques (i.e. Bresenham's algorithm).
  705. The rift drawing routine terminates when the rift hits ocean.  If the growing
  706. rift hits another landmass, which could occur if two landmasses were touching
  707. but had not yet merged, the rift is aborted since the result would be a very
  708. unnatural looking U-shaped continent.
  709. X
  710. Once the rift is created, a segmentation algorithm determines how
  711. many new landmasses were formed.  There should only be two new landmasses,
  712. but splinters can be formed if the rift runs along a narrow peninsula or
  713. too close to a coast.  The algorithm detects and erases such splinters.
  714. The landmasses are given an initial velocity which makes them drift directly
  715. away from the rift.  The velocities are inversely dependent on the area
  716. of the landmass so that smaller masses move faster.  After the initial
  717. velocities have been determined, the rift is erased.
  718. X
  719. The second and third steps are concerned with moving the landmasses.  This
  720. is done with a slightly simpler version of Bresenham's algorithm.  The velocity
  721. profile described in Section II is applied so that landmasses will drift
  722. apart at first, but will then slow down and come back together.  Because a
  723. landmass can split up again, the process does not simply reassemble the
  724. original supercontinent when they drift back together.
  725. X
  726. Mountains are built under two conditions: where two landmasses collide, and
  727. where landmass subsumes ocean basin.  Both conditions are detected and resolved
  728. in the movement routine.  Movement is performed from a source array to a
  729. destination array.  A loop steps over every square in the source array.  If
  730. there is land in a square, its new position is computed based on what
  731. landmass the square belongs to.  If there is ocean basin there in the source
  732. array, the square belongs to the leading edge of a landmass which is subsuming
  733. ocean basin.  A constant is added to the height of the land in that square.
  734. If there is land there in the destination array, then the two landmasses are
  735. colliding.  There is a collision array which records how many times each
  736. pair of landmasses collide in any given timestep, and the movement routine
  737. increments the appropriate element of this array for each collision.
  738. Mountains are built in this case by adding half the height of the lower
  739. terrain to the height of the higher terrain.
  740. X
  741. Step four uses the collision information provided by the movement routine
  742. to adjust the velocities of colliding landmasses and perhaps merge them.
  743. XFor each pair of colliding landmasses, the routine determines how "strong"
  744. the collision is this timestep.  The velocities are adjusted, again in
  745. inverse proportion to the landmass areas, so that the continents begin
  746. to come to rest with respect to each other.  If the relative velocity of
  747. the two landmasses, after adjustment, is small enough, then the masses
  748. are merged.  This is the mechanism that reassembles the continental
  749. fragments into a supercontinent.
  750. X
  751. XErosion is the final, and most computation-intensive, step of the simulation.
  752. XEach pair of adjacent squares is considered exactly once.  If either square
  753. is part of a landmass, erosion occurs.  Some fraction of the difference between
  754. the two squares' altitudes is subtracted from the taller and added to the
  755. shorter.  This is a very simple algorithm since it ignores many factors,
  756. but more detail would make the simulation even slower.
  757. X
  758. X
  759. IV.  REFERENCES
  760. X
  761. X1.  Dole, Stephen H., "Computer Simulation of the Formation of Planetary
  762. X    Systems", Icarus 13 (1970), pp 494-508.
  763. X2.  Hart, Michael H., ""The Evolution of the Atmosphere of the Earth", Icarus
  764. X    33 (1978), pp 23-39.
  765. X3.  Forrester, J.W., World Dynamics, Wright-Allen Press (1973).
  766. X4.  Wilson, J. Tuzo, "Continental Drift", Scientific American 208, 4 (April
  767. X    1963), pp 86-100.
  768. X5.  Nance, R.D., Worsley, T.R., and Moody, J.B., "The Supercontinent Cycle",
  769. X    Scientific American (July 1988), pp 72-79.
  770. END_OF_FILE
  771. if test 10300 -ne `wc -c <'tec-v3/technical.doc'`; then
  772.     echo shar: \"'tec-v3/technical.doc'\" unpacked with wrong size!
  773. fi
  774. # end of 'tec-v3/technical.doc'
  775. fi
  776. if test -f 'tec-v3/ami.c' -a "${1}" != "-c" ; then 
  777.   echo shar: Will not clobber existing file \"'tec-v3/ami.c'\"
  778. else
  779. echo shar: Extracting \"'tec-v3/ami.c'\" \(6077 characters\)
  780. sed "s/^X//" >'tec-v3/ami.c' <<'END_OF_FILE'
  781. X/* This program is Copyright (c) 1990 David Allen.  It may be freely
  782. X   distributed as long as you leave my name and copyright notice on it.
  783. X   I'd really like your comments and feedback; send e-mail to
  784. X   davea@vlsi.ll.mit.edu, or send us-mail to David Allen, 10 O'Moore Ave,
  785. X   Maynard, MA 01754. */
  786. X
  787. X
  788. X/* This file contains only functions which are specific to the Amiga.  It
  789. X   connects to the other source files via a small number of functions.
  790. X   Main() is here.  It calls init() and onestep().  The other source files
  791. X   can call rnd(), draw() and panic() from this file; these are at the end
  792. X   of the file.  My purpose here is to make tec?.c machine
  793. X   independent, with all the machine dependencies in this file. */
  794. X
  795. X
  796. X#include "const.h"
  797. X#include "var.h"
  798. X#include "exec/types.h"
  799. X#include "intuition/intuition.h"
  800. X#include "intuition/intuitionbase.h"
  801. X
  802. extern short step; /* Defined in tec1.c */
  803. extern unsigned char t[2][MAXX][MAXY]; /* Defined in tec1.c */
  804. extern unsigned long RangeSeed; /* Amiga random number seed */
  805. extern struct IntuitionBase *IntuitionBase;
  806. X
  807. struct GfxBase        *GfxBase;
  808. struct RastPort       *rp;
  809. struct ViewPort       *vp;
  810. struct Window         *w = NULL;
  811. struct Screen         *screen;
  812. struct IntuiMessage   *message;
  813. unsigned long         class;
  814. unsigned short        code;
  815. X
  816. X/* 32 colors - 0-3 are used by Intuition; black background, grey gadgets, */
  817. X/* white shadows, red highlighting.  Then there are 5 shades of blue from */
  818. X/* dark to light, 5 of green, 5 of red, 5 of purple, 5 white, and 3 yellow. */
  819. X/* A 5-bitplane screen is required. */
  820. unsigned short colors [32] = {
  821. X   0x000, 0x888, 0xfff, 0x00f,
  822. X   0x007, 0x009, 0x00b, 0x00d, 0x00f,
  823. X   0x070, 0x090, 0x0b0, 0x0d0, 0x0f0,
  824. X   0x700, 0x900, 0xb00, 0xd00, 0xf00,
  825. X   0x707, 0x909, 0xb0b, 0xd0d, 0xf0f,
  826. X   0x777, 0x999, 0xbbb, 0xddd, 0xfff,
  827. X   0x099, 0x0bb, 0x0dd };
  828. X
  829. X/* Structures for a custom lores screen of 5 bitplanes with a 320x200 */
  830. X/* window; use left-amiga-n and left-amiga-m to get back to workbench screen */
  831. X
  832. struct NewScreen ns = { 0L, 0L, 320L, 200L, 5L, 0, 1,
  833. X   NULL, CUSTOMSCREEN, NULL, (UBYTE *)0, NULL, NULL };
  834. X
  835. struct NewWindow nw = {
  836. X   0, 0, 320, 200, 0, 1, 0, 0, NULL, NULL,
  837. X   (UBYTE *) NULL, NULL, NULL,
  838. X   0, 0, 320, 200, CUSTOMSCREEN };
  839. X
  840. X
  841. main (argc, argv) int argc; char **argv; {
  842. X   unsigned long t[3];
  843. X
  844. X   /* Initialize random number generator using milliseconds of datestamp */
  845. X   DateStamp (t);  RangeSeed = t[2];
  846. X
  847. X   /* Initialize everything */
  848. X   grafinit ();
  849. X   init (*++argv);
  850. X
  851. X   /* Call onestep () once per step; check for mouse clicks */
  852. X   for (step=0; step<MAXSTEP; step++) {
  853. X      checkmouse ();
  854. X      onestep (); }
  855. X
  856. X   /* Loop forever until user clicks close gadget - busy waiting, sorry! */
  857. X   while (1 == 1) checkmouse (); }
  858. X
  859. X
  860. grafinit () {
  861. X   /* This is a standard kind of setup function; open all the libraries, then
  862. X   open the screen, then open the window.  If any of the calls fail, free the
  863. X   memory and return 0.  The rastport variable is kept for the drawing
  864. X   function and the colors are loaded. */
  865. X
  866. X   GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L);
  867. X   IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L);
  868. X   screen = (struct Screen *) OpenScreen (&ns);
  869. X   if (screen == NULL) goto c2;
  870. X   vp = &screen->ViewPort; nw.Screen = screen;
  871. X   nw.Title = "Tectonics";
  872. X   nw.Flags = SIMPLE_REFRESH | WINDOWCLOSE;
  873. X   nw.IDCMPFlags = MOUSEBUTTONS | CLOSEWINDOW;
  874. X   w = (struct Window *) OpenWindow (&nw);
  875. X   if (w == NULL) goto c1;
  876. X
  877. X   rp = w->RPort; SetDrMd (rp, 0);
  878. X   LoadRGB4 (vp, colors, 32);
  879. X   return (1);
  880. X
  881. X   c1: if (w) CloseWindow (w);
  882. X   c2: CloseScreen (screen);
  883. X   CloseLibrary (IntuitionBase);
  884. X   CloseLibrary (GfxBase);
  885. X   return (0); }
  886. X
  887. X
  888. grafexit () {
  889. X   /* Just close all the things that were opened, then exit(). */
  890. X   CloseWindow (w);
  891. X   CloseScreen (screen);
  892. X   CloseLibrary (IntuitionBase);
  893. X   CloseLibrary (GfxBase);
  894. X   exit (0); }
  895. X
  896. X
  897. checkmouse () {
  898. X   /* Standard event handler; loop through all the messages that have come in,
  899. X   figure out whether they are clicks or gadget hits, and reply to them.
  900. X   Outside the loop, act on the clicks.  If the CLOSEWINDOW gadget was hit,
  901. X   exit the program; if the left button was clicked anywhere, print out the
  902. X   current values of t[src] using tecst () in tec1.c. */
  903. X
  904. X   short mousecode = 0, i, j, k;
  905. X
  906. X   while ((message=(struct IntuiMessage *)GetMsg(w->UserPort))!=NULL) {
  907. X      class = message->Class; code = message->Code;
  908. X      ReplyMsg (message);
  909. X      if (code == SELECTDOWN) mousecode = 1;
  910. X      if (class == CLOSEWINDOW) mousecode = -1; }
  911. X   if (mousecode == -1) grafexit ();
  912. X   if (mousecode == 1) tecst (step % 2, DRAWMODE); }
  913. X
  914. X
  915. rnd (top) short top; { return (RangeRand (top)); }
  916. X   /* RangeRand is located in Amiga.lib */
  917. X
  918. X
  919. panic (s) char *s; { printf ("PANIC: %s\n", s); grafexit (0); }
  920. X   /* Used when some fatal inconsistency is found in the database;
  921. X   its function is to immediately free all graphics memory and exit. */
  922. X
  923. X
  924. draw (src) short src; {
  925. X   /* Takes the array m[src] and draws it on the screen, in a hopefully
  926. X   efficient way.  The function tries to make long horizontal
  927. X   patches that are all the same color.  Then they can be rendered by a
  928. X   graphics function that draws arbitrary rectangles quickly. */
  929. X
  930. X   register short i, j, k, x;
  931. X
  932. X   /* Erase the screen first by drawing a big black box */
  933. X   SetAPen (rp, 0); RectFill (rp, 14, 10, 280, 189); 
  934. X
  935. X   /* For each scan line, start at the left edge */
  936. X   for (j=0, i=0; j<YSIZE; j++, i=0) {
  937. X
  938. X      /* If the current square is not ocean, set x to its color */
  939. X      top: if ((x = t[src][i][j] >> 2) > 1) {
  940. X
  941. X         /* Go as far along to the right as you can in this color */
  942. X         k = i+1; while (((t[src][k][j] >> 2) == x) && (k < XSIZE-1)) k++;
  943. X
  944. X         /* Draw a short, wide rectangle */
  945. X         if (x > 27) x = 27; SetAPen (rp, x+4);
  946. X         RectFill (rp, 3*i + 14, 2*j + 10, 3*k + 13, 2*j + 11);
  947. X         i = k-1; }
  948. X
  949. X      /* If not at end of scanline, do more; else start next scanline */
  950. X      if (i < XSIZE-1) { i++; goto top; } } }
  951. END_OF_FILE
  952. if test 6077 -ne `wc -c <'tec-v3/ami.c'`; then
  953.     echo shar: \"'tec-v3/ami.c'\" unpacked with wrong size!
  954. fi
  955. # end of 'tec-v3/ami.c'
  956. fi
  957. if test -f 'tec-v3/unix.c' -a "${1}" != "-c" ; then 
  958.   echo shar: Will not clobber existing file \"'tec-v3/unix.c'\"
  959. else
  960. echo shar: Extracting \"'tec-v3/unix.c'\" \(1223 characters\)
  961. sed "s/^X//" >'tec-v3/unix.c' <<'END_OF_FILE'
  962. X/* This program is Copyright (c) 1990 David Allen.  It may be freely
  963. X   distributed as long as you leave my name and copyright notice on it.
  964. X   I'd really like your comments and feedback; send e-mail to
  965. X   davea@vlsi.ll.mit.edu, or send us-mail to David Allen, 10 O'Moore Ave,
  966. X   Maynard, MA 01754. */
  967. X
  968. X
  969. X/* This file substitutes for ami.c.  The function draw() is called by 
  970. X   onestep() once every DRAWEVERY steps, and it just calls tecst() in 
  971. X   tec1.c.  Most of the functions in this file are dummies; see ami.c for
  972. X   more details on what they were. */
  973. X
  974. X
  975. X#include "const.h"
  976. X#include "var.h"
  977. X#include <sys/types.h>
  978. X#include <sys/timeb.h>
  979. X
  980. extern short step;
  981. X
  982. X
  983. main (argc, argv) int argc; char **argv; { struct timeb t;
  984. X
  985. X   /* Initialize random number generator */
  986. X   ftime (&t); srandom ((int) ((t.time % 100000) + t.millitm));
  987. X
  988. X   /* Run the program */
  989. X   init (*++argv);
  990. X   for (step=0; step<MAXSTEP; step++) onestep ();
  991. X   exit (0); }
  992. X
  993. X
  994. rnd (top) short top; { return (random () % top); }
  995. X
  996. X
  997. panic (s) char *s; { printf ("PANIC: %s\n", s); exit (1); }
  998. X   /* Used when some fatal inconsistency is found in the database;
  999. X   its function is to just exit the program. */
  1000. X
  1001. X
  1002. draw (src) short src; { tecst (src, DRAWMODE); }
  1003. END_OF_FILE
  1004. if test 1223 -ne `wc -c <'tec-v3/unix.c'`; then
  1005.     echo shar: \"'tec-v3/unix.c'\" unpacked with wrong size!
  1006. fi
  1007. # end of 'tec-v3/unix.c'
  1008. fi
  1009. if test -f 'tec-v3/sun.c' -a "${1}" != "-c" ; then 
  1010.   echo shar: Will not clobber existing file \"'tec-v3/sun.c'\"
  1011. else
  1012. echo shar: Extracting \"'tec-v3/sun.c'\" \(3564 characters\)
  1013. sed "s/^X//" >'tec-v3/sun.c' <<'END_OF_FILE'
  1014. X/* This program is Copyright (c) 1990 David Allen.  It may be freely
  1015. X   distributed as long as you leave my name and copyright notice on it.
  1016. X   I'd really like your comments and feedback; send e-mail to
  1017. X   davea@vlsi.ll.mit.edu, or send us-mail to David Allen, 10 O'Moore Ave,
  1018. X   Maynard, MA 01754. */
  1019. X
  1020. X
  1021. X/* This file contains code to run tec under Un*x and Sunview.  The
  1022. X   random number code is the same as that contained in unix.c; the
  1023. X   graphics code was inspired by the example code from Sun contained
  1024. X   in /usr/share/src/sun/suntool/examples/coloredit.c and in the
  1025. X   Sunview Programmer's Guide.  I don't claim to understand it.  The
  1026. X   code in draw() is similar to that in ami.c. */
  1027. X
  1028. X#include <suntool/sunview.h>
  1029. X#include <suntool/canvas.h>
  1030. X#include <sys/types.h>
  1031. X#include <sys/timeb.h>
  1032. X#include "const.h"
  1033. X#include "var.h"
  1034. X
  1035. extern short step, phead; /* Defined in tec1.c */
  1036. extern unsigned char t[2][MAXX][MAXY]; /* Defined in tec1.c */
  1037. X
  1038. X/* These arrays define similar colors to those in ami.c; the first two
  1039. X   are black, followed by two blues, four greens, four reds, four purples,
  1040. X   four greys, and a bunch of bright whites. */
  1041. unsigned char red [] = {
  1042. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xb0, 0xd0, 0xf0,
  1043. X   0x90, 0xb0, 0xd0, 0xf0, 0x90, 0xb0, 0xd0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
  1044. X   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 };
  1045. unsigned char green [] = {
  1046. X   0x00, 0x00, 0x00, 0x00, 0x90, 0xb0, 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00,
  1047. X   0x00, 0x00, 0x00, 0x00, 0x90, 0xb0, 0xd0, 0xf0, 0x90, 0xb0, 0xd0, 0xf0,
  1048. X   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 };
  1049. unsigned char blue [] = {
  1050. X   0x00, 0x00, 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1051. X   0x90, 0xb0, 0xd0, 0xf0, 0x90, 0xb0, 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00,
  1052. X   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 };
  1053. X
  1054. X
  1055. Pixwin *pw;
  1056. struct rect tr = { 0, 0, MAXX * 6, MAXY * 6 };
  1057. X
  1058. X
  1059. tecdestroy (c, s) Notify_client c; Destroy_status s; { step = MAXSTEP; }
  1060. X/* A function called when the user tells Sunview to exit; it tells main()
  1061. that its time is up, so main can exit after finishing the current step */
  1062. X
  1063. X
  1064. main (argc, argv) int argc; char **argv; {
  1065. X   struct timeb t;
  1066. X   Frame  base_frame;
  1067. X   Canvas canvas;
  1068. X   char   cmsname[CMS_NAMESIZE];
  1069. X
  1070. X   /* Initialize random number generator */
  1071. X   ftime (&t); srandom ((int) ((t.time % 100000) + t.millitm));
  1072. X
  1073. X   /* Suntools-specific graphics setup */
  1074. X   base_frame = window_create (NULL, FRAME, FRAME_LABEL, "suntec", 
  1075. X      WIN_WIDTH, MAXX * 6, WIN_HEIGHT, MAXY*6, 0);
  1076. X   canvas = window_create (base_frame, CANVAS, WIN_WIDTH, 
  1077. X      MAXX * 6, WIN_HEIGHT, MAXY * 6, 0);
  1078. X   pw = (Pixwin *) canvas_pixwin (canvas);
  1079. X   sprintf (cmsname, "suntec%D", getpid());
  1080. X   pw_setcmsname (pw, cmsname);
  1081. X   pw_putcolormap (pw, 0, 32, red, green, blue);
  1082. X   notify_interpose_destroy_func (base_frame, tecdestroy);
  1083. X   window_set (base_frame, WIN_SHOW, TRUE, 0);
  1084. X
  1085. X   /* Run the program, checking with Sunview after each step */
  1086. X   init (*++argv);
  1087. X   for (step=0; step<MAXSTEP; step++) { onestep (); notify_dispatch (); }
  1088. X   exit (0); }
  1089. X
  1090. X
  1091. rnd (top) short top; { return (random () % top); }
  1092. X
  1093. X
  1094. panic (s) char *s; { printf ("PANIC: %s\n", s); exit (1); }
  1095. X
  1096. X
  1097. draw (src) short src; {
  1098. X   register short i, j, k, x;
  1099. X
  1100. X   pw_lock (pw, &tr);
  1101. X   for (j=0, i=0; j<YSIZE; j++, i=0) {
  1102. X      top: x = t[src][i][j] >> 2;
  1103. X      k = i+1; while (((t[src][k][j] >> 2) == x) && (k < XSIZE-1)) k++;
  1104. X      pw_rop (pw, i*6, j*6, (k-i)*6, 6, PIX_SRC | PIX_COLOR (x), NULL, 0, 0);
  1105. X      i = k-1;
  1106. X      if (i < XSIZE-1) { i++; goto top; } }
  1107. X   pw_unlock (pw); }
  1108. END_OF_FILE
  1109. if test 3564 -ne `wc -c <'tec-v3/sun.c'`; then
  1110.     echo shar: \"'tec-v3/sun.c'\" unpacked with wrong size!
  1111. fi
  1112. # end of 'tec-v3/sun.c'
  1113. fi
  1114. if test -f 'tec-v3/const.h' -a "${1}" != "-c" ; then 
  1115.   echo shar: Will not clobber existing file \"'tec-v3/const.h'\"
  1116. else
  1117. echo shar: Extracting \"'tec-v3/const.h'\" \(515 characters\)
  1118. sed "s/^X//" >'tec-v3/const.h' <<'END_OF_FILE'
  1119. X/* This file contains some defines for maximum array dimensions, as well
  1120. as the one structure definition needed and some miscellaneous declarations */
  1121. X
  1122. X#define MAXX 90
  1123. X#define MAXY 90
  1124. X#define MAXSPLINTER 10
  1125. X#define MAXFRAG 100
  1126. X#define MAXPLATE 40
  1127. X#define REALSCALE 100
  1128. X#define DRAWMODE_NONE 0
  1129. X#define DRAWMODE_GENERIC 1
  1130. X#define DRAWMODE_TEXT 2
  1131. X#define DRAWMODE_GRAY 3
  1132. X
  1133. X#define ABS(xx) ((xx < 0) ? -xx: xx)
  1134. X
  1135. extern double cos(), sin(), sqrt();
  1136. X
  1137. struct plate { short dx, dy, odx, ody, rx, ry, age, area, id, next; };
  1138. END_OF_FILE
  1139. if test 515 -ne `wc -c <'tec-v3/const.h'`; then
  1140.     echo shar: \"'tec-v3/const.h'\" unpacked with wrong size!
  1141. fi
  1142. # end of 'tec-v3/const.h'
  1143. fi
  1144. if test -f 'tec-v3/tec3.c' -a "${1}" != "-c" ; then 
  1145.   echo shar: Will not clobber existing file \"'tec-v3/tec3.c'\"
  1146. else
  1147. echo shar: Extracting \"'tec-v3/tec3.c'\" \(7136 characters\)
  1148. sed "s/^X//" >'tec-v3/tec3.c' <<'END_OF_FILE'
  1149. X/* This program is Copyright (c) 1990 David Allen.  It may be freely
  1150. X   distributed as long as you leave my name and copyright notice on it.
  1151. X   I'd really like your comments and feedback; send e-mail to
  1152. X   davea@vlsi.ll.mit.edu, or send us-mail to David Allen, 10 O'Moore Ave,
  1153. X   Maynard, MA 01754. */
  1154. X
  1155. X/* This file contains the function getparams(), which reads parameters
  1156. X   from an input file.  The default values for all of the parameters are
  1157. X   set here as well. */
  1158. X
  1159. X#include "const.h"
  1160. X
  1161. X/* These are all of the adjustable parameters; they are completely
  1162. X   described in the file params.doc. */
  1163. X
  1164. long XSIZE = 90,    YSIZE = 90,    MAXSTEP = 100;
  1165. long MAXBUMP = 50,    BUMPTOL = 50;
  1166. long DRAWEVERY = 1,    BLOBLEVEL = 64,    DRAWMODE = DRAWMODE_GENERIC;
  1167. long ZINIT = 22,    ZSUBSUME = 16,    ZCOAST = 16;
  1168. long ZSHELF = 8,    ZMOUNTAIN = 48;
  1169. long RIFTPCT = 40,    DOERODE = 1,    ERODERND = 4;
  1170. long MAXCTRTRY = 50,    RIFTDIST = 5,    BENDEVERY = 6;
  1171. long BENDBY = 50,    SPEEDRNG = 300,    SPEEDBASE = 200;
  1172. X
  1173. double MR [] = { 1.0,1.0,1.0,0.7,0.4,0.1,-0.2,-0.5,-0.8,-1.0 };
  1174. long MAXLIFE = 10; /* Length of MR vector */
  1175. X
  1176. X
  1177. X#include <stdio.h>
  1178. XFILE *fp;
  1179. X
  1180. X/* The input is handled by one function, gettoken, which returns one
  1181. X   of the following codes each time it is called. */
  1182. X#define TOK_EOF 0
  1183. X#define TOK_OPEN 1
  1184. X#define TOK_CLOSE 2
  1185. X#define TOK_WORD 3
  1186. X
  1187. short linecount = 1; /* So error messages can refer to a line number */
  1188. char getbuf[256]; /* Storage for each token as it is being read */
  1189. X
  1190. X/* A shorthand for string comparison */
  1191. X#define CMP(x) (!strcmp (getbuf, x))
  1192. X
  1193. extern float atof ();
  1194. X
  1195. X
  1196. getparams (s) char *s; { 
  1197. X   /* This function is called by init() with one parameter, a string which
  1198. X   comes directly off the command line.  If the string is null, getparams()
  1199. X   is never called; otherwise, a "-" means standard input, while any other
  1200. X   text is treated as a filename and handed to fopen().  If the file doesn't
  1201. X   exist the program exits via panic().  Once the file is open, the function
  1202. X   expects to find paren-delimited pairs of (name value).  Value could be
  1203. X   a vector, like (name (val1 val2)).  After a name is found, there is
  1204. X   a very simple test, one string comparison per adjustable parameter,
  1205. X   to see if the name is recognized.  If unrecognized, the program panics.
  1206. X   If it is a recognized name, the appropriate parsing function, with the
  1207. X   appropriate parameters, is called.  There are three parsing functions,
  1208. X   getdim(), getlng(), and getdvec(). */
  1209. X
  1210. X   short x, i, j;
  1211. X
  1212. X   if (!strcmp (s, "-")) fp = stdin;
  1213. X   else { fp = fopen (s, "r"); if (!fp) panic ("Can't find input file"); }
  1214. X   
  1215. X   while ((x = gettoken (getbuf)) != TOK_EOF) {
  1216. X      if (x != TOK_OPEN) geterr ("expected open paren");
  1217. X      if (gettoken (getbuf) != TOK_WORD) geterr ("expected parameter name");
  1218. X      if      CMP ("XSIZE")    getdim  (&XSIZE);
  1219. X      else if CMP ("YSIZE")    getdim  (&YSIZE);
  1220. X      else if CMP ("MOVERATE")    getdvec (&MAXLIFE, MR);
  1221. X      else if CMP ("MAXSTEP")    getlng  (&MAXSTEP);
  1222. X      else if CMP ("MAXBUMP")    getlng  (&MAXBUMP);
  1223. X      else if CMP ("BUMPTOL")    getlng  (&BUMPTOL);
  1224. X      else if CMP ("DRAWEVERY")    getlng  (&DRAWEVERY);
  1225. X      else if CMP ("DRAWMODE")    getlng  (&DRAWMODE);
  1226. X      else if CMP ("BLOBLEVEL")    getlng  (&BLOBLEVEL);
  1227. X      else if CMP ("ZINIT")    getlng  (&ZINIT);
  1228. X      else if CMP ("ZSUBSUME")    getlng  (&ZSUBSUME);
  1229. X      else if CMP ("ZCOAST")    getlng  (&ZCOAST);
  1230. X      else if CMP ("ZSHELF")    getlng  (&ZSHELF);
  1231. X      else if CMP ("ZMOUNTAIN")    getlng  (&ZMOUNTAIN);
  1232. X      else if CMP ("RIFTPCT")    getlng  (&RIFTPCT);
  1233. X      else if CMP ("DOERODE")    getlng  (&DOERODE);
  1234. X      else if CMP ("ERODERND")    getlng  (&ERODERND);
  1235. X      else if CMP ("MAXCTRTRY")    getlng  (&MAXCTRTRY);
  1236. X      else if CMP ("RIFTDIST")    getlng  (&RIFTDIST);
  1237. X      else if CMP ("BENDEVERY")    getlng  (&BENDEVERY);
  1238. X      else if CMP ("BENDBY")    getlng  (&BENDBY);
  1239. X      else if CMP ("SPEEDBASE")    getlng  (&SPEEDBASE);
  1240. X      else if CMP ("SPEEDRNG")    getlng  (&SPEEDRNG);
  1241. X      else geterr ("unknown parameter name");
  1242. X      if (gettoken (getbuf) != TOK_CLOSE) geterr ("expected close paren"); } }
  1243. X
  1244. X
  1245. gettoken (s) char *s; {
  1246. X   /* This is the only function which actually reads from the file.  It
  1247. X   maintains a one-character unget buffer.  It ignores initial whitespace,
  1248. X   but counts newlines to maintain an accurate linecount.  Open or close
  1249. X   parentheses count as tokens, and so does any amount of text with no
  1250. X   whitespace or parens.  The return code indicates whether end of file,
  1251. X   open paren, close paren, or a word were found.  If a word was found, it
  1252. X   is copied into the string pointed to by s.  When a word is found, the
  1253. X   character which terminated the word (whitespace, EOF or paren) is put
  1254. X   into the unget buffer to be read the next time gettoken() is called. */
  1255. X
  1256. X   static char buf = 0; char c;
  1257. X
  1258. X   white: if (buf) { c = buf; buf = 0; } else c = getc (fp);
  1259. X   switch (c) {
  1260. X      case '\n': linecount++;
  1261. X      case '\t': 
  1262. X      case ' ' : goto white; break;
  1263. X      case EOF : return (TOK_EOF); break;
  1264. X      case '(' : return (TOK_OPEN); break;
  1265. X      case ')' : return (TOK_CLOSE); break; }
  1266. X   text: if ((c==' ')||(c=='\t')||(c=='\n')||(c=='(')||(c==')')||(c==EOF)) {
  1267. X      buf = c; *s = 0; return (TOK_WORD); }
  1268. X   else { *s++ = c; c = getc (fp); goto text; } }
  1269. X
  1270. X
  1271. geterr (s) char *s; {
  1272. X   /* Calls machine-specific panic() with nicely formatted message */
  1273. X   sprintf (getbuf, "Parameter error: %s in line %d", s, linecount);
  1274. X   panic (getbuf); }
  1275. X
  1276. X
  1277. getlng (x) long *x; {
  1278. X   /* Called after reading a name associated with a single long,
  1279. X   this function just reads a long from the input file and uses atoi()
  1280. X   to convert it into a long, stored at the address passed in.   Note
  1281. X   that any text, including a string or a real, will be read; no type
  1282. X   checking is performed. */
  1283. X
  1284. X   if (gettoken (getbuf) != TOK_WORD) geterr ("expected long");
  1285. X   *x = atoi (getbuf); }
  1286. X
  1287. X
  1288. getdim (x) long *x; {
  1289. X   /* Called right after reading a name associated with an array bound,
  1290. X   this function reads one long from the input file; if the value is
  1291. X   greater than the default value assigned above, the user is trying
  1292. X   to exceed a compiled-in limit.  That's an error. */
  1293. X
  1294. X   long y;
  1295. X
  1296. X   if (gettoken (getbuf) != TOK_WORD) geterr ("expected long");
  1297. X   y = atoi (getbuf);
  1298. X   if (y > *x) geterr ("dimension exceeds reserved space");
  1299. X   *x = y; }
  1300. X
  1301. X
  1302. getdvec (dim, v) long *dim; double *v; {
  1303. X   /* Called right after reading a name associated with a one-dimensional
  1304. X   array of doubles, this function expects to find a list of doubles
  1305. X   starting with an open paren and ended by a closing paren.  The parameter
  1306. X   dim contains the compiled-in array limit; if the input file contains
  1307. X   more than this number of entries, the function complains.  No type checking
  1308. X   is done; atof() is used to convert any text to a double.  On exit, the
  1309. X   dimension is set to the correct value. */
  1310. X
  1311. X   short x; long i = 0;
  1312. X
  1313. X   if (gettoken (getbuf) != TOK_OPEN)
  1314. X      geterr ("expected open paren");
  1315. X   while ((x = gettoken (getbuf)) == TOK_WORD) {
  1316. X      if (i == *dim) geterr ("vector is too long");
  1317. X      v[i++] = atof (getbuf); }
  1318. X   if (x != TOK_CLOSE) geterr ("expected close paren");
  1319. X   *dim = i; } 
  1320. END_OF_FILE
  1321. if test 7136 -ne `wc -c <'tec-v3/tec3.c'`; then
  1322.     echo shar: \"'tec-v3/tec3.c'\" unpacked with wrong size!
  1323. fi
  1324. # end of 'tec-v3/tec3.c'
  1325. fi
  1326. echo shar: End of shell archive.
  1327. exit 0
  1328.  
  1329.