#ifndef DPKERNEL_H
#define DPKERNEL_H TRUE

/*
**   $VER: dpkernel.h V0.8B
**
**   General include file for programs using the Games Master System.
**
**   (C) Copyright 1996-1997 DreamWorld Productions.
**       All Rights Reserved.
*/

#ifndef SYSTEM_TYPES_H
#include <system/types.h>
#endif

#ifndef SYSTEM_REGISTER_H
#include <system/register.h>
#endif

/***************************************************************************/

#define DPKVersion  0
#define DPKRevision 8

#define SKIPENTRY  0
#define ENDLIST    -1
#define LISTEND    -1
#define TAGEND     0
#define DEFAULT    0

#define TBYTE    0
#define TLONG    (1L<<31)
#define TWORD    (1L<<30)
#define TAPTR    (1L<<29)|TLONG
#define TSTEPIN  (1L<<28)
#define TSTEPOUT (1L<<27)

#ifndef TAG_IGNORE
#define TAG_IGNORE (1L)
#define TAG_MORE   (2L)
#define TAG_SKIP   (3L)
#endif

#define JMP_AMIGA 0

#define GET_NOTRACK 0x00010000

#define DMsg(a)    DebugMessage(DBG_Message,a)
#define EMsg(a)    DebugMessage(DBG_Error,a)
#define ErrCode(a) ErrorMessage(a)

/****************************************************************************
** Header used for all objects.
*/

struct Head {
  WORD   ID;
  WORD   Version;
  struct SysObject *SysObject;
  struct Stats     *Stats;
};

/* The Stats structure is private to the system */

struct Stats {
  LONG Key;          /* Resource tracking key */
  APTR ChildPrivate; /* Reserved pointer for use by child objects */
};

/****************************************************************************
** This structure is passed to programs that are about to be executed.
*/

#define STVERSION 1

struct StartUp {
  struct Head Head;
  LONG   Version;
  LONG   Revision;
  struct DPKBase *DPKBase;
};

/****************************************************************************
** Raw Data object.
*/

#define RAWVERSION   1
#define TAGS_RAWDATA ((ID_SPCTAGS<<16)|ID_RAWDATA)

struct RawData {
  struct Head Head;  /* Standard structure header */
  LONG   Size;       /* Size of the data in bytes */
  APTR   Data;       /* Pointer to the data */

  /*** Private flags below ***/

  BYTE prvAFlags;    /* Private */
  BYTE prvPad;       /* Private */
};

/****************************************************************************
** Universal errorcodes returned by certain functions.
*/

#define ERR_OK           0  /* Function went OK (also NULL) */
#define ERR_NOMEM        1  /* Not enough memory available */
#define ERR_NOPTR        2  /* Required pointer not present */
#define ERR_INUSE        3  /* Previous allocations have not been freed */
#define ERR_STRUCT       4  /* Structure version not supported or not found */
#define ERR_FAILED       5  /* General failure */
#define ERR_FILE         6  /* File error, eg file not found */
#define ERR_DATA         7  /* There is an error in the given data */
#define ERR_SEARCH       8  /* A search routine in this function failed */
#define ERR_SCRTYPE      9  /* Screen type not recognised */
#define ERR_MODULE      10  /* Trouble initialising/using a module */
#define ERR_RASTCOMMAND 11  /* Invalid raster command detected */
#define ERR_RASTERLIST  12  /* Complete rasterlist failure */
#define ERR_NORASTER    13  /* Expected rasterlist is missing from Screen */
#define ERR_DISKFULL    14  /* Disk full error */
#define ERR_FILEMISSING 15  /* File not found */
#define ERR_WRONGVER    16  /* Wrong version or version not supported */
#define ERR_MONITOR     17  /* Monitor driver not found or cannot be used */
#define ERR_UNPACK      18  /* Problem with unpacking of data */
#define ERR_ARGS        19  /* Invalid arguments passed to function */
#define ERR_NODATA      20  /* No data is available for use */
#define ERR_READ        21  /* Error reading data from file */
#define ERR_WRITE       22  /* Error writing data to file */
#define ERR_LOCK        23  /* Could not obtain lock on object */
#define ERR_EXAMINE     24  /* Could not examine directory or file */
#define ERR_LOSTCLASS   25  /* This object has lost its class reference */
#define ERR_NOACTION    26  /* This object does not support the required action */

/****************************************************************************
** Memory types used by AllocMemBlock().  This is generally identical to the
** exec definitions but CHIP is renamed to VIDEO (displayable memory) and
** there is an addition of BLIT and SOUND specific memory.
*/

#define MEM_DATA      0
#define MEM_PRIVATE   (1L<<0)
#define MEM_VIDEO     (1L<<1)
#define MEM_BLIT      (1L<<2)
#define MEM_SOUND     (1L<<3)
#define MEM_CODE      (1L<<4)
#define MEM_UNTRACKED (1L<<31)

/***************************************************************************/

#ifndef SYSTEM_MISC_H
#include <system/misc.h>
#endif

#ifndef SYSTEM_MODULES_H
#include <system/modules.h>
#endif

#ifndef GRAPHICS_BLITTER_H
#include <graphics/blitter.h>
#endif

#ifndef GRAHICS_PICTURES_H
#include <graphics/pictures.h>
#endif

#ifndef GRAPHICS_SCREENS_H
#include <graphics/screens.h>
#endif

#ifndef GMS_JOYPORTS_H
#include <games/joyports.h>
#endif

#ifndef GMS_SOUND_H
#include <games/sound.h>
#endif

#ifndef FILES_FILES_H
#include <files/files.h>
#endif

#endif /* DPKERNEL_H */
