home *** CD-ROM | disk | FTP | other *** search
- /* DA.h - Desk Accessory Header (tabs=4) */
-
- /* (C) Copyright 1985 by Roy A. Leban
- *
- * This header file is free. It is not, however, Public Domain.
- * You may distribute it free of charge to anyone, provided
- * that this comment, as well as the copyright notice is left
- * intact. If you modify this header and distribute it, you
- * must include comments to indicate which changes are yours.
- * You may not sell this source file without my permission.
- * You may, however, use this header in any Desk Accessory
- * that you want (which you may sell if you wish). If you
- * do so, you must include a credit notice which says:
- * "Portions of this program Copyright 1985 by Roy A. Leban"
- * You must include this notice whether or not you sell the DA.
- * If you distribute the source to your DA in any fashion, and
- * in doing so, include this header, you must include this comment.
- * If you have modified the header, you may, of course, include any
- * copyright of your own, with any appropriate notice.
- * You may not publish this DA in any magazine, electronic, printed
- * or otherwise, without my permission. This does not include posting
- * on public or private bulletin boards or conferencing systems.
- *
- */
-
-
- /*
- * This header is designed to provide a complete C interface
- * for Desk Accessories. It is written for Manx Aztec C and
- * has been completely tested with version 1.06F. Unlike the
- * header for the Explorer DA provided with Aztec C, this header
- * provides support for re-entry (necessary if you have a RunEvent,
- * if you have a Quit in your Menu or use dialog boxes) and allows
- * you to use the GoodBye kiss feature (necessary if you have
- * open files). You don't need to do anything special for the
- * GoodBye, as the assembly code handles it automatically. This
- * header file may work with other C compilers, but the parameter
- * passing and stack/register usage may need to be changed.
- * If you have questions, you can call or write me at:
- * Roy A. Leban
- * 314 Packard, #3
- * Ann Arbor, Michigan 48104
- * (313)761-5869
- * I'll try to help if I can, but I won't write your DA's for you.
- * Have fun.
- *
- */
-
- /*
- * To use this header file, the assembly variables drvrFlags, drvrDelay
- * and drvrEMask must be set to the appropriate values. For example:
- *
- * #asm
- * drvrFlags equ $7400 ; drvrFlags: dNeedLock + dNeedTime +
- * ; dNeedGoodBye + dCtlEnable
- * drvrDelay equ 0 ; drvrDelay: (No periodic action)
- * drvrEMask equ $0002 ; drvrEMask: MouseDown (+ Update & Activate)
- * #endasm
- *
- * #include <DA.h>
- */
-
-
- /*
- * Desk Accessories aren't supposed to get Prime or Status calls.
- * Drivers need to return via an RTS if they were called immediately
- * or the I/O request is incomplete. If the I/O is complete, they
- * return with a jump to IODone. This code assumes that any
- * DA calls will be immediate calls and therefore always return
- * with an RTS. If it is desired to support the Prime and Status
- * calls differently, this can easily be changed. The Prime and
- * Status entries have not been tested.
- */
-
- #asm
- main
- dc.w drvrFlags
- dc.w drvrDelay
- dc.w drvrEMask
- dc.w 0 ; drvrMenu: Only needed for ROM DA's
-
- dc.w callOpen-main
- dc.w callPrime-main
- dc.w callCtl-main
- dc.w callStatus-main
- dc.w callClose-main
-
- dc.b 8 ; drvrName: Only needed for ROM DA's
- dc.b "DA" ; (But we need to put something here anyway)
- ds 0 ; Forces alignment back to word boundary
-
- public _Uend_,_Dorg_,_Cend_
-
- Space equ 0 ; Stack spece required for routines
- SaveReg reg a0/a1 ; Registers to save in routines
- csCode equ 26 ; (Pb).u.cp.csCode Offset
- GoodBye equ -1 ; csCode of GoodBye Kiss
- jIODone equ $000008FC ; IODone Jump Vector
-
-
- callOpen
- link a6,#Space ; Allocate Stack Space on a6
- movem.l SaveReg,-(sp) ; Save Registers
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ; Set up globals
- move.l a0,-(a7) ; ParmBlkPtr
- move.l a1,-(a7) ; DCEPtr
- jsr drvrOpen_ ; Call actual routine
- add.w #8,a7 ; Pop off arguments
- movem.l (sp)+,SaveReg ; Restore Registers
- unlk a6 ; Restore a6
- move.l #0,d0 ; noErr result code
- rts
-
- callPrime
- link a6,#Space ; Allocate Stack Space on a6
- movem.l SaveReg,-(sp) ; Save Registers
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ; Set up globals
- move.l a0,-(a7) ; ParmBlkPtr
- move.l a1,-(a7) ; DCEPtr
- jsr drvrPrim_ ; Call actual routine
- add.w #8,a7 ; Pop off arguments
- movem.l (sp)+,SaveReg ; Restore Registers
- unlk a6 ; Restore a6
- move.l #0,d0 ; noErr result code
- rts
-
- callCtl
- link a6,#Space ; Allocate Stack Space on a6
- movem.l SaveReg,-(sp) ; Save Registers
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ; Set up globals
- move.l a0,-(a7) ; ParmBlkPtr
- move.l a1,-(a7) ; DCEPtr
- jsr drvrCtl_ ; Call actual routine
- add.w #8,a7 ; Pop off arguments
- movem.l (sp)+,SaveReg ; Restore Registers
- unlk a6 ; Restore a6
- move.w csCode(a0),d0 ; d0 = Pb->u.cp.csCode
- cmp.w #GoodBye,d0 ; Is this GoodBye?
- beq IODone ; ..need to exit at IODone
- move.l #0,d0 ; noErr result code
- rts
-
- callStatus
- link a6,#Space ; Allocate Stack Space on a6
- movem.l SaveReg,-(sp) ; Save Registers
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ; Set up globals
- move.l a0,-(a7) ; ParmBlkPtr
- move.l a1,-(a7) ; DCEPtr
- jsr drvrStat_ ; Call actual routine
- add.w #8,a7 ; Pop off arguments
- movem.l (sp)+,SaveReg ; Restore Registers
- unlk a6 ; Restore a6
- ;; jmp IODone ; (See note above)
- move.l #0,d0 ; noErr result code
- rts
-
- callClose
- link a6,#Space ; Allocate Stack Space on a6
- movem.l SaveReg,-(sp) ; Save Registers
- lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ; Set up globals
- move.l a0,-(a7) ; ParmBlkPtr
- move.l a1,-(a7) ; DCEPtr
- jsr drvrClos_ ; Call actual routine
- add.w #8,a7 ; Pop off arguments
- movem.l (sp)+,SaveReg ; Restore Registers
- unlk a6 ; Restore a6
- move.l #0,d0 ; noErr result code
- rts
-
- IODone
- move.l jIODone,-(sp) ; Push Jump Vector Address onto stack
- move.l #0,d0 ; noErr result code
- rts
-
- #endasm
-