⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 s3c44b0上边的各个功能实现 ADS1.2
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			main.c
** Last modified Date:  2004-09-16
** Last Version:		1.0
** Descriptions:		The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by:			Chenmingji
** Created date:		2004-09-16
** Version:				1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#include "stdlib.h"
#include <math.h>
#define   LEFT  	1
#define   RIGHT 	2
#define   DOWN  	3
#define   UP    	4
#define   ESC   	5
#define   N 		30

#define LED1 	    (1<<22)			//灯的定义
#define LED2 	    (1<<29)
#define LED3 	    (1<<30)
#define KEY_UP      (1<<24)			//按键的定义
#define KEY_DOWN    (1<<28)
#define KEY_LIFT    (1<<23)
#define KEY_RIGHT   (1<<25)
#define	TaskStkLengh	130		//Define the Task0 stack length 定义用户任务0的堆栈长度
#define  TASK_STK_SIZE  100
OS_STK	TaskStk[TaskStkLengh];		//Define the Task0 stack 定义用户任务0的堆栈
OS_STK  TaskLed1Stk[TASK_STK_SIZE];
OS_STK 	TaskLed2Stk[TASK_STK_SIZE];
OS_STK 	TaskLed3Stk[TASK_STK_SIZE];
void 	Task0(void *pdata);			//Task0 任务0
static void  TaskLed1(void *data);
static void  TaskLed2(void *data);
static void  TaskLed3(void *data);
void    PrintScore(uint32 x, uint32 y, uint32 data);
void  	DrawBeanSnake(uint32 x, uint32 y);
void    ClearSnake(uint32 x, uint32 y);
void 	IniGamePicture(void);
void 	GameOver(void);
void 	GamePlay(void);



/* @tan 贪(16x16,V)@ [suki software]*/
uint8 const tan0[]=
{
0x01,0x00,0x02,0x80,0x04,0x40,0x0A,0x30,0x31,0x0E,0xCF,0xE4,0x00,0x40,0x1F,0xF0,
0x10,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x12,0x90,0x04,0x60,0x08,0x30,0x30,0x10,
};

uint8 const chi0[]=
{
/* @chi0 吃(16x16,V)@ [suki software]*/
0x01,0x00,0x01,0x80,0x79,0x00,0x4B,0xFE,0x4A,0x00,0x4C,0x00,0x4B,0xF0,0x48,0x10,
0x48,0x20,0x78,0x40,0x48,0x80,0x41,0x00,0x02,0x02,0x02,0x02,0x01,0xFE,0x00,0x00,
};

uint8 const she0[]=
{
/* @she0 蛇(16x16,V)@ [suki software]*/
0x10,0x40,0x10,0x30,0x10,0x20,0x11,0xFE,0x7D,0x04,0x56,0x88,0x54,0x80,0x54,0x88,
0x7C,0xB0,0x54,0xC0,0x10,0x80,0x14,0x84,0x1E,0x84,0xE4,0x84,0x00,0x78,0x00,0x00, 
};

/* @you0 游(16x16,V)@ [suki software]*/
unsigned char you0[]={
0x44,0x20,0x22,0x20,0x22,0x20,0x0F,0xBE,0x84,0x40,0x54,0xBC,0x57,0x08,0x25,0x10,
0x25,0x10,0x25,0x7E,0xC5,0x10,0x49,0x10,0x49,0x10,0x49,0x10,0x55,0x50,0x42,0x20
};
/* @xi0 戏(16x16,V)@ [suki software]*/
unsigned char xi0[]={
0x00,0x40,0x00,0x50,0x7E,0x48,0x02,0x48,0x44,0x40,0x25,0xFE,0x18,0x40,0x08,0x44,
0x0C,0x28,0x14,0x30,0x12,0x20,0x22,0x50,0x41,0x92,0x06,0x0A,0x00,0x06,0x00,0x02
};
/* @jie0 结(16x16,V)@ [suki software]*/
unsigned char jie0[]={
0x10,0x20,0x10,0x20,0x20,0x20,0x23,0xFE,0x48,0x20,0xF0,0x20,0x11,0xFC,0x20,0x00,
0x40,0x00,0xF9,0xFC,0x01,0x04,0x01,0x04,0x19,0x04,0xE1,0xFC,0x01,0x04,0x00,0x00,
};
/* @shu0 束(16x16,V)@ [suki software]*/
unsigned char shu0[]={
0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,
0x23,0x08,0x05,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,
};
/* @tui0 退(16x16,V)@ [suki software]*/
unsigned char tui0[]={
0x40,0x00,0x27,0xF0,0x24,0x10,0x07,0xF0,0x04,0x10,0x04,0x10,0xE7,0xF0,0x24,0x88,
0x24,0x50,0x24,0x20,0x25,0x10,0x26,0x18,0x24,0x08,0x50,0x00,0x8F,0xFE,0x00,0x00,
};

