欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機+LCD12864實現的俄羅斯方塊代碼 小游戲
[打印本頁]
作者:
wangmuran
時間:
2021-1-3 15:27
標題:
單片機+LCD12864實現的俄羅斯方塊代碼 小游戲
單片機實現的俄羅斯方塊的仿真,和程序
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png
(16.06 KB, 下載次數: 71)
下載附件
2021-1-3 18:09 上傳
單片機源程序如下:
#include <AT89X51.H>
#define DOWNTIME 30
#define MAXHANG 20
#define MAXLIE 16
#define MAXPIX 3
#define PUSHON 50
#define LCD P2
#define EN P3_0
#define RW P3_1
#define RS P3_2
#define CS1 P3_3
#define CS2 P3_4
#define KEYLEFT P1_0
#define KEYDOWN P1_7
#define KEYRIGH P1_6
#define KEYROTATION P1_1
unsigned char gkey=0xff,keystate=0,t0ms1=0,t0ms=0,downtimegap=0;
unsigned char miao=0,fen=0;
unsigned char downok;
bit keyflag,timeupdate,fashionupdate;
unsigned char idata cubeMap[MAXHANG][2];
typedef struct{
unsigned char code * box;
unsigned char cube : 4;
unsigned char state : 4;
char row;
char column;
} block;
block this;
unsigned int score=0;
unsigned char speed=1;
unsigned char code bittable[8]={1,2,4,8,0x10,0x20,0x40,0x80};
unsigned char code cube[]=
{
/* ■
■■■
*/
0,4,0xe,0, 0,2,6,2, 0,7,2,0, 4,6,4,0,
/*■
■■■
*/
0,8,0xe,0, 0,4,4,0xc, 0,0,0xe,2, 0,6,4,4,
/*■■■
■
*/
0,0xe,8,0, 0,4,4,6, 0,1,7,0, 6,2,2,0,
/*■■
■■
*/
0,0xc,6,0, 0,2,6,4, 0,6,3,0, 2,6,4,0,
/* ■■
■■
*/
0,6,0xc,0, 0,4,6,2, 0,3,6,0, 4,6,2,0,
/*■■■■
*/
0,0xf,0,0, 4,4,4,4, 0,0,0xf,0, 2,2,2,2,
/*■■
■■
*/
0,6,6,0, 0,6,6,0, 0,6,6,0, 0,6,6,0
};
unsigned char code asii[]=
{
0x3E,0x51,0x49,0x45,0x3E, // -0-
0x00,0x42,0x7F,0x40,0x00, // -1-
0x62,0x51,0x49,0x49,0x46, // -2-
0x21,0x41,0x49,0x4D,0x33, // -3-
0x18,0x14,0x12,0x7F,0x10, // -4-
0x27,0x45,0x45,0x45,0x39, // -5-
0x3C,0x4A,0x49,0x49,0x31, // -6-
0x01,0x71,0x09,0x05,0x03, // -7-
0x36,0x49,0x49,0x49,0x36, // -8-
0x46,0x49,0x49,0x29,0x1E, // -9-
0x00,0x36,0x36,0x00,0x00, // -:-10
//next
0x7F,0x04,0x08,0x10,0x7F, // -N-11
0x7F,0x49,0x49,0x49,0x41, // -E-12
0x63,0x14,0x08,0x14,0x63, // -X-13
0x01,0x01,0x7F,0x01,0x01, // -T-14
//speed
0x26,0x49,0x49,0x49,0x32, // -S-15
0x7F,0x09,0x09,0x09,0x06, // -P-16
0x7F,0x49,0x49,0x49,0x41, // -E-17
0x7F,0x41,0x41,0x41,0x3E, // -D-18
//score
0x3E,0x41,0x41,0x41,0x22, // -C-19
0x3E,0x41,0x41,0x41,0x3E, // -O-20
0x7F,0x09,0x19,0x29,0x46, // -R-21
0x00,0x00,0x00,0x00,0x00, // - -22
//GAME OVER
0x3E,0x41,0x51,0x51,0x72, // -G-23
0x7C,0x12,0x11,0x12,0x7C, // -A-24
0x7F,0x02,0x0C,0x02,0x7F, // -M-25
0x1F,0x20,0x40,0x20,0x1F, // -V-26
//TIME
// 0x00,0x41,0x7F,0x41,0x00 // -I-27
};
////////////////////////////////////////////////////////////////////////////////
void lcdCmd(unsigned char cmd)
{
bit ea;
ea=EA;
EA=0;
EN=0;
RW=0;
RS=0;
LCD=cmd;
EN=1;
EN=1;
EN=0;
EA=ea;
}
//-------------------------------------------------------------------------------
void lcdWriteByte(unsigned char ch)
{
EN=0;
RS=1;
RW=0;
LCD=ch;
EN=1;
EN=1;
EN=0;
}
//--------------------------------------------------------------------------------
void lcdSetPage(unsigned char page)
{
page &=0x7;
page +=0xb8;
lcdCmd(page);
}
//--------------------------------------------------------------------------------
void lcdSetColumn(unsigned char column)
{
column &=0x3f;
column +=0x40;
lcdCmd(column);
}
//--------------------------------------------------------------------------------
//character fron=5*8
void lcdPlayChar(unsigned char index,unsigned char page,unsigned char colume)
{
unsigned char i,temp;
unsigned int p;
p=5*index;
for(i=colume;i<colume+5;i++)
{
if(i<64)
{
CS1=1;
CS2=0;
temp=i;
}
else
{
CS1=0;
CS2=1;
temp=i-64;
}
lcdSetPage(page);
lcdSetColumn(temp);
lcdWriteByte(asii[p++]);
}
}
//---------------------------------------------------------------------------------
//rectangle(3,0,50,60)
void rectangle(void)
{
unsigned char i,page;
CS1=1;
CS2=0;
lcdSetPage(0);
lcdSetColumn(2);
EN=0;
RS=1;
RW=0;
LCD=0xff;
EN=1;
EN=1;
EN=0;
for(i=3;i<51;i++)
{
EN=0;
RS=1;
RW=0;
LCD=0x1;
EN=1;
EN=1;
EN=0;
}
EN=0;
RS=1;
RW=0;
LCD=0xff;
EN=1;
EN=1;
EN=0;
//---------------------------
for(page=1;page<7;page++)
{
lcdSetPage(page);
lcdSetColumn(2);
EN=0;
RS=1;
RW=0;
LCD=0xff;
EN=1;
EN=1;
EN=0;
for(i=3;i<51;i++)
{
EN=0;
RS=1;
RW=0;
LCD=0x0;
EN=1;
EN=1;
EN=0;
}
EN=0;
RS=1;
RW=0;
LCD=0xff;
EN=1;
EN=1;
EN=0;
}
//---------------------------
lcdSetPage(7);
lcdSetColumn(2);
EN=0;
RS=1;
RW=0;
LCD=0x1f;
EN=1;
EN=1;
EN=0;
for(i=3;i<51;i++)
{
EN=0;
RS=1;
RW=0;
LCD=0x10;
EN=1;
EN=1;
EN=0;
}
EN=0;
RS=1;
RW=0;
LCD=0x1f;
EN=1;
EN=1;
EN=0;
}
//--------------------------------------------------------------------
//x:列;y行,頁 3*3
void lcdPutPix(unsigned char x, unsigned char y,unsigned char flag)
{
unsigned char i,dat,bitmask,nextbit;
bit bflag,pflag,ea;
x=x*MAXPIX;
y=y*MAXPIX;
bflag=0;
pflag=0;
i=y%8;
if(i==0)
bitmask=0x7;
else if(i==1)
bitmask=0xe;
else if(i==2)
bitmask=0x1c;
else if(i==3)
bitmask=0x38;
else if(i==4)
bitmask=0x70;
else if(i==5)
bitmask=0xe0;
else if(i==6)
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
俄羅斯方塊Proteus7.8打開.7z
(47.31 KB, 下載次數: 70)
2021-1-3 18:11 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
菲菲gff
時間:
2021-3-11 16:09
非常有用,感謝大佬
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1