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

📄 top.c

📁 一个不错的硬盘播放器程序,包含VFD显示程序,红外线遥控程序,硬盘读写程序,及解码程序等.
💻 C
📖 第 1 页 / 共 3 页
字号:
#if 0	      
		VID_error_timeout = 1;
#endif	      
	    } else
#endif	      
	    {
		VID_init();
	    }
	}
#endif
#ifdef MPEG2
	if (error_code == -1) {
	    hardware_reset(1);
	    VID_init();
	}
#endif
    }
}

/***************************************************************************
 Audio decoding task.
 ***************************************************************************/
#ifndef SUB_PICTURE
static void	TSK_decode_audio(void)
{
    if (vcx_playvideo_only
#ifdef FIXEFM
	|| TDM_skip_sectors
#endif
    ) {
        ABV_rdptr = ABV_wrptr;
    	if (!ABV_filling) ABV_start_filling();
    } else {
	int status;
        DBG_mark_current_time(1);
	wait_huffman_idle();
	switch_huffman_to_audio();
	status = AUD_decode();
        DBG_check_elapsed(1);

	/* We might not need this. Should think it thru carefully. */
	if (status) {
	    KEYDEBUGINC(1, bad_audio);
	    oh_my(2);
	    /* hardware_reset(0); */
	}
	DBG_dump_pcm_when_full();
    }
}
#endif

#ifdef KARAOKE
/***************************************************************************
 key shifting task.
 ***************************************************************************/
static void	TSK_karaoke(void)
{
    int status;
    DBG_mark_current_time(3);
    status = karaoke_shift(&KARAvcd);
#ifndef ZERO_BUFFER
#ifndef ECHO
	if (PCM_starved) {
	    PRINTF(("Manual PCM take out\n"));
	    PCM_take_out();
	}
#endif
#endif
    DBG_check_elapsed(3);
    if (status) {
	KEYDEBUGINC(1, bad_kara);
	oh_my(3);
	hardware_reset(0);
    }
    DBG_dump_pcm_when_full();
}
#endif

#ifdef ECHO
/***************************************************************************
 ECHO task.
 ***************************************************************************/
static void	TSK_echo(void)
{
    DBG_mark_current_time(6);
    ECHO_main(1);
    DBG_check_elapsed(6);
}
#endif

/***************************************************************************
 CDDA task.
 ***************************************************************************/
static void	TSK_cdda(void)
{
    int tmp;

#ifdef DVD_VCD
    ABV_check_underflow();
#endif

#ifdef MPEG1
    DBG_mark_current_time(4);

    VP_load_ucode(rcdda);
    VP_cmdq_wait(6+4+4+6);	/* For the worst case */

    VP_xfer(0, VPCMD_W_DP, 0, 0, ABV_rdptr, CDDA_chunk, 1);
    VP_block_twice(0, UCODE_IDLE);
    VP_cmdq_wait_empty;
    mvd[riface_irqsuppress] = 0;
    ABV_rdptr_advance(CDDA_chunk);

    if (vcx_audio_channel < 2) {
	VP_cmdq_wait(NCMDQ_VP_data + NCMDQ_VP_ucode + NCMDQ_VP_block_twice);
    	vp_data_only(vcx_audio_channel);
    	VP_ucode(0, VPCMD_WAIT + cdda_mono);
    	VP_block_twice(0, UCODE_IDLE);
    }
    /*
     * If we are not in the middle of audio fade (i.e. vcx_fade_audio_volume
     * is 0x1010, then use vcx_audio_volume to determine volume; otherwise,
     * vcx_fade_audio_volume has the required volume value.
     */
    tmp = (vcx_fade_audio_volume == 0x1010) ? vcx_audio_volume
					    : vcx_fade_audio_volume;
    vp_data_only(tmp);
    VP_ucode(0, VPCMD_WAIT + cdda_volume_control);
    VP_block_twice(0, UCODE_IDLE);

    VP_xfer(0, VPCMD_R_DP, 0, 0, PCM_raw_wrptr, CDDA_chunk, 1);
    VP_block_twice(0, UCODE_IDLE);
    VP_cmdq_wait_empty;
    PCM_raw_wrptr_advance(CDDA_chunk);
    PCM_fake_data = 0;
    AUD_n_frames++;
#ifndef KARAOKE
#ifndef ZERO_BUFFER
#ifndef ECHO
    if (PCM_starved) PCM_take_out();
#endif
#endif
#endif

    DBG_check_elapsed(4);
#endif
}

