admin 管理员组

文章数量: 1086019


2024年4月29日发(作者:xshell命令大全详解)

#include

#include

#include

#include

#include

#include

#include

/*定义左上角点在屏幕上的位置*/

#define MAPXOFT 9

#define MAPYOFT 5

/*定义下一个方块显示的位置*/

#define MAPXOFT1 13

#define MAPYOFT1 -2

#define LEFT 0x4b00

#define RIGHT 0x4d00

#define DOWN 0x5000 /*此键为加速键*/

#define UP 0x4800 /*此键为变形键*/

#define ESC 0x011b /*此键为退出键*/

#define ENTER 0x1c0d

#define TIMER 0x1c /* 时钟中断的中断号 */

/* 中断处理函数在C和C++中的表示略有不同。

如果定义了_cplusplus则表示在C++环境下,否则是在C环境下。 */

#ifdef __cplusplus

#define __CPPARGS ...

#else

#define __CPPARGS

#endif

int TimerCounter=0; /* 计时变量,每秒钟增加18。 */

/* 指向原来时钟中断处理过程入口的中断处理函数指针(句柄) */

void interrupt ( *oldhandler)(__CPPARGS);

/* 新的时钟中断处理函数 */

void interrupt newhandler(__CPPARGS)

{

/* increase the global counter */

TimerCounter++;

/* call the old routine */

oldhandler();

}

/* 设置新的时钟中断处理过程 */

void SetTimer(void interrupt (*IntProc)(__CPPARGS))

{

oldhandler=getvect(TIMER);

disable(); /* 设置新的时钟中断处理过程时,禁止所有中断 */

setvect(TIMER,IntProc);

enable(); /* 开启中断 */

}

/* 恢复原有的时钟中断处理过程 */

void KillTimer()

{

disable();

setvect(TIMER,oldhandler);

enable();

}

struct shape

{

int xy[8],next;

};

struct shape shapes[19]=

{

/*x1,y1,x2,y2,x3,y3,x4,y4 指四个小方块的相对坐标,next指此方块变形后应变为哪个小方块

{ x1,y1,x2,y2,x3,y3,x4,y4,next}*/

{ 0,-2, 0,-1, 0, 0, 1, 0, 1},

{-1, 0, 0, 0, 1,-1, 1, 0, 2},

{ 0,-2, 1,-2, 1,-1, 1, 0, 3},

{-1,-1,-1, 0, 0,-1, 1,-1, 0},

{ 0,-2, 0,-1, 0, 0, 1,-2, 5},

{-1,-1, 0,-1, 1,-1, 1, 0, 6},

{ 0, 0, 1,-2, 1,-1, 1, 0, 7},

{-1,-1,-1, 0, 0, 0, 1, 0, 4},

{-1, 0, 0,-1, 0, 0, 1, 0, 9},

{ 0,-2, 0,-1, 0, 0, 1,-1,10},

{-1,-1, 0,-1, 1,-1, 0, 0,11},

{ 0,-1, 1,-2, 1,-1, 1, 0, 8},

{-1, 0, 0,-1, 0, 0, 1,-1,13},

{ 0,-2, 0,-1, 1,-1, 1, 0,12},

{-1,-1, 0,-1, 0, 0, 1, 0,15},

{ 0,-1, 0, 0, 1,-2, 1,-1,14},

{ 0,-3, 0,-2, 0,-1, 0, 0,17},

{-1, 0, 0, 0, 1, 0, 2, 0,16},

{ 0,-1, 0, 0, 1,-1, 1, 0,18}

};

int board[10][20]={0};/*定义游戏板初始化为0*/

char sp[]="0",le[]="0",sc[]="00000";

int speed,speed0,level,score;

int sign,flag;

int style,style1; /*style为当前方块的种类,style1为即将输出的方块的种类*/

void draw_block(int x,int y,int style,int way);


本文标签: 中断 方块 时钟 命令 定义