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

  1. C.S.M.P. Digest             Tue, 20 Oct 92       Volume 1 : Issue 189
  2.  
  3. Today's Topics:
  4.  
  5.     Extended PRam
  6.     PathName from FSSpec (pascal code)
  7.     simulating page-flipping via cluts
  8.     HFS Calls in IM6?
  9.     HOT KEY trouble
  10.     Acessing the TRAP word
  11.     Writing an external file system
  12.     I wanna program a Newton - but how?
  13.     Trap word parameter to Set/GetTrapAddress?
  14.  
  15.  
  16.  
  17. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  18.  
  19. The digest is a collection of article threads from the internet newsgroup
  20. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  21. regularly and want an archive of the discussions.  If you don't know what a
  22. newsgroup is, you probably don't have access to it.  Ask your systems
  23. administrator(s) for details.  (This means you can't post questions to the
  24. digest.)
  25.  
  26. Each issue of the digest contains one or more sets of articles (called
  27. threads), with each set corresponding to a 'discussion' of a particular
  28. subject.  The articles are not edited; all articles included in this digest
  29. are in their original posted form (as received by our news server at
  30. cs.uoregon.edu).  Article threads are not added to the digest until the last
  31. article added to the thread is at least one month old (this is to ensure that
  32. the thread is dead before adding it to the digest).  Article threads that
  33. consist of only one message are generally not included in the digest.
  34.  
  35. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  36. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  37. file /pub/mac/csmp-digest/README before downloading any files.  The most
  38. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  39. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  40. archive has a mail server; send a message with the text '$MACarch help' (no
  41. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  42.  
  43. The digest is also available via email.  Just send a note saying that you
  44. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  45. automatically receive each new issue as it is created.  Sorry, back issues
  46. are not available through the mailing list.
  47.  
  48. Send administrative mail to mkelly@cs.uoregon.edu.
  49.  
  50.  
  51. -------------------------------------------------------
  52.  
  53. From: JTC4@psuvm.psu.edu
  54. Subject: Extended PRam
  55. Date: 9 Sep 92 14:13:29 GMT
  56. Organization: Penn State University
  57.  
  58. Does anyone know the format of PRam beond the 20 bytes documented in IM
  59. or where it is documented?  Information about how to access it (ReadXPRam
  60. and WriteXPRam?) would also be appreciated.  I am trying to set the alert
  61. sound to some default for system 7 and it seems to be kept in XPRam
  62. somewhere.  I also need to know where system 6.0.7 kept the defalt.
  63.  
  64. +++++++++++++++++++++++++++
  65.  
  66. From: jpugh@apple.com (Jon Pugh)
  67. Date: 14 Sep 92 21:47:06 GMT
  68. Organization: Apple Computer, Inc.
  69.  
  70. In article <92253.101329JTC4@psuvm.psu.edu>, JTC4@psuvm.psu.edu wrote:
  71. > Does anyone know the format of PRam beond the 20 bytes documented in IM
  72. > or where it is documented?  Information about how to access it (ReadXPRam
  73. > and WriteXPRam?) would also be appreciated.  I am trying to set the alert
  74. > sound to some default for system 7 and it seems to be kept in XPRam
  75. > somewhere.  I also need to know where system 6.0.7 kept the defalt.
  76.  
  77. It would appear that no one has written down all the secret bytes of XPRAM,
  78. although someone must arbitrate conflicts when we define stuff.  I've just
  79. never needed to know.  I did disassemble the Sound cdev to figure out where
  80. and how the beep resource number was saved for my SwitchBeep cdev
  81. (available on ftp.apple.com in /pub/pugh/switchbeep.sit.hqx).
  82.  
  83. The ReadXParam and WriteXParam traps are apparently discussed in the
  84. hardware manual (a WWDC trivia question was "What are the only traps not
  85. defined anywhere in Inside Macintosh?").  They are register based traps
  86. without glue, so they cannot be called directly from C or Pascal.
  87.  
  88. However, I have created two cheap routines which do exactly what you want. 
  89. Since I am a nice guy, at least at the moment, here they are.  Send money.
  90. ;)
  91.  
  92. FUNCTION GetBeep: Integer; INLINE $204F, $203C, $0002, $007C, $A051;
  93.  
  94. PROCEDURE SetBeep (theBeep: Integer); INLINE $204F, $203C, $0002, $007C,
  95. $A052;
  96.  
  97. These routines use the 'snd ' resource ID number.  This is the same under
  98. system 6 and 7.
  99.  
  100. As usual, these routines are unsafe and unsupported.  I might even be
  101. hosing your stack since I hand assembled them but they seem to work for me.
  102.  
  103. Jon
  104.  
  105. ---------------------------
  106.  
  107. From: mxmora@unix.sri.com (Matthew Xavier Mora)
  108. Subject: PathName from FSSpec (pascal code)
  109. Date: 9 Sep 92 00:21:34 GMT
  110. Organization: SRI International
  111.  
  112. I spent the long weekend cursing at the AppleEventManager
  113. trying to get the finder to open a control panel. Anyway,
  114. one of the things I discoverd was that the alias manager will
  115. give you a path name if you ask for it. Since my program needed to
  116. display the path name, I wrote a function that will return a full
  117. path name in a handle (not in a str255 so you it won't crash with long 
  118. path names) when you give it a fsspec. 
  119.  
  120. I also figured out how to get the finder to open a control panel.
  121. You need to send an open selection event. I finally found an example that
  122. worked and ported it to pascal. If you would like to see that code I can
  123. post it here also. Its a direct copy of C.K Han's C code that is on the 
  124. developers CD.
  125.  
  126. Here is the code:
  127.  
  128. {-------------------------------------------------------------------------}
  129. {Path Name From FSSpec                                                    }
  130. {by Matthew Xavier Mora                                                   }
  131. {9-8-92                                                                   }
  132. {Given a FSSpec this function will return a handle to the full path       }
  133. {name. It creates the handle as it goes. It does not have the limited     }
  134. {string length (255) problem like the ones I have seen. This of course    }
  135. {requires system seven or better because of the use of the alias manager  }
  136. { Don't forget to dispose the handle when you are done with it.           }
  137. {-------------------------------------------------------------------------}
  138. {$PUSH}
  139. {$-R}
  140.  function PathNameFromFSSpec (var theFile: FSSpec): Handle;
  141.   var
  142.    i: AliasInfoType;
  143.    theStr: STR63;
  144.    h: Handle;
  145.    oe: OSErr;
  146.    alias: AliasHandle;
  147.    theSize: longint;
  148.  begin
  149.   PathNameFromFSSpec := nil;
  150.   oe := NewAlias(nil, theFile, alias);          {create a temporary alias}
  151.   if alias = nil then                                       {if nil exit }
  152.    exit(PathNameFromFSSpec);
  153.  
  154.   h := NewHandle(0);
  155.   if h = nil then                                          {if nil exit. }
  156.    exit(PathNameFromFSSpec);
  157.  
  158.   i := asiAliasName;                       { set the index to the Parent }
  159.   if GetAliasInfo(alias, i, thestr) = noerr then     {get The parentName }
  160.    begin                                     {returns error if bad alias }
  161.     while thestr <> '' do      { will be '' when done traversing the path}
  162.      begin
  163.       theSize := longint(thestr[0]) + 1;       
  164.       thestr[0] := ':';  { use the size byte to store the colon. aux='/' }
  165.                                                 { Let Munger do the work }
  166.       theSize := Munger(h, 0, nil, 0, @thestr, thesize); 
  167.       i := i + asiParentName;           {set the index to the next parent}
  168.       oe := GetAliasInfo(alias, i, thestr);          {get the parentName }
  169.      end;
  170.                                                     {get the Volume Name }
  171.     oe := GetAliasInfo(alias, asiVolumeName, thestr);
  172.     theSize := longint(thestr[0]);
  173.     theSize := Munger(h, 0, nil, 0, Ptr(ord(@theStr) + 1), theSize);
  174.  
  175.     PathNameFromFSSpec := h;             {return the newly created handle}
  176.    end;
  177.   DisposeHandle(Handle(alias));
  178.  end;
  179. {$POP}
  180.  
  181.  
  182. Matt
  183.  
  184. +++++++++++++++++++++++++++
  185.  
  186. From: mxmora@unix.sri.com (Matthew Xavier Mora)
  187. Date: 14 Sep 92 20:13:59 GMT
  188. Organization: SRI International
  189.  
  190. I spent the long weekend cursing at the AppleEventManager
  191. trying to get the finder to open a control panel. Anyway,
  192. one of the things I discovered was that the alias manager will
  193. give you a path name if you ask for it. Since my program needed to
  194. display the path name, I wrote a function that will return a full
  195. path name in a handle (not in a str255 so it won't crash with long 
  196. path names) when you give it a fsspec. 
  197.  
  198. I also figured out how to get the finder to open a control panel.
  199. You need to send an open selection event. I finally found an example that
  200. worked and ported it to pascal. If you would like to see that code I can
  201. post it here also. Its a direct copy of C.K Han's C code that is on the 
  202. developers CD.
  203.  
  204. Here is the code:
  205.  
  206. {-------------------------------------------------------------------------}
  207. {Path Name From FSSpec                                                    }
  208. {by Matthew Xavier Mora                                                   }
  209. {9-8-92                                                                   }
  210. {Given a FSSpec this function will return a handle to the full path       }
  211. {name. It creates the handle as it goes. It does not have the limited     }
  212. {string length (255) problem like the ones I have seen. This of course    }
  213. {requires system seven or better because of the use of the alias manager  }
  214. { Don't forget to dispose the handle when you are done with it.           }
  215. {-------------------------------------------------------------------------}
  216. {$PUSH}
  217. {$-R}
  218.  function PathNameFromFSSpec (var theFile: FSSpec): Handle;
  219.   var
  220.    i: AliasInfoType;
  221.    theStr: STR63;
  222.    h: Handle;
  223.    oe: OSErr;
  224.    alias: AliasHandle;
  225.    theSize: longint;
  226.  begin
  227.   PathNameFromFSSpec := nil;
  228.   oe := NewAlias(nil, theFile, alias);          {create a temporary alias}
  229.   if alias = nil then                                       {if nil exit }
  230.    exit(PathNameFromFSSpec);
  231.  
  232.   h := NewHandle(0);
  233.   if h = nil then                                          {if nil exit. }
  234.    exit(PathNameFromFSSpec);
  235.  
  236.   i := asiAliasName;                       { set the index to the Parent }
  237.   if GetAliasInfo(alias, i, thestr) = noerr then     {get The parentName }
  238.    begin                                     {returns error if bad alias }
  239.     while thestr <> '' do      { will be '' when done traversing the path}
  240.      begin
  241.       theSize := longint(thestr[0]) + 1;       
  242.       thestr[0] := ':';  { use the size byte to store the colon. aux='/' }
  243.                                                 { Let Munger do the work }
  244.       theSize := Munger(h, 0, nil, 0, @thestr, thesize); 
  245.       i := i + asiParentName;           {set the index to the next parent}
  246.       oe := GetAliasInfo(alias, i, thestr);          {get the parentName }
  247.      end;
  248.                                                     {get the Volume Name }
  249.     oe := GetAliasInfo(alias, asiVolumeName, thestr);
  250.     theSize := longint(thestr[0]);
  251.     theSize := Munger(h, 0, nil, 0, Ptr(ord(@theStr) + 1), theSize);
  252.  
  253.     PathNameFromFSSpec := h;             {return the newly created handle}
  254.    end;
  255.   DisposeHandle(Handle(alias));
  256.  end;
  257. {$POP}
  258.  
  259.  
  260. Matt
  261.  
  262. ---------------------------
  263.  
  264. From: tmaehl@vax1.umkc.edu
  265. Subject: simulating page-flipping via cluts
  266. Date: 11 Sep 92 09:03:44 GMT
  267. Organization: University of Missouri - Kansas City
  268.  
  269. In article <1992Sep10.182147.25618@hobbes.kzoo.edu>, 
  270. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  271.  
  272. > How many games do you know that really, really _need_ 256 colors--not
  273. > 254 or 255 but 256?  If you're clut-flipping to simulate page-flipping,
  274. > OK;  if you're writing for a 2-bit-deep screen, I can see that.  Most
  275. > games get along fine with 254 colors.
  276.  
  277. Two questions: How do you simulate page-flipping with clut-flipping??
  278. Set one clut to all black and draw with it and then flip to the clut
  279. with the proper colors? I'm not sure I see where this gains you
  280. anything. Anyone care to explain in detail??
  281.  
  282. And second: Wouldn't this fail to accomplish anything at all on
  283. a direct color screen, or am I *completely* misunderstanding (a
  284. distinct possibility.)
  285.  
  286. Jonathan (tmaehl@vax1.umkc.edu)
  287.  
  288. +++++++++++++++++++++++++++
  289.  
  290. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  291. Date: 11 Sep 92 16:31:35 GMT
  292. Organization: Kalamazoo College
  293.  
  294. tmaehl@vax1.umkc.edu writes:
  295. >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  296. >
  297. >> If you're clut-flipping to simulate page-flipping,
  298. >> [you need every single color]
  299. >
  300. >Two questions: How do you simulate page-flipping with clut-flipping??
  301. >
  302. >And second: Wouldn't this fail to accomplish anything at all on
  303. >a direct color screen, or am I *completely* misunderstanding (a
  304. >distinct possibility.)
  305.  
  306. The easy one first:  yes, clut-flipping does nothing on a direct-color
  307. screen.  In fact, a direct-color screen doesn't even have a color table
  308. to flip.
  309.  
  310. Clut flipping is a nasty little technique that lets you pretend you have
  311. two video pages, each of which has half as many bits per pixel as the
  312. real video page.  In short, you split each pixel in half, and alternate
  313. between setting the clut so that one half is visible and the other half
  314. not.  An example might help clarify.
  315.  
  316. Let's say we're working on an 8-bit-deep screen.  Conceptually, split
  317. each pixel into two 4-bit halves, call them left and right.  To set the
  318. pixel at x,y on the left video page to, say, color 7, you set the high
  319. four bits of the actual pixel at x,y to 7, without disturbing the low
  320. four bits.  To set the pixel on the right video page to color 4, you set
  321. the low four bits to 4 without disturbing the high four bits.
  322.  
  323. Let's say the palette we're using is sixteen shades of gray.  (Note that
  324. you only get sixteen colors, since each page gets only four bits per
  325. pixel.  Note also that you can have different palettes for the left and
  326. the right page, and that there's actually a good use for that:  there
  327. are glasses that sync to your monitor that use LCD shutters to give a
  328. decent 3-D effect.  But I digress.)  Then, to display the left page, you
  329. set colors 0x00-0x0F to black, 0x10-0x1F to dark gray, ... , 0xF0-0xFF
  330. to white.  To display the right page, you set 0x00, 0x10, ... 0xF0 to
  331. black, 0x01, 0x11, ... 0xF1 to dark gray, and so on.
  332.  
  333. Note that you don't have to use hi-nybble/lo-nybble for left and right
  334. pages;  you can split up the pixel any way you want.  It doesn't even
  335. have to be an even split, and you can split it as many ways as there are
  336. bits in the pixel in the first place.  If you don't mind having only two
  337. colors and seeing the same eight frames over and over, you can do
  338. eight-position full-screen animation at whatever your monitor's refresh
  339. rate is, using just a tiny fraction of CPU power.
  340.  
  341. Note also that, if the palette(s) for your virtual pages all have all
  342. their bits clear for white and all their bits set for black, you can
  343. leave those two colors where they are, and the Palette Manager will be
  344. usable.  (Though I'll concede that there's no good reason not to use
  345. SetEntries instead of AnimatePalette when you're getting this
  346. low-level...)
  347. - -- 
  348.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  349.  "I may not understand what you say, but I'll defend to your death
  350.   my right to deny it."                 - Albert, from 'Outrageously Pogo'
  351.  
  352. +++++++++++++++++++++++++++
  353.  
  354. From: Joe.Francis@dartmouth.edu (Joe Francis)
  355. Date: 14 Sep 92 20:55:33 GMT
  356. Organization: Dartmouth College, Hanover, NH
  357.  
  358. Is this the technique that someone was trying to claim a software
  359. patent on?
  360.  
  361. ---------------------------
  362.  
  363. From: ba0k+@andrew.cmu.edu (Brian Patrick Arnold)
  364. Subject: HFS Calls in IM6?
  365. Date: 25 Aug 92 15:39:25 GMT
  366. Organization: Carnegie Mellon, Pittsburgh, PA
  367.  
  368.  
  369. Howdy,
  370.  
  371. Can anybody tell me whether the HFS High-level calls in Inside Macintosh
  372. Vol 6 noted as being equivalent to HFS low-level calls in Inside
  373. Macintosh Vol 4 ARE, IN FACT simply glue to HFS low-level traps, or are
  374. they specific to System 7, i.e., traps themselves?  I noticed that
  375. MacApp 3.0's TFile class uses these HOpenDF etc. without checking for
  376. System 7 or File Manager Gestalt.  TFile does check for Alias manager
  377. using Gestalt, to filter out whether it will do certain FSp, Finder and
  378. Alias Manager calls, but it doesn't filter on the H calls.  I am
  379. compelled to assume it is safe to use H calls documented in Inside
  380. Macintosh vol 6 provided I have the correct include files, and the
  381. correct linker glue?  Am I just stupid and I didn't find the sentence in
  382. Inside Macintosh Vol 6 that explains that I can call the HFS High-level
  383. calls (HRename, HOpenDF etc.) as long as HFS is present? These are the
  384. ones that accept dirIDs, instead of continuing to use FSOpen etc with
  385. working directories, and I am NOT talking about the FSp calls that
  386. require System 7 obviously.  Somebody set me straight.  Thanks,
  387.  
  388. - - Brian
  389.  
  390. +++++++++++++++++++++++++++
  391.  
  392. From: leonardr@ccs.itd.umich.edu
  393. Organization: Campus Computing Sites, University of Michigan-Ann Arbor
  394. Date: Wed, 26 Aug 1992 03:27:07 GMT
  395.  
  396. In article <keagGhC00UhWM6nGQa@andrew.cmu.edu> ba0k+@andrew.cmu.edu (Brian Patrick Arnold) writes:
  397. >
  398. >Howdy,
  399. >
  400. >Can anybody tell me whether the HFS High-level calls in Inside Macintosh
  401. >Vol 6 noted as being equivalent to HFS low-level calls in Inside
  402. >Macintosh Vol 4 ARE, IN FACT simply glue to HFS low-level traps, or are
  403. >they specific to System 7, i.e., traps themselves?  
  404. >
  405.     All of the high level HFS calls ('Hxxx') are valid under System 6 -
  406. EXCEPT HOpenDF which is only valid for Sys7.  However there is no easy way
  407. to test for just "_OpenDF" implemented.  I usually test for the FSSpec
  408. calls to be valid (via Gestalt) and if they are, then so is the OpenDF 
  409. routines.
  410.  
  411. >I noticed that
  412. >MacApp 3.0's TFile class uses these HOpenDF etc. without checking for
  413. >System 7 or File Manager Gestalt.  TFile does check for Alias manager
  414. >using Gestalt, to filter out whether it will do certain FSp, Finder and
  415. >Alias Manager calls, but it doesn't filter on the H calls.  
  416. >
  417.     that would mean that MacApp 3 programs won't work under System 6!
  418.  
  419. - -- 
  420. - -----------------------------------------------------------------------
  421. Leonard Rosenthol          Internet: leonardr@ccs.itd.umich.edu
  422. Director of Advanced Technology   AppleLink: MACgician
  423. Aladdin Systems, inc.          GEnie:     MACgician
  424.  
  425. +++++++++++++++++++++++++++
  426.  
  427. From: ksand@apple.com (Kent Sandvik)
  428. Date: 15 Sep 92 04:25:36 GMT
  429. Organization: Apple
  430.  
  431. In article <1992Aug26.032707.9139@terminator.cc.umich.edu>,
  432. leonardr@ccs.itd.umich.edu wrote:
  433. > In article <keagGhC00UhWM6nGQa@andrew.cmu.edu> ba0k+@andrew.cmu.edu (Brian Patrick Arnold) writes:
  434. > >I noticed that
  435. > >MacApp 3.0's TFile class uses these HOpenDF etc. without checking for
  436. > >System 7 or File Manager Gestalt.  TFile does check for Alias manager
  437. > >using Gestalt, to filter out whether it will do certain FSp, Finder and
  438. > >Alias Manager calls, but it doesn't filter on the H calls.  
  439. > >
  440. >     that would mean that MacApp 3 programs won't work under System 6!
  441.  
  442. Huh? MacApp 3.0.1 TFile uses PBHOpenDenySync OR PBHOpenSync for opening the
  443. data fork, and HOpenResFile for opening the resource fork System 6-wise,
  444. and FSpOpenResFile if System 7 is present. The last thing is also
  445. a little bit questionable, because HOpenResFile works fine in both
  446. environments (looking at the code the MacApp engineers saved one
  447. link assignment for the file name, so I guess they saved 20-30 cycles
  448. on that one).
  449.  
  450. So there are no known problems as I know of opening files with
  451. the MacApp provided TFile Open routines. Using PBHOpenDenySync before
  452. PBHOpenSync is also smart; MacApp tests if the file has file
  453. access permissions OK (shared volume) before trying PBHOpenSync
  454. on a normal HFS based volume. I guess anyone else looking at 
  455. File I/O routines could take a look at the code inside UFile.cp 
  456. in the MacApp library folder.
  457.  
  458. Cheers,
  459. Kent Sandvik/DTS
  460.  
  461. "I would rather have a thousands idiots attacking my position, than
  462. have one idiot helping to defend it."    [Paraphrased from Voltaire]
  463. - -------------------
  464. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  465. DISCLAIMER: Private activities on the Net.
  466.  
  467. ---------------------------
  468.  
  469. From: gbs@panix.com (Eric Braun)
  470. Subject: HOT KEY trouble
  471. Date: 30 Jul 92 18:56:18 GMT
  472. Organization: PANIX Public Access Unix, NYC
  473.  
  474. Hi,
  475.  
  476. I'm implementing a hot key by patching JGNEFilter and looking for the
  477. appropriate key as the events flow by.  This works fine and dandy.
  478. The problem is that the hot key is supposed to open up my DA and the
  479. way it works now is that it'll open up the DA on top of almost
  480. anything!
  481.  
  482. This is bad new cus you don't want a DA poping up on top of, say, a
  483. file selection box, or any other modal dialog for that matter.
  484.  
  485. THE QUESTIONS: how can I tell if a modal dialog box is open so as to
  486. temporarily disable the hotkey?  Are there any other situations that
  487. might cause problems where I should also disable it?
  488.  
  489. Perhaps a hot-key would better be implemented in some other way?
  490.  
  491. thanks in advance  -eeb
  492.  
  493. ___________________________________________________________
  494. Eric Braun                Glass Bead Software
  495. gbs@panix.com                803 President St.
  496. (718)230-8010                       Brooklyn, NY 11215
  497. - -- 
  498. ___________________________________________________________
  499. Eric Braun                Glass Bead Software
  500. gbs@panix.com                803 President St.
  501.  
  502. +++++++++++++++++++++++++++
  503.  
  504. From: gadget@engin.umich.edu (Timothy David Sharpe)
  505. Date: 2 Aug 92 04:16:14 GMT
  506. Organization: University of Michigan Engineering, Ann Arbor
  507.  
  508. In article <1992Jul30.185618.10382@panix.com> gbs@panix.com (Eric Braun) writes:
  509. >Hi,
  510. >
  511. >I'm implementing a hot key by patching JGNEFilter and looking for the
  512. >appropriate key as the events flow by.  This works fine and dandy.
  513. >The problem is that the hot key is supposed to open up my DA and the
  514. >way it works now is that it'll open up the DA on top of almost
  515. >anything!
  516. >
  517. >This is bad new cus you don't want a DA poping up on top of, say, a
  518. >file selection box, or any other modal dialog for that matter.
  519. >
  520.   Well if you have a hot key, why not let someone use it whenever they want,
  521. just put up a big cancel button in your DA's window.
  522.  
  523. >THE QUESTIONS: how can I tell if a modal dialog box is open so as to
  524. >temporarily disable the hotkey?  Are there any other situations that
  525. >might cause problems where I should also disable it?
  526. >
  527.   Maybe there's a way to find out if there's a ProcFilter taking all the events?
  528.  
  529.  If the machine is running TCP programs, your DA might cause a timeout error
  530. <<I don't know how to check for that either though>>
  531.  
  532. >Perhaps a hot-key would better be implemented in some other way?
  533. >
  534. >Maybe figure out how to put a menu key into the Sys 7.0 Apple menu.
  535.  
  536. >thanks in advance  -eeb
  537.  
  538. +++++++++++++++++++++++++++
  539.  
  540. From: jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  541. Date: 2 Aug 92 09:19:58 GMT
  542. Organization: Computer Science Dept, QMW, University of London
  543.  
  544. In <60W-x6B@engin.umich.edu> gadget@engin.umich.edu (Timothy David Sharpe) writes:
  545. >I'm implementing a hot key by patching JGNEFilter and looking for the
  546. >appropriate key as the events flow by.  This works fine and dandy.
  547. >The problem is that the hot key is supposed to open up my DA and the
  548. >way it works now is that it'll open up the DA on top of almost
  549. >anything!
  550. >
  551. >This is bad new cus you don't want a DA poping up on top of, say, a
  552. >file selection box, or any other modal dialog for that matter.
  553. >
  554.  
  555. >THE QUESTIONS: how can I tell if a modal dialog box is open so as to
  556. >temporarily disable the hotkey?  Are there any other situations that
  557. >might cause problems where I should also disable it?
  558. >
  559.  
  560. I had a similar problem with Apollo, an INIT I've written. This
  561. is my solution:
  562.  
  563. Boolean FrontIsDialog(void)
  564. {
  565.     WindowPtr w = FrontWindow();
  566.     return (w!=nil && GetWVariant(w)==dBoxProc);
  567. }
  568.  
  569. if (MyHotKeyPressed() && !FrontIsDialog())
  570.     DoSpecialStuff();
  571.  
  572. Seems to work: just realised that it won't pick up moveable
  573. modals, though.
  574.  
  575. Jeremy
  576.  
  577. ---------------------------
  578.  
  579. From: bscott@sbphy.physics.ucsb.edu ( Brian Scott)
  580. Subject: Acessing the TRAP word
  581. Date: 31 Jul 92 04:43:20 GMT
  582.  
  583.  
  584. Hi,
  585.  
  586. When you overload a trap, how can you access the trap word
  587. in the routine that handles the trap.  I am overloading the 
  588. PBRead routine.  I need to check whether the ASYNC bit of
  589. the trap word has been set in my routine that handles PBRead.
  590. Is this possible?
  591.  
  592. Any help is appreciated,
  593.  
  594. Thanks,
  595.  
  596. Brian
  597.  
  598. +++++++++++++++++++++++++++
  599.  
  600. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  601. Date: 31 Jul 92 06:34:15 GMT
  602. Organization: U.C. Berkeley Open Computing Facility
  603.  
  604. In article <bscott.712557800@sbphy.physics.ucsb.edu> bscott@sbphy.physics.ucsb.edu ( Brian Scott) writes:
  605. >
  606. >Hi,
  607. >
  608. >When you overload a trap, how can you access the trap word
  609. >in the routine that handles the trap.  I am overloading the 
  610. >PBRead routine.  I need to check whether the ASYNC bit of
  611. >the trap word has been set in my routine that handles PBRead.
  612. >Is this possible?
  613.  
  614. Check the registers using macsbug or tmon on entry to your patch.  I think
  615. D2 has the trap word.  Not sure how documented this is, it might not be at all,
  616. but it has worked for me under 2 system versions and all macs.  (Well not the
  617. pre-plus ones, but that hardly had anything to do with traps).
  618.  
  619. E. Wylie
  620.  
  621. - ----
  622. Increasing message length so my machine will actually post it..
  623. .
  624. .
  625. .
  626. ... hate this thing.
  627.  
  628. +++++++++++++++++++++++++++
  629.  
  630. From: gurgle@netcom.com (Pete Gontier)
  631. Date: 1 Aug 92 16:44:25 GMT
  632. Organization: cellular
  633.  
  634. ewylie@ocf.berkeley.edu (Elizabeth Wylie) writes:
  635.  
  636. >In article <bscott.712557800@sbphy.physics.ucsb.edu> bscott@sbphy.physics.ucsb.edu ( Brian Scott) writes:
  637. >>When you overload a trap, how can you access the trap word
  638. >>in the routine that handles the trap.  I am overloading the 
  639. >>PBRead routine.  I need to check whether the ASYNC bit of
  640. >>the trap word has been set in my routine that handles PBRead.
  641. >>Is this possible?
  642.  
  643. >I think D2 has the trap word.
  644.  
  645. It's D1. Do an 'atb control' in MacsBug, step once, and the trap word
  646. is sitting there in D1.
  647.  
  648. >Not sure how documented this is, it might not be at all,
  649. >but it has worked for me under 2 system versions and all macs.
  650.  
  651. And I think it will continue to work; all sorts of sofware makes this
  652. assumption. I think 68000 family Macs will always do this as a result.
  653. Be aware that it's valid only for OS traps, though.
  654.  
  655. Also be aware that code that makes assumtpions like this, and in fact
  656. any assembly at all, is going to have to be rewritten for the RISC Macs
  657. which apparently might be out as early as next year.
  658. - -- 
  659.  Pete Gontier // EC Technology // gurgle@netcom.com
  660.  
  661. +++++++++++++++++++++++++++
  662.  
  663. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  664. Date: 2 Aug 92 01:17:45 GMT
  665. Organization: U.C. Berkeley Open Computing Facility
  666.  
  667.  
  668. Well, ok.  It's in D1, then.
  669.  
  670. - -E Wylie
  671.  
  672. ---------------------------
  673.  
  674. Subject: Writing an external file system
  675. From: russells@ccu1.aukuni.ac.nz (Russell Street)
  676. Date: Wed, 8 Jul 1992 04:19:02 GMT
  677. Organization: University of Auckland, New Zealand.
  678.  
  679. Anyone got any idea how to write an external file system 
  680. for the Macintosh?  IM only points me to Tech Support,
  681. which apparently does not give much support (though I
  682. have not tried there yet).
  683.  
  684. Thanks for any information...
  685. - --------------------------------------------------------------
  686. Russell Street (russells@ccu1.aukuni.ac.nz)
  687.     It was the least I could do -- a quantity I specialize in.
  688.  
  689.  
  690.  
  691.  
  692. +++++++++++++++++++++++++++
  693.  
  694. From: creiman@Apple.COM (Charle Reiman)
  695. Date: 8 Jul 92 16:09:48 GMT
  696. Organization: Apple Computer Inc., Cupertino, CA
  697.  
  698. russells@ccu1.aukuni.ac.nz (Russell Street) writes:
  699.  
  700. >Anyone got any idea how to write an external file system 
  701. >for the Macintosh?  IM only points me to Tech Support,
  702. >which apparently does not give much support (though I
  703. >have not tried there yet).
  704.  
  705. Short answer: You're doomed. Sorry. 
  706.  
  707. Long answer: The external file interafce isn't etched in stone. If you
  708. contact DTS, they'll first warn you away, then (if you persist in being
  709. bothersome) send you a large bundle of unreleased documentation,
  710. prefaced with many warnings and apolgies. This isn't the usual "Don't
  711. use that global!" warning; they are very serious about the probability
  712. of change.
  713.  
  714. My advice is to not do it. It'll take a lot of effort and reverse
  715. engineering, plus your code will almost certainly break in the future.
  716.  
  717. Disclaimer: External file systems is a touchy subject with DTS. I am
  718. not in DTS and do not speak for them. However, I am speaking from
  719. personal experience.
  720.  
  721. - -- 
  722. Charlie Reiman
  723. creiman@apple.com
  724.  
  725. +++++++++++++++++++++++++++
  726.  
  727. From: amanda@intercon.com (Amanda Walker)
  728. Date: Sat, 11 Jul 92 20:32:46 GMT
  729. Organization: InterCon Systems Corporation
  730.  
  731. russells@ccu1.aukuni.ac.nz (Russell Street) writes:
  732. > Anyone got any idea how to write an external file system 
  733. > for the Macintosh?  IM only points me to Tech Support,
  734. > which apparently does not give much support (though I
  735. > have not tried there yet).
  736.  
  737. The short answer is "it's not worth it."  The long answer is "it is possible,
  738. but extremely aggravating."  This is part of why Apple won't help you;
  739. you basically have to have carnal knowledge of the File Manager and the
  740. Finder(s) in order to do it righ, and even then it will make you crazy.
  741. You will swear at your Mac.  You will find yourself going to see Arnold
  742. Schwarzenegger movies just to watch things blow up spectacularly.
  743.  
  744. Basically, this is one of those areas of the Toolbox Jungle where, if you can't
  745. find your own way, you probably shouldn't be there :)...
  746.  
  747.  
  748. Amanda Walker <amanda@intercon.com>
  749. InterCon Systems Corporation
  750. - -- 
  751. "Don't try to out-weird me--I get stranger things than you free with
  752.  my breakfast cereal..."    --Hitchhiker's Guide To The Galaxy
  753.  
  754.  
  755. +++++++++++++++++++++++++++
  756.  
  757. From: rae@alias.com (Reid Ellis)
  758. Organization: Alias Research, Inc., Toronto ON Canada
  759. Date: Tue, 14 Jul 1992 00:29:58 GMT
  760.  
  761. Russell Street <russells@ccu1.aukuni.ac.nz> writes:
  762. |Anyone got any idea how to write an external file system 
  763. |for the Macintosh?  IM only points me to Tech Support,
  764. |which apparently does not give much support (though I
  765. |have not tried there yet).
  766.  
  767. Amanda Walker <amanda@intercon.com> writes:
  768. |The short answer is "it's not worth it."  The long answer is "it is possible,
  769. |but extremely aggravating."
  770.  
  771. Have there been any word of this changing in the near future? [System
  772. 7.1, maybe?]
  773.  
  774. Reid
  775. - --
  776. Reid Ellis                                            
  777. rae@utcs.utoronto.ca        ||           rae@Alias.com
  778. CDA0610@applelink.apple.com ||  +1 416 362 9181 [work]
  779.  
  780. +++++++++++++++++++++++++++
  781.  
  782. From: amanda@intercon.com (Amanda Walker)
  783. Date: 14 Jul 92 16:24:07 GMT
  784. Organization: InterCon Systems Corporation
  785.  
  786. rae@alias.com (Reid Ellis) writes:
  787. > Have there been any word of this changing in the near future? [System
  788. > 7.1, maybe?]
  789.  
  790. There have been rumblings about a File System Manager, which would support
  791. a well-defined external file system interface, but like many things 
  792. originally planned for System 7, it was evidently harder than it seemed, even 
  793. for Apple :).
  794.  
  795. We can but hope for it.
  796.  
  797. Amanda Walker <amanda@intercon.com>
  798. - -- 
  799. "Many of the truths we cling to depend greatly upon our point of view."
  800.         --Obi-Wan Kenobi in "Return of the Jedi"
  801.  
  802. +++++++++++++++++++++++++++
  803.  
  804. From: Quinn <quinn@cs.uwa.edu.au>
  805. Organization: The University of Western Australia
  806. Date: Thu, 16 Jul 1992 01:42:43 GMT
  807.  
  808. >Amanda Walker <amanda@intercon.com> comments on the joys of writing
  809. >external file systems:
  810. >|The short answer is "it's not worth it."  The long answer is "it is 
  811. >|possible, but extremely aggravating."
  812. >
  813. >Reid Ellis <rae@alias.com> then asks:
  814. >Have there been any word of this changing in the near future? [System
  815. >7.1, maybe?]
  816.  
  817. Interesting question.  Personally I'm waiting for the "File System
  818. Manager" to be finalised.  Do this:  Get a copy of Gestalt DA 0.4,
  819. look at the gestaltFSAttr selector and observe the meaning of bit 2
  820. ("File System Manager present").  Most of you will have this bit
  821. clear, however those of you with Macintosh PC Exchange installed
  822. will have it set.  Curious.  Methinks PC Exchange comes with an
  823. early version of the File System Manager and that one day, hopefully
  824. in the not too distant future, Apple will reveal the secrets of it
  825. to everyone.
  826.  
  827. Quinn "The Eskimo!"   <quinn@cs.uwa.edu.au>  "Real Coke, Diet .sig"
  828. Department of Computer Science, The University of Western Australia
  829.   -- Waiting, waiting, waiting...
  830.  
  831. +++++++++++++++++++++++++++
  832.  
  833. From: dstine@cisco.com (David S.A. Stine)
  834. Organization: cisco Systems, Menlo Park, California, USA
  835. Date: Tue, 21 Jul 1992 07:51:14 GMT
  836.  
  837. In article <2A5F456E.5AA5@intercon.com> amanda@intercon.com (Amanda Walker) writes:
  838. >russells@ccu1.aukuni.ac.nz (Russell Street) writes:
  839. >> Anyone got any idea how to write an external file system 
  840. >> for the Macintosh?  IM only points me to Tech Support,
  841. >> which apparently does not give much support (though I
  842. >> have not tried there yet).
  843. >
  844. >The short answer is "it's not worth it."  The long answer is "it is possible,
  845. >but extremely aggravating."  This is part of why Apple won't help you;
  846. >you basically have to have carnal knowledge of the File Manager and the
  847. >Finder(s) in order to do it righ, and even then it will make you crazy.
  848. >You will swear at your Mac.  You will find yourself going to see Arnold
  849. >Schwarzenegger movies just to watch things blow up spectacularly.
  850.  
  851. Indeed. I can second this, having had the pleasure of writing one...
  852.  
  853. >Basically, this is one of those areas of the Toolbox Jungle where, if you can't
  854. >find your own way, you probably shouldn't be there :)...
  855.  
  856. As a pointer to find your own way, I would recommend that you break out your
  857. copy of MacNosy (if you want to do this level of programming, you MUST have
  858. Nosy) and disassemble the AppleShare client. It has an EFS contained within it
  859. which translates the Finder HFS calls into AFP calls.
  860.  
  861.  
  862. dsa
  863.  
  864.  
  865. +++++++++++++++++++++++++++
  866.  
  867. From: Quinn <quinn@cs.uwa.edu.au>
  868. Organization: The University of Western Australia
  869. Date: Wed, 22 Jul 1992 01:45:40 GMT
  870.  
  871. David S.A. Stine talks about the easiest way to figure out external
  872. file systems on the Mac:
  873.  
  874. >As a pointer to find your own way, I would recommend that you break out
  875. your
  876. >copy of MacNosy (if you want to do this level of programming, you MUST
  877. have
  878. >Nosy) and disassemble the AppleShare client.
  879.  
  880. Damn the licencing agreement, full speed ahead!  (-:
  881.  
  882. Quinn "The Eskimo!"   <quinn@cs.uwa.edu.au>  "Real Coke, Diet .sig"
  883. Department of Computer Science, The University of Western Australia
  884.   -- Who was going to quote chapter and verse but can't *actually*
  885.      find a copy of Apple's system software licencing agreement |-:
  886.  
  887. +++++++++++++++++++++++++++
  888.  
  889. From: sdorner@qualcom.qualcomm.com (Steve Dorner)
  890. Date: 24 Jul 92 01:58:08 GMT
  891. Organization: Qualcomm, Inc., San Diego, CA
  892.  
  893. Quinn <quinn@cs.uwa.edu.au> writes:
  894. >>Nosy) and disassemble the AppleShare client.
  895. >Damn the licensing agreement, full speed ahead!  (-:
  896.  
  897. That's right; you're not allowed to "reduce the software to human-
  898. perceivable form".  Apple's lawyers are such kidders.
  899. - -- 
  900. Steve Dorner, Qualcomm, Inc.
  901. Yes, I'm still working on Eudora and it's still free.
  902.  
  903. +++++++++++++++++++++++++++
  904.  
  905. From: milt@tenon.com (Milt Roselinsky)
  906. Date: 27 Jul 92 21:24:31 GMT
  907. Organization: "Tenon Intersystems"
  908.  
  909. Russell Street <russells@ccu1.aukuni.ac.nz> writes:
  910. |Anyone got any idea how to write an external file system 
  911. |for the Macintosh?  IM only points me to Tech Support,
  912. |which apparently does not give much support (though I
  913. |have not tried there yet).
  914.  
  915. In IM IV, there is an obscure reference to "eXternal File
  916. System Development Package for Foreign File Access".  I was able to
  917. get this through dts, and used it to implement NFS as a XFS under MachTen.
  918. The package was a very nice headstart on what was required, with example
  919. code for a "read only" file system.
  920.  
  921. milt
  922.  
  923. +++++++++++++++++++++++++++
  924.  
  925. From: scott@mcl.ucsb.edu (Scott Bronson)
  926. Date: 28 Jul 92 05:53:41 GMT
  927.  
  928. In <1992Jul24.015808.17679@qualcomm.com> sdorner@qualcom.qualcomm.com (Steve Dorner) writes:
  929.  
  930. >Quinn <quinn@cs.uwa.edu.au> writes:
  931. >>>Nosy) and disassemble the AppleShare client.
  932. >>Damn the licensing agreement, full speed ahead!  (-:
  933.  
  934. >That's right; you're not allowed to "reduce the software to human-
  935. >perceivable form".  Apple's lawyers are such kidders.
  936.  
  937. Truly.  I remember long summers hacking on the Apple II, burying my
  938. nose in the mini-assembler and poking bytes in by hand.  Towards the
  939. end of the summers, I would normally be able to tell you what certain
  940. code did simply by looking at the hex dump.  What do you think every
  941. time you see 4E71?  Well, I knew most 6502 opcodes this comfortably.
  942.  
  943. If they had had this agreement back then, then they would have been
  944. in violation of their own agreement when they assembled it, right?
  945.  
  946. Just a thought...
  947.  
  948.     - Scott
  949.  
  950. ---------------------------
  951.  
  952. From: weiser@pogo.den.mmc.com (Matt Weiser)
  953. Subject: I wanna program a Newton - but how?
  954. Date: 23 Jul 92 20:18:09 GMT
  955. Organization: Martin Marietta WIS
  956.  
  957. How does one get in on the ground floor of Newton software
  958. development?  Is there an Apple contact?  Anyone have a phone #
  959. or e-mail address?
  960.  
  961. We have a couple of really great uses for this type of product, 
  962. but we don't want to have to wait for the Newton to
  963. release to be able to begin development.
  964.  
  965.  
  966. Thanks a ton!
  967.  
  968. Matt Weiser
  969. weiser@pogo.den.mmc.com
  970.  
  971. +++++++++++++++++++++++++++
  972.  
  973. From: jpugh@apple.com (Jon Pugh)
  974. Date: 2 Aug 92 17:06:40 GMT
  975. Organization: Apple Computer, Inc.
  976.  
  977. In article <1992Jul23.201809.28064@den.mmc.com>, weiser@pogo.den.mmc.com
  978. (Matt Weiser) wrote:
  979. > How does one get in on the ground floor of Newton software
  980. > development?  Is there an Apple contact?  Anyone have a phone #
  981. > or e-mail address?
  982.  
  983. Email NEWTON.DEVS@Applelink.Apple.Com
  984.  
  985. Good luck.
  986.  
  987. Jon
  988.  
  989. ---------------------------
  990.  
  991. From: russells@ccu1.aukuni.ac.nz (Russell Street)
  992. Subject: Trap word parameter to Set/GetTrapAddress?
  993. Date: 31 Jul 92 06:11:24 GMT
  994. Organization: University of Auckland, New Zealand.
  995.  
  996. I am slightly confused about the Trap Word parameter
  997. to Get/SetTrapAddress:
  998.     What should it be? :-)
  999. For instance do I use "0xA9FD" for _ExitToShell or "0xFD"
  1000. or NGetTrapAddress or what?
  1001.  
  1002. I have always used the straight trap word (0xA9FD) and that
  1003. appears to work, but other people strip of high parts or
  1004. other strange things (or reasonable depends on which way you
  1005. look at it).
  1006.  
  1007. I would really like to get this clear (even in my own mind).
  1008. Information relevant to modern systems only, PLEASE!
  1009.  
  1010. - -------------------------------------------------------
  1011. And with that remark, folks, the case of the Crown vs
  1012. Russell Street (russells@ccu1.aukuni.ac.nz) was proven.
  1013.  
  1014. +++++++++++++++++++++++++++
  1015.  
  1016. From: gurgle@netcom.com (Pete Gontier)
  1017. Date: 1 Aug 92 16:57:49 GMT
  1018. Organization: cellular
  1019.  
  1020. russells@ccu1.aukuni.ac.nz (Russell Street) writes:
  1021.  
  1022. >I am slightly confused about the Trap Word parameter
  1023. >to Get/SetTrapAddress... For instance do I use "0xA9FD"
  1024. >for _ExitToShell or "0xFD" or NGetTrapAddress or what?
  1025.  
  1026. There is some masking necessary. xSetTrapAddress has always
  1027. wanted a trap *number*, not a trap word. It just so happens
  1028. that it does some masking of its own, just in case people
  1029. pass in a trap word, but this masking is not very ... shall
  1030. we say... sophisticated. After all, the caller is supposed
  1031. to pass the right info. :-) Here's the code I use:
  1032.  
  1033. #define kTrapNumberMask            0x07FF
  1034. #define kUnimplementedTrapWord    0xA89F
  1035.  
  1036. static void * AS_GetTrapAddress (short trapWord) {
  1037.     return ((void *) NGetTrapAddress (trapWord & kTrapNumberMask, (trapWord & 0x0800) ? ToolTrap : OSTrap));
  1038. }
  1039.  
  1040. static void AS_SetTrapAddress (void *proc, short trapWord) {
  1041.     NSetTrapAddress ((long) StripAddress(proc), trapWord & kTrapNumberMask, (trapWord & 0x0800) ? ToolTrap : OSTrap);
  1042. }
  1043.  
  1044. Well, this isn't actually the code I use. Whenever I see a new "standard"
  1045. interface in the headers, I try to move toward it. In this case, there
  1046. is now glue for SetToolTrapAddress, or something like that, and the
  1047. code I'm using now takes advantage of that. I just don't happen to have
  1048. a copy of it lying around.
  1049.  
  1050. >I have always used the straight trap word (0xA9FD) and that
  1051. >appears to work, but other people strip of high parts or
  1052. >other strange things (or reasonable depends on which way you
  1053. >look at it).
  1054.  
  1055. It is quite strange, and frankly I've never bothered to look into
  1056. how or why it works. I came up with these magic numbers with the
  1057. help of DTS and MacApp.
  1058.  
  1059. >I would really like to get this clear (even in my own mind).
  1060. >Information relevant to modern systems only, PLEASE!
  1061.  
  1062. Well, that's a good and bad thing to request. You have to be aware
  1063. of which machines your code won't work for. My understanding of the
  1064. code in Inside Mac VI that does things in a similar way is that the
  1065. IM code is able to accomodate really old trap tables on machines that
  1066. no one wants to support any longer. On the other hand, you have to
  1067. be aware of which ones they are. There's a tech note, I believe.
  1068. - -- 
  1069.  Pete Gontier // EC Technology // gurgle@netcom.com
  1070.  
  1071. +++++++++++++++++++++++++++
  1072.  
  1073. From: keith@taligent.com (Keith Rollin)
  1074. Date: 3 Aug 92 02:27:58 GMT
  1075. Organization: Taligent
  1076.  
  1077. In article <0yrmt6=.gurgle@netcom.com>, gurgle@netcom.com (Pete Gontier) writes:
  1078. > russells@ccu1.aukuni.ac.nz (Russell Street) writes:
  1079. > >I am slightly confused about the Trap Word parameter
  1080. > >to Get/SetTrapAddress... For instance do I use "0xA9FD"
  1081. > >for _ExitToShell or "0xFD" or NGetTrapAddress or what?
  1082. > There is some masking necessary. xSetTrapAddress has always
  1083. > wanted a trap *number*, not a trap word. It just so happens
  1084. > that it does some masking of its own, just in case people
  1085. > pass in a trap word, but this masking is not very ... shall
  1086. > we say... sophisticated. After all, the caller is supposed
  1087. > to pass the right info. :-) Here's the code I use:
  1088. > #define kTrapNumberMask            0x07FF
  1089. > #define kUnimplementedTrapWord    0xA89F
  1090. >  
  1091. > static void * AS_GetTrapAddress (short trapWord) {
  1092. >     return ((void *) NGetTrapAddress (trapWord & kTrapNumberMask, (trapWord &
  1093. 0x0800) ? ToolTrap : OSTrap));
  1094. > }
  1095. >  
  1096. > static void AS_SetTrapAddress (void *proc, short trapWord) {
  1097. >     NSetTrapAddress ((long) StripAddress(proc), trapWord & kTrapNumberMask,
  1098. (trapWord & 0x0800) ? ToolTrap : OSTrap);
  1099. > }
  1100. > Well, this isn't actually the code I use. Whenever I see a new "standard"
  1101. > interface in the headers, I try to move toward it.
  1102.  
  1103.  
  1104. I looked into this a couple of weeks ago. If I remember correctly, here's how
  1105. things are laid out:
  1106.  
  1107. In the beginning, there was G/SetTrapAddress. This guy took a trap number. Since
  1108. trap numbers were shared between OS and Toolbox traps, that's all you needed to
  1109. specify.
  1110.  
  1111. Then the 128K ROMs came out, and there weren't enough trap numbers. Or, at
  1112. least, the Apple Engineers realized at that time that they would soon run out of
  1113. trap numbers. So they allowed the duplication of trap numbers between OS and
  1114. Tool traps, and added NG/SetTrapAddress. This function, which was implemented
  1115. with glue, required the programmer to specify whether the trap number was for an
  1116. OS function or Toolbox function. When the old G/SetTrapAddress routine is called
  1117. with an ambiguous trap number, it makes a guess as to whether it's for an OS
  1118. trap or a Toolbox trap.
  1119.  
  1120. Internally, the glue for NG/SetTrapAddress looked at the trapType parameter and
  1121. simply called G/SetTrapAddress with some bits set. For example, a call to the
  1122. old-style SetTrapAddress invokes trap word 0xA047. A call to the newer-style
  1123. NSetTrapAddress with trapType == OSTrap invokes trap word 0xA247, and a call to
  1124. NSetTrapAddress with trapType == ToolTrap invokes trap word 0xA647.
  1125.  
  1126. With the latest MPW and THINK headers, you no longer need the glue.
  1127. G/SetToolTrapAddress and G/SetOSTrapAddress invoke these trap words directly.
  1128. This is the same philosphy used with the new PBxxxSync and PBxxxAsync calls that
  1129. allow you to eschew the Boolean parameter you used to have to pass to those
  1130. routines.
  1131.  
  1132. I believe that there is an undocumented variation of the 0xAx47 trap (perhaps it
  1133. is documented and I just missed it). 0xA447 does just what Pete's routines above
  1134. do. It looks at the full trapword, and then alters the OS trap table or the
  1135. Toolbox trap table accordingly. Take this with a grain of salt, since I haven't
  1136. actually tried this myself.
  1137.  
  1138. - --
  1139. Keith Rollin
  1140. Phantom Programmer
  1141. Taligent, Inc.
  1142.  
  1143. ---------------------------
  1144.  
  1145. End of C.S.M.P. Digest
  1146. **********************
  1147.