根据程序的不同,代码也不一样,会有变化的,
0xA9,0xEF,//00220HZ ,1 //0
0x93,0xF0,//00233HZ ,1#
0x73,0xF1,//00247HZ ,2
0x49,0xF2,//00262HZ ,2#
0x07,0xF3,//00277HZ ,3
0xC8,0xF3,//00294HZ ,4
0x73,0xF4,//00311HZ ,4#
0x1E,0xF5,//00330HZ ,5
0xB6,0xF5,//00349HZ ,5#
0x4C,0xF6,//00370HZ ,6
0xD7,0xF6,//00392HZ ,6#
0x5A,0xF7,//00415HZ ,7
0xD8,0xF7,//00440HZ 1 //12
0x4D,0xF8,//00466HZ 1# //13
0xBD,0xF8,//00494HZ 2 //14
0x24,0xF9,//00523HZ 2# //15
0x87,0xF9,//00554HZ 3 //16
0xE4,0xF9,//00587HZ 4 //17
0x3D,0xFA,//00622HZ 4# //18 0x90,0xFA,//00659HZ 5 //19
0xDE,0xFA,//00698HZ 5# //20
0x29,0xFB,//00740HZ 6 //21
0x6F,0xFB,//00784HZ 6# //22
0xB1,0xFB,//00831HZ 7 //23
0xEF,0xFB,//00880HZ `1
0x2A,0xFC,//00932HZ `1#
0x62,0xFC,//00988HZ `2
0x95,0xFC,//01046HZ `2#
0xC7,0xFC,//01109HZ `3
0xF6,0xFC,//01175HZ `4
0x22,0xFD,//01244HZ `4#
0x4B,0xFD,//01318HZ `5
0x73,0xFD,//01397HZ `5#
0x98,0xFD,//01480HZ `6
0xBB,0xFD,//01568HZ `6#
0xDC,0xFD,//01661HZ `7 //35
};
timer0() interrupt 1
{
TL0=tl0_f;TH0=th0_f;
BEEP=~BEEP;
}
changedata(uchar *song,uchar *diao,uchar *jie)
{
uchar i,i1,j;
char gaodi;
uchar banyin;
uchar yinchang;
uchar code jie7[8]={0,12,14,16,17,19,21,23};
*diao=*song;
for(i=0,i1=0;;)
{
gaodi=0;
banyin=0;
yinchang=4;
if((*(song+i)=='|') || (*(song+i)==' ')) i++;
switch(*(song+i))
{
case ',': gaodi=-12;i++;
break;
case '`': gaodi=12;i++;
break;
}
if(*(song+i)==0)
{
*(diao+i1)=0;
*(jie+i1)=0;
return;
}
j=*(song+i)-0x30; i++;
j=jie7[j]+gaodi;
yinc: switch(*(song+i))
{
case '#':
i++;j++;
goto yinc;
case '-':
yinchang+=4;
i++;
goto yinc;
case '_':
yinchang/=2;
i++;
goto yinc;
case '.':
yinchang=yinchang+yinchang/2;
i++;
goto yinc;
}
*(diao+i1)=j;
*(jie+i1)=yinchang;
i1++;
}
}
void play(uchar *songdata)
{
uchar i,c,j=0;
uint n;
uchar xdata diaodata[112];
uchar xdata jiedata[112];
changedata(songdata,diaodata,jiedata);
TR0=1;
for(i=0;diaodata[i]!=0;i++)
{
tl0_f=freq[diaodata[i]*2];
th0_f=freq[diaodata[i]*2+1];
for(c=0;c<jiedata[i];c++)
{
for(n=0;n<32000;n++);
if(!key1)
{
TR0=0;
return;
}
}
TR0=0;
for(n=0;n<500;n++);
TR0=1;
//turn();
}
TR0=0;
}
uchar code mamahao[]={
"6.5_35|`16_5_6-|35_6_53_2_|1_,6_5_3_2-|"
"2.3_55_6_|321-|5.3_2_1_,6_1_|,5--"
};
这是种比较复杂的 |