📄 plays.c
字号:
/* Copyright 1998-1999, ESS Technology, Inc. */
/* SCCSID @(#)plays.c 4.131.1.48 03/16/05 */
/*
* This is based on version 1.338(09/22/98) of play.c.
* For SONY, Matsushita(Panasonic) and Samsung direct servo control
* (i.e. CXDSERVO, MSERVO and SAM_SRV, respectively)
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "vcxi.h"
#include "buffer.h"
#include "cd.h"
#include "memmap.h"
#include "const.h"
#include "audio.h"
#include "debug.h"
#include "display.h"
#include "mpeg1vid.h"
#include "util.h"
#include "low.h"
#include "dsa.h"
#include "ir.h"
#include "tdm.h"
#include "keydef.h"
#include "timedef.h"
#include "vcd.h"
#include "micro.h"
#include "play.h"
#include "digest.h"
#include "av_play.h"
#include "kara.h"
#include "panel.h"
#include "xport.h"
#include "zoom.h"
#include "filesys.h"
#include "nav_menu.h"
#include "servo.h"
#if defined(ABNORMAL_VCD) || defined(ANTI_SHOCK)
#include "pts.h"
#endif
#ifdef TWO_FIELDS_OSD
#include "cg.h"
#else
#include "fsosd.h"
#endif
#ifdef EQUALIZER
#include "eq.h"
#endif
#ifdef ECHO
#include "echo.h"
#endif
#ifdef REAL_CLOCK
#include "realclk.h"
#endif
#ifdef MZOOM
#include "mzoom.h"
#endif
#ifdef CD_TEXT
#include "cd_text.h"
#endif
#ifdef CDG
#include "cdg.h"
#endif
#ifdef FLESHTONE
#include "fshtone.h"
#endif
#ifdef DATA_CD
#ifdef ID3
#include "id3.h"
#endif
#include "vp.h"
#include "mp3.h"
#include "mpgaudio.h"
#endif
#if (defined(MIC_RECORD) || defined(ANTI_SHOCK))
#include "recorder.h"
#include "vp.h"
#endif
#if (defined INES_CD || defined VGB_CD)
#include "game.h"
#endif
#ifdef GDTSERVO
#include "servogdt.h"
#endif
/************************************************************************
* Debugging
************************************************************************/
#if 0
int bpt;
#define BREAKPOINT(x) {bpt=x;while(bpt) VCX_service();}
#else
#define BREAKPOINT(x)
#endif
#undef PRINTF
#if 0
#define PRINTF(s) printf s
#else
#define PRINTF(s)
#endif
DEBUGVAR(play_deadlock, 0);
DEBUGVAR(selection_deadlock, 0);
/************************************************************************
* PLAY related options *
************************************************************************/
#if 0 /* NOT_USED */
#define NO_AUTO_PLAY
#define START_IN_PBC_OFF /* always start in PBC-off mode */
#define CLEAR_JPEG /* clear jpeg when stopped */
#define LOGO4CDDA /* display logo when playing CDDA */
#endif
#define ABS_GOTO_OVERRIDES_PROGRAM /* abs. goto will cancel program mode */
#define VOLUME_CONTROL
#define ZOOM_IN_OUT_SAME_KEY
#define SCREEN_ON_TIME_SAME_KEY
#define SHOW_LOGO_AT_STOP
#define STOP_RETURN_SAME_KEY
#ifdef STOP_RETURN_SAME_KEY
#undef RETURN_KEY
#define RETURN_KEY STOP_KEY
#endif
#ifdef I2C_E2PROM
unsigned char SaveDisc[] = "DISC: ";
uchar OldMin;
uchar step,StopKey;
uchar DISCindex, FlagSaveData;
uint DiscAddr;
extern uchar EepromErr;
uint Track0;
#ifdef FIVE_DISC_POWERRESUME
/***************************************************************************
E2PROM storage positions .
(01) : Storage STARTUP_INDEX
(02 - 04) : Storage disc0 ID
(05 - 07) : Storage disc1 ID
(08 - 10) : Storage disc2 ID
(11 - 13) : Storage disc3 ID
(14 - 16) : Storage disc4 ID
(20 - 31) : Storage disc0 INFORMATION 14-1F
(32 - 43) : Storage disc1 INFORMATION 20-2B
(44 - 55) : Storage disc2 INFORMATION 2C-37
(56 - 67) : Storage disc3 INFORMATION 38-43
(68 - 79) : Storage disc4 INFORMATION 44-4F
****************************************************************************/
#define STARTUP_INDEX 1
#define STARTUP_DISC1 2
#define STARTUP_DISC2 5
#define STARTUP_DISC3 8
#define STARTUP_DISC4 11
#define STARTUP_DISC5 14
#define STARTUP_INFO_STAE 0
#define STARTUP_PIC_HEIGHT 1
#define STARTUP_PIC_RES 2
#define STARTUP_TRACK 3
#define STARTUP_MIN 4
#define STARTUP_SEC 5
#define STARTUP_FRAME 6
#define STARTUP_PSD_OFFSET_H 7
#define STARTUP_PSD_OFFSET_L 8
#define STARTUP_PLAY_LIST_PLAY_ITEM_NUMVER_H 9
#define STARTUP_PLAY_LIST_PLAY_ITEM_NUMVER_L 10
#define STARTUP_PLAY_AUDIO_LEVEL 11
int SaveTime;
void SaveDiscNo(uchar Disc);
uint LoadDiscNo(uchar Disc);
#else
/***************************************************************************
E2PROM storage positions (0 to 127) for setup menu.
(65 - 97) : STARTUP INFORMATION (only if POWERUP_RESUME)
****************************************************************************/
#define STARTUP_INFO_STAE 11
#define STARTUP_PIC_HEIGHT 12
#define STARTUP_PIC_RES 13
#define STARTUP_TRACK 14
#define STARTUP_MIN 15
#define STARTUP_SEC 16
#define STARTUP_FRAME 17
#define STARTUP_PSD_OFFSET_H 18
#define STARTUP_PSD_OFFSET_L 19
#define STARTUP_PLAY_LIST_PLAY_ITEM_NUMVER_H 20
#define STARTUP_PLAY_LIST_PLAY_ITEM_NUMVER_L 21
#define RESUME_PBC_FLAG 22
int SaveTime;
int resume_flag = 0;
#endif FIVE_DISC_POWERRESUME
#endif I2C_E2PROM
/* ======================= BEGIN customer section =========================*/
/*------------------------------------------------------------------------
Fastforwar and Fastreverse variables and difinitions.
------------------------------------------------------------------------*/
/* Definition of Fastforwar and fastrewind speed. */
#define FAST_SPEED_LIMIT 4
#define SLOW_MOTION_LIMIT 3
/* Fast forward/backward interval in secs (BCD) */
static char fast_fram_amount_ary[FAST_SPEED_LIMIT]
= {0x02, 0x05, 0x10, 0x20};
static unsigned char slow_motion_ary[SLOW_MOTION_LIMIT]
= {6, 10, 14}; /* num of displaying field time. For example,
* if the number is 4, the each picture will
* be displayed 4 field time. Normal field
* time for NTSC pictures is 2. */
extern int bad_track_len; /* bad audio frame counter defined in
* mpgaudio.c */
/*------------------------------------------------------------------------
Define the intro interval.
------------------------------------------------------------------------*/
#define INTRO_TIME_MMSSFF 0x001000 /* 10 seconds */
/* Define number of entries in PLAY_MENU_STATE */
#define SELECT_INTRO 1
#define SELECT_DISC 2
#define SELECT_TRACK 3
#define SELECT_GAME 4
#define NUM_OF_ENTRY 4
#define SELECT_EXIT 4
/* ======================= END customer section =========================*/
/*-------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------*/
void time_display_reset(void);
static int PLAY_track_at_time(int track, int rel_time);
static void play_item(int playitem_number);
static void play_track(int track_number);
static void play_entry(int entry_number);
static void play_segment(int segment_number);
static void play_entry_in_track(int entry_number);
static int change_to_trick_mode(int key);
#ifdef GAMEBOY
static void play_game(int playitem_number);
#endif
#ifdef ABSOLUTE_GOTO_TIME
static int PLAY_absolute(int);
#endif
#ifdef REVERB
static void RVB_toggle_mode(void);
#endif
/* utilities functions */
static void assign_selection_list(unsigned char *scratch);
static void assign_play_list(unsigned char *scratch);
#ifdef GAMEBOY
static void assign_game_list(unsigned char *scratch);
#endif
static void compute_cd_total_remain(void);
static int find_track_number(int track_number);
static int get_next_track();
static int peek_next_track();
static int get_previous_track();
static int get_track_time(int, int *, int *);
static int is_time_expired(unsigned int begin_time, short expire_time);
static int processVCD();
static void programRemoveTrack(void);
static void programAddTrack(int track);
static void init_PBC_on();
static void change_sequence_mode(int mode);
static void disp_stop_LCD(void);
static void disp_cd_info_LCD(void);
static void display_cddigest_osd(int track);
static void check_entry_number(int track_number, int starttime);
/* process key functions */
static void process_close_key();
static void post_process_close_tray();
static void process_open_key();
static void process_PBC_key();
void process_power_off_key(void);
static int process_resume_key(void);
static void process_stop_key();
static int process_zoom_key();
/* play state machine functions */
static int change_play_state();
static int play_state_machine();
static void goto_digest_track_segment(int selection_num);
static void PLAY_update_osd(void);
static void init_machine(); /* Liang Weihua */
static void save_resume_time(void);
static void save_resume_info(void);
static void restore_resume_track_time(void);
static void initCD_finished();
#ifdef ZOOM
void set_zoom(void);
#endif
static void PLAY_fill_volumebarbuf(int);
static int Data_File_end_of_play();
#ifdef EQUALIZER
static int process_EQ_key(int);
#endif
#ifdef DATA_CD
static int Is_DATA_CD(void);
static void get_next_data_track(void);
static void get_prev_data_track(void);
#ifdef JPEG_DGST
static int get_jpeg_track(int);
#endif /* JPEG_DGST */
#endif
#ifdef SCENE
static int process_scene_key(void);
static void update_scene_number(void);
#endif /*SCENE*/
#ifdef MSERVO
EXPORT void DSP_Data_Write(int data);
#endif
#ifdef ABNORMAL_VCD
EXPORT int calc_bitrate(int, int);
#endif
#ifdef CDG
static void Is_CDG_Disc(void);
#endif
#ifdef REVERB
static void RVB_turn_on(int);
#endif
#ifdef I2C_E2PROM
extern int i2c_e2prom_bywrite(uchar, uchar);
#endif I2C_E2PROM
/*-------------------------------------------------------------
Definitions
-------------------------------------------------------------*/
#define TurnOffTDM system_reset
#ifdef NO_MICRO
#define PANEL_PLAY_INDEX(a)
#else
#define PANEL_PLAY_INDEX(a) panel_play_index(a)
#endif
/* definitions for play mode */
#define PLAY_INFO_STOP_MODE 1
#define PLAY_INFO_PLAYING_MODE 2
#define PLAY_INFO_PAUSE_MODE 3
/* definitions for events */
#define NULL_EVENT 0
#define NEW_LIST_EVENT 1
#define WAIT_TIME_EXPIRED_EVENT 2
#define LOOP_COUNT_EVENT 3
#define PREVIOUS_KEY_EVENT 4
#define REPEAT_OFF 0
#define REPEAT_ONE 1
#define REPEAT_ALL 2
#define RESUME_EMPTY 0
#define RESUME_SAVED 1
#define RESUME_RESTORE 2
#define RESUME_SUCCESS 3
#define RESUME_FAILURE 4
/* for VCD_ptr_resume_info->state */
#define VOCAL_LEFT_LEFT 3
#define VOCAL_RIGHT_RIGHT 4
#define DIGEST_TRACK_PIC_LIMIT 9
#ifdef MP3_PROGRAM
#define MAX_TRACK_NUMBER 30
#define MAX_PROGRAM_TRACKS 20
#else MP3_PROGRAM
#define MAX_TRACK_NUMBER 99
#define MAX_PROGRAM_TRACKS 99
#endif MP3_PROGRAM
/* For OSD message buffers */
#define SPEED_POS 4
#define SLOW_SPEED_POS 5
#define SEL_NUM_POS 8
#ifdef USE_CN_HEADER
#define CSPEED_POS 6
#define CSLOW_SPEED_POS 5
#define CSEL_NUM_POS 6
#else
#define CSPEED_POS 4
#define CSLOW_SPEED_POS 3
#define CSEL_NUM_POS 4
#endif /* USE_CN_HEADER */
/* Play control variables */
unsigned int seg_sel = 0; /* Use in segment play (select E1 (1) *
* E2 (2), or E0 (0) */
#ifdef FAST_MODE_CONTROL
int fast_mode_ctrl = 0;
#endif
/*------------------------------------------------------------------------
* Variables for display. If we want to save memory, we can use common
* buffer for all osd display.
*------------------------------------------------------------------------*/
static unsigned char *osd_msg;
#ifdef BILINGUAL_OSD
static unsigned char *c_osd_msg;
#endif
static unsigned char osd_region = OSD_FUNCTION_STATUS_REGION; /* default region */
static unsigned char osd_timeout = DISPLAY_TIME_OUT; /* default timeout */
static unsigned char sel_buf[] = "SELECT ";
static unsigned char FF_buf[] = "FF X1 ";
static unsigned char FR_buf[] = "FR X1 ";
#ifdef SONY3D
static unsigned char disc_buf[] = "DISC ";
#endif
static unsigned char slow_buf[] = "SLOW ";
static unsigned char clear_msg[] = {FONT_BLANK,0};
static unsigned char error_msg[] = "#"; /* Show a hand */
#ifdef KARASC
static unsigned char ksc_buf[] = "KARAOKE SCORE: ";
#endif KARASC
#ifdef SCENE
static unsigned char scene_buf[] = "SCENE ----";
#endif
#ifdef BILINGUAL_OSD
#ifdef USE_CN_HEADER
static unsigned char c_slow_buf[] = {
CN_HEADER, CN_MAN4, CN_HEADER, CN_FANG4, ' ', ' ', ' ', '\0'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -