home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-224.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  41.8 KB  |  1,239 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Mon, 21 Dec 92       Volume 1 : Issue 224
  2.  
  3. Today's Topics:
  4.  
  5.     Button() not callable from interrupt ?
  6.     looking for a REALLY RaNdOM "RANDOM"
  7.     MachineLocation dlsDelta: can I set?
  8.     XVT's Portability Toolkit
  9.     sndPlay while animating
  10.     INIT's/System Extension Questions
  11.     is there a way to find out who is using an app ?
  12.     Hilite a Rect
  13.  
  14.  
  15.  
  16. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  17.  
  18. The digest is a collection of article threads from the internet newsgroup
  19. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  20. regularly and want an archive of the discussions.  If you don't know what a
  21. newsgroup is, you probably don't have access to it.  Ask your systems
  22. administrator(s) for details.  You can post articles to any newsgroup by
  23. mailing your article to newsgroup@ucbvax.berkeley.edu.  So, to post an
  24. article to comp.sys.mac.programmer, you mail it to
  25. comp-sys-mac-programmer@ucbvax.berkeley.edu.  Note the '-' instead of '.'
  26. in the newsgroup name.
  27.  
  28. Each issue of the digest contains one or more sets of articles (called
  29. threads), with each set corresponding to a 'discussion' of a particular
  30. subject.  The articles are not edited; all articles included in this digest
  31. are in their original posted form (as received by our news server at
  32. cs.uoregon.edu).  Article threads are not added to the digest until the last
  33. article added to the thread is at least one month old (this is to ensure that
  34. the thread is dead before adding it to the digest).  Article threads that
  35. consist of only one message are generally not included in the digest.
  36.  
  37. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  38. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  39. file /pub/mac/csmp-digest/README before downloading any files.  The most
  40. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  41. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  42. archive has a mail server; send a message with the text '$MACarch help' (no
  43. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  44.  
  45. The digest is also available via email.  Just send a note saying that you
  46. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  47. automatically receive each new issue as it is created.  Sorry, back issues
  48. are not available through the mailing list.
  49.  
  50. Send administrative mail to mkelly@cs.uoregon.edu.
  51.  
  52.  
  53. -------------------------------------------------------
  54.  
  55. From: robert@wsooti11.info.win.tue.nl (Robert Lukassen)
  56. Subject: Button() not callable from interrupt ?
  57. Date: 9 Nov 92 09:36:42 GMT
  58. Organization: Eindhoven University of Technology, the Netherlands
  59.  
  60. Hi,
  61.  
  62. I ran into a bit of trouble the other day when I tried to read the state of the
  63. mouse-button from an interrupt-routine. I know that the state of the mouse-button
  64. is represented by a single bit in some low-memory variable and this works well, but
  65. why does (the old version of) Inside Macintosh claims that Button() can move or purge
  66. memory. That is absolutely insane! A simple fetch of a low-memory variable can't
  67. trigger a memory move or memory purge. What are they doing that makes calling
  68. Button() so dangerous?
  69.  
  70. Robert
  71. - --
  72. +--------------------------------------+--------------------------------------+
  73. |  Robert 'MacBear' Lukassen           |  Eindhoven University of Technology  |
  74. |  Email: robert@info.win.tue.nl       |  The Netherlands                     |
  75. +--------------------------------------+--------------------------------------+
  76. | 'So logically ?  If she weighs the same as a duck, she's made of wood...    |
  77. |  And therefore ?  ...a WITCH !!!!'   - Monty Python, the Holy Grail.        |
  78. +-----------------------------------------------------------------------------+
  79.  
  80. +++++++++++++++++++++++++++
  81.  
  82. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  83. Date: 9 Nov 92 14:40:20 GMT
  84. Organization: Symantec Corp.
  85.  
  86. >>>>> On 9 Nov 92 09:36:42 GMT, robert@wsooti11.info.win.tue.nl (Robert Lukassen) said:
  87.  
  88.  > I ran into a bit of trouble the other day when I tried to read the
  89.  > state of the mouse-button from an interrupt-routine. I know that
  90.  > the state of the mouse-button is represented by a single bit in
  91.  > some low-memory variable and this works well, but why does (the old
  92.  > version of) Inside Macintosh claims that Button() can move or purge
  93.  > memory. That is absolutely insane! A simple fetch of a low-memory
  94.  > variable can't trigger a memory move or memory purge. What are they
  95.  > doing that makes calling Button() so dangerous?
  96.  
  97. I ran into a similar situation with GetMouse(), which IM I also
  98. documents as moving memory. It turns out that the only time Button()
  99. and GetMouse() (as well as some others) move memory is when then
  100. all-but-dead Journaling Mechanism is enabled. (Supposedly it was
  101. reserved in System 7 for a revised version of MacroMaker, one of the
  102. few macro tools that actually used journaling. Thankfully, MacroMaker
  103. rests in peace...)
  104.  
  105. If you disassemble these routines, you'll find that they check
  106. JournalFlag at 0x8DE to see if journaling is currently enabled. A
  107. possible solution is to add a similar check to your own code and use a
  108. low mem global when necessary; it's probably simpler to always examine
  109. low memory directly.
  110.  
  111.     -phil
  112. - --
  113.    Phil Shapiro                                   Software Engineer
  114.    Language Products Group                     Symantec Corporation
  115.            Internet: phils@cs.brandeis.edu
  116.  
  117. +++++++++++++++++++++++++++
  118.  
  119. From: lsr@taligent.com (Larry Rosenstein)
  120. Date: 9 Nov 92 18:23:05 GMT
  121. Organization: Taligent, Inc.
  122.  
  123. In article <ROBERT.92Nov9103642@wsooti11.info.win.tue.nl>,
  124. robert@wsooti11.info.win.tue.nl (Robert Lukassen) wrote:
  125. > mouse-button from an interrupt-routine. I know that the state of the 
  126.  
  127. Use OSEventAvail with a 0 mask.  The event record will contain the state of
  128. the mouse button.
  129.  
  130. Larry Rosenstein
  131. Taligent, Inc.
  132.  
  133. lsr@taligent.com
  134.  
  135. +++++++++++++++++++++++++++
  136.  
  137. From: ericsc@microsoft.com (Eric Schlegel)
  138. Date: 10 Nov 92 16:36:53 GMT
  139. Organization: Microsoft Corporation
  140.  
  141. In article <ROBERT.92Nov9103642@wsooti11.info.win.tue.nl> robert@wsooti11.info.win.tue.nl (Robert Lukassen) writes:
  142. >I ran into a bit of trouble the other day when I tried to read the state of the
  143. >mouse-button from an interrupt-routine. I know that the state of the button
  144. >is represented by a single bit in some low-memory variable and this works well,
  145. >but why does (the old version of) Inside Macintosh claims that Button() can
  146. >move or purge memory. That is absolutely insane! A simple fetch of a low-memory
  147. >variable can't trigger a memory move or memory purge. What are they doing that
  148. >makes calling Button() so dangerous?
  149.  
  150. Unfortunately, they're checking to see if journalling is on, and if so, making
  151. a call to the journalling driver, which CAN move memory. It's not just a simple
  152. fetch.
  153.  
  154. I had the same problem - currently I'm reading MBState directly, for lack of
  155. a better solution, but I sure wish there was a better way...
  156.  
  157. - -eric
  158. - ------
  159. My opinions, not Microsoft's.
  160.  
  161. +++++++++++++++++++++++++++
  162.  
  163. From: lsr@taligent.com (Larry Rosenstein)
  164. Date: 12 Nov 92 17:35:32 GMT
  165. Organization: Taligent, Inc.
  166.  
  167. In article <lsr-091192102228@lsr.taligent.com>, lsr@taligent.com (Larry
  168. Rosenstein) wrote:
  169. > Use OSEventAvail with a 0 mask.  The event record will contain the state of
  170. > the mouse button.
  171.  
  172. Unfortunately, this is wrong.  Eric Schlegel pointed out that the DTS Q&A
  173. stack says that if Balloon Help is turned on, then OSEventAvail can move
  174. memory.
  175.  
  176. Larry Rosenstein
  177. Taligent, Inc.
  178.  
  179. lsr@taligent.com
  180.  
  181. ---------------------------
  182.  
  183. From: rsherman@mthvax.cs.miami.edu (Roby Sherman)
  184. Subject: looking for a REALLY RaNdOM "RANDOM"
  185. Date: 8 Nov 1992 12:09:06 -0500
  186. Organization: The Tao of Programming
  187.  
  188. Hello all.
  189.  
  190. I'm looking for a pascal piece of code that illustrates a really nice
  191. random number generation.
  192.  
  193. I'm working on an INIT that needs a few random numbers and at boot time,
  194. Apple's RANDOM function seems to always retrurn the same old thing.
  195. Any ideas?
  196.  
  197.  
  198.           Thanks in advance...
  199.  
  200.  
  201.                    --Roby
  202.  
  203. - -- 
  204. rsherman@mthvax.cs.miami.edu                    Roby Sherman
  205.  
  206. +++++++++++++++++++++++++++
  207.  
  208. From: bwilliam@iat.holonet.net (Bill Williams)
  209. Date: 9 Nov 92 03:19:10 GMT
  210. Organization: HoloNet (BBS: 510-704-1058)
  211.  
  212. Request for GOOD random number generator in Pascal:
  213.  
  214. I have lots of random number generator source, most are in "C" two are in
  215. 68000 assembly but one of them (My ultimate favorite) is actually in
  216. Pascal (The language you requested) here it is:
  217.  
  218.  
  219. ===========
  220.  
  221. UNIT Portable_Random_Numbers;
  222. INTERFACE
  223.  
  224.     FUNCTION Fetch_Random_Numbers: real;
  225.  
  226.     PROCEDURE Manually_Initialize_Seeds (value_1, value_2: LONGINT);
  227.  
  228.     PROCEDURE Auto_Initialize_Seeds;
  229.  
  230.  
  231. IMPLEMENTATION
  232.  
  233.     VAR
  234.         Random_Number_Seed_1, Random_Number_Seed_2: LONGINT; {
  235. signed 32-bit integers }
  236.  
  237.     FUNCTION Fetch_Random_Numbers: real;
  238.  
  239.         VAR
  240.             zz, kk: longint;
  241.  
  242.     BEGIN
  243.  
  244.         kk := Random_Number_Seed_1 DIV 53668;
  245.         Random_Number_Seed_1 := 40014 * (Random_Number_Seed_1 - kk
  246. * 53668) - kk * 12211;
  247.         IF Random_Number_Seed_1 < 0 THEN
  248.             Random_Number_Seed_1 := Random_Number_Seed_1 + 2147483563;
  249.  
  250.         kk := Random_Number_Seed_2 DIV 52774;
  251.         Random_Number_Seed_2 := 40692 * (Random_Number_Seed_2 - kk
  252. * 52774) - kk * 3791;
  253.         IF Random_Number_Seed_2 < 0 THEN
  254.             Random_Number_Seed_2 := Random_Number_Seed_2 + 2147483399;
  255.  
  256.         zz := Random_Number_Seed_1 - Random_Number_Seed_2;
  257.  
  258.         IF zz < 1 THEN
  259.             zz := zz + 2147483562;
  260.  
  261.         Fetch_Random_Numbers := zz * 4.65661E-10;
  262.  
  263.     END;
  264.  
  265.  
  266.     PROCEDURE Manually_Initialize_Seeds (value_1, value_2: LONGINT);
  267.  
  268. { This is for repeatable use of the Random number generator }
  269. { requirement is that  Random_Number_Seed_1 be in the range [1,
  270. 2_147_483_562] and  Random_Number_Seed_2 }
  271. { be in [1, 2_147_483_398] ( [ -2**31 + 85, 2**31 - 85 ]). }
  272.  
  273.     BEGIN
  274.         Random_Number_Seed_1 := value_1;
  275.         Random_Number_Seed_2 := value_2;
  276.     END;
  277.  
  278.  
  279.     PROCEDURE Auto_Initialize_Seeds;
  280.  
  281. { This version of Initialize_Seeds is Macintosh dependent. The theoretical }
  282. { requirement is that  Random_Number_Seed_1 be in the range [1,
  283. 2_147_483_562] and  Random_Number_Seed_2 }
  284. { be in [1, 2_147_483_398] ( [ -2**31 + 85, 2**31 - 85 ]). Here, 
  285. Random_Number_Seed_1 and }
  286. {  Random_Number_Seed_2 are in [0, 32_737]. See reference [1] cited in the
  287. comments of }
  288. { Fetch_Random_Numbers for more information on generating seeds. }
  289.  
  290.     BEGIN
  291.         GetDateTime(randSeed);
  292.         Random_Number_Seed_1 := abs(Random);
  293.         Random_Number_Seed_2 := abs(Random);
  294.     END;
  295.  
  296.  
  297.  
  298. END. { Portable_Random_Numbers }
  299. - -------------
  300.  
  301.  
  302. It is a classic Multiplicative Linear Congruential Generator as known
  303. about for over 20 years and proven to be the best "shitty" safe and
  304. equally distributed, evenly repeating random technique.
  305.  
  306. references :
  307.  
  308. {1. L'Ecuyer, Pierre, Efficient and Portable Combined Random Number }
  309. { Generators. Communications of the ACM, 31, 6 (June 1988), 742-749, 774 }
  310.  
  311. L'Ecuyer reports that a comprehensive battery of over 20 different tests
  312. were performed on the generator that involved billions of psuedo-random
  313. numbers and over 200 hours of VAX-11/780 CPU time. The empirical behavior
  314. of the generators is very satisfactory for this class of generator.
  315.  
  316.  
  317. Hope that solves it!
  318.  
  319. Bill Williams
  320.  
  321. +++++++++++++++++++++++++++
  322.  
  323. From: wingo@apple.com (Tony Wingo)
  324. Date: Mon, 9 Nov 1992 21:38:04 GMT
  325. Organization: Apple Computer
  326.  
  327. In article <1djhjiINNhlc@mthvax.cs.miami.edu>, rsherman@mthvax.cs.miami.edu
  328. (Roby Sherman) wrote:
  329. > Hello all.
  330. > I'm looking for a pascal piece of code that illustrates a really nice
  331. > random number generation.
  332. > I'm working on an INIT that needs a few random numbers and at boot time,
  333. > Apple's RANDOM function seems to always retrurn the same old thing.
  334. > Any ideas?
  335.  
  336. To the best of my knowlege, Apple's random number generator is based on
  337. Park and Miller's "Minimal Standard Random Number Generator", which is
  338. about as good as you are going to get for a 31-bit multiplicative residue
  339. RNG.  The reason you are always getting the same sequence is that you are
  340. not setting the seed to something different each time you start up.  Set it
  341. to something like the time of day.
  342.  
  343. For coding examples, and some theory, check out Park and Miller's article: 
  344. "Random Number Generators: Good Ones Are Hard To Find", CACM Vol 31, Number
  345. 10 (Oct 1988).
  346.  
  347. And of course, if you really want to get down to the nitty-gritty theory
  348. behind RNG's, there is always Vol 2. of Knuth.
  349.  
  350. - -tony
  351. >>usual disclaimer<<
  352.  
  353. +++++++++++++++++++++++++++
  354.  
  355. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  356. Date: 12 Nov 92 21:55:44 GMT
  357. Organization: University of Illinois at Urbana
  358.  
  359. In <1djhjiINNhlc@mthvax.cs.miami.edu> rsherman@mthvax.cs.miami.edu (Roby 
  360. Sherman) writes:
  361.  
  362. >Hello all.
  363.  
  364. >I'm looking for a pascal piece of code that illustrates a really nice
  365. >random number generation.
  366.  
  367. >I'm working on an INIT that needs a few random numbers and at boot time,
  368. >Apple's RANDOM function seems to always retrurn the same old thing.
  369. >Any ideas?
  370.  
  371.  
  372. interesting thing to note... I suppose it is because the seed for it is 
  373. connected to how long the machine has been on? (i.e. in the same Mac, an INIT 
  374. will see the same thing every time)
  375.  
  376. If you want a way of generating different random numbers, the principle isn't 
  377. too tough. one quick psuedo-random number would just be some modulo math on the
  378. current date/time value. (for example, date mod 99 will give you a random 
  379. number between 0 and 98) Depending on how random you want the number, you can 
  380. get into some very fancy number twiddling to make things more erratic, but in 
  381. all likelihood, some modulo of the date/time (which is seconds since 12 am 
  382. 1/1/04) with an odd value should give you a useable base.
  383.  
  384. ---------------------------
  385.  
  386. From: wdh@netcom.com (Bill Hofmann)
  387. Subject: MachineLocation dlsDelta: can I set?
  388. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  389. Date: Fri, 13 Nov 1992 18:02:13 GMT
  390.  
  391. IM V describes the MachineLocation struct and routines to set/get the
  392. CPU's location.  One of the fields is gmtFlags.dlsDelta, which is totally
  393. undocumented, and from what I can tell, unused, but always 0.  I'd love to
  394. use it for, of all things, daylight savings delta information.  Is there anyone 
  395. who knows anything about this field?  Anyone care to email me on the
  396. side with Apple's future plans? (I'm already so non-disclosed, I can't
  397. tell you my real name...).
  398.  
  399. - -Bill Hofmann (or so you think)
  400.  
  401. +++++++++++++++++++++++++++
  402.  
  403. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  404. Organization: University of Illinois at Urbana
  405. Date: Fri, 13 Nov 1992 20:36:41 GMT
  406.  
  407. wdh@netcom.com (Bill Hofmann) writes:
  408.  
  409. >IM V describes the MachineLocation struct and routines to set/get the
  410. >CPU's location.  One of the fields is gmtFlags.dlsDelta, which is totally
  411. >undocumented, and from what I can tell, unused, but always 0.  I'd love to
  412. >use it for, of all things, daylight savings delta information. Is there anyone
  413. >who knows anything about this field?  Anyone care to email me on the
  414. >side with Apple's future plans? (I'm already so non-disclosed, I can't
  415. >tell you my real name...).
  416.  
  417. Back in February, I asked an Apple person (whose identity I will
  418. protect) about just this issue and got the following response:
  419.  
  420. >Unfortunately, there aren't any plans right now to use the dlsDelta field
  421. >of the MachineLocation record. That's really sad considering it's right
  422. >there and useable, but there's nothing there to trust, just like you
  423. >suspected. 
  424.  
  425. [...Some gross INIT ideas to slove a problem that I posed to him...]
  426.  
  427. >I hope these ideas help you. It's a tough problem, and I can't think of any
  428. >clean solutions. If you decide to use a dirty solution like the one I
  429. >described, make sure you do a lot of testing, especially when new system
  430. >software releases are done. I'll suggest to the system software engineers
  431. >that the dlsDelta field should be used in future system software releases. 
  432.  
  433. It doesn't look good.
  434.  
  435. pr
  436. - -- 
  437. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  438. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  439. System manager - Cognitive Science Group, Beckman Institute, UIUC
  440. Internet: resnick@cogsci.uiuc.edu
  441.  
  442. ---------------------------
  443.  
  444. From: Daryl_Spitzer@mindlink.bc.ca (Daryl Spitzer)
  445. Subject: XVT's Portability Toolkit
  446. Organization: MIND LINK! - British Columbia, Canada
  447. Date: Fri, 13 Nov 1992 19:57:12 GMT
  448.  
  449. Does anyone know anything about XVT's Portability Toolkit?  A friend pointed
  450. out their ad. in BYTE.  He tells me it's expensive, but if it does what they
  451. advertise, it would be worth it:
  452.  
  453.         - supports Mac, Microsoft Windows, OS/2 PM, OPEN LOOK, OSF/Motif
  454.           & character
  455.  
  456.         - native look & feel
  457.  
  458.         - access to complete functionality of each system
  459.  
  460. So is this for real?
  461.  
  462. (If so, why should one wait for Bedrock?)
  463.  
  464. - --
  465. - -------------------------------------------------------------------
  466.  Daryl_Spitzer@mindlink.bc.ca     "Life isn't just, life just is."
  467.          a2251@mindlink.bc.ca              -- Me  (I think.)
  468. - -------------------------------------------------------------------
  469.  
  470. +++++++++++++++++++++++++++
  471.  
  472. From: werner@soe.berkeley.edu (John Werner)
  473. Date: 13 Nov 92 21:03:15 GMT
  474. Organization: UC Berkeley School of Education
  475.  
  476. In article <17443@mindlink.bc.ca>, Daryl Spitzer wrote:
  477. > Does anyone know anything about XVT's Portability Toolkit?
  478. > [...]
  479. > So is this for real?
  480.  
  481. Here's an editied verion of what I answered last time someone asked this
  482. (in comp.lang.c++)...
  483.  
  484. At my last job I was involved in a research project evaluating future
  485. cross-platform projects.  We spent most of our time evaluating and
  486. prototyping with XVT.  One of their current products is also mostly written
  487. with XVT.  So I can give you some opinions.
  488.  
  489. For totally-from-scratch portable development of simple applications, XVT
  490. probably isn't so bad.  Code that's written using just the XVT api is
  491. indeed portable.  The catch is that the API is basically a lowest common
  492. denominator of all the environments it supports.  The people at XVT will
  493. deny this; it's sort of a religious issue with them.  But just try to get
  494. them to support some functionality that isn't directly supported by all the
  495. environments, and you'll find out the truth.  We were trying to get them to
  496. support floating windows and pop-up menus, among other things, and they
  497. refused, basically for religious reasons.
  498.  
  499. What little I saw of XVTs C++ class library made me want to run and hide. 
  500. It was just a set of wrapper classes around the various objects in the C
  501. api.  I spent a fair amount of time writing my own MacApp-inspired C++
  502. library around XVT.  It's possible to do, and it was actually kind of fun
  503. for me, but it's something XVT should have done themselves.  I think
  504. writing a real class library is definitely the way to go if you plan to
  505. write a large user interface with XVT.
  506.  
  507. One more complaint: XVTs resource language is a piece of junk.  It's
  508. impossible to be any more polite about it than that.  It really stinks out
  509. loud.  For all but the simplest applications you'll have to code the
  510. resources separately on each platform.
  511.  
  512. And finally, the programmers at my last job who developed a Windows product
  513. using XVT absolutely HATED it.  Part of this was related to dialog box
  514. support: XVT doesn't have a very complete or flexible set of dialog
  515. functions.  They don't allow you to define custom controls in dialogs at
  516. all portably.  Related to this is the fact that mixing platform-specific
  517. code into an XVT application is a major nightmare; you start running into
  518. lots of "who's in charge" issues, and lots of things that are just plain
  519. XVT bugs.  We had the source code, so at least we could fix them.
  520.  
  521. Summary: If you're writing a simple program, without complicated dialogs,
  522. or if you're willing to take the time to write a large class library around
  523. XVT, it might be worth using.  Otherwise don't.
  524.  
  525. PS: Have you considered writing in MacApp and then porting to Bedrock (the
  526. new portable class library being developed by Apple and Symantec) when it
  527. comes out (sometime next year?)?
  528.  
  529. > (If so, why should one wait for Bedrock?)
  530.  
  531. Bedrock is going to be an entirely different animal: an application
  532. framework/class library, ala MacApp.
  533.  
  534. - --
  535. John Werner                         werner@soe.berkeley.edu
  536. UC Berkeley School of Education     510-642-9651
  537.  
  538. ---------------------------
  539.  
  540. From: mak+@cs.cmu.edu (Matthew Alan Kane)
  541. Subject: sndPlay while animating
  542. Date: 15 Nov 92 19:08:01 GMT
  543. Organization: School of Computer Science, Carnegie Mellon
  544.  
  545. Situation:
  546. I have animation running during vbl
  547. and am playing snd resources with sndPlay.
  548.  
  549. Problem:
  550. How do I keep my animation going while the sound is playing?
  551.  
  552. Thanks,
  553.  
  554. Matthew Kane
  555. mak@cs.cmu.edu
  556.  
  557. +++++++++++++++++++++++++++
  558.  
  559. From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
  560. Date: 15 Nov 92 23:58:30 GMT
  561. Organization: The Great Beyond
  562.  
  563. In article <BxruHF.F11.1@cs.cmu.edu> mak+@cs.cmu.edu (Matthew Alan Kane) writes:
  564. >Situation:
  565. >I have animation running during vbl
  566. >and am playing snd resources with sndPlay.
  567. >
  568. >Problem:
  569. >How do I keep my animation going while the sound is playing?
  570. >
  571. >mak@cs.cmu.edu
  572.  
  573. Hi..
  574.  
  575.    I assume when you call SndPlay, the computer then freezes until it's
  576. done playing the sound?  Or even if you're playing it asynchronously and
  577. that's not working well, the following should help.
  578.  
  579.    I wrote some simple code in Think C for a game I'm working on to play
  580. sounds in the background.  For me the sounds seem totally independent of
  581. the animation; that is, the animation doesn't get in the way of the sound
  582. and vice-versa.  It works.
  583.  
  584. Here's the code:
  585.  
  586. First, set up a sound channel.
  587.  
  588. void ThisWorks(void)
  589. {
  590.   SndChannelPtr   myChannel;
  591.   OSErr           myErr;
  592.   SndCommand      mySndCommand;
  593.   Handle          mySoundEffect;
  594.  
  595.   myErr = SndNewChannel(&myChannel, sampledSynth, initMono, nil);
  596.  
  597.   mySoundEffect = GetResource('snd ', SOUND_RESOURCE_ID);
  598.  
  599.   mySndCommand.param1 = 0;
  600.   mySndCommand.param2 = 0;
  601.   mySndCommand.cmd = flushCmd;
  602.  
  603.   myErr = SndDoImmediate(myChannel, &mySndCommand);
  604.   myErr = SndPlay(myChannel, mySoundEffect, true);
  605. }
  606.  
  607. Of course, you need to include <sound.h> at the beginning of your program.
  608.  
  609. I'm not certain the "flushCmd" deal is necessary..  (I wrote this awhile ago,
  610. in Pascal at first, so if you're using Pascal and have a problem converting
  611. it, buzz me.)  I think that just flushes the channel in case any other sounds
  612. are playing on it.
  613.  
  614. Actually, it's useful to set up multiple channels (on sound-capable Macs you
  615. have 4), because then you can use one channel for a continuous soundtrack,
  616. and another channel for sound effects, etc.  (Of course this method might
  617. cause problems if you're competing with other programs for the same channel,
  618. etc.)
  619.  
  620. Hope that helps!
  621.  
  622. M. Scott Smith
  623.   (mssmith@afterlife.ncsc.mil || umsmith@mcs.drexel.edu)
  624.  
  625. +++++++++++++++++++++++++++
  626.  
  627. From: REEKES@applelink.apple.com (Jim Reekes)
  628. Date: 16 Nov 92 21:19:52 GMT
  629. Organization: Apple Computer, Inc.
  630.  
  631. In article <1992Nov15.235830.17180@afterlife.ncsc.mil>,
  632. mssmith@afterlife.ncsc.mil (M. Scott Smith) wrote:
  633. > In article <BxruHF.F11.1@cs.cmu.edu> mak+@cs.cmu.edu (Matthew Alan Kane) writes:
  634. > >Situation:
  635. > >I have animation running during vbl
  636. > >and am playing snd resources with sndPlay.
  637. > >
  638. > >Problem:
  639. > >How do I keep my animation going while the sound is playing?
  640. >
  641. > Here's the code:
  642. > First, set up a sound channel.
  643. > void ThisWorks(void)
  644. > {
  645. >   SndChannelPtr   myChannel;
  646. >   OSErr           myErr;
  647. >   SndCommand      mySndCommand;
  648. >   Handle          mySoundEffect;
  649. >   myErr = SndNewChannel(&myChannel, sampledSynth, initMono, nil);
  650. >   mySoundEffect = GetResource('snd ', SOUND_RESOURCE_ID);
  651. >   mySndCommand.param1 = 0;
  652. >   mySndCommand.param2 = 0;
  653. >   mySndCommand.cmd = flushCmd;
  654. >   myErr = SndDoImmediate(myChannel, &mySndCommand);
  655. >   myErr = SndPlay(myChannel, mySoundEffect, true);
  656. > }
  657.  
  658. You didn't initialize the channel pointer before calling SndNewChannel. 
  659. This will trash random locations of memory.  You need to add the line:
  660.  
  661.     myChannel = nil;
  662.  
  663. before calling SndNewChannel.
  664.  
  665. > I'm not certain the "flushCmd" deal is necessary..
  666.  
  667. It's not.  Also, the next problem is that after you play this sound you
  668. need to know when you can dispose of the sound channel.  Also, in this
  669. example the channel was a local variable on the stack so you'll lose your
  670. referece to it.  It needs to be a global or some how be made available
  671. later in the program so you can call SndDisposeChannel. Using a
  672. CallBackProc and the callBackCmd will help you to determine when the sound
  673. has finished.
  674.  
  675. - -----------------------------------------------------------------------
  676. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  677.                              |          Sound Manager Expert
  678. Apple Computer, Inc.         | "All opinions expressed are mine, and do
  679. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  680. Cupertino, CA 95014          |       employer, Apple Computer Inc."
  681.  
  682. ---------------------------
  683.  
  684. From: system@asuvax.eas.asu.edu (Marc Lesure)
  685. Subject: INIT's/System Extension Questions
  686. Date: 5 Nov 92 18:46:23 GMT
  687. Organization: Arizona State University
  688.  
  689. I have an INIT that I wrote under System 6.x which works just fine.  The
  690. INIT still works under System 7.0 if it resides in the System folder,
  691. however if I put it in the Extension folder it fails.  The problem seems to
  692. be the call to the routine OpenDriver(), under the extension folder it
  693. returns the error openErr.  The device driver resides in the INIT resource
  694. fork.  Any suggestions?
  695.  
  696. Also, are there any snippets showing the best way to show an INIT icon
  697. during the booting sequence?
  698.  
  699. Thanks!
  700.  
  701. - -----------------------------------------------------------------------
  702. Marc Lesure / Arizona State University / Tempe, AZ
  703. "Between the world of men and make-believe, I can be found..."
  704. "False faces and meaningless chases, I travel alone..."
  705. "And where do you go when you come to the end of your dream?"
  706.  
  707. UUCP:       ...!ncar!noao!asuvax!lesure  
  708. Internet:   lesure@asuvax.eas.asu.edu
  709.  
  710. +++++++++++++++++++++++++++
  711.  
  712. From: cklarson@taquito.engr.ucdavis.edu (Christopher Klaus Larson)
  713. Date: 9 Nov 92 01:08:45 GMT
  714. Organization: College of Engineering - University of California - Davis
  715.  
  716. In article <1992Nov5.184623.15326@asuvax.eas.asu.edu> system@asuvax.eas.asu.edu (Marc Lesure) writes:
  717.  
  718. >Also, are there any snippets showing the best way to show an INIT icon
  719. >during the booting sequence?
  720.  
  721. I'm not sure if this is the _best_ way to show an icon during startup, but
  722. it has always worked for me. :-)
  723.  
  724. Feel free to use this as you see fit. Optimizations and bug fixes welcome.
  725.  
  726. It is written in THINK C and requires the inclusion of the MacTraps library.
  727. Hopefully the comments within the code are a sufficient explination of how
  728. it works.
  729.  
  730. I have seen other examples that perform this operation but they were
  731. written in assembly.
  732.  
  733. Sorry about the lines longer than 80 characters.
  734.  
  735. - -- Chris
  736. cklarson@engr.ucdavis.edu
  737.  
  738. Code Follows ...
  739. - ----------------------
  740.  
  741. /******************************************************************************
  742.  
  743.     Draw_Init_Icon.c    1992 - Chris Larson
  744.  
  745.     This function will draw an Init's icon on the screen during startup.
  746.     
  747.     Include the line,
  748.     
  749.         extern void Draw_Init_Icon (short icon_id);
  750.         
  751.     in your INIT source with your function prototypes and pass in the
  752.     resource ID of the icon you wish to be drawn. If color QD exists, the
  753.     function will attempt to draw a 'cicn' resource. If there is no color QD,
  754.     it will draw an 'icn#'. If an error occurs, SysBeep is called and nothing
  755.     is drawn.
  756.     
  757. ******************************************************************************/
  758.  
  759. #include <Quickdraw.h>
  760. #include <Types.h>
  761. #include <OSUtils.h>
  762. #include <Resources.h>
  763. #include <Memory.h>
  764. #include <LoMem.h>
  765.  
  766. #define DI_INITIAL_OFFSET       8
  767. #define DI_BOTTOM_OFFSET        8
  768. #define DI_ICON_HEIGHT          32
  769. #define DI_ICON_WIDTH           32
  770. #define DI_ICON_OFFSET          8
  771. #define DI_NO_COLOR_QD          0x4000
  772. #define DI_BEEP_LENGTH          30
  773. #define DI_ICNPOUND_ROWBYTES    4
  774. #define DI_INCPOUND_MASK_OFFSET 128
  775. #define DI_CHECKSUM_CONSTANT    0x1021
  776. #define DI_PVT_GBL_SIZE         76
  777.  
  778. #define LEFT_OFFSET_POINTER ((short *)0x092C) /* Last 4 bytes of CurAppName */
  779. #define CHECKSUM_POINTER    ((short *)0x092E) /* hold position & checksum   */
  780.  
  781. typedef struct
  782.     {
  783.     Byte        QD_Private_Global_Space[DI_PVT_GBL_SIZE];
  784.     long        randseed;
  785.     BitMap      screenBits;
  786.     Cursor      arrow;
  787.     Pattern     dkGray;
  788.     Pattern     ltGray;
  789.     Pattern     gray;
  790.     Pattern     black;
  791.     Pattern     white;
  792.     GrafPtr     thePort;
  793.     } QD_Variables;
  794.  
  795. void Draw_Init_Icon (short icon_id);
  796.  
  797. void Draw_Init_Icon (short icon_id)
  798. {
  799.     CIconHandle     icon_handle = NULL;
  800.     Rect            destination_rect;
  801.     Rect            source_rect;
  802.     BitMap          icon_bitmap;
  803.     BitMap          mask_bitmap;
  804.     GrafPort        local_port;
  805.     QD_Variables    my_vars;
  806.     long            our_a5;
  807.     long            old_a5;
  808.     
  809.     /* Prepare A5 for InitGraf call */
  810.     
  811.     asm 68000
  812.         {
  813.         move.l  a5,old_a5
  814.         lea     our_a5,a5
  815.         move.l  a5,CurrentA5
  816.         }
  817.     
  818.     /* InitGraf and open our GrafPort */
  819.     
  820.     InitGraf (&(my_vars.thePort));
  821.     OpenPort (&local_port);
  822.     
  823.     /* Determine if position is valid. If not, set to initial value.
  824.        If so, do nothing. */
  825.     
  826.     if ((((*LEFT_OFFSET_POINTER)<<1)^DI_CHECKSUM_CONSTANT) != (*CHECKSUM_POINTER))
  827.         *LEFT_OFFSET_POINTER = DI_INITIAL_OFFSET;
  828.     
  829.     /* Compute destination Rect. */
  830.     
  831.     destination_rect.bottom = local_port.portRect.bottom - DI_BOTTOM_OFFSET;
  832.     destination_rect.left = local_port.portRect.left + *LEFT_OFFSET_POINTER;
  833.     destination_rect.top = destination_rect.bottom - DI_ICON_HEIGHT;
  834.     destination_rect.right = destination_rect.left + DI_ICON_WIDTH;
  835.     
  836.     /* If color QD exists, use 'cicn'. If not, use 'ICN#'.
  837.        SysBeep and return if resource unavailable. */
  838.     
  839.     if (!(ROM85&DI_NO_COLOR_QD))
  840.         {
  841.         icon_handle = GetCIcon (icon_id);
  842.         if (!icon_handle)
  843.             {
  844.             SysBeep (DI_BEEP_LENGTH);
  845.             return;
  846.             }
  847.         PlotCIcon (&destination_rect,icon_handle);
  848.         DisposCIcon (icon_handle);
  849.         }
  850.     else
  851.         {
  852.         icon_handle = (CIconHandle)GetResource ('ICN#',icon_id);
  853.         if (!icon_handle)
  854.             {
  855.             SysBeep(DI_BEEP_LENGTH);
  856.             return;
  857.             }
  858.         
  859.         HLock (icon_handle);
  860.         
  861.         /* Set source Rect and intialize source BitMaps. */
  862.         
  863.         SetRect (&source_rect,0,0,DI_ICON_HEIGHT,DI_ICON_WIDTH);
  864.         
  865.         icon_bitmap.bounds  = mask_bitmap.bounds = source_rect;
  866.         icon_bitmap.rowBytes = mask_bitmap.rowBytes = DI_ICNPOUND_ROWBYTES;
  867.         icon_bitmap.baseAddr = (Ptr)(*icon_handle);
  868.         mask_bitmap.baseAddr = (Ptr)(((Byte *)(*icon_handle))+DI_INCPOUND_MASK_OFFSET);
  869.         
  870.         /* Draw the 'ICN#' using its mask. */
  871.         
  872.         CopyMask (&icon_bitmap,&mask_bitmap,&(local_port.portBits),&source_rect,&source_rect,&destination_rect);
  873.         
  874.         HUnlock (icon_handle);
  875.         ReleaseResource (icon_handle);
  876.         }
  877.     
  878.     ClosePort (&local_port);
  879.     
  880.     /* Update drawing position and checksum. */
  881.     
  882.     *LEFT_OFFSET_POINTER += DI_ICON_WIDTH+DI_ICON_OFFSET;
  883.     
  884.     *CHECKSUM_POINTER = ((*LEFT_OFFSET_POINTER)<<1)^DI_CHECKSUM_CONSTANT;
  885.     
  886.     /* Reset A5 */
  887.     
  888.     asm 68000
  889.         {
  890.         movea.l old_a5,a5
  891.         move.l  a5,CurrentA5
  892.         }
  893.     
  894.     /* We're outa here. */
  895.     
  896.     return;
  897. }
  898.  
  899.  
  900. +++++++++++++++++++++++++++
  901.  
  902. From: Mark.R.Valence@dartmouth.edu (Mark R. Valence)
  903. Date: 9 Nov 92 14:29:44 GMT
  904. Organization: Dartmouth College, Hanover, NH
  905.  
  906. In article <19028@ucdavis.ucdavis.edu>
  907. cklarson@taquito.engr.ucdavis.edu (Christopher Klaus Larson) writes:
  908.  
  909. > In article <1992Nov5.184623.15326@asuvax.eas.asu.edu> system@asuvax.eas.asu.edu (Marc Lesure) writes:
  910. >  
  911. > >Also, are there any snippets showing the best way to show an INIT icon
  912. > >during the booting sequence?
  913. >  
  914. > I'm not sure if this is the _best_ way to show an icon during startup, but
  915. > it has always worked for me. :-)
  916. > Feel free to use this as you see fit. Optimizations and bug fixes welcome.
  917.  
  918. I have two minor comments:
  919.  
  920. 1.  You save A5, and then restore A5 AND CurrentA5 to the A5's original
  921. value.  This is dangerous, as you are assuming A5 points to a valid
  922. quickdraw globals area upon entry to your code.  I would suggest
  923. instead that you save BOTH A5 and CurrentA5 in separate locations, and
  924. restore them separately.  If you don't, you will see some weird bugs
  925. with some pretty widely used INITs (I won't mention any names).
  926.  
  927. 2.  You should probably give some credit to the guys who wrote the
  928. original and most widely used version of this code.  They were the
  929. ones, I believe, who first used CurApName for temporary storage, and
  930. made it the "standard".  I, too have written my own version of this
  931. code (it's smaller than the original, and does the same stuff), but my
  932. code still credits the original source.
  933.  
  934. Mark.
  935.  
  936. +++++++++++++++++++++++++++
  937.  
  938. From: franklin@endive.eecs.ucdavis.edu (Paul Franklin)
  939. Date: 11 Nov 92 23:46:58 GMT
  940. Organization: University of California at Davis
  941.  
  942. In article <1992Nov9.142944.3187@dartvax.dartmouth.edu> Mark.R.Valence@dartmouth.edu (Mark R. Valence) writes:
  943. >In article <19028@ucdavis.ucdavis.edu>
  944. >cklarson@taquito.engr.ucdavis.edu (Christopher Klaus Larson) writes:
  945. >
  946. >> Feel free to use this as you see fit. Optimizations and bug fixes welcome.
  947. >
  948. >I have two minor comments:
  949. >
  950. >1.  You save A5, and then restore A5 AND CurrentA5 to the A5's original
  951. >value.  This is dangerous, as you are assuming A5 points to a valid
  952. >quickdraw globals area upon entry to your code.  I would suggest
  953. >instead that you save BOTH A5 and CurrentA5 in separate locations, and
  954. >restore them separately.  If you don't, you will see some weird bugs
  955. >with some pretty widely used INITs (I won't mention any names).
  956.  
  957. Very true. I do assume that A5 and CurrentA5 contain the same value
  958. upon entry -- a POOR assumption. The value of CurrentA5 should be
  959. saved and restored to its value on entry, not restored to A5's entry
  960. value.
  961.  
  962. >2.  You should probably give some credit to the guys who wrote the
  963. >original and most widely used version of this code.  They were the
  964. >ones, I believe, who first used CurApName for temporary storage, and
  965. >made it the "standard".  I, too have written my own version of this
  966. >code (it's smaller than the original, and does the same stuff), but my
  967. >code still credits the original source.
  968.  
  969. Absolutely. The original routine was written by Paul Mercer, Darin Adler,
  970. and Paul Snively from an idea by Steve Capps. Their code did standardize
  971. the use of CurApName for temporary storage. In no way do I attempt to
  972. take credit for thier work and I apologize for this omission.
  973.  
  974. Thanks for the comments.
  975.  
  976. (Sorry it took so long for me to respond -- we have had some problems
  977. with our news server so I had to post this from a friend's account.)
  978.  
  979. - -- Chris
  980. cklarson@engr.ucdavis.edu
  981.  
  982. +++++++++++++++++++++++++++
  983.  
  984. From: walkerj@math.scarolina.edu (Jim Walker)
  985. Organization: USC  Department of Computer Science
  986. Date: 18 Nov 92 15:10:54 GMT
  987.  
  988. In article <1992Nov5.184623.15326@asuvax.eas.asu.edu>
  989.  system@asuvax.eas.asu.edu (Marc Lesure) writes:
  990.  
  991. >Also, are there any snippets showing the best way to show an INIT icon
  992. >during the booting sequence?
  993.  
  994. I have one I call ShowIcon7 which is compatible (I think) with IconWrap,
  995. and which (under System 7) will show color icons of iclx types. Under
  996. System 6, it does black and white.  It's written in THINK C 5.  Source and
  997. compiled code is available by ftp from bigbird.csd.scarolina.edu in
  998. pub/mac.
  999. - --
  1000.  
  1001.  -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  1002.  
  1003. ---------------------------
  1004.  
  1005. From: jxs18@po.CWRU.Edu (Jerry Sy)
  1006. Subject: is there a way to find out who is using an app ?
  1007. Date: 16 Nov 1992 21:49:18 GMT
  1008. Organization: Case Western Reserve University, Cleveland, OH (USA)
  1009.  
  1010.  
  1011. Here's my problem.
  1012.  
  1013. I have an application that runs in multiuser mode out on an appleshare
  1014. server volume.  Now whenever I make some changes and want to update,
  1015. I can't because people are using the program.  Now the appleshare
  1016. program will tell me who is currently logged on, but not who is
  1017. using my program.
  1018.  
  1019. is there a way to determine (programmatically or otherwise) who is
  1020. using an app on the server, short of going to each and every one
  1021. of the 50 users who are currently logged in ?
  1022.  
  1023. thanks
  1024. jerry
  1025.  
  1026.  
  1027. +++++++++++++++++++++++++++
  1028.  
  1029. From: leonardr@netcom.com (Leonard Rosenthol)
  1030. Date: 17 Nov 92 05:02:25 GMT
  1031. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  1032.  
  1033. In article <1e950uINN3lb@usenet.INS.CWRU.Edu> jxs18@po.CWRU.Edu (Jerry Sy) writes:
  1034. >
  1035. >I have an application that runs in multiuser mode out on an appleshare
  1036. >server volume.  Now whenever I make some changes and want to update,
  1037. >I can't because people are using the program.  Now the appleshare
  1038. >program will tell me who is currently logged on, but not who is
  1039. >using my program.
  1040. >
  1041. >is there a way to determine (programmatically or otherwise) who is
  1042. >using an app on the server, short of going to each and every one
  1043. >of the 50 users who are currently logged in ?
  1044. >
  1045.     Nope, there is no way to tell who has a file open.  This is a REAL
  1046. problem if you want to do multi-user software, where a given file could be
  1047. open by many people at the same time.
  1048.  
  1049. - -- 
  1050. - -----------------------------------------------------------------------------
  1051. Leonard Rosenthol            Internet:     leonardr@netcom.com
  1052. Director of Advanced Technology        AppleLink:    MACgician
  1053. Aladdin Systems, Inc.            GEnie:        MACgician
  1054.  
  1055. +++++++++++++++++++++++++++
  1056.  
  1057. From: veloso@husc9.harvard.edu (Manuel Veloso)
  1058. Date: 17 Nov 92 14:10:16 GMT
  1059. Organization: Harvard University
  1060.  
  1061. In article <1e950uINN3lb@usenet.INS.CWRU.Edu> Jerry Sy, jxs18@po.CWRU.Edu
  1062. writes:
  1063. >is there a way to determine (programmatically or otherwise) who is
  1064. >using an app on the server, short of going to each and every one
  1065. >of the 50 users who are currently logged in ?
  1066. >
  1067. >thanks
  1068. >jerry
  1069.  
  1070. What you could do, although it would be a lot of work, is install a
  1071. ServerEvent handler on the server & watch for FPOpenFork. When you get
  1072. it, check to see what file it is & who's opening it...if it's an
  1073. application, you've probably got a launch...
  1074.  
  1075. Manny
  1076.  
  1077. ---------------------------
  1078.  
  1079. From: bfoley@obelisk.berkeley.edu (Brian Foley)
  1080. Subject: Hilite a Rect
  1081. Date: 17 Nov 92 05:16:17 GMT
  1082. Organization: University of California, Berkeley
  1083.  
  1084.  
  1085. How do you hilite a rect using the current hilite color?
  1086. I am using InvertRect() now, but it would be "better" to do it
  1087. in color.  Inside Mac is rather vague on the subject I tried using 
  1088.  
  1089. BitClr ((Ptr) HiliteMode, pHiliteBit);  /* IM V-61 */
  1090.  
  1091. but that gave me a bus error.
  1092.  
  1093. brian foley
  1094.  
  1095. bfoley@garnet.berkeley.edu
  1096. Science and Mathematics Education
  1097. University of California, Berkeley
  1098.  
  1099. +++++++++++++++++++++++++++
  1100.  
  1101. From: stepan@natinst.com (Stepan Riha)
  1102. Date: 17 Nov 1992 08:30:44 -0600
  1103. Organization: National Instruments, Austin, TX
  1104.  
  1105. In article <1e9v71INNgqn@agate.berkeley.edu> bfoley@obelisk.berkeley.edu (Brian Foley) writes:
  1106. >How do you hilite a rect using the current hilite color?
  1107. >I am using InvertRect() now, but it would be "better" to do it
  1108. >in color.  Inside Mac is rather vague on the subject I tried using 
  1109. >
  1110. >BitClr ((Ptr) HiliteMode, pHiliteBit);  /* IM V-61 */
  1111. >
  1112. >but that gave me a bus error.
  1113.  
  1114. I never use the BitClr function (for byte to long sized variables) because
  1115. you get the extra trap dispatch overhead.  The way I code my highlights is:
  1116.  
  1117.     *(char*)HiliteMode &= ~(0x01<<hiliteBit);
  1118.  
  1119. Note that <Quickdraw.h> defines pHiliteBit = 7 and hiliteBit = 0, that's
  1120. because BitClr(ptr, bitNr) counts the high order bit of *ptr as bit 0.
  1121. IM I p.470-471.
  1122.  
  1123. However, I don't know why your code using BitClr should cause a buss error.
  1124.  
  1125.     - Stepan
  1126. - -- 
  1127.    Stepan Riha -- stepan@natinst.com
  1128.  
  1129.  
  1130. +++++++++++++++++++++++++++
  1131.  
  1132. From: engber@ils.nwu.edu (Mike Engber)
  1133. Date: 17 Nov 92 15:37:47 GMT
  1134. Organization: The Institute for the Learning Sciences
  1135.  
  1136. >I never use the BitClr function (for byte to long sized variables) because
  1137. >you get the extra trap dispatch overhead.  The way I code my highlights is:
  1138. >
  1139. >    *(char*)HiliteMode &= ~(0x01<<hiliteBit);
  1140. >
  1141. >However, I don't know why your code using BitClr should cause a buss error.
  1142.  
  1143. My guess is the the original poster is using THINK C which defines globals
  1144. as external vars - (not their addresses). From LoMem.h:
  1145.  char HiliteMode : 0x938;
  1146.  
  1147. In which case your suggestion will suffer the same problem. He needs to use:
  1148.  BitClr(&HiliteMode,pHiliteBit);
  1149.  
  1150. I made this same mistake myself recently. It's so easy (and foolish) to copy
  1151. code right from IM w/o thinking.
  1152.  
  1153. - -ME
  1154.  
  1155. +++++++++++++++++++++++++++
  1156.  
  1157. From: cklarson@burrito.engr.ucdavis.edu (Christopher Klaus Larson)
  1158. Date: 18 Nov 92 21:14:04 GMT
  1159. Organization: College of Engineering - University of California - Davis
  1160.  
  1161. In article <1e9v71INNgqn@agate.berkeley.edu> bfoley@obelisk.berkeley.edu (Brian Foley) writes:
  1162. >
  1163. >How do you hilite a rect using the current hilite color?
  1164. >I am using InvertRect() now, but it would be "better" to do it
  1165. >in color.  Inside Mac is rather vague on the subject I tried using 
  1166. >
  1167. >BitClr ((Ptr) HiliteMode, pHiliteBit);  /* IM V-61 */
  1168. >
  1169.  
  1170. If you are using THINK C >= 5.0, the variable HiliteMode contains the 
  1171. value of the hilite mode byte, not the addresss of the hilite mode byte.
  1172. Try the following:
  1173.  
  1174.     *((char *)0x0938) &= 0x7F;
  1175.  
  1176.     or
  1177.  
  1178.     HiliteMode &= 0x7F; (THINK C only)
  1179.  
  1180. before your call to InvertRect(). That should do the trick. 0x0938 is the
  1181. address of HiliteMode and 0x7F will mask off pHiliteBit.
  1182.  
  1183. - --Chris
  1184. cklarson@engr.ucdavis.edu
  1185.  
  1186. +++++++++++++++++++++++++++
  1187.  
  1188. From: udmorrow@mcs.drexel.edu (Daniel Morrow)
  1189. Date: 19 Nov 92 00:09:19 GMT
  1190. Organization: Drexel University
  1191.  
  1192. In article <19386@ucdavis.ucdavis.edu> cklarson@burrito.engr.ucdavis.edu (Christopher Klaus Larson) writes:
  1193. >In article <1e9v71INNgqn@agate.berkeley.edu> bfoley@obelisk.berkeley.edu (Brian Foley) writes:
  1194. >>
  1195. >>How do you hilite a rect using the current hilite color?
  1196. >>I am using InvertRect() now, but it would be "better" to do it
  1197. >>in color.  Inside Mac is rather vague on the subject I tried using 
  1198. >>
  1199. >>BitClr ((Ptr) HiliteMode, pHiliteBit);  /* IM V-61 */
  1200. >>
  1201. >
  1202. >If you are using THINK C >= 5.0, the variable HiliteMode contains the 
  1203.  
  1204. (some stuff deleted, then) Try this:
  1205. >
  1206. >    *((char *)0x0938) &= 0x7F;
  1207. >
  1208. >    or
  1209. >
  1210. >    HiliteMode &= 0x7F; (THINK C only)
  1211. >
  1212.  
  1213. I use Think 5.0 and all I do is say:
  1214.     BitClr(&HiliteMode, pHiliteBit);
  1215.  
  1216. This works quite nicely.
  1217.  
  1218. - -Dan.
  1219.  
  1220. ---------------------------
  1221.  
  1222. End of C.S.M.P. Digest
  1223. **********************
  1224.