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

  1. C.S.M.P. Digest             Sun, 09 Aug 92       Volume 1 : Issue 163
  2.  
  3. Today's Topics:
  4.  
  5.     Time Manager
  6.     TAS instruction use
  7.     Can't use Sys7 icon suite commands!
  8.     How Do You Sleep?
  9.     Why can't I Quit?
  10.     CALLM/RTM (was Re: TAS instruction use)
  11.     Divisible Window Updates: Thought Crime?
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  (This means you can't post questions to the
  22. digest.)
  23.  
  24. Each issue of the digest contains one or more sets of articles (called
  25. threads), with each set corresponding to a 'discussion' of a particular
  26. subject.  The articles are not edited; all articles included in this digest
  27. are in their original posted form (as received by our news server at
  28. cs.uoregon.edu).  Article threads are not added to the digest until the last
  29. article added to the thread is at least one month old (this is to ensure that
  30. the thread is dead before adding it to the digest).  Article threads that
  31. consist of only one message are generally not included in the digest.
  32.  
  33. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  34. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  35. file /pub/mac/csmp-digest/README before downloading any files.  The most
  36. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  37. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  38. archive has a mail server; send a message with the text '$MACarch help' (no
  39. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  40.  
  41. The digest is also available via email.  Just send a note saying that you
  42. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  43. automatically receive each new issue as it is created.  Sorry, back issues
  44. are not available through the mailing list.
  45.  
  46. Send administrative mail to mkelly@cs.uoregon.edu.
  47.  
  48.  
  49. -------------------------------------------------------
  50.  
  51. From: minow@apple.com (Martin Minow)
  52. Subject: Time Manager
  53. Date: 9 Jun 92 23:01:13 GMT
  54. Organization: Apple Computer - MacDTS
  55.  
  56. In article <1992Jun2.101638.7127@eua.ericsson.se>, marcus@erix.ericsson.se
  57. (Marcus Arendt) writes:
  58. > Has anyone out there convinced the Time Manager to perform a
  59. > periodic task in C? I've tried follow the instructions in
  60. > IM VI chapter 23 but haven't succeded. Please help!
  61. There's some sample code in the current (March 1992, I think) edition
  62. of MacTutor (written by me) that might help. Also, if you have access
  63. to the sample applications, look in the Fractal Application - there is
  64. some sample Time Manager code hidden there.
  65.  
  66. Some things to watch out for:
  67.  
  68. - -- Your "clock-tick" function will be called as a completion routine. This
  69.    means that it can't move memory or depend on the value of A5. You can
  70.    use the time manager request record's refCon to remember A5 - see the
  71.    example on page 23-13.
  72. - -- The best way to handle a repetitive task would probably be to use the
  73.    Process Manager's WakeUpProcess call (using the application's process
  74.    id that you've stored in a global somewhere) - that should cause your
  75.    process to leave WaitNextEvent. (This presumes System 7, of course).
  76.  
  77. This is all off the top of my head - hope it helps.
  78.  
  79. Martin Minow
  80. minow@apple.com
  81.  
  82. +++++++++++++++++++++++++++
  83.  
  84. From: grobbins@Apple.COM (Grobbins)
  85. Date: 10 Jun 92 05:54:11 GMT
  86. Organization: Apple DTS, sort of
  87.  
  88. In article <26614@goofy.Apple.COM> minow@apple.com (New Guy In DTS) writes:
  89. >In article <1992Jun2.101638.7127@eua.ericsson.se>, marcus@erix.ericsson.se
  90. >(Marcus Arendt) writes:
  91. >> Has anyone out there convinced the Time Manager to perform a
  92. >> periodic task in C? 
  93. >-- The best way to handle a repetitive task would probably be to use the
  94. >   Process Manager's WakeUpProcess call (using the application's process
  95. >   id that you've stored in a global somewhere) - that should cause your
  96. >   process to leave WaitNextEvent. 
  97.  
  98. Right on, Martin.  This is one of my favorite System 7 strategies.  It
  99. ends up looking just like this:
  100.  
  101.   TYPE enhTMTaskRec = RECORD 
  102.               theTMTask: TMTask;
  103.               myA5: LONGINT
  104.             END;
  105.     enhTMTaskPtr = ^enhTMTaskRec;
  106.  
  107.   FUNCTION GetTMInfo: enhTMTaskPtr;
  108.     INLINE $2E89; { put A1 on stack }
  109.   
  110.   PROCEDURE MyTimeTask;
  111.   { this routine is executed when the primed time manager task comes due }
  112.     VAR
  113.       recPtr: enhTMTaskPtr;
  114.       oldA5: LONGINT;
  115.       anOSErr: LONGINT;
  116.     BEGIN
  117.       recPtr := GetTMInfo; { get pointer to record for this task }
  118.       
  119.       oldA5 := SetA5(recPtr^.myA5); { we want globals }
  120.             
  121.       { flag that time is up and wake the app }
  122.       timeTaskFlag := TRUE; 
  123.       anOSErr := WakeUpProcess(myPSN);
  124.       
  125.       { make this task periodic }
  126.       PrimeTime(QElemPtr(recPtr), kTimerPrimer);
  127.       
  128.       { now back to our previously scheduled A5 world }
  129.       oldA5 := SetA5(oldA5); 
  130.     END;
  131.  
  132. (code from ledApp, available from ftp.apple.com in the folder, er, directory
  133. /dts/mac/sc/snippets/devices.hardware)
  134.  
  135. Then you can yield the maximum time in the WaitNextEvent call, either
  136. MAXLONGINT or the appropriate idle time.  Remember that Apple events
  137. and any other events will wake a sleeping app, so feel free to crank
  138. up the sleep value in the WNE call.
  139.  
  140. Grobbins                  grobbins@apple.com
  141.  
  142. Usual disclaimers apply.
  143.  
  144. +++++++++++++++++++++++++++
  145.  
  146. From: marcus@erix.ericsson.se (Marcus Arendt)
  147. Date: 2 Jun 92 10:16:38 GMT
  148. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  149.  
  150. Has anyone out there convinced the Time Manager to perform a
  151. periodic task in C? I've tried follow the instructions in
  152. IM VI chapter 23 but haven't succeded. Please help!
  153.  
  154. /M.A.
  155.  
  156. - ------------------------------------------------------------------
  157. - --                                --
  158. - --    Marcus H Arendt                        --
  159. - --    Computer Science Laboratory                --
  160. - --    Ellemtel Telecom Systems Labs                --
  161. - --    P.O. Box 1505                        --
  162. - --    S-125 25 Stockholm                    --
  163. - --    SWEDEN                            --
  164. - --                                --
  165. - --    Email: marcus@super.eua.ericsson.se            --
  166. - --    Phone: +46-87273150                    --
  167. - --                                --
  168. - ------------------------------------------------------------------
  169.  
  170. +++++++++++++++++++++++++++
  171.  
  172. From: baker4@husc10.harvard.edu (David Baker)
  173. Date: 6 Jul 92 23:33:50 GMT
  174. Organization: Department of Psychology, Harvard University
  175.  
  176.  
  177. Hi--
  178.  
  179. Does anyone else have the problem with the Time Manager (when computing
  180. elapsed times) wherein the InsTime-PrimeTime-RmvTime sequence causes the
  181. tmCount field to be completely wrong when using milliseconds (positive
  182. values), but not microseconds (negative values)?  I'm using 2^31, the maximum
  183. long int value, as my PrimeTime count parameter.  When it's negative, it's
  184. fine, but when it's positiv, it isn't.  For an approximately three-second
  185. delay, I get 87,723,814 milliseconds.
  186.  
  187. Thanks in advance.
  188. David
  189.  
  190. P.S.  Please, if possible, respond to my "work" address below, and not to the
  191. address in the "From" field above (my work machine doesn't have USENet
  192. access).
  193.  
  194. - --
  195. - -------------------------------------------------------------------------------
  196. David P. Baker                Misbrainer:
  197. Work: dpb@huelings.harvard.edu        The onions impressed herein are mine,
  198. Home: baker4@husc.harvard.edu        not throes of my imploder.
  199. Office: William James Hall, 1204    He wouldn't want 'em, anyway.
  200.     (617) 495-3773
  201.     Department of Psychology
  202.     Harvard University
  203. - -------------------------------------------------------------------------------
  204.  
  205. ---------------------------
  206.  
  207. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  208. Subject: TAS instruction use
  209. Organization: University of Illinois at Urbana
  210. Date: Tue, 23 Jun 1992 03:22:08 GMT
  211.  
  212. Inside Mac VI p. 3-6 says that you should not use the TAS instruction
  213. on a Mac SE or Mac II computer because the hardware does not support
  214. it. Why is this? TAS is a 68000 instruction as far as my little M68000
  215. User's Manual is concerned. What is the problem with using TAS on
  216. these machines?
  217.  
  218. pr
  219. - --
  220. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  221. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  222. System manager - Cognitive Science Group, Beckman Institute, UIUC
  223. Internet: resnick@cogsci.uiuc.edu
  224.  
  225. +++++++++++++++++++++++++++
  226.  
  227. From: Mark.R.Valence@dartmouth.edu (Mark R. Valence)
  228. Date: 23 Jun 92 13:32:25 GMT
  229. Organization: Dartmouth College, Hanover, NH
  230.  
  231.  
  232. Pete Resnick writes ---
  233.  
  234. Inside Mac VI p. 3-6 says that you should not use the TAS instruction
  235. on a Mac SE or Mac II computer because the hardware does not support
  236. it. Why is this? TAS is a 68000 instruction as far as my little M68000
  237. User's Manual is concerned. What is the problem with using TAS on
  238. these machines?
  239.  
  240. pr
  241.  
  242. - --- end of quote
  243.  
  244. The support that IM is refering to is the "indivisibility" (atomicity)
  245. of the instruction (term used in the 68K User's Manual).  What does
  246. this mean?  Well, for the standard Mac programmer (and the non-standard
  247. Mac-programmer, too) TAS will work as you probably want it to.  That
  248. is, it will test the high bit of its operand, set the CC register
  249. accordingly, and the set the high bit.
  250.  
  251. However, (and this is a big HOWEVER), if you are writing an operating
  252. system for the 68K, and you want to make SURE that the TAS instruction
  253. is not interrupted (by some task-spawwing interrupt which proceeds to
  254. TAS the same memory location), then you must make sure that your
  255. machine support TAS to its fullest extent.  One good use of the TAS
  256. instruction is to test guard flags to critical sections of an Operating
  257. System.  For an explanation of critical sections, semaphores, and
  258. examples of what could go wrong, see any good Operating Systems book.
  259.  
  260. So, what should you do?  Prepare for hypocracy: Use BSET #7,
  261. <flag-byte> as a substitute for TAS.  It performs the exact same
  262. function, but is not "indivisible" (atomic).
  263.  
  264. Hope that helps,
  265.  
  266. Mark.
  267.  
  268. +++++++++++++++++++++++++++
  269.  
  270. From: hawley@adobe.com (Steve Hawley)
  271. Organization: Adobe Systems Incorporated
  272. Date: Wed, 24 Jun 1992 00:55:09 GMT
  273.  
  274. In article <1992Jun23.133225.10402@dartvax.dartmouth.edu> Mark.R.Valence@dartmouth.edu (Mark R. Valence) writes:
  275. >However, (and this is a big HOWEVER), if you are writing an operating
  276. >system for the 68K, and you want to make SURE that the TAS instruction
  277. >is not interrupted (by some task-spawwing interrupt which proceeds to
  278. >TAS the same memory location), then you must make sure that your
  279. >machine support TAS to its fullest extent.
  280.  
  281. I think Pete wanted to know exactly _why_ TAS is an unsupported on the
  282. listed Mac models.  I'm curious too.  According to my 68K reference, "the
  283. operation is indivisible, using a read-modify-write memory operation."
  284. Does this mean that those Mac models don't support read-modify-write?
  285.  
  286. You suggestion of using BSET #7, <ea> is very clever.  It turns out that
  287. BSET copies the value of bit before being set into the Z bit of the CC
  288. register.
  289.  
  290. I'm still kind of lost as to how either mechanism wouldn't be indivisible?
  291. Are interrupts processed on instruction boundaries or will they cause the
  292. current instruction to be halted and restarted upon return?
  293.  
  294. If they are processed on instruction boundaries, I fail to see how either
  295. instruction could be indivisible...
  296.  
  297. Steve Hawley
  298. hawley@adobe.com
  299. - -- 
  300. "Did you know that a cow was *MURDERED* to make that jacket?"
  301. "Yes.    I didn't think there were any witnesses, so I guess I'll have to kill
  302.  you too." -Jake Johansen
  303.  
  304. +++++++++++++++++++++++++++
  305.  
  306. From: des7f@fulton.seas.Virginia.EDU (David E. Sappington)
  307. Date: 24 Jun 92 08:02:10 GMT
  308. Organization: University of Virginia
  309.  
  310. M68000 16/32-BIT MICROPROCESSOR PROGRAMMER'S REFERENCE MANUAL (4th edition)
  311. p159 says:
  312.  
  313. TAS: "The operation is indivisible (using a read-modify-write memory cycle)
  314. to allow synchronization of several processors.)"
  315.  
  316. resnick@cogsci.cso.uiuc.edu (Pete Resnick) writes:
  317. [ I don't have IM-VI handy so I'll just quote Pete here. ]
  318. > Inside Mac VI p. 3-6 says that you should not use the TAS instruction
  319. > on a Mac SE or Mac II computer because the hardware does not support
  320. > it.
  321.  
  322. I interpret this to mean that the Mac doesn't guarantee atomic operation
  323. of the read-modify-write cycle.  Thus (say) if you do a TAS on some address
  324. in I/O space you can't be sure (based on r-m-w alone) that the I/O hardware
  325. would not have changed the value in "memory" after the read but before the
  326. write. I'm not sure how the Mac deals with the electrical signals generated
  327. by a 680x0 executing a TAS.
  328.  
  329. hawley@adobe.com (Steve Hawley) writes:
  330. >I'm still kind of lost as to how either mechanism wouldn't be indivisible?
  331.  
  332. Even if the read-modify-write cycle was supported (i.e. guaranteed atomic)
  333. the TAS could be interrupted prior to the cycle: imagine a TAS <ea> where
  334. <ea> pointed to a VM page that wasn't resident in physical memory. Of
  335. course if r-m-w was atomic you'd get the desired behavior even if this
  336. interrupt occurred.
  337.  
  338. >Are interrupts processed on instruction boundaries or will they cause the 
  339. >current instruction to be halted and restarted upon return? 
  340.  
  341. Actually it's worse than either case.  With VM an instruction might be
  342. interrupted prior to completion.  Furthermore you can't just "restart"
  343. the instruction once the interrupt is completed; you have to "continue"
  344. it.  A good example would be a MOVEM.L <...>,-(a7) that page faults
  345. midway through execution.  Restarting would require that the initial
  346. a7 be saved somewhere.  Restarting might also cause problems when
  347. reading/writing to I/O space since two operations on an address might
  348. produce a different result than a single operation.  On the 68010
  349. (sorry, I don't have a manual for the higher MC chips handy) the RTE
  350. restores the internal state of the CPU so that an instruction can be
  351. continued.
  352.  
  353. Dave Sappington                     des7f@virginia.edu
  354. Institute for Parallel Computation  des7f@virginia.bitnet
  355. University of Virginia
  356.  
  357. +++++++++++++++++++++++++++
  358.  
  359. From: Quinn <quinn@cs.uwa.edu.au>
  360. Organization: The University of Western Australia
  361. Date: Wed, 24 Jun 1992 08:58:04 GMT
  362.  
  363. In article <BqA40y.Cz9@news.cso.uiuc.edu> Pete Resnick,
  364. resnick@cogsci.uiuc.edu writes:
  365. >Inside Mac VI p. 3-6 says that you should not use the TAS instruction
  366. >on a Mac SE or Mac II computer because the hardware does not support
  367. >it. Why is this?
  368.  
  369. ...and...
  370.  
  371. In article <1992Jun24.005509.23293@adobe.com> Steve Hawley,
  372. hawley@adobe.com writes:
  373. >I think Pete wanted to know exactly _why_ TAS is an unsupported on the
  374. >listed Mac models.  I'm curious too.  According to my 68K reference, "the
  375. >operation is indivisible, using a read-modify-write memory operation."
  376. >Does this mean that those Mac models don't support read-modify-write?
  377.  
  378. Yes.  Of course "Why?" is another question all together.
  379.  
  380. TAS is normally only used on multiprocessor systems.  The
  381. read-modify-write
  382. bus cyclce ensures atomicity between processors.  For a single process
  383. (and correct me if I'm wrong 'cause I'm about to write a program that
  384. relies on it (-: ) BSET will do the job.
  385.  
  386. Quinn "The Eskimo!"   <quinn@cs.uwa.edu.au>  "Real Coke, Diet .sig"
  387. Department of Computer Science, The University of Western Australia
  388.  
  389. +++++++++++++++++++++++++++
  390.  
  391. From: jmunkki@vipunen.hut.fi (Juri Munkki)
  392. Organization: Helsinki University of Technology
  393. Date: Sun, 28 Jun 1992 16:55:19 GMT
  394.  
  395. In article <1992Jun24.005509.23293@adobe.com> hawley@adobe.com (Steve Hawley) writes:
  396. >I think Pete wanted to know exactly _why_ TAS is an unsupported on the
  397. >listed Mac models.  I'm curious too.  According to my 68K reference, "the
  398. >operation is indivisible, using a read-modify-write memory operation."
  399. >Does this mean that those Mac models don't support read-modify-write?
  400.  
  401. As far as I can remember, TAS is not supported because the classic Macintosh
  402. relies on the fact that all Macintosh memory operations only operate on
  403. every second clock cycle, so the remaining cycles can be used for video
  404. access.
  405.  
  406. Of course, TAS is an exception and the result is that it causes the
  407. processor to use the same cycles as the video memory. This causes all
  408. those strange and wonderful popping and sizzling crashes on the old
  409. Macs.
  410.  
  411. - -- 
  412.   Juri Munkki                           Windsurf: fast sailing
  413.  jmunkki@hut.fi                          Macintosh: fast software
  414.  
  415. +++++++++++++++++++++++++++
  416.  
  417. From: ray@netcom.com (Ray Fischer)
  418. Date: 29 Jun 92 23:49:04 GMT
  419. Organization: Netcom - Online Communication Services
  420.  
  421. hawley@adobe.com (Steve Hawley) writes ...
  422. >You suggestion of using BSET #7, <ea> is very clever.  It turns out that
  423. >BSET copies the value of bit before being set into the Z bit of the CC
  424. >register.
  425. >
  426. >I'm still kind of lost as to how either mechanism wouldn't be indivisible?
  427. >Are interrupts processed on instruction boundaries or will they cause the
  428. >current instruction to be halted and restarted upon return?
  429. >
  430. >If they are processed on instruction boundaries, I fail to see how either
  431. >instruction could be indivisible...
  432.  
  433. When there is more than one processor on the same bus.  The TAS is prevents
  434. even another processor from getting at the memory location between the read
  435. and the write.  BSET doesn't provide this guarantee, even though the one
  436. CPU won't interrupt the instruction while between the read and the write.
  437.  
  438. - -- 
  439. Ray Fischer
  440. rfischer@cs.stanford.edu
  441. ray@netcom.com
  442.  
  443. +++++++++++++++++++++++++++
  444.  
  445. From: alexr@apple.com (Alexander M. Rosenberg)
  446. Date: 1 Jul 92 17:43:52 GMT
  447. Organization: Hackers Anonymous
  448.  
  449. In article <1992Jun23.133225.10402@dartvax.dartmouth.edu> Mark R. Valence,
  450. Mark.R.Valence@dartmouth.edu writes:
  451. >Pete Resnick writes ---
  452. >
  453. >Inside Mac VI p. 3-6 says that you should not use the TAS instruction
  454. >on a Mac SE or Mac II computer because the hardware does not support
  455. >it. Why is this? TAS is a 68000 instruction as far as my little M68000
  456. >User's Manual is concerned. What is the problem with using TAS on
  457. >these machines?
  458. >
  459. >--- end of quote
  460.  
  461. The address decoding hardware on the II and SE cannot handle the
  462. Read-Modify-Write cycle that the TAS, CAS, or CAS2 instructions use. (Or so I
  463. was lead to believe.)
  464.  
  465. That hardware generates a bus error when one of these cycles begin. It would
  466. appear that some amount of software is available to emulate the instructions.
  467. (They don't crash the machine under System 7.)
  468.  
  469. >
  470. >The support that IM is refering to is the "indivisibility" (atomicity)
  471. >of the instruction (term used in the 68K User's Manual).  What does
  472. >this mean?  Well, for the standard Mac programmer (and the non-standard
  473. >Mac-programmer, too) TAS will work as you probably want it to.  That
  474. >is, it will test the high bit of its operand, set the CC register
  475. >accordingly, and the set the high bit.
  476. >
  477.  
  478. It will not work necessarily at all. Do not use TAS, CAS, or CAS2 instructions.
  479.  
  480. >However, (and this is a big HOWEVER), if you are writing an operating
  481. >system for the 68K, and you want to make SURE that the TAS instruction
  482. >is not interrupted (by some task-spawwing interrupt which proceeds to
  483. >TAS the same memory location), then you must make sure that your
  484. >machine support TAS to its fullest extent.  One good use of the TAS
  485. >instruction is to test guard flags to critical sections of an Operating
  486. >System.  For an explanation of critical sections, semaphores, and
  487. >examples of what could go wrong, see any good Operating Systems book.
  488. >
  489. >So, what should you do?  Prepare for hypocracy: Use BSET #7,
  490. ><flag-byte> as a substitute for TAS.  It performs the exact same
  491. >function, but is not "indivisible" (atomic).
  492.  
  493. While the RMW cycle is designed to help with this sort of Operating System
  494. support, it isn't used in the Mac OS. RMW instructions - just say no!
  495. - ---------------------------------------------------------------------------
  496. - -  Alexander M. Rosenberg  - INTERNET: alexr@apple.com      - Yoyodyne    -
  497. - -  330 Waverley St., Apt B - UUCP:ucbvax!apple!alexr        - Propulsion  -
  498. - -  Palo Alto, CA 94301     -                                - Systems     -
  499. - -  (415) 329-8463          - Nobody is my employer so       - :-)         -
  500. - -                          - nobody cares what I say.       -             -
  501.  
  502. +++++++++++++++++++++++++++
  503.  
  504. From: ksand@apple.com (Kent Sandvik (Hacker))
  505. Date: 3 Jul 92 02:38:27 GMT
  506. Organization: Apple
  507.  
  508. In article <1992Jun24.080210.25912@murdoch.acc.Virginia.EDU>,
  509. des7f@fulton.seas.Virginia.EDU (David E. Sappington) wrote:
  510. > >Are interrupts processed on instruction boundaries or will they cause the 
  511. > >current instruction to be halted and restarted upon return? 
  512. > Actually it's worse than either case.  With VM an instruction might be
  513. > interrupted prior to completion.  Furthermore you can't just "restart"
  514. > the instruction once the interrupt is completed; you have to "continue"
  515. > it.  A good example would be a MOVEM.L <...>,-(a7) that page faults
  516. > midway through execution.  Restarting would require that the initial
  517. > a7 be saved somewhere.  Restarting might also cause problems when
  518. > reading/writing to I/O space since two operations on an address might
  519. > produce a different result than a single operation.  On the 68010
  520. > (sorry, I don't have a manual for the higher MC chips handy) the RTE
  521. > restores the internal state of the CPU so that an instruction can be
  522. > continued.
  523.  
  524. This is one of the reasons DTS ask developers not to use TAS.
  525.  
  526. Cheers,
  527. Kent/DTS
  528.  
  529. +++++++++++++++++++++++++++
  530.  
  531. From: orpheus@reed.edu (P. Hawthorne)
  532. Date: 3 Jul 92 09:45:01 GMT
  533. Organization: Reed College, Portland, OR
  534.  
  535.  
  536.   Kent Sandvik (ksand@apple.com) implores:
  537. . DTS asks developers not to use TAS.
  538.  
  539.   What about CALLM/RTM on apps meant for 68020/+ machines?
  540.  
  541.   Theus (orpheus@reed.edu)
  542.  
  543. +++++++++++++++++++++++++++
  544.  
  545. From: stu5s11@bcrka280.bnr.ca
  546. Date: 7 Jul 92 19:03:47 GMT
  547. Organization: Bell-Northern Research, Ottawa, Canada
  548.  
  549. >  Kent Sandvik (ksand@apple.com) implores:
  550. >. DTS asks developers not to use TAS.>
  551. >
  552. >  What about CALLM/RTM on apps meant for 68020/+ machines?
  553. >
  554. >  Theus (orpheus@reed.edu)
  555.  
  556. Motorola has eliminated the CALLM/RTM instructions on the
  557. 68030 and 68040 and future processors. The only processor
  558. they were ever used on was the 68020.
  559.  
  560. The reason they were eliminated was that no one used them.
  561. (At least no one who was buying more than $50 million
  562. worth of processors) The secondary reason for eliminating
  563. them was that it simplified the '030 and let them
  564. use the transistors for more useful purposes.
  565.  
  566. Note that the same thing happened with the Breakpoint
  567. instruction and some of the more obscure MMU instructions.
  568.  
  569.  
  570. John Andrusiak
  571.  
  572.  
  573. ---------------------------
  574.  
  575. From: digi@dgp.toronto.edu (Chris DiGiano)
  576. Subject: Can't use Sys7 icon suite commands!
  577. Date: 3 Jul 92 22:19:36 GMT
  578.  
  579. Okay, I've read and reread the updated TN #306, but I still can't even
  580. load an icon family, let alone draw one.  Here's what I'm doing in C:
  581.  
  582. pascal OSErr GetIconSuite(Handle *theIconSuite,short theResID,short selector)=
  583.         {0x303C, 0x0501, 0xABC9};
  584.  
  585. enum IconSelectorValue {
  586.     svAllAvailableData     =    0xffffffff
  587. };
  588.  
  589. void geticon()
  590. {
  591.     Handle h;
  592.     err = GetIconSuite(&h, 101, svAllAvailableData);
  593. }
  594.  
  595.  
  596. The GetIconSuite statement causes a bus error.  Any ideas?
  597.  
  598. - ---
  599. Chris DiGiano  (416) 978-6619, fax: 0458         digi@dgp.utoronto.{ca,bitnet}
  600. Dynamic Graphics Project, Dept. of Computer Sci.          digi@dgp.toronto.edu
  601. University of Toronto, Canada   M5S 1A4         ...!uunet!dgp.toronto.edu!digi
  602.  
  603. +++++++++++++++++++++++++++
  604.  
  605. From: jackl@austin.apple.com (Jack Littleton)
  606. Date: 6 Jul 92 18:14:51 GMT
  607. Organization: Apple Computer, Inc.
  608.  
  609. In article <1992Jul3.181936.19713@jarvis.csri.toronto.edu>, digi@dgp.toronto.edu (Chris DiGiano) writes:
  610. > pascal OSErr GetIconSuite(Handle *theIconSuite,short theResID,short selector)=
  611. >         {0x303C, 0x0501, 0xABC9};
  612. > enum IconSelectorValue {
  613. >     svAllAvailableData     =    0xffffffff
  614. > };
  615. > void geticon()
  616. > {
  617. >     Handle h;
  618. >     err = GetIconSuite(&h, 101, svAllAvailableData);
  619. > }
  620. > The GetIconSuite statement causes a bus error.  Any ideas?
  621.  
  622. >From what I see, you haven't allocated memory for the handle in geticon().  You need
  623. to explicitly allocate memory for the handle by calling the toolbox routine
  624. NewHandle.
  625.  
  626. - --
  627. Jack Littleton
  628. Developer Tools Engineering Group
  629. Apple Computer, Inc.
  630.  
  631. Opinions expressed above are not necessarily those of Apple Computer, Inc.
  632.  
  633. +++++++++++++++++++++++++++
  634.  
  635. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  636. Date: 7 Jul 92 17:40:30 GMT
  637. Organization: MacDTS Misfits
  638.  
  639. In article <1992Jul6.181451.15385@pcnntp.apple.com>, jackl@austin.apple.com (Jack Littleton) writes:
  640. > In article <1992Jul3.181936.19713@jarvis.csri.toronto.edu>, digi@dgp.toronto.edu (Chris DiGiano) writes:
  641. > > pascal OSErr GetIconSuite(Handle *theIconSuite,short theResID,short selector)=
  642. > >         {0x303C, 0x0501, 0xABC9};
  643. > > 
  644. > > enum IconSelectorValue {
  645. > >     svAllAvailableData     =    0xffffffff
  646. > > };
  647. > > 
  648. > > void geticon()
  649. > > {
  650. > >     Handle h;
  651. > >     err = GetIconSuite(&h, 101, svAllAvailableData);
  652. > > }
  653. > > 
  654. > > 
  655. > > The GetIconSuite statement causes a bus error.  Any ideas?
  656. > >From what I see, you haven't allocated memory for the handle in geticon().  You need
  657. > to explicitly allocate memory for the handle by calling the toolbox routine
  658. > NewHandle.
  659.  
  660. Actually, your problem is that the prototypes are wrong; the GetIconSuite call
  661. should be:
  662.  
  663. pascal OSErr GetIconSuite(Handle *theIconSuite,short theResID,long selector)=
  664.         {0x303C, 0x0501, 0xABC9};
  665.  
  666. Note that the selector is now a long; this matches its format as given in
  667. the selector constants (you can see that they're all 32 bits long).  You
  668. should _not_ allocate memory for the handle ahead of time; this is why
  669. you pass the handle by reference; so the system can allocate the handle
  670. and pass it back.
  671.  
  672. Tim Dierks
  673. MacDTS, but I speak for the trees
  674.  
  675. ---------------------------
  676.  
  677. From: ccmlh@buitc.bu.edu (Mark Hayes)
  678. Subject: How Do You Sleep?
  679. Date: 30 Jun 92 16:54:12 GMT
  680. Organization: Boston University, Boston, MA, USA
  681.  
  682. How do I pause a program for a short period of time? THINK C's UNIX
  683. library provides a "sleep()" function, but it only pauses for
  684. multiples of one second, and I'd like something finer than that.
  685. Is there a toolbox function for this? I'd rather avoid something
  686. as embarrassing as "for (x=0; x < 99999; x++)".
  687.  
  688. +++++++++++++++++++++++++++
  689.  
  690. From: Steve Kohlmeyer
  691. Date: 1 Jul 92 00:52:53 GMT
  692. Organization: University of Minnesota
  693.  
  694. In article <89943@bu.edu> ccmlh@buitc.bu.edu (Mark Hayes) writes:
  695. >How do I pause a program for a short period of time? THINK C's UNIX
  696. >library provides a "sleep()" function, but it only pauses for
  697. >multiples of one second, and I'd like something finer than that.
  698. >Is there a toolbox function for this? I'd rather avoid something
  699. >as embarrassing as "for (x=0; x < 99999; x++)".
  700. >
  701.  
  702. You can use the TickCount() function to wait in multiples of 1 tick.
  703. (60 ticks = 1 second)
  704.  
  705. Wait(int ticks) {
  706.  
  707.  long    start;
  708.  
  709.     start = TickCount();
  710.     while (TickCount() < start+ticks) ;
  711. }
  712.  
  713. Steve Kohlmeyer
  714.  
  715. +++++++++++++++++++++++++++
  716.  
  717. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  718. Organization: Royal Institute of Technology, Stockholm, Sweden
  719. Date: Wed, 1 Jul 1992 10:49:09 GMT
  720.  
  721. .cis.umn.edu> Steve Kohlmeyer writes:
  722.  
  723.    You can use the TickCount() function to wait in multiples of 1 tick.
  724.    (60 ticks = 1 second)
  725.  
  726.    Wait(int ticks) {
  727.  
  728.     long    start;
  729.  
  730.        start = TickCount();
  731.        while (TickCount() < start+ticks) ;
  732.    }
  733.  
  734. AUGH ! DON'T ! THIS IS WORSE THAN CALLING _Delay !
  735.  
  736.  
  737. You should AT MINIMUM include a call to SystemTask in
  738. the loop. Better yet, use WaitNextEvent in the loop, like:
  739.  
  740. void
  741. Wait ( long ticks )
  742. {
  743.     long target = TickCount ( ) + ticks ;
  744.     EventRecord er ;
  745.  
  746.     while ( ( ticks = TickCount ( ) ) < target ) {
  747.  
  748.         WaitNextEvent ( 0 , & er , target - ticks , NULL ) ;
  749.     }
  750. }
  751.  
  752. Maybe you should check for suspend/resume/activate/update/apple
  753. events in the loop, too, by calling your global event handler
  754. routine...
  755.  
  756. - -- 
  757.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  758.  
  759.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  760.                - Andrew Kass in comp.sys.mac.hardware
  761.  
  762. +++++++++++++++++++++++++++
  763.  
  764. From: obi@gumby.ocs.com (Kuryan "Obi" Thomas)
  765. Date: 1 Jul 92 16:40:47 GMT
  766. Organization: Online Computer Systems, Inc.
  767.  
  768. In article <89943@bu.edu> ccmlh@buitc.bu.edu (Mark Hayes) writes:
  769. >How do I pause a program for a short period of time? THINK C's UNIX
  770. >library provides a "sleep()" function, but it only pauses for
  771. >multiples of one second, and I'd like something finer than that.
  772. >Is there a toolbox function for this? I'd rather avoid something
  773. >as embarrassing as "for (x=0; x < 99999; x++)".
  774. >
  775.  
  776. See Delay(), Inside Macintosh Vol II, p 384.
  777.  
  778. procedure Delay(numTicks: longint; var finalTicks: longint);
  779.  
  780. or
  781.  
  782. void Delay(long, long*);
  783.  
  784. The first arg says how long you want to sleep (in ticks; 1 tick = 1/60 sec).
  785. The second arg gives the global tick count at the time of "wakeup."
  786.  
  787. Hope this helps.
  788.  
  789. +++++++++++++++++++++++++++
  790.  
  791. From: obi@gumby.ocs.com (Kuryan "Obi" Thomas)
  792. Date: 2 Jul 92 20:00:34 GMT
  793. Organization: Online Computer Systems, Inc.
  794.  
  795. In article <D88-JWA.92Jul1114909@dront.nada.kth.se>, Jon W{tte writes:
  796. > .cis.umn.edu> Steve Kohlmeyer writes:
  797. >
  798.     [ A code fragment; deleted. ]
  799. > AUGH ! DON'T ! THIS IS WORSE THAN CALLING _Delay !
  800. > You should AT MINIMUM include a call to SystemTask in
  801. > the loop. Better yet, use WaitNextEvent in the loop, like:
  802.     [ A code fragment; deleted. ]
  803. > Maybe you should check for suspend/resume/activate/update/apple
  804. > events in the loop, too, by calling your global event handler
  805. > routine...
  806.  
  807. I agree that this is closer to what the UNIX sleep() system call does: it
  808. allows other processes a chance to run. However, this isn't necessarily what
  809. is required. For example, consider the only use I've made of Delay(): if the
  810. user presses Return or Enter in a window with a default button, I highlight
  811. the button for an instant (as if it had been clicked with the mouse) and then
  812. do what the button is supposed to do.
  813.  
  814. I implement "highlighting for an instant" by highlighting, calling Delay() for
  815. 5 or so ticks, and then unhighlighting. In this scenario, you would not want
  816. to read the event loop -- you may get switched out, or worse, pick up a mouse
  817. click on the button itself.
  818.  
  819. I would think that calling Delay() is fine in most situations except when you
  820. are, as they say in UNIX, "sleeping on an event," i.e., napping until some
  821. alarm goes off (printer is ready; disk i/o completed; whatever). In that case,
  822. you would definitely want to allow yourself to be switched out and yield the
  823. CPU to another process which can get some work done in the meantime.
  824.  
  825. +++++++++++++++++++++++++++
  826.  
  827. From: jmunkki@vipunen.hut.fi (Juri Munkki)
  828. Organization: Helsinki University of Technology
  829. Date: Fri, 3 Jul 1992 20:04:40 GMT
  830.  
  831. In article <Bqs28z.K2y@gumby.ocs.com> obi@gumby.ocs.com writes:
  832. >In article <D88-JWA.92Jul1114909@dront.nada.kth.se>, Jon W{tte writes:
  833. >> You should AT MINIMUM include a call to SystemTask in
  834. >> the loop. Better yet, use WaitNextEvent in the loop, like:
  835.  
  836. >I implement "highlighting for an instant" by highlighting, calling Delay() for
  837. >5 or so ticks, and then unhighlighting. In this scenario, you would not want
  838. >to read the event loop -- you may get switched out, or worse, pick up a mouse
  839. >click on the button itself.
  840.  
  841. No, but you should give time to background processes, so WaitNextEvent
  842. might be a good idea. Just pass a 0 mask that tells the system that you
  843. don't actually want any events. Another possibility is to use GetNextEvent
  844. and SystemTask inside a loop.
  845.  
  846. The idea of multitasking is to enable the user to get the maximum amount
  847. of efficiency from a processor. Sitting in a call to _Delay is not my idea
  848. of making good use of the processor.
  849.  
  850. - -- 
  851.   Juri Munkki                           Windsurf: fast sailing
  852.  jmunkki@hut.fi                          Macintosh: fast software
  853.  
  854. +++++++++++++++++++++++++++
  855.  
  856. From: Eric.J.Baumgartner@dartmouth.edu (Eric J. Baumgartner)
  857. Date: 6 Jul 92 18:35:20 GMT
  858. Organization: Dartmouth College, Hanover, NH
  859.  
  860. In article <Bqs28z.K2y@gumby.ocs.com>
  861. obi@gumby.ocs.com (Kuryan "Obi" Thomas) writes:
  862.  
  863. > For example, consider the only use I've made of Delay(): if the
  864. > user presses Return or Enter in a window with a default button, I highlight
  865. > the button for an instant (as if it had been clicked with the mouse) and
  866. > then do what the button is supposed to do.
  867.  
  868. Another way to do this is to convert the event from a keystroke into a
  869. mousedown on your button, and pass the event back to the system so that
  870. it highlights the button. This is pretty simple to do for dialogs via
  871. the filter; I would assume (ha ha) it would be fairly simple for
  872. standard windows as well.
  873.  
  874. Eric Baumgartner                   *  ebaum@dartmouth.edu
  875. Interactive Media Lab              *  - When in danger or in doubt,
  876. Dartmouth Medical School           *      run in circles, scream and
  877. shout.
  878.  
  879. ---------------------------
  880.  
  881. From: djpegg@utkvx4.utk.edu (PEGG, DAVID J)
  882. Subject: Why can't I Quit?
  883. Date: 6 Jul 92 18:21:00 GMT
  884. Organization: University of Tennessee Computing Center
  885.  
  886. I'm writing my first program for the Mac that actually uses a Mac interface
  887. instead of relying on stdio stuff.  My menu bar consists of the apple, file,
  888. and edit menus, plus three menus for manipulating data in the program (it's a
  889. simple graphing porgram with four windows, each containg a separate graph).
  890.  
  891. My problem is that it won't quit.  The file menu has Quit as option #8 with the
  892. command-Q key equivalent.  But choosing this (whether with the mouse or the
  893. keys) gives me errors.  I'm using Think C 5.0.2 with Think C Debugger 5.0. 
  894. Everything works fine, until I choose Quit.  If I'm running the Debugger, I
  895. usually get an "illegal instruction" error, although I sometimes get an "odd
  896. address" error instead.  If I'm not running the Debugger, one of three things
  897. happens.  Either it quits just fine (rare, and never twice in a row), the
  898. screen freezes, permitting no mouse movement, or I get a system error: "bad
  899. F-line instruction." (This is the most common one I see.)  What does this mean?
  900.  
  901. I'm just using a regular event loop:
  902.     done = FALSE;
  903.     while (!done)
  904.     {
  905.         WaitNextEvent(...);
  906.         HandleEvent(event);
  907.     }
  908.  
  909. The variable done is a global that is set TRUE when Quit is chosen.  I can't
  910. figure it out; I'm at your mercy!
  911.  
  912. Thanks in advance,
  913.     Michael Lewis
  914.  
  915. +++++++++++++++++++++++++++
  916.  
  917. From: howard@netcom.com (Howard Berkey)
  918. Date: 6 Jul 92 19:05:34 GMT
  919. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  920.  
  921.  
  922. >
  923. >The variable done is a global that is set TRUE when Quit is chosen.  I can't
  924. >figure it out; I'm at your mercy!
  925.  
  926. OK, first of all, what is after your event loop in main()?  The way you have it
  927. all it will do is exit the event loop but still execute commands after the
  928. loop.  A better way to quit is to use ExitToShell() in this case as your app
  929. is guaranteed to be in the foreground when the user selects Quit or hits
  930. command-Q in your application.  Something like this in your file menu handler:
  931.  
  932.                 
  933.         ...
  934.         case quitCommand:    
  935.             DoHouseCleaning();    /* everything after your event
  936.                            loop as it is now...   */
  937.             ExitToShell();
  938.         break;
  939.         ...  
  940.  
  941.     On this note, could someone tell me if anything is wrong with using 
  942. ExitToShell() in the background?  I've never done it, but I know that when
  943. you use 'es' in Macsbug  you want to check the app name at $910 (?) to make
  944. sure you're escaping from the right app...  Since ExitToShell() basically
  945. just calls _Launch w/ finder as the app, I don't see any problem using it
  946. in the background.
  947.  
  948. - -Howard 
  949.  
  950.  
  951. - -- 
  952. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  953. Howard Berkey                        howard@netcom.com
  954. If while you are in school, there is a shortage of qualified personnel
  955. in a particular field, then by the time you graduate with the necessary
  956. qualifications, that field's employment market is glutted.
  957.         -- Marguerite Emmons
  958.  
  959. +++++++++++++++++++++++++++
  960.  
  961. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  962. Organization: Royal Institute of Technology, Stockholm, Sweden
  963. Date: Mon, 6 Jul 1992 22:48:19 GMT
  964.  
  965. > howard@netcom.com (Howard Berkey) writes:
  966.  
  967.        On this note, could someone tell me if anything is wrong with using 
  968.    ExitToShell() in the background?  I've never done it, but I know that when
  969.  
  970. I don't think that's any problem. I certainly do it.
  971.  
  972.    you use 'es' in Macsbug  you want to check the app name at $910 (?) to make
  973.    sure you're escaping from the right app...  Since ExitToShell() basically
  974.  
  975. Yes, but that means you exittoshell whatever application is currently
  976. SWITCHED IN (!= foreground) - when your application executes code
  977. that isn't an interrupt handler, it is by definition switched in.
  978.  
  979. - -- 
  980.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  981.  
  982.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  983.                - Andrew Kass in comp.sys.mac.hardware
  984.  
  985. ---------------------------
  986.  
  987. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  988. Subject: CALLM/RTM (was Re: TAS instruction use)
  989. Date: 4 Jul 92 04:00:41 GMT
  990. Organization: University of Waikato, Hamilton, New Zealand
  991.  
  992. In article <1992Jul3.094501.12376@reed.edu>, orpheus@reed.edu (P. Hawthorne) writes:
  993.  
  994. >   What about CALLM/RTM on apps meant for 68020/+ machines?
  995.  
  996. Those instructions are ONLY available on the 68020 -- not on the 68030/040.
  997. I think nobody could figure out what to use them for. :-)
  998.  
  999. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1000. Computer Services Dept                     fax: +64-7-838-4066
  1001. University of Waikato            electric mail: ldo@waikato.ac.nz
  1002. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1003.  
  1004. +++++++++++++++++++++++++++
  1005.  
  1006. From: jimc@tau-ceti.isc-br.com (Jim Cathey)
  1007. Date: 7 Jul 92 20:04:31 GMT
  1008. Organization: ISC - Bunker Ramo, Spokane, WA
  1009.  
  1010. In article <1992Jul4.160041.9151@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
  1011. >>   What about CALLM/RTM on apps meant for 68020/+ machines?
  1012. >
  1013. >Those instructions are ONLY available on the 68020 -- not on the 68030/040.
  1014. >I think nobody could figure out what to use them for. :-)
  1015.  
  1016. If I remember correctly, to actually do anything they required that the
  1017. system designer also supply a custom MMU coprocessor.  Nobody did this,
  1018. so they took it back out.  Maybe the feature was Ada-inspired or something.
  1019.  
  1020. - -- 
  1021. +----------------+
  1022. ! II      CCCCCC !  Jim Cathey
  1023. ! II  SSSSCC     !  ISC-Bunker Ramo
  1024. ! II      CC     !  TAF-C8;  Spokane, WA  99220
  1025. ! IISSSS  CC     !  UUCP: uunet!isc-br!jimc (jimc@isc-br.isc-br.com)
  1026. ! II      CCCCCC !  (509) 927-5757
  1027. +----------------+
  1028.             "PC's --- the junk bonds of the computer industry"
  1029.  
  1030. ---------------------------
  1031.  
  1032. From: orpheus@reed.edu (P. Hawthorne)
  1033. Subject: Divisible Window Updates: Thought Crime?
  1034. Date: 5 Jul 92 23:41:39 GMT
  1035. Organization: Reed College, Portland OR
  1036.  
  1037. The toolbox routines for window updates assume that the entire update can
  1038. be performed at once, before going on to the next event. This is fine for
  1039. simple graphics, but some updates can take a long time. Users may decide
  1040. that they want to proceed without waiting for the update to finish.
  1041.  
  1042. In a perfect world, updates would be seamless. That is to say that users
  1043. could make menu selections or switch to another application while a window
  1044. was updating, as if updating windows was something the application did in
  1045. its spare time just for the exercise. PhotoShop and StrataVision, two
  1046. MacApps as elegant as they are glacial, accomplish this ideal.
  1047.  
  1048. The toolbox routines for updates have to be avoided for this to work. What
  1049. I want to know is: Assuming that the regions in question are dealt with
  1050. properly, is there any overwhelming reason for BeginUpdate and EndUpdate to
  1051. be called in response to window update events?
  1052.  
  1053. Theus (orpheus@reed.edu)
  1054.  
  1055. +++++++++++++++++++++++++++
  1056.  
  1057. From: joseph@joebloe.maple-shade.nj.us (Joseph Nathan Hall)
  1058. Date: 5 Jul 92 03:01:29 GMT
  1059. Organization: 5 Sigma Software
  1060.  
  1061.  
  1062. In article <1992Jul5.234139.4921@reed.edu> (comp.sys.mac.programmer), orpheus@reed.edu (P. Hawthorne) writes:
  1063. ) The toolbox routines for window updates assume that the entire update can
  1064. ) be performed at once, before going on to the next event....
  1065.  
  1066.                 ...What
  1067. ) I want to know is: Assuming that the regions in question are dealt with
  1068. ) properly, is there any overwhelming reason for BeginUpdate and EndUpdate to
  1069. ) be called in response to window update events?
  1070.  
  1071. Aside from the necessity of stopping the incessant flow of update 
  1072. events ... no.
  1073.  
  1074. You WILL have to process update events, which means you will have
  1075. to call BeginUpdate/EndUpdate.  Even if you don't do anything between.
  1076.  
  1077. I have an app that updates a window as an idle chore ... you can too.
  1078. It still processes ordinary updates (from uncovering, etc.), but I don't 
  1079. use the InvalRect-type mechanism to show ongoing changes.
  1080.  
  1081. Although I hate to praise Microsoft for anything, particularly Word,
  1082. particularly for the Mac, I have to admit that I am quite fond of the way 
  1083. that Word redraws during scrolling ... leaving as little blank screen
  1084. as possible.  (I also like the way that it lets me open 3.5 MB documents
  1085. without so much as a burp.)
  1086.  
  1087. uunet!joebloe!joseph   (609) 273-8200 day   joseph%joebloe@uunet.uu.net
  1088. v   v  sssss | Certified Guru: all-grain brewing,| 2102 Ryan's Run East
  1089.  v v  s   s  | C, synthesizer comp & arranging,  | Rt 38 & 41
  1090.   v    sss   | photography. Also not a bad cook. | Maple Shade NJ 08052
  1091. - -----My employer isn't paying for this, and my opinions are my own-----
  1092.  
  1093. +++++++++++++++++++++++++++
  1094.  
  1095. From: tmaehl@vax1.umkc.edu
  1096. Date: 6 Jul 92 08:56:08 GMT
  1097. Organization: University of Missouri - Kansas City
  1098.  
  1099. In article <1992Jul5.234139.4921@reed.edu>, 
  1100. orpheus@reed.edu (P. Hawthorne) writes:
  1101. > The toolbox routines for window updates assume that the entire update can
  1102. > be performed at once, before going on to the next event. This is fine for
  1103. > simple graphics, but some updates can take a long time. Users may decide
  1104. > that they want to proceed without waiting for the update to finish.
  1105.  
  1106. Updates should be thought of as "refresh" requests. If your app does
  1107. all of its drawing offscreen in a gworld, when you get an update event
  1108. you just copy the original back to the screen. This takes virtually no
  1109. time and is easily accomplished before going onto the next event.
  1110.  
  1111. *Drawing* should be nicely intertwined with reasonable calls to GNE.
  1112. But an update event doesn't require you to *draw*, just *refresh*.
  1113.  
  1114. Jonathan/tmaehl@vax1.umkc.edu
  1115.  
  1116. +++++++++++++++++++++++++++
  1117.  
  1118. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1119. Date: 6 Jul 92 11:46:15 GMT
  1120. Organization: Kalamazoo College
  1121.  
  1122. tmaehl@vax1.umkc.edu writes:
  1123. >orpheus@reed.edu (P. Hawthorne) writes:
  1124. >> some updates can take a long time. Users may decide
  1125. >> that they want to proceed without waiting for the update to finish.
  1126. >
  1127. >If your app does
  1128. >all of its drawing offscreen in a gworld, when you get an update event
  1129. >you just copy the original back to the screen. This takes virtually no
  1130. >time and is easily accomplished before going onto the next event.
  1131.  
  1132. Even that can take quite some time.  For example, your offscreen
  1133. pixel map is 24 bits deep and you want to copy it onto an 8-bit screen,
  1134. dithered, with different source and destination rectangles.  Or your
  1135. offscreen image is too big to (comfortably) fit in memory, and you have
  1136. it partly stored on disk.  Or VM is on, which amounts to the same thing.
  1137. Etc., etc.
  1138. - -- 
  1139.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1140.  Nobody reads signatures anyway.
  1141.  
  1142. +++++++++++++++++++++++++++
  1143.  
  1144. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  1145. Date: 6 Jul 92 13:06:39 GMT
  1146. Organization: Royal Institute of Technology, Stockholm, Sweden
  1147.  
  1148. .edu> orpheus@reed.edu (P. Hawthorne) writes:
  1149.  
  1150.    I want to know is: Assuming that the regions in question are dealt with
  1151.    properly, is there any overwhelming reason for BeginUpdate and EndUpdate to
  1152.    be called in response to window update events?
  1153.  
  1154. Yes.
  1155.  
  1156. People patch EndUpdate for some hacks... not to mention Apple
  1157. probably has some strange fixes in there, too.
  1158.  
  1159. Instead, do BeginUpdate - remmeber clip region - EndUpdate
  1160. and then start drawing in the remembered region while calling
  1161. WaitNextEvent.
  1162.  
  1163. Or just store all drawing in an offscreen GWorld, and CopyBits
  1164. to screen when you get a refresh event. Takes memory for a
  1165. 24 bit 21" screen, though.
  1166.  
  1167. - -- 
  1168.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  1169.  
  1170.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  1171.                - Andrew Kass in comp.sys.mac.hardware
  1172.  
  1173. +++++++++++++++++++++++++++
  1174.  
  1175. From: jimc@tau-ceti.isc-br.com (Jim Cathey)
  1176. Date: 7 Jul 92 20:34:24 GMT
  1177. Organization: ISC - Bunker Ramo, Spokane, WA
  1178.  
  1179. In article <1992Jul5.234139.4921@reed.edu> orpheus@reed.edu (P. Hawthorne) writes:
  1180. >The toolbox routines for window updates assume that the entire update can
  1181. >be performed at once, before going on to the next event. This is fine for
  1182. >simple graphics, but some updates can take a long time. Users may decide
  1183. >that they want to proceed without waiting for the update to finish.
  1184.  
  1185. I had a problem with this in a program I did that was an emulation of a
  1186. foreign windowing system (call it X, but it wasn't) using as much of the
  1187. native Mac toolbox as possible.  The problem is that multiple updates
  1188. could be going on in parallel, since separate Un*x applications on
  1189. remote systems were driving each of the windows, through a translation
  1190. program.  Scheduling variations and variable network delays conspire to
  1191. ensure that there is no way in hell my translation program could
  1192. complete (or even start) an update when it got an update event from the
  1193. Toolbox.  So, my solution was to immediately grab the update region of
  1194. the dirty window (to save it, and to send its bounding rectangle away to
  1195. the remote client), then do a BeginUpdate/EndUpdate to clear out the
  1196. dirty status.  When the update starts to come in I then do an InvalRgn
  1197. to re-dirtify the dirty area, then a BeginUpdate, then I grab a copy of
  1198. the SaveVisRgn low-memory global (per the note in IM-1).  When the
  1199. remote update is finally done (which may take awhile) I restore the
  1200. SaveVisRgn from my copy (since who knows how many other updates to
  1201. other windows may have been done by then, and <Begin|End>Update don't
  1202. normally nest), and then do an EndUpdate, followed by a final CalcVis
  1203. since the saved SaveVisRgn may have been completely invalid by the
  1204. time all this was done.  Messy (and probably non-optimal), but it works.
  1205. I think (in retrospect) that the business with SaveVisRgn was completely
  1206. unnecessary, since the CalcVis call cleans up all the mess.  However,
  1207. it _was_ a late fix to the code.
  1208.  
  1209. >The toolbox routines for updates have to be avoided for this to work. What
  1210. >I want to know is: Assuming that the regions in question are dealt with
  1211. >properly, is there any overwhelming reason for BeginUpdate and EndUpdate to
  1212. >be called in response to window update events?
  1213.  
  1214. You don't have to avoid them (in fact you really can't avoid them and
  1215. stay 'clean'), but you do have to slaughter a chicken or two in their
  1216. name. 
  1217.  
  1218. - -- 
  1219. +----------------+
  1220. ! II      CCCCCC !  Jim Cathey
  1221. ! II  SSSSCC     !  ISC-Bunker Ramo
  1222. ! II      CC     !  TAF-C8;  Spokane, WA  99220
  1223. ! IISSSS  CC     !  UUCP: uunet!isc-br!jimc (jimc@isc-br.isc-br.com)
  1224. ! II      CCCCCC !  (509) 927-5757
  1225. +----------------+
  1226.             "PC's --- the junk bonds of the computer industry"
  1227.  
  1228. +++++++++++++++++++++++++++
  1229.  
  1230. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1231. Date: 8 Jul 92 18:18:01 +1200
  1232. Organization: University of Waikato, Hamilton, New Zealand
  1233.  
  1234. In article <2370@tau-ceti.isc-br.com>, jimc@tau-ceti.isc-br.com (Jim Cathey) writes:
  1235. > In article <1992Jul5.234139.4921@reed.edu> orpheus@reed.edu (P. Hawthorne) writes:
  1236. >>The toolbox routines for window updates assume that the entire update can
  1237. >>be performed at once, before going on to the next event. This is fine for
  1238. >>simple graphics, but some updates can take a long time. Users may decide
  1239. >>that they want to proceed without waiting for the update to finish.
  1240. >
  1241. > I had a problem with this in a program I did that was an emulation of a
  1242. > foreign windowing system ... [with] multiple updates
  1243. > could be going on in parallel, ...
  1244. > [and] no way in hell my translation program could
  1245. > complete (or even start) an update when it got an update event from the
  1246. > Toolbox.  So, my solution was to immediately grab the update region of
  1247. > the dirty window (to save it, and to send its bounding rectangle away to
  1248. > the remote client), then do a BeginUpdate/EndUpdate to clear out the
  1249. > dirty status.
  1250.  
  1251. Yup, this sounds like mostly the right way to me, so far.
  1252.  
  1253. > When the update starts to come in I then do an InvalRgn
  1254. > to re-dirtify the dirty area, then a BeginUpdate, then I grab a copy of
  1255. > the SaveVisRgn low-memory global (per the note in IM-1).  When the
  1256. > remote update is finally done (which may take awhile) I restore the
  1257. > SaveVisRgn from my copy (since who knows how many other updates to
  1258. > other windows may have been done by then, and <Begin|End>Update don't
  1259. > normally nest), and then do an EndUpdate, followed by a final CalcVis
  1260. > since the saved SaveVisRgn may have been completely invalid by the
  1261. > time all this was done.
  1262. ...
  1263. > However, it _was_ a late fix to the code.
  1264.  
  1265. As an alternative technique, why not leave the visRgn alone, and just set the
  1266. clip region to the area needing updating? I guess the answer is you're using
  1267. the grafport clip region to directly implement an application-settable clip
  1268. region. So why not maintain a separate "application clip region", so the clip
  1269. region of the grafport becomes the intersection of this and the region
  1270. currently being updated?
  1271.  
  1272. Just a way of avoiding fiddling with visRgns and faking out the Toolbox,
  1273. that's all.
  1274.  
  1275. To allow for multiple concurrent window updates while still being responsive
  1276. to mouse and key events, how about this:
  1277.  
  1278. For each window, in addition to the standard Toolbox structures, you maintain
  1279. two additional regions: an application-level clip region (representing the
  1280. area that the application really wants to draw into) and a region needing
  1281. updating. Every time you get a Toolbox update event for such a window, you
  1282. simply do a UnionRgn of the updateRgn with your separate update region,
  1283. and then call ValidRgn or ValidRect (quicker than BeginUpdate/EndUpdate) to
  1284. clear the update event.
  1285.  
  1286. Then each time around your event loop, you select a window with a non-null
  1287. region needing updating. You extract a band from this region (say a rectangle
  1288. extending the full width of the window, but limited to some maximum height),
  1289. representing an area that you can update in the maximum interval that you're
  1290. prepared to tolerate between responses to mouse/key events. You set the clip
  1291. region to the intersection of this band and the application-level clip region,
  1292. and do your updating of that area (hopefully minimizing your attempts to draw
  1293. objects that fall entirely outside the clip region). And you subtract the band
  1294. from the region needing updating.
  1295.  
  1296. How does this sound? There is a potential complication if your on-screen
  1297. drawing involves CopyBits dithering (the error propagation may not match up
  1298. across the band boundaries), but it's not insurmountable.
  1299.  
  1300. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1301. Computer Services Dept                     fax: +64-7-838-4066
  1302. University of Waikato            electric mail: ldo@waikato.ac.nz
  1303. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1304.  
  1305. ---------------------------
  1306.  
  1307. End of C.S.M.P. Digest
  1308. **********************
  1309.