/***************************************************************************
 High priority background house-keeping.
 ***************************************************************************/
extern void CUST_background();
extern int microKeyPending();
extern char wait_pause;
void	TSK_background_high_priority()
{
#if (KARAOKE && SPATIAL && VSCALE)
    VBV_alarm = (vcx_karaokey && SPA_level && (vcx_scn_vscale != 0x10))
                ? 1536 : 1024;
#endif
    if (vcx_pause && (vcx_pause_ack == 0)) {
#ifdef PLAY20
/*	system_reset();*/
#endif

#if (P1O || P2O || P3O || P4O)
	if (!vcx_digest) {
	    /* I.e. Stop decoding during fast forward */
	    vcx_playvideo_only = 1;
	    vcx_playaudio_only = 1;
	}
#endif
	vcx_pause_ack = 1;
    }

#ifdef MPEG1
    {
      extern int picture_done;
      if (picture_done) end_of_still = 0;
      else if (end_of_still == 2) {
	processEndOfStill();
	end_of_still = 1;
      }
      if (picture_type == 0xe0) {
	  if (end_of_sequence && !b7_already_flushed) {
	      processEndOfStill();
	      b7_already_flushed = 1;
	  }
      }
    }
#endif

#ifdef DIGEST
    if (vcx_digest)
	decideDigestVideoOrAudio();
#endif	

#ifndef CUST4 /* For CUST4, change TV mode even in digest */
    if (!vcx_digest) 
#endif
    {
      	if ((vcx_scn_height != DISP_scn_height) || do_blank) {
	    /*
	     * Only start the mode changing process if we are showing
	     * blank screen to minimize garbage on screen.
	     */
	    if (!do_blank) {
		done_blank = 0;
		do_blank = 1;
	    } else {
		if ((!VID_decoding_in_progress || vcx_playaudio_only) &&
		    done_blank) {
		    DISP_change_TV();
		    do_blank = 0;
#ifdef PLAY20
		    tv_changed = 1;
#endif
		}
	    }
      	}
    }

#ifdef FRACTINT
    if (FRACT_display_on) FRACT_set_palette();
#endif

#ifndef S215
#if (MKROM && PLAY20)
    receive_dsa();	/* to prevent losing key/CD info */
#endif
#endif

#ifdef SERVO
    SERVO_service();
    SERVO_mode_handle();
#endif

#ifdef MPEG1
    /*
     * When there is a voltage spike, our TDM may get out of sync and
     * start to latch the wrong data. In which case, there will be
     * no valid incoming data and the system will hang.
     *
     * The following check looks for this condition and restarts TDM to
     * recover from this situation.
     */
    if (XPORT_active && !TDM_isCDDA) {
	PRIVATE unsigned int next_tdm_check_timer;
	PRIVATE int last_tdm_int_counter;

	if (glbTimer > next_tdm_check_timer) {
	    if (TDM_cntInterrupt == last_tdm_int_counter) {
		/* This is BAD! TDM may be out of sync. */
		if (vcx_xfer_mode == 5) TDM_turn_on();
	    }
	    next_tdm_check_timer = glbTimer + 10;	/* ~.2 second */
	    last_tdm_int_counter = TDM_cntInterrupt;
	}
    }
#endif

#ifdef NO_MICRO
    /* If we have key pending, we should process it ASAP. */
    if (microKeyPending()||wait_pause)
	CUST_background();
#endif
#if   defined(DVD_VCD) && defined ( I2C_E2PROM )
    i2c_e2prom_process();
#endif

#ifdef CUST6
    Servo_main();
#endif

    VCX_service();
}

