基于AT89C51单片机的贪吃蛇电子游戏(仿真)

  有关贪吃蛇的历史发展可以看一下这个网址,贪吃蛇最初的设计和现在并不相同。。http://www.techweb.com.cn/internet/2013-02-21/1278055.shtml

  该项目设计硬件平台选择了简单易用的AT89C51单片机,显示屏选择的是AMPIRE128X64液晶屏幕显示器,按照一定顺序连接后,如下图:

  基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第1张图片

 

  软件方面采用了C51编写代码,代码编写模块如下图:

基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第2张图片

 

 

  除去网上已有的图形驱动代码外,其核心代码主要为游戏处理、信息处理和按键处理。

  编写游戏的功能代码,先定义游戏的数据结构和常量。

#define uchar unsigned char
#define uint  unsigned int

sbit  P00 = P0 ^ 0;                //
sbit  P01 = P0 ^ 1;                //
sbit  P02 = P0 ^ 2;                //
sbit  P03 = P0 ^ 3;                //
sbit  P04 = P0 ^ 4;                //    开始/暂停

#define RIGHT 1
#define LEFT  2
#define UP    3
#define DOWN  4

#define ERASE     0
#define REWRITTEN 1

#define NO  0
#define YES 1

#define FALSE 0
#define TRUE  1

bit ESC = TRUE;                   //    开始 暂停标志位

uchar gameSpeed = 20;             //    游戏速度调节
uchar level = 1;                  //    难度
uchar s1[] = "1";                 //    保存显示难度的汉子

//    uchar = unsigned char
//    食物的结构体
struct Food
{
   uchar x;                        //    食物的横坐标
   uchar y;                        //    食物的纵坐标
}food;    

//    贪吃蛇主体的结构体
struct Snake
{
   uchar x[39];
   uchar y[39];
   uchar node;                    //    蛇的节数
   uchar direction;               //    蛇移动方向
}snake;

  其中食物的数据结构采用结构体定义,两个unsigned char变量分别定义为食物的横纵坐标;蛇的身体定义为长度最大值为39的数组,游戏中贪吃蛇长度达到39,游戏通关结束。

 

  游戏处理模块为贪吃蛇在游玩过程中遇到的需要被处理的情况,主要实现的功能包括以下四个方面,即移动、食物、死亡和更新。

  1. 移动

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第3张图片基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第4张图片

     

      流程与运行仿真如上图,按下“开始”键后,游戏开始启动,初始化完毕后,屏幕会显示“贪吃蛇”、“食物”和游戏的边界框,“贪吃蛇”在固定的周期内会向前移动一格,此时“贪吃蛇”身体从尾巴至头部每一个后序节点会向前序节点移动,后序节点移动完毕后,头部会根据此时按键的方向对相应的横纵坐标进行加减。

  2. 食物

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第5张图片基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第6张图片

      “贪吃蛇”向前移动后,此时要判断蛇头是否与“食物”的横纵坐标一一对应,如果不是则退出该模块,进入下一模块;如果是,则“贪吃蛇”的节数增加一。节数增加后判断蛇的节数是否为10的倍数,如果是则提升“贪吃蛇”的等级,并对游戏增加难度,加快贪吃蛇移动的速度。退出了游戏升级的模块后将进入创建新的“食物”模块,为了避免“食物”与“贪吃蛇”的节点坐标重复,“食物”在创建后要与“贪吃蛇”的每个节点的坐标一一比较,如果重合则重新创建“食物”的坐标,直到创建成功为止。

  3. 结束

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第7张图片

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第8张图片

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第9张图片

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第10张图片

     

      “贪吃蛇”在向前移动后,有可能撞到墙壁或自己的身体,也有可能吃到食物,或者只是向前移动一格,移动完毕后如果吃到了食物,如果“贪吃蛇”的node(节数)达到了最大值(39),那么玩家将会通关游戏,并且游戏退出,此时需要判断游戏是否结束,一共有三种判别,前两种为失败结局,即撞到了墙壁或自己的身体,最后一种为通关结局,将在屏幕上打印“Congratulations”祝贺玩家成功通关游戏。

  4. 更新

    基于AT89C51单片机的贪吃蛇电子游戏(仿真)_第11张图片

      游戏在判断结束后,如果没有结束,那么更新屏幕上的“贪吃蛇”的状态。

 

  四个模块的核心代码如下:

//    运行游戏的具体实现
void gamePlay(void)
{    
    bit hero = FALSE;                   //    完成游戏
            
    while(1) {
        EA = 1;
        if (ESC == FALSE) {
            gameSpeed = 20;
               level = 1;
            s1[0] = '1';
            start();            
        }

        while(ESC == FALSE) {
            EA = 1;            

            move();                                                               //    贪吃蛇向前移动

            if(snake.x[0] == food.x && snake.y[0] == food.y) {                    //    判断蛇头吃到食物以后    
                RectArea(food.x, food.y, food.x + 2, food.y + 2, ERASE);          //    把画面上的食物去掉
                snake.node++;                                                     //    蛇的身体长一节

                if (increaseLevel()) {                                            //    根据难度变化判断是否要重新开始
                    restart();
                    continue;
                }

                while (!createNewFood()) {                                        //    如果创建失败则继续创建,直到成功
                    ;
                }
                
                RectArea(food.x, food.y, food.x + 2, food.y + 2, REWRITTEN);      //    在画面上显示食物
            }
            
                                                 
            if (isOver()) {                                                       //    判断游戏是否结束
                if(snake.node == 39) 
                    hero = TRUE;
                }
                ESC = TRUE;
                hero = gameOver(hero);        
                break;
            }        
                
            //    打印贪吃蛇
            updataSnakeHead();                //    更新头部
            delay(gameSpeed);                 //    速度设置
            eraseSnakeTail();                 //    删除尾巴
        }   //    退出循环(!ESC)
    }
}

 

  其余的函数代码编写如下:

//    随机数产生
int rand(void)
{    
    int i;    
    i = ((TH0 << 8) | TL0) & 0x7fff;    
    return(i);
}

//    延时   
void delay(uchar ms)       //    10毫秒
{
    uchar i, j, k;
        
    while(ms--) {
        for(i = 5; i > 0; i--) {
            for(j = 4; j > 0; j--) {
                for(k = 248; k > 0; k--)
                    ;
            }  
        }
    }
}

void mulDelay(int s)     //    1秒
{
    int i;
    uchar j;

    for (i = 0; i < s; ++i) {
        for (j = 0; j < 100; ++j) {
            delay(1);     
        }
    }
}

//    键扫描函数 
void KeyScan()
{
    P0 = 0xff;


    if(P00 == 0 && snake.direction != LEFT) {
        snake.direction = RIGHT;
    }
                
    if(P01 == 0 && snake.direction != RIGHT) {
        snake.direction = LEFT;
    }
             
    if(P02 == 0 && snake.direction != DOWN) {
        snake.direction = UP;
    }         
         
    if(P03 == 0 && snake.direction != UP) {
        snake.direction = DOWN;
    }
     
    if(P04 == 0) {
        ESC = ~ESC;
    }  
}

void int_0(void) interrupt 0
{
    EA = 0;
    KeyScan();
}

void snakeInit()
{         
    snake.direction = RIGHT;            //    方向往右

    snake.x[0] = 9;                     //    蛇头坐标
    snake.y[0] = 33;    

    snake.x[1] = 6;                     //    蛇尾坐标
    snake.y[1] = 33;

    snake.node = 2;                     //    节数
}

void init(void) 
{
    EX0 = 1;                            //    开中断
    IT0 = 1;                            //    设置电平触发方式
    EA = 1;                             //    开所有中断
    TMOD = 0x01;
    TH0 = 65536 / 256;
    TL0 = 65536 % 256;
    TR0 = 1;

    
    hz_disp(3, 40, 3, snaker, 1);
    snakeInit();
}

//    需要出现新食物
bit createNewFood()
{
    uchar i;
    uchar size = snake.node;
    bit flag = TRUE;                         //    标记创建的新事物与贪吃蛇的身体冲突
    
    food.x = rand() % 114 + 6;
    food.y = rand() % 51 + 6;
    
    //    食物的坐标必须为3的倍数才会在显示屏先被显示
    for (; food.x % 3 != 0; ++food.x) {      
        ;
    }
    
    for (; food.y % 3 != 0; ++food.y) {       
        ;
    }
    
    for (i = 0; i < size; ++i) {
        if (food.x == snake.x[i] && food.y == snake.y[i]) {
            flag = FALSE;
            break;
        }
    }    

    return flag;
}

void start()
{
    ClearLCD(); 
    hz_disp(3, 40, 2, gameLevel, REWRITTEN);                         //    显示汉子“难度”
    en_disp(3, 80, 1, Asc, s1, REWRITTEN);                           //    显示s1数组的内容
    delay(150);
    ClearLCD();
    
    rectBoundary(5, 5, 123, 60, REWRITTEN);                          //    显示边框
    
    while (!createNewFood()) {                                       //    如果创建失败则继续创建,直到成功
        ;
    }
                
    RectArea(food.x, food.y, food.x + 2, food.y + 2, REWRITTEN);     //    在画面上显示食物
}

//    重新开始
void restart()
{            
    start();
}

//    是否增加难度
//    如果是,那么要重新开始
bit increaseLevel() 
{
    bit res = NO;
    //    每次蛇的长度超过10个增加一次难度,level最高4级
    if(snake.node % 10 == 0) {     
        level += 1;
        switch (level) {
            case 2:
                s1[0] = '2';
                gameSpeed = 15;
                break;
            case 3:
                s1[0] = '3';
                gameSpeed = 10;
                break;
            case 4:
                s1[0] = '4';
                gameSpeed = 5;
                break;
        }
        res = YES;
    }

    return res;
}



//    贪吃蛇移动
void move()
{
    uchar i;

    //    将蛇从最后个节点向前一个节点移动
    for(i = snake.node - 1; i > 0; i--) {                    
        snake.x[i] = snake.x[i - 1];
        snake.y[i] = snake.y[i - 1];
    }
    
    //    根据此时贪吃蛇的方向,设置蛇头的位置            
    switch(snake.direction)    {                  
        case RIGHT: 
            snake.x[0] += 3;
            break;
        case LEFT: 
            snake.x[0] -= 3;
            break;
        case UP: 
            snake.y[0] -= 3;
            break;
        case DOWN: 
            snake.y[0] += 3;
            break;
    }
}
 
//    游戏是否结束
bit isOver()
{
    bit overFlag = 0;
    uchar i;

    //    判断蛇是否吃到自己了
    //    从蛇的第四节开始判断是否撞到自己了
    for (i = 3; i < snake.node; i++)    {            
        if (snake.x[i] == snake.x[0] && snake.y[i] == snake.y[0]) {
            overFlag = 1;    
            break;
        }
    }
            
    if(snake.x[0] < 6 || snake.x[0] > 120
    || snake.y[0] < 6 || snake.y[0] > 57) {                //    判断蛇是否撞到墙壁    
        overFlag = 1;                                    
    }
    
    if(snake.node == 39) {
        overFlag = 1;
    }

    return overFlag;
}


void congratulations()
{
    idata uchar str[] = "Congratulations";
    uchar tmp[1];
    uchar len = 15;
    uchar i;
    s1[0] = 's';
    for (i = 0; i < 15; ++i) {
        tmp[0] = str[i];
        en_disp(3, i * 8 + 1, 1, Asc, tmp, REWRITTEN);
        //    en_disp(3, 80, 1, Asc, s1, REWRITTEN);
    }    
}

//    游戏结束后的画面
void theEndGraph()
{
    uchar i, j;

    for (i = 0; i < 2; ++i) {
        for (j = 0; j < 6; ++j) {
            hz_disp(i * 2, j * 21, 1, mySchool[i*6+j], 1);
        }
    }

    for (i = 0; i < 6; ++i) {
        hz_disp(6, i * 21, 1, myName[i], 1);
    }
}

//    游戏结束
bit gameOver(bit hero)
{
    //    ClearLCD();

    if (hero == TRUE) {                    //    当玩家贪吃蛇的节点达到了39个后显示恭喜通关画面
        hero = FALSE;        
        congratulations();
        mulDelay(2);
    } else {        
        hz_disp(3, 25, 4, theEnd, 1);
        mulDelay(2);    
    }
    
    ClearLCD();
    theEndGraph();                        //    打印“毕业设计“
    snakeInit();                          //    重新初始化游戏的参数
    return hero;
}

//    更新贪吃蛇的头部
void updataSnakeHead()
{
    RectArea(snake.x[0], snake.y[0], snake.x[0] + 2, snake.y[0] + 2, REWRITTEN);         //    绘制当前的头部
    RectArea(snake.x[1], snake.y[1], snake.x[1] + 2, snake.y[1] + 2, REWRITTEN);         //    将上一次的头部重新绘制以补全边角

    //    根据蛇的方向擦除蛇的头部中间的一点以确认贪吃蛇的头部
    switch (snake.direction) {
        case RIGHT:
            Dot(snake.x[0] + 2, snake.y[0] + 1, ERASE);            
            break;

        case LEFT:
            Dot(snake.x[0], snake.y[0] + 1, ERASE);            
            break;
                    
        case UP:
            Dot(snake.x[0] + 1, snake.y[0], ERASE);
            break;

        case DOWN:
            Dot(snake.x[0] + 1, snake.y[0] + 2, ERASE);
            break;
    }
}

//    去除蛇的的最后一节
void eraseSnakeTail()
{
     RectArea(snake.x[snake.node - 1], snake.y[snake.node - 1], snake.x[snake.node - 1] + 2, snake.y[snake.node - 1] + 2, ERASE);
}

  

  测试函数放在最后

void main (void)
{
    LCD12864_init();
    ClearLCD();
    init();

    gamePlay();
    while(1) {
        ;    
    }      
}

 

  以上是贪吃蛇游戏的实现snake.c,游戏的图形驱动12864.h和打印的字符代码asc.h如下:

//    12864.h
/*-----------------------------------------------------------*/
#define LCD_OFF 0x3E
#define LCD_ON  0x3F
#define Add_X     0xB8     //    the start address of the page 0 ;(0~7)
#define Add_Y     0x40     //    the start address of the Y counter ; (0~64)
#define Add_Z     0xC0     //    the start address of the DDRAM ; (0~64)
/*-----------------------------------------------------------*/
#define  LCD12864_DATA_PORT  P1
typedef unsigned char uchar;

sbit  LCD12864_EN         = P2 ^ 0;
sbit  LCD12864_RW         = P2 ^ 1;       //    0:write ; 1:read 
sbit  LCD12864_RS         = P2 ^ 2;       //    0:the command .1:the data
sbit  LCD12864_CS_L       = P2 ^ 3;       //    select the left of the lcd when 1
sbit  LCD12864_CS_R       = P2 ^ 4;  

/*--------------------------函数列表-------------------------*/
void LCDSel(uchar sel);                        //    片选 0全选 1左 2右
void WaitLCD();                                //    忙等待
void WriteDatToLCD12864(uchar dat);            //    写数据
void WriteCmdToLCD12864(uchar cmd);            //    写命令
uchar ReadDatFromLCD12864(void);               //    读数据

void SetX(uchar x);                            //    设置页地址0 - 7
void SetY(uchar y);                            //    设置列地址0 - 127
void SetZ(uchar z);                            //    设置首地址0-63

void ClearLCD();                               //    清屏 

void Dot(char x, char y, bit flag);            //    x:0~63~127    y:0~63    flag :0:擦除某个点 1:显示某个点
void Line(uchar x1, uchar y1, uchar x2, uchar y2, bit flag);                           //    (x1,y1) (x2,y2)作直线   flag :0:擦除线 1:显示线
void Rect(uchar x1, uchar y1, uchar x2, uchar y2, bit flag);                           //    (x1,y1) (x2,y2)作矩形框  flag :0:擦除框 1:显示框
void RectArea(uchar x1, uchar y1, uchar x2, uchar y2, bit flag);                       //    (x1,y1) (x2,y2)填充矩形  flag :0:擦除矩形 1:显示矩形
void hz_disp(uchar x, uchar y, uchar n, uchar code * hz, bit flag);                    //    x:行0~7  y:列0~127  显示n个汉字 flag:0 反白  16*16
void en_disp(uchar x, uchar y, uchar n, uchar code *asc, uchar *string, bit flag);     //    x:行0~7  y:列0~127  asc:指向标准交换码  string:指向要显示的字符串  flag:0 反白显示

/*--------------------------select the LCD--------------------*/
void LCDSel(uchar sel)
{
    switch(sel) {
        case 0: 
            LCD12864_CS_L = 0;
            LCD12864_CS_R = 0;
            break;      
        case 1: 
            LCD12864_CS_L = 1;
            LCD12864_CS_R = 0;
            break;       //left 
        case 2: 
            LCD12864_CS_L = 0;
            LCD12864_CS_R = 1;
            break;        //right
        default:
            ;
    }
}

/*------------------------------------------------------------*/
void WaitLCD()
{
    uchar flag;
    LCD12864_DATA_PORT = 0xFF;
    LCD12864_RW = 1;
    LCD12864_RS = 0;
    LCD12864_EN = 1;
    LCD12864_EN = 1;
    LCD12864_EN = 0;
    LCD12864_DATA_PORT = 0xFF;
    LCD12864_RW = 1;
    LCD12864_RS = 0;
    LCD12864_EN=1;

    do {
        flag=LCD12864_DATA_PORT;
    } while(!((flag & 0x80) == 0x80));
    
    LCD12864_EN=0;
}
                
/*-------------------------------------------------------------*/
void WriteDatToLCD12864(uchar dat)
{
    WaitLCD();
    LCD12864_RS = 1;
    LCD12864_RW = 0;
    LCD12864_DATA_PORT = dat;
    
    LCD12864_EN = 1;
    LCD12864_EN = 0;
}

/*-------------------------------------------------------------*/
void WriteCmdToLCD12864(uchar cmd)
{
    WaitLCD();
    LCD12864_RS = 0;
    LCD12864_RW = 0;
    LCD12864_DATA_PORT = cmd;
       
    LCD12864_EN = 1;
    LCD12864_EN = 0;
}
/*-------------------------------------------------------------*/
uchar ReadDatFromLCD12864(void)
{
    uchar dat;
    WaitLCD();

    LCD12864_DATA_PORT = 0xFF;              
    LCD12864_RS = 1;
    LCD12864_RW = 1;
    LCD12864_EN = 1;
    LCD12864_EN = 1;
    LCD12864_EN = 0;

    LCD12864_DATA_PORT = 0xFF;
    LCD12864_RS = 1;
    LCD12864_RW = 1;
    LCD12864_EN = 1;
    LCD12864_EN = 1;

    dat = LCD12864_DATA_PORT;
    LCD12864_EN = 0;

    return dat;
}
    

//x:0~7
void SetX(uchar x)
{
    WriteCmdToLCD12864(Add_X + x);
}


//y:0~127
void SetY(uchar y)
{
    WriteCmdToLCD12864(Add_Y + y);
}
/*------------------------------------------------------------*/
//z:0~63
void SetZ(uchar z)
{
    WriteCmdToLCD12864(Add_Z + z);
}

//    12864显示器初始化
void LCD12864_init(void)
{
    LCDSel(0);                       

    WriteCmdToLCD12864(0x3E);              //    分别初始化左半屏和右半屏
    WriteCmdToLCD12864(0X3F);
}

//    清屏
void ClearLCD()
{
    int i, j;

    LCDSel(0);
    for(j = 0; j < 8; j++) {
        WriteCmdToLCD12864(LCD_ON);
        SetX(j);  
        WriteCmdToLCD12864(Add_Y);
        SetZ(0);

        for (i = 0; i < 64; i++) {
            WriteDatToLCD12864(0x00);
        }
    }    
}

/*------------------------------------------------------------*/
//左上角第一个点为原点,垂直向下为Y轴,水平向右为X轴
//x:0~63~127    y:0~63
//flag :  0:擦除某个点
//        1:显示某个点 
uchar code Tab[] = {
    0x01, 0x02, 0x04, 0x08,
    0x10, 0x20, 0x40, 0x80
};

void Dot(char x,char y,bit flag)
{
    unsigned char dat;
    //    y=63-y;                                  
    //    坐标轴的移动和反转
    if (x < 64) {
        LCDSel(1);
        SetX(y / 8);           //    set the page address
        SetY(x);               //    set the Y adress
        dat = ReadDatFromLCD12864();

        if(flag) {
            dat = dat | (Tab[y % 8]);
        } else {
            dat= dat & (~(Tab[y % 8]));
        }
        
        SetX(y / 8);
        SetY(x);         //set the Y adress
        WriteDatToLCD12864(dat);
    } else if (x < 128) {
        LCDSel(2);
        SetX(y / 8);
        SetY(x - 64);

        dat=ReadDatFromLCD12864();

        if(flag) {
            dat = dat | (Tab[y % 8]);
        } else {
             dat = dat & (~(Tab[y % 8]));
        }

        SetY(x - 64);
        WriteDatToLCD12864(dat);
    }     
}

void swap(uchar *x, uchar *y)
{
    uchar tmp = *x;

    *x = *y;
    *y = tmp;
}

//    draw a line between point(x1,y1) and point(x2,y2)
//    flag       0: erase the line    
//            1: draw a line
void Line(uchar x1, uchar y1, uchar x2, uchar y2, bit flag)
{
    uchar i;
    float k;

    if (x1 == x2) {
        if (y1 > y2) {   
            swap(&x1, &x2);
            swap(&y1, &y2);
        }
        for (i = y1; i <= y2; i++) {
            Dot(x1, i, flag);
        }
    } else {
        if ( x1 > x2) {
               swap(&x1, &x2);
            swap(&y1, &y2);
         }

        k = (float)(y2 - y1) / (float)(x2 - x1);

        for (i = 0; i < x2 - x1; i++) {
            Dot(x1 + i, (uchar)(y1 + k * i), flag);
        }
    }
}       

void rectBoundary(uchar x1, uchar y1, uchar x2, uchar y2, bit flag)
{
       Line(x1, y1, x2, y1, flag);
    Line(x1, y1, x1, y2, flag);
    Line(x2, y1, x2, y2, flag);
    Line(x1, y2, x2, y2, flag);
} 


void RectArea(uchar x1, uchar y1, uchar x2, uchar y2, bit flag)
{
    uchar i;

    if (x1 > x2) {
        swap(&x1, &x2);
        swap(&y1, &y2);
    }

    for (i = 0; i <= x2 - x1; i++) {
        Line(x1 + i, y1, x1 + i, y2, flag);
    }

}              


