#include"reg52.h"#defineWINDOW_XADDR_START0x0050//HorizontalStartAddressSet#defineWINDOW_XADDR_END0x0051//HorizontalEndAddressSet#defineWINDOW_YADDR_START0x0052//VerticalStartAddressSet#defineWINDOW_YADDR_END0x0053//VerticalEndAddressSet#defineGRAM_XADDR0x0020//GRAMHorizontalAddressSet#defineGRAM_YADDR0x0021//GRAMVerticalAddressSet#defineGRAMWR0x0022//memorywrite#defineuintunsignedint#defineucharunsignedcharsbitCS=P2^2;//片选sbitRES=P2^1;//复位sbitRS=P2^4;//数据/命令选择sbitRW=P2^5;constuintcol[9]={0x0000,0xFFFF,0x001F,0xFFE0,0xF800,0xF81F,0x07E0,0x7FFF,0x051F};//BlackWhiteBlueYellowRedMagentaGreenCyanBlue2constuintboxes[7]={//方块样式存储数组0x0f00,0x0740,0x0e20,0x0e40,0x0c60,0x06c0,0x0660};uintfi[23]={0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xc003,0xffff,0xffff,0xffff};uchara,b;uintt,p;uintscore;ucharspeed,leve,time;//游戏速度ucharpcolor,color;voidInit_Timer1(void){TMOD|=0x10;//使用模式1,16位定时器,使用"|"符号可以在使用多个定时器时不受影响TH1=0x3c;//给定初值,这里使用定时器最大值从0开始计数一直到65535溢出TL1=0xb0;EA=1;//总中断打开ET1=1;//定时器中断打开TR1=1;//定时器开关打开}voiddelay(unsignedinti)//延时函数{while(i--);}ucharkeyscan(void)//键盘扫描函数,使用行列反转扫描法{uchark;P1=0xff;k=P1;if(k!=0xff){delay(100);if(k!=0xff){k=P1;if(k==0xfd)return1;if(k==0xfb)return2;if(k==0xf7)return3;if(k==0xef)return4;}}return8;}voiddelayms(uintcount){inti,j;for(i=0;i<count;i++){for(j=0;j<260;j++);}}voidWrite_Cmd(ucharDH,ucharDL){CS=0;RS=0;P0=DH;RW=0;RW=1;P0=DL;RW=0;RW=1;CS=1;}voidWrite_Data(ucharDH,ucharDL){CS=0;RS=1;P0=DH;RW=0;RW=1;P0=DL;RW=0;RW=1;CS=1;}voidWrite_Cmd_Data(ucharx,uinty){ucharm,n;m=y>>8;n=y;Write_Cmd(0x00,x);Write_Data(m,n);}voidWrite_Data_U16(uinty){unsignedcharm,n;m=y>>8;n=y;Write_Data(m,n);}staticvoidLCD_SetPos(uintx0,uintx1,uinty0,uinty1){Write_Cmd_Data(WINDOW_XADDR_START,x0);Write_Cmd_Data(WINDOW_XADDR_END,x1);Write_Cmd_Data(WINDOW_YADDR_START,y0);Write_Cmd_Data(WINDOW_YADDR_END,y1);Write_Cmd_Data(GRAM_XADDR,x0);Write_Cmd_Data(GRAM_YADDR,y0);Write_Cmd(0x00,0x22);//LCD_WriteCMD(GRAMWR);}voidILI9325_Initial(void){CS=1;delayms(5);RES=0;delayms(5);RES=1;delayms(5);delayms(100);Write_Cmd_Data(0x0001,0x0100);Write_Cmd_Data(0x0002,0x0700);Write_Cmd_Data(0x0003,0x1030);Write_Cmd_Data(0x0004,0x0000);Write_Cmd_Data(0x0008,0x0207);Write_Cmd_Data(0x0009,0x0000);Write_Cmd_Data(0x000A,0x0000);Write_Cmd_Data(0x000C,0x0000);Write_Cmd_Data(0x000D,0x0000);Write_Cmd_Data(0x000F,0x0000);//poweronsequenceVGHVGLWrite_Cmd_Data(0x0010,0x0000);Write_Cmd_Data(0x0011,0x0007);Write_Cmd_Data(0x0012,0x0000);Write_Cmd_Data(0x0013,0x0000);//vghWrite_Cmd_Data(0x0010,0x1290);Write_Cmd_Data(0x0011,0x0227);//delayms(100);//vregioutWrite_Cmd_Data(0x0012,0x001d);//0x001b//delayms(100);//vomamplitudeWrite_Cmd_Data(0x0013,0x1500);//delayms(100);//vomHWrite_Cmd_Data(0x0029,0x0018);Write_Cmd_Data(0x002B,0x000D);//gammaWrite_Cmd_Data(0x0030,0x0004);Write_Cmd_Data(0x0031,0x0307);Write_Cmd_Data(0x0032,0x0002);//0006Write_Cmd_Data(0x0035,0x0206);Write_Cmd_Data(0x0036,0x0408);Write_Cmd_Data(0x0037,0x0507);Write_Cmd_Data(0x0038,0x0204);//0200Write_Cmd_Data(0x0039,0x0707);Write_Cmd_Data(0x003C,0x0405);//0504Write_Cmd_Data(0x003D,0x0F02);//ramWrite_Cmd_Data(0x0050,0x0000);Write_Cmd_Data(0x0051,0x00EF);Write_Cmd_Data...