File: fission031.c - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

/*
 Fission (casse brique) 0.31 - LYNX - kit BLL (newcc65)
 08/12/2010
 console tenu � la verticale
 Handy/Option/Rotate Screen(Right)
 D-pad et bouton pause
 LYNX - video game */

 
#include <stdlib.h>
#include <lynx.h>
#include <lynxlib.h>
//{
extern void silence();
extern void abcmusic();
extern void update_music();

char abcmusic0[];
char abcmusic1[];
char abcmenu1[];
char abcmenu2[];
char abcball1[];
char abcball2[];
char abcball3[];
char abcaptvir[];
char abcbric[];

#asm
 xref _abcmenu1
 xref _abcmenu2
 xref _abcball1
 xref _abcbric
 xref _abcaptvir
 xref _abcboum
 xref _abcpanne
 xref _abces
 xref _abcmusic0
 xref _abcmusic1
_abcmenu1
 dc.b "O2X7I1V32T20R54H7K8"
 dc.b "|:C4"
 dc.b 0
_abcmenu2
 dc.b "O3X7I1V16T20R54H7K12"
 dc.b "|:c2"
 dc.b 0
; ball :
_abcball1
 dc.b "O4X3I1V70T20R32H2K1"
 dc.b "|:C4"
_abcball2
 dc.b "O4X3I1V70T20R32H2K1"
 dc.b "|:D4"
_abcball3
 dc.b "O4X3I1V70T20R32H2K1"
 dc.b "|:F4"
_abcaptvir
 dc.b "O2X15I1V32T1R14H6K30"
 dc.b "|:C4D4C4E4D4C4D4"
 dc.b 0
_abcbric
 dc.b "O4X7I1V16T20R54H7K12"
 dc.b "|:C1"
 dc.b 0
_abcmusic0
 dc.b "O2X3I1V70T20R54H2K1"
 dc.b "|:C4O3T2C4"
 dc.b 0
_abcmusic1
 dc.b "O2X7I0V45T20R80H8K1"
 dc.b "|:C4D4E4F4"
 dc.b "C4D4E4F4"
 dc.b "c4B4A4E4"
 dc.b "c4B4A4E4"
 dc.b "E4F4G4A4"
 dc.b "E4F4G4A4"
 dc.b "C4D4E4F4"
 dc.b "C4D4E4F4:"
 dc.b 0
#endasm
//}

/* 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_LEFT  0x02
#define BUTTON_RIGHT 0x01

#define BUTTON_PAUSE 0x01

#define SC BSTRETC H(a) (*(uint *)((a)+15)) // d�formation, macro
#define SC BTILT(a) (*(uint *)((a)+17)) // d�formation, macro

uchar SCREEN[8160]       at (MEMTOP-16320);
uchar RENDER[8160]       at (MEMTOP-8160);

uchar pali[]={
 0x00,0x0F,0x02,0x03,0x0A,0x04,0x05,0x06,0x07,0x0B,0x08,0x09,0x04,0x0B,0x0C,0x01,
 0x00,0xFF,0x22,0x33,0xAA,0x44,0x55,0x66,0x77,0x00,0x88,0x99,0x53,0xBB,0xCC,0x11};
uchar palg[]={
 0x00,0x0F,0x0A,0x00,0x03,0x05,0x08,0x0A,0x0C,0x0E,0x0D,0x00,0x04,0x03,0x02,0x00,
 0x00,0xFF,0xF0,0x0F,0x3F,0x5F,0x8F,0xAF,0xCF,0xEF,0x28,0xF8,0x53,0x63,0x52,0x21};


uchar palr[]={
 0x00,0x0F,0x0A,0x00,0x03,0x05,0x08,0x0A,0x0C,0x0E,0x0D,0x00,0x04,0x00,0x02,0x00,
 0x00,0xFF,0xF0,0x0F,0x3F,0x5F,0x8F,0xAF,0xCF,0xEF,0x28,0xF8,0x53,0x0F,0x52,0x21};
/*****************************************************************************
**  Ci-dessous, le contenu du fichier batchfile pour l'image imole.bmp      **
                                                                            **
set image01=imole.bmp
SPRPCK -t6 -S072072 -r001001 -a036036 -p0 %image01%
cmd
                                                                            **
**  Le point d'action de l'image imole est mis au centre de celle-ci,       **
**  72/2 = 36 (-a036036). Le but de la manoeuvre est de r�aliser un zoom    **
**  correctement.                                                           **
*****************************************************************************/


extern uchar ititre[];  // image titre, d'une taille de 15*49;
extern uchar iname[];  // image nom/pr�nom de auteur, d'une taille de 93*9;
extern uchar imole[];  // image molecule, d'une taille de 72*72;
uchar SCB[];
#asm        
_SCB      dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
extern uchar fondg[]; // image fond game, d'une taille de 160*102;
uchar SCBg[];

#asm        
_SCBg      dc.b $c0,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
#endasm
// ------------------------------------
extern uchar pushup[]; // image appuyez sur haut, d'une taille de 48*35;
uchar SCBp[];
#asm        
_SCBp      dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
/*****************************************************************************
**  Ci-dessous, le contenu du fichier batchfile pour l'image raquet.bmp      **
set image01=raquet.bmp
SPRPCK -t6 -S008025 -a000012 -p0 %image01%
cmd
*****************************************************************************/

extern uchar raquet[]; // image raquette, d'une taille de 8*24;
uchar SCBr[];
#asm        
_SCBr      dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
// clip du sprite chiffres, chacun d'une taille de 8*8: 0123456789.LEV
extern uchar bc000000[];
extern uchar bc000001[];
extern uchar bc000002[];
extern uchar bc000003[];
extern uchar bc000004[];
extern uchar bc000005[];
extern uchar bc000006[];
extern uchar bc000007[];
extern uchar bc000008[];
extern uchar bc000009[];
extern uchar bc000010[];
extern uchar bc000011[];
extern uchar bc000012[];
extern uchar bc000013[];

uchar *chiffrestab[14] = {bc000000, bc000001, bc000002, bc000003, bc000004,
                         bc000005, bc000006, bc000007, bc000008, bc000009,
                         bc000010, bc000011, bc000012, bc000013};
uchar SCBchiffres1[]; // d�claration d'un nouveau controleur de sprite (test)
uchar SCBchiffres2[]; // d�claration d'un nouveau controleur de sprite (test)
uchar SCBchiffres3[]; // d�claration d'un nouveau controleur de sprite (test)
uchar SCBchiffres4[]; // d�claration d'un nouveau controleur de sprite (test)
uchar SCBchiffres5[]; // d�claration d'un nouveau controleur de sprite (test)

uchar SCBscore1[]; // d�claration d'un nouveau controleur de sprite (score unit�)
uchar SCBscore2[]; // d�claration d'un nouveau controleur de sprite (score dizaine)
uchar SCBscore3[]; // d�claration d'un nouveau controleur de sprite (score centaine)
uchar SCBscore4[]; // d�claration d'un nouveau controleur de sprite (score millier)

uchar SCBtexte1[]; // d�claration d'un nouveau controleur de sprite (level)
uchar SCBtexte2[]; // d�claration d'un nouveau controleur de sprite (level)
uchar SCBtexte3[]; // d�claration d'un nouveau controleur de sprite (level)
uchar SCBtexte4[]; // d�claration d'un nouveau controleur de sprite (level)
uchar SCBtexte5[]; // d�claration d'un nouveau controleur de sprite (level)

uchar SCBlife[]; // d�claration d'un nouveau controleur de sprite (score unit�)

#asm
_SCBchiffres1     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBchiffres2     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBchiffres3     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBchiffres4     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBchiffres5     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBscore1     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBscore2     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBscore3     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBscore4     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBtexte1     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBtexte2     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBtexte3     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBtexte4     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBtexte5     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBlife     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
// set image01=fdir.bmp
// SPRPCK -t6 -S018015 -r007001 -o000000 -i126015 -p0 %image01% fd
// cmd
// clip du sprite fleches (7 images d'une taille de 18*15).
extern uchar fd000000[];
extern uchar fd000001[];
extern uchar fd000002[];
extern uchar fd000003[];
extern uchar fd000004[];
extern uchar fd000005[];
extern uchar fd000006[];

uchar *fdtab[7] = {fd000000, fd000001, fd000002, fd000003, fd000004,
                   fd000005, fd000006};
uchar SCBfd[]; // d�claration d'un nouveau controleur de sprite
#asm
_SCBfd     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
/*****************************************************************************
**  Ci-dessous, le contenu du fichier batchfile pour l'image fball.bmp      **
                                                                            **
set image01=fball.bmp
SPRPCK -t6 -S005005 -r001001 -a002002 -p0 %image01%
cmd
                                                                            **
**  Le point d'action de l'image fball est mis au centre de celle-ci,       **
**  0 1 2 3 4   --> la valeur 2 correspond exactement au centre (-a002002)  **
*****************************************************************************/


