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-07 15:51:01 +00:00
|
|
|
|
#include <absacc.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>
|
2022-06-06 11:05:34 +00:00
|
|
|
|
//#define DEBUG_MODE
|
2022-06-06 05:55:35 +00:00
|
|
|
|
|
|
|
|
|
#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>
|
2022-06-06 12:52:06 +00:00
|
|
|
|
Menu M_BEST; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
Menu M_ABOUT; //<2F><><EFBFBD><EFBFBD>
|
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-07 15:51:01 +00:00
|
|
|
|
code unsigned int ver _at_ 0x7ffe;
|
2022-06-05 13:19:35 +00:00
|
|
|
|
enum OPR opr = idle;
|
2022-06-07 06:25:11 +00:00
|
|
|
|
static unsigned char local[2] = {0};
|
2022-06-06 14:57:48 +00:00
|
|
|
|
unsigned int score;
|
2022-06-07 13:45:23 +00:00
|
|
|
|
unsigned int bestScore[10];
|
2022-06-06 11:05:34 +00:00
|
|
|
|
extern enum GS blockGameStatus;
|
2022-06-05 12:26:03 +00:00
|
|
|
|
|
|
|
|
|
|
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-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
if(!local[1])
|
|
|
|
|
{
|
|
|
|
|
local[1] = 1;
|
|
|
|
|
drawVER(90, 4);
|
|
|
|
|
drawSUPNUM(80, 6, ver / 10000); //<2F><><EFBFBD>ư汾
|
|
|
|
|
drawSUPNUM(89, 6, (ver % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(98, 6, (ver % 1000) / 100);
|
|
|
|
|
drawSUPNUM(107, 6, (ver % 100) / 10);
|
|
|
|
|
drawSUPNUM(116, 6, ver % 10);
|
|
|
|
|
delayms(1000);
|
|
|
|
|
drawVOID8(90, 4, 32);
|
|
|
|
|
drawVOID8(80, 6, 46);
|
|
|
|
|
}
|
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-07 15:51:01 +00:00
|
|
|
|
if(local[0] > 1)
|
2022-06-05 13:03:15 +00:00
|
|
|
|
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:
|
2022-06-06 12:52:06 +00:00
|
|
|
|
NOW = &M_BEST; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
2022-06-05 13:19:35 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2022-06-06 11:36:45 +00:00
|
|
|
|
NOW = &M_ABOUT; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
2022-06-05 13:19:35 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-06 09:01:36 +00:00
|
|
|
|
|
|
|
|
|
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-06 09:01:36 +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 09:01:36 +00:00
|
|
|
|
drawVerticalDottedLine(64);
|
|
|
|
|
drawBLOCKSCORE();
|
|
|
|
|
blockInit();
|
2022-06-05 13:19:35 +00:00
|
|
|
|
}
|
2022-06-06 09:01:36 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
2022-06-06 05:41:14 +00:00
|
|
|
|
if(opr == confirm)
|
|
|
|
|
{
|
2022-06-06 09:01:36 +00:00
|
|
|
|
opr = idle;
|
|
|
|
|
blockDestroy();
|
2022-06-07 06:25:11 +00:00
|
|
|
|
NOW = &M_MAINMENU;
|
|
|
|
|
clear();
|
2022-06-06 09:01:36 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(opr == left)
|
2022-06-06 06:27:04 +00:00
|
|
|
|
{
|
2022-06-06 09:01:36 +00:00
|
|
|
|
opr = idle;
|
|
|
|
|
moveLeftPiece();
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawBlock();
|
|
|
|
|
return;
|
2022-06-06 09:01:36 +00:00
|
|
|
|
}
|
|
|
|
|
if(opr == right)
|
2022-06-06 06:27:04 +00:00
|
|
|
|
{
|
2022-06-06 09:01:36 +00:00
|
|
|
|
opr = idle;
|
|
|
|
|
moveRightPiece();
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawBlock();
|
|
|
|
|
return;
|
2022-06-06 09:01:36 +00:00
|
|
|
|
}
|
2022-06-06 11:05:34 +00:00
|
|
|
|
switch(blockGameStatus)
|
|
|
|
|
{
|
|
|
|
|
case good:
|
2022-06-06 12:52:06 +00:00
|
|
|
|
drawGOOD(70, 4);
|
2022-06-07 06:25:11 +00:00
|
|
|
|
blockGameStatus = start;
|
2022-06-06 11:05:34 +00:00
|
|
|
|
break;
|
|
|
|
|
case over:
|
2022-06-06 12:52:06 +00:00
|
|
|
|
drawGAME(70, 4);
|
|
|
|
|
drawOVER(70, 6);
|
2022-06-06 11:05:34 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2022-06-06 12:52:06 +00:00
|
|
|
|
drawVOID8(70, 4, 40);
|
|
|
|
|
drawVOID8(70, 6, 32);
|
2022-06-06 11:05:34 +00:00
|
|
|
|
}
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(70, 2, score / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|
|
|
|
drawSUPNUM(79, 2, (score % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(88, 2, (score % 1000) / 100);
|
|
|
|
|
drawSUPNUM(97, 2, (score % 100) / 10);
|
|
|
|
|
drawSUPNUM(106, 2, score % 10);
|
|
|
|
|
blockGameOver(); //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
2022-06-06 12:52:06 +00:00
|
|
|
|
genPiece(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
|
|
|
|
|
dropPiece(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
judgeBlock(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
drawBlock(); //<2F><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
|
2022-06-06 11:52:51 +00:00
|
|
|
|
delayms(400);
|
2022-06-06 09:01:36 +00:00
|
|
|
|
|
2022-06-06 11:36:45 +00:00
|
|
|
|
}
|
2022-06-06 09:01:36 +00:00
|
|
|
|
|
2022-06-06 11:36:45 +00:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ҳ
|
|
|
|
|
void m_about(struct _menu* this)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(LAST != &M_ABOUT)
|
|
|
|
|
{
|
|
|
|
|
LAST = &M_ABOUT;
|
2022-06-07 06:25:11 +00:00
|
|
|
|
delayms(2000);
|
2022-06-06 11:36:45 +00:00
|
|
|
|
drawNAME(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-06-06 11:52:51 +00:00
|
|
|
|
delayms(2000);
|
2022-06-06 11:36:45 +00:00
|
|
|
|
drawNUMBER(); //<2F><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>
|
2022-06-07 15:51:01 +00:00
|
|
|
|
delayms(3000);
|
|
|
|
|
|
|
|
|
|
drawVER(5, 4);
|
|
|
|
|
drawSUPNUM(2, 6, ver / 10000); //<2F><><EFBFBD>ư汾
|
|
|
|
|
drawSUPNUM(11, 6, (ver % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(20, 6, (ver % 1000) / 100);
|
|
|
|
|
drawSUPNUM(29, 6, (ver % 100) / 10);
|
|
|
|
|
drawSUPNUM(38, 6, ver % 10);
|
2022-06-06 11:36:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(opr == confirm)
|
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
NOW = &M_MAINMENU; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
clear();
|
|
|
|
|
}
|
2022-06-05 13:19:35 +00:00
|
|
|
|
}
|
2022-06-06 11:36:45 +00:00
|
|
|
|
|
2022-06-07 06:25:11 +00:00
|
|
|
|
//<2F><>¼ҳ
|
|
|
|
|
void m_best(struct _menu* this)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(LAST != &M_BEST)
|
|
|
|
|
{
|
|
|
|
|
LAST = &M_BEST;
|
2022-06-07 13:45:23 +00:00
|
|
|
|
drawBEST(2, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(2, 2, bestScore[0] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|
|
|
|
drawSUPNUM(11, 2, (bestScore[0] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(20, 2, (bestScore[0] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(29, 2, (bestScore[0] % 100) / 10);
|
|
|
|
|
drawSUPNUM(38, 2, bestScore[0] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(2, 4, bestScore[1] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(11, 4, (bestScore[1] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(20, 4, (bestScore[1] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(29, 4, (bestScore[1] % 100) / 10);
|
|
|
|
|
drawSUPNUM(38, 4, bestScore[1] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(2, 6, bestScore[2] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(11, 6, (bestScore[2] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(20, 6, (bestScore[2] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(29, 6, (bestScore[2] % 100) / 10);
|
|
|
|
|
drawSUPNUM(38, 6, bestScore[2] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(72, 0, bestScore[3] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(81, 0, (bestScore[3] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(90, 0, (bestScore[3] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(99, 0, (bestScore[3] % 100) / 10);
|
|
|
|
|
drawSUPNUM(108, 0, bestScore[3] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(72, 2, bestScore[4] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(81, 2, (bestScore[4] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(90, 2, (bestScore[4] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(99, 2, (bestScore[4] % 100) / 10);
|
|
|
|
|
drawSUPNUM(108, 2, bestScore[4] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(72, 4, bestScore[5] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(81, 4, (bestScore[5] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(90, 4, (bestScore[5] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(99, 4, (bestScore[5] % 100) / 10);
|
|
|
|
|
drawSUPNUM(108, 4, bestScore[5] % 10);
|
2022-06-07 15:51:01 +00:00
|
|
|
|
|
|
|
|
|
drawSUPNUM(72, 6, bestScore[6] / 10000); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
2022-06-07 06:25:11 +00:00
|
|
|
|
drawSUPNUM(81, 6, (bestScore[6] % 10000) / 1000);
|
|
|
|
|
drawSUPNUM(90, 6, (bestScore[6] % 1000) / 100);
|
|
|
|
|
drawSUPNUM(99, 6, (bestScore[6] % 100) / 10);
|
|
|
|
|
drawSUPNUM(108, 6, bestScore[6] % 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(opr == confirm)
|
|
|
|
|
{
|
|
|
|
|
opr = idle;
|
|
|
|
|
NOW = &M_MAINMENU; //ת<><D7AA><EFBFBD><EFBFBD>һ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-19 13:07:52 +00:00
|
|
|
|
void menuInit()
|
|
|
|
|
{
|
2022-06-05 12:26:03 +00:00
|
|
|
|
M_MAINMENU.f = m_mainmenu;
|
2022-06-06 09:01:36 +00:00
|
|
|
|
M_BLOCK.f = m_block;
|
2022-06-07 06:25:11 +00:00
|
|
|
|
M_ABOUT.f = m_about;
|
|
|
|
|
M_BEST.f = m_best;
|
2022-06-06 09:01:36 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_MODE
|
|
|
|
|
NOW = &M_DEBUG;
|
|
|
|
|
#else
|
2022-06-06 11:36:45 +00:00
|
|
|
|
NOW = &M_MAINMENU;
|
2022-06-06 09:01:36 +00:00
|
|
|
|
#endif
|
2022-05-19 13:07:52 +00:00
|
|
|
|
}
|