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

  1. Received-Date: Mon, 30 May 1994 14:02:09 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-032
  4. To: csmp-digest@ens.fr
  5. Date: Mon, 30 May 94 14:02:04 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 35
  10.  
  11. C.S.M.P. Digest             Mon, 30 May 94       Volume 3 : Issue 32
  12.  
  13. Today's Topics:
  14.  
  15.         Are there any Disassemblers for Mac?
  16.         Drawing strings vertically.
  17.         I HATE GWorlds!
  18.         Is FSpExchangeFiles still broken?
  19.         Looping sounds
  20.         PPC Toolbox GetDefaultUser() bug
  21.         SU3.0 programming tip
  22.  
  23.  
  24.  
  25. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  26. (pottier@clipper.ens.fr).
  27.  
  28. The digest is a collection of article threads from the internet newsgroup
  29. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  30. regularly and want an archive of the discussions.  If you don't know what a
  31. newsgroup is, you probably don't have access to it.  Ask your systems
  32. administrator(s) for details.  If you don't have access to news, you may
  33. still be able to post messages to the group by using a mail server like
  34. anon.penet.fi (mail help@anon.penet.fi for more information).
  35.  
  36. Each issue of the digest contains one or more sets of articles (called
  37. threads), with each set corresponding to a 'discussion' of a particular
  38. subject.  The articles are not edited; all articles included in this digest
  39. are in their original posted form (as received by our news server at
  40. nef.ens.fr).  Article threads are not added to the digest until the last
  41. article added to the thread is at least two weeks old (this is to ensure that
  42. the thread is dead before adding it to the digest).  Article threads that
  43. consist of only one message are generally not included in the digest.
  44.  
  45. The digest is officially distributed by two means, by email and ftp.
  46.  
  47. If you want to receive the digest by mail, send email to listserv@ens.fr
  48. with no subject and one of the following commands as body:
  49.     help                        Sends you a summary of commands
  50.     subscribe csmp-digest Your Name    Adds you to the mailing list
  51.     signoff csmp-digest            Removes you from the list
  52. Once you have subscribed, you will automatically receive each new
  53. issue as it is created.
  54.  
  55. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  56. Questions related to the ftp site should be directed to
  57. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  58. digest are available there.
  59.  
  60. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  61.  
  62.  
  63. -------------------------------------------------------
  64.  
  65. >From fd ()
  66. Subject: Are there any Disassemblers for Mac?
  67. Date: 13 May 1994 21:31:30 GMT
  68. Organization: Northwestern University, Evanston, IL  USA
  69.  
  70.  
  71. I was wondering... is there a program out there
  72. which can take, say, a CODE or MDEF etc resource and
  73. at the very least, disassemble it into the 680x0 instructions?
  74.  
  75. Even better if it could do more things, like maybe tell you
  76. what toolbox trap a jump was to, etc.
  77.  
  78. Does Macsbug let you do this?
  79.  
  80. any info/comments would be greatly appreciated on this or
  81. any other tool that helps you dissect code.
  82.  
  83. many thanks in advance,
  84. usman
  85.  
  86. +++++++++++++++++++++++++++
  87.  
  88. >From ray@netcom.com (Ray Fischer)
  89. Date: Sat, 14 May 1994 03:18:50 GMT
  90. Organization: Netcom. San Jose, California
  91.  
  92. fd () writes ...
  93. >I was wondering... is there a program out there
  94. >which can take, say, a CODE or MDEF etc resource and
  95. >at the very least, disassemble it into the 680x0 instructions?
  96.  
  97. Yes, and a nice (and free) tool it is, too.
  98.  
  99. Look for the CODE editor for ResEdit.  It disassembles most code
  100. resource types and has some nifty features.  It's probably on
  101. ftp.apple.com or sumex.stanford.edu (or one of its mirror sites).
  102.  
  103. -- 
  104. Ray Fischer          "Men become civilized, not in proportion to their
  105. ray@netcom.com        willingness to believe, but in their readiness
  106.                       to doubt."  -- H. L. Mencken
  107.  
  108. +++++++++++++++++++++++++++
  109.  
  110. >From kenlong@netcom.com (Ken Long)
  111. Date: Sat, 14 May 1994 07:16:29 GMT
  112. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  113.  
  114. The ResEdit 'CODE' editor is good.  Once installed (the resources pasted 
  115. into ResEdit's pref's file) it will open a disassembled representation of 
  116. the 'CODE' resources by double-clicking on the resource in the picker 
  117. window.  You can't edit from within the disassble window - you must open 
  118. the ID with the hex editor to do that.  but the "edit" window is great 
  119. for navigating and "tree climbing" through the program.  It does jumps 
  120. within the 'CODE' resource - even ID to ID.
  121.  
  122. If you want the port output in a text file, you have to copy/paste 
  123. (unless someone knows of another way).  I do this by opening the editor 
  124. window, clicking in pageDown 18 times (LC/10MB/12"monitor) then holding 
  125. down shift and clicking once in the hex at the screen right.  Then 
  126. copy to clip.  Then I click in a new Think C editor window I already had 
  127. set up and paste into it.  Save, then click in the 'CODE' editor window 
  128. anh hit right-arrow once.  Then hit pageDown 18 more times.  Any more and 
  129. ResEdit barfs up a "can't" alert.
  130.  
  131. Continue this sequence until you are at the end.
  132.  
  133. Faster and easier, but less elegant output, is DisAsm 3.1.  You open the 
  134. file, select the resource (default is 'CODE' and you can save output to a 
  135. text file.
  136.  
  137. A few notches above this is RSC_Viewer II.  I will save a 'CODE' ID at a 
  138. time to a text file.  The output is closest to ResEdit output.
  139.  
  140. Then the big-money diassembler is MacNosy.  It does a better job at a lot 
  141. of things than other disassemblers, but a lousy job at some things.  it 
  142. leaves out most of the "(sp)" ((A7))s and puts "PUSH" and "POP" in where 
  143. others (including ResEdit) put something else.  But it lists generic 
  144. variables and parameters before the routines they go in, which no other 
  145. disassembler I've seen does.  Not as good as "short one, two, three" but 
  146. just the fact that it has locals or parameters, their order and size.  
  147. Better than nothing.
  148.  
  149. It also lists out globals in a similar way.  I've set Think C to generate 
  150. a map during a build, built the app., ran it through Nosy and compared 
  151. the map with the Nosy output.  It tracks.  Of course, I have a lot to 
  152. learn, so it may provide more info than I can see.
  153.  
  154. Nosy also extracts strings, and says where in the code they go.
  155.  
  156. When I got the asm source for Orion, I ran Orion through Nosy and it 
  157. tracked exactly with the source.  I did not get the star table when I 
  158. first got the source, so I made them with what I got out of Nosy output.  
  159. Then, later, when I did get them, and compared them with the ones I made, 
  160. they were the same.  Cool!
  161.  
  162. Those four are the main ones.  The MPW disassembler, I'm told, was used 
  163. as the basis for the ResEdit 'CODE' editor.
  164.  
  165. I have some MSQBasic source for an old console dumping disassembler.  
  166. It's not a hex dumper, but outputs instructions and operands.  I'd like 
  167. to get some C source for one.
  168.  
  169. That's about it - those 5.  ResEdit, DisAsm 3.1, RSC_Viewer II, MPW and 
  170. MacNosy.  There may be more I've not seen.
  171.  
  172. -Ken-
  173.  
  174. +++++++++++++++++++++++++++
  175.  
  176. >From Vampire@crypt.demon.co.uk (Vampire)
  177. Date: Sat, 14 May 1994 16:25:37 GMT
  178. Organization: Pennangalan Software
  179.  
  180.  
  181. In article <fd-130594162741@cmac177.acns.nwu.edu> fd () writes:
  182. >
  183. >I was wondering... is there a program out there
  184. >which can take, say, a CODE or MDEF etc resource and
  185. >at the very least, disassemble it into the 680x0 instructions?
  186. >
  187. >Even better if it could do more things, like maybe tell you
  188. >what toolbox trap a jump was to, etc.
  189. >
  190. Yes, there is a Disassembler extension for ResEdit 2.1 that does everything you
  191. mention.
  192.  
  193. Vampire
  194.  
  195. =============================================================================
  196.                                   |"If I knock on your door, you're a fool;
  197.          VAMPIRE                  | if you invite me in, you're a dead fool"
  198.   (Pennangalan Software)          |  My dust resides @crypt.demon.co.uk
  199. =============================================================================
  200.  
  201. +++++++++++++++++++++++++++
  202.  
  203. >From peirce@outpost.SF-Bay.org (Michael Peirce)
  204. Date: Sat, 14 May 94 15:52:12 PST
  205. Organization: Peirce Software, Inc.
  206.  
  207.  
  208. In article <fd-130594162741@cmac177.acns.nwu.edu> (comp.sys.mac.programmer), fd () writes:
  209. > I was wondering... is there a program out there
  210. > which can take, say, a CODE or MDEF etc resource and
  211. > at the very least, disassemble it into the 680x0 instructions?
  212. > Even better if it could do more things, like maybe tell you
  213. > what toolbox trap a jump was to, etc.
  214. > Does Macsbug let you do this?
  215. > any info/comments would be greatly appreciated on this or
  216. > any other tool that helps you dissect code.
  217.  
  218. Two come to mind:
  219.  
  220. (1) ResEdit has a CODE editor (really a viewer) that disassembles
  221. CODE, INIT, WDEF, and more code resources.  It's pretty god really.
  222.  
  223. (2) MacNosey from Jasik Designs.  This is the industrial strength
  224. disassembler.  It it invaluable if you are really going to, err, well,
  225. I'll say it, reverse engineer something :-)
  226.  
  227. __ Michael Peirce        __ peirce@outpost.sf-bay.org
  228. __ Peirce Software, Inc. __ 719 Hibiscus Place, Suite 301
  229. __                       __ San Jose, California USA 95117-1844
  230. __ Makers of: Smoothie & __ voice: +1.408.244.6554 fax: +1.408.244.6882
  231. __    Peirce Print Tools __ AppleLink: peirce & AOL: AFC Peirce
  232.  
  233. ---------------------------
  234.  
  235. >From kenlong@netcom.com (Ken Long)
  236. Subject: Drawing strings vertically.
  237. Date: Sat, 14 May 1994 22:09:15 GMT
  238. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  239.  
  240. /* 
  241. This is a little thing I tossed together when I saw a c.s.m.p.
  242. message requesting source for writing vertical text.  There may have 
  243. been a reply I missed, but if not, this source will do.
  244.  
  245. Add MacTraps and ANSI (for strlen) and you're cookin'  The vertical
  246. text routine came from the SplatMaster Pascal source, by Jon Benton, 
  247. which I'm porting to Think C.  It doesn't totally run yet, otherwise
  248. I'd post it, too (though not here).
  249.  
  250. Anyway, as stated below, vertical strings are excellent for scroll
  251. labels, as well as about box goodies, vertical progress bars, etc.
  252.  
  253. Enjoy!
  254. */
  255.  
  256. // VerticalText.c
  257.  
  258. MenuHandle    appleMenu, fileMenu, editMenu;
  259.  
  260. enum {
  261.     appleID = 1,
  262.     fileID,
  263.     editID
  264. };
  265.  
  266. enum {
  267.     openItem = 1,
  268.     closeItem,
  269.     quitItem = 4
  270. };
  271.  
  272.  
  273. WindowPtr    genericWindow;
  274. Rect        dragRect;
  275. Rect        windowBounds = { 20, 0, 384, 512}; 
  276. Rect        strRect ={5, 20, 364, 40};
  277. int            width = 1;
  278.  
  279. // Prototypes.
  280.  
  281. void    SetUpWindow (void);
  282. void    DrawTheStrings (short active);
  283. void    SetUpMenus (void);
  284. void    AdjustMenus (void);
  285. static    enable (MenuHandle menu, short item, short ok);
  286. void    HandleMenu (long mSelect);
  287. void    InitMacintosh (void);
  288. void    HandleMouseDown (EventRecord *theEvent);
  289. void    HandleEvent (void);
  290. int        main (void);
  291.  
  292. void SetUpWindow (void)
  293. {
  294.     dragRect = qd.screenBits.bounds;
  295.     
  296.     genericWindow = NewWindow (0L, &windowBounds, "\pWhat about it?", true, noGrowDocProc, (WindowPtr) -1L, true, 0);
  297.     SetPort (genericWindow);
  298. }
  299.  
  300. void SetUpMenus (void)
  301. {
  302.     InsertMenu (appleMenu = NewMenu (appleID, "\p\024"), 0);
  303.     InsertMenu (fileMenu = NewMenu (fileID, "\pFile"), 0);
  304.     InsertMenu (editMenu = NewMenu (editID, "\pEdit"), 0);
  305.     DrawMenuBar ();
  306.     AddResMenu (appleMenu, 'DRVR');
  307.     AppendMenu (fileMenu, "\pOpen/O;Close/W;(-;Quit/Q");
  308.     AppendMenu (editMenu, "\pUndo/Z; (-;Cut/X;Copy/C;Paste/V;Clear");
  309. }
  310.  
  311. void VerticalString (Rect word_rect, Str255 word_string)
  312. {
  313.     #define center 5    // center of label is 'center' pixels from left of rect.
  314.     
  315.     short numChars, leading, stringCenter, x, curVert;
  316.     FontInfo fInfo;
  317.  
  318.     TextFont (monaco);
  319.     TextSize (9);
  320.     TextFace (0);
  321.     GetFontInfo (&fInfo);
  322.     leading = fInfo.ascent + fInfo.descent + fInfo.leading;
  323.     stringCenter = word_rect.left - center;
  324.  
  325. //    ForeColor (redColor);    // oldStyle color.
  326.     curVert = word_rect.top + leading;    // primed for first character.
  327.     numChars = strlen (word_string);
  328.     for (x = 1; x < numChars; x++)
  329.     {
  330.         MoveTo (stringCenter - (CharWidth (word_string[x]) / 2), 
  331.                 curVert);
  332.         DrawChar ((char) word_string[x]);
  333.         curVert = curVert + leading;
  334.     }
  335. //    ForeColor (blackColor);    // oldStyle color.
  336. }    // VerticalString.
  337.  
  338. void DrawTheStrings (short active)
  339. {
  340.     int        color = true;
  341.     
  342.     SetPort (genericWindow);
  343.     
  344.     VerticalString (strRect, "\pMy name is Long but this is ");
  345.     OffsetRect (&strRect, 20, 0);
  346.     VerticalString (strRect, "\pnot Chinese writing.");
  347.     
  348.     OffsetRect (&strRect, 40, 0);
  349.     VerticalString (strRect, "\pSuperman\0");
  350.     OffsetRect (&strRect, 20, 0);
  351.     VerticalString (strRect, "\pStrange visitor\0");
  352.     OffsetRect (&strRect, 20, 0);
  353.     VerticalString (strRect, "\pfrom another planet\0");
  354.     OffsetRect (&strRect, 20, 0);
  355.     VerticalString (strRect, "\pwho came to Earth  beyond\0");
  356.     OffsetRect (&strRect, 20, 0);
  357.     VerticalString (strRect, "\pwith powers and abilities far\0");
  358.     OffsetRect (&strRect, 20, 0);
  359.     VerticalString (strRect, "\pbeyond those of mortal men.\0");
  360.     
  361.     OffsetRect (&strRect, 40, 0);
  362.     VerticalString (strRect, "\pThe VerticalString Routine was\0");
  363.     OffsetRect (&strRect, 20, 0);
  364.     VerticalString (strRect, "\ptaken from 'SplatMaster' Pascal\0");
  365.     OffsetRect (&strRect, 20, 0);
  366.     VerticalString (strRect, "\psource code. It was ported to\0");
  367.     OffsetRect (&strRect, 20, 0);
  368.     VerticalString (strRect, "\pThink C by Kenneth A. Long in\0");
  369.     OffsetRect (&strRect, 20, 0);
  370.     VerticalString (strRect, "\pmid 1992 and put into this demo\0");
  371.     OffsetRect (&strRect, 20, 0);
  372.     VerticalString (strRect, "\pin May of 1994 for YOUR use and\0");
  373.     OffsetRect (&strRect, 20, 0);
  374.     VerticalString (strRect, "\p enjoyment.  Please do so!\0");
  375.     OffsetRect (&strRect, 40, 0);
  376.     VerticalString (strRect, "\pVertical strings are excellent\0");
  377.     OffsetRect (&strRect, 20, 0);
  378.     VerticalString (strRect, "\pfor labeling vertical scrolls.\0");
  379.     OffsetRect (&strRect, 40, 0);
  380.     VerticalString (strRect, "\pBullseye was used for the shell.\0");
  381.     OffsetRect (&strRect, 20, 0);
  382.     VerticalString (strRect, "\pJon Benton wrote SplatMaster.\0");
  383.     OffsetRect (&strRect, 20, 0);
  384.     VerticalString (strRect, "\pVertical String Demo is PD.\0");
  385. }
  386.  
  387. void AdjustMenus (void)
  388. {
  389.     register WindowPeek wp = (WindowPeek) FrontWindow ();
  390.     short kind = wp ? wp->windowKind : 0;
  391.     Boolean DA = kind < 0;
  392.     
  393.     enable (editMenu, 1, DA);
  394.     enable (editMenu, 3, DA);
  395.     enable (editMenu, 4, DA);
  396.     enable (editMenu, 5, DA);
  397.     enable (editMenu, 6, DA);
  398.     
  399.     enable (fileMenu, openItem, ! ((WindowPeek) genericWindow)->visible);
  400.     enable (fileMenu, closeItem, DA || ((WindowPeek) genericWindow)->visible);
  401. }
  402.  
  403. static enable (MenuHandle menu, short item, short ok)
  404. {
  405.     if (ok)
  406.         EnableItem (menu, item);
  407.     else
  408.         DisableItem (menu, item);
  409. }
  410.  
  411. void HandleMenu (long mSelect)
  412. {
  413.     int            menuID = HiWord (mSelect);
  414.     int            menuItem = LoWord (mSelect);
  415.     Str255        name;
  416.     GrafPtr        savePort;
  417.     WindowPeek    frontWindow;
  418.     
  419.     switch (menuID)
  420.     {
  421.         case    appleID:
  422.             GetPort (&savePort);
  423.             GetItem (appleMenu, menuItem, name);
  424.             OpenDeskAcc (name);
  425.             SetPort (savePort);
  426.         break;
  427.         
  428.         case    fileID:
  429.             switch (menuItem)
  430.             {
  431.                 case    openItem:
  432.                     ShowWindow (genericWindow);
  433.                     SelectWindow (genericWindow);
  434.                 break;
  435.                               
  436.                 case    closeItem:
  437.                     if ((frontWindow = (WindowPeek) FrontWindow ()) == 0L)
  438.                 break;
  439.             
  440.                 if (frontWindow->windowKind < 0)
  441.                     CloseDeskAcc (frontWindow->windowKind);
  442.                 else 
  443.                     if (frontWindow = (WindowPeek) genericWindow)
  444.                         HideWindow (genericWindow);
  445.                       break;
  446.                       
  447.                 case    quitItem:
  448.                     ExitToShell ();
  449.                 break;
  450.             }
  451.         break;
  452.                   
  453.         case    editID:
  454.             if (!SystemEdit (menuItem-1))
  455.                 SysBeep (5);
  456.         break;
  457.     }
  458. }
  459.  
  460. void InitMacintosh (void)
  461. {
  462.     MaxApplZone ();
  463.     
  464.     InitGraf (& (qd.thePort));
  465.     InitFonts ();
  466.     FlushEvents (everyEvent, 0);
  467.     InitWindows ();
  468.     InitMenus ();
  469.     TEInit ();
  470.     InitDialogs (0L);
  471.     InitCursor ();
  472. }
  473.  
  474. void HandleMouseDown (EventRecord    *theEvent)
  475. {
  476.     WindowPtr    theWindow;
  477.     int            windowCode = FindWindow (theEvent->where, &theWindow);
  478.     
  479.     switch (windowCode)
  480.     {
  481.         case inSysWindow: 
  482.             SystemClick (theEvent, theWindow);
  483.         break;
  484.     
  485.         case inMenuBar:
  486.             AdjustMenus ();
  487.             HandleMenu (MenuSelect (theEvent->where));
  488.         break;
  489.     
  490.         case inDrag:
  491.             if (theWindow == genericWindow)
  492.                 DragWindow (genericWindow, theEvent->where, &dragRect);
  493.         break;
  494.         
  495.         case inContent:
  496. //            if (theWindow == genericWindow)
  497. //            {
  498. //                if (theWindow != FrontWindow ())
  499. //                    SelectWindow (genericWindow);
  500. //                else
  501. //                    InvalRect (&genericWindow->portRect);
  502. //            }
  503.         break;
  504.         
  505.         case inGoAway:
  506.             if (theWindow == genericWindow && 
  507.                 TrackGoAway (genericWindow, theEvent->where))
  508.                 HideWindow (genericWindow);
  509.         break;
  510.     }
  511. }
  512.  
  513. void HandleEvent (void)
  514. {
  515.     int            ok;
  516.     EventRecord    theEvent;
  517.  
  518.     HiliteMenu (0);
  519.     SystemTask ();        /* Handle desk accessories */
  520.     
  521.     ok = GetNextEvent (everyEvent, &theEvent);
  522.     if (ok)
  523.     switch (theEvent.what)
  524.     {
  525.         case mouseDown:
  526.             HandleMouseDown (&theEvent);
  527.         break;
  528.             
  529.         case keyDown: 
  530.         case autoKey:
  531.         if ((theEvent.modifiers & cmdKey) != 0)
  532.         {
  533.             AdjustMenus ();
  534.             HandleMenu (MenuKey ((char) (theEvent.message & charCodeMask)));
  535.         }
  536.         break;
  537.             
  538.         case updateEvt:
  539.             BeginUpdate (genericWindow);
  540.             DrawTheStrings (((WindowPeek) genericWindow)->hilited);
  541.             EndUpdate (genericWindow);
  542.         break;
  543.         
  544.         case activateEvt:
  545.             InvalRect (&genericWindow->portRect);
  546.         break;
  547.     }
  548. }
  549.  
  550. main ()
  551. {
  552.     InitMacintosh ();
  553.     SetUpMenus ();
  554.     SetUpWindow ();
  555.     
  556.     for (;;)
  557.         HandleEvent ();
  558. }
  559.  
  560.  
  561. +++++++++++++++++++++++++++
  562.  
  563. >From kenlong@netcom.com (Ken Long)
  564. Date: Sun, 15 May 1994 06:16:46 GMT
  565. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  566.  
  567. I don't care how many times I check it, a typo manages to get through.  
  568. Must be old-timer's disease creaping in!
  569.  
  570. The quote is:
  571.  
  572. "Superman!  Strange visitor, from another planet, who came to Earth with 
  573. powers and abilities far beyond those of mortal men."
  574.  
  575. (no "beyond" after "Earth")
  576.  
  577. -Ken-  :|
  578.  
  579.  
  580. ---------------------------
  581.  
  582. >From mprince@mail.trincoll.edu (Matthew Prince)
  583. Subject: I HATE GWorlds!
  584. Date: 5 May 1994 05:21:30 GMT
  585. Organization: Trinity College
  586.  
  587. I'm confused.  I thought that I'd venture into the world of Offscreen
  588. GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  589. that everything would be nice and easy.  I thought that I could have
  590. everything working in a few days, and if not, I could figure out what
  591. was wrong easily.  I was wrong.  I've set up an offscreen GWorld that
  592. has the same dimensions as my on screen window.  I think that it's set
  593. up correctly because the first time that I CopyBits from it everything
  594. works fine.  And if I CopyBits a simple image it works fine too.  But
  595. when I try to CopyBits a complex image from it once, and then change
  596. the image slightly and try to CopyBits it again, it looks as if someone
  597. has taken a shotgun to the image.  I'd say about half the pixels are
  598. there.  And while it's in the same basic shape and color of the
  599. original image, it looks as if it's had a bunch of information lost. 
  600. I'm confused.  It's late.  I'm sure this is a stupid question.  Please
  601. forgive me.  But if anyone has any idea what is going on, I'd
  602. appreciate any help they could lend.
  603.  
  604. Thanks,
  605. Matthew Prince
  606. mprince@mail.trincoll.edu
  607.  
  608. +++++++++++++++++++++++++++
  609.  
  610. >From Thomas Reed <reed@medicine.wustl.edu>
  611. Date: 6 May 1994 14:08:26 GMT
  612. Organization: Washington University
  613.  
  614. In article <2q9voq$nt1@yar.trincoll.edu> Matthew Prince,
  615. mprince@mail.trincoll.edu writes:
  616. >I'm confused.  I thought that I'd venture into the world of Offscreen
  617. >GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  618. >that everything would be nice and easy.  I thought that I could have
  619. >everything working in a few days, and if not, I could figure out what
  620. >was wrong easily.  I was wrong.
  621.  
  622. You bet!  And you were using GWorlds -- try it with offscreen GrafPorts! 
  623. It took me two years to find information on how to do it with GrafPorts. 
  624. Of course, this was before I had access to all the wonderful information
  625. on the Internet!  So things were harder to find back then...
  626.  
  627. Anyway, I'm not sure what's going wrong with your code, but here's some
  628. source code to look at.  First, here's what I do when I want to transfer
  629. from an offscreen GWorld to an onscreen window:
  630.  
  631.     UseOffWorld(gGeneralWorld);
  632.     EraseRect(&thePort->portRect);
  633.     /* do some drawing in the offscreen GWorld */
  634.     DoneWithOffWorld(gGeneralWorld);
  635.     CopyBits(*GetGWorldPixMap(gGeneralWorld), &myWind->portBits,
  636. &myWind->portRect, &myWind->portRect, srcCopy, myWind->visRgn);
  637.  
  638. Now, many of you may not recognize the UseOffWorld and DoneWithOffWorld
  639. calls.  They're in a custom library I've written that contains code for
  640. both GWorlds and for GrafPorts.  I'll stick the entire library at the end
  641. of this message.
  642.  
  643. Hope this helps!
  644.  
  645. -Thomas
  646.  
  647. - ------- begin offscreen library ---------
  648. #define NIL        0L
  649.  
  650. /* for BitMap calls */
  651. #define kIsVisible TRUE
  652. #define kNoGoAway FALSE
  653. #define kNoWindowStorage 0L
  654. #define kFrontWindow ((WindowPtr) -1L)
  655.  
  656.  
  657. GDHandle        gOldDevice;
  658. CGrafPtr        gOldPort;
  659.  
  660. void UseOffWorld(GWorldPtr offWorlder);
  661.   /* call before drawing to offscreen GWorld */
  662. void DoneWithOffWorld(GWorldPtr offWorlder);
  663.   /* call after drawing to offscreen GWorld, before CopyBits */
  664. Boolean CreateOffscreenBitMap(GrafPtr *, Rect *);
  665. void DestroyOffscreenBitMap(GrafPtr);
  666.  
  667. void UseOffWorld(GWorldPtr offWorlder)
  668. {
  669.   GetGWorld(&gOldPort, &gOldDevice);
  670.   LockPixels(GetGWorldPixMap(offWorlder));
  671.   SetGWorld(offWorlder, NIL);
  672. }
  673.  
  674. void DoneWithOffWorld(GWorldPtr offWorlder)
  675. {
  676.   UnlockPixels(GetGWorldPixMap(offWorlder));
  677.   SetGWorld(gOldPort, gOldDevice);
  678. }
  679.  
  680. /* === BitMap routines === */
  681.  
  682. Boolean CreateOffscreenBitMap(GrafPtr *newOffscreen, Rect *inBounds)
  683. {
  684.   GrafPtr savePort;
  685.   GrafPtr newPort;
  686.  
  687.   GetPort(&savePort); /* need this to restore thePort after OpenPort */
  688.  
  689.   newPort = (GrafPtr)NewPtr(sizeof(GrafPort));/* allocate the grafPort */
  690.   if(MemError() != noErr)
  691.     return FALSE;                                            
  692.     /* failure to allocate off-screen port */
  693.  
  694.     /*    the call to OpenPort does the following:
  695.  
  696.         allocates space for visRgn (set to screenBits.bounds)
  697.         and clipRgn (set wide open)
  698.         sets portBits to screenBits
  699.         sets portRect to screenBits.bounds
  700.         etc. (see Inside Macintosh Volume 1 pages 163-164)
  701.         side effect: does a SetPort (&offScreen)
  702.     */
  703.  
  704.   OpenPort(newPort);
  705.  
  706.   /* make bitmap the size of the bounds that caller supplied */
  707.   newPort->portRect = *inBounds;
  708.   newPort->portBits.bounds = *inBounds;
  709.   RectRgn(newPort->clipRgn, inBounds);
  710.   RectRgn(newPort->visRgn, inBounds);
  711.   /* rowBytes is size of row, must be rounded up to an even number of
  712. bytes */
  713.  
  714.   newPort->portBits.rowBytes = ((inBounds->right - inBounds->left + 15)
  715. >> 4) << 1;
  716.  
  717.   /* number of bytes in BitMap is rowBytes * number of rows */
  718.   /* see notes at end of example about using NewPtr instead of NewHandle
  719. */
  720.   newPort->portBits.baseAddr = 
  721.     NewPtr(newPort->portBits.rowBytes * (long)(inBounds->bottom -
  722. inBounds->top));
  723.  
  724.   if(MemError() != noErr)
  725.   {
  726.     SetPort(savePort);
  727.     ClosePort(newPort);            /* dump the visRgn and clipRgn */
  728.     DisposPtr((Ptr)newPort);    /* dump the GrafPort */
  729.     return FALSE;    /* tell caller we failed */
  730.   }
  731.  
  732.   /* since the bits are just memory, let's clear them before we start */
  733.   EraseRect(inBounds);/* OpenPort did a SetPort(newPort) so we are OK*/
  734.   *newOffscreen = newPort;
  735.   SetPort(savePort);
  736.   return TRUE;                        /* success */
  737. }
  738.  
  739. /*
  740.     DestroyOffscreenBitMap - get rid of an off-screen bitmap created
  741.     by CreateOffscreenBitMap
  742. */
  743. void DestroyOffscreenBitMap(GrafPtr oldOffscreen)
  744. {
  745.   ClosePort(oldOffscreen);            /* dump the visRgn and clipRgn */
  746.   DisposPtr(oldOffscreen->portBits.baseAddr);    /* dump the bits */
  747.   DisposPtr((Ptr)oldOffscreen);            /* dump the port */
  748. }
  749. - ------- end offscreen library ----------
  750. =====================================================
  751. Thomas Reed                    Washington University
  752. Reed@telesphere.wustl.edu          Medical School
  753. (also:  Reed@medicine.wustl.edu)
  754. - ---------------------------------------------------
  755. Clothes make the man.  Naked people have little or no
  756. influence on society.  -- Mark Twain
  757. =====================================================
  758.  
  759. +++++++++++++++++++++++++++
  760.  
  761. >From tgaul@halcyon.com (Troy Gaul)
  762. Date: 9 May 1994 05:10:25 GMT
  763. Organization: Infinity Systems
  764.  
  765. In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  766. (Matthew Prince) wrote:
  767.  
  768. > I'm confused.  I thought that I'd venture into the world of Offscreen
  769. > GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  770. > that everything would be nice and easy.  I thought that I could have
  771. > everything working in a few days, and if not, I could figure out what
  772. > was wrong easily.  I was wrong.  I've set up an offscreen GWorld that
  773. > has the same dimensions as my on screen window.  I think that it's set
  774. > up correctly because the first time that I CopyBits from it everything
  775. > works fine.  And if I CopyBits a simple image it works fine too.  But
  776. > when I try to CopyBits a complex image from it once, and then change
  777. > the image slightly and try to CopyBits it again, it looks as if someone
  778. > has taken a shotgun to the image.  I'd say about half the pixels are
  779. > there.  And while it's in the same basic shape and color of the
  780. > original image, it looks as if it's had a bunch of information lost. 
  781. > I'm confused.  It's late.  I'm sure this is a stupid question.  Please
  782. > forgive me.  But if anyone has any idea what is going on, I'd
  783. > appreciate any help they could lend.
  784.  
  785. Just to make sure this isn't the case (I don't have the New Inside Mac here
  786. to look at to see what they say about the topic):  Are you locking the
  787. GWorld's pixel map before calling CopyBits?
  788.  
  789. Also, when modifying the image between CopyBits's, are you setting and
  790. resetting the GWorld (with Get/SetGWorld)?
  791.  
  792. GWorld's really aren't that bad once you get all of these little things
  793. worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  794.  
  795. _troy
  796.  
  797. +++++++++++++++++++++++++++
  798.  
  799. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  800. Date: Wed, 11 May 1994 18:41:07 GMT
  801. Organization: Apple Computer
  802.  
  803. Matthew Prince, mprince@mail.trincoll.edu writes:
  804. > I'm confused.  I thought that I'd venture into the world of Offscreen
  805. > GWorld drawing with my new copy of Inside Macintosh Imaging.  I thought
  806. > that everything would be nice and easy.  I thought that I could have
  807. > everything working in a few days, and if not, I could figure out what
  808. > was wrong easily.  I was wrong.
  809.  
  810. Matthew, for the crime of dissing GWorlds I sentence you to write offscreen
  811. color graphics code _without_ using them. (I did it once, with help from
  812. Andrew Welch. I could post some source code that would curl your hair!)
  813.  
  814. Mistakes you might be making:
  815. - Don't make assumptions about the rowBytes of the offscreen data. It often
  816. gets rounded up for efficiency. Get the rowBytes out of the pixMap and use
  817. that in all your calculations.
  818. - If you're groping into the pixel data (which is fine) make sure to do your
  819. math with longints, as things can overflow 32k pretty quickly.
  820. - Remember that the pixel data is in a handle and can move around unless you
  821. lock it down with the appropriate calls.
  822. - When drawing, you must be set to the graphics world of the destination or
  823. colors will map wrong. I.e. SetGWorld to your offscreen world when drawing to
  824. it, and SetGWorld back to the screen when drawing to the screen from your
  825. offscreen world.
  826.  
  827. I think once you figure out what mistake you're making, you'll find that
  828. GWorlds are actually pretty easy to use.
  829.  
  830. --Jens Alfke
  831.   jens_alfke@powertalk              Rebel girl, rebel girl,
  832.             .apple.com              Rebel girl you are the queen of my world
  833.  
  834. +++++++++++++++++++++++++++
  835.  
  836. >From dwareing@apanix.apana.org.au (David Wareing)
  837. Date: 10 May 94 15:28:23 GMT
  838. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  839.  
  840. tgaul@halcyon.com (Troy Gaul) writes:
  841.  
  842. >In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  843. >(Matthew Prince) wrote:
  844.  
  845. <tale of CopyBits woe from original poster deleted>
  846.  
  847. >Just to make sure this isn't the case (I don't have the New Inside Mac here
  848. >to look at to see what they say about the topic):  Are you locking the
  849. >GWorld's pixel map before calling CopyBits?
  850.  
  851. I may be utterly wrong on this, and someone please correct me if I am, but
  852. I believe that CopyBits locks the PixMaps for you. But still, I guess its
  853. good programming practice to lock them anyway.
  854.  
  855. >Also, when modifying the image between CopyBits's, are you setting and
  856. >resetting the GWorld (with Get/SetGWorld)?
  857.  
  858. My money's on this one. Either that or the wrong rects are inadvertently
  859. being used after the GWorld PixMap has been altered, and CopyBits is
  860. scaling the image or otherwise screwing it up.
  861.  
  862. >GWorld's really aren't that bad once you get all of these little things
  863. >worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  864.  
  865. Dead right. There's a hell of a lot more things to go wrong if you had to
  866. create and maintain your offscreen PixMaps by yourself. In fact, the only
  867. real obstacle to learning to use GWorlds is learning to use CopyBits
  868. properly first. In comparison, GWorlds are a breeze and easily one of the
  869. best things Apple ever came up with in the graphics dept.
  870.  
  871. --
  872. David Wareing
  873. Adelaide, South Australia
  874. Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  875. - --------------------------------------------------------------------
  876.  
  877. +++++++++++++++++++++++++++
  878.  
  879. >From forrest@hprnd.rose.hp.com (Forrest Tanaka)
  880. Date: 16 May 1994 15:45:48 GMT
  881. Organization: Hewlett-Packard, Roseville Networks Division
  882.  
  883. In article <dwareing.768583703@apanix.apana.org.au>
  884. dwareing@apanix.apana.org.au (David Wareing) writes:
  885.  
  886. > tgaul@halcyon.com (Troy Gaul) writes:
  887. > >In article <2q9voq$nt1@yar.trincoll.edu>, mprince@mail.trincoll.edu
  888. > >(Matthew Prince) wrote:
  889. > >Just to make sure this isn't the case (I don't have the New Inside Mac here
  890. > >to look at to see what they say about the topic):  Are you locking the
  891. > >GWorld's pixel map before calling CopyBits?
  892. > I may be utterly wrong on this, and someone please correct me if I am, but
  893. > I believe that CopyBits locks the PixMaps for you. But still, I guess its
  894. > good programming practice to lock them anyway.
  895. >
  896.  
  897.     There are two issues here.  One is locking the GWorld's pixels, and
  898. one is locking the GWorld's PixMap.  You *must* lock a GWorld's pixels
  899. before drawing into a GWorld, but you probably don't have to lock a
  900. GWorld's PixMap at any time.
  901.  
  902.     You must lock a GWorld's pixels because the pixel image of every
  903. GWorld is created as a relocatable block that's MoveHHi'd right after
  904. allocation.  It just floats there like any other handle until you call
  905. LockPixels which locks the pixel image wherever it is in memory so that
  906. you can draw into it.  As soon as you feel you're done drawing into it
  907. for now, you call UnlockPixels so that it can move in memory again. 
  908. Remember, pixel images can be *very* big if you ask for a big GWorld,
  909. so don't be surprised if you find big delays as your pixel image is
  910. moved around.  There might be times that you want to lock your pixel
  911. images just to be sure 10MB doesn't have to be moved in memory when you
  912. don't want it to.
  913.  
  914.     You probably don't ever have to lock a GWorld's PixMap, nor any
  915. PixMap for that matter.  Color QuickDraw was designed so that you never
  916. have to lock a PixMap--all Color QuickDraw drawing routines expect that
  917. they're unlocked, so they do what they can to avoid moving them at a
  918. bad time.  When I was in Apple DTS, I did find a bug where CopyBits had
  919. a very small but potential chance to move a PixMap structure and not
  920. take the fact that it moved into account.  This can only happen if you
  921. have a Picture open at the time.  I don't know if this was ever fixed. 
  922. If you want to experiment with this one, try a simple program with heap
  923. scramble on in your low-level debugger of choice.
  924.  
  925. > >GWorld's really aren't that bad once you get all of these little things
  926. > >worked out.  Keep at it.  You'll be glad you did. (And good luck.)
  927. > Dead right. There's a hell of a lot more things to go wrong if you had to
  928. > create and maintain your offscreen PixMaps by yourself. In fact, the only
  929. > real obstacle to learning to use GWorlds is learning to use CopyBits
  930. > properly first. In comparison, GWorlds are a breeze and easily one of the
  931. > best things Apple ever came up with in the graphics dept.
  932. >
  933.  
  934.     I third that--it's more than worth it to try to get GWorld's
  935. working.  Having seen the source code to GWorlds, I can assure you that
  936. they're not that magic if you don't have a QuickDraw accelerator card,
  937. and they're really fast if you do.  If you use GWorlds, you can save
  938. yourself a lot of coding.
  939.  
  940.  
  941. > --
  942. > David Wareing
  943. > Adelaide, South Australia
  944. > Mac Games & Multimedia Development        dwareing@apanix.apana.org.au
  945. > ----------------------------------------------------------------------
  946.  
  947.  
  948. -- Forrest Tanaka
  949. Hewlett-Packard, Roseville Networks Division
  950. Speaking on behalf of myself.
  951.  
  952. ---------------------------
  953.  
  954. >From partingt@fwi.uva.nl (Vincent Partington)
  955. Subject: Is FSpExchangeFiles still broken?
  956. Date: 13 May 1994 11:43:39 GMT
  957. Organization: FWI, University of Amsterdam
  958.  
  959. Hi,
  960.  
  961. I got a code-snippet from umich-mac last week which contains some code to
  962. do FSpExchangeFiles for volumes that don't support it (CAP a.o.).
  963. It came with a message from Jim Luther to Jon W{tte in which Jim said
  964. FSpExchangeFiles was broken on some third-party servers (and AU/X?) so
  965. he advised you to program around this bug with the code he supplied.
  966. I don't like cramming large bits of code into my program to fix a bug in the
  967. System software (just like the System shouldn't work around bugs of known
  968. programs...) so my questions is: is all this still necessary?
  969.  
  970. Vincent.
  971. -- 
  972. My opinions are not my own. I copy them    | Internet : partingt@fwi.uva.nl
  973. from books, television, video, the net,    |            vincent@tnc.nl
  974. my friends, my parents, my teachers and    | FidoNet  : 2:281/202.15
  975. and numerous other contributors.           | NeST     : 90:500/202.15
  976.  
  977. +++++++++++++++++++++++++++
  978.  
  979. >From zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  980. Date: 13 May 1994 14:51:43 GMT
  981. Organization: Bucknell University, Lewisburg, Pa.
  982.  
  983. >I got a code-snippet from umich-mac last week which contains some code to
  984. >do FSpExchangeFiles for volumes that don't support it (CAP a.o.).
  985. >It came with a message from Jim Luther to Jon W{tte in which Jim said
  986. >FSpExchangeFiles was broken on some third-party servers (and AU/X?) so
  987. >he advised you to program around this bug with the code he supplied.
  988. >I don't like cramming large bits of code into my program to fix a bug in the
  989. >System software (just like the System shouldn't work around bugs of known
  990. >programs...) so my questions is: is all this still necessary?
  991. >
  992. >Vincent.
  993.  
  994. Why not use PBHGetVolParms to find out if the volume supports
  995. FSpExchangeFiles?  (That is, the bHasFileIDs bit of vMAttrib is set.)
  996. If it does, use it.  Otherwise, save without it.  There's one thing to
  997. watch out for though.  AUX 3.0 will tell you it has file IDs when it
  998. fact it doesn't.  I got a message from someone at Apple that said this
  999. is fixed in AUX 3.0.1 and later.
  1000.  
  1001. Rick Zaccone
  1002. --
  1003. zaccone@bucknell.edu
  1004.  
  1005.  
  1006. +++++++++++++++++++++++++++
  1007.  
  1008. >From jumplong@aol.com (Jump Long)
  1009. Date: 14 May 1994 03:02:53 -0400
  1010. Organization: America Online, Inc. (1-800-827-6364)
  1011.  
  1012. In article <2qvp5b$pp6@hermes.fwi.uva.nl>, partingt@fwi.uva.nl (Vincent
  1013. Partington) writes:
  1014.  
  1015. >I got a code-snippet from umich-mac last week which contains some code to
  1016. >do FSpExchangeFiles for volumes that don't support it
  1017. >...
  1018. >is all this still necessary?
  1019.  
  1020. FSpExchangeFiles is fixed by System Update 3.0.  However, unless you can ensure
  1021. that *all* users of your code update their systems, you need to include the
  1022. work-around code.
  1023.  
  1024. The latest and greatest version of the FSpExchangeFiles work-around,
  1025. FSpExchangeFilesCompat(),  can be found in MoreFiles 1.1 or later, the DTS
  1026. sample code/library that I wrote.  You can find it in the FSpCompat.c file.  My
  1027. code checks to see if the bug has been fixed and if not, does everything the
  1028. right way.  The fix will add around 800 bytes to your application (if you copy
  1029. just the routines related to FSpExchangeFiles into your code) - well worth it
  1030. if you depend on FSpExchangeFiles doing the right thing.
  1031.  
  1032. If you really don't want to add that code, then use PBExchangeFiles instead of
  1033. FSpExchangeFiles. PBExchangeFiles only works on volumes that support file
  1034. reference IDs so it will fail with a paramErr (-50) on some volumes (mostly old
  1035. external file systems or file servers that haven't been updated for System 7
  1036. features).  That means you can't do the safe-save thing on those volumes
  1037. without adding your own code (which will look a *lot* like the code in
  1038. FSpExchangeFilesCompat).
  1039.  
  1040. - Jim Luther
  1041.  
  1042.  
  1043. ---------------------------
  1044.  
  1045. >From andrew@random.demon.co.uk (Andrew Walker)
  1046. Subject: Looping sounds
  1047. Date: Sat, 14 May 1994 10:05:24 GMT
  1048. Organization: Inner Workings
  1049.  
  1050.  
  1051.  
  1052. How can I get a sound to loop?
  1053.  
  1054. What I would like to acheive is to set up a channel which is dedicated to
  1055. playing a 10 second piece of music over and over again. I have been trying
  1056. to acheive this using the callBackCmd command but up until now I have been
  1057. unsucessful.
  1058.  
  1059. Is there anyone out there with any advice on how to acheive this?
  1060.  
  1061.  
  1062. cheers,
  1063. Andrew.
  1064.  
  1065. =========================================================================
  1066. Andrew Walker - Inner Workings, Suite 406, The Pentagon Centre,  
  1067.                                 36 Washington Street, Glasgow, UK, G3 8AZ
  1068. INTERNET:- andrew@random.demon.co.uk
  1069. Compuserve:- 100102,1634
  1070.  
  1071.  
  1072.  
  1073.  
  1074. +++++++++++++++++++++++++++
  1075.  
  1076. >From alex@metcalf.demon.co.uk (Alex Metcalf)
  1077. Date: Sat, 14 May 1994 13:19:55 GMT
  1078. Organization: Best Before Yesterday
  1079.  
  1080. In article <43@random.demon.co.uk>, andrew@random.demon.co.uk (Andrew
  1081. Walker) wrote:
  1082.  
  1083. > How can I get a sound to loop?
  1084. > What I would like to acheive is to set up a channel which is dedicated to
  1085. > playing a 10 second piece of music over and over again. I have been trying
  1086. > to acheive this using the callBackCmd command but up until now I have been
  1087. > unsucessful.
  1088. > Is there anyone out there with any advice on how to acheive this?
  1089.  
  1090.    In a call back routine (when your sound finishes playing), you can't
  1091. play the sound again, because the callback is an interrupt so playing a
  1092. sound may move or purge memory.
  1093.  
  1094.    There are two solutions:
  1095.  
  1096. just send the sound to the channel as many times as you like (hundreds if
  1097. necessary). Make sure your sound channel queue length is big enough.
  1098.  
  1099. or
  1100.  
  1101. in your call back, set a global boolean saying "play again". Then,
  1102. continuously call a routine in your main loop of your application which
  1103. checks this boolean and starts the sound off if its true.
  1104.  
  1105. in order to set the global boolean in your callback, you'll need to sent
  1106. the current A5 setting as a parameter to the callback routine. You'll need
  1107. GetA5 and SetA5.
  1108.  
  1109.  
  1110. This second method will work indefinitely, but there will be a very small
  1111. pause between the end of the sound and the time it takes to start it
  1112. playing again.
  1113.  
  1114. Hope this helps,
  1115.  
  1116.  
  1117.  
  1118. Alex
  1119.  
  1120. --
  1121. Alex Metcalf, Best Before Yesterday
  1122. Mac programmer in C, C++, HyperTalk, assembler
  1123.  
  1124. Internet, AOL, BIX: alex@metcalf.demon.co.uk            "Surely you
  1125. AppleLink:          alex@metcalf.demon.co.uk@internet#   can't be
  1126. CompuServe:         INTERNET:alex@metcalf.demon.co.uk    serious?"
  1127. Delphi:             alex@metcalf.demon.co.uk@inet#
  1128. FirstClass:         alex@metcalf.demon.co.uk,Internet   "I am serious...
  1129. Fax (UK):           (0570) 45636                         and don't call
  1130. Fax (US / Canada):  011 44 570 45636                     me Shirley."
  1131.  
  1132. +++++++++++++++++++++++++++
  1133.  
  1134. >From kluev@jonathan.srcc.msu.su (Kluev)
  1135. Date: Sun, 15 May 94 20:31:21 +0400
  1136. Organization: (none)
  1137.  
  1138. In article <43@random.demon.co.uk> alex@metcalf.demon.co.uk (Alex
  1139. Metcalf) wrote:
  1140.  
  1141. >In article <43@random.demon.co.uk>, andrew@random.demon.co.uk (Andrew
  1142. >Walker) wrote:
  1143.  
  1144. >> How can I get a sound to loop?
  1145. >> 
  1146. >> What I would like to acheive is to set up a channel which is
  1147. dedicated to
  1148. >> playing a 10 second piece of music over and over again. I have been
  1149. trying
  1150. >> to acheive this using the callBackCmd command but up until now I
  1151. have been
  1152. >> unsucessful.
  1153. >> 
  1154. >> Is there anyone out there with any advice on how to acheive this?
  1155.  
  1156. >   In a call back routine (when your sound finishes playing), you
  1157. can't
  1158. >play the sound again, because the callback is an interrupt so playing
  1159. a
  1160. >sound may move or purge memory.
  1161.  
  1162. There was a thread about PlayingSoundAtInterruptTime some time ago,
  1163. Here are extracts from there.
  1164.  
  1165. You *CAN* play sound in callback procedure. Yes it is interrupt time
  1166. and you can't issue some sound commands like "reinitCmd", "freeCmd"
  1167. (via SndDisposeChannel), etc., i.e. commands that moves memory. But
  1168. you can issue commands like "bufferCmd" to play sounds. By the way,
  1169. QuickTime use this technique.
  1170.  
  1171. Note however that with the presence of new sound manager (3.0)
  1172. bufferCmd, sometimes needs to reconfigure channel. This happened
  1173. when you start to play a "different sort" of sound. By "sort" I mean
  1174. "Compressed or No", SampleRate, SampleSize, ... (May be this list is
  1175. not exact). So to ensure that SM will not reconfigure channel (read:
  1176. Move Memory) at interrupt time - issue first bufferCmd at main time,
  1177. and feel free to call other bufferCmds at interrupt time (PROVIDED
  1178. they are the same sort sound commands). Then, whenever you want to
  1179. play different sort of sound - repeat from the beginning -
  1180. First command at main, other commands at callback.
  1181.  
  1182. The original poster's question was about sound looping: this can
  1183. be done also by modifying loopStart and loopEnd fields, "installing
  1184. sound as a voice" (using soundCmd) (IM VI terminology), and
  1185. issuing freqCmd or freqDurationCmd. All this can be done within
  1186. 'snd' resource, so you can just SndPlay on this resource and it will
  1187. play forever.
  1188.  
  1189. Michael Kluev.
  1190.  
  1191. +++++++++++++++++++++++++++
  1192.  
  1193. >From folta@netcom.com (Steve Folta)
  1194. Date: Mon, 16 May 1994 07:32:31 GMT
  1195. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1196.  
  1197. andrew@random.demon.co.uk (Andrew Walker) writes:
  1198. >How can I get a sound to loop?
  1199.  
  1200. Install the sound with a soundCmd, start playing it with a freqCmd, stop 
  1201. it with a restCmd or quietCmd.  If you want the sound to play out when 
  1202. you stop the looping, make sure your restCmd has a long enough duration.  
  1203. You can use a callBackCmd after the restCmd to set a flag when the sound 
  1204. is done, so you'll know when it's safe to dispose the sound (and the 
  1205. channel if you're not going to reuse it).
  1206.  
  1207. Oh yeah, and make sure the looping points are set in the sound resource.
  1208.  
  1209. -- 
  1210. Steve Folta
  1211. folta@netcom.com
  1212.  
  1213. +++++++++++++++++++++++++++
  1214.  
  1215. >From Thomas Reed <reed@medicine.wustl.edu>
  1216. Date: 16 May 1994 14:52:05 GMT
  1217. Organization: Washington University
  1218.  
  1219. In article <alex-140594141810@metcalf.demon.co.uk> Alex Metcalf,
  1220. alex@metcalf.demon.co.uk writes:
  1221. >just send the sound to the channel as many times as you like
  1222. >or
  1223. >in your call back, set a global boolean saying "play again".
  1224. >
  1225. >This second method will work indefinitely, but there will be a very small
  1226. >pause between the end of the sound and the time it takes to start it
  1227. >playing again.
  1228.  
  1229. I wrote a small test program that uses the second method, and it works
  1230. pretty well, with no pause most places.  Of course, to manage this, you
  1231. have to keep the sound channel open constantly, which, I've heard, can
  1232. play havoc with other things.
  1233.  
  1234. One combination of these two methods would be to constantly keep two
  1235. sounds in the queue.  When the one that's playing finishes, the next one
  1236. will start playing, and you send the next sound into the queue.  Doesn't
  1237. need as big a queue, and there won't be any pause anywhere.  (Well, not
  1238. counting disk accesses or stuff like that.)
  1239.  
  1240. If the original poster (or anyone else, for that matter) is interested in
  1241. seeing my asynch sounds library, I'd be willing to e-mail it.
  1242.  
  1243. -Thomas
  1244. =====================================================
  1245. Thomas Reed                    Washington University
  1246. Reed@telesphere.wustl.edu          Medical School
  1247. (also:  Reed@medicine.wustl.edu)
  1248. - ---------------------------------------------------
  1249. Clothes make the man.  Naked people have little or no
  1250. influence on society.  -- Mark Twain
  1251. =====================================================
  1252.  
  1253. ---------------------------
  1254.  
  1255. >From zwelch@nyx.cs.du.edu (Zach Welch)
  1256. Subject: PPC Toolbox GetDefaultUser() bug
  1257. Date: Sat, 7 May 94 20:57:54 GMT
  1258. Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
  1259.  
  1260. Has anyone else out there had the problems I have had with the PPC Toolbox
  1261. call GetDefaultUser()?  I am using Symantec C++ 7.0 (I've tried it with
  1262. 6.0 as well).  I called Symantec Tech Support, and they couldn't get it to
  1263. work either.  Every time I try to make the call, I get the error return code
  1264. noLoggedInErr (-923).  The information in the Sharing Setup control panel
  1265. is all valid, so that's not the problem.  All I'm trying to do is get the
  1266. name that appears there.  I know that the info is saved in the Users & Groups
  1267. Prefs file, thought I more than a little hesitant to try to hack the format.
  1268. If anyone has any idea as to why this call always fails, please let me know.
  1269.  
  1270. Zach
  1271. `
  1272.  
  1273. +++++++++++++++++++++++++++
  1274.  
  1275. >From jumplong@aol.com (Jump Long)
  1276. Date: 14 May 1994 01:51:04 -0400
  1277. Organization: America Online, Inc. (1-800-827-6364)
  1278.  
  1279. In article <1994May7.205754.23878@mnemosyne.cs.du.edu>, zwelch@nyx.cs.du.edu
  1280. (Zach Welch) writes:
  1281.  
  1282. >Every time I try to make the call, I get the error return code
  1283. >noLoggedInErr (-923).
  1284.  
  1285. That error means the default user reference hasn't been used yet, or that it
  1286. has been deleted.  "Huh, what's the default user reference" you say?  Let me
  1287. explain...
  1288.  
  1289. Each time a PPC Toolbox session is authenticated, PPCStart() (via
  1290. StartSecureSession()) returns a user reference number that's associated with
  1291. the user name/password combination entered.  That user reference number can be
  1292. used to reopen a closed PPC Toolbox session using PPCStart() (and thus
  1293. bypassing the user authentication dialog).  One user reference number is
  1294. special, the default user reference number. The default user reference number
  1295. is associated with the user name/password combination that was entered in the
  1296. Sharing Setup control panel and is created the first time a PPC connection is
  1297. opened using that particular user name/password combination.
  1298.  
  1299. So, if you call GetDefaultUser() and get the error noLoggedInErr, it means that
  1300. either: a) the user hasn't authenticated a PPC Toolbox session using their
  1301. default name and password, or b) some piece of code has deleted the default
  1302. user reference number with DeleteUserIdentity().
  1303.  
  1304. By the way, the Event PPC code (what the Apple Event Manager uses to open PPC
  1305. sessions) has a bug in that is deletes all user reference numbers returned by
  1306. StartSecureSession().  It should only delete the non-default user reference
  1307. numbers as shown in the example code on  page 7-36 of Inside Macintosh volume
  1308. VI. Fortunately, I believe it has been fixed for the future.
  1309.  
  1310. I hope that explains PPC Toolbox user reference numbers better than IM did. 
  1311. User reference numbers were somewhat of a mystery to me when I reviewed that
  1312. chapter of Inside Macintosh, but after we shipped System 7, I got to answer
  1313. enough questions about them that I ended up digging the PPC Toolbox's sources
  1314. to find out what they're really used for.
  1315.  
  1316. - Jim Luther
  1317.  
  1318.  
  1319. ---------------------------
  1320.  
  1321. >From dazuma@cco.caltech.edu (Daniel Azuma)
  1322. Subject: SU3.0 programming tip
  1323. Date: Mon, 16 May 1994 07:10:45 -0700
  1324. Organization: California Institute of Technology, Pasadena
  1325.  
  1326. Just a few quick things about programming with System Update 3.0 in mind. 
  1327. Some of us at TopSoft ran into these problems while debugging an alpha of
  1328. FilterTop.
  1329.  
  1330. We use a custom GetFile dialog to get a set of files.  Similarly to THINK's
  1331. and CodeWarrior's "add files..." commands, this dialog "adds" the files
  1332. from the Standard File's list into a custom list below, and then opens the
  1333. files en masse when the user clicks "done".
  1334.  
  1335. Our first problem was that, starting with SU 3.0, it appears that passing
  1336. sfItemOpenButton back from the DlogHook does NOT dismiss the dialog IF no
  1337. items are selected in the Standard File package's main list.  We were
  1338. mapping presses of our "done" button to sfItemOpenButton in order to
  1339. dismiss the dialog, and all of a sudden, that stopped working in the case
  1340. where we had items present in our "to add" list but nothing actually
  1341. selected in the Standard File's main list.  This wasn't happening before we
  1342. installed SU 3!!  The solution, should you run into this, is to return
  1343. sfItemCancelButton instead from your DlogHook, whenever you want to dismiss
  1344. the dialog and it is possible that nothing is selected in the Standard
  1345. File's main list.
  1346.  
  1347. The second problem has to do with the new (very cool) color icons.  There
  1348. are certain circumstances when they're not color!  One notable example is
  1349. the Open... dialog in Microsoft Word (definitely version 5.1a, but probably
  1350. all the others as well).  The reason is, if you use a custom "DLOG"
  1351. resource for your GetFile dialog, you also need to include a "dctb"
  1352. resource in order for it to plot color icons.  The easiest way to add a
  1353. "dctb" resource is to do the following:
  1354. 1) Open the appropriate "DLOG" resource in ResEdit 2.1.1.
  1355. 2) Change the color option radio button to "custom".
  1356. 3) Use the pop-ups to change one of the colors (doesn't matter which one).
  1357. 4) Click ok in the alert that pops up.
  1358. 5) Use the pop-ups to change the color BACK to what it was.
  1359.  
  1360. Hope this makes life easier for someone!
  1361.  
  1362. -Dan
  1363.  
  1364. (Thanks to George Tempel and Jim Brunner for their help in tracking this
  1365. down.)
  1366.  
  1367.  
  1368. _______________________________________________________________________
  1369.  Daniel Azuma            | "Life's bad enough as it is without wanting
  1370.  Caltech                 |  to invent any more of it."
  1371.  dazuma@cco.caltech.edu  |                             --Douglas Adams
  1372.  
  1373. ---------------------------
  1374.  
  1375. End of C.S.M.P. Digest
  1376. **********************
  1377.  
  1378.  
  1379.