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

  1. Received-Date: Fri, 18 Mar 1994 16:17:18 +0100
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: C.S.M.P. Digest, Issue 3.006
  4. To: csmp-digest@ens.fr
  5. Date: Fri, 18 Mar 94 16:15:51 MET
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 7
  10.  
  11. C.S.M.P. Digest             Fri, 18 Mar 94       Volume 3 : Issue 6
  12.  
  13. Today's Topics:
  14.  
  15.         68K emulation and PPC toolbox questions.
  16.         AE coercion handlers ?
  17.         ARGH!!! Whamwhamwham!! (DialogSelect stuff)
  18.         An offering: Assembly language code for a high speed copybits
  19.         Animation speed: here we go again...
  20.         Animation speed: improvement!
  21.         Animation speed: more info
  22.         Animation: the story continues...
  23.         Blank Screen?
  24.         C code for scrollable application help
  25.         Can C be as fast as Assembler? (next...on the McLaughlin Group)
  26.         Color Terminal Emulator
  27.         DrawString + Ellipsis character ?
  28.         Finder comments on non-Desktop DB volumes?
  29.         Finding System Folder (Again)
  30.         Free code:  Sean's window manager
  31.         How does the Finder handle events?
  32.         How to determine color of progress bar?
  33.         How to draw inits icons?
  34.         How to tell a Mac from a Mac?
  35.         I know the Mac MM isn't reentrant, but:
  36.         If you use SysBeep() for debugging...
  37.         Improving DrawText speed (Was: Color Terminal Emulator)
  38.         Interface guidelines for extra program files
  39.         Intermixing graphics and text
  40.         Let's kill 24-bit mode! (was Re: Let's kill System 6!)
  41.         Let's kill system 6!
  42.         Never beep when using GWorlds. System software bug!
  43.         PPC & 68k UPP problems
  44.         PPC binaries
  45.         Passing data through to completion procs?
  46.         Password editing item.. Tricky?
  47.         Permanent front windows...
  48.         Preference file question!
  49.         Reading PICT files != 72 dpi. How ?
  50.         Resources on PowerPC
  51.         Safer Segments ?
  52.         Speeding up animation; questions
  53.         System Folder on NONstartup disk
  54.         Trap dispatcher overhead
  55.         User in a menu?
  56.         What happens if my Vertical Retrace task takes too long?
  57.         When to StripAddress?  (was Re: Let's kill 24-bit mode!)
  58.         Why can't I have AEs *in* AEs?
  59.         Why use handles at all, though?
  60.         Writing To Screen Memory
  61.         dirIDs
  62.         jGNEFilter Q
  63.         password encryption
  64.  
  65.  
  66.  
  67. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  68. (pottier@clipper.ens.fr).
  69.  
  70. The digest is a collection of article threads from the internet newsgroup
  71. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  72. regularly and want an archive of the discussions.  If you don't know what a
  73. newsgroup is, you probably don't have access to it.  Ask your systems
  74. administrator(s) for details.  If you don't have access to news, you may
  75. still be able to post messages to the group by using a mail server like
  76. anon.penet.fi (mail help@anon.penet.fi for more information).
  77.  
  78. Each issue of the digest contains one or more sets of articles (called
  79. threads), with each set corresponding to a 'discussion' of a particular
  80. subject.  The articles are not edited; all articles included in this digest
  81. are in their original posted form (as received by our news server at
  82. nef.ens.fr).  Article threads are not added to the digest until the last
  83. article added to the thread is at least two weeks old (this is to ensure that
  84. the thread is dead before adding it to the digest).  Article threads that
  85. consist of only one message are generally not included in the digest.
  86.  
  87. The digest is officially distributed by two means, by email and ftp.
  88.  
  89. If you want to receive the digest by mail, send email to listserv@ens.fr
  90. with no subject and one of the following commands as body:
  91.     help                        Sends you a summary of commands
  92.     subscribe csmp-digest Your Name    Adds you to the mailing list
  93.     signoff csmp-digest            Removes you from the list
  94. Once you have subscribed, you will automatically receive each new
  95. issue as it is created.
  96.  
  97. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  98. Questions related to the ftp site should be directed to
  99. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  100. digest are available there.
  101.  
  102. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  103.  
  104.  
  105. -------------------------------------------------------
  106.  
  107. >From herman@ece.cmu.edu (Herman Schmit)
  108. Subject: 68K emulation and PPC toolbox questions.
  109. Date: 16 Mar 1994 19:32:32 GMT
  110. Organization: Electrical and Computer Engineering, Carnegie Mellon
  111.  
  112.  
  113.  
  114. When doing 68K emulation, will a Power Mac do emulation of 68K toolbox
  115. routines, or does the emulator detect those routines and execute the
  116. PowerPC toolbox code for that routine?
  117.  
  118. I'm also curious exactly why there will not be a 68K->PowerPC machine
  119. code translator in addition to an emulator.  I always thought that the
  120. problem with translating between CPUs was not caused by different
  121. instruction sets but by different system/OS calls and different memory
  122. models.  If the toolbox will be the same, the system/OS calls are no
  123. longer a problem.  Do the Power Macs have a significantly different
  124. memory model?
  125.  
  126. Even if they have a different memory model, couldn't you do some sort
  127. of emulation of the 68K memory and translate the everything else into
  128. PPC native code?  Or is this what is done?
  129.  
  130. herman
  131.  
  132.  
  133. +++++++++++++++++++++++++++
  134.  
  135. >From rang@winternet.mpls.mn.us (Anton Rang)
  136. Date: 17 Mar 1994 05:13:49 GMT
  137. Organization: Minnesota Angsters
  138.  
  139. In article <2m7msg$s9f@fs7.ece.cmu.edu> herman@ece.cmu.edu (Herman Schmit) writes:
  140. >When doing 68K emulation, will a Power Mac do emulation of 68K toolbox
  141. >routines, or does the emulator detect those routines and execute the
  142. >PowerPC toolbox code for that routine?
  143.  
  144.   The emulator detects A-traps and dispatches them through the trap
  145. table, as happens on 68K machines.  If the trap is written in PowerPC
  146. code, the Mixed Mode Manager switches to PowerPC native mode (if
  147. needed) and then runs it.  Similarly, if the trap is in 68K code, the
  148. MMM switches to 68K emulation and then runs it.
  149.  
  150. >I'm also curious exactly why there will not be a 68K->PowerPC machine
  151. >code translator in addition to an emulator.  I always thought that the
  152. >problem with translating between CPUs was not caused by different
  153. >instruction sets but by different system/OS calls and different memory
  154. >models.
  155.  
  156.   First, there is at least one third-party translator available,
  157. FlashPort by Echo Logic.  But it requires some input from the
  158. developers to do a good job; you can't just drag-and-drop onto it.
  159.  
  160.   Second, both problems exist.  It's not trivial to convert between
  161. different code models *and get reasonable performance*.  It can be
  162. done -- VEST on DEC's Alpha VMS machines is truly incredible! -- but
  163. it's very state-of-the-art and probably would have cost Apple many
  164. millions to develop....
  165. --
  166. Anton Rang (rang@winternet.mpls.mn.us)
  167.  
  168. +++++++++++++++++++++++++++
  169.  
  170. >From zstern@adobe.com (Zalman Stern)
  171. Date: Fri, 18 Mar 1994 11:55:45 GMT
  172. Organization: Adobe Systems Incorporated
  173.  
  174. Anton Rang writes
  175. > In article <2m7msg$s9f@fs7.ece.cmu.edu> herman@ece.cmu.edu (Herman Schmit)  
  176. writes:
  177. > >When doing 68K emulation, will a Power Mac do emulation of 68K toolbox
  178. > >routines, or does the emulator detect those routines and execute the
  179. > >PowerPC toolbox code for that routine?
  180. >   The emulator detects A-traps and dispatches them through the trap
  181. > table, as happens on 68K machines.  If the trap is written in PowerPC
  182. > code, the Mixed Mode Manager switches to PowerPC native mode (if
  183. > needed) and then runs it.  Similarly, if the trap is in 68K code, the
  184. > MMM switches to 68K emulation and then runs it.
  185.  
  186. In addition, some traps are "fat" and provide both 68K and PowerPC code.  
  187. This avoids the overhead of a mixed-mode switch for very small routines.  
  188. (Like say SetPort and GetPort.) All of the above applies to any routine  
  189. descriptor, not just the ones placed in the trap table. The most common use  
  190. is for callbacks passed to toolbox routines, however they can be used within  
  191. your own code as well. (There is special support in Mixed Mode to handle the  
  192. dispatching and calling conventions of traps of course.)
  193. --
  194. Zalman Stern           zalman@adobe.com            (415) 962 3824
  195. Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900
  196. "Do right, and risk consequences." Motto of Sam Houston (via Molly Ivins)
  197.  
  198. ---------------------------
  199.  
  200. >From paulr@syma.sussex.ac.uk (Paul Russell)
  201. Subject: AE coercion handlers ?
  202. Date: Wed, 2 Mar 1994 16:31:54 GMT
  203. Organization: University of Sussex
  204.  
  205. Am I right in thinking that there are no default
  206. system AE coercion handlers ? Not even for such 
  207. basic conversions as typeChar<->typeExtended ?
  208.  
  209. Is there a utility for displaying the installed
  210. coercion handlers ?
  211.  
  212. Are there any available handlers for common
  213. types, either as source or as an extension ?
  214.  
  215. //Paul
  216.  
  217. -- 
  218. |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  219. |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  220. |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  221. |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  222.  
  223. +++++++++++++++++++++++++++
  224.  
  225. >From jwbaxter@olympus.net (John W. Baxter)
  226. Date: Wed, 02 Mar 1994 12:43:30 -0800
  227. Organization: Internet for the Olympic Peninsula
  228.  
  229. In article <1994Mar2.163154.19747@syma.sussex.ac.uk>,
  230. paulr@syma.sussex.ac.uk (Paul Russell) wrote:
  231.  
  232. > Am I right in thinking that there are no default
  233. > system AE coercion handlers ? Not even for such 
  234. > basic conversions as typeChar<->typeExtended ?
  235.  
  236. There are a bunch of coercions built in to the Apple Event Manager.  As it
  237. happens, typeChar<->typeExtended is one of them.  They are listed in Inside
  238. Mac: IAC in table 4-1, which occupies ALL of pages 4-43 and 4-44.
  239.  
  240. There are more "exotic" ones built in, too, such as typeAppleEvent -->
  241. typeAppParameters (by far the easiest way to build THAT monster).
  242.  
  243. > Is there a utility for displaying the installed
  244. > coercion handlers ?
  245.  
  246. Yes...there is a little FKey.  It puts up a nice list of all the
  247. Application handlers (event, coercion, object extraction, etc) for the
  248. front application, and all the System handlers.  It is broken when the
  249. current Finder is in front [if it hurts, don't do it].  It's on the
  250. Developer CDs...since it is there, I don't know where else it may be.  It
  251. can also be used to trigger the handlers, although I haven't exercised that
  252. ability.
  253.  
  254. > Are there any available handlers for common
  255. > types, either as source or as an extension ?
  256.  
  257. AppleScript installs a whole bunch more.  And they are multiplying on the
  258. net.  They can get pretty much as outrageous as you may want.  I suppose a
  259. hypothetical typeRTF -> hypothetical typePostScript would be possible (but
  260. not written by me).
  261.  
  262. -- 
  263. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  264.    jwbaxter@pt.olympus.net
  265.  
  266. +++++++++++++++++++++++++++
  267.  
  268. >From paulr@syma.sussex.ac.uk (Paul Russell)
  269. Date: Thu, 3 Mar 1994 13:49:08 GMT
  270. Organization: University of Sussex
  271.  
  272. John W. Baxter (jwbaxter@olympus.net) wrote:
  273. : In article <1994Mar2.163154.19747@syma.sussex.ac.uk>,
  274. : paulr@syma.sussex.ac.uk (Paul Russell) wrote:
  275.  
  276. : > Am I right in thinking that there are no default
  277. : > system AE coercion handlers ? Not even for such 
  278. : > basic conversions as typeChar<->typeExtended ?
  279.  
  280. : There are a bunch of coercions built in to the Apple Event Manager.  As it
  281. : happens, typeChar<->typeExtended is one of them.  They are listed in Inside
  282. : Mac: IAC in table 4-1, which occupies ALL of pages 4-43 and 4-44.
  283.  
  284. : There are more "exotic" ones built in, too, such as typeAppleEvent -->
  285. : typeAppParameters (by far the easiest way to build THAT monster).
  286.  
  287. Thanks for the above and the rest of your comments - it looks like I
  288. have some sort of problem. I tried writing a small program which just
  289. calls AEGetCoercionHandler for a few different types and I get a -1717
  290. for everything I've tried. I have Apple Event Manager 1.0.1 and
  291. AppleScript 1.0 installed and am running System 7.1. I think both
  292. Apple Event Manager 1.0.1 and AppleScript 1.0 may be out of date
  293. by now so I'll have a dig through the developer CD's and see if
  294. I can find something newer.
  295.  
  296. //Paul
  297. -- 
  298. |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  299. |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  300. |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  301. |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  302.  
  303. +++++++++++++++++++++++++++
  304.  
  305. >From isis@netcom.com (Mike Cohen)
  306. Date: Thu, 3 Mar 1994 01:48:50 GMT
  307. Organization: ISIS International
  308.  
  309. paulr@syma.sussex.ac.uk (Paul Russell) writes:
  310.  
  311. >Am I right in thinking that there are no default
  312. >system AE coercion handlers ? Not even for such 
  313. >basic conversions as typeChar<->typeExtended ?
  314.  
  315. >Is there a utility for displaying the installed
  316. >coercion handlers ?
  317.  
  318. >Are there any available handlers for common
  319. >types, either as source or as an extension ?
  320.  
  321. >//Paul
  322.  
  323. There are default handlers for most numeric types to/from text and from
  324. alias to FSSpec. With AppleScript installed, there are many more coercion
  325. handlers available.
  326. -- 
  327. Mike Cohen - isis@netcom.com
  328. NewtonMail: MikeC49506 / ALink: D6734 / AOL: MikeC20
  329.  
  330.  
  331. +++++++++++++++++++++++++++
  332.  
  333. >From paulr@syma.sussex.ac.uk (Paul Russell)
  334. Date: Fri, 4 Mar 1994 13:20:57 GMT
  335. Organization: University of Sussex
  336.  
  337. Mike Cohen (isis@netcom.com) wrote:
  338. : paulr@syma.sussex.ac.uk (Paul Russell) writes:
  339.  
  340. : >Am I right in thinking that there are no default
  341. : >system AE coercion handlers ? Not even for such 
  342. : >basic conversions as typeChar<->typeExtended ?
  343.  
  344. : >Is there a utility for displaying the installed
  345. : >coercion handlers ?
  346.  
  347. : >Are there any available handlers for common
  348. : >types, either as source or as an extension ?
  349.  
  350. : >//Paul
  351.  
  352. : There are default handlers for most numeric types to/from text and from
  353. : alias to FSSpec. With AppleScript installed, there are many more coercion
  354. : handlers available.
  355.  
  356. Thanks - I found the FKEY that displays the installed handlers and
  357. although there is a motley assortment of coercion handlers, none
  358. of the expected handlers for text<->float etc seem to be available.
  359. This appears to be the case on several Macs that I have tried this on,
  360. and I have also written a test program which calls AEGetCoercionHandler
  361. which returns -1717 for just about any pair of types I try.
  362.  
  363. My best guess is that this is something to do with localisation - I am
  364. wondering if the US version of the Apple Event Manager/Apple Script
  365. checks the system version and doesn't install any handlers which might
  366. be country-specific ? 
  367.  
  368. If the above is not the correct explanation then I'd be interested to
  369. hear any other possible explanations for why the usual handlers aren't
  370. available ?
  371.  
  372. //Paul
  373.  
  374. -- 
  375. |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  376. |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  377. |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  378. |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  379.  
  380. +++++++++++++++++++++++++++
  381.  
  382. >From lai@apple.com (Ed Lai)
  383. Date: 4 Mar 1994 23:32:40 GMT
  384. Organization: Apple
  385.  
  386. In article <1994Mar4.132057.18343@syma.sussex.ac.uk>,
  387. paulr@syma.sussex.ac.uk (Paul Russell) wrote:
  388.  
  389. > Mike Cohen (isis@netcom.com) wrote:
  390. > : paulr@syma.sussex.ac.uk (Paul Russell) writes:
  391. > : >Am I right in thinking that there are no default
  392. > : >system AE coercion handlers ? Not even for such 
  393. > : >basic conversions as typeChar<->typeExtended ?
  394. > : >Is there a utility for displaying the installed
  395. > : >coercion handlers ?
  396. > : >Are there any available handlers for common
  397. > : >types, either as source or as an extension ?
  398. > : >//Paul
  399. > : There are default handlers for most numeric types to/from text and from
  400. > : alias to FSSpec. With AppleScript installed, there are many more coercion
  401. > : handlers available.
  402. > Thanks - I found the FKEY that displays the installed handlers and
  403. > although there is a motley assortment of coercion handlers, none
  404. > of the expected handlers for text<->float etc seem to be available.
  405. > This appears to be the case on several Macs that I have tried this on,
  406. > and I have also written a test program which calls AEGetCoercionHandler
  407. > which returns -1717 for just about any pair of types I try.
  408. > My best guess is that this is something to do with localisation - I am
  409. > wondering if the US version of the Apple Event Manager/Apple Script
  410. > checks the system version and doesn't install any handlers which might
  411. > be country-specific ? 
  412. > If the above is not the correct explanation then I'd be interested to
  413. > hear any other possible explanations for why the usual handlers aren't
  414. > available ?
  415. > //Paul
  416. > -- 
  417. > |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  418. > |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  419. > |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  420. > |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  421.  
  422. The FKEY displays the installed handlers, i.e. those handler installed
  423. using AEInstallXXX, but not the built-in handlers. The built-in handlers
  424. are listed in IM. The are built-in typeChar<->numericTypes. However they
  425. are not localized and are not meant for formating of numbers, they are
  426. more like what you expect to see in a debugger.
  427.  
  428. -- 
  429. /* Disclaimer: All statments and opinions expressed are my own */
  430. /* Edmund K. Lai                                               */
  431. /* Apple Computer, MS303-3A                                    */
  432. /* 20525 Mariani Ave,                                          */
  433. /* Cupertino, CA 95014                                         */
  434. /* (408)974-6272                                               */
  435. zW@h9cOi
  436.  
  437. +++++++++++++++++++++++++++
  438.  
  439. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  440. Date: 9 Mar 94 11:59:29 +1300
  441. Organization: University of Waikato, Hamilton, New Zealand
  442.  
  443. In article <isisCM2FpH.n03@netcom.com>, isis@netcom.com (Mike Cohen) writes:
  444. > paulr@syma.sussex.ac.uk (Paul Russell) writes:
  445. >
  446. >>Am I right in thinking that there are no default
  447. >>system AE coercion handlers ? Not even for such
  448. >>basic conversions as typeChar<->typeExtended ?
  449. >
  450. > There are default handlers for most numeric types to/from text and from
  451. > alias to FSSpec. With AppleScript installed, there are many more coercion
  452. > handlers available.
  453.  
  454. But one obvious one is missing: converting a pathname string to an alias or
  455. an FSSpec. I _always_ keep forgetting to prefix my pathnames with "file" or
  456. "alias"...
  457.  
  458. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  459. Info & Tech Services Division              fax: +64-7-838-4066
  460. University of Waikato            electric mail: ldo@waikato.ac.nz
  461. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  462.  
  463. +++++++++++++++++++++++++++
  464.  
  465. >From lai@apple.com (Ed Lai)
  466. Date: 10 Mar 1994 17:57:10 GMT
  467. Organization: Apple
  468.  
  469. In article <1994Mar3.134908.28390@syma.sussex.ac.uk>,
  470. paulr@syma.sussex.ac.uk (Paul Russell) wrote:
  471.  
  472. > John W. Baxter (jwbaxter@olympus.net) wrote:
  473. > : In article <1994Mar2.163154.19747@syma.sussex.ac.uk>,
  474. > : paulr@syma.sussex.ac.uk (Paul Russell) wrote:
  475. > : > Am I right in thinking that there are no default
  476. > : > system AE coercion handlers ? Not even for such 
  477. > : > basic conversions as typeChar<->typeExtended ?
  478. > : There are a bunch of coercions built in to the Apple Event Manager.  As it
  479. > : happens, typeChar<->typeExtended is one of them.  They are listed in Inside
  480. > : Mac: IAC in table 4-1, which occupies ALL of pages 4-43 and 4-44.
  481. > : There are more "exotic" ones built in, too, such as typeAppleEvent -->
  482. > : typeAppParameters (by far the easiest way to build THAT monster).
  483. > Thanks for the above and the rest of your comments - it looks like I
  484. > have some sort of problem. I tried writing a small program which just
  485. > calls AEGetCoercionHandler for a few different types and I get a -1717
  486. > for everything I've tried. I have Apple Event Manager 1.0.1 and
  487. > AppleScript 1.0 installed and am running System 7.1. I think both
  488. > Apple Event Manager 1.0.1 and AppleScript 1.0 may be out of date
  489. > by now so I'll have a dig through the developer CD's and see if
  490. > I can find something newer.
  491. > //Paul
  492. > -- 
  493. > |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  494. > |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  495. > |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  496. > |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  497.  
  498. AEGetCoercionHandler just returns whether an XXXX->YYYY coercion handler
  499. has
  500. been installed, it does not really tell you if a particular coercion
  501. exists.
  502. Built-in handler does not have a fixed address since the PACK can be
  503. relocated
  504. so the address cannot be returned. And if XXXX->YYYY coercion is handled by
  505. the ****->YYYY coercion handler, AEM has no idea that XXXX->YYYY can or
  506. cannot be done through ****->YYYY. So the rule is that it strictly returns
  507. an XXXX->YYYY address if it exists, it is not meant to rule out the
  508. existence of the possibility of XXXX->YYYY coercion.
  509.  
  510.  
  511. -- 
  512. /* Disclaimer: All statments and opinions expressed are my own */
  513. /* Edmund K. Lai                                               */
  514. /* Apple Computer, MS303-3A                                    */
  515. /* 20525 Mariani Ave,                                          */
  516. /* Cupertino, CA 95014                                         */
  517. /* (408)974-6272                                               */
  518. zW@h9cOi
  519.  
  520. +++++++++++++++++++++++++++
  521.  
  522. >From jonpugh@netcom.com (Jon Pugh)
  523. Date: Sat, 12 Mar 1994 07:19:44 GMT
  524. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  525.  
  526. Lawrence D'Oliveiro, Waikato University (ldo@waikato.ac.nz) wrote:
  527.  
  528. > But one obvious one is missing: converting a pathname string to an alias or
  529. > an FSSpec. I _always_ keep forgetting to prefix my pathnames with "file" or
  530. > "alias"...
  531.  
  532. This is done and working as part of Jon's Commands 1.1.  Interested in beta
  533. testing?
  534.  
  535. Jon
  536.  
  537.  
  538. ---------------------------
  539.  
  540. >From gjw2824@hertz.njit.edu (Greg Weston)
  541. Subject: ARGH!!! Whamwhamwham!! (DialogSelect stuff)
  542. Date: 5 Mar 94 19:58:17 GMT
  543. Organization: New Jersey Institute of Technology, Newark, New Jersey
  544.  
  545. Howdy, folks. I've been playing with everyone's favorite UI addition:
  546. Floating Windows. I've gotten them to work smoothly and cleanly, and
  547. they interact fine with normal windows and dialogs (modal or not). The
  548. only problem is within a pair of cute little routines called
  549. IsDialogEvent and DialogSelect. They don't like having a (floating)
  550. window in front of the Dialog they're working with. 
  551.  
  552. So, I re-wrote them. (Cough. Embarrased grin.) Still no problem. I'm
  553. left with one teensy little problem:
  554. How in the blazes does DialogSelect do its magic when you have
  555. multiple editTexts in a dialog and either click in a non-current one
  556. or press Tab?!?!
  557.  
  558. On that topic, IM is silent, and I can't figure out how to
  559. successfully pull off the swap with what they give you. Any thoughts,
  560. suggestions, or even polite chuckles would be appreciated.
  561.     Thanks,
  562.         Greg
  563.  
  564. +++++++++++++++++++++++++++
  565.  
  566. >From cconstan@epdiv1.env.gov.bc.ca (Carl B. Constantine)
  567. Date: Mon, 07 Mar 1994 10:31:52 -0800
  568. Organization: Ministry of Environment, Lands & Parks
  569.  
  570. In article <1994Mar5.195817.28298@njitgw.njit.edu>, gjw2824@hertz.njit.edu
  571. (Greg Weston) wrote:
  572.  
  573. > Howdy, folks. I've been playing with everyone's favorite UI addition:
  574. > Floating Windows. I've gotten them to work smoothly and cleanly, and
  575. > they interact fine with normal windows and dialogs (modal or not). The
  576. > only problem is within a pair of cute little routines called
  577. > IsDialogEvent and DialogSelect. They don't like having a (floating)
  578. > window in front of the Dialog they're working with. 
  579. > So, I re-wrote them. (Cough. Embarrased grin.) Still no problem. I'm
  580. > left with one teensy little problem:
  581. > How in the blazes does DialogSelect do its magic when you have
  582. > multiple editTexts in a dialog and either click in a non-current one
  583. > or press Tab?!?!
  584. > On that topic, IM is silent, and I can't figure out how to
  585. > successfully pull off the swap with what they give you. Any thoughts,
  586. > suggestions, or even polite chuckles would be appreciated.
  587. >     Thanks,
  588. >         Greg
  589.  
  590. One solution the new IM suggests instead of using dialog Select, you can
  591. use a custom routing to take a look at what kind of window the event
  592. occured in and then process the event that way.
  593.  
  594. Very usefull if you're dealing with modeless and movableModal Dialogs.
  595.  
  596. Source: IM Macintosh Toolbox Essentials, ch. 6 Dialog Manager.
  597.  
  598. -- 
  599. =========================================================================
  600. Carl B. Constantine                      B.C. Environment, Lands & Parks
  601. End-User Support Analyst                 CCONSTAN@epdiv1.env.gov.bc.ca
  602.  
  603. +++++++++++++++++++++++++++
  604.  
  605. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  606. Date: Tue, 8 Mar 1994 15:37:06 GMT
  607. Organization: Sexton Software
  608.  
  609. In article <1994Mar5.195817.28298@njitgw.njit.edu> Greg Weston,
  610. gjw2824@hertz.njit.edu writes:
  611. >How in the blazes does DialogSelect do its magic when you have
  612. >multiple editTexts in a dialog and either click in a non-current one
  613. >or press Tab?!?!
  614.  
  615.  I can't tell exactly how far along you are in this project but if you
  616. haven't taken a look at the DialogRecord structure you should do so now
  617. (I know, you probably have). 
  618. DialogRecord = record
  619.     window: WindowRecord;
  620.     items: Handle;
  621.     textH: TEHandle;
  622.     editField: Integer;
  623.     editOpen: Integer;
  624.     aDefItem: Integer;
  625. end;
  626. You need to manipulate the textH and editField variables. EditField
  627. points to the current text item in the linked list starting at items. Of
  628. course you have to update the current text item before setting up textH
  629. for the new text item. I thought there was some fairly useful information
  630. about this stuff in Inside Mac Volume I. My volume I is at home so I
  631. can't check but try looking there.
  632.  
  633. +++++++++++++++++++++++++++
  634.  
  635. >From u9119523@sys.uea.ac.uk (Graham Cox)
  636. Date: Wed, 9 Mar 1994 17:01:47 GMT
  637. Organization: School of Information Systems, UEA, Norwich
  638.  
  639. In article <cconstan-070394103153@eusacbc.env.gov.bc.ca>,
  640. cconstan@epdiv1.env.gov.bc.ca (Carl B. Constantine) wrote:
  641.  
  642. > In article <1994Mar5.195817.28298@njitgw.njit.edu>, gjw2824@hertz.njit.edu
  643. > (Greg Weston) wrote:
  644. > > Howdy, folks. I've been playing with everyone's favorite UI addition:
  645. > > Floating Windows. I've gotten them to work smoothly and cleanly, and
  646. > > they interact fine with normal windows and dialogs (modal or not). The
  647. > > only problem is within a pair of cute little routines called
  648. > > IsDialogEvent and DialogSelect. They don't like having a (floating)
  649. > > window in front of the Dialog they're working with. 
  650. > > 
  651. > > So, I re-wrote them. (Cough. Embarrased grin.) Still no problem. I'm
  652. > > left with one teensy little problem:
  653. > > How in the blazes does DialogSelect do its magic when you have
  654. > > multiple editTexts in a dialog and either click in a non-current one
  655. > > or press Tab?!?!
  656. > > 
  657. [SNIP!]
  658.  
  659.  
  660. If your question is how does it switch from one field to another, then I
  661. can answer!
  662.  
  663. In the DIALOGRECORD is a field which contains the ID number of the current
  664. editable item. When you hit tab, this is incremented and GetDItem called to
  665. see if the resulting item is an edit field, if not, it increments until it
  666. finds one or until the last item is found, at which point it starts over
  667. from item 1. When it finds an edit field item, it retrieves the text from
  668. the current one and stashes it into the item list as that item's string,
  669. then installs the text from the new one into the teRecord using TESetText,
  670. then selects it with TESetSelect, or if it was a click, calls TEClick. The
  671. DialogRecord also contains the teHandle.
  672.  
  673. The DialogRecord itself is documented in IM, though this sequence of events
  674. isn't- I had to figure this out for myself once when trying to do something
  675. along the same lines as you.
  676.  
  677. You can get the dialog record by casting the DialogPtr to type DialogPeek.
  678.  
  679. Hope this helps!
  680.  
  681.  
  682. > =========================================================================
  683. > Carl B. Constantine                      B.C. Environment, Lands & Parks
  684. > End-User Support Analyst                 CCONSTAN@epdiv1.env.gov.bc.ca
  685.  
  686. - ------------------------------------------------------------------------
  687. Love & BSWK, Graham
  688.  
  689. -Everyone is entitled to their opinion, no matter how wrong they may be...
  690. - ------------------------------------------------------------------------
  691. - ------------------------------------------------------------------------
  692. Love & BSWK, Graham
  693.  
  694. -Everyone is entitled to their opinion, no matter how wrong they may be...
  695. - ------------------------------------------------------------------------
  696.  
  697. +++++++++++++++++++++++++++
  698.  
  699. >From qsi@NU91.wlink.nl (Peter Kocourek)
  700. Date: Tue, 08 Mar 1994 20:55:13 +0100
  701. Organization: (none)
  702.  
  703. Greg Weston wrote in a message on 05 Mar 94 to All
  704.  
  705.  GW> Howdy, folks. I've been playing with everyone's favorite UI 
  706.  GW> addition: Floating Windows. I've gotten them to work smoothly 
  707.  GW> and cleanly, and they interact fine with normal windows and 
  708.  GW> dialogs (modal or not). The only problem is within a pair of 
  709.  GW> cute little routines called IsDialogEvent and DialogSelect. 
  710.  GW> They don't like having a (floating) window in front of the 
  711.  GW> Dialog they're working with.
  712.  GW>  So, I re-wrote them. (Cough. Embarrased grin.) Still no problem. I'm   
  713.  GW> left with one teensy little problem: How in the blazes does 
  714.  GW> DialogSelect do its magic when you have multiple editTexts in a
  715.  GW> dialog and either click in a non-current one or press Tab?!?! 
  716.  
  717. These two issues are separate from one another. Handling Tab presses is far
  718. easier than getting the mouseclick-induced editText change right. In fact, I
  719. haven't been able to get my own routines to do this properly. I was writing my
  720. own replacements for DialogSelect (to handle movable modals and modeless
  721. dialogs, with enhancements) and bumped into this problem. I tried all sorts of
  722. things with the TERecord, but I wasn't able to get the swap done cleanly.
  723.  
  724. So I cheated. :-) In my generic mouseDown-handling procedure (within my
  725. DialogSelect replacement), I first check to see where the mouseDown occurred.
  726. If it is in an editText field, I check whether it's the currently active
  727. text-input-capable [TIC, my shorthand] item, and in that case a simple TEClick
  728. call will take care of everything. If it is not the active TIC item (you have
  729. to keep track of this separately), and the currently active TIC is not an
  730. editText item, I call the deactivate function for the TIC; this is usually a
  731. custom routine for userItems which contain lists, for instance. One aesthetic
  732. problem with this is, that userItems don't have refCons, so that storing the
  733. ProcPtr's for userItem service routines is a bit cumbersome. Anyway, once your
  734. previously active TIC item is deactivated, you can activate manually the
  735. TERecord, and call TEClick.
  736. If, however, the active TIC item is an editText item, you'll have to "cheat".
  737. Having found no way doing the transition from one editText item to another
  738. cleanly, I simply call the real DialogSelect at that point. Note that I only do
  739. this when I have determined unambiguously, that the action to be taken is
  740. switching from one editText item to anohter.
  741.  
  742. As for handling Tabs, the situation is a bit easier. You have to find the next
  743. TIC item in your dialog (or the previous one, if the user pressed shift-Tab),
  744. and handle the deactivating and activating as above. The one thing that makes
  745. it doable without "cheating", is that you don't have to place the caret
  746. anywhere within the text of the next editText item (this was causing my
  747. problems), but you either select the entire text, if there is any, or you place
  748. just a caret, if there isn't. I'll include my source code where I do this.
  749. Parts of the code are specific to my implementation. For instance, I store a
  750. struct via a Handle in the window refCon. This struct contains lots of
  751. information about the dialog; you'll have to adapt it to your own needs. You
  752. will have to provide the CanAcceptText and ActivateItem functions for your own
  753. userItems.
  754. (sorry about the formatting)
  755.  
  756. /*************************************************************************************
  757.  * Somehow I'm not sure I should be doing this... requires too much thinking.
  758.  * CycleKeyBoardInput is a generic routine that will find and activate the next
  759. (or
  760.  * previous) item in the DITL that can accept keyDown events. To do this, it
  761. needs:
  762.  *  + a DialogPtr, to indicate in which dialog to look, and to get at the
  763. WIHandle.
  764.  *  + a Boolean isShiftPressed, to determine whether to search forward or
  765. backward in
  766.  *      the DITL
  767.  *  + a pointer to a function, that returns a Boolean. If this function,
  768. CanAcceptText,
  769.  *    returns TRUE, then the userItem (passed as a short to CanAcceptText) can
  770. accept
  771.  *    keyDown events. This function should be declared along with the other
  772. specific
  773.  *    functions for this dialog (as in AddressesDialog.c)
  774.  *  + another pointer to a function, that will either activate or deactivate a
  775. userItem
  776.  *    in the DITL, that can accept text. {De}Activating editText items is done
  777. here.
  778.  *
  779.  ************************************************************************************/
  780.  
  781. void CycleKeyboardInput(DialogPtr dPtr, Boolean isShiftPressed, 
  782.         Boolean (*CanAcceptText)(short), void (*ActivateItem)(WindowInfoHandle,
  783. short, Boolean))
  784.  
  785. {
  786.     WindowInfoHandle aWIHandle;          /* my own struct with info */
  787.     short    numItems, activeItem, queryItem, iType;
  788.  
  789.     aWIHandle = (WindowInfoHandle)GetWRefCon(dPtr);
  790.     activeItem = (**aWIHandle).activeItem; /* keeping track of the active TIC */
  791.     queryItem = activeItem + (isShiftPressed ? -1 : 1);
  792.     numItems = CountDITL(dPtr); 
  793.  
  794.     while (queryItem != activeItem)        /* check to see if we're back where we
  795. started */
  796.     {
  797.         if (queryItem == 0)                        /* handle rollover */
  798.             queryItem = numItems;
  799.         else if (queryItem == numItems+1)
  800.             queryItem = 1;
  801.             
  802.         GetDItem(dPtr, queryItem, &iType, &workHandle, &workRect);    /* get item info
  803. */
  804.         if (iType == editText)                                    /* if editText, we're finished */
  805.             break;
  806.         if (iType == userItem && CanAcceptText(queryItem))            /* same for userItem */
  807.             break;
  808.         
  809.         isShiftPressed ? queryItem-- : queryItem++;        /* get next item to query */
  810.     
  811.     }
  812.     
  813.     if (queryItem != activeItem)        /* found a new one? */
  814.     {
  815.         short aType;
  816.         
  817.         GetDItem(dPtr, activeItem, &aType, &workHandle, &workRect);
  818.         if (aType == userItem)
  819.             ActivateItem(aWIHandle, activeItem, FALSE);        /* deactivate currently active
  820. user item */
  821.         
  822.         
  823.         if (iType == editText)
  824.         {
  825.             SelIText(dPtr, queryItem, 0, 32767);    /* select new editText item */
  826.             workTEHandle = ((DialogPeek)dPtr)->textH;
  827.         }
  828.         else if (iType == userItem)
  829.         {
  830.             if (aType == editText)        /* was previously active item an editText? */
  831.                 TEDeactivate(((DialogPeek)dPtr)->textH);
  832.             ActivateItem(aWIHandle, queryItem, TRUE); /* select new userItem */    
  833.             workTEHandle = NIL;
  834.         }
  835.     
  836.         (**aWIHandle).activeItem = queryItem;
  837.         UpdateEditMenus(workTEHandle, kSystemTE);     /* my own service proc */
  838.         
  839.     }
  840. }
  841.  
  842. I hope you can make some sense out of all this. :-) Additional notes: CountDITL
  843. is System 7 specific (may come with CTB under System 6), but I don't do System
  844. 6 anymore. An example of an ActivateItem function would be for a list to draw a
  845. border around the list, to alert the user that keypresses will go to the list
  846. (to select a cell in the list).
  847.  
  848.  GW> On that topic, IM is silent, and I can't figure out how to 
  849.  GW> successfully pull off the swap with what they give you. Any 
  850.  GW> thoughts, suggestions, or even polite chuckles would be appreciated. 
  851.  
  852. <chuckle, polite> :-)
  853.  
  854.  
  855. YHS:QSI!
  856.  
  857.  
  858. +++++++++++++++++++++++++++
  859.  
  860. >From gjw2824@hertz.njit.edu (Greg Weston)
  861. Date: 10 Mar 94 20:38:09 GMT
  862. Organization: New Jersey Institute of Technology, Newark, New Jersey
  863.  
  864. Well, I had three people respond, each with different suggestions, and
  865. got it working with the first one. I'd like to thank Steve Bryan, Carl
  866. Constantine, and Simon Ward for their advice. I had looked through the
  867. IM vol 1 stuff pretty carefully, but the mechanics of the manipulation
  868. really were sketchy. My NIM is 100+ miles away, so I didn't have that
  869. to look through. I have a solution that works quite well, though, and
  870. I'm very happy with the finished product. Thank you kindly, and y'all
  871. will probably see a submission to the standard archives soon.
  872.     Greg
  873.  
  874. ---------------------------
  875.  
  876. >From ejohnson@netcom.com (Eric Johnson)
  877. Subject: An offering: Assembly language code for a high speed copybits
  878. Date: Fri, 18 Mar 1994 07:50:48 GMT
  879. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  880.  
  881. About two weeks ago, I had mentioned that I had written some assembly
  882. language code that could beat copybits given certain assumptions.  A
  883. number of people (Alex Metcalf and David Wareing) had asked me to send
  884. them some samples.  I was going to write up some demo code with it,
  885. but never got around to it due to work obligations.
  886.  
  887. A few days ago, I sent David an email message with some and a length
  888. explanation.  I figured that maybe everyone else could benefit from
  889. the email to.  Keep in mind that the following code was my first real
  890. whack at some high speed copybits.  I may be breaking a few rules, or
  891. doing bad Mac programmer things.  So USE IT AT YOUR OWN RISK.
  892.  
  893. I believe further enhancements can be made to it, especially given the
  894. wide spread prominence of the 030 and 040.  When I first wrote it, the
  895. 020 was in much more common use.
  896.  
  897. This code has evolved into a copybits that will do some very fast
  898. masking.  I had used it for a graphics engine that would display
  899. things at a perspective.  Where each icon was a perspective block, if
  900. you will.  Thus masking was needed.  It looks quite sharp.  I can go
  901. over that code too, as well as the trick I put in for some fast
  902. masking.  As always, you pay for the speed.  It needs a bit of memory.
  903.  
  904. Let me know if this helps anyone.  Here is the message I sent to David
  905. Wareing. 
  906.  
  907. <------------->
  908.  
  909. David,
  910.  
  911. Okay, here's some code with some explanation off the top of my head.
  912.  
  913. This code was developed for a tile based adventure game that was never
  914. quite finished.  The graphics were a simple display consisting of
  915. 11x11 icons where each icon was a 24x24 cicn resource.  This type of
  916. display is identical to that of the old Ultima games on the Apple ][
  917. and old PC's.  And the more recent Zelda of Nintendo or Civilization
  918. on the Macintosh.
  919.  
  920. I initially wrote everything in C, and used PlotCIcon to place my color
  921. icons on the screen.  In found that to be too slow, because the Mac
  922. was constantly converting the colors in the resource to those
  923. available on the screen.  Hence the molases like quality.  So I said
  924. to myself, "Screw it, I'm going do it in assembly.".
  925.  
  926. Even though the code I'm including has been rewritten for a slightly
  927. more complex display, I'm giving this to you so you can follow the
  928. history of its development.  It should make more sense this way, and
  929. you'll see some room for improvements along the way.  I wrote this as
  930. a beginner Mac programmer, so I may be breaking some rules.
  931.  
  932. Let's first identify what slows down drawing to the screen.  In my
  933. case, I had a few mistakes.  The first one was using PlotCIcon.  The
  934. Mac was constantly converting the resource into the current colors
  935. available in the port.  That's all well and good, in fact that's quite
  936. nice of them.  But it slows things down a bit.
  937.  
  938. To get around this, I created an off screen window that would
  939. warehouse my icons.  The benefit is that the off screen window would
  940. have the same color table [CLUT, right?] so any transfer between an
  941. offscreen window and the main screen would be a trivial copy.  Thus,
  942. at start time, I painted each icon into the off screen to "coerce" it
  943. into the current system table.
  944.  
  945. Okay, so I did that.  I would then use copy bits to repaint my window.
  946. In my game, I have a two dimensional array with numbers indicating
  947. which icon goes at what location.  So, I would get the id number of
  948. the display icon, locate it in my off screen window [the palette of
  949. icons] and use copybits to get it to the window.
  950.  
  951. Well, that was better, but was still slower than I expected.  So, I
  952. got to thinking about how to speed things up.  The bottleneck in this
  953. case is copybits.  Sure, copybits is fairly fast, but I know a few
  954. things about my icons that it doesn't know.  They are all of the same
  955. width, and same height.  But how do I put this knowledge to good use?
  956.  
  957. Let's step back for a second and look at the Motorola architecture.
  958. When I wrote it, I decided to take advantage of the features found in
  959. the 68020's and later.  It really starts to do well in the 030.  We
  960. won't consider the 68000 because there's not much you can do for that
  961. chip.
  962.  
  963. The 680x0 has 8 32 bit data registers and 8 32 address registers.  You
  964. lose some of the address registers to the system, but all in all,
  965. there's some room to play around in.  The 68020 and later have some
  966. code cache and data caches to work with too.  In other words, you can
  967. have a loop fill up the instruction cache, and then the CPU can run
  968. faster because all of its code is in the cache.
  969.  
  970. It's this instruction cacheing that I take full advatange of.  In later
  971. developments of this code, I try to take advantage of the data cache.
  972. So, we need to write some assembly language code that will copy 24
  973. bytes at a time from 24 different parts of memory.  Remember, in this
  974. case, my icons are 24 bytes wide (24 pixels at 8 bits a pixel).  And
  975. the are 24 pixels high.  So, we've got 24 blocks of 24 pixels.  Each
  976. block starts at a slightly different memory location.
  977.  
  978. My code loops 24 times, one for each row of 24 bytes.  Thus, the code
  979. that copies each row lands in the instruction cache.  So, on each
  980. subsequent reitiration of the code, we are running strictly from the
  981. cache.  This gives us some good performance.  But there's one more
  982. feature too.
  983.  
  984. Most modern processors have a pipeline where the different parts of
  985. the CPU execute part of an instruction then hand it off to the next
  986. step.  It works identically to an assembly line where someone installs
  987. the engine and the next person installs the tires.  A new car always
  988. rolls off the line every so often even though it may take a bit for a
  989. car to travel the entire line.
  990.  
  991. The catch lies with branch instructions.  The CPU won't know if the
  992. branch should be taken until its evaluation is complete.  But, this
  993. means that the CPU won't necessarily be putting the right instructions
  994. in the pipeline.  It would be like producing a car that indicated the
  995. previous cars should be destroyed.  This wrecks efficiency.
  996.  
  997. To get around it, Motorola has provided an instruction, dbra, that
  998. serves as a hint.  dbra tells the CPU to branch if the contents of the
  999. data register are not zero.  It instructs the CPU to expect the branch
  1000. and fill the pipeline with the instructions that would result if a
  1001. branch takes place.
  1002.  
  1003. So, my loops gets two nice features going.  The instruction cache and
  1004. it keeps the pipeline going too.  Pretty sweet, eh?
  1005.  
  1006. My code works in two steps.  The first section is the prepatory work
  1007. for the loop.  I put as much stuff as I can into registers, because
  1008. adding and multiplying "in register" is much faster than from memory.
  1009. And the instructions are shorter, which means less space is taken up
  1010. in the instruction cache.
  1011.  
  1012. This point of putting stuff "in register" may seem anal, but remember,
  1013. we need to add some values at the end of each iteration of the loop
  1014. and keeping stuff as fast and small is good.
  1015.  
  1016. Now, let's go over the parameters to the code.
  1017.  
  1018. mySource points to the start of the off screen palette.
  1019. myDestination points to the start of the off screen drawing space.
  1020.  
  1021. xSource and ySource are the x,y coordinates of the pixel that
  1022. represents the upper left hand corner of the thing you wish copied.
  1023. Keep in mind that these are *PIXEL COORIDINATES* not icon coordinates.
  1024. Its up to you to find the start of the icon you wish copied in your
  1025. off screen palette of icons.  I suppose my code could do it.  I just
  1026. didn't bother.
  1027.  
  1028. xDestination and yDestination are the same xSource and ySource except
  1029. for the destination array.
  1030.  
  1031. iconSize should be your icon height minues one.  In my case, its 23.
  1032.  
  1033.  
  1034. int  MyCopyBits8(Ptr mySource, Ptr myDestination,
  1035.                  long int xSource, long int ySource,
  1036.                  long int xDestination, long int yDestination,
  1037.                  long int iconSize) {
  1038.   
  1039.   asm 68000 {
  1040.  
  1041.     /**
  1042.      ** We need to save the registers that we are going to clobber.
  1043.      **
  1044.      ** a1 starts out pointing to the top of the pallete, but it .
  1045.      ** will eventually end up pointing to the start of the source
  1046.      ** icon.  Same goes for a2.
  1047.      **
  1048.      ** d2 and d3 are a bit tricky to explain.  They are the row
  1049.      ** byte values for the source and destination.  A row byte
  1050.      ** value is the number of bytes required to jump down to the
  1051.      ** next row.  It needs to be a multiple of four else some
  1052.      ** Mac internals complain.  We use these values to find the
  1053.      ** real location of both icons.
  1054.      **
  1055.      **/
  1056.  
  1057.     movem.l    a1-a2/d0-d3, -(sp);    /* save the regs */
  1058.     move.l    mySource,a1;
  1059.     move.l    myDestination,a2;
  1060.     move.l    #0x0780,d2;    /* hard coded row bytes value */
  1061.     move.l    #0x0138,d3;    /* hard coded row bytes value */
  1062.  
  1063.     /**
  1064.      ** The following four lines find the real address of the source
  1065.      ** icon.  They do this by following a simple formula.
  1066.      **  real_source = base + y Position * row bytes for Src + x Pos
  1067.      ** This result is placed into a1 as mentioned before.
  1068.      **/
  1069.     
  1070.     move.l    ySource,d0;
  1071.     mulu    d2,d0;
  1072.     add.l    d0,a1;
  1073.     add.l    xSource,a1;
  1074.  
  1075.     /** We follow the same formula for the destination address **/
  1076.     
  1077.     move.l    yDestination,d0;
  1078.     mulu    d3,d0;
  1079.     add.l    d0,a2;
  1080.     add.l    xDestination,a2;
  1081.  
  1082.     /**
  1083.      ** The following will seem a bit weird.  Why subtract #20 from the
  1084.      ** row byte values?  Keep in mind that as we are copying from the
  1085.      ** source to the destination, we are changing our pointers 
  1086.      ** (marching them across the icon).  When we are finished copying,
  1087.      ** we need to add the rowBytes-20 to get to the first byte of the
  1088.      ** the next row.  Note that 20 is iconSize-3.  Yeah, that should be
  1089.      ** that way in the code.  Just never bothered to change it.
  1090.      **/
  1091.  
  1092.     sub.l    #20,d2;
  1093.     sub.l    #20,d3;
  1094.     move.l    iconSize,d0;
  1095.  
  1096.     /** END OF PREPARTORY WORK **/
  1097.  
  1098.     /** And now you're ready to start the copy of each row of bytes **/
  1099.     
  1100.     @1   ;
  1101.     move.l    (a1)+,(a2)+;  /** Note that we are increasing our **/
  1102.     move.l    (a1)+,(a2)+;  /** pointers as go along here.      **/
  1103.     move.l    (a1)+,(a2)+;  /** Also note that we copy four     **/
  1104.     move.l    (a1)+,(a2)+;  /** bytes at a crack.  And we do it **/
  1105.     move.l    (a1)+,(a2)+;  /** six times.  For 24 bytes!       **/
  1106.     move.l    (a1),(a2);
  1107.         
  1108.     add.l    d2,a1; /** We need to jump down to the start of **/
  1109.     add.l    d3,a2; /** first pixel in the next row.         **/
  1110.     dbra    d0,@1; /** Branch until we are done **/
  1111.       
  1112.     movem.l    (sp)+, a1-a2/d0-d3  /* restore the registers */
  1113.   }
  1114.         
  1115.   return(1);
  1116. }
  1117. -- 
  1118. Eric E Johnson
  1119. ejohnson@netcom.netcom.com   
  1120.  
  1121. ---------------------------
  1122.  
  1123. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1124. Subject: Animation speed: here we go again...
  1125. Date: Sat, 12 Mar 1994 10:14:53 GMT
  1126. Organization: Demon Internet
  1127.  
  1128.  
  1129.  
  1130.         Now that we've exhausted the previous "animation speed" thread,
  1131. it's time to start another. :-)
  1132.  
  1133.         Having got my game code to run (what I considered to be) extremely
  1134. fast on my LC475, I thought I'd give it a whirl on our IIsi. Oh no!
  1135. Extremely slow animation speed. I know that the IIsi has very slow video,
  1136. but what was running at 60fps on an LC475 surely wouldn't be reduced to
  1137. less than 10fps on a IIsi.
  1138.  
  1139.         One of the things I thought might be causing the problem was that I
  1140. still might be having problems matching colour tables between the GWorld
  1141. and the window on-screen. I'm creating a normal colour window, and making
  1142. it the size of the screen (0,0,640,480). I'm not changing its palette in
  1143. any way. Then I'm using NewGWorld with a pixel depth of 0, which is meant
  1144. to optimise CopyBits calls with the screen. It's also meant to use the
  1145. colour table info and screen depth of the deepest monitor intercepting the
  1146. given rectangle. Since I've only got one monitor, this shouldn't be the
  1147. problem.
  1148.  
  1149.         However, response still seems to be unreasonbly sluggish on the
  1150. IIsi: whether its in gray scale or colour, the speed is disappointing.
  1151.  
  1152.         I believe Andrew Welch (hope I spelt your name right) reads this
  1153. area regularly: for Maelstrom, what is the animation speed like on low end
  1154. '030 Macs? I know you use heavily optimised assembler for your animation,
  1155. but I don't think that what I'm doing (CopyBits) should case such a
  1156. dramatic difference in animation speed. Is there any way to make CopyBits
  1157. completely ignore the colour table differences?
  1158.  
  1159.         Interesting ideas and suggestions are always appreciated.
  1160.  
  1161.  
  1162.  
  1163.         Alex
  1164.  
  1165. --
  1166. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1167.  
  1168. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  1169. AppleLink:              alex@metcalf.demon.co.uk@internet#
  1170. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  1171. Delphi:                 alex@metcalf.demon.co.uk@inet#
  1172. FirstClass:             alex@metcalf.demon.co.uk,Internet
  1173. Fax (UK):               (0570) 45636
  1174. Fax (US / Canada):      011 44 570 45636
  1175.  
  1176. +++++++++++++++++++++++++++
  1177.  
  1178. >From Arsenault_C@msm.cdx.mot.com (Chris Arsenault)
  1179. Date: Tue, 15 Mar 1994 12:29:41 -0500
  1180. Organization: Motorola Codex
  1181.  
  1182. In article <alex-120394101542@metcalf.demon.co.uk>,
  1183. alex@metcalf.demon.co.uk (Alex Metcalf) wrote:
  1184.  
  1185. >         However, response still seems to be unreasonbly sluggish on the
  1186. > IIsi: whether its in gray scale or colour, the speed is disappointing.
  1187.  
  1188. It sounds like you're okay with your color tables and CopyBits.
  1189.  
  1190. You might be running into a hardware problem.  There is no separate VRAM
  1191. for video on the IIsi (or IIci).  The IIsi has 1 MB on the motherboard, a
  1192. portion of which it uses as video RAM.   Not that I've investigated this,
  1193. but I remember reading that if the disk cache is boosted to occupy the
  1194. majority of motherboard RAM, then the video driver uses the SIMMs instead
  1195. and because the SIMM RAM doesn't have to deal with a bank switch wait you
  1196. can get approx. a 30% speed increase. 
  1197.  
  1198. The unfortunate part about this is that it's not really software
  1199. controllable - it's sort of up to the user.
  1200.  
  1201. Chris
  1202. -- 
  1203. #include <UsualLegalDisclaimers.h>
  1204.  
  1205. ---------------------------
  1206.  
  1207. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1208. Subject: Animation speed: improvement!
  1209. Date: Sun, 6 Mar 1994 23:16:59 GMT
  1210. Organization: Demon Internet
  1211.  
  1212.  
  1213.         I discovered something quite interesting this afternoon, which has
  1214. almost doubled the speed of the sprite animation in my game.
  1215.  
  1216.         Just a quick recap: my game copies the background (behind the
  1217. sprites) to a gworld, copies the sprites the same gworld, and then copies
  1218. that rectangle to the screen. In all, I was using 5 CopyBits for the
  1219. background, 5 CopyMasks for the sprites, and 5 CopyBits for copying to the
  1220. screen.
  1221.  
  1222.         Someone originally suggested that I combined all the rectangles
  1223. into a region and do a single CopyBits call. However, it turned out to be
  1224. slower! Go figure. I guess the individual CopyBits calls outstrip the
  1225. RectRgn and UnionRgn calls.
  1226.  
  1227.         This afternoon, I thought I'd give it another shot, in case I'd
  1228. missed something (or done a goofy error which was slowing things down).
  1229. This time, for no particular reason, I chose to combine the rectangles for
  1230. my CopyBits calls to the screen, and only do the single CopyBits call.
  1231.  
  1232.         I gave it a go and... WHOAH! Unbelievable speed increase (almost
  1233. 200%, 60 fps). It seems that CopyBits calls have much more overhead when
  1234. copying to the screen rather than copying between offscreen gworlds. I
  1235. guess this is because it checks screen depth, colour tables, etc. etc.
  1236.  
  1237.         To give you an idea of the speed increase: with the extra "time" I
  1238. had in my game loop, I was able to add another 4 sprites to the screen,
  1239. resulting in another 4 CopyBits calls and 4 CopyMask calls. Even then, it
  1240. was still faster than when I was using individual CopyBits calls to the
  1241. screen!
  1242.  
  1243.         So, I've found that the fastest way (with normal QuickDraw
  1244. routines) to make my animation work is to use individual CopyBits calls for
  1245. sprites between GWorlds, and then a single CopyBits call when it's all
  1246. ready to come to the screen.
  1247.  
  1248.         Here's my code snippet for the copy-to-screen, where gWorldRect is
  1249. 0,0,640,480 (full screen). I guess I don't need the second SetEmptyRgn
  1250. call.
  1251. (I use "t" to denote local variables).
  1252.  
  1253.  
  1254. // ------
  1255.  
  1256.         SetEmptyRgn (tCopyRgn);
  1257.         SetEmptyRgn (tRectRgn);
  1258.         
  1259.         tObject = gFirstObject;
  1260.         while (tObject != nil)
  1261.         {
  1262.                 if (!tObject->fVisible)
  1263.                 {
  1264.                         tObject = (GameObject) tObject->fNextObject;
  1265.                         continue;
  1266.                 }
  1267.                 
  1268.                 RectRgn (tRectRgn, &tObject->fAnimEnclosureRect);
  1269.                 UnionRgn (tRectRgn, tCopyRgn, tCopyRgn);
  1270.                 
  1271.                 tObject = (GameObject) tObject->fNextObject;
  1272.         }
  1273.         CopyBits ((BitMap *) *tPixMap[3], (BitMap *)
  1274. &gGameWindow->portPixMap,
  1275.                 &gWorldRect, &gWorldRect, srcCopy, tCopyRgn);
  1276.  
  1277. // ------
  1278.  
  1279.  
  1280.         On a slightly different topic: thanks to some code by Francis
  1281. (Francis H Schiffer 3rd), I was able to test my game loop to see where the
  1282. time was being used up. I knew that the copying of graphics takes up quite
  1283. a lot of time, but I'd never imagined that it tool 98% of the time!
  1284. Needless to say, that is what inspired me to have another go at improving
  1285. the CopyBits speed...
  1286.  
  1287.         Thanks again to all those who have given suggestions and code
  1288. snippets.... they've all been very useful (or at least, interesting!).
  1289.  
  1290.       
  1291.         Alex
  1292.  
  1293. --
  1294. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1295.  
  1296. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  1297. AppleLink:              alex@metcalf.demon.co.uk@internet#
  1298. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  1299. Delphi:                 alex@metcalf.demon.co.uk@inet#
  1300. FirstClass:             alex@metcalf.demon.co.uk,Internet
  1301. Fax (UK):               (0570) 45636
  1302. Fax (US / Canada):      011 44 570 45636
  1303.  
  1304. +++++++++++++++++++++++++++
  1305.  
  1306. >From u9119523@sys.uea.ac.uk (Graham Cox)
  1307. Date: Mon, 7 Mar 1994 11:23:35 GMT
  1308. Organization: School of Information Systems, UEA, Norwich
  1309.  
  1310. In article <alex-060394231740@metcalf.demon.co.uk>,
  1311. alex@metcalf.demon.co.uk (Alex Metcalf) wrote:
  1312.  
  1313. >         I discovered something quite interesting this afternoon, which has
  1314. > almost doubled the speed of the sprite animation in my game.
  1315. [SNIP!]
  1316.  
  1317. I also read somewhere that CopyBits with a mask region parameter is faster
  1318. than CopyMask- you might want to try this and see if it's true.
  1319.  
  1320. - ------------------------------------------------------------------------
  1321. Love & BSWK, Graham
  1322.  
  1323. -Everyone is entitled to their opinion, no matter how wrong they may be...
  1324. - ------------------------------------------------------------------------
  1325.  
  1326. +++++++++++++++++++++++++++
  1327.  
  1328. >From Tony Myles <tony.myles@3do.com>
  1329. Date: 7 Mar 1994 21:45:34 GMT
  1330. Organization: The 3DO Company
  1331.  
  1332. In article <alex-060394231740@metcalf.demon.co.uk> Alex Metcalf,
  1333. alex@metcalf.demon.co.uk writes:
  1334. [stuff deleted]
  1335. >        So, I've found that the fastest way (with normal QuickDraw
  1336. >routines) to make my animation work is to use individual CopyBits calls
  1337. for
  1338. >sprites between GWorlds, and then a single CopyBits call when it's all
  1339. >ready to come to the screen.
  1340. [stuff deleted]
  1341.  
  1342.  
  1343. Hey, thats cool. Hmm, just out of curiosity, what kind of Mac are you
  1344. running this on? I think I tried this a long time ago on a Q800, and it
  1345. was still slower than individual CopyBits calls to the screen. I'll have
  1346. to try it again though, I can't remember if I did it quite the way you
  1347. describe.
  1348.  
  1349. ...Tony
  1350. - ---------------------------------------------
  1351. Tony Myles             work: tony.myles@3do.com
  1352. The 3DO Company        home: suiryu@aol.com
  1353.  
  1354. +++++++++++++++++++++++++++
  1355.  
  1356. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1357. Date: Tue, 8 Mar 1994 13:38:19 GMT
  1358. Organization: Demon Internet
  1359.  
  1360. In article <2lg79u$lp8@mac_serv.3do.COM>, Tony Myles <tony.myles@3do.com>
  1361. wrote:
  1362.  
  1363. > In article <alex-060394231740@metcalf.demon.co.uk> Alex Metcalf,
  1364. > alex@metcalf.demon.co.uk writes:
  1365. > [stuff deleted]
  1366. > >        So, I've found that the fastest way (with normal QuickDraw
  1367. > >routines) to make my animation work is to use individual CopyBits calls
  1368. > for
  1369. > >sprites between GWorlds, and then a single CopyBits call when it's all
  1370. > >ready to come to the screen.
  1371. > [stuff deleted]
  1372. > Hey, thats cool. Hmm, just out of curiosity, what kind of Mac are you
  1373. > running this on?
  1374. > <snip>
  1375.  
  1376.         I'm running this on an LC475. I believe I've got all the colour tables
  1377. matched up correctly, and the source and destination rectangles are the
  1378. same (and the bit depths).
  1379.  
  1380.  
  1381.      Alex
  1382.  
  1383. --
  1384. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1385.  
  1386. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  1387. AppleLink:              alex@metcalf.demon.co.uk@internet#
  1388. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  1389. Delphi:                 alex@metcalf.demon.co.uk@inet#
  1390. FirstClass:             alex@metcalf.demon.co.uk,Internet
  1391. Fax (UK):               (0570) 45636
  1392. Fax (US / Canada):      011 44 570 45636
  1393.  
  1394. ---------------------------
  1395.  
  1396. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1397. Subject: Animation speed: more info
  1398. Date: Thu, 3 Mar 1994 00:25:29 GMT
  1399. Organization: Demon Internet
  1400.  
  1401.  
  1402.  
  1403.         Thanks to those who sent replies to me about improving the
  1404. animation speed in my game.
  1405.  
  1406.         I thought I'd be a little more specific in this description about
  1407. exactly what I'm doing, and (as always) I appreciate any feedback.
  1408.  
  1409.         I have an arcade game which I would like to run at 30 fps on a
  1410. 68030 Mac or better. It currently DOES run at 30 fps on my LC475, but only
  1411. just, and since that's on a 68LC040, I don't stand much chance of 30 fps on
  1412. an 030!
  1413.  
  1414.         In my game, there are 5 or 6 sprites always on the screen, each of
  1415. them 24 x 24 pixels in size. There are a number of calculations that I do
  1416. with them each time through my 2 tick "loop", but I'm assuming that I can
  1417. get the most speed increase by improving my animation code.
  1418.  
  1419.         I have four (yeah, four) offscreen gworlds, three of them in 8 bit
  1420. and 1 in 1 bit. I'll call the 1 bit one the "mask world", and the other
  1421. ones worlds "one", "two", and "three".
  1422.  
  1423.         In world one, I have all my sprite animations, placed there from a
  1424. PICT resource. In the mask world, I have the masks for the sprites, all
  1425. with exactly the same rectangles as the ones in world one.
  1426.  
  1427.         In world two, I have the background. I'm using world 3 as the
  1428. destination world for preparing to copy to the screen window.
  1429.  
  1430.         Every time through my loop, I first copy all the background rects
  1431. to world three, each one covering the previous location and the next
  1432. location of a sprite. This is done with a CopyBits call between worlds.
  1433. Then, I use CopyMask to copy the sprites (from world one and the mask
  1434. world) on to the background (world three). Finally, I copy each of the
  1435. background rects onto the screen, again using CopyBits.
  1436.  
  1437.         So in summary: I make 6 CopyBits calls between worlds, 6 CopyMask
  1438. calls between worlds, and 6 CopyBits calls from the world to the screen.
  1439. The rectangles being copied are no more than 32 x 32.
  1440.  
  1441.         How can I speed this up? I know that assembly programming would be
  1442. useful here, but hacking up an assembler copy between gworlds is a new
  1443. project to me. I would like to get the animation up to a speed where I can
  1444. do 30 fps on a 20mhz 68030, with slow screen redraw (a.k.a. our Mac IIsi).
  1445.  
  1446.         Thanks in advance for any help you can give me.
  1447.  
  1448.         
  1449.  
  1450.         Alex
  1451.  
  1452. --
  1453. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1454.  
  1455. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  1456. AppleLink:              alex@metcalf.demon.co.uk@internet#
  1457. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  1458. Delphi:                 alex@metcalf.demon.co.uk@inet#
  1459. FirstClass:             alex@metcalf.demon.co.uk,Internet
  1460. Fax (UK):               (0570) 45636
  1461. Fax (US / Canada):      011 44 570 45636
  1462.  
  1463. ---------------------------
  1464.  
  1465. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1466. Subject: Animation: the story continues...
  1467. Date: Sun, 6 Mar 1994 00:45:45 GMT
  1468. Organization: Demon Internet
  1469.  
  1470.  
  1471.         Just a quick update on my original question about speeding up
  1472. animation in my game code.
  1473.  
  1474.         Thanks to all those who gave suggestions for speeding things up:
  1475. I'm sorry I haven't had a chance to reply to each of you individually, but
  1476. I've had a huge amount of email (about 50 messages a day) and I'm finding
  1477. it hard to keep up. Along side this game, I'm working on about 5 or 6
  1478. different HyperCard external projects, and that mail (together with regular
  1479. newsletters and listserv discussions) makes life quite busy!
  1480.  
  1481.         Anyway, here are a few of the suggestions I've tried:
  1482.  
  1483.  
  1484. o  A suggestion was made that rather than CopyBits each of the sprites from
  1485. one world to another, I should combine them into a single region and make
  1486. only one CopyBits call.
  1487.  
  1488.    Here's the way I was doing it before:
  1489.  
  1490.  ...
  1491.         tObject = gFirstObject;
  1492.         while (tObject != nil)
  1493.         {
  1494.                 if (!tObject->fVisible)
  1495.                 {
  1496.                         tObject = (AppObject) tObject->fNextObject;
  1497.                         continue;
  1498.                 }
  1499.                 
  1500.                 CopyBits ((BitMap *) *tPixMap[2], (BitMap *) *tPixMap[3],
  1501.                         &tObject->fAnimEnclosureRect,
  1502.                         &tObject->fAnimEnclosureRect, srcCopy, nil);
  1503.                 tObject = (AppObject) tObject->fNextObject;
  1504.         }
  1505.  ...
  1506.  
  1507.    And here's the way I tried doing it, using only a single CopyBits call.
  1508. gWorldRect is the enclosing rectangle for the gworld.
  1509.  
  1510.  ...
  1511.         SetEmptyRgn (gCopyRgn);
  1512.         
  1513.         tObject = gFirstObject;
  1514.         while (tObject != nil)
  1515.         {
  1516.                 if (!tObject->fVisible)
  1517.                 {
  1518.                         tObject = (AppObject) tObject->fNextObject;
  1519.                         continue;
  1520.                 }
  1521.                 RectRgn (gRectRgn, &tObject->fAnimEnclosureRect);
  1522.                 UnionRgn (gCopyRgn, gRectRgn, gCopyRgn);
  1523.                 
  1524.                 tObject = (AppObject) tObject->fNextObject;
  1525.         }
  1526.         CopyBits ((BitMap *) *tPixMap[2], (BitMap *) *tPixMap[3],
  1527.                 &gWorldRect, &gWorldRect, srcCopy, gCopyRgn);
  1528.  ...
  1529.  
  1530.  
  1531.    The second section of code being slower than the first!
  1532.  
  1533.  
  1534. o  Someone else had suggested that rather than do a CopyMask call, I could
  1535. do a CopyBits call with a region (apparently being 60% faster). However,
  1536. while the mask for CopyMask masks out the source, the region for CopyBits
  1537. masks out the destination. Therefore, unless I can change the position of a
  1538. region each time I copy a sprite to the screen, I'm not sure the region
  1539. param in CopyBits will help.
  1540.  
  1541.  
  1542.         Thanks again for all those who have helped out: further suggestions
  1543. are always welcomed. I've learned a whole lot more about CopyBits and
  1544. CopyMask now!
  1545.  
  1546.         Thanks,
  1547.  
  1548.  
  1549.         Alex
  1550.  
  1551. --
  1552. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  1553.  
  1554. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  1555. AppleLink:              alex@metcalf.demon.co.uk@internet#
  1556. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  1557. Delphi:                 alex@metcalf.demon.co.uk@inet#
  1558. FirstClass:             alex@metcalf.demon.co.uk,Internet
  1559. Fax (UK):               (0570) 45636
  1560. Fax (US / Canada):      011 44 570 45636
  1561.  
  1562. ---------------------------
  1563.  
  1564. >From mprince@mail.trincoll.edu (Matthew Prince)
  1565. Subject: Blank Screen?
  1566. Date: Wed, 2 Mar 1994 16:52:07 GMT
  1567. Organization: Trinity College
  1568.  
  1569. I'm curious what exactly I need to do to blank the entire screen.  When
  1570. I try to create a window that is the entire size of the GrayRgn I am
  1571. able to cover up everything but the menu bar.  Is there then a
  1572. hideMenuBar command or something?  Also, when I PaintRect the area
  1573. defined by the GrayRgn to black a strip about the width of and right
  1574. below the menu bar is left white.  Any help would be appreciated.
  1575.  
  1576. Matthew Prince
  1577. mprince@mail.trincoll.edu
  1578.  
  1579. +++++++++++++++++++++++++++
  1580.  
  1581. >From kenlong@netcom.com (Ken Long)
  1582. Date: Thu, 3 Mar 1994 03:53:58 GMT
  1583. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  1584.  
  1585. Yes.  You hide your menuBar before you show your window.  That way the 
  1586. window is not 20 pixels down with the user's desktop textuer peeking over 
  1587. the top.
  1588.  
  1589. The "HideMenuBar" and "ShowMenuBar routines in NewShuttle 1.0d3 are about 
  1590. as common as they come.  I consulted 3 or 4 other working menu bar 
  1591. hide/show sources before finally deciding on that one.
  1592.  
  1593. That Shuttle source is kind of a cheapo.  It uses a "full screet window" 
  1594. as long as you use a 512 x 384 monitor.  Unless your window is based on 
  1595. screenBits.bounds, as apple points out, such specific sized main windows 
  1596. are user unfriendly.  But you also have to get fancy about positioning 
  1597. and/or sizing your window contents if you are going to make users with 
  1598. monitors over 14" happy, too.  But scaling your screen objects is not 
  1599. very viable - it usually makes them look odd.
  1600.  
  1601. You could do a monitor check and if it's larger than 14", don't hide the 
  1602. MBar and center the window.  Another trick, as in "Out of This World" is 
  1603. to have all black outside the window.  you could hide MBar, fill the rgn 
  1604. with black, and center your window within it.  That looks okay regardless 
  1605. of window size (wintin reason).  It that particular game, a click outside 
  1606. the action window updates the desktop, washing away the black.  A click 
  1607. back in the action window, blacks it out, again.  Nicely done.
  1608.  
  1609. There are probably more 14" monitors than any other.  The 12"s were 
  1610. popular when they first came out, but I wish I didn't get one.
  1611.  
  1612. Some people, if the program is thoroughly done, will make sets of sizes 
  1613. of program parts for different monitors.  The program would have to be 
  1614. worth it, and it would be done to increase the purchaser base potential.
  1615.  
  1616. Here's some hide/show MBar, in C:
  1617.  
  1618. RgnHandle mBarRgn;        // First we need to "get a holt of" the MBar.
  1619. short      *mBarHeightPtr;
  1620. short      oldMBarHeight;
  1621.  
  1622. void HideMenuBar (void) 
  1623. {
  1624.     Rect    mBarRect;
  1625.  
  1626.     GrayRgn = GetGrayRgn ();
  1627.     mBarHeightPtr = (short *)  0x0BAA;
  1628.     oldMBarHeight = *mBarHeightPtr;
  1629.     *mBarHeightPtr = 0;
  1630.     mBarRect = screenBits.bounds;
  1631.     mBarRect.bottom = mBarRect.top + oldMBarHeight;
  1632.     mBarRgn = NewRgn ();
  1633.     RectRgn (mBarRgn, &mBarRect);
  1634.     UnionRgn (GrayRgn, mBarRgn, GrayRgn);
  1635.     PaintOne (0L, mBarRgn);
  1636. }
  1637. void ShowMenuBar (void) 
  1638. {
  1639.     *mBarHeightPtr = oldMBarHeight;
  1640.     DiffRgn (GrayRgn, mBarRgn, GrayRgn);
  1641.     DisposeRgn (mBarRgn);
  1642. }
  1643.  
  1644. And here's how they are called:
  1645.  
  1646. main (void)
  1647. {
  1648.     Do_Init_Managers ();    // Gee!  What's this do?
  1649.     Set_Data_Array ();    // Some initializations.
  1650.     Init_Variables ();    // More init.
  1651.     HideMenuBar ();        // Take a little off the top.
  1652.     Set_Up_Window ();    // Get ready for showtime.
  1653.     HideCursor ();        // Get rid of "the fly."
  1654.     Main_Event_Loop ();    // ACTION!
  1655.     ShowCursor ();        // Action's over, bring back some control.
  1656.     ShowMenuBar ();        // Bring this back.
  1657.     DisposeWindow (&window);// Dump this, an the RAM in rode in on.
  1658.     ExitToShell ();        // Get back home, Loretta!
  1659. }                // We're in the Finder.
  1660.  
  1661. -Ken-
  1662.  
  1663. ---------------------------
  1664.  
  1665. >From rod@faceng.anu.edu.au
  1666. Subject: C code for scrollable application help
  1667. Date: 3 Mar 1994 22:19:21 GMT
  1668. Organization: Department of Engineering, ANU, Australia
  1669.  
  1670. I recall from somewhere that there exists some code example
  1671. for providing a scrollable text window designed for providing
  1672. help information (possibly with an indexing facility).  Can someone
  1673. direct me to the source (if it exists)?
  1674.  
  1675. My Freeware application has full Balloon help but I'd like to complement
  1676. it with information akin to readme files.
  1677.  
  1678. Thanks in advance.
  1679.  
  1680. Rod
  1681.  
  1682.  
  1683.  
  1684. +++++++++++++++++++++++++++
  1685.  
  1686. >From kidwell@wam.umd.edu (Christopher Bruce Kidwell)
  1687. Date: 4 Mar 1994 14:30:05 GMT
  1688. Organization: University of Maryland, College Park
  1689.  
  1690. In article <2l5npaINN75o@dubhe.anu.edu.au>,  <rod@faceng.anu.edu.au> wrote:
  1691. >I recall from somewhere that there exists some code example
  1692. >for providing a scrollable text window designed for providing
  1693. >help information (possibly with an indexing facility).  Can someone
  1694. >direct me to the source (if it exists)?
  1695.  
  1696. on mac.archive.umich.edu: /development/source/help.cpt.hqx
  1697. It uses a styled TEXT resource to display scrollable text with a popup
  1698. menu to jump to different sections. That version shows the help in a
  1699. modal dialog box -- I don't know if there's a moveable modal version
  1700. out there anywhere.
  1701.  
  1702. Chris Kidwell
  1703. kidwell@wam.umd.edu
  1704.  
  1705.  
  1706.  
  1707. +++++++++++++++++++++++++++
  1708.  
  1709. >From chuck@gte.com (Chuck Hoffman)
  1710. Date: Fri, 4 Mar 1994 15:19:53 GMT
  1711. Organization: GTE Laboratories
  1712.  
  1713. In article <2l5npaINN75o@dubhe.anu.edu.au>, rod@faceng.anu.edu.au wrote:
  1714.  
  1715. > I recall from somewhere that there exists some code example
  1716. > for providing a scrollable text window designed for providing
  1717. > help information (possibly with an indexing facility).  Can someone
  1718. > direct me to the source (if it exists)?
  1719. > My Freeware application has full Balloon help but I'd like to complement
  1720. > it with information akin to readme files.
  1721. > Thanks in advance.
  1722. > Rod
  1723.  
  1724. You might find the Help routines useful in the sample application Chassis
  1725. 6.0.  The text is simple, non-styled text.
  1726.  
  1727. The text and the selection list are both scrollable.
  1728.  
  1729. The window is not a dialog, and can remain open while other windows are in
  1730. use.
  1731.  
  1732. The text is kept in the resource fork.
  1733.  
  1734. The Help menu item is on the Apple menu.  In release 6.1 it will be moved
  1735. to the Help (baloon) menu.  (6.1 will also be AppleEvent aware.)
  1736.  
  1737. Chassis 6.0 is freeware.  It is available at mac.archive.umich.edu and its
  1738. mirror sites, also at CompuServe and America OnLine.  Chassis 6.0 is also
  1739. available directly from us at ftp.gte.com, file
  1740. /pub/chuck/Chassis_6.0.sea.hqx
  1741.  
  1742. DO NOT USE THE VERSION AT SUMEX-AIM.STANFORD.EDU.  Inexplicably, they never
  1743. posted the new version.  The one they have, 4.3 or so, is not 32-bit clean
  1744. and won't compile with THINK C 6.0.  (Don't ask me... I sent the new
  1745. version to them twice.)
  1746.  
  1747. -- 
  1748. Chuck Hoffman
  1749. GTE Laboratories, Waltham, MA, USA
  1750. 617-466-2131
  1751. - ------------------------------------------------
  1752. I'm not sure why we're here, but I am sure that
  1753. while we're here we're supposed to help each other.
  1754. - ------------------------------------------------
  1755.  
  1756. +++++++++++++++++++++++++++
  1757.  
  1758. >From Robert Hess <robert_hess@macweek.ziff.com>
  1759. Date: Wed, 9 Mar 1994 02:40:56 GMT
  1760. Organization: MacWEEK
  1761.  
  1762. In article <2l7gld$kgq@cville-srv.wam.umd.edu> Christopher Bruce Kidwell,
  1763. kidwell@wam.umd.edu writes:
  1764. >on mac.archive.umich.edu: /development/source/help.cpt.hqx
  1765. >It uses a styled TEXT resource to display scrollable text with a popup
  1766. >menu to jump to different sections. That version shows the help in a
  1767. >modal dialog box -- I don't know if there's a moveable modal version
  1768. >out there anywhere.
  1769.  
  1770. You!re thinking of James Walker!s !show_help!, version 2.0 of which
  1771. offers a
  1772. movable modal.
  1773.  
  1774. =======================================================================
  1775. ====
  1776. Robert Hess, WEEKgeek                        AppleLink: WNDZSX
  1777. MacWEEK                                      CompuServe: 72511,333
  1778. 301 Howard                                   America Online: MacWEEK
  1779. San Francisco, Calif. 94105                  MCI: RHESS
  1780. (415) 243-3576 days                          Internet:
  1781. (415) 243-3651 fax                             
  1782. robert_hess@macweek.ziff.com
  1783. (415) 647-5549 nights
  1784.               I speak for myself.  And sometimes not even that.
  1785. =======================================================================
  1786. ====
  1787.  
  1788. ---------------------------
  1789.  
  1790. >From mfi@i-link.com (MicroFrontier Inc.)
  1791. Subject: Can C be as fast as Assembler? (next...on the McLaughlin Group)
  1792. Date: 28 Feb 1994 09:37:13 -0600
  1793. Organization: I-Link, Ltd., Des Moines, IA, USA - 515/255-2754
  1794.  
  1795.  
  1796.  
  1797. OK, I've heard both sides of the story here...some developers say that C
  1798. can be as fast as assembler (or at least very, very close), provided it is
  1799. written well enough. Other say that C code doesn't get anywhere near the
  1800. speed of assembler, no matter how it's written.
  1801.  
  1802. Now, I would imagine that C can get closer to assembly depending on the
  1803. task that is being done....what tasks would those be?
  1804.  
  1805. What's the best way to optimize C?
  1806.  
  1807. And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  1808. produces the fastest C code (with all optimization turned on)? Which do
  1809. you think produces the best quality code (if being the fastest doesn't
  1810. make it the best quality by default)?
  1811.  
  1812. Please post responses to the net...I'm sure this is something we can all
  1813. benefit from. Also, please try to keep it civil. :-)
  1814.  
  1815.  
  1816.  
  1817. -kevin
  1818.  
  1819. +++++++++++++++++++++++++++
  1820.  
  1821. >From chyang@quip.eecs.umich.edu (Chung-Hsiung Yang)
  1822. Date: 28 Feb 1994 16:11:50 GMT
  1823. Organization: University of Michigan EECS Dept., Ann Arbor, MI
  1824.  
  1825. In article <2kt339$589@ilink1.i-link.com>, mfi@i-link.com (MicroFrontier Inc.) writes:
  1826. |> 
  1827. |> 
  1828. |> OK, I've heard both sides of the story here...some developers say that C
  1829. |> can be as fast as assembler (or at least very, very close), provided it is
  1830. |> written well enough. Other say that C code doesn't get anywhere near the
  1831. |> speed of assembler, no matter how it's written.
  1832. |> 
  1833. |> Now, I would imagine that C can get closer to assembly depending on the
  1834. |> task that is being done....what tasks would those be?
  1835. |> 
  1836. |> What's the best way to optimize C?
  1837.  
  1838.     I don't think this is really a good way to look at both sides of
  1839. the world.  I tend to agree that assembler will be faster than C generated
  1840. code because programming in assembler requires the programmer to optimize
  1841. (some what) the code as you go alone because you are dealing
  1842. with much lower semantics than C.  On the other hand, the level of optimization
  1843. one could do with C is really more dependent on the compiler itself.
  1844.  
  1845.     But look what you are doing here.  What do you want to do with 
  1846. assembler vs. C?  If you restrict yourself to the assembler world, then
  1847. you are limited to pretty small programs with pretty limited software
  1848. architecture.  Maybe you could write routines
  1849. for a small, but very fast computation that does for example some process
  1850. in digital signal processing.  Because of the overhead in C, you would 
  1851. probably not be able to achieve the speed that you could obtain with C.
  1852.  
  1853.     But imagine yourself writing a 100,000 line code in C.  Quite a
  1854. big project.  Imagin writing the same code in assembly, you will probably
  1855. have to write close to a million line or more.  When you get to a million
  1856. lines of code in assember, how do you optimize it?  It is a scary thought,
  1857. I wouldn't do it.  In this case I would rather depend on a well designed
  1858. C compiler to do the job.  In this case, I think for very big programs C
  1859. would very likely produce faster codes because there is no way for human
  1860. beings to program codes that big in assembly.  Also when you get to 
  1861. that programs that size, there are many tricks that one could play to
  1862. optimize the code than assembly because, the notion of a high level 
  1863. software architecture such as object oriented design just could not be
  1864. easily achieved by assembly.  (You could do it, but it will be very hard).
  1865.  
  1866.  
  1867. - Chung Yang
  1868.  
  1869. |> And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  1870. |> produces the fastest C code (with all optimization turned on)? Which do
  1871. |> you think produces the best quality code (if being the fastest doesn't
  1872. |> make it the best quality by default)?
  1873. |> 
  1874. |> Please post responses to the net...I'm sure this is something we can all
  1875. |> benefit from. Also, please try to keep it civil. :-)
  1876. |> 
  1877. |> 
  1878. |> 
  1879. |> -kevin
  1880.  
  1881. +++++++++++++++++++++++++++
  1882.  
  1883. >From mssmith@afterlife.ncsc.mil (M. Scott Smith)
  1884. Date: Mon, 28 Feb 1994 16:30:42 GMT
  1885. Organization: The Great Beyond
  1886.  
  1887. In article <2kt546$23o@zip.eecs.umich.edu> chyang@quip.eecs.umich.edu (Chung-Hsiung Yang) writes:
  1888. >In article <2kt339$589@ilink1.i-link.com>, mfi@i-link.com (MicroFrontier Inc.) writes:
  1889. >|> 
  1890. >|> 
  1891. >|> OK, I've heard both sides of the story here...some developers say that C
  1892. >|> can be as fast as assembler (or at least very, very close), provided it is
  1893. >|> written well enough. Other say that C code doesn't get anywhere near the
  1894. >|> speed of assembler, no matter how it's written.
  1895. >|> 
  1896. >|> Now, I would imagine that C can get closer to assembly depending on the
  1897. >|> task that is being done....what tasks would those be?
  1898. >|> 
  1899. >|> What's the best way to optimize C?
  1900.  
  1901.    Well, first, I'd say in many cases a lot of blame is put on the compiler
  1902. producing "unoptimized" code when the user could in fact be optimizing
  1903. their program.
  1904.  
  1905.    Meaning, often great speed increases can be seen by changing the way
  1906. your program does certain things.  If you do a sort, are you using a
  1907. bubble sort or a quicker sort?  Things like that.  Once you've done a
  1908. good job in that arena, then it comes time when you can benefit from
  1909. better code production.
  1910.  
  1911.    Most compilers (such as Think C) have a "dissassemble" option that
  1912. allow you to look at the assembly the compiler is producing.  This is
  1913. helpful if you know assembly; if you don't, it may not be too useful.
  1914. But if you can read assembly, you can see exactly how the compiler is
  1915. interpreting your code and try making modifications to your code so
  1916. that the resultant assembly is better.  Compilers are smart, but they're
  1917. not geniouses -- often switching two lines around will signal the compiler
  1918. to use some trick to make something much quicker.
  1919.  
  1920.    I wouldn't recommend writing in Assembly unless you absolutely need
  1921. to; that will be weighted yourself down with concrete bricks when you
  1922. want to take your program into the future.  The PowerPC is an excellent
  1923. case in point.  The programmers who are porting their applications in
  1924. two days are the ones who don't have any of their code in assembly.
  1925.  
  1926.    But a knowledge of 680x0 or PPC assembly is useful; again, you can
  1927. tweak your C code around so it results in better assembly production
  1928. with your compiler, without jeopardizing future compatibility.
  1929.  
  1930. >|> And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  1931. >|> produces the fastest C code (with all optimization turned on)? Which do
  1932. >|> you think produces the best quality code (if being the fastest doesn't
  1933. >|> make it the best quality by default)?
  1934.  
  1935.    I think this is impossible to say.  Each compiler is different, and
  1936. each one might produce better code in some places and not others.
  1937.  
  1938.    Unless one has obvious code generator flaws, they're all probably
  1939. pretty good.  Code optimization (on the compiler's part) is tricky stuff,
  1940. from what I understand.  Remember: the compiler basically just does the
  1941. "brute force" work of taking your C and transforming it into working,
  1942. equivalent assembly.  This doesn't require much "smarts" on the compiler's
  1943. part.
  1944.  
  1945.    To look at the C code, and to find tricks for performing the same
  1946. function with less instructions, takes great problem-solving skills and
  1947. insight which humans often have, but which is difficult to duplicate
  1948. in computers.
  1949.  
  1950.    Each compiler author will no doubt provide that "intelligence" in
  1951. their optimizers in different ways.  Each compiler probably knows
  1952. different tricks.  One routine of yours might result in lots of
  1953. tricks with compiler X, but none in compiler Y.  But with your next
  1954. routine the reverse might be true.
  1955.  
  1956.    I don't know how to define "best quality" in terms other than speed.
  1957. Presumably, a compiler is going to produce _100% working code_.  There's
  1958. no room for errors (on the compiler's part, anyway).  So you'd expect
  1959. any code a compiler produces to work.  The next criterion is "how quickly
  1960. does it work?"  This is where the optimization comes in.  I can't
  1961. really think of better ways to measure quality of code generation,
  1962. if you make the assumption that any code coming from a compiler isn't
  1963. going to have any bugs introduced by the compiler.  (That may not always
  1964. be a valid assumption.)
  1965.  
  1966. Just my thoughts..
  1967.  
  1968. Scott
  1969.  
  1970. - -
  1971. M. Scott Smith         (mssmith@afterlife.ncsc.mil)
  1972.  
  1973.   Macintosh developer.. Student.. Ski bum.  Eater of Kellog's Frosted Flakes.
  1974.  
  1975.      "Last stop for fuel on the information highway"
  1976.  
  1977.  
  1978. +++++++++++++++++++++++++++
  1979.  
  1980. >From neeri@iis.ee.ethz.ch (Matthias Neeracher)
  1981. Date: 28 Feb 94 18:05:12
  1982. Organization: Integrated Systems Laboratory, ETH, Zurich
  1983.  
  1984. In article <2kt339$589@ilink1.i-link.com>, mfi@i-link.com (MicroFrontier Inc.) writes:
  1985.  
  1986. > OK, I've heard both sides of the story here...
  1987.  
  1988. Really? I haven't seen a hardcore assembler advocate here in a long time.
  1989.  
  1990. > some developers say that C
  1991. > can be as fast as assembler (or at least very, very close), provided it is
  1992. > written well enough. Other say that C code doesn't get anywhere near the
  1993. > speed of assembler, no matter how it's written.
  1994.  
  1995. Assembler is much slower than C in several respects:
  1996.  
  1997.  - Almost all code (with a few exceptions) takes longer to write, debug, and
  1998.    maintain in Assembler. Note that for the same reasons, C++ is also faster
  1999.    than C, Eiffel is faster than C++, and Perl for some tasks is much faster
  2000.    than all of them.
  2001.  - You will find it easier to identify and rewrite speed critical parts in a C
  2002.    program than in an assembler program.
  2003.  - A C application compiled with an "Optimizing for PowerPC" compiler will
  2004.    run circles around your 680X0 assembler code.
  2005.    
  2006. > Now, I would imagine that C can get closer to assembly depending on the
  2007. > task that is being done....what tasks would those be?
  2008.  
  2009. Depends also a lot on the compiler and the target processor. The 680X0 is
  2010. a reasonable code generation target, and so is the PowerPC. In some ways, the
  2011. PowerPC will be easier, but new factors like instruction scheduling come into
  2012. play. I think assembly language progarmmers will have a harder time beating
  2013. compilers on PowerPCs, since instruction scheduling is rather hard to do in
  2014. one's head (Except if you are the infamous Mel, who programmed  rotating disk
  2015. memory machines).
  2016.  
  2017. > What's the best way to optimize C?
  2018.  
  2019. Use a good compiler. Profile. Rewrite critical sections. repeat.
  2020.  
  2021. > And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  2022. > produces the fastest C code (with all optimization turned on)?
  2023.                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2024.  
  2025. One problem I ahve with Mac C compilers is that at least for some of them,
  2026. turning on optimizaion is too dangerous to do for an entire program.
  2027.  
  2028. > Which do
  2029. > you think produces the best quality code (if being the fastest doesn't
  2030. > make it the best quality by default)?
  2031.  
  2032. I'd take a reliable compiler over a fast compiler or one producing fast code
  2033. anytime.
  2034.  
  2035. > Also, please try to keep it civil. :-)
  2036.  
  2037. With a topic like this??
  2038.  
  2039. Matthias
  2040.  
  2041. - ---
  2042. Matthias Neeracher                                      neeri@iis.ethz.ch
  2043.   "And I won this ribbon in a Degradation Contest at the Teheran
  2044.    meeting of Junkies Anonymous" -- William Burroughs, _The Naked Lunch_
  2045.  
  2046. +++++++++++++++++++++++++++
  2047.  
  2048. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  2049. Date: 1 Mar 1994 12:03:20 +0800
  2050. Organization: NCRPDA, Curtin University
  2051.  
  2052. mfi@i-link.com (MicroFrontier Inc.) writes:
  2053.  
  2054. >OK, I've heard both sides of the story here...some developers say that C
  2055. >can be as fast as assembler (or at least very, very close), provided it is
  2056. >written well enough. Other say that C code doesn't get anywhere near the
  2057. >speed of assembler, no matter how it's written.
  2058.  
  2059. C or Pascal produce about teh same quality code.  It's generally about
  2060. half the speed of reasonably tight assembly code (although an important
  2061. thing to remember before converting your code from C/Pascal to asm is
  2062. that while you might get a double speed imporvement, redesigning the 
  2063. *algorithm* used may get you orders of magnitude of imporvement, and also
  2064. asm can't be recompiled on the PPC to get you ~4 times speed improvement 
  2065. going native instead of interpreted.
  2066.  
  2067. >Now, I would imagine that C can get closer to assembly depending on the
  2068. >task that is being done....what tasks would those be?
  2069.  
  2070. Small, simple, processor intensive things can be done more more quickly
  2071. in asm (eg BlockMove, Character translation (ISO<->Mac, <crlf><-><cr>,
  2072. BinHex/UU translation, etc)).  Large things are better written in a high
  2073. level language for the reasons stated above (easier to improve the
  2074. algorithm, easier to compile on faster machines) (not to mention all the
  2075. other obvious advantages (portability (kinda ;-), maintenance (kinda ;-),
  2076. etc).
  2077.  
  2078. >What's the best way to optimize C?
  2079.  
  2080. Don't use any pointers.  Pointers screw up optimizing compilers.
  2081.  
  2082. >And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  2083. >produces the fastest C code (with all optimization turned on)? Which do
  2084. >you think produces the best quality code (if being the fastest doesn't
  2085. >make it the best quality by default)?
  2086.  
  2087. No idea, they are probably all withing 10% (as is Pascal, normally on
  2088. the faster side).
  2089.    Peter.
  2090. -- 
  2091. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  2092.  
  2093. +++++++++++++++++++++++++++
  2094.  
  2095. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  2096. Date: Mon, 28 Feb 1994 22:25:15 -0600
  2097. Organization: University of Illinois at Urbana-Champaign
  2098.  
  2099. In article <2kueq8$865@ncrpda.curtin.edu.au>, peter@ncrpda.curtin.edu.au
  2100. (Peter N Lewis) wrote:
  2101.  
  2102. >>What's the best way to optimize C?
  2103. >
  2104. >Don't use any pointers.  Pointers screw up optimizing compilers.
  2105.  
  2106. What?!?! Sometimes using pointers is the only way to get a really stupid
  2107. compiler to do register allocation and register loading properly.
  2108.  
  2109. pr
  2110. -- 
  2111. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  2112. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  2113. System manager - Cognitive Science Group, Beckman Institute, UIUC
  2114. Internet: resnick@cogsci.uiuc.edu
  2115.  
  2116. +++++++++++++++++++++++++++
  2117.  
  2118. >From ari@world.std.com (Ari I Halberstadt)
  2119. Date: Tue, 1 Mar 1994 07:17:57 GMT
  2120. Organization: The World Public Access UNIX, Brookline, MA
  2121.  
  2122. In article <NEERI.94Feb28180512@yggdrasil.ethz.ch>,
  2123. Matthias Neeracher <neeri@iis.ee.ethz.ch> wrote:
  2124. > - Almost all code (with a few exceptions) takes longer to write, debug, and
  2125. >   maintain in Assembler. Note that for the same reasons, C++ is also faster
  2126. >   than C, Eiffel is faster than C++, and Perl for some tasks is much faster
  2127. >   than all of them.
  2128.  
  2129. If only Eiffel were more widely available (like, for the mac), and a
  2130. bit cheaper for us poorer programmers. Five years ago I fell in love
  2131. with Eiffel, but it's still not on the mac (except for A/UX), which
  2132. makes it a bit slower than C or C++.
  2133. -- 
  2134. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  2135. "These beetles were long considered to be very rare because very few
  2136. entomologists look for beetles in the mountains, in winter, at night,
  2137. during snow storms." -- Purves W. K., et al, "Life: The Science of
  2138.  
  2139. +++++++++++++++++++++++++++
  2140.  
  2141. >From jim@brunner.wf.com (Jim Brunner)
  2142. Date: 28 Feb 94 14:57:34 GMT
  2143. Organization: (none)
  2144.  
  2145.  
  2146. In article <2kt339$589@ilink1.i-link.com>, you write:
  2147. > OK, I've heard both sides of the story here...some developers say that C
  2148. > can be as fast as assembler (or at least very, very close), provided it 
  2149. is
  2150. > written well enough. Other say that C code doesn't get anywhere near the
  2151. > speed of assembler, no matter how it's written.
  2152. > Now, I would imagine that C can get closer to assembly depending on the
  2153. > task that is being done....what tasks would those be?
  2154. > What's the best way to optimize C?
  2155.  
  2156. The best way to optimize ANY program in ANY language is to take a hard look 
  2157. at the algorithms in use.  For almost any program with noticable 
  2158. performance problems, 90% better speed is all in the algorithm.  It's only 
  2159. when you get down to those last few tweeks for fractions of a percent that 
  2160. assembler *might* make any difference.  (Of course, I'm talking in the 
  2161. general case - like the original poster.  There are, of course, 
  2162. exceptions.)
  2163.  
  2164. Try profiling your code.  Run your program with a profiler (like the one 
  2165. included with Think C) and find out where it's spending it's time.  Most 
  2166. likely, 90% of the time will be in 10% of the code.  Look at that 10% and 
  2167. ignore the rest.  Look at the algorithms first - searching a linked list 
  2168. instead of a binary tree?
  2169.  
  2170. Make a decision:  How many people does this affect, how critical is it?  If 
  2171. the program in question isn't very critical, it might be more cost 
  2172. effective to ignore the problem.  If not too many people use the program, 
  2173. it may be more cost effective to buy a faster machine.  Assembly language 
  2174. is expensive.  It's expensive in programmer time and maintenance cost.
  2175.  
  2176. Go further only for those few lines of highly critical code - realize that 
  2177. these changes are not necessarily beneficial across platforms.  Start by 
  2178. disassembling the code generated by the C compiler.  Take a look at how 
  2179. slight coding changes affect the generated code.
  2180.  
  2181. Only on highly critical sections of code (counting clock cycles here), go 
  2182. to assembler and hand code the critical section (if the compiler didn't do 
  2183. it well enough to begin with.
  2184.  
  2185. These days, assembler code is almost extinct.  I've seen it used recently 
  2186. on a small subroutine that was part of the firmware running on a DSP chip - 
  2187. there was a timing limitation in # of clock cycles.
  2188. - -
  2189. Jim Brunner (jim@brunner.wf.com)
  2190.  
  2191. +++++++++++++++++++++++++++
  2192.  
  2193. >From gregor@nrlfs1.nrl.navy.mil (joe gregor)
  2194. Date: Tue, 1 Mar 1994 14:29:37 GMT
  2195. Organization: NRL
  2196.  
  2197. In Article <2kueq8$865@ncrpda.curtin.edu.au>, peter@ncrpda.curtin.edu.au
  2198. (Peter N Lewis) wrote:
  2199.  
  2200. >C or Pascal produce about teh same quality code.  It's generally about
  2201. >half the speed of reasonably tight assembly code...
  2202.  
  2203. >>And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  2204. >>produces the fastest C code (with all optimization turned on)? Which do
  2205. >>you think produces the best quality code (if being the fastest doesn't
  2206. >>make it the best quality by default)?
  2207. >
  2208. >No idea, they are probably all withing 10% (as is Pascal, normally on
  2209. >the faster side).
  2210.  
  2211.     I had always heard/read that C was the fastest language next to asm.
  2212. I *never* heard/read that Pascal was even close, let alone faster. Please
  2213. identify your references so I may (re)educate myself.
  2214.  
  2215.     -- Joe
  2216. ________________________________________________________________________________
  2217.  
  2218.  Joseph Gregor                  |   
  2219.     gregor@ccf.nrl.navy.mil     |      THIS SPACE INTENTIONALLY LEFT BLANK.
  2220.        tmh@eng.umd.edu          |
  2221. ________________________________|_______________________________________________
  2222.  
  2223. +++++++++++++++++++++++++++
  2224.  
  2225. >From jwbaxter@olympus.net (John W. Baxter)
  2226. Date: Tue, 01 Mar 1994 08:35:48 -0800
  2227. Organization: Internet for the Olympic Peninsula
  2228.  
  2229. In article <9402281957344983@brunner.wf.com>, jim@brunner.wf.com (Jim
  2230. Brunner) wrote:
  2231.  
  2232. > Go further only for those few lines of highly critical code - realize that 
  2233. > these changes are not necessarily beneficial across platforms.
  2234.  
  2235. Keeping in mind that "across platforms" above in some cases includes
  2236. differences among the 68000, 68020, 68030, and 68040.  You may have to
  2237. decide which of those you want to target (probably 68040 these days, say I
  2238. who still runs a 68030), at the cost of hurting the others.
  2239.  
  2240. -- 
  2241. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2242.    jwbaxter@pt.olympus.net
  2243.  
  2244. +++++++++++++++++++++++++++
  2245.  
  2246. >From mmorgan@gpu.srv.ualberta.ca (Martin Morgan)
  2247. Date: 1 Mar 1994 17:31:22 GMT
  2248. Organization: University of Alberta
  2249.  
  2250. Peter N Lewis (peter@ncrpda.curtin.edu.au) wrote:
  2251. : mfi@i-link.com (MicroFrontier Inc.) writes:
  2252. : >What's the best way to optimize C?
  2253. : Don't use any pointers.  Pointers screw up optimizing compilers.
  2254.  
  2255. Is this true? Is it true in a more restricted sense, don't use pointers in
  2256. speed-critical sections of code?
  2257.  
  2258. Martin Morgan
  2259. University of Alberta
  2260.  
  2261.  
  2262. +++++++++++++++++++++++++++
  2263.  
  2264. >From nagle@netcom.com (John Nagle)
  2265. Date: Tue, 1 Mar 1994 18:40:47 GMT
  2266. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  2267.  
  2268. mfi@i-link.com (MicroFrontier Inc.) writes:
  2269. >OK, I've heard both sides of the story here...some developers say that C
  2270. >can be as fast as assembler (or at least very, very close), provided it is
  2271. >written well enough. Other say that C code doesn't get anywhere near the
  2272. >speed of assembler, no matter how it's written.
  2273.  
  2274.       Depends on the compiler.  Both MPW C and Symantec C++ are worse than,
  2275. say, mainframe FORTRAN compilers of the late 1960s.  Good compilers
  2276. for the 680x0 machines exist, but not on the Mac.  MetaWare High-C
  2277. is available for the 68000, but they market it to embedded systems
  2278. makers, not Macs.  The Sun compiler for the older 68000 Suns were
  2279. reasonably good as well, and one large CAD package for the Mac used
  2280. to be cross-compiled on a Sun to take advantage of this.
  2281.  
  2282.       I like to try compiling
  2283.  
  2284.         int i; char tab1[100]; tab2[100];
  2285.         for (i=0; i<100; i++) tab1[i] = tab2[i];
  2286.  
  2287. and see what the inner loop looks like.  Ideally, the inner loop
  2288. should have two instructions, but I've seen as many as 12.
  2289.  
  2290. Incidentally, using subscripts vs pointer incrementation does not make
  2291. much difference with most modern compilers.  Even SC++ gets this one
  2292. right.
  2293.  
  2294.       The big SC++ problem is really dumb register usage.  One sees
  2295. lots of unnecessary register-to-register moves in SC++ output.  The
  2296. compiler never seems to take full advantage of all the registers
  2297. available (it's a port of a compiler for Intel CPUs, which have 
  2298. fewer registers).  In the compiler-design world, using all the registers
  2299. effectively is generally considered a win even when not "optimizing", 
  2300. because it takes less time to figure out which register to use than
  2301. to generate the register-to-register moves and stack manipulation
  2302. required when doing it wrong.  The global optimizer does a good job, though, 
  2303. except when it makes mistakes.  
  2304.  
  2305.       MPW C has a better code generator but a weaker global optimizer.
  2306.  
  2307.       I tried this simple test case on a pre-release MetroWerks
  2308. compiler, and it generated OK, but not spectacular code.
  2309.  
  2310.       Still, if there was a compiler for the Mac that generated state of the
  2311. art optimized code, programs would be perhaps twice as fast in some cases,
  2312. and somewhat smaller.  
  2313.  
  2314.                     John Nagle
  2315.  
  2316.  
  2317. +++++++++++++++++++++++++++
  2318.  
  2319. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  2320. Date: 1 Mar 1994 23:13:52 GMT
  2321. Organization: Royal Institute of Technology, Stockholm, Sweden
  2322.  
  2323. >>>What's the best way to optimize C?
  2324.  
  2325. >>Don't use any pointers.  Pointers screw up optimizing compilers.
  2326.  
  2327. >What?!?! Sometimes using pointers is the only way to get a really stupid
  2328. >compiler to do register allocation and register loading properly.
  2329.  
  2330. Yes, but at the same time, pointers (and especially when assigned to
  2331. addresses of local variables) can limit more sophisticated compilers,
  2332. since they can't do a full analysis of where your pointer might point
  2333. and what short-cuts it can take.
  2334.  
  2335. -- 
  2336.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  2337.  
  2338.    Cookie Jar: Vanilla Yoghurt with Crushed Oreos.
  2339.  
  2340. +++++++++++++++++++++++++++
  2341.  
  2342. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  2343. Date: Tue, 01 Mar 1994 17:32:34 -0600
  2344. Organization: University of Illinois at Urbana-Champaign
  2345.  
  2346. In article <2l0i7g$o51@news.kth.se>, d88-jwa@mumrik.nada.kth.se (Jon Wtte)
  2347. wrote:
  2348.  
  2349. >>What?!?! Sometimes using pointers is the only way to get a really stupid
  2350. >>compiler to do register allocation and register loading properly.
  2351. >
  2352. >Yes, but at the same time, pointers (and especially when assigned to
  2353. >addresses of local variables) can limit more sophisticated compilers,
  2354. >since they can't do a full analysis of where your pointer might point
  2355. >and what short-cuts it can take.
  2356.  
  2357. Compilers are generally stupid. If you disassemble code resources you'll
  2358. see that MPW C is stupider than THINK C, but THINK C is pretty stupid too.
  2359. I am waiting for someone to release a compiler that does peep-hole
  2360. optimization. Does anyone by any chance know if MetroWorks does so?
  2361.  
  2362. Here's a rash claim (flames against my ignorance welcome): Stupid
  2363. compilers are why RISC processors do better than CISC processors. If
  2364. compilers were smart enough to take advantage of all of the interesting
  2365. addressing modes and instructions on CISC architectures, CISCs would
  2366. overall be faster at running programs than RISCs. (*Duck*)
  2367.  
  2368. pr
  2369. -- 
  2370. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  2371. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  2372. System manager - Cognitive Science Group, Beckman Institute, UIUC
  2373. Internet: resnick@cogsci.uiuc.edu
  2374.  
  2375. +++++++++++++++++++++++++++
  2376.  
  2377. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  2378. Date: 02 Mar 1994 01:25:16 GMT
  2379. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  2380.  
  2381. In article <2kvu5a$b06@quartz.ucs.ualberta.ca> mmorgan@gpu.srv.ualberta.ca (Martin Morgan) writes:
  2382.  
  2383.    Peter N Lewis (peter@ncrpda.curtin.edu.au) wrote:
  2384.    : mfi@i-link.com (MicroFrontier Inc.) writes:
  2385.    : >What's the best way to optimize C?
  2386.    : Don't use any pointers.  Pointers screw up optimizing compilers.
  2387.  
  2388.    Is this true? Is it true in a more restricted sense, don't use pointers in
  2389.    speed-critical sections of code?
  2390.  
  2391. using pointers does NOT directly result in slower code.  there are many
  2392. cases where pointers can be used to generate significantly optimized
  2393. code.
  2394.  
  2395. however, if you use pointers you should be aware of the fact that the
  2396. code optimizer now can make fewer assumptions about your code, and 
  2397. thus it may not be able to apply certain optimizations.
  2398.  
  2399. get a good book on compiler writing (eg: Aho, Sethi & Ullman) and
  2400. read the sections on optimizing.  understanding how optimizers work
  2401. will greatly aid your programming: you'll have a better understanding
  2402. of what the compiler can annd cannot do.
  2403.  
  2404.  
  2405. -gary j kacmarcik
  2406. platypus@curie.ces.cwru.edu
  2407.  
  2408.  
  2409. +++++++++++++++++++++++++++
  2410.  
  2411. >From siegel@netcom.com (Rich Siegel)
  2412. Date: Wed, 2 Mar 1994 05:41:38 GMT
  2413. Organization: Bare Bones Software
  2414.  
  2415. In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2416. >
  2417. >Compilers are generally stupid. If you disassemble code resources you'll
  2418. >see that MPW C is stupider than THINK C, but THINK C is pretty stupid too.
  2419. >I am waiting for someone to release a compiler that does peep-hole
  2420. >optimization. Does anyone by any chance know if MetroWorks does so?
  2421.  
  2422. Metrowerks does. So does THINK C. So does MPW C.
  2423.  
  2424. >Here's a rash claim (flames against my ignorance welcome): Stupid
  2425. >compilers are why RISC processors do better than CISC processors. If
  2426. >compilers were smart enough to take advantage of all of the interesting
  2427. >addressing modes and instructions on CISC architectures, CISCs would
  2428. >overall be faster at running programs than RISCs. (*Duck*)
  2429.  
  2430. I have a reality adjustment for you. On the 68020, many of the fancy
  2431. addressing modes are either a wash or are actually slower than an
  2432. equivalent sequence of instructions using 68000-only addressing modes.
  2433.  
  2434. R.
  2435.  
  2436. -- 
  2437. Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software
  2438. --> For information about BBEdit, finger bbedit@world.std.com <--
  2439.  
  2440. "He then proceeded to give a history of the universe, in real time."
  2441.  
  2442. +++++++++++++++++++++++++++
  2443.  
  2444. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  2445. Date: 2 Mar 1994 13:20:52 +0800
  2446. Organization: NCRPDA, Curtin University
  2447.  
  2448. >From: chewy@shell.portal.com (Paul Snively)
  2449. >...
  2450. >q = *p++;
  2451. >...
  2452. >q = *p++;
  2453. >...
  2454. >
  2455. >Note that the above code features common subexpressions (in fact, for
  2456.  
  2457. No, they are not cse's.  To be eleigable for cse elemination, the 
  2458. expression must not have any side effects.  I'd quote chapter and verse
  2459. out of the Dragon book, but I don't have it handy.
  2460.  
  2461. >The moral of the story is twofold: a) try to write clean, readable code
  2462. >that doesn't rely on nasty compound functions, especially with
  2463. >side-effects; and b) know thy optimizer.  If you need help, disassemble
  2464. >the code and see what your optimizer is doing behind your back.
  2465.  
  2466. No, a) is certainly true, but b) should not be.  The optimizer should
  2467. never change the way your program behaves - if it does, either the optimizer
  2468. is broken (like the THINK C optimizer), or your program is broken.
  2469.  
  2470. >From: gregor@nrlfs1.nrl.navy.mil (joe gregor)
  2471.  
  2472. >>No idea, they are probably all withing 10% (as is Pascal, normally on
  2473. >>the faster side).
  2474.  
  2475. >    I had always heard/read that C was the fastest language next to asm.
  2476. >I *never* heard/read that Pascal was even close, let alone faster. Please
  2477. >identify your references so I may (re)educate myself.
  2478.  
  2479. You've probably heard thousands of people tell you PCs are better than Macs.
  2480.  
  2481. Try it and see for yourself.  Pascal compilers will generally produce faster
  2482. code than C compilers with equivalent source.  Obviously, compilers vary
  2483. a great deal, but the above is generally true.  I wouldn't worry though,
  2484. I expect the next generation of compilers will make C faster than Pascal,
  2485. since Pascal compilers will get a lot less work done on them.  Of course,
  2486. then everyone will be using C++ and efficiency will be thrown right out
  2487. the window, but such is life ;-)
  2488.  
  2489. >From: mmorgan@gpu.srv.ualberta.ca (Martin Morgan)
  2490.  
  2491. >: Don't use any pointers.  Pointers screw up optimizing compilers.
  2492. >
  2493. >Is this true? Is it true in a more restricted sense, don't use pointers in
  2494. >speed-critical sections of code?
  2495.  
  2496. What I said is true, in that pointers screw up most really clever high
  2497. level optimizations because the compiler has an impossible task
  2498. of figuring out what you're doing.  For example, if you do this:
  2499.  
  2500. x = 5;
  2501. for i:=1 to 100 do
  2502.   arr[i] = 0;
  2503. end-for;
  2504. y = x;
  2505.  
  2506. (equivalent in C or Pascal).  It is easy for the compiler to know that
  2507. x has remained unchanged, that i is now undefined (and thus the
  2508. register can be reused), that the array has been modified, that i
  2509. is always between 1 and 100 and so no range checking needs to be done,
  2510. that y can be assigned 5 directly, etc.
  2511.  
  2512. If you instead do this:
  2513.  
  2514. x=5;
  2515. i=100;
  2516. p = @arr[1];
  2517. while (i>0) do
  2518.   *p++ = 0;
  2519.   i--;
  2520. end-while
  2521. y = x;
  2522.  
  2523. Now it is nearly impossible for the compiler to determine any of that.
  2524. It has to be really clever to figure out that p only ever points to
  2525. the array arr (a compiler would probably be allowed to assume this 
  2526. though, since it is undefined what happens if you increment a ptr outside
  2527. of the area it started in).  If the compiler can't figure that out, then
  2528. all variables must be in memory (not registers) and all are potentially
  2529. modified, so none of the optimizations above are available.
  2530.  
  2531. Of course I wouldn't worry about this either, since most compilers don't
  2532. do very much in the way of clever optimizing (and when they try, they 
  2533. usually screw it up)...
  2534.    Peter.
  2535. -- 
  2536. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  2537.  
  2538. +++++++++++++++++++++++++++
  2539.  
  2540. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  2541. Date: Wed, 02 Mar 1994 00:51:17 -0600
  2542. Organization: University of Illinois at Urbana-Champaign
  2543.  
  2544. In article <siegelCM0vtF.9F@netcom.com>, siegel@netcom.com (Rich Siegel) wrote:
  2545.  
  2546. >In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2547. >>
  2548. >>Compilers are generally stupid. If you disassemble code resources you'll
  2549. >>see that MPW C is stupider than THINK C, but THINK C is pretty stupid too.
  2550. >>I am waiting for someone to release a compiler that does peep-hole
  2551. >>optimization. Does anyone by any chance know if MetroWorks does so?
  2552. >
  2553. >Metrowerks does. So does THINK C. So does MPW C.
  2554.  
  2555. Surely you're kidding. I've seen MPW C move things back and forth between
  2556. the same two registers (or worse, to and from the stack) oodles of times
  2557. in a series of instructions with no other side effects. THINK C constantly
  2558. does 'MOVE.L (A7)+,D3' followed by a 'TST.L D3' followed by a branch on
  2559. condition code. And I've never seen either of them generate a DBcc
  2560. instruction, even when I force feed it; I have lots of code for which
  2561. THINK C generates:
  2562.  
  2563.     SUBQ.W #$1,D3
  2564.     CMPI.W #$FFFF,D3
  2565.     BNE.S  *-$000C
  2566.  
  2567. What *are* they looking for if not these kinds of things?
  2568.  
  2569. As for the RISC/CISC argument I started, I've gotten lots of really cool
  2570. mail in response, some in support and some against, but almost all of it
  2571. saying, "It's a lot more complicated than you think." I figured as much,
  2572. but I do thank everyone for their comments; I have learned a lot in the
  2573. process.
  2574.  
  2575. pr
  2576. -- 
  2577. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  2578. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  2579. System manager - Cognitive Science Group, Beckman Institute, UIUC
  2580. Internet: resnick@cogsci.uiuc.edu
  2581.  
  2582. +++++++++++++++++++++++++++
  2583.  
  2584. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  2585. Date: 2 Mar 1994 10:32:23 GMT
  2586. Organization: Royal Institute of Technology, Stockholm, Sweden
  2587.  
  2588. >I don't have my ANSI reference in front of me, but I distinctly recall
  2589. >my shock upon reading something in it that made it quite clear that the
  2590. >semantics of your program could differ between unoptimized and
  2591. >optimized versions of your code.
  2592.  
  2593. So far so good.
  2594.  
  2595. >To give just one obvious example of how this could happen, consider a
  2596. >function that uses a pointer p, and contains code like this:
  2597.  
  2598. >q = *p++;
  2599. >q = *p++;
  2600.  
  2601. >let's say I compile this code without Common Subexpression Elimination.
  2602. > The pointer gets incremented twice, which is probably what the author
  2603. >had in mind.  But if I compile with Common Subexpression Elimination
  2604. >on, the compiler is completely free to evaluate the p++ once and stick
  2605. >the result in a register.  Oops.
  2606.  
  2607. No, that's NOT legal, since this has a very well-defined semantic
  2608. meaning. What the compiler CAN do, is change its behaviour for
  2609. UNDEFINED cases, such as:
  2610.  
  2611.     foo ( q ++ , q ++ ) ;
  2612.  
  2613. Where foo might be called as foo ( 0 , 1 ) or foo ( 1 , 0 ) depending
  2614. on moon phase. Anyway, since your program shouldn't be relying on
  2615. such UNDEFINED behaviour, the above allowance really isn't a problem.
  2616.  
  2617. And since we all validate our code and use ASSERTs everywhere and
  2618. step through it at the instruction level to verify it works right
  2619. after we wrote it (using all available documentation) this group
  2620. shouldn't have any "help me with my bug" questions either :-) :-)
  2621.  
  2622. -- 
  2623.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  2624.   "It was, in fact, cool as all get-out.  Fortunately it was a little
  2625.    too late (historically speaking) to be groovy."
  2626.                      -- Dennis Pelton
  2627.  
  2628. +++++++++++++++++++++++++++
  2629.  
  2630. >From infosafe@panix.com (Infosafe Systems)
  2631. Date: 2 Mar 1994 11:28:02 -0500
  2632. Organization: PANIX Public Access Internet and Unix, NYC
  2633.  
  2634. In article <siegelCM0vtF.9F@netcom.com>, Rich Siegel <siegel@netcom.com> wrote:
  2635. >In article <resnick-010394173234@colt-17.slip.uiuc.edu>
  2636.  resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2637. >>Here's a rash claim (flames against my ignorance welcome): Stupid
  2638.                                     ^^^^^^
  2639. >>compilers are why RISC processors do better than CISC processors. If
  2640.             ^^^ ^^^ ^^^^            ^^ ^^^^^^ ^^^^ ^^^^
  2641. >>compilers were smart enough to take advantage of all of the interesting
  2642. >>addressing modes and instructions on CISC architectures, CISCs would
  2643. >>overall be faster at running programs than RISCs. (*Duck*)
  2644.  
  2645. I'm no expert but perhaps someone here could help me out.  A few months
  2646. ago I read a longish article in Byte? (I will post the reference 
  2647. tomorrow when I am in work, if anyone is interested) about the greatness
  2648. of the MPC chip.
  2649.  
  2650. One of the topics it discussed in detail was the fact that RISC chips have
  2651. become popular, and more powerful than CISC chips for a bunch of reasons.
  2652. These included fixed instruction length to eliminate bubbles in the 
  2653. pipeline, faster instruction decode because you don't have to spend time
  2654. figuring out how long your instruction is, etc.
  2655.  
  2656. The last point that they made was that RISC has "come out on top" *because*
  2657. of improvements in compiler technology.  The article said that optimizers 
  2658. were able to make better use of RISC instructions than CISC instructions,
  2659. and this has been one of the motivating forces in developing RISC chips
  2660. for workstations, where you have *good* compilers ;-)
  2661.  
  2662. Opinions?  Let the flames begin!
  2663.  
  2664. (Again, I will post the article and a better summary, if anyone is interested)
  2665.  
  2666. Bradford Smith
  2667.  
  2668.  
  2669.  
  2670. +++++++++++++++++++++++++++
  2671.  
  2672. >From siegel@netcom.com (Rich Siegel)
  2673. Date: Wed, 2 Mar 1994 16:06:46 GMT
  2674. Organization: Bare Bones Software
  2675.  
  2676. In article <resnick-020394005117@colt-42.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2677. >In article <siegelCM0vtF.9F@netcom.com>, siegel@netcom.com (Rich Siegel) wrote:
  2678. >
  2679. >>In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2680. >>>
  2681. >>>Compilers are generally stupid. If you disassemble code resources you'll
  2682. >>>see that MPW C is stupider than THINK C, but THINK C is pretty stupid too.
  2683. >>>I am waiting for someone to release a compiler that does peep-hole
  2684. >>>optimization. Does anyone by any chance know if MetroWorks does so?
  2685. >>
  2686. >>Metrowerks does. So does THINK C. So does MPW C.
  2687. >
  2688. >Surely you're kidding. I've seen MPW C move things back and forth between
  2689. >the same two registers (or worse, to and from the stack) oodles of times
  2690. >in a series of instructions with no other side effects. THINK C constantly
  2691. >does 'MOVE.L (A7)+,D3' followed by a 'TST.L D3' followed by a branch on
  2692. >condition code. And I've never seen either of them generate a DBcc
  2693. >instruction, even when I force feed it; I have lots of code for which
  2694. >THINK C generates:
  2695. >
  2696. >    SUBQ.W #$1,D3
  2697. >    CMPI.W #$FFFF,D3
  2698. >    BNE.S  *-$000C
  2699. >
  2700. >What *are* they looking for if not these kinds of things?
  2701.  
  2702. I'm not kidding, and don't call me Shirley. :-) Don't confuse
  2703. instruction selection and target analysis with peepholing, and DBRA is
  2704. not a cure-all.  One thing that THINK C (and THINK Pascal) do pretty
  2705. well is branch-and-loop optimization (a "peephole" operation).
  2706.  
  2707. All of the above-mentioned compilers do -some- peepholing. It may not
  2708. be as thorough as you might like it, but it's done.
  2709.  
  2710. R.
  2711. -- 
  2712. Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software
  2713. --> For information about BBEdit, finger bbedit@world.std.com <--
  2714.  
  2715. "...yeah, I inhaled, and then I drank the bong water. So what're
  2716. you gonna do about it?" - Dennis Miller, on Bill Clinton
  2717.  
  2718. +++++++++++++++++++++++++++
  2719.  
  2720. >From ari@world.std.com (Ari I Halberstadt)
  2721. Date: Wed, 2 Mar 1994 17:00:16 GMT
  2722. Organization: The World Public Access UNIX, Brookline, MA
  2723.  
  2724. In article <resnick-020394005117@colt-42.slip.uiuc.edu>,
  2725. Pete Resnick <resnick@cogsci.uiuc.edu> wrote:
  2726. >condition code. And I've never seen either of them generate a DBcc
  2727. >instruction, even when I force feed it; I have lots of code for which
  2728. >THINK C generates:
  2729. >
  2730. >    SUBQ.W #$1,D3
  2731. >    CMPI.W #$FFFF,D3
  2732. >    BNE.S  *-$000C
  2733. >
  2734. >What *are* they looking for if not these kinds of things?
  2735.  
  2736. Try structure assignment in THINK C. The structure has to be big
  2737. enough, or the compiler will just use word or long word move
  2738. instructions. Here's an example of a DBF instruction:
  2739.  
  2740. static void x(void)
  2741. {
  2742.     struct { long a, b, c, d, e, f, g; } a, b;
  2743.     
  2744.     a = b;
  2745. }
  2746.  
  2747. x:
  2748. 00000000        LINK      A6,#$FFC8
  2749. 00000004        LEA       $FFE4(A6),A0
  2750. 00000008        LEA       $FFC8(A6),A1
  2751. 0000000C        MOVEQ     #$06,D0
  2752. 0000000E        MOVE.L    (A1)+,(A0)+
  2753. 00000010        DBF       D0,*-$0002     ; 0000000E
  2754. 00000014        UNLK      A6
  2755. 00000016        RTS
  2756. 0000001C
  2757.  
  2758. -- 
  2759. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  2760. "These beetles were long considered to be very rare because very few
  2761. entomologists look for beetles in the mountains, in winter, at night,
  2762. during snow storms." -- Purves W. K., et al, "Life: The Science of
  2763.  
  2764. +++++++++++++++++++++++++++
  2765.  
  2766. >From jwbaxter@olympus.net (John W. Baxter)
  2767. Date: Wed, 02 Mar 1994 10:03:00 -0800
  2768. Organization: Internet for the Olympic Peninsula
  2769.  
  2770. In article <2l2eqi$j40@panix2.panix.com>, infosafe@panix.com (Infosafe
  2771. Systems) wrote:
  2772.  
  2773. > I'm no expert but perhaps someone here could help me out.  A few months
  2774. > ago I read a longish article in Byte? (I will post the reference 
  2775. > tomorrow when I am in work, if anyone is interested) about the greatness
  2776. > of the MPC chip.
  2777. > One of the topics it discussed in detail was the fact that RISC chips have
  2778. > become popular, and more powerful than CISC chips for a bunch of reasons.
  2779. > These included fixed instruction length to eliminate bubbles in the 
  2780. > pipeline, faster instruction decode because you don't have to spend time
  2781. > figuring out how long your instruction is, etc.
  2782. > The last point that they made was that RISC has "come out on top" *because*
  2783. > of improvements in compiler technology.  The article said that optimizers 
  2784. > were able to make better use of RISC instructions than CISC instructions,
  2785. > and this has been one of the motivating forces in developing RISC chips
  2786. > for workstations, where you have *good* compilers ;-)
  2787.  
  2788. I've been around these crazy machines since around 1959 (more like 1952 if
  2789. I get to count helping mother with her "homework" with her computer usage
  2790. at JPL (she used IBM 650, ElectroData <<became part of Burroughs>> #1, IBM
  2791. 704)).
  2792.  
  2793. There have been periodic waves of RISCness, followed by retreats to
  2794. CISCness.  But the R is gradually winning...each retreat to the C direction
  2795. goes a little less far.
  2796.  
  2797. I'm beginning to thing that the current RISC wave is the real thing, and
  2798. that there won't be much retreat.  And I tend to agree that the advances in
  2799. compiler technology are a major reason why RISC may well happen this time.
  2800.  
  2801. In any case, as viewed from the late 1950s, everything we run today is
  2802. RISC.  Consider the NCR 304:  3-address instructions (add A to B putting
  2803. the result in C).  One of the interesting single machine instructions was
  2804. "write-copy-read":  write this record to that tape, read records from that
  2805. other tape and copy them to that tape until one has a key which matches
  2806. this test, and give me the matching record.  Absolutely perfect for
  2807. father-son file updates, which aren't done much any more.
  2808.  
  2809. The 304 also had single instruction in-memory sorts and merges.
  2810. -- 
  2811. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2812.    jwbaxter@pt.olympus.net
  2813.  
  2814. +++++++++++++++++++++++++++
  2815.  
  2816. >From mxmora@unix.sri.com (Matt Mora)
  2817. Date: 2 Mar 1994 11:10:40 -0800
  2818. Organization: SRI International, Menlo Park, CA
  2819.  
  2820. In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2821.  
  2822. >Here's a rash claim (flames against my ignorance welcome): Stupid
  2823. >compilers are why RISC processors do better than CISC processors. If
  2824. >compilers were smart enough to take advantage of all of the interesting
  2825. >addressing modes and instructions on CISC architectures, CISCs would
  2826. >overall be faster at running programs than RISCs. (*Duck*)
  2827.  
  2828. I don't think could be possible. Even though its called RISC the PowerPC
  2829. chip has more instructions than the 68020 or so I've read. Its the
  2830. complexity of the instruction that matters. An instuction on a RISC takes at 
  2831. max 5 clocks, but on a CISC who knows how long a certain intruction
  2832. will take. There goes your pipelining. 
  2833.  
  2834. The beauty of RISC is its simplicity. With few transistors and less
  2835. logic, its easy to get faster CPU speeds. That's why even before the
  2836. first PowerPc mac shipped, its already be upgraded from 66 mhz to 80 mhz.
  2837. A slower running CISC will never be able to keep up. Remember the 32k
  2838. of on chip cache takes up a big chuck of the die size. Without the cache
  2839. the die would be even smaller. (but slower) CISC is doomed because
  2840. the art of writing tight fast code is becoming obsolete. If compiler
  2841. writers won't do it why should we. Image how fast things would be on RISC
  2842. with hand tuned assembly.
  2843.  
  2844.  
  2845.  
  2846.  
  2847. Xavier
  2848.  
  2849.  
  2850.  
  2851. -- 
  2852. ___________________________________________________________
  2853. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  2854. SRI International                       mxmora@unix.sri.com
  2855. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  2856.  
  2857. +++++++++++++++++++++++++++
  2858.  
  2859. >From nagle@netcom.com (John Nagle)
  2860. Date: Wed, 2 Mar 1994 19:30:41 GMT
  2861. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  2862.  
  2863. siegel@netcom.com (Rich Siegel) writes:
  2864. >In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2865. >>Compilers are generally stupid. If you disassemble code resources you'll
  2866. >>see that MPW C is stupider than THINK C, but THINK C is pretty stupid too.
  2867. >>I am waiting for someone to release a compiler that does peep-hole
  2868. >>optimization. Does anyone by any chance know if MetroWorks does so?
  2869.  
  2870. >Metrowerks does. So does THINK C. So does MPW C.
  2871.  
  2872.       But SC++ doesn't, judging from the code.
  2873.  
  2874. >>Here's a rash claim (flames against my ignorance welcome): Stupid
  2875. >>compilers are why RISC processors do better than CISC processors. If
  2876. >>compilers were smart enough to take advantage of all of the interesting
  2877. >>addressing modes and instructions on CISC architectures, CISCs would
  2878. >>overall be faster at running programs than RISCs. (*Duck*)
  2879.  
  2880. >I have a reality adjustment for you. On the 68020, many of the fancy
  2881. >addressing modes are either a wash or are actually slower than an
  2882. >equivalent sequence of instructions using 68000-only addressing modes.
  2883.  
  2884.       That's a problem with many machines with variable-length
  2885. instructions.  Check the timings for the 68030 and '040, though;
  2886. the ratios get better as you throw more transistors at the problem.
  2887.  
  2888.                           John Nagle
  2889.  
  2890. +++++++++++++++++++++++++++
  2891.  
  2892. >From jvp@tools1.ee.iastate.edu (Jim Van Peursem)
  2893. Date: 2 Mar 94 21:24:34 GMT
  2894. Organization: Iowa State University, Ames, Iowa
  2895.  
  2896. In <2l2obg$fca@unix.sri.com> mxmora@unix.sri.com (Matt Mora) writes:
  2897.  
  2898. >In article <resnick-010394173234@colt-17.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  2899.  
  2900. >>Here's a rash claim (flames against my ignorance welcome): Stupid
  2901. >>compilers are why RISC processors do better than CISC processors. If
  2902. >>compilers were smart enough to take advantage of all of the interesting
  2903. >>addressing modes and instructions on CISC architectures, CISCs would
  2904. >>overall be faster at running programs than RISCs. (*Duck*)
  2905.  
  2906. >I don't think could be possible. Even though its called RISC the PowerPC
  2907. >chip has more instructions than the 68020 or so I've read. Its the
  2908. >complexity of the instruction that matters. An instuction on a RISC takes at 
  2909. >max 5 clocks, but on a CISC who knows how long a certain intruction
  2910. >will take. There goes your pipelining. 
  2911.  
  2912.   Ah yes, the wandering definition of RISC. I saw a nice summary of
  2913. what RISC means in comp.arch awhile back. It's more a function of
  2914. cycles-per-instruction and number of registers, etc than the number
  2915. of instructions supported.
  2916.  
  2917.   I agree with Pete that originally, RISC was driven by the fact that
  2918. most compilers simply didn't support the complex instructions in some
  2919. chips. But more accurately, some complex instructions in some chips were
  2920. slower than their counter-part simple instructions to perform the same
  2921. task. The VAX had several of these as I recall. Anyway, your definition
  2922. of RISC taking a max 5 clock cycles is wrong. That depends on the depth
  2923. of the pipe and other factors.
  2924.  
  2925. >The beauty of RISC is its simplicity. With few transistors and less
  2926. >logic, its easy to get faster CPU speeds. That's why even before the
  2927. >first PowerPc mac shipped, its already be upgraded from 66 mhz to 80 mhz.
  2928.  
  2929.   But these days, the RISC processors have around the same number of
  2930. transistors as their CISC counterparts. It's more a function of the
  2931. regularity of the instructions. Since all instructions are the same
  2932. size, and decode the same, it's easy to pipeline them and keep the
  2933. pipe full.
  2934.  
  2935.   I say the reason RISC is winning the game now is because of the
  2936. advancements in both the pipelines and compilers.
  2937.  
  2938. >Image how fast things would be on RISC
  2939. >with hand tuned assembly.
  2940.  
  2941.   It would be slower. :) Remembering all of the pipeline hazards
  2942. by hand is very complex. A compiler can do a much better job of
  2943. these kinds of scheduling issues for any reasonably sized routine.
  2944.  
  2945. +---------------------------------------------------------------+
  2946. | Jim Van Peursem - Ph.D. Candidate - Ham Radio -> KE0PH        |
  2947. | Department of Electrical Engineering and Computer Engineering |
  2948. | Iowa State University - Ames, IA 50011 : (515) 294-8339       |
  2949. | internet - jvp@iastate.edu  -or-  jvp@cpre1.ee.iastate.edu    |
  2950. +---------------------------------------------------------------+
  2951.  
  2952. +++++++++++++++++++++++++++
  2953.  
  2954. >From jim@brunner.wf.com (Jim Brunner)
  2955. Date: 2 Mar 94 02:57:28 GMT
  2956. Organization: (none)
  2957.  
  2958.  
  2959. In article <resnick-010394173234@colt-17.slip.uiuc.edu>, you write:
  2960. > Here's a rash claim (flames against my ignorance welcome): Stupid
  2961. > compilers are why RISC processors do better than CISC processors. If
  2962. > compilers were smart enough to take advantage of all of the interesting
  2963. > addressing modes and instructions on CISC architectures, CISCs would
  2964. > overall be faster at running programs than RISCs. (*Duck*)
  2965.  
  2966. Actually, good RISC compilers are MORE difficult because of the difficulty 
  2967. of doing pipeline optimization.
  2968. - -
  2969. Jim Brunner (jim@brunner.wf.com)
  2970.  
  2971. +++++++++++++++++++++++++++
  2972.  
  2973. >From jtbell@cs1.presby.edu (Jon Bell)
  2974. Date: Wed, 2 Mar 94 23:06:40 GMT
  2975. Organization: Presbyterian College, Clinton, South Carolina USA
  2976.  
  2977. In article <gregor.1112919817C@ra.nrl.navy.mil>,
  2978. joe gregor <gregor@nrlfs1.nrl.navy.mil> wrote:
  2979. >In Article <2kueq8$865@ncrpda.curtin.edu.au>, peter@ncrpda.curtin.edu.au
  2980. >(Peter N Lewis) wrote:
  2981. >
  2982. >>C or Pascal produce about teh same quality code.  It's generally about
  2983. >>half the speed of reasonably tight assembly code...
  2984. >
  2985. >    I had always heard/read that C was the fastest language next to asm.
  2986. >I *never* heard/read that Pascal was even close, let alone faster. Please
  2987. >identify your references so I may (re)educate myself.
  2988.  
  2989. It makes no sense to talk about the "speed" of a language (or rather, its
  2990. compiled code) without reference to the compiler and the computer it's
  2991. running on.  There is nothing intrinsic in the design of Pascal or C that
  2992. would make one faster than the other.  What counts is the implementation.  
  2993.  
  2994. On some computers, C is indeed much faster than Pascal because their C
  2995. compilers are more "efficient" in that respect than their Pascal
  2996. compilers.  On the Mac, this is not the case.  The two languages run just
  2997. about neck and neck when you compare (say) Think Pascal with Think C or
  2998. MPW Pascal with MPW C. 
  2999.  
  3000. I don't have specific references handy, but I'll browse through my back
  3001. issues of MacTutor and see if I can find something to post if no one beats
  3002. me to it.  
  3003.  
  3004. -- 
  3005. Jon Bell <jtbell@presby.edu>                        Presbyterian College
  3006. Dept. of Physics and Computer Science        Clinton, South Carolina USA
  3007.  
  3008. +++++++++++++++++++++++++++
  3009.  
  3010. >From especkma@reed.edu (Erik A. Speckman)
  3011. Date: 3 Mar 1994 06:56:45 GMT
  3012. Organization: Hellmouth-Heater Democrat
  3013.  
  3014. In article <jvp.762643474@tools1.ee.iastate.edu>,
  3015. Jim Van Peursem <jvp@tools1.ee.iastate.edu> wrote:
  3016. >  I agree with Pete that originally, RISC was driven by the fact that
  3017. >most compilers simply didn't support the complex instructions in some
  3018. >chips. But more accurately, some complex instructions in some chips were
  3019. >slower than their counter-part simple instructions to perform the same
  3020. >task. The VAX had several of these as I recall. Anyway, your definition
  3021. >of RISC taking a max 5 clock cycles is wrong. That depends on the depth
  3022. >of the pipe and other factors.
  3023.  
  3024. No, no, no its that implimenting complex instructions costs silicon that 
  3025. could be better used increacing pipeline complexity or chache and 
  3026. speeding up all operations.
  3027.  
  3028. No, its a desert topping.
  3029.  
  3030. No, it is all those things and a desert topping to boot.
  3031.  
  3032.  >
  3033. --
  3034. ____________________________________________________________________________
  3035. Erik Speckman            especkma@romulus.reed.edu            GBDS
  3036.  
  3037. Workstation- A high-performance microcomputer designed to run benchmarks.
  3038.  
  3039. +++++++++++++++++++++++++++
  3040.  
  3041. >From rang@winternet.mpls.mn.us (Anton Rang)
  3042. Date: 03 Mar 1994 14:37:47 GMT
  3043. Organization: Minnesota Angsters
  3044.  
  3045. In article <resnick-280294222515@colt-19.slip.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  3046. >In article <2kueq8$865@ncrpda.curtin.edu.au>, peter@ncrpda.curtin.edu.au
  3047. >(Peter N Lewis) wrote:
  3048. >
  3049. >>>What's the best way to optimize C?
  3050. >>
  3051. >>Don't use any pointers.  Pointers screw up optimizing compilers.
  3052. >
  3053. >What?!?! Sometimes using pointers is the only way to get a really stupid
  3054. >compiler to do register allocation and register loading properly.
  3055.  
  3056.   Yes, but if you have a really *smart* compiler, pointers screw it up
  3057. royally, especially if you are passing parameters around by address.
  3058. Once you take the address of an object, almost any access through a
  3059. pointer stops the compiler from being able to optimize it.  So you're
  3060. often better off to use a temporary variable, like --
  3061.  
  3062.     temp_x = x;
  3063.     do_something(&temp_x);
  3064.     x = temp_x;
  3065.  
  3066. and keep 'x' local, so the compiler can (a) keep it in a register, and
  3067. (b) assume that its value isn't changed by almost *every* call and
  3068. every assignment through a pointer.
  3069.  
  3070. Of course, using the best algorithms is still the best way to optimize
  3071. *any* language.
  3072.  
  3073. -- Anton
  3074. --
  3075. Anton Rang (rang@acm.org)
  3076.  
  3077. +++++++++++++++++++++++++++
  3078.  
  3079. >From Brad Koehn <koehn@macc.wisc.edu>
  3080. Date: 4 Mar 1994 01:58:54 GMT
  3081. Organization: University of Wisconsin
  3082.  
  3083. In article <2l17nk$1ku@ncrpda.curtin.edu.au> Peter N Lewis,
  3084. peter@ncrpda.curtin.edu.au writes:
  3085. >Try it and see for yourself.  Pascal compilers will generally produce
  3086. faster
  3087. >code than C compilers with equivalent source.  Obviously, compilers vary
  3088. >a great deal, but the above is generally true.  I wouldn't worry though,
  3089. >I expect the next generation of compilers will make C faster than Pascal,
  3090. >since Pascal compilers will get a lot less work done on them.  Of course,
  3091. >then everyone will be using C++ and efficiency will be thrown right out
  3092. >the window, but such is life ;-)
  3093.  
  3094. Heck, check out the XLC and XLC++ compilers from IBM. Talk about
  3095. well-built! From what I understand, Apple was using them for quite a
  3096. while to compile for PPC (ahh, MPW, you dog you).
  3097.  
  3098. Anyway, these two beasties can do some really nice magic with your code.
  3099. And IBM just keeps improving them. Now, if only the Mac had it so good...
  3100. Oh, that's right, PowerOpen lets me use both AIX and MAS on the same
  3101. machine! So I can use XLC++ with my Mac code! Life is so good!
  3102. _________________________________________________________________________
  3103. Brad Koehn          Data Transformations, Inc.        koehn@macc.wisc.edu
  3104.  
  3105. +++++++++++++++++++++++++++
  3106.  
  3107. >From Brad Koehn <koehn@macc.wisc.edu>
  3108. Date: 4 Mar 1994 02:06:09 GMT
  3109. Organization: University of Wisconsin
  3110.  
  3111. In article <RANG.94Mar3083747@icicle.winternet.mpls.mn.us> Anton Rang,
  3112. rang@winternet.mpls.mn.us writes:
  3113. >  Yes, but if you have a really *smart* compiler, pointers screw it up
  3114. >royally, especially if you are passing parameters around by address.
  3115. >Once you take the address of an object, almost any access through a
  3116. >pointer stops the compiler from being able to optimize it.  So you're
  3117. >often better off to use a temporary variable, like --
  3118. >
  3119. >    temp_x = x;
  3120. >    do_something(&temp_x);
  3121. >    x = temp_x;
  3122. >
  3123. >and keep 'x' local, so the compiler can (a) keep it in a register, and
  3124. >(b) assume that its value isn't changed by almost *every* call and
  3125. >every assignment through a pointer.
  3126.  
  3127. Can't the compiler just check the code for do_something and see if it
  3128. changes temp_x? I realize it would be a real pain for compilers, but so
  3129. what? Life is pain. Anyone who tells you otherwise is trying to sell you
  3130. something.* Just build a table for each function that checks to see if
  3131. the parameters are changed. Sigh. I guess I should have taken that
  3132. compiler class...
  3133.  
  3134. * The Man in Black, "The Princess Bride"
  3135. _________________________________________________________________________
  3136. Brad Koehn          Data Transformations, Inc.        koehn@macc.wisc.edu
  3137.  
  3138. +++++++++++++++++++++++++++
  3139.  
  3140. >From pottier@prao.ens.fr (Francois Pottier)
  3141. Date: 4 Mar 1994 14:26:33 GMT
  3142. Organization: Ecole Normale Superieure, PARIS, France
  3143.  
  3144. In article <2l652h$aa6@news.doit.wisc.edu>,
  3145. Brad Koehn  <koehn@macc.wisc.edu> wrote:
  3146.  
  3147. >>    temp_x = x;
  3148. >>    do_something(&temp_x);
  3149. >>    x = temp_x;
  3150.  
  3151. >Can't the compiler just check the code for do_something and see if it
  3152. >changes temp_x? I realize it would be a real pain for compilers, but so
  3153.  
  3154. No, it can't. This looks like a typical undecidable problem. In a language
  3155. with pointers like C or Pascal, there are tons of ways of modifying a
  3156. variable. For instance, look at this:
  3157.  
  3158.   long x, y;
  3159.   long *p;
  3160.  
  3161.   p = &x;
  3162.   p++;
  3163.   *p = 0;
  3164.  
  3165. This code modifies y. Hard to tell, uh ?
  3166.  
  3167. I think it should be relatively easy to demonstrate that the problem
  3168. is undecidable. I could try writing a proof if you wish.
  3169.  
  3170. -- 
  3171. Francois Pottier            ___ ___  _    _  / ___  ___    ___
  3172. pottier@dmi.ens.fr       /_  /__/ /_|  /| / /  / /  / / /__
  3173.               /   / \  /  | / |/ /___ /__/ / ___/ _
  3174.                           /
  3175.  
  3176. +++++++++++++++++++++++++++
  3177.  
  3178. >From mmorgan@gpu.srv.ualberta.ca (Martin Morgan)
  3179. Date: 4 Mar 1994 16:02:53 GMT
  3180. Organization: University of Alberta
  3181.  
  3182. Francois Pottier (pottier@prao.ens.fr) wrote:
  3183. : Brad Koehn  <koehn@macc.wisc.edu> wrote:
  3184. : >>    temp_x = x;
  3185. : >>    do_something(&temp_x);
  3186. : >>    x = temp_x;
  3187. : >Can't the compiler just check the code for do_something and see if it
  3188. : >changes temp_x? I realize it would be a real pain for compilers, but so
  3189. : No, it can't. This looks like a typical undecidable problem. In a language
  3190.  
  3191. or the user declare do_something as do_something (const type-of-x *)?. Is
  3192. that a legal declaration?
  3193.  
  3194. : variable. For instance, look at this:
  3195. :   long x, y;
  3196. :   long *p;
  3197. :   p = &x;
  3198. :   p++;
  3199. :   *p = 0;
  3200. : This code modifies y. Hard to tell, uh ?
  3201.  
  3202. surely memory allocation of x and y is left to the compiler, so there's no
  3203. guarantee that anything relevant to the snippet is modified by *p = 0?
  3204.  
  3205. Martin Morgan
  3206.  
  3207.  
  3208.  
  3209. +++++++++++++++++++++++++++
  3210.  
  3211. >From rang@winternet.mpls.mn.us (Anton Rang)
  3212. Date: 05 Mar 1994 15:44:45 GMT
  3213. Organization: Minnesota Angsters
  3214.  
  3215. In article <2l652h$aa6@news.doit.wisc.edu> Brad Koehn <koehn@macc.wisc.edu> writes:
  3216. >>    temp_x = x;
  3217. >>    do_something(&temp_x);
  3218. >>    x = temp_x;
  3219. >
  3220. >Can't the compiler just check the code for do_something and see if it
  3221. >changes temp_x? I realize it would be a real pain for compilers, but so
  3222. >what?
  3223.  
  3224.   Yes and no.  The problem is that C's separate compilation model
  3225. calls for "compile a bunch of functions so that they all work
  3226. correctly independently; at link time, hook them together."  To make
  3227. this work right, you need to defer code generation until linking.
  3228. There are Ada development systems which do this (they need to generate
  3229. extremely tight code for embedded systems).
  3230.  
  3231.   However, because of C's ubiquitous pointers, this trick only works
  3232. for very simple functions.  Figuring out what variables a given
  3233. procedure call might modify, or even an approximation to it, in the
  3234. presence of globals or structures containing pointers, is non-trivial.
  3235. --
  3236. Anton Rang (rang@acm.org)
  3237.  
  3238. +++++++++++++++++++++++++++
  3239.  
  3240. >From zstern@adobe.com (Zalman Stern)
  3241. Date: Mon, 7 Mar 1994 02:50:34 GMT
  3242. Organization: Adobe Systems Incorporated
  3243.  
  3244. Anton Rang writes
  3245. >   Yes and no.  The problem is that C's separate compilation model
  3246. > calls for "compile a bunch of functions so that they all work
  3247. > correctly independently; at link time, hook them together."  To make
  3248. > this work right, you need to defer code generation until linking.
  3249. > There are Ada development systems which do this (they need to generate
  3250. > extremely tight code for embedded systems).
  3251.  
  3252. MIPS' C compiler/linker and the Plan 9 C compiler/linker (from AT&T Bell  
  3253. Labs) both offer link time code generation and optimization. I'm sure there  
  3254. are others. (Part of the problem with discussing a topic like this in the  
  3255. Mac community is most Mac programmers have limited experience with the broad  
  3256. realm of tools that run on other platforms.) I'd be happy with a Mac C  
  3257. compiler that was up to the state-of-the-art with regard to intra-procedure  
  3258. optimization. (Though I insist on automatic inlining of appropriate file  
  3259. scope static functions.)
  3260. --
  3261. Zalman Stern           zalman@adobe.com            (415) 962 3824
  3262. Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900
  3263. "Do right, and risk consequences." Motto of Sam Houston (via Molly Ivins)
  3264.  
  3265. +++++++++++++++++++++++++++
  3266.  
  3267. >From armb@setanta.demon.co.uk (Alan Braggins)
  3268. Date: Mon, 7 Mar 1994 17:22:02 GMT
  3269. Organization: Setanta Software
  3270.  
  3271. In article <2l7m3d$jil@quartz.ucs.ualberta.ca> mmorgan@gpu.srv.ualberta.ca (Martin Morgan) writes:
  3272.    : >Can't the compiler just check the code for do_something and see if it
  3273.    : >changes temp_x? I realize it would be a real pain for compilers, but so
  3274.  
  3275.    : No, it can't. This looks like a typical undecidable problem. In a language
  3276.  
  3277.    or the user declare do_something as do_something (const type-of-x *)?. Is
  3278.    that a legal declaration?
  3279.  
  3280. It is. But do_something is allowed to cast away const with
  3281. implementation defined results.
  3282. --
  3283. Alan Braggins  armb@setanta.demon.co.uk  abraggins@cix.compulink.co.uk
  3284. "Any technology distinguishable from magic is insufficiently advanced"
  3285.  
  3286. +++++++++++++++++++++++++++
  3287.  
  3288. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  3289. Date: 9 Mar 1994 11:41:15 +0800
  3290. Organization: NCRPDA, Curtin University
  3291.  
  3292. scott.m.silver@dartmouth.edu (Scott M. Silver) writes:
  3293.  
  3294. >All the books I've read about RISC say this is true.  I think this is
  3295. >from the standpoint that it is also easier to optimize for RISC chips
  3296. >because there aren't 9 million addressing modes, and eighty different
  3297. >ways to do things.
  3298.  
  3299. Yep, it was great writing an optimizing compiler for the ARM (Acorn
  3300. RISC Machine) (now used in the Newton).  We'd sit down and look at the
  3301. code it produced and we could come up with a thousand different ways of
  3302. doing the same thing, and they all took exactly the same amount of time!
  3303. Very nice.  Much more pleasant than sitting down with a 68040 manual and
  3304. spending several days comparing timing before deciding that it's non-
  3305. deterministic ;-)
  3306.    Peter.
  3307. -- 
  3308. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  3309.  
  3310. +++++++++++++++++++++++++++
  3311.  
  3312. >From tom@wcc.oz.au (Tom Evans)
  3313. Date: 10 Mar 94 09:05:12 GMT
  3314. Organization: Webster Computer Corp, Melbourne, Australia
  3315.  
  3316. In article <2kueq8$865@ncrpda.curtin.edu.au>, peter@ncrpda.curtin.edu.au (Peter N Lewis) surprisingly writes:
  3317. > mfi@i-link.com (MicroFrontier Inc.) writes:
  3318. > >And....which compiler (MPW C, Symantec C, or Metrowerks C) do you think
  3319. > >produces the fastest C code (with all optimization turned on)? Which do
  3320.  
  3321. Don't run MPW C (V3.3) with "-opt full" - it can't even printf() if you do!
  3322.  
  3323. > No idea, they are probably all withing 10% (as is Pascal, normally on
  3324. > the faster side).
  3325.  
  3326. I wish it were so Peter, but it ain't, not unless they're all within
  3327. 10% of being 30% slower than they should be.
  3328.  
  3329. I compile on a Macintosh under MPW and on a Sun 3 under its compiler
  3330. or gcc. The Mac is a 33MHz 68030. The Sun is a 20MHz 68020. When I
  3331. benchmark them against each other, they always run at about the SAME
  3332. SPEED. 
  3333.  
  3334. The Sun compiles the following:
  3335.  
  3336.     void testcopy(char *p1, char *p2, short length)
  3337.     {
  3338.             while (length--)
  3339.                     *p1++ = *p2++;
  3340.     }
  3341. To:
  3342.     testcopy:                linkw   a6,#-0x10
  3343.     testcopy+4:              movl    a6@(0xc),a0
  3344.     testcopy+8:              movl    a6@(8),a1
  3345.     testcopy+0xc:            movw    a6@(0x12),d0
  3346.     testcopy+0x10:           bras    _memcpy+0x14
  3347.     testcopy+0x12:           movb    a0@+,a1@+
  3348.     testcopy+0x14:           dbra    d0,_memcpy+0x12
  3349.     testcopy+0x18:           unlk    a6
  3350.     testcopy+0x1a:           rts
  3351.  
  3352. This is pretty much exactly as an assembler programmer might do it
  3353. (but a real assembler programmer would unroll the loop, as would a
  3354. real C programmer :-).
  3355.  
  3356. MPW with optimisation on makes the following botch of it:
  3357.  
  3358.     00000000: LINK       A6,#$0000
  3359.     00000004: MOVEM.L    D7/A3/A4,-(A7)
  3360.     00000008: MOVE.W     $0012(A6),D7
  3361.     0000000C: MOVEA.L    $000C(A6),A3
  3362.     00000010: MOVEA.L    $0008(A6),A4
  3363.     00000014: BRA.S      *+$0004             ; 00000018
  3364.     00000016: MOVE.B     (A3)+,(A4)+
  3365.     00000018: MOVE.W     D7,D0
  3366.     0000001A: SUBQ.W     #$1,D7
  3367.     0000001C: TST.W      D0
  3368.     0000001E: BNE.S      *-$0008             ; 00000016
  3369.     00000020: MOVEM.L    -$000C(A6),D7/A3/A4
  3370.     00000026: UNLK       A6
  3371.     00000028: RTS        
  3372.  
  3373. MPW has used 42 bytes of code to do what the Sun did in 28 (50% more),
  3374. and it takes 40% longer to do it. There are 2 instructions in the
  3375. Sun's inner loop, versus 5 with MPW.
  3376.  
  3377. Benchmark figures - I copied the Sun's assembler code to the Mac and
  3378. assembled it there to get the "Mac running Sun compiled" figure:
  3379.  
  3380. To run 100000 loops of the above function with "len = 10" takes:
  3381.  
  3382.     Sun running    Mac running    Mac running
  3383.     Sun compiled    Mac compiled    Sun compiled
  3384.     --------------------------------------------
  3385.     23 s        22 s        15 s
  3386.  
  3387. The Mac is 47% faster running the same binary, but only 5% faster
  3388. running the same "source". MPW generated code that takes 40% longer
  3389. to execute than the Sun-compiled code did.
  3390.  
  3391. Yes, this is a slightly contrived example (a - shock, horror,
  3392. BENCHMARK!) - it took a tiny amount of work (and knowledge) to get
  3393. the Sun to use the DBRA, and not a subtract-and-branch, but at least
  3394. it doesn't copy it before comparing.
  3395.  
  3396. However, whenever I've looked at MPW's output, I've always seen
  3397. unnecessary copying between registers, unnecessary masking, weird
  3398. testing, operations that can be done in one line of code taking 4 or
  3399. 5 lines. I've foung gcc does about the same job as the Sun compiler
  3400. does (i.e. very good).
  3401.  
  3402. Does this mean that if the Macintosh ROMs and System were recompiled with
  3403. gcc the system would be 30% smaller and 50% faster? :-)
  3404.  
  3405. > >What's the best way to optimize C?
  3406. > Don't use any pointers.  Pointers screw up optimizing compilers.
  3407.  
  3408. MPW doesn't count as an "optimising compiler" then, so it doesn't
  3409. matter :-). Use pointers in preference to array references though.
  3410.  
  3411. Back to the original question - has anyone compared MPW and Symantec
  3412. and Metrowerks (and the latest gnu port perhaps) head-on-head?
  3413. Compared code SIZE and SPEED?
  3414.  
  3415. ========================
  3416. Tom Evans  tom@wcc.oz.au
  3417. Webster Computer Corp P/L, 11 Glenvale Crescent Mulgrave, Melbourne 3170
  3418. Victoria, Australia 61-3-560-1100  FAX ...560-0067  A.C.N. 004 818 455
  3419.  
  3420. wcc@cup.portal.com, AppleLink: "WEBSTER.USA"
  3421. 2109 O'Toole Avenue, Suite J. San Jose, CA 95131-1338 USA
  3422. 1-408-954-8054  FAX 1-408-954-1832  AppleLink WEBSTER.USA
  3423.  
  3424. +++++++++++++++++++++++++++
  3425.  
  3426. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  3427. Date: Thu, 10 Mar 94 09:04:22 PST
  3428. Organization: Peirce Software, Inc.
  3429.  
  3430.  
  3431. In article <3731@wcc.oz.au> (comp.sys.mac.programmer), tom@wcc.oz.au (Tom Evans) writes:
  3432. > Does this mean that if the Macintosh ROMs and System were recompiled with
  3433. > gcc the system would be 30% smaller and 50% faster? :-)
  3434.  
  3435. You're assuming the "system" is written in C.  Parts are, but bigger
  3436. parts are written in plain old assembler.  Other parts are written
  3437. in Pascal.
  3438.  
  3439. Some parts are highly hand optomized to run best on the specific processor
  3440. they are destine to run on since the code lives in a ROM that won't
  3441. ever be plugged into another processor type.  BlockMove and CopyBits
  3442. come to mind.
  3443.  
  3444. I understand major parts of the system are (have been) rewritten in
  3445. C to make them portable (to PowerPC and x86).
  3446.  
  3447.  
  3448. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  3449. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  3450. --                       -- San Jose, California USA 95117
  3451. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  3452. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  3453.  
  3454. +++++++++++++++++++++++++++
  3455.  
  3456. >From s_heidri@irau32.ira.uka.de (Dietmar Heidrich)
  3457. Date: 17 Mar 1994 13:39:58 GMT
  3458. Organization: University of Karlsruhe, FRG
  3459.  
  3460. In article <gregor.1112919817C@ra.nrl.navy.mil>, gregor@nrlfs1.nrl.navy.mil (joe gregor) writes:
  3461. |> 
  3462. |>     I had always heard/read that C was the fastest language next to asm.
  3463. |> I *never* heard/read that Pascal was even close, let alone faster. Please
  3464. |> identify your references so I may (re)educate myself.
  3465.  
  3466. The implementation of a language can be fast or slow, not the language itself.
  3467. For some reasons not well understood (unless you agree with Richard Gabriel in
  3468. his JOOP article), C is widespread used and therefore gets most support efforts
  3469. (at least on other platforms).
  3470.  
  3471.  
  3472.  
  3473. --
  3474. Dietmar Heidrich, Universitaet Karlsruhe, Germany
  3475.  
  3476.  
  3477. "Die Hoffnung auf den Tod ist das einzige, was mich am Leben erhaelt."
  3478.  
  3479. ---------------------------
  3480.  
  3481. >From mbayme@bih.harvard.edu (Michael J. Bayme, M.D.)
  3482. Subject: Color Terminal Emulator
  3483. Date: Sun, 06 Mar 1994 13:37:29 -0500
  3484. Organization: Beth Israel Hospital Boston
  3485.  
  3486. Hi! I'm writing a color terminal emultor for my hospital's system - and
  3487. it's slow. I use srcCopy and lots of DrawChars - it's slow. I've seen tech
  3488. notes about a bug in system 7 that makes this sort of code run slowly. Is
  3489. this true? Are there work-arounds available.
  3490. Thanks, Michael Bayme
  3491.  
  3492. +++++++++++++++++++++++++++
  3493.  
  3494. >From leonardr@netcom.com (Leonard Rosenthol)
  3495. Date: Sun, 6 Mar 1994 20:32:26 GMT
  3496. Organization: Aladdin Systems, Inc.
  3497.  
  3498. In article <mbayme-060394133729@bayme.bih.harvard.edu>,
  3499. mbayme@bih.harvard.edu (Michael J. Bayme, M.D.) wrote:
  3500.  
  3501. > Hi! I'm writing a color terminal emultor for my hospital's system - and
  3502. > it's slow. I use srcCopy and lots of DrawChars - it's slow. I've seen tech
  3503. > notes about a bug in system 7 that makes this sort of code run slowly. Is
  3504. > this true? Are there work-arounds available.
  3505. >
  3506.    The only "problem" with System 7 and color has to do with calling
  3507. SetCtlValue() on things like scrollbars to often.  
  3508.    
  3509.    Your problem is more likely the calls to DrawChar().  Try doing some
  3510. buffering and calling DrawString() or DrawText() instead, that will speed
  3511. things up.  Also look for multiple calls to setting/resetting colors, text
  3512. mode, etc.  The things a good profiler would find.
  3513.  
  3514. Leonard
  3515. - ------------------------------------------------------------------------
  3516. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  3517. Director of Advanced Technology        AppleLink:      MACgician
  3518. Aladdin Systems, Inc.                  GEnie:          MACgician
  3519.  
  3520. +++++++++++++++++++++++++++
  3521.  
  3522. >From trygve@apple.com (Trygve Isaacson)
  3523. Date: Thu, 10 Mar 1994 01:06:06 -0800
  3524. Organization: Apple Computer, Inc.
  3525.  
  3526. In article <mbayme-060394133729@bayme.bih.harvard.edu>,
  3527. mbayme@bih.harvard.edu (Michael J. Bayme, M.D.) wrote:
  3528.  
  3529. > Hi! I'm writing a color terminal emultor for my hospital's system - and
  3530. > it's slow. I use srcCopy and lots of DrawChars - it's slow. I've seen tech
  3531. > notes about a bug in system 7 that makes this sort of code run slowly. Is
  3532. > this true? Are there work-arounds available.
  3533. > Thanks, Michael Bayme
  3534.  
  3535. Fortunately, yes. Terminal emulators were among the first to hit this
  3536. problem because few other programs' performance relies on the speed of
  3537. drawing text on a colored background.
  3538.  
  3539. The solution is to use srcOr instead of srcCopy (srcOr is fast). But this
  3540. means you are responsible for filling in the background color before
  3541. drawing. So:
  3542. - First, paint the invalid area with the background color
  3543. - Then, draw the text with the foreground color using srcOr
  3544.  
  3545. Unfortunately, this two-phase drawing is visibly a bit uglier than srcCopy,
  3546. but if you spend a little extra effort to do it offscreen, it will look
  3547. even better than before.
  3548.  
  3549. While I'm yacking, here are a couple of other speed tips:
  3550.  
  3551. 1) Don't draw character by character: instead, draw an entire run of text
  3552. at a time, where a run is defined as all adjacent characters that can be
  3553. drawn with the same pen/color/style/whatever. (OK, this is obvious;
  3554. otherwise your drawing would already be intolerably slow.)
  3555.  
  3556. 2) Optimize out whitespace: move the pen instead of drawing blanks. Of
  3557. course, this assumes you can calculate the character width ahead of time,
  3558. which assumes you're using a monospaced font. Note that boldface throws a
  3559. wrench in things unless your font's bold maintains the same character width
  3560. as plain, as does our Noiro font shipped with the SNA%ps emulators.
  3561.  
  3562. 3) Optimize out areas (rows/cols) that don't need to be drawn, such as
  3563. areas outside the window update region, and areas outside the modified
  3564. data. In other words, don't let clipping do all your work for you. It's
  3565. faster to calculate what doesn't need to be drawn than to actually draw
  3566. text that will be clipped.
  3567.  
  3568. 4) When you get new data to draw, don't just invalidate and sit there
  3569. waiting for an update event; draw immediately.
  3570.  
  3571. Hmmm, that's it off the top of my head.... Good luck...
  3572.  
  3573. Trygve Isaacson
  3574. SNA%ps engineer
  3575. Apple Computer, Inc.
  3576.  
  3577. +++++++++++++++++++++++++++
  3578.  
  3579. >From msouth@BIX.com (msouth on BIX)
  3580. Date: 12 Mar 94 04:28:12 GMT
  3581. Organization: Delphi Internet Services Corporation
  3582.  
  3583.  
  3584. More terminal-emulation tips of varying usefullness:
  3585.  
  3586. 5) Don't scroll with every linefeed received. Instead, save up text
  3587. and scroll a certain number of times per second.
  3588. 5) Get complicated. Most of the CPU time is probablly being
  3589. used to scroll text up one line with every linefeed received.
  3590. Instead, save up incoming text (by drawing to offscreen bitmap?),
  3591. and scroll in three or four lines at a time. You can't see more
  3592. than 20 frames or so a second, so 60 lines a secord (for instance)
  3593. would be wasting a lot of time.  Even 5 or 10 refreshes a second
  3594. can be bearable.
  3595.  
  3596. Mike South
  3597.  
  3598. ---------------------------
  3599.  
  3600. >From warwick_j@cubldr.colorado.edu
  3601. Subject: DrawString + Ellipsis character ?
  3602. Date: Thu, 10 Mar 1994 10:35:24 GMT
  3603. Organization: University of Colorado, Boulder
  3604.  
  3605. What is the best way to draw a Str255 into a Rect, abbreviating the
  3606. string if it doesn't fit by putting an ellipsis at the end?
  3607.  
  3608. The Finder does this for its By Name views, for example, when one of the
  3609. fields doesn't fit into the space provided. I seem to remember seeing a
  3610. routine to do this documented somewhere.
  3611.  
  3612. Obviously it would be simple to write, but I'd hate to reinvent the
  3613. wheel...
  3614.  
  3615. Nick.
  3616.  
  3617. +++++++++++++++++++++++++++
  3618.  
  3619. >From Lars.Farm@nts.mh.se (Lars Farm)
  3620. Date: Thu, 10 Mar 1994 14:34:24 +0100
  3621. Organization: Mid Sweden University
  3622.  
  3623. In article <1994Mar10.033524.1@cubldr.colorado.edu>,
  3624. warwick_j@cubldr.colorado.edu wrote:
  3625.  
  3626. > What is the best way to draw a Str255 into a Rect, abbreviating the
  3627. > string if it doesn't fit by putting an ellipsis at the end?
  3628.  
  3629. Use the Script Manager routine TruncString() or TruncText().
  3630. See: TextUtils.h or Script.h
  3631.  
  3632. -- 
  3633. Lars.Farm@nts.mh.se
  3634.  
  3635. +++++++++++++++++++++++++++
  3636.  
  3637. >From harveyj@dunx1.ocs.drexel.edu. (John Harvey)
  3638. Date: Thu, 10 Mar 1994 16:36:04 GMT
  3639. Organization: Drexel University
  3640.  
  3641. In article <1994Mar10.033524.1@cubldr.colorado.edu>
  3642. warwick_j@cubldr.colorado.edu writes:
  3643.  
  3644. > What is the best way to draw a Str255 into a Rect, abbreviating the
  3645. > string if it doesn't fit by putting an ellipsis at the end?
  3646.  
  3647. Use either of these two traps:
  3648.  
  3649. FUNCTION TruncText (width: Integer; textPtr: Ptr; 
  3650.                           VAR length: Integer; 
  3651.                           truncWhere: TruncCode): Integer;
  3652.  
  3653. or 
  3654.  
  3655. FUNCTION TruncString (width: Integer; VAR theString: Str255; 
  3656.                              truncWhere: TruncCode): Integer;
  3657.  
  3658. They both will return a hunk of text which will fit in the width
  3659. specified and has the correct truncation symbol(internationally
  3660. speaking).  IM-Text 5-71 to 5-72 has the details.
  3661.  
  3662. John Harvey 
  3663.  
  3664. +++++++++++++++++++++++++++
  3665.  
  3666. >From mgr@aggroup.aggroup.com (Mike Russell)
  3667. Date: Thu, 10 Mar 1994 12:44:02 -0800
  3668. Organization: the ag group, inc.
  3669.  
  3670. In article <1994Mar10.033524.1@cubldr.colorado.edu>,
  3671. warwick_j@cubldr.colorado.edu wrote:
  3672.  
  3673. > What is the best way to draw a Str255 into a Rect, abbreviating the
  3674. > string if it doesn't fit by putting an ellipsis at the end?
  3675.  
  3676. Here's some code that tries to use condensed text, then truncates the
  3677. center of the string.
  3678.  
  3679. - --
  3680.  
  3681. /*
  3682.  * shoehorn - shrink a name to the specified width by first setting
  3683. condensed text
  3684.  *                  face, then deleting letters from the middle.  Returns the value
  3685.  *                  of StringWidth().  Returns the final width.
  3686.  *
  3687.  *                   Face is not altered if it is already nonzero.
  3688.  */
  3689. int
  3690. shoehorn(StringPtr name, int *face, int w)
  3691. {
  3692.     int extra = (*face & italic)?CharWidth(' '):0;
  3693.     int ww;
  3694.     int elipsis = 0;
  3695.     Ptr p;
  3696.     
  3697.     while(name[0] > 1 && (ww=StringWidth(name) + extra) > w) {
  3698.         if(!name[0] || !w) return ww;
  3699.         if(!(*face & condense)) {
  3700.             TextFace(*face |= condense);
  3701.         } else {
  3702.             if(!elipsis)
  3703.                 name[elipsis = name[0]/2] = 'I';
  3704.             p = (Ptr)name + elipsis + 1;
  3705.             if(elipsis > name[0]/2) {
  3706.                 p -= 2;
  3707.                 elipsis--;
  3708.             }
  3709.             BlockMove(p+1, p, name[0] - (p - (Ptr)name));
  3710.             name[0]--;
  3711.         }
  3712.     }
  3713.     return ww;
  3714. }
  3715.  
  3716. +++++++++++++++++++++++++++
  3717.  
  3718. >From harveyj@dunx1.ocs.drexel.edu. (harveyj)
  3719. Date: Mon, 14 Mar 1994 16:08:54 GMT
  3720. Organization: Drexel University, Office Of Computing Services
  3721.  
  3722. In article <B.Kobben-140394142336@karto516.frw.ruu.nl>
  3723. B.Kobben@frw.ruu.nl (Barend Kobben) writes:
  3724.  
  3725. > I have not got IM-Text (yet), but Trunctext and Truncstring aren't in Think
  3726. > Reference either. Could this be correct? Anyway, do these functions work if
  3727. > I want to offer sys 6 compatibility?
  3728.  
  3729. I don't own a paper copy of IM-Text myself, but I'm getting by with
  3730. copies on CD's that are lying around my place of work.  
  3731.  
  3732. Anyway, TruncText and TruncString  are not available prior to 7.0
  3733. script manager.  If you want to do the right thing internationally on
  3734. systems earlier than 7.0 you need to dig the ellipsis character out of
  3735. the 'itl4' resource's untoken table  yourself and then measure your
  3736. text to figure out where to put the ellipsis character.  IM-Text has
  3737. some example code for finding the token table and retrieving the
  3738. desired character.  Here it is (I know it is in Pascal, blame IM-Text
  3739. not me):
  3740.  
  3741. PROCEDURE MyMapTokenToString(theScript: ScriptCode; theToken: Integer;
  3742. VAR theString: Str255);
  3743.  
  3744. VAR
  3745.     itlHandle:                        Handle;
  3746.     untokenOffset:                        LongInt;
  3747.     untokenLength:                        LongInt;
  3748.     untokenPtr:                        UntokenTablePtr;
  3749.     untokenStringPtr:                        StringPtr;
  3750.  
  3751. BEGIN
  3752.     GetIntlResourceTable(theScript, smUnTokenTable, itlHandle, 
  3753.                                 untokenOffset, untokenLength);
  3754.     
  3755.     IF itlHandle = NIL THEN                                    {handle errors, return null string}
  3756.         theString := ''
  3757.     ELSE BEGIN                                    {make untokenPtr point to the }
  3758.                                         { beginning of the untoken table}
  3759.         untokenPtr := UntokenTablePtr(LongInt(itlHandle^) + 
  3760.                             untokenOffset);
  3761.         IF theToken > untokenPtr^.lastToken THEN                                                        {this token is
  3762. }
  3763.                                                             { not in table-- } 
  3764.             theString := ''                                                { return null string}
  3765.         ELSE BEGIN                                {index[theToken] is the offset }
  3766.                                         { of the desired string from the }
  3767.                                         { beginning of the untoken table}
  3768.             untokenStringPtr := StringPtr(LongInt(untokenPtr)            
  3769.                                +untokenPtr^.index[theToken]);
  3770.             theString := untokenStringPtr^;
  3771.         END;
  3772.     END;
  3773.  
  3774. I'll leave the measuring code and inserting the character to the reader
  3775. (there was another posting which provided code to do that, I think).
  3776.  
  3777. Of course, if you don't mind the ellipsis character turning into a
  3778. hiragana character on a Japanese system ( and other things on other
  3779. non-roman systems), the easiest thing to do is just hardwire the
  3780. ellipsis character.  
  3781.  
  3782. If you worry much about text on the Mac then IM-Text is a pretty
  3783. important investment.  Stuff that was scattered everywhere is finally
  3784. together in one book, and questions about when features are available
  3785. are easily answered. 
  3786.  
  3787. Sorry, I didn't include a mention of 6.0 compatibility before.
  3788.  
  3789. John Harvey
  3790.  
  3791.  
  3792. +++++++++++++++++++++++++++
  3793.  
  3794. >From Lars.Farm@nts.mh.se (Lars Farm)
  3795. Date: Tue, 15 Mar 1994 10:43:13 +0100
  3796. Organization: Mid Sweden University
  3797.  
  3798. In article <1994Mar14.160854.3349@netnews.noc.drexel.edu>,
  3799. harveyj@dunx1.ocs.drexel.edu. (harveyj) wrote:
  3800.  
  3801. > Anyway, TruncText and TruncString  are not available prior to 7.0
  3802. > script manager.  
  3803.  
  3804. They were introduced in 6.0.3 or 6.0.4 I think, with Upr/LwrText and others
  3805. in the script manager.
  3806.  
  3807. Lars
  3808.  
  3809. -- 
  3810. Lars.Farm@nts.mh.se
  3811.  
  3812. +++++++++++++++++++++++++++
  3813.  
  3814. >From harveyj@dunx1.ocs.drexel.edu. (harveyj)
  3815. Date: Tue, 15 Mar 1994 13:11:49 GMT
  3816. Organization: Drexel University, Office Of Computing Services
  3817.  
  3818. In article <Lars.Farm-150394104313@sleipner.nts.mh.se>
  3819. Lars.Farm@nts.mh.se (Lars Farm) writes:
  3820.  
  3821. > They were introduced in 6.0.3 or 6.0.4 I think, with Upr/LwrText and others
  3822. > in the script manager.
  3823.  
  3824. I sound like a parrot with this IM-Text stuff, but table 6-1 on page
  3825. 6-6 of IM-Text says that TruncText and TruncString were introduced with
  3826. version 7.0 Script Manager.  Version 7.0 Script Manager was first
  3827. released with system 7.0 (table 6-2 page 6-9 of IM-Text).
  3828.  
  3829. Like Al Smith said, "Let's look at the record."  Of course, I've
  3830. apparently lost my mind to quote somebody without a reference.  But, I
  3831. think I saw the quote in _Mad Magazine_, April 1964.  OK?
  3832.  
  3833. John Harvey
  3834.  
  3835. ---------------------------
  3836.  
  3837. >From klug@genesis.nred.ma.us (Mark Pirri)
  3838. Subject: Finder comments on non-Desktop DB volumes?
  3839. Date: Fri, 11 Mar 1994 05:14:07 GMT
  3840. Organization: Genesis Public Access Unix +1 508 664 0149
  3841.  
  3842. Is it possible to read the Finder comments for files on a <2MB volume
  3843. (i.e. no Desktop database) in System 7.  I know that they're stored in the
  3844. old-style Desktop file (resource type 'FCMT' or something like that), but
  3845. since the Finder always keeps that open, how can I access them?
  3846.  
  3847. Any assistance would be greatly appreciated. 
  3848.  
  3849. Thanks in advance
  3850. -mark p
  3851. -- 
  3852. - ------------------------------\
  3853. Mark N. Pirri             \  THIS SPACE FOR RENT
  3854. internet: klug@genesis.nred.ma.us \  no corny .sig's, please!
  3855. AOL: TheVortex [@aol.com]       \  
  3856.  
  3857. +++++++++++++++++++++++++++
  3858.  
  3859. >From kd@summit.novell.com (Delbarre K.)
  3860. Date: 11 Mar 1994 20:18:40 -0500
  3861. Organization: Novell, Summit
  3862.  
  3863. In article <CMHIJK.HEw@genesis.nred.ma.us> klug@genesis.nred.ma.us (Mark Pirri) writes:
  3864. >Is it possible to read the Finder comments for files on a <2MB volume
  3865. >(i.e. no Desktop database) in System 7.  I know that they're stored in the
  3866. >old-style Desktop file (resource type 'FCMT' or something like that), but
  3867. >since the Finder always keeps that open, how can I access them? [ ... ]
  3868.  
  3869. You can open the Desktop resource file read-only using
  3870. FSpOpenResFile(spec, fsRdPerm) or some variant thereof.
  3871. TN212 says to avoid opening a resource file read-only,
  3872. because it could lead to a corrupted resource map.
  3873. If there is a safer alternative I'd love to hear about it.
  3874.  
  3875. My utility GetInfo exists primarily to allow you to save
  3876. and restore all of your comments from a System 7 Desktop
  3877. Database, but also has the capability of extracting the
  3878. comments from an old-style Desktop resource file.  It
  3879. uses FSpOpenResFile(spec, fsRdPerm) to open the resource
  3880. file for the reason you mention.
  3881. --
  3882. Kelvin Delbarre, Omicron Software Systems, Inc.
  3883. contracted to Novell's UNIX System Laboratories, Summit, NJ
  3884. kd@summit.novell.com
  3885.  
  3886. +++++++++++++++++++++++++++
  3887.  
  3888. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3889. Date: 14 Mar 94 18:05:57 +1300
  3890. Organization: University of Waikato, Hamilton, New Zealand
  3891.  
  3892. In article <CMHIJK.HEw@genesis.nred.ma.us>, klug@genesis.nred.ma.us (Mark Pirri) writes:
  3893. > Is it possible to read the Finder comments for files on a <2MB volume
  3894. > (i.e. no Desktop database) in System 7.  I know that they're stored in the
  3895. > old-style Desktop file (resource type 'FCMT' or something like that), but
  3896. > since the Finder always keeps that open, how can I access them?
  3897.  
  3898. Here's an idea I came up with. Unfortunately, it'll only work with Finder 7.1.3
  3899. (which makes proper use of the AppleEvent Manager):
  3900.  
  3901. * Install a system handler for a custom AppleEvent.
  3902. * Send this event to the Finder, so it executes your custom event handler
  3903.   in the Finder's process context.
  3904. * Your custom handler now has full access to all the resource files the Finder
  3905.   has open, including the desktop database on <2MB volumes.
  3906.  
  3907. Now, can anyone figure out how to make this work with pre-7.1.x Finders...?
  3908.  
  3909. Lawrence
  3910. (had a lot of fun with special kernel ASTs under VAX/VMS)
  3911.  
  3912. +++++++++++++++++++++++++++
  3913.  
  3914. >From leonardr@netcom.com (Leonard Rosenthol)
  3915. Date: Tue, 15 Mar 1994 20:03:10 GMT
  3916. Organization: Aladdin Systems, Inc.
  3917.  
  3918. In article <1994Mar14.180557.26363@waikato.ac.nz>, ldo@waikato.ac.nz
  3919. (Lawrence D'Oliveiro, Waikato University) wrote:
  3920.  
  3921. > Here's an idea I came up with. 
  3922. > Unfortunately, it'll only work with Finder 7.1.3
  3923. > (which makes proper use of the AppleEvent Manager):
  3924. > * Install a system handler for a custom AppleEvent.
  3925. > * Send this event to the Finder, so it executes your custom event handler
  3926. >   in the Finder's process context.
  3927. > * Your custom handler now has full access to all the resource files the Finder
  3928. >   has open, including the desktop database on <2MB volumes.
  3929. > Now, can anyone figure out how to make this work with pre-7.1.x Finders...?
  3930.    Actually it will work JUST FINE under ANY version of System 7, since
  3931. even older versions of the Finder will end up "forwarding" on the event to
  3932. the system handlers.  
  3933.  
  3934.    In fact, this is how OSA Menu works - it sends an event to the current
  3935. process that should end up getting ignored and processed by my system
  3936. handler.
  3937.  
  3938. Leonard
  3939. - ------------------------------------------------------------------------
  3940. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  3941. Director of Advanced Technology        AppleLink:      MACgician
  3942. Aladdin Systems, Inc.                  GEnie:          MACgician
  3943.  
  3944. ---------------------------
  3945.  
  3946. >From ssiegler@hns.com (Stuart Sieger)
  3947. Subject: Finding System Folder (Again)
  3948. Date: Mon, 28 Feb 1994 18:54:49 GMT
  3949. Organization: Hughes Network Systems Inc.
  3950.  
  3951.     OK, Im hopeless.
  3952.  
  3953.     I am trying to "find" the system folder so that I can put my
  3954.     preferences there...
  3955.  
  3956.     How does one go about that?  I read that FindFolder works for sys7
  3957.     only (and I still need to support sys6).  Can someone give me
  3958.     a code frag (or point me in the right direction) to locate the
  3959.     system folder (or at least locate the path-string that leads
  3960.     to the folder (ie, disk:System Folder:Preferences).
  3961.  
  3962.     Any other suggestions (other than RTFM (I already tried that))
  3963.     would be helpful.
  3964.  
  3965.     Stuart Siegler
  3966. "Just because you're paranoid doesn't mean they aren't out to get you"
  3967.  
  3968.  
  3969. +++++++++++++++++++++++++++
  3970.  
  3971. >From alana@cs.uoregon.edu (Alan Akins)
  3972. Date: 3 Mar 1994 09:19:45 -0800
  3973. Organization: The uncharted backwaters of the unfashionable end of the                  Western Spiral arm of the Galaxy.
  3974.  
  3975. In article <1994Feb28.185449.22632@hns.com>,
  3976. Stuart Sieger <ssiegler@hns.com> wrote:
  3977. >
  3978. >       I am trying to "find" the system folder so that I can put my
  3979. >       preferences there...
  3980. >
  3981. >       How does one go about that?  I read that FindFolder works for sys7
  3982. >       only (and I still need to support sys6).  Can someone give me
  3983. >       a code frag (or point me in the right direction) to locate the
  3984. >       system folder (or at least locate the path-string that leads
  3985. >       to the folder (ie, disk:System Folder:Preferences).
  3986.  
  3987. OK. Using FindFolder with System 7 is all I can help you with. I know
  3988. that glue code is supplied in THINK C for System 6 as well, but I've
  3989. never tried anything I've written with pre Sys7 systems.
  3990.  
  3991. FindFolder is doc'd in IM: Mac TB Essentials 7-54 thru 7-56 and is defined:
  3992.  
  3993. FUNCTION FindFolder( vRefNum: Integer; folderType: OSType;
  3994.                      createFolder: Boolean; VAR foundVRefNum: Integer;
  3995.                      VAR foundDirID: LongInt): OSErr;
  3996.  
  3997.  
  3998. The System Folder has constant type kSystemFolderType.  For my
  3999. example, we also depend on the system constants kOnSystemDisk and
  4000. kCreateFolder.
  4001.  
  4002. So, one would use it like this (in C):
  4003.  
  4004. long
  4005. FindSysFolder( void )
  4006. {
  4007.     long    dirID;
  4008.     short   vRefNum;
  4009.     OSErr   err;
  4010.  
  4011.     err = FindFolder( kOnSystemDisk, kSystemFolderType, kCreateFolder,
  4012.                       &vRefNum, &dirID );
  4013.     if ( err == noErr )
  4014.         return dirID;
  4015.     else
  4016.         /* Do some error recovery here */
  4017.         ;
  4018. }
  4019.  
  4020. This will look for the System Folder on the startup disk and if it is
  4021. not found, it will be created. Since it looks on the startup disk, it
  4022. should definitely be able to find it!
  4023.  
  4024. Hope this all helps!
  4025. -- 
  4026. *      "Evan's been doing parallel       |    Alan Akins                      *
  4027. *           processing for so long...    |    alana@cs.uoregon.edu            *
  4028. *                 he's beside himself."  |    University of Oregon            *
  4029. *                        - Me            |    Department of Computer Science  *
  4030.  
  4031. +++++++++++++++++++++++++++
  4032.  
  4033. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  4034. Date: Fri, 4 Mar 1994 06:20:56 GMT
  4035. Organization: Sexton Software
  4036.  
  4037. In article <1994Feb28.185449.22632@hns.com> Stuart Sieger,
  4038. ssiegler@hns.com writes:
  4039. >    only (and I still need to support sys6).  Can someone give me
  4040. >    a code frag (or point me in the right direction) to locate the
  4041. >    system folder (or at least locate the path-string that leads
  4042. >    to the folder (ie, disk:System Folder:Preferences).
  4043.  
  4044. Call SysEnvirons. This sets a variable of type SysEnvRec. One of its
  4045. fields is sysVRefNum which is a working directory refNum for the system
  4046. folder. If you need its 'real' vRefNum and dirID use sysVRefNum and a
  4047. call to PBGetWDInfo.
  4048. Steve Bryan                  InterNet: sbryan@maroon.tc.umn.edu
  4049. Sexton Software            CompuServe: 76545,527
  4050. Minneapolis, MN                   Fax: (612) 929-1799
  4051.  
  4052. ---------------------------
  4053.  
  4054. >From kurisuto@chopin.udel.edu (Sean J. Crist)
  4055. Subject: Free code:  Sean's window manager
  4056. Date: 8 Mar 1994 20:07:11 -0500
  4057. Organization: University of Delaware
  4058.  
  4059. Following is the Pascal code I mentioned on an earlier post; since a few
  4060. people have expressed an interest, I'll go ahead and post it. 
  4061.  
  4062. This is basically an extension to the Window Manager with two functions:
  4063. 1) it supports floating palettes associated with specific windows, and 2)
  4064. it helps keep track of which window is which when your application allows
  4065. the user to open any number of windows (e.g. if you're writing a word
  4066. processor which allows any number of documents to be open at once, this
  4067. code helps to tell the document windows apart from each other without
  4068. maintaining a WindowPtr to each one). 
  4069.  
  4070. Sorry that this is isn't binhexed or compressed.  This code may be freely
  4071. incorporated into shareware programs, but I reserve all other rights. 
  4072. Military use of this code is specifically prohibited.
  4073.  
  4074.  
  4075. unit SeansWindowManager;
  4076.  
  4077. {Copyright 1994 by Sean Crist (kurisuto@chopin.udel.edu).  This code may be
  4078. freely incorporated into shareware}
  4079. {or freeware projects.  All other rights reserved.}
  4080.  
  4081. {I am aware of no bugs in this code, but please send me reports of any 
  4082. bugs you find.}
  4083.  
  4084. {     What this code is for:  This is basically an extension to the 
  4085. Window Manager 1) to support floating palettes, and}
  4086. { 2) to obviate the need to keep WindowPtr's to each window.  If you are 
  4087. writing an application with a fixed number}
  4088. {of windows, you can just define your WindowPtr's as globals, but if your 
  4089. application supports arbitrary}
  4090. {numbers of windows (e.g. a word processor which allows any number of 
  4091. documents to be open at a time), it can be}
  4092. {a hassle to keep track of all of these WindowPtr's in a variable-length 
  4093. array or whatever.  The following code}
  4094. {makes it easy to manage large numbers of windows of assorted kinds. }
  4095. {     The basic strategy here is to put a handle in the RefCon of every 
  4096. window opened by your application (not only}
  4097. {your 'document' windows but also your Clipboard window, your modeless 
  4098. dialogs, etc).  This handle contains}
  4099. {information uniquely identifying the window.  You don't need to keep any 
  4100. pointers to specific windows; when you}
  4101. {want a certain window, you just call one of the routines below, giving 
  4102. information to identify the window.}
  4103. {The code below quickly looks through all the windows and gives you a 
  4104. pointer to the window you want.}
  4105. {     Of course, you need not be greatly concerned with these handles; 
  4106. just make the appropriate calls to the}
  4107. {routines below, and most of the grubby work will be done for you.}
  4108.  
  4109. {There's several changes you must make to your code, and to the code 
  4110. below, for this all to work properly:}
  4111. {1.  You must edit the list of wTypes below to reflect all the kinds of 
  4112. windows your program supports.}
  4113. {2.  You must edit the SetPrivateHilite routine below to reflect the 
  4114. relation between palettes and regular}
  4115. {      windows in a way specific to your application.  For example, if 
  4116. you want your wToolsPalette to become}
  4117. {      visible when one of you wArtWindows is selected, you should code 
  4118. this here.}
  4119. {3.  Your program's initialization routine must set the 
  4120. PrivateFrontWindow global (declared below) to some}
  4121. {      valid WindowPtr.  It doesn't matter which window this is, as long 
  4122. as it is a valid one.  The code below}
  4123. {      will change the PrivateFrontWindow in response to your calls, but 
  4124. it needs a window to start out with.}
  4125. {4.  Every time you open a new window, you must call InitializeWindow on 
  4126. it to record what kind of window it is.}
  4127. {      Just before you dispose of a window, you must call DisposeWData on 
  4128. it first.}
  4129. {5.  You must not call the Toolbox routine SelectWindow, since this will 
  4130. mess up the hiliting of windows and }
  4131. {      visibility of palettes.  Use the routine PrivateActivate (defined 
  4132. below) instead.}
  4133. {6.   In your event loop, you need to do a little extra work to support 
  4134. floating palettes. We treat a window and }
  4135. {      its palettes as one 'layer'.  When you get a mousedown in 
  4136. PrivateFrontWindow, or in one of the palettes}
  4137. {      belonging to PrivateFrontWindow, then you should just call 
  4138. BringToFront on that window.}
  4139. {      (Your event code thus needs to be smart about what kinds of 
  4140. palettes belong to what kinds }
  4141. {      of windows.)}
  4142. {      If the mousedown is in some other window (i.e. neither 
  4143. PrivateFrontWindow nor its palettes), then you should}
  4144. {      call PrivateActivate, which is much like SelectWindow except that 
  4145. it does the extra work to support floating}
  4146. {      palettes and make sure everything gets hilited properly.}
  4147.  
  4148.  
  4149. interface
  4150.  
  4151. {Window types}
  4152.  const
  4153.   wMiscWindow = 1;
  4154.   wMiscWindowWithPalette = 2;
  4155.   wMiscPalette = 3;
  4156. {These window types are just to illustrate how this code works.  In your 
  4157. program, you would want to change these}
  4158. {constants to whatever kinds of windows your program supports.  (The 
  4159. application I'm working on has about 15}
  4160. {different kinds of windows and three kinds of palettes, for example.)  
  4161. Each window type, including palettes, must}
  4162. {have a unique identifying number.}
  4163.  
  4164.  const
  4165.   BadWindow = 9999;
  4166. {For doing error checking.  We send this to our own error handlers, 
  4167. pretending it's a real Toolbox error code.}
  4168.  
  4169.  var
  4170.   PrivateFrontWindow: WindowPtr;
  4171. {This is the WindowPtr to the window that we _consider_ to be the front 
  4172. window, ignoring whatever floating palettes}
  4173. {might be in front of it in the actual window list.  Note: you must 
  4174. initialize this to some valid WindowPtr when your}
  4175. {program initializes itself, or this code will crash.}
  4176.  
  4177.  
  4178.  
  4179. {We store the following record as a handle in the RefCon field of a 
  4180. window.  It contains all of our information that}
  4181. {we need to keep track of what kind of window this is.  Most of the time, 
  4182. you'll never need to manipulate the contents}
  4183. {of this record directly, since there's more convenient routines below to 
  4184. do this work for you.}
  4185.  type
  4186.   WindowData = record
  4187.     Class: Integer;     {What kind of window or dialog?  This is one of 
  4188. the wType constants above.}
  4189.     Owner: Integer;
  4190.     Index: Integer;
  4191.     DataHandle: Handle; {Handle to whatever other data you wish to store 
  4192. for this window.}
  4193.     AuxData: Integer;   {To be used however you like.}
  4194.    end;
  4195.   WDataPtr = ^WindowData;
  4196.   WDataHandle = ^WDataPtr;
  4197. {     Note on the fields 'Class', 'Owner', and 'Index':  the Class is the 
  4198. kind of window, e.g. a Clipboard window,}
  4199. {a search-and-replace modeless dialog, or whatever.  This field contains 
  4200. one of the wType constants defined above.}
  4201. {The owner and index tell which window of that kind we are talking 
  4202. about.  In the case where there's only one }
  4203. {instance of a kind of window (such as a Clipboard window), you can just 
  4204. set Owner and Index to 0 when you call }
  4205. {InitializeWindow.  When there's more than one instance of a particular 
  4206. window type, give each window a different }
  4207. {Index to distinguish it.}
  4208. {     Under normal circumstances, you can just set Owner to 0 in all 
  4209. cases.  I include this field because my application }
  4210. {has script windows for different kinds of objects, so I need to know if 
  4211. this is, say, the script window for}
  4212. {the 7th zone or the 7th room or whatever.}
  4213.  
  4214.  
  4215.  
  4216. {Call InitializeWindow when you are opening a new window.  You are 
  4217. responsible for creating the window with}
  4218. {GetNewCWindow or GetNewDialog or whatever; pass this handle in 
  4219. WhichWindow.  InitializeWindow allocates}
  4220. {a WDataHandle, installs it in the refCon of whichWindow, and sets up the 
  4221. Class, Owner, and Index values.}
  4222.  function InitializeWindow (whichWindow: WindowPtr; Class, Owner, Index: 
  4223. Integer): Boolean;
  4224.  
  4225. {Dispose the WDataHandle associated with whichWindow.  Note:  You are 
  4226. responsible for disposing whatever}
  4227. {data you have stored in DataHandle.  The right order to dispose things 
  4228. is: 1) dispose any data of your own}
  4229. {which you've stored in DataHandle 2) call DisposeWData  3) dispose of 
  4230. the window or dialog itself with}
  4231. {the appropriate Toolbox call.}
  4232.  procedure DisposeWData (whichWindow: WindowPtr);
  4233.  
  4234. {Store this handle in DataHandle.}
  4235.  procedure SetWHandle (whichWindow: WindowPtr; TheHandle: Handle);
  4236.  
  4237. {Return the handle stored in DataHandle.}
  4238.  function GetWHandle (whichWindow: WindowPtr): Handle;
  4239.  
  4240. {Given a window, return its WDataHandle}
  4241.  function GetWData (whichWindow: WindowPtr): WDataHandle;
  4242.  
  4243. {What is the class of whichWindow?  (You could accomplish this same thing 
  4244. by calling GetWData and then}
  4245. {looking at MyWData^^.Class, but this routine saves work.)  Returns -1 if 
  4246. the WData is bad (i.e., you probably}
  4247. {didn't call InitializeWindow on this window.}
  4248.  function GetWClass (whichWindow: WindowPtr): Integer;
  4249.  
  4250. {What is the index of whichWindow?  (You could accomplish this same thing 
  4251. by calling GetWData and then}
  4252. {looking at MyWData^^.Index, but this routine saves work.)  Returns -1 if 
  4253. the WData is bad (i.e., you probably}
  4254. {didn't call InitializeWindow on this window.}
  4255.  function GetWIndex (whichWindow: WindowPtr): Integer;
  4256.  
  4257. {Search through all the windows and try to find the one which has the 
  4258. specified class, owner, and index.}
  4259.  function SearchWindow (Class, Owner, Index: Integer): WindowPtr;
  4260.  
  4261. {Same as SearchWindow, but for windows like the Clipboard which have only 
  4262. one instance.}
  4263.  function FindUniqueWindow (Class: Integer): WindowPtr;
  4264.  
  4265. {Try to bring to front the window with this class, owner, and index.  
  4266. Returns TRUE if there is no such window,}
  4267. {i.e.  the window can't be activated and must be created.  This can make 
  4268. your code succinct; when the user}
  4269. {does some action to open a particular window, your routine MyOpenWindow 
  4270. can start out 'if CantActivate}
  4271. {(the window I need) then (do whatever to open it, including calling 
  4272. InitializeWindow)'.}
  4273.  function CantActivate (Class, Owner, Index: Integer): Boolean;
  4274.  
  4275. {You should use this instead of SelectWindow.}
  4276.  procedure PrivateActivate (whichWindow: WindowPtr);
  4277.  
  4278.  
  4279. implementation
  4280.  
  4281.  procedure doOSErr (ErrorCode: Integer);
  4282.  begin
  4283. {Handle the error however you like.  I usually post an alert.}
  4284.  end;
  4285.  
  4286. {Error checking.  Make sure the WDataHandle is a valid one by checking 
  4287. its length.  This is}
  4288. {mainly for debugging.}
  4289.  function IsValidWindowHandle (TheWDataHandle: WDataHandle): Boolean;
  4290.   var
  4291.    HandleSize: LongInt;
  4292.  begin
  4293.   IsValidWindowHandle := TRUE;
  4294.   HandleSize := GetHandleSize(Handle(TheWDataHandle));
  4295.   if HandleSize <> SizeOf(WindowData) then
  4296.    IsValidWindowHandle := FALSE;
  4297.  end;
  4298.  
  4299.  
  4300.  function GetWData (whichWindow: WindowPtr): WDataHandle;
  4301.   var
  4302.    thePeek: WindowPeek;
  4303.    TheHandle: Handle;
  4304.  begin
  4305.   if WhichWindow = nil then
  4306.    begin
  4307.     doOSErr(BadWindow);
  4308.     GetWData := nil;
  4309.    end
  4310.   else
  4311.    begin
  4312.     thePeek := WindowPeek(WhichWindow);
  4313.     TheHandle := Handle(thePeek^.RefCon);
  4314.     GetWData := WDataHandle(TheHandle);
  4315.    end;
  4316.  end;
  4317.  
  4318.  
  4319.  function GetWClass (whichWindow: WindowPtr): Integer;
  4320.   var
  4321.    WData: WDataHandle;
  4322.  begin
  4323.   WData := GetWData(whichWindow);
  4324.   if IsValidWindowHandle(WData) then
  4325.    GetWClass := WData^^.Class
  4326.   else
  4327.    GetWClass := -1;
  4328.  end;
  4329.  
  4330.  
  4331.  function GetWIndex (whichWindow: WindowPtr): Integer;
  4332.   var
  4333.    WData: WDataHandle;
  4334.  begin
  4335.   WData := GetWData(whichWindow);
  4336.   if IsValidWindowHandle(WData) then
  4337.    GetWIndex := WData^^.Index
  4338.   else
  4339.    GetWIndex := -1;
  4340.  end;
  4341.  
  4342.  
  4343.  function GetWHandle (whichWindow: WindowPtr): Handle;
  4344.   var
  4345.    WData: WDataHandle;
  4346.  begin
  4347.   WData := GetWData(whichWindow);
  4348.   if IsValidWindowHandle(WData) then
  4349.    GetWHandle := WData^^.DataHandle
  4350.   else
  4351.    begin
  4352.     GetWHandle := nil;
  4353.     doOSErr(BadWindow);
  4354.    end;
  4355.  end;
  4356.  
  4357.  
  4358.  procedure SetWHandle (whichWindow: WindowPtr; TheHandle: Handle);
  4359.   var
  4360.    WData: WDataHandle;
  4361.  begin
  4362.   WData := GetWData(whichWindow);
  4363.   if IsValidWindowHandle(WData) then
  4364.    WData^^.DataHandle := TheHandle
  4365.   else
  4366.    doOSErr(BadWindow);
  4367.  end;
  4368.  
  4369.  
  4370.  
  4371.  function InitializeWindow (whichWindow: WindowPtr; Class, Owner, Index: 
  4372. Integer): Boolean;
  4373.   var
  4374.    thePeek: WindowPeek;
  4375.    WData: WDataHandle;
  4376.    OkSoFar: Boolean;
  4377.    Result: Integer;
  4378.  begin
  4379.   OkSoFar := true;
  4380.   thePeek := WindowPeek(WhichWIndow);
  4381.   WData := WDataHandle(NewHandle(SizeOf(WindowData)));
  4382.   Result := MemError;
  4383.   if Result <> 0 then
  4384.    begin
  4385.     OkSoFar := False;
  4386.     doOSErr(MemError);
  4387.    end;
  4388.  
  4389.   if OkSoFar then
  4390.    begin
  4391.     thePeek^.RefCon := LongInt(WData);
  4392.     WData^^.Class := Class;
  4393.     WData^^.Owner := Owner;
  4394.     WData^^.Index := Index;
  4395.    end;
  4396.  
  4397.   InitializeWindow := OkSoFar;
  4398.  end;
  4399.  
  4400.  
  4401.  procedure DisposeWData (whichWindow: WindowPtr);
  4402.   var
  4403.    WData: WDataHandle;
  4404.  begin
  4405.   WData := GetWData(whichWindow);
  4406.   if IsValidWindowHandle(WData) then
  4407.    DisposHandle(Handle(WData))
  4408.   else
  4409.    doOSErr(BadWindow);
  4410.  end;
  4411.  
  4412.  
  4413. {I hope this is still a kosher way to find out which window is really in 
  4414. the front!  If this is no longer}
  4415. {kosher, then I'd just make an invisible window which is always frontmost 
  4416. (a la BringToFront) and}
  4417. {use it as my starting point for the search through the linked list.}
  4418.  function findFrontWindow: WindowPtr;
  4419.   const
  4420.    WindowList = $9D6;
  4421.   type
  4422.    PtrPtr = ^Ptr;
  4423.   var
  4424.    WindowListPtr: PtrPtr;
  4425.  begin
  4426.   WindowListPtr := Pointer(WindowList);
  4427.   findFrontWindow := WindowPtr(WindowListPtr^);  {was: FrontWindow}
  4428.  end;
  4429.  
  4430.  
  4431.  function SearchWindow (Class, Owner, Index: Integer): WindowPtr;
  4432.   var
  4433.    done: boolean;
  4434.    ThisWindow, FoundWindow: WindowPtr;
  4435.    WData: WDataHandle;
  4436.    ThisWPeek: WindowPeek;
  4437.  begin
  4438.   done := false;
  4439.   FoundWindow := nil;
  4440.   ThisWindow := FindFrontWindow;
  4441.   if ThisWindow <> nil then
  4442.    while not done do
  4443.     begin
  4444.      WData := GetWData(ThisWindow);
  4445.      if IsValidWindowHandle(WData) then
  4446.       if WData^^.Class = Class then
  4447.        if WData^^.Owner = Owner then
  4448.        if WData^^.Index = Index then
  4449.        begin
  4450.        FoundWindow := ThisWindow;
  4451.        Done := true;
  4452.        end;
  4453.      if not Done then
  4454.       begin
  4455.        ThisWPeek := WindowPeek(ThisWindow);
  4456.        ThisWPeek := ThisWPeek^.nextWindow;
  4457.        ThisWindow := WindowPtr(ThisWPeek);
  4458.        if ThisWindow = nil then
  4459.        Done := true;
  4460.       end;
  4461.     end;
  4462.   SearchWindow := FoundWindow;
  4463.  end;
  4464.  
  4465.  
  4466.  function CantActivate (Class, Owner, Index: Integer): Boolean;
  4467.   var
  4468.    ThisWindow: WindowPtr;
  4469.  begin
  4470.   CantActivate := TRUE;  {Assume the window doesn't exist.}
  4471.   ThisWindow := SearchWindow(Class, Owner, Index);
  4472.   if ThisWindow <> nil then
  4473.    begin
  4474.     SelectWindow(ThisWindow);
  4475.     CantActivate := FALSE;  {The window exists, so we _can_ activate it.}
  4476.    end;
  4477.  end;
  4478.  
  4479.  function FindUniqueWindow (Class: Integer): WindowPtr;
  4480.  begin
  4481.   FindUniqueWindow := SearchWindow(Class, 0, 0);
  4482. {By convention, all unique windows have 0 and 0 as their other arguments.}
  4483.  end;
  4484.  
  4485.  procedure AutoPositionPalettes (WhichWindow: WindowPtr);
  4486.  begin
  4487. {If you want your palettes to be automatically positioned next to a 
  4488. certain kind of window, put code here}
  4489. {to move the palettes to the right position.}
  4490.  end;
  4491.  
  4492. {This internal routine is used to hilite or unhilite windows.  Note that 
  4493. there's more going on here than}
  4494. {just drawing the hiliting on the window.  For our purposes, 'hilite' 
  4495. means 'bring it to the front, hilite it,}
  4496. {and display its palettes as well'.  'Unhilite' means 'Turn off its 
  4497. hiliting, and hide its palettes also.'}
  4498.  procedure SetPrivateHilite (whichWindow: WindowPtr; Hilite: Boolean);
  4499.  begin
  4500.   if WhichWindow = nil then
  4501.    doOSErr(BadWindow);
  4502.   if Hilite then
  4503.    begin
  4504.     BringToFront(whichWindow);
  4505.     ShowHide(whichWindow, TRUE);
  4506.    end;
  4507.   HiliteWindow(whichWindow, Hilite);
  4508. {If this window has a palette, bring it to the front as well.}
  4509.   case GetWClass(whichWindow) of
  4510. {You should modify the case selectors here to handle whatever kinds of 
  4511. windows with palettes your application supports.}
  4512.    wMiscWindowWithPalette: 
  4513.     begin
  4514.      if Hilite then
  4515.       begin
  4516.        AutoPositionPalettes(whichWindow);
  4517.        BringToFront(FindUniqueWindow(wMiscPalette));
  4518.       end;
  4519.      ShowHide(FindUniqueWindow(wMiscPalette), Hilite);
  4520.     end;
  4521.   end;
  4522.  end;
  4523.  
  4524. {Since we're using windows in a slightly unorthodox way, we can't rely on 
  4525. the Activate and Deactivate events}
  4526. {to do our work for us.  doSendPrivateActivateMessage is the routine to 
  4527. handle our equivalent of an Activate}
  4528. {event for the PrivateFrontWindow.  (Palettes can never be the 
  4529. PrivateFrontWindow, by definition.)}
  4530.  procedure doSendPrivateActivateMessage (whichWindow: WindowPtr);
  4531.  external;
  4532.  
  4533.  procedure privateActivate (whichWindow: WindowPtr);
  4534.  begin
  4535.   SetPrivateHilite(PrivateFrontWindow, FALSE);
  4536.   PrivateFrontWindow := whichWindow;
  4537.   SetPrivateHilite(PrivateFrontWindow, TRUE);
  4538. {Then send a message to update menus, etc.}
  4539.   doSendPrivateActivateMessage(PrivateFrontWindow);
  4540.  end;
  4541.  
  4542. end.
  4543.  
  4544.  
  4545.  
  4546.  
  4547. ---------------------------
  4548.  
  4549. >From grantd@dcs.gla.ac.uk (Dair Grant)
  4550. Subject: How does the Finder handle events?
  4551. Date: Wed, 9 Mar 1994 16:46:06 GMT
  4552. Organization: Glasgow University Computing Science Dept.
  4553.  
  4554.  
  4555. How does the Finder handle the high level Apple Events listed in its
  4556. 'fmnu' resources? I've sat in the event queue and watched the same events
  4557. arriving from other applications as expected, but the Finder doesn't
  4558. appear to send anything to itself for the same event (e.g., 'sdup').
  4559.  
  4560. I've also tried installing new handlers to override any original handlers,
  4561. but they're never actually called - in fact, they don't actually get to
  4562. override anything, as there don't seem to be any handlers installed which
  4563. they can override.
  4564.  
  4565. What mechanism does the Finder use for handling these AEs? How do things
  4566. like CopyDoubler intercept control? Any ideas?
  4567.  
  4568.  
  4569.  
  4570. -dair
  4571.  
  4572. +++++++++++++++++++++++++++
  4573.  
  4574. >From hubauer@telerama.lm.com (Bill Hubauer)
  4575. Date: 10 Mar 1994 08:24:35 -0500
  4576. Organization: Telerama Public Access Internet, Pittsburgh, PA
  4577.  
  4578. Dair Grant (grantd@dcs.gla.ac.uk) wrote:
  4579. :  
  4580. : How does the Finder handle the high level Apple Events listed in its
  4581. : 'fmnu' resources? I've sat in the event queue and watched the same events
  4582. : arriving from other applications as expected, but the Finder doesn't
  4583. : appear to send anything to itself for the same event (e.g., 'sdup').
  4584. :  
  4585. : I've also tried installing new handlers to override any original handlers,
  4586. : but they're never actually called - in fact, they don't actually get to
  4587. : override anything, as there don't seem to be any handlers installed which
  4588. : they can override.
  4589. :  
  4590. : What mechanism does the Finder use for handling these AEs? How do things
  4591. : like CopyDoubler intercept control? Any ideas?
  4592. :  
  4593. :  
  4594. :  
  4595. : -dair
  4596.  
  4597. The non-scriptable finder does not use the apple event manager at all.
  4598. It just uses highlevel events and parses them without the help of the
  4599. apple event manager.  This is why you can't patch in.
  4600.  
  4601. -- 
  4602. - -------------------------------------------
  4603. Bill Hubauer                          Hubauer@TeleRama.pgh.pa.us
  4604. AOL: MacBilly                         CIS: 76114,3012
  4605.  
  4606. +++++++++++++++++++++++++++
  4607.  
  4608. >From gurgle@netcom.com (Pete Gontier)
  4609. Date: Thu, 10 Mar 1994 17:45:01 GMT
  4610. Organization: cellular
  4611.  
  4612. hubauer@telerama.lm.com (Bill Hubauer) writes:
  4613.  
  4614. >Dair Grant (grantd@dcs.gla.ac.uk) wrote:
  4615.  
  4616. >: How does the Finder handle the high level Apple Events listed in its
  4617. >: 'fmnu' resources? I've sat in the event queue and watched the same
  4618. >: events arriving from other applications as expected, but the Finder
  4619. >: doesn't appear to send anything to itself for the same event (e.g.,
  4620. >: 'sdup').
  4621. >:
  4622. >: I've also tried installing new handlers to override any original
  4623. >: handlers, but they're never actually called - in fact, they don't
  4624. >: actually get to override anything, as there don't seem to be any
  4625. >: handlers installed which they can override.
  4626. >:
  4627. >: What mechanism does the Finder use for handling these AEs? How do
  4628. >: things like CopyDoubler intercept control? Any ideas?
  4629.  
  4630. >The non-scriptable finder does not use the apple event manager at all.
  4631. >It just uses highlevel events and parses them without the help of the
  4632. >apple event manager. This is why you can't patch in.
  4633.  
  4634. However, note that half of his investigations, he says, have been
  4635. with the event queue, not with the AppleEvent Manager. It would be
  4636. interesting to hear whether he is watching event records as they come
  4637. back from WNE or if he is waiting for Finder to call some other trap to
  4638. clue him in that there might be a high level event or AppleEvent being
  4639. handled. If the former, it sounds like Finder does not even defer its
  4640. event processing until the next iteration of the event loop. This would
  4641. not be surprising if Finder used AppleEvents, because the AE Manager
  4642. routes events sent to self directly to the handler. But we know Finder
  4643. is not using the AE Manager, so it might be that it sends high level
  4644. events to itself and somehow waits for the event loop to process them.
  4645. Then again, it might not. More information is in order. Oh, MacsBug...
  4646.  
  4647.     ATB A88F rA7^.w==34
  4648.  
  4649. ...which puts a break on PostHighLevelEvent, which is probably what
  4650. Finder would be using instead of AESend. Although it does get called
  4651. when Finder wants to open a document into a running app ('odoc' --
  4652. probably it's just the AE manager calling PostHighLevelEvent rather than
  4653. Finder), it doesn't get called when one makes a Finder menu selection
  4654. or drags an icon from one folder to another. However, doing little
  4655. investigations like this one is the very essence of this sort of hack.
  4656. Be persistent, and good luck.
  4657. -- 
  4658.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  4659.  
  4660. ---------------------------
  4661.  
  4662. >From dubois@uakari.primate.wisc.edu (Paul DuBois)
  4663. Subject: How to determine color of progress bar?
  4664. Date: 9 Mar 1994 23:05:40 -0600
  4665. Organization: Castra Parvulorum
  4666.  
  4667. When the Finder does a copy, it shows a progress bar.  How do
  4668. I tell what the background and foreground colors of the bar are?
  4669. -- 
  4670. Paul DuBois
  4671. dubois@primate.wisc.edu
  4672.  
  4673. +++++++++++++++++++++++++++
  4674.  
  4675. >From kenlong@netcom.com (Ken Long)
  4676. Date: Thu, 10 Mar 1994 08:47:42 GMT
  4677. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  4678.  
  4679. Do you want to tell what color they are, or make them be a certain color?
  4680.  
  4681. The gray is RGB 17476, and the lavender is R 52428, G 52428, B 65535.
  4682.  
  4683. Kinda hard to screen shot it while a dialog's cookin', huh.
  4684.  
  4685. The above numbers are from Joe Zobkiw's "Finder Prgress", which should 
  4686. also jive with Scott Knaster's "erasing your hard disk" SMP demo.
  4687.  
  4688. -Ken-
  4689.  
  4690. +++++++++++++++++++++++++++
  4691.  
  4692. >From kenlong@netcom.com (Ken Long)
  4693. Date: Thu, 10 Mar 1994 15:41:03 GMT
  4694. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  4695.  
  4696. That's "MPS" - not SMP.  ("club" finger, late night, craniaplegic, no 
  4697. glasses, keyboard worn out, etc.)
  4698.  
  4699. Mac Programming Secrets C source - dig?
  4700.  
  4701. -Ken-
  4702.  
  4703. +++++++++++++++++++++++++++
  4704.  
  4705. >From rmcassid@uci.edu (Robert Cassidy)
  4706. Date: Thu, 10 Mar 1994 10:24:22 -0700
  4707. Organization: TLG Project
  4708.  
  4709. In article <kenlongCMFxrI.Ep1@netcom.com>, kenlong@netcom.com (Ken Long)
  4710. wrote:
  4711.  
  4712. > Do you want to tell what color they are, or make them be a certain color?
  4713. > The gray is RGB 17476, and the lavender is R 52428, G 52428, B 65535.
  4714. > Kinda hard to screen shot it while a dialog's cookin', huh.
  4715. > The above numbers are from Joe Zobkiw's "Finder Prgress", which should 
  4716. > also jive with Scott Knaster's "erasing your hard disk" SMP demo.
  4717. > -Ken-
  4718.  
  4719. Does the progress bar vary it's colors according to the Color control panel
  4720. the way windows do? (I'd check, but I have a *%&$@# monochrome monitor)
  4721. I've only looked at windows and controls but these two have optional color
  4722. tables or system default color tables (based on Color control panel
  4723. settings) that contain the proper values. Look at Troy Gaul's Infinity
  4724. Windoid code. His code can show you what to do for black and white as well
  4725. as color - very helpful.
  4726.  
  4727. -- 
  4728. Robert Cassidy
  4729. TLG Project
  4730. UC Irvine
  4731.  
  4732. Let's hope 'Information SuperTollroad' isn't the catchphrase of the next
  4733. decade...
  4734.  
  4735. +++++++++++++++++++++++++++
  4736.  
  4737. >From mgr@aggroup.aggroup.com (Mike Russell)
  4738. Date: Thu, 10 Mar 1994 12:40:57 -0800
  4739. Organization: the ag group, inc.
  4740.  
  4741. In article <2lm9r4INNj2v@uakari.primate.wisc.edu>,
  4742. dubois@uakari.primate.wisc.edu (Paul DuBois) wrote:
  4743.  
  4744. > When the Finder does a copy, it shows a progress bar.  How do
  4745. > I tell what the background and foreground colors of the bar are?
  4746.  
  4747. I use shades of the user's select color, as someone suggested long
  4748. ago in this news group.  That way you use a color that the user chose
  4749. and presumably likes.
  4750.  
  4751. +++++++++++++++++++++++++++
  4752.  
  4753. >From kenlong@netcom.com (Ken Long)
  4754. Date: Fri, 11 Mar 1994 01:25:27 GMT
  4755. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  4756.  
  4757. So how do you get the colors the user set with the Colors Control Panel?  
  4758. Greg's buttons taps those, too.
  4759.  
  4760. I wasn't aware the progress colors change along with it.  I'll have to 
  4761. see that for myself.  (Oh goody!  Something else to do on my Mac!)
  4762.  
  4763. -Ken-
  4764.  
  4765. +++++++++++++++++++++++++++
  4766.  
  4767. >From troy@i-link.com (Troy Gaul)
  4768. Date: 11 Mar 1994 00:35:51 -0600
  4769. Organization: I-Link, Ltd., Des Moines, IA, USA - 515/255-2754
  4770.  
  4771. In article <kenlongCMH7yH.n0o@netcom.com>, Ken Long <kenlong@netcom.com> wrote:
  4772. >So how do you get the colors the user set with the Colors Control Panel?  
  4773. >Greg's buttons taps those, too.
  4774.  
  4775. If you get the Infinity Windoid WDEF and look in the Windoid Util file,
  4776. there's a routine that gets a color from the window color table and sets
  4777. it as the fore (or back) color. For example, do a:
  4778.  
  4779.         WctbForeColor(nil, wTingeLight);
  4780.  
  4781. [The nil is the window parameter, you could pass in the WindowPtr, but
  4782. if you use nil, it'll just use the default color table from the System.]
  4783.  
  4784. With the standard window colors, this maps to the steel blue that we all
  4785. know and love.  With another tinge color, it maps to the appropriate
  4786. shade of that tinge.
  4787.  
  4788. >I wasn't aware the progress colors change along with it.  I'll have to 
  4789. >see that for myself.  (Oh goody!  Something else to do on my Mac!)
  4790.  
  4791. They don't.  I've always thought this was a little odd.  Actually, I've
  4792. tried doing a progress bar that uses the tinge color, but it doesn't
  4793. always look great (some of those tinge colors don't work well in that
  4794. large of an area).
  4795.  
  4796. _troy
  4797.  
  4798.  
  4799. -- 
  4800. //////// //////   Troy Gaul                            t-gaul@i-link.com   //
  4801.   //    //       I-Link, Ltd.                                             //
  4802.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)              //
  4803. //    ////// __________________________________________________________ //
  4804.  
  4805. +++++++++++++++++++++++++++
  4806.  
  4807. >From kenlong@netcom.com (Ken Long)
  4808. Date: Fri, 11 Mar 1994 09:06:30 GMT
  4809. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  4810.  
  4811. Thanks for that info, Troy.  I'll have to get that WDEF out and 
  4812. thoroughly read it, and read up on it!
  4813.  
  4814. -Ken-
  4815.  
  4816. "I love it when a plan comes together."
  4817.     George Peppard as "Hannibal Smith"
  4818.  
  4819. +++++++++++++++++++++++++++
  4820.  
  4821. >From jwbaxter@olympus.net (John W. Baxter)
  4822. Date: Fri, 11 Mar 1994 12:58:24 -0800
  4823. Organization: Internet for the Olympic Peninsula
  4824.  
  4825. In article <mgr-100394124057@mike.aggroup.com>, mgr@aggroup.aggroup.com
  4826. (Mike Russell) wrote:
  4827.  
  4828. > I use shades of the user's select color, as someone suggested long
  4829. > ago in this news group.  That way you use a color that the user chose
  4830. > and presumably likes.
  4831.  
  4832. As a user, I really wish you wouldn't (although for progress bars it's not
  4833. so bad).  AppleScript Script Editor has "forced" me to use a neutral grey
  4834. for my highlight color, because it wants to use a shade of my highlight for
  4835. the frame of its script editing window (monitor in 16-color mode).  With a
  4836. highly visible highlight color, the result is bizarre.
  4837.  
  4838. -- 
  4839. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  4840.    jwbaxter@pt.olympus.net
  4841.  
  4842. +++++++++++++++++++++++++++
  4843.  
  4844. >From kenh@world.std.com (Ken Hancock)
  4845. Date: Sat, 12 Mar 1994 01:11:19 GMT
  4846. Organization: Isle Systems - Nashua, NH
  4847.  
  4848. In article <2lp3g7$l1p@ilink1.i-link.com>, Troy Gaul <troy@i-link.com> wrote:
  4849. >In article <kenlongCMH7yH.n0o@netcom.com>, Ken Long <kenlong@netcom.com> wrote:
  4850. >>I wasn't aware the progress colors change along with it.  I'll have to 
  4851. >>see that for myself.  (Oh goody!  Something else to do on my Mac!)
  4852. >
  4853. >They don't.  I've always thought this was a little odd.  Actually, I've
  4854. >tried doing a progress bar that uses the tinge color, but it doesn't
  4855. >always look great (some of those tinge colors don't work well in that
  4856. >large of an area).
  4857.  
  4858. This is one of the things which makes me think that the window color
  4859. control panel was a (good) hack by one of the engineeers who couldn't
  4860. stand the "standard" purple.  Personally, I've always done my
  4861. progress bars using wTingeLight as Apple should have, IMHO.
  4862. (It loes look silly having everything else in the window gold or green
  4863. but still have that $#*& progress bar be purple)
  4864.  
  4865. Ken
  4866.  
  4867.  
  4868. -- 
  4869. Ken Hancock             | INTERNET: kenh@vgi.com 
  4870. Isle Systems            | Compuserve: >INTERNET: kenh@vgi.com
  4871. Macintosh Consulting    | AOL: KHancock 
  4872.                         | Disclaimer: My opinions are mine,
  4873.  
  4874. +++++++++++++++++++++++++++
  4875.  
  4876. >From markhanrek@aol.com (MarkHanrek)
  4877. Date: 12 Mar 1994 04:54:01 -0500
  4878. Organization: America Online, Inc. (1-800-827-6364)
  4879.  
  4880. Do a cmd-shift-3 to take a snapshot of the screen while the progress dialog is
  4881. up, then use the eyedropper tool of any color graphics editing / paint program
  4882. to determine the RGB value or the indexed color value.
  4883.  
  4884. Mark Hanrek
  4885.  
  4886.  
  4887. +++++++++++++++++++++++++++
  4888.  
  4889. >From kenlong@netcom.com (Ken Long)
  4890. Date: Sat, 12 Mar 1994 19:14:30 GMT
  4891. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  4892.  
  4893. I don't know if it happens in every instance, but, usually, when there's 
  4894. some operation going on and you try to do a screen shot, the command to 
  4895. do the screen shot goes on the "waiting list" and is carried out after 
  4896. the current operation is complete.
  4897.  
  4898. Sometimes you can sneak a screenshot in if the operation is operating in 
  4899. a loop and checks for events (like the ones that look for keyDowns like 
  4900. Command-. etc.).
  4901.  
  4902. But those colors are pretty easy to spot in a system color palette, in 
  4903. ResEdit or a color paint program - especially after seeing them several 
  4904. times a day, 7 days a week, for 2 (?) years.
  4905.  
  4906. -Ken-
  4907.  
  4908. +++++++++++++++++++++++++++
  4909.  
  4910. >From D.A.G.Gillies@bradford.ac.uk (David Gillies)
  4911. Date: Mon, 14 Mar 1994 17:57:47 GMT
  4912. Organization: Unseen University, Ankh-Morpork
  4913.  
  4914. In article <rmcassid-100394102422@rmcassidy.tlg.uci.edu> rmcassid@uci.edu (Robert Cassidy) writes:
  4915. >In article <kenlongCMFxrI.Ep1@netcom.com>, kenlong@netcom.com (Ken Long)
  4916. >wrote:
  4917. >
  4918. >> Do you want to tell what color they are, or make them be a certain color?
  4919. >> 
  4920. >> The gray is RGB 17476, and the lavender is R 52428, G 52428, B 65535.
  4921. >> 
  4922. >> Kinda hard to screen shot it while a dialog's cookin', huh.
  4923. >> 
  4924. >> The above numbers are from Joe Zobkiw's "Finder Prgress", which should 
  4925. >> also jive with Scott Knaster's "erasing your hard disk" SMP demo.
  4926. >> 
  4927. >> -Ken-
  4928. >
  4929. >Does the progress bar vary it's colors according to the Color control panel
  4930. >the way windows do? (I'd check, but I have a *%&$@# monochrome monitor)
  4931. >I've only looked at windows and controls but these two have optional color
  4932. >tables or system default color tables (based on Color control panel
  4933. >settings) that contain the proper values. Look at Troy Gaul's Infinity
  4934. >Windoid code. His code can show you what to do for black and white as well
  4935. >as color - very helpful.
  4936.  
  4937.  
  4938. If it's any help, the lilac colour is no. 42 in the standard system palette.
  4939. I implement the progress bar by just having the system palette in my
  4940. application and calling PmForeColor(42). Maybe not very elegant, but hey, it
  4941. works.
  4942.  
  4943. ______________________________________________________________________
  4944. David A. G. Gillies                     (D.A.G.Gillies@bradford.ac.uk)
  4945. (c) 1994 Wittgenstein and The Furniture Depository of The Living Dead
  4946.  
  4947. A little learning is a dangerous thing - but not half as dangerous as a
  4948. lot of ignorance.
  4949.  
  4950. - ---------------------REPLIES VIA EMAIL PLEASE-----------------------
  4951. _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  4952.  
  4953. +++++++++++++++++++++++++++
  4954.  
  4955. >From walrathw@rferl.org (WalrathW)
  4956. Date: 14 Mar 94 15:31:56 -0500
  4957. Organization: RFE/RL Inc.
  4958.  
  4959. In article <2ls3fp$qta@search01.news.aol.com>
  4960. markhanrek@aol.com (MarkHanrek) writes:
  4961.  
  4962. > Do a cmd-shift-3 to take a snapshot of the screen while the progress dialog is
  4963. > up, then use the eyedropper tool of any color graphics editing / paint program
  4964. > to determine the RGB value or the indexed color value.
  4965. > Mark Hanrek
  4966.  
  4967. I should also point out a very useful set of FKEYs called Jon's FKEYs
  4968. which I use all the time. There is one which lets you get the color of
  4969. any pixel on the screen (in RGB, HSV, or CMY), and another which lets
  4970. you drag out a rect of marching ants and gives you the coordinates. I
  4971. use them all the time for determining what the cool colors other
  4972. developers are using in their hacks are. They're available at the usual
  4973. Mac archive sites.
  4974.  
  4975.  
  4976. ________oOo________ 
  4977.  Wayne Walrath    
  4978.  RFE/RL Inc.
  4979.  walrathW@rferl.org
  4980.  
  4981. +++++++++++++++++++++++++++
  4982.  
  4983. >From zobkiw@datawatch.com (joe zobkiw)
  4984. Date: Tue, 15 Mar 1994 12:29:12 GMT
  4985. Organization: Datawatch Corporation
  4986.  
  4987. In article <1994Mar14.153157.371@dcvaxb.rferl.org>, walrathw@rferl.org
  4988. (WalrathW) wrote:
  4989.  
  4990. Forget it...use this routine...this will return the light and dark tinges
  4991. currently being used by the WDEF/CDEF in System 7 to draw things like
  4992. scroll bars and window borders, etc. You can then use these colors to draw
  4993. the foreground and background of your progress bar. This way, you will
  4994. always match what the user has selected in the Color control panel.
  4995.  
  4996. And NO you shouldn't release the resource. Try it and you'll see why :)
  4997.  
  4998. /*******************************************************************************
  4999.  
  5000.     GetWindowTinges
  5001.  
  5002.     Should have color quickdraw for this routine to be called
  5003. *******************************************************************************/
  5004.  
  5005. void GetWindowTinges(RGBColor *lightTinge, RGBColor *darkTinge)
  5006. {
  5007.     CTabHandle    windowCTable;
  5008.     
  5009.     lightTinge->red = lightTinge->green = lightTinge->blue = 0xffff;
  5010.     darkTinge->red = darkTinge->green = darkTinge->blue = 0x0000;
  5011.     
  5012.     if ((windowCTable = (CTabHandle)GetResource('wctb', 0)) != nil) {
  5013.         *lightTinge = (**windowCTable).ctTable[11].rgb;
  5014.         *darkTinge = (**windowCTable).ctTable[12].rgb;
  5015.     }
  5016.     
  5017.     /* case for black and white window defs under system 7, both return black!
  5018. */
  5019.     if ((lightTinge->red == 0x0000) && (lightTinge->green == 0x0000) &&
  5020. (lightTinge->blue == 0x0000))
  5021.         lightTinge->red = lightTinge->green = lightTinge->blue = 0xffff;
  5022.  
  5023. }
  5024.  
  5025. ___________________________________________________________
  5026. _/_/_/_/   Joe Zobkiw                                   ,,,
  5027.     _/     Senior Software Engineer                     - -
  5028.   _/       Datawatch Corporation                         L
  5029. _/_/_/_/   zobkiw@datawatch.com                          -
  5030.  
  5031. +++++++++++++++++++++++++++
  5032.  
  5033. >From KLUEV@jonathan.srcc.msu.su
  5034. Date: Wed, 16 Mar 1994 21:06:43 +0300
  5035. Organization: (none)
  5036.  
  5037. In article <zobkiw-150394072912@zobkiw.datawatch.com>
  5038. zobkiw@datawatch.com (joe zobkiw) writes:
  5039. >In article <1994Mar14.153157.371@dcvaxb.rferl.org>, walrathw@rferl.org
  5040. >(WalrathW) wrote:
  5041. >
  5042. >Forget it...use this routine...this will return the light and dark tinges
  5043. >currently being used by the WDEF/CDEF in System 7 to draw things like
  5044. >scroll bars and window borders, etc. You can then use these colors to draw
  5045. >the foreground and background of your progress bar. This way, you will
  5046. >always match what the user has selected in the Color control panel.
  5047. >
  5048. >And NO you shouldn't release the resource. Try it and you'll see why :)
  5049. >
  5050. ... Code deleted ...
  5051. >        if ((windowCTable = (CTabHandle)GetResource('wctb', 0)) != nil) {
  5052. >                *lightTinge = (**windowCTable).ctTable[11].rgb;
  5053. >                *darkTinge = (**windowCTable).ctTable[12].rgb;
  5054. ...
  5055.  
  5056. It's better to use GetAuxWin procedure. This way you will take into
  5057. account custom 'wctb's.
  5058.  
  5059. Michael Kluev.
  5060.  
  5061. +++++++++++++++++++++++++++
  5062.  
  5063. >From rollin@newton.apple.com (Keith Rollin)
  5064. Date: Sun, 13 Mar 1994 01:32:55 GMT
  5065. Organization: Apple Computer, Inc.
  5066.  
  5067. In article <2ls3fp$qta@search01.news.aol.com>, markhanrek@aol.com
  5068. (MarkHanrek) wrote:
  5069.  
  5070. > Do a cmd-shift-3 to take a snapshot of the screen while the progress dialog is
  5071. > up, then use the eyedropper tool of any color graphics editing / paint program
  5072. > to determine the RGB value or the indexed color value.
  5073.  
  5074. A neat idea, but not the best way to go. The color specified by the program
  5075. drawing the progress bar (e.g., the Finder) is not necessarily the one that
  5076. appears on the screen. Instead, the RGB color specified is mapped to the
  5077. closest available color in the screen device's color table. To look at an
  5078. extreme example, if the screen is in B&W mode, a nice purple will get
  5079. mapped to black. Even on a 256 color device, the color specified will
  5080. almost always be different than that displayed.
  5081.  
  5082. When I was working on "Macintosh Programming Secrets", I wanted to get the
  5083. *exact* colors that the Finder was using. To do this, I set breakpoints on
  5084. a few of QuickDraw's calls (like PaintRect and FillCRect). I can't remember
  5085. exactly what call the Finder was using, but when I broke into the debugger,
  5086. I was able to either look at the color being passed into the call, or the
  5087. RGBForeColor in the current CGrafPort.
  5088.  
  5089. - --------------------------------------------------------------------------
  5090. Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team
  5091. Newton
  5092.  
  5093. +++++++++++++++++++++++++++
  5094.  
  5095. >From melissa@i-link.com (Melissa Gaul)
  5096. Date: Wed, 16 Mar 1994 18:41:48 -0600
  5097. Organization: I-Link, Ltd.
  5098.  
  5099. In article <862D4F21C8@VADIK.srcc.msu.su>, KLUEV@jonathan.srcc.msu.su
  5100. wrote:
  5101.  
  5102. > In article <zobkiw-150394072912@zobkiw.datawatch.com>
  5103. > zobkiw@datawatch.com (joe zobkiw) writes:
  5104. > >In article <1994Mar14.153157.371@dcvaxb.rferl.org>, walrathw@rferl.org
  5105. > >(WalrathW) wrote:
  5106. > >
  5107. > >Forget it...use this routine...this will return the light and dark tinges
  5108. > >currently being used by the WDEF/CDEF in System 7 to draw things like
  5109. > >scroll bars and window borders, etc. You can then use these colors to draw
  5110. > >the foreground and background of your progress bar. This way, you will
  5111. > >always match what the user has selected in the Color control panel.
  5112. > >
  5113. > >And NO you shouldn't release the resource. Try it and you'll see why :)
  5114. > >
  5115. > ... Code deleted ...
  5116. > >        if ((windowCTable = (CTabHandle)GetResource('wctb', 0)) != nil) {
  5117. > >                *lightTinge = (**windowCTable).ctTable[11].rgb;
  5118. > >                *darkTinge = (**windowCTable).ctTable[12].rgb;
  5119. > ...
  5120. > It's better to use GetAuxWin procedure. This way you will take into
  5121. > account custom 'wctb's.
  5122.  
  5123. If you do this, you should also be prepared in case the window's color
  5124. table (from GetAuxWin) isn't long enough to hold the tinge colors you're
  5125. looking for. Then, you could try GetAuxWin(nil) and try there, but this
  5126. might still not have enough, so you should have some built-in defaults. 
  5127.  
  5128. (This all assumes you want to handle all cases. If you control the windows
  5129. in your application and know this isn't needed, you might be able to avoid
  5130. it.)
  5131.  
  5132. _troy
  5133. ////////_//////___Troy Gaul_________________________t-gaul@i-link.com___//
  5134.   //    //       I-Link, Ltd.                                          //
  5135.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)           //
  5136. //____//////_________________________________________________________//
  5137.  
  5138. +++++++++++++++++++++++++++
  5139.  
  5140. >From giles@med.cornell.edu (Aaron Giles)
  5141. Date: Wed, 16 Mar 1994 22:12:52 -0500
  5142. Organization: Cornell University Medical College
  5143.  
  5144. In article <rollin-120394173255@rollin-keith.apple.com>,
  5145. rollin@newton.apple.com (Keith Rollin) wrote:
  5146.  
  5147. > In article <2ls3fp$qta@search01.news.aol.com>, markhanrek@aol.com
  5148. > (MarkHanrek) wrote:
  5149. >> Do a cmd-shift-3 to take a snapshot of the screen while the progress dialog is
  5150. >> up, then use the eyedropper tool of any color graphics editing / paint program
  5151. >> to determine the RGB value or the indexed color value.
  5152. > A neat idea, but not the best way to go. The color specified by the program
  5153. > drawing the progress bar (e.g., the Finder) is not necessarily the one that
  5154. > appears on the screen. Instead, the RGB color specified is mapped to the
  5155. > closest available color in the screen device's color table.
  5156.  
  5157. Of course, if you do this on a 24-bit color screen, you don't need to
  5158. worry. :-)  If you want your progress bars to look like the Finder's, try:
  5159.  
  5160.     static RGBColor gBarBackground = { 0xcccc, 0xcccc, 0xffff };
  5161.     static RGBColor gBarForeground = { 0x6666, 0x6666, 0x6666 };
  5162.  
  5163. Assuming that "background" refers to the steel blue, and "foreground"
  5164. refers to the gray.
  5165.  
  5166. Aaron
  5167. -- 
  5168. Aaron Giles
  5169. Macintosh & Newton Developer
  5170. Cornell University Medical College
  5171. giles@med.cornell.edu
  5172.  
  5173. +++++++++++++++++++++++++++
  5174.  
  5175. >From troy@i-link.com (Troy Gaul)
  5176. Date: Thu, 17 Mar 1994 00:02:56 -0600
  5177. Organization: I-Link, Ltd.
  5178.  
  5179. >In article <melissa-160394184148@ts1-3.i-link.com>, melissa@i-link.com 
  5180. >(Melissa Gaul) wrote:
  5181.  
  5182. Oops, that was supposed to be me, not my wife. :(
  5183.  
  5184. Just goes to show how a mechanism for having different preferences files
  5185. for two people who use the same machine can be important, I guess...
  5186.  
  5187. _troy
  5188. ////////_//////___Troy Gaul_________________________t-gaul@i-link.com___//
  5189.   //    //       I-Link, Ltd.                                          //
  5190.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)           //
  5191. //____//////_________________________________________________________//
  5192.  
  5193. +++++++++++++++++++++++++++
  5194.  
  5195. >From arentz@batcave.knoware.nl (Stefan Arentz)
  5196. Date: Thu, 17 Mar 1994 17:15:57 GMT
  5197. Organization: Knoware
  5198.  
  5199. In article <rollin-120394173255@rollin-keith.apple.com>,
  5200. rollin@newton.apple.com (Keith Rollin) wrote:
  5201.  
  5202. > When I was working on "Macintosh Programming Secrets", I wanted to get the
  5203. > *exact* colors that the Finder was using. To do this, I set breakpoints on
  5204. > a few of QuickDraw's calls (like PaintRect and FillCRect). I can't remember
  5205. > exactly what call the Finder was using, but when I broke into the debugger,
  5206. > I was able to either look at the color being passed into the call, or the
  5207. > RGBForeColor in the current CGrafPort.
  5208.  
  5209. RGBColor    CProgressIndicator::mBlack     = { 0x0000, 0x0000, 0x0000 };
  5210. RGBColor    CProgressIndicator::mWhite     = { 0xFFFF, 0xFFFF, 0xFFFF };
  5211. RGBColor    CProgressIndicator::mDarkGrey  = { 0x4000, 0x4000, 0x4000 };
  5212. RGBColor    CProgressIndicator::mSteelBlue    = { 0xCCCC, 0xCCCC, 0xFFFF };
  5213.  
  5214. Black is black, White is white, SteelBlue is the background color of the
  5215. indicator, and DarkGray is the color of the moving bar...
  5216.  
  5217. Great Book Keith! ;-)
  5218.  
  5219. > ----------------------------------------------------------------------------
  5220. > Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team Newton
  5221.  
  5222. Er, Team Newton? Does this mean we can expect a 'Newton Programming
  5223. Secrets'?
  5224.  
  5225. -- Stefan
  5226.  
  5227. - -----------------------------------------------------------------------
  5228. Stefan Arentz    -- Lunatech Software Development --    arentz@knoware.nl
  5229.  
  5230. +++++++++++++++++++++++++++
  5231.  
  5232. >From mshields%peruvian.cs.utah.edu@cs.utah.edu (Michael S Shields)
  5233. Date: 17 Mar 94 16:25:05 MST
  5234. Organization: University of Utah Computer Science
  5235.  
  5236.  
  5237. Um,
  5238.  
  5239. I just did a little test and I found that the progress bar in a finder copy
  5240. doesn't depend on the window cor.  I usually have my windws at the "Standard"
  5241. color, so I switched it to red and the progress bar was still in the dark grey/
  5242. purplish color combo. So, I think that putting up a progress bar in the window
  5243. colors might be unnerving to a user if you are trying to mimic the Finder.
  5244. Also, it's work you could eliminate to spend more time on other things.
  5245.  
  5246. Mike
  5247. mshields@peruvian.cs.utah.edu
  5248. mshields@dayna.com
  5249.  
  5250.  
  5251.  
  5252. ---------------------------
  5253.  
  5254. >From peloy@ccxbbs.uunet.ve
  5255. Subject: How to draw inits icons?
  5256. Date: 2 Mar 1994 07:35:11 -0600
  5257. Organization: Caracas Computer Exchange BBS
  5258.  
  5259. To: comp-sys-mac-programmer@cs.utexas.edu
  5260.  
  5261. Hello there.
  5262.  
  5263. I've looking so far to find how to draw my INIT's icon on the bottom of the
  5264. screen at boot time. I haven't found anything in Inside Macintosh or in the
  5265. Technical Notes.
  5266.  
  5267. I would like to know how can I do this. I could borrow the code needed to draw
  5268. the icon from any INIT but I would like to understand how it works. When doing
  5269. "reverse engineering" on the code to draw INIT's icons, I've found some low
  5270. memory variables that are not documented.
  5271.  
  5272. It would be very fine if you can send me source code to do this or you can
  5273. explain me how to do my own code.
  5274.  
  5275. I don't have direct access to c.s.m.p. so please send your help to my
  5276. electronic address (peloy@ccxbbs.uunet.ve).
  5277.  
  5278. Thans a lot in advance,
  5279. Eloy A. Paris <peloy@ccxbbs.uunet.ve>
  5280.  
  5281.  
  5282.  -> Alice4Mac 2.2.2E QWK Ser#127-1073 
  5283.  
  5284. +++++++++++++++++++++++++++
  5285.  
  5286. >From kenlong@netcom.com (Ken Long)
  5287. Date: Wed, 2 Mar 1994 16:58:26 GMT
  5288. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  5289.  
  5290. There's a couple files you can get.  Connect to:
  5291.  
  5292. ftp bigbird.csd.scarolina.edu
  5293.  
  5294. and in the pub/mac directory is Jim Walker's "ShowIcon7" - a C project 
  5295. and info on doing that.
  5296.  
  5297. Then, in alt.sources.mac is a file I got off AOL that is a C project for 
  5298. generic control panels and INITs which use "ShowINIT.c" to show it.  I 
  5299. tried the example CP in this file and it did, indeed, show its icon on 
  5300. startup.  The file is probably on sumex, as well.
  5301.  
  5302. -Ken-
  5303.  
  5304. ---------------------------
  5305.  
  5306. >From dat91jre@ludat.lth.se (Regmyr Jonas)
  5307. Subject: How to tell a Mac from a Mac?
  5308. Date: 7 Mar 1994 08:49:33 GMT
  5309. Organization: Lund Institute of Technology, Sweden
  5310.  
  5311. Hi!
  5312.  
  5313. Is there a way to tell one Mac from anotherone or, is there a way
  5314. for a program to tell if it has been moved from one machine to
  5315. anotherone, possible the same type (from, say, one Classic to another)?
  5316. If so, how do I do this?
  5317.  
  5318. I've thought about some ways to achive this:
  5319. If there is a way to get the serial # of the machine the problem
  5320.     is solved (probably won't work).
  5321. One could use the name of the boot volume but, what if the user
  5322.     change it -> program will get confused (not so nice approach).
  5323. If there is a way to write to ROM there is a way to check the
  5324.     appearance of some word, bit or whatever and by that know if
  5325.     I've (the program) been here before (can one do this?).
  5326.  
  5327. For me, this problem is yet to be solved.
  5328. Please help me.
  5329.  
  5330. Thanx...
  5331.  
  5332.                     /Jonas...
  5333.  
  5334.  
  5335. -- 
  5336. Mail: Karl Jonas Regmyr   Carl Hillsgatan 9   S-217 56 Malmoe Sweden
  5337. Phone: +46 (0)40 91 42 41               Email: dat91jre@ludat.lth.se
  5338.  
  5339. +++++++++++++++++++++++++++
  5340.  
  5341. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  5342. Date: 7 Mar 1994 11:02:09 GMT
  5343. Organization: Royal Institute of Technology, Stockholm, Sweden
  5344.  
  5345. In <2lepqt$1g3@nic.lth.se> dat91jre@ludat.lth.se (Regmyr Jonas) writes:
  5346.  
  5347. >Is there a way to tell one Mac from anotherone or, is there a way
  5348. >for a program to tell if it has been moved from one machine to
  5349. >anotherone, possible the same type (from, say, one Classic to another)?
  5350.  
  5351. Yes; write your program to require an ADB dongle; thus if your
  5352. user moves the application but not the dongle (hardware key)
  5353. your app will notice it has been moved.
  5354.  
  5355. Copy protection in evil.
  5356.  
  5357. >If there is a way to get the serial # of the machine the problem
  5358.  
  5359. Nope.
  5360.  
  5361. >One could use the name of the boot volume but, what if the user
  5362. >    change it -> program will get confused (not so nice approach).
  5363.  
  5364. Very bad; users switch between systems daily for things like
  5365. System 6 or Kanji or whatever.
  5366.  
  5367. >If there is a way to write to ROM there is a way to check the
  5368. >    appearance of some word, bit or whatever and by that know if
  5369. >    I've (the program) been here before (can one do this?).
  5370.  
  5371. ROM == Read-Only Memory == not-writable.
  5372.  
  5373. The simplest thing you can do is to check if your preferences
  5374. file is there in the preferences folder; if it's not, it's
  5375. probably a new installation (or the user installed a new system
  5376. or restored a backup, or switched systems or whatever)
  5377.  
  5378. -- 
  5379.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  5380.  
  5381.    This article printed on 100% recycled electrons.
  5382.  
  5383. +++++++++++++++++++++++++++
  5384.  
  5385. >From Matt Slot <fprefect@engin.umich.edu>
  5386. Date: 7 Mar 1994 11:45:09 GMT
  5387. Organization: University of Michigan
  5388.  
  5389.  Regmyr Jonas, dat91jre@ludat.lth.se writes:
  5390.  
  5391. >Is there a way to tell one Mac from another one or, is there a way
  5392. >for a program to tell if it has been moved from one machine to
  5393. >anotherone, possible the same type (from, say, one Classic to another)?
  5394. >If so, how do I do this?
  5395. - -----------
  5396. First a note: dont make self-modifying apps! Your app should not store
  5397. machine specific information within itself; if you save a preference
  5398. do it to a preferences file. 
  5399.  
  5400. OK, off the podium. If you still need to identify a Mac from another,
  5401. use the Volume Creation date for VRefNum = -1. This is the long date
  5402. to the second of the initialization of that HD. For a 1 in 4 billion
  5403. chance of duplication, this works rather well. If the user *does*
  5404. reformat the boot disk, it will probably be a full reinstall and for
  5405. all intents a "new" machine.
  5406.  
  5407. Matt
  5408.  
  5409. +++++++++++++++++++++++++++
  5410.  
  5411. >From u9119523@sys.uea.ac.uk (Graham Cox)
  5412. Date: Mon, 7 Mar 1994 11:32:44 GMT
  5413. Organization: School of Information Systems, UEA, Norwich
  5414.  
  5415. In article <2lf1jh$rk2@news.kth.se>, d88-jwa@mumrik.nada.kth.se (Jon Wtte)
  5416. wrote:
  5417.  
  5418. > In <2lepqt$1g3@nic.lth.se> dat91jre@ludat.lth.se (Regmyr Jonas) writes:
  5419. > >Is there a way to tell one Mac from anotherone or, is there a way
  5420. > >for a program to tell if it has been moved from one machine to
  5421. > >anotherone, possible the same type (from, say, one Classic to another)?
  5422.  
  5423. Here's a simple way. Get the Date/Time of initialization of the startup
  5424. disk. As this is accurate to the second, the chance of two Macs having
  5425. their hard disks initialised at the same time is very small.
  5426.  
  5427. You can store this value in your app's preferences, and compare it with the
  5428. current disk at startup. If different, you can ask the user to enter a
  5429. validation code. If correct, you can then update the disk "ID" so the user
  5430. doesn't get bothered again, unless the program is copied to another
  5431. machine. If you add some kind of encryption to the stored values, the
  5432. likelihood of someone being able to hack the values is virtually
  5433. non-existent. I used this method on a commercial app and it works a treat.
  5434. It's also one of the few copy-protection methods thats absolutely
  5435. compatible with the system and unlikely to fail in future releases.
  5436.  
  5437.  
  5438. - ------------------------------------------------------------------------
  5439. Love & BSWK, Graham
  5440.  
  5441. -Everyone is entitled to their opinion, no matter how wrong they may be...
  5442. - ------------------------------------------------------------------------
  5443.  
  5444. +++++++++++++++++++++++++++
  5445.  
  5446. >From ajr3@quads.uchicago.edu (Alain Roy)
  5447. Date: Mon, 7 Mar 1994 15:00:36 GMT
  5448. Organization: University of Chicago
  5449.  
  5450. In article <u9119523-070394123244@graphics1.sys.uea.ac.uk> u9119523@sys.uea.ac.uk (Graham Cox) writes:
  5451. >
  5452. >Here's a simple way. Get the Date/Time of initialization of the startup
  5453. >disk. As this is accurate to the second, the chance of two Macs having
  5454. >their hard disks initialised at the same time is very small.
  5455.  
  5456. works unless you're like me: i have 2 hard drives. if every time i switched,
  5457. i had the copy protection of a program fire up, i'd be really upset.
  5458.  
  5459. -alain
  5460.  
  5461. +++++++++++++++++++++++++++
  5462.  
  5463. >From time@garnet.msen.com (Tim Endres)
  5464. Date: 7 Mar 1994 19:22:52 GMT
  5465. Organization: Msen, Inc. -- Ann Arbor, MI (account info: +1 313 998-4562)
  5466.  
  5467. Matt Slot (fprefect@engin.umich.edu) wrote:
  5468. :  Regmyr Jonas, dat91jre@ludat.lth.se writes:
  5469. :  
  5470. : >Is there a way to tell one Mac from another one or, is there a way
  5471. : >for a program to tell if it has been moved from one machine to
  5472. : >anotherone, possible the same type (from, say, one Classic to another)?
  5473. : >If so, how do I do this?
  5474. : -------------
  5475. : First a note: dont make self-modifying apps! Your app should not store
  5476. : machine specific information within itself; if you save a preference
  5477. : do it to a preferences file. 
  5478.  
  5479. Unless you need a self-modifying app, such as TransIt.
  5480.  
  5481. : OK, off the podium. If you still need to identify a Mac from another,
  5482. : use the Volume Creation date for VRefNum = -1. This is the long date
  5483. : to the second of the initialization of that HD. For a 1 in 4 billion
  5484.  
  5485. Except that most times are in the range from 1984 to 1994, as
  5486. opposed to 1904 to 1994. Thus, closer to 478 Million. Still reasonable.
  5487.  
  5488. : chance of duplication, this works rather well. If the user *does*
  5489. : reformat the boot disk, it will probably be a full reinstall and for
  5490. : all intents a "new" machine.
  5491.  
  5492. Or, as pointed out, the user boots from more than one
  5493. volume. In this case, you need to keep a "list" of
  5494. drives, which may not be what you want.
  5495.  
  5496. +++++++++++++++++++++++++++
  5497.  
  5498. >From gregor@nrlfs1.nrl.navy.mil (joe gregor)
  5499. Date: Mon, 7 Mar 1994 19:45:14 GMT
  5500. Organization: NRL
  5501.  
  5502. In Article <2lf445$5qd@lastactionhero.rs.itd.umich.edu>, Matt Slot
  5503. <fprefect@engin.umich.edu> wrote:
  5504.  
  5505. >OK, off the podium. If you still need to identify a Mac from another,
  5506. >use the Volume Creation date for VRefNum = -1. This is the long date
  5507. >to the second of the initialization of that HD. For a 1 in 4 billion
  5508. >chance of duplication, this works rather well. If the user *does*
  5509. >reformat the boot disk, it will probably be a full reinstall and for
  5510. >all intents a "new" machine.
  5511. >
  5512.     Never had to replace a hard disk before, huh.
  5513.  
  5514.             -- Joe
  5515.  
  5516. +++++++++++++++++++++++++++
  5517.  
  5518. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  5519. Date: Mon, 7 Mar 94 13:52:36 PST
  5520. Organization: Peirce Software, Inc.
  5521.  
  5522.  
  5523. In article <u9119523-070394123244@graphics1.sys.uea.ac.uk> (comp.sys.mac.programmer), u9119523@sys.uea.ac.uk (Graham Cox) writes:
  5524. > Here's a simple way. Get the Date/Time of initialization of the startup
  5525. > disk. As this is accurate to the second, the chance of two Macs having
  5526. > their hard disks initialised at the same time is very small.
  5527. > You can store this value in your app's preferences, and compare it with the
  5528. > current disk at startup. If different, you can ask the user to enter a
  5529. > validation code. If correct, you can then update the disk "ID" so the user
  5530. > doesn't get bothered again, unless the program is copied to another
  5531. > machine. If you add some kind of encryption to the stored values, the
  5532. > likelihood of someone being able to hack the values is virtually
  5533. > non-existent. I used this method on a commercial app and it works a treat.
  5534. > It's also one of the few copy-protection methods thats absolutely
  5535. > compatible with the system and unlikely to fail in future releases.
  5536.  
  5537. How do people feel about this technique.  Are there any obvious drawbacks?
  5538.  
  5539. It does mean you need to "install" the software on each new system
  5540. disk, any objections to this?
  5541.  
  5542.  
  5543. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  5544. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  5545. --                       -- San Jose, California USA 95117
  5546. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  5547. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  5548.  
  5549. +++++++++++++++++++++++++++
  5550.  
  5551. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  5552. Date: 8 Mar 1994 13:04:08 +0800
  5553. Organization: NCRPDA, Curtin University
  5554.  
  5555. time@garnet.msen.com (Tim Endres) writes:
  5556.  
  5557. >: First a note: dont make self-modifying apps! Your app should not store
  5558. >: machine specific information within itself; if you save a preference
  5559. >: do it to a preferences file. 
  5560.  
  5561. >Unless you need a self-modifying app, such as TransIt.
  5562.  
  5563. Besides, it's perfectly reasonable to modify yourself during instalation.
  5564. But it would definiitely be bad later on when the admin has writeprotected
  5565. the directory (and it's not much use on CDROMs either, etc).
  5566.  
  5567. >Or, as pointed out, the user boots from more than one
  5568. >volume. In this case, you need to keep a "list" of
  5569. >drives, which may not be what you want.
  5570.  
  5571. That's not really needed - if you boot from a seperate disk, then you'll
  5572. have a seperate prefs file, so you'll have to enter the serial number
  5573. once per system folder, thats not particularly unreasonable (and I hate
  5574. copy protection!).
  5575.  
  5576. The main draw back of this scheme is that it's a royal pain in the ass
  5577. for network mutli-user licenses.  I think you can guess how happy I'd be
  5578. to buy a twenty user license and then have the fun of going around
  5579. typing serial numbers into every damn machine - and since this is such
  5580. a pain, I'll probably not recomend your software as the one to buy...
  5581.    Peter.
  5582. -- 
  5583. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  5584.  
  5585. +++++++++++++++++++++++++++
  5586.  
  5587. >From ivanski@world.std.com (Ivan M CaveroBelaunde)
  5588. Date: Tue, 8 Mar 1994 16:30:43 GMT
  5589. Organization: The World Public Access UNIX, Brookline, MA
  5590.  
  5591. peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  5592. >In article <u9119523-070394123244@graphics1.sys.uea.ac.uk> (comp.sys.mac.programmer), u9119523@sys.uea.ac.uk (Graham Cox) writes:
  5593. >> Here's a simple way. Get the Date/Time of initialization of the startup
  5594. >> disk. As this is accurate to the second, the chance of two Macs having
  5595. >> their hard disks initialised at the same time is very small.
  5596. >> 
  5597. >> You can store this value in your app's preferences, and compare it with the
  5598. >> current disk at startup. If different, you can ask the user to enter a
  5599. >> validation code. If correct, you can then update the disk "ID" so the user
  5600. >> doesn't get bothered again, unless the program is copied to another
  5601. >> machine. If you add some kind of encryption to the stored values, the
  5602. >> likelihood of someone being able to hack the values is virtually
  5603. >> non-existent. I used this method on a commercial app and it works a treat.
  5604. >> It's also one of the few copy-protection methods thats absolutely
  5605. >> compatible with the system and unlikely to fail in future releases.
  5606. >How do people feel about this technique.  Are there any obvious drawbacks?
  5607. >It does mean you need to "install" the software on each new system
  5608. >disk, any objections to this?
  5609.  
  5610. Actually, I really dislike the idea of having to install the software on
  5611. each new system, or being unable to switch to a different startup disk
  5612. (if say my startup volume died suddenly). I'd advocate a much different route
  5613. (which might be in use right now, since I've seen software behave this
  5614. way). Currently, a lot of software requires the user to do the first launch
  5615. on a writable volume in order to store registration information. As long
  5616. as it runs off of a read-only volume (ie a server) after that one registration
  5617. step, that doesn't bother me, and I don't think most users would be hassled
  5618. by this too much either. Consequently, I'd consider doing the following -
  5619. when prompting the user for registration information (which would be stored
  5620. inside the app), also look at the date/time of initialization of the
  5621. volume CONTAINING THE APP, and also look at the fileID of the app itself
  5622. (ie manually build a mini alias). Then store this information with the
  5623. registration information inside the app, and check against it at app
  5624. launch. This way, you can detect if the app file itself has been copied,
  5625. and reprompt for registration info if this is the case. The method is
  5626. flexible enough that if you wanted to allow some variants of copying
  5627. (ie doing a duplicate on the app file in the finder), you could check that
  5628. the app the reg info specifies is present and meets some basic checks
  5629. (as opposed to requiring that the app you are RUNNING is the app the reg
  5630. info points to). The other drawback is that this requires installation of
  5631. software on read-only servers by users with write permission - but this
  5632. requirement is present currently anyway.
  5633.  
  5634. Comments?
  5635.  
  5636. -Ivan
  5637. - -
  5638. Ivan Cavero Belaunde (ivanski@world.std.com)
  5639. Avid VideoShop Project Lead
  5640. Avid Technology, Inc.
  5641.  
  5642. +++++++++++++++++++++++++++
  5643.  
  5644. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  5645. Date: Tue, 8 Mar 94 09:16:22 PST
  5646. Organization: Peirce Software, Inc.
  5647.  
  5648.  
  5649. In article <1994Mar7.150036.11171@midway.uchicago.edu> (comp.sys.mac.programmer), ajr3@quads.uchicago.edu (Alain Roy) writes:
  5650. > In article <u9119523-070394123244@graphics1.sys.uea.ac.uk> u9119523@sys.uea.ac.uk (Graham Cox) writes:
  5651. > >
  5652. > >Here's a simple way. Get the Date/Time of initialization of the startup
  5653. > >disk. As this is accurate to the second, the chance of two Macs having
  5654. > >their hard disks initialised at the same time is very small.
  5655. > works unless you're like me: i have 2 hard drives. if every time i switched,
  5656. > i had the copy protection of a program fire up, i'd be really upset.
  5657.  
  5658. But this would only happen the first time you started up on your second
  5659. disk.  After that, its prefs file would contain the init time of *that*
  5660. disk.
  5661.  
  5662.  
  5663. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  5664. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  5665. --                       -- San Jose, California USA 95117
  5666. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  5667. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  5668.  
  5669. +++++++++++++++++++++++++++
  5670.  
  5671. >From time@garnet.msen.com (Tim Endres)
  5672. Date: 8 Mar 1994 18:47:42 GMT
  5673. Organization: Msen, Inc. -- Ann Arbor, MI (account info: +1 313 998-4562)
  5674.  
  5675. I really like Ivan's idea of storing the time for the disk
  5676. that the *app* is on. This solves Peter's network installation
  5677. problems and it solves CD and server setups.
  5678.  
  5679. +++++++++++++++++++++++++++
  5680.  
  5681. >From mahboud@aggroup.com (Mahboud Zabetian)
  5682. Date: Tue, 08 Mar 1994 11:37:13 -0800
  5683. Organization: AG Group, Inc.
  5684.  
  5685.  
  5686. For macs with built-in Ethernet;  Ethernet addresses are unique.
  5687.  
  5688. -mahboud
  5689. - -------------------------------------------------------------
  5690. Mahboud Zabetian
  5691. mahboud@aggroup.com
  5692. ag group, inc.
  5693. 2540 camino diablo, suite 200
  5694. walnut creek, ca 94596
  5695. 510-937-7900 voice
  5696. 510-937-2479 fax
  5697. 510-937-6704 ara
  5698. ftp.aggroup.com anonymous ftp
  5699.  
  5700. +++++++++++++++++++++++++++
  5701.  
  5702. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  5703. Date: Tue, 8 Mar 94 20:41:45 GMT
  5704. Organization: National Renewable Energy Laboratory
  5705.  
  5706. In article <mahboud-080394113713@mahboud.aggroup.com> Mahboud Zabetian,
  5707. mahboud@aggroup.com writes:
  5708. >For macs with built-in Ethernet;  Ethernet addresses are unique.
  5709.  
  5710. True, but what about machines that use Ethernet cards?  If the card is
  5711. changed for some reason, the nice app you spent good cash for no longer
  5712. runs.
  5713.  
  5714. +++++++++++++++++++++++++++
  5715.  
  5716. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  5717. Date: 8 Mar 1994 21:16:28 GMT
  5718. Organization: Royal Institute of Technology, Stockholm, Sweden
  5719.  
  5720. In <CNjbKKKX.q1oh3b@outpost.SF-Bay.org> peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  5721.  
  5722. >It does mean you need to "install" the software on each new system
  5723. >disk, any objections to this?
  5724.  
  5725. Not popular among large sites.
  5726.  
  5727. There is a way that an application can sense it's KeyServer
  5728. keyed and turn off its internal copy protection, though.
  5729. -- 
  5730.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  5731.  
  5732.     I should have stayed at the bus station.
  5733.  
  5734. +++++++++++++++++++++++++++
  5735.  
  5736. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  5737. Date: Wed, 9 Mar 1994 00:37:18 GMT
  5738. Organization: Proteus Ventures, Inc.
  5739.  
  5740. In article <A9A2311939027D1A@cro.nrel.gov>
  5741. Carl R. Osterwald <carl_osterwald@nrel.gov> writes:
  5742.  
  5743. > In article <mahboud-080394113713@mahboud.aggroup.com> Mahboud Zabetian,
  5744. > mahboud@aggroup.com writes:
  5745. > >For macs with built-in Ethernet;  Ethernet addresses are unique.
  5746. > True, but what about machines that use Ethernet cards?  If the card is
  5747. > changed for some reason, the nice app you spent good cash for no longer
  5748. > runs.
  5749.  
  5750. The ethernet address would still be the same. The address is assigned
  5751. to the machine and not to the card. The address is kept by the Mac TCP
  5752. software. (and can ussually be typed in by the user)
  5753.  
  5754. Addresses can and do change for other reasons, though. Administrators
  5755. can reassign addresses, the ethernet class could change, the machine
  5756. could be moved to a different network, etc.
  5757.  
  5758. Juan Ingles
  5759. <DACRXL01.OURX124@tcp30.dx.deere.com>
  5760. --
  5761. Proteus Ventures, Inc. - Computer Software Consulting and Development
  5762.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  5763.  
  5764. +++++++++++++++++++++++++++
  5765.  
  5766. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  5767. Date: 9 Mar 1994 11:48:59 +0800
  5768. Organization: NCRPDA, Curtin University
  5769.  
  5770. ivanski@world.std.com (Ivan M CaveroBelaunde) writes:
  5771.  
  5772. >Actually, I really dislike the idea of having to install the software on
  5773. >each new system, or being unable to switch to a different startup disk
  5774. >(if say my startup volume died suddenly). I'd advocate a much different route
  5775. >(which might be in use right now, since I've seen software behave this
  5776. >way). Currently, a lot of software requires the user to do the first launch
  5777. >on a writable volume in order to store registration information. As long
  5778.  
  5779. The problem with both these solutions is they are a pain to setup in a 
  5780. network environment, and since multiple copy licenses make up a large
  5781. chunk of the revenue, it really doesn't do to piss of these people with
  5782. anoying copy protection pains.
  5783.  
  5784. I don't mind software that asks you to register it with a serial number and
  5785. your name when you first install it, but if I have to do that for all
  5786. twenty copies that I bought, I wont buy them in the first place.
  5787.  
  5788. Piracy loses sales, but so does copy protection.
  5789.    Peter.
  5790. -- 
  5791. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  5792.  
  5793. +++++++++++++++++++++++++++
  5794.  
  5795. >From ari@world.std.com (Ari I Halberstadt)
  5796. Date: Wed, 9 Mar 1994 07:31:34 GMT
  5797. Organization: The World Public Access UNIX, Brookline, MA
  5798.  
  5799. In article <2lf445$5qd@lastactionhero.rs.itd.umich.edu>,
  5800. Matt Slot  <fprefect@engin.umich.edu> wrote:
  5801. >OK, off the podium. If you still need to identify a Mac from another,
  5802. >use the Volume Creation date for VRefNum = -1. This is the long date
  5803. >to the second of the initialization of that HD. For a 1 in 4 billion
  5804. >chance of duplication, this works rather well. If the user *does*
  5805. >reformat the boot disk, it will probably be a full reinstall and for
  5806. >all intents a "new" machine.
  5807.  
  5808. We can assume that all Macintosh hard drives have been formatted no
  5809. earlier than 1983 and no later than 1994 (assuming the user remembered
  5810. to set the clock before formatting). This gives a range of about
  5811. 3.47x10^8 seconds, or 347 million. Most drives have probably been
  5812. formatted in only the last 4 years (there weren't even hard drives for
  5813. the mac until '85, I think), so it's probably more like 1.26x10^8
  5814. seconds.  This is still a big number, but it's not nearly in the
  5815. billions.
  5816. -- 
  5817. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  5818. "These beetles were long considered to be very rare because very few
  5819. entomologists look for beetles in the mountains, in winter, at night,
  5820. during snow storms." -- Purves W. K., et al, "Life: The Science of
  5821.  
  5822. +++++++++++++++++++++++++++
  5823.  
  5824. >From dwalton1@bach.helios.nd.edu (david walton)
  5825. Date: 9 Mar 1994 08:21:54 GMT
  5826. Organization: University of Notre Dame, Notre Dame
  5827.  
  5828. In article <CMDGE6.5zt@deere.com> DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles) writes:
  5829. >In article <A9A2311939027D1A@cro.nrel.gov>
  5830. >Carl R. Osterwald <carl_osterwald@nrel.gov> writes:
  5831. >
  5832. >> In article <mahboud-080394113713@mahboud.aggroup.com> Mahboud Zabetian,
  5833. >> mahboud@aggroup.com writes:
  5834. >> >For macs with built-in Ethernet;  Ethernet addresses are unique.
  5835. >> 
  5836. >> True, but what about machines that use Ethernet cards?  If the card is
  5837. >> changed for some reason, the nice app you spent good cash for no longer
  5838. >> runs.
  5839. >
  5840. >The ethernet address would still be the same. The address is assigned
  5841. >to the machine and not to the card. The address is kept by the Mac TCP
  5842. >software. (and can ussually be typed in by the user)
  5843.  
  5844. *Ethernet* addresses are assigned to the physical hardware on the card
  5845. (which card may be moved around from machine to machine).  *IP
  5846. addresses* (which I think is what you mean) are configurable by the
  5847. MacTCP Control Panel and can therefore be changed by any user
  5848. (although AdminTCP may be required if the network administrator was
  5849. smart enough to lock the settings). If some form of BOOTP is used,
  5850. then the administrator controls which interface gets which address,
  5851. but the user can always configure MacTCP to use a static address.
  5852. (Which address, btw, often ends up being one which was assigned to
  5853. another user--anyone who's dealt with the "this IP address is already
  5854. in use" message from MacTCP when some putz on your local network
  5855. steals an address will know exactly what I'm talking about).
  5856.  
  5857. Point is, you can't assume a fixed relationship between either
  5858. ethernet or IP addresses and a particular machine, except in the
  5859. limiting case where the ethernet hardware's built in.  Hence, this
  5860. would not be a reliable copy-protection scheme in the general case.
  5861.  
  5862. Not that I _want_ copy-protection, mind you....
  5863.  
  5864. Now that I think about it, it's not trivial to get the Ethernet
  5865. address on built-in hardware if the machine doesn't have a transceiver
  5866. with an active link attached.  (Is is possible to do this, BTW?  I
  5867. don't see any way of doing it by making MacTCP calls, but is there a
  5868. lower-level driver call that could return this information?)
  5869.  
  5870. David
  5871. --
  5872. {  David Walton  School:  Dept. of History and Philosophy of Science     }
  5873. {           Work:  Office of University Computing        }
  5874. {             Mail:  David.Walton.10@nd.edu            }
  5875. {  Any unquoted opinions expressed herein are...well...mine.  Pity.    }
  5876.  
  5877. +++++++++++++++++++++++++++
  5878.  
  5879. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  5880. Date: 9 Mar 1994 15:07:28 GMT
  5881. Organization: Royal Institute of Technology, Stockholm, Sweden
  5882.  
  5883. In <CMDGE6.5zt@deere.com> DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles) writes:
  5884.  
  5885. >> True, but what about machines that use Ethernet cards?  If the card is
  5886. >> changed for some reason, the nice app you spent good cash for no longer
  5887. >> runs.
  5888.  
  5889. >The ethernet address would still be the same. The address is assigned
  5890. >to the machine and not to the card. The address is kept by the Mac TCP
  5891. >software. (and can ussually be typed in by the user)
  5892.  
  5893. PLEASE get your facts straigt at least.
  5894.  
  5895. Ethernet addresses are hardcoded in the Ethernet card ROM, and no
  5896. two cards EVER have the same address.
  5897.  
  5898. The IP address is what's maintained by MacTCP. Totally different
  5899. beast. Even if you don't install MacTCP, the ethernet address is
  5900. there in the ethernet card (even if you turn off AppleTalk!)
  5901.  
  5902. Ethernet breaks. Motherboard break. Users upgrade software. If
  5903. you've GOT to have copy protection, and don't mind breaking on
  5904. PowerBook Duos, use an ADB dongle; safe & efficient, upgradable,
  5905. and the money you save by not being pirated should pay for the
  5906. dongle price; if you subscribe to that theory. (I do for some
  5907. special niche products I make)
  5908. -- 
  5909.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  5910.  
  5911.    What we need is a good GNU [...] licence manager implementation.
  5912.                      -- Raphael Manfredi
  5913.  
  5914. +++++++++++++++++++++++++++
  5915.  
  5916. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  5917. Date: Wed, 9 Mar 1994 16:49:05 GMT
  5918. Organization: Proteus Ventures, Inc.
  5919.  
  5920. In article <2lk0v2$oq3@news.nd.edu>
  5921. dwalton1@bach.helios.nd.edu (david walton) writes:
  5922.  
  5923. > *Ethernet* addresses are assigned to the physical hardware on the card
  5924. > (which card may be moved around from machine to machine).  *IP
  5925. > addresses* (which I think is what you mean) 
  5926.  
  5927. Yea, I meant IP. I'm not a hardware person, so I had never heard of
  5928. Ethernet adresses on the cards and assumed that the "adress" mentioned
  5929. was an IP address.
  5930.  
  5931. Juan Ingles
  5932. <DACRXL01.OURX124@tcp30.dx.deere.com>
  5933. --
  5934. Proteus Ventures, Inc. - Computer Software Consulting and Development
  5935.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  5936.  
  5937. +++++++++++++++++++++++++++
  5938.  
  5939. >From Paul Ferguson <pferguson@kaleida.com>
  5940. Date: 9 Mar 1994 19:06:06 GMT
  5941. Organization: Kaleida Labs, Inc.
  5942.  
  5943. In article <2lk0v2$oq3@news.nd.edu> david walton,
  5944. dwalton1@bach.helios.nd.edu writes:
  5945. > Now that I think about it, it's not trivial to get the Ethernet
  5946. > address on built-in hardware if the machine doesn't have a
  5947. transceiver
  5948. > with an active link attached.  (Is is possible to do this, BTW?  I
  5949. > don't see any way of doing it by making MacTCP calls, but is there
  5950. a
  5951. > lower-level driver call that could return this information?)
  5952.  
  5953. Yes, there is a device driver call to the EtherTalk driver to
  5954. return the Ethernet address.
  5955.  
  5956. All Ethernet cards have their Ethernet address PROM memory mapped
  5957. into the physical address space, but there is no standard for where
  5958. this may be.  Therefore, directly accessing the Ethernet address
  5959. is highly vendor dependent.
  5960.  
  5961. Also, there is a defined method for providing a "soft" Ethernet
  5962. address in a resource that will override the hardware Ethernet
  5963. address.
  5964.  
  5965. --fergy
  5966.  
  5967. - ------------------------------------------------------------------
  5968.   Paul Ferguson         | "It's a sick world, I'm a happy guy..."
  5969.   pferguson@kaleida.com |  
  5970. - ------------------------------------------------------------------
  5971.  
  5972. +++++++++++++++++++++++++++
  5973.  
  5974. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  5975. Date: Wed, 9 Mar 1994 23:05:51 GMT
  5976. Organization: Proteus Ventures, Inc.
  5977.  
  5978. In article <2lkong$k0c@news.kth.se>
  5979. d88-jwa@mumrik.nada.kth.se (Jon Wdtte) writes:
  5980.  
  5981. > >The ethernet address would still be the same. The address is assigned
  5982. > >to the machine and not to the card. The address is kept by the Mac TCP
  5983. > >software. (and can ussually be typed in by the user)
  5984. > PLEASE get your facts straigt at least.
  5985.  
  5986. Hey! My facts were straight! I was just talking about something
  5987. completly different than everyone else was! That's all! :)
  5988.  
  5989. (Is that the Topic Police I hear coming?.....)
  5990.  
  5991. Juan Ingles
  5992. <DACRXL01.OURX124@tcp30.dx.deere.com>
  5993. --
  5994. Proteus Ventures, Inc. - Computer Software Consulting and Development
  5995.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  5996. --
  5997. Yes, I understand that you understood what I said. What you don't
  5998. understand is that I didn't say what I meant.
  5999.  
  6000. +++++++++++++++++++++++++++
  6001.  
  6002. >From peterb@tcc.oecn.ohio.gov (Peter Bierman)
  6003. Date: Sun, 13 Mar 1994 22:32:50 GMT
  6004. Organization: Linworth Alternative HS
  6005.  
  6006. In article <2lih8e$l5b@nigel.msen.com>, time@garnet.msen.com (Tim Endres)
  6007. wrote:
  6008.  
  6009. > I really like Ivan's idea of storing the time for the disk
  6010. > that the *app* is on. This solves Peter's network installation
  6011. > problems and it solves CD and server setups.
  6012.  
  6013. But what if the user transfers the app to a different volume because of low
  6014. disk space? I do this all the time.
  6015.  
  6016. -- 
  6017.        Peter Bierman       \  The Metropolis  \ The most primitive part of
  6018. the
  6019. peterb@tcc.oecn.ohio.gov    \  (614)-846-1911  \   the brain concerns
  6020. itself
  6021.                              \  600MB Mac Files \     with the "Four F's":
  6022. "I've changed my mind, Hobbes \  FirstClass      \ Feeding, Fighting,
  6023. Fleeing,
  6024.  people are scum." --Calvin    \  Mac & Windows   \     and Reproduction.
  6025.  
  6026. +++++++++++++++++++++++++++
  6027.  
  6028. >From noah@apple.com (Noah Price)
  6029. Date: Thu, 10 Mar 1994 23:49:02 GMT
  6030. Organization: (not the opinions of) Apple Computer, Inc.
  6031.  
  6032. In article <CNjbKKKX.q3sn67@outpost.SF-Bay.org>, peirce@outpost.SF-Bay.org
  6033. (Michael Peirce) wrote:
  6034. > In article <1994Mar7.150036.11171@midway.uchicago.edu>, ajr3@quads.uchicago.edu (Alain Roy) writes:
  6035. > > 
  6036. > > works unless you're like me: i have 2 hard drives. if every time i switched,
  6037. > > i had the copy protection of a program fire up, i'd be really upset.
  6038. > But this would only happen the first time you started up on your second
  6039. > disk.  After that, its prefs file would contain the init time of *that*
  6040. > disk.
  6041.  
  6042. But what if he switches back and forth between the two disks often for
  6043. whatever reason?
  6044.  
  6045. noah
  6046.  
  6047. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6048. Noah Price                    (not the opinions of) Apple Computer, Inc.
  6049. Macintosh AV Hardware                      20525 Mariani Ave., MS 60-TNT
  6050. noah@apple.com                                        Cupertino CA 95014
  6051.  
  6052. +++++++++++++++++++++++++++
  6053.  
  6054. >From zdelesde@vt.edu (Zac DeLesDernier)
  6055. Date: 18 Mar 1994 03:17:41 GMT
  6056. Organization: Virginia Tech
  6057.  
  6058.      I have a related question. I need a way to uniquely identify a
  6059. file, other than its name. This identifying mechanism should also work
  6060. for copies of a file. (i.e. A backup would have the same file id.) The
  6061. id should _not_ change if the file is renamed or moved. (I hope I am
  6062. making myself clear.) One idea I had was writing some bignum into the
  6063. VERS resource, but then I dont want this marking system to mangle
  6064. applications (or anything else that might have a valid VERS resource.)
  6065. Any ideas?
  6066.  
  6067. - -
  6068.  
  6069. Zac DeLesDernier
  6070. zdelesde@vt.edu
  6071.  
  6072. ---------------------------
  6073.  
  6074. >From bdiamand@netcom.com (Ben Diamand)
  6075. Subject: I know the Mac MM isn't reentrant, but:
  6076. Date: Thu, 10 Mar 1994 03:12:17 GMT
  6077. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  6078.  
  6079.  
  6080. I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6081. interrupt(read:completion routine/callBack)?  If the answer is no, would 
  6082. some mac guru care to post/email a way to let the Mac Memory Manager know 
  6083. that a handle no longer needs to locked?  I realize it's been a long time 
  6084. since the high byte was used for this purpose, but the same info's got to 
  6085. be somewhere, right?!  As a further question to the same person who tells 
  6086. me how to change this(assuming anyone does :) ), am I doomed in 
  6087. native/emulated PowerPC using whatever means you give me to change this 
  6088. attribute?
  6089.  
  6090. Thanks!
  6091.  
  6092. Ben Diamand
  6093. bdiamand@netcom.com
  6094. ALINK:bdiamand
  6095.  
  6096.  
  6097. +++++++++++++++++++++++++++
  6098.  
  6099. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  6100. Date: Wed, 09 Mar 1994 23:07:59 -0600
  6101. Organization: University of Illinois at Urbana-Champaign
  6102.  
  6103. In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6104. Diamand) wrote:
  6105.  
  6106. >I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6107. >interrupt(read:completion routine/callBack)?
  6108.  
  6109. HUnlock is not on the list of routines that cannot be called at interrupt
  6110. time. It should be safe.
  6111.  
  6112. pr
  6113. -- 
  6114. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  6115. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  6116. System manager - Cognitive Science Group, Beckman Institute, UIUC
  6117. Internet: resnick@cogsci.uiuc.edu
  6118.  
  6119. +++++++++++++++++++++++++++
  6120.  
  6121. >From bdiamand@netcom.com (Ben Diamand)
  6122. Date: Thu, 10 Mar 1994 07:25:56 GMT
  6123. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  6124.  
  6125. Pete Resnick (resnick@cogsci.uiuc.edu) wrote:
  6126. : In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6127. : Diamand) wrote:
  6128.  
  6129. : >I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6130. : >interrupt(read:completion routine/callBack)?
  6131.  
  6132. : HUnlock is not on the list of routines that cannot be called at interrupt
  6133. : time. It should be safe.
  6134.  
  6135. Thank-you for the reply...Ya, I know that it's not on the list.  But, I
  6136. have great fear regarding interrupts and the MM, Sound Manager, and the
  6137. File Manager.  They all use interrupts to get their respective jobs done
  6138. and they all are incorrectly documented with respect to interrupts in
  6139. various versions of IM.  Sound Manager 3.0 seems to fix many problems that
  6140. I had with sound interrupts, but I stiil am very leary(sp?) of the Mac MM. 
  6141. Maybe I'm a Unix person at heart?  :)
  6142.  
  6143. Ben Diamand
  6144. bdiamand@netcom.com
  6145. ALINK:bdiamand
  6146.  
  6147.  
  6148. +++++++++++++++++++++++++++
  6149.  
  6150. >From gurgle@netcom.com (Pete Gontier)
  6151. Date: Thu, 10 Mar 1994 17:52:59 GMT
  6152. Organization: cellular
  6153.  
  6154. resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  6155.  
  6156. >In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6157. >Diamand) wrote:
  6158.  
  6159. >>I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6160. >>interrupt(read:completion routine/callBack)?
  6161.  
  6162. >HUnlock is not on the list of routines that cannot be called at interrupt
  6163. >time. It should be safe.
  6164.  
  6165. Apple has now disowned that list. Apple says that although there are
  6166. traps which can be called at interrupt time, the list is out of date.
  6167.  
  6168. In particular, I can imagine HUnlock being one of the traps that would
  6169. fail or misbehave at interrupt time. If the handle's flags were kept
  6170. in a prefix to the buffer rather than in the master pointer list, the
  6171. Memory Manager could be in the middle of shuffling that block when
  6172. HUnlock occurred, and the master pointer might not be updated yet. I'm
  6173. not sure, but I think this may be possible in a 32-bit heap. In any
  6174. case, it's not something I would want to rely on. Apple is changing the
  6175. implementation of the Memory Manager under System 7 for PowerPC, which
  6176. means there will be at least 3 known major versions of the MM. Since the
  6177. MM is one of the most sensitive areas with regard to interrupt time, I
  6178. wouldn't push my luck.
  6179.  
  6180. But now I'm curious -- why would you want to unlock a handle at
  6181. interrupt time?
  6182. -- 
  6183.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  6184.  
  6185. +++++++++++++++++++++++++++
  6186.  
  6187. >From ivanski@world.std.com (Ivan M CaveroBelaunde)
  6188. Date: Thu, 10 Mar 1994 15:28:20 GMT
  6189. Organization: The World Public Access UNIX, Brookline, MA
  6190.  
  6191. resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  6192. >In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6193. >Diamand) wrote:
  6194. >>I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6195. >>interrupt(read:completion routine/callBack)?
  6196. >HUnlock is not on the list of routines that cannot be called at interrupt
  6197. >time. It should be safe.
  6198.  
  6199. Actually, the list is described as "routines that move memory." I don't
  6200. believe this implies that all other routines can be called at interrupt
  6201. time - certainly reentrancy can be an issue even for routines that do not
  6202. move memory. I'd be a little queasy about unlocking a handle from
  6203. interrupt time, for a couple of reasons:
  6204.     o In the best of cases, that handle must be locked. It's
  6205.         perfectly legal to unlock an unlocked handle, but
  6206.         if done at interrupt time you would hose yourself
  6207.         badly. I'd do an HGetState before that - of course,
  6208.         I'm not sure whether it's safe to call HGetState
  6209.         on an unlocked block during interrupt time in
  6210.         the first place, so unless it's always locked or
  6211.         you keep parallel state somewhere alse (ie global
  6212.         storage) this becomes a catch-22.
  6213.     o Non-reentrancy of the memory manager. I believe the memory manager
  6214.         uses private pieces of low memory for temporary storage,
  6215.         which might get nuked if you call HUnlock in the middle
  6216.         of another mem mgr operation. Also, while I don't know
  6217.         whether the "old" memory manager checks handle validity
  6218.         on an HUnlock operation (by walking the free master pointer
  6219.         lists, a no-no at interrupt time), the "new" memory manager
  6220.         that has appeared on developer CDs in prerelease version
  6221.         can be placed into a mode that performs that check.
  6222.     o Patches. There are probably more than a few INITs/extensions out
  6223.         there that patch HUnlock and do their own thing. While it
  6224.         is completely illegal for them to move memory in their
  6225.         patch, whether they could assume that the heaps are in
  6226.         a consistent state (an invalid assumption at interrupt time)
  6227.         is a gray area. Coupled with the fact that if your app
  6228.         is incompatible with a popular extension, it will be your
  6229.         app that is blamed, not that extension (unless the extension
  6230.         is known as a particularly troublesome one), this'd make
  6231.         me very wary.
  6232.  
  6233. For what it's worth, I wouldn't do it. I'd set a global flag and do it
  6234. from interrupt safe-land (like the event loop).
  6235.  
  6236. -Ivan
  6237. - -
  6238. Ivan Cavero Belaunde (ivanski@world.std.com)
  6239. Avid VideoShop Project Lead
  6240. Avid Technology, Inc.
  6241.  
  6242. +++++++++++++++++++++++++++
  6243.  
  6244. >From mgr@aggroup.aggroup.com (Mike Russell)
  6245. Date: Thu, 10 Mar 1994 12:05:29 -0800
  6246. Organization: the ag group, inc.
  6247.  
  6248. In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6249. Diamand) wrote:
  6250.  
  6251. > I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6252. > interrupt(read:completion routine/callBack)?
  6253.  
  6254. YOW - even if it's otherwise legal, consider the problems the following
  6255. non-interrupt code could run into if myHandle is unlocked asynchronously:
  6256.  
  6257.      SignedByte s = HGetState(myHandle);
  6258.      HLock(myHandle);
  6259.      ... Do some stuff ...
  6260.      HSetState(myHandle, s);
  6261.  
  6262. So be very careful about who else might be looking at the locked block.
  6263. A safer way to do this - DTInstall(), IM V-467.
  6264.  
  6265. +++++++++++++++++++++++++++
  6266.  
  6267. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  6268. Date: 11 Mar 1994 02:03:15 GMT
  6269. Organization: University of Illinois at Urbana
  6270.  
  6271. mgr@aggroup.aggroup.com (Mike Russell) writes:
  6272.  
  6273. >So be very careful about who else might be looking at the locked block.
  6274. >A safer way to do this - DTInstall(), IM V-467.
  6275.  
  6276. No, DTInstall won't help. Deferred tasks get executed at a time which
  6277. is effectively the same as interrupt time. It is no safer to call a
  6278. routine at deferred task time than at interrupt time.
  6279.  
  6280. pr
  6281. -- 
  6282. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  6283. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  6284. System manager - Cognitive Science Group, Beckman Institute, UIUC
  6285. Internet: resnick@cogsci.uiuc.edu
  6286.  
  6287. +++++++++++++++++++++++++++
  6288.  
  6289. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  6290. Date: 11 Mar 1994 02:10:29 GMT
  6291. Organization: University of Illinois at Urbana
  6292.  
  6293. ivanski@world.std.com (Ivan M CaveroBelaunde) writes:
  6294.  
  6295. >Actually, the list is described as "routines that move memory."
  6296.  
  6297. No, the list at the end of the second edition of the X-Ref is
  6298. "routines that can't be called at interrupt." Some of them move
  6299. memory; some of them aren't reentrant.
  6300.  
  6301. pr
  6302. -- 
  6303. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  6304. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  6305. System manager - Cognitive Science Group, Beckman Institute, UIUC
  6306. Internet: resnick@cogsci.uiuc.edu
  6307.  
  6308. +++++++++++++++++++++++++++
  6309.  
  6310. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  6311. Date: Fri, 11 Mar 1994 12:14:37 +0800
  6312. Organization: Department of Computer Science, The University of Western Australia
  6313.  
  6314. In article <resnick-090394230759@colt-17.slip.uiuc.edu>,
  6315. resnick@cogsci.uiuc.edu (Pete Resnick) wrote:
  6316.  
  6317. >In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6318. >Diamand) wrote:
  6319. >
  6320. >>I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6321. >>interrupt(read:completion routine/callBack)?
  6322. >
  6323. >HUnlock is not on the list of routines that cannot be called at interrupt
  6324. >time. It should be safe.
  6325.  
  6326. I hate to be picky but this is ***RONG!!!!***
  6327.  
  6328. If you don't believe me read Kon & Bal's puzzle page in develop 16.
  6329. Here's an extract....
  6330.  
  6331. - --------------------
  6332.         Mike    The interesting part of the heap before and after the
  6333. MoveHHi call is shown in the figure. Before MoveHHi there was a locked
  6334. block, labeled A in the figure, which is marked as relocatable afterward.
  6335. The relocatable block just below locked block B is getting overwritten by
  6336. the block we9re calling MoveHHi on. 
  6337.         KON     MoveHHi works by first saving the contents of the block
  6338. that you9re moving, then marking the block as free. Then it calls
  6339. CompactMem on the heap, which bubbles all the free space up to any islands
  6340. and all relocatable blocks down. Then it copies the block to the free
  6341. block just before the island. 
  6342.         BAL     And someone is coming in at interrupt time and unlocking
  6343. the island, block A in the figure. Instead of remembering the location of
  6344. the island, MoveHHi searches for it after the CompactMem call. Since that
  6345. block was unlocked by an interrupt after CompactMem, a different block is
  6346. found the second time. When MoveHHi backs up to the previous, presumably
  6347. free, block and starts copying data, the heap gets trashed.
  6348.         Mike    Yeah, that interrupt unlocking the block was QuickTime,
  6349. BAL. It turns out the Sound Manager does the same thing. Apparently the
  6350. 3system architects2 at the time thought it was OK to call HUnlock on a
  6351. locked block during an interrupt. Not! We fixed it by deferring all
  6352. HUnlock calls until MoveHHi finishes. This was the cleanest fix; it keeps
  6353. us from patching out huge parts of the Memory Manager. But we were stumped
  6354. for quite a while. 
  6355.         KON     Nasty.
  6356.         BAL     Yeah.
  6357. - --------------------
  6358.  
  6359. I'm sorry about the formatting but I cut and pasted it out of the
  6360. magazine on the CD.  Please read the article for a better explanation.
  6361.  
  6362. -- 
  6363. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  6364. Department of Computer Science, The University of Western Australia
  6365.   I hate newsreaders that complain about more quoted text than article
  6366.   text.  My quotes weren't from another article.  Grrrrr!!!!!
  6367.  
  6368. +++++++++++++++++++++++++++
  6369.  
  6370. >From bdiamand@netcom.com (Ben Diamand)
  6371. Date: Fri, 11 Mar 1994 07:41:42 GMT
  6372. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  6373.  
  6374. Mike Russell (mgr@aggroup.aggroup.com) wrote:
  6375. : In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6376. : Diamand) wrote:
  6377.  
  6378. : > 
  6379. : > I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6380. : > interrupt(read:completion routine/callBack)?
  6381.  
  6382. : YOW - even if it's otherwise legal, consider the problems the following
  6383. : non-interrupt code could run into if myHandle is unlocked asynchronously:
  6384.  
  6385. :      SignedByte s = HGetState(myHandle);
  6386. :      HLock(myHandle);
  6387. :      ... Do some stuff ...
  6388. :      HSetState(myHandle, s);
  6389.  
  6390. : So be very careful about who else might be looking at the locked block.
  6391. : A safer way to do this - DTInstall(), IM V-467.
  6392.  
  6393. My non-interrupt code locks the handle as soon as it gets it and then 
  6394. 'forgets' about the handle.  The interrupt code handles the handles:)
  6395.  
  6396. Ben Diamand
  6397. bdiamand@netcom.com
  6398. ALINK:bdiamand
  6399.  
  6400.  
  6401. +++++++++++++++++++++++++++
  6402.  
  6403. >From bdiamand@netcom.com (Ben Diamand)
  6404. Date: Fri, 11 Mar 1994 07:46:12 GMT
  6405. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  6406.  
  6407. Quinn "The Eskimo! (quinn@cs.uwa.edu.au) wrote:
  6408. : In article <resnick-090394230759@colt-17.slip.uiuc.edu>,
  6409. : resnick@cogsci.uiuc.edu (Pete Resnick) wrote:
  6410.  
  6411. : >In article <bdiamandCMFI8H.K7o@netcom.com>, bdiamand@netcom.com (Ben
  6412. : >Diamand) wrote:
  6413. : >
  6414. : >>I know the Mac MM isn't reentrant, but, can I call HUnlock from within an 
  6415. : >>interrupt(read:completion routine/callBack)?
  6416. : >
  6417. : >HUnlock is not on the list of routines that cannot be called at interrupt
  6418. : >time. It should be safe.
  6419.  
  6420. : I hate to be picky but this is ***RONG!!!!***
  6421.  
  6422. : If you don't believe me read Kon & Bal's puzzle page in develop 16. :
  6423. Here's an extract.... 
  6424.  
  6425. [text deleted]
  6426. : ----------------------
  6427. :         Mike    Yeah, that interrupt unlocking the block was QuickTime,
  6428. : BAL. It turns out the Sound Manager does the same thing. Apparently the
  6429. : 3system architects2 at the time thought it was OK to call HUnlock on a
  6430. : locked block during an interrupt. Not! We fixed it by deferring all
  6431. : HUnlock calls until MoveHHi finishes. This was the cleanest fix; it keeps
  6432. : us from patching out huge parts of the Memory Manager. But we were stumped
  6433. : for quite a while. 
  6434. :         KON     Nasty.
  6435. :         BAL     Yeah.
  6436. : ----------------------
  6437.  
  6438. : I'm sorry about the formatting but I cut and pasted it out of the
  6439. : magazine on the CD.  Please read the article for a better explanation.
  6440.  
  6441. : -- 
  6442. : Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  6443. : Department of Computer Science, The University of Western Australia
  6444. :   I hate newsreaders that complain about more quoted text than article
  6445. :   text.  My quotes weren't from another article.  Grrrrr!!!!!
  6446.  
  6447. Ok, now here's a stupid question.  How does one know when MoveHHi is done?
  6448. I don't mind terribly defering the HUnlock...I just wanted to know if I 
  6449. had to...Thanks forthe reply...
  6450.  
  6451. Ben Diamand
  6452. bdiamand@netcom.com
  6453. ALINK:bdiamand
  6454.  
  6455.  
  6456. +++++++++++++++++++++++++++
  6457.  
  6458. >From Duane Murphy <damurphy@wc.novell.com>
  6459. Date: Mon, 14 Mar 1994 16:14:32 GMT
  6460. Organization: Novell, Inc.
  6461.  
  6462. In article <bdiamandCMFI8H.K7o@netcom.com> Ben Diamand,
  6463. bdiamand@netcom.com writes:
  6464. >I know the Mac MM isn't reentrant, but, can I call HUnlock from within
  6465. an 
  6466. >interrupt(read:completion routine/callBack)?  If the answer is no, would 
  6467. Ben,
  6468. There is a great article in develop issue 16 in KON & BAL's Puzzle Page 
  6469. that talks about just this problem. I just read it last week. Even the 
  6470. guru's at Apple think that HUnlock can be called at interrupt time. 
  6471.  
  6472. The problem stems from the algorithm used for MoveHHI. I don't 
  6473. quite understand it enough to explain it, but if the handle gets unlocked 
  6474. at the wrong time then MoveHHI will overwrite the handle.
  6475.  
  6476. Check out the article, it is pretty interesting (especially for debugging 
  6477. techniques).
  6478.  
  6479. Later,
  6480. ...Duane
  6481.  
  6482.   +------------------------+--------------------------------------------+
  6483.   | Duane Murphy           | My opinions are mine, mine, and only mine; |
  6484.   | damurphy@wc.novell.com |      Except when they are also yours.      |
  6485.   +------------------------+--------------------------------------------+
  6486.  
  6487. +++++++++++++++++++++++++++
  6488.  
  6489. >From Steve Ethier <ethier@wc.novell.com>
  6490. Date: Mon, 14 Mar 1994 18:03:43 GMT
  6491. Organization: Novell, Inc.
  6492.  
  6493. In article <1994Mar14.161432.18054@novell.com> Duane Murphy,
  6494. damurphy@wc.novell.com writes:
  6495. >In article <bdiamandCMFI8H.K7o@netcom.com> Ben Diamand,
  6496. >bdiamand@netcom.com writes:
  6497. >>I know the Mac MM isn't reentrant, but, can I call HUnlock from within
  6498. >an 
  6499. >>interrupt(read:completion routine/callBack)?  If the answer is no,
  6500. would 
  6501. >Ben,
  6502. >There is a great article in develop issue 16 in KON & BAL's Puzzle Page 
  6503. >that talks about just this problem. I just read it last week. Even the 
  6504. >guru's at Apple think that HUnlock can be called at interrupt time. 
  6505. >
  6506. >The problem stems from the algorithm used for MoveHHI. I don't 
  6507. >quite understand it enough to explain it, but if the handle gets
  6508. unlocked 
  6509. >at the wrong time then MoveHHI will overwrite the handle.
  6510. >
  6511. >Check out the article, it is pretty interesting (especially for
  6512. debugging 
  6513. >techniques).
  6514. >
  6515. >Later,
  6516. >...Duane
  6517.  
  6518. Ben, the "short form" to Duane's answer is that HUnlock is *not* safe to
  6519. call at interrupt time.  (Duane let me read the article, and I must admit
  6520. that it is indeed very interesting.)
  6521.  
  6522. Steve Ethier
  6523. ethier@wc.novell.com
  6524.  
  6525. +++++++++++++++++++++++++++
  6526.  
  6527. >From David A Lyons <dlyons@apple.com>
  6528. Date: Thu, 10 Mar 1994 22:26:21 GMT
  6529. Organization: Apple Computer, Inc.
  6530.  
  6531. In article <gurgleCMGn0B.F87@netcom.com> Pete Gontier,
  6532. gurgle@netcom.com writes:
  6533. > In particular, I can imagine HUnlock being one of the traps that
  6534. would
  6535. > fail or misbehave at interrupt time.
  6536.  
  6537. Correct, calling HUnlock at interrupt time is bad.  See Kon and Bal's
  6538. Puzzle Page in _develop_ #16 (December 1993).
  6539.  
  6540. Dave Lyons, dlyons@apple.com
  6541. Mr Tangent
  6542.  
  6543. My opinions are my own, not Apple's.
  6544.  
  6545. ---------------------------
  6546.  
  6547. >From mahboud@aggroup.com (Mahboud Zabetian)
  6548. Subject: If you use SysBeep() for debugging...
  6549. Date: Wed, 23 Feb 1994 15:07:55 -0800
  6550. Organization: AG Group, Inc.
  6551.  
  6552. If you're like me and like to throw in SysBeep() calls in questionable code
  6553. to help determine program flow, be careful!
  6554.  
  6555. SysBeep() may move memory and could potentially make dereferenced handles
  6556. invalid!
  6557.  
  6558. This is a hard one to chase down, since you now have another bug added to
  6559. whatever bug you were originally looking for.
  6560.  
  6561. Hope this helps someone.  
  6562.  
  6563. -mahboud
  6564.  
  6565. - -------------------------------------------------------------
  6566. Mahboud Zabetian
  6567. mahboud@aggroup.com
  6568. ag group, inc.
  6569. 2540 camino diablo, suite 200
  6570. walnut creek, ca 94596
  6571. 510-937-7900 voice
  6572. 510-937-2479 fax
  6573. 510-937-6704 ara
  6574. ftp.aggroup.com anonymous ftp
  6575.  
  6576. +++++++++++++++++++++++++++
  6577.  
  6578. >From blume@twg.com (David Blume)
  6579. Date: Wed, 23 Feb 1994 23:56:35 GMT
  6580. Organization: Gokuraku Videos - Wollongong Dept.
  6581.  
  6582. mahboud@aggroup.com (Mahboud Zabetian) wrote:
  6583. >If you're like me and like to throw in SysBeep() calls in questionable code
  6584. >to help determine program flow, be careful!
  6585. >
  6586. >SysBeep() may move memory and could potentially make dereferenced handles
  6587. >invalid!
  6588.  
  6589. According to IM2, SysBeep() is stack-based.  Also, my handy-dandy Online
  6590. reference doesn't have the diamond character indicating that it moves
  6591. memory.
  6592.  
  6593. However, 411 does agree with Mahboud.  It says that SysBeep() does move
  6594. or purge memory.  Sneaky...
  6595.  
  6596. --David
  6597. +-------------------------------------------------------------------------+
  6598. | David Blume   | "A, Ayukawa!"    | "Moemichan! ... SUKIDA!!" -- Youta   |
  6599. | blume@twg.com | "Kasuga-kuun..." | "Suckerfish!"  -- Ai Amano           |
  6600. +-------------------------------------------------------------------------+
  6601.  
  6602. +++++++++++++++++++++++++++
  6603.  
  6604. >From danprice@delphi.com
  6605. Date: Wed, 23 Feb 94 19:51:33 -0500
  6606. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  6607.  
  6608.  
  6609. Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6610.  
  6611. Has anyone had a problem w/ sysbeep() doing this?
  6612.  
  6613.     -dp
  6614.  
  6615. +++++++++++++++++++++++++++
  6616.  
  6617. >From mahboud@aggroup.com (Mahboud Zabetian)
  6618. Date: Wed, 23 Feb 1994 22:51:49 -0800
  6619. Organization: AG Group, Inc.
  6620.  
  6621. In article <1994Feb23.235635.17269@twg.com>, blume@twg.com (David Blume)
  6622. wrote:
  6623.  
  6624. > mahboud@aggroup.com (Mahboud Zabetian) wrote:
  6625. > >If you're like me and like to throw in SysBeep() calls in questionable code
  6626. > >to help determine program flow, be careful!
  6627. > >
  6628. > >SysBeep() may move memory and could potentially make dereferenced handles
  6629. > >invalid!
  6630. > According to IM2, SysBeep() is stack-based.  Also, my handy-dandy Online
  6631. > reference doesn't have the diamond character indicating that it moves
  6632. > memory.
  6633.  
  6634. Back in the days of the 128K and 512K mac, SysBeep() just played a good ole
  6635. beep.  A tone.
  6636.  
  6637. Now that it plays digitized sounds, it seems to do a GetResource and/or
  6638. LoadResource to get the sound.  You can verify with an A-Trap break (Don't
  6639. ATB on GetResource; Do an ATb for SysBeep, then when you are in the
  6640. debugger, setup an ATB GetResource.  You'll see 'snd ' on the stack).
  6641.  
  6642. > However, 411 does agree with Mahboud.  It says that SysBeep() does move
  6643. > or purge memory.  Sneaky...
  6644. > --David
  6645. > +-------------------------------------------------------------------------+
  6646. > | David Blume   | "A, Ayukawa!"    | "Moemichan! ... SUKIDA!!" -- Youta   |
  6647. > | blume@twg.com | "Kasuga-kuun..." | "Suckerfish!"  -- Ai Amano           |
  6648. > +-------------------------------------------------------------------------+
  6649.  
  6650. Sneaky is right.  I was been bitten by this one 3 years ago too.  Hard to
  6651. figure out.
  6652.  
  6653. -mahboud
  6654.  
  6655. - -------------------------------------------------------------
  6656. Mahboud Zabetian
  6657. mahboud@aggroup.com
  6658. ag group, inc.
  6659. 2540 camino diablo, suite 200
  6660. walnut creek, ca 94596
  6661. 510-937-7900 voice
  6662. 510-937-2479 fax
  6663. 510-937-6704 ara
  6664. ftp.aggroup.com anonymous ftp
  6665.  
  6666. +++++++++++++++++++++++++++
  6667.  
  6668. >From mahboud@aggroup.com (Mahboud Zabetian)
  6669. Date: Wed, 23 Feb 1994 22:58:58 -0800
  6670. Organization: AG Group, Inc.
  6671.  
  6672. In article <xu5p+Bd.danprice@delphi.com>, danprice@delphi.com wrote:
  6673.  
  6674. >  
  6675. > Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6676. >  
  6677. > Has anyone had a problem w/ sysbeep() doing this?
  6678. >  
  6679. >     -dp
  6680.  
  6681. Here's one way that I am trying out, but it's not audible like SysBeep().
  6682.  
  6683. I start at one end of my window and turn a pixel on.  Using SetCPixel, I
  6684. can setup the color too.
  6685.  
  6686. I was mainly interested in doing this from an interrupt handler (I never
  6687. checked to see if it moved memory, sorry), and it seemed to work fine,
  6688. except that it was slow compared to my interrupt handler, and was slowing
  6689. everything down.
  6690.  
  6691. Are there still LowMem globals reserved for apps to use?  If so, maybe the
  6692. application under test could write a status value into that global, and can
  6693. be checked at a later time?
  6694.  
  6695. Any other thoughts appreciated...
  6696.  
  6697. -mahboud
  6698.  
  6699. - -------------------------------------------------------------
  6700. Mahboud Zabetian
  6701. mahboud@aggroup.com
  6702. ag group, inc.
  6703. 2540 camino diablo, suite 200
  6704. walnut creek, ca 94596
  6705. 510-937-7900 voice
  6706. 510-937-2479 fax
  6707. 510-937-6704 ara
  6708. ftp.aggroup.com anonymous ftp
  6709.  
  6710. +++++++++++++++++++++++++++
  6711.  
  6712. >From pottier@corvette.ens.fr (Francois Pottier)
  6713. Date: 24 Feb 1994 10:39:07 GMT
  6714. Organization: Ecole Normale Superieure, PARIS, France
  6715.  
  6716. In article <mahboud-230294225858@mahboud.aggroup.com>,
  6717. Mahboud Zabetian <mahboud@aggroup.com> wrote:
  6718.  
  6719. >> Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6720.  
  6721. Why not use the DebugStr call ?
  6722. For instance, if I'm not mistaken, DebugStr('Checkpoint 1 ; g');
  6723. should print "Checkpoint 1" into Macsbug and resume execution.
  6724.  
  6725.  
  6726.  
  6727. -- 
  6728. Francois Pottier            ___ ___  _    _  / ___  ___    ___
  6729. pottier@dmi.ens.fr       /_  /__/ /_|  /| / /  / /  / / /__
  6730.               /   / \  /  | / |/ /___ /__/ / ___/ _
  6731.                           /
  6732.  
  6733. +++++++++++++++++++++++++++
  6734.  
  6735. >From tzs@u.washington.edu (Tim Smith)
  6736. Date: 24 Feb 1994 10:43:04 GMT
  6737. Organization: University of Washington School of Law, Class of '95
  6738.  
  6739. In article <xu5p+Bd.danprice@delphi.com>,  <danprice@delphi.com> wrote:
  6740. >Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6741.  
  6742. One thing I found real useful for debugging was to write my own printf
  6743. that wrote directly to screen memory.  It used a simple built in font
  6744. (with each character being 3x5--yes, you can actually make a legible
  6745. character set with 3x5--so that the memory manipulation would be easy).
  6746. With this, I could get debugging information from all kinds of places
  6747. where regular debug tools might fail: ethernet interrupt routines,
  6748. SCSI boot code, Nubus card interrupts, etc., and I didn't have to
  6749. worry about memory being moved, or managers not being in the proper
  6750. state, or whatever.
  6751.  
  6752. Unfortunately, I wrote this as part of my job, so I can't post it.
  6753.  
  6754. --Tim Smith
  6755.  
  6756. +++++++++++++++++++++++++++
  6757.  
  6758. >From kledbetter@aol.com (KLedbetter)
  6759. Date: 24 Feb 1994 13:34:01 -0500
  6760. Organization: America Online, Inc.
  6761.  
  6762. >>Wow, good point.  Any suggestions for an easy debugging tool like
  6763. >> sysbeep()?
  6764.  
  6765.  Well, if you're using C and System 7, you might want to look for my program
  6766. "DebugWindow 2.0".  It uses AppleEvents to easily display messages in a
  6767. debugging window.  Simply add DebugWindow.Lib to your project, and then you can
  6768. do things like:
  6769.  
  6770.    Debug ("Just starting so-and-so routine\r");
  6771.    .....
  6772.    Debug ("Value of index is now %d\r", index);
  6773.  
  6774. Keith
  6775.  
  6776.  
  6777. +++++++++++++++++++++++++++
  6778.  
  6779. >From perlis_a@math.lsu.edu (Alexander Perlis)
  6780. Date: 25 Feb 1994 00:47:14 GMT
  6781. Organization: Louisiana State University InterNetNews Site
  6782.  
  6783. In article <1994Feb23.235635.17269@twg.com> blume@twg.com (David Blume)  
  6784. writes:
  6785. > mahboud@aggroup.com (Mahboud Zabetian) wrote:
  6786. > >If you're like me and like to throw in SysBeep() calls in questionable  
  6787. code
  6788. > >to help determine program flow, be careful!
  6789. > >
  6790. > >SysBeep() may move memory and could potentially make dereferenced  
  6791. handles
  6792. > >invalid!
  6793. > According to IM2, SysBeep() is stack-based.  Also, my handy-dandy Online
  6794. > reference doesn't have the diamond character indicating that it moves
  6795. > memory.
  6796. > However, 411 does agree with Mahboud.  It says that SysBeep() does move
  6797. > or purge memory.  Sneaky...
  6798. > --David
  6799.  
  6800. I would presume that this inconsistency in the documentation has to do  
  6801. with changes to the SysBeep() trap after the Sound Manager was added to  
  6802. the system software a few years back. At that point, SysBeep() no longer  
  6803. accessed the speaker or low-level sound routines directly, but instead  
  6804. called the Sound Manager to play the current system beep sound. The Sound  
  6805. Manager, being complicated and supporting different sounds stored in  
  6806. various formats in resources, obviously moves memory to do its work.
  6807.  
  6808. At one point (when the Sound Manager first came out) it was still possible  
  6809. to call the original SysBeep() code. At least, if "System Beep" was the  
  6810. system beep sound, then SysBeep() would use its old code rather than  
  6811. calling the Sound Manager. In today's system software, however, there is  
  6812. an actual sound called "System Beep" and it gets played by the Sound  
  6813. Manager if it is the selected system beep sound. [Boy, this sounds like a  
  6814. bunch of double-talk. Is anyone able to follow this?]
  6815.  
  6816. Presumably, if the code of the original SysBeep() routine is still in ROM,  
  6817. one can call it somehow, and memory will not be moved. That would solve  
  6818. the problem of using beep sounds while debugging code which cannot move  
  6819. memory. I don't know how to call the original SysBeep() code, assuming it  
  6820. is even possible. Can any of the experts reading this thread shed some  
  6821. light on the matter?
  6822.  
  6823.  
  6824. Alexander Perlis, perlis_a@math.lsu.edu
  6825.  
  6826. +++++++++++++++++++++++++++
  6827.  
  6828. >From robert@tbit.com (RObert Abatecola)
  6829. Date: Thu, 24 Feb 94 17:55:06 PST
  6830. Organization: TBIT, WMCS chat/message BBS, San Jose, CA  (408)257-6225
  6831.  
  6832. >  Well, if you're using C and System 7, you might want to look for my program
  6833. > "DebugWindow 2.0".  It uses AppleEvents to easily display messages in a
  6834. > debugging window.  Simply add DebugWindow.Lib to your project, and then you 
  6835. > can
  6836. > do things like:
  6837. >    Debug ("Just starting so-and-so routine\r");
  6838. >    .....
  6839. >    Debug ("Value of index is now %d\r", index);
  6840.  
  6841. Any hints on where one might look for DebugWindow 2.0?
  6842.  
  6843. +++++++++++++++++++++++++++
  6844.  
  6845. >From pjcreath@tucson.Princeton.EDU (Peter Janssen Creath)
  6846. Date: Thu, 24 Feb 1994 21:10:06 GMT
  6847. Organization: Princeton University
  6848.  
  6849. In article <xu5p+Bd.danprice@delphi.com>,  <danprice@delphi.com> wrote:
  6850. >Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6851.  
  6852. My personal favorite is MacsBug in conjunction with Debugger() or
  6853. DebugStr("\pWhatever error message I want");
  6854.  
  6855. And it's free...(just hit "g" to resume)
  6856.  
  6857. And unless you're fiddling with low memory (and hosing the interrupt
  6858. table) it won't crash on you...
  6859.  
  6860.  
  6861. +++++++++++++++++++++++++++
  6862.  
  6863. >From blume@twg.com (David Blume)
  6864. Date: Fri, 25 Feb 1994 16:34:03 GMT
  6865. Organization: Gokuraku Videos - Wollongong Dept.
  6866.  
  6867. tzs@u.washington.edu (Tim Smith) wrote:
  6868. >One thing I found real useful for debugging was to write my own printf
  6869. >that wrote directly to screen memory. ... I didn't have to
  6870. >worry about memory being moved, or managers not being in the proper
  6871. >state, or whatever.
  6872.  
  6873. How did you draw characters directly to the screen without using a toolbox
  6874. routine that may have moved or purged memory?  Everything from DrawChar()
  6875. to CopyBits() might move memory...
  6876.  
  6877. --David
  6878. +---------------------------------------------------------------+
  6879. |  David Blume    |  "I get tired thinking of all the things I  |
  6880. |  blume@twg.com  |   don't want to do."  --Bukowski, _Barfly_  |
  6881. +---------------------------------------------------------------+
  6882.  
  6883. +++++++++++++++++++++++++++
  6884.  
  6885. >From bc@wetware.com (monsieur HAINEUX)
  6886. Date: Fri, 25 Feb 1994 19:20:09 GMT
  6887. Organization: /usr/local/lib/rn/organization
  6888.  
  6889. |In article <xu5p+Bd.danprice@delphi.com>,  <danprice@delphi.com> wrote:
  6890. |>Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6891.  
  6892. Use DebugStr(). Unless there's a reason you can't use MacsBug[1], it
  6893. works like a champ, and you get more feedback than SysBeep.
  6894.  
  6895. If you're REALLY clever, you can use a macro that includes an #ifdef
  6896. _DEBUG_ to automatically make the DebugStr's go away for production
  6897. code.
  6898.  
  6899. bill coderre
  6900. [1] Yes, there are cases where you cannot use MacsBug. Pray that they
  6901. never catch up to you.
  6902.  
  6903.  
  6904. +++++++++++++++++++++++++++
  6905.  
  6906. >From mahboud@aggroup.com (Mahboud Zabetian)
  6907. Date: Fri, 25 Feb 1994 12:16:16 -0800
  6908. Organization: AG Group, Inc.
  6909.  
  6910. In article <CLsoDL.Exu@wetware.com>, bc@wetware.com (monsieur HAINEUX)
  6911. wrote:
  6912.  
  6913. > |In article <xu5p+Bd.danprice@delphi.com>,  <danprice@delphi.com> wrote:
  6914. > |>Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6915. > Use DebugStr(). Unless there's a reason you can't use MacsBug[1], it
  6916. > works like a champ, and you get more feedback than SysBeep.
  6917. I do use Debugger() and DebugStr().  (In fact I also have use my own
  6918. DebugNum(), DebugHexNum() DebugBuffStr()....).
  6919.  
  6920. Yet there have been times that a SysBeep() is best.  For example:  A
  6921. customer complains that our applications doesn't do x.  I look and look and
  6922. look and look at the code and wonder: does it get to x and doesn't execute
  6923. it, or does it execute x and x is the problem, or is this user on drugs
  6924. since the code is OBVIOUSLY correct? (I don't write buggy code :-)  Well, I
  6925. add a quick SysBeep() before x and in x.  Then I send it to the customer
  6926. (who may or may not have MacsBug or who may or may not know what to do when
  6927. in MacsBug) and ask him:  "Does it beep when you try it?  Once or twice?"
  6928.  
  6929. You see, a Debugger() call would probably have been more of a hassle.
  6930.  
  6931. -mahboud
  6932.  
  6933. ps.   My favorite bug:
  6934.  
  6935.      handle = GetResource(.....);
  6936.      if (handle = nil) {
  6937.           // resource is there so do somthing with it.
  6938.      }
  6939.  
  6940. My next favorite bug:
  6941.       Calling InvalRect without a valid GrafPort set.
  6942.  
  6943. And:
  6944.      SetPort(window);  // where window is a random, garbage value on the
  6945. stack
  6946. - -------------------------------------------------------------
  6947. Mahboud Zabetian
  6948. mahboud@aggroup.com
  6949. ag group, inc.
  6950. 2540 camino diablo, suite 200
  6951. walnut creek, ca 94596
  6952. 510-937-7900 voice
  6953. 510-937-2479 fax
  6954. 510-937-6704 ara
  6955. ftp.aggroup.com anonymous ftp
  6956.  
  6957. +++++++++++++++++++++++++++
  6958.  
  6959. >From bc@wetware.com (monsieur HAINEUX)
  6960. Date: Fri, 25 Feb 1994 21:34:25 GMT
  6961. Organization: /usr/local/lib/rn/organization
  6962.  
  6963. In article <CLsoDL.Exu@wetware.com> bc@wetware.com (monsieur HAINEUX) writes:
  6964. ||In article <xu5p+Bd.danprice@delphi.com>,  <danprice@delphi.com> wrote:
  6965. ||>Wow, good point.  Any suggestions for an easy debugging tool like sysbeep()?
  6966. |
  6967. |Use DebugStr(). Unless there's a reason you can't use MacsBug[1], it
  6968. |works like a champ, and you get more feedback than SysBeep.
  6969. |
  6970. |If you're REALLY clever, you can use a macro that includes an #ifdef
  6971. |_DEBUG_ to automatically make the DebugStr's go away for production
  6972. |code.
  6973. |
  6974. |bill coderre
  6975. |[1] Yes, there are cases where you cannot use MacsBug. Pray that they
  6976. |never catch up to you.
  6977.  
  6978. Think Reference reminded me that DebugStr dumps you into the debugger,
  6979. but you can put a string like "Entering BugVille;g" and the semicolon
  6980. allows you to load up the rest of the string with MacsBug commands. In
  6981. this case, the screen will flicker briefly while Macsbug writes the
  6982. line, then the program will resume.
  6983.  
  6984. bill coderre
  6985. "Hard Problems made simple -- and vice versa"
  6986.     -- corporate motto of Symbolics
  6987.  
  6988.  
  6989. +++++++++++++++++++++++++++
  6990.  
  6991. >From mxmora@unix.sri.com (Matt Mora)
  6992. Date: 25 Feb 1994 10:08:13 -0800
  6993. Organization: SRI International, Menlo Park, CA
  6994.  
  6995. In article <1994Feb25.163403.14920@twg.com> blume@twg.com (David Blume) writes:
  6996. >tzs@u.washington.edu (Tim Smith) wrote:
  6997. >>One thing I found real useful for debugging was to write my own printf
  6998. >>that wrote directly to screen memory. ... I didn't have to
  6999. >>worry about memory being moved, or managers not being in the proper
  7000. >>state, or whatever.
  7001. >
  7002. >How did you draw characters directly to the screen without using a toolbox
  7003. >routine that may have moved or purged memory?  Everything from DrawChar()
  7004. >to CopyBits() might move memory...
  7005.  
  7006. He probably twiddled the bits directly. Which is why he said he was using
  7007. a 5 x 7 character set. He set each bit in the screen's bitmap himself.
  7008. Cool.
  7009.  
  7010.  
  7011. Xavier
  7012.  
  7013.  
  7014.  
  7015.  
  7016.  
  7017. -- 
  7018. ___________________________________________________________
  7019. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  7020. SRI International                       mxmora@unix.sri.com
  7021. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  7022.  
  7023. +++++++++++++++++++++++++++
  7024.  
  7025. >From monroe@teleport.com (Monroe Williams)
  7026. Date: 25 Feb 1994 17:00:18 -0800
  7027. Organization: Teleport - Portland's Public Access (503) 220-1016
  7028.  
  7029. In article <2kjhqi$2n70@te6000.otc.lsu.edu>,
  7030. Alexander Perlis <perlis_a@math.lsu.edu> wrote:
  7031. [...]
  7032. >Presumably, if the code of the original SysBeep() routine is still in ROM,  
  7033. >one can call it somehow, and memory will not be moved. That would solve  
  7034. >the problem of using beep sounds while debugging code which cannot move  
  7035. >memory. I don't know how to call the original SysBeep() code, assuming it  
  7036. >is even possible. Can any of the experts reading this thread shed some  
  7037. >light on the matter?
  7038.  
  7039. I doubt very much that any of the newer machines have the old SysBeep
  7040. code in them.  As you said, it's been done through the sound manager
  7041. for quite some time now.
  7042.  
  7043. However...
  7044.  
  7045. It should be possible to find the startup chime code in the ROMs.  I
  7046. seem to remember a little utility that plays the startup chime and
  7047. various error tones, apparently using the ROMs to do it.  Does anybody
  7048. out there know how this is done?  There are a couple of really
  7049. disturbing sounds a Mac can make (like when it fails the hardware RAM
  7050. diagnostic) that would definitely get your attention.  I can't imagine
  7051. these ROM routines would even require the memory manager, much less
  7052. move memory.
  7053.  
  7054. BTW (for the curious), on my SE/30 you can hear the error tones by
  7055. pressing the interrupt button on the programmer's switch while the
  7056. machine is doing the initial memory tests when you first switch it on.
  7057. I don't know if this trick works on newer machines that have the nicer
  7058. sounding startup chime, though.
  7059.  
  7060. - monroe
  7061. -- 
  7062. monroe@teleport.COM  Public Access User --- Not affiliated with TECHbooks
  7063. Public Access UNIX and Internet at (503) 220-0636 (1200/2400, N81)
  7064.  
  7065. +++++++++++++++++++++++++++
  7066.  
  7067. >From monroe@teleport.com (Monroe Williams)
  7068. Date: 25 Feb 1994 17:22:04 -0800
  7069. Organization: Teleport - Portland's Public Access (503) 220-1016
  7070.  
  7071. In article <CLsuLE.LBM@wetware.com>, monsieur HAINEUX <bc@wetware.com> wrote:
  7072. >In article <CLsoDL.Exu@wetware.com> bc@wetware.com (monsieur HAINEUX) writes:
  7073. >|If you're REALLY clever, you can use a macro that includes an #ifdef
  7074. >|_DEBUG_ to automatically make the DebugStr's go away for production
  7075. >|code.
  7076.  
  7077. Digressing just a bit...
  7078.  
  7079. It's pretty simple to make up a version of assert() that uses
  7080. DebugStr.  (Start with the assert.h that comes with your development
  7081. environment.  It's almost always implemented as a macro.)  With a few
  7082. preprocessor tricks, it will give you the file name and line number, as
  7083. well as the expression inside the assertion.  Real handy, especially
  7084. for porting code from unix that's full of asserts, when you're not
  7085. using console I/O.
  7086.  
  7087. - monroe
  7088. -- 
  7089. monroe@teleport.COM  Public Access User --- Not affiliated with TECHbooks
  7090. Public Access UNIX and Internet at (503) 220-0636 (1200/2400, N81)
  7091.  
  7092. +++++++++++++++++++++++++++
  7093.  
  7094. >From lewistot@netcom.com (John Lewis)
  7095. Date: Sat, 26 Feb 1994 04:22:56 GMT
  7096. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  7097.  
  7098. Mahboud Zabetian (mahboud@aggroup.com) wrote:
  7099. : SysBeep() may move memory and could potentially make dereferenced handles
  7100. : invalid!
  7101.  
  7102. You mean you don't lock your handles BEFORE you dereference them?
  7103.  
  7104. : This is a hard one to chase down, since you now have another bug added to
  7105. : whatever bug you were originally looking for.
  7106.  
  7107. Surround your dereferences with a LockHandle/UnlockHandle pair. This is
  7108. not only good programming practice, but it will also solve the problem
  7109. of SysBeep moving things around.
  7110. -- 
  7111. - -------------------------------------------------------------------------
  7112. John "I'ld rather be skydiving" Lewis|#include "standard .sig BS" |Witty  |
  7113. lewistot@netcom.com <- prefered      |Blue Skies to all skydivers.|text   |
  7114. jlewis@maxis.com    <- work          |USPA 87419, C-22826         |picture|
  7115. lewistotle@aol.com                   |<Fnord>                     |comming|
  7116.  
  7117. +++++++++++++++++++++++++++
  7118.  
  7119. >From kledbetter@aol.com (KLedbetter)
  7120. Date: 26 Feb 1994 13:25:02 -0500
  7121. Organization: America Online, Inc.
  7122.  
  7123. >    Debug ("Just starting so-and-so routine\r");
  7124. >    .....
  7125. >    Debug ("Value of index is now %d\r", index);
  7126.  
  7127. Any hints on where one might look for DebugWindow 2.0?
  7128. - --------
  7129. Robert --
  7130.  
  7131.   it's available on Compuserve in the MacDev forum, and on America Online in
  7132. the Mac Developers area.   It works really nice .. you can also do Hex dumps to
  7133. the window (ie: DebugHexDump (myBuffer, 1024)) and then print out the window's
  7134. contents, save as a teachtext document, etc..
  7135.  
  7136. Keith
  7137.  
  7138.  
  7139. +++++++++++++++++++++++++++
  7140.  
  7141. >From casgrain@ERE.UMontreal.CA (Casgrain Philippe)
  7142. Date: Sat, 26 Feb 1994 19:53:59 GMT
  7143. Organization: Universite de Montreal
  7144.  
  7145. >>    Debug ("Just starting so-and-so routine\r");
  7146. >>    .....
  7147. >>    Debug ("Value of index is now %d\r", index);
  7148. >
  7149. >Any hints on where one might look for DebugWindow 2.0?
  7150.  
  7151. >  it's available on Compuserve in the MacDev forum, and on America Online in
  7152. >the Mac Developers area.   It works really nice .. you can also do Hex dumps to
  7153. >the window (ie: DebugHexDump (myBuffer, 1024)) and then print out the window's
  7154. >contents, save as a teachtext document, etc..
  7155. >
  7156. Any idea where we could find it on the Internet? could somebody post it?
  7157.  
  7158. Philippe
  7159. -- 
  7160. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  7161. Philippe Casgrain              Etudiant-Chercheur      Casgrain@ERE.UMontreal.CA
  7162. Departement des Sciences Biologiques                      Universite de Montreal
  7163.                   "Imitation is the sincerest form of flattery"
  7164.  
  7165. +++++++++++++++++++++++++++
  7166.  
  7167. >From kledbetter@aol.com (KLedbetter)
  7168. Date: 27 Feb 1994 01:35:01 -0500
  7169. Organization: America Online, Inc.
  7170.  
  7171. >
  7172. Any idea where we could find it on the Internet? could somebody post it?
  7173.  
  7174. Philippe
  7175. - -------
  7176.  
  7177.   I'm looking into getting it up on the Internet now...I'll post a message as
  7178. soon as I get it out there...
  7179.  
  7180. keith
  7181.  
  7182.  
  7183. +++++++++++++++++++++++++++
  7184.  
  7185. >From tzs@u.washington.edu (Tim Smith)
  7186. Date: 1 Mar 1994 03:24:34 GMT
  7187. Organization: University of Washington School of Law, Class of '95
  7188.  
  7189. In article <2kleqd$51q@unix.sri.com>, Matt Mora <mxmora@unix.sri.com> wrote:
  7190. >He probably twiddled the bits directly. Which is why he said he was using
  7191. >a 5 x 7 character set. He set each bit in the screen's bitmap himself.
  7192. >Cool.
  7193.  
  7194. Actually, I said 3x5.  That way, with one pixel between consecutive characters,
  7195. memory manipulation only had to go down to the nibble level.  On a 640x480
  7196. display, with 2 lines of leading between lines, I could get 160 columns and
  7197. 68 rows.
  7198.  
  7199. In addition to drawing the character, I would also draw an underline three
  7200. lines below the character, and erase the two lines immediately below the
  7201. character.  That way, you could tell which of the 68 rows was the last one
  7202. drawn--it was the one that was underlined.  That way you can tell where you
  7203. are as more than 68 rows are printed and they start to wrap.  I also had an
  7204. end of line marker so you could tell on a row which characters belonged to
  7205. that row, and which were left over from the 68th previous printf, the 136th
  7206. previous printf, etc.
  7207.  
  7208. The hardest part was coming up with a 3x5 'M' that looks different than
  7209. a 3x5 'N'!  Here's my character set, in case anyone is curious.
  7210.  
  7211. struct OneChar
  7212. {
  7213.     char data[5];                           /* the data for a character */
  7214. };
  7215.  
  7216. struct OneChar CharData[] =
  7217. {
  7218.     {5,2,5,2,5},    /* non-existant char */
  7219.     {2,5,7,5,5},    /* 1 A */
  7220.     {6,5,6,5,6},
  7221.     {7,5,4,5,7},
  7222.     {6,5,5,5,6},
  7223.     {7,4,6,4,7},
  7224.     {7,4,6,4,4},
  7225.     {7,4,5,5,7},    /* 7 G */
  7226.     {5,5,7,5,5},
  7227.     {7,2,2,2,7},
  7228.     {3,1,1,5,7},
  7229.     {4,5,6,5,5},
  7230.     {4,4,4,4,7},
  7231.     {5,7,5,5,5},
  7232.     {5,7,7,7,5},
  7233.     {2,5,5,5,2},    /* 15 O */
  7234.     {7,5,7,4,4},
  7235.     {2,5,5,7,3},
  7236.     {6,5,7,6,5},
  7237.     {3,4,6,1,7},
  7238.     {7,2,2,2,2},
  7239.     {5,5,5,5,7},
  7240.     {5,5,5,5,2},
  7241.     {5,5,5,7,5},
  7242.     {5,2,2,2,5},
  7243.     {5,5,2,2,2},
  7244.     {7,1,2,4,7},    /* 26 Z */
  7245.     {3,5,5,5,6},    /* 27 0 */
  7246.     {2,6,2,2,7},
  7247.     {7,5,2,4,7},
  7248.     {7,1,3,1,7},
  7249.     {5,5,7,1,1},
  7250.     {7,4,7,1,7},
  7251.     {4,4,7,5,7},
  7252.     {7,1,1,2,2},
  7253.     {7,5,7,5,7},
  7254.     {7,5,7,1,1},    /* 36 9 */
  7255.     {0,0,0,0,0},    /* 37 space */
  7256.     {2,2,2,0,2},    /* ! */
  7257.     {5,5,0,0,0},    /* " */
  7258.     {5,7,5,7,5},    /* 40 # */
  7259.     {7,6,2,3,7},    /* $ */
  7260.     {3,3,2,6,6},    /* % */
  7261.     {6,5,2,5,7},    /* & */
  7262.     {2,2,0,0,0},    /* ' */
  7263.     {2,4,4,4,2},    /* 45 ( */
  7264.     {2,1,1,1,2},    /* ) */
  7265.     {5,2,7,2,5},    /* * */
  7266.     {0,2,7,2,0},    /* + */
  7267.     {0,0,0,1,3},    /* , */
  7268.     {0,0,7,0,0},    /* 50 - */
  7269.     {0,0,0,6,6},    /* . */
  7270.     {1,1,2,2,4},    /* / */
  7271.     {6,6,0,6,6},    /* : */
  7272.     {6,6,0,2,6},    /* ; */
  7273.     {1,2,4,2,1},    /* 55 < */
  7274.     {0,7,0,7,0},    /* = */
  7275.     {4,2,1,2,4},    /* > */
  7276.     {6,1,2,0,2},    /* ? */
  7277.     {6,4,4,4,6},    /* [ */
  7278.     {4,4,2,2,1},    /* 60 \ */
  7279.     {3,1,1,1,3},    /* ] */
  7280.     {2,5,0,0,0},    /* ^ */
  7281.     {0,0,0,0,7},    /* _ */
  7282.     {4,2,0,0,0},    /* ^ */
  7283.     {3,2,4,2,3},    /* 65 { */
  7284.     {2,2,2,2,2},    /* | */
  7285.     {6,2,1,2,6},    /* } */
  7286.     {4,7,1,0,0},    /* ~ */
  7287.     {0,3,5,6,3},    /* @ */
  7288.     {7,7,7,7,7}     /* end of line marker */
  7289. }
  7290.  
  7291. --Tim Smith
  7292.  
  7293. +++++++++++++++++++++++++++
  7294.  
  7295. >From ez006626@othello.ucdavis.edu (David Xavier Clancy)
  7296. Date: Tue, 1 Mar 1994 09:51:29 GMT
  7297. Organization: University of California, Davis
  7298.  
  7299. I thought the accepted thing was to use FlashMenuBar
  7300.  
  7301. It is not auditory, but if you are looking at the screen, it does the trick.
  7302.  
  7303. Also, I'm pretty sure DebugWindow, (i get the name right?) mentioned in other
  7304. posts is at sumex.  
  7305.  
  7306. --xav
  7307.  
  7308.  
  7309. +++++++++++++++++++++++++++
  7310.  
  7311. >From philip@concave.cs.wits.ac.za (Philip Machanick)
  7312. Date: Tue, 01 Mar 1994 08:51:39 +0200
  7313. Organization: Computer Science Dept, U of Witwatersrand
  7314.  
  7315. In article <lewistotCLtDIA.C3@netcom.com>, lewistot@netcom.com (John Lewis)
  7316. wrote:
  7317.  
  7318. > Surround your dereferences with a LockHandle/UnlockHandle pair. This is
  7319. > not only good programming practice, but it will also solve the problem
  7320. > of SysBeep moving things around.
  7321.  
  7322. No it's not. Much better practice is 
  7323.   oldstate = HGetState(h);
  7324.   HLock(h);
  7325. ...do something assuming h can't move...
  7326.   HSetState(h, oldstate);  
  7327. otherwise you could end up unlocking a handle that the code that called the
  7328. current routine still expects to have locked.
  7329.  
  7330. In any case: there are situations where you don't want to lock a handle and
  7331. to put the locking code in just because you are debugging is not a good
  7332. solution.
  7333. -- 
  7334. Philip Machanick                   philip@concave.cs.wits.ac.za
  7335. Department of Computer Science, University of the Witwatersrand
  7336. 2050 Wits, South Africa
  7337. phone 27(11)716-3309  fax 27(11)339-7965
  7338.  
  7339. +++++++++++++++++++++++++++
  7340.  
  7341. >From walrathw@rferl.org (WalrathW)
  7342. Date: 3 Mar 94 09:22:38 -0500
  7343. Organization: RFE/RL Inc.
  7344.  
  7345. In article <lewistotCLtDIA.C3@netcom.com>
  7346. lewistot@netcom.com (John Lewis) writes:
  7347.  
  7348. > Mahboud Zabetian (mahboud@aggroup.com) wrote:
  7349. > : SysBeep() may move memory and could potentially make dereferenced handles
  7350. > : invalid!
  7351. > You mean you don't lock your handles BEFORE you dereference them?
  7352. > : This is a hard one to chase down, since you now have another bug added to
  7353. > : whatever bug you were originally looking for.
  7354. > Surround your dereferences with a LockHandle/UnlockHandle pair. This is
  7355. > not only good programming practice, but it will also solve the problem
  7356. > of SysBeep moving things around.
  7357. > -- 
  7358.  
  7359. I would disagree that it's good programming practice to just surround
  7360. every handle with HLock/HUnlock calls.  Those calls take time and if
  7361. they aren't absolutely necessary, then you shouldn't use them.
  7362.  
  7363. HLock(myHandle);
  7364. ((MyStruct*)*myHandle)->myLong = 10;
  7365. HUnlock(myHandle);
  7366.  
  7367. nahhh?
  7368.  
  7369.  
  7370. > ---------------------------------------------------------------------------
  7371. > John "I'ld rather be skydiving" Lewis|#include "standard .sig BS" |Witty  |
  7372. > lewistot@netcom.com <- prefered      |Blue Skies to all skydivers.|text   |
  7373. > jlewis@maxis.com    <- work          |USPA 87419, C-22826         |picture|
  7374. > lewistotle@aol.com                   |<Fnord>                     |comming|
  7375.  
  7376. maxis.com, is that the Simulation Games company?
  7377.  
  7378. ______o0o______
  7379.  Wayne Walrath
  7380.  RFE/RL Inc.
  7381.  
  7382. +++++++++++++++++++++++++++
  7383.  
  7384. >From tgreen@ersys.edmonton.ab.ca (Terry Greeniaus)
  7385. Date: Mon, 07 Mar 94 16:13:55 MST
  7386. Organization: Edmonton Remote Systems #2
  7387.  
  7388. > In article <mahboud-230294225858@mahboud.aggroup.com>,
  7389. > Mahboud Zabetian <mahboud@aggroup.com> wrote:
  7390. > >> Wow, good point.  Any suggestions for an easy debugging tool like sysbeep(
  7391.  
  7392. Well, you could use FlashMenuBar(), but I'm not sure whether it messes 
  7393. with memory or not.
  7394.  
  7395. --
  7396. Terry Greeniaus   tgreen@ersys.edmonton.ab.ca   
  7397. Edmonton Remote Systems   Serving Edmonton/Northern Alberta since 1982
  7398.  
  7399. +++++++++++++++++++++++++++
  7400.  
  7401. >From mxmora@unix.sri.com (Matt Mora)
  7402. Date: 10 Mar 1994 09:00:10 -0800
  7403. Organization: SRI International, Menlo Park, CA
  7404.  
  7405. In article <wPBuic1w165w@ersys.edmonton.ab.ca> tgreen@ersys.edmonton.ab.ca (Terry Greeniaus) writes:
  7406. >> In article <mahboud-230294225858@mahboud.aggroup.com>,
  7407. >> Mahboud Zabetian <mahboud@aggroup.com> wrote:
  7408. >
  7409. >Well, you could use FlashMenuBar(), but I'm not sure whether it messes 
  7410. >with memory or not.
  7411.  
  7412. Not unless you are sure the gworld is valid ( ie the one with the menubar)
  7413. before you call it as another poster had mentioned.
  7414.  
  7415.  
  7416. Xavier
  7417.  
  7418.  
  7419.  
  7420. -- 
  7421. ___________________________________________________________
  7422. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  7423. SRI International                       mxmora@unix.sri.com
  7424. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  7425.  
  7426. +++++++++++++++++++++++++++
  7427.  
  7428. >From mbabramo@unix.amherst.edu (MICHAEL BERNARD ABRAMOWICZ)
  7429. Date: 11 Mar 1994 20:15:35 -0500
  7430. Organization: Amherst College, Amherst MA, USA
  7431.  
  7432. > Well, you could use FlashMenuBar(), but I'm not sure whether it messes 
  7433. > with memory or not.
  7434.  
  7435. This is exactly the solution. FlashMenuBar() does NOT move memory.
  7436.  
  7437. > --
  7438. > Terry Greeniaus   tgreen@ersys.edmonton.ab.ca   
  7439. > Edmonton Remote Systems   Serving Edmonton/Northern Alberta since 1982
  7440.  
  7441. Michael Abramowicz
  7442. Amherst College
  7443. Writer, Inside Macintosh: Memory, More Macintosh Toolbox, Sound
  7444.  
  7445. +++++++++++++++++++++++++++
  7446.  
  7447. >From mahboud@aggroup.com (Mahboud Zabetian)
  7448. Date: Sun, 13 Mar 1994 23:34:29 -0800
  7449. Organization: AG Group, Inc.
  7450.  
  7451. In article <2lr53n$lr3@amhux3.amherst.edu>, mbabramo@unix.amherst.edu
  7452. (MICHAEL BERNARD ABRAMOWICZ) wrote:
  7453.  
  7454. > > Well, you could use FlashMenuBar(), but I'm not sure whether it messes 
  7455. > > with memory or not.
  7456. > This is exactly the solution. FlashMenuBar() does NOT move memory.
  7457. > > --
  7458. > > Terry Greeniaus   tgreen@ersys.edmonton.ab.ca   
  7459. > > Edmonton Remote Systems   Serving Edmonton/Northern Alberta since 1982
  7460. > Michael Abramowicz
  7461. > Amherst College
  7462. > Writer, Inside Macintosh: Memory, More Macintosh Toolbox, Sound
  7463.  
  7464. I have tried to use FlashMenuBar in place of SysBeep.  I don't find it as
  7465. useful as SysBeep though.  It is very hard to miss a SysBeep, but
  7466. FlashMenuBar is easy to miss.  Especially if you have a faster machine.
  7467.  
  7468. -mahboud
  7469.  
  7470. - -------------------------------------------------------------
  7471. Mahboud Zabetian
  7472. mahboud@aggroup.com
  7473. ag group, inc.
  7474. 2540 camino diablo, suite 200
  7475. walnut creek, ca 94596
  7476. 510-937-7900 voice
  7477. 510-937-2479 fax
  7478. 510-937-6704 ara
  7479. ftp.aggroup.com anonymous ftp
  7480.  
  7481. +++++++++++++++++++++++++++
  7482.  
  7483. >From Greg_Marriott@genmagic.com (Greg Marriott)
  7484. Date: Mon, 14 Mar 1994 01:55:17 -0800
  7485. Organization: General Magic, Inc.
  7486.  
  7487. mbabramo@unix.amherst.edu (MICHAEL BERNARD ABRAMOWICZ) wrote:
  7488. > > Well, you could use FlashMenuBar(), but I'm not sure whether it messes 
  7489. > > with memory or not.
  7490. > This is exactly the solution. FlashMenuBar() does NOT move memory.
  7491.  
  7492. Wrong.
  7493.  
  7494. This took me less than a minute to check out.  Among the calls made inside
  7495. FlashMenuBar(): NewHandle() and SetHandleSize().
  7496.  
  7497. -- 
  7498. Greg Marriott
  7499. Just Some Guy
  7500. General Magic, Inc.
  7501.  
  7502. Disclaimer: My opinions are not necessarily the same as General Magic's.
  7503.             (can a company even HAVE an opinion?)
  7504.  
  7505. ---------------------------
  7506.  
  7507. >From perlis_a@math.lsu.edu (Alexander Perlis)
  7508. Subject: Improving DrawText speed (Was: Color Terminal Emulator)
  7509. Date: 11 Mar 1994 18:28:27 GMT
  7510. Organization: Louisiana State University InterNetNews Site
  7511.  
  7512. In article <trygve-100394010606@kip-87.apple.com> trygve@apple.com (Trygve  
  7513. Isaacson) writes:
  7514. > 2) Optimize out whitespace: move the pen instead of drawing blanks. Of
  7515. > course, this assumes you can calculate the character width ahead of  
  7516. time,
  7517. > which assumes you're using a monospaced font. Note that boldface throws  
  7518. a
  7519. > wrench in things unless your font's bold maintains the same character  
  7520. width
  7521. > as plain, as does our Noiro font shipped with the SNA ps emulators.
  7522. > Trygve Isaacson
  7523. > SNA ps engineer
  7524. > Apple Computer, Inc.
  7525.  
  7526. I thought the built-in QuickDraw routines for drawing text simply ASSUME  
  7527. that the space character (ASCII 32) in every font is truly a space and  
  7528. simply move the pen without drawing anything when in srcOr mode. Of  
  7529. course, if your font is monospaced and you have a bunch of spaces, it  
  7530. might be faster to just skip over that than letting QuickDraw move the pen  
  7531. a bunch of times, but I don't believe that the speedup is too significant  
  7532. in the sense that one should worry more about speeding up the drawing of  
  7533. actual text than speeding up the movement of the pen over empty regions.
  7534.  
  7535. If you put a graphic character in position 32 of a font, it will NOT be  
  7536. displayed. As far as I can tell, this behavior, and a few other subleties  
  7537. involving graphic characters in the control positions of a font,  
  7538. characters 0 through 31, have never been fully documented or explained by  
  7539. Apple. Please correct me if I'm wrong and point me in the direction of  
  7540. such documentation.
  7541.  
  7542. I got around the problems in QuickDraw by writing a complete replacement  
  7543. for the text drawing system (not too difficult since I only use monospaced  
  7544. fonts in terminal emulation) which can handle fonts of 256 true graphic  
  7545. characters. This solution proved faster than using two Macintosh fonts  
  7546. with 128 characters each to simulate a 256-character font and swapping  
  7547. between the two fonts all the time.
  7548.  
  7549. Incidentally, I never understood WHY QuickDraw has trouble drawing text in  
  7550. srcCopy mode. The only slowdown should come when it has to draw a space,  
  7551. since now it must actually erase the rectangle rather than simply moving  
  7552. the pen. But that should not account for the major difference in speed  
  7553. between srcOr and srcCopy. Can someone at Apple explain this?
  7554.  
  7555. Alexander Perlis
  7556. perlis_a@math.lsu.edu
  7557.  
  7558. ---------------------------
  7559.  
  7560. >From atotic@void.ncsa.uiuc.edu (Alexsander Totic)
  7561. Subject: Interface guidelines for extra program files
  7562. Date: 16 Mar 94 16:36:40 GMT
  7563. Organization: University of Illinois at Urbana
  7564.  
  7565. I am building a program that creates and uses several external files besides
  7566. preferences. I have always disliked any external file approaches, but
  7567. this time I have to store data in this way. I was wandering what the
  7568. Apple's recommendation for storing of these files are: should application
  7569. have its own folder somewhere on a disk, or in a system folder, or spread
  7570. around through user preferences.
  7571.  
  7572. Allowing user to specify location of external folder allows multiple users
  7573. to start up an application by clicking on their preferences file, and have
  7574. everything work fine. But it also confuses them, especially when there are
  7575. many external files.
  7576.  
  7577. There is no right solution, so I would like to skip the responsibility, and
  7578. follow the guidelines.
  7579.  
  7580. Aleks
  7581. -- 
  7582. Aleksandar Totic        -- MacMosaic developer --          atotic@ncsa.uiuc.edu
  7583. Software Development Group      National Center for Supercomputing Applications
  7584.            http://www.ncsa.uiuc.edu/SDG/People/atotic/alex.html
  7585.  
  7586. +++++++++++++++++++++++++++
  7587.  
  7588. >From pcastine@jake.prz.tu-berlin.de (Peter Castine)
  7589. Date: Thu, 17 Mar 1994 20:57:38 GMT
  7590. Organization: PRZ TU-Berlin
  7591.  
  7592. Alexsander Totic writes:
  7593. >I am building a program that creates and uses several external files besides
  7594. >preferences. I have always disliked any external file approaches, but
  7595. >this time I have to store data in this way. I was wandering what the
  7596. >Apple's recommendation for storing of these files are: should application
  7597. >have its own folder somewhere on a disk, or in a system folder, or spread
  7598. >around through user preferences.
  7599. >
  7600. >Allowing user to specify location of external folder allows multiple users
  7601. >to start up an application by clicking on their preferences file, and have
  7602. >everything work fine. But it also confuses them, especially when there are
  7603. >many external files.
  7604. >
  7605. >There is no right solution, so I would like to skip the responsibility, and
  7606. >follow the guidelines.
  7607. >
  7608.  
  7609. The only guideline is "Don't put user files in the same folder as
  7610. the application." This is because the application might well be on
  7611. a file server and the user would probably not have write access to
  7612. that folder. 
  7613.  
  7614. I think the best solution is to do what QuickMail (and several other
  7615. programs) does: instead of a single file in the user's Preferences
  7616. folder, it creates a '<AppName> Stuff' folder in the Preferences
  7617. folder, and dumps everything in there.
  7618.  
  7619. Make sure to use the _FindFolder trap (if it's available) when looking
  7620. for the Prefs folder. It is *NOT* called 'Preferences' on many Macs.
  7621.  
  7622. -- 
  7623. Peter Castine                      | One child is shot every two hours
  7624. pcastine@jake.kgw.tu-berlin.de     | in the U.S.A.
  7625.                    | Thank you for blocking gun control,
  7626.                    | N.R.A.
  7627.  
  7628. ---------------------------
  7629.  
  7630. >From jafl@cco.caltech.edu (John Lindal)
  7631. Subject: Intermixing graphics and text
  7632. Date: 15 Mar 1994 01:35:47 GMT
  7633. Organization: California Institute of Technology, Pasadena
  7634.  
  7635. Has anyone written any straight code or TCL classes that allow pictures
  7636. and text to be intermixed?  Of these, is there anyone willing to share this?
  7637. (or sell it for that matter?)
  7638.  
  7639. Thanks.  John Lindal
  7640.  
  7641.  
  7642. +++++++++++++++++++++++++++
  7643.  
  7644. >From thunderone@delphi.com
  7645. Date: Tue, 15 Mar 94 02:40:05 -0500
  7646. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  7647.  
  7648. John Lindal <jafl@cco.caltech.edu> writes:
  7649.  
  7650. >Has anyone written any straight code or TCL classes that allow pictures
  7651. >and text to be intermixed?  Of these, is there anyone willing to share this?
  7652. >(or sell it for that matter?)
  7653.  
  7654. If you want to use TextEdit, it's pretty simple to do.  Here's how I do
  7655. it.  Note that pictHandle is an array containing PICT resources
  7656. (surprise!) and pictPositions is an array that holds the number of the
  7657. character that the lower left corner of the picture is anchored on.
  7658.  
  7659.     Point       tPoint;
  7660.     PicHandle   WhiteNoise;
  7661.     short       i;
  7662.     Rect        theRect;
  7663. /  GrafPtr     old;
  7664.     CGrafPtr    theGraf=(CGrafPtr)theWindow;
  7665.  
  7666.     SetPort(thePort);
  7667.     if(numPicts){
  7668.         for(i=1;i<=numPicts;i++){
  7669.             WhiteNoise=pictHandle[i];
  7670.             if(!WhiteNoise)
  7671.                 return;
  7672.             tPoint=TEGetPoint(pictPositions[i],theTE);
  7673.             HLockHi((Handle)WhiteNoise);
  7674.             theRect=(**WhiteNoise).picFrame;
  7675.  
  7676.             theRect.right=tPoint.h+(theRect.right-theRect.left);
  7677.             theRect.top=tPoint.v-(theRect.bottom-theRect.top);
  7678.             theRect.left=tPoint.h;
  7679.             theRect.bottom=tPoint.v;
  7680.  
  7681.             UQD::KillClip();
  7682.             ClipRect(&teSquare);//(**theTE).viewRect
  7683.  
  7684.             DrawPicture(WhiteNoise,&theRect);
  7685.  
  7686.             if(pictPositions[i]>=(**theTE).selStart&&pictPositions[i]<(**theTE).
  7687. selEnd){
  7688.                 if(UQD::BitDepth()>1){
  7689.                     PenMode(adMin);
  7690.                     RGBForeColor(&(**(GVarHandle)theGraf->grafVars).rgbHiliteCol
  7691. or);
  7692.                     BackColor(blackColor);
  7693.                     PaintRect(&theRect);
  7694.                 }else{
  7695.                     InvertRect(&theRect);
  7696.                 }
  7697.             }
  7698.             ForeColor(blackColor);
  7699.             BackColor(whiteColor);
  7700.             UQD::RestoreClip();
  7701.             HUnlock((Handle)WhiteNoise);
  7702.         }
  7703.     }
  7704.  
  7705. Chris
  7706.  
  7707. -
  7708. Chris Thomas, Delphi ICONtact Developer Database Librarian
  7709. thunderone@delphi.com
  7710.  
  7711. ---------------------------
  7712.  
  7713. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  7714. Subject: Let's kill 24-bit mode! (was Re: Let's kill System 6!)
  7715. Date: 14 Mar 94 18:31:16 +1300
  7716. Organization: University of Waikato, Hamilton, New Zealand
  7717.  
  7718. OK, let's start a new version of this thread, shall we?
  7719.  
  7720. With more and more machines running with more than 8MB of RAM, is it worth
  7721. still testing your code to make sure it works in 24-bit mode? It's so much
  7722. easier leaving out all those StripAddress calls, rather than trying to remember
  7723. when you need them and when you don't, don't you think?
  7724.  
  7725. I've been running a home machine in 32-bit mode for close to 3 years now.
  7726. First it was an LC with 10MB, now it's a C650 with 16MB. And Godot, my long-
  7727. awaited, brand-spanking-new 840AV at work, couldn't run in 24-bit mode if I
  7728. wanted it to.
  7729.  
  7730. So what do other people think? Is it time to declare 24-bit mode dead yet...?
  7731.  
  7732. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  7733. Info & Tech Services Division              fax: +64-7-838-4066
  7734. University of Waikato            electric mail: ldo@waikato.ac.nz
  7735. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  7736.  
  7737. +++++++++++++++++++++++++++
  7738.  
  7739. >From jwbaxter@olympus.net (John W. Baxter)
  7740. Date: Mon, 14 Mar 1994 09:18:43 -0800
  7741. Organization: Internet for the Olympic Peninsula
  7742.  
  7743. In article <1994Mar14.183116.26366@waikato.ac.nz>, ldo@waikato.ac.nz
  7744. (Lawrence D'Oliveiro, Waikato University) wrote:
  7745.  
  7746. > So what do other people think? Is it time to declare 24-bit mode dead yet...?
  7747.  
  7748. If you like, and test for the machine being in 24-bit mode at the start of
  7749. your code, and alert and exit gracefully.  I don't mind being told gently
  7750. that your code won't work on my secondary machine (a 4 meg Mac Plus).  I do
  7751. mind if it crashes.  And I mind a WHOLE LOT if it corrupts the disk
  7752. while/before crashing, or (worse) corrupts the disk without crashing.
  7753.  
  7754. Same with my primary machine, in the once-every-6-months situation where I
  7755. set it to 24-bit mode for some odd reason.
  7756.  
  7757. With some of the newest machines not being able to run in 24-bit mode, the
  7758. time is approaching, but it may not be here yet.
  7759. -- 
  7760. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  7761.    jwbaxter@pt.olympus.net
  7762.  
  7763. +++++++++++++++++++++++++++
  7764.  
  7765. >From u9119523@sys.uea.ac.uk (Graham Cox)
  7766. Date: Tue, 15 Mar 1994 17:41:52 GMT
  7767. Organization: School of Information Systems, UEA, Norwich
  7768.  
  7769. In article <1994Mar14.183116.26366@waikato.ac.nz>, ldo@waikato.ac.nz
  7770. (Lawrence D'Oliveiro, Waikato University) wrote:
  7771.  
  7772. > OK, let's start a new version of this thread, shall we?
  7773. > With more and more machines running with more than 8MB of RAM, is it worth
  7774. > still testing your code to make sure it works in 24-bit mode? It's so much
  7775. > easier leaving out all those StripAddress calls, rather than trying to remember
  7776. > when you need them and when you don't, don't you think?
  7777. > I've been running a home machine in 32-bit mode for close to 3 years now.
  7778. > First it was an LC with 10MB, now it's a C650 with 16MB. And Godot, my long-
  7779. > awaited, brand-spanking-new 840AV at work, couldn't run in 24-bit mode if I
  7780. > wanted it to.
  7781. > So what do other people think? Is it time to declare 24-bit mode dead yet...?
  7782. > Lawrence D'Oliveiro                       fone: +64-7-856-2889
  7783. > Info & Tech Services Division              fax: +64-7-838-4066
  7784. > University of Waikato            electric mail: ldo@waikato.ac.nz
  7785. > Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  7786.  
  7787.  
  7788. Am I missing something vital here? I have never used StripAddress in any
  7789. program I've ever written and they all work in 24 or 32-bit mode. Either
  7790. what I'm doing is not very advanced compared to yours or you aren't doing
  7791. things the compatible way! I don't want to dump on you about this without
  7792. knowing the facts- I therefore assume the former (?). I believe that
  7793. addresses/pointers are always valid in whatever mode and OF COURSE you
  7794. never try to set the high byte of a handle right?
  7795.  
  7796.  
  7797.  
  7798. - ------------------------------------------------------------------------
  7799. Love & BSWK, Graham
  7800.  
  7801. -Everyone is entitled to their opinion, no matter how wrong they may be...
  7802. - ------------------------------------------------------------------------
  7803.  
  7804. +++++++++++++++++++++++++++
  7805.  
  7806. >From t-gaul@i-link.com (Troy Gaul)
  7807. Date: Tue, 15 Mar 1994 17:10:35 -0600
  7808. Organization: I-Link, Ltd.
  7809.  
  7810. In article <u9119523-150394174152@case6.sys.uea.ac.uk>,
  7811. u9119523@sys.uea.ac.uk (Graham Cox) wrote:
  7812.  
  7813. > In article <1994Mar14.183116.26366@waikato.ac.nz>, ldo@waikato.ac.nz
  7814. > (Lawrence D'Oliveiro, Waikato University) wrote:
  7815. > > OK, let's start a new version of this thread, shall we?
  7816. > > 
  7817. > > With more and more machines running with more than 8MB of RAM, is it worth
  7818. > > still testing your code to make sure it works in 24-bit mode? It's so much
  7819. > > easier leaving out all those StripAddress calls, rather than trying to remember
  7820. > > when you need them and when you don't, don't you think?
  7821. > > 
  7822. > > I've been running a home machine in 32-bit mode for close to 3 years now.
  7823. > > First it was an LC with 10MB, now it's a C650 with 16MB. And Godot, my long-
  7824. > > awaited, brand-spanking-new 840AV at work, couldn't run in 24-bit mode if I
  7825. > > wanted it to.
  7826. > > 
  7827. > > So what do other people think? Is it time to declare 24-bit mode dead yet...?
  7828. > Am I missing something vital here? I have never used StripAddress in any
  7829. > program I've ever written and they all work in 24 or 32-bit mode. Either
  7830. > what I'm doing is not very advanced compared to yours or you aren't doing
  7831. > things the compatible way! I don't want to dump on you about this without
  7832. > knowing the facts- I therefore assume the former (?). I believe that
  7833. > addresses/pointers are always valid in whatever mode and OF COURSE you
  7834. > never try to set the high byte of a handle right?
  7835.  
  7836. There are cases where you must call StripAddress for a program to function
  7837. correctly in all 'modes'. It is possible that you haven't run across them.
  7838.  
  7839. One case in point is when you are manually switching the processor's
  7840. addressing modes (like, when working with directly accessing data in a
  7841. GWorld PixMap).  Since the PixMap may be stored on a NuBus board's memory
  7842. (our of 24-bit range), you should switch to 32-bit mode to access the data
  7843. (and back when you're done).  If you have a pointer in a local variable
  7844. from before you switched out of 24-bit, it is possible this pointer has
  7845. some high bits being used, so you should strip it if you intend to
  7846. dereference it from 32-bit mode.
  7847.  
  7848. Moral is: when you might be changing modes, you should be careful.
  7849.  
  7850. Or something like that. :)
  7851.  
  7852. _troy
  7853. //////// //////___Troy Gaul_________________________t-gaul@i-link.com__ //
  7854.   //    //       I-Link, Ltd. ; West Des Moines, Iowa                  //
  7855.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)           //
  7856. //    //////________________________________________________________ //
  7857. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  7858. Subject: Let's kill 24-bit mode! (was Re: Let's kill System 6!)
  7859. Date: Tue, 15 Mar 1994 23:47:30 GMT
  7860. Organization: Proteus Ventures, Inc.
  7861.  
  7862. In article <1994Mar14.183116.26366@waikato.ac.nz>
  7863. ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  7864.  
  7865. > With more and more machines running with more than 8MB of RAM, is it worth
  7866. > still testing your code to make sure it works in 24-bit mode? It's so much
  7867. > easier leaving out all those StripAddress calls, rather than trying to remember
  7868. > when you need them and when you don't, don't you think?
  7869.  
  7870. Huh? StripAddress? What's that? :-) :-)
  7871.  
  7872. Juan Ingles
  7873. <DACRXL01.OURX124@tcp30.dx.deere.com>
  7874. --
  7875. Proteus Ventures, Inc. - Computer Software Consulting and Development
  7876.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  7877.  
  7878. +++++++++++++++++++++++++++
  7879.  
  7880. >From sw@network-analysis-ltd.co.uk (Sak Wathanasin)
  7881. Date: Wed, 16 Mar 94 00:15:54 GMT
  7882. Organization: Network Analysis Ltd
  7883.  
  7884.  
  7885. In article <u9119523-150394174152@case6.sys.uea.ac.uk> (comp.sys.mac.programmer), u9119523@sys.uea.ac.uk (Graham Cox) writes:
  7886.  
  7887. > ... I believe that
  7888. > addresses/pointers are always valid in whatever mode and OF COURSE you
  7889. > never try to set the high byte of a handle right?
  7890.  
  7891. You don't have to: the resource manager will happily set them for you,
  7892. for example. Most of the time it doesn't matter, but there are times
  7893. when it does (like when you call a code resource loaded with the RM and
  7894. the CR turns on 32-bit mode - your return addreses on the stack become
  7895. instant garbage). There's a tech note that tells you when StripAdress
  7896. is necessary; can't remember what it's called off the top of my head.
  7897.  
  7898. Sak Wathanasin
  7899. Network Analysis Limited
  7900. 178 Wainbody Ave South, Coventry CV3 6BX, UK
  7901.  
  7902. Internet: sw@network-analysis-ltd.co.uk 
  7903. uucp:     ...!uknet!nan!sw                       AppleLink: NAN.LTD
  7904. Phone: (+44) 203 419996 Mobile:(+44) 850 587411  Fax: (+44) 203 690690
  7905.  
  7906. ---------------------------
  7907.  
  7908. >From bsc@oui.com (Bill Stewart-Cole)
  7909. Subject: Let's kill system 6!
  7910. Date: 20 Feb 1994 13:12:15 -0600
  7911. Organization: Odyssey Ultraware Inc
  7912. St Louis, MO
  7913.  
  7914. The whole discussion on supporting system 6 has spurred some thoughts: 
  7915.  
  7916. Would not Mac developers benefit by a 100% move to system 7?
  7917. Would not Mac users benefit by upgrading to 7 and Macs that can run it well?
  7918.  
  7919. It is a royal pain to support BOTH the full features of 7, and system 6.  I
  7920. have taken 2 tracks: 1. if the program specifically calls for features of 7,
  7921. I check for it and politely quit if I don't have it. 2. If the program can be
  7922. used just fine without 7-specific features, I use all the system 6 versions
  7923. and let the program crash on the rare 512k (not 512ke) running 4.1.   The one
  7924. time I tried to develop a program for an either/or operation, the result was
  7925. a confusing program to debug and a program far too big. And a nervous tic:). 
  7926.   We'd all make smaller, clearer, and less bug-prone code if we stuck to one
  7927. set of system features.  Programs would get out faster. Money would flow in
  7928. for programs sooner.  We'd have fewer ulcers.
  7929.  
  7930. On the user side, it's important to consider who is still using system 6 and
  7931. why.  They are essentially 2 types: 1. People who have a fixed function for
  7932. their Mac that works well and can be done with 6.  2. People who  would do
  7933. better running 7 on a faster Mac.   In the first group, they aren't buying
  7934. software.  In the second,  they are ready to move to 7 with the slightest
  7935. nudge. A //ci-class Mac is a fine platform for 7, and the 5 machines in that
  7936. general performance range are breaking below $700 on the used market.  Even
  7937. if Joe Plus User won't bite on a $2000 PDM PowerMac, he is not unlikely to
  7938. see the used //ci's and //cx's and LC3's being dumped to upgrade by other
  7939. users who want faster boxes as tempting.  The increased pressure in that
  7940. direction of 7-only software (i.e. requiring a good machine for running 7)
  7941. will make for a user base with more compatibility, more power, and less
  7942. ghettoizing of users. 
  7943.  
  7944. Anyway, I think it is a positive step for developers to move away from
  7945. supporting system 6 because of the good it will do to get everyone running 7,
  7946. both for developers and for users. 
  7947.  
  7948. +++++++++++++++++++++++++++
  7949.  
  7950. >From rrwood@r-node.io.org (Roy Wood)
  7951. Date: 21 Feb 1994 10:41:47 -0500
  7952. Organization: Internex Online (io.org) Data: 416-363-3783  Voice: 416-363-8676
  7953.  
  7954.  
  7955. Another group of users stuck with sloooooooow system 6 machines are students
  7956. and teachers at public schools.  I'd love to upgrade our lab to faster
  7957. machines, but there's no way our budget can afford it.
  7958.  
  7959. This is not such a huge problem, in terms of the thread being discussed,
  7960. since we're doing mostly word processing and other mundane things, and
  7961. we're hardly likely to rush out and invest in any bleeding-edge killer
  7962. apps anyway.
  7963.  
  7964. -Roy
  7965.  
  7966.  
  7967. +++++++++++++++++++++++++++
  7968.  
  7969. >From time@garnet.msen.com (Tim Endres)
  7970. Date: 22 Feb 1994 17:32:28 GMT
  7971. Organization: Msen, Inc. -- Ann Arbor, MI (account info: +1 313 998-4562)
  7972.  
  7973. Bill Stewart-Cole (bsc@oui.com) wrote:
  7974. : The whole discussion on supporting system 6 has spurred some thoughts: 
  7975.  
  7976. : Would not Mac developers benefit by a 100% move to system 7?
  7977. : Would not Mac users benefit by upgrading to 7 and Macs that can run it well?
  7978.  
  7979. This is a marketing decision, not a engineering decision.
  7980. Perform your own market analysis and make a business decision.
  7981. That is what most developers do...
  7982.  
  7983. +++++++++++++++++++++++++++
  7984.  
  7985. >From wbostow@hounix.org (Wayne Bostow)
  7986. Date: Thu, 24 Feb 1994 15:09:52 GMT
  7987. Organization: Houston UNIX Users Group (HOUNIX), Houston, TX
  7988.  
  7989.  
  7990. : Would not Mac developers benefit by a 100% move to system 7?
  7991.  
  7992.   Well, not me! I am ticked at Apple for allowing no upgrade path from
  7993. MPW 1.0. I bought everything in '87 for under $300. I did not get several
  7994. upgrades because APPLE said not to unless you had a machine to handle
  7995. it. My current version will not even launch under sys 7. To get everything
  7996. now is about $1000 plus a new hard drive and more memory. 
  7997.  
  7998.   As an assembly programmer, I see most of the improvements as clutter.
  7999. -- 
  8000. __________________________________________________________
  8001.   Wayne Bostow "The HangulMan"
  8002.    10558 Alcott, Houston, TX 77043    ph. (713)468-6546
  8003.      wbostow@hounix.org
  8004.  
  8005. +++++++++++++++++++++++++++
  8006.  
  8007. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  8008. Date: Fri, 25 Feb 1994 11:04:37 GMT
  8009. Organization: (none)
  8010.  
  8011. time@garnet.msen.com (Tim Endres) writes:
  8012.  
  8013. >Bill Stewart-Cole (bsc@oui.com) wrote:
  8014. >: The whole discussion on supporting system 6 has spurred some thoughts: 
  8015.  
  8016. >: Would not Mac developers benefit by a 100% move to system 7?
  8017. >: Would not Mac users benefit by upgrading to 7 and Macs that can run it well?
  8018.  
  8019. That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8020. Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8021. All those Macs are significantly nicer with System 6. Apple has designed
  8022. System 7 in a way that makes a 100% move to System 7 *impossible*. System
  8023. 6 won't go away until the last of the above Macs stop working. Sure, many
  8024. users will move to sys 7 even with slow Macs, usually since they are forced
  8025. to, but lots of them will run system 6 until they die.
  8026.  
  8027. And they won't die for a long time yet. You might be able to get rid of
  8028. some by good trade-in offers, but even that won't help. Would you trade an
  8029. SE for a LC475 at half the price? Sure? Many people will say yes, but some
  8030. may think twice. Some of those Macs - especially SE - are *much* more
  8031. reliable than the new ones. That's (one of the reasons) why they were
  8032. so expensive.
  8033.  
  8034. >This is a marketing decision, not a engineering decision.
  8035. >Perform your own market analysis and make a business decision.
  8036. >That is what most developers do...
  8037.  
  8038. Isn't this both marketing and engineering?
  8039.  
  8040. --
  8041. - -
  8042. Ingemar Ragnemalm, PhD
  8043. Image processing, Mac shareware games
  8044. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  8045.  
  8046. +++++++++++++++++++++++++++
  8047.  
  8048. >From j-norstad@nwu.edu (John Norstad)
  8049. Date: Fri, 25 Feb 1994 13:28:09 -0600
  8050. Organization: Northwestern University
  8051.  
  8052. In article <CLs1Fr.Fup@lysator.liu.se>, ingemar@lysator.liu.se (Ingemar
  8053. Ragnemalm) wrote:
  8054.  
  8055. > That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8056. > Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8057. > All those Macs are significantly nicer with System 6.
  8058.  
  8059. I couldn't disagree more strongly. I have a Mac Classic at home with 4
  8060. megs. It is *infinitely* nicer with System 7 than with System 6. My two
  8061. kids, ages 8 and 13, who use it for homework, agree with me 100%.
  8062.  
  8063. You need a Mac Plus or later with at least 4 megs to run System 7. It
  8064. works just fine on the old Macs, and is nicer than System 6 on those Macs
  8065. for exactly the same reason that it's nicer than System 6 on the newer and
  8066. bigger Macs.
  8067.  
  8068. At NU, we have completely dropped support for System 6. We tell people to
  8069. get at least 4 megs and run System 7 on their old Macs. They can stay with
  8070. System 6 if they wish, but if they do they are on their own, with no
  8071. support from us. This was a good decision, IMHO.
  8072.  
  8073. -- 
  8074. John Norstad
  8075. Academic Computing and Network Services
  8076. Northwestern University
  8077. j-norstad@nwu.edu
  8078.  
  8079. +++++++++++++++++++++++++++
  8080.  
  8081. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  8082. Date: Fri, 25 Feb 1994 19:31:46 GMT
  8083. Organization: Proteus Ventures, Inc.
  8084.  
  8085. In article <CLs1Fr.Fup@lysator.liu.se>
  8086. ingemar@lysator.liu.se (Ingemar Ragnemalm) writes:
  8087.  
  8088. > Some of those Macs - especially SE - are *much* more
  8089. > reliable than the new ones. That's (one of the reasons) why they were
  8090. > so expensive.
  8091.  
  8092. Huh? Is there any evidence to support this? In my personal dealings, I
  8093. have found newer machines more reliable.
  8094.  
  8095. >That's (one of the reasons) why they were so expensive.
  8096.  
  8097. If that were true, they would still hold a high value. I would think
  8098. that  profit margins, R&D, and inflation make up 99% of the reason.
  8099.  
  8100. Juan Ingles
  8101. <DACRXL01.OURX124@tcp30.dx.deere.com>
  8102. --
  8103. Proteus Ventures, Inc. - Computer Software Consulting and Development
  8104.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  8105. -- 
  8106. All reality portrayed in this message is fictional. Any resemblance to
  8107. any real reality, alive or dead, is purely coincidental and
  8108. unintentional.
  8109.  
  8110. +++++++++++++++++++++++++++
  8111.  
  8112. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  8113. Date: 25 Feb 1994 22:08:30 GMT
  8114. Organization: Royal Institute of Technology, Stockholm, Sweden
  8115.  
  8116. In <CLs1Fr.Fup@lysator.liu.se> ingemar@lysator.liu.se (Ingemar Ragnemalm) writes:
  8117.  
  8118. >That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8119. >Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8120.  
  8121. My value judgement is that all of the color-capable Macs are
  8122. also System-7-capable.
  8123.  
  8124. >All those Macs are significantly nicer with System 6. Apple has designed
  8125. >System 7 in a way that makes a 100% move to System 7 *impossible*. System
  8126.  
  8127. "All those Macs"
  8128.  
  8129. Apple is increasing its market share som 30% a year, and all macs sold
  8130. the last few years have been System 7 Macs. System 6 will go away, not
  8131. only because people upgrade, but because Apple sells so many more macs
  8132. a year now than in 1991.
  8133.  
  8134. Cheers,
  8135.  
  8136.                     / h+
  8137. -- 
  8138.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  8139.  
  8140.    This article printed on 100% recycled electrons.
  8141.  
  8142. +++++++++++++++++++++++++++
  8143.  
  8144. >From cabu1hj@ube.ub.umd.edu
  8145. Date: 26 Feb 94 22:52:01 -0500
  8146. Organization: University of Baltimore
  8147.  
  8148. In article <CLs1Fr.Fup@lysator.liu.se>, ingemar@lysator.liu.se 
  8149. (Ingemar Ragnemalm) writes:
  8150. > [stuff deleted]
  8151. > That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8152. > Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8153. > All those Macs are significantly nicer with System 6. 
  8154.  
  8155. I think you need to double check statements like this.  Several of these
  8156. systems run just fine with System 7.0, 7.0.1, & 7.1.  Not with the 
  8157. factory shipped memory (like 3MB on the IIsi).  Running them with 
  8158. 8MB+ isn't unrealistic given the size of current applications either.
  8159.  
  8160.  
  8161. +++++++++++++++++++++++++++
  8162.  
  8163. >From qsi@NU91.wlink.nl (Peter Kocourek)
  8164. Date: Sun, 27 Feb 1994 00:22:45 +0100
  8165. Organization: (none)
  8166.  
  8167. Ingemar Ragnemalm wrote in a message on 25 Feb 94
  8168.  
  8169.  IR> That means killing off all Macs below LC III. Plus, SE, LC, 
  8170.  IR> LC II, Classic, Classic II, Color Classic, PB100,Portable, 
  8171.  IR> perhaps even IIcx, IIsi and IIvi. All those Macs are significantly 
  8172.  IR> nicer with System 6. Apple has designed System 7 in a way that 
  8173.  
  8174. I beg to differ. I have a IIsi here, and I don't see how running System 6 on it
  8175. would make it "nicer". I'd lose aliases, drag & drop, AppleEvents (and hence
  8176. AppleScript), a much better Finder, WorldScript, and Publish & Subscribe. How
  8177. can the loss of these make the machine "nicer"?
  8178.  
  8179.  IR> makes a 100% move to System 7 *impossible*. System 6 won't 
  8180.  IR> go away until the last of the above Macs stop working. Sure, 
  8181.  IR> many users will move to sys 7 even with slow Macs, usually 
  8182.  IR> since they are forced to, but lots of them will run system 
  8183.  IR> 6 until they die. 
  8184.  
  8185. Oh, sure, a 100% adoption rate for System 7 won't ever happen; after all, there
  8186. are still people running CP/M too. :-) But I think you are wrong with your
  8187. classification of System 6 Macs; I don't know anybody running System 6 on an LC
  8188. or Mac II. And System 6 is dying very quickly, now that Apple is selling huge
  8189. amounts of Macs every year (perhaps as many as 4 million this year), none of
  8190. which can run System 6.
  8191.  
  8192.  IR> And they won't die for a long time yet. You might be able to 
  8193.  IR> get rid of some by good trade-in offers, but even that won't 
  8194.  IR> help. Would you trade an SE for a LC475 at half the price? 
  8195.  IR> Sure? Many people will say yes, but some may think twice. Some 
  8196.  IR> of those Macs - especially SE - are *much* more reliable than 
  8197.  IR> the new ones. That's (one of the reasons) why they were so 
  8198.  IR> expensive.
  8199.  
  8200. I'm extremely skeptical about this claim. Could you provide some evidence to
  8201. support this? The reason they were so expensive was because Apple had huge
  8202. profit margins.
  8203.  
  8204.  
  8205. YHS:QSI!
  8206.  
  8207.  
  8208. +++++++++++++++++++++++++++
  8209.  
  8210. >From isis@netcom.com (Mike Cohen)
  8211. Date: Sun, 27 Feb 1994 20:27:17 GMT
  8212. Organization: ISIS International
  8213.  
  8214. cabu1hj@ube.ub.umd.edu writes:
  8215.  
  8216. >In article <CLs1Fr.Fup@lysator.liu.se>, ingemar@lysator.liu.se 
  8217. >(Ingemar Ragnemalm) writes:
  8218. >> 
  8219. >> [stuff deleted]
  8220. >> 
  8221. >> That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8222. >> Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8223. >> All those Macs are significantly nicer with System 6. 
  8224.  
  8225. >I think you need to double check statements like this.  Several of these
  8226. >systems run just fine with System 7.0, 7.0.1, & 7.1.  Not with the 
  8227. >factory shipped memory (like 3MB on the IIsi).  Running them with 
  8228. >8MB+ isn't unrealistic given the size of current applications either.
  8229.  
  8230. I have a PB100, IIsi (with 14 megs of RAM & a FPU) and an SE/30 (acting as a
  8231. file server). All of them run System 7 or later (S7Pro on the IIsi) and I
  8232. don't think I could live with anything less. System 6 should finally be laid
  8233. to rest. The speed & size difference isn't that great (the lean system on my
  8234. PB even though I have CPU, FaxPro, & ARA is only 1300K) and the many benefits
  8235. & convenience features of System 7 far outweigh the tiny speed difference.
  8236. -- 
  8237. Mike Cohen - isis@netcom.com
  8238. NewtonMail: MikeC49506 / ALink: D6734 / AOL: MikeC20
  8239.  
  8240.  
  8241. +++++++++++++++++++++++++++
  8242.  
  8243. >From L.H.Wood@lut.ac.uk
  8244. Date: Sun, 27 Feb 1994 22:56:15 GMT
  8245. Organization: Loughborough University, UK.
  8246.  
  8247. In article <762314409.AA03366@nu91.wlink.nl> qsi@NU91.wlink.nl (Peter Kocourek) writes:
  8248. >Ingemar Ragnemalm wrote in a message on 25 Feb 94
  8249. >
  8250. > IR> That means killing off all Macs below LC III. Plus, SE, LC, 
  8251. > IR> LC II, Classic, Classic II, Color Classic, PB100,Portable, 
  8252. > IR> perhaps even IIcx, IIsi and IIvi. All those Macs are significantly 
  8253. > IR> nicer with System 6. Apple has designed System 7 in a way that 
  8254. >
  8255. >I beg to differ. I have a IIsi here, and I don't see how running System 6 on it
  8256. >would make it "nicer". I'd lose aliases, drag & drop, AppleEvents (and hence
  8257. >AppleScript), a much better Finder, WorldScript, and Publish & Subscribe. How
  8258. >can the loss of these make the machine "nicer"?
  8259. >
  8260. System 6 and 7 store things at the opposite ends of memory to each other.
  8261. Under S6 on a IIsi, a large disk cache is not required to boost drawing-to
  8262. video speeds. Nothing gets put in the remaining part of that megabyte until
  8263. you fill the machine right up.
  8264.  
  8265. Considering that the disk cache in not used under S6 Multifinder, this is
  8266. a blessing twice over. (Aside: I've read that Apple are redoing the disk-cache
  8267. code. Can we expect a disk cache whose size you don't set, that utilises free
  8268. memory wherever it can, a la Windows NT, for System 7.5?)
  8269.  
  8270. L.
  8271.  
  8272. +++++++++++++++++++++++++++
  8273.  
  8274. >From neeri@iis.ee.ethz.ch (Matthias Neeracher)
  8275. Date: 28 Feb 94 17:26:34
  8276. Organization: Integrated Systems Laboratory, ETH, Zurich
  8277.  
  8278. In article <CLs1Fr.Fup@lysator.liu.se>, ingemar@lysator.liu.se (Ingemar Ragnemalm) writes:
  8279.  
  8280. > time@garnet.msen.com (Tim Endres) writes:
  8281.  
  8282. >>Bill Stewart-Cole (bsc@oui.com) wrote:
  8283. >>: The whole discussion on supporting system 6 has spurred some thoughts: 
  8284.  
  8285. >>: Would not Mac developers benefit by a 100% move to system 7?
  8286. >>: Would not Mac users benefit by upgrading to 7 and Macs that can run it well?
  8287.  
  8288. > That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8289. > Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8290. > All those Macs are significantly nicer with System 6.
  8291.  
  8292. I do most of my programming on an original Mac II. For about a year, I had one
  8293. System 6 and one System 7 startup volume, but it turned out taht I never used
  8294. the System 6 volume anymore.
  8295.  
  8296. Matthias
  8297.  
  8298. - ---
  8299. Matthias Neeracher                                      neeri@iis.ee.ethz.ch
  8300.    "I feel morally and intellectually obligated simply to concede that the 
  8301.     death penalty experiment has failed." 
  8302.                                -- Supreme Court Justice Harry A. Blackmun
  8303.  
  8304. +++++++++++++++++++++++++++
  8305.  
  8306. >From wbostow@hounix.org (Wayne Bostow)
  8307. Date: Mon, 28 Feb 1994 21:39:45 GMT
  8308. Organization: Houston UNIX Users Group (HOUNIX), Houston, TX
  8309.  
  8310.  
  8311. >If that were true, they would still hold a high value. I would think
  8312. that  profit margins, R&D, and inflation make up 99% of the reason.
  8313.  
  8314.   I think the used price lists show SE30s higher that Classic IIs and
  8315. IIcx's higher than their LC replacements. I attribute it to people who
  8316. want to continue using 6.
  8317.  
  8318.   There are lots of us not ready to spend thousands on hardware and
  8319. software upgrades even to get something " *infinitely* nicer".
  8320.  
  8321.  
  8322.  
  8323.  
  8324. -- 
  8325. __________________________________________________________
  8326.   Wayne Bostow "The HangulMan"
  8327.    10558 Alcott, Houston, TX 77043    ph. (713)468-6546
  8328.      wbostow@hounix.org
  8329.  
  8330. +++++++++++++++++++++++++++
  8331.  
  8332. >From gdl@stlawrence.maths (Mr_G._Landweber_student_tel_2-73550)
  8333. Date: 28 Feb 1994 23:48:12 GMT
  8334. Organization: (none)
  8335.  
  8336.    In article <CLs1Fr.Fup@lysator.liu.se>
  8337.    ingemar@lysator.liu.se (Ingemar Ragnemalm) writes:
  8338.  
  8339.    > Some of those Macs - especially SE - are *much* more
  8340.    > reliable than the new ones. That's (one of the reasons) why they were
  8341.    > so expensive.
  8342.  
  8343. I remember writing a 3-page essay with WriteNow on my old Mac SE, and
  8344. it crashed at least three times.  More recently, I wrote a 50+ page
  8345. thesis with Word and it only crashed once.
  8346.  
  8347. In my experience, my Mac IIcx/Rocket is much more stable than my SE
  8348. ever was.  In fact, most of my crashes come from bugs in pre-release
  8349. versions of Greg's Buttons (some pretty spectatular things happen when
  8350. you patch _GetResource and trash A1).
  8351.  
  8352. -- Greg "Buttons" Landweber
  8353.    gdl@maths.ox.ac.uk
  8354.  
  8355. +++++++++++++++++++++++++++
  8356.  
  8357. >From cabu1hj@ube.ub.umd.edu
  8358. Date: 28 Feb 94 19:53:09 -0500
  8359. Organization: University of Baltimore
  8360.  
  8361. In article <WISEKB.12.0016AE3C@caedm.et.byu.edu>, 
  8362. WISEKB@caedm.et.byu.edu (Kevin B. Wise) writes:
  8363. > Long live system 6!!!!!!!!!
  8364.  
  8365. Spoken like a ture horse & buggy man.
  8366.  
  8367.  
  8368. +++++++++++++++++++++++++++
  8369.  
  8370. >From jwbaxter@olympus.net (John W. Baxter)
  8371. Date: Tue, 01 Mar 1994 08:48:30 -0800
  8372. Organization: Internet for the Olympic Peninsula
  8373.  
  8374. I don't want to prevent anyone from using System 6 who wants to do so.
  8375.  
  8376. On the other hand, I haven't written anything for System 6 for a couple of
  8377. years.  I've forgotten how.  I don't want to relearn.  So...what I write
  8378. won't do any good for people who run System 6.  [But...I haven't released
  8379. anything major recently, anyhow.]
  8380.  
  8381. For some developers, there's still a nice market of System 6 users.  Go for
  8382. it!
  8383.  
  8384. -- 
  8385. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  8386.    jwbaxter@pt.olympus.net
  8387.  
  8388. +++++++++++++++++++++++++++
  8389.  
  8390. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  8391. Date: 1 Mar 1994 19:42:48 GMT
  8392. Organization: Royal Institute of Technology, Stockholm, Sweden
  8393.  
  8394. In <1994Feb28.213945.20363@hounix.org> wbostow@hounix.org (Wayne Bostow) writes:
  8395.  
  8396. >  I think the used price lists show SE30s higher that Classic IIs and
  8397. >IIcx's higher than their LC replacements. I attribute it to people who
  8398. >want to continue using 6.
  8399.  
  8400. I attribute it to an informed market; the SE30 is twice the speed
  8401. of the Classic II and can take more memory; the IIcx is not only twice
  8402. the speed of the LC, it also has three NuBus slots.
  8403.  
  8404. Cheers,
  8405.  
  8406.                         / h+
  8407. -- 
  8408.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  8409.  "Don't use the Layer Manager"
  8410.  
  8411. +++++++++++++++++++++++++++
  8412.  
  8413. >From temple@itd.nrl.navy.mil (Dr. Jon Gerard Temple)
  8414. Date: Wed, 2 Mar 1994 20:11:17 GMT
  8415. Organization: Naval Research Laboratory
  8416.  
  8417. In article <2l05ro$mqi@news.kth.se>
  8418. d88-jwa@mumrik.nada.kth.se (Jon Wdtte) writes:
  8419.  
  8420. > In <1994Feb28.213945.20363@hounix.org> wbostow@hounix.org (Wayne Bostow) writes:
  8421. > >  I think the used price lists show SE30s higher that Classic IIs and
  8422. > >IIcx's higher than their LC replacements. I attribute it to people who
  8423. > >want to continue using 6.
  8424. > I attribute it to an informed market; the SE30 is twice the speed
  8425. > of the Classic II and can take more memory; the IIcx is not only twice
  8426. > the speed of the LC, it also has three NuBus slots.
  8427.  
  8428. Agreed. Moreover, the SE/30 and IIcx were quality machines. Designed
  8429. well and made to last. The LCs and Classic IIs always feel cheap in
  8430. comparison, with much less care taken in their design and manufacture. 
  8431. Not that I would turn my nose up at a LC475 (Q605)...
  8432.  
  8433. Jon
  8434.  
  8435. +++++++++++++++++++++++++++
  8436.  
  8437. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  8438. Date: Wed, 2 Mar 1994 19:29:08 GMT
  8439. Organization: (none)
  8440.  
  8441. cabu1hj@ube.ub.umd.edu writes:
  8442.  
  8443. >In article <CLs1Fr.Fup@lysator.liu.se>, ingemar@lysator.liu.se 
  8444. >(Ingemar Ragnemalm) writes:
  8445. >> 
  8446. >> [stuff deleted]
  8447. >> 
  8448. >> That means killing off all Macs below LC III. Plus, SE, LC, LC II, Classic,
  8449. >> Classic II, Color Classic, PB100,Portable, perhaps even IIcx, IIsi and IIvi.
  8450. >> All those Macs are significantly nicer with System 6. 
  8451.  
  8452. >I think you need to double check statements like this.  Several of these
  8453. >systems run just fine with System 7.0, 7.0.1, & 7.1.  Not with the 
  8454. >factory shipped memory (like 3MB on the IIsi).  Running them with 
  8455. >8MB+ isn't unrealistic given the size of current applications either.
  8456.  
  8457. I didn't say it won't work - it will, at least with 4 megs. I said that
  8458. those Macs are so slow that they are *noticeably* more sluggish (at least
  8459. in the Finder) when using System 7, and therefore many users won't change.
  8460. And as long as many users have a better life with the *old* system, it
  8461. won't go away in a long time.
  8462.  
  8463. I've tried Sys 7 on my SE. Never again. I use System 7 on my LC. I wish
  8464. I didn't have to, but with sys 6 it can't print due to the sys 7-running
  8465. IIfx that uses the same printer. When I switch the LC to sys 6 (I have both
  8466. on it, on separate disks) it feels like if I had plugged in an accelerator
  8467. board.
  8468.  
  8469. Plusses, SE's and Classics are best used with sys 6, if at all possible
  8470. (again, sharing a printer might make it impossible). Faster, more memory
  8471. (max 4, you know). LC's only for the speed difference. At IIsi, it's
  8472. getting fast enough to consider upgrading to 7, but it does slow down...
  8473.  
  8474. About that printer problem... Anyone who knows a way to make a sys 6 Mac
  8475. work with the new printer drivers? Will 6.0.8 fix it? (Dumping in the
  8476. new drivers didn't.)
  8477.  
  8478. --
  8479. - -
  8480. Ingemar Ragnemalm, PhD
  8481. Image processing, Mac shareware games
  8482. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  8483.  
  8484. +++++++++++++++++++++++++++
  8485.  
  8486. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  8487. Date: Wed, 2 Mar 1994 19:41:30 GMT
  8488. Organization: (none)
  8489.  
  8490. L.H.Wood@lut.ac.uk writes:
  8491.  
  8492. >Aside: I've read that Apple are redoing the disk-cache
  8493. >code. Can we expect a disk cache whose size you don't set, that utilises free
  8494. >memory wherever it can, a la Windows NT, for System 7.5?
  8495.  
  8496. That could be nice, but even more important: will Apple get it act together
  8497. and fix the memory management overall? It seems like RamDoubler will fix
  8498. most of it for now, but fixes like that should go into the OS. Memory
  8499. protection would be nice too. (I suppose I won't get that from RamDoubler.)
  8500.  
  8501. --
  8502. - -
  8503. Ingemar Ragnemalm, PhD
  8504. Image processing, Mac shareware games
  8505. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  8506.  
  8507. +++++++++++++++++++++++++++
  8508.  
  8509. >From watkeyeh@dunx1.ocs.drexel.edu (Edwin H. Watkeys III)
  8510. Date: Thu, 3 Mar 1994 00:47:57 GMT
  8511. Organization: Drexel University
  8512.  
  8513. In article <CM1y4M.E9t@lysator.liu.se> ingemar@lysator.liu.se (Ingemar Ragnemalm) writes:
  8514. >[A lot of stuff deleted]
  8515.  
  8516. There's no point in arguing -- the speed tradeoff is worth it to me. I'd
  8517. sooner use a typewriter than System 6.
  8518.  
  8519. >
  8520. >About that printer problem... Anyone who knows a way to make a sys 6 Mac
  8521. >work with the new printer drivers? Will 6.0.8 fix it? (Dumping in the
  8522. >new drivers didn't.)
  8523. >
  8524.  
  8525. I thought this was the reason 6.0.8 came out in the first place (to make
  8526. System 6 compatible with System 7.x printing drivers). Try it.
  8527.  
  8528. Ed
  8529. -- 
  8530. Ed Watkeys              watkeyeh@dunx1.ocs.drexel.edu  Drexel University
  8531. Philosopher-Programmer  EdWatkeys@distant.com           Distant Software
  8532.  
  8533. +++++++++++++++++++++++++++
  8534.  
  8535. >From Brad Koehn <koehn@macc.wisc.edu>
  8536. Date: 4 Mar 1994 01:17:08 GMT
  8537. Organization: University of Wisconsin
  8538.  
  8539. In article <CM1y4M.E9t@lysator.liu.se> Ingemar Ragnemalm,
  8540. ingemar@lysator.liu.se writes:
  8541. >I didn't say it won't work - it will, at least with 4 megs. I said that
  8542. >those Macs are so slow that they are *noticeably* more sluggish (at least
  8543. >in the Finder) when using System 7, and therefore many users won't
  8544. change.
  8545. >And as long as many users have a better life with the *old* system, it
  8546. >won't go away in a long time.
  8547. >
  8548. >I've tried Sys 7 on my SE. Never again. I use System 7 on my LC. I wish
  8549. >I didn't have to, but with sys 6 it can't print due to the sys 7-running
  8550. >IIfx that uses the same printer. When I switch the LC to sys 6 (I have
  8551. both
  8552. >on it, on separate disks) it feels like if I had plugged in an
  8553. accelerator
  8554. >board.
  8555. >
  8556. >Plusses, SE's and Classics are best used with sys 6, if at all possible
  8557. >(again, sharing a printer might make it impossible). Faster, more memory
  8558. >(max 4, you know). LC's only for the speed difference. At IIsi, it's
  8559. >getting fast enough to consider upgrading to 7, but it does slow down...
  8560. >
  8561. >About that printer problem... Anyone who knows a way to make a sys 6 Mac
  8562. >work with the new printer drivers? Will 6.0.8 fix it? (Dumping in the
  8563. >new drivers didn't.)
  8564.  
  8565. The printer problem is from using the System 7 LW Driver alongside the
  8566. System 6 LW Driver. Just put the Sys6 driver on the Sys7 machine and the
  8567. printer won't re-initialize every time you print from the other machine. 
  8568.  
  8569. Also, I agree that Sys7 is more sluggish than Sys6, but you have to take
  8570. into effect things like aliases (so you don't have to navigate to every
  8571. file) and AppleScript. System 7 lets the Finder do more, and if you take
  8572. advantage of the extra goodies, you can be more productive.
  8573.  
  8574. As someone (I believe it was Jon) pointed out, there are far more Sys7
  8575. Macs out there, and more and more software is Sys7 only. While there may
  8576. be some people out there that stick with Sys6, their number is getting
  8577. smaller every day. Also, Sys6 don't tend to buy lots of new software,
  8578. which is understandable, but doesn't help the "Sys7 required" trend.
  8579. _________________________________________________________________________
  8580. Brad Koehn          Data Transformations, Inc.        koehn@macc.wisc.edu
  8581.  
  8582. +++++++++++++++++++++++++++
  8583.  
  8584. >From worley@el.wpafb.af.mil (Rick Worley)
  8585. Date: Fri, 4 Mar 94 16:42:31 GMT
  8586. Organization: WL/ELM
  8587.  
  8588. >
  8589. >About that printer problem... Anyone who knows a way to make a sys 6 Mac
  8590. >work with the new printer drivers? Will 6.0.8 fix it? (Dumping in the
  8591. >new drivers didn't.)
  8592. >
  8593. 6.0.8 is available from ftp.apple.com//dts/sys.soft
  8594.  
  8595. 6.0.8 is compatible with System 7 laserwriter drivers
  8596.  
  8597. But you should install LaserWriter 8.1.1 on all your macs, it works with
  8598. both System 6 and 7.
  8599.  
  8600. Rick Worley                                                  Tel: (513) 255-7665
  8601. WL/ELM  BLDG 620                                             Fax: (513) 476-4807
  8602. 2241 AVIONICS CIRCLE SUITE 25                             worley@el.wpafb.af.mil
  8603. WRIGHT-PATTERSON AFB OH 45433-7327
  8604.  
  8605. +++++++++++++++++++++++++++
  8606.  
  8607. >From wbostow@hounix.org (Wayne Bostow)
  8608. Date: Sun, 06 Mar 1994 23:02:22 GMT
  8609. Organization: Houston UNIX Users Group (HOUNIX), Houston, TX
  8610.  
  8611.  
  8612. >But you should install LaserWriter 8.1.1 on all your macs, it works with
  8613. both System 6 and 7.
  8614.  
  8615.   Depends what you mean by "works".
  8616.  
  8617.   I heard this nonsense when sys 7 first came out and wasted a lot
  8618. of time with it before taking it off to use with my LaserWriterPlus.
  8619.  
  8620.   Thing is, with that printer, there is a max of about 128k free for
  8621. fonts using the sys 6 driver. Eat that away with the newer drivers
  8622. and you cannot print your existing documents.
  8623.  
  8624.   If you are working alone and are printing OK now, don't change.
  8625. -- 
  8626. __________________________________________________________
  8627.   Wayne Bostow "The HangulMan"
  8628.    10558 Alcott, Houston, TX 77043    ph. (713)468-6546
  8629.      wbostow@hounix.org
  8630.  
  8631. ---------------------------
  8632.  
  8633. >From pope@imv.aau.dk (Povl H. Pedersen)
  8634. Subject: Never beep when using GWorlds. System software bug!
  8635. Date: 6 Mar 1994 12:52:05 GMT
  8636. Organization: Information and Media Science, Aarhus University, DENMARK
  8637.  
  8638. I just had to help a guy who used my PICT file saving code.
  8639. He had some problems, and had inserted a SysBeep() in the bottleneck
  8640. procedure to write the bytes.
  8641.  
  8642. Now, the way my routine works is to create a new GWorld, SetGWorld,
  8643. OpenPicture, CopyBits, ClosePicture.
  8644.  
  8645. The problem is, that the machine he uses has the volume set to 0.
  8646. When my GWorld is set, and the SysBeep() tries to flash the menubar,
  8647. then the machine crashes each and every time! When I replaced the
  8648. the SetGWorld with a SetPort to the port of the FronWindow(), then I
  8649. got the flashing menu bar. Setting the sound volume > 0 gave me the
  8650. beeps instead.
  8651.  
  8652. So I would appreciate if some dude at Apple could look the code over,
  8653. and make sure that FlashMenuBar() is only called with a valid GWorld,
  8654. or sets/restores the window Gworld itself.
  8655.  
  8656. Now, this problem will probably get low priority, as it affects <10% of 
  8657. the Maacintosh users (those with sound level set to 0).
  8658.  
  8659. - -
  8660. Povl H. Pedersen  -  Macintosh Consultant and Programmer
  8661. System Administrator at the Aarhus Engineering School
  8662. pope@imv.aau.dk (preferred)  /  povlphp@uts.uni-c.dk
  8663.  
  8664. "Macintosh...for those who can see through Windows!"
  8665.  
  8666. +++++++++++++++++++++++++++
  8667.  
  8668. >From tgreen@ersys.edmonton.ab.ca (Terry Greeniaus)
  8669. Date: Thu, 10 Mar 94 15:46:30 MST
  8670. Organization: Edmonton Remote Systems #1
  8671.  
  8672. pope@imv.aau.dk (Povl H. Pedersen) writes:
  8673.  
  8674. > I just had to help a guy who used my PICT file saving code.
  8675. > He had some problems, and had inserted a SysBeep() in the bottleneck
  8676. > procedure to write the bytes.
  8677. > Now, the way my routine works is to create a new GWorld, SetGWorld,
  8678. > OpenPicture, CopyBits, ClosePicture.
  8679. > The problem is, that the machine he uses has the volume set to 0.
  8680. > When my GWorld is set, and the SysBeep() tries to flash the menubar,
  8681. > then the machine crashes each and every time! When I replaced the
  8682. > the SetGWorld with a SetPort to the port of the FronWindow(), then I
  8683. > got the flashing menu bar. Setting the sound volume > 0 gave me the
  8684. > beeps instead.
  8685. > So I would appreciate if some dude at Apple could look the code over,
  8686. > and make sure that FlashMenuBar() is only called with a valid GWorld,
  8687. > or sets/restores the window Gworld itself.
  8688. > Now, this problem will probably get low priority, as it affects <10% of 
  8689. > the Maacintosh users (those with sound level set to 0).
  8690. Well, I have also had problems with GWorlds, (offscreen ports, actually, 
  8691. but it's on a related topice.).  If you are set to a port somewhere 
  8692. offscreen, and call SetWTitle() it will try to draw the window into your 
  8693. port off screen, and make funny things appear.  (I'm not sure if the 
  8694. Inside Mac description says the set the port to the window who's title 
  8695. you're going to change, but that solved the problem.)
  8696.  
  8697.  
  8698. "Yes, I have tricks in my pocket, I have things up my sleeve.  But I am 
  8699. the opposite of a stage magician.  He gives you illusion that has the 
  8700. appearance of truth.  I give you truth in the pleasant disguise of 
  8701. illusion."
  8702.                                 --Tom Wingfield
  8703.                                 from "The Glass Menagerie" by T. Williams
  8704.  
  8705. +++++++++++++++++++++++++++
  8706.  
  8707. >From markhanrek@aol.com (MarkHanrek)
  8708. Date: 12 Mar 1994 04:37:00 -0500
  8709. Organization: America Online, Inc. (1-800-827-6364)
  8710.  
  8711. I could be wrong, but I believe your problems has to do with the graphic device
  8712. involved.
  8713.  
  8714. It is a common "programming error" to not restore the graphic device along with
  8715. the GWorld when working with GWorlds. This often happens when mixing the use of
  8716. GetPort/SetPort and GetGWorld/SetGWorld calls.
  8717.  
  8718. The guy who was having the problems using sysbeep was doing something
  8719. incorrect, and it doesn't seem it is the system's responsibility to protect
  8720. against a "programming error".
  8721.  
  8722. The call to SysBeep should have been bracketed with the appropriate
  8723. Get/SetGWorld calls to save and restore the port AND the graphic device.
  8724. Actually, the System crashed because the graphic device for the monitor the
  8725. menubar is on was not the currently active graphic device, I suspect.
  8726.  
  8727. If Apple fixed SysBeep to be self protecting, then a jillion other routines
  8728. would deserve upgrade. So you can see the problem.
  8729.  
  8730. It sounds like I am saying it is your friend's fault, :) but actually it is the
  8731. fault of less-than-adequate information management and accessibility here in
  8732. the future.  We developers have to know too much, and have yet to really use
  8733. our computers to help alleviate this burden in a coordinated way.
  8734.  
  8735. Hope this helps.
  8736.  
  8737. Mark Hanrek
  8738. The Information Workshop
  8739.  
  8740.  
  8741. +++++++++++++++++++++++++++
  8742.  
  8743. >From rmah@panix.com (Robert S. Mah)
  8744. Date: Sat, 12 Mar 1994 10:13:04 -0500
  8745. Organization: One Step Beyond
  8746.  
  8747. markhanrek@aol.com (MarkHanrek) wrote:
  8748.  
  8749. > [...]
  8750. > The call to SysBeep should have been bracketed with the appropriate
  8751. > Get/SetGWorld calls to save and restore the port AND the graphic device.
  8752. >[...]
  8753.  
  8754. I have to disagree.  If SysBeep() normally affected the screen then, yes,
  8755. it should be the application programmers responsibility to set/restore 
  8756. the GWorld, but the menu bar flashing behaviour is a special case inside
  8757. SysBeep() and not part of it's "standard" behaviour.  Thus, it is SysBeep
  8758. that should be setting/restoring the GWorld.
  8759.  
  8760. Of course, given the existance of this bug, the point is mute as the app
  8761. programmer _must_ set/restore the GWorld when calling SysBeep() in order
  8762. to have his stuff work.  C'est la vie.
  8763.  
  8764. Cheers,
  8765. Rob
  8766. ________________________________________________________________________
  8767.  Robert S. Mah              One Step Beyond              rmah@panix.com
  8768.  
  8769. +++++++++++++++++++++++++++
  8770.  
  8771. >From tgreen@ersys.edmonton.ab.ca (Terry Greeniaus)
  8772. Date: Sun, 13 Mar 94 15:42:40 MST
  8773. Organization: Edmonton Remote Systems #2
  8774.  
  8775. rmah@panix.com (Robert S. Mah) writes:
  8776.  
  8777. > markhanrek@aol.com (MarkHanrek) wrote:
  8778. > > [...]
  8779. > > The call to SysBeep should have been bracketed with the appropriate
  8780. > > Get/SetGWorld calls to save and restore the port AND the graphic device.
  8781. > >[...]
  8782. > I have to disagree.  If SysBeep() normally affected the screen then, yes,
  8783. > it should be the application programmers responsibility to set/restore 
  8784. > the GWorld, but the menu bar flashing behaviour is a special case inside
  8785. > SysBeep() and not part of it's "standard" behaviour.  Thus, it is SysBeep
  8786. > that should be setting/restoring the GWorld.
  8787. > Of course, given the existance of this bug, the point is mute as the app
  8788. > programmer _must_ set/restore the GWorld when calling SysBeep() in order
  8789. > to have his stuff work.  C'est la vie.
  8790. > Cheers,
  8791. > Rob
  8792.  
  8793. Well, if you're worried, at the start of your application, you could 
  8794. check the sound level and see if it was zero.  Then set a Boolean 
  8795. variable to true if it is non-zero or false if it is zero.  Then you 
  8796. could write some routine:
  8797. void MySysBeep()
  8798. {
  8799.    if (beepFlag)
  8800.       SysBeep(1);
  8801.    else
  8802.    {
  8803.       // Either save the current GWorld or not beep at all
  8804.       // SysBeep();
  8805.       // Reset the current GWorld
  8806.    }
  8807. }
  8808. and then replace all your calls to SysBeep(1) with MySysBeep(); .
  8809.  
  8810. There ya go! :-)
  8811.  
  8812. "Yes, I have tricks in my pocket, I have things up my sleeve.  But I am 
  8813. the opposite of a stage magician.  He gives you illusion that has the 
  8814. appearance of truth.  I give you truth in the pleasant disguise of 
  8815. illusion."
  8816.                                 --Tom Wingfield
  8817.                                 from "The Glass Menagerie" by T. Williams
  8818.  
  8819. +++++++++++++++++++++++++++
  8820.  
  8821. >From Ralph Martin <Ralph.Martin@cm.cf.ac.uk>
  8822. Date: Mon, 14 Mar 1994 16:22:13 +0000
  8823. Organization: University of Wales College of Cardiff
  8824.  
  8825. In article <T0D6ic3w165w@ersys.edmonton.ab.ca> Terry Greeniaus,
  8826. tgreen@ersys.edmonton.ab.ca writes:
  8827. >Well, if you're worried, at the start of your application, you could 
  8828. >check the sound level and see if it was zero.  Then set a Boolean 
  8829. >variable to true if it is non-zero or false if it is zero.  Then you 
  8830. >could write some routine:
  8831. >void MySysBeep()
  8832. >{
  8833. >   if (beepFlag)
  8834. >      SysBeep(1);
  8835. >   else
  8836. >   {
  8837. >      // Either save the current GWorld or not beep at all
  8838. >      // SysBeep();
  8839. >      // Reset the current GWorld
  8840. >   }
  8841. >}
  8842. >and then replace all your calls to SysBeep(1) with MySysBeep(); .
  8843.  
  8844. And then when the user changes the sound level AFTER your program has
  8845. started?
  8846.  
  8847. Kaboom...
  8848.  
  8849. +++++++++++++++++++++++++++
  8850.  
  8851. >From jwbaxter@olympus.net (John W. Baxter)
  8852. Date: Mon, 14 Mar 1994 09:06:57 -0800
  8853. Organization: Internet for the Olympic Peninsula
  8854.  
  8855. In article <T0D6ic3w165w@ersys.edmonton.ab.ca>, tgreen@ersys.edmonton.ab.ca
  8856. (Terry Greeniaus) wrote:
  8857.  
  8858. Discussion of the need to save/restore GWorlds before SysBeep () omitted
  8859.  
  8860. > Well, if you're worried, at the start of your application, you could 
  8861. > check the sound level and see if it was zero.  Then set a Boolean 
  8862. > variable to true if it is non-zero or false if it is zero.  Then you 
  8863. > could write some routine:  [omitted]
  8864.  
  8865. Not at the start of the application:  the user can change the sound level
  8866. any time your app calls WaitNextEvent ().  YOU wouldn't do that...but the
  8867. whole point of the exercise is to make your code work on other people's
  8868. machines.
  8869. -- 
  8870. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  8871.    jwbaxter@pt.olympus.net
  8872.  
  8873. +++++++++++++++++++++++++++
  8874.  
  8875. >From jim_reekes@quickmail.apple.com (Jim Reekes)
  8876. Date: Tue, 15 Mar 1994 06:29:45 GMT
  8877. Organization: Apple Computer, Inc.
  8878.  
  8879. In article <rmah-120394101304@rmah.dialup.access.net>, rmah@panix.com
  8880. (Robert S. Mah) wrote:
  8881. > markhanrek@aol.com (MarkHanrek) wrote:
  8882. > > [...]
  8883. > > The call to SysBeep should have been bracketed with the appropriate
  8884. > > Get/SetGWorld calls to save and restore the port AND the graphic device.
  8885. > >[...]
  8886. > I have to disagree.  If SysBeep() normally affected the screen then, yes,
  8887. > it should be the application programmers responsibility to set/restore 
  8888. > the GWorld, but the menu bar flashing behaviour is a special case inside
  8889. > SysBeep() and not part of it's "standard" behaviour.  Thus, it is SysBeep
  8890. > that should be setting/restoring the GWorld.
  8891. > Of course, given the existance of this bug, the point is mute as the app
  8892. > programmer _must_ set/restore the GWorld when calling SysBeep() in order
  8893. > to have his stuff work.  C'est la vie.
  8894.  
  8895. Well, I wrote SysBeep and I simply use the following code.
  8896.  
  8897.     FlashMenuBar(0);                                // just flash entire menu bar
  8898.     Delay(kMenuBarDelayTime, &finalTick);
  8899.     FlashMenuBar(0);
  8900.  
  8901. If anyone is NOT saving/restoring the GWorlds, it could be the Menu
  8902. Manager.
  8903.  
  8904. I missed the original message, but this is not a sound manager bug.
  8905.  
  8906. - ---------------------------------------------------------------------
  8907. Jim Reekes, Polterzeitgeist   |     Macintosh Toolbox Engineering
  8908.                               |          Sound Manager Expert
  8909. Apple Computer, Inc.          | "All opinions expressed are mine, and do
  8910. 20525 Mariani Ave. MS 302-3KS |   not necessarily represent those of my
  8911. Cupertino, CA 95014           |       employer, Apple Computer Inc."
  8912.  
  8913. +++++++++++++++++++++++++++
  8914.  
  8915. >From qsi@cnh.wlink.nl (Peter Kocourek)
  8916. Date: Tue, 15 Mar 1994 00:04:37 +0100
  8917. Organization: (none)
  8918.  
  8919. Terry Greeniaus wrote:
  8920.  
  8921.  TG> Well, if you're worried, at the start of your application, 
  8922.  TG> you could check the sound level and see if it was zero. Then 
  8923.  TG> set a Boolean variable to true if it is non-zero or false if 
  8924.  TG> it is zero. Then you could write some routine: 
  8925.  
  8926. No, you should check the sound level every time just before the SysBeep,
  8927. because users can and do change the sound level while your app is running.
  8928.  
  8929.  
  8930. YHS:QSI!
  8931.  
  8932.  
  8933. +++++++++++++++++++++++++++
  8934.  
  8935. >From KLUEV@jonathan.srcc.msu.su
  8936. Date: Wed, 16 Mar 1994 21:02:49 +0300
  8937. Organization: (none)
  8938.  
  8939. In article <763696813.AA01334@cnh.wlink.nl>
  8940. qsi@cnh.wlink.nl (Peter Kocourek) writes:
  8941. >Terry Greeniaus wrote:
  8942. >
  8943. > TG> Well, if you're worried, at the start of your application, 
  8944. > TG> you could check the sound level and see if it was zero. Then 
  8945. > TG> set a Boolean variable to true if it is non-zero or false if 
  8946. > TG> it is zero. Then you could write some routine: 
  8947. >
  8948. >No, you should check the sound level every time just before the SysBeep,
  8949. >because users can and do change the sound level while your app is running.
  8950.  
  8951. (SoundLevel <> 0) doesn't lead to (There will be sound, and not flash).
  8952.  
  8953. Michael Kluev.
  8954.  
  8955. ---------------------------
  8956.  
  8957. >From ViviStar@ACM.org (Jonathan Hess)
  8958. Subject: PPC & 68k UPP problems
  8959. Date: Tue, 1 Mar 1994 00:56:35 GMT
  8960. Organization: ViviStar Consulting
  8961.  
  8962. I've reviewed "Making the Leap to PowerPC" article in develop 16 but
  8963. find its description of Universal ProcPtrs lacking.  Particularly in
  8964. relation to coding source that is compatible with both 68k and PowerPC
  8965. systems.
  8966.  
  8967. Using the code snippets from that article would lead one to believe
  8968. that a global declaration of:
  8969.  
  8970.     RoutineDescriptor gVActionProcRD = BUILD_ROUTINE_DESCRIPTOR(
  8971.         uppControlActionProcInfo, VActionProc);
  8972.  
  8973. with code such as:
  8974.  
  8975.     TrackControl(ctlHit, mouseLoc, (ControlActionUPP) &gVActionProcRD);
  8976.  
  8977. would work under both PowerPC and 68k systems.  While this might work
  8978. with PowerPC systems it clearly will not work with 68k systems --
  8979. VActionProc should be passed in the TrackControl call but taking the
  8980. address of gVActionProcRD can not possibly return that appropriate
  8981. address.
  8982.  
  8983. Anyone have some sample code you could link me or that I could ftp from
  8984. somewhere?
  8985.  
  8986. Thanks,
  8987. Jonathan Hess
  8988. ViviStar Consulting
  8989.  
  8990. +++++++++++++++++++++++++++
  8991.  
  8992. >From zstern@adobe.com (Zalman Stern)
  8993. Date: Tue, 1 Mar 1994 12:25:29 GMT
  8994. Organization: Adobe Systems Incorporated
  8995.  
  8996. Jonathan Hess writes
  8997. > I've reviewed "Making the Leap to PowerPC" article in develop 16 but
  8998. > find its description of Universal ProcPtrs lacking.  Particularly in
  8999. > relation to coding source that is compatible with both 68k and PowerPC
  9000. > systems.
  9001. > Using the code snippets from that article would lead one to believe
  9002. > that a global declaration of:
  9003. >     RoutineDescriptor gVActionProcRD = BUILD_ROUTINE_DESCRIPTOR(
  9004. >         uppControlActionProcInfo, VActionProc);
  9005. > with code such as:
  9006. >     TrackControl(ctlHit, mouseLoc, (ControlActionUPP) &gVActionProcRD);
  9007. > would work under both PowerPC and 68k systems.  While this might work
  9008. > with PowerPC systems it clearly will not work with 68k systems --
  9009. > VActionProc should be passed in the TrackControl call but taking the
  9010. > address of gVActionProcRD can not possibly return that appropriate
  9011. > address.
  9012. > Anyone have some sample code you could link me or that I could ftp from
  9013. > somewhere?
  9014.  
  9015. I'd do something like this. In a header file have the following:
  9016.  
  9017.     #if NEEDROUTINEDESCRIPTORS
  9018.     #define MakeStaticRoutineDesc(name, procinfo) \
  9019.         RoutineDescriptor name##RDS = \
  9020.             BUILD_ROUTINE_DESCRIPTOR(procinfo, name);
  9021.     #else
  9022.     #define MakeStaticRoutineDesc(name, procinfo)
  9023.     #endif
  9024.  
  9025.     #if NEEDROUTINEDESCRIPTORS
  9026.     #define ExternRoutineDescriptor(name) \
  9027.         extern RoutineDescriptor name##RDS;
  9028.     #else
  9029.     #define ExternRoutineDesc(name)
  9030.     #ednif
  9031.  
  9032.     #if NEEDROUTINEDESCRIPTORS
  9033.     #define ConditionalRD(name) (&name##RDS)
  9034.     #else
  9035.     #define ConditionalRD(name) (&name)
  9036.     #endif
  9037.  
  9038. To use this write code like so:
  9039.  
  9040.     pascal void VActionProc(ControlHandle theControl, short partCode)
  9041.     {
  9042.     /* ... */
  9043.     }
  9044.  
  9045.     MakeStaticRoutineDesc(VActionProc, uppControlActionProcInfo)
  9046.  
  9047.     {
  9048.         TrackControl(ctlHit, mouseLoc, (ControlActionUPP)  
  9049. ConditionalRD(VActionProc));
  9050.     }
  9051.  
  9052. The ExternRoutineDesc macro is used in addition to existing extern  
  9053. prototypes in header files. (Ideally, the Apple header files would declare a  
  9054. direct function type for each callback in addition to the function pointer  
  9055. type, but they don't. If they did, ExternRoutineDesc could declare either a  
  9056. function or a RoutineDescriptor structure.)
  9057. --
  9058. Zalman Stern           zalman@adobe.com            (415) 962 3824
  9059. Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900
  9060. "Do right, and risk consequences." Motto of Sam Houston (via Molly Ivins)
  9061.  
  9062. +++++++++++++++++++++++++++
  9063.  
  9064. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  9065. Date: 1 Mar 1994 19:50:23 GMT
  9066. Organization: Royal Institute of Technology, Stockholm, Sweden
  9067.  
  9068. In <CLynyC.G8v@news.direct.net> ViviStar@ACM.org (Jonathan Hess) writes:
  9069.  
  9070. >Using the code snippets from that article would lead one to believe
  9071. >that a global declaration of:
  9072.  
  9073. >    RoutineDescriptor gVActionProcRD = BUILD_ROUTINE_DESCRIPTOR(
  9074. >        uppControlActionProcInfo, VActionProc);
  9075.  
  9076. >would work under both PowerPC and 68k systems.  While this might work
  9077. >with PowerPC systems it clearly will not work with 68k systems --
  9078. >VActionProc should be passed in the TrackControl call but taking the
  9079. >address of gVActionProcRD can not possibly return that appropriate
  9080. >address.
  9081.  
  9082. No, but it might be that under the 68k environment, the routine
  9083. descriptor includes a JMP instruction and the address...
  9084.  
  9085. However, that doesn't appear to be the case; instead, you're
  9086. supposed to call NewControlActionProc which WILL work on both
  9087. kinds of systems.
  9088.  
  9089. Cheers,
  9090.  
  9091.                         / h+
  9092. -- 
  9093.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  9094.  "Don't use the Layer Manager"
  9095.  
  9096. +++++++++++++++++++++++++++
  9097.  
  9098. >From t-gaul@i-link.com (Troy Gaul)
  9099. Date: Wed, 02 Mar 1994 15:29:32 -0600
  9100. Organization: I-Link, Ltd.
  9101.  
  9102. In article <2l069v$mt4@news.kth.se>, d88-jwa@mumrik.nada.kth.se (Jon Wtte)
  9103. wrote:
  9104.  
  9105. > In <CLynyC.G8v@news.direct.net> ViviStar@ACM.org (Jonathan Hess) writes:
  9106. > >Using the code snippets from that article would lead one to believe
  9107. > >that a global declaration of:
  9108. > >    RoutineDescriptor gVActionProcRD = BUILD_ROUTINE_DESCRIPTOR(
  9109. > >        uppControlActionProcInfo, VActionProc);
  9110. > >would work under both PowerPC and 68k systems.  While this might work
  9111. > >with PowerPC systems it clearly will not work with 68k systems --
  9112. > >VActionProc should be passed in the TrackControl call but taking the
  9113. > >address of gVActionProcRD can not possibly return that appropriate
  9114. > >address.
  9115. > No, but it might be that under the 68k environment, the routine
  9116. > descriptor includes a JMP instruction and the address...
  9117. > However, that doesn't appear to be the case; instead, you're
  9118. > supposed to call NewControlActionProc which WILL work on both
  9119. > kinds of systems.
  9120.  
  9121. Yeah, but that creates it in the heap (on PowerPC), not on the stack, which
  9122. can be advantageous at times. Zalman Stern recently posted a technique in
  9123. this thread that allows you to create a static routine descriptor, which it
  9124. looked like, would also work for stack-based RDs. 
  9125.  
  9126. This can be useful for things like DeviceLoop drawing procs that don't have
  9127. to stay around for long to avoid creating and disposing in the heap all of
  9128. the time (in code like a WDEF that, on the 68K, can't have global data -- I
  9129. know that it can on the PowerPC, but I wanted to do it in a portable way
  9130. for if/when RDs are supported on 68K).
  9131.  
  9132. _troy
  9133. //////// //////___Troy Gaul_________________________t-gaul@i-link.com__ //
  9134.   //    //       I-Link, Ltd. ; West Des Moines, Iowa                  //
  9135.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)           //
  9136. //    //////________________________________________________________ //
  9137.  
  9138. ---------------------------
  9139.  
  9140. >From arose@ATHENA.MIT.EDU (Alex Rosen)
  9141. Subject: PPC binaries
  9142. Date: 7 Mar 1994 17:05:23 GMT
  9143. Organization: Massachusetts Institute of Technology
  9144.  
  9145. (1) Since PPC code is in the data fork and 68k code is in the resource
  9146. fork:  Would it be possible to embed a tiny 68k app in my PPC app,
  9147. which just pops up a dialog saying "This program is for PPC computers,
  9148. please install the 68k version" or something like that?
  9149.  
  9150. (2) I assume that CodeWarrior and the Apple SDK don't use any of the
  9151. instructions on the 601 that aren't part of the PPC spec, and that may
  9152. not be around on future chips.  Is this so?  Might these instructions be
  9153. emulated via traps on future chips?
  9154.  
  9155. (3) Has Apple said anything about low memory globals on PPC?  If Apple
  9156. were to release a system with memory protection, it would seem that all
  9157. apps which access LMGs directly would break, and there are plenty of
  9158. these apps around.  But it seems that recompiling for PPC is the perfect
  9159. time for developers to replace this code with system software calls
  9160. (e.g.  GetMBarHeight(), SetMBarHeight() ).  Any word from Apple on this?
  9161.  
  9162. --Alex
  9163.  
  9164.  
  9165. +++++++++++++++++++++++++++
  9166.  
  9167. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  9168. Date: 7 Mar 1994 19:13:25 GMT
  9169. Organization: Royal Institute of Technology, Stockholm, Sweden
  9170.  
  9171. In <2lfmsj$otv@senator-bedfellow.MIT.EDU> arose@ATHENA.MIT.EDU (Alex Rosen) writes:
  9172.  
  9173. >(1) Since PPC code is in the data fork and 68k code is in the resource
  9174. >fork:  Would it be possible to embed a tiny 68k app in my PPC app,
  9175. >which just pops up a dialog saying "This program is for PPC computers,
  9176. >please install the 68k version" or something like that?
  9177.  
  9178. It's not only possible, it's THE LAW, unless you shiip a fat
  9179. binary.
  9180.  
  9181. Now, should you embed a tiny PEF that says "this application is only
  9182. for 68k Macs" ? :-)
  9183.  
  9184. There is sample code on the SDK to show this, though it's really
  9185. as trivial as building:
  9186.  
  9187. void
  9188. main ( void ) {
  9189.     InitGraf ( & qd . thePort ) ;
  9190.     InitFonts ( ) ;
  9191.     InitWindows ( ) ;
  9192.     InitMenus ( ) ;
  9193.     TEInit ( ) ;
  9194.     InitDialogs ( ) ;
  9195.     Alert ( 666 , NULL ) ;
  9196. }
  9197.  
  9198. and pasting your app resources into the native (nee, "optimized")
  9199. app.
  9200.  
  9201. >(2) I assume that CodeWarrior and the Apple SDK don't use any of the
  9202. >instructions on the 601 that aren't part of the PPC spec, and that may
  9203. >not be around on future chips.  Is this so?  Might these instructions be
  9204. >emulated via traps on future chips?
  9205.  
  9206. They're all clean.
  9207.  
  9208. >(3) Has Apple said anything about low memory globals on PPC?  If Apple
  9209.  
  9210. Yeah, they're still there (if you call LMGetCurDeactive() or LMSetXXX)
  9211. However, in the future, the programming model might rid itself of
  9212. lo-mem globals.
  9213.  
  9214. -- 
  9215.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  9216.  
  9217.    There's no problem that can't be solved using brute-force algorithms
  9218.    and a sufficiently fast computer. Ergo, buy more hardware.    (NOT!)
  9219.  
  9220. +++++++++++++++++++++++++++
  9221.  
  9222. >From gdl@stlawrence.maths (Mr_G._Landweber_student_tel_2-73550)
  9223. Date: 07 Mar 1994 23:38:36 GMT
  9224. Organization: (none)
  9225.  
  9226. In article <2lfmsj$otv@senator-bedfellow.MIT.EDU> arose@ATHENA.MIT.EDU (Alex Rosen) writes:
  9227.    (3) Has Apple said anything about low memory globals on PPC?  If Apple
  9228.    were to release a system with memory protection, it would seem that all
  9229.    apps which access LMGs directly would break, and there are plenty of
  9230.    these apps around.  But it seems that recompiling for PPC is the perfect
  9231.    time for developers to replace this code with system software calls
  9232.    (e.g.  GetMBarHeight(), SetMBarHeight() ).  Any word from Apple on this?
  9233.  
  9234. As of the first PowerMacs, all the low memory globals--both documented
  9235. and not--are still there.  However, the universal header files for
  9236. compling PowerPC native (and 680x0) apps no longer define these
  9237. globals.  They use "Get..." and "Set..." macros instead.
  9238.  
  9239. -- Greg "Buttons" Landweber
  9240.    gdl@maths.ox.ac.uk
  9241.  
  9242. +++++++++++++++++++++++++++
  9243.  
  9244. >From DACRXL01.OURX124@tcp30.dx.deere.com (Juan Ingles)
  9245. Date: Tue, 8 Mar 1994 18:16:12 GMT
  9246. Organization: Proteus Ventures, Inc.
  9247.  
  9248. In article <2lfucm$21c@news.kth.se>
  9249. d88-jwa@mumrik.nada.kth.se (Jon Wdtte) writes:
  9250.  
  9251. > void
  9252. > main ( void ) {
  9253. >         InitGraf ( & qd . thePort ) ;
  9254. >         InitFonts ( ) ;
  9255. >         InitWindows ( ) ;
  9256. >         InitMenus ( ) ;
  9257. >         TEInit ( ) ;
  9258. >         InitDialogs ( ) ;
  9259. >         Alert ( 666 , NULL ) ;
  9260. > }
  9261.  
  9262. InitDialogs ( )  should be: InitDialogs ( NULL )
  9263.  
  9264. Tsk... Tsk... Jon, you forgot your resumeProc Ptr.  :)
  9265.  
  9266. >-- 
  9267. > -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  9268. >There's no problem that can't be solved using brute-force algorithms
  9269. >and a sufficiently fast computer. Ergo, buy more hardware.    (NOT!)
  9270.  
  9271. There's no code that can't be optimized. Ergo, spend the rest of your
  9272. life optimizing code, and in the end the code won't take any time to
  9273. run at all. ;)
  9274.  
  9275. Juan Ingles
  9276. <DACRXL01.OURX124@tcp30.dx.deere.com>
  9277. --
  9278. Proteus Ventures, Inc. - Computer Software Consulting and Development
  9279.     1514 Oriole Ave * Waterloo, IA 50701 * (319) 232-0985
  9280.  
  9281. +++++++++++++++++++++++++++
  9282.  
  9283. >From ejf0@ns1.cc.lehigh.edu (EUGENE JOSEPH FOSS)
  9284. Date: Thu, 10 Mar 1994 03:34:55 GMT
  9285. Organization: Lehigh University
  9286.  
  9287. Jon Wdtte (d88-jwa@mumrik.nada.kth.se) wrote:
  9288.  
  9289. : Now, should you embed a tiny PEF that says "this application is only
  9290. : for 68k Macs" ? :-)
  9291.  
  9292. Well, you could if you wanted too, but wouldn't it be a little silly?  I mean,
  9293. since all the PPC Macs include 68k emulation...
  9294.  
  9295.  
  9296. -- 
  9297.      Eugene Foss                                         CS/Math/Cog. Sci.
  9298.      ---------------------------------------------------------------------
  9299.        "Eating meat on Fridays may not be a mortal sin anymore, but I
  9300.         bet there are still some guys in hell doing time on a meat rap."
  9301.  
  9302. +++++++++++++++++++++++++++
  9303.  
  9304. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  9305. Date: 10 Mar 1994 10:30:50 GMT
  9306. Organization: Royal Institute of Technology, Stockholm, Sweden
  9307.  
  9308.  
  9309. >: Now, should you embed a tiny PEF that says "this application is only
  9310. >: for 68k Macs" ? :-)
  9311.  
  9312. >Well, you could if you wanted too, but wouldn't it be a little silly?  I mean,
  9313. >since all the PPC Macs include 68k emulation...
  9314.  
  9315. There WAS a smiley there after all.
  9316.  
  9317. The more relevant reason being there may be a PPC version, and
  9318. users should know they're losing out on performance.
  9319.  
  9320. So, your installer could choose between installing
  9321. 1) Full fat binary
  9322. 2) PPC code with tiny 68k alert
  9323. 3) 68k code with tiny PEF alert
  9324.  
  9325. Cheers,
  9326.  
  9327.                     / h+
  9328. -- 
  9329.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  9330.    The word "politics" is derived from the word "poly", meaning
  9331.    "many", and the word "ticks", meaning "blood sucking parasites".
  9332.                      -- Larry Hardiman
  9333.  
  9334. +++++++++++++++++++++++++++
  9335.  
  9336. >From zstern@adobe.com (Zalman Stern)
  9337. Date: Thu, 10 Mar 1994 18:59:10 GMT
  9338. Organization: Adobe Systems Incorporated
  9339.  
  9340. Jon W tte writes
  9341. > >: Now, should you embed a tiny PEF that says "this application is only
  9342. > >: for 68k Macs" ? :-)
  9343. > >Well, you could if you wanted too, but wouldn't it be a little silly?  I  
  9344. mean,
  9345. > >since all the PPC Macs include 68k emulation...
  9346. > There WAS a smiley there after all.
  9347. > The more relevant reason being there may be a PPC version, and
  9348. > users should know they're losing out on performance.
  9349. > So, your installer could choose between installing
  9350. > 1) Full fat binary
  9351. > 2) PPC code with tiny 68k alert
  9352. > 3) 68k code with tiny PEF alert
  9353.  
  9354. Its just as easy to gestalt for the PowerPC in your 68k code. However, there  
  9355. is an interesting question there about how one should differentiate between  
  9356. running PowerPC and 68K code. A good solution is to put something in the  
  9357. splash screen. (At least for apps with heavy weight splash screens.)  
  9358. Likewise, this would appear in the about box. The question is what should be  
  9359. there?
  9360. --
  9361. Zalman Stern           zalman@adobe.com            (415) 962 3824
  9362. Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900
  9363. "Do right, and risk consequences." Motto of Sam Houston (via Molly Ivins)
  9364.  
  9365. ---------------------------
  9366.  
  9367. >From gewekean@studentg.msu.edu (Andrew Geweke)
  9368. Subject: Passing data through to completion procs?
  9369. Date: Wed, 16 Mar 1994 22:06:40 -0500
  9370. Organization: Michigan State University
  9371.  
  9372. What I'm doing is writing an interface library to MacTCP; I want it to be 
  9373. simple. All routines are async, so I just want to have the caller pass in a 
  9374. simple structure pointer; a field in the struct gets changed when the call 
  9375. completes. I want to do this rather than having the user ravage through large 
  9376. ParamBlocks and so forth for simplicity and so on.
  9377.  
  9378. My question is this: How can I get the Device Manager to pass four bytes to a 
  9379. completion routine that I pass in when I make the call?
  9380.  
  9381. Basically, I'm having trouble getting a pointer to the structure through to 
  9382. the completion routine. Is there any place I can stash this? I'm looking 
  9383. through the ParamBlock structure right now, and everything's used or "not 
  9384. used" (which, as we all know, means reserved -- I don't want to break rules 
  9385. here).
  9386.  
  9387. Here are my ideas so far:
  9388.  
  9389. (1) Set the user up with a pointer to the ioResult field. Disadvantage: I 
  9390. want to deallocate the parameter-block's memory as soon as the call 
  9391. completes. This would require the user to do this.
  9392.  
  9393. (2) Create a linked list of all outstanding calls with pointers to their 
  9394. parameter blocks. This is a roundabout method, though it should work; 
  9395. however, I'd rather not.
  9396.  
  9397. Basically, I'm converting async calls from the beasts that they are into 
  9398. simple ones; you pass in a struct with only the specific information that 
  9399. gets a flag set when it's done. Any ideas?
  9400.  
  9401.  
  9402.  
  9403.  
  9404.  
  9405. +++++++++++++++++++++++++++
  9406.  
  9407. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  9408. Date: Thu, 17 Mar 1994 01:37:49 -0600
  9409. Organization: University of Illinois at Urbana-Champaign
  9410.  
  9411. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  9412. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  9413.  
  9414. >What I'm doing is writing an interface library to MacTCP;
  9415. >
  9416. >My question is this: How can I get the Device Manager to pass four bytes to a 
  9417. >completion routine that I pass in when I make the call?
  9418. >
  9419. >Basically, I'm having trouble getting a pointer to the structure through to 
  9420. >the completion routine. Is there any place I can stash this?
  9421.  
  9422. Since you're using MacTCP, you're in luck. Every MacTCP param block has a
  9423. userDataPtr field, which is exactly where you can store any pointer you
  9424. like.
  9425.  
  9426. Even if this field weren't there, you can do the same thing. Just make
  9427. your own personal parameter block which contains everything the real
  9428. parameter block does, plus one pointer field tacked onto the end. The
  9429. Device Manager and driver are only going to use the fields they specify,
  9430. so this is perfectly safe. (How could it not be? It would be quite ugly if
  9431. a device driver decided to use some memory past the end of its parameter
  9432. block!)
  9433.  
  9434. pr
  9435. -- 
  9436. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  9437. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  9438. System manager - Cognitive Science Group, Beckman Institute, UIUC
  9439. Internet: resnick@cogsci.uiuc.edu
  9440.  
  9441. +++++++++++++++++++++++++++
  9442.  
  9443. >From zben@ni.umd.edu (Charles B. Cranston)
  9444. Date: 18 Mar 1994 00:50:47 GMT
  9445. Organization: UMCP Network Infrastructures
  9446.  
  9447. In article <9403162206.AA40375@geweke.ppp.msu.edu>,
  9448. gewekean@studentg.msu.edu (Andrew Geweke) wrote:
  9449.  
  9450. > What I'm doing is writing an interface library to MacTCP; I want it to be 
  9451. > simple. All routines are async, so I just want to have the caller pass in a 
  9452. > simple structure pointer; a field in the struct gets changed when the call 
  9453. > completes. I want to do this rather than having the user ravage through large 
  9454. > ParamBlocks and so forth for simplicity and so on.
  9455.  
  9456. > My question is this: How can I get the Device Manager to pass four bytes to a 
  9457. > completion routine that I pass in when I make the call?
  9458.  
  9459. Another approach would be to erect a "trampoline" somewhere.  This would
  9460. be 8 bytes consisting of a JSr to the real handler followed by the four
  9461. data bytes.  The real handler immediately does a Move.L (A7)+,A0 and then
  9462. A0 points to the four data bytes, and the stacktop is now the real final
  9463. return address.
  9464.  
  9465. For MacTCP the UserData approach or the embed-IOPB-in-larger-known-block
  9466. approaches would both work.  I am thinking about using this trampoline
  9467. technique for EtherNet "Protocol Handlers" where the IOPB is not passed
  9468. to the callback routine.
  9469.  
  9470. The cost, of course, is allocating and freeing the memory space for
  9471. the trampoline, especially in the asynchronous environment you are
  9472. talking about.
  9473.  
  9474. ---------------------------
  9475.  
  9476. >From Dmitry Boldyrev <dmitry@atlas.chem.utah.edu>
  9477. Subject: Password editing item.. Tricky?
  9478. Date: 23 Feb 1994 02:22:25 GMT
  9479. Organization: University of Utah
  9480.  
  9481. Hi All.
  9482. I am wounding if anyone has implemented so called scrambled editing item
  9483. I looked at the ftp.apple.com and found a couple of codes which would do
  9484. it
  9485. but, I don't think it is the best way to do.. 
  9486. I am gonna use it for my FTP client. so, when I type my password "hello"
  9487. it should actually print on the display "!!!!!". and the buffer should
  9488. have "hello" so that I can then use it.
  9489. I am thinking that there should be a way of writing a small routine and
  9490. hook the interruption and everything what supposed to be displayed will
  9491. be taken care by that routine.. 
  9492. Any ideas how it can be implemented? (Pascal, C iz ok)
  9493. Thank you very much!
  9494.  
  9495. ......................................................................
  9496. . Dmitry Boldyrev                     . (_) (_)                      .
  9497. . University of Utah, Salt Lake City  .  |---| urricane, inc         .
  9498. . Utah, USA                           . (_) (_)                      .
  9499. . Home Tel: (801) 581-1298, Office Tel: (801) 581-5465               . 
  9500. ......................................................................
  9501.  
  9502. +++++++++++++++++++++++++++
  9503.  
  9504. >From infosafe@panix.com (Tom Lipscomb)
  9505. Date: 22 Feb 1994 23:57:18 -0500
  9506. Organization: PANIX Public Access Internet and Unix, NYC
  9507.  
  9508. The easiest solution I came up with was to make my own font, which had
  9509. one character (a diamond) for all of the letters.  Use this font for
  9510. the edit text that they are typing the password in.
  9511.  
  9512. Cheers,
  9513. Bradford Smith
  9514.  
  9515.  
  9516.  
  9517. +++++++++++++++++++++++++++
  9518.  
  9519. >From Jonathan D Baumgartner <Jonathan.D.Baumgartner@unh.edu>
  9520. Date: 23 Feb 1994 15:11:37 GMT
  9521. Organization: Computing & Information Services, University of New Hampshire
  9522.  
  9523. In article <2kenne$rku@panix2.panix.com> Tom Lipscomb, infosafe@panix.com
  9524. writes:
  9525. >The easiest solution I came up with was to make my own font, which had
  9526. >one character (a diamond) for all of the letters.  Use this font for
  9527. >the edit text that they are typing the password in.
  9528.  
  9529. That's an interesting solution; wish I'd thought of that earlier :-)
  9530.  
  9531. I did this by creating a dialog filter which I pass to ModalDialog.  When
  9532. a keyDown or autoKey event occurs, it takes the character, appends it to
  9533. a dummy string, and then changes the EventRecord's message to a bullet. 
  9534. This way you end up with a string that holds the password, but the user
  9535. only sees bullets on-screen.
  9536.  
  9537. I found a really excellent example (but HUGE, and it does a lot of other
  9538. stuff besides) in the source for John Norstad's NewsWatcher.
  9539.  
  9540. jon
  9541. --
  9542. Jonathan D. Baumgartner        Jonathan.D.Baumgartner@unh.edu 
  9543. Computing & Information Services, University of New Hampshire            
  9544.  
  9545.            "It's just a matter of opinion." -- Primus
  9546.  
  9547. +++++++++++++++++++++++++++
  9548.  
  9549. >From Scott_Gruby@hmc.edu (Scott Gruby)
  9550. Date: Wed, 23 Feb 1994 07:34:32 -0800
  9551. Organization: Harvey Mudd College, Claremont CA
  9552.  
  9553. In article <2kfrn9$d4v@mozz.unh.edu>, Jonathan D Baumgartner
  9554. <Jonathan.D.Baumgartner@unh.edu> wrote:
  9555.  
  9556. > I did this by creating a dialog filter which I pass to ModalDialog.  When
  9557. > a keyDown or autoKey event occurs, it takes the character, appends it to
  9558. > a dummy string, and then changes the EventRecord's message to a bullet. 
  9559. > This way you end up with a string that holds the password, but the user
  9560. > only sees bullets on-screen.
  9561. > I found a really excellent example (but HUGE, and it does a lot of other
  9562. > stuff besides) in the source for John Norstad's NewsWatcher.
  9563.  
  9564. There's a snippet on ftp.apple.com that shows 3 ways of doing this; 1 is
  9565. with a different font, 1 is as you described and I forgot what the 3rd one
  9566. was. Anyway there is an example that is really SMALL and very easy to
  9567. understand.
  9568. -- 
  9569. Scott Allen Gruby                         (Scott_Gruby@hmc.edu)
  9570. Macintosh Student System Manager
  9571. Academic Computing, Harvey Mudd College
  9572. Claremont, CA 91711
  9573.  
  9574. +++++++++++++++++++++++++++
  9575.  
  9576. >From mwalker@netcom.com (Mel Walker)
  9577. Date: Wed, 23 Feb 1994 17:01:30 GMT
  9578. Organization: Committee to Elect Dan Quayle Lord of the Cosmos
  9579.  
  9580. Dmitry Boldyrev (dmitry@atlas.chem.utah.edu) wrote:
  9581. : Hi All.
  9582. : I am wounding if anyone has implemented so called scrambled editing item
  9583. : I looked at the ftp.apple.com and found a couple of codes which would do
  9584. : it
  9585. : but, I don't think it is the best way to do.. 
  9586. : I am gonna use it for my FTP client. so, when I type my password "hello"
  9587. : it should actually print on the display "!!!!!". and the buffer should
  9588. : have "hello" so that I can then use it.
  9589. : I am thinking that there should be a way of writing a small routine and
  9590. : hook the interruption and everything what supposed to be displayed will
  9591. : be taken care by that routine.. 
  9592. : Any ideas how it can be implemented? (Pascal, C iz ok)
  9593. : Thank you very much!
  9594.  
  9595. My prefered way is to have two text boxes for the password, one of which 
  9596. is outside of the dialog (i.e., it's invisible). Use a filter routine in 
  9597. your modal dialog that puts keystrokes into the invisible field, and puts 
  9598. a ! into the visible field. Backspaces, selections, and the like affect 
  9599. both fields.
  9600. I may be explaining this badly. Send me email if you want more help.
  9601. -- 
  9602. Mel Walker                                   mwalker@netcom.com
  9603. "Natural exuberance is one of those qualities that makes us tigers so 
  9604. darn endearing!" -- Hobbes
  9605.  
  9606. +++++++++++++++++++++++++++
  9607.  
  9608. >From Dmitry Boldyrev <dmitry@atlas.chem.utah.edu>
  9609. Date: 23 Feb 1994 18:27:43 GMT
  9610. Organization: University of Utah
  9611.  
  9612. In article <2kfrn9$d4v@mozz.unh.edu> Jonathan D Baumgartner,
  9613. Jonathan.D.Baumgartner@unh.edu writes:
  9614. >That's an interesting solution; wish I'd thought of that earlier :-)
  9615. >
  9616. >I did this by creating a dialog filter which I pass to ModalDialog.  When
  9617. >a keyDown or autoKey event occurs, it takes the character, appends it to
  9618. >a dummy string, and then changes the EventRecord's message to a bullet. 
  9619. >This way you end up with a string that holds the password, but the user
  9620. >only sees bullets on-screen.
  9621. >
  9622. >I found a really excellent example (but HUGE, and it does a lot of other
  9623. >stuff besides) in the source for John Norstad's NewsWatcher.
  9624.  
  9625. Yeah, I know about the way of making such a font.. looks like it is the
  9626. only
  9627. solution I can think of. I've done the same way as Johnatan described, but
  9628. there iz a little problem. Suppose you want to show a password when you
  9629. create
  9630. a window.. How would you do it?
  9631. like I want !!!!!! to be shown when the dialog appears.. they way you
  9632. suggest
  9633. it it won't work.
  9634. Thanks for the replies, guys!
  9635.  
  9636. +++++++++++++++++++++++++++
  9637.  
  9638. >From Dmitry Boldyrev <dmitry@atlas.chem.utah.edu>
  9639. Date: 23 Feb 1994 18:28:57 GMT
  9640. Organization: University of Utah
  9641.  
  9642. In article <2kenne$rku@panix2.panix.com> Tom Lipscomb, infosafe@panix.com
  9643. writes:
  9644. >The easiest solution I came up with was to make my own font, which had
  9645. >one character (a diamond) for all of the letters.  Use this font for
  9646. >the edit text that they are typing the password in.
  9647. >
  9648. >Cheers,
  9649. >Bradford Smith
  9650.  
  9651. A little problem too.
  9652. How would you do it if you have two editing items?
  9653. When you change the font, it will make all TE items the same font.. ?
  9654. Thanks
  9655.  
  9656. Dmitry.
  9657.  
  9658. +++++++++++++++++++++++++++
  9659.  
  9660. >From hrafal@copernicus.bbn.com (Howie Rafal)
  9661. Date: 23 Feb 1994 19:24:30 GMT
  9662. Organization: BBN, Inc
  9663.  
  9664. In article <2kenne$rku@panix2.panix.com>, infosafe@panix.com (Tom Lipscomb)
  9665. wrote:
  9666. > The easiest solution I came up with was to make my own font, which had
  9667. > one character (a diamond) for all of the letters.  Use this font for
  9668. > the edit text that they are typing the password in.
  9669. > Cheers,
  9670. > Bradford Smith
  9671.  
  9672. Be careful to not allow copy in the item, because it could be pasted
  9673. somewhere else and the font changed.
  9674.  
  9675. I use a TCL class called CPasswordText that I could forward to you if you
  9676. want.  It actually uses a bullet character and maintains a text item
  9677. offscreen.  I also have classes for password dialogs which handle turning
  9678. on and off the OK button based on the login fields having values entered.
  9679.  
  9680.  
  9681. HOWIE.
  9682.  
  9683. +++++++++++++++++++++++++++
  9684.  
  9685. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  9686. Date: 24 Feb 1994 10:39:33 +0800
  9687. Organization: NCRPDA, Curtin University
  9688.  
  9689. infosafe@panix.com (Tom Lipscomb) writes:
  9690.  
  9691. >The easiest solution I came up with was to make my own font, which had
  9692. >one character (a diamond) for all of the letters.  Use this font for
  9693. >the edit text that they are typing the password in.
  9694.  
  9695. Don't spaces show up though?  Last time I tried this, the spaces showed up
  9696. even if your font didn't define the space character or even if you did,
  9697. it would show up as a space.  This was a long time back, maybe its changed?
  9698.    Peter.
  9699. -- 
  9700. _______________________________________________________________________
  9701. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  9702.  
  9703. +++++++++++++++++++++++++++
  9704.  
  9705. >From Jonathan D Baumgartner <Jonathan.D.Baumgartner@unh.edu>
  9706. Date: 24 Feb 1994 18:24:47 GMT
  9707. Organization: Computing & Information Services, University of New Hampshire
  9708.  
  9709. In article <2kg76v$bei@u.cc.utah.edu> Dmitry Boldyrev,
  9710. dmitry@atlas.chem.utah.edu writes:
  9711. >Yeah, I know about the way of making such a font.. looks like it is the
  9712. >only
  9713. >solution I can think of. I've done the same way as Johnatan described,
  9714. but
  9715. >there iz a little problem. Suppose you want to show a password when you
  9716. >create
  9717. >a window.. How would you do it?
  9718. >like I want !!!!!! to be shown when the dialog appears.. they way you
  9719. >suggest
  9720. >it it won't work.
  9721.  
  9722. Um, you mean you want the password to show up as a series of !s before
  9723. anything is typed?  Like a default password or something?
  9724.  
  9725. Assuming that's what you mean, I just use GetDItem() and SetIText().  Get
  9726. a handle to the edit text field with GetDItem(), and then use SetIText()
  9727. to change the text to an appropriate number of !s.
  9728.  
  9729. (Appropriate number in this case would be the length of the actual
  9730. password.)
  9731.  
  9732. jon
  9733. --
  9734. Jonathan D. Baumgartner        Jonathan.D.Baumgartner@unh.edu 
  9735. Computing & Information Services, University of New Hampshire            
  9736.  
  9737.            "It's just a matter of opinion." -- Primus
  9738.  
  9739. +++++++++++++++++++++++++++
  9740.  
  9741. >From f8dy@access.netaxs.com (Mark Pilgrim)
  9742. Date: 24 Feb 1994 22:22:38 GMT
  9743. Organization: Net Access - Philadelphia's Internet Connection
  9744.  
  9745. Peter N Lewis (peter@ncrpda.curtin.edu.au) wrote:
  9746. : infosafe@panix.com (Tom Lipscomb) writes:
  9747.  
  9748. : >The easiest solution I came up with was to make my own font, which had
  9749. : >one character (a diamond) for all of the letters.  Use this font for
  9750. : >the edit text that they are typing the password in.
  9751.  
  9752. : Don't spaces show up though?  Last time I tried this, the spaces showed up
  9753. : even if your font didn't define the space character or even if you did,
  9754. : it would show up as a space.  This was a long time back, maybe its changed?
  9755. :    Peter.
  9756.  
  9757. Peter, you are correct.  Tom, the one (potential) problem with your method
  9758. is that one could copy the password to the clipboard and paste it somewhere
  9759. else in a different font -- especially a problem if the dialog box is
  9760. coming up with a password already there (in diamonds or bullets or bangs).
  9761.  
  9762. After much agonizing over this issue, I finally went with the "editable
  9763. text item outside the frame of the dialog" approach.  I did _not_ have a
  9764. second text item that mirrored the first one with bullets(/diamonds/bangs);
  9765. instead, I displayed a character count (similar to Compact Pro) which
  9766. updated with every keypress to the length of the editable text box.  (This
  9767. covers the situation of a user pasting in a password and/or cutting part of
  9768. it out, where the length of the password may change by more than +-1.)  And
  9769. I had checkboxes to hide/show the character count and hide/show the password
  9770. itself -- both of which should be saved a preferences and restored the next
  9771. time the user has to enter a password.
  9772.  
  9773. Of course, this doesn't solve the problem of having a password there when
  9774. the dialog box comes up, since you could just check "show password" and see
  9775. it. (:  But having a password there is an inherent security weakness.  I
  9776. have discovered the password to an Appletalk server in the Chooser because
  9777. the password was "there" but expressed in bullet characters (i.e. copying
  9778. and pasting just yields bullets).  Replacing one character at a time and
  9779. seeing if it was still the right password gave me the password in less than
  9780. a minute.  (Of course, I assumed standard character frequencies and the
  9781. password happened to be "tres", but it's still a bad assumption that just
  9782. because the dialog box contains bullet characters that the underlying
  9783. password is safe.)
  9784.  
  9785. --
  9786. Mark Pilgrim | f8dy@netaxs.com | Please do not worry the philosophers.
  9787. "I can't say enough about the importance of brevity."
  9788.  
  9789. +++++++++++++++++++++++++++
  9790.  
  9791. >From ez015670@hamlet.ucdavis.edu ()
  9792. Date: Fri, 25 Feb 1994 00:33:49 GMT
  9793. Organization: University of California, Davis
  9794.  
  9795. Mark Pilgrim (f8dy@access.netaxs.com) wrote:
  9796. : Peter N Lewis (peter@ncrpda.curtin.edu.au) wrote:
  9797. : : Don't spaces show up though?  Last time I tried this, the spaces showed up
  9798. : : even if your font didn't define the space character or even if you did,
  9799. : : it would show up as a space.  This was a long time back, maybe its changed?
  9800. : :    Peter.
  9801.  
  9802. : Peter, you are correct.  Tom, the one (potential) problem with your method
  9803.  
  9804. Another potential security problem that has not been addressed is the picking
  9805. up of the password at a much lower level.  I have made a program that
  9806. prints all the characters pressed to a file including passwords.  Maybe
  9807. through a jGNE filter one could remove the characters before other inits
  9808. can get a hold of them.
  9809.  
  9810. Bret Olmsted
  9811. olmsted@cs.ucdavis.edu
  9812.  
  9813.  
  9814.  
  9815. +++++++++++++++++++++++++++
  9816.  
  9817. >From scott.m.silver@dartmouth.edu (Scott M. Silver)
  9818. Date: 25 Feb 1994 03:28:06 GMT
  9819. Organization: Dartmouth College - Hanover, NH
  9820.  
  9821. In article <CLr88E.C7F@ucdavis.edu>
  9822. ez015670@hamlet.ucdavis.edu () writes:
  9823.  
  9824. > Another potential security problem that has not been addressed is the picking
  9825. > up of the password at a much lower level.  I have made a program that
  9826. > prints all the characters pressed to a file including passwords.  Maybe
  9827. > through a jGNE filter one could remove the characters before other inits
  9828. > can get a hold of them.
  9829.  
  9830. This sort of seems to be one of those things where if "the person can
  9831. get to the computer-locally, then your data is not safe".  (Unless it's
  9832. encrypted).  Anyone can patch every single trap, write a jGNE filter,
  9833. etc and figure out what your password is (or get a program to watch you
  9834. type it in).  Hell, they could video tape you typing it in.
  9835.  
  9836. Scott
  9837.  
  9838. ____________________________________________________________________
  9839. Scott Silver            Dartmouth College                Hanover, NH
  9840.  
  9841. +++++++++++++++++++++++++++
  9842.  
  9843. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  9844. Date: 24 Feb 1994 10:47:58 GMT
  9845. Organization: Royal Institute of Technology, Stockholm, Sweden
  9846.  
  9847. In <2kfrn9$d4v@mozz.unh.edu> Jonathan D Baumgartner <Jonathan.D.Baumgartner@unh.edu> writes:
  9848.  
  9849. >>The easiest solution I came up with was to make my own font, which had
  9850. >>one character (a diamond) for all of the letters.  Use this font for
  9851. >>the edit text that they are typing the password in.
  9852.  
  9853. >That's an interesting solution; wish I'd thought of that earlier :-)
  9854.  
  9855. Because fonts in applications are a bad idea (for a number
  9856. of Font Manager reasons)
  9857.  
  9858. What I do is I patch the QuickDraw text measurement and text
  9859. drawing bottlenecks to measure a string of bullets instead of
  9860. the real string.
  9861.  
  9862. Cheers,
  9863.  
  9864.                     / h+
  9865. -- 
  9866.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  9867.     Not speaking for the Microsoft Corporation.
  9868.  
  9869. +++++++++++++++++++++++++++
  9870.  
  9871. >From infosafe@panix.com (Tom Lipscomb)
  9872. Date: 25 Feb 1994 01:11:10 -0500
  9873. Organization: PANIX Public Access Internet and Unix, NYC
  9874.  
  9875. In article <2kg799$bei@u.cc.utah.edu>,
  9876. Dmitry Boldyrev  <dmitry@atlas.chem.utah.edu> wrote:
  9877. >In article <2kenne$rku@panix2.panix.com> Tom Lipscomb, infosafe@panix.com
  9878. >writes:
  9879. >>The easiest solution I came up with was to make my own font, which had
  9880. >>one character (a diamond) for all of the letters.  Use this font for
  9881. >>the edit text that they are typing the password in.
  9882. >>
  9883. >>Cheers,
  9884. >>Bradford Smith
  9885. >
  9886. >A little problem too.
  9887. >How would you do it if you have two editing items?
  9888. >When you change the font, it will make all TE items the same font.. ?
  9889. >Thanks
  9890. >
  9891. >Dmitry.
  9892.  
  9893. For static text I made them User Items that drew the appropriate text in
  9894. Chicago.  For the field where they typed the name, I set the font to 
  9895. be Geneva, or something.  For the field where I put the password, I set the
  9896. font to be .pwd font (or whatever it was).  It's not the most secure 
  9897. method; as lots of people pointed out, you can copy it to another field
  9898. and see what the text is.
  9899.  
  9900. For me this was not a concern, though.  The person typed in the name and
  9901. pwd, it was accepted or rejected, and they moved on.  The only person who
  9902. could have copied the text to another app was the person who just typed 
  9903. it in -- not a security risk.
  9904.  
  9905. As for writing an init to catch the keystrokes -- anyone know how to stop it?
  9906.  
  9907. Cheers,
  9908. Bradford
  9909.  
  9910. +++++++++++++++++++++++++++
  9911.  
  9912. >From Jim.Matthews@dartmouth.edu (Jim Matthews)
  9913. Date: 25 Feb 1994 14:11:52 GMT
  9914. Organization: Dartmouth College
  9915.  
  9916. In article <2ki0ku$pir@news.kth.se>, d88-jwa@mumrik.nada.kth.se (Jon Wtte)
  9917. wrote:
  9918.  
  9919. > What I do is I patch the QuickDraw text measurement and text
  9920. > drawing bottlenecks to measure a string of bullets instead of
  9921. > the real string.
  9922.  
  9923. I tried that once but found it difficult to tell when StdText and StdMeas
  9924. were being called for the password, as opposed to anything else in the
  9925. dialog.  Is there a sure-fire way to do this?
  9926.  
  9927. Jim Matthews
  9928. Dartmouth Software Development
  9929.  
  9930. +++++++++++++++++++++++++++
  9931.  
  9932. >From Mark.R.Valence@dartmouth.edu (kurash@dartmouth.edu)
  9933. Date: 25 Feb 1994 18:37:55 GMT
  9934. Organization: Dartmouth College, Hanover, NH
  9935.  
  9936. In article <Jim.Matthews-250294091049@ishmael.dartmouth.edu>
  9937. Jim.Matthews@dartmouth.edu (Jim Matthews) writes:
  9938. > In article <2ki0ku$pir@news.kth.se>, d88-jwa@mumrik.nada.kth.se (Jon Wtte)
  9939. > wrote:
  9940. > > What I do is I patch the QuickDraw text measurement and text
  9941. > > drawing bottlenecks to measure a string of bullets instead of
  9942. > > the real string.
  9943. > I tried that once but found it difficult to tell when StdText and StdMeas
  9944. > were being called for the password, as opposed to anything else in the
  9945. > dialog.  Is there a sure-fire way to do this?
  9946.  
  9947. I tried patching the screen driver and watched for the proper bit
  9948. pattern of the real password characters, then replaced the bits with a
  9949. bullet pattern.  I never did get that to work... ;-)
  9950.  
  9951. There are two main weaknesses of using a "bullet font" (or the StdText
  9952. method) to hide a password in a dialog box edittext item.  First,
  9953. anyone can grab the password by choosing Copy from the Edit menu (under
  9954. Sys7).  This is not an issue unless the user has a habit of typing a
  9955. password and leaving the dialog on the screen.
  9956.  
  9957. The more important drawback is that it is difficult to handle two-byte
  9958. character sets.  Because the font would be script specific, extra
  9959. "bullet" characters would be emitted.
  9960.  
  9961. The source below solves the password-in-a-dialog problem by filtering
  9962. the event stream and modifying the proper key-down events.  It keeps a
  9963. private copy of the password. Although this implementation does not
  9964. support multibyte character sets, it could be modified to do so easily
  9965. (and in fact I am going to have to do this eventually myself).
  9966.  
  9967. The PassFilter routine uses another dialog filter routine that handles
  9968. the non-password related stuff (OK and Cancel keyboard equivalents,
  9969. etc.)  You need to write this y'self.
  9970.  
  9971. On a side note, I always liked the way the original StuffIt (I think)
  9972. handled the archive password.  It just changed the font size to
  9973. something like 2, and used PICTs for the "static text" (there were no
  9974. non-password edit text items).  Cute.
  9975.  
  9976. Mark.
  9977.  
  9978. - --------------------------------------------------------------------
  9979. "On the Internet, nobody knows you're a dog."   Ice Peak Form Mice Elf
  9980.                     -- cartoon in New Yorker
  9981.  
  9982.  
  9983. /*
  9984.  *    (c)1994 Mark Valence
  9985.  *
  9986.  *    Permission to use and alter this source is
  9987.  *    granted, provided that you do not transmit
  9988.  *    the resulting password in cleartext over a
  9989.  *    network (unless required by the protocol).
  9990.  */
  9991.  
  9992. #include <types.h>
  9993. #include <memory.h>
  9994. #include <events.h>
  9995. #include <windows.h>
  9996. #include <dialogs.h>
  9997. #include <controls.h>
  9998.  
  9999. /*
  10000.  * example of usage:
  10001.  *
  10002.  *    PassData pdata;
  10003.  *    Str255 mypass;
  10004.  *
  10005.  *    ...
  10006.  *    pdata.passitem = MY_PASSWORD_ITEM;
  10007.  *    pdata.passmax = 8;
  10008.  *    pdata.bullet = '*';
  10009.  *    pdata.password = mypass;
  10010.  *    *mypass = 0;
  10011.  *    SetWRefCon(dialog, (long)&pdata);
  10012.  *    ModalDialog((ProcPtr)PassFilter, &item);
  10013.  *    ...
  10014.  */
  10015.  
  10016. /*
  10017.  * a pointer to this structure is placed in the refCon
  10018.  * of the dialog box that contains the password item.
  10019.  * the buffer that 'password' points to must be at
  10020.  * least 'passmax'+1 bytes (one byte for the length),
  10021.  * and must initially be zero-length.
  10022.  */
  10023. typedef struct t_passdata {
  10024.     short passitem;        /* dialog item number of password text */
  10025.     short passmax;        /* maximum length of password */
  10026.     char bullet;        /* special character to use */
  10027.     StringPtr password;    /* pointer to a buffer for the real password */
  10028. } PassData;
  10029.  
  10030.  
  10031. /*
  10032.  * this routine must be linked in from another source
  10033.  * it is responsible for handling special keystrokes
  10034.  * such as <return>, <enter>, <escape>, Cmd-., etc.
  10035.  * UpdtFilter also handles window update events for
  10036.  * application windows and the Edit menu command keys.
  10037.  */
  10038. pascal Boolean UpdtFilter (DialogPtr dialog, EventRecord *event, short
  10039. *item);
  10040.  
  10041. /*
  10042.  * these routines are included below for completeness
  10043.  */
  10044. char *pstrdel (unsigned char *s, int ix, int len);
  10045. char *pstrins (unsigned char *s, unsigned char c, int ix);
  10046.  
  10047.  
  10048. pascal Boolean
  10049. PassFilter (DialogPtr dialog, EventRecord *event, short *item)
  10050. {
  10051.     PassData *passp;
  10052.     short selStart, selEnd;
  10053.     unsigned char ch;
  10054.     Str255 hold;
  10055.     short kind;
  10056.     Handle h;
  10057.     Rect r;
  10058.  
  10059.     /* take care of return, enter, cmd-.,
  10060.      * escape, updates, Edit menu, etc.
  10061.      */
  10062.     if (UpdtFilter(dialog, event, item))
  10063.         return(true);
  10064.  
  10065.     passp = (PassData *)GetWRefCon(dialog);
  10066.     if (!(event->modifiers & cmdKey)
  10067.         && (event->what == keyDown || event->what == autoKey)
  10068.         && (((DialogPeek)dialog)->editField == (passp->passitem - 1)))
  10069.     {
  10070.         ch = event->message & charCodeMask;
  10071.         selStart = (**(((DialogPeek)dialog)->textH)).selStart;
  10072.         selEnd = (**(((DialogPeek)dialog)->textH)).selEnd;
  10073.  
  10074.         switch (ch) {
  10075.         case 0x08:    /* backspace */
  10076.             if (selEnd != selStart)
  10077.                 pstrdel(passp->password, selStart + 1, selEnd - selStart);
  10078.             else if (selStart > 0)
  10079.                 pstrdel(passp->password, selStart, 1);
  10080.             break;
  10081.  
  10082.         case 0x09:    /* tab */
  10083.         case 0x1C:    /* left arrow */
  10084.         case 0x1D:    /* right arrow */
  10085.         case 0x1E:    /* up arrow */
  10086.         case 0x1F:    /* down arrow */
  10087.             break;
  10088.  
  10089.         default:
  10090.             BlockMove(passp->password, hold, sizeof(hold));
  10091.             pstrdel(hold, selStart + 1, selEnd - selStart);
  10092.             pstrins(hold, ch, selStart + 1);
  10093.             if (*hold > passp->passmax) {
  10094.                 event->what = nullEvent;
  10095.                 SysBeep(1);
  10096.             } else {
  10097.                 BlockMove(hold, passp->password, *hold + 1);
  10098.                 event->message &= 0xFFFFFF00;
  10099.                 event->message |= passp->bullet;
  10100.             }
  10101.             break;
  10102.         }
  10103.  
  10104.         GetDItem(dialog, ok, &kind, &h, &r);
  10105.         HiliteControl((ControlHandle)h, (*passp->password ? 0 : 255));
  10106.     }
  10107.     return(false);
  10108. }
  10109.  
  10110. char *
  10111. pstrdel (unsigned char *s, int ix, int len)
  10112. {
  10113.     int last;
  10114.  
  10115.     if (len == 0 || ix > *s)
  10116.         return(s);
  10117.  
  10118.     last = ix + len;
  10119.     if (last > *s) {
  10120.         *s = ix - 1;
  10121.     } else {
  10122.         BlockMove(&s[last], &s[ix], *s - last + 1);
  10123.         *s -= len;
  10124.     }
  10125.     return(s);
  10126. }
  10127.  
  10128. char *
  10129. pstrins (unsigned char *s, unsigned char c, int ix)
  10130. {
  10131.     if (*s < 0x00FF)
  10132.         (*s)++;
  10133.     BlockMove(&s[ix], &s[ix + 1], *s - ix);
  10134.     s[ix] = c;
  10135.     return(s);
  10136. }
  10137.  
  10138.  
  10139. +++++++++++++++++++++++++++
  10140.  
  10141. >From kjohnso@nyx10.cs.du.edu (Kai)
  10142. Date: Fri, 4 Mar 94 21:26:04 GMT
  10143. Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
  10144.  
  10145. In article <2klgi3$36o@dartvax.dartmouth.edu>,
  10146. kurash@dartmouth.edu <Mark.R.Valence@dartmouth.edu> wrote:
  10147. >In article <Jim.Matthews-250294091049@ishmael.dartmouth.edu>
  10148. >Jim.Matthews@dartmouth.edu (Jim Matthews) writes:
  10149. >
  10150. >There are two main weaknesses of using a "bullet font" (or the StdText
  10151. >method) to hide a password in a dialog box edittext item.  First,
  10152. >anyone can grab the password by choosing Copy from the Edit menu (under
  10153. >Sys7).  This is not an issue unless the user has a habit of typing a
  10154. >password and leaving the dialog on the screen.
  10155. >
  10156. >The more important drawback is that it is difficult to handle two-byte
  10157. >character sets.  Because the font would be script specific, extra
  10158. >"bullet" characters would be emitted.
  10159. >
  10160. >The source below solves the password-in-a-dialog problem by filtering
  10161. >the event stream and modifying the proper key-down events.  It keeps a
  10162. >private copy of the password. Although this implementation does not
  10163. >support multibyte character sets, it could be modified to do so easily
  10164. >(and in fact I am going to have to do this eventually myself).
  10165. >
  10166. >[source deleted...]
  10167.  
  10168. You can do the same trick and support all the standard TextEdit things
  10169. by putting a hidden TE item offscreen and rerouting key events to it.
  10170. Just keep the selections in the two items in sync, and match the number
  10171. of bullets in the visible item to the hidden one.
  10172.  
  10173. The user can copy the password all they want, but they just get bullets.
  10174.  
  10175. I think this is how the sample code in the H/I notes from Apple works...
  10176.  
  10177. Oh, if you're doing passwords, you should have a look at the note about
  10178. them, there are some standard ways for handling all the clicks and key
  10179. presses.
  10180.  
  10181. I can probably find both the H/I note and the sample code if you but me
  10182. about it.
  10183.  
  10184. -Kai
  10185.  
  10186. +++++++++++++++++++++++++++
  10187.  
  10188. >From moofster@world.std.com (A Happy Dog-Cow)
  10189. Date: Sun, 6 Mar 1994 05:36:58 GMT
  10190. Organization: The Nest of the Moofster
  10191.  
  10192. Sheesh!  All of this talk of patching traps & weirdo fonts to just make
  10193. a password entry screen!  Programmers should be on guard against
  10194. innapropriate over-engineering!!  Sheesh!  Just make a ModalDialogFIlter
  10195. procedure, intercept the update routine for the item(s) in question,
  10196. and voila.  Patching traps or coming up with exotic fonts to perform
  10197. this is unnecessary!
  10198.  
  10199. Robert M. Seretny, Armesti Research,
  10200. (Macintosh/SCSI guru for short-term hire; email moofster@world.std.com)
  10201.  
  10202.  
  10203. +++++++++++++++++++++++++++
  10204.  
  10205. >From danprice@delphi.com
  10206. Date: Mon, 7 Mar 94 18:55:47 -0500
  10207. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  10208.  
  10209.  
  10210. I dunno, I wrote a short routine for a friend in a comp/sci course who wanted
  10211. to impress his teacher.  Basically, I set up a dialog with 12 buttons, in
  10212. a numeric keypad arrangement.  The things that's neat about this is that,
  10213. unless the "hacker" is extremely clever, he won't be able to use a filter
  10214. (sorry, not a filter) a trap patch to intercept the passcode, as the
  10215. difficulty of figuring which part of the screen clicked is fairly high.
  10216.  
  10217. Also, I thought about randomly scrambling the buttons in the dialog, to
  10218. make this _even_ harder, as well as to foil those with binoculars and such.
  10219.  
  10220. I think this whole password thing is overkill....
  10221.     -dp
  10222.  
  10223. ---------------------------
  10224.  
  10225. >From python@jhunix.hcf.jhu.edu (Bryan Arntson)
  10226. Subject: Permanent front windows...
  10227. Date: 3 Mar 1994 17:53:33 -0500
  10228. Organization: Homewood Academic Computing, Johns Hopkins University, Baltimore, Md, USA
  10229.  
  10230. I apologize for not knowing what these windows are called, but how do I
  10231. create those windows that are ALWAYS in the front.  They look like little
  10232. fake windows.  They have B&W window titles, that are about 10 pixels high,
  10233. and then the window below them.  What are these called?  And most
  10234. importantly, HOW DO I CREATE ONE?  Could someone post, or send me, a short
  10235. code on the subject?
  10236.  
  10237. Thanks in advance,
  10238.  
  10239. Bryan
  10240. python@jhunix.hcf.jhu.edu
  10241.  
  10242.  
  10243. +++++++++++++++++++++++++++
  10244.  
  10245. >From troy@i-link.com (Troy Gaul)
  10246. Date: 3 Mar 1994 23:24:53 -0600
  10247. Organization: I-Link, Ltd., Des Moines, IA
  10248.  
  10249. In article <2l5ppdINN5qk@jhunix.hcf.jhu.edu>,
  10250. Bryan Arntson <python@jhunix.hcf.jhu.edu> wrote:
  10251. >I apologize for not knowing what these windows are called, but how do I
  10252. >create those windows that are ALWAYS in the front.  
  10253.  
  10254. There are several names that are used, including 'Utility Window', 'Tool
  10255. Window', 'Palette', 'Windoid', 'Floating Window', and 'Floater'. 
  10256.  
  10257. >They look like little
  10258. >fake windows.  They have B&W window titles, that are about 10 pixels high,
  10259. >and then the window below them.  
  10260.  
  10261. They don't _have_ to have a B&W window title. The only reason that I can
  10262. think of that many of them are B&W is that the programmers didn't know
  10263. about the Infinity Windoid WDEF (which, it happens, I wrote), which gives
  10264. you a System 7-style coloring scheme (but is also compatible with System 6).
  10265. It gives these to you for free, as it is freeware, and worry-free (it's been
  10266. well tested, and the source is included).
  10267.  
  10268. >What are these called?  And most
  10269. >importantly, HOW DO I CREATE ONE?  Could someone post, or send me, a short
  10270. >code on the subject?
  10271.  
  10272. You can make a window with this type of a titlebar by getting the Infinity
  10273. Windoid WDEF from the anonymous FTP site:
  10274.  
  10275.     ftp://ftp.i-link.com/pub/infsys/
  10276.  
  10277. This WDEF does not help you make the window float on top of the others,
  10278. however. To do this, you need a floating window library. There was one
  10279. included with Develop 15, and updated code was included with Develop 16.
  10280. You can pick up the latest version of that code, along with the text of
  10281. the article (through an arrangement I make with Apple), in the same place.
  10282.  
  10283. _troy
  10284.  
  10285. -- 
  10286. //////// //////   Troy Gaul                            t-gaul@i-link.com   //
  10287.   //    //       I-Link, Ltd.                                             //
  10288.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)              //
  10289. //    ////// __________________________________________________________ //
  10290.  
  10291. +++++++++++++++++++++++++++
  10292.  
  10293. >From kurisuto@chopin.udel.edu (Sean J. Crist)
  10294. Date: 4 Mar 1994 11:37:41 -0500
  10295. Organization: University of Delaware
  10296.  
  10297. >This WDEF does not help you make the window float on top of the others,
  10298. >however. To do this, you need a floating window library. There was one
  10299. >included with Develop 15, and updated code was included with Develop 16.
  10300. >You can pick up the latest version of that code, along with the text of
  10301. >the article (through an arrangement I make with Apple), in the same place.
  10302.  
  10303. Or, for that matter, you could just write your own routines to do this. 
  10304. This only took me a few hours to do.  Basically, you've got to rewrite the
  10305. top level of the window manager.  A good start is to write a routine that
  10306. acts like SelectWindow (calling ShowHide and HiliteWindow) except that it
  10307. leaves your Palette window in front.  Then go through your code and do a
  10308. global search-and-replace to change SelectWindow to the name of your
  10309. replacement routine.  If you can get that much working properly, that's
  10310. 90% of the game.
  10311.  
  10312. If there's interest, I can post my code; it's pretty complicated, though,
  10313. because I'm doing a lot more than just supporting floating palettes. 
  10314. Rather than keep a million WindowPtr's to everything (which is messy when
  10315. your application allows the user to open any number of instances of a
  10316. particular type of window), I keep information about the window in a
  10317. handle stored in the window's RefCon.  Then when I need window number X of
  10318. type Y, I call one of my routines to quickly search through the linked
  10319. list of windows to try to find a match.  I can clean up this code a little
  10320. and post it if there's interest.
  10321.  
  10322. --Sean (kurisuto@chopin.udel.edu)
  10323.  
  10324.   \/ __ __    _\_   |  If restaurants were named as gay organizations are,
  10325.  ---  |  |    \ /   |  "McDonald's" would be called "Meat, Bread, Vegetables,
  10326.   _| ,| ,|   -----  |  Beverages, Condiments, and Friends" (MBVBCF for short).
  10327.   _| ,| ,|    [_]   |--------------------------------------------------------
  10328.    |  |  |    [_]   |  Finger this account for a copy of the Bill of Rights.
  10329.  
  10330. ---------------------------
  10331.  
  10332. >From andersw@hum.gu.se (Anders Wahlin)
  10333. Subject: Preference file question!
  10334. Date: Fri, 4 Mar 1994 08:03:28 GMT
  10335. Organization: Hum Fak:s Dataservice
  10336.  
  10337. Almost every program has a preference file. I have twoo very simple
  10338. questions about this. 
  10339.  
  10340. 1%    Is it "wrong" to have a resource file as a preference file?
  10341.  
  10342. 2%    How can I create an icon on my preference file, within the program?
  10343.  
  10344. Thanks!
  10345.  
  10346. -- 
  10347. Anders Wahlin
  10348. andersw@hum.gu.se
  10349.  
  10350. +++++++++++++++++++++++++++
  10351.  
  10352. >From rmah@panix.com (Robert S. Mah)
  10353. Date: Fri, 04 Mar 1994 04:52:40 -0500
  10354. Organization: One Step Beyond
  10355.  
  10356. andersw@hum.gu.se (Anders Wahlin) wrote:
  10357.  
  10358. > Almost every program has a preference file. I have twoo very simple
  10359. > questions about this. 
  10360. > 1    Is it "wrong" to have a resource file as a preference file?
  10361.  
  10362. No, many programs use resources to store their prefs.  The only drawback is
  10363. that the file is no longer platform independent.  I've often thought of
  10364. using a text file to store prefs.
  10365.  
  10366.  
  10367. > 2    How can I create an icon on my preference file, within the program?
  10368.  
  10369. Simply add an entry into your BNDL resource with associated FREF and
  10370. ICN#/icl/ics resources. 
  10371.  
  10372. However, please think about using the standard 'pref' file type.  The
  10373. finder will give it a nice prefs style icon and people's preferences folder
  10374. will open just a bit faster.  Now if everyone did this...
  10375.  
  10376. Cheers,
  10377. Rob
  10378. ________________________________________________________________________
  10379.  Robert S. Mah              One Step Beyond              rmah@panix.com
  10380.  
  10381. +++++++++++++++++++++++++++
  10382.  
  10383. >From Lars.Farm@nts.mh.se (Lars Farm)
  10384. Date: Fri, 04 Mar 1994 11:33:02 +0100
  10385. Organization: Mid Sweden University
  10386.  
  10387. In article <andersw-040394090400@bigmac.hds.gu.se>, andersw@hum.gu.se
  10388. (Anders Wahlin) wrote:
  10389.  
  10390. > 1%    Is it "wrong" to have a resource file as a preference file?
  10391.  
  10392. No. It's common practice.
  10393.  
  10394. > 2%    How can I create an icon on my preference file, within the program?
  10395.  
  10396. Set the file type to 'pref'.
  10397.  
  10398. Lars
  10399.  
  10400. -- 
  10401. Lars.Farm@nts.mh.se
  10402.  
  10403. +++++++++++++++++++++++++++
  10404.  
  10405. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  10406. Date: 5 Mar 1994 21:14:20 +0800
  10407. Organization: NCRPDA, Curtin University
  10408.  
  10409. rmah@panix.com (Robert S. Mah) writes:
  10410.  
  10411. >However, please think about using the standard 'pref' file type.  The
  10412. >finder will give it a nice prefs style icon and people's preferences folder
  10413. >will open just a bit faster.  Now if everyone did this...
  10414.  
  10415. Do this - it's much nicer.  I used to do it the other way with a BNDL and
  10416. icon for the prefs file, but the Preferences folder is full up with
  10417. thousands of different icons, it's just a mess.  So use the 'pref' file
  10418. type, and don't worry about designing an icon, and life will be good.
  10419.    Peter.
  10420. -- 
  10421. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  10422.  
  10423. +++++++++++++++++++++++++++
  10424.  
  10425. >From perm@csd.uu.se (Per Mildner)
  10426. Date: 11 Mar 1994 14:56:23 GMT
  10427. Organization: Computing Science Dept.,Uppsala University, Sweden
  10428.  
  10429.  
  10430. Several people have suggested using the 'pref' file type for
  10431. preference files.  There is one problem with this, this is the type
  10432. for the finder prefs.  Most people thinks this is a good thing as this
  10433. automagically gives the pref file a good icon, but the people
  10434. suggesting this are not likely to use balloon help in the finder :-)
  10435. If you use the pref file you better add some balloon info in your pref
  10436. file too. (Another potential problem might be with EasyOpen or
  10437. whatever which I have not used).
  10438. Regards,
  10439. --
  10440. Per Mildner            Per.Mildner@CSD.UU.SE
  10441. Computing Science Dept.        tel: +46 18 181049
  10442. Uppsala University, Sweden    fax: +46 18 521270
  10443.  
  10444. +++++++++++++++++++++++++++
  10445.  
  10446. >From t-gaul@i-link.com (Troy Gaul)
  10447. Date: Fri, 11 Mar 1994 12:35:25 -0600
  10448. Organization: I-Link, Ltd.
  10449.  
  10450. In article <PERM.94Mar11155623@groucho.csd.uu.se>, perm@csd.uu.se (Per
  10451. Mildner) wrote:
  10452.  
  10453. > Several people have suggested using the 'pref' file type for
  10454. > preference files.  There is one problem with this, this is the type
  10455. > for the finder prefs.  Most people thinks this is a good thing as this
  10456. > automagically gives the pref file a good icon, but the people
  10457. > suggesting this are not likely to use balloon help in the finder :-)
  10458. > If you use the pref file you better add some balloon info in your pref
  10459. > file too. 
  10460.  
  10461. I really don't think this is a big issue against using that as a file type.
  10462. Besides, I have several other pieces of Apple software (the Apple Modem
  10463. Tool was the one I saw when I checked this out) that also do the same
  10464. thing.
  10465.  
  10466. > (Another potential problem might be with EasyOpen or
  10467. > whatever which I have not used).
  10468.  
  10469. I don't see where this would be a problem. Actually, quite the opposite is
  10470. true. If you have the resources for Easy Open in your application, then you
  10471. can describe the preferences file with a 'kind' resource as 'MyApplication
  10472. preferences', and this would appear in the Finder names lists of the
  10473. preferences folder (or the get info box).  
  10474.  
  10475. Easy Open uses the creator of the file to determine its labeling,
  10476. apparently, the Balloon help in the Finder doesn't look at the creator of
  10477. the file when the cursor's pointed at a 'pref' file as it should.
  10478.  
  10479. I've taken the advice to use 'pref' as the file type and to NOT include an
  10480. icon for that type to heart.  I'm doing it in most of my own programming
  10481. projects now.
  10482.  
  10483. _troy
  10484. //////// //////___Troy Gaul_________________________t-gaul@i-link.com__ //
  10485.   //    //       I-Link, Ltd. ; West Des Moines, Iowa                  //
  10486.  //    //  //   "Iungo ergo sum." (I-Link, therefore I am.)           //
  10487. //    //////________________________________________________________ //
  10488.  
  10489. ---------------------------
  10490.  
  10491. >From pope@imv.aau.dk (Povl H. Pedersen)
  10492. Subject: Reading PICT files != 72 dpi. How ?
  10493. Date: 26 Feb 1994 16:01:21 GMT
  10494. Organization: Information and Media Science, Aarhus University, DENMARK
  10495.  
  10496. I am working on a small custom image modifying program, and it will have 
  10497. to load in PICT files created in other applications.
  10498.  
  10499. I have managed to steal some code that will rwad/write PICT files, but my 
  10500. problem now is, that the end user somethimes generates PICTs in a better 
  10501. resolution than 72 dpi. When he reads them in, they are shrinked to keep 
  10502. size as the original, and he then loses information.
  10503.  
  10504. How do I read in PICT files with all osrts of resolution, handle them as 
  10505. pixel-by-pixel images, and then finally write them back with their 
  10506. original resolution info ?
  10507.  
  10508. thanks in advance,
  10509.  
  10510. - -
  10511. Povl H. Pedersen  -  Macintosh Consultant and Programmer
  10512. pope@imv.aau.dk (preferred)  /  povlphp@uts.uni-c.dk
  10513.  
  10514. "Macintosh...for those who can see through Windows!"
  10515.  
  10516. +++++++++++++++++++++++++++
  10517.  
  10518. >From pope@imv.aau.dk (Povl H. Pedersen)
  10519. Date: 28 Feb 1994 18:16:17 GMT
  10520. Organization: Information and Media Science, Aarhus University, DENMARK
  10521.  
  10522. I wanted to know how I could read in a PICT in a higher than 72dpi 
  10523. resolution, and keep every single pixel. I tried the net, as it is usual 
  10524. a good fast reference manual ;^)
  10525.  
  10526. The net did not want to answer me, so I did spend some time, and found a 
  10527. working way. I am using information on page 17-24 of Inside Macintosh 
  10528. volume VI. This info is not documented in any headers anywhere, but I 
  10529. suppose it is safe to use.
  10530.  
  10531. (Now, why has Apple not given us routines to read/write PICT files ? They 
  10532. should be a natural part of the toolbox. Just like some way to get a 
  10533. PicHandle from a pixmap).
  10534.  
  10535. My ugly code is enclosed below. I did slight editing after copy/pasting, so
  10536. it may contain a few syntax errors. My routine allocates a new offscreen 
  10537. GWorld, and reads the picture in here. Only minimum level of error 
  10538. checking is done. The application where this is used will not be run on 
  10539. large images on machines with less than 32-64 MB RAM. So memory is no 
  10540. problem. This is one reason I make the offscreen pixmap 32 bits instead 
  10541. of using the information from the file. Another reason is, that I parse 
  10542. all pixels in a loop that expects 32bit pixmap.
  10543.  
  10544. Disclaimer: This code is guaranteed to be incompatible with at least one 
  10545. version of one Microsoft product. Not necesarily now, but then in the 
  10546. future. Don't blame me. Blame the guilty ones.
  10547.  
  10548. Povl
  10549.  
  10550. - -----------------------------
  10551.  
  10552. // structure not defined anywhere. Contents just listed in IM VI, page 17-24
  10553. typedef struct {
  10554.     unsigned short  picSize;
  10555.     Rect            picFrame;
  10556.     // Now comes the header as displayed in IM VI, but not defined in any headers
  10557.     short           s1;             // = 0x0011 for special resolution
  10558.     short           s2;             // = 0x02FF
  10559.     short           HeaderOp;       // Opcode for PICT command. 0x0C00 = header
  10560.     short           version;        // = -2 for extended version 2 pict file
  10561.     short           reserved;
  10562.     Fixed           hRes;           // horizontal resolution
  10563.     Fixed           vRes;           // vertical resolution
  10564.     Rect            srcRect;        // Native source rectangle
  10565.     // More stuff follows but is ignored
  10566. } myVersion2PICTHeaderT;
  10567.  
  10568. static short gPICT_FILE_RESNUM;
  10569.  
  10570. // Quickdraw bottleneck routine to do the hard work
  10571. pascal void GetPICTData( Ptr dataPtr, short byteCount )
  10572. {
  10573.     long    longCount;
  10574.     
  10575.     longCount = byteCount;
  10576.     err = FSRead( gPICT_FILE_RESNUM, &longCount, dataPtr );
  10577. }
  10578.  
  10579. // This routine takes the following parametres:
  10580. // p:        a pointer to a GWorldPtr. On exit it will point to a new GWorld.
  10581. // filespec: FSSpec pointer that identifies the PICT file to read.
  10582.  
  10583. void getPICTFile( GWorldPtr *p, FSSpec *fileSpec)
  10584. {
  10585.     QDProcsPtr  savedProcs;
  10586.     CQDProcs    myProcs;
  10587.     GDHandle    gdh;
  10588.     CGrafPtr    port;
  10589.     PicHandle   thePic = nil;
  10590.     long        longCount;
  10591.     short       h, w;
  10592.     Rect        r,gr;
  10593.  
  10594.     PictInfo    pinfo;
  10595.  
  10596.     Fixed       vRes, hRes;     // horizontal/vertical resolutions
  10597.     myVersion2PICTHeaderT myPICTheader;
  10598.  
  10599.     *p = nil;        // lazy way to return error
  10600.     
  10601.     // Open file and skip old MacPaint header
  10602.     err = FSpOpenDF( fileSpec, fsRdPerm, &gPICT_FILE_RESNUM );
  10603.     SetFPos( gPICT_FILE_RESNUM, fsFromStart, 512);  // skip header
  10604.  
  10605.     // clear my header.
  10606.     memset( &myPICTheader, 0, sizeof(myPICTheader) );
  10607.     
  10608.     // Get the IM VI documented header
  10609.     longCount = sizeof( myPICTheader );
  10610.     err = FSRead( gPICT_FILE_RESNUM, &longCount, &myPICTheader );
  10611.     if (err != noErr) {
  10612.         TellUser( "Unpected End-of-File. Replace user and try again");
  10613.         return;
  10614.     }
  10615.     
  10616.     // Test if we have an extendended version 2 pict header
  10617.     if ( myPICTheader.s1 == 0x0011 && myPICTheader.s2 == 0x02FF && 
  10618.          myPICTheader.HeaderOp == 0x0C00 && myPICTheader.version == -2) {
  10619.     
  10620.         // Now we have a PICTure of another resolution
  10621.         
  10622.         hRes = myPICTheader.hRes;
  10623.         vRes = myPICTheader.vRes;
  10624.     }
  10625.     else
  10626.         hRes = vRes = Long2Fix( 72 );       // default resolution
  10627.  
  10628.     // skip back to header again, loading pict should start at pos=512
  10629.     SetFPos( gPICT_FILE_RESNUM, fsFromStart, 512);
  10630.     // Get room for the real header and read it
  10631.     thePic = (PicHandle) NewHandle(sizeof(Picture));
  10632.  
  10633.     longCount = sizeof( Picture );
  10634.     FSRead( gPICT_FILE_RESNUM, &longCount, (Ptr) *thePic );
  10635.     
  10636.     // different resolution, use the info from our version 2 extended header
  10637.     if (hRes != Long2Fix( 72 )) {
  10638.         w = myPICTheader.srcRect.right - myPICTheader.srcRect.left;
  10639.         h = myPICTheader.srcRect.bottom - myPICTheader.srcRect.top;
  10640.         r = myPICTheader.srcRect;
  10641.     }
  10642.     else {    // just use the data the old way
  10643.         w = (**thePic).picFrame.right;
  10644.         h = (**thePic).picFrame.bottom;
  10645.         r = (**thePic).picFrame;
  10646.     }
  10647.     
  10648.     // Now that we have the header, we know which size to make our offscreen buffer
  10649.     GetGWorld( &port, &gdh );
  10650.     
  10651.     SetRect( &gr, 0, 0, w, h );
  10652.     err = NewGWorld( p, 32, &gr, (CTabHandle) 0, (GDHandle) 0, 0 );
  10653.     if (err != noErr)
  10654.         DoCrashTheMachineAndAnnoyTheEndUser();
  10655.  
  10656.     SetGWorld( *p, nil );
  10657.     
  10658.     // Set our resolution. This makes sure the usual save routine will 
  10659.     // write it back for whatever DPI we use.
  10660.     (*p->portPixMap)->vRes = vRes;
  10661.     (*p->portPixMap)->hRes = hRes;
  10662.     
  10663.     // SetStdCProcs
  10664.     SetStdCProcs( &myProcs );
  10665.     myProcs.getPicProc = GetPICTData;
  10666.     savedProcs = ((GrafPtr) p)->grafProcs;
  10667.     ((CGrafPtr) p)->grafProcs = &myProcs;
  10668.     // this line does the real work
  10669.     DrawPicture( thePic, &r );
  10670.     
  10671.     SetGWorld( port, gdh ); 
  10672.  
  10673.     FSClose( gPICT_FILE_RESNUM );
  10674.     DisposHandle( (Handle) thePic );
  10675.     ((GrafPtr) p)->grafProcs = savedProcs;
  10676. }
  10677.  
  10678. - -
  10679. Povl H. Pedersen  -  Macintosh Consultant and Programmer (For hire).
  10680. System Administrator at the Aarhus Engineering School
  10681. pope@imv.aau.dk (preferred)  /  povlphp@uts.uni-c.dk
  10682.  
  10683. "Macintosh...for those who can see through Windows!"
  10684.  
  10685. ---------------------------
  10686.  
  10687. >From temple@itd.nrl.navy.mil (Dr. Jon Gerard Temple)
  10688. Subject: Resources on PowerPC
  10689. Date: Fri, 11 Mar 1994 19:56:23 GMT
  10690. Organization: Naval Research Laboratory
  10691.  
  10692. There is an issue I have a little trouble with: it is my understanding
  10693. that Native applications on the Power Macintosh will not use resources
  10694. (or the resource fork.). What does this mean for programmers that are
  10695. used to ResEdit for creating/editing resources, whose code points to
  10696. reusable resources, etc? Will this feature of Mac programming simply
  10697. cease to exist when writing Native RISC applications or is there an
  10698. alternative approach that will treat part of the DATA fork on PPC Macs
  10699. as editable, callable, reusable resources that a new version of ResEdit
  10700. (DataEdit??) will able to work with?
  10701.  
  10702. Ideas?
  10703.  
  10704.  
  10705. +++++++++++++++++++++++++++
  10706.  
  10707. >From minnis@cobaf.unt.edu (Minnis, Robert)
  10708. Date: Fri, 11 Mar 1994 20:15:23 GMT
  10709. Organization: College of Business Administration, UNT
  10710.  
  10711. In article <CMInE0.5nM@ra.nrl.navy.mil> temple@itd.nrl.navy.mil (Dr. Jon Gerard Temple) writes:
  10712. >From: temple@itd.nrl.navy.mil (Dr. Jon Gerard Temple)
  10713. >Subject: Resources on PowerPC
  10714. >Date: Fri, 11 Mar 1994 19:56:23 GMT
  10715.  
  10716. >There is an issue I have a little trouble with: it is my understanding
  10717. >that Native applications on the Power Macintosh will not use resources
  10718. >(or the resource fork.). What does this mean for programmers that are
  10719. >used to ResEdit for creating/editing resources, whose code points to
  10720. >reusable resources, etc? Will this feature of Mac programming simply
  10721. >cease to exist when writing Native RISC applications or is there an
  10722. >alternative approach that will treat part of the DATA fork on PPC Macs
  10723. >as editable, callable, reusable resources that a new version of ResEdit
  10724. >(DataEdit??) will able to work with?
  10725.  
  10726. >Ideas?
  10727.  
  10728. >From what I understand, resources are not going to vanish.  PPC code will be 
  10729. stored in the data fork (68K code will still be stored in CODE resources).
  10730.  
  10731. Robert Minnis
  10732.  
  10733. +++++++++++++++++++++++++++
  10734.  
  10735. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  10736. Date: Fri, 11 Mar 94 15:39:49 PST
  10737. Organization: Peirce Software, Inc.
  10738.  
  10739.  
  10740. In article <CMInE0.5nM@ra.nrl.navy.mil> (comp.sys.mac.programmer), temple@itd.nrl.navy.mil (Dr. Jon Gerard Temple) writes:
  10741. > There is an issue I have a little trouble with: it is my understanding
  10742. > that Native applications on the Power Macintosh will not use resources
  10743. > (or the resource fork.). What does this mean for programmers that are
  10744. > used to ResEdit for creating/editing resources, whose code points to
  10745. > reusable resources, etc? Will this feature of Mac programming simply
  10746. > cease to exist when writing Native RISC applications or is there an
  10747. > alternative approach that will treat part of the DATA fork on PPC Macs
  10748. > as editable, callable, reusable resources that a new version of ResEdit
  10749. > (DataEdit??) will able to work with?
  10750.  
  10751. Resourse do *not* go away on the Power Mac.  PowerPC executable code
  10752. is not found in CODE resources (though it can be found in a few special
  10753. code resources) rather in the data fork.  Still, all other "normal"
  10754. Mac resources are still around and used.  In fact, CODE resource can
  10755. still contain 68K code - this is how you implement fat binaries.
  10756.  
  10757. So relax, ResEdit isn't going away.
  10758.  
  10759.  
  10760. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  10761. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  10762. --                       -- San Jose, California USA 95117
  10763. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  10764. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  10765.  
  10766. +++++++++++++++++++++++++++
  10767.  
  10768. >From richardb@cocytus.demon.co.uk (Richard Buckle)
  10769. Date: Sat, 12 Mar 1994 12:57:25 GMT
  10770. Organization: None
  10771.  
  10772.  
  10773. In article <CNjbKKKX.qcga43@outpost.SF-Bay.org> peirce@outpost.SF-Bay.org
  10774. (Michael Peirce) writes:
  10775. >
  10776. >...
  10777. >Resourse do *not* go away on the Power Mac.  PowerPC executable code
  10778. >is not found in CODE resources (though it can be found in a few special
  10779. >code resources) rather in the data fork.  Still, all other "normal"
  10780. >Mac resources are still around and used.  In fact, CODE resource can
  10781. >still contain 68K code - this is how you implement fat binaries.
  10782. >...
  10783.  
  10784. Arrgggh! How could Apple do this to me? I need my data forks for DATA.
  10785.  
  10786. A major part of my job is writing computationally *very* intensive XCMDs (for
  10787. HyperCard) and CODE resources (for Excel). These are of course stored in the
  10788. resource forks of stacks and spreadsheets and we need to turn them into fat
  10789. binaries. And HyperCard and Excel expect to call CODE and XCMD resources, not
  10790. any other type.
  10791.  
  10792. Will it be possible to have 68K stub resources call 'special' PowerPC
  10793. executable resources?
  10794.  
  10795. If not, I guess I shall have to store the PowerPC code in the data fork of
  10796. another file. As new releases are very frequent this would be an installation
  10797. nightmare. Would the new Shared Library Manager help at all?
  10798.  
  10799. BTW, how is the global A4 addressing issue handled in PowerPC standalone code?
  10800.  
  10801. Replies by mail please -- I shan't have time to read much news next week. I
  10802. shall summarise in c.s.m.p when the shouting is over.
  10803.  
  10804. Apologies if these are RTFM-type questions -- we have not yet taken delivery of
  10805. CodeWarrior so I am rather in the dark.
  10806.  
  10807. - -
  10808. Richard Buckle
  10809. richardb@cocytus.demon.co.uk
  10810. richardb@cix.compulink.co.uk
  10811.  
  10812. +++++++++++++++++++++++++++
  10813.  
  10814. >From wdh@netcom.com (Bill Hofmann)
  10815. Date: Sat, 12 Mar 1994 20:00:40 GMT
  10816. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  10817.  
  10818. richardb@cocytus.demon.co.uk (Richard Buckle) writes:
  10819. >A major part of my job is writing computationally *very* intensive XCMDs (for
  10820. >HyperCard) and CODE resources (for Excel). These are of course stored in the
  10821. >resource forks of stacks and spreadsheets and we need to turn them into fat
  10822. >binaries. And HyperCard and Excel expect to call CODE and XCMD resources, not
  10823. >any other type.
  10824. This seems to be enough of a FAQ that I've responded here as well as directly.
  10825. Michael misspoke himself slightly: BY DEFAULT, PowerPC code for APPLICATIONS
  10826. lives in the data fork of the file.  What this means is:
  10827.     * PPC application code can be in the data fork
  10828.     * PPC application code can be in one huge resource
  10829. You just have to set up the (mandatory) 'cfrg' resource properly.
  10830. Also:
  10831.     * standalone code resource can be all 680x0
  10832.     * standalone code resources can be all PowerPC
  10833.     * standalone code resources can be "fat", containing both
  10834. If standalone code will only be called from 680x0 code,
  10835.     * it can be plain vanilla 680x0 code, like today
  10836.     * it can be PPC code with a "RoutineDescriptor" at the front
  10837.     * it can be "fat" with a "RoutineDescriptor" at the front
  10838. 680x0 code doesn't need to know about the PowerPC AT ALL.
  10839.  
  10840. If standalone code will only be called from PowerPC code,
  10841.     * it can be naked PPC code
  10842.     * it can be PPC code with a RoutineDescriptor
  10843.     * it can be 680x0 code with a RoutineDescriptor
  10844.     * it can be "fat" with a RoutineDescriptor
  10845.     * it can be naked 680x0 code
  10846. In all but the FIRST (native PPC), it must be called using a special routine.
  10847. So if you write PPC-aware code, you need to read the MixedMode manager 
  10848. chapter of the Mac on RISC SDK.
  10849.  
  10850. If standalone code may be called from either 680x0 or PPC:
  10851.     * it can be naked 680x0 code
  10852.     * it can be PPC code with a RoutineDescriptor
  10853.     * it can be 680x0 code with a Routine Descriptor
  10854.     * it can be "fat" with a RoutineDescriptor
  10855. Since not all of the ToolBox and OS are native, ANY standard code resource
  10856. that contains PPC code MUST have a routine descriptor.  That goes for things
  10857. like XCMDs as well.
  10858.  
  10859.  
  10860. I think that about covers it.  Whoever maintains the FAQ might want to 
  10861. put this in there.
  10862.  
  10863. Oh yes, Apple Developer University is offering a course called "PowerPC
  10864. Boot Camp", which covers this and lots more.  It's a four day course,
  10865. with plenty of hands-on, including code resource kinda stuff.  I'm one
  10866. of the Drill Sargeants, oops, instructors, so, I have an ulterior motive.
  10867. -- 
  10868. -Bill Hofmann                    wdh@netcom.COM
  10869.  Fresh Software and Instructional Design    +1 510 524 0852
  10870.  
  10871. +++++++++++++++++++++++++++
  10872.  
  10873. >From Mark_Day@powertalk.apple.com (Mark Day)
  10874. Date: Sat, 12 Mar 1994 00:11:42 GMT
  10875. Organization: Apple Computer, Inc.
  10876.  
  10877. In article <CMInE0.5nM@ra.nrl.navy.mil>, temple@itd.nrl.navy.mil (Dr. Jon
  10878. Gerard Temple) wrote:
  10879.  
  10880. > There is an issue I have a little trouble with: it is my understanding
  10881. > that Native applications on the Power Macintosh will not use resources
  10882. > (or the resource fork.). What does this mean for programmers that are
  10883. > used to ResEdit for creating/editing resources, whose code points to
  10884. > reusable resources, etc? Will this feature of Mac programming simply
  10885. > cease to exist when writing Native RISC applications or is there an
  10886. > alternative approach that will treat part of the DATA fork on PPC Macs
  10887. > as editable, callable, reusable resources that a new version of ResEdit
  10888. > (DataEdit??) will able to work with?
  10889. > Ideas?
  10890.  
  10891. The code for native applications is normally found in the data fork,
  10892. not a bunch of CODE resources (for non-native code).  You can (and
  10893. should) still use resources.  In fact, you can have a "fat" application
  10894. with both CODE resources and native code in the data fork, that share
  10895. other non-code resources (like strings, icons, etc.).  Such "fat"
  10896. applications will execute the native code on Power Macintosh or the
  10897. old 68K CODE resources on non-Power Macintoshes.
  10898. -- 
  10899. Mark Day, Apple Computer, Inc.
  10900. mday@apple.com
  10901.  
  10902. ---------------------------
  10903.  
  10904. >From neeri@iis.ee.ethz.ch (Matthias Neeracher)
  10905. Subject: Safer Segments ?
  10906. Date: 15 Mar 94 16:49:06
  10907. Organization: Integrated Systems Laboratory, ETH, Zurich
  10908.  
  10909. My program usually has multiple resource files open, some of which contain CODE
  10910. resources (they are similar to AppleScript droplets). Unfortunately, if
  10911. _LoadSeg is called while one of the other CODE containing resource forks is
  10912. in front of the resource chain, a nasty crash results. So far, I have been able
  10913. to work around this problem by calling UseResFile() in all the right places,
  10914. but I'd prefer to know a simpler solution, if one exists.
  10915.  
  10916. Any ideas?
  10917.  
  10918. Matthias
  10919.  
  10920. - ---
  10921. Matthias Neeracher                                      neeri@iis.ee.ethz.ch
  10922.    "I really don't want the SNMP agent controlling my toilet to tell
  10923.     someone when/where I'm using it." -- Sean Graham
  10924.  
  10925. +++++++++++++++++++++++++++
  10926.  
  10927. >From wysocki@netcom.com (Chris Wysocki)
  10928. Date: Wed, 16 Mar 1994 10:02:35 GMT
  10929. Organization: Global Village Communication, Mountain View, CA
  10930.  
  10931. In article <NEERI.94Mar15164906@yggdrasil.ethz.ch> neeri@iis.ee.ethz.ch (Matthias Neeracher) writes:
  10932.  
  10933. >My program usually has multiple resource files open, some of which contain CODE
  10934. >resources (they are similar to AppleScript droplets). Unfortunately, if
  10935. >_LoadSeg is called while one of the other CODE containing resource forks is
  10936. >in front of the resource chain, a nasty crash results. So far, I have been able
  10937. >to work around this problem by calling UseResFile() in all the right places,
  10938. >but I'd prefer to know a simpler solution, if one exists.
  10939.  
  10940. It's hardly simple, but the most robust thing to do is to patch
  10941. _LoadSeg and have your patch set the current resource file, call the
  10942. "real" _LoadSeg and restore the previous resource file on the way out.
  10943. Patching _LoadSeg also allows you to preflight the loading of the code
  10944. resources so that you can avoid crashing in the event that the Segment
  10945. Loader can't load the segment.  I've use this technique in a number of
  10946. applications and it works quite well; if you have MacApp 3.x, take a
  10947. look at UMemory.cp and UMemory.a to see how it can be done.
  10948.  
  10949. Chris.
  10950.  
  10951. +++++++++++++++++++++++++++
  10952.  
  10953. >From Greg_Marriott@genmagic.com (Greg Marriott)
  10954. Date: Thu, 17 Mar 1994 02:26:31 -0800
  10955. Organization: General Magic, Inc.
  10956.  
  10957. neeri@iis.ee.ethz.ch (Matthias Neeracher) wrote:
  10958.  
  10959. > [...] if _LoadSeg is called while one of the other CODE
  10960. > containing resource forks is in front of the resource chain, a nasty
  10961. > crash results. So far, I have been able to work around this problem
  10962. > by calling UseResFile() in all the right places, [...]
  10963. > Any ideas?
  10964.  
  10965. I don't know if you'll think this is simpler or not... You might try
  10966. patching _LoadSeg to call UseResFile() before jumping to the original code.
  10967.  
  10968. -- 
  10969. Greg Marriott
  10970. Just Some Guy
  10971. General Magic, Inc.
  10972.  
  10973. Disclaimer: My opinions are not necessarily the same as General Magic's.
  10974.             (can a company even HAVE an opinion?)
  10975.  
  10976. +++++++++++++++++++++++++++
  10977.  
  10978. >From ari@world.std.com (Ari I Halberstadt)
  10979. Date: Thu, 17 Mar 1994 21:08:39 GMT
  10980. Organization: The World Public Access UNIX, Brookline, MA
  10981.  
  10982. In article <NEERI.94Mar15164906@yggdrasil.ethz.ch>,
  10983. Matthias Neeracher <neeri@iis.ee.ethz.ch> wrote:
  10984. >My program usually has multiple resource files open, some of which contain CODE
  10985. >resources (they are similar to AppleScript droplets). Unfortunately, if
  10986. >_LoadSeg is called while one of the other CODE containing resource forks is
  10987. >in front of the resource chain, a nasty crash results. So far, I have been able
  10988. >to work around this problem by calling UseResFile() in all the right places,
  10989. >but I'd prefer to know a simpler solution, if one exists.
  10990.  
  10991. You can patch the _LoadSeg trap. Here's the code I use to patch
  10992. LoadSeg. It checks that there's enough memory available before loading
  10993. the segment. If you add a call to UseResFile just before and after the
  10994. GetResource call it should do what you need. The PatchType structure
  10995. contains info about the patch that you'd set when installing the
  10996. patch, though you could just use some global variable to hold the
  10997. address of the routine returned by NGetTrapAddress.
  10998.  
  10999. /* data needed by a patch */
  11000. typedef struct PatchType {
  11001.    struct PatchType *next;      /* next patch */
  11002.    pascal void (*addr)(...);   /* address of patch routine */
  11003.    pascal void   (*trap)(...);   /* saved trap address */
  11004.    TrapType      type;            /* type of trap */
  11005.    short         num;            /* number of trap */
  11006.    Boolean      installed;      /* true if patch was installed */
  11007. } PatchType, *PatchPtr, **PatchHandle;
  11008.  
  11009. /* The PATCH_ENTER macro should be the first executable statement in
  11010.    your patch routine. PATCH_ENTER saves all of the registers and sets
  11011.    up register a5. PATCH_ENTER also ensures that the routine has a stack
  11012.    frame so that the PATCH_RETURN macro can be used. */
  11013. #define PATCH_ENTER() \
  11014.    {   long _patch_force_stack_frame; {      /* force stack frame of at least 4 bytes */ \
  11015.       asm { movem.l a0-a5/d0-d7, -(sp) }   /* save registers */ \
  11016.       asm { move.l #0x0904, a5 }            /* setup register a5 */ \
  11017.       asm { move.l (a5), a5 }
  11018.  
  11019. // this PATCH_RETURN macro magically restores registers d0-d7/d0-a7 to the
  11020. // same values they had when it was entered, which makes it a pretty
  11021. // safe way to patch traps (note: well, i've only been using this code
  11022. // for about a week, but i stepped through it and it should work).
  11023.  
  11024. /* The PATCH_RETURN macro jumps to the address of the originally patched
  11025.    routine. You should call PATCH_RETURN at the end of your patch. The
  11026.    'patch' parameter should be a pointer returned from PatchBegin. The
  11027.    compiler must generate a stack frame (using register a6) for the patch
  11028.    routine. This should be ensured by the PATCH_ENTER macro. */
  11029. #define PATCH_RETURN(patch) \
  11030.    } } \
  11031.    { \
  11032.       asm { move.l a6, a1 }               /* get current value of a6 */ \
  11033.       asm { move.l (a6), -(a6) }            /* shift location of saved a6 */ \
  11034.       asm { move.l patch, a0 }            /* get pointer to patch record */ \
  11035.       asm { move.l PatchType.trap(a0), (a1) } /* put patched routine's address on stack */ \
  11036.       asm { movem.l (sp)+, a0-a5/d0-d7 }   /* restore registers */ \
  11037.       asm { unlk a6 }                     /* pop stack frame */ \
  11038.       asm { rts }                           /* return to patched routine */ \
  11039.    }
  11040.  
  11041. static PatchType *gPatchLoadSeg;   /* data about patch */
  11042.  
  11043. /* get a code resource */
  11044. static Handle GetCodeResource(ResID id)
  11045. {
  11046.    Handle code;
  11047.    
  11048.    require(LMGetResLoad());
  11049.    SetResLoad(false);
  11050.    code = GetResource('CODE', id);
  11051.    SetResLoad(true);
  11052.    FailNILRes(code);
  11053.    /* We use MemAvailableNoCushion since MemAvailable could unload
  11054.       segments, and if segments are unloaded from within this patch
  11055.       the program crashes. */
  11056.    if (! *code && ! MemAvailableNoCushion(SizeResource(code)))
  11057.       FailOSErr(memFullErr);
  11058.    SetResAttrs(code, GetResAttrs(code) & ~resLocked);
  11059.    FailResError();
  11060.    LoadResource(code);
  11061.    FailResError();
  11062.    return(code);
  11063. }
  11064.  
  11065. /* For its own reasons, perhaps related to using FAR code, THINK C seems
  11066.    to patch the _LoadSeg trap. THINK C also makes code resources locked.
  11067.    Unfortunately, this prevents _LoadSeg from calling MoveHHi on segments,
  11068.    even if the low-memory global SegHiEnable is non-zero. Having code
  11069.    segments low in memory leads to severe heap fragmentation when pointers
  11070.    are allocated above the code segments. This patch will load the resource,
  11071.    move it to the top of the heap, and lock it there. This patch will also
  11072.    trigger an exception if the resource couldn't be loaded or if there isn't
  11073.    enough memory to load the resource. */
  11074. static pascal void PatchLoadSeg(ResID segnum)
  11075. {
  11076.    Handle code;
  11077.    
  11078.    PATCH_ENTER();
  11079.    code = GetCodeResource(segnum);
  11080.    if (code && LMGetSegHiEnable()) {
  11081.       MoveHHi(code);
  11082.       HLock(code);
  11083.    }
  11084.    PATCH_RETURN(gPatchLoadSeg);
  11085. }
  11086.  
  11087. // this has nothing to do with the above patch, but could be useful
  11088. // to someone who wants to load a segment
  11089.  
  11090. pascal void LoadSegTrap(ResID seg) = _LoadSeg; 
  11091.  
  11092. /* load the segment */
  11093. static void LoadSeg(ResID seg)
  11094. {
  11095.    asm {
  11096.             move.w seg, -(sp)
  11097.             bra.s @1    /* call LoadSeg */
  11098.             bra.s @2    /* LoadSeg returns here */
  11099.             nop          /* fill up two bytes */
  11100.       @1:   LoadSegTrap
  11101.       @2:
  11102.    }
  11103. }
  11104. -- 
  11105. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  11106. "These beetles were long considered to be very rare because very few
  11107. entomologists look for beetles in the mountains, in winter, at night,
  11108. during snow storms." -- Purves W. K., et al, "Life: The Science of
  11109.  
  11110. ---------------------------
  11111.  
  11112. >From mssmith@afterlife.ncsc.mil (M. Scott Smith)
  11113. Subject: Speeding up animation; questions
  11114. Date: Sun, 27 Feb 1994 23:49:11 GMT
  11115. Organization: The Great Beyond
  11116.  
  11117. Ramble alert!  (This one's kinda long..)
  11118.  
  11119. Hi gang!
  11120.  
  11121.    I found a few minutes this weekend to revisit my much-procrastinated
  11122. tour into the development of Mac arcade games..  (Well, I haven't really
  11123. procrastinated, I just haven't had the time.  :(
  11124.  
  11125.    I've been developing a direct-screen animation toolkit which I'll
  11126. (eventually) be using to write games.  I'm now working on the "animation
  11127. engine" -- the heart of the game where all of the animation will be
  11128. performed.
  11129.  
  11130.    What I'll do is describe the method(s) I'm thinking about using.  Any
  11131. comments on my methods would be greatly appreciated; don't hesitate to
  11132. tell me that I'm going about it all the wrong way.
  11133.  
  11134.    The type of game I'll be writing will probably be similar to Lemmings,
  11135. in that I need to have support for lots of (fairly small) sprites.  Having
  11136. 30 separate sprites on screen and moving is not too much to ask.  (It may
  11137. be too much to program, but...)  But they'll generally be 32x32 pixels or
  11138. smaller, with room for a few larger ones.  I'll write this game to fill
  11139. the 12" monitor -- 512x384 pixels.  It will only support color, probably
  11140. require System 7, etc.  And it uses "direct-screen" drawing; filling the
  11141. video RAM with bytes for instant gratification.
  11142.  
  11143.    First question: will direct-screen animation work on the PowerPC, if
  11144. the loosely-defined "correct" way of doing it is followed?  From what I
  11145. have heard and seen of the PowerPC, it doesn't seem like there's any
  11146. inhibiting factors against using direct-screen graphics.  But I haven't
  11147. gotten my hands on a PPC compiler yet to try it out.
  11148.  
  11149.    Ok.  So, here's how I'll do my animation: I'll have two buffers (at
  11150. about 384k each -- this game will probably require at least 2 megs) the
  11151. size of the game area.  One of these buffers contains the background.
  11152. The other buffer is a "work" buffer.  First I copy the entire background
  11153. to the work buffer.  Then I mask or draw all of my sprites on top of the
  11154. background in the work buffer.  Then I copy the work buffer to the screen.
  11155. The process continues for each frame of animation.  I'll sync the drawing
  11156. with the electron beam, if necessary.
  11157.  
  11158.    From previous discussions here and elsewhere, this seems to be an
  11159. accepted method that will result in flicker-free animation.  It's memory-
  11160. intensive, but as I have described it, relatively easy to implement.
  11161.  
  11162.    But (at least) two things bother me: there's two copies of 512x384 bytes
  11163. occurring for each frame of animation: first the copy of the background
  11164. into the work buffer, then the copy of the work buffer to the screen.  Not
  11165. to mention all the copies of the sprites -- possibly up to 30.
  11166.  
  11167.    I know there are probably ways to prevent copying the entire screen,
  11168. and I could use some suggestions.  I could keep track of a "dirty rectangle"
  11169. that needs updating, but for my game I'll have sprites all over the screen
  11170. so it seems like I'll need to copy the whole screen anyway.  Keeping a
  11171. list of rectangles needing to be copied is another possibility, but this
  11172. will result in a lot of overhead and required computations, and numerous
  11173. little copies that would probably make it slower.
  11174.  
  11175.    I did some (rough) experimentation.  I took two sprites, each 512x384,
  11176. and blasted them to the screen in alternating order for 30 seconds,
  11177. incrementing a counter with each blast.  I did this on a Macintosh IIfx.
  11178. Here are the results:
  11179.  
  11180.   No optimizations:        356 frames / 30 seconds or 11.87 frames/s
  11181.   Compiled for 68020 and up,
  11182.     with all Symantec C++ opts: 554 frames / 30 seconds or 18.47 frames/s
  11183.  
  11184.    Comments: I used the Symantec C++ compiler.  And keep in mind I'll
  11185. have at least two full copies going on for each frame, plus all the work
  11186. involved in drawing the numerous sprites, overhead from the rest of the
  11187. game's I/O and logic, etc.  I don't think a bad prediction would be that
  11188. with those results, I might end up with around 6 frames per second.  Isn't
  11189. that pretty bad?  For arcade games, how many "complete" screen updates / s
  11190. are there usually?  (I've also got to remind myself that I'm developing
  11191. this on a IIfx -- which (for now) is still speedier than the average Mac.)
  11192.  
  11193.    Here's the code I use for blasting the 512x384 sprite to the screen:
  11194.  
  11195. void
  11196. Sprite::Plot(long x, long y)
  11197. {
  11198.   long        *longPtr, *longPtr2;
  11199.   register long    xx;
  11200.   register long    yy;
  11201.   long        sum1, sum2;
  11202.   
  11203.   if (data_allocated == 1)
  11204.   {
  11205.     HLock(theData);
  11206.     
  11207.     longPtr2 = (long *)(*theData);
  11208.     sum1 = y + height;
  11209.     sum2 = x + width;
  11210.     for (yy=y; yy<sum1; yy++)
  11211.     {
  11212.       longPtr = (long *)(x + theScreen->line_ptr[yy]);
  11213.       for (xx=x; xx<sum2; xx+=4)
  11214.         *longPtr++ = *longPtr2++;
  11215.     }
  11216.     
  11217.     HUnlock(theData);
  11218.   }
  11219.   
  11220. }
  11221.  
  11222.    line_ptr is an array of the addresses that start each line of the video
  11223. RAM.  Also, the way this is written, it requires the width and the height
  11224. of the sprite to be divisible by 4.  theData is just a chunk of memory
  11225. containing a stream of bytes representing the colors of the 8-bit sprites.
  11226.  
  11227.    Can anyone think of ways to optimize this?  I could post the dissassembly
  11228. but this message is long enough.  (I'm still a stranger to assembly
  11229. language so I have trouble noting obvious inefficiencies in the dissasembly.)
  11230.  
  11231.    (And if you guys don't kill me first, I'd love to post my version of
  11232. a masking copy routine so you all can tell me how horribly inefficient
  11233. THAT is..  Although it seems pretty quick.)
  11234.  
  11235.    (How would CopyBits compare?)
  11236.  
  11237.    Well, I guess that's about it.  For the type of game I've described,
  11238. am I approaching this in the correct manner?  If not, what other techniques
  11239. should I try?  If so, how can I approach it more efficiently?  I'm
  11240. looking for speed.  I'm not sure if I've found it yet.
  11241.  
  11242.    Again, ANY comments would be appreciated.  I've only gotten this far
  11243. by generous help from Ingemar Ragnemalm, Matt Hall, Tom Dowdy, Juri
  11244. Munkki, Rick Holzgrafe, Jon Witte, Julian Harris, and others..  (Sorry
  11245. if I killed anyone's spelling; you probably don't even remember helping
  11246. me, as I first posed these types of questions back in November of '92.
  11247. I archived your messages and have referred to them often.)
  11248.  
  11249. Later!
  11250.  
  11251. - M. Scott Smith     [mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu]
  11252.  
  11253.   Macintosh developer, student, ski bum.  Eater of Kellogg's Frosted Flakes.
  11254.  
  11255.   "Last chance for fuel on information highway."
  11256.  
  11257.  
  11258. +++++++++++++++++++++++++++
  11259.  
  11260. >From john_werner@taligent.com (John Werner)
  11261. Date: Mon, 28 Feb 1994 03:18:49 GMT
  11262. Organization: Taligent, Inc.
  11263.  
  11264. In article <1994Feb27.234911.14595@afterlife.ncsc.mil>,
  11265. mssmith@afterlife.ncsc.mil (M. Scott Smith) wrote:
  11266.  
  11267. >    But (at least) two things bother me: there's two copies of 512x384 bytes
  11268. > occurring for each frame of animation: first the copy of the background
  11269. > into the work buffer, then the copy of the work buffer to the screen.  Not
  11270. > to mention all the copies of the sprites -- possibly up to 30.
  11271.  
  11272. You're right.  This will be too slow, as your experiment below shows.
  11273.  
  11274. > Keeping a
  11275. > list of rectangles needing to be copied is another possibility, but this
  11276. > will result in a lot of overhead and required computations,
  11277.  
  11278. This is probably the way to do it.  If you try hard enough you can optimize
  11279. the list of rectangles by merging ones that overlap or are adjacent.  To
  11280. make things more complicated, you need to do this all twice: once for
  11281. copying from your background bitmap to the work buffer, then for the copy
  11282. from the work buffer to the screen.  When copying from the background, you
  11283. only need to copy the areas corresponding to the sprites' old locations (to
  11284. erase them).  When copying to the screen, you need the union of the old and
  11285. new sprite locations, to erase the old sprites and draw the new ones. 
  11286.  
  11287. Another strategy would be to divide the screen up into an even grid of
  11288. rectangles.  If a rectangle contains any sprites then it gets copied;
  11289. otherwise it doesn't.  This would work best if you know your sprites are
  11290. usually going to be concentrated in certain areas rather than randomly
  11291. scattered around the screen.
  11292.  
  11293. > and numerous little copies that would probably make it slower.
  11294.  
  11295. You should test this before you assume it's true.  If the bit depths and
  11296. color tables all match, most of the time is going to be spent writing bits
  11297. to the screen.
  11298.  
  11299. Other tips:
  11300.  
  11301. Make sure all of your bitmaps are longword-aligned.
  11302.  
  11303. Make sure all the color tables and bit depths match.  CopyBits can slow
  11304. down a lot when they don't.  With a custom blitter life will be a lot
  11305. simpler if you don't have to worry about such things.
  11306.  
  11307. Expand the left and right edges of areas to be copied so that they end on
  11308. byte (or word, or longword) boundaries, so CopyBits or your custom blitter
  11309. has a much simpler job to do.
  11310.  
  11311. > I don't think a bad prediction would be that
  11312. > with those results, I might end up with around 6 frames per second.  Isn't
  11313. > that pretty bad?
  11314.  
  11315. Yes.  You need 20 fps or so to look at all decent.  30 would be even
  11316. better.
  11317.  
  11318. -- 
  11319. John Werner                          john_werner@taligent.com
  11320. Taligent, Inc.
  11321.  
  11322. +++++++++++++++++++++++++++
  11323.  
  11324. >From Turly.OConnor@isltd.insignia.com (Turly OConnor)
  11325. Date: 28 Feb 1994 10:39:45 -0600
  11326. Organization: UTexas Mail-to-News Gateway
  11327.  
  11328. M. Scott Smith had a few questions regarding speeding up his sprite drawer.
  11329. Here's one:
  11330.  
  11331.   - Don't bother with locking and unlocking the handle!
  11332.     Since you don't call anything which moves memory, there's no point.
  11333.     The trap dispatcher overhead is likely to be bigger than your entire
  11334.     sprite copying loop!
  11335.  
  11336.   - Re-organise your code so you use
  11337.       do {
  11338.          *longPtr++ = *spritePtr++;
  11339.       } while (--xx);
  11340.     instead of the for(;;) loop you've currently got.
  11341.  
  11342.   - If you know the sprites are 32 pixels wide, unroll your x-loop so
  11343.     that you write all 32 pixels at once; in fact, get rid of your x-loop
  11344.     altogether.
  11345.  
  11346. Oops, sorry, more than one but what the heck!
  11347.  
  11348. Have fun!
  11349.  
  11350. --turly
  11351.  
  11352. +++++++++++++++++++++++++++
  11353.  
  11354. >From al@crucible.powertools.com (Al Evans)
  11355. Date: 28 Feb 94 16:51:00 GMT
  11356. Organization: PowerTools, Austin, Texas
  11357.  
  11358. In article <1994Feb27.234911.14595@afterlife.ncsc.mil> mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  11359.  
  11360. [Sprite animation, wants to support up to 30 32X32 sprites]
  11361.  
  11362. >   First question: will direct-screen animation work on the PowerPC, if
  11363. >the loosely-defined "correct" way of doing it is followed?  From what I
  11364. >have heard and seen of the PowerPC, it doesn't seem like there's any
  11365. >inhibiting factors against using direct-screen graphics.  But I haven't
  11366. >gotten my hands on a PPC compiler yet to try it out.
  11367.  
  11368. Consider the possibility that you may be working on the wrong thing.
  11369. First, it's difficult to beat CopyBits by much when you're using
  11370. srcCopy mode and everything is ligned up right (assuming 8-bit color
  11371. with value of ctSeed equal in offscreen GWorld and onscreen device).
  11372. Second, remember that even eliminating the offscreen-to-onscreen copy
  11373. COMPLETELY will only make you about 30% faster (which may be what you
  11374. have to do to get the performance you want). Third, remember that
  11375. CopyBits will always be supported and will work on all Macs.
  11376.  
  11377. [Description of animation loop: offscreen-to-offscreen copy of
  11378. entire background, offscreen-to-offscreen to sprites, offscreen-to-
  11379. onscreen of composite]
  11380.  
  11381. >   I know there are probably ways to prevent copying the entire screen,
  11382. >and I could use some suggestions.  I could keep track of a "dirty rectangle"
  11383. >that needs updating, but for my game I'll have sprites all over the screen
  11384. >so it seems like I'll need to copy the whole screen anyway.  Keeping a
  11385. >list of rectangles needing to be copied is another possibility, but this
  11386. >will result in a lot of overhead and required computations, and numerous
  11387. >little copies that would probably make it slower.
  11388.  
  11389. My tests indicate that the overhead of maintaining a sorted list of
  11390. update Rects is small compared to the time saved in copying. Look at
  11391. it this way: if you only save 4 pixels at each side of the window,
  11392. that's 4 * 384 * 2 bytes that don't have to be moved, or enough bytes
  11393. for 3 32X32X8 sprites.
  11394.  
  11395. [timing tests]
  11396.  
  11397. >I might end up with around 6 frames per second.  Isn't
  11398. >that pretty bad?  For arcade games, how many "complete" screen updates / s
  11399. >are there usually?  (I've also got to remind myself that I'm developing
  11400. >this on a IIfx -- which (for now) is still speedier than the average Mac.)
  11401.  
  11402. I've done some pretty extensive speed testing lately in finishing up
  11403. my Graphic Elements system (watch this space for announcements Real Soon
  11404. Now). I use a somewhat similar double buffering technique. I find that
  11405. I can get 8 frames/second on a Mac IIsi with 30 32X32 sprites scattered
  11406. over the screen and moving randomly. This drops to 7 fps with a "load",
  11407. i.e. collision processing. On a Quadra 800, the numbers are 33 and
  11408. 29, respectively. I do not believe that these numbers can be substantially
  11409. improved without going to a different animation scheme (but I'd love
  11410. to be proved wrong:-).
  11411.  
  11412. [...]
  11413.  
  11414. >   Well, I guess that's about it.  For the type of game I've described,
  11415. >am I approaching this in the correct manner?  If not, what other techniques
  11416. >should I try?  If so, how can I approach it more efficiently?  I'm
  11417. >looking for speed.  I'm not sure if I've found it yet.
  11418.  
  11419. "Correct" is a big word, but you're approaching it in the only highly
  11420. general manner (i.e. offscreen construction, off-to-onscreen copy).
  11421. If I were you, I would look at the following possibilities: 1) Use
  11422. smaller sprites or fewer of them; 2) Keep a list of dirty Rects and
  11423. copy only what you have to; 3) Try to "offset" your frame generation
  11424. so that, for example, only 1/3 of the sprites need updating on a
  11425. given frame (of course this only works in conjunction with 2).
  11426.  
  11427.                     --Al Evans--
  11428. -- 
  11429.  
  11430. Al Evans                         Tu causes, tu causes
  11431. al@crucible.powertools.com               C'est tout ce que tu sais faire
  11432. cs.utexas.edu!crucible!al                     -- LaVerdure
  11433.  
  11434. +++++++++++++++++++++++++++
  11435.  
  11436. >From mxmora@unix.sri.com (Matt Mora)
  11437. Date: 28 Feb 1994 09:33:03 -0800
  11438. Organization: SRI International, Menlo Park, CA
  11439.  
  11440. In article <1994Feb27.234911.14595@afterlife.ncsc.mil> mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  11441.  
  11442.  
  11443. >   I know there are probably ways to prevent copying the entire screen,
  11444. >and I could use some suggestions.  I could keep track of a "dirty rectangle"
  11445. >that needs updating, but for my game I'll have sprites all over the screen
  11446. >so it seems like I'll need to copy the whole screen anyway.  Keeping a
  11447. >list of rectangles needing to be copied is another possibility, but this
  11448. >will result in a lot of overhead and required computations, and numerous
  11449. >little copies that would probably make it slower.
  11450.  
  11451. You get lots of suggestions about optimizations but one thing you should
  11452. remember, try any move as little bytes as possible. You will never
  11453. be able to an entire screen in one tick on apples current hardware. Maybe
  11454. this will be possible in PowerPC and we will finally be able to play games
  11455. with a scrolling background. :-)
  11456.  
  11457. If you have many sprites union their rects and copy that data. Though
  11458. you are copying more data than you need to you should win by being able
  11459. to move longwords at a time. 
  11460.  
  11461.  
  11462. Xavier
  11463.  
  11464.  
  11465.  
  11466. -- 
  11467. ___________________________________________________________
  11468. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  11469. SRI International                       mxmora@unix.sri.com
  11470. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  11471.  
  11472. +++++++++++++++++++++++++++
  11473.  
  11474. >From Arsenault_C@msm.cdx.mot.com (Chris Arsenault)
  11475. Date: Mon, 28 Feb 1994 13:26:21 -0500
  11476. Organization: Motorola Codex
  11477.  
  11478. In article <1994Feb27.234911.14595@afterlife.ncsc.mil>,
  11479. mssmith@afterlife.ncsc.mil (M. Scott Smith) wrote:
  11480.  
  11481. >    The type of game I'll be writing will probably be similar to Lemmings,
  11482. > in that I need to have support for lots of (fairly small) sprites.  Having
  11483. > 30 separate sprites on screen and moving is not too much to ask.  (It may
  11484. > be too much to program, but...)  But they'll generally be 32x32 pixels or
  11485. > smaller, with room for a few larger ones.  I'll write this game to fill
  11486. > the 12" monitor -- 512x384 pixels.  It will only support color, probably
  11487. > require System 7, etc.  And it uses "direct-screen" drawing; filling the
  11488. > video RAM with bytes for instant gratification.
  11489.  
  11490. >    Well, I guess that's about it.  For the type of game I've described,
  11491. > am I approaching this in the correct manner?  If not, what other techniques
  11492. > should I try?  If so, how can I approach it more efficiently?  I'm
  11493. > looking for speed.  I'm not sure if I've found it yet.
  11494.  
  11495.  
  11496. Some comments:
  11497.  - if you have a lot of sprites moving on screen then it may be better to
  11498. optimize the background copy operation between your saved background and
  11499. your work buffer (the one you do a CopyBits to the screen with).  You can
  11500. unroll a loop in assembler and refresh your work buffer real fast. Then you
  11501. can do all the real drawing in your work buffer. Given your type of game
  11502. you have to determine if the overhead of tracking and updating invalid
  11503. rects is worth the time. Generally the more smaller rects you need to
  11504. update, the easier it is to save time by just doing a real fast copy of the
  11505. buffer. I would calculate a dirty rect for all sprites drawn in the work
  11506. buffer though, so what I actually have to copy to the screen would remain
  11507. the minimal update rect. (Don't forget to adjust this update rect to the
  11508. proper multiple of 32 for both left and right edges!) Once calculated, you
  11509. use this rect to restore the background on the next pass!
  11510.  
  11511. - You really don't want to play with direct screen drawing for this style
  11512. of animation for a couple of reasons:  Directly writing to the video memory
  11513. can get you clobbered by some graphics accellerators. If you allow the user
  11514. to switch out to the Finder and s/he changes the depth of the monitor on
  11515. the fly, and you don't check it, you're in ds trouble.  Also, although you
  11516. can sync up to obtain a nice smooth animation with vertical blanking you
  11517. still can end up trying to beat the electron gun.  If, in drawing directly
  11518. to video memory, you end up drawing the last item in your sprite drawlist
  11519. near the top of the screen when the vertical blanking interval is over,
  11520. you'll end up with a tearing effect. There is overhead in trying to order
  11521. sprites, both for front-back and top-bottom drawing (to provide tear-free
  11522. animation). Also, given you may have a higher refresh rate on some
  11523. monitors, you'd be playing with an unknown. (Spend more of your development
  11524. time trying to avoid hardware related issues - you'll thank me later! ;-) )
  11525.  
  11526. - I'm assuming that you're going to look through your GDeviceList and set
  11527. up your VBL task in the correct slot to synch with the monitor or monitors.
  11528. Again, be aware of different refresh rates for monitors.
  11529.  
  11530. - Sometimes you don't need a high frame rate to achieve the appearence of a
  11531. very fast frame rate. For example if you attain 30fps moving your sprites 1
  11532. pixel position on the screen you can achieve the same "look" by moving your
  11533. sprites 2 pixel positions for only 15 fps. AND... if you're tearing at
  11534. 30fs, but tear-free at 15 fps...the user will prefer the smooth look vs the
  11535. choppy.     
  11536.  
  11537. - Do everything in your offscreen buffer then use CopyBits to move the
  11538. dirtyRect to screen...even if CopyBits has to make the transition to
  11539. different bit depths, chances are it will stay ahead of the electron gun
  11540. and you'll still get robust, smooth flicker-free animation and your game
  11541. will have a nice long life. (See Inside Mac III, p20. Although the values
  11542. are off, the ideas are still valid!)
  11543.  
  11544. - The only time direct screen drawing is really affordable (or necessary)
  11545. is when you're doing extremely minimal updates to an existing image using
  11546. polygons and the like or performing a non-rectangular copy (for example
  11547. doing a custom block copy that skews the image to some arbitrary angle.)
  11548. (Rule of thumb - if you have a lot of game event overhead time, like
  11549. network games or computing intelligence for chars, then simplify the
  11550. graphics to absolute minimum - most successful with poly or solid color
  11551. updates)  Sounds like your sprites do internal animation - if this is the
  11552. case you have to do complete draw of the new sprite each pass anyway.
  11553.  
  11554. Also it might be nicer to concentrate on supporting B&W versions if
  11555. possible...in terms of market there is still a lot of B&W Mac's out
  11556. there...including a lot of new PowerBooks.
  11557.  
  11558. BTW - in Sprite::Plot, you can increase the speed considerably by unrolling
  11559. the loop (for every iteration of the loop code overhead try to copy as many
  11560. longwords as you can!)
  11561.  
  11562.  
  11563. Good luck and put me on your beta test list!
  11564. Chris
  11565.  
  11566. -- 
  11567. #include <UsualLegalDisclaimers.h>
  11568. #define AnnoyThem  "This bug's for you!"
  11569.  
  11570. +++++++++++++++++++++++++++
  11571.  
  11572. >From u9119523@sys.uea.ac.uk (Graham Cox)
  11573. Date: Tue, 1 Mar 1994 18:22:04 GMT
  11574. Organization: School of Information Systems, UEA, Norwich
  11575.  
  11576. In article <1994Feb27.234911.14595@afterlife.ncsc.mil>,
  11577. mssmith@afterlife.ncsc.mil (M. Scott Smith) wrote:
  11578.  
  11579. > Ramble alert!  (This one's kinda long..)
  11580. > Hi gang!
  11581. >    I found a few minutes this weekend to revisit my much-procrastinated
  11582. > tour into the development of Mac arcade games..  (Well, I haven't really
  11583. > procrastinated, I just haven't had the time.  :(
  11584. >    I've been developing a direct-screen animation toolkit which I'll
  11585. > (eventually) be using to write games.  I'm now working on the "animation
  11586. > engine" -- the heart of the game where all of the animation will be
  11587. > performed.
  11588. [deleted]
  11589.  
  11590.  
  11591. > - M. Scott Smith     [mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu]
  11592. >   Macintosh developer, student, ski bum.  Eater of Kellogg's Frosted Flakes.
  11593. >   "Last chance for fuel on information highway."
  11594.  
  11595. If you're the type who likes to reinvent the wheel, (like we all are at
  11596. times!) then go ahead and don't let me stop you. 
  11597.  
  11598. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11599. identically to the way you describe, with a pair of offscreen work areas.
  11600. It generates sprites from PICT or cicn resources, and uses the time manager
  11601. to give sub-tick accuracy. It also has hooks for writing custom blitting
  11602. routines, and comes with one for 8-bit colour direct screen blitting, or
  11603. can use CopyBits. The example program turned in something like 100
  11604. frames/sec on a Centris 610 animating 5 or 6 50 x 50 pixel sprites. I got
  11605. 64 frames/sec on my IIsi! It also has full layer support and collision
  11606. detection. It is stable and easy to use- I rolled it into one of my C
  11607. applications in one evening and never had the slightest trouble compiling
  11608. it.
  11609.  
  11610.  
  11611. Now I have SpriteWorld, I am never going to write another sprite-animation
  11612. routine again!
  11613.  
  11614. I would also say that I have nothing whatsoever to do with its author, but
  11615. I am one very satisfied "customer" -and word-of-mouth advertising is the
  11616. best kind!
  11617.  
  11618. A technical point- SpriteWorld uses linked lists to store the data for each
  11619. sprite, not arrays. I wonder which method is faster? I reckon that the
  11620. performance is not bound by this anyway, but on the number of pixels
  11621. blitted per frame. SpriteWorld seems to go to a lot of trouble to minimise
  11622. the number of pixels blitted per frame, adding a little code overhead to
  11623. check this, but its high performance seems to suggest that this is a good
  11624. strategy.
  11625.  
  11626. - ------------------------------------------------------------------------
  11627. Love & BSWK, Graham
  11628.  
  11629. -Everyone is entitled to their opinion, no matter how wrong they may be...
  11630. - ------------------------------------------------------------------------
  11631.  
  11632. +++++++++++++++++++++++++++
  11633.  
  11634. >From Tony Myles <tony.myles@3do.com>
  11635. Date: 1 Mar 1994 22:55:29 GMT
  11636. Organization: The 3DO Company
  11637.  
  11638. In article <u9119523-010394182204@case1.sys.uea.ac.uk> Graham Cox,
  11639. u9119523@sys.uea.ac.uk writes:
  11640. >If you're the type who likes to reinvent the wheel, (like we all are at
  11641. >times!) then go ahead and don't let me stop you. 
  11642. >
  11643. >BUT- this has already been done- "SpriteWorld" (archive sites) works
  11644. >identically to the way you describe, with a pair of offscreen work areas.
  11645. >It generates sprites from PICT or cicn resources, and uses the time
  11646. manager
  11647. >to give sub-tick accuracy. It also has hooks for writing custom blitting
  11648. >routines, and comes with one for 8-bit colour direct screen blitting, or
  11649. >can use CopyBits. The example program turned in something like 100
  11650. >frames/sec on a Centris 610 animating 5 or 6 50 x 50 pixel sprites. I got
  11651. >64 frames/sec on my IIsi! It also has full layer support and collision
  11652. >detection. It is stable and easy to use- I rolled it into one of my C
  11653. >applications in one evening and never had the slightest trouble compiling
  11654. >it.
  11655.  
  11656. There will be a new version of SpriteWorld out soon. I have sped it up
  11657. about 20-30% using the custom blitter, and about 20% more on top of that
  11658. using compiled sprites. Numerous bug fixes were rolled in as well.
  11659.  
  11660. >Now I have SpriteWorld, I am never going to write another
  11661. sprite-animation
  11662. >routine again!
  11663. >
  11664. >I would also say that I have nothing whatsoever to do with its author,
  11665. but
  11666. >I am one very satisfied "customer" -and word-of-mouth advertising is the
  11667. >best kind!
  11668.  
  11669. Thanks, this is good to hear. Any chance of a SpriteWorld based version
  11670. of Desk Invaders?
  11671.  
  11672. >A technical point- SpriteWorld uses linked lists to store the data for
  11673. each
  11674. >sprite, not arrays. I wonder which method is faster? I reckon that the
  11675. >performance is not bound by this anyway, but on the number of pixels
  11676. >blitted per frame. SpriteWorld seems to go to a lot of trouble to
  11677. minimise
  11678. >the number of pixels blitted per frame, adding a little code overhead to
  11679. >check this, but its high performance seems to suggest that this is a good
  11680. >strategy.
  11681.  
  11682. Early versions of SpriteWorld used arrays, when I switched to doubly
  11683. linked lists it made no difference (for better or worse) in terms of
  11684. speed but it did greatly increase flexibility. 
  11685. As far as code overhead goes, I have found that almost anything you can
  11686. do to reduce the number of pixels you have to move, results in a faster
  11687. frame rate. During the development of SpriteWorld this has proved true in
  11688. almost all cases. However, when optimizing any algorithm, you have to
  11689. keep in mind the most common case. Take for example the case of
  11690. overlapping sprites. You might go to a lot of trouble to avoid blitting
  11691. the overlapping areas of the screen more than once per frame, but if your
  11692. sprites don't overlap much (or at all) this doesn't make sense. The
  11693. overhead of calculating the difference of the overlapping rects would
  11694. just slow down the most common case. For something like SpriteWorld, this
  11695. is particularly tricky, since I don't know for sure what the most common
  11696. case will be. Indeed, there is a danger of optimizing for the most common
  11697. case too much, to where the code is no longer good for anything BUT the
  11698. most common case (which may be OK, again depending on the application).
  11699. Inevitably it becomes a question of a tradeoffs between application
  11700. specific optimizations, and code generality and reusability.
  11701.  
  11702. ...Tony
  11703. - ---------------------------------------------
  11704. Tony Myles             work: tony.myles@3do.com
  11705. The 3DO Company        home: suiryu@aol.com
  11706.  
  11707. +++++++++++++++++++++++++++
  11708.  
  11709. >From deweeset@ptolemy1.rdrc.rpi.edu (Thomas E. DeWeese)
  11710. Date: 1 Mar 1994 20:52:02 GMT
  11711. Organization: Rensselaer Polytechnic Institute, Troy NY, USA
  11712.  
  11713. In article <1994Feb27.234911.14595@afterlife.ncsc.mil>,
  11714. M. Scott Smith <mssmith@afterlife.ncsc.mil> wrote:
  11715. >Ramble alert!  (This one's kinda long..)
  11716.  
  11717. >   I've been developing a direct-screen animation toolkit which I'll
  11718. >(eventually) be using to write games.  I'm now working on the "animation
  11719. >engine" -- the heart of the game where all of the animation will be
  11720. >performed.
  11721.  
  11722. >   The type of game I'll be writing will probably be similar to Lemmings,
  11723. >in that I need to have support for lots of (fairly small) sprites.  Having
  11724. >30 separate sprites on screen and moving is not too much to ask.  (It may
  11725. >be too much to program, but...)  But they'll generally be 32x32 pixels or
  11726. >smaller, with room for a few larger ones.  I'll write this game to fill
  11727. >the 12" monitor -- 512x384 pixels.  It will only support color, probably
  11728. >require System 7, etc.  And it uses "direct-screen" drawing; filling the
  11729. >video RAM with bytes for instant gratification.
  11730.     Just a note, 30 32x32 sprites in a 512x384 window is pretty
  11731. crowded (in my opinion).  
  11732.  
  11733. >   But (at least) two things bother me: there's two copies of 512x384 bytes
  11734. >occurring for each frame of animation: first the copy of the background
  11735. >into the work buffer, then the copy of the work buffer to the screen.  Not
  11736. >to mention all the copies of the sprites -- possibly up to 30.
  11737.  
  11738.     Yes this is a problem.  I strongly suggest the 'dirty'
  11739. rectangle solution propsed by so many others.  Using an insertion sort
  11740. to order them top to bottom, left to right shouldn't be so bad, for
  11741. only 30-60 elems.
  11742.  
  11743. >game's I/O and logic, etc.  I don't think a bad prediction would be that
  11744. >with those results, I might end up with around 6 frames per second.  Isn't
  11745. >that pretty bad?
  11746.     Yes, as others have noted 20-30fps is where you want to be.
  11747.  
  11748.  
  11749. As for your code:
  11750.     Keep your pixmap locked down, actually it doesn't matter too
  11751. much for this function since you can't cause a handle to move.
  11752.     Don't mess up a nice tight function with stuff like:
  11753.           if (data_allocated == 1)
  11754.     Test it once before you start blitting.  
  11755.  
  11756.     This should give you a pretty good starting place to start
  11757. optomizing your asm. The following is off the top of my head so it
  11758. might not compile.
  11759.  
  11760.  
  11761. long rowBytesDiv4;  /* row bytes divided by 4 (or >> 2 if your smart) */
  11762.  
  11763. void
  11764. Sprite::Plot(register long x, register long y)
  11765. {
  11766.   register long    *longPtr, *longPtr2;
  11767.   register long *endLn, *endImg;
  11768.   register long rowOffset = rowBytesDiv4 - width;  /* possibly precomputed */
  11769.  
  11770.  longPtr2 = (long *)(*theData);
  11771.  endImg = longPtr2+width*height;
  11772.  
  11773.  longPtr = (long *)(x + theScreen->line_ptr[y]);
  11774.  
  11775.  while (longPtr2<endImg)
  11776.    {
  11777.      longPtr += rowOffset;
  11778.      endLn = longPtr+width;
  11779.      while (longPtr<endLn)
  11780.        *longPtr++ = *longPtr2++;  /* if width is known unroll this using
  11781.                            * 68000 post increment stuff, and movem
  11782.                    */
  11783.    }
  11784. }
  11785.  
  11786. >   (How would CopyBits compare?)
  11787.     CopyBits has a fair amount of over head so for small blits it
  11788. loses (it needs to check colorTables, bit depths, clipRgns, and all
  11789. that junk) But once it get's going you won't be able to beat it.  So
  11790. for large general area copies you can only hope to match it's speed.
  11791. But for small known size areas you can cream it.
  11792.     BTW the above code won't get you any closer to animating
  11793. 512x384 at 30fps (if it did, we'd have Sonic THH on the market by
  11794. now), it will make it possible to animate your 32x32 icons at a reasonable
  11795. speed if you use a dirty rectangle scheme.  Also don't forget your basic
  11796. math.  If your sprite moves < 13 pixes blit one rectangle that encloses both
  11797. the new, and old location (45x45 = 2025 pixles, 32x32x2 = 2048 pixels).
  11798.  
  11799.     +-----+                     +--------+
  11800.     |##+-----+                    |#####   | one larger blit
  11801.     |##|.....| two 32x32 blits            |##......|
  11802.     +--|.....|                    |  ......|
  11803.            +-----+                    +--------+
  11804.  
  11805.     There is a trade off in that fixed size blits will be faster,
  11806. due to loop unrolling etc... than a variable sized loop (so you might
  11807. try haveing fixed width, and variable height, so the width is unrolled
  11808. and the height isn't.  You might have a function for widths of 32, 36,
  11809. 40, and 44.  You could then have an array of function pointers for
  11810. dispatching appropriately.
  11811.  
  11812. -- 
  11813.  
  11814. Thomas DeWeese         "If it helps you, just think of people using swear 
  11815. deweeset@rdrc.rpi.edu   words as truck drivers on the Information Superhighway"
  11816.                              -- Matthias Neeracher
  11817.  
  11818. +++++++++++++++++++++++++++
  11819.  
  11820. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  11821. Date: 2 Mar 1994 10:40:16 GMT
  11822. Organization: Royal Institute of Technology, Stockholm, Sweden
  11823.  
  11824. In <2l09tj$4i9@usenet.rpi.edu> deweeset@ptolemy1.rdrc.rpi.edu (Thomas E. DeWeese) writes:
  11825.  
  11826. >long rowBytesDiv4;  /* row bytes divided by 4 (or >> 2 if your smart) */
  11827.  
  11828. >>2 isn't very smart. It has strange semantics (precedence, signed/unsigned
  11829. etc) as well as is harder to read than a simple /4.
  11830.  
  11831. If your compiler doesn't generate a fast shift instead of a slow compile,
  11832. you have MUCH worse optimizations to worry about than hand-coding the
  11833. shift.
  11834.  
  11835. -- 
  11836.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  11837.   "It was, in fact, cool as all get-out.  Fortunately it was a little
  11838.    too late (historically speaking) to be groovy."
  11839.                      -- Dennis Pelton
  11840.  
  11841. +++++++++++++++++++++++++++
  11842.  
  11843. >From andrewwelc@aol.com (AndrewWelc)
  11844. Date: 2 Mar 1994 05:23:04 -0500
  11845. Organization: America Online, Inc.
  11846.  
  11847. >>
  11848. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11849. identically to the way you describe, with a pair of offscreen work areas.
  11850. <<
  11851. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11852. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11853. it.
  11854.  
  11855. The custom drawing routine just aren't all that optimized -- I recommend
  11856. writing your own if you plan to animate a reasonable number of sprites on
  11857. lower-end machines.  For the PowerPC, just use CopyBits().
  11858.  
  11859. Andrew
  11860.  
  11861. +++++++++++++++++++++++++++
  11862.  
  11863. >From andrewwelc@aol.com (AndrewWelc)
  11864. Date: 2 Mar 1994 05:23:07 -0500
  11865. Organization: America Online, Inc.
  11866.  
  11867. >>
  11868. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11869. identically to the way you describe, with a pair of offscreen work areas.
  11870. <<
  11871. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11872. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11873. it.
  11874.  
  11875. The custom drawing routine just aren't all that optimized -- I recommend
  11876. writing your own if you plan to animate a reasonable number of sprites on
  11877. lower-end machines.  For the PowerPC, just use CopyBits().
  11878.  
  11879. Andrew
  11880.  
  11881. +++++++++++++++++++++++++++
  11882.  
  11883. >From andrewwelc@aol.com (AndrewWelc)
  11884. Date: 2 Mar 1994 05:23:08 -0500
  11885. Organization: America Online, Inc.
  11886.  
  11887. >>
  11888. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11889. identically to the way you describe, with a pair of offscreen work areas.
  11890. <<
  11891. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11892. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11893. it.
  11894.  
  11895. The custom drawing routine just aren't all that optimized -- I recommend
  11896. writing your own if you plan to animate a reasonable number of sprites on
  11897. lower-end machines.  For the PowerPC, just use CopyBits().
  11898.  
  11899. Andrew
  11900.  
  11901. +++++++++++++++++++++++++++
  11902.  
  11903. >From andrewwelc@aol.com (AndrewWelc)
  11904. Date: 2 Mar 1994 05:23:05 -0500
  11905. Organization: America Online, Inc.
  11906.  
  11907. >>
  11908. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11909. identically to the way you describe, with a pair of offscreen work areas.
  11910. <<
  11911. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11912. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11913. it.
  11914.  
  11915. The custom drawing routine just aren't all that optimized -- I recommend
  11916. writing your own if you plan to animate a reasonable number of sprites on
  11917. lower-end machines.  For the PowerPC, just use CopyBits().
  11918.  
  11919. Andrew
  11920.  
  11921. +++++++++++++++++++++++++++
  11922.  
  11923. >From andrewwelc@aol.com (AndrewWelc)
  11924. Date: 2 Mar 1994 05:23:16 -0500
  11925. Organization: America Online, Inc.
  11926.  
  11927. >>
  11928. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11929. identically to the way you describe, with a pair of offscreen work areas.
  11930. <<
  11931. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11932. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11933. it.
  11934.  
  11935. The custom drawing routine just aren't all that optimized -- I recommend
  11936. writing your own if you plan to animate a reasonable number of sprites on
  11937. lower-end machines.  For the PowerPC, just use CopyBits().
  11938.  
  11939. Andrew
  11940.  
  11941. +++++++++++++++++++++++++++
  11942.  
  11943. >From andrewwelc@aol.com (AndrewWelc)
  11944. Date: 2 Mar 1994 05:23:18 -0500
  11945. Organization: America Online, Inc.
  11946.  
  11947. >>
  11948. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11949. identically to the way you describe, with a pair of offscreen work areas.
  11950. <<
  11951. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11952. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11953. it.
  11954.  
  11955. The custom drawing routine just aren't all that optimized -- I recommend
  11956. writing your own if you plan to animate a reasonable number of sprites on
  11957. lower-end machines.  For the PowerPC, just use CopyBits().
  11958.  
  11959. Andrew
  11960.  
  11961. +++++++++++++++++++++++++++
  11962.  
  11963. >From andrewwelc@aol.com (AndrewWelc)
  11964. Date: 2 Mar 1994 05:23:12 -0500
  11965. Organization: America Online, Inc.
  11966.  
  11967. >>
  11968. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11969. identically to the way you describe, with a pair of offscreen work areas.
  11970. <<
  11971. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11972. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11973. it.
  11974.  
  11975. The custom drawing routine just aren't all that optimized -- I recommend
  11976. writing your own if you plan to animate a reasonable number of sprites on
  11977. lower-end machines.  For the PowerPC, just use CopyBits().
  11978.  
  11979. Andrew
  11980.  
  11981. +++++++++++++++++++++++++++
  11982.  
  11983. >From andrewwelc@aol.com (AndrewWelc)
  11984. Date: 2 Mar 1994 05:23:13 -0500
  11985. Organization: America Online, Inc.
  11986.  
  11987. >>
  11988. BUT- this has already been done- "SpriteWorld" (archive sites) works
  11989. identically to the way you describe, with a pair of offscreen work areas.
  11990. <<
  11991. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  11992. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  11993. it.
  11994.  
  11995. The custom drawing routine just aren't all that optimized -- I recommend
  11996. writing your own if you plan to animate a reasonable number of sprites on
  11997. lower-end machines.  For the PowerPC, just use CopyBits().
  11998.  
  11999. Andrew
  12000.  
  12001. +++++++++++++++++++++++++++
  12002.  
  12003. >From andrewwelc@aol.com (AndrewWelc)
  12004. Date: 2 Mar 1994 05:23:15 -0500
  12005. Organization: America Online, Inc.
  12006.  
  12007. >>
  12008. BUT- this has already been done- "SpriteWorld" (archive sites) works
  12009. identically to the way you describe, with a pair of offscreen work areas.
  12010. <<
  12011. Sure -- SpriteWorld is good architecture (if you aren't going to do anything
  12012. with scrolling backgrounds, etc.), but in terms of raw animation speed, forget
  12013. it.
  12014.  
  12015. The custom drawing routine just aren't all that optimized -- I recommend
  12016. writing your own if you plan to animate a reasonable number of sprites on
  12017. lower-end machines.  For the PowerPC, just use CopyBits().
  12018.  
  12019. Andrew
  12020.  
  12021. +++++++++++++++++++++++++++
  12022.  
  12023. >From Tony Myles <tony.myles@3do.com>
  12024. Date: 2 Mar 1994 18:15:58 GMT
  12025. Organization: The 3DO Company
  12026.  
  12027. In article <2l1pe8$ehi@rmg01.prod.aol.net> AndrewWelc, andrewwelc@aol.com
  12028. writes:
  12029. >Sure -- SpriteWorld is good architecture (if you aren't going to do
  12030. anything
  12031. >with scrolling backgrounds, etc.), but in terms of raw animation speed,
  12032. forget
  12033. >it.
  12034.  
  12035. Forget it? Oooh, that stings. ;-)
  12036.  
  12037. >The custom drawing routine just aren't all that optimized -- I recommend
  12038. >writing your own if you plan to animate a reasonable number of sprites on
  12039. >lower-end machines.
  12040.  
  12041. So do I.  I have improved the blitters in SpriteWorld about 20%, but they
  12042. were really never intended to be used as is. They more or less serve as
  12043. examples, so that you can write your own that are more specific to your
  12044. animation. (ie. assuming 32x32 sprites or whatever).
  12045.  
  12046. >For the PowerPC, just use CopyBits().
  12047.  
  12048. Decide to give up on your PowerPC sprite compiler, Andrew?
  12049.  
  12050. ...Tony
  12051. - ---------------------------------------------
  12052. Tony Myles             work: tony.myles@3do.com
  12053. The 3DO Company        home: suiryu@aol.com
  12054.  
  12055. +++++++++++++++++++++++++++
  12056.  
  12057. >From al@crucible.powertools.com (Al Evans)
  12058. Date: 2 Mar 94 19:15:31 GMT
  12059. Organization: PowerTools, Austin, Texas
  12060.  
  12061. In another article in this thread (which has unfortunately expired from
  12062. my news spool), John Werner (john_werner@taligent.com) suggested a
  12063. strategy of dividing up the background into a grid of rectangles to limit
  12064. the amount of drawing that would be required for each update.
  12065.  
  12066. Since this kind of thing is easy to implement in Graphic Elements (took
  12067. me 26 lines of code, boast boast), I ran some tests. In these tests,
  12068. a) the moving graphics were 42 X 42 pixels, and b) the background
  12069. which was updated in any particular cell was the union of the rects
  12070. of all changed graphics in that cell. I used two different sets of
  12071. test conditions. 
  12072.  
  12073. In the first test, the graphics were all in two even lines, moving to the 
  12074. right to the edge of the window, then dropping down half their height
  12075. and moving to the left. When they hit the bottom of the window, they 
  12076. moved back to the top left corner.
  12077.  
  12078. Using 16 of these graphics on a Quadra 800, I found that the frame
  12079. rate varied from 60 to 71 fps when the background was a single
  12080. cell. This is explained by the fact that when a graphic on the
  12081. bottom right "dropped off" to the top left, almost the entire 
  12082. background (512 X 384) was included in the update. 
  12083.  
  12084. A few quick tests indicated that the optimum dimensions for the
  12085. background grid were about 3X the "sprite" size. Dividing the
  12086. background into 128X128 cells gave me frame rates of 63 to 68
  12087. fps -- not as high on the high end because of the increased 
  12088. overhead of processing 12 background elements instead of 1,
  12089. but better on the low end. The improvement in the "look" of the 
  12090. movement was better than the figures would indicate, since these 
  12091. are average frame rates over 30 seconds.
  12092.  
  12093. This technique really shone, though, when the graphics were in
  12094. random motion over the background. For the same 16 graphics, I
  12095. got an average of 46 fps using the 128X128 cells, as compared
  12096. to 39 fps using a single background cell. And the difference
  12097. increased as the number of graphics dropped: 80 fps as compared
  12098. to 60 with 8 graphics, 175 as compared to 96 with 4. Once
  12099. again, the "look" was greatly improved.
  12100.  
  12101. I'm sure that's more than you ever wanted to know. But I've found
  12102. that it's very difficult to predict the effect of an "improvement"
  12103. in a high-performance animation system, and thought I'd share these
  12104. numbers since I'm in a position to do so.
  12105.  
  12106.                     --Al Evans--
  12107. -- 
  12108.  
  12109. Al Evans                         Tu causes, tu causes
  12110. al@crucible.powertools.com               C'est tout ce que tu sais faire
  12111. cs.utexas.edu!crucible!al                     -- LaVerdure
  12112.  
  12113. +++++++++++++++++++++++++++
  12114.  
  12115. >From mxmora@unix.sri.com (Matt Mora)
  12116. Date: 2 Mar 1994 13:28:29 -0800
  12117. Organization: SRI International, Menlo Park, CA
  12118.  
  12119. In article <421@crucible.powertools.com> al@crucible.powertools.com (Al Evans) writes:
  12120.  
  12121. >I'm sure that's more than you ever wanted to know. But I've found
  12122. >that it's very difficult to predict the effect of an "improvement"
  12123. >in a high-performance animation system, and thought I'd share these
  12124. >numbers since I'm in a position to do so.
  12125.  
  12126. Can you post the code? It would be cool to try it on other macs to see
  12127. how things differ.
  12128.  
  12129.  
  12130.  
  12131. Xavier
  12132.  
  12133.  
  12134. -- 
  12135. ___________________________________________________________
  12136. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  12137. SRI International                       mxmora@unix.sri.com
  12138. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  12139.  
  12140. +++++++++++++++++++++++++++
  12141.  
  12142. >From ua025@freenet.Victoria.BC.CA (Cody Jones)
  12143. Date: Fri, 4 Mar 1994 10:37:46 GMT
  12144. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  12145.  
  12146.  
  12147. I'll just put in my 2 bits... I'm also doing a game w/ direct-screen
  12148. writing, a fair number of 32x32 sprites, etc... I ONLY use direct writing
  12149. because I've had it with letting the system do it for me.  Besides, my
  12150. game will have a MOD playing so my code needs all the speed it can get.
  12151.  
  12152. Anyway, a suggestion: Try and make use of the 68040's MOVE16 command. 
  12153. You might keep an array of flags, one for each row on the screen.  If the
  12154. row is set, update it - the entire row, that is.  The MOVE16 will probably
  12155. be fast enough to compensate for copying what you don't need to on each
  12156. line: on my Tempest (aka. 660AV) I was able to move over 80 megs/second
  12157. with it!  For a 512x384 screen, you can sure get a decent frame rate with
  12158. that - well, well over 60 fps.
  12159.  
  12160. I haven't actually implemented this 'row updating' idea, only a routine to
  12161. test the MOVE16's speed.  Of course this method won't work on 68030's...
  12162. your program would have to check & call the proper update-routine
  12163. according to the processor.
  12164.  
  12165. Cody Jones of Zerius Development
  12166. ua025@freenet.victoria.bc.ca
  12167.  
  12168. -- 
  12169.  
  12170. +++++++++++++++++++++++++++
  12171.  
  12172. >From andrewwelc@aol.com (AndrewWelc)
  12173. Date: 4 Mar 1994 10:32:04 -0500
  12174. Organization: America Online, Inc.
  12175.  
  12176. >>
  12177. I haven't actually implemented this 'row updating' idea, only a routine to
  12178. test the MOVE16's speed.  Of course this method won't work on 68030's...
  12179. your program would have to check & call the proper update-routine
  12180. according to the processor.
  12181. <<
  12182. I'm curious what other nitty gritty write-directly-to-the-screen-in-assmebler
  12183. game programmers out there (like me) are doing for the PowerPC....?
  12184.  
  12185. Andrew Welch
  12186. Ambrosia Software
  12187.  
  12188.  
  12189. +++++++++++++++++++++++++++
  12190.  
  12191. >From Ron_Hunsinger@bmug.org
  12192. Date: Tue, 01 Mar 1994 15:37:18 PST
  12193. Organization: BMUG, Inc.
  12194.  
  12195. M. Scott Smith,mssmith@afterlife.ncsc.mil writes:
  12196.  
  12197. >   But (at least) two things bother me: there's two copies of 512x384 bytes
  12198. >occurring for each frame of animation: first the copy of the background
  12199. >into the work buffer, then the copy of the work buffer to the screen.  Not
  12200. >to mention all the copies of the sprites -- possibly up to 30.
  12201.  
  12202. That worries me too.  (I developed a sprite engine on the Plus, and ran
  12203. into the same kinds of problems you're running into.)
  12204.  
  12205. >  No optimizations:356 frames / 30 seconds or 11.87 frames/s
  12206. >  Compiled for 68020 and up,
  12207. >    with all Symantec C++ opts: 554 frames / 30 seconds or 18.47 frames/s
  12208.  
  12209. And this is the main problem, in a nutshell.  Even on a B/W 512x342 screen,
  12210. there just isn't time to be copying screen-sized data around.  The Plus
  12211. simply didn't have that kind of horsepower, and if you are running on
  12212. a faster machine you are probably using color and/or a bigger screen, and
  12213. the problem is still there.  Probably will always be there, because I
  12214. see no reason for the screenSize:processorPower ratio to change much.
  12215.  
  12216. >   I know there are probably ways to prevent copying the entire screen,
  12217. >and I could use some suggestions.  I could keep track of a "dirty rectangle"
  12218. >that needs updating, but for my game I'll have sprites all over the screen
  12219. >so it seems like I'll need to copy the whole screen anyway.  Keeping a
  12220. >list of rectangles needing to be copied is another possibility, but this
  12221. >will result in a lot of overhead and required computations, and numerous
  12222. >little copies that would probably make it slower.
  12223.  
  12224. I used the "dirty rectangle" approach, but NOT by keeping a separate 
  12225. rectangle for each sprite.  Remember, you're trying to minimize copying,
  12226. so you don't want to copy the data twice if two sprites overlap.
  12227.  
  12228. Instead, I divided the screen into a bunch of rectangular zones, each
  12229. rectangular and nicely aligned.  In my case, I made the zones 16x16
  12230. pixels, so that the entire screen was like 32x20 zones.  (For an
  12231. effective screen size of 512x320 pixels, meaning I discarded 22 pixels
  12232. in the vertical dimension.)  Then I kept track of which zones were
  12233. dirty, using a table of 20 longwords.  You might call this the "dirty
  12234. zone" method.
  12235.  
  12236. Taking the union of draw lists becomes a snap.  (You have to update not 
  12237. only the zones where the sprites are now, but also the zones where they 
  12238. were last time.)  Just keep two dirty zone lists: one for the work area,
  12239. to keep track of which zones differ from the background; and one for the
  12240. screen, for all the zones that need to be updated from the work area.
  12241.  
  12242. When I actually copied the data to the screen, I walked the dirty zone
  12243. table, and copied each dirty zone directly to the screen using 16 
  12244. consecutive MOVE.W instructions.  Remember, I was doing this on a Plus, 
  12245. which had a 16-bit data bus and no cache.  (At the time, color and the 
  12246. Mac II were only rumors.)  
  12247.  
  12248. I was able to get 30 frames per second on a Plus, with a few hundred
  12249. sprites moving on the screen at once.  Looked nice.  Since the zones get 
  12250. updated in top-to-bottom order, I got no flicker even though I made no
  12251. effort to synchronize with vertical retrace.
  12252.  
  12253. If I were to do it again, I would use larger zones, keeping them 
  12254. longword aligned but large enough so that the width of the screen would 
  12255. still not exceed 32 zones.  And although writing directly to the screen 
  12256. is faster, I think now I would seriously consider using CopyBits for the 
  12257. final copy.  I did not appreciate at the time how fragile direct screen 
  12258. manipulation makes your program.  I would probably try to combine 
  12259. horizontally adjacent zones into a single CopyBits call, to minimize
  12260. CopyBit's setup overhead.
  12261.  
  12262. -Ron Hunsinger
  12263.  
  12264.  
  12265.  
  12266. +++++++++++++++++++++++++++
  12267.  
  12268. >From mssmith@afterlife.ncsc.mil (M. Scott Smith)
  12269. Date: Sun, 6 Mar 1994 01:30:05 GMT
  12270. Organization: The Great Beyond
  12271.  
  12272. Hi gang!
  12273.  
  12274.    I want to extend a very loud "thank you!" to everyone for their messages
  12275. concerning speeding up my animation.
  12276.  
  12277.    A week or so ago, I brainstormed out loud about a method for doing smooth
  12278. animation in a game that might potentially have a lot of small sprites.  The
  12279. easiest method I could think of was to keep two offscreen buffers, one a
  12280. "background" buffer (always containing the pure background) and another a
  12281. "work" buffer, where I would copy the background and then stick sprites on.
  12282. Finally, I would copy from the work buffer to the screen.
  12283.  
  12284.    But my suggested method (while certainly easiest) of copying the entire
  12285. buffer first from background to work area, and then work area to screen,
  12286. was, by my own testing, slow on a IIfx in 8-bit.  I asked for any
  12287. suggestions, including whether or not "dirty rectangle" approaches would
  12288. be faster.  I also posted some code and asked for suggestions on
  12289. optimization.
  12290.  
  12291.    Well, dozens of people responded on the net and in e-mail, and every 
  12292. single comment I received was of great help.
  12293.  
  12294.    First, people made code-level suggestions for squeezing more speed out
  12295. of my algorithm, and I learned some new optimizing techniques that I'll
  12296. be using from now on.
  12297.  
  12298.    The general concensus seems to be that the best approach to updating the
  12299. screen as quick as possible is to use "dirty rectangles" or "dirty zones."
  12300. In some way, maintain areas which you can flag as "dirty" (meaning they
  12301. have had activity that requires updating).  While I pondered over whether or
  12302. not this might be slow -- after all, maintaing such a list can require quite
  12303. a few operations -- people said that it will almost always be less expensive
  12304. than copying all of the data in an entire screen.  And that makes sense to
  12305. me now.  Efficient methods of maintaining such lists were presented.
  12306.  
  12307.    I was reminded that libraries such as SpriteWorld exist and already do
  12308. much of what I want, but I don't mind "reinventing the wheel" because this
  12309. is a learning experience for me.  (This is the same reason I don't use
  12310. MacApp or TCL but instead write my own class libraries; I may not do it
  12311. as well, but I learn how it's done.  Maybe that's stubborn, but as a kid
  12312. I took everything apart to see how it works; I don't like "black boxes."
  12313. Once I learn how to develop my own class libraries, I'll be happy to use
  12314. other ones since I'll have an idea of how they were written.)
  12315.  
  12316.    I really like the kind of discussion that has been going on in this
  12317. thread; it's thought-provoking.  It'd be great if it could continue;
  12318. there's lots of general issues involved in game writing which are a little
  12319. abstract.
  12320.  
  12321. - -[fade out, fade in..]---
  12322.  
  12323.    One of the other things that has been eating at me is the best way to
  12324. handle "timing."  The best method will be to make the animation machine-
  12325. independent.  If a sprite is moving across the screen at a certain speed
  12326. on the PowerMac's, it should move at the same speed on an LC.  This may
  12327. mean skipping frames in the animation -- or moving the sprite along 4
  12328. pixels at a time instead of 2.
  12329.  
  12330.    I've mulled over this one a bit, but haven't come up with anything
  12331. that I'm particularly thrilled about.  Any suggestions?
  12332.  
  12333.    And on another note entirely, say you have some type of "animated
  12334. background."  Such as a flaming torch on the wall of a castle.  The
  12335. flame flickers and throws out dancing light along the wall.  But it's
  12336. always in the background -- it's animated just like sprites, but it
  12337. doesn't interact with the (foreground) sprites.
  12338.  
  12339.    Something I briefly tried some time ago was putting the code for
  12340. these types of animations in background tasks.  Is this more trouble
  12341. than it's worth?  (Is it better to handle all of the animation in the
  12342. same place?)
  12343.  
  12344. Thanks again for all the help..
  12345.  
  12346. Scott
  12347.  
  12348. - -
  12349. M. Scott Smith    (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
  12350.  
  12351.   Macintosh developer. Student. Ski bum.  Eater of Ben and Jerry's ice cream.
  12352.  
  12353.  
  12354. +++++++++++++++++++++++++++
  12355.  
  12356. >From ua025@freenet.Victoria.BC.CA (Cody Jones)
  12357. Date: Sun, 6 Mar 1994 02:26:26 GMT
  12358. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  12359.  
  12360.  
  12361. "   One of the other things that has been eating at me is the best way to
  12362. handle "timing."  The best method will be to make the animation machine-
  12363. independent.  If a sprite is moving across the screen at a certain speed
  12364. on the PowerMac's, it should move at the same speed on an LC.  This may
  12365. mean skipping frames in the animation -- or moving the sprite along 4
  12366. pixels at a time instead of 2."
  12367.  
  12368. One way I use is this:  Keep track of the last time your update routine
  12369. was called.  When you get to the update again, see how many ticks have
  12370. passed, and for each one, call your update routine.  Thus your rout always
  12371. gets called 60 times a second... well, kind of.
  12372. After that you output the frame.  This method has the advantage you are
  12373. looking for.  No matter how bad the fps rate, objects always move at the
  12374. same rate.
  12375.  
  12376. Cody Jones, Zerius Development
  12377. ua025@freenet.victoria.bc.ca
  12378. voltaire@amtsgi.bc.ca
  12379.  
  12380. -- 
  12381.  
  12382. +++++++++++++++++++++++++++
  12383.  
  12384. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  12385. Date: Sun, 6 Mar 1994 11:48:05 GMT
  12386. Organization: Demon Internet
  12387.  
  12388.  
  12389. >    One of the other things that has been eating at me is the best way to
  12390. > handle "timing."  The best method will be to make the animation machine-
  12391. > independent.  If a sprite is moving across the screen at a certain speed
  12392. > on the PowerMac's, it should move at the same speed on an LC.  This may
  12393. > mean skipping frames in the animation -- or moving the sprite along 4
  12394. > pixels at a time instead of 2.
  12395. >    I've mulled over this one a bit, but haven't come up with anything
  12396. > that I'm particularly thrilled about.  Any suggestions?
  12397. >    And on another note entirely, say you have some type of "animated
  12398. > background."  Such as a flaming torch on the wall of a castle.  The
  12399. > flame flickers and throws out dancing light along the wall.  But it's
  12400. > always in the background -- it's animated just like sprites, but it
  12401. > doesn't interact with the (foreground) sprites.
  12402. >    Something I briefly tried some time ago was putting the code for
  12403. > these types of animations in background tasks.  Is this more trouble
  12404. > than it's worth?  (Is it better to handle all of the animation in the
  12405. > same place?)
  12406. > Thanks again for all the help..
  12407. > Scott
  12408.  
  12409.      In my game, I have a simple loop of game code, and I use quite simple
  12410. code to determine a standard game speed for all Macs:
  12411.  
  12412. {
  12413.      long tTicks;
  12414.  
  12415.      tTicks = TickCount ();
  12416.      GameLoop ();
  12417.      while (TickCount () - tTicks < kLoopSpeed);
  12418. }
  12419.  
  12420. where kLoopSpeed, on my game, is 2. I know this method isn't all that
  12421. accurate, but it's good enough for what I'm doing.
  12422.  
  12423.      As for the flickering torches idea... that shouldn't be a problem.
  12424. Just make the torch a sprite just like the others, but make sure that it's
  12425. one of the first ones copied across to your work area, before any of your
  12426. moving sprites are copied. That way, anything that passes "over it" will be
  12427. copied on top of it, and it will look like the torch is behind your main
  12428. (moving) sprites.
  12429.  
  12430.      Hope this helps,
  12431.  
  12432.  
  12433.  
  12434.      Alex
  12435.  
  12436. --
  12437. Alex Metcalf, Mac programmer in C, C++, HyperTalk, assembler
  12438.  
  12439. Internet, AOL, BIX:     alex@metcalf.demon.co.uk
  12440. AppleLink:              alex@metcalf.demon.co.uk@internet#
  12441. CompuServe:             INTERNET:alex@metcalf.demon.co.uk
  12442. Delphi:                 alex@metcalf.demon.co.uk@inet#
  12443. FirstClass:             alex@metcalf.demon.co.uk,Internet
  12444. Fax (UK):               (0570) 45636
  12445. Fax (US / Canada):      011 44 570 45636
  12446.  
  12447. +++++++++++++++++++++++++++
  12448.  
  12449. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  12450. Date: Sun, 6 Mar 1994 20:54:35 GMT
  12451. Organization: DCRT, NIH, Bethesda, MD
  12452.  
  12453. In article <alex-060394114457@metcalf.demon.co.uk>, alex@metcalf.demon.co.uk (Alex Metcalf) writes:
  12454. >Someone named Scott writes: (sorry; I lost the attribution!)
  12455. >> 
  12456. >>    One of the other things that has been eating at me is the best way to
  12457. >> handle "timing."  The best method will be to make the animation machine-
  12458. >> independent.  If a sprite is moving across the screen at a certain speed
  12459. >> on the PowerMac's, it should move at the same speed on an LC.  This may
  12460. >> mean skipping frames in the animation -- or moving the sprite along 4
  12461. >> pixels at a time instead of 2.
  12462. >> 
  12463. >>    I've mulled over this one a bit, but haven't come up with anything
  12464. >> that I'm particularly thrilled about.  Any suggestions?
  12465.  
  12466. >     In my game, I have a simple loop of game code, and I use quite simple
  12467. >code to determine a standard game speed for all Macs:
  12468. >
  12469. >{
  12470. >     long tTicks;
  12471. >
  12472. >     tTicks = TickCount ();
  12473. >     GameLoop ();
  12474. >     while (TickCount () - tTicks < kLoopSpeed);
  12475. >}
  12476. >
  12477. >where kLoopSpeed, on my game, is 2. I know this method isn't all that
  12478. >accurate, but it's good enough for what I'm doing.
  12479.  
  12480. Ack!  Phtui!
  12481.  
  12482. (Sorry; I got a little carried away.  :-)
  12483.  
  12484. This might be reasonable if your animation speed is high, but it *does*
  12485. have the unfortunate property that it locks up the rest of the machine
  12486. while waiting for an animation interval to pass.
  12487.  
  12488. Why not set up a simple Time Manager routine to set a flag somewhere
  12489. that means 'it's time to draw another animation step?'  This is
  12490. particularly nice in that you can have more than one Time Manager
  12491. routine that set different flags for different movement rates.  That
  12492. way, you don't need the movement rates to necessarily be integer
  12493. multiples of some base rate (other than the rate of traversal of the
  12494. main loop, of course).
  12495.  
  12496. Also, I *believe* that a Time Manager task doesn't take up any
  12497. execution time while it's pending - is this right?  I was of the impression
  12498. that a pending Time Manager task is just an entry in the task queue, 
  12499. until such time as the Time Manager decides it's time to call it.  If
  12500. this is the case, then you avoid any 'check to see if it's time yet'
  12501. overhead.
  12502.  
  12503. Furthermore (:-), this automatically gives you 'simulated' fixed-point
  12504. movement speeds - i.e. not integer numbers of pixels per step in any
  12505. given direction.  Not having integer pixels/step speeds goes a looooong
  12506. way towards making your animation look smooth, especially at lower object
  12507. movement speeds.
  12508.  
  12509. (Good luck, by the way!  And remember that the Time Manager is your friend!)
  12510.  
  12511. - --------------------------------------------------------------------------
  12512. Christopher Tate            |  "I hate writing, and I hate statistics, but
  12513. MSD, Inc.                   |   most of all I hate writing about statistics.
  12514.                             |   I'd rather go to the dentist; at least there
  12515. fixer@faxcsl.dcrt.nih.gov   |   you get to spit."     -- Ed Sewell
  12516.  
  12517. +++++++++++++++++++++++++++
  12518.  
  12519. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  12520. Date: Sun, 6 Mar 1994 23:15:50 GMT
  12521. Organization: Demon Internet
  12522.  
  12523. In article <1994Mar6.205435.229@alw.nih.gov>, fixer@faxcsl.dcrt.nih.gov
  12524. (Chris Gonna' Find Ray Charles Tate) wrote:
  12525.  
  12526. > In article <alex-060394114457@metcalf.demon.co.uk>, alex@metcalf.demon.co.uk (Alex Metcalf) writes:
  12527. > >Someone named Scott writes: (sorry; I lost the attribution!)
  12528. > >> 
  12529. > >>    One of the other things that has been eating at me is the best way to
  12530. > >> handle "timing."  The best method will be to make the animation machine-
  12531. > >> independent.  If a sprite is moving across the screen at a certain speed
  12532. > >> on the PowerMac's, it should move at the same speed on an LC.  This may
  12533. > >> mean skipping frames in the animation -- or moving the sprite along 4
  12534. > >> pixels at a time instead of 2.
  12535. > >> 
  12536. > >>    I've mulled over this one a bit, but haven't come up with anything
  12537. > >> that I'm particularly thrilled about.  Any suggestions?
  12538. > >     In my game, I have a simple loop of game code, and I use quite simple
  12539. > >code to determine a standard game speed for all Macs:
  12540. > >
  12541. > >{
  12542. > >     long tTicks;
  12543. > >
  12544. > >     tTicks = TickCount ();
  12545. > >     GameLoop ();
  12546. > >     while (TickCount () - tTicks < kLoopSpeed);
  12547. > >}
  12548. > >
  12549. > >where kLoopSpeed, on my game, is 2. I know this method isn't all that
  12550. > >accurate, but it's good enough for what I'm doing.
  12551. > Ack!  Phtui!
  12552. > (Sorry; I got a little carried away.  :-)
  12553. > This might be reasonable if your animation speed is high, but it *does*
  12554. > have the unfortunate property that it locks up the rest of the machine
  12555. > while waiting for an animation interval to pass.
  12556. > Why not set up a simple Time Manager routine to set a flag somewhere
  12557. > that means 'it's time to draw another animation step?'  This is
  12558. > particularly nice in that you can have more than one Time Manager
  12559. > routine that set different flags for different movement rates.  That
  12560. > way, you don't need the movement rates to necessarily be integer
  12561. > multiples of some base rate (other than the rate of traversal of the
  12562. > main loop, of course).
  12563.  
  12564.      Ack! Phtui!
  12565.  
  12566.      That's all fine and well, but if your game doesn't have an event loop
  12567. (as most arcade games don't, since it takes too much CPU time for
  12568. background processing), there's nothing else to do while you're waiting for
  12569. the next animation interval!
  12570.  
  12571.      But it's a good idea. :-)
  12572.  
  12573.      Alex
  12574.  
  12575. +++++++++++++++++++++++++++
  12576.  
  12577. >From s_heidri@iraul1.ira.uka.de (Dietmar Heidrich)
  12578. Date: 7 Mar 1994 13:58:31 GMT
  12579. Organization: University of Karlsruhe, FRG
  12580.  
  12581. In article <Arsenault_C-280294132621@134.33.101.226>, Arsenault_C@msm.cdx.mot.com (Chris Arsenault) writes:
  12582. |> Some comments:
  12583. [...]
  12584. |> - Do everything in your offscreen buffer then use CopyBits to move the
  12585. |> dirtyRect to screen...even if CopyBits has to make the transition to
  12586. |> different bit depths, chances are it will stay ahead of the electron gun
  12587. |> and you'll still get robust, smooth flicker-free animation and your game
  12588. |> will have a nice long life. (See Inside Mac III, p20. Although the values
  12589. |> are off, the ideas are still valid!)
  12590.  
  12591. I am no Mac programmer, but on other platforms you can switch video buffers
  12592. for games instead of copying everything you already have drawn.  Is there
  12593. no way to do that OS compliant on the Mac ?  I think CopyBits() will be too
  12594. slow for action games if you need to copy 640x480x8bit = 307200 bytes per
  12595. frame.  For 30 frames/s update rate, this yields 9 MB/s transfer rate eaten
  12596. up only for CopyBits().  Assuming you can transfer 16 bytes via burst (giving
  12597. 576000 bursts needed) in 20 clock cycles, this means 46% CPU time on a 25 MHz
  12598. 68040.
  12599.  
  12600.  
  12601.  
  12602. --
  12603. Dietmar Heidrich, Universitaet Karlsruhe, Germany
  12604.  
  12605.  
  12606. "Die Hoffnung auf den Tod ist das einzige, was mich am Leben erhaelt."
  12607.  
  12608. +++++++++++++++++++++++++++
  12609.  
  12610. >From rmah@panix.com (Robert S. Mah)
  12611. Date: Tue, 08 Mar 1994 01:29:01 -0500
  12612. Organization: One Step Beyond
  12613.  
  12614. s_heidri@iraul1.ira.uka.de (Dietmar Heidrich) wrote:
  12615.  
  12616. > I am no Mac programmer, but on other platforms you can switch video buffers
  12617. > for games instead of copying everything you already have drawn.  Is there
  12618. > no way to do that OS compliant on the Mac ?  
  12619.  
  12620. Nope.
  12621.  
  12622. > I think CopyBits() will be too slow for action games if you need to copy
  12623. > 640x480x8bit = 307200 bytes per frame.  For 30 frames/s update rate, this
  12624. > [...]
  12625.  
  12626. Tell that to those who use CopyBits to write arcade games :-).  Seriouslly,
  12627. it's possible, it's just not easy.
  12628.  
  12629. Cheers,
  12630. Rob
  12631. ________________________________________________________________________
  12632.  Robert S. Mah              One Step Beyond              rmah@panix.com
  12633.  
  12634. +++++++++++++++++++++++++++
  12635.  
  12636. >From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  12637. Date: 8 Mar 1994 11:25:16 GMT
  12638. Organization: University of Iceland
  12639.  
  12640. In <2lfbu7INN597@iraun1.ira.uka.de> s_heidri@iraul1.ira.uka.de (Dietmar Heidrich) writes:
  12641.  
  12642. >In article <Arsenault_C-280294132621@134.33.101.226>, Arsenault_C@msm.cdx.mot.com (Chris Arsenault) writes:
  12643. [snip]
  12644. >I am no Mac programmer, but on other platforms you can switch video buffers
  12645. >for games instead of copying everything you already have drawn.  Is there
  12646. >no way to do that OS compliant on the Mac ?
  12647. [snip]
  12648.  
  12649.   There is a well defined way to do this for color-quickdraw capable
  12650. video devices. The video driver interface includes calls to check how
  12651. many video pages are available, find their baseaddresses and to switch
  12652. between video pages. It seems that this feature is little enough used
  12653. though that newer video cards don't bother to support multiple video
  12654. pages, even if they have the video RAM needed, the Quadras for instance
  12655. don't seem to support multiple video pages.
  12656. -- 
  12657. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  12658. Kambasel 26            | for instance declares f as an array of unspecified 
  12659. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  12660. sigurasg@rhi.hi.is     | functions that return void... I think"
  12661.  
  12662. +++++++++++++++++++++++++++
  12663.  
  12664. >From mgleason@cse.unl.edu (Mike Gleason)
  12665. Date: 9 Mar 1994 02:09:38 GMT
  12666. Organization: NCEMRSoft
  12667.  
  12668. |s_heidri@iraul1.ira.uka.de (Dietmar Heidrich) wrote:
  12669.  
  12670. |> I am no Mac programmer, but on other platforms you can switch video buffers
  12671. |> for games instead of copying everything you already have drawn.  Is there
  12672. |> no way to do that OS compliant on the Mac ?  
  12673.  
  12674. |Nope.
  12675.  
  12676. That's pretty depressing.  The Sega Genesis and Commodore Amiga, which
  12677. use the same damn 68000 in the Mac Plus I use, get phemomenal performance.
  12678. Ever play Sonic the Hedgehog?  That should be able to be done on a mac.
  12679. Hard to believe...  I think the Amiga uses a Screen pointer, which is
  12680. changeable by the programmer, so that to do very fast screen scrolling,
  12681. all you need to do is set the screen pointer to something else.  It makes
  12682. no sense to me that you have to re-copy the whole damn screen if all you
  12683. want to do is scroll the screen downward a pixel.
  12684.  
  12685. --
  12686. ______________________________________________________________________________
  12687. mike gleason                 mgleason@cse.unl.edu             NCEMRSoft, baby!
  12688.  
  12689. +++++++++++++++++++++++++++
  12690.  
  12691. >From Arsenault_C@msm.cdx.mot.com (Chris Arsenault)
  12692. Date: Tue, 08 Mar 1994 12:35:30 -0500
  12693. Organization: Motorola Codex
  12694.  
  12695. In article <alex-060394231343@metcalf.demon.co.uk>,
  12696. alex@metcalf.demon.co.uk (Alex Metcalf) wrote:
  12697.  
  12698. >      That's all fine and well, but if your game doesn't have an event loop
  12699. > (as most arcade games don't, since it takes too much CPU time for
  12700. > background processing), there's nothing else to do while you're waiting for
  12701. > the next animation interval!
  12702.  
  12703. One of the things I do is to switch in and out of a main event loop.  When
  12704. running time critical game code I stay out of the main event loop, working
  12705. only with specific keypresses etc. When I see a special key (such as the
  12706. space bar) I switch in and out of the main event loop where I handle events
  12707. normally.  The nice part about this approach is I have very clean/fast
  12708. animation without background process relinquish jitters, but I can still
  12709. handle menus, application switching and the like.
  12710.  
  12711. BTW, when you're the foreground process you can tell the system that you
  12712. really want all the time you can by setting the WaitNextEvent sleep
  12713. parameter to 0.
  12714.  
  12715. Chris  
  12716.  
  12717. -- 
  12718. #include <UsualLegalDisclaimers.h>
  12719.  
  12720. +++++++++++++++++++++++++++
  12721.  
  12722. >From Arsenault_C@msm.cdx.mot.com (Chris Arsenault)
  12723. Date: Tue, 08 Mar 1994 12:51:42 -0500
  12724. Organization: Motorola Codex
  12725.  
  12726. In article <2lfbu7INN597@iraun1.ira.uka.de>, s_heidri@iraul1.ira.uka.de
  12727. (Dietmar Heidrich) wrote:
  12728.  
  12729.  
  12730. > I am no Mac programmer, but on other platforms you can switch video buffers
  12731. > for games instead of copying everything you already have drawn.  Is there
  12732. > no way to do that OS compliant on the Mac ?  I think CopyBits() will be too
  12733. > slow for action games if you need to copy 640x480x8bit = 307200 bytes per
  12734. > frame.  For 30 frames/s update rate, this yields 9 MB/s transfer rate eaten
  12735. > up only for CopyBits().  Assuming you can transfer 16 bytes via burst (giving
  12736. > 576000 bursts needed) in 20 clock cycles, this means 46% CPU time on a 25 MHz
  12737. > 68040.
  12738.  
  12739. No. Not when focusing on market share.
  12740.  
  12741. You're right about video page flipping being CPU intensive.  That's why you
  12742. don't see a lot of Mac video games that do full frame (640x480) flipping
  12743. and if you do the frames are usually small (ever seen QuickTime movies
  12744. playing at full speed?).
  12745.  
  12746. Actually, there is a tradeoff involved. By using CopyBits we gain
  12747. simplicity in handling numerous video configurations and application
  12748. longevity.  What we lose is speed. We don't have a mode 13h or X. If we
  12749. draw using Toolbox trap calls to memory on a video card, then we have to
  12750. run over NuBus. (number of draw calls * (Trap dispatch overhead + NuBus
  12751. overhead + actual operation) = too expensive).
  12752.  
  12753. BTW - there are video cards out there that support several frame buffers
  12754. (GWorlds). But they are more likely to be found in high end publishing
  12755. systems than in the target game Mac - the LCIII.
  12756.  
  12757. IMHO, I would love to see hardware supported video DMA. I've worked with
  12758. the Amiga and it was great to have the blitter and copper. 
  12759. Chris
  12760.  
  12761. -- 
  12762. #include <UsualLegalDisclaimers.h>
  12763.  
  12764. +++++++++++++++++++++++++++
  12765.  
  12766. >From flavius@bga.com (Flavius Goombius)
  12767. Date: 9 Mar 1994 09:48:54 -0600
  12768. Organization: PowerTools, Austin, TX
  12769.  
  12770. In article <1994Mar6.013005.18429@afterlife.ncsc.mil>,
  12771. M. Scott Smith <mssmith@afterlife.ncsc.mil> wrote:
  12772.  
  12773. >   One of the other things that has been eating at me is the best way to
  12774. >handle "timing."  The best method will be to make the animation machine-
  12775. >independent.  If a sprite is moving across the screen at a certain speed
  12776. >on the PowerMac's, it should move at the same speed on an LC.  This may
  12777. >mean skipping frames in the animation -- or moving the sprite along 4
  12778. >pixels at a time instead of 2.
  12779. >
  12780. >   I've mulled over this one a bit, but haven't come up with anything
  12781. >that I'm particularly thrilled about.  Any suggestions?
  12782.  
  12783. Sorry about the funky From: line; this is really Al Evans (al@crucible.
  12784. powertools.com), posting from an alternate site because my newsfeed
  12785. has been hosed for the past few days.
  12786.  
  12787. Anyway: Let's take a simple case. There is an "overall" animation system
  12788. time. Each sprite has variables which represent its move interval and
  12789. its last move time. For each frame, you run through the sprite list and
  12790. update the sprites for which lastMove + moveInterval <= currentTime.
  12791.  
  12792. At this point, you have three options. First, you can set the sprite's
  12793. last move time to the current system time. The advantage of this approach
  12794. is that each frame gets drawn for each sprite. The disadvantage is that,
  12795. on entry, currentTime can easily be lastMove + (10 * moveInterval),
  12796. and the extra nine moveIntervals are lost forever. In other words, unless
  12797. the host system is fast enough that the maximum animation time is less
  12798. than the minimum move interval, the animation will slow down.
  12799.  
  12800. The second approach is to do something like
  12801.  
  12802. while ((lastMove + moveInterval) <= currentTime) {
  12803.     MoveSprite(thisSprite);
  12804.     lastMove = lastMove + moveInterval;
  12805. }
  12806.  
  12807. This keeps the sprite movement speeds the same on all systems, but leads
  12808. to skipped frames (and possible jerky animation) on slower systems. In
  12809. addition, you must provide some means of "stopping the clock" when 
  12810. you are not animating. For example, if the user holds down a menu so that
  12811. your animation loop doesn't get called for a few seconds, the sprites
  12812. will all jump to where they are supposed to be "now" if the clock has
  12813. continued running.
  12814.  
  12815. Finally, you can combine the two approaches, setting last move equal
  12816. to lastMove + moveInterval but only moving once each time through the
  12817. loop. This assumes that there will be time available at some point for
  12818. the animation to "catch up" on comparatively slow systems (for example,
  12819. a series of frames in which most sprites are standing still). With this
  12820. technique, all sprites will be where they are supposed to be -- eventually.
  12821. The problem of stopping time while the user holds down a menu (or whatever)
  12822. remains, only in this case the sprites will "run real fast" to get
  12823. where they're supposed to be when the user releases the menu.
  12824.  
  12825. I am not really satisfied with any of these approaches, but the only
  12826. better one I can think of is to measure system speed and alter the
  12827. move distances (and frame changes) of each sprite, possibly using
  12828. fixed-point numbers for fractional pixels. If anybody has a better method,
  12829. I'd like to hear it.
  12830.  
  12831. For a variety of reasons, I personally use the first method, and 
  12832. accept the inevitable slowdown on slower systems.  
  12833.  
  12834.                     --Al Evans--
  12835.  
  12836. +++++++++++++++++++++++++++
  12837.  
  12838. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  12839. Date: Wed, 9 Mar 1994 18:26:03 GMT
  12840. Organization: Demon Internet
  12841.  
  12842. In article <Arsenault_C-080394123530@134.33.101.226>,
  12843. Arsenault_C@msm.cdx.mot.com (Chris Arsenault) wrote:
  12844.  
  12845. > In article <alex-060394231343@metcalf.demon.co.uk>,
  12846. > alex@metcalf.demon.co.uk (Alex Metcalf) wrote:
  12847. > >      That's all fine and well, but if your game doesn't have an event loop
  12848. > > (as most arcade games don't, since it takes too much CPU time for
  12849. > > background processing), there's nothing else to do while you're waiting for
  12850. > > the next animation interval!
  12851. > One of the things I do is to switch in and out of a main event loop.  When
  12852. > running time critical game code I stay out of the main event loop, working
  12853. > only with specific keypresses etc. When I see a special key (such as the
  12854. > space bar) I switch in and out of the main event loop where I handle events
  12855. > normally.  The nice part about this approach is I have very clean/fast
  12856. > animation without background process relinquish jitters, but I can still
  12857. > handle menus, application switching and the like.
  12858. > BTW, when you're the foreground process you can tell the system that you
  12859. > really want all the time you can by setting the WaitNextEvent sleep
  12860. > parameter to 0.
  12861.  
  12862.      Interesting.... I already have an event loop for other parts of the
  12863. game (such as loading and intro), but I hadn't considered sharing my
  12864. important game code time with other events. Worth a try!
  12865.  
  12866.      Alex
  12867.  
  12868. +++++++++++++++++++++++++++
  12869.  
  12870. >From ua025@freenet.Victoria.BC.CA (Cody Jones)
  12871. Date: Thu, 10 Mar 1994 08:58:39 GMT
  12872. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  12873.  
  12874.  
  12875. I posted my method of handling animation-rates on different systems some
  12876. time ago.  Others have posted similar ideas and some think that it would
  12877. be wise to use Time Manager tasks to handle movement.  There is no need -
  12878. to avoid having movement be integer-multiples of the update-frequency,
  12879. simply store your velocity and positions as fixed point.  In my present
  12880. project I use 10.6 bits.  I have a routine that converts a fixed-pt.
  12881. coordinate and two lengths into a rectangle; this is used for any
  12882. memory-copying or intersection-testing.
  12883.  
  12884. Personally I think doing it this way is better than setting up a Time
  12885. Manager task for every moving object.
  12886.  
  12887. Cody Jones
  12888. Zerius Development
  12889. -- 
  12890.  
  12891. +++++++++++++++++++++++++++
  12892.  
  12893. >From s_heidri@ira.uka.de (Dietmar Heidrich)
  12894. Date: 10 Mar 1994 18:12:58 GMT
  12895. Organization: University of Karlsruhe, Comp. Sc. Dept., FRG
  12896.  
  12897. Chris Arsenault (Arsenault_C@msm.cdx.mot.com) wrote:
  12898. : In article <2lfbu7INN597@iraun1.ira.uka.de>, s_heidri@iraul1.ira.uka.de
  12899. : (Dietmar Heidrich) wrote:
  12900. : > I am no Mac programmer, but on other platforms you can switch video buffers
  12901. : > for games instead of copying everything you already have drawn.  Is there
  12902. : > no way to do that OS compliant on the Mac ?  I think CopyBits() will be too
  12903. : > slow for action games if you need to copy 640x480x8bit = 307200 bytes per
  12904. : > frame.  For 30 frames/s update rate, this yields 9 MB/s transfer rate eaten
  12905. : > up only for CopyBits().  Assuming you can transfer 16 bytes via burst (giving
  12906. : > 576000 bursts needed) in 20 clock cycles, this means 46% CPU time on a 25 MHz
  12907. : > 68040.
  12908.  
  12909. : Actually, there is a tradeoff involved. By using CopyBits we gain
  12910. : simplicity in handling numerous video configurations and application
  12911. : longevity.  What we lose is speed. We don't have a mode 13h or X. If we
  12912. : draw using Toolbox trap calls to memory on a video card, then we have to
  12913. : run over NuBus. (number of draw calls * (Trap dispatch overhead + NuBus
  12914. : overhead + actual operation) = too expensive).
  12915.  
  12916. What is mode 13h ?  I think you assume I am an Intel-Weirdo.  I AM NOT !
  12917.  
  12918. But you can design hardware-independant systems with double-buffering and
  12919. OS compliancy.  You do not have to lose speed.  And as long as the system
  12920. provides fast BitBlt() for the graphics board memory, the NuBus should not
  12921. be an obstacle.
  12922.  
  12923.  
  12924.  
  12925. Dietmar Heidrich
  12926.  
  12927. +++++++++++++++++++++++++++
  12928.  
  12929. >From dwareing@apanix.apana.org.au (David Wareing)
  12930. Date: 11 Mar 94 04:18:24 GMT
  12931. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  12932.  
  12933. mgleason@cse.unl.edu (Mike Gleason) writes:
  12934.  
  12935. >|s_heidri@iraul1.ira.uka.de (Dietmar Heidrich) wrote:
  12936.  
  12937. >|> I am no Mac programmer, but on other platforms you can switch video buffers
  12938. >|> for games instead of copying everything you already have drawn.  Is there
  12939. >|> no way to do that OS compliant on the Mac ?  
  12940.  
  12941. >|Nope.
  12942.  
  12943. >That's pretty depressing.  The Sega Genesis and Commodore Amiga, which
  12944. >use the same damn 68000 in the Mac Plus I use, get phemomenal performance.
  12945.  
  12946. Yeah, I wonder why. Can you say "custom blitting hardware"? Decent graphic
  12947. performance is expected from both the Sega Genesis/MegaDrive and the
  12948. Amiga, as both started out life as games machines (both still are, but I
  12949. digress). The did not start their lives as multi-purpose home and business
  12950. computers. They do one job and they do it well. Want to try and run Word
  12951. or Lotus 123 on a Sega games machine? Of course not - games boxes weren't
  12952. designed to do such things. Just as the Mac Plus was not designed to play
  12953. Sonic the Hedgehog.
  12954.  
  12955. >Ever play Sonic the Hedgehog?  That should be able to be done on a mac.
  12956. >Hard to believe... 
  12957.  
  12958. *Very* hard to believe actually. Why should it be able to done on a mac?
  12959. Somehow I don't think the number one choice for buying a mac is its
  12960. ability to play Sonic. I agree that macs should eventually come standard
  12961. with some form of hardware-accelerated graphics, but lets not get carried
  12962. away and whine that you can't play Sonic on a lowly Mac Plus.
  12963.  
  12964. >I think the Amiga uses a Screen pointer, which is
  12965. >changeable by the programmer, so that to do very fast screen scrolling,
  12966. >all you need to do is set the screen pointer to something else.  It makes
  12967. >no sense to me that you have to re-copy the whole damn screen if all you
  12968. >want to do is scroll the screen downward a pixel.
  12969.  
  12970. See the comments above about the Amiga's blitting hardware. Damn it. 
  12971. Horses for courses.
  12972.  
  12973. --
  12974. David Wareing
  12975. Adelaide, South Australia
  12976. Mac Games & Multimedia Programming        dwareing@apanix.apana.org.au
  12977. - --------------------------------------------------------------------
  12978.  
  12979. +++++++++++++++++++++++++++
  12980.  
  12981. >From snozer@cats.ucsc.edu (Daniel Craig Jalkut)
  12982. Date: 14 Mar 1994 08:22:55 GMT
  12983. Organization: University of California, Santa Cruz
  12984.  
  12985.  
  12986. In <dwareing.763359504@apanix.apana.org.au> dwareing@apanix.apana.org.au (David Wareing) writes:
  12987.  
  12988.  
  12989. >Yeah, I wonder why. Can you say "custom blitting hardware"? Decent graphic
  12990. >performance is expected from both the Sega Genesis/MegaDrive and the
  12991. >Amiga, as both started out life as games machines (both still are, but I
  12992. >digress). The did not start their lives as multi-purpose home and business
  12993. >computers. They do one job and they do it well. Want to try and run Word
  12994. >or Lotus 123 on a Sega games machine? Of course not - games boxes weren't
  12995. >designed to do such things. Just as the Mac Plus was not designed to play
  12996. >Sonic the Hedgehog.
  12997.  
  12998.  
  12999. But the bottom line is that the Amiga can do everything the Mac can
  13000. do, but the converse is not true.  The advantages you point out for 
  13001. the Mac are all software(which is why i'm a mac user and no longer an 
  13002. Amigan), if the software were written as well for the Amiga(including 
  13003. the OS), then you'd have the equivalent of a Macintosh with the bonus
  13004. of excellent graphics hardware.  And the Amiga computers were sold 
  13005. for much less than macs in the past, so it's not infeasable cost-wise
  13006. that the Macs have this type of hardware for graphics. 
  13007.  
  13008. Would be nice...
  13009.  
  13010.  
  13011. +++++++++++++++++++++++++++
  13012.  
  13013. >From rba26@cas.org (Brad Andrews)
  13014. Date: Mon, 14 Mar 1994 18:08:22 GMT
  13015. Organization: Chemical Abstracts Service
  13016.  
  13017. In article dpi@darkstar.UCSC.EDU, snozer@cats.ucsc.edu (Daniel Craig Jalkut) writes:
  13018. ]
  13019. ]But the bottom line is that the Amiga can do everything the Mac can
  13020. ]do, but the converse is not true.  The advantages you point out for 
  13021.  
  13022. Hardly.  Certainly you may prefer the Amiga, and many do, but some things are
  13023. extremely difficult.  I had a lot more hastles getting an Amiga version of 
  13024. a game port running than I did on the Mac, including such things as supporting a
  13025. hard drive.
  13026.  
  13027. - -
  13028.  
  13029. Brad Andrews
  13030. brad.andrews@cas.org
  13031. All opinions are strictly mine
  13032.  
  13033.  
  13034. +++++++++++++++++++++++++++
  13035.  
  13036. >From snozer@cats.ucsc.edu (Daniel Craig Jalkut)
  13037. Date: 15 Mar 1994 16:03:41 GMT
  13038. Organization: University of California, Santa Cruz
  13039.  
  13040.  
  13041. In <1994Mar14.180822.7882@chemabs.uucp> rba26@cas.org (Brad Andrews) writes:
  13042.  
  13043. >Hardly.  Certainly you may prefer the Amiga, and many do, but some things are
  13044. >extremely difficult.  I had a lot more hastles getting an Amiga version of 
  13045. >a game port running than I did on the Mac, including such things as supporting a
  13046. >hard drive.
  13047.  
  13048.  
  13049. If I preferred Amigas, I wouldn't have said that I was a mac person.
  13050.  
  13051.  
  13052. +++++++++++++++++++++++++++
  13053.  
  13054. >From s_heidri@irau32.ira.uka.de (Dietmar Heidrich)
  13055. Date: 17 Mar 1994 13:36:48 GMT
  13056. Organization: University of Karlsruhe, FRG
  13057.  
  13058. In article <dwareing.763359504@apanix.apana.org.au>, dwareing@apanix.apana.org.au (David Wareing) writes:
  13059. |> mgleason@cse.unl.edu (Mike Gleason) writes:
  13060. |> 
  13061. |> >|s_heidri@iraul1.ira.uka.de (Dietmar Heidrich) wrote:
  13062. |> 
  13063. |> >|> I am no Mac programmer, but on other platforms you can switch video buffers
  13064. |> >|> for games instead of copying everything you already have drawn.  Is there
  13065. |> >|> no way to do that OS compliant on the Mac ?  
  13066. |> 
  13067. |> >|Nope.
  13068. |> 
  13069. |> >That's pretty depressing.  The Sega Genesis and Commodore Amiga, which
  13070. |> >use the same damn 68000 in the Mac Plus I use, get phemomenal performance.
  13071. |> 
  13072. |> Yeah, I wonder why. Can you say "custom blitting hardware"? Decent graphic
  13073. |> performance is expected from both the Sega Genesis/MegaDrive and the
  13074. |> Amiga, as both started out life as games machines (both still are, but I
  13075. |> digress). The did not start their lives as multi-purpose home and business
  13076. |> computers. They do one job and they do it well. Want to try and run Word
  13077. |> or Lotus 123 on a Sega games machine? Of course not - games boxes weren't
  13078. |> designed to do such things. Just as the Mac Plus was not designed to play
  13079. |> Sonic the Hedgehog.
  13080.  
  13081. I did not ask for special-purpose hardware, I was asking about opening and
  13082. switching two video buffers.  To me, this purely seems to be a question of
  13083. programming interface.  The MacOS does not support this (though it would be
  13084. quite simple to implement that), so the game programming idea I had is dead.
  13085.  
  13086.  
  13087.  
  13088. --
  13089. Dietmar Heidrich, Universitaet Karlsruhe, Germany
  13090.  
  13091.  
  13092. "Die Hoffnung auf den Tod ist das einzige, was mich am Leben erhaelt."
  13093.  
  13094. +++++++++++++++++++++++++++
  13095.  
  13096. >From fixer@faxcsl.dcrt.nih.gov (Chris Gonna' Find Ray Charles Tate)
  13097. Date: Thu, 17 Mar 1994 16:15:36 GMT
  13098. Organization: DCRT, NIH, Bethesda, MD
  13099.  
  13100. In article <2m9mdgINNei4@iraun1.ira.uka.de>, s_heidri@irau32.ira.uka.de (Dietmar Heidrich) writes:
  13101. >
  13102. >I did not ask for special-purpose hardware, I was asking about opening and
  13103. >switching two video buffers.  To me, this purely seems to be a question of
  13104. >programming interface.  The MacOS does not support this (though it would be
  13105. >quite simple to implement that), so the game programming idea I had is dead.
  13106.  
  13107. But video double-buffering *is* dependant on the hardware.
  13108.  
  13109. Think about it - you need to be able to tell the video card where to look
  13110. in RAM for its frame buffer.  That sounds like hardware functionality to
  13111. me....
  13112.  
  13113. I *believe* the original Apple color video card (that they would sell you
  13114. with a Mac II) supported two switchable frame buffers in 16-color mode.
  13115. You switched between them with a Control() call to the video driver, as
  13116. I recall.  I also think that Vette! (or some other driving game?) used
  13117. this capability.
  13118.  
  13119. Unfortunately, it's not a guaranteed availability by any stretch of the
  13120. imagination, and so you can't write code depending on it.  I agree that
  13121. it would be nice to have hardware pan, though, as a documented and
  13122. required video card capability.  That's the one that's the most expensive
  13123. to do in software.  Makes the idea of a 'Xevious' clone pretty remote. :-)
  13124.  
  13125. - --------------------------------------------------------------------------
  13126. Christopher Tate            |  "I hate writing, and I hate statistics, but
  13127. MSD, Inc.                   |   most of all I hate writing about statistics.
  13128.                             |   I'd rather go to the dentist; at least there
  13129. fixer@faxcsl.dcrt.nih.gov   |   you get to spit."     -- Ed Sewell
  13130.  
  13131. +++++++++++++++++++++++++++
  13132.  
  13133. >From Pascal_Haakmat
  13134. Date: Mon, 14 Mar 94 20:09:46 +0100
  13135. Organization: (none)
  13136.  
  13137. >That's pretty depressing.  The Sega Genesis and Commodore Amiga
  13138.  DW> Horses for courses.
  13139.  
  13140. Nonetheless, it remains pretty depressing.
  13141.  
  13142.  
  13143.  
  13144.     Pascal.
  13145.  
  13146. - - Obolus 1.0.2
  13147.  * Origin:  pretty blue dreams  (2:281/202.13)
  13148.  
  13149. ---------------------------
  13150.  
  13151. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  13152. Subject: System Folder on NONstartup disk
  13153. Date: Thu, 3 Mar 94 19:51:03 PST
  13154. Organization: Peirce Software, Inc.
  13155.  
  13156. Does anyone know how to find the System Folder on a volume that isn't
  13157. the startup volume?
  13158.  
  13159.  
  13160. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  13161. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  13162. --                       -- San Jose, California USA 95117
  13163. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  13164. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  13165.  
  13166. +++++++++++++++++++++++++++
  13167.  
  13168. >From mxmora@unix.sri.com (Matt Mora)
  13169. Date: 4 Mar 1994 09:42:08 -0800
  13170. Organization: SRI International, Menlo Park, CA
  13171.  
  13172. In article <CNjbKKKX.pns11u@outpost.SF-Bay.org> peirce@outpost.SF-Bay.org 
  13173. (Michael Peirce) writes:
  13174. >Does anyone know how to find the System Folder on a volume that isn't
  13175. >the startup volume?
  13176.  
  13177. Are you talking about a volume that has a system folder that's not blessed?
  13178. If its not blessed you probably need to do a PBCatSearch.
  13179.  
  13180. If its blessed, but not the startup volume, I assume you call findfolder
  13181. with the vRefNum set to the vRefnum of the volume that you want to
  13182. look on. Being that you're Michael Peirce, you probably already
  13183. tried that it it doesn't work. In that case do scan of the disk
  13184. and look for a folder that contains the finder and system at the same level
  13185. and you have a good chance that those files parent directory is/was
  13186. a system folder.
  13187.  
  13188. Xavier
  13189.  
  13190. P.S. Are you setting up another netter's dinner?
  13191.  
  13192. -- 
  13193. ___________________________________________________________
  13194. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  13195. SRI International                       mxmora@unix.sri.com
  13196. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  13197.  
  13198. +++++++++++++++++++++++++++
  13199.  
  13200. >From Robin J. Lunge <rjl1@cornell.edu>
  13201. Date: 5 Mar 1994 03:36:41 GMT
  13202. Organization: Cornell University
  13203.  
  13204. In article <CNjbKKKX.pns11u@outpost.SF-Bay.org> Michael Peirce,
  13205. peirce@outpost.SF-Bay.org writes:
  13206. >Does anyone know how to find the System Folder on a volume that isn't
  13207. >the startup volume?
  13208.  
  13209. FindFolder ought to work on any startup disk -- whether it is the current
  13210. startup disk or not. If you are talking about a disk that is not blessed,
  13211. the only solution is to search for a folder containing a "Finder" and a
  13212. "System" (use PBCatSearch if it is available). The Finder and System
  13213. strings are script-independent.
  13214.  
  13215. +++++++++++++++++++++++++++
  13216.  
  13217. >From Ron_Hunsinger@bmug.org
  13218. Date: Sat, 05 Mar 1994 19:39:48 -0700
  13219. Organization: BMUG, Inc.
  13220.  
  13221. Michael Peirce,peirce@outpost.SF-Bay.org writes:
  13222.  
  13223. >Does anyone know how to find the System Folder on a volume that isn't
  13224. >the startup volume?
  13225.  
  13226. Its directoryID is the first longword of vcbFndrInfo.  This isn't
  13227. documented anywhere, but I don't see how they can change it, since
  13228. the ROM has to be getting the system folder from here at bootup.
  13229.  
  13230. -Ron Hunsinger
  13231.  
  13232.  
  13233.  
  13234. +++++++++++++++++++++++++++
  13235.  
  13236. >From macguru@halcyon.com. (Allan Foster)
  13237. Date: 10 Mar 1994 07:08:02 GMT
  13238. Organization: Guru Inc
  13239.  
  13240. In article <1994Mar05.193948.1193292@bmug.org>
  13241. Ron_Hunsinger@bmug.org writes:
  13242.  
  13243. > Michael Peirce,peirce@outpost.SF-Bay.org writes:
  13244. > >Does anyone know how to find the System Folder on a volume that isn't
  13245. > >the startup volume?
  13246. > Its directoryID is the first longword of vcbFndrInfo.  This isn't
  13247. > documented anywhere, but I don't see how they can change it, since
  13248. > the ROM has to be getting the system folder from here at bootup.
  13249. Except that I do not believe that the rom gets this information... 
  13250. That is all done by the boot blocks...   just my $0.02 nitpicking!
  13251.  
  13252. Allan Foster
  13253.  
  13254. - --------------------------------------------------------
  13255. I am responsible for what I say and do. -- Allan Foster --
  13256.  
  13257. ---------------------------
  13258.  
  13259. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  13260. Subject: Trap dispatcher overhead
  13261. Date: Tue,  1 Mar 1994 19:23:18 -0500
  13262. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  13263.  
  13264. Every few days, a post floats by here saying "Don't call toolbox traps
  13265. in time-critical loops; they take forever." How long is forever? I mean,
  13266. is there a nice rule like "a trap dispatch is worth 27 pointer
  13267. dereferences on a '030 CPU"?
  13268.  
  13269. What about "idiot" toolbox calls (like SetRectSize or OffsetRect, that
  13270. would be blindingly fast if compiled inline)? Is is worth #defining
  13271. macros to replace them, or do the header files take care of this? (I'd
  13272. look, but I'm not at my Mac right now.) (Think C 5.0.4 header files, if
  13273. it matters.)
  13274.  
  13275. And, most importantly :-) why doesn't Inside Macintosh tell you about
  13276. this? I originally assumed that a toolbox call was as fast as any other
  13277. function call, with maybe a couple of memory lookups and register loads
  13278. tacked on.
  13279.  
  13280. --Z
  13281.  
  13282. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  13283.  
  13284. +++++++++++++++++++++++++++
  13285.  
  13286. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  13287. Date: Wed, 02 Mar 1994 00:09:17 -0600
  13288. Organization: University of Illinois at Urbana-Champaign
  13289.  
  13290. In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>, "Andrew C. Plotkin"
  13291. <ap1i+@andrew.cmu.edu> wrote:
  13292.  
  13293. >Every few days, a post floats by here saying "Don't call toolbox traps
  13294. >in time-critical loops; they take forever." How long is forever? I mean,
  13295. >is there a nice rule like "a trap dispatch is worth 27 pointer
  13296. >dereferences on a '030 CPU"?
  13297.  
  13298. Examples: On the original 68000, the trap itself takes 34 clock cycles. On
  13299. the 68030, it takes 18-20 cycles. The trap dispatcher takes some amount of
  13300. time to figure out what routine to call for an individual trap word, so
  13301. you would have to add on the time it takes to go through a small search.
  13302. Then the RTE is 20 cycles on the 68000, or 18-20 cycles on the 68030. So
  13303. altogether, we're probably talking about something on the order of a
  13304. divide instruction. That's a good chunk of overhead for silly things like
  13305. SetRect, but not bad at all for other things.
  13306.  
  13307. pr
  13308. -- 
  13309. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  13310. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  13311. System manager - Cognitive Science Group, Beckman Institute, UIUC
  13312. Internet: resnick@cogsci.uiuc.edu
  13313.  
  13314. +++++++++++++++++++++++++++
  13315.  
  13316. >From ari@world.std.com (Ari I Halberstadt)
  13317. Date: Sat, 5 Mar 1994 11:11:29 GMT
  13318. Organization: The World Public Access UNIX, Brookline, MA
  13319.  
  13320. In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>,
  13321. Andrew C. Plotkin <ap1i+@andrew.cmu.edu> wrote:
  13322. >Every few days, a post floats by here saying "Don't call toolbox traps
  13323. >in time-critical loops; they take forever." How long is forever? I mean,
  13324. >is there a nice rule like "a trap dispatch is worth 27 pointer
  13325. >dereferences on a '030 CPU"?
  13326.  
  13327. If speed of execution is truly critical then you're better off not
  13328. using a Toolbox trap. For instance, context switches for threads
  13329. should be very efficient. In my Thread Library (a publicly available
  13330. implementation of nonpreemptive threads), threads are scheduled for
  13331. execution at a certain time. I wanted to reduce the time spent in
  13332. context switches, and since the scheduling loop was already pretty
  13333. minimal I substituted the use of the TickCount trap with a direct
  13334. access to the Ticks low-memory global. This resulted in nearly a 50%
  13335. decrease in the time spent in scheduling context switches. Apple's
  13336. Thread Manager is slower than Thread Library. I suspect that, at least
  13337. in part, the slowness of Apple's Thread Manager is due to its use of
  13338. traps.
  13339.  
  13340. You should, however, take great pains to use documented traps to
  13341. access the operating system. Before using the Ticks low-memory global,
  13342. I tried calling the TickCount trap only once. Instead of something
  13343. like the following:
  13344.  
  13345.   for (each thread) {
  13346.      if (TickCount() - thread->went_to_sleep >= thread->sleep_time)
  13347.         activate this thread;
  13348.   }
  13349.  
  13350. you could cache the value of TickCount, assuming the inner loop would
  13351. execute in less than 1 tick (a valid assumption for many operations).
  13352.  
  13353.   unsigned long ticks;
  13354.  
  13355.   ticks = TickCount();
  13356.   for (each thread) {
  13357.      if (ticks >= thread->time_to_wakeup) // we precalculated time_to_wakeup
  13358.        activate this thread;
  13359.   }
  13360.  
  13361. Only if this is not feasible (because the loop takes too long), or is
  13362. still too slow, should you use the Ticks low-memory global.
  13363. -- 
  13364. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  13365. "These beetles were long considered to be very rare because very few
  13366. entomologists look for beetles in the mountains, in winter, at night,
  13367. during snow storms." -- Purves W. K., et al, "Life: The Science of
  13368.  
  13369. +++++++++++++++++++++++++++
  13370.  
  13371. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  13372. Date: Wed,  9 Mar 1994 11:45:19 -0500
  13373. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  13374.  
  13375. In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>,
  13376. Andrew C. Plotkin <ap1i+@andrew.cmu.edu> wrote:
  13377. >Every few days, a post floats by here saying "Don't call toolbox traps
  13378. >in time-critical loops; they take forever." How long is forever? I mean,
  13379. >is there a nice rule like "a trap dispatch is worth 27 pointer
  13380. >dereferences on a '030 CPU"?
  13381.  
  13382. A small experiment (what, facts on the Net?) has determined that calling
  13383. the SetRect trap takes about -four times- the time of the equivalent
  13384. four assignment statements.
  13385.  
  13386. Parameters: 
  13387. '040 CPU, Centris 610
  13388. virtual memory off, 32-bit mode off
  13389. Think C 5.0.4, no optimization
  13390. A loop which just calls SetRect (or the equivalent macro) 10^n times,
  13391. same arguments each time, none of the arguments equal to zero. (Yes, I
  13392. disassembled the code and made sure it wasn't sneakily optimizing
  13393. anything away behind my back.)
  13394.  
  13395. The object size difference was a few bytes (four or six, I think), which
  13396. is unlikely to be a big deal.
  13397.  
  13398. So I put SetRect and SetPt macros into my project. And immediately it
  13399. stopped working right. Sigh. Turned out I had two calls of the form
  13400.     SetRect(&box, x, y, x+box.right-box.left, y+box.bottom-box.top);
  13401. and changing the function call to a macro changed the semantics! Heh. Be
  13402. warned.
  13403.  
  13404. Conclusion: it's worthwhile, but be careful. And in C++ you probably
  13405. want to declare an inline function rather than a macro.
  13406.  
  13407. --Z
  13408.  
  13409. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  13410.  
  13411. +++++++++++++++++++++++++++
  13412.  
  13413. >From macguru@halcyon.com. (Allan Foster)
  13414. Date: 10 Mar 1994 07:12:12 GMT
  13415. Organization: Guru Inc
  13416.  
  13417. In article <whTToTS00gpIFYYFsM@andrew.cmu.edu>
  13418. "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu> writes:
  13419.  
  13420. > In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>,
  13421. > Andrew C. Plotkin <ap1i+@andrew.cmu.edu> wrote:
  13422. > >Every few days, a post floats by here saying "Don't call toolbox traps
  13423. > >in time-critical loops; they take forever." How long is forever? I mean,
  13424. > >is there a nice rule like "a trap dispatch is worth 27 pointer
  13425. > >dereferences on a '030 CPU"?
  13426. > A small experiment (what, facts on the Net?) has determined that calling
  13427. > the SetRect trap takes about -four times- the time of the equivalent
  13428. > four assignment statements.
  13429.  
  13430. The trap dispatcher overhead is in the order of 120 Cycles, depending
  13431. on the machine, and which trap you are calling....  I believe that
  13432. toolbox traps take slightly longer,  (140?? cycles)
  13433.  
  13434. It is a fact that the trivial traps should rather be coded inline. 
  13435. These being SetPt, EqualPt and even the Rect calls should be inline.
  13436.  
  13437. In fact, I believe that the new MPW glue libraries actually implement
  13438. some these functions as glue rather than the trap call....  
  13439.  
  13440. For most other traps, the overhead of the dispatcher becomes
  13441. insignificant.
  13442.  
  13443. Allan Foster
  13444.  
  13445. - --------------------------------------------------------
  13446. I am responsible for what I say and do. -- Allan Foster --
  13447.  
  13448. +++++++++++++++++++++++++++
  13449.  
  13450. >From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  13451. Date: 10 Mar 1994 14:47:33 GMT
  13452. Organization: University of Iceland
  13453.  
  13454. In <2lmh8c$5l4@nwfocus.wa.com> macguru@halcyon.com. (Allan Foster) writes:
  13455.  
  13456. >In article <whTToTS00gpIFYYFsM@andrew.cmu.edu>
  13457. >"Andrew C. Plotkin" <ap1i+@andrew.cmu.edu> writes:
  13458.  
  13459. >> In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>,
  13460. >> Andrew C. Plotkin <ap1i+@andrew.cmu.edu> wrote:
  13461. >> >Every few days, a post floats by here saying "Don't call toolbox traps
  13462. [snip]
  13463. >> 
  13464.  
  13465. >The trap dispatcher overhead is in the order of 120 Cycles, depending
  13466. >on the machine, and which trap you are calling....  I believe that
  13467. >toolbox traps take slightly longer,  (140?? cycles)
  13468.  
  13469.   When virtual memory is enabled you get some additional overhead.
  13470. Basically what happens is that the a-trap traps to supervisory level via
  13471. the VBR trap vector, then there's a shift back down to user level, and
  13472. a jump to the original lomem trap vector. I sometimes wonder if this
  13473. additional a-trap overhead is the main cause for the apparent slowdown
  13474. when VM is on.
  13475. -- 
  13476. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  13477. Kambasel 26            | for instance declares f as an array of unspecified 
  13478. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  13479. sigurasg@rhi.hi.is     | functions that return void... I think"
  13480.  
  13481. +++++++++++++++++++++++++++
  13482.  
  13483. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  13484. Date: 10 Mar 1994 18:58:48 GMT
  13485. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  13486.  
  13487.  
  13488. In article <2lmh8c$5l4@nwfocus.wa.com> macguru@halcyon.com. (Allan Foster) writes:
  13489. > In article <whTToTS00gpIFYYFsM@andrew.cmu.edu>
  13490. > "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu> writes:
  13491. > > 
  13492. > > A small experiment (what, facts on the Net?) has determined that calling
  13493. > > the SetRect trap takes about -four times- the time of the equivalent
  13494. > > four assignment statements.
  13495. >
  13496. > The trap dispatcher overhead is in the order of 120 Cycles, depending
  13497. > on the machine, and which trap you are calling....  I believe that
  13498. > toolbox traps take slightly longer,  (140?? cycles)
  13499. >
  13500. > It is a fact that the trivial traps should rather be coded inline. 
  13501. > These being SetPt, EqualPt and even the Rect calls should be inline.
  13502.  
  13503. last night i wrote a program which takes a PEF application as input and
  13504. modifies the app so that all calls to SetRect and SetPt are made "inline".
  13505. (well, OK, i had written all of the PEF parsing stuff earlier, i just
  13506. had to modify it to scan for and modify these routines).
  13507.  
  13508. it does this by replacing the 6-instruction global linkage for the routine
  13509. with an implementation of the routine itself.  this can be done for any
  13510. routine that can be implemented in 5 (or fewer) PowerPC instructions.
  13511.  
  13512. basically, i convert:             into:
  13513.  
  13514. glink:   lwz     r12,xx(r2)            subic   r3,r3,2
  13515.          stw     r2,0x14(r1)           sthu    r5,2(r3)
  13516.          lwz     r0,0x0(r12)           sthu    r4,2(r3)
  13517.          lwz     r2,0x4(r12)           sthu    r7,2(r3)
  13518.          mtctr   r0                    sthu    r6,2(r3)
  13519.          bctr                          blr
  13520.  
  13521. i haven't tested it yet (since i don't have a PowerMac), but i see
  13522. no reason why this shouldn't work.  the only "worry" i have is that
  13523. it trashes r3 (which contains the ptr to the rect), but since SetRect
  13524. doesn't return a value and r3-r10 are volatile, i believe that this
  13525. should be OK.
  13526.  
  13527. anyway, i can't distribute this yet because of licensing issues that i
  13528. have to work out with Apple.  i wrote the code, but it's based on some
  13529. of Apple's headers -- so i need to make sure that things are OK before
  13530. i release it.  i'll post it somewhere as soon as these issues are
  13531. resolved.
  13532.  
  13533.  
  13534. -gary j kacmarcik
  13535. platypus@curie.ces.cwru.edu
  13536.  
  13537. +++++++++++++++++++++++++++
  13538.  
  13539. >From rollin@newton.apple.com (Keith Rollin)
  13540. Date: Sun, 13 Mar 1994 01:42:44 GMT
  13541. Organization: Apple Computer, Inc.
  13542.  
  13543. In article <whTToTS00gpIFYYFsM@andrew.cmu.edu>, "Andrew C. Plotkin"
  13544. <ap1i+@andrew.cmu.edu> wrote:
  13545.  
  13546. > In article <MhQxlq600gpI0WyHdn@andrew.cmu.edu>,
  13547. > Andrew C. Plotkin <ap1i+@andrew.cmu.edu> wrote:
  13548. > >Every few days, a post floats by here saying "Don't call toolbox traps
  13549. > >in time-critical loops; they take forever." How long is forever? I mean,
  13550. > >is there a nice rule like "a trap dispatch is worth 27 pointer
  13551. > >dereferences on a '030 CPU"?
  13552. > A small experiment (what, facts on the Net?) has determined that calling
  13553. > the SetRect trap takes about -four times- the time of the equivalent
  13554. > four assignment statements.
  13555. > Parameters: 
  13556. > '040 CPU, Centris 610
  13557. > virtual memory off, 32-bit mode off
  13558. > Think C 5.0.4, no optimization
  13559. > A loop which just calls SetRect (or the equivalent macro) 10^n times,
  13560. > same arguments each time, none of the arguments equal to zero. (Yes, I
  13561. > disassembled the code and made sure it wasn't sneakily optimizing
  13562. > anything away behind my back.)
  13563. > The object size difference was a few bytes (four or six, I think), which
  13564. > is unlikely to be a big deal.
  13565. > So I put SetRect and SetPt macros into my project. And immediately it
  13566. > stopped working right. Sigh. Turned out I had two calls of the form
  13567. >     SetRect(&box, x, y, x+box.right-box.left, y+box.bottom-box.top);
  13568. > and changing the function call to a macro changed the semantics! Heh. Be
  13569. > warned.
  13570. > Conclusion: it's worthwhile, but be careful. And in C++ you probably
  13571. > want to declare an inline function rather than a macro.
  13572.  
  13573.  
  13574. And after you started using the macros, was there any discernable
  13575. difference in the execution speed of your program? Was there any measurable
  13576. difference in the speed of your program?
  13577.  
  13578. I want to thank you for actually performing the experiment and seeing what
  13579. the effect of the trap dispatcher has on small functions like SetRect and
  13580. SetPt. But before a "ban calling through the trap dispatcher" campaign gets
  13581. started, I want to highlight two things:
  13582.  
  13583. 1) The overhead of the trap dispatcher is negligable for most calls. For
  13584. instance, it would be interesting to see what measurable difference there
  13585. is in calling LineTo via the trap dispatcher and calling it directly (after
  13586. a GetTrapAddress call).
  13587.  
  13588. 2) Even when there is a measurable difference, is there an _apparent_
  13589. difference? Is it worth the hassle and compatibility problems of
  13590. re-implementing system functionality inline or calling a system function
  13591. directly?
  13592.  
  13593. - --------------------------------------------------------------------------
  13594. Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team
  13595. Newton
  13596.  
  13597. +++++++++++++++++++++++++++
  13598.  
  13599. >From mxmora@unix.sri.com (Matt Mora)
  13600. Date: 16 Mar 1994 16:32:25 -0800
  13601. Organization: SRI International, Menlo Park, CA
  13602.  
  13603. In article <rollin-120394174244@rollin-keith.apple.com> rollin@newton.apple.com (Keith Rollin) writes:
  13604.  
  13605. >2) Even when there is a measurable difference, is there an _apparent_
  13606. >difference? Is it worth the hassle and compatibility problems of
  13607. >re-implementing system functionality inline or calling a system function
  13608. >directly?
  13609.  
  13610. The original thread was about doing his own line drawing by writing
  13611. directly to screen. If he didn't care about that incompatibility,
  13612. then calling the trap directly is the lesser of the two evils. If your
  13613. goal is speed, calling a trap isn't going to help, no matter how
  13614. small the overhead.
  13615.  
  13616. Xavier
  13617.  
  13618. -- 
  13619. ___________________________________________________________
  13620. Matthew Xavier Mora                       Matt_Mora@sri.com
  13621. SRI International                       mxmora@unix.sri.com
  13622. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  13623.  
  13624. ---------------------------
  13625.  
  13626. >From jclark@galaxy.csc.calpoly.edu (Joseph V Clarke)
  13627. Subject: User in a menu?
  13628. Date: Tue, 08 Mar 94 19:16:35 GMT
  13629. Organization: Computer Science Department, Cal Poly SLO
  13630.  
  13631.  
  13632. An event is only generated when a menu item has been selected...
  13633. So how could I find out if the user is clicking on a menu..
  13634. (not neccessarily selecting an item, though.)  Can I patch
  13635. some kind of interrupt handler?  My application is real time
  13636. intensive and when someone holds down the menu, my app loses control
  13637. of the mac and the real time is lost (the data is crunched and when
  13638. I release the menu, it gushes out...thereby not accurately representing
  13639. the data.)
  13640.  
  13641. I would just like to clear the buffer and eliminate the data if the
  13642. user happened to be in the menu for awhile.  Suggestions?
  13643.  
  13644. Thanks for your time!
  13645.  
  13646. Joseph
  13647. -- 
  13648. Telemidi - A Mac application that allows 2 musicians to instantaneously express
  13649.            their musical ideas in real time over the phone lines.
  13650. Joseph V. Clarke ===================================== jclark@galaxy.calpoly.edu
  13651.  
  13652. +++++++++++++++++++++++++++
  13653.  
  13654. >From sw@network-analysis-ltd.co.uk (Sak Wathanasin)
  13655. Date: Wed, 9 Mar 94 19:52:17 GMT
  13656. Organization: Network Analysis Ltd
  13657.  
  13658.  
  13659. In article <1994Mar08.191635.25383@rat.csc.calpoly.edu> (comp.sys.mac.programmer), jclark@galaxy.csc.calpoly.edu (Joseph V Clarke) writes:
  13660. > some kind of interrupt handler?  My application is real time
  13661. > intensive and when someone holds down the menu, my app loses control
  13662. > of the mac and the real time is lost (the data is crunched and when
  13663. > I release the menu, it gushes out...thereby not accurately representing
  13664. > the data.)
  13665. > I would just like to clear the buffer and eliminate the data if the
  13666. > user happened to be in the menu for awhile.  Suggestions?
  13667.  
  13668. Try using a MenuHook proc: see Inside Mac vol 1 pg 356.
  13669.  
  13670.  
  13671. Sak Wathanasin
  13672. Network Analysis Limited
  13673. 178 Wainbody Ave South, Coventry CV3 6BX, UK
  13674.  
  13675. Internet: sw@network-analysis-ltd.co.uk 
  13676. uucp:     ...!uknet!nan!sw                       AppleLink: NAN.LTD
  13677. Phone: (+44) 203 419996 Mobile:(+44) 850 587411  Fax: (+44) 203 690690
  13678.  
  13679. +++++++++++++++++++++++++++
  13680.  
  13681. >From paulr@syma.sussex.ac.uk (Paul Russell)
  13682. Date: Thu, 10 Mar 1994 14:41:27 GMT
  13683. Organization: University of Sussex
  13684.  
  13685. Sak Wathanasin (sw@network-analysis-ltd.co.uk) wrote:
  13686.  
  13687. : In article <1994Mar08.191635.25383@rat.csc.calpoly.edu> (comp.sys.mac.programmer), jclark@galaxy.csc.calpoly.edu (Joseph V Clarke) writes:
  13688. : > some kind of interrupt handler?  My application is real time
  13689. : > intensive and when someone holds down the menu, my app loses control
  13690. : > of the mac and the real time is lost (the data is crunched and when
  13691. : > I release the menu, it gushes out...thereby not accurately representing
  13692. : > the data.)
  13693. : > 
  13694. : > I would just like to clear the buffer and eliminate the data if the
  13695. : > user happened to be in the menu for awhile.  Suggestions?
  13696.  
  13697. : Try using a MenuHook proc: see Inside Mac vol 1 pg 356.
  13698.  
  13699. I wrote a little background tasking unit for a comms program a
  13700. few years back and I spent some time working out which traps
  13701. needed to be patched in order to get regular calls regardless
  13702. of what the user is doing.
  13703.  
  13704. It turns out that you can do this by patching two traps - GetNextEvent and
  13705. OSEventAvail (I think). GetNextEvent gets called most of the time and
  13706. OSEventAvail gets called when the mouse is down in a menu. (BTW,
  13707. WaitNextEvent calls GetNextEvent).
  13708.  
  13709. You need to make sure that your patches are in the System heap so that
  13710. they still get called when your application is switched to the background.
  13711.  
  13712. Doing this is much nicer than using VBL's, particularly when it comes
  13713. to debugging...
  13714.  
  13715. //Paul
  13716.  
  13717. -- 
  13718. |  Paul Russell               |  Internet:  P.T.Russell@sussex.ac.uk  |
  13719. |  Experimental Psychology    |  AppleLink: EP.SUSSEX                 |
  13720. |  Sussex University, Falmer  |  Telephone: +44 273 678639            |
  13721. |  Brighton BN1 9QG, England  |  Facsimile: +44 273 678433            |
  13722.  
  13723. +++++++++++++++++++++++++++
  13724.  
  13725. >From dean@genmagic.com (Dean Yu)
  13726. Date: 10 Mar 1994 21:46:46 GMT
  13727. Organization: General Magic, Inc.
  13728.  
  13729. In article <1994Mar08.191635.25383@rat.csc.calpoly.edu>
  13730. (comp.sys.mac.programmer), jclark@galaxy.csc.calpoly.edu (Joseph V Clarke)
  13731. writes:
  13732. > some kind of interrupt handler?  My application is real time
  13733. > intensive and when someone holds down the menu, my app loses control
  13734. > of the mac and the real time is lost (the data is crunched and when
  13735. > I release the menu, it gushes out...thereby not accurately representing
  13736. > the data.)
  13737. > I would just like to clear the buffer and eliminate the data if the
  13738. > user happened to be in the menu for awhile.  Suggestions?
  13739.  
  13740.   Assuming that this is an application of your own creation, and you're not
  13741. using some application framework, you know when the user started mousing
  13742. around in a menu because you called MenuSelect, and you know when the user
  13743. let go of the button because MenuSelect returns.
  13744.  
  13745. -- Dean Yu
  13746.    Negative Ethnic Role Model
  13747.    General Magic, Inc.
  13748.  
  13749. +++++++++++++++++++++++++++
  13750.  
  13751. >From KLUEV@jonathan.srcc.msu.su
  13752. Date: Sat, 12 Mar 1994 21:14:18 +0300
  13753. Organization: (none)
  13754.  
  13755. In article <1994Mar10.144127.15078@syma.sussex.ac.uk>
  13756. paulr@syma.sussex.ac.uk (Paul Russell) writes:
  13757. >Sak Wathanasin (sw@network-analysis-ltd.co.uk) wrote:
  13758. >
  13759. >: In article <1994Mar08.191635.25383@rat.csc.calpoly.edu> (comp.sys.mac.programmer), jclark@galaxy.csc.calpoly.edu (Joseph V Clarke) writes:
  13760. >: > some kind of interrupt handler?  My application is real time
  13761. >: > intensive and when someone holds down the menu, my app loses control
  13762. >: > of the mac and the real time is lost (the data is crunched and when
  13763. >: > I release the menu, it gushes out...thereby not accurately representing
  13764. >: > the data.)
  13765.  
  13766. >: Try using a MenuHook proc: see Inside Mac vol 1 pg 356.
  13767. >
  13768. >I wrote a little background tasking unit for a comms program a
  13769. >few years back and I spent some time working out which traps
  13770. >needed to be patched in order to get regular calls regardless
  13771. >of what the user is doing.
  13772. >
  13773. >It turns out that you can do this by patching two traps - GetNextEvent and
  13774. >OSEventAvail (I think). GetNextEvent gets called most of the time and
  13775. >OSEventAvail gets called when the mouse is down in a menu. (BTW,
  13776. >WaitNextEvent calls GetNextEvent).
  13777. >
  13778. >You need to make sure that your patches are in the System heap so that
  13779. >they still get called when your application is switched to the background.
  13780.  
  13781. This "system heapness" works only with VBL's, i.e. if your VBL proc
  13782. resides in sysHeap, it (proc) will not be swapped on MF switch.
  13783. This trick will not work with patching traps.
  13784. It is "near" to be impossible to make a global patch from within an
  13785. application, so you need an INIT; and if you want not an INIT but
  13786. an application - you need VBL (or other int. time)
  13787.  
  13788. Why "near"? One can install a TM or VBL task and patch the trap
  13789. for currently running application. Red banner.
  13790.  
  13791. Michael Kluev.
  13792.  
  13793. ---------------------------
  13794.  
  13795. >From jfinete@cats.ucsc.edu (Joseph Manuel Finete)
  13796. Subject: What happens if my Vertical Retrace task takes too long?
  13797. Date: 3 Mar 1994 01:33:00 GMT
  13798. Organization: University of California; Santa Cruz
  13799.  
  13800.  
  13801. My understanding of the vertical retrace manager is that you supply an
  13802. number of ticks to wait before calling the vertical retrace task, and that
  13803. your task function should update this number when it's finished.
  13804.  
  13805. My question is, if my task takes longer than one tick (1/60 th of a
  13806. second) will the number of ticks between tasks be the number of ticks
  13807. to complete the task plus the number of interval ticks? Is there any
  13808. danger in having a vertical retrace task that can't be completed in one
  13809. tick?
  13810.  
  13811. -- 
  13812. Joe Finete
  13813. jfinete@cats.ucsc.edu
  13814.  
  13815. +++++++++++++++++++++++++++
  13816.  
  13817. >From ari@world.std.com (Ari I Halberstadt)
  13818. Date: Thu, 3 Mar 1994 06:40:51 GMT
  13819. Organization: The World Public Access UNIX, Brookline, MA
  13820.  
  13821. In article <2l3eoc$k6q@darkstar.ucsc.edu>,
  13822. >My understanding of the vertical retrace manager is that you supply an
  13823. >number of ticks to wait before calling the vertical retrace task, and that
  13824. >your task function should update this number when it's finished.
  13825.  
  13826. That's true.
  13827.  
  13828. >My question is, if my task takes longer than one tick (1/60 th of a
  13829. >second) will the number of ticks between tasks be the number of ticks
  13830. >to complete the task plus the number of interval ticks? Is there any
  13831. >danger in having a vertical retrace task that can't be completed in one
  13832. >tick?
  13833.  
  13834. You definitely don't want your task to take longer than 1/60th of a
  13835. second. In fact, you want it to take substantially less than 1/60th of
  13836. a second, since there are bound to be other tasks the processor has to
  13837. handle. If your task takes too long all sorts of things will get
  13838. messed up, including cursor tracking, the Ticks low-memory global,
  13839. other VBL tasks that need to be executed every 1/60th of a second,
  13840. video updates etc. The CPU can accomplish quite a bit of processing in
  13841. a fraction of 1/60th of a second. If your task is that compute
  13842. intensive you should probably run it during null event processing.
  13843.  
  13844. For precise intervals between tasks you should investigate the
  13845. extended time manager, though even that won't work well if tasks take
  13846. too long. I've found that time manager tasks on a Mac Plus work ok up
  13847. to about 1/100th of a second, more frequent than that and the machine
  13848. gets pretty slow; this probably applies to other 68000 machines,
  13849. though faster CPUs should be able to handle smaller time slices.
  13850. -- 
  13851. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  13852. "These beetles were long considered to be very rare because very few
  13853. entomologists look for beetles in the mountains, in winter, at night,
  13854. during snow storms." -- Purves W. K., et al, "Life: The Science of
  13855.  
  13856. ---------------------------
  13857.  
  13858. >From rang@winternet.mpls.mn.us (Anton Rang)
  13859. Subject: When to StripAddress?  (was Re: Let's kill 24-bit mode!)
  13860. Date: 16 Mar 1994 01:33:27 GMT
  13861. Organization: Minnesota Angsters
  13862.  
  13863. In article <t-gaul-150394171035@infinity.i-link.com> t-gaul@i-link.com (Troy Gaul) writes:
  13864. >There are cases where you must call StripAddress for a program to function
  13865. >correctly in all 'modes'. It is possible that you haven't run across them.
  13866.  
  13867.   One which bit me last year, that I never did find documented....
  13868. It's important to call StripAddress() on any value that you pass to
  13869. InitZone().  Otherwise, something internal to the memory manager
  13870. starts to strip *some* addresses in the zone, but not others, and it
  13871. all flies apart....
  13872.  
  13873.   Other than that, hmm.  When you patch traps or change hooks (like
  13874. the routines in a GrafPort, or low-memory globals), make sure that you
  13875. call StripAddress() first.  The system might switch into 32-bit mode
  13876. and then call your routine.  (I'm sure this happens for very few
  13877. cases, but I've seen it cause problems before.)
  13878.  
  13879.   And, obviously, if you're switching modes yourself.  :-)
  13880. --
  13881. Anton Rang (rang@winternet.mpls.mn.us)
  13882.  
  13883. ---------------------------
  13884.  
  13885. >From AIKEN <INRA000@MUSICB.MCGILL.CA>
  13886. Subject: Why can't I have AEs *in* AEs?
  13887. Date: Fri, 25 Feb 1994 02:35:52 GMT
  13888. Organization: McGill University
  13889.  
  13890.     For reasons of my own (yes, I am sick and twisted) I am trying to
  13891. add an Apple Event to another Apple event as a paramater. My code
  13892. looks something like:
  13893.  
  13894. **
  13895. AppleEvent AEToSend,AEToInclude;
  13896.  
  13897.     Error=AEPutParamDesc(&AEToSend,keyDirectObject,&AEToInclude);
  13898. **
  13899.  
  13900.     the AE Manager just barfs up a -1703 err, "Wrong descriptor type".
  13901. Is this not something I'm supposed to be contemplating, or am I mis-
  13902. sing something?
  13903.  
  13904.     The funny thing is, if I do a AEPutParamPtr like:
  13905.  
  13906.     Error=AEPutParamPtr(&AEToSend,keyDirectObject,'aevt',
  13907.         &AEToInclude,sizeof(AppleEvent));
  13908.  
  13909.     Everything is hunky-dory. However, I'm concerned that this method
  13910. does not make a true duplicate of AEToInclude, which will definately
  13911. raise hell down the line. This is confusing, however, because both
  13912. methods should produce a paramater with the same keyword and descriptor
  13913. type, no?
  13914.  
  13915.     Insights *greatly* appreciated.
  13916.  
  13917.     Mark Aiken
  13918.     inra@musicb.mcgill.ca
  13919.  
  13920.  
  13921. +++++++++++++++++++++++++++
  13922.  
  13923. >From jwbaxter@olympus.net (John W. Baxter)
  13924. Date: Fri, 25 Feb 1994 00:43:56 -0800
  13925. Organization: Internet for the Olympic Peninsula
  13926.  
  13927. In article <24FEB94.23325740.0070@VM1.MCGILL.CA>, AIKEN
  13928. <INRA000@MUSICB.MCGILL.CA> wrote:
  13929.  
  13930. >     For reasons of my own (yes, I am sick and twisted) I am trying to
  13931. > add an Apple Event to another Apple event as a paramater. My code
  13932. > looks something like:
  13933. > **
  13934. > AppleEvent AEToSend,AEToInclude;
  13935. >     Error=AEPutParamDesc(&AEToSend,keyDirectObject,&AEToInclude);
  13936. > **
  13937. >     the AE Manager just barfs up a -1703 err, "Wrong descriptor type".
  13938. > Is this not something I'm supposed to be contemplating, or am I mis-
  13939. > sing something?
  13940.  
  13941. Hmmm...surprising that it's not allowed (although it's also surprising you
  13942. want to do this).  An Apple Event is almost an AERecord (but not quite).
  13943.  
  13944. >     The funny thing is, if I do a AEPutParamPtr like:
  13945. >     Error=AEPutParamPtr(&AEToSend,keyDirectObject,'aevt',
  13946. >         &AEToInclude,sizeof(AppleEvent));
  13947.  
  13948. Not a good idea.
  13949.  
  13950. >     Everything is hunky-dory. However, I'm concerned that this method
  13951. > does not make a true duplicate of AEToInclude, which will definately
  13952. > raise hell down the line. This is confusing, however, because both
  13953. > methods should produce a paramater with the same keyword and descriptor
  13954. > type, no?
  13955.  
  13956. No.  Look at the AEPutParamPtr again.  The third parameter points to an
  13957. AppleEvent.  If you go back far enough, that's just an AEDesc.  A type, and
  13958. a handle.  sizeof (AppleEvent) is 8.  So you put the 8 bytes (the type),
  13959. and the value of the address of the block's master pointer into your
  13960. AEToSend as the '----' parameter.  I strongly suspect that's not what you
  13961. want to do.
  13962.  
  13963. What MAY work is this:
  13964. 1.  Build your AEToInclude in the usual way.
  13965. 2.  Close your eyes (figuratively), and stuff 'reco' into 
  13966. AEToInclude.descriptorType  ['reco' is also known as typeAErecord, and you
  13967. should use that constant, IMHO].
  13968. 3.  Now, you should be able to add your AEToInclude to AEToSend with
  13969. AEPutParamDesc ().
  13970. 4.  On the other end, knowing what is coming in, get the parameter using
  13971. AEGetParamDesc, and stuff typeAppleEvent ('aevt') into the descriptorType
  13972. field of the AEDesc.
  13973.  
  13974. The above will probably work today.  It's asking for trouble.
  13975.  
  13976. Do you *really* want to do this???  Or...can you get by with passing an
  13977. AERecord, instead?  You can make your own AEList of attributes, if needed.
  13978. -- 
  13979. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  13980.    jwbaxter@pt.olympus.net
  13981.  
  13982. +++++++++++++++++++++++++++
  13983.  
  13984. >From lai@apple.com (Ed Lai)
  13985. Date: 25 Feb 1994 17:27:15 GMT
  13986. Organization: Apple
  13987.  
  13988. > In article <24FEB94.23325740.0070@VM1.MCGILL.CA>, AIKEN
  13989. > <INRA000@MUSICB.MCGILL.CA> wrote:
  13990. > >     For reasons of my own (yes, I am sick and twisted) I am trying to
  13991. > > add an Apple Event to another Apple event as a paramater. My code
  13992. > > looks something like:
  13993. > > 
  13994. > > **
  13995. > > AppleEvent AEToSend,AEToInclude;
  13996. > > 
  13997. > >     Error=AEPutParamDesc(&AEToSend,keyDirectObject,&AEToInclude);
  13998. > > **
  13999. > > 
  14000. > >     the AE Manager just barfs up a -1703 err, "Wrong descriptor type".
  14001. > > Is this not something I'm supposed to be contemplating, or am I mis-
  14002. > > sing something?
  14003.  
  14004. The Apple Event Manager checks to make sure you cannot stuff an Apple Event
  14005. inside another Apple Event, list or record.
  14006.  
  14007. -- 
  14008. /* Disclaimer: All statments and opinions expressed are my own */
  14009. /* Edmund K. Lai                                               */
  14010. /* Apple Computer, MS303-3A                                    */
  14011. /* 20525 Mariani Ave,                                          */
  14012. /* Cupertino, CA 95014                                         */
  14013. /* (408)974-6272                                               */
  14014. zW@h9cOi
  14015.  
  14016. +++++++++++++++++++++++++++
  14017.  
  14018. >From AIKEN <INRA000@MUSICB.MCGILL.CA>
  14019. Date: Fri, 25 Feb 1994 23:27:21 GMT
  14020. Organization: McGill University
  14021.  
  14022. In article <lai-250294092517@mac254.kip.apple.com> lai@apple.com (Ed Lai) writes:
  14023. >The Apple Event Manager checks to make sure you cannot stuff an Apple Event
  14024. >inside another Apple Event, list or record.
  14025.  
  14026.     Since this is deliberate, I assume there is a logical reason why
  14027. this is so. However, I don't see it. What gives?
  14028.  
  14029.     Mark Aiken
  14030.     inra@musicb.mcgill.ca
  14031.  
  14032.  
  14033. +++++++++++++++++++++++++++
  14034.  
  14035. >From AIKEN <INRA000@MUSICB.MCGILL.CA>
  14036. Date: Fri, 25 Feb 1994 23:48:43 GMT
  14037. Organization: McGill University
  14038.  
  14039. In article <jwbaxter-250294004357@ptpm006.olympus.net> jwbaxter@olympus.net (John W. Baxter) writes:
  14040. >In article <24FEB94.23325740.0070@VM1.MCGILL.CA>, AIKEN
  14041. ><INRA000@MUSICB.MCGILL.CA> wrote:
  14042. >
  14043. >>     For reasons of my own (yes, I am sick and twisted) I am trying to
  14044. >> add an Apple Event to another Apple event as a paramater. My code
  14045. >> looks something like:
  14046.  
  14047. [CHOP -- trying AEPutParamDesc doesn't work.]
  14048.  
  14049. >>     The funny thing is, if I do a AEPutParamPtr like:
  14050. >>
  14051. >>     Error=AEPutParamPtr(&AEToSend,keyDirectObject,'aevt',
  14052. >>         &AEToInclude,sizeof(AppleEvent));
  14053. >
  14054. >Not a good idea.
  14055. >>
  14056. >>     Everything is hunky-dory. However, I'm concerned that this method
  14057. >> does not make a true duplicate of AEToInclude, which will definately
  14058. >> raise hell down the line. This is confusing, however, because both
  14059. >> methods should produce a paramater with the same keyword and descriptor
  14060. >> type, no?
  14061. >
  14062. >No.  Look at the AEPutParamPtr again.  The third parameter points to an
  14063. >AppleEvent.  If you go back far enough, that's just an AEDesc.  A type, and
  14064. >a handle.  sizeof (AppleEvent) is 8.  So you put the 8 bytes (the type),
  14065. >and the value of the address of the block's master pointer into your
  14066. >AEToSend as the '----' parameter.  I strongly suspect that's not what you
  14067. >want to do.
  14068.  
  14069.     I know.
  14070.  
  14071.     What confuses me is this: AEPutParamDesc with the above usage
  14072. should attempt to add a copy of the supplied Apple Event (type: 'aevt')
  14073. as the direct paramater. But as a helpful Apple Person (tm) pointed
  14074. out, the AE Manager specifically watches out for this. However,
  14075. AEPutParamPtr, with the above usage, *also* tries to add a hunk of data
  14076. as the direct paramater. The descriptor type, of course, is supplied
  14077. in the arguments. AEPutParamPtr is inappropriate here because it doesn't
  14078. copy all the associated data of the AE, just its 8-byte descriptor data.
  14079. However, I find it confounding that the AE Manager would agree to add
  14080. a descriptor record of type 'aevt' from certain calls and not from
  14081. others.
  14082.  
  14083. >What MAY work is this:
  14084. >1.  Build your AEToInclude in the usual way.
  14085. >2.  Close your eyes (figuratively), and stuff 'reco' into
  14086. >AEToInclude.descriptorType  ['reco' is also known as typeAErecord, and you
  14087. >should use that constant, IMHO].
  14088. >3.  Now, you should be able to add your AEToInclude to AEToSend with
  14089. >AEPutParamDesc ().
  14090. >4.  On the other end, knowing what is coming in, get the parameter using
  14091. >AEGetParamDesc, and stuff typeAppleEvent ('aevt') into the descriptorType
  14092. >field of the AEDesc.
  14093. >
  14094. >The above will probably work today.  It's asking for trouble.
  14095.  
  14096.     I'm having trouble understanding why this is all such a bad idea.
  14097. An AppleEvent descriptor record just points to a list of other stuff,
  14098. namely attributes and parameters, right? So why *shouldn't* I be able
  14099. to add it to another AE? Why is the above likely to break in future?
  14100.  
  14101. >Do you *really* want to do this???  Or...can you get by with passing an
  14102. >AERecord, instead?  You can make your own AEList of attributes, if needed.
  14103.  
  14104.     I don't *really* have to do this. It's just that at one point, I
  14105. have data in one AE that another app will need in an AE *it* will send
  14106. in response to an AE I'm about to send it (read that slowly!). It
  14107. seemed natural to stuff a copy of the pre-fab AE that the other app
  14108. will need into the AE I'm about to send it, so that at the other end,
  14109. the app can remove the enclosed AE, twiddle the address and maybe one
  14110. or two other things, and send it off. No fuss, no muss. Oh, well.
  14111.  
  14112.     Since both apps know exactly what's supposed to be in the AEs, I
  14113. can just bundle all the data into *one* AE, that the receiving app can
  14114. rip apart to put together its own AE. But it would have been nice
  14115. to be able to send it one already ready to go.
  14116.  
  14117.     I hadn't thought of your solution, though (thanks!), but I would
  14118. love an explanation as to why it's such a bad idea before I start using
  14119. it! :-)
  14120.  
  14121.     Mark Aiken
  14122.     inra@musicb.mcgill.ca
  14123.  
  14124.  
  14125. +++++++++++++++++++++++++++
  14126.  
  14127. >From jwbaxter@olympus.net (John W. Baxter)
  14128. Date: Sat, 26 Feb 1994 00:13:49 -0800
  14129. Organization: Internet for the Olympic Peninsula
  14130.  
  14131. In article <25FEB94.20317060.0081@VM1.MCGILL.CA>, AIKEN
  14132. <INRA000@MUSICB.MCGILL.CA> wrote:
  14133.  
  14134. [a few words of quotation left out]
  14135.  
  14136. >     I hadn't thought of your solution, though (thanks!), but I would
  14137. > love an explanation as to why it's such a bad idea before I start using
  14138. > it! :-)
  14139.  
  14140. Apple specifies that once you have done your inserting of something into
  14141. any of the AE structures, the layout of the contents of the structure are
  14142. unknown to you.  They do that in part because, I suspect, they are darn
  14143. tired of working around the clever things developers have done with
  14144. knowledge of such things (like forcing a whole bunch of extra structures in
  14145. a color window).
  14146.  
  14147. So, in principal, all you know is that you toss some bytes in one end, and
  14148. the same byte values come out the other end.
  14149.  
  14150. Having said that:  You say:
  14151. > An AppleEvent descriptor record just points to a list of other stuff,
  14152. > namely attributes and parameters, right?
  14153.  
  14154. No...it only looks that way.  At each stage, the structure is flattened,
  14155. and there's only one handle involved with the AEDesc, which contains copies
  14156. of everything that has been stuffed in, whether by xxxPtr, or xxxDesc.  At
  14157. least...it's that way this week (see above).
  14158.  
  14159. -- 
  14160. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  14161.    jwbaxter@pt.olympus.net
  14162.  
  14163. +++++++++++++++++++++++++++
  14164.  
  14165. >From peter@ncrpda.curtin.edu.au (Peter N Lewis)
  14166. Date: 27 Feb 1994 12:52:03 +0800
  14167. Organization: NCRPDA, Curtin University
  14168.  
  14169. lai@apple.com (Ed Lai) writes:
  14170.  
  14171. >The Apple Event Manager checks to make sure you cannot stuff an Apple Event
  14172. >inside another Apple Event, list or record.
  14173.  
  14174. Stupid question: Why?
  14175.    Peter.
  14176. -- 
  14177. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  14178.  
  14179. +++++++++++++++++++++++++++
  14180.  
  14181. >From Patrick C. Beard <beard@cs.ucdavis.edu>
  14182. Date: Mon, 28 Feb 1994 01:38:35 GMT
  14183. Organization: Dept. Of Computer Science, U.C. Davis
  14184.  
  14185. In article <24FEB94.23325740.0070@VM1.MCGILL.CA> AIKEN,
  14186. INRA000@MUSICB.MCGILL.CA writes:
  14187. >    For reasons of my own (yes, I am sick and twisted) I am trying to
  14188. >add an Apple Event to another Apple event as a paramater. My code
  14189. >looks something like:
  14190. >
  14191. >**
  14192. >AppleEvent AEToSend,AEToInclude;
  14193. >
  14194. >    Error=AEPutParamDesc(&AEToSend,keyDirectObject,&AEToInclude);
  14195. >**
  14196. >
  14197. >    the AE Manager just barfs up a -1703 err, "Wrong descriptor type".
  14198. >Is this not something I'm supposed to be contemplating, or am I mis-
  14199. >sing something?
  14200.  
  14201. I ran into the same problem. My solution? Lie to the AppleEvent manager. 
  14202. There's no reason it has to know the type of a parameter. Just make up 
  14203. one of your own.
  14204.  
  14205. Since an AppleEvent is just an AEDesc with a descriptorType and a
  14206. dataHandle,
  14207. and the type is always 'aevt', just do the following:
  14208.  
  14209.     OSErr StuffAE(AppleEvent* event, AppleEvent* nestedEvent)
  14210.     {
  14211.         OSErr result;
  14212.         
  14213.         Handle eventData = nestedEvent->dataHandle;
  14214.         HLock(eventData);
  14215.         result = AEPutParamPtr(&event, keyDirectObject, 'stuff', *eventData,
  14216.                             GetHandleSize(eventData));
  14217.         HUnlock(eventData);
  14218.         return result;
  14219.     }
  14220.  
  14221. I've used this approach, and it works.
  14222. //
  14223. // Patrick C. Beard
  14224. // Dept. of Computer Science, U. C. Davis
  14225. // beard@cs.ucdavis.edu
  14226. //
  14227.  
  14228. +++++++++++++++++++++++++++
  14229.  
  14230. >From lai@apple.com (Ed Lai)
  14231. Date: 5 Mar 1994 00:36:19 GMT
  14232. Organization: Apple
  14233.  
  14234. In article <25FEB94.19932459.0081@VM1.MCGILL.CA>, AIKEN
  14235. <INRA000@MUSICB.MCGILL.CA> wrote:
  14236.  
  14237. > In article <lai-250294092517@mac254.kip.apple.com> lai@apple.com (Ed Lai) writes:
  14238. > >The Apple Event Manager checks to make sure you cannot stuff an Apple Event
  14239. > >inside another Apple Event, list or record.
  14240. >     Since this is deliberate, I assume there is a logical reason why
  14241. > this is so. However, I don't see it. What gives?
  14242. >     Mark Aiken
  14243. >     inra@musicb.mcgill.ca
  14244.  
  14245. Well, the answer is that the Apple Event Manager is just one of the
  14246. implementations of Apple Event, and the Apple Event Transport Format
  14247. (it is in one of the tech note) specifies that there can be no
  14248. Apple Event embedded in another Apple Event.
  14249.  
  14250. Then the question is why the AETF specifies this. I guess it is
  14251. partly not to make it too complicated, and partly because an
  14252. embedded Apple Event can be misleading. Let say you create Apple
  14253. Event A and B in a machine X with some valid session id as the target
  14254. address, you embed B into A and send it off to another machine.
  14255. When it arrives at the other machine Y, the adress of Apple Event
  14256. A will be valid on arrival. However, if you pull out the Apple
  14257. Event B from Apple Event A, you get an Apple Event with an
  14258. session ID from machine X which is invalid in machine Y.
  14259.  
  14260. -- 
  14261. /* Disclaimer: All statments and opinions expressed are my own */
  14262. /* Edmund K. Lai                                               */
  14263. /* Apple Computer, MS303-3A                                    */
  14264. /* 20525 Mariani Ave,                                          */
  14265. /* Cupertino, CA 95014                                         */
  14266. /* (408)974-6272                                               */
  14267. zW@h9cOi
  14268.  
  14269. ---------------------------
  14270.  
  14271. >From dresden@albert.ma.utexas.edu (Greg Dresden)
  14272. Subject: Why use handles at all, though?
  14273. Date: 1 Mar 1994 16:43:35 -0600
  14274. Organization: University Of Texas Mathematics
  14275.  
  14276. Concerning the current debate about handles:
  14277.  
  14278. I've been reading with great interest these articles about when to lock 'em,
  14279. when to unlock 'em, and when to walk away. 
  14280.  
  14281. >From what I can pick up, it seems as if these handles are simply 
  14282. pointers to pointers. (Alas, I must have been asleep when we discussed these
  14283. in class.)
  14284.  
  14285. If this is so, why would anyone want to: (a) use handles when you could
  14286. just use pointers, and (b) use a "with" statement when you could just
  14287. type out the pointer's full name (thus saving yourself much grief.)
  14288.  
  14289. Now, I am a still-wet-behind-the-ears newbie, but I can't really
  14290. see the value of handles as a programming tool.
  14291.  
  14292. Are there any enlightened gurus out there who would like to rush to the
  14293. defense of these much-maligned objects?
  14294.  
  14295. - --------------------------------------------------
  14296. dresden@albert.ma.utexas.edu
  14297.  
  14298. +++++++++++++++++++++++++++
  14299.  
  14300. >From mssmith@afterlife.ncsc.mil (M. Scott Smith)
  14301. Date: Wed, 2 Mar 1994 13:10:43 GMT
  14302. Organization: The Great Beyond
  14303.  
  14304. In article <2l0gen$k3e@albert.ma.utexas.edu> dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  14305. >Concerning the current debate about handles:
  14306. >
  14307. >I've been reading with great interest these articles about when to lock 'em,
  14308. >when to unlock 'em, and when to walk away. 
  14309. >
  14310. >From what I can pick up, it seems as if these handles are simply 
  14311. >pointers to pointers. (Alas, I must have been asleep when we discussed these
  14312. >in class.)
  14313. >
  14314. >If this is so, why would anyone want to: (a) use handles when you could
  14315. >just use pointers [...]
  14316.  
  14317. I'll try to tackle this one..
  14318.  
  14319.    Memory management on the Macintosh is different than most other
  14320. computers.  When the Mac first came out, it didn't have much memory
  14321. available for applications' use.  And Mac programs -- being graphical,
  14322. etc., tended to take up more memory than their text counterparts (even
  14323. though a lot of the Toolbox calls were in ROM.)
  14324.  
  14325.    Because of this, it was necessary to create a very efficient memory
  14326. model.
  14327.  
  14328.    Let's first look at the traditional way of allocating memory with
  14329. pointers.
  14330.  
  14331.    When you first run a program, a chunk of memory is set aside.  Then,
  14332. whenever you call NewPtr, you're taking away from that chunk.
  14333.  
  14334.    Say the memory partition is 200 kilobytes.  You go along and allocate
  14335. 100k with a pointer.  Now memory looks like this:
  14336.  
  14337. - --
  14338. |XX|  100k (allocated)
  14339. |XX|
  14340. |--|
  14341. |  |  100k (available)
  14342. |  |
  14343. - --
  14344.  
  14345.    Now you allocate 30k.  After that, you deallocate the 100k.  Now
  14346. memory looks like this:
  14347.  
  14348. - --
  14349. |  |  100k (available)
  14350. |  |
  14351. |XX|  30k (allocated)
  14352. |  |
  14353. |  |  70k (available)
  14354. - --
  14355.  
  14356.    Now say you need to allocate 110k.
  14357.  
  14358.    You can't.  You can allocate up to 100k, but no more, even though you've
  14359. technically got 170k available.
  14360.  
  14361.    Why?  Because you've fragmented the heap, as they say.  I've really
  14362. simplified things here; you can imagine just how fragmented the heap can
  14363. get before too long, especially if it's not all that large to begin with
  14364. (the ideal).
  14365.  
  14366.    Wouldn't it be great if the computer was smart enough to, say, move
  14367. that 30k down to the bottom of the heap so you could allocate the whole
  14368. 170k?
  14369.  
  14370.    Enter handles.  As if pointers weren't confusing enough, now you've
  14371. got pointers to pointers (to pointers to pointers to..)  Say we wanted
  14372. to solve our problem using pointers; we wanted to make the computer
  14373. intelligent enough to rearrange memory.  The problem is, we've got a
  14374. local variable which is a pointer to a memory address that locates your
  14375. allocation on the heap.  If the memory manager moved your allocation
  14376. on the heap, your pointer would still be pointing at the old address --
  14377. which is most likely NOT what you want.  (Unless you're one of those
  14378. "grunge" programmers.)
  14379.  
  14380.    With handles, you still maintain a pointer, but it points to a pointer
  14381. which is maintained by the memory manager, and not you.  That way, the
  14382. memory manager is free to do anything it wants with memory -- so long
  14383. as it updates that pointer it's maintaining to reflect the new location
  14384. of your memory.
  14385.  
  14386.    So long as you use YOUR pointer, you will be safe; it will always be
  14387. pointing to a pointer which points to the correct address of your memory,
  14388. even if that address changes.
  14389.  
  14390.    Other issues come up, though.  Dereferencing a pointer twice is a lot
  14391. slower than dereferencing a pointer once, so you'll probably want to
  14392. dereference that handle to get to the pointer that points straight to
  14393. the data, when you want to access that data.
  14394.  
  14395.    This can be dangerous, because the memory manager can change it at
  14396. any time (and your dereference won't reflect that change!)  When can the
  14397. memory manager move things around in the heap?  Just about anytime it
  14398. feels like it.  Many (most?) of the Toolbox functions can trigger memory
  14399. manager activity.  If you do dereference a handle, you should be careful
  14400. that memory isn't going to move; if you're uncertain, you can "lock"
  14401. the handle down, which guarantees the memory manager won't move it.
  14402. (You should unlock it when you're done so it can move it.  After all,
  14403. that's the whole point.)
  14404.  
  14405.    Does that help clear things up a bit?
  14406.  
  14407. Scott
  14408.  
  14409. - -
  14410. M. Scott Smith
  14411.  
  14412.    Macintosh developer, student, ski bum.  Eater of Cadbury's Creme Eggs.
  14413.  
  14414.  
  14415. +++++++++++++++++++++++++++
  14416.  
  14417. >From gurgle@netcom.com (Pete Gontier)
  14418. Date: Wed, 2 Mar 1994 19:51:32 GMT
  14419. Organization: cellular
  14420.  
  14421. dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  14422.  
  14423. >I've been reading with great interest these articles about when to
  14424. >lock 'em, when to unlock 'em, and when to walk away. From what I can
  14425. >pick up, it seems as if these handles are simply pointers to pointers.
  14426. >(Alas, I must have been asleep when we discussed these in class.) If
  14427. >this is so, why would anyone want to: (a) use handles when you could
  14428. >just use pointers...
  14429.  
  14430. What's misleading about many articles which discuss the pitfalls of
  14431. handle-based memory management is that they focus on the pitfalls, not
  14432. surprisingly. In fact, there is so much discussion of the pitfalls that
  14433. it must seem like handles are just a bogus design waiting to cause bugs
  14434. in otherwise innocent programs. However, handles have real positive
  14435. effects when used in low-memory siuations, because they can be moved and
  14436. recombined and shuffled in general within a heap to make the maximum
  14437. possible blocks size available to whoever needs it.
  14438.  
  14439. > ...and (b) use a "with" statement when you could just type out the
  14440. >pointer's full name (thus saving yourself much grief.)
  14441.  
  14442. Most people use WITH statements just for convenience. In some cases,
  14443. that convenience can be non-trivial. Suppose you have several nested
  14444. records. You know that a certain piece of code wants to access the
  14445. fields of one of the most deeply nested records. Suppose further that
  14446. you would like to be able to reorganize the containment structure of
  14447. this deeply nested record if and when necessary. The WITH statement,
  14448. used properly, would theoretically allow you to change less code,
  14449. thereby reducing the chance of introducing a typographical error which
  14450. coincidentally compiles without error.
  14451.  
  14452. In most cases, though, I think you're right: WITH is just expedient.
  14453.  
  14454. >Are there any enlightened gurus out there who would like to rush to the
  14455. >defense of these much-maligned objects?
  14456.  
  14457. IMO (and there are plenty who disagree with me), the era of handles is
  14458. largely over. People used to allocate handles whenever they needed a
  14459. hunk of memory out of the heap. This was necessary because the Mac had
  14460. very little memory. Now that customers expect applications to be huge,
  14461. I think you can get away with allocating pointers a lot of the time.
  14462. Large chunks of memory should probably still be in pointers. Also, don't
  14463. conclude that I think applications can be and should be huge these days.
  14464. That's obviously an unsupportable position. I am merely pointing out
  14465. that since many apps are huge, there's a little more weight on the side
  14466. of the scale for safety and robustness (pointers) than there used to be.
  14467. Also, don't use NewPtr or malloc. But that's another story altogether.
  14468. -- 
  14469.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  14470.  
  14471. +++++++++++++++++++++++++++
  14472.  
  14473. >From u9119523@sys.uea.ac.uk (Graham Cox)
  14474. Date: Thu, 3 Mar 1994 15:43:15 GMT
  14475. Organization: School of Information Systems, UEA, Norwich
  14476.  
  14477. In article <gurgleCM1z5y.4J1@netcom.com>, gurgle@netcom.com (Pete Gontier)
  14478. wrote:
  14479.  
  14480. > dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  14481. [SNIP!]
  14482.  
  14483. Just to add my two-penn'orth...
  14484.  
  14485. Once you understand WHY handles exist and HOW to use them, you hardly ever
  14486. use pointers again, and your ability as a programmer of truly stable, solid
  14487. Mac programs takes a massive leap forward. That was my experience anyway
  14488. (was it really 1986...?)
  14489.  
  14490. - ------------------------------------------------------------------------
  14491. Love & BSWK, Graham
  14492.  
  14493. -Everyone is entitled to their opinion, no matter how wrong they may be...
  14494. - ------------------------------------------------------------------------
  14495.  
  14496. +++++++++++++++++++++++++++
  14497.  
  14498. >From gurgle@netcom.com (Pete Gontier)
  14499. Date: Thu, 3 Mar 1994 20:52:39 GMT
  14500. Organization: cellular
  14501.  
  14502. gurgle@netcom.com (Pete Gontier) writes:
  14503.  
  14504. >Large chunks of memory should probably still be in pointers.
  14505.  
  14506. Yow! Here I was trying to be responsible and I let a zinger like THIS go
  14507. by. It should have read:
  14508.  
  14509. >Large chunks of memory should probably still be in handles.
  14510. -- 
  14511.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  14512.  
  14513. +++++++++++++++++++++++++++
  14514.  
  14515. >From rang@winternet.mpls.mn.us (Anton Rang)
  14516. Date: 04 Mar 1994 00:35:07 GMT
  14517. Organization: Minnesota Angsters
  14518.  
  14519. In article <gurgleCM1z5y.4J1@netcom.com> gurgle@netcom.com (Pete Gontier) writes:
  14520. >However, handles have real positive
  14521. >effects when used in low-memory siuations, because they can be moved and
  14522. >recombined and shuffled in general within a heap to make the maximum
  14523. >possible blocks size available to whoever needs it.
  14524.  
  14525.   Not just in low-memory situations, either; any time that you need to
  14526. have a memory block whose size varies dynamically, a handle is *very*
  14527. useful....
  14528. --
  14529. Anton Rang (rang@acm.org)
  14530.  
  14531. +++++++++++++++++++++++++++
  14532.  
  14533. >From Brad Koehn <koehn@macc.wisc.edu>
  14534. Date: 4 Mar 1994 01:30:22 GMT
  14535. Organization: University of Wisconsin
  14536.  
  14537. In article <gurgleCM1z5y.4J1@netcom.com> Pete Gontier, gurgle@netcom.com
  14538. writes:
  14539. >IMO (and there are plenty who disagree with me), the era of handles is
  14540. >largely over. 
  14541.  
  14542. I guess I'm one of those people.
  14543.  
  14544. >People used to allocate handles whenever they needed a
  14545. >hunk of memory out of the heap. This was necessary because the Mac had
  14546. >very little memory. 
  14547.  
  14548. That's still true. You can never have enough memory, and one pointer can
  14549. cut the RAM you have in half, no matter how much you have.
  14550.  
  14551. I'm kind of a purist, I love the Mac memory model (well, not all of it,
  14552. but within a heap anyway) and thinks it's just great. I can make great
  14553. programs that require hardly any memory to run, and they have all kinds
  14554. of cool memory management w/o requiring an MMU.
  14555.  
  14556. As long as I assume that my handles are going to move all the time,
  14557. everything's kosher. Wait, that's not true. My handles don't move all the
  14558. time, they only do during most trap calls. I don't bother to check which
  14559. ones (unless I'm in speed critical code), I just lock and unlock as
  14560. necessary. As it turns out, it's usually not all that necessary. And on
  14561. top of that, I get a nice clean heap.
  14562.  
  14563. I do wish that HLock and HUnlock weren't traps though, it bothers me that
  14564. my precious clock cycles are being stolen by the trap dispatcher (esp.
  14565. with TCL...).
  14566. _________________________________________________________________________
  14567. Brad Koehn          Data Transformations, Inc.        koehn@macc.wisc.edu
  14568.  
  14569. +++++++++++++++++++++++++++
  14570.  
  14571. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  14572. Date: 4 Mar 94 17:02:44 +1300
  14573. Organization: University of Waikato, Hamilton, New Zealand
  14574.  
  14575. In article <2l0gen$k3e@albert.ma.utexas.edu>, dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  14576. > Concerning the current debate about handles:
  14577. >
  14578. > I've been reading with great interest these articles about when to lock 'em,
  14579. > when to unlock 'em, and when to walk away.
  14580. >
  14581. > From what I can pick up, it seems as if these handles are simply
  14582. > pointers to pointers. (Alas, I must have been asleep when we discussed these
  14583. > in class.)
  14584.  
  14585. Ar, that be right.
  14586.  
  14587. > If this is so, why would anyone want to: (a) use handles when you could
  14588. > just use pointers,...
  14589.  
  14590. The thing about handles is that the memory blocks can move about in memory.
  14591. This has two consequences:
  14592.  
  14593. 1) Fragmentation is less likely when memory is running low, and
  14594. 2) You can resize the blocks.
  14595.  
  14596. Reason 1 is less important when you have megabytes to play with. However, 2
  14597. is still a very useful property: it's handy for creating all kinds of
  14598. dynamically-sized structures--arrays and the like.
  14599.  
  14600. > and (b) use a "with" statement when you could just
  14601. > type out the pointer's full name (thus saving yourself much grief.)
  14602.  
  14603. Beats me, too...
  14604.  
  14605. > Now, I am a still-wet-behind-the-ears newbie, but I can't really
  14606. > see the value of handles as a programming tool.
  14607.  
  14608. I trust I have managed to disabuse you of that notion.
  14609.  
  14610. Lawrence
  14611. a member of the society for linking things to other things.
  14612.  
  14613. +++++++++++++++++++++++++++
  14614.  
  14615. >From D.A.G.Gillies@bradford.ac.uk (DAG GILLIES)
  14616. Date: Fri, 4 Mar 1994 12:40:41 GMT
  14617. Organization: University of Bradford, UK
  14618.  
  14619. In article <gurgleCM1z5y.4J1@netcom.com> gurgle@netcom.com (Pete Gontier) writes:
  14620. >dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  14621. >
  14622. >>Are there any enlightened gurus out there who would like to rush to the
  14623. >>defense of these much-maligned objects?
  14624. >
  14625. >IMO (and there are plenty who disagree with me), the era of handles is
  14626. >largely over. People used to allocate handles whenever they needed a
  14627. >hunk of memory out of the heap. This was necessary because the Mac had
  14628. >very little memory. Now that customers expect applications to be huge,
  14629. >I think you can get away with allocating pointers a lot of the time.
  14630. >Large chunks of memory should probably still be in pointers. Also, don't
  14631. >conclude that I think applications can be and should be huge these days.
  14632. >That's obviously an unsupportable position. I am merely pointing out
  14633. >that since many apps are huge, there's a little more weight on the side
  14634. >of the scale for safety and robustness (pointers) than there used to be.
  14635. >Also, don't use NewPtr or malloc. But that's another story altogether.
  14636. >-- 
  14637.  
  14638.  
  14639. I like handles from an aesthetic point of view - they seem to me to be
  14640. a nice way of handling dynamic memory. I have a general rule of thumb for
  14641. when to use handles and when to use pointers, and it relies mainly on the
  14642. scope and lifetime of the entity for which storage is being allocated. In
  14643. general, if I am allocating an object at global scope, I will use a handle, 
  14644. to allow that object to waft around the heap and maximise available memory.
  14645. Typically, where it is being used in a function, I will lock it down (and
  14646. high) with HLockHi for the duration of that function and than free it up
  14647. again at the end. This allows me to dereference it once at the beginning of
  14648. the function for speed. However, if I am allocating an object that only
  14649. exists at local scope, and which will be destroyed when the enclosing
  14650. function returns, I will use a pointer, unless the object is needed by a
  14651. lot of functions called by the enclosing function, in which case I may well
  14652. use a Handle (and possibly lock it down as before).
  14653.  
  14654. If I am messing with resource creation (like building Finder aliases), I
  14655. will use Handles, simply because resources are Handles themselves, and
  14656. in general speed is not critical in such cases.
  14657.  
  14658. ______________________________________________________
  14659. David A. G. Gillies     (D.A.G.Gillies@bradford.ac.uk)
  14660. (c) 1994 Wittgenstein's Amazing Underwater Supermarket
  14661.  
  14662. - -------------REPLIES VIA EMAIL PLEASE---------------
  14663. _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  14664.  
  14665. +++++++++++++++++++++++++++
  14666.  
  14667. >From partingt@fwi.uva.nl (Vincent Partington)
  14668. Date: 4 Mar 1994 16:08:49 GMT
  14669. Organization: FWI, University of Amsterdam
  14670.  
  14671. gurgle@netcom.com (Pete Gontier) writes:
  14672.  
  14673. >>Large chunks of memory should probably still be in pointers.
  14674. >Yow! Here I was trying to be responsible and I let a zinger like THIS go
  14675. >by. It should have read:
  14676. >>Large chunks of memory should probably still be in handles.
  14677.  
  14678. It doesn't really matter if you put large or small objects in handles.
  14679. Small objects break up the heap just as good as big objects. So if you go
  14680. with handles, go with them all the way.
  14681.  
  14682. Vincent.
  14683.  
  14684. BTW, Why isn't there a TempNewPtr call? To prevent us from cluttering the
  14685. temporary heap?
  14686. -- 
  14687. VI is better than Emacs.      | Let's     | Internet : partingt@fwi.uva.nl
  14688. MacOS is better than Windows. | start the |            vincent@tnc.nl
  14689. Unix is better than VMS.      | religious | FidoNet  : 2:281/202.15
  14690. Eiffel is better than C++.    | war!!     | NeST     : 90:500/202.15
  14691.  
  14692. +++++++++++++++++++++++++++
  14693.  
  14694. >From gurgle@netcom.com (Pete Gontier)
  14695. Date: Fri, 4 Mar 1994 20:09:41 GMT
  14696. Organization: cellular
  14697.  
  14698. rang@winternet.mpls.mn.us (Anton Rang) writes:
  14699.  
  14700. >In article <gurgleCM1z5y.4J1@netcom.com> gurgle@netcom.com (Pete Gontier) writes:
  14701. >>However, handles have real positive
  14702. >>effects when used in low-memory siuations, because they can be moved and
  14703. >>recombined and shuffled in general within a heap to make the maximum
  14704. >>possible blocks size available to whoever needs it.
  14705.  
  14706. >Not just in low-memory situations, either; any time that you need to
  14707. >have a memory block whose size varies dynamically, a handle is *very*
  14708. >useful....
  14709.  
  14710. That depends on how you define "useful", of course.
  14711.  
  14712. If you are, for example, talking about adding a couple of bytes to
  14713. a handle which takes up more than half the heap, which would be
  14714. impossible without handles, I would call that part of the low-memory
  14715. considerations.
  14716.  
  14717. The other aspects of it are about convenience and performance, not space
  14718. savings. And it's true that these also are reasons to advocate handles.
  14719. But if you can't do something at all, it doesn't matter how convenient
  14720. or fast it would have been. :-)
  14721. -- 
  14722.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  14723.  
  14724. +++++++++++++++++++++++++++
  14725.  
  14726. >From gurgle@netcom.com (Pete Gontier)
  14727. Date: Fri, 4 Mar 1994 20:18:09 GMT
  14728. Organization: cellular
  14729.  
  14730. Brad Koehn <koehn@macc.wisc.edu> writes:
  14731.  
  14732. > ...one pointer can cut the RAM you have in half, no matter how much
  14733. > you have.
  14734.  
  14735. Sure, that's true. But I'd say it's easier for the most part to keep
  14736. this in mind and avoid it rather than use handles all the time. I'm not
  14737. suggesting people allocate pointers for long-term global-state storage.
  14738. If, well into a program's lifetime, it decides it's going to allocate
  14739. a text buffer and leave it hanging around indefinitely, that buffer
  14740. shouldn't go into a pointer. For all it knows, a properly written
  14741. function has been called deep in a call hierarchy, and several bazillion
  14742. pointers may already have been allocated on the heap. Allocating another
  14743. and leaving it around could easily frag the heap and reduce the amount
  14744. of memory available to any one block.
  14745.  
  14746. >My handles don't move all the time, they only do during most trap
  14747. >calls. I don't bother to check which ones (unless I'm in speed critical
  14748. >code), I just lock and unlock as necessary.
  14749.  
  14750. I usually assume StripAddress and BlockMove are not going to move
  14751. memory, but that's about it. :-)
  14752.  
  14753. BTW, also remember to be paranoid about inter-segment calls.
  14754. -- 
  14755.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  14756.  
  14757. +++++++++++++++++++++++++++
  14758.  
  14759. >From mxmora@unix.sri.com (Matt Mora)
  14760. Date: 4 Mar 1994 09:27:52 -0800
  14761. Organization: SRI International, Menlo Park, CA
  14762.  
  14763. In article <2l62ve$97p@news.doit.wisc.edu> Brad Koehn <koehn@macc.wisc.edu> writes:
  14764. >In article <gurgleCM1z5y.4J1@netcom.com> Pete Gontier, gurgle@netcom.com
  14765. >writes:
  14766. >>IMO (and there are plenty who disagree with me), the era of handles is
  14767. >>largely over. 
  14768. >
  14769. >I guess I'm one of those people.
  14770.  
  14771. Me too. (if your talking about wanting to keep Handles) I think Handles
  14772. are cool but always wished they did more. Why couldn't handles, when being
  14773. moved to make room, jump over locked blocks? Handles can become pretty useless
  14774. if there are a few locked blocks in memory. I think handles should have been
  14775. more automagic. The memeory manager should take care of the details for me.
  14776.  
  14777. For example. Why couldn't we call one function to tell the memory
  14778. manager that we are about to use the data thats in the handle. ie:
  14779.  
  14780. HUsingHandle(h);
  14781. <do what ever I want with the handle because its is now in a safe state>
  14782. HNotUsingHandle(h);
  14783.  
  14784. After marking the handle as not in use, the system is now free to do anything
  14785. it wants with the handle. That includes paging it to disk, moving it around, 
  14786. jumping over locked memory islands, or even compressing it.
  14787.  
  14788. Certain functions would call these functions internally like DrawPicture.
  14789. So you know that when you call drawpicture the system would do anything
  14790. that it needs to bring the handle to a safe state and then use the data.
  14791.  
  14792. With the PowerPC machines, things like this are possible.
  14793.  
  14794. Xavier
  14795.  
  14796.  
  14797. -- 
  14798. ___________________________________________________________
  14799. Matthew Xavier Mora                    Matt_Mora@qm.sri.com
  14800. SRI International                       mxmora@unix.sri.com
  14801. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  14802.  
  14803. +++++++++++++++++++++++++++
  14804.  
  14805. >From j-norstad@nwu.edu (John Norstad)
  14806. Date: Fri, 04 Mar 1994 18:41:08 -0600
  14807. Organization: Northwestern University
  14808.  
  14809. In article <2l0gen$k3e@albert.ma.utexas.edu>, dresden@albert.ma.utexas.edu
  14810. (Greg Dresden) wrote:
  14811.  
  14812. > Are there any enlightened gurus out there who would like to rush to the
  14813. > defense of these much-maligned objects?
  14814.  
  14815. Yes, I will.
  14816.  
  14817. Relocatable memory blocks are incredibly useful for storying varying
  14818. amounts of data when you don't know in advance how much memory you are
  14819. going to need, and when the memory needs grow and shrink during the
  14820. lifetime of the block.
  14821.  
  14822. The Mac memory manager can easily make a relocatable block larger by
  14823. moving it or by moving other relocatable blocks out of the way. This is
  14824. not possible in fixed block systems.
  14825.  
  14826. This is incredibly useful. All of my Mac programs make extensive use of
  14827. this feature of the Mac memory manager, and would be very significantly
  14828. more difficult to write on a system without relocatable blocks.
  14829.  
  14830. For example, in my NewsWatcher program, I use this in dozens of places.
  14831. It's an extraordinarily useful technique. I have grow so accustomed to
  14832. having it that I find it difficult to live without it when I have to deal
  14833. with programming on other systems. Programing without relocatable and
  14834. growable blocks is like returning to the pre-Mac stone ages for me.
  14835.  
  14836. SetHandleSize(h, GetHandleSize(h) + n) is one of my favorite lines of C on
  14837. the Mac, and is one of the many reasons I find programming the Mac to be
  14838. much more fun and pleasant than programming other kinds of computers.
  14839.  
  14840. Yes, you do have to be very careful about dangling pointers. It's the
  14841. price paid for the flexibility.
  14842.  
  14843. I have also used a system (Control Data's NOS/VE) where each process could
  14844. use a very large number of very large separate virtual address spaces. On
  14845. those systems, you put varying size objects in their own address space.
  14846.  
  14847. -- 
  14848. John Norstad
  14849. Academic Computing and Network Services
  14850. Northwestern University
  14851. j-norstad@nwu.edu
  14852.  
  14853. +++++++++++++++++++++++++++
  14854.  
  14855. >From ari@world.std.com (Ari I Halberstadt)
  14856. Date: Sat, 5 Mar 1994 11:18:56 GMT
  14857. Organization: The World Public Access UNIX, Brookline, MA
  14858.  
  14859. In article <2l7r2o$t2f@unix.sri.com>, Matt Mora <mxmora@unix.sri.com> wrote:
  14860. >Me too. (if your talking about wanting to keep Handles) I think Handles
  14861. >are cool but always wished they did more. Why couldn't handles, when being
  14862.  
  14863. If we're on the subject of wish lists...
  14864.  
  14865. How about a language with a decent garbage collection coroutine? Since
  14866. the garbage collector would track all memory references, we could let
  14867. the garbage collector automagically compact the heap for us. Handles
  14868. would be obsolete and most memory errors would be obsolete (e.g.,
  14869. using disposed memory, forgetting to dispose of memory, even address
  14870. and bus errors would be very rare with such a language). To top it all
  14871. off, our programs would be a heck of a lot simpler and easier to write
  14872. and maintain. I wouldn't worry too much about speed. Algorithms are
  14873. always getting better, and we can always just throw another CPU at the
  14874. problem (i.e., parallelize the garbage collection).
  14875. -- 
  14876. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  14877. "These beetles were long considered to be very rare because very few
  14878. entomologists look for beetles in the mountains, in winter, at night,
  14879. during snow storms." -- Purves W. K., et al, "Life: The Science of
  14880.  
  14881. +++++++++++++++++++++++++++
  14882.  
  14883. >From gurgle@netcom.com (Pete Gontier)
  14884. Date: Sat, 5 Mar 1994 22:28:41 GMT
  14885. Organization: cellular
  14886.  
  14887. partingt@fwi.uva.nl (Vincent Partington) writes:
  14888.  
  14889. >gurgle@netcom.com (Pete Gontier) writes:
  14890.  
  14891. >>>Large chunks of memory should probably still be in pointers.
  14892. >>Yow! Here I was trying to be responsible and I let a zinger like THIS go
  14893. >>by. It should have read:
  14894. >>>Large chunks of memory should probably still be in handles.
  14895.  
  14896. >It doesn't really matter if you put large or small objects in handles.
  14897. >Small objects break up the heap just as good as big objects. So if you go
  14898. >with handles, go with them all the way.
  14899.  
  14900. I don't think this is valid. If you know what you are doing, it does
  14901. in fact make sense to put small objects in pointers and large objects
  14902. in handles in many contexts. Size is not the only consideration, as I
  14903. posted elsewhere; however, large objects should probably go in handles
  14904. regardless of other considerations; I believe that would have been more
  14905. evident if I had quoted more of the original message.
  14906. -- 
  14907.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  14908.  
  14909. +++++++++++++++++++++++++++
  14910.  
  14911. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  14912. Date: 7 Mar 94 14:57:51 +1300
  14913. Organization: University of Waikato, Hamilton, New Zealand
  14914.  
  14915. In article <u9119523-030394154315@case6.sys.uea.ac.uk>, u9119523@sys.uea.ac.uk (Graham Cox) writes:
  14916. >
  14917. > Once you understand WHY handles exist and HOW to use them, you hardly ever
  14918. > use pointers again, and your ability as a programmer of truly stable, solid
  14919. > Mac programs takes a massive leap forward. That was my experience anyway
  14920. > (was it really 1986...?)
  14921.  
  14922. My Mac experience dates from about the same time (I started getting seriously
  14923. into Mac programming about 86/87), and I would say "No way!".
  14924.  
  14925. I wrote some code which created a sorted tree structure once. Initially each
  14926. block was relocatable. Every now and then, the program would print garbage for
  14927. the contents of a tree node. Obviously a block was moving unexpectedly from
  14928. under me.
  14929.  
  14930. Rather than try to track down the exact place where I was forgetting to lock
  14931. the block, I changed all the relocatable blocks for the tree nodes to
  14932. nonrelocatable ones. This is how a conventional tree or linked list structure
  14933. is built in the textbooks, anyway. The program worked fine after that.
  14934.  
  14935. Moral: use nonrelocatable blocks for large numbers of identically-sized blocks.
  14936. I don't think that creating large numbers of handles is a good idea (unless
  14937. you manage the master pointers quite carefully). If you're doing a lot of
  14938. allocating and deallocating of blocks of a particular size, you could create
  14939. a lookaside list to speed things up. I tend to use handles where the system
  14940. encourages (or forces) me to, and where I need resizable structures.
  14941.  
  14942. And, yes, I do make frequent use of resizable structures.
  14943.  
  14944. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  14945. Info & Tech Services Division              fax: +64-7-838-4066
  14946. University of Waikato            electric mail: ldo@waikato.ac.nz
  14947. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  14948.  
  14949. +++++++++++++++++++++++++++
  14950.  
  14951. >From bcollett@hamilton.edu (Brian Collett)
  14952. Date: 8 Mar 1994 17:13:07 GMT
  14953. Organization: Hamilton College
  14954.  
  14955. In article <1994Mar7.145751.26071@waikato.ac.nz>, ldo@waikato.ac.nz
  14956. (Lawrence D'Oliveiro, Waikato University) wrote:
  14957. > Moral: use nonrelocatable blocks for large numbers of identically-sized blocks.
  14958. > I don't think that creating large numbers of handles is a good idea (unless
  14959. > you manage the master pointers quite carefully). If you're doing a lot of
  14960. > allocating and deallocating of blocks of a particular size, you could create
  14961. > a lookaside list to speed things up. I tend to use handles where the system
  14962. > encourages (or forces) me to, and where I need resizable structures.
  14963.  
  14964. If you are manipulating large numbers of identical blocks then it is highly
  14965. advantageous to pre-allocate a large chunk of them and then manage them
  14966. yourself (I use a simple linked list of free blocks). Identical size blocks
  14967. have no fragmentation problems and you can write a MUCH faster memory
  14968. manager for them. I have cut the memory manager overhead in a program that
  14969. manipulates many dynamic blocks from  >50% of the total execution time to
  14970. <10% by this trick.
  14971.  
  14972. Brian Collett, Physics Dept., Hamilton College, Clinton, NY 13323
  14973.  
  14974. +++++++++++++++++++++++++++
  14975.  
  14976. >From Brad Miller  <miller@cs.rochester.edu>
  14977. Date: Tue, 8 Mar 1994 17:16:27 -0500
  14978. Organization: University of Rochester Computer Science Dept
  14979.  
  14980. >>>>> "Ari" == Ari I Halberstadt <ari@world.std.com> writes:
  14981.  
  14982.     Ari> In article <2l7r2o$t2f@unix.sri.com>, Matt Mora <mxmora@unix.sri.com> wrote:
  14983.     >> Me too. (if your talking about wanting to keep Handles) I think Handles are cool but always wished they did
  14984.     >> more. Why couldn't handles, when being
  14985.  
  14986.     Ari> If we're on the subject of wish lists...
  14987.  
  14988.     Ari> How about a language with a decent garbage collection coroutine? Since the garbage collector would track all
  14989.     Ari> memory references, we could let the garbage collector automagically compact the heap for us. Handles would be
  14990.     Ari> obsolete and most memory errors would be obsolete (e.g., using disposed memory, forgetting to dispose of
  14991.     Ari> memory, even address and bus errors would be very rare with such a language). To top it all off, our programs
  14992.     Ari> would be a heck of a lot simpler and easier to write and maintain. I wouldn't worry too much about
  14993.     Ari> speed. Algorithms are always getting better, and we can always just throw another CPU at the problem (i.e.,
  14994.     Ari> parallelize the garbage collection).  -- Ari Halberstadt ari@world.std.com #include <std/disclaimer.h> "These
  14995.     Ari> beetles were long considered to be very rare because very few entomologists look for beetles in the mountains,
  14996.     Ari> in winter, at night, during snow storms." -- Purves W. K., et al, "Life: The Science of
  14997.  
  14998. It already exists, it's called "Lisp". The apple implementation, "Macintosh
  14999. Common Lisp" is quite good too.
  15000.  
  15001. Handles shouldn't be needed with any "real" VM. Arguably, the same is true for garbage, if you have a big enough heap.
  15002.  
  15003.  
  15004. +++++++++++++++++++++++++++
  15005.  
  15006. >From tblanch@lookout.ecte.uswc.uswest.com (Todd Blanchard)
  15007. Date: Mon, 7 Mar 1994 23:44:48 GMT
  15008. Organization: US WEST Information Technologies
  15009.  
  15010. Graham Cox (u9119523@sys.uea.ac.uk) wrote:
  15011. : In article <gurgleCM1z5y.4J1@netcom.com>, gurgle@netcom.com (Pete Gontier)
  15012. : wrote:
  15013.  
  15014. : > dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  15015. : > 
  15016. : [SNIP!]
  15017.  
  15018. : Just to add my two-penn'orth...
  15019.  
  15020. : Once you understand WHY handles exist and HOW to use them, you hardly ever
  15021. : use pointers again, and your ability as a programmer of truly stable, solid
  15022. : Mac programs takes a massive leap forward. That was my experience anyway
  15023. : (was it really 1986...?)
  15024.  
  15025. Perhaps, but I'm rather used to doing things like:
  15026.  
  15027.     myObject = new Object();
  15028.     myObject->Message();
  15029.     delete myObject;
  15030.  
  15031. This is the very stuff of C++ and I really like it.  Handles are OK for
  15032. buffers and such but they don't make C++ very nice to implement.  A good
  15033. VM system sort of negates the value of the things.
  15034.  
  15035. JMO
  15036. Todd Blanchard
  15037.  
  15038.  
  15039. +++++++++++++++++++++++++++
  15040.  
  15041. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  15042. Date: Fri, 11 Mar 94 11:23:45 PST
  15043. Organization: Peirce Software, Inc.
  15044.  
  15045.  
  15046. In article <j-norstad-040394184108@aragorn12.acns.nwu.edu> (comp.sys.mac.programmer), j-norstad@nwu.edu (John Norstad) writes:
  15047. > In article <2l0gen$k3e@albert.ma.utexas.edu>, dresden@albert.ma.utexas.edu
  15048. > (Greg Dresden) wrote:
  15049. > > Are there any enlightened gurus out there who would like to rush to the
  15050. > > defense of these much-maligned objects?
  15051. > Yes, I will.
  15052. > Relocatable memory blocks are incredibly useful for storying varying
  15053. > amounts of data when you don't know in advance how much memory you are
  15054. > going to need, and when the memory needs grow and shrink during the
  15055. > lifetime of the block.
  15056. > The Mac memory manager can easily make a relocatable block larger by
  15057. > moving it or by moving other relocatable blocks out of the way. This is
  15058. > not possible in fixed block systems.
  15059. > This is incredibly useful. All of my Mac programs make extensive use of
  15060. > this feature of the Mac memory manager, and would be very significantly
  15061. > more difficult to write on a system without relocatable blocks.
  15062.  
  15063. I agree with John.  Handles are really useful mainly because they
  15064. are resizable.  You simply can't do this with simple pointers.
  15065.  
  15066. I don't really understand why some people want to banish handles and
  15067. regress to a pointer only memory model.  Yuck.
  15068.  
  15069.  
  15070. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  15071. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  15072. --                       -- San Jose, California USA 95117
  15073. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  15074. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  15075.  
  15076. +++++++++++++++++++++++++++
  15077.  
  15078. >From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  15079. Date: 11 Mar 1994 23:13:44 GMT
  15080. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  15081.  
  15082. In article <CNjbKKKX.qc1a0h@outpost.SF-Bay.org> peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  15083. >
  15084. > In article <j-norstad-040394184108@aragorn12.acns.nwu.edu> (comp.sys.mac.programmer), j-norstad@nwu.edu (John Norstad) writes:
  15085. > > 
  15086. > > Relocatable memory blocks are incredibly useful for storying varying
  15087. > > amounts of data when you don't know in advance how much memory you are
  15088. > > going to need, and when the memory needs grow and shrink during the
  15089. > > lifetime of the block.
  15090. > > 
  15091. > > The Mac memory manager can easily make a relocatable block larger by
  15092. > > moving it or by moving other relocatable blocks out of the way. This is
  15093. > > not possible in fixed block systems.
  15094. >
  15095. > I agree with John.  Handles are really useful mainly because they
  15096. > are resizable.  You simply can't do this with simple pointers.
  15097.  
  15098. while i agree that handles are useful.  pointers _can_ be resizable.
  15099.  
  15100. for example, the following routine:
  15101.  
  15102. int ReallocPtr(Ptr *p,Size newSize)  {
  15103.    Ptr new_p;
  15104.  
  15105.    // try to resize the pointer
  15106.    SetPtrSize(p,newSize);
  15107.    if(MemError() == noErr)
  15108.       return(0);
  15109.  
  15110.    // couldn't simply resize, re-allocate the ptr
  15111.    new_p = NewPtrClear(newSize);
  15112.    if(MemError() != noErr)
  15113.       return(1);
  15114.  
  15115.    // copy the data from the old area to the new area
  15116.    BlockMove(*p,new_p,GetPtrSize(*p));
  15117.  
  15118.    // trash the old ptr
  15119.    DisposePtr(*p);
  15120.  
  15121.    *p = new_p;
  15122.    return(0);
  15123.    }
  15124.  
  15125. this does basically the same thing that ResizeHandle() does with handles
  15126. or that realloc() does for pointers in ANSI C.
  15127.  
  15128. anyway, handles are more convenient than using the above code, but
  15129. i just wanted to show that Ptr's _can_ be resized.
  15130.  
  15131.  
  15132. -gary j kacmarcik
  15133. platypus@curie.ces.cwru.edu
  15134.  
  15135. +++++++++++++++++++++++++++
  15136.  
  15137. >From u9119523@sys.uea.ac.uk (Graham Cox)
  15138. Date: Fri, 11 Mar 1994 12:37:54 GMT
  15139. Organization: School of Information Systems, UEA, Norwich
  15140.  
  15141. In article <CMBJAo.H8t@da_vinci.it.uswc.uswest.com>,
  15142. tblanch@lookout.ecte.uswc.uswest.com (Todd Blanchard) wrote:
  15143.  
  15144. > Graham Cox (u9119523@sys.uea.ac.uk) wrote:
  15145. > : In article <gurgleCM1z5y.4J1@netcom.com>, gurgle@netcom.com (Pete Gontier)
  15146. > : wrote:
  15147. > : > dresden@albert.ma.utexas.edu (Greg Dresden) writes:
  15148. > : > 
  15149. > : [SNIP!]
  15150. > : Just to add my two-penn'orth...
  15151. > : Once you understand WHY handles exist and HOW to use them, you hardly ever
  15152. > : use pointers again, and your ability as a programmer of truly stable, solid
  15153. > : Mac programs takes a massive leap forward. That was my experience anyway
  15154. > : (was it really 1986...?)
  15155. > Perhaps, but I'm rather used to doing things like:
  15156. >     myObject = new Object();
  15157. >     myObject->Message();
  15158. >     delete myObject;
  15159.  
  15160. Yeah, me too!
  15161.  
  15162. > This is the very stuff of C++ and I really like it.  Handles are OK for
  15163. > buffers and such but they don't make C++ very nice to implement.  A good
  15164. > VM system sort of negates the value of the things.
  15165. > JMO
  15166. > Todd Blanchard
  15167.  
  15168. I don't see why. A handle is a mechanism for implemeinting efficient memory
  15169. usage. In the original (non C++) implementation of the THINK class library
  15170. objects WERE handles. Did the programmer care? No- the indirection was
  15171. hidden from the programmer. Upshot- easy to write syntax PLUS efficient
  15172. memory management. In C++ I believe that objects are pointers. What
  15173. difference does it make to the programmer?- none. The syntax is identical.
  15174. The code is portable. However the fragmentation problem is still there, and
  15175. presumably C++ apps either suffer as a result or have their own memory
  15176. management code.
  15177.  
  15178. Personally, though I'm very much sold on OOP, I still like and appreciate
  15179. handles, and would prefer that C++ implemented object as handles.
  15180.  
  15181. - ------------------------------------------------------------------------
  15182. Love & BSWK, Graham
  15183.  
  15184. -Everyone is entitled to their opinion, no matter how wrong they may be...
  15185. - ------------------------------------------------------------------------
  15186.  
  15187. +++++++++++++++++++++++++++
  15188.  
  15189. >From rang@winternet.mpls.mn.us (Anton Rang)
  15190. Date: 12 Mar 1994 04:48:12 GMT
  15191. Organization: Minnesota Angsters
  15192.  
  15193. In article <PLATYPUS.94Mar11181344@cirrus.som.cwru.edu> platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  15194. >while i agree that handles are useful.  pointers _can_ be resizable.
  15195. > [ ... example of re-allocating pointers, pass in ptr, pass out ptr ... ]
  15196.  
  15197.   The problem with re-allocating a pointer using such a routine is
  15198. that it doesn't update any *other* pointers to the same memory block.
  15199. So if you have a data structure whose size needs to change, you need
  15200. to track every pointer to it.  At that point, you're just re-inventing
  15201. handles.
  15202. --
  15203. Anton Rang (rang@winternet.mpls.mn.us)
  15204.  
  15205. +++++++++++++++++++++++++++
  15206.  
  15207. >From gurgle@netcom.com (Pete Gontier)
  15208. Date: Sat, 12 Mar 1994 06:03:23 GMT
  15209. Organization: cellular
  15210.  
  15211. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  15212.  
  15213. >while i agree that handles are useful.  pointers _can_ be resizable.
  15214.  
  15215. >for example, the following routine:
  15216.  
  15217. >int ReallocPtr(Ptr *p,Size newSize)  {
  15218. >   ...
  15219. >   return(0);
  15220. >   }
  15221.  
  15222. If this is an actual routine you are using, allow me to make a
  15223. suggestion. Since it always returns 0, you might care to change it so it
  15224. returns the resized pointer.
  15225.  
  15226.     void * ReallocPtr (void *p, Size newSize);
  15227.  
  15228. I am using something like this and it works dandy. What returning the
  15229. resized pointer buys you is less nasty casting to get the parameter right.
  15230. With the original version, you might have to do something like this:
  15231.  
  15232.     void foo (int *bar)
  15233.     {
  15234.         int x = ReallocPtr ((Ptr *) &bar, sizeof (*bar));
  15235.     }
  15236.  
  15237. I know I would get this cast wrong more often than I care to admit.
  15238. With the newer declaration, you could write the same function like this:
  15239.  
  15240.     void foo (int *bar)
  15241.     {
  15242.         bar = ReallocPtr (bar,sizeof (*bar));
  15243.     }
  15244. -- 
  15245.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  15246.  
  15247. +++++++++++++++++++++++++++
  15248.  
  15249. >From john_werner@taligent.com (John Werner)
  15250. Date: Sat, 12 Mar 1994 07:18:31 GMT
  15251. Organization: Taligent, Inc.
  15252.  
  15253. In article <u9119523-110394123755@graphics9.sys.uea.ac.uk>,
  15254. u9119523@sys.uea.ac.uk (Graham Cox) wrote:
  15255.  
  15256. > In the original (non C++) implementation of the THINK class library
  15257. > objects WERE handles.
  15258.  
  15259. They still are, unfortunately.
  15260.  
  15261. > Did the programmer care?
  15262.  
  15263. Yes.  You have to be very careful to lock TCL objects if you're going to
  15264. pass around pointers to any of their fields.  References make this even
  15265. worse, since it's not clear from looking at a piece of code whether
  15266. references are involved.
  15267.  
  15268. Code as innocuous looking as this:
  15269.  
  15270.   class foo : public TObject {
  15271.     Complex a, b;
  15272.     Complex bar();
  15273.   };
  15274.   
  15275.   Complex foo::bar() { return a + b; }
  15276.  
  15277. can screw you up if operator+ uses references and foo::bar is in an
  15278. unloaded segment.
  15279.  
  15280. It could be argued that this is a compiler bug.  The C++ standard (such as
  15281. it is) says that references and pointers are supposed to refer or point to
  15282. the original object for as long as it exists.  In this case they don't. 
  15283.   
  15284. > Upshot- easy to write syntax PLUS efficient memory management.
  15285.  
  15286. It's quite possible to write an efficient pointer-based memory manager. 
  15287. Heaps may take up a bit more space, but they're a lot faster, since you can
  15288. don't have to move blocks around all the time.  With decent virtual memory,
  15289. large resizable blocks like editing buffers aren't a big issue, because you
  15290. can use memory-mapped files (ala Unix's mmap) for them.
  15291.  
  15292. -- 
  15293. John Werner                          john_werner@taligent.com
  15294. Taligent, Inc.
  15295.  
  15296. +++++++++++++++++++++++++++
  15297.  
  15298. >From sw@network-analysis-ltd.co.uk (Sak Wathanasin)
  15299. Date: Sat, 12 Mar 94 09:25:50 GMT
  15300. Organization: Network Analysis Ltd
  15301.  
  15302.  
  15303. In article <RANG.94Mar11224814@icicle.winternet.mpls.mn.us> (comp.sys.mac.programmer), rang@winternet.mpls.mn.us (Anton Rang) writes:
  15304. > In article <PLATYPUS.94Mar11181344@cirrus.som.cwru.edu> platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  15305. > >while i agree that handles are useful.  pointers _can_ be resizable.
  15306. > > [ ... example of re-allocating pointers, pass in ptr, pass out ptr ... ]
  15307. >   The problem with re-allocating a pointer using such a routine is
  15308. > that it doesn't update any *other* pointers to the same memory block.
  15309. > So if you have a data structure whose size needs to change, you need
  15310. > to track every pointer to it.  At that point, you're just re-inventing
  15311. > handles.
  15312. > --
  15313. > Anton Rang (rang@winternet.mpls.mn.us)
  15314.  
  15315. And, of course, it's considered an "advanced C++ idiom"* these days to
  15316. use ptrs to objects that may not actually be there. Variously known as
  15317. smart pointers, envelopes &c (yes, I know they are not exactly the
  15318. same), they can used to implement persistent objects, smart memory
  15319. allocation and deallocation, bounds checking on access and so on. Mac
  15320. OS handles are a special case of these.
  15321.  
  15322. Anyone remember Iliffe's "Basic machine"? (That's "basic" as in
  15323. "fundamental", not "BASIC" as in "programming language".) Mostly a
  15324. paper design, but some of the ideas were implemented in the Burroughs
  15325. Algol engines. And capability-based systems? The "descriptor
  15326. registers" in ICL 2900/MU5 architectures? (Oh dear! showing my age :-)
  15327.  
  15328. The more things change,...
  15329.  
  15330.  
  15331. * Coplien: Advanced C++ Programing Styles and Idioms
  15332.   Alger: "C++ for gurus" in latest issue of Frameworks
  15333.  
  15334.  
  15335. Sak Wathanasin
  15336. Network Analysis Limited
  15337. 178 Wainbody Ave South, Coventry CV3 6BX, UK
  15338.  
  15339. Internet: sw@network-analysis-ltd.co.uk 
  15340. uucp:     ...!uknet!nan!sw                       AppleLink: NAN.LTD
  15341. Phone: (+44) 203 419996 Mobile:(+44) 850 587411  Fax: (+44) 203 690690
  15342.  
  15343. +++++++++++++++++++++++++++
  15344.  
  15345. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  15346. Date: Sat, 12 Mar 94 09:31:56 PST
  15347. Organization: Peirce Software, Inc.
  15348.  
  15349. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  15350.  
  15351. >while i agree that handles are useful.  pointers _can_ be resizable.
  15352.  
  15353. >for example, the following routine:
  15354.  
  15355. >int ReallocPtr(Ptr *p,Size newSize)  {
  15356. >   ...
  15357. >   return(0);
  15358. >   }
  15359.  
  15360. Two problems:
  15361.  
  15362. (1) This works OK if you have basically unlimited memory
  15363. available to you.  If you don't, you can easily run into a
  15364. situation where you have a memory block of size N and free memory
  15365. of size N and you want to increase the size of your memory
  15366. block.   In this case you can't allocate a new block until you
  15367. deallocate your old block which you can't do.  With Handles, you
  15368. can move stuff around so that you can simply extend the size of
  15369. your memory block.
  15370.  
  15371. (2) I haven't seen a good way to get the size of the memory
  15372. block pointed at by a pointer.  Using GetHandleSize() on the
  15373. Mac is quite useful.
  15374.  
  15375. Handles aren't nirvana, but I personally don't want to give them up.
  15376.  
  15377.  
  15378. -- Michael Peirce        -- peirce@outpost.sf-bay.org
  15379. -- Peirce Software, Inc. -- 719 Hibiscus Place, Suite 301
  15380. --                       -- San Jose, California USA 95117
  15381. -- Makers of: Smoothie & -- voice: +1.408.244.6554 fax: +1.408.244.6882
  15382. --    Peirce Print Tools -- AppleLink: peirce & America Online: AFC Peirce
  15383.  
  15384. +++++++++++++++++++++++++++
  15385.  
  15386. >From resnick@cogsci.uiuc.edu (Pete Resnick)
  15387. Date: Sat, 12 Mar 1994 14:18:53 -0600
  15388. Organization: University of Illinois at Urbana-Champaign
  15389.  
  15390. In article <CNjbKKKX.qef4bx@outpost.SF-Bay.org>, peirce@outpost.SF-Bay.org
  15391. (Michael Peirce) wrote:
  15392.  
  15393. >(2) I haven't seen a good way to get the size of the memory
  15394. >block pointed at by a pointer.  Using GetHandleSize() on the
  15395. >Mac is quite useful.
  15396.  
  15397. Uh, GetPtrSize? (IM II-37, top of the page)
  15398.  
  15399. pr
  15400. -- 
  15401. Pete Resnick        (...so what is a mojo, and why would one be rising?)
  15402. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  15403. System manager - Cognitive Science Group, Beckman Institute, UIUC
  15404. Internet: resnick@cogsci.uiuc.edu
  15405.  
  15406. +++++++++++++++++++++++++++
  15407.  
  15408. >From gurgle@netcom.com (Pete Gontier)
  15409. Date: Sat, 12 Mar 1994 22:52:04 GMT
  15410. Organization: cellular
  15411.  
  15412. u9119523@sys.uea.ac.uk (Graham Cox) writes:
  15413.  
  15414. >In the original (non C++) implementation of the THINK class library
  15415. >objects WERE handles. Did the programmer care? No- the indirection was
  15416. >hidden from the programmer. Upshot- easy to write syntax PLUS efficient
  15417. >memory management. In C++ I believe that objects are pointers. What
  15418. >difference does it make to the programmer?- none. The syntax is
  15419. >identical. The code is portable. However the fragmentation problem is
  15420. >still there, and presumably C++ apps either suffer as a result or have
  15421. >their own memory management code.
  15422.  
  15423. Try multiple inheritance with a handle-based object. Pass the address
  15424. of an object member field to a trap which moves memory. The portability
  15425. between the two schemes is *not* transparent.
  15426.  
  15427. >Personally, though I'm very much sold on OOP, I still like and
  15428. >appreciate handles, and would prefer that C++ implemented object as
  15429. >handles.
  15430.  
  15431. Me too. It must be difficult, though, as at least three compilers have
  15432. failed to support it.
  15433. -- 
  15434.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  15435.  
  15436. +++++++++++++++++++++++++++
  15437.  
  15438. >From gurgle@netcom.com (Pete Gontier)
  15439. Date: Sat, 12 Mar 1994 22:53:23 GMT
  15440. Organization: cellular
  15441.  
  15442. peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  15443.  
  15444. >(2) I haven't seen a good way to get the size of the memory block
  15445. >pointed at by a pointer. Using GetHandleSize() on the Mac is quite
  15446. >useful.
  15447.  
  15448. GetPtrSize works. Writing your own glue to store the size works.
  15449. -- 
  15450.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  15451.  
  15452. +++++++++++++++++++++++++++
  15453.  
  15454. >From hammett@sbsu1.auckland.ac.nz (Tim Hammett)
  15455. Date: 13 Mar 1994 20:15:22 GMT
  15456. Organization: University of Auckland
  15457.  
  15458. peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  15459. >(1) This works OK if you have basically unlimited memory
  15460. >available to you.  If you don't, you can easily run into a
  15461. >situation where you have a memory block of size N and free memory
  15462. >of size N and you want to increase the size of your memory
  15463. >block.   In this case you can't allocate a new block until you
  15464. >deallocate your old block which you can't do.  With Handles, you
  15465. >can move stuff around so that you can simply extend the size of
  15466. >your memory block.
  15467.  
  15468. I'm not sure I follow you here. His routine tries a SetPtrSize() first,
  15469. which will attempt to increase the size of the pointed-to block without
  15470. moving it (possibly by moving relocatable stuff after the block). He only
  15471. copies if SetPtrSize() can't do its stuff. This is exactly the same as
  15472. what would happen if you were trying to resize a handle (except
  15473. SetHandleSize() will move your block if it can't resize in situ).
  15474.  
  15475. The only objection I can see is that by using pointers exclusively,
  15476. there isn't likely to be much the memory manager can do to move things
  15477. out of the way to resize a block in place (because almost eveything
  15478. else in the heap will be non-movable). Also Anton's point about invalid
  15479. pointers was a good one.
  15480.  
  15481. >(2) I haven't seen a good way to get the size of the memory
  15482. >block pointed at by a pointer.  Using GetHandleSize() on the
  15483. >Mac is quite useful.
  15484.  
  15485. There's actually a GetPtrSize() routine. (It makes sense that there should
  15486. be one, since the memory manager needs to keep info about the size of
  15487. blocks, even if they're non-relocatable, so that it can walk the heap).
  15488. (As for stuff allocated using malloc(), that's another story).
  15489. --
  15490. Tim Hammett, School of Biological Sciences, Auckland University, New Zealand.
  15491. t.hammett@auckland.ac.nz   Phone: +64-9-373-7599 x8365    FAX: +64-9-373-7416
  15492.  
  15493. +++++++++++++++++++++++++++
  15494.  
  15495. >From sew@design.canberra.edu.au (Simon Ward)
  15496. Date: Mon, 14 Mar 94 03:58:51 GMT
  15497. Organization: University of Canberra
  15498.  
  15499.  
  15500. In article <j-norstad-040394184108@aragorn12.acns.nwu.edu> John Norstad, 
  15501. j-norstad@nwu.edu writes:
  15502. >SetHandleSize(h, GetHandleSize(h) + n) is one of my favorite lines of C on
  15503. >the Mac, and is one of the many reasons I find programming the Mac to be
  15504. >much more fun and pleasant than programming other kinds of computers.
  15505.  
  15506. I agree, it's a very flexible way of dealing with a user's data 
  15507. structures that are of an indeterminate size. Pointers can't offer the 
  15508. same flexiblity.
  15509.  
  15510.  
  15511. Simon Ward
  15512. sew@design.canberra.edu.au
  15513.  
  15514.  
  15515.  
  15516.  
  15517. +++++++++++++++++++++++++++
  15518.  
  15519. >From ivanski@world.std.com (Ivan M CaveroBelaunde)
  15520. Date: Mon, 14 Mar 1994 15:40:35 GMT
  15521. Organization: The World Public Access UNIX, Brookline, MA
  15522.  
  15523. peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  15524. >platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  15525. >>for example, the following routine:
  15526. >>int ReallocPtr(Ptr *p,Size newSize)  {
  15527. >>   ...
  15528. >>   return(0);
  15529. >>   }
  15530.  
  15531. >Two problems:
  15532. > ( ... deleted ...)
  15533. Additionally, this also presents the same problem that the concept
  15534. of master pointers in handles were intended to solve - namely,
  15535. that the block of memory could be moved but the number the program
  15536. used to identify that (the handle) need not change. If I hand off
  15537. the above pointer to some other block of my program and then call
  15538. ReallocPtr, the other block is left holding a reference to a stale
  15539. pointer, something that does not happen with handles.
  15540.  
  15541. -Ivan
  15542. - -
  15543. Ivan Cavero Belaunde (ivanski@world.std.com)
  15544. Avid VideoShop Project Lead
  15545. Avid Technology, Inc.
  15546.  
  15547. +++++++++++++++++++++++++++
  15548.  
  15549. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  15550. Date: 14 Mar 94 17:37:10 +1300
  15551. Organization: University of Waikato, Hamilton, New Zealand
  15552.  
  15553. In article <199403082216.RAA07098@wolverine.cs.rochester.edu>, Brad Miller  <miller@cs.rochester.edu> writes:
  15554. >
  15555. > Handles shouldn't be needed with any "real" VM.
  15556. >
  15557.  
  15558. Gee, and after all the comments from people pointing out how useful handles
  15559. are for creating resizable objects. How does virtual memory help deal with
  15560. this?
  15561.  
  15562. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  15563. Info & Tech Services Division              fax: +64-7-838-4066
  15564. University of Waikato            electric mail: ldo@waikato.ac.nz
  15565. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  15566.  
  15567. +++++++++++++++++++++++++++
  15568.  
  15569. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  15570. Date: 14 Mar 94 17:59:05 +1300
  15571. Organization: University of Waikato, Hamilton, New Zealand
  15572.  
  15573. In article <PLATYPUS.94Mar11181344@cirrus.som.cwru.edu>,
  15574. platypus@cirrus.som.cwru.edu (Gary Kacmarcik) reminds everyone about
  15575. SetPtrSize.
  15576.  
  15577. Sure, this call exists. But how often is it likely to succeed? I can't imagine
  15578. the Memory Manager deliberately goes about leaving gaps between successively-
  15579. allocated blocks. Thus, it seems to me it's going to fail on the vast majority
  15580. of calls.
  15581.  
  15582. Your sample code did check for this situation, and if the pointer resize failed,
  15583. it allocated a new block and deallocated the old one. Now, what happens if
  15584. you have several bits of code wanting access to the data? Answer: you must
  15585. maintain a single master pointer to the block. What if the clients don't know
  15586. where the master pointer is? Answer: you give them a pointer to the master
  15587. pointer. Congratulations! You've just reinvented handles, only you're not going
  15588. to do it as efficiently as the Memory Manager can.
  15589.  
  15590. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  15591. Info & Tech Services Division              fax: +64-7-838-4066
  15592. University of Waikato            electric mail: ldo@waikato.ac.nz
  15593. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  15594.  
  15595. +++++++++++++++++++++++++++
  15596.  
  15597. >From rabeet@aol.com (Rabeet)
  15598. Date: 14 Mar 1994 23:48:03 -0500
  15599. Organization: America Online, Inc. (1-800-827-6364)
  15600.  
  15601. Here's a simple solution to the argument: sit down, learn how to deal with
  15602. handles and what they are really good for. End of argument.
  15603.  
  15604. I have long since given up on handles for C++ objects (love mix-ins and
  15605. embedded objects), which aren't of variable size anyway, but anyone doing
  15606. serious Mac development uses them for a large portion of everything else.
  15607.  
  15608. Edward Harp
  15609. Rocket Science Games, Inc.
  15610. Disclaimer: my opinions aren't rocket science
  15611.  
  15612. +++++++++++++++++++++++++++
  15613.  
  15614. >From nagle@netcom.com (John Nagle)
  15615. Date: Tue, 15 Mar 1994 17:45:08 GMT
  15616. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  15617.  
  15618. ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  15619. >In article <199403082216.RAA07098@wolverine.cs.rochester.edu>, Brad Miller  <miller@cs.rochester.edu> writes:
  15620. >>
  15621. >> Handles shouldn't be needed with any "real" VM.
  15622. >>
  15623.  
  15624.       Handles would be more useful if they were properly supported in
  15625. compilers.  Many Mac compilers dereference handles without locking
  15626. them, which is dumb.  This started with Pascal, where "with" statements
  15627. dereference handles, and you're supposed to know that you have to lock
  15628. them before doing a "with" statement, unless you're sure the clauses of
  15629. the "with" statement can't move memory.  It got worse in C++, where
  15630. there's the possibility that someone may subclass a function previously
  15631. "safe" with regard to moving memory and make it unsafe.  There's also
  15632. a serious problem with handle objects that contain non-handle objects
  15633. with constructors; SC++ will call a constructor for a subobject with
  15634. the main object dereferenced and unlocked.  If the compiler does a
  15635. dereference on its own, the compiler should lock, unless the compiler
  15636. can optimize out the lock because the intervening code is safe.
  15637.  
  15638.       The other big mistake is that Apple publishes a list of system calls
  15639. that can move memory, and changes it periodically.  They should have 
  15640. published a short list of system calls that they guarantee DON'T move memory,
  15641. and never removed any.
  15642.  
  15643.                     John Nagle
  15644.  
  15645.  
  15646. ---------------------------
  15647.  
  15648. >From rwparker@netcom.com (Richard W. Parker)
  15649. Subject: Writing To Screen Memory
  15650. Date: Mon, 28 Feb 1994 23:25:20 GMT
  15651. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  15652.  
  15653. Does anyone know of a "generally-accepted" method for writing directly to
  15654. screen memory?  I am looking for a method that will work across most of the
  15655. 32-bitQD Macintoshes.
  15656.  
  15657. Also - what are the pros and cons in doing so?  Is CopyBits fast enough not
  15658. to worry about it?
  15659. -- 
  15660.                                              rwparker@netcom.com
  15661.  
  15662. +++++++++++++++++++++++++++
  15663.  
  15664. >From mssmith@afterlife.ncsc.mil (M. Scott Smith)
  15665. Date: Tue, 1 Mar 1994 00:55:36 GMT
  15666. Organization: The Great Beyond
  15667.  
  15668. In article <rwparkerCLyJqB.6nD@netcom.com> rwparker@netcom.com (Richard W. Parker) writes:
  15669. >Does anyone know of a "generally-accepted" method for writing directly to
  15670. >screen memory?  I am looking for a method that will work across most of the
  15671. >32-bitQD Macintoshes.
  15672. >
  15673. >Also - what are the pros and cons in doing so?  Is CopyBits fast enough not
  15674. >to worry about it?
  15675.  
  15676. Whew boy..
  15677.  
  15678.    There is a "generally-accepted" method of writing directly to screen
  15679. memory.  There was a pretty good article on this issue in a past issue of
  15680. Develop.  (I forget which one..  Hopefully someone remembers; you can
  15681. download Develop from ftp.apple.com.)
  15682.  
  15683.    As I recall, there's a few things to keep in mind.  First, you need to
  15684. make as few assumptions as possible about the video hardware.  If your
  15685. monitor is 640x480 and your video card can only drive it at 8-bits, you
  15686. can't assume that there's 640 bytes of RAM per scan line, for example.
  15687. There might be a WHOLE kilobyte -- or more -- or less -- who knows?
  15688. So you poll the video hardware to find the rowBytes, and use that as
  15689. a basis for calculations.
  15690.  
  15691.    Also, it seems you need to make sure you're in 32-bit mode for everything
  15692. to work properly.  There's a hack way to "jump" to 32-bit mode right
  15693. before you do any drawing and then jump back, if required.  (That's pretty
  15694. dangerous, so you make sure you do it when the Mac's not looking..)
  15695.  
  15696.    And there's some magic with ShieldCursor() calls (which I forget off
  15697. the top of my head) which "ensure" compatibility with certain third
  15698. party devices, notably the Radius Pivot monitor.
  15699.  
  15700.    Without telling us what your needs are, it's difficult to assess whether
  15701. or not CopyBits is quick enough for your application, but the safe answer
  15702. is "yes, it is."  CopyBits is unbelievably versatile and fast.  In
  15703. fact, many of the QuickDraw routines are -- such as LineTo.  The trick
  15704. to unleashing the full power (in terms of speed) in QuickDraw is pretty
  15705. well documented, I believe it was the subject of an Apple technote.
  15706. (I..  forget which one.  Aren't I helpful today?)  You do things like
  15707. make sure source and destination rectangles are equal (so VERY expensive
  15708. scaling won't occur) and are divisible by 4, etc.  Some people have
  15709. written replacements for CopyBits which are quicker (but less versatile).
  15710.  
  15711.    What are the advantages and disadvantages of messing around with the
  15712. video RAM?
  15713.  
  15714. Disadvantages:
  15715.  
  15716.  - Many programmers will frown upon you and say "Tsk, tsk."
  15717.  - You may not need to for speed, anyway.
  15718.  - You're playing with a loaded gun in terms of ensuring compatibility with
  15719.    future Macs.
  15720.  - You've got to take it upon yourself to deal with all kinds of yechy
  15721.    "possibilities" that QuickDraw normally handles for you (such as.. the
  15722.    Radius Pivot.)
  15723.  - You give up the Mac interface, unless you're really tricky.  For example,
  15724.    you won't be drawing in a window, so the user can't move your drawing
  15725.    across the screen...  or from one monitor to another..  And System 7
  15726.    doesn't know about your drawing so it's perfectly happy to throw stuff
  15727.    right on top of it.
  15728.  - Did I mention all those yechy possibilities?  What if the depth of
  15729.    the monitor somehow gets changed in the middle of your program?  Youch.
  15730.  - It's very low-level and a headache.  You'll be rebooting quite
  15731.    frequently as you try to figure it out.  In Quickdraw, if you write
  15732.    outside the boundary of a window, it's nicely clipped for you.  Nothing
  15733.    bad happens.  If you're writing to video RAM and you go off the screen,
  15734.    well, the best you can hope for is an exciting crash instead of a
  15735.    silent freeze.
  15736.  
  15737. Advantages:
  15738.  
  15739.  - Many other programmers will congratulate you for ignoring the wimps
  15740.    who say "tsk, tsk."
  15741.  - If you know what you're doing, you can see some serious speed in certain
  15742.    circumstances.
  15743.  - Hey, a lot of people do it.  Lots of games.  Lots of commercial programs.
  15744.    Heck, even System 7 does it!
  15745.  - Enough people have done it to come up with a list of "rules" to follow;
  15746.    it's not black magic as it once used to be.  (Again, find that Develop
  15747.    article.)
  15748.  - It will give you an opportunity to really understand what's going on
  15749.    with the video in your Mac.  And I get a pleasure out of refining my
  15750.    code to make it quicker and quicker.  It's fun to develop methods for
  15751.    masking, etc.  You gain speed by writing routines specific to your
  15752.    needs.  While CopyBits will do just about anything, you might find
  15753.    youself writing 10 different versions for different situations.
  15754.  - It will work with the PowerPC, so you're safe for now.
  15755.  - All that rebooting will let you see that friendly smiling Mac more times
  15756.    a day.
  15757.  
  15758.    I suppose I might get around to posting a simple class I wrote in C++
  15759. that let's you attack direct-screen drawing in a slightly less intimidating
  15760. manner, on alt.sources.mac.  But I must admit right now I'm not doing
  15761. the 32-bit or ShieldCursor tricks.  Heck, I don't need to.  Works fine
  15762. on my Mac right now..  So I'd need to clean it up a bit first.
  15763.  
  15764. Good luck!
  15765.  
  15766. Scott
  15767.  
  15768. - -
  15769. M. Scott Smith      (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
  15770.  
  15771.    Macintosh developer, student, ski bum.  Eater of Cinnamon Toast Crunch.
  15772.  
  15773.      "Last stop for fuel on the information superhighway."
  15774.  
  15775.  
  15776. +++++++++++++++++++++++++++
  15777.  
  15778. >From jwbaxter@olympus.net (John W. Baxter)
  15779. Date: Mon, 28 Feb 1994 22:15:19 -0800
  15780. Organization: Internet for the Olympic Peninsula
  15781.  
  15782. In article <rwparkerCLyJqB.6nD@netcom.com>, rwparker@netcom.com (Richard W.
  15783. Parker) wrote:
  15784.  
  15785. > Does anyone know of a "generally-accepted" method for writing directly to
  15786. > screen memory?  I am looking for a method that will work across most of the
  15787. > 32-bitQD Macintoshes.
  15788. > Also - what are the pros and cons in doing so?  Is CopyBits fast enough not
  15789. > to worry about it?
  15790.  
  15791. I don't think this is the time to be exploring direct writing to screen
  15792. memory.  Too much is happening "real soon now":  (1) powerPC, and (2) more
  15793. important here, QuickDraw GX.
  15794.  
  15795. The time spent mastering direct writing can probably be better spent
  15796. learning QD GX (even though the latter won't be in every Mac for a while).
  15797.  
  15798. -- 
  15799. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  15800.    jwbaxter@pt.olympus.net
  15801.  
  15802. +++++++++++++++++++++++++++
  15803.  
  15804. >From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  15805. Date: 1 Mar 1994 19:20:51 GMT
  15806. Organization: Royal Institute of Technology, Stockholm, Sweden
  15807.  
  15808. >> Does anyone know of a "generally-accepted" method for writing directly to
  15809. >> screen memory?  I am looking for a method that will work across most of the
  15810. >> 32-bitQD Macintoshes.
  15811.  
  15812. >I don't think this is the time to be exploring direct writing to screen
  15813. >memory.  Too much is happening "real soon now":  (1) powerPC, and (2) more
  15814. >important here, QuickDraw GX.
  15815.  
  15816. None of these will impact direct-to-screen-drawing in the near
  15817. future. If you mean the PowerPC will be fast enough to not need
  15818. direct-to-screen (and the same for QDGX) then consider the
  15819. large installed base of Performas which will NOT be PowerPC
  15820. upgraded anytime soon, and QDGX will not be faster than QD for
  15821. bitmap-type things, just better :-)
  15822.  
  15823. >The time spent mastering direct writing can probably be better spent
  15824. >learning QD GX (even though the latter won't be in every Mac for a while).
  15825.  
  15826. Not if what he wants to do is write an arcade game.
  15827. -- 
  15828.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  15829.  "Don't use the Layer Manager"
  15830.  
  15831. +++++++++++++++++++++++++++
  15832.  
  15833. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  15834. Date: Fri, 4 Mar 1994 10:52:11 GMT
  15835. Organization: (none)
  15836.  
  15837. mssmith@afterlife.ncsc.mil (M. Scott Smith) writes:
  15838.  
  15839. >   What are the advantages and disadvantages of messing around with the
  15840. >video RAM?
  15841.  
  15842. >Disadvantages:
  15843.  
  15844. > - Many programmers will frown upon you and say "Tsk, tsk."
  15845. > - You may not need to for speed, anyway.
  15846.  
  15847. For games, we generally do.
  15848.  
  15849. > - You're playing with a loaded gun in terms of ensuring compatibility with
  15850. >   future Macs.
  15851. > - You've got to take it upon yourself to deal with all kinds of yechy
  15852. >   "possibilities" that QuickDraw normally handles for you (such as.. the
  15853. >   Radius Pivot.)
  15854.  
  15855. An option to use it or use QuickDraw instead isn't too bad. It's hard for
  15856. the program to tell if it will work, but at least the user can make it work
  15857. if he/she has hardware where it doesn't.
  15858.  
  15859. > - You give up the Mac interface, unless you're really tricky.  For example,
  15860. >   you won't be drawing in a window, so the user can't move your drawing
  15861. >   across the screen...  or from one monitor to another..  And System 7
  15862. >   doesn't know about your drawing so it's perfectly happy to throw stuff
  15863. >   right on top of it.
  15864.  
  15865. That means only a few drawbacks. Make the window non-moveable, and only use
  15866. the direct-to-screen routines when it's the front window.
  15867.  
  15868. > - Did I mention all those yechy possibilities?  What if the depth of
  15869. >   the monitor somehow gets changed in the middle of your program?  Youch.
  15870.  
  15871. Did anyone notice how SAT switches depth automatically? :-)
  15872.  
  15873. > - It's very low-level and a headache.
  15874.  
  15875. This is *true*. :-(
  15876.  
  15877. >Advantages:
  15878.  
  15879. (Deleted - but speed is what counts)
  15880.  
  15881. --
  15882. - -
  15883. Ingemar Ragnemalm, PhD
  15884. Image processing, Mac shareware games
  15885. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  15886.  
  15887. ---------------------------
  15888.  
  15889. >From Tony Andreoli <Tony_Andreoli_-_CTA@CL_63SMTP_GW.CHINALAKE.NAVY.MIL>
  15890. Subject: dirIDs
  15891. Date: Wed, 9 Mar 1994 15:23:21 GMT
  15892. Organization: Naval Air Warfare Center - Weapons Division
  15893.  
  15894. Here is my question...I am in the home folder of an application and I
  15895. know the name of a
  15896. folder in the same directory.  How can I obtain the dirID of the
  15897. directory so that I can do
  15898. a PBGetCatInfo on that directory.
  15899.  
  15900. thanx for the help...
  15901.  
  15902. +++++++++++++++++++++++++++
  15903.  
  15904. >From Steve Bryan <sbryan@maroon.tc.umn.edu>
  15905. Date: Mon, 14 Mar 1994 16:23:54 GMT
  15906. Organization: Sexton Software
  15907.  
  15908. In article <CMELEx.CG0@avalon.chinalake.navy.mil> Tony Andreoli,
  15909. Tony_Andreoli_-_CTA@CL_63SMTP_GW.CHINALAKE.NAVY.MIL writes:
  15910. >Here is my question...I am in the home folder of an application and I
  15911. >know the name of a
  15912. >folder in the same directory.  How can I obtain the dirID of the
  15913. >directory so that I can do
  15914. >a PBGetCatInfo on that directory.
  15915.  
  15916. When your program is starting up call CurResFile to identify the refNum
  15917. of the resource fork of your application. Call PBGetFCBInfo with ioRefNum
  15918. set to your resource fork refNum and ioFCBIndx set to zero. It will
  15919. return a bunch of info including the parID for the folder containing your
  15920. application. Note that there is at least one other method for obtaining
  15921. the refNum of your application which may be less likely to break which is
  15922. a call to GetAppParms. I mentioned the other way because that is what I
  15923. use.
  15924.  
  15925. ---------------------------
  15926.  
  15927. >From jaeger@kunikpok.icus.com (Jaeger)
  15928. Subject: jGNEFilter Q
  15929. Date: Fri, 11 Mar 94 10:56:26 CST
  15930. Organization: Kunikpok Kennels and Komputers (Pet Project)
  15931.  
  15932. HereUs a question for any jGNEFilter gurus out there:  Is there any time 
  15933. that it is safe for a jGNEFilter to uninstall itself?  For instance, if 
  15934. the value stored in the global jGNEFilter is equal to your own entry 
  15935. point is it safe to uninstall yourself.  Also, is it safe for an init to 
  15936. install a jGNEFilter at other than init time?  If you do that will it be 
  15937. removed by the finder when the app that was running when the filter was 
  15938. installed quits?  IUm assuming that the finder maintains the jGNEFilter 
  15939. global as part of the lo-mem world that is alterred when the context is 
  15940. switched.
  15941.   
  15942. Brian Stern  :-{)}
  15943. Jaeger@fquest.com
  15944.  
  15945.  
  15946. +++++++++++++++++++++++++++
  15947.  
  15948. >From gurgle@netcom.com (Pete Gontier)
  15949. Date: Fri, 11 Mar 1994 23:31:13 GMT
  15950. Organization: cellular
  15951.  
  15952. jaeger@kunikpok.icus.com (Jaeger) writes:
  15953.  
  15954. >HereUs a question for any jGNEFilter gurus out there:  Is there any time 
  15955. >that it is safe for a jGNEFilter to uninstall itself?  For instance, if 
  15956. >the value stored in the global jGNEFilter is equal to your own entry 
  15957. >point is it safe to uninstall yourself.
  15958.  
  15959. Maybe. Assuming no one is trying to trick you with a skanky hack.
  15960.  
  15961. >Also, is it safe for an init to install a jGNEFilter at other than init
  15962. >time?
  15963.  
  15964. >From what I hear on the net, it is even safe for an application to
  15965. install a jGNEFilter -- and it will apply to all apps. Of course, the
  15966. difficult part for an application is how to uninstall the filter when
  15967. quitting.
  15968.  
  15969. >If you do that will it be removed by the finder when the app that was
  15970. >running when the filter was installed quits?
  15971.  
  15972. No.
  15973.  
  15974. >IUm assuming that the finder maintains the jGNEFilter global as part of
  15975. >the lo-mem world that is alterred when the context is switched.
  15976.  
  15977. >From what I have heard on the net, this is not the case.
  15978. -- 
  15979.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  15980.  
  15981. +++++++++++++++++++++++++++
  15982.  
  15983. >From urge@mcl.ucsb.edu (Scott Bronson)
  15984. Date: 12 Mar 1994 00:53:47 GMT
  15985. Organization: University of California, Santa Barbara
  15986.  
  15987. In <Rw91ic1w165w@kunikpok.icus.com> jaeger@kunikpok.icus.com (Jaeger) writes:
  15988.  
  15989. >HereUs a question for any jGNEFilter gurus out there:  Is there any time 
  15990. >that it is safe for a jGNEFilter to uninstall itself?  For instance, if 
  15991. >the value stored in the global jGNEFilter is equal to your own entry 
  15992. >point is it safe to uninstall yourself.
  15993.  
  15994. Theoretically, once you've stored a value in JGNEFilter, you can never
  15995. go back.  While it's probably 99.9999% safe to deinstall your jGNE,
  15996. I personally would not (and did not).  Instead, I've installed a tiny,
  15997. locked code resource in the Sytem Heap that would communicate with a
  15998. Gestalt selector to indicate what it should do with the incoming events.
  15999. Using a jGNE/Gestalt tandem also means you only have to install once,
  16000. because you can use it from then on (it's immune to application launches,
  16001. quits, ...)
  16002.  
  16003. Please note: each installed jGNE slows down the machine's perceived
  16004. speed--it will take longer between the time the user clicks the mouse
  16005. and the button highlights.  The Mac is already slower than other machines
  16006. in this respect, so *please* do as little processing as possible at jGNE
  16007. time.
  16008.  
  16009. >Also, is it safe for an init to 
  16010. >install a jGNEFilter at other than init time? If you do that will it be 
  16011. >removed by the finder when the app that was running when the filter was 
  16012. >installed quits?  IUm assuming that the finder maintains the jGNEFilter 
  16013. >global as part of the lo-mem world that is alterred when the context is 
  16014. >switched.
  16015.  
  16016. Yes, it is safe to install a jGNE after INIT time.  Just make sure to
  16017. install your proc in the System Heap because it will never be uninstalled
  16018. (except perhaps by you, which is bad for reasons previously mentioned).
  16019. The jGNE will be called for EVERY event, not just events that belong to
  16020. the application that installed it.  This is a very effecitve way of
  16021. slurping events destined for other apps; I've used this technique before.
  16022.  
  16023. A low-level debugger and some patience are all that's required.  Have
  16024. fun with it.
  16025.  
  16026.     - Scott
  16027.  
  16028. +++++++++++++++++++++++++++
  16029.  
  16030. >From moofster@world.std.com (A Happy Dog-Cow)
  16031. Date: Sat, 12 Mar 1994 09:32:08 GMT
  16032. Organization: The Nest of the Moofster
  16033.  
  16034. In general, if TrapAddress(patchedTrap/Vector) == (yourHandler)
  16035. Then it's safe to de-install.  With very few exceptions, this is
  16036. the case for all traps & low-memory vectors.
  16037.  
  16038. I ditto earlier comments about keeping gneFilter processing to
  16039. an absolute minimum.
  16040.  
  16041. Robert M. Seretny, Armesti Research
  16042.  
  16043.  
  16044. +++++++++++++++++++++++++++
  16045.  
  16046. >From jlscott@tigr.org (John L. Scott)
  16047. Date: 15 Mar 1994 11:17:28 -0600
  16048. Organization: Self
  16049.  
  16050. In article <Rw91ic1w165w@kunikpok.icus.com>, jaeger@kunikpok.icus.com
  16051. (Jaeger) wrote:
  16052.  
  16053. > I'm assuming that the finder maintains the jGNEFilter 
  16054. > global as part of the lo-mem world that is alterred when the context is 
  16055. > switched.
  16056.  
  16057. Don't assume that.  jGNEFilter is _not_ altered when the context is
  16058. switched.
  16059.  
  16060. --John
  16061.  
  16062. ---------------------------
  16063.  
  16064. >From cverret@vnet3.vub.ac.be (Chris Verret)
  16065. Subject: password encryption
  16066. Date: Tue, 08 Mar 1994 15:54:07 +0100
  16067. Organization: Vrije Universiteit Brussel
  16068.  
  16069. I suppose most users would appreciate it when an application
  16070. encrypts passwords before they are placed in a preference file.
  16071.  
  16072. So does anyone perharps know where I can find a straightforward
  16073. snippet for encryption/decryption of passwords?
  16074.  
  16075.  
  16076.  
  16077. PS: recently some queries were posted concerning the bulleting of
  16078. password textitems. Its very simple to write a short filter for
  16079. this. If anyone is still needs this, I'm always prepared to mail
  16080. a short example.
  16081.  
  16082. -- 
  16083. __________________________________________________________________________
  16084. Chris Verret                                       cverret@vnet3.vub.ac.be
  16085.  
  16086. +++++++++++++++++++++++++++
  16087.  
  16088. >From zobkiw@datawatch.com (joe zobkiw)
  16089. Date: Wed, 9 Mar 1994 14:40:09 GMT
  16090. Organization: Datawatch Corporation
  16091.  
  16092. In article <cverret-080394155407@progmc39.vub.ac.be>,
  16093. cverret@vnet3.vub.ac.be (Chris Verret) wrote:
  16094.  
  16095. > I suppose most users would appreciate it when an application
  16096. > encrypts passwords before they are placed in a preference file.
  16097. > So does anyone perharps know where I can find a straightforward
  16098. > snippet for encryption/decryption of passwords?
  16099.  
  16100. This code is from NewsWatcher...it works nicely...
  16101.  
  16102. /*----------------------------------------------------------------------------
  16103.  
  16104.     ScramblePassword
  16105.     
  16106.     Scrambles (and unscrambles) saved passwords. This is not really secure,
  16107.     just something to foil people browsing using disk editors.
  16108.     
  16109.     Entry:    pw = the password.
  16110.             len = length of password.
  16111.             
  16112.     Exit:    Each byte nibble-swapped and bit-flipped.
  16113.     
  16114. - --------------------------------------------------------------------------*/
  16115.  
  16116. void ScramblePassword(unsigned char *password, short len)
  16117. {
  16118.     unsigned char *p, *pEnd;
  16119.     
  16120.     pEnd = password + len;
  16121.     for (p = password; p < pEnd; p++) 
  16122.         *p = (((*p >> 4) & 0x0f) | ((*p & 0x0f) << 4)) ^ 0xff;
  16123. }
  16124.  
  16125. ___________________________________________________________
  16126. _/_/_/_/   Joe Zobkiw                                   ,,,
  16127.     _/     Senior Software Engineer                     - -
  16128.   _/       Datawatch Corporation                         L
  16129. _/_/_/_/   zobkiw@datawatch.com                          -
  16130.  
  16131. +++++++++++++++++++++++++++
  16132.  
  16133. >From sholmes@netrix.com (Stephen R Holmes)
  16134. Date: Fri, 11 Mar 1994 17:03:32 GMT
  16135. Organization: Netrix Corporation
  16136.  
  16137. In article <cverret-080394155407@progmc39.vub.ac.be>,
  16138. cverret@vnet3.vub.ac.be (Chris Verret) wrote:
  16139.  
  16140. > I suppose most users would appreciate it when an application
  16141. > encrypts passwords before they are placed in a preference file.
  16142. > So does anyone perharps know where I can find a straightforward
  16143. > snippet for encryption/decryption of passwords?
  16144.  
  16145. Actual _encryption_ may not really be necessary; encryption sort of
  16146. implies that you'll want to recover the original value from the
  16147. encrypted result.  For passwording, all you really [may] want is to
  16148. verify that the entered password is the same as the original; to
  16149. do so with reasonable assurance, it may only be necessary to "hash"
  16150. the original password, then "hash" all subsequent entries to see
  16151. if the hash-value is the same as the one stored.  Simple example:
  16152.  
  16153. unsigned long hash_pwd (char *pwd)
  16154. {
  16155.   unsigned long hash = 0x31415926;
  16156.  
  16157.   while (*pwd)
  16158.     hash =  (hash<<1) + *pwd++;
  16159.   return (hash);
  16160. }
  16161.  
  16162. The mathematically-inclined out there may be able to tell us what
  16163. the probability of two distinct passwords having the same hash-value
  16164. is, but the intuitive answer is 'pretty darn small'  :-)  Naturally,
  16165. your routine would refuse to accept 1- or 2-character passwords...
  16166.  
  16167. /srh
  16168. -- 
  16169. Stephen R. Holmes   | sholmes@netrix.com  | the usual disclaimers
  16170. Netrix Corporation  | srh@netrix.com      | .....
  16171. Herndon, VA  USA    | srholmes@aolcom     | witty saying TBD
  16172.  
  16173. ---------------------------
  16174.  
  16175. End of C.S.M.P. Digest
  16176. **********************
  16177.  
  16178.  
  16179.