extern uchar fball[]; // image balle, d'une taille de 5*5;
uchar SCBball[];
#asm        
_SCBball      dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------
// ------------------------------------
//char fbriq[]; //

// clip du sprite brique, d'une taille de 10*14 : 0(d�truite), 1(normale), 2(dure) et 3(incassable).
extern uchar br000000[];
extern uchar br000001[];
extern uchar br000002[];
extern uchar br000003[];

uchar *brtab[4] = {br000000, br000001, br000002, br000003};

// nombreuses d�clarations des nouveaux controleurs de sprite pour les briques.
uchar SCBbr01[];
uchar SCBbr02[];
uchar SCBbr03[];
uchar SCBbr04[];
uchar SCBbr05[];
uchar SCBbr06[];
uchar SCBbr07[];
uchar SCBbr08[];
uchar SCBbr09[];
uchar SCBbr10[];
uchar SCBbr11[];
uchar SCBbr12[];
uchar SCBbr13[];
uchar SCBbr14[];
uchar SCBbr15[];
uchar SCBbr16[];
uchar SCBbr17[];
uchar SCBbr18[];
uchar SCBbr19[];
uchar SCBbr20[];
uchar SCBbr21[];
uchar SCBbr22[];
uchar SCBbr23[];
uchar SCBbr24[];
uchar SCBbr25[];
#asm
_SCBbr01     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr02     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr03     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr04     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr05     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr06     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr07     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr08     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr09     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr10     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr11     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr12     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr13     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr14     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr15     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr16     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr17     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr18     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr19     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr20     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr21     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr22     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr23     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr24     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
;
_SCBbr25     dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------ ouf !

// ------------------------------------
extern char ipause[]; // image pause, d'une taille de 13*43;
char SCBip[];
#asm        
_SCBip      dc.b $c7,$10,$20
          dc.w 0,0
          dc.w 0,0,$100,$100
          dc.b $01,$23,$45,$67,$89,$ab,$cd,$ef
#endasm
// ------------------------------------




int posx,posy,level,score,xpush,ypush,relach;
int i;
char tempa,tempb,tempc,tempd,tempe,etape,filife,gspause,gsblip,mhaut,mbas; // de -128 � 127
int molescx,molescy;
int atest,unite,dizaine,centaine,millier,dmillier,horszone;

// ydirf --> d�placer l�g�rement la fl�che.
// dirf --> direction fleche de 0 � 6, mais aussi direction Y de la balle (-3 -2 -1 0 +1 +2 +3) (ici gauche/droite car LYNX verticale).
// bdirx --> direction X de la balle (ici haut/bas car le jeu se joue la LYNX tenu � la verticale).
char ydirf,dirf,bdirx,speedX,oboucl,basar,odirx,Xtemp,Ytemp,fsaut,upbri;
int balldirX,balldirY,yplayer;

int compti, comptx, compty;
int tligne,nbrbriqx, nbrbriqy;

// assembler vertical retrace syncronisation routine
void Vsync()
{
#asm
vretrace:
 lda $fd0a
 bne vretrace
#endasm
}

// Hors de l'assembleur, point de salut...
// L'utilisation de la procedure suivante, lors de l'�cran d'action,
// fait ramer le jeu.

void Fchiffres(clx,cly,classe)
int clx,cly,classe;
 {
 SCBDATA(SCBchiffres1) = chiffrestab[classe%14];
 SCBX(SCBchiffres1) = clx;
 SCBY(SCBchiffres1) = cly;  
 DrawSprite(SCBchiffres1);
 }


// brique : �tat + coordonn�es X et Y. brsco[25], bricol[5],
int cible, bbcontact, rebcot, brnbr, brie[25], brif[25], brix[5]; // 5 car il y a 5 rang�es de briques sur la m�me ligne (ligne car ecran vertical).
//int briy[25];
 uchar *brdata[25];//25 briques test en ligne
// uchar *brdatb[25];//25 briques test en colonne
 uchar *brsco[25];

 
ShowScreen()
{


 brix[0] = 85-horszone;
  SCBX(SCBbr01) = brix[0];

  SCBX(SCBbr02) = brix[0];

  SCBX(SCBbr03) = brix[0];

  SCBX(SCBbr04) = brix[0];

  SCBX(SCBbr05) = brix[0];


 brix[1] = 95-horszone;
  SCBX(SCBbr06) = brix[1];

  SCBX(SCBbr07) = brix[1];

  SCBX(SCBbr08) = brix[1];

  SCBX(SCBbr09) = brix[1];

  SCBX(SCBbr10) = brix[1];


 brix[2] = 105-horszone;
  SCBX(SCBbr11) = brix[2];

  SCBX(SCBbr12) = brix[2];

  SCBX(SCBbr13) = brix[2];

  SCBX(SCBbr14) = brix[2];

  SCBX(SCBbr15) = brix[2];


 brix[3] = 115-horszone;
  SCBX(SCBbr16) = brix[3];

  SCBX(SCBbr17) = brix[3];

  SCBX(SCBbr18) = brix[3];

  SCBX(SCBbr19) = brix[3];

  SCBX(SCBbr20) = brix[3];
 
 
 brix[4] = 125-horszone;
  SCBX(SCBbr21) = brix[4];

  SCBX(SCBbr22) = brix[4];

  SCBX(SCBbr23) = brix[4];

  SCBX(SCBbr24) = brix[4];

  SCBX(SCBbr25) = brix[4];
 
 
 if (horszone>0)
  {
  horszone=horszone-4;
  if (horszone<1)  horszone=0;
  }

}



/**************************************************************************

ATTENTION : Ci-dessous des tableaux de valeurs : ces valeurs ne pourront pas �tre modifi� par la suite.

La variable brie[25] sera donc utilis� pour modifier l'�tat des 25 briques.
**************************************************************************/


#include "fifi.h"

/**************************************************************************
**                                                                       **
**                                                                       **
**************************************************************************/

