#include <lynx.h> 
#include <lynxlib.h> 
/* LYNX-specific #defines: */ 
#define JOY_RIGHT		0x10 
#define JOY_LEFT		0x20 
#define JOY_DOWN		0x40 
#define JOY_UP			0x80 
 
#define BUTTON_OPTION1	0x08 
#define BUTTON_OPTION2	0x04 
#define BUTTON_INNER	0x02 
#define BUTTON_OUTER	0x01 
 
#define BUTTON_PAUSE	0x01 
 
char SCREEN[8160]       at (MEMTOP-16320); 
char RENDER[8160]       at (MEMTOP-8160); 

int cat_x;
int cat_y;
int cat_x_max;
int cat_y_max;
char score;

char stp_0;
char stp_1;
char stp_2;
char stp_3;
char stp_4;
char stp_5;
char stp_6;
char stp_7;
char stp_8;
char stp_9;

extern void silence(); 
extern void abcmusic(); 
extern void update_music(); 

char drawPending;
 
VBL() interrupt 
{ 
    if (drawPending) { 
        SwapBuffers();
        drawPending = 0; 
    } 
    update_music(); 
} 



//////////////////
// ETOILE
//////////////////
//deux couleurs (1bit) dont une de transparence 1blanc
char spr_etoile1[]={
2,0x00,
2,0x00,
2,0x00,
2,0x10,
2,0x00,
2,0x00,
2,0x00,
0
};
char spr_etoile2[]={
2,0x00,
2,0x00,
2,0x10,
2,0x28,
2,0x10,
2,0x00,
2,0x00,
0
};
char spr_etoile3[]={
2,0x00,
2,0x10,
2,0x10,
2,0x6C,
2,0x10,
2,0x10,
2,0x00,
0
};
char spr_etoile4[]={
2,0x10,
2,0x10,
2,0x00,
2,0xD6,
2,0x00,
2,0x10,
2,0x10,
0
};
char spr_etoile5[]={
2,0x10,
2,0x44,
2,0x00,
2,0x82,
2,0x00,
2,0x44,
2,0x10,
0
};
char spr_etoile6[]={
2,0x10,
2,0x00,
2,0x00,
2,0x82,
2,0x00,
2,0x00,
2,0x10,
0
};           

//////////////////
// QUEUE DU CHAT
//////////////////
//trois couleurs (deux bits) dont une de transparence 1noir 2gris
char spr_queue1[]={
3,0x55,0x00,
3,0x69,0x40,
3,0x5A,0x50,
3,0x16,0x90,
3,0x05,0xA0,
3,0x01,0x50,
3,0x00,0x10,
0
};
char spr_queue2[]={
3,0x00,0x00,
3,0x14,0x00,
3,0x69,0x00,
3,0x69,0x50,
3,0x1A,0xA0,
3,0x05,0xA0,
3,0x00,0x50,
0
};
char spr_queue3[]={
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x10,
3,0x05,0x50,
3,0x5A,0xA0,
3,0x6A,0x50,
3,0x15,0x40,
0
};
char spr_queue4[]={
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x00,
3,0x00,0x50,
3,0x05,0xA0,
3,0x1A,0xA0,
3,0x69,0x50,
3,0x69,0x00,
3,0x14,0x00,
0
};
char spr_queue5[]={
3,0x00,0x00,
3,0x00,0x00,
3,0x15,0x00,
3,0x69,0x50,
3,0x5A,0x90,
3,0x05,0x60,
3,0x00,0x50,
0
};
char spr_queue6[]={
3,0x00,0x00,
3,0x14,0x00,
3,0x69,0x00,
3,0x69,0x50,
3,0x1A,0xA0,
3,0x05,0xA0,
3,0x00,0x50,
0
};


