基于stc51單片機(jī)的光立方c語(yǔ)言源代碼 作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢(xún) 收藏 /*音柱編碼*/uchar code tuku1[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff};uchar code table1[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff/*0X1C,0X3E,0X7E,0XFC,0XFC,0X7E,0X3E,0X1C*/};uchar code table2[]={0Xe0,0Xe0,0Xe0,0xe0,0Xe0,0Xe0,0Xe0,0Xe0,0X07,0X07,0X07,0X07,0X07,0X07,0X07,0X07};/*uchar code table2[]={0X80,0Xc0,0Xe0,0xf0,0Xf0,0Xe0,0Xc0,0X80,0X01,0X03,0X07,0X0f,0X0f,0X07,0X03,0X01};*/uchar code table3[]={0Xf0,0Xe0,0Xc0,0x80,0X00,0X00,0X00,0X00,0X03,0X07,0X0e,0x1c,0X38,0X70,0Xe0,0Xc0,0X00,0X00,0X00,0X00,0X01,0X03,0X07,0X0f};uchar code table4[]={0Xc0,0Xc0,0X00,0x00,0X00,0X00,0X00,0X00,0X00,0X00,0X30,0x30,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0c,0X0c,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X03};uchar code table5[]={0Xc0,0Xc0,0X00,0x00,0X00,0X00,0X00,0X00,0X18,0X18,0X00,0x00,0X00,0X00,0X00,0X00,0X03,0X03,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X03,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X03};uchar code table6[]={0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,0Xc0,0Xc0,0X00,0x00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0xc0,0Xc0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0xc0,0Xc0,0X00,0X00,0X00,0X00,0X00,0X00,0X18,0X18,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X03};uchar code number[]={//數(shù)字,滾動(dòng)字幕使用,從上至下0x00,0x40,0x40,0x40,0x40,0x40,0x7E,0x00,/*"L",0*/0x00,0x7E,0x40,0x7E,0x40,0x40,0x7E,0x00,/*"E",1*/0x00,0x7C,0x46,0x42,0x42,0x46,0x7C,0x00,/*"D",2*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",3*/0x00,0x3C,0x62,0x40,0x40,0x61,0x3E,0x00,/*"C",4*/0x00,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,/*"U",5*/0x00,0x7C,0x42,0x7C,0x42,0x41,0x7E,0x00,/*"B",6*/0x00,0x7E,0x40,0x7E,0x40,0x40,0x7E,0x00,/*"E",7*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",8*/0x00,0x42,0x42,0x7E,0x42,0x42,0x42,0x00,/*"H",9*/0x00,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,/*"U",10*/0x00,0xC2,0x64,0x38,0x10,0x10,0x10,0x00,/*"Y",11*/0x00,0x18,0x18,0x24,0x7E,0x42,0x81,0x00,/*"A",12*/0x00,0x62,0x62,0x52,0x4A,0x46,0x46,0x00,/*"N",13*/0x00,0x3C,0x62,0x40,0x4E,0x62,0x3E,0x00,/*"G",14*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",16*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",17*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"Y",18*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",19*/0x00,0x44,0x44,0x7C,0x44,0x44,0x44,0x00,/*"H",20*/0x00,0x44,0x44,0x44,0x44,0x44,0x38,0x00,/*"U",21*/0x00,0x82,0x44,0x28,0x10,0x10,0x10,0x00,/*"Y",22*/0x00,0x10,0x28,0x28,0x7C,0x44,0x82,0x00,/*"A",23*/0x00,0x64,0x64,0x54,0x54,0x4C,0x44,0x00,/*"N",24*/0x00,0x78,0xC4,0x80,0x9C,0xC4,0x7C,0x00,/*"G",25*/0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x00,/*"!",26*/0X38,0X64,0X06,0X3E,0X66,0X66,0X24,0X18,//"9"270X3C,0X66,0X66,0X3C,0X66,0X66,0X24,0X18,//"8"280X30,0X30,0X30,0X18,0X0C,0X04,0X46,0X7E,//"7"290X18,0X26,0X66,0X78,0X60,0X66,0X24,0X18,//"6"300X18,0X64,0X46,0X06,0X1C,0X60,0X62,0X7E,//"5"310X0C,0X0C,0X7E,0X68,0X6C,0X2C,0X3C,0X1C,//"4"320x78,0x46,0x06,0x06,0x1c,0x06,0x46,0x3c,//"3"330xfc,0xc0,0x60,0x30,0x18,0xc6,0xc6,0x78,//"2"340x3c,0x18,0x18,0x18,0x18,0x18,0x38,0x18,//"1"350X18,0X24,0X66,0X66,0X66,0X66,0X24,0X18,//"0"36//0XCC,0XCC,0X44,0X44,0X22,0X22,0X1f,0X00,//0XCC,0XCC,0X44,0X44,0X22,0X22,0X1f,0X00,0X66,0X66,0X66,0X7E,0X66,0X66,0X3C,0X18,/*"A",37*///0X00,0X99,0X99,0X99,0X99,0X99,0X66,0X00,0XC3,0XC7,0XCF,0XDF,0XFB,0XF3,0XE3,0XC3,/*"N",38*///0X03,0X05,0XF9,0X81,0X81,0XF9,0X05,0X03,0X7E,0X62,0X62,0X60,0X60,0X60,0X60,0X60/*"L",39*/};/*音柱編碼*/uchar code tuku[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};uchar code BRTable[64] ={ 0,32,16,48,8,40,24,56,4,36,20,52,12,44,28,60,2,34,18,50,10,42,26,58,6,38,22,54,14,46,30,62,1,33,17,49,9,41,25,57,5,37,21,53,13,45,29,61,3,35,19,51,11,43,27,59,7,39,23,55,15,47,31,63};char code sin_tabb[64] = { 0 ,12 ,25 ,37 ,49 ,60 ,71 ,81 ,90 ,98 ,106 ,112 ,117 ,122 ,125 ,126 ,127 ,126 ,125 ,122 ,117 ,112 ,106 ,98 ,90 ,81 ,71 ,60 ,49 ,37 ,25 ,12 ,0 ,-12 ,-25 ,-37 ,-49 ,-60 ,-71 ,-81 ,-90 ,-98 ,-106 ,-112 ,-117 ,-122 ,-125 ,-126 ,-127 ,-126 ,-125 ,-122 ,-117 ,-112 ,-106 ,-98 ,-90 ,-81 ,-71 ,-60 ,-49 ,-37 ,-25 ,-12 }; char code cos_tabb[64] = {127 ,126 ,125 ,122 ,117 ,112 ,106 ,98 ,90 ,81 ,71 ,60 ,49 ,37 ,25 ,12 ,0 ,-12 ,-25 ,-37 ,-49 ,-60 ,-71 ,-81 ,-90 ,-98 ,-106 ,-112 ,-117 ,-122 ,-125 ,-126 ,-127 ,-126 ,-125 ,-122 ,-117 ,-112 ,-106 ,-98 ,-90 ,-81 ,-71 ,-60 ,-49 ,-37 ,-25 ,-12 ,0 ,12 ,25 ,37 ,49 ,60 ,71 ,81 ,90 ,98 ,106 ,112 ,117 ,122 ,125 ,126 };char num;char c[6];//用于存儲(chǔ)5個(gè)不同頻率的幅值char b[6];//用于使音譜柱形顯示的平滑char amenu,menu,out;int xdata Real[64];//實(shí)部 int xdata Image[64];//虛部void delay(int t){int i;while(t--)for(i=0;i<700;i++);}void delay1(int t){char i;while(t--)for(i=0;i<20;i++);}void clc()//全局清屏{P3=0;P2=0xff;P0=0;P2=0;}uchar daoxu(uchar x)//一字節(jié)倒序{uchar k=0;char i;for(i=0;i<8;i++){if((x>>(7-i))&0x01)k|=0x01<>=1;}}*/void fun1(uchar *a,uchar d,uchar b,uchar c,uchar e)//滾動(dòng)字幕數(shù)據(jù)處理{char i;for(i=0;i<8;i++){a[i]=e&0x01;e>>=1;}a[7]|=(c<<1);a[6]|=(c&0x80);for(i=0;i<6;i++){a[5-i]|=((b<<(7-i))&0x80);}d=daoxu(d);a[0]|=((d>>1)&0x7e);}void zhen(uchar *a,uchar v)//一幀,a是一幀編碼起始地址{uchar p;char i;while(v--){p=1;for(i=0;i<8;i++){key_out_scan();key_amenu_scan();key_menu_scan();if(amenu)break;P3=0;fun(a+i*8);P3=p;delay(2);p<<=1;}} }void turn_on(uchar v){uchar a[64]={0};char i,j;a[7]=0x80;zhen(a,v);for(i=1;i<8;i++){a[i*8+7]=0x80;zhen(a,v);}for(i=6;i>=0;i--){for(j=0;j<8;j++)a[j*8+i]=0x80;zhen(a,v);} for(i=0;i<64;i++)a[i]=0; }void H_scan(uchar v){ uchar b[64]={0};char i,j;for(i=0;i<64;i++)b[i]=0x80;for(i=0;i<7;i++){for(j=0;j<64;j++)b[j]>>=1;zhen(b,v);}}void V_scan(uchar v){uchar a[64]={0};char i,j;for(i=0;i<8;i++)a[i]=0xff;zhen(a,v);for(i=1;i<8;i++){for(j=0;j<8;j++){a[i*8+j]=0xff;a[(i-1)*8+j]=0;}zhen(a,v);}}void jb0(char num,char v)///////////////////////////////{char i,k;uchar c[64]={0};for(i=0;i<64;i++)c[i]=0x80;zhen(c,v);while(num--)for(i=0;i<28;i++){if(i<7)for(k=0;k<8;k++){c[k*8]|=(0x80>>(i+1));c[k*8+7-i]=0;}else if(i<14)for(k=0;k<8;k++){c[k*8+i-6]=0x01;c[k*8]>>=0x01;}else if(i<21)for(k=0;k<8;k++){c[k*8+i-14]=0;c[k*8+7]|=(0x01<<(i-13));}else if(i<28)for(k=0;k<8;k++){c[k*8+27-i]=0x80;c[k*8+7]<<=1;}zhen(c,v);}clc();}void link_pingmian1(char v){uchar a[64]={0};char i,j;for(i=0;i<8;i++)for(j=0;j<8;j++){a[7*8+j]|=(0x01<>=1;}else if(i<14)for(k=0;k<8;k++){a[k]|=0x01<<(i-6);a[(14-i)*8+k]=0;}else if(i<21)for(k=0;k<8;k++){a[(i-13)*8+k]=0x80;a[k]<<=1;} else for(k=0;k<8;k++){a[7*8+k]|=0x80>>(i-20);a[(i-21)*8+k]=0;}zhen(a,v);}clc();}void move(uchar *a,char kind,char direction,char length)//length不能為8//kind=0 x軸,1 x軸,2 z軸;direction=0,負(fù)向,1正向{char i,j;if(kind==0){if(direction==1)for(i=0;i<64;i++)a[i]<<=length;elsefor(i=0;i<64;i++)a[i]>>=length; }else if(kind==1){if(direction==1)for(j=0;j<8;j++){for(i=7;i>=length;i--)a[i+j*8]=a[i-length+j*8];for(i=0;i=length;i--)a[j+i*8]=a[j+(i-length)*8];for(i=0;i>(8-n);elsea[j+i*8]=0;} }void produce_empty(uchar *a,char n)//0>(8-n);/************X4列*************/a[(n-1)*8+n-1]=p;a[(n-1)*8]=p;a[0]=p;a[n-1]=p;for(j=0;j0;i--)//退出{if(empty==0)produce_cube(a,i);elseproduce_empty(a,i);if(kind==0){move(a,1,1,8-i);move(a,0,1,8-i);}else if(kind==1)move(a,0,1,8-i);else if(kind==2){;}elsemove(a,1,1,8-i); zhen(a,v);}}/***************************************************************************/void yinchu(uchar *table,char n,char v){/****************************n為幀數(shù)******************************/char i,j,k;uchar a[64]={0},p;for(k=0;k>i))&(p<<(7-i));}zhen(a,v); }zhen(table+k*64,50);}}void rain(char menu,char num,char v){//menu=0,up;menu=1,downuchar a[64]={0};char i,j;if(menu==0){for(i=0;i<8;i++)a[i]=tab_rain[i];zhen(a,v);for(i=1;i<8;i++){move(a,2,1,1);for(j=0;j<8;j++)a[j]=tab_rain[i*8+j];zhen(a,v);} while(num--){ for(i=0;i<8;i++){move(a,2,1,1);for(j=0;j<8;j++)a[j]=tab_rain[i*8+j];zhen(a,v);}}}else{for(i=0;i<8;i++)a[7*8+i]=tab_rain[i];zhen(a,v);for(i=1;i<8;i++){move(a,2,0,1);for(j=0;j<8;j++)a[7*8+j]=tab_rain[i*8+j];zhen(a,v);}while(num--){ for(i=0;i<8;i++){move(a,2,0,1);for(j=0;j<8;j++)a[j+7*8]=tab_rain[i*8+j];zhen(a,v);} }}}void LED(){char i;uchar p=0x01;for(i=0;i<8;i++){P2=p;delay1(1);P0=0xff;delay1(1);p<<=1;}P2=0;while(!out){key_out_scan();key_amenu_scan();P3=0xff;delay1(amenu*30);P3=0;delay1((6-amenu)*30);}P3=0;}void pc1(char num,char v){uchar a[64]={0};char i,j;while(num--){for(i=1;i<8;i++)a[i]=0xff;zhen(a,v);for(i=1;i<8;i++){move(a,2,1,1);for(j=0;j<8;j++)a[j]=0xff;zhen(a,v);}for(i=0;i<8;i++){if(num==0&&i==7)continue;move(a,2,1,1);zhen(a,v);}}for(i=0;i<7;i++){move(a,2,0,1);zhen(a,v+5);}}void link(char v){/****************************旋轉(zhuǎn)銜接******************************/char i,j,k;uchar a[64]={0};for(i=0;i<64;i++)a[i]=0x80;zhen(a,3);for(i=0;i<8;i++){for(j=0;j<8;j++){if(i<7)a[j*8+7-i]&=0x7f;a[j*8+i]|=(0x80>>i);}zhen(a,v);}for(i=0;i<6;i++){for(j=0;j<8;j++)for(k=0;k<8;k++)a[j*8+k]=tab_xuanzhuantiao[(i+8)*8+k];zhen(a,3);}}void leitu(uchar *b,char num,char v)//V>1{uchar a[64]={0},p;char i,j,k,m;for(m=0;m=8)a[tab10[i-8]]^=(0x01<1&&k<6&&j>1&&j<6&&kind!=1)a[k+j*8]=tab_xuanzhuantiao[i*8+k]&0xc3;elsea[k+j*8]=tab_xuanzhuantiao[i*8+k];}}zhen(a,v);}}}void qumianxuanzhuan(char kind,char num,char v)//曲面旋轉(zhuǎn){uchar a[64]={0};char i,j,k;for(j=0;j<8;j++)for(i=0;i<8;i++)a[i+j*8]=tab_xuanzhuantiao[i];zhen(a,v);if(kind==1){for(j=1;j<8;j++)//順時(shí)針初形變換{for(i=0;i=0;i--){move(a,2,1,1);for(j=0;j<8;j++)a[j]=tab_xuanzhuantiao[i*8+j];zhen(a,v);}}while(num--)//主循環(huán){if(kind==1)for(i=0;i<14;i++){move(a,2,1,1);for(j=0;j<8;j++)a[j]=tab_xuanzhuantiao[i*8+j];zhen(a,v);}elsefor(i=13;i>=0;i--){move(a,2,1,1); for(j=0;j<8;j++)a[j]=tab_xuanzhuantiao[i*8+j];zhen(a,v);}}if(kind==1)for(j=0;j<7;j++){for(i=7;i>=j;i--){if(i>j)for(k=0;k<8;k++)a[k+i*8]=tab_xuanzhuantiao[(14-i+j)*8+k];elsefor(k=0;k<8;k++)a[k+i*8]=tab_xuanzhuantiao[k];}zhen(a,v);}elsefor(j=1;j<7;j++){for(i=7;i>=j;i--){if(i>j)for(k=0;k<8;k++)a[k+i*8]=tab_xuanzhuantiao[(i-j)*8+k];elsefor(k=0;k<8;k++)a[k+i*8]=tab_xuanzhuantiao[k];}zhen(a,v);}}void qumianxuanzhuan2(char num,char v)//曲面旋轉(zhuǎn){uchar a[64]={0};char i,j,k;for(j=0;j<8;j++)for(i=0;i<8;i++)a[i+j*8]=tab_xuanzhuantiao[i];zhen(a,v);for(j=1;j<8;j++){for(i=0;i=0;i--){for(j=0;j<8;j++){a[j*8+i]=0xff;a[j*8+i+1]=0;}zhen(a,v);}clc();}void zimu(uchar *x,char n,char v,int num)//滾動(dòng)字幕,num表示循環(huán)次數(shù),v表示滾動(dòng)速度,n字符個(gè)數(shù){char i,j,k;uchar xdata a[64]={0},temp0[8],temp1[8],temp2[8],temp3[8],temp[8];for(i=0;i<8;i++){temp0[i]=0;temp1[i]=0;temp2[i]=0;temp3[i]=0;}while(num--)for(j=0;j=0;k--)//讀取數(shù)據(jù)temp[7-k]=x[j*8+k];for(k=0;k<8;k++)//移動(dòng)8位{for(i=0;i<8;i++){temp0[i]=(temp0[i]<<1)|(temp1[i]>>7);temp1[i]=(temp1[i]<<1)|(temp2[i]>>7);temp2[i]=(temp2[i]<<1)|(temp3[i]>>7);temp3[i]=(temp3[i]<<1)|(temp[i]>>7);temp[i]<<=1;fun1(a+i*8,temp0[i],temp1[i],temp2[i],temp3[i]);}zhen(a,v);}}}void hy(uchar *tab,char v){uchar a[64]={0};char i,j;for(i=0;i<8;i++)a[i*8]=tab[i];zhen(a,v);for(i=1;i<8;i++){for(j=0;j<8;j++)a[i+j*8]=a[i-1+j*8];zhen(a,v);} for(i=0;i<7;i++){for(j=0;j<8;j++)a[i+j*8]=0;zhen(a,v);}zhen(a,23); }void W_side(uchar *tab,char num,char v){uchar a[64]={0};int i,j;for(j=0;j0;k--){if(m==1&&k==6){;}elseb[(k+1)*8+7-i]&=(~p);b[k*8+7-i]|=(0x01<0;j--){for(i=7;i>0;i--){b[i]=b[i-1];}zhen(b,5); }clc();}void water1(char x,char y,char v){uchar a[64]={0};char i,r;a[7*8+y]=0x01<=0;i--){a[i*8+y]=a[(i+1)*8+y];a[(i+1)*8+y]=0;zhen(a,v);}//下落for(r=0;r<7;r++){for(i=0;i<8;i++)a[i]=tab_water[r*16+7-y+i]>>(7-x);zhen(a,v+1);}//擴(kuò)散}void water2(char x1,char y1,char x2,char y2,char v){uchar a[64]={0};char i,r;a[7*8+y1]=0x01<=0;i--){move(a,2,0,1);if(i==5){a[7*8+y2]=0x01<>(7-x2); if(r<7)for(i=0;i<8;i++)a[i]|=(tab_water[r*16+7-y1+i]>>(7-x1));if(r==1)a[y2]|=0x01<=0;i--){move(a,2,0,1);if(i==5)//第二點(diǎn)a[7*8+y2]=0x01<=4)for(i=0;i<8;i++)a[i]=tab_water[(r-4)*16+7-y3+i]>>(7-x3);if(r<9&&r>=2)for(i=0;i<8;i++)a[i]|=tab_water[(r-2)*16+7-y2+i]>>(7-x2); if(r<7)for(i=0;i<8;i++)a[i]|=(tab_water[r*16+7-y1+i]>>(7-x1));if(r==1)a[y2]|=0x01<=0;i--){a[i]=0x01<55)a[i]=0xff;elsea[i]=0;}*/zhen(a,20);for(i=7;i>=0;i--)//1for(j=6;j>=0;j--){a[i+j*8]=0xff;a[i+(j+1)*8]=0;zhen(a,v);}zhen(a,27);for(i=7;i>=0;i--)//2for(j=1;j<8;j++){a[i+j*8]=0xff;a[i+(j-1)*8]=0;zhen(a,v);}zhen(a,27);for(i=7;i>=0;i--)//3for(k=6;k>=0;k--){for(j=0;j<8;j++){if(k==0)a[j+k*8]|=(0x80>>(7-i));elsea[j+k*8]=(0x80>>(7-i));a[j+(k+1)*8]^=(0x80>>(7-i));}zhen(a,v);}zhen(a,27);for(i=7;i>=0;i--)//4for(k=1;k<8;k++){for(j=0;j<8;j++){if(k==7)a[j+k*8]|=(0x80>>(7-i));elsea[j+k*8]=(0x80>>(7-i));a[j+(k-1)*8]^=(0x80>>(7-i));}zhen(a,v);}zhen(a,27);}void donghua(uchar *tab,uchar num,uchar n,char v){char i;while(n--){for(i=0;i=0;j--){for(i=7;i>=0;i--){a[i*8+3]=szfc_table[j+i];a[i*8+4]=szfc_table[j+i];}zhen(a,v);}} 上一頁(yè) 1 2 3 4 下一頁(yè)
評(píng)論