home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma58.dms / ma58.adf / superplay-lib_DEV / Programmers / Example_SPObjects / ST / SP_RecogSubs.c < prev    next >
C/C++ Source or Header  |  1996-05-27  |  4KB  |  153 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 PPBase        *PPBase                = N;
  25. struct XpkBase       *XpkBase               = N;
  26.  
  27. #define VERSION  2
  28. #define REVISION 5
  29.  
  30. char __aligned SVLibName   [] = "ST.spobject";
  31. char __aligned SVLibID     [] = "ST 2.5 (27.5.96)\15\12\0";
  32. char __aligned AKCopyright [] = "(c) 1994-96 by Andreas R. Kleinert";
  33.  
  34. extern ULONG InitTab[];
  35.  
  36. extern APTR EndResident; /* below */
  37.  
  38. struct Resident ROMTag =
  39. {
  40.  RTC_MATCHWORD,
  41.  &ROMTag,
  42.  &EndResident,
  43.  RTF_AUTOINIT,
  44.  VERSION,
  45.  NT_LIBRARY,
  46.  REVISION,
  47.  &SVLibName[0],
  48.  &SVLibID[0],
  49.  &InitTab[0]
  50. };
  51.  
  52. APTR EndResident;
  53.  
  54. struct MyDataInit
  55. {
  56.  UWORD ainit1; UWORD binit1; UWORD ln_type;
  57.  UBYTE ainit2; UBYTE binit2; ULONG ln_name2;
  58.  UWORD ainit3; UWORD binit3; UWORD lib_flags;
  59.  UWORD ainit4; UWORD binit4; UWORD lib_version;
  60.  UWORD ainit5; UWORD binit5; UWORD lib_revision;
  61.  UBYTE ainit6; UBYTE binit6; ULONG lib_idstring2;
  62.  ULONG end;
  63. } DataTab =
  64. {
  65.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  66.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &SVLibName[0],
  67.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  68.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  69.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  70.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &SVLibID[0],
  71.  (ULONG) 0
  72. };
  73.  
  74. ULONG __saveds __stdargs SPLI_OpenLibs(void)
  75. {
  76.  SysBase = (*((struct ExecBase **) 4));
  77.  
  78.  DOSBase = (APTR) OpenLibrary("dos.library", 37);
  79.  if(!DOSBase) return(FALSE);
  80.  
  81.  IntuitionBase = (APTR) OpenLibrary("intuition.library", 37);
  82.  if(!IntuitionBase) return(FALSE);
  83.  
  84.  GfxBase = (APTR) OpenLibrary("graphics.library", 37);
  85.  if(!GfxBase) return(FALSE);
  86.  
  87.  UtilityBase = (APTR) OpenLibrary("utility.library", 37);
  88.  if(!UtilityBase) return(FALSE);
  89.  
  90.  PPBase  = (APTR) OpenLibrary("powerpacker.library", 33);
  91.  XpkBase = (APTR) OpenLibrary("xpkmaster", 2);
  92.  
  93.  return(TRUE);
  94. }
  95.  
  96. void __saveds __stdargs SPLI_CloseLibs(void)
  97. {
  98.  if(DOSBase)               CloseLibrary((APTR) DOSBase);
  99.  if(IntuitionBase)         CloseLibrary((APTR) IntuitionBase);
  100.  if(GfxBase)               CloseLibrary((APTR) GfxBase);
  101.  if(UtilityBase)           CloseLibrary((APTR) UtilityBase);
  102.  if(PPBase)                CloseLibrary((APTR) PPBase);
  103.  if(XpkBase)               CloseLibrary((APTR) XpkBase);
  104. }
  105.  
  106. void __saveds __stdargs SPLI_InitSPOList(void)
  107. {
  108.  struct SPO_ObjectNode *spo_node = N;
  109.  
  110.  SPObjectBase->spb_SPObject = N;
  111.  
  112.  if(FindName(&SysBase->LibList, "superplay.library"))
  113.   {
  114.    struct SuperPlayBase *SuperPlayBase = (APTR) OpenLibrary("superplay.library", 2);
  115.  
  116.    if(SuperPlayBase)
  117.     {
  118.      SPObjectBase->spb_SPObject = (APTR) FindName((APTR) &SuperPlayBase->spb_SPObjectList, "ST.spobject");
  119.  
  120.      CloseLibrary((APTR) SuperPlayBase);
  121.     }
  122.   }else
  123.   {
  124.    spo_node = AllocVec(sizeof(struct SPO_ObjectNode), (MEMF_CLEAR|MEMF_PUBLIC));
  125.  
  126.    if(!spo_node) return;
  127.  
  128.    SPObjectBase->spb_SPObject = spo_node;
  129.  
  130.    SPObjectBase->spb_SPObject = spo_node;
  131.  
  132.    ((struct Node *)spo_node)->ln_Type = NT_UNKNOWN;
  133.    ((struct Node *)spo_node)->ln_Pri  = -1;
  134.    ((struct Node *)spo_node)->ln_Name = N;
  135.  
  136.    spo_node->spo_Version = 2;
  137.    spo_node->spo_ObjectType = SPO_OBJECTTYPE_MODULE;
  138.  
  139.    strcpy(spo_node->spo_FileName, "ST.spobject");
  140.  
  141.    strcpy(spo_node->spo_TypeID, "SoundTracker");
  142.    spo_node->spo_TypeCode = N;                /* set by superplay.library */
  143.  
  144.    spo_node->spo_SubTypeNum = 1;
  145.  
  146.    strcpy(spo_node->spo_SubTypeID[0], "(ST)");
  147.  
  148.    spo_node->spo_SubTypeCode[0] = N;          /* set by superplay.library */
  149.  
  150.    spo_node->spo_BackgroundReplay = TRUE;
  151.   }
  152. }
  153.