//////////////////
// ARC EN CIEL
//////////////////
//7 couleurs (4 bits) dont une de transparence 1rouge 2orange 3jaune 4vert 5bleu 6violet
char spr_arc1[]={
35,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,
35,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
35,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
35,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,
35,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
35,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
35,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,
35,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
35,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
35,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,
35,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
35,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
35,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,
35,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
35,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
35,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,
35,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
35,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
35,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,
0
};

char spr_arc2[]={
35,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,0x11,0x11,0x00,0x00,
35,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
35,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
35,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,0x22,0x22,0x11,0x11,
35,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
35,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
35,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,0x33,0x33,0x22,0x22,
35,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
35,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
35,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,0x44,0x44,0x33,0x33,
35,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
35,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
35,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,0x55,0x55,0x44,0x44,
35,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
35,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
35,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,0x66,0x66,0x55,0x55,
35,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
35,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,
35,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,0x00,0x00,0x66,0x66,
0
};

//////////////////
// TETE
//////////////////
//5 couleurs (4 bits) dont une de transparence 1noir 2gris 3blanc 4rose
char spr_tete[]={
9,0x00,0x11,0x00,0x00,0x00,0x00,0x11,0x00,
9,0x01,0x22,0x10,0x00,0x00,0x01,0x22,0x10,
9,0x01,0x22,0x21,0x00,0x00,0x12,0x22,0x10,
9,0x01,0x22,0x22,0x11,0x11,0x22,0x22,0x10,
9,0x12,0x22,0x22,0x22,0x22,0x22,0x22,0x21,
9,0x12,0x22,0x31,0x22,0x22,0x23,0x12,0x21,
9,0x12,0x22,0x11,0x22,0x21,0x21,0x12,0x21,
9,0x12,0x44,0x22,0x22,0x22,0x22,0x24,0x41,
9,0x12,0x44,0x21,0x22,0x12,0x21,0x24,0x41,
9,0x01,0x22,0x21,0x11,0x11,0x11,0x22,0x10,
9,0x00,0x12,0x22,0x22,0x22,0x22,0x21,0x00,
9,0x00,0x01,0x11,0x11,0x11,0x11,0x10,0x00,
0
};

//////////////////
// PATTES
//////////////////
//3 couleurs (2 bits) dont une de transparence 1noir 2gris
char spr_pattes1[]={
8,0x05,0x51,0x54,0x00,0x15,0x45,0x50,
8,0x1A,0x91,0xA4,0x00,0x1A,0x46,0x90,
8,0x1A,0x51,0xA4,0x00,0x1A,0x46,0x90,
8,0x15,0x41,0x50,0x00,0x05,0x41,0x40,
0          
};         
char spr_pattes2[]={
8,0x01,0x51,0x54,0x00,0x15,0x45,0x50,
8,0x06,0x91,0xA4,0x00,0x1A,0x46,0x90,
8,0x06,0x91,0xA4,0x00,0x1A,0x46,0x90,
8,0x05,0x40,0x54,0x00,0x05,0x41,0x40,
0
};
char spr_pattes3[]={
8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
8,0x01,0x54,0x69,0x00,0x06,0x91,0xA4,
8,0x01,0xA4,0x69,0x00,0x06,0x91,0xA4,
8,0x01,0xA4,0x69,0x00,0x06,0x91,0xA4,
8,0x01,0x50,0x15,0x00,0x01,0x50,0x54,
0
};
char spr_pattes4[]={
8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
8,0x01,0x51,0x54,0x00,0x15,0x45,0x50,
8,0x06,0x91,0xA4,0x00,0x1A,0x46,0x90,
8,0x05,0x40,0x54,0x00,0x05,0x41,0x50,
0
};
char spr_pattes5[]={
8,0x05,0x55,0x40,0x00,0x55,0x15,0x40,
8,0x15,0x5A,0x40,0x00,0x69,0x1A,0x40,
8,0x6A,0x5A,0x40,0x00,0x69,0x1A,0x40,
8,0x69,0x1A,0x40,0x00,0x69,0x1A,0x40,
8,0x54,0x05,0x40,0x00,0x15,0x05,0x40,
0
};
char spr_pattes6[]={
8,0x05,0x55,0x40,0x00,0x55,0x15,0x40,
8,0x1A,0x5A,0x40,0x00,0x69,0x1A,0x40,
8,0x6A,0x5A,0x40,0x00,0x69,0x1A,0x40,
8,0x69,0x1A,0x40,0x00,0x69,0x1A,0x40,
8,0x54,0x05,0x00,0x00,0x54,0x05,0x40,
0
};


