硬件STC8A8K64S4A12+LCD12864,只做了兩個游戲(俄羅斯方塊+推箱子),有興趣的師兄可以繼續(xù)寫完!如需幫助點我頭像加我
單片機源程序如下:
- #include <STC8.h>
- #include <stdlib.h>
- #include <intrins.h>
- #include "51GUI.h"
- #include "ST7567.h"
- #include "EEPROM.h"
- #include "主菜單.h"
- #include "俄羅斯方塊1.h"
- #include "推箱子1.h"
- #define InitialAddress 1632
- unsigned char module,minute,second,count,D_num;
- void verify_eeprom(){
- p_DATA eepromdata dat;
- unsigned char a;
- unsigned int b;
- if(ED->sign!='L'){
- for(a=1;a<38;a++)((unsigned char p_DATA*)&dat)[a]=0;
- for(b=38;b<467;b++)((unsigned char p_DATA*)&dat)[a]=0xFF;
- dat.sign='L';
- EEPROM_Write(&dat);
- }
- }
- unsigned char Key_scan(){//按鍵掃描
- unsigned char a;
- a=P3&Bin(0011,0011);
- P3=Bin(1100,1101);
- _nop_();_nop_();_nop_();_nop_();
- a|=P3&Bin(1100,1101);
- P3=Bin(0011,0011);
- return a;
- }
- void main(){
- VOCTRL=Bin(1000,0000);
- P_SW1=Bin(0000,0100);
- SPCTL=Bin(1101,1100);
- AUXR=Bin(0001,0000);
- TH0=0x0B;
- TL0=0xDC;
- INTCLKO=Bin(0100,0000);
- IE2=Bin(0000,0100);
- IE=Bin(1000,0010);
- init_mempool(InitialAddress,8192-InitialAddress);
- GUI_Init(64,128);
- ST7567_init();
- verify_eeprom();
- for(;;)switch(module){
- case NMM:main_menu();break;
- case NT:tetris();break;
- case NTG:tetris_gameover();break;
- case NS:Sokoban();break;
- case NSP:Sokoban_reach();break;
- case NSSA:module=NS;break;
- }
- }
- time25ms()interrupt 1{//計時
- if(++count>40){
- count=0;
- if(--second==0xFF){
- second=59;
- --minute;
- }
- }
- }
- delay()interrupt 12{
- D_num++;
- }
- Automatically_download()interrupt 16{
- IAP_CONTR=0x60;
- }
復制代碼
所有程序51hei提供下載:
方塊游戲機.zip
(308.87 KB, 下載次數(shù): 25)
2021-6-11 06:07 上傳
點擊文件名下載附件
|