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

  1. C.S.M.P. Digest             Mon, 23 Nov 92       Volume 1 : Issue 217
  2.  
  3. Today's Topics:
  4.  
  5.     Suppl. Gestalt Selectors List 1.0.1
  6.     TimeDBRA
  7.     TrapAvailable for C (Was Re: help with Link failures in THINK C 5.03)
  8.     calling GetMenu twice on same MENU - actually seems ok?
  9.     Resource Manager Questions
  10.  
  11.  
  12.  
  13. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  14.  
  15. The digest is a collection of article threads from the internet newsgroup
  16. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  17. regularly and want an archive of the discussions.  If you don't know what a
  18. newsgroup is, you probably don't have access to it.  Ask your systems
  19. administrator(s) for details.  You can post articles to any newsgroup by
  20. mailing your article to newsgroup@ucbvax.berkeley.edu.  So, to post an
  21. article to comp.sys.mac.programmer, you mail it to
  22. comp-sys-mac-programmer@ucbvax.berkeley.edu.  Note the '-' instead of '.'
  23. in the newsgroup name.
  24.  
  25. Each issue of the digest contains one or more sets of articles (called
  26. threads), with each set corresponding to a 'discussion' of a particular
  27. subject.  The articles are not edited; all articles included in this digest
  28. are in their original posted form (as received by our news server at
  29. cs.uoregon.edu).  Article threads are not added to the digest until the last
  30. article added to the thread is at least one month old (this is to ensure that
  31. the thread is dead before adding it to the digest).  Article threads that
  32. consist of only one message are generally not included in the digest.
  33.  
  34. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  35. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  36. file /pub/mac/csmp-digest/README before downloading any files.  The most
  37. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  38. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  39. archive has a mail server; send a message with the text '$MACarch help' (no
  40. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  41.  
  42. The digest is also available via email.  Just send a note saying that you
  43. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  44. automatically receive each new issue as it is created.  Sorry, back issues
  45. are not available through the mailing list.
  46.  
  47. Send administrative mail to mkelly@cs.uoregon.edu.
  48.  
  49.  
  50. -------------------------------------------------------
  51.  
  52. From: rgaros@bio.vu.nl (Rene G.A. Ros)
  53. Subject: Suppl. Gestalt Selectors List 1.0.1
  54. Date: 22 Oct 92 17:29:09 GMT
  55. Organization: VU Biology, Amsterdam, The Netherlands
  56.  
  57. Supplemental Gestalt Selector List 1.0.1
  58.  
  59. Last updated: Oct., 22 1992 11:04 CET (GMT+1)
  60. (I have started to use version numbering for this list, previous
  61. list was 1.0).
  62.  
  63. Thanks to those persons who responded to the previous posting.
  64. The information you mailed me is added to this list.
  65.  
  66. Supplemental to the selectors listed in the Gestalt Chapter of
  67. Inside Macintosh VI (IM VI), that is.
  68. These can include selectors added by Apple's (system) software or by
  69. software from third parties (your software?).
  70. If a selector code is added by Apple software the entry also includes
  71. if it is an addition to or not listed in IM VI.
  72.  
  73. I don't have all the documentation or knowledge and I don't want to.
  74. I would like to see this list as a combined effort by different
  75. persons who have together access to a wide area of information.
  76. This list may contain (educated) guesses and perhaps even false
  77. information, so no guarantee is made about the contents.
  78. When there is a reference to a source you may expect there is a higher
  79. probability it is correct.
  80. If you have additions, corrections, comments, suggestions, news about
  81. available software (latest version of GestaltDA?), etc., please mail me
  82. (rgaros@bio.vu.nl). Please, mention the source you used.
  83.  
  84. If you read this list in a Usenet group: you can also read it by using
  85. finger to the same address.
  86.     Tip: finger rgaros@bio.vu.nl | more
  87. My .plan file which you see when you do this is more up-to-date. I will
  88. post this list to comp.sys.mac.programmer once a month. Or when (a lot
  89. of) information is added/corrected.
  90.  
  91. CONTENTS
  92.     Changes
  93.     Format used
  94.     Gestalt Selector Codes & Responses
  95.     Abbreviations
  96.     Format 4-byte word version number
  97.     About AppleShare File & Print Server selectors
  98.     Sources
  99.     Thanks to
  100.  
  101. ####Changes (since 1.0)
  102.     Added selectors : atlk, tabl, SLip
  103.     Changes to info : mtcp, qdrw, qtim
  104.  
  105.  
  106. ####Format used:
  107.  
  108.     | ****'selector code' (Application [available since version])
  109.     |     name (description, documentation) OR description
  110.     |
  111.     |     CONST declaration; (remark) *ref.number to source
  112.     |
  113.     |     contradiction:
  114.     |       source A says "x"
  115.     |       source B says "y"
  116.  
  117.     Some constant-names may not originate from official publications.
  118.     Any bitpattern described is what I or others found on their machine
  119.     with their configuration.
  120.  
  121.  
  122. ####Gestalt Selector Codes & Responses
  123. ****'admn' (AppleShare Admin appl [since v3.0?])
  124.     gestaltASAdminAttr (not listed in IM VI)
  125.  
  126.     gestaltASAdmin        = 'admn';
  127.     gestaltASAdminPresent = 0;
  128. ****'ApoL' (Apollo ext [since v1.0a7])
  129.     gestaltINITApolloTable
  130.  
  131.     (response will be published by Jeremy Roussak,
  132.      Apollo 1.0 is not yet released.)
  133. ****'asps' (AppleShare Print Server appl [since v3.0?])
  134.     gestaltASPrintServerAttr (not listed in IM VI)
  135.  
  136.     gestaltASPrintServer        = 'asps';
  137.     gestaltASPrintServerPresent = 0;
  138. ****'atkv' (System [since v7.0])
  139.     gestaltATalkVersion *5
  140.     Returns AppleTalk version in 4-byte words
  141.  
  142.     gestaltATalkVersion = 'atkv'; *3/5
  143.     This is different from 'atlk' !
  144. ****'atlk' (System)
  145.     gestaltAppleTalkVersion (addition)
  146.     Returns the version of the .MPP driver.
  147.  
  148.     LAPMgrExists := (AppleTalkVersion >= 53); *5
  149. ****'AzNe' (NameView cp)
  150.     unknown, Table?
  151. ****'BSDa' (CloseView cp)
  152.     unknown
  153. ****'bugz' (System [Tuna Helper INIT rsrc]/Tune-up ext)
  154.     unknown
  155. ****'conn' (System)
  156.     gestaltConnMgrAttr (addition)
  157.  
  158.     additional responses exist but unknown (bit 2 & 3)
  159. ****'cpnt' (QuickTime ext)
  160.     gestaltComponentMgrAttr (Component Manager)
  161.  
  162.     gestaltComponentMgr        = 'cpnt';
  163.     gestaltComponentMgrPresent = 0; (guess)
  164. ****'dict' (System [since v7.1])
  165.     gestaltDictionaryMgr (System 7.1 Dictionary Manager,
  166.                           not listed in IM VI)
  167.  
  168.     gestaltDictionaryMgr = 'dict';
  169.     new System 7.1 responses exist but unknown
  170. ****'eajt' (System)
  171.     gestaltEasyAccessJTable (not listed in IM VI)
  172.  
  173.     gestaltEasyAccessJ = 'eajt'; *3
  174.     Returns the base address of the Easy Access jump-trap table
  175. ****'ESOC' (Serial of Champions ext)
  176.     unknown
  177. ****'flag' (Network Extension ext [since System v7.0 *5])
  178.     gestaltFlagshipAttr (not listed in IM VI)
  179.  
  180.     gestaltFlagship           = 'flag'; *3
  181.     gestaltFlagshipPresent    = 0;      *3
  182.     gestaltFlagshipRegistered = 1;      *3
  183. ****'fpu ' (System)
  184.     gestaltFPUType (addition)
  185.  
  186.     gestal68040FPU = 3; *2
  187. ****'fs  ' (System)
  188.     gestaltFSAttr (addition)
  189.  
  190.     gestaltHasFileSystemManager = 2; *2
  191. ****'font' (System)
  192.     gestaltFontMgrAttr (addition)
  193.  
  194.     additional System 7.1 responses exist but unknown
  195. ****'hdwr' (System)
  196.     gestaltHardwareAttr (additions)
  197.  
  198.     gestaltHasRBV          =  2; (RBV)             *3
  199.     gestaltHasOSS          =  5; (OSS)             *3
  200.     gestaltHasSCSIDMA      =  6; (53C80 SCSI DMA)  *3
  201.     gestaltHasSWIMIOP      =  8; (SWIM IOP)        *3
  202.     gestaltHasSCCIOP       =  9; (SCC IOP)         *3
  203.     gestaltHasIWM          = 11; (IWM)             *3
  204.     gestaltHasSoftPowerOff = 19;                   *2
  205.     gestaltHasSonic        = 20; (Sonic)           *3
  206.     gestaltHasSCSI961      = 21; (Int. 53C96 SCSI) *1
  207.     gestaltHasSCSI962      = 22; (Ext. 53C96 SCSI) *1
  208.     gestaltHasDAFBVideo    = 23; (DAFB Video)      *3
  209. ****'He20' (Helium cp)
  210.     unknown
  211. ****'hgfd' (AppleShare File Server appl [since v3.0?])
  212.     gestaltASFileServerAttr (not listed in IM VI)
  213.  
  214.     gestaltASFileServer        = 'hgfd';
  215.     gestaltASFileServerPresent = 0;
  216. ****'icmp' (QuickTime ext)
  217.     unknown
  218. ****'Intj' (Interjection ext)
  219.     unknown
  220. ****'kbd ' (System)
  221.     gestaltKeyboardType (additions)
  222.  
  223.     gestaltPwrBookADBKbd    = 12; (PowerBook ADB Keyboard)     *1
  224.     gestaltPwrBookISOADBKbd = 13; (PowerBook ADB Keyboard ISO) *1
  225. ****'mach' (System)
  226.     gestaltMachineType (additions)
  227.  
  228.     gestaltQuadra900    = 20; (Macintosh Quadro 900)     *1
  229.     gestaltPowerBook170 = 21; (Macintosh PowerBook 170)  *1
  230.     gestaltQuadra700    = 22; (Macintosh Quadra 700)     *1
  231.     gestaltClassicII    = 23; (Macintosh Classic II)     *1
  232.     gestaltPowerBook100 = 24; (Macintosh PowerBook 100)  *1
  233.     gestaltPowerBook140 = 25; (Macintosh PowerBook 140)  *1
  234.     gestaltQuadra950    = 26; (Macintosh Quadra 950)     *1
  235.     gestaltPowerBook210 = 29; (Macintosh PowerBook 210)
  236.     gestaltPowerBook230 = 32; (Macintosh PowerBook 230)
  237.     gestaltPowerBook180 = 33; (Macintosh PowerBook 180)
  238.     gestaltPowerBook160 = 34; (Macintosh PowerBook 160)
  239.     gestaltMacLCII      = 37; (Macintosh LC II)
  240.     gestaltMacIIvi      = 44; (Macintosh IIvi)
  241.     gestaltPerforma600  = 45; (Macintosh Performa 600)
  242.     gestaltMacIIvx      = 48; (Macintosh IIvx)
  243.     gestaltPowerBook145 = 54; (Macintosh PowerBook 145)
  244.  
  245.     contradiction 1:
  246.       TN129 says             "The Macintosh LC II is identical to the
  247.                               Macintosh LC, except for the presence of
  248.                               an MC68030 processor, so it returns the
  249.                               same gestaltMachineType response as the
  250.                               Macintosh LC (i.e. 19).
  251.       According to M.Johnson "gestaltLCII = 37;"
  252.     contradiction 2:
  253.       DN PowerBook145 says   "gestaltPowerBook145 = 25; with sys 7.0.x
  254.                          and  gestaltPowerBook145 = 45; with sys 7.1"
  255.       According to M.Johnson "gestaltPowerBook145 = 54;"
  256. ****'mtcp' (MacTCP cp [since v1.1])
  257.     gestaltMacTCPAttr
  258.     0 is returned if MacTCP is present but unopened, *6
  259.     1 is returned for MacTCP when it is opened.      *6
  260.  
  261.     gestaltMacTCPAttr   = 'mtcp'
  262.     gestaltMacTCPOpened = 0;                         *6
  263. ****'mmu ' (System)
  264.     gestaltMMUType (addition)
  265.  
  266.     gestalt68040MMU = 4; *2
  267. ****'MV10' (TearOFF cp)
  268.     unknown
  269. ****'ppc ' (System)
  270.     gestaltPPCToolboxAttr
  271.  
  272.     gestaltPPCToolbox        = 'ppc '
  273.     gestaltPPCToolboxDenyIn  =  0; (Deny incoming net requests)  *3
  274.     gestaltPPCToolboxDenyOut =  1; (Deny outgoing net requests)  *3
  275.     gestaltPPCToolboxRTDeliv = 12; (supports real-time delivery) *3
  276.     gestaltPPCToolboxStore   = 13; (supports store and format)   *3
  277.     gestaltPPCToolboxCare    = 14; (supports "Don't care")       *3
  278.  
  279.     contradiction:
  280.       TN129 says     "gestaltPPCToolboxPresent = 0;"
  281.       GestaltDA says "gestaltPPCToolboxDenyIn  = 0;"
  282. ****'proc' (System)
  283.     gestaltProcessorType (addition)
  284.  
  285.     gestalt68040 = 5; *2
  286. ****'qdrw' (System)
  287.     gestaltQuickDrawFeaturesAttr (not listed in IM VI)
  288.     There is a bug in the 'qdrw' selector that causes it to report
  289.     that Color QuickDraw is always present, even on machines that
  290.     don't support it.  Apple has acknowledged this bug on AppleLink.
  291.  
  292.     gestaltQuickDrawFeatures = 'qdrw'; *2
  293.     gestaltHasColor          = 0;      *2
  294.     gestaltHasDeepGWorlds    = 1;      *2
  295.     gestaltHasDirectPixMaps  = 2;      *2
  296.     gestaltHasGrayishTextOr  = 3;      *2
  297. ****'qtim' (QuickTime ext)
  298.     gestaltQuickTimeVersion
  299.     Returns QuickTime version in 4-byte words
  300.     Bug with QT 1.5 (with system 7.0.1)? The response is $01508000 which
  301.     would mean it's version 1.80 final??
  302.  
  303.     gestaltQuickTimeVersion = 'qtim';
  304. ****'SLip' (StuffIt SpaceSaver)
  305.     gestaltStuffItSpaceSaverAddr
  306.     Returns the addres of the SpaceSaver "command module" which allows
  307.     developers to access all the functions of SS.
  308. ****'rsrc' (System)
  309.     gestaltResourceMgrAttr (addition)
  310.  
  311.     additional response exist but unknown (bit 1)
  312. ****'tabl' (System)
  313.     gestaltSelectorTable
  314.     Returns the address of the Gestalt selector table itself.
  315.  
  316.     gestaltSelectorTable = 'tabl';
  317. ****'tsmv' (System)
  318.     gestaltTextServicesMgrVersion? (not listed in IM VI)
  319.  
  320.     gestaltTextServicesMgr = 'tsmv';
  321.     new System 7.1 responses exist but unknown
  322. ****'vmcl' (System, VM on)
  323.     unknown.
  324. ****'vmbs' (System, VM on)
  325.     unknown.
  326. ****'wma.' (System)
  327.     gestaltResponderAttr (Workstation Management Agent aka Responder,
  328.                           not listed in IM VI)
  329.  
  330.     gestaltResponder        = 'wma.';
  331.     gestaltResponderPresent = 0;
  332. ****'xttt' (System)
  333.     gestaltExtToolboxTable
  334.     Returns the base address of the Extended Toolbox trap table.
  335.  
  336.     gestaltExtToolboxTable = 'xttt';
  337. ****'YeHa' (SpeedyFinder7 cp)
  338.     unknown
  339.  
  340.  
  341. ####Abbreviations:
  342.     appl  - application
  343.     cp    - control panel
  344.     ext   - extension
  345.  
  346.     ADB   - Apple Desktop Bus
  347.     AS    - AppleShare
  348.     ASC   - Apple Sound Chip
  349.     CPU   - Central Processing Unit
  350.     DAFB  - ?
  351.     DMA   - Direct Memory Access
  352.     DN    - Developer Note
  353.     FPU   - Floating Point Unit
  354.     IOP   - Input/Output Processor
  355.     IWM   - Integrated Woz Machine
  356.     MMU   - Memory Management Unit
  357.     OSS   - ?
  358.     PPC   - Program-to-Program Communication
  359.     RBV   - ?
  360.     SCC   - Serial Communications Controller
  361.     SCSI  - Small Computer System Interface
  362.     SIMM  - Single In-line Memory Module
  363.     Sonic - ?
  364.     SWIM  - Super Integrated Woz Machine
  365.     TN    - Technical Note
  366.     VIA   - Versatile Interface Adapter
  367.     VM    - Virtual Memory
  368.  
  369.  
  370. ####Format 4-byte word version number (*5):
  371.     The format of the LONGINT result is as follows:
  372.  
  373.         byte;                        /* Major revision */
  374.         byte;                        /* Minor revision */
  375.         byte    development = 0x20,  /* Release stage */
  376.                 alpha = 0x40,
  377.                 beta = 0x60,
  378.                 final = 0x80, /* or */ release = 0x80;
  379.         byte;                        /* Non-final release # */
  380.  
  381. ####About AppleShare File & Print Server selectors
  382.     The selectors are present when the application has ran.
  383.     If it is still running (or wasn't properly quit) the response
  384.     is one (1). When the application has properly quit the response
  385.     is zero (0).
  386.     'admn' AppleShare Admin
  387.     'asps' AppleShare Print Server
  388.     'hgfd' AppleShare File Server
  389.  
  390.  
  391. ####Sources:
  392.     *1 Apple Inc.; TN129 May 1987, rev. May 1992
  393.     *2 Symantec Corp.; THINK Pascal 4.0.1
  394.     *3 Gestalt DA by Carl C.Hewitt, 1990
  395.     *4 Apple Inc.; Developer Notes PowerBook 145
  396.     *5 Apple Inc.; TN311 April 1992, rev. May 1992
  397.     *6 MacTCP 1.1 Programmer's Guide.
  398.     If no source mentioned, found by myself or others (see below).
  399.  
  400.     All trade names referenced are the trademark or registered
  401.     trademark of their respective holder.
  402.  
  403.  
  404. ####Thanks to:
  405.     Chris Wysocki<wysocki@netcom.com>,
  406.     Cor Stoof <sjoukje@bio.vu.nl>,
  407.     John van Wielink <vwielink@bio.vu.nl>,
  408.     Lawrence D'Oliveiro <ldo@waikato.ac.nz>,
  409.     Leonard Rosenthol<leonardr@netcom.com>,
  410.     Marco Piovanelli <piovanel@pluto.sm.dsi.unimi.it>,
  411.     Mark B. Johnson <mjohnson@Apple.com>,
  412.     Pete Resnick <resnick@cogsci.uiuc.edu>,
  413.     Quinn <quinn@cs.uwa.edu.au>.
  414.  
  415.     These persons provided information used in this list. They did this
  416.     on personal title, NOT on behalf of their employer.
  417.     There is no reference to which information they provided.
  418.     I assume information mailed to me about Gestalt selectors may be
  419.     added to this list. If information was provided in a posting to a
  420.     Usenet group, this is also included and the persons name added to
  421.     the 'Thanks to' list.
  422.     I will not mail you back only to say 'Thank you'.
  423.  
  424.  
  425. ####Moderator:
  426.     Rene G.A. Ros (student Computer Science)
  427.     D.C. van Krimpenstraat 3
  428.     1067 SG  Amsterdam, The Netherlands
  429.     Phone#    : +31 20 611 92 74 / +31 20 611 87 00
  430.     Fax#      : +31 20 611 60 06
  431.     Internet  : rgaros@bio.vu.nl
  432.                 rgaros@nikhefk.nikhef.nl
  433.     CompuServe: 100112,1363 (not prefered)
  434.                 >INTERNET:rgaros@bio.vu.nl
  435.  
  436. ---------------------------
  437.  
  438. From: mxmora@unix.sri.com (Matthew Xavier Mora)
  439. Subject: TimeDBRA
  440. Date: 16 Oct 92 18:28:39 GMT
  441. Organization: SRI International
  442.  
  443. I would like to know how to determine what MHZ a mac CPU is using.
  444. I see a global called TimeDBRA which IM says "TimeDBRA=$D00; number of
  445. DBRAs executed per millisecond [word] V-352"
  446.  
  447. Is this a reliable figure? Can the speed of the processor be determined
  448. with this value? I would like to know because I am working on a info
  449. program like MacEnvy. 
  450.  
  451. Also I know I can assume that a certain cpu is at xmhz according to the
  452. product sheet (MacPlus is at 8mhz) but what if its using an accelerator?
  453.  
  454. My MacSE say timedbra=6
  455. My Mac II says timedbra=10
  456.  
  457. My MacSE has a 16mhz 68000 upgrade.
  458.  
  459. So the main question is how can I figure out the speed of the system
  460. in Mhz? 
  461.  
  462. - --
  463. - ----------------------------------------------------------------------
  464. Matthew Xavier Mora                                mxmora@unix.sri.com
  465. SRI International                                       (415) 859-5011
  466. - ----------------------------------------------------------------------
  467.  
  468. +++++++++++++++++++++++++++
  469.  
  470. From: keith@taligent.com (Keith Rollin)
  471. Organization: Taligent
  472. Date: Fri, 16 Oct 1992 22:12:57 GMT
  473.  
  474. In article <mxmora-161092110250@css-mac1.sri.com>, mxmora@unix.sri.com
  475. (Matthew Xavier Mora) wrote:
  476. > I would like to know how to determine what MHZ a mac CPU is using.
  477. > I see a global called TimeDBRA which IM says "TimeDBRA=$D00; number of
  478. > DBRAs executed per millisecond [word] V-352"
  479. > Is this a reliable figure? Can the speed of the processor be determined
  480. > with this value? I would like to know because I am working on a info
  481. > program like MacEnvy.
  482.  
  483. You cannot determine the CPU speed this way. TimeDBRA can have different
  484. values depending on, say, whether or not the on-chip-cache for the 68040 is
  485. on or off, or whether a Mac IIci has a cache card.
  486.  
  487. > So the main question is how can I figure out the speed of the system
  488. > in Mhz? 
  489.  
  490. I'm afraid I don't have any clever ideas here. In my mind, the question
  491. isn't "How fast is my Mac going?" but "Is my Mac going fast enough for my
  492. needs?" A raw MHz rating isn't going to tell me that.
  493.  
  494. - -----
  495. Keith Rollin
  496. Phantom Programmer
  497. Taligent, Inc.
  498.  
  499. +++++++++++++++++++++++++++
  500.  
  501. From: REEKES@applelink.apple.com (Jim Reekes)
  502. Date: 19 Oct 92 18:44:27 GMT
  503. Organization: Apple Computer, Inc.
  504.  
  505. In article <mxmora-161092110250@css-mac1.sri.com>, mxmora@unix.sri.com
  506. (Matthew Xavier Mora) wrote:
  507. > I would like to know how to determine what MHZ a mac CPU is using.
  508. > I see a global called TimeDBRA which IM says "TimeDBRA=$D00; number of
  509. > DBRAs executed per millisecond [word] V-352"
  510.  
  511. But, it's the number of milliseconds for executing DBRAs from the ROM.
  512. This is different from the code speed being ran out of RAM.
  513. This number also doesn't consider many other factors such as 8, 16, or 32
  514. bit bus addressing, NuBus speeds, etc.
  515.  
  516. - -----------------------------------------------------------------------
  517. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  518.                              |          Sound Manager Expert
  519. Apple Computer, Inc.         | RAll opinions expressed are mine, and do
  520. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  521. Cupertino, CA 95014          |       employer, Apple Computer Inc.S
  522.  
  523. +++++++++++++++++++++++++++
  524.  
  525. From: mxmora@unix.SRI.COM (Matt Mora)
  526. Date: 20 Oct 92 16:14:44 GMT
  527. Organization: SRI International, Menlo Park, California
  528.  
  529. In article <REEKES-191092114530@90.10.20.67> REEKES@applelink.apple.com (Jim Reekes) writes:
  530. >
  531. >But, it's the number of milliseconds for executing DBRAs from the ROM.
  532. >This is different from the code speed being ran out of RAM.
  533. >This number also doesn't consider many other factors such as 8, 16, or 32
  534. >bit bus addressing, NuBus speeds, etc.
  535.  
  536.  
  537. If the figure is unreliable, then what's the purpose of this global? 
  538.  
  539. Does anybody know?
  540.  
  541.  
  542.  
  543.  
  544. Matt
  545.  
  546.  
  547.  
  548.  
  549.  
  550. - -- 
  551. ___________________________________________________________
  552. Matthew Mora                |   my Mac  Matt_Mora@sri.com
  553. SRI International           |  my unix  mxmora@unix.sri.com
  554. ___________________________________________________________
  555.  
  556. +++++++++++++++++++++++++++
  557.  
  558. From: peirce@outpost.SF-Bay.org (Michael Peirce)
  559. Date: 21 Oct 92 06:13:34 GMT
  560. Organization: Peirce Software
  561.  
  562.  
  563. In article <39732@unix.SRI.COM> (comp.sys.mac.programmer), mxmora@unix.SRI.COM (Matt Mora) writes:
  564. > In article <REEKES-191092114530@90.10.20.67> REEKES@applelink.apple.com (Jim Reekes) writes:
  565. > >
  566. > >But, it's the number of milliseconds for executing DBRAs from the ROM.
  567. > >This is different from the code speed being ran out of RAM.
  568. > >This number also doesn't consider many other factors such as 8, 16, or 32
  569. > >bit bus addressing, NuBus speeds, etc.
  570. > If the figure is unreliable, then what's the purpose of this global? 
  571. > Does anybody know?
  572.  
  573. Pure conjecture, but...
  574.  
  575. There are a number of things on the Mac that need direct, time critical
  576. attention by the CPU (such as the floppy disk and maybe AppleTalk).
  577. The code that does this *is* in ROM and probably uses the value to
  578. set up time critical code.
  579.  
  580. - --  Michael Peirce      --   peirce@outpost.SF-Bay.org
  581. - --  Peirce Software     --   Suite 301, 719 Hibiscus Place
  582. - --                      --   San Jose, California USA 95117
  583. - --  Makers of...        --   voice: (408) 244-6554 fax: (408) 244-6882
  584. - --            SMOOTHIE  --   AppleLink: peirce & America Online: AFC Peirce
  585.  
  586. +++++++++++++++++++++++++++
  587.  
  588. From: kent@sunfs3.Camex.COM (Kent Borg)
  589. Date: 21 Oct 92 14:49:23 GMT
  590. Organization: Camex Inc., Boston MA
  591.  
  592. In article <D2150035.gkd8e8@outpost.SF-Bay.org> peirce@outpost.SF-Bay.org (Michael Peirce) writes:
  593. >
  594. >In article <39732@unix.SRI.COM> (comp.sys.mac.programmer), mxmora@unix.SRI.COM (Matt Mora) writes:
  595. >> In article <REEKES-191092114530@90.10.20.67> REEKES@applelink.apple.com (Jim Reekes) writes:
  596. >> >
  597. >> >But, it's the number of milliseconds for executing DBRAs from the ROM.
  598. >> >This is different from the code speed being ran out of RAM.
  599. >> >This number also doesn't consider many other factors such as 8, 16, or 32
  600. >> >bit bus addressing, NuBus speeds, etc.
  601. >> 
  602. >> 
  603. >> If the figure is unreliable, then what's the purpose of this global? 
  604. >> 
  605. >> Does anybody know?
  606. >
  607. >Pure conjecture, but...
  608. >
  609. >There are a number of things on the Mac that need direct, time critical
  610. >attention by the CPU (such as the floppy disk and maybe AppleTalk).
  611. >The code that does this *is* in ROM and probably uses the value to
  612. >set up time critical code.
  613.  
  614.  
  615. More conjecture:
  616.  
  617. When that global was conceived the computer world was a simpler place.
  618. CPU data books still gave timing data for individual instructions,
  619. timings were still predictable.  It was a fair measure of raw computer
  620. speed.  These days, with nested caches and pipelined chips, timings
  621. are not even going to be always repeatable.
  622.  
  623. It makes me wonder how one does do timing critical code?  I guess by
  624. avoiding the point.  Localtalk timing is not CPU determined, is it?
  625. Isn't it the UART which clocks out those bits?  The CPU simply needs
  626. to be fast enough to supply the data and swallow the data.  For the
  627. floppy, I didn't think the CPU regulated the motor speed, I thought it
  628. just stuffed some hardware to set it.  (So why do they turn off
  629. interrupts?  Probably they have no buffer space on the IWM chip
  630. either.)
  631.  
  632. Non-Apple Sound Chip sound seems the most critical--and note, sound is
  633. one thing that broke on some accelerators. Maybe they were the ones
  634. that didn't adjust the TimeDBRA early enough in the boot
  635. process...comments Mr. Reekes?
  636.  
  637.  
  638. - --
  639. Kent Borg            kent@camex.com or kentborg@aol.com (when it is *working*)
  640.                                             H:(617) 776-6899  W:(617) 426-3577
  641. As always, things look better when some costs are left out.
  642.                               -Economist 3-28-92 p. 94
  643.  
  644. +++++++++++++++++++++++++++
  645.  
  646. From: bell@apple.com (Mike Bell)
  647. Date: 21 Oct 92 20:27:16 GMT
  648. Organization: Apple Computer, Inc.
  649.  
  650. In article <1992Oct21.104923.11491@sunfs3.Camex.COM>, kent@sunfs3.Camex.COM 
  651. (Kent Borg) writes:
  652.  
  653. > More conjecture:
  654. > When that global was conceived the computer world was a simpler place.
  655. > CPU data books still gave timing data for individual instructions,
  656. > timings were still predictable.  It was a fair measure of raw computer
  657. > speed.  These days, with nested caches and pipelined chips, timings
  658. > are not even going to be always repeatable.
  659. > It makes me wonder how one does do timing critical code?  I guess by
  660. > avoiding the point.  Localtalk timing is not CPU determined, is it?
  661.  
  662.  
  663. Well, sort of. While the actual data is clocked, the  LocalTalk protocol 
  664. timing is CPU speed dependent. For example, the IDG and IFG times are 
  665. measured by the processor. So, faster processors would run LocalTalk at the 
  666. wrong speed unless the time parameters were adjusted for each processor speed.
  667.  
  668.  
  669.  
  670.   -Mike
  671.  
  672.  
  673.  
  674. ****************************************************************************
  675.  
  676. Mike Bell                                                                                    email: bell@apple.com
  677. Senior Engineer
  678. 68000 High Performance Software Group
  679. MS 60-CS
  680. Apple Computer, Inc.
  681. 20525 Mariani Ave.
  682. Cupertino, CA 95014
  683.  
  684. ****************************************************************************
  685.  
  686. +++++++++++++++++++++++++++
  687.  
  688. From: Steve Christensen <stevec@apple.com>
  689. Date: Thu, 22 Oct 1992 00:57:19 GMT
  690. Organization: Apple Computer, Inc.
  691.  
  692. In article <39732@unix.SRI.COM> Matt Mora, mxmora@unix.SRI.COM writes:
  693. >REEKES@applelink.apple.com (Jim Reekes) writes:
  694. >>But, it's the number of milliseconds for executing DBRAs from the ROM.
  695. >>This is different from the code speed being ran out of RAM.
  696. >>This number also doesn't consider many other factors such as 8, 16, or
  697. 32
  698. >>bit bus addressing, NuBus speeds, etc.
  699. >
  700. >If the figure is unreliable, then what's the purpose of this global? 
  701. >Does anybody know?
  702.  
  703. TimeDBRA is calculated by executing a DBRA loop in ROM (with interrupts
  704. turned off and cache turned on, and the DBRA loop preloaded into the
  705. cache) as part of the startup process.  So running out of ROM or RAM
  706. has essentially no difference since the only hit you'd take would be
  707. for a single cache fetch of the loop instruction (DBRA), which is
  708. pretty much insignificant.
  709.  
  710. The only other thing that affects the timing of the loop is if interrupts
  711. are enabled while the loop is executing.  This will increase the time it
  712. takes to execute the loop, plus you may also have to re-fetch the DBRA
  713. instruction.
  714.  
  715. TimeDBRA is used for generating timing loops when (1) the loop time is
  716. under 16ms (1 tick), or (2) using the Delay() routine wouldn't work (if
  717. interrupts were disabled, for example).
  718.  
  719. For the speed-sensitive portions of the ROM and system software, it's
  720. important that they work on a wide variety of machines, no matter if
  721. it's a 16MHz '020 or a 33MHz '040.  TimeDBRA-based loops provide one
  722. means of throttling executing speed (when needed).
  723.  
  724. steve
  725.  
  726. +++++++++++++++++++++++++++
  727.  
  728. From: philip@research.canon.oz.au (Philip Craig)
  729. Date: 22 Oct 92 22:15:49 GMT
  730. Organization: Canon Information Systems Research Australia
  731.  
  732. In article <39732@unix.SRI.COM> mxmora@unix.SRI.COM (Matt Mora) writes:
  733. >In article <REEKES-191092114530@90.10.20.67> REEKES@applelink.apple.com (Jim Reekes) writes:
  734. >>
  735. >>But, it's the number of milliseconds for executing DBRAs from the ROM.
  736. >>This is different from the code speed being ran out of RAM.
  737. >>This number also doesn't consider many other factors such as 8, 16, or 32
  738. >>bit bus addressing, NuBus speeds, etc.
  739. >
  740. >
  741. >If the figure is unreliable, then what's the purpose of this global? 
  742. >
  743. >Does anybody know?
  744.  
  745. I always thought it was used by AppleTalk code to work out some timing
  746. details for the processor it was running on. I know I've seen references
  747. to AppleTalk fixes taking account of DBRA.
  748. - -- 
  749.    _/_/_/ _/  _/ _/ _/     _/ _/_/_/ _p_h_i_l_i_p_@_r_e_s_e_a_r_c_h_._c_a_n_o_n_._o_z_._a_u   _--_|\
  750.   _/  _/ _/  _/ _/ _/     _/ _/  _/  Phone: +61 2 805 2951        /      \
  751.  _/_/_/ _/_/_/ _/ _/     _/ _/_/_/   Fax:   +61 2 805 2929        \_.--._/
  752. _/     _/  _/ _/ _/_/_/ _/ _/     PO Box 313 North Ryde 2113 AUSTRALIA  v
  753.  
  754. ---------------------------
  755.  
  756. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  757. Subject: TrapAvailable for C (Was Re: help with Link failures in THINK C 5.03)
  758. Date: 19 Oct 92 01:57:40 GMT
  759. Organization: University of Illinois at Urbana
  760.  
  761. Here is my version of TrapAvailable for C. Hope it comes in handy:
  762.  
  763. Boolean TrapAvailable(short theTrap)
  764. {
  765.     long trapAddress;
  766.     
  767.     if(theTrap & 0x0800) {
  768.         theTrap &= 0x07FF;
  769.         if(theTrap >= ((GetToolTrapAddress(_InitGraf) == GetToolTrapAddress(0xAA6E)) ? 0x0200 : 0x0400))
  770.             return(false);
  771.         trapAddress = GetToolTrapAddress(theTrap);
  772.     } else {
  773.         trapAddress = GetOSTrapAddress(theTrap);
  774.     }
  775.     return(trapAddress != GetToolTrapAddress(_Unimplemented));
  776. }
  777.  
  778. pr
  779. - -- 
  780. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  781. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  782. System manager - Cognitive Science Group, Beckman Institute, UIUC
  783. Internet: resnick@cogsci.uiuc.edu
  784.  
  785. +++++++++++++++++++++++++++
  786.  
  787. From: bwilliam@iat.holonet.net (Bill Williams)
  788. Organization: HoloNet (BBS: 510-704-1058)
  789. Date: Mon, 19 Oct 1992 08:12:43 GMT
  790.  
  791. Hers my more verbose version of "Trap_Available", it is not as efficient
  792. but a little more clear.
  793.  
  794. INTEGER_16 Number_Of_Toolbox_Traps(void)
  795. {
  796. #define INITGRAF_TRAP        0xA86E
  797.  
  798.     if (NGetTrapAddress(INITGRAF_TRAP, ToolTrap) ==
  799. NGetTrapAddress(0xAA6E, ToolTrap))
  800.         return(0x200);
  801.     else
  802.         return(0x400);
  803.         
  804. }
  805. /*=**************************************************************************=*/
  806.  
  807.  
  808. /*=**************************************************************************=*/
  809. INTEGER_16 Get_Trap_Type(INTEGER_16 trap_Number)
  810. {
  811. #define TRAP_MASK        0x0800
  812.  
  813.     if ((trap_Number & TRAP_MASK) > 0)
  814.         return(ToolTrap);
  815.     else
  816.         return(OSTrap);
  817.         
  818. /*=**************************************************************************=*/
  819.  
  820.  
  821. /*=**************************************************************************=*/
  822. Boolean Trap_Available(INTEGER_16 trap_Number)
  823. {
  824.     INTEGER_16        trap_Type;
  825.     Boolean    function_Result;
  826.  
  827.  
  828.     function_Result = FALSE;
  829.     trap_Type = Get_Trap_Type(trap_Number);
  830.     if (trap_Type == ToolTrap) {
  831.         trap_Number = trap_Number & 0x07FF;
  832.         if (trap_Number >= Number_Of_Toolbox_Traps())
  833.             trap_Number = _Unimplemented;
  834.     }
  835.     
  836.     if (NGetTrapAddress(trap_Number, trap_Type) !=
  837. NGetTrapAddress(_Unimplemented, ToolTrap))
  838.         function_Result = TRUE;
  839.     
  840.     return(function_Result);
  841.     
  842. }
  843.  
  844.  
  845. Bill Williams
  846.  
  847.  
  848. +++++++++++++++++++++++++++
  849.  
  850. From: REEKES@applelink.apple.com (Jim Reekes)
  851. Date: 21 Oct 92 18:05:32 GMT
  852. Organization: Apple Computer, Inc.
  853.  
  854. In article <BwCIs6.Bs3@news.cso.uiuc.edu>, resnick@cogsci.uiuc.edu (Pete
  855. Resnick) wrote:
  856. > Here is my version of TrapAvailable for C. Hope it comes in handy:
  857. > Boolean TrapAvailable(short theTrap)
  858. > {
  859. >     long trapAddress;
  860. >     
  861. >     if(theTrap & 0x0800) {
  862. >         theTrap &= 0x07FF;
  863. >         if(theTrap >= ((GetToolTrapAddress(_InitGraf) == GetToolTrapAddress(0xAA6E)) ? 0x0200 : 0x0400))
  864. >             return(false);
  865. >         trapAddress = GetToolTrapAddress(theTrap);
  866. >     } else {
  867. >         trapAddress = GetOSTrapAddress(theTrap);
  868. >     }
  869. >     return(trapAddress != GetToolTrapAddress(_Unimplemented));
  870. > }
  871.  
  872.  
  873. Your version is very close to the one I use.  They're both based on the
  874. original version published by MacDTS and now in Inside Mac.  I've added an
  875. explaination as to how this works.  I also avoid tertiary expressions
  876. unless it's very very short and simple.
  877.  
  878.  
  879. #define       kOSTrapBit          (1<<11)  /* bit 11 is the OS Trap bit */
  880. #define       kATrapBits          0xA800   /* bits used by the A-Trap mechanism */
  881.  
  882. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  883. // InitGraf is always implemented (trap 0xA86E). If the trap table is big
  884. // enough, trap 0xAA6E will always point to either Unimplemented or some
  885. other
  886. // trap, but will never be the same as InitGraf. Thus, you can check the
  887. size
  888. // of the trap table by asking if the address of trap 0xA86E is the same as
  889. 0xAA6E.
  890.  
  891. short NumToolboxTraps(void)
  892. {
  893.     if ( GetToolboxTrapAddress(_InitGraf)
  894.          == GetToolboxTrapAddress(_InitGraf + 0x0200) )
  895.         return (0x0200);
  896.     else
  897.         return (0x0400);
  898. }
  899.  
  900. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  901. // Check to see if a given trap is implemented.  GetTrapAddress may fuck up
  902. and
  903. // wrap around into the trap table if you give it a toolbox trap that is
  904. out of
  905. // range, so check for this first.
  906.  
  907. Boolean TrapExists(short theTrap)
  908. {
  909.     long            trapAddress;
  910.  
  911.     if ( !(theTrap & kOSTrapBit) )                    // is it an OS trap?
  912.         trapAddress = GetOSTrapAddress(theTrap);
  913.     else {
  914.         theTrap &= ~kATrapBits;                       // get the trap
  915. number
  916.         if ( theTrap < NumToolboxTraps() )            // can this tool trap
  917. exist?
  918.             trapAddress = GetToolTrapAddress(theTrap);
  919.         else
  920.             return (false);
  921.     }
  922.     return ( GetToolboxTrapAddress(_Unimplemented) != trapAddress );
  923. }
  924.  
  925.  
  926. - -----------------------------------------------------------------------
  927. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  928.                              |          Sound Manager Expert
  929. Apple Computer, Inc.         | RAll opinions expressed are mine, and do
  930. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  931. Cupertino, CA 95014          |       employer, Apple Computer Inc.S
  932.  
  933. +++++++++++++++++++++++++++
  934.  
  935. From: engber@ils.nwu.edu (Mike Engber)
  936. Date: 22 Oct 92 19:17:22 GMT
  937. Organization: The Institute for the Learning Sciences
  938.  
  939.  
  940. Ok, here's my TrapAvailable implementation. The only reasons I can offer
  941. for why you should bother to look are:
  942.  
  943.   * TRAP_AVAIL is a #define macro and the determination of whether or
  944.     no the trap is a tool or os trap is done at compile time by a smart
  945.     compiler (like THINK C). So that's a small efficiency gain.
  946.  
  947.   * It's very terse. Obfuscated C code fans should love it. Unfortunatly,
  948.     several of the line are > 80 chars - so if your viewing it wrapped it
  949.     may be hard to read.
  950.  
  951. Below are the .h and a .c file. TRAP_AVAIL is the macro thats
  952. supposed to be used (as opposed to the two fns).  Written in THINK C.
  953.  
  954. - -ME
  955.  
  956. - ---
  957.  
  958. ***trapU.h***
  959.  
  960. #include <traps.h>
  961.  
  962. /* see IM VI p 3-8 */
  963. #define TRAP_IMPL(trap,type)    (NGetTrapAddress(trap,type) != NGetTrapAddress(_Unimplemented,ToolTrap))
  964. #define NUM_TOOL_TRAPS          (NGetTrapAddress(_InitGraf,ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap) ? 0x0200 : 0x0400)
  965. #define TRAP_TYPE(trap)         (trap & 0x0800 ? ToolTrap : OSTrap)
  966. #define TRAP_AVAIL(trap)        ((TRAP_TYPE(trap) == ToolTrap) ? ToolTrapAvail(trap) : OSTrapAvail(trap))
  967.  
  968. extern Boolean ToolTrapAvail(short theTrap);
  969. extern Boolean OSTrapAvail(short theTrap);
  970.  
  971.  
  972. ***trapU.c***
  973.  
  974.  
  975. #include "trapsU.h"
  976.  
  977. Boolean ToolTrapAvail(short theTrap){
  978.     return (theTrap & 0x7FFF >= NUM_TOOL_TRAPS) ? false : TRAP_IMPL(theTrap,ToolTrap);
  979. }
  980.  
  981. Boolean OSTrapAvail(short theTrap){
  982.     return TRAP_IMPL(theTrap,OSTrap);
  983. }
  984.  
  985. +++++++++++++++++++++++++++
  986.  
  987. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  988. Date: 22 Oct 92 22:03:26 GMT
  989. Organization: University of Illinois at Urbana
  990.  
  991. engber@ils.nwu.edu (Mike Engber) writes:
  992.  
  993. >  * TRAP_AVAIL is a #define macro and the determination of whether or
  994. >    no the trap is a tool or os trap is done at compile time by a smart
  995. >    compiler (like THINK C). So that's a small efficiency gain.
  996.  
  997. For OSTraps, it is certainly more efficent. For ToolTraps, depending on
  998. how many times you call TrapAvailable, NUM_TOOL_TRAPS being a macro
  999. would generate quite a bit more code. I like it in principle though.
  1000. Also, using NGetTrapAddress produces glue, whereas using
  1001. GetToolTrapAddress and GetOSTrapAddress just put the traps in-line.
  1002.  
  1003. pr
  1004. - -- 
  1005. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  1006. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  1007. System manager - Cognitive Science Group, Beckman Institute, UIUC
  1008. Internet: resnick@cogsci.uiuc.edu
  1009.  
  1010. ---------------------------
  1011.  
  1012. From: engber@ils.nwu.edu (Mike Engber)
  1013. Subject: calling GetMenu twice on same MENU - actually seems ok?
  1014. Date: 21 Oct 92 13:45:42 GMT
  1015. Organization: The Institute for the Learning Sciences
  1016.  
  1017.  
  1018. I know why you shouldn't call GetMenu twice on the same MENU. But,
  1019. recently I had decided this was the bug I was tracking and it turned
  1020. out not to be. It seems (in System 7 at least) that GetMenu has been
  1021. change to compensate for this common error. Can anyone confirm this?
  1022.  
  1023. And yes, I checked that the word at offset 6 didn't happen to be
  1024. zero after the first call to GetMenu.
  1025.  
  1026. Along similar lines, TN#78 warns that you need to set ResErrProc
  1027. to NULL while you call get menu, else if you're using a ResErrProc
  1028. on 128ROM machines your ResErrProc will get called when it shouldn't.
  1029. Has this ever been fixed? It's a pretty subtle point and one I would
  1030. never have know about if someone hadn't pointed it out to me.
  1031.  
  1032. In the end, none of these trap bug fixes really does any good
  1033. (as far as cleaning up code goes) if you want backward compatibility.
  1034. It sort of depressing to see all these hacks cluttering my code
  1035. with no real hope of ever eliminating them. I guess PowerPC will
  1036. offer some chance - depends on how backward compatible they make its
  1037. ToolBox.
  1038.  
  1039. - -ME
  1040.  
  1041. +++++++++++++++++++++++++++
  1042.  
  1043. From: lsr@taligent.com (Larry Rosenstein)
  1044. Date: 22 Oct 92 21:37:45 GMT
  1045. Organization: Taligent, Inc.
  1046.  
  1047. In article <1992Oct21.134542.4267@ils.nwu.edu>, engber@ils.nwu.edu (Mike
  1048. Engber) wrote:
  1049. > out not to be. It seems (in System 7 at least) that GetMenu has been
  1050. > change to compensate for this common error. Can anyone confirm this?
  1051.  
  1052. On a IIci, Quadra, and PB140, the ROM version of GetMenu seems to test
  1053. whether the defproc handle is a handle to an MDEF resource.  If not then it
  1054. assumes that the MDEF needs to be read in.  I don't have an older machine
  1055. to examine, in order to see if this is patched in earlier machines.
  1056.  
  1057. This should handle the most common cases of calling GetMenu twice, but it
  1058. won't help if you install a custom defproc that's not a real MDEF and call
  1059. GetMenu on that menu.  For example, rather than creating an MDEF resource,
  1060. some applications that use custom menus create a small handle that JMPs to
  1061. the defproc code, which is linked into the app.  I don't think the ROM test
  1062. will detect this case.
  1063.  
  1064. Larry Rosenstein
  1065. Taligent, Inc.
  1066.  
  1067. lsr@taligent.com
  1068.  
  1069. ---------------------------
  1070.  
  1071. From: csuley@cs.cornell.edu (Christopher Suley)
  1072. Subject: Resource Manager Questions
  1073. Date: 21 Oct 92 16:08:50 GMT
  1074. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  1075.  
  1076. I am writing some code that grabs resources out of a file that the user
  1077. chooses using StandardGetFile or SFGetFile.
  1078.  
  1079. When I am done with the file, I would like to call CloseResFile( refNum ),
  1080. but I realize that an enterprising user might choose to scrounge around
  1081. in the System file.  Closing the System file is a Bad Thing, so I am
  1082. trying to find a way to recognize that I have opened the System file,
  1083. and not close it.
  1084.  
  1085. IM V1 indicates that the System file is referred to with reference number 0.
  1086. However, I have found evidence to the contrary.
  1087.  
  1088. Using FSpOpenResFile (HOpenResFile under System 6), I watched in MacsBug as
  1089. I opened the System file.  The reference number returned was 2!  So, my
  1090. checking for refNum > 0 before CloseResFile( refNum ) was ineffective, and
  1091. I enjoyed a spectacular crash.
  1092.  
  1093. So, what is the official way to recognize that you have opened the System
  1094. file?  Should I just check to see if the type and creator are 'ZSYS','MACS'?
  1095.  
  1096. I also have a second question.  If I open up a resource file and grab its
  1097. resources, I don't want to dispose of resources that are already in use.
  1098. Would code like this be acceptable?:
  1099.  
  1100. n = Count1Resources( resType );
  1101. for ( i = 1 ; i <= n ; i++ )
  1102.   {
  1103.     SetResLoad( false );
  1104.     h = Get1IndResource( resType, i );
  1105.     SetResLoad( true );
  1106.     if ( GetHandleSize( h ) )
  1107.       disposeMe = false;
  1108.     else
  1109.       {
  1110.         disposeMe = true;
  1111.         LoadResource( h );
  1112.       }
  1113.  
  1114.     // yatta yatta yatta
  1115.  
  1116.     if ( disposeMe )
  1117.       ReleaseResource( h );
  1118.   }
  1119.  
  1120. Thanks in advance.
  1121.  
  1122. +++++++++++++++++++++++++++
  1123.  
  1124. From: marshall@sdd.hp.com (Marshall Clow)
  1125. Date: 21 Oct 92 17:20:30 GMT
  1126. Organization: Hewlett Packard San Diego Printer Division
  1127.  
  1128. In article <1992Oct21.160850.1076@cs.cornell.edu>, csuley@cs.cornell.edu
  1129. (Christopher Suley) wrote:
  1130. > I am writing some code that grabs resources out of a file that the user
  1131. > chooses using StandardGetFile or SFGetFile.
  1132. > When I am done with the file, I would like to call CloseResFile( refNum ),
  1133. > but I realize that an enterprising user might choose to scrounge around
  1134. > in the System file.  Closing the System file is a Bad Thing, so I am
  1135. > trying to find a way to recognize that I have opened the System file,
  1136. > and not close it.
  1137. [ stuff deleted ]
  1138.  
  1139. What you really want to do is to check if the file is already open. This
  1140. is true no matter what file you are modifying, System file or watever. If
  1141. the file is already open, then you don't want to close it. You can check
  1142. using PGetCatInfo, and checking the flags. One of them (bit 2) tells you if
  1143. the resource fork is open [See IM-IV pp 125]
  1144.  
  1145. > I also have a second question.  If I open up a resource file and grab its
  1146. > resources, I don't want to dispose of resources that are already in use.
  1147. > Would code like this be acceptable?:
  1148. [ code deleted ]
  1149. Looks ok to me.
  1150.  
  1151. > Thanks in advance.
  1152. You're welcome.
  1153.  
  1154. One other point: Remember to SetResLoad ( false ) before you open the
  1155. resource file, so that resources marked 'preload' will not get loaded.
  1156.  
  1157. Marshall Clow
  1158. San Diego Printer Division      Hewlett Packard
  1159. Internet: marshall@sdd.hp.com   AppleLink: HP.Marshall    AOL: MClow
  1160.  
  1161. +++++++++++++++++++++++++++
  1162.  
  1163. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1164. Date: 21 Oct 92 17:34:08 GMT
  1165. Organization: Kalamazoo College
  1166.  
  1167. csuley@cs.cornell.edu (Christopher Suley) writes:
  1168. >
  1169. >I am writing some code that grabs resources out of a file that the user
  1170. >chooses using StandardGetFile or SFGetFile.
  1171. >
  1172. >When I am done with the file, I would like to call CloseResFile( refNum ),
  1173. >but I realize that an enterprising user might choose to scrounge around
  1174. >in the System file.  Closing the System file is a Bad Thing, so I am
  1175. >trying to find a way to recognize that I have opened the System file,
  1176. >and not close it.
  1177.  
  1178. I would suggest that opening the System file (or any file already open)
  1179. is a very touchy thing to do.  Witness ResEdit's superstitious behavior
  1180. when you mess with it or with ResEdit itself.
  1181.  
  1182. The first thing that comes to mind, when you say you're getting 2 as the
  1183. System's refnum, is that you've just opened another access path to its
  1184. resource fork, which is not a Good Thing.  Might this be possible?
  1185.  
  1186. If you were I, I'd special-case the opening of the system file (checking
  1187. type/creator should do it, make sure it's in the blessed folder too).
  1188. (If you want the app to be able to open itself, you'll have to
  1189. special-case that as well.)  I'd handle a resource read by setting the
  1190. current resource file to 0 and reading it in (make sure you don't make
  1191. any cross-segment function calls that might require 'CODE' to be loaded
  1192. in).  Would that work?
  1193. - -- 
  1194.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1195.  Regrettably, my college's computer has once again deleted my in-box without
  1196.  even telling me who the senders were. If you sent me mail around Sunday night,
  1197.  contact me. Don't resend a long (100K) letter, it'll just delete it again.
  1198.  
  1199. +++++++++++++++++++++++++++
  1200.  
  1201. From: keith@taligent.com (Keith Rollin)
  1202. Date: 21 Oct 92 18:53:04 GMT
  1203. Organization: Taligent
  1204.  
  1205. In article <1992Oct21.160850.1076@cs.cornell.edu>, csuley@cs.cornell.edu
  1206. (Christopher Suley) wrote:
  1207. > I am writing some code that grabs resources out of a file that the user
  1208. > chooses using StandardGetFile or SFGetFile.
  1209. > When I am done with the file, I would like to call CloseResFile( refNum ),
  1210. > but I realize that an enterprising user might choose to scrounge around
  1211. > in the System file.  Closing the System file is a Bad Thing, so I am
  1212. > trying to find a way to recognize that I have opened the System file,
  1213. > and not close it.
  1214.  
  1215. Marshall Clow and James McCarthy have responded to this question already.
  1216. Unfortunately, there are problems with their solutions.
  1217.  
  1218. Marshall suggests looking at the resource-fork-is-open bit returned by
  1219. GetCatInfo. The problem with this is that this bit is set if the file is
  1220. open by _any_ process, when what you need to know is if the file is open by
  1221. _your_ process.
  1222.  
  1223. James suggests special checking for the System file. However, this ignores
  1224. other files that might be open, such as your own application, files open by
  1225. Suitcase, or System 7.1 font files.
  1226.  
  1227. A working solution is shown in DTS sample code #18. I think that someone
  1228. else posted an slightly different approach which I considered a little
  1229. better, but I'm afraid I can't remember what/who it was right now.
  1230.  
  1231. - -----
  1232. Keith Rollin
  1233. Phantom Programmer
  1234. Taligent, Inc.
  1235.  
  1236. +++++++++++++++++++++++++++
  1237.  
  1238. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1239. Date: 21 Oct 92 19:52:08 GMT
  1240. Organization: Kalamazoo College
  1241.  
  1242. [How do you get access to a resource fork that may already be open, e.g.
  1243. the System, your own app, another running app, a suitcase opened by
  1244. Suitcase, etc.?]
  1245.  
  1246. keith@taligent.com (Keith Rollin) writes:
  1247. >
  1248. >A working solution is shown in DTS sample code #18. I think that someone
  1249. >else posted an slightly different approach which I considered a little
  1250. >better, but I'm afraid I can't remember what/who it was right now.
  1251.  
  1252. I vaguely recall someone saying to open the resource file, then to check
  1253. the lo-mem global TopMapHndl.  If it was already open, the global
  1254. wouldn't change;  otherwise it would.  But I can't find any reference to
  1255. TopMapHndl.  Does this sound at all familiar?
  1256.  
  1257. By the way, am I correct in assuming that God will strike you down if
  1258. you try to open the System's resource fork with write access?  'cos
  1259. StdFile.p (sample #18) only demonstrates read access.  I expect ResEdit
  1260. is full of custom code that basically duplicates what the Resource
  1261. Manager does except it allows direct munging of already-open files like
  1262. the System...
  1263. - -- 
  1264.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1265.  Regrettably, my college's computer has once again deleted my in-box without
  1266.  even telling me who the senders were. If you sent me mail around Sunday night,
  1267.  contact me. Don't resend a long (100K) letter, it'll just delete it again.
  1268.  
  1269. +++++++++++++++++++++++++++
  1270.  
  1271. From: csuley@cs.cornell.edu (Christopher Suley)
  1272. Date: 21 Oct 92 19:56:28 GMT
  1273. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  1274.  
  1275. keith@taligent.com (Keith Rollin) writes:
  1276. >csuley@cs.cornell.edu (Christopher Suley) wrote:
  1277. >> 
  1278. >> I am writing some code that grabs resources out of a file that the user
  1279. >> chooses using StandardGetFile or SFGetFile.
  1280. >> 
  1281. >> When I am done with the file, I would like to call CloseResFile( refNum ),
  1282. >> but I realize that an enterprising user might choose to scrounge around
  1283. >> in the System file.  Closing the System file is a Bad Thing, so I am
  1284. >> trying to find a way to recognize that I have opened the System file,
  1285. >> and not close it.
  1286. >
  1287. >Marshall Clow and James McCarthy have responded to this question already.
  1288. >Unfortunately, there are problems with their solutions.
  1289. >
  1290. >Marshall suggests looking at the resource-fork-is-open bit returned by
  1291. >GetCatInfo. The problem with this is that this bit is set if the file is
  1292. >open by _any_ process, when what you need to know is if the file is open by
  1293. >_your_ process.
  1294.  
  1295. Actually, I'm doing this from a Control Panel (forgot to say that), so I'm
  1296. not really a process.  I don't think it matters who has it open, I just want
  1297. to know if it's open at all.
  1298.  
  1299. >A working solution is shown in DTS sample code #18.
  1300.  
  1301. Sample code #18 says to use read-only permission to get a unique access path
  1302. to a file, but cautions that you shouldn't use a read-only file because
  1303. someone else might come along and stomp on it.  Since all I am doing is
  1304. reading some resources out of the file into my own data structures, then
  1305. immediately closing (if appropriate) the file, does this affect me?  The
  1306. Mac OS isn't pre-emptive, so as long as my code is executing, no one else
  1307. is going to munge the resources I'm copying, right?
  1308.  
  1309. +++++++++++++++++++++++++++
  1310.  
  1311. From: mxmora@unix.SRI.COM (Matt Mora)
  1312. Date: 21 Oct 92 20:06:31 GMT
  1313. Organization: SRI International, Menlo Park, California
  1314.  
  1315. In article <1992Oct21.195208.13268@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  1316.  
  1317. >I vaguely recall someone saying to open the resource file, then to check
  1318. >the lo-mem global TopMapHndl.  If it was already open, the global
  1319. >wouldn't change;  otherwise it would.  But I can't find any reference to
  1320. >TopMapHndl.  Does this sound at all familiar?
  1321.  
  1322.  
  1323. TopMapHndl=$A50; 1st map in list [handle] IM vol 1 page 115
  1324.  
  1325.  
  1326.  
  1327.  
  1328. Matt
  1329.  
  1330.  
  1331.  
  1332. - -- 
  1333. ___________________________________________________________
  1334. Matthew Mora                |   my Mac  Matt_Mora@sri.com
  1335. SRI International           |  my unix  mxmora@unix.sri.com
  1336. ___________________________________________________________
  1337.  
  1338. +++++++++++++++++++++++++++
  1339.  
  1340. From: keith@taligent.com (Keith Rollin)
  1341. Date: 22 Oct 92 00:40:08 GMT
  1342. Organization: Taligent
  1343.  
  1344. In article <1992Oct21.195628.11737@cs.cornell.edu>, csuley@cs.cornell.edu
  1345. (Christopher Suley) wrote:
  1346. > Sample code #18 says to use read-only permission to get a unique access path
  1347. > to a file, but cautions that you shouldn't use a read-only file because
  1348. > someone else might come along and stomp on it.  Since all I am doing is
  1349. > reading some resources out of the file into my own data structures, then
  1350. > immediately closing (if appropriate) the file, does this affect me?  The
  1351. > Mac OS isn't pre-emptive, so as long as my code is executing, no one else
  1352. > is going to munge the resources I'm copying, right?
  1353.  
  1354. Keerect, keemosabi. Open-read-only/read/close will work as long as you
  1355. don't call WaitNextEvent (or let the Finder do it, which is the process
  1356. you're running under (with System 7)).
  1357.  
  1358. Both you and James pointed out that the technique I was referring to in
  1359. Sample Code #18 has been removed. Sorry for that dangling pointer. The
  1360. technique was to look at TopMapHndl, remember it, call FSpOpenResFile (yes,
  1361. I'm a System 7 bigot), and see if TopMapHndl had changed. If it had, then
  1362. the resource fork had just been opened, and needed to be closed when you
  1363. were done.
  1364.  
  1365. It's been a while since I've done this, so I hope I haven't forgotten
  1366. anything. I think it was Lawrence D'Oliveiro who described a method like
  1367. this several months ago. If so, I hope he'll point out any ommissions,
  1368. caveats, etc.
  1369.  
  1370. - -----
  1371. Keith Rollin
  1372. Phantom Programmer
  1373. Taligent, Inc.
  1374.  
  1375. +++++++++++++++++++++++++++
  1376.  
  1377. From: Quinn <quinn@cs.uwa.edu.au>
  1378. Organization: The University of Western Australia
  1379. Date: Fri, 23 Oct 1992 01:08:13 GMT
  1380.  
  1381. Will someone *please* bundle up *the* definitive solution to this
  1382. problem and mail it to Mike Kelly <mkelly@cs.uoregon.edu> so he can
  1383. put it in the FAQ.
  1384.  
  1385. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  1386. Department of Computer Science, The University of Western Australia
  1387.   -- "FAQ you, a***h***!", The Usenet Terminator (-:
  1388.  
  1389. +++++++++++++++++++++++++++
  1390.  
  1391. From: knott@apple.com (William Knott)
  1392. Date: 23 Oct 92 06:21:33 GMT
  1393. Organization: Apple Computer
  1394.  
  1395.  
  1396. One of the original fears that Christopher Suley stated was that 'Closing
  1397. the System file is a Bad Thing'.  I do agree with this, however calling 
  1398. CloseResFile on the System File will not close it, the resource manager
  1399. contains a check to make sure a file marked as non-closable is not closed, and
  1400. the system approprately enough is one of them
  1401.  
  1402. - -----
  1403. Bill Knott
  1404. Apple Computer, Inc.
  1405.  
  1406. ---------------------------
  1407.  
  1408. End of C.S.M.P. Digest
  1409. **********************
  1410.