//////////////////
// CORPS
//////////////////
//5 couleurs (4 bits) dont une de transparence 1noir 2beige 3rose 4rosefonc‚
char spr_corps[]={
12,0x00,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x00,
12,0x01,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x21,0x00,
12,0x12,0x22,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x22,0x10,
12,0x12,0x23,0x33,0x33,0x34,0x33,0x43,0x33,0x33,0x22,0x10,
12,0x12,0x33,0x43,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x43,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x43,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x34,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x34,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x34,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x33,0x33,0x34,0x33,0x33,0x33,0x33,0x33,0x32,0x10,
12,0x12,0x23,0x43,0x33,0x33,0x33,0x33,0x33,0x33,0x22,0x10,
12,0x12,0x22,0x33,0x33,0x33,0x33,0x33,0x33,0x32,0x22,0x10,
12,0x01,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x21,0x00,
12,0x00,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x10,0x00,
0
};

char pal[] = {
0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x08,0x0F,0x08,0x00,0x0F,0x00,0x00,0x00, //0G
0x00,0x0F,0x4F,0x0F,0x00,0xF0,0xF8,0x00,0x88,0x8F,0xFF,0xFF,0xFF,0x80,0x00,0x00  //BR
/*      |    |    |    |    |    |    |    |    |    |    |    |    |
rouge--/     |    |    |    |    |    |    |    |    |    |    |    |
orange------/     |    |    |    |    |    |    |    |    |    |    |
jaune------------/     |    |    |    |    |    |    |    |    |    |
vert------------------/     |    |    |    |    |    |    |    |    |
cyan (bleu arc en ciel)----/     |    |    |    |    |    |    |    |
indigo--------------------------/     |    |    |    |    |    |    |
noir---------------------------------/     |    |    |    |    |    |
gris--------------------------------------/     |    |    |    |    |
beige------------------------------------------/     |    |    |    |
rose------------------------------------------------/     |    |    |
rosefoncé------------------------------------------------/     |    |
blanc---------------------------------------------------------/     |
bleufoncé (fond)---------------------------------------------------/
*/};

//////////////////
// SPLASH SCREEN
//////////////////
char pal_splash[]={
	0x00,0x0F,0x00,0x0F,0x0F,0x00,0x0C,0x08,0x08,0x0F,0x08,0x08,0x08,0x08,0x04,0x0F,
	0x00,0xFF,0x0F,0x0F,0x00,0xF0,0xCC,0x8C,0x88,0x8F,0xFF,0x4F,0x48,0xF0,0x08,0xFF};
extern char nyan_splash[];
extern char nyan_rtfm[];


extern char SCB_STAR[];
extern char SCB_CORPS[];
extern char SCB_QUEUE[];
extern char SCB_TETE[];
extern char SCB_PIEDS[];
extern char SCB_ARCENCIEL[];
extern char SCB_SPLASH[];