/* @chu0 出(16x16,V)@ [suki software]*/
unsigned char chu0[]={
0x01,0x00,0x01,0x00,0x21,0x04,0x21,0x04,0x21,0x04,0x21,0x04,0x3F,0xFC,0x21,0x04,
0x01,0x00,0x21,0x04,0x21,0x04,0x21,0x04,0x21,0x04,0x3F,0xFC,0x20,0x04,0x00,0x00,
};
/* @kai0 开(16x16,V)@ [suki software]*/
unsigned char kai0[]={
0x00,0x00,0x7F,0xFE,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0xFF,0xFE,0x04,0x20,
0x04,0x20,0x04,0x20,0x08,0x20,0x08,0x20,0x10,0x20,0x20,0x20,0x40,0x20,0x00,0x00,
};
/* @shi0 始(16x16,V)@ [suki software]*/
unsigned char shi3[]={
0x10,0x20,0x18,0x30,0x10,0x20,0x10,0x48,0xFC,0x84,0x25,0xFE,0x24,0x84,0x44,0x00,
0x44,0xFC,0x28,0x84,0x18,0x84,0x14,0x84,0x22,0x84,0x42,0xFC,0x80,0x84,0x00,0x00,
};
/* @de0 得(16x16,V)@ [suki software]*/
unsigned char de0[]={
0x13,0xF8,0x1A,0x08,0x23,0xF8,0x4A,0x08,0x8B,0xF8,0x10,0x00,0x13,0xFE,0x30,0x10,
0x50,0x10,0x97,0xFE,0x10,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x10,0x50,0x10,0x20,
};
/* @fen0 分(16x16,V)@ [suki software]*/
unsigned char fen0[]={
0x08,0x80,0x0C,0x80,0x08,0x40,0x10,0x20,0x10,0x30,0x20,0x18,0x40,0x0E,0x9F,0xE4,
0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x08,0x20,0x10,0xA0,0x20,0x40,0x40,0x00,
};
/* @she0 设(16x16,V)@ [suki software]*/
unsigned char she4[]={
0x40,0x00,0x21,0xF0,0x31,0x10,0x21,0x10,0x01,0x10,0x01,0x10,0xE2,0x0E,0x25,0xF8,
0x21,0x08,0x21,0x08,0x20,0x90,0x20,0x90,0x28,0x60,0x30,0x90,0x23,0x0E,0x0C,0x04,
};
/* @ji0 计(16x16,V)@ [suki software]*/
unsigned char ji0[]={
0x40,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x00,0x20,0xF3,0xFE,0x10,0x20,0x10,0x20,
0x10,0x20,0x10,0x20,0x10,0x20,0x12,0x20,0x14,0x20,0x18,0x20,0x10,0x20,0x00,0x20,
};
/* @zhe0 者(16x16,V)@ [suki software]*/
unsigned char zhe0[]={
0x01,0x00,0x01,0x08,0x3F,0xEC,0x01,0x10,0x01,0x20,0x7F,0xFE,0x00,0x80,0x03,0x00,
0x07,0xF8,0x1C,0x08,0xE4,0x08,0x07,0xF8,0x04,0x08,0x04,0x08,0x07,0xF8,0x04,0x08,
};
/* @zhou0 周(16x16,V)@ [suki software]*/
unsigned char zhou0[]={
0x00,0x00,0x1F,0xFC,0x10,0x84,0x13,0xE4,0x10,0x84,0x10,0x84,0x17,0xF4,0x10,0x04,
0x13,0xE4,0x12,0x24,0x12,0x24,0x13,0xE4,0x22,0x24,0x20,0x04,0x40,0x14,0x80,0x08,
};
/* @yi0 义(16x16,V)@ [suki software]*/
unsigned char yi0[]={
0x00,0x00,0x04,0x20,0x22,0x30,0x21,0x20,0x11,0x20,0x10,0x40,0x08,0x40,0x04,0x80,
0x02,0x80,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x30,0x30,0x0E,0xC0,0x04,0x00,0x00,
};
/* @huang0 黄(16x16,V)@ [suki software]*/
unsigned char huang0[]={
0x04,0x40,0x04,0x40,0x7F,0xFC,0x04,0x40,0x04,0x40,0xFF,0xFE,0x01,0x00,0x1F,0xF0,
0x11,0x10,0x1F,0xF0,0x11,0x10,0x11,0x10,0x1F,0xF0,0x08,0x20,0x10,0x18,0x60,0x08,
};
/* @shi0 石(16x16,V)@ [suki software]*/
unsigned char shi0[]={
0x00,0x00,0xFF,0xFE,0x02,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x07,0xF8,0x0C,0x08,
0x0C,0x08,0x14,0x08,0x24,0x08,0x44,0x08,0x84,0x08,0x07,0xF8,0x04,0x08,0x00,0x00,
};
/* @li0 理(16x16,V)@ [suki software]*/
unsigned char li0[]={
0x00,0x00,0x03,0xFC,0xFA,0x44,0x22,0x44,0x23,0xFC,0x22,0x44,0xFA,0x44,0x23,0xFC,
0x22,0x44,0x20,0x40,0x23,0xFC,0x38,0x40,0xC0,0x40,0x00,0x40,0x0F,0xFE,0x00,0x00,
};
/* @gong0 工(16x16,V)@ [suki software]*/
unsigned char gong0[]={
0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,
};
/* @xue0 学(16x16,V)@ [suki software]*/
unsigned char xue0[]={
0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0xE8,0x00,0x40,
0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x02,0x80,0x01,0x00,
};
/* @yuan0 院(16x16,V)@ [suki software]*/
unsigned char yuan0[]={
0x00,0x80,0xF8,0x40,0x8F,0xFE,0x94,0x04,0xA0,0x00,0xA3,0xF8,0x90,0x00,0x88,0x00,
0x8F,0xFE,0xA9,0x20,0x91,0x20,0x81,0x20,0x82,0x22,0x82,0x22,0x84,0x22,0x88,0x1E,
};


