#include #define ucharunsigned char
#define uintunsigned int
sbit sound=P3^7;
unsigned char n=0;
unsigned char code music[] ={
0x83,0x14,
0x75,0x14,
0x6E,0x28,
0x75,0x28,
0x6E,0x28,
0x57,0x28,
0x75,0x28,
0x75,0x28,
0x75,0x28,
0xAF,0x14,
0xAF,0x14,
0x83,0x28,
0x93,0x28,
0x83,0x28,
0x6E,0x28,
0x93,0x28,
0x93,0x28,
0x00,0x28,
0xAF,0x14,
0xAF,0x14,
0xA5,0x28,
0xAF,0x28,
0xA5,0x28,
0x6E,0x14,
0xAF,0x28,
0xAF,0x28,
0x00,0x14,
0x6E,0x14,
0x6E,0x28,
0x75,0x28,
0xA5,0x28,
0xA5,0x28,
0x75,0x28,
0x75,0x50,
0x00,0x28,
0x83,0x14,
0x75,0x14,
0x6E,0x28,
0x75,0x28,
0x6E,0x28,
0x57,0x28,
0x75,0x50,
0x00,0x28,
0xAF,0x14,
0xAF,0x14,
0x83,0x28,
0x93,0x28,
0x83,0x28,
0x6E,0x28,
0x93,0x28,
0x93,0x50,
0x00,0x14,
0xAF,0x14,
0xA5,0x28,
0x6E,0x14,
0x75,0x14,
0x75,0x28,
0x6E,0x28,
0x62,0x14,
0x62,0x14,
0x57,0x14,
0x6E,0x28,
0x00,0x28,
0x6E,0x28,
0x75,0x28,
0x83,0x14,
0x83,0x14,
0x75,0x28,
0x93,0x28,
0x83,0x50,
0x00,0x28,
0x6E,0x14,
0x62,0x14,
0x57,0x28,
0x62,0x28,
0x57,0x28,
0x49,0x28,
0x62,0x50,
0x00,0x28,
0x49,0x14,
0x49,0x14,
0x6E,0x14,
0x75,0x14,
0x6E,0x28,
0x57,0x28,
0x57,0x50,
0x00,0x14,
0x00,0x14,
0x83,0x14,
0x75,0x14,
0x6E,0x28,
0x75,0x28,
0x62,0x14,
0x62,0x14,
0x6E,0x28,
0x93,0x28,
0x93,0x28,
0x00,0x28,
0x52,0x28,
0x57,0x28,
0x62,0x28,
0x6E,0x28,
0x57,0x50,
0x57,0x50,
0x57,0x50,
0x00,0x28,
0x57,0x28,
0x41,0x50,
0x49,0x50,
0x57,0x14,
0x62,0x14,
0x6E,0x28,
0x00,0x14,
0x6E,0x14,
0x62,0x28,
0x6E,0x14,
0x62,0x14,
0x62,0x28,
0x49,0x28,
0x57,0x50,
0x00,0x28,
0x57,0x28,
0x41,0x50,
0x49,0x50,
0x57,0x14,
0x62,0x14,
0x6E,0x50,
0x00,0x28,
0x6E,0x14,
0x62,0x28,
0x6E,0x14,
0x62,0x14,
0x62,0x28,
0x75,0x28,
0x41,0x50,
0x00,0x28,
0x83,0x14,
0x75,0x14,
0x83,0x50,
0x83,0x50,
0xff,0x28
};
void int0() interrupt 1
{ TH0=0xd8;
TL0=0x60;
n--;
}
void delay (unsigned char m)
{
for(m=m;m>0;m--) ;
}
void delayms(unsigned char a)
{
while(--a);
}
void main()
{ unsigned char p,m;
unsigned char i=0;
TMOD=0x01;
TH0=0xd8;
TL0=0x60;
EA=1;
ET0=1;
while(1)
{
p=music[i];
if(p==0xff) { i=0;sound=0; delayms(5000);continue;}
else if(p==0x00) { i=i+2;delayms(400);}
else {m=music[i++], n=music[i++];}
TR0=1;
while(n!=0) sound=~sound,delay(m);
TR0=0;
}
}