extern char nyan_main_droite[];
extern char nyan_main_gauche[];
extern char nyan_start[];
//CDEFGABcdefgabz
/*
C 1
D 2
E 3
F 4
G 5
A 6
B 7
c 8
d 9
e 10
f 11
g 12
a 13
b 14
z ¤
*/
//            dc.b "|:e2f2 ^Bc2=B | =cBA2 A2B2 | =c2cB AB^ce | fceB cABA |c2e2 fceB | cA^Bc =c=BAB | =c2AB ^ceB=c |1 BAB2 A2B2 :|2 BAB2 A2A2 ||" 
//            dc.b "|:\A2EF A2EF | ABcA dcde | A2A2 EFAE | dcBA DCDE |A2EF A2EF | AABc AEFE | A2AG AEFA |1 dcde A2G2 :|2 dcde A2B2 |"
#asm
_SCB_SPLASH dc.b $C1,$30,$20 
          dc.w 0,0
          dc.w 0,0,$100,$100,0,0
          dc.b $01,$23,$45,$67,$89,$AB,$CD,$EF

_nyan_start
            dc.b "O2X4I1V65T5R40H2K3" 
            dc.b "O2EFGzcFEFGcegagBcz GzEFGzc2dBcdfefcz"
            dc.b 0 

_nyan_main_droite
            dc.b "O2X4I1V65T5R40H2K3" 
            dc.b "|:G2A2=EE2D=EDC2C2D2"
						dc.b "=E2EDCDEGAEGDECDCE2G2AEGDEC=EE=EDCD=E2CDEGD=EDCD2C2D2"
						dc.b "G2A2=EE2D=EDC2C2D2=E2EDCDEGAEGDECDCE2G2AEGDEC=EE=EDCD"
						dc.b "=E2CDEGD=EDCD2C2C2C2O1GAc2GAcdecfefg c2c2GAcGfedcFEFG"
						dc.b "c2GAc2GAccdecGAGc2cBcGAcfefgc2B2c2GAc2GAcdecfefg"
						dc.b "c2c2GAcfedcFFc2GAc2GAccdecGAGc2cBcGAcfefgc2d2"
						dc.b ":"
            dc.b 0 
_nyan_main_gauche
            dc.b "O4X4I1V65T5R40H2K3" 
						dc.b "|:"
						dc.b "F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2"
						dc.b ":"
            dc.b 0 
_nyan_main_gaucheold
            dc.b "O4X4I1V65T5R40H2K3" 
						dc.b "|:"
						dc.b "F2f2G2g2E2e2A2a2"
						dc.b "D2d2G2g2CcC2D2E2F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2"
						dc.b "F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2F2f2G2g2E2e2A2a2"
						dc.b "D2d2G2g2CcC2D2E2F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2"
						dc.b "F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2F2f2G2g2E2e2A2a2"
						dc.b "D2d2G2g2CcC2D2E2F2f2G2g2E2e2A2a2D2d2G2g2CcC2D2E2"
						dc.b ":"
            dc.b 0 

_SCB_STAR dc.b $04,$B0,$20 
          dc.w 0,0 
          dc.w 0,0,$100,$100,$00,$00
          dc.b $0C,$00,$00,$00,$00,$00,$00,$00
_SCB_CORPS dc.b $C4,$B0,$20 
          dc.w 0,0 
          dc.w $43,$2A,$100,$100,$00,$00
          dc.b $07,$9A,$B0,$00,$00,$00,$00,$00
_SCB_QUEUE dc.b $44,$B0,$20 
          dc.w 0,0 
          dc.w $3E,$30,$100,$100,$00,$00
          dc.b $07,$80,$00,$00,$00,$00,$00,$00
_SCB_TETE dc.b $C4,$B0,$20 
          dc.w 0,0 
          dc.w $4C,$30,$100,$100,$00,$00
          dc.b $07,$8C,$A0,$00,$00,$00,$00,$00
_SCB_PIEDS dc.b $44,$B0,$20 
          dc.w 0,0 
          dc.w $3F,$3A,$100,$100,$00,$00
          dc.b $07,$80,$00,$00,$00,$00,$00,$00
_SCB_ARCENCIEL dc.b $C4,$B0,$20 
          dc.w 0,0 
          dc.w 0,$2B,$100,$100,$00,$00
          dc.b $00,$00,$00,$00,$00,$00,$00,$00

#endasm 