//    16 * 16
//    x行  0~7      
//    y列  0~127
//    flag 0:汉字反白显示
void hz_disp(uchar x, uchar y, uchar n, uchar code * hz, bit flag)
{
    uchar i, j;
    for (j = 0; j < n; j++) {
        //显示上半个汉字
        for (i = 0; i < 16; i++) {
            //点的位置是在左还是右
            if(y + 16 * j + i < 64) {
                LCDSel(1);
                WriteCmdToLCD12864(LCD_ON);
                
                SetX(x);
                SetZ(0);
                SetY(y+16*j+i);

                if(flag) {
                     WriteDatToLCD12864(hz[32 * j + i]);
                } else {
                     WriteDatToLCD12864(~hz[32 * j + i]);
                }        
            } else if(y + 16 * j + i < 128) {
                LCDSel(2);
                WriteCmdToLCD12864(LCD_ON);

                SetX(x);
                SetZ(0);
                SetY(y + 16 * j + i - 64);

                if(flag) {
                     WriteDatToLCD12864(hz[32 * j + i]);
                } else {
                     WriteDatToLCD12864(~hz[32 * j + i]);
                }      
            }
        }
        
        //显示下半个汉字
        for (i = 16; i < 32; i++) {
            //先判断点是在左还是在右
            if(y + 16 * j + i - 16 < 64) {    
                if(x + 1 < 8) {                               //最后一行显示上半个字
                    LCDSel(1);
                    WriteCmdToLCD12864(LCD_ON);

                    SetX(x + 1);
                    SetZ(0);
                    SetY(y + 16 * j + i - 16);

                    if(flag) {
                         WriteDatToLCD12864(hz[32 * j + i]);
                    } else {
                         WriteDatToLCD12864(~hz[32 * j + i]);
                    }    
                }
            } else if (y + 16 * j + i - 16 < 127) {
                if(x + 1 < 8) {                           //最后一行
                    LCDSel(2);
                    WriteCmdToLCD12864(LCD_ON);

                    SetX(x + 1);
                    SetZ(0);
                    SetY(y + 16 * j + i - 16 - 64);

                    if(flag) {
                         WriteDatToLCD12864(hz[32 * j + i]);
                    } else {
                         WriteDatToLCD12864(~hz[32 * j + i]);
                    }
                }
            }
        }
    }
}


//    x:行0~7
//    y:列0~127
//    asc: 指向标准交换码
//    string: 指向要显示的字符串
//    flag:  0 反白显示
void en_disp(uchar x, uchar y, uchar n, uchar code *asc, uchar *string, bit flag)
{
    uchar i, j, loc;

    for (j = 0; j < n; j++) {
        loc = string[j] - 0x20;            //    确定要显示的字符在asc表中的位置(乘上16)
        
        //    显示上半个ASCII字符
        for (i = 0; i < 8; i++) {
            //     点的位置是在左还是右
            if( y + 8 * j + i < 64) {
                LCDSel(1);
                WriteCmdToLCD12864(LCD_ON);
                
                SetX(x);
                SetZ(0);
                SetY(y + 8 * j + i);
                
                if(flag) {
                    WriteDatToLCD12864(asc[16 * loc + i]);
                } else {
                    WriteDatToLCD12864(~asc[16 * loc + i]);
                }
                    
            } else if (y + 8 * j + i < 128) {
                LCDSel(2);
                WriteCmdToLCD12864(LCD_ON);

                SetX(x);
                SetZ(0);
                SetY(y + 8 * j + i - 64);

                if(flag) {
                    WriteDatToLCD12864(asc[16 * loc + i]);
                } else {
                    WriteDatToLCD12864(~asc[16 * loc + i]);
                }            
            }
        }

        //    显示下半个ASCII字符
        for (i = 8; i < 16; i++) {
            //    先判断点是在左还是在右
            if(y + 8 * j + i - 8 < 64) {  
                if(x + 1 < 8) {                        //    最后一行
                    LCDSel(1);
                    WriteCmdToLCD12864(LCD_ON);

                    SetX(x + 1);
                    SetZ(0);
                    SetY(y + 8 * j + i - 8);

                    if(flag) {
                        WriteDatToLCD12864(asc[16 * loc + i]);
                    } else {
                        WriteDatToLCD12864(~asc[16 * loc + i]);
                    }        
                }
            } else if (y + 8 * j + i - 8 < 128) {
                if(x + 1 < 8) {                       //    最后一行
                    LCDSel(2);
                    WriteCmdToLCD12864(LCD_ON);

                    SetX(x + 1);
                    SetZ(0);
                    SetY(y + 8 * j + i - 8 - 64);

                    if(flag) {
                        WriteDatToLCD12864(asc[16 * loc + i]);
                    } else {
                        WriteDatToLCD12864(~asc[16 * loc + i]);
                    }
                }        
            }
        }
    }  
}

 

//    asc.h
//    以下均为汉子和字符的代码,感谢晓奇工作室 www.xiao-qi.com的软件

//    难度
unsigned char code gameLevel[]=
{
      0x04,0x34,0xC4,0x04,0xC4,0x3E,0x44,0x20,
      0xF8,0x4F,0x49,0xFA,0x48,0x4C,0x08,0x00,
      0x20,0x10,0x0C,0x03,0x04,0x18,0x00,0x00,
      0xFF,0x22,0x22,0x3F,0x22,0x32,0x20,0x00,

      0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0xA5,
      0xA6,0xA4,0xFC,0x24,0x34,0x26,0x04,0x00,
      0x40,0x20,0x9F,0x80,0x42,0x42,0x26,0x2A,
      0x12,0x2A,0x26,0x42,0x40,0xC0,0x40,0x00
};

//    贪吃蛇
unsigned char code snaker[]=
{
      0x00,0x20,0x10,0xD8,0x88,0x8C,0x96,0x97,
      0xDB,0xB2,0x94,0x9C,0xD8,0xB0,0x20,0x20,
      0x00,0x00,0x00,0x9F,0x5F,0x60,0x30,0x3E,
      0x1C,0x60,0xC0,0xDF,0x5F,0x00,0x00,0x00,

      0x00,0xFC,0xF8,0x08,0xF8,0xFC,0x48,0x20,
      0xB8,0x9E,0x97,0x92,0x90,0xD0,0x98,0x10,
      0x00,0x1F,0x1F,0x08,0x1F,0x1F,0x00,0x70,
      0xF8,0xCC,0xC6,0xC2,0xC3,0xC1,0xF0,0x40,

       0x00,0xF0,0x20,0xFE,0xFC,0x20,0xF0,0x18,
      0x3C,0x08,0xE9,0xCE,0x0C,0x88,0x38,0x1C,
      0x00,0x23,0x62,0x3F,0x3F,0x12,0x3B,0x20,
      0x10,0x08,0x7F,0xFF,0xC3,0xC3,0x79,0x20
};

