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

  1. C.S.M.P. Digest             Tue, 03 Nov 92       Volume 1 : Issue 207
  2.  
  3. Today's Topics:
  4.  
  5.     Using ReadXPRam and WriteXPRam traps
  6.     putting the mouse in a cage?
  7.     Q: How to tell the depth of screen?
  8.     If I have the old, do I need to buy the new Inside Mac?
  9.     Gestalt Return Value for 24-bit addressing?
  10.     Writing dcmds in MPW
  11.     HOpen confusion
  12.     Quickdraw region implementation
  13.     Questions relating to direct-to-screen drawing
  14.  
  15.  
  16.  
  17. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  18.  
  19. The digest is a collection of article threads from the internet newsgroup
  20. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  21. regularly and want an archive of the discussions.  If you don't know what a
  22. newsgroup is, you probably don't have access to it.  Ask your systems
  23. administrator(s) for details.  (This means you can't post questions to the
  24. digest.)
  25.  
  26. Each issue of the digest contains one or more sets of articles (called
  27. threads), with each set corresponding to a 'discussion' of a particular
  28. subject.  The articles are not edited; all articles included in this digest
  29. are in their original posted form (as received by our news server at
  30. cs.uoregon.edu).  Article threads are not added to the digest until the last
  31. article added to the thread is at least one month old (this is to ensure that
  32. the thread is dead before adding it to the digest).  Article threads that
  33. consist of only one message are generally not included in the digest.
  34.  
  35. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  36. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  37. file /pub/mac/csmp-digest/README before downloading any files.  The most
  38. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  39. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  40. archive has a mail server; send a message with the text '$MACarch help' (no
  41. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  42.  
  43. The digest is also available via email.  Just send a note saying that you
  44. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  45. automatically receive each new issue as it is created.  Sorry, back issues
  46. are not available through the mailing list.
  47.  
  48. Send administrative mail to mkelly@cs.uoregon.edu.
  49.  
  50.  
  51. -------------------------------------------------------
  52.  
  53. From: jst@dcs.ed.ac.uk (Julian Turnbull)
  54. Subject: Using ReadXPRam and WriteXPRam traps
  55. Date: 30 Sep 92 08:56:51 GMT
  56. Organization: Department of Computer Science, Edinburgh University
  57.  
  58. [ Sorry if you're seeing this twice - I posted a couple of weeks ago, with
  59.   a restricted distribution, but got no response, so I'm casting the net a
  60.   bit wider this time.  JST ]
  61.  
  62. I'm trying to find some documentation for the _ReadXPRam and _WriteXPRam
  63. traps, which read and write the extended PRAM found in later Macs.
  64. Specifically, I want to be able to get at the latitude, longitude, and
  65. timezone information set by the Map cdev.
  66.  
  67. "Inside Mac" is remarkably coy about these calls - I got to Volume VI before
  68. I even found an admission that they exist.  However, some people manage to
  69. use them, so the information must exist _somewhere_.  Can anyone enlighten
  70. me?
  71.  
  72. Thanks in advance,
  73. Julian.
  74.  
  75.  
  76. - --
  77. | Julian Turnbull,                               | Phone: +44 31 650 5124
  78. | Department of Computer Science                 | JANET: jst@uk.ac.ed.dcs
  79. | University of Edinburgh, Edinburgh EH9 3JZ,    | Everywhere else:
  80. | Scotland, U.K.                                 |        jst@dcs.ed.ac.uk
  81.  
  82. +++++++++++++++++++++++++++
  83.  
  84. From: rjc@monet.ccs.itd.umich.edu (Robert John Churchill)
  85. Organization: University of Michigan
  86. Date: Thu, 1 Oct 1992 00:17:22 GMT
  87.  
  88. In article <BvDvIr.A5J@dcs.ed.ac.uk>, jst@dcs.ed.ac.uk (Julian Turnbull)
  89. wrote:
  90. > I'm trying to find some documentation for the _ReadXPRam and _WriteXPRam
  91. > traps, which read and write the extended PRAM found in later Macs.
  92. > Specifically, I want to be able to get at the latitude, longitude, and
  93. > timezone information set by the Map cdev.
  94. > "Inside Mac" is remarkably coy about these calls - I got to Volume VI before
  95. > I even found an admission that they exist.  However, some people manage to
  96. > use them, so the information must exist _somewhere_.  Can anyone enlighten
  97. > me?
  98.  
  99. Use ReadLocation and WriteLocation instead of messing with PRAM.  See
  100. Inside Mac volume 6 Chapter 14..
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. From: minow@Apple.COM (Martin Minow)
  105. Date: 1 Oct 92 22:31:09 GMT
  106. Organization: Apple Computer Inc., Cupertino, CA
  107.  
  108.  
  109. jst@dcs.ed.ac.uk (Julian Turnbull) asks about the ReadXParam and WriteXParam
  110. traps as he needs to access the location (latitude, longitude, and timezone
  111. offset).
  112.  
  113. The proper way to access this information is by using the ReadLocation and
  114. WriteLocation functions described in the ScriptManager chapter of Inside Mac VI.
  115.  
  116. Hope this helps.
  117.  
  118. Martin Minow
  119. minow@apple.com
  120.  
  121. +++++++++++++++++++++++++++
  122.  
  123. From: grobbins@Apple.COM (Grobbins)
  124. Date: 2 Oct 92 02:13:18 GMT
  125. Organization: Apple Computer Inc., Cupertino, CA
  126.  
  127. In article <72990@apple.Apple.COM> minow@Apple.COM (Martin Minow) writes:
  128. >jst@dcs.ed.ac.uk (Julian Turnbull) asks about the ReadXParam and WriteXParam
  129. >traps as he needs to access the location (latitude, longitude, and timezone
  130. >offset).
  131. >The proper way to access this information is by using the ReadLocation and
  132. >WriteLocation functions described in the ScriptManager chapter of Inside Mac VI
  133.  
  134. There is a sample program for getting the map information in the
  135. snippets collection, available via anonymous ftp from ftp.apple.com
  136. as
  137.  
  138.   /dts/mac/sc/snippets/toolbox.iac/other/readlocation.hqx
  139.  
  140. Setting of this and other information stored in Parameter
  141. RAM is unsupported, underdocumented, and discouraged.
  142.  
  143. Grobbins        grobbins@apple.com
  144.  
  145. Usual disclaimers apply.
  146.  
  147.  
  148. ---------------------------
  149.  
  150. From: heyes@dadev.cebaf.gov (Graham Heyes)
  151. Subject: putting the mouse in a cage?
  152. Organization: Continuous Electron Beam Accelerator Facility
  153. Date: Wed, 30 Sep 1992 14:35:07 GMT
  154.  
  155. Two quick questions related to the mouse/pointer...
  156.  
  157. Firstly how if at all possible can the movement of the
  158. mouse be restricted to one area of the screen, for example
  159. restricting mouse movement to within a particular window ?
  160.  
  161. Secondly, and probably related, what confines the pointer 
  162. to the screen? 
  163.  
  164.      I haven't seen this in any volumes of IM or anywhere
  165. else for that matter so I'm curious as to if it is possible.
  166.  
  167.             Graham Heyes
  168.  
  169. +++++++++++++++++++++++++++
  170.  
  171. From: BLOOMDA@ctrvax.vanderbilt.edu (_creative_output_)
  172. Organization: Camp Vanderbilt Vision Research Center
  173. Date: Thu, 1 Oct 1992 18:45:38 GMT
  174.  
  175. Figured this out digging through some MacsBug shorthand equates:
  176.  
  177. static    Rect    box = {100,100,400,400}, dispR = {20,20,60,160};
  178.         char      outs[20], pouts[20];
  179.         WindowPtr wind;
  180.         int      X,Y,    dl=23, dt=44;
  181.  
  182. #define    RawMouse    0x082C
  183. #define    Yaddr        (int*) (RawMouse)
  184. #define    Xaddr        (int*) (RawMouse+sizeof(int))
  185.  
  186. #define    MTemp        0x0828
  187. #define    YaddrT        (int*) (MTemp)
  188. #define    XaddrT        (int*) (MTemp+sizeof(int))
  189.  
  190. main()
  191. {
  192. InitMacintosh();
  193. wind = NewCWindow( 0L, &screenBits.bounds, "\p", true, plainDBox,-1L,true,0 );
  194. SetPort( wind );    ShowWindow( wind );       EraseRect(&screenBits.bounds );
  195. FrameRect( &box );
  196. while ( ! Button() )
  197.     {
  198.     X = * Xaddr;    Y = * Yaddr;            /* get raw mouse pos  */
  199.  
  200.     if ( X > 400 )    * Xaddr = * XaddrT = 100;   /* force x if too big */
  201.     if ( X < 100 )    * Xaddr = * XaddrT = 400;   /* force x if too lil */
  202.     if ( Y > 400 )    * Yaddr = * YaddrT = 100;   /* force y if too big */
  203.     if ( Y < 100 )    * Yaddr = * YaddrT = 400;   /* force y if too lil */
  204.  
  205.     sprintf( outs, "%d,%d", X,Y );    CopyCToPas( outs, pouts ); /*  tell  */
  206.     EraseRect( &dispR );  MoveTo( dl,dt );  DrawString( pouts ); /*   us   */
  207.     }
  208. }
  209.  
  210. ... InitMacintosh() does the usual mac init stuff ...
  211.  
  212. That should do it!  (I guess i originally intended to use the Rect 'box'....)
  213.  
  214.  
  215. - - Dave Bloom
  216.  
  217. "He who speaks the truth           - Arabian saying,
  218.  better have one foot in the stirrup"    from _Moon_Over_Morocco_,
  219.                                          by Meatball Fulton & ZBS Foundation
  220.  
  221. +++++++++++++++++++++++++++
  222.  
  223. From: crod@cc.curtin.edu.au (Scott Kevill)
  224. Date: 2 Oct 92 01:49:56 GMT
  225. Organization: Curtin University of Technology
  226.  
  227. There used to be a lovely global variable called PinMouse (can't
  228. remember the location offhand) that contained a rectangle that did
  229. all this work for you. The other advantage was that it worked with
  230. everything and wasn't just while a loop was executing.
  231.  
  232. This global variable worked fine until System 7 came along - it
  233. has no effect and System 7 seems to continously reset this variable.
  234. However this should work fine on any system before 7 although it
  235. may not be of much use.
  236.  
  237. Hope this helps !
  238.  
  239. Scott
  240.  
  241. +-----------------------+--------------------------------------+
  242. I Scott Kevill          I   "Be like me, be original"          I
  243. I crod@cc.curtin.edu.au I                              -- Me   I
  244. +-----------------------+--------------------------------------+
  245.  
  246. +++++++++++++++++++++++++++
  247.  
  248. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  249. Organization: Kalamazoo College
  250. Date: Fri, 2 Oct 1992 03:38:51 GMT
  251.  
  252. crod@cc.curtin.edu.au (Scott Kevill) writes:
  253. >There used to be a lovely global variable called PinMouse (can't
  254. >remember the location offhand)
  255.  
  256. 0x0834.
  257.  
  258. >that contained a rectangle that did
  259. >all this work for you. The other advantage was that it worked with
  260. >everything and wasn't just while a loop was executing.
  261. >
  262. >This global variable worked fine until System 7 came along - it
  263. >has no effect and System 7 seems to continously reset this variable.
  264. >However this should work fine on any system before 7...
  265.  
  266. If I recall correctly, it failed to have any effect on any of the
  267. machines with Color QuickDraw I tried.  It worked on my SE and failed
  268. on a IIcx running 6.0.x.  But I didn't test it on many machines...
  269. - -- 
  270.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  271.  I'm your only friend, I'm not your only friend, but I'm a little glowing
  272.  friend, but really I'm not actually your friend, but I am...
  273.  
  274. ---------------------------
  275.  
  276. From: tbl@rock.concert.net (Ted Lowery)
  277. Subject: Q: How to tell the depth of screen?
  278. Organization: MacSolutions
  279. Date: Wed, 30 Sep 1992 18:12:19 GMT
  280.  
  281. Hi all-
  282.  
  283. Question:  What is the best way to tell the depth of the default screen when
  284. your application starts up?  The way I am currently doing is to check
  285. SysEnvirons.hasColorQD, and if so, I create a color port with the following:
  286.  
  287. if (myEnv.hasColorQD) {
  288.         myCGrafPtr = NewPtrClear(sizeof(CGrafPort));
  289.         OpenCPort(myCGrafPtr);
  290.         theDepth = (**(*myCGrafPtr).portPixMap).pixelSize;
  291.         CloseCPort(myCGrafPtr);
  292.         }
  293. else theDepth = 1;
  294.  
  295. seems to me, there is probably a lot of overhead involved here, and there
  296. should to be a simpler way.  I need to do it before I open a window, so that
  297. I know which type of window, and what size to open.
  298.  
  299. Also, what is the screen size of the 12" bw and color monitors like the 
  300. LC use?
  301.  
  302. Thanks...
  303.  
  304. +----------------------------+----------------------------+
  305. |  Ted Lowery                |              MacSolutions  |
  306. |  tbl@rock.concert.net      |              PO Box 30051  |
  307. |  CIS: 76350,2613           |        Raleigh, NC  27622  |
  308. +----------------------------+----------------------------+
  309. |  A bore is someone who persists in holding his own      |
  310. |  views aster we have enlightened him with ours.         |
  311. +---------------------------------------------------------+
  312.  
  313.  
  314. +++++++++++++++++++++++++++
  315.  
  316. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  317. Organization: Kalamazoo College
  318. Date: Wed, 30 Sep 1992 18:56:10 GMT
  319.  
  320. tbl@rock.concert.net (Ted Lowery) writes:
  321. >
  322. >What is the best way to tell the depth of the default screen when
  323. >your application starts up?  The way I am currently doing is to check
  324. >SysEnvirons.hasColorQD, and if so, I create a color port...
  325. >seems to me, there is probably a lot of overhead involved here, and there
  326. >should to be a simpler way.
  327.  
  328. Yep.  Try (**(**GetMainDevice()).gdPMap).pixelSize.
  329.  
  330. >Also, what is the screen size of the 12" bw and color monitors like the 
  331. >LC use?
  332.  
  333. Both mono and color 12" are 512x384.
  334. - -- 
  335.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  336.  I suppose ya don't think I was run over by a streetcar!
  337.  
  338. +++++++++++++++++++++++++++
  339.  
  340. From: Andrew Gilmartin <Andrew_Gilmartin@Brown.Edu>
  341. Date: 30 Sep 1992 23:20:31 GMT
  342. Organization: Brown University
  343.  
  344. In article <1992Sep30.185610.3998@hobbes.kzoo.edu> Jamie R.
  345. McCarthy, k044477@hobbes.kzoo.edu writes:
  346.  
  347. >Yep.  Try (**(**GetMainDevice()).gdPMap).pixelSize.
  348.  
  349. I had a similar need, but I wanted to find out if any attached
  350. device was using black and white only. Since there is no
  351. complement to GetMaxDevice(), here is a kind is GetMinDevice().
  352.  
  353. Boolean IsMonochrome( void )
  354. {
  355.      GDHandle theDevice;
  356.     
  357.      for ( theDevice = GetDeviceList()
  358.           ; theDevice
  359.           ; theDevice = GetNextDevice( theDevice ) )
  360.           if ( (**(**theDevice).gdPMap).pixelSize == 1 )  // Is
  361. device using monochrome?
  362.                return TRUE;
  363.     
  364.      return FALSE; // Using color on all devices
  365.     
  366. } /* IsMonochrome */
  367.  
  368. Note: Just checking the device type is no enough, you have to
  369. check the pix map.
  370.  
  371. - -- Andrew
  372.  
  373. +++++++++++++++++++++++++++
  374.  
  375. From: Andreas Wuertz <wuertz@tik.ethz.ch>
  376. Organization: Federal Institute of Technology
  377. Date: Thu, 1 Oct 1992 08:19:46 GMT
  378.  
  379. In article <1992Sep30.185610.3998@hobbes.kzoo.edu> Jamie R. McCarthy,
  380. k044477@hobbes.kzoo.edu writes:
  381. >Both mono and color 12" are 512x384.
  382.  
  383. Is there a special bw monitor for the LC? Because the standard bw 12"
  384. monitor has 640x480 pixels. 512x384 is right for the 12" colour monitor.
  385. By the way: Start ResEdit 2.1 and create/open a ALRT, DLOG or WIND
  386. resource. You'll get a menu called 'MiniScreen' which has all the current
  387. sizes in it.
  388.  
  389. Andy (wuertz@tik.ethz.ch)
  390.  
  391. ========================================================================
  392. The only person who got all his work done by Friday was Robinson Crusoe.
  393. ========================================================================
  394.  
  395. +++++++++++++++++++++++++++
  396.  
  397. From: greeny@top.cis.syr.edu (J. S. Greenfield)
  398. Date: 1 Oct 92 14:38:53 GMT
  399. Organization: Syracuse University, CIS Dept.
  400.  
  401. In article <1992Sep30.185610.3998@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  402. >
  403. >>Also, what is the screen size of the 12" bw and color monitors like the 
  404. >>LC use?
  405. >
  406. >Both mono and color 12" are 512x384.
  407.  
  408. The color is 512x384 (about 55 dpi, I think), but the mono is 640x480 (72 dpi).
  409.  
  410.  
  411. - -- 
  412. J. S. Greenfield                                         greeny@top.cis.syr.edu
  413. (I like to put 'greeny' here, 
  414. but my d*mn system wants a 
  415. *real* name!)                        "What's the difference between an orange?"
  416.  
  417. ---------------------------
  418.  
  419. From: jbm@panix.com (John Mignault)
  420. Subject: If I have the old, do I need to buy the new Inside Mac?
  421. Date: Wed, 30 Sep 1992 22:15:26 GMT
  422. Organization: PANIX Public Access Unix, NYC
  423.  
  424. The subject line just about says it all. The bookstore where I work just
  425. got three volumes of the new Inside Mac, and I was wondering, before I
  426. decide to spend another $200 or so on the six new books, just how much I'll
  427. actually need them if I already own the original six. I understand they're
  428. probably pretty cool and slick and suchlike, but if I can afford not to buy
  429. them ( at least right now ), I won't. Any opinions?
  430.  
  431. John Mignault
  432. jbm@panix.com
  433.  
  434. +++++++++++++++++++++++++++
  435.  
  436. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  437. Organization: Kalamazoo College
  438. Date: Thu, 1 Oct 1992 03:38:46 GMT
  439.  
  440. jbm@panix.com (John Mignault) writes:
  441. >The subject line just about says it all. The bookstore where I work just
  442. >got three volumes of the new Inside Mac, and I was wondering, before I
  443. >decide to spend another $200 or so on the six new books, just how much I'll
  444. >actually need them if I already own the original six.
  445.  
  446. Do you have a CD-ROM drive?
  447.  
  448. September's developer CD arrived a few days ago, and I was pleasantly
  449. surprised to find all three currently-existing New Inside Macintosh
  450. volumes on it.  (Although I was puzzled to not see an issue of
  451. _develop_.  Anyone know what's up?)  Sure, browsing's slow off the CD,
  452. and they'll take up ten megs if you copy them to hard disk--but you can
  453. always print them yourself, and besides you can't electronically search
  454. the paper version.
  455.  
  456. Do I remember right that a year's subscription to the developer CD runs
  457. something like $30?  (If you can confirm or correct this, please email
  458. me.)  If so, and if you have a CD-ROM drive--snap it up.  If you don't
  459. have a CD-ROM...hey, it's about the same price as the next umpteen
  460. New Inside Macintosh books.  :-)
  461. - -- 
  462.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  463.  I suppose ya don't think I was run over by a streetcar!
  464.  
  465. +++++++++++++++++++++++++++
  466.  
  467. From: de19@umail.umd.edu (Dana S Emery)
  468. Date: 1 Oct 92 08:47:58 GMT
  469. Organization: Personal
  470.  
  471. In article <1992Sep30.221526.26751@panix.com>, jbm@panix.com (John
  472. Mignault) wrote:
  473. > [...] I was wondering, before I decide to spend another $200 or so on the 
  474. > six new books, just how much I'll actually need them if I already own the 
  475. > original six.
  476.  
  477. well, actually its going to be more like 15 new volumes, and the TN are
  478. going to be withdrawn as they are obsoleted by the new volumes, so you
  479. probably should get them, after all, apple's new publishing venture might
  480. go broke if we decided to boycott it.
  481. - --
  482.  
  483. Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
  484.                                   |     de novo, de no-o-o-o-o---, 
  485.                                   | Novemba come an' dey gonna go home."
  486.  
  487. +++++++++++++++++++++++++++
  488.  
  489. From: hammett@sbsu1.aukuni.ac.nz (Tim Hammett)
  490. Date: 1 Oct 92 20:37:25 GMT
  491. Organization: University of Auckland, New Zealand.
  492.  
  493. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  494. >Do I remember right that a year's subscription to the developer CD runs
  495. >something like $30?  (If you can confirm or correct this, please email
  496. >me.)  If so, and if you have a CD-ROM drive--snap it up.  If you don't
  497.  
  498. This isn't totally correct - a year's subscription to develop (which includes
  499. four of that year's developer disks) costs $30 to US subscribers.
  500.  
  501. The full developer mailing (12 CD's per year, plus the occasional other
  502. goodie, but excluding any betas) is available from APDA, & costs around
  503. $250 + shipping (which is substantial).
  504.  
  505. (^^ I don't have my APDA catalog handy, so I'm not totally sure of the $250
  506. figure, but it's that order of magnitude).
  507.  
  508. - --
  509. Tim Hammett, Botany Dept, Auckland University, New Zealand.
  510. t.hammett@aukuni.ac.nz   Phone: +64-9-373-7599 x8365    FAX: +64-9-373-7416
  511.  
  512. +++++++++++++++++++++++++++
  513.  
  514. From: zaphod@bluemoon.rn.com (Peter Bierman)
  515. Organization: Blue Moon BBS ((614) 868-998[024])
  516. Date: Thu, 01 Oct 92 14:56:56 EDT
  517.  
  518. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  519.  
  520. > Do I remember right that a year's subscription to the developer CD runs
  521. > something like $30?  (If you can confirm or correct this, please email
  522. > me.)  If so, and if you have a CD-ROM drive--snap it up.  If you don't
  523. > have a CD-ROM...hey, it's about the same price as the next umpteen
  524. > New Inside Macintosh books.  :-)
  525.  
  526. Yep. It's $30 plus tax. $25 if you get one of those purple cards from 
  527. someone who already gets it. That's only 4 CDs though. One every three 
  528. months.
  529.  
  530.  
  531. - ---
  532. The opinions I express are rarely my own, because my own are far too
  533. outragous to post here.
  534.  
  535. IntNet:SEE NOTE BELOW            FutureNet: #33@#10
  536. The Metropolis (614)-846-1911
  537. - ---
  538. Internet Address: Send two copies of everything to:
  539. zaphod@bluemmon.rn.com and zaphod@bluemoon.use.com
  540.  
  541. +++++++++++++++++++++++++++
  542.  
  543. From: zaphod@bluemoon.rn.com (Peter Bierman)
  544. Date: 1 Oct 92 18:54:10 GMT
  545. Organization: Blue Moon BBS ((614) 868-998[024])
  546.  
  547. jbm@panix.com (John Mignault) writes:
  548.  
  549. > The subject line just about says it all. The bookstore where I work just
  550. > got three volumes of the new Inside Mac, and I was wondering, before I
  551. > decide to spend another $200 or so on the six new books, just how much I'll
  552. > actually need them if I already own the original six. I understand they're
  553. > probably pretty cool and slick and suchlike, but if I can afford not to buy
  554. > them ( at least right now ), I won't. Any opinions?
  555.  
  556. Well, I own all 6, + IMCTB, + XREF, + Hardcopy of all TNs. I just bought 
  557. the first 3 new ones, and I must say that I'm QUITE impressed. The fact 
  558. that everything in them is ACCURATE, and COMPLETE just about pays for 
  559. itself. AL least get "files" because the old way to do files involves 
  560. memorizing IM2, 4, and 6, + about 12 tech notes.
  561.  
  562. In short, the new ones are worth it. They're jammed with source code, and 
  563. the biggest part of each chapter is the ENGLISH explanation about how it 
  564. all works together.
  565.  
  566.  
  567. - ---
  568. The opinions I express are rarely my own, because my own are far too
  569. outragous to post here.
  570.  
  571. IntNet:SEE NOTE BELOW            FutureNet: #33@#10
  572. The Metropolis (614)-846-1911
  573. - ---
  574. Internet Address: Send two copies of everything to:
  575. zaphod@bluemmon.rn.com and zaphod@bluemoon.use.com
  576.  
  577. ---------------------------
  578.  
  579. From: aep@world.std.com (Andrew E Page)
  580. Subject: Gestalt Return Value for 24-bit addressing?
  581. Date: 2 Oct 92 13:22:52 GMT
  582. Organization: The World Public Access UNIX, Brookline, MA
  583.  
  584.  
  585.     What does the Gestalt Trap return when 24-bit addressing is
  586. in effect?  It returns a 0,1, or 2 when various flavors of 32-bit
  587. is in effect, at least according to GestaltEqu.a.  Or does it
  588. simply pass back a non-zero result code in D0?
  589.  
  590. - -- 
  591. Andrew E. Page   (Warrior Poet) |   Decision and Effort The Archer and Arrow
  592. Mac Consultant                  |     The difference between what we are
  593. Macintosh and DSP Technology    |           and what we want to be.
  594.  
  595. +++++++++++++++++++++++++++
  596.  
  597. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  598. Date: 2 Oct 92 18:49:16 GMT
  599. Organization: MacDTS Marauders
  600.  
  601. In article <BvHx65.1t9@world.std.com>, aep@world.std.com (Andrew E Page)
  602. wrote:
  603. >     What does the Gestalt Trap return when 24-bit addressing is
  604. > in effect?  It returns a 0,1, or 2 when various flavors of 32-bit
  605. > is in effect, at least according to GestaltEqu.a.  Or does it
  606. > simply pass back a non-zero result code in D0?
  607. > -- 
  608. > Andrew E. Page   (Warrior Poet) |   Decision and Effort The Archer and Arrow
  609. > Mac Consultant                  |     The difference between what we are
  610. > Macintosh and DSP Technology    |           and what we want to be.
  611.  
  612. The 0,1 and 2 are bit numbers, as is the standard for gestalt...Attr
  613. selectors, as described on page 3-34 of Inside Mac VI.  Thus, if
  614. you were in 32-bit mode, the response would generally be $00000007, or
  615. binary 00000000000000000000000000000111, having bits 0,1, and 2 set;
  616. the same Mac in 24-bit mode might return $00000004 (binary ...0100),
  617. having only the 32-bit capable bit set.
  618.  
  619. Tim Dierks
  620. MacDTS
  621.  
  622. +++++++++++++++++++++++++++
  623.  
  624. From: anders@verity.com (Anders Wallgren)
  625. Date: 2 Oct 92 20:52:56 GMT
  626. Organization: Verity, Mountain View, CA, USA
  627.  
  628. In article <BvHx65.1t9@world.std.com> Andrew E Page,
  629. aep@world.std.com writes:
  630. >    What does the Gestalt Trap return when 24-bit addressing is
  631. >in effect?  It returns a 0,1, or 2 when various flavors of 32-bit
  632. >is in effect, at least according to GestaltEqu.a.  Or does it
  633. >simply pass back a non-zero result code in D0?
  634.  
  635. Bit 0: 32-bit addressing mode
  636. Bit 1: 32-bit clean System Heap
  637. Bit 2: Machine is 32-bit capable
  638.  
  639. In your case, I would probably test if bit 0 is off.
  640.  
  641. ---------------------------
  642.  
  643. From: evans@natural.com (Christopher Evans)
  644. Subject: Writing dcmds in MPW
  645. Date: 1 Oct 92 20:43:31 GMT
  646. Organization: Natural Intelligence, Inc.
  647.  
  648. I am trying to write a dcmd in MPW or Think C and I am having a heck
  649. of a time!  The dcmd uses some ANSI calls and a couple of toolbox calls.
  650. The problem is that I can't link it in MPW.  The sample dcmd on the 
  651. developer cd's links a file called "{CLibraries}CInterface.o which I don't
  652. have.  Where is this file?  
  653.  
  654. Can I also be safe in assuming that I should not waste my time trying to 
  655. write a dcmd in Think C?
  656.  
  657. <=================================Q=================================>
  658.  Chris Evans                      |   Internet: evans@natural.com
  659.  Senior Macintosh Programmer      |   Phone: 617-876-4876
  660.  Natural Intelligence, Inc.       |   FAX:   617-492-7425
  661.  2067 Massachusetts Avenue        |   AppleLink: NATURAL
  662.  Cambridge MA  02140              |   or evans@natural.com@internet#
  663.  
  664. +++++++++++++++++++++++++++
  665.  
  666. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  667. Date: 2 Oct 92 19:22:12 GMT
  668. Organization: MacDTS Marauders
  669.  
  670. In article <1992Oct1.204331.10558@natural.com>, evans@natural.com
  671. (Christopher Evans) wrote:
  672. > I am trying to write a dcmd in MPW or Think C and I am having a heck
  673. > of a time!  The dcmd uses some ANSI calls and a couple of toolbox calls.
  674. > The problem is that I can't link it in MPW.  The sample dcmd on the 
  675. > developer cd's links a file called "{CLibraries}CInterface.o which I don't
  676. > have.  Where is this file?  
  677. > Can I also be safe in assuming that I should not waste my time trying to 
  678. > write a dcmd in Think C?
  679.  
  680. OK; I'd suggest you write the dmcd in MPW, because the tools are designed
  681. to work in MPW; I don't have any idea how you'd do it in Think C.  You're
  682. going to run into two problems, because the dcmd stuff was designed for
  683. MPW 3.1, and there's been two significant changes:
  684.   1) CInterfaces.o and CRuntime.o were eliminated
  685.   2) The segmentation strategy for a lot of routines changed
  686.  
  687. You're currently running into 1); it's trying to link with CInterface.o,
  688. and it doesn't exist.  Replace all references to "{CLibraries}"CRuntime.o
  689. with "{Libraries}"Runtime.o and replace "{CLibraries}"CInterface.o with
  690. "{Libraries}"Interface.o.  Note you will usually have two references
  691. to "{Libraries}"Interface.o now; you can delete one of them.
  692.  
  693. You'll soon run into 2).  The BuildDCMD tool expects a very specific
  694. segmentation, and because the libraries were resegmented in MPW 3.2,
  695. it can't recognize things, so you'll need to merge the extraneous
  696. segments into the "Main" segment.  You'll need to add arguments like
  697. - -sg Main=StdIO,StdLib to your link line.  The easiest way to determine
  698. which segments you've got that need to be merged is to link the dcmd
  699. without merging anything, then open it with RedEdit and look at the
  700. CODE resources; they'll all have names, and each resource's name
  701. is a segment name.  You need to merge all the segments except for
  702. %A5Init into Main.  So write down all the names of all the other
  703. segments and add this argument to your link line:
  704.   -sg Main=segName1,segName2,and,so,on
  705. This will merge all the named segments into Main, giving you the
  706. canonical 2-segment file BuildDCMD wants to use.
  707.  
  708. Enjoy;
  709. Tim Dierks
  710. MacDTS
  711.  
  712. ---------------------------
  713.  
  714. From: Michael_Hecht@mac.sas.com (Michael Hecht)
  715. Subject: HOpen confusion
  716. Date: 21 Sep 92 14:40:56 GMT
  717. Organization: SAS Institute Inc.
  718.  
  719. This is probably obvious to everyone, but...
  720.  
  721. I'm trying to call PBHOpenDFAsync, which takes an HParmBlkPtr, and I'm
  722. getting confused.
  723.  
  724. * Which variant of the HParamBlockRec do I use? The field names in IM
  725. imply that I should use IOParam, except it doesn't contain an ioDirID.
  726. Ok, I'll use FileParam instead, except it doesn't contain an ioPermssn or
  727. ioMisc. [Confusion?!?!?]
  728.  
  729. * Nowhere in IM-Files is it stated what variant goes with what routine.
  730. It only offers this extremely useless admonition: "When you call a
  731. low-level routine, you pass the address of the appropriate parameter
  732. block to the routine." How profound! I thought I should pass an
  733. inappropriate parameter block. Thanks for the sage advice!!
  734. [Frustration!!!!!]
  735.  
  736. * Is ioMisc still used for Opens? IM-IV says I should set it to NIL or to
  737. an I/O buffer. IM-Files doesn't say anything about it with regards to the
  738. HOpen family. [Omission?????]
  739.  
  740. * IM-Files makes no mention of zeroing the version number in the Open
  741. descriptions. It does, however, mention it in the Data Structures section
  742. that describes the HParamBlockRec. Do I still need to set it to zero for
  743. HOpen? If I'm using the FileParam variant, do I set both ioFVersNum and
  744. ioFlVersNum? Probably not, since the second one overlays ioMisc, which
  745. maybe should or shouldn't be set to NIL. Wouldn't I be totally in the
  746. dark if I were new to this game? [Disappointment...]
  747.  
  748. Anxiously awaiting the blinding light of truth...
  749. - --Michael
  750.  
  751. =======================================================================
  752. Michael P. Hecht                 | Internet:  Michael_Hecht@mac.sas.com
  753. SAS Institute Inc.; Cary, NC USA | AppleLink: SAS.HECHT
  754.  
  755. +++++++++++++++++++++++++++
  756.  
  757. From: leonardr@netcom.com (Leonard Rosenthol)
  758. Date: 21 Sep 92 16:50:30 GMT
  759. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  760.  
  761. In article <BuxnG8.8Fo@unx.sas.com> Michael Hecht <Michael_Hecht@mac.sas.com> writes:
  762. >I'm trying to call PBHOpenDFAsync, which takes an HParmBlkPtr, and I'm
  763. >getting confused.
  764. >
  765.         You probably want to make that a Sync open, don't you?  
  766.  
  767. >* Which variant of the HParamBlockRec do I use? The field names in IM
  768. >imply that I should use IOParam, except it doesn't contain an ioDirID.
  769. >Ok, I'll use FileParam instead, except it doesn't contain an ioPermssn or
  770. >ioMisc. [Confusion?!?!?]
  771. >
  772.         I use an HParamBlockRec and then set it up as follows:
  773. pb.fileParam.ioCompletion = NULL;
  774. pb.fileParam.ioVRefNum = vRefnum;
  775. pb.fileParam.ioDirID = dirID;
  776. pb.fileParam.ioNamePtr = (StringPtr) fName;
  777. pb.ioParam.ioPermssn = fsRdWrPerm;
  778. pb.ioParam.ioMisc = (Ptr)NULL;
  779.         and then call PBHOpenDFsync, remember that this will NOT work under
  780. System 6.
  781.  
  782. >* Is ioMisc still used for Opens? IM-IV says I should set it to NIL or to
  783. >an I/O buffer. IM-Files doesn't say anything about it with regards to the
  784. >HOpen family. [Omission?????]
  785. >
  786.         I don't know if it is still used or not, but it doesn't hurt to set it.
  787.  
  788. - -- 
  789. - -----------------------------------------------------------------------------
  790. Leonard Rosenthol            Internet:     leonardr@netcom.com
  791. Director of Advanced Technology        AppleLink:    MACgician
  792. Aladdin Systems, Inc.            GEnie:        MACgician
  793.  
  794. +++++++++++++++++++++++++++
  795.  
  796. From: sdorner@qualcomm.com (Steven Dorner)
  797. Date: 27 Sep 92 15:46:28 GMT
  798. Organization: Qualcomm, Inc
  799.  
  800. In article <BuxnG8.8Fo@unx.sas.com>, Michael Hecht
  801. <Michael_Hecht@mac.sas.com> wrote:
  802. > * Is ioMisc still used for Opens? IM-IV says I should set it to NIL or to
  803. > an I/O buffer. IM-Files doesn't say anything about it with regards to the
  804. > HOpen family. [Omission?????]
  805.  
  806. Set it to NIL.  I had a very disturbing experience with ioMisc.  My program
  807. would crash at more or less random times.  No matter where I set
  808. breakpoints, it would crash somewhere else; but only on MacPlusses and
  809. SE's; II's and up were fine.  All these machines were running whatever was
  810. current at the time (6.0.5, I think).
  811.  
  812. The culprit was ioMisc.  I was failing to zero it, and this made SE's and
  813. Plusses go bonkers (at unpredictable times, since the buffer's only used
  814. when a track needs to be transferred), whereas it didn't affect II's at
  815. all.
  816.  
  817. I concluded from this that ROM's since the II's must ignore ioMisc on
  818. opens.  However, I wouldn't bet my life on it, and you don't want to cut
  819. off SE's and Plusses (SE's especially, since they're better machines than
  820. Classics).
  821.  
  822. ---------------------------
  823.  
  824. From: dbassett@bonnie.ics.uci.edu (Douglas Scott Bassett)
  825. Subject: Quickdraw region implementation
  826. Date: 28 Sep 92 22:19:16 GMT
  827. Organization: Univ. of Calif., Irvine, Info. & Computer Sci. Dept.
  828.  
  829. Does anyone know exactly how Quickdraw regions are implemented on the MAC?
  830.  
  831. +++++++++++++++++++++++++++
  832.  
  833. From: wysocki@netcom.com (Chris Wysocki)
  834. Date: Tue, 29 Sep 92 01:56:37 GMT
  835. Organization: Connectix Corporation, San Mateo, CA
  836.  
  837. In article <2AC784E4.20055@ics.uci.edu> dbassett@ics.uci.edu (Douglas
  838. Scott Bassett) writes:
  839.  
  840. >Does anyone know exactly how Quickdraw regions are implemented on the MAC?
  841.  
  842. A QuickDraw region consists of a series of "inversion points", i.e.
  843. points at which one goes from outside the region to inside or vice
  844. versa.  These points are stored in ascending scanline order following
  845. the rgnSize and rgnBBox fields in the region handle.  Each scanline in
  846. the region data starts with the vertical coordinate, followed by the
  847. horizontal coordinates of the inversion points on that scanline.
  848. (Since regions are closed, there are always an even number of
  849. horizontal coordinates per scanline.)  The last horizontal coordinate
  850. on a scanline is followed by $7FFF, which marks the end of the
  851. scanline data.  This is repeated for each scanline in the region; a
  852. vertical coordinate of $7FFF marks the end of the region data.
  853. Rectangular regions are the one exception to this format; such regions
  854. contain no inversion point data (i.e. "GetHandleSize(theRegion) ==
  855. sizeof(Region)") and are fully described by their bounding rectangle
  856. (the rgnBBox field).
  857.  
  858.  
  859.  
  860. - -- 
  861. Chris Wysocki
  862. wysocki@netcom.com
  863. afachrisw@aol.com
  864.  
  865.  
  866. ---------------------------
  867.  
  868. From: dougm@cns.caltech.edu (Doug McNaught)
  869. Subject: Questions relating to direct-to-screen drawing
  870. Date: 29 Sep 92 04:50:37 GMT
  871. Organization: California Institute of Technology
  872.  
  873.  
  874. Hey friendly netters,
  875.   A friend of mine is working on a program that draws directly to the
  876. screen in a window, and he has some questions about StripAddress and
  877. maintaining as much compatibility as possible with various models. The
  878. program runs in 8-bit mode and requires Color QuickDraw. I'm going to
  879. append the message he sent me and you can reply to him, myself, or the
  880. net--I'll make sure he gets any useful responses. 
  881.  
  882. His name is Alexei Lebedev and he can be reached at 
  883.   70534.404@CompuServe.COM
  884.  
  885. - ------here we go!!!------
  886.  
  887. Doug,- 
  888.  
  889. I'd be very grateful if you posted my problem on UseNet. In particular, I need
  890. to know the following:
  891.  
  892. 1). IM says "strip when the system may be running 24 bit mem manager". I guess
  893. any system can run 24 bit memory manager. Also, no my global MaskBC variable 
  894. is always 0x00FFFFFF, even when I'm in 32 bit mode. That means I'm always 
  895. running 24 bit mem manager.
  896.  
  897. 2). How do you tell the hardware to operate in 32 bits? Should I use stripped 
  898. addresses right away, or can I keep a variable that's a stripped address? In 
  899. particular, when I lock my Image data structure, I do the following:
  900.  
  901. HLock(destImage->baseH);
  902. CheckOS(MemError(), "LOCK");    /* last parameter is a routine name */
  903. destImage->baseAddr = StripAddress(*destImage->baseH);
  904.  
  905. Is this the right way to do this?
  906.  
  907. 3). When I start writing to the screen, I switch to 32 bit addressing with 
  908. SwapMMUMode. Does this have any effect on a computer like LC?
  909.  
  910. 4). I use screenbits.baseAddr to get screen memory's base address. Is this 
  911. address 32 bit clean no matter what? (I guess it should be, since it doesn't 
  912. point to a memory manager block.) Is this a base address of the main screen?
  913.  
  914. 5). When I switch pixel depth, screenBits.rowBytes remains the same. This is 
  915. very nasty. What is the right way of getting screen's base address, and should
  916. I always switch machine to 32 bit addressing mode before writing to the 
  917. screen?
  918.  
  919. 6). How come screenBits is a bit map, but the screen is color? since 
  920. screenbits is a bitmap, the high bit of its rowBytes should be cleared. This 
  921. means using copyBits on the screen will produce b/w images, if not nonsense.
  922.  
  923. 7). At what times EXACTLY should strip address be used, and at what times 
  924. EXACTLY should SwapMMUMode be used?
  925.  
  926. These are just some of the questions that bug me. Also, if I want to write to 
  927. another screen, do I call SetGDevice? If so, what happens to my screenBits? 
  928. Can the device be changed when I call WaitNextEvent? I mean, when I return 
  929. from WaitNextEvent, should I always switch to the my own device, like I do 
  930. with ports?
  931.  
  932. I used to calculate screen width by taking screenBits.rowBytes and multiplying
  933. it by 8. However, when I start up in 4 bits and then switch to 8 bits (by 
  934. using SetDepth), the cube becomes twice as large, instead of being twice as 
  935. small. This doesn't make much sense to me. Also it doesn't make sense that in 
  936. 1 bit mode screenbits.rowBytes is 1024 (!!), while in 8 bit mode it's 512 
  937. (??).
  938.  
  939. Hope some of them get answered.
  940. Have fun.
  941. - -Alexei
  942.  
  943. - --
  944. Doug McNaught              |"Sadder still to watch it die/ Then never to have
  945. dougm@cns.caltech.edu      | known it/ For you, the blind who once could see/
  946. doug@midget.towson.edu     | The bell tolls for thee..." --Neil Peart
  947.   Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
  948.  
  949. +++++++++++++++++++++++++++
  950.  
  951. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  952. Date: 29 Sep 92 12:04:52 GMT
  953. Organization: Kalamazoo College
  954.  
  955. dougm@cns.caltech.edu (Doug McNaught) writes:
  956. >
  957. >  A friend of mine is working on a program that draws directly to the
  958. >screen in a window, and he has some questions about StripAddress...
  959. >
  960. >His name is Alexei Lebedev and he can be reached at 
  961. >  70534.404@CompuServe.COM
  962. >
  963. >1). ... my global MaskBC variable 
  964. >is always 0x00FFFFFF, even when I'm in 32 bit mode. That means I'm always 
  965. >running 24 bit mem manager.
  966.  
  967. The global will not tell you;  disassemble _StripAddress in both 24- and
  968. 32-bit mode to see why.  (In 24-bit mode, it ANDs the global like you'd
  969. expect;  in 32-bit mode, it returns and does nothing.)
  970.  
  971. >2). How do you tell the hardware to operate in 32 bits? Should I use stripped 
  972. >addresses right away, or can I keep a variable that's a stripped address? In 
  973. >particular, when I lock my Image data structure, I do the following:
  974. >
  975. >HLock(destImage->baseH);
  976. >destImage->baseAddr = StripAddress(*destImage->baseH);
  977. >
  978. >Is this the right way to do this?
  979.  
  980. Looks fine to me.  
  981.  
  982. >3). When I start writing to the screen, I switch to 32 bit addressing with 
  983. >SwapMMUMode. Does this have any effect on a computer like LC?
  984.  
  985. It has an effect on any computer running in 24-bit mode that is capable
  986. of switching into 32-bit mode.  The LC, like most Macs, could fit these
  987. conditions.
  988.  
  989. >4). I use screenbits.baseAddr to get screen memory's base address. Is this 
  990. >address 32 bit clean no matter what? (I guess it should be, since it doesn't 
  991. >point to a memory manager block.) Is this a base address of the main screen?
  992.  
  993. Is it 32-bit clean?  Probably, but why take a chance?  StripAddress is a
  994. very quick call.  Is it the baseAddr of the main screen?  Yes.
  995.  
  996. >5). When I switch pixel depth, screenBits.rowBytes remains the same. This is 
  997. >very nasty. What is the right way of getting screen's base address, and should
  998. >I always switch machine to 32 bit addressing mode before writing to the 
  999. >screen?
  1000.  
  1001. screenBits.rowBytes stays the same for a good reason--it _is_ the same,
  1002. at least on your machine.  The standard Apple 8-bit card, for example,
  1003. will always have a rowBytes of 1024, no matter how many bytes wide the
  1004. image actually is.  If you're in 8-bit mode, 384 bytes per line are
  1005. going to waste;  if you're in 1-bit mode, 944.  (That way-cool screen
  1006. extender by that European dude, I think it's called MaxApplScreen or
  1007. something like that, makes use of the extra ram on the card, by the way.
  1008. Except I can never remember the name of the control panel, I always
  1009. think "MaxApplZone"...anyway...)
  1010.  
  1011. The Right(tm) way of getting a screen's base address is to decide which
  1012. screen you want from the device list, and use
  1013. (**(**theGDevHndl).gdPMap).baseAddr.  Generally, you should always swap
  1014. into 32-bit mode before writing to the screen (or anyplace not in main
  1015. RAM).  I say "generally" because if you know for a fact that the screen's
  1016. address is a 24-bit address, you don't need to--but why _not_ call
  1017. SwapMMUMode()?
  1018.  
  1019. >6). How come screenBits is a bit map, but the screen is color? since 
  1020. >screenbits is a bitmap, the high bit of its rowBytes should be cleared. This 
  1021. >means using copyBits on the screen will produce b/w images, if not nonsense.
  1022.  
  1023. screenBits is a holdover from 9-inch-screen days.  The Right(tm) way to
  1024. get a screen's PixMap is to walk the GDevice list, as I said above.
  1025. I don't know whether screenBits was upgraded to a PixMap, or what the
  1026. story is, because I never use it.  It's a very rare occasion that you
  1027. know for sure that the main screen is the one you want.
  1028.  
  1029. >7). At what times EXACTLY should strip address be used, and at what times 
  1030. >EXACTLY should SwapMMUMode be used?
  1031.  
  1032. "Concentrate and ask again."  :-)  Seriously, Tech Note #213
  1033. ("StripAddress: the Untold Story") explains stripping and MMU modes
  1034. quite well.
  1035.  
  1036. >Also, if I want to write to 
  1037. >another screen, do I call SetGDevice? If so, what happens to my screenBits? 
  1038.  
  1039. No, you don't have to.  Change the current GDevice and you change the
  1040. color environment--for example, I believe the Color Manager call
  1041. Color2Index will decide on an index based on the new GDevice's inverse
  1042. table.  You won't affect QuickDraw calls (hopefully), because they all
  1043. go through DeviceLoop anyway.  I have no idea whether screenBits will
  1044. reflect the current GDevice, or always the main one.
  1045.  
  1046. >Can the device be changed when I call WaitNextEvent? I mean, when I return 
  1047. >from WaitNextEvent, should I always switch to the my own device, like I do 
  1048. >with ports?
  1049.  
  1050. I believe the rule is--always leave the current GDevice where you found
  1051. it.  (And I believe that, if others follow the rule, you'll always find
  1052. it set to the main device.)  So, do GetGDevice/SetGDevice/.../SetGDevice.
  1053.  
  1054. If you need to, that is--when you're drawing direct to screen, there
  1055. isn't much reason to change the current GDevice.
  1056.  
  1057. >I used to calculate screen width by taking screenBits.rowBytes and multiplying
  1058. >it by 8.
  1059.  
  1060. This is not a good thing to do.  (Although I must say it's interesting
  1061. to try to figure out what's going on inside your computer.)  Trust
  1062. rowBytes.  If you want screen width, subtract left from right.
  1063.  
  1064. >Also it doesn't make sense that in 
  1065. >1 bit mode screenbits.rowBytes is 1024 (!!), while in 8 bit mode it's 512 
  1066. >(??).
  1067.  
  1068. Makes no sense to me neither--check that value with the 8-bit screen
  1069. again.  I'll bet it's still 1024.
  1070.  
  1071.  
  1072. Also, I highly recommend Forrest Tanaka's short develop article entitled
  1073. "Graphical Truffles" (sorry, I forget which issue, email me if you need
  1074. to know).  It cleared a lot of cobwebs out of my Color QuickDraw
  1075. paradigm.  Develop is downloadable from ftp.apple.com.
  1076. - -- 
  1077.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1078.  Was bringt mich nicht um...
  1079.  
  1080. +++++++++++++++++++++++++++
  1081.  
  1082. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  1083. Date: 29 Sep 92 22:21:09 GMT
  1084. Organization: MacDTS Marauders
  1085.  
  1086. In article <DOUGM.92Sep28215037@bradbury.cns.caltech.edu>,
  1087. dougm@cns.caltech.edu (Doug McNaught) wrote:
  1088. > Hey friendly netters,
  1089. >   A friend of mine is working on a program that draws directly to the
  1090. > screen in a window, and he has some questions about StripAddress and
  1091. > maintaining as much compatibility as possible with various models. The
  1092. > program runs in 8-bit mode and requires Color QuickDraw. I'm going to
  1093. > append the message he sent me and you can reply to him, myself, or the
  1094. > net--I'll make sure he gets any useful responses. 
  1095. > His name is Alexei Lebedev and he can be reached at 
  1096. >   70534.404@CompuServe.COM
  1097. > ------here we go!!!------
  1098. > Doug,- 
  1099. > I'd be very grateful if you posted my problem on UseNet. In particular, I need
  1100. > to know the following:
  1101. > 1). IM says "strip when the system may be running 24 bit mem manager". I guess
  1102. > any system can run 24 bit memory manager. Also, no my global MaskBC variable 
  1103. > is always 0x00FFFFFF, even when I'm in 32 bit mode. That means I'm always 
  1104. > running 24 bit mem manager.
  1105.  
  1106. No; when you're in 32-bit mode, you're using the 32-bit memory manager.
  1107. The proper way to check your memory mode is to use Gestalt with the
  1108. gestaltAddressingModeAttr selector ('addr').  If bit 0 is set
  1109. (the gestalt32BitAddressing flag), then you're in 32-bit mode.  You
  1110. probably don't need to know this; see below.
  1111.  
  1112. > 2). How do you tell the hardware to operate in 32 bits? Should I use stripped 
  1113. > addresses right away, or can I keep a variable that's a stripped address? In 
  1114. > particular, when I lock my Image data structure, I do the following:
  1115. > HLock(destImage->baseH);
  1116. > CheckOS(MemError(), "LOCK");    /* last parameter is a routine name */
  1117. > destImage->baseAddr = StripAddress(*destImage->baseH);
  1118. > Is this the right way to do this?
  1119.  
  1120. This is OK; you can cache a stripped address safely, however, because
  1121. the "stripping" doesn't ever change; if you're in 24-bit mode, it
  1122. will always mask off the top byte; if you're in 32-bit mode, it
  1123. will always leave the address unchanged.  Stripping an address
  1124. so you can use it after switching to 32-bit mode is always an OK 
  1125. thing to do; it will do the right thing, regardless of the memory
  1126. manager mode you are in previously.
  1127.  
  1128. > 3). When I start writing to the screen, I switch to 32 bit addressing with 
  1129. > SwapMMUMode. Does this have any effect on a computer like LC?
  1130.  
  1131. On the LC, this has neither good nor bad effect, because the hardware is
  1132. 24-bit; stripping it has no effect, but there's no reason to take it
  1133. out, either.
  1134.  
  1135. > 4). I use screenbits.baseAddr to get screen memory's base address. Is this 
  1136. > address 32 bit clean no matter what? (I guess it should be, since it doesn't 
  1137. > point to a memory manager block.) Is this a base address of the main screen?
  1138. >
  1139. > 5). When I switch pixel depth, screenBits.rowBytes remains the same. This is 
  1140. > very nasty. What is the right way of getting screen's base address, and should
  1141. > I always switch machine to 32 bit addressing mode before writing to the 
  1142. > screen?
  1143. > 6). How come screenBits is a bit map, but the screen is color? since 
  1144. > screenbits is a bitmap, the high bit of its rowBytes should be cleared. This 
  1145. > means using copyBits on the screen will produce b/w images, if not nonsense.
  1146.  
  1147. If you're attempting to draw on a color machine, you should look
  1148. through the GDevices to determine the size, depth and location of screens.
  1149. See the "Graphic Devices" chapters in Inside Mac V and VI.
  1150.  
  1151. > 7). At what times EXACTLY should strip address be used, and at what times 
  1152. > EXACTLY should SwapMMUMode be used?
  1153.  
  1154. You should use SwapMMUMode any time you access the frame buffer for a
  1155. video device.  You should use StripAddress() to clean any other addresses
  1156. you wish to use while switched into 32-bit mode.  For example, if I wanted
  1157. to copy an image from a handle to the screen, I would first call
  1158. StripAddress on a pointer to the image data; this produces a clean
  1159. pointer I can use while in 32-bit mode.  I then call SwapMMUMode(); I'm
  1160. now in 32-bit mode, so I can access the screen's memory safely.  I can
  1161. then copy the data from the stripped address to the screen.  I then
  1162. call SwapMMUMode() to switch back to the mode I was in before.
  1163.  
  1164. > These are just some of the questions that bug me. Also, if I want to write to 
  1165. > another screen, do I call SetGDevice? If so, what happens to my screenBits? 
  1166. > Can the device be changed when I call WaitNextEvent? I mean, when I return 
  1167. > from WaitNextEvent, should I always switch to the my own device, like I do 
  1168. > with ports?
  1169.  
  1170. If you want to draw on another screen, find its GDevice and use the
  1171. depth and base address from that structure.  You do not need to change
  1172. the devicew, because that's a QuickDraw call, and you're not using
  1173. QuickDraw.  (Not that you would use it to draw on the screen if you
  1174. were using QuickDraw- it is intended solely for switching to offscreen
  1175. GDevices).
  1176.  
  1177. > I used to calculate screen width by taking screenBits.rowBytes and multiplying
  1178. > it by 8. However, when I start up in 4 bits and then switch to 8 bits (by 
  1179. > using SetDepth), the cube becomes twice as large, instead of being twice as 
  1180. > small. This doesn't make much sense to me. Also it doesn't make sense that in 
  1181. > 1 bit mode screenbits.rowBytes is 1024 (!!), while in 8 bit mode it's 512 
  1182. > (??).
  1183.  
  1184. Once again, use GDevices (and their associated PixMaps) to get rowBytes
  1185. and everything else.
  1186.  
  1187. > Hope some of them get answered.
  1188. > Have fun.
  1189. > -Alexei
  1190. > --
  1191. > Doug McNaught              |"Sadder still to watch it die/ Then never to have
  1192. > dougm@cns.caltech.edu      | known it/ For you, the blind who once could see/
  1193. > doug@midget.towson.edu     | The bell tolls for thee..." --Neil Peart
  1194. >   Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
  1195.  
  1196. Tim Dierks
  1197. MacDTS, but I speak for my knees.
  1198.  
  1199. +++++++++++++++++++++++++++
  1200.  
  1201. From: absurd@applelink.apple.com (Tim Dierks, software saboteur)
  1202. Date: 30 Sep 92 02:00:03 GMT
  1203. Organization: MacDTS Marauders
  1204.  
  1205. In article <1992Sep29.120452.28513@hobbes.kzoo.edu>,
  1206. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) wrote:
  1207. > dougm@cns.caltech.edu (Doug McNaught) writes:
  1208. > >
  1209. > >  A friend of mine is working on a program that draws directly to the
  1210. > >screen in a window, and he has some questions about StripAddress...
  1211. > >
  1212. > >His name is Alexei Lebedev and he can be reached at 
  1213. > >  70534.404@CompuServe.COM
  1214. [...]
  1215. > >4). I use screenbits.baseAddr to get screen memory's base address. Is this 
  1216. > >address 32 bit clean no matter what? (I guess it should be, since it doesn't 
  1217. > >point to a memory manager block.) Is this a base address of the main screen?
  1218. > Is it 32-bit clean?  Probably, but why take a chance?  StripAddress is a
  1219. > very quick call.  Is it the baseAddr of the main screen?  Yes.
  1220.  
  1221. I meant to mention this in my previous post, but I forgot.  You should
  1222. _not_ strip the address of the main screen.  It will always, and
  1223. must always be a true 32-bit address.  Here's why:
  1224.  
  1225. In the 24-bit memory map, there is 1 Megabyte of space allocated to
  1226. each NuBus card at the locations xxs00000 - xxsFFFFF.  In the original
  1227. slot manager, with original color QuickDraw, this was big enough to
  1228. hold all screens.  (I can't remember ever seeing a screen with more
  1229. than 1024 x 1024 pixels before 32-bit QD).  However, if you go to 32-
  1230. bit deep, even a standard 640 x 480 screen will be too big; its RAM
  1231. won't fit into the 1 Mb space (640 x 480 x 4 bytes/pixel) = 1228800
  1232. bytes = 1.2 Mb.  That means that all deep screens must be located
  1233. in an area of the address map which is only accessible in 32-bit
  1234. mode.  For convenience, cards from some manufacturers are always
  1235. located in the 32-bit address space so they don't have to support
  1236. having RAM at two different addresses.
  1237.  
  1238. Given all that, let's assume that you've got a 32-bit screen whose 
  1239. base address is CC010000 (this is the base address of my 8o24 GC
  1240. card, in slot C).  Let's also say you've booted up into 24 bit mode.
  1241. If you switch into 32-bit mode and use this address, you'll be
  1242. just hunky-dory.  If you attempt to use StripAddress() however,
  1243. bad things will happen: the top byte of CC010000 will be masked
  1244. off, making it into 00010000, which is most definitely not your
  1245. screen buffer.  This means that the base address of any screen
  1246. GDevice's pixel map must be "pre-stripped" so it can be used as
  1247. a raw 32-bit address, because you can't strip it (or any other
  1248. pointer that might point into a NuBus card outside of the
  1249. minor slot space).
  1250.  
  1251. Tim Dierks
  1252. MacDTS, but I speak for the spleen.
  1253.  
  1254. ---------------------------
  1255.  
  1256. End of C.S.M.P. Digest
  1257. **********************
  1258.