#ifndef PPCAMIGA_PPCAMIGA_H
#define PPCAMIGA_PPCAMIGA_H

#ifndef LIBRARIES_POWERPC_H
#include <libraries/powerpc.h>
#endif

#ifndef _INCLUDE_PRAGMA_POWERPC_LIB_H
#include <pragma/powerpc_lib.h>
#endif

#ifndef DOS_DOS_H
#include <dos/dos.h>
#endif

#ifdef PPC

// This Code is for the PowerPC, do not try to execute it on 68k !
__inline LONG __CallLibrary(APTR base, LONG offset, ULONG *regs)
{
	extern struct Library *PowerPCBase;

	struct PPCArgs call;
	int i;

	call.PP_Code = base ;
	call.PP_Offset = offset ;
	call.PP_Flags = 0 ;			// call sync
	call.PP_Stack = NULL ;
	call.PP_StackSize = 0 ;

	for (i = PPREG_D0; i <= PPREG_A5; i++)
	{
		call.PP_Regs[i] = regs[i];
	};
	call.PP_Regs[PPREG_A6] = (LONG) base;

	Run68K(&call);

	regs[PPREG_D0] = call.PP_Regs[PPREG_D0];

	return call.PP_Regs[PPREG_D0];
};

#else // PPC

__inline void Call_PPC_Code(void *code)
{
	struct PPCArgs ppc = {0,0,0,0}; // clear all of it
	ppc.PP_Code = code;
	ppc.PP_Flags = 0;
	RunPPC(&ppc);
}

#endif // PPC

#endif