char main()
{
  InitIRQ();
  CLI;

  SetBuffers(SCREEN, RENDER ,0);



  posx=76;  
  posy=47;  
  xpush=-48;
  ypush=34;
//  SCBX(SCB) = 60;
//  SCBY(SCB) = 42;
//  SCBDATA(SCB) = ititre;

// 1er sprite chain� (fond + raquette)
  SCBX(SCBg) = 0;
  SCBY(SCBg) = 0;
  SCBDATA(SCBg) = fondg;

  SCBNEXT(SCBg) = SCBp; // chainage de sprite info commande
  SCBX(SCBp) = xpush;
  SCBY(SCBp) = ypush;
  SCBDATA(SCBp) = pushup;
//SCBCTL0(SCBp)= 0x001;//99; // pas glop
  SCBNEXT(SCBp) = SCBr; // chainage de sprite raquette
  SCBX(SCBr) = -200;
  SCBY(SCBr) = 0;
  SCBDATA(SCBr) = raquet;  

  SCBNEXT(SCBr) = SCBfd; // chainage de sprite fleche directionnelle
  SCBX(SCBfd) = 0;
  SCBY(SCBfd) = 0;
  SCBDATA(SCBfd) = fdtab[dirf%7];//fleche;  

horszone=150;// mettre les briques hors de l'�cran visible. Sprite brique d'une taille de 6*14, 0=normale 1=dure 2=incassable.
  SCBNEXT(SCBfd) = SCBbr01; // chainage de la brique 01
  SCBX(SCBbr01) = 85-horszone;
  SCBY(SCBbr01) = 16;
  SCBDATA(SCBbr01) = brtab[0%4]; //
  SCBNEXT(SCBbr01) = SCBbr02; // chainage de la brique 02
  SCBX(SCBbr02) = 85-horszone;
  SCBY(SCBbr02) = 16+14;
  SCBDATA(SCBbr02) = brtab[0%4]; //
  SCBNEXT(SCBbr02) = SCBbr03; // chainage de la brique 03
  SCBX(SCBbr03) = 85-horszone;
  SCBY(SCBbr03) = 16+28;
  SCBDATA(SCBbr03) = brtab[0%4]; //
  SCBNEXT(SCBbr03) = SCBbr04; // chainage de la brique 04
  SCBX(SCBbr04) = 85-horszone;
  SCBY(SCBbr04) = 16+42;
  SCBDATA(SCBbr04) = brtab[0%4]; //
  SCBNEXT(SCBbr04) = SCBbr05; // chainage de la brique 05
  SCBX(SCBbr05) = 85-horszone;
  SCBY(SCBbr05) = 16+56;
  SCBDATA(SCBbr05) = brtab[0%4]; //

  SCBNEXT(SCBbr05) = SCBbr06; // chainage de la brique 06
  SCBX(SCBbr06) = 95-horszone;
  SCBY(SCBbr06) = 16;
  SCBDATA(SCBbr06) = brtab[0%4]; //
  SCBNEXT(SCBbr06) = SCBbr07; // chainage de la brique 07
  SCBX(SCBbr07) = 95-horszone;
  SCBY(SCBbr07) = 16+14;
  SCBDATA(SCBbr07) = brtab[0%4]; //
  SCBNEXT(SCBbr07) = SCBbr08; // chainage de la brique 08
  SCBX(SCBbr08) = 95-horszone;
  SCBY(SCBbr08) = 16+28;
  SCBDATA(SCBbr08) = brtab[0%4]; //
  SCBNEXT(SCBbr08) = SCBbr09; // chainage de la brique 09
  SCBX(SCBbr09) = 95-horszone;
  SCBY(SCBbr09) = 16+42;
  SCBDATA(SCBbr09) = brtab[0%4]; //
  SCBNEXT(SCBbr09) = SCBbr10; // chainage de la brique 10
  SCBX(SCBbr10) = 95-horszone;
  SCBY(SCBbr10) = 16+56;
  SCBDATA(SCBbr10) = brtab[0%4]; //

  SCBNEXT(SCBbr10) = SCBbr11; // chainage de la brique 11
  SCBX(SCBbr11) = 105-horszone;
  SCBY(SCBbr11) = 16;
  SCBDATA(SCBbr11) = brtab[0%4]; //
  SCBNEXT(SCBbr11) = SCBbr12; // chainage de la brique 12
  SCBX(SCBbr12) = 105-horszone;
  SCBY(SCBbr12) = 16+14;
  SCBDATA(SCBbr12) = brtab[0%4]; //
  SCBNEXT(SCBbr12) = SCBbr13; // chainage de la brique 13
  SCBX(SCBbr13) = 105-horszone;
  SCBY(SCBbr13) = 16+28;
  SCBDATA(SCBbr13) = brtab[0%4]; //
  SCBNEXT(SCBbr13) = SCBbr14; // chainage de la brique 14
  SCBX(SCBbr14) = 105-horszone;
  SCBY(SCBbr14) = 16+42;
  SCBDATA(SCBbr14) = brtab[0%4]; //
  SCBNEXT(SCBbr14) = SCBbr15; // chainage de la brique 15
  SCBX(SCBbr15) = 105-horszone;
  SCBY(SCBbr15) = 16+56;
  SCBDATA(SCBbr15) = brtab[0%4]; //

  SCBNEXT(SCBbr15) = SCBbr16; // chainage de la brique 16
  SCBX(SCBbr16) = 115-horszone;
  SCBY(SCBbr16) = 16;
  SCBDATA(SCBbr16) = brtab[0%4]; //
  SCBNEXT(SCBbr16) = SCBbr17; // chainage de la brique 17
  SCBX(SCBbr17) = 115-horszone;
  SCBY(SCBbr17) = 16+14;
  SCBDATA(SCBbr17) = brtab[0%4]; //
  SCBNEXT(SCBbr17) = SCBbr18; // chainage de la brique 18
  SCBX(SCBbr18) = 115-horszone;
  SCBY(SCBbr18) = 16+28;
  SCBDATA(SCBbr18) = brtab[0%4]; //
  SCBNEXT(SCBbr18) = SCBbr19; // chainage de la brique 19
  SCBX(SCBbr19) = 115-horszone;
  SCBY(SCBbr19) = 16+42;
  SCBDATA(SCBbr19) = brtab[0%4]; //
  SCBNEXT(SCBbr19) = SCBbr20; // chainage de la brique 15
  SCBX(SCBbr20) = 115-horszone;
  SCBY(SCBbr20) = 16+56;
  SCBDATA(SCBbr20) = brtab[0%4]; //
 
  SCBNEXT(SCBbr20) = SCBbr21; // chainage de la brique 21
  SCBX(SCBbr21) = 125-horszone;
  SCBY(SCBbr21) = 16;
  SCBDATA(SCBbr21) = brtab[0%4]; //
  SCBNEXT(SCBbr21) = SCBbr22; // chainage de la brique 22
  SCBX(SCBbr22) = 125-horszone;
  SCBY(SCBbr22) = 16+14;
  SCBDATA(SCBbr22) = brtab[0%4]; //
  SCBNEXT(SCBbr22) = SCBbr23; // chainage de la brique 23
  SCBX(SCBbr23) = 125-horszone;
  SCBY(SCBbr23) = 16+28;
  SCBDATA(SCBbr23) = brtab[0%4]; //
  SCBNEXT(SCBbr23) = SCBbr24; // chainage de la brique 24
  SCBX(SCBbr24) = 125-horszone;
  SCBY(SCBbr24) = 16+42;
  SCBDATA(SCBbr24) = brtab[0%4]; //
  SCBNEXT(SCBbr24) = SCBbr25; // chainage de la brique 25
  SCBX(SCBbr25) = 125-horszone;
  SCBY(SCBbr25) = 16+56;
  SCBDATA(SCBbr25) = brtab[0%4]; //

  SCBNEXT(SCBbr25) = SCBball; // chainage de sprite balle
  SCBX(SCBball) = -200;
  SCBY(SCBball) = 0;
  SCBDATA(SCBball) = fball;  
 
  SCBNEXT(SCBball) = SCBscore1; // chainage score unit�
  SCBX(SCBscore1) = -10;
  SCBY(SCBscore1) = 99-8;
  SCBDATA(SCBscore1) = chiffrestab[0%14]; //
  SCBNEXT(SCBscore1) = SCBscore2; // chainage score dizaine
  SCBX(SCBscore2) = -10;
  SCBY(SCBscore2) = 99-16;
  SCBDATA(SCBscore2) = chiffrestab[0%14]; //
  SCBNEXT(SCBscore2) = SCBscore3; // chainage score centaine
  SCBX(SCBscore3) = -10;
  SCBY(SCBscore3) = 99-24;
  SCBDATA(SCBscore3) = chiffrestab[0%14]; //
  SCBNEXT(SCBscore3) = SCBscore4; // chainage score millier
  SCBX(SCBscore4) = -10;
  SCBY(SCBscore4) = 99-32;
  SCBDATA(SCBscore4) = chiffrestab[0%14]; //
 
  SCBNEXT(SCBscore4) = SCBlife; // chainage nombre de vie
  SCBY(SCBlife) = 9;
 
 
  //SCBX(SCBscore1) = -10;SCBX(SCBscore2) = -10;SCBX(SCBscore3) = -10;SCBX(SCBscore4) = -10; // score plac�s hors de l'�cran
 
  SCBNEXT(SCBlife) = SCBtexte1; // chainage texte 1
  SCBX(SCBtexte1) = 0;SCBY(SCBtexte1) = -200;
  SCBDATA(SCBtexte1) = chiffrestab[0%14]; //
 
  SCBNEXT(SCBtexte1) = SCBtexte2; // chainage texte 2
  SCBX(SCBtexte2) = 0;SCBY(SCBtexte2) = -200;
  SCBDATA(SCBtexte2) = chiffrestab[0%14]; //
 
  SCBNEXT(SCBtexte2) = SCBtexte3; // chainage texte 3
  SCBX(SCBtexte3) = 0;SCBY(SCBtexte3) = -200;
  SCBDATA(SCBtexte3) = chiffrestab[0%14]; //
 
  SCBNEXT(SCBtexte3) = SCBtexte4; // chainage texte 4
  SCBX(SCBtexte4) = 0;SCBY(SCBtexte4) = -200;
  SCBDATA(SCBtexte4) = chiffrestab[0%14]; //
 
  SCBNEXT(SCBtexte4) = SCBtexte5; // chainage texte 3
  SCBX(SCBtexte5) = 0;SCBY(SCBtexte5) = -200;
  SCBDATA(SCBtexte5) = chiffrestab[0%14]; //
 

 
 
  SCBNEXT(SCBtexte5) = SCBip; // chainage pause
  SCBX(SCBip) = 147;SCBY(SCBip) = -200;
  SCBDATA(SCBip) = ipause; //
 
 

 
 
// 2�me sprite chain� (test)
  SCBX(SCBchiffres1) = 0;SCBY(SCBchiffres1) = 0;
  //SCBDATA(SCBchiffres1) = chiffres;    
  SCBNEXT(SCBchiffres1) = SCBchiffres2; // chainage de sprite
  SCBX(SCBchiffres2) = 0;SCBY(SCBchiffres2) = 0;
  //SCBDATA(SCBchiffres2) = chiffres;  
  SCBNEXT(SCBchiffres2) = SCBchiffres3; // chainage de sprite
  SCBX(SCBchiffres3) = 0;SCBY(SCBchiffres3) = 0;
  //SCBDATA(SCBchiffres3) = chiffres;  
  SCBNEXT(SCBchiffres3) = SCBchiffres4; // chainage de sprite
  SCBX(SCBchiffres4) = 0;SCBY(SCBchiffres4) = 0;
  SCBNEXT(SCBchiffres4) = SCBchiffres5; // chainage de sprite
  SCBX(SCBchiffres5) = 0;SCBY(SCBchiffres5) = 0;


// truc bien pratique : associer les briques des tableaux � une variable num�rot�.
brdata[0] = SCBbr01;brdata[1] = SCBbr02;brdata[2] = SCBbr03;brdata[3] = SCBbr04;brdata[4] = SCBbr05;
brdata[5] = SCBbr06;brdata[6] = SCBbr07;brdata[7] = SCBbr08;brdata[8] = SCBbr09;brdata[9] = SCBbr10;
brdata[10] = SCBbr11;brdata[11] = SCBbr12;brdata[12] = SCBbr13;brdata[13] = SCBbr14;brdata[14] = SCBbr15;
brdata[15] = SCBbr16;brdata[16] = SCBbr17;brdata[17] = SCBbr18;brdata[18] = SCBbr19;brdata[19] = SCBbr20;
brdata[20] = SCBbr21;brdata[21] = SCBbr22;brdata[22] = SCBbr23;brdata[23] = SCBbr24;brdata[24] = SCBbr25;



/**************************************************************************
 ï¿½a marche !
  comptx=0;
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][0]%3];
  comptx=1;
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][1]%3];
  comptx=2;
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][2]%3];
  comptx=3;
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][3]%3];
  comptx=4;
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][4]%3];
**************************************************************************/


/**************************************************************************
 ï¿½a marche !
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 1ere rang�e de brique
  {
  SCBDATA(brdata[comptx]) = brtab[tbr01[0][comptx]%3];
  }
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 2eme rang�e de brique
  {
  SCBDATA(brdata[(comptx+5)]) = brtab[tbr01[1][comptx]%3];
  }
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 3eme rang�e de brique
  {
  SCBDATA(brdata[(comptx+10)]) = brtab[tbr01[2][comptx]%3];
  }
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 4eme rang�e de brique
  {
  SCBDATA(brdata[(comptx+15)]) = brtab[tbr01[3][comptx]%3];
  }
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 5eme rang�e de brique
  {
  SCBDATA(brdata[(comptx+20)]) = brtab[tbr01[4][comptx]%3];
  }
**/

 
/**************************************************************************
 ï¿½a marche !
 for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5. 1ere rang�e de brique
  {
  for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
   {
   SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr01[compty][comptx]%3];
   }
  }
**/


/**************************************************************************
**                       BOUCLE PRINCIPALE                               **
**************************************************************************/
   
  while(1)
{
//  for( ; ; )

  Vsync();
  SwapBuffers();
update_music(); // petite subtilit� de la gestion sonore





 ++gsblip; // economie ressource machine --> certaines des conditions n'ont pas besoin d'�tre lu par la LYNX � chaque boucle.
 if (gsblip==5)
 {
 gsblip=1;

 if (switches & BUTTON_PAUSE)
  {
  if (gspause==0) {gspause=1;silence();abcmusic(0,abcaptvir);}
  }
 if (!(switches & BUTTON_PAUSE))
  {
  if (gspause==1) gspause=2;
  }

 if (switches & BUTTON_PAUSE)
  {
  if (gspause==2) gspause=3;
  }

 if (!(switches & BUTTON_PAUSE))
  {
  if (gspause==3) gspause=0;
  }
 }



/**************************************************************************
**************************************************************************/

 if (etape>=0 & etape<=4)  // �cran titre
 {
  /* set the palette */
 SetRGB(pali); //  Ceci sert � changer la palette de la Lynx.
 DrawFBox(0,0,160,102,0); // couleur 0 (noire)
 
 SCBX(SCBlife) = -10;SCBDATA(SCBlife) = chiffrestab[3%14]; //
 
 SCBX(SCBr) = -200; // raquette mis hors de l'�cran
 SCBX(SCBball) = -200; // balle mis hors de l'�cran
 SCBX(SCBfd) = -200; // fleche directionnelle mis hors de l'�cran
 
 
 //SCBX(SCB) = 78-(molescx/gmole);SCBY(SCB) = 42-(molescy/gmole)

 //SCBX(SCB) = SCBX(SCB) - (molescx/6); SCBY(SCB) = SCBY(SCB) - (molescy/6);
 SCBX(SCB) = 78; SCBY(SCB) = 52;
 SCBDATA(SCB) = imole;

// SCBY(SCBacteur) = yacteur-(actscy/4);
// SCBY(SCBacteur) = SCBY(SCBacteur) + 16;
 
        //SCBHS(SCB) = 0x100;
        //SCBVS(SCB) = 0x100;

if (gspause==0)
 {

/**
 etape=1;molescx=256;molescy=256;
**/



/**

 if (etape==4) {
     if (molescx>256) molescx=molescx-4;
     if (molescy>128) molescy=molescy-8;
     if (molescx<257 & molescy<129) {molescx=256;molescy=128;etape=2;mhaut=4;}
     }
 if (etape==3) {
     if (molescx>128) molescx=molescx-8;
     if (molescy>256) molescy=molescy-4;
     if (molescx<129 & molescy<257) {molescx=128;molescy=256;etape=2;mbas=4;}
     }
 if (etape==2) {
     if (molescx<384) molescx=molescx+(4+mbas);
     if (molescy<384) molescy=molescy+(4+mhaut);
     if (molescx>383 & molescy>383)
      {
      molescx=384;molescy=384;++tempc;mhaut=0;mbas=0;
      if (tempc==3) tempc=1;
      if (tempc==1) etape=3;
      if (tempc==2) etape=4;
      }
     }
 if (etape==1) {
     ++tempb;
     if (tempb>64) {
         tempb=0;etape=2;
         }
     }
 if (etape==0) {
     if (molescx<256) {
          molescx=molescx+2;molescy=molescy+2;
          if (molescx>255) {molescx=256;molescy=256;etape=1;}
          }
     }
**/

 switch (etape)
  {
  case 0:
    molescx=molescx+2;molescy=molescy+2;
  break;
  }
 if (molescx>255) {molescx=256;molescy=256;etape=1;}
 
 
 
 SCBY(SCBip) = -50;
 }// if (gspause==0)
 else
 {
 SCBY(SCBip) = 30; // coordonn�es image pause
 }
 
 
 
 SCBHS(SCB) = molescx;
 SCBVS(SCB) = molescy;
 DrawSprite(SCB); // affichage molecule
 
 if (etape>0) {SCBHS(SCB) = 256;SCBVS(SCB) = 256;} // remise � 0 echelle des images SCB
 SCBX(SCB) = 34; SCBY(SCB) = 2; SCBDATA(SCB) = iname; DrawSprite(SCB);  
 SCBX(SCB) = 74; SCBY(SCB) = 26; SCBDATA(SCB) = ititre; DrawSprite(SCB);

//
 SCBX(SCBscore1) = 4;SCBX(SCBscore2) = 4;SCBX(SCBscore3) = 4;SCBX(SCBscore4) = 4;SCBX(SCBscore1) = 4;
 SCBDATA(SCBscore1) = chiffrestab[0%14];  
 SCBDATA(SCBscore2) = chiffrestab[1%14];
 SCBDATA(SCBscore3) = chiffrestab[0%14];
 SCBDATA(SCBscore4) = chiffrestab[2%14];


 SCBX(SCBp) = xpush;//48;
 SCBY(SCBp) = ypush;

 SCBY(SCBg) = -200; // fond zone de jeu
 SCBX(SCBr) = -200; // raquette
 
 DrawSprite(SCBg); // Affichage fond jeu + info commande + raquette + balle + fleche directionnelle + briques + score + texte + pause
 
 if (gspause==0 & etape>0)
  {
  if (xpush<8)  xpush=xpush+2; // apparition de la bulle info "Push UP"
  if (xpush>7)//(tempa>24 & etape==0) // petite teporisation avant d'autoriser le joueur de recommencer le jeu.
   {
   xpush=8;
   ++tempa; // bulle info clignote doucement
   if (tempa>63) tempa=1;
   if (tempa>0 & tempa<32)  ypush=34;
   if (tempa>31) ypush=-100;

   if (joystick & JOY_RIGHT)
    {
    level=1;//3;//1;
    tempa=0;tempb=0;etape=9;//xpush=-48;ypush=34;xlvla=160;xlvlb=160;xlvlc=160;xlvld=160;xlvle=160;elvl=0;
    xpush=-48;ypush=34;
    score=0;
    filife=3;
    // bruitage menu :
    silence();
    abcmusic(0,abcmenu1);
    abcmusic(1,abcmenu2);


//   // bruitage panne s�che :
//   silence();
//   abcmusic(3,abcpanne);

    SetRGB(palg); //  Ceci sert � changer la palette de la Lynx.
    SCBY(SCBg) = 0; // fond zone de jeu.
    SCBX(SCBp) = xpush;
    relach=1;
   
     SCBDATA(SCBscore1) = chiffrestab[0%14];
     SCBDATA(SCBscore2) = chiffrestab[0%14];
     SCBDATA(SCBscore3) = chiffrestab[0%14];
     SCBDATA(SCBscore4) = chiffrestab[0%14];
     

   
   
   
   
   
    }
   }
  }
 //TextOut(24, 2, 2, 0, "Philippe Haouli present"); // lettre grise 32,32,32
 //TextOut(24, 2, 1, 0, "Philippe Haouli"); // lettre blanche

 }

/**************************************************************************
**************************************************************************/

 if (etape==9)  // coordonn�es affichage texte "LEVEL", et surtout application des choix de la nature des briques (voir tables de donn�es plus haut).
 {
 ++etape;
     SCBX(SCBtexte1) = 140; SCBY(SCBtexte1) = 18; SCBDATA(SCBtexte1) = chiffrestab[11%14]; // L
     SCBX(SCBtexte2) = 140; SCBY(SCBtexte2) = 26; SCBDATA(SCBtexte2) = chiffrestab[12%14]; // E
     SCBX(SCBtexte3) = 140; SCBY(SCBtexte3) = 34; SCBDATA(SCBtexte3) = chiffrestab[13%14]; // V
     SCBX(SCBtexte4) = 140; SCBY(SCBtexte4) = 42; SCBDATA(SCBtexte4) = chiffrestab[12%14]; // E
     SCBX(SCBtexte5) = 140; SCBY(SCBtexte5) = 50; SCBDATA(SCBtexte5) = chiffrestab[11%14]; // L

 if (level>0 & level<13)
  {
  for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
   {
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    if (level==1) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr01[compty][comptx]%4];
    if (level==2) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr02[compty][comptx]%4];
    if (level==3) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr03[compty][comptx]%4];
    if (level==4) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr04[compty][comptx]%4];
    if (level==5) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr05[compty][comptx]%4];
   
    if (level==6) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr06[compty][comptx]%4];
    if (level==7) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr07[compty][comptx]%4];
    if (level==8) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr08[compty][comptx]%4];
    if (level==9) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr09[compty][comptx]%4];
    if (level==10) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr10[compty][comptx]%4];
   
    if (level==11) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr11[compty][comptx]%4];
    if (level==12) SCBDATA(brdata[comptx+(compty*5)]) = brtab[tbr12[compty][comptx]%4];
    }
   }
