home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gfx / superview-lib-9.12.lha / SuperView-Lib / Programmers / Example_SVDrivers / ECS / SD_AsmPart.a < prev    next >
Text File  |  1994-12-28  |  9KB  |  313 lines

  1. ; * ************************************************************************ *
  2. ; * 'ECS.svdriver' V1.11                                                     *
  3. ; * ************************************************************************ *
  4. ; * (c) 1993-94 by Andreas Ralph Kleinert. All rights reserved.              *
  5. ; * This code can be used to create the 'ECS.svdriver'.                      *
  6. ; * THIS IS NOT ALLOWED WITHOUT SPECIAL PERMISSION BY THE AUTHOR !!!         *
  7. ; * ************************************************************************ *
  8. ; * Address         : Andreas R. Kleinert                     *
  9. ; *               Grube Hohe Grethe 23                     *
  10. ; *               D-57074 Siegen                         *
  11. ; *               Germany                             *
  12. ; * ************************************************************************ *
  13.  
  14. ; * ************************************************************************ *
  15. ; * Module         : SD_AsmPart.a                         *
  16. ; * Version         : V1.11                             *
  17. ; * Last updated     : 28.12.1994                                         *
  18. ; * Includes         : V40-Includes                                          *
  19. ; * Compiler         : SAS/C V6.51 (ASM)                                     *
  20. ; * Compiler-Options : (smakefile)                                           *
  21. ; * ************************************************************************ *
  22.  
  23.   INCLUDE "exec/types.i"
  24.   INCLUDE "exec/execbase.i"
  25.   INCLUDE "exec/initializers.i"
  26.   INCLUDE "exec/libraries.i"
  27.   INCLUDE "exec/resident.i"
  28.  
  29. VERSION  EQU 1
  30. REVISION EQU 11
  31.  
  32.   XREF _LinkerDB
  33.  
  34.   XREF _LVOOpenLibrary
  35.   XREF _LVOCloseLibrary
  36.   XREF _LVORemove
  37.   XREF _LVOFreeMem
  38.  
  39.   XREF _SVLI_InitSVDList          ; library-internal initialization function
  40.  
  41.   XREF _SVD_AllocHandle
  42.   XREF _SVD_FreeHandle
  43.   XREF _SVD_CloseDisplay
  44.   XREF _SVD_FreeResources
  45.   XREF _SVD_SetGfxBuffer
  46.   XREF _SVD_DisplayGfxBuffer
  47.   XREF _SVD_SetScreenType
  48.   XREF _SVD_SetWindowFlags
  49.   XREF _SVD_SetWindowIDCMP
  50.   XREF _SVD_GetScreenAddress
  51.   XREF _SVD_GetWindowAddress
  52.  
  53.   STRUCTURE SVDriverBase,0
  54.    STRUCT svb_LibNode,LIB_SIZE
  55.    ULONG  svb_SVDriver
  56.  
  57.    ULONG  svb_Reserved,32
  58.  
  59.    ULONG  svb_SegList
  60.    ULONG  svb_SysBase
  61.    ULONG  svb_DOSBase
  62.    ULONG  svb_IntuitionBase
  63.    ULONG  svb_GfxBase
  64.    ULONG  svb_SVSupportBase
  65.   LABEL  svb_SIZEOF
  66.  
  67.   SECTION svb_lib,CODE
  68. ;-------------- `Notausgang` ------------------------------------------------
  69. Start:    moveq #0,d0
  70.     rts
  71. ;-------------- Resident-Struktur -------------------------------------------
  72.  
  73.  
  74. ROMTag:
  75.      dc.w RTC_MATCHWORD
  76.      dc.l ROMTag         ; ptr to itself
  77.      dc.l EndResident    ; ptr to end of Resident-Structure
  78.      dc.b RTF_AUTOINIT   ; Initialisierungsart
  79.      dc.b VERSION         ; Version
  80.      dc.b NT_LIBRARY     ; Node-Typ
  81.      dc.b REVISION         ; Prioritaet
  82.      dc.l SVLibName      ; Name
  83.      dc.l SVLibID         ; LibIDString
  84.      dc.l InitTab         ; ptr to InitTab
  85.  
  86. SVLibName:    dc.b 'ECS.svdriver',0
  87. SVLibID:    dc.b 'ECS 1.11 (28.12.94)',13,10,0
  88. AKCopyright:    dc.b '(c) 1994 by Andreas R. Kleinert',0
  89. DosName:    dc.b 'dos.library',0
  90. IntuitionName:    dc.b 'intuition.library',0
  91. GfxName:    dc.b 'graphics.library',0
  92. SVSupportName:    dc.b 'superviewsupport.library',0
  93.         ds.w 0
  94.  
  95. EndResident:
  96.  
  97.  
  98. ;-------------- Funktionstabellen fuer InitStruct u.a. ----------------------
  99. InitTab:
  100.      dc.l svb_SIZEOF       ; LibBase-Size
  101.      dc.l FuncTab          ; Function-Table begin
  102.      dc.l DataTab          ; Data-Table begin
  103.      dc.l InitLib          ; ptr to InitLib
  104. FuncTab:
  105.      dc.l OpenLib          ; internal functions
  106.      dc.l CloseLib
  107.      dc.l ExpungeLib
  108.      dc.l ExtFuncLib
  109.  
  110.          dc.l _SVD_AllocHandle
  111.          dc.l _SVD_FreeHandle
  112.          dc.l _SVD_CloseDisplay
  113.          dc.l _SVD_FreeResources
  114.          dc.l _SVD_SetGfxBuffer
  115.          dc.l _SVD_DisplayGfxBuffer
  116.          dc.l _SVD_SetScreenType
  117.          dc.l _SVD_SetWindowFlags
  118.          dc.l _SVD_SetWindowIDCMP
  119.          dc.l _SVD_GetScreenAddress
  120.          dc.l _SVD_GetWindowAddress
  121.  
  122.      dc.l -1
  123. DataTab:
  124.      INITBYTE LN_TYPE,NT_LIBRARY
  125.      INITLONG LN_NAME,SVLibName
  126.      INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  127.      INITWORD LIB_VERSION,VERSION
  128.      INITWORD LIB_REVISION,REVISION
  129.      INITLONG LIB_IDSTRING,SVLibID
  130.      dc.l 0
  131.  
  132. ;-------------- InitLib (Initialisieren der Library) ---------------------------
  133. ;     A0 : &SegList
  134. ;     A6 : &SysBase
  135. ;     D0 : &SVLibrary
  136.  
  137. InitLib:
  138.       movem.l a4-a5,-(sp)       ; a4 und a5 auf Stack retten
  139.  
  140.       lea     _LinkerDB,a4        ; _LinkerDB  -> A4
  141.       move.l d0,a5            ; &SVLibrary -> A5
  142.  
  143.       move.l a6,_SysBase(a4)    ; &SysBase retten
  144.  
  145.       move.l a6,svb_SysBase(a5)  ; &SysBase   -> SVLibrary.svb_SysBase
  146.       move.l a0,svb_SegList(a5)  ; &SegList   -> SVLibrary.svb_SegList
  147.  
  148.       lea DosName,a1
  149.       move.l #37,d0
  150.       LINKLIB _LVOOpenLibrary,_SysBase
  151.       move.l d0,_DOSBase
  152.       move.l d0,svb_DOSBase(a5)        ; save it !
  153.  
  154.       lea IntuitionName,a1
  155.       move.l #37,d0
  156.       LINKLIB _LVOOpenLibrary,_SysBase
  157.       move.l d0,_IntuitionBase
  158.       move.l d0,svb_IntuitionBase(a5)  ; save it !
  159.  
  160.       lea GfxName,a1
  161.       move.l #37,d0
  162.       LINKLIB _LVOOpenLibrary,_SysBase
  163.       move.l d0,_GfxBase
  164.       move.l d0,svb_GfxBase(a5)        ; save it !
  165.  
  166.       lea SVSupportName,a1
  167.       move.l #1,d0
  168.       LINKLIB _LVOOpenLibrary,_SysBase
  169.       move.l d0,_SVSupportBase
  170.       move.l d0,svb_SVSupportBase(a5)        ; save it !
  171.  
  172.           tst.l _DOSBase
  173.           beq InitLib_Fail
  174.           tst.l _IntuitionBase
  175.           beq InitLib_Fail
  176.           tst.l _GfxBase
  177.           beq InitLib_Fail
  178.           tst.l _SVSupportBase
  179.           beq InitLib_Fail
  180.  
  181.       move.l a5,_SVDriverBase        ; save Base Address for internal use
  182.  
  183.           jsr _SVLI_InitSVDList
  184.  
  185.       move.l a5,d0                    ; return &SVDriverBase
  186.  
  187.           jmp InitLib_RTS
  188.  
  189. InitLib_Fail:
  190.  
  191.       moveq #0,d0                ; NULL !
  192.  
  193. InitLib_RTS:
  194.  
  195.       movem.l (sp)+,a4-a5
  196.       rts
  197.  
  198.  
  199. ;-------------- OpenLib (Oeffnen der Library) ----------------------------------
  200. OpenLib:
  201.         addq.w #1,LIB_OPENCNT(a6)          ; LIB_OPENCNT ++
  202.         bclr   #LIBB_DELEXP,LIB_FLAGS(a6)  ; clear LIBF_DELEXP
  203.         move.l a6,d0               ; return &SVDriverBase
  204.  
  205.         rts
  206.  
  207. ;-------------- CloseLib (Schliessen der Library) ------------------------------
  208. CloseLib:
  209.         moveq #0,d0
  210.         subq.w #1,LIB_OPENCNT(a6)          ; LIB_OPENCNT --
  211.         bne.s EndCloseLib           ; wenn nicht null, Abbruch
  212.         btst #LIBB_DELEXP,LIB_FLAGS(a6)    ; Test auf LIBF_DELEXP
  213.         beq.s EndCloseLib           ; wenn Null, Abbruch
  214.         bsr.s ExpungeLib           ; wenn gesetzt, ExpungeLib
  215. EndCloseLib:
  216.         rts
  217.  
  218. ;-------------- ExpungeLib (Entfernen der Library) ----------------------------
  219. ExpungeLib:
  220.         movem.l d2/a5/a6,-(sp)
  221.  
  222.         move.l a6,a5               ; &SVLibrary retten
  223.         move.l _SysBase,a6           ; ExecBase to A6
  224.         tst.w LIB_OPENCNT(a5)              ; test LIB_OPENCNT
  225.         beq.s NoOpenLib            ; ...
  226.         bset #LIBB_DELEXP,LIB_FLAGS(a5)    ; set LIBF_DELEXP flag
  227.         moveq #0,d0               ; Ptr auf Segmentliste
  228.         jmp   ExpungeLibEnd           ;
  229. NoOpenLib:
  230.         move.l svb_SegList(a5),d2           ; SegList retten
  231.  
  232.         move.l a5,a1               ; &SVLibrary nach A1 (Par.)
  233.         LINKLIB _LVORemove,_SysBase       ; Library-Node entfernen
  234.  
  235.         move.l _DOSBase,a1
  236.         LINKLIB _LVOCloseLibrary,_SysBase
  237.  
  238.         move.l _IntuitionBase,a1
  239.         LINKLIB _LVOCloseLibrary,_SysBase
  240.  
  241.         move.l _GfxBase,a1
  242.         LINKLIB _LVOCloseLibrary,_SysBase
  243.  
  244.         move.l _SVSupportBase,a1
  245.         LINKLIB _LVOCloseLibrary,_SysBase
  246.  
  247.         moveq  #0,d0               ; D0 loeschen
  248.         move.l a5,a1               ; &SVLibrary nach A1 (Par.)
  249.         move.w LIB_NEGSIZE(a5),d0          ; Groesse der
  250.         sub.l d0,a1               ; Library
  251.         add.w LIB_POSSIZE(a5),d0           ; ermitteln !!!
  252.  
  253.         LINKLIB _LVOFreeMem,_SysBase       ; Speicher freigeben
  254.         move.l d2,d0               ; &SegList zurueckgeben
  255. ExpungeLibEnd:
  256.         movem.l (sp)+,d2/a5/a6
  257.         rts
  258.  
  259. ;-------------- ExtFuncLib (bis einschl. OS V2.04 unbenutzt) ---------------
  260. ExtFuncLib:
  261.  
  262.         moveq #0,d0         ; Ist nie falsch ........ - oder ?
  263.         rts
  264.  
  265. ;-------------- Eigene Funktionen ------------------------------------------
  266.  
  267.   SECTION __MERGED,BSS
  268.  
  269. _SVDriverBase:    ds.l 1
  270. _SysBase:    ds.l 1
  271. _DOSBase:    ds.l 1
  272. _IntuitionBase: ds.l 1
  273. _GfxBase:    ds.l 1
  274. _SVSupportBase:    ds.l 1
  275.  
  276. _XCEXIT:    ds.l 1      ; dummy-values to get the compiler's libs work :
  277. __XCEXIT:    ds.l 1
  278. _ONBREAK:    ds.l 1
  279. __ONBREAK:    ds.l 1
  280. __base:     ds.l 1
  281. ___base:     ds.l 1
  282. _ProgramName:    ds.l 1
  283. __ProgramName:    ds.l 1
  284. _StackPtr:    ds.l 1
  285. __StackPtr:    ds.l 1
  286. _oserr:     ds.l 1
  287. __oserr:    ds.l 1
  288. _OSERR:     ds.l 1
  289. __OSERR:    ds.l 1
  290.  
  291.   XDEF _SVDriverBase
  292.   XDEF _SysBase
  293.