#include "fxlib.h"
#include "stdio.h"
#include "stdlib.h"
int a=10, b=250, x, y, z ,i = 0;
int jeu[8];
char affichage[21]; 
int AddIn_main(int isAppli, unsigned short OptionNum)
{
	while(i++, b=b>100?--b:100, a!=jeu[0]) {
		jeu[0]=jeu[1], jeu[1]=jeu[2], jeu[2]=jeu[3], jeu[3]=jeu[4], jeu[4]=jeu[5], jeu[5]=jeu[6], jeu[6]=jeu[7]; 
		jeu[7]=Rand(16, 0);
		if(IsKeyDown(KEY_CTRL_LEFT))	a=(a==0)?15:--a;
		if(IsKeyDown(KEY_CTRL_RIGHT))	a=(a==15)?0:++a;
		for(x=0; x<8; x++) {for(y=1; y<7; y++)	Bdisp_SetPoint_VRAM(a*8+y, x, 1);}
		for(x=0; x<8; x++) {for(y=0; y<8; y++) {for(z=0; z<8;z++) {Bdisp_SetPoint_VRAM(jeu[z]*8+y, z*8+x, 1);}}}
		Bdisp_AllClr_DD(), Bdisp_PutDisp_DD(), Bdisp_AllClr_VRAM();
		Sleep(b);
	}
	PrintXY(41, 0, "Perdu!", 0), sprintf(affichage,"Score: %d",i), PrintXY(34, 8, affichage, 1), Bdisp_PutDisp_DD();
	Sleep(2500);
	
	return 1;
}
int Rand(int max, int min) // merci a PierrotLL
{
	static int a = 123456789;
	static int b = 362436069;
	static int c = 521288629;
	static int d = 88675123;
	int t;
	t = a ^ (a << 11);
	a = b;
	b = c;
	c = d;
	return (d = d ^ (d >> 19) ^ (t ^ (t >> 8 )))%max+min;
}

//Ne pas toucher à cela:
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
    return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section