888光立方源程序-简单

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includereg52.h#defineuintunsignedint//宏定义#defineucharunsignedcharucharnumber=0,count,qi=0;//number动力数count层扫描用的数qi可以在数组里面定位初始地址uintjishi,ji;//计时ji可是改变每步转换的时间bitj;//控制动画往前还是往后uchar*pa;//主数组指针可以在不同的数组之间取数ucharcodeceng[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};//层扫描的数组ucharcodedigit[]={0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,//数字浮出0x00,0x00,0x00,0x08,0x0C,0x08,0x08,0x08,0x08,0x08,0x3E,//10x00,0x00,0x00,0x3C,0x20,0x20,0x3C,0x04,0x04,0x3C,0x00,//20x00,0x00,0x00,0x3C,0x20,0x20,0x3C,0x20,0x20,0x3C,0x00,//30x00,0x00,0x00,0x10,0x18,0x14,0x3E,0x10,0x10,0x00,0x00,//40x00,0x00,0x00,0x78,0x08,0x08,0x78,0x40,0x40,0x78,0x00,//50x00,0x00,0x00,0x78,0x08,0x08,0x78,0x48,0x48,0x78,0x00,//60x00,0x00,0x00,0x78,0x40,0x40,0x40,0x40,0x40,0x00,0x00,//70x00,0x00,0x00,0x7C,0x44,0x44,0x7C,0x44,0x44,0x7C,0x00,//80x00,0x00,0x00,0x7C,0x44,0x44,0x7C,0x40,0x40,0x7C,0x00,//90x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//20x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//30x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//40x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//50x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//60x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//70x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//80x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//90x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};ucharcodezheng[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,//0正方形用的数组0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,//10x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,//20x00,0x00,0x00,0x00,0x0f,0x0f,0x0f,0x0f,//30x00,0x00,0x00,0x1f,0x1f,0x1f,0x1f,0x1f,//40x00,0x00,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,//50x00,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,//60xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,//70x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//8};ucharcodedigit1[]=//数字推出用的数组{0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,//00x08,0x0C,0x08,0x08,0x08,0x08,0x08,0x3E,//10x3C,0x20,0x20,0x3C,0x04,0x04,0x3C,0x00,//20x3C,0x20,0x20,0x3C,0x20,0x20,0x3C,0x00,//30x10,0x18,0x14,0x3E,0x10,0x10,0x00,0x00,//40x78,0x08,0x08,0x78,0x40,0x40,0x78,0x00,//50x78,0x08,0x08,0x78,0x48,0x48,0x78,0x00,//60x78,0x40,0x40,0x40,0x40,0x40,0x00,0x00,//70x7C,0x44,0x44,0x7C,0x44,0x44,0x7C,0x00,//80x7C,0x44,0x44,0x7C,0x40,0x40,0x7C,0x00,//90x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//100x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//10};ucharcodetable[]=//第二数组选择不同的方式给每个面送数{1,1,0,0,0,1,1,1,//d=00,8,8,8,8,8,8,8,//0d=81,1,8,8,8,8,8,8,//12,2,2,8,8,8,8,8,//23,3,3,3,8,8,8,8,//34,4,4,4,4,8,8,8,//45,5,5,5,5,5,8,8,//56,6,6,6,6,6,6,8,//67,7,7,7,7,7,7,7,//77,7,7,7,7,7,7,7,//86,6,6,6,6,6,6,8,//95,5,5,5,5,5,8,8,//104,4,4,4,4,8,8,8,//113,3,3,3,8,8,8,8,//122,2,2,8,8,8,8,8,//131,1,8,8,8,8,8,8,//140,8,8,8,8,8,8,8,//150,10,10,10,10,10,10,10,//00,0,10,10,10,10,10,10,//10,0,0,10,10,10,10,10,//210,0,0,0,10,10,10,10,//310,10,0,0,0,10,10,10,//410,10,10,0,0,0,10,10,//510,10,10,10,0,0,0,10,//610,10,10,10,10,0,0,0,//710,10,10,10,10,10,0,0,//810,10,10,10,10,10,10,0,//910,10,10,10,10,10,10,0,//1010,10,10,10,10,10,10,0,//1110,10,10,10,10,10,10,0,//1210,10,10,10,10,10,10,0//13};chushi()//初始函数{TMOD=0x01;TH0=-50008;TL0=-5000;TR0=1;EA=1;ET0=1;ji=250;j=1;pa=digit;}voidclc()//全局清屏{P3=0;P2=0xff;P0=0;P2=0;}voiddelay1(intt)//延时函数{inti;while(t--)for(i=0;i700;i++);}voidfun(uchar*a,ucharjump0,uintd)//第二数组不动主数组动1{unsignedchari,p;p=1;for(i=0;i8;i++){P2=p;P0=a[table[i+d]*jump0+number+count+qi*8];P2=0;p=1;}}voidfun1(uchar*a,ucharjump0,uintd)//第二数组动主数组不动{unsignedchari,p;p=1;for(i=0;i8;i++){P2=p;P0=a[table[i+d+number*8]*jump0+count+qi*8];P2=0;p=1;}}zhen(uchar*a,ucharjump0,uintd)//第二数组不动主数组动1{for(count=0;count8;count++){P3=0;fun(a,jump0,d);P3=ceng[count];delay1(2);}}zhen1(uchar*a,ucharjump0,uintd)//第二数组动主数组不动jump0主数组跳的距离d第二数组的初始地址{for(count=0;count8;count++){P3=0;fun1(a,jump0,d);P3=ceng[count];delay1(2);}}main(){ucharxun;//控制每步动画的循环bitgo;//每步动画之间的联系go=1;chushi();while(1){while(go)//数字浮出{zhen(pa,128,0);if(number==110){number=0;go=0;}}pa=zheng;//正方形缩放for(xun=0;xun6;xun++){go=1;while(go){zhen1(pa,8,8);if(number==15){go=0;number=0;}}}pa=digit1;//数字推出for(xun=0;xun9;xun++){go=1;while(go){zhen1(pa,8,128);if(number==13){number=0;go=0;}}qi++;}clc();while(!go){}//动画停止}}voidisr_time0()interrupt1//动画动起来的动力{TH0=-15008;TL0=-1500;jishi++;if(jishi==ji){if(j==1){number=number+1;}else{number=number-1;}jishi=0;}}

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功