//brsco=25;// nombre initial de brique � casser
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==1)
   {
/************************************************************************** ok
**************************************************************************/

   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr01[comptx][compty];
     ++brnbr;
     //if (brie[brnbr]==0 | brie[brnbr]==3) --brsco; // nombre de brique � casser
     //if (brie[brnbr]==0)  --brsco; // nombre de brique � casser
     //if (brie[brnbr]==3)  --brsco; // nombre de brique � casser
     }
    }
/**
brnbr=0; // �tat des briques, de 0 � 24.


   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
     {
     brif[brnbr]=tbr01[comptx][compty];
     ++brnbr;
     }
    }
**/

/************************************************************************** ok
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brif[compty]=tbr01[compty][0];
    }

   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brie[compty]=tbr01[0][compty];
    }
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brie[compty+5]=tbr01[1][compty];
    }
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brie[compty+10]=tbr01[2][compty];
    }
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brie[compty+15]=tbr01[3][compty];
    }
   for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
    {
    brie[compty+20]=tbr01[4][compty];
    }
**************************************************************************/


/************************************************************************** ok
  brif[0]=tbr01[0][0];
  brif[1]=tbr01[1][0];
  brif[2]=tbr01[2][0];
  brif[3]=tbr01[3][0];
  brif[4]=tbr01[4][0];

  brif[5]=tbr01[1][1];
  brif[6]=tbr01[1][1];
  brif[7]=tbr01[1][2];
  brif[8]=tbr01[1][3];
  brif[9]=tbr01[1][4];
 
   brie[0]=tbr01[0][0];
   brie[1]=tbr01[0][1];
   brie[2]=tbr01[0][2];
   brie[3]=tbr01[0][3];
   brie[4]=tbr01[0][4];

   brie[5]=tbr01[1][1];
   brie[6]=tbr01[1][1];
   brie[7]=tbr01[1][2];
   brie[8]=tbr01[1][3];
   brie[9]=tbr01[1][4];

   brie[10]=tbr01[2][1];
   brie[11]=tbr01[2][1];
   brie[12]=tbr01[2][2];
   brie[13]=tbr01[2][3];
   brie[14]=tbr01[2][4];

   brie[15]=tbr01[3][1];
   brie[16]=tbr01[3][1];
   brie[17]=tbr01[3][2];
   brie[18]=tbr01[3][3];
   brie[19]=tbr01[3][4];

   brie[20]=tbr01[4][1];
   brie[21]=tbr01[4][1];
   brie[22]=tbr01[4][2];
   brie[23]=tbr01[4][3];
   brie[24]=tbr01[4][4];
**************************************************************************/

   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==2)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr02[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==3)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr03[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==4)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr04[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==5)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr05[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==6)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr06[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==7)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr07[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==8)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr08[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==9)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr09[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==10)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr10[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==11)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr11[comptx][compty];
     ++brnbr;
     }
    }
   }
