⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userio.c

📁 ST72T63游戏杆源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/**************** (c) 1998            STD Holdings  **********************

PROJECT : SV239
COMPILER : ST7 HICROSS C (HIWARE)

MODULE  :  userio.c
VERSION :  V 1.0

CREATION DATE :  16/11/98

AUTHOR : Ivan Cheng

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

DESCRIPTION : To define the user input and output functions.

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

MODIFICATIONS :


******************************************************************************/

#include "my_appli.h"
#include "define.h"
#include "hidef.h"
#include "map_7263.h"
#include "usr_var.h"
#include "lib_bits.h"
#include "userio.h"



/*------------------------------------------------------------------------
ROUTINE NAME : AutofireLED(int state)
INPUT/OUTPUT : Output
DESCRIPTION  : This function turns on/off the autofire LED
------------------------------------------------------------------------*/
void AutofireLED(int state)
{
  if (state)
    {  
       AutofireLEDstate=1; }	
  else
    {   
       AutofireLEDstate=0; }

}


/*------------------------------------------------------------------------
ROUTINE NAME : be(void)
INPUT/OUTPUT : Output
DESCRIPTION  : This function is dealy
------------------------------------------------------------------------*/
void be(void)
{
  asm nop;
  asm nop;
  asm nop;
  asm nop;
  
}

/*------------------------------------------------------------------------
ROUTINE NAME : GetInput()
INPUT/OUTPUT : Input
DESCRIPTION  : This function get the status of the keys
------------------------------------------------------------------------*/
void GetInput()
{
  asm SIM;

  
  PBDR |= 0x60;         // Set all output pins to 1       f0-------e0    1-11-00
  PADR |=0x04;
  PCDR |=0x02;
  PCDR &=0xfd;              //   PC1  to 0    1-11-00
  AutofireFlash = 0;
 
  if ((PADR & 0x80)==0)           {A.pressed++;}
       else  {A.pressed=0;}
  if ((PADR & 0x40)==0)           {B.pressed++;}
       else  {B.pressed=0;}
  if ((PADR & 0x10)==0)           {C.pressed++;}
       else  {C.pressed=0;}
  if ((PADR & 0x8)==0)            {D.pressed++;}
       else  {D.pressed=0;}
  if((PADR & 0x1)==0)                {MODESW.pressed++;}
       else  {MODESW.pressed=0;}
  
    //PBDR |= 0x60;         // Set all output pins to 1     1-11-00
	//PADR |= 0x04;
    PCDR |= 0x02;         // PC1 to 1  1-11-00
	for(delay=0;delay<2;delay++);           //1-12-00     key delay

  asm RIM;
  asm SIM;

  PBDR &= 0xdf;         //   and pin 5 to 0
  AutofireFlash = (A.autofire && A.pressed)||(B.autofire && B.pressed)||(C.autofire && C.pressed)||(D.autofire && D.pressed);

  if ((PADR & 0x80)==0)           {E.pressed++;}
       else  {E.pressed=0;}
  if ((PADR & 0x40)==0)           {F.pressed++;}
       else  {F.pressed=0;}
  if ((PADR & 0x10)==0)           {L.pressed++;}
       else  {L.pressed=0;}
  if ((PADR & 0x8)==0)            {R.pressed++;}
       else  {R.pressed=0;}
  
    PBDR |= 0x60;         // Set all output pins to 1     1-11-00
	//PADR |= 0x04;
    //PCDR |= 0x02;         // PC1 to 1  1-11-00
	for(delay=0;delay<2;delay++);        //1-12-00   key delay

  asm RIM;
  asm SIM;

  PBDR &= 0xbf;         //   and pin 6 to 0
  AutofireFlash = AutofireFlash||(MODESW.autofire && MODESW.pressed)||(E.autofire && E.pressed)||(F.autofire && F.pressed);

  if ((PADR & 0x80)==0)           {UP.pressed++;}
       else  {UP.pressed=0;}
  if ((PADR & 0x40)==0)           {DOWN.pressed++;}
       else  {DOWN.pressed=0;}
  if ((PADR & 0x10)==0)           {LEFT.pressed++;}
       else  {LEFT.pressed=0;}
  if ((PADR & 0x8)==0)            {RIGHT.pressed++;}
       else  {RIGHT.pressed=0;}

    PBDR |= 0x60;         // Set all output pins to 1     1-11-00
	//PADR |= 0x04;
    //PCDR |= 0x02;         // PC1 to 1  1-11-00
  for(delay=0;delay<2;delay++);           //1-12-00     key delay


  asm RIM;       
  asm SIM;

  //PBDR &= 0x7f;         //   and pin 7 to 0
  PADR &=0xfb;            //PADR pin 3 to 0
  AutofireFlash = AutofireFlash||(L.autofire && L.pressed)||(R.autofire && R.pressed);

  if ((PADR & 0x80)==0)               MODE.pressed++;
       else  MODE.pressed=0;
  if ((PADR & 0x40)==0)               PROFEDIT.pressed++;
       else  PROFEDIT.pressed=0;
  if ((PADR & 0x10)==0)               {L1.pressed++;}
       else  {L1.pressed=0;}
  if ((PADR & 0x8)==0)                {R1.pressed++;}
       else  {R1.pressed=0;}
 
    //PBDR |= 0x60;         // Set all output pins to 1     1-11-00
	PADR |= 0x04;
    //PCDR |= 0x02;         // PC1 to 1  1-11-00
  
  asm RIM;
  
  AutofireFlash = AutofireFlash||(L1.autofire && L1.pressed)||(R1.autofire && R1.pressed);
}