/***************************************************************************
 Background tasks.
 ***************************************************************************/
void TSK_background()
{
    {
    	static int fullness_time = 0;
    	if ((glbTimer - fullness_time) > 10) {
    	    VBV_update_occupancy(VBV_fullness);
    	    spoolkeyvar(&VBV_fullness);
    	    ABV_update_occupancy(ABV_fullness);
    	    spoolkeyvar(&ABV_fullness);
    	    PCM_update_occupancy(PCM_fullness);
    	    spoolkeyvar(&PCM_fullness);
	    fullness_time = glbTimer;
	}
    }

    if (PTS_xsit>0) process_pts();

#ifdef FRACTINT
    if (FRACT_process_on) FRACT_paint_a_block();
#endif

#if (PLAYONLY || PLAY20 || CUST3)
    CUST_background();
#endif

#ifdef ECHO
    /*
     * If we have not successfully turn on MIC, then do it now.
     */
    if (!MIC_is_turned_on) MIC_turn_on();
#endif

#ifdef IR
#ifndef NO_MICRO
    processKeycode();
#endif
#endif

#ifdef DEBUG
    if (dbg_console) {
	DBG_console();
	dbg_console = 0;
    }
#endif

#ifdef DIGEST_MVD
    if (digest_go == 1) {
	if (!VID_decoding_in_progress) {
	    digestPage(0);
	    digest_go = 0;
	}
    }
    if (digest_go == 2) {
	resetDigest();
	system_start();
	XPORT_restart_at(XPORT_OFFSET_FUZZY_PLAY, 0);
	XFER_start(xfer_mode);
	digest_go = 0;
    }
#endif

#ifdef ZOOM_MVD
    if (zoom_go_in) {
	zoom_in();
	zoom_go_in = 0;
    }
    if (zoom_go_out) {
	zoom_out();
	zoom_go_out = 0;
    }
    if (zoom_go_up) {
	zoom_move_up();
	zoom_go_up = 0;
    }
    if (zoom_go_down) {
	zoom_move_down();
	zoom_go_down = 0;
    }
    if (zoom_go_right) {
	zoom_move_right();
	zoom_go_right = 0;
    }
    if (zoom_go_left) {
	zoom_move_left();
	zoom_go_left = 0;
    }
#endif

#ifdef FADE_MVD
    switch (fade_go) {
	int logo_time;
	case 1:	/* Fade out to black. */
	    FADE_start(FADE_OUT, 8, 0x8000 + 15); /* Fade to solid black */
	    fade_go = 2;
	    break;
	case 2:	/* Actively fading out to black. */
	    if (!FADE_in_process) {	/* OK we're done */
    		system_reset();
    		show_mpeg_still(0xe1, powerupScreen, T_powerupScreen_SZ>>2);
		FADE_start(FADE_IN, 8, 0x8000 + 15); /* Fade from solid black */
	    	fade_go = 3;
	    }
	    break;
	case 3:	/* Actively fading into the logo. */
	    if (!FADE_in_process) {	/* OK we're done */
		FADE_stop(); /* So that you can have OSD if you want */
	    	fade_go = 4;
		logo_time = glbTimer;
	    }
	    break;
	case 4:	/* We are showing logo. */
	    if (glbTimer - logo_time > 10*60) {
	    	FADE_start(FADE_OUT, 10, 0xd430 + 15); /* Fade to magenta */
		fade_go = 5;
	    }
	    break;
	case 5:	/* Actively fading out to magenta. */
	    if (!FADE_in_process) {	/* OK we're done */
		system_reset();
		system_start();
		XPORT_restart_at(XPORT_OFFSET_FUZZY_PLAY, 0);
		XFER_start(xfer_mode);
		fade_go = 6;
	    }
	    break;
	case 6:	/* Showing magenta, now fade in to normal video. */
	    FADE_start(FADE_IN, 8, 0xd430 + 15); /* Fade from magenta */
	    fade_go = 7;
	    break;
	case 7:	/* Actively fading to normal video. */
	    if (!FADE_in_process) {	/* OK we're done */
	    	FADE_stop();	/* back to normal OSD */
	    	fade_go = 0;
	    }
	    break;
    }
#endif
#ifdef FADE
    if (FADE_in_process) Fade();
#endif
}

