资源描述:
《c51单片机12864液晶带按键制作俄罗斯方块c源码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、************说明******************************此程序包含一个俄罗斯方块.c文件和一个12864.h文件********************俄罗斯方块.c文件**************************#include"reg51.h"#include"12864.h"#defineucharunsignedchar#defineuintunsignedintstaticunsignedlongSeed=1;#defineA48271L#defineM2147483647L#defineQ(M/A)#defineR(M%A)s
2、bitK1=P3^4;sbitK2=P3^5;sbitK3=P3^6;sbitK4=P3^7;unsignedintidatanum[19+2]={0xfff,//第1行,最下面0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,//第2行到第20行共19行0xfff//第21行,最上面};//定义共21行,其中num[0]为下墙壁行,num[20]为上墙壁行,每行12格,最左一格为左墙壁列,最右一格为右
3、墙壁列unsignedcharcodeBlock[28][2]={/**口口口口口口*口口口口*口口口口口口*/{0x88,0xc0},{0xe8,0x00},{0x62,0x20},{0x02,0xe0},/**口口口口口口*口口口口*口口口口口口*/{0x22,0x60},{0x08,0xe0},{0xc8,0x80},{0xe2,0x00},/**口*口口口口*口口口*/{0x8c,0x40},{0x6c,0x00},{0x8c,0x40},{0x6c,0x00},/**口口口*口口口口*口*/{0x4c,0x80},{0xc6,0x00},{0x4c,0x80},{0x
4、c6,0x00},/**口口*口口口口口口口口*口口口口口口*/{0x04,0xe0},{0x8c,0x80},{0xe4,0x00},{0x26,0x20},/*口*口*口口口口口*口*/{0x44,0x44},{0x0f,0x00},{0x44,0x44},{0x0f,0x00},/**口口*口口*/{0x06,0x60},{0x06,0x60},{0x06,0x60},{0x06,0x60}};#definePASSSCORE20structJimu{unsignedintdat;charx;unsignedchary;unsignedchartype;unsignedc
5、harchange;}Sign[3];//积木结构体unsignedcharSysFlag=0;#defineNEWSIGNFLAG0#defineDEADFLAG1#definePAUSEFLAG2unsignedcharScore=0;unsignedcharLevel=1;unsignedcharDelayCnt=5;/*********************************************************/#defineN25/************************************伪随机数发生器****************
6、*********************/doubleRandom(void){longTmpSeed;TmpSeed=A*(Seed%Q)-R*(Seed/Q);if(TmpSeed>=0)Seed=TmpSeed;elseSeed=TmpSeed+M;return(double)Seed/M;}/**************************************为伪随机数发生器播种***************************************/voidInitRandom(unsignedlongInitVal){Seed=InitVal;}//
7、延时子程序voidDelay(unsignedintt){unsignedinti,j;for(i=0;i8、=0x04;}/*******************