/*------------------------------------------------------------------------
ROUTINE NAME : SendABCDSubroutine()
INPUT/OUTPUT : Output
DESCRIPTION  : This function sent the ABD data with the clock C
------------------------------------------------------------------------*/
void SendABCDSubroutine()
{
        //  PADR &=0xfd;               //PADR pin 1 to 0,clock c 1 to 0;
	
     D1=0x80;
     for (BitCount=0; BitCount<8; BitCount++)
     {
           
           PADR &=0xfd;               //PADR pin 1 to 0,clock c 1 to 0;
       
           // Set the A, B and D data
           if (TEMP & D1)
              PBDR |= 0x20;           // set DATA A to 1;
           else PBDR &= 0xdf;           // set DATA A to 0;
               
           if (TEMP1 & D1)
              PBDR |= 0x40;           // set DATA B to 1;
           else PBDR &= 0xbf;           // set DATA B to 0;
               
           //if (TEMP2 & D1)
              //PBDR |= 0x80;           // set DATA D to 1;
           //else PBDR &= 0x7f;           // set DATA D to 0;
           if (TEMP2 & D1)
              PADR |= 0x04;           // set DATA D to 1;
           else PADR &= 0xFB;           // set DATA D to 0;   CHANGE DATA D TO PADR PART

           D1 = D1 >> 1;

           
		   be();
		   be();
		   asm nop;
		   asm nop;

		   //be();
	 	   //be();
	 	 

           // Set the clock high
           //PBDR |= 0x10;           // Clock C  0 to 1;
		   PADR |=0x02;				 //PADR pin 1 to 1,clock c 0 to1;

           be();
		   be();
           be();
           be();
           be();
		   be();
		   asm nop;
		   asm nop;
		   //asm nop;
		   //asm nop;
		   
//		   PADR &=0xfd;
		   
     }
		   PADR &=0xfd;
          
		   
		   be();
		   //be();
		   //asm nop;
		   //asm nop;
}


/*------------------------------------------------------------------------
ROUTINE NAME : SendABCD()
INPUT/OUTPUT : Output
DESCRIPTION  : This function sent the ABD data with the clock C
------------------------------------------------------------------------*/
void SendABCD(int Pad_total)
{

   //PADR |= 0x01;           // HC126 control C 0 to 1;   
   
   PadCount=0;
   ByteCount=0;
   
   TEMP = Pad_total*9+3;
   //TEMP1 = 0x02;
   //TEMP2 = 0x39;
   TEMP1 = 0x30;
   TEMP2 = 0x02;   //1-17-00 i73002 id
   for (delay=0;delay<2;delay++);
   SendABCDSubroutine();   

   // Send the data through the A,B,C,D to the Computer
   //
   for (PadCount=0;PadCount<Pad_total;PadCount++)
   {
       for (ByteCount=1;ByteCount<4;ByteCount++)
       {
           TEMP = A_DATA[PadCount].Packet[ByteCount];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -