Apple II Q& A

Apple II DEVELOPER TECHNICAL SUPPORT

Q Our Apple IIGS® TextEdit field created with NewControl2 appears to be redrawn
within the TESetText call, but Apple II GS Toolbox Reference Volume 3 says controls
won't be redrawn until the next update event. Is this a mistake in the documentation or
in our logic?

A Internally, TextEdit uses control records for all TextEdit records. The main
difference between control and noncontrol records is that the control defproc handles
many of the standard TextEdit functions without requiring your application to do so. In
the case of TESetText, though, TextEdit will always redraw the entire viewRect. This is
a mistake in the manual.

Q We want to load $BC files from a folder when our program is launched. How do we
ask the Apple II GS System Loader to discard these loaded files at application shutdown
time? We tried using the main program's master ID from the Memory Manager, but
the files are still not unloaded.

A The Loader is not designed to support more than one program with one user ID. It
assumes that InitialLoad or InitialLoad2 will be called with distinct user IDs for each
"program" to be controlled individually.

 You need to get new user IDs (probably $1000 type) for each module you load, so that
you can call UserShutDown on each of them individually when you need to. Don't
dispose of the memory at the end; call UserShutDown on each of the IDs and the Loader
will take care of the rest. If you're not quitting, you might want to shut them down in
zombie state so that they don't have to be reloaded from disk if the memory is
available. You can just pass $1000 as the user ID to InitialLoad and it will get a new ID
for you and return it on the stack.

 Remember that $BC auxiliary types are reserved and must be assigned by Apple
Developer Technical Support.

Q How can I turn off the GS/OS file system cache, or keep it from writing to a disk
while my file system optimizer is running?

A Altering volumes at the block level will confuse GS/OS ® , because the ProDOS®
File System Translator (FST) keeps copies of file system structures that aren't in the
cache. You need to use DWrite, although using DWrite instead of WRITE_BLOCK risks
destroying the integrity of any open files on disk, such as the system resource file. If
you use WRITE_BLOCK, you must close any open files, including the system resource
file if you optimize the boot disk.

 Once you start optimizing, don't make any calls that could directly or indirectly result
in operating system calls--no DA access, no Font Manager calls, no loading tools,
nothing. When you're done, GS/OS's internal volume control records (VCRs) will be
completely invalid and you'll have to call OSShutDown.

Q When is it OK to make Apple II GS system service calls? I'd like to make calls such as
MOVE_INFO from a driver that's executing asynchronously.

A It's OK to make system service calls in response to a GS/OS request, for example.
Most of them require the OS environment, such as GS/OS's direct page, but
MOVE_INFO, SET_SYS_SPEED, DYN_SLOT_ARBITER, and SIGNAL do not. When you're
not in the GS/OS environment, make sure the proper language card bank of bank 1 is
swapped in. Just JSLing there will put you into something that's not a system service
call. You can either use the bank $E1 equivalents of MOVE_INFO, SET_SYS_SPEED, and
DYN_SLOT_ARBITER, or you can make sure that the right $01 language card bank is
enabled:

    short
    lda >$E0C068
    pha
    lda >$E0C08B
    lda >$E0C08B
    longmx
; Set up the registers and make your
; JSL  My_Favorite_SysSrv_Call
    short
    lda >$E0C083
    lda >$E0C083
    pla
    sta >$E0C068
    longmx

Q Do I have to write extra program code for my Apple II GS program to grow a
resource?

A No, it's pretty straightforward. All you have to do to modify the content of any
resource (including growing it) is to load the resource in, make any changes you want
to the handle (such as change the data inside or call SetHandleSize to make it bigger),
and then call MarkResourceChange. The Resource Manager updates the contents of your
file when you call UpdateResourceFile. The Resource Manager recognizes the change in
the size of the handle automatically.

Q The Apple IIGS does not seem to sort out equivalent devices on the Apple Desktop
BusTM (ADB) as the Macintosh does and as outlined in the ADB specification. We want
multiple keyboard support, but the Apple IIGS ADB micro just begins reading blindly
from addresses 2 and 3, assuming one keyboard and one mouse are attached. Is this
information correct?

A The Apple IIGS does not do the same kind of dynamic device mapping and remapping
that the Macintosh ADB Manager does. The "Apple Desktop Bus Tool Set" chapter of the
Apple IIGS Toolbox Reference  gives instructions on how to remap devices dynamically
yourself. Essentially, you have two options:

 If you don't expect many developers to use a second keyboard, you might just choose to
remap it inside any program that uses it. You could write an external library or
functions that remap a second keyboard and read from it.

Q Where can I find documentation on how to recognize SCSI partitions, such as MS DOS
partitions, from GS/OS?

A The documents you'll need are the GS/OS Reference  (Addison-Wesley) and the
GS/OS Device Driver Reference  (APDA). You can recognize SCSI hard disk partitions
programmatically by looking for a SCSI Hard Drive device type ($0005) and a
forwardLink or headLink that's nonzero.  This will give you all SCSI hard disk
partitions, but it won't give you non-SCSI partitions, which have a different device
type.

 Bit 13 of the Device Characteristics word is for "Linked devices" like partitions, but
the GS/OS Device Driver Reference  says that bit applies to removable media, so not
all third-party GS/OS drivers may set that bit for partitions (even though Apple's
SCSI hard disk driver does).

 Remember that GS/OS requires each partition to appear as a separate device, so
there's no support for multiple partitions on one logical device.

 

Kudos to our readers who care enough to ask us terrific and well thought-out
questions. The answers are supplied by our teams of technical gurus; our thanks to all.
Special thanks to Matt Deatherage, C. K. Haun, Jim Luther, and Jim Mensch for the
material in this Q & A column. *

Have more questions? Need more answers? Take a look at the Dev Tech Answers
library on AppleLink (updated weekly) or at the Q & A stack on the Developer
Essentials disc. *