• LE61
    了解作者
  • C#
    开发工具
  • 261KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2013-06-29 00:21
    上传日期
C51贪吃蛇游戏代码,文档附有lcd对应C51引脚,lcd引脚说明
C51tanchishe.rar
  • C51贪吃蛇游戏代码
  • obj
  • SNAKE.obj
    18KB
  • ILI9163.obj
    111.6KB
  • KEY.lst
    3.6KB
  • SNAKE.lst
    18KB
  • ILI9163.hex
    18.7KB
  • 贪吃蛇.m51
    38.5KB
  • 9325TP.obj
    108.5KB
  • main.obj
    5.1KB
  • ILI9163.m51
    38.2KB
  • 9325TP.lst
    25.4KB
  • ILI9163
    124.3KB
  • ILI9163.lst
    24.1KB
  • KEY.obj
    2.9KB
  • ILI9163.plg
    179B
  • main.lst
    1.7KB
  • 贪吃蛇.plg
    217B
  • pic.h
    205.1KB
  • ILI9163.opt.bak
    2.2KB
  • GB1616.h
    7.3KB
  • 贪吃蛇_Opt.Bak
    2KB
  • 8x16.h
    44.1KB
  • 8x8h.h
    44.1KB
  • ILI9163.uvproj
    13.4KB
  • 贪吃蛇_Uv2.Bak
    2.1KB
  • main.c
    580B
  • 9325TP.C
    13.4KB
  • ILI9163.Uv2.bak
    2.1KB
  • main.OBJ
    5.1KB
  • 9325TP.h
    1.8KB
  • KEY_SWEEP.H
    593B
  • SNAKE.OBJ
    18KB
  • 贪吃蛇
    124.1KB
  • KEY.OBJ
    2.9KB
  • SNAKE.c
    9.1KB
  • KEY.c
    1.3KB
  • ILI9163_Opt.Bak
    2.2KB
  • LCD.H
    1.8KB
  • 贪吃蛇.Uv2
    2.2KB
  • 9325TP.OBJ
    108.3KB
  • ILI9163.uvopt
    58.1KB
  • SNAKE.h
    296B
  • 贪吃蛇.hex
    18.7KB
  • 贪吃蛇.Opt
    1.4KB
  • lcd对应C51引脚.png
    17.8KB
  • lcd引脚说明.png
    59.5KB
