Winter 91 - MACINTOSH Q & A
MACINTOSH Q & A
MACINTOSH DEVELOPER TECHNICAL SUPPORT
QHow can I set the Protect bit of a file?
AThe Protect bit is neither documented nor supported. PBSetCatInfo and PBSetFInfo
cannot set this bit. Additionally, attempting to change the Lock bit also fails with either
of these calls. SetFLock trap must be used to set the Lock bit of the file's attribute. The
Protect bit was an early method of copy protection. If the Finder sees this bit set, it
will not allow the user to copy, move, delete, or rename the file. It is important to note
that ONLY the Finder pays any attention to this bit. So, it would be possible to use any
file utility to copy the file even if it is "protected".
QSystem 6's "About Finder" memory info for my 16 MB Macintosh IIfx is incorrect.
ASystem 6 does not run in 32-bit address mode so it cannot support more than 8 MB
of RAM. What you are seeing in the "About" box is the Finder trying to understand what
has happened to the other 8 MB of RAM. It assumes the system is using it, but in
reality the RAM is not being used by anything. A/UX and System 7 both support up to 1
GB of RAM for 68030 Macintoshes since the IIci. System 7's "Memory" cdev must be
set for 32-bit addressing in order to take advantage of RAM beyond 8 MB. This also
requires "32-bit clean" ROMs (Macintosh IIci or later).
QIs there a way to determine if a machine has a PMMU installed?
AThe Gestault Manager's gestaultMMUType selector (available since System 6.0.4)
will tell you if, and which type of, MMU is installed. For preliminary Gestault
documentation and interface files, check AppleLink and developer CDs.
QHow do I set the cursor at interrupt time, for instance in a VBL task?
AChanging the cursor at interrupt time is permissible as long as the cursor handle is
locked in memory and the cursor routines are not busy. A test needs to be performed
before you change the cursor. If you want to call SetCursor (with a cursor handle
locked in memory), you nmust check CrsrBusy, a low-global defined in the Macintosh
Programmer's Workshop (MPW) SysEqu. If CrsrBusy is true, then you cannot call
SetCursor. Changing the cursor while CrsrBusy is true causes it to leave mouse bits,
or trails, on the screen.
CrsrBusy EQU $8CD ; Cursor locked out? [byte]
QHow do penguins know when it’s safe to go in the water?
APenguins in the Antarctic face many perils, not the least of which are several species
of sea mammals waiting at the edge of icebergs to nibble on their little penguin bods
when they go in the water. So, penguins will just wander around on the edge of an ice
floe until one of them accidentally falls in the ocean. When that happens all the
penguins will stand by and watch to see if the fallen penguin gets eaten. If the penguin
comes to harm it’s back to business as usual on the iceberg. If the penguin is safe
(apparently for a period of time known only to the other penguins) then the entire
dissimulation leaps in, hunting for food.
QIs the maximum size of a resource still 32K?
ANo. There used to be a bug in the 64K ROMs that didn’t allow you to write even
multiples of 32K (that is, 32K-64K, 128K-192K). This was fixed in 128K ROMs. As
of 128K ROMs, the resource size is limited to “maxlongint” bytes.
QHow do I write a background-only application for MultiFinder?
AA background-only application is similar to a standard MultiFinder-aware
application except that it performs a task in the background with no user interface
such as windows or menus. A background-only application must not initialize any
Toolbox managers; for example, it must not call InitWindows or InitMenus. If a dialog
needs to be displayed by a background application, the Notification Manager should be
used.
QI am writing a Chooser PACK resource. When I change the flags that control which
messages I will be sent, nothing seems to change. Why?
AChooser caches the flags from your Chooser PACK the first time it sees the file. From
then on, changes are ignored until the PACK's name is changed, or until the Chooser's
cache is flushed. To flush the cache, simply hold down the Command and Option keys
when selecting Chooser from the Apple menu. When the cache is flushed, the system
will beep.
QWhat can I do and not do while executing in interrupt code?
AInterrupt code is most commonly used for I/O completion routines, VBLs, Time
Manager tasks, and deferred tasks. Contrary to popular belief, the Deferred Task
Manager will run your task at interrupt level. All code that runs at interrupt level
must follow very strict rules. The most important rule is that the code cannot allocate,
move, or purge memory, reference memory manager structures (that is, HUnlock),
or call a Toolbox routine that would. This eliminates nearly, if not all, QuickDraw
operations. For a more complete list of these Toolbox routines, refer to the Inside
Macintosh X-Ref .
Additionally, interrupt code should avoid accessing a low-memory global or calling a
trap that would access one. While MultiFinder is running, the applications'
low-memory globals are being swapped in and out. Because of this, the interrupt code
cannot rely on which application's globals are currently available. Even if CurApName
is correct, the interrupt routine may be called while MultiFinder is in the process of
swapping the applications' globals. This restriction is difficult to deal with because
there is no documention as to which low-memory globals are swapped by MultiFinder,
nor which globals are accessed by traps.
A typical example of this problem is interrupt routines that attempt to restore A5 by
examining CurrentA5. This low-memory global is valid only while the current
application is running at non-interrupt time. Thus, the Macintosh Programmer's
Workshop (MPW) routine SetCurrentA5 (or the obsoleteSetupA5) cannot be used at
interrupt level. It is necessary to place the application's A5 value somewhere it can be
located while in the interrupt routine. This is documented in Technical Notes #180
and #208. In fact, the exact code you need is in #180.
Also, there are interrupt limitations while System 7 is running under Virtual
Memory. Therefore, it is best to avoid interrupt code if at all possible. Move the
functionality of the interrupt code into the application. For example, if you do require
a VBL, limit the code to an absolute minimum. Also, set a global flag for the application
to check in its event loop.
QIs the maximum size for global and local data still 32K?
AStarting with MPW 3.0, the maximum size for global data in MPW became larger
than 32K, using compiler and linker options -m and -srt. Local data is tougher,
because local data is allocated by using the LINK instruction, for example, LINK
A6,#$-380. With this relative addressing mode, you're constrained to the negative
side of a 16-bit value for local space, which translates to 32K. That is, this limit is
basically due to the Motorola processor architecture. If you are allocating more than
32K either globally or locally, you might want to rearchitect your system to use
dynamic (and theoretically unbounded, especially on virtual architectures) storage