brnbr=0; // �tat des briques, de 0 � 24.
  if (level==12)
   {
   for(comptx=0 ; comptx<5; comptx++) // de 0 � 4, ce qui fait 5.
    {
    for(compty=0 ; compty<5; compty++) // de 0 � 4, ce qui fait 5.
     {
     brie[brnbr]=tbr12[comptx][compty];
     ++brnbr;
     }
    }
   }
  brsco[0]=19; // nombre de brique � casser
  brsco[1]=19; // nombre de brique � casser
  brsco[2]=18; // nombre de brique � casser
  brsco[3]=8; // nombre de brique � casser
  brsco[4]=17; // nombre de brique � casser
  brsco[5]=15; // nombre de brique � casser
  brsco[6]=15; // nombre de brique � casser
  brsco[7]=16; // nombre de brique � casser
  brsco[8]=12; // nombre de brique � casser
  brsco[9]=13; // nombre de brique � casser
  brsco[10]=15; // nombre de brique � casser
  brsco[11]=12; // nombre de brique � casser
  }
 
 
 }


/**************************************************************************
**************************************************************************/

 if (etape==10)  // ecran level
 {
 
 ShowScreen(); // Coordonn�es de toutes les briques (voir au d�but de ce joyeux code).
 
 SCBX(SCBp) = xpush;//48;
 SCBY(SCBp) = ypush;
 
 SCBX(SCBr) = -200; // Coordonn�e X de la raquette (ici mis hors de l'�cran).
 DrawSprite(SCBg); // Affichage fond jeu + info commande + raquette + balle + fleche directionnelle + briques + score + texte + pause
 
 unite = level % 10;
 dizaine = level / 10 % 10;
 // unit�:  
 SCBDATA(SCBchiffres1) = chiffrestab[unite%14];
 SCBX(SCBchiffres1) = 140;
 SCBY(SCBchiffres1) = 50+24;  
 
 // dizaine:  
 SCBDATA(SCBchiffres2) = chiffrestab[dizaine%14];
 SCBX(SCBchiffres2) = 140;
 SCBY(SCBchiffres2) = 50+16;  
 
 DrawSprite(SCBchiffres1); // Affichage valeur test�  
 
 
 if (relach==1) {
     if (!(joystick & JOY_RIGHT)) {relach=0;} // utile pour v�rifier si le joueur n'appui plus sur D-pad haut
     }
 if (gspause==0)
  {
  if (xpush<8 & horszone==0) xpush=xpush+2;
  if (xpush>7)//(tempa>24 & etape==0) // petite teporisation avant d'autoriser le joueur de recommencer le jeu.
   {
   xpush=8;

   ++tempa; // bulle info clignote doucement
   if (tempa>63)  tempa=1;
   if (tempa>0 & tempa<32)  ypush=34;
   if (tempa>31)  ypush=200;  
 
   if (relach==0 & horszone==0)
    {
    if (joystick & JOY_RIGHT) {
           //level=1;//3;//1;
           tempa=0;tempb=0;etape=20,yplayer=51;//xpush=-48;ypush=34;xlvla=160;xlvlb=160;xlvlc=160;xlvld=160;xlvle=160;elvl=0;
           xpush=-48;ypush=34;
           dirf=3;ydirf=6;
           SCBY(SCBtexte1) = -200;SCBY(SCBtexte2) = -200;SCBY(SCBtexte3) = -200;SCBY(SCBtexte4) = -200;SCBY(SCBtexte5) = -200;
           SCBX(SCBlife) = 4;
           score=0;
           // bruitage menu :
           silence();
           abcmusic(0,abcmenu1);
           abcmusic(1,abcmenu2);


//   // bruitage panne s�che :
//   silence();
//   abcmusic(3,abcpanne);

        //SetRGB(palg); //  Ceci sert � changer la palette de la Lynx.
        //SCBX(SCBg) = 0; // fond zone de jeu
           SCBX(SCBp) = xpush;
        //SCBX(SCBr) = 200; // raquette
       

           relach=1; // utile pour v�rifier si le joueur n'appui plus sur D-pad haut
       
           //Vsync();
           //SwapBuffers();
           }
    }
   }
  SCBY(SCBip) = -50;
  }// if (gspause==0)
  else
  {
  SCBY(SCBip) = 30; // coordonn�es image pause
  }
 
 
 
 
 
 }

