home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: LibInit.c 1.0 (14.8.96)
- **
- ** Library initializers and functions to be called by StartUp.c
- **
- ** (C) Copyright 1996 Andreas R. Kleinert
- ** All Rights Reserved.
- **
- ** Modified by Dirk Holtwick for DITO, 1996
- */
-
- /// HEADER
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/libraries.h>
- #include <exec/execbase.h>
- #include <exec/resident.h>
- #include <exec/initializers.h>
-
- #include <proto/exec.h>
-
- #include "defs.h"
- #include "base.h"
-
- ULONG __saveds __stdargs L_OpenLibs(void);
- void __saveds __stdargs L_CloseLibs(void);
-
- extern struct DitoExtBase *DitoExtBase;
-
- extern ULONG DITO_OpenExtension(void);
- extern void DITO_CloseExtension(void);
-
- struct ExecBase *SysBase = NULL;
- struct DosLibrary *DOSBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
- struct GfxBase *GfxBase = NULL;
-
- char __aligned ExLibName [] = LIBNAME;
- char __aligned ExLibID [] = LIBID;
- char __aligned AKCopyright [] = COPYRIGHT;
-
- extern ULONG InitTab[];
-
- extern APTR EndResident; /* below */
-
- struct Resident ROMTag =
- {
- RTC_MATCHWORD,
- &ROMTag,
- &EndResident,
- RTF_AUTOINIT,
- VERSION,
- NT_LIBRARY,
- REVISION,
- &ExLibName[0],
- &ExLibID[0],
- &InitTab[0]
- };
-
- APTR EndResident;
-
- struct MyDataInit
- {
- UWORD ainit1; UWORD binit1; UWORD ln_type;
- UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
- UWORD ainit3; UWORD binit3; UWORD lib_flags;
- UWORD ainit4; UWORD binit4; UWORD lib_version;
- UWORD ainit5; UWORD binit5; UWORD lib_revision;
- UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
- ULONG end;
- } DataTab =
- {
- INITBYTE(OFFSET(Node, ln_Type), NT_LIBRARY),
- 0x80, (UBYTE) OFFSET(Node, ln_Name), (ULONG) &ExLibName[0],
- INITBYTE(OFFSET(Library, lib_Flags), LIBF_SUMUSED|LIBF_CHANGED),
- INITWORD(OFFSET(Library, lib_Version), VERSION),
- INITWORD(OFFSET(Library, lib_Revision), REVISION),
- 0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
- (ULONG) 0
- };
- ///
-
- /// L_OpenLibs()
- ULONG __saveds __stdargs L_OpenLibs(void)
- {
- SysBase = (*((struct ExecBase **) 4));
-
- DOSBase = (APTR) OpenLibrary("dos.library", 37);
- if(!DOSBase) return(FALSE);
-
- IntuitionBase = (APTR) OpenLibrary("intuition.library", 37);
- if(!IntuitionBase) return(FALSE);
-
- GfxBase = (APTR) OpenLibrary("graphics.library", 37);
- if(!GfxBase) return(FALSE);
-
- DitoExtBase->exb_DOSBase = DOSBase;
- DitoExtBase->exb_IntuitionBase = IntuitionBase;
- DitoExtBase->exb_GfxBase = GfxBase;
-
- return(DITO_OpenExtension());
- }
- ///
- /// L_CloseLibs()
- void __saveds __stdargs L_CloseLibs(void)
- {
- DITO_CloseExtension();
- if(GfxBase) CloseLibrary((APTR) GfxBase);
- if(IntuitionBase) CloseLibrary((APTR) IntuitionBase);
- if(DOSBase) CloseLibrary((APTR) DOSBase);
- }
- ///
-