top.c

来自「一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.」· C语言 代码 · 共 1,718 行 · 第 1/3 页

C
1,718
字号
      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.
       */
      LOW_init_gateway();

#ifdef ZERO_BUFFER
      LOW_init_audio();
#endif
#ifdef ECHO
      LOW_init_audio();
#endif
      system_start();

#ifdef ZERO_BUFFER
      PCM_start_take_out();
#endif
#ifdef ECHO
      MIX_init();
#ifdef VCDROM
      old_play_clip = play_clip;
      play_clip = 0;
#endif
      MIX_start_take_out();
#ifdef VCDROM
      play_clip = old_play_clip;
#endif

#endif

      if (TDM_isCDDA)
	XPORT_restart_at(XPORT_OFFSET_PLAY_CDDA, 1);
      else {
#ifdef PLAY20
	  /*
	   * For safety, 2.0 machines will check whether the XPORT was
	   * stopped when longjump occurs. If XPORT was in STOP_STATE,
	   * then don't bother to restart XPORT; otherwise, we may
	   * have the strange behavior of having "slide show" when we intend
	   * to show one slide.
	   */
	  if (xportpc != XPORT_OFFSET_STOP_STATE)
	    XPORT_restart_at(XPORT_OFFSET_FUZZY_PLAY, 0);
#else
	  XPORT_restart_at(XPORT_OFFSET_FUZZY_PLAY, 0);
#endif
      }
      XFER_start(xfer_mode);

      EPRINTF(("WATCH DOG RESET!\n"));
    }
#endif

#ifdef FRACTINT
    if (xport_type == AUDIO_ELM_ONLY) {
    	FRACT_start();
    }
#endif

#ifdef DVD_VCD
    init_hellen();
    while(!hellen_is_alive){
	risc_sleep_a_bit(100000);
    }
#endif

#if defined(DVD_VCD) && defined(I2C_E2PROM)
    { /* process jump info reading */
	int i;
	for ( i = 0; i < 10000 ; i ++ ){
	    i2c_e2prom_process();
	}
    }
#endif

#ifdef KEYDEBUG
    dram_at_0 = *((int *)0x12000000);
#endif

    do {
	current_task = what_to_do();

#ifdef FIXEFM
	{
	    static int prev_skip_sectors;
	    if (prev_skip_sectors && !TDM_skip_sectors) {
		/* 
		 * We shall start decoding again. Reset video and audio.
		 * We have thrown away a number of sectors!
		 */
		VID_init();
		AUD_init();
	    }
	    prev_skip_sectors = TDM_skip_sectors;
	}
#endif /* FIXEFM */


#if (C80 && THREE_CDS)
	cd_exchange() ; /* 97/12/31 */
#endif

	if (current_task) DBG_log_task(1, current_task, 0, 0, 0, 0);
	switch (current_task) {
	    case 0:
	        TSK_background();
		break;
	    case 1:
#ifdef SUB_PICTURE
	 	DBG_check_elapsed_every(1);	
	    	check_spu_data();
		spu_decoder();
#else
		oh_my(4);
		TSK_decode_audio();
#endif
		break;
	    case 2:
		oh_my(5);
		TSK_decode_video();
		break;
#ifdef KARAOKE
	    case 3:
		oh_my(6);
		TSK_karaoke();
		break;
#endif
	    case 4:
		TSK_cdda();
		break;
#ifdef VSCALE
	    case 5:
/* When vscale is ready, it is not really the new picture is ready,
   so, the program will scale the old one. In slide show, we have
   destroied the original picture, it is really bad to see this 
   picture rescaled before the new one coming */
#ifdef ZOOM
		if ((zoom_level || expect_zoom) &&
		     zoom_frame == H_VscaleFrame) resetVscale();
#endif
	        vscale2();
		break;
#endif
#ifdef ECHO
	   case 6:
		TSK_echo();
		break;
#endif
#ifdef MZOOM
	   case 7:
	   	MZM_ip_frame();
		break;
#endif
	}

#ifdef C80
/*    cd_exchange() ; 97/12/31 */
	test_fok();
	if ((current_task == 0) || (cd_presmodu != T_RUN))
	    cd_main() ;
#endif

	if (current_task) DBG_log_task(2, current_task, 0, 0, 0, 0);

	/*
	 * reset the task
	 */
	current_task = 0;
#ifdef ZOOM
	/* do zoom when necessary */
	if (!VID_decoding_in_progress && !end_of_still && 
	    expect_zoom) {
	    if  (vcx_VertSz <= 288) {
#if (CUST3 && !CUST71)
	       cancel_zoom();
#else
	       zoom_reset();
#endif
	       set_zoom();
	    }
	    expect_zoom = 0;
	}
#endif

#ifdef MZOOM
#if 0
        if (!VID_decoding_in_progress) {
	    if (in) {
		MZM_in();
		in = 0;
	    } else if (out) {
		MZM_out();
		out = 0;
	    }

	    if (up) {
		MZM_pan_up();
		up = 0;
	    } else if (down) {
		MZM_pan_down();
		down = 0;
	    } else if (left) {
		MZM_pan_left();
		left = 0;
	    } else if (right) {
		MZM_pan_right();
		right = 0;
	    }
	}
#endif
#endif

	TSK_background_high_priority();

#ifdef DVD_VCD
	VBV_update_occupancy(VBV_fullness);
#endif

#ifdef KEYDEBUG
	if (dram_at_0 != *((int *)0x12000000)) {
	    KEYDEBUGINC(1, dram_overwrite);
	    DBG_console();
	}
#endif

    } while (1);
}