// assembler vertical retrace syncronisation routine 
void Vsync()  
{ 
#asm 
vretrace: 
	lda $fd0a 
	bne vretrace 
#endasm 
} 
 
char WaitButton()
{
   char key;
   while ( (key = joystick) == 0)
      ;
   /* wait for the button to be released */
   while ( joystick )
      ;
   return key;
}

void ArcEnCiel(step)
char step;
{
	SCBX(SCB_ARCENCIEL)=cat_x-67;
	SCBY(SCB_ARCENCIEL)=cat_y+1;
	if(step==0){
		SCBDATA(SCB_ARCENCIEL) = spr_arc1;
	}else{
		SCBDATA(SCB_ARCENCIEL) = spr_arc2;
	}
	DrawSprite(SCB_ARCENCIEL);
	if(cat_x>134){
		SCBX(SCB_ARCENCIEL)=cat_x-201;
		DrawSprite(SCB_ARCENCIEL);
	}
	if(cat_x>67){
		if(step==1){
			SCBDATA(SCB_ARCENCIEL) = spr_arc1;
		}else{
			SCBDATA(SCB_ARCENCIEL) = spr_arc2;
		}
		SCBX(SCB_ARCENCIEL)=cat_x-134;
		DrawSprite(SCB_ARCENCIEL);
	}
}

void Etoile(ligne,shift,stp)
char ligne;
char shift;
char stp
{
	char val;
	//TextOut(0,90,5,0,random());
	val=(16+(ligne-shift)-stp) % 6;
	if(val == 0){
		SCBDATA(SCB_STAR) = spr_etoile1; 
	} else {
		if(val == 1){
			SCBDATA(SCB_STAR) = spr_etoile2; 
		} else {
			if(val == 2){
				SCBDATA(SCB_STAR) = spr_etoile3; 
			} else {
				if(val == 3){
					SCBDATA(SCB_STAR) = spr_etoile4; 
				} else {
					if(val == 4){
						SCBDATA(SCB_STAR) = spr_etoile5; 
					} else {
						if(val == 5){
							SCBDATA(SCB_STAR) = spr_etoile6;
						} else {
							SCBDATA(SCB_STAR) = spr_etoile1;
						}
					}
				}
			}
		}
	}
	SCBY(SCB_STAR)=ligne*10+(2*stp)-6;
	SCBX(SCB_STAR)=shift*10;
	DrawSprite(SCB_STAR);
	if (val > 4){
		if (shift*10>(cat_x+9) && shift*10<cat_x_max){
			if (ligne*10>(cat_y+6) && ligne*10<cat_y_max){
				IncrementeScore();
				pal[0xD]=0xF;
				SetRGB(pal); 
			}
		}
	}
}

void Queue(step)
char step;
{
	SCBX(SCB_QUEUE)=cat_x-5;
	SCBY(SCB_QUEUE)=cat_y+6;
	if(step % 6 == 0){
		SCBDATA(SCB_QUEUE) = spr_queue1; 
	} else {
		if(step % 6 == 1){
			SCBDATA(SCB_QUEUE) = spr_queue2; 
		} else {
			if(step % 6 == 2){
				SCBDATA(SCB_QUEUE) = spr_queue3; 
			} else {
				if(step % 6 == 3){
					SCBDATA(SCB_QUEUE) = spr_queue4; 
				} else {
					if(step % 6 == 4){
						SCBDATA(SCB_QUEUE) = spr_queue5; 
					} else {
						if(step % 6 == 5){
							SCBDATA(SCB_QUEUE) = spr_queue6;
						} else {
							SCBDATA(SCB_QUEUE) = spr_queue1;
						}
					}
				}
			}
		}
	}
	DrawSprite(SCB_QUEUE);
}
//spr_pattes5
void Pattes(step)
char step;
{
	SCBX(SCB_PIEDS)=cat_x-4;
	SCBY(SCB_PIEDS)=cat_y+16;
	if(step % 6 == 0){
		SCBDATA(SCB_PIEDS) = spr_pattes1; 
	} else {
		if(step % 6 == 1){
			SCBDATA(SCB_PIEDS) = spr_pattes2; 
		} else {
			if(step % 6 == 2){
				SCBDATA(SCB_PIEDS) = spr_pattes3; 
			} else {
				if(step % 6 == 3){
					SCBDATA(SCB_PIEDS) = spr_pattes4; 
				} else {
					if(step % 6 == 4){
						SCBDATA(SCB_PIEDS) = spr_pattes5; 
					} else {
						if(step % 6 == 5){
							SCBDATA(SCB_PIEDS) = spr_pattes6;
						} else {
							SCBDATA(SCB_PIEDS) = spr_pattes1;
						}
					}
				}
			}
		}
	}
	DrawSprite(SCB_PIEDS);
}

