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