home *** CD-ROM | disk | FTP | other *** search
- **
- ** $VER: libhdr.i 2.0 (30.09.94)
- **
- ** library header include file
- **
- ** © Copyright 1994 by Norbert Püschel
- ** All Rights Reserved
- **
- ** Include & assemble with asm -iINCLUDE:
- **
-
- IFND LIBHDR_I
- LIBHDR_I SET 1
-
- * includes
-
- IFND EXEC_TYPES_I
- INCLUDE 'exec/types.i'
- ENDC
- IFND EXEC_LIBRARIES_I
- INCLUDE 'exec/libraries.i'
- ENDC
- IFND EXEC_RESIDENT_I
- INCLUDE 'exec/resident.i'
- ENDC
- IFND EXEC_INITIALIZERS_I
- INCLUDE 'exec/initializers.i'
- ENDC
-
- * CALLSYS macro
-
- CALL MACRO
- jsr _LVO\1(A6)
- ENDM
-
- CALLSYS MACRO
- move.l A6,-(SP)
- move.l _SysBase,A6
- CALL \1
- move.l (SP)+,A6
- ENDM
-
- * _LVOs
-
- _LVORemove EQU -252
- _LVOFreeMem EQU -210
-
- * library code & romtag
-
- SECTION TEXT,CODE
-
- StartCode:
- moveq #-1,D0
- rts
-
- RomTag:
- dc.w RTC_MATCHWORD
- dc.l RomTag
- dc.l EndCode
- dc.b RTF_AUTOINIT
- dc.b VER
- dc.b NT_LIBRARY
- dc.b PRI
- dc.l _LibName
- dc.l _LibID
- dc.l InitTab
-
- IFND BASE_SIZE
- BASE_SIZE EQU LIB_SIZE
- ENDC
-
- InitTab:
- dc.l BASE_SIZE
- dc.l _FuncTable
- dc.l _DataTable
- dc.l _aLibInit
-
- _DataTable:
- INITBYTE LN_TYPE,NT_LIBRARY
- INITBYTE LN_PRI,PRI
- INITLONG LN_NAME,_LibName
- INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
- INITWORD LIB_VERSION,VER
- INITWORD LIB_REVISION,REV
- INITLONG LIB_IDSTRING,_LibID
- dc.l 0
-
- IFD INIT
- XREF _LibInit
- ENDC
-
- _aLibInit:
- move.l A0,_SegList
- move.l A6,_SysBase
- move.l D0,_LibBase ; set global variables
-
- IFD INIT
- jsr _LibInit
- tst.l D0
- beq.s 1$
- move.l _LibBase,D0
- bra.s $2
-
- 1$: move.l _LibBase,A6
- move.l A6,A1
- move.w LIB_NEGSIZE(A6),D0 ; D0 is 0 before !
- sub.l D0,A1
- add.w LIB_POSSIZE(A6),D0
- CALLSYS FreeMem
-
- moveq.l #0,D0
- 2$:
- ENDC
-
- rts
-
- IFD OPEN
- XREF _LibOpen
- ENDC
-
- _aLibOpen:
- IFND OPEN
- move.l A6,D0
- ENDC
-
- IFD OPEN
- jsr _LibOpen
- tst.l D0
- beq.s 1$
- move.l A6,D0
- ENDC
-
- addq.w #1,LIB_OPENCNT(A6)
- bclr #LIBB_DELEXP,LIB_FLAGS(A6)
- 1$: rts
-
- IFD CLOSE
- XREF _LibClose
- ENDC
-
- _aLibClose:
- IFND CLOSE
- moveq.l #0,D0
- ENDC
-
- subq.w #1,LIB_OPENCNT(A6)
-
- IFD CLOSE
- move.l A6,D0
- jsr _LibClose
- tst.l D0
- bne.s 1$
- addq.w #1,LIB_OPENCNT(A6)
- bra.s 2$
- 1$: moveq.l #0,D0
- tst.w LIB_OPENCNT(A6)
- ENDC
-
- bne.s 2$
- btst #LIBB_DELEXP,LIB_FLAGS(A6)
- beq.s 2$
- bsr _aLibExpunge
-
- 2$: rts
-
- IFD EXPUNGE
- XREF _LibExpunge
- ENDC
-
- _aLibExpunge:
- tst.w LIB_OPENCNT(A6)
- beq.s 1$
-
- bset #LIBB_DELEXP,LIB_FLAGS(A6)
- moveq.l #0,D0
- bra.s 3$
-
- 1$:
- IFD EXPUNGE
- move.l A6,D0
- jsr _LibExpunge
- tst.l D0
- bne.s 2$
- bset #LIBB_DELEXP,LIB_FLAGS(A6)
- bra.s 3$
- 2$:
- ENDC
-
- move.l A6,A1
- CALLSYS Remove
-
- moveq.l #0,D0
- move.l A6,A1
- move.w LIB_NEGSIZE(A6),D0
- sub.l D0,A1
- add.w LIB_POSSIZE(A6),D0
- CALLSYS FreeMem
-
- move.l _SegList,D0
-
- 3$: rts
-
- _aLibExtFunc:
- moveq.l #0,D0
- rts
-
- IFD REXX
-
- XREF _LIBRexxQuery
-
- _aLibRexxQuery:
- link A5,#-4
- lea -4(A5),A1
- jsr _LIBRexxQuery
- move.l -4(A5),A0
- unlk A5
- rts
-
- ENDC
-
- EndCode:
-
- SECTION __MERGED,DATA
-
- * LIBRARY macro for generating the function table
-
- LIBRARY MACRO
-
- IFLT \2
- VER EQU VERSION
- REV EQU REVISION
- ELSE
- VER EQU \2
- REV EQU \3
- ENDC
-
- PRI EQU \4
-
- XDEF _\5
- XDEF _SysBase
-
- _\5:
- _LibBase:
- dc.l 0
- _SysBase:
- dc.l 0
- _SegList:
- dc.l 0
- dc.b '$VER: '
- _LibID:
- IFLT \2
- VERS
- ELSE
- dc.b \1,' \2.\3'
- ENDC
- dc.b ' ('
- IFC \6,'-'
- DATE
- ELSE
- dc.b \6
- ENDC
- dc.b ')',13,10,0
- _LibName:
- dc.b \1,0
- dc.w 0
-
- _FuncTable:
- dc.l _aLibOpen
- dc.l _aLibClose
- dc.l _aLibExpunge
- dc.l _aLibExtFunc
-
- IFD REXX
- dc.l _aLibRexxQuery
- ENDC
-
- ENDM
-
- FUNCDEF MACRO
- XREF _LIB\1
- dc.l _LIB\1
- ENDM
-
- ENDLIB MACRO
- dc.l -1
- ENDM
-
- ENDC ; LIBHDR_I
-