void Corps(step)
char step;
{
	SCBX(SCB_CORPS)=cat_x;
	SCBY(SCB_CORPS)=cat_y;
	if((step % 6)==0) SCBY(SCB_CORPS)=SCBY(SCB_CORPS)+1;
	if((step % 6)==2) SCBY(SCB_CORPS)=SCBY(SCB_CORPS)-1;
	DrawSprite(SCB_CORPS);
	if(pal[0xD]>1){
		pal[0xD]=pal[0xD]-2;
		SetRGB(pal);
	}
}

void Tete(step)
char step;
{
	SCBX(SCB_TETE)=cat_x+9;
	SCBY(SCB_TETE)=cat_y+6;
	if((step % 6)==1) SCBX(SCB_TETE)=SCBX(SCB_TETE)+1;
	if((step % 6)==2) SCBY(SCB_TETE)=SCBY(SCB_TETE)+1;
	if((step % 6)==4) SCBX(SCB_TETE)=SCBX(SCB_TETE)-1;
	if((step % 6)==5) SCBY(SCB_TETE)=SCBY(SCB_TETE)-1;
	DrawSprite(SCB_TETE);
}

void Touches()
{
	if (joystick&JOY_RIGHT) cat_x+=4;
	if (joystick&JOY_LEFT) cat_x-=4;
	if (joystick&JOY_UP) cat_y-=4;
	if (joystick&JOY_DOWN) cat_y+=4;
	if (cat_x<0) cat_x=0;
	if (cat_y<0) cat_y=0;
	if (cat_x>135) cat_x=135;
	if (cat_y>82) cat_y=82;
	cat_x_max=cat_x+25;
	cat_y_max=cat_y+22;

}

void IncrementeScore()
{
	score++;
	if(score<7){
		if(score>0){
			SCB_ARCENCIEL[20]=0x03;
			if(score>1){
				SCB_ARCENCIEL[21]=0x40;
				if(score>2){
					SCB_ARCENCIEL[20]=0x23;
					if(score>3){
						SCB_ARCENCIEL[21]=0x45;
						if(score>4){
							SCB_ARCENCIEL[22]=0x60;
							if(score>5){
								SCB_ARCENCIEL[19]=0x01;
							}
						}
					}
				}
			}
		}
	} else {
		score=7;
	}
}

