/*
** includes + classbase definition for the bmp.datatype
*/

#include <exec/types.h>

#if !defined(__GNUC__)
#define REG(x)
#else
#define REG(x) asm(#x)
#endif

#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/resident.h>
#include <dos/dos.h>
#include <graphics/gfx.h>
#include <intuition/classes.h>
#include <datatypes/pictureclass.h>
#include <datatypes/pictureclassext.h>
#include <proto/datatypes.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/utility.h>
#define DoSuperMethodA __stdargs DoSuperMethodA
#include <proto/exec.h>
#undef DoSuperMethodA
#include <proto/dos.h>

/*
** global class structure
*/

struct ClassBase {
  struct Library          LibNode;
  UWORD                   Pad1;
  BPTR                    SegList;
  struct Library         *SysBase,
                         *DOSBase,
                         *IntuitionBase,
                         *GfxBase,
                         *UtilityBase,
                         *DataTypesBase,
                         *SuperClassBase;
  struct IClass          *PictureClass;
  struct SignalSemaphore  LockSemaphore;
  UWORD                   Pad2;
};

/*
** majik ;(
*/

#if !defined(__GNUC__) || defined(mc68020) || defined(mc68030) || defined(mc68040) || defined(mc68060)

#define MOD(x,y) ((x)%(y))
#define MUL(x,y) ((x)*(y))

#else

STATIC inline LONG MYMOD(LONG x,LONG y,APTR UtilityBase)
{
  REGISTER LONG _RES REG(d1);

  (VOID)SDivMod32(x,y); __asm __volatile ("" : "=r" (_RES)); return _RES;
}

STATIC inline LONG MYMUL(LONG x,LONG y,APTR UtilityBase)
{
  return SMult32(x,y);
}

#define MUL(x,y) MYMUL(x,y,cb->UtilityBase)
#define MOD(x,y) MYMOD(x,y,cb->UtilityBase)

#endif
