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

📄 chf.c

📁 一个通过光碟的8位GAME在DVD机上打GAME的程序,数据读出及处理.
💻 C
字号:
#include  "buffer.h"
#include  "const.h"
#include  "dsa.h"
#include  "timedef.h"  /*glotimer*/
#include  "fsosd.h"
#include  "vcxi.h"
#include  "echo.h"
#include  "play.h"                          
#include  "font.h"
#include  "chf.h"

unsigned short  download_time ,game_flag = 0;
int             echo_old = -1;

void    debugOsd1(int, unsigned short);    
void    PANA_GAME_send_data(unsigned char);
void    select_vcd();
void    download_data(int dst, unsigned int *srcp, int n);
void    delay_one_second();

void MDC_GAME_rst()
{
   RESET_USE;
   delay_one_second();
   RESET_NO_USE;
   PANA_GAME_send_data(0x0f);
   ;
   LATCH_LOW;
   LATCH_HIGH;
   //      DSC_set_aux(1, 0,LATCH_SIG); 
   //      DSC_set_aux(1, 1,LATCH_SIG);  
   RESET_USE;           
   delay_one_second();
   RESET_NO_USE;
   AVSEL_VCD;
}
void PANA_GAME_send_data(unsigned char data)
{
        if (data & 0x01)
           SET_EAUX0;
        else
           CLEAR_EAUX0;

        if (data & 0x02)
           SET_EAUX1;
        else
           CLEAR_EAUX1;

        if (data & 0x04)
           SET_EAUX2;
        else
           CLEAR_EAUX2;

        if (data & 0x08)
           SET_EAUX3;
        else
           CLEAR_EAUX3;

        if (data & 0x10)
           SET_EAUX4;
        else
           CLEAR_EAUX4;

        if (data & 0x20)
           SET_EAUX5;
        else
           CLEAR_EAUX5;

        if (data & 0x40)
           SET_EAUX6;
        else
           CLEAR_EAUX6;

        if (data & 0x80)
           SET_EAUX7;
        else
           CLEAR_EAUX7;
}

void delay_one_second()
{
   int i,j;
   for (i=0; i<8500; i++) {
       for (j=0; j<50; j++) {
            ;
            ;
       }
   }
}
void MDC_GAME_stopgame()
{
   if (game_flag == 1) {
       vcx_echo = echo_old;
       if (vcx_echo == -1){
           MIC_stop_take_in();
              }
       if (vcx_echo == 0) {  
           MIC_init();
           MIC_start_take_in();
           }
       }
  /* POWER_OFF;*/
   AVSEL_VCD;
/*   RESET_USE;
   delay_one_second();
   RESET_NO_USE;
   */
   game_flag = 0;
}

