#ifndef SYSTEM_MODULES_H
#define SYSTEM_MODULES_H 1

/*
**  $VER: modules.h V0.8B
**
**  (C) Copyright 1996-1997 DreamWorld Productions.
**      All Rights Reserved.
**
*/

#ifndef DPKERNEL_H
#include <games/dpkernel.h>
#endif

/*****************************************************************************
** Module Object.
*/

#define MODVERSION  1
#define TAGS_MODULE ((ID_SPCTAGS<<16)|ID_MODULE)

struct Function {
  WORD LVO;
  APTR Routine;
};

struct Module {
  struct Head Head;        /* [00] Standard header */
  WORD   Number;           /* [12] Number of the associated module */
  APTR   ModBase;          /* [14] Ptr to function jump table */
  struct Segment *Segment; /* [18] Segment pointer */
  WORD   TableType;        /* [20] Type of table */
  WORD   empty;            /* [22] */
  LONG   emp;              /* [26] */
  LONG   Version;          /* [30] Version of the module */
  LONG   Revision;         /* [34] Revision of the module */
  struct ModHeader *Table; /* [38] Header */
  BYTE   *Name;            /* [42] Name of the module */
};

#define MODA_Number    (12|TWORD)
#define MODA_TableType (20|TWORD)
#define MODA_Version   (30|TLONG)
#define MODA_Revision  (34|TLONG)
#define MODA_Name      (42|TAPTR)

#define JMP_LVO    1  /* Default jump type for Amiga's */
#define JMP_AMIGAE 2  /* Amiga E jump table */

/*****************************************************************************
** Module file header.
*/

#define MODULE_HEADER_V1 0x4D4F4401

struct ModHeader {
  LONG Version;
  __asm LONG (*Init)(register __a0 struct Module *, register __a1 struct DPKBase *,
               register __d0 LONG dpkVersion, register __d1 LONG dpkRevision);
  __asm void (*Close)(register __a0 struct Module *);
  __asm LONG (*Expunge)(register __a0 struct Module *);
  __asm LONG (*SetPrefs)(register __a0 struct Module *);
  __asm void (*FreePrefs)(register __a0 struct Module *);
  APTR  (*FuncList);    /* Pointer to function list */
  LONG  CPUNumber;      /* CPU that this module is compiled for */
  LONG  ModVersion;     /* Version of this module */
  LONG  ModRevision;    /* Revision of this module */
  LONG  MinDPKVersion;  /* Minimum DPK version required */
  LONG  MinDPKRevision; /* Minimum DPK revision required */
  __asm LONG (*Open)(register __a0 struct Module *);
  APTR  ModBase;        /* Generated function base for given CPU */
  WORD  OpenCount;      /* Amount of programs with this module open */
};

#define CPU_68000  1
#define CPU_68010  2
#define CPU_68020  3
#define CPU_68030  4
#define CPU_68040  5
#define CPU_68060  6

#endif /* SYSTEM_MODULES_H */