//    游戏结束
unsigned char code theEnd[]=
{
      0x10,0x22,0x6C,0x00,0x08,0x08,0xF9,0x4A,
      0xC8,0x18,0x28,0x27,0xA4,0x66,0x24,0x00,
      0x04,0x04,0xFE,0x41,0x20,0x18,0x07,0x40,
      0x7F,0x02,0x42,0x82,0x7F,0x02,0x02,0x00,

      0x00,0x14,0x24,0xC4,0x04,0xE4,0x1C,0x10,
      0x10,0xFF,0x10,0x12,0x14,0xD0,0x10,0x00,
      0x20,0x10,0x08,0x06,0x01,0x02,0x8C,0x40,
      0x20,0x17,0x18,0x24,0x43,0x80,0xE0,0x00,

      0x00,0x30,0x28,0xA4,0x63,0x10,0x08,0x48,
      0x48,0x48,0x7F,0x48,0x48,0x4C,0x08,0x00,
      0x00,0x22,0x63,0x22,0x12,0x12,0x00,0xFE,
      0x42,0x42,0x42,0x42,0x42,0xFF,0x02,0x00,

      0x04,0x04,0xE4,0x24,0x24,0x24,0x24,0xFF,
      0x24,0x24,0x24,0x24,0xF4,0x26,0x04,0x00,
      0x40,0x40,0x27,0x22,0x12,0x0A,0x06,0xFF,
      0x06,0x0A,0x12,0x12,0x27,0x60,0x20,0x00
};

//    成都理工大学工程技术学院
unsigned char code mySchool[12][32] = {
      0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0x08,
      0x08,0xFF,0x08,0x09,0x0A,0xC8,0x08,0x00,
      0x80,0x60,0x1F,0x00,0x10,0x20,0x1F,0x80,
      0x40,0x21,0x16,0x18,0x26,0x41,0xF8,0x00,

       0x20,0x24,0x24,0xA4,0x7F,0x24,0x34,0x28,
      0x26,0x20,0xFE,0x02,0x22,0xDA,0x06,0x00,
      0x04,0x02,0xFF,0x49,0x49,0x49,0x49,0xFF,
      0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00,

       0x04,0x84,0x84,0xFC,0x84,0x84,0x00,0xFE,
      0x92,0x92,0xFE,0x92,0x92,0xFE,0x00,0x00,
      0x20,0x60,0x20,0x1F,0x10,0x10,0x40,0x44,
      0x44,0x44,0x7F,0x44,0x44,0x44,0x40,0x00,

       0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,
      0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

       0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
      0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,
      0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,

       0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,
      0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
      0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
      0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,

      0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,
      0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00,
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,
      0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,

       0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,
      0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00,
      0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,
      0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00,

       0x10,0x10,0x10,0xFF,0x10,0x90,0x08,0x88,
      0x88,0x88,0xFF,0x88,0x88,0x88,0x08,0x00,
      0x04,0x44,0x82,0x7F,0x01,0x80,0x80,0x40,
      0x43,0x2C,0x10,0x28,0x46,0x81,0x80,0x00,

       0x00,0x10,0x10,0x10,0x10,0xD0,0x30,0xFF,
      0x30,0xD0,0x12,0x1C,0x10,0x10,0x00,0x00,
      0x10,0x08,0x04,0x02,0x01,0x00,0x00,0xFF,
      0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x00,

       0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,
      0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,
      0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,
      0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
       
      0x00,0xFE,0x22,0x5A,0x86,0x10,0x0C,0x24,
      0x24,0x25,0x26,0x24,0x24,0x14,0x0C,0x00,
      0x00,0xFF,0x04,0x08,0x07,0x80,0x41,0x31,
      0x0F,0x01,0x01,0x3F,0x41,0x41,0x71,0x00
};

//    毕业设计
unsigned char code myName[6][32] = {
       0x40,0x48,0x48,0x48,0xFF,0x48,0x48,0x00,
      0x04,0x08,0x30,0xC0,0x30,0x0E,0x00,0x00,
      0x80,0x60,0x1F,0x20,0x7F,0x44,0x44,0x40,
      0x48,0x44,0x43,0x40,0x43,0x4C,0x40,0x00,

       0x20,0xC2,0x0C,0x80,0x84,0xA4,0xA4,0xAF,
      0xA4,0xF4,0xA4,0xAF,0xA4,0xE4,0x84,0x00,
      0x04,0x04,0x7E,0x81,0x40,0x3A,0x22,0x1A,
      0x02,0xFF,0x0A,0x32,0x02,0xFB,0x00,0x00,

      0x00,0x00,0xFF,0x88,0x88,0x48,0x48,0x00,
      0x7F,0x88,0x84,0x84,0x82,0xE0,0x00,0x00,
      0x04,0x04,0x05,0x04,0x04,0x04,0x04,0xFF,
      0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,

       0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,
      0x00,0xFF,0x00,0x00,0xC0,0x30,0x00,0x00,
      0x40,0x40,0x40,0x43,0x40,0x7F,0x40,0x40,
      0x40,0x7F,0x42,0x41,0x40,0x40,0x40,0x00,

       0x40,0x40,0x42,0xCC,0x00,0x40,0xA0,0x9E,
      0x82,0x82,0x82,0x9E,0xA0,0x20,0x20,0x00,
      0x00,0x00,0x00,0x3F,0x90,0x88,0x40,0x43,
      0x2C,0x10,0x28,0x46,0x41,0x80,0x80,0x00,

       0x40,0x40,0x42,0xCC,0x00,0x40,0x40,0x40,
      0x40,0xFF,0x40,0x40,0x40,0x40,0x40,0x00,
      0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x00,
      0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00
};