/**************************************************************************
**************************************************************************/

 if (etape==20)  // �cran jeu 1 (fleche directionnelle)
 {
 // raquette :
 SCBX(SCBr) = 24;//32;
 SCBY(SCBr) = yplayer;
 
 // balle :
 SCBX(SCBball) = 34;//+110;//42
 SCBY(SCBball) = 51;
 
 // fleche directionnelle :
 SCBDATA(SCBfd) = fdtab[dirf%7];
 SCBX(SCBfd) = 39;
 SCBY(SCBfd) = 38+ydirf;

 if (gspause==0)
  {
  if (tempa>0) {--tempa;}

  if (joystick & JOY_DOWN)
   {
   if (tempa==0 & dirf<6) {++dirf;tempa=16;++ydirf;++ydirf;}
   }
  if (joystick & JOY_UP)
   {
   if (tempa==0 & dirf>0) {--dirf;tempa=16;--ydirf;--ydirf;}
   }

  if (relach==1)
   {
   if (!(joystick & JOY_RIGHT)) {relach=0;} // utile pour v�rifier si le joueur n'appui plus sur D-pad haut
   }
  if (joystick & JOY_RIGHT)
   {
   if (relach==0) {
       SCBX(SCBfd) = -200; // fleche directionnelle mis hors de l'�cran
       dirf=dirf-3;bdirx=1;
       tempa=0;etape=30;
       balldirX=SCBX(SCBball);
       balldirY=SCBY(SCBball);
       }
   }
 
 
  SCBY(SCBip) = -50;
  }// if (gspause==0)
  else
  {
  SCBY(SCBip) = 30; // coordonn�es image pause
  }
  //}
 DrawSprite(SCBg); // Affichage fond jeu + info commande + raquette + balle + fleche directionnelle + briques + score + texte + pause
 }