#ifdef MZOOM
#if 0
int in          = 0,
    out         = 0,
    up          = 0,
    down        = 0,
    right       = 0,
    left        = 0;
#endif
#endif
/***************************************************************************
 The main task.
 ***************************************************************************/
static void TSK_main()
{
    int	xport_type;

#ifdef DSC
    /* If we are in power down mode, stay here! */
    if (IS_POWER_DOWN) {
	while (1) {
	    TSK_background_high_priority();
	    TSK_background();
#ifdef REAL_CLOCK
	    realClkVFD();
#endif
	}
    } 
#endif
    enable_int(vout);
    enable_int(buscon);
    enable_int(xport);

    system_reset();
#ifndef CUST4
    /* For CUST4, logo is not shown until we get currrent TV mode */
    /* Show logo */
#if defined(CUST3) && defined(NOLOGO)
    fill_screen(COLOR_BLUE);
#else

#ifdef VCDROM
    if (play_clip) {
#ifdef CUST71
	fill_screen(COLOR_BLUE);
#else
	fill_screen(COLOR_BLACK);
#endif
    } else
      show_mpeg_still(0xe1, powerupScreen, T_powerupScreen_SZ>>2);
#else
    show_mpeg_still(0xe1, powerupScreen, T_powerupScreen_SZ>>2);
#endif

#if (!CUST3 && !CUST4 && DSC)
    /* If power on, send pull low to reset CD */
    RESET_CD_LOW;
#endif
#endif

#endif /* CUST4 */

    /* Select and initialise input.
       Rely on vcx_bistream_type and vcx_xfer_mode */
#ifdef DVD_VCD
    vcx_xfer_mode = 0;   
#endif

    xfer_mode = XFER_init(-1);
    xport_type = XPORT_init(-1, xfer_mode);

#if defined(MUSICAM) && defined(MPEG2)
    AUD_set_PES(xport_type == DSS_SIMPLE);
#endif

    DBG_start_tracing();

    VBV_ABV_set_parameters(xfer_mode);

#ifdef ECHO
    MIX_init();
    MIX_start_take_out();
#endif

    /* Start the xport and various buscons. TDM has to be the last to start */
    system_start();

#ifdef ZERO_BUFFER
    /*
     * When zero buffer is used, we only do PCM_start_take_out once
     * at the very beginning.
     */
    PCM_start_take_out();
    LOW_reset_audio_port();	/* Don't know why I need this */
#endif

    XPORT_restart_at(XPORT_OFFSET_FUZZY_PLAY, 0);
    XFER_start(xfer_mode);

#ifdef WATCHDOG
    if (setjmp(err_buf)) {
      /*
       * reinitialise registers 
       */
      register int foo = 0xc3;
      mvd[riface_irqsuppress] = 0;
      asm("nop"); asm("nop");
      asm volatile("movtos %0,psw" : :"r" (foo));

      jumpCDtime = currCDtime;	/* Record this for debugging!! */
      current_task = 0;
      do_blank = done_blank = 0;

      /*
       * Kill r2b so we'll not hang inside buscon_wait in case we were
       * doing OSD before long jump
       */
      buscon_zap(r2b);

#ifdef ZERO_BUFFER
      buscon_zap(d2a);
      PCM_starved = 1;
#endif

#ifdef ECHO
      buscon_zap(d2a);
  /*    MIX_out = 0;  */
#endif
      system_reset();

      /*
       * Without initializing gateway, we may get into a strange state
       * that video/audio keeps on decoding, but screen has checker board
       * and audio is broken.

⌨️ 快捷键说明

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