//    ASCII值
unsigned char code Asc[] =                   
{
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // - -
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x00,0x00,0x38,0xFC,0xFC,0x38,0x00,0x00,  // -!-
    0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,

    0x00,0x0E,0x1E,0x00,0x00,0x1E,0x0E,0x00,  // -"-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x20,0xF8,0xF8,0x20,0xF8,0xF8,0x20,0x00,  // -#-
    0x02,0x0F,0x0F,0x02,0x0F,0x0F,0x02,0x00,

    0x38,0x7C,0x44,0x47,0x47,0xCC,0x98,0x00,  // -$-
    0x03,0x06,0x04,0x1C,0x1C,0x07,0x03,0x00,

    0x30,0x30,0x00,0x80,0xC0,0x60,0x30,0x00,  // -%-
    0x0C,0x06,0x03,0x01,0x00,0x0C,0x0C,0x00,

    0x80,0xD8,0x7C,0xE4,0xBC,0xD8,0x40,0x00,  // -&-
    0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

    0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,0x00,  // -'-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x00,0x00,0xF0,0xF8,0x0C,0x04,0x00,0x00,  // -(-
    0x00,0x00,0x03,0x07,0x0C,0x08,0x00,0x00,

    0x00,0x00,0x04,0x0C,0xF8,0xF0,0x00,0x00,  // -)-
    0x00,0x00,0x08,0x0C,0x07,0x03,0x00,0x00,

    0x80,0xA0,0xE0,0xC0,0xC0,0xE0,0xA0,0x80,  // -*-
    0x00,0x02,0x03,0x01,0x01,0x03,0x02,0x00,

    0x00,0x80,0x80,0xE0,0xE0,0x80,0x80,0x00,  // -+-
    0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00,

    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -,-
    0x00,0x00,0x10,0x1E,0x0E,0x00,0x00,0x00,

    0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,  // ---
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -.-
    0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,

    0x00,0x00,0x00,0x80,0xC0,0x60,0x30,0x00,  // -/-
    0x0C,0x06,0x03,0x01,0x00,0x00,0x00,0x00,

    0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00,  // -0-
    0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00,

    0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00,  // -1-
    0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00,

    0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00,  // -2-
    0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00,

    0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00,  // -3-
    0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,

    0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00,  // -4-
    0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,

    0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00,  // -5-
    0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00,

    0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00,  // -6-
    0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

    0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00,  // -7-
    0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00,

    0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00,  // -8-
    0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

    0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00,  // -9-
    0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00,

    0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,  // -:-
    0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,

    0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,  // -;-
    0x00,0x00,0x08,0x0E,0x06,0x00,0x00,0x00,

    0x00,0x80,0xC0,0x60,0x30,0x18,0x08,0x00,  // -<-
    0x00,0x00,0x01,0x03,0x06,0x0C,0x08,0x00,

    0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,  // -=-
    0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,

    0x00,0x08,0x18,0x30,0x60,0xC0,0x80,0x00,  // ->-
    0x00,0x08,0x0C,0x06,0x03,0x01,0x00,0x00,

    0x18,0x1C,0x04,0xC4,0xE4,0x3C,0x18,0x00,  // -?-
    0x00,0x00,0x00,0x0D,0x0D,0x00,0x00,0x00,

    0xF0,0xF8,0x08,0xC8,0xC8,0xF8,0xF0,0x00,  // -@-
    0x07,0x0F,0x08,0x0B,0x0B,0x0B,0x01,0x00,

    0xE0,0xF0,0x98,0x8C,0x98,0xF0,0xE0,0x00,  // -A-
    0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

    0x04,0xFC,0xFC,0x44,0x44,0xFC,0xB8,0x00,  // -B-
    0x08,0x0F,0x0F,0x08,0x08,0x0F,0x07,0x00,

    0xF0,0xF8,0x0C,0x04,0x04,0x0C,0x18,0x00,  // -C-
    0x03,0x07,0x0C,0x08,0x08,0x0C,0x06,0x00,

    0x04,0xFC,0xFC,0x04,0x0C,0xF8,0xF0,0x00,  // -D-
    0x08,0x0F,0x0F,0x08,0x0C,0x07,0x03,0x00,

    0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,  // -E-
    0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,

    0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,  // -F-
    0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

    0xF0,0xF8,0x0C,0x84,0x84,0x8C,0x98,0x00,  // -G-
    0x03,0x07,0x0C,0x08,0x08,0x07,0x0F,0x00,

    0xFC,0xFC,0x40,0x40,0x40,0xFC,0xFC,0x00,  // -H-
    0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

    0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x00,  // -I-
    0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

    0x00,0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,  // -J-
    0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00,

    0x04,0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00,  // -K-
    0x08,0x0F,0x0F,0x00,0x01,0x0F,0x0E,0x00,

    0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,  // -L-
    0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00,

    0xFC,0xFC,0x38,0x70,0x38,0xFC,0xFC,0x00,  // -M-
    0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

    0xFC,0xFC,0x38,0x70,0xE0,0xFC,0xFC,0x00,  // -N-
    0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,

    0xF0,0xF8,0x0C,0x04,0x0C,0xF8,0xF0,0x00,  // -O-
    0x03,0x07,0x0C,0x08,0x0C,0x07,0x03,0x00,

    0x04,0xFC,0xFC,0x44,0x44,0x7C,0x38,0x00,  // -P-
    0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

    0xF8,0xFC,0x04,0x04,0x04,0xFC,0xF8,0x00,  // -Q-
    0x07,0x0F,0x08,0x0E,0x3C,0x3F,0x27,0x00,

    0x04,0xFC,0xFC,0x44,0xC4,0xFC,0x38,0x00,  // -R-
    0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

    0x18,0x3C,0x64,0x44,0xC4,0x9C,0x18,0x00,  // -S-
    0x06,0x0E,0x08,0x08,0x08,0x0F,0x07,0x00,

    0x00,0x1C,0x0C,0xFC,0xFC,0x0C,0x1C,0x00,  // -T-
    0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

    0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,  // -U-
    0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

    0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,  // -V-
    0x01,0x03,0x06,0x0C,0x06,0x03,0x01,0x00,

    0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00,  // -W-
    0x03,0x0F,0x0E,0x03,0x0E,0x0F,0x03,0x00,

    0x0C,0x3C,0xF0,0xC0,0xF0,0x3C,0x0C,0x00,  // -X-
    0x0C,0x0F,0x03,0x00,0x03,0x0F,0x0C,0x00,

    0x00,0x3C,0x7C,0xC0,0xC0,0x7C,0x3C,0x00,  // -Y-
    0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

    0x1C,0x0C,0x84,0xC4,0x64,0x3C,0x1C,0x00,  // -Z-
    0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0E,0x00,

    0x00,0x00,0xFC,0xFC,0x04,0x04,0x00,0x00,  // -[-
    0x00,0x00,0x0F,0x0F,0x08,0x08,0x00,0x00,

    0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,0x00,  // -\-
    0x00,0x00,0x00,0x01,0x03,0x07,0x0E,0x00,

    0x00,0x00,0x04,0x04,0xFC,0xFC,0x00,0x00,  // -]-
    0x00,0x00,0x08,0x08,0x0F,0x0F,0x00,0x00,

    0x08,0x0C,0x06,0x03,0x06,0x0C,0x08,0x00,  // -^-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  // -_-
    0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,

    0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00,  // -`-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x00,0xA0,0xA0,0xA0,0xE0,0xC0,0x00,0x00,  // -a-
    0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

    0x04,0xFC,0xFC,0x20,0x60,0xC0,0x80,0x00,  // -b-
    0x08,0x0F,0x07,0x08,0x08,0x0F,0x07,0x00,

    0xC0,0xE0,0x20,0x20,0x20,0x60,0x40,0x00,  // -c-
    0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,

    0x80,0xC0,0x60,0x24,0xFC,0xFC,0x00,0x00,  // -d-
    0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

    0xC0,0xE0,0xA0,0xA0,0xA0,0xE0,0xC0,0x00,  // -e-
    0x07,0x0F,0x08,0x08,0x08,0x0C,0x04,0x00,

    0x40,0xF8,0xFC,0x44,0x0C,0x18,0x00,0x00,  // -f-
    0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

    0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00,  // -g-
    0x27,0x6F,0x48,0x48,0x7F,0x3F,0x00,0x00,

    0x04,0xFC,0xFC,0x40,0x20,0xE0,0xC0,0x00,  // -h-
    0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

    0x00,0x00,0x20,0xEC,0xEC,0x00,0x00,0x00,  // -i-
    0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

    0x00,0x00,0x00,0x00,0x20,0xEC,0xEC,0x00,  // -j-
    0x00,0x30,0x70,0x40,0x40,0x7F,0x3F,0x00,

    0x04,0xFC,0xFC,0x80,0xC0,0x60,0x20,0x00,  // -k-
    0x08,0x0F,0x0F,0x01,0x03,0x0E,0x0C,0x00,

    0x00,0x00,0x04,0xFC,0xFC,0x00,0x00,0x00,  // -l-
    0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,

    0xE0,0xE0,0x60,0xC0,0x60,0xE0,0xC0,0x00,  // -m-
    0x0F,0x0F,0x00,0x0F,0x00,0x0F,0x0F,0x00,

    0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00,  // -n-
    0x00,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00,

    0xC0,0xE0,0x20,0x20,0x20,0xE0,0xC0,0x00,  // -o-
    0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00,

    0x20,0xE0,0xC0,0x20,0x20,0xE0,0xC0,0x00,  // -p-
    0x40,0x7F,0x7F,0x48,0x08,0x0F,0x07,0x00,

    0xC0,0xE0,0x20,0x20,0xC0,0xE0,0x20,0x00,  // -q-
    0x07,0x0F,0x08,0x48,0x7F,0x7F,0x40,0x00,

    0x20,0xE0,0xC0,0x60,0x20,0x60,0xC0,0x00,  // -r-
    0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00,

    0x40,0xE0,0xA0,0x20,0x20,0x60,0x40,0x00,  // -s-
    0x04,0x0C,0x09,0x09,0x0B,0x0E,0x04,0x00,

    0x20,0x20,0xF8,0xFC,0x20,0x20,0x00,0x00,  // -t-
    0x00,0x00,0x07,0x0F,0x08,0x0C,0x04,0x00,

    0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00,  // -u-
    0x07,0x0F,0x08,0x08,0x07,0x0F,0x08,0x00,

    0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,  // -v-
    0x00,0x03,0x07,0x0C,0x0C,0x07,0x03,0x00,

    0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00,  // -w-
    0x07,0x0F,0x0C,0x07,0x0C,0x0F,0x07,0x00,

    0x20,0x60,0xC0,0x80,0xC0,0x60,0x20,0x00,  // -x-
    0x08,0x0C,0x07,0x03,0x07,0x0C,0x08,0x00,

    0xE0,0xE0,0x00,0x00,0x00,0xE0,0xE0,0x00,  // -y-
    0x47,0x4F,0x48,0x48,0x68,0x3F,0x1F,0x00,

    0x60,0x60,0x20,0xA0,0xE0,0x60,0x20,0x00,  // -z-
    0x0C,0x0E,0x0B,0x09,0x08,0x0C,0x0C,0x00,

    0x00,0x40,0x40,0xF8,0xBC,0x04,0x04,0x00,  // -{-
    0x00,0x00,0x00,0x07,0x0F,0x08,0x08,0x00,

    0x00,0x00,0x00,0xBC,0xBC,0x00,0x00,0x00,  // -|-
    0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,

    0x00,0x04,0x04,0xBC,0xF8,0x40,0x40,0x00,  // -}-
    0x00,0x08,0x08,0x0F,0x07,0x00,0x00,0x00,

    0x08,0x0C,0x04,0x0C,0x08,0x0C,0x04,0x00,  // -~-
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

    0x80,0xC0,0x60,0x30,0x60,0xC0,0x80,0x00,  // --
    0x07,0x07,0x04,0x04,0x04,0x07,0x07,0x00,
};

 

  

 

转载于:https://www.cnblogs.com/hcxc/p/5647946.html

你可能感兴趣的:(基于AT89C51单片机的贪吃蛇电子游戏(仿真))