MEGA16游戲開(kāi)發(fā)板驅(qū)動(dòng)
void deal_keym()//主菜單處理
{
if(dat_k==247){if(flag<1)flag=3;else flag--;dat_k=0;printf(flag_right);}
if(dat_k==127){if(flag>2)flag=0;else flag++;dat_k=0;printf(flag_right);}
if(dat_k==223){if(flag==3)power_down();{flag_right=flag+1;dat_k=0;printf(flag_right);}}
if(dat_k==191){flag_right=10;flag=10;dat_k=0;};
if(dat_k==239){flag_right=0;flag=0;dat_k=0;};
}
void if_back()//是否返回
{
DDRD&=~BIT(6);
PORTD|=BIT(6);
if(!(PIND&0X40))flag_right=0;
}
void tuya()
{
ILU=4;
if(tyb)png[ILU][tyx]|=BIT(tyy);
if(!tyb)png[ILU][tyx]&=~BIT(tyy);
if(dat_k==191){if(tyx<7)tyx++;dat_k=0;}
if(dat_k==239){if(tyx>0)tyx--;dat_k=0;}
if(dat_k==127){if(tyy<7)tyy++;dat_k=0;}
if(dat_k==247){if(tyy>0)tyy--;dat_k=0;}
if(dat_k==223){tyb=!tyb;dat_k=0;}
if(tyb)ten_led(1);
if(!tyb)ten_led(0);
}
void yj()
{
if(dat_k==223){yj_f++;dat_k=0;if(yj_f==2){yj_y=0;yj_y1=0;}}
if(yj_f>2)yj_f=0;
if(yj_f==0)dat_yj=0;
if(yj_f==1){dat_yj++;dat_yj++;dat_yj1--;dat_yj1--;dat_yj1--;}
if(dat_yj>98)dat_yj=0;
if(dat_yj1<6)dat_yj1=99;
if(yj_f==2)if(yj_y1<1)
{
yj_y1=yj_y++;
dat_yj++;dat_yj++;
dat_yj1--;dat_yj1--;
}
if(yj_f==2)if(yj_y<16)if(yj_y1>0)yj_y1--;
if(yj_f==2)ten_led(0);
if(yj_f==1)ten_led(1);
}
void dis_show()
{
uchar i=50;
if(!tyb&flag_right==1){png[ILU][tyx]|=BIT(tyy);}
printf(flag_right);
while(i--)
{
dat_show();
png_show();
if_back();
dat_f=diskey();
if(flag_right==0)deal_keym();
if(flag_right==1)tuya();
if(i<30)if(!tyb&flag_right==1){png[ILU][tyx]|=BIT(tyy);}
if(flag_right==2)yj();
MAC;
if(flag_right==10)printf1();
}
}
void power_off()
{
clean();
sends(2," Welcome");
sends(3," Hi_The_Boy!");
PORTD|=BIT(5);
delayms(5000);
//clean();
// PORTD&=~BIT(5);
WDTCR=0X18;
}
void main()
{
MCUCSR|=BIT(7);
MCUCSR|=BIT(7);
/////////////////
DDRB=0X3F;
DDRD|=BIT(4)|BIT(5)|BIT(7);
DDRD&=~BIT(2);
PORTD|=BIT(2);
//////////////////
TCCR1A=0X23;
TCCR1B=0X1d;
OCR1A=6000;
OCR1B=100;
/////////////////
EN;ROMCS_;LEDEN_;LE;
/////////////////*
MCUCR&=0X20;
GICR|=BIT(6);
SREG|=BIT(7);
///////////////
PORTD|=BIT(5);
//////////////////
DDRD|=BIT(0);
PORTD|=BIT(0);
printf(0);
while(1)
{
MCUCR|=BIT(6);
dis_show();
brush();
}
}
評(píng)論