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 space.
QIs it possible to get PAL (Phased Alternate Lines) timing from the new 4*8 and 8*24
cards?
AThe 4*8 and 8*24 cards currently support NTSC (National Television Standards Committee)
output and will support PAL output as well when the next ROM revision is put into production
early this year. (The 8*24 GC card currently supports PAL.)
QWhat is a System Error 29? It's not in any of the documentation I have available. One of
my applications has been reported to crash with this error occasionally.
AWhen the Package Manager can't load in a PACK resource for any reason, it calls SysErr. There is a
range of system error codes reserved for the situation in which the PACK resource couldn't be
loaded. That range is 17 through 24. So if it couldn't load the List Manager package, which is
PACK 0, the Package Manager adds 0 to 17 and calls SysErr with a code of 17. If it couldn't load
the Standard File package, which is PACK 3, the Package Manager adds 3 to 17 and calls SysErr
with a code of 20.
The problem is, we overflowed our PACK SysErr range. The Color Picker is PACK 12. If the
Package Manager couldn't load in PACK 12, it adds 12 to 17 and calls SysErr with a code of ... 29.
And there you have it.
PACKs are loaded into the system heap. If there's not enough room in the system heap for a PACK,
the system heap is expanded and the PACK is loaded in. If you set your application to take over the
entire application memory space, the system heap can't grow anymore. The
GetResource('PACK',12) call that the Package Manager makes fails: It adds 12 to 17, and calls
SysErr with a code of 29. This could be what's causing the crashes in your case.
QHow can we increase the stack space allocated by the DA Handler?
AThere is no simple, supported way
to increase the stack space available
to a DA. DAs were designed to
provide easy access to simple tools from the user's desktop. As such, the environment of a DA is
relatively limited. Now, with MultiFinder and especially with System 7.0, applications can provide
all the functionality of a DA with none of the limitations. Under MultiFinder the DA Handler
actually reduces the stack space available to a DA by about 25 percent. This limitation is not a
problem for applications. If you need stack space beyond the bounds of the DA's environment, we
encourage you to convert your DA to a full application.
QDoes 32-Bit QuickDraw support packed PICTs? What's the technique for saving packed
PICT formats? What compression schemes are supported?
AColor QuickDraw has always supported packed PICTs. See Inside Macintosh , volume V, for details
on how CLUT PixMaps are packed. Under 32-Bit QuickDraw, to pack direct RGB PixMaps in
PICTs, call CopyBits with the packType field in the source PixMap set to one of the following
constants that apply to direct RGB PixMaps:
0 | default packing (pixelSize 16 defaults to packType 3 and pixelSize 32 defaults to packType 4)
|
1 | no packing
|
2 | remove pad byte (32-bit pixels only)
|
3 | run-length encoding by pixel size chunks (16-bit pixels only)
|
4 | run-length encoding, all of one component at the time, one scan line at a time (24-bit pixels only)
Scheme 4 will store the alpha channel also if cmpCount is set to to four. PackSize is not used and
should be set to zero for compatibility reasons.
See Inside Macintosh, Volume 6, for complete details.
QIs there any way to stop the Dialog Manager from playing with the txSize and txFace fields of a dialog's grafPort so that I can draw Geneva 9-point text from
within a userItem proc?
AUnfortunately, because the Dialog Manager forgets about your previous calls to TextFont and
TextSize when you put up your dialog again, you will need to call TextFont and TextSize every time
your userItem proc is called.
QWhen should the Color Manager be used and when should the Palette Manager be used?
AThe Palette Manager is by far the friendlier and more versatile of the two. It provides all the
functionality you need to customize and animate the colors in your application. You shouldn't ever
need to use the Color Manager unless you require custom color search and complement functions.
Unless you really understand the Color Manager in detail, you are likely to have problems getting
the Color Manager to work in a clean fashion.
When using the Palette Manager, applications following the rules will maintain their respective
color environments safely as windows move back and forth from foreground to background, and
from one screen to another. Accomplishing this with the Color Manager calls is not worth the effort.
For additional information, see the Palette Manager article in this issue.
QI would like to make my fills print better. Currently, they come out as 72 dpi patterns. Is
there a way that
I can make them print at a higher resolution, but have my patterns still print as patterns?
ATo make your patterns print at the printer's resolution, you need to use Printing Manager
PrGeneral's GetRslData and SetRsl opcodes to get and set the resolution, and you must
scale the pattern to match. Let
me explain.
If we do not scale our patterns up to the printer's resolution before print time, we would get "big
chunky" patterns because the printer driver would need to scale the patterns on the fly from 72 dpi
to its resolution. Therefore, we use the "cookie cutter" approach to "place" the pattern into the
object that is being filled. The size of the "cookie cutter" (the destination Rect) depends on the
"scaleFactor." For example, a "scaleFactor" of 2 will have a destination rect of 16 x 16. We will then
CopyBits the pattern one square at a time into the object that is being filled.
You might find the article "Meet PrGeneral" from the July 1990 issue
of develop useful for describing the functionality of PrGeneral in greater detail.
QWhat versions of Apple Color Printer software work with what system software versions?
Can Apple Color Printer software distributed with System 6.0.7 work with System 6.0.5
and earlier versions? I am distributing LaserWriter ® drivers with modified pgsz resources. I
would like to cut back on the number of files I need to distribute.
AThe software sent with version 6.0.7 will work with all other 6.0.x systems. This should be the rule
with most other LaserWriter printer software as well. Color has been supported since LaserWriter
driver 6.0, for color depths of 8 bits or less. Depths greater than 8 bits must be converted before
printing.
There really isn't any simple way to match up the version of released printer software with what
version of the system it is compatible. LaserWriter 7.x is compatible with both System 7 and System
6. It's still prerelease software, however. Do not ship the preliminary LaserWriter 7.x driver with
your application. You'll be able to ship the final LaserWriter 7 driver with your product as soon as
System 7 is final.
QHow can I use SndPlay to function asynchronously? It seems to ignore the async parameter.
ATo use SndPlay asynchronously, you must have allocated a sound channel without passing NIL as
the chan parameter. There is one thing to be aware of in doing this, which often confuses
developers. If the 'snd' resource being used with SndPlay specifies a 'snth' resource, then you cannot
create the sound channel with a synth. Because of a Sound Manager bug that has been present in all
releases through System 6.0.7, SndPlay has not worked correctly for a 'snd' resource specifying a
'snth', with a user channel initialized with a 'snth'. For example, the following code will fail:
SndNewChannel(myChan, sampledSound, init, @myCallBack);
SndPlay(myChan, sndHdl, async);
{sndHdle is a sampled sound}
The Sound Manager attempts to link this 'snth' to the channel with every call to SndPlay. If the
synthesizer has already been installed, the Sound Manager attempts to install it again, only this time
as a modifier. The same 'snth' code ends up being installed more than once in the channel. If the
'snd' contains 'snth' information, then SndPlay can be used once and only once on a channel. A
format 2 'snd' resource is assumed to be a sampled sound. For format 1, check the number of snths
specified in the 'snd' and then check each one. The latest version of SoundApp has source code that
does these tests.
This limitation has been fixed in System 7. In System 7, SndPlay can be called any number of times
on a channel. For older system releases you need to create and dispose of the channel each time after
calling SndPlay, as in the following code:
#include <Resources.h>
#include <Sound.h>
#define TRUE 0xFF
#define FALSE 0
main()
{
Handle Sound;
SndChannelPtr chan;
int i;
OSErr err;
Sound = GetResource('snd', 100);
if (ResError() != noErr || Sound == nil)
Debugger();
for (i = 0; i < 3; ++i)
{
chan = nil;
err = SndNewChannel(
&chan, 0, 0, nil);
if (err != noErr)
Debugger();
err = SndPlay (chan,
Sound, FALSE);
if (err != noErr)
Debugger();
}
}
A good method for playing sampled sound asynchronously on any Macintosh is to create a sound channel
and use the bufferCmd. Find the sound header from the 'snd ' resource and pass the pointer to
this in the bufferCmd. Use this with SndDoCommand or SndDoImmediate. To determine when the sound has completed so that you can know when
to dispose of the channel, send a bufferCmd with SndDoCommand (in order to queue it)
after the bufferCmd. Once your callback procedure is called, set a global signalling that
the sound has finished. The new Sound Manager (System 6.0.7 and beyond) supports a new call, SndChannelStatus, which
will tell you if the channel is playing a sound or not. Instead of the callback procedure,
you can poll the channel’s status to determine when to dispose of the channel.
Example code using the callback procedure can be found in the DTS sample code SoundApp.
Q What is the difference between North and West?
A
North is an absolute direction on the globe. Once you are on the North Pole it is impossible to go any
"further North." West, on the other hand,
is a relative position. No matter where you are on the surface of the Earth, it’s always possible to go further West.
Q
I have found that sounds recorded at good or better quality will not play with system software prior to 6.0.7.
That’s expected, but the fact that SndPlay does not return an error message is not.
How can I check to see if a sound is compressed when running older system software?
A
There is a byte in the SoundHeader
data structure (and thus in a 'snd' resource), called "encode." If the sound is compressed,
the value of this byte will be $FE, which is defined as the constant cmpSH in the headers for the Sound Manager.
Q
Why do golf balls have pocks?
A
As counter intuitive as it may seem
at first, the pocks on golf balls actually make them fly farther. A golf ball builds turbulence in front of it as it flies through the air. If the ball is pocked, the turbulence “fills” the pockets as the ball spins, resulting in less resistance and more flight. 747s have pocks on their wings for the same reason. Dolphins presumably have these pocks on their fins for this purpose as well, but to date none of them have come out publicly and said so.
Q
We generate sounds using the Sound Driver’s four-tone synthesizer. Our application must run on all Macintosh computers and all system software versions starting with System 6.0.
According to an early version of Inside Macintosh, Volume VI, the new Sound Manager's
wave-table synthesizer, which replaces the Sound Driver's four-tone synthesizer, does not
perform as expected on some Macintosh systems. When should we use the Sound Manager and
when should we use the Sound Driver?
AThe Sound Driver is no longer supported, as of System 6.0.7. The wave-form synthesizer in the Sound
Manager released with 6.0.7 does not work correctly for non-Apple Sound Chip machines (Macintosh
Plus, SE, Classic, and LC), but this will be fixed in System 7. If you need to use the wave-form
synthesizer for non-ASC machines running 6.0.7, you could try the Sound Driver with 6.0.7 on the
chance it'll work for your purpose. Use the Sound Driver for non-ASC machines running System 6.0.5
and earlier.
QDoes stereo work? I was hoping to init the left and right channels separately
(using initChanLeft and initChanRight ) and send different sampled sounds out both
channels. But the Sound Manager documentation says stereo is not supported. I figured this
would be a "cheap" way of playing two sounds at the same time, sending them out the left
and right channels and letting the Macintosh mix them together (or telling the user to flip
the MONO switch on their stereo).
AStereo and mixing multiple channels
are new features of the Sound Manager released with System 6.0.7. If you create a mono channel, the
sounds come out both speakers. If you create a left channel, it is a mono sound coming from only the
left channel. Alternatively, creating a right channel will only come from the right.
If you create a stereo channel, then
the sound's left or right position is determined by the sound header you
use (with the bufferCmd). A stereo sound is only supported by a compressed or extended sound header.
You cannot control the left or right panning of a stereo sound. This is only determined by the sound
header and its interleaved data. The left or right init params will have no affect on a stereo channel.
True stereo sounds can only occur by using a stereo sound header. Two mono channels, one for the
left speaker and one for the right, could be opened for the affect that most developers want.
Only the Macintosh SE/30 and the Macintosh IIsi have both the left and right sources mixed to the
internal speaker. A stereo sound on all other Macintosh systems have the left source only sent to the
internal speaker. The right source is only sent to the external port, and it isn't possible to determine
if the external port is in use or not.
QIs it necessary to lock a 'snd' resource that is to be played asynchronously with SndPlay?
AYes, if you are playing a sound resource asynchronously with SndPlay, then you have to lock the
sound. SndPlay will restore the handle's state as soon as the trap returns to the caller. If the call is
asynchronous, the handle's state is restored immediately after calling SndPlay, before the sound
finishes playing.
QWhen converting stacks from HyperCard 1.2.5 to 2.0, the default "fixed line height" setting
for text fields sometimes enlarges the space required by text and destroys the layout of the
screen. For example,text tends to disappear outside the edges of the field, or be misaligned. Deselecting "fixed line
height" corrects the problem in most instances, but there can still be a slight discrepancy in the
amount of space taken up by identical fonts in identical fields between 1.2.5 and 2.0, such that
layouts are disrupted even if "fixed line height" is not selected.
AInherent in the design of HyperCard 2.0, the way a field is displayed may
be different in HyperCard 2.0 than
in HyperCard 1.2.5. Converting a
stack to HyperCard 2.0 from HyperCard 1.2.5 may require that
fields be tweaked to appear properly. Therefore, developers may want to provide special versions of
their stacks for use with HyperCard 2.0, regardless of whether features specific to HyperCard 2.0 are
incorporated.
QSince I have received HyperCard 2.0 I have converted several stacks for 1.x to 2.0 and have
experienced several problems with scripts that worked fine in 1.x. I have recently learned
that HyperCard 1.x will NOT run on System 6.0.7 and later versions. For HyperCard 1.x
users this results in stacks that cannot be used in HyperCard 2.0. For HyperCard stack
developers this presents a nightmare in converting old 1.x stacks for users into 2.0 stacks.
Since encountering these problems I have changed my scripts in 1.x so that when converted
they work. What is Apple's position on "seamless conversion" of HyperCard 1.x stacks to
HyperCard 2.0?
AMost functioning 1.x scripts will work without modification under HyperCard 2.0. However,
HyperCard 2.0 is a bit more strict in enforcing some of the grammar of HyperTalk. For example,
keywords can no longer be used as variable names under 2.0. Under 1.x, keywords could be used as
variable names, but the documentation specifically warned against doing this.
Kudos to our readers who care enough to ask us terrific and well-thought-out questions. The answers to these puzzles have
been supplied courtesy of our teams of technical gurus; our thanks to all. Special thanks to Pete "Luke Skywalker"
Alexander, Mark Baumwell, Jeremy Bornstein, Rich Collyer, Dennis Hescox, Jim Luther, Guillermo Ortiz, Jim Reekes, Bryan
Stearns, Robert Stobel,Forrest Tanaka,Vince Tapia, Jon Zap, and Scott "Zz" Zimmerman for the material in this Q & A
column. *
Have more questions? Need more answers? Take a look at the new developer technical library on AppleLink (updated
weekly) or the Q & A stack on each Developer CD Series disc. *
Software Updates via MacUpdate
Price Scanner via MacPrices.net
Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more
Jobs Board
Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple
Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states)
Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) -
Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom
Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall
Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
|