home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-025 < prev    next >
Text File  |  2010-09-21  |  47KB  |  1,319 lines

  1. Received-Date: Tue, 10 May 1994 17:15:15 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-025, resend
  4. To: csmp-digest@ens.fr
  5. Date: Tue, 10 May 94 17:15:09 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 28
  10.  
  11.  
  12. Hi,
  13. Issue 25 of the digest contains some binhexed files, which reportedly
  14. caused some dumb mailers to extract the binhex codes and delete the rest.
  15. I have removed the faulty thread; here is a "clean" digest.
  16.  
  17. Francois
  18. pottier@dmi.ens.fr
  19.  
  20. ------
  21.  
  22. C.S.M.P. Digest             Tue, 10 May 94       Volume 3 : Issue 25
  23.  
  24. Today's Topics:
  25.  
  26.         CodeWarrior GOLD DR-2 - Can't seem to generate fast FP code
  27.         Determining if user is on a network
  28.         Sample Think C AE Code
  29.         drawing arrowheads
  30.         writing an INIT... a few questions
  31.  
  32.  
  33.  
  34. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  35. (pottier@clipper.ens.fr).
  36.  
  37. The digest is a collection of article threads from the internet newsgroup
  38. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  39. regularly and want an archive of the discussions.  If you don't know what a
  40. newsgroup is, you probably don't have access to it.  Ask your systems
  41. administrator(s) for details.  If you don't have access to news, you may
  42. still be able to post messages to the group by using a mail server like
  43. anon.penet.fi (mail help@anon.penet.fi for more information).
  44.  
  45. Each issue of the digest contains one or more sets of articles (called
  46. threads), with each set corresponding to a 'discussion' of a particular
  47. subject.  The articles are not edited; all articles included in this digest
  48. are in their original posted form (as received by our news server at
  49. nef.ens.fr).  Article threads are not added to the digest until the last
  50. article added to the thread is at least two weeks old (this is to ensure that
  51. the thread is dead before adding it to the digest).  Article threads that
  52. consist of only one message are generally not included in the digest.
  53.  
  54. The digest is officially distributed by two means, by email and ftp.
  55.  
  56. If you want to receive the digest by mail, send email to listserv@ens.fr
  57. with no subject and one of the following commands as body:
  58.     help                        Sends you a summary of commands
  59.     subscribe csmp-digest Your Name    Adds you to the mailing list
  60.     signoff csmp-digest            Removes you from the list
  61. Once you have subscribed, you will automatically receive each new
  62. issue as it is created.
  63.  
  64. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  65. Questions related to the ftp site should be directed to
  66. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  67. digest are available there.
  68.  
  69. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  70.  
  71.  
  72. -------------------------------------------------------
  73.  
  74. >From bcorrie@csr.UVic.CA (Brian  Corrie)
  75. Subject: CodeWarrior GOLD DR-2 - Can't seem to generate fast FP code
  76. Date: 15 Apr 94 20:51:55 GMT
  77. Organization: University of Victoria
  78.  
  79. G'day,
  80.  
  81. I just recently got my CodeWarrior Gold. I wrote a simple application that
  82. does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  83. to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  84. 10 at work. Timings below:
  85.  
  86. RS6000         2.4 seconds
  87. SPARC10     4.8 seconds
  88. Quadra840AV    40 seconds
  89. PowerMac 6100    53 seconds???????
  90.  
  91. Now obviously this code is running in emulation mode (at least I hope so
  92. or I will be a bit bummed out 8-). The weird thing is that I CAN NOT get
  93. this to change. I am running the PPC version of the compiler, I set the
  94. preferences to what I think they should be to generate native PowerPC code,
  95. use what I think are the right libraries, and lo and behold, it runs slow.
  96.  
  97. Now I am probably missing something obvious, and you are probably saying
  98. RTFM, but really, I have spent the last two days trying to figure this out!
  99. Reading the manual, talking to someone who has a bit more Mac expereince
  100. than I do, etc. Still no luck. What am I doing wrong???? Any ideas?
  101. Is there something obvious that I have to do. Did I install things
  102. incorrectly? Is there a special library I need to use to take advantage
  103. of the PPC floating point hardware? ARGGGHHHH. I want to say "look how
  104. fast my machine is" but I can't at the moment!!!!!
  105.  
  106. Any and all pointers, even those exposing my stupidity, are welcome.
  107.  
  108. Cheers,
  109.  
  110.     Brian
  111.  
  112.  
  113. --
  114.                   Brian Corrie (bcorrie@csr.uvic.ca)
  115. Under the most rigorously controlled conditions of pressure, temperature,
  116. volume, humidity and other variables, the organism will do as it damn well
  117. pleases. Sounds like some of the code I have written......  8-)
  118.  
  119. +++++++++++++++++++++++++++
  120.  
  121. >From usenet@lowry.eche.ualberta.ca (Brian Lowry)
  122. Date: 15 Apr 1994 22:12:20 GMT
  123. Organization: Chem Eng - Univ of Alberta
  124.  
  125. In article <bcorrie.766443115@tara>, bcorrie@csr.UVic.CA (Brian  Corrie)
  126. wrote:
  127.  
  128. > I just recently got my CodeWarrior Gold. I wrote a simple application that
  129. > does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  130. > to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  131. > 10 at work. Timings below:
  132. > RS6000         2.4 seconds
  133. > SPARC10     4.8 seconds
  134. > Quadra840AV    40 seconds
  135. > PowerMac 6100    53 seconds???????
  136.  
  137.   Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  138. speed did you expect?  Obviously you're calling SANE routines while the IBM
  139. is calling efficent PPC routines.  You'd probably see a speed improvement
  140. with even relatively inefficient sin/cos/sqrt algorithms.
  141.  
  142. -- 
  143.  
  144. Brian Lowry
  145.  
  146. +++++++++++++++++++++++++++
  147.  
  148. >From bcorrie@csr.UVic.CA (Brian  Corrie)
  149. Date: 16 Apr 94 00:20:22 GMT
  150. Organization: University of Victoria
  151.  
  152. usenet@lowry.eche.ualberta.ca (Brian Lowry) writes:
  153. >In article <bcorrie.766443115@tara>, bcorrie@csr.UVic.CA (Brian  Corrie)
  154. >wrote:
  155.  
  156. >> I just recently got my CodeWarrior Gold. I wrote a simple application that
  157. >> does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  158. >> to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  159. >> 10 at work. Timings below:
  160. >> 
  161. >> RS6000         2.4 seconds
  162. >> SPARC10     4.8 seconds
  163. >> Quadra840AV    40 seconds
  164. >> PowerMac 6100    53 seconds???????
  165.  
  166. >  Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  167. >speed did you expect?  Obviously you're calling SANE routines while the IBM
  168. >is calling efficent PPC routines.  You'd probably see a speed improvement
  169. >with even relatively inefficient sin/cos/sqrt algorithms.
  170.  
  171. Care to elaborate a bit on that? Like I said, I am not a Mac programmer
  172. and don't know a lot about SANE, but it doesn't make much sense that
  173. my PowerMac is SLOWER than a Quadra840 when the code on the PowerMac
  174. is native PowerPC code. Surely the sin and cos functions are implemented
  175. using the native PowerPC code and isn't being implemented as emmulated
  176. 020 code!?!?!?
  177.  
  178. How does one expect to take advantage of the floating point speed of the
  179. PowerPC architecture if basic mathematical functions like sin, cos, and
  180. sqrt are not implemented natively. Seems rather silly to me. Am I out to
  181. lunch on this one???? Is their not a native implementation of SANE? I was
  182. expecting to get an execution time of below ten seconds based on what I
  183. have read about the PowerPC specs.
  184.  
  185. Any insights. Can someone set me straight, this doesn't make sense to me.
  186.  
  187.     Brian (stressed about his slow PowerMac) Corrie
  188.  
  189.  
  190.  
  191.     Brian
  192.  
  193. --
  194.                   Brian Corrie (bcorrie@csr.uvic.ca)
  195. Under the most rigorously controlled conditions of pressure, temperature,
  196. volume, humidity and other variables, the organism will do as it damn well
  197. pleases. Sounds like some of the code I have written......  8-)
  198.  
  199. +++++++++++++++++++++++++++
  200.  
  201. >From bcorrie@csr.UVic.CA (Brian  Corrie)
  202. Date: 16 Apr 94 01:18:07 GMT
  203. Organization: University of Victoria
  204.  
  205. Dave Falkenburg <falken@apple.com> writes:
  206. >In article <usenet-150494160853@lowry.eche.ualberta.ca> Brian Lowry,
  207. >usenet@lowry.eche.ualberta.ca writes:
  208. Brian Corrie originally wrote:
  209. >>> I just recently got my CodeWarrior Gold. I wrote a simple application that
  210. >>> does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  211. >>> to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  212. >>> 10 at work. Timings below:
  213. >>> 
  214. >>> RS6000         2.4 seconds
  215. >>> SPARC10     4.8 seconds
  216. >>> Quadra840AV    40 seconds
  217. >>> PowerMac 6100    53 seconds???????
  218. >>
  219. >>  Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  220. >>speed did you expect?  Obviously you're calling SANE routines while the IBM
  221. >>is calling efficent PPC routines.  You'd probably see a speed improvement
  222. >>with even relatively inefficient sin/cos/sqrt algorithms.
  223. >>
  224. >>-- 
  225. >>
  226. >>Brian Lowry
  227.  
  228. >Remember that MW DR/2 doesn't generate really optimal code (yet). You're not
  229. >calling SANE, you are just executing non-optimzied code on a RISC machine.
  230.  
  231. I realize that the code optimization isn't the best, but surely running 
  232. native code on a PowerPC should run faster than a Quadra840 with a
  233. 68881?2.  If not, I want my money back!!!! Seriously, if the sin, cos,
  234. sqrt are running as native code and not being emulated as 020 through
  235. SANE or some such bizarre twist, then why can't the PowerPC beat a
  236. Quadra 840. Even if I turn off optimization and turn on debugging
  237. and profiling on the SPARC10 I get a run time of 7.9 seconds. Still a
  238. ton and a half less than 53. We are talking an order of magnitude
  239. difference when I would expect them to be in the same ball park.
  240.  
  241. Almost all 3D graphics use sin, cos, and sqrt extensively. How can all
  242. those native 3D programs claim massive speedups over high end Quadras
  243. when I am getting worse performance!?! It just don't make sense mon,
  244. I am still convinced that I am doing something ridiculously stoopid.
  245. Please, someone just tell me what it is!  8-)
  246.  
  247. >If you compile on AIX with "-lm" and ship the code back over to your PowerMac
  248. >you should see VERY nice performance improvements.
  249.  
  250. >Also: Were you using the Apple mathlib?
  251.  
  252. I was using the MathLib that comes with the CW DR/2 release, whatever
  253. that is. It seems to me that I must be using the wrong library, but
  254. its beyond me which one I should be using.... 
  255.  
  256. I will play some more with the compiler tonight and report further on
  257. this "drama"
  258.  
  259. Cheers,
  260.  
  261.     Brian
  262.  
  263. --
  264.                   Brian Corrie (bcorrie@csr.uvic.ca)
  265. Under the most rigorously controlled conditions of pressure, temperature,
  266. volume, humidity and other variables, the organism will do as it damn well
  267. pleases. Sounds like some of the code I have written......  8-)
  268.  
  269. +++++++++++++++++++++++++++
  270.  
  271. >From Chuck Browne <chuck@molecule.physics.drexel.edu>
  272. Date: Sat, 16 Apr 1994 02:37:14 GMT
  273. Organization: Drexel Univ. Physics
  274.  
  275. In article <usenet-150494160853@lowry.eche.ualberta.ca> Brian Lowry,
  276. usenet@lowry.eche.ualberta.ca writes:
  277. >  Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  278. >speed did you expect?  Obviously you're calling SANE routines while the
  279. IBM
  280. >is calling efficent PPC routines.  You'd probably see a speed improvement
  281. >with even relatively inefficient sin/cos/sqrt algorithms.
  282.  
  283. Well, in the MW manual, it says about SANE for the PowerMacs:
  284.  
  285. "SANE is dead." 
  286.  
  287. Are you using the math library with <fp.h>? I believe that is what you
  288. should be using. Not that I would really know, as I don't have a PowerMac
  289. (although I will be able to test some calcs next week on one), but 
  290. since when has not knowing what you're talking about been a crime on 
  291. usenet? :-)
  292.  
  293. Anyway, I don't know if you're using the ANSI libs. They're probably 
  294. slower than the math library...
  295.  
  296. Chuck
  297.  
  298. +++++++++++++++++++++++++++
  299.  
  300. >From Dave Falkenburg <falken@apple.com>
  301. Date: Fri, 15 Apr 1994 23:58:13 GMT
  302. Organization: Apple Computer, Inc.
  303.  
  304. In article <usenet-150494160853@lowry.eche.ualberta.ca> Brian Lowry,
  305. usenet@lowry.eche.ualberta.ca writes:
  306. >> I just recently got my CodeWarrior Gold. I wrote a simple application
  307. that
  308. >> does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  309. >> to test the speed of my PowerMac 6100/60 compared to an RS6000 and
  310. SPARC
  311. >> 10 at work. Timings below:
  312. >> 
  313. >> RS6000         2.4 seconds
  314. >> SPARC10     4.8 seconds
  315. >> Quadra840AV    40 seconds
  316. >> PowerMac 6100    53 seconds???????
  317. >
  318. >  Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  319. >speed did you expect?  Obviously you're calling SANE routines while the
  320. IBM
  321. >is calling efficent PPC routines.  You'd probably see a speed improvement
  322. >with even relatively inefficient sin/cos/sqrt algorithms.
  323. >
  324. >-- 
  325. >
  326. >Brian Lowry
  327.  
  328. Remember that MW DR/2 doesn't generate really optimal code (yet). You're
  329. not
  330. calling SANE, you are just executing non-optimzied code on a RISC machine.
  331.  
  332. If you compile on AIX with "-lm" and ship the code back over to your
  333. PowerMac
  334. you should see VERY nice performance improvements.
  335.  
  336. Also: Were you using the Apple mathlib?
  337.  
  338. -Dave Falkenburg
  339. -Apple Computer, Inc.
  340.  
  341. +++++++++++++++++++++++++++
  342.  
  343. >From rang@winternet.mpls.mn.us (Anton Rang)
  344. Date: 16 Apr 1994 01:56:31 GMT
  345. Organization: Minnesota Angsters
  346.  
  347. In article <bcorrie.766443115@tara> bcorrie@csr.UVic.CA (Brian  Corrie) writes:
  348. >I just recently got my CodeWarrior Gold. I wrote a simple application that
  349. >does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  350. >to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  351. >10 at work. Timings below:
  352.  
  353.   Aha!  You have discovered Apple's Incredibly Inefficient Trig
  354. Functions.  They're so bad that, as you discovered, the 840AV is
  355. faster.  The cure is to write your own, snarf the library from the
  356. RS/6000 (probably legal issues involved), or curse Apple until they
  357. fix it.  (Hmm.)
  358.  
  359.   Check the timing of add/multiply and you'll see it's way faster than
  360. any 68000.  So if Apple even used the same algorithms that the 68882
  361. uses (or heck, even SANE) it would be faster.  :(
  362. --
  363. Anton Rang (rang@winternet.mpls.mn.us)
  364.  
  365. +++++++++++++++++++++++++++
  366.  
  367. >From johnmce@world.std.com (John McEnerney)
  368. Date: Sat, 16 Apr 1994 07:16:19 GMT
  369. Organization: The World Public Access UNIX, Brookline, MA
  370.  
  371. usenet@lowry.eche.ualberta.ca (Brian Lowry) writes:
  372.  
  373. >In article <bcorrie.766443115@tara>, bcorrie@csr.UVic.CA (Brian  Corrie)
  374. >wrote:
  375.  
  376. >> I just recently got my CodeWarrior Gold. I wrote a simple application that
  377. >> does a bunch of floating point calculations (sin, cos, sqrt, *, / etc.)
  378. >> to test the speed of my PowerMac 6100/60 compared to an RS6000 and SPARC
  379. >> 10 at work. Timings below:
  380. >> 
  381. >> RS6000         2.4 seconds
  382. >> SPARC10     4.8 seconds
  383. >> Quadra840AV    40 seconds
  384. >> PowerMac 6100    53 seconds???????
  385.  
  386. >  Since sin, cos, and sqrt aren't supported by the PPC601, what sort of
  387. >speed did you expect?  Obviously you're calling SANE routines while the IBM
  388. >is calling efficent PPC routines.  You'd probably see a speed improvement
  389. >with even relatively inefficient sin/cos/sqrt algorithms.
  390.  
  391. This should not be true. When using sin(), cos() etc. one normally links 
  392. against the MathLib shared library from Apple. These routines were 
  393. supposedly coded for high performance.
  394.  
  395. -- John McEnerney, Metrowerks PowerPC Product Architect
  396.  
  397.  
  398. +++++++++++++++++++++++++++
  399.  
  400. >From jwbaxter@olympus.net (John W. Baxter)
  401. Date: Fri, 15 Apr 1994 20:36:24 -0700
  402. Organization: Internet for the Olympic Peninsula
  403.  
  404. In article <bcorrie.766459087@tara>, bcorrie@csr.UVic.CA (Brian  Corrie)
  405. wrote:
  406.  
  407. > I was using the MathLib that comes with the CW DR/2 release, whatever
  408. > that is. It seems to me that I must be using the wrong library, but
  409. > its beyond me which one I should be using.... 
  410.  
  411. That should be the right one (and should actually mean that you're running
  412. the ROM-based fragment).
  413.  
  414. What data type are you using for your floating point?  float and double are
  415. good (supported, except for some operations, by the chip)...long double is
  416. not (done in software).  If you are using long double (and even more if you
  417. are using one of the extended types left over from the old days), I'd
  418. suggest you switch to double_t.  When compiled for PPC, that gives you
  419. double (64-bit); when compiled for 68K Mac, it gives you long double (80 or
  420. 96 bit depending upon FPU setting).  On PPC compiles, long double is the
  421. [somewhat strange] 128-bit format.
  422.  
  423. -- 
  424. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  425.    jwbaxter@pt.olympus.net
  426.  
  427. +++++++++++++++++++++++++++
  428.  
  429. >From somogyi@macuser.ziff.com (Stephan Somogyi)
  430. Date: Sat, 16 Apr 1994 17:24:31 GMT
  431. Organization: MacUser Magazine US
  432.  
  433. In article <CoCC78.D3r@world.std.com>, johnmce@world.std.com (John
  434. McEnerney) wrote:
  435.  
  436. > When using sin(), cos() etc. one normally links  against the MathLib
  437. > shared library from Apple. These routines were  supposedly coded for
  438. > high performance.
  439.  
  440. A fellow from Apple said in the PowerPC Talk area on AppleLink that they
  441. are aware of MathLib's bad trig performance and are working on resolving
  442. the problem. For the time being, the prudent thing to do seems to be to
  443. get another trig implementation.
  444.  
  445. __________________________________________________________________________
  446. Stephan Somogyi                 "Davidian Inside"                  MacUser
  447.  
  448. +++++++++++++++++++++++++++
  449.  
  450. >From squeegee@world.std.com (Stephen C. Gilardi)
  451. Date: Sat, 16 Apr 1994 20:20:08 GMT
  452. Organization: SQ Software via The World Public Access UNIX, Brookline, MA
  453.  
  454. oliver@psy.fsu.edu (Bill Oliver) writes:
  455.  
  456. >I've also been looking at the floating point performance of CodeWarrior
  457. >C code on my Centris 660AV Mac. I've compiled a test program using the
  458. >various ANSI881 libraries with what I believe are the appropriate
  459. >compiler options. The program takes *twice* as long to exectute than
  460. >the same program compiled on a NeXT Cube, which has the same CPU (25MHz
  461. >68040).Obviously, I must be doing something wrong. Are there any
  462. >example programs available (with projects) that illustrate how to get
  463. >fast FP code from CW?
  464.  
  465. If you just include math.h, then all trig functions, logs, etc. will
  466. be calculated using SANE.  If you #define __FASTMATH__ and/or
  467. __HYBRIDMATH__ before include math.h, then the 68881 will be used
  468. directly for those functions (at the expense of the extra error
  469. checking and control which you get with SANE).
  470.  
  471. However, I believe there is a bug in the DR/2 math.h which makes those
  472. #defines not have the desired effect.
  473.  
  474. Here's a portion of the bug report I sent:
  475.  
  476. [I think math.h is wrong...]
  477.  
  478. Here's how I think the relevant portion of math.h should read:
  479.  
  480. #ifdef __FASTMATH__
  481. #define log(x)        _log(x)
  482. #define log10(x)    _log10(x)
  483. #endif
  484.  
  485. #ifdef    __HYBRIDMATH__
  486. #define sin(x)        _sin(x)
  487. #define cos(x)        _cos(x)
  488. #define tan(x)        _tan(x)
  489. #define asin(x)        _asin(x)
  490. #define acos(x)        _acos(x)
  491. #define atan(x)        _atan(x)
  492. #define sinh(x)        _sinh(x)
  493. #define cosh(x)        _cosh(x)
  494. #define tanh(x)        _tanh(x)
  495. #define exp(x)        _exp(x)
  496. #define sqrt(x)        _sqrt(x)
  497. #define fabs(x)        _fabs(x)
  498. #define fmod(x,y)    _fmod((x),(y))
  499. #define ldexp(x,n)    _ldexp((x),(n))
  500. #endif
  501.  
  502. I believe that the underscores indicate direct calls to the 68881.
  503. With it defined as I suggest, the MATH macros work as documented.
  504.  
  505. --Steve
  506.  
  507. +++++++++++++++++++++++++++
  508.  
  509. >From rang@winternet.mpls.mn.us (Anton Rang)
  510. Date: 17 Apr 1994 02:39:15 GMT
  511. Organization: Minnesota Angsters
  512.  
  513. In article <CoCC78.D3r@world.std.com> johnmce@world.std.com (John McEnerney) writes:
  514. >This should not be true. When using sin(), cos() etc. one normally links 
  515. >against the MathLib shared library from Apple. These routines were 
  516. >supposedly coded for high performance.
  517.  
  518.   Hmm.  Well, they ought to be, but another poster earlier (on
  519. c.s.powerpc) gave me a benchmark to run on the 8100/80, and it
  520. indicated that sin/cos are *very* slow compared to almost any other
  521. implementation.  A few selected rows from the table he sent --
  522.  
  523. Machine                    MFLOPS        FLOPS/sin()
  524. - -----                    ------        -----------
  525.  
  526. Cray-2                                   45.06             18.43
  527. PowerMac 8100/80 (Apple SDK beta)        37.50            1223.88
  528. IBM RS6000/550                 22.22              25.89
  529. PowerMac 8100/80 (Metrowerks 1.0a1)      14.28             464.98
  530. IBM RS6000/320H                     13.51              28.15
  531.  
  532. The MFLOPS is calculated in a tight loop where the multiply-add can be
  533. used to advantage, thus the relatively high performance.  The compiler
  534. makes a considerable difference here due primarily to loop unrolling,
  535. which allows better instruction scheduling, and the use of the
  536. load-with-update instructions by the Apple SDK compiler.
  537.  
  538. FLOPS/sin() is the relative performance of a loop which calls sin()
  539. instead of doing multiplication/addition.  Note the incredibly slow
  540. performance....
  541. --
  542. Anton Rang (rang@winternet.mpls.mn.us)
  543.  
  544. +++++++++++++++++++++++++++
  545.  
  546. >From Dave Falkenburg <falken@apple.com>
  547. Date: Mon, 18 Apr 1994 21:08:56 GMT
  548. Organization: Apple Computer, Inc.
  549.  
  550. In article <CoCC78.D3r@world.std.com> John McEnerney,
  551. johnmce@world.std.com writes:
  552. >This should not be true. When using sin(), cos() etc. one normally links 
  553. >against the MathLib shared library from Apple. These routines were 
  554. >supposedly coded for high performance.
  555. >
  556. >-- John McEnerney, Metrowerks PowerPC Product Architect
  557.  
  558. My bet is that they are coded to be highly accurate, so that when someone
  559. decides to build a bridge or an airplane using a Mac it won't fail due to
  560. a rounding error.
  561.  
  562. Lawyers are great, aren't they?
  563.  
  564. BTW: One of the NuCalc guys typed up a REALLY fast version of mathlib
  565. that is less accurate, but MUCH faster. Think about table lookup and
  566. interpolation. He probably wouldn't want you to design his next car with
  567. it, however.
  568.  
  569. -Dave Falkenburg
  570. -Apple Computer, Inc.
  571.  
  572. +++++++++++++++++++++++++++
  573.  
  574. >From bcorrie@csr.UVic.CA (Brian  Corrie)
  575. Date: 20 Apr 94 20:39:44 GMT
  576. Organization: University of Victoria
  577.  
  578. ViviStar@ACM.org (Jonathan Hess) writes:
  579. >In article <bcorrie.766459087@tara>
  580. >bcorrie@csr.UVic.CA (Brian  Corrie) writes:
  581.  
  582. >> Almost all 3D graphics use sin, cos, and sqrt extensively. How can all
  583. >> those native 3D programs claim massive speedups over high end Quadras
  584. >> when I am getting worse performance!?! It just don't make sense mon,
  585. >> I am still convinced that I am doing something ridiculously stoopid.
  586. >> Please, someone just tell me what it is!  8-)
  587.  
  588. >While it is besides the point of this thread I would tend to disagree
  589. >with the statement that "almost all 3D graphics use sin, cos, and sqrt
  590. >extensively."  Successfully fast packages avoid sin, cos, and sqrt as
  591. >much as possibly.  You can rewrite the basic tranform and projection
  592. >equations to where the 1 required trig operation can be computed and
  593. >stored in a constant once per projection.
  594.  
  595. Hmm, I guess my previous post demonstrates that my
  596. fingers do fly faster than my brain (which implies my brain ain't
  597. to fast because I can't type!!! 8-). On thinking about it, I agree,
  598. sin and cos are not used very often in graphics code. I was thinking
  599. of shading calculations that can use trig functions, but on reflection
  600. they rarely use sin/cos as there are usually more efficient ways
  601. of doing the computation (on reflection, shading...hmmm, a bit of a pun...!)
  602.  
  603. >Ray tracers are another story since they have to do a lot more
  604. >calculations with angles of incidence and things.
  605.  
  606. Even ray tracers can get away with using dot product, cross product etc.
  607. and rarely use sin/cos. It is just convenient to think of them as sin/cos
  608. as I did above.
  609.  
  610. Anyway, back to the thread of hacking down the slow sin/cos routines on
  611. the PowerMacs. I still say that it is ridiculous for a Quadra 840 to
  612. be faster than a PowerMac on native floating point sin/cos calculations.
  613. Still no insights as to what I am doing wrong, if anything. Are sin/cos
  614. really that slow on the PowerMacs???
  615.  
  616. Cheers,
  617.  
  618.     Brian
  619.  
  620.  
  621. --
  622.                   Brian Corrie (bcorrie@csr.uvic.ca)
  623. Under the most rigorously controlled conditions of pressure, temperature,
  624. volume, humidity and other variables, the organism will do as it damn well
  625. pleases. Sounds like some of the code I have written......  8-)
  626. >From eric.larson@f620.n2605.z1.fidonet.org (eric larson)
  627. Subject: CodeWarrior GOLD DR-2 - Can't seem to generate fast FP code
  628. Date: 20 Apr 94 18:52:00 -0500
  629. Organization: FidoNet:* File Edit View Label Special                 ? D (1:2605/620)
  630.  
  631.  > In article <CoCC78.D3r@world.std.com> John McEnerney,
  632.  
  633.  >>This should not be true. When using sin(), cos() etc. one normally links
  634.  >>against the MathLib shared library from Apple. These routines were
  635.  >>supposedly coded for high performance.
  636.  
  637.  > My bet is that they are coded to be highly accurate, so that when
  638.  > someone decides to build a bridge or an airplane using a Mac it won't
  639.  > fail due to a rounding error.
  640.  
  641. Butbutbut why would Seymour Cray ship a machine that produces lousy floating
  642. point results? These things are generally used for simulations far more heavily
  643. than an Mac ever is.
  644.  
  645. Meethinks this should be investigated carefully.
  646.  
  647. +++++++++++++++++++++++++++
  648.  
  649. >From rmcassid@uci.edu (Robert Cassidy)
  650. Date: Thu, 21 Apr 1994 12:41:21 -0800
  651. Organization: TLG Project
  652.  
  653. In article <bcorrie.766874384@tara>, bcorrie@csr.UVic.CA (Brian  Corrie)
  654. wrote:
  655.  
  656. [stuff deleted]
  657.  
  658. > Even ray tracers can get away with using dot product, cross product etc.
  659. > and rarely use sin/cos. It is just convenient to think of them as sin/cos
  660. > as I did above.
  661. > Anyway, back to the thread of hacking down the slow sin/cos routines on
  662. > the PowerMacs. I still say that it is ridiculous for a Quadra 840 to
  663. > be faster than a PowerMac on native floating point sin/cos calculations.
  664. > Still no insights as to what I am doing wrong, if anything. Are sin/cos
  665. > really that slow on the PowerMacs???
  666.  
  667. Since sometimes you *have* to do a lot of sin/cos work I don't think these
  668. functions should be ignored. I'm toying with the idea of writing a fp
  669. library (probably mostly trig) that would calculate w.r.t. a determined
  670. precision. I remember writing programs on the VAX at school that seemed
  671. unbelievably slow at sin/cos. It turned out that I was getting far more
  672. precision than I needed. I rewrote the routines and got something like a
  673. 10x speed improvement. Often you don't need a lot of precision
  674. (particularly with graphics) so why do all of the work of calculating what
  675. you don't use? If there is interest in this I may pursue it further (of
  676. course I have to get a PM first! :-)
  677.  
  678. -- 
  679. Robert Cassidy
  680. TLG Project
  681. UC Irvine
  682.  
  683. Let's hope 'Information SuperTollroad' isn't the catchphrase of the next
  684. decade...
  685.  
  686. +++++++++++++++++++++++++++
  687.  
  688. >From AppleGG@lamg.com (Gordon Apple)
  689. Date: 22 Apr 1994 12:16:21 -0800
  690. Organization: (none)
  691.  
  692. Since sometimes you *have* to do a lot of sin/cos work I don't think these
  693. functions should be ignored. I'm toying with the idea of writing a fp
  694. library (probably mostly trig) that would calculate w.r.t. a determined
  695. precision. I remember writing programs on the VAX at school that seemed
  696. unbelievably slow at sin/cos. It turned out that I was getting far more
  697. precision than I needed. I rewrote the routines and got something like a
  698. 10x speed improvement. Often you don't need a lot of precision
  699. (particularly with graphics) so why do all of the work of calculating what
  700. you don't use? If there is interest in this I may pursue it further (of
  701. course I have to get a PM first! :-)
  702.  
  703.  
  704.     The fastest way to generate sin and cos is with a look-up table.  If
  705. you're doing statistical communications simulations, or doing a software
  706. modem, the table size deoesn't have to be very large for your error noise to
  707. be swamped by the input noise.  You can build the table from SANE or whatever
  708. else is handy when you need it.  If you need more precision, use of the above
  709. table in conjunction with the double-angle formula gives highly accurate
  710. results with minimal computation. We have used these techniques for years in
  711. simulations and in DSPs.  They are extremely computationally efficient.  In
  712. fact, if you write it for a PowerPC processor, you could pipeline the
  713. process, using both the integer and floating point units at the same time. 
  714. That sucker should scream with that type algorithm.
  715.  
  716.  
  717. G. Gordon Apple, PhD
  718. Advanced Communications Engineering, Inc.
  719. Redondo Beach, CA
  720.  
  721. +++++++++++++++++++++++++++
  722.  
  723. >From usenet@lowry.eche.ualberta.ca (Brian Lowry)
  724. Date: 24 Apr 1994 00:08:46 GMT
  725. Organization: Chem Eng - Univ of Alberta
  726.  
  727.   It really isn't so hard to code efficent sin/cos/sqrt routines.  There
  728. are complete reference books with excellent algorithms (for much more
  729. difficult functions than sin or cos).  If anyone wants simple sin, cos, and
  730. sqrt routines which are on the order of optimal (in C, no doubt assembly
  731. would be faster), then just send me e-mail.
  732.  
  733. --
  734.  
  735. Brian Lowry
  736.  
  737. ---------------------------
  738.  
  739. >From mkelly@cs.uoregon.edu (Michael A. Kelly)
  740. Subject: Determining if user is on a network
  741. Date: 25 Apr 1994 15:26:26 -0700
  742. Organization: High Risk Ventures
  743.  
  744.  
  745. Hey,
  746.  
  747. Is there any way to determine if a machine is on a local network?  I can
  748. find out if AppleTalk is on, but that doesn't tell me if the machine is
  749. part of a network.
  750.  
  751. Thanks,
  752.  
  753. Mike.
  754. -- 
  755. _____________________________________________________________________________
  756. Michael A. Kelly                                                President/CEO
  757. mkelly@cs.uoregon.edu                                      High Risk Ventures
  758. _____________________________________________________________________________
  759.  
  760. +++++++++++++++++++++++++++
  761.  
  762. >From mxmora@unix.sri.com (Matt Mora)
  763. Date: 26 Apr 1994 10:44:04 -0700
  764. Organization: SRI International, Menlo Park, CA
  765.  
  766. In article <2phg2i$9lb@majestix.cs.uoregon.edu> mkelly@cs.uoregon.edu (Michael A. Kelly) writes:
  767. >
  768. >Hey,
  769. >
  770. >Is there any way to determine if a machine is on a local network?  I can
  771. >find out if AppleTalk is on, but that doesn't tell me if the machine is
  772. >part of a network.
  773.  
  774.  
  775. Here you go. 
  776.  
  777. /*
  778.     Sample code to demonstrate use of the LAP Manager call to determine
  779.     the current connection type i.e LocalTalk, EtherTalk phase 1/2, or
  780.     TokenTalk phase 2.
  781.     Rich Kubota 
  782.     DTS
  783. */
  784.  
  785. #include <Types.h>
  786. #include <string.h>
  787.  
  788. #define LGetATalkInfo     0x09        /* Get AppleTalk info */
  789.  
  790. /* 'atlk' resource ID's of Apple supplied driver software. */
  791. #define    LTalk        0
  792. #define    ETalkPh1    2
  793. #define    TTalkPh2    5
  794. #define    ETalkPh2    10
  795. #define LAPMgrPtr             0xB18
  796. #define LAPMgrCall            2
  797.  
  798. #include "GetADEVType.h"
  799.  
  800. pascal long CallLAPMgr(short selector) 
  801. {
  802.     asm{
  803.         MOVE.W        selector,D0        ; move selector parameter into D0
  804.         MOVE.L        A2,-(A7)        ; store A2 on stack
  805.         MOVEA.L        LAPMgrPtr,A2    ; Set A2 to address of LAP Mgr.
  806.         JSR            LAPMgrCall(A2)    ; Call LAP Manager
  807.         MOVE.L        D1,0x0A(A6)        ; Place result onto stack
  808.         MOVE.L        (A7)+,A2        ; Restore A2
  809.         UNLK        A6                ; restore stack frame
  810.         MOVEA.L        (A7)+,A0        ; put return address into A0
  811.         ADDQ.W        #0x02,A7        ; clear off the parameter
  812.         JMP            (A0)            ; return to caller
  813.         RTS
  814.     }
  815. }
  816. void CheckNetType(char * resultStr)
  817. {
  818.     long    result;
  819.     char    adevType;
  820.     char    slot;
  821.     
  822.     //Debugger();
  823.     result = CallLAPMgr(LGetATalkInfo); 
  824.     adevType = result & 0x000000FF;    /* atlk resource id is return in LSB */
  825.     slot = result>>24;                 /* card slot returned in MSB */
  826.     
  827.     switch (adevType) {
  828.         case LTalk:
  829.                 strcpy(resultStr,"LocalTalk");
  830.                 break;
  831.         case ETalkPh1:
  832.                 strcpy(resultStr,"EtherTalk phase 1");
  833.                 break;
  834.         case ETalkPh2:
  835.                 strcpy(resultStr,"EtherTalk phase 2");
  836.                 break;
  837.         case TTalkPh2:
  838.                 strcpy(resultStr,"TokenTalk");
  839.                 break;
  840.         default:
  841.                 strcpy(resultStr,"Unrecognized connection");
  842.                 break;
  843.         }
  844.  
  845. }
  846.  
  847. Warning. I never could get this to work on all systems.
  848.  
  849. Xavier
  850.  
  851.  
  852.  
  853. -- 
  854. ___________________________________________________________
  855. Matthew Xavier Mora                       Matt_Mora@sri.com
  856. SRI International                       mxmora@unix.sri.com
  857. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  858.  
  859. ---------------------------
  860.  
  861. >From neath@brazil.psych.purdue.edu (Ian Neath)
  862. Subject: Sample Think C AE Code
  863. Date: Wed, 20 Apr 1994 13:18:15 GMT
  864. Organization: Purdue University
  865.  
  866. As an amateur programmer trying to stay on the cutting edge
  867. of yesterday's technology, I'm trying to implement AE and
  868. custom AE into some apps.  I can't find much sample C code,
  869. though.  Any suggestions for locations (already tried
  870. sumex, etc.) greatly appreciated.  (We rarely get alt.sources.
  871. mac here)
  872.  
  873.  
  874. --
  875.       Ian Neath        | There are four kinds of people in this world:
  876. neath@psych.purdue.edu | cretins, fools, morons and lunatics - U. Eco
  877.  
  878. +++++++++++++++++++++++++++
  879.  
  880. >From Deirdre Maloy <Deeny3@aol.com>
  881. Date: Wed, 20 Apr 1994 18:24:07 GMT
  882. Organization: Metro Information Services, Raleigh NC
  883.  
  884. I remember that I found precious little about SENDING custom apple
  885. events. On the off chance this'll help, here's a sample sending code and
  886. receiving code (which go in two different apps). Despite the debug code,
  887. they do work -- one app sends another app the info about a file to
  888. launch, waits for an acknowledgement from the receiving app, then renames
  889. itself and quits. When the first app detects that the other app quit, it
  890. eats it. I had to do this for complicated reasons relating to auto-update
  891. version control experimentation. <g> All our applications are launched by
  892. the program we call "Itty" which is a faceless app that acts as a
  893. switchboard for apple events between our applications -- you can send an
  894. apple event to the Itty for an application that's not launched. It will
  895. then launch the app and forward the message when the app is ready to
  896. receive. This set of events is just designed for one app to tell the Itty
  897. to launch another app and when--though the when is controlled elsewhere.
  898.  
  899. _Deirdre
  900.  
  901. On receiving end:
  902. #include    "Launcher.h"
  903. #include    <Aliases.h>
  904.  
  905. extern    Boolean                highPriority;
  906. extern    launchRecord            myLaunchInfo[MAX_SUBLAUNCHES];        //    info on where
  907. app is located
  908. extern    short                currentLaunch;
  909. extern    Str255                myFile;                        //    name of current document
  910.  
  911.  
  912. pascal OSErr myHandleItty(AppleEvent *ittyEvent, AppleEvent *replyEvent,
  913. long refCon)
  914. {
  915.         OSErr        myErr;
  916.         AEDesc        myDesc;
  917.         long            actualSize;
  918.         DescType        actualType;
  919.         long            count;
  920.         AEDescList    myIttyList;
  921.         AEKeyword    myKeyword;
  922.         DescType        myType;
  923.         Str32        myString;
  924.     
  925.     highPriority = TRUE;
  926.     
  927.     myErr = AEGetParamPtr(ittyEvent, 'app ', 'fss ',
  928.                     &myType, (Ptr) &myLaunchInfo[currentLaunch].appName,
  929.                     (long) sizeof(FSSpec), &actualSize);
  930.     
  931.     myErr = HGetVol(myString,&myLaunchInfo[currentLaunch].appName.vRefNum,
  932.                     &myLaunchInfo[currentLaunch].appName.parID);
  933.  
  934.     myErr = AEGetParamPtr(ittyEvent, 'doc ', 's255',
  935.                     &myType, (Ptr) &myFile, (long) sizeof(Str255), &actualSize);
  936.                     
  937.     if (myErr != noErr)
  938.         myFile[0] = 0;
  939.     
  940.     CopyPString("\pHowdy",myString);
  941.                     
  942.     myErr = AEPutParamPtr(replyEvent, keyErrorString, typeChar,
  943. (Ptr)&myString[1], myString[0]);
  944.                     
  945.     SysBeep(3);
  946.     
  947.     return (noErr);
  948. }
  949.  
  950.  
  951. #include "Teeny.h"
  952. #include    <EPPC.h>
  953. #include    <AppleEvents.h>
  954.  
  955. extern    FSSpec                myAppLoc;        //    info on where doc to open is located
  956. extern    Str255                myDocPath;
  957. extern    ProcessSerialNumber    PSN;
  958. extern    Boolean                gQuit;
  959.  
  960. void    getIttyPSN(ProcessSerialNumber *ittyPSN, OSType ittySig);
  961. pascal Boolean MyIdleFunction(EventRecord *event,
  962.                     long *sleepTime, RgnHandle *mouseRgn);
  963.  
  964. void    sendIttyAE(void)
  965. {
  966.     //    Here's all the garbage you will need.
  967.  
  968.             OSType                ittyType = 'I???', ittyMsg = 'l8tr';
  969.             AEAddressDesc            ittyDesc;
  970.             AEDescList            myIttyList;
  971.             AEDesc                myApp, myDoc;
  972.             AppleEvent            myAppleEvent, myAEreply;
  973.             short                iErr;
  974.             ProcessSerialNumber    ittyPSN;
  975.             EventRecord            myEvent;
  976.  
  977.     //    create the address descriptor record.
  978.  
  979.         iErr = AECreateDesc(typeApplSignature, (Ptr)&ittyType,
  980. sizeof(ittyType), &ittyDesc);
  981.  
  982.     //    exit if there's an error
  983.  
  984.         if (iErr != noErr)
  985.             goto Sayonara;
  986.         
  987.     //    For the IttyBitty, the Apple Event TYPE should be 'I???',
  988.     //    which is also IttyBitty's signature. The Event ID should be one of
  989. the following:
  990.     //        'imed'    Launch this application IMMEDIATELY.
  991.     //        'delo'    Delete file.
  992.     //        'l8tr'    Launch this application when I quit.
  993.     //        (no other events defined)
  994.     //
  995.     //    in all cases, a parameter list is required
  996.     //        'app '    for application to launch (fsspec expected)
  997.     //        'doc '    for document to launch with app (Str255 expected)
  998.     //        'fss '        for any other fsspec
  999.     
  1000.         iErr = AECreateAppleEvent(ittyType, ittyMsg, &ittyDesc,
  1001. kAutoGenerateReturnID,
  1002.                 kAnyTransactionID, &myAppleEvent);
  1003.                 
  1004.         if (iErr != noErr)
  1005.             goto Sayonara;
  1006.         
  1007.         iErr = AEPutParamPtr(&myAppleEvent, 'app ', 'fss ', (Ptr) &myAppLoc,
  1008. (long) sizeof(FSSpec));
  1009.     
  1010.         if (myDocPath[0] > 2)
  1011.             iErr = AEPutParamPtr(&myAppleEvent, 'doc ', 's255', (Ptr) myDocPath,
  1012. (long) sizeof(Str255));
  1013.  
  1014.     //    We should be OK to send the apple event now.
  1015.     
  1016.         iErr = AESend(&myAppleEvent, &myAEreply, kAEWaitReply+kAECanInteract,
  1017.                     kAEHighPriority, 720, &MyIdleFunction, 0L);
  1018.     
  1019.         WaitNextEvent(0x2, &myEvent, 40L, 0);
  1020.                     
  1021.         if (iErr == noErr)    SysBeep(3);    //    to let user know AppleEvent was sent
  1022.         
  1023.         gQuit = TRUE;                    //    our task is done, the AppleEvent was sent
  1024.         
  1025. Sayonara:
  1026.         AEDisposeDesc(&ittyDesc);
  1027.         AEDisposeDesc(&myAppleEvent);
  1028.         AEDisposeDesc(&myAEreply);
  1029. }
  1030.  
  1031.  
  1032.  
  1033. // prototype your routine like this prior to calling it
  1034. // NOTE that it uses pascal calling conventions since it is called
  1035. // from the AESend routine
  1036. pascal Boolean MyIdleFunction(EventRecord *event,
  1037.                     long  *sleepTime, RgnHandle *mouseRgn);
  1038.  
  1039. // Application global variable to keep track of cursor rgn
  1040.  
  1041. RgnHandle gCursorRgn;
  1042.  
  1043. pascal Boolean MyIdleFunction(EventRecord *event,
  1044.                     long *sleepTime, RgnHandle *mouseRgn)
  1045. {
  1046.     char         hiByte;
  1047.     OSErr     myErr;
  1048.  
  1049.     switch ( event->what )
  1050.     {
  1051.         case updateEvt:
  1052.         case activateEvt:            // every idle function should handle
  1053.         case app4Evt:                // these kinds of events
  1054.             SetFrontProcess(&PSN);
  1055.             break;
  1056.         case nullEvent:
  1057.                                 // set the sleeptime and mouseRgn parameters
  1058.             *mouseRgn = gCursorRgn;
  1059.             *sleepTime = 10;        // use the correct value for your app
  1060.             SystemTask();            // the application's idle handling
  1061.             SystemTask();            // the application's idle handling
  1062.             SystemTask();            // the application's idle handling
  1063.             break;
  1064.     }
  1065.     return FALSE;
  1066. }
  1067.  
  1068.  
  1069.  
  1070. In article <CoK7MF.9Lq@mozo.cc.purdue.edu> Ian Neath,
  1071. neath@brazil.psych.purdue.edu writes:
  1072. >As an amateur programmer trying to stay on the cutting edge
  1073. >of yesterday's technology, I'm trying to implement AE and
  1074. >custom AE into some apps.  I can't find much sample C code,
  1075. >though.  Any suggestions for locations (already tried
  1076. >sumex, etc.) greatly appreciated.  (We rarely get alt.sources.
  1077. >mac here)
  1078. --
  1079. Deirdre Maloy, Metro Information Services, Raleigh NC
  1080. "My employer pays me for my opinions; you get them free."
  1081.  
  1082. +++++++++++++++++++++++++++
  1083.  
  1084. >From john40@aol.com (John40)
  1085. Date: 22 Apr 1994 19:25:02 -0400
  1086. Organization: America Online, Inc. (1-800-827-6364)
  1087.  
  1088. In article <CoK7MF.9Lq@mozo.cc.purdue.edu>, neath@brazil.psych.purdue.edu (Ian
  1089. Neath) writes:
  1090.  
  1091. >As an amateur programmer trying to stay on the cutting edge
  1092. >of yesterday's technology, I'm trying to implement AE and
  1093. >custom AE into some apps.  I can't find much sample C code,
  1094. >though.  Any suggestions for locations (already tried
  1095. >sumex, etc.) greatly appreciated.  (We rarely get alt.sources.
  1096. >mac here)
  1097.  
  1098. Get yourself a copy of UserLand Frontier's SDK 3.0.  It's packed with useful
  1099. Apple Events stuff.  The code is even free to use in your own programs
  1100. (no royalty, and its source code can even by distributed if you don't change it
  1101. - this is
  1102. according to their documentation).  You can get the SDK from BBSs such as
  1103. America Online
  1104. or by buying Frontier.
  1105.  
  1106. John Schlack
  1107.  
  1108.  
  1109. +++++++++++++++++++++++++++
  1110.  
  1111. >From eschen@molbio.cbs.umn.edu (Art Eschenlauer)
  1112. Date: Sun, 24 Apr 1994 18:04:22 GMT
  1113. Organization: University of Minnesota, Twin Cities
  1114.  
  1115. Today I noted in the MERIT Macintosh software archives at umich:
  1116.  
  1117. /mac/development/libraries/aebuilder1.1.cpt.hqx  (134K)
  1118. A ThinkC 5.0 kit to help construct and call Apple Events.
  1119. Very thorough and helpful. [Description theirs, not mine.]
  1120. --
  1121. eschen@molbio.cbs.umn.edu (Art Eschenlauer, 
  1122. U of M Agronomy and Plant Genetics Dept.)
  1123.  
  1124. ---------------------------
  1125.  
  1126. >From dacton@beak.com (Dan Acton)
  1127. Subject: drawing arrowheads
  1128. Date: 25 Apr 1994 08:36:10 -0600
  1129. Organization: Beak Consultants Ltd.
  1130.  
  1131. Has anyone out there figured out how to draw nice arrowheads on the ends of
  1132. lines similar to MacDraw, SuperPaint, Canvas, etc.?  I've written a routine
  1133. which uses QuickDraw arcs and some trigonometry and everyone says they look
  1134. terrible.
  1135. ********************************************
  1136.  Sent via BeakNet
  1137.  Beak Consultants Limited, Electronic Mail Network
  1138.    42 Arrow Road
  1139.    Guelph, Ontario, CANADA
  1140.    (519) 763-BEAK (voice)
  1141.    (519) 763-2378 (FAX)
  1142. ********************************************
  1143.  
  1144. +++++++++++++++++++++++++++
  1145.  
  1146. >From sw@network-analysis-ltd.co.uk (Sak Wathanasin)
  1147. Date: Tue, 26 Apr 94 00:12:12 GMT
  1148. Organization: Network Analysis Ltd
  1149.  
  1150.  
  1151. In article <1407844318.11694@beaknet1.beak.com> (comp.sys.mac.programmer), dacton@beak.com (Dan Acton) writes:
  1152. > Has anyone out there figured out how to draw nice arrowheads on the ends of
  1153. > lines similar to MacDraw, SuperPaint, Canvas, etc.?  I've written a routine
  1154. > which uses QuickDraw arcs and some trigonometry and everyone says they look
  1155. > terrible.
  1156.  
  1157. Oh well, I might as well get my code pulled apart. It's not
  1158. particularly efficient, but I only have to draw these occasionally. All
  1159. suggestions for improvement gratefully received. This has been pulled
  1160. from a MacApp prog; just assume that everything has been declared
  1161. appropriately. The consts were worked out using a desk calculator...
  1162.  
  1163. The method computes a QD poly, and is called whenever the start/end
  1164. points change. When I have to refresh the view, I call
  1165. PaintPoly(fArrowHead) after I draw the connecting line.
  1166.  
  1167. Set tabstops=4 for proper alignment.
  1168.  
  1169. pascal void
  1170. TEPConnection::CalcArrows    (void)
  1171. {
  1172.     const extended    kDeg2Rad     = 0.01745329252;        // for converting degrees to radians
  1173.     const extended    kArrowLength = 10.0;                // length of arrowhead
  1174.     const extended    kArrowAngle  = kDeg2Rad * 30.0;        // angle arrow makes with line
  1175.     short            angle;                                // angle between connecting line & vertical axis
  1176.     Rect            r;
  1177.                                                         // bounding box of agent
  1178.     Point            apex          = fEndPt;                // point of the arrow
  1179.     Point            pt2, pt3;                            // corners of the arrow
  1180.     
  1181.     r.left    = fStartPt.h - 10;
  1182.     r.top    = fStartPt.v - 10;
  1183.     r.right    = fStartPt.h + 10;
  1184.     r.bottom= fStartPt.v + 10;                            // concoct a square around the start pt
  1185.     PtToAngle(&r, apex, &angle);                        // calc angle of connecting line
  1186.     extended    rangle = (extended)(90-angle) * kDeg2Rad;
  1187.                                                         // the angle in radians                                                        // the angle in radians
  1188.     extended    temp    = rangle - kArrowAngle;
  1189.     pt2.h    = (short)((extended)apex.h - (kArrowLength * cos(temp)));
  1190.     pt2.v    = (short)((extended)apex.v + (kArrowLength * sin(temp)));
  1191.     temp     = rangle + kArrowAngle;
  1192.     pt3.h    = (short)((extended)apex.h - (kArrowLength * cos(temp)));
  1193.     pt3.v    = (short)((extended)apex.v + (kArrowLength * sin(temp)));
  1194.     
  1195.     if (fArrowPoly != NULL) {
  1196.         KillPoly(fArrowPoly);                            // get rid of prev arrow
  1197.         fArrowPoly = NULL;
  1198.     }
  1199.     PolyHandle    arrowPoly = OpenPoly();
  1200.     FailNULL(arrowPoly);
  1201.     MoveTo(apex.h, apex.v);
  1202.     LineTo(pt2.h, pt2.v);
  1203.     LineTo(pt3.h, pt3.v);
  1204.     LineTo(apex.h, apex.v);
  1205.     ClosePoly();
  1206.     fArrowPoly    = arrowPoly;    
  1207.  
  1208.     // reset the bounding box
  1209.     // ... some code to compute the bounding box, which you probably don't need
  1210. }
  1211.  
  1212. Sak Wathanasin
  1213. Network Analysis Limited
  1214. 178 Wainbody Ave South, Coventry CV3 6BX, UK
  1215.  
  1216. Internet: sw@network-analysis-ltd.co.uk 
  1217. uucp:     ...!uknet!nan!sw                       AppleLink: NAN.LTD
  1218. Phone: (+44) 203 419996 Mobile:(+44) 850 587411  Fax: (+44) 203 690690
  1219.  
  1220. ---------------------------
  1221.  
  1222. >From jadams@eng.umd.edu (Josh Adams)
  1223. Subject: writing an INIT... a few questions
  1224. Date: 22 Apr 1994 16:14:32 GMT
  1225. Organization: Project GLUE, University of Maryland, College Park
  1226.  
  1227. Hi,
  1228. I am a somewhat new Mac programmer. I have written some apps, but now I want
  1229. to write an INIT (I think). I was wondering a few things:
  1230. 1) Is there some info somewhere that documents how to do this and ant
  1231. background info I should have about things like memory and registers
  1232. and such?
  1233. 2) If I want to patch a trap for all applications, but I want to have a
  1234. window constantly displaying stuff, should I have an init to patch the 
  1235. trap(s) and then have it launch an app at startup, then send info from
  1236. the patched trap to my app with Apple Events? Would there be a better 
  1237. way? I couldn't imagine that it would be good to have the init make
  1238. a window...
  1239. 3) What does it mean to detach a resource? Would this affect me? 
  1240. 4) What registers do I have to care about?
  1241. 5) Is there a way to access the small black line at the bottom of the 
  1242. menu bar? Like if I drew something there, the menu would just erase
  1243. over it, right? Is there a way to change the line to be more than one
  1244. color? (Just wondering... I probably won't need to, but it is interesting
  1245. to know.
  1246.  
  1247. Thanks for all replies and info,
  1248. Stu
  1249.  
  1250.  
  1251. +++++++++++++++++++++++++++
  1252.  
  1253. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  1254. Date: Mon, 25 Apr 1994 07:18:46 -0400
  1255. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  1256.  
  1257. For the source code to three inits look in host akutaktak.andrew.cmu.edu
  1258. [128.2.35.1] /aw0g/*.hqx.
  1259.  
  1260. Excerpts from netnews.comp.sys.mac.programmer: 22-Apr-94 writing an
  1261. INIT... a few qu.. Josh Adams@eng.umd.edu (1094)
  1262.  
  1263. > 1) Is there some info somewhere that documents how to do this and ant
  1264. > background info I should have about things like memory and registers
  1265. > and such?
  1266.  
  1267.  
  1268. Not that I know of.   I guess I should write a how to write an
  1269. INIT/DRVR/CDEV faq...
  1270.  
  1271. Excerpts from netnews.comp.sys.mac.programmer: 22-Apr-94 writing an
  1272. INIT... a few qu.. Josh Adams@eng.umd.edu (1094)
  1273.  
  1274. > 2) If I want to patch a trap for all applications, but I want to have a
  1275. > window constantly displaying stuff,
  1276.  
  1277. The patch code needs to live in the system heap (otherwise multifinder
  1278. will swap the patch out when it switches applications).  The patch
  1279. should probably post it's information to a device driver.  The
  1280. application should read it from the driver.   I don't know enough about
  1281. apple events to know what problems there would be in using them.  I
  1282. suspect that there would be difficulties in getting the port for apple
  1283. events to not be closed when the applicaiton that was running when it
  1284. was opened quit.
  1285.  
  1286. Excerpts from netnews.comp.sys.mac.programmer: 22-Apr-94 writing an
  1287. INIT... a few qu.. Josh Adams@eng.umd.edu (1094)
  1288.  
  1289. > 3) What does it mean to detach a resource? Would this affect me? 
  1290.  
  1291.  
  1292. A code resource (the code for an INIT) is still attached to the resource
  1293. map for the init file.   If you don't detach it (with DetachResource)
  1294. the code block will be reused when the mac os cleans up after your init
  1295. starts and it goes on to the next init.  Rather than detach the init
  1296. code I prefer to have the init install anouther code resource.  That way
  1297. the installation part of the init code is freeed as it should be.
  1298.  
  1299. Excerpts from netnews.comp.sys.mac.programmer: 22-Apr-94 writing an
  1300. INIT... a few qu.. Josh Adams@eng.umd.edu (1094)
  1301.  
  1302. > 4) What registers do I have to care about?
  1303.  
  1304.  
  1305. For an init in general you don't have to worry about it.  Except if you
  1306. are using think c (which I recommend) you need to set up the A4
  1307. register.   See the init code in the softkiss driver for a good example
  1308. of dealing with this. 
  1309.  
  1310. ---------------------------
  1311.  
  1312. End of C.S.M.P. Digest
  1313. **********************
  1314.  
  1315.  
  1316.  
  1317.