#include
unsigned char position1=1;//position一共有3种状况,0代表最边上,1代表初始方位,2代表最前的方位unsigned char position2=1;//position一共有3种状况,0代表最边上,1代表初始方位,2代表最前的方位unsigned char fist1=0;//1没有出拳unsigned char fist2=0;//2没有出拳unsigned char leg1=0;//1没有出脚unsigned char leg2=0;//2没有出脚unsigned char count_back1=0;unsigned char count_back2=0;unsigned char count_forth1=0;unsigned char count_forth2=0;unsigned char time0_count=0;unsigned char time1_count=0;unsigned char blood1=7;unsigned char blood2=7;unsigned char buff1[16]={0x00,0x18,0x24,0x24,0x18,0x18,0x7E,0x66,//右边小人的初始形状0x66,0x24,0x3C,0x24,0x24,0x24,0x24,0x00};unsigned char buff2[16]={0x00,0x18,0x24,0x24,0x18,0x18,0x7E,0x66,//右边小人的初始形状0x66,0x24,0x3C,0x24,0x24,0x24,0x24,0x00};//界说两名选手的操作键//选手1#define S11 P1_0//向前#define S12 P1_1//撤退#define S13 P1_2//出拳#define S14 P1_3//出腿//选手2#define S21 P1_4//向前#define S22 P1_5//向后#define S23 P1_6//出出#define S24 P1_7//腿拳//两个选手的led点阵行扫描使能端#define A_1 P0_0#define B_1 P0_1#define C_1 P0_2#define D_1 P0_3//两个选手的2个595使能端#define SCLK P2_0#define SI P2_1#define RCLK P2_2//当按下S1时 开端游戏,游戏结束时显现哪方取胜,然后按下S2键后重新开端新一轮游戏#define S1 P2_6#define S2 P2_7//榜首个人的74HC154区域行选#define NUMLED1OPEN(); {D_1=0;C_1=0;B_1=0;A_1=0;};#define NUMLED2OPEN(); {D_1=0;C_1=0;B_1=0;A_1=1;};#define NUMLED3OPEN(); {D_1=0;C_1=0;B_1=1;A_1=0;};#define NUMLED4OPEN(); {D_1=0;C_1=0;B_1=1;A_1=1;};#define NUMLED5OPEN(); {D_1=0;C_1=1;B_1=0;A_1=0;};#define NUMLED6OPEN(); {D_1=0;C_1=1;B_1=0;A_1=1;};#define NUMLED7OPEN(); {D_1=0;C_1=1;B_1=1;A_1=0;};#define NUMLED8OPEN(); {D_1=0;C_1=1;B_1=1;A_1=1;};#define NUMLED9OPEN(); {D_1=1;C_1=0;B_1=0;A_1=0;};#define NUMLED10OPEN(); {D_1=1;C_1=0;B_1=0;A_1=1;};#define NUMLED11OPEN(); {D_1=1;C_1=0;B_1=1;A_1=0;};#define NUMLED12OPEN(); {D_1=1;C_1=0;B_1=1;A_1=1;};#define NUMLED13OPEN(); {D_1=1;C_1=1;B_1=0;A_1=0;};#define NUMLED14OPEN(); {D_1=1;C_1=1;B_1=0;A_1=1;};#define NUMLED15OPEN(); {D_1=1;C_1=1;B_1=1;A_1=0;};#define NUMLED16OPEN(); {D_1=1;C_1=1;B_1=1;A_1=1;};//0是榜首个选手的索引表的开端 80是第二个选手开端在表中的方位#define START1 0#define START2 80#define INIT 16//榜首个选手从的初始状况在中心 为16#define JUMP_UP_AND_BACK1 48//向后跳起的缓冲动作的方位#define JUMP_UP_AND_BACK2 64//向后跳起的缓冲动作的方位#define BACK 0//在最边后边的状况的方位#define FORTH 32//在最前面的状况的方位#define GO 0//游戏的开端画面 然后按S1开端游戏//#define KO 32#define P1_WIN 64//显现P1成功在索引表中的方位#define P2_WIN 96//显现P2成功在索引表中的方位//图画表//人物的各种形状和方位unsigned char code role_action[]={0x00,0x0C,0x12,0x12,0x0C,0x0C,0x3F,0x33,//左面小人撤退一步的状况00x33,0x12,0x1E,0x12,0x12,0x12,0x12,0x00,0x00,0x18,0x24,0x24,0x18,0x18,0x7E,0x66,//左面小人的初始形状160x66,0x24,0x3C,0x24,0x24,0x24,0x24,0x00,0x00,0x30,0x48,0x48,0x30,0x30,0xFC,0xCC,//左面小人行进一步的状况320xCC,0x48,0x78,0x48,0x48,0x48,0x48,0x00,0x18,0x24,0x24,0x18,0x18,0x66,0x66,0x65,//左面小人向右后方向跳起的动作1 480x24,0x3C,0x24,0x12,0x12,0x12,0x00,0x00,0x0C,0x12,0x12,0x0C,0x0C,0x33,0x33,0x53,//左面小人向右后方向跳起的动作2 640x12,0x1E,0x12,0x24,0x24,0x24,0x00,0x00,0x00,0x30,0x48,0x48,0x30,0x30,0xCC,0xCC,//右边小人撤退一步的动作800xCC,0x48,0x78,0x48,0x48,0x48,0x48,0x00,0x00,0x18,0x24,0x24,0x18,0x18,0x7E,0x66,//左面小人的初始形状960x66,0x24,0x3C,0x24,0x24,0x24,0x24,0x00,0x00,0x0C,0x12,0x12,0x0C,0x0C,0x33,0x33,//右边小人行进一步的状况1120x33,0x12,0x1E,0x12,0x12,0x12,0x12,0x00,0x18,0x24,0x24,0x18,0x18,0x66,0x66,0xA6,//右边小人向左后方向跳起的动作1 1280x24,0x3C,0x24,0x48,0x48,0x48,0x00,0x00,0x30,0x48,0x48,0x30,0x30,0xCC,0xCC,0xCA,//右边小人向左后方向跳起的动作2 1440x48,0x78,0x48,0x24,0x24,0x24,0x00,0x00};//开机画面和结束时显现哪方成功的索引表unsigned char code welecome_and_end[]={0x00,0x00,0x00,0x04,0xF9,0xF4,0xF9,0xF4,0x00,0x04,0xF9,0xF4,0xF9,0xF4,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//GO!!! 00x00,0x00,0x22,0x38,0x24,0x44,0x28,0x44,0x30,0x44,0x28,0x44,0x24,0x44,0x22,0x44,0x22,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x92,0x49,0x45,0x14,0x28,0xA2,0x92,0x49,//KO 320x00,0x00,0x00,0x00,0x00,0x00,0x25,0x12,0x51,0x13,0x55,0x12,0x55,0x52,0x54,0xA7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//P1 WIN 640x00,0x00,0x00,0x00,0x00,0x00,0x4A,0x24,0xA2,0x2A,0xAA,0x24,0xAA,0xA2,0xA9,0x4E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//P2 WIN 96};void delayu(unsigned int time);//延时函数 延时0.1msvoid delay(unsigned int time);//延时函数 延时1msvoid NUMLEDOPEN(int i);//74HC154进行行挑选,第i行void dat_in(unsigned char dat);//将8为数据从597传送曩昔void display_one_page();//先加载各方“血”的状况,并显现一张图片,显现人的状况和血的状况void display_scene(int scene);//显现开机画面和输赢画面的函数void change_buffer_to1(int position);//修正1的图画状况缓冲 从人物索引表的第position个8位数个开端显现void change_buffer_to2(int position);//修正2的图画状况缓冲 从人物索引表的第position个8位数个开端显现void action_back1();//第1个人向后一步 并将position减1 直到它不能撤退void action_back2();//第2个人向后一步 并将position减1 直到它不能撤退void action_forth1();//第1个人向前一步 并将position加1 直到它不能撤退void action_forth2();//第2个人向前一步 并将position加1 直到它不能撤退void fist_change_buff1();//因为1出拳对画面的改动 要调用change_buff1_to_bit(int pos)和change_buff1_to_bit_low(int pos)函数void leg_change_buff1();//因为1出腿对画面的改动 要调用change_buff1_to_bit(int pos)和change_buff1_to_bit_low(int pos)函数void fist_change_buff2();//因为2出拳对画面的改动 要调用change_buff1_to_bit(int pos)和change_buff1_to_bit_low(int pos)函数void leg_change_buff2();//因为2出腿对画面的改动 要调用change_buff1_to_bit(int pos)和change_buff1_to_bit_low(int pos)函数void change_buff1_to_bit(int pos); //将特定某一方位一void change_buff2_to_bit(int pos);//将特定某一方位一void change_buff1_to_bit_low(int pos);//将特定某一方位0void change_buff2_to_bit_low(int pos);//将特定某一方位0void action_fist1();//第1个人出拳 并处理减血状况void action_fist2();//第2个人出拳 并处理减血状况void action_leg1();//第1个人出腿 并处理减血状况void action_leg2();//第2个人出腿 并处理减血状况void scan_key();//这个是函数的主体部分 别离扫描并处理向撤退 向前走 出拳 出腿的动作 当出拳和出腿的时分 敞开定时器//这300ms内记载是否有对方出拳出腿的动作 并依照先扫描向撤退 后扫描向行进的次序 扫描一遍 并处理 假如没有这两个动作 直接回来调用出拳//不然处理后再出拳 出脚的道理共同void init_interrupt();//中止位的设置//敞开定两个时器中止 16位形式void shed_blood1();//记载流血的数字void shed_blood2();void main(){int i;while(1){if(S1==0){delay(1);if(S1==0){for(i=0;i