#include"..\ucos-ii\includes.h" /* uC/OS interface *
#include "..\ucos-ii\add\osaddition.h"
#include "..\inc\drv.h"
#include "..\INC\DRV\zlg7289.h"
#include
#include
#include
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
extern int Zlg7289SIOBand;
extern int Zlg7289SIOCtrl;
///******************任务定义***************///
OS_STK Main_Stack[STACKSIZE*8]={0, }; //Main_Test_Task堆栈
void Main_Task(void *Id); //Main_Test_Task
#define Main_Task_Prio 12
/**************已经定义的OS任务*************
tcp监控任务 11
以太网物理层监控任务 8
触摸屏任务 9
键盘任务 10
lcd刷新任务 59
系统任务 1
*****************************************************/
OS_STK Time_Stack[STACKSIZE*8]={0, }; //Time_Tsk堆栈
void Time_Task(void *Id); //Time_Task
#define Time_Task_Prio 13
OS_STK Uart_Stack[STACKSIZE*8]={0, }; //Uart_Task堆栈
void Uart_Task(void *Id); //Uart_Task
#define Uart_Task_Prio 14
#define OSM_TIME 4 //定时器消息
/*重画界面命令*/
#define OSM_DRAW 5
/*消去一个满行的命令*/
#define OSM_DELLINE 6
/*自动下移一行的命令*/
#define OSM_AOTODOWN 7
/*生产新的方块*/
#define OSM_GEN 8
/*向左移动的命令,以键盘上的7来控制*/
#define LEFTMOVE 11
/*向右移动的命令,以键盘上的9来控制*/
#define RINGHTMOVE 13
/*旋转方块的命令,以键盘上的5来控制*/
#define ROTATE 9
/*向下加速的命令,以键盘上的8来控制*/
#define DOWNMOVE 12
/*更新分数*/
#define OSM_SCORE 13
/*提示下一个方块*/
#define OSM_NEXT 14
/*串口消息*/
#define OSM_UART 15
/*下面定义了显示区域的位置*/
#define AREALEFT -125
#define AREATOP -100
#define AREARIGHT -25
#define AREABOTTOM 100
/*下面定义了显示下一个方块的位置*/
#define NEXTLEFT 50
#define NEXTTOP -100
#define NEXTRIGHT 90
#define NEXTBOTTOM -60
/*下面定义了显示区域的大小 10*20*/
#define MAXHEIGHT 20
#define MAXWIDTH 10
/*颜色*/
#define RED 0x00ff0000
#define GREEN 0x0000ff00
#define BLUE 0x000000ff
#define COLORNUM 3
U32 color[COLORNUM]={RED,GREEN,BLUE};
/*定义七种基本的方块形状*/
#define SHAPENUM 19
U16 BASICBOX[SHAPENUM][4][4]={
{{1,1,1,1},{0,0,0,0},{0,0,0,0},{0,0,0,0}},
{{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0}},
{{1,1,1,0},{1,0,0,0},{0,0,0,0},{0,0,0,0}},
{{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}},
{{1,1,0,0},{0,1,0,0},{0,1,0,0},{0,0,0,0}},
{{0,0,1,0},{1,1,1,0},{0,0,0,0},{0,0,0,0}},
{{1,1,1,0},{0,0,1,0},{0,0,0,0},{0,0,0,0}},
{{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}},
{{1,1,0,0},{1,0,0,0},{1,0,0,0},{0,0,0,0}},
{{1,0,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
{{1,1,1,0},{0,1,0,0},{0,0,0,0},{0,0,0,0}},
{{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
{{1,0,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
{{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
{{1,1,0,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}},
{{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
{{0,1,1,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}},
{{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
{{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}}
};
///*****************事件定义*****************///
OS_EVENT *Nand_Rw_Sem; //Nand_Flash读写控制权旗语
//and you can use it as folloeing:
// Nand_Rw_Sem=OSSemCreate(1); //创建Nand-Flash读写控制权旗语,初值为1满足互斥条件//
// OSSemPend(Nand_Rw_Sem,0,&err);
// OSSemPost(Nand_Rw_Sem);
OS_EVENT *Uart_Rw_Sem; //Uart读写控制权旗语
//and you can use it as folloeing:
// Uart_Rw_Sem=OSSemCreate(1); //创建Uart读写控制权旗语,初值为1满足互斥条件//
// OSSemPend(Uart_Rw_Sem,0,&err);
// OSSemPost(Uart_Rw_Sem);
//////////////////////////////////////////////////////////
int oldarea[MAXHEIGHT][MAXWIDTH];
int area[MAXHEIGHT][MAXWIDTH];
/*存储当前方块的数组*/
int box[4][4];
/*当前方块的位置*/
int curX;
int curY;
int curW;
int curH;
/*方块当前的状态*/
int active;
/*方块的新位置*/
int newX;
int newY;
int newW;
int newH;
/*需要改变的屏幕区域*/
int actX;
int actY;
int actW;
int actH;
/*分数*/
int score;
/*当前的方块*/
int curID;
/*下一个方块*/
int nextID;
/*当前方框的颜色*/
int curColor;
/*下一个方框的颜色*/
int nextColor;
/*得到方块的宽度,即从右向左第一个不空的列*/
int GetWidth()
{
int i,j;
for(i=3;i>0;i--)
{
for(j=0;j<4;j++)
{
if(box[j])
return i;
}
}
return 0;
}
/*得到方块的高度,从上往下第一个不空的行*/
int GetHeight()
{
U16 i,j;
for(j=3;j>0;j--)
{
for(i=0;i<4;i++)
{
if(box[j])
return j;
}
}
return 0;
}
|