char main() 
{ 
	int i;
	char tempoo;
  char step_arc_en_ciel;
  char step_queue;
  char shift_0;
  char shift_1;
  char shift_2;
  char shift_3;
  char shift_4;
  char shift_5;
  char shift_6;
  char shift_7;
  char shift_8;
  char shift_9;
  char inc;
  char cpt_inc;
  char key;
  
  inc=1;
  cpt_inc=0;
	cat_x=67;
	cat_y=42;
	score=0;
  InitIRQ(); 
  CLI;
  SetBuffers(SCREEN, RENDER ,0); 
	InstallIRQ(2,VBL); 
	EnableIRQ(2); 
  tempoo=10;
  step_arc_en_ciel=0;
  step_queue=0;
  shift_0=16;
  shift_1=10;
  shift_2=13;
  shift_3=5;
  shift_4=8;
  shift_5=1;
  shift_6=3;
  shift_7=19;
  shift_8=4;
  shift_9=12;
  
	SetRGB(pal_splash);
	DrawFBox(0,0,160,102,0);
	SCBDATA(SCB_SPLASH) = nyan_splash;
	DrawSprite(SCB_SPLASH);
	SwapBuffers(); 
	Vsync(); 
  silence(); 
  abcmusic(0,nyan_start);
  for(i=0;i<340;i++) Vsync();
  silence(); 
  abcmusic(0,nyan_main_droite);
  abcmusic(1,nyan_main_gauche);
	pal_splash[1]=0;
	pal_splash[17]=0;
	SCBDATA(SCB_SPLASH) = nyan_rtfm;
	DrawSprite(SCB_SPLASH);
	SwapBuffers(); 
	Vsync(); 

	while ( (key = joystick) == 0){
		if (inc==1){
			pal_splash[1]=(pal_splash[1]+1)&0xF;
			pal_splash[17]=(pal_splash[17]+0x11);
		} else {
			pal_splash[1]=(pal_splash[1]-1)&0xF;
			pal_splash[17]=(pal_splash[17]-0x11);
		}
		cpt_inc++;
		if (cpt_inc>=16 || cpt_inc<0){
			inc=1-inc;
			cpt_inc=0;
		}
		SetRGB(pal_splash);
		Vsync(); 
	}
	while ( joystick );
	SetRGB(pal);

  
	/* set the palette */ 
	SetRGB(pal); 
	DrawFBox(0,0,160,102,0xD);
/*	SCBDATA(SCB_STAR) = spr_etoile1; 
	SCBDATA(SCB_CORPS) = spr_corps; 
	SCBDATA(SCB_QUEUE) = spr_queue1; 
	SCBDATA(SCB_TETE) = spr_tete; 
	SCBDATA(SCB_PIEDS) = spr_pattes1; 
	SCBDATA(SCB_ARCENCIEL) = spr_arc1; */
	
	SCBDATA(SCB_CORPS) = spr_corps;
	SCBDATA(SCB_TETE) = spr_tete;
  
  
	for (;;){
    //while (1) ; 
		
		//étape 1
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
		Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 2
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
		Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 3
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
		Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 4
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 5
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 6
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 7
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 8
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 9
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 10
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 11
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;

		//étape 12
		DrawFBox(0,0,160,102,0xD);
		ArcEnCiel(step_arc_en_ciel);
		step_arc_en_ciel=step_arc_en_ciel^1;
		Etoile(0,shift_0--,stp_0);
		Etoile(2,shift_2--,stp_2);
		Etoile(4,shift_4--,stp_4);
		Etoile(6,shift_6--,stp_8);
		Etoile(8,shift_8--,stp_6);
		if (shift_0<0) {shift_0=16;stp_0=random()%6;}
		if (shift_1<0) {shift_1=16;stp_1=random()%6;}
		if (shift_2<0) {shift_2=16;stp_2=random()%6;}
		if (shift_3<0) {shift_3=16;stp_3=random()%6;}
		if (shift_4<0) {shift_4=16;stp_4=random()%6;}
		if (shift_5<0) {shift_5=16;stp_5=random()%6;}
		if (shift_6<0) {shift_6=16;stp_6=random()%6;}
		if (shift_7<0) {shift_7=16;stp_7=random()%6;}
		if (shift_8<0) {shift_8=16;stp_8=random()%6;}
		if (shift_9<0) {shift_9=16;stp_9=random()%6;}
	 	Queue(step_queue);
	 	Pattes(step_queue);
	 	Corps(step_queue);
	 	Tete(step_queue++);
	 	if (step_queue>5) step_queue=0;
	 	Touches();
	 	for(i=0;i<tempoo;i++) Vsync();
		SwapBuffers();
	 	//drawPending=1;
	}
} 
