home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-073 < prev    next >
Text File  |  2010-09-21  |  35KB  |  887 lines

  1. Received-Date: Sun, 4 Dec 1994 15:53:27 +0100
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-073
  4. To: csmp-digest@ens.fr
  5. Date: Sun, 4 Dec 1994 15:53:28 +0100 (MET)
  6. X-Mailer: ELM [version 2.4 PL23]
  7. Mime-Version: 1.0
  8. Content-Type: text/plain; charset=ISO-8859-1
  9. Content-Transfer-Encoding: 8bit
  10. Errors-To: listman@ens.fr
  11. Reply-To: pottier@clipper.ens.fr
  12. X-Sequence: 79
  13.  
  14. C.S.M.P. Digest             Sun, 04 Dec 94       Volume 3 : Issue 73
  15.  
  16. Today's Topics:
  17.  
  18.         ? THINK Pascal: calling code
  19.         Any science to segmenting?
  20.         Plug-Ins w- CFM
  21.         Saving a PICT to a file - how?
  22.         Sprite Animation Toolkit 2.3a1
  23.         UPP's & calling completion procs
  24.  
  25.  
  26.  
  27. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  28. (pottier@clipper.ens.fr).
  29.  
  30. The digest is a collection of article threads from the internet newsgroup
  31. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  32. regularly and want an archive of the discussions.  If you don't know what a
  33. newsgroup is, you probably don't have access to it.  Ask your systems
  34. administrator(s) for details.  If you don't have access to news, you may
  35. still be able to post messages to the group by using a mail server like
  36. anon.penet.fi (mail help@anon.penet.fi for more information).
  37.  
  38. Each issue of the digest contains one or more sets of articles (called
  39. threads), with each set corresponding to a 'discussion' of a particular
  40. subject.  The articles are not edited; all articles included in this digest
  41. are in their original posted form (as received by our news server at
  42. nef.ens.fr).  Article threads are not added to the digest until the last
  43. article added to the thread is at least two weeks old (this is to ensure that
  44. the thread is dead before adding it to the digest).  Article threads that
  45. consist of only one message are generally not included in the digest.
  46.  
  47. The digest is officially distributed by two means, by email and ftp.
  48.  
  49. If you want to receive the digest by mail, send email to listserv@ens.fr
  50. with no subject and one of the following commands as body:
  51.     help                        Sends you a summary of commands
  52.     subscribe csmp-digest Your Name    Adds you to the mailing list
  53.     signoff csmp-digest            Removes you from the list
  54. Once you have subscribed, you will automatically receive each new
  55. issue as it is created.
  56.  
  57. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  58. Questions related to the ftp site should be directed to
  59. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  60. digest are available there.
  61.  
  62. Also, the digests are available to WAIS users.  To search back issues
  63. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  64. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  65.  
  66.  
  67. -------------------------------------------------------
  68.  
  69. >From ase@cyberspace.org (Ashley A Thomas)
  70. Subject: ? THINK Pascal: calling code
  71. Date: Fri, 18 Nov 1994 16:51:15 +1100
  72. Organization: little to none
  73.  
  74. Could someone tell me where to find a good desription of how to write and
  75. use code you call from inside your program with THINK Pascal in the same
  76. way C programs can by calling a routine by passing a pointer to it.
  77.  
  78. e.g. running code in a resource given its handle (like dnr); or passing a
  79. pointer to a procedure to be called somewhere else.
  80.  
  81. Thanks!
  82. ASE
  83.  
  84. -- 
  85.  
  86. Ashley A Thomas
  87. Email: ase@cyberspace.org
  88.  
  89. +++++++++++++++++++++++++++
  90.  
  91. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  92. Date: 20 Nov 1994 12:59:59 GMT
  93. Organization: (none)
  94.  
  95. ase@cyberspace.org (Ashley A Thomas) writes:
  96.  
  97. >Could someone tell me where to find a good desription of how to write and
  98. >use code you call from inside your program with THINK Pascal in the same
  99. >way C programs can by calling a routine by passing a pointer to it.
  100.  
  101. >e.g. running code in a resource given its handle (like dnr); or passing a
  102. >pointer to a procedure to be called somewhere else.
  103.  
  104. The following inline function is taken from TransSkel.p:
  105.  
  106.     procedure CallpInt (myInt: integer; myProc: ProcPtr);
  107.  
  108. { Two calls use integer as one parameter arguments.  This procedure handles    }
  109. { both of them.                                                                            }
  110.  
  111.     inline
  112.         $205f,     {movea.l  (a7)+,a0        ; (a0) is a ptr to string, 4(a0) is mode}
  113.         $4e90;
  114.  
  115.  
  116. By calling CallpInt, you call the procedure that myProc points to, with myInt
  117. as argument. Unfortunately, there is no type-checking done, so you are
  118. responsible for sending a pointer to a procedure that takes exactly the
  119. arguments you assume.
  120.  
  121. myProc can be created by taking the address of the procedure (e.g.
  122. myProc := @MyProcedure;), or by dereferencing a handle to a code resource
  123. (after locking it!), e.g. something like:
  124.  
  125. myCode := GetResource('CODE', 9999);
  126. if myCode = nil then
  127.     HandleError
  128. else begin
  129.     HLock(myCode);
  130.     myProc := myCode^;
  131. end;
  132.  
  133. You can change the above inline to any other argument list simply by adding
  134. or replacing arguments.
  135.  
  136. Calling procedure pointers should really be built-in into Pascal, just as it
  137. is in Modula2, so we didn't have to do this kind of workarounds. Most of all,
  138. I want type checking on my procedure pointers. Perhaps we could convince
  139. MetroWerks to add it?
  140.  
  141. --
  142. - -
  143. Ingemar Ragnemalm, PhD
  144. Image processing, Mac shareware games
  145. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  146.  
  147. ---------------------------
  148.  
  149. >From ikb_macd@ece.concordia.ca (Keith MacDonald)
  150. Subject: Any science to segmenting?
  151. Date: 8 Nov 1994 04:23:04 GMT
  152. Organization: ECE - Concordia University
  153.  
  154.  
  155. Should I be practising any science in determining which procedures are
  156. grouped into the same segments when I code or is there little/no
  157. overhead in jumping from one segment to another?
  158.  
  159. Cheers,
  160. Keith
  161. ___________________________________________________________________________
  162.  Keith MacDonald                                       Computer Engineering
  163.  ikb_macd@ECE.concordia.ca                             Concordia University
  164.  http://www.ece.concordia.ca/~ikb_macd/addr.html       Montreal, QC, Canada
  165.  
  166. +++++++++++++++++++++++++++
  167.  
  168. >From nick+@pitt.edu ( nick.c )
  169. Date: Tue, 08 Nov 1994 01:05:54 -0500
  170. Organization: The Pitt, Chemistry
  171.  
  172. In article <39muf8$9mu@newsflash.concordia.ca>, ikb_macd@ece.concordia.ca
  173. (Keith MacDonald) wrote:
  174.  
  175. > Should I be practising any science in determining which procedures are
  176. > grouped into the same segments when I code or is there little/no
  177. > overhead in jumping from one segment to another?
  178.  
  179.    My understanding is a segment is swapped into memory as a whole.
  180.      So, (and I'm reasoning here, not speaking with any authority)
  181.      it would make sense to me to group functions that call each
  182.      other together into the same segment.  Try and make each segment
  183.      as "self contained" as possible (realizing that no segment
  184.      could be entirely self contained - or it would be unnecessary
  185.      to 'main').  This would minimize the efficiency loss of swapping
  186.      in segments.  'Course with the modern memory structure of the
  187.      Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  188.  
  189.  
  190.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  191.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  192.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  193.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  194.                     
  195.  
  196. +++++++++++++++++++++++++++
  197.  
  198. >From ramer@nrc.uab.edu (Kevin W. Ramer)
  199. Date: Wed, 09 Nov 1994 09:07:44 -0600
  200. Organization: University of Alabama at Birmingham
  201.  
  202. In article <nick+-0811940105540001@ehdup-f-1.slip.net.pitt.edu>,
  203. nick+@pitt.edu ( nick.c ) wrote:
  204. > > Should I be practising any science in determining which procedures are
  205. > > grouped into the same segments ?
  206.  
  207. >    My understanding is a segment is swapped into memory as a whole.
  208. >      So, (and I'm reasoning here, not speaking with any authority)
  209. >      it would make sense to me to group functions that call each
  210. >      other together into the same segment.  Try and make each segment
  211. >      as "self contained" as possible (realizing that no segment
  212. >      could be entirely self contained - or it would be unnecessary
  213. >      to 'main').  This would minimize the efficiency loss of swapping
  214. >      in segments.  'Course with the modern memory structure of the
  215. >      Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  216.  
  217. A couple of additional points to be made are 1) if you wish to have 
  218. segments  unloaded, do so from the main segment. Typically, calling 
  219. UnloadSeg each time through your event loop.  2) If you don't stick
  220. to 1 be sure to never unload segments earlier in the calling chain !
  221. For example, main calls A which calls B (each in different segments)
  222. _do not_ UnloadSeg(A) while in B.  Makes for nasty crashes.
  223.  
  224. -- 
  225. Kevin W. Ramer                   ramer@nrc.uab.edu
  226. Programmer Analyst
  227. Neurobiology Research Center
  228. University of Alabama at Birmingham
  229.  
  230. +++++++++++++++++++++++++++
  231.  
  232. >From pgontier@novell.com (Pete Gontier)
  233. Date: Wed, 09 Nov 1994 09:42:45 -0800
  234. Organization: Novell, Inc., Walnut Creek/Macintosh Site
  235.  
  236. In article <nick+-0811940105540001@ehdup-f-1.slip.net.pitt.edu>,
  237. nick+@pitt.edu ( nick.c ) wrote:
  238.  
  239. > 'Course with the modern memory structure of the
  240. > Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  241.  
  242. Yes, it does. The Modern Memory Manager just has better (read: faster)
  243. heap management. It doesn't try to tell anyone what to do with individual
  244. heap blocks, which of course are what contain each code segment. You may
  245. be thinking of the Power Mac code model, which has a new paging scheme for
  246. code fragments in the data fork, assuming VM is turned on.
  247.  
  248. I might as well add, now that I have followed up, that a successful
  249. segmentation strategy has to be planned ahead of time. The good news is
  250. that the strategy has a lot in common with good engineering practice
  251. regardless of segmentation, so if you are a good engineering citizen, you
  252. probably *accidentally* planned your segmentation strategy ahead of time
  253. :-). More specifically, if you have narrow entry points into your
  254. functional sub-systems, you can simply put each sub-system into its own
  255. segment and unload it when it's not needed.
  256.  
  257. -- 
  258.  The views expressed here do not necessarily reflect those of my employer.
  259.  
  260. +++++++++++++++++++++++++++
  261.  
  262. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  263. Date: Tue, 8 Nov 1994 18:41:38 GMT
  264. Organization: Semicolon Software
  265.  
  266. In article <39muf8$9mu@newsflash.concordia.ca>, ikb_macd@ece.concordia.ca
  267. (Keith MacDonald) wrote:
  268.  
  269. > Should I be practising any science in determining which procedures are
  270. > grouped into the same segments when I code or is there little/no
  271. > overhead in jumping from one segment to another?
  272.  
  273. Segments exist mainly for memory management purposes: they allow you to
  274. group relevant portions of your code into chunks which do not have to be
  275. kept in memory when they are not in use. For example, your initialization
  276. code runs only once, when the app starts up: put it all into a segment,
  277. and unload it when initialization is complete. You may have printing code
  278. which can be cleanly separated from the rest of your code; there's no need
  279. for it to be in memory when the user isn't printing -- and so on. This
  280. makes more efficient use of your heap and allows your app to run in less
  281. memory.
  282.  
  283. There is a slight performance hit when making calls across segments,
  284. because they must pass through the jump table. Normally it's not worth
  285. worrying about, but I wouldn't call segment B from inside a tight, long,
  286. hopefully-fast loop in segment A. If you segment your code functionally,
  287. this will generally not happen anyway.
  288.  
  289. You should be aware that segments are loaded automagically the first time
  290. any function in them is called, but they are never unloaded unless you do
  291. so specifically in your code. This has a couple of effects. One effect is
  292. that *any* routine can move memory if it is in an unloaded segment when
  293. you call it, because its segment will be loaded into your heap before the
  294. routine can be called. Another effect is that you need to be intelligent
  295. about unloading your segments if you want to reap the memory-management
  296. benefits. A common practice is to keep your main event loop in segment 0
  297. (that is, the one that contains your main routine), and each time through
  298. the event loop, unload every other segment you've got. Unloading a segment
  299. doesn't force it from memory, it just frees it to move in the heap and to
  300. be purged if needed when memory gets low. Commonly used segments will
  301. therefore incur no serious performance penalty from being repeatedly
  302. unloaded unless memory is low; the user can then improve performance by
  303. allocating more memory to the app, if more memory is available.
  304.  
  305. Exceptions to the automagical loading of segments: returns from
  306. subroutines do *not* force loading of segments, and segments cannot be
  307. loaded at interrupt level. Never unload a segment if your call stack
  308. contains pointers into it, or if you are using interrupt-level callbacks
  309. (e.g. from VBL or slot queues, async sound calls, async network calls, and
  310. the like) to routines in the segment. (I got into trouble once by calling
  311. my main event handler from a routine in a different segment; the main
  312. event handler was innocently unloading the segment that called it.
  313. Intermittently [whenever something stirred up the heap just wrong] it
  314. would crash when trying to return to the unloaded segment.)
  315.  
  316. Segments can be marked "preload" in the resource fork if you want them
  317. loaded at startup; if you never explicitly unload them, then they'll
  318. always be there when you need them.
  319.  
  320. Hope this helps.
  321.  
  322. -- Rick Holzgrafe, a member of the Taligentsia
  323.    Rick_Holzgrafe@taligent.com
  324.    rmh@taligent.com
  325.  
  326. +++++++++++++++++++++++++++
  327.  
  328. >From curreyr@halcyon.halcyon.com (curreyr)
  329. Date: 19 Nov 1994 10:16:54 GMT
  330. Organization: Northwest Nexus Inc.
  331.  
  332. In article <Rick_Holzgrafe-0811941041380001@ricks-cafe.taligent.com>
  333. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) writes:
  334.  
  335. > You should be aware that segments are loaded automagically the first time
  336. > any function in them is called, but they are never unloaded unless you do
  337. > so specifically in your code. This has a couple of effects. One effect is
  338. > that *any* routine can move memory if it is in an unloaded segment when
  339. > you call it, because its segment will be loaded into your heap before the
  340.  
  341. Another "effect" is that it can FAIL to load if there isn't room in the
  342. heap for the segment. This can be bad news to your users. If you ignore
  343. this fact, and the segment fails to load, your code had better handle
  344. this fact. But handling the failure is a pain in the @#$@. How many
  345. apps can you name that handle low memory situations reliably?
  346.  
  347. My suggestion would be to use a modern application framework that hides
  348. the ugly details of segmentation loading/unloading and follow the
  349. advice others have given on segmenting your code. MacApp maintains a
  350. reserve in order to insure that there is always going to be memory
  351. available for that code segments to be loaded and could be used as an
  352. example if you want to "roll your own".
  353.  
  354. -Robert Currey
  355.  
  356. ---------------------------
  357.  
  358. >From mdaw@alias.com (Matt Daw)
  359. Subject: Plug-Ins w- CFM
  360. Date: Wed, 16 Nov 1994 03:50:10 GMT
  361. Organization: Alias Research Inc.
  362.  
  363. Has anybody implemented a way to do plug-ins (ala PhotoShop) with the Code
  364. Fragment Manager? If so, what is the best way of doing this?
  365.  
  366. - ---------------------
  367. | Matt Daw            |
  368. | Alias Research Inc. |
  369. - ---------------------
  370.  
  371. +++++++++++++++++++++++++++
  372.  
  373. >From h+@metrowerks.com (Jon W{tte)
  374. Date: Sat, 19 Nov 1994 15:40:34 +0100
  375. Organization: The Conspiracy
  376.  
  377. In article <mdaw-1511942250100001@192.75.21.44>,
  378. mdaw@alias.com (Matt Daw) wrote:
  379.  
  380. >Has anybody implemented a way to do plug-ins (ala PhotoShop) with the Code
  381. >Fragment Manager? If so, what is the best way of doing this?
  382.  
  383. It's REALLY easy. You just load the fragment from disk, and get 
  384. the value of the symbol you want (like "main") and call it as a 
  385. function pointer. NO PAIN!
  386.  
  387. Unless you're on the 68K, in which case it's #$GUffaw
  388.  
  389. <What was that?>
  390. <The manager for the CFM 68K, tiring of the flames and 
  391. putting them out>
  392. <Oh!>
  393.  
  394. Cheers,
  395.  
  396.                     / h+
  397.  
  398.  
  399. --
  400.   Jon W‰tte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  401.   "Psychotherapist" - "Psycho-The-Rapist"
  402.    Pure coincidence? You decide!
  403.  
  404.  
  405. ---------------------------
  406.  
  407. >From andy@dijkstra.cs.clemson.edu (Andrew Greenshields)
  408. Subject: Saving a PICT to a file - how?
  409. Date: 16 Nov 1994 00:43:29 GMT
  410. Organization: Clemson University
  411.  
  412.  
  413.   I have finally got my text file to convert to a nice infra-red image
  414. which I now have in the format of a PICT.  However, when I try to save
  415. this PICT as a file I am running into trouble.  I am using
  416. GetHandleSize to find out how big the PICT is and then I am using
  417. SFWrite to write the data to a file.  I am using *thePict as the
  418. pointer to the data, where thePict is of type PicHandle.  When I try
  419. and look at this file using Photoshop it tells me there is a problem
  420. reading this file.  What am I doing wrong?
  421.  
  422.   Any help would be greatly appreciated.
  423.  
  424.  
  425. Thanks in advance,
  426.  
  427. Andy
  428.  
  429. -- 
  430.   Andrew J. Greenshields N3IGS    |  Some people can tell what time it is by
  431.   andy@cs.clemson.edu             |  looking at the Sun, but I have never been
  432.   USPA C-24393                    |  able to make out the numbers.
  433. - ---------------------***STANDARD DISCLAIMERS APPLY***------------------------
  434.  
  435. +++++++++++++++++++++++++++
  436.  
  437. >From blm@coho.halcyon.com (Brian L. Matthews)
  438. Date: 16 Nov 1994 18:14:08 GMT
  439. Organization: NWNEXUS, Inc. - Making Internet Easy
  440.  
  441. In article <3abkjh$5jm@hubcap.clemson.edu>,
  442. Andrew Greenshields <andy@dijkstra.cs.clemson.edu> wrote:
  443. | I am using GetHandleSize to find out how big the PICT is and then I
  444. |am using SFWrite to write the data to a file.
  445.  
  446. A PICT file starts with a 512-byte header before the actual PICT data.
  447. This header is for use by applications, and as far as I know, there aren't
  448. any standards for what goes in there, except one.  If it's all zeroes,
  449. you're fine.  So, before calling FSWrite to put the picture data in the
  450. file, do a:
  451.  
  452.     err = SetFPos (fRefNum, 1, 512);
  453.  
  454. If you've just created the file, this will effectively put 512 0s at
  455. the start of the file.  Note that if you're writing to an existing file,
  456. you may actually have to do an FSWrite of 512 0s to ensure they're there.
  457.  
  458. Brian
  459. --
  460. Brian L. Matthews                    blm@halcyon.com
  461.   "Look past the ghost that hides Hell's treasures." -Sky Cries Mary
  462.  
  463. +++++++++++++++++++++++++++
  464.  
  465. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  466. Date: 17 Nov 94 16:59:07 +1300
  467. Organization: University of Waikato, Hamilton, New Zealand
  468.  
  469. In article <3adi5g$qed@news.halcyon.com>, blm@coho.halcyon.com (Brian L. Matthews) writes:
  470. >
  471. > A PICT file starts with a 512-byte header before the actual PICT data.
  472. > This header is for use by applications, and as far as I know, there aren't
  473. > any standards for what goes in there, except one.  If it's all zeroes,
  474. > you're fine.  So, before calling FSWrite to put the picture data in the
  475. > file, do a:
  476. >
  477. >     err = SetFPos (fRefNum, 1, 512);
  478. >
  479. > If you've just created the file, this will effectively put 512 0s at
  480. > the start of the file.
  481.  
  482. No, it will not. You must explicitly write 512 bytes of zeroes in all cases.
  483.  
  484. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  485. Computer Services Dept                     fax: +64-7-838-4066
  486. University of Waikato            electric mail: ldo@waikato.ac.nz
  487. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  488.  
  489. +++++++++++++++++++++++++++
  490.  
  491. >From blm@chinook.halcyon.com (Brian L. Matthews)
  492. Date: 17 Nov 1994 18:26:54 GMT
  493. Organization: NWNEXUS, Inc. - Making Internet Easy
  494.  
  495. In article <1994Nov17.165907.35371@waikato.ac.nz>,
  496. Lawrence D'Oliveiro, Waikato University <ldo@waikato.ac.nz> wrote:
  497. |>     err = SetFPos (fRefNum, 1, 512);
  498. |> If you've just created the file, this will effectively put 512 0s at
  499. |> the start of the file.
  500. |No, it will not. You must explicitly write 512 bytes of zeroes in all cases.
  501.  
  502. Argh.  Lawrence is, of course, absolutely right.  I always seem to get
  503. Unix and the Mac confused in cases like this.  Anyway, I was actually
  504. wrong twice.  First, SetFPos will fail if you attempt to set the file
  505. position beyond the end of file.  And second, if you use SetEOF before
  506. the SetFPos, it doesn't fill with 0s.  So while I was right about needing
  507. the 512 0s, I screwed up how to get them there. :-)
  508.  
  509. Brian
  510. --
  511. Brian L. Matthews                    blm@halcyon.com
  512.   "Look past the ghost that hides Hell's treasures." -Sky Cries Mary
  513.  
  514. +++++++++++++++++++++++++++
  515.  
  516. >From andy@dijkstra.cs.clemson.edu (Andrew Greenshields)
  517. Date: 18 Nov 1994 01:32:04 GMT
  518. Organization: Clemson University
  519.  
  520. In article <3ag79e$2vj@news.halcyon.com> blm@chinook.halcyon.com (Brian L. Matthews) writes:
  521. >In article <1994Nov17.165907.35371@waikato.ac.nz>,
  522. >Lawrence D'Oliveiro, Waikato University <ldo@waikato.ac.nz> wrote:
  523.  
  524.   Thankyou both, I can now successfully save my PICTs to files!
  525.  
  526. Andy
  527.  
  528.  
  529. -- 
  530.   Andrew J. Greenshields N3IGS    |  Some people can tell what time it is by
  531.   andy@cs.clemson.edu             |  looking at the Sun, but I have never been
  532.   USPA C-24393                    |  able to make out the numbers.
  533. - ---------------------***STANDARD DISCLAIMERS APPLY***------------------------
  534.  
  535. +++++++++++++++++++++++++++
  536.  
  537. >From rollin@newton.apple.com (Keith Rollin)
  538. Date: Sun, 20 Nov 1994 22:56:08 -0800
  539. Organization: Apple ][ -> Mac -> Taligent -> Newton -> Windows?
  540.  
  541. In article <3abkjh$5jm@hubcap.clemson.edu>, andy@dijkstra.cs.clemson.edu
  542. (Andrew Greenshields) wrote:
  543.  
  544. >  I have finally got my text file to convert to a nice infra-red image
  545. >which I now have in the format of a PICT.  However, when I try to save
  546. >this PICT as a file I am running into trouble.  I am using
  547. >GetHandleSize to find out how big the PICT is and then I am using
  548. >SFWrite to write the data to a file.  I am using *thePict as the
  549. >pointer to the data, where thePict is of type PicHandle.  When I try
  550. >and look at this file using Photoshop it tells me there is a problem
  551. >reading this file.  What am I doing wrong?
  552.  
  553. PICT files begin with a 512 byte header (documented in an old Technote and
  554. in NIM:Imaging with QuickDraw). You don't mention that you are providing
  555. for this header, so that might be your problem.
  556.  
  557. The 512 byte header is for application-defined purposes. If you don't need
  558. to use it, you should clear it out (set it to zero) so as not to confuse
  559. another application that may try interpreting it.
  560.  
  561. - --------------------------------------------------------------------------
  562. Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team Newton
  563. "I say, let's write "wacko" on all the rocks and be done with it."
  564.  
  565. ---------------------------
  566.  
  567. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  568. Subject: Sprite Animation Toolkit 2.3a1
  569. Date: 19 Nov 1994 18:12:06 GMT
  570. Organization: (none)
  571.  
  572. Sprite Animation Toolkit 2.3, alpha version 1, is now available by
  573. ftp from ftp.uu.net, in the /tmp directory, as sat23a1.hqx. It will
  574. probably not remain there for more than a week.
  575.  
  576. Sprite Animation Toolkit is a programming library for making sprite-based
  577. animations (e.g. games). It includes a large number of demos, ranging from
  578. trivially simple to a complete game. It has been used for producing over
  579. a dozen released games.
  580.  
  581. This version works with CodeWarrior (Pascal or C, not PPC yet) as well
  582. as the Think compilers. (Not MPW. Sorry.) Several new features have been
  583. added, and a few changes have been made to make it faster, use less
  584. memory and be more foolproof.
  585.  
  586. This is an alpha version. It is not thoroughly tested. All demos work just
  587. fine on all systems I have been able to try them on, but I need help to find
  588. out if there are any serious bugs left.
  589.  
  590. --
  591. - -
  592. Ingemar Ragnemalm, PhD
  593. Image processing, Mac shareware games
  594. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  595.  
  596. ---------------------------
  597.  
  598. >From D_Gladstone@cs.auckland.ac.nz (David Gladstone)
  599. Subject: UPP's & calling completion procs
  600. Date: Thu, 17 Nov 1994 08:55:53 +1200
  601. Organization: University of Auckland, New Zealand.
  602.  
  603.  
  604. Hi.  I have been having some conceptual problems with UPPs.  I am writing
  605. a Catalog Service Access Module driver which needs to call a completion
  606. routine.
  607.  
  608. I have been getting confused about how things work (especially with CFM68K
  609. on the horizon).  I wrote the following initially as a series of questions
  610. and (as is often the case) managed to find plausible answers just by trying
  611. to phrase the questions - so I have stated what I understand instead.  How
  612. accurate is my version of the story below.  It has been a while since I read
  613. develop 17 (16?) "Making the Leap to PowerPC"...
  614.  
  615.  
  616. The way I figure it, there are several situations that could occur at runtime
  617. for my driver:
  618.  
  619. 1. I am 68K code and the completion routine field is a ProcPtr
  620. 2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  621.    code fragment)
  622. 3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  623.    code fragment)
  624. 4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  625.    non CFM68K app)
  626.    
  627.  
  628. Case 1 would occur when we are running on a PPC in emulation or on a 68K
  629. machine and an old piece of software calls me.  Since my code is 68K and
  630. I don't have CFM68K at my disposal the only option I have is to call
  631. the routine as if it were a ProcPtr (which is fine in this case).
  632.  
  633.  
  634. Case 2 would occur when a 68K version of the driver is running in emulation
  635. on a PPC or it is running on a 68K machine with CFM68K installed.
  636.  
  637. It would not be so difficult if CFM68K existed - I could use it to dispatch
  638. all UPP calls and it would determine whether the pointer was a real UPP or
  639. not.  However, without using CFM68K for the 68K version of the driver I 
  640. have to call any value in the completion routine field of the parameter
  641. block as if it were a ProcPtr.  This means that I will be jumping to the
  642. routine descriptor rather than the routine itself.  I presume that
  643. NewRoutineDescriptor() must put 68K code at the beginning of all routine
  644. descriptors to handle this.
  645.  
  646.  
  647.  
  648. Case 3 would occur when a PPC version of the driver is called by a CFM
  649. aware 68K or PPC app.
  650.  
  651. In this case just call CallUniversalProc to dispatch the call.
  652.  
  653.  
  654.  
  655. Case 4 would occur when a PPC version of the driver is called by an old 
  656. non-CFM68K application.
  657.  
  658. This must be handled by the Code Fragment Manager.  If you call
  659. CallUniversalProc with a ProcPtr it figures out that the address in 
  660. memory is not a routine descriptor and therefore should execute it as
  661. 68K code.
  662.  
  663.  
  664.  
  665.  
  666.  
  667. Is it really that simple?
  668.  
  669.  
  670. David Gladstone.
  671.  
  672. _________________________________________________________________________
  673. David Gladstone : Computer Science Department, University of Auckland, NZ
  674. david@cs.auckland.ac.nz : Ph. +64 9 373-7599 x 5336 : Fax: +64 9 373-7453
  675. _________________________________________________________________________
  676.                       "Give blood... Play Hockey." 
  677.  
  678.  
  679. +++++++++++++++++++++++++++
  680.  
  681. >From Jaeger@fquest.com (Brian Stern)
  682. Date: 17 Nov 1994 05:03:19 GMT
  683. Organization: The University of Texas at Austin, Austin, Texas
  684.  
  685. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  686. D_Gladstone@cs.auckland.ac.nz wrote:
  687.  
  688. < Hi.  I have been having some conceptual problems with UPPs.  I am writing
  689. < a Catalog Service Access Module driver which needs to call a completion
  690. < routine.
  691.  
  692.   I presume that
  693. < NewRoutineDescriptor() must put 68K code at the beginning of all routine
  694. < descriptors to handle this.
  695.  
  696. Not Exactly.  If you're on a PowerMac, drop into macsBug and type 'il
  697. CopyBits'.  CopyBits is native.  What you'll see looks something like
  698. this:
  699.  
  700.             000C12AC   TB         E                 | AAFE
  701.             000C12AE   BTST       D3,D0             | 0700
  702.             000C12B0   ORI.B      #$00,D0           | 0000 0000
  703.             000C12B4   ORI.B      #$00,D0           | 0000 0000
  704.             000C12B8   ORI.B      #$BFC0,D3         | 0003 BFC0
  705.             000C12BC   ORI.B      #$04,D1           | 0001 0004
  706.             000C12C0   ORI.B      #$2C10,A3         | 000B 2C10
  707.             000C12C4   ORI.B      #$00,D0           | 0000 0000
  708.             000C12C8   ORI.B      #$00,D0           | 0000 0000
  709.             000C12CC   ORI.B      #$A8EF,D0         | 0000 A8EF
  710.  
  711. What you're looking at is the routine descriptor for Copybits.  Notice
  712. that the first word is AAFE.  That's the mixedmodemagic trap.  So when you
  713. call copybits you're actually jumping to the mixedmodemagic trap.  It
  714. knows the location of the rest of the routine descriptor and gets the
  715. information that it needs to jump to the appropriate code in the
  716. appropriate mode.
  717.  
  718. < Is it really that simple?
  719.  
  720. Pretty much.
  721. If you're 68K then all you know about are procptrs.  If you're PPC then
  722. you MUST use CallUniversalProc.  CallUniversalProc works correctly if the
  723. code it's pointing to is a routine descriptor or is 68K code.
  724.  
  725. < David Gladstone.
  726. < _________________________________________________________________________
  727. < David Gladstone : Computer Science Department, University of Auckland, NZ
  728. < david@cs.auckland.ac.nz : Ph. +64 9 373-7599 x 5336 : Fax: +64 9 373-7453
  729. < _________________________________________________________________________
  730. <                       "Give blood... Play Hockey."
  731.  
  732. -- 
  733. Brian  Stern  :-{)}
  734. Toolbox commando and Menu bard
  735. Jaeger@fquest.com
  736.  
  737. +++++++++++++++++++++++++++
  738.  
  739. >From wdh@fresh.com (Bill Hofmann)
  740. Date: Thu, 17 Nov 1994 17:54:50 GMT
  741. Organization: Fresh Software
  742.  
  743. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  744. D_Gladstone@cs.auckland.ac.nz wrote:
  745. >....
  746. > The way I figure it, there are several situations that could occur at runtime
  747. > for my driver:
  748. > 1. I am 68K code and the completion routine field is a ProcPtr
  749. > 2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  750. >    code fragment)
  751. > 3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  752. >    code fragment)
  753. > 4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  754. >    non CFM68K app)
  755. >....
  756. > Is it really that simple?
  757. Yes, it is.  Look at almost any header.  The proper way to call the
  758. completion proc is to define a set of macros (I bet they're already
  759. defined for CSAMs):
  760. #if ROUTINEDESCRIPTORS
  761. #define CallCSAMCompletionProc(proc, foo, bar)    \
  762.         CallUniversalProc(proc, uppCSAMCompletionProcInfo, (foo), (bar))
  763. #else
  764. #define CallCSAMCompletionProc(proc, foo, bar)     \
  765.         ((proc)((foo), (bar))
  766. #endif
  767. like so, look for more detail in any header.  Just use CallCSAMCompletionProc()
  768. in your code.
  769.  
  770. -Bill
  771.  
  772. -- 
  773. Bill Hofmann                                  wdh@fresh.com
  774. Fresh Software and Instructional Design       voice: +1 510 524 0852
  775. 1640 San Pablo Ave #C, Berkeley CA 94702 USA  fax:   +1 510 524 0853
  776.  
  777. +++++++++++++++++++++++++++
  778.  
  779. >From h+@metrowerks.com (Jon W{tte)
  780. Date: Fri, 18 Nov 1994 09:26:57 +0100
  781. Organization: The Conspiracy
  782.  
  783. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  784. D_Gladstone@cs.auckland.ac.nz (David Gladstone) wrote:
  785.  
  786. >1. I am 68K code and the completion routine field is a ProcPtr
  787. >2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  788. >   code fragment)
  789.  
  790. Here, just blithely jump to the address. Things will work, 
  791. because the 68K code in the UPP includes the _MixedModeMagic 
  792. trap.
  793.  
  794. >3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  795. >   code fragment)
  796. >4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  797. >   non CFM68K app)
  798.  
  799. If the API says this is now a UPP field, then you have to call 
  800. through with CallXXX() which will make sure that everything 
  801. works.
  802.  
  803. However, the way that the 68K CFM works (totally new glue 
  804. libraries; can't use old headers) and PPC emulation works, the 
  805. 68K CFM model will look just like the PPC model, i e do what 
  806. you'd do on the PPC and you will be fine.
  807.  
  808. That there is no architecture for CFM driver (and even less for 
  809. PPC drivers) probably has something to do with it as well. 
  810. Safest bet would be to write it in plain, non-CFM 68K code 
  811. until the new driver architecture rolls around.
  812.  
  813. Cheers,
  814.  
  815.                     / h+
  816.  
  817.  
  818. --
  819.   Jon W‰tte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  820.  
  821. "When I started hacking, we didnπt have ones. We had to make do with zeros."
  822.     ã Overheard by Andrew Craze
  823.  
  824.  
  825. +++++++++++++++++++++++++++
  826.  
  827. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  828. Date: Sat, 19 Nov 1994 01:43:04 +1300 (NZDT)
  829. Organization: (none)
  830.  
  831. Jaeger@fquest.com (Brian Stern) writes:
  832. >   I presume that
  833. > < NewRoutineDescriptor() must put 68K code at the beginning of all routine
  834. > < descriptors to handle this.
  835. > Not Exactly.  If you're on a PowerMac, drop into macsBug and type 'il
  836. > CopyBits'.  CopyBits is native.  What you'll see looks something like
  837. > this:
  838. >             000C12AC   TB         E                 | AAFE
  839. >             000C12AE   BTST       D3,D0             | 0700
  840. >             000C12B0   ORI.B      #$00,D0           | 0000 0000
  841. >             000C12B4   ORI.B      #$00,D0           | 0000 0000
  842. >             000C12B8   ORI.B      #$BFC0,D3         | 0003 BFC0
  843. >             000C12BC   ORI.B      #$04,D1           | 0001 0004
  844. >             000C12C0   ORI.B      #$2C10,A3         | 000B 2C10
  845. >             000C12C4   ORI.B      #$00,D0           | 0000 0000
  846. >             000C12C8   ORI.B      #$00,D0           | 0000 0000
  847. >             000C12CC   ORI.B      #$A8EF,D0         | 0000 A8EF
  848. > What you're looking at is the routine descriptor for Copybits.  Notice
  849. > that the first word is AAFE.  That's the mixedmodemagic trap.  So when you
  850. > call copybits you're actually jumping to the mixedmodemagic trap.  It
  851. > knows the location of the rest of the routine descriptor and gets the
  852. > information that it needs to jump to the appropriate code in the
  853. > appropriate mode.
  854.  
  855. You're running an old version of Macsbug.  My 6100 says:
  856.  
  857.             000B6FAC   _MixedModeMagic                       ; AAFE       | AAFE
  858.             000B6FAE   BTST       D3,D0                                   | 0700
  859.             000B6FB0   ORI.B      #$00,D0                                 | 0000 0000
  860.             000B6FB4   ORI.B      #$00,D0                                 | 0000 0000
  861.             000B6FB8   ORI.B      #$BFC0,D3                               | 0003 BFC0
  862.             000B6FBC   ORI.B      #$04,D1                                 | 0001 0004
  863.             000B6FC0   ORI.B      #$8A60,A2                  ; '`'        | 000A 8A60
  864.             000B6FC4   ORI.B      #$00,D0                                 | 0000 0000
  865.             000B6FC8   ORI.B      #$00,D0                                 | 0000 0000
  866.             000B6FCC   ORI.B      #$A8EF,D0                               | 0000 A8EF
  867.  
  868. -- Bruce
  869.  
  870.  
  871.  
  872.  
  873. ---------------------------
  874.  
  875. End of C.S.M.P. Digest
  876. **********************
  877.  
  878.  
  879.