内容介绍
/*---------------------------------------------------------------- 320x240彩屏液晶驱动程序 ----------------------------------------------------------------*/ #include"9325tp.h" #include"reg52.h" /*---------------------------------------------------------------- 全局变量 ----------------------------------------------------------------*/ #define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set #define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set #define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set #define WINDOW_YADDR_END 0x0053 // Vertical End Address Set #define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set #define GRAM_YADDR 0x0021 // GRAM Vertical Address Set #define GRAMWR 0x0022 // memory write #define DataPort P0 //数据口使用DataPort /*---------------------------------------------------------------- 定义硬件端口 ----------------------------------------------------------------*/ sbit CS=P2^2; //片选 sbit RES=P2^1; //复位 sbit RS=P2^4; //数据/命令选择 sbit RW=P2^5; /*---------------------------------------------------------------- 清屏函数 输入参数:bColor 清屏所使用的背景色 ----------------------------------------------------------------*/ void CLR_Screen(unsigned int bColor) { unsigned int i,j; LCD_SetPos(0,240,0,320);//320x240 for (i=0;i<320;i++) { for (j=0;j<240;j++) Write_Data_U16(bColor); } } /*---------------------------------------------------------------- 显示英文字符 输入参数:x 横坐标 y 纵坐标 c 需要显示的字符 fColor 字符颜色 bColor 字符背景颜色 ----------------------------------------------------------------*/ #include "8X16.h" void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) { unsigned int i,j; LCD_SetPos(x,x+8-1,y,y+16-1); for(i=0; i<16;i++) { unsigned char m=Font8x16[c*16+i]; for(j=0;j<8;j++) { if((m&0x80)==0x80) { Write_Data_U16(fColor); } else { Write_Data_U16(bColor); } m<<=1; } } } /*---------------------------------------------------------------- 显示英文字符 输入参数:x 横坐标 y 纵坐标 c 需要显示的字符 fColor 字符颜色 bColor 字符背景颜色 ----------------------------------------------------------------*/ void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) { LCD_PutChar8x16( x, y, c, fColor, bColor ); } /*---------------------------------------------------------------- 显示汉字 输入参数:x 横坐标 y 纵坐标 c 需要显示的汉字码 fColor 字符颜色 bColor 字符背景颜色 ----------------------------------------------------------------*/ #include "GB1616.h" //16*16汉字字模 void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){ unsigned int i,j,k; LCD_SetPos(x, x+16-1,y, y+16-1); for (k=0;k<64;k++) { //64标示自建汉字库中的个数,循环查询内码 if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){ for(i=0;i<32;i++) { unsigned short m=codeGB_16[k].Msk[i]; for(j=0;j<8;j++) { if((m&0x80)==0x80) { Write_Data_U16(fColor); } else { Write_Data_U16(bColor); } m<<=1; } } } } } /*---------------------------------------------------------------- 显示字符串 可以中英文同时显示 输入参数:x 横坐标 y 纵坐标 *s 需要显示的字符串 fColor 字符颜色 bColor 字符背景颜色 ----------------------------------------------------------------*/ void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor) { unsigned char l=0; while(*s) { if( *s < 0x80) { LCD_PutChar(x+l*8,y,*s,fColor,bColor); s++;l++; } else { PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor); s+=2;l+=2; } } } /*---------------------------------------------------------------- 显示RGB颜色 输入参数:x0,y0 起始坐标 x1,y1 结束坐标 Color 背景颜色 ----------------------------------------------------------------*/ /*void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color) { unsigned int i,j; LCD_SetPos(x0,x1,y0,y1); for (i=y0;i<=y1;i++) { for (j=x0;j<=x1;j++) Write_Data_U16(Color); } } */ /*---------------------------------------------------------------- 显示图片 图片必须是320x240,否则不能正确识别 ----------------------------------------------------------------*/ /*void show_photo(void) { unsigned char j; unsigned int i; unsigned long s=0; LCD_SetPos(0,240,0,320);//320x240 for (i=0;i<75;i++) { for (j=0;j<240;j++) Write_Data(0xff,0xff); } for (i=0;i<170;i++) { for (j=0;j<55;j++) Write_Data(0xff,0xff); for (j=0;j<130;j++) Write_Data(pic[s++],pic[s++]); for (j=0;j<55;j++) Write_Data(0xff,0xff); } for (i=0;i<75;i++) { for (j=0;j<240;j++) Write_Data(0xff,0xff); } } */ /*---------------------------------------------------------------- 写命令、写数据 输入参数:x 需要输入的命令 16位 y 需要输入的数据 16位 ----------------------------------------------------------------*/ void Write_Cmd_Data (unsigned char x,unsigned int y) { unsigned char m,n; m=y>>8; n=y; Write_Cmd(0x00,x); Write_Data(m,n); } /*---------------------------------------------------------------- 写16位数据 ----------------------------------------------------------------*/ void Write_Data_U16(unsigned int y) { unsigned char m,n; m=y>>8; n=y; Write_Data(m,n); } /*---------------------------------------------------------------- 写命令 ----------------------------------------------------------------*/ void Write_Cmd(unsigned char DH,unsigned char DL) { CS=0; RS=0; DataPort=DH; RW=0; RW=1; DataPort=DL; RW=0; RW=1; CS=1; } /*---------------------------------------------------------------- 写数据 双8位 ----------------------------------------------------------------*/ void Write_Data(unsigned char DH,unsigned char DL) { CS=0; RS=1; DataPort=DH; RW=0; RW=1; DataPort=DL; RW=0; RW=1; CS=1; } /*---------------------------------------------------------------- 延时函数 ----------------------------------------------------------------*/ void delayms(unsigned int count) { int i,j; for(i=0;i<count;i++) { for(j=0;j<260;j++); } } /*---------------------------------------------------------------- 液晶初始化 ----------------------------------------------------------------*/ void ILI9325_Initial(void) { CS=1; delayms(5); RES=0; delayms(5); RES=1; delayms(50); 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); //power on sequence VGHVGL Write_Cmd_Data(0x0010,0x0000); Write_Cmd_Data(0x0011,0x0007); Write_Cmd_Data(0x0012,0
评论
    相关推荐