From: rudolph@unixg.ubc.ca (Christopher E Rudolph)
Newsgroups: comp.sys.mac.programmer
Subject: Another StripAddress Question?
Date: 7 Jan 93 20:30:41 GMT
Organization: The University of British Columbia
NNTP-Posting-Host: unixg.ubc.ca
Summary: I am having trouble w/ StripAddress () in 24 and 32 bit modes
Keywords: Strip Address Question

Hello All,

This relates to a problem I posted yesterday, which Tim Dierks explained
nicely to me (thanks).

However I see to be having trouble with this StipAddress () call.  It doesn't
seem to be working the way I think it should (not that that means very much).

Okay, here goes again.

1)  Assume the Mac is in 32 bit Addressing mode after startup.  Thus any call
    to  StripAddress () will leave the address unchanged. 
    I have a Handle to a 'icl8' that I pass to a function as a pointer to a
    long. 
    
    >   Handle colorIconH; 
    >    
    >   Function ((long *)*colorIconH)      <Function (long *colorIconPtr)>  
              
    I make sure that the 'icl8' was properly loaded (ie !NIL)
    before passing it. So I now a have pointer to a long that is the starting
    address of the first byte of my 'icl8' 
    So I call StripAddress () because I won't be able to know if the user is
    in 24 or 32 bit mode 
    
    >   colorIconPtr = (long *)StripAddress(colorIconPtr); 
    
    I call SwapMMUMode (); 
    
    >   mmuMode = true32b; 
    >   SwapMMUMode (&mmuMode); 
    
    I have previously figured out where the baseAddr of the mainscreen is etc
    so that drawing directly to the screen is simply:  
    
    >   for (...;...;...)       /* basic looping stuff */ 
    >   {
    >       *screenPtr++ = *colorIconPtr1++; 
    >       /* screenPtr is a pointer to the baseAddr of the mainscreen */ 
    >       ... 
    >       ... 
    >       ...
    >       ... 
    >   } 
    
    Okay I don't think I have left anything out other calling SwapMMUMode
    again. 
    
    PROBLEM: 
    Since I am in 32 bit Addressing mode I don't need the StripAddress call,
    but since StripAddress is supposed to return the address unchanged if 
    we are already in 32 bit mode, it shouldn't matter (NOT). 
    When I comment out the StripAddress () call I get the color Icon drawn
    properly to the screen.  However, when I don't comment it out, I get
    junk on the screen.   I don't understand why this is happening, because 
    if StripAddress is supposed to  return the value unchanged, commenting 
    or not commenting the call shouldn't make a difference ???????????????.
     
2)  Assume the Mac is in 24 bit Addressing mode after startup.  Thus any call
    to  StripAddress () will strip the high byte of the address. 
    I figured that maybe I should see what is happening in 24 bit addressing
    mode and see what happens now. 
    
    >   The code is the same as 1) 
    
    PROBLEM: 
    Now when I comment out the StripAddress call I get a BusError.  I should
    expect this since the value is probably garbage when switching to 32 bit
    mode. But when I uncomment StripAddress () I still get garbage on the screen.

    FINAL QUESTION: 
    So then why should I get the icon properly placed when in 32 bit mode and
    not stripping the address, but garbage or a bus error in all the other 
    cases.

    This is quite confusing to me, and I would really love to hear an
    explanation on it.  I hope I have been clear and to the point.
     

---------------------------------------------- 
Chris Rudolph (ComputerScience,UBC) <rudolph@unixg.ubc.ca>
----------------------------------------------