home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-016 < prev    next >
Internet Message Format  |  2010-09-21  |  71KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-016
  3. To: Scott.M.Silver@Dartmouth.EDU
  4. Date: Sat, 23 Apr 94 10:55:49 MET DST
  5. X-Mailer: ELM [version 2.3 PL11]
  6.  
  7. C.S.M.P. Digest             Mon, 18 Apr 94       Volume 3 : Issue 16
  8.  
  9. Today's Topics:
  10.  
  11.         AppleTalk ON and OFF
  12.         CtoPstr in THINK C 6.0
  13.         Highlight colour?
  14.         Picture Recording
  15.         Speeding up animation; questions
  16.         Tools to improve segmentation?
  17.         copy file question, code available?
  18.         skeleton code generators?
  19.  
  20.  
  21.  
  22. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  23. (pottier@clipper.ens.fr).
  24.  
  25. The digest is a collection of article threads from the internet newsgroup
  26. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  27. regularly and want an archive of the discussions.  If you don't know what a
  28. newsgroup is, you probably don't have access to it.  Ask your systems
  29. administrator(s) for details.  If you don't have access to news, you may
  30. still be able to post messages to the group by using a mail server like
  31. anon.penet.fi (mail help@anon.penet.fi for more information).
  32.  
  33. Each issue of the digest contains one or more sets of articles (called
  34. threads), with each set corresponding to a 'discussion' of a particular
  35. subject.  The articles are not edited; all articles included in this digest
  36. are in their original posted form (as received by our news server at
  37. nef.ens.fr).  Article threads are not added to the digest until the last
  38. article added to the thread is at least two weeks old (this is to ensure that
  39. the thread is dead before adding it to the digest).  Article threads that
  40. consist of only one message are generally not included in the digest.
  41.  
  42. The digest is officially distributed by two means, by email and ftp.
  43.  
  44. If you want to receive the digest by mail, send email to listserv@ens.fr
  45. with no subject and one of the following commands as body:
  46.     help                        Sends you a summary of commands
  47.     subscribe csmp-digest Your Name    Adds you to the mailing list
  48.     signoff csmp-digest            Removes you from the list
  49. Once you have subscribed, you will automatically receive each new
  50. issue as it is created.
  51.  
  52. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  53. Questions related to the ftp site should be directed to
  54. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  55. digest are available there.
  56.  
  57. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  58.  
  59.  
  60. -------------------------------------------------------
  61.  
  62. From makmur@aramis.rutgers.edu (Hanz Makmur)
  63. Subject: AppleTalk ON and OFF
  64. Date: 18 Mar 94 21:02:12 GMT
  65. Organization: Rutgers Univ., New Brunswick, N.J.
  66.  
  67.  
  68. Hi..
  69. I am learning how to program a Mac and trying to figure out a way to 
  70. Turn ON and Off appletalk at will from a program.
  71.  
  72. Does anyone have any idea how to do this ?  There is a program called:
  73. AppleTalkON by Jon Pugh@apple that does appletalk ON and OFF. I tried
  74. to contact Jon but it looks like he is no longer at Apple.
  75.  
  76. If any one can help, I appreciate the help. A pointer or sample source
  77. code will help.
  78.  
  79. Thank you.
  80. Hanz
  81.  
  82. If possible at all, please reply by mail to: makmur@cs.rutgers.edu
  83. -- 
  84. - ---------------------------The opinions expressed in this message are 
  85. Hanz Makmur             my own and do not necessarily reflect those of 
  86. makmur@cs.rutgers.edu         The State University of New Jersey. U.S.A
  87.  
  88. +++++++++++++++++++++++++++
  89.  
  90. From jonpugh@netcom.com (Jon Pugh)
  91. Date: Sun, 20 Mar 1994 07:41:23 GMT
  92. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  93.  
  94. Hanz Makmur (makmur@aramis.rutgers.edu) wrote:
  95.  
  96. > Does anyone have any idea how to do this ?  There is a program called:
  97. > AppleTalkON by Jon Pugh@apple that does appletalk ON and OFF. I tried
  98. > to contact Jon but it looks like he is no longer at Apple.
  99.  
  100. That doesn't mean I'm dead.  ;)
  101.  
  102. I simply call MPPOpen and MPPClose.  If you want it to stick across reboots
  103. then you also need to twiddle the PortB global.  See IM 1-3 for the 
  104. specifics.
  105.  
  106. Jon
  107.  
  108.  
  109.  
  110. +++++++++++++++++++++++++++
  111.  
  112. From zben@ni.umd.edu (Charles B. Cranston)
  113. Date: 20 Mar 1994 19:02:31 GMT
  114. Organization: UMCP Network Infrastructures
  115.  
  116. In article <jonpughCMyDCz.GrG@netcom.com>, jonpugh@netcom.com (Jon Pugh)
  117. wrote:
  118.  
  119. > I simply call MPPOpen and MPPClose.  If you want it to stick across reboots
  120. > then you also need to twiddle the PortB global.  See IM 1-3 for the 
  121. > specifics.
  122.  
  123. I've written an INIT to force it on and off.  It does a reboot
  124. to get the change to 'take'.  Does the code below do the
  125. appropriate kind of fiddling with the PortB global?
  126.  
  127. I just dumped PRAM and found it contained 1 in one case
  128. and 2 in the other.
  129.  
  130. In particular, IM 1-3 was written when ALAP was the only LAP for
  131. AppleTalk and the extension to a world in which the Ether/Token
  132. LAPs are also an alternative is not obvious to me...
  133.  
  134. ===============
  135.  
  136. ...
  137.     Move.L    #$00010013,D0        ; Byte 13
  138.     LEA    S.Curr(A6),A0        ; Point to stack space
  139.     _ReadXPram            ; Read current setting from parameter RAM
  140.     BNE.S    @900            ; If error then get out
  141.     Move.B    #1,D1            ; Get "ON" value
  142.     Tst.L    S.Want(A6)        ; Do we want it on?
  143.     BNE.S    @040            ; Yes, go set it ON
  144.     Move.B    #2,D1            ; Else get "OFF" value
  145. @040    ;
  146.     LEA    S.Curr(A6),A0        ; Get address of current value
  147.     Move.B    (A0),D2            ; Get current value
  148.     And.B    #$0F,D2            ; Get AppleTalk config bits
  149.     Cmp.B    D2,D1            ; Is it the desired value?
  150.     BEq.S    @050            ; Yes, go check LAP status
  151. *
  152. * Rewrite AppleTalk On/Off selection in PRAM and force reboot.
  153. *
  154.     Move.B    (A0),D2            ; Get current value
  155.     And.B    #$F0,D2            ; Keep upper 4 bits
  156.     Or.B    D1,D2            ; Use our lower bits
  157.     Move.B    D2,(A0)            ; Set current value
  158.     Move.L    #$00010013,D0        ; Bytes E0 thru E3
  159.     _WriteXPram            ; Write back to parameter RAM
  160.     Move.W    #1,S.Boot(A6)        ; Set flag to force reboot
  161. ...
  162.  
  163. ===============
  164.  
  165.     Title    'Force AppleTalk and LAP settings' ;
  166. *
  167. * Module for "Force" shell.
  168. * Ben Cranston March 1, 1994
  169. *
  170.     Print    Off            ; Here be includes
  171.     Include    'RomEqu.a'        ;
  172.     Include    'Traps.a'        ;
  173.     Print    On,NoGen        ; Here be includes
  174.     Main                ; Begin module
  175. *
  176. S    Record    {A6Link},Decr        ; Stack frame
  177. A6Link    DS.L    1            ; Caller's A6
  178. SPB    DS    SpBlock            ; Slot Parameter Block
  179. Curr    DS.L    1            ; Current PRAM value
  180. Want    DS.L    1            ; Desired PRAM value
  181. Flag    DS.W    1            ; Desired PRAM setup flags
  182. Boot    DS.W    1            ; Set if reboot required
  183. SS    Equ    *            ; Stack size
  184.     EndR                ; Stack frame
  185. *
  186. * Get resource containing the desired PRAM contents.
  187. *
  188.     Link    A6,#S.SS        ; Make local frame
  189.     Clr.W    S.Boot(A6)        ; Initially set no reboot
  190.     Tst.L    D1            ; Was our data resource present?
  191.     BEq.W    @999            ; If not then just return
  192.     Move.L    D1,A0            ; Get resource handle
  193.     Move.L    (A0),A0            ; Get pointer
  194.     Move.W    (A0),S.Flag(A6)        ; Get desired value
  195. *
  196.     Eject                ;
  197. *
  198. * Test if AppleTalk is to be turned off entirely.
  199. *
  200.     Clr.L    S.Want(A6)        ; Initially set AppleTalk OFF
  201.     Move.B    S.Flag+0(A6),D1        ; Get master flag
  202.     BEq.S    @030            ; Is AppleTalk to be turned off entirely?
  203. *
  204. * Test if LocalTalk is wanted.
  205. *
  206.     Move.B    #1,S.Want+3(A6)        ; Set AppleTalk on LocalTalk
  207.     Cmp.B    #1,D1            ; Want LocalTalk or EtherTalk?
  208.     BEq.S    @030            ; Want EtherTalk, skip
  209. *
  210. * Find Ethernet card address to complete the desired PRAM value.
  211. *
  212.     LEA    S.SPB(A6),A0        ; Get spBlock address
  213.     Move.B    S.Flag+1(A6),spBlock.spSlot(A0) ; Set slot to start searching at
  214.     Clr.B    spBlock.spId(A0)    ; Find any resource number
  215.     Clr.B    spBlock.spExtDev(A0)    ; External device zero?
  216.     Clr.B    spBlock.spHwDev(A0)    ; Ignore external hardware
  217.     Move.B    #3,spBlock.spTBMask(A0)    ; Look at Category and CType
  218.     Move.W    #catNetwork,spBlock.spCategory(A0) ; Network category
  219.     Move.W    #typEtherNet,spBlock.spCType(A0) ; EtherNet type
  220.     _sNextTypesRsrc            ; Get next sResource info
  221.     BNE.W    @900            ; If nofind then get out
  222.     Move.B    spBlock.spSlot(A0),S.Want+0(A6) ; Get network card slot number
  223.     Move.B    spBlock.spId(A0),S.Want+1(A6) ; Get slot resource ID number
  224.     Clr.B    S.Want+2(A6)        ; Clear unused field
  225.     Move.B    #$A,D1            ; Get EtherTalk Phase 2 code
  226.     Cmp.B    #2,S.Flag+0(A6)        ; Did he want Phase 1?
  227.     BNE.S    @020            ; If not then assume Phase 2
  228.     Move.B    #$2,D1            ; Get EtherTalk Phase 1 code
  229. @020    ;
  230.     Move.B    D1,S.Want+3(A6)        ; Set Phase 1 / Phase 2 code
  231. *
  232.     Eject                ;
  233. *
  234. * Read PRAM for AppleTalk On/Off selection, decide if we must change it.
  235. *
  236. @030    ;
  237.     Move.L    #$00010013,D0        ; Byte 13
  238.     LEA    S.Curr(A6),A0        ; Point to stack space
  239.     _ReadXPram            ; Read current setting from parameter RAM
  240.     BNE.S    @900            ; If error then get out
  241.     Move.B    #1,D1            ; Get "ON" value
  242.     Tst.L    S.Want(A6)        ; Do we want it on?
  243.     BNE.S    @040            ; Yes, go set it ON
  244.     Move.B    #2,D1            ; Else get "OFF" value
  245. @040    ;
  246.     LEA    S.Curr(A6),A0        ; Get address of current value
  247.     Move.B    (A0),D2            ; Get current value
  248.     And.B    #$0F,D2            ; Get AppleTalk config bits
  249.     Cmp.B    D2,D1            ; Is it the desired value?
  250.     BEq.S    @050            ; Yes, go check LAP status
  251. *
  252. * Rewrite AppleTalk On/Off selection in PRAM and force reboot.
  253. *
  254.     Move.B    (A0),D2            ; Get current value
  255.     And.B    #$F0,D2            ; Keep upper 4 bits
  256.     Or.B    D1,D2            ; Use our lower bits
  257.     Move.B    D2,(A0)            ; Set current value
  258.     Move.L    #$00010013,D0        ; Bytes E0 thru E3
  259.     _WriteXPram            ; Write back to parameter RAM
  260.     Move.W    #1,S.Boot(A6)        ; Set flag to force reboot
  261.     Tst.L    S.Want(A6)        ; Did we want it off?
  262.     BEq.S    @999            ; Yes, we are done
  263. *
  264.     Eject                ;
  265. *
  266. * Read PRAM for AppleTalk LAP selection, decide if we must change it.
  267. *
  268. @050    ;
  269.     Move.L    #$000400E0,D0        ; Bytes E0 thru E3
  270.     LEA    S.Curr(A6),A0        ; Point to stack space
  271.     _ReadXPram            ; Read current from parameter RAM
  272.     BNE.S    @900            ; If error then get out
  273.     Move.B    S.Curr+1(A6),D1        ; Get current alt atalk type
  274.     Cmp.B    S.Want+1(A6),D1        ; Same as desired?
  275.     BNE.S    @060            ; No, must reset and reboot
  276.     Move.B    S.Curr+3(A6),D1        ; Get current alt level
  277.     Cmp.B    S.Want+3(A6),D1        ; Same as desired?
  278.     BEq.S    @999            ; If so then skip
  279. *
  280. * Rewrite AppleTalk LAP selection in PRAM and force reboot.
  281. *
  282. @060    ;
  283.     LEA    S.Want(A6),A0        ; Get address of desired
  284.     Move.L    #$000400E0,D0        ; Bytes E0 thru E3
  285.     _WriteXPram            ; Write back to parameter RAM
  286.     Move.W    #1,S.Boot(A6)        ; Set flag to force reboot
  287.     Bra.S    @999            ; Return to driver
  288. *
  289. * Some kind of error, just return OK status.
  290. *
  291. @900    ;
  292.     Clr.W    S.Boot(A6)        ; Set no reboot
  293. *
  294. @999    ;
  295.     Move.W    S.Boot(A6),D0        ; Set return value
  296.     UnLk    A6            ; Drop local frame
  297.     RTS                ; Return to INIT31
  298. *
  299.     EndMain                ; Keep MPW happy
  300.     End                ; ForceAppleTalk.a
  301.  
  302. +++++++++++++++++++++++++++
  303.  
  304. From walkerj@math.scarolina.edu (Jim Walker)
  305. Date: 21 Mar 1994 02:42:16 GMT
  306. Organization: University of South Carolina - Columbia - Computer Science
  307.  
  308. jonpugh@netcom.com (Jon Pugh) writes:
  309.  
  310. >I simply call MPPOpen and MPPClose.  If you want it to stick across reboots
  311. >then you also need to twiddle the PortB global.  See IM 1-3 for the 
  312. >specifics.
  313.  
  314. When I tried MPPOpen, I got a -98 error unless I cleared the low nybble of  
  315. SPConfig first.
  316.  
  317. The current AppleTalk.h says that MPPClose is obsolete, but so far as I know 
  318. Apple has not released a new Inside Mac volume discussing AppleTalk. Anyone
  319. know what should be used instead of MPPClose?
  320.  
  321.  
  322. --
  323.  
  324.  -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  325.  
  326. +++++++++++++++++++++++++++
  327.  
  328. From mahboud@aggroup.com (Mahboud Zabetian)
  329. Date: Mon, 21 Mar 1994 12:43:21 -0800
  330. Organization: AG Group, Inc.
  331.  
  332. In article <2mj1i8$jki@redwood.cs.scarolina.edu>,
  333. walkerj@math.scarolina.edu (Jim Walker) wrote:
  334.  
  335. > jonpugh@netcom.com (Jon Pugh) writes:
  336. > >I simply call MPPOpen and MPPClose.  If you want it to stick across reboots
  337. > >then you also need to twiddle the PortB global.  See IM 1-3 for the 
  338. > >specifics.
  339. > When I tried MPPOpen, I got a -98 error unless I cleared the low nybble of  
  340. > SPConfig first.
  341. > The current AppleTalk.h says that MPPClose is obsolete, but so far as I know 
  342. > Apple has not released a new Inside Mac volume discussing AppleTalk. Anyone
  343. > know what should be used instead of MPPClose?
  344.  
  345. I remember seeing a TechNote that said use PBOpen (OpenDriver) and PBClose
  346. instead.  Check the Networking TechNotes.  I believe that MPPClose is one
  347. of the calls that will not be ported to the PowerPC.  I think that it will
  348. still be available emulated, but if your native app want to get to it,
  349. it'll have to go through some hoops.
  350.  
  351. -mahboud
  352.  
  353. - -------------------------------------------------------------
  354. Mahboud Zabetian
  355. mahboud@aggroup.com
  356. ag group, inc.
  357. 2540 camino diablo, suite 200
  358. walnut creek, ca 94596
  359. 510-937-7900 voice
  360. 510-937-2479 fax
  361. 510-937-6704 ara
  362. ftp.aggroup.com anonymous ftp
  363.  
  364. +++++++++++++++++++++++++++
  365.  
  366. From Mark_Day@powertalk.apple.com (Mark Day)
  367. Date: Fri, 1 Apr 1994 18:10:08 GMT
  368. Organization: Apple Computer, Inc.
  369.  
  370. In article <2mj1i8$jki@redwood.cs.scarolina.edu>,
  371. walkerj@math.scarolina.edu (Jim Walker) wrote:
  372.  
  373. > When I tried MPPOpen, I got a -98 error unless I cleared the low nybble of  
  374. > SPConfig first.
  375.  
  376. Fiddling with SPConfig sounds kind of dangerous.  If .MPP won't open the
  377. printer port for LocalTalk, it's probably because some other piece of
  378. software says it is still using the port.  I'd suggest tracking down
  379. what other code thinks it's using the printer port, first (and make sure
  380. it clears the in use bit when it really is done with the port).
  381.  
  382. > The current AppleTalk.h says that MPPClose is obsolete, but so far as I know 
  383. > Apple has not released a new Inside Mac volume discussing AppleTalk. Anyone
  384. > know what should be used instead of MPPClose?
  385.  
  386. MPPOpen is the equivalent of OpenDriver(".MPP"), and MPPClose is equivalent
  387. to closing the .MPP driver.  Theoretically, you shouldn't close the network
  388. drivers from your application because some other application may be using
  389. them.  Ask yourself if you REALLY need to close .MPP.
  390.  
  391. If you do have a valid reason to close the driver (for example, you're
  392. providing a user with the ability to turn AppleTalk on or off, like the
  393. Chooser does), I'd suggest using OpenDriver and CloseDriver on the .MPP
  394. driver.
  395.  
  396. The other thing you should look at is the AppleTalk Transition Queue,
  397. which is used to notify clients of changes to AppleTalk's state.  I don't
  398. know enough of the details to tell you what the right thing to do is,
  399. there.
  400. It's documented, but offhand, I don't know where.
  401. -- 
  402. Mark Day, Apple Computer, Inc.
  403. mday@apple.com
  404.  
  405. +++++++++++++++++++++++++++
  406.  
  407. From walkerj@math.scarolina.edu (Jim Walker)
  408. Date: 2 Apr 1994 04:28:54 GMT
  409. Organization: University of South Carolina - Columbia - Computer Science
  410.  
  411. Mark_Day@powertalk.apple.com (Mark Day) writes:
  412.  
  413. >If you do have a valid reason to close the driver (for example, you're
  414. >providing a user with the ability to turn AppleTalk on or off, like the
  415. >Chooser does), I'd suggest using OpenDriver and CloseDriver on the .MPP
  416. >driver.
  417.  
  418. Yes, that's the idea, I want to make a utility that turns AppleTalk on and
  419. off.  I would not do that without the user's consent.  But unlike the
  420. Chooser, I would like to be able to turn AppleTalk on without restarting the
  421. Mac.  Calling OpenDriver on .MPP just gives a -23 error in that case. 
  422. Anyone know the trick?
  423. --
  424.  
  425.  -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  426.  
  427. +++++++++++++++++++++++++++
  428.  
  429. From ugtalbot@mcs.drexel.edu (George T. "14K F/D" Talbot)
  430. Date: Sat, 2 Apr 94 20:54:00 GMT
  431. Organization: Drexel University
  432.  
  433. In article <2nisa6$i6u@redwood.cs.scarolina.edu> walkerj@math.scarolina.edu (Jim Walker) writes:
  434. >Mark_Day@powertalk.apple.com (Mark Day) writes:
  435. >
  436. >>If you do have a valid reason to close the driver (for example, you're
  437. >>providing a user with the ability to turn AppleTalk on or off, like the
  438. >>Chooser does), I'd suggest using OpenDriver and CloseDriver on the .MPP
  439. >>driver.
  440. >
  441. >Yes, that's the idea, I want to make a utility that turns AppleTalk on and
  442. >off.  I would not do that without the user's consent.  But unlike the
  443. >Chooser, I would like to be able to turn AppleTalk on without restarting the
  444. >Mac.  Calling OpenDriver on .MPP just gives a -23 error in that case. 
  445. >Anyone know the trick?
  446. >--
  447. >
  448. > -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  449.  
  450. I've run into this using the .ENET driver.  You have to set the read/write
  451. permissions in the Open parameter block to fsSharedRdWrPerm (or something like
  452. that) to open the driver.  This means you'll have to use the PBOpen call,
  453. rather than OpenDriver.
  454.  
  455. Hope this helps.
  456.  
  457. -- 
  458. George T. Talbot
  459. <ugtalbot@mcs.drexel.edu>
  460. - -------------------------------------------------------------------------
  461. Finger my account for PGP public key.  |  This is very political software.
  462.  
  463. +++++++++++++++++++++++++++
  464.  
  465. From mahboud@aggroup.com (mahboud)
  466. Date: Mon, 04 Apr 1994 15:53:33 -0800
  467. Organization: AG Group, Inc.
  468.  
  469. In article <2nisa6$i6u@redwood.cs.scarolina.edu>,
  470. walkerj@math.scarolina.edu (Jim Walker) wrote:
  471.  
  472. > Mark_Day@powertalk.apple.com (Mark Day) writes:
  473. > >If you do have a valid reason to close the driver (for example, you're
  474. > >providing a user with the ability to turn AppleTalk on or off, like the
  475. > >Chooser does), I'd suggest using OpenDriver and CloseDriver on the .MPP
  476. > >driver.
  477. > Yes, that's the idea, I want to make a utility that turns AppleTalk on and
  478. > off.  I would not do that without the user's consent.  But unlike the
  479. > Chooser, I would like to be able to turn AppleTalk on without restarting the
  480. > Mac.  Calling OpenDriver on .MPP just gives a -23 error in that case. 
  481. > Anyone know the trick?
  482. > --
  483. >  -- Jim Walker  USC Dept. of Math.  walkerj@math.scarolina.edu
  484.  
  485. If AppleTalk was off when you restarted, a major portion of its code will
  486. not be in memory and will not be loaded up with an MPPOpen (or PBOpen)
  487. call.  This cahnge was put in after the original System 7 Tuner in order to
  488. save about 100K of memory for people who are not using their macs on
  489. networks.
  490.  
  491. I think that you will have to restart if you did not have AppleTalk active,
  492. the last time you restarted.
  493.  
  494. On the other hand, I have had no trouble turning AppleTalk off and on, if
  495. it was already active.  I use MPPOpen and MPPClose.
  496.  
  497. -mahboud
  498. - -------------------------------------------------------------
  499. Mahboud Zabetian
  500. mahboud@aggroup.com
  501. ag group, inc.
  502. 2540 camino diablo, suite 200
  503. walnut creek, ca 94596
  504. 510-937-7900 voice
  505. 510-937-2479 fax
  506. 510-937-6704 ara
  507. ftp.aggroup.com anonymous ftp
  508.  
  509. ---------------------------
  510.  
  511. From wang_dj@dev.gdb.org (David J. Wang)
  512. Subject: CtoPstr in THINK C 6.0
  513. Date: Sat, 2 Apr 1994 01:40:17 GMT
  514. Organization: Genome Database
  515.  
  516. I have a newbie programmer question.  Can anyone instruct me as to the
  517. correct way to use CtoPstr and PtoCstr.  I suppose the problem isn't
  518. so much in using those functions, but rather trying to pass the result
  519. to a function that requires a Str255 (for example DrawString() ).
  520. For example:
  521.     char *foo;
  522.     CtoPstr(foo);
  523.     DrawString(WHAT GOES IN HERE?);
  524.  
  525.     or am I totally off base.  On a related note, why does CtoPstr
  526. take a pointer to a char for an argument while PtoCstr take a pointer
  527. to an unsigned char.  This being the case, does that mean that I have
  528. to always cast one or the other?
  529.  
  530. Finally, I would appreciate any hints in getting started in Mac
  531. programming, or where I could turn (good books, etc).
  532.  
  533. Thanks,
  534.  
  535. David
  536.  
  537.  
  538. --
  539. *************************************************************************
  540. David J. Wang                 #include <std_disclaimer>
  541. wang_dj@gdb.org                 (410)614-0393
  542. wang_dj@server.cs.jhu.edu         Biology@The Johns Hopkins University
  543.                      Baltimore, Maryland 21210
  544. ************************************************************************/
  545.  
  546. +++++++++++++++++++++++++++
  547.  
  548. From omh@cs.brown.edu (Owen M. Hartnett)
  549. Date: Sat, 2 Apr 1994 05:10:17 GMT
  550. Organization: Brown University Department of Computer Science
  551.  
  552. In article <1994Apr2.014017.6498@news.gdb.org> wang_dj@dev.gdb.org (David J. Wang) writes:
  553. >I have a newbie programmer question.  Can anyone instruct me as to the
  554. >correct way to use CtoPstr and PtoCstr.  I suppose the problem isn't
  555. >so much in using those functions, but rather trying to pass the result
  556. >to a function that requires a Str255 (for example DrawString() ).
  557. >For example:
  558. >    char *foo;
  559. >    CtoPstr(foo);
  560. >    DrawString(WHAT GOES IN HERE?);
  561. >
  562. >    or am I totally off base.  On a related note, why does CtoPstr
  563. >take a pointer to a char for an argument while PtoCstr take a pointer
  564. >to an unsigned char.  This being the case, does that mean that I have
  565. >to always cast one or the other?
  566. >
  567. >Finally, I would appreciate any hints in getting started in Mac
  568. >programming, or where I could turn (good books, etc).
  569. >
  570.  
  571. Hi David!
  572.  
  573. This is an excellent newbie question. Thanks for posing it.
  574.  
  575. Your question actually has many facets, so I will attempt to answer the
  576. whole scope here.
  577.  
  578. 1) First of all, in your code above, strictly speaking, will cause the
  579. computer to crash. The definition:
  580.     char *foo;
  581. only defines enough space for a pointer to a string of characters, not
  582. the string itself. You have to define the space yourself, as in:
  583.     char foo[255];
  584. This allocates an array of 255 characters and makes space for the
  585. characters themselves. Once you do this you can than use the name of
  586. the array, foo, as a pointer to the first character, foo[0]. Thus, you
  587. could assign it to another char pointer, as so:
  588.  
  589.     char *foo
  590.     char bar[255];
  591.  
  592.     foo = bar;
  593.  
  594. This will make the pointer foo act the same as the pointer bar.
  595.  
  596. 2) I went through the above explanation even though I thought you
  597. might already know it because of the way you used your code example.
  598. Also, I wanted to point out the fact that CtoPstr and PtoCstr change
  599. the strings *in place*. They expect that you are passing to them a
  600. pointer to a string of characters which already exist in memory, and
  601. they move the test over a byte one way or the other and write in
  602. either a trailing zero or a beginning length byte.
  603.  
  604. 3) Because of the nature of these bad boys, and that the string you want
  605. to C may be declared as C or P or vice versa, you end up casting a lot.
  606. A useful type for casting is StringPtr. This can be used to cast a
  607. char * into a Str255 * (which you can't do directly, hence your above
  608. problem.)
  609.  
  610. Thus, here is the compleat guide for string casting, along with sundry
  611. baits and lures:
  612.  
  613.     char    foo[255];
  614.     Str255    bar;
  615.  
  616.     char    mac[255];
  617.     Str255    ibm;
  618.  
  619.     /* Assume appropriate data has been moved into strings    */
  620.  
  621.     /* straight, no casting required    */
  622.  
  623.     CtoPstr(foo);
  624.     PtoCstr(bar);
  625.  
  626.     /* cast your pointers to the winds!    */
  627.  
  628.     CtoPstr((char *) ibm);
  629.     PtoCstr((StringPtr) mac);
  630.  
  631. Remember, let he whose programs are without bugs cast the first pointers.
  632.  
  633. -Owen
  634.  
  635. -Owen
  636.  
  637.  
  638. -- 
  639. Owen Hartnett                omh@cs.brown.edu
  640. "FAITH, n. Belief without evidence in what is told by one who speaks
  641.         without knowledge, of things without parallel."
  642.             -Ambrose Bierce - The Devil's Dictionary
  643.  
  644. +++++++++++++++++++++++++++
  645.  
  646. From benh@fdn.org (Benjamin Herrenschmidt)
  647. Date: Sun, 3 Apr 94 12:36:41 +0100
  648. Organization: (none)
  649.  
  650.  
  651. Be careful to allocate your Pascal string as an array of 256 chars,
  652. not 255 ! There is the length byte !
  653.  
  654. char foo[256];    // is ok.
  655.  
  656. Str255 foo;        // is ok too
  657.  
  658. BenH.
  659.  
  660. ---------------------------
  661.  
  662. From ikb_macd@ECE.Concordia.CA (Ian Keith Baker Mac Donald)
  663. Subject: Highlight colour?
  664. Date: Mon, 4 Apr 1994 03:59:56 GMT
  665. Organization: ECE - Concordia University
  666.  
  667. I'd like to use the highlight colour as specified by the user in the Colors
  668. control panel, can anyone tell me how to get the color information?  IM
  669. says that there's a global called HiliteRGB, but ThinkP doesn't recognize
  670. it.
  671.  
  672. Thanks,
  673. Keith
  674.  
  675.  
  676.  
  677. +++++++++++++++++++++++++++
  678.  
  679. From rlvd_cif@uhura.cc.rochester.edu (Rob Levandowski)
  680. Date: Mon, 4 Apr 94 05:27:18 GMT
  681. Organization: University of Rochester - Rochester, New York
  682.  
  683. In <Cnpv3w.2pJ@newsflash.concordia.ca> ikb_macd@ECE.Concordia.CA (Ian Keith Baker Mac Donald) writes:
  684.  
  685. >I'd like to use the highlight colour as specified by the user in the Colors
  686. >control panel, can anyone tell me how to get the color information?  IM
  687. >says that there's a global called HiliteRGB, but ThinkP doesn't recognize
  688. >it.
  689.  
  690. >Thanks,
  691. >Keith
  692.  
  693.  
  694. Try adding "SysEqu.p" to your project.
  695.  
  696. The recommended way to use the hilight colour is detailed in Inside Mac
  697. vol. V, p. V-61. (I don't have the new IM.) Issue the command
  698.  
  699.     BitClr(Ptr(Hilite,pHiliteBit));
  700.  
  701. immediately before InvertRect,InvertRgn,InvertArc,InvertRoundRct, or
  702. InvertPoly, or any other drawing done in srcXor mode. The inversion will
  703. be done using the user-selected hilite color on a color-capable Mac;
  704. otherwise B&W is used. This is safe to call on all Macs. You must make
  705. the call immediately before each call that you want to use hilite color
  706. with; it is reset each time a drawing call is made.
  707. -- 
  708. --Rob Levandowski
  709.   Computer Interest Floor associate / University of Rochester
  710.   macwhiz@cif.rochester.edu     [Opinions expressed are mine, not UR's.]
  711.  
  712. +++++++++++++++++++++++++++
  713.  
  714. From platypus@cirrus.som.cwru.edu (Gary Kacmarcik)
  715. Date: 04 Apr 1994 13:26:38 GMT
  716. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  717.  
  718. In article <1994Apr4.052718.8957@galileo.cc.rochester.edu> rlvd_cif@uhura.cc.rochester.edu (Rob Levandowski) writes:
  719. >
  720. > In <Cnpv3w.2pJ@newsflash.concordia.ca> ikb_macd@ECE.Concordia.CA (Ian Keith Baker Mac Donald) writes:
  721. >
  722. > >I'd like to use the highlight colour as specified by the user in the Colors
  723. > >control panel, can anyone tell me how to get the color information?  IM
  724. > >says that there's a global called HiliteRGB, but ThinkP doesn't recognize
  725. > >it.
  726. >
  727. > The recommended way to use the hilight colour is detailed in Inside Mac
  728. > vol. V, p. V-61. (I don't have the new IM.) Issue the command
  729. >
  730. >    BitClr(Ptr(Hilite,pHiliteBit));
  731. >
  732. > immediately before InvertRect,InvertRgn,InvertArc,InvertRoundRct, or
  733.  
  734. this is no longer the recommended way to do this.  in fact, accessing
  735. any Low Memory global _directly_ is frowned upon.
  736.  
  737. the proper way is to use the accessor functions:
  738.  
  739.   extern unsigned char LMGetHiliteMode(void);
  740.   extern void LMSetHiliteMode(unsigned char HiliteModeValue);
  741.  
  742. these are defined as part of the new Universal Headers (in LowMem.h)
  743.  
  744. if you compile a native version of your code using the "set the Low Mem
  745. global directly" method, you are likely to run into problems.
  746.  
  747. > This is safe to call on all Macs.
  748.  
  749. the direct method is "safe" to call on all 68k macs and PowerMacs running
  750. in 68k emulation, but not on PowerMacs in native mode.
  751.  
  752. the accessor functions will compile to the right thing on 68k and PowerPC
  753. based Macs.
  754.  
  755.  
  756. -gary j kacmarcik
  757. platypus@curie.ces.cwru.edu
  758.  
  759. +++++++++++++++++++++++++++
  760.  
  761. From d88-jwa@mumrik.nada.kth.se (Jon Wdtte)
  762. Date: 4 Apr 1994 14:19:07 GMT
  763. Organization: The Royal Institute of Technology
  764.  
  765. In <PLATYPUS.94Apr4092638@cirrus.som.cwru.edu> platypus@cirrus.som.cwru.edu (Gary Kacmarcik) writes:
  766.  
  767. >this is no longer the recommended way to do this.  in fact, accessing
  768. >any Low Memory global _directly_ is frowned upon.
  769.  
  770. That's because the new Macintosh OS will supposedly do away with
  771. the globals, but retain accessors for the equivalent functionality.
  772.  
  773. >  extern unsigned char LMGetHiliteMode(void);
  774. >  extern void LMSetHiliteMode(unsigned char HiliteModeValue);
  775. >these are defined as part of the new Universal Headers (in LowMem.h)
  776.  
  777. Yes, but using the lo-mem global at all is only marginally
  778. better than addressing it directly. Instead, use PenMode(hilite)
  779. like so:
  780.  
  781.     PenMode ( hilite ) ;
  782.     InvertRgn ( selectionRgn ) ;
  783.  
  784. >if you compile a native version of your code using the "set the Low Mem
  785. >global directly" method, you are likely to run into problems.
  786.  
  787. No problem. ALL lo-mem globals are still there on the PowerPC.
  788. I spoke to an engineer who translated part of ROM (things like
  789. Button :-) and he said they pretty much kept ALL quirks of the
  790. ROM, for compatibility (like journalling, which is why Button
  791. may move memory)
  792.  
  793. -- 
  794.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  795.     Not speaking for the Liberian Government.
  796.  
  797. ---------------------------
  798.  
  799. From weip@engin.umich.edu (Patrick Wei)
  800. Subject: Picture Recording
  801. Date: 4 Apr 1994 17:22:32 GMT
  802. Organization: University of Michigan Engineering, Ann Arbor
  803.  
  804.  
  805. I can't seem to get drawing information recorded into a picture that is loaded from
  806. a resource file. Should I call OpenPicture in addition to DrawPicture?
  807.  
  808. The code is the following:
  809.  
  810. - --------------------------------
  811.     resFileNum = OpenResFile( (ConstStr255Param) pictInfo[j].name);
  812.     if((thePicture = GetPicture( (short) pictInfo[j].id)) == 0)
  813.     {
  814.         printf("can't get picture\n");
  815.         goto end_of_loop;
  816.     }
  817.  
  818.     r = (*thePicture)->picFrame;
  819.     width = r.right - r.left;
  820.     height = r.bottom - r.top;
  821.         
  822.     SetRect(&r, 0, 0, width, height);
  823.     OffsetRect(&r, 50, 50);
  824.     
  825.     DrawPicture(thePicture, &r);
  826.  
  827.     followed by a bunch of Line and LineTo operations. 
  828.  
  829.     //save resource    
  830.     {
  831.     Handle pictHandle;
  832.     PtrToHand(*thePicture, &pictHandle, (*thePicture)->picSize);
  833.     AddResource(pictHandle, 'PICT', 401, "\p");     
  834.     CloseResFile(resFileNum);
  835.     }
  836. - --------------------------------------
  837.  
  838. When I tried the save thePicture, the original picture is saved to disk, not the altered
  839. version that I want. The drawing information is never recorded into the picture
  840.  
  841. +++++++++++++++++++++++++++
  842.  
  843. From Carl R. Osterwald <carl_osterwald@nrel.gov>
  844. Date: Mon, 4 Apr 94 21:43:51 GMT
  845. Organization: National Renewable Energy Laboratory
  846.  
  847. In article <2npicoINNq72@srvr1.engin.umich.edu> Patrick Wei,
  848. weip@engin.umich.edu writes:
  849. >I can't seem to get drawing information recorded into a picture that is
  850. loaded from
  851. >a resource file. Should I call OpenPicture in addition to DrawPicture?
  852. >    resFileNum = OpenResFile( (ConstStr255Param) pictInfo[j].name);
  853. >    DrawPicture(thePicture, &r);
  854. >
  855. >    followed by a bunch of Line and LineTo operations. 
  856. >
  857. >    //save resource    
  858. >    {
  859. >    Handle pictHandle;
  860. >    PtrToHand(*thePicture, &pictHandle, (*thePicture)->picSize);
  861. >    AddResource(pictHandle, 'PICT', 401, "\p");     
  862. >    CloseResFile(resFileNum);
  863. >    }
  864. >When I tried the save thePicture, the original picture is saved to disk,
  865. not the altered
  866. >version that I want. The drawing information is never recorded into the
  867. picture
  868.  
  869. If you are trying to make a new PICT, you have to use:
  870. * OpenPicture
  871. * (QD drawing commands)
  872. * ClosePicture
  873. * AddResource
  874.  
  875. If you are trying to modify or add to an existing PICT, you need:
  876. * OpenPicture (new pic)
  877. * DrawPicture (existing pic)
  878. * (QD drawing commands)
  879. * ClosePicture (new pic)
  880. * RemoveResourse (existing pic)
  881. * AddResource
  882. You also could use ChangedResourse instead of Add/Remove, but you would
  883. have to make the existing pic the same as the new pic with something like:
  884. * SetHandleSize(0) (existing pic)
  885. * HandAndHand(new pic, existing pic)
  886. * ChangedResourse (existing pic)
  887.  
  888. +++++++++++++++++++++++++++
  889.  
  890. From scottsquir@aol.com (ScottSquir)
  891. Date: 5 Apr 1994 02:50:04 -0400
  892. Organization: America Online, Inc. (1-800-827-6364)
  893.  
  894. In article <2npicoINNq72@srvr1.engin.umich.edu>, weip@engin.umich.edu (Patrick
  895. Wei) writes:
  896.  
  897. >Should I call OpenPicture in addition to DrawPicture?
  898.  
  899. yes, you need to do an OpenPicture to start recording QuickDraw operations
  900. and then close it to create a PICT resource.  -scott
  901.  
  902.  
  903.  
  904. +++++++++++++++++++++++++++
  905.  
  906. From jwbaxter@olympus.net (John W. Baxter)
  907. Date: Mon, 04 Apr 1994 22:05:26 -0700
  908. Organization: Internet for the Olympic Peninsula
  909.  
  910. In article <A9C5D82708017D1A@cro.nrel.gov>, Carl R. Osterwald
  911. <carl_osterwald@nrel.gov> wrote:
  912.  
  913. > If you are trying to modify or add to an existing PICT, you need:
  914. > * OpenPicture (new pic)
  915. > * DrawPicture (existing pic)
  916. > * (QD drawing commands)
  917. > * ClosePicture (new pic)
  918. > * RemoveResourse (existing pic)
  919. > * AddResource
  920.  
  921.  
  922. Remembering along the way that the existing PICT resource is quite likely
  923. to be marked purgeable, so it may have gone away between being gotten
  924. (getPicture () or getResource () and the time above when you are ready to
  925. call DrawPicture () on it.  A LoadResource () to ensure that it's still
  926. around would be a nice idea.
  927. Or a variety of possibilities to keep it from being purged.
  928.  
  929. -- 
  930. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  931.    jwbaxter@pt.olympus.net
  932.  
  933. ---------------------------
  934.  
  935.  
  936. From ua025@freenet.Victoria.BC.CA (Cody Jones)
  937. Subject: Speeding up animation; questions
  938. Date: Sun, 27 Mar 1994 09:13:55 GMT
  939. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  940.  
  941.  
  942. A fair number of coders are complaining about the Mac's lack of
  943. screen-pages.  Perhaps I may suggest a technique I'm presently using.
  944. Maybe you are all already acceptably aquainted [and aggravated by my
  945. alliteration - sorry, couldn't help myself] with it, but I may as well
  946. mention it.
  947.  
  948. Divide your 8-bit palette into 2 halves.  You now have 2, 4-bit screens. 
  949. It's simple to switch screens - it's just a palette change.  You can draw
  950. directly onto the screen (using nondisplaying colors, of course) -
  951. there's no need to assemble all your images in an off-screen buffer and
  952. blit it the screen.  There's only two drawbacks: you only get 16 colors,
  953. and you need 2 copies of every sprite/background.  (Why a second copy? 
  954. Because otherwise you'd have to shift every pixel left 4 bits before
  955. drawing it onto your second page.  Slow.)
  956.  
  957. I am presently hacking away at a Doom-style engine, and using a 4-bit
  958. grayscale palette with this method looks pretty decent.  I hope that other
  959. people will also try doing decent things with this technique.
  960.  
  961. Cody Jones, Zerius Development
  962.  
  963. -- 
  964.  
  965. +++++++++++++++++++++++++++
  966.  
  967. From pburgess@netcom.com (Phillip Burgess)
  968. Date: Sun, 27 Mar 1994 22:59:16 GMT
  969. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  970.  
  971. ua025@freenet.Victoria.BC.CA (Cody Jones) writes:
  972.  
  973. >Divide your 8-bit palette into 2 halves.  You now have 2, 4-bit screens. 
  974. >It's simple to switch screens - it's just a palette change.
  975.  
  976. The thought had occurred to me... I just assumed it would be much too slow
  977. doing all that bit wrangling to draw stuff.  How un-scientific of me!  What
  978. sort of speed improvement are you getting with this technique vs. 8-bit
  979. drawing & CopyBits?
  980.  
  981. 8-D.. .   .  <- Me, drooling like an imbecile
  982.  
  983. -- 
  984.   Phillip Burgess   (pburgess@netcom.com)
  985.  
  986. +++++++++++++++++++++++++++
  987.  
  988. From ua025@freenet.Victoria.BC.CA (Cody Jones)
  989. Date: Mon, 28 Mar 1994 06:29:19 GMT
  990. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  991.  
  992.  
  993. > The thought had occurred to me... I just assumed it would be much too slow
  994. > doing all that bit wrangling to draw stuff.  How un-scientific of me!  What
  995. > sort of speed improvement are you getting with this technique vs. 8-bit
  996. > drawing & CopyBits?
  997.  
  998. Unfortunately I haven't updated my sprite routines, so I can't give you
  999. any figures (yet).  But here's some points in this method's favour:
  1000.  
  1001. Here's how I used to do masking for sprites (ie. only one screen page). 
  1002. Note this is exactly how Maelstrom's sprite code operates.  Assume we're
  1003. working with 1 pixel here, and the mask is either a 0xFF for 'solid'
  1004. pixels and 0x00 for 'transparent' pixels:
  1005.  
  1006. 1. AND the mask with the sprite
  1007. 2. NOT the mask
  1008. 3. AND the result of step 2 with the background
  1009. 4. OR the result of step 1 with the result of step 3
  1010.  
  1011. Note that steps 1 and 2 can be done just after the sprite(s) are loaded
  1012. in; there's no need to do them every time you draw a sprite.
  1013.  
  1014. OK: here's how I draw individual pixels with the 2-buffer method.  Assume
  1015. that screen one uses the low-order nybble; screen 2 uses the high-order.
  1016. For screen 1, AND 0xF0 with a pixel taken from the screen (or your pixmap,
  1017. it doesn't matter).  This clears the nybble you'll need for step 2, which
  1018. is simply an OR with your color value.
  1019. Screen 2 is very similar: AND 0x0F with your original pixel and then OR
  1020. with your color value.  Note, however, that this color value must be
  1021. shifted left 4 bits...
  1022.  
  1023. Finally, how all this ties together!  I expect you'll like the sound of
  1024. this: NO modification to the sprite code is required.  All you need are 2
  1025. copies in memory of every sprite/background (1 per screen), and some
  1026. modification to the sprite preprocessor (steps 1 and 2 as described above
  1027. regarding normal sprite drawing).
  1028.  
  1029. Imagine a mask and sprite from a normal (?) '1-screen' display:
  1030. Mask   = 0xFF00FF
  1031. Sprite = 0x010203
  1032.  
  1033. Your sprite preprocessor would, for the screen 1 (scr1) version, involve
  1034. an additional step after the first 2: every high-order nybble from every
  1035. pixel of the mask should be set to 0xF.  Thus, when masking onto scr1, the
  1036. "mask AND background" operation preserves the contents of all scr2 pixels.
  1037. The preprocessor for scr2 is almost identical: the additional step is
  1038. instead to set every low-order nybble from every mask pixel to 0xF.
  1039.  
  1040. Whew!  A fair bit of text there!  There's some big benefits involved here,
  1041. though.  I'm assuming you're drawing directly into screen memory: using
  1042. CopyBits won't work with this technique, because you have to copy a full
  1043. screen's worth every frame *anyway*, so there's no difference...
  1044. Anyway, one major stage of memory-moving is eliminated: from the completed
  1045. off-screen buffer onto the screen.  You can draw backgrounds, sprites,
  1046. text (etc) onto the undisplaying screen, and flip the palette when the
  1047. next vertical retrace occurs.
  1048. Say you're wanting a scrolling background that's 512x384 pixels big on the
  1049. screen.  That's 196,608 bytes you no longer have to copy... which will
  1050. result in a good speed increase.
  1051.  
  1052. A wise use of colors will help mask your lack of them (16-color
  1053. grayscale looks good).
  1054.  
  1055. Have fun with this one!
  1056.  
  1057. Cody Jones, Zerius Development
  1058.  
  1059. -- 
  1060.  
  1061. +++++++++++++++++++++++++++
  1062.  
  1063. From dwareing@apanix.apana.org.au (David Wareing)
  1064. Date: 16 Mar 94 11:51:28 GMT
  1065. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  1066.  
  1067. snozer@cats.ucsc.edu (Daniel Craig Jalkut) writes:
  1068.  
  1069.  
  1070. >In <dwareing.763359504@apanix.apana.org.au> dwareing@apanix.apana.org.au (David Wareing) writes:
  1071.  
  1072. >But the bottom line is that the Amiga can do everything the Mac can
  1073. >do, but the converse is not true.  The advantages you point out for 
  1074. >the Mac are all software(which is why i'm a mac user and no longer an 
  1075. >Amigan), if the software were written as well for the Amiga(including 
  1076. >the OS), then you'd have the equivalent of a Macintosh with the bonus
  1077. >of excellent graphics hardware.  And the Amiga computers were sold 
  1078. >for much less than macs in the past, so it's not infeasable cost-wise
  1079. >that the Macs have this type of hardware for graphics. 
  1080.  
  1081. I don't want this to become yet another brandX vs mac flamewar, but there
  1082. are many reasons why amigas have been sold for much less than macs in the
  1083. past. Amiga equipment, in general (and I'm not talking about their custom
  1084. chipsets), is piss-poor. Everything from the floppy drive (screech screech
  1085. kerklunk) to the keyboards were of a quality that made the machines look
  1086. even more like toys. You had a gui that sucked rocks. Period. You had a
  1087. system where the only way to play the majority of games, was to turn the
  1088. thing off or vulcan-nerve-pinch it, shove the disk in, and turn it on
  1089. again. You had non-existant developer support from Commodore. Commodore
  1090. themselves actively promoted their machines as "entertainment" platforms
  1091. (i.e. games machines). Until not all that long ago, a look inside an amiga
  1092. 'starter kit' would show you a handful of floppies, most of which were
  1093. games, and a few lame word-processors such as KindWords.
  1094.  
  1095. In contrast, apple equipment has been expensive, but of generally high
  1096. quality. You can't compare the Sony Trinitrons to the Philips monitors
  1097. such as Commodore's 1084 etc. You also can't compare the price.  In
  1098. comparison to the amiga, the mac is an extremely well thought out design,
  1099. and extremely well supported by both manufacturer and third parties. In
  1100. the amiga's case, the only support is from its huge third party hardware
  1101. manufacturer base and developers (most of whom appear to be of the hacker
  1102. variety).
  1103.  
  1104. That's part of the reason why the prices are much different. Which would
  1105. you prefer? A custom blitting chipset, or monitors you could actually read
  1106. word-processing text from, and an overall architecture that is consistent
  1107. and of high quality?
  1108.  
  1109. --
  1110. David Wareing
  1111. Adelaide, South Australia
  1112. dwareing@apanix.apana.org.au
  1113.  
  1114.  
  1115. +++++++++++++++++++++++++++
  1116.  
  1117. From jmunkki@beta.hut.fi (Juri Munkki)
  1118. Date: 28 Mar 1994 19:35:12 GMT
  1119. Organization: Helsinki University of Technology
  1120.  
  1121. In article <CnBGB7.KvC@suncad.camosun.bc.ca> ua025@freenet.Victoria.BC.CA (Cody Jones) writes:
  1122. >Divide your 8-bit palette into 2 halves.  You now have 2, 4-bit screens. 
  1123. >It's simple to switch screens - it's just a palette change.  You can draw
  1124. >directly onto the screen (using nondisplaying colors, of course) -
  1125. >there's no need to assemble all your images in an off-screen buffer and
  1126. >blit it the screen.  There's only two drawbacks: you only get 16 colors,
  1127. >and you need 2 copies of every sprite/background.  (Why a second copy? 
  1128. >Because otherwise you'd have to shift every pixel left 4 bits before
  1129. >drawing it onto your second page.  Slow.)
  1130.  
  1131. Arashi (STORM) splits an 8 bit pixel into four parts: two 3 bit (7 colors+
  1132. transparency) buffers (double-buffered) and two 1 bit buffers for background
  1133. graphics. Including the background color, this gives you 10 colors to work
  1134. with.
  1135.  
  1136. Since everything is done with vector graphics, this doesn't create as much
  1137. of a performance problem as with sprites (where you would have to do at
  1138. least twice the work). The Arashi animation toolkit is available with
  1139. anonymous ftp from ics.uci.edu (pub/mac/think-c/apps or something like that).
  1140.  
  1141. There's a big catch, however...and I didn't discover it than until when the
  1142. game was pretty well along: video cards behave differently on palette changes.
  1143. Some cards wait for the next vertical blanking to switch palettes and some
  1144. cards do it immediately. Method #1 wastes time and method #2 produces
  1145. partial frames where the bottom and top do not match. With some cards,
  1146. calling the palette change from within the vertical blanking routine will
  1147. wait until the next vertical blank (stupid, stupid) and on some cards it
  1148. will simply not work at all... The video card driver specifications give
  1149. some guidelines, but it seems people are not following all those guidelines.
  1150.  
  1151. So...in my current animation kit I'm doing something totally different.
  1152. I'm not using Quickdraw, it's fast, supports 2, 4, 16, 256, 32768 and
  1153. millions of colors (with a maximum of 32768 colors), multiple screens
  1154. (the animation can be split on several screen of different depth and
  1155. different color maps) and it's completely flicker-free. (Partial frames
  1156. do occur, but it doesn't seem too bothersome and it would be pretty hard
  1157. to avoid on a system with 8 monitors, for instance.)
  1158.  
  1159. Animation timing is done with the time manager, so you can set your
  1160. frame rate to anything you want. I should have some kind of demo game
  1161. out for WWDC (May) and I will convert this software to PowerPC once
  1162. CodeWarrior ships with an inline assembler (it runs quite well under
  1163. emulation though).
  1164.  
  1165. Oh, and the class library I built on the basic animation engine supports
  1166. unrestricted scaling and rotation and warping with 2x3 matrices and it
  1167. now also supports very fast collision detection in a user coordinate system
  1168. (doesn't depend on screen resolution).
  1169.  
  1170. Finally, the animation engine is not available to developers, unless you
  1171. can be very, very convincing ($$$).
  1172.  
  1173. The first game will be something simple and will probably not show all the
  1174. neat things that can be done with the animation kit. I just want something
  1175. out there to show the world that I'm still alive and working on software...
  1176.  
  1177. -- 
  1178.   Juri Munkki            There ain't so such thing as a shareware lunch.
  1179.  jmunkki@hut.fi                Windsurfing: Faster than the wind.
  1180.  
  1181. +++++++++++++++++++++++++++
  1182.  
  1183. From ua025@freenet.Victoria.BC.CA (Cody Jones)
  1184. Date: Tue, 29 Mar 1994 04:10:19 GMT
  1185. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  1186.  
  1187.  
  1188. > There's a big catch, however...and I didn't discover it than until when the
  1189. > game was pretty well along: video cards behave differently on palette
  1190. > changes.  Some cards wait for the next vertical blanking to switch palettes
  1191. > and some cards do it immediately. Method #1 wastes time and method #2
  1192. > produces partial frames where the bottom and top do not match. With some
  1193. > cards, calling the palette change from within the vertical blanking routine
  1194. > will wait until the next vertical blank (stupid, stupid) and on some
  1195. > cards it will simply not work at all... The video card driver
  1196. > specifications give some guidelines, but it seems people are not following
  1197. > all those guidelines.
  1198.  
  1199. What!!  I thought that SetEntries (that's the lowest-level I could get for
  1200. palette stuff :) always waited for a vertical retrace before doing its
  1201. palette-change.  I believe I read this in an Apple document.  Are you
  1202. saying that it's really up to the card, not SetEntries?  That would mean
  1203. Apple wants this to be a standard and so goes around saying to high-level
  1204. programmers that SetEntries does the work (when that's just a fabrication).
  1205.  
  1206. If this is true... well, I'm not about to give up on a decent technique. 
  1207. The people with the wrong type of video card can play someone else's game
  1208. instead...
  1209.  
  1210. Cody Jones, Zerius Development
  1211. -- 
  1212.  
  1213. +++++++++++++++++++++++++++
  1214.  
  1215. From dwareing@apanix.apana.org.au (David Wareing)
  1216. Date: 22 Mar 94 13:46:07 GMT
  1217. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  1218.  
  1219. rhn@netcom.com (Ron Nicholson) writes:
  1220.  
  1221. >One idea used the in Apple II days for fast graphics animation, that I
  1222. >haven't seen mentioned, is pre-shifted sprites.  Since copybits runs
  1223. >fastest when the source and distination are 32 bit aligned (64 bit for
  1224. >PowerPC), having 4 or 8 pre-aligned sprite pixmaps, would mean copybits
  1225. >would never waste any time shifting.  Has anyone experimented with
  1226. >this?
  1227.  
  1228. An easier way to do this is to create your aligned pixmaps with a call to
  1229. NewGWorld. Give it a depth of 0. This supposedly creates a pixmap that is
  1230. aligned to the screen. And yes, it is certainly worth your while. You can
  1231. get *very* nice speed increases with aligned pixmaps.
  1232.  
  1233. Repeat the following mantra until a state similar to coma is reached:
  1234.  
  1235. "GWorlds are my friends. GWorlds are my friends. GWorlds are my friends."
  1236.  
  1237. --
  1238. David Wareing
  1239. Adelaide, South Australia
  1240. Mac Games & Multimedia Programming        dwareing@apanix.apana.org.au
  1241. - --------------------------------------------------------------------
  1242.  
  1243. +++++++++++++++++++++++++++
  1244.  
  1245. From jmunkki@beta.hut.fi (Juri Munkki)
  1246. Date: 29 Mar 1994 15:59:35 GMT
  1247. Organization: Helsinki University of Technology
  1248.  
  1249. In article <CnErL8.Ax6@suncad.camosun.bc.ca> ua025@freenet.Victoria.BC.CA (Cody Jones) writes:
  1250. >What!!  I thought that SetEntries (that's the lowest-level I could get for
  1251. >palette stuff :) always waited for a vertical retrace before doing its
  1252. >palette-change.  I believe I read this in an Apple document.  Are you
  1253. >saying that it's really up to the card, not SetEntries?  That would mean
  1254. >Apple wants this to be a standard and so goes around saying to high-level
  1255. >programmers that SetEntries does the work (when that's just a fabrication).
  1256.  
  1257. Apple's video drivers wait for the next refresh, but I have seen at least
  1258. one third party card that didn't wait for them. That was quite a few years
  1259. ago, so they might not be sold anymore.
  1260.  
  1261. Unless you use very careful timing, you'll waste up to one full frame
  1262. of CPU time by doing SetEntries-type buffer switching on most cards.
  1263.  
  1264. It's also limited to one video card because of this problem.
  1265. -- 
  1266.   Juri Munkki            There ain't so such thing as a shareware lunch.
  1267.  jmunkki@hut.fi                Windsurfing: Faster than the wind.
  1268.  
  1269. +++++++++++++++++++++++++++
  1270.  
  1271. From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  1272. Date: 29 Mar 1994 21:11:24 GMT
  1273. Organization: University of Iceland
  1274.  
  1275. In <2n9j97$6e@nntp.hut.fi> jmunkki@beta.hut.fi (Juri Munkki) writes:
  1276.  
  1277. >In article <CnErL8.Ax6@suncad.camosun.bc.ca> ua025@freenet.Victoria.BC.CA (Cody Jones) writes:
  1278. >>What!!  I thought that SetEntries (that's the lowest-level I could get for
  1279. >>palette stuff :) always waited for a vertical retrace before doing its
  1280. >>palette-change.  I believe I read this in an Apple document.  Are you
  1281. >>saying that it's really up to the card, not SetEntries?  That would mean
  1282. >>Apple wants this to be a standard and so goes around saying to high-level
  1283. >>programmers that SetEntries does the work (when that's just a fabrication).
  1284.  
  1285.   I believe that SetEntries is just a wrapper for a control call to the
  1286. driver, it is (naturally) the driver's work to actually set the hardware
  1287. CLUT, and to wait for the blanking interval (if it is requested to do so,
  1288. see below) since for both tasks you need to talk to the hardware.
  1289.  
  1290. >Apple's video drivers wait for the next refresh, but I have seen at least
  1291. >one third party card that didn't wait for them. That was quite a few years
  1292. >ago, so they might not be sold anymore.
  1293.  
  1294. [snip]
  1295.  
  1296.   According to C&D, the drivers are supposed to do this only if they're
  1297. called at interrupt level 0, if the interrupt level has been raised
  1298. (this is from memory, there might be a specific level required -
  1299. possibly 2) the driver should not wait for blanking (talk about weird
  1300. calling conventions, passing parameters in SR! :-).
  1301. -- 
  1302. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  1303. Kambasel 26            | for instance declares f as an array of unspecified 
  1304. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  1305. sigurasg@rhi.hi.is     | functions that return void... I think"
  1306.  
  1307. +++++++++++++++++++++++++++
  1308.  
  1309. From ua025@freenet.Victoria.BC.CA (Cody Jones)
  1310. Date: Wed, 30 Mar 1994 00:52:51 GMT
  1311. Organization: The Victoria Freenet Association (VIFA), Victoria, B.C., Canada
  1312.  
  1313.  
  1314. > Unless you use very careful timing, you'll waste up to one full frame
  1315. > of CPU time by doing SetEntries-type buffer switching on most cards.
  1316.  
  1317. Why?  Here's how I see it:  after doing all your drawing to the
  1318. non-displayed screen, you call SetEntries to swap the screens.  Yes, the
  1319. CPU does wait for a VR and thus waste some time between frames, but what
  1320. else can your program do with that time?  If your drawing code takes less
  1321. than 1 refresh cycle, your graphics will keep up with the retrace.  If it
  1322. takes just over 1 cycle, then your FPS rate will drop by 2x - but that's
  1323. unavoidable.
  1324.  
  1325. Cody Jones, Zerius Development
  1326.  
  1327. -- 
  1328.  
  1329. +++++++++++++++++++++++++++
  1330.  
  1331. From jmunkki@beta.hut.fi (Juri Munkki)
  1332. Date: 30 Mar 1994 15:36:54 GMT
  1333. Organization: Helsinki University of Technology
  1334.  
  1335. In article <2na5hs$5fp@eldborg.rhi.hi.is> sigurasg@rhi.hi.is (Sigurdur Asgeirsson) writes:
  1336. >  I believe that SetEntries is just a wrapper for a control call to the
  1337. >driver, it is (naturally) the driver's work to actually set the hardware
  1338. >CLUT, and to wait for the blanking interval (if it is requested to do so,
  1339. >see below) since for both tasks you need to talk to the hardware.
  1340.  
  1341. The driver waits for the VBL. SetEntries also seems to invalidate the ctSeed
  1342. for the gDevice, so calling GetNextEvent or WaitNextEvent can cause a lot of
  1343. extra processing to happen when Finder tries to figure out what happened.
  1344.  
  1345. Because of this, Arashi calls the driver directly.
  1346.  
  1347. >  According to C&D, the drivers are supposed to do this only if they're
  1348. >called at interrupt level 0, if the interrupt level has been raised
  1349. >(this is from memory, there might be a specific level required -
  1350. >possibly 2) the driver should not wait for blanking (talk about weird
  1351. >calling conventions, passing parameters in SR! :-).
  1352.  
  1353. Either I missed this or this is a new spec. Designing Cards & Drivers has
  1354. been updated several times and I wrote the Arashi animation code years ago.
  1355.  
  1356. I tried making the call from the vertical blanking interrupt (what's the
  1357. interrupt level for those?), from a time manager task (very unreliable)
  1358. and from the program itself.
  1359.  
  1360. -- 
  1361.   Juri Munkki            There ain't so such thing as a shareware lunch.
  1362.  jmunkki@hut.fi                Windsurfing: Faster than the wind.
  1363.  
  1364. +++++++++++++++++++++++++++
  1365.  
  1366. From Bruce_Burkhalter@inetlink.berksys.com (Bruce Burkhalter)
  1367. Date: 30 Mar 1994 17:46:17 GMT
  1368. Organization: Berkeley Systems
  1369.  
  1370. In article <2nc6am$gui@nntp.hut.fi>, jmunkki@beta.hut.fi (Juri Munkki)
  1371. wrote:
  1372.  
  1373. > In article <2na5hs$5fp@eldborg.rhi.hi.is> sigurasg@rhi.hi.is (Sigurdur Asgeirsson) writes:
  1374. > >  I believe that SetEntries is just a wrapper for a control call to the
  1375. > >driver, it is (naturally) the driver's work to actually set the hardware
  1376. > >CLUT, and to wait for the blanking interval (if it is requested to do so,
  1377. > >see below) since for both tasks you need to talk to the hardware.
  1378. > The driver waits for the VBL. SetEntries also seems to invalidate the ctSeed
  1379. > for the gDevice, so calling GetNextEvent or WaitNextEvent can cause a lot of
  1380. > extra processing to happen when Finder tries to figure out what happened.
  1381. > Because of this, Arashi calls the driver directly.
  1382.  
  1383. A couple After Dark modules do this as well.  Making the Control() call is
  1384. a lot faster than SetEntries().  A neat trick you can do if you want to
  1385. cycle the table continously is to make a copy of the table immediately
  1386. following the it.  To cycle through the colors, you just increment your ptr
  1387. and reset it to the top when you get to 255.
  1388.  
  1389. -- 
  1390. Bruce Burkhalter
  1391. Bruce_Burkhalter@inetlink.berksys.com
  1392. All opinions are mine.
  1393. Berkeley Systems Inc.
  1394.  
  1395. +++++++++++++++++++++++++++
  1396.  
  1397. From jmunkki@beta.hut.fi (Juri Munkki)
  1398. Date: 30 Mar 1994 22:11:36 GMT
  1399. Organization: Helsinki University of Technology
  1400.  
  1401. In article <CnGD44.361@suncad.camosun.bc.ca> ua025@freenet.Victoria.BC.CA (Cody Jones) writes:
  1402. >> Unless you use very careful timing, you'll waste up to one full frame
  1403. >> of CPU time by doing SetEntries-type buffer switching on most cards.
  1404. >
  1405. >Why?  Here's how I see it:  after doing all your drawing to the
  1406. >non-displayed screen, you call SetEntries to swap the screens.  Yes, the
  1407. >CPU does wait for a VR and thus waste some time between frames, but what
  1408. >else can your program do with that time?  If your drawing code takes less
  1409. >than 1 refresh cycle, your graphics will keep up with the retrace.  If it
  1410. >takes just over 1 cycle, then your FPS rate will drop by 2x - but that's
  1411. >unavoidable.
  1412.  
  1413. You could start calculating stuff for the next frame.
  1414.  
  1415. The way Arashi works is that it sets a game rate goal of 20 steps per
  1416. second. On most monitors, this isn't an even multiple of the vertical
  1417. blanking rate. Depending on what is happening in the game and depending
  1418. what the game is running on, it may not be possible to display 20 frames
  1419. per second. If this happens (as it often happens on the Color Classic and
  1420. other slow machines), no drawing is done even though the game keeps running.
  1421. This temporarily drops the frame rate to 10 fps or even lower.
  1422.  
  1423. What I'm trying to say is that there's no way to tell how long it is going
  1424. to take to process one game step or wether that game step is going to draw
  1425. at all. In the future, I might want to write a game that runs at 100 fps
  1426. or more internally and draw as often as possible. In this case, any waiting
  1427. in an interrupt routine will be time wasted and will increase the probability
  1428. that frames will have to be "skipped".
  1429.  
  1430. Running at a fast enough internal rate sometimes makes hit and collision
  1431. testing easier without being too costly otherwise.
  1432.  
  1433. And, as I said in another posting, having to wait for one card makes it
  1434. very hard to use this method on two or more cards.
  1435.  
  1436. Another thing where at least two buffers are useful is displaying objects
  1437. in stereo 3D for LC shutter glasses. (You need four buffers for double-
  1438. buffering stereo 3D.) In the four buffer case you will be drawing into
  1439. two of the buffers and flipping between the other two. Any time wasted
  1440. is away from the time that you have available for drawing the next frame.
  1441. In stereo 3D applications, anything below the true vertical blanking rate
  1442. of the monitor is too slow.
  1443.  
  1444. Fortunately, I think that machines are now getting fast enough so that
  1445. these things can be more flexibly done with software solutions. This is
  1446. better for the user, because it does not limit the amount of colors (you
  1447. can do it in 15 or 24 bit color if you want) and you do not force the
  1448. user to a certain bit depth.
  1449.  
  1450. -- 
  1451.   Juri Munkki            There ain't so such thing as a shareware lunch.
  1452.  jmunkki@hut.fi                Windsurfing: Faster than the wind.
  1453.  
  1454. +++++++++++++++++++++++++++
  1455.  
  1456. From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  1457. Date: 31 Mar 1994 13:22:12 GMT
  1458. Organization: University of Iceland
  1459.  
  1460. In <2nc6am$gui@nntp.hut.fi> jmunkki@beta.hut.fi (Juri Munkki) writes:
  1461.  
  1462. >In article <2na5hs$5fp@eldborg.rhi.hi.is> sigurasg@rhi.hi.is (Sigurdur Asgeirsson) writes:
  1463. [snip]
  1464. >>  According to C&D, the drivers are supposed to do this only if they're
  1465. >>called at interrupt level 0, if the interrupt level has been raised
  1466. >>(this is from memory, there might be a specific level required -
  1467. >>possibly 2) the driver should not wait for blanking (talk about weird
  1468. >>calling conventions, passing parameters in SR! :-).
  1469.  
  1470. >Either I missed this or this is a new spec. Designing Cards & Drivers has
  1471. >been updated several times and I wrote the Arashi animation code years ago.
  1472.  
  1473.   In my copy of C&D second edition, on page 185 (in the description of
  1474. the SetEntries routine in the DRVR code example) there is the following
  1475. text:
  1476.  
  1477.   2) If SetEntries is entered while the interrupt level is non-zero,
  1478.      it should write immediately to the CLUT hardware.
  1479.  
  1480.   However, this is in reference to an optional feature of the driver,
  1481. that of doing CLUT updates asyncronously, so drivers aren't required to
  1482. do this.
  1483.  
  1484. -- 
  1485. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  1486. Kambasel 26            | for instance declares f as an array of unspecified 
  1487. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  1488. sigurasg@rhi.hi.is     | functions that return void... I think"
  1489.  
  1490. +++++++++++++++++++++++++++
  1491.  
  1492. From jmunkki@beta.hut.fi (Juri Munkki)
  1493. Date: 31 Mar 1994 20:40:29 GMT
  1494. Organization: Helsinki University of Technology
  1495.  
  1496. In article <2neiq4$rth@eldborg.rhi.hi.is> sigurasg@rhi.hi.is (Sigurdur Asgeirsson) writes:
  1497. >  In my copy of C&D second edition, on page 185 (in the description of
  1498. >the SetEntries routine in the DRVR code example) there is the following
  1499. >text:
  1500. >
  1501. >  2) If SetEntries is entered while the interrupt level is non-zero,
  1502. >     it should write immediately to the CLUT hardware.
  1503. >
  1504. >  However, this is in reference to an optional feature of the driver,
  1505. >that of doing CLUT updates asyncronously, so drivers aren't required to
  1506. >do this.
  1507.  
  1508. Now I remember it. I tried and it and found it very unreliable. Apple's
  1509. drivers tended to wait for the next VB period no matter how I called them.
  1510. (I think I was using a TOBY 8 bit card on a Mac II... at least that card
  1511. supported multiple pages. My Quadra 700 doesn't have support for more than
  1512. one video page.)
  1513.  
  1514. -- 
  1515.   Juri Munkki            There ain't so such thing as a shareware lunch.
  1516.  jmunkki@hut.fi                Windsurfing: Faster than the wind.
  1517.  
  1518. ---------------------------
  1519.  
  1520. From jhiggins@mathworks.com (John M. Higgins)
  1521. Subject: Tools to improve segmentation?
  1522. Date: 24 Mar 1994 21:13:33 GMT
  1523. Organization: The MathWorks, Inc.
  1524.  
  1525. Are there any tools which help optimize CODE segmentation by monitoring
  1526. frequency of intersegment calls and segment use?
  1527.  
  1528. -- 
  1529. John M. Higgins
  1530. The MathWorks, Inc.
  1531. jhiggins@mathworks.com
  1532.  
  1533. +++++++++++++++++++++++++++
  1534.  
  1535. From ari@world.std.com (Ari I Halberstadt)
  1536. Date: Mon, 4 Apr 1994 04:20:07 GMT
  1537. Organization: The World Public Access UNIX, Brookline, MA
  1538.  
  1539. In article <jhiggins-240394161555@144.212.1.91>,
  1540. John M. Higgins <jhiggins@mathworks.com> wrote:
  1541. >Are there any tools which help optimize CODE segmentation by monitoring
  1542. >frequency of intersegment calls and segment use?
  1543.  
  1544. Efficient segmentation of applications has troubled me since my first
  1545. multisegment Macintosh application. Unfortunately, due to the lack of
  1546. tools to automatically segment applications, the only practical
  1547. solution I've found has been to effectively ignore the problem.
  1548. Fortunately, this is finally a reasonably viable approach, as the
  1549. PowerPC no longer uses segmented applications.
  1550.  
  1551. That said, this is what I've managed to do with my messing around in
  1552. the Segment Loader.
  1553.  
  1554. You can arrange to have inactive segments unloaded automatically. An
  1555. inactive segment is a segment that does not contain the program
  1556. counter and which is not pointed to by a return address on the stack.
  1557. To unload inactive segments, you need to walk the stack to access all
  1558. of the return addresses that are pointed to by register a6. You can
  1559. then search for the segments containing the return addresses from
  1560. among all segments that are in memory. All segments found to contain a
  1561. return address are deemed active and are not unloaded. All other
  1562. segments can be unloaded with UnloadSeg. There are some complications
  1563. to this scheme that can arise if you attempt to unload segments from a
  1564. routine called by the OS or if you are using a multi-threaded
  1565. application. You also must know the format of the jump table produced
  1566. by your compiler. This is somewhat similar to what Windows does to
  1567. manage program segments, though Windows goes a step further and can
  1568. unload active segments as well as inactive segments. I have
  1569. implemented the above algorithm in Winter Shell, though support for
  1570. multiple threads is not present yet in the current released version.
  1571.  
  1572. You can use a program to generate a function call tree for your
  1573. application. For instance, you can use the "cflow" program on a Unix
  1574. system to generate a function call tree. Cflow supports two forms of
  1575. function call trees. The default format shows the function call
  1576. sequence, while a reversed format lists all functions that call a
  1577. function. I have found the reversed format to be most useful.
  1578. Unfortunately, the version of cflow that I have used omits many
  1579. functions from its listings. To process Macintosh source code also
  1580. requires uploading the code to a Unix machine (assuming you don't have
  1581. A/UX). Since cflow doesn't have access to all of the Macintosh header
  1582. files, it tends to produce volumes of error messages (5 megs for 1 meg
  1583. of source code) that should be redirected to /dev/null. Once you have
  1584. a function call tree, you can get some idea of how functions might
  1585. most efficiently be segmented.
  1586.  
  1587. To gather segment usage statistics, you can use the compiler's
  1588. profiler. In THINK C, you can modify the profiler to gather
  1589. information about the segment containing the profiled functions. Even
  1590. if you can't modify your compiler's profiler, you could generate a
  1591. link map for your application and use a script to correlate the link
  1592. map with the profiler's output. You could also patch the _LoadSeg trap
  1593. and gather statistics when it is executed, but you will need to unload
  1594. the application's segments for it to be called with any regularity.
  1595.  
  1596. I have tried segmenting a large program (again, Winter Shell) into
  1597. many small segments with only one file per segment. This turned out to
  1598. be a poor method to segment applications. In the current development
  1599. version of Winter Shell I have simply segmented the application in a
  1600. manner that is most convenient and logical for me, the programmer.
  1601. With the new segmentation scheme, Winter Shell doesn't require much
  1602. more memory than it did with the former method. Furthermore, the
  1603. application spends less time loading and unloading segments.
  1604.  
  1605. Today, most applications can assume that all of their code can be
  1606. loaded into memory (or virtual memory). This assumption greatly
  1607. simplifies segmentation, since you effectively don't have to worry
  1608. about it. In the extreme case, you could just use far-code and one
  1609. huge segment and forget about the whole issue. I used this extremely
  1610. lazy approach to port a large 600K Unix application to the Macintosh.
  1611. If you expect your application will run in a memory partition that
  1612. will not allow all of its code to be resident, then you will obviously
  1613. need to work out a good segmentation strategy. If your application's
  1614. memory usage peaks while performing certain operations, then you could
  1615. optimize the segmentation towards those peak operations. For instance,
  1616. when printing, you could unload most of your application's code.
  1617.  
  1618. The automatic segment unloading code that I mentioned above is in the
  1619. file "SegmentLib.c" in Winter Shell. Winter Shell is a free
  1620. application framework written in C. You can retrieve Winter Shell
  1621. 1.0d2 by ftp'ing any of the following files:
  1622.  
  1623.   sumex-aim.stanford.edu:/info-mac/dev/src/winter-shell-10d2-c.hqx
  1624.   mac.archive.umich.edu:/mac/development/source/wintershell1.0d2.sit.hqx
  1625.  
  1626. umich also has three mirrors that are updated daily:
  1627.  
  1628.        "wuarchive.wustl.edu" in the directory "mirrors/archive.umich.edu",
  1629.                                         (apple2,mac,atari,msdos,next)
  1630.        "src.doc.ic.ac.uk"    in the directory  "packages/mac/umich",
  1631.   and  "archie.au"           in the directory  "micros/mac/umich".
  1632.  
  1633. there are additional mirrors of info-mac in Europe, among them
  1634.  
  1635.   nic.switch.ch (Switzerland)
  1636.   metten.fenk.wau.nl (The Netherlands)
  1637.   swdsrv.edvz.univie.ac.at (Austria)
  1638.  
  1639. Several people have mentioned the lack of documentation for Winter
  1640. Shell. I'm working on an update to Winter Shell that will include at
  1641. least some automatically extracted documentation that will provide
  1642. minimal comments for all of the functions in Winter Shell. The update
  1643. will also add a better event handling mechanism. I will probably also
  1644. add a "ws_" prefix to all externally defined functions and symbols to
  1645. prevent symbol name conflicts. No promises on when it will be
  1646. available though.
  1647. -- 
  1648. Ari Halberstadt    ari@world.std.com     #include <std/disclaimer.h>
  1649. "These beetles were long considered to be very rare because very few
  1650. entomologists look for beetles in the mountains, in winter, at night,
  1651. during snow storms." -- Purves W. K., et al, "Life: The Science of
  1652.  
  1653. ---------------------------
  1654.  
  1655. From dsf5454@ritvax.isc.rit.edu
  1656. Subject: copy file question, code available?
  1657. Date: Wed, 30 Mar 1994 18:42:23 GMT
  1658. Organization: Rochester Institute of Technology
  1659.  
  1660. Hello...
  1661.     I'm curious if there are any routines available to copy a file to a
  1662. different subdirectory..? I'm certainly interested in finding out as I have a
  1663. need for such a beast... even the pseudocode or tips on how to do one would
  1664. help.. thanks! Much appreciated.
  1665.  
  1666. -Dan Foster
  1667. Internet:    dsf5454@ritvax.isc.rit.edu
  1668. BITNET/CREN:    dsf5454@ritvax.BITNET
  1669.  
  1670.  
  1671. +++++++++++++++++++++++++++
  1672.  
  1673. From jumplong@aol.com (Jump Long)
  1674. Date: 30 Mar 1994 21:48:02 -0500
  1675. Organization: America Online, Inc. (1-800-827-6364)
  1676.  
  1677. In article <1994Mar30.184223.9555@ultb.isc.rit.edu>, dsf5454@ritvax.isc.rit.edu
  1678. writes:
  1679.  
  1680. > I'm curious if there are any routines available to copy a file to a
  1681. > different subdirectory..? I'm certainly interested in finding out as I have a
  1682. > need for such a beast... even the pseudocode or tips on how to do one would
  1683. > help.. thanks! Much appreciated.
  1684.  
  1685. Dan, look at the MoreFiles sample code from Apple DTS. It available on the last
  1686. few Developer CDs and at Apple's FTP site.
  1687.  
  1688. - Jim Luther
  1689.  
  1690.  
  1691. +++++++++++++++++++++++++++
  1692.  
  1693. From kenlong@netcom.com (Ken Long)
  1694. Date: Thu, 31 Mar 1994 18:06:12 GMT
  1695. Organization: NETCOM On-line Communication Services (408 241-9760 guest)
  1696.  
  1697. Also, there's a demo of that beast, complete with tooth and claw, in the 
  1698. "Other K&R's" Mac Prog Secrets source.
  1699.  
  1700. -Ken-
  1701.  
  1702. +++++++++++++++++++++++++++
  1703.  
  1704. From rollin@newton.apple.com (Keith Rollin)
  1705. Date: Fri, 1 Apr 1994 00:37:51 GMT
  1706. Organization: Little to none
  1707.  
  1708. In article <kenlongCnJJMC.J7u@netcom.com>, kenlong@netcom.com (Ken Long)
  1709. wrote:
  1710.  
  1711. > Also, there's a demo of that beast, complete with tooth and claw, in the 
  1712. > "Other K&R's" Mac Prog Secrets source.
  1713.  
  1714. I can't remember if this was mentioned in an earlier part of the thread,
  1715. but Jim Luther of Mac DTS has released a package called MoreFiles (now in
  1716. version 1.1.1). This package has a lot of File Manager utilities (such as
  1717. pre-7.0 glue for the FSSpec routines). One of the utilities is a file copy
  1718. routine that does everything the exact right way. I haven't poured over the
  1719. code yet to see how it works, but I know this guy, and he does good work.
  1720. I'd trust his version over mine (for instance, his version works with
  1721. AppleShare drop boxes, and mine doesn't).
  1722.  
  1723. The package can be found on ftp.apple.com in /dts/mac/sc.
  1724.  
  1725. - --------------------------------------------------------------------------
  1726. Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team
  1727. Newton
  1728.  
  1729. +++++++++++++++++++++++++++
  1730.  
  1731. From jumplong@aol.com (Jump Long)
  1732. Date: 3 Apr 1994 14:02:02 -0400
  1733. Organization: America Online, Inc. (1-800-827-6364)
  1734.  
  1735. In article <rollin-310394163751@rollin-keith.apple.com>,
  1736. rollin@newton.apple.com (Keith Rollin) writes:
  1737.  
  1738. > I haven't poured over the  yet to see how it works, but I know this guy,
  1739. > and he does good work.
  1740.  
  1741. It works and I've only made one minor change to it lately. The next version of
  1742. FileCopy won't attempt to copy empty forks (that makes it work better with
  1743. foreign file systems that don't support multiple forks natively).
  1744.  
  1745. - Jim Luther
  1746.  
  1747.  
  1748. ---------------------------
  1749.  
  1750. From guapo@news.cs.columbia.edu (J. Robert Diana)
  1751. Subject: skeleton code generators?
  1752. Date: 28 Mar 1994 08:42:40 -0500
  1753. Organization: Columbia University Department of Computer Science
  1754.  
  1755.  
  1756. Are there any free/shareware code generators for C?  I do not need to see full
  1757. prgrams, just some things like what one would do to make Mac specific stuff.
  1758. I have found that trying to study a fully implemented program is quite a 
  1759. hassle.
  1760. Any info is greatly appreciated.
  1761. Thanks in advance.
  1762.  
  1763. Rob Diana
  1764. guapo@cs.columbia.edu
  1765.  
  1766. +++++++++++++++++++++++++++
  1767.  
  1768. From chuck@gte.com (Chuck Hoffman)
  1769. Date: Fri, 1 Apr 1994 16:37:21 GMT
  1770. Organization: GTE Laboratories
  1771.  
  1772. In article <2n6msg$b2d@ground.cs.columbia.edu>, guapo@news.cs.columbia.edu
  1773. (J. Robert Diana) wrote:
  1774.  
  1775. > Are there any free/shareware code generators for C?  I do not need to see full
  1776. > prgrams, just some things like what one would do to make Mac specific stuff.
  1777. > I have found that trying to study a fully implemented program is quite a 
  1778. > hassle.
  1779. > Any info is greatly appreciated.
  1780. > Thanks in advance.
  1781.  
  1782. Chassis 6.0 is not a code generator.  It is a basic application framework
  1783. which you might find useful anyway.  It is not as confusing to look at as a
  1784. fully developed application, and there is a program flow-chart provided
  1785. with the code.
  1786.  
  1787. I am working on Chassis 6.1 right now, which will be AppleEvent aware.
  1788.  
  1789. Chassis 6.0 compiles with either THINK C 6 or 5.  6.1 will compile only
  1790. with THINK C 6.
  1791.  
  1792. Don't use the version of Chassis at sumex-aim.stanford.edu.  They have an
  1793. old version which is not 32-bit clean.  They never posted the new version.
  1794.  
  1795. Chassis is in the following anonymous ftp locations:
  1796.  
  1797. ftp.gte.com:
  1798. /pub/chuck/Chassis_6.0.sea.hqx
  1799.  
  1800. mac.archive.umich.edu:
  1801. /mac/development/source/chassis6.0.cpt.hqx
  1802.  
  1803. -- 
  1804. Chuck Hoffman
  1805. GTE Laboratories, Waltham, MA, USA
  1806. 617-466-2131
  1807. - ------------------------------------------------
  1808. I'm not sure why we're here, but I am sure that
  1809. while we're here we're supposed to help each other.
  1810. - ------------------------------------------------
  1811.  
  1812. +++++++++++++++++++++++++++
  1813.  
  1814. From jumplong@aol.com (Jump Long)
  1815. Date: 3 Apr 1994 13:51:02 -0400
  1816. Organization: America Online, Inc. (1-800-827-6364)
  1817.  
  1818. In article <2n6msg$b2d@ground.cs.columbia.edu>, guapo@news.cs.columbia.edu (J.
  1819. Robert Diana) writes:
  1820.  
  1821. > Are there any free/shareware code generators for C?
  1822.  
  1823. You might want to get a copy of AppsToGo, a shell from Apple Developer
  1824. Technical Support. There are a couple of sample applications built with
  1825. AppsToGo that you can look at, too (DTS Draw and Kibitz). Available on Apple's
  1826. Developer CD and FTP site.
  1827.  
  1828. - Jim Luther
  1829.  
  1830. ---------------------------
  1831.  
  1832. End of C.S.M.P. Digest
  1833. **********************
  1834.  
  1835.