void MDC_play_game(play_item,play_size)
{
    unsigned int * ptr;
    unsigned char * pVcd;
    unsigned int *pTk;
    int sector_num,time,time1,n,size,retry_cnt = 0;

    echo_old = vcx_echo;    
    game_flag = 1;
    vcx_echo = -1;
    MIC_stop_take_in();
    vcx_audio_volume = 0;
/*    retry_cnt = 0;*/
game_retry:
    sector_num = 0;
    time = play_item;
    time1 = 0x00;
    size =  play_size/2 /10 + 1;

    for (sector_num = 0;sector_num < size;sector_num ++) {
         if (!getSectors(time + time1, 10, 2048)) {
            return;       
           }
        if (((sector_num + 0x01) * 10) >= 75){   
             if ((time & 0xf00) == 0x0900)
             time1 = hex2bcd[(sector_num + 0x01) * 10 - 75] & 0xff | 0x700;
             else {
             if (((sector_num + 0x01) * 10) >= (75 * 2))
             time1 = hex2bcd[(sector_num + 0x01) * 10 - 75 - 75] & 0xff | 0x200;
             else
             time1 = hex2bcd[(sector_num + 0x01) * 10 - 75] & 0xff | 0x100;
                 }
             }
        else       
            time1 = hex2bcd[(sector_num + 0x01) * 10] & 0xff;
        if(sector_num >= 1)                 
        debugOsd1(4, hex2bcd[size - sector_num]);

        CDI_ptr = (unsigned char *) dram(VBV_start);
        pVcd = CDI_ptr;
        ptr = (unsigned int *) pVcd;

        if (sector_num == 0) {
             if (((*ptr >> 16) & 0xffff)!= 0x4d59)  { /* MY */
                 return ;           
                  }
/*           MDC_GAME_rst();*/
             RESET_USE;
             delay_one_second();
             RESET_NO_USE;
             delay_one_second();
             RESET_USE;
             delay_one_second();
             RESET_NO_USE;
  
        }
    if ((BUSY_HIGH) && (retry_cnt < 3)) {
          retry_cnt ++;
          goto game_retry;
          }
       download_data(0, ptr, 2048 * 10 /4);
      }

   if ((BUSY_HIGH) || (retry_cnt >= 3))   select_vcd();
   else {
    retry_cnt ++;
    goto game_retry;
     }
     vcx_audio_volume = 0x1010;
     dsa_stop();
     OSD_clear_all(); 
}

void download_data(dst, srcp, n)
unsigned int     *srcp;    /* source ptr in SRAM   */
int                   n;    /* block size in dwords */
{
    
    int i;
    while (n--) {                
              for (i=0; i<20000; i++) {
                 if (BUSY_LOW) goto l1;
                             }

l1:            PANA_GAME_send_data((*srcp >> 24) & 0xff);
/*               if (n ==  2048 * 10 /4 - 1) debugOsd(10,(*srcp >> 24) & 0xff);*/
               ;
               ;
               LATCH_LOW;
               LATCH_HIGH;
              // DSC_set_aux(1, 0,LATCH_SIG);             
              // DSC_set_aux(1, 1,LATCH_SIG);   
              for (i=0; i<20000; i++) {
                 if (BUSY_LOW) goto l2;
                  if (i == 0x10000 ){
                  select_vcd();
                  return;
                  }
                 
            } 
l2:            PANA_GAME_send_data((*srcp >> 16) & 0xff);
               ;
               ;
               LATCH_LOW;
               LATCH_HIGH;
              for (i=0; i<20000; i++) {
                 if (BUSY_LOW) goto l3;

                  if (i == 10000 ){
                  select_vcd();
                  return;         
                  }
            } 
l3:           PANA_GAME_send_data((*srcp >> 8) & 0xff);
               ;
               ;
               LATCH_LOW;
               LATCH_HIGH;
              for (i=0; i<20000; i++) {
                 if (BUSY_LOW) goto l4;
                  if (i == 10000 ){
                  select_vcd();
                  return;
                  }
            } 
l4:            PANA_GAME_send_data(*srcp & 0xff);
               ;
               ;
               LATCH_LOW;
               LATCH_HIGH;
              srcp ++;
/*              for (i=0; i<2000; i++)  ;*/
              
    }
}
                           
                      
char hex2ascii1[]={

'0','1','2','3',
'4','5','6','7',
'8','9','A','B',
'C','D','E','F'
};

void debugOsd1(i,code)
  unsigned short code;
  int i;
    {
      char array[9];
      array[8]=0;
      array[0]= ' ';
      array[1]= CN_SHENG4;
      array[2]= CN_YU2;
      array[3]= ' ';
      array[4]= ' ';
      array[7]= ' ';
      array[5]=hex2ascii1[(code>>4) & 0xf ];
      array[6]=hex2ascii1[ code & 0xf];
            
      OUTOSD(i,array,array,2);
     }
void select_vcd( )
{
                  AVSEL_GAME;
                  vcx_echo = 0;
                  MIC_init();
                  MIC_start_take_in();
}

⌨️ 快捷键说明

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