feat(MCU课设): 扫雷程序添加

This commit is contained in:
iridiumR 2022-06-08 20:07:55 +08:00
parent fd117446b3
commit 0fb13571bf
5 changed files with 78 additions and 4 deletions

View file

@ -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

View file

@ -3,7 +3,7 @@
//#define WIPE_BEST
#define RELOAD (65535-8535) //定时器填充值(1ms)
#define RELOAD (65535-7535) //定时器填充值(1ms)
unsigned char TH, TL;
extern Menu *NOW; //꽉데寧濾

View file

@ -7,6 +7,7 @@
#include <stdlib.h>
#include "block.h"
#include <absacc.h>
#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;

View file

@ -2,6 +2,8 @@
#include "mine.h"
#include "button.h"
#include <reg52.h>
#include "draw.h"
#include <string.h>
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()

View file

@ -1,2 +1,11 @@
#ifndef _MINE_H_
#define _MINE_H_
#define MAX_MX 8
#define MAX_MY 8
#define MAX_MY 8
void genMine();
void mineDestroy();
void mineInit();
#endif