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

  1. C.S.M.P. Digest             Tue, 14 Jul 92       Volume 1 : Issue 142
  2.  
  3. Today's Topics:
  4.  
  5.     Standard File Woes w/Super Boomerang
  6.     How do I tell if I'm in COLOR or MONOCHROME??
  7.     Multiple non-modal movable dialogs
  8.     68040 extremely slow when rounding real numbers !!!!
  9.     scsi driver for Kennedy 9track tape
  10.     AppleEvents for Education
  11.  
  12.  
  13.  
  14. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  15.  
  16. The digest is a collection of article threads from the internet newsgroup
  17. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  18. regularly and want an archive of the discussions.  If you don't know what a
  19. newsgroup is, you probably don't have access to it.  Ask your systems
  20. administrator(s) for details.  (This means you can't post questions to the
  21. digest.)
  22.  
  23. Each issue of the digest contains one or more sets of articles (called
  24. threads), with each set corresponding to a 'discussion' of a particular
  25. subject.  The articles are not edited; all articles included in this digest
  26. are in their original posted form (as received by our news server at
  27. cs.uoregon.edu).  Article threads are not added to the digest until the last
  28. article added to the thread is at least one month old (this is to ensure that
  29. the thread is dead before adding it to the digest).  Article threads that
  30. consist of only one message are generally not included in the digest.
  31.  
  32. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  33. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  34. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  35. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  36. has a mail server; send a message with the text '$MACarch help' (no quotes)
  37. to LISTSERV@ricevm1.rice.edu for more information.
  38.  
  39. These digest is also available via email.  Just send a note saying that you
  40. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  41. automatically receive each new issue as it is created.  Sorry, back issues
  42. are not available through the mailing list.
  43.  
  44. Send administrative mail to mkelly@cs.uoregon.edu.
  45.  
  46.  
  47. -------------------------------------------------------
  48.  
  49. From: rsherman@mthvax.cs.miami.edu (Roby Sherman)
  50. Subject: Standard File Woes w/Super Boomerang
  51. Date: 11 Jun 1992 22:36:43 -0400
  52. Organization: The Tao of Programming
  53.  
  54. Hi all. I posted a message earlier telling of how when I use a file
  55. filter with the StandardGetFile call, I get a divide by zero message...
  56. Well, after a little bit of investigating, it seems to me  that Super
  57. Boomerang 3.0.2 is causing the problem. If I turn SB off, my code no
  58. longer crashes... Any have any reason why the two wouldn't exist
  59. peacefully together? Enclosed is the SF portion of my code, just in case
  60. it *IS* me...
  61.  
  62.                 thanks,
  63.  
  64.                    Roby
  65.  
  66. My Call is : StandardGetFile(@MyFileFilter,-1,emptyTypes,MyReply);
  67.  
  68. The filter function is :
  69.  
  70. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  71.  function MyFileFilter (pb: CinfoPBPtr): boolean;
  72.  begin
  73.   if pb <> nil then
  74.    begin
  75.     if allowanything then
  76.      begin
  77.       MyFileFilter := false;
  78.       exit(MyFileFilter);
  79.      end;
  80.      
  81.     if Pb^.IOFLFndrInfo.FDCreator = ctype then
  82.       MyFileFilter := false
  83.      else
  84.       MyFileFilter := true;
  85.    end;
  86.  end;
  87.  
  88. - -- 
  89. rsherman@mthvax.cs.miami.edu                    Roby Sherman
  90.  
  91. +++++++++++++++++++++++++++
  92.  
  93. From: Michael_Hecht@mac.sas.com (Michael Hecht)
  94. Date: Fri, 12 Jun 1992 19:31:22 GMT
  95. Organization: SAS Institute Inc.
  96.  
  97. I've had this bite me also. The problem is that SB is calling your filterProc
  98. as though it were a CustomGetFile-style filterProc. SB 3.0.2 is *supposed* to
  99. fix the problem. DFaultD 2.22 has the same bug, and I don't know of a
  100. later version that fixes it.
  101.  
  102. Once I determined what was going on, I hacked up this code to get around
  103. the problem (my filter filters out files w/o a resource fork):
  104.  
  105.  
  106. pascal Boolean ResourceFileFilter( ParmBlkPtr pb )
  107. {
  108.     /*
  109.      *    Deal with stupid bug in SuperBoomerang & DFaultD.
  110.      *    They're calling our filter proc as though it was a FileFilterYDProc!!!
  111.      *    When this happens, pb will be null. So, just eat a longword on the stack
  112.      *    to get around the problem.
  113.      */
  114.     if( !pb ) {
  115.         asm {
  116.             move.l        4(a7),8(a7)
  117.             move.l        (a7)+,(a7)
  118.             addq.l        #4,a6
  119.         }
  120.     }
  121.  
  122.     /* Don't filter out directories */
  123.     if( pb->fileParam.ioFlAttrib & ioDirMask )
  124.         return FALSE;
  125.  
  126.     return ( pb->fileParam.ioFlRPyLen == 0 ) ? TRUE : FALSE;
  127. }
  128.  
  129. - --Michael
  130.  
  131. =======================================================================
  132. Michael P. Hecht                 | Internet:  Michael_Hecht@mac.sas.com
  133. SAS Institute Inc.; Cary, NC USA | AppleLink: SAS.HECHT
  134.  
  135. ---------------------------
  136.  
  137. From: rsherman@mthvax.cs.miami.edu (Roby Sherman)
  138. Subject: How do I tell if I'm in COLOR or MONOCHROME??
  139. Date: 6 Jun 92 14:22:28 GMT
  140. Organization: The Tao of Programming
  141.  
  142. Hi.
  143.  
  144.  
  145.     Does the Cgrafport have some sort of flag that indicates when it's
  146. displaying gray-scale or color? If not, how can I determine this?
  147.  
  148.  
  149.         thanks...
  150.  
  151.                 Roby
  152.  
  153. - -- 
  154. rsherman@mthvax.cs.miami.edu                    Roby Sherman
  155.  
  156. +++++++++++++++++++++++++++
  157.  
  158. From: vvann@umbio.med.miami.edu (Vince Vann)
  159. Organization: University of Miami Medical School
  160. Date: Sun, 7 Jun 1992 18:11:09 GMT
  161.  
  162. rsherman@mthvax.cs.miami.edu (Roby Sherman) writes:
  163. :     Does the Cgrafport have some sort of flag that indicates when it's
  164. : displaying gray-scale or color? If not, how can I determine this?
  165. : rsherman@mthvax.cs.miami.edu                    Roby Sherman
  166.  
  167. No. 
  168.  
  169. You must look at the graphics device field 'gdFlags' to determine
  170. this.  The gdDevType flag (bit 0) tells you whether you are in
  171. monochrome mode (=0) or color mode (=1).
  172.  
  173. Of course, you should use the function TestDeviceAttribute( aDevice, 0) to 
  174. get this flag rather than test it yourself, since Apple could easily change
  175. the gDevice structure or its flag locations.  
  176.  
  177. To get the maximum depth device that intersects a global rect in screen
  178. coordinates use GetMaxDevice( &globalRect).
  179.  
  180. [See IM-V, Chap. 5 on Graphics Devices].
  181.  
  182. Vince
  183. vvann@umbio.med.miami.edu
  184.  
  185. +++++++++++++++++++++++++++
  186.  
  187. From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  188. Date: 8 Jun 92 11:34:34 GMT
  189. Organization: Bucknell University, Lewisburg, Pa.
  190.  
  191. In article <1992Jun7.181109.20207@newssun.med.miami.edu> vvann@umbio.med.miami.edu (Vince Vann) writes:
  192.  
  193.    You must look at the graphics device field 'gdFlags' to determine
  194.    this.  The gdDevType flag (bit 0) tells you whether you are in
  195.    monochrome mode (=0) or color mode (=1).
  196.  
  197. Doesn't this just tell you if it's a color capable monitor?  This may
  198. not reflect the current mode.  I thought that you had to check gdMode
  199. to get the current mode.  If gdMode > 128, then we are not in
  200. monochrome mode.  If this is not the correct interpretation, then
  201. what's the difference between gdDevType and gdMode?
  202.  
  203. Rick Zaccone
  204. - --
  205. zaccone@bucknell.edu
  206.  
  207.  
  208. +++++++++++++++++++++++++++
  209.  
  210. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  211. Date: 8 Jun 92 16:22:41 GMT
  212. Organization: MacDTS Misfits
  213.  
  214. In article <ZACCONE.92Jun8073434@rigel.cs.bucknell.edu>, zaccone@rigel.cs.bucknell.edu (Rick Zaccone) writes:
  215. > In article <1992Jun7.181109.20207@newssun.med.miami.edu> vvann@umbio.med.miami.edu (Vince Vann) writes:
  216. >    You must look at the graphics device field 'gdFlags' to determine
  217. >    this.  The gdDevType flag (bit 0) tells you whether you are in
  218. >    monochrome mode (=0) or color mode (=1).
  219. > Doesn't this just tell you if it's a color capable monitor?  This may
  220. > not reflect the current mode.  I thought that you had to check gdMode
  221. > to get the current mode.  If gdMode > 128, then we are not in
  222. > monochrome mode.  If this is not the correct interpretation, then
  223. > what's the difference between gdDevType and gdMode?
  224.  
  225. No, the gdDevType tells you what mode the monitor is in at the moment.
  226. In fact, there isn't any way to determine if a monitor is monochrome
  227. or color; all the translation is done in software and there isn't
  228. any way for a monitor to indicate to the system that it doesn't
  229. support color.
  230.  
  231. Tim Dierks
  232. MacDTS, but I speak for my knees
  233.  
  234. +++++++++++++++++++++++++++
  235.  
  236. From: jmatthews@desire.wright.edu
  237. Date: 8 Jun 92 22:18:28 GMT
  238. Organization: Wright State University
  239.  
  240. In article <ZACCONE.92Jun8073434@rigel.cs.bucknell.edu>, zaccone@rigel.cs.bucknell.edu (Rick Zaccone) writes:
  241. > In-reply-to: vvann@umbio.med.miami.edu's message of 7 Jun 92 18:11:09 GMT
  242. > In article <1992Jun7.181109.20207@newssun.med.miami.edu> vvann@umbio.med.miami.edu (Vince Vann) writes:
  243. >    You must look at the graphics device field 'gdFlags' to determine
  244. >    this.  The gdDevType flag (bit 0) tells you whether you are in
  245. >    monochrome mode (=0) or color mode (=1).
  246. > Doesn't this just tell you if it's a color capable monitor?  This may
  247. > not reflect the current mode.  I thought that you had to check gdMode
  248. > to get the current mode.  If gdMode > 128, then we are not in
  249. > monochrome mode.  If this is not the correct interpretation, then
  250. > what's the difference between gdDevType and gdMode?
  251.  
  252. I think the gdDevType bit of gdFlags is set if the device has been set
  253. to display color; it's clear in grayscale. The gdMode field is a
  254. number that may only make sense to a particular video card. In Apple's
  255. old card it corresponds to various bit depth settings.  I avoid using
  256. the word "mode" in connection with the gdFlags to prevent confusion
  257. with the gdMode field of the GDevice record.
  258.  
  259. Use the following code to determine current settings of a particular
  260. GDevice:
  261.  
  262. procedure GetVidMode(theDevice: GDHandle;var mode: Integer; var color:
  263. Boolean);
  264. begin
  265.   mode:= theDevice^^.gdMode;
  266.   color:= TestDeviceAttribute(theDevice,gdDevType)
  267. end;
  268.  
  269. Note that someone may change the settings (from the control panel or
  270. using one of the routines below) after you make this call.
  271.  
  272. In System 7, use the HasDepth function to determine if a particular
  273. device can handle a particular depth/color combination. HasDepth has
  274. the effect of translating a depth (say 8 bits) into a gdMode ($83 or
  275. so on mine). Use the whichFlags and flags parameters to about color
  276. vs. grayscale. SetDepth is similar; it sets the depth and color/gray.
  277.  
  278. GetVidMode (above) determines the current setting; HasMode determines
  279. the availability of a potential setting.
  280.  
  281. [Ijust love using GDevices 'cause I get to type "gd" so much:-]
  282.  
  283. o----------------------------------------------------------------------------o
  284. | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  285. | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  286. o----------------------------------------------------------------------------o
  287.  
  288. +++++++++++++++++++++++++++
  289.  
  290. From: S4161006@deimos.ucc.umass.edu (S4161006)
  291. Date: 12 Jun 92 21:00:56 GMT
  292. Organization: University of Massachusetts at Amherst
  293.  
  294. In <ZACCONE.92Jun8073434@rigel.cs.bucknell.edu> zaccone@rigel.cs.bucknell.edu writes:
  295.  
  296. > In article <1992Jun7.181109.20207@newssun.med.miami.edu> vvann@umbio.med.miami.edu (Vince Vann) writes:
  297. >    You must look at the graphics device field 'gdFlags' to determine
  298. >    this.  The gdDevType flag (bit 0) tells you whether you are in
  299. >    monochrome mode (=0) or color mode (=1).
  300. > Doesn't this just tell you if it's a color capable monitor?  This may
  301. > not reflect the current mode.  I thought that you had to check gdMode
  302. > to get the current mode.  If gdMode > 128, then we are not in
  303. > monochrome mode.  If this is not the correct interpretation, then
  304. > what's the difference between gdDevType and gdMode?
  305. > Rick Zaccone
  306. > --
  307. > zaccone@bucknell.edu
  308.  
  309. All this talk is making me nervous!!  I need to find out the pixel
  310. depth the user has set to determine what kind of drawing I do. To do this
  311. I do the following:
  312.  
  313. TheGDevice := GetGDevice;
  314. Depth := TheGDevice^^.gdPMap^^.pixelSize;
  315.  
  316.  
  317. So, is this OK?  If not what should I do.  Thanks in advance
  318.  
  319. +++++++++++++++++++++++++++
  320.  
  321. From: oster@well.sf.ca.us (David Phillip Oster)
  322. Organization: Whole Earth 'Lectronic Link
  323. Date: Sat, 13 Jun 1992 05:07:05 GMT
  324.  
  325. In article <1992Jun12.210056.943@nic.umass.edu> S4161006@deimos.ucc.umass.edu (S4161006) writes:
  326. >All this talk is making me nervous!!  I need to find out the pixel
  327. >depth the user has set to determine what kind of drawing I do. To do this
  328. >I do the following:
  329.  
  330. >TheGDevice := GetGDevice;
  331. >Depth := TheGDevice^^.gdPMap^^.pixelSize;
  332.  
  333. Of course, this can't possibly be the right thing to do if the user has
  334. two monitors on his mac, and the window spans them both, and tthey have
  335. different screen depths: Some parts will have one pixelsize, and some 
  336. another.  Tehre is an article in the current issue of Develop magazine
  337. that talks about a new system call in System 7 and how to emulate it
  338. on older systems so that a single update event will get broken up into
  339. one piece for each montior that the update region intersects. Of course,
  340. if you do any drawing not at update time (say as a result of the user
  341. using a scroll nar...).
  342.  
  343. +++++++++++++++++++++++++++
  344.  
  345. From: zaccone@rigel.cs.bucknell.edu (Rick Zaccone)
  346. Date: 13 Jun 92 19:44:55 GMT
  347. Organization: Bucknell University, Lewisburg, Pa.
  348.  
  349. In article <1992Jun12.210056.943@nic.umass.edu> S4161006@deimos.ucc.umass.edu (S4161006) writes:
  350.  
  351.    All this talk is making me nervous!!  I need to find out the pixel
  352.    depth the user has set to determine what kind of drawing I do. To do this
  353.    I do the following:
  354.  
  355.    TheGDevice := GetGDevice;
  356.    Depth := TheGDevice^^.gdPMap^^.pixelSize;
  357.  
  358.  
  359.    So, is this OK?  If not what should I do.  Thanks in advance
  360. - ----------------------------------------------------------------------
  361. I've done some investigation and here's what I found out.  The
  362. following is taken from Apple's Q&A Stack 4.0.6:
  363.  
  364. In my Macintosh system, I have two screens. The main screen in a 19"
  365. monochrome. The second screen, to the left of the main one, is color.
  366. How can my program know whether or not a color display is available,
  367. its depth, and its coordinates?
  368.  
  369. The following bit of code will show you basically how to walk the
  370. GDevice list and find the information you want from it. Most of this
  371. information can be found on pages 119 and 124 of Inside Macintosh
  372. Volume V.
  373.  
  374.  
  375. count = 0;
  376. GDevHand = GetDeviceList();
  377. ScreenRect[count] = (*(*gDevHand)->gdPMap)->bounds;
  378. ScreenDepth[count] = (*(*gDevHand)->gdPMap)->pixelSize;
  379. ScreenColor[count] = TestDeviceAttribute (GDevHand, gdDevType);
  380.  
  381. while ((GDevHand = GetNextDevice(GDevHand)) != nil) {
  382.      ++count;
  383.      ScreenRect[count] = (*(*gDevHand)->gdPMap)->bounds;
  384.      ScreenDepth[count] = (*(*gDevHand)->gdPMap)->pixelSize;
  385.      ScreenColor[count] = TestDeviceAttribute (GDevHand, gdDevType);
  386. }
  387.  
  388. - ----------------------------------------------------------------------
  389. Here are some comments that I would like to add:
  390.  
  391. 1. The result of the call to TestDeviceAttribute reflects the status
  392. of the Grays:/Colors: radio buttons in the Monitors control panel. Be
  393. careful interpreting the results of this call because it is possible
  394. that the Colors: radio button is selected and the monitor is
  395. displaying B&W. In this case, TestDeviceAttribute will return 1
  396. (color). You also need to consider the depth of the color being
  397. displayed. (Because 1 bit color == B&W). So, to determine if color is
  398. currently being displayed, you need to consider more than the result
  399. of TestDeviceAttribute. You also need to consider the value of
  400. pixelSize.
  401.  
  402. 2. The value of pixelSize reflects the currently selected item in the
  403. scrollable list of screen depths in the Monitors control panel.
  404. Considering pixelSize alone is not enough because it doesn't tell you
  405. whether you are displaying grayscale or color.
  406.  
  407. 3. To determine the current display device, use GetGDevice(). Be
  408. careful though. This routine is not available on all Macs. In
  409. particular, it is not available on Classics, Plus' and SE's. If you
  410. try to call this routine on a Classic and you are running System 7 the
  411. machine will bomb with an unimplemented A-trap error. Use
  412. TrapAvailable as defined in IM Vol. 6 to determine if this routine is
  413. available. If the trap is not available, you can be sure that the
  414. machine is displaying B&W. I'm not sure if GetDeviceList() and
  415. GetNextDevice() are available on all machines. The same problem may
  416. exist with them.
  417.  
  418. Rick Zaccone
  419. - --
  420. zaccone@bucknell.edu
  421.  
  422.  
  423. ---------------------------
  424.  
  425. From: hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer)
  426. Subject: Multiple non-modal movable dialogs
  427. Organization: Washington University in Saint Louis, Missouri USA
  428. Date: Mon, 8 Jun 1992 11:27:10 GMT
  429.  
  430. Hi,
  431. I am about to write a database front end in MPW C/C++.
  432. I need to have a few dialogs open at the same time, and the user should
  433. be able to select any of them. The dialogs might even have a vertical
  434. scroll bar, a zoom box, and a close box. They will also contain stuff
  435. with different fonts, fancy buttons I design myself etc.
  436.  
  437. Is there any way smarter to do this than to use dialogs, and use
  438. IsDialogEvent, UpdateDialog, and lots of user items ? Is there any
  439. sample code available for this anywhere ? I couldn't find anything on
  440. ftp.apple.com, so here is a little work for DTS.
  441. - --
  442. Povl H. Pedersen             hp48sx@wuarchive.wustl.edu
  443. HP48sx archive maintainer
  444.  
  445. All Opinions (C) Copyright the Integalactic Thought Association
  446.  
  447. +++++++++++++++++++++++++++
  448.  
  449. From: bin@primate.wisc.edu (Brain in Neutral)
  450. Date: 9 Jun 92 17:36:15 GMT
  451.  
  452. >Subject: Re: Multiple non-modal movable dialogs
  453.  
  454. You mean...modeless dialogs?
  455.  
  456. > I need to have a few dialogs open at the same time, and the user should
  457. > be able to select any of them. The dialogs might even have a vertical
  458. > scroll bar, a zoom box, and a close box. They will also contain stuff
  459. > with different fonts, fancy buttons I design myself etc.
  460. > Is there any way smarter to do this than to use dialogs, and use
  461. > IsDialogEvent, UpdateDialog, and lots of user items ? Is there any
  462. > sample code available for this anywhere ? I couldn't find anything on
  463. > ftp.apple.com, so here is a little work for DTS.
  464.  
  465. It sounds like you'd be better off to use regular windows.  By the time
  466. you get done messing with all that junk so that you can properly support
  467. modeless dialogs, you'll be sorry.
  468.  
  469. Have a look at Tech Note 203: Don't Abuse the Managers.  It has a section
  470. on using the dialog manager.  The section seems to focus on modal dialogs
  471. (whereas you're interested in modeless ones), but my own experience is
  472. that getting the event loop right for modeless dialogs is, um, difficult.
  473. At least, in TransSkel I know there were several revisions made to the
  474. event routing code to get it to work properly for modeless dialogs, and
  475. I'm still not sure it's correct yet.
  476.  
  477. Paul DuBois
  478. dubois@primate.wisc.edu
  479.  
  480. +++++++++++++++++++++++++++
  481.  
  482. From: zben@ni.umd.edu (Charles B. Cranston)
  483. Organization: UM Home for the Terminally Analytical
  484. Date: Tue, 9 Jun 1992 19:45:42 GMT
  485.  
  486. In article <6230@uakari.primate.wisc.edu>, bin@primate.wisc.edu (Brain in Neutral) writes:
  487.  
  488. > ...my own experience is that getting the event loop right for modeless
  489. > dialogs is, um, difficult.  At least, in TransSkel I know there were
  490. > several revisions made to the event routing code to get it to work
  491. > properly for modeless dialogs, and I'm still not sure it's correct yet.
  492. > Paul DuBois
  493.  
  494. Hello Paul, glad you are well and still pushing bits!  I've done a number
  495. of small applications based on modeless dialogs, the most complicated has
  496. four independant window types (including the about box, which was just
  497. another modeless dialog!).  I've never tried to do a skeleton like TransSkel
  498. and I know that is a quantum leap beyond any fixed application, but after
  499. a few revisions I think I've got a structure that works.
  500.  
  501. The key for me was to call IsDialogEvent once at the beginning and store
  502. the result into a local Boolean.  For some events you care if it is a
  503. dialog event and for some you do not.  The first two cuts were a big ifelse
  504. on IsDialogEvent and two separate switch statements, the second cut was
  505. one big switch in which about half the cases had if IsDialogEvent and the
  506. other half didn't.  The third and final version uses the Boolean local:
  507.  
  508.  
  509. /* Main routine and event loop
  510.  */
  511. main()
  512. {
  513.     EventRecord    myevent;
  514.     Boolean    devent;
  515.     WindowPtr    windp;
  516.     short    wtype;
  517.     short    itemhit;
  518.     Point    where;
  519.   
  520.     initialize();
  521.     do {
  522.     windp = FrontWindow();
  523.     if (drawmenubar) {
  524.         DrawMenuBar();
  525.         drawmenubar = 0;
  526.     }
  527.     WaitNextEvent(everyEvent,&myevent,30,nil);
  528. /*
  529.  * Don't call IsDialogEvent on null or update events in background.
  530.  
  531. +++++++++++++++++++++++++++
  532.  
  533. From: REEKES@applelink.apple.com (Jim Reekes)
  534. Date: 9 Jun 92 21:04:21 GMT
  535. Organization: Apple Computer, Inc.
  536.  
  537. In article <hp48sx.708002830@wuarchive.wustl.edu>, hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:
  538. > Hi,
  539. > I am about to write a database front end in MPW C/C++.
  540. > I need to have a few dialogs open at the same time, and the user should
  541. > be able to select any of them. The dialogs might even have a vertical
  542. > scroll bar, a zoom box, and a close box. They will also contain stuff
  543. > with different fonts, fancy buttons I design myself etc.
  544. > Is there any way smarter to do this than to use dialogs, and use
  545. > IsDialogEvent, UpdateDialog, and lots of user items ? Is there any
  546. > sample code available for this anywhere ? I couldn't find anything on
  547. > ftp.apple.com, so here is a little work for DTS.
  548. > --
  549. > Povl H. Pedersen             hp48sx@wuarchive.wustl.edu
  550. > HP48sx archive maintainer
  551.  
  552. This is easier done WITHOUT using the Dialog Manager.
  553.  
  554. You'll end up spending way too much time making this work.  You'll always
  555. be adding more and more hacks to make it work.  Everything you'll need
  556. will end up being a userItem, of which the Dialog Manager doesn't handle.
  557.  
  558. For example, IsDialogEvent prior to System 7 did not check the result
  559. of FrontWindow before deferencing the WindowPtr.  If there were no windows
  560. visible, then the Dialog Manager would check two bytes in low memory to
  561. be dialogKind.  But it could also bus error depending on what you have
  562. at location zero.  To avoid this you have to call FrontWindow before
  563. calling IsDialogEvent.  At this is only the beginning.
  564.  
  565.  
  566. The Dialog Manager is not a user interface.
  567. The Dialog Manager is not a user interface.
  568. The Dialog Manager is not a user interface.
  569. The Dialog Manager is not a user interface.
  570. The Dialog Manager is not a user interface.
  571.  
  572.  
  573. - -----------------------------------------------------------------------
  574. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  575.                              |          Sound Manager Expert
  576. Apple Computer, Inc.         | "All opinions expressed are mine, and do
  577. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  578. Cupertino, CA 95014          |       employer, Apple Computer Inc."
  579.  
  580. +++++++++++++++++++++++++++
  581.  
  582. From: orpheus@reed.edu (P. Hawthorne)
  583. Date: 10 Jun 92 07:53:36 GMT
  584. Organization: Reed College, Portland, Oregon
  585.  
  586.  
  587.   hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:
  588. . I am about to write a database front end in MPW C/C++.  I need to have a
  589. . few dialogs open at the same time, and the user should be able to select
  590. . any of them....
  591.  
  592.   REEKES@applelink.apple.com (Jim Reekes) writes:
  593. . This is easier done WITHOUT using the Dialog Manager.
  594. . The Dialog Manager is not a user interface.
  595.  
  596.   Agreed! I had not wanted to comment on this, because I wouldn't want to
  597. rain on anyone's parade. The Dialog Manager was never intended to be the
  598. end all be all of user interface management systems. The only reason you
  599. would ever need to use it would be in the standard open, save, page setup,
  600. and print dialogs.
  601.  
  602.   In my humble opinion, what you are describing are not modal dialogs per
  603. se. Rather, I suspect that they are simply windows at the beck and call of
  604. the user and the current document. The only reason modality would enter
  605. into it would be if the function of one of the window was atomic, and would
  606. have to be completed before doing anything else. From what you've
  607. described, this is not the case. Disinfectant does a good job of being
  608. utterly modeless, if I am not mistaken.
  609.  
  610.   My application framework handles dialogs with a stack of modality states.
  611. When you open a modal dialog, you push a new modality state of true. This
  612. prevents the user from switching to another window, and takes care of
  613. updating the menus and so forth. When it goes away, you pop it. These are
  614. usually done in the constructor and destructor methods for the dialog
  615. object. Internally, the Dialog Manager is never used. The gadgets you
  616. describe are implemented as a rooted graph of objects, with the root being
  617. the dialog object itself.
  618.  
  619.   Theus (orpheus@reed.edu)
  620.  
  621. +++++++++++++++++++++++++++
  622.  
  623. From: oster@well.sf.ca.us (David Phillip Oster)
  624. Organization: Whole Earth 'Lectronic Link
  625. Date: Sat, 13 Jun 1992 03:56:53 GMT
  626.  
  627. Altough the Dialog manager isn't _intended_ to be the be all and end all in 
  628. window design tools, the DITL editor editor in ResEdit is very, very good.
  629. It is a shame to throw that away just because some one at apple warns you
  630. about the dialog manager.  What I do is re-implement the dialog manager so
  631. I have my  own interpreter for DITLs. This lets me leverage off of existing
  632. tools like the DITL editor in ResEdit.  With the new pop-up menu CDEF, it
  633. is even easier to do some spectacular user interface design work just in
  634. the dialog manager (provide you are willing to implement your own CDEFs
  635. and MDEFs.)
  636.  
  637. ---------------------------
  638.  
  639. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  640. Subject: 68040 extremely slow when rounding real numbers !!!!
  641. Date: 11 Jun 92 00:05:52 GMT
  642. Organization: MacDTS Misfits
  643.  
  644. In article <1992Jun10.070034.2328@ousrvr.oulu.fi>, juha@skynet.oulu.fi (Juha Pirttil{) writes:
  645. > We would very much appreciate if someone from Motorola or Apple or 
  646. > anyone else who understands the inside of 68040 explained what is
  647. > going inside 68040 during FINTRZ/FINT operations. Why is it so
  648. > sloooow when rounding ??? Otherwise we have no complaints concerning
  649. > its speed.
  650.  
  651. The 68040 doesn't contain a complete floating point processor; a number
  652. of the FPU instructions are emulated by a software package included with
  653. System 7.0.1.  Among these are FINTRZ, which the C compiler is forced to
  654. use because of the C language specification.  Needless to say, emulating
  655. these instructions is somewhat slower than they would execute were they
  656. in hardware, as they are in the 68881/2.
  657.  
  658. There is a tech note on this situation, #317: "FPU Operations on
  659. Macintosh Quadras".  In this note, the following workaround is 
  660. suggested:
  661.  
  662. Rather than using the sequence:
  663.  
  664.     FINTRZ        FPn,FPm                  ; truncate to integral value
  665.     FMOVE.L       FPm,<ea>                 ; convert to integral format
  666.  
  667. you use the following:
  668.  
  669.     FMOVE.L       #$00000010,FPCR          ; set round-to-zero mode
  670.     FMOVE.L       FPn,<ea>                 ; truncate to integral format
  671.     FMOVE.L       #$00000000,FPCR          ; restore default modes
  672.  
  673. This should operate much faster on the 68040 with minimal performance
  674. impact on the 68020/30 and 68881/2 combination.
  675.  
  676. As always, make sure you check for an FPU using Gestalt before
  677. executing any of these sequences.
  678.  
  679. Tim Dierks
  680. MacDTS, but I speak for my knees.
  681.  
  682. +++++++++++++++++++++++++++
  683.  
  684. From: juha@skynet.oulu.fi (Juha Pirttil{)
  685. Date: 10 Jun 92 07:00:34 GMT
  686. Organization: Department of Physics, University of Oulu
  687.  
  688. For all programmers who use ploating point arithmetic on
  689. a Motorola 68040 and want it to be as fast as possible:
  690.  
  691. Motorola 68040 rounds extended numbers *really* slowly.
  692.  
  693. An incoherant scatter radar analysis program called GUISDAP 
  694. has been developed in Finland. It has been written using
  695. MATLAB and therefore it runs on all computers that can run MATLAB.
  696. However GUISDAP is being developed on the Macintosh.
  697.  
  698. Because MATLAB is slow, it was decided to use C-language for 
  699. the most time-consuming parts. They are typically heavy 
  700. floating point calculations. One routine was a complex Lagrange 
  701. interpolation routine that has 24 floating point operations(FLOP). 
  702. When the routine was tested it used 9 us for these 24 FLOPs.
  703. (Around 2.7 MFLOPS). The final routine had some rounding before the
  704. actual calculation. When the final routine was tested the speed
  705. dropped down to 0.333 MFLOPS!. After a few days of hard work we 
  706. found that the slowdown occurred because FINTRZ/FINT or FMOVE.L 
  707. operations are extremely slow on the 68040. FINTRZ/FINT uses 14 us 
  708. and FMOVE.L 12 us. In addition MPW C compiles simple operation
  709.  
  710.              i = (int)x,
  711.  
  712. where i is long and x is extended, to assembly in this way:
  713.  
  714.              
  715.              FINTRZ    FP7,FP0           (14 us)
  716.              FMOVE.L   FP0,-$0008(A6)    (12 us)
  717.              MOVE.L    -$0008(A6),FP0    (<1 us)
  718.              
  719. Alltogether this rounding takes 26 us. Because there were two 
  720. roundings the total calculation time is 61 us (26 + 26 + 9)
  721. which is desperately slow for our purposes. 
  722. On the Macintosh IIci exactly the same calculations took about
  723. the same time than on the Quadra, which is because 68030/68882 
  724. rounds relatively faster than 68040 !!! (68030/68882: Calculation 
  725. 90 us Rounding: 15 us, 68040: Calculation: 9 us Rounding: 26 us)
  726.  
  727. Fortunately we were able to solve the problem. We wrote a function
  728. called ffloor (fast floor), which takes an extended number as an input
  729. parameter and returns the integer part of it in a long integer. The 
  730. ffloor operation took only 2.6 us instead of 26 us. Following is the 
  731. listing of ffloor and some and some sample code. 
  732.  
  733. We would very much appreciate if someone from Motorola or Apple or 
  734. anyone else who understands the inside of 68040 explained what is
  735. going inside 68040 during FINTRZ/FINT operations. Why is it so
  736. sloooow when rounding ??? Otherwise we have no complaints concerning
  737. its speed.
  738.  
  739.  
  740. #include <stdio.h>
  741. #include <math.h>
  742. #include <StdLib.h>
  743.  
  744. extern void timer(int *n);
  745.  
  746.  
  747. int ffloor(extended x)
  748.     {
  749.     int *ii;
  750.     char *ic;
  751.     ic=&x;
  752.     ii=ic+6;
  753.     x = x + 140739635838976; /* 2^47+2^31 */
  754.     return( *ii - 2147483648 ); /* 2^31 */
  755.     }
  756.  
  757. main(int argc, char *argv[])
  758. {
  759.     extended x;
  760.     int nn,i,j;
  761.     x=2.3456;
  762.  
  763.     timer(&nn);
  764.     for (i=0; i < 1000000; i++) {
  765.             j=(int)x;
  766.     }
  767.     timer(&nn);
  768.     printf("time = %d ?s\n",nn);
  769.  
  770.     timer(&nn);
  771.     for (i=0; i < 1000000; i++) {
  772.             j=ffloor(x);
  773.     }
  774.     timer(&nn);
  775.     printf("time = %d ?s\n",nn);
  776.     return(0);
  777. }
  778. /* Some runs:
  779.  
  780. demo
  781. time = 25721024 ?s
  782. time = 2634484 ?s
  783. demo
  784. time = 25507483 ?s
  785. time = 2634566 ?s
  786. demo
  787. time = 25496106 ?s
  788. time = 2633708 ?s
  789. */
  790.  
  791.  
  792. Juha Pirttil{                         Markku Lehtinen
  793. Physics Department                      Sodankyl{?Geophysical Observatory
  794. University of Oulu
  795. 90570 Oulu                            99600 Sodankyl{
  796. FINLAND                               FINLAND
  797.  
  798.  ********************************************************************
  799.  *                     J u h a   P i r t t i l {                    *
  800.  *                                                                  *
  801.  *      juha@skynet.oulu.fi            addr. Yliopistokatu 38/521   *
  802.  *      tel: 358-81-361661                   90570 Oulu             *
  803.  *                                           Finland                *
  804.  *      Macintosh Programmer                                        *  
  805.  ********************************************************************
  806.  
  807. ---------------------------
  808.  
  809. From: bedford@proto.saic.com (Don Bedford)
  810. Subject: scsi driver for Kennedy 9track tape
  811. Date: 12 Jun 92 21:36:52 GMT
  812. Organization: SAIC, San Diego
  813.  
  814.  
  815. I dont want to - but have to - write a device driver in Think Pascal to
  816. drive a Kennedy 9 track tape unit which has a Kennedy 8124 scsi controller
  817. board installed.  I am able to select and rewind the tape, but haven't 
  818. been successful in getting any further.  If anyone has endured similar
  819. folly please respond with useful hints (I am developing on a Mac IIfx)
  820.  
  821. thanks in advance...
  822.  
  823. don bedford for doug rowitch for gary shaffer
  824.  
  825. +++++++++++++++++++++++++++
  826.  
  827. From: oster@well.sf.ca.us (David Phillip Oster)
  828. Organization: Whole Earth 'Lectronic Link
  829. Date: Sat, 13 Jun 1992 05:13:36 GMT
  830.  
  831. Remember to protect both the parameter block and the destination buffer
  832. in a SCSIRead and a SCSIWrite so it fdoesn't get flushed by the virtual memory
  833. sub system. Under System 7, Apple does _not_ do this for you. (However, if 
  834. you are writing a true device driver (a DRVR resource with a name starting
  835. with ".", then Apple will protect the buffer, and the io parameter block
  836. for you. You are on your own about the SCSI control block though. See
  837. Inside Mac VI for more info (og, also, if it isn't a true driver, you
  838. also need to protect the code itself.)  Apple, please fix SCSIRead and
  839. SCSIWrite!  (and while your at it, how about Asynch i/o like the floppy
  840. driver has had since '84?)
  841.  
  842. Also, if your device is like mine, it will only abort an operation if
  843. you send it a NAK at the end of a buffer read. If you need to abort the
  844. read because you couldn't allocate the buffer to put the data, you'll need
  845. a specail version of your call to SCSIRead that "drops the data on the floor"
  846. so you can get it out of the SCSI device buffers and send that NAK.
  847.  
  848. ---------------------------
  849.  
  850. From: cinquin@imag.fr ( Philippe Cinquin)
  851. Subject: AppleEvents for Education
  852. Date: 12 Jun 92 18:03:36 GMT
  853. Organization: IMAG Institute, University of Grenoble, France
  854.  
  855. I've known for a long time there were special AppleEvents for education
  856. programs, and I did not care about them, but, this afternoon, I realized
  857. I desperately need to integrate them to my program!
  858.  
  859. Could anyone please tell me where to find info about them?
  860.  
  861. Thanks. If you email, please do so at "ocinquin@timb.imag.fr"
  862.  
  863. +++++++++++++++++++++++++++
  864.  
  865. From: molla@paone.uucp (Levent Mollamustafaoglu)
  866. Organization: Aiken Computation Lab, Harvard University
  867. Date: Sat, 13 Jun 1992 05:52:00 GMT
  868.  
  869. In article <35553@imag.imag.fr> cinquin@imag.fr ( Philippe Cinquin) writes:
  870. >I've known for a long time there were special AppleEvents for education
  871. >programs, and I did not care about them, but, this afternoon, I realized
  872. >I desperately need to integrate them to my program!
  873. >
  874. >Could anyone please tell me where to find info about them?
  875. >
  876. >Thanks. If you email, please do so at "ocinquin@timb.imag.fr"
  877.  
  878. The latest APDA manual shows a document named (As far as I remember)
  879. "The Education Suite" which should be similar to the Apple Events Registry
  880. for the General Suite. I don't recall the price.
  881.  
  882. You can reach APDA by apda@applelink.apple.com, or get some useful
  883. information via ftp from ftp.apple.com, probably in directory
  884. dts/apda.
  885.  
  886.  
  887. ===========================================================================
  888. Dr. Levent Mollamustafaoglu       Harvard University    
  889. molla@paone.harvard.edu    molla@metatron.harvard.edu
  890. ===========================================================================
  891.  
  892. ---------------------------
  893.  
  894. End of C.S.M.P. Digest
  895. **********************
  896.