[fa.info-mac] Answers and Questions

info-mac@uw-beaver.UUCP (10/06/84)

From: David.Anderson@CMU-CS-K
I've been writing a real terminal emulator (read Concept-LNZ, a super-set of
the HDS Concept-100, with data compression) for the Mac with SUMacC, and I've
learned a few things that might save others some debugging effort:

(1)  The code that sets up trap and subroutine calls to the toolbox and
operating system is NOT REENTRANT.  This may not sound too bad, but this
means that you can not safely make such calls from an ioCompletetion or
Vertical Retrace Control Block routine.  I solved the problem by avoided
such asynchrony; another solution is to write the code in assembler, making
the trap calls explicitly.

(2)  Be sure you restore a5 (from _savea5) before making any toolbox calls.

(3)  rmaker doesn't support the type KEYC (keyboard configuration).  (Maybe
someone could add this?)  I allow the user to use either the option or the
command key as the control key (the other is used as meta).  Unfortunately,
the standard keyboard configuration grabs option-e, option-n, etc. as
special accenting characters, which plays havoc if they are supposed to be
^E, ^N, ^X, etc. in emacs.  My solution?  029E is the address of key1trans,
into which I sneak my own pointer.  If do you write your own keytrans, you
can get all the keyboard events, including those involving only the modifier
keys.  (BTW, using the option key as control seems much less awkward to me.
I looking into converting the CAPS LOCK key, but that would appear to
require unsoldering and replacing the keyswitch.)

Maybe someone can help me with these questions:

(1)  Has anyone looked at BlockMove to see what it does if the source and
destination areas overlap?  Inside Mac simply states that the pointers are
not checked.

(2)  Does anyone know what to do with the "Finder Information Handle?"  This
is the information that the Finder provides to an application when it is
launched, such as which document should be opened, or printed, etc.

(3)  Finally, has anyone figured out how to use VInstall to get the 1/60 sec.
vertical retrace interrupts?  There are some obvious things to try, based
on the format of VBLCntrlBlk, but has anyone done it?

By the way, as fast as quickdraw is, it is extremely difficult to write a
terminal emulator that can keep up at high baud rates (without resorting to
flow control).  It is especially important to avoid using EraseRect on a per
character basis, but this is difficult to avoid, since the only text modes
are srcOr, srcXor, and srcBic, and you sometimes have to erase an earlier
character before writing a new one.  Similarly, calling DrawText with several
characters to draw seems to be noticeably faster than calling DrawChar
several times (and avoids the string parameter conversion that DrawStr
requires).  By being very tricky I can now throw up characters to the screen
about 3-4 times faster than my initial, straightforward code, but it's still
slower than I'd like.  (All I know for sure is that I can more than keep up
at 1200 baud -- I'll have to take my Mac to school for higher speed testing.)