home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20868 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  3.1 KB

  1. Path: sparky!uunet!olivea!apple!goofy!mumbo.apple.com!gallant.apple.com!seuss.apple.com!user
  2. From: absurd@apple.apple.com (Tim Dierks, software saboteur)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: StripAddress Question.
  5. Message-ID: <absurd-070193002032@seuss.apple.com>
  6. Date: 7 Jan 93 08:34:12 GMT
  7. References: <rudolph.726382887@unixg.ubc.ca>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Organization: MacDTS Marauders
  11. Lines: 65
  12.  
  13. In article <rudolph.726382887@unixg.ubc.ca>, rudolph@unixg.ubc.ca
  14. (Christopher E Rudolph) wrote:
  15. > Hello all,
  16. > I hope this isn't an FAQ, but here goes.  
  17. > I have been looming over the thrill of writing directly to the screen, and
  18. > I find it very interesting.
  19. > One question though:
  20. >     Could anyone give me a bit of theory as to why the high byte of the
  21. >     starting address of say a color icon has to be stripped before 
  22. >     accessing video memory.
  23. >     I did this when I was already in 32bit mode and all I got was garbage
  24. >     on the screen.  If I omit it I get what I expect.
  25. >     I am new to this low level stuff and would really appreciate a bit of
  26. >     an explanation.
  27. > I hope that was clear enough.
  28. > Chris Rudolph <rudolph@unixg.ubc.ca>
  29. > ------------------------------------
  30.  
  31. [ First, some history & backgound ]
  32. The 680000 processor has 32-bit address registers, but only 24 pins
  33. for the address bus, so the top 8 bits of addresses are ignored.
  34. The original Mac OS exploited this quirk, using the top 8 bits of
  35. block addresses to store information about those blocks (locked or
  36. unlocked, etc.) The 24 bit address bus, and the following 24-bit
  37. addressing limitation limits the total address space to 16 Mb in
  38. 68000 machines, which traditionally gives a limit of 8 Mb.  When
  39. the Mac II line was introduced, more address space was needed to
  40. provide room to interface NuBus cards.  Fortunately, all Mac IIs
  41. have 68020 or greater processors, and so have a full 32-bit
  42. address bus.  However, because the memory manager and a number of
  43. 3rd party application still used the top byte of addresses for
  44. other purposes, this extended address space couldn't be put to
  45. use until the 32-bit memory manager was made available with
  46. System 7.
  47.  
  48. [ Second, the facts ]
  49. Because your screen memory might be in 32-bit mode, if you're
  50. in 24-bit mode, you need to call SwapMMUMode() to switch into
  51. 32-bit mode.  (You don't have to check your memory mode; it's
  52. designed so you don't have to worry about it.)  Now that you're
  53. in 32-bit mode, the top 8 bits of your icon's pointer, which
  54. were ignored before, must be stripped or they will be interpreted
  55. as address bits and using the address will either cause a bus
  56. error or return garbage.
  57.  
  58. [ Third, the summary ]
  59. You only need to mask off the top byte if you're in 24 bit mode,
  60. you're going to try to use the pointer in 32-bit mode, and the
  61. pointer points into the main RAM (i.e., _do not_ strip pointers
  62. onto NuBus cards).  All you need to do is call StripAddress();
  63. if you're in 24 bit mode, it will mask off the byte, if you're
  64. in 32-bit mode, it will leave it alone.
  65.  
  66. Enjoy,
  67. Tim Dierks
  68. MacDTS, but I speak for myself and this really wacky keyboard.
  69.