unsigned char BeanLocate[][2]={{3,2},

};

struct Snake
{	
	uint32 x[N];
	uint32 y[N];
	uint32 node;
	uint32 direction;
	uint32 life;
}snake;

struct Food
{
	uint32 x;
	uint32 y;
	uint32 yes;
}food;

typedef struct
{
	uint32 Message;
	uint32 WParam;
	uint32 LParam;
}OSMSG,*POSMSG;	
	

uint32 GameSpeed = 10;
uint32 score	 = 0 ;





/****************************************************************************
* 名称:DrawBeanSnake()
* 功能:贪吃蛇专用,蛇和屏幕的位置坐标范围为(0,0)到(110/5=21,60/5=11)
*		画蛇和豆子
* 入口参数:x		蛇的x坐标值
*           y		蛇的y坐标值
* 出口参数:无
* 说明:操作失败原因是指定地址超出有效范围。
****************************************************************************/
void  DrawBeanSnake(uint32 x, uint32 y)
{  
	uint32 x0, y0, x1, y1;
    x0=x*6+1;	//偏移一个1为偏移的边框线,乘5是一个蛇节象素的大小
    y0=y*6+1;
    x1=x*6+6;
    y1=y*6+6;
	GUI_HLine(x0, y0, x1, 1);
    GUI_HLine(x0, y1, x1, 1);
    GUI_RLine(x0, y0, y1, 1);
    GUI_RLine(x1, y0, y1, 1);
}


