home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma58.dms / ma58.adf / superplay-lib_DEV / Programmers / Example_SPObjects / SPO / SP_RecogSubs.c < prev    next >
C/C++ Source or Header  |  1996-05-27  |  4KB  |  149 lines

  1.  
  2.  /* SP_RecogSubs.c
  3.     - Functions for External Module Recognition and Binding -
  4.     (c) 1993-96 by Andreas R. Kleinert
  5.     Last changes : 27.05.1996
  6.  */
  7.  
  8.  
  9. #include "spobject.h"
  10.  
  11. #include <exec/execbase.h>
  12. #include <exec/resident.h>
  13. #include <exec/initializers.h>
  14.  
  15. ULONG __saveds __stdargs SPLI_OpenLibs(void);
  16. void  __saveds __stdargs SPLI_CloseLibs(void);
  17. void  __saveds __stdargs SPLI_InitSPOList(void);
  18.  
  19. struct ExecBase      *SysBase               = N;
  20. struct DosLibrary    *DOSBase               = N;
  21. struct IntuitionBase *IntuitionBase         = N;
  22. struct GfxBase       *GfxBase               = N;
  23. struct Library       *UtilityBase           = N;
  24. struct XpkBase       *XpkBase               = N;
  25.  
  26. #define VERSION  2
  27. #define REVISION 5
  28.  
  29. char __aligned SVLibName   [] = "SPO.spobject";
  30. char __aligned SVLibID     [] = "SPO 2.5 (27.5.96)\15\12\0";
  31. char __aligned AKCopyright [] = "(c) 1994-96 by Andreas R. Kleinert";
  32.  
  33. extern ULONG InitTab[];
  34.  
  35. extern APTR EndResident; /* below */
  36.  
  37. struct Resident ROMTag =
  38. {
  39.  RTC_MATCHWORD,
  40.  &ROMTag,
  41.  &EndResident,
  42.  RTF_AUTOINIT,
  43.  VERSION,
  44.  NT_LIBRARY,
  45.  REVISION,
  46.  &SVLibName[0],
  47.  &SVLibID[0],
  48.  &InitTab[0]
  49. };
  50.  
  51. APTR EndResident;
  52.  
  53. struct MyDataInit
  54. {
  55.  UWORD ainit1; UWORD binit1; UWORD ln_type;
  56.  UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
  57.  UWORD ainit3; UWORD binit3; UWORD lib_flags;
  58.  UWORD ainit4; UWORD binit4; UWORD lib_version;
  59.  UWORD ainit5; UWORD binit5; UWORD lib_revision;
  60.  UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
  61.  ULONG end;
  62. } DataTab =
  63. {
  64.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  65.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &SVLibName[0],
  66.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  67.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  68.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  69.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &SVLibID[0],
  70.  (ULONG) 0
  71. };
  72.  
  73. ULONG __saveds __stdargs SPLI_OpenLibs(void)
  74. {
  75.  SysBase = (*((struct ExecBase **) 4));
  76.  
  77.  DOSBase = (APTR) OpenLibrary("dos.library", 37);
  78.  if(!DOSBase) return(FALSE);
  79.  
  80.  IntuitionBase = (APTR) OpenLibrary("intuition.library", 37);
  81.  if(!IntuitionBase) return(FALSE);
  82.  
  83.  GfxBase = (APTR) OpenLibrary("graphics.library", 37);
  84.  if(!GfxBase) return(FALSE);
  85.  
  86.  UtilityBase = (APTR) OpenLibrary("utility.library", 37);
  87.  if(!UtilityBase) return(FALSE);
  88.  
  89.  XpkBase = (APTR) OpenLibrary("xpkmaster", 2);
  90.  if(!XpkBase) return(FALSE);
  91.  
  92.  return(TRUE);
  93. }
  94.  
  95. void __saveds __stdargs SPLI_CloseLibs(void)
  96. {
  97.  if(DOSBase)               CloseLibrary((APTR) DOSBase);
  98.  if(IntuitionBase)         CloseLibrary((APTR) IntuitionBase);
  99.  if(GfxBase)               CloseLibrary((APTR) GfxBase);
  100.  if(UtilityBase)           CloseLibrary((APTR) UtilityBase);
  101.  if(XpkBase)               CloseLibrary((APTR) XpkBase);
  102. }
  103.  
  104. void __saveds __stdargs SPLI_InitSPOList(void)
  105. {
  106.  struct SPO_ObjectNode *spo_node = N;
  107.  
  108.  SPObjectBase->spb_SPObject = N;
  109.  
  110.  if(FindName(&SysBase->LibList, "superplay.library"))
  111.   {
  112.    struct SuperPlayBase *SuperPlayBase = (APTR) OpenLibrary("superplay.library", 2);
  113.  
  114.    if(SuperPlayBase)
  115.     {
  116.      SPObjectBase->spb_SPObject = (APTR) FindName((APTR) &SuperPlayBase->spb_SPObjectList, "SPO.spobject");
  117.  
  118.      CloseLibrary((APTR) SuperPlayBase);
  119.     }
  120.   }else
  121.   {
  122.    spo_node = AllocVec(sizeof(struct SPO_ObjectNode), (MEMF_CLEAR|MEMF_PUBLIC));
  123.  
  124.    if(!spo_node) return;
  125.  
  126.    SPObjectBase->spb_SPObject = spo_node;
  127.  
  128.    ((struct Node *)spo_node)->ln_Type = NT_UNKNOWN;
  129.    ((struct Node *)spo_node)->ln_Pri  = -1;
  130.    ((struct Node *)spo_node)->ln_Name = N;
  131.  
  132.    spo_node->spo_Version = 2;
  133.    spo_node->spo_ObjectType = SPO_OBJECTTYPE_SAMPLE;
  134.  
  135.    strcpy(spo_node->spo_FileName, "SPO.spobject");
  136.  
  137.    strcpy(spo_node->spo_TypeID, "SPO Sample");
  138.    spo_node->spo_TypeCode = N;                /* set by superplay.library */
  139.  
  140.    spo_node->spo_SubTypeNum = 1;
  141.  
  142.    strcpy(spo_node->spo_SubTypeID[0], " ");
  143.  
  144.    spo_node->spo_SubTypeCode[0] = N;          /* set by superplay.library */
  145.  
  146.    spo_node->spo_BackgroundReplay = TRUE;
  147.   }
  148. }
  149.