硬件STC8A8K64S4A12+LCD12864,只做了两个游戏(俄罗斯方块+推箱子)!
1.jpg

2.png

3.png

4.png

单片机源程序如下:
#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;
  • }
  • 复制代码