#if !((defined(CUST3)||defined(CUST4)) && defined(NOLOGO))
/* Not every one needs it */
/***************************************************************************
 Decode and display an mpeg still.
 Side effect: the entire data chain starting from xport is stopped!
 ***************************************************************************/
int show_mpeg_still(e1e2, data, n)
int e1e2;           /* Either 0xe1 or 0xe2 */
int *data;          /* Where data starts */
int n;              /* Size of stream in 32-bit words */
{
    extern int arodnap;
    extern int good_old_days;
    extern int bane;
    extern int picture_type;

#if defined(NOLOGO)
    arodnap = good_old_days = 0;
    /* If we want to save space, we have the option not to include logo */
    DISP_paint_screen(COLOR_BLUE, 1, DISP_frame);
#else
    int	m;

#ifdef MPEG1
    int	save[32], matrix_status;
    extern int H_CurrFrame;

    /* Save quant matrices */
    matrix_status = VID_save_q_matrices(save);
#endif

    bane = arodnap = good_old_days = 0;
    assert(n <= VBV_size);
    system_reset();

    /* Move the data to the VBV.
       Force data size to be integer multiples of VBV_read. */
    sram_to_dram(VBV_start, data, n);
    m = n % VBV_read;
    if (m) {
	int *p = (int *)dram(VBV_start + n);
	while (m++ < VBV_read) {
	    *p++ = 0; n++;
	}
    }
    VBV_wrptr_advance(n);
    PRINTF(("LOGO (%d) now in DRAM at 0x%x.\n", n, dram(VBV_start)));

    /* Start draining the VBV. We set VBV_filling to 1 to fool
       hufdecv_xfer_end into not starting a xportv_xfer. */
    VBV_start_draining();
    VBV_filling = 1;
    
    picture_type = e1e2;
    /* The real decoding loop */
    VID_decoding_in_progress = 1;
    while (VID_decoding_in_progress) {
	VID_decode();
    }
    
#ifdef VSCALE
    /* Do vertical scaling if necessary */
    if ((vcx_scn_vscale != 0x10) && 
        (vcx_user_video_stream != 0xe2)){
      	H_VscaleFrame = H_CurrFrame;
      	initVscale_Pointer();
      	VscaleStart = 1;
	VscaleLastFrame = 0;
      	while (VscaleStart) vscale2();
	DISP_frame = 2;  
    } else DISP_frame = H_CurrFrame;
#else    
#ifdef MPEG1
    DISP_frame = H_CurrFrame;
#else
    DISP_frame = 1;
#endif
#endif
    DISP_count = 0;

    system_reset();
    picture_type = 0xe0; /* also reset picture_type*/

#ifdef MPEG1
    /* Restore quant matrices */
    VID_restore_q_matrices(matrix_status, save);
#endif	/* NOLOGO or MPEG2 */
#endif	/* NOLOGO */
}
#endif

/***************************************************************************
 The main entry point.
 ***************************************************************************/
main()
{
    /* ******** RISC and register setups ******** */
    register int psw_shadow = 0xc3;
    asm volatile("movtos %0,psw" :  :"r" (psw_shadow) );
    mvd = (int *)OMNI_BASE;
#ifdef MKROM
    /* Chip version detected in startup.s; 0xc3 at 0 means 3210 */
    mvd_version = (*((int *)(dram(0))) == 0xc3) ? 0x3210 : 0x3208;
#endif

#ifdef DSC
    DSC_getstatus();
#endif
    Init_const();
    initialization();
    DBG_allocate_trace_buffer();
#ifdef C80
    cd_init() ;
#endif

    TSK_main();
}

/***************************************************************************
 Misc interrupt handling.
 ***************************************************************************/
extern void trap0;
static int *trapptr0 = &trap0;

