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

  1. Received-Date: Wed, 7 Sep 1994 18:19:26 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-054
  4. To: csmp-digest@ens.fr
  5. Date: Wed, 7 Sep 1994 18:19:19 +0200 (MET DST)
  6. X-Mailer: ELM [version 2.4 PL23]
  7. Mime-Version: 1.0
  8. Content-Type: text/plain; charset=ISO-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Errors-To: listman@ens.fr
  11. Reply-To: pottier@clipper.ens.fr
  12. X-Sequence: 59
  13.  
  14. C.S.M.P. Digest             Wed, 07 Sep 94       Volume 3 : Issue 54
  15.  
  16. Today's Topics:
  17.  
  18.         How to use AESuspendTheCurrentEvent?
  19.         Learning Macintosh Programming
  20.         Should function order be conserved? (CW vs. GestaltValue)
  21.         Sound Manager headaches (again)
  22.         Stopping a 'snd ' resource dead
  23.         [Q] What does "_Xxxxx ,Sys,Immed" mean?
  24.         jGNE from an INIT
  25.  
  26.  
  27.  
  28. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  29. (pottier@clipper.ens.fr).
  30.  
  31. The digest is a collection of article threads from the internet newsgroup
  32. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  33. regularly and want an archive of the discussions.  If you don't know what a
  34. newsgroup is, you probably don't have access to it.  Ask your systems
  35. administrator(s) for details.  If you don't have access to news, you may
  36. still be able to post messages to the group by using a mail server like
  37. anon.penet.fi (mail help@anon.penet.fi for more information).
  38.  
  39. Each issue of the digest contains one or more sets of articles (called
  40. threads), with each set corresponding to a 'discussion' of a particular
  41. subject.  The articles are not edited; all articles included in this digest
  42. are in their original posted form (as received by our news server at
  43. nef.ens.fr).  Article threads are not added to the digest until the last
  44. article added to the thread is at least two weeks old (this is to ensure that
  45. the thread is dead before adding it to the digest).  Article threads that
  46. consist of only one message are generally not included in the digest.
  47.  
  48. The digest is officially distributed by two means, by email and ftp.
  49.  
  50. If you want to receive the digest by mail, send email to listserv@ens.fr
  51. with no subject and one of the following commands as body:
  52.     help                        Sends you a summary of commands
  53.     subscribe csmp-digest Your Name    Adds you to the mailing list
  54.     signoff csmp-digest            Removes you from the list
  55. Once you have subscribed, you will automatically receive each new
  56. issue as it is created.
  57.  
  58. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  59. Questions related to the ftp site should be directed to
  60. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  61. digest are available there.
  62.  
  63. Also, the digests are available to WAIS users.  To search back issues
  64. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  65. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  66.  
  67.  
  68. -------------------------------------------------------
  69.  
  70. >From phaedrus@chinook.halcyon.com (Mark Phaedrus)
  71. Subject: How to use AESuspendTheCurrentEvent?
  72. Date: 19 Aug 1994 21:44:57 GMT
  73. Organization: NWNEXUS, Inc. - Making Internet Easy
  74.  
  75.      Could someone please post some brief sample code showing the correct use
  76. of AESuspendTheCurrentEvent and AEResumeTheCurrentEvent?
  77.      Basically, this is what I'm doing right now:
  78.  
  79. AppleEvent *pendingEvent,*pendingReply;
  80. OSErr err;
  81.  
  82. pascal OSErr MyEventHandler(AppleEvent *messagein, AppleEvent *reply,
  83.                             long refcon)
  84. {
  85.    /* make sure we're allowed to put up a window */
  86.    if (noErr != (err = AEInteractWithUser(kMyTimeoutTicks,nil,nil)))
  87.         return err;
  88.    /* assorted code to display the window deleted */
  89.    /* keep track of these events for later */
  90.    pendingEvent = messagein;
  91.    pendingReply = reply;
  92.    /* we'll wait for the user to do something that triggers a response */
  93.    if (noErr != (err = AESuspendTheCurrentEvent(messagein)))
  94.        return err;
  95.    return noErr;
  96. }
  97.  
  98. pascal OSErr MyEventCompletion(AppleEvent *messagein,AppleEvent *reply,
  99.                                long refcon)
  100. {
  101.      AEPutParamPtr(reply,keyAEResult,typeChar,(Ptr)myStuff,strlen(myStuff));
  102.      return noErr;
  103. }
  104.  
  105. void CodeCalledWhenReadyToFinish(void)
  106. {
  107.    err = AEResumeTheCurrentEvent(pendingEvent,pendingReply,MyEventCompletion,
  108.                                  0);
  109. }
  110.  
  111.     When the event handler is called, AESuspendTheCurrentEvent returns noErr,
  112. and the event is apparently suspended correctly; at least, the caller never
  113. gets a reply, even though the event handler returns.  The problem is that the
  114. event and reply records seem to be getting disposed immediately; pendingEvent
  115. and pendingReply are pointing at garbage when CodeCalledWhenReadyToFinish is
  116. called, and as a result AEResumeTheCurrentEvent fails miserably.
  117.     Any help you can give is gratefully appreciated...
  118.  
  119.  
  120. --
  121. \o\   If you're interested in books/stories with transformation    \o\
  122.  \o\themes, or in furry/anthropomorphic art, email me, or anonymous-\o\
  123.   \o\ftp to ftp.halcyon.com and check the /local/phaedrus directory. \o\
  124.    \o\ Web users:  Now try http://www.halcyon.com/phaedrus/Menu.html  \o\
  125.  
  126. +++++++++++++++++++++++++++
  127.  
  128. >From hanrek@cts.com (Mark Hanrek)
  129. Date: 22 Aug 1994 04:54:34 GMT
  130. Organization: The Information Workshop
  131.  
  132. In article <33394p$cs5@news.halcyon.com>, phaedrus@chinook.halcyon.com
  133. (Mark Phaedrus) wrote:
  134.  
  135. >      Could someone please post some brief sample code showing the correct use
  136. > of AESuspendTheCurrentEvent and AEResumeTheCurrentEvent?
  137. >      Basically, this is what I'm doing right now:
  138.  
  139. There is some example source code called "SuspendAppleEvent" that will
  140. hopefully help.
  141.  
  142. You will find under "Inter-Application Communication" within the Snippets
  143. collection.  It is on the Developer CD and hopefully available at
  144. ftp://ftp.apple.com/ as well.
  145.  
  146. Mark Hanrek
  147.  
  148. +++++++++++++++++++++++++++
  149.  
  150. >From bb@lightside.com (Bob Bradley)
  151. Date: Sun, 21 Aug 1994 04:13:05 -0800
  152. Organization: SS Software Inc.
  153.  
  154. I don't have a question of how to use AESuspendTheCurrentEvent but,
  155. whether I should use it. When I receive an OpenDoc event, I put up a
  156. dialog and the files attached to the OpenDoc event do not get processed
  157. until the user hits ok in the dialog (or cancel which would not process
  158. the documents at all). Should I suspend the OpenDoc event and resume when
  159. (or if) the user chooses ok in the dialog or should I just let the
  160. AppleEvent return and process the documents when the user wants?
  161.  
  162. IM Interapp Comm says the AppleEvent Manager expects the event to have
  163. been processed when the handler returns which it wouldn't have been in my
  164. case and I'm not sure if I should call AESuspendTheCurrentEvent (and
  165. resume it later). It works fine though.
  166.  
  167. +++++++++++++++++++++++++++
  168.  
  169. >From paul@architecture.mcgill.ca (Paul Lalonde)
  170. Date: Tue, 23 Aug 1994 02:28:45 GMT
  171. Organization: McGill University School of Architecture
  172.  
  173. In article <33394p$cs5@news.halcyon.com>, phaedrus@chinook.halcyon.com
  174. (Mark Phaedrus) wrote:
  175.  
  176. >      Could someone please post some brief sample code showing the correct use
  177. > of AESuspendTheCurrentEvent and AEResumeTheCurrentEvent?
  178. >      Basically, this is what I'm doing right now:
  179.  
  180. > [ stuff deleted ]
  181.  
  182. You have to save the actual event and reply records, not just pointers to 
  183. them.  So a revised version of the snippet you posted would look like this:
  184.  
  185. AppleEvent pendingEvent,pendingReply;
  186.  
  187. pascal OSErr MyEventHandler(AppleEvent *messagein, AppleEvent *reply,
  188.                             long refcon)
  189. {
  190.    /* stuff deleted */
  191.    pendingEvent = *messagein;
  192.    pendingReply = *reply;
  193.    /* more stuff deleted */
  194.    return noErr;
  195. }
  196.  
  197. void CodeCalledWhenReadyToFinish(void)
  198. {
  199.    err = AEResumeTheCurrentEvent(&pendingEvent,&pendingReply,
  200.                                  MyEventCompletion,0);
  201. }
  202.  
  203.  
  204. Hope this helps,
  205.  
  206. Paul Lalonde
  207. paul@architecture.mcgill.ca
  208.  
  209. ---------------------------
  210.  
  211. >From dchakrav@netserv.unmc.edu (Dhruba Chakravarti)
  212. Subject: Learning Macintosh Programming
  213. Date: 19 Aug 1994 11:23:44 -0500
  214. Organization: University of Nebraska Medical Center, Omaha, NE, USA
  215.  
  216. I do not know anything about programming, which should be obvious
  217. from the header.  I have a Macintosh computer and would like to
  218. learn programming for Macintosh.  Please advise me.
  219.  
  220. Regards,
  221.  
  222. Dhruba.
  223.  
  224.  
  225. +++++++++++++++++++++++++++
  226.  
  227. >From mathews@ns9000.furman.edu (Owen Mathews)
  228. Date: 19 Aug 1994 18:50:13 GMT
  229. Organization: furman university computing center
  230.  
  231. Dhruba Chakravarti (dchakrav@netserv.unmc.edu) wrote:
  232. : I do not know anything about programming, which should be obvious
  233. : from the header.  I have a Macintosh computer and would like to
  234. : learn programming for Macintosh.  Please advise me.
  235.  
  236. : Regards,
  237.  
  238. : Dhruba.
  239.  
  240. If you're programming in Pascal, pick up the
  241.  
  242.     -Macintosh Pascal Programming Primer
  243.      by Dave Mark and ??? Reed (something like that)
  244.     **good introductory Mac book; teaches all about the Toolbox
  245.     and Mac programming fundamentals; comes with several well-thought-out
  246.     example programs to get you started
  247.  
  248. If you're using C, then try
  249.  
  250.     -Macintosh C Programming Primer
  251.      same fellow(s?)
  252.     **I haven't see this one, but I assume it's the same idea.
  253.  
  254. If you're really ambitious, take a look at
  255.  
  256.     -Learn C++ on the Macintosh
  257.      guess who?  (I'm a real admirer of this guy)
  258.     **Also probably the same basic idea.
  259.  
  260. No matter which language you use, you'll eventually want to invest in
  261.  
  262.     -Inside Macintosh
  263.      Apple Computer
  264.     **This set of reference books is the ultimate authority on all
  265.     aspects of Mac programming.  It comes in two flavors:  Old Inside Mac
  266.     (IM) and New IM (NIM).  Old IM comes in 6 volumes that are organized
  267.     chronologically.  This unfortunately means that certain related material
  268.     can be spread out over multiple volumes, forcing you to spend extra
  269.     time to find the right volume.  NIM groups material logically by
  270.     subject.  Each volume covers some clearly-defined area of the Mac API.
  271.     Of course, NIM's disadvantage is that when Apple releases new stuff,
  272.     you can't go and pick up the next chronological volume -- instead,
  273.     you'll probably have to go and buy half a dozen updates to the subject
  274.     volumes.
  275.     But I'm rambling.
  276.  
  277. Hey, don't let all that talk daunt you.  With any of the first three books,
  278. you can get started programming quickly and produce your first (albeit ultra-
  279. simple) Mac application within an hour or two.
  280.  
  281. Hope this helps!
  282.  
  283. --
  284.        Owen Mathews    mathews@furman.edu
  285.        <><><><><><><><><><><><><><><><><><><><>
  286.        Furman University, Computer Science Dept
  287.  
  288. +++++++++++++++++++++++++++
  289.  
  290. >From dchakrav@netserv.unmc.edu (Dhruba Chakravarti)
  291. Date: 19 Aug 1994 17:17:42 -0500
  292. Organization: University of Nebraska Medical Center, Omaha, NE, USA
  293.  
  294. Owen Mathews (mathews@ns9000.furman.edu) wrote:
  295. : Dhruba Chakravarti (dchakrav@netserv.unmc.edu) wrote:
  296. : : I do not know anything about programming, which should be obvious
  297. : : from the header.  I have a Macintosh computer and would like to
  298. : : learn programming for Macintosh.  Please advise me.
  299.  
  300. : : Regards,
  301.  
  302. : : Dhruba.
  303.  
  304. : If you're programming in Pascal, pick up the
  305.  
  306. :     -Macintosh Pascal Programming Primer
  307. :      by Dave Mark and ??? Reed (something like that)
  308. :     **good introductory Mac book; teaches all about the Toolbox
  309. :     and Mac programming fundamentals; comes with several well-thought-out
  310. :     example programs to get you started
  311.  
  312. : If you're using C, then try
  313.  
  314. :     -Macintosh C Programming Primer
  315. :      same fellow(s?)
  316. :     **I haven't see this one, but I assume it's the same idea.
  317.  
  318. : If you're really ambitious, take a look at
  319.  
  320. :     -Learn C++ on the Macintosh
  321. :      guess who?  (I'm a real admirer of this guy)
  322. :     **Also probably the same basic idea.
  323.  
  324. : No matter which language you use, you'll eventually want to invest in
  325.  
  326. :     -Inside Macintosh
  327. :      Apple Computer
  328. :     **This set of reference books is the ultimate authority on all
  329. :     aspects of Mac programming.  It comes in two flavors:  Old Inside Mac
  330. :     (IM) and New IM (NIM).  Old IM comes in 6 volumes that are organized
  331. :     chronologically.  This unfortunately means that certain related material
  332. :     can be spread out over multiple volumes, forcing you to spend extra
  333. :     time to find the right volume.  NIM groups material logically by
  334. :     subject.  Each volume covers some clearly-defined area of the Mac API.
  335. :     Of course, NIM's disadvantage is that when Apple releases new stuff,
  336. :     you can't go and pick up the next chronological volume -- instead,
  337. :     you'll probably have to go and buy half a dozen updates to the subject
  338. :     volumes.
  339. :     But I'm rambling.
  340.  
  341. : Hey, don't let all that talk daunt you.  With any of the first three books,
  342. : you can get started programming quickly and produce your first (albeit ultra-
  343. : simple) Mac application within an hour or two.
  344.  
  345. : Hope this helps!
  346.  
  347. : --
  348. :        Owen Mathews    mathews@furman.edu
  349. :        <><><><><><><><><><><><><><><><><><><><>
  350. :        Furman University, Computer Science Dept
  351.  
  352. Thank you very much!  I'll get these books and start reading.
  353.  
  354. Regards,
  355.  
  356. Dhruba.
  357.  
  358.  
  359. +++++++++++++++++++++++++++
  360.  
  361. >From Chris Kueny <yun@fusion.ph.utexas.edu>
  362. Date: 19 Aug 1994 23:37:21 GMT
  363. Organization: The University of Texas at Austin, Austin, Texas
  364.  
  365. In article <332mag$2jq@netserv.unmc.edu> Dhruba Chakravarti,
  366. dchakrav@netserv.unmc.edu writes:
  367.  
  368. >I do not know anything about programming, which should be obvious
  369. >from the header.  I have a Macintosh computer and would like to
  370. >learn programming for Macintosh.  Please advise me.
  371.  
  372. The C Programming Primer by Dave Mark assumes that you
  373. know something about the C programming language (and I 
  374. assume that the Pascal Programming Primer assumes knowledge
  375. of Pascal.) Another good book at this level is Dan Parks Sydow's
  376. "Macintosh Programming Techniques".
  377.  
  378. But if you have no programming experience at all, then a good
  379. one to start with is "Learn C on the Macintosh" by Dave Mark.
  380. This has a stripped down version of Symantec's Think C compiler
  381. that can be used to run the projects in the book. It will give you
  382. an introduction to the C language, but won't tell you everything.
  383. It has a good explanation of programming concepts for people
  384. who have never done such things before. As mentioned above,
  385. Dave also wrote "Learn C++ on the Macintosh".
  386.  
  387. A classic reference for the whole C language is "The C Programming
  388. Language" by Kernighan & Ritchie.
  389.  
  390. I don't have much knowledge of Pascal. I think I heard someone
  391. say that it is easier for a beginner to learn Pascal than to learn C.
  392.  
  393. Eventually you will have to buy a compiler. C and Pascal compilers
  394. are available at good discounts for university and college students
  395. and staff (maybe younger students too?) Used ones are also
  396. sometimes advertised in this newsgroup.
  397.  
  398. +++++++++++++++++++++++++++
  399.  
  400. >From millsp@govonca.gov.on.ca (Phil Mills)
  401. Date: Sat, 20 Aug 1994 13:05:05 GMT
  402. Organization: Government of Ontario
  403.  
  404. In <332mag$2jq@netserv.unmc.edu> dchakrav@netserv.unmc.edu (Dhruba Chakravarti) writes:
  405.  
  406. >I do not know anything about programming, which should be obvious
  407. >from the header.  I have a Macintosh computer and would like to
  408. >learn programming for Macintosh.  Please advise me.
  409.  
  410. 1) Decide why you want to program and what kind of program you would
  411. like to create.  The best choice in tools and information sources will
  412. change depending on that decision.
  413.  
  414. (Without an answer to #1, there *is* no item #2.  :-)  )
  415.  
  416. +++++++++++++++++++++++++++
  417.  
  418. >From kenlong@netcom.com (Ken Long)
  419. Date: Sat, 20 Aug 1994 16:52:14 GMT
  420. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  421.  
  422. Learn C on the Macintosh is NOT a good book for someone who has no 
  423. programming or Mac programming experience.  It contains LITTLE about what 
  424. new Mac programmers are interested in.
  425.  
  426. Think THINK C!, by Dan Parks Sydow is THE book to start with.  It teaches 
  427. new Mac programmers about aspects of Mac programming they WANT to know about.
  428.  
  429. -Ken-
  430.  
  431. +++++++++++++++++++++++++++
  432.  
  433. >From silicon@Simplex.NL (Silicon Island Software)
  434. Date: 21 Aug 1994 08:28:13 GMT
  435. Organization: Simplex Networking Amsterdam, The Netherlands.
  436.  
  437. Dhruba Chakravarti (dchakrav@netserv.unmc.edu) wrote:
  438. : I do not know anything about programming, which should be obvious
  439. : from the header.  I have a Macintosh computer and would like to
  440. : learn programming for Macintosh.  Please advise me.
  441.  
  442.  
  443. Why Visual EzC is good for learning Macintosh programming.
  444.  
  445. When you program in EzC, the Layouts of the applications with
  446. their interface elements are all created graphically in a MacDraw
  447. like Layout Editor. The process has little if anything to do with
  448. programming. 
  449.  
  450. The Menus of the application are also created in a graphic editor
  451. by simply adding menus and menu items in a list.
  452.  
  453. The EzC program code is a C-like code, with all the basic syntax
  454. and functionality the same as in normal C.
  455.  
  456. There is admittedly nothing new about creating layouts and
  457. menus graphically. - The available 4GL languages all do that, each
  458. in their own way. What is new though is, that EzC has a very
  459. powerful and well known programming language, and the EzC
  460. code can be pre-compiled into C, simply by selecting Precompile
  461. from the menu. The resulting C code can then be compiled with
  462. for instance MPW and the project can be made into a standalone
  463. application. 
  464.  
  465. Programs written in EzC are just as fast and small in size as
  466. programs written from scratch in C or Pascal.
  467.  
  468. To give the curious an example of how a simple program looks
  469. like in EzC we can take as an example a window with a text field
  470. and listbox and an accept button. When the user keys in a name
  471. in the text field and clicks the accept button the name appears in
  472. the listbox.
  473.  
  474. Solving the problem:
  475.  
  476. 1) The interface elements are drawn in the layout editor.
  477.  
  478. 2) A menu for the application is created in the menu editor.
  479.  
  480. 3) The code to do the processing is as follows:
  481.  
  482.  
  483. inherit "Std:System:Window";
  484.  
  485. string *arr;
  486.  
  487. void _OpenView()  {
  488.     arr=({});
  489.     LoadMenubar("Main");
  490. }
  491.  
  492. void _Click(string name)  {
  493.     if(name=="ok")  {
  494.        arr+=({Get("field","text")});
  495.        Set("listbox","array",arr);
  496.        Set("field","text","");
  497.     }
  498. }
  499.  
  500. The layout with the program code constitutes an object in EzC.
  501.  
  502. The explanation of the code is simple. 
  503.  
  504. In the first line we inherit the standard behaviour of a window.
  505.  
  506. EzC is event driven, and opening a window generates an event.
  507. To every EzC event corresponds a function. _OpenView() is one
  508. such function. If defined in an object, it is invoked when the
  509. event occurs. _Click() is another event handler function. It is
  510. invoked on clicking the mouse.
  511.  
  512. The interface elements have names. The text field has the been
  513. given the name 'field' and the listbox element is called 'listbox'
  514. and the accept button's name is 'ok'.
  515.  
  516. The Set() function sets a property of an interface element with
  517. given parameters, and the Get() function fetches the value of a
  518. property of an interface element.
  519.  
  520. The code is only a few lines, and this is a functioning application,
  521. and can be made standalone.
  522.  
  523. It is our opinion that EzC is a suitable language for learning
  524. Macintosh programming. - Try for instance for comparison to
  525. teach the beginner to create the above example application with
  526. Think C using the TCL library. 
  527.  
  528. The programmer does not need to study any textbook on
  529. Macintosh programming to be able create simple applications
  530. like the above application in EzC, nor does he need to have read a
  531. word of the voluminous Inside Macintosh. He does however need
  532. to know something about C programming in general and to
  533. understand the events of EzC and to have at hand a reference
  534. over the main kernel and Library functions in EzC.
  535.  
  536. As the programmer becomes more proficient Visual EzC will
  537. grow with him, since it is so strongly related to C. The
  538. programmer also gradually becomes interested in acquiring
  539. knowledge of the Macintosh Toolbox as he needs to solve more
  540. advanced problems. 
  541.  
  542. The main advantage of learning Macintosh programming by
  543. using EzC is that the beginner can actually create useful
  544. standalone applications that he can be proud of within hours.
  545.  
  546. Another important advantage is, that the beginner will quickly
  547. learn to appreciate Object Oriented programming as object
  548. orientation is so closely woven into the EzC language.
  549.  
  550. A third advantage is, that the beginner will learn the basics of a
  551. generally known and accepted language, C.
  552.  
  553. Last but not least. One should not forget that EzC also has a built
  554. in relational database engine, so when the beginner wants to
  555. create a database program, the tools are right there.
  556.  
  557. A demo of Visual EzC can be found on mac.archive.umich.edu in
  558. the /mac/misc/demo/visualezc1.0b4-demo.hqx and on any of the
  559. info-mac mirror sites.
  560.  
  561. Silicon Island Software
  562. Email: silicon@simplex.nl
  563.  
  564. +++++++++++++++++++++++++++
  565.  
  566. >From D.Birnie@Regy.Canterbury.ac.nz (Denis A. Birnie)
  567. Date: Mon, 22 Aug 1994 11:17:06 +1200
  568. Organization: ISS
  569.  
  570. > I do not know anything about programming, which should be obvious
  571. > from the header.  I have a Macintosh computer and would like to
  572. > learn programming for Macintosh.  Please advise me.
  573. Dhruba,
  574.  
  575. The current way to go language-wise is C (or C++).
  576.  
  577. The book which I'd recommend (and which uses C) is
  578. Macintosh_Programming_Secrets (2nd edition) by Scott Knaster & Keith
  579. Rollin.  Shows you all sorts of interesting and neat things as well as
  580. giving you a skeleton application to work from. A VERY good book.
  581.  
  582. I'd also suggest Think Reference if you get serious and have a screen
  583. larger than the original 9"ers.
  584.  
  585. Denis Birnie
  586. --
  587. COBOhoLic!
  588.  
  589. +++++++++++++++++++++++++++
  590.  
  591. >From hanrek@cts.com (Mark Hanrek)
  592. Date: 22 Aug 1994 05:04:10 GMT
  593. Organization: The Information Workshop
  594.  
  595. In article <332mag$2jq@netserv.unmc.edu>, dchakrav@netserv.unmc.edu
  596. (Dhruba Chakravarti) wrote:
  597.  
  598. > I do not know anything about programming, which should be obvious
  599. > from the header.  I have a Macintosh computer and would like to
  600. > learn programming for Macintosh.  Please advise me.
  601.  
  602. Dhruba,
  603.  
  604. Besides all the excellent suggestions and advice thus far, consider doing
  605. the following...
  606.  
  607. Decide on a language, and get the compiler for it.
  608.  
  609. Then, download all the example source code you can find in that language
  610. and compile it.
  611.  
  612. If something is too hard to get going, move on to another.
  613.  
  614. When you get something to compile successfully, and it runs, then maybe
  615. you can think of an easy way to tweak it or make it do something
  616. different.
  617.  
  618. - --
  619.  
  620. This method is an excellent method, because you will quickly become
  621. familiar with your development environment, and the language, and the
  622. Macintosh Toolbox (the three things you'll be learning at the same time).
  623.  
  624. But what is great about this approach is that you will be getting a sense
  625. of gratification as you go along, and you will always be modifying rather
  626. than creating -- these are two very important things in the beginning, and
  627. two of the major reasons many people give up.
  628.  
  629. There's no need to overwhelm yourself.  Always have a language reference handy.
  630.  
  631. So compile freely downloadable program right and left, have fun, make some
  632. changes that make goofy things happen, and next thing you know, you will
  633. have subliminally learned a ton of essential things without even noticing
  634. it.
  635.  
  636.  
  637. Good luck to you.
  638.  
  639. Mark Hanrek
  640. The Information Workshop
  641.  
  642. +++++++++++++++++++++++++++
  643.  
  644. >From garyg@oak.circa.ufl.edu
  645. Date: 22 Aug 1994 12:46:50 GMT
  646. Organization: Center for Instructional and Research Computing Activities
  647.  
  648. Dhruba,
  649. In addition to the other advice offered, I'd suggest that you also get:
  650. Macintosh Programming Techniques: A Foundation for All Macintosh
  651. Programmers by Dan Parks Sydow (1994; M&T Books). It includes a
  652. diskette with interactive tutorials, sample code with small built
  653. applications (in case you don't have a C compiler yet), and lots
  654. of highly useful info. Another great job by DPSydow!!
  655. hth, Gary
  656.  
  657. +++++++++++++++++++++++++++
  658.  
  659. >From dchakrav@netserv.unmc.edu (Dhruba Chakravarti)
  660. Date: 23 Aug 1994 11:27:23 -0500
  661. Organization: University of Nebraska Medical Center, Omaha, NE, USA
  662.  
  663. garyg@oak.circa.ufl.edu wrote:
  664. : Dhruba,
  665. : In addition to the other advice offered, I'd suggest that you also get:
  666. : Macintosh Programming Techniques: A Foundation for All Macintosh
  667. : Programmers by Dan Parks Sydow (1994; M&T Books). It includes a
  668. : diskette with interactive tutorials, sample code with small built
  669. : applications (in case you don't have a C compiler yet), and lots
  670. : of highly useful info. Another great job by DPSydow!!
  671. : hth, Gary
  672.  
  673.  
  674. Thank you all very much!
  675.  
  676. Regards,
  677.  
  678. Dhruba.
  679.  
  680.  
  681. ---------------------------
  682.  
  683. >From will@cs.su.oz.au (William Uther)
  684. Subject: Should function order be conserved? (CW vs. GestaltValue)
  685. Date: 20 Aug 1994 16:19:54 +1000
  686. Organization: Basser Dept of Computer Sciece, Uni of Sydney, Australia
  687.  
  688. Hi,
  689.   I am using CodeWarrior to write a small application.  I want this application
  690. to publish a handle.  I had an earlier version that did this using the
  691. GestaltValue library.  This library does not work with CW 3.5.
  692.   I traced it, and found that the reason it didn't work was because it relied
  693. upon the ordering of functions to find the size of a block of memory to
  694. allocate.  (it subtracted the address of the start of one function from the
  695. address of the start of another function to get the size of the first function
  696. and hence the amount of memory it had to allocate to copy it to the system heap)
  697.   CW 3.5 does not respect this ordering when it converts Apple's '.o' file into
  698. a library.
  699.  
  700.   Is this a problem for MetroWerks (CW SHOULD respect the function ordering),
  701. or is this a problem for Apple (DTS shouldn't write libraries that rely on
  702. function ordering)??  At the moment it just seems to be a problem for me....
  703.  
  704.   Metrowerks tech support were very good at verifying the problem,
  705. unfortunately, since they shifted the blame to Apple they haven't done much.
  706. (BTW the library works in THINK C 5.0, 6.0 and 7.0 - I assume it works in MPW
  707. as it's an MPW object file)
  708.  
  709. Should I be talking to Apple DTS or Metrowerks tech support?
  710.  
  711. \x/ill        :-}
  712.  
  713. will@cs.su.oz.au
  714.  
  715.  
  716. +++++++++++++++++++++++++++
  717.  
  718. >From cokenias@netcom.com (Damon Cokenias)
  719. Date: Sun, 21 Aug 1994 21:16:36 GMT
  720. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  721.  
  722. - ---
  723.   I traced it, and found that the reason it didn't work was because it relied
  724. upon the ordering of functions to find the size of a block of memory to
  725. allocate.  (it subtracted the address of the start of one function from the
  726. address of the start of another function to get the size of the first function
  727. and hence the amount of memory it had to allocate to copy it to the system heap)
  728.   CW 3.5 does not respect this ordering when it converts Apple's '.o' file into
  729. a library.
  730. - ---
  731.  
  732. Every time I'm stepping through somebody's INIT trying to find out if it is
  733. responsible for crashing my machine, I invariably find this sort of programming.
  734. It is sick and immoral.  It is absolutely none of the programmer's business
  735. where or how their code gets compiled.
  736.  
  737. There are two solutions to the Patch/Gestalt Selector/Shutdown Handler install
  738. problem.  (Actually, there are more than two, but these are my favorites).
  739.  
  740. ** A **
  741.  
  742. 1) Call Get1IndResource (INIT, 1) to find yourself (or other appropriate
  743.    GetResource call)
  744. 2) Detach yourself, install all patches, etc.
  745.  
  746. ** B **
  747.  
  748. 1) Load a code resource containing your patch routines, detach and lock
  749. 2) Install patches.
  750.  
  751. I typically use A for quickie jobs that I just want to crank out in a moment
  752. or two.  It has the disadvantage of leaving the loader code behind.  Some of
  753. the advantages are: Only one binary to build (nice for THINK and CW users),
  754. the patches have access to the same A4 globals the loader code did.  This
  755. can be usefull.
  756.  
  757. I choose B for lean and mean INITs that I release to the public.  In order to
  758. initialize the globals for the code resource with values from the loader, I
  759. sometimes do the following:
  760.  
  761. 1) Inside the code resource I have an A4 global called 'intialized'.  It's
  762. initial value is zero.
  763. 2) BEFORE installing the patches, I call my code resource, passing a pointer
  764. to a structure containing initial values.  This can only be done for patches
  765. that accept parameters, obviously.
  766. 3) If 'initialized' is still false, the code resource knows the passed parameter
  767. contains special data and uses that data.  'initialized' is then set to true.
  768. 4) From this point on, all calls to the code resource are treated as one would
  769. expect them to.
  770.  
  771. Often, this is the most convenient way to tell a patch where to jump to after
  772. completion.  It is 100% portable on all platforms that allow a standalone
  773. code resource to have globals.
  774.  
  775. DO NOT:
  776.   * assume code gets put anywhere.  If you use Codewarrior, the frequent
  777.     updates and changes should cure you of that fast enough.
  778.  
  779. (What if CW noticed that a particular routine could be called with a short
  780. branch instead of a long one?  It might re-arrange certain funtions to make
  781. them closer to their callers.)
  782.  
  783. -Damon Cokenias
  784. .
  785.  
  786. -- 
  787. Damon Cokenias
  788. cokenias@netcom.COM
  789.  
  790. +++++++++++++++++++++++++++
  791.  
  792. >From h+@nada.kth.se (Jon W{tte)
  793. Date: Mon, 22 Aug 1994 14:54:28 +0200
  794. Organization: Royal Institute of Something or other
  795.  
  796. In article <cokeniasCuwLro.J8@netcom.com>,
  797. cokenias@netcom.com (Damon Cokenias) wrote:
  798.  
  799. >It is sick and immoral.  It is absolutely none of the programmer's business
  800. >where or how their code gets compiled.
  801.  
  802. Yes; it definately is. For a well-defined runtime architecture, 
  803. like the Mac 68k one, you're allowed and sometimes forced to do 
  804. this.
  805.  
  806. >There are two solutions to the Patch/Gestalt Selector/Shutdown Handler install
  807. >problem.  (Actually, there are more than two, but these are my favorites).
  808.  
  809. >1) Call Get1IndResource (INIT, 1) to find yourself (or other appropriate
  810. >   GetResource call)
  811. >2) Detach yourself, install all patches, etc.
  812.  
  813. >1) Load a code resource containing your patch routines, detach and lock
  814. >2) Install patches.
  815.  
  816. Strangely enough, I use none of these. Instead, I get the 
  817. address of the first instruction (you can use A0 as well, but 
  818. it's slightly less safe - someone COULD have jumped to you 
  819. through another register) Then I call RecoverHandle and 
  820. DetachResource, and use PC-relative addressing to install my 
  821. patches (and store data) This requires your INIT to be marked 
  822. pre-loaded, system heap and locked.
  823.  
  824. >1) Inside the code resource I have an A4 global called 'intialized'.  It's
  825.  
  826. A4 globals are much more horrible than comparing addresses of 
  827. functions. A4 globals require you to always enter through 
  828. main(), unless you do extra inline assembly, which kind of 
  829. rules out the case where the loader and the patch are in the 
  830. same code resource.
  831.  
  832. PS: you can get by the loader-left problem by putting the 
  833. loader code last, branch to it from the top and then call 
  834. SetHandleSize.
  835.  
  836.  
  837.  
  838.  
  839. --
  840.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  841.  "Don't Deal with a Dragon."
  842.  
  843.  
  844. +++++++++++++++++++++++++++
  845.  
  846. >From Jaeger@fquest.com (Brian Stern)
  847. Date: 22 Aug 1994 17:00:11 GMT
  848. Organization: The University of Texas at Austin, Austin, Texas
  849.  
  850. In article <9668AA7E6CA4.FDF19@klkmac008.nada.kth.se>, h+@nada.kth.se (Jon
  851. W{tte) wrote:
  852.  
  853. > A4 globals are much more horrible than comparing addresses of 
  854. > functions. A4 globals require you to always enter through 
  855. > main(), unless you do extra inline assembly, which kind of 
  856. > rules out the case where the loader and the patch are in the 
  857. > same code resource.
  858.  
  859. This isn't true.  With A4 globals you must enter through main *once*.  You
  860. save the address of A4 in main.  After that you can enter through any
  861. entry point you like.  Each additional entry point first retrieves A4 and
  862. can then access its globals.  It restores A4 before exiting.  There is no
  863. reason you can't have the loader and the patch in the same code resource.
  864.  
  865. > PS: you can get by the loader-left problem by putting the 
  866. > loader code last, branch to it from the top and then call 
  867. > SetHandleSize.
  868.  
  869. I agree that this is a neat trick.  Unfortunately you can't use it when
  870. using A4 global addressing.  The globals end up at the end of the code
  871. resource.  Oh well.
  872.  
  873. > --
  874. >   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  875. >  "Don't Deal with a Dragon."
  876.  
  877. -- 
  878. Brian  Stern  :-{)}
  879. Jaeger@fquest.com
  880.  
  881. +++++++++++++++++++++++++++
  882.  
  883. >From h+@nada.kth.se (Jon W{tte)
  884. Date: Tue, 23 Aug 1994 08:54:14 +0200
  885. Organization: Royal Institute of Something or other
  886.  
  887. In article <Jaeger-2208941202170001@slip-2-18.ots.utexas.edu>,
  888. Jaeger@fquest.com (Brian Stern) wrote:
  889.  
  890. >This isn't true.  With A4 globals you must enter through main *once*.  You
  891. >save the address of A4 in main.  After that you can enter through any
  892. >entry point you like.  Each additional entry point first retrieves A4 and
  893. >can then access its globals.  It restores A4 before exiting.  There is no
  894. >reason you can't have the loader and the patch in the same code resource.
  895.  
  896. How do you retrieve the stored value of A4 without extra inline 
  897. assembly? Or does Symantec provide the extra assembler to do it 
  898. for you from anywhere now ?(it was a long time since I last used 
  899. it...)
  900.  
  901.  
  902. Cheers,
  903.  
  904.                 / h+
  905.  
  906.  
  907. --
  908.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  909.   "Psychotherapist" - "Phycho-The-Rapist"
  910.    Pure coincidence? You decide!
  911.  
  912.  
  913. +++++++++++++++++++++++++++
  914.  
  915. >From Jaeger@fquest.com (Brian Stern)
  916. Date: 23 Aug 1994 16:19:46 GMT
  917. Organization: The University of Texas at Austin, Austin, Texas
  918.  
  919. In article <9668AA7F69B6.206994@klkmac012.nada.kth.se>, h+@nada.kth.se
  920. (Jon W{tte) wrote:
  921.  
  922. > How do you retrieve the stored value of A4 without extra inline 
  923. > assembly? Or does Symantec provide the extra assembler to do it 
  924. > for you from anywhere now ?(it was a long time since I last used 
  925. > it...)
  926. > Cheers,
  927. >                                 / h+
  928. > --
  929. >   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  930. >   "Psychotherapist" - "Phycho-The-Rapist"
  931. >    Pure coincidence? You decide!
  932.  
  933. Yes, the inline code is provided in a header file that must be included in
  934. each source file that needs to do A4 addressing.  The header contains
  935. several inline assembler functions for saving and restoring A4.  From the
  936. standpoint of the programmer there is no assembly required.
  937.  
  938. -- 
  939. Brian  Stern  :-{)}
  940. Jaeger@fquest.com
  941.  
  942. +++++++++++++++++++++++++++
  943.  
  944. >From phils@bedford.symantec.com (Phil Shapiro)
  945. Date: Tue, 23 Aug 1994 19:31:26 -0400
  946. Organization: Symantec Corp.
  947.  
  948. In article <9668AA7F69B6.206994@klkmac012.nada.kth.se>, h+@nada.kth.se
  949. (Jon W{tte) wrote:
  950.  
  951. | In article <Jaeger-2208941202170001@slip-2-18.ots.utexas.edu>,
  952. | Jaeger@fquest.com (Brian Stern) wrote:
  953. | >This isn't true.  With A4 globals you must enter through main *once*.  You
  954. | >save the address of A4 in main.  After that you can enter through any
  955. | >entry point you like.  Each additional entry point first retrieves A4 and
  956. | >can then access its globals.  It restores A4 before exiting.  There is no
  957. | >reason you can't have the loader and the patch in the same code resource.
  958. | How do you retrieve the stored value of A4 without extra inline 
  959. | assembly? Or does Symantec provide the extra assembler to do it 
  960. | for you from anywhere now ?(it was a long time since I last used 
  961. | it...)
  962.  
  963. Each source file gets its own copy of A4. As long as you're in the same
  964. source file that you called RememberA0() in (or RememberA4(), if A4 was
  965. valid already), you can call SetUpA4() at any entry point. This is because
  966. A4 is stored inside code in a static function; each file that uses the
  967. function gets a different copy. This has been true for quite awhile, I'm
  968. pretty sure that LSC 4.0 worked this way.
  969.  
  970. If you build with a custom header, you don't even need to enter main() at
  971. all. But you better set up A4 before you access any globals or
  972. cross-segment routines.
  973.  
  974.    -phil
  975.  
  976. ---------------------------
  977.  
  978. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  979. Subject: Sound Manager headaches (again)
  980. Date: Sun, 21 Aug 1994 14:42:43 -0400
  981. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  982.  
  983. When we last left our hero, he had just figured out how to play a sound
  984. at a given frequency (by sending soundCmd and freqDurationCmd to a
  985. sampledSynth channel.) (I sent a code snippet of doing this to
  986. alt.sources.mac, if you care. ./vol-08/sampledsnd.cpt.hqx)
  987.  
  988. Well, there was a reason I wanted to do that. See, I want to get music
  989. out, and I thought that the way to do that was record snd resources of
  990. each instrument, and then use that technique to play notes. Allocate
  991. several channels, you can get multiple notes at once.
  992.  
  993. ...Riiiiight.
  994.  
  995. First problem: they don't start off in synch. I use the algorithm given
  996. in the PlayTwoSoundsSynched in the SM3.0 tech note:  (warning:
  997. pseudocode, not real code, ahead)
  998.     SndDoImmediate(chan1, syncCmd{3, kID})
  999.     SndDoCommand(chan1, restCmd{500});
  1000.     SndDoCommand(chan1, freqDurationCmd{500, MIDDLE_C});
  1001.     SndDoImmediate(chan2, syncCmd{3, kID})
  1002.     SndDoCommand(chan2, restCmd{500});
  1003.     SndDoCommand(chan2, freqDurationCmd{500, MIDDLE_G});
  1004.     SndDoImmediate(chan1, syncCmd{1, kID})
  1005. I expect this to pause a quarter-second, then play a nice chord. Nope.
  1006. One channel (the first one, I believe) starts slightly -- but audibly --
  1007. first. (They do finish together, though.) This occurs both with and
  1008. without SM3.0. 
  1009. (My guess: the SM has to resample one or both sounds to a different
  1010. frequency, and this takes some time. Sigh.) 
  1011. Oh, yeah -- syncCmd behaves with extreme magic. I still don't know
  1012. exactly what it does. For example, if I change the last line in the
  1013. algorithm above from chan1 to chan2, only one note plays instead of
  1014. both. Huh?
  1015.  
  1016. Second problem: Under SM3.0, if I play a sequence of notes of the same
  1017. duration, they don't come out with the same duration. Again, the
  1018. difference is pretty audible -- as much as a 50% error in short notes.
  1019. Unless I can do something about this, my entire plan is screwed. (Kinda
  1020. cool, huh? The nifty new SM *doesn't support freqDurationCmd* in a
  1021. usable form. I was pleased.) I recall someone else posted about this a
  1022. few weeks ago, and he couldn't get it to work either.
  1023. (My guess: same reason as before. The SM *does* keep the same
  1024. (distorted) time between channels; if I start two parallel synched
  1025. sequences, they stay synched. I guess that's something. It still ruins
  1026. the music, though.)
  1027.  
  1028. My question, pretty much, is "Have I missed anything?" I don't think I
  1029. have. I think I'm going to have to ditch the whole idea of
  1030. freqDurationCmd, and write my *own* sound-resampling-and-playing module
  1031. a la SoundTracker. (Or just use SoundTracker or some other MOD player.
  1032. This is tempting, but I haven't seen a freeware MOD player which
  1033. includes source code, except for an icky-looking one ported straight
  1034. from Unix, with malloc() everywhere. Anyone? Anyone?)
  1035.  
  1036. ObBribery: if you give me a magic answer that fixes my music-playing
  1037. code, I'll release the code as freeware. And I'll throw in the
  1038. simple-but-oh-so-elegant music editor I've spent the past month on.
  1039. (OTOH, if I wind up writing a MOD-style thing, I'll do the same thing.
  1040. Nevertheless.)
  1041.  
  1042. --Z
  1043.  
  1044. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  1045.  
  1046. +++++++++++++++++++++++++++
  1047.  
  1048. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  1049. Date: Mon, 22 Aug 1994 18:22:58 GMT
  1050. Organization: Semicolon Software
  1051.  
  1052. In article <siJu0X_00gpI9iY0YJ@andrew.cmu.edu>, "Andrew C. Plotkin"
  1053. <ap1i+@andrew.cmu.edu> wrote:
  1054.  
  1055. > Second problem: Under SM3.0, if I play a sequence of notes of the same
  1056. > duration, they don't come out with the same duration. Again, the
  1057. > difference is pretty audible -- as much as a 50% error in short notes.
  1058. > Unless I can do something about this, my entire plan is screwed. (Kinda
  1059. > cool, huh? The nifty new SM *doesn't support freqDurationCmd* in a
  1060. > usable form. I was pleased.) I recall someone else posted about this a
  1061. > few weeks ago, and he couldn't get it to work either.
  1062.  
  1063. That was me, I think. I've heard The Word from The Source: a key
  1064. programmer at Apple tells me that SM 3.0 has been optimized for playing
  1065. sampled sounds. The optimizations DE-optimized for playing melodies via
  1066. freqDurationCmd; something about internal buffers having a size that
  1067. causes perceptible delays when they need to be refilled. There is no
  1068. workaround. For my app, I had to give up on freqDurationCmds (under SM
  1069. 3.0) and convert my tunes to single sampled sound resources, which
  1070. increased their size by two orders of magnitude and (to keep them from
  1071. getting even larger) decreased their sound quality. My app now tests the
  1072. version of the Sound Manager; if it is 3.0, you get one and only one
  1073. melody; if less than 3.0, you get a rotating selection out of a list of
  1074. seven melodies. The seven melodies take up about 20K of disk space; the
  1075. one sampled-sound melody takes several times that. Feh.
  1076.  
  1077. FWIW, I can show you code that should solve your synchronization problem.
  1078. Your various melodic parts will start together correctly, and they will
  1079. stay synched. Doesn't help the uneven tempo, though.
  1080.  
  1081. -- Rick Holzgrafe
  1082.    Semicolon Software
  1083.    rmh@taligent.com
  1084.  
  1085. +++++++++++++++++++++++++++
  1086.  
  1087. >From h+@nada.kth.se (Jon W{tte)
  1088. Date: Tue, 23 Aug 1994 09:49:07 +0200
  1089. Organization: Royal Institute of Something or other
  1090.  
  1091. In article <Rick_Holzgrafe-2208941123020001@ricks-cafe.taligent.com>,
  1092. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) wrote:
  1093.  
  1094. >version of the Sound Manager; if it is 3.0, you get one and only one
  1095. >melody; if less than 3.0, you get a rotating selection out of a list of
  1096. >seven melodies. The seven melodies take up about 20K of disk space; the
  1097. >one sampled-sound melody takes several times that. Feh.
  1098.  
  1099. With QuickTime 2.0, however, all you do is store a General MIDI 
  1100. file in your resource fork (3-10k) and there's your melody.
  1101.  
  1102. Luckily, this isn't rec.music.makers.synth, where "General 
  1103. MIDI" is a cuss word.
  1104.  
  1105. Cheers,
  1106.  
  1107.                 / h+
  1108.  
  1109.  
  1110. --
  1111.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  1112.   "Psychotherapist" - "Phycho-The-Rapist"
  1113.    Pure coincidence? You decide!
  1114.  
  1115.  
  1116. +++++++++++++++++++++++++++
  1117.  
  1118. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  1119. Date: Tue, 23 Aug 1994 18:24:34 GMT
  1120. Organization: Semicolon Software
  1121.  
  1122. In article <Rick_Holzgrafe-2208941123020001@ricks-cafe.taligent.com>,
  1123. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) wrote:
  1124.  
  1125. >version of the Sound Manager; if it is 3.0, you get one and only one
  1126. >melody; if less than 3.0, you get a rotating selection out of a list of
  1127. >seven melodies. The seven melodies take up about 20K of disk space; the
  1128. >one sampled-sound melody takes several times that. Feh.
  1129.  
  1130. In article <9668AA7F7693.236F39@klkmac012.nada.kth.se>, h+@nada.kth.se
  1131. (Jon W{tte) wrote:
  1132.  
  1133. > With QuickTime 2.0, however, all you do is store a General MIDI 
  1134. > file in your resource fork (3-10k) and there's your melody.
  1135.  
  1136. Great. So now instead of checking for the version of the Sound Manager and
  1137. having two methods of playing music, I must also check for the presence
  1138. and version of QuickTime, and have THREE methods. Ain't progress
  1139. wonderful?
  1140.  
  1141. Your pardon, please, for my surliness. I'm just tired of carefully coding
  1142. to Apple's published interfaces, and having my sound code break anyway
  1143. every couple of years.
  1144.  
  1145. -- Rick Holzgrafe
  1146.    Semicolon Software
  1147.    rmh@taligent.com
  1148.  
  1149. ---------------------------
  1150.  
  1151. >From mdc14@ciao.cc.columbia.edu (Michael D Coble)
  1152. Subject: Stopping a 'snd ' resource dead
  1153. Date: 23 Aug 1994 03:53:01 GMT
  1154. Organization: Columbia University
  1155.  
  1156.         I am a programming student trying to write a couple of macintosh
  1157. applications.  I recorded some music into a 'snd ' resource and want to
  1158. invoke the music when a user chooses the about this application from the
  1159. apple menu accompanied by a little animation.  The 'snd ' resource is a
  1160. couple of minutes long, so I'd like to be able to allow a user to click
  1161. the close box and stop it in its tracks.  I wonder if one of you
  1162. experienced programmers out there might point me in the direction to
  1163. reach this goal.
  1164.  
  1165.                 Thanks,  Michael Coble, mdc14@columbia.edu
  1166.  
  1167.  
  1168. +++++++++++++++++++++++++++
  1169.  
  1170. >From bb@lightside.com (Bob Bradley)
  1171. Date: Sun, 21 Aug 1994 15:12:37 -0800
  1172. Organization: SS Software Inc.
  1173.  
  1174. In article <33brqt$mi8@apakabar.cc.columbia.edu>,
  1175. mdc14@ciao.cc.columbia.edu (Michael D Coble) wrote:
  1176.  
  1177. >         I am a programming student trying to write a couple of macintosh
  1178. > applications.  I recorded some music into a 'snd ' resource and want to
  1179. > invoke the music when a user chooses the about this application from the
  1180. > apple menu accompanied by a little animation.  The 'snd ' resource is a
  1181. > couple of minutes long, so I'd like to be able to allow a user to click
  1182. > the close box and stop it in its tracks.  I wonder if one of you
  1183. > experienced programmers out there might point me in the direction to
  1184. > reach this goal.
  1185.  
  1186. You can do this by playing the sound async. Something like this:
  1187.  
  1188. SndNewChannel(...)                  // Create a new sound channel
  1189. soundHandle = GetResource(...)      // Get the snd resource
  1190. SndPlay(...)                        // Play the sound setting async to true
  1191. SndDisposeChanne(...)               // Dispose of the sound channel and setting
  1192.                                     // quietNow to true so it stops any sound
  1193.                                     // that is currently playing.
  1194.  
  1195. Hope that helps and doesn't contain too many errors :)
  1196.  
  1197. +++++++++++++++++++++++++++
  1198.  
  1199. >From reed@medicine.wustl.edu (Thomas Reed)
  1200. Date: Tue, 23 Aug 1994 11:08:58 -0500
  1201. Organization: Washington University
  1202.  
  1203. If you ftp to thomas_mac.wustl.edu, you'll find the source code for a
  1204. solitaire game I wrote a while back.  It contains some very useful
  1205. libraries I've written -- one of which is a sound library.  Not only will
  1206. it let you do what you want to do, but it'll also let you play the sound
  1207. from disk to reduce the memory requirements.
  1208.  
  1209. Hope you like it!
  1210.  
  1211. Oh, for those of you with NewsWatcher, here's the URL:
  1212.  
  1213.   ftp://thomas_mac.wustl.edu/Public/for_ftp/Solitaire_code.sit
  1214.  
  1215. -Thomas
  1216.  
  1217. =====================================================
  1218. Thomas Reed                     Washington University
  1219. reed@telesphere.wustl.edu           Medical School
  1220. reed@medicine.wustl.edu            Saint Louis, MO
  1221. - ---------------------------------------------------
  1222. Clothes make the man.  Naked people have little or no
  1223. influence on society.  -- Mark Twain
  1224. =====================================================
  1225.  
  1226. Opinions posted are not the opinions of Wash. U.
  1227.  
  1228. ---------------------------
  1229.  
  1230. >From chris-b@cs.auckland.ac.nz (Chris Burns)
  1231. Subject: [Q] What does "_Xxxxx ,Sys,Immed" mean?
  1232. Date: Wed, 24 Aug 1994 11:36:07 +1200
  1233. Organization: AucklandUniversity:ComputerScience:HMU
  1234.  
  1235. Hi all,
  1236.  
  1237. What do the ",Sys,Immed" qualifiers mean?
  1238. I know they specify certain bits in the trap word, but what do the
  1239. different combinations mean?
  1240.  
  1241. What I want is a table:
  1242.  
  1243. Sys   Immed    Meaning
  1244.  
  1245.  x      x      ?
  1246.  x             ?
  1247.         x      ?
  1248.                ?
  1249.  
  1250. Thanks Heaps In Advance,
  1251.  
  1252. Chris B
  1253. - ---------------------------------------------------------------------
  1254. NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
  1255. Internet: chris-b@cs.auckland.ac.nz
  1256. Phone:    +64 9 373-7599 x6194
  1257. Fax:      +64 9 373-7453                         Async, therefore I am.
  1258. - ---------------------------------------------------------------------
  1259.  
  1260. +++++++++++++++++++++++++++
  1261.  
  1262. >From wysocki@netcom.com (Chris Wysocki)
  1263. Date: Wed, 24 Aug 1994 15:27:25 GMT
  1264. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1265.  
  1266. In article <chris-b-2408941136070001@hmu7.cs.aukuni.ac.nz>,
  1267. Chris Burns <chris-b@cs.auckland.ac.nz> wrote:
  1268.  
  1269. >What do the ",Sys,Immed" qualifiers mean?
  1270. >I know they specify certain bits in the trap word, but what do the
  1271. >different combinations mean?
  1272.  
  1273. The ",Sys" and ",Immed" qualifiers displayed by MacsBug can be
  1274. misnomers, since these are only two of the possible meaning of bits 9
  1275. and 10 of a trap word.  All the possible meaning for these bits can be
  1276. found in Traps.a:
  1277.  
  1278. ; Equates for setting trap option bits
  1279.  
  1280. ; for Device and File Manager routines
  1281.  
  1282. immed        EQU        $200      ; execute immediately, bypass I/O queue
  1283. async        EQU        $400      ; asynchronous, don't wait for completion
  1284.  
  1285. ; for Memory Manager routines
  1286.  
  1287. clear        EQU        $200
  1288. sys          EQU        $400
  1289.  
  1290. ; for string routines
  1291.  
  1292. marks        EQU        $200      ; set to ignore/strip diacriticals
  1293. case         EQU        $400      ; set for case sensitivity
  1294.  
  1295. ; for all Toolbox routines
  1296.  
  1297. autoPop      EQU        $400      ; set to pop an extra return address
  1298.  
  1299. ; for Get/Set & NGet/NSet TrapAddress
  1300.  
  1301. newTool      EQU        $600      ; Toolbox trap, under new ordering
  1302. newOS        EQU        $200      ; OS trap, under new ordering
  1303.  
  1304. ; for HFS routines
  1305.  
  1306. newHFS       EQU        $200
  1307.  
  1308.  
  1309. Chris.
  1310.  
  1311. ---------------------------
  1312.  
  1313. >From chrism@col.hp.com (Chris Magnuson)
  1314. Subject: jGNE from an INIT
  1315. Date: 17 Aug 1994 05:50:18 GMT
  1316. Organization: HP Colorado Springs Division
  1317.  
  1318.   I am writing a jGNE event filter in MPW that needs to be part of an INIT that
  1319.   does alot of other things ( i.e. the jGNE function is one part of the
  1320.   INIT code resource).  I've gotten alot done, but run into problems when
  1321.   events actually call my jGNE routine to do the event "interception/
  1322.   redirection."  
  1323.  
  1324.   short JGNEFilterFunc(short hasEvent, const EventRecord *theEvent)
  1325.  
  1326.   My question is this:  when the JGNEFilterFunc routine is called with an
  1327.   EventRecord, etc. am I supposed to be doing some A5 world swapping to
  1328.   get things to be handled properly in the jGNE routine?  Without posting
  1329.   alot of code here is basically what the INIT initialization does.  Hints
  1330.   are greatly appreciated!
  1331.  
  1332.  
  1333.   main() {
  1334.         oldZone = GetZone();
  1335.     SetZone(SystemZone());
  1336.  
  1337.     MakeA5World(&A5Ref);
  1338.     if (A5Ref == nil) {
  1339.         SetZone(oldZone);
  1340.         return(memFullErr);
  1341.     }
  1342.     a_SetA5Ref(A5Ref);
  1343.     oldA5 = SetA5World(A5Ref);
  1344.  
  1345.     (void) ReadPrefs();
  1346.     jGNEInit();    /* point to assembly glue routine that eventually calls
  1347.                         * JGNEFilterFunc() when events go through jGNE 0x29A
  1348.                         */
  1349.  
  1350.     (void) SetA5(oldA5);
  1351.     SetZone(oldZone);
  1352.    }
  1353.  
  1354. Chris Magnuson
  1355. chrism@col.hp.com
  1356.  
  1357. +++++++++++++++++++++++++++
  1358.  
  1359. >From gurgle@dnai.com (Pete Gontier)
  1360. Date: Tue, 16 Aug 1994 23:10:27 -0800
  1361. Organization: Integer Poet Software
  1362.  
  1363. In article <32s8eq$kdr@hp-col.col.hp.com>,
  1364. chrism@col.hp.com (Chris Magnuson) wrote:
  1365.  
  1366. > I am writing a jGNE event filter in MPW that needs to be part of an INIT...
  1367. > am I supposed to be doing some A5 world swapping... ?
  1368.  
  1369. You will want to read the DSC Technical Note "Stand-alone Code Resources
  1370. Ad Nauseum" if you have not already. The short answer is yes, you do need
  1371. to do some twiddling to get access to global variables.
  1372.  
  1373. Frankly, though, I would recommend doing this project in THINK C, because
  1374. (a) assembly code is easier to integrate, (b) global variables are easier
  1375. to access, and (c) my sample jGNE INIT, "jGNE Helper", is posted monthly
  1376. to 'alt.sources.mac' with a THINK C project and will make all of these
  1377. problems go away for you.
  1378.  
  1379. -- 
  1380.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  1381.  
  1382.  "I am Homer of Borg! Prepare to be... Ooooooo! Donuts!"
  1383.  
  1384. +++++++++++++++++++++++++++
  1385.  
  1386. >From neil_ticktin@xplain.com (Neil Ticktin)
  1387. Date: Wed, 17 Aug 1994 16:26:42 GMT
  1388. Organization: MacTech Magazine/Xplain Corporation
  1389.  
  1390. In article <32s8eq$kdr@hp-col.col.hp.com>, chrism@col.hp.com (Chris
  1391. Magnuson) wrote:
  1392.  
  1393. >>   I am writing a jGNE event filter in MPW that needs to be part of an
  1394. INIT that
  1395. >>   does alot of other things ( i.e. the jGNE function is one part of the
  1396. >>   INIT code resource).  I've gotten alot done, but run into problems when
  1397. >>   events actually call my jGNE routine to do the event "interception/
  1398. >>   redirection."  
  1399. >> 
  1400.  
  1401. Chris,
  1402.  
  1403. Late last year, there was a great article by Symantec Tech Support in
  1404. about writing a jGNEFilter.  It was one of the THINK Top 10 columns.  It
  1405. contained the template code and an example of how to do it.  I'm on the
  1406. road and don't have the issue handy, but you should check it out.
  1407.  
  1408. Hope it helps,
  1409.  
  1410. Neil
  1411.  
  1412. - ---------------------------------------------------------------------
  1413.            Neil Ticktin, MacTech Magazine (formerly MacTutor)
  1414. PO Box 250055, Los Angeles, CA 90025 * 310-575-4343 * Fax: 310-575-0925
  1415.  For more info, anonymous ftp to ftp.netcom.com and cd to /pub/xplain
  1416.   custservice@xplain.com * editorial@xplain.com * adsales@xplain.com
  1417. marketing@xplain.com * accounting@xplain.com * pressreleases@xplain.com
  1418.    progchallenge@xplain.com * publisher@xplain.com * info@xplain.com
  1419.  
  1420. +++++++++++++++++++++++++++
  1421.  
  1422. >From chrism@col.hp.com (Chris Magnuson)
  1423. Date: 17 Aug 1994 20:14:57 GMT
  1424. Organization: HP Colorado Springs Division
  1425.  
  1426. Pete Gontier (gurgle@dnai.com) wrote:
  1427. : In article <32s8eq$kdr@hp-col.col.hp.com>,
  1428. : chrism@col.hp.com (Chris Magnuson) wrote:
  1429.  
  1430. : > I am writing a jGNE event filter in MPW that needs to be part of an INIT...
  1431. : > am I supposed to be doing some A5 world swapping... ?
  1432.  
  1433. : You will want to read the DSC Technical Note "Stand-alone Code Resources
  1434. : Ad Nauseum" if you have not already. The short answer is yes, you do need
  1435. : to do some twiddling to get access to global variables.
  1436.  
  1437. : Frankly, though, I would recommend doing this project in THINK C, because
  1438. : (a) assembly code is easier to integrate, (b) global variables are easier
  1439. : to access, and (c) my sample jGNE INIT, "jGNE Helper", is posted monthly
  1440. : to 'alt.sources.mac' with a THINK C project and will make all of these
  1441. : problems go away for you.
  1442.  
  1443.  
  1444.  No it won't :)  I must not be communicating what has to happen here.  main()
  1445.  is no longer the entry point for a jGNE filter only.  main() is the entry
  1446.  point for an entire INIT, one component of which is a jGNE event processor.
  1447.  So the code resource in question here is an entire INIT, not just a jGNE
  1448.  filter.
  1449.  
  1450.  In other words, the jGNE portion of the code is one routine within the INIT
  1451.  code resource, and I have glue that dispatches to that routine, but it
  1452.  does not behave properly.
  1453.  
  1454.  So maybe the question is, when the jGNE event is dispatched to the code
  1455.  within my INIT, must I set A5 for some reason?  Even though I am not
  1456.  interested in globals (just the parameters on the stack)?
  1457.  
  1458.  Chris Magnuson
  1459.  chrism@col.hp.com
  1460.  
  1461. +++++++++++++++++++++++++++
  1462.  
  1463. >From chrism@col.hp.com (Chris Magnuson)
  1464. Date: 17 Aug 1994 20:16:09 GMT
  1465. Organization: HP Colorado Springs Division
  1466.  
  1467.   Thanks.  Yes, I did check that out.  It doesnt answer my question since it
  1468.   is a standalone jGNE (in other words the jGNE event processor is not part
  1469.   of a larger code resource with other things going on).
  1470.  
  1471. Chris Magnuson
  1472. chrism@col.hp.com
  1473.  
  1474.  
  1475. Neil Ticktin (neil_ticktin@xplain.com) wrote:
  1476. : In article <32s8eq$kdr@hp-col.col.hp.com>, chrism@col.hp.com (Chris
  1477. : Magnuson) wrote:
  1478.  
  1479. : >>   I am writing a jGNE event filter in MPW that needs to be part of an
  1480. : INIT that
  1481. : >>   does alot of other things ( i.e. the jGNE function is one part of the
  1482. : >>   INIT code resource).  I've gotten alot done, but run into problems when
  1483. : >>   events actually call my jGNE routine to do the event "interception/
  1484. : >>   redirection."  
  1485. : >> 
  1486.  
  1487. : Chris,
  1488.  
  1489. : Late last year, there was a great article by Symantec Tech Support in
  1490. : about writing a jGNEFilter.  It was one of the THINK Top 10 columns.  It
  1491. : contained the template code and an example of how to do it.  I'm on the
  1492. : road and don't have the issue handy, but you should check it out.
  1493.  
  1494. : Hope it helps,
  1495.  
  1496. : Neil
  1497.  
  1498. : -----------------------------------------------------------------------
  1499. :            Neil Ticktin, MacTech Magazine (formerly MacTutor)
  1500. : PO Box 250055, Los Angeles, CA 90025 * 310-575-4343 * Fax: 310-575-0925
  1501. :  For more info, anonymous ftp to ftp.netcom.com and cd to /pub/xplain
  1502. :   custservice@xplain.com * editorial@xplain.com * adsales@xplain.com
  1503. : marketing@xplain.com * accounting@xplain.com * pressreleases@xplain.com
  1504. :    progchallenge@xplain.com * publisher@xplain.com * info@xplain.com
  1505.  
  1506. +++++++++++++++++++++++++++
  1507.  
  1508. >From larson@oahu.cs.ucla.edu (Christopher Larson)
  1509. Date: Wed, 17 Aug 94 21:28:50 GMT
  1510. Organization: UCLA, Computer Science Department
  1511.  
  1512. In article <32tr42$pfg@hp-col.col.hp.com> chrism@col.hp.com (Chris Magnuson) writes:
  1513. >: In article <32s8eq$kdr@hp-col.col.hp.com>,
  1514. >: chrism@col.hp.com (Chris Magnuson) wrote:
  1515. >
  1516. >: > I am writing a jGNE event filter in MPW that needs to be part of an INIT...
  1517. >: > am I supposed to be doing some A5 world swapping... ?
  1518.  
  1519. [...]
  1520.  
  1521. > So maybe the question is, when the jGNE event is dispatched to the code
  1522. > within my INIT, must I set A5 for some reason?  Even though I am not
  1523. > interested in globals (just the parameters on the stack)?
  1524.  
  1525. If you don't use (or cause to be used) any globals, you don't need an A5
  1526. world, and, therefore, you don't need to set A5.
  1527.  
  1528. If the jGNE filter doesn't need access to any globals, why is it part of
  1529. the INIT (I read the above to mean the jGNE code is within the INIT resource,
  1530. if not, ignore this)? Wouldn't it be easier to compile the jGNE portion as
  1531. a seperate resource, and just load, detatch, and install from the INIT
  1532. resource?
  1533.  
  1534. --Chris <Wondering if he's missing something obvious> Larson
  1535. _______________________________________________________________________________
  1536. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1537. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1538. Death to the Trojans! Go Bruins!
  1539.  
  1540. (Insert disclaimer here)
  1541. Internet: larson@kingston.cs.ucla.edu
  1542.  
  1543. +++++++++++++++++++++++++++
  1544.  
  1545. >From Jaeger@fquest.com (Brian Stern)
  1546. Date: 18 Aug 1994 00:53:36 GMT
  1547. Organization: The University of Texas at Austin, Austin, Texas
  1548.  
  1549. In article <32tr42$pfg@hp-col.col.hp.com>, chrism@col.hp.com (Chris
  1550. Magnuson) wrote:
  1551.  
  1552. > Pete Gontier (gurgle@dnai.com) wrote:
  1553. > : In article <32s8eq$kdr@hp-col.col.hp.com>,
  1554. > : chrism@col.hp.com (Chris Magnuson) wrote:
  1555. > : > I am writing a jGNE event filter in MPW that needs to be part of an
  1556. INIT...
  1557. > : > am I supposed to be doing some A5 world swapping... ?
  1558.  
  1559. >  No it won't :)  I must not be communicating what has to happen here.  main()
  1560. >  is no longer the entry point for a jGNE filter only.  main() is the entry
  1561. >  point for an entire INIT, one component of which is a jGNE event processor.
  1562. >  So the code resource in question here is an entire INIT, not just a jGNE
  1563. >  filter.
  1564. >  In other words, the jGNE portion of the code is one routine within the INIT
  1565. >  code resource, and I have glue that dispatches to that routine, but it
  1566. >  does not behave properly.
  1567. >  So maybe the question is, when the jGNE event is dispatched to the code
  1568. >  within my INIT, must I set A5 for some reason?  Even though I am not
  1569. >  interested in globals (just the parameters on the stack)?
  1570. >  Chris Magnuson
  1571. >  chrism@col.hp.com
  1572.  
  1573. In order to function properly any jGNEFilter has to insert itself into the
  1574. chain of all jGNEFilters.  When your filter exits it needs to jump to the
  1575. previous filter.  The address of the previous filter must be saved at the
  1576. time that you install your filter.  This saved address must be a global. 
  1577. Therefore your jGNEFilter, and all jGNEFilters for all time, must have
  1578. access to global variables.  There are several mechanisms for accessing
  1579. global variables in stand alone code resources like your jGNEFilter.  As I
  1580. understand it MPW uses an A5-based mechanism that is described in the tech
  1581. note.  Use that mechanism if you like.  Think, and I believe CW, use an
  1582. A4-based mechanism, which is straightforward to use.  Aside from access to
  1583. the previous filter's address or to other global variables there is no
  1584. requirement for an A5 world to be set up.
  1585.  
  1586. There is a sample jGNEFilter written by Dave Falkenberg that can be found
  1587. at ftp.apple.com.  This sample is all in MPW assembler.  It does not use
  1588. the A5 mechanism for storing the address of the previous filter.  It
  1589. simply stores the address within itself.
  1590.  
  1591. -- 
  1592. Brian  Stern  :-{)}
  1593. Jaeger@fquest.com
  1594.  
  1595. +++++++++++++++++++++++++++
  1596.  
  1597. >From gurgle@dnai.com (Pete Gontier)
  1598. Date: Wed, 17 Aug 1994 21:17:15 -0800
  1599. Organization: Integer Poet Software
  1600.  
  1601. In article <1994Aug17.212850.10867@cs.ucla.edu>, larson@oahu.cs.ucla.edu
  1602. (Christopher Larson) wrote:
  1603.  
  1604. > If the jGNE filter doesn't need access to any globals, why is it part of
  1605. > the INIT ... ? Wouldn't it be easier to compile the jGNE portion as
  1606. > a seperate resource, and just load, detatch, and install from the INIT
  1607. > resource?
  1608.  
  1609. His filter might want to call other functions in the INIT without
  1610. duplicating them in the jGNE resource. I don't know enough about
  1611. MPW-generated code resources to be able to say whether it needs A5 to call
  1612. functions. Probably it uses PC-relative calls, but it's something you
  1613. would want to look up.
  1614.  
  1615. -- 
  1616.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  1617.  
  1618.  "Even during a particularly harsh (Colorado) winter... many of the
  1619.  300 families in the VCTV (movies-on-demand) trial continued to go
  1620.  to video stores." -- eis@murrow.tufts.edu, in Wired 2.09 p62
  1621.  
  1622. +++++++++++++++++++++++++++
  1623.  
  1624. >From gurgle@dnai.com (Pete Gontier)
  1625. Date: Wed, 17 Aug 1994 21:25:33 -0800
  1626. Organization: Integer Poet Software
  1627.  
  1628. In article <32tr42$pfg@hp-col.col.hp.com>, chrism@col.hp.com (Chris
  1629. Magnuson) wrote:
  1630.  
  1631. >  I must not be communicating what has to happen here.  main()
  1632. >  is no longer the entry point for a jGNE filter only.  main() is the entry
  1633. >  point for an entire INIT, one component of which is a jGNE event processor.
  1634. >  So the code resource in question here is an entire INIT, not just a jGNE
  1635. >  filter. In other words, the jGNE portion of the code is one routine within
  1636. >  the INIT code resource, and I have glue that dispatches to that routine,
  1637. >  but it does not behave properly.
  1638.  
  1639. As I said in email, I know. :-) Probably I am the one who did insufficient
  1640. communicating. With a THINK (or CodeWarrior) compiler, what you're asking
  1641. about is trivial, because the compiler actually knows that it's compiling
  1642. something other than an application, unlike MPW. MPW only knows at link
  1643. time; consequently, MPW code resource have to pretend in many ways that
  1644. they are apps. Hence that entire tech note about code resources and A5.
  1645. Blech.
  1646.  
  1647. >  So maybe the question is, when the jGNE event is dispatched to the code
  1648. >  within my INIT, must I set A5 for some reason?  Even though I am not
  1649. >  interested in globals (just the parameters on the stack)?
  1650.  
  1651. Again as I said in email, if your code does not use statically allocated
  1652. variables (locals declared 'static' or globals), you may still need to set
  1653. up A5 if your filter calls other routines, depending on how MPW finds
  1654. those routines. Probably it finds them PC-relative, but it may find them
  1655. A5-relative. Perhaps some MPW guru can shed light on this.
  1656.  
  1657. -- 
  1658.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  1659.  
  1660.  "Even during a particularly harsh (Colorado) winter... many of the
  1661.  300 families in the VCTV (movies-on-demand) trial continued to go
  1662.  to video stores." -- eis@murrow.tufts.edu, in Wired 2.09 p62
  1663.  
  1664. +++++++++++++++++++++++++++
  1665.  
  1666. >From Jaeger@fquest.com (Brian Stern)
  1667. Date: 19 Aug 1994 02:36:45 GMT
  1668. Organization: The University of Texas at Austin, Austin, Texas
  1669.  
  1670. In article <jedavis.777254033@Xenon.Stanford.EDU>,
  1671. jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  1672.  
  1673. > On a side note.. I dont suppose you have any idea if I can 
  1674. > allocate some memory in a jGNEfilter? I dont mind stealing
  1675. > from the host app. I want to muck with the clipboard, so need 
  1676. > a couple handles that dont mind being resized by the Scrap calls.
  1677. > -James
  1678.  
  1679. Since jGNEFilters are called from WNE/GNE and both of those traps are
  1680. documented as moving or purging memory, Yes you can allocate memory from
  1681. inside a jGNEFilter.  If you want the memory to last longer than one pass
  1682. through your filter make sure to allocate the memory in the system heap,
  1683. otherwise it will be lost if the app quits.  If the memory will be
  1684. allocated and disposed within one pass of the filter it can go in the
  1685. application's heap.
  1686.  
  1687. -- 
  1688. Brian  Stern  :-{)}
  1689. Jaeger@fquest.com
  1690.  
  1691. +++++++++++++++++++++++++++
  1692.  
  1693. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  1694. Date: 18 Aug 94 18:51:13 GMT
  1695. Organization: Stanford University: Computer Science Department
  1696.  
  1697. larson@oahu.cs.ucla.edu (Christopher Larson) writes:
  1698.  
  1699. >In article <32tr42$pfg@hp-col.col.hp.com> chrism@col.hp.com (Chris Magnuson) writes:
  1700. >> So maybe the question is, when the jGNE event is dispatched to the code
  1701. >> within my INIT, must I set A5 for some reason?  Even though I am not
  1702. >> interested in globals (just the parameters on the stack)?
  1703.  
  1704. >If you don't use (or cause to be used) any globals, you don't need an A5
  1705. >world, and, therefore, you don't need to set A5.
  1706.  
  1707. Yes, but remember that some Quickdraw globals are offset from A5 as
  1708. well. You might not need *your* A5, but you will need a valid one.
  1709. I bring this up, because inside your jGNEfilter you wont
  1710. neccessarily get one. You can set the A5 of the
  1711. currently executing application from the low memory global CurrentA5,
  1712. but remember to put back whatever stuffs was in A5 to start with.
  1713.  
  1714. James Davis : jedavis@cs.stanford.edu
  1715.  
  1716. +++++++++++++++++++++++++++
  1717.  
  1718. >From larson@oahu.cs.ucla.edu (Christopher Larson)
  1719. Date: Thu, 18 Aug 94 21:05:17 GMT
  1720. Organization: UCLA, Computer Science Department
  1721.  
  1722. James said:
  1723. >I said:
  1724. >>Chris Magnuson said:
  1725. >>> So maybe the question is, when the jGNE event is dispatched to the code
  1726. >>> within my INIT, must I set A5 for some reason?  Even though I am not
  1727. >>> interested in globals (just the parameters on the stack)?
  1728. >
  1729. >>If you don't use (or cause to be used) any globals, you don't need an A5
  1730. >>world, and, therefore, you don't need to set A5.
  1731. >
  1732. >Yes, but remember that some Quickdraw globals are offset from A5 as
  1733. >well.
  1734.  
  1735. Making any calls which require Quickdraw globals count as causing globals
  1736. to be used. (Perhaps I should have made that point clear :-).
  1737.  
  1738. > You might not need *your* A5, but you will need a valid one.
  1739.  
  1740. Why? If I don't use Quickdraw or my own globals, I shouldn't (see caveat
  1741. below) need an A5 world and shouldn't care what the value of A5 is. I've
  1742. written numerous code resources and trap patches (though never a jGNE
  1743. filter). I've never needed an A5 world of my own (meaning belonging to
  1744. the code resource), and only needed to borrow the current application's
  1745. A5 when using Quickdraw globals. Unless jGNE filters are inherently
  1746. different, I don't see why one must run with a valid A5. (I didn't
  1747. intend this to sound at all like a flame. I'm just trying to get to
  1748. the bottom of this too.)
  1749.  
  1750. caveat: As Peter Lewis pointed out, calls to other routines within
  1751. code resources may use a jump table, which may use A5. Consult your
  1752. development system regarding this. (I'm paraphrasing, excuse me if I've
  1753. misinterpreted you, Peter.)
  1754.  
  1755. >I bring this up, because inside your jGNEfilter you wont neccessarily get
  1756. >one.
  1757.  
  1758. You sure won't.
  1759.  
  1760. >You can set the A5 of the currently executing application from the low
  1761. >memory global CurrentA5, but remember to put back whatever stuffs was in
  1762. >A5 to start with.
  1763.  
  1764. An invaluable piece of information. Saved my hiney many times.
  1765.  
  1766. --Chris
  1767. _______________________________________________________________________________
  1768. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1769. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1770. Death to the Trojans! Go Bruins!
  1771.  
  1772. (Insert disclaimer here)
  1773. Internet: larson@kingston.cs.ucla.edu
  1774.  
  1775. +++++++++++++++++++++++++++
  1776.  
  1777. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  1778. Date: 18 Aug 94 23:53:53 GMT
  1779. Organization: Stanford University: Computer Science Department
  1780.  
  1781. larson@oahu.cs.ucla.edu (Christopher Larson) writes:
  1782.  
  1783. >> You might not need *your* A5, but you will need a valid one.
  1784. >Why? If I don't use Quickdraw or my own globals, I shouldn't (see caveat
  1785. >below) need an A5 world and shouldn't care what the value of A5 is. I've
  1786. >written numerous code resources and trap patches (though never a jGNE
  1787. >filter). I've never needed an A5 world of my own (meaning belonging to
  1788. >the code resource), and only needed to borrow the current application's
  1789. >A5 when using Quickdraw globals. Unless jGNE filters are inherently
  1790. >different, I don't see why one must run with a valid A5. (I didn't
  1791. >intend this to sound at all like a flame. I'm just trying to get to
  1792. >the bottom of this too.)
  1793.  
  1794. You're correct. I phrased something badly. I had meant to
  1795. suggest that stealing the current applications A5 would do
  1796. for quickdraw globals, if you didnt have one of your own handy.
  1797.  
  1798. On a side note.. I dont suppose you have any idea if I can 
  1799. allocate some memory in a jGNEfilter? I dont mind stealing
  1800. from the host app. I want to muck with the clipboard, so need 
  1801. a couple handles that dont mind being resized by the Scrap calls.
  1802.  
  1803. -James
  1804.  
  1805. +++++++++++++++++++++++++++
  1806.  
  1807. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  1808. Date: 19 Aug 94 09:42:08 GMT
  1809. Organization: Stanford University: Computer Science Department
  1810.  
  1811. Jaeger@fquest.com (Brian Stern) writes:
  1812.  
  1813. >In article <32tr42$pfg@hp-col.col.hp.com>, chrism@col.hp.com (Chris
  1814. >Magnuson) wrote:
  1815.  
  1816. >> Pete Gontier (gurgle@dnai.com) wrote:
  1817. >> : In article <32s8eq$kdr@hp-col.col.hp.com>,
  1818. >> : chrism@col.hp.com (Chris Magnuson) wrote:
  1819. >> 
  1820. >>  So maybe the question is, when the jGNE event is dispatched to the code
  1821. >>  within my INIT, must I set A5 for some reason?  Even though I am not
  1822. >>  interested in globals (just the parameters on the stack)?
  1823. >> 
  1824. >>  chrism@col.hp.com
  1825.  
  1826. >In order to function properly any jGNEFilter has to insert itself into the
  1827. >chain of all jGNEFilters.  When your filter exits it needs to jump to the
  1828. >previous filter.  The address of the previous filter must be saved at the
  1829. >time that you install your filter.  This saved address must be a global. 
  1830.  
  1831. Global? Well not really. Its not really good style, but Ive seen it done
  1832. by stuffing the address into your code at install time. The same way
  1833. many people store their app A5, with code that self modifies to
  1834. contain the location.
  1835. For that matter, where should I store my apps A5, so I can reset
  1836. it without using self modifying code?
  1837.  
  1838. -James 
  1839.  
  1840. +++++++++++++++++++++++++++
  1841.  
  1842. >From larson@oahu.cs.ucla.edu (Christopher Larson)
  1843. Date: Fri, 19 Aug 94 16:15:35 GMT
  1844. Organization: UCLA, Computer Science Department
  1845.  
  1846. In article <jedavis.777289328@Xenon.Stanford.EDU> jedavis@Xenon.Stanford.EDU (James Edward Davis) writes:
  1847. >Jaeger@fquest.com (Brian Stern) writes:
  1848. >>In order to function properly any jGNEFilter has to insert itself into the
  1849. >>chain of all jGNEFilters.  When your filter exits it needs to jump to the
  1850. >>previous filter.  The address of the previous filter must be saved at the
  1851. >>time that you install your filter.  This saved address must be a global. 
  1852. >
  1853. >Global? Well not really. Its not really good style, but Ive seen it done
  1854. >by stuffing the address into your code at install time. The same way
  1855. >many people store their app A5, with code that self modifies to
  1856. >contain the location.
  1857.  
  1858. I'm not sure this strategy counts as self-modification if the installed
  1859. code is contained in its own resource. When the app (INIT, whatever) loads
  1860. the resource, before detaching and installing, it's just data. If it's
  1861. modified at this point, I don't think you will have any problems (still
  1862. need to flush caches though), because the resource has never been loaded
  1863. as code. If the code to be installed is in your 'CODE' resources, all
  1864. bets are off. (Comments on this welcome....)
  1865.  
  1866. >For that matter, where should I store my apps A5, so I can reset
  1867. >it without using self modifying code?
  1868.  
  1869. Well, you could use the above strategy, or if that is still to self-modify-
  1870. ish, you could install a Gestalt selector. Note that trickery to recover your
  1871. A5 is only necessary if your code might run when your app is switched out or
  1872. at interrupt time. If this is not the case, you can recover it from CurrentA5,
  1873. as you suggested earlier. 
  1874.  
  1875. Hmmm. This raises an interesting question. If an app installs a jGNEFilter,
  1876. is that filter visible to all other applications, or is it more like trap
  1877. patches (which, if done from an app, are only visible to the installing app)?
  1878. Anyone?
  1879.  
  1880. Since this thread is about jGNEFilters, I assume your question was specific
  1881. to recovering A5 from a jGNEFilter/trap patch kind of situation. If not, mail
  1882. me with the specifics.
  1883.  
  1884. --Chris
  1885. _______________________________________________________________________________
  1886. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1887. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1888. Death to the Trojans! Go Bruins!
  1889.  
  1890. (Insert disclaimer here)
  1891. Internet: larson@kingston.cs.ucla.edu
  1892.  
  1893. +++++++++++++++++++++++++++
  1894.  
  1895. >From larson@oahu.cs.ucla.edu (Christopher Larson)
  1896. Date: Fri, 19 Aug 94 16:22:01 GMT
  1897. Organization: UCLA, Computer Science Department
  1898.  
  1899. In article <Jaeger-1808942138440001@slip-15-7.ots.utexas.edu> Jaeger@fquest.com (Brian Stern) writes:
  1900. >In article <jedavis.777254033@Xenon.Stanford.EDU>,
  1901. >jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  1902. >
  1903. >> On a side note.. I dont suppose you have any idea if I can 
  1904. >> allocate some memory in a jGNEfilter? I dont mind stealing
  1905. >
  1906. >Since jGNEFilters are called from WNE/GNE and both of those traps are
  1907. >documented as moving or purging memory, Yes you can allocate memory from
  1908. >inside a jGNEFilter.  If you want the memory to last longer than one pass
  1909. >through your filter make sure to allocate the memory in the system heap,
  1910. >otherwise it will be lost if the app quits.
  1911.  
  1912. Or, you could receive consecutive calls from two different applications.
  1913. Best, in any case, to allocate from the system heap if you want persistance.
  1914.  
  1915. >If the memory will be allocated and disposed within one pass of the filter
  1916. >it can go in the application's heap.
  1917.  
  1918. Or maybe temporary memory if you don't want to use the app's heap.
  1919.  
  1920. --Chris
  1921. _______________________________________________________________________________
  1922. Chris Larson -- Amateur Macintosh Geek, CoBase Research Assistant
  1923. L.A. Institute of Slowly and Painfully Working Out the Surprisingly Obvious
  1924. Death to the Trojans! Go Bruins!
  1925.  
  1926. (Insert disclaimer here)
  1927. Internet: larson@kingston.cs.ucla.edu
  1928.  
  1929. +++++++++++++++++++++++++++
  1930.  
  1931. >From gurgle@dnai.com (Pete Gontier)
  1932. Date: Fri, 19 Aug 1994 09:45:18 -0800
  1933. Organization: Integer Poet Software
  1934.  
  1935. In article <1994Aug19.161535.10734@cs.ucla.edu>, larson@oahu.cs.ucla.edu
  1936. (Christopher Larson) wrote:
  1937.  
  1938. > If an app installs a jGNEFilter,
  1939. > is that filter visible to all other applications, or is it more like trap
  1940. > patches (which, if done from an app, are only visible to the installing app)?
  1941.  
  1942. It's visible to all other applications.
  1943.  
  1944. -- 
  1945.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  1946.  
  1947.  "Even during a particularly harsh (Colorado) winter... many of the
  1948.  300 families in the VCTV (movies-on-demand) trial continued to go
  1949.  to video stores." -- eis@murrow.tufts.edu, in Wired 2.09 p62
  1950.  
  1951. +++++++++++++++++++++++++++
  1952.  
  1953. >From Jaeger@fquest.com (Brian Stern)
  1954. Date: 19 Aug 1994 16:43:20 GMT
  1955. Organization: The University of Texas at Austin, Austin, Texas
  1956.  
  1957. In article <jedavis.777289328@Xenon.Stanford.EDU>,
  1958. jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  1959.  
  1960. > Jaeger@fquest.com (Brian Stern) writes:
  1961. > >In order to function properly any jGNEFilter has to insert itself into the
  1962. > >chain of all jGNEFilters.  When your filter exits it needs to jump to the
  1963. > >previous filter.  The address of the previous filter must be saved at the
  1964. > >time that you install your filter.  This saved address must be a global. 
  1965. > Global? Well not really. Its not really good style, but Ive seen it done
  1966. > by stuffing the address into your code at install time. The same way
  1967. > many people store their app A5, with code that self modifies to
  1968. > contain the location.
  1969. > For that matter, where should I store my apps A5, so I can reset
  1970. > it without using self modifying code?
  1971. > -James 
  1972.  
  1973. App?  I thought we were talking about about an INIT.  Installing a
  1974. jGNEFilter from an app has a number of problems to worry about.  I would
  1975. probably write the filter as a code resource using A4 addressing.  To
  1976. install it I'd load the resource into the system heap, set up A0, and jump
  1977. to it from the app to initilize it.  It would save A5 for later use.  It
  1978. would also have to make sure that the app still existed.  The A4 mechanism
  1979. as used by Think C is also a self-modifying mechanism and I don't see any
  1980. clean way around it.
  1981.  
  1982. Having said that, I recently came across some code in a package called
  1983. Extension Shell by Dair Grant that uses A4 addressing without being
  1984. self-modifying.  Here's the code:
  1985.  
  1986.    WRITTEN BY:
  1987.       Eric Shapiro (from July 1993 BYTE article, and the supporting source code)
  1988.  
  1989. // Saves the current value of A4 on the stack, and puts the address of main
  1990. // into A4. Should be called at start of stand-alone code resource to
  1991. access globals.
  1992. #define GetGlobals()    asm {                                        \
  1993.                         move.l      A4, -(SP)      ; save old A4        \
  1994.                         lea      main, A4       ; get globals        \
  1995.                         }
  1996.  
  1997.  
  1998. // The converse of GetGlobals(). Restore the value of A4                
  1999. #define UngetGlobals()     asm {                                     \
  2000.                         move.l      (SP)+, A4      ; restore A4 from stack \
  2001.                         }
  2002.  
  2003. This is dependent on main being at the beginning of your code resource and
  2004. on your compiler compiling the code resource using A4 addressing.
  2005.  
  2006. -- 
  2007. Brian  Stern  :-{)}
  2008. Jaeger@fquest.com
  2009.  
  2010. +++++++++++++++++++++++++++
  2011.  
  2012. >From bjaques@vanbc.wimsey.com (Barton Jaques)
  2013. Date: Fri, 19 Aug 1994 09:36:35 -0700
  2014. Organization: Wimsey Information Services
  2015.  
  2016. I spent many long hours slaving over my hot jGNEFilter before it worked
  2017. correctly. It is the sloppiest hack I've seen in a while, but it works
  2018. great. In short, here's what I do:
  2019.  
  2020. • I have a separate jGNEFilter.π project which compiles into a single
  2021. resource.
  2022. • My INIT or DRVR reads that resource, detaches it, locks it.
  2023. • At startup time, my INIT or DRVR reads the current value of jGNEFilter,
  2024. pokes it into my patch resource, then sticks the address of my patch
  2025. resource into jGNEFilter.
  2026. • I have another handle which contains useful "global" variables and
  2027. pointers to procedures contained in other code resources. I poke the handle
  2028. into my detached jGNE resource. This way I have access to "globals" which I
  2029. have scattered through different code resources … yet I don't have to
  2030. fiddle with A5.
  2031. • The way I do this is by initialising a couple of local variables in my
  2032. patch resource as follows:
  2033.      globRecH     globalsH = 0xEEEEEEEE;
  2034.      long            nextGNEFilter = 0xDDDDDDDD;
  2035.   My INIT or DRVR scans the resource, finds 0xEEEEEEEE, and overwrites it
  2036. with my "globals" handle. Then it scans for 0xDDDDDDDD, and overwrites it
  2037. with the pointer to the next GNE filter.
  2038. • If my GNEFilter calls a procedure in another of my code resources, THEN I
  2039. need to set up A4/A5 as appropriate, and put it back before I return to my
  2040. patch.
  2041. • When I want to de-install my driver, etc., I cauterise my patch by
  2042. plugging 0x00000000 where my globals handle was. The filter then knows that
  2043. it has been deactivated, so it passes to the next filter without doing
  2044. anything. I can always restore the patch simply by poking globH back in
  2045. again.
  2046.  
  2047.   This is the code in THINK C 68K. It surely will not work under another
  2048. environment without serious modification, but it should illustrate the
  2049. idea. 
  2050.  
  2051. void 
  2052. main() {
  2053.  
  2054.     globRecH        globH    = (globRecH)0xEEEEEEEE;
  2055.     long            nextGNEFilter = 0xDDDDDDDD;
  2056.     EventRecord *filteredEventP;
  2057.   // declare any other local vars you need
  2058.     Ptr            stackP;                            // stackP MUST be last local var declared
  2059.     
  2060.     //    move.l    (a7), -(a7)                        ; In actual res this line must precede LINK A6
  2061.     //                                                    ; In ResEdit, insert '2F17' as 1st word in res
  2062.     //                                                    ; then move 2nd-last byte (= 4E5E) to
  2063.     //                                                    ; precede 5th-last byte (= 4A97)
  2064.  
  2065.     asm{
  2066.         movem.l    a7, stackP                        ; make copy of stack pointer
  2067.         movem.l    a0-a3/d0-d7, -(sp)            ; save registers
  2068.     }            
  2069.     
  2070.     // if nextGNEFilter exists we must fiddle with stack to insert it
  2071.     if (nextGNEFilter) {
  2072.         stackP += ((Ptr)&globH - (Ptr)&stackP) + 8;
  2073.         *(long*)stackP = nextGNEFilter;
  2074.     }
  2075.     
  2076.     // do nothing if no globals
  2077.     if (globH) {
  2078.   // get a pointer to the event record
  2079.         asm{
  2080.             move.l    a1, filteredEventP            ; test a1 (EventPtr)
  2081.         }
  2082.         eventwhat = filteredEventP->what;
  2083.  
  2084.   // now we can do our stuff
  2085.     }
  2086.  
  2087.     // restore registers and stack
  2088.     asm{
  2089.         movem.l    (sp)+, d0-d7/a0-a3        ; restore all registers
  2090.         tst.l        (sp)                            ; in actual res these lines follow UNLK A6 (see note
  2091. above)
  2092.         bne        @END                            ; 
  2093.         tst.l        (sp)+                            ;
  2094.         @END
  2095.     }
  2096.  
  2097.     // control now passes to next GNEFilter handler if any
  2098. }
  2099.  
  2100.  
  2101. -- 
  2102. bjaques@vanbc.wimsey.com
  2103.  
  2104. +++++++++++++++++++++++++++
  2105.  
  2106. >From gurgle@dnai.com (Pete Gontier)
  2107. Date: Fri, 19 Aug 1994 12:20:28 -0800
  2108. Organization: Integer Poet Software
  2109.  
  2110. In article <bjaques-190894093636@pme22.pomo.wis.net>,
  2111. bjaques@vanbc.wimsey.com (Barton Jaques) wrote:
  2112.  
  2113. > I spent many long hours slaving over my hot jGNEFilter before it worked
  2114. > correctly. It is the sloppiest hack I've seen in a while, but it works
  2115. > great. In short, here's what I do...
  2116.  
  2117. With all due respect for your long hours, quite frankly this all seems
  2118. very convoluted and mildly dangerous. If any step in the development
  2119. process goes wrong, the program fails at runtime. There are a minimum of
  2120. helpful compile-time checks, and it's difficult to see why any one part of
  2121. it works the way it does without understanding the whole picture. I'm glad
  2122. it works for you, but it seems a lot simpler and a lot cleaner to simply
  2123. use a strategy like that illustrated in "jGNE Helper" or whatever the hell
  2124. that monthly posting is called. (It may sound like I didn't write it
  2125. because I can't even remember its name, but I did write it, and you should
  2126. assume I am accordingly biased.)
  2127.  
  2128. -- 
  2129.  Pete Gontier // CTO, Integer Poet Software // gurgle@dnai.com
  2130.  
  2131.  "Even during a particularly harsh (Colorado) winter... many of the
  2132.  300 families in the VCTV (movies-on-demand) trial continued to go
  2133.  to video stores." -- eis@murrow.tufts.edu, in Wired 2.09 p62
  2134.  
  2135. +++++++++++++++++++++++++++
  2136.  
  2137. >From Jaeger@fquest.com (Brian Stern)
  2138. Date: 20 Aug 1994 00:25:40 GMT
  2139. Organization: The University of Texas at Austin, Austin, Texas
  2140.  
  2141. In article <bjaques-190894093636@pme22.pomo.wis.net>,
  2142. bjaques@vanbc.wimsey.com (Barton Jaques) wrote:
  2143.  
  2144. > I spent many long hours slaving over my hot jGNEFilter before it worked
  2145. > correctly. It is the sloppiest hack I've seen in a while, but it works
  2146. > great. In short, here's what I do:
  2147.  
  2148. Or, you could simply use A4 addressing to access your globals from your
  2149. Filter.  You can easily set a Boolean flag to let your Filter know if it's
  2150. supposed to do anything.  
  2151.  
  2152. I don't trust any code building method that has instructions in it like '
  2153. In ResEdit, insert '2F17' as 1st word in res then move 2nd-last byte (=
  2154. 4E5E) to precede 5th-last byte (= 4A97)'.
  2155.  
  2156. In programming like in most things simpler is usually better.  There are
  2157. lot's simpler ways to do it than this.
  2158.  
  2159. > -- 
  2160. > bjaques@vanbc.wimsey.com
  2161.  
  2162. -- 
  2163. Brian  Stern  :-{)}
  2164. Jaeger@fquest.com
  2165.  
  2166. +++++++++++++++++++++++++++
  2167.  
  2168. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  2169. Date: 20 Aug 94 17:24:09 GMT
  2170. Organization: Stanford University: Computer Science Department
  2171.  
  2172. larson@oahu.cs.ucla.edu (Christopher Larson) writes:
  2173.  
  2174. >In article <jedavis.777289328@Xenon.Stanford.EDU> jedavis@Xenon.Stanford.EDU (James Edward Davis) writes:
  2175. >>Jaeger@fquest.com (Brian Stern) writes:
  2176.  
  2177. >Well, you could use the above strategy, or if that is still to self-modify-
  2178. >ish, you could install a Gestalt selector. Note that trickery to recover your
  2179. >A5 is only necessary if your code might run when your app is switched out or
  2180. >at interrupt time. If this is not the case, you can recover it from CurrentA5,
  2181. >as you suggested earlier. 
  2182.  
  2183. >Hmmm. This raises an interesting question. If an app installs a jGNEFilter,
  2184. >is that filter visible to all other applications, or is it more like trap
  2185. >patches (which, if done from an app, are only visible to the installing app)?
  2186. >Anyone?
  2187.  
  2188. The jGNE filter *is* active across all apps. The low memory global that
  2189. points to the filter chain, is not changed by context switches. This
  2190. means you have to be very careful if you install a filter with code
  2191. in your app heap, since if you quit without cleanup, theres a dangling
  2192. reference and the machine will crash.
  2193.  
  2194. -James
  2195.  
  2196.  
  2197. +++++++++++++++++++++++++++
  2198.  
  2199. >From kluev@jonathan.srcc.msu.su (Kluev)
  2200. Date: Mon, 22 Aug 94 23:02:46 +0400
  2201. Organization: (none)
  2202.  
  2203. In article <jedavis.777403449@Xenon.Stanford.EDU>
  2204. jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2205.  
  2206. > The jGNE filter *is* active across all apps. The low memory global
  2207. that
  2208. > points to the filter chain, is not changed by context switches. This
  2209. > means you have to be very careful if you install a filter with code
  2210. > in your app heap, since if you quit without cleanup, theres a
  2211. dangling
  2212. > reference and the machine will crash.
  2213.  
  2214. One should be careful about this cleanup. One shouldn't restore
  2215. original value in jGNEFilter, because someone may install gne
  2216. filter on top of one's. Restoring jGNEFilter to original value
  2217. will remove someone's filter and may crash him. The better
  2218. solution is to install one's filter into system heap, never
  2219. remove it, check if filter was already installed (Gestalt is
  2220. one solution) (not to install it twice), set/clear flag on
  2221. application's startup/exit to turn filter's activity on/off.
  2222.  
  2223. Michael Kluev.
  2224.  
  2225. +++++++++++++++++++++++++++
  2226.  
  2227. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  2228. Date: 23 Aug 94 02:50:02 GMT
  2229. Organization: Stanford University: Computer Science Department
  2230.  
  2231. kluev@jonathan.srcc.msu.su (Kluev) writes:
  2232.  
  2233. >In article <jedavis.777403449@Xenon.Stanford.EDU>
  2234. >jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2235.  
  2236. >One should be careful about this cleanup. One shouldn't restore
  2237. >original value in jGNEFilter, because someone may install gne
  2238. >filter on top of one's. Restoring jGNEFilter to original value
  2239. >will remove someone's filter and may crash him. The better
  2240. >solution is to install one's filter into system heap, never
  2241. >remove it, check if filter was already installed (Gestalt is
  2242. >one solution) (not to install it twice), set/clear flag on
  2243. >application's startup/exit to turn filter's activity on/off.
  2244.  
  2245. Yes, that would work but Id rather not leave memory allocated
  2246. in the system heap. But your right about another being installed
  2247. over mine. I allocate a small block in the system heap that just
  2248. jumps to my code in the application heap. When I want to deinstall,
  2249. I check to see if the front jGNEfilter is me. If it is, I can 
  2250. just reset the pointer. If its not, I change my stub to 
  2251. jump to the original address instead of my code. I only end up
  2252. wasting a little system heap that way. I cant claim credit 
  2253. for the technique. I got a snippet from someone else, thought
  2254. it was clever, and used it.
  2255.  
  2256. -James
  2257.  
  2258. +++++++++++++++++++++++++++
  2259.  
  2260. >From h+@nada.kth.se (Jon W{tte)
  2261. Date: Tue, 23 Aug 1994 09:49:02 +0200
  2262. Organization: Royal Institute of Something or other
  2263.  
  2264. In article <jedavis.777610202@Xenon.Stanford.EDU>,
  2265. jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2266.  
  2267. >Yes, that would work but Id rather not leave memory allocated
  2268. >in the system heap. But your right about another being installed
  2269. >over mine. I allocate a small block in the system heap that just
  2270. >jumps to my code in the application heap. When I want to deinstall,
  2271.  
  2272. I hope you remember to flush the cache when you change this 
  2273. value...
  2274.  
  2275. Cheers,
  2276.  
  2277.                 / h+
  2278.  
  2279.  
  2280. --
  2281.   Jon W‰tte (h+@nada.kth.se), Hagagatan 1, 113 48 Stockholm, Sweden
  2282.   "Psychotherapist" - "Phycho-The-Rapist"
  2283.    Pure coincidence? You decide!
  2284.  
  2285.  
  2286. +++++++++++++++++++++++++++
  2287.  
  2288. >From jedavis@Xenon.Stanford.EDU (James Edward Davis)
  2289. Date: 23 Aug 94 22:00:51 GMT
  2290. Organization: Stanford University: Computer Science Department
  2291.  
  2292. h+@nada.kth.se (Jon W{tte) writes:
  2293.  
  2294. >In article <jedavis.777610202@Xenon.Stanford.EDU>,
  2295. >jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2296.  
  2297. >>Yes, that would work but Id rather not leave memory allocated
  2298. >>in the system heap. But your right about another being installed
  2299. >>over mine. I allocate a small block in the system heap that just
  2300. >>jumps to my code in the application heap. When I want to deinstall,
  2301.  
  2302. >I hope you remember to flush the cache when you change this 
  2303. >value...
  2304.  
  2305. Why.. thats an excellent point. I dont flush it, but it seems to
  2306. work fine on my C610. I think Ive been very lucky.. Ill go change
  2307. that. Unless anyone can think of a legit reason its working.
  2308.  
  2309. Thanks,
  2310. James
  2311.  
  2312. +++++++++++++++++++++++++++
  2313.  
  2314. >From kluev@jonathan.srcc.msu.su (Kluev)
  2315. Date: Wed, 24 Aug 94 21:13:06 +0400
  2316. Organization: (none)
  2317.  
  2318. In article <jedavis.777679251@Xenon.Stanford.EDU>
  2319. jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2320.  
  2321. > h+@nada.kth.se (Jon W{tte) writes:
  2322. > >In article <jedavis.777610202@Xenon.Stanford.EDU>,
  2323. > >jedavis@Xenon.Stanford.EDU (James Edward Davis) wrote:
  2324. > >>Yes, that would work but Id rather not leave memory allocated
  2325. > >>in the system heap. But your right about another being installed
  2326. > >>over mine. I allocate a small block in the system heap that just
  2327. > >>jumps to my code in the application heap. When I want to deinstall,
  2328. > >I hope you remember to flush the cache when you change this 
  2329. > >value...
  2330. > Why.. thats an excellent point. I dont flush it, but it seems to
  2331. > work fine on my C610. I think Ive been very lucky.. Ill go change
  2332. > that. Unless anyone can think of a legit reason its working.
  2333.  
  2334. This depends on processor type and what your code is looked like.
  2335.  
  2336. If it is looked like that:
  2337.   JMP Address; 0x4EF9 0x12345678; where 0x12345678 is modified address,
  2338. you need to flush cache on 040 processors.
  2339.  
  2340. If it is looked like this:
  2341.   MOVE.L *+$0006, -(sp); 0x2F3A0004;
  2342.   RTS;                   0x4E75
  2343.   DC.L 0x12345678;       0x12345678; where 0x12345678 is modified addr,
  2344. don't worry about flushing cache. (DC.L will not run as code.)
  2345.  
  2346. /* From MacTech magazine */
  2347.  
  2348. Michael Kluev.
  2349.  
  2350. ---------------------------
  2351.  
  2352. End of C.S.M.P. Digest
  2353. **********************
  2354.  
  2355.  
  2356.