#ifndef  STORMAMIGA_H
#define  STORMAMIGA_H

/*
**       $VER: stormamiga.h 43.24 (26.11.98)
**              Includes Release 45.00
**               AmigaOS/68K Version
**
**     Copyright © 1996/99 by CyberdyneSystems
**
**            written by Matthias Henze
**               All Rights Reserved
*/

typedef const void              cvoid;
typedef const char              cchar;
typedef const signed char       cschar;
typedef const unsigned char     cuchar;
typedef signed char             schar;
typedef unsigned char           uchar;
typedef unsigned short          ushort;
typedef long int                lint;
typedef long long int           llint;
typedef unsigned int            uint;
typedef unsigned long int       ulint;
typedef unsigned long long int  ullint;
typedef long long               llong;
typedef unsigned long           ulong;
typedef unsigned long long      ullong;

#ifdef STORMAMIGA_PPC
  #include <PPC_stormamiga.h>
#else /* PPC */

#ifndef _INCLUDE_STDIO_H
  #include <stdio.h>
#endif
#ifndef INTUITION_INTUITION_H
  #include <intuition/intuition.h>
#endif
#ifndef HARDWARE_INTBITS_H
  #include <hardware/intbits.h>
#endif
#ifndef  CLIB_ALIB_PROTOS_H
  #include <clib/alib_protos.h>
#endif
#ifndef _INCLUDE_PRAGMA_EXEC_LIB_H
  #include <pragma/exec_lib.h>
#endif
#ifndef _INCLUDE_PRAGMA_GRAPHICS_LIB_H
  #include <pragma/graphics_lib.h>
#endif

#ifdef STORMAMIGA_NOWB
  void wbmain_(void) {};
#endif

#ifdef STORMAMIGA_OS3
  #ifdef __cplusplus
    extern "C" {
    void *malloc_3(size_t);
    void free_3(void *); }
    void *operator new(size_t bytes)
    { return malloc_3(bytes); }

    void operator delete(void *mem, size_t)
    { free_3(mem); }
  #endif
#endif

#ifdef STORMAMIGA_STACK
  long stack = STORMAMIGA_STACK;
  extern "C" {void INIT_9_Stack(void);}
  static void _initstack(void)
  { INIT_9_Stack(); }
#endif

#ifdef __cplusplus
  extern "C" {
#endif

#ifdef STORMAMIGA_NO_IO_WB
  void ioinit_(void) {};
#endif

#ifdef STORMAMIGA_OS3
  void *malloc_3(size_t);
  void free_3(void *);
  void _malloc_3(void);
  void _free_3(void);

  void _free(void)
  { _free_3(); }

  void _malloc(void)
  { _malloc_3(); }

  #define malloc         malloc_3
  #define free           free_3

  #define LibCreatePool  CreatePool
  #define LibDeletePool  DeletePool
  #define LibAllocPooled AllocPooled
  #define LibFreePooled  FreePooled
#endif

/*----- stormamiga-special-functions -----*/

long  muls            (long, long);
ulong mulu            (ulong, ulong);
long  divsl           (long, long);
ulong divul           (ulong, ulong);
long  muls64          (long, long);
ulong mulu64          (ulong, ulong);
long  divs64          (long, long);
ulong divu64          (ulong, ulong);
int   button          (int, int);
int   button_al       ();
int   button_ar       ();
int   button_bl       ();
int   button_br       ();
void  waitbutton      (int, int);
void  waitbutton_al   ();
void  waitbutton_ar   ();
void  waitbutton_bl   ();
void  waitbutton_br   ();
int   max_Width       (struct Window *);
int   max_Height      (struct Window *);

/*----- support for UNIX-functions -----*/

  char *UnixToAmigaPath (cchar *);

#ifdef __cplusplus
  }
#endif

#ifdef STORMAMIGA_INLINE

/*----- amiga.lib-functions -----*/

#define DeleteTask       RemTask
#define CreateExtIO      CreateIORequest
#define DeleteExtIO      DeleteIORequest
#define DeleteStdIO      DeleteIORequest

__inline void RemTOF     (struct Isrvstr *intr)
{ RemIntServer           (INTB_VERTB, (struct Interrupt *) intr); }

__inline struct IOStdReq *CreateStdIO (struct MsgPort *port)
{ return (struct IOStdReq *) CreateIORequest (port, sizeof (struct IOStdReq)); }

__inline void waitbeam   (long pos)
{ do {} while (pos > VBeamPos ()); }

__inline void NewList    (struct List *list)
{
  long *p;
  list -> lh_TailPred = (struct Node *) list;
  list = (struct List *)((char *) list + sizeof (LONG));
  *(long *) list = 0;
  p = (long *) list;
  *-- p = (long) list;
}

/*----- Amiga-functions -----*/

#define Move             Move_
#define GetAPen          GetAPen_
#define GetBPen          GetBPen_
#define GetDrMd          GetDrMd_
#define GetOutlinePen    GetOutlinePen_

__inline void Move_      (struct RastPort *rp, long x, long y)
{
  rp -> cp_x = x;
  rp -> cp_y = y;
}

__inline ulong GetAPen_  (struct RastPort *rp)
{ return rp -> FgPen; }

__inline ulong GetBPen_  (struct RastPort *rp)
{ return rp -> BgPen; }

__inline ulong GetDrMd_  (struct RastPort *rp)
{ return rp -> DrawMode; }

__inline ulong GetOutlinePen_ (struct RastPort *rp)
{ return rp -> AOlPen; }

/*----- stormamiga-special-functions -----*/

__inline long  muls      (long arg1, long arg2)
{ return (arg1 * arg2); }

__inline ulong mulu      (ulong arg1, ulong arg2)
{ return (arg1 * arg2); }

__inline int max_Width   (struct  Window *window)
{ return (window -> Width - window -> BorderLeft - window -> BorderRight); }

__inline int max_Height  (struct Window *window)
{ return (window -> Height - window -> BorderTop - window -> BorderBottom); }
#endif  /* STORMAMIGA_INLINE */

#endif  /* PPC */
#endif  /* STORMAMIGA_H */
