 =============================================
 Pascal 1.1 protocol for character I/O devices
 
 22-Mar-88
 =============================================
   David A. Lyons  a.k.a.  DAL Systems
   PO Box 287 | North Liberty, IA 52317
   BITNET: AWCTTYPA@UIAMVS
   CompuServe: 72177,3233
   GEnie mail: D.LYONS2
 ==============================================
 References:
   Apple IIgs Firmware Reference, December 23, 1986 DRAFT (chapter 5)
   Apple II Miscellaneous Technical Note #3 [11/85] "Super Serial Card
      Firmware Bug"
   January 1986 Open Apple (vol 1, #12, page 101) & other Open Apple's
   [Open Apple is $28/yr.  P.O. Box 11250, Overland Park, KS 66207.]
 
 Most 80-column cards and serial cards support the "Pascal 1.1" protocol
 for character input and output.  (//c and IIgs *ports* behave like cards
 and follow this protocol.)
 
 In the following discussion, "n" is the slot number (1 to 7) of the card
 or port your program wants to deal with.
 
 The ROM for slot n is from $Cn00 to $CnFF.  $Cn0B contains $01 if the card
 or port follows the Pascal 1.1 protocol.
 
 $Cn0C identifies the kind of card:
    $1x: printer
    $2x: joystick
    $3x: serial or parallel card
    $4x: modem
    $5x: sound or speech device
    $6x: clock
    $7x: disk or other storage device
    $8x: 80-column card
    $9x: network or bus interface
   ($Ax..$Fx are not currently defined)
 
 The "x" can be used to distinguish between different cards of a particular
 type.
 
 $Cn0D to $Cn10 contain the *offsets* into the card's ROM of the Init, Read,
 Write, and Status routines.
 
 For example, if $Cn0D contains $34, then the Init entry point is $Cn34.
 
 ----------------------------------------------------------------------
 >>> Before making any of these calls, the X register must be     <<<
     loaded with $Cn, and the Y register must be loaded with $n0!
 
 Init (offset at $Cn0D):
   Initializes the card; do this once before doing any other calls to
   the card.
 
 Read (offset at $Cn0E):
   Reads one character from the card.
   Returns:  A = character read
             X = error code
 
 Write (offset at $Cn0F):
   Writes one character to the card (from A).
   Returns:  X = error code
 
 Status (offset at $Cn10):
   Determines if the card is ready to accept output or provide input.
   A = 0 checks output; A = 1 checks input.
   Returns:  X = error code
             carry set = ready; carry clear = not ready
 
 [Error codes:  0=no error; any others defined?]
 ----------------------------------------------------------------------
 Notes:
 
   o  (Open Apple Vol 3, #12, page 3.96c)  "Revision 1 IIc ROMs (the models
      that don't support 3.5 drives) will not correctly return status
      because of a missing CMP #$10 at $C227 in the firmware.  The
      result is that the status may be okay, but the result of the status
      call says it isn't.  This prevents using the Pascal inteface with
      early IIcs."
 
      [Does anybody have a work-around for this?  A reasonable approach
      might be to check for the original //c ROM version and then do
      the STATUS call with a fixed version of the STATUS routine,
      contained in your program.]
 
   o  Because the Super Serial card doesn't do it for you, twiddle location
      $CFFF before making a Pascal 1.1 call to make sure no other slot's
      ROMs are using the $C800..$CFFE space.
 
      Also, you should store $Cn into $07F8 so that interrupt-handling
      firmware can restore the correct $C800 space after an interupt
      occurs.
 
   o  See Open Apple vol 3, #12, p. 92-94 and #9 p. 66-68 for more info
      and real live examples.
 ----------------------------------------------------------------------
