diff --git a/MCU/MCU_REAL_FINAL/img.h b/MCU/MCU_REAL_FINAL/img.h index c98a08c..c760358 100644 --- a/MCU/MCU_REAL_FINAL/img.h +++ b/MCU/MCU_REAL_FINAL/img.h @@ -151,4 +151,13 @@ code unsigned char FONT_BEST1[]={ 0x02,0x42,0x81,0x7F,0x00,0x08,0x08,0x08,0xFF,0x00,0x00,0xFF,0x08,0x08,0x08,0x00, 0x02,0x01,0x00,0xFF,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00, }; +//=================== 扫雷字库 ================== +code unsigned char FONT_MINE0[]={ +0x00,0xFE,0x20,0x20,0x3F,0x20,0x00,0xFC,0x24,0xE4,0x24,0x22,0x23,0xE2,0x00,0x00, +0x00,0x10,0x10,0x10,0x10,0xD0,0x30,0xFF,0x30,0xD0,0x10,0x10,0x10,0x10,0x00,0x00, +}; +code unsigned char FONT_MINE1[]={ +0x80,0x7F,0x01,0x01,0xFF,0x80,0x60,0x1F,0x80,0x41,0x26,0x18,0x26,0x41,0x80,0x00, +0x10,0x08,0x04,0x02,0x09,0x08,0x08,0xFF,0x08,0x08,0x09,0x02,0x04,0x08,0x10,0x00, +}; #endif \ No newline at end of file diff --git a/MCU/MCU_REAL_FINAL/main.c b/MCU/MCU_REAL_FINAL/main.c index 95d2270..9b5302f 100644 --- a/MCU/MCU_REAL_FINAL/main.c +++ b/MCU/MCU_REAL_FINAL/main.c @@ -3,7 +3,7 @@ //#define WIPE_BEST -#define RELOAD (65535-8535) //定时器填充值(1ms) +#define RELOAD (65535-7535) //定时器填充值(1ms) unsigned char TH, TL; extern Menu *NOW; //菜单指针 diff --git a/MCU/MCU_REAL_FINAL/menu.c b/MCU/MCU_REAL_FINAL/menu.c index 8ba2ccf..2a42860 100644 --- a/MCU/MCU_REAL_FINAL/menu.c +++ b/MCU/MCU_REAL_FINAL/menu.c @@ -7,6 +7,7 @@ #include #include "block.h" #include +#include "mine.h" //便于调试的预编译命令 //#define DEBUG_MODE @@ -19,13 +20,14 @@ Menu M_MAINMENU;// Menu M_BLOCK; //俄罗斯方块 Menu M_BEST; //弹球 Menu M_ABOUT; //关于 +Menu M_MINE; //扫雷 Menu* NOW; //当前菜单指针 Menu* LAST = NULL; //上一个状态的菜单 code unsigned int ver _at_ 0x7ffe; enum OPR opr = idle; -static unsigned int local[4] = {0}; +static unsigned int local[5] = {0}; unsigned int score; unsigned int bestScore[10]; unsigned int mBestScore[10]; @@ -236,6 +238,7 @@ void m_best(struct _menu* this) if(LAST != &M_BEST) { LAST = &M_BEST; + local[4] = 0; drawBEST(2, 0); //绘制字 drawSUPNUM(2, 2, bestScore[0] / 10000); //绘制分数 drawSUPNUM(11, 2, (bestScore[0] % 10000) / 1000); @@ -286,6 +289,38 @@ void m_best(struct _menu* this) NOW = &M_MAINMENU; //转向下一菜单 clear(); } + if(opr == left) + { + opr = idle; + local[4]++; + } + if(local[4] > 5) + { + local[4] = 0; + NOW = &M_MINE; //扫雷调试入口 + clear(); + } +} + +//扫雷游戏 +void m_mine(struct _menu* this) +{ + if(LAST != &M_MINE) + { + LAST = &M_MINE; + drawVerticalDottedLine(64); + drawBLOCKSCORE(); + mineInit(); + } + //返回 + if(opr == confirm) + { + opr = idle; + clear(); + mineDestroy(); + NOW = &M_MAINMENU; + return; + } } void menuInit() @@ -294,6 +329,7 @@ void menuInit() M_BLOCK.f = m_block; M_ABOUT.f = m_about; M_BEST.f = m_best; + M_MINE.f = m_mine; #ifdef DEBUG_MODE NOW = &M_DEBUG; diff --git a/MCU/MCU_REAL_FINAL/mine.c b/MCU/MCU_REAL_FINAL/mine.c index 36e4e70..8b0b8ff 100644 --- a/MCU/MCU_REAL_FINAL/mine.c +++ b/MCU/MCU_REAL_FINAL/mine.c @@ -2,6 +2,8 @@ #include "mine.h" #include "button.h" #include +#include "draw.h" +#include enum MGS mineGameStatus = _idle; extern unsigned int mBestScore[]; @@ -9,6 +11,24 @@ char mbase[MAX_MX][MAX_MY] = {0}; //x*y //0为 extern unsigned int score; extern enum OPR opr; +void mineInit() +{ + char i, j; + mineGameStatus = start; + score = 0; + + for(i = 0; i < 8; i++) + for(j = 0; j < 8; j++) + placeIMG_BLOCK(i, j); + genMine(); +} + +void mineDestroy() +{ + score = 0; + memset(mbase,0, sizeof(mbase)); + mineGameStatus = over; +} unsigned mIsIegal(int i, int j) { @@ -33,7 +53,7 @@ unsigned int findSum(int i, int j) mIsIegal(i - 1, j - 1) ? re += mbase[i - 1][j - 1] : 0; mIsIegal(i + 1, j - 1) ? re += mbase[i + 1][j - 1] : 0; } - return re; + return re; } void genMine() diff --git a/MCU/MCU_REAL_FINAL/mine.h b/MCU/MCU_REAL_FINAL/mine.h index 3c5a4ff..fc9dcf5 100644 --- a/MCU/MCU_REAL_FINAL/mine.h +++ b/MCU/MCU_REAL_FINAL/mine.h @@ -1,2 +1,11 @@ +#ifndef _MINE_H_ +#define _MINE_H_ + #define MAX_MX 8 -#define MAX_MY 8 \ No newline at end of file +#define MAX_MY 8 + +void genMine(); +void mineDestroy(); +void mineInit(); + +#endif \ No newline at end of file