/****************************************************************************
* 名称:ClearSnake()
* 功能:贪吃蛇专用 蛇和屏幕的位置坐标范围为(0,0)到(110/5-21/5=17,60/5-11/5=9)
*		清除蛇的尾部
* 入口参数:x		蛇的x坐标值
*           y		蛇的y坐标值
*
* 出口参数:无
* 说明:
****************************************************************************/
void  ClearSnake(uint32 x, uint32 y)
{  
    uint32 x0, y0, x1, y1;
    x0=x*6+1;	//偏移一个1为偏移的边框线,乘5是一个蛇节象素的大小
    y0=y*6+1;
    x1=x*6+6;
    y1=y*6+6;
    GUI_HLine(x0, y0, x1-1, 0);		//减1为防止把前面蛇的一个边框点给清掉
	GUI_HLine(x0, y1, x1-1, 0);
    GUI_RLine(x0, y0, y1,   0);
    GUI_RLine(x1, y0, y1, 0);
}

/****************************************************************************
* 名称:GameOvere()
* 功能:游戏结束时清屏,并显示"游戏结束"
*		
* 入口参数:无
* 出口参数:无
* 说明:无
****************************************************************************/
void GameOver(void)
{
	GUI_FillSCR(0x00);
	GUI_PutHZ(32, 25,       (uint8 *)you0, 16, 16);		//中间显示"游戏结束"
    GUI_PutHZ(32+16, 25,    (uint8 *)xi0,  16, 16);
    GUI_PutHZ(32+16+16, 25, (uint8 *)jie0, 16, 16);
    GUI_PutHZ(32+16+16+16, 25, (uint8 *)shu0, 16, 16);
}

/****************************************************************************
* 名称:PrintScore()
* 功能:在坐标(x,y)的屏幕上显示一个数
*		
* 入口参数:x		数的x坐标值
*           y		数的y坐标值
*			data	要显示的数
* 出口参数:无
* 说明:数的大小不能超过100
****************************************************************************/
void PrintScore(uint32 x, uint32 y, uint32 data)
{
	uint32 i,j,x0,y0;
	x0=x;
	y0=y;
	i=data/10;
	j=data%10;
	switch(i)
		{
		 //case 0:GUI_PutChar8_8(125-12, 54, '0');break;
		 case 0:GUI_PutChar8_8(x0, y0, '0');break;
		 case 1:GUI_PutChar8_8(x0, y0, '1');break;
		 case 2:GUI_PutChar8_8(x0, y0, '2');break;
		 case 3:GUI_PutChar8_8(x0, y0, '3');break;
		 case 4:GUI_PutChar8_8(x0, y0, '4');break;
		 case 5:GUI_PutChar8_8(x0, y0, '5');break;
		 case 6:GUI_PutChar8_8(x0, y0, '6');break;
		 case 7:GUI_PutChar8_8(x0, y0, '7');break;
		 case 8:GUI_PutChar8_8(x0, y0, '8');break;
		 case 9:GUI_PutChar8_8(x0, y0, '9');break;
		} 
	switch(j)
		{
		 //case 0:GUI_PutChar8_8(125-5, 54, '0');break;
		 case 0:GUI_PutChar8_8(x0+8, y0, '0');break;
		 case 1:GUI_PutChar8_8(x0+8, y0, '1');break;
		 case 2:GUI_PutChar8_8(x0+8, y0, '2');break;
		 case 3:GUI_PutChar8_8(x0+8, y0, '3');break;
		 case 4:GUI_PutChar8_8(x0+8, y0, '4');break;
		 case 5:GUI_PutChar8_8(x0+8, y0, '5');break;
		 case 6:GUI_PutChar8_8(x0+8, y0, '6');break;
		 case 7:GUI_PutChar8_8(x0+8, y0, '7');break;
		 case 8:GUI_PutChar8_8(x0+8, y0, '8');break;
		 case 9:GUI_PutChar8_8(x0+8, y0, '9');break;
		} 	
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -