home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / sampleda.pit / SampleDA.pit / DA.h next >
Encoding:
Text File  |  1985-11-13  |  5.9 KB  |  176 lines

  1. /*    DA.h - Desk Accessory Header     (tabs=4) */
  2.  
  3. /*    (C) Copyright 1985 by Roy A. Leban
  4.  *
  5.  * This header file is free.  It is not, however, Public Domain.
  6.  * You may distribute it free of charge to anyone, provided
  7.  * that this comment, as well as the copyright notice is left
  8.  * intact.  If you modify this header and distribute it, you
  9.  * must include comments to indicate which changes are yours.
  10.  * You may not sell this source file without my permission.
  11.  * You may, however, use this header in any Desk Accessory
  12.  * that you want (which you may sell if you wish).  If you
  13.  * do so, you must include a credit notice which says:
  14.  *        "Portions of this program Copyright 1985 by Roy A. Leban"
  15.  * You must include this notice whether or not you sell the DA.
  16.  * If you distribute the source to your DA in any fashion, and
  17.  * in doing so, include this header, you must include this comment.
  18.  * If you have modified the header, you may, of course, include any
  19.  * copyright of your own, with any appropriate notice.
  20.  * You may not publish this DA in any magazine, electronic, printed
  21.  * or otherwise, without my permission.  This does not include posting
  22.  * on public or private bulletin boards or conferencing systems.
  23.  *
  24.  */
  25.  
  26.  
  27. /*
  28.  * This header is designed to provide a complete C interface
  29.  * for Desk Accessories.  It is written for Manx Aztec C and
  30.  * has been completely tested with version 1.06F.  Unlike the
  31.  * header for the Explorer DA provided with Aztec C, this header 
  32.  * provides support for re-entry (necessary if you have a RunEvent,
  33.  * if you have a Quit in your Menu or use dialog boxes) and allows
  34.  * you to use the GoodBye kiss feature (necessary if you have
  35.  * open files).  You don't need to do anything special for the
  36.  * GoodBye, as the assembly code handles it automatically.  This
  37.  * header file may work with other C compilers, but the parameter
  38.  * passing and stack/register usage may need to be changed.
  39.  * If you have questions, you can call or write me at:
  40.  *        Roy A. Leban
  41.  *        314 Packard, #3
  42.  *        Ann Arbor, Michigan  48104
  43.  *        (313)761-5869
  44.  * I'll try to help if I can, but I won't write your DA's for you.
  45.  * Have fun.
  46.  *
  47.  */
  48.  
  49. /*
  50.  * To use this header file, the assembly variables drvrFlags, drvrDelay
  51.  * and drvrEMask  must be set to the appropriate values.  For example:
  52.  *
  53.  *      #asm
  54.  *      drvrFlags    equ    $7400    ; drvrFlags: dNeedLock + dNeedTime +
  55.  *                            ;             dNeedGoodBye + dCtlEnable
  56.  *      drvrDelay    equ    0        ; drvrDelay: (No periodic action)
  57.  *      drvrEMask    equ    $0002    ; drvrEMask: MouseDown (+ Update & Activate)
  58.  *      #endasm
  59.  *
  60.  *      #include    <DA.h>
  61.  */
  62.  
  63.  
  64. /*
  65.  * Desk Accessories aren't supposed to get Prime or Status calls.
  66.  * Drivers need to return via an RTS if they were called immediately
  67.  * or the I/O request is incomplete.  If the I/O is complete, they
  68.  * return with a jump to IODone.  This code assumes that any
  69.  * DA calls will be immediate calls and therefore always return
  70.  * with an RTS.  If it is desired to support the Prime and Status
  71.  * calls differently, this can easily be changed.  The Prime and 
  72.  * Status entries have not been tested.
  73.  */
  74.  
  75. #asm
  76. main
  77.     dc.w    drvrFlags
  78.     dc.w    drvrDelay
  79.     dc.w    drvrEMask
  80.     dc.w    0                ; drvrMenu: Only needed for ROM DA's
  81.  
  82.     dc.w    callOpen-main
  83.     dc.w    callPrime-main
  84.     dc.w    callCtl-main
  85.     dc.w    callStatus-main
  86.     dc.w    callClose-main
  87.  
  88.     dc.b    8                ; drvrName: Only needed for ROM DA's
  89.     dc.b    "DA"            ; (But we need to put something here anyway)
  90.     ds        0                ; Forces alignment back to word boundary
  91.  
  92.     public    _Uend_,_Dorg_,_Cend_
  93.  
  94. Space    equ    0                ; Stack spece required for routines
  95. SaveReg    reg    a0/a1            ; Registers to save in routines
  96. csCode    equ    26                ; (Pb).u.cp.csCode Offset
  97. GoodBye    equ    -1                ; csCode of GoodBye Kiss
  98. jIODone    equ    $000008FC        ; IODone Jump Vector
  99.  
  100.  
  101. callOpen
  102.     link    a6,#Space            ; Allocate Stack Space on a6
  103.     movem.l    SaveReg,-(sp)        ; Save Registers
  104.     lea        main+(_Uend_-_Dorg_)+(_Cend_-main),a4        ; Set up globals
  105.     move.l    a0,-(a7)            ; ParmBlkPtr
  106.     move.l    a1,-(a7)            ; DCEPtr
  107.     jsr        drvrOpen_            ; Call actual routine
  108.     add.w    #8,a7                ; Pop off arguments
  109.     movem.l    (sp)+,SaveReg        ; Restore Registers
  110.     unlk    a6                    ; Restore a6
  111.     move.l    #0,d0                ; noErr result code
  112.     rts
  113.  
  114. callPrime
  115.     link    a6,#Space            ; Allocate Stack Space on a6
  116.     movem.l    SaveReg,-(sp)        ; Save Registers
  117.     lea        main+(_Uend_-_Dorg_)+(_Cend_-main),a4        ; Set up globals
  118.     move.l    a0,-(a7)            ; ParmBlkPtr
  119.     move.l    a1,-(a7)            ; DCEPtr
  120.     jsr        drvrPrim_            ; Call actual routine
  121.     add.w    #8,a7                ; Pop off arguments
  122.     movem.l    (sp)+,SaveReg        ; Restore Registers
  123.     unlk    a6                    ; Restore a6
  124.     move.l    #0,d0                ; noErr result code
  125.     rts
  126.  
  127. callCtl
  128.     link    a6,#Space            ; Allocate Stack Space on a6
  129.     movem.l    SaveReg,-(sp)        ; Save Registers
  130.     lea        main+(_Uend_-_Dorg_)+(_Cend_-main),a4        ; Set up globals
  131.     move.l    a0,-(a7)            ; ParmBlkPtr
  132.     move.l    a1,-(a7)            ; DCEPtr
  133.     jsr        drvrCtl_            ; Call actual routine
  134.     add.w    #8,a7                ; Pop off arguments
  135.     movem.l    (sp)+,SaveReg        ; Restore Registers
  136.     unlk    a6                    ; Restore a6
  137.     move.w    csCode(a0),d0        ; d0 = Pb->u.cp.csCode
  138.     cmp.w    #GoodBye,d0            ; Is this GoodBye?
  139.     beq        IODone                ; ..need to exit at IODone
  140.     move.l    #0,d0                ; noErr result code
  141.     rts
  142.  
  143. callStatus
  144.     link    a6,#Space            ; Allocate Stack Space on a6
  145.     movem.l    SaveReg,-(sp)        ; Save Registers
  146.     lea        main+(_Uend_-_Dorg_)+(_Cend_-main),a4        ; Set up globals
  147.     move.l    a0,-(a7)            ; ParmBlkPtr
  148.     move.l    a1,-(a7)            ; DCEPtr
  149.     jsr        drvrStat_            ; Call actual routine
  150.     add.w    #8,a7                ; Pop off arguments
  151.     movem.l    (sp)+,SaveReg        ; Restore Registers
  152.     unlk    a6                    ; Restore a6
  153. ;;    jmp        IODone                ; (See note above)
  154.     move.l    #0,d0                ; noErr result code
  155.     rts
  156.  
  157. callClose
  158.     link    a6,#Space            ; Allocate Stack Space on a6
  159.     movem.l    SaveReg,-(sp)        ; Save Registers
  160.     lea        main+(_Uend_-_Dorg_)+(_Cend_-main),a4        ; Set up globals
  161.     move.l    a0,-(a7)            ; ParmBlkPtr
  162.     move.l    a1,-(a7)            ; DCEPtr
  163.     jsr        drvrClos_            ; Call actual routine
  164.     add.w    #8,a7                ; Pop off arguments
  165.     movem.l    (sp)+,SaveReg        ; Restore Registers
  166.     unlk    a6                    ; Restore a6
  167.     move.l    #0,d0                ; noErr result code
  168.     rts
  169.  
  170. IODone
  171.     move.l    jIODone,-(sp)        ; Push Jump Vector Address onto stack
  172.     move.l    #0,d0                ; noErr result code
  173.     rts
  174.  
  175. #endasm
  176.