Voilà la source et je ne comprend toujours pas pourquoi ça ne fonctionne pas.
void PlaySound(void *Channel1, void *Channel2, short Tempo)
{
unsigned short tps1=0;
unsigned short tps2=0;
//unsigned short sav_tps1,sav_tps2;
unsigned short unittps;
unsigned char data_note,data_duree;
unsigned short offset1=0,offset2=0;
unsigned char duree1=1,duree2=1;
//unsigned short sav_unittps;
//register unsigned short tps1 asm ("d1")=0,tps2 asm ("d2")=0;
//register unsigned short unittps asm ("d4");
unittps=Tempo;
//Adaptation du HW1
if (AMS_1xx==TRUE) unittps=unittps/1.2;
//Initialize port
asm ("bset #6,0x60000C
bclr #0,0x60000E
bclr #1,0x60000E");
boucle1:
if (_keytest(RR_ESC)==TRUE) goto fin;
//-----------------------
//Extraction voie n°1
//-----------------------
duree1=duree1-1;
if (duree1==0)
{
data_note=*(BYTE*)(Channel1+offset1);
data_duree=*(BYTE*)(Channel1+offset1+1);
offset1+=2;
if (data_note==255) goto fin;
if (data_note==0) tps1=unittps+1;
else tps1=decode(data_note);
duree1=data_duree;
if ((peekIO_bit (0x60000E,1))==0) pokeIO_bclr (0x60000E,0);
else pokeIO_bset (0x60000E,0);
}
//------------------------
//Extraction voie n°2
//------------------------
duree2=duree2-1;
if (duree2==0)
{
data_note=*(BYTE*)(Channel2+offset2);
data_duree=*(BYTE*)(Channel2+offset2+1);
offset2+=2;
if (data_note==255) goto fin;
if (data_note==0) tps1=unittps+1;
else tps2=decode(data_note);
duree2=data_duree;
if ((peekIO_bit (0x60000E,0))==0) pokeIO_bclr (0x60000E,1);
else pokeIO_bset (0x60000E,1);
}
//------------------
/*printf_xy (0,0,"%d",tps1);
printf_xy (0,10,"%d",tps2);
printf_xy (0,30,"%d",duree1);
printf_xy (0,40,"%d",duree2);*/
//for (i=0;i<sav_unittps;i++)
//{
// if ((sav_tps2--)<=0) {sav_tps1=tps1; asm ("bchg #0,0x60000E");}
// if ((sav_tps1--)<=0) {sav_tps2=tps2; asm ("bchg #1,0x60000E");}
// //if ((sav_tps2--)<=0) {sav_tps2=tps2; asm ("bchg #1,0x60000E");}
// //if ((sav_tps1--)<=0) {sav_tps1=tps1; asm ("bchg #0,0x60000E");}
//}
asm ("cmp.w %1,%0
jbhi paspause1
move.w %1,%%d7
paspause1:
cmp.w %2,%0
jbhi paspause2
move.w %2,%%d6
paspause2:
bcle_son1:
dbf %%d7,son_11
move.w %1,%%d7
bchg #0,(0x60000E)
son_11:
dbf %%d6,son_21
move.w %2,%%d6
bchg #1,(0x60000E)
son_21:
dbf %0,bcle_son1"::"g"(unittps),"g"(tps1),"g"(tps2));
goto boucle1;
fin:
asm ("bclr #0,(0x60000E)
bclr #1,(0x60000E)
move.b 0x8D,(0x60000C)");
}
Dans le code le seul problème c'est la partie en assembleur qui ne fonctionne pas correctement.
