#include<reg52.h>
#include <intrins.h> //内部包含延时函数 _nop_();
#define uchar unsigned char
#define uint unsigned int
uchar song_index=0,tone_index=0;
uchar code FFW[8]={0x1f,0x3f,0x2f,0x6f,0x4f,0xcf,0x8f,0x9f};
uchar ModeNo; //流水灯模式编号
uint Speed; //流水移动速度
uchar *song_tone_pointer,*song_time_pointer;
uchar tCount=0;
uchar Idx; //速度索引值
uchar mb_Count=0; //移位位数
uchar i=0;
uchar Key;
bit Dirtect=1; //流水灯滚动方向
sbit beep=P2^3;
sbit K1=P2^0;
sbit K2=P2^1;
sbit K3=P2^2;
sbit K4=P3^7;
uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //段码表0-9
uint code sTable[]={0,1,3,5,7,9,15,30,50,100,200,230,280,300,350}; //速度由快到慢
uint code tone_delay[]={64021,64103,64260,64400,64524,64580,64684,64777,
64820,64898,64968,65030,65058,65110,65157,65178};
uchar code song1_tone[]={119,126,159,142,159,0,106,126,159,169,190,119,212,212,190,212,142,
159,212,212,190,212,159,169,212,212,190,212,142,159,212,212};
uchar code song1_time[]={9,3,12,12,12,24,9,3,12,12,12,24,9,3,12,12,12,12,12,
9,3,12,12,12,24,0};
uchar code song2_tone[]={212,212,106,126,159,169,190,119,212,212,190,212,159,169,212,212,190,212,142,159,
212,106,126,159,169,190,119,119,126,159,142,159,0};
uchar code song2_time[]={3,12,12,12,24,0,9,3,12,12,12,24,9,3,12,12,12,24,9,3,12,12,12,12,12,9};
uchar code song3_tone[]={212,212,190,212,159,169,212,212,190,212,142,159,212,
212,106,126,129,169,190,119,119,126,159,142,159,0};
uchar code song3_time[]={9,3,12,12,12,24,9,3,12,12,12,24,9,3,12,12,12,12,12,9,3,12,12,12,24,};
void Delay(uint x) //延时函数
{
uchar i;
while(x--)
for(i=0;i<120;i++);
}
uchar GetKey() //按键判断
{
uchar K;
if((K1==1)&&(K2==1)&&(K3==1)&&(K4==1))
return 0;
Delay(10);
if(K1==0)
{
K=1;
song_tone_pointer=&song1_tone[0];