2022-05-19 13:07:52 +00:00
|
|
|
|
#include "menu.h"
|
|
|
|
|
#include "display.h"
|
|
|
|
|
#include "delay.h"
|
2022-05-25 07:12:42 +00:00
|
|
|
|
#include "draw.h"
|
2022-06-05 12:26:03 +00:00
|
|
|
|
#include <stdio.h>
|
2022-06-05 13:03:15 +00:00
|
|
|
|
#include <stdlib.h>
|
2022-06-05 15:35:53 +00:00
|
|
|
|
#include "block.h"
|
2022-06-05 13:19:35 +00:00
|
|
|
|
|
2022-06-06 05:55:35 +00:00
|
|
|
|
//<2F><><EFBFBD>ڵ<EFBFBD><DAB5>Ե<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#define DEBUG_MODE
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_MODE
|
|
|
|
|
#define M_DEBUG M_BLOCK
|
|
|
|
|
#endif
|
2022-06-06 05:41:14 +00:00
|
|
|
|
|
2022-06-05 12:26:03 +00:00
|
|
|
|
Menu M_MAINMENU;//<2F><><EFBFBD>˵<EFBFBD>
|
2022-06-05 13:19:35 +00:00
|
|
|
|
Menu M_BLOCK; //<2F><><EFBFBD><EFBFBD>˹<EFBFBD><CBB9><EFBFBD><EFBFBD>
|
|
|
|
|
Menu M_BALL; //<2F><><EFBFBD><EFBFBD>
|
2022-05-19 13:07:52 +00:00
|
|
|
|
|
2022-06-06 05:41:14 +00:00
|
|
|
|
Menu M_STARTUP;
|
2022-05-19 13:07:52 +00:00
|
|
|
|
|
2022-06-04 14:15:13 +00:00
|
|
|
|
Menu* NOW; //<2F><>ǰ<EFBFBD>˵<EFBFBD>ָ<EFBFBD><D6B8>
|
2022-06-05 13:03:15 +00:00
|
|
|
|
Menu* LAST = NULL; //<2F><>һ<EFBFBD><D2BB>״̬<D7B4>IJ˵<C4B2>
|
2022-05-25 07:12:42 +00:00
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
enum OPR opr = idle;
|
2022-06-05 13:03:15 +00:00
|
|
|
|
static unsigned char local[10] = {0};
|
2022-05-25 07:12:42 +00:00
|
|
|
|
|
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʾ
|
2022-06-05 13:03:15 +00:00
|
|
|
|
void m_startup(struct _menu* this)
|
2022-06-05 12:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(LAST != &M_STARTUP)
|
|
|
|
|
{
|
2022-06-05 13:03:15 +00:00
|
|
|
|
LAST = &M_STARTUP;
|
|
|
|
|
|
2022-06-05 12:26:03 +00:00
|
|
|
|
drawNAME(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
delay(1000);
|
|
|
|
|
drawNUMBER(); //<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
if(opr == right)
|
2022-06-05 12:26:03 +00:00
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
NOW = this->n; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
//<2F><><EFBFBD>˵<EFBFBD>
|
2022-06-05 13:03:15 +00:00
|
|
|
|
void m_mainmenu(struct _menu* this)
|
2022-05-19 13:07:52 +00:00
|
|
|
|
{
|
2022-06-05 12:26:03 +00:00
|
|
|
|
if(LAST != &M_MAINMENU)
|
|
|
|
|
{
|
|
|
|
|
LAST = &M_MAINMENU;
|
2022-06-05 13:03:15 +00:00
|
|
|
|
drawMAINMENU(local[0]);
|
2022-06-05 12:26:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-05 13:03:15 +00:00
|
|
|
|
if(opr == right)
|
|
|
|
|
{
|
|
|
|
|
local[0]++;
|
|
|
|
|
if(local[0] > 3)
|
|
|
|
|
local[0] = 3;
|
2022-06-05 13:19:35 +00:00
|
|
|
|
|
|
|
|
|
opr = idle;
|
|
|
|
|
drawMAINMENU(local[0]);
|
2022-06-05 13:03:15 +00:00
|
|
|
|
}
|
2022-06-05 12:26:03 +00:00
|
|
|
|
if(opr == left)
|
|
|
|
|
{
|
2022-06-05 13:03:15 +00:00
|
|
|
|
if(local[0] != 0)
|
|
|
|
|
local[0]--;
|
2022-06-05 13:19:35 +00:00
|
|
|
|
|
|
|
|
|
opr = idle;
|
|
|
|
|
drawMAINMENU(local[0]);
|
2022-06-05 13:03:15 +00:00
|
|
|
|
}
|
2022-06-05 13:19:35 +00:00
|
|
|
|
if(opr == confirm)
|
2022-06-05 13:03:15 +00:00
|
|
|
|
{
|
2022-06-05 13:19:35 +00:00
|
|
|
|
|
|
|
|
|
switch(local[0])
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2022-06-05 15:35:53 +00:00
|
|
|
|
return;
|
2022-06-05 13:19:35 +00:00
|
|
|
|
case 1:
|
|
|
|
|
NOW = &M_BLOCK; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
NOW = &M_BALL; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
NOW = &M_STARTUP; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local[0]=0;
|
|
|
|
|
clear();
|
2022-06-05 12:26:03 +00:00
|
|
|
|
opr = idle;
|
|
|
|
|
}
|
2022-05-19 13:07:52 +00:00
|
|
|
|
}
|
2022-06-05 12:26:03 +00:00
|
|
|
|
|
2022-05-19 13:07:52 +00:00
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
void m_block(struct _menu* this)
|
|
|
|
|
{
|
2022-06-05 15:35:53 +00:00
|
|
|
|
if(LAST != &M_BLOCK)
|
2022-06-05 13:19:35 +00:00
|
|
|
|
{
|
2022-06-05 15:35:53 +00:00
|
|
|
|
LAST = &M_BLOCK;
|
2022-06-06 06:48:59 +00:00
|
|
|
|
drawVerticalDottedLine(64);
|
2022-06-05 15:35:53 +00:00
|
|
|
|
blockInit();
|
2022-06-05 13:19:35 +00:00
|
|
|
|
}
|
2022-06-06 06:27:04 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
2022-06-06 05:41:14 +00:00
|
|
|
|
if(opr == confirm)
|
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
blockDestroy();
|
|
|
|
|
drawBlock();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-06 06:27:04 +00:00
|
|
|
|
if(opr == left)
|
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
moveLeftPiece();
|
|
|
|
|
drawBlock();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(opr == right)
|
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
moveRightPiece();
|
|
|
|
|
drawBlock();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-06 05:41:14 +00:00
|
|
|
|
|
|
|
|
|
genPiece();
|
2022-06-05 15:35:53 +00:00
|
|
|
|
dropPiece();
|
|
|
|
|
drawBlock();
|
|
|
|
|
delay(200);
|
2022-06-06 05:41:14 +00:00
|
|
|
|
|
2022-06-05 15:35:53 +00:00
|
|
|
|
|
2022-06-05 13:19:35 +00:00
|
|
|
|
}
|
2022-05-19 13:07:52 +00:00
|
|
|
|
void menuInit()
|
|
|
|
|
{
|
2022-06-05 12:26:03 +00:00
|
|
|
|
M_STARTUP.n = &M_MAINMENU;
|
|
|
|
|
M_STARTUP.f = m_startup;
|
|
|
|
|
|
|
|
|
|
M_MAINMENU.f = m_mainmenu;
|
2022-06-05 15:35:53 +00:00
|
|
|
|
M_BLOCK.f = m_block;
|
|
|
|
|
|
2022-06-06 05:55:35 +00:00
|
|
|
|
#ifdef DEBUG_MODE
|
|
|
|
|
NOW = &M_DEBUG;
|
|
|
|
|
#else
|
2022-06-05 12:26:03 +00:00
|
|
|
|
NOW = &M_STARTUP;
|
2022-06-06 05:55:35 +00:00
|
|
|
|
#endif
|
2022-05-19 13:07:52 +00:00
|
|
|
|
}
|