/**************************************************************************
**************************************************************************/

 if (etape==30)  // �cran jeu 2
 {
 if (gspause==0)
  {
  if (dirf<0) // Si la balle se dirige vers la gauche, alors...
   {
   if (balldirY<3)
    {
    balldirY=3;dirf=-dirf; // cadre gauche
    // bruitage balle cadre:
    silence();
    abcmusic(1,abcball2);
    }
   if (dirf==-3)  {
       ++Ytemp;
       if (Ytemp>1) {Ytemp=0;balldirY=balldirY-3;odirx=3;} // vitesse Y r�elle --> -1,5
       }
   if (dirf==-2)  {balldirY=balldirY-1;odirx=2;} // vitesse Y --> -1
   if (dirf==-1)  {
       ++Ytemp;odirx=1;
       if (Ytemp>1) {Ytemp=0;balldirY=balldirY-1;} // vitesse Y r�elle --> -0,5
       }
   }

  if (dirf==0) {odirx=0;} // vitesse X --> +2 balle se dirige droit devant.

  if (dirf>0) // Si la balle se dirige vers la droite, alors...
   {
   if (dirf==1)  {
       ++Ytemp;odirx=1;
       if (Ytemp>1) {Ytemp=0;balldirY=balldirY+1;} // vitesse Y r�elle --> +0,5
       }
   if (dirf==2)  {balldirY=balldirY+1;odirx=2;} // vitesse Y --> +1
   if (dirf==3)  {
       ++Ytemp;
       if (Ytemp>1) {Ytemp=0;balldirY=balldirY+3;odirx=3;} // vitesse Y r�elle --> +1,5
       }
       
   if (balldirY>93)
    {
    balldirY=93;dirf=-dirf;// cadre droite (102-6 = 96-3 = 93)
    // bruitage balle cadre:
    silence();
    abcmusic(1,abcball2);
    }
//   balldirY=balldirY+2;
   //balldirY=balldirY+dirf;
   
   //if (dirf==1) {balldirY=balldirY+1;speedX=1;}
   //if (dirf==2) {balldirY=balldirY+2;speedX=3;}
   //if (dirf==3) {balldirY=balldirY+2;speedX=5;}

   }
   
   
   
   //If bille()\balldirY=0:bille()\bally-(3+bille()\speed):EndIf    
   //If bille()\balldirY=1:bille()\bally+(3+bille()\speed):EndIf
  if (odirx==0)
   {
   //if (bdirx==1) balldirX=balldirX+2; // vitesse X --> +2
   //if (bdirx==-1) balldirX=balldirX-2; // vitesse X --> -2
   
   ++Xtemp;
   if (Xtemp>1)
    {
    Xtemp=0;
    if (bdirx==1) balldirX=balldirX+3; // vitesse X r�elle --> +1,5
    if (bdirx==-1) balldirX=balldirX-3; // vitesse X r�elle --> -1,5
    }
   }
  if (odirx==1)
   {
   ++Xtemp;
   if (Xtemp>1)
    {
    Xtemp=0;
    if (bdirx==1) balldirX=balldirX+3; // vitesse X r�elle --> +1,5
    if (bdirx==-1) balldirX=balldirX-3; // vitesse X r�elle --> -1,5
    }
   }
  if (odirx==2)
   {
   if (bdirx==1) balldirX=balldirX+1;  // vitesse X --> +1
   if (bdirx==-1) balldirX=balldirX-1;  // vitesse X --> -1
   }
  if (odirx==3)
   {
   ++Xtemp;
   if (Xtemp>1)
    {
    Xtemp=0;
    if (bdirx==1) balldirX=balldirX+1; // vitesse X r�elle --> +0,5
    if (bdirx==-1) balldirX=balldirX-1; // vitesse X r�elle --> -0,5
    }
   }
  if (bdirx==1) { // Si la balle monte
       if (balldirX>154)
        {// collision haut du cadre: changement de direction
        balldirX=154;bdirx=-bdirx; // inverse la direction de la balle
        if (dirf==0) {
            basar=random()%3; // de 0 � 2
            --basar;dirf=basar; // -1 ou 0 ou 1
            }
        // bruitage balle cadre:
        silence();
        abcmusic(1,abcball2);
        }
      }
  if (bdirx==-1) { // Si la balle descend
     
      if (balldirX<18) // provisoire
       {// collision bas du cadre: changement de direction
        //balldirX=18;bdirx=-bdirx; // inverse la direction de la balle
        etape=50;gsblip=1;--filife; // aie !
       }
       
      //if (balldirX>34 & balldirX<42)// collision ball/raquette: changement de direction
      if (balldirX>26 & balldirX<34)// collision ball/raquette: changement de direction
       {
       if (balldirY>yplayer-13 & balldirY<yplayer+13)
        {
         balldirX=34;bdirx=-bdirx;
         // bruitage balle raquette:
         silence();
         abcmusic(0,abcball1);
         
         //centre de la raquette :
         if (balldirY>yplayer-3 & balldirY<yplayer+3)
          {
          if (dirf==1) {dirf=0;oboucl=1;}
          if (dirf==2) {dirf=1;oboucl=1;}
          if (dirf==3) {dirf=2;oboucl=1;}
         
          if (dirf==-1) {dirf=0;oboucl=1;}
          if (dirf==-2) {dirf=-1;oboucl=1;}
          if (dirf==-3) {dirf=-2;oboucl=1;}
          }
         if (oboucl==1) {oboucl=0;goto test_finish;}
         
         //gauche de la raquette :
         if (balldirY>yplayer-8 & balldirY<yplayer-2)
          {
          //if (dirf==-1) {dirf=-2;oboucl=1;}
          if (dirf==-1) {dirf=-1;oboucl=1;}
          if (dirf==-3) {dirf=-2;oboucl=1;}
         
          if (dirf==1) {dirf=-1;oboucl=1;}
          if (dirf==2) {dirf=-2;oboucl=1;}
          if (dirf==3) {dirf=-2;oboucl=1;}
         
          if (dirf==0) {dirf=-1;oboucl=1;}
          }
         if (oboucl==1) {oboucl=0;goto test_finish;}
         
         //droite de la raquette :
         if (balldirY>yplayer+2 & balldirY<yplayer+8)
          {
          //if (dirf==1) {dirf=2;oboucl=1;}
          if (dirf==1) {dirf=1;oboucl=1;}
          if (dirf==3) {dirf=2;oboucl=1;}
         
          if (dirf==-1) {dirf=1;oboucl=1;}
          if (dirf==-2) {dirf=2;oboucl=1;}
          if (dirf==-3) {dirf=2;oboucl=1;}
         
          if (dirf==0) {dirf=1;oboucl=1;}
          }
         if (oboucl==1) {oboucl=0;goto test_finish;}
         
         //exgauche de la raquette :
         if (balldirY>yplayer-13 & balldirY<yplayer-7)
          {
          if (dirf==-1) {dirf=-2;oboucl=1;}//break;
          if (dirf==-2) {dirf=-3;oboucl=1;}
         
          if (dirf==1) {dirf=-2;oboucl=1;}
          if (dirf==2) {dirf=-3;oboucl=1;}
          if (dirf==3) {dirf=-3;oboucl=1;}
         
          if (dirf==0) {dirf=-2;oboucl=1;}
          }
         if (oboucl==1) {oboucl=0;goto test_finish;}
         
         //exdroite de la raquette :
         if (balldirY>yplayer+7 & balldirY<yplayer+13)
          {
          if (dirf==1) {dirf=2;oboucl=1;}
          if (dirf==2) {dirf=3;oboucl=1;}
         
          if (dirf==-1) {dirf=2;oboucl=1;}
          if (dirf==-2) {dirf=3;oboucl=1;}
          if (dirf==-3) {dirf=3;oboucl=1;}
         
          if (dirf==0) {dirf=2;oboucl=1;}
          }
         if (oboucl==1) {oboucl=0;goto test_finish;}
        }
       }
      }
   
test_finish:
   
  if (joystick & JOY_DOWN) {
         yplayer=yplayer+2;
         if (yplayer>87) {yplayer=87;} // (102-24 = 78-3 = 75) ; 24 = largeur de la raquette
         }
  if (joystick & JOY_UP)  {
         yplayer=yplayer-2;
         if (yplayer<15) {yplayer=15;}
         }

   
 SCBX(SCBball)=balldirX;SCBY(SCBball)=balldirY; // appliquer les variables balldirX et balldirY aux coordonn�es de la balle.
 SCBY(SCBr) = yplayer;
 
 
 

ShowScreen(); // Coordonn�es de toutes les briques (voir au d�but de ce joyeux code).

// test Balle/briques : la lutte est rude ;)
//upbri=0;
 if (fsaut==0)
  {
  cible=0;bbcontact=0;
  if (balldirX<brix[0]-3 | balldirX>brix[4]+12)  goto stop_test;//15
 
  if (balldirY>16-1 & balldirY<30) cible=1;
  if (balldirY>30-1 & balldirY<44) cible=2;
  if (balldirY>44-1 & balldirY<58) cible=3;
  if (balldirY>58-1 & balldirY<72) cible=4;
  if (balldirY>72-1 & balldirY<86) cible=5;
 
 
  if (cible>0)
   {
   // +10 ou +11 ou +12
   if (balldirX>brix[0]+9 & balldirX<brix[0]+13) upbri=1; // haut brique de 0 � 4
   if (balldirX>brix[1]+9 & balldirX<brix[1]+13) upbri=2; // haut brique de 5 � 9
   if (balldirX>brix[2]+9 & balldirX<brix[2]+13) upbri=3; // haut brique de 10 � 14
   //if (balldirX>brix[3]+9 & balldirX<brix[3]+13) upbri=4; // haut brique de 15 � 19
   //if (balldirX>brix[4]+9 & balldirX<brix[4]+13) upbri=5; // haut brique de 20 � 24
   
   if (balldirX>brix[1]-4) cible=cible+5;
   if (balldirX>brix[2]-4) cible=cible+5;
   if (balldirX>brix[3]-4) cible=cible+5;
   if (balldirX>brix[4]-4) cible=cible+5;
   --cible;

   /** La variable brie[25] sera donc utilis� pour modifier l'�tat des 25 briques. **/
   if (brie[cible] == 1)
    {
    brie[cible]=0;score+=10;SCBDATA(brdata[0 + cible]) = brtab[0%4];bbcontact=1;
    --level;--brsco[level];
    if (brsco[level]==0) etape=40; // toutes les briques destrutibles sont d�truites : passage au niveau suivant...
    ++level;
    silence();abcmusic(2,abcball3);
    }
   if (brie[cible] == 2)   {brie[cible]=1;score+=10;SCBDATA(brdata[0 + cible]) = brtab[1%4];bbcontact=1;silence();abcmusic(2,abcball3);}
   if (brie[cible] == 3)   {bbcontact=1;}
   
   if (bbcontact==1)
    {
    fsaut=1; // suite � une collision balle/brique, laisser un cycle avant d'autoriser � nouveaux les tests (ceci dit, je ne suis pas s�r de ce choix, hum).
    if (dirf>0) // Si la balle se dirige vers la droite, alors...
    {
    //if ((balldirY>15 & balldirY<19) | (balldirY>29 & balldirY<33) | (balldirY>43 & balldirY<47) | (balldirY>57 & balldirY<61) | (balldirY>71 & balldirY<75))
    if ( (balldirY>15-3 & balldirY<19) | (balldirY>29-3 & balldirY<33) | (balldirY>43-3 & balldirY<47) | (balldirY>57-3 & balldirY<61) | (balldirY>71-3 & balldirY<75))
     {
     if ((balldirX>85-1 & balldirX<85+10) | (balldirX>95-1 & balldirX<95+10) | (balldirX>105-1 & balldirX<105+10) | (balldirX>115-1 & balldirX<115+10) | (balldirX>125-1 & balldirX<125+10))
      {rebcot=1;goto stop_test;} // c�t� gauche
     }
    }
    if (dirf<0) // Si la balle se dirige vers la gauche, alors...
    {
    //if ((balldirY>26 & balldirY<30) | (balldirY>40 & balldirY<44) | (balldirY>54 & balldirY<58) | (balldirY>68 & balldirY<72) | (balldirY>82 & balldirY<86))
    if ((balldirY>26 & balldirY<30+3) | (balldirY>40 & balldirY<44+3) | (balldirY>54 & balldirY<58+3) | (balldirY>68 & balldirY<72+3) | (balldirY>82 & balldirY<86+3))
     {
     if ((balldirX>85-1 & balldirX<85+10) | (balldirX>95-1 & balldirX<95+10) | (balldirX>105-1 & balldirX<105+10) | (balldirX>115-1 & balldirX<115+10) | (balldirX>125-1 & balldirX<125+10))
      {rebcot=2;goto stop_test;} // c�t� droite
     }
    }
   
    if (cible>-1 & cible<5 ) // de 0 � 4
     { // brix[0] = 85-horszone; // & (balldirY>18 & balldirY<27)balldirX=balldirX-3;balldirX=balldirX+3;
     // si balle monte :
     if (bdirx==1 & (balldirX>brix[0]-4 & balldirX<brix[0])) // -3 ou -2 ou -1
      {bdirx=-bdirx;balldirX=brix[0]-4;goto stop_test;}//++atest;}
     // si balle descend :
//     if (bdirx==-1 & (balldirX>brix[0]+9 & balldirX<brix[0]+13)) // +10 ou +11 ou +12
     if (bdirx==-1 & upbri==1) // +10 ou +11 ou +12
      {++atest;bdirx=-bdirx;balldirX=brix[0]+13;goto stop_test;}
     }
    if (cible>4 & cible<10 ) // de 5 � 9
     { // brix[1] = 95-horszone; // & (balldirY>32 & balldirY<41)
     // si balle monte :
     if (bdirx==1 & (balldirX>brix[1]-4 & balldirX<brix[1])) // -3 ou -2 ou -1
      {bdirx=-bdirx;balldirX=brix[1]-4;goto stop_test;}
     // si balle descend :
//     if (bdirx==-1 & (balldirX>brix[1]+9 & balldirX<brix[1]+13)) // +10 ou +11 ou +12
     if (bdirx==-1 & upbri==2) // +10 ou +11 ou +12
      {++atest;bdirx=-bdirx;balldirX=brix[1]+13;goto stop_test;}
     }
    if (cible>9 & cible<15 ) // de 10 � 14
     { // brix[2] = 105-horszone; // & (balldirY>46 & balldirY<55)
     // si balle monte :
     if (bdirx==1 & (balldirX>brix[2]-4 & balldirX<brix[2])) // -3 ou -2 ou -1
      {bdirx=-bdirx;balldirX=brix[2]-4;goto stop_test;}
     // si balle descend :
//     if (bdirx==-1 & (balldirX>brix[2]+9 & balldirX<brix[2]+13)) // +10 ou +11 ou +12
     if (bdirx==-1 & upbri==3) // +10 ou +11 ou +12
      {++atest;bdirx=-bdirx;balldirX=brix[2]+13;goto stop_test;}
     }
    if (cible>14 & cible<20 ) // de 15 � 19
     { // brix[4] = 115-horszone; // & (balldirY>60 & balldirY<69)
     // si balle monte :
     if (bdirx==1 & (balldirX>brix[3]-4 & balldirX<brix[3])) // -3 ou -2 ou -1
      {bdirx=-bdirx;balldirX=brix[3]-4;goto stop_test;}
     // si balle descend :
     if (bdirx==-1 & (balldirX>brix[3]+9 & balldirX<brix[3]+13)) // +10 ou +11 ou +12
//     if (bdirx==-1 & upbri==4) // +10 ou +11 ou +12
      {++atest;bdirx=-bdirx;balldirX=brix[3]+13;goto stop_test;}
     }
    if (cible>19 & cible<25 ) // de 20 � 24
     { // brix[4] = 125-horszone; // & (balldirY>74 & balldirY<83)
     // si balle monte :
     if (bdirx==1 & (balldirX>brix[4]-4 & balldirX<brix[4])) // -3 ou -2 ou -1
      {bdirx=-bdirx;balldirX=brix[4]-4;goto stop_test;}
     // si balle descend :
     if (bdirx==-1 & (balldirX>brix[4]+9 & balldirX<brix[4]+13)) // +10 ou +11 ou +12
//     if (bdirx==-1 & upbri==5) // +10 ou +11 ou +12
      {++atest;bdirx=-bdirx;balldirX=brix[4]+13;goto stop_test;}
     }

    }
   }
  }
  else
  {
  fsaut=0;
  }
stop_test:
if (rebcot==1)  {dirf=-dirf;balldirY=balldirY-3;}//
if (rebcot==2)  {dirf=-dirf;balldirY=balldirY+3;}//
rebcot=0;

//if (bdirx==-1)  {++atest;} // descend

  /** affichage du score et nombre de vie:
  **/

  //if (gsblip==1) // test effectu� 1 fois 5, car la mise � jour du score n'est pas une priorit� absolu...
  switch (gsblip)
  {
  case 1:
 
   unite = score % 10;
   dizaine = score / 10 % 10;
   centaine = score / 100 % 10;
   millier = score / 1000 % 10;
  // unit�:  
   SCBDATA(SCBscore1) = chiffrestab[unite%14];
  // dizaine:  
   SCBDATA(SCBscore2) = chiffrestab[dizaine%14];
  // centaine:  
   SCBDATA(SCBscore3) = chiffrestab[centaine%14];
  // millier:  
   SCBDATA(SCBscore4) = chiffrestab[millier%14];
   
   
   unite = filife % 10;
   SCBDATA(SCBlife) = chiffrestab[unite%14];
  break;
  }



  SCBY(SCBip) = -50;
  }// if (gspause==0)
 
 
 

else
{
 //scrollx=0; // vitesse de d�filement du d�cor
 SCBY(SCBip) = 30; // coordonn�es image pause
}
 
 
  DrawSprite(SCBg); // Affichage fond jeu + info commande + raquette + balle + fleche directionnelle + briques + score + texte + pause
 
 
}
/**************************************************************************
**************************************************************************/

 if (etape==40)  // passage au niveau suivant.
 {
    tempa=0;tempb=0;etape=9;//xpush=-48;ypush=34;xlvla=160;xlvlb=160;xlvlc=160;xlvld=160;xlvle=160;elvl=0;
    xpush=-48;ypush=34;
    ++level;
    if (level>12) level=1;
 // balle :
 SCBY(SCBball) = -20;
 horszone=150;// mettre les briques hors de l'�cran visible.
 }
