
extern int num_sprite_actif;

extern int CreePerso(unsigned short x,
					 unsigned short y,
					 short direction,
					 unsigned short largeur,
					 unsigned short hauteur,
					 void (*fonction) (),
					 unsigned int instructions);
extern int CreePersoID(unsigned int id,
					   unsigned short x,
					   unsigned short y,
					   short direction,
					   unsigned short largeur,
					   unsigned short hauteur,
					   void (*fonction) (),
					   unsigned int instructions);

//extern void /*IWRAM_CODE*/ VerifieSIlYABesoinDePlacerUnSprite(u32 x, u32 y, ECRAN *ecr);

//Détecte une collision entre s1 et s2 et renvoie le résultat
#define CollisionEntreDeuxSprites(s1, s2) \
	( \
	(s1)->x + (s1)->largeur > (s2)->x \
	&&        (s1)->x < (s2)->x + (s2)->largeur \
	&&        (s1)->y + (s1)->hauteur > (s2)->y \
	&&        (s1)->y < (s2)->y + (s2)->hauteur \
	)

extern u32 CreeObjetStandard(u16 x,
							 u16 y,
							 unsigned short tiles,
							 unsigned short palette,
							 unsigned short forme,
							 unsigned short taille);
extern void CreeObjetStandardSonicRotation(
	unsigned short prio,
	unsigned short tiles,
	unsigned short palette,
	unsigned short forme,
	unsigned short taille);
extern void CreeObjetStandardStage(s16 x,
								   s16 y,
								   unsigned short tiles,
								   unsigned short palette,
								   unsigned short forme,
								   unsigned short taille);
extern void CreeObjetStandardSansEcran(s16 x,
									   s16 y,
									   unsigned short tiles,
									   unsigned short palette,
									   unsigned short forme,
									   unsigned short taille);
extern void CreeObjetStandardAlpha(u16 x,
								   u16 y,
								   unsigned short tiles,
								   unsigned short palette,
								   unsigned short forme,
								   unsigned short taille);
extern u32 CreeObjetStandardP(PERSO *p,
							  unsigned short tiles,
							  unsigned short palette,
							  unsigned short forme,
							  unsigned short taille);
extern void CreeObjetStandardEx(u16 x,
								u16 y,
								u16 alpha,
								u16 prio,
								u16 mh,
								u16 mv,
								unsigned short tiles,
								unsigned short palette,
								unsigned short forme,
								unsigned short taille);
extern void EffacePerso(u32 j);
extern void LiberePerso(u32 j);
extern void RemetPerso(u32 j);
extern void CreeObjetStandardHUD(u32 x,
								 u32 y,
								 unsigned short tiles,
								 unsigned short palette,
								 unsigned short forme,
								 unsigned short taille);

extern void AfficheSonic(SONIC *perso, ECRAN *ecr);

extern ECRAN *EcrSprites;
extern void InitSprites();

extern void CollisionGauche(SONIC *s);
extern void CollisionDroite(SONIC *s);
extern void EssaieDeCrocher(SONIC *s);

extern u32 MoteurCollisionObjets(PERSO *s, int vx, int vy);
extern void IWRAM_CODE GerePersos(SONIC *sonic, ECRAN *ecr);

//extern void IWRAM_CODE BougeSprites(ECRAN *ecr);
extern void Sonic_perdBagues(SONIC *s);

extern int nbrePersos;
extern int gblJ, perso_signal;

extern void DetruitPerso(PERSO *p);
extern void InserePerso(int nombre);

#define OBJ_SONIC                        0        //Numéro d'objet représentant Sonic (constant)
#define CodeBaseCreeObjet        if (objetsUtilises >= 127 || nSpritesSup >= SPRITES_SUP_MAX) \
	return 0; \
	VerifieSIlYABesoinDePlacerUnSprite(x, y, EcrSprites); \
	if (posX == 240 || posY == 160) \
	return 0; \
	objetsUtilises++;

#define CreeObjetStandardExRapide(x, y, alpha, prio, mh, mv, tiles, palette, taille) \
	( \
{ \
	if (objetsUtilises < 127 && nSpritesSup < SPRITES_SUP_MAX) \
{ \
	VerifieSIlYABesoinDePlacerUnSprite(x, y, EcrSprites); if (posX != 240 && posY != 160) \
{ \
	objetsUtilises++; CreeObjet(objetsUtilises, tiles, posX, posY, alpha, taille, 0, palette, prio, mv, mh, 0, 0, 0, 0); \
} \
} \
} \
	)

extern int super_vitesse;
extern int wrap(int angle);
extern int gblSonicComplexe;
extern void AfficheSonicComplexe();

//DEBOGAGE SEULEMENT
extern int gblDebug_ID;

extern void IWRAM_CODE MoveRotData(u32 nbSprites);
extern void Sonic_metEnBoule(SONIC *s, u32 etat);
extern int gblChangeEnboule;

extern void CreeObjetStandardEau(
								 s32 x,
								 s32 y,
								 unsigned short tiles,
								 unsigned short palette,
								 unsigned short forme,
								 unsigned short taille);
extern void CreeObjetStandardHUDRotation(u32 x, u32 y, unsigned short tiles, unsigned short palette, unsigned short no_rotation, unsigned short forme, unsigned short taille);
extern void CreeObjetStandardHUDPlus(s32 x, s32 y, unsigned short tiles, unsigned short palette, unsigned short forme, unsigned short taille);
extern void CreeObjetStandardHUDHorsEcran(s32 x, s32 y, unsigned short tiles, unsigned short palette, unsigned short forme, unsigned short taille);
extern void GereSonicEnBoule(SONIC *s);

u32 prioDefaut; //Priorité par défaut des objets