#ifndef DRAM_GAME
static 
#endif
void install_interrupt_vectors()
{
    int *a, *b, i;

#ifdef MKROM
    b = (int*)((int)trapptr0<<2);
#else
    b = (int*)((int)trapptr0);
#endif
    /* 
     * The DWORD at 0x18 is used for resume!!
     * The DWORD at 0x1c is used for real-time clock!! 
     *
     * Don't read 0x10 to 0x1f, they meant to be noncachable.
     */
    for (a = (int*)0, i = 0; i < 4; i++) *a++ = *b++;
}

#if (CUST3 && !CUST71)
int free_time_act() 
{
#ifdef VCDROM
    if (VCD_30)
	return;
#endif

    if (vcx_digest) 
	return;

    if (play_state == PLAY_STEP_STATE || play_state == PLAY_SLOW_STATE ||
	play_state == ENTRY_STATE)
	return;

    current_task = what_to_do();
    switch(current_task) {
	case 1:
#ifdef SUB_PICTURE
	    DBG_check_elapsed_every(1);	
	    check_spu_data();
	    spu_decoder();
#else
	    oh_my(4);
	    TSK_decode_audio();
#endif
	    break;
	case 2:
	    oh_my(5);
	    TSK_decode_video();
	    break;
#ifdef KARAOKE
	case 3:
	    oh_my(6);
	    TSK_karaoke();
	    break;
#endif
	case 4:
	    TSK_cdda();
	    break;
#ifdef VSCALE
	case 5:
#ifdef ZOOM
	   if ((zoom_level || expect_zoom) &&
	     zoom_frame == H_VscaleFrame) resetVscale();
#endif
	    vscale2();
	    break;
#endif
#ifdef ECHO
	case 6:
	    TSK_echo();
	    break;
#endif
    }
    current_task = 0;		/* reset current_task */
    return current_task;
}
#endif


#ifdef VCDROM
int *data_loc_30=0;

void vcd30()
{
    void BB_jump30(int *);

    power_up = 0;

#ifdef ECHO
    if (vcx_echo >= 0)
        MIC_stop_take_in();
#endif
 
    if (repeat_a2b) {/* REPEAT_AB_START or REPEAT_AB_END */
        repeat_a2b = REPEAT_AB_OFF;
        panel_repeat_ab(REPEAT_AB_OFF);
    }

    system_reset();
    mvd[riface_irqmask]=0;

    mvd[vid_scn_hstart]         = vcx_scn_hstart+4;
    mvd[vid_scn_hend]           = vcx_scn_hstart+4 + 720;
    old_vcx_scn_height = vcx_scn_height;

    asm("addi r0,#0x6000,r29");

    BB_jump30(data_loc_30);
    VCD_30 = 1;
    XPORT_active = 0;
    init();
}

void vcd20(int vcd30_event)
{
    extern int screen_end;
    int i;
    int time_out;
    int addr;
    register int stack = VCD20STACK;
    extern short list_previous_list_offset;
    extern short list_next_list_offset;
    extern unsigned char cur_list_state;

#if (SERVO2545 || TCSERVO)
    if (vcd30_event == VCD30_EJECT ||
	vcd30_event == VCD30_ROTATE_CLOCK ||
	vcd30_event == VCD30_ROTATE_ANTI_CLOCK)
	dsa_stop();
#endif

    stack += (ADJUST_4_LINE * 4);/* Optionally adjust stack for 4 line OSD */

    /* set the screen to blank. */
    mvd[vid_scn_vstart]       = screen_end;
    mvd[vid_scn_vend]         = screen_end + 1;
    time_out = glbTimer + 3;
    while (glbTimer < time_out)
	VCX_service();
	
    mvd[riface_irqmask]       = 0;

#ifndef CUST71
    if (!vcd30_event) {
	DSC_powerup();
	return;	
    }
#endif

    SPA_level = SPA_OFF; /* reset surround */
    play_clip = vcd30_event;
    VCD_30 = 0;

    /* Flush cache */
    UTIL_flushcache(0x30, 8*1024);
	
    VCD30_event = vcd30_event;

    asm("addi %0,#0,r29" : : "r" (stack));
    VBV_size = MPEG_VBV_size;
    pic_height = 0;
    pic_width = 0;
    list_previous_list_offset = -1;
    list_next_list_offset = -1;
    cur_list_state = 0;
	
    DSC_toggle();
    initialization();
    
    if (vcx_scn_height != old_vcx_scn_height) 
	DISP_change_TV();

    DBG_allocate_trace_buffer();
#ifdef ECHO
    /* reset mix pointers, so it does not produce audio noise. */
    MIX_init();
    /*
     * For 3881/3883, we turn off MIC when going to 3.0 (for better
     * audio quality, so MIC_is_turned_on is 0. Therefore,
     * MIC_is_turned_on is only good for 3207/3209
     */
    if ((MIC_is_turned_on || DSC_version) && (vcx_echo >= 0)) {
	MIC_init();	
	MIC_start_take_in();
    }

#endif
    TSK_main();
}
#endif

⌨️ 快捷键说明

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