/**************************************************************************
**************************************************************************/


 if (etape==50)  // perd une raquette !
 {
 SetRGB(palr); //  Ceci sert � changer la palette de la Lynx.
 DrawSprite(SCBg); // Affichage fond jeu + info commande + raquette + balle + fleche directionnelle + briques + score + texte + pause
 
 ++tempb;
 /**
 if (tempb>64)
  {
  tempb=0;
  SetRGB(palg); //  Ceci sert � changer la palette de la Lynx.
 
  yplayer=51;//xpush=-48;ypush=34;xlvla=160;xlvlb=160;xlvlc=160;xlvld=160;xlvle=160;elvl=0;
  dirf=3;ydirf=6;
 
  etape=20;
  // raquette :
  SCBX(SCBr) = 24;//32;
  SCBY(SCBr) = yplayer;
 
  // balle :
  SCBX(SCBball) = 34;//42
  SCBY(SCBball) = 51;
 
  // fleche directionnelle :
  SCBDATA(SCBfd) = fdtab[dirf%7];
  SCBX(SCBfd) = 39;
  SCBY(SCBfd) = 38+ydirf;
 

 
  }
 **/

 
 switch (tempb)
  {
  case 70:
  tempb=0;
  SetRGB(palg); //  Ceci sert � changer la palette de la Lynx.
 
  yplayer=51;//xpush=-48;ypush=34;xlvla=160;xlvlb=160;xlvlc=160;xlvld=160;xlvle=160;elvl=0;
  dirf=3;ydirf=6;
 
  etape=20;
  // raquette :
  SCBX(SCBr) = 24;//32;
  SCBY(SCBr) = yplayer;
 
  // balle :
  SCBX(SCBball) = 34;//42
  SCBY(SCBball) = 51;
 
  // fleche directionnelle :
  SCBDATA(SCBfd) = fdtab[dirf%7];
  SCBX(SCBfd) = 39;
  SCBY(SCBfd) = 38+ydirf;
  if (filife==0) {etape=0;horszone=150;ShowScreen();}
  break;
  }
 
 //if (filife==0) etape=0;
 
// switch (filife)
//  {
//  case 0:
//  etape=0;
///  break;
//  }
 }
/**************************************************************************
**************************************************************************/

/** test


 atest=upbri;//etape;//brsco[0];//ttest;//9;//balldirX;//yplayer;//speedX;//dirf;//etape;

 //atest=horszone;//relach;//etape;//SCBCTL0(SCBbr);
 unite = atest % 10;
 dizaine = atest / 10 % 10;
 centaine = atest / 100 % 10;
// millier = atest / 1000 % 10;
// dmillier = atest / 10000 % 10;
  // unit�:  
  SCBDATA(SCBchiffres1) = chiffrestab[unite%14];
  SCBX(SCBchiffres1) = 100;
  SCBY(SCBchiffres1) = 53;  

  // dizaine:  
  SCBDATA(SCBchiffres2) = chiffrestab[dizaine%14];
  SCBX(SCBchiffres2) = 100;
  SCBY(SCBchiffres2) = 53-8;

  // centaine:  
  SCBDATA(SCBchiffres3) = chiffrestab[centaine%14]; // 0
  SCBX(SCBchiffres3) = 100;
  SCBY(SCBchiffres3) = 53-16;
 
  // millier:  
//  SCBDATA(SCBchiffres4) = chiffrestab[millier%14]; // 0
//  SCBX(SCBchiffres4) = 100;
//  SCBY(SCBchiffres4) = 53-24;

  // dizaine de millier:  
//  SCBDATA(SCBchiffres5) = chiffrestab[dmillier%14]; // 0
//  SCBX(SCBchiffres5) = 100;
//  SCBY(SCBchiffres5) = 53-32;
 
  DrawSprite(SCBchiffres1); // Affichage valeur test�    

 **/


 

//  SCBDATA(SCBchiffres1) = chiffrestab[10%14];
//  SCBX(SCBchiffres1) = 40;
  //SCBY(SCBchiffres1) = yplayer;
//  SCBY(SCBchiffres1) = yplayer;//yplayer+23;  
 
/*** Tests important des coordonn�es des images ***/
// SCBDATA(SCBchiffres1) = chiffrestab[10%14];
// SCBX(SCBchiffres1) = SCBX(SCBball);
// SCBY(SCBchiffres1) = SCBY(SCBball);
/*** fin de ces tests de coordonn�e ***/
 
//  DrawSprite(SCBchiffres1); // Affichage valeur test�  



  //Vsync();
  //SwapBuffers();
 
}
 
/**************************************************************************
**                     FIN de la BOUCLE PRINCIPALE                       **
**************************************************************************/
 
 
 }

 
 
 
 
 
 
/*

#asm
vretrace:
 lda $fd0a
 bne vretrace
#endasm




  LDA bally
  CMP #TOPWALL
  BCS MoveBallUpDone      ;;if ball y > top wall, still on screen, skip next section
  LDA #$01
  STA balldown
  LDA #$00
  STA ballup         ;;bounce, ball now moving down
MoveBallUpDone:


MoveBallDown:
  LDA balldown
  BEQ MoveBallDownDone   ;;if ballup=0, skip this section

  LDA bally
  CLC
  ADC ballspeedy        ;;bally position = bally + ballspeedy
  STA bally

  LDA bally
  CMP #BOTTOMWALL
  BCC MoveBallDownDone      ;;if ball y < bottom wall, still on screen, skip next section


 
 
 
 
 
  LDA ballx
  SEC
  SBC ballspeedx        ;;ballx position = ballx - ballspeedx
  STA ballx  
 
 
 
LDA ballright
BEQ MoveBallRightDone // if ballright=0, skip this section  
*/

//#asm
//lda oboucl
//bne test_finish ;;// if oboucl=0, skip this section
//#endasm




//#asm
//vretrace:
// lda $